Changeset 77e23a2 in sasview
- Timestamp:
- Apr 2, 2009 12:28:34 PM (16 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:
- 7fff5cd
- Parents:
- 05f14dd
- Location:
- sansview/perspectives/fitting
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r376916c r77e23a2 29 29 ## parent of the page 30 30 self.parent = parent 31 ## manager is the fitting plugin 32 self.manager=None 31 33 ## owner of the page (fitting plugin) 32 34 self.event_owner= None … … 70 72 self.data = self.page_info.data 71 73 self.event_owner = self.page_info.event_owner 74 self.manager=self.page_info.manager 72 75 73 76 if self.model !=None: … … 356 359 357 360 def onSetFocus(self, evt): 361 """ 362 highlight the current textcrtl and hide the error text control shown 363 after fitting 364 """ 365 if hasattr(self,"text2_3"): 366 self.text2_3.Hide() 367 if len(self.parameters)>0: 368 for item in self.parameters: 369 ## hide statictext +/- 370 if item[3]!=None: 371 item[3].Hide() 372 ## hide textcrtl for error after fit 373 if item[4]!=None: 374 item[4].Clear() 375 item[4].Hide() 376 if len(self.fittable_param)>0: 377 for item in self.fittable_param: 378 ## hide statictext +/- 379 if item[3]!=None: 380 item[3].Hide() 381 ## hide textcrtl for error after fit 382 if item[4]!=None: 383 item[4].Clear() 384 item[4].Hide() 385 self.Layout() 358 386 # Get a handle to the TextCtrl 359 387 widget = evt.GetEventObject() 360 388 # Select the whole control, after this event resolves 361 wx.CallAfter(widget.SetSelection, -1, 389 wx.CallAfter(widget.SetSelection, -1,-1) 362 390 return 363 391 … … 414 442 """ 415 443 if self.model !=None: 444 416 445 # Flag to register when a parameter has changed. 417 446 is_modified = False … … 723 752 self.model= MultiplicationModel(form_factor(),struct_factor()) 724 753 725 self. set_model_param_sizer(self.model)754 self._on_select_model(event=None) 726 755 self.sizer4_4.Clear() 727 756 self.sizer4.Layout() 728 757 729 self._draw_model()758 730 759 self.set_scroll() 731 760 … … 752 781 except: 753 782 pass 754 wx.EVT_COMBOBOX(combobox,-1, self._on_select_model)783 #wx.EVT_COMBOBOX(combobox,-1, self._on_select_model) 755 784 return 0 756 785 … … 802 831 for item in list: 803 832 try: 833 name = str(item[1]) 804 834 if hasattr(self,"text2_3"): 805 835 self.text2_3.Hide() 836 ## check model parameters range 837 ## check minimun value 838 param_min= None 839 param_max= None 840 if item[5]!= None: 841 if format_number(item[5].GetValue())!="NaN": 842 param_min = float(item[5].GetValue()) 843 self.model.details[name][1]=param_min 844 ## check maximum value 845 if item[6]!= None: 846 if format_number(item[6].GetValue())!="NaN": 847 param_max = float(item[6].GetValue()) 848 849 from sans.guiframe.utils import check_value 850 if param_min != None and param_max !=None: 851 if check_value(item[5], item[6]): 852 self.model.details[name][1:]=param_min,param_max 853 else: 854 msg= "Wrong Fit range entered for parameter " 855 msg+= "name %s of model %s "%(name, self.model.name) 856 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 857 self.model.details[name][1:]=param_min,param_max 858 ## hide statictext +/- 806 859 if item[3]!=None: 807 860 item[3].Hide() 861 ## hide textcrtl for error after fit 808 862 if item[4]!=None: 809 863 item[4].Clear() 810 864 item[4].Hide() 811 name = str(item[1])865 812 866 value= float(item[2].GetValue()) 813 867 # If the value of the parameter has changed, -
sansview/perspectives/fitting/fitpage.py
r376916c r77e23a2 9 9 from sans.guicomm.events import StatusEvent 10 10 from sans.guiframe.utils import format_number 11 11 12 (ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent() 13 (FitterTypeEvent, EVT_FITTER_TYPE) = wx.lib.newevent.NewEvent() 12 14 _BOX_WIDTH = 80 13 15 … … 43 45 self.page_info.model= self.model 44 46 self._on_select_model(event=None) 45 46 47 self.Bind(EVT_FITTER_TYPE,self._on_engine_change) 48 49 50 def _on_engine_change(self, event): 51 """ 52 get an event containing the current name of the fit engine type 53 @param event: FitterTypeEvent containing the name of the current engine 54 """ 55 if len(self.parameters)==0: 56 return 57 for item in self.parameters: 58 if event.type =="scipy": 59 item[5].SetValue(format_number("")) 60 item[5].Hide() 61 item[6].SetValue(format_number("")) 62 item[6].Hide() 63 self.text2_min.Hide() 64 self.text2_max.Hide() 65 else: 66 item[5].Show(True) 67 item[6].Show(True) 68 self.text2_min.Show(True) 69 self.text2_max.Show(True) 70 71 self.sizer3.Layout() 72 self.SetScrollbars(20,20,200,100) 73 74 47 75 def _on_display_description(self, event): 48 76 """ … … 261 289 ctl1.SetValue(str (format_number(value))) 262 290 ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 291 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 263 292 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 264 293 self.sizer4_4.Add(ctl1, (iy,ix),(1,1),wx.EXPAND) … … 286 315 Tctl.SetValue(str (format_number(value))) 287 316 Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 317 Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 288 318 Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 289 319 self.sizer4_4.Add(Tctl, (iy,ix),(1,1), … … 300 330 Tctl.SetValue(str (format_number(value))) 301 331 Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 332 Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 302 333 Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 303 334 self.sizer4_4.Add(Tctl, (iy,ix),(1,1), … … 344 375 self.manager.set_fit_range(page= self,qmin= self.qmin_x, qmax= self.qmax_x) 345 376 #single fit 346 #self.manager.on_single_fit(qmin=self.qmin_x,qmax=self.qmax_x)347 377 self.manager.onFit() 348 378 … … 373 403 when enter value on panel redraw model according to changed 374 404 """ 375 376 405 self._onparamEnter_helper() 377 406 self.compute_chisqr() … … 660 689 661 690 662 def set_model_param_sizer(self, model , engine_type="park"):691 def set_model_param_sizer(self, model): 663 692 """ 664 693 Build the panel from the model content … … 719 748 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 720 749 self.text2_4.Hide() 721 if engine_type == "park": 722 self.text2_max.Show(True) 723 self.text2_min.Show(True) 750 724 751 725 752 for item in keys: … … 739 766 style=wx.TE_PROCESS_ENTER) 740 767 741 ctl1.SetValue(str (format_number(value))) 768 ctl1.SetValue(format_number(value)) 769 ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 742 770 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 743 771 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) … … 755 783 ctl2.Hide() 756 784 785 param_min, param_max= self.model.details[item][1:] 757 786 ix += 1 758 787 ctl3 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) 788 ctl3.SetValue(format_number(param_min)) 789 ctl3.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 759 790 ctl3.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 760 791 ctl3.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 761 792 sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 762 793 ctl3.Hide() 763 794 764 795 ix += 1 765 796 ctl4 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) 797 ctl4.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 766 798 ctl4.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 767 799 ctl4.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 768 800 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 801 ctl4.SetValue(format_number(param_max)) 769 802 ctl4.Hide() 770 if engine_type == "park": 771 ctl3.Show(True) 772 ctl4.Show(True) 773 803 774 804 ix +=1 775 805 # Units -
sansview/perspectives/fitting/fitpanel.py
r1328e03 r77e23a2 152 152 myinfo = PageInfo( self, data=data ) 153 153 myinfo.model_list_box = self.model_list_box.get_list() 154 myinfo.event_owner =self.event_owner 154 myinfo.event_owner = self.event_owner 155 myinfo.manager = self.manager 155 156 156 157 if not name in self.fit_page_name : … … 160 161 panel.name = name 161 162 panel.window_name= "fitpage" 162 panel.set_manager(self.manager)163 panel.set_owner(self.event_owner)164 165 163 self.AddPage(page=panel,caption=name,select=True) 166 164 #panel.populate_box( self.model_list_box) … … 215 213 myinfo = PageInfo( self, model ) 216 214 myinfo.model_list_box = self.model_list_box.get_list() 217 myinfo.event_owner =self.event_owner 215 myinfo.event_owner = self.event_owner 216 myinfo.manager = self.manager 218 217 219 218 from modelpage import ModelPage 220 219 panel = ModelPage(self,myinfo,page_title) 221 panel.set_manager(self.manager) 222 panel.set_owner(self.event_owner) 223 224 220 225 221 self.AddPage(page=panel,caption="Model",select=True) 226 #panel.populate_box( self.model_list_box) 222 227 223 panel.name = page_title 228 224 self.draw_model_name=page_title -
sansview/perspectives/fitting/fitting.py
r89ef796 r77e23a2 22 22 import time 23 23 import thread 24 24 25 25 26 (PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() … … 450 451 Add name of a closed page of fitpanel in a menu 451 452 """ 452 # Post paramters 453 event_id = wx.NewId() 454 self.menu1.Append(event_id, name, 455 "Show %s fit panel" % name) 456 self.closed_page_dict[event_id ]= [page_info, fitproblem] 453 if len(self.closed_page_dict)>0: 454 for k , value in self.closed_page_dict.iteritems(): 455 if not name in value: 456 # Post paramters 457 event_id = wx.NewId() 458 self.menu1.Append(event_id, name, "Show %s fit panel" % name) 459 self.closed_page_dict[event_id ]= [page_info, fitproblem] 460 else: 461 event_id= k 462 self.closed_page_dict[k ]= [page_info, fitproblem] 463 else: 464 event_id = wx.NewId() 465 self.menu1.Append(event_id, name, "Show %s fit panel" % name) 466 self.closed_page_dict[event_id ]= [page_info, fitproblem] 457 467 wx.EVT_MENU(self.parent,event_id, self._open_closed_page) 458 468 … … 719 729 @param engine: the key work of the engine 720 730 """ 731 ## saving fit engine name 721 732 self._fit_engine = engine 733 ## post a message to status bar 722 734 wx.PostEvent(self.parent, StatusEvent(status="Engine set to: %s" % self._fit_engine)) 723 735 736 ## Bind every open fit page with a newevent to know the current fitting engine 737 import fitpage 738 event= fitpage.FitterTypeEvent() 739 event.type = self._fit_engine 740 for key in self.page_finder.keys(): 741 wx.PostEvent(key, event) 742 724 743 725 744 def _on_model_panel(self, evt): … … 729 748 """ 730 749 model = evt.model 750 731 751 if model ==None: 732 752 return 733 753 734 sim_page=self.sim_page735 754 current_pg = self.fit_panel.get_current_page() 736 755 ## make sure nothing is done on self.sim_page 737 756 ## example trying to call set_panel on self.sim_page 738 if current_pg != s im_page:757 if current_pg != self.sim_page : 739 758 740 759 if self.page_finder[current_pg].get_model()== None : … … 743 762 self.index_model += 1 744 763 else: 745 746 764 model.name= self.page_finder[current_pg].get_model().name 747 765 748 749 766 metadata = self.page_finder[current_pg].get_plotted_data() 750 767 -
sansview/perspectives/fitting/modelpage.py
r376916c r77e23a2 178 178 ctl1.SetValue(str (format_number(value))) 179 179 ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 180 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 180 181 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 181 182 self.sizer4_4.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) … … 192 193 Tctl1.SetValue(str (format_number(value))) 193 194 Tctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 195 Tctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 194 196 Tctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 195 197 self.sizer4_4.Add(Tctl1, (iy,ix),(1,1), … … 207 209 Tctl2.SetValue(str (format_number(value))) 208 210 Tctl2.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 211 Tctl2.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 209 212 Tctl2.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 210 213 self.sizer4_4.Add(Tctl2, (iy,ix),(1,1), … … 386 389 ctl1.SetValue(str (format_number(value))) 387 390 ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 391 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 388 392 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 389 393 -
sansview/perspectives/fitting/simfitpage.py
r6f023e8 r77e23a2 290 290 Show constraint fields 291 291 """ 292 self.btAdd.Show(True) 292 293 if len(self.constraints_list)!= 0: 293 294 nb_fit_param = 0 … … 511 512 self.btAdd.Bind(wx.EVT_BUTTON, self._onAdd_constraint,id= self.btAdd.GetId()) 512 513 self.btAdd.SetToolTipString("Add another constraint?") 514 self.btAdd.Hide() 513 515 514 516
Note: See TracChangeset
for help on using the changeset viewer.