|
QGIS API Documentation
master-6227475
|
00001 /*************************************************************************** 00002 qgsrenderchecker.h - check maprender output against an expected image 00003 -------------------------------------- 00004 Date : 18 Jan 2008 00005 Copyright : (C) 2008 by Tim Sutton 00006 email : tim @ linfiniti.com 00007 *************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 00016 #ifndef QGSRENDERCHECKER_H 00017 #define QGSRENDERCHECKER_H 00018 00019 #include <QDir> 00020 #include <QString> 00021 #include <qgsmaprenderer.h> 00022 class QImage; 00023 00029 class CORE_EXPORT QgsRenderChecker 00030 { 00031 public: 00032 00033 QgsRenderChecker(); 00034 00036 ~QgsRenderChecker() {}; 00037 00038 QString controlImagePath() const; 00039 00040 QString report() { return mReport; }; 00041 float matchPercent() 00042 { 00043 return static_cast<float>( mMismatchCount ) / 00044 static_cast<float>( mMatchTarget ) * 100; 00045 }; 00046 unsigned int mismatchCount() { return mMismatchCount; }; 00047 unsigned int matchTarget() { return mMatchTarget; }; 00048 //only records time for actual render part 00049 int elapsedTime() { return mElapsedTime; }; 00050 void setElapsedTimeTarget( int theTarget ) { mElapsedTimeTarget = theTarget; }; 00055 void setControlName( const QString theName ); 00059 void setControlPathPrefix( const QString theName ) { mControlPathPrefix = theName + QDir::separator(); } 00061 QString imageToHash( QString theImageFile ); 00062 00063 void setRenderedImage( QString theImageFileName ) { mRenderedImageFile = theImageFileName; }; 00064 void setMapRenderer( QgsMapRenderer * thepMapRenderer ) { mpMapRenderer = thepMapRenderer; }; 00075 bool runTest( QString theTestName, unsigned int theMismatchCount = 0 ); 00076 00088 bool compareImages( QString theTestName, unsigned int theMismatchCount = 0, QString theRenderedImageFile = "" ); 00096 bool isKnownAnomaly( QString theDiffImageFile ); 00097 00098 private: 00099 00100 QString mReport; 00101 QString mExpectedImageFile; 00102 QString mControlName; 00103 QString mRenderedImageFile; 00104 unsigned int mMismatchCount; 00105 unsigned int mMatchTarget; 00106 int mElapsedTime; 00107 int mElapsedTimeTarget; 00108 QgsMapRenderer * mpMapRenderer; 00109 QString mControlPathPrefix; 00110 00111 }; // class QgsRenderChecker 00112 00113 #endif