📄 segymat.m
字号:
function varargout = segymat(varargin)% segymat : Garphical User Interface for SegyMAT%% (C) 2001-2004 Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com% % SEGYMAT M-file for segymat.fig% SEGYMAT, by itself, creates a new SEGYMAT or raises the existing% singleton*.%% H = SEGYMAT returns the handle to a new SEGYMAT or the handle to% the existing singleton*.%% SEGYMAT('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in SEGYMAT.M with the given input arguments.%% SEGYMAT('Property','Value',...) creates a new SEGYMAT or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before segymat_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to segymat_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help segymat% Last Modified by GUIDE v2.5 27-Jul-2004 19:23:56% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @segymat_OpeningFcn, ... 'gui_OutputFcn', @segymat_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);% Next line is edited % ORIGINAL : if nargin & isstr(varargin{1})if nargin>1 & isstr(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:});endif nargin==1 & isstr(varargin{1}) [path,file,suffix]=fileparts(varargin{1}); segyfile.pathname=path; if length(suffix)>1, segyfile.filename=[file,'.',suffix]; else segyfile.filename=file; end % FIGURE OUT HOW TO GET THE hObject ?? % fReadSegy_Callback(hObject, eventdata, handles,segyfile);end% End initialization code - DO NOT EDIT% --- Executes just before segymat is made visible.function segymat_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to segymat (see VARARGIN) SegymatVerbose(['GUI : OPENING GUI'],20)% Choose default command line output for segymathandles.output = hObject;% Initialize PlotPref handles.PlotPref.Show=0;% Update handles structureguidata(hObject, handles);% Resize FigurefMain_ResizeFcn(hObject, eventdata, handles)% read in segy filesegyfile.pathname='c:\MaTLAB6p5\work\';segyfile.filename='test.sgy';%segyfile.filename='peaksh.segy';%fReadSegy_Callback(hObject, eventdata, handles,segyfile);% disable edit menuUpdateMenus(hObject, eventdata, handles)% UIWAIT makes segymat wait for user response (see UIRESUME)% uiwait(handles.fMain);% --- Outputs from this function are returned to the command line.function varargout = segymat_OutputFcn(hObject, eventdata, handles)% varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout{1} = handles.output;% --- Executes when fMain window is resized.function fMain_ResizeFcn(hObject, eventdata, handles)% hObject handle to fMain (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) if (isfield(handles,'fMain')==0) returnendSegymatVerbose(['GUI : Resizing'],20)data=guidata(hObject);% Get Size of Main Window[mainPos]=get(handles.fMain,'Position');d=4; % Distance to edgesd_ax=.2; % distance between axesif isfield(data,'PlotPref')==0, data.PlotPref.Show=1; guidata(hObject,data);end if isfield(data.PlotPref,'Show')==0, data.PlotPref.Show=1; guidata(hObject,data);end% fHeader Locationif data.PlotPref.Show==0, fHeaderW=d; set(handles.fHeader,'Visible','Off'); set(handles.text7,'Visible','Off'); set(handles.txtGain,'Visible','Off'); set(handles.pbGainUp,'Visible','Off'); set(handles.pbGainDown,'Visible','Off'); set(handles.eGainMin,'Visible','Off'); set(handles.eGainMax,'Visible','Off'); set(handles.popTop,'Visible','Off'); set(handles.popBot,'Visible','Off'); set(handles.txtTop,'Visible','Off'); set(handles.txtBot,'Visible','Off'); set(handles.txtColormap,'Visible','Off'); set(handles.popColormap,'Visible','Off'); set(handles.txtStyle,'Visible','Off'); set(handles.popStyle,'Visible','Off'); else fHeaderW=30; % WIDTH OF INFO PAGE x0=d;y0=d; w=fHeaderW-d; h=mainPos(4)-2*d; x1=x0+w; y1=y0+h; Wuic=8; % WIDTH OF UICONTROL Huic=1.4; % HEIGHT OF UICONTROL set(handles.fHeader,'Position',[x0 y0 w h]) d_frame=1; x0=x0+d_frame; wframe=w-2*d_frame; % TXT HEADER ytop=mainPos(4)-d;% set(handles.text7,'Position',[d+d ytop fHeaderW-3*d 2]); set(handles.text7,'Position',[x0 ytop wframe 2]); % GAIN ytop=ytop-d_ax-Huic; set(handles.txtGain,'Position',[x0,ytop,wframe,Huic]) ytop=ytop-d_ax-Huic; w_sign=4; set(handles.eGainMin,'Position',[x0,ytop,wframe-w_sign,Huic]) set(handles.pbGainDown,'Position',[x0+wframe-w_sign,ytop,w_sign,Huic]) ytop=ytop-d_ax-Huic; set(handles.eGainMax,'Position',[x0,ytop,Wuic*1.5,Huic]) set(handles.pbGainUp,'Position',[x0+Wuic*1.5,ytop,Wuic/2,Huic]) set(handles.eGainMax,'Position',[x0,ytop,wframe-w_sign,Huic]) set(handles.pbGainUp,'Position',[x0+wframe-w_sign,ytop,w_sign,Huic]) % TopSub ytop=ytop-2*d_ax-Huic; set(handles.txtTop,'Position',[x0,ytop,wframe,Huic]) ytop=ytop-d_ax-Huic; set(handles.popTop,'Position',[x0,ytop,wframe,Huic]) % BaseSub ytop=ytop-2*d_ax-Huic; set(handles.txtBot,'Position',[x0,ytop,wframe,Huic]) ytop=ytop-d_ax-Huic; set(handles.popBot,'Position',[x0,ytop,wframe,Huic]) % Style ytop=ytop-2*d_ax-Huic; set(handles.txtStyle,'Position',[x0,ytop,wframe,Huic]) ytop=ytop-d_ax-Huic; set(handles.popStyle ,'Position',[x0,ytop,wframe,Huic]) % Colormap ytop=ytop-2*d_ax-Huic; set(handles.txtColormap,'Position',[x0,ytop,wframe,Huic]) ytop=ytop-d_ax-Huic; set(handles.popColormap ,'Position',[x0,ytop,wframe,Huic]) % % MAKE ALL VISIBLE set(handles.fHeader,'Visible','On'); set(handles.text7,'Visible','On'); set(handles.txtGain,'Visible','On'); set(handles.pbGainUp,'Visible','On'); set(handles.pbGainDown,'Visible','On'); set(handles.eGainMin,'Visible','On'); set(handles.eGainMax,'Visible','On'); set(handles.popTop,'Visible','On'); set(handles.popBot,'Visible','On'); set(handles.txtTop,'Visible','On'); set(handles.txtBot,'Visible','On'); set(handles.txtColormap,'Visible','On'); set(handles.popColormap,'Visible','On'); set(handles.txtStyle,'Visible','On'); set(handles.popStyle,'Visible','On'); end% AXISaxLeft=fHeaderW+2*d;Hsmallax=4;% axBotaxBotX=axLeft;axBotY=d;axBotW=mainPos(3)-axLeft-2*d;axBotH=Hsmallax;axB=get(handles.axBot,'Position');set(handles.axBot,'Position',[axBotX axBotY axBotW axBotH])% axTopaxTopX=axLeft;axTopY=mainPos(4)-Hsmallax-d;axTopW=axBotW;axTopH=Hsmallax;axT=get(handles.axTop,'Position');set(handles.axTop,'Position',[axTopX axTopY axTopW axTopH])% axMainaxMainX=axLeft;axMainY=axBotY+Hsmallax+d_ax;axMainW=axBotW;axMainH=mainPos(4)-axMainY-Hsmallax-d-d_ax;set(handles.axMain,'Position',[axMainX axMainY axMainW axMainH])% --------------------------------------------------------------------function UpdatePrefs(hObject, eventdata, handles) SegymatVerbose(['GUI : UpdatePrefs'],20) data=guidata(hObject);if isfield(data,'SegyData')==0, set(handles.eGainMin,'Enable','off'); set(handles.eGainMin,'String',''); set(handles.eGainMax,'Enable','off'); set(handles.eGainMax,'String',''); returnelse set(handles.eGainMin,'Enable','on'); set(handles.eGainMax,'Enable','on');endif isfield(data.PlotPref,'caxis')==0 data.PlotPref.caxis=[min(data.SegyData(:)) max(data.SegyData(:))];end set(handles.eGainMin,'String',data.PlotPref.caxis(1));set(handles.eGainMax,'String',data.PlotPref.caxis(2));if isfield(data.PlotPref,'TraceHeaders')==0, data.PlotPref.TraceHeaders=fieldnames(data.SegyTraceHeaders);end if isfield(data.PlotPref,'TopPlot')==0, data.PlotPref.TopPlot=7; endif isfield(data.PlotPref,'BotPlot')==0, data.PlotPref.BotPlot=13; endset(handles.popTop,'String',data.PlotPref.TraceHeaders);set(handles.popTop,'value',data.PlotPref.TopPlot);set(handles.popTop,'Enable','On');set(handles.popBot,'String',data.PlotPref.TraceHeaders);set(handles.popBot,'value',data.PlotPref.BotPlot);set(handles.popBot,'Enable','On');guidata(hObject,data);% --------------------------------------------------------------------function UpdatePlots(hObject, eventdata, handles) SegymatVerbose(['GUI : Update Plots'],20) %data=guidata(hObject); UpdateMainPlot(hObject, eventdata, handles) UpdateTopPlot(hObject, eventdata, handles) UpdateBotPlot(hObject, eventdata, handles) axes(handles.axMain);%%%zoom on;% --------------------------------------------------------------------function UpdateMainPlot(hObject, eventdata, handles) SegymatVerbose(['GUI : Update Main Plot'],20) data=guidata(hObject); Style=get(handles.popStyle,'Value'); % GET PLOTTING STYLE axes(handles.axMain); if ((Style==1)|(Style==4)|(Style==5)) imagesc(data.SegyTrace,data.SegyTime,data.SegyData); caxis(data.PlotPref.caxis) hold on end gain=max(abs(data.PlotPref.caxis)); if ((Style==2)|(Style==4)) wiggle(data.SegyTrace,data.SegyTime,data.SegyData,'wiggle',gain); end if ((Style==3)|(Style==5)) wiggle(data.SegyTrace,data.SegyTime,data.SegyData,'VA',gain); end hold off set(gca,'YaxisLocation','Right'); set(gca,'XtickLabel',[]); ylabel('TWT [ms]') %% RESET ZOOM SUCH THAT THIS STATE IS THE 'ZOOM OUT' STATE. zoom reset; %%%zoom on;% --------------------------------------------------------------------function UpdateTopPlot(hObject, eventdata, handles) SegymatVerbose(['GUI : Update TOP Plots'],60) data=guidata(hObject); axes(handles.axMain);axMain=axis; pop=get(handles.popTop,'String'); ipop=get(handles.popTop,'value'); hname=pop{ipop}; axes(handles.axTop) if isfield(data,'dTopPlot') if ipop~=data.dTopPlot_ipop data.dTopPlot=bar([data.SegyTraceHeaders.(hname)]); data.dTopPlot_ipop=ipop; guidata(hObject,data) end else data.dTopPlot=bar([data.SegyTraceHeaders.(hname)]); data.dTopPlot_ipop=ipop; guidata(hObject,data) end ax=axis;axis([axMain(1) axMain(2) ax(3) ax(4)]) set(gca,'XaxisLocation','Top'); set(gca,'YaxisLocation','Right'); xlabel(hname) axes(handles.axMain);%%%zoom on; function UpdateBotPlot(hObject, eventdata, handles) SegymatVerbose(['GUI : Update BOT Plots'],60) data=guidata(hObject); axes(handles.axMain);axMain=axis; pop=get(handles.popBot,'String'); ipop=get(handles.popBot,'value'); hname=pop{ipop}; axes(handles.axBot) if isfield(data,'dBotPlot') if ipop~=data.dBotPlot_ipop data.dBotPlot=plot([data.SegyTraceHeaders.(hname)]); data.dBotPlot_ipop=ipop; guidata(hObject,data) end else data.dBotPlot=plot([data.SegyTraceHeaders.(hname)]); data.dBotPlot_ipop=ipop; guidata(hObject,data) end % bar([data.SegyTraceHeaders.(hname)]); ax=axis;axis([axMain(1) axMain(2) ax(3) ax(4)]) set(gca,'XaxisLocation','Bot'); set(gca,'YaxisLocation','Right'); xlabel(hname) axes(handles.axMain);%%%zoom on;% --------------------------------------------------------------------function UpdateGain(hObject, eventdata, handles) SegymatVerbose(['GUI : UpdateGain'],20) data=guidata(hObject); set(handles.eGainMin,'String',data.PlotPref.caxis(1)); set(handles.eGainMax,'String',data.PlotPref.caxis(2)); axes(handles.axMain); caxis(data.PlotPref.caxis); drawnow; % --------------------------------------------------------------------function KeyPressFcn_Callback(hObject, eventdata, handles)data=guidata(hObject);Key=get(gcf,'CurrentCharacter');%SegymatVerbose(['GUI : KeyPressFcn : ',num2str(double(Key)),' ',char(Key)],20)%disp(char(Key));%disp(double(Key));%%%%%%%%%%%% GAIN%if (Key=='+'),if ((double(Key)==30)|(double(Key)==43)|(double(Key)==115)) data.PlotPref.caxis=data.PlotPref.caxis./(1.2); guidata(hObject,data); UpdateGain(hObject, eventdata, handles) ;end%if (Key=='-');if ((double(Key)==31)|(double(Key)==45)|(double(Key)==120)) data.PlotPref.caxis=data.PlotPref.caxis.*(1.2); guidata(hObject,data); UpdateGain(hObject, eventdata, handles) ;end%% SHOW PREFSif (lower(Key)=='h') if isfield(data.PlotPref,'Show')==0, data.PlotPref.Show=1;end data.PlotPref.Show=1-data.PlotPref.Show; guidata(hObject,data); fMain_ResizeFcn(hObject,[],handles);end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ZOOM ON MAIN AXif isfield(data,'zoomfac')==0 data.zoomfac=1.5; guidata(hObject,data);end zoom_in_keys=[29,97]; % ARROW RIGHT OR 'a'zoom_out_keys=[28,122]; % ARROW LEFT OR 'z'if find(double(Key)==zoom_in_keys);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -