From: mzn Date: Thu, 27 Oct 2005 11:32:44 +0000 (+0000) Subject: Fix for bug PAL9160 ( No shading on visualizations ). X-Git-Tag: V2_2_6~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=56c632e1c4f0b447088ecafec9d0a066f8e6db45;p=modules%2Fvisu.git Fix for bug PAL9160 ( No shading on visualizations ). --- diff --git a/src/OBJECT/VISU_ScalarMapAct.cxx b/src/OBJECT/VISU_ScalarMapAct.cxx index 01449f79..4dd55d13 100644 --- a/src/OBJECT/VISU_ScalarMapAct.cxx +++ b/src/OBJECT/VISU_ScalarMapAct.cxx @@ -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); +} diff --git a/src/OBJECT/VISU_ScalarMapAct.h b/src/OBJECT/VISU_ScalarMapAct.h index bae6e529..1d8197a1 100644 --- a/src/OBJECT/VISU_ScalarMapAct.h +++ b/src/OBJECT/VISU_ScalarMapAct.h @@ -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; diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 0fc01fbb..cacfe290 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -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(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(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(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 diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index bcefa28a..f8ade71c 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -238,6 +238,9 @@ public slots: void MakeSurface(); void MakePoints(); void MakeShrink(); + + void SetShadingOn(); + void SetShadingOff(); void ChageColor(); void ChangeWireframeColor();