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=9f17ae1b4e0f5d40ff6a9821af3ef69f10d2380b;hb=80b2ef84c3197c4159cd6b82cc6a476853e76022;hpb=e4737e85f0da6d3f90fd08f6be1c2825195fe16f diff --git a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx index 9f17ae1b4..f406022d2 100644 --- a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx +++ b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx @@ -1,74 +1,84 @@ -// File : SMESH_TypeFilter.cxx -// Created : Fri Dec 07 09:57:24 2001 -// Author : Nicolas REJNERI -// Project : SALOME -// Module : SMESH -// Copyright : Open CASCADE -// $Header$ +#include "SMESH_TypeFilter.hxx" -#include "SMESH_TypeFilter.ixx" +#include -#include "SALOME_InteractiveObject.hxx" -#include "SALOME_TypeFilter.hxx" +#include +#include -#include "utilities.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_Study.h" - -using namespace std; +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( "SMESH" ); - 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()); - bool Ok = false; + if (owner && appStudy) { + _PTR(Study) study = appStudy->studyDS(); + QString entry = owner->entry(); - 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) obj (study->FindObjectID(entry.latin1())), aRefSO; + if( extractReference && obj && obj->ReferencedObject( aRefSO ) ) + obj = aRefSO; + if (!obj) return false; + + _PTR(SObject) objFather = obj->GetFather(); + _PTR(SComponent) objComponent = obj->GetFatherComponent(); + + if( objComponent->ComponentDataType()!="SMESH" ) + return false; - SALOMEDS::SObject_var objFather = obj->GetFather(); - SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - int aLevel = obj->Depth() - objComponent->Depth(); - // Max level under the component is 4: + // 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 ) + if (aLevel <= 0) return false; - switch ( myKind ) + switch (myType) { case HYPOTHESIS: { - if ( aLevel == 2 && ( objFather->Tag() == 1 )) + 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: { - if ( aLevel == 2 && ( objFather->Tag() == 2 )) + 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; } @@ -133,3 +143,8 @@ Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& } return Ok; } + +MeshObjectType SMESH_TypeFilter::type() const +{ + return myType; +}