Home > vbmeg > functions > gui > current_gui_dir > current_gui_advanced.m

current_gui_advanced

PURPOSE ^

Edit dvanced parameter of current_parm field and return.

SYNOPSIS ^

function [current_parm, cancelled] = current_gui_advanced(varargin)

DESCRIPTION ^

 Edit dvanced parameter of current_parm field and return.
 [USAGE]
    [current_parm] = current_gui_advanced('init' [,current_parm]);
 [IN]
    varargin{1} : command
    varargin{2} : command parameter
 [OUT]
    current_parm : updated current_parm
       cancelled : cancelled to input.

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [current_parm, cancelled] = current_gui_advanced(varargin)
0002 % Edit dvanced parameter of current_parm field and return.
0003 % [USAGE]
0004 %    [current_parm] = current_gui_advanced('init' [,current_parm]);
0005 % [IN]
0006 %    varargin{1} : command
0007 %    varargin{2} : command parameter
0008 % [OUT]
0009 %    current_parm : updated current_parm
0010 %       cancelled : cancelled to input.
0011 %
0012 % Copyright (C) 2011, ATR All Rights Reserved.
0013 % License : New BSD License(see VBMEG_LICENSE.txt)
0014 
0015 if nargin == 0
0016     key = 'init';
0017 else
0018     key = varargin{1};
0019 end
0020 
0021 if ~strcmp(key, 'init')
0022     h = get(0, 'CurrentFigure');
0023     data = figure_load_data(h);
0024 end
0025 
0026 
0027 switch(key)
0028     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029     % --- public
0030     % These interfaces are able to use from external function.
0031     case 'init'
0032          if nargin < 2
0033              current_parm = [];
0034          else
0035              current_parm = varargin{2};
0036          end
0037         % multiple launching of the allication is prohibited.
0038         h = findobj('Name', APPLICATION_NAME);
0039         if ~isempty(h)
0040             res = questdlg('Already opened. Reopen?',...
0041                                 'confirm', 'Yes', 'No', 'Yes');
0042             if strcmp(res, 'Yes')
0043                 destruct_gui;
0044             else
0045                 % figure pull up to top.
0046                 figure(h);
0047                 return;
0048             end
0049         end
0050         % create gui
0051         data = create_gui(current_parm);
0052         figure_save_data(data.H.figure, data);
0053         
0054         % wait for figure property Visible = off
0055         waitfor(data.H.figure, 'Visible', 'off');
0056 
0057         % get return data
0058         data = figure_load_data(data.H.figure);
0059         cancelled    = data.cancelled;
0060         current_parm = data.current_parm;
0061         % delete figure
0062         destruct_gui;
0063         return;
0064     case 'exit'
0065          destruct_gui;
0066          return;
0067     case 'set_parm'
0068         current_parm = varargin{2};
0069         set_parm_gui(data, current_parm);
0070     case 'get_parm'
0071         current_parm = get_parm_gui(data);
0072     
0073     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0074     % --- private
0075     % These interfaces are for current_gui_advanced.
0076     % Don't use from external function.
0077     %
0078     case 'callback'
0079         hObj = varargin{2};
0080         data = callback(data, hObj);
0081 end
0082 % Save application data to the figure.
0083 figure_save_data(data.H.figure, data);
0084 
0085 
0086 function [data] = create_gui(current_parm)
0087 % create figure and application data.
0088 % [IN]
0089 %    current_parm : current parameter
0090 % [OUT]
0091 %    data : application data
0092 %           .H            : gui component handles
0093 %           .H.figure     : figure handle
0094 %           .cancelled    : cancel button pushed flag(true or false)
0095 %           .current_parm : current parameter to return
0096 
0097     fig = openfig('current_gui_advanced');
0098     H = guihandles(fig);
0099     H.figure = fig;
0100     set(fig, 'Name', APPLICATION_NAME);
0101 
0102     % make application data
0103     data = struct;
0104     data.H = H;
0105     data.cancelled = false;
0106     data.current_parm = current_parm;
0107 
0108 % end of create_gui();
0109 
0110 function destruct_gui
0111 % destruct figure
0112 % [IN]
0113 %    none
0114 % [OUT]
0115 %    none
0116 
0117     h = get(0, 'CurrentFigure');
0118     if strcmp(get(h, 'Name'), APPLICATION_NAME)
0119     else
0120         h = findobj('Name', APPLICATION_NAME);
0121     end
0122     try
0123         delete(h);
0124     catch
0125     end
0126 % end of destruct_gui()
0127 
0128 function figure_save_data(fig, data)
0129 % Save application data to the figure
0130 % [IN]
0131 %    fig : figure handle for save.
0132 %   data : @see create_gui
0133     guidata(fig, data);
0134 % end of figure_save_data()
0135 
0136 function [data] = figure_load_data(fig)
0137 % Load application data from the figure
0138     data = [];
0139     if isempty(fig) || ~ishandle(fig)
0140         data.current_parm = [];
0141         data.cancelled = true;
0142     else
0143         data = guidata(fig);
0144     end
0145 % end of figure_load_data()
0146 
0147 function [data] = callback(data, hObj)
0148 % This function will called by gui event.
0149 % [IN]
0150 %    data : application data (@see create_gui())
0151 %    hObj : gui component handle(event)
0152 % [OUT]
0153 %    data : application data (@see create_gui())
0154 
0155 H = data.H;
0156 switch(hObj)
0157     case {H.overlapped_radiobutton, H.concatenate_radiobutton}
0158         radiobutton_group = [H.overlapped_radiobutton, ...
0159                              H.concatenate_radiobutton];
0160         set(radiobutton_group, 'Value', 0);
0161         set(hObj, 'Value', 1);
0162     case H.cancel_push
0163         data.cancelled = true;
0164         set(H.figure, 'Visible', 'off');
0165     case H.ok_push
0166         data.current_parm = get_parm_gui(data);
0167         data.cancelled = false;
0168         set(H.figure, 'Visible', 'off');
0169 end
0170 
0171 get(hObj, 'Tag')
0172 
0173 
0174 function current_parm = get_parm_gui(data)
0175     current_parm = [];
0176 
0177 function v = APPLICATION_NAME
0178     v = 'current_parm';
0179

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005