|
5 | 5 | # Copyright (c) 2015 Pierre Raybaut, for the Python translation/optimization |
6 | 6 | # (see LICENSE file for more details) |
7 | 7 |
|
8 | | -from qwt.qt.QtCore import QRectF |
| 8 | +""" |
| 9 | +QwtSeriesStore |
| 10 | +-------------- |
9 | 11 |
|
| 12 | +.. autoclass:: QwtSeriesStore |
| 13 | + :members: |
| 14 | +""" |
10 | 15 |
|
11 | | -class QwtAbstractSeriesStore(object): |
12 | | - def dataChanged(self): |
13 | | - raise NotImplementedError |
14 | | - |
15 | | - def dataSize(self): |
16 | | - raise NotImplementedError |
17 | | - |
18 | | - def dataRect(self): |
19 | | - raise NotImplementedError |
20 | | - |
21 | | - def setRectOfInterest(self, rect): |
22 | | - raise NotImplementedError |
| 16 | +from qwt.qt.QtCore import QRectF |
23 | 17 |
|
24 | 18 |
|
25 | | -class QwtSeriesStore(QwtAbstractSeriesStore): |
| 19 | +class QwtSeriesStore(object): |
| 20 | + """ |
| 21 | + Class storing a `QwtSeriesData` object |
| 22 | +
|
| 23 | + `QwtSeriesStore` and `QwtPlotSeriesItem` are intended as base classes for |
| 24 | + all plot items iterating over a series of samples. |
| 25 | + """ |
26 | 26 | def __init__(self): |
27 | 27 | self.__series = None |
28 | 28 |
|
| 29 | + def setData(self, series): |
| 30 | + """ |
| 31 | + Assign a series of samples |
| 32 | +
|
| 33 | + :param qwt.series_data.QwtSeriesData series: Data |
| 34 | +
|
| 35 | + .. warning:: |
| 36 | + |
| 37 | + The item takes ownership of the data object, deleting it |
| 38 | + when its not used anymore. |
| 39 | + """ |
| 40 | + if self.__series != series: |
| 41 | + self.__series = series |
| 42 | + self.dataChanged() |
| 43 | + |
29 | 44 | def data(self): |
| 45 | + """ |
| 46 | + :return: the series data |
| 47 | + """ |
30 | 48 | return self.__series |
31 | 49 |
|
32 | 50 | def sample(self, index): |
| 51 | + """ |
| 52 | + :param int index: Index |
| 53 | + :return: Sample at position index |
| 54 | + """ |
33 | 55 | if self.__series: |
34 | 56 | return self.__series.sample(index) |
35 | 57 | else: |
36 | | - #TODO: not implemented! |
37 | 58 | return |
38 | 59 |
|
39 | | - def setData(self, series): |
40 | | - if self.__series != series: |
41 | | - self.__series = series |
42 | | - self.dataChanged() |
43 | | - |
44 | 60 | def dataSize(self): |
| 61 | + """ |
| 62 | + :return: Number of samples of the series |
| 63 | + |
| 64 | + .. seealso:: |
| 65 | + |
| 66 | + :py:meth:`setData()`, |
| 67 | + :py:meth:`qwt.series_data.QwtSeriesData.size()` |
| 68 | + """ |
45 | 69 | if self.__series is None: |
46 | 70 | return 0 |
47 | 71 | return self.__series.size() |
48 | 72 |
|
49 | 73 | def dataRect(self): |
| 74 | + """ |
| 75 | + :return: Bounding rectangle of the series or an invalid rectangle, when no series is stored |
| 76 | + |
| 77 | + .. seealso:: |
| 78 | + |
| 79 | + :py:meth:`qwt.series_data.QwtSeriesData.boundingRect()` |
| 80 | + """ |
50 | 81 | if self.__series is None or self.dataSize() == 0: |
51 | 82 | return QRectF(1.0, 1.0, -2.0, -2.0) |
52 | 83 | return self.__series.boundingRect() |
53 | 84 |
|
54 | 85 | def setRectOfInterest(self, rect): |
| 86 | + """ |
| 87 | + Set a the "rect of interest" for the series |
| 88 | + |
| 89 | + :param QRectF rect: Rectangle of interest |
| 90 | + |
| 91 | + .. seealso:: |
| 92 | + |
| 93 | + :py:meth:`qwt.series_data.QwtSeriesData.setRectOfInterest()` |
| 94 | + """ |
55 | 95 | if self.__series: |
56 | 96 | self.__series.setRectOfInterest(rect) |
57 | 97 |
|
58 | 98 | def swapData(self, series): |
| 99 | + """ |
| 100 | + Replace a series without deleting the previous one |
| 101 | + |
| 102 | + :param qwt.series_data.QwtSeriesData series: New series |
| 103 | + :return: Previously assigned series |
| 104 | + """ |
59 | 105 | swappedSeries = self.__series |
60 | 106 | self.__series = series |
61 | 107 | return swappedSeries |
0 commit comments