Salome HOME
Bugs 153, 154.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_VTKPrsDisplayer.cxx
index 909012353d23fffc6ad6de8103e0a11e6de9a561..2b3e55f58810093e80c2ec9b07ecafa4bd60cd11 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <vtkLookupTable.h>
 #include <vtkRenderer.h>
+#include <vtkTextProperty.h>
 #include <vtkWindow.h>
 #include <vtkActor2DCollection.h>
 
@@ -52,8 +53,8 @@
 //#define SATURATION_START 1.0 
 //#define SATURATION_END   0.4
 
-#define HUE_START 0.0
-#define HUE_END   0.7 
+#define HUE_START 0.7
+#define HUE_END   0.0 
 #define SATURATION_START 1.0 
 #define SATURATION_END   1.0
 
@@ -103,18 +104,22 @@ void HYDROGUI_VTKPrsDisplayer::DeleteScalarBar( const int theViewerId )
   SVTK_Viewer* aViewer = module()->getVTKViewer( theViewerId );
   if( aViewer )
   {
-    SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(
-      aViewer->getViewManager()->getActiveView() );
-    if ( aView )
+    if ( myScalarBars.contains( (size_t)aViewer ) )
     {
-      if ( myScalarBars.contains( (size_t)aViewer ) )
+      SUIT_ViewManager* aViewMgr = dynamic_cast<SUIT_ViewManager*>( aViewer->getViewManager() );
+      if ( aViewMgr && aViewMgr->getViewsCount() > 0 )
       {
-        vtkScalarBarActor* aScalarBar = myScalarBars[ (size_t)aViewer ];
-        if ( aView->getRenderer()->HasViewProp( aScalarBar ) )
+        SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>( aViewMgr->getActiveView() );
+        if ( aView )
         {
-          aView->getRenderer()->RemoveActor2D( aScalarBar );
+          vtkScalarBarActor* aScalarBar = myScalarBars[ (size_t)aViewer ];
+          if ( aView->getRenderer()->HasViewProp( aScalarBar ) )
+          {
+            aView->getRenderer()->RemoveActor2D( aScalarBar );
+          }
         }
       }
+      myScalarBars.remove( (size_t)aViewer );
     }
   }
 }
@@ -335,6 +340,9 @@ void HYDROGUI_VTKPrsDisplayer::createScalarBar( const int theViewId )
     aTable->Build();
     vtkSmartPointer<vtkScalarBarActor> aScalarBar = vtkScalarBarActor::New();
     aScalarBar->SetLookupTable( aTable );
+    aScalarBar->SetNumberOfLabels( NB_COLORS * 0.75 );
+    aScalarBar->SetWidth( aScalarBar->GetWidth() / 1.5 );
+    aScalarBar->SetTextureGridWidth( aScalarBar->GetTextureGridWidth() * 4. );
     aTable->Delete();
     myScalarBars.insert( theViewId, aScalarBar );
   }