📄 tzdefine.m
字号:
function tzdefine(action,arg2)
% TZDEFINE is the central part of a dialog used by LOGSEC to define time-depth
% curves. Inititate the dialog by calling TZDEFINEINIT and finish it by calling
% TZDEFINEFINI.
%
% 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
if( strcmp(action,'init'))
stuff=get(gca,'userdata');
ind=find(isnan(stuff));
transfer=setstr(stuff(1:ind(1)-1));
sections=setstr(stuff(ind(1)+1:ind(2)-1));
hmasterfig=stuff(ind(2)+1);
holealg=stuff(ind(2)+2);
numlegs=stuff(ind(2)+3);
vo=stuff(ind(2)+4);
alphax=stuff(ind(2)+5);
alphaz=stuff(ind(2)+6);
isec=stuff(ind(2)+7);
%make a new figure
hfig=figure('visible','off','menubar','none');
bgkol=[0 1 1];
fgkol=[0 0 0];
msgkol=[1 0 0];
pos=get(hfig,'position');
height=20;
figheight=10*height;
figwidth=302;
sep=1;
xnow=sep;
ynow=figheight-height-sep;
width=300;
htitle=uicontrol('style','text','position',[xnow,ynow,width,height],'string',...
'Define Time - Depth (T-Z) Curves','foregroundcolor',msgkol);
xnow=sep;
ynow=ynow-height-sep;
hmsg=uicontrol('style','text','position',[xnow,ynow,width,height],'string',...
'MB1: select sonic for analysis display','foregroundcolor',msgkol);
xnow=sep;
ynow=ynow-height-sep;
width=120;
hsectionlbl=uicontrol('style','text','string','Sonic Log Section:','position',...
[xnow,ynow,width,height]);
xnow=xnow+width+sep;
width=180;
hsection=uicontrol('style','popupmenu','string',sections,'position',...
[xnow,ynow,width,height],'callback','tzdefine(''setsection'')'...
,'foregroundcolor',fgkol,'backgroundcolor',bgkol,...
'value',isec);
ynow=ynow-height-sep;
xnow=sep;
width=150;
hholelbl=uicontrol('style','text','string','Hole Filling Algorithm:',...
'position',[xnow,ynow,width,height]);
xnow=xnow+width+sep;
width=150;
hholealg=uicontrol('style','popupmenu','string',...
'Constant|Linear|Mean|Layer Mean|Layer Trend',...
'position',[xnow,ynow,width,height],'value',holealg);
xnow=sep;
ynow=ynow-height-sep;
width=80;
hmodelbl=uicontrol('style','text','string','Mode:','position',...
[xnow,ynow,width,height]);
xnow=xnow+width+sep;
width=120;
hmode=uicontrol('style','popupmenu','string','Analyze|Compute',...
'position',[xnow,ynow,width,height]','callback','tzdefine(''mode'');',...
'foregroundcolor',fgkol,'backgroundcolor',bgkol);
xnow=sep;
ynow=ynow-height-sep;
width=120;
hnumlegslbl=uicontrol('style','text','string','Number of Legs:',...
'position',[xnow,ynow,width,height]);
xnow=xnow+width+sep;
width=40;
hnumlegs=uicontrol('style','edit','string',num2str(numlegs),'position',...
[xnow,ynow,width,height]);
xnow=sep;
ynow=ynow-height-sep;
width=40;
hvolbl=uicontrol('style','text','string','Vo:','position',...
[xnow,ynow,width,height]);
xnow=xnow+width+sep;
width=60;
hvo=uicontrol('style','edit','string',num2str(vo),'position',...
[xnow,ynow,width,height]);
xnow=xnow+width+sep;
width=60;
halphaxlbl=uicontrol('style','text','string','AlphaX:','Position',...
[xnow,ynow,width,height]);
xnow=xnow+sep+width;
width=40;
halphax=uicontrol('style','edit','string',num2str(alphax),'position',...
[xnow,ynow,width,height]);
xnow=xnow+sep+width;
width=60;
halphazlbl=uicontrol('style','text','string','AlphaZ:','Position',...
[xnow,ynow,width,height]);
xnow=xnow+sep+width;
width=40;
halphaz=uicontrol('style','edit','string',num2str(alphaz),'position',...
[xnow,ynow,width,height]);
xnow=sep;
ynow=ynow-height-sep;
width=100;
hnamelbl=uicontrol('style','text','string','TZ name:','Position',...
[xnow,ynow,width,height]);
xnow=xnow+width+sep;
width=200;
sections=strvec2mat(sections);
hname=uicontrol('style','edit','string',['TZ: ' ...
sections(isec,:)],'position',[xnow,ynow,width,height]);
%the buttons
xnow=sep;
ynow=ynow-height-sep;
width=60;
% the done button is enabled when the mode is switched to compute
hdone=uicontrol('style','pushbutton','string','Done','position',...
[xnow,ynow,width,height],'callback','tzdefine(''done'');',...
'userdata',transfer,'enable','off');
xnow=xnow+width+sep;
width=60;
hcancel=uicontrol('style','pushbutton','string','Cancel','position',...
[xnow,ynow,width,height],'callback','tzdefine(''cancel'');');
set(hfig,'userdata',[hmasterfig,hmsg,hsection,hholealg,hmode,hnumlegs,hvo,...
halphax,halphaz,hdone,hcancel hname]);
tzdefine('mode');
set(hfig,'position',[pos(1:2) figwidth figheight]);
set(hfig,'visible','on');
return;
end
%
% handle the done button
%
if(strcmp(action,'done'))
h=get(gcf,'userdata');
hmasterfig=h(1);
hdone=h(10);
tzdefine('getparameters',gcf);
%call the transfer function
transfer=get(hdone,'userdata');
close(gcf);
figure(hmasterfig);
eval(transfer);
return;
end
%
% do a cancel
%
if(strcmp(action,'cancel'))
h=get(gcf,'userdata');
hmasterfig=h(1);
hmode=h(5);
hdone=h(10);
fcn=get(hmode,'userdata');
if(~isempty(fcn))
set(hmasterfig,'windowbuttonupfcn',fcn);
else
set(hmasterfig,'windowbuttonupfcn','');
end
transfer=get(hdone,'userdata');
hax=get(hmasterfig,'currentaxes');
set(hax,'userdata',-1);
close(gcf);
figure(hmasterfig);
eval(transfer);
return;
end
%
% the mode switch
%
if(strcmp(action,'mode'))
h=get(gcf,'userdata');
hmasterfig=h(1);
hmsg=h(2);
hmode=h(5);
hdone=h(10);
flag=get(hmode,'value');
if(flag==1)
set(hdone,'enable','off');
fcn=get(hmasterfig,'windowbuttonupfcn');
tst=get(hmode,'userdata');
if(isempty(tst))
set(hmode,'userdata',fcn);
end
set(hmasterfig,'windowbuttonupfcn','logsec(''tzanal'')');
set(hmsg,'string','MB1: select sonic for analysis display');
else
set(hdone,'enable','on');
fcn=get(hmode,'userdata');
if(~isempty(fcn))
set(hmasterfig,'windowbuttonupfcn',fcn);
else
set(hmasterfig,'windowbuttonupfcn','');
end
set(hmsg,'string','Push done to compute tz function');
end
return;
end
%
%
%
if(strcmp(action,'getparameters'))
hfig=arg2;
h=get(hfig,'userdata');
hmasterfig=h(1);
hmsg=h(2);
hsection=h(3);
hholealg=h(4);
hmode=h(5);
hnumlegs=h(6);
hvo=h(7);
halphax=h(8);
halphaz=h(9);
hdone=h(10);
hcancel=h(11);
hname=h(12);
hax=get(hmasterfig,'currentaxes');
%get the number of legs
numlegs=sscanf(get(hnumlegs,'string'),'%d');
if( numlegs<0 | isempty(numlegs) | floor(numlegs)~=numlegs)
set(hax,'userdata',-1);
figure(hfig);
set(hmsg,'string','Number of legs must be a positive integer');
error('Number of legs must be a positive integer');
end
%get the initial velocity
vo=sscanf(get(hvo,'string'),'%f');
if( vo<0 | isempty(vo) | isnan(vo) )
set(hax,'userdata',-1);
figure(hfig);
set(hmsg,'string','Vo must be a positive real number or inf');
error('Vo must be a positive real number or inf');
end
%get the x accelerator
alphax=sscanf(get(halphax,'string'),'%f');
if( isempty(alphax) | alphax<-10 | alphax>10 )
set(hax,'userdata',-1);
figure(hfig);
set(hmsg,'string','Alphax must be between -10 and 10');
error('Alphax must be between -10 and 10');
end
%get the z accelerator
alphaz=sscanf(get(halphaz,'string'),'%f');
if( isempty(alphaz) | alphaz<-10 | alphaz>10 )
set(hax,'userdata',-1);
figure(hfig);
set(hmsg,'string','Alphaz must be between -10 and 10');
error('Alphaz must be between -10 and 10');
end
%get the name
name=get(hname,'string');
if( strcmp(name,'') | strcmp(name,' ') | length(name)>30 )
set(hax,'userdata',-1);
figure(hfig);
set(hmsg,'string','Provide a non-blank name, max of 30 chars');
error('Provide a non-blank name');
end
% get the section choice
sectionum=get(hsection,'value');
%the hole algorithm
holealg=get(hholealg,'value');
%store this stuff
set(hax,'userdata',[sectionum holealg numlegs vo alphax alphaz abs(name)]);
return;
end
%
%
%
if(strcmp(action,'setsection'))
h=get(gcf,'userdata');
hsection=h(3);
hname=h(12);
secnames=get(hsection,'string');
secnum=get(hsection,'value');
set(hname,'string',['TZ: ' secnames(secnum,:)]);
return;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -