📄 slicetool.m
字号:
'slicetool(''doit'')','position',[xnow,ynow,width,height]); % make a quit button xnow=sep+width+xnow; hquit = uicontrol('style','pushbutton','string','Quit','callback',... 'slicetool(''quit'')','position',[xnow,ynow,width,height]); % make a message box xnow=sep+width+xnow; ynow=sep; figGeom = get(gcf,'position'); width = figGeom(3)-width-5*sep; height=20; hmessage = uicontrol('style','text','string','','position',[xnow,ynow,width,height]); %make zoom scroll buttons ynow=ynow+height+sep; xnow=sep; width=40; hright=uicontrol('style','pushbutton','string','Right',... 'callback','slicetool(''right'')','visible','off',... 'position',[xnow,ynow,width,height]); ynow=ynow+height+sep; hleft=uicontrol('style','pushbutton','string','Left',... 'callback','slicetool(''left'')','visible','off',... 'position',[xnow,ynow,width,height]); ynow=ynow+height+sep; hdown=uicontrol('style','pushbutton','string','Down',... 'callback','slicetool(''down'')','visible','off',... 'position',[xnow,ynow,width,height]); ynow=ynow+height+sep; hup=uicontrol('style','pushbutton','string','Up',... 'callback','slicetool(''up'')','visible','off',... 'position',[xnow,ynow,width,height]); %see what kind of an object we have test=objget(object,'objtype'); if(strcmp(test,'cont')) set(hmessage,'userdata',object); object=objget(object,'randobj'); else co=contobj(objget(object,'name'),'slce'); co=objset(co,'randobj',object); file=contobj('file','prvt'); file=objset(file,'filename','undefined'); file=objset(file,'pathname',' '); co=objset(co,'file',file); set(hmessage,'userdata',co); co=[]; end set(hdoit,'userdata',object);% make the output menu houtput = uimenu(gcf,'label','File'); hallcurves = uimenu(houtput,'Label','Save','callback',... 'slicetool(''save'')'); hsaveas = uimenu(houtput,'Label','Save As','callback',... 'slicetool(''saveas'')','userdata',p); hcurrcurves = uimenu(houtput,'Label','Save Current Curves','callback',... 'slicetool(''out'')'); hcurrpoly = uimenu(houtput,'Label','Save Current Poly Coeffs','callback',... 'slicetool(''out'')','enable','off'); houtopts = uimenu(houtput,'label','Output Options'); houtcurve = uimenu(houtopts,'label','Output as Simple Curve','callback',... 'slicetool(''exboolean'')','checked','off','enable','off'); houtobj = uimenu(houtopts,'label','Output as Object','callback',... 'slicetool(''exboolean'')','checked','on','userdata',... [2 houtcurve]); set(houtcurve,'userdata',[1 houtobj]); hmatfile = uimenu(houtopts,'label','In Matlab File Format','callback',... 'slicetool(''exboolean'')','checked','on'); hascii = uimenu(houtopts,'label','In ASCII File Format','callback',... 'slicetool(''exboolean'')','checked','off','userdata',... [2 hmatfile],'enable','off'); hshowfile= uimenu(houtopts,'label','Show Save File','callback',... 'slicetool(''showfile'')'); set(hmatfile,'userdata',[1 hascii]); set(houtopts,'userdata',[houtcurve,houtobj,hmatfile,hascii]); hhardcopy = uimenu(houtput,'Label','Hard Copy','callback',... 'slicetool(''Hardcopy'')','userdata',p(1:2)); % make the options menu hoptions = uimenu(gcf,'Label','Options'); hhold=uimenu(hoptions,'label','Hold Plot','callback',... 'slicetool(''boolean'')'); if(p(3)) chk='on'; else chk='off'; end hflipx=uimenu(hoptions,'label','Flip X','callback','slicetool(''boolean'')',... 'checked',chk); if(p(4)) chk='on'; else chk='off'; end hflipy=uimenu(hoptions,'label','Flip Y','callback','slicetool(''boolean'')',... 'checked',chk); if(p(5)) chk='on'; else chk='off'; end hgrid=uimenu(hoptions,'label','Grid','callback','slicetool(''boolean'')',... 'userdata',smfig,'checked',chk); if(p(6)) chk='on'; else chk='off'; end hscatter=uimenu(hoptions,'label','Scatter Plot','callback',... 'slicetool(''boolean'')','userdata','slicetool','checked',chk,... 'separator','on'); hptsize=uimenu(hoptions,'label','Scatter Plot Pt Size','userdata',p(7)); if(p(7)==6) chk='on'; else chk='off'; end hpt6=uimenu(hptsize,'label','6','checked',chk,... 'callback','slicetool(''exboolean'')'); if(p(7)==9) chk='on'; else chk='off'; end hpt9=uimenu(hptsize,'label','9','checked',chk,... 'callback','slicetool(''exboolean'')'); if(p(7)==12) chk='on'; else chk='off'; end hpt12=uimenu(hptsize,'label','12','checked',chk,... 'callback','slicetool(''exboolean'')'); if(p(7)==18) chk='on'; else chk='off'; end hpt18=uimenu(hptsize,'label','18','checked',chk,... 'callback','slicetool(''exboolean'')'); if(p(7)==28) chk='on'; else chk='off'; end hpt28=uimenu(hptsize,'label','28','checked',chk,... 'callback','slicetool(''exboolean'')'); if(p(7)==50) chk='on'; else chk='off'; end hpt50=uimenu(hptsize,'label','50','checked',chk,... 'callback','slicetool(''exboolean'')'); set(hpt6,'userdata',[-6 hptsize hpt9 hpt12 hpt18 hpt28 hpt50]); set(hpt9,'userdata',[-9 hptsize hpt6 hpt12 hpt18 hpt28 hpt50]); set(hpt12,'userdata',[-12 hptsize hpt6 hpt9 hpt18 hpt28 hpt50]); set(hpt18,'userdata',[-18 hptsize hpt6 hpt9 hpt12 hpt28 hpt50]); set(hpt28,'userdata',[-28 hptsize hpt6 hpt9 hpt12 hpt18 hpt50]); set(hpt50,'userdata',[-50 hptsize hpt6 hpt9 hpt12 hpt18 hpt28]); hnumcolors=uimenu(hoptions,'label','Number of Colors','userdata',p(28)); if(p(28)==6) chk='on'; else chk='off'; end hc6=uimenu(hnumcolors,'label','6','checked',chk,... 'callback','slicetool(''exboolean'')'); if(p(28)==9) chk='on'; else chk='off'; end hc9=uimenu(hnumcolors,'label','9','checked',chk,... 'callback','slicetool(''exboolean'')'); if(p(28)==12) chk='on'; else chk='off'; end hc12=uimenu(hnumcolors,'label','12','checked',chk,... 'callback','slicetool(''exboolean'')'); if(p(28)==18) chk='on'; else chk='off'; end hc18=uimenu(hnumcolors,'label','18','checked',chk,... 'callback','slicetool(''exboolean'')'); if(p(28)==24) chk='on'; else chk='off'; end hc24=uimenu(hnumcolors,'label','24','checked',chk,... 'callback','slicetool(''exboolean'')'); if(p(28)==30) chk='on'; else chk='off'; end hc30=uimenu(hnumcolors,'label','30','checked',chk,... 'callback','slicetool(''exboolean'')'); set(hc6,'userdata',[-6 hnumcolors hc9 hc12 hc18 hc24 hc30]); set(hc9,'userdata',[-9 hnumcolors hc6 hc12 hc18 hc24 hc30]); set(hc12,'userdata',[-12 hnumcolors hc6 hc9 hc18 hc24 hc30]); set(hc18,'userdata',[-18 hnumcolors hc6 hc9 hc12 hc24 hc30]); set(hc24,'userdata',[-24 hnumcolors hc6 hc9 hc12 hc18 hc30]); set(hc30,'userdata',[-30 hnumcolors hc6 hc9 hc12 hc18 hc24]); if(p(8)) chk='on'; else chk='off'; end hscale=uimenu(hoptions,'label','1-0 (Max-Min) Scaling','callback',... 'slicetool(''boolean'')','checked',chk); if(p(9)) chk='on'; else chk='off'; end hautopro=uimenu(hoptions,'label','Auto Promote','checked',chk,... 'callback','slicetool(''boolean'')','separator','on'); if(p(27)) chk='on'; else chk='off'; end hautoident=uimenu(hoptions,'label','Auto Identify','checked',chk,... 'callback','slicetool(''boolean'')'); if(p(10)) chk='on'; else chk='off'; end hpolydisp=uimenu(hoptions,'label','Display Poly Coefs','checked',chk,... 'callback','slicetool(''boolean'')'); if(p(11)) chk='on'; else chk='off'; end hpolyeval=uimenu(hoptions,'label','Evaluate Poly Locally','checked',chk,... 'callback','slicetool(''boolean'')'); haltlabels=uimenu(hoptions,'label','Alt Axis Labels','separator','on'); if(p(12)) chk='on'; else chk='off'; end haltx=uimenu(haltlabels,'label','X Axis','callback','slicetool(''altlabelx'')',... 'checked',chk,'userdata',p(13)); if(p(14)) chk='on'; else chk='off'; end halty=uimenu(haltlabels,'label','Y Axis','callback','slicetool(''altlabely'')',... 'checked',chk,'userdata',p(15)); hcomplex=uimenu(hoptions,'label','Complex Data'); if(p(16)==1) chk='on'; else chk='off'; end hamplin=uimenu(hcomplex,'label','Linear Amplitude Spectrum','callback',... 'slicetool(''complex'')','userdata',1,'checked',chk); if(p(16)==2) chk='on'; else chk='off'; end hampdb=uimenu(hcomplex,'label','Decibel Amplitude Spectrum','callback',... 'slicetool(''complex'')','userdata',2,'checked',chk); if(p(16)==3) chk='on'; else chk='off'; end hphase=uimenu(hcomplex,'label','Phase Spectrum','callback',... 'slicetool(''complex'')','userdata',3,'checked',chk); if(p(16)==4) chk='on'; else chk='off'; end hampphs=uimenu(hcomplex,'label','Amp&Phase Spectra','callback',... 'slicetool(''complex'')','userdata',4,'checked',chk); if(p(16)==5) chk='on'; else chk='off'; end hrealimag=uimenu(hcomplex,'label','Real&Imag Spectra','callback',... 'slicetool(''complex'')','userdata',5,'checked',chk); set(hcomplex,'userdata',[2 hamplin hampdb hphase hampphs hrealimag]); % make the actions menu hactions = uimenu(gcf,'label','Actions');% % to add a new action to the list, you must do the following% 1) make a menu item for it by modifying one of those below. If its setting is to be% exclusive (like plot,zoom,...identify) make sure its user data is the next largest% integer not already used as user data. It can have other userdata, but the first % element of the userdata matrix must be this integer. Otherwise make it like the mode setting.% 2) If it's an exclusive action, enter its handle at the end of the list of the userdata% items for hactions. Otherwise, put it's handle in the list of the figure's user data% like hmode.% 3) Modify the if-elseif switch in the 'actions' code block to take the action appropriate% when the menu item is selected. This may be just setting some flags and enabling the% doit button (as in plot or unzoom) or it might require setting the windowbutton functions% as in zoom, pickslope,... identify.% 4) If the action requires the user to press the doit button, then add an appropriate case% to the if-elseif block in the 'doit' code block% 5) if the action uses the mouse, then add appropriate code to the 'buttondown' & % 'buttonup' code blocks% 6) if it affect the plot, you may have to change the 'plot' code block% hplot = uimenu(hactions,'label','Plot','callback',... 'slicetool(''actions'')','userdata',1,'checked','on'); hpickslopes = uimenu(hactions,'label','Pick Slopes','callback',... 'slicetool(''actions'')','userdata',4,'checked','off'); hpolyfit=uimenu(hactions,'label','Poly Fit','callback',... 'slicetool(''actions'')','userdata',5,'checked','off'); hpolygen=uimenu(hactions,'label','Poly Gen','callback',... 'slicetool(''polygen'')','userdata',9,'checked','off'); hidentify=uimenu(hactions,'label','Identify','callback',... 'slicetool(''actions'')','userdata',6,'checked','off'); halgebra=uimenu(hactions,'label','Curve Algebra','userdata',7,... 'callback','slicetool(''algebra'')','checked','off'); hsmooth=uimenu(hactions,'label','Smooth','userdata',10,... 'callback','slicetool(''smooth'')','checked','off'); hderiv=uimenu(hactions,'label','Derivative','userdata',11,... 'callback','slicetool(''deriv'')','checked','off'); hpromote=uimenu(hactions,'label','Promote/Delete','userdata',8,... 'callback','slicetool(''promote'')'); hzoom = uimenu(hactions,'label','Zoom','callback',... 'slicetool(''zoom'')','userdata',2,'checked','off',... 'separator','on'); hunzoom = uimenu(hactions,'label','unZoom','callback',... 'slicetool(''unzoom'')','userdata',3,'checked','off'); hmode=uimenu(hactions,'label','Mode','userdata',1,... 'separator','on'); if(p(17)==1) chk='on'; else chk='off'; end hnormal = uimenu(hmode,'label','Normal','userdata',1,'callback',... 'slicetool(''mode'')','checked',chk); if(p(17)==2) chk='on'; else chk='off'; end htransform = uimenu(hmode,'label','Transform','userdata',2,'callback',... 'slicetool(''mode'')','checked',chk); htransoptions = uimenu(hmode,'label','Transform Options'); hzeromean = uimenu(htransoptions,'label','Remove Mean','checked','on',... 'callback','slicetool(''boolean''),slicetool(''zerotranstore'')'); hzeropad = uimenu(htransoptions,'label','Zero Pad','checked','on',... 'callback','slicetool(''boolean''),slicetool(''zerotranstore'')'); hburg = uimenu(htransoptions,'label','Burg Spectrum','checked','off',... 'callback','slicetool(''boolean''),slicetool(''zerotranstore'')'); hburgorder = uimenu(htransoptions,'label','Burg Order'); hburg6 = uimenu(hburgorder,'label','L=6','checked','off','callback',... 'slicetool(''setorder''),slicetool(''zerotranstore'')','userdata',6); hburg8 = uimenu(hburgorder,'label','L=8','checked','off','callback',... 'slicetool(''setorder''),slicetool(''zerotranstore'')','userdata',8); hburg10 = uimenu(hburgorder,'label','L=10','checked','off','callback',... 'slicetool(''setorder''),slicetool(''zerotranstore'')','userdata',10); hburg12 = uimenu(hburgorder,'label','L=12','checked','on','callback',... 'slicetool(''setorder''),slicetool(''zerotranstore'')','userdata',12); hburg16 = uimenu(hburgorder,'label','L=16','checked','off','callback',... 'slicetool(''setorder''),slicetool(''zerotranstore'')','userdata',16); hburg20 = uimenu(hburgorder,'label','L=20','checked','off','callback',... 'slicetool(''setorder''),slicetool(''zerotranstore'')','userdata',20); hburg26 = uimenu(hburgorder,'label','L=26','checked','off','callback',... 'slicetool(''setorder''),slicetool(''zerotranstore'')','userdata',26); hburg32 = uimenu(hburgorder,'label','L=32','checked','off','callback',... 'slicetool(''setorder''),slicetool(''zerotranstore'')','userdata',32); % the bizarre userdata below allows the use of order values that are not simple % sequential integers. When the second integer is negative, that is a flag % for non-sequential ordering. set(hburgorder,'userdata',[12 -8 [6 8 10 12 16 20 26 32] hburg6 hburg8 hburg10 hburg12 hburg16 hburg20... hburg26 hburg32]); set(htransoptions,'userdata',[hzeromean hzeropad hburg hburgorder]); set(hmode,'userdata',[1 hnormal htransform htransoptions]); hpolyorder=uimenu(hactions,'label','Poly Order'); % make a shitload of submenus for hpolyorder if(p(18)==1) chk='on'; else chk='off'; end hpoly1=uimenu(hpolyorder,'label','order 1','checked',chk,'callback',... 'slicetool(''setorder'')','userdata',1); if(p(18)==2) chk='on'; else chk='off'; end hpoly2=uimenu(hpolyorder,'label','order 2','checked',chk,'callback',... 'slicetool(''setorder'')','userdata',2); if(p(18)==3) chk='on'; else chk='off'; end hpoly3=uimenu(hpolyorder,'label','order 3','checked',chk,'callback',... 'slicetool(''setorder'')','userdata',3); if(p(18)==4) chk='on'; else chk='off'; end hpoly4=uimenu(hpolyorder,'label','order 4','checked',chk,'callback',... 'slicetool(''setorder'')','userdata',4); if(p(18)==5) chk='on'; else chk='off'; end hpoly5=uimenu(hpolyorder,'label','order 5','checked',chk,'callback',... 'slicetool(''setorder'')','userdata',5); if(p(18)==6) chk='on'; else chk='off'; end hpoly6=uimenu(hpolyorder,'label','order 6','checked',chk,'callback',... 'slicetool(''setorder'')','userdata',6); if(p(18)==7) chk='on'; else chk='off'; end hpoly7=uimenu(hpolyorder,'label','order 7','checked',chk,'callback',... 'slicetool(''setorder'')','userdata',7); if(p(18)==8) chk='on'; else chk='off'; end hpoly8=uimenu(hpolyorder,'label','order 8','checked',chk,'callback',... 'slicetool(''setorder'')','userdata',8); if(p(18)==9) chk='on'; else chk='off'; end hpoly9=uimenu(hpolyorder,'label','order 9','checked',chk,'callback',... 'slicetool(''setorder'')','userdata',9); set(hpolyorder,'userdata',[1 hpoly1 hpoly2 hpoly3 hpoly4 hpoly5 hpoly6 hpoly7... hpoly8 hpoly9]); set(hactions,'userdata',[1 hplot,hzoom,hunzoom,hpickslopes,hpolyfit,... hidentify, halgebra, hpromote hpolygen hsmooth hderiv]); hslopetools = uimenu(hactions,'label','Slope Tools','Userdata',1); if(p(19)==1) chk='on'; else chk='off'; end hslopedisplay = uimenu(hslopetools,'label','Simple Display',... 'callback','slicetool(''exboolean'');slicetool(''resetslopetool'')'... ,'checked',chk); if(p(19)==2) chk='on'; else chk='off'; end hmagdepth = uimenu(hslopetools,'label','Magnetic Depth (Peters)','checked',... chk,'callback',... 'slicetool(''exboolean'');slicetool(''resetslopetool'')'); set(hslopedisplay,'userdata',[-1 hslopetools hmagdepth]); set(hmagdepth,'userdata',[-2 hslopetools hslopedisplay]); % % userdata for hdefineqn is [a b m n] where the equation is of the form % a*(curve1).^m + b*(curve2).^n % hdefineqn= uimenu(hactions,'label','Algebra Equation','callback',... 'slicetool(''defineqn'')','userdata',p(20:24)); % % userdata for hdefinesm is [n flag] % n is no.of pts., flag is 1 for box, 2 for triangle % hdefinesm= uimenu(hactions,'label','Smoother Type','callback',... 'slicetool(''definesm'')','userdata',p(29:30)); % make the xaxis & yaxis menu hxaxis = uimenu(gcf,'label','X_Data'); hyaxis = uimenu(gcf,'label','Y_Data'); % loop over number of items in object and load into menu names=objget(object,'namesmatrix'); [ndata,c]=size(names); xhandles=zeros(1,ndata); yhandles=zeros(1,ndata); for k=1:ndata thisname=names(k,:); ind=find(abs(thisname)==1); if( ~isempty(ind) ) thisname=thisname(1:ind(1)-1); end xhandles(k) = uimenu(hxaxis,'label',thisname,... 'callback','slicetool(''xdata'')'); %'userdata',k,'callback','slicetool(''xdata'')'); yhandles(k) = uimenu(hyaxis,'label',thisname,... 'callback','slicetool(''ydata'')'); %'userdata',k,'callback','slicetool(''ydata'')'); end hxoption = uimenu(hxaxis,'label','Option'); if(p(25)==1) chk='on'; else chk='off'; end hxaccum = uimenu(hxoption,'label','Accumulate Selections',... 'callback','slicetool(''dataoption'')','userdata',1,... 'checked',chk); if(p(25)==2) chk='on'; else chk='off'; end hexclude = uimenu(hxoption,'label','Exclusive Selections',... 'callback','slicetool(''dataoption'')','userdata',2,... 'checked',chk); set(hxoption,'userdata',[p(25) hxaccum hexclude]); hyoption = uimenu(hyaxis,'label','Option'); if(p(26)==1) chk='on'; else chk='off'; end hyaccum = uimenu(hyoption,'label','Accumulate Selections',... 'callback','slicetool(''dataoption'')','userdata',1,... 'checked',chk); if(p(26)==2) chk='on'; else chk='off'; end heyclude = uimenu(hyoption,'label','Exclusive Selections',... 'callback','slicetool(''dataoption'')','userdata',2,... 'checked',chk); set(hyoption,'userdata',[p(26) hyaccum heyclude]); %set x and y axis defaults % make the first item in the object the x axis set(xhandles(1),'checked','on'); set(hxaxis,'userdata',[ndata xhandles hxoption 1]); % make the third item in the object the y axis if( length(yhandles) >= 3 ) set(yhandles(3),'checked','on'); ynum=3; elseif( length(yhandles) >= 2 ) set(yhandles(2),'checked','on'); ynum=2; else set(yhandles(1),'checked','on'); ynum=1; end set(hyaxis,'userdata',[ndata yhandles hyoption ynum]); % a couple of storage buckets htranstore = uicontrol('style','text','userdata',[],'visible','off'); hcmplxstore = uicontrol('style','text','userdata',[],'visible','off'); hpolystore = uicontrol('style','text','userdata',[],'visible','off'); % set the user data of the figure set(hfig,'userdata',[hdoit hoptions hflipx hflipy hhold hactions ... hxaxis hyaxis hquit hmode hmessage htranstore... hcmplxstore hgrid hcomplex hpolyorder houtput houtopts...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -