Changeset a5701e6 in sasview for sansview/perspectives/fitting
- Timestamp:
- Mar 10, 2011 5:11:55 PM (14 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:
- c399004
- Parents:
- 7987962
- Location:
- sansview/perspectives/fitting
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r7987962 ra5701e6 1658 1658 enable2D=self.enable2D) 1659 1659 1660 def _set_model_sizer(self,sizer, box_sizer, title="", object=None):1661 """1662 Use lists to fill a sizer for model info1663 """1664 1665 sizer.Clear(True)1666 ##For MAC, this should defined here.1667 if box_sizer == None:1668 box_description= wx.StaticBox(self, -1,str(title))1669 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)1670 else:1671 boxsizer1 = box_sizer1672 sizer_buttons = wx.BoxSizer(wx.HORIZONTAL)1673 #--------------------------------------------------------1674 self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes', style=wx.RB_GROUP)1675 self.shape_indep_rbutton = wx.RadioButton(self, -1, "Shape-Independent")1676 self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ")1677 self.plugin_rbutton = wx.RadioButton(self, -1, "Customized Models")1678 1679 self.Bind( wx.EVT_RADIOBUTTON, self._show_combox,1680 id= self.shape_rbutton.GetId() )1681 self.Bind( wx.EVT_RADIOBUTTON, self._show_combox,1682 id= self.shape_indep_rbutton.GetId() )1683 self.Bind( wx.EVT_RADIOBUTTON, self._show_combox,1684 id= self.struct_rbutton.GetId() )1685 self.Bind( wx.EVT_RADIOBUTTON, self._show_combox,1686 id= self.plugin_rbutton.GetId() )1687 #MAC needs SetValue1688 self.shape_rbutton.SetValue(True)1689 1690 sizer_radiobutton = wx.GridSizer(2, 2,5, 5)1691 sizer_radiobutton.Add(self.shape_rbutton)1692 sizer_radiobutton.Add(self.shape_indep_rbutton)1693 1694 sizer_radiobutton.Add(self.plugin_rbutton)1695 sizer_radiobutton.Add(self.struct_rbutton)1696 sizer_buttons.Add(sizer_radiobutton)1697 # detail button1698 if object !=None:1699 sizer_buttons.Add((50,0))1700 sizer_buttons.Add(object)1701 1702 sizer_selection = wx.BoxSizer(wx.HORIZONTAL)1703 mutifactor_selection = wx.BoxSizer(wx.HORIZONTAL)1704 1705 self.text1 = wx.StaticText( self,-1,"" )1706 self.text2 = wx.StaticText( self,-1,"P(Q)*S(Q)" )1707 self.mutifactor_text = wx.StaticText( self,-1,"No. of Shells: " )1708 self.mutifactor_text1 = wx.StaticText( self,-1,"" )1709 self.show_sld_button = wx.Button( self,-1,"Show SLD Profile" )1710 self.show_sld_button.Bind(wx.EVT_BUTTON,self._on_show_sld)1711 1712 self.formfactorbox = wx.ComboBox(self, -1,style=wx.CB_READONLY)1713 if self.model!= None:1714 self.formfactorbox.SetValue(self.model.name)1715 1716 self.structurebox = wx.ComboBox(self, -1,style=wx.CB_READONLY)1717 self.multifactorbox = wx.ComboBox(self, -1,style=wx.CB_READONLY)1718 self.initialize_combox()1719 1720 wx.EVT_COMBOBOX(self.formfactorbox,-1, self._on_select_model)1721 wx.EVT_COMBOBOX(self.structurebox,-1, self._on_select_model)1722 wx.EVT_COMBOBOX(self.multifactorbox,-1, self._on_select_model)1723 1724 ## check model type to show sizer1725 if self.model !=None:1726 self._set_model_sizer_selection( self.model )1727 1728 sizer_selection.Add(self.text1)1729 sizer_selection.Add((5,5))1730 sizer_selection.Add(self.formfactorbox)1731 sizer_selection.Add((5,5))1732 sizer_selection.Add(self.text2)1733 sizer_selection.Add((5,5))1734 sizer_selection.Add(self.structurebox)1735 #sizer_selection.Add((5,5))1736 mutifactor_selection.Add((10,5))1737 mutifactor_selection.Add(self.mutifactor_text)1738 mutifactor_selection.Add(self.multifactorbox)1739 mutifactor_selection.Add((5,5))1740 mutifactor_selection.Add(self.mutifactor_text1)1741 mutifactor_selection.Add((10,5))1742 mutifactor_selection.Add(self.show_sld_button)1743 1744 boxsizer1.Add( sizer_buttons )1745 boxsizer1.Add( (15,15))1746 boxsizer1.Add( sizer_selection )1747 boxsizer1.Add( (10,10))1748 boxsizer1.Add(mutifactor_selection)1749 1750 self._set_multfactor_combobox()1751 self.multifactorbox.SetSelection(1)1752 self.show_sld_button.Hide()1753 #--------------------------------------------------------1754 sizer.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)1755 sizer.Layout()1756 1660 1757 1661 def _on_show_sld(self, event=None): -
sansview/perspectives/fitting/fitpage.py
rfa65e99 ra5701e6 20 20 (Chi2UpdateEvent, EVT_CHI2_UPDATE) = wx.lib.newevent.NewEvent() 21 21 _BOX_WIDTH = 76 22 _DATA_BOX_WIDTH = 3 6622 _DATA_BOX_WIDTH = 300 23 23 SMEAR_SIZE_L = 0.005 24 24 SMEAR_SIZE_H = 0.006 … … 473 473 sizer_range.Add(wx.StaticText(self, -1, "Max: "),0, wx.LEFT, 10) 474 474 sizer_range.Add(self.maximum_q,0, wx.LEFT, 10) 475 id = wx.NewId()476 self.model_view = wx.Button(self, id,"Switch to 2D", size=(80, 23))477 self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D, id=id)478 hint = "toggle view of model from 1D to 2D or 2D from 1D"479 self.model_view.SetToolTipString(hint)480 sizer_range.Add(self.model_view,0, wx.LEFT, 10)481 482 475 boxsizer1.Add(sizer_data,0, wx.ALL, 10) 483 476 boxsizer1.Add(sizer_range, 0 , wx.LEFT, 10) … … 500 493 self.model_help.Bind(wx.EVT_BUTTON, self.on_model_help_clicked,id=id) 501 494 self.model_help.SetToolTipString("Model Function Help") 502 503 ## class base method to add view 2d button 504 self._set_model_sizer(sizer=sizer, box_sizer=boxsizer1, 505 title="Model",object=self.model_help ) 495 id = wx.NewId() 496 self.model_view = wx.Button(self, id,"Switch to 2D", size=(80, 23)) 497 self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D, id=id) 498 hint = "toggle view of model from 1D to 2D or 2D from 1D" 499 self.model_view.SetToolTipString(hint) 500 501 self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes', style=wx.RB_GROUP) 502 self.shape_indep_rbutton = wx.RadioButton(self, -1, "Shape-Independent") 503 self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ") 504 self.plugin_rbutton = wx.RadioButton(self, -1, "Customized Models") 505 506 self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 507 id= self.shape_rbutton.GetId()) 508 self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 509 id= self.shape_indep_rbutton.GetId()) 510 self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 511 id= self.struct_rbutton.GetId()) 512 self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 513 id= self.plugin_rbutton.GetId()) 514 #MAC needs SetValue 515 self.shape_rbutton.SetValue(True) 516 517 sizer_radiobutton = wx.GridSizer(2, 3, 5, 5) 518 sizer_radiobutton.Add(self.shape_rbutton) 519 sizer_radiobutton.Add(self.shape_indep_rbutton) 520 #sizer_radiobutton.Add((5, 5)) 521 sizer_radiobutton.Add(self.model_view,1, wx.LEFT, 20) 522 sizer_radiobutton.Add(self.plugin_rbutton) 523 sizer_radiobutton.Add(self.struct_rbutton) 524 #sizer_radiobutton.Add((5, 5)) 525 sizer_radiobutton.Add(self.model_help,1, wx.LEFT, 20) 526 527 sizer_selection = wx.BoxSizer(wx.HORIZONTAL) 528 mutifactor_selection = wx.BoxSizer(wx.HORIZONTAL) 529 530 self.text1 = wx.StaticText(self,-1,"" ) 531 self.text2 = wx.StaticText(self,-1,"P(Q)*S(Q)" ) 532 self.mutifactor_text = wx.StaticText( self,-1,"No. of Shells: ") 533 self.mutifactor_text1 = wx.StaticText( self,-1,"" ) 534 self.show_sld_button = wx.Button( self,-1,"Show SLD Profile" ) 535 self.show_sld_button.Bind(wx.EVT_BUTTON,self._on_show_sld) 536 537 self.formfactorbox = wx.ComboBox(self, -1,style=wx.CB_READONLY) 538 if self.model!= None: 539 self.formfactorbox.SetValue(self.model.name) 540 self.structurebox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 541 self.multifactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 542 self.initialize_combox() 543 wx.EVT_COMBOBOX(self.formfactorbox, -1, self._on_select_model) 544 wx.EVT_COMBOBOX(self.structurebox, -1, self._on_select_model) 545 wx.EVT_COMBOBOX(self.multifactorbox, -1, self._on_select_model) 546 ## check model type to show sizer 547 if self.model !=None: 548 self._set_model_sizer_selection(self.model) 549 550 sizer_selection.Add(self.text1) 551 sizer_selection.Add((5, 5)) 552 sizer_selection.Add(self.formfactorbox) 553 sizer_selection.Add((5, 5)) 554 sizer_selection.Add(self.text2) 555 sizer_selection.Add((5, 5)) 556 sizer_selection.Add(self.structurebox) 557 558 mutifactor_selection.Add((10,5)) 559 mutifactor_selection.Add(self.mutifactor_text) 560 mutifactor_selection.Add(self.multifactorbox) 561 mutifactor_selection.Add((5, 5)) 562 mutifactor_selection.Add(self.mutifactor_text1) 563 mutifactor_selection.Add((10, 5)) 564 mutifactor_selection.Add(self.show_sld_button) 565 566 567 boxsizer1.Add(sizer_radiobutton) 568 boxsizer1.Add((10, 10)) 569 boxsizer1.Add(sizer_selection) 570 boxsizer1.Add((10, 10)) 571 boxsizer1.Add(mutifactor_selection) 572 573 self._set_multfactor_combobox() 574 self.multifactorbox.SetSelection(1) 575 self.show_sld_button.Hide() 576 sizer.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) 577 sizer.Layout() 506 578 507 579 def _set_sizer_dispersion(self, dispersity): … … 1446 1518 self.enable_smearer.Enable() 1447 1519 1520 def get_view_mode(self): 1521 """ 1522 return True if the panel allow 2D or False if 1D 1523 """ 1524 return self.enable2D 1525 1448 1526 def set_data(self, data): 1449 1527 """ … … 2630 2708 self.Layout() 2631 2709 self.Refresh() 2632 self.SetupScrolling() 2633 2710 2634 2711 def _onModel2D(self, event): 2635 2712 """ -
sansview/perspectives/fitting/fitpanel.py
r9f391af ra5701e6 269 269 pos = self.GetPageIndex(page) 270 270 if page.get_data() is None: 271 page.set_data(data) 272 self.SetPageText(pos, str(data.name)) 273 self.SetSelection(pos) 274 return page 271 enable2D = page.get_view_mode() 272 if (data.__class__.__name__ == "Data2D" and enable2D)\ 273 or (data.__class__.__name__ == "Data1D" and not enable2D): 274 page.set_data(data) 275 self.SetPageText(pos, str(data.name)) 276 self.SetSelection(pos) 277 return page 275 278 elif page.get_data().id == data.id: 276 279 msg = "Data already existing in the fitting panel" -
sansview/perspectives/fitting/fitting.py
r3fafe15 ra5701e6 270 270 for data in selected_data_list: 271 271 self.add_fit_page(data=data) 272 272 273 wx.PostEvent(self.parent, NewPlotEvent(plot=data, 273 274 title=str(data.title))) … … 645 646 if page.id in self.page_finder: 646 647 theory_data = self.page_finder[page.id].get_theory_data() 648 647 649 if issubclass(data.__class__, Data2D): 648 650 data.group_id.append(wx.NewId()) 651 if theory_data is not None: 652 group_id = str(page.id) + " Model1D" 653 if group_id in theory_data.group_id: 654 theory_data.group_id.remove(group_id) 655 wx.PostEvent(self.parent, 656 NewPlotEvent(group_id=group_id, 657 action="delete")) 649 658 else: 650 659 if theory_data is not None: 660 group_id = str(page.id) + " Model2D" 661 if group_id in theory_data.group_id: 662 theory_data.group_id.remove(group_id) 663 theory_data.group_id.append(wx.NewId()) 651 664 group_id = theory_data.group_id[len(theory_data.group_id)-1] 652 665 if group_id not in data.group_id: 653 666 data.group_id.append(group_id) 667 wx.PostEvent(self.parent, 668 NewPlotEvent(group_id=group_id, 669 action="delete")) 670 654 671 self.parent.update_data(prev_data=theory_data, new_data=data) 655 672 self.store_data(id=page.id, data=data, caption=page.window_name) … … 1117 1134 if group_id not in new_plot.group_id: 1118 1135 new_plot.group_id.append(group_id) 1136 1119 1137 else: 1120 1138 _xaxis, _xunit = "\\rm{Q}", 'A^{-1}' … … 1144 1162 NewPlotEvent(group_id=str(id) + " Model2D", 1145 1163 action="Hide")) 1146 print "toggle model on -->1d"1164 1147 1165 self.page_finder[id].set_theory_data(new_plot) 1148 1166 if data is None:
Note: See TracChangeset
for help on using the changeset viewer.