QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsmultirenderchecker.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmultirenderchecker.h
3  --------------------------------------
4  Date : 6.11.2014
5  Copyright : (C) 2014 Matthias Kuhn
6  Email : matthias at opengis dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSMULTIRENDERCHECKER_H
17 #define QGSMULTIRENDERCHECKER_H
18 
19 #include "qgsrenderchecker.h"
20 
51 class CORE_EXPORT QgsMultiRenderChecker
52 {
53  public:
55 
61  void setControlName( const QString& theName );
62 
63  void setControlPathPrefix( const QString& prefix );
64 
71  void setRenderedImage( const QString& renderedImagePath ) { mRenderedImage = renderedImagePath; }
72 
78  void setMapSettings( const QgsMapSettings& mapSettings );
79 
87  void setColorTolerance( unsigned int theColorTolerance ) { mColorTolerance = theColorTolerance; }
88 
102  bool runTest( const QString& theTestName, unsigned int theMismatchCount = 0 );
103 
109  QString report() const { return mReport; }
110 
115  QString controlImagePath() const;
116 
120  static void drawBackground( QImage* image ) { QgsRenderChecker::drawBackground( image ); }
121 
122  private:
123  QString mReport;
124  QString mRenderedImage;
125  QString mControlName;
126  QString mControlPathPrefix;
127  unsigned int mColorTolerance;
128  QgsMapSettings mMapSettings;
129 };
130 
131 #ifdef ENABLE_TESTS
132 
137 class CORE_EXPORT QgsCompositionChecker : public QgsMultiRenderChecker
138 {
139  public:
140  QgsCompositionChecker( const QString& testName, QgsComposition* composition );
141  ~QgsCompositionChecker();
142 
143  void setSize( QSize size ) { mSize = size; }
144 
145  bool testComposition( QString &theReport, int page = 0, int pixelDiff = 0 );
146 
147  private:
148  QgsCompositionChecker(); //forbidden
149 
150  QString mTestName;
151  QgsComposition* mComposition;
152  QSize mSize;
153  int mDotsPerMeter;
154 };
156 #endif
157 
158 
159 #endif // QGSMULTIRENDERCHECKER_H
QString report() const
Returns a report for this test.
The QgsMapSettings class contains configuration for rendering of the map.
This class allows checking rendered images against comparison images.
Graphics scene for map printing.
static void drawBackground(QImage *image)
Draws a checkboard pattern for image backgrounds, so that transparency is visible without requiring a...
void setColorTolerance(unsigned int theColorTolerance)
Set tolerance for color components used by runTest() Default value is 0.
static void drawBackground(QImage *image)
Draws a checkboard pattern for image backgrounds, so that transparency is visible without requiring a...
void setRenderedImage(const QString &renderedImagePath)
Set the path to the rendered image.