Beispiel #1
0
 def __init__(self, orientation='bottom', allowAdd=True, **kargs):
     """
     ============= =================================================================================
     **Arguments**
     orientation   Set the orientation of the gradient. Options are: 'left', 'right'
                   'top', and 'bottom'.
     allowAdd      Specifies whether ticks can be added to the item by the user.
     tickPen       Default is white. Specifies the color of the outline of the ticks.
                   Can be any of the valid arguments for :func:`mkPen <pyqtgraph.mkPen>`
     ============= =================================================================================        
     """
     ## public
     GraphicsWidget.__init__(self)
     self.orientation = orientation
     self.length = 100
     self.tickSize = 15
     self.ticks = {}
     self.maxDim = 20
     self.allowAdd = allowAdd
     if 'tickPen' in kargs:
         self.tickPen = fn.mkPen(kargs['tickPen'])
     else:
         self.tickPen = fn.mkPen('w')
         
     self.orientations = {
         'left': (90, 1, 1), 
         'right': (90, 1, 1), 
         'top': (0, 1, -1), 
         'bottom': (0, 1, 1)
     }
     
     self.setOrientation(orientation)
Beispiel #2
0
    def show(self):

        if self.orientation in ["left", "right"]:
            self.setWidth()
        else:
            self.setHeight()
        GraphicsWidget.show(self)
Beispiel #3
0
 def show(self):
     
     if self.orientation in ['left', 'right']:
         self.setWidth()
     else:
         self.setHeight()
     GraphicsWidget.show(self)
Beispiel #4
0
 def __init__(self, orientation, pen=None, linkView=None, parent=None, maxTickLength=-5, showValues=True):
     """
     ==============  ===============================================================
     **Arguments:**
     orientation     one of 'left', 'right', 'top', or 'bottom'
     maxTickLength   (px) maximum length of ticks to draw. Negative values draw
                     into the plot, positive values draw outward.
     linkView        (ViewBox) causes the range of values displayed in the axis
                     to be linked to the visible range of a ViewBox.
     showValues      (bool) Whether to display values adjacent to ticks 
     pen             (QPen) Pen used when drawing ticks.
     ==============  ===============================================================
     """
     
     GraphicsWidget.__init__(self, parent)
     self.label = QtGui.QGraphicsTextItem(self)
     self.showValues = showValues
     self.picture = None
     self.orientation = orientation
     if orientation not in ['left', 'right', 'top', 'bottom']:
         raise Exception("Orientation argument must be one of 'left', 'right', 'top', or 'bottom'.")
     if orientation in ['left', 'right']:
         #self.setMinimumWidth(25)
         #self.setSizePolicy(QtGui.QSizePolicy(
             #QtGui.QSizePolicy.Minimum,
             #QtGui.QSizePolicy.Expanding
         #))
         self.label.rotate(-90)
     #else:
         #self.setMinimumHeight(50)
         #self.setSizePolicy(QtGui.QSizePolicy(
             #QtGui.QSizePolicy.Expanding,
             #QtGui.QSizePolicy.Minimum
         #))
     #self.drawLabel = False
     
     self.labelText = ''
     self.labelUnits = ''
     self.labelUnitPrefix=''
     self.labelStyle = {'color': '#CCC'}
     self.logMode = False
     
     self.textHeight = 18
     self.tickLength = maxTickLength
     self.scale = 1.0
     self.autoScale = True
         
     self.setRange(0, 1)
     
     if pen is None:
         pen = QtGui.QPen(QtGui.QColor(100, 100, 100))
     self.setPen(pen)
     
     self._linkedView = None
     if linkView is not None:
         self.linkToView(linkView)
         
     self.showLabel(False)
     
     self.grid = False
Beispiel #5
0
 def __init__(self, text=' ', parent=None, angle=0, **args):
     GraphicsWidget.__init__(self, parent)
     self.item = QtGui.QGraphicsTextItem(self)
     self.opts = {'color': 'CCC', 'justify': 'center'}
     self.opts.update(args)
     self.sizeHint = {}
     self.setText(text)
     self.setAngle(angle)
Beispiel #6
0
 def __init__(self, orientation, pen=None, linkView=None, parent=None, maxTickLength=-5, showValues=True):
     """
     GraphicsItem showing a single plot axis with ticks, values, and label.
     Can be configured to fit on any side of a plot, and can automatically synchronize its displayed scale with ViewBox items.
     Ticks can be extended to make a grid.
     If maxTickLength is negative, ticks point into the plot. 
     """
     
     
     GraphicsWidget.__init__(self, parent)
     self.label = QtGui.QGraphicsTextItem(self)
     self.showValues = showValues
     self.picture = None
     self.orientation = orientation
     if orientation not in ['left', 'right', 'top', 'bottom']:
         raise Exception("Orientation argument must be one of 'left', 'right', 'top', or 'bottom'.")
     if orientation in ['left', 'right']:
         #self.setMinimumWidth(25)
         #self.setSizePolicy(QtGui.QSizePolicy(
             #QtGui.QSizePolicy.Minimum,
             #QtGui.QSizePolicy.Expanding
         #))
         self.label.rotate(-90)
     #else:
         #self.setMinimumHeight(50)
         #self.setSizePolicy(QtGui.QSizePolicy(
             #QtGui.QSizePolicy.Expanding,
             #QtGui.QSizePolicy.Minimum
         #))
     #self.drawLabel = False
     
     self.labelText = ''
     self.labelUnits = ''
     self.labelUnitPrefix=''
     self.labelStyle = {'color': '#CCC'}
     self.logMode = False
     
     self.textHeight = 18
     self.tickLength = maxTickLength
     self.scale = 1.0
     self.autoScale = True
         
     self.setRange(0, 1)
     
     if pen is None:
         pen = QtGui.QPen(QtGui.QColor(100, 100, 100))
     self.setPen(pen)
     
     self._linkedView = None
     if linkView is not None:
         self.linkToView(linkView)
         
     self.showLabel(False)
     
     self.grid = False
Beispiel #7
0
 def __init__(self, text=' ', parent=None, angle=0, **args):
     GraphicsWidget.__init__(self, parent)
     self.item = QtGui.QGraphicsTextItem(self)
     self.opts = {
         'color': 'CCC',
         'justify': 'center'
     }
     self.opts.update(args)
     self.sizeHint = {}
     self.setText(text)
     self.setAngle(angle)
Beispiel #8
0
 def __init__(self, parent=None, border=None):
     GraphicsWidget.__init__(self, parent)
     if border is True:
         border = (100,100,100)
     self.border = border
     self.layout = QtGui.QGraphicsGridLayout()
     self.setLayout(self.layout)
     self.items = {}
     self.rows = {}
     self.currentRow = 0
     self.currentCol = 0
Beispiel #9
0
 def __init__(self, parent=None, border=None):
     GraphicsWidget.__init__(self, parent)
     if border is True:
         border = (100, 100, 100)
     self.border = border
     self.layout = QtGui.QGraphicsGridLayout()
     self.setLayout(self.layout)
     self.items = {}
     self.rows = {}
     self.currentRow = 0
     self.currentCol = 0
Beispiel #10
0
    def __init__(self, image=None, fillHistogram=True):
        """
        If *image* (ImageItem) is provided, then the control will be automatically linked to the image and changes to the control will be immediately reflected in the image's appearance.
        By default, the histogram is rendered with a fill. For performance, set *fillHistogram* = False.
        """
        GraphicsWidget.__init__(self)
        self.lut = None
        self.imageItem = None

        self.layout = QtGui.QGraphicsGridLayout()
        self.setLayout(self.layout)
        self.layout.setContentsMargins(1, 1, 1, 1)
        self.layout.setSpacing(0)
        self.vb = ViewBox()
        self.vb.setMaximumWidth(152)
        self.vb.setMinimumWidth(52)
        self.vb.setMouseEnabled(x=False, y=True)
        self.gradient = GradientEditorItem()
        self.gradient.setOrientation('right')
        self.gradient.loadPreset('grey')
        self.region = LinearRegionItem([0, 1], LinearRegionItem.Horizontal)
        self.region.setZValue(1000)
        self.vb.addItem(self.region)
        self.axis = AxisItem('left',
                             linkView=self.vb,
                             maxTickLength=-10,
                             showValues=False)
        self.layout.addItem(self.axis, 0, 0)
        self.layout.addItem(self.vb, 0, 1)
        self.layout.addItem(self.gradient, 0, 2)
        self.range = None
        self.gradient.setFlag(self.gradient.ItemStacksBehindParent)
        self.vb.setFlag(self.gradient.ItemStacksBehindParent)

        #self.grid = GridItem()
        #self.vb.addItem(self.grid)

        self.gradient.sigGradientChanged.connect(self.gradientChanged)
        self.region.sigRegionChanged.connect(self.regionChanging)
        self.region.sigRegionChangeFinished.connect(self.regionChanged)
        self.vb.sigRangeChanged.connect(self.viewRangeChanged)
        self.plot = PlotDataItem()
        self.plot.rotate(90)
        self.fillHistogram(fillHistogram)

        self.vb.addItem(self.plot)
        self.autoHistogramRange()

        if image is not None:
            self.setImageItem(image)
Beispiel #11
0
 def __init__(self, image=None, fillHistogram=True):
     """
     If *image* (ImageItem) is provided, then the control will be automatically linked to the image and changes to the control will be immediately reflected in the image's appearance.
     By default, the histogram is rendered with a fill. For performance, set *fillHistogram* = False.
     """
     GraphicsWidget.__init__(self)
     self.lut = None
     self.imageItem = None
     
     self.layout = QtGui.QGraphicsGridLayout()
     self.setLayout(self.layout)
     self.layout.setContentsMargins(1,1,1,1)
     self.layout.setSpacing(0)
     self.vb = ViewBox()
     self.vb.setMaximumWidth(152)
     self.vb.setMinimumWidth(52)
     self.vb.setMouseEnabled(x=False, y=True)
     self.gradient = GradientEditorItem()
     self.gradient.setOrientation('right')
     self.gradient.loadPreset('grey')
     self.region = LinearRegionItem([0, 1], LinearRegionItem.Horizontal)
     self.region.setZValue(1000)
     self.vb.addItem(self.region)
     self.axis = AxisItem('left', linkView=self.vb, maxTickLength=-10, showValues=False)
     self.layout.addItem(self.axis, 0, 0)
     self.layout.addItem(self.vb, 0, 1)
     self.layout.addItem(self.gradient, 0, 2)
     self.range = None
     self.gradient.setFlag(self.gradient.ItemStacksBehindParent)
     self.vb.setFlag(self.gradient.ItemStacksBehindParent)
     
     #self.grid = GridItem()
     #self.vb.addItem(self.grid)
     
     self.gradient.sigGradientChanged.connect(self.gradientChanged)
     self.region.sigRegionChanged.connect(self.regionChanging)
     self.region.sigRegionChangeFinished.connect(self.regionChanged)
     self.vb.sigRangeChanged.connect(self.viewRangeChanged)
     self.plot = PlotDataItem()
     self.plot.rotate(90)
     self.fillHistogram(fillHistogram)
         
     self.vb.addItem(self.plot)
     self.autoHistogramRange()
     
     if image is not None:
         self.setImageItem(image)
Beispiel #12
0
 def __init__(self, orientation='bottom', allowAdd=True, **kargs):
     GraphicsWidget.__init__(self)
     self.orientation = orientation
     self.length = 100
     self.tickSize = 15
     self.ticks = {}
     self.maxDim = 20
     self.allowAdd = allowAdd
     if 'tickPen' in kargs:
         self.tickPen = fn.mkPen(kargs['tickPen'])
     else:
         self.tickPen = fn.mkPen('w')
         
     self.orientations = {
         'left': (90, 1, 1), 
         'right': (90, 1, 1), 
         'top': (0, 1, -1), 
         'bottom': (0, 1, 1)
     }
     
     self.setOrientation(orientation)
Beispiel #13
0
 def hide(self):
     if self.orientation in ["left", "right"]:
         self.setWidth(0)
     else:
         self.setHeight(0)
     GraphicsWidget.hide(self)
Beispiel #14
0
 def hide(self):
     if self.orientation in ['left', 'right']:
         self.setWidth(0)
     else:
         self.setHeight(0)
     GraphicsWidget.hide(self)