From b4944f7095504790bdda21374f5101d446d91cb7 Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 1 Jul 2005 11:55:23 +0000 Subject: [PATCH] Now operation has method "selected", which allows to receive list of names, types and entries of selected objects. Successors of operation may call dlg()->selectObject() in selectionDone() and pass these lists to implement simple behavior of selection. --- src/SalomeApp/SalomeApp_Operation.cxx | 60 ++++++++++++++++----------- src/SalomeApp/SalomeApp_Operation.h | 16 +++++-- 2 files changed, 49 insertions(+), 27 deletions(-) diff --git a/src/SalomeApp/SalomeApp_Operation.cxx b/src/SalomeApp/SalomeApp_Operation.cxx index d5ca2fea7..add111a67 100755 --- a/src/SalomeApp/SalomeApp_Operation.cxx +++ b/src/SalomeApp/SalomeApp_Operation.cxx @@ -8,15 +8,14 @@ // Author : Sergey LITONIN // Module : SALOME -#include "SalomeApp_Operation.h" - -#include "SalomeApp_Module.h" -#include "SalomeApp_Application.h" -#include "SalomeApp_Operation.h" +#include +#include +#include +#include +#include +#include -#include #include -#include /* @@ -208,6 +207,36 @@ bool SalomeApp_Operation::eventFilter( QObject* obj, QEvent* e ) return SUIT_Operation::eventFilter( obj, e ); } +//======================================================================= +// name : type +// Purpose : Find type by entry +//======================================================================= +int SalomeApp_Operation::type( const QString& ) const +{ + return -1; +} + +//======================================================================= +// name : selected +// Purpose : Get names, types and entries of selected objects +//======================================================================= +void SalomeApp_Operation::selected( QStringList& names, SalomeApp_Dialog::TypesList& types, QStringList& entries ) const +{ + 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->() ); + if( owner ) + { + QString entry = owner->entry(); + entries.append( entry ); + types.append( type( entry ) ); + names.append( owner->IO()->getName() ); + } + } +} //======================================================================= // name : eventFilter // Purpose : Block mouse and key events if operator is not active one @@ -217,20 +246,3 @@ void SalomeApp_Operation::update( const int flags ) if ( myModule != 0 ) myModule->update( flags ); } - - - - - - - - - - - - - - - - - diff --git a/src/SalomeApp/SalomeApp_Operation.h b/src/SalomeApp/SalomeApp_Operation.h index c6c1875b7..fbc2e7456 100755 --- a/src/SalomeApp/SalomeApp_Operation.h +++ b/src/SalomeApp/SalomeApp_Operation.h @@ -12,13 +12,13 @@ #ifndef SalomeApp_Operation_H #define SalomeApp_Operation_H -#include "SUIT_Operation.h" +#include +#include class SalomeApp_Module; class SalomeApp_Application; class SalomeApp_Operation; class SalomeApp_SelectionMgr; -class SalomeApp_Dialog; class SUIT_Desktop; /* @@ -91,7 +91,17 @@ protected: void update( const int ); // Call update() method of module ( see SalomeApp_Module for description ) + + + + virtual void selected( QStringList&, SalomeApp_Dialog::TypesList&, QStringList& ) const; + // Get names, types and entries of selected objects + + virtual int type( const QString& ) const; + // Find type by entry: default implementation is to return -1 + // Please redefine it if you want function "selected" to work correctly + private slots: virtual void onSelectionDone(); @@ -101,7 +111,7 @@ private: bool eventFilter( QObject*, QEvent* ); // Block mouse and key events if operator is not active one - + private: SalomeApp_Module* myModule; -- 2.39.2