📄 slicetool.m
字号:
function slicetool(arg1,arg2)% SLICETOOL provides interactive 2-D viewing and manipulation of a random % Earth Object. Slicetool may be invoked in any of the following ways:% 1) slicetool % If no input, SLICETOOL puts up a file input panel which can be used% to direct the program to an object saved on disk. This should be a% MATLAB .mat file which can contain an object of any of the three types% mentioned above.%% 2) slicetool('extract') % causes SLICETOOL to put up a file input panel which is used to direct% the program to an ASCII file containing SEISLINE data and created by% EXTRACT_RASTERS. SLICETOOL will read this file and create and object% of type iii) (see below) which is then used to initiate automatically% a SLICEMASTER panel.% This method has been disabled by comment out the line which calls% the extract function.%% 3) slicetool(object) % invokes SLICETOOL for work on "object" which may be any of: % i) a random earth object, ii) a container object containing a single% random object whose datatype is 'line' and whose container label % (name) is 'randobj' and any number of other objects with auxiliary % information % iii) a container object containing any number of containers of type 'ii' % whose datatype has been set to 'slce'. In the latter two cases, % the containers should also store a container named 'file' which % has fields called 'filename' and 'pathname' to direct the saveing% of datasets. In case iii) SLICETOOL launches a control panel % called 'SLICEMASTER' from which any of the contained slices can% be launched in SLICETOOL windows and then pauses.%% Related MATLAB programs include EXTRACT, SEIS2WELL, GRIDTOOL, READZMAP, % and LOGSEC.%% by G.F. Margrave, Jan-March 1994 %% NOTE: It is illegal for you to use this software for a purpose other% than non-profit education or research UNLESS you are employed by a CREWES% Project sponsor. By using this software, you are agreeing to the terms% detailed in this software's Matlab source file. % BEGIN TERMS OF USE LICENSE%% This SOFTWARE is maintained by the CREWES Project at the Department% of Geology and Geophysics of the University of Calgary, Calgary,% Alberta, Canada. The copyright and ownership is jointly held by % its author (identified above) and the CREWES Project. The CREWES % project may be contacted via email at: crewesinfo@crewes.org% % The term 'SOFTWARE' refers to the Matlab source code, translations to% any other computer language, or object code%% Terms of use of this SOFTWARE%% 1) Use of this SOFTWARE by any for-profit commercial organization is% expressly forbidden unless said organization is a CREWES Project% Sponsor.%% 2) A CREWES Project sponsor may use this SOFTWARE under the terms of the % CREWES Project Sponsorship agreement.%% 3) A student or employee of a non-profit educational institution may % use this SOFTWARE subject to the following terms and conditions:% - this SOFTWARE is for teaching or research purposes only.% - this SOFTWARE may be distributed to other students or researchers % provided that these license terms are included.% - reselling the SOFTWARE, or including it or any portion of it, in any% software that will be resold is expressly forbidden.% - transfering the SOFTWARE in any form to a commercial firm or any % other for-profit organization is expressly forbidden.%% END TERMS OF USE LICENSE%note that arg2 is used by SLICEMASTER to provde its figure number to SLICETOOL.if( nargin < 2) smfig=[];else smfig=arg2;endif( nargin < 1) % get the input file [filename,path] = uigetfile('*.mat','Select Saved Session'); if( isempty(filename) ) error('no file name given'); end if( filename==0 ) error('no file name given'); end ind = findstr(filename,'.mat'); if( length(ind)>0 ) filename=filename(1:ind-1); else error(' invalid file extension'); end fullfilename = [path filename]; % load the file if( strcmp(computer,'MAC2') ) eval(['load ' filename]); else eval(['load ' fullfilename]); end %copy it into object eval(['object=' filename ';']); eval([filename '=[];']); % because all relevant variables are stored in this file, this will % restore them under their proper name. % set action to indicate this status action = 'initialize'; arg1=[]; endif( isstr(arg1) ) action = arg1;elseif( ~isempty(arg1) ) action='initialize'; object=arg1;end%test for extract invocationif(strcmp(action,'extract')) % make a temp figure htmp=figure('visible','off'); %ask for the extraction increment askthingsinit('slicetool(''extract2'')','Extract_rasters trace increment?',... '1'); return;end if(strcmp(action,'extract2')) a=askthingsfini; % test for cancel if( a== -1 ) error(' Trace increment not supplied'); end inc=sscanf(a,'%d');% get the input file [filename,path] = uigetfile('*.dat','Select extract_raster file'); if( isempty(filename) ) error('no file name given'); end if( filename==0 ) error('no file name given'); end ind = findstr(filename,'.dat'); if( isempty(length(ind)) ) error(' invalid file extension. Filename must be *.dat'); end fullfilename = [path filename]; % run extract %object=extract(fullfilename,inc); % EXTRACT creates a container object with multiple lines inside which will % cause slicetool to launch SLICEMASTER % set action to indicate this status action = 'initialize'; arg1=[]; delete(gcf); end if( strcmp(action,'initialize') )% test what kind of object we haveflag=objget(object,'objtype');if( strcmp(flag,'cont') ) % see if it has any slices in it test=objget(object,'namesmatrix','slce'); if( ~isempty(test) ) slicemaster(object); return; else test=objget(object,'namesmatrix','line'); if( isempty(test) ) error('unknown object in slicetool'); end endend % open up a new figure hfig = figcent(.6,.6); set(hfig,'menubar','none');%% userdata assignments%%hfig = handle of the main figure ... % [hdoit hoptions hflipx hflipy hhold hactions ...% hxaxis hyaxis hquit hmode hmessage htranstore...% hcmplxstore hgrid hcomplex hpolyorder houtput houtopts...% hpolystore hscale hslopetools hautopro halgebra hpromote...% hdefineqn hscatter hshowfile hsaveas hup hdown...% hleft hright hpolydisp hautoident haltlabels haltx...% halty hpolyeval hptsize hhardcopy hnumcolors hpolygen...% hsmooth hdefinesm hderiv]);%% hdoit = handle of the doit button ... the input object%% hoptions = handle of the options menu ... temp storage of windowbutton functions% while zooming%% hactions = handle of the actions menu ... a number indicating the current action% and a list of the submenu handles: [1 hplot,hzoom,hunzoom,hpickslopes,hpolyfit% ,hidentify]%% hidentify = handle of the identify action menu ... the number 7 followed by up% to 2n graphics handles (n== the number of data fields in the object). If ndisp% is the number of displayed fields, then there will be ndisp curve handles and% ndisp text label handles for the first subplot and the same for the second in a % second row of the userdata. If the is i subplot, then the size of the userdata% is [1,2*ndisp+1] and for 2 subplots it is [2,2*ndisp+1]. Position (2,1) is not% used.%% hzoom = handle of zoom menu ... the coordinates of the zoom box% % hpickslopes = handle of the pickslopes menu ... latest slope pick%% hpolyfit = handle of the polyfit menu ... athe number 6 followed by a vector of curve% handles and a vector of id numbers for the polynomila fits displayed on screen% Gets reset everytime a plot with no hold is made%% hpolystore = handle of the polynomial coeficients storage bin. ... a curve id number,% followed by an integer giving the number of coeficients, followed by that many % coeficients. This is repeated for any number of curves on screen. % Gets reset everytime a new polynomial fit is done.%% htransform = handle of the transform menu ... transforms of the displayed variables???%% hxaxis = handle of the x axis menu ... the number of data items, the handles of the% submenus, option menu handle, and the numbers of any that are checked (on)% [num vector_of_handles option_handle first_item second_item ...]% If there are n data fields in the object being displayed, and if the userdata is% called xinfo, then the numbers of the displayed data fields are given by% xinfo(n+3:2n+3) or equivalently xinfo(xinfo(1)+3:length(xinfo)) since % xinfo(1)==n.%% hyaxis = handle of the y axis menu ... the number of data items, the handles of the% submenus, and the numbers of any that are checked (on)% [num vector_of_handles first_item second_item ...]%% hmode = handle of the mode menu ... a number indicating the mode (1=normal, % 2=transform) and the handles of the submenus%% hmessage = handle of the message panel ...the original container object%% htranstore = handle of storage bucket for transfoms ... nx +ny columns of data% containing the complex transforms of the selected data%% hcmplxstore = handle of storage bucket for complex data ... nx +ny columns of data% processed as per the complex data option%% hgrid = handle of "grid on" menu ... the handle of the SLICEMASTER window (if any)% which is in control%% hcomplex = handle of the complex options menu ... integer indicating the current % option and handles of all of the sub menus:% [flag hamplin hampdb hphase hampphs hrealimag]%% hpolyorder = handle of the polynomial order menu ... number indicating the % current order and a vector of submenu handles%% hautopro = handle of the auto promotion option menu ... command to be called% after auto promotion% % halgebra = handle of the algebra menu ... integer indicationg the action and % handle of curve1 in the current equation%% hpromote = handle of the promote menu ... interger indicating the action and% handle of the curve to be promoted%% hdefineqn = handle of the define equation menu ... [a b m n flag] where tha% allowed equation is of the form: a*(curve1).^m +|* b*(curve2).^n% If flag ==1, then + is used or if flag==2 then * is used.%% hscatter = handle of the scatterplot boolean menu ... the string 'slicetool' to allow% positive id of the figure%% hshowfile ... not used%% hsaveas ... the SLICETOOL parameters%% hup ... not used%% hdown ... not used%% hleft ... not used%% hright ... not used%% hpolydisp ... not used%% hautoident ... not used%% haltlabels ... not used%% haltx ... name of the alternate label vector for the x axis%% halty ... name of the alternate label vector for the y axis%% hpolyeval ... not used%% hptsize ... the current scatterplot point size%% hhardcopy ... the last used scales for x & y%% hnumcolors ... the current number of colors%% hpolygen ... not used%% hsmooth ... handle of the smooth menu ... integer indicating the action and % handle of curve to be smoothed%% hdefinesm = handle of the define smoother menu ... [n flag] where % n is the number of points in the smoother, and flag for smoother type.% If flag ==1, then boxcar is used or if flag==2 then triangle is used.%% hderiv ... handle of the derivative menu ... integer indicating the action and % handle of curve to be derivatived% SLICETOOL saved parameters definition%% p(1) ... last xscale setting for hardcopy% p(2) ... last yscale setting for hardcopy% p(3) ... flipx setting% p(4) ... flipy setting% p(5) ... grid setting% p(6) ... scatterplot setting% p(7) ... scatterplot pt size% p(8) ... 1-0 scaling setting% p(9) ... auto promote setting% p(10) ... display poly coeffs setting% p(11) ... eval poly locally setting% p(12) ... alt x axis setting% p(13) ... number of the field proving the alternate x axis setting% p(14) ... alt y axis setting% p(15) ... number of the field proving the alternate y axis setting% p(16) ... complex data option number% p(17) ... mode option% p(18) ... polynomial order% p(19) ... number of the slope tool% p(20) ... algebra eqn 'a'% p(21) ... algebra eqn 'b'% p(22) ... algebra eqn 'm'% p(23) ... algebra eqn 'n'% p(24) ... algebra eqn type (1... add 2...mult)% p(25) ... y data option (0 for exclusive, 1 for accumulate)% p(26) ... x data option (0 for exclusive, 1 for accumulate)% p(27) ... autoidentify setting% p(28) ... number of colors% p(29) ... smoother length (number of points)% p(30) ... smoother type (1... box 2... triangle)%% These will be stored in a container object called 'parameters' which is in % another container called 'slicetool_settings'% Also in slicetool_settings will be 'data_settings' or dset % which will be a vector whose first entry tells the number of data fields and% where length(dset)=1+dset(1)*nentries where nentries is the number of saved% entries for each data vector. Currently, I plan to save:% xflag ... whether the menu is checked in xdata% yflag ... whether the menu is checked in ydata% r ... the red color value for this data % g ... the green color value for this data% b ... the blue color value for this data% Or five entries for each data vector.% see if there is a saved settings object sliceset=objget(object,'slicetool_settings'); if( ~isempty(sliceset) ) p=objget(sliceset,'parameters'); olp=length(p); if(olp<30) p=[p zeros(1,30-length(p))]; end if(olp<28) p(28)=6; end if(olp<29) p(29)=7; end if(olp<30) p(30)=1; end else % generate default parameters p=zeros(1,28); p(7)=12; p(16)=2; p(18)=1; p(19)=1; p(20)=1; p(21)=-1; p(22)=1; p(23)=1; p(24)=1; p(25:26)=[2 2]; p(28)=6; p(29)=7; p(30)=1; end % make a doit button sep=1; xnow=sep; ynow=sep; width=50; height=20; hdoit = uicontrol('style','pushbutton','string','Doit','callback',...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -