From: asl Date: Tue, 25 Oct 2005 08:19:21 +0000 (+0000) Subject: PAL10332 - references are interpreted as original objects in filters, dialogs, etc. X-Git-Tag: V3_1_0a3~43 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b0105f0f9d05ef09ad770cf0d343901589cba620;p=modules%2Fsmesh.git PAL10332 - references are interpreted as original objects in filters, dialogs, etc. --- diff --git a/src/SMESHFiltersSelection/SMESH_NumberFilter.cxx b/src/SMESHFiltersSelection/SMESH_NumberFilter.cxx index 517d45053..a44dcf87f 100644 --- a/src/SMESHFiltersSelection/SMESH_NumberFilter.cxx +++ b/src/SMESHFiltersSelection/SMESH_NumberFilter.cxx @@ -127,7 +127,7 @@ bool SMESH_NumberFilter::isOk (const SUIT_DataOwner* theDataOwner) const // Purpose : Retrieve geom object from SALOME_InteractiveObject //======================================================================= GEOM::GEOM_Object_ptr SMESH_NumberFilter::getGeom - (const SUIT_DataOwner* theDataOwner) const + (const SUIT_DataOwner* theDataOwner, const bool extractReference ) const { const SalomeApp_DataOwner* owner = dynamic_cast(theDataOwner); @@ -142,7 +142,10 @@ GEOM::GEOM_Object_ptr SMESH_NumberFilter::getGeom _PTR(Study) study = appStudy->studyDS(); QString entry = owner->entry(); - _PTR(SObject) aSO(study->FindObjectID(entry.latin1())); + _PTR(SObject) aSO( study->FindObjectID( entry.latin1() ) ), aRefSO; + if( extractReference && aSO && aSO->ReferencedObject( aRefSO ) ) + aSO = aRefSO; + if (!aSO) return GEOM::GEOM_Object::_nil(); diff --git a/src/SMESHFiltersSelection/SMESH_NumberFilter.hxx b/src/SMESHFiltersSelection/SMESH_NumberFilter.hxx index 6b3411293..4f6602e5f 100644 --- a/src/SMESHFiltersSelection/SMESH_NumberFilter.hxx +++ b/src/SMESHFiltersSelection/SMESH_NumberFilter.hxx @@ -55,7 +55,7 @@ class SMESH_NumberFilter : public SUIT_SelectionFilter void SetMainShape (GEOM::GEOM_Object_ptr); private: - GEOM::GEOM_Object_ptr getGeom (const SUIT_DataOwner*) const; + GEOM::GEOM_Object_ptr getGeom (const SUIT_DataOwner*, const bool extractReference = true ) const; private: char* myKind; diff --git a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx index acf7cb815..b99f4d1d7 100644 --- a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx +++ b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx @@ -16,7 +16,7 @@ SMESH_TypeFilter::~SMESH_TypeFilter() bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const { - bool Ok = false; + bool Ok = false, extractReference = true; const SalomeApp_DataOwner* owner = dynamic_cast(theDataOwner); @@ -27,7 +27,9 @@ bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const _PTR(Study) study = appStudy->studyDS(); QString entry = owner->entry(); - _PTR(SObject) obj (study->FindObjectID(entry.latin1())); + _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(); diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index e53d67a79..d802648e4 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -667,7 +667,7 @@ namespace{ { // VSR 17/11/04: check if all objects selected belong to SMESH component --> start SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr(); - SALOME_ListIO selected; aSel->selectedObjects( selected ); + SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false ); QString aParentComponent = QString::null; for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() ) @@ -1829,7 +1829,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); SALOME_ListIO selected; if( aSel ) - aSel->selectedObjects( selected ); + aSel->selectedObjects( selected, QString::null, false ); SALOME_ListIteratorOfListIO It(selected); for (int i = 0; It.More(); It.Next(), i++) { diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index 33f01403f..1b281d27f 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -49,23 +49,25 @@ void SMESHGUI_Selection::init( const QString& client, SalomeApp_SelectionMgr* mg { _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" ); - } + for( int i=0, n=count(); i ( ow ); + if( owner ) + myActors.append( dynamic_cast( owner->GetActor() ) ); + else + myActors.append( 0 ); +} + //======================================================================= //function : param //purpose : @@ -103,13 +105,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; } //======================================================================= @@ -240,8 +239,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() ) @@ -266,18 +266,19 @@ QVariant SMESHGUI_Selection::isComputable( int ind ) const { if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) { - Handle(SALOME_InteractiveObject) 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 ); } @@ -289,16 +290,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 ); } //======================================================================= @@ -310,8 +302,8 @@ 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 ); @@ -320,16 +312,6 @@ QVariant SMESHGUI_Selection::isVisible( int ind ) const 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 : diff --git a/src/SMESHGUI/SMESHGUI_Selection.h b/src/SMESHGUI/SMESHGUI_Selection.h index 524aa26a2..833dde674 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.h +++ b/src/SMESHGUI/SMESHGUI_Selection.h @@ -31,7 +31,6 @@ #include "SalomeApp_Selection.h" #include "SALOMEDSClient_definitions.hxx" -#include "SUIT_DataOwner.h" class SalomeApp_SelectionMgr; class SALOMEDSClient_Study; @@ -46,6 +45,7 @@ public: virtual void init( const QString&, SalomeApp_SelectionMgr* ); virtual QtxValue param( const int , const QString& paramName ) const; + virtual void processOwner( const SalomeApp_DataOwner* ); // got from object, not from actor virtual int numberOfNodes( int ind ) const; @@ -64,12 +64,11 @@ public: SMESH_Actor* getActor( int ind ) const; static int type( const QString&, _PTR(Study) ); - static int type( SalomeApp_DataOwner* owner, _PTR(Study) study); static QString typeName( const int type); private: - QStringList myTypes; - SUIT_DataOwnerPtrList myDataOwners; + QStringList myTypes; + QPtrList myActors; }; #endif diff --git a/src/SMESHGUI/SMESHGUI_SelectionOp.cxx b/src/SMESHGUI/SMESHGUI_SelectionOp.cxx index 1bc466c6a..699231958 100644 --- a/src/SMESHGUI/SMESHGUI_SelectionOp.cxx +++ b/src/SMESHGUI/SMESHGUI_SelectionOp.cxx @@ -43,6 +43,8 @@ #include CORBA_SERVER_HEADER(GEOM_Gen) #include +#include + /* Class : SMESHGUI_SelectionOp Description : Base operation for all operations using object selection in viewer or objectbrowser @@ -357,7 +359,7 @@ void SMESHGUI_SelectionOp::selected( QStringList& names, SalomeApp_Dialog::TypesList& types, QStringList& ids ) const { - SUIT_DataOwnerPtrList list; selectionMgr()->selected( list ); +/* SUIT_DataOwnerPtrList list; selectionMgr()->selected( list ); SUIT_DataOwnerPtrList::const_iterator anIt = list.begin(), aLast = list.end(); for( ; anIt!=aLast; anIt++ ) @@ -389,6 +391,37 @@ void SMESHGUI_SelectionOp::selected( QStringList& names, types.append( typeById( id, Object ) ); names.append( owner->IO()->getName() ); } + }*/ + + SALOME_ListIO selObjs; + TColStd_IndexedMapOfInteger selIndices; + selectionMgr()->selectedObjects( selObjs ); + Selection_Mode mode = selectionMode(); + EntityType objtype = mode == NodeSelection ? MeshNode : MeshElement; + + for( SALOME_ListIteratorOfListIO anIt( selObjs ); anIt.More(); anIt.Next() ) + { + selIndices.Clear(); + selectionMgr()->GetIndexes( anIt.Value(), selIndices ); + if( selIndices.Extent()==0 ) + { + QString id_str = QString( "%1%2%3" ).arg( anIt.Value()->getEntry() ).arg( idChar() ), current_id_str; + for( int i=1, n=selIndices.Extent(); i<=n; i++ ) + { + int curid = selIndices( i ); + current_id_str = id_str.arg( curid ); + ids.append( current_id_str ); + types.append( typeById( current_id_str, objtype ) ); + names.append( QString( "%1" ).arg( curid ) ); + } + } + else + { + QString id = anIt.Value()->getEntry(); + ids.append( id ); + types.append( typeById( id, Object ) ); + names.append( anIt.Value()->getName() ); + } } }