1 // Copyright (C) 2007-2008 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
22 #include "SMESH_TypeFilter.hxx"
24 #include <SUIT_Session.h>
26 #include <SalomeApp_Study.h>
27 #include <LightApp_DataOwner.h>
29 #include <SALOMEconfig.h>
30 #include CORBA_CLIENT_HEADER(SMESH_Gen)
32 SMESH_TypeFilter::SMESH_TypeFilter (MeshObjectType theType)
37 SMESH_TypeFilter::~SMESH_TypeFilter()
41 bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const
43 bool Ok = false, extractReference = true;
45 const LightApp_DataOwner* owner =
46 dynamic_cast<const LightApp_DataOwner*>(theDataOwner);
47 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
48 (SUIT_Session::session()->activeApplication()->activeStudy());
50 if (owner && appStudy) {
51 _PTR(Study) study = appStudy->studyDS();
52 QString entry = owner->entry();
54 _PTR(SObject) obj (study->FindObjectID(entry.latin1())), aRefSO;
55 if( extractReference && obj && obj->ReferencedObject( aRefSO ) )
57 if (!obj) return false;
59 _PTR(SObject) objFather = obj->GetFather();
60 _PTR(SComponent) objComponent = obj->GetFatherComponent();
62 if( objComponent->ComponentDataType()!="SMESH" )
65 int aLevel = obj->Depth() - objComponent->Depth();
67 // Max level under the component is 5:
75 // |- Applied Hypotheses
76 // |- Applied Algorithms
77 // |- Submeshes on Face
80 // 4 | |- Applied algorithms ( selectable in Use Case Browser )
91 if (aLevel == 2 && (objFather->Tag() == SMESH::Tag_HypothesisRoot))
94 else if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_RefOnAppliedHypothesis))
95 // applied global hypo
97 else if (aLevel == 5 && (objFather->Tag() == SMESH::Tag_RefOnAppliedHypothesis))
104 if (aLevel == 2 && (objFather->Tag() == SMESH::Tag_AlgorithmsRoot))
107 else if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_RefOnAppliedAlgorithms))
108 // applied global algo
110 else if (aLevel == 5 && (objFather->Tag() == SMESH::Tag_RefOnAppliedAlgorithms))
111 // applied local algo
117 if (aLevel == 1 && (obj->Tag() >= SMESH::Tag_FirstMeshRoot))
123 // see SMESH_Gen_i.cxx for tag numbers
124 if (aLevel == 3 && (objFather->Tag() >= SMESH::Tag_FirstSubMesh &&
125 objFather->Tag() <= SMESH::Tag_LastSubMesh))
131 if (aLevel == 1 && (obj->Tag() >= SMESH::Tag_FirstMeshRoot))
133 else if (aLevel == 3 && (objFather->Tag() >= SMESH::Tag_FirstSubMesh &&
134 objFather->Tag() <= SMESH::Tag_LastSubMesh))
138 case SUBMESH_VERTEX: // Label "SubMeshes on vertexes"
140 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnVertex))
146 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnEdge))
152 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnFace))
158 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnSolid))
162 case SUBMESH_COMPOUND:
164 if (aLevel == 3 && (objFather->Tag() == SMESH::Tag_SubMeshOnCompound))
170 if (aLevel == 3 && (objFather->Tag() >= SMESH::Tag_FirstGroup))
179 MeshObjectType SMESH_TypeFilter::type() const