Changeset 4992ff2 in sasview for src/sas/qtgui/Perspectives/Fitting


Ignore:
Timestamp:
Nov 9, 2017 8:43:07 AM (6 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:
7969b9c
Parents:
7fb471d
git-author:
Piotr Rozyczko <rozyczko@…> (10/30/17 07:50:09)
git-committer:
Piotr Rozyczko <rozyczko@…> (11/09/17 08:43:07)
Message:

Initial, in-progress version. Not really working atm. SASVIEW-787

Location:
src/sas/qtgui/Perspectives/Fitting
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingOptions.py

    • Property mode changed from 100755 to 100644
    rb3e8629 r4992ff2  
    44import types 
    55 
    6 from PyQt4 import QtCore 
    7 from PyQt4 import QtGui 
    8 from PyQt4 import QtWebKit 
     6from PyQt5 import QtCore 
     7from PyQt5 import QtGui 
     8from PyQt5 import QtWidgets 
     9from PyQt5 import QtWebKitWidgets 
    910 
    1011from sas.qtgui.UI import images_rc 
     
    2122 
    2223 
    23 class FittingOptions(QtGui.QDialog, Ui_FittingOptions): 
     24class FittingOptions(QtWidgets.QDialog, Ui_FittingOptions): 
    2425    """ 
    2526    Hard-coded version of the fit options dialog available from BUMPS. 
     
    5253 
    5354        # Handle the Apply button click 
    54         self.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked.connect(self.onApply) 
     55        self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).clicked.connect(self.onApply) 
    5556        # handle the Help button click 
    56         self.buttonBox.button(QtGui.QDialogButtonBox.Help).clicked.connect(self.onHelp) 
     57        self.buttonBox.button(QtWidgets.QDialogButtonBox.Help).clicked.connect(self.onHelp) 
    5758 
    5859        # Handle the combo box changes 
     
    7172 
    7273        # OK has to be initialized to True, after initial validator setup 
    73         self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(True) 
     74        self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 
    7475 
    7576        # Display HTML content 
    76         self.helpView = QtWebKit.QWebView() 
     77        self.helpView = QtWebKitWidgets.QWebView() 
    7778 
    7879    def assignValidators(self): 
     
    104105        if state == QtGui.QValidator.Acceptable: 
    105106            color = '' # default 
    106             self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(True) 
     107            self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 
    107108        else: 
    108109            color = '#fff79a' # yellow 
    109             self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(False) 
     110            self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False) 
    110111 
    111112        sender.setStyleSheet('QLineEdit { background-color: %s }' % color) 
     
    134135 
    135136        # OK has to be reinitialized to True 
    136         self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(True) 
     137        self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 
    137138 
    138139    def onApply(self): 
     
    148149            """ 
    149150            widget = self.widgetFromOption(option) 
    150             new_value = widget.currentText() if isinstance(widget, QtGui.QComboBox) \ 
     151            new_value = widget.currentText() if isinstance(widget, QtWidgets.QComboBox) \ 
    151152                else float(widget.text()) 
    152153            self.config.values[self.current_fitter_id][option] = new_value 
  • src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py

    rb3e8629 r4992ff2  
    11import numpy 
    22 
    3 from PyQt4 import QtCore 
    4 from PyQt4 import QtGui 
     3from PyQt5 import QtCore 
     4from PyQt5 import QtGui 
     5from PyQt5 import QtWidgets 
    56 
    67from bumps import options 
     
    1415#from sas.qtgui.Perspectives.Fitting import ModelUtilities 
    1516 
    16 class FittingWindow(QtGui.QTabWidget): 
     17class FittingWindow(QtWidgets.QTabWidget): 
    1718    """ 
    1819    """ 
    1920    name = "Fitting" # For displaying in the combo box in DataExplorer 
    2021    def __init__(self, parent=None, data=None): 
     22 
    2123        super(FittingWindow, self).__init__() 
    2224 
  • src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py

    rcee5c78 r4992ff2  
    11from copy import deepcopy 
    22 
    3 from PyQt4 import QtGui 
    4 from PyQt4 import QtCore 
     3from PyQt5 import QtCore 
     4from PyQt5 import QtGui 
     5from PyQt5 import QtWidgets 
    56 
    67import numpy 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r7fb471d r4992ff2  
    99import numpy as np 
    1010 
    11 from PyQt4 import QtGui 
    12 from PyQt4 import QtCore 
    13 from PyQt4 import QtWebKit 
     11from PyQt5 import QtCore 
     12from PyQt5 import QtGui 
     13from PyQt5 import QtWidgets 
     14from PyQt5 import QtWebKitWidgets 
    1415 
    1516from sasmodels import product 
     
    7475        return QtGui.QStandardItemModel.headerData(self, section, orientation, role) 
    7576 
    76 class FittingWidget(QtGui.QWidget, Ui_FittingWidgetUI): 
     77class FittingWidget(QtWidgets.QWidget, Ui_FittingWidgetUI): 
    7778    """ 
    7879    Main widget for selecting form and structure factor models 
     
    121122 
    122123        # Display HTML content 
    123         self.helpView = QtWebKit.QWebView() 
     124        self.helpView = QtWebKitWidgets.QWebView() 
    124125 
    125126        # New font to display angstrom symbol 
     
    233234        """ 
    234235        # Options widget 
    235         layout = QtGui.QGridLayout() 
     236        layout = QtWidgets.QGridLayout() 
    236237        self.options_widget = OptionsWidget(self, self.logic) 
    237238        layout.addWidget(self.options_widget) 
     
    239240 
    240241        # Smearing widget 
    241         layout = QtGui.QGridLayout() 
     242        layout = QtWidgets.QGridLayout() 
    242243        self.smearing_widget = SmearingWidget(self) 
    243244        layout.addWidget(self.smearing_widget) 
     
    254255 
    255256        # Magnetic angles explained in one picture 
    256         self.magneticAnglesWidget = QtGui.QWidget() 
    257         labl = QtGui.QLabel(self.magneticAnglesWidget) 
     257        self.magneticAnglesWidget = QtWidgets.QWidget() 
     258        labl = QtWidgets.QLabel(self.magneticAnglesWidget) 
    258259        pixmap = QtGui.QPixmap(GuiUtils.IMAGES_DIRECTORY_LOCATION + '/M_angles_pic.bmp') 
    259260        labl.setPixmap(pixmap) 
     
    274275        self.lstParams.setModel(self._model_model) 
    275276        self.readCategoryInfo() 
     277 
    276278        self.model_parameters = None 
    277279 
     
    307309        self.lstParams.customContextMenuRequested.connect(self.showModelDescription) 
    308310        self.lstParams.setAttribute(QtCore.Qt.WA_MacShowFocusRect, False) 
    309  
    310311        # Poly model displayed in poly list 
    311312        self.lstPoly.setModel(self._poly_model) 
     
    466467            msg += "You must select a model to get information on this" 
    467468 
    468         menu = QtGui.QMenu() 
    469         label = QtGui.QLabel(msg) 
     469        menu = QtWidgets.QMenu() 
     470        label = QtWidgets.QLabel(msg) 
    470471        action = QtGui.QWidgetAction(self) 
    471472        action.setDefaultWidget(label) 
     
    915916        self.lstParams.resizeColumnToContents(4) 
    916917        self.lstParams.resizeColumnToContents(5) 
    917         self.lstParams.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding) 
     918        self.lstParams.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) 
    918919 
    919920        self.has_error_column = True 
     
    12301231        # Adjust the table cells width 
    12311232        self.lstParams.resizeColumnToContents(0) 
    1232         self.lstParams.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding) 
     1233        self.lstParams.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) 
    12331234 
    12341235        # Now we claim the model has been loaded 
     
    15361537        table.verticalHeader().setVisible(False) 
    15371538        table.setAlternatingRowColors(True) 
    1538         table.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding) 
    1539         table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) 
     1539        table.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) 
     1540        table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) 
    15401541        table.resizeColumnsToContents() 
    15411542 
    15421543        # Header 
    15431544        header = table.horizontalHeader() 
    1544         header.setResizeMode(QtGui.QHeaderView.ResizeToContents) 
    1545  
    1546         header.ResizeMode(QtGui.QHeaderView.Interactive) 
     1545        header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) 
     1546        header.ResizeMode(QtWidgets.QHeaderView.Interactive) 
     1547 
     1548        # Qt5: the following 2 lines crash - figure out why! 
    15471549        # Resize column 0 and 7 to content 
    1548         header.setResizeMode(0, QtGui.QHeaderView.ResizeToContents) 
    1549         header.setResizeMode(7, QtGui.QHeaderView.ResizeToContents) 
     1550        #header.setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents) 
     1551        #header.setSectionResizeMode(7, QtWidgets.QHeaderView.ResizeToContents) 
    15501552 
    15511553    def setPolyModel(self): 
     
    16001602 
    16011603        # All possible polydisp. functions as strings in combobox 
    1602         func = QtGui.QComboBox() 
     1604        func = QtWidgets.QComboBox() 
    16031605        func.addItems([str(name_disp) for name_disp in POLYDISPERSITY_MODELS.keys()]) 
    16041606        # Set the default index 
     
    16831685        Show the load file dialog and loads requested data into state 
    16841686        """ 
    1685         datafile = QtGui.QFileDialog.getOpenFileName( 
    1686             self, "Choose a weight file", "", "All files (*.*)", 
    1687             QtGui.QFileDialog.DontUseNativeDialog) 
     1687        datafile = QtWidgets.QFileDialog.getOpenFileName( 
     1688            self, "Choose a weight file", "", "All files (*.*)", None, 
     1689            QtWidgets.QFileDialog.DontUseNativeDialog) 
    16881690 
    16891691        if datafile is None or str(datafile)=='': 
     
    17841786        item1 = QtGui.QStandardItem(param_name) 
    17851787 
    1786         func = QtGui.QComboBox() 
     1788        func = QtWidgets.QComboBox() 
    17871789        # Available range of shells displayed in the combobox 
    17881790        func.addItems([str(i) for i in range(param_length+1)]) 
  • src/sas/qtgui/Perspectives/Fitting/OptionsWidget.py

    • Property mode changed from 100755 to 100644
    rb3e8629 r4992ff2  
    33""" 
    44import numpy as np 
    5 from PyQt4 import QtGui 
    6 from PyQt4 import QtCore 
     5from PyQt5 import QtCore 
     6from PyQt5 import QtGui 
     7from PyQt5 import QtWidgets 
    78 
    89from sas.qtgui.Plotting.PlotterData import Data2D 
     
    2122    'LOG_SPACED'] 
    2223 
    23 class DataWidgetMapper(QtGui.QDataWidgetMapper): 
     24class DataWidgetMapper(QtWidgets.QDataWidgetMapper): 
    2425    """ 
    2526    Custom version of the standard QDataWidgetMapper allowing for proper 
     
    3233            super(DataWidgetMapper, self).addMapping(widget, section, propertyName) 
    3334 
    34         if isinstance(widget, QtGui.QComboBox): 
     35        if isinstance(widget, QtWidgets.QComboBox): 
    3536            delegate = self.itemDelegate() 
    3637            widget.currentIndexChanged.connect(lambda: delegate.commitData.emit(widget)) 
    3738 
    38         elif isinstance(widget, QtGui.QCheckBox): 
     39        elif isinstance(widget, QtWidgets.QCheckBox): 
    3940            delegate = self.itemDelegate() 
    4041            widget.stateChanged.connect(lambda: delegate.commitData.emit(widget)) 
    4142 
    42 class OptionsWidget(QtGui.QWidget, Ui_tabOptions): 
     43class OptionsWidget(QtWidgets.QWidget, Ui_tabOptions): 
    4344    plot_signal = QtCore.pyqtSignal() 
    4445    def __init__(self, parent=None, logic=None): 
     
    5253 
    5354        # Weight radio box group 
    54         self.weightingGroup = QtGui.QButtonGroup() 
     55        self.weightingGroup = QtWidgets.QButtonGroup() 
    5556        self.weighting = 0 
    5657 
     
    114115        self.mapper.addMapping(self.txtNpts,     MODEL.index('NPTS')) 
    115116        self.mapper.addMapping(self.chkLogData,  MODEL.index('LOG_SPACED')) 
    116         self.mapper.toFirst() 
     117        # FIXME DOESNT WORK WITH QT5 
     118        #self.mapper.toFirst() 
    117119 
    118120    def toggleLogData(self, isChecked): 
  • src/sas/qtgui/Perspectives/Fitting/SmearingWidget.py

    • Property mode changed from 100755 to 100644
    rb3e8629 r4992ff2  
    22Widget/logic for smearing data. 
    33""" 
    4 from PyQt4 import QtGui 
    5 from PyQt4 import QtCore 
     4from PyQt5 import QtCore 
     5from PyQt5 import QtGui 
     6from PyQt5 import QtWidgets 
    67 
    78from sas.qtgui.Plotting.PlotterData import Data1D 
     
    1112from sas.qtgui.Perspectives.Fitting.UI.SmearingWidgetUI import Ui_SmearingWidgetUI 
    1213 
    13 class DataWidgetMapper(QtGui.QDataWidgetMapper): 
     14class DataWidgetMapper(QtWidgets.QDataWidgetMapper): 
    1415    """ 
    1516    Custom version of the standard QDataWidgetMapper allowing for proper 
     
    2223            super(DataWidgetMapper, self).addMapping(widget, section, propertyName) 
    2324 
    24         if isinstance(widget, QtGui.QComboBox): 
     25        if isinstance(widget, QtWidgets.QComboBox): 
    2526            delegate = self.itemDelegate() 
    2627            widget.currentIndexChanged.connect(lambda: delegate.commitData.emit(widget)) 
     
    3536    'ACCURACY'] 
    3637 
    37 class SmearingWidget(QtGui.QWidget, Ui_SmearingWidgetUI): 
     38class SmearingWidget(QtWidgets.QWidget, Ui_SmearingWidgetUI): 
    3839    def __init__(self, parent=None): 
    3940        super(SmearingWidget, self).__init__() 
     
    8384        self.mapper.addMapping(self.cbSmearing,   MODEL.index('SMEARING')) 
    8485        self.mapper.addMapping(self.cbAccuracy,   MODEL.index('ACCURACY')) 
    85         self.mapper.toFirst() 
     86 
     87        # FIXME DOESNT WORK WITH QT5 
     88        #self.mapper.toFirst() 
    8689 
    8790    def updateSmearing(self, data=None): 
  • src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py

    r02f1d12 r4992ff2  
    1 from PyQt4 import QtGui 
    2 from PyQt4 import QtCore 
     1from PyQt5 import QtCore 
     2from PyQt5 import QtGui 
     3from PyQt5 import QtWidgets 
    34 
    45import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    56 
    6 class ModelViewDelegate(QtGui.QStyledItemDelegate): 
     7class ModelViewDelegate(QtWidgets.QStyledItemDelegate): 
    78    """ 
    89    Custom delegate for appearance and behavior control of the model view 
     
    1213        Overwrite generic constructor to allow for some globals 
    1314        """ 
    14         super(QtGui.QStyledItemDelegate, self).__init__() 
     15        super(QtWidgets.QStyledItemDelegate, self).__init__() 
    1516 
    1617        # Main parameter table view columns 
     
    4344        if index.column() in self.fancyColumns(): 
    4445            # Units - present in nice HTML 
    45             options = QtGui.QStyleOptionViewItemV4(option) 
     46            #options = QtWidgets.QStyleOptionViewItemV4(option) 
     47            options = QtWidgets.QStyleOptionViewItem(option) 
    4648            self.initStyleOption(options,index) 
    4749 
     
    5759            # delete the original content 
    5860            options.text = "" 
    59             style.drawControl(QtGui.QStyle.CE_ItemViewItem, options, painter, options.widget); 
     61            style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter, options.widget); 
    6062 
    6163            context = QtGui.QAbstractTextDocumentLayout.PaintContext() 
    62             textRect = style.subElementRect(QtGui.QStyle.SE_ItemViewItemText, options) 
     64            textRect = style.subElementRect(QtWidgets.QStyle.SE_ItemViewItemText, options) 
    6365 
    6466            painter.save() 
     
    7072        else: 
    7173            # Just the default paint 
    72             QtGui.QStyledItemDelegate.paint(self, painter, option, index) 
     74            QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) 
    7375 
    7476    def createEditor(self, widget, option, index): 
     
    7981            return 0 
    8082        if index.column() == self.param_value: #only in the value column 
    81             editor = QtGui.QLineEdit(widget) 
     83            editor = QtWidgets.QLineEdit(widget) 
    8284            validator = QtGui.QDoubleValidator() 
    8385            editor.setValidator(validator) 
     
    100102                # balloon popup? tooltip? cell background colour flash? 
    101103                return 
    102         QtGui.QStyledItemDelegate.setModelData(self, editor, model, index) 
    103  
    104  
    105 class PolyViewDelegate(QtGui.QStyledItemDelegate): 
     104        QtWidgets.QStyledItemDelegate.setModelData(self, editor, model, index) 
     105 
     106 
     107class PolyViewDelegate(QtWidgets.QStyledItemDelegate): 
    106108    """ 
    107109    Custom delegate for appearance and behavior control of the polydispersity view 
     
    116118        Overwrite generic constructor to allow for some globals 
    117119        """ 
    118         super(QtGui.QStyledItemDelegate, self).__init__() 
     120        super(QtWidgets.QStyledItemDelegate, self).__init__() 
    119121 
    120122        self.poly_parameter = 0 
     
    160162            return None 
    161163        elif index.column() in self.editableParameters(): 
    162             self.editor = QtGui.QLineEdit(widget) 
     164            self.editor = QtWidgets.QLineEdit(widget) 
    163165            validator = QtGui.QDoubleValidator() 
    164166            self.editor.setValidator(validator) 
    165167            return self.editor 
    166168        else: 
    167             QtGui.QStyledItemDelegate.createEditor(self, widget, option, index) 
     169            QtWidgets.QStyledItemDelegate.createEditor(self, widget, option, index) 
    168170 
    169171    def paint(self, painter, option, index): 
     
    173175        if index.column() in (self.poly_min, self.poly_max): 
    174176            # Units - present in nice HTML 
    175             options = QtGui.QStyleOptionViewItemV4(option) 
     177            options = QtWidgets.QStyleOptionViewItem(option) 
    176178            self.initStyleOption(options,index) 
    177179 
     
    187189            # delete the original content 
    188190            options.text = "" 
    189             style.drawControl(QtGui.QStyle.CE_ItemViewItem, options, painter, options.widget); 
     191            style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter, options.widget); 
    190192 
    191193            context = QtGui.QAbstractTextDocumentLayout.PaintContext() 
    192             textRect = style.subElementRect(QtGui.QStyle.SE_ItemViewItemText, options) 
     194            textRect = style.subElementRect(QtWidgets.QStyle.SE_ItemViewItemText, options) 
    193195 
    194196            painter.save() 
     
    200202        else: 
    201203            # Just the default paint 
    202             QtGui.QStyledItemDelegate.paint(self, painter, option, index) 
    203  
    204 class MagnetismViewDelegate(QtGui.QStyledItemDelegate): 
     204            QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) 
     205 
     206class MagnetismViewDelegate(QtWidgets.QStyledItemDelegate): 
    205207    """ 
    206208    Custom delegate for appearance and behavior control of the magnetism view 
     
    210212        Overwrite generic constructor to allow for some globals 
    211213        """ 
    212         super(QtGui.QStyledItemDelegate, self).__init__() 
     214        super(QtWidgets.QStyledItemDelegate, self).__init__() 
    213215 
    214216        self.mag_parameter = 0 
     
    238240            return 0 
    239241        if index.column() in self.editableParameters(): 
    240             editor = QtGui.QLineEdit(widget) 
     242            editor = QtWidgets.QLineEdit(widget) 
    241243            validator = QtGui.QDoubleValidator() 
    242244            editor.setValidator(validator) 
    243245            return editor 
    244246        else: 
    245             QtGui.QStyledItemDelegate.createEditor(self, widget, option, index) 
     247            QtWidgets.QStyledItemDelegate.createEditor(self, widget, option, index) 
    246248 
    247249    def paint(self, painter, option, index): 
     
    251253        if index.column() in (self.mag_min, self.mag_max, self.mag_unit): 
    252254            # Units - present in nice HTML 
    253             options = QtGui.QStyleOptionViewItemV4(option) 
     255            options = QtWidgets.QStyleOptionViewItem(option) 
    254256            self.initStyleOption(options,index) 
    255257 
     
    265267            # delete the original content 
    266268            options.text = "" 
    267             style.drawControl(QtGui.QStyle.CE_ItemViewItem, options, painter, options.widget); 
     269            style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter, options.widget); 
    268270 
    269271            context = QtGui.QAbstractTextDocumentLayout.PaintContext() 
    270             textRect = style.subElementRect(QtGui.QStyle.SE_ItemViewItemText, options) 
     272            textRect = style.subElementRect(QtWidgets.QStyle.SE_ItemViewItemText, options) 
    271273 
    272274            painter.save() 
     
    278280        else: 
    279281            # Just the default paint 
    280             QtGui.QStyledItemDelegate.paint(self, painter, option, index) 
     282            QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) 
Note: See TracChangeset for help on using the changeset viewer.