Create property dialog. [syntax] v_out = vb_property_dlg(property_names,values,description) [input] property_names: <<cell>> String cell of property names. values : <<cell>> String cell of property default values. Its length must be the same with length(property_names). description : <<cell>> String cell of descrption of properties. [output] v_out: <<cell>> String cell of property values. [example] >> property_names = {'Colorbar','Max','Min'}; >> default_values = {'1',num2str(Jmax_plot),num2str(Jmin_plot)}; >> description ... >> = {'Colorbar is attached (1) or not (0).', ... >> 'Maximum value of the absolute value plotted.', ... >> ['Minimum threshold; vertices with values lower than ' ... >> 'the threshold are not plotted.']}; >> values = vb_property_dlg(property_names,default_values,description); >> >> if isempty(values), >> return; >> end >> >> iscbar = str2num(values{1}); >> Jmax_plot = str2num(values{2}); >> Jmin_plot = str2num(values{3}); [history] 2011-01-11 taku-y Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function varargout = vb_property_dlg(varargin) 0002 % Create property dialog. 0003 % 0004 % [syntax] 0005 % v_out = vb_property_dlg(property_names,values,description) 0006 % 0007 % [input] 0008 % property_names: <<cell>> String cell of property names. 0009 % values : <<cell>> String cell of property default values. Its 0010 % length must be the same with length(property_names). 0011 % description : <<cell>> String cell of descrption of properties. 0012 % 0013 % [output] 0014 % v_out: <<cell>> String cell of property values. 0015 % 0016 % [example] 0017 % >> property_names = {'Colorbar','Max','Min'}; 0018 % >> default_values = {'1',num2str(Jmax_plot),num2str(Jmin_plot)}; 0019 % >> description ... 0020 % >> = {'Colorbar is attached (1) or not (0).', ... 0021 % >> 'Maximum value of the absolute value plotted.', ... 0022 % >> ['Minimum threshold; vertices with values lower than ' ... 0023 % >> 'the threshold are not plotted.']}; 0024 % >> values = vb_property_dlg(property_names,default_values,description); 0025 % >> 0026 % >> if isempty(values), 0027 % >> return; 0028 % >> end 0029 % >> 0030 % >> iscbar = str2num(values{1}); 0031 % >> Jmax_plot = str2num(values{2}); 0032 % >> Jmin_plot = str2num(values{3}); 0033 % 0034 % [history] 0035 % 2011-01-11 taku-y 0036 % 0037 % Copyright (C) 2011, ATR All Rights Reserved. 0038 % License : New BSD License(see VBMEG_LICENSE.txt) 0039 0040 % Begin initialization code 0041 gui_Singleton = 1; 0042 gui_State = struct('gui_Name', mfilename, ... 0043 'gui_Singleton', gui_Singleton, ... 0044 'gui_OpeningFcn', @vb_property_dlg_OpeningFcn, ... 0045 'gui_OutputFcn', @vb_property_dlg_OutputFcn, ... 0046 'gui_LayoutFcn', [] , ... 0047 'gui_Callback', []); 0048 0049 if nargin && ischar(varargin{1}), % init/invoke callback func 0050 gui_State.gui_Callback = str2func(varargin{1}); 0051 end 0052 0053 if nargout, 0054 [varargout{1:nargout}] = gui_mainfcn(gui_State,varargin{:}); 0055 else 0056 gui_mainfcn(gui_State,varargin{:}); 0057 end 0058 0059 % --- Executes just before vb_property_dlg is made visible. 0060 function vb_property_dlg_OpeningFcn(hObject, eventdata, handles, varargin) 0061 % This function has no output args, see OutputFcn. 0062 % hObject handle to figure 0063 % eventdata reserved - to be defined in a future version of MATLAB 0064 % handles structure with handles and user data (see GUIDATA) 0065 % varargin command line arguments to vb_property_dlg (see VARARGIN) 0066 0067 % Choose default command line output for property_dlg 0068 handles.output = ''; 0069 handles.property_names = varargin{1}; 0070 handles.description = varargin{3}; 0071 values = varargin{2}; 0072 set(handles.figure1,'UserData',values); 0073 0074 % Initialize listbox1 and edit1 and text4 0075 for i=1:length(varargin{1}) 0076 listbox1_str{i} = [handles.property_names{i} ': ' values{i}]; 0077 end 0078 set(handles.listbox1,'String',listbox1_str); 0079 set(handles.edit1,'String',values{1}); 0080 set(handles.text4,'String',handles.description{1}); 0081 0082 % Update handles structure 0083 guidata(hObject, handles); 0084 0085 % UIWAIT makes vb_property_dlg wait for user response (see UIRESUME) 0086 uiwait(handles.figure1); 0087 0088 % --- Outputs from this function are returned to the command line. 0089 function varargout = vb_property_dlg_OutputFcn(hObject, eventdata, handles) 0090 % varargout cell array for returning output args (see VARARGOUT); 0091 % hObject handle to figure 0092 % eventdata reserved - to be defined in a future version of MATLAB 0093 % handles structure with handles and user data (see GUIDATA) 0094 0095 % Get default command line output from handles structure 0096 varargout{1} = get(handles.figure1,'UserData'); 0097 delete(handles.figure1); 0098 0099 % --- Executes on button press in pushbutton1. 0100 function pushbutton1_Callback(hObject, eventdata, handles) 0101 % hObject handle to pushbutton1 (see GCBO) 0102 % eventdata reserved - to be defined in a future version of MATLAB 0103 % handles structure with handles and user data (see GUIDATA) 0104 0105 uiresume(handles.figure1); 0106 0107 % --- Executes on button press in pushbutton2. 0108 function pushbutton2_Callback(hObject, eventdata, handles) 0109 % hObject handle to pushbutton1 (see GCBO) 0110 % eventdata reserved - to be defined in a future version of MATLAB 0111 % handles structure with handles and user data (see GUIDATA) 0112 0113 set(handles.figure1,'UserData',''); 0114 uiresume(handles.figure1); 0115 0116 % --- Executes on selection change in listbox1. 0117 function listbox1_Callback(hObject, eventdata, handles) 0118 % hObject handle to listbox1 (see GCBO) 0119 % eventdata reserved - to be defined in a future version of MATLAB 0120 % handles structure with handles and user data (see GUIDATA) 0121 0122 % Hints: contents = get(hObject,'String') returns listbox1 contents as cell array 0123 % contents{get(hObject,'Value')} returns selected item from listbox1 0124 0125 ix = get(hObject,'Value'); 0126 values = get(handles.figure1,'UserData'); 0127 set(handles.edit1,'String',values{ix}); 0128 set(handles.text4,'String',handles.description{ix}); 0129 0130 % --- Executes during object creation, after setting all properties. 0131 function listbox1_CreateFcn(hObject, eventdata, handles) 0132 % hObject handle to listbox1 (see GCBO) 0133 % eventdata reserved - to be defined in a future version of MATLAB 0134 % handles empty - handles not created until after all CreateFcns called 0135 0136 % Hint: listbox controls usually have a white background on Windows. 0137 % See ISPC and COMPUTER. 0138 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0139 set(hObject,'BackgroundColor','white'); 0140 end 0141 0142 function edit1_Callback(hObject, eventdata, handles) 0143 % hObject handle to edit1 (see GCBO) 0144 % eventdata reserved - to be defined in a future version of MATLAB 0145 % handles structure with handles and user data (see GUIDATA) 0146 0147 % Hints: get(hObject,'String') returns contents of edit1 as text 0148 % str2double(get(hObject,'String')) returns contents of edit1 as a double 0149 0150 ix = get(handles.listbox1,'Value'); 0151 values = get(handles.figure1,'UserData'); 0152 value = get(hObject,'String'); 0153 values{ix} = value; 0154 set(handles.figure1,'UserData',values); 0155 listbox1_str = get(handles.listbox1,'String'); 0156 listbox1_str{ix} = [handles.property_names{ix} ': ' value]; 0157 set(handles.listbox1,'String',listbox1_str); 0158 0159 % --- Executes during object creation, after setting all properties. 0160 function edit1_CreateFcn(hObject, eventdata, handles) 0161 % hObject handle to edit1 (see GCBO) 0162 % eventdata reserved - to be defined in a future version of MATLAB 0163 % handles empty - handles not created until after all CreateFcns called 0164 0165 % Hint: edit controls usually have a white background on Windows. 0166 % See ISPC and COMPUTER. 0167 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0168 set(hObject,'BackgroundColor','white'); 0169 end 0170