From 56c632e1c4f0b447088ecafec9d0a066f8e6db45 Mon Sep 17 00:00:00 2001 From: mzn Date: Thu, 27 Oct 2005 11:32:44 +0000 Subject: [PATCH] Fix for bug PAL9160 ( No shading on visualizations ). --- src/OBJECT/VISU_ScalarMapAct.cxx | 24 ++++++++++++++++++++++++ src/OBJECT/VISU_ScalarMapAct.h | 3 +++ src/VISUGUI/VisuGUI.cxx | 31 +++++++++++++++++++++++++++++++ src/VISUGUI/VisuGUI.h | 3 +++ 4 files changed, 61 insertions(+) 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(); -- 2.39.2