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

📄 importlas.m

📁 地震中常用的一些偏移程序
💻 M
📖 第 1 页 / 共 2 页
字号:


%done and cancel buttons
	ynow=ynow-sep-height;
	xnow=sep;
	width=.3;
	hdone=uicontrol('style','pushbutton','string','Done','units','normalized',...
		'position',[xnow ynow width height],'callback','importlas(''done'')',...
		'foregroundcolor','r');
	xnow=xnow+width+sep;
	width=.3;
	hcancel=uicontrol('style','pushbutton','string','Cancel','units','normalized',...
	'position',[xnow ynow width height],'callback','importlas(''done'')');
	


	% get the position of the calling figure
	hparent=get(hax,'parent');
	pospar=get(hparent,'position');

	px=pospar(1)+pospar(3)/2;
	py=pospar(2)+pospar(4)/2;

	set(hdial,'position',[px py figwidth figheight]);
 	set(hdial,'visible','on');
 	
 	set(hdone,'userdata',transfer);
        
	set(hdial,'userdata',[hmsg htoggle hlogname1 hlogname2  hlogedit1 hlogedit2...
		hlogimp1 hlogimp2 hwellopt1 hwellopt2 hwellname1 hwellname2 ...
		hexist1 hexist2 hinline1 hinline2 hzstart1 hzstart2 ...
		hzend1 hzend2 hunits hkb htops hdone ...
		hcancel]);
        
 return;
        
end

if(strcmp(action,'done'))
   % here we must:
   % 1) get the log munbers to import
   % 2) for each log, get its edited name
   % 3) get the well name
   % 4) get the depth interval
   % 5) get the x coordinate
   % 6) get the use tops flag
   
   h=get(gcf,'userdata');
   hmsg=h(1);
   hlogname2=h(4);
   hlogimp2=h(8);
	  hwellopt2=h(10);
   hwellname2=h(12);
	  hexist2=h(14);
   hinline2=h(16);
   hzstart2=h(18);
   hzend2=h(20);
   htops=h(23);
   hdone=h(24);
	  hkb=h(22);
	  hunits=h(21);
   
   flag=get(gco,'string');
   if( strcmp(flag,'Cancel') )
   	hax=get(hmsg,'userdata');
		set(hax,'userdata',-1);
   	% call the transfer expression
		transfer=get(hdone,'userdata');
		close(gcf);
		eval(transfer);
		return;
	  end
   
   %save the edited name
		importlas('setlogname');
   
   % get the lognames
   lognames=get(hlogname2,'string');
   [nlogs,nc]=size(lognames);
   
   %get the log numbers to import
   str=get(hlogimp2,'string');
   lognums=sscanf(str,'%d');
   
   test=find(diff(lognums)==0);
   
   if(isempty(lognums) | max(lognums)> nlogs | min(lognums)<1 | ~isempty(test))
   	set(hmsg,'string','Log numbers are not sensible!');
		set(hmsg,'backgroundcolor','r','foregroundcolor','y');
   	return;
   end
   
   lognames=lognames(:,4:nc);
   
   %get the well name
	  test=get(hwellopt2,'value');
	  if(test~=3)
		wellname=get(hwellname2,'string');
		ind=find(abs(wellname)~=32);
		if( isempty(wellname(ind)) )
			set(hmsg,'string','Well name must be non-blank');
			set(hmsg,'backgroundcolor','r','foregroundcolor','y');
			return;
		end
	  else
		wellnum=get(hexist2,'value');
		wellist=get(hexist2,'string');
		wellname=strunpad(wellist(wellnum,:));
	  end
	  %if the name was typed in, then we make sure it differs from
	  %existing wells
	  if(test~=3 & hexist2)
		wellnames=get(hexist2,'string');
		[numnames,ncols]=size(wellnames);
		for k=1:numnames
			thisname=wellnames(k,:);
			ind=find(thisname~=0);
			thisname=thisname(ind);
			if(strcmp(thisname,wellname))
				set(hmsg,'string','Wellname must differ from existing wells');
				set(hmsg,'backgroundcolor','r','foregroundcolor','y');
				return;
			end
		end
	  end
   
   %get the depth interval
   str=get(hzstart2,'string');
   zstart=sscanf(str,'%f');
   str=get(hzend2,'string');
   zend=sscanf(str,'%f');
   
   if(isempty(zstart) | isempty(zend) | zend<=zstart)
   	set(hmsg,'string','Depth interval is mis-specified');
		set(hmsg,'backgroundcolor','r','foregroundcolor','y');
   	return;
   end
   
   %get the inline coordinate
   if( strcmp(get(hinline2,'visible'),'on'))
   	str=get(hinline2,'string');
   	x=sscanf(str,'%f');
   	
   	if(isempty(x))
   		set(hmsg,'string','Specify the inline coordinate!');
        set(hmsg,'backgroundcolor','r','foregroundcolor','y');
        return;
    end
   else
   	x=inf;
   end
   
   %get the topsflag
   if(htops)
   	topsflag=get(htops,'value');
   else
   	topsflag=htops;
   end
   
	hax=get(hmsg,'userdata');

    % get the kb and the units
    str=get(hkb,'string');
    kb=sscanf(str,'%*s%*s%f');
    if(isempty(kb)) kb=str2num(str);end  % If that failed, try another way.
    % if it still didn't work, kick back to the user.
    if(isempty(kb))
        set(hmsg, 'string', 'Set a valid KB elevation!');
        set(hmsg, 'backgroundcolor', 'r', 'foregroundcolor', 'y');
        return;
    end
    units=get(hunits,'string');
    
	
	[m,n]=size(lognames);
	lognames=lognames(:)';
	set(hax,'userdata',[lognums' nan m n abs(lognames) nan abs(wellname)...
		 nan double(units) nan x zstart zend topsflag kb]);
   		        
 % call the transfer expression
	transfer=get(hdone,'userdata');
	%******NOTE*********
	% If I delete the las dialog figure prior to calling the transfer function
	% I tend to get matlab segmentation faults. This should work because I 
	% truly have no further use for the figure; however, I've found it necessary
	% to hide the figure, make the calling figure current, call the transfer
	% function, and then delete the hidden dialog figure. So the next few
	% lines should work but are commented out:
	% Should work:
	%close(gcf);
	%eval(transfer);
	hfig=gcf;
	set(hfig,'visible','off');
	hmasterfig=get(hax,'parent');
	figure(hmasterfig);
	eval(transfer);
	close(hfig);
        
	return;
        	
end

	
if(strcmp(action,'lognames') )
	h=get(gcf,'userdata');
	hlogname2=h(4);
	hlogedit2=h(6);

	%save the edited name
	importlas('setlogname');

	%swap userdata and string in hlognames
	tmp=get(hlogname2,'userdata');

	set(hlogname2,'userdata',get(hlogname2,'string'));
	set(hlogname2,'string',tmp);

	%set the string in heditlog2
	[nr,nc]=size(tmp);
	set(hlogedit2,'string',tmp(1,4:nc));
	set(hlogedit2,'userdata',1);

	return;

end

% save an edited log name
if(strcmp(action,'setlogname'))
	h=get(gcf,'userdata');
	hlogname2=h(4);
	hlogedit2=h(6);

	n=get(hlogedit2,'userdata');
	name=get(hlogedit2,'string');

	%remove any blanks
	ind=find(abs(name)~=32);
	name=name(min(ind):max(ind));

	lognames=get(hlogname2,'string');
	[nr,nc]=size(lognames);

	newnames=lognames(1:n-1,:);
	newnames=strmat(newnames,[lognames(n,1:3) name]);
	newnames=strmat(newnames,lognames(n+1:nr,:));
	[nr,nc]=size(newnames);

	val=get(hlogname2,'value');

	set(hlogname2,'string',newnames,'value',val);
	set(hlogedit2,'string',newnames(val,4:nc));
	set(hlogedit2,'userdata',val);

	return;
end

if(strcmp(action,'wellname'))
	h=get(gcf,'userdata');
	hwellopt2=h(10);
	hwellname1=h(11);
	hwellname2=h(12);
	hexist1=h(13);
	hexist2=h(14);
	hinline1=h(15);
	hinline2=h(16);

	val=get(hwellopt2,'value');
	if( val<3 )
		set(hwellname1,'visible','on');
		set(hwellname2,'visible','on');
		if(hexist1)
			set(hexist1,'visible','off');
			set(hexist2,'visible','off');
		end
		set(hinline1,'visible','on');
		set(hinline2,'visible','on');

		names=get(hwellopt2,'string');
		set( hwellname2,'string',names(val,:));

	else
		set(hwellname1,'visible','off');
		set(hwellname2,'visible','off');
		set(hexist1,'visible','on');
		set(hexist2,'visible','on');
		set(hinline1,'visible','off');
		set(hinline2,'visible','off');
	end

	return;

end

if(strcmp(action,'tops'))
	htop=gco;
 bgkol=[0 1 1];
 grey=[.702 .702 .702];

	val=get(htop,'value');

	if(val==1)
		set(gco,'backgroundcolor',bgkol);
	else
		set(gco,'backgroundcolor',grey);
	end

	return;
end

⌨️ 快捷键说明

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