Esempio n. 1
0
    def __init__(self,
                 autoRangeFunctions=None,
                 nodeName='range',
                 expanded=False,
                 paddingDefault=-1):
        """ Constructor.
            The target axis is specified by viewBox and axisNumber (0 for x-axis, 1 for y-axis)

            If given, autoRangeMethods must be a (label to function) dictionary that will be used
            to populate the (auto range) method ChoiceCti.
            If autoRangeFunctions is None, there will be no auto-range child CTI.
            If autoRangeFunctions has one element there will be an auto-range child without a method
            child CTI (the function from the autoRangeMethods dictionary will be the default).

            :param int paddingDefault: default padding value. Use -1 for 'dynamic' padding, which
                is the PyQtGraph padding algorithm.
        """
        super(AbstractRangeCti, self).__init__(nodeName, expanded=expanded)

        self._rangeFunctions = {}
        self.autoRangeCti = None
        self.methodCti = None
        self.subsampleCti = None
        self.paddingCti = None

        if autoRangeFunctions is not None:
            self.autoRangeCti = self.insertChild(
                BoolCti("auto-range", True, expanded=False))
            self._rangeFunctions = autoRangeFunctions

            if len(autoRangeFunctions) > 1:
                self.methodCti = ChoiceCti("method",
                                           configValues=list(
                                               autoRangeFunctions.keys()))
                self.autoRangeCti.insertChild(self.methodCti)

                self.subsampleCti = BoolCti("subsample", True)
                self.autoRangeCti.insertChild(self.subsampleCti)

            self.paddingCti = IntCti("padding",
                                     paddingDefault,
                                     suffix="%",
                                     specialValueText="dynamic",
                                     minValue=-1,
                                     maxValue=1000,
                                     stepSize=1)
            self.autoRangeCti.insertChild(self.paddingCti)

        self.rangeMinCti = self.insertChild(SnFloatCti('min', 0.0))
        self.rangeMaxCti = self.insertChild(SnFloatCti('max', 1.0))
Esempio n. 2
0
    def __init__(self, targetWidget, nodeName='font', defaultData=None):
        """ Constructor.

            :param targetWidget: a QWidget that must have a setFont() method
            For the (other) parameters see the AbstractCti constructor documentation.
        """
        super(FontCti, self).__init__(nodeName,
                                defaultData=QtGui.QFont() if defaultData is None else defaultData)

        self._targetWidget = targetWidget

        self.familyCti = self.insertChild(
            FontChoiceCti("family", defaultFamily=self.defaultData.family()))

        self.pointSizeCti = self.insertChild(
            IntCti("size", self.defaultData.pointSize(),
                   minValue=1, maxValue=500, stepSize=1, suffix=' pt'))

        QtF = QtGui.QFont
        weights = [QtF.Light, QtF.Normal, QtF.DemiBold, QtF.Bold, QtF.Black]
        self.weightCti = self.insertChild(
            ChoiceCti("weight", defaultData=fontWeightIndex(self.defaultData, weights),
                      displayValues=['Light', 'Normal', 'DemiBold', 'Bold', 'Black'],
                      configValues=weights))

        self.italicCti = self.insertChild(BoolCti("italic", self.defaultData.italic()))
Esempio n. 3
0
 def _createConfig(self):
     """ Creates a config tree item (CTI) hierarchy containing default children.
     """
     # Currently not added to the config tree as there are no configurable items.
     rootItem = MainGroupCti('data repository')
     rootItem.insertChild(BoolCti('test checkbox',
                                  False))  # Does nothing yet
     return rootItem
Esempio n. 4
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
Esempio n. 5
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))
Esempio n. 6
0
    def __init__(self,
                 plotItem,
                 nodeName="grid",
                 defaultData=True,
                 expanded=False):
        """ Constructor.
            The target axis is specified by viewBox and axisNumber (0 for x-axis, 1 for y-axis)
        """
        super(PgGridCti, self).__init__(nodeName,
                                        defaultData=defaultData,
                                        expanded=expanded)
        check_class(plotItem, pg.PlotItem)
        self.plotItem = plotItem

        self.xGridCti = self.insertChild(BoolCti('x-axis', defaultData))
        self.yGridCti = self.insertChild(BoolCti('y-axis', defaultData))
        self.alphaCti = self.insertChild(
            FloatCti('alpha',
                     0.20,
                     minValue=0.0,
                     maxValue=1.0,
                     stepSize=0.01,
                     decimals=2))
Esempio n. 7
0
    def __init__(self,
                 colorLegendItem,
                 nodeName="color map",
                 defaultData=DEFAULT_COLOR_MAP,
                 expanded=False):
        """ Constructor.

            Stores a color map as data.

            :param defaultData: the default index in the combobox that is used for editing
        """
        check_class(colorLegendItem, ArgosColorLegendItem)
        self.colorLegendItem = colorLegendItem
        self.cmLibModel = CmLibModelSingleton.instance()

        # grey scale color map for when no color map is selected.
        lutRgba = np.outer(np.arange(256, dtype=np.uint8),
                           np.array([1, 1, 1, 1], dtype=np.uint8))
        lutRgba[:, 3] = 255
        self.greyScaleColorMap = ColorMap(CmMetaData("-- none --"),
                                          CatalogMetaData("Argos"))
        self.greyScaleColorMap.set_rgba_uint8_array(lutRgba)

        super(PgColorMapCti, self).__init__(nodeName,
                                            defaultData,
                                            expanded=expanded)

        self.reverseCti = self.insertChild(BoolCti("reversed", False))

        self.subSampleCti = self.insertChild(
            IntCti("subsample",
                   self.SUB_SAMPLING_OFF,
                   specialValueText="off",
                   minValue=self.SUB_SAMPLING_OFF,
                   maxValue=64,
                   stepSize=1))
Esempio n. 8
0
    def __init__(self, pgImagePlot2d, nodeName):
        """ Constructor

            Maintains a link to the target pgImagePlot2d inspector, so that changes in the
            configuration can be applied to the target by simply calling the apply method.
            Vice versa, it can connect signals to the target.
        """
        super(PgImagePlot2dCti, self).__init__(nodeName)
        check_class(pgImagePlot2d, PgImagePlot2d)
        self.pgImagePlot2d = pgImagePlot2d
        imagePlotItem = self.pgImagePlot2d.imagePlotItem
        viewBox = imagePlotItem.getViewBox()

        self.insertChild(
            ChoiceCti('title',
                      0,
                      editable=True,
                      configValues=[
                          "{base-name} -- {name} {slices}", "{name} {slices}",
                          "{path} {slices}"
                      ]))

        #### Axes ####

        self.aspectLockedCti = self.insertChild(PgAspectRatioCti(viewBox))

        self.xAxisCti = self.insertChild(PgAxisCti('x-axis'))
        self.xAxisCti.insertChild(
            PgAxisLabelCti(imagePlotItem,
                           'bottom',
                           self.pgImagePlot2d.collector,
                           defaultData=1,
                           configValues=[NO_LABEL_STR, "{x-dim} [index]"]))
        self.xFlippedCti = self.xAxisCti.insertChild(
            PgAxisFlipCti(viewBox, X_AXIS))
        self.xAxisRangeCti = self.xAxisCti.insertChild(
            PgAxisRangeCti(viewBox, X_AXIS))

        self.yAxisCti = self.insertChild(PgAxisCti('y-axis'))
        self.yAxisCti.insertChild(
            PgAxisLabelCti(imagePlotItem,
                           'left',
                           self.pgImagePlot2d.collector,
                           defaultData=1,
                           configValues=[NO_LABEL_STR, "{y-dim} [index]"]))
        self.yFlippedCti = self.yAxisCti.insertChild(
            PgAxisFlipCti(viewBox, Y_AXIS, defaultData=True))
        self.yAxisRangeCti = self.yAxisCti.insertChild(
            PgAxisRangeCti(viewBox, Y_AXIS))

        #### Color scale ####

        self.colorCti = self.insertChild(PgAxisCti('color scale'))

        self.colorCti.insertChild(
            PgColorLegendLabelCti(pgImagePlot2d.colorLegendItem,
                                  self.pgImagePlot2d.collector,
                                  defaultData=1,
                                  configValues=[
                                      NO_LABEL_STR, "{name} {unit}",
                                      "{path} {unit}", "{name}", "{path}",
                                      "{raw-unit}"
                                  ]))

        self.colorCti.insertChild(
            PgColorMapCti(self.pgImagePlot2d.colorLegendItem))

        self.showHistCti = self.colorCti.insertChild(
            PgShowHistCti(pgImagePlot2d.colorLegendItem))
        self.showDragLinesCti = self.colorCti.insertChild(
            PgShowDragLinesCti(pgImagePlot2d.colorLegendItem))

        colorAutoRangeFunctions = defaultAutoRangeMethods(self.pgImagePlot2d)
        self.colorLegendCti = self.colorCti.insertChild(
            PgColorLegendCti(pgImagePlot2d.colorLegendItem,
                             colorAutoRangeFunctions,
                             nodeName="range"))

        # If True, the image is automatically downsampled to match the screen resolution. This
        # improves performance for large images and reduces aliasing. If autoDownsample is not
        # specified, then ImageItem will choose whether to downsample the image based on its size.
        self.autoDownSampleCti = self.insertChild(
            BoolCti('auto down sample', True))
        self.zoomModeCti = self.insertChild(
            BoolCti('rectangle zoom mode', False))

        ### Probe and cross-hair plots ###

        self.probeCti = self.insertChild(BoolCti('show probe', True))
        self.crossPlotGroupCti = self.insertChild(
            BoolGroupCti('cross-hair', expanded=False))
        self.crossPenCti = self.crossPlotGroupCti.insertChild(
            PgPlotDataItemCti(expanded=False))

        self.horCrossPlotCti = self.crossPlotGroupCti.insertChild(
            BoolCti('horizontal', False, expanded=False))

        self.horCrossPlotCti.insertChild(
            PgGridCti(pgImagePlot2d.horCrossPlotItem))
        self.horCrossPlotRangeCti = self.horCrossPlotCti.insertChild(
            PgAxisRangeCti(self.pgImagePlot2d.horCrossPlotItem.getViewBox(),
                           Y_AXIS,
                           nodeName="data range",
                           autoRangeFunctions=crossPlotAutoRangeMethods(
                               self.pgImagePlot2d, "horizontal")))

        self.verCrossPlotCti = self.crossPlotGroupCti.insertChild(
            BoolCti('vertical', False, expanded=False))
        self.verCrossPlotCti.insertChild(
            PgGridCti(pgImagePlot2d.verCrossPlotItem))
        self.verCrossPlotRangeCti = self.verCrossPlotCti.insertChild(
            PgAxisRangeCti(self.pgImagePlot2d.verCrossPlotItem.getViewBox(),
                           X_AXIS,
                           nodeName="data range",
                           autoRangeFunctions=crossPlotAutoRangeMethods(
                               self.pgImagePlot2d, "vertical")))

        # Connect signals.

        # Use a queued connect to schedule the reset after current events have been processed.
        self.pgImagePlot2d.colorLegendItem.sigResetColorScale.connect(
            self.colorLegendCti.setAutoRangeOn, type=Qt.QueuedConnection)
        self.pgImagePlot2d.imagePlotItem.sigResetAxis.connect(
            self.setImagePlotAutoRangeOn, type=Qt.QueuedConnection)
        self.pgImagePlot2d.horCrossPlotItem.sigResetAxis.connect(
            self.setHorCrossPlotAutoRangeOn, type=Qt.QueuedConnection)
        self.pgImagePlot2d.verCrossPlotItem.sigResetAxis.connect(
            self.setVerCrossPlotAutoRangeOn, type=Qt.QueuedConnection)

        # Also update axis auto range tree items when linked axes are resized
        horCrossViewBox = self.pgImagePlot2d.horCrossPlotItem.getViewBox()
        horCrossViewBox.sigRangeChangedManually.connect(
            self.xAxisRangeCti.setAutoRangeOff)
        verCrossViewBox = self.pgImagePlot2d.verCrossPlotItem.getViewBox()
        verCrossViewBox.sigRangeChangedManually.connect(
            self.yAxisRangeCti.setAutoRangeOff)
Esempio n. 9
0
    def __init__(self, pgLinePlot1d, nodeName):
        """ Constructor

            Maintains a link to the target pgLinePlot1d inspector, so that changes in the
            configuration can be applied to the target by simply calling the apply method.
            Vice versa, it can connect signals to the target.
        """
        super(PgLinePlot1dCti, self).__init__(nodeName=nodeName)

        check_class(pgLinePlot1d, PgLinePlot1d)
        self.pgLinePlot1d = pgLinePlot1d

        self.insertChild(
            ChoiceCti('title',
                      0,
                      editable=True,
                      configValues=[
                          "{base-name} -- {name} {slices}", "{name} {slices}",
                          "{path} {slices}"
                      ]))

        #### Axes ####
        plotItem = self.pgLinePlot1d.plotItem
        viewBox = plotItem.getViewBox()

        self.insertChild(PgGridCti(plotItem))

        self.xAxisCti = self.insertChild(PgAxisCti('x-axis'))
        self.xAxisCti.insertChild(
            PgAxisLabelCti(
                plotItem,
                'bottom',
                self.pgLinePlot1d.collector,
                defaultData=1,
                configValues=[PgAxisLabelCti.NO_LABEL, "{x-dim} [index]"]))
        # No logarithmic X-Axis as long as abcissa is not yet implemented.
        #xAxisCti.insertChild(PgAxisLogModeCti(imagePlotItem, X_AXIS))
        self.xAxisRangeCti = self.xAxisCti.insertChild(
            PgAxisRangeCti(viewBox, X_AXIS))

        self.yAxisCti = self.insertChild(PgAxisCti('y-axis'))
        self.yAxisCti.insertChild(
            PgAxisLabelCti(plotItem,
                           'left',
                           self.pgLinePlot1d.collector,
                           defaultData=1,
                           configValues=[
                               PgAxisLabelCti.NO_LABEL, "{name} {unit}",
                               "{path} {unit}", "{name}", "{path}",
                               "{raw-unit}"
                           ]))
        self.yLogCti = self.yAxisCti.insertChild(
            PgAxisLogModeCti(plotItem, Y_AXIS))

        rangeFunctions = defaultAutoRangeMethods(self.pgLinePlot1d, {
            PgAxisRangeCti.PYQT_RANGE:
            partial(viewBoxAxisRange, viewBox, Y_AXIS)
        })
        self.yAxisRangeCti = self.yAxisCti.insertChild(
            PgAxisRangeCti(viewBox, Y_AXIS, rangeFunctions))

        #### Pen ####

        self.plotDataItemCti = self.insertChild(PgPlotDataItemCti())
        self.probeCti = self.insertChild(BoolCti('show probe', True))

        # Connect signals
        self.pgLinePlot1d.plotItem.sigAxisReset.connect(self.setAutoRangeOn)
Esempio n. 10
0
    def __init__(self, tableInspector, nodeName):

        super(TableInspectorCti, self).__init__(nodeName)

        check_class(tableInspector, TableInspector)
        self.tableInspector = tableInspector

        # The defaultRowHeightCti and defaultColWidthCti are initialized with -1; they will get
        # the actual values in the TableInspector constructor.
        self.autoRowHeightCti = self.insertChild(
            BoolCti("auto row heights", False, childrenDisabledValue=True))
        self.defaultRowHeightCti = self.autoRowHeightCti.insertChild(
            IntCti("row height", -1, minValue=20, maxValue=500, stepSize=5))

        self.autoColWidthCti = self.insertChild(
            BoolCti("auto column widths", False, childrenDisabledValue=True))
        self.defaultColWidthCti = self.autoColWidthCti.insertChild(
            IntCti("column width", -1, minValue=20, maxValue=500, stepSize=5))

        self.insertChild(BoolCti("separate fields", True))
        self.insertChild(BoolCti("word wrap", False))

        self.encodingCti = self.insertChild(
            ChoiceCti(
                'encoding',
                editable=True,
                configValues=['utf-8', 'ascii', 'latin-1', 'windows-1252']))

        fmtCti = self.insertChild(GroupCti("format specifiers"))

        # Use '!r' as default for Python 2. This will convert the floats with repr(), which is
        # necessary because str() or an empty format string will only print 2 decimals behind the
        # point. In Python 3 this is not necessary: all relevant decimals are printed.
        numDefaultValue = 6 if six.PY2 else 0

        self.strFormatCti = fmtCti.insertChild(
            ChoiceCti("strings",
                      0,
                      editable=True,
                      completer=None,
                      configValues=[
                          '', 's', '!r', '!a', '10.10s', '_<15s', '_>15s',
                          "'str: {}'"
                      ]))

        self.intFormatCti = fmtCti.insertChild(
            ChoiceCti("integers",
                      0,
                      editable=True,
                      completer=None,
                      configValues=[
                          '', 'd', 'n', 'c', '#b', '#o', '#x', '!r', '8d',
                          '#8.4g', '_<10', '_>10', "'int: {}'"
                      ]))

        self.numFormatCti = fmtCti.insertChild(
            ChoiceCti("other numbers",
                      numDefaultValue,
                      editable=True,
                      completer=None,
                      configValues=[
                          '', 'f', 'g', 'n', '%', '!r', '8.3e', '#8.4g',
                          '_<15', '_>15', "'num: {}'"
                      ]))

        self.otherFormatCti = fmtCti.insertChild(
            ChoiceCti("other types",
                      0,
                      editable=True,
                      completer=None,
                      configValues=['', '!s', '!r', "'other: {}'"]))

        self.maskFormatCti = fmtCti.insertChild(
            ChoiceCti("missing data",
                      2,
                      editable=True,
                      completer=None,
                      configValues=['', "' '", "'--'", "'<masked>'", '!r']))

        self.fontCti = self.insertChild(
            FontCti(self.tableInspector,
                    "font",
                    defaultData=QtGui.QFont(MONO_FONT, FONT_SIZE)))

        self.dataColorCti = self.insertChild(
            ColorCti('text color', QtGui.QColor('#000000')))

        self.missingColorCti = self.insertChild(
            ColorCti('missing data color', QtGui.QColor('#B0B0B0')))

        self.horAlignCti = self.insertChild(
            ChoiceCti(
                'horizontal alignment',
                configValues=[
                    ALIGN_SMART, Qt.AlignLeft, Qt.AlignHCenter, Qt.AlignRight
                ],
                displayValues=['Type-dependent', 'Left', 'Center', 'Right']))
        # Qt.AlignJustify not included, it doesn't seem to do anything,

        self.verAlignCti = self.insertChild(
            ChoiceCti(
                'vertical alignment',
                defaultData=1,
                configValues=[Qt.AlignTop, Qt.AlignVCenter, Qt.AlignBottom],
                displayValues=['Top', 'Center', 'Bottom']))

        # Per pixel scrolling works better for large cells (e.g. containing XML strings).
        self.insertChild(
            ChoiceCti("scroll",
                      displayValues=["Per cell", "Per pixel"],
                      configValues=[
                          QtWidgets.QAbstractItemView.ScrollPerItem,
                          QtWidgets.QAbstractItemView.ScrollPerPixel
                      ]))
Esempio n. 11
0
    def __init__(self, pgImagePlot2d, nodeName):
        """ Constructor

            Maintains a link to the target pgImagePlot2d inspector, so that changes in the
            configuration can be applied to the target by simply calling the apply method.
            Vice versa, it can connect signals to the target.
        """
        super(PgImagePlot2dCti, self).__init__(nodeName)
        check_class(pgImagePlot2d, PgImagePlot2d)
        self.pgImagePlot2d = pgImagePlot2d
        imagePlotItem = self.pgImagePlot2d.imagePlotItem
        viewBox = imagePlotItem.getViewBox()

        self.insertChild(
            ChoiceCti('title',
                      0,
                      editable=True,
                      configValues=[
                          "{base-name} -- {name} {slices}", "{name} {slices}",
                          "{path} {slices}"
                      ]))
        #### Axes ####
        self.aspectLockedCti = self.insertChild(PgAspectRatioCti(viewBox))

        self.xAxisCti = self.insertChild(PgAxisCti('x-axis'))
        #xAxisCti.insertChild(PgAxisShowCti(imagePlotItem, 'bottom')) # disabled, seems broken
        self.xAxisCti.insertChild(
            PgAxisLabelCti(
                imagePlotItem,
                'bottom',
                self.pgImagePlot2d.collector,
                defaultData=1,
                configValues=[PgAxisLabelCti.NO_LABEL, "{x-dim} [index]"]))
        self.xFlippedCti = self.xAxisCti.insertChild(
            PgAxisFlipCti(viewBox, X_AXIS))
        self.xAxisRangeCti = self.xAxisCti.insertChild(
            PgAxisRangeCti(viewBox, X_AXIS))

        self.yAxisCti = self.insertChild(PgAxisCti('y-axis'))
        #yAxisCti.insertChild(PgAxisShowCti(imagePlotItem, 'left'))  # disabled, seems broken
        self.yAxisCti.insertChild(
            PgAxisLabelCti(
                imagePlotItem,
                'left',
                self.pgImagePlot2d.collector,
                defaultData=1,
                configValues=[PgAxisLabelCti.NO_LABEL, "{y-dim} [index]"]))
        self.yFlippedCti = self.yAxisCti.insertChild(
            PgAxisFlipCti(viewBox, Y_AXIS))
        self.yAxisRangeCti = self.yAxisCti.insertChild(
            PgAxisRangeCti(viewBox, Y_AXIS))

        #### Color scale ####

        colorAutoRangeFunctions = defaultAutoRangeMethods(self.pgImagePlot2d)

        self.histColorRangeCti = self.insertChild(
            PgHistLutColorRangeCti(pgImagePlot2d.histLutItem,
                                   colorAutoRangeFunctions,
                                   nodeName="color range"))

        histViewBox = pgImagePlot2d.histLutItem.vb
        histViewBox.enableAutoRange(Y_AXIS, False)
        rangeFunctions = defaultAutoRangeMethods(
            self.pgImagePlot2d, {
                PgAxisRangeCti.PYQT_RANGE:
                partial(viewBoxAxisRange, histViewBox, Y_AXIS)
            })

        self.histRangeCti = self.insertChild(
            PgAxisRangeCti(histViewBox,
                           Y_AXIS,
                           nodeName='histogram range',
                           autoRangeFunctions=rangeFunctions))

        self.insertChild(
            PgGradientEditorItemCti(self.pgImagePlot2d.histLutItem.gradient))

        # Probe and cross-hair plots
        self.probeCti = self.insertChild(BoolCti('show probe', True))

        self.crossPlotGroupCti = self.insertChild(
            BoolGroupCti('cross-hair', expanded=False))

        self.crossPenCti = self.crossPlotGroupCti.insertChild(
            PgPlotDataItemCti(expanded=False))
        #self.crossLinesCti = self.crossPlotGroupCti.insertChild(PgPlotDataItemCti('cross pen',
        #                                                                          expanded=False))

        self.horCrossPlotCti = self.crossPlotGroupCti.insertChild(
            BoolCti('horizontal', False, expanded=False))
        self.horCrossPlotCti.insertChild(
            PgGridCti(pgImagePlot2d.horCrossPlotItem))
        self.horCrossPlotRangeCti = self.horCrossPlotCti.insertChild(
            PgAxisRangeCti(self.pgImagePlot2d.horCrossPlotItem.getViewBox(),
                           Y_AXIS,
                           nodeName="data range",
                           autoRangeFunctions=crossPlotAutoRangeMethods(
                               self.pgImagePlot2d, "horizontal")))

        self.verCrossPlotCti = self.crossPlotGroupCti.insertChild(
            BoolCti('vertical', False, expanded=False))
        self.verCrossPlotCti.insertChild(
            PgGridCti(pgImagePlot2d.verCrossPlotItem))
        self.verCrossPlotRangeCti = self.verCrossPlotCti.insertChild(
            PgAxisRangeCti(self.pgImagePlot2d.verCrossPlotItem.getViewBox(),
                           X_AXIS,
                           nodeName="data range",
                           autoRangeFunctions=crossPlotAutoRangeMethods(
                               self.pgImagePlot2d, "vertical")))

        # Connect signals
        self.pgImagePlot2d.imagePlotItem.sigAxisReset.connect(
            self.setImagePlotAutoRangeOn)
        self.pgImagePlot2d.horCrossPlotItem.sigAxisReset.connect(
            self.setHorCrossPlotAutoRangeOn)
        self.pgImagePlot2d.verCrossPlotItem.sigAxisReset.connect(
            self.setVerCrossPlotAutoRangeOn)

        # Also update axis auto range tree items when linked axes are resized
        horCrossViewBox = self.pgImagePlot2d.horCrossPlotItem.getViewBox()
        horCrossViewBox.sigRangeChangedManually.connect(
            self.xAxisRangeCti.setAutoRangeOff)
        verCrossViewBox = self.pgImagePlot2d.verCrossPlotItem.getViewBox()
        verCrossViewBox.sigRangeChangedManually.connect(
            self.yAxisRangeCti.setAutoRangeOff)
Esempio n. 12
0
    def __init__(self, pgLinePlot1d, nodeName):
        """ Constructor

            Maintains a link to the target pgLinePlot1d inspector, so that changes in the
            configuration can be applied to the target by simply calling the apply method.
            Vice versa, it can connect signals to the target.
        """
        super(PgLinePlot1dCti, self).__init__(nodeName=nodeName)

        check_class(pgLinePlot1d, PgLinePlot1d)
        self.pgLinePlot1d = pgLinePlot1d

        self.insertChild(
            ChoiceCti('title',
                      0,
                      editable=True,
                      configValues=[
                          "{base-name} -- {name} {slices}", "{name} {slices}",
                          "{path} {slices}"
                      ]))

        #### Axes ####
        plotItem = self.pgLinePlot1d.plotItem
        viewBox = plotItem.getViewBox()

        self.insertChild(PgGridCti(plotItem))

        self.xAxisCti = self.insertChild(PgAxisCti('x-axis'))
        self.xAxisCti.insertChild(
            PgAxisLabelCti(plotItem,
                           'bottom',
                           self.pgLinePlot1d.collector,
                           defaultData=1,
                           configValues=[NO_LABEL_STR, "{x-dim} [index]"]))
        # No logarithmic X-Axis as long as abcissa is not yet implemented.
        #xAxisCti.insertChild(PgAxisLogModeCti(imagePlotItem, X_AXIS))
        self.xAxisRangeCti = self.xAxisCti.insertChild(
            PgAxisRangeCti(viewBox, X_AXIS))

        self.yAxisCti = self.insertChild(PgAxisCti('y-axis'))
        self.yAxisCti.insertChild(
            PgAxisLabelCti(plotItem,
                           'left',
                           self.pgLinePlot1d.collector,
                           defaultData=1,
                           configValues=[
                               NO_LABEL_STR, "{name} {unit}", "{path} {unit}",
                               "{name}", "{path}", "{raw-unit}"
                           ]))
        self.yLogCti = self.yAxisCti.insertChild(
            PgAxisLogModeCti(plotItem, Y_AXIS))

        rangeFunctions = defaultAutoRangeMethods(self.pgLinePlot1d)
        self.yAxisRangeCti = self.yAxisCti.insertChild(
            PgAxisRangeCti(viewBox, Y_AXIS, rangeFunctions))

        #### Pen ####

        self.plotDataItemCti = self.insertChild(PgPlotDataItemCti())
        self.zoomModeCti = self.insertChild(
            BoolCti('rectangle zoom mode', False))
        self.probeCti = self.insertChild(BoolCti('show probe', True))

        # Connect signals.

        # We need a QueuedConnection here so that the axis reset is scheduled after all current
        # events have been processed. Otherwise the mouseReleaseEvent may look for a PlotCurveItem
        # that is no longer present after the reset, which results in a RuntimeError: wrapped C/C++
        # object of type PlotCurveItem has been deleted.
        self.pgLinePlot1d.plotItem.sigResetAxis.connect(
            self.setAutoRangeOn, type=QtCore.Qt.QueuedConnection)