]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
correct selection mode activation
authorasl <asl@opencascade.com>
Tue, 20 Oct 2015 10:30:31 +0000 (13:30 +0300)
committerasl <asl@opencascade.com>
Tue, 20 Oct 2015 10:30:31 +0000 (13:30 +0300)
src/HYDRO_tests/TestViewer.cxx
src/HYDRO_tests/TestViewer.h
src/HYDRO_tests/test_HYDROData_LandCoverMap.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;
 }
index 4f6ee5503869499d020421c597175e177087a0bf..61f0d6bb6d9e67cec2ba5996d95a1c14e556c86e 100644 (file)
@@ -24,7 +24,7 @@ public:
   static bool AssertImages( QString& theMessage );
   static QColor GetColor(int i);
 
-  static Handle_Aspect_ColorScale showColorScale();
+  static Handle_Aspect_ColorScale showColorScale( bool );
 
 private:
   static OCCViewer_ViewManager* myViewManager;
index ce19c750f7937809c02d30b2690d6dd351b38752..aa7f4d2b1539b330ebeeeed64d08382366a1072a 100644 (file)
@@ -518,7 +518,7 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types()
 
   Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
   aPrs->SetTable( aTable );
-  TestViewer::show( aPrs, AIS_Shaded, 1, true, "LandCoverMap_PrsByTypes" );
+  TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByTypes" );
   CPPUNIT_ASSERT_IMAGES
 
   aDoc->Close();
@@ -550,10 +550,11 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff()
 
   Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
   aPrs->SetTable( aTable );
-  aPrs->SetColorScale( TestViewer::showColorScale() );
-  TestViewer::show( aPrs, AIS_Shaded, 1, true, "LandCoverMap_PrsByCoeff" );
+  aPrs->SetColorScale( TestViewer::showColorScale( true ) );
+  TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByCoeff" );
   CPPUNIT_ASSERT_IMAGES
 
+  TestViewer::showColorScale( false );
   aDoc->Close();
 }