+ QImage anActualImage = viewWindow()->dumpView();
+
+ QString anExpectedRefFilePath = qgetenv( "HYDRO_REFERENCE_DATA" );
+ anExpectedRefFilePath += "/" + myKey + ".png";
+ QImage anExpectedRefImage;
+ anExpectedRefImage.load( anExpectedRefFilePath );
+
+ if( AreImagesEqual( anActualImage, anExpectedRefImage, 0.001 ) )
+ {
+ theMessage = "";
+ return true;
+ }
+
+ QString aPath = QDir::tempPath() + "/" + myKey + ".png";
+ anActualImage.save( aPath );
+ //std::cout << anActualImage.width() << "x" << anActualImage.height() << std::endl;
+ theMessage = "The viewer contents does not correspond to the reference image: " + myKey;
+
+ QImage aDiff( anExpectedRefImage.width(), anExpectedRefImage.height(), QImage::Format_ARGB32 );
+ QPainter aPainter( &aDiff );
+ aPainter.drawImage( 0, 0, anExpectedRefImage );
+ aPainter.setCompositionMode( QPainter::RasterOp_SourceXorDestination );
+ aPainter.drawImage( 0, 0, anActualImage );
+
+ QString aDiffFilePath = QDir::tempPath() + "/" + myKey + "_diff.png";
+ aDiff.save( aDiffFilePath );
+
+ return false;
+}
+
+Handle_Aspect_ColorScale TestViewer::showColorScale( bool isShow )
+{
+ Handle(V3d_View) aView = myViewWindow->getViewPort()->getView();
+ if( aView.IsNull() )
+ return Handle(Aspect_ColorScale)();
+
+ Handle(Aspect_ColorScale) aColorScale = aView->ColorScale();
+ if( aColorScale.IsNull() )
+ return aColorScale;
+
+ Standard_Real anXPos = 0.05;
+ Standard_Real anYPos = 0.1;
+ Standard_Real aWidth = 0.2;
+ Standard_Real aHeight = 0.5;
+ Standard_Integer aTextHeight = 14;
+ Standard_Integer aNbIntervals = 30;
+
+ aColorScale->SetXPosition( anXPos );
+ aColorScale->SetYPosition( anYPos );
+ aColorScale->SetWidth( aWidth );
+ aColorScale->SetHeight( aHeight );
+ aColorScale->SetTextHeight( aTextHeight );
+ aColorScale->SetNumberOfIntervals( aNbIntervals );
+
+ aColorScale->SetTitle( "test" );
+ aColorScale->SetRange( 0, 1 );
+
+ if( isShow )
+ {
+ if( !aView->ColorScaleIsDisplayed() )
+ aView->ColorScaleDisplay();
+ }
+ else
+ {
+ if( aView->ColorScaleIsDisplayed() )
+ aView->ColorScaleErase();
+ }
+ return aColorScale;
+}
+
+void TestViewer::select( int theViewX, int theViewY )
+{
+ Handle(V3d_View) aView = myViewWindow->getViewPort()->getView();
+ context()->MoveTo( theViewX, theViewY, aView );
+ context()->Select();
+}
+
+bool TestViewer::areScriptsEqual( const QString& theBaseName )
+{
+ QString anExpectedRefFilePath = qgetenv( "HYDRO_REFERENCE_DATA" );
+ anExpectedRefFilePath += "/" + theBaseName;
+
+ QString anActualFilePath = QDir::tempPath() + "/" + theBaseName;
+
+ QFile anExpected( anExpectedRefFilePath );
+ QFile anActual( anActualFilePath );
+ if( !anExpected.open( QFile::ReadOnly | QFile::Text ) ||
+ !anActual.open ( QFile::ReadOnly | QFile::Text ) )
+ return false;
+
+ const int aLinesToOmit = 20;
+ for( int i=0; i<aLinesToOmit; i++ )
+ anExpected.readLine();
+
+ bool isEqual = true;
+ while( !anExpected.atEnd() && isEqual )
+ {
+ QString anExpectedLine = QString::fromUtf8( anExpected.readLine() );
+ QString anActualLine = anActual.readLine();
+ isEqual = anExpectedLine == anActualLine;
+ }
+
+ if( isEqual )
+ isEqual = anActual.atEnd();
+
+ anExpected.close();
+ anActual.close();