def __init__(self, textInspector, nodeName): """ Constructor :param textInspector: the TextInspector widget that is being configured :param nodeName: node name """ super(TextInspectorCti, self).__init__(nodeName) check_class(textInspector, TextInspector) self.textInspector = textInspector Opt = QtGui.QTextOption self.wordWrapCti = self.insertChild( ChoiceCti('word wrap', displayValues=[ 'No wrapping', 'Word boundaries', 'Anywhere', 'Boundaries or anywhere' ], configValues=[ Opt.NoWrap, Opt.WordWrap, Opt.WrapAnywhere, Opt.WrapAtWordBoundaryOrAnywhere ])) self.encodingCti = self.insertChild( ChoiceCti( 'encoding', editable=True, configValues=['utf-8', 'ascii', 'latin-1', 'windows-1252'])) self.fontCti = self.insertChild( FontCti(self.textInspector.editor, "font", defaultData=QtGui.QFont(MONO_FONT, FONT_SIZE)))
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))
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
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 ]))
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)
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)