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

📄 test_editmultiueparameter.m

📁 文件中有一个经典guide编程案例
💻 M
📖 第 1 页 / 共 3 页
字号:
function  varargout = test_EditMultiUEParameter( varargin ) 
% this function is edit some UEClass parameters .
% old function name is link_EditMultiUEParameter .
% 
% Syntax: 
%     link_EditMultiUEParameter ;   
%     link_EditMultiUEParameter( MultiUEParameter ) ;   
%     link_EditMultiUEParameter( MultiUEParameter, DialogTitle ) ;   
%     MultiUEParameter = link_EditMultiUEParameter( ... ) ;   
% 



if logical( 1 )
    % if run, call the dll file .
    link_EditMultiUEParameter ;
    return ;
end


if nargin == 0    
    
    % define the UE parameter .
    MultiUEParameter = get_DefaultMultiUEParameter ;    
    DialogTitle = '' ;
    
elseif nargin == 1  
    MultiUEParameter = varargin{1} ;
    DialogTitle = '' ;
        
elseif nargin == 2    
    if ischar( varargin{1} )   % must is callback .
        MultiUEParameter = [] ;
        DialogTitle = '' ;
    else
        MultiUEParameter = varargin{1} ;
        DialogTitle = varargin{2} ;
    end
    
else
    errordlg( 'It is too many input parameters.', 'Error' ) ;
    return ;
end



if isstruct( MultiUEParameter ) 
    
    % find if have the same figure, and close it .
    OldFigure = findobj( 'type', 'figure', 'Tag', 'EditMultiUEParameter' ) ;
    if ishandle( OldFigure )
        close( OldFigure ) ;
    end   
    
    SoftLanguage = 'Chinese' ;
    if  strcmp( SoftLanguage, 'English' )
        FigureName = 'Mixed Traffic UE Parameter' ;
    elseif  strcmp( SoftLanguage, 'Chinese' )
        FigureName = '混合业务UE参数' ;
    else
        return ;
    end

    CallFromFigureHandle = gcbf ;
     
    % generate a new figure .
    FigureHandle = com_Figure( [10 10 20 20] ) ;
    set( FigureHandle, 'Units' , 'pixels', 'Position', [20 150 250 500], ...
        'Name', DialogTitle, 'Tag', 'EditMultiUEParameter', ...
        'Resize', 'off', 'windowstyle', 'modal', 'Visible', 'on', ...
        'CloseRequestFcn', 'set(gcbf, ''Selected'', ''on'') ;'  ) ; 

    
    setappdata( FigureHandle, 'MultiUEParameter', MultiUEParameter ) ;
    setappdata( FigureHandle, 'NewMultiUEParameter', MultiUEParameter ) ;
    
    % generate the dialog .
    link_GenEditMultiUEParameter( FigureHandle, CallFromFigureHandle ) ;
    
    set( FigureHandle, 'Visible', 'on' ) ;

    init_FigureContent( FigureHandle ) ;
    
    
    waitfor( FigureHandle, 'Selected', 'on' ) ;
    
    % output the user setting result .
    if nargout > 0
        
        % get the MultiUEParameter from the figure .
        MultiUEParameter = getappdata( FigureHandle, 'NewMultiUEParameter' ) ;

        varargout{1} = MultiUEParameter ;
        
    end
    % close current dialog .
    delete( FigureHandle ) ;

    
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  link_GenEditMultiUEParameter( FigureHandle, CallFromFigureHandle ) ;

% get the old MultiUEParameter .
MultiUEParameter = getappdata( FigureHandle, 'MultiUEParameter' ) ;

% get the reference screen size .
set(0,'Units','pixels') ;
RefScreenSize = get( 0,'ScreenSize' ) ;


% init the variables .
FigureWidth = 420 ;
FigureHeight = 250 ;
TabSpace = 10 ;
TextHeight = 20 ;

if ishandle( CallFromFigureHandle )   % test .
    
    OldUnits = get( CallFromFigureHandle, 'Units' ) ;
    set( CallFromFigureHandle, 'Units', 'pixels' ) ;
    RefFigurePosition = get( CallFromFigureHandle, 'Position' ) ;
    set( CallFromFigureHandle, 'Units', OldUnits ) ;
    
    FigureXPos = RefFigurePosition(1) + TabSpace * 1 ;
    FigureYPos = RefFigurePosition(2) + RefFigurePosition(4) - FigureHeight - TabSpace * 2 ;
    
else
    FigureXPos = 20 ;
    FigureYPos = RefScreenSize(4) - FigureHeight - TabSpace * 4 ;
end


% reset the figure's size .
set( FigureHandle, 'visible','on', 'Units', 'pixels', ...
    'Position', [FigureXPos FigureYPos  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] ) ;


% generate the first group uicontrols .
% ===========================================================================================
FrameXPos = TabSpace ;
FrameWidth = FigureWidth - TabSpace * 2 ;
Frame1Height = 40 ;
FrameYPos = FigureHeight - TabSpace * 1.5 - Frame1Height ; 
Frame1Position = [FrameXPos  FrameYPos  FrameWidth  Frame1Height] ;
% generate the first frame .
com_BackgroundFrame(AxesHandle, Frame1Position ) ;



SoftLanguage = 'Chinese' ;
if  strcmp( SoftLanguage, 'English' )
    TextString = 'Calculation Method:' ;
    TextWidth = 140 ;
elseif  strcmp( SoftLanguage, 'Chinese' )
    TextString = '计算方法: ' ;
    TextWidth = 80 ;
else
    return ;
end    

TextXPos = Frame1Position(1) + TabSpace ;
TextYPos = Frame1Position(2) + TabSpace ;
TextPosition = [TextXPos  TextYPos  TextWidth  TextHeight] ;
% generate the text of Define Method .
TextHandle = com_Uicontrol( FigureHandle, TextPosition, 'subtitle', RefScreenSize ) ;
set(TextHandle, 'Tag', 'DefineMethod', 'String', TextString, 'HorizontalAlignment', 'left' ) ;


SoftLanguage = 'Chinese' ;
if  strcmp( SoftLanguage, 'English' )
    RadiobuttonString = {'UE Number[%]'; 'Throughput[%]'} ;
elseif  strcmp( SoftLanguage, 'Chinese' )
    RadiobuttonString = {'按UE数[%]'; '按吞吐量[%]'} ;
else
    return ;
end    

RadiobuttonXPos = TextPosition(1) + TextPosition(3) + TabSpace ;
RadiobuttonYPos = TextPosition(2) ;
RadiobuttonWidth = (Frame1Position(3) - TextWidth - TabSpace * 4) / 2 ;
Radiobutton1Position = [RadiobuttonXPos  RadiobuttonYPos  RadiobuttonWidth  TextHeight] ;
% generate the text of the first Method .
RadiobuttonHandle = com_Uicontrol( FigureHandle, Radiobutton1Position, 'radiobutton', RefScreenSize ) ;
set(RadiobuttonHandle, 'Tag', 'UENumberPercent', 'String', RadiobuttonString{1}, 'Value', 1, ...
    'Callback', ['link_EditMultiUEParameter(''UENumberPercent_Callback'',gcbo)'] ) ;

  
RadiobuttonXPos = Radiobutton1Position(1) + Radiobutton1Position(3) + TabSpace ;
Radiobutton2Position = [RadiobuttonXPos  RadiobuttonYPos  RadiobuttonWidth  TextHeight] ;
% generate the text of the first Method .
RadiobuttonHandle = com_Uicontrol( FigureHandle, Radiobutton2Position, 'radiobutton', RefScreenSize ) ;
set(RadiobuttonHandle, 'Tag', 'ThroughputPercent', 'String', RadiobuttonString{2}, 'Value', 0, ...
    'Callback', ['link_EditMultiUEParameter(''ThroughputPercent_Callback'',gcbo)'] ) ;
  

% the second frame .
% ---------------------------------------------------------------------------
FenceNumber1 = 4 ;
FenceButtonHeight = 25 ;

Frame2XPos = TabSpace ;
Frame2Width = FigureWidth - TabSpace * 2 ;
EditFrame2Height = (FenceNumber1 + 1) * FenceButtonHeight + 4 ;
Frame2YPos = Frame1Position(2) - TabSpace * 1.5 - EditFrame2Height ;
EditFrame2Position = [Frame2XPos  Frame2YPos  Frame2Width  EditFrame2Height] ;


% define the width of the EditFrame1 .
SliderWidth = 20 ;
FenceButtonWidth = EditFrame2Position(3) - SliderWidth - 4 ;

% generate the first frame .
EditFrame1 = com_Uicontrol( FigureHandle, EditFrame2Position, 'edit', RefScreenSize ) ;
set(EditFrame1, 'Tag', 'EditFrame1', 'enable','off', 'Visible', 'on' ) ;


% get the line slider to move line FenceButton .
SliderWidth = 20 ;
SliderXPos = EditFrame2Position(1) + EditFrame2Position(3) - 2 - SliderWidth ;
SliderYPos = EditFrame2Position(2) + 2 ;
SliderHeight = EditFrame2Position(4) - 4 ;
SliderPosition = [SliderXPos  SliderYPos  SliderWidth  SliderHeight] ;

EditFrame1Slider = com_Uicontrol( FigureHandle, SliderPosition, 'slider', RefScreenSize ) ;
set(EditFrame1Slider, 'Tag','EditFrame1Slider', 'Enable', 'off' ) ;


% define the width of every part .
Part1Wdith = (FenceButtonWidth - TabSpace * 5) * 0.32 ;
Part2Wdith = (FenceButtonWidth - TabSpace * 5) * 0.21 ;
Part3Wdith = (FenceButtonWidth - TabSpace * 5) * 0.21 ;
Part4Wdith = (FenceButtonWidth - TabSpace * 5) * 0.26 ;

for num = 1
    % generate a background frame .
    FenceButtonPosition = [(EditFrame2Position(1) + 2), ...
            (EditFrame2Position(2) + 2 + ((FenceNumber1 + 1) - num)*FenceButtonHeight), ...
            FenceButtonWidth,  FenceButtonHeight] ; 
    FenceButton1 = com_Uicontrol( FigureHandle, FenceButtonPosition, 'buttonframe', RefScreenSize ) ;
    set(FenceButton1,'Tag', ['EditFrame1FenceButton'], ...
        'Enable','off', 'Visible', 'on' ) ;

    
    SoftLanguage = 'Chinese' ;
    if  strcmp( SoftLanguage, 'English' )
        TextString = 'UEClass Name' ;
    elseif  strcmp( SoftLanguage, 'Chinese' )
        TextString = 'UE类名称' ;
    else
        return ;
    end    
    
    % generate the first title text: UEClass Name .
    Text1Position = [(FenceButtonPosition(1) + 2) , ...
            (EditFrame2Position(2) + 4 + ((FenceNumber1 + 1) - num)*FenceButtonHeight), ...
            (Part1Wdith + TabSpace * 2 - 4),  (TextHeight - 0)] ;     
    TextHandle1 = com_Uicontrol( FigureHandle , Text1Position, 'text', RefScreenSize ) ;
    set(TextHandle1, 'Tag', ['UEClassNameTitle'], 'String', TextString ) ;
    
    
    SoftLanguage = 'Chinese' ;
    if  strcmp( SoftLanguage, 'English' )
        TextString = 'UE Number[%]' ;
    elseif  strcmp( SoftLanguage, 'Chinese' )
        TextString = 'UE数[%]' ;
    else
        return ;
    end        
    % generate the second title text: Percent(%) .
    Text2Position = [(FenceButtonPosition(1) + 2 + TabSpace * 1 + Part1Wdith), ...
            (EditFrame2Position(2) + 4 + ((FenceNumber1 + 1) - num)*FenceButtonHeight), ...
            (Part2Wdith + TabSpace * 2 - 4),  (TextHeight - 0)] ;     
    TextHandle2 = com_Uicontrol( FigureHandle , Text2Position, 'text', RefScreenSize ) ;
    set(TextHandle2, 'Tag', ['UENumberPercentTitle'], 'String', TextString ) ;
    % save the handles of Percent .
    UENumberPercentHandles = TextHandle2 ; 
    
    SoftLanguage = 'Chinese' ;
    if  strcmp( SoftLanguage, 'English' )
        TextString = 'Throughput[%]' ;
        ButtonString = 'Edit' ;
    elseif  strcmp( SoftLanguage, 'Chinese' )
        TextString = '吞吐量[%]' ;
        ButtonString = '编辑' ;
    else
        return ;
    end        
    % generate the third title text: Number(/sq.km.) .
    Text3Position = [(FenceButtonPosition(1) + 2 + TabSpace * 2 + Part1Wdith + Part2Wdith), ...
            (EditFrame2Position(2) + 4 + ((FenceNumber1 + 1) - num)*FenceButtonHeight), ...
            (Part3Wdith + TabSpace * 2 - 4),  (TextHeight - 0)] ;     
    TextHandle3 = com_Uicontrol( FigureHandle , Text3Position, 'text', RefScreenSize ) ;
    set(TextHandle3, 'Tag', ['ThroughputPercentTitle'], 'String', TextString, 'Enable', 'off' ) ;
    % save the handles of Number .
    ThroughputPercentHandles = TextHandle3 ; 
    
    SoftLanguage = 'Chinese' ;
    if  strcmp( SoftLanguage, 'English' )
        TextString = 'Parameter' ;
    elseif  strcmp( SoftLanguage, 'Chinese' )
        TextString = '参数' ;
    else
        return ;
    end        
    % generate the third title text: Number(/sq.km.) .
    Text4Position = [(FenceButtonPosition(1) + 2 + TabSpace * 3 + Part1Wdith + Part2Wdith * 2 ), ...
            (EditFrame2Position(2) + 4 + ((FenceNumber1 + 1) - num)*FenceButtonHeight), ...
            (Part4Wdith + TabSpace * 2 - 4),  (TextHeight - 0)] ;     
    TextHandle3 = com_Uicontrol( FigureHandle , Text4Position, 'text', RefScreenSize ) ;
    set(TextHandle3, 'Tag', ['UEParameterTitle'], 'String', TextString, 'Enable', 'on' ) ;
end  
   

TagIndex = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ;
for num = 1: FenceNumber1

    % generate a background frame .
    FenceButtonPosition = [(EditFrame2Position(1) + 2), ...
            (EditFrame2Position(2) + 2 + (FenceNumber1 - num)*FenceButtonHeight), ...
            FenceButtonWidth,  (FenceButtonHeight + 1)] ; 
    FenceButton1 = com_Uicontrol( FigureHandle, FenceButtonPosition, 'buttonframe', RefScreenSize ) ;
    set(FenceButton1,'Tag', ['EditFrame1FenceButton', TagIndex(num)], ...
        'Enable','off', 'Visible', 'on' ) ;
    
    % generate the checkbox .
    Position = [(FenceButtonPosition(1) + TabSpace), ...
            (EditFrame2Position(2) + 5 + (FenceNumber1 - num)*FenceButtonHeight), ...
            Part1Wdith,  (TextHeight - 0)] ;     
    TextHandle1 = com_Uicontrol( FigureHandle , Position, 'checkbox', RefScreenSize ) ;
    set(TextHandle1, 'Tag', ['UEClassCheckbox', TagIndex(num)], 'FontSize', 8, ...
        'Callback', ['link_EditMultiUEParameter(''UEClassCheckbox_Callback'',gcbo)'] ) ;
    
    % generate the edit to Percent .

⌨️ 快捷键说明

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