1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "SMESH_TypeFilter.hxx"
23 #include <SUIT_Session.h>
25 #include <SalomeApp_Study.h>
26 #include <LightApp_DataOwner.h>
28 #include <SALOMEconfig.h>
29 #include CORBA_CLIENT_HEADER(SMESH_Gen)
31 SMESH_TypeFilter::SMESH_TypeFilter (MeshObjectType theType)
36 SMESH_TypeFilter::~SMESH_TypeFilter()
40 bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const
42 bool Ok = false, extractReference = true;
44 const LightApp_DataOwner* owner =
45 dynamic_cast<const LightApp_DataOwner*>(theDataOwner);
46 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
47 (SUIT_Session::session()->activeApplication()->activeStudy());
49 if (owner && appStudy) {
50 _PTR(Study) study = appStudy->studyDS();
51 QString entry = owner->entry();
53 _PTR(SObject) obj (study->FindObjectID(entry.latin1())), aRefSO;
54 if( extractReference && obj && obj->ReferencedObject( aRefSO ) )
56 if (!obj) return false;
58 _PTR(SObject) objFather = obj->GetFather();
59 _PTR(SComponent) objComponent = obj->GetFatherComponent();
61 if( objComponent->ComponentDataType()!="SMESH" )
64 int aLevel = obj->Depth() - objComponent->Depth();
66 // Max level under the component is 5:
74 // |- Applied Hypotheses
75 // |- Applied Algorithms
76 // |- Submeshes on Face
79 // 4 | |- Applied algorithms ( selectable in Use Case Browser )
90 if (aLevel == 2 && (objFather->Tag() == SMESH::Tag_HypothesisRoot))
93 else if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_RefOnAppliedHypothesis))
94 // applied global hypo
96 else if (aLevel == 5 && (objFather->Tag() == SMESH::Tag_RefOnAppliedHypothesis))
103 if (aLevel == 2 && (objFather->Tag() == SMESH::Tag_AlgorithmsRoot))
106 else if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_RefOnAppliedAlgorithms))
107 // applied global algo
109 else if (aLevel == 5 && (objFather->Tag() == SMESH::Tag_RefOnAppliedAlgorithms))
110 // applied local algo
116 if (aLevel == 1 && (obj->Tag() >= SMESH::Tag_FirstMeshRoot))
122 // see SMESH_Gen_i.cxx for tag numbers
123 if (aLevel == 3 && (objFather->Tag() >= SMESH::Tag_FirstSubMesh &&
124 objFather->Tag() <= SMESH::Tag_LastSubMesh))
130 if (aLevel == 1 && (obj->Tag() >= SMESH::Tag_FirstMeshRoot))
132 else if (aLevel == 3 && (objFather->Tag() >= SMESH::Tag_FirstSubMesh &&
133 objFather->Tag() <= SMESH::Tag_LastSubMesh))
137 case SUBMESH_VERTEX: // Label "SubMeshes on vertexes"
139 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnVertex))
145 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnEdge))
151 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnFace))
157 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnSolid))
161 case SUBMESH_COMPOUND:
163 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnCompound))
169 if (aLevel == 3 && (objFather->Tag() >= SMESH::Tag_FirstGroup))
178 MeshObjectType SMESH_TypeFilter::type() const