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

📄 gui_callback.m

📁 水声模型 很不错的东西
💻 M
📖 第 1 页 / 共 2 页
字号:
case 'FontTitleAll',
   AxesHandles = findobj(gcbf, 'Type', 'axes');
   for IAx = 1:length(AxesHandles);
      h = get(AxesHandles(IAx), 'title');
      if (IAx == 1)
         NewFont = uisetfont(h);
      else
         set(h, NewFont);
      end
   end
   
case 'FontDefaultAll'
   DfltInfo = GUI_Defaults;
   AxesHandles = findobj(gcbf, 'Type', 'axes');
   for IAx = 1:length(AxesHandles);
      set(AxesHandles(IAx), DfltInfo.AxisFont);
      HArr = get(AxesHandles(IAx), {'xlabel', 'ylabel', 'zlabel', 'title'});
      for ILab = 1:3
         set(HArr{ILab}, DfltInfo.LabelFont);
      end
      set(HArr{4}, DfltInfo.TitleFont);
   end

case 'FontEverythingCurrent',
   Ax = get(gcbf, 'CurrentAxes');
   NewFont = uisetfont(Ax);
   HArr = get(Ax, {'xlabel', 'ylabel', 'zlabel', 'title'});
   for ILab = 1:length(HArr)
      set(HArr{ILab}, NewFont);
   end
   
case 'FontAxesCurrent',
   Ax = get(gcbf, 'CurrentAxes');
   NewFont = uisetfont(Ax);
   
case 'FontLabelsCurrent',
   Ax = get(gcbf, 'CurrentAxes');
   HArr = get(Ax, {'xlabel', 'ylabel', 'zlabel'});
   for ILab = 1:length(HArr)
    	if (ILab == 1)
        	NewFont = uisetfont(HArr{ILab});
      else
        	set(HArr{ILab}, NewFont);
      end
   end
   
case 'FontTitleCurrent',
   Ax = get(gcbf, 'CurrentAxes');
   h = get(Ax, 'title');
   NewFont = uisetfont(h);
   
case 'NewTitleCurrent',
   Ax = get(gcbf, 'CurrentAxes');
   h = get(Ax, 'title');
   CurrentTitle = get(h, 'String');
   Ans = inputdlg({'New title:'}, '', 1, {CurrentTitle});
   if ~isempty(Ans)
      set(h, 'String', Ans{1});
   end

case 'FontDefaultCurrent'
   DfltInfo = GUI_Defaults;
   Ax = get(gcbf, 'CurrentAxes');
   set(Ax, DfltInfo.AxisFont);
   HArr = get(Ax, {'xlabel', 'ylabel', 'zlabel', 'title'});
   for ILab = 1:3
      set(HArr{ILab}, DfltInfo.LabelFont);
   end
   set(HArr{4}, DfltInfo.TitleFont);
   
case 'GridOnOffCurrent',
   Ax = get(gcbf, 'CurrentAxes');
   axes(Ax);
   grid;
   GridState = strcmp(get(Ax, 'XGrid'), 'on');  
   if GridState;
      set(gcbo, 'Checked', 'on');
   else
      set(gcbo, 'Checked', 'off');
   end
   
case 'GridOnOffAll',
   AxesHandles = findobj(gcbf, 'Type', 'axes');
   for IAx = 1:length(AxesHandles)
      Ax = AxesHandles(IAx);
      axes(Ax);
      if IAx == 1
   		grid;
   		GridState = strcmp(get(Ax, 'XGrid'), 'on');  
   		if GridState;
      		set(gcbo, 'Checked', 'on');
   		else
      		set(gcbo, 'Checked', 'off');
         end
      else
         if GridState
            grid on;
         else
            grid off;
         end
      end
   end
   
case 'BoxOnOffCurrent',
   Ax = get(gcbf, 'CurrentAxes');
   axes(Ax);
   box;
   BoxState = strcmp(get(Ax, 'Box'), 'on');  
   if BoxState;
      set(gcbo, 'Checked', 'on');
   else
      set(gcbo, 'Checked', 'off');
   end
   
case 'BoxOnOffAll',
   AxesHandles = findobj(gcbf, 'Type', 'axes');
   for IAx = 1:length(AxesHandles)
      Ax = AxesHandles(IAx);
      axes(Ax);
      if IAx == 1
   		box;
   		BoxState = strcmp(get(Ax, 'Box'), 'on');  
   		if BoxState;
      		set(gcbo, 'Checked', 'on');
   		else
      		set(gcbo, 'Checked', 'off');
         end
      else
         if BoxState
            box on;
         else
            box off;
         end
      end
   end
case 'NewTitleAll',
   StartChar = 'a';
   AxesHandles = findobj(gcbf, 'Type', 'axes');
   NAx = length(AxesHandles);
   Position = zeros(NAx, 4);
   Index = 1:NAx;
   
   for IAx = 1:NAx
      Ax = AxesHandles(IAx);
      axes(Ax);
      Position(IAx, :) = get(Ax, 'Position');
   end
   
   Done = 0;
   RefPt = [0.0 1.0];
   AxNum = 1;
   while ~isempty(Position)
      %Find the first plot in the row
   	TopLeft = [Position(:, 1), Position(:,2)+Position(:,4)];
   	DistFromRef = sqrt((TopLeft(:, 1)-RefPt(1)).^2 + (TopLeft(:,2)-RefPt(2)).^2);
   	[MinDist, IRef] = min(DistFromRef);  %Find the top-left plot
      RefPosn = Position(IRef, :);
      RefHandle = AxesHandles(IRef);
      
      Sz = size(Position);
      %Look for something to the right of the current plot
         
      ThisPosn = [];
      ThisHandle = [];
      ThisIndex = [];
         
      for ISub = 1:Sz(1)
         if lIsYOverlapped(Position(ISub, :), RefPosn)
            ThisPosn = [ThisPosn; Position(ISub, :)];
            ThisHandle = [ThisHandle; AxesHandles(ISub)];
            ThisIndex = [ThisIndex; Index(ISub)];
         end
      end
         
      HDist = ThisPosn(:, 1) - RefPosn(1);
      [Dist, ColInd] = sort(HDist);
         
      for ICol = 1:length(ColInd)
    		Ax = ThisHandle(ColInd(ICol));
     		axes(Ax);
     		h = get(Ax, 'title');
     		ThisChar = char(double(StartChar)+AxNum-1);
     		set(h, 'String', ['(' ThisChar ')']);
         AxNum = AxNum + 1;
      end
      
      if ~isempty(ThisIndex)
	      Position(ThisIndex, :) = [];
   	   AxesHandles(ThisIndex) = [];
      	Index(ThisIndex) = [];
         RefPt = [RefPosn(1) RefPosn(2)];
      end
      
   end
   
   
case 'LineWidthAll',
   prompt={'Enter new line width:'};
   title='';
   lineNo=1;
   AxesHandles = findobj(gcbf, 'Type', 'axes');
   for IAx = 1:length(AxesHandles);
      HArr = get(AxesHandles(IAx), 'Children');
      for ICh = 1:length(HArr)
         if (IAx == 1) & (ICh == 1)
            def = {num2str(get(HArr(ICh), 'linewidth'))};
            Answer=inputdlg(prompt,title,lineNo,def);
            if ~isempty(Answer)
               NewWidth = str2num(Answer{1});
            else 
               NewWidth = [];
            end
   		end         
         if ~isempty(NewWidth)   
            set(HArr(ICh), 'linewidth', NewWidth);
         end
         
      end
   end
   
case 'LineWidthCurrent',
   prompt={'Enter new line width:'};
   title='';
   lineNo=1;
   Ax = get(gcbf, 'CurrentAxes');
   HArr = get(Ax, 'Children');
   for ICh = 1:length(HArr)
      if  (ICh == 1)
         def = {num2str(get(HArr(ICh), 'linewidth'))};
         Answer=inputdlg(prompt,title,lineNo,def);
         if ~isempty(Answer)
            NewWidth = str2num(Answer{1});
         else 
            NewWidth = [];
         end
   	end         
      if ~isempty(NewWidth)   
         set(HArr(ICh), 'linewidth', NewWidth);
      end
   end
   
end


function Properties = SaveAxisProperties(Ax)

%Define properties to save
AxisProperties = {'fontname', 'fontsize', 'fontunits', 'fontweight', 'fontangle'};
LabelProperties = {'string', 'fontname', 'fontsize', 'fontunits', 'fontweight', 'fontangle'};

%save specified axis properties
AxProp = get(Ax, AxisProperties);  

%save label properties
hx = get(Ax, 'xlabel');
XStrProp = get(hx, LabelProperties);
            
hy = get(Ax, 'ylabel');
YStrProp = get(hy, LabelProperties);
            
hz = get(Ax, 'zlabel');
ZStrProp = get(hz, LabelProperties);

Properties.AxPropDef = AxisProperties;
Properties.LabelPropDef = LabelProperties;
Properties.Axis = AxProp;
Properties.XStr = XStrProp;
Properties.YStr = YStrProp;
Properties.ZStr = ZStrProp;



function RestoreAxisProperties(Ax, P)

set(Ax, P.AxPropDef, P.Axis);

hx = get(Ax, 'xlabel');
set(hx, P.LabelPropDef, P.XStr);

hy = get(Ax, 'ylabel');
set(hy, P.LabelPropDef, P.YStr);
            
hz = get(Ax, 'zlabel');
set(hz, P.LabelPropDef, P.ZStr);

function Flag = lIsXOverlapped(Posn1, Posn2)
Flag = ((Posn2(1) <= Posn1(1)) & (Posn2(1)+Posn2(3) >= Posn1(1))) | ...
   ((Posn2(1) <= Posn1(1)+Posn1(3)) & (Posn2(1)+Posn2(3) >= Posn1(1)+Posn1(3)));

function Flag = lIsYOverlapped(Posn1, Posn2)
Flag = ((Posn2(2) <= Posn1(2)) & (Posn2(2)+Posn2(4) >= Posn1(2))) | ...
   ((Posn2(2) <= Posn1(2)+Posn1(4)) & (Posn2(2)+Posn2(4) >= Posn1(2)+Posn1(4)));

⌨️ 快捷键说明

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