Home > src > createSingleSampleSoftDistanceConstraint_Dialog.m

# createSingleSampleSoftDistanceConstraint_Dialog

## PURPOSE

- create single sample soft distance constraint dialog

## SYNOPSIS

function varargout = createSingleSampleSoftDistanceConstraint_Dialog(varargin)

## DESCRIPTION

     - create single sample soft distance 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.

## CROSS-REFERENCE INFORMATION

This function calls:

- getdfName - extracts a dataframe name selected in the GUI
- sos_gui - sos main GUI
- validateRealNumber - helper function to validate that a string represents a real number
- 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 createSingleSampleSoftDistanceConstraint_Dialog_OpeningFcn(hObject, eventdata, handles, varargin)
- function varargout = createSingleSampleSoftDistanceConstraint_Dialog_OutputFcn(hObject, eventdata, handles)
- function edit_name_Callback(hObject, eventdata, handles)
- function flag = validate_name(handles)
- function edit_name_CreateFcn(hObject, eventdata, handles)
- function popupmenu_sample1Selector_Callback(hObject, eventdata, handles)
- function populateSampleList(hObject)
- function popupmenu_sample1Selector_CreateFcn(hObject, eventdata, handles)
- function pushbutton_refreshSample1List_Callback(hObject, eventdata, handles)
- function popupmenu_sample1Selector_ButtonDownFcn(hObject, eventdata, handles)
- function popupmenu_sample1ColSelector_Callback(hObject, eventdata, handles)
- function populateColumnList(hObject,sampleSelector)
- function popupmenu_sample1ColSelector_CreateFcn(hObject, eventdata, handles)
- function pushbutton_refreshsample1ColSelector_Callback(hObject, eventdata, handles)
- function popupmenu_sample2Selector_Callback(hObject, eventdata, handles)
- function popupmenu_sample2Selector_CreateFcn(hObject, eventdata, handles)
- function pushbutton_refreshSample2List_Callback(hObject, eventdata, handles)
- function popupmenu_sample2ColSelector_Callback(hObject, eventdata, handles)
- function popupmenu_sample2ColSelector_CreateFcn(hObject, eventdata, handles)
- function pushbutton_refreshsample2ColSelector_Callback(hObject, eventdata, handles)
- function popupmenu_sample1ColSelector_ButtonDownFcn(hObject, eventdata, handles)
- function popupmenu_sample2Selector_ButtonDownFcn(hObject, eventdata, handles)
- function popupmenu_sample2ColSelector_ButtonDownFcn(hObject, eventdata, handles)
- function edit_value_Callback(hObject, eventdata, handles)
- function flag = validate_value(handles)
- function edit_value_CreateFcn(hObject, eventdata, handles)
- function popupmenu_desiredpvalCondition_Callback(hObject, eventdata, handles)
- function popupmenu_desiredpvalCondition_CreateFcn(hObject, eventdata, handles)
- function popupmenu_tails_Callback(hObject, eventdata, handles)
- function popupmenu_tails_CreateFcn(hObject, eventdata, handles)
- function pushbutton_createSingleSampleSoftDistanceConstraint_Callback(hObject, eventdata, handles)
- function popupmenu_type_Callback(hObject, eventdata, handles)
- function popupmenu_type_CreateFcn(hObject, eventdata, handles)
- function popupmenu_fncSelector_Callback(hObject, eventdata, handles)
- function popupmenu_fncSelector_CreateFcn(hObject, eventdata, handles)
- function edit_weight_Callback(hObject, eventdata, handles)
- function flag = validate_weight(handles)
- function edit_weight_CreateFcn(hObject, eventdata, handles)
- function edit_exp_Callback(hObject, eventdata, handles)
- function flag = validate_exp(handles)
- function edit_exp_CreateFcn(hObject, eventdata, handles)
- function popupmenu_statSelector_Callback(hObject, eventdata, handles)
- function popupmenu_statSelector_CreateFcn(hObject, eventdata, handles)

## SOURCE CODE

    0001 % - create single sample soft distance 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 = createSingleSampleSoftDistanceConstraint_Dialog(varargin)
    0025 % CREATESINGLESAMPLESOFTDISTANCECONSTRAINT_DIALOG M-file for createSingleSampleSoftDistanceConstraint_Dialog.fig
    0026 %      CREATESINGLESAMPLESOFTDISTANCECONSTRAINT_DIALOG, by itself, creates a new CREATESINGLESAMPLESOFTDISTANCECONSTRAINT_DIALOG or raises the existing
    0027 %      singleton*.
    0028 %
    0029 %      H = CREATESINGLESAMPLESOFTDISTANCECONSTRAINT_DIALOG returns the handle to a new CREATESINGLESAMPLESOFTDISTANCECONSTRAINT_DIALOG or the handle to
    0030 %      the existing singleton*.
    0031 %
    0032 %      CREATESINGLESAMPLESOFTDISTANCECONSTRAINT_DIALOG('CALLBACK',hObject,eventData,handles,...) calls the local
    0033 %      function named CALLBACK in CREATESINGLESAMPLESOFTDISTANCECONSTRAINT_DIALOG.M with the given input arguments.
    0034 %
    0035 %      CREATESINGLESAMPLESOFTDISTANCECONSTRAINT_DIALOG('Property','Value',...) creates a new CREATESINGLESAMPLESOFTDISTANCECONSTRAINT_DIALOG or raises the
    0036 %      existing singleton*.  Starting from the left, property value pairs are
    0037 %      applied to the GUI before createSingleSampleSoftDistanceConstraint_Dialog_OpeningFcn gets called.  An
    0038 %      unrecognized property name or invalid value makes property application
    0039 %      stop.  All inputs are passed to createSingleSampleSoftDistanceConstraint_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 createSingleSampleSoftDistanceConstraint_Dialog
    0047
    0048 % Last Modified by GUIDE v2.5 16-Sep-2010 17:16:23
    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', @createSingleSampleSoftDistanceConstraint_Dialog_OpeningFcn, ...
    0055                    'gui_OutputFcn',  @createSingleSampleSoftDistanceConstraint_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 createSingleSampleSoftDistanceConstraint_Dialog is made visible.
    0071 function createSingleSampleSoftDistanceConstraint_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 createSingleSampleSoftDistanceConstraint_Dialog (see VARARGIN)
    0077
    0078 % Choose default command line output for createSingleSampleSoftDistanceConstraint_Dialog
    0079 handles.output = hObject;
    0080
    0081 % Update handles structure
    0082 guidata(hObject, handles);
    0083
    0084 % UIWAIT makes createSingleSampleSoftDistanceConstraint_Dialog wait for user response (see UIRESUME)
    0085 % uiwait(handles.figure_createSingleSampleSoftDistanceConstraint_Dialog);
    0086
    0087
    0088 % --- Outputs from this function are returned to the command line.
    0089 function varargout = createSingleSampleSoftDistanceConstraint_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_sample1Selector.
    0153 function popupmenu_sample1Selector_Callback(hObject, eventdata, handles)
    0154 % hObject    handle to popupmenu_sample1Selector (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_sample1Selector contents as cell array
    0159 %        contents{get(hObject,'Value')} returns selected item from popupmenu_sample1Selector
    0160     populateSampleList(hObject);
    0161
    0162
    0163 function populateSampleList(hObject)
    0164     % get a list of all populations in the base workspace:
    0165     vars = evalin('base','whos()');
    0166
    0167     samples = [];
    0168     for i=1:length(vars)
    0169         if strcmp(vars(i).class,'sample')
    0170             samples = [samples; {vars(i).name}]; %#ok<AGROW>
    0171         end
    0172     end
    0173
    0174
    0175
    0176     % assign that list to the options in the pop up menu
    0177     warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid');
    0178     set(hObject,'String',samples);
    0179
    0180 % --- Executes during object creation, after setting all properties.
    0181 function popupmenu_sample1Selector_CreateFcn(hObject, eventdata, handles)
    0182 % hObject    handle to popupmenu_sample1Selector (see GCBO)
    0183 % eventdata  reserved - to be defined in a future version of MATLAB
    0184 % handles    empty - handles not created until after all CreateFcns called
    0185
    0186 % Hint: popupmenu controls usually have a white background on Windows.
    0187 %       See ISPC and COMPUTER.
    0188 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0189     set(hObject,'BackgroundColor','white');
    0190 end
    0191
    0192
    0193 % --- Executes on button press in pushbutton_refreshSample1List.
    0194 function pushbutton_refreshSample1List_Callback(hObject, eventdata, handles)
    0195 % hObject    handle to pushbutton_refreshSample1List (see GCBO)
    0196 % eventdata  reserved - to be defined in a future version of MATLAB
    0197 % handles    structure with handles and user data (see GUIDATA)
    0198     populateSampleList(handles.popupmenu_sample1Selector);
    0199
    0200 % --- If Enable == 'on', executes on mouse press in 5 pixel border.
    0201 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_sample1Selector.
    0202 function popupmenu_sample1Selector_ButtonDownFcn(hObject, eventdata, handles)
    0203 % hObject    handle to popupmenu_sample1Selector (see GCBO)
    0204 % eventdata  reserved - to be defined in a future version of MATLAB
    0205 % handles    structure with handles and user data (see GUIDATA)
    0206     populateSampleList(hObject);
    0207
    0208
    0209 % --- Executes on selection change in popupmenu_sample1ColSelector.
    0210 function popupmenu_sample1ColSelector_Callback(hObject, eventdata, handles)
    0211 % hObject    handle to popupmenu_sample1ColSelector (see GCBO)
    0212 % eventdata  reserved - to be defined in a future version of MATLAB
    0213 % handles    structure with handles and user data (see GUIDATA)
    0214     populateColumnList(hObject,handles.popupmenu_sample1Selector);
    0215
    0216 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_sample1ColSelector contents as cell array
    0217 %        contents{get(hObject,'Value')} returns selected item from popupmenu_sample1ColSelector
    0218 function populateColumnList(hObject,sampleSelector)
    0219     % get a list of all populations in the base workspace:
    0220
    0221     create = true;
    0222
    0223     % get the sample in the first list.
    0224     sampleMenuHandle = sampleSelector;
    0225     sampleName = getdfName(sampleMenuHandle,'sample 1');
    0226
    0227     if isempty(sampleName)
    0228         create = false;
    0229     end
    0230
    0231     if create == true
    0232         % add in all of the header names associated with that sample.
    0233         tmpColNames = evalin('base',[sampleName,'.header']);
    0234
    0235         % melt and refreeze cells
    0236         colNames = {};
    0237
    0238         for i=1:length(tmpColNames)
    0239             colNames = [colNames ; tmpColNames{i}]; %#ok<AGROW>
    0240         end
    0241
    0242
    0243     % assign that list to the options in the pop up menu
    0244         warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid');
    0245         set(hObject,'String',colNames);
    0246     end
    0247
    0248 % --- Executes during object creation, after setting all properties.
    0249 function popupmenu_sample1ColSelector_CreateFcn(hObject, eventdata, handles)
    0250 % hObject    handle to popupmenu_sample1ColSelector (see GCBO)
    0251 % eventdata  reserved - to be defined in a future version of MATLAB
    0252 % handles    empty - handles not created until after all CreateFcns called
    0253
    0254 % Hint: popupmenu controls usually have a white background on Windows.
    0255 %       See ISPC and COMPUTER.
    0256 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0257     set(hObject,'BackgroundColor','white');
    0258 end
    0259
    0260
    0261 % --- Executes on button press in pushbutton_refreshsample1ColSelector.
    0262 function pushbutton_refreshsample1ColSelector_Callback(hObject, eventdata, handles)
    0263 % hObject    handle to pushbutton_refreshsample1ColSelector (see GCBO)
    0264 % eventdata  reserved - to be defined in a future version of MATLAB
    0265 % handles    structure with handles and user data (see GUIDATA)
    0266     populateColumnList(handles.popupmenu_sample1ColSelector,handles.popupmenu_sample1Selector);
    0267
    0268
    0269 % --- Executes on selection change in popupmenu_sample2Selector.
    0270 function popupmenu_sample2Selector_Callback(hObject, eventdata, handles)
    0271 % hObject    handle to popupmenu_sample2Selector (see GCBO)
    0272 % eventdata  reserved - to be defined in a future version of MATLAB
    0273 % handles    structure with handles and user data (see GUIDATA)
    0274
    0275 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_sample2Selector contents as cell array
    0276 %        contents{get(hObject,'Value')} returns selected item from popupmenu_sample2Selector
    0277     populateSampleList(hObject);
    0278
    0279
    0280 % --- Executes during object creation, after setting all properties.
    0281 function popupmenu_sample2Selector_CreateFcn(hObject, eventdata, handles)
    0282 % hObject    handle to popupmenu_sample2Selector (see GCBO)
    0283 % eventdata  reserved - to be defined in a future version of MATLAB
    0284 % handles    empty - handles not created until after all CreateFcns called
    0285
    0286 % Hint: popupmenu controls usually have a white background on Windows.
    0287 %       See ISPC and COMPUTER.
    0288 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0289     set(hObject,'BackgroundColor','white');
    0290 end
    0291
    0292
    0293 % --- Executes on button press in pushbutton_refreshSample2List.
    0294 function pushbutton_refreshSample2List_Callback(hObject, eventdata, handles)
    0295 % hObject    handle to pushbutton_refreshSample2List (see GCBO)
    0296 % eventdata  reserved - to be defined in a future version of MATLAB
    0297 % handles    structure with handles and user data (see GUIDATA)
    0298     populateSampleList(handles.popupmenu_sample2Selector);
    0299
    0300 % --- Executes on selection change in popupmenu_sample2ColSelector.
    0301 function popupmenu_sample2ColSelector_Callback(hObject, eventdata, handles)
    0302 % hObject    handle to popupmenu_sample2ColSelector (see GCBO)
    0303 % eventdata  reserved - to be defined in a future version of MATLAB
    0304 % handles    structure with handles and user data (see GUIDATA)
    0305
    0306 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_sample2ColSelector contents as cell array
    0307 %        contents{get(hObject,'Value')} returns selected item from popupmenu_sample2ColSelector
    0308     populateColumnList(hObject,handles.popupmenu_sample2Selector);
    0309
    0310
    0311 % --- Executes during object creation, after setting all properties.
    0312 function popupmenu_sample2ColSelector_CreateFcn(hObject, eventdata, handles)
    0313 % hObject    handle to popupmenu_sample2ColSelector (see GCBO)
    0314 % eventdata  reserved - to be defined in a future version of MATLAB
    0315 % handles    empty - handles not created until after all CreateFcns called
    0316
    0317 % Hint: popupmenu controls usually have a white background on Windows.
    0318 %       See ISPC and COMPUTER.
    0319 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0320     set(hObject,'BackgroundColor','white');
    0321 end
    0322
    0323
    0324 % --- Executes on button press in pushbutton_refreshsample2ColSelector.
    0325 function pushbutton_refreshsample2ColSelector_Callback(hObject, eventdata, handles)
    0326 % hObject    handle to pushbutton_refreshsample2ColSelector (see GCBO)
    0327 % eventdata  reserved - to be defined in a future version of MATLAB
    0328 % handles    structure with handles and user data (see GUIDATA)
    0329     populateColumnList(handles.popupmenu_sample2ColSelector,handles.popupmenu_sample2Selector);
    0330
    0331
    0332 % --- If Enable == 'on', executes on mouse press in 5 pixel border.
    0333 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_sample1ColSelector.
    0334 function popupmenu_sample1ColSelector_ButtonDownFcn(hObject, eventdata, handles)
    0335 % hObject    handle to popupmenu_sample1ColSelector (see GCBO)
    0336 % eventdata  reserved - to be defined in a future version of MATLAB
    0337 % handles    structure with handles and user data (see GUIDATA)
    0338     populateColumnList(hObject,handles.popupmenu_sample1Selector);
    0339
    0340
    0341 % --- If Enable == 'on', executes on mouse press in 5 pixel border.
    0342 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_sample2Selector.
    0343 function popupmenu_sample2Selector_ButtonDownFcn(hObject, eventdata, handles)
    0344 % hObject    handle to popupmenu_sample2Selector (see GCBO)
    0345 % eventdata  reserved - to be defined in a future version of MATLAB
    0346 % handles    structure with handles and user data (see GUIDATA)
    0347     populateSampleList(hObject);
    0348
    0349
    0350 % --- If Enable == 'on', executes on mouse press in 5 pixel border.
    0351 % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu_sample2ColSelector.
    0352 function popupmenu_sample2ColSelector_ButtonDownFcn(hObject, eventdata, handles)
    0353 % hObject    handle to popupmenu_sample2ColSelector (see GCBO)
    0354 % eventdata  reserved - to be defined in a future version of MATLAB
    0355 % handles    structure with handles and user data (see GUIDATA)
    0356     populateColumnList(hObject,handles.popupmenu_sample2Selector);
    0357
    0358
    0359
    0360 function edit_value_Callback(hObject, eventdata, handles)
    0361 % hObject    handle to edit_value (see GCBO)
    0362 % eventdata  reserved - to be defined in a future version of MATLAB
    0363 % handles    structure with handles and user data (see GUIDATA)
    0364
    0365 % Hints: get(hObject,'String') returns contents of edit_value as text
    0366 %        str2double(get(hObject,'String')) returns contents of edit_value as a double
    0367     validate_value(handles);
    0368
    0369
    0370 function flag = validate_value(handles)
    0371      str = get(handles.edit_value,'String');
    0372
    0373     errmsg = 'Bound value must be a number';
    0374     errtitle = 'Invalid bound value!';
    0375
    0376     flag = validateRealNumber(str,errmsg,errtitle);
    0377
    0378
    0379
    0380 % --- Executes during object creation, after setting all properties.
    0381 function edit_value_CreateFcn(hObject, eventdata, handles)
    0382 % hObject    handle to edit_value (see GCBO)
    0383 % eventdata  reserved - to be defined in a future version of MATLAB
    0384 % handles    empty - handles not created until after all CreateFcns called
    0385
    0386 % Hint: edit controls usually have a white background on Windows.
    0387 %       See ISPC and COMPUTER.
    0388 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0389     set(hObject,'BackgroundColor','white');
    0390 end
    0391
    0392
    0393 % --- Executes on selection change in popupmenu_desiredpvalCondition.
    0394 function popupmenu_desiredpvalCondition_Callback(hObject, eventdata, handles)
    0395 % hObject    handle to popupmenu_desiredpvalCondition (see GCBO)
    0396 % eventdata  reserved - to be defined in a future version of MATLAB
    0397 % handles    structure with handles and user data (see GUIDATA)
    0398
    0399 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_desiredpvalCondition contents as cell array
    0400 %        contents{get(hObject,'Value')} returns selected item from popupmenu_desiredpvalCondition
    0401
    0402
    0403 % --- Executes during object creation, after setting all properties.
    0404 function popupmenu_desiredpvalCondition_CreateFcn(hObject, eventdata, handles)
    0405 % hObject    handle to popupmenu_desiredpvalCondition (see GCBO)
    0406 % eventdata  reserved - to be defined in a future version of MATLAB
    0407 % handles    empty - handles not created until after all CreateFcns called
    0408
    0409 % Hint: popupmenu controls usually have a white background on Windows.
    0410 %       See ISPC and COMPUTER.
    0411 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0412     set(hObject,'BackgroundColor','white');
    0413 end
    0414
    0415
    0416 % --- Executes on selection change in popupmenu_tails.
    0417 function popupmenu_tails_Callback(hObject, eventdata, handles)
    0418 % hObject    handle to popupmenu_tails (see GCBO)
    0419 % eventdata  reserved - to be defined in a future version of MATLAB
    0420 % handles    structure with handles and user data (see GUIDATA)
    0421
    0422 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_tails contents as cell array
    0423 %        contents{get(hObject,'Value')} returns selected item from popupmenu_tails
    0424
    0425
    0426 % --- Executes during object creation, after setting all properties.
    0427 function popupmenu_tails_CreateFcn(hObject, eventdata, handles)
    0428 % hObject    handle to popupmenu_tails (see GCBO)
    0429 % eventdata  reserved - to be defined in a future version of MATLAB
    0430 % handles    empty - handles not created until after all CreateFcns called
    0431
    0432 % Hint: popupmenu controls usually have a white background on Windows.
    0433 %       See ISPC and COMPUTER.
    0434 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0435     set(hObject,'BackgroundColor','white');
    0436 end
    0437
    0438
    0439 % --- Executes on button press in pushbutton_createSingleSampleSoftDistanceConstraint.
    0440 function pushbutton_createSingleSampleSoftDistanceConstraint_Callback(hObject, eventdata, handles)
    0441 % hObject    handle to pushbutton_createSingleSampleSoftDistanceConstraint (see GCBO)
    0442 % eventdata  reserved - to be defined in a future version of MATLAB
    0443 % handles    structure with handles and user data (see GUIDATA)
    0444
    0445     type = getdfName(handles.popupmenu_type,'type');
    0446
    0447     mainWindowHandle = sos_gui;
    0448     mainWindowData = guidata(mainWindowHandle);
    0449
    0450     sosObjName = getdfName(mainWindowData.popupmenu_SOSSelector,'SOS');
    0451
    0452     if isempty(sosObjName) == 0
    0453         % we have a valid SOS object to add the test to
    0454         % validate all of the parameters for the test
    0455         create = validate_name(handles);
    0456         name = get(handles.edit_name,'String');
    0457
    0458         if create == true
    0459             sample1 = getdfName(handles.popupmenu_sample1Selector,'sample 1');
    0460
    0461             if isempty(sample1) == 0
    0462                 sample1Col = getdfName(handles.popupmenu_sample1ColSelector','sample 1 column');
    0463
    0464                 if isempty(sample1Col) == 0
    0465                    create = validate_value(handles);
    0466
    0467                    if create == true
    0468                        % all values have passed.  Can execute the command
    0469                         value = get(handles.edit_value,'String');
    0470
    0471                         % check weight
    0472                         create = validate_weight(handles);
    0473                         if create == true
    0474                             weight = get(handles.edit_weight,'String');
    0475
    0476                             create = validate_exp(handles);
    0477                             if create == true
    0478                                 exp = get (handles.edit_exp,'String');
    0479
    0480                                     %all functions passed, retrieve the
    0481                                     %hard-coded popup menu data
    0482
    0483                                     fnc = getdfName(handles.popupmenu_fncSelector,...
    0484                                                     'fnc');
    0485                                     stat = getdfName(handles.popupmenu_statSelector,...
    0486                                                     'stat');
    0487
    0488
    0489                                     %all of the other options are in drop-down
    0490                                     %menus and as such necessarily will pass.
    0491                                     %run the command.
    0492
    0493                                     command = [name,'=',sosObjName,'.addConstraint(',...
    0494                                         '''name'',''',name,''',',...
    0495                                         '''constraintType'',''',type,''',',...
    0496                                         '''stat'',''',stat,''',',...
    0497                                         '''fnc'',''',fnc,''',',...
    0498                                         '''sample1'',',sample1,',',...
    0499                                         '''s1ColName'',''',sample1Col,''',',...
    0500                                         '''targVal'',',value,',',...
    0501                                         '''weight'',',weight,','...
    0502                                         '''exponent'',',exp,');',...
    0503                                         ];
    0504
    0505                                     verbosePrint(['Executing command: ','''',command,''''],'createSingleSampleSoftDistanceConstraint_Dialog_create');
    0506                                     evalin('base',command);
    0507                                     close(handles.figure_createSingleSampleSoftDistanceConstraint_Dialog);
    0508                             end
    0509                         end
    0510                    end
    0511                 end
    0512             end
    0513         end
    0514     end
    0515
    0516
    0517 % --- Executes on selection change in popupmenu_type.
    0518 function popupmenu_type_Callback(hObject, eventdata, handles)
    0519 % hObject    handle to popupmenu_type (see GCBO)
    0520 % eventdata  reserved - to be defined in a future version of MATLAB
    0521 % handles    structure with handles and user data (see GUIDATA)
    0522
    0523 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_type contents as cell array
    0524 %        contents{get(hObject,'Value')} returns selected item from popupmenu_type
    0525
    0526
    0527 % --- Executes during object creation, after setting all properties.
    0528 function popupmenu_type_CreateFcn(hObject, eventdata, handles)
    0529 % hObject    handle to popupmenu_type (see GCBO)
    0530 % eventdata  reserved - to be defined in a future version of MATLAB
    0531 % handles    empty - handles not created until after all CreateFcns called
    0532
    0533 % Hint: popupmenu controls usually have a white background on Windows.
    0534 %       See ISPC and COMPUTER.
    0535 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0536     set(hObject,'BackgroundColor','white');
    0537 end
    0538
    0539
    0540 % --- Executes on selection change in popupmenu_fncSelector.
    0541 function popupmenu_fncSelector_Callback(hObject, eventdata, handles)
    0542 % hObject    handle to popupmenu_fncSelector (see GCBO)
    0543 % eventdata  reserved - to be defined in a future version of MATLAB
    0544 % handles    structure with handles and user data (see GUIDATA)
    0545
    0546 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_fncSelector contents as cell array
    0547 %        contents{get(hObject,'Value')} returns selected item from popupmenu_fncSelector
    0548
    0549
    0550 % --- Executes during object creation, after setting all properties.
    0551 function popupmenu_fncSelector_CreateFcn(hObject, eventdata, handles)
    0552 % hObject    handle to popupmenu_fncSelector (see GCBO)
    0553 % eventdata  reserved - to be defined in a future version of MATLAB
    0554 % handles    empty - handles not created until after all CreateFcns called
    0555
    0556 % Hint: popupmenu controls usually have a white background on Windows.
    0557 %       See ISPC and COMPUTER.
    0558 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0559     set(hObject,'BackgroundColor','white');
    0560 end
    0561
    0562
    0563
    0564 function edit_weight_Callback(hObject, eventdata, handles)
    0565 % hObject    handle to edit_weight (see GCBO)
    0566 % eventdata  reserved - to be defined in a future version of MATLAB
    0567 % handles    structure with handles and user data (see GUIDATA)
    0568
    0569 % Hints: get(hObject,'String') returns contents of edit_weight as text
    0570 %        str2double(get(hObject,'String')) returns contents of edit_weight as a double
    0571     validate_weight(handles);
    0572
    0573
    0574 function flag = validate_weight(handles)
    0575      str = get(handles.edit_weight,'String');
    0576
    0577     errmsg = 'Weight must be a number';
    0578     errtitle = 'Invalid weight!';
    0579
    0580     flag = validateRealNumber(str,errmsg,errtitle);
    0581
    0582 % --- Executes during object creation, after setting all properties.
    0583 function edit_weight_CreateFcn(hObject, eventdata, handles)
    0584 % hObject    handle to edit_weight (see GCBO)
    0585 % eventdata  reserved - to be defined in a future version of MATLAB
    0586 % handles    empty - handles not created until after all CreateFcns called
    0587
    0588 % Hint: edit controls usually have a white background on Windows.
    0589 %       See ISPC and COMPUTER.
    0590 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0591     set(hObject,'BackgroundColor','white');
    0592 end
    0593
    0594
    0595
    0596 function edit_exp_Callback(hObject, eventdata, handles)
    0597 % hObject    handle to edit_exp (see GCBO)
    0598 % eventdata  reserved - to be defined in a future version of MATLAB
    0599 % handles    structure with handles and user data (see GUIDATA)
    0600
    0601 % Hints: get(hObject,'String') returns contents of edit_exp as text
    0602 %        str2double(get(hObject,'String')) returns contents of edit_exp as a double
    0603     validate_exp(handles);
    0604
    0605
    0606 function flag = validate_exp(handles)
    0607      str = get(handles.edit_exp,'String');
    0608
    0609     errmsg = 'Exponent must be a number';
    0610     errtitle = 'Invalid exponent!';
    0611
    0612     flag = validateRealNumber(str,errmsg,errtitle);
    0613
    0614 % --- Executes during object creation, after setting all properties.
    0615 function edit_exp_CreateFcn(hObject, eventdata, handles)
    0616 % hObject    handle to edit_exp (see GCBO)
    0617 % eventdata  reserved - to be defined in a future version of MATLAB
    0618 % handles    empty - handles not created until after all CreateFcns called
    0619
    0620 % Hint: edit controls usually have a white background on Windows.
    0621 %       See ISPC and COMPUTER.
    0622 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0623     set(hObject,'BackgroundColor','white');
    0624 end
    0625
    0626
    0627 % --- Executes on selection change in popupmenu_statSelector.
    0628 function popupmenu_statSelector_Callback(hObject, eventdata, handles)
    0629 % hObject    handle to popupmenu_statSelector (see GCBO)
    0630 % eventdata  reserved - to be defined in a future version of MATLAB
    0631 % handles    structure with handles and user data (see GUIDATA)
    0632
    0633 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_statSelector contents as cell array
    0634 %        contents{get(hObject,'Value')} returns selected item from popupmenu_statSelector
    0635
    0636
    0637 % --- Executes during object creation, after setting all properties.
    0638 function popupmenu_statSelector_CreateFcn(hObject, eventdata, handles)
    0639 % hObject    handle to popupmenu_statSelector (see GCBO)
    0640 % eventdata  reserved - to be defined in a future version of MATLAB
    0641 % handles    empty - handles not created until after all CreateFcns called
    0642
    0643 % Hint: popupmenu controls usually have a white background on Windows.
    0644 %       See ISPC and COMPUTER.
    0645 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0646     set(hObject,'BackgroundColor','white');
    0647 end