Changes in src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py [d2007a8:fb39f28] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
rd2007a8 rfb39f28 1 1 import numpy 2 import copy 2 3 3 4 from PyQt5 import QtCore … … 10 11 import sas.qtgui.Utilities.LocalConfig as LocalConfig 11 12 import sas.qtgui.Utilities.ObjectLibrary as ObjectLibrary 13 import sas.qtgui.Utilities.GuiUtils as GuiUtils 12 14 13 15 from sas.qtgui.Perspectives.Fitting.FittingWidget import FittingWidget … … 37 39 self.maxIndex = 1 38 40 39 ## Index of the current tab40 #self.currentTab = 041 42 41 # The default optimizer 43 42 self.optimizer = 'Levenberg-Marquardt' … … 85 84 self.updateWindowTitle() 86 85 86 # Add new tab mini-button 87 self.plusButton = QtWidgets.QToolButton(self) 88 self.plusButton.setText("+") 89 self.setCornerWidget(self.plusButton) 90 self.plusButton.setToolTip("Add a new Fit Page") 91 self.plusButton.clicked.connect(lambda: self.addFit(None)) 92 87 93 def updateWindowTitle(self): 88 94 """ … … 112 118 def onLatexCopy(self): 113 119 self.currentTab.onCopyToClipboard("Latex") 120 121 def serializeAllFitpage(self): 122 # serialize all active fitpages and return 123 # a dictionary: {data_id: fitpage_state} 124 params = {} 125 for i, tab in enumerate(self.tabs): 126 tab_data = self.getSerializedFitpage(tab) 127 if 'data_id' not in tab_data: continue 128 id = tab_data['data_id'][0] 129 if isinstance(id, list): 130 for i in id: 131 if i in params: 132 params[i].append(tab_data) 133 else: 134 params[i] = [tab_data] 135 else: 136 if id in params: 137 params[id].append(tab_data) 138 else: 139 params[id] = [tab_data] 140 return params 141 142 def serializeCurrentFitpage(self): 143 # serialize current(active) fitpage 144 return self.getSerializedFitpage(self.currentTab) 145 146 def getSerializedFitpage(self, tab): 147 """ 148 get serialize requested fit tab 149 """ 150 fitpage_state = tab.getFitPage() 151 fitpage_state += tab.getFitModel() 152 # put the text into dictionary 153 line_dict = {} 154 for line in fitpage_state: 155 #content = line.split(',') 156 if len(line) > 1: 157 line_dict[line[0]] = line[1:] 158 return line_dict 159 160 def currentTabDataId(self): 161 """ 162 Returns the data ID of the current tab 163 """ 164 tab_id = [] 165 if not self.currentTab.data: 166 return tab_id 167 for item in self.currentTab.all_data: 168 data = GuiUtils.dataFromItem(item) 169 tab_id.append(data.id) 170 171 return tab_id 172 173 def updateFromParameters(self, parameters): 174 """ 175 Pass the update parameters to the current fit page 176 """ 177 self.currentTab.createPageForParameters(parameters) 114 178 115 179 def closeEvent(self, event): … … 246 310 for index_to_delete in index_list: 247 311 index_to_delete_str = str(index_to_delete) 248 if index_to_delete_str in list(self.dataToFitTab.keys()): 249 for tab_name in self.dataToFitTab[index_to_delete_str]: 250 # delete tab #index after corresponding data got removed 251 self.closeTabByName(tab_name) 252 self.dataToFitTab.pop(index_to_delete_str) 312 orig_dict = copy.deepcopy(self.dataToFitTab) 313 for tab_key in orig_dict.keys(): 314 if index_to_delete_str in tab_key: 315 for tab_name in orig_dict[tab_key]: 316 self.closeTabByName(tab_name) 317 self.dataToFitTab.pop(tab_key) 253 318 254 319 def allowBatch(self): 255 320 """ 256 321 Tell the caller that we accept multiple data instances 322 """ 323 return True 324 325 def isSerializable(self): 326 """ 327 Tell the caller that this perspective writes its state 257 328 """ 258 329 return True … … 337 408 pass 338 409 410 def getCurrentStateAsXml(self): 411 """ 412 Returns an XML version of the current state 413 """ 414 state = {} 415 for tab in self.tabs: 416 pass 417 return state 418 339 419 @property 340 420 def currentTab(self):
Note: See TracChangeset
for help on using the changeset viewer.