📄 xianshi.asv
字号:
function varargout = xianshi( varargin )
% this module display the results .
% February 2004
% $Revision: 1.00 $
if (nargin == 0) | isstruct( varargin{1} ) % LAUNCH GUI
if nargin == 1
T_SimulationData = varargin{1} ;
else
T_SimulationData = [] ;
end
% find if have the same figure, and close it .
OldFigure = findobj( 'type', 'figure', 'Tag', 'xianshi' ) ;
if ishandle( OldFigure )
close( OldFigure ) ;
end
% generate a new figure .
FigureHandle = figure( 'Visible', 'off' ) ;
set( FigureHandle, 'Units' , 'pixels', 'Position', [150 150 500 300], ...
'Name', 'T型自卸汽车优化分析程序(优化后)', ...
'Tag', 'xianshi', ...
'FileName' , '' ,...
'MenuBar' , 'none' ,...
'NumberTitle' , 'off' ,...
'Resize', 'off', ...
'windowstyle', 'normal', ...
'Visible', 'off' ) ;
% generate the menu .
generate_MenuContent( FigureHandle ) ;
% generate the uicontrols .
generate_FigureContent( FigureHandle ) ;
% save the T_SimulationData .
setappdata( FigureHandle, 'T_SimulationData', T_SimulationData ) ;
% display the figure .
movegui( FigureHandle, 'center' ) ;
% set( findobj( FigureHandle, 'Type', 'uicontrol' ), 'Units', 'normalized' ) ;
set( FigureHandle, 'Visible', 'on', ...
'ResizeFcn','off' ) ;
% init the data .
init_FigureContent( FigureHandle ) ;
if nargout > 0
varargout{1} = FigureHandle;
end
elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK
global SET_DEBUG_VALUE_IN_SIMULATOR ;
if isempty( SET_DEBUG_VALUE_IN_SIMULATOR ) | ~isnumeric( SET_DEBUG_VALUE_IN_SIMULATOR )
SET_DEBUG_VALUE_IN_SIMULATOR = 0 ;
else
end
if SET_DEBUG_VALUE_IN_SIMULATOR == 1 ;
if (nargout)
[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
else
feval(varargin{:}); % FEVAL switchyard
end
else
try
if (nargout)
[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
else
feval(varargin{:}); % FEVAL switchyard
end
catch
disp(lasterr);
end
end
end
% ------------------------------------------------------------
function generate_MenuContent( FigureHandle ) ;
% generate the file menu .
% ------------------------------------------------------------
MenuHandle = uimenu( 'Parent', FigureHandle, 'Label', '文件(&F)' ) ;
% define the parameters of the menus .
MenuLabel = { '打开(&O)'; '保存(&S)'; '退出(&E)' } ;
% add Polygon at 2003.10.13 .
MenuTag = { 'MenuOpenResult'; 'MenuSaveResult'; 'MenuClose' } ;
MenuCallback = { ['T_youhua( ''MenuOpenHistory_Callback'', gcbf)']; ...
['xianshi( ''SaveResult_Callback'', gcbf)']; ...
['close all;'] } ;
SeparatorGroup = { 'off'; 'off'; 'on' } ;
% generate the uimenus of file .
for num = 1: length( MenuTag )
% for num = 3
UimenuHandle(num) = uimenu( MenuHandle ) ;
set( UimenuHandle(num), 'Tag' , MenuTag{num} , ...
'Callback' , MenuCallback{num} , ...
'Label' , MenuLabel{num} , ...
'Separator', SeparatorGroup{num} ) ;
end
% ------------------------------------------------------------
% ------------------------------------------------------------
MenuHandle = uimenu( FigureHandle, 'Label', '参数(&P)' ) ;
% define the parameters of the menus .
MenuLabel = { '导入(&L)'; '保存(&E)' } ;
% add Polygon at 2003.10.13 .
MenuTag = { 'MenuLoadData'; 'MenuSaveData' } ;
MenuCallback = { ...
['xianshi( ''LoadData_Callback'', gcbo)']; ...
['xianshi( ''SaveData_Callback'', gcbo)']; } ;
SeparatorGroup = { 'off'; 'on' } ;
% generate the uimenus of file .
for num = 1: length( MenuTag )
UimenuHandle(num) = uimenu( MenuHandle ) ;
set( UimenuHandle(num), 'Tag' , MenuTag{num} , ...
'Callback' , MenuCallback{num} , ...
'Label' , MenuLabel{num} , ...
'Separator', SeparatorGroup{num} ) ;
end
%----------------------------------------------------------
MenuHandle = uimenu( FigureHandle, 'Label', '结果(&m)' ) ;
% define the parameters of the menus .
MenuLabel = { '传动角' } ;
% add Polygon at 2003.10.13 .
MenuTag = { 'chuandong'} ;
MenuCallback = { ...
'xianshi( ''chuandong'', gcbo)' } ;
SeparatorGroup = { 'off' } ;
% generate the uimenus of file .
for num = 1: 1
UimenuHandle(num) = uimenu( MenuHandle ) ;
set( UimenuHandle(num), 'Tag' , MenuTag{num} , ...
'Callback' , MenuCallback{num} , ...
'Label' , MenuLabel{num} , ...
'Separator', SeparatorGroup{num} ) ;
end
% generate the parameter menu .
% ------------------------------------------------------------
MenuHandle = uimenu( FigureHandle, 'Label', '帮助(&H)', 'Enable', 'on' ) ;
% define the parameters of the menus .
MenuLabel = { '帮助(&P)'; '演示(&D)'; '关于(&A)';'时钟(&S)' } ;
% add Polygon at 2003.10.13 .
MenuTag = { 'MenuHelp'; 'MenuDemo'; 'MenuAbout';'shijian' } ;
MenuCallback = { ...
['T_youhua( ''MenuHelp_Callback'', gcbo)']; ...
['T_youhua( ''MenuDemo_Callback'', gcbo)']; ...
['T_youhua( ''MenuAbout_Callback'', gcbo)'];...
['T_youhua( ''shizhong'', gcbo)']} ;
SeparatorGroup = { 'off'; 'on'; 'on'; 'on' } ;
% generate the uimenus of file .
for num = 1: length( MenuTag )
UimenuHandle(num) = uimenu( MenuHandle ) ;
set( UimenuHandle(num), 'Tag' , MenuTag{num} , ...
'Callback' , MenuCallback{num} , ...
'Label' , MenuLabel{num} , ...
'Separator', SeparatorGroup{num} ) ;
end
% ------------------------------------------------------------
function generate_FigureContent( FigureHandle )
% generate the uicontrols .
% init the variables .
FigureWidth = 700 ;
FigureHeight = 500 ;
TabSpace = 10 ;
TextHeight = 22 ;
ChangeYPos = 30 ;
% reset the figure's size .
set( FigureHandle, 'Units', 'pixels', ...
'Position', [150 150 FigureWidth FigureHeight], ...
'DoubleBuffer', 'on' ) ;
% generate the axes to plot lines .
AxesHandle = axes( 'Parent', FigureHandle, 'Units' , 'pixels' , ...
'Position', [0 0 FigureWidth FigureHeight], 'Visible', 'off', ...
'Tag', 'BackgroundAxes', ...
'Xlim', [0 FigureWidth], 'Ylim', [0 FigureHeight] ) ;
% get the color of the figure .
FigureColor = get( FigureHandle, 'Color' ) ;
% reset the default value of the uicontrols .
set(FigureHandle,'defaultuicontrolunits','normalized');
set(FigureHandle,'defaultuicontrolfontname','隶书');
set(FigureHandle,'defaultuicontrolBackgroundColor', FigureColor );
% generate the parameters of the Analyze .
% -----------------------------------------------------------------------------
% define the first frame .
% FrameXPos = Frame1Position(1) + Frame1Position(3) + TabSpace * 1.5 ;
FrameXPos = TabSpace * 1.5 ;
FrameWidth = FigureWidth - TabSpace * 3 -200;
FrameHeight = FigureHeight - TabSpace * (8 + 5)+20 ;
FrameYPos = FigureHeight - FrameHeight - TabSpace * 1.5-20 ;
Frame1Position = [FrameXPos FrameYPos FrameWidth FrameHeight] ;
% generate a frame .
LineXData = [FrameXPos FrameXPos (FrameXPos + FrameWidth) (FrameXPos + FrameWidth) FrameXPos] ;
LineYData = [FrameYPos (FrameYPos + FrameHeight) (FrameYPos + FrameHeight) FrameYPos FrameYPos] ;
LineHandle = line ( 'Parent', AxesHandle, 'XData', LineXData, 'YData', LineYData,...
'Tag', 'FrameLine1', 'LineStyle', '-', 'Color', [0 0 0], 'Marker', 'none' );
TextXPos = Frame1Position(1) + 15 ;
TextYPos = Frame1Position(2) + Frame1Position(4) - 12 ;
TextWidth = 80 ;
TextPosition = [TextXPos TextYPos TextWidth TextHeight] ;
% subtitle: 分析
SubtitleHandle = uicontrol(FigureHandle, 'Style','text', 'Units','pixels',...
'Position',TextPosition,'horizontal','center',...
'Tag', 'AnalyzeText', 'String', '受力分析', 'fontsize',13 );
% get the position of the axeses .
AxesXPos = Frame1Position(1) + TabSpace * 5.5 ;
AxesWidth = (Frame1Position(3) - TabSpace * 17) / 3 +250;
AxesHeight = (Frame1Position(4) - TabSpace * 15) / 2 +170;
AxesYPos = Frame1Position(2) + Frame1Position(4) - AxesHeight - TabSpace * 3-20 ;
AxesPosition = [AxesXPos AxesYPos AxesWidth AxesHeight] ;
% generate the axes to plot lines .
AxesHandle = axes( 'Parent', FigureHandle, 'Units' , 'Pixels' , ...
'Position', AxesPosition, 'Visible', 'on', ...
'Tag', 'ax_plot','XDir','reverse','YAxisLocation','right') ;
%generate the pushbotton to contol the plot
ButtonWidth = 50 ;
ButtonHeight = 30 ;
ButtonXPos = 450+60*(1:3) ;
ButtonYPos = 80+50*(1:7) ;
pushbotton1 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', [ButtonXPos(1) ButtonYPos(1) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton1', 'string','Fo' , 'Fontsize',12, ...
'Callback', ['xianshi(''pushbotton1_Callback'',gcbo)'] ) ;
pushbotton2 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', [ButtonXPos(2) ButtonYPos(1) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton2', 'string','Fa' , 'Fontsize',12, ...
'Callback',[ 'xianshi(''pushbotton2_Callback'',gcbo)'] ) ;
pushbotton3 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', [ButtonXPos(3) ButtonYPos(1) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton3', 'string','Fj' , 'Fontsize',12, ...
'Callback', ['xianshi(''pushbotton3_Callback'',gcbo)'] ) ;
pushbotton4 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', [ButtonXPos(1) ButtonYPos(2) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton4', 'string','FA' , 'Fontsize',12, ...
'Callback', ['xianshi(''pushbotton4_Callback'',gcbo)'] ) ;
pushbotton5 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', [ButtonXPos(2) ButtonYPos(2) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton5', 'string','FB' , 'Fontsize',12, ...
'Callback', ['xianshi(''pushbotton5_Callback'',gcbo)'] ) ;
pushbotton6 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', [ButtonXPos(3) ButtonYPos(2) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton6', 'string','FC' , 'Fontsize',12, ...
'Callback', ['xianshi(''pushbotton6_Callback'',gcbo)'] ) ;
pushbotton7 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', [ButtonXPos(1) ButtonYPos(3) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton7', 'string','FO' , 'Fontsize',12, ...
'Callback',[ 'xianshi(''pushbotton7_Callback'',gcbo)'] ) ;
pushbotton8 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', [ButtonXPos(2) ButtonYPos(3) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton8', 'string','FO1' , 'Fontsize',12, ...
'Callback', ['xianshi(''pushbotton8_Callback'',gcbo)'] ) ;
pushbotton9 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', [ButtonXPos(3) ButtonYPos(3) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton9', 'string','FO2' , 'Fontsize',12, ...
'Callback', ['xianshi(''pushbotton9_Callback'',gcbo)'] ) ;
pushbotton10 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', [ButtonXPos(1) ButtonYPos(4) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton10', 'string','L' , 'Fontsize',12, ...
'Callback', ['xianshi(''pushbotton10_Callback'',gcbo)'] ) ;
pushbotton11 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', [ButtonXPos(2) ButtonYPos(4) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton11', 'string','D' , 'Fontsize',12, ...
'Callback', ['xianshi(''pushbotton11_Callback'',gcbo)'] ) ;
pushbotton12 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels','Position', [ButtonXPos(3) ButtonYPos(4) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton12', 'string','P' , 'Fontsize',12, ...
'Callback', ['xianshi(''pushbotton12_Callback'',gcbo)'] ) ;
pushbotton13 = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', [ButtonXPos(1) ButtonYPos(5) ButtonWidth ButtonHeight], ...
'Style', 'pushbutton', 'Tag','pushbotton13', 'string','reset' , 'Fontsize',12, ...
'Callback', ['xianshi(''pushbotton13_Callback'',gcbo)'] ) ;
% define the parameters of the buttons .
ButtonString = { '上一步'; ...
'打开'; ...
'保存'; ...
'下一步' } ;
ButtonTag = { 'PreviousButton'; ...
'LoadResultButton'; ...
'SaveResultButton'; ...
'NextButton' } ;
ButtonCallback = { ['xianshi(''PreviousButton_Callback'',gcbo)']; ...
['xianshi( ''DataLoadResult_Callback'', gcbf)']; ...
['xianshi(''DataSaveResult_Callback'',gcbo)']; ...
['xianshi(''NextButton_Callback'',gcbo)'] } ;
ButtonWidth = 80 ;
ButtonHeight = 25 ;
ButtonXPos = FigureWidth - ButtonWidth * 4 - TabSpace * 5 ;
ButtonYPos = TabSpace * 2 ;
ButtonPosition = [ButtonXPos ButtonYPos ButtonWidth ButtonHeight] ;
for num = 1: 4
TempButtonPosition = ButtonPosition ;
TempButtonPosition(1) = TempButtonPosition(1) + (num - 1) * (ButtonWidth + TabSpace) ;
% generate the pushbutton: OK .
ButtonHandle = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', TempButtonPosition, ...
'Style', 'pushbutton', 'Tag',ButtonTag{num}, 'string', ButtonString{num}, 'Fontsize',12, ...
'Callback', ButtonCallback{num} ) ;
end
handles = guihandles( FigureHandle ) ;
guidata( FigureHandle, handles ) ;
% --------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -