X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_Selection.cxx;h=c7fe08a39b05af90f9300d05e644f7c5aee3a402;hp=014e88a5a224c77011c207fe20d021266716e1a1;hb=4ff5bd61540272713e48de1eee75625028c32155;hpb=1f1c0e4dcbab7d45bfb55661736fbcfab125772c diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index 014e88a5a..c7fe08a39 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -1,3 +1,22 @@ +// Copyright (C) 2005 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.salome-platform.org/ +// #include "SMESHGUI_Selection.h" #include "SMESHGUI_Utils.h" @@ -8,9 +27,9 @@ #include "SMESH_Type.h" #include "SMESH_Actor.h" -#include "SalomeApp_SelectionMgr.h" +#include "LightApp_SelectionMgr.h" #include "SalomeApp_Study.h" -#include "SalomeApp_VTKSelector.h" +#include "LightApp_VTKSelector.h" #include "SUIT_Session.h" @@ -25,7 +44,7 @@ //purpose : //======================================================================= SMESHGUI_Selection::SMESHGUI_Selection() -: SalomeApp_Selection() +: LightApp_Selection() { } @@ -41,31 +60,36 @@ SMESHGUI_Selection::~SMESHGUI_Selection() //function : init //purpose : //======================================================================= -void SMESHGUI_Selection::init( const QString& client, SalomeApp_SelectionMgr* mgr ) +void SMESHGUI_Selection::init( const QString& client, LightApp_SelectionMgr* mgr ) { - SalomeApp_Selection::init( client, mgr ); + LightApp_Selection::init( client, mgr ); if( mgr && study() ) { - _PTR(Study) aStudy = study()->studyDS(); - - SUIT_DataOwnerPtrList sel; - mgr->selected( sel, client ); - myDataOwners = sel; - SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(), - aLast = sel.end(); - for( ; anIt!=aLast; anIt++ ) - { - SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() ); - SalomeApp_DataOwner* sowner = dynamic_cast( owner ); - if( sowner ) - myTypes.append( typeName( type( sowner, aStudy ) ) ); - else - myTypes.append( "Unknown" ); - } + SalomeApp_Study* aSStudy = dynamic_cast(study()); + if (!aSStudy) + return; + _PTR(Study) aStudy = aSStudy->studyDS(); + + for( int i=0, n=count(); i ( ow ); + if( owner ) + myActors.append( dynamic_cast( owner->GetActor() ) ); + else + myActors.append( 0 ); +} + //======================================================================= //function : param //purpose : @@ -84,12 +108,16 @@ QtxValue SMESHGUI_Selection::param( const int ind, const QString& p ) const else if ( p=="displayMode" ) val = QtxValue( displayMode( ind ) ); else if ( p=="isComputable" ) val = QtxValue( isComputable( ind ) ); else if ( p=="hasReference" ) val = QtxValue( hasReference( ind ) ); - else if ( p=="isVisible" ) val = QtxValue( isVisible( ind ) ); +// else if ( p=="isVisible" ) val = QtxValue( isVisible( ind ) ); - // printf( "--> param() : [%s] = %s (%s)\n", p.latin1(), val.toString().latin1(), val.typeName() ); + // printf( "--> param() : [%s] = %s (%s)\n", p.latin1(), val.toString().latin1(), val.typeName() ); //if ( val.type() == QVariant::List ) //cout << "size: " << val.toList().count() << endl; - return val; + + if( val.isValid() ) + return val; + else + return LightApp_Selection::param( ind, p ); } //======================================================================= @@ -99,13 +127,10 @@ QtxValue SMESHGUI_Selection::param( const int ind, const QString& p ) const SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const { - if ( ind >= 0 && ind < myDataOwners.count() ) { - const SalomeApp_SVTKDataOwner* owner = - dynamic_cast ( myDataOwners[ ind ].get() ); - if ( owner ) - return dynamic_cast( owner->GetActor() ); - } - return 0; + if( ind >= 0 && ind < count() ) + return ((QPtrList&)myActors).at( ind ); + else + return 0; } //======================================================================= @@ -214,6 +239,7 @@ QString SMESHGUI_Selection::controlMode( int ind ) const case SMESH_Actor::eMultiConnection: return "eMultiConnection"; case SMESH_Actor::eMultiConnection2D: return "eMultiConnection2D"; case SMESH_Actor::eArea: return "eArea"; + case SMESH_Actor::eVolume3D: return "eVolume3D"; case SMESH_Actor::eTaper: return "eTaper"; case SMESH_Actor::eAspectRatio: return "eAspectRatio"; case SMESH_Actor::eAspectRatio3D: return "eAspectRatio3D"; @@ -235,8 +261,9 @@ int SMESHGUI_Selection::numberOfNodes( int ind ) const { if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) { - CORBA::Object_var obj = - SMESH::DataOwnerToObject( static_cast( myDataOwners[ ind ].get() )); + _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).latin1() ); + CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() ); + if ( ! CORBA::is_nil( obj )) { SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj ); if ( ! mesh->_is_nil() ) @@ -261,18 +288,19 @@ QVariant SMESHGUI_Selection::isComputable( int ind ) const { if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) { - Handle(SALOME_InteractiveObject) io = - static_cast( myDataOwners[ ind ].get() )->IO(); +/* Handle(SALOME_InteractiveObject) io = + static_cast( myDataOwners[ ind ].get() )->IO(); if ( !io.IsNull() ) { SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(io) ; // m,sm,gr->m - if ( !mesh->_is_nil() ) { - _PTR(SObject) so = SMESH::FindSObject( mesh ); + if ( !mesh->_is_nil() ) {*/ + _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ) ); + //FindSObject( mesh ); if ( so ) { GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so ); return QVariant( !shape->_is_nil(), 0 ); } - } - } +// } +// } } return QVariant( false, 0 ); } @@ -284,16 +312,7 @@ QVariant SMESHGUI_Selection::isComputable( int ind ) const QVariant SMESHGUI_Selection::hasReference( int ind ) const { - if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) - { - SalomeApp_DataOwner* owner = dynamic_cast( myDataOwners[ ind ].operator->() ); - if( owner ) - { - _PTR(SObject) obj ( study()->studyDS()->FindObjectID( owner->entry().latin1() ) ), ref; - return QVariant( obj->ReferencedObject( ref ), 0 ); - } - } - return QVariant( false, 0 ); + return QVariant( isReference( ind ), 0 ); } //======================================================================= @@ -305,26 +324,16 @@ QVariant SMESHGUI_Selection::isVisible( int ind ) const { if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) { - QString entry = static_cast( myDataOwners[ ind ].get() )->entry(); - SMESH_Actor* actor = SMESH::FindActorByEntry( entry.latin1() ); + QString ent = entry( ind ); + SMESH_Actor* actor = SMESH::FindActorByEntry( ent.latin1() ); if ( actor && actor->hasIO() ) { - SVTK_RenderWindowInteractor* renderInter = SMESH::GetCurrentVtkView()->getRWInteractor(); - return QVariant( renderInter->isVisible( actor->getIO() ), 0 ); + if(SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView()) + return QVariant( aViewWindow->isVisible( actor->getIO() ), 0 ); } } return QVariant( false, 0 ); } - -//======================================================================= -//function : type -//purpose : -//======================================================================= -int SMESHGUI_Selection::type( SalomeApp_DataOwner* owner, _PTR(Study) study ) -{ - return type( owner->entry(), study ); -} - //======================================================================= //function : type //purpose : @@ -346,6 +355,9 @@ int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study ) if( objComponent->ComponentDataType()!="SMESH" ) return -1; + if( objComponent->GetIOR()==obj->GetIOR() ) + return COMPONENT; + int aLevel = obj->Depth() - objComponent->Depth(), aFTag = objFather->Tag(), anOTag = obj->Tag(), @@ -389,6 +401,8 @@ int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study ) } if( aFTag>10 ) res = GROUP; + else + res = SUBMESH; break; } @@ -427,6 +441,8 @@ QString SMESHGUI_Selection::typeName( const int t ) return "Mesh compound"; case GROUP: return "Group"; + case COMPONENT: + return "Component"; default: return "Unknown"; }