⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewslice.m

📁 matlab下看地震切片的程序
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = ViewSlice(varargin)
% ViewSlice M-file for ViewSlice.fig
%      ViewSlice, by itself, creates a new ViewSlice or raises the existing
%      singleton*.
%
%      H = ViewSlice returns the handle to a new ViewSlice or the handle to
%      the existing singleton*.
%
%      ViewSlice('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in ViewSlice.M with the given input arguments.
%
%      ViewSlice('Property','Value',...) creates a new ViewSlice or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before ViewSlice_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to ViewSlice_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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help ViewSlice

% Last Modified by GUIDE v2.5 03-Mar-2007 22:53:32

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @ViewSlice_OpeningFcn, ...
                   'gui_OutputFcn',  @ViewSlice_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% global workdir SegyFileName
% if isempty(workdir)
%     workdir = fileparts(which(mfilename));
% end
% if isdir(workdir)
%     cd(workdir)
% end

% --- Executes just before ViewSlice is made visible.
function ViewSlice_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 ViewSlice (see VARARGIN)

% Choose default command line output for ViewSlice
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
set(gca, 'XTick', [])
set(gca, 'YTick', [])
set(handles.axes1, 'Box', 'On')
set(handles.figure1, 'Toolbar', 'figure')

% global workdir
% Disable the View Slice menu until the data file has been opened
if  ~isfield(handles, 'filename')
     set(handles.TimeSliceMenu,  'Enable',  'Off');
else
     set(handles.TimeSliceMenu, 'Enable', 'On');
end

% --- Outputs from this function are returned to the command line.
function varargout = ViewSlice_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 structure
varargout{1} = handles.output;

% --- Executes on slider movement.
function LevelSlider_Callback(hObject, eventdata, handles)
% hObject    handle to LevelSlider (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% --- Executes on slider movement.
function UprightSlider_Callback(hObject, eventdata, handles)
% hObject    handle to UprightSlider (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


% --------------------------------------------------------------------
function FileMenu_Callback(hObject, eventdata, handles)
% hObject    handle to FileMenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function SaveMenu_Callback(hObject, eventdata, handles)
% hObject    handle to SaveMenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename, pathname] = uiputfile({'*.tif'; '*.bmp';'*.eps'; '*.emf'}, 'Save current figure as');
fullfilename = fullfile(pathname, filename);
saveas(handles.figure1, fullfilename)

% --------------------------------------------------------------------
function PrintMenu_Callback(hObject, eventdata, handles)
% hObject    handle to PrintMenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

function MenuExit_Callback(hObject, eventdata, handles)
% hObject    handle to MenuExit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

delete(handles.figure1)

% --------------------------------------------------------------------
function MenuSetWorkDir_Callback(hObject, eventdata, handles)
% hObject    handle to MenuSetDir (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global workdir
workdir = uigetdir;
handles.workdir = workdir;
guidata(hObject, handles)

% --------------------------------------------------------------------
function ViewMenu_Callback(hObject, eventdata, handles)
% hObject    handle to ViewMenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function BaseMapMenu_Callback(hObject, eventdata, handles)
% hObject    handle to BaseMapMenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global workdir 
cd(workdir)
cd('horizon')
handles.SliceType = 'BaseMap';
guidata(hObject, handles)

if isfield(handles, 'FilePara')
    FilePara = handles.FilePara;
    nxs = FilePara.nxs;
    nxe = FilePara.nxe;
    nys = FilePara.nys;
    nye = FilePara.nye;
    nline = FilePara.nline;
    ncdp = FilePara.ncdp;
else
    return;
end

horizonFileNameStr = ls;
numOfHorizons = size(horizonFileNameStr,1)-2;
if numOfHorizons < 0
    return;
end
handles.numOfHorizons = numOfHorizons;
handles.horizonFileNameStr = horizonFileNameStr;
set(handles.StepSlider, 'Max', numOfHorizons, 'Min', 1, 'Value', 1)
set(handles.StepSlider, 'SliderStep', [0.2 0.1]);
load(horizonFileNameStr(3, :));
cd(workdir)
timemap = NaN(ncdp, nline);
v1 = unique(horizon(:, 1));   % Obtain inline numbers
nCol = length(v1);  
for ix = 1:nCol
    ind = find(horizon(:,1) == v1(ix));
    timemap( horizon(ind,2), v1(ix)) = horizon(ind, 3);
end
set(0, 'CurrentFigure', handles.figure1)
figureData = timemap;
yCor = [nys:nye];
xCor = [nxs:nxe];
mydispslice(timemap, [], [], xCor, yCor);
xlabel( 'Inline');
ylabel('Crossline');
set(gca, 'TickDir', 'Out', 'XMinorTick', 'On', 'YMinorTick', 'On')
handles.figureData = figureData;
set(gcf, 'UserData', figureData);
set(handles.EditStep, 'String', num2str(1));

% --------------------------------------------------------------------
function TimeSliceMenu_Callback(hObject, eventdata, handles)
% hObject    handle to TimeSliceMenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global workdir
if isfield(handles, 'FilePara')
    FilePara = handles.FilePara;
    nxs = FilePara.nxs;
    nxe = FilePara.nxe;
    nys = FilePara.nxs;
    nye = FilePara.nxe;
    nzts = FilePara.nzts;
    nzte = FilePara.nzte;
    nSampleInterval = FilePara.nSampleInterval;
else
    return;
end
set(handles.StepSlider, 'Enable', 'On')
set(handles.EditStep, 'Enable', 'On');
set(handles.EditSliceNum, 'Enable', 'On');

handles.SliceType = 'TimeSlice';
guidata(hObject, handles)
% Get the current time slice number
str2 = get(handles.EditSliceNum, 'string');
nSliceNum = str2num(str2);
if isempty(nSliceNum)
    nSliceNum = nzts;
    set(handles.EditSliceNum, 'String', num2str(nzts))
else
    if nSliceNum > nzte
        nSliceNum = nzte;
    elseif nSliceNum<nzts
        nSliceNum = nzts;
    end
end
nSliceNum = round((nSliceNum-nzts)/nSampleInterval) + 1;
set(handles.StepSlider, 'Max', nzte, 'Min', nzts, 'Value', nzts)
set(handles.StepSlider, 'SliderStep', [0.01 0.05]);
figureData = mydispslice2(nSliceNum, handles);
set(gca, 'TickDir', 'Out', 'XMinorTick', 'On', 'YMinorTick', 'On')
set(gcf, 'UserData', figureData);

% --------------------------------------------------------------------
function ViewHorMenu_Callback(hObject, eventdata, handles)
% hObject    handle to ViewHorMenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global workdir 
cd(workdir)
handles.SliceType = 'Horizon';
guidata(hObject, handles)

set(handles.StepSlider, 'Enable', 'Off')
set(handles.EditStep, 'Enable', 'Off');
set(handles.EditSliceNum, 'Enable', 'Off');

if isfield(handles, 'FilePara')
    FilePara = handles.FilePara;
    nxs = FilePara.nxs;
    nxe = FilePara.nxe;
    nys = FilePara.nys;
    nye = FilePara.nye;
    nline = FilePara.nline;
    ncdp = FilePara.ncdp;
else
    return;
end
slice = NaN(ncdp, nline);
fid = fopen(handles.filename, 'r', 'b');
slice = fread(fid, [ncdp, nline], 'float32');
fclose(fid);


set(0, 'CurrentFigure', handles.figure1)

figureData = slice;
yCor = [nys:nye];
xCor = [nxs:nxe];
mydispslice(slice, [], [], xCor, yCor);
xlabel( 'Inline');
ylabel('Crossline');
set(gca, 'TickDir', 'Out', 'XMinorTick', 'On', 'YMinorTick', 'On')
handles.figureData = figureData;
set(gcf, 'UserData', figureData);
set(gcf, 'name', ['View Horizon-' handles.filename])



% --------------------------------------------------------------------
function ZoomOffMenu_Callback(hObject, eventdata, handles)
% hObject    handle to ZoomOffMenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function ZoomOnMenu_Callback(hObject, eventdata, handles)
% hObject    handle to ZoomOnMenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on slider movement.
function StepSlider_Callback(hObject, eventdata, handles)
% hObject    handle to StepSlider (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
global workdir
if isdir(workdir)
    cd(workdir);
end
if isfield(handles, 'FilePara')
    FilePara = handles.FilePara;
    nxs = FilePara.nxs;
    nxe = FilePara.nxe;
    nys = FilePara.nys;
    nye = FilePara.nye;
    nzts = FilePara.nzts;
    nzte = FilePara.nzte;
    nline = FilePara.nline;
    ncdp = FilePara.ncdp;
    nsample = FilePara.nsample;
    nSampleInterval = FilePara.nSampleInterval;
else
    return;
end
if strcmp(lower(handles.SliceType), 'basemap')
    timemap = NaN(ncdp, nline);
end
% Get the current horizon number
prevnSlice = str2num(get(handles.EditSliceNum, 'String'));
if isempty(prevnSlice)
    if strcmp(lower(handles.SliceType), 'timeslice')
        prevnSlice = nzts;
        set(handles.EditSliceNum, 'String', num2str(nzts))
    elseif strcmp(lower(handles.SliceType), 'basemap')
        prevnBasemap = 1;
        set(handles.EditSliceNum, 'String', num2str(prevnBasemap))
    end
end
step = str2num(get(handles.EditStep, 'String'));
if isempty(step)
    if strcmp(lower(handles.SliceType), 'timeslice')
        step = nSampleInterval;
    elseif strcmp(lower(handles.SliceType), 'basemap')
        step = 1;
    end
    set(handles.EditStep, 'String', num2str(step))
end
currentSlice = round(get(hObject, 'Value'));
if strcmp(lower(handles.SliceType), 'timeslice')
    if currentSlice < nzts;
        currentSlice = nzts;
    elseif currentSlice> nzte
        currentSlice = nzte;
    end
    set(handles.StepSlider, 'SliderStep', [step/nsample 0.05], 'Value', currentSlice);
    nSlice = fix((currentSlice-nzts)/nSampleInterval)+1;
    figureData = mydispslice2(nSlice, handles);
    set(gca, 'TickDir', 'Out', 'XMinorTick', 'On', 'YMinorTick', 'On')
    set(gcf, 'UserData', figureData);
elseif strcmp(lower(handles.SliceType), 'basemap')
    cd('horizon')
    horizonFileNameStr = ls('*.hor*');
    numOfHorizons = size(horizonFileNameStr,1);
    if currentSlice < 1;
        currentSlice = 1;
    elseif currentSlice > numOfHorizons;
        currentSlice = numOfHorizons;
    end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -