#include <SALOME_InteractiveObject.hxx>
#include <SOCC_Prs.h>
+#include <SVTK_Prs.h>
+#include <SALOME_Actor.h>
+#include <vtkActorCollection.h>
#include <OCCViewer_ViewModel.h>
{
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;
}
}
}
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<SALOME_Actor*>( 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 "";
}
return GEOM::GEOM_Object::_nil();
}
+
+bool GEOMGUI_Selection::isActiveViewer() const
+{
+ return ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow() != 0 );
+}
private:
bool isVisible( const int ) const;
bool isOCC() const;
+ bool isActiveViewer() const;
QString typeName( const int ) const;
QString displayMode( const int ) const;
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 );
}