Changeset 0b477f6 in sasview for fittingview/src/sans/perspectives
- Timestamp:
- May 24, 2012 1:45:11 PM (13 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:
- 7b7ff27
- Parents:
- 0c24e98
- Location:
- fittingview/src/sans/perspectives/fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/basepage.py
r940aca7 r0b477f6 1 1 """ 2 Base Page for fitting 3 """ 2 4 import sys 3 5 import os … … 19 21 from sans.dataloader.data_info import Detector 20 22 from sans.dataloader.data_info import Source 21 import pagestate 22 from pagestate import PageState 23 from sans.perspectives.fitting.pagestate import PageState 23 24 24 25 (PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() … … 102 103 self.disp_cb_dict = {} 103 104 104 self.state = PageState(parent=parent)105 #self.state = PageState(parent=parent) 105 106 ## dictionary containing list of models 106 107 self.model_list_box = {} … … 780 781 self.onResetModel(event) 781 782 self._draw_model() 782 783 def old_on_bookmark(self, event): 784 """ 785 save history of the data and model 786 """ 787 if self.model == None: 788 msg = "Can not bookmark; Please select Data and Model first..." 789 wx.MessageBox(msg, 'Info') 790 return 791 if hasattr(self, "enable_disp"): 792 self.state.enable_disp = copy.deepcopy(self.enable_disp.GetValue()) 793 if hasattr(self, "disp_box"): 794 self.state.disp_box = copy.deepcopy(self.disp_box.GetSelection()) 795 796 self.state.model.name = self.model.name 797 798 #Remember fit engine_type for fit panel 799 if self.engine_type == None: 800 self.engine_type = "scipy" 801 if self._manager != None: 802 self._manager._on_change_engine(engine=self.engine_type) 803 804 self.state.engine_type = self.engine_type 805 806 new_state = self.state.clone() 807 new_state.model.name = self.state.model.name 808 809 new_state.enable2D = copy.deepcopy(self.enable2D) 810 ##Add model state on context menu 811 self.number_saved_state += 1 812 name = self.model.__class__.__name__ + "[%g]" % self.number_saved_state 813 self.saved_states[name] = new_state 814 815 ## Add item in the context menu 816 817 year, month, day, hour, minute, second, tda, ty, tm_isdst \ 818 = time.localtime() 819 my_time = str(hour) + " : " + str(minute) + " : " + str(second) + " " 820 date = str(month) + "|" + str(day) + "|" + str(year) 821 msg = "Model saved at %s on %s" % (my_time, date) 822 ## post help message for the selected model 823 msg += " Saved! right click on this page to retrieve this model" 824 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 825 826 id = wx.NewId() 827 self.popUpMenu.Append(id, name, str(msg)) 828 wx.EVT_MENU(self, id, self.onResetModel) 829 783 830 784 def onSetFocus(self, evt): 831 785 """ … … 1911 1865 source='model', 1912 1866 weight=weight) 1913 1867 1914 1868 def _on_show_sld(self, event=None): 1915 1869 """ … … 3294 3248 print "BasicPage.update_pinhole_smear was called: skipping" 3295 3249 return 3250 3251 def _fill_model_sizer(self, sizer): 3252 """ 3253 fill sizer containing model info 3254 """ 3255 ##Add model function Details button in fitpanel. 3256 ##The following 3 lines are for Mac. Let JHC know before modifying... 3257 title = "Model" 3258 self.formfactorbox = None 3259 self.multifactorbox = None 3260 self.mbox_description = wx.StaticBox(self, -1, str(title)) 3261 boxsizer1 = wx.StaticBoxSizer(self.mbox_description, wx.VERTICAL) 3262 self.mbox_description.SetForegroundColour(wx.RED) 3263 id = wx.NewId() 3264 self.model_help = wx.Button(self, id, 'Details', size=(80, 23)) 3265 self.model_help.Bind(wx.EVT_BUTTON, self.on_model_help_clicked, id=id) 3266 self.model_help.SetToolTipString("Model Function Help") 3267 id = wx.NewId() 3268 self.model_view = wx.Button(self, id, "Show 2D", size=(80, 23)) 3269 self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D, id=id) 3270 hint = "toggle view of model from 1D to 2D or 2D to 1D" 3271 self.model_view.SetToolTipString(hint) 3272 3273 self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes', 3274 style=wx.RB_GROUP) 3275 self.shape_indep_rbutton = wx.RadioButton(self, -1, 3276 "Shape-Independent") 3277 self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ") 3278 self.plugin_rbutton = wx.RadioButton(self, -1, "Customized Models") 3279 3280 self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 3281 id=self.shape_rbutton.GetId()) 3282 self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 3283 id=self.shape_indep_rbutton.GetId()) 3284 self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 3285 id=self.struct_rbutton.GetId()) 3286 self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 3287 id=self.plugin_rbutton.GetId()) 3288 #MAC needs SetValue 3289 self.shape_rbutton.SetValue(True) 3290 3291 sizer_radiobutton = wx.GridSizer(2, 3, 5, 5) 3292 sizer_radiobutton.Add(self.shape_rbutton) 3293 sizer_radiobutton.Add(self.shape_indep_rbutton) 3294 sizer_radiobutton.Add(self.model_view, 1, wx.LEFT, 20) 3295 sizer_radiobutton.Add(self.plugin_rbutton) 3296 sizer_radiobutton.Add(self.struct_rbutton) 3297 sizer_radiobutton.Add(self.model_help, 1, wx.LEFT, 20) 3298 3299 sizer_selection = wx.BoxSizer(wx.HORIZONTAL) 3300 mutifactor_selection = wx.BoxSizer(wx.HORIZONTAL) 3301 3302 self.text1 = wx.StaticText(self, -1, "") 3303 self.text2 = wx.StaticText(self, -1, "P(Q)*S(Q)") 3304 self.mutifactor_text = wx.StaticText(self, -1, "No. of Shells: ") 3305 self.mutifactor_text1 = wx.StaticText(self, -1, "") 3306 self.show_sld_button = wx.Button(self, -1, "Show SLD Profile") 3307 self.show_sld_button.Bind(wx.EVT_BUTTON, self._on_show_sld) 3308 3309 self.formfactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 3310 if self.model != None: 3311 self.formfactorbox.SetValue(self.model.name) 3312 self.structurebox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 3313 self.multifactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 3314 self.initialize_combox() 3315 wx.EVT_COMBOBOX(self.formfactorbox, -1, self._on_select_model) 3316 3317 wx.EVT_COMBOBOX(self.structurebox, -1, self._on_select_model) 3318 wx.EVT_COMBOBOX(self.multifactorbox, -1, self._on_select_model) 3319 ## check model type to show sizer 3320 if self.model != None: 3321 self._set_model_sizer_selection(self.model) 3322 3323 sizer_selection.Add(self.text1) 3324 sizer_selection.Add((5, 5)) 3325 sizer_selection.Add(self.formfactorbox) 3326 sizer_selection.Add((5, 5)) 3327 sizer_selection.Add(self.text2) 3328 sizer_selection.Add((5, 5)) 3329 sizer_selection.Add(self.structurebox) 3330 3331 mutifactor_selection.Add((10, 5)) 3332 mutifactor_selection.Add(self.mutifactor_text) 3333 mutifactor_selection.Add(self.multifactorbox) 3334 mutifactor_selection.Add((5, 5)) 3335 mutifactor_selection.Add(self.mutifactor_text1) 3336 mutifactor_selection.Add((10, 5)) 3337 mutifactor_selection.Add(self.show_sld_button) 3338 3339 boxsizer1.Add(sizer_radiobutton) 3340 boxsizer1.Add((10, 10)) 3341 boxsizer1.Add(sizer_selection) 3342 boxsizer1.Add((10, 10)) 3343 boxsizer1.Add(mutifactor_selection) 3344 3345 self._set_multfactor_combobox() 3346 self.multifactorbox.SetSelection(1) 3347 self.show_sld_button.Hide() 3348 sizer.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 3349 sizer.Layout() -
fittingview/src/sans/perspectives/fitting/fitpage.py
r940aca7 r0b477f6 554 554 self.sizer5.Layout() 555 555 556 def _fill_model_sizer(self, sizer):557 """558 fill sizer containing model info559 """560 ##Add model function Details button in fitpanel.561 ##The following 3 lines are for Mac. Let JHC know before modifying...562 title = "Model"563 self.formfactorbox = None564 self.multifactorbox = None565 self.mbox_description = wx.StaticBox(self, -1, str(title))566 boxsizer1 = wx.StaticBoxSizer(self.mbox_description, wx.VERTICAL)567 self.mbox_description.SetForegroundColour(wx.RED)568 id = wx.NewId()569 self.model_help = wx.Button(self, id, 'Details', size=(80, 23))570 self.model_help.Bind(wx.EVT_BUTTON, self.on_model_help_clicked, id=id)571 self.model_help.SetToolTipString("Model Function Help")572 id = wx.NewId()573 self.model_view = wx.Button(self, id, "Show 2D", size=(80, 23))574 self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D, id=id)575 hint = "toggle view of model from 1D to 2D or 2D to 1D"576 self.model_view.SetToolTipString(hint)577 578 self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes',579 style=wx.RB_GROUP)580 self.shape_indep_rbutton = wx.RadioButton(self, -1,581 "Shape-Independent")582 self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ")583 self.plugin_rbutton = wx.RadioButton(self, -1, "Customized Models")584 585 self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,586 id=self.shape_rbutton.GetId())587 self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,588 id=self.shape_indep_rbutton.GetId())589 self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,590 id=self.struct_rbutton.GetId())591 self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,592 id=self.plugin_rbutton.GetId())593 #MAC needs SetValue594 self.shape_rbutton.SetValue(True)595 596 sizer_radiobutton = wx.GridSizer(2, 3, 5, 5)597 sizer_radiobutton.Add(self.shape_rbutton)598 sizer_radiobutton.Add(self.shape_indep_rbutton)599 sizer_radiobutton.Add(self.model_view, 1, wx.LEFT, 20)600 sizer_radiobutton.Add(self.plugin_rbutton)601 sizer_radiobutton.Add(self.struct_rbutton)602 sizer_radiobutton.Add(self.model_help, 1, wx.LEFT, 20)603 604 sizer_selection = wx.BoxSizer(wx.HORIZONTAL)605 mutifactor_selection = wx.BoxSizer(wx.HORIZONTAL)606 607 self.text1 = wx.StaticText(self, -1, "")608 self.text2 = wx.StaticText(self, -1, "P(Q)*S(Q)")609 self.mutifactor_text = wx.StaticText(self, -1, "No. of Shells: ")610 self.mutifactor_text1 = wx.StaticText(self, -1, "")611 self.show_sld_button = wx.Button(self, -1, "Show SLD Profile")612 self.show_sld_button.Bind(wx.EVT_BUTTON, self._on_show_sld)613 614 self.formfactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY)615 if self.model != None:616 self.formfactorbox.SetValue(self.model.name)617 self.structurebox = wx.ComboBox(self, -1, style=wx.CB_READONLY)618 self.multifactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY)619 self.initialize_combox()620 wx.EVT_COMBOBOX(self.formfactorbox, -1, self._on_select_model)621 622 wx.EVT_COMBOBOX(self.structurebox, -1, self._on_select_model)623 wx.EVT_COMBOBOX(self.multifactorbox, -1, self._on_select_model)624 ## check model type to show sizer625 if self.model != None:626 self._set_model_sizer_selection(self.model)627 628 sizer_selection.Add(self.text1)629 sizer_selection.Add((5, 5))630 sizer_selection.Add(self.formfactorbox)631 sizer_selection.Add((5, 5))632 sizer_selection.Add(self.text2)633 sizer_selection.Add((5, 5))634 sizer_selection.Add(self.structurebox)635 636 mutifactor_selection.Add((10, 5))637 mutifactor_selection.Add(self.mutifactor_text)638 mutifactor_selection.Add(self.multifactorbox)639 mutifactor_selection.Add((5, 5))640 mutifactor_selection.Add(self.mutifactor_text1)641 mutifactor_selection.Add((10, 5))642 mutifactor_selection.Add(self.show_sld_button)643 644 boxsizer1.Add(sizer_radiobutton)645 boxsizer1.Add((10, 10))646 boxsizer1.Add(sizer_selection)647 boxsizer1.Add((10, 10))648 boxsizer1.Add(mutifactor_selection)649 650 self._set_multfactor_combobox()651 self.multifactorbox.SetSelection(1)652 self.show_sld_button.Hide()653 sizer.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10)654 sizer.Layout()655 556 656 557 def _set_sizer_dispersion(self):
Note: See TracChangeset
for help on using the changeset viewer.