From: asv Date: Tue, 14 Jun 2005 12:40:36 +0000 (+0000) Subject: bug fixes with popup menus. X-Git-Tag: T3_0_0_a4~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5013150a88333d5c1bc7cbd8a5dbae62b262ae0b;p=modules%2Fgeom.git bug fixes with popup menus. --- diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index 8896412aa..aebc85bbf 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -19,6 +19,9 @@ #include #include +#include +#include +#include #include @@ -38,13 +41,14 @@ QtxValue GEOMGUI_Selection::param( const int ind, const QString& p ) const { QtxValue val( SalomeApp_Selection::param( ind, p ) ); if ( !val.isValid() ) { - if ( p == "isVisible" ) val = QtxValue( isVisible( ind ) ); - else if ( p == "isOCC" ) val = QtxValue( isOCC() ); - else if ( p == "type" ) val = QtxValue( typeName( ind ) ); - else if ( p == "displaymode" ) val = QtxValue( displayMode( ind ) ); + if ( p == "isVisible" ) val = QtxValue( isVisible( ind ) ); + else if ( p == "isOCC" ) val = QtxValue( isOCC() ); + else if ( p == "type" ) val = QtxValue( typeName( ind ) ); + else if ( p == "displaymode" ) val = QtxValue( displayMode( ind ) ); + else if ( p == "isActiveViewer" ) val = QtxValue( isActiveViewer() ); } - //printf( "--> param() : [%s] = %s\n", p.latin1(), val.toString ().latin1() ); + printf( "--> param() : [%s] = %s\n", p.latin1(), val.toString ().latin1() ); return val; } @@ -113,8 +117,23 @@ QString GEOMGUI_Selection::displayMode( const int index ) const } } else { // assuming VTK - - } + SVTK_Prs* vtkPrs = (SVTK_Prs*) prs; + vtkActorCollection* lst = vtkPrs->GetObjects(); + if ( lst ) { + lst->InitTraversal(); + vtkActor* actor = lst->GetNextActor(); + if ( actor ) { + SALOME_Actor* salActor = dynamic_cast( actor ); + if ( salActor ) { + int dm = salActor->getDisplayMode(); + if ( dm == 0 ) + return "Wireframe"; + else if ( dm == 1 ) + return "Shading"; + } // if ( salome actor ) + } // if ( actor ) + } // if ( lst == vtkPrs->GetObjects() ) + } // if VTK } } return ""; @@ -157,3 +176,8 @@ GEOM::GEOM_Object_ptr GEOMGUI_Selection::getObject( const int index ) const } return GEOM::GEOM_Object::_nil(); } + +bool GEOMGUI_Selection::isActiveViewer() const +{ + return ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow() != 0 ); +} diff --git a/src/GEOMGUI/GEOMGUI_Selection.h b/src/GEOMGUI/GEOMGUI_Selection.h index dc98b1f02..88470fb67 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.h +++ b/src/GEOMGUI/GEOMGUI_Selection.h @@ -45,6 +45,7 @@ public: private: bool isVisible( const int ) const; bool isOCC() const; + bool isActiveViewer() const; QString typeName( const int ) const; QString displayMode( const int ) const; diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index ec47ce98d..8dfea14e7 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -955,13 +955,13 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->setRule( action( 8034 ), "$client in {'OCCViewer'} and selcount>0", true ); mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( action( 216 ), -1, -1 ); // display - mgr->setRule( action( 216 ), "selcount>0 and (($type in {'Shape' 'Group'} and ($isVisible in {false})) or $type in {'Component'})", true ); + mgr->setRule( action( 216 ), "$isActiveViewer in {true} and selcount>0 and (($type in {'Shape' 'Group'} and ($isVisible in {false})) or $type in {'Component'})", true ); mgr->insert( action( 215 ), -1, -1 ); // erase - mgr->setRule( action( 215 ), "selcount>0 and (($type in {'Shape' 'Group'} and $isVisible in {true}) or ($type in {'Component'} and selcount=1))", true ); + mgr->setRule( action( 215 ), "$isActiveViewer in {true} and selcount>0 and (($type in {'Shape' 'Group'} and $isVisible in {true}) or ($type in {'Component'} and selcount=1))", true ); mgr->insert( action( 214 ), -1, -1 ); // erase All - mgr->setRule( action( 214 ), "$client in {'OCCViewer' 'VTKViewer'}", true ); + mgr->setRule( action( 214 ), "$isActiveViewer in {true} and $client in {'OCCViewer' 'VTKViewer'}", true ); mgr->insert( action( 213 ), -1, -1 ); // display only - mgr->setRule( action( 213 ), "selcount>0 and ($type in {'Shape' 'Group'} or ($type in {'Component'} and selcount=1))", true ); + mgr->setRule( action( 213 ), "$isActiveViewer in {true} and selcount>0 and ($type in {'Shape' 'Group'} or ($type in {'Component'} and selcount=1))", true ); mgr->insert( separator(), -1, -1 ); }