Changeset 5062bbf in sasview for sansview/perspectives/fitting/fitpanel.py
- Timestamp:
- Jun 7, 2010 10:26:43 AM (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:
- b94945d
- Parents:
- 79ac6f8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitpanel.py
r31b0c47 r5062bbf 12 12 class StateIterator(object): 13 13 """ 14 15 16 17 14 Contains all saved state of a given page. 15 Provide position of the current state of a page, the first save state 16 and the last state for a given page. 17 Allow easy undo or redo for a given page 18 18 """ 19 19 def __init__(self): 20 """ 21 """ 20 22 self._current=0 21 23 22 23 24 def __iter__(self): 25 """ 26 """ 24 27 return self 25 28 26 27 29 def first(self): 30 """ 31 """ 28 32 self._current =0 29 33 return self._current 30 34 31 35 def next(self, max ): 36 """ 37 """ 32 38 if self._current < max: 33 39 self._current += 1 … … 35 41 36 42 def previous(self): 43 """ 44 """ 37 45 if self._current > 0: 38 46 self._current = self._current -1 … … 40 48 41 49 def currentPosition(self): 50 """ 51 """ 42 52 return self._current 43 53 44 54 def setPosition(self, value): 55 """ 56 """ 45 57 if value >=0: 46 58 self._current = int(value) 47 59 48 60 49 class ListOfState(list): 61 class ListOfState(list): 62 """ 63 """ 50 64 def __init__(self, *args, **kw): 51 65 list.__init__(self, *args, **kw) … … 53 67 54 68 def appendItem(self, x): 69 """ 70 """ 55 71 self.append(x) 56 72 self.iterator.setPosition(value= len(self)-1) 57 73 58 74 def removeItem(self, x): 75 """ 76 """ 59 77 self.iterator.previous() 60 78 self.remove(x) 61 79 62 80 def getPreviousItem(self): 81 """ 82 """ 63 83 position = self.iterator.previous() 64 84 … … 69 89 70 90 def getNextItem(self): 91 """ 92 """ 71 93 position = self.iterator.next(max= len(self)-1) 72 94 if position >= len(self): … … 76 98 77 99 def getCurrentItem(self): 100 """ 101 """ 78 102 postion = self.iterator.currentPosition() 79 103 if postion >= 0 and position < len(self): … … 83 107 84 108 def getCurrentPosition(self): 109 """ 110 """ 85 111 return self.iterator.currentPosition() 86 112 … … 88 114 class PageInfo(object): 89 115 """ 90 91 116 this class contains the minimum numbers of data members 117 a fitpage or model page need to be initialized. 92 118 """ 93 119 data = None … … 106 132 event_owner=None, model_list_box=None, name=None): 107 133 """ 108 134 Initialize data members 109 135 """ 110 136 self.data = data … … 121 147 122 148 """ 123 FitPanel class contains fields allowing to fit models and data 124 @note: For Fit to be performed the user should check at least one parameter 149 FitPanel class contains fields allowing to fit models and data 150 151 :note: For Fit to be performed the user should check at least one parameter 125 152 on fit Panel window. 126 153 … … 133 160 134 161 def __init__(self, parent, *args, **kwargs): 162 """ 163 """ 135 164 wx.aui.AuiNotebook.__init__(self, parent, -1, 136 165 style= wx.aui.AUI_NB_WINDOWLIST_BUTTON| … … 173 202 def set_state(self, state): 174 203 """ 175 204 Restore state of the panel 176 205 """ 177 206 page_is_opened = False … … 193 222 def on_close_page(self, event): 194 223 """ 195 224 close page and remove all references to the closed page 196 225 """ 197 226 nbr_page = self.GetPageCount() … … 204 233 def close_page_with_data(self, deleted_data): 205 234 """ 206 235 close a fit page when its data is completely remove from the graph 207 236 """ 208 237 if deleted_data is None: … … 223 252 def set_manager(self, manager): 224 253 """ 225 set panel manager 226 @param manager: instance of plugin fitting 254 set panel manager 255 256 :param manager: instance of plugin fitting 257 227 258 """ 228 259 self.manager = manager … … 231 262 def set_owner(self,owner): 232 263 """ 233 set and owner for fitpanel 234 @param owner: the class responsible of plotting 264 set and owner for fitpanel 265 266 :param owner: the class responsible of plotting 267 235 268 """ 236 269 self.event_owner = owner … … 238 271 def set_model_list(self, dict): 239 272 """ 240 copy a dictionary of model into its own dictionary 241 @param dict: dictionnary made of model name as key and model class 273 copy a dictionary of model into its own dictionary 274 275 :param dict: dictionnary made of model name as key and model class 242 276 as value 243 277 """ 244 278 self.model_list_box = dict 245 279 246 247 280 def get_current_page(self): 248 281 """ 249 @return the current page selected 282 :return: the current page selected 283 250 284 """ 251 285 return self.GetPage(self.GetSelection() ) … … 253 287 def add_sim_page(self): 254 288 """ 255 289 Add the simultaneous fit page 256 290 """ 257 291 from simfitpage import SimultaneousFitPage … … 265 299 def get_page_info(self, data=None): 266 300 """ 267 301 fill information required to add a page in the fit panel 268 302 """ 269 303 name = "Fit Page" … … 290 324 def add_empty_page(self): 291 325 """ 292 326 add an empty page 293 327 """ 294 328 page_info = self.get_page_info() … … 301 335 def add_page(self, page_info): 302 336 """ 303 337 add a new page 304 338 """ 305 339 from fitpage import FitPage … … 312 346 def change_page_content(self, data, index): 313 347 """ 314 348 replace the contains of an existing page 315 349 """ 316 350 page_info = self.get_page_info(data=data) … … 328 362 def replace_page(self, index, page_info, type): 329 363 """ 330 364 replace an existing page 331 365 """ 332 366 self.DeletePage(index) … … 336 370 def add_fit_page(self, data, reset=False): 337 371 """ 338 Add a fitting page on the notebook contained by fitpanel 339 @param data: data to fit 340 @return panel : page just added for further used. is used by fitting module 372 Add a fitting page on the notebook contained by fitpanel 373 374 :param data: data to fit 375 376 :return panel : page just added for further used. is used by fitting module 377 341 378 """ 342 379 if data is None: … … 381 418 def _onGetstate(self, event): 382 419 """ 383 420 copy the state of a page 384 421 """ 385 422 page= event.page … … 389 426 def _onUndo(self, event ): 390 427 """ 391 428 return the previous state of a given page is available 392 429 """ 393 430 page = event.page … … 402 439 def _onRedo(self, event): 403 440 """ 404 441 return the next state available 405 442 """ 406 443 page = event.page … … 417 454 def _close_helper(self, selected_page): 418 455 """ 419 456 Delete the given page from the notebook 420 457 """ 421 458 #remove hint page
Note: See TracChangeset
for help on using the changeset viewer.