- create soft meta-constraint 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.
0001 % - create soft meta-constraint 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 = createSoftMetaConstraint_Dialog(varargin) 0025 % CREATESOFTMETACONSTRAINT_DIALOG M-file for createSoftMetaConstraint_Dialog.fig 0026 % CREATESOFTMETACONSTRAINT_DIALOG, by itself, creates a new CREATESOFTMETACONSTRAINT_DIALOG or raises the existing 0027 % singleton*. 0028 % 0029 % H = CREATESOFTMETACONSTRAINT_DIALOG returns the handle to a new CREATESOFTMETACONSTRAINT_DIALOG or the handle to 0030 % the existing singleton*. 0031 % 0032 % CREATESOFTMETACONSTRAINT_DIALOG('CALLBACK',hObject,eventData,handles,...) calls the local 0033 % function named CALLBACK in CREATESOFTMETACONSTRAINT_DIALOG.M with the given input arguments. 0034 % 0035 % CREATESOFTMETACONSTRAINT_DIALOG('Property','Value',...) creates a new CREATESOFTMETACONSTRAINT_DIALOG or raises the 0036 % existing singleton*. Starting from the left, property value pairs are 0037 % applied to the GUI before createSoftMetaConstraint_Dialog_OpeningFcn gets called. An 0038 % unrecognized property name or invalid value makes property application 0039 % stop. All inputs are passed to createSoftMetaConstraint_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 createSoftMetaConstraint_Dialog 0047 0048 % Last Modified by GUIDE v2.5 17-Sep-2010 15:47:05 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', @createSoftMetaConstraint_Dialog_OpeningFcn, ... 0055 'gui_OutputFcn', @createSoftMetaConstraint_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 createSoftMetaConstraint_Dialog is made visible. 0071 function createSoftMetaConstraint_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 createSoftMetaConstraint_Dialog (see VARARGIN) 0077 0078 % Choose default command line output for createSoftMetaConstraint_Dialog 0079 handles.output = hObject; 0080 0081 % Update handles structure 0082 guidata(hObject, handles); 0083 0084 % UIWAIT makes createSoftMetaConstraint_Dialog wait for user response (see UIRESUME) 0085 % uiwait(handles.figure_createSoftMetaConstraint_Dialog); 0086 0087 0088 % --- Outputs from this function are returned to the command line. 0089 function varargout = createSoftMetaConstraint_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_name_Callback(hObject, eventdata, handles) 0101 % hObject handle to edit_name (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_name as text 0106 % str2double(get(hObject,'String')) returns contents of edit_name as a double 0107 validate_name(handles); 0108 0109 0110 function flag = validate_name(handles) 0111 0112 varName = get(handles.edit_name,'String'); 0113 0114 %check to make sure that the name is a valid variable name: 0115 valid = regexp(varName,'^[a-zA-Z]+\w*$', 'once'); 0116 0117 if isempty(valid) 0118 % name is not currently valid, tell the user. 0119 msgbox('Only letters, numbers, and underscores are permitted in the name of the ttest object. The first character must also be a letter.',... 0120 'Invalid name!'); 0121 flag = false; 0122 else 0123 % check to make sure that the new variable name doesn't already exist. 0124 command = strcat('whos(''',varName,''')'); 0125 varExists = evalin('base',command); 0126 0127 0128 % if a variable with this name already exists, warns the user 0129 if isempty(varExists) == 0 0130 msgbox('A variable with this name already exists and will be overridden if you continue',... 0131 'Variable name already in use!'); 0132 end 0133 0134 flag = true; 0135 end 0136 0137 0138 0139 % --- Executes during object creation, after setting all properties. 0140 function edit_name_CreateFcn(hObject, eventdata, handles) 0141 % hObject handle to edit_name (see GCBO) 0142 % eventdata reserved - to be defined in a future version of MATLAB 0143 % handles empty - handles not created until after all CreateFcns called 0144 0145 % Hint: edit controls usually have a white background on Windows. 0146 % See ISPC and COMPUTER. 0147 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0148 set(hObject,'BackgroundColor','white'); 0149 end 0150 0151 0152 % --- Executes on selection change in popupmenu_constraint1Selector. 0153 function popupmenu_constraint1Selector_Callback(hObject, eventdata, handles) 0154 % hObject handle to popupmenu_constraint1Selector (see GCBO) 0155 % eventdata reserved - to be defined in a future version of MATLAB 0156 % handles structure with handles and user data (see GUIDATA) 0157 0158 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_constraint1Selector contents as cell array 0159 % contents{get(hObject,'Value')} returns selected item from popupmenu_constraint1Selector 0160 populateConstraintList(hObject); 0161 0162 0163 function populateConstraintList(hObject) 0164 % get a list of all populations in the base workspace: 0165 0166 mainWindowHandle = sos_gui; 0167 mainWindowData = guidata(mainWindowHandle); 0168 0169 sosObjName = getdfName(mainWindowData.popupmenu_SOSSelector,'SOS'); 0170 0171 list = {}; 0172 % we have an SOS object. List its constraints: 0173 if isempty(sosObjName) == 0 0174 tmpSOS = evalin('base',sosObjName); 0175 0176 for i=1:length(tmpSOS.hardConstraints) 0177 list = [list ; tmpSOS.hardConstraints{i}.name]; %#ok<AGROW> 0178 end 0179 0180 for i=1:length(tmpSOS.softConstraints) 0181 list = [list ; tmpSOS.softConstraints{i}.name]; %#ok<AGROW> 0182 end 0183 0184 end 0185 0186 0187 % assign that list to the options in the pop up menu 0188 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid'); 0189 set(hObject,'String',list); 0190 createSoftMetaConstraint_Dialog(); 0191 0192 0193 0194 0195 % --- Executes during object creation, after setting all properties. 0196 function popupmenu_constraint1Selector_CreateFcn(hObject, eventdata, handles) 0197 % hObject handle to popupmenu_constraint1Selector (see GCBO) 0198 % eventdata reserved - to be defined in a future version of MATLAB 0199 % handles empty - handles not created until after all CreateFcns called 0200 0201 % Hint: popupmenu controls usually have a white background on Windows. 0202 % See ISPC and COMPUTER. 0203 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0204 set(hObject,'BackgroundColor','white'); 0205 end 0206 0207 0208 % --- Executes on button press in pushbutton_refreshSample2List. 0209 function pushbutton_refreshSample1List_Callback(hObject, eventdata, handles) 0210 % hObject handle to pushbutton_refreshSample2List (see GCBO) 0211 % eventdata reserved - to be defined in a future version of MATLAB 0212 % handles structure with handles and user data (see GUIDATA) 0213 populateConstraintList(handles.popupmenu_constraint1Selector); 0214 0215 % --- If Enable == 'on', executes on mouse press in 5 pixel border. 0216 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_constraint1Selector. 0217 function popupmenu_constraint1Selector_ButtonDownFcn(hObject, eventdata, handles) 0218 % hObject handle to popupmenu_constraint1Selector (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 populateConstraint(hObject); 0222 0223 0224 % --- Executes on selection change in popupmenu_sample1ColSelector. 0225 function popupmenu_sample1ColSelector_Callback(hObject, eventdata, handles) 0226 % hObject handle to popupmenu_sample1ColSelector (see GCBO) 0227 % eventdata reserved - to be defined in a future version of MATLAB 0228 % handles structure with handles and user data (see GUIDATA) 0229 populateColumnList(hObject,handles.popupmenu_constraint1Selector); 0230 0231 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_sample1ColSelector contents as cell array 0232 % contents{get(hObject,'Value')} returns selected item from popupmenu_sample1ColSelector 0233 function populateColumnList(hObject,sampleSelector) 0234 % get a list of all populations in the base workspace: 0235 0236 create = true; 0237 0238 % get the sample in the first list. 0239 sampleMenuHandle = sampleSelector; 0240 sampleName = getdfName(sampleMenuHandle,'sample 1'); 0241 0242 if isempty(sampleName) 0243 create = false; 0244 end 0245 0246 if create == true 0247 % add in all of the header names associated with that sample. 0248 tmpColNames = evalin('base',[sampleName,'.header']); 0249 0250 % melt and refreeze cells 0251 colNames = {}; 0252 0253 for i=1:length(tmpColNames) 0254 colNames = [colNames ; tmpColNames{i}]; %#ok<AGROW> 0255 end 0256 0257 0258 % assign that list to the options in the pop up menu 0259 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid'); 0260 set(hObject,'String',colNames); 0261 end 0262 0263 % --- Executes during object creation, after setting all properties. 0264 function popupmenu_sample1ColSelector_CreateFcn(hObject, eventdata, handles) 0265 % hObject handle to popupmenu_sample1ColSelector (see GCBO) 0266 % eventdata reserved - to be defined in a future version of MATLAB 0267 % handles empty - handles not created until after all CreateFcns called 0268 0269 % Hint: popupmenu controls usually have a white background on Windows. 0270 % See ISPC and COMPUTER. 0271 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0272 set(hObject,'BackgroundColor','white'); 0273 end 0274 0275 0276 % --- Executes on button press in pushbutton_refreshsample1ColSelector. 0277 function pushbutton_refreshsample1ColSelector_Callback(hObject, eventdata, handles) 0278 % hObject handle to pushbutton_refreshsample1ColSelector (see GCBO) 0279 % eventdata reserved - to be defined in a future version of MATLAB 0280 % handles structure with handles and user data (see GUIDATA) 0281 populateColumnList(handles.popupmenu_sample1ColSelector,handles.popupmenu_constraint1Selector); 0282 0283 0284 % --- Executes on selection change in popupmenu_sample2Selector. 0285 function popupmenu_sample2Selector_Callback(hObject, eventdata, handles) 0286 % hObject handle to popupmenu_sample2Selector (see GCBO) 0287 % eventdata reserved - to be defined in a future version of MATLAB 0288 % handles structure with handles and user data (see GUIDATA) 0289 0290 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_sample2Selector contents as cell array 0291 % contents{get(hObject,'Value')} returns selected item from popupmenu_sample2Selector 0292 populateConstraintList(hObject); 0293 0294 0295 % --- Executes during object creation, after setting all properties. 0296 function popupmenu_sample2Selector_CreateFcn(hObject, eventdata, handles) 0297 % hObject handle to popupmenu_sample2Selector (see GCBO) 0298 % eventdata reserved - to be defined in a future version of MATLAB 0299 % handles empty - handles not created until after all CreateFcns called 0300 0301 % Hint: popupmenu controls usually have a white background on Windows. 0302 % See ISPC and COMPUTER. 0303 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0304 set(hObject,'BackgroundColor','white'); 0305 end 0306 0307 0308 % --- Executes on button press in pushbutton_refreshSample2List. 0309 function pushbutton_refreshSample2List_Callback(hObject, eventdata, handles) 0310 % hObject handle to pushbutton_refreshSample2List (see GCBO) 0311 % eventdata reserved - to be defined in a future version of MATLAB 0312 % handles structure with handles and user data (see GUIDATA) 0313 populateConstraintList(handles.popupmenu_constraint2Selector); 0314 0315 0316 % --- Executes on selection change in popupmenu_sample2ColSelector. 0317 function popupmenu_sample2ColSelector_Callback(hObject, eventdata, handles) 0318 % hObject handle to popupmenu_sample2ColSelector (see GCBO) 0319 % eventdata reserved - to be defined in a future version of MATLAB 0320 % handles structure with handles and user data (see GUIDATA) 0321 0322 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_sample2ColSelector contents as cell array 0323 % contents{get(hObject,'Value')} returns selected item from popupmenu_sample2ColSelector 0324 populateColumnList(hObject,handles.popupmenu_sample2Selector); 0325 0326 0327 % --- Executes during object creation, after setting all properties. 0328 function popupmenu_sample2ColSelector_CreateFcn(hObject, eventdata, handles) 0329 % hObject handle to popupmenu_sample2ColSelector (see GCBO) 0330 % eventdata reserved - to be defined in a future version of MATLAB 0331 % handles empty - handles not created until after all CreateFcns called 0332 0333 % Hint: popupmenu controls usually have a white background on Windows. 0334 % See ISPC and COMPUTER. 0335 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0336 set(hObject,'BackgroundColor','white'); 0337 end 0338 0339 0340 % --- Executes on button press in pushbutton_refreshsample2ColSelector. 0341 function pushbutton_refreshsample2ColSelector_Callback(hObject, eventdata, handles) 0342 % hObject handle to pushbutton_refreshsample2ColSelector (see GCBO) 0343 % eventdata reserved - to be defined in a future version of MATLAB 0344 % handles structure with handles and user data (see GUIDATA) 0345 populateColumnList(handles.popupmenu_sample2ColSelector,handles.popupmenu_sample2Selector); 0346 0347 0348 % --- If Enable == 'on', executes on mouse press in 5 pixel border. 0349 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_sample1ColSelector. 0350 function popupmenu_sample1ColSelector_ButtonDownFcn(hObject, eventdata, handles) 0351 % hObject handle to popupmenu_sample1ColSelector (see GCBO) 0352 % eventdata reserved - to be defined in a future version of MATLAB 0353 % handles structure with handles and user data (see GUIDATA) 0354 populateColumnList(hObject,handles.popupmenu_constraint1Selector); 0355 0356 0357 % --- If Enable == 'on', executes on mouse press in 5 pixel border. 0358 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_sample2Selector. 0359 function popupmenu_sample2Selector_ButtonDownFcn(hObject, eventdata, handles) 0360 % hObject handle to popupmenu_sample2Selector (see GCBO) 0361 % eventdata reserved - to be defined in a future version of MATLAB 0362 % handles structure with handles and user data (see GUIDATA) 0363 populateConstraintList(hObject); 0364 0365 0366 % --- If Enable == 'on', executes on mouse press in 5 pixel border. 0367 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_sample2ColSelector. 0368 function popupmenu_sample2ColSelector_ButtonDownFcn(hObject, eventdata, handles) 0369 % hObject handle to popupmenu_sample2ColSelector (see GCBO) 0370 % eventdata reserved - to be defined in a future version of MATLAB 0371 % handles structure with handles and user data (see GUIDATA) 0372 populateColumnList(hObject,handles.popupmenu_sample2Selector); 0373 0374 0375 0376 function edit_value_Callback(hObject, eventdata, handles) 0377 % hObject handle to edit_value (see GCBO) 0378 % eventdata reserved - to be defined in a future version of MATLAB 0379 % handles structure with handles and user data (see GUIDATA) 0380 0381 % Hints: get(hObject,'String') returns contents of edit_value as text 0382 % str2double(get(hObject,'String')) returns contents of edit_value as a double 0383 validate_value(handles); 0384 0385 0386 function flag = validate_value(handles) 0387 str = get(handles.edit_value,'String'); 0388 0389 errmsg = 'Multiplier must be a number'; 0390 errtitle = 'Invalid Multiplier!'; 0391 0392 flag = validateRealNumber(str,errmsg,errtitle); 0393 0394 0395 0396 % --- Executes during object creation, after setting all properties. 0397 function edit_value_CreateFcn(hObject, eventdata, handles) 0398 % hObject handle to edit_value (see GCBO) 0399 % eventdata reserved - to be defined in a future version of MATLAB 0400 % handles empty - handles not created until after all CreateFcns called 0401 0402 % Hint: edit controls usually have a white background on Windows. 0403 % See ISPC and COMPUTER. 0404 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0405 set(hObject,'BackgroundColor','white'); 0406 end 0407 0408 0409 % --- Executes on selection change in popupmenu_desiredpvalCondition. 0410 function popupmenu_desiredpvalCondition_Callback(hObject, eventdata, handles) 0411 % hObject handle to popupmenu_desiredpvalCondition (see GCBO) 0412 % eventdata reserved - to be defined in a future version of MATLAB 0413 % handles structure with handles and user data (see GUIDATA) 0414 0415 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_desiredpvalCondition contents as cell array 0416 % contents{get(hObject,'Value')} returns selected item from popupmenu_desiredpvalCondition 0417 0418 0419 % --- Executes during object creation, after setting all properties. 0420 function popupmenu_desiredpvalCondition_CreateFcn(hObject, eventdata, handles) 0421 % hObject handle to popupmenu_desiredpvalCondition (see GCBO) 0422 % eventdata reserved - to be defined in a future version of MATLAB 0423 % handles empty - handles not created until after all CreateFcns called 0424 0425 % Hint: popupmenu controls usually have a white background on Windows. 0426 % See ISPC and COMPUTER. 0427 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0428 set(hObject,'BackgroundColor','white'); 0429 end 0430 0431 0432 % --- Executes on selection change in popupmenu_tails. 0433 function popupmenu_tails_Callback(hObject, eventdata, handles) 0434 % hObject handle to popupmenu_tails (see GCBO) 0435 % eventdata reserved - to be defined in a future version of MATLAB 0436 % handles structure with handles and user data (see GUIDATA) 0437 0438 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_tails contents as cell array 0439 % contents{get(hObject,'Value')} returns selected item from popupmenu_tails 0440 0441 0442 % --- Executes during object creation, after setting all properties. 0443 function popupmenu_tails_CreateFcn(hObject, eventdata, handles) 0444 % hObject handle to popupmenu_tails (see GCBO) 0445 % eventdata reserved - to be defined in a future version of MATLAB 0446 % handles empty - handles not created until after all CreateFcns called 0447 0448 % Hint: popupmenu controls usually have a white background on Windows. 0449 % See ISPC and COMPUTER. 0450 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0451 set(hObject,'BackgroundColor','white'); 0452 end 0453 0454 0455 % --- Executes on button press in pushbutton_createSoftMetaConstraint. 0456 function pushbutton_createSoftMetaConstraint_Callback(hObject, eventdata, handles) 0457 % hObject handle to pushbutton_createSoftMetaConstraint (see GCBO) 0458 % eventdata reserved - to be defined in a future version of MATLAB 0459 % handles structure with handles and user data (see GUIDATA) 0460 0461 type = getdfName(handles.popupmenu_type,'type'); 0462 0463 mainWindowHandle = sos_gui; 0464 mainWindowData = guidata(mainWindowHandle); 0465 0466 sosObjName = getdfName(mainWindowData.popupmenu_SOSSelector,'SOS'); 0467 0468 if isempty(sosObjName) == 0 0469 % we have a valid SOS object to add the test to 0470 % validate all of the parameters for the test 0471 create = validate_name(handles); 0472 name = get(handles.edit_name,'String'); 0473 0474 if create == true 0475 constraint1 = getdfName(handles.popupmenu_constraint1Selector,'constraint 1'); 0476 0477 if isempty(constraint1) == 0 0478 constraint2 = getdfName(handles.popupmenu_constraint2Selector','constraint 2'); 0479 0480 if isempty(constraint2) == 0 0481 create = validate_value(handles); 0482 0483 if create == true 0484 % all values have passed. Can execute the command 0485 value = get(handles.edit_value,'String'); 0486 0487 % check weight 0488 create = validate_weight(handles); 0489 if create == true 0490 weight = get(handles.edit_weight,'String'); 0491 0492 create = validate_exp(handles); 0493 if create == true 0494 exp = get (handles.edit_exp,'String'); 0495 0496 %all functions passed, retrieve the 0497 %hard-coded popup menu data 0498 0499 fnc = getdfName(handles.popupmenu_fncSelector,... 0500 'fnc'); 0501 0502 %all of the other options are in drop-down 0503 %menus and as such necessarily will pass. 0504 %run the command. 0505 0506 command = [name,'=',sosObjName,'.addConstraint(',... 0507 '''name'',''',name,''',',... 0508 '''constraintType'',''',type,''',',... 0509 '''fnc'',''',fnc,''',',... 0510 '''constraint1'',',constraint1,',',... 0511 '''constraint2'',',constraint2,',',... 0512 '''constraint2costScale'',',value,',',... 0513 '''weight'',',weight,','... 0514 '''exponent'',',exp,');',... 0515 ]; 0516 0517 0518 verbosePrint(['Executing command: ','''',command,''''],'createSoftMetaConstraint_Dialog_create'); 0519 evalin('base',command); 0520 close(handles.figure_createSoftMetaConstraint_Dialog); 0521 end 0522 end 0523 end 0524 end 0525 end 0526 end 0527 end 0528 0529 0530 % --- Executes on selection change in popupmenu_type. 0531 function popupmenu_type_Callback(hObject, eventdata, handles) 0532 % hObject handle to popupmenu_type (see GCBO) 0533 % eventdata reserved - to be defined in a future version of MATLAB 0534 % handles structure with handles and user data (see GUIDATA) 0535 0536 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_type contents as cell array 0537 % contents{get(hObject,'Value')} returns selected item from popupmenu_type 0538 0539 0540 % --- Executes during object creation, after setting all properties. 0541 function popupmenu_type_CreateFcn(hObject, eventdata, handles) 0542 % hObject handle to popupmenu_type (see GCBO) 0543 % eventdata reserved - to be defined in a future version of MATLAB 0544 % handles empty - handles not created until after all CreateFcns called 0545 0546 % Hint: popupmenu controls usually have a white background on Windows. 0547 % See ISPC and COMPUTER. 0548 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0549 set(hObject,'BackgroundColor','white'); 0550 end 0551 0552 0553 % --- Executes on selection change in popupmenu_fncSelector. 0554 function popupmenu_fncSelector_Callback(hObject, eventdata, handles) 0555 % hObject handle to popupmenu_fncSelector (see GCBO) 0556 % eventdata reserved - to be defined in a future version of MATLAB 0557 % handles structure with handles and user data (see GUIDATA) 0558 0559 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_fncSelector contents as cell array 0560 % contents{get(hObject,'Value')} returns selected item from popupmenu_fncSelector 0561 0562 0563 % --- Executes during object creation, after setting all properties. 0564 function popupmenu_fncSelector_CreateFcn(hObject, eventdata, handles) 0565 % hObject handle to popupmenu_fncSelector (see GCBO) 0566 % eventdata reserved - to be defined in a future version of MATLAB 0567 % handles empty - handles not created until after all CreateFcns called 0568 0569 % Hint: popupmenu controls usually have a white background on Windows. 0570 % See ISPC and COMPUTER. 0571 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0572 set(hObject,'BackgroundColor','white'); 0573 end 0574 0575 0576 0577 function edit_weight_Callback(hObject, eventdata, handles) 0578 % hObject handle to edit_weight (see GCBO) 0579 % eventdata reserved - to be defined in a future version of MATLAB 0580 % handles structure with handles and user data (see GUIDATA) 0581 0582 % Hints: get(hObject,'String') returns contents of edit_weight as text 0583 % str2double(get(hObject,'String')) returns contents of edit_weight as a double 0584 validate_weight(handles); 0585 0586 0587 function flag = validate_weight(handles) 0588 str = get(handles.edit_weight,'String'); 0589 0590 errmsg = 'Weight must be a number'; 0591 errtitle = 'Invalid weight!'; 0592 0593 flag = validateRealNumber(str,errmsg,errtitle); 0594 0595 % --- Executes during object creation, after setting all properties. 0596 function edit_weight_CreateFcn(hObject, eventdata, handles) 0597 % hObject handle to edit_weight (see GCBO) 0598 % eventdata reserved - to be defined in a future version of MATLAB 0599 % handles empty - handles not created until after all CreateFcns called 0600 0601 % Hint: edit controls usually have a white background on Windows. 0602 % See ISPC and COMPUTER. 0603 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0604 set(hObject,'BackgroundColor','white'); 0605 end 0606 0607 0608 0609 function edit_exp_Callback(hObject, eventdata, handles) 0610 % hObject handle to edit_exp (see GCBO) 0611 % eventdata reserved - to be defined in a future version of MATLAB 0612 % handles structure with handles and user data (see GUIDATA) 0613 0614 % Hints: get(hObject,'String') returns contents of edit_exp as text 0615 % str2double(get(hObject,'String')) returns contents of edit_exp as a double 0616 validate_exp(handles); 0617 0618 0619 function flag = validate_exp(handles) 0620 str = get(handles.edit_exp,'String'); 0621 0622 errmsg = 'Exponent must be a number'; 0623 errtitle = 'Invalid exponent!'; 0624 0625 flag = validateRealNumber(str,errmsg,errtitle); 0626 0627 % --- Executes during object creation, after setting all properties. 0628 function edit_exp_CreateFcn(hObject, eventdata, handles) 0629 % hObject handle to edit_exp (see GCBO) 0630 % eventdata reserved - to be defined in a future version of MATLAB 0631 % handles empty - handles not created until after all CreateFcns called 0632 0633 % Hint: edit controls usually have a white background on Windows. 0634 % See ISPC and COMPUTER. 0635 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0636 set(hObject,'BackgroundColor','white'); 0637 end 0638 0639 0640 % --- Executes on selection change in popupmenu_statSelector. 0641 function popupmenu_statSelector_Callback(hObject, eventdata, handles) 0642 % hObject handle to popupmenu_statSelector (see GCBO) 0643 % eventdata reserved - to be defined in a future version of MATLAB 0644 % handles structure with handles and user data (see GUIDATA) 0645 0646 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_statSelector contents as cell array 0647 % contents{get(hObject,'Value')} returns selected item from popupmenu_statSelector 0648 0649 0650 % --- Executes during object creation, after setting all properties. 0651 function popupmenu_statSelector_CreateFcn(hObject, eventdata, handles) 0652 % hObject handle to popupmenu_statSelector (see GCBO) 0653 % eventdata reserved - to be defined in a future version of MATLAB 0654 % handles empty - handles not created until after all CreateFcns called 0655 0656 % Hint: popupmenu controls usually have a white background on Windows. 0657 % See ISPC and COMPUTER. 0658 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0659 set(hObject,'BackgroundColor','white'); 0660 end 0661 0662 0663 % --- Executes on selection change in popupmenu_constraint2Selector. 0664 function popupmenu_constraint2Selector_Callback(hObject, eventdata, handles) 0665 % hObject handle to popupmenu_constraint2Selector (see GCBO) 0666 % eventdata reserved - to be defined in a future version of MATLAB 0667 % handles structure with handles and user data (see GUIDATA) 0668 0669 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_constraint2Selector contents as cell array 0670 % contents{get(hObject,'Value')} returns selected item from popupmenu_constraint2Selector 0671 populateConstraintList(hObject); 0672 0673 % --- Executes during object creation, after setting all properties. 0674 function popupmenu_constraint2Selector_CreateFcn(hObject, eventdata, handles) 0675 % hObject handle to popupmenu_constraint2Selector (see GCBO) 0676 % eventdata reserved - to be defined in a future version of MATLAB 0677 % handles empty - handles not created until after all CreateFcns called 0678 0679 % Hint: popupmenu controls usually have a white background on Windows. 0680 % See ISPC and COMPUTER. 0681 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0682 set(hObject,'BackgroundColor','white'); 0683 end 0684 0685 0686 % --- Executes on button press in pushbutton_refreshSample2List. 0687 function pushbutton7_Callback(hObject, eventdata, handles) 0688 % hObject handle to pushbutton_refreshSample2List (see GCBO) 0689 % eventdata reserved - to be defined in a future version of MATLAB 0690 % handles structure with handles and user data (see GUIDATA) 0691 0692 0693 % --- Executes on key press with focus on popupmenu_constraint2Selector and none of its controls. 0694 function popupmenu_constraint2Selector_KeyPressFcn(hObject, eventdata, handles) 0695 % hObject handle to popupmenu_constraint2Selector (see GCBO) 0696 % eventdata structure with the following fields (see UICONTROL) 0697 % Key: name of the key that was pressed, in lower case 0698 % Character: character interpretation of the key(s) that was pressed 0699 % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed 0700 % handles structure with handles and user data (see GUIDATA) 0701 0702 0703 % --- If Enable == 'on', executes on mouse press in 5 pixel border. 0704 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_constraint2Selector. 0705 function popupmenu_constraint2Selector_ButtonDownFcn(hObject, eventdata, handles) 0706 % hObject handle to popupmenu_constraint2Selector (see GCBO) 0707 % eventdata reserved - to be defined in a future version of MATLAB 0708 % handles structure with handles and user data (see GUIDATA) 0709 populateConstraintList(hObject);