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/
20 #include "SMESH_TypeFilter.hxx"
22 #include <SUIT_Session.h>
24 #include <SalomeApp_Study.h>
25 #include <LightApp_DataOwner.h>
27 SMESH_TypeFilter::SMESH_TypeFilter (MeshObjectType theType)
32 SMESH_TypeFilter::~SMESH_TypeFilter()
36 bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const
38 bool Ok = false, extractReference = true;
40 const LightApp_DataOwner* owner =
41 dynamic_cast<const LightApp_DataOwner*>(theDataOwner);
42 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
43 (SUIT_Session::session()->activeApplication()->activeStudy());
45 if (owner && appStudy) {
46 _PTR(Study) study = appStudy->studyDS();
47 QString entry = owner->entry();
49 _PTR(SObject) obj (study->FindObjectID(entry.latin1())), aRefSO;
50 if( extractReference && obj && obj->ReferencedObject( aRefSO ) )
52 if (!obj) return false;
54 _PTR(SObject) objFather = obj->GetFather();
55 _PTR(SComponent) objComponent = obj->GetFatherComponent();
57 if( objComponent->ComponentDataType()!="SMESH" )
60 int aLevel = obj->Depth() - objComponent->Depth();
62 // Max level under the component is 5:
70 // |- Applied Hypotheses
71 // |- Applied Algorithms
72 // |- Submeshes on Face
75 // 4 | |- Applied algorithms ( selectable in Use Case Browser )
86 if ( aLevel == 2 && ( objFather->Tag() == 1 )) // hypo definition
88 else if ( aLevel == 3 && ( objFather->Tag() == 2 )) // applied global hypo
90 else if ( aLevel == 5 && ( objFather->Tag() == 2 )) // applied local hypo
96 if ( aLevel == 2 && ( objFather->Tag() == 2 )) // algo definition
98 else if ( aLevel == 3 && ( objFather->Tag() == 3 )) // applied global algo
100 else if ( aLevel == 5 && ( objFather->Tag() == 3 )) // applied local algo
106 if ( aLevel == 1 && ( obj->Tag() >= 3 ))
112 // see SMESH_Gen_i.cxx for tag numbers
113 if ( aLevel == 3 && ( objFather->Tag() >= 4 && objFather->Tag() <= 10 ))
119 if ( aLevel == 1 && ( obj->Tag() >= 3 ))
121 else if ( aLevel == 3 && ( objFather->Tag() >= 4 && objFather->Tag() <= 10 ))
125 case SUBMESH_VERTEX: // Label "SubMeshes on vertexes"
127 if ( aLevel == 3 && ( objFather->Tag() == 4 ))
133 if ( aLevel == 3 && ( objFather->Tag() == 5 ))
139 if ( aLevel == 3 && ( objFather->Tag() == 7 ))
145 if ( aLevel == 3 && ( objFather->Tag() == 9 ))
149 case SUBMESH_COMPOUND:
151 if ( aLevel == 3 && ( objFather->Tag() == 10 ))
157 if ( aLevel == 3 && ( objFather->Tag() > 10 ))
166 MeshObjectType SMESH_TypeFilter::type() const