+ for( ; anIt.More(); anIt.Next(), i++ )
+ show( anIt.Value(), theMode, false, GetColor(i) );
+ }
+ else if (theShape.ShapeType()==TopAbs_FACE ||
+ theShape.ShapeType()==TopAbs_WIRE ||
+ theShape.ShapeType()==TopAbs_EDGE ||
+ theShape.ShapeType()==TopAbs_VERTEX )
+ show( theShape, theMode, false, GetColor(0) );
+}
+
+bool AreImagesEqual( const QImage& theImage1, const QImage& theImage2, double theTolerance )
+{
+ if( theImage1.isNull() || theImage2.isNull() )
+ return theImage1.isNull() == theImage2.isNull();
+
+ if( theImage1.size() != theImage2.size() )
+ return false;
+
+ int aBytesCount = theImage1.byteCount();
+ const uchar *aBytes1 = theImage1.constBits();
+ const uchar *aBytes2 = theImage2.constBits();
+ int aBytesCountE = 0;
+ for( int i=0; i<aBytesCount; i++ )
+ if( aBytes1[i] != aBytes2[i] )
+ aBytesCountE++;
+
+ if ((double)aBytesCountE / (double)aBytesCount > theTolerance)
+ return false;
+
+ return true;
+}
+
+bool TestViewer::AssertImages( QString& theMessage )
+{
+ 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();