]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for bug PAL9160 ( No shading on visualizations ).
authormzn <mzn@opencascade.com>
Thu, 27 Oct 2005 11:32:44 +0000 (11:32 +0000)
committermzn <mzn@opencascade.com>
Thu, 27 Oct 2005 11:32:44 +0000 (11:32 +0000)
src/OBJECT/VISU_ScalarMapAct.cxx
src/OBJECT/VISU_ScalarMapAct.h
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h

index 01449f79b21e3d63a93c441610c1868223ca1c8f..4dd55d133c3c341d83b63462ce12ce96eba837c2 100644 (file)
@@ -78,3 +78,27 @@ 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);
+}
index bae6e5295529f0807fde190fe65cd048368a0dd1..1d8197a1edb32bcc87666cc034d1f0de5023a074 100644 (file)
@@ -50,6 +50,9 @@ class VTKOCC_EXPORT VISU_ScalarMapAct : public VISU_Actor {
   virtual void SetBarVisibility(bool theMode);
   virtual bool GetBarVisibility(){ return myBarVisibility;}
 
+  virtual void SetShading(bool theOn = true);
+  virtual bool IsShading();
+
  protected:
   VISU_ScalarMapAct();
   bool myBarVisibility;
index 0fc01fbbc0c0feaa2c0491e15b6dd93674f88ba7..cacfe29052dfd50a15baa45070ac373468f4c138 100644 (file)
@@ -48,6 +48,7 @@
 
 #include "VISU_Actor.h"
 #include "VISU_MeshAct.h"
+#include "VISU_ScalarMapAct.h"
 
 #include "VisuGUI_MagnitudeDlg.h"
 #include "VisuGUI_CursorDlg.h"
@@ -1603,7 +1604,27 @@ void VisuGUI::MakeShrink() {
   ChangeRepresentation(VISU::SHRINK);
 }
 
+void VisuGUI::SetShadingOn() {
+  if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d())
+    if(VISU_Actor* anActor = GetActor(aPrsObject)){
+      VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor);
+      if (aScalarMapActor)
+       aScalarMapActor->SetShading();
+    }
+  if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) 
+    vf->Repaint();
+}
 
+void VisuGUI::SetShadingOff() {
+  if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d())
+    if(VISU_Actor* anActor = GetActor(aPrsObject)){
+      VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor);
+      if (aScalarMapActor)
+       aScalarMapActor->SetShading(false);
+    }
+  if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) 
+    vf->Repaint();
+}
 
 //=====================================================================================
 // functions : Change Propertise
@@ -3001,6 +3022,16 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri
                    else
                      aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
                  }
+
+               if (VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(anVISUActor))
+                 {
+                   aPresMenu->insertSeparator();
+                   if (anActor->IsShading())
+                     aPresMenu->insertItem("Shading Off", visuGUI, SLOT(SetShadingOff()));
+                   else
+                     aPresMenu->insertItem("Shading On", visuGUI, SLOT(SetShadingOn()));
+                 }
+
                thePopup->insertItem("Representation", aPresMenu);
 
                // Add Properties
index bcefa28a22cb996ca8fc96d1c692f729ca3e4554..f8ade71c6e7094d1c9d2a2929a0a4451f3f6d9f0 100644 (file)
@@ -238,6 +238,9 @@ public slots:
   void MakeSurface();
   void MakePoints();
   void MakeShrink();
+
+  void SetShadingOn();
+  void SetShadingOff();
   
   void ChageColor();
   void ChangeWireframeColor();