File: qgsrenderchecker.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 (319 lines) | stat: -rw-r--r-- 9,496 bytes parent folder | download | duplicates (6)
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/qgsrenderchecker.h                                          *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/







class QgsRenderChecker
{
%Docstring(signature="appended")
This is a helper class for unit tests that need to write an image and
compare it to an expected result or render time.
%End

%TypeHeaderCode
#include "qgsrenderchecker.h"
%End
  public:
    static const QMetaObject staticMetaObject;

  public:

    QgsRenderChecker();
%Docstring
Constructor for QgsRenderChecker.
%End

    static QDir testReportDir();
%Docstring
Returns the directory to use for generating a test report.

.. versionadded:: 3.28
%End

    static bool shouldGenerateReport();
%Docstring
Returns ``True`` if a test report should be generated given the current
environment.

.. versionadded:: 3.28
%End

    QString controlImagePath() const;
%Docstring
Returns the base path containing the reference images.

This defaults to an internal QGIS test data path, but can be changed via
:py:func:`~QgsRenderChecker.setControlImagePath`.

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

    void setControlImagePath( const QString &path );
%Docstring
Sets the base ``path`` containing the reference images.

.. seealso:: :py:func:`controlImagePath`

.. versionadded:: 3.18
%End

    QString report( bool ignoreSuccess = true ) const;
%Docstring
Returns the HTML report describing the results of the test run.

If ``ignoreSuccess`` is ``True`` then the report will always be empty if
the test was successful.

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

    QString markdownReport( bool ignoreSuccess = true ) const;
%Docstring
Returns the markdown report describing the results of the test run.

If ``ignoreSuccess`` is ``True`` then the report will always be empty if
the test was successful.

.. seealso:: :py:func:`report`

.. versionadded:: 3.34
%End

    float matchPercent() const;
%Docstring
Returns the percent of pixels which matched the control image.
%End

    unsigned int mismatchCount() const;
%Docstring
Returns the number of pixels which did not match the control image.
%End

    unsigned int matchTarget() const;
%Docstring
Returns the total number of pixels in the control image.
%End

    int elapsedTime() const;
%Docstring
Returns the total elapsed time for the rendering test.

.. note::

   This only records time for actual render part.
%End
    void setElapsedTimeTarget( int target );

    void setControlName( const QString &name );
%Docstring
Sets the base directory ``name`` for the control image (with control
image path suffixed).

The path to the image will be constructed like this:
:py:func:`~QgsRenderChecker.controlImagePath` + '/' + control name + '/'
+ control name + '.' + extension ('png' by default)
%End

    void setControlExtension( const QString &extension );
%Docstring
Sets file extension for the control image. By default it is "png"

.. versionadded:: 3.20
%End

    void setControlPathPrefix( const QString &name );
%Docstring
Sets the path prefix where the control images are kept. This will be
appended to :py:func:`~QgsRenderChecker.controlImagePath`.
%End

    void setControlPathSuffix( const QString &name );

    QString imageToHash( const QString &imageFile );
%Docstring
Gets an md5 hash that uniquely identifies an image
%End

    void setRenderedImage( const QString &imageFileName );
%Docstring
Sets the file name of the rendered image generated by the test.
%End

    void setExpectFail( bool expectFail );
%Docstring
Sets whether the comparison is expected to fail.

.. versionadded:: 3.28
%End

    QString renderedImage() const;
%Docstring
Returns the path of the rendered image generated by the test.

This method will return either the path set with
:py:func:`~QgsRenderChecker.setRenderedImage` or generated in
:py:func:`~QgsRenderChecker.runTest`.
%End

    void setMapSettings( const QgsMapSettings &mapSettings );

    void setColorTolerance( unsigned int colorTolerance );
%Docstring
Set tolerance for color components used by
:py:func:`~QgsRenderChecker.runTest` and
:py:func:`~QgsRenderChecker.compareImages`. Default value is 0.

:param colorTolerance: is maximum difference for each color component
                       including alpha to be considered correct.
%End

    void setSizeTolerance( int xTolerance, int yTolerance );
%Docstring
Sets the largest allowable difference in size between the rendered and
the expected image.

:param xTolerance: x tolerance in pixels
:param yTolerance: y tolerance in pixels
%End

    enum class Flag /BaseType=IntFlag/
    {
      AvoidExportingRenderedImage,
      Silent,
    };

    typedef QFlags<QgsRenderChecker::Flag> Flags;


    bool runTest( const QString &testName, unsigned int mismatchCount = 0, QgsRenderChecker::Flags flags = QgsRenderChecker::Flags() );
%Docstring
Test using renderer to generate the image to be compared.

:param testName: to be used as the basis for writing a file to e.g.
                 /tmp/theTestName.png
:param mismatchCount: defaults to 0. The number of pixels that are
                      allowed to be different from the control image. In
                      some cases rendering may be non-deterministic.
                      This parameter allows you to account for that by
                      providing a tolerance.
:param flags: render checker flags

.. note::

   Make sure to call setExpectedImage and setMapRenderer first
%End

    bool compareImages( const QString &testName, unsigned int mismatchCount = 0, const QString &renderedImageFile = QString(), QgsRenderChecker::Flags flags = QgsRenderChecker::Flags() );
%Docstring
Test using two arbitrary images (map renderer will not be used)

:param testName: to be used as the basis for writing a file to e.g.
                 /tmp/theTestName.png
:param mismatchCount: defaults to 0. The number of pixels that are
                      allowed to be different from the control image. In
                      some cases rendering may be non-deterministic.
                      This parameter allows you to account for that by
                      providing a tolerance.
:param renderedImageFile: to optionally override the output filename
:param flags: render checker flags

.. note::

   Make sure to call setExpectedImage and setRenderedImage first.
%End

    bool compareImages( const QString &testName, const QString &referenceImageFile, const QString &renderedImageFile, unsigned int mismatchCount = 0, QgsRenderChecker::Flags flags = QgsRenderChecker::Flags() );
%Docstring
Test using two arbitrary images at the specified paths for equality.

.. versionadded:: 3.18
%End

 bool isKnownAnomaly( const QString &diffImageFile ) /Deprecated/;
%Docstring
Gets a list of all the anomalies. An anomaly is a rendered difference
file where there is some red pixel content (indicating a render check
mismatch), but where the output was still acceptable. If the render diff
matches one of these anomalies we will still consider it to be
acceptable.

:return: a bool indicating if the diff matched one of the anomaly files

.. deprecated:: 3.40

   Use the test mask system instead.
%End

    static void drawBackground( QImage *image );
%Docstring
Draws a checkboard pattern for image backgrounds, so that opacity is
visible without requiring a transparent background for the image
%End

    QString expectedImageFile() const;
%Docstring
Returns the path to the expected image file

:return: Path to the expected image file
%End

    void enableDashBuffering( bool enable );
%Docstring
Call this to enable internal buffering of dash messages. You may later
call :py:func:`~QgsRenderChecker.dashMessages` to get access to the
buffered messages. If disabled (default) dash messages will be sent
immediately.

:param enable: Enable or disable buffering
%End

    QVector<QgsDartMeasurement> dartMeasurements() const;
%Docstring
Gets access to buffered dash messages. Only will return something if you
call enableDashBuffering( ``True`` ); before.

:return: buffered dash messages
%End

    static QString sourcePath();
%Docstring
Returns the path to the QGIS source code.

.. versionadded:: 3.36
%End

  protected:

};

QFlags<QgsRenderChecker::Flag> operator|(QgsRenderChecker::Flag f1, QFlags<QgsRenderChecker::Flag> f2);



bool compareWkt( const QString &a, const QString &b, double tolerance = 0.000001 );
%Docstring
Compare two WKT strings with some tolerance

:param a: first WKT string
:param b: second WKT string
:param tolerance: tolerance to use (optional, defaults to 0.000001)

:return: bool indicating if the WKT are sufficiently equal
%End

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