|
9 | 9 |
|
10 | 10 |
|
11 | 11 |
|
| 12 | + |
| 13 | +class QgsLayoutItemRenderContext |
| 14 | +{ |
| 15 | +%Docstring |
| 16 | +Contains settings and helpers relating to a render of a QgsLayoutItem. |
| 17 | + |
| 18 | +.. versionadded:: 3.0 |
| 19 | +%End |
| 20 | + |
| 21 | +%TypeHeaderCode |
| 22 | +#include "qgslayoutitem.h" |
| 23 | +%End |
| 24 | + public: |
| 25 | + |
| 26 | + QgsLayoutItemRenderContext( QgsRenderContext &context, double viewScaleFactor = 1.0 ); |
| 27 | +%Docstring |
| 28 | +Constructor for QgsLayoutItemRenderContext. |
| 29 | + |
| 30 | +The ``renderContext`` parameter specifies a QgsRenderContext for use within |
| 31 | +the QgsLayoutItemRenderContext. |
| 32 | + |
| 33 | +The ``viewScaleFactor`` gives the current view zoom (scale factor). It can be |
| 34 | +used to scale render graphics so that they always appear a constant size, |
| 35 | +regardless of the current view zoom. |
| 36 | +%End |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + QgsRenderContext &renderContext(); |
| 41 | +%Docstring |
| 42 | +Returns a reference to the context's render context. |
| 43 | + |
| 44 | +Note that the context's painter has been scaled so that painter units are pixels. |
| 45 | +Use the QgsRenderContext methods to convert from millimeters or other units to the painter's units. |
| 46 | +%End |
| 47 | + |
| 48 | + |
| 49 | + double viewScaleFactor() const; |
| 50 | +%Docstring |
| 51 | +Returns the current view zoom (scale factor). It can be |
| 52 | +used to scale render graphics so that they always appear a constant size, |
| 53 | +regardless of the current view zoom. |
| 54 | + |
| 55 | +E.g. a value of 0.5 indicates that the view is zoomed out to 50% size, so rendered |
| 56 | +items must be scaled by 200% in order to have a constant visible size. A value |
| 57 | +of 2.0 indicates that the view is zoomed in 200%, so rendered items must be |
| 58 | +scaled by 50% in order to have a constant visible size. |
| 59 | +%End |
| 60 | + |
| 61 | + private: |
| 62 | + QgsLayoutItemRenderContext( const QgsLayoutItemRenderContext &rh ); |
| 63 | +}; |
| 64 | + |
| 65 | + |
12 | 66 | class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInterface
|
13 | 67 | {
|
14 | 68 | %Docstring
|
15 |
| - Base class for graphical items within a QgsLayout. |
| 69 | + Base class for graphical items within a :py:class:`QgsLayout`. |
16 | 70 |
|
17 | 71 | .. versionadded:: 3.0
|
18 | 72 | %End
|
@@ -939,9 +993,10 @@ painter.
|
939 | 993 | :param painter: destination QPainter
|
940 | 994 | %End
|
941 | 995 |
|
942 |
| - virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 ) = 0; |
| 996 | + virtual void draw( QgsLayoutItemRenderContext &context ) = 0; |
943 | 997 | %Docstring
|
944 |
| -Draws the item's contents using the specified render ``context``. |
| 998 | +Draws the item's contents using the specified item render ``context``. |
| 999 | + |
945 | 1000 | Note that the context's painter has been scaled so that painter units are pixels.
|
946 | 1001 | Use the QgsRenderContext methods to convert from millimeters or other units to the painter's units.
|
947 | 1002 | %End
|
|
0 commit comments