Changeset e7651ff in sasview for src/sas


Ignore:
Timestamp:
Oct 28, 2017 4:09:10 AM (6 years ago)
Author:
krzywon
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
Message:

Renamed from PrInversion? to Inversion. Added base for plotting.

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  
    55 
    66from PyQt4 import QtGui, QtCore, QtWebKit 
     7from twisted.internet import reactor 
    78 
    89# sas-global 
    910import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    1011 
    11 # pr inversion gui elements 
    12 from PrInversionUtils import WIDGETS 
     12# pr inversion GUI elements 
     13from InversionUtils import WIDGETS 
    1314import UI.TabbedPrInversionUI 
    1415from UI.TabbedPrInversionUI import Ui_PrInversion 
     16from InversionLogic import InversionLogic 
    1517 
    1618# pr inversion calculation elements 
     
    2426        return 0.0 
    2527 
    26 class PrInversionWindow(QtGui.QTabWidget, Ui_PrInversion): 
     28class InversionWindow(QtGui.QTabWidget, Ui_PrInversion): 
    2729    """ 
    2830    The main window for the P(r) Inversion perspective. 
    2931    """ 
    3032 
    31     name = "PrInversion" 
     33    name = "Inversion" 
    3234 
    3335    def __init__(self, parent=None, data=None): 
    34         super(PrInversionWindow, self).__init__() 
     36        super(InversionWindow, self).__init__() 
    3537        self.setupUi(self) 
    3638 
     
    4345        self.communicate = GuiUtils.Communicate() 
    4446 
     47        self.logic = InversionLogic() 
     48 
    4549        # The window should not close 
    4650        self._allow_close = False 
    4751 
    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 
    5156 
    5257        # p(r) calculator 
     
    6570            self._data_list.append({datum: self._calculator.clone()}) 
    6671 
     72        # plots 
     73        self.pr_plot = None 
     74        self.data_plot = None 
     75 
    6776        self.model = QtGui.QStandardItemModel(self) 
    6877        self.mapper = QtGui.QDataWidgetMapper(self) 
     
    7685    ###################################################################### 
    7786    # Base Perspective Class Definitions 
     87 
     88    def communicator(self): 
     89        return self.communicate 
    7890 
    7991    def allowBatch(self): 
     
    214226        Enable buttons when data is present, else disable them 
    215227        """ 
    216         if self._has_data: 
     228        if self.logic.data_is_loaded: 
    217229            self.explorerButton.setEnabled(True) 
    218230            self.calculateButton.setEnabled(True) 
     
    244256    def update_calculator(self): 
    245257        """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) 
    249261        self._calculator.set_qmin(is_float(UI.TabbedPrInversionUI._fromUtf8( 
    250262            self.minQInput.text()))) 
     
    275287        if not self.mapper: 
    276288            return 
     289        # TODO: Update plots 
    277290        self.mapper.toFirst() 
    278         # TODO: Update plots, etc. 
    279291 
    280292    def help(self): 
     
    339351 
    340352        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) 
    345355            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 
    347374            self.model.setItem(WIDGETS.W_QMIN, QtGui.QStandardItem( 
    348                 "{:.4g}".format(data_object.x.min()))) 
     375                "{:.4g}".format(qmin))) 
    349376            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 
    360382            break 
    361383 
     
    367389            Start a calculation thread 
    368390        """ 
    369         from PrThread import CalcPr 
     391        from Thread import CalcPr 
    370392 
    371393        # If a thread is already started, stop it 
     
    385407            Perform parameter estimation 
    386408        """ 
    387         from PrThread import EstimateNT 
     409        from Thread import EstimateNT 
    388410 
    389411        # If a thread is already started, stop it 
     
    409431            Perform parameter estimation 
    410432        """ 
    411         from PrThread import EstimatePr 
     433        from Thread import EstimatePr 
     434 
     435        self._calculation() 
    412436 
    413437        # If a thread is already started, stop it 
     
    464488        self.model.setItem(WIDGETS.W_COMP_TIME, 
    465489                           QtGui.QStandardItem(str(elapsed))) 
     490        self.PrTabWidget.setCurrentIndex(0) 
    466491        if message: 
    467492            logging.info(message) 
    468             pass 
    469493 
    470494    def _completed(self, out, cov, pr, elapsed): 
     
    481505        # Keep a copy of the last result 
    482506        self._last_calculator = pr.clone() 
    483  
    484         # TODO: Append to data dictionary 
    485         # self._data_list.append({s}) 
    486507 
    487508        # Save Pr invertor 
     
    512533        # Display results tab 
    513534        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 
    516539        # Show I(q) fit 
    517540        # self.show_iq(out, self._calculator) 
     
    524547        """ 
    525548        logging.warning(error) 
    526  
    527     def show_data(self, path=None, data=None, reset=False): 
    528         """ 
    529         Show data read from a file 
    530  
    531         :param path: file path 
    532         :param reset: if True all other plottables will be cleared 
    533  
    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_value 
    540                 raise RuntimeError, status 
    541  
    542             # If the file contains nothing, just return 
    543             if pr is None: 
    544                 raise RuntimeError, "Loaded data is invalid" 
    545  
    546             self._calculator = pr 
    547  
    548         # Make a plot of I(q) data 
    549         if self._calculator.err is None: 
    550             logging.log(self._calculator.err) 
    551         else: 
    552             # TODO: Do something 
    553             pass 
    554         # Get Q range 
    555         #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  
    44from Fitting.FittingPerspective import FittingWindow 
    55from Invariant.InvariantPerspective import InvariantWindow 
    6 from PrInversion.PrInversionPerspective import PrInversionWindow 
     6from Inversion.InversionPerspective import InversionWindow 
    77 
    88PERSPECTIVES = { 
    99    FittingWindow.name: FittingWindow, 
    1010    InvariantWindow.name: InvariantWindow, 
    11     PrInversionWindow.name: PrInversionWindow 
     11    InversionWindow.name: InversionWindow 
    1212} 
Note: See TracChangeset for help on using the changeset viewer.