X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHFiltersSelection%2FSMESH_TypeFilter.cxx;h=f406022d264b4c852e47da78af1f6e5d218ae115;hp=dd7de5e4d68d2d8ad1b1ddbce9186a11074671fc;hb=80b2ef84c3197c4159cd6b82cc6a476853e76022;hpb=4791f5b30ea7a9c1247aa551750dc71cb83b99aa diff --git a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx index dd7de5e4d..f406022d2 100644 --- a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx +++ b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx @@ -1,159 +1,150 @@ -// SMESH SMESHFiltersSelection : filter selector for viewer -// -// Copyright (C) 2003 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. -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESH_TypeFilter.cxx -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ +#include "SMESH_TypeFilter.hxx" -using namespace std; -#include "SMESH_TypeFilter.ixx" +#include -#include "SALOME_InteractiveObject.hxx" -#include "SALOME_TypeFilter.hxx" - -#include "utilities.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_Study.h" +#include +#include +SMESH_TypeFilter::SMESH_TypeFilter (MeshObjectType theType) +{ + myType = theType; +} -SMESH_TypeFilter::SMESH_TypeFilter(MeshObjectType aType) +SMESH_TypeFilter::~SMESH_TypeFilter() { - myKind = aType; } -Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const +bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const { - Handle(SALOME_TypeFilter) meshFilter = new SALOME_TypeFilter( "MESH" ); - if ( !meshFilter->IsOk(anObj) ) - return false; + bool Ok = false, extractReference = true; + + const LightApp_DataOwner* owner = + dynamic_cast(theDataOwner); + SalomeApp_Study* appStudy = dynamic_cast + (SUIT_Session::session()->activeApplication()->activeStudy()); + + if (owner && appStudy) { + _PTR(Study) study = appStudy->studyDS(); + QString entry = owner->entry(); + + _PTR(SObject) obj (study->FindObjectID(entry.latin1())), aRefSO; + if( extractReference && obj && obj->ReferencedObject( aRefSO ) ) + obj = aRefSO; + if (!obj) return false; - if ( anObj->hasEntry() ) { - QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); - SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() ); + _PTR(SObject) objFather = obj->GetFather(); + _PTR(SComponent) objComponent = obj->GetFatherComponent(); - bool Ok = false; + if( objComponent->ComponentDataType()!="SMESH" ) + return false; - switch ( myKind ) + int aLevel = obj->Depth() - objComponent->Depth(); + + // Max level under the component is 5: + // + // 0 Mesh Component + // 1 |- Hypotheses + // 2 | |- Regular 1D + // |- Algorithms + // |- Mesh 1 + // |- * Main Shape + // |- Applied Hypotheses + // |- Applied Algorithms + // |- Submeshes on Face + // 3 | |- SubmeshFace + // 4 | |- * Face 1 + // 4 | |- Applied algorithms ( selectable in Use Case Browser ) + // 5 | |- Regular 1D + // |- Group Of Nodes + + if (aLevel <= 0) + return false; + + switch (myType) { case HYPOTHESIS: { - SALOMEDS::SObject_var objFather = obj->GetFather(); - SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - if (( objFather->Tag() == 1 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) + 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; } case ALGORITHM: { - SALOMEDS::SObject_var objFather = obj->GetFather(); - SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - if (( objFather->Tag() == 2 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) + 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; } case MESH: { - SALOMEDS::SObject_var objFather = obj->GetFather(); - SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - - if (( obj->Tag() >= 3 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) == 0 ) ) + if ( aLevel == 1 && ( obj->Tag() >= 3 )) Ok = true; break; } case SUBMESH: { - SALOMEDS::SObject_var objFather = obj->GetFather(); - SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - - if (( objFather->Tag() >= 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) + // see SMESH_Gen_i.cxx for tag numbers + if ( aLevel == 3 && ( objFather->Tag() >= 4 && objFather->Tag() <= 10 )) Ok = true; break; } case MESHorSUBMESH: { - SALOMEDS::SObject_var objFather = obj->GetFather(); - SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - - if (( obj->Tag() >= 3 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) == 0 ) ) - Ok = true; - - if (( objFather->Tag() >= 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) + 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: + case SUBMESH_VERTEX: // Label "SubMeshes on vertexes" { - SALOMEDS::SObject_var objFather = obj->GetFather(); - SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - - if (( obj->Tag() == 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + if ( aLevel == 3 && ( objFather->Tag() == 4 )) Ok = true; break; } case SUBMESH_EDGE: { - SALOMEDS::SObject_var objFather = obj->GetFather(); - SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - - if (( obj->Tag() == 5 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + if ( aLevel == 3 && ( objFather->Tag() == 5 )) Ok = true; break; } case SUBMESH_FACE: { - SALOMEDS::SObject_var objFather = obj->GetFather(); - SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - - if (( obj->Tag() == 6 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + if ( aLevel == 3 && ( objFather->Tag() == 7 )) Ok = true; break; } case SUBMESH_SOLID: { - SALOMEDS::SObject_var objFather = obj->GetFather(); - SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - - if (( obj->Tag() == 7 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + if ( aLevel == 3 && ( objFather->Tag() == 9 )) Ok = true; break; } case SUBMESH_COMPOUND: { - SALOMEDS::SObject_var objFather = obj->GetFather(); - SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - - if (( obj->Tag() == 8 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + if ( aLevel == 3 && ( objFather->Tag() == 10 )) + Ok = true; + break; + } + case GROUP: + { + if ( aLevel == 3 && ( objFather->Tag() > 10 )) Ok = true; break; } } - - if ( Ok ) - return true; } - return false; + return Ok; +} + +MeshObjectType SMESH_TypeFilter::type() const +{ + return myType; }