- Timestamp:
- Jun 9, 2009 2:49:39 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:
- fe496eeb
- Parents:
- d4ccbb1
- Location:
- sansview/perspectives/fitting
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r1b69256 r330573d 10 10 from pagestate import PageState 11 11 (PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() 12 (PreviousStateEvent, EVT_PREVIOUS_STATE) = wx.lib.newevent.NewEvent() 13 (NextStateEvent, EVT_NEXT_STATE) = wx.lib.newevent.NewEvent() 12 14 _BOX_WIDTH = 80 13 15 … … 46 48 ## smearer object 47 49 self.smearer = None 50 48 51 ##list of model parameters. each item must have same length 49 52 ## each item related to a given parameters … … 81 84 self.number_saved_state= 0 82 85 ## dictionary of saved state 83 self.saved_states={} 86 self.saved_states={} 84 87 85 88 ## Create context menu for page … … 125 128 126 129 127 128 130 def onUndo(self, event): 129 131 """ … … 131 133 """ 132 134 print "enable undo" 135 event = PreviousStateEvent(page = self) 136 wx.PostEvent(self.parent, event) 137 133 138 134 139 def onRedo(self, event): … … 137 142 """ 138 143 print "enable redo" 144 event = NextStateEvent(page= sent) 145 wx.PostEvent(self.parent, event) 146 139 147 140 148 def define_page_structure(self): … … 361 369 362 370 self.state.disp_cb_dict[p]= self.disp_cb_dict[p].GetValue() 363 event = PageInfoEvent(page = self)364 wx.PostEvent(self.parent, event)371 #event = PageInfoEvent(page = self) 372 #wx.PostEvent(self.parent, event) 365 373 return 366 374 … … 564 572 565 573 ## post state to fit panel 566 event = PageInfoEvent(page = self)567 wx.PostEvent(self.parent, event)574 #event = PageInfoEvent(page = self) 575 #wx.PostEvent(self.parent, event) 568 576 569 577 … … 575 583 state of the graphic interface 576 584 """ 585 if state ==None: 586 self._undo.Enable(False) 587 return 577 588 self.model= state.model 578 589 self.data = state.data … … 592 603 if hasattr(self, "cb1"): 593 604 self.cb1.SetValue(state.cb1) 605 594 606 ## reset state of checkbox,textcrtl and regular parameters value 595 607 self._reset_parameters_state(self.orientation_params_disp, … … 674 686 self.state = state.clone() 675 687 ## post state to fit panel 676 event = PageInfoEvent(page = self)677 wx.PostEvent(self.parent, event)688 #event = PageInfoEvent(page = self) 689 #wx.PostEvent(self.parent, event) 678 690 679 691 def _selectDlg(self): … … 732 744 if self.model !=None: 733 745 734 ## save current state 735 self.save_current_state() 736 746 737 747 # Flag to register when a parameter has changed. 738 748 is_modified = False … … 1183 1193 self.state.disp_list = self.disp_list 1184 1194 1185 ## post state to fit panel1186 event = PageInfoEvent(page = self)1187 wx.PostEvent(self.parent, event)1188 1189 1195 self.sizer4_4.Layout() 1190 1196 self.sizer4.Layout() … … 1200 1206 """ 1201 1207 tcrtl= event.GetEventObject() 1202 1208 ## save current state 1209 self.save_current_state() 1210 1211 event = PageInfoEvent(page = self) 1212 wx.PostEvent(self.parent, event) 1213 1203 1214 if check_float(tcrtl): 1215 1204 1216 self._onparamEnter_helper() 1205 1217 else: … … 1396 1408 self.state.disp_box= n 1397 1409 ## post state to fit panel 1398 event = PageInfoEvent(page = self)1399 wx.PostEvent(self.parent, event)1410 #event = PageInfoEvent(page = self) 1411 #wx.PostEvent(self.parent, event) 1400 1412 1401 1413 self.sizer4_4.Layout() -
sansview/perspectives/fitting/fitpage.py
r7437880 r330573d 169 169 170 170 #Set sizer for Fitting section 171 self._set_range_sizer( title="Fitting", 172 object1=sizer_smearer, object= sizer_fit) 171 self._set_range_sizer( title="Fitting",object1=sizer_smearer, object= sizer_fit) 173 172 174 173 … … 543 542 wx.PostEvent(self.event_owner, evt) 544 543 self.btFit.SetFocus() 544 ## post state to fit panel 545 event = PageInfoEvent(page = self) 546 wx.PostEvent(self.parent, event) 547 545 548 546 549 def _onparamRangeEnter(self, event): … … 577 580 """ 578 581 tcrtl= event.GetEventObject() 582 ## save current state 583 self.save_current_state() 584 585 event = PageInfoEvent(page = self) 586 wx.PostEvent(self.parent, event) 587 579 588 if check_float(tcrtl): 580 589 self._onparamEnter_helper() … … 751 760 self.compute_chisqr(smearer= temp_smearer) 752 761 ## save the state enable smearing 753 self.save_current_state() 762 self.state.smearer= temp_smearer 763 #self.save_current_state() 764 754 765 755 766 def complete_chisqr(self, output, elapsed=None): … … 765 776 ## post state to fit panel 766 777 self.state.tcChi =output 767 event = PageInfoEvent(page = self)768 wx.PostEvent(self.parent, event)778 #event = PageInfoEvent(page = self) 779 #wx.PostEvent(self.parent, event) 769 780 except: 770 781 pass … … 901 912 item[0].SetValue(False) 902 913 self.param_toFit=[] 903 904 self.save_current_state() 914 self._copy_parameters_state(self.orientation_params, 915 self.state.orientation_params) 916 self._copy_parameters_state(self.orientation_params_disp, 917 self.state.orientation_params_disp) 918 self._copy_parameters_state(self.parameters, self.state.parameters) 919 self._copy_parameters_state(self.fittable_param, self.state.fittable_param) 920 self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 921 922 #self.save_current_state() 905 923 906 924 … … 936 954 self.cb1.SetValue(False) 937 955 ## save current state of the page 938 self.save_current_state() 956 self._copy_parameters_state(self.orientation_params, 957 self.state.orientation_params) 958 self._copy_parameters_state(self.orientation_params_disp, 959 self.state.orientation_params_disp) 960 self._copy_parameters_state(self.parameters, self.state.parameters) 961 self._copy_parameters_state(self.fittable_param, self.state.fittable_param) 962 self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 963 964 #self.save_current_state() 939 965 940 966 … … 1011 1037 for item in keys: 1012 1038 if not item in self.disp_list and not item in self.model.orientation_params: 1039 1013 1040 iy += 1 1014 1041 ix = 0 … … 1198 1225 self.sizer3.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) 1199 1226 self.sizer3.Layout() 1227 self.Layout() 1228 self.Refresh() 1200 1229 self.SetScrollbars(20,20,200,100) 1201 1202 1230 1203 1231 1204 1232 -
sansview/perspectives/fitting/fitpanel.py
r1b69256 r330573d 3 3 import wx.lib 4 4 import numpy 5 import string ,re 6 #import models 5 import string 6 7 8 import basepage 9 7 10 _BOX_WIDTH = 80 8 import basepage 9 10 class State Container(object):11 12 13 class StateIterator(object): 11 14 """ 12 15 Contains all saved state of a given page. 13 16 Provide position of the current state of a page, the first save state 14 17 and the last state for a given page. 15 Allow easy unoding or redo for a given page 16 """ 17 def __init__(self, page=None): 18 """ 19 Initialize variable 20 """ 21 self.page = page 22 self.begin =0 23 self.current=0 24 self.end=0 18 Allow easy undo or redo for a given page 19 """ 20 def __init__(self): 21 self._current=0 22 23 24 def __iter__(self): 25 return self 26 27 28 def first(self): 29 self._current =0 30 return self._current 31 32 def next(self, max ): 33 if self._current < max: 34 self._current += 1 35 return self._current 36 37 def previous(self): 38 if self._current > 0: 39 self._current = self._current -1 40 return self._current 41 42 def currentPosition(self): 43 return self._current 44 45 def setPosition(self, value): 46 if value >=0: 47 self._current = int(value) 48 49 50 51 52 class ListOfState(list): 53 def __init__(self, *args, **kw): 54 list.__init__(self, *args, **kw) 55 self.iterator = StateIterator() 56 57 def appendItem(self, x): 58 self.append(x) 59 self.iterator.setPosition(value= len(self)-1) 60 61 def removeItem(self, x): 62 self.iterator.previous() 63 self.remove(x) 64 65 def getPreviousItem(self): 66 position = self.iterator.previous() 67 68 if position < 0: 69 return None 70 else: 71 return self[position] 72 73 def getNextItem(self): 74 position = self.iterator.next() 75 if position >= len(self): 76 return None 77 else: 78 return self[position] 79 80 def getCurrentItem(self): 81 postion = self.iterator.currentPosition() 82 if postion >= 0 and position < len(self): 83 return self[postion] 84 else: 85 return None 86 87 def getCurrentPosition(self): 88 return self.iterator.currentPosition() 89 90 25 91 26 92 … … 37 103 model_list_box = None 38 104 name=None 39 105 ## Internal name for the AUI manager 40 106 window_name = "Page" 41 107 ## Title to appear on top of the window … … 105 171 ## get the state of a page 106 172 self.Bind(basepage.EVT_PAGE_INFO, self._onGetstate) 173 self.Bind(basepage.EVT_PREVIOUS_STATE, self._onUndo) 174 #(NextStateEvent, EVT_NEXT_STATE) = wx.lib.neweve 107 175 # increment number for model name 108 176 self.count=0 … … 241 309 panel.reset_page(memento) 242 310 else: 243 self.fit_page_name[name]= []244 self.fit_page_name[name].insert(0,panel.createMemento())311 self.fit_page_name[name]=ListOfState() 312 #self.fit_page_name[name].appendItem(panel.createMemento()) 245 313 #GetPage(self, page_idx) 246 314 return panel … … 248 316 if self.fit_page1D_number!=None: 249 317 panel =self.GetPage(self.fit_page1D_number) 250 self.fit_page_name[name]=[] 251 self.fit_page_name[name].insert(0,panel.createMemento()) 318 #self.fit_page_name[name]=[] 319 self.fit_page_name[name]= ListOfState() 320 #self.fit_page_name[name].insert(0,panel.createMemento()) 321 #self.fit_page_name[name].append(panel.createMemento()) 252 322 return panel 253 323 return None … … 255 325 if self.fit_page2D_number!=None: 256 326 panel =self.GetPage(self.fit_page2D_number) 257 self.fit_page_name[name]= []258 self.fit_page_name[name].insert(0,panel.createMemento())327 self.fit_page_name[name]=ListOfState() 328 #self.fit_page_name[name].append(panel.createMemento()) 259 329 return panel 260 330 return None … … 324 394 page= event.page 325 395 if page.window_name in self.fit_page_name: 326 self.fit_page_name[page.window_name]. insert(0,page.createMemento())396 self.fit_page_name[page.window_name].appendItem(page.createMemento()) 327 397 398 def _onUndo(self, event ): 399 """ 400 return the previous state of a given page is available 401 """ 402 page = event.page 403 if page.window_name in self.fit_page_name: 404 if self.fit_page_name[page.window_name].getCurrentPosition()==0: 405 state = None 406 else: 407 state = self.fit_page_name[page.window_name].getPreviousItem() 408 page.reset_page(state) 409 410 328 411 329 412 def _help_add_model_page(self,model,page_title="Model", qmin=0.0001, -
sansview/perspectives/fitting/modelpage.py
r71f0373 r330573d 347 347 if self.model !=None: 348 348 self._draw_model() 349 349 ## post state to fit panel 350 event = PageInfoEvent(page = self) 351 wx.PostEvent(self.parent, event) 352 350 353 351 354 def set_model_description(self,description,sizer):
Note: See TracChangeset
for help on using the changeset viewer.