Salome HOME
Fix for the problem: VTK Viewer isn?t updated automatically after activation of...
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Selection.cxx
index eb48d8144df29a323679f849edac57a7a6633341..014e88a5a224c77011c207fe20d021266716e1a1 100644 (file)
@@ -86,9 +86,9 @@ QtxValue SMESHGUI_Selection::param( const int ind, const QString& p ) const
   else if ( p=="hasReference" )  val = QtxValue( hasReference( ind ) );
   else if ( p=="isVisible" )     val = QtxValue( isVisible( ind ) );
 
-//   printf( "--> param() : [%s] = %s (%s)\n", p.latin1(), val.toString().latin1(), val.typeName() );
-//   if ( val.type() == QVariant::List )
-//     cout << "size: " << val.toList().count() << endl;
+  // printf( "--> param() : [%s] = %s (%s)\n", p.latin1(), val.toString().latin1(), val.typeName() );
+  //if ( val.type() == QVariant::List )
+  //cout << "size: " << val.toList().count() << endl;
   return val;
 }
 
@@ -102,7 +102,7 @@ SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const
   if ( ind >= 0 && ind < myDataOwners.count() ) {
     const SalomeApp_SVTKDataOwner* owner = 
       dynamic_cast<const SalomeApp_SVTKDataOwner*> ( myDataOwners[ ind ].get() );
-    if ( owner )
+    if ( owner )    
       return dynamic_cast<SMESH_Actor*>( owner->GetActor() );
   }
   return 0;
@@ -286,10 +286,12 @@ QVariant SMESHGUI_Selection::hasReference( int ind ) const
 {
   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
   {
-    Handle(SALOME_InteractiveObject) io =
-      static_cast<SalomeApp_DataOwner*>( myDataOwners[ ind ].get() )->IO();
-    if ( !io.IsNull() )
-      return QVariant( io->hasReference(), 0 );
+    SalomeApp_DataOwner* owner = dynamic_cast<SalomeApp_DataOwner*>( myDataOwners[ ind ].operator->() );
+    if( owner )
+    {
+      _PTR(SObject) obj ( study()->studyDS()->FindObjectID( owner->entry().latin1() ) ), ref;
+      return QVariant( obj->ReferencedObject( ref ), 0 );
+    }
   }
   return QVariant( false, 0 );
 }
@@ -314,23 +316,36 @@ QVariant SMESHGUI_Selection::isVisible( int ind ) const
 }
 
 
+//=======================================================================
+//function : type
+//purpose  :
+//=======================================================================
+int SMESHGUI_Selection::type( SalomeApp_DataOwner* owner, _PTR(Study) study )
+{
+  return type( owner->entry(), study );
+}
+
 //=======================================================================
 //function : type
 //purpose  : 
 //=======================================================================
 
-int SMESHGUI_Selection::type( SalomeApp_DataOwner* owner,
-                              _PTR(Study) study )
+int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study )
 {
-  QString entry = owner->entry();
-
   _PTR(SObject) obj (study->FindObjectID(entry.latin1()));
   if( !obj )
     return -1;
 
+  _PTR(SObject) ref;
+  if( obj->ReferencedObject( ref ) )
+    obj = ref;
+
   _PTR(SObject) objFather = obj->GetFather();
   _PTR(SComponent) objComponent = obj->GetFatherComponent();
 
+  if( objComponent->ComponentDataType()!="SMESH" )
+    return -1;
+
   int aLevel = obj->Depth() - objComponent->Depth(),
       aFTag = objFather->Tag(),
       anOTag = obj->Tag(),