Changeset e7651ff in sasview for src/sas/qtgui/Perspectives
- Timestamp:
- Oct 28, 2017 6:09:10 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:
- 57ad773
- Parents:
- d1a4793
- Location:
- src/sas/qtgui/Perspectives
- Files:
-
- 1 added
- 1 edited
- 9 moved
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
rd1a4793 re7651ff 5 5 6 6 from PyQt4 import QtGui, QtCore, QtWebKit 7 from twisted.internet import reactor 7 8 8 9 # sas-global 9 10 import sas.qtgui.Utilities.GuiUtils as GuiUtils 10 11 11 # pr inversion guielements12 from PrInversionUtils import WIDGETS12 # pr inversion GUI elements 13 from InversionUtils import WIDGETS 13 14 import UI.TabbedPrInversionUI 14 15 from UI.TabbedPrInversionUI import Ui_PrInversion 16 from InversionLogic import InversionLogic 15 17 16 18 # pr inversion calculation elements … … 24 26 return 0.0 25 27 26 class PrInversionWindow(QtGui.QTabWidget, Ui_PrInversion):28 class InversionWindow(QtGui.QTabWidget, Ui_PrInversion): 27 29 """ 28 30 The main window for the P(r) Inversion perspective. 29 31 """ 30 32 31 name = " PrInversion"33 name = "Inversion" 32 34 33 35 def __init__(self, parent=None, data=None): 34 super( PrInversionWindow, self).__init__()36 super(InversionWindow, self).__init__() 35 37 self.setupUi(self) 36 38 … … 43 45 self.communicate = GuiUtils.Communicate() 44 46 47 self.logic = InversionLogic() 48 45 49 # The window should not close 46 50 self._allow_close = False 47 51 48 # is there data 49 self._has_data = False 50 self._data = Data1D() 52 # current QStandardItem showing on the panel 53 self._data = None 54 # current Data1D as referenced by self._data 55 self._data_set = None 51 56 52 57 # p(r) calculator … … 65 70 self._data_list.append({datum: self._calculator.clone()}) 66 71 72 # plots 73 self.pr_plot = None 74 self.data_plot = None 75 67 76 self.model = QtGui.QStandardItemModel(self) 68 77 self.mapper = QtGui.QDataWidgetMapper(self) … … 76 85 ###################################################################### 77 86 # Base Perspective Class Definitions 87 88 def communicator(self): 89 return self.communicate 78 90 79 91 def allowBatch(self): … … 214 226 Enable buttons when data is present, else disable them 215 227 """ 216 if self. _has_data:228 if self.logic.data_is_loaded: 217 229 self.explorerButton.setEnabled(True) 218 230 self.calculateButton.setEnabled(True) … … 244 256 def update_calculator(self): 245 257 """Update all p(r) params. Take all GUI values as an override""" 246 self._calculator.set_x(self._data .x)247 self._calculator.set_y(self._data .y)248 self._calculator.set_err(self._data .dy)258 self._calculator.set_x(self._data_set.x) 259 self._calculator.set_y(self._data_set.y) 260 self._calculator.set_err(self._data_set.dy) 249 261 self._calculator.set_qmin(is_float(UI.TabbedPrInversionUI._fromUtf8( 250 262 self.minQInput.text()))) … … 275 287 if not self.mapper: 276 288 return 289 # TODO: Update plots 277 290 self.mapper.toFirst() 278 # TODO: Update plots, etc.279 291 280 292 def help(self): … … 339 351 340 352 for data in data_item: 341 data_object = GuiUtils.dataFromItem(data) 342 self._data_list.append({data_object: None}) 343 self._has_data = True 344 self._data = data_object 353 self._data = data 354 self._data_set = GuiUtils.dataFromItem(data) 345 355 self.enableButtons() 346 self.populateDataComboBox(data_object.filename) 356 self.populateDataComboBox(self._data_set.filename) 357 358 # Estimate initial values from data 359 self.performEstimate() 360 self.logic.data(self._calculator) 361 362 self._manager.createGuiData(None) 363 364 # TODO: Finish plotting 365 if self.pr_plot is None: 366 self.pr_plot = None 367 #self.pr_plot = self.logic.new1DPlot(self._calculator) 368 if self.data_plot is None: 369 self.data_plot = None 370 371 qmin, qmax, _ = self.logic.computeDataRange() 372 title = self._data.filename 373 347 374 self.model.setItem(WIDGETS.W_QMIN, QtGui.QStandardItem( 348 "{:.4g}".format( data_object.x.min())))375 "{:.4g}".format(qmin))) 349 376 self.model.setItem(WIDGETS.W_QMAX, QtGui.QStandardItem( 350 "{:.4g}".format(data_object.x.max()))) 351 352 # Estimate initial values from data 353 self.update_calculator() 354 self.performEstimate() 355 356 # TODO: Plot data on load 357 358 # TODO: Only load the 1st data until batch mode is working 359 # TODO: thus, the break 377 "{:.4g}".format(qmax))) 378 #reactor.callFromThread(GuiUtils.updateModelItemWithPlot, 379 # self._model_item, self._communicator, title) 380 381 # TODO: Only load 1st data until batch mode working. Thus, break 360 382 break 361 383 … … 367 389 Start a calculation thread 368 390 """ 369 from PrThread import CalcPr391 from Thread import CalcPr 370 392 371 393 # If a thread is already started, stop it … … 385 407 Perform parameter estimation 386 408 """ 387 from PrThread import EstimateNT409 from Thread import EstimateNT 388 410 389 411 # If a thread is already started, stop it … … 409 431 Perform parameter estimation 410 432 """ 411 from PrThread import EstimatePr 433 from Thread import EstimatePr 434 435 self._calculation() 412 436 413 437 # If a thread is already started, stop it … … 464 488 self.model.setItem(WIDGETS.W_COMP_TIME, 465 489 QtGui.QStandardItem(str(elapsed))) 490 self.PrTabWidget.setCurrentIndex(0) 466 491 if message: 467 492 logging.info(message) 468 pass469 493 470 494 def _completed(self, out, cov, pr, elapsed): … … 481 505 # Keep a copy of the last result 482 506 self._last_calculator = pr.clone() 483 484 # TODO: Append to data dictionary485 # self._data_list.append({s})486 507 487 508 # Save Pr invertor … … 512 533 # Display results tab 513 534 self.PrTabWidget.setCurrentIndex(1) 514 515 # TODO: Show plots 535 self._data_list.append({self._data: pr}) 536 537 # TODO: Show plots - Really, this should be linked to the inputs, etc, 538 # TODO: so it should happen automagically 516 539 # Show I(q) fit 517 540 # self.show_iq(out, self._calculator) … … 524 547 """ 525 548 logging.warning(error) 526 527 def show_data(self, path=None, data=None, reset=False):528 """529 Show data read from a file530 531 :param path: file path532 :param reset: if True all other plottables will be cleared533 534 """535 if data is not None:536 try:537 pr = self._create_file_pr(data)538 except:539 status = "Problem reading data: %s" % sys.exc_value540 raise RuntimeError, status541 542 # If the file contains nothing, just return543 if pr is None:544 raise RuntimeError, "Loaded data is invalid"545 546 self._calculator = pr547 548 # Make a plot of I(q) data549 if self._calculator.err is None:550 logging.log(self._calculator.err)551 else:552 # TODO: Do something553 pass554 # Get Q range555 #self.control_panel.q_min = min(self._calculator.x)556 #self.control_panel.q_max = max(self._calculator.x) -
src/sas/qtgui/Perspectives/__init__.py
re32b120 re7651ff 4 4 from Fitting.FittingPerspective import FittingWindow 5 5 from Invariant.InvariantPerspective import InvariantWindow 6 from PrInversion.PrInversionPerspective import PrInversionWindow6 from Inversion.InversionPerspective import InversionWindow 7 7 8 8 PERSPECTIVES = { 9 9 FittingWindow.name: FittingWindow, 10 10 InvariantWindow.name: InvariantWindow, 11 PrInversionWindow.name: PrInversionWindow11 InversionWindow.name: InversionWindow 12 12 }
Note: See TracChangeset
for help on using the changeset viewer.