File: qgslayoututils.sip.in

package info (click to toggle)
qgis 3.40.11%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,183,800 kB
  • sloc: cpp: 1,595,841; python: 372,637; xml: 23,474; sh: 3,761; perl: 3,664; ansic: 2,257; sql: 2,137; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 154
file content (295 lines) | stat: -rw-r--r-- 10,308 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/layout/qgslayoututils.h                                     *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/




class QgsLayoutUtils
{
%Docstring(signature="appended")
Utilities for layouts.
%End

%TypeHeaderCode
#include "qgslayoututils.h"
%End
  public:

    static void rotate( double angle, double &x, double &y );
%Docstring
Rotates a point / vector around the origin.

:param angle: rotation angle in degrees, counterclockwise
:param x: in/out: x coordinate before / after the rotation
:param y: in/out: y coordinate before / after the rotation
%End

    static double normalizedAngle( double angle, bool allowNegative = false );
%Docstring
Ensures that an ``angle`` (in degrees) is in the range 0 <= angle < 360.
If ``allowNegative`` is ``True`` then angles between (-360, 360) are
allowed. If ``False``, angles are converted to positive angles in the
range [0, 360).
%End

    static double snappedAngle( double angle );
%Docstring
Snaps an ``angle`` (in degrees) to its closest 45 degree angle.

:return: angle snapped to 0, 45/90/135/180/225/270 or 315 degrees
%End

    static QgsRenderContext createRenderContextForMap( QgsLayoutItemMap *map, QPainter *painter, double dpi = -1 );
%Docstring
Creates a render context suitable for the specified layout ``map`` and
``painter`` destination. This method returns a new
:py:class:`QgsRenderContext` which matches the scale and settings of the
target map. If the ``dpi`` argument is not specified then the dpi will
be taken from the destination painter device.

.. seealso:: :py:func:`createRenderContextForLayout`
%End

    static QgsRenderContext createRenderContextForLayout( QgsLayout *layout, QPainter *painter, double dpi = -1 );
%Docstring
Creates a render context suitable for the specified ``layout`` and
``painter`` destination. This method returns a new
:py:class:`QgsRenderContext` which matches the scale and settings from
the layout's :py:func:`QgsLayout.referenceMap()`. If the ``dpi``
argument is not specified then the dpi will be taken from the
destination painter device.

.. seealso:: :py:func:`createRenderContextForMap`
%End

    static void relativeResizeRect( QRectF &rectToResize, const QRectF &boundsBefore, const QRectF &boundsAfter );
%Docstring
Resizes a QRectF relative to a resized bounding rectangle.

:param rectToResize: QRectF to resize, contained within boundsBefore.
                     The rectangle is linearly scaled to retain its
                     relative position and size within boundsAfter.
:param boundsBefore: QRectF of bounds before resize
:param boundsAfter: QRectF of bounds after resize
%End

    static double relativePosition( double position, double beforeMin, double beforeMax, double afterMin, double afterMax );
%Docstring
Returns a scaled position given a before and after range

:param position: initial position within before range to scale
:param beforeMin: minimum value in before range
:param beforeMax: maximum value in before range
:param afterMin: minimum value in after range
:param afterMax: maximum value in after range

:return: position scaled to range specified by afterMin and afterMax
%End

    static QFont scaledFontPixelSize( const QFont &font );
%Docstring
Returns a ``font`` where size is set in points and the size has been
upscaled with FONT_WORKAROUND_SCALE to workaround QT font rendering
bugs. Returns a font with size set in pixels.
%End

    static double fontAscentMM( const QFont &font );
%Docstring
Calculates a ``font`` ascent in millimeters, including workarounds for
QT font rendering issues.

.. seealso:: :py:func:`fontDescentMM`

.. seealso:: :py:func:`fontHeightMM`

.. seealso:: :py:func:`fontHeightCharacterMM`

.. seealso:: :py:func:`textWidthMM`
%End

    static double fontDescentMM( const QFont &font );
%Docstring
Calculate a ``font`` descent in millimeters, including workarounds for
QT font rendering issues.

.. seealso:: :py:func:`fontAscentMM`

.. seealso:: :py:func:`fontHeightMM`

.. seealso:: :py:func:`fontHeightCharacterMM`

.. seealso:: :py:func:`textWidthMM`
%End

    static double fontHeightMM( const QFont &font );
%Docstring
Calculate a ``font`` height in millimeters, including workarounds for QT
font rendering issues. The font height is the font ascent + descent + 1
(for the baseline).

.. seealso:: :py:func:`fontAscentMM`

.. seealso:: :py:func:`fontDescentMM`

.. seealso:: :py:func:`fontHeightCharacterMM`

.. seealso:: :py:func:`textWidthMM`
%End

    static double fontHeightCharacterMM( const QFont &font, QChar character );
%Docstring
Calculate a ``font`` height in millimeters of a single ``character``,
including workarounds for QT font rendering issues.

.. seealso:: :py:func:`fontAscentMM`

.. seealso:: :py:func:`fontDescentMM`

.. seealso:: :py:func:`fontHeightMM`

.. seealso:: :py:func:`textWidthMM`
%End

    static double textWidthMM( const QFont &font, const QString &text );
%Docstring
Calculate a ``font`` width in millimeters for a ``text`` string,
including workarounds for QT font rendering issues.

.. seealso:: :py:func:`fontAscentMM`

.. seealso:: :py:func:`fontDescentMM`

.. seealso:: :py:func:`fontHeightMM`

.. seealso:: :py:func:`fontHeightCharacterMM`

.. seealso:: :py:func:`textHeightMM`
%End

    static double textHeightMM( const QFont &font, const QString &text, double multiLineHeight = 1.0 );
%Docstring
Calculate a ``font`` height in millimeters for a ``text`` string,
including workarounds for QT font rendering issues. Note that this
method uses a non-standard measure of text height, where only the font
ascent is considered for the first line of text.

The ``multiLineHeight`` parameter specifies the line spacing factor.

.. seealso:: :py:func:`textWidthMM`
%End

    static void drawText( QPainter *painter, QPointF position, const QString &text, const QFont &font, const QColor &color = QColor() );
%Docstring
Draws ``text`` on a ``painter`` at a specific ``position``, taking care
of layout specific issues (calculation to pixel, scaling of font and
painter to work around Qt font bugs).

If ``color`` is specified, text will be rendered in that color. If not
specified, the current painter pen color will be used instead.
%End

    static void drawText( QPainter *painter, const QRectF &rectangle, const QString &text, const QFont &font, const QColor &color = QColor(), Qt::AlignmentFlag halignment = Qt::AlignLeft, Qt::AlignmentFlag valignment = Qt::AlignTop, int flags = Qt::TextWordWrap );
%Docstring
Draws ``text`` on a ``painter`` within a ``rectangle``, taking care of
layout specific issues (calculation to pixel, scaling of font and
painter to work around Qt font bugs).

If ``color`` is specified, text will be rendered in that color. If not
specified, the current painter pen color will be used instead.

The text alignment within ``rectangle`` can be set via the
``halignment`` and ``valignment`` arguments.

The ``flags`` parameter allows for passing Qt.TextFlags to control
appearance of rendered text.
%End

    static QRectF largestRotatedRectWithinBounds( const QRectF &originalRect, const QRectF &boundsRect, double rotation );
%Docstring
Calculates the largest scaled version of ``originalRect`` which fits
within ``boundsRect``, when it is rotated by the a specified
``rotation`` amount.

:param originalRect: QRectF to be rotated and scaled
:param boundsRect: QRectF specifying the bounds which the rotated and
                   scaled rectangle must fit within
:param rotation: the rotation in degrees to be applied to the rectangle

:return: largest scaled version of the rectangle possible
%End

    static QgsLayoutItemPage::Orientation decodePaperOrientation( const QString &string, bool &ok );
%Docstring
Decodes a ``string`` representing a paper orientation and returns the
decoded orientation. If the string was correctly decoded, ``ok`` will be
set to ``True``.
%End

 static double scaleFactorFromItemStyle( const QStyleOptionGraphicsItem *style ) /Deprecated/;
%Docstring
Extracts the scale factor from an item ``style``.

.. deprecated:: 3.40

   Use the variant with a QPainter argument instead.
%End

    static double scaleFactorFromItemStyle( const QStyleOptionGraphicsItem *style, QPainter *painter );
%Docstring
Extracts the scale factor from an item ``style`` and ``painter``.

.. versionadded:: 3.20
%End

    static QgsMapLayer *mapLayerFromString( const QString &string, QgsProject *project );
%Docstring
Resolves a ``string`` into a map layer from a given ``project``.
Attempts different forms of layer matching such as matching by layer id
or layer name.

Layer names are matched using a case-insensitive check, ONLY if an exact
case match was not found.

.. versionadded:: 3.2
%End

    static double calculatePrettySize( double minimumSize, double maximumSize );
%Docstring
Calculates a "pretty" size which falls between the range
[``minimumSize``, ``maximumSize``].

This method will return an optimal round number which falls within the
given range, finding the largest "pretty" number possible.

.. versionadded:: 3.10
%End

    static bool itemIsAClippingSource( const QgsLayoutItem *item );
%Docstring
Returns ``True`` if an ``item`` is a clipping item for another layout
item.

.. versionadded:: 3.16
%End

    static QVector< double > predefinedScales( const QgsLayout *layout );
%Docstring
Returns a list of predefined scales associated with a ``layout``.

.. versionadded:: 3.20
%End

};

/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/layout/qgslayoututils.h                                     *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/