1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "SMESH_TypeFilter.hxx"
25 #include <SUIT_Session.h>
27 #include <SalomeApp_Study.h>
28 #include <LightApp_DataOwner.h>
30 #include <SALOMEconfig.h>
31 #include CORBA_CLIENT_HEADER(SMESH_Gen)
33 SMESH_TypeFilter::SMESH_TypeFilter (MeshObjectType theType)
38 SMESH_TypeFilter::~SMESH_TypeFilter()
42 bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const
44 bool Ok = false, extractReference = true;
46 const LightApp_DataOwner* owner =
47 dynamic_cast<const LightApp_DataOwner*>(theDataOwner);
48 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
49 (SUIT_Session::session()->activeApplication()->activeStudy());
51 if (owner && appStudy) {
52 _PTR(Study) study = appStudy->studyDS();
53 QString entry = owner->entry();
55 _PTR(SObject) obj (study->FindObjectID(entry.toLatin1().data())), aRefSO;
56 if( extractReference && obj && obj->ReferencedObject( aRefSO ) )
58 if (!obj) return false;
60 _PTR(SObject) objFather = obj->GetFather();
61 _PTR(SComponent) objComponent = obj->GetFatherComponent();
63 if( objComponent->ComponentDataType()!="SMESH" )
66 int aLevel = obj->Depth() - objComponent->Depth();
68 // Max level under the component is 5:
76 // |- Applied Hypotheses
77 // |- Applied Algorithms
78 // |- Submeshes on Face
81 // 4 | |- Applied algorithms ( selectable in Use Case Browser )
92 if (aLevel == 2 && (objFather->Tag() == SMESH::Tag_HypothesisRoot))
95 else if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_RefOnAppliedHypothesis))
96 // applied global hypo
98 else if (aLevel == 5 && (objFather->Tag() == SMESH::Tag_RefOnAppliedHypothesis))
105 if (aLevel == 2 && (objFather->Tag() == SMESH::Tag_AlgorithmsRoot))
108 else if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_RefOnAppliedAlgorithms))
109 // applied global algo
111 else if (aLevel == 5 && (objFather->Tag() == SMESH::Tag_RefOnAppliedAlgorithms))
112 // applied local algo
118 if (aLevel == 1 && (obj->Tag() >= SMESH::Tag_FirstMeshRoot))
124 // see SMESH_Gen_i.cxx for tag numbers
125 if (aLevel == 3 && (objFather->Tag() >= SMESH::Tag_FirstSubMesh &&
126 objFather->Tag() <= SMESH::Tag_LastSubMesh))
132 if (aLevel == 1 && (obj->Tag() >= SMESH::Tag_FirstMeshRoot))
134 else if (aLevel == 3 && (objFather->Tag() >= SMESH::Tag_FirstSubMesh &&
135 objFather->Tag() <= SMESH::Tag_LastSubMesh))
139 case SUBMESH_VERTEX: // Label "SubMeshes on vertexes"
141 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnVertex))
147 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnEdge))
153 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnFace))
159 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnSolid))
163 case SUBMESH_COMPOUND:
165 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnCompound))
171 if (aLevel == 3 && (objFather->Tag() >= SMESH::Tag_FirstGroup))
180 MeshObjectType SMESH_TypeFilter::type() const