From 106cb1d888bc9015fa711393529aebe65704258b Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 1 Dec 2005 10:05:15 +0000 Subject: [PATCH] Improvement: now in rules you can use "canBeDisplayed" parameter. It is true, if current object can be displayed in active viewer. The result of this check is calculated by new virtual method LightApp_Displayer::canBeDisplayed. GEOM, SMESH, VISU overrides it in order to provide information, what object can be displayed in what viewer --- src/GEOMGUI/GEOM_Displayer.cxx | 5 +++++ src/GEOMGUI/GEOM_Displayer.h | 3 ++- src/GEOMGUI/GeometryGUI.cxx | 25 +++++++++++++++++++++---- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 20b49e11c..def483eb2 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -1094,3 +1094,8 @@ void GEOM_Displayer::setShape( const TopoDS_Shape& theShape ) { myShape = theShape; } + +bool GEOM_Displayer::canBeDisplayed( const QString& /*entry*/, const QString& viewer_type ) const +{ + return viewer_type==SOCC_Viewer::Type() || viewer_type==SVTK_Viewer::Type(); +} diff --git a/src/GEOMGUI/GEOM_Displayer.h b/src/GEOMGUI/GEOM_Displayer.h index 8d081a0dd..d1af6d1f0 100644 --- a/src/GEOMGUI/GEOM_Displayer.h +++ b/src/GEOMGUI/GEOM_Displayer.h @@ -75,8 +75,9 @@ public: /* Destructor */ virtual ~GEOM_Displayer(); - /* Display/Erase object methods */ + virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const; + /* Display/Erase object methods */ void Display ( const Handle(SALOME_InteractiveObject)& theIO, const bool updateViewer = true, SALOME_View* theViewFrame = 0 ); diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index ae7f47327..04cf3d313 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -996,9 +996,16 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( 212, viewId, -1 ); createMenu( 214, viewId, -1 ); createMenu( separator(), viewId, -1 ); + +/* + PAL9111: + because of these items are accessible through object browser and viewers + we have removed they from main menu + createMenu( 216, viewId, -1 ); createMenu( 213, viewId, -1 ); createMenu( 215, viewId, -1 ); +*/ // ---- create toolbars -------------------------- @@ -1067,15 +1074,25 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action( 8034 ), -1, -1 ); // isos mgr->setRule( action( 8034 ), "client='OCCViewer' and selcount>0 and isVisible", true ); mgr->insert( separator(), -1, -1 ); // ----------- + + + + QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ", + onlyComponent = "((type='Component') and selcount=1)", + rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")", + types = "'Shape' 'Group'"; + mgr->insert( action( 216 ), -1, -1 ); // display - mgr->setRule( action( 216 ), "$component={'GEOM'} and ( (selcount>0) and (((isActiveView=true) and (($type in {'Shape' 'Group'} and (not isVisible)) or type='Component'))" - "or ((isActiveView=false) and ($type in {'Shape' 'Group' 'Component'}))))", true ); + mgr->setRule( action( 216 ), rule.arg( types ).arg( "not isVisible" ), true ); + mgr->insert( action( 215 ), -1, -1 ); // erase - mgr->setRule( action( 215 ), "$component={'GEOM'} and ((isActiveView=true) and (($type in {'Shape' 'Group'} and isVisible and selcount>0) or (type='Component' and selcount=1)))", true ); + mgr->setRule( action( 215 ), rule.arg( types ).arg( "isVisible" ), true ); + mgr->insert( action( 214 ), -1, -1 ); // erase All mgr->setRule( action( 214 ), "client='OCCViewer' or client='VTKViewer'", true ); + mgr->insert( action( 213 ), -1, -1 ); // display only - mgr->setRule( action( 213 ), "$component={'GEOM'} and (($type in {'Shape' 'Group'} and selcount>0) or (type='Component' and selcount=1))", true ); + mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), true ); mgr->insert( separator(), -1, -1 ); mgr->hide( mgr->actionId( action( myEraseAll ) ) ); -- 2.39.2