From: mzn Date: Thu, 27 Oct 2005 11:59:06 +0000 (+0000) Subject: Fix for bug PAL9160 ( No shading on visualizations ). X-Git-Tag: BR-D5-38-2003_D2005-27-10~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=70ae0b0139868088804efbc29a4ac170c2b62127;p=modules%2Fvisu.git Fix for bug PAL9160 ( No shading on visualizations ). --- diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index b1f94480..5598166f 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -268,6 +268,12 @@ msgstr "Show Table" msgid "VisuGUI::MEN_SHRINK" msgstr "Shrink" +msgid "VisuGUI::MEN_SHADING" +msgstr "Shading On" + +msgid "VisuGUI::MEN_NOSHADING" +msgstr "Shading Off" + msgid "VisuGUI::MEN_STREAM_LINES" msgstr "Stream Lines" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 94d4ad9a..52de37fb 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -870,6 +870,20 @@ OnMakeShrink() ChangeRepresentation(this, VISU::SHRINK); } +void +VisuGUI:: +OnSetShadingOn() +{ + SetShading(this, true); +} + +void +VisuGUI:: +OnSetShadingOff() +{ + SetShading(this, false); +} + void VisuGUI:: OnChangeColor() @@ -2136,6 +2150,14 @@ createActions() createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(), tr("MEN_UNSHRINK"), "", 0, aParent, false, this, SLOT(OnMakeShrink())); + + createAction( VISU_SHADING, tr("MEN_SHADING"), QIconSet(), + tr("MEN_SHADING"), "", 0, aParent, false, + this, SLOT(OnSetShadingOn())); + + createAction( VISU_NOSHADING, tr("MEN_NOSHADING"), QIconSet(), + tr("MEN_NOSHADING"), "", 0, aParent, false, + this, SLOT(OnSetShadingOff())); createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(), tr("MEN_CELL_COLOR"), "", 0, aParent, false, @@ -2377,6 +2399,9 @@ createPopupMenus() mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe mgr->insert( action( VISU_SHRINK ) , parentId, -1, -1 ); // shrink mgr->insert( action( VISU_UNSHRINK ) , parentId, -1, -1 ); // unshrink + mgr->insert( separator(), parentId, -1, -1 ); + mgr->insert( action( VISU_SHADING ) , parentId, -1, -1 ); // shading + mgr->insert( action( VISU_NOSHADING ) , parentId, -1, -1 ); // noshading // "Properties" submenu parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 ); @@ -2501,6 +2526,9 @@ createPopupMenus() mgr->setRule( action( VISU_SHRINK ) , aRule + aShrinkType + " and isShrunk=0", true ); mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true ); + mgr->setRule( action( VISU_SHADING ) , aRule + " and isScalarMapAct=1 and isShading=0", true ); + mgr->setRule( action( VISU_NOSHADING ), aRule + " and isScalarMapAct=1 and isShading=1", true ); + // "Properties" submenu mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true ); mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true ); diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index b8746644..5b64c53a 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -105,6 +105,9 @@ protected slots: void OnMakePoints(); void OnMakeShrink(); + void OnSetShadingOn(); + void OnSetShadingOff(); + void OnChangeColor(); void OnChangeWireframeColor(); void OnChangeOpacity(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 0a795733..b3b99f36 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -55,6 +55,9 @@ #define VISU_SHRINK 4055 #define VISU_UNSHRINK 4056 +#define VISU_SHADING 4083 +#define VISU_NOSHADING 4084 + #define VISU_CELL_COLOR 4057 #define VISU_COLOR 4058 #define VISU_EDGE_COLOR 4059 diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index 3aceb478..73826c96 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -29,6 +29,7 @@ #include "VisuGUI_Tools.h" #include "VISU_Actor.h" +#include "VISU_ScalarMapAct.h" using namespace VISU; @@ -49,6 +50,8 @@ QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const // else if ( p == "isVisible" ) val = QtxValue( isVisible( ind ) ); else if ( p == "isShrunk" ) val = QtxValue( isShrunk( ind ) ); else if ( p == "hasActor" ) val = QtxValue( hasActor( ind ) ); + else if ( p == "isShading" ) val = QtxValue( isShading( ind ) ); + else if ( p == "isScalarMapAct" ) val = QtxValue( isScalarMapAct( ind ) ); } return val; @@ -215,3 +218,29 @@ QString VisuGUI_Selection::hasActor( const int ind ) const { return representation( ind ).isEmpty() ? "0" : "1"; } + +QString VisuGUI_Selection::isShading( const int ind ) const +{ + QString aResStr; + + if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) ) + if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ) + if ( VISU_ScalarMapAct* anActor = dynamic_cast(anVISUActor) ) + aResStr = anActor->IsShading() ? "1" : "0"; + + return aResStr; +} + +QString VisuGUI_Selection::isScalarMapAct( const int ind ) const +{ + QString aResStr; + + if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) ) + if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ) + { + VISU_ScalarMapAct* anActor = dynamic_cast(anVISUActor); + aResStr = anActor ? "1" : "0"; + } + + return aResStr; +} diff --git a/src/VISUGUI/VisuGUI_PopupTools.h b/src/VISUGUI/VisuGUI_PopupTools.h index f93d8810..537dfafb 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.h +++ b/src/VISUGUI/VisuGUI_PopupTools.h @@ -54,6 +54,8 @@ private: QString isVisible( const int ) const; QString isShrunk( const int ) const; QString hasActor( const int ) const; + QString isShading( const int ) const; + QString isScalarMapAct( const int ) const; private: int nbChild( const int, const bool ) const; diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 208b8a1a..86f6b654 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -36,6 +36,7 @@ #include "VISU_ViewManager_i.hh" #include "VISU_Actor.h" +#include "VISU_ScalarMapAct.h" #include "SalomeApp_Module.h" #include "SalomeApp_Study.h" @@ -500,6 +501,36 @@ namespace VISU } } } + + void + SetShading ( const SalomeApp_Module* theModule, + bool theOn ) + { + SUIT_ViewWindow* aView = GetActiveView(theModule, SVTK_Viewer::Type()); + if (!aView) return; + SVTK_ViewWindow* vw = dynamic_cast( aView ); + if( !vw ) + return; + + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO); + if (CORBA::is_nil(anObject)) return; + + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if (CORBA::is_nil(aVisuObj)) return; + + PortableServer::ServantBase_var aServant = VISU::GetServant(anObject); + if (!aServant.in()) return; + + VISU::Prs3d_i* aPrs3d = dynamic_cast(aServant.in()); + if (aPrs3d) { + if (VISU_Actor* anActor = GetActor(aPrs3d, vw)) { + if ( VISU_ScalarMapAct* aScalarMapActor = dynamic_cast(anActor) ) + aScalarMapActor->SetShading( theOn ); + } + vw->Repaint(); + } + } //************************************************************ // SObject type diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index 3d6fd0e5..f5fee097 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -110,6 +110,8 @@ namespace VISU { void ChangeRepresentation (const SalomeApp_Module* theModule, VISU::PresentationType theType); + void SetShading ( const SalomeApp_Module* theModule, bool theOn = true ); + // SObject type bool CheckTimeStamp(const SalomeApp_Module* theModule, _PTR(SObject)& theSObject,