Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / OBJECT / VISU_ScalarMapAct.cxx
index 6323ce13768f2b1143bcd921b07f475406d1a12e..93445e00fbd7d35206fc6e311d4b997978354769 100644 (file)
 
 #include <vtkObjectFactory.h>
 #include <vtkRenderer.h>
+#include <vtkProperty.h>
 
 vtkStandardNewMacro(VISU_ScalarMapAct);
 
-VISU_ScalarMapAct::VISU_ScalarMapAct(){
+VISU_ScalarMapAct
+::VISU_ScalarMapAct()
+{
   myScalarBar = VISU_ScalarBarActor::New();
 
   vtkProperty* aProperty = GetProperty();
-  aProperty->SetAmbient(0.5); 
-  aProperty->SetDiffuse(0.2);
-  aProperty->SetSpecular(0.2);
-  //aProperty->SetAmbient(1.0); 
-  //aProperty->SetDiffuse(0.0);
-  //aProperty->SetSpecular(0.0);
-
+  //aProperty->SetAmbient(0.5); 
+  //aProperty->SetDiffuse(0.2);
+  //aProperty->SetSpecular(0.2);
+  aProperty->SetAmbient(1.0); 
+  aProperty->SetDiffuse(0.0);
+  aProperty->SetSpecular(0.0);
+  
   myProperty->DeepCopy(aProperty);
 }
 
-VISU_ScalarMapAct::~VISU_ScalarMapAct(){
+VISU_ScalarMapAct
+::~VISU_ScalarMapAct()
+{
   myScalarBar->Delete();
 }
 
-void VISU_ScalarMapAct::AddToRender(vtkRenderer* theRenderer){
-  SALOME_Actor::AddToRender(theRenderer);
+void
+VISU_ScalarMapAct
+::AddToRender(vtkRenderer* theRenderer)
+{
+  Superclass::AddToRender(theRenderer);
+
   if(myScalarBar)
     theRenderer->AddActor2D(myScalarBar);
 }
 
-void VISU_ScalarMapAct::RemoveFromRender(vtkRenderer* theRenderer){
-  SALOME_Actor::RemoveFromRender(theRenderer);
+void
+VISU_ScalarMapAct
+::RemoveFromRender(vtkRenderer* theRenderer)
+{
   if(myScalarBar)
     theRenderer->RemoveActor(myScalarBar);
+
+  Superclass::RemoveFromRender(theRenderer);
 }
 
-void VISU_ScalarMapAct::SetVisibility(int theMode){
-  SALOME_Actor::SetVisibility(theMode);
-  if(myScalarBar) myScalarBar->SetVisibility(myBarVisibility && theMode);
+void
+VISU_ScalarMapAct
+::SetVisibility(int theMode)
+{
+  Superclass::SetVisibility(theMode);
+
+  if(myScalarBar) 
+    myScalarBar->SetVisibility(myBarVisibility && theMode);
 }
 
-int VISU_ScalarMapAct::GetVisibility(){
-  return SALOME_Actor::GetVisibility();
+int 
+VISU_ScalarMapAct
+::GetVisibility()
+{
+  return Superclass::GetVisibility();
 }
 
-void VISU_ScalarMapAct::SetBarVisibility(bool theMode){
+void
+VISU_ScalarMapAct
+::SetBarVisibility(bool theMode)
+{
   myBarVisibility = theMode;
   if(myScalarBar) myScalarBar->SetVisibility(myBarVisibility);
 }
+
+void VISU_ScalarMapAct::SetShading(bool theOn)
+{
+  vtkProperty* aProperty = GetProperty();
+
+  if (theOn)
+    {
+      aProperty->SetAmbient(0.0); 
+      aProperty->SetDiffuse(1.0);
+    }
+  else
+    {
+      aProperty->SetAmbient(1.0); 
+      aProperty->SetDiffuse(0.0);
+    }
+  myProperty->DeepCopy(aProperty);
+}
+
+bool VISU_ScalarMapAct::IsShading()
+{
+  vtkProperty* aProperty = GetProperty();
+  
+  return (aProperty->GetAmbient() == 0 && aProperty->GetDiffuse() == 1);
+}