Changeset 2a432e7 in sasview


Ignore:
Timestamp:
May 17, 2017 1:17:36 AM (7 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:
dc5ef15
Parents:
00b3b40
Message:

Minor refactoring + improvements to fitting views

Location:
src/sas/qtgui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/MainWindow/GuiManager.py

    rd48cc19 r2a432e7  
    1919import sas.qtgui.Utilities.LocalConfig as LocalConfig 
    2020import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     21import sas.qtgui.Utilities.ObjectLibrary as ObjectLibrary 
    2122 
    2223from sas.qtgui.MainWindow.UI.AcknowledgementsUI import Ui_Acknowledgements 
     
    113114        # Add FileDialog widget as docked 
    114115        self.filesWidget = DataExplorerWindow(self._parent, self, manager=self._data_manager) 
     116        ObjectLibrary.addObject('DataExplorer', self.filesWidget) 
    115117 
    116118        self.dockedFilesWidget = QtGui.QDockWidget("Data Explorer", self._workspace) 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r00b3b40 r2a432e7  
    5252        # Necessary globals 
    5353        self.parent = parent 
     54 
     55        # Which tab is this widget displayed in? 
     56        self.tab_id = tab_id 
     57 
     58        # Main Data[12]D holder 
     59        self.logic = FittingLogic(data=data) 
     60 
     61        # Globals 
     62        self.initializeGlobals() 
     63 
     64        # Main GUI setup up 
     65        self.setupUi(self) 
     66        self.setWindowTitle("Fitting") 
     67 
     68        # Set up tabs widgets 
     69        self.initializeWidgets() 
     70 
     71        # Set up models and views 
     72        self.initializeModels() 
     73 
     74        # Defaults for the structure factors 
     75        self.setDefaultStructureCombo() 
     76 
     77        # Make structure factor and model CBs disabled 
     78        self.disableModelCombo() 
     79        self.disableStructureCombo() 
     80 
     81        # Generate the category list for display 
     82        self.initializeCategoryCombo() 
     83 
     84        # Connect signals to controls 
     85        self.initializeSignals() 
     86 
     87        # Initial control state 
     88        self.initializeControls() 
     89 
     90        # Display HTML content 
     91        self.helpView = QtWebKit.QWebView() 
     92 
     93        self._index = None 
     94        if data is not None: 
     95            self.data = data 
     96 
     97    def close(self): 
     98        """ 
     99        Remember to kill off things on exit 
     100        """ 
     101        self.helpView.close() 
     102        del self.helpView 
     103 
     104    @property 
     105    def data(self): 
     106        return self.logic.data 
     107 
     108    @data.setter 
     109    def data(self, value): 
     110        """ data setter """ 
     111        assert isinstance(value, QtGui.QStandardItem) 
     112        # _index contains the QIndex with data 
     113        self._index = value 
     114 
     115        # Update logics with data items 
     116        self.logic.data = GuiUtils.dataFromItem(value) 
     117 
     118        # Overwrite data type descriptor 
     119        self.is2D = True if isinstance(self.logic.data, Data2D) else False 
     120 
     121        self.data_is_loaded = True 
     122 
     123        # Enable/disable UI components 
     124        self.setEnablementOnDataLoad() 
     125 
     126    def initializeGlobals(self): 
     127        """ 
     128        Initialize global variables used in this class 
     129        """ 
    54130        # SasModel is loaded 
    55131        self.model_is_loaded = False 
     
    77153        self.weighting = 0 
    78154        self.chi2 = None 
    79  
    80155        # Does the control support UNDO/REDO 
    81156        # temporarily off 
     
    86161        self.model_data = None 
    87162 
    88         # Which tab is this widget displayed in? 
    89         self.tab_id = tab_id 
    90  
    91163        # Which shell is being currently displayed? 
    92164        self.current_shell_displayed = 0 
    93165        self.has_error_column = False 
    94166 
    95         # Main Data[12]D holder 
    96         self.logic = FittingLogic(data=data) 
    97  
    98         # Main GUI setup up 
    99         self.setupUi(self) 
    100         self.setWindowTitle("Fitting") 
     167        # signal communicator 
    101168        self.communicate = self.parent.communicate 
    102169 
     170    def initializeWidgets(self): 
     171        """ 
     172        Initialize widgets for tabs 
     173        """ 
    103174        # Options widget 
    104175        layout = QtGui.QGridLayout() 
     
    122193        self.lblFilename.setText("") 
    123194 
     195    def initializeModels(self): 
     196        """ 
     197        Set up models and views 
     198        """ 
    124199        # Set the main models 
    125200        # We can't use a single model here, due to restrictions on flattening 
     
    139214        self.lstParams.setAlternatingRowColors(True) 
    140215        stylesheet = """ 
    141             QTreeView{ 
    142                 alternate-background-color: #f6fafb; 
    143                 background: #e8f4fc; 
     216            QTreeView::item:hover { 
     217                background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1); 
     218                border: 1px solid #bfcde4; 
    144219            } 
    145         """ 
     220 
     221            QTreeView::item:selected { 
     222                border: 1px solid #567dbc; 
     223            } 
     224 
     225            QTreeView::item:selected:active{ 
     226                background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc); 
     227            } 
     228 
     229            QTreeView::item:selected:!active { 
     230                background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf); 
     231            } 
     232           """ 
    146233        self.lstParams.setStyleSheet(stylesheet) 
    147234        self.lstParams.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) 
     
    160247        self.setTableProperties(self.lstMagnetic) 
    161248 
    162         # Defaults for the structure factors 
    163         self.setDefaultStructureCombo() 
    164  
    165         # Make structure factor and model CBs disabled 
    166         self.disableModelCombo() 
    167         self.disableStructureCombo() 
    168  
    169         # Generate the category list for display 
     249    def initializeCategoryCombo(self): 
     250        """ 
     251        Model category combo setup 
     252        """ 
    170253        category_list = sorted(self.master_category_dict.keys()) 
    171254        self.cbCategory.addItem(CATEGORY_DEFAULT) 
     
    173256        self.cbCategory.addItem(CATEGORY_STRUCTURE) 
    174257        self.cbCategory.setCurrentIndex(0) 
    175  
    176         # Connect signals to controls 
    177         self.initializeSignals() 
    178  
    179         # Initial control state 
    180         self.initializeControls() 
    181  
    182         # Display HTML content 
    183         self.helpView = QtWebKit.QWebView() 
    184  
    185         self._index = None 
    186         if data is not None: 
    187             self.data = data 
    188  
    189     def close(self): 
    190         """ 
    191         Remember to kill off things on exit 
    192         """ 
    193         self.helpView.close() 
    194         del self.helpView 
    195  
    196     @property 
    197     def data(self): 
    198         return self.logic.data 
    199  
    200     @data.setter 
    201     def data(self, value): 
    202         """ data setter """ 
    203         assert isinstance(value, QtGui.QStandardItem) 
    204         # _index contains the QIndex with data 
    205         self._index = value 
    206  
    207         # Update logics with data items 
    208         self.logic.data = GuiUtils.dataFromItem(value) 
    209  
    210         # Overwrite data type descriptor 
    211         self.is2D = True if isinstance(self.logic.data, Data2D) else False 
    212  
    213         self.data_is_loaded = True 
    214  
    215         # Enable/disable UI components 
    216         self.setEnablementOnDataLoad() 
    217258 
    218259    def setEnablementOnDataLoad(self): 
  • src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py

    r00b3b40 r2a432e7  
    3535            options = QtGui.QStyleOptionViewItemV4(option) 
    3636            self.initStyleOption(options,index) 
     37 
    3738            style = QtGui.QApplication.style() if options.widget is None else options.widget.style() 
    3839 
     
    4647            # delete the original content 
    4748            options.text = "" 
    48             style.drawControl(QtGui.QStyle.CE_ItemViewItem, options, painter); 
     49            style.drawControl(QtGui.QStyle.CE_ItemViewItem, options, painter, options.widget); 
    4950 
    5051            context = QtGui.QAbstractTextDocumentLayout.PaintContext() 
     
    5657            # Draw the QTextDocument in the cell 
    5758            doc.documentLayout().draw(painter, context) 
    58  
    5959            painter.restore() 
    6060        else: 
Note: See TracChangeset for help on using the changeset viewer.