Пример #1
0
    def createPlotDataItem(self):
        """ Creates a PyQtGraph PlotDataItem from the config values
        """
        antialias = self.antiAliasCti.configValue

        color = self.penColor
        if self.lineCti.configValue:
            pen = QtGui.QPen()
            pen.setCosmetic(True)
            pen.setColor(color)
            pen.setWidthF(self.lineWidthCti.configValue)
            pen.setStyle(self.lineStyleCti.configValue)
            shadowCti = self.lineCti.findByNodePath('shadow')
            shadowPen = shadowCti.createPen(altStyle=pen.style(),
                                            altWidth=2.0 * pen.widthF())
        else:
            pen = None
            shadowPen = None

        drawSymbols = self.symbolCti.configValue
        symbolShape = self.symbolShapeCti.configValue if drawSymbols else None
        symbolSize = self.symbolSizeCti.configValue if drawSymbols else 0.0
        symbolPen = None  # otherwise the symbols will also have dotted/solid line.
        symbolBrush = QtGui.QBrush(color) if drawSymbols else None

        plotDataItem = pg.PlotDataItem(antialias=antialias,
                                       pen=pen,
                                       shadowPen=shadowPen,
                                       symbol=symbolShape,
                                       symbolSize=symbolSize,
                                       symbolPen=symbolPen,
                                       symbolBrush=symbolBrush)
        return plotDataItem
Пример #2
0
    def __init__(self, nodeName, defaultData, resetTo=None, expanded=True,
                 includeNoneStyle=False, includeZeroWidth=False):
        """ Sets the children's default value using the resetTo value.

            The resetTo value must be a QPen or value that can be converted to QPen. It is used
            to initialize the child nodes' defaultValues. If resetTo is None, the default QPen
            will be used, which is a black solid pen of width 1.0.

            (resetTo is not called 'defaultData' since the PenCti itself always has a data and
            defaultData of None. That is, it does not store the data itself but relies on its
            child nodes). The default data, is used to indicate if the pen is enabled.

            If includeNonStyle is True, an None-option will be prepended to the style choice
        """
        super(PenCti, self).__init__(nodeName, defaultData, expanded=expanded,
                                     childrenDisabledValue=False)
        # We don't need a similar initFrom parameter.
        qPen = QtGui.QPen(resetTo)

        self.colorCti = self.insertChild(ColorCti('color', defaultData=qPen.color()))
        defaultIndex = PEN_STYLE_CONFIG_VALUES.index(qPen.style()) + int(includeNoneStyle)
        self.styleCti = self.insertChild(createPenStyleCti('style', defaultData=defaultIndex,
                                                           includeNone=includeNoneStyle))
        self.widthCti = self.insertChild(createPenWidthCti('width', defaultData=qPen.widthF(),
                                                zeroValueText=' ' if includeZeroWidth else None))
Пример #3
0
    def __init__(self, nodeName="pen", defaultData=None, expanded=True):
        """ Constructor.
        """
        super(PgPlotDataItemCti, self).__init__(nodeName,
                                                defaultData=defaultData,
                                                expanded=expanded)
        self.antiAliasCti = self.insertChild(BoolCti("anti-alias", True))

        self.colorCti = self.insertChild(
            ColorCti('color', QtGui.QColor('#FF0066')))
        self.lineCti = self.insertChild(
            BoolCti('line', True, expanded=False, childrenDisabledValue=False))
        self.lineStyleCti = self.lineCti.insertChild(
            createPenStyleCti('style'))
        self.lineWidthCti = self.lineCti.insertChild(
            createPenWidthCti('width'))

        defaultShadowPen = QtGui.QPen(QtGui.QColor('#BFBFBF'))
        defaultShadowPen.setWidth(0)
        self.lineCti.insertChild(
            PenCti("shadow",
                   False,
                   expanded=False,
                   resetTo=QtGui.QPen(defaultShadowPen),
                   includeNoneStyle=True,
                   includeZeroWidth=True))

        self.symbolCti = self.insertChild(
            BoolCti("symbol",
                    False,
                    expanded=False,
                    childrenDisabledValue=False))
        self.symbolShapeCti = self.symbolCti.insertChild(
            ChoiceCti("shape",
                      0,
                      displayValues=[
                          'circle', 'square', 'triangle', 'diamond', 'plus'
                      ],
                      configValues=['o', 's', 't', 'd', '+']))
        self.symbolSizeCti = self.symbolCti.insertChild(
            IntCti('size', 5, minValue=0, maxValue=100, stepSize=1))
Пример #4
0
 def configValue(self):
     """ Creates a QPen made of the children's config values.
     """
     if not self.data:
         return None
     else:
         pen = QtGui.QPen()
         pen.setCosmetic(True)
         pen.setColor(self.colorCti.configValue)
         style = self.styleCti.configValue
         if style is not None:
             pen.setStyle(style)
         pen.setWidthF(self.widthCti.configValue)
         return pen
Пример #5
0
    def _createConfig(self):
        """ Creates a config tree item (CTI) hierarchy containing default children.
        """
        rootItem = MainGroupCti('debug inspector')

        if DEBUGGING:
            # Some test config items.
            import numpy as np
            from argos.config.untypedcti import UntypedCti
            from argos.config.stringcti import StringCti
            from argos.config.intcti import IntCti
            from argos.config.floatcti import FloatCti, SnFloatCti
            from argos.config.boolcti import BoolCti, BoolGroupCti
            from argos.config.choicecti import ChoiceCti
            from argos.config.qtctis import PenCti

            grpItem = GroupCti("group")
            rootItem.insertChild(grpItem)

            lcItem = UntypedCti('line color', 123)
            grpItem.insertChild(lcItem)

            disabledItem = rootItem.insertChild(StringCti('disabled', "Can't touch me"))
            disabledItem.enabled=False

            grpItem.insertChild(IntCti('line-1 color', 7, minValue = -5, stepSize=2,
                                       prefix="@", suffix="%", specialValueText="I'm special"))
            rootItem.insertChild(StringCti('letter', 'aa', maxLength = 1))
            grpItem.insertChild(FloatCti('width', 2, minValue =5, stepSize=0.45, decimals=3,
                                         prefix="@", suffix="%", specialValueText="so very special"))
            grpItem.insertChild(SnFloatCti('scientific', defaultData=-np.inf))

            gridItem = rootItem.insertChild(BoolGroupCti('grid', True))
            gridItem.insertChild(BoolCti('X-Axis', True))
            gridItem.insertChild(BoolCti('Y-Axis', False))

            rootItem.insertChild(ChoiceCti('hobbit', 2, editable=True,
                                           configValues=['Frodo', 'Sam', 'Pippin', 'Merry']))
            myPen = QtGui.QPen(QtGui.QColor('#1C8857'))
            myPen.setWidth(2)
            myPen.setStyle(Qt.DashDotDotLine)
            rootItem.insertChild(PenCti('line', False, resetTo=myPen))

        return rootItem