Salome HOME
Update copyright info (2010->2011)
[modules/smesh.git] / src / SMESHFiltersSelection / SMESH_TypeFilter.cxx
index bac11fe1899778835d656dffae856993c4190f54..5ad49ba68ecefba17dcea2833c6f015e772a0385 100644 (file)
@@ -1,22 +1,25 @@
-// 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.
+//  Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// 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
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-// See http://www.salome-platform.org/
+//  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 "SMESH_TypeFilter.hxx"
 
 #include <SUIT_Session.h>
 #include <SalomeApp_Study.h>
 #include <LightApp_DataOwner.h>
 
-SMESH_TypeFilter::SMESH_TypeFilter (MeshObjectType theType) 
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SMESH_Gen)
+
+SMESH_TypeFilter::SMESH_TypeFilter (MeshObjectType theType)
 {
   myType = theType;
 }
 
-SMESH_TypeFilter::~SMESH_TypeFilter() 
+SMESH_TypeFilter::~SMESH_TypeFilter()
 {
 }
 
@@ -46,7 +52,7 @@ bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const
     _PTR(Study) study = appStudy->studyDS();
     QString entry = owner->entry();
 
-    _PTR(SObject) obj (study->FindObjectID(entry.latin1())), aRefSO;
+    _PTR(SObject) obj (study->FindObjectID(entry.toLatin1().data())), aRefSO;
     if( extractReference && obj && obj->ReferencedObject( aRefSO ) )
       obj = aRefSO;
     if (!obj) return false;
@@ -80,90 +86,98 @@ bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const
       return false;
 
     switch (myType)
-      {
+    {
       case HYPOTHESIS:
-       {
-         if ( aLevel == 2 && ( objFather->Tag() == 1 )) // hypo definition
-           Ok = true;
-         else if ( aLevel == 3 && ( objFather->Tag() == 2 )) // applied global hypo
-           Ok = true;
-         else if ( aLevel == 5 && ( objFather->Tag() == 2 )) // applied local hypo
-           Ok = true;
-         break;
-       }
+        {
+          if      (aLevel == 2 && (objFather->Tag() == SMESH::Tag_HypothesisRoot))
+            // hypo definition
+            Ok = true;
+          else if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_RefOnAppliedHypothesis))
+            // applied global hypo
+            Ok = true;
+          else if (aLevel == 5 && (objFather->Tag() == SMESH::Tag_RefOnAppliedHypothesis))
+            // applied local hypo
+            Ok = true;
+          break;
+        }
       case ALGORITHM:
-       {
-         if ( aLevel == 2 && ( objFather->Tag() == 2 )) // algo definition
-           Ok = true;
-         else if ( aLevel == 3 && ( objFather->Tag() == 3 )) // applied global algo
-           Ok = true;
-         else if ( aLevel == 5 && ( objFather->Tag() == 3 )) // applied local algo
-           Ok = true;
-         break;
-       }
+        {
+          if      (aLevel == 2 && (objFather->Tag() == SMESH::Tag_AlgorithmsRoot))
+            // algo definition
+            Ok = true;
+          else if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_RefOnAppliedAlgorithms))
+            // applied global algo
+            Ok = true;
+          else if (aLevel == 5 && (objFather->Tag() == SMESH::Tag_RefOnAppliedAlgorithms))
+            // applied local algo
+            Ok = true;
+          break;
+        }
       case MESH:
-       {
-         if ( aLevel == 1 && ( obj->Tag() >= 3 ))
-           Ok = true;
-         break;
-       }
+        {
+          if (aLevel == 1 && (obj->Tag() >= SMESH::Tag_FirstMeshRoot))
+            Ok = true;
+          break;
+        }
       case SUBMESH:
-       {
-         // see SMESH_Gen_i.cxx for tag numbers
-         if ( aLevel == 3 && ( objFather->Tag() >= 4 && objFather->Tag() <= 10 ))
-           Ok = true;
-         break;
-       }
+        {
+          // see SMESH_Gen_i.cxx for tag numbers
+          if (aLevel == 3 && (objFather->Tag() >= SMESH::Tag_FirstSubMesh &&
+                              objFather->Tag() <= SMESH::Tag_LastSubMesh))
+            Ok = true;
+          break;
+        }
       case MESHorSUBMESH:
-       {
-         if ( aLevel == 1 && ( obj->Tag() >= 3 ))
-           Ok = true; // mesh
-          else if ( aLevel == 3 && ( objFather->Tag() >= 4 && objFather->Tag() <= 10 ))
-           Ok = true;
-         break;
-       }
-      case SUBMESH_VERTEX:  // Label "SubMeshes on vertexes"
-       {
-         if ( aLevel == 3 && ( objFather->Tag() == 4 ))
-           Ok = true;
-         break;
-       }
+        {
+          if (aLevel == 1 && (obj->Tag() >= SMESH::Tag_FirstMeshRoot))
+            Ok = true; // mesh
+          else if (aLevel == 3 && (objFather->Tag() >= SMESH::Tag_FirstSubMesh &&
+                                   objFather->Tag() <= SMESH::Tag_LastSubMesh))
+            Ok = true;
+          break;
+        }
+      case SUBMESH_VERTEX: // Label "SubMeshes on vertexes"
+        {
+          if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnVertex))
+            Ok = true;
+          break;
+        }
       case SUBMESH_EDGE:
-       {
-         if ( aLevel == 3 && ( objFather->Tag() == 5 ))
-           Ok = true;
-         break;
-       }
+        {
+          if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnEdge))
+            Ok = true;
+          break;
+        }
       case SUBMESH_FACE:
-       {
-         if ( aLevel == 3 && ( objFather->Tag() == 7 ))
-           Ok = true;
-         break;
-       }
+        {
+          if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnFace))
+            Ok = true;
+          break;
+        }
       case SUBMESH_SOLID:
-       {
-         if ( aLevel == 3 && ( objFather->Tag() == 9 ))
-           Ok = true;
-         break;
-       }
+        {
+          if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnSolid))
+            Ok = true;
+          break;
+        }
       case SUBMESH_COMPOUND:
-       {
-         if ( aLevel == 3 && ( objFather->Tag() == 10 ))
-           Ok = true;
-         break;
-       }
+        {
+          if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnCompound))
+            Ok = true;
+          break;
+        }
       case GROUP:
-       {
-         if ( aLevel == 3 && ( objFather->Tag() > 10 ))
-           Ok = true;
-         break;
-       }
-      }
+        {
+          if (aLevel == 3 && (objFather->Tag() >= SMESH::Tag_FirstGroup))
+            Ok = true;
+          break;
+        }
+    }
   }
   return Ok;
 }
 
-MeshObjectType SMESH_TypeFilter::type() const 
+MeshObjectType SMESH_TypeFilter::type() const
 {
   return myType;
 }