Salome HOME
refs #1330: basic implementation of the not zoomable polyline arrows
[modules/hydro.git] / src / HYDRO_tests / TestViewer.cxx
index c5e8e5132c06530ee3b024019806abdab3fced84..71cd941b27ab2e332f21742e5f9e3dcc75818aab 100644 (file)
@@ -43,6 +43,7 @@
 #include <QHash>
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
+#include <Prs3d_IsoAspect.hxx>
 
 #include <GEOMUtils.hxx>
 #include <TopTools_ListOfShape.hxx>
@@ -141,29 +142,38 @@ void TestViewer::show( const Handle(AIS_InteractiveObject)& theObject,
   }
 
   if( isFitAll )
-  {
-    viewWindow()->onTopView();
-    viewWindow()->onFitAll();
-  }
+    fitAll();
+}
+
+void TestViewer::fitAll()
+{
+  viewWindow()->onTopView();
+  viewWindow()->onFitAll();
 }
 
-void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor )
+void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor,
+  int theUIANb, int theVIANb)
 {
   Handle(AIS_Shape) aShape = new AIS_Shape( theShape );
   if( theShape.ShapeType()==TopAbs_VERTEX )
     aShape->Attributes()->PointAspect()->SetTypeOfMarker( Aspect_TOM_X );
+  if (theShape.ShapeType()==TopAbs_FACE)
+  {
+    context()->DefaultDrawer()->UIsoAspect()->SetNumber(theUIANb);
+    context()->DefaultDrawer()->VIsoAspect()->SetNumber(theVIANb);
+    Handle_Prs3d_Drawer aDrawer = aShape->Attributes();
+    aDrawer->UIsoAspect()->SetNumber(theUIANb);
+    aDrawer->VIsoAspect()->SetNumber(theVIANb);
+  }
   aShape->SetMaterial( Graphic3d_NOM_PLASTIC );
   aShape->SetColor( HYDROData_Tool::toOccColor( theColor ) );
   context()->Display( aShape, theMode, 0, Standard_False );
 
   if( isFitAll )
-  {
-    viewWindow()->onTopView();
-    viewWindow()->onFitAll();
-  }
+    fitAll();
 }
-
-void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey )
+void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey,
+                       int theUIANb, int theVIANb)
 {
   QString aNewKey = theKey;
   if( !aNewKey.isEmpty() )
@@ -184,7 +194,7 @@ void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll,
   GEOMUtils::SortShapes(aListOfFaces);
   TopTools_ListIteratorOfListOfShape aLF(aListOfFaces);
   for( ; aLF.More(); aLF.Next(), i++)
-    show( aLF.Value(), theMode, false, GetColor(i) );
+    show( aLF.Value(), theMode, false, GetColor(i), theUIANb, theVIANb );
 
   //show all independent wires
   TopTools_ListOfShape aListOfWires;
@@ -207,10 +217,7 @@ void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll,
     show( aLE.Value(), theMode, false, GetColor(i) );
 
   if( isFitAll )
-  {
-    viewWindow()->onTopView();
-    viewWindow()->onFitAll();
-  }
+    fitAll();
 }
 
 /*void TestViewer::ShowShape(const TopoDS_Shape& theShape, int theMode, int& i)
@@ -256,9 +263,16 @@ bool AreImagesEqual( const QImage& theImage1, const QImage& theImage2, double th
   return true;
 }
 
-bool TestViewer::AssertImages( QString& theMessage )
+bool TestViewer::AssertImages( QString& theMessage, const QImage* theImage, const char* theCase )
 {
-  QImage anActualImage = viewWindow()->dumpView();
+  QImage anActualImage;
+  if( theImage )
+    anActualImage = *theImage;
+  else
+    anActualImage = viewWindow()->dumpView();
+
+  if( theCase )
+    myKey = theCase;
 
   QString anExpectedRefFilePath = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test/HYDRO";
   anExpectedRefFilePath += "/" + myKey + ".png";
@@ -285,6 +299,8 @@ bool TestViewer::AssertImages( QString& theMessage )
   QString aDiffFilePath = QDir::tempPath() + "/" + myKey + "_diff.png";
   aDiff.save( aDiffFilePath );
 
+  anExpectedRefImage.save( QDir::tempPath() + "/" + myKey + "_1.png");
+
   return false;
 }
 
@@ -332,6 +348,11 @@ void TestViewer::showColorScale( bool isShow )
   }
 }
 
+bool TestViewer::ColorScaleIsDisplayed()
+{
+  return context()->IsDisplayed( colorScale() );
+}
+
 void TestViewer::select( int theViewX, int theViewY )
 {
   Handle(V3d_View) aView = myViewWindow->getViewPort()->getView();