Salome HOME
bug fixes with popup menus.
authorasv <asv@opencascade.com>
Tue, 14 Jun 2005 12:40:36 +0000 (12:40 +0000)
committerasv <asv@opencascade.com>
Tue, 14 Jun 2005 12:40:36 +0000 (12:40 +0000)
src/GEOMGUI/GEOMGUI_Selection.cxx
src/GEOMGUI/GEOMGUI_Selection.h
src/GEOMGUI/GeometryGUI.cxx

index 8896412aaa1981a2de2d4bc7825b8dfe19580652..aebc85bbfad9de5157ed5610f25cdd43d2c9a3c2 100644 (file)
@@ -19,6 +19,9 @@
 #include <SALOME_InteractiveObject.hxx>
 
 #include <SOCC_Prs.h>
+#include <SVTK_Prs.h>
+#include <SALOME_Actor.h>
+#include <vtkActorCollection.h>
 
 #include <OCCViewer_ViewModel.h>
 
@@ -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<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 "";
@@ -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 );
+}
index dc98b1f026754c855b5a8a5179c43596c2ad8fef..88470fb67e36f308d8e40229ca26b38a1b211b0e 100644 (file)
@@ -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;
 
index ec47ce98d01d53531c1ba62ffee752e5cc1f24ef..8dfea14e7b4efb73b12bad4341122dc4735898ed 100644 (file)
@@ -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 );
 }