Merge changes from Kratz:
- isocurveitem documentation - updates to GradientEditor and PlotItem docs - Fix for Canvas handling of item Z-position
This commit is contained in:
parent
f278abd55d
commit
d436f4b634
@ -369,10 +369,16 @@ class Canvas(QtGui.QWidget):
|
|||||||
z = citem.zValue()
|
z = citem.zValue()
|
||||||
if z is None:
|
if z is None:
|
||||||
zvals = [i.zValue() for i in siblings]
|
zvals = [i.zValue() for i in siblings]
|
||||||
if len(zvals) == 0:
|
if parent == self.itemList.invisibleRootItem():
|
||||||
z = 0
|
if len(zvals) == 0:
|
||||||
|
z = 0
|
||||||
|
else:
|
||||||
|
z = max(zvals)+10
|
||||||
else:
|
else:
|
||||||
z = max(zvals)+10
|
if len(zvals) == 0:
|
||||||
|
z = parent.canvasItem.zValue()
|
||||||
|
else:
|
||||||
|
z = max(zvals)+1
|
||||||
citem.setZValue(z)
|
citem.setZValue(z)
|
||||||
|
|
||||||
## determine location to insert item relative to its siblings
|
## determine location to insert item relative to its siblings
|
||||||
|
7
documentation/source/graphicsItems/isocurveitem.rst
Normal file
7
documentation/source/graphicsItems/isocurveitem.rst
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
IsocurveItem
|
||||||
|
========
|
||||||
|
|
||||||
|
.. autoclass:: pyqtgraph.IsocurveItem
|
||||||
|
:members:
|
||||||
|
|
||||||
|
.. automethod:: pyqtgraph.IsocurveItem.__init__
|
@ -8,15 +8,27 @@ from GraphicsWidget import GraphicsWidget
|
|||||||
|
|
||||||
__all__ = ['AxisItem']
|
__all__ = ['AxisItem']
|
||||||
class AxisItem(GraphicsWidget):
|
class AxisItem(GraphicsWidget):
|
||||||
|
"""
|
||||||
|
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 draw a grid.
|
||||||
|
If maxTickLength is negative, ticks point into the plot.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, orientation, pen=None, linkView=None, parent=None, maxTickLength=-5, showValues=True):
|
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.
|
**Arguments:**
|
||||||
Ticks can be extended to make a grid.
|
orientation one of 'left', 'right', 'top', or 'bottom'
|
||||||
If maxTickLength is negative, ticks point into the plot.
|
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)
|
GraphicsWidget.__init__(self, parent)
|
||||||
self.label = QtGui.QGraphicsTextItem(self)
|
self.label = QtGui.QGraphicsTextItem(self)
|
||||||
self.showValues = showValues
|
self.showValues = showValues
|
||||||
@ -78,6 +90,11 @@ class AxisItem(GraphicsWidget):
|
|||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def setLogMode(self, log):
|
def setLogMode(self, log):
|
||||||
|
"""
|
||||||
|
If *log* is True, then ticks are displayed on a logarithmic scale and values
|
||||||
|
are adjusted accordingly. (This is usually accessed by changing the log mode
|
||||||
|
of a :func:`PlotItem <pyqtgraph.PlotItem.setLogMode>`)
|
||||||
|
"""
|
||||||
self.logMode = log
|
self.logMode = log
|
||||||
self.picture = None
|
self.picture = None
|
||||||
self.update()
|
self.update()
|
||||||
@ -110,6 +127,7 @@ class AxisItem(GraphicsWidget):
|
|||||||
self.picture = None
|
self.picture = None
|
||||||
|
|
||||||
def showLabel(self, show=True):
|
def showLabel(self, show=True):
|
||||||
|
"""Show/hide the label text for this axis."""
|
||||||
#self.drawLabel = show
|
#self.drawLabel = show
|
||||||
self.label.setVisible(show)
|
self.label.setVisible(show)
|
||||||
if self.orientation in ['left', 'right']:
|
if self.orientation in ['left', 'right']:
|
||||||
@ -120,6 +138,7 @@ class AxisItem(GraphicsWidget):
|
|||||||
self.setScale()
|
self.setScale()
|
||||||
|
|
||||||
def setLabel(self, text=None, units=None, unitPrefix=None, **args):
|
def setLabel(self, text=None, units=None, unitPrefix=None, **args):
|
||||||
|
"""Set the text displayed adjacent to the axis."""
|
||||||
if text is not None:
|
if text is not None:
|
||||||
self.labelText = text
|
self.labelText = text
|
||||||
self.showLabel()
|
self.showLabel()
|
||||||
@ -179,10 +198,11 @@ class AxisItem(GraphicsWidget):
|
|||||||
Set the value scaling for this axis.
|
Set the value scaling for this axis.
|
||||||
The scaling value 1) multiplies the values displayed along the axis
|
The scaling value 1) multiplies the values displayed along the axis
|
||||||
and 2) changes the way units are displayed in the label.
|
and 2) changes the way units are displayed in the label.
|
||||||
For example:
|
|
||||||
If the axis spans values from -0.1 to 0.1 and has units set to 'V'
|
For example: If the axis spans values from -0.1 to 0.1 and has units set
|
||||||
then a scale of 1000 would cause the axis to display values -100 to 100
|
to 'V' then a scale of 1000 would cause the axis to display values -100 to 100
|
||||||
and the units would appear as 'mV'
|
and the units would appear as 'mV'
|
||||||
|
|
||||||
If scale is None, then it will be determined automatically based on the current
|
If scale is None, then it will be determined automatically based on the current
|
||||||
range displayed by the axis.
|
range displayed by the axis.
|
||||||
"""
|
"""
|
||||||
@ -207,6 +227,7 @@ class AxisItem(GraphicsWidget):
|
|||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def setRange(self, mn, mx):
|
def setRange(self, mn, mx):
|
||||||
|
"""Set the range of values displayed by the axis"""
|
||||||
if mn in [np.nan, np.inf, -np.inf] or mx in [np.nan, np.inf, -np.inf]:
|
if mn in [np.nan, np.inf, -np.inf] or mx in [np.nan, np.inf, -np.inf]:
|
||||||
raise Exception("Not setting range to [%s, %s]" % (str(mn), str(mx)))
|
raise Exception("Not setting range to [%s, %s]" % (str(mn), str(mx)))
|
||||||
self.range = [mn, mx]
|
self.range = [mn, mx]
|
||||||
@ -223,6 +244,7 @@ class AxisItem(GraphicsWidget):
|
|||||||
return self._linkedView()
|
return self._linkedView()
|
||||||
|
|
||||||
def linkToView(self, view):
|
def linkToView(self, view):
|
||||||
|
"""Link this axis to a ViewBox, causing its displayed range to match the visible range of the view."""
|
||||||
oldView = self.linkedView()
|
oldView = self.linkedView()
|
||||||
self._linkedView = weakref.ref(view)
|
self._linkedView = weakref.ref(view)
|
||||||
if self.orientation in ['right', 'left']:
|
if self.orientation in ['right', 'left']:
|
||||||
@ -272,7 +294,8 @@ class AxisItem(GraphicsWidget):
|
|||||||
This method is called whenever the axis needs to be redrawn and is a
|
This method is called whenever the axis needs to be redrawn and is a
|
||||||
good method to override in subclasses that require control over tick locations.
|
good method to override in subclasses that require control over tick locations.
|
||||||
|
|
||||||
The return value must be a list of three tuples:
|
The return value must be a list of three tuples::
|
||||||
|
|
||||||
[
|
[
|
||||||
(major tick spacing, offset),
|
(major tick spacing, offset),
|
||||||
(minor tick spacing, offset),
|
(minor tick spacing, offset),
|
||||||
@ -311,12 +334,13 @@ class AxisItem(GraphicsWidget):
|
|||||||
|
|
||||||
def tickValues(self, minVal, maxVal, size):
|
def tickValues(self, minVal, maxVal, size):
|
||||||
"""
|
"""
|
||||||
Return the values and spacing of ticks to draw
|
Return the values and spacing of ticks to draw::
|
||||||
[
|
|
||||||
(spacing, [major ticks]),
|
[
|
||||||
(spacing, [minor ticks]),
|
(spacing, [major ticks]),
|
||||||
...
|
(spacing, [minor ticks]),
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
By default, this method calls tickSpacing to determine the correct tick locations.
|
By default, this method calls tickSpacing to determine the correct tick locations.
|
||||||
This is a good method to override in subclasses.
|
This is a good method to override in subclasses.
|
||||||
|
@ -334,7 +334,7 @@ class GradientEditorItem(TickSliderItem):
|
|||||||
**Bases:** :class:`TickSliderItem <pyqtgraph.TickSliderItem>`
|
**Bases:** :class:`TickSliderItem <pyqtgraph.TickSliderItem>`
|
||||||
|
|
||||||
An item that can be used to define a color gradient. Implements common pre-defined gradients that are
|
An item that can be used to define a color gradient. Implements common pre-defined gradients that are
|
||||||
customizable by the user. :class: `GradientWidget <pyqtgraph.widgets.GradientWidget>` provides a widget
|
customizable by the user. :class: `GradientWidget <pyqtgraph.GradientWidget>` provides a widget
|
||||||
with a GradientEditorItem that can be added to a GUI.
|
with a GradientEditorItem that can be added to a GUI.
|
||||||
|
|
||||||
======================== ===========================================================
|
======================== ===========================================================
|
||||||
@ -359,7 +359,7 @@ class GradientEditorItem(TickSliderItem):
|
|||||||
'top', and 'bottom'.
|
'top', and 'bottom'.
|
||||||
allowAdd Default is True. Specifies whether ticks can be added to the item.
|
allowAdd Default is True. Specifies whether ticks can be added to the item.
|
||||||
tickPen Default is white. Specifies the color of the outline of the ticks.
|
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>'
|
Can be any of the valid arguments for :func:`mkPen <pyqtgraph.mkPen>`
|
||||||
============= =================================================================================
|
============= =================================================================================
|
||||||
"""
|
"""
|
||||||
self.currentTick = None
|
self.currentTick = None
|
||||||
|
@ -71,6 +71,7 @@ class PlotItem(GraphicsWidget):
|
|||||||
:func:`setXLink <pyqtgraph.ViewBox.setXLink>`,
|
:func:`setXLink <pyqtgraph.ViewBox.setXLink>`,
|
||||||
:func:`setYLink <pyqtgraph.ViewBox.setYLink>`,
|
:func:`setYLink <pyqtgraph.ViewBox.setYLink>`,
|
||||||
:func:`viewRect <pyqtgraph.ViewBox.viewRect>`,
|
:func:`viewRect <pyqtgraph.ViewBox.viewRect>`,
|
||||||
|
:func:`viewRange <pyqtgraph.ViewBox.viewRange>`,
|
||||||
:func:`setMouseEnabled <pyqtgraph.ViewBox.setMouseEnabled>`,
|
:func:`setMouseEnabled <pyqtgraph.ViewBox.setMouseEnabled>`,
|
||||||
:func:`enableAutoRange <pyqtgraph.ViewBox.enableAutoRange>`,
|
:func:`enableAutoRange <pyqtgraph.ViewBox.enableAutoRange>`,
|
||||||
:func:`disableAutoRange <pyqtgraph.ViewBox.disableAutoRange>`,
|
:func:`disableAutoRange <pyqtgraph.ViewBox.disableAutoRange>`,
|
||||||
@ -188,7 +189,7 @@ class PlotItem(GraphicsWidget):
|
|||||||
## Wrap a few methods from viewBox
|
## Wrap a few methods from viewBox
|
||||||
for m in [
|
for m in [
|
||||||
'setXRange', 'setYRange', 'setXLink', 'setYLink',
|
'setXRange', 'setYRange', 'setXLink', 'setYLink',
|
||||||
'setRange', 'autoRange', 'viewRect', 'setMouseEnabled',
|
'setRange', 'autoRange', 'viewRect', 'viewRange', 'setMouseEnabled',
|
||||||
'enableAutoRange', 'disableAutoRange', 'setAspectLocked',
|
'enableAutoRange', 'disableAutoRange', 'setAspectLocked',
|
||||||
'register', 'unregister']: ## NOTE: If you update this list, please update the class docstring as well.
|
'register', 'unregister']: ## NOTE: If you update this list, please update the class docstring as well.
|
||||||
setattr(self, m, getattr(self.vb, m))
|
setattr(self, m, getattr(self.vb, m))
|
||||||
|
Loading…
Reference in New Issue
Block a user