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

📄 t_youhua.m

📁 matlab 遗传算法的程序
💻 M
📖 第 1 页 / 共 2 页
字号:
function  varargout = T_youhua( varargin )
% this module open the soft .

%  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', 'T_youhua' ) ;
    if ishandle( OldFigure )
        close( OldFigure ) ;
    end
     FigureHandle = figure( 'Visible', 'off' ) ;
    set( FigureHandle, 'Units' , 'pixels', 'Position', [150 150 300 300], ...
        'Name', 'T型自卸汽车优化分析程序', ...
        'Tag', 'T_youhua', ...
        '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( FigureHandle, 'Visible', 'on' ) ;
% 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)'; '退出(&E)' } ;

% add Polygon at 2003.10.13 .
MenuTag = { 'MenuOpenHistory'; 'MenuClose' } ;
MenuCallback = { ...
    ['T_youhua( ''MenuOpenHistory_Callback'', gcbf)']; ...
    ['close all;'] } ;
SeparatorGroup = { 'off'; 'on' } ;

% generate the uimenus of file .
for num = 1: length( MenuTag )
% for num = 2
    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', '参数(&P)' ) ;
% 
% % define the parameters of the menus .
% MenuLabel = { '导入(&L)'; '编辑(&E)' } ;
% 
% % add Polygon at 2003.10.13 .
% MenuTag = { 'MenuLoadData'; 'MenuEditParameter' } ;
% MenuCallback = { ...
%     ['T_youhua( ''MenuLoadData_Callback'', gcbo)']; ...
%     ['T_youhua( ''BeginButton_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


% 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 = 20 ;
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' , 'normalized' ,  ...
    'Position', [0 0 1 1], 'Visible', 'off', ...
    '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 );


% define the first frame .
FrameXPos = TabSpace ;
FrameWidth = FigureWidth - TabSpace * 2 ;
FrameHeight = 60 ;
FrameYPos = FigureHeight - FrameHeight - TabSpace * 2 ;
Frame1Position = [FrameXPos  FrameYPos  FrameWidth  FrameHeight] ;
% generate the second frame .
% com_BackgroundFrame(AxesHandle, Frame1Position ) ;
h_text1=uicontrol(FigureHandle,'style','text', 'unit','pixels',...
    'position',Frame1Position,'tag','h_text1','Horizontal','center','visible','off',...
    'string',{'T型自卸汽车优化分析软件'},'fontsize',30);
FrameXPos = TabSpace ;
FrameWidth = FigureWidth - TabSpace * 2 ;
FrameHeight = 60 ;
FrameYPos = FigureHeight - FrameHeight - TabSpace * 2 -90;
Frame1Position = [FrameXPos  FrameYPos  FrameWidth  FrameHeight] ;
h_text2=uicontrol(FigureHandle,'style','text', 'unit','pixels',...
    'position',Frame1Position,'tag','h_text2','Horizontal','center','visible','off',...
    'string',{'指导老师 :  徐锐良  制作 :  崔林林    '},'fontsize',20);

% generate the axes to plot lines .

% load the picture data .
ImageCData = imread( 'Tt.bmp', 'BMP' ) ;
for num1 = 1:3
    ImageCData(:,:,num1) = flipud( ImageCData(:,:,num1) ) ;
end

ImageXPos = TabSpace * 5 ;
ImageYPos = TabSpace * 5 ;
ImageWidth = 450 ;
ImageHeight = 300 ;
ImageXData = ImageXPos + [0  ImageWidth] ;
ImageYData = ImageYPos + [0  ImageHeight] ;
% generate a image to display picture .
MovieImageHandle = image( 'Parent', AxesHandle, ...
    'XData', ImageXData, 'YData', ImageYData, ...
    'Cdata', ImageCData ) ;
 


% define the parameters of the buttons .
ButtonString = { '开始'; '演示实例'; '使用说明' } ; 
ButtonTag = { 'BeginButton'; 'DemoButton'; 'HelpButton' } ;
ButtonCallback = { ['T_youhua(''BeginButton_Callback'',gcbo)']; ...
        ['T_youhua(''MenuDemo_Callback'',gcbo)']; ...
        ['T_youhua(''MenuHelp_Callback'',gcbo)'] } ;
ButtonEnable = { 'on'; 'on'; 'on' } ;

ButtonWidth = 120 ;
ButtonHeight = 32 ;
ButtonXPos = FigureWidth - ButtonWidth - TabSpace * 3 ;
ButtonYPos = TabSpace * 1 + ButtonHeight * 3 + TabSpace * 2+60 ;
ButtonPosition = [ButtonXPos  ButtonYPos  ButtonWidth  ButtonHeight] ;
for num = 1: 3
    TempButtonPosition = ButtonPosition ;
    TempButtonPosition(2) = TempButtonPosition(2) - (num - 1) * (ButtonHeight + TabSpace * 0.5)*2.5+60 ;
    % generate the pushbutton: OK .
    ButtonHandle = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', TempButtonPosition, ...
        'Style', 'pushbutton', 'Tag',ButtonTag{num}, 'string', ButtonString{num}, 'Fontsize',15,'visible','off', ...
        'Callback', ButtonCallback{num}, 'Enable', ButtonEnable{num} ) ;
    
end


handles = guihandles( FigureHandle ) ;
guidata( FigureHandle, handles ) ;




% --------------------------------------------------------------------------
function  init_FigureContent( h )
       
handles = guidata( h ) ;

% get the T_SimulationData .
T_SimulationData = getappdata( handles.T_youhua, 'T_SimulationData' ) ;
if isempty( T_SimulationData )
    T_SimulationData = T_youhua( 'Get_DefaultT_SimulationData' ) ;    
    % save the data .
    setappdata( handles.T_youhua, 'T_SimulationData', T_SimulationData ) ;
end

   micintro ;
set(handles.h_text1,'visible','on');
set(handles.h_text2,'visible','on');
set(handles.BeginButton,'visible','on');
set(handles.DemoButton,'visible','on');
set(handles.HelpButton,'visible','on');
% --------------------------------------------------------------------------
function   T_SimulationData = Get_DefaultT_SimulationData ;
% init all of the parameters .

T_SimulationData = GetDefaultT_Parameter ;




% --------------------------------------------------------------------------
function  MenuOpenHistory_Callback( h )
       
handles = guidata( h ) ;


PromptString = '选择数据文件.' ;
WarningString1 = '文件格式出错。 ' ;
WarningString2 = '选择的文件不是正确的数据文件。 ' ;


[ FileName , PathName ] = uigetfile( {'*.mat','数据文件(*.mat)'}, PromptString ) ;


if FileName == 0
    return ;    
else
    
    [TempPathName, FileName, FileTypeName, Version] = fileparts( FileName ) ;

    if ~strcmp( FileTypeName, '.mat' ) ;
        warndlg( WarningString1, '警告', 'modal' ) ;
        return ;
    end
    SaveFile = fullfile( PathName, [FileName, FileTypeName, Version] ) ;
end

⌨️ 快捷键说明

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