Changeset 4cac8a47 in sasview
- Timestamp:
- Oct 31, 2017 2:45:50 PM (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:
- 7f5196e
- Parents:
- 570a2f73 (diff), cd4f421 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Jeff Krzywon <krzywon@…> (10/31/17 14:45:50)
- git-committer:
- GitHub <noreply@…> (10/31/17 14:45:50)
- Location:
- src/sas/qtgui
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Plotting/Plottables.py
rdc5ef15 rbed08e7 227 227 if p.hidden == True: 228 228 continue 229 if not p.x ==None:229 if not p.x is None: 230 230 for x_i in p.x: 231 if min_value ==None or x_i < min_value:231 if min_value is None or x_i < min_value: 232 232 min_value = x_i 233 if max_value ==None or x_i > max_value:233 if max_value is None or x_i > max_value: 234 234 max_value = x_i 235 235 return min_value, max_value … … 560 560 Returns True if there is no data stored in the plottable 561 561 """ 562 if not self.x ==None and len(self.x) == 0 \563 and not self.y ==None and len(self.y) == 0:562 if not self.x is None and len(self.x) == 0 \ 563 and not self.y is None and len(self.y) == 0: 564 564 return True 565 565 return False … … 795 795 tempy = [] 796 796 tempdy = [] 797 if self.dx ==None:797 if self.dx is None: 798 798 self.dx = numpy.zeros(len(self.x)) 799 if self.dy ==None:799 if self.dy is None: 800 800 self.dy = numpy.zeros(len(self.y)) 801 801 if self.xLabel == "log10(x)": … … 825 825 tempy = [] 826 826 tempdy = [] 827 if self.dx ==None:827 if self.dx is None: 828 828 self.dx = numpy.zeros(len(self.x)) 829 if self.dy ==None:829 if self.dy is None: 830 830 self.dy = numpy.zeros(len(self.y)) 831 831 if self.yLabel == "log10(y)": … … 858 858 tempy = [] 859 859 tempdy = [] 860 if self.dx ==None:860 if self.dx is None: 861 861 self.dx = numpy.zeros(len(self.x)) 862 if self.dy ==None:862 if self.dy is None: 863 863 self.dy = numpy.zeros(len(self.y)) 864 864 if xmin != None and xmax != None: … … 1202 1202 """ 1203 1203 """ 1204 if self._chisq ==None:1204 if self._chisq is None: 1205 1205 chisqTxt = r'$\chi^2=$' 1206 1206 else: -
src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
rd132f33 r570a2f73 21 21 22 22 def is_float(value): 23 """Converts text input values to floats. Empty strings throw ValueError""" 23 24 try: 24 25 return float(value) … … 26 27 return 0.0 27 28 29 30 # TODO: Remove data 31 # TODO: Modify plot references, don't just send new 32 # TODO: Explorer button - link to PR from AW 33 # TODO: Update help with batch capabilities 34 # TODO: Window should not be fixed size 35 # TODO: Easy way to scroll through results - no tabs in window(?) - 'spreadsheet' 36 # TODO: Method to export results in some meaningful way 28 37 class InversionWindow(QtGui.QTabWidget, Ui_PrInversion): 29 38 """ … … 71 80 self._data_list[datum] = self._calculator.clone() 72 81 73 # plots 82 # plots for current data 74 83 self.pr_plot = None 75 84 self.data_plot = None 85 # plot references for all data in perspective 86 self.pr_plot_list = {} 87 self.data_plot_list = {} 76 88 77 89 self.model = QtGui.QStandardItemModel(self) … … 83 95 # Set up the Widget Map 84 96 self.setupMapper() 97 # Set base window state 98 self.setupWindow() 85 99 86 100 ###################################################################### … … 118 132 def setupLinks(self): 119 133 """Connect the use controls to their appropriate methods""" 120 self.enableButtons()121 134 self.dataList.currentIndexChanged.connect(self.displayChange) 122 self.calculateButton.clicked.connect(self._calculation) 135 self.calculateAllButton.clicked.connect(self.startThreadAll) 136 self.calculateThisButton.clicked.connect(self.startThread) 123 137 self.helpButton.clicked.connect(self.help) 124 138 self.estimateBgd.toggled.connect(self.toggleBgd) … … 149 163 str(self.slitHeightInput.text())))) 150 164 self.model.itemChanged.connect(self.model_changed) 151 self.estimateBgd.setChecked(True)152 165 153 166 def setupMapper(self): … … 194 207 195 208 # Main Buttons 196 self.mapper.addMapping(self.calculateButton, WIDGETS.W_CALCULATE) 209 self.mapper.addMapping(self.calculateAllButton, WIDGETS.W_CALCULATE_ALL) 210 self.mapper.addMapping(self.calculateThisButton, 211 WIDGETS.W_CALCULATE_VISIBLE) 197 212 self.mapper.addMapping(self.helpButton, WIDGETS.W_HELP) 198 213 … … 238 253 self.model.setItem(WIDGETS.W_SIGMA_POS_FRACTION, item) 239 254 255 def setupWindow(self): 256 """Initialize base window state on init""" 257 self.setTabPosition(0) 258 self.enableButtons() 259 self.estimateBgd.setChecked(True) 260 240 261 ###################################################################### 241 262 # Methods for updating GUI … … 245 266 Enable buttons when data is present, else disable them 246 267 """ 247 if self.logic.data_is_loaded: 248 self.explorerButton.setEnabled(True) 249 self.calculateButton.setEnabled(True) 250 else: 251 self.calculateButton.setEnabled(False) 252 self.explorerButton.setEnabled(False) 253 254 def populateDataComboBox(self, filename): 268 self.explorerButton.setEnabled(self.logic.data_is_loaded) 269 self.calculateAllButton.setEnabled(self.logic.data_is_loaded) 270 self.calculateThisButton.setEnabled(self.logic.data_is_loaded) 271 272 def populateDataComboBox(self, filename, data_ref): 255 273 """ 256 274 Append a new file name to the data combobox … … 258 276 """ 259 277 qt_item = QtCore.QString.fromUtf8(filename) 260 self.dataList.addItem(qt_item) 278 ref = QtCore.QVariant(data_ref) 279 self.dataList.addItem(qt_item, ref) 261 280 262 281 def acceptNoTerms(self): … … 271 290 272 291 def displayChange(self): 273 data_name = str(self.dataList.currentText()) 274 # TODO: Find data ref based on file name 275 # TODO: Find way to link standardmodelitem with combobox entry 292 variant_ref = self.dataList.itemData(self.dataList.currentIndex()) 293 self.setCurrentData(variant_ref.toPyObject()) 276 294 277 295 ###################################################################### … … 284 302 self._calculator.set_err(self._data_set.dy) 285 303 286 def _calculation(self):287 """288 Calculate the P(r) for every data set in the data list289 """290 for data_ref, pr in self._data_list.items():291 self._data_set = GuiUtils.dataFromItem(data_ref)292 self._calculator = pr293 # Set data before running the calculations294 self.update_calculator()295 # Run296 self.startThread()297 298 304 def model_changed(self): 299 305 """Update the values when user makes changes""" 300 306 if not self.mapper: 301 return 307 msg = "Unable to update P{r}. The connection between the main GUI " 308 msg += "and P(r) was severed. Attempting to restart P(r)." 309 logging.warning(msg) 310 self.setClosable(True) 311 self.close() 312 InversionWindow.__init__(self.parent(), self._data_list.keys()) 313 exit(0) 314 # TODO: Only send plot first time - otherwise, update in complete 302 315 if self.pr_plot is not None: 303 316 title = self.pr_plot.name … … 326 339 """ 327 340 Toggle the background between manual and estimated 328 :param item: gui item that was triggered329 341 """ 330 342 sender = self.sender() … … 338 350 Open the Explorer window to see correlations between params and results 339 351 """ 340 # TODO: This depends on SVCC-45352 # TODO: Look at PR from AW - Is there anything else I need to do? 341 353 pass 342 354 … … 346 358 def setData(self, data_item=None, is_batch=False): 347 359 """ 348 Assign new data set or setsto the P(r) perspective349 Obtain a QStandardItem object and dissectit to get Data1D/2D360 Assign new data set(s) to the P(r) perspective 361 Obtain a QStandardItem object and parse it to get Data1D/2D 350 362 Pass it over to the calculator 351 363 """ … … 356 368 raise AttributeError, msg 357 369 358 if not isinstance(data_item[0], QtGui.QStandardItem):359 msg = "Incorrect type passed to the P(r) Perspective"360 raise AttributeError, msg361 362 370 for data in data_item: 363 # Data references364 self._data = data371 # Create initial internal mappings 372 self._data_list[data] = self._calculator.clone() 365 373 self._data_set = GuiUtils.dataFromItem(data) 366 self.populateDataComboBox(self._data_set.filename) 367 self._data_list[self._data] = self._calculator 374 self.data_plot_list[data] = self.data_plot 375 self.pr_plot_list[data] = self.pr_plot 376 ref_var = QtCore.QVariant(data) 377 self.populateDataComboBox(self._data_set.filename, ref_var) 378 self.setCurrentData(data) 368 379 369 380 # Estimate initial values from data … … 378 389 "{:.4g}".format(qmax))) 379 390 380 self.enableButtons() 391 self.enableButtons() 392 393 def setCurrentData(self, data_ref): 394 """Get the current data and display as necessary""" 395 396 if not isinstance(data_ref, QtGui.QStandardItem): 397 msg = "Incorrect type passed to the P(r) Perspective" 398 raise AttributeError, msg 399 400 # Data references 401 self._data = data_ref 402 self._data_set = GuiUtils.dataFromItem(data_ref) 403 self._calculator = self._data_list[data_ref] 404 self.pr_plot = self.pr_plot_list[data_ref] 405 self.data_plot = self.data_plot_list[data_ref] 381 406 382 407 ###################################################################### 383 408 # Thread Creators 384 409 410 # TODO: Move to individual class(?) 411 412 def startThreadAll(self): 413 for data_ref, pr in self._data_list.items(): 414 self._data_set = GuiUtils.dataFromItem(data_ref) 415 self._calculator = pr 416 self.startThread() 417 385 418 def startThread(self): 386 419 """ … … 388 421 """ 389 422 from Thread import CalcPr 423 424 # Set data before running the calculations 425 self.update_calculator() 390 426 391 427 # If a thread is already started, stop it … … 431 467 from Thread import EstimatePr 432 468 433 self. _calculation()469 self.startThread() 434 470 435 471 # If a thread is already started, stop it … … 508 544 # Show result on control panel 509 545 510 # TODO: Connect self._calculator to GUI 546 # TODO: Connect self._calculator to GUI - two-to-one connection possible? 511 547 self.model.setItem(WIDGETS.W_RG, QtGui.QStandardItem(str(pr.rg(out)))) 512 548 self.model.setItem(WIDGETS.W_I_ZERO, … … 534 570 self._data_list[self._data] = self._calculator.clone() 535 571 572 # Create new P(r) and fit plots 536 573 if self.pr_plot is None: 537 574 self.pr_plot = self.logic.newPRPlot(out, self._calculator, cov) 575 self.pr_plot_list[self._data] = self.pr_plot 576 else: 577 # FIXME: this should update the existing plot, not create a new one 578 self.pr_plot = self.logic.newPRPlot(out, self._calculator, cov) 579 self.pr_plot_list[self._data] = self.pr_plot 538 580 if self.data_plot is None: 539 581 self.data_plot = self.logic.new1DPlot(out, self._calculator) 582 self.data_plot_list[self._data] = self.data_plot 583 else: 584 # FIXME: this should update the existing plot, not create a new one 585 self.data_plot = self.logic.new1DPlot(out, self._calculator) 586 self.data_plot_list[self._data] = self.data_plot 540 587 541 588 def _threadError(self, error): -
src/sas/qtgui/Perspectives/Inversion/InversionUtils.py
re7651ff rc00a28ff 27 27 'W_SIGMA_POS_FRACTION', 28 28 # bottom buttons 29 'W_CALCULATE', 29 'W_CALCULATE_ALL', 30 'W_CALCULATE_VISIBLE', 30 31 'W_HELP' 31 32 ) -
src/sas/qtgui/Perspectives/Inversion/UI/TabbedInversionUI.ui
r57ad773 rc00a28ff 39 39 </property> 40 40 <item> 41 <widget class="QPushButton" name="calculateButton"> 41 <widget class="QPushButton" name="calculateThisButton"> 42 <property name="text"> 43 <string>Calculate</string> 44 </property> 45 </widget> 46 </item> 47 <item> 48 <widget class="QPushButton" name="calculateAllButton"> 42 49 <property name="sizePolicy"> 43 50 <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> … … 47 54 </property> 48 55 <property name="text"> 49 <string>Calculate </string>56 <string>Calculate All</string> 50 57 </property> 51 58 </widget>
Note: See TracChangeset
for help on using the changeset viewer.