Changeset 38eb433 in sasview for src/sas/qtgui
- Timestamp:
- Aug 14, 2017 4:33:18 AM (7 years ago)
- Branches:
- 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
- Children:
- 377ade1
- Parents:
- ee18d33
- Location:
- src/sas/qtgui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/MainWindow/DataExplorer.py
ree18d33 r38eb433 279 279 ind = -1 280 280 # Use 'while' so the row count is forced at every iteration 281 deleted_indices = [] 281 282 while ind < self.model.rowCount(): 282 283 ind += 1 … … 284 285 if item and item.isCheckable() and item.checkState() == QtCore.Qt.Checked: 285 286 # Delete these rows from the model 287 deleted_indices.append(item) 286 288 self.model.removeRow(ind) 287 289 # Decrement index since we just deleted it 288 290 ind -= 1 289 291 290 # pass temporarily kept as a breakpoint anchor291 pass292 # Let others know we deleted data 293 self.communicator.dataDeletedSignal.emit(deleted_indices) 292 294 293 295 def deleteTheory(self, event): -
src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
ree18d33 r38eb433 32 32 self.currentTab = 0 33 33 34 # The current optimizer34 # The default optimizer 35 35 self.optimizer = 'Levenberg-Marquardt' 36 37 # Dataset inde -> Fitting tab mapping 38 self.dataToFitTab = {} 36 39 37 40 # The tabs need to be closeable … … 45 48 # Deal with signals 46 49 self.tabCloseRequested.connect(self.tabCloses) 50 self.communicate.dataDeletedSignal.connect(self.dataDeleted) 47 51 48 52 # Perspective window not allowed to close by default … … 104 108 tab.is_batch_fitting = is_batch 105 109 # Add this tab to the object library so it can be retrieved by scripting/jupyter 106 ObjectLibrary.addObject(self.tabName(), tab) 110 tab_name = self.tabName(is_batch=is_batch) 111 ObjectLibrary.addObject(tab_name, tab) 107 112 self.tabs.append(tab) 113 if data: 114 self.updateFitDict(data, tab_name) 108 115 self.maxIndex += 1 109 self.addTab(tab, self.tabName()) 110 111 def tabName(self): 116 self.addTab(tab, tab_name) 117 118 def updateFitDict(self, item_key, tab_name): 119 """ 120 Create a list if none exists and append if there's already a list 121 """ 122 if item_key in self.dataToFitTab.keys(): 123 self.dataToFitTab[item_key].append(tab_name) 124 else: 125 self.dataToFitTab[item_key] = [tab_name] 126 127 #print "CURRENT dict: ", self.dataToFitTab 128 129 def tabName(self, is_batch=False): 112 130 """ 113 131 Get the new tab name, based on the number of fitting tabs so far 114 132 """ 115 page_name = "FitPage" + str(self.maxIndex) 133 page_name = "BatchPage" if is_batch else "FitPage" 134 page_name = page_name + str(self.maxIndex) 116 135 return page_name 117 136 137 def resetTab(self, index): 138 """ 139 Adds a new tab and removes the last tab 140 as a way of resetting the fit tabs 141 """ 142 # If data on tab empty - do nothing 143 if not self.tabs[index].data: 144 return 145 # Add a new, empy tab 146 self.addFit(None) 147 # Remove the previous last tab 148 self.tabCloses(index) 149 118 150 def tabCloses(self, index): 119 151 """ 120 152 Update local bookkeeping on tab close 121 153 """ 122 assert len(self.tabs) >= index154 #assert len(self.tabs) >= index 123 155 # don't remove the last tab 124 156 if len(self.tabs) <= 1: 157 self.resetTab(index) 125 158 return 126 ObjectLibrary.deleteObjectByRef(self.tabs[index]) 127 del self.tabs[index] 128 self.removeTab(index) 159 try: 160 ObjectLibrary.deleteObjectByRef(self.tabs[index]) 161 self.removeTab(index) 162 del self.tabs[index] 163 except IndexError: 164 # The tab might have already been deleted previously 165 pass 166 167 def closeTabByName(self, tab_name): 168 """ 169 Given name of the fitting tab - close it 170 """ 171 for tab_index in xrange(len(self.tabs)): 172 if self.tabText(tab_index) == tab_name: 173 self.tabCloses(tab_index) 174 pass # debug hook 175 176 def dataDeleted(self, index_list): 177 """ 178 Delete fit tabs referencing given data 179 """ 180 if not index_list or not self.dataToFitTab: 181 return 182 for index_to_delete in index_list: 183 if index_to_delete in self.dataToFitTab.keys(): 184 for tab_name in self.dataToFitTab[index_to_delete]: 185 # delete tab #index after corresponding data got removed 186 self.closeTabByName(tab_name) 187 self.dataToFitTab.pop(index_to_delete) 188 189 #print "CURRENT dict: ", self.dataToFitTab 129 190 130 191 def allowBatch(self): … … 158 219 159 220 if numpy.any(available_tabs): 160 self.tabs[available_tabs.index(True)].data = data 221 first_good_tab = available_tabs.index(True) 222 self.tabs[first_good_tab].data = data 223 tab_name = str(self.tabText(first_good_tab)) 224 self.updateFitDict(data, tab_name) 161 225 else: 162 226 self.addFit(data, is_batch=is_batch) -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
ree18d33 r38eb433 311 311 self.cbFileNames.addItem(filename) 312 312 self.cbFileNames.setVisible(True) 313 # This panel is not designed to view individual fits, so disable plotting 314 self.cmdPlot.setVisible(False) 313 315 # Similarly on other tabs 314 316 self.options_widget.setEnablementOnDataLoad() -
src/sas/qtgui/Perspectives/Fitting/UI/FittingWidgetUI.ui
ree18d33 r38eb433 34 34 <item row="0" column="0"> 35 35 <widget class="QComboBox" name="cbFileNames"> 36 <property name="toolTip"> 37 <string><html><head/><body><p>Choose a file to set initial fit parameters.</p></body></html></string> 38 </property> 36 39 <property name="sizeAdjustPolicy"> 37 40 <enum>QComboBox::AdjustToContents</enum> -
src/sas/qtgui/Utilities/GuiUtils.py
r985ad94 r38eb433 245 245 # Current perspective changed 246 246 perspectiveChangedSignal = QtCore.pyqtSignal(str) 247 248 # File/dataset got deleted 249 dataDeletedSignal = QtCore.pyqtSignal(list) 247 250 248 251
Note: See TracChangeset
for help on using the changeset viewer.