X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_SelectionOp.cxx;h=c03de45c1dfb03c362c3587681e23948778c55bd;hb=09762cc8542af51d28035b69eeaada9355cc9aee;hp=1bc466c6a2c7d3a5fdef41355bd1da7d3f4939ae;hpb=3f8d4c84db10ac0b6dd2452de5f773a277bce609;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_SelectionOp.cxx b/src/SMESHGUI/SMESHGUI_SelectionOp.cxx index 1bc466c6a..c03de45c1 100644 --- a/src/SMESHGUI/SMESHGUI_SelectionOp.cxx +++ b/src/SMESHGUI/SMESHGUI_SelectionOp.cxx @@ -29,9 +29,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include #include @@ -43,10 +43,12 @@ #include CORBA_SERVER_HEADER(GEOM_Gen) #include +#include + /* Class : SMESHGUI_SelectionOp Description : Base operation for all operations using object selection in viewer or objectbrowser - through common widgets created by SalomeApp_Dialog::createObject + through common widgets created by LightApp_Dialog::createObject */ //================================================================================= @@ -78,6 +80,9 @@ SMESHGUI_SelectionOp::~SMESHGUI_SelectionOp() //================================================================================= void SMESHGUI_SelectionOp::startOperation() { + myOldSelectionMode = selectionMode(); + setSelectionMode( myDefSelectionMode ); + SMESHGUI_Operation::startOperation(); if( dlg() ) { @@ -88,9 +93,6 @@ void SMESHGUI_SelectionOp::startOperation() connect( dlg(), SIGNAL( objectDeactivated( int ) ), this, SLOT( onDeactivateObject( int ) ) ); connect( dlg(), SIGNAL( selectionChanged( int ) ), this, SLOT( onSelectionChanged( int ) ) ); } - - myOldSelectionMode = selectionMode(); - setSelectionMode( myDefSelectionMode ); } //================================================================================= @@ -99,7 +101,7 @@ void SMESHGUI_SelectionOp::startOperation() //================================================================================= void SMESHGUI_SelectionOp::removeCustomFilters() const { - SalomeApp_SelectionMgr* mgr = selectionMgr(); + LightApp_SelectionMgr* mgr = selectionMgr(); if( !mgr ) return; @@ -116,9 +118,9 @@ void SMESHGUI_SelectionOp::removeCustomFilters() const //================================================================================= void SMESHGUI_SelectionOp::commitOperation() { + SMESHGUI_Operation::commitOperation(); removeCustomFilters(); setSelectionMode( myOldSelectionMode ); - SMESHGUI_Operation::commitOperation(); } //================================================================================= @@ -127,9 +129,9 @@ void SMESHGUI_SelectionOp::commitOperation() //================================================================================= void SMESHGUI_SelectionOp::abortOperation() { + SMESHGUI_Operation::abortOperation(); removeCustomFilters(); setSelectionMode( myOldSelectionMode ); - SMESHGUI_Operation::abortOperation(); } //================================================================================= @@ -154,7 +156,7 @@ void SMESHGUI_SelectionOp::selectionDone() } QStringList names, ids; - SalomeApp_Dialog::TypesList types; + LightApp_Dialog::TypesList types; selected( names, types, ids ); dlg()->selectObject( names, types, ids ); } @@ -174,7 +176,7 @@ SUIT_SelectionFilter* SMESHGUI_SelectionOp::createFilter( const int ) const //================================================================================= void SMESHGUI_SelectionOp::onActivateObject( int id ) { - SalomeApp_SelectionMgr* mgr = selectionMgr(); + LightApp_SelectionMgr* mgr = selectionMgr(); if( !mgr ) return; @@ -193,7 +195,7 @@ void SMESHGUI_SelectionOp::onActivateObject( int id ) //================================================================================= void SMESHGUI_SelectionOp::onDeactivateObject( int id ) { - SalomeApp_SelectionMgr* mgr = selectionMgr(); + LightApp_SelectionMgr* mgr = selectionMgr(); if( mgr && myFilters.contains( id ) && myFilters[ id ] ) mgr->removeFilter( myFilters[ id ] ); } @@ -354,16 +356,16 @@ int SMESHGUI_SelectionOp::typeById( const QString& str, const EntityType objtype // Purpose : Get names, types and ids of selected objects //======================================================================= void SMESHGUI_SelectionOp::selected( QStringList& names, - SalomeApp_Dialog::TypesList& types, + LightApp_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++ ) { - SalomeApp_DataOwner* owner = dynamic_cast( (*anIt).operator->() ); - SalomeApp_SVTKDataOwner* vtkowner = dynamic_cast( (*anIt).operator->() ); + LightApp_DataOwner* owner = dynamic_cast( (*anIt).operator->() ); + LightApp_SVTKDataOwner* vtkowner = dynamic_cast( (*anIt).operator->() ); if( vtkowner ) { @@ -389,6 +391,43 @@ 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 ) ); + SalomeApp_Study* _study = dynamic_cast( study() ); + if( _study ) + { + _PTR(SObject) obj = _study->studyDS()->FindObjectID( anIt.Value()->getEntry() ); + if( obj ) + names.append( obj->GetName().c_str() ); + } + } } } @@ -458,7 +497,7 @@ void SMESHGUI_SelectionOp::onTextChanged( int, const QStringList& list ) selector()->AddOrRemoveIndex( sel.First(), newIndices, false ); highlight( sel.First(), true, true ); - QStringList names, _ids; SalomeApp_Dialog::TypesList types; + QStringList names, _ids; LightApp_Dialog::TypesList types; selected( names, types, _ids ); dlg()->selectObject( names, types, _ids, false ); }