Example #1
0
    def __init__(self, parent=None, plot=None):
        TableWidget.__init__(self, parent)
        _StatsWidgetBase.__init__(self,
                                  statsOnVisibleData=False,
                                  displayOnlyActItem=False)

        # Init for _displayOnlyActItem == False
        assert self._displayOnlyActItem is False
        self.setSelectionBehavior(qt.QAbstractItemView.SelectRows)
        self.setSelectionMode(qt.QAbstractItemView.SingleSelection)
        self.currentItemChanged.connect(self._currentItemChanged)

        self.setRowCount(0)
        self.setColumnCount(2)

        # Init headers
        headerItem = qt.QTableWidgetItem('Legend')
        headerItem.setData(qt.Qt.UserRole, self._LEGEND_HEADER_DATA)
        self.setHorizontalHeaderItem(0, headerItem)
        headerItem = qt.QTableWidgetItem('Kind')
        headerItem.setData(qt.Qt.UserRole, self._KIND_HEADER_DATA)
        self.setHorizontalHeaderItem(1, headerItem)

        self.setSortingEnabled(True)
        self.setPlot(plot)
Example #2
0
    def __init__(self, parent, plot):
        TableWidget.__init__(self, parent)
        _StatsWidgetBase.__init__(self,
                                  statsOnVisibleData=False,
                                  displayOnlyActItem=False)
        self.__region_edition_callback = {}
        """We need to keep trace of the roi signals connection because
        the roi emits the sigChanged during roi edition"""
        self._items = {}
        self.setRowCount(0)
        self.setColumnCount(3)

        # Init headers
        headerItem = qt.QTableWidgetItem(self._LEGEND_HEADER_DATA.title())
        headerItem.setData(qt.Qt.UserRole, self._LEGEND_HEADER_DATA)
        self.setHorizontalHeaderItem(0, headerItem)
        headerItem = qt.QTableWidgetItem(self._KIND_HEADER_DATA.title())
        headerItem.setData(qt.Qt.UserRole, self._KIND_HEADER_DATA)
        self.setHorizontalHeaderItem(1, headerItem)
        headerItem = qt.QTableWidgetItem(self._ROI_HEADER_DATA.title())
        headerItem.setData(qt.Qt.UserRole, self._ROI_HEADER_DATA)
        self.setHorizontalHeaderItem(2, headerItem)

        self.setSortingEnabled(True)
        self.setPlot(plot)

        self.__plotItemToItems = {}
        """Key is plotItem, values is list of __RoiStatsItemWidget"""
        self.__roiToItems = {}
        """Key is roi, values is list of __RoiStatsItemWidget"""
        self.__roisKeyToRoi = {}
Example #3
0
    def __init__(self, parent=None, plot=None):
        TableWidget.__init__(self, parent)
        """Next freeID for the curve"""
        self.plot = None
        self._displayOnlyActItem = False
        self._statsOnVisibleData = False
        self._lgdAndKindToItems = {}
        """Associate to a tuple(legend, kind) the items legend"""
        self.callbackImage = None
        self.callbackScatter = None
        self.callbackCurve = None
        """Associate the curve legend to his first item"""
        self._statsHandler = None
        self._legendsSet = []
        """list of legends actually displayed"""
        self._resetColumns()

        self.setColumnCount(len(self._columns))
        self.setSelectionBehavior(qt.QAbstractItemView.SelectRows)
        self.setPlot(plot)
        self.setSortingEnabled(True)
Example #4
0
    def __init__(self, parent=None, plot=None):
        TableWidget.__init__(self, parent)
        """Next freeID for the curve"""
        self.plot = None
        self._displayOnlyActItem = False
        self._statsOnVisibleData = False
        self._lgdAndKindToItems = {}
        """Associate to a tuple(legend, kind) the items legend"""
        self.callbackImage = None
        self.callbackScatter = None
        self.callbackCurve = None
        """Associate the curve legend to his first item"""
        self._statsHandler = None
        self._legendsSet = []
        """list of legends actually displayed"""
        self._resetColumns()

        self.setColumnCount(len(self._columns))
        self.setSelectionBehavior(qt.QAbstractItemView.SelectRows)
        self.setPlot(plot)
        self.setSortingEnabled(True)
Example #5
0
    def __init__(self, parent=None, plot=None):
        TableWidget.__init__(self, parent)
        _StatsWidgetBase.__init__(self, statsOnVisibleData=False,
                                  displayOnlyActItem=False)

        # Init for _displayOnlyActItem == False
        assert self._displayOnlyActItem is False
        self.setSelectionBehavior(qt.QAbstractItemView.SelectRows)
        self.setSelectionMode(qt.QAbstractItemView.SingleSelection)
        self.currentItemChanged.connect(self._currentItemChanged)

        self.setRowCount(0)
        self.setColumnCount(2)

        # Init headers
        headerItem = qt.QTableWidgetItem('Legend')
        headerItem.setData(qt.Qt.UserRole, self._LEGEND_HEADER_DATA)
        self.setHorizontalHeaderItem(0, headerItem)
        headerItem = qt.QTableWidgetItem('Kind')
        headerItem.setData(qt.Qt.UserRole, self._KIND_HEADER_DATA)
        self.setHorizontalHeaderItem(1, headerItem)

        self.setSortingEnabled(True)
        self.setPlot(plot)
Example #6
0
 def __init__(self, parent, numRows, numColumns, legList, motList):
     TableWidget.__init__(self, parent)
     self.setRowCount(0)
     self.setColumnCount(numColumns)
     self.currentComboBox = 1
     self.legendsList = legList
     self.motorsList = motList
     self.motorNamesList = self.getAllMotorNames()
     self.motorNamesList.sort()
     self.infoDict = dict(zip(self.legendsList, self.motorsList))
     self.header = MotorInfoHeader(self)
     self.setHorizontalHeader(self.header)
     self.setHorizontalHeaderItem(0, qt.QTableWidgetItem('Legend'))
     self.setSortingEnabled(True)
     self.verticalHeader().hide()
     self.setSelectionBehavior(qt.QAbstractItemView.SelectRows)
     self.setShowGrid(False)
     for idx in range(len(self.legendsList)):
         curveLegend = self.legendsList[idx]
         self.insertRow(idx)
         self.setItem(idx, 0, curveLegend)
         for jdx in range(1, self.columnCount()):
             self.setItem(0, jdx, '')
     self.sortByColumn(0, qt.Qt.AscendingOrder)
Example #7
0
 def __init__(self, parent, numRows, numColumns, legList, motList):
     TableWidget.__init__(self, parent)
     self.setRowCount(0)
     self.setColumnCount(numColumns)
     self.currentComboBox = 1
     self.legendsList = legList
     self.motorsList  = motList
     self.motorNamesList = self.getAllMotorNames()
     self.motorNamesList.sort()
     self.infoDict = dict( zip( self.legendsList, self.motorsList ) )
     self.header = MotorInfoHeader(self)
     self.setHorizontalHeader(self.header)
     self.setHorizontalHeaderItem(0, qt.QTableWidgetItem('Legend'))
     self.setSortingEnabled(True)
     self.verticalHeader().hide()
     self.setSelectionBehavior(qt.QAbstractItemView.SelectRows)
     self.setShowGrid(False)
     for idx in range(len(self.legendsList)):
         curveLegend = self.legendsList[idx]
         self.insertRow(idx)
         self.setItem(idx, 0, curveLegend )
         for jdx in range(1, self.columnCount()):
             self.setItem(0, jdx, '')
     self.sortByColumn(0, qt.Qt.AscendingOrder)
Example #8
0
 def __init__(self, parent=None):
     TableWidget.__init__(self, parent)
     self.clear()
Example #9
0
 def __init__(self, parent=None):
     TableWidget.__init__(self, parent)
     self.clear()
Example #10
0
    def __init__(self, parent=None, paramlist=None):
        TableWidget.__init__(self, parent)
        self.setContentsMargins(0, 0, 0, 0)

        labels = ['Parameter', 'Estimation', 'Fit Value', 'Sigma',
                  'Constraints', 'Min/Parame', 'Max/Factor/Delta']
        tooltips = ["Fit parameter name",
                    "Estimated value for fit parameter. You can edit this column.",
                    "Actual value for parameter, after fit",
                    "Uncertainty (same unit as the parameter)",
                    "Constraint to be applied to the parameter for fit",
                    "First parameter for constraint (name of another param or min value)",
                    "Second parameter for constraint (max value, or factor/delta)"]

        self.columnKeys = ['name', 'estimation', 'fitresult',
                           'sigma', 'code', 'val1', 'val2']
        """This list assigns shorter keys to refer to columns than the
        displayed labels."""

        self.__configuring = False

        # column headers and associated tooltips
        self.setColumnCount(len(labels))

        for i, label in enumerate(labels):
            item = self.horizontalHeaderItem(i)
            if item is None:
                item = qt.QTableWidgetItem(label,
                                           qt.QTableWidgetItem.Type)
                self.setHorizontalHeaderItem(i, item)

            item.setText(label)
            if tooltips is not None:
                item.setToolTip(tooltips[i])

        # resize columns
        for col_key in ["name", "estimation", "sigma", "val1", "val2"]:
            col_idx = self.columnIndexByField(col_key)
            self.resizeColumnToContents(col_idx)

        # Initialize the table with one line per supplied parameter
        paramlist = paramlist if paramlist is not None else []
        self.parameters = OrderedDict()
        """This attribute stores all the data in an ordered dictionary.
        New data can be added using :meth:`newParameterLine`.
        Existing data can be modified using :meth:`configureLine`

        Keys of the dictionary are:

            -  'name': parameter name
            -  'line': line index for the parameter in the table
            -  'estimation'
            -  'fitresult'
            -  'sigma'
            -  'code': constraint code (one of the elements of
                :attr:`code_options`)
            -  'val1': first parameter related to constraint, formatted
                as a string, as typed in the table
            -  'val2': second parameter related to constraint, formatted
                as a string, as typed in the table
            -  'cons1': scalar representation of 'val1'
                (e.g. when val1 is the name of a fit parameter, cons1
                will be the line index of this parameter)
            -  'cons2': scalar representation of 'val2'
            -  'vmin': equal to 'val1' when 'code' is "QUOTED"
            -  'vmax': equal to 'val2' when 'code' is "QUOTED"
            -  'relatedto': name of related parameter when this parameter
                is constrained to another parameter (same as 'val1')
            -  'factor': same as 'val2' when 'code' is 'FACTOR'
            -  'delta': same as 'val2' when 'code' is 'DELTA'
            -  'sum': same as 'val2' when 'code' is 'SUM'
            -  'group': group index for the parameter
            -  'xmin': data range minimum
            -  'xmax': data range maximum
        """
        for line, param in enumerate(paramlist):
            self.newParameterLine(param, line)

        self.code_options = ["FREE", "POSITIVE", "QUOTED", "FIXED",
                             "FACTOR", "DELTA", "SUM", "IGNORE", "ADD"]
        """Possible values in the combo boxes in the 'Constraints' column.
        """

        # connect signal
        self.cellChanged[int, int].connect(self.onCellChanged)
    def __init__(self, parent=None, paramlist=None):
        TableWidget.__init__(self, parent)
        self.setContentsMargins(0, 0, 0, 0)

        labels = [
            'Parameter', 'Estimation', 'Fit Value', 'Sigma', 'Constraints',
            'Min/Parame', 'Max/Factor/Delta'
        ]
        tooltips = [
            "Fit parameter name",
            "Estimated value for fit parameter. You can edit this column.",
            "Actual value for parameter, after fit",
            "Uncertainty (same unit as the parameter)",
            "Constraint to be applied to the parameter for fit",
            "First parameter for constraint (name of another param or min value)",
            "Second parameter for constraint (max value, or factor/delta)"
        ]

        self.columnKeys = [
            'name', 'estimation', 'fitresult', 'sigma', 'code', 'val1', 'val2'
        ]
        """This list assigns shorter keys to refer to columns than the
        displayed labels."""

        self.__configuring = False

        # column headers and associated tooltips
        self.setColumnCount(len(labels))

        for i, label in enumerate(labels):
            item = self.horizontalHeaderItem(i)
            if item is None:
                item = qt.QTableWidgetItem(label, qt.QTableWidgetItem.Type)
                self.setHorizontalHeaderItem(i, item)

            item.setText(label)
            if tooltips is not None:
                item.setToolTip(tooltips[i])

        # resize columns
        for col_key in ["name", "estimation", "sigma", "val1", "val2"]:
            col_idx = self.columnIndexByField(col_key)
            self.resizeColumnToContents(col_idx)

        # Initialize the table with one line per supplied parameter
        paramlist = paramlist if paramlist is not None else []
        self.parameters = OrderedDict()
        """This attribute stores all the data in an ordered dictionary.
        New data can be added using :meth:`newParameterLine`.
        Existing data can be modified using :meth:`configureLine`

        Keys of the dictionary are:

            -  'name': parameter name
            -  'line': line index for the parameter in the table
            -  'estimation'
            -  'fitresult'
            -  'sigma'
            -  'code': constraint code (one of the elements of
                :attr:`code_options`)
            -  'val1': first parameter related to constraint, formatted
                as a string, as typed in the table
            -  'val2': second parameter related to constraint, formatted
                as a string, as typed in the table
            -  'cons1': scalar representation of 'val1'
                (e.g. when val1 is the name of a fit parameter, cons1
                will be the line index of this parameter)
            -  'cons2': scalar representation of 'val2'
            -  'vmin': equal to 'val1' when 'code' is "QUOTED"
            -  'vmax': equal to 'val2' when 'code' is "QUOTED"
            -  'relatedto': name of related parameter when this parameter
                is constrained to another parameter (same as 'val1')
            -  'factor': same as 'val2' when 'code' is 'FACTOR'
            -  'delta': same as 'val2' when 'code' is 'DELTA'
            -  'sum': same as 'val2' when 'code' is 'SUM'
            -  'group': group index for the parameter
            -  'xmin': data range minimum
            -  'xmax': data range maximum
        """
        for line, param in enumerate(paramlist):
            self.newParameterLine(param, line)

        self.code_options = [
            "FREE", "POSITIVE", "QUOTED", "FIXED", "FACTOR", "DELTA", "SUM",
            "IGNORE", "ADD"
        ]
        """Possible values in the combo boxes in the 'Constraints' column.
        """

        # connect signal
        self.cellChanged[int, int].connect(self.onCellChanged)