Changeset 83d6249 in sasview for src/sas


Ignore:
Timestamp:
Feb 16, 2017 8:06:17 AM (8 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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:
2bb20a5, fca1f50
Parents:
4c7dd9f
Message:

Perspectives are now switchable and can be added "dynamically"

Location:
src/sas/qtgui
Files:
3 added
5 edited
2 moved

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/DataExplorer.py

    r965fbd8 r83d6249  
    6565        self._helpView = QtWebKit.QWebView() 
    6666 
     67        # Fill in the perspectives combo 
     68        self.initPerspectives() 
     69 
    6770        # Custom context menu 
    6871        self.treeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) 
     
    125128        self.cbgraph.setEnabled(len(PlotHelper.currentPlots()) > 0) 
    126129        self.cmdAppend.setEnabled(len(PlotHelper.currentPlots()) > 0) 
     130 
     131    def initPerspectives(self): 
     132        """ 
     133        Populate the Perspective combobox and define callbacks 
     134        """ 
     135        self.cbFitting.currentIndexChanged.connect(self.updatePerspectiveCombo) 
     136        # Set the index so we see the default (Fitting) 
     137        self.updatePerspectiveCombo(0) 
    127138 
    128139    def loadFromURL(self, url): 
     
    389400            self.cbgraph.setCurrentIndex(ind) 
    390401 
     402    def updatePerspectiveCombo(self, index): 
     403        """ 
     404        Notify the gui manager about the new perspective chosen. 
     405        """ 
     406        self.communicator.perspectiveChangedSignal.emit(self.cbFitting.currentText()) 
     407 
    391408    def newPlot(self): 
    392409        """ 
  • src/sas/qtgui/GuiManager.py

    r257bd57 r83d6249  
    2929 
    3030# Perspectives 
     31import Perspectives 
    3132from sas.qtgui.Perspectives.Invariant.InvariantPerspective import InvariantWindow 
     33from sas.qtgui.Perspectives.Fitting.FittingPerspective import FittingWindow 
    3234from sas.qtgui.DataExplorer import DataExplorerWindow 
    3335 
     
    98100                                              "_downloads", 
    99101                                              "Tutorial.pdf")) 
    100  
    101         #========================================================== 
    102         # TEMP PROTOTYPE 
    103         # Add InvariantWindow to the workspace. 
    104         self.invariantWidget = InvariantWindow(self) 
    105         self._workspace.workspace.addWindow(self.invariantWidget) 
    106  
    107         # Default perspective 
    108         self._current_perspective = self.invariantWidget 
     102        # Current displayed perspective 
     103        self._current_perspective = None 
     104 
     105        # Invoke the initial perspective 
     106        self.perspectiveChanged("Fitting") 
    109107 
    110108    def addWidgets(self): 
     
    120118        self.dockedFilesWidget = QtGui.QDockWidget("Data Explorer", self._workspace) 
    121119        self.dockedFilesWidget.setWidget(self.filesWidget) 
     120 
    122121        # Disable maximize/minimize and close buttons 
    123122        self.dockedFilesWidget.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures) 
     
    143142        self.KIESSIGCalculator = KiessigPanel(self) 
    144143        self.SlitSizeCalculator = SlitSizeCalculator(self) 
     144 
    145145    def statusBarSetup(self): 
    146146        """ 
     
    173173        """ 
    174174        return self._workspace.workspace 
     175 
     176    def perspectiveChanged(self, perspective_name): 
     177        """ 
     178        Respond to change of the perspective signal 
     179        """ 
     180        # Close the previous perspective 
     181        if self._current_perspective: 
     182            self._current_perspective.close() 
     183        # Default perspective 
     184        self._current_perspective = Perspectives.PERSPECTIVES[str(perspective_name)](self) 
     185        self._workspace.workspace.addWindow(self._current_perspective) 
     186        self._current_perspective.show() 
    175187 
    176188    def updatePerspective(self, data): 
     
    322334        self.communicate.updatePerspectiveWithDataSignal.connect(self.updatePerspective) 
    323335        self.communicate.progressBarUpdateSignal.connect(self.updateProgressBar) 
     336        self.communicate.perspectiveChangedSignal.connect(self.perspectiveChanged) 
    324337 
    325338    def addTriggers(self): 
  • src/sas/qtgui/GuiUtils.py

    r3bdbfcc r83d6249  
    233233    # Current workspace chart's name changed 
    234234    activeGraphName = QtCore.pyqtSignal(tuple) 
     235 
     236    # Current perspective changed 
     237    perspectiveChangedSignal = QtCore.pyqtSignal(str) 
    235238 
    236239 
  • src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py

    r4c7dd9f r83d6249  
    33from PyQt4 import QtCore 
    44 
    5 from UI.fitting import Ui_Dialog 
     5from UI.FittingUI import Ui_FittingUI 
    66 
    7 class prototype(QtGui.QDialog, Ui_Dialog): 
    8     def __init__(self): 
    9         super(prototype, self).__init__() 
     7class FittingWindow(QtGui.QDialog, Ui_FittingUI): 
     8    name = "Fitting" # For displaying in the combo box 
     9    def __init__(self, manager=None, parent=None): 
     10        super(FittingWindow, self).__init__() 
    1011        self._model_model = QtGui.QStandardItemModel() 
    1112        self._poly_model = QtGui.QStandardItemModel() 
     
    146147if __name__ == "__main__": 
    147148    app = QtGui.QApplication([]) 
    148     dlg = prototype() 
     149    dlg = FittingWindow() 
    149150    dlg.show() 
    150151    sys.exit(app.exec_()) 
  • src/sas/qtgui/Perspectives/Fitting/UI/FittingUI.ui

    r4c7dd9f r83d6249  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<ui version="4.0"> 
    3  <class>Dialog</class> 
    4  <widget class="QDialog" name="Dialog"> 
     3 <class>FittingUI</class> 
     4 <widget class="QDialog" name="FittingUI"> 
    55  <property name="geometry"> 
    66   <rect> 
     
    1212  </property> 
    1313  <property name="windowTitle"> 
    14    <string>Dialog</string> 
     14   <string>Fitting Perspective</string> 
     15  </property> 
     16  <property name="windowIcon"> 
     17   <iconset resource="../../../UI/main_resources.qrc"> 
     18    <normaloff>:/res/ball.ico</normaloff>:/res/ball.ico</iconset> 
    1519  </property> 
    1620  <layout class="QGridLayout" name="gridLayout_15"> 
     
    664668  </layout> 
    665669 </widget> 
    666  <resources/> 
     670 <resources> 
     671  <include location="../../../UI/main_resources.qrc"/> 
     672 </resources> 
    667673 <connections/> 
    668674</ui> 
  • src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py

    rb789967 r83d6249  
    3939    # The controller which is responsible for managing signal slots connections 
    4040    # for the gui and providing an interface to the data model. 
     41    name = "Invariant" # For displaying in the combo box 
    4142    def __init__(self, manager=None, parent=None): 
    4243        super(InvariantWindow, self).__init__(parent) 
     
    102103        self.setupMapper() 
    103104 
    104     def closeEvent(self, event): 
    105         """ 
    106         Overwrite the default close method of QWidget 
    107         """ 
    108         # No close on perspectives - one must always be active. 
    109         event.ignore() 
     105    #def closeEvent(self, event): 
     106    #    """ 
     107    #    Overwrite the default close method of QWidget 
     108    #    """ 
     109    #    # No close on perspectives - one must always be active. 
     110    #    event.ignore() 
    110111 
    111112    def communicator(self): 
  • src/sas/qtgui/Perspectives/__init__.py

    • Property mode changed from 100755 to 100644
    rf721030 r83d6249  
     1# Available perspectives. 
     2# When adding a new perspective, this dictionary needs to be updated 
     3 
     4from Fitting.FittingPerspective import FittingWindow 
     5from Invariant.InvariantPerspective import InvariantWindow 
     6 
     7PERSPECTIVES = { 
     8    FittingWindow.name: FittingWindow, 
     9    InvariantWindow.name: InvariantWindow, 
     10} 
Note: See TracChangeset for help on using the changeset viewer.