Salome HOME
refs #653, #665 - 669: start implementation of features.
[modules/hydro.git] / src / HYDRO_tests / TestViewer.cxx
index fd8c5f867f3550c52a7ec04818a8a747680dfdd3..f54fdfc064a7b80137e9c1de65fa5c1f91a484cf 100644 (file)
@@ -2,6 +2,9 @@
 #include <TestViewer.h>
 #include <HYDROData_Tool.h>
 #include <OCCViewer_ViewManager.h>
+#ifdef WIN32
+  #pragma warning ( disable: 4251 )
+#endif
 #include <OCCViewer_ViewPort3d.h>
 #ifdef WIN32
   #pragma warning ( disable: 4251 )
@@ -18,7 +21,6 @@
 #include <AIS_Shape.hxx>
 #include <Aspect_ColorScale.hxx>
 #include <TopoDS_Iterator.hxx>
-
 #include <QDir>
 #include <QPainter>
 #include <QHash>
@@ -69,22 +71,31 @@ Handle(AIS_InteractiveContext) context()
 
 QColor TestViewer::GetColor(int i)
 {
-  QVector<QColor> aCV;
-  aCV  << QColor(0,0,255) 
-    << QColor(0,255,0)
-    << QColor(255,0,0)
-    << QColor(255,255,20) 
-    << QColor(20,255,255) 
-    << QColor(100,100,20) 
-    << QColor(10,100,150);
+  static QVector<QColor> aCV;
+  if( aCV.isEmpty() )
+  {
+    aCV  << QColor(0,0,255) 
+         << QColor(0,255,0)
+         << QColor(255,0,0)
+         << QColor(255,255,20) 
+         << QColor(20,255,255) 
+         << QColor(100,100,20) 
+         << QColor(10,100,150);
+  }
   return aCV[i];
 }
 
 void TestViewer::show( const Handle(AIS_InteractiveObject)& theObject,
                        int theMode, int theSelectionMode, bool isFitAll, const char* theKey )
 {
+  context()->CloseLocalContext();
   context()->EraseAll( Standard_False );
-  context()->Display( theObject, theMode, theSelectionMode );
+  if( theSelectionMode > 0 )
+  {
+    context()->Display( theObject, theMode, theSelectionMode );
+    context()->OpenLocalContext();
+    context()->Activate( theObject, theSelectionMode, Standard_True );
+  }
 
   myKey = theKey;
 
@@ -185,7 +196,7 @@ bool TestViewer::AssertImages( QString& theMessage )
   return false;
 }
 
-Handle_Aspect_ColorScale TestViewer::showColorScale()
+Handle_Aspect_ColorScale TestViewer::showColorScale( bool isShow )
 {
   Handle(V3d_View) aView = myViewWindow->getViewPort()->getView();
   if( aView.IsNull() )
@@ -212,8 +223,15 @@ Handle_Aspect_ColorScale TestViewer::showColorScale()
   aColorScale->SetTitle( "test" );
   aColorScale->SetRange( 0, 1 );
 
-  if( !aView->ColorScaleIsDisplayed() )
-    aView->ColorScaleDisplay();
-
+  if( isShow )
+  {
+    if( !aView->ColorScaleIsDisplayed() )
+      aView->ColorScaleDisplay();
+  }
+  else
+  {
+    if( aView->ColorScaleIsDisplayed() )
+      aView->ColorScaleErase();
+  }
   return aColorScale;
 }