Skip to content

Commit 0f80dc6

Browse files
committed
Added docstrings to plot_grid, plot_histogram and plot_layout modules
1 parent 83fb930 commit 0f80dc6

File tree

10 files changed

+987
-4
lines changed

10 files changed

+987
-4
lines changed

doc/reference/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ Main `python-qwt` classes:
1515
plot
1616
plot_canvas
1717
plot_curve
18+
plot_directpainter
19+
plot_grid
20+
plot_histogram
21+
plot_layout
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. automodule:: qwt.plot_directpainter
2+
:members:

doc/reference/plot_grid.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. automodule:: qwt.plot_grid
2+
:members:

doc/reference/plot_histogram.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. automodule:: qwt.plot_histogram
2+
:members:

doc/reference/plot_layout.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. automodule:: qwt.plot_layout
2+
:members:

qwt/plot_curve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class QwtPlotCurve(QwtPlotSeriesItem, QwtSeriesStore):
195195
196196
Constructor
197197
198-
:param title: Parent plot widget
198+
:param title: Curve title
199199
:type title: qwt.text.QwtText or str or None
200200
"""
201201

qwt/plot_directpainter.py

Lines changed: 124 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
# Copyright (c) 2015 Pierre Raybaut, for the Python translation/optimization
66
# (see LICENSE file for more details)
77

8+
"""
9+
QwtPlotDirectPainter
10+
--------------------
11+
12+
.. autoclass:: QwtPlotDirectPainter
13+
:members:
14+
"""
15+
816
from qwt.qt.QtGui import QPainter, QRegion
917
from qwt.qt.QtCore import QObject, QT_VERSION, Qt, QEvent
1018

@@ -39,6 +47,51 @@ def __init__(self):
3947

4048

4149
class QwtPlotDirectPainter(QObject):
50+
"""
51+
Painter object trying to paint incrementally
52+
53+
Often applications want to display samples while they are
54+
collected. When there are too many samples complete replots
55+
will be expensive to be processed in a collection cycle.
56+
57+
`QwtPlotDirectPainter` offers an API to paint
58+
subsets (f.e all additions points) without erasing/repainting
59+
the plot canvas.
60+
61+
On certain environments it might be important to calculate a proper
62+
clip region before painting. F.e. for Qt Embedded only the clipped part
63+
of the backing store will be copied to a (maybe unaccelerated)
64+
frame buffer.
65+
66+
.. warning::
67+
68+
Incremental painting will only help when no replot is triggered
69+
by another operation (like changing scales) and nothing needs
70+
to be erased.
71+
72+
Paint attributes:
73+
74+
* `QwtPlotDirectPainter.AtomicPainter`:
75+
76+
Initializing a `QPainter` is an expensive operation.
77+
When `AtomicPainter` is set each call of `drawSeries()` opens/closes
78+
a temporary `QPainter`. Otherwise `QwtPlotDirectPainter` tries to
79+
use the same `QPainter` as long as possible.
80+
81+
* `QwtPlotDirectPainter.FullRepaint`:
82+
83+
When `FullRepaint` is set the plot canvas is explicitly repainted
84+
after the samples have been rendered.
85+
86+
* `QwtPlotDirectPainter.CopyBackingStore`:
87+
88+
When `QwtPlotCanvas.BackingStore` is enabled the painter
89+
has to paint to the backing store and the widget. In certain
90+
situations/environments it might be faster to paint to
91+
the backing store only and then copy the backing store to the canvas.
92+
This flag can also be useful for settings, where Qt fills the
93+
the clip region with the widget background.
94+
"""
4295

4396
# enum Attribute
4497
AtomicPainter = 0x01
@@ -50,6 +103,16 @@ def __init__(self, parent=None):
50103
self.__data = QwtPlotDirectPainter_PrivateData()
51104

52105
def setAttribute(self, attribute, on=True):
106+
"""
107+
Change an attribute
108+
109+
:param int attribute: Attribute to change
110+
:param bool on: On/Off
111+
112+
.. seealso::
113+
114+
:py:meth:`testAttribute()`
115+
"""
53116
if self.testAttribute(attribute) != on:
54117
self.__data.attributes |= attribute
55118
else:
@@ -58,29 +121,86 @@ def setAttribute(self, attribute, on=True):
58121
self.reset()
59122

60123
def testAttribute(self, attribute):
124+
"""
125+
:param int attribute: Attribute to be tested
126+
:return: True, when attribute is enabled
127+
128+
.. seealso::
129+
130+
:py:meth:`setAttribute()`
131+
"""
61132
return self.__data.attributes & attribute
62133

63134
def setClipping(self, enable):
135+
"""
136+
En/Disables clipping
137+
138+
:param bool enable: Enables clipping is true, disable it otherwise
139+
140+
.. seealso::
141+
142+
:py:meth:`hasClipping()`, :py:meth:`clipRegion()`,
143+
:py:meth:`setClipRegion()`
144+
"""
64145
self.__data.hasClipping = enable
65146

66147
def hasClipping(self):
148+
"""
149+
:return: Return true, when clipping is enabled
150+
151+
.. seealso::
152+
153+
:py:meth:`setClipping()`, :py:meth:`clipRegion()`,
154+
:py:meth:`setClipRegion()`
155+
"""
67156
return self.__data.hasClipping
68157

69158
def setClipRegion(self, region):
159+
"""
160+
Assign a clip region and enable clipping
161+
162+
Depending on the environment setting a proper clip region might
163+
improve the performance heavily. F.e. on Qt embedded only the clipped
164+
part of the backing store will be copied to a (maybe unaccelerated)
165+
frame buffer device.
166+
167+
:param QRegion region: Clip region
168+
169+
.. seealso::
170+
171+
:py:meth:`hasClipping()`, :py:meth:`setClipping()`,
172+
:py:meth:`clipRegion()`
173+
"""
70174
self.__data.clipRegion = region
71175
self.__data.hasClipping = True
72176

73177
def clipRegion(self):
178+
"""
179+
:return: Return Currently set clip region.
180+
181+
.. seealso::
182+
183+
:py:meth:`hasClipping()`, :py:meth:`setClipping()`,
184+
:py:meth:`setClipRegion()`
185+
"""
74186
return self.__data.clipRegion
75187

76188
def drawSeries(self, seriesItem, from_, to):
77-
"""When observing an measurement while it is running, new points have
189+
"""
190+
Draw a set of points of a seriesItem.
191+
192+
When observing a measurement while it is running, new points have
78193
to be added to an existing seriesItem. drawSeries() can be used to
79194
display them avoiding a complete redraw of the canvas.
80195
81-
Setting plot().canvas().setAttribute(Qt.WA_PaintOutsidePaintEvent, True)
196+
Setting `plot().canvas().setAttribute(Qt.WA_PaintOutsidePaintEvent, True)`
82197
will result in faster painting, if the paint engine of the canvas widget
83-
supports this feature."""
198+
supports this feature.
199+
200+
:param qwt.plot_seriesitem.QwtPlotSeriesItem seriesItem: Item to be painted
201+
:param int from_: Index of the first point to be painted
202+
:param int to: Index of the last point to be painted. If to < 0 the series will be painted to its last point.
203+
"""
84204
if seriesItem is None or seriesItem.plot() is None:
85205
return
86206
canvas = seriesItem.plot().canvas()
@@ -129,6 +249,7 @@ def drawSeries(self, seriesItem, from_, to):
129249
self.__data.seriesItem = None
130250

131251
def reset(self):
252+
"""Close the internal QPainter"""
132253
if self.__data.painter.isActive():
133254
w = self.__data.painter.device() #XXX: cast to QWidget
134255
if w:

0 commit comments

Comments
 (0)