- create sosplots 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 sosplots 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 0025 0026 function varargout = createPlots_Dialog(varargin) 0027 % CREATEPLOTS_DIALOG M-file for createPlots_Dialog.fig 0028 % CREATEPLOTS_DIALOG, by itself, creates a new CREATEPLOTS_DIALOG or raises the existing 0029 % singleton*. 0030 % 0031 % H = CREATEPLOTS_DIALOG returns the handle to a new CREATEPLOTS_DIALOG or the handle to 0032 % the existing singleton*. 0033 % 0034 % CREATEPLOTS_DIALOG('CALLBACK',hObject,eventData,handles,...) calls the local 0035 % function named CALLBACK in CREATEPLOTS_DIALOG.M with the given input arguments. 0036 % 0037 % CREATEPLOTS_DIALOG('Property','Value',...) creates a new CREATEPLOTS_DIALOG or raises the 0038 % existing singleton*. Starting from the left, property value pairs are 0039 % applied to the GUI before createPlots_Dialog_OpeningFcn gets called. An 0040 % unrecognized property name or invalid value makes property application 0041 % stop. All inputs are passed to createPlots_Dialog_OpeningFcn via varargin. 0042 % 0043 % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 0044 % instance to run (singleton)". 0045 % 0046 % See also: GUIDE, GUIDATA, GUIHANDLES 0047 0048 % Edit the above text to modify the response to help createPlots_Dialog 0049 0050 % Last Modified by GUIDE v2.5 09-Sep-2010 11:49:00 0051 0052 % Begin initialization code - DO NOT EDIT 0053 gui_Singleton = 1; 0054 gui_State = struct('gui_Name', mfilename, ... 0055 'gui_Singleton', gui_Singleton, ... 0056 'gui_OpeningFcn', @createPlots_Dialog_OpeningFcn, ... 0057 'gui_OutputFcn', @createPlots_Dialog_OutputFcn, ... 0058 'gui_LayoutFcn', [] , ... 0059 'gui_Callback', []); 0060 if nargin && ischar(varargin{1}) 0061 gui_State.gui_Callback = str2func(varargin{1}); 0062 end 0063 0064 if nargout 0065 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 0066 else 0067 gui_mainfcn(gui_State, varargin{:}); 0068 end 0069 % End initialization code - DO NOT EDIT 0070 0071 0072 0073 % --- Executes just before createPlots_Dialog is made visible. 0074 function createPlots_Dialog_OpeningFcn(hObject, eventdata, handles, varargin) 0075 % This function has no output args, see OutputFcn. 0076 % hObject handle to figure 0077 % eventdata reserved - to be defined in a future version of MATLAB 0078 % handles structure with handles and user data (see GUIDATA) 0079 % varargin command line arguments to createPlots_Dialog (see VARARGIN) 0080 0081 % Choose default command line output for createPlots_Dialog 0082 handles.output = hObject; 0083 0084 % Update handles structure 0085 guidata(hObject, handles); 0086 0087 % UIWAIT makes createPlots_Dialog wait for user response (see UIRESUME) 0088 % uiwait(handles.figure_createPlots); 0089 0090 0091 % --- Outputs from this function are returned to the command line. 0092 function varargout = createPlots_Dialog_OutputFcn(hObject, eventdata, handles) 0093 % varargout cell array for returning output args (see VARARGOUT); 0094 % hObject handle to figure 0095 % eventdata reserved - to be defined in a future version of MATLAB 0096 % handles structure with handles and user data (see GUIDATA) 0097 0098 % Get default command line output from handles structure 0099 varargout{1} = handles.output; 0100 0101 0102 % --- Executes on button press in pushbutton_createPlots. 0103 function pushbutton_createPlots_Callback(hObject, eventdata, handles) 0104 % hObject handle to pushbutton_createPlots (see GCBO) 0105 % eventdata reserved - to be defined in a future version of MATLAB 0106 % handles structure with handles and user data (see GUIDATA) 0107 0108 % validate the number of iterations to display 0109 0110 create = true; 0111 0112 dispIt = get(handles.edit_dispIt,'String'); 0113 0114 %check to make sure that the name is a valid variable name: 0115 valid = regexp(dispIt,'^[1-9]+[0-9]*$'); 0116 0117 0118 if isempty(valid) 0119 % name is not currently valid, tell the user. 0120 msgbox('Sample size must be a whole number > 0',... 0121 'Invalid sample size!'); 0122 create = false; 0123 end 0124 0125 % if the first variable passed, proceed to check the second 0126 if create == true 0127 mainWindowHandle = sos_gui; 0128 mainWindowData = guidata(mainWindowHandle); 0129 0130 sosObjName = getdfName(mainWindowData.popupmenu_SOSSelector,'SOS'); 0131 0132 if isempty(sosObjName) == 0 0133 % we have a valid name, run the command 0134 command = [sosObjName,'.createPlots(',dispIt,');']; 0135 0136 verbosePrint(['Executing command: ','''',command,''''],'createPlots_Dialog_create'); 0137 evalin('base',command); 0138 0139 close(handles.figure_createPlots); 0140 else 0141 % if it was empty, a warning message will have been triggered by getdfName; 0142 % no need to do anything here. 0143 end 0144 end 0145 0146 0147 0148 function edit_dispIt_Callback(hObject, eventdata, handles) 0149 % hObject handle to edit_dispIt (see GCBO) 0150 % eventdata reserved - to be defined in a future version of MATLAB 0151 % handles structure with handles and user data (see GUIDATA) 0152 0153 % Hints: get(hObject,'String') returns contents of edit_dispIt as text 0154 % str2double(get(hObject,'String')) returns contents of edit_dispIt as a double 0155 varName = get(hObject,'String'); 0156 0157 %check to make sure that the name is a valid variable name: 0158 valid = regexp(varName,'^[1-9]+[0-9]*$', 'once'); 0159 0160 0161 if isempty(valid) 0162 % name is not currently valid, tell the user. 0163 msgbox('Number of iterations to display must be > 0',... 0164 'Invalid dispIt!'); 0165 end 0166 0167 % --- Executes during object creation, after setting all properties. 0168 function edit_dispIt_CreateFcn(hObject, eventdata, handles) 0169 % hObject handle to edit_dispIt (see GCBO) 0170 % eventdata reserved - to be defined in a future version of MATLAB 0171 % handles empty - handles not created until after all CreateFcns called 0172 0173 % Hint: edit controls usually have a white background on Windows. 0174 % See ISPC and COMPUTER. 0175 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 0176 set(hObject,'BackgroundColor','white'); 0177 end