Salome HOME
Fix bug 12796: Warning missed for the bad file 'test18.med'
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Selection.cxx
index 1b281d27f2fbe22edd697f66034c1d1b247bd84f..7602c410b31212349110866af3ac1cc3aeb32641 100644 (file)
@@ -1,3 +1,22 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include "SMESHGUI_Selection.h"
 #include "SMESHGUI_Utils.h"
@@ -8,9 +27,9 @@
 #include "SMESH_Type.h"
 #include "SMESH_Actor.h"
 
-#include "SalomeApp_SelectionMgr.h"
+#include "LightApp_SelectionMgr.h"
 #include "SalomeApp_Study.h"
-#include "SalomeApp_VTKSelector.h"
+#include "LightApp_VTKSelector.h"
 
 #include "SUIT_Session.h"
 
@@ -25,7 +44,7 @@
 //purpose  : 
 //=======================================================================
 SMESHGUI_Selection::SMESHGUI_Selection()
-: SalomeApp_Selection()
+: LightApp_Selection()
 {
 }
 
@@ -41,13 +60,16 @@ SMESHGUI_Selection::~SMESHGUI_Selection()
 //function : init
 //purpose  : 
 //=======================================================================
-void SMESHGUI_Selection::init( const QString& client, SalomeApp_SelectionMgr* mgr )
+void SMESHGUI_Selection::init( const QString& client, LightApp_SelectionMgr* mgr )
 {
-  SalomeApp_Selection::init( client, mgr );
+  LightApp_Selection::init( client, mgr );
 
   if( mgr && study() )
   {
-    _PTR(Study) aStudy = study()->studyDS();
+    SalomeApp_Study* aSStudy = dynamic_cast<SalomeApp_Study*>(study());
+    if (!aSStudy)
+      return;
+    _PTR(Study) aStudy = aSStudy->studyDS();
 
     for( int i=0, n=count(); i<n; i++ )
       myTypes.append( typeName( type( entry( i ), aStudy ) ) );
@@ -58,10 +80,10 @@ void SMESHGUI_Selection::init( const QString& client, SalomeApp_SelectionMgr* mg
 //function : processOwner
 //purpose  : 
 //=======================================================================
-void SMESHGUI_Selection::processOwner( const SalomeApp_DataOwner* ow )
+void SMESHGUI_Selection::processOwner( const LightApp_DataOwner* ow )
 {
-  const SalomeApp_SVTKDataOwner* owner = 
-    dynamic_cast<const SalomeApp_SVTKDataOwner*> ( ow );
+  const LightApp_SVTKDataOwner* owner = 
+    dynamic_cast<const LightApp_SVTKDataOwner*> ( ow );
   if( owner )
     myActors.append( dynamic_cast<SMESH_Actor*>( owner->GetActor() ) );
   else
@@ -88,14 +110,14 @@ 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() );
+       // printf( "--> param() : [%s] = %s (%s)\n", p.latin1(), val.toString().latin1(), val.typeName() );
   //if ( val.type() == QVariant::List )
   //cout << "size: " << val.toList().count() << endl;
 
   if( val.isValid() )
     return val;
   else
-    return SalomeApp_Selection::param( ind, p );
+    return LightApp_Selection::param( ind, p );
 }
 
 //=======================================================================
@@ -267,11 +289,11 @@ QVariant SMESHGUI_Selection::isComputable( int ind ) const
   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
   {
 /*    Handle(SALOME_InteractiveObject) io =
-      static_cast<SalomeApp_DataOwner*>( myDataOwners[ ind ].get() )->IO();
+      static_cast<LightApp_DataOwner*>( myDataOwners[ ind ].get() )->IO();
     if ( !io.IsNull() ) {
       SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(io) ; // m,sm,gr->m
       if ( !mesh->_is_nil() ) {*/
-        _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ) );
+        _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).latin1() );
        //FindSObject( mesh );
         if ( so ) {
           GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
@@ -305,8 +327,8 @@ QVariant SMESHGUI_Selection::isVisible( int ind ) const
     QString ent = entry( ind );
     SMESH_Actor* actor = SMESH::FindActorByEntry( ent.latin1() );
     if ( actor && actor->hasIO() ) {
-      SVTK_RenderWindowInteractor* renderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
-      return QVariant( renderInter->isVisible( actor->getIO() ), 0 );
+      if(SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView())
+       return QVariant( aViewWindow->isVisible( actor->getIO() ), 0 );
     }
   }
   return QVariant( false, 0 );
@@ -379,6 +401,8 @@ int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study )
     }
     if( aFTag>10 )
       res = GROUP;
+    else
+      res = SUBMESH;
 
     break;
   }