Home > src > createSOS_dialog.m

# createSOS_dialog

## PURPOSE

- create SOS optimizer dialog

## SYNOPSIS

function varargout = createSOS_dialog(varargin)

## DESCRIPTION

     - create SOS optimizer dialog

     copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut

        This file is part of SOS

        SOS is free software: you can redistribute it and/or modify
        it for academic and non-commercial purposes
        under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.  For commercial or for-profit
        uses, please contact the authors (sos@cnbc.cmu.edu).

        SOS is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

## CROSS-REFERENCE INFORMATION

This function calls:

- getPopupMenuName - retrieves the popup menu name in the GUI
- validatePositiveInteger - helper function to validate that a string represents a positive integer
- verbosePrint - master print function that regulates cmd line output based on verbosity flags

This function is called by:

- sos_gui - sos main GUI

## SUBFUNCTIONS

- function createSOS_dialog_OpeningFcn(hObject, eventdata, handles, varargin)
- function varargout = createSOS_dialog_OutputFcn(hObject, eventdata, handles)
- function edit_maxIt_Callback(hObject, eventdata, handles)
- function flag = validate_maxIt(handles)
- function edit_maxIt_CreateFcn(hObject, eventdata, handles)
- function edit_reportInterval_Callback(hObject, eventdata, handles)
- function flag = validate_reportInterval(handles)
- function edit_reportInterval_CreateFcn(hObject, eventdata, handles)
- function edit_statInterval_Callback(hObject, eventdata, handles)
- function flag = validate_statInterval(handles)
- function edit_statInterval_CreateFcn(hObject, eventdata, handles)
- function pushbutton1_Callback(hObject, eventdata, handles)
- function popupmenu_statReportStyle_Callback(hObject, eventdata, handles)
- function popupmenu_statReportStyle_CreateFcn(hObject, eventdata, handles)
- function edit_stopFreezeIt_Callback(hObject, eventdata, handles)
- function flag = validate_stopFreezeIt(handles)
- function edit_stopFreezeIt_CreateFcn(hObject, eventdata, handles)
- function edit_blockSize_Callback(hObject, eventdata, handles)
- function flag = validate_blockSize(handles)
- function edit_blockSize_CreateFcn(hObject, eventdata, handles)
- function popupmenu_targSampleCandSelectMethod_Callback(hObject, eventdata, handles)
- function popupmenu_targSampleCandSelectMethod_CreateFcn(hObject, eventdata, handles)
- function popupmenu_pSwapFunction_Callback(hObject, eventdata, handles)
- function popupmenu_pSwapFunction_CreateFcn(hObject, eventdata, handles)
- function pushbutton_createSOS_Callback(hObject, eventdata, handles)
- function popupmenu_feederdfCandSelectMethod_Callback(hObject, eventdata, handles)
- function popupmenu_feederdfCandSelectMethod_CreateFcn(hObject, eventdata, handles)
- function edit_name_Callback(hObject, eventdata, handles)
- function flag = validate_name(handles)
- function edit_name_CreateFcn(hObject, eventdata, handles)

## SOURCE CODE

    0001 % - create SOS optimizer dialog
    0002 %
    0003 % copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut
    0004 %
    0005 %    This file is part of SOS
    0006 %
    0007 %    SOS is free software: you can redistribute it and/or modify
    0008 %    it for academic and non-commercial purposes
    0009 %    under the terms of the GNU General Public License as published by
    0010 %    the Free Software Foundation, either version 3 of the License, or
    0011 %    (at your option) any later version.  For commercial or for-profit
    0012 %    uses, please contact the authors (sos@cnbc.cmu.edu).
    0013 %
    0014 %    SOS is distributed in the hope that it will be useful,
    0015 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
    0016 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0017 %    GNU General Public License for more details.
    0018
    0019 %    You should have received a copy of the GNU General Public License
    0020 %    along with SOS (see COPYING.txt).
    0021 %    If not, see <http://www.gnu.org/licenses/>.
    0022
    0023
    0024 function varargout = createSOS_dialog(varargin)
    0025 % CREATESOS_DIALOG M-file for createSOS_dialog.fig
    0026 %      CREATESOS_DIALOG, by itself, creates a new CREATESOS_DIALOG or raises the existing
    0027 %      singleton*.
    0028 %
    0029 %      H = CREATESOS_DIALOG returns the handle to a new CREATESOS_DIALOG or the handle to
    0030 %      the existing singleton*.
    0031 %
    0032 %      CREATESOS_DIALOG('CALLBACK',hObject,eventData,handles,...) calls the local
    0033 %      function named CALLBACK in CREATESOS_DIALOG.M with the given input arguments.
    0034 %
    0035 %      CREATESOS_DIALOG('Property','Value',...) creates a new CREATESOS_DIALOG or raises the
    0036 %      existing singleton*.  Starting from the left, property value pairs are
    0037 %      applied to the GUI before createSOS_dialog_OpeningFcn gets called.  An
    0038 %      unrecognized property name or invalid value makes property application
    0039 %      stop.  All inputs are passed to createSOS_dialog_OpeningFcn via varargin.
    0040 %
    0041 %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
    0042 %      instance to run (singleton)".
    0043 %
    0044 % See also: GUIDE, GUIDATA, GUIHANDLES
    0045
    0046 % Edit the above text to modify the response to help createSOS_dialog
    0047
    0048 % Last Modified by GUIDE v2.5 08-Sep-2010 22:22:01
    0049
    0050 % Begin initialization code - DO NOT EDIT
    0051 gui_Singleton = 1;
    0052 gui_State = struct('gui_Name',       mfilename, ...
    0053                    'gui_Singleton',  gui_Singleton, ...
    0054                    'gui_OpeningFcn', @createSOS_dialog_OpeningFcn, ...
    0055                    'gui_OutputFcn',  @createSOS_dialog_OutputFcn, ...
    0056                    'gui_LayoutFcn',  [] , ...
    0057                    'gui_Callback',   []);
    0058 if nargin && ischar(varargin{1})
    0059     gui_State.gui_Callback = str2func(varargin{1});
    0060 end
    0061
    0062 if nargout
    0063     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    0064 else
    0065     gui_mainfcn(gui_State, varargin{:});
    0066 end
    0067 % End initialization code - DO NOT EDIT
    0068
    0069
    0070 % --- Executes just before createSOS_dialog is made visible.
    0071 function createSOS_dialog_OpeningFcn(hObject, eventdata, handles, varargin)
    0072 % This function has no output args, see OutputFcn.
    0073 % hObject    handle to figure
    0074 % eventdata  reserved - to be defined in a future version of MATLAB
    0075 % handles    structure with handles and user data (see GUIDATA)
    0076 % varargin   command line arguments to createSOS_dialog (see VARARGIN)
    0077
    0078 % Choose default command line output for createSOS_dialog
    0079 handles.output = hObject;
    0080
    0081 % Update handles structure
    0082 guidata(hObject, handles);
    0083
    0084 % UIWAIT makes createSOS_dialog wait for user response (see UIRESUME)
    0085 % uiwait(handles.figure_createSOS);
    0086
    0087
    0088 % --- Outputs from this function are returned to the command line.
    0089 function varargout = createSOS_dialog_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} = handles.output;
    0097
    0098
    0099
    0100 function edit_maxIt_Callback(hObject, eventdata, handles)
    0101 % hObject    handle to edit_maxIt (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 % Hints: get(hObject,'String') returns contents of edit_maxIt as text
    0106 %        str2double(get(hObject,'String')) returns contents of edit_maxIt as a double
    0107     validate_maxIt(handles);
    0108
    0109
    0110 function flag = validate_maxIt(handles)
    0111     str = get(handles.edit_maxIt,'String');
    0112
    0113     errmsg = 'Sample size must be a whole number > 0';
    0114     errtitle = 'Invalid max iteration!';
    0115
    0116     flag = validatePositiveInteger(str,errmsg,errtitle);
    0117
    0118
    0119
    0120 % --- Executes during object creation, after setting all properties.
    0121 function edit_maxIt_CreateFcn(hObject, eventdata, handles)
    0122 % hObject    handle to edit_maxIt (see GCBO)
    0123 % eventdata  reserved - to be defined in a future version of MATLAB
    0124 % handles    empty - handles not created until after all CreateFcns called
    0125
    0126 % Hint: edit controls usually have a white background on Windows.
    0127 %       See ISPC and COMPUTER.
    0128 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0129     set(hObject,'BackgroundColor','white');
    0130 end
    0131
    0132
    0133
    0134 function edit_reportInterval_Callback(hObject, eventdata, handles)
    0135 % hObject    handle to edit_reportInterval (see GCBO)
    0136 % eventdata  reserved - to be defined in a future version of MATLAB
    0137 % handles    structure with handles and user data (see GUIDATA)
    0138
    0139 % Hints: get(hObject,'String') returns contents of edit_reportInterval as text
    0140 %        str2double(get(hObject,'String')) returns contents of edit_reportInterval as a double
    0141     validate_reportInterval(handles);
    0142
    0143 function flag = validate_reportInterval(handles)
    0144     str = get(handles.edit_reportInterval,'String');
    0145
    0146     errmsg = 'Sample size must be a whole number > 0';
    0147     errtitle = 'Invalid reportInterval!';
    0148
    0149     flag = validatePositiveInteger(str,errmsg,errtitle);
    0150
    0151
    0152
    0153 % --- Executes during object creation, after setting all properties.
    0154 function edit_reportInterval_CreateFcn(hObject, eventdata, handles)
    0155 % hObject    handle to edit_reportInterval (see GCBO)
    0156 % eventdata  reserved - to be defined in a future version of MATLAB
    0157 % handles    empty - handles not created until after all CreateFcns called
    0158
    0159 % Hint: edit controls usually have a white background on Windows.
    0160 %       See ISPC and COMPUTER.
    0161 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0162     set(hObject,'BackgroundColor','white');
    0163 end
    0164
    0165
    0166
    0167 function edit_statInterval_Callback(hObject, eventdata, handles)
    0168 % hObject    handle to edit_statInterval (see GCBO)
    0169 % eventdata  reserved - to be defined in a future version of MATLAB
    0170 % handles    structure with handles and user data (see GUIDATA)
    0171
    0172 % Hints: get(hObject,'String') returns contents of edit_statInterval as text
    0173 %        str2double(get(hObject,'String')) returns contents of
    0174 %        edit_statInterval as a double
    0175     validate_statInterval(handles)
    0176
    0177 function flag = validate_statInterval(handles)
    0178     str = get(handles.edit_statInterval,'String');
    0179
    0180     errmsg = 'Stat test interval must be a whole number > 0';
    0181     errtitle = 'Invalid statInterval!';
    0182
    0183     flag = validatePositiveInteger(str,errmsg,errtitle);
    0184
    0185
    0186 % --- Executes during object creation, after setting all properties.
    0187 function edit_statInterval_CreateFcn(hObject, eventdata, handles)
    0188 % hObject    handle to edit_statInterval (see GCBO)
    0189 % eventdata  reserved - to be defined in a future version of MATLAB
    0190 % handles    empty - handles not created until after all CreateFcns called
    0191
    0192 % Hint: edit controls usually have a white background on Windows.
    0193 %       See ISPC and COMPUTER.
    0194 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0195     set(hObject,'BackgroundColor','white');
    0196 end
    0197
    0198
    0199 % --- Executes on button press in pushbutton1.
    0200 function pushbutton1_Callback(hObject, eventdata, handles)
    0201 % hObject    handle to pushbutton1 (see GCBO)
    0202 % eventdata  reserved - to be defined in a future version of MATLAB
    0203 % handles    structure with handles and user data (see GUIDATA)
    0204
    0205     flag = validate_maxIt(handles);
    0206
    0207     if flag == true
    0208         disp('yes, valid string');
    0209     end
    0210
    0211
    0212
    0213
    0214
    0215
    0216 % --- Executes on selection change in popupmenu_statReportStyle.
    0217 function popupmenu_statReportStyle_Callback(hObject, eventdata, handles)
    0218 % hObject    handle to popupmenu_statReportStyle (see GCBO)
    0219 % eventdata  reserved - to be defined in a future version of MATLAB
    0220 % handles    structure with handles and user data (see GUIDATA)
    0221
    0222 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_statReportStyle contents as cell array
    0223 %        contents{get(hObject,'Value')} returns selected item from popupmenu_statReportStyle
    0224
    0225
    0226 % --- Executes during object creation, after setting all properties.
    0227 function popupmenu_statReportStyle_CreateFcn(hObject, eventdata, handles)
    0228 % hObject    handle to popupmenu_statReportStyle (see GCBO)
    0229 % eventdata  reserved - to be defined in a future version of MATLAB
    0230 % handles    empty - handles not created until after all CreateFcns called
    0231
    0232 % Hint: popupmenu controls usually have a white background on Windows.
    0233 %       See ISPC and COMPUTER.
    0234 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0235     set(hObject,'BackgroundColor','white');
    0236 end
    0237
    0238
    0239
    0240 function edit_stopFreezeIt_Callback(hObject, eventdata, handles)
    0241 % hObject    handle to edit_stopFreezeIt (see GCBO)
    0242 % eventdata  reserved - to be defined in a future version of MATLAB
    0243 % handles    structure with handles and user data (see GUIDATA)
    0244
    0245 % Hints: get(hObject,'String') returns contents of edit_stopFreezeIt as text
    0246 %        str2double(get(hObject,'String')) returns contents of edit_stopFreezeIt as a double
    0247     validate_stopFreezeIt(handles);
    0248
    0249
    0250 function flag = validate_stopFreezeIt(handles)
    0251     str = get(handles.edit_stopFreezeIt,'String');
    0252
    0253     errmsg = 'Freeze interval must be a whole number > 0';
    0254     errtitle = 'Invalid stopFreezeIt!';
    0255
    0256     flag = validatePositiveInteger(str,errmsg,errtitle);
    0257
    0258
    0259 % --- Executes during object creation, after setting all properties.
    0260 function edit_stopFreezeIt_CreateFcn(hObject, eventdata, handles)
    0261 % hObject    handle to edit_stopFreezeIt (see GCBO)
    0262 % eventdata  reserved - to be defined in a future version of MATLAB
    0263 % handles    empty - handles not created until after all CreateFcns called
    0264
    0265 % Hint: edit controls usually have a white background on Windows.
    0266 %       See ISPC and COMPUTER.
    0267 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0268     set(hObject,'BackgroundColor','white');
    0269 end
    0270
    0271
    0272
    0273 function edit_blockSize_Callback(hObject, eventdata, handles)
    0274 % hObject    handle to edit_blockSize (see GCBO)
    0275 % eventdata  reserved - to be defined in a future version of MATLAB
    0276 % handles    structure with handles and user data (see GUIDATA)
    0277
    0278 % Hints: get(hObject,'String') returns contents of edit_blockSize as text
    0279 %        str2double(get(hObject,'String')) returns contents of edit_blockSize as a double
    0280     validate_blockSize(handles);
    0281
    0282
    0283 function flag = validate_blockSize(handles)
    0284     str = get(handles.edit_blockSize,'String');
    0285
    0286     errmsg = 'Block size must be a whole number > 0';
    0287     errtitle = 'Invalid block size!';
    0288
    0289     flag = validatePositiveInteger(str,errmsg,errtitle);
    0290
    0291 % --- Executes during object creation, after setting all properties.
    0292 function edit_blockSize_CreateFcn(hObject, eventdata, handles)
    0293 % hObject    handle to edit_blockSize (see GCBO)
    0294 % eventdata  reserved - to be defined in a future version of MATLAB
    0295 % handles    empty - handles not created until after all CreateFcns called
    0296
    0297 % Hint: edit controls usually have a white background on Windows.
    0298 %       See ISPC and COMPUTER.
    0299 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0300     set(hObject,'BackgroundColor','white');
    0301 end
    0302
    0303
    0304 % --- Executes on selection change in popupmenu_targSampleCandSelectMethod.
    0305 function popupmenu_targSampleCandSelectMethod_Callback(hObject, eventdata, handles)
    0306 % hObject    handle to popupmenu_targSampleCandSelectMethod (see GCBO)
    0307 % eventdata  reserved - to be defined in a future version of MATLAB
    0308 % handles    structure with handles and user data (see GUIDATA)
    0309
    0310 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_targSampleCandSelectMethod contents as cell array
    0311 %        contents{get(hObject,'Value')} returns selected item from popupmenu_targSampleCandSelectMethod
    0312
    0313
    0314 % --- Executes during object creation, after setting all properties.
    0315 function popupmenu_targSampleCandSelectMethod_CreateFcn(hObject, eventdata, handles)
    0316 % hObject    handle to popupmenu_targSampleCandSelectMethod (see GCBO)
    0317 % eventdata  reserved - to be defined in a future version of MATLAB
    0318 % handles    empty - handles not created until after all CreateFcns called
    0319
    0320 % Hint: popupmenu controls usually have a white background on Windows.
    0321 %       See ISPC and COMPUTER.
    0322 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0323     set(hObject,'BackgroundColor','white');
    0324 end
    0325
    0326
    0327 % --- Executes on selection change in popupmenu_pSwapFunction.
    0328 function popupmenu_pSwapFunction_Callback(hObject, eventdata, handles)
    0329 % hObject    handle to popupmenu_pSwapFunction (see GCBO)
    0330 % eventdata  reserved - to be defined in a future version of MATLAB
    0331 % handles    structure with handles and user data (see GUIDATA)
    0332
    0333 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_pSwapFunction contents as cell array
    0334 %        contents{get(hObject,'Value')} returns selected item from popupmenu_pSwapFunction
    0335
    0336
    0337 % --- Executes during object creation, after setting all properties.
    0338 function popupmenu_pSwapFunction_CreateFcn(hObject, eventdata, handles)
    0339 % hObject    handle to popupmenu_pSwapFunction (see GCBO)
    0340 % eventdata  reserved - to be defined in a future version of MATLAB
    0341 % handles    empty - handles not created until after all CreateFcns called
    0342
    0343 % Hint: popupmenu controls usually have a white background on Windows.
    0344 %       See ISPC and COMPUTER.
    0345 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0346     set(hObject,'BackgroundColor','white');
    0347 end
    0348
    0349
    0350 % --- Executes on button press in pushbutton_createSOS.
    0351 function pushbutton_createSOS_Callback(hObject, eventdata, handles)
    0352 % hObject    handle to pushbutton_createSOS (see GCBO)
    0353 % eventdata  reserved - to be defined in a future version of MATLAB
    0354 % handles    structure with handles and user data (see GUIDATA)
    0355
    0356     % re-validate all fields
    0357
    0358     createObj = validate_name(handles);
    0359
    0360     if createObj == true
    0361         createObj = validate_maxIt(handles);
    0362         if createObj == true
    0363             createObj = validate_reportInterval(handles);
    0364
    0365             if createObj == true
    0366                 createObj = validate_statInterval(handles);
    0367
    0368                 if createObj == true
    0369                     createObj = validate_stopFreezeIt(handles);
    0370
    0371                     if createObj == true
    0372                         createObj = validate_blockSize(handles);
    0373
    0374                         if createObj == true
    0375                         % the other fields are pop-up menus and necessarily
    0376                         % pass validation.  Go on to create the object.
    0377
    0378                         %cmd =
    0379                         varName = get(handles.edit_name,'String');
    0380                         maxIt = (get(handles.edit_maxIt,'String'));
    0381                         reportInterval = (get(handles.edit_reportInterval,'String'));
    0382                         statInterval = (get(handles.edit_statInterval,'String'));
    0383                         stopFreezeIt = (get(handles.edit_stopFreezeIt,'String'));
    0384                         blockSize = (get(handles.edit_blockSize,'String'));
    0385
    0386                         statMenuHandle = handles.popupmenu_statReportStyle;
    0387                         reportStyle = getPopupMenuName(statMenuHandle,...
    0388                                     'Error, could not retrieve label,','Error');
    0389
    0390                         SampleCandMenuHandle = handles.popupmenu_targSampleCandSelectMethod;
    0391                         targSampleCandSelectMethod = getPopupMenuName(SampleCandMenuHandle,...
    0392                                     'Error, could not retrieve label,','Error');
    0393
    0394                         feederdfCandSelectMethodHandle =  handles.popupmenu_feederdfCandSelectMethod;
    0395                         feederdfCandSelectMethod = getPopupMenuName(feederdfCandSelectMethodHandle,...
    0396                                     'Error, could not retrieve label,','Error');
    0397
    0398                         pSwapFunctionHandle =  handles.popupmenu_pSwapFunction;
    0399                         pSwapFunction = getPopupMenuName(pSwapFunctionHandle,...
    0400                                     'Error, could not retrieve label,','Error');
    0401
    0402                         command = strcat(varName,'=','sos(','''maxIt'',', maxIt,...
    0403                                 ',''reportInterval'',',reportInterval,...
    0404                                 ',''statInterval'',',statInterval,...
    0405                                 ',''stopFreezeIt'',',stopFreezeIt,...
    0406                                 ',''blockSize'',',blockSize,...
    0407                                 ',''statTestReportStyle'',''',reportStyle,...
    0408                                 ''',''targSampleCandSelectMethod'',''',targSampleCandSelectMethod,...
    0409                                 ''',''feederdfCandSelectMethod'',''',feederdfCandSelectMethod,...
    0410                                 ''',''pSwapFunction'',''',pSwapFunction,...
    0411                                 ''');'...
    0412                                 );
    0413
    0414                             verbosePrint(['Executing command: ','''',command,''''],'createSOSDialog_createSOS');
    0415                             evalin('base',command);
    0416
    0417
    0418
    0419
    0420                             close(handles.figure_createSOS);
    0421                         end
    0422                     end
    0423                 end
    0424             end
    0425         end
    0426     end
    0427
    0428
    0429
    0430
    0431 % --- Executes on selection change in popupmenu_feederdfCandSelectMethod.
    0432 function popupmenu_feederdfCandSelectMethod_Callback(hObject, eventdata, handles)
    0433 % hObject    handle to popupmenu_feederdfCandSelectMethod (see GCBO)
    0434 % eventdata  reserved - to be defined in a future version of MATLAB
    0435 % handles    structure with handles and user data (see GUIDATA)
    0436
    0437 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_feederdfCandSelectMethod contents as cell array
    0438 %        contents{get(hObject,'Value')} returns selected item from popupmenu_feederdfCandSelectMethod
    0439
    0440
    0441 % --- Executes during object creation, after setting all properties.
    0442 function popupmenu_feederdfCandSelectMethod_CreateFcn(hObject, eventdata, handles)
    0443 % hObject    handle to popupmenu_feederdfCandSelectMethod (see GCBO)
    0444 % eventdata  reserved - to be defined in a future version of MATLAB
    0445 % handles    empty - handles not created until after all CreateFcns called
    0446
    0447 % Hint: popupmenu controls usually have a white background on Windows.
    0448 %       See ISPC and COMPUTER.
    0449 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0450     set(hObject,'BackgroundColor','white');
    0451 end
    0452
    0453
    0454
    0455 function edit_name_Callback(hObject, eventdata, handles)
    0456 % hObject    handle to edit_name (see GCBO)
    0457 % eventdata  reserved - to be defined in a future version of MATLAB
    0458 % handles    structure with handles and user data (see GUIDATA)
    0459
    0460 % Hints: get(hObject,'String') returns contents of edit_name as text
    0461 %        str2double(get(hObject,'String')) returns contents of edit_name as a double
    0462     validate_name(handles);
    0463
    0464
    0465 function flag = validate_name(handles)
    0466
    0467     varName = get(handles.edit_name,'String');
    0468
    0469     %check to make sure that the name is a valid variable name:
    0470     valid = regexp(varName,'^[a-zA-Z]+\w*$');
    0471
    0472     if isempty(valid)
    0473         % name is not currently valid, tell the user.
    0474         msgbox('Only letters, numbers, and underscores are permitted in the name of the sample object.  The first character must also be a letter.',...
    0475                 'Invalid name!');
    0476         flag = false;
    0477     else
    0478         % check to make sure that the new variable name doesn't already exist.
    0479         command = strcat('whos(''',varName,''')');
    0480         varExists = evalin('base',command);
    0481
    0482
    0483         % if a variable with this name already exists, warns the user
    0484         if isempty(varExists) == 0
    0485             msgbox('A sample with this name already exists and will be overridden if you continue',...
    0486                     'Sample exists!');
    0487         end
    0488
    0489         flag = true;
    0490     end
    0491
    0492 % --- Executes during object creation, after setting all properties.
    0493 function edit_name_CreateFcn(hObject, eventdata, handles)
    0494 % hObject    handle to edit_name (see GCBO)
    0495 % eventdata  reserved - to be defined in a future version of MATLAB
    0496 % handles    empty - handles not created until after all CreateFcns called
    0497
    0498 % Hint: edit controls usually have a white background on Windows.
    0499 %       See ISPC and COMPUTER.
    0500 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0501     set(hObject,'BackgroundColor','white');
    0502 end