Changeset 7d32aaf in sasview for src/sas/perspectives
- Timestamp:
- Feb 18, 2015 3:46:23 PM (10 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- d90f91b
- Parents:
- c1694f8 (diff), e8bb5b6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas/perspectives
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/calculator/image_viewer.py
r7a04dbb reec63a8 59 59 plot_frame = ImageFrame(parent, -1, basename, img) 60 60 plot_frame.Show(False) 61 #plot_frame.im_show(img)62 61 ax = plot_frame.plotpanel 63 62 if not is_png: … … 73 72 except: 74 73 print "parent", parent 75 raise76 74 err_msg += "Failed to load '%s'.\n"% basename 77 75 if err_msg: … … 80 78 else: 81 79 print err_msg 82 83 80 84 81 def choose_data_file(self, location=None): … … 86 83 Open a file dialog to allow loading a file 87 84 """ 88 parent = self.parent89 85 path = None 90 86 if location == None: 91 87 location = os.getcwd() 92 wlist = '' 93 elist = ["All images (*.png, *.bmp, *.gif, *.jpg, *.tif, *.tiff) | \ 94 *.png; *.bmp; *.gif; *.jpg; *.tif; *.tiff", 95 "PNG files (*.PNG, *.png) | *.png", 96 "BMP files (*.BMP, *.bmp) | *.bmp", 97 "GIF files (*.GIF, *.gif) | *.gif", 98 "JPG files (*.JPG, *.jpg) | *.jpg", 99 "TIF files (*.TIF, *.tif) | *.tif", 100 "TIFF files (*.TIFF, *.tiff) | *.tiff"] 101 if not IS_WIN: 102 del elist[0] 103 elist.append("All files (*.*) | *.*") 104 wlist = '|'.join(elist) 105 style = wx.OPEN|wx.FD_MULTIPLE 106 dlg = wx.FileDialog(parent, "Image Viewer: Choose a image file", 107 location, "", wlist, style=style) 88 dlg = wx.FileDialog(self.parent, "Image Viewer: Choose a image file", 89 location, "", "", style=wx.FD_OPEN|wx.FD_MULTIPLE) 108 90 if dlg.ShowModal() == wx.ID_OK: 109 91 path = dlg.GetPaths() -
src/sas/perspectives/calculator/media/data_operator_help.rst
r98b30b4 r684fade 9 9 Description 10 10 ----------- 11 This dialog panel provides arithmetic operations between two data sets (the12 last data set could be a number).13 11 14 When data1 and data2 are selected, their x (or qx and qy for 2D) value(s) 15 must match with each other. 12 This tool permits arithmetic operations between two data sets. Alternatively, 13 the last data set can be a number. 14 15 *NOTE! When* Data1 *and* Data2 *are both data, their Q (or Qx and Qy for 2D) 16 value(s) must match with each other UNLESS using the 'append' operator.* 16 17 17 18 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ … … 19 20 How To 20 21 ------ 21 1. Type the data name resulted from an operation.22 22 23 2) Select a data/theory in the drop down menus. When data2 is set to number, 24 type a number in the text control box. 23 1) Enure you have loaded data into the *Data Explorer* (see :ref:`Load_Data`). 25 24 26 3) Select an arithmetic operator symbol; + (for addition), - (for subtraction), 27 * (for multiplication), / (for division), and | (for combination of two data 28 sets). 25 2) Select *Data Operation* from the *Tool* menu on the SasView toolbar. 29 26 30 If two data sets do not match, the operation will fail and the background color 31 of the combo box items will turn to red (WIN only).27 3) Select a dataset/theory in the drop-down menu *Data1*. A mini-plot of the 28 data will appear underneath. 32 29 33 4) If the operation is successful, hit the Apply button to make the new data.34 Then the data name will be shown up in the data box in the data explorer.30 4) Select a dataset/theory in the drop-down menu *Data2* or select *Number* 31 and enter a number in the box that appears alongside. 35 32 36 Note: Any errors and warnings will be displayed at the bottom of the SasView 37 window. 33 5) Select an arithmetic operator symbol from the *Operator* drop-down. The 34 available operators are: 35 36 * + (for addition) 37 * - (for subtraction), 38 * * (for multiplication) 39 * / (for division) 40 * | (for combination of two data sets) 41 42 If two data sets do not match, the operation will fail and the background 43 color of the combo box items will turn to red (WIN only). 44 45 6) If the operation is successful, hit the Apply button to make the new dataset. 46 The new dataset will appear in the *Data Explorer*. 47 48 *NOTE! Any errors and warnings will be displayed at the bottom of the SasView 49 window.* 38 50 39 51 .. image:: data_oper_pic.png 52 53 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 54 55 .. note:: This help document was last changed by Steve King, 18Feb2015 -
src/sas/perspectives/calculator/media/density_calculator_help.rst
rec392464 r054a3ad 10 10 ----------- 11 11 12 This tool is to calculatethe mass density from the molar volume or vice12 This tool calculates the mass density from the molar volume or vice 13 13 versa. To calculate the mass density, the chemical formula and molar volume 14 14 should be provided. … … 19 19 ------ 20 20 21 1. Molecular Formula: The chemical formula of ONE molecule or ONE atom. For 22 mixtures, the ratio of the each molecules should be used; for example, 23 (H2O)0.5(D2O)0.5. 21 1) Enter the empirical formula of a molecule. For mixtures, the ratio of each 22 of the molecules should be used, for example, (H2O)0.5(D2O)0.5. 24 23 25 2 . Select input (molar volume or mass density) from combobox. Then type in the26 input value.24 2) Use the input combo box to choose between molar volume or mass density and 25 then type in an input value. 27 26 28 3. Click the 'Calculate' button to perform the calculation. 29 30 4. Outputs also include the molar mass (weight) that depends only on the 31 chemical formula 27 3) Click the 'Calculate' button to perform the calculation. 32 28 33 29 .. image:: density_tutor.gif 30 31 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 32 33 .. note:: This help document was last changed by Steve King, 18Feb2015 -
src/sas/perspectives/fitting/batchfitpage.py
r79492222 rfa09d62 17 17 from sas.models.qsmearing import smear_selection 18 18 from sas.perspectives.fitting.fitpage import FitPage 19 from sas.perspectives.fitting.fitpage import check_data_validity 19 20 20 21 class BatchFitPage(FitPage): … … 30 31 """ 31 32 FitPage.__init__(self, parent, color=color) 32 self.window_name = "BatchFit" 33 self.window_caption = "BatchFit" 34 self._set_save_flag(False) 35 self._set_bookmark_flag(False) 36 37 def _fill_range_sizer(self): 33 34 ## draw sizer 35 36 def _fill_data_sizer(self): 38 37 """ 39 Fill the sizer containing the plotting range 40 add access to npts 38 fill sizer 0 with data info 41 39 """ 42 is_2Ddata = False 43 44 # Check if data is 2D 45 if self.data.__class__.__name__ == "Data2D" or \ 46 self.enable2D: 47 is_2Ddata = True 48 49 title = "Fitting" 50 self._get_smear_info() 51 52 #Sizers 53 box_description_range = wx.StaticBox(self, -1, str(title)) 54 boxsizer_range = wx.StaticBoxSizer(box_description_range, wx.VERTICAL) 55 self.sizer_set_smearer = wx.BoxSizer(wx.VERTICAL) 56 #sizer_smearer = wx.BoxSizer(wx.HORIZONTAL) 57 self.sizer_new_smear = wx.BoxSizer(wx.HORIZONTAL) 58 self.sizer_set_masking = wx.BoxSizer(wx.HORIZONTAL) 59 sizer_chi2 = wx.BoxSizer(wx.VERTICAL) 60 61 sizer_fit = wx.GridSizer(2, 4, 2, 6) 62 #Fit button 63 self.btFit = wx.Button(self, wx.NewId(), 'Fit', size=(88, 25)) 64 self.default_bt_colour = self.btFit.GetDefaultAttributes() 65 self.btFit.Bind(wx.EVT_BUTTON, self._onFit, id= self.btFit.GetId()) 66 self.btFit.SetToolTipString("Start fitting.") 67 68 # Update and Draw button 69 self.draw_button = wx.Button(self, wx.NewId(), 'Compute', size=(88, 24)) 70 self.draw_button.Bind(wx.EVT_BUTTON, \ 71 self._onDraw,id=self.draw_button.GetId()) 72 self.draw_button.SetToolTipString("Compute and Draw.") 73 sizer_fit.Add(self.draw_button, 0, 0) 74 sizer_fit.Add(self.btFit, 0, 0) 75 sizer_chi2.Add((-1, 5)) 76 # get smear_selection 77 self.current_smearer = smear_selection( self.data, self.model ) 78 boxsizer_range.Add(self.sizer_set_masking) 79 #2D data? default 80 is_2Ddata = False 81 82 #check if it is 2D data 83 if self.data.__class__.__name__ == "Data2D" or \ 84 self.enable2D: 85 is_2Ddata = True 86 87 self.sizer5.Clear(True) 88 89 self.qmin = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 90 style=wx.TE_PROCESS_ENTER, 91 text_enter_callback = self._onQrangeEnter) 92 self.qmin.SetValue(str(self.qmin_x)) 93 self.qmin.SetToolTipString("Minimun value of Q in linear scale.") 94 95 self.qmax = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 96 style=wx.TE_PROCESS_ENTER, 97 text_enter_callback=self._onQrangeEnter) 98 self.qmax.SetValue(str(self.qmax_x)) 99 self.qmax.SetToolTipString("Maximum value of Q in linear scale.") 100 101 id = wx.NewId() 102 self.reset_qrange =wx.Button(self, id, 'Reset', size=(77, 20)) 103 104 self.reset_qrange.Bind(wx.EVT_BUTTON, self.on_reset_clicked, id=id) 105 self.reset_qrange.SetToolTipString(\ 106 "Reset Q range to the default values") 107 108 sizer_horizontal = wx.BoxSizer(wx.HORIZONTAL) 109 sizer = wx.GridSizer(2, 4, 2, 6) 110 111 self.btEditMask = wx.Button(self, wx.NewId(),'Editor', size=(88, 23)) 112 self.btEditMask.Bind(wx.EVT_BUTTON, 113 self._onMask,id=self.btEditMask.GetId()) 114 self.btEditMask.SetToolTipString("Edit Mask.") 115 self.EditMask_title = wx.StaticText(self, -1, ' Masking(2D)') 116 117 sizer.Add(wx.StaticText(self, -1, 'Q range')) 118 sizer.Add(wx.StaticText(self, -1, ' Min[1/A]')) 119 sizer.Add(wx.StaticText(self, -1, ' Max[1/A]')) 120 sizer.Add(self.EditMask_title) 121 122 sizer.Add(self.reset_qrange) 123 sizer.Add(self.qmin) 124 sizer.Add(self.qmax) 125 126 sizer.Add(self.btEditMask) 127 boxsizer_range.Add(sizer_chi2) 128 boxsizer_range.Add((10, 10)) 129 boxsizer_range.Add(sizer) 130 131 boxsizer_range.Add((10, 15)) 132 boxsizer_range.Add(sizer_fit) 133 if is_2Ddata: 134 self.btEditMask.Enable() 135 self.EditMask_title.Enable() 40 self.data_box_description = wx.StaticBox(self, -1, 'I(q) Data Source') 41 if check_data_validity(self.data): 42 dname_color = wx.BLUE 136 43 else: 137 self.btEditMask.Disable() 138 self.EditMask_title.Disable() 139 140 ## save state 141 #self.save_current_state() 142 143 self.sizer5.Add(boxsizer_range, 0, wx.EXPAND | wx.ALL, 10) 144 self.sizer5.Layout() 145 146 def _on_select_model(self, event=None): 147 """ 148 call back for model selection 149 """ 150 151 self.Show(False) 152 self._on_select_model_helper() 153 self.set_model_param_sizer(self.model) 154 if self.model is None: 155 self._set_bookmark_flag(False) 156 self._keep.Enable(False) 157 self._set_save_flag(False) 158 self.enable_disp.SetValue(False) 159 self.disable_disp.SetValue(True) 160 try: 161 self.set_dispers_sizer() 162 except: 163 pass 164 self.state.structurecombobox = self.structurebox.GetCurrentSelection() 165 self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection() 166 167 if self.model != None: 168 self._set_copy_flag(True) 169 self._set_paste_flag(True) 170 if self.data != None: 171 self._set_bookmark_flag(False) 172 self._keep.Enable(False) 173 174 temp_smear = None 175 ## event to post model to fit to fitting plugins 176 (ModelEventbox, _) = wx.lib.newevent.NewEvent() 177 178 ## set smearing value whether or not 179 # the data contain the smearing info 180 evt = ModelEventbox(model=self.model, 181 smearer=temp_smear, 182 qmin=float(self.qmin_x), 183 uid=self.uid, 184 qmax=float(self.qmax_x)) 185 186 self._manager._on_model_panel(evt=evt) 187 self.mbox_description.SetLabel("Model [%s]" % str(self.model.name)) 188 self.state.model = self.model.clone() 189 self.state.model.name = self.model.name 190 191 192 if event != None: 193 ## post state to fit panel 194 new_event = PageInfoEvent(page = self) 195 wx.PostEvent(self.parent, new_event) 196 #update list of plugins if new plugin is available 197 if self.plugin_rbutton.GetValue(): 198 temp = self.parent.update_model_list() 199 if temp: 200 self.model_list_box = temp 201 current_val = self.formfactorbox.GetValue() 202 pos = self.formfactorbox.GetSelection() 203 self._show_combox_helper() 204 self.formfactorbox.SetSelection(pos) 205 self.formfactorbox.SetValue(current_val) 206 self._onDraw(event=None) 207 else: 208 self._draw_model() 209 self.SetupScrolling() 210 self.Show(True) 211 212 def _update_paramv_on_fit(self): 213 """ 214 make sure that update param values just before the fitting 215 """ 216 #flag for qmin qmax check values 217 flag = True 218 self.fitrange = True 219 is_modified = False 220 221 if self.model != None: 222 ##Check the values 223 self._check_value_enter( self.fittable_param, is_modified) 224 self._check_value_enter( self.fixed_param, is_modified) 225 self._check_value_enter( self.parameters, is_modified) 226 227 # If qmin and qmax have been modified, update qmin and qmax and 228 # Here we should check whether the boundaries have been modified. 229 # If qmin and qmax have been modified, update qmin and qmax and 230 # set the is_modified flag to True 231 self.fitrange = self._validate_qrange(self.qmin, self.qmax) 232 if self.fitrange: 233 tempmin = float(self.qmin.GetValue()) 234 if tempmin != self.qmin_x: 235 self.qmin_x = tempmin 236 tempmax = float(self.qmax.GetValue()) 237 if tempmax != self.qmax_x: 238 self.qmax_x = tempmax 239 if tempmax == tempmin: 240 flag = False 241 #temp_smearer = None 242 if self._is_2D(): 243 # only 2D case set mask 244 flag = self._validate_Npts() 245 if not flag: 246 return flag 247 else: flag = False 248 else: 249 flag = False 250 251 #For invalid q range, disable the mask editor and fit button, vs. 252 if not self.fitrange: 253 #self.btFit.Disable() 254 if self._is_2D(): 255 self.btEditMask.Disable() 256 else: 257 #self.btFit.Enable(True) 258 if self._is_2D() and self.data != None: 259 self.btEditMask.Enable(True) 260 261 if not flag: 262 msg = "Cannot Plot or Fit :Must select a " 263 msg += " model or Fitting range is not valid!!! " 264 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 265 266 self.save_current_state() 267 268 return flag 269 def save_current_state(self): 270 """ 271 Currently no save option implemented for batch page 272 """ 273 pass 274 def save_current_state_fit(self): 275 """ 276 Currently no save option implemented for batch page 277 """ 278 pass 279 def set_data(self, data): 280 """ 281 reset the current data 282 """ 283 #id = None 284 group_id = None 285 flag = False 286 if self.data is None and data is not None: 287 flag = True 288 if data is not None: 289 #id = data.id 290 group_id = data.group_id 291 if self.data is not None: 292 flag = (data.id != self.data.id) 293 self.data = data 294 if self.data is None: 295 data_min = "" 296 data_max = "" 297 data_name = "" 298 self._set_bookmark_flag(False) 299 self._keep.Enable(False) 300 self._set_save_flag(False) 301 else: 302 if self.model != None: 303 self._set_bookmark_flag(False) 304 self._keep.Enable(False) 305 self._set_save_flag(False) 306 self._set_preview_flag(True) 307 308 self.formfactorbox.Enable() 309 self.structurebox.Enable() 310 data_name = self.data.name 311 #set maximum range for x in linear scale 312 if not hasattr(self.data,"data"): #Display only for 1D data fit 313 # Minimum value of data 314 data_min = min(self.data.x) 315 # Maximum value of data 316 data_max = max(self.data.x) 317 self.btEditMask.Disable() 318 self.EditMask_title.Disable() 319 else: 320 321 ## Minimum value of data 322 data_min = 0 323 x = max(math.fabs(self.data.xmin), math.fabs(self.data.xmax)) 324 y = max(math.fabs(self.data.ymin), math.fabs(self.data.ymax)) 325 ## Maximum value of data 326 data_max = math.sqrt(x*x + y*y) 327 self.btEditMask.Enable() 328 self.EditMask_title.Enable() 329 330 self.dataSource.SetValue(data_name) 331 self.qmin_x = data_min 332 self.qmax_x = data_max 333 #self.minimum_q.SetValue(str(data_min)) 334 #self.maximum_q.SetValue(str(data_max)) 335 self.qmin.SetValue(str(data_min)) 336 self.qmax.SetValue(str(data_max)) 337 self.qmin.SetBackgroundColour("white") 338 self.qmax.SetBackgroundColour("white") 339 self.state.data = data 340 self.state.qmin = self.qmin_x 341 self.state.qmax = self.qmax_x 342 343 #update model plot with new data information 344 if flag: 345 #set model view button 346 if self.data.__class__.__name__ == "Data2D": 347 self.enable2D = True 348 self.model_view.SetLabel("2D Mode") 349 else: 350 self.enable2D = False 351 self.model_view.SetLabel("1D Mode") 352 353 self.model_view.Disable() 354 355 wx.PostEvent(self._manager.parent, 356 NewPlotEvent(group_id=group_id, 357 action="delete")) 358 #plot the current selected data 359 wx.PostEvent(self._manager.parent, NewPlotEvent(plot=self.data, 360 title=str(self.data.title))) 361 self._manager.store_data(uid=self.uid, data=data, 362 data_list=self.data_list, 363 caption=self.window_name) 364 self._draw_model() 44 dname_color = wx.RED 45 self.data_box_description.SetForegroundColour(dname_color) 46 boxsizer1 = wx.StaticBoxSizer(self.data_box_description, wx.VERTICAL) 47 #---------------------------------------------------------- 48 sizer_data = wx.BoxSizer(wx.VERTICAL) 49 text1 = wx.StaticText(self, -1, ' - Choose a file to set initial fit parameters -') 50 text1.SetForegroundColour(wx.RED) 51 sizer_data.Add(text1) 52 text2 = wx.StaticText(self, -1, ' - This panel is not designed to view individual fits. - ') 53 text2.SetForegroundColour(wx.RED) 54 sizer_data.Add(text2) 55 56 combo = wx.BoxSizer(wx.HORIZONTAL) 57 self.dataSource = wx.ComboBox(self, -1, style=wx.CB_READONLY) 58 wx.EVT_COMBOBOX(self.dataSource, -1, self.on_select_data) 59 self.dataSource.SetMinSize((_DATA_BOX_WIDTH, -1)) 60 61 combo.Add(wx.StaticText(self, -1, 'Name : ')) 62 combo.Add((0,5)) 63 combo.Add(self.dataSource) 64 65 sizer_data.Add(combo, 0, wx.ALL, 10) 66 boxsizer1.Add(sizer_data, 0, wx.ALL, 0) 67 self.sizer0.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 68 self.sizer0.Layout() 69 70 # COMMENTED OUT TO USE METHODS INHERITED FROM fitpage.py 71 72 # def _fill_range_sizer(self): 73 # """ 74 # Fill the sizer containing the plotting range 75 # add access to npts 76 # """ 77 # is_2Ddata = False 78 # 79 # # Check if data is 2D 80 # if self.data.__class__.__name__ == "Data2D" or \ 81 # self.enable2D: 82 # is_2Ddata = True 83 # 84 # title = "Fitting" 85 # self._get_smear_info() 86 # 87 # #Sizers 88 # box_description_range = wx.StaticBox(self, -1, str(title)) 89 # boxsizer_range = wx.StaticBoxSizer(box_description_range, wx.VERTICAL) 90 # self.sizer_set_smearer = wx.BoxSizer(wx.VERTICAL) 91 # #sizer_smearer = wx.BoxSizer(wx.HORIZONTAL) 92 # self.sizer_new_smear = wx.BoxSizer(wx.HORIZONTAL) 93 # self.sizer_set_masking = wx.BoxSizer(wx.HORIZONTAL) 94 # sizer_chi2 = wx.BoxSizer(wx.VERTICAL) 95 # 96 # sizer_fit = wx.GridSizer(2, 4, 2, 6) 97 # #Fit button 98 # self.btFit = wx.Button(self, wx.NewId(), 'Fit', size=(88, 25)) 99 # self.default_bt_colour = self.btFit.GetDefaultAttributes() 100 # self.btFit.Bind(wx.EVT_BUTTON, self._onFit, id= self.btFit.GetId()) 101 # self.btFit.SetToolTipString("Start fitting.") 102 # 103 # # Update and Draw button 104 # self.draw_button = wx.Button(self, wx.NewId(), 'Compute', size=(88, 24)) 105 # self.draw_button.Bind(wx.EVT_BUTTON, \ 106 # self._onDraw,id=self.draw_button.GetId()) 107 # self.draw_button.SetToolTipString("Compute and Draw.") 108 # sizer_fit.Add(self.draw_button, 0, 0) 109 # sizer_fit.Add(self.btFit, 0, 0) 110 # sizer_chi2.Add((-1, 5)) 111 # # get smear_selection 112 # self.current_smearer = smear_selection( self.data, self.model ) 113 # boxsizer_range.Add(self.sizer_set_masking) 114 # #2D data? default 115 # is_2Ddata = False 116 # 117 # #check if it is 2D data 118 # if self.data.__class__.__name__ == "Data2D" or \ 119 # self.enable2D: 120 # is_2Ddata = True 121 # 122 # self.sizer5.Clear(True) 123 # 124 # self.qmin = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 125 # style=wx.TE_PROCESS_ENTER, 126 # text_enter_callback = self._onQrangeEnter) 127 # self.qmin.SetValue(str(self.qmin_x)) 128 # self.qmin.SetToolTipString("Minimun value of Q in linear scale.") 129 # 130 # self.qmax = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 131 # style=wx.TE_PROCESS_ENTER, 132 # text_enter_callback=self._onQrangeEnter) 133 # self.qmax.SetValue(str(self.qmax_x)) 134 # self.qmax.SetToolTipString("Maximum value of Q in linear scale.") 135 # 136 # id = wx.NewId() 137 # self.reset_qrange =wx.Button(self, id, 'Reset', size=(77, 20)) 138 # 139 # self.reset_qrange.Bind(wx.EVT_BUTTON, self.on_reset_clicked, id=id) 140 # self.reset_qrange.SetToolTipString(\ 141 # "Reset Q range to the default values") 142 # 143 # sizer_horizontal = wx.BoxSizer(wx.HORIZONTAL) 144 # sizer = wx.GridSizer(2, 4, 2, 6) 145 # 146 # self.btEditMask = wx.Button(self, wx.NewId(),'Editor', size=(88, 23)) 147 # self.btEditMask.Bind(wx.EVT_BUTTON, 148 # self._onMask,id=self.btEditMask.GetId()) 149 # self.btEditMask.SetToolTipString("Edit Mask.") 150 # self.EditMask_title = wx.StaticText(self, -1, ' Masking(2D)') 151 # 152 # sizer.Add(wx.StaticText(self, -1, 'Q range')) 153 # sizer.Add(wx.StaticText(self, -1, ' Min[1/A]')) 154 # sizer.Add(wx.StaticText(self, -1, ' Max[1/A]')) 155 # sizer.Add(self.EditMask_title) 156 # 157 # sizer.Add(self.reset_qrange) 158 # sizer.Add(self.qmin) 159 # sizer.Add(self.qmax) 160 # 161 # sizer.Add(self.btEditMask) 162 # boxsizer_range.Add(sizer_chi2) 163 # boxsizer_range.Add((10, 10)) 164 # boxsizer_range.Add(sizer) 165 # 166 # boxsizer_range.Add((10, 15)) 167 # boxsizer_range.Add(sizer_fit) 168 # if is_2Ddata: 169 # self.btEditMask.Enable() 170 # self.EditMask_title.Enable() 171 # else: 172 # self.btEditMask.Disable() 173 # self.EditMask_title.Disable() 174 # 175 # ## save state 176 # #self.save_current_state() 177 # 178 # self.sizer5.Add(boxsizer_range, 0, wx.EXPAND | wx.ALL, 10) 179 # self.sizer5.Layout() 180 # 181 # def _on_select_model(self, event=None): 182 # """ 183 # call back for model selection 184 # """ 185 # 186 # self.Show(False) 187 # self._on_select_model_helper() 188 # self.set_model_param_sizer(self.model) 189 # if self.model is None: 190 # self._set_bookmark_flag(False) 191 # self._keep.Enable(False) 192 # self._set_save_flag(False) 193 # self.enable_disp.SetValue(False) 194 # self.disable_disp.SetValue(True) 195 # try: 196 # self.set_dispers_sizer() 197 # except: 198 # pass 199 # self.state.structurecombobox = self.structurebox.GetCurrentSelection() 200 # self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection() 201 # 202 # if self.model != None: 203 # self._set_copy_flag(True) 204 # self._set_paste_flag(True) 205 # if self.data != None: 206 # self._set_bookmark_flag(False) 207 # self._keep.Enable(False) 208 # 209 # temp_smear = None 210 # ## event to post model to fit to fitting plugins 211 # (ModelEventbox, _) = wx.lib.newevent.NewEvent() 212 # 213 # ## set smearing value whether or not 214 # # the data contain the smearing info 215 # evt = ModelEventbox(model=self.model, 216 # smearer=temp_smear, 217 # qmin=float(self.qmin_x), 218 # uid=self.uid, 219 # qmax=float(self.qmax_x)) 220 # 221 # self._manager._on_model_panel(evt=evt) 222 # self.mbox_description.SetLabel("Model [%s]" % str(self.model.name)) 223 # self.state.model = self.model.clone() 224 # self.state.model.name = self.model.name 225 # 226 # 227 # if event != None: 228 # ## post state to fit panel 229 # new_event = PageInfoEvent(page = self) 230 # wx.PostEvent(self.parent, new_event) 231 # #update list of plugins if new plugin is available 232 # if self.plugin_rbutton.GetValue(): 233 # temp = self.parent.update_model_list() 234 # if temp: 235 # self.model_list_box = temp 236 # current_val = self.formfactorbox.GetValue() 237 # pos = self.formfactorbox.GetSelection() 238 # self._show_combox_helper() 239 # self.formfactorbox.SetSelection(pos) 240 # self.formfactorbox.SetValue(current_val) 241 # self._onDraw(event=None) 242 # else: 243 # self._draw_model() 244 # self.SetupScrolling() 245 # self.Show(True) 246 # 247 # def _update_paramv_on_fit(self): 248 # """ 249 # make sure that update param values just before the fitting 250 # """ 251 # #flag for qmin qmax check values 252 # flag = True 253 # self.fitrange = True 254 # is_modified = False 255 # 256 # if self.model != None: 257 # ##Check the values 258 # self._check_value_enter( self.fittable_param, is_modified) 259 # self._check_value_enter( self.fixed_param, is_modified) 260 # self._check_value_enter( self.parameters, is_modified) 261 # 262 # # If qmin and qmax have been modified, update qmin and qmax and 263 # # Here we should check whether the boundaries have been modified. 264 # # If qmin and qmax have been modified, update qmin and qmax and 265 # # set the is_modified flag to True 266 # self.fitrange = self._validate_qrange(self.qmin, self.qmax) 267 # if self.fitrange: 268 # tempmin = float(self.qmin.GetValue()) 269 # if tempmin != self.qmin_x: 270 # self.qmin_x = tempmin 271 # tempmax = float(self.qmax.GetValue()) 272 # if tempmax != self.qmax_x: 273 # self.qmax_x = tempmax 274 # if tempmax == tempmin: 275 # flag = False 276 # #temp_smearer = None 277 # if self._is_2D(): 278 # # only 2D case set mask 279 # flag = self._validate_Npts() 280 # if not flag: 281 # return flag 282 # else: flag = False 283 # else: 284 # flag = False 285 # 286 # #For invalid q range, disable the mask editor and fit button, vs. 287 # if not self.fitrange: 288 # #self.btFit.Disable() 289 # if self._is_2D(): 290 # self.btEditMask.Disable() 291 # else: 292 # #self.btFit.Enable(True) 293 # if self._is_2D() and self.data != None: 294 # self.btEditMask.Enable(True) 295 # 296 # if not flag: 297 # msg = "Cannot Plot or Fit :Must select a " 298 # msg += " model or Fitting range is not valid!!! " 299 # wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 300 # 301 # self.save_current_state() 302 # 303 # return flag 304 # def save_current_state(self): 305 # """ 306 # Currently no save option implemented for batch page 307 # """ 308 # pass 309 # def save_current_state_fit(self): 310 # """ 311 # Currently no save option implemented for batch page 312 # """ 313 # pass 314 # def set_data(self, data): 315 # """ 316 # reset the current data 317 # """ 318 # #id = None 319 # group_id = None 320 # flag = False 321 # if self.data is None and data is not None: 322 # flag = True 323 # if data is not None: 324 # #id = data.id 325 # group_id = data.group_id 326 # if self.data is not None: 327 # flag = (data.id != self.data.id) 328 # self.data = data 329 # if self.data is None: 330 # data_min = "" 331 # data_max = "" 332 # data_name = "" 333 # self._set_bookmark_flag(False) 334 # self._keep.Enable(False) 335 # self._set_save_flag(False) 336 # else: 337 # if self.model != None: 338 # self._set_bookmark_flag(False) 339 # self._keep.Enable(False) 340 # self._set_save_flag(False) 341 # self._set_preview_flag(True) 342 # 343 # self.formfactorbox.Enable() 344 # self.structurebox.Enable() 345 # data_name = self.data.name 346 # #set maximum range for x in linear scale 347 # if not hasattr(self.data,"data"): #Display only for 1D data fit 348 # # Minimum value of data 349 # data_min = min(self.data.x) 350 # # Maximum value of data 351 # data_max = max(self.data.x) 352 # self.btEditMask.Disable() 353 # self.EditMask_title.Disable() 354 # else: 355 # 356 # ## Minimum value of data 357 # data_min = 0 358 # x = max(math.fabs(self.data.xmin), math.fabs(self.data.xmax)) 359 # y = max(math.fabs(self.data.ymin), math.fabs(self.data.ymax)) 360 # ## Maximum value of data 361 # data_max = math.sqrt(x*x + y*y) 362 # self.btEditMask.Enable() 363 # self.EditMask_title.Enable() 364 # 365 # self.dataSource.SetValue(data_name) 366 # self.qmin_x = data_min 367 # self.qmax_x = data_max 368 # #self.minimum_q.SetValue(str(data_min)) 369 # #self.maximum_q.SetValue(str(data_max)) 370 # self.qmin.SetValue(str(data_min)) 371 # self.qmax.SetValue(str(data_max)) 372 # self.qmin.SetBackgroundColour("white") 373 # self.qmax.SetBackgroundColour("white") 374 # self.state.data = data 375 # self.state.qmin = self.qmin_x 376 # self.state.qmax = self.qmax_x 377 # 378 # #update model plot with new data information 379 # if flag: 380 # #set model view button 381 # if self.data.__class__.__name__ == "Data2D": 382 # self.enable2D = True 383 # self.model_view.SetLabel("2D Mode") 384 # else: 385 # self.enable2D = False 386 # self.model_view.SetLabel("1D Mode") 387 # 388 # self.model_view.Disable() 389 # 390 # wx.PostEvent(self._manager.parent, 391 # NewPlotEvent(group_id=group_id, 392 # action="delete")) 393 # #plot the current selected data 394 # wx.PostEvent(self._manager.parent, NewPlotEvent(plot=self.data, 395 # title=str(self.data.title))) 396 # self._manager.store_data(uid=self.uid, data=data, 397 # data_list=self.data_list, 398 # caption=self.window_name) 399 # self._draw_model() 365 400 366 401 -
src/sas/perspectives/fitting/fitpanel.py
r79492222 rfa09d62 371 371 """ 372 372 from fitpage import FitPage 373 panel = FitPage(parent=self)373 from batchfitpage import BatchFitPage 374 374 if self.batch_on: 375 panel = BatchFitPage(parent=self) 375 376 self.batch_page_index += 1 376 377 caption = "BatchPage" + str(self.batch_page_index) … … 378 379 else: 379 380 #Increment index of fit page 381 panel = FitPage(parent=self) 380 382 self.fit_page_index += 1 381 383 caption = "FitPage" + str(self.fit_page_index) … … 467 469 if data_1d_list and data_2d_list: 468 470 # need to warning the user that this batch is a special case 469 from sas import BatchDataDialog471 from sas.perspectives.fitting.fitting_widgets import BatchDataDialog 470 472 dlg = BatchDataDialog(self) 471 473 if dlg.ShowModal() == wx.ID_OK: -
src/sas/perspectives/fitting/report_dialog.py
r4ec242e re8bb5b6 14 14 15 15 import wx 16 import sys17 16 import os 18 17 import wx.html as html 19 import logging20 18 21 _STATICBOX_WIDTH = 480 22 PANEL_WIDTH = 530 23 PANEL_HEIGHT = 700 24 FONT_VARIANT = 1 25 ISMAC = False 26 ISPDF = False 27 if sys.platform == "win32": 28 _STATICBOX_WIDTH = 450 29 PANEL_WIDTH = 500 30 PANEL_HEIGHT = 700 31 FONT_VARIANT = 0 32 ISMAC = False 33 ISPDF = True 34 elif sys.platform == "darwin": 35 ISMAC = True 36 ISPDF = True 19 from sas.guiframe.report_dialog import BaseReportDialog 37 20 38 39 class ReportDialog(wx.Dialog): 21 class ReportDialog(BaseReportDialog): 40 22 """ 41 23 The report dialog box. 42 24 """ 43 25 44 def __init__(self, list, *args, **kwds):26 def __init__(self, report_list, *args, **kwds): 45 27 """ 46 28 Initialization. The parameters added to Dialog are: 47 29 48 :param list: report_list (list of html_str, text_str, image)30 :param report_list: list of html_str, text_str, image 49 31 from invariant_state 50 32 """ 51 kwds["style"] = wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE 52 wx.Dialog.__init__(self, *args, **kwds) 53 kwds["image"] = 'Dynamic Image' 33 super(ReportDialog, self).__init__(report_list, *args, **kwds) 34 54 35 # title 55 36 self.SetTitle("Report: Fitting") 56 # size 57 self.SetSize((720, 650)) 58 # font size 59 self.SetWindowVariant(variant=FONT_VARIANT) 60 # check if tit is MAC 61 self.is_pdf = ISPDF 62 # report string 63 self.report_list = list 37 64 38 # number of images of plot 65 self.nimages = len( list[2])39 self.nimages = len(self.report_list[2]) 66 40 67 if list[2] != None:41 if self.report_list[2] != None: 68 42 # put image path in the report string 69 if len( list[2]) == 1:43 if len(self.report_list[2]) == 1: 70 44 self.report_html = self.report_list[0] % \ 71 45 "memory:img_fit0.png" 72 elif len( list[2]) == 2:46 elif len(self.report_list) == 2: 73 47 self.report_html = self.report_list[0] % \ 74 48 ("memory:img_fit0.png", … … 85 59 self._setup_layout() 86 60 87 def _setup_layout(self):88 """89 Set up layout90 """91 hbox = wx.BoxSizer(wx.HORIZONTAL)92 93 # buttons94 id = wx.ID_OK95 button_close = wx.Button(self, id, "Close")96 button_close.SetToolTipString("Close this report window.")97 #hbox.Add((5,10), 1 , wx.EXPAND|wx.ADJUST_MINSIZE,0)98 hbox.Add(button_close)99 button_close.SetFocus()100 101 id = wx.NewId()102 button_preview = wx.Button(self, id, "Preview")103 button_preview.SetToolTipString("Print preview this report.")104 button_preview.Bind(wx.EVT_BUTTON, self.onPreview,105 id=button_preview.GetId())106 hbox.Add(button_preview)107 108 id = wx.NewId()109 button_print = wx.Button(self, id, "Print")110 button_print.SetToolTipString("Print this report.")111 button_print.Bind(wx.EVT_BUTTON, self.onPrint,112 id=button_print.GetId())113 hbox.Add(button_print)114 115 id = wx.NewId()116 button_save = wx.Button(self, id, "Save")117 button_save.SetToolTipString("Save this report.")118 button_save.Bind(wx.EVT_BUTTON, self.onSave, id=button_save.GetId())119 hbox.Add(button_save)120 121 # panel for report page122 #panel = wx.Panel(self, -1)123 vbox = wx.BoxSizer(wx.VERTICAL)124 # html window125 self.hwindow = html.HtmlWindow(self, style=wx.BORDER)126 # set the html page with the report string127 self.hwindow.SetPage(self.report_html)128 129 # add panels to boxsizers130 vbox.Add(hbox)131 vbox.Add(self.hwindow, 1, wx.EXPAND|wx.ALL,0)132 133 self.SetSizer(vbox)134 self.Centre()135 self.Show(True)136 137 61 def onSave(self, event=None): 138 62 """ 139 63 Save 140 64 """ 141 # pdf supporting only on MAC, not on exe142 if self.is_pdf:143 wild_card = ' PDF files (*.pdf)|*.pdf|'144 ind_cor = 0145 else:146 wild_card = ''147 ind_cor = 1148 wild_card += 'HTML files (*.html)|*.html|'149 wild_card += 'Text files (*.txt)|*.txt'150 151 65 #todo: complete saving fig file and as a txt file 152 66 dlg = wx.FileDialog(self, "Choose a file", 153 wildcard= wild_card,67 wildcard=self.wild_card, 154 68 style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) 155 69 dlg.SetFilterIndex(0) # Set .html files to be default … … 166 80 pic_fname = [] 167 81 #PDF 168 if ext_num == (0 + 2 * ind_cor):82 if ext_num == (0 + 2 * self.index_offset): 169 83 # TODO: Sort this case out 170 84 ext = '.pdf' … … 216 130 return 217 131 #HTML + png(graph) 218 elif ext_num == (1 - ind_cor):132 elif ext_num == (1 - self.index_offset): 219 133 ext = '.html' 220 134 for num in range(self.nimages): … … 222 136 report_frame = self.report_list[0] 223 137 #TEXT + pdf(graph) 224 elif ext_num == (2 - ind_cor):138 elif ext_num == (2 - self.index_offset): 225 139 ext = '.txt' 226 140 # changing the image extension actually changes the image … … 241 155 pic_fname.append(pic_name) 242 156 #put the image path in html string 243 if ext_num == (1 - ind_cor):157 if ext_num == (1 - self.index_offset): 244 158 if self.nimages == 1: 245 159 report = report_frame % os.path.basename(pic_fname[0]) … … 259 173 self.report_list[2][num].savefig(pic_fname[num]) 260 174 261 def onPreview(self, event=None):262 """263 Preview264 265 : event: Preview button event266 """267 previewh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)268 previewh.PreviewText(self.report_html)269 if event is not None:270 event.Skip()271 self.Update()272 273 def onPrint(self, event=None):274 """275 Print276 277 : event: Print button event278 """279 printh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)280 printh.PrintText(self.report_html)281 if event is not None:282 event.Skip()283 self.Update()284 285 def OnClose(self, event=None):286 """287 Close the Dialog288 289 : event: Close button event290 """291 self.Close()292 # Reset memory293 #wx.MemoryFSHandler()294 if event is not None:295 event.Skip()296 297 def HTML2PDF(self, data, filename):298 """299 Create a PDF file from html source string.300 Returns True is the file creation was successful.301 302 : data: html string303 : filename: name of file to be saved304 """305 try:306 from xhtml2pdf import pisa307 # open output file for writing (truncated binary)308 resultFile = open(filename, "w+b")309 # convert HTML to PDF310 pisaStatus = pisa.CreatePDF(data, dest=resultFile)311 # close output file312 resultFile.close()313 self.Update()314 return pisaStatus.err315 except:316 logging.error("Error creating pdf: %s" % sys.exc_value)317 return False -
src/sas/perspectives/invariant/report_dialog.py
r4ec242e re8bb5b6 15 15 """ 16 16 import wx 17 import sys18 17 import os 19 18 import wx.html as html 20 import logging 21 ISPDF = False 22 if sys.platform == "win32": 23 _STATICBOX_WIDTH = 450 24 PANEL_WIDTH = 500 25 PANEL_HEIGHT = 700 26 FONT_VARIANT = 0 27 ISMAC = False 28 ISPDF = True 29 elif sys.platform == "darwin": 30 _STATICBOX_WIDTH = 480 31 PANEL_WIDTH = 530 32 PANEL_HEIGHT = 700 33 FONT_VARIANT = 1 34 ISMAC = True 35 ISPDF = True 36 37 class ReportDialog(wx.Dialog): 19 20 from sas.guiframe.report_dialog import BaseReportDialog 21 22 class ReportDialog(BaseReportDialog): 38 23 """ 39 24 The report dialog box. 40 25 """ 41 26 42 def __init__(self, list, *args, **kwds):27 def __init__(self, report_list, *args, **kwds): 43 28 """ 44 29 Initialization. The parameters added to Dialog are: 45 30 46 :param list: report_list (list of html_str, text_str, image)31 :param report_list: list of html_str, text_str, image 47 32 from invariant_state 48 33 """ 49 kwds["style"] = wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE 50 wx.Dialog.__init__(self, *args, **kwds) 51 kwds["image"] = 'Dynamic Image' 34 super(ReportDialog, self).__init__(report_list, *args, **kwds) 35 52 36 # title 53 37 self.SetTitle("Report: Invariant computaion") 54 # size55 self.SetSize((720, 650))56 # font size57 self.SetWindowVariant(variant=FONT_VARIANT)58 38 59 # check if tit is MAC60 self.is_pdf = ISPDF61 62 # report string63 self.report_list = list64 39 # put image path in the report string 65 40 self.report_html = self.report_list[0] % "memory:img_inv.png" 66 41 # layout 67 42 self._setup_layout() 68 # wild card69 # pdf supporting only on MAC70 if self.is_pdf:71 self.wild_card = ' PDF files (*.pdf)|*.pdf|'72 else:73 self.wild_card = ''74 self.wild_card += 'HTML files (*.html)|*.html|'75 self.wild_card += 'Text files (*.txt)|*.txt'76 77 78 79 def _setup_layout(self):80 """81 Set up layout82 """83 hbox = wx.BoxSizer(wx.HORIZONTAL)84 85 # buttons86 id = wx.ID_OK87 button_close = wx.Button(self, id, "Close")88 button_close.SetToolTipString("Close this report window.")89 #hbox.Add((5,10), 1 , wx.EXPAND|wx.ADJUST_MINSIZE,0)90 hbox.Add(button_close)91 button_close.SetFocus()92 93 id = wx.NewId()94 button_preview = wx.Button(self, id, "Preview")95 button_preview.SetToolTipString("Print preview this report.")96 button_preview.Bind(wx.EVT_BUTTON, self.onPreview,97 id=button_preview.GetId())98 hbox.Add(button_preview)99 100 id = wx.NewId()101 button_print = wx.Button(self, id, "Print")102 button_print.SetToolTipString("Print this report.")103 button_print.Bind(wx.EVT_BUTTON, self.onPrint,104 id=button_print.GetId())105 hbox.Add(button_print)106 107 id = wx.NewId()108 button_save = wx.Button(self, id, "Save" )109 button_save.SetToolTipString("Save this report.")110 button_save.Bind(wx.EVT_BUTTON, self.onSave, id = button_save.GetId())111 hbox.Add(button_save)112 113 # panel for report page114 #panel = wx.Panel(self, -1)115 vbox = wx.BoxSizer(wx.VERTICAL)116 # html window117 self.hwindow = html.HtmlWindow(self,style=wx.BORDER)118 # set the html page with the report string119 self.hwindow.SetPage(self.report_html)120 121 # add panels to boxsizers122 vbox.Add(hbox)123 vbox.Add(self.hwindow, 1, wx.EXPAND|wx.ALL,0)124 125 self.SetSizer(vbox)126 self.Centre()127 self.Show(True)128 129 43 130 44 def onSave(self, event=None): … … 144 58 fName = dlg.GetPath() 145 59 ext_num = dlg.GetFilterIndex() 146 # index correction147 if not self.is_pdf:148 ind_cor = 1149 else:150 ind_cor = 0151 60 #set file extensions 152 if ext_num == (0 + 2 * ind_cor):153 61 if ext_num == (0 + 2 * self.index_offset): 62 # TODO: Sort this case out 154 63 ext = '.pdf' 155 64 img_ext = '_img.png' … … 186 95 os.remove(pic_fname) 187 96 return 188 elif ext_num == (1 - ind_cor):97 elif ext_num == (1 - self.index_offset): 189 98 ext = '.html' 190 99 img_ext = '_img4html.png' 191 100 report_frame = self.report_list[0] 192 elif ext_num == (2 - ind_cor):101 elif ext_num == (2 - self.index_offset): 193 102 ext = '.txt' 194 103 # changing the image extension actually changes the image … … 205 114 pic_fname = os.path.splitext(fName)[0] + img_ext 206 115 #put the image path in html string 207 if ext_num == (1 - ind_cor):116 if ext_num == (1 - self.index_offset): 208 117 report = report_frame % os.path.basename(pic_fname) 209 118 … … 214 123 self.report_list[2].savefig(pic_fname) 215 124 216 217 def onPreview(self, event=None):218 """219 Preview220 221 : event: Preview button event222 """223 previewh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)224 previewh.PreviewText(self.report_html)225 if event is not None:226 event.Skip()227 228 def onPrint(self, event=None):229 """230 Print231 232 : event: Print button event233 """234 printh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)235 printh.PrintText(self.report_html)236 if event is not None:237 event.Skip()238 239 def OnClose(self,event=None):240 """241 Close the Dialog242 243 : event: Close button event244 """245 self.Close()246 247 def HTML2PDF(self, data, filename):248 """249 Create a PDF file from html source string.250 Returns True is the file creation was successful.251 252 : data: html string253 : filename: name of file to be saved254 """255 try:256 from xhtml2pdf import pisa257 # open output file for writing (truncated binary)258 resultFile = open(filename, "w+b")259 # convert HTML to PDF260 pisaStatus = pisa.CreatePDF(data, dest=resultFile)261 # close output file262 resultFile.close()263 self.Update()264 return pisaStatus.err265 except:266 logging.error("Error creating pdf: %s" % sys.exc_value)267 return False -
src/sas/perspectives/fitting/basepage.py
r4380c03 rc1694f8 26 26 from sas.perspectives.fitting.pagestate import PageState 27 27 from sas.guiframe.CategoryInstaller import CategoryInstaller 28 from sas.guiframe.documentation_window import DocumentationWindow 29 28 30 29 31 (PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() … … 2916 2918 return graphs, canvases 2917 2919 2918 def on_model_help_clicked(self, event): 2919 """ 2920 Function called when 'Details' button is pressed next to model 2921 of interest. As of Feb 2015 this function follows two paths: 2922 For regular models that ship with the release, it calls the Sphinx 2923 generated html documentation. For plugin models it still uses the 2924 old pop up window reading the description provided in the model. 2925 2926 This will presumably be deprecated when the sas mdels team decides 2927 on how to discover new models and grab their documentation from the 2928 file. 2929 2930 PDB 18 Feb 2015 2931 2932 :param evt: on Details Button pressed event 2933 """ 2934 from sas.perspectives.fitting.help_panel import HelpWindow 2935 from sas.models import get_data_path 2936 2937 # Get models help model_function path 2938 path = get_data_path(media='media') 2939 model_path = os.path.join(path, "model_functions.html") 2920 def on_function_help_clicked(self, event): 2921 """ 2922 Function called when 'Help' button is pressed next to model 2923 of interest. This calls DocumentationWindow from 2924 documentation_window.py. It will load the top level of the model 2925 help documenation sphinx generated html if no model is presented. 2926 If a model IS present then if documention for that model exists 2927 it will load to that point otherwise again it will go to the top. 2928 For Wx2.8 and below is used (i.e. non-released through installer) 2929 a browser is loaded and the top of the model documentation only is 2930 accessible because webbrowser module does not pass anything after 2931 the # to the browser. 2932 2933 :param evt: on Help Button pressed event 2934 """ 2935 2940 2936 if self.model == None: 2941 2937 name = 'index.html' 2942 2938 else: 2943 2939 name = self.formfactorbox.GetValue() 2944 frame = HelpWindow(None, -1, pageToOpen=model_path) 2945 #If model name exists and model is not a custom model 2946 #mod_cat = self.categorybox.GetStringSelection() 2947 if frame.rhelp.HasAnchor(name): 2948 frame.Show(True) 2949 frame.rhelp.ScrollToAnchor(name) 2940 2941 if self.model != None: 2942 _docspath='user/models/model_functions.html#' + name 2943 _doc_viewer = DocumentationWindow(self, -1, _docspath, name + "Help") 2950 2944 else: 2951 if self.model != None: 2952 frame.Destroy() 2953 msg = 'Model description:\n' 2954 if str(self.model.description).rstrip().lstrip() == '': 2955 msg += "Sorry, no information is available for this model." 2956 else: 2957 msg += self.model.description + '\n' 2958 info = "Info" 2959 wx.MessageBox(msg, info) 2945 _doc_viewer = DocumentationWindow(self, -1, "index.html", \ 2946 "General Help") 2947 2948 2949 def on_model_help_clicked(self, event): 2950 """ 2951 Function called when 'Description' button is pressed next to model 2952 of interest. This calls the Description embedded in the model. This 2953 should work with either Wx2.8 and lower or higher. If no model is 2954 selected it will give the message that a model must be chosen first 2955 in the box that would normally contain the description. If a badly 2956 behaved model is encountered which has no description then it will 2957 give the message that none is available. 2958 2959 :param evt: on Description Button pressed event 2960 """ 2961 2962 if self.model == None: 2963 name = 'index.html' 2964 else: 2965 name = self.formfactorbox.GetValue() 2966 2967 msg = 'Model description:\n' 2968 info = "Info" 2969 if self.model != None: 2970 # frame.Destroy() 2971 if str(self.model.description).rstrip().lstrip() == '': 2972 msg += "Sorry, no information is available for this model." 2960 2973 else: 2961 frame.Show(True) 2974 msg += self.model.description + '\n' 2975 wx.MessageBox(msg, info) 2976 else: 2977 msg += "You must select a model to get information on this" 2978 wx.MessageBox(msg, info) 2962 2979 2963 2980 def _on_mag_help(self, event): … … 2966 2983 is clicked. Calls DocumentationWindow with the path of the location 2967 2984 within the documentation tree (after /doc/ ....". When using old 2968 versions of Wx When(i.e. before 2.9 and therefore not part of release2985 versions of Wx (i.e. before 2.9 and therefore not part of release 2969 2986 versions distributed via installer) it brings up an image viewer 2970 2987 box which allows the user to click through the rest of the images in … … 2976 2993 :param evt: Triggers on clicking ? in Magnetic Angles? box 2977 2994 """ 2978 2979 from sas.guiframe.documentation_window import DocumentationWindow2980 2995 2981 2996 _TreeLocation = "_images/M_angles_pic.bmp" … … 3024 3039 :param evt: Triggers on clicking ? in polydispersity box 3025 3040 """ 3026 3027 from sas.guiframe.documentation_window import DocumentationWindow 3028 3041 3029 3042 _TreeLocation = "user/perspectives/fitting/fitting_help.html" 3030 3043 _TreeLocation += "#polydispersity-distributions" … … 3592 3605 self.mbox_description.SetForegroundColour(wx.RED) 3593 3606 id = wx.NewId() 3594 self.model_help = wx.Button(self, id, 'Details', size=(80, 23)) 3607 self.model_func = wx.Button(self, id, 'Help', size=(80, 23)) 3608 self.model_func.Bind(wx.EVT_BUTTON, self.on_function_help_clicked, id=id) 3609 self.model_func.SetToolTipString("Full Model Function Help") 3610 id = wx.NewId() 3611 self.model_help = wx.Button(self, id, 'Description', size=(80, 23)) 3595 3612 self.model_help.Bind(wx.EVT_BUTTON, self.on_model_help_clicked, id=id) 3596 self.model_help.SetToolTipString(" Model Function Help")3613 self.model_help.SetToolTipString("Short Model Function Description") 3597 3614 id = wx.NewId() 3598 3615 self.model_view = wx.Button(self, id, "Show 2D", size=(80, 23)) … … 3636 3653 3637 3654 sizer_radiobutton = wx.GridSizer(2, 2, 5, 5) 3655 3638 3656 3639 3657 #sizer_radiobutton.Add(self.shape_rbutton) 3640 3658 #sizer_radiobutton.Add(self.shape_indep_rbutton) 3641 3659 sizer_radiobutton.Add((5,5)) 3642 sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 15)3660 sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 5) 3643 3661 #sizer_radiobutton.Add(self.plugin_rbutton) 3644 3662 #sizer_radiobutton.Add(self.struct_rbutton) 3645 sizer_radiobutton.Add((5,5)) 3646 sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT, 15) 3663 # sizer_radiobutton.Add((5,5)) 3664 sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT|wx.LEFT, 5) 3665 # sizer_radiobutton.Add((5,5)) 3666 sizer_radiobutton.Add(self.model_func, 1, wx.RIGHT, 5) 3647 3667 sizer_cat.Add(sizer_cat_box, 1, wx.LEFT, 2.5) 3648 3668 sizer_cat.Add(sizer_radiobutton)
Note: See TracChangeset
for help on using the changeset viewer.