Example #1
0
 def onPropertyControlChanged(self, *args):
     '''slot called whenever one of the controls is changed '''
     shownprop = self.getShownProperties()
     data = self.model().data
     setData = self.model().setData
     for index in self.selectionModel().partiallySelectedRows():
         prop = data(index, PROPS_ROLE)
         if prop.conflictsWith(shownprop):
             updatedprop = CurveAppearanceProperties.merge(
                 [prop, shownprop], conflict=CurveAppearanceProperties.inConflict_update_a)
             setData(index, updatedprop, PROPS_ROLE)
Example #2
0
 def onPropertyControlChanged(self, *args):
     '''slot called whenever one of the controls is changed '''
     shownprop = self.getShownProperties()
     data = self.model().data
     setData = self.model().setData
     for index in self.selectionModel().partiallySelectedRows():
         prop = data(index, PROPS_ROLE)
         if prop.conflictsWith(shownprop):
             updatedprop = CurveAppearanceProperties.merge(
                 [prop, shownprop],
                 conflict=CurveAppearanceProperties.inConflict_update_a)
             setData(index, updatedprop, PROPS_ROLE)
Example #3
0
 def updateControls(self):
     '''Updates the state of the properties controls to reflect the selection
     '''
     selectedCurves = self.selectionModel().partiallySelectedRows()
     self.showProperties(self._emptyProps)
     if len(selectedCurves) < 1:
         return
     modeldata = self.model().data
     props = [modeldata(index, PROPS_ROLE) for index in selectedCurves]
     mergedprop = CurveAppearanceProperties.merge(
         props, conflict=CurveAppearanceProperties.inConflict_none)
     self.showProperties(mergedprop)
Example #4
0
 def updateControls(self):
     '''Updates the state of the properties controls to reflect the selection
     '''
     selectedCurves = self.selectionModel().partiallySelectedRows()
     self.showProperties(self._emptyProps)
     if len(selectedCurves) < 1:
         return
     modeldata = self.model().data
     props = [modeldata(index, PROPS_ROLE) for index in selectedCurves]
     mergedprop = CurveAppearanceProperties.merge(
         props, conflict=CurveAppearanceProperties.inConflict_none)
     self.showProperties(mergedprop)
Example #5
0
 def __init__(self,
              xsrc='',
              ysrc='',
              properties=None,
              title='',
              vis=Qwt5.QwtPlot.yLeft):
     if properties is None:
         properties = CurveAppearanceProperties()
     self.properties = properties
     self.title = title
     self.vis = vis
     self.x = Component(xsrc)
     self.y = Component(ysrc)
Example #6
0
    def __init__(self, parent=None, designMode=False):
        super(CurvePropertiesView, self).__init__(parent)
        self.loadUi()

        self.ui.sStyleCB.insertItems(0, sorted(NamedSymbolStyles.values()))
        self.ui.lStyleCB.insertItems(0, NamedLineStyles.values())
        self.ui.cStyleCB.insertItems(0, NamedCurveStyles.values())
        self.ui.sColorCB.addItem("")
        self.ui.lColorCB.addItem("")
        for color in NamedColors:
            icon = self._colorIcon(color)
            self.ui.sColorCB.addItem(icon, "", Qt.QVariant(Qt.QColor(color)))
            self.ui.lColorCB.addItem(icon, "", Qt.QVariant(Qt.QColor(color)))

        self._emptyProps = CurveAppearanceProperties()
        self.showProperties(self._emptyProps)

        # Connections
        self.connect(self.ui.sStyleCB,
                     Qt.SIGNAL("currentIndexChanged(const QString&)"),
                     self._onSymbolStyleChanged)
        self.connect(self.ui.sStyleCB, Qt.SIGNAL("currentIndexChanged(int)"),
                     self.onPropertyControlChanged)
        self.connect(self.ui.lStyleCB, Qt.SIGNAL("currentIndexChanged(int)"),
                     self.onPropertyControlChanged)
        self.connect(self.ui.lStyleCB, Qt.SIGNAL("currentIndexChanged(int)"),
                     self.onPropertyControlChanged)
        self.connect(self.ui.lColorCB, Qt.SIGNAL("currentIndexChanged(int)"),
                     self.onPropertyControlChanged)
        self.connect(self.ui.sColorCB, Qt.SIGNAL("currentIndexChanged(int)"),
                     self.onPropertyControlChanged)
        self.connect(self.ui.cStyleCB, Qt.SIGNAL("currentIndexChanged(int)"),
                     self.onPropertyControlChanged)
        self.connect(self.ui.sSizeSB, Qt.SIGNAL("valueChanged(int)"),
                     self.onPropertyControlChanged)
        self.connect(self.ui.lWidthSB, Qt.SIGNAL("valueChanged(int)"),
                     self.onPropertyControlChanged)
        self.connect(self.ui.sFillCB, Qt.SIGNAL("stateChanged(int)"),
                     self.onPropertyControlChanged)
        self.connect(self.ui.cFillCB, Qt.SIGNAL("stateChanged(int)"),
                     self.onPropertyControlChanged)
Example #7
0
    def getShownProperties(self):
        """Returns a copy of the currently shown properties

        :return: (CurveAppearanceProperties)
        """
        prop = CurveAppearanceProperties()
        # get the values from the Style comboboxes. Note that the empty string
        # ("") translates into None
        prop.sStyle = ReverseNamedSymbolStyles[str(
            self.ui.sStyleCB.currentText())]
        prop.lStyle = ReverseNamedLineStyles[str(
            self.ui.lStyleCB.currentText())]
        prop.cStyle = ReverseNamedCurveStyles[str(
            self.ui.cStyleCB.currentText())]
        # get sSize and lWidth from the spinboxes
        prop.sSize = self.ui.sSizeSB.value()
        prop.lWidth = self.ui.lWidthSB.value()
        if prop.sSize < 0:
            prop.sSize = None
        if prop.lWidth < 0:
            prop.lWidth = None
        # Get the Color combo boxes. The item at index 0 is the empty one in
        # the comboboxes
        index = self.ui.sColorCB.currentIndex()
        if index == 0:
            prop.sColor = None
        else:
            prop.sColor = Qt.QColor(self.ui.sColorCB.itemData(index))
        index = self.ui.lColorCB.currentIndex()
        if index == 0:
            prop.lColor = None
        else:
            prop.lColor = Qt.QColor(self.ui.lColorCB.itemData(index))
        # get the sFill from the Checkbox.
        checkState = self.ui.sFillCB.checkState()
        if checkState == Qt.Qt.PartiallyChecked:
            prop.sFill = None
        else:
            prop.sFill = bool(checkState)
        # get the cFill from the Checkbox.
        checkState = self.ui.cFillCB.checkState()
        if checkState == Qt.Qt.PartiallyChecked:
            prop.cFill = None
        else:
            prop.cFill = bool(checkState)
        # store the props
        return copy.deepcopy(prop)
Example #8
0
    def getShownProperties(self):
        """Returns a copy of the currently shown properties

        :return: (CurveAppearanceProperties)
        """
        prop = CurveAppearanceProperties()
        # get the values from the Style comboboxes. Note that the empty string
        # ("") translates into None
        prop.sStyle = ReverseNamedSymbolStyles[
            str(self.ui.sStyleCB.currentText())]
        prop.lStyle = ReverseNamedLineStyles[
            str(self.ui.lStyleCB.currentText())]
        prop.cStyle = ReverseNamedCurveStyles[
            str(self.ui.cStyleCB.currentText())]
        # get sSize and lWidth from the spinboxes
        prop.sSize = self.ui.sSizeSB.value()
        prop.lWidth = self.ui.lWidthSB.value()
        if prop.sSize < 0:
            prop.sSize = None
        if prop.lWidth < 0:
            prop.lWidth = None
        # Get the Color combo boxes. The item at index 0 is the empty one in
        # the comboboxes
        index = self.ui.sColorCB.currentIndex()
        if index == 0:
            prop.sColor = None
        else:
            prop.sColor = Qt.QColor(self.ui.sColorCB.itemData(index))
        index = self.ui.lColorCB.currentIndex()
        if index == 0:
            prop.lColor = None
        else:
            prop.lColor = Qt.QColor(self.ui.lColorCB.itemData(index))
        # get the sFill from the Checkbox.
        checkState = self.ui.sFillCB.checkState()
        if checkState == Qt.Qt.PartiallyChecked:
            prop.sFill = None
        else:
            prop.sFill = bool(checkState)
        # get the cFill from the Checkbox.
        checkState = self.ui.cFillCB.checkState()
        if checkState == Qt.Qt.PartiallyChecked:
            prop.cFill = None
        else:
            prop.cFill = bool(checkState)
        # store the props
        return copy.deepcopy(prop)
Example #9
0
    def _populatePlots(self):
        # Curves appearance
        self._yAppearance = CurveAppearanceProperties(
            sStyle=Qwt5.QwtSymbol.NoSymbol,
            lStyle=Qt.Qt.SolidLine,
            lWidth=2,
            lColor='black',
            cStyle=Qwt5.QwtPlotCurve.Lines,
            yAxis=Qwt5.QwtPlot.yLeft)

        self._correctedAppearance = CurveAppearanceProperties(
            sStyle=Qwt5.QwtSymbol.NoSymbol,
            lStyle=Qt.Qt.DashLine,
            lWidth=1,
            lColor='blue',
            cStyle=Qwt5.QwtPlotCurve.Lines,
            yAxis=Qwt5.QwtPlot.yLeft)

        self._cpointsAppearance = CurveAppearanceProperties(
            sStyle=Qwt5.QwtSymbol.Rect,
            sSize=5,
            sColor='blue',
            sFill=True,
            lStyle=Qt.Qt.NoPen,
            yAxis=Qwt5.QwtPlot.yLeft)

        self._corrAppearance = CurveAppearanceProperties(
            sStyle=Qwt5.QwtSymbol.NoSymbol,
            lStyle=Qt.Qt.SolidLine,
            lWidth=1,
            lColor='blue',
            cStyle=Qwt5.QwtPlotCurve.Lines,
            yAxis=Qwt5.QwtPlot.yLeft)

        self.plot1.attachRawData({'x': self.x, 'y': self.y, 'title': 'Master'})
        self.plot1.setCurveAppearanceProperties({'Master': self._yAppearance})

        self.plot1.attachRawData({
            'x': self.xp,
            'y': self.yp + self.corrp,
            'title': 'Control Points'
        })
        self.plot1.setCurveAppearanceProperties(
            {'Control Points': self._cpointsAppearance})

        self.plot1.attachRawData({
            'x': self.x,
            'y': self.y + self.corr,
            'title': 'Corrected'
        })
        self.plot1.setCurveAppearanceProperties(
            {'Corrected': self._correctedAppearance})

        self.plot2.attachRawData({
            'x': self.x,
            'y': self.corr,
            'title': 'Correction'
        })
        self.plot2.setCurveAppearanceProperties(
            {'Correction': self._corrAppearance})

        self.plot2.attachRawData({
            'x': self.xp,
            'y': self.corrp,
            'title': 'Control Points'
        })
        self.plot2.setCurveAppearanceProperties(
            {'Control Points': self._cpointsAppearance})