From: asl Date: Wed, 9 Nov 2005 11:07:50 +0000 (+0000) Subject: PAL9391 - display/erase objects from other modules X-Git-Tag: V3_1_0a3~47 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2c2087cf071de8649aeca7cd6b40ef3832580384;p=modules%2Fgui.git PAL9391 - display/erase objects from other modules --- diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index 15bfc77af..54835f757 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -23,12 +23,15 @@ #include #include +#include #include #include +#include #include #include #include #include +#include #include @@ -45,7 +48,8 @@ LightApp_Module::LightApp_Module( const QString& name ) mySwitchOp( 0 ), myDisplay( -1 ), myErase( -1 ), - myDisplayOnly( -1 ) + myDisplayOnly( -1 ), + myEraseAll( -1 ) { } @@ -235,14 +239,18 @@ QtxPopupMgr* LightApp_Module::popupMgr() *erase = createAction( -1, tr( "TOP_ERASE" ), p, tr( "MEN_ERASE" ), tr( "STB_ERASE" ), 0, d, false, this, SLOT( onShowHide() ) ), *dispOnly = createAction( -1, tr( "TOP_DISPLAY_ONLY" ), p, tr( "MEN_DISPLAY_ONLY" ), tr( "STB_DISPLAY_ONLY" ), + 0, d, false, this, SLOT( onShowHide() ) ), + *eraseAll = createAction( -1, tr( "TOP_ERASE_ALL" ), p, tr( "MEN_ERASE_ALL" ), tr( "STB_ERASE_ALL" ), 0, d, false, this, SLOT( onShowHide() ) ); myDisplay = actionId( disp ); myErase = actionId( erase ); myDisplayOnly = actionId( dispOnly ); + myEraseAll = actionId( eraseAll ); myPopupMgr->insert( disp, -1, 0 ); myPopupMgr->insert( erase, -1, 0 ); myPopupMgr->insert( dispOnly, -1, 0 ); + myPopupMgr->insert( eraseAll, -1, 0 ); myPopupMgr->insert( separator(), -1, 0 ); QString uniform = "( count( $component ) = 1 ) and ( component != activeModule ) and ( activeModule = '%1' )"; @@ -250,6 +258,9 @@ QtxPopupMgr* LightApp_Module::popupMgr() myPopupMgr->setRule( disp, /*QString( "( not isVisible ) and " ) + */ uniform, true ); myPopupMgr->setRule( erase, /*QString( "( isVisible ) and " ) + */ uniform, true ); myPopupMgr->setRule( dispOnly, uniform, true ); + QString viewers = "{ '%1' '%2' '%3' }"; + viewers = viewers.arg( SOCC_Viewer::Type() ).arg( SVTK_Viewer::Type() ).arg( SPlot2d_Viewer::Type() ); + myPopupMgr->setRule( eraseAll, QString( "client in %1" ).arg( viewers ), true ); } return myPopupMgr; } @@ -355,6 +366,8 @@ LightApp_Operation* LightApp_Module::createOperation( const int id ) const return new LightApp_ShowHideOp( LightApp_ShowHideOp::ERASE ); else if( id==myDisplayOnly ) return new LightApp_ShowHideOp( LightApp_ShowHideOp::DISPLAY_ONLY ); + else if( id==myEraseAll ) + return new LightApp_ShowHideOp( LightApp_ShowHideOp::ERASE_ALL ); else return 0; } diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index e881547da..2df7aab61 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -14,6 +14,7 @@ class LightApp_Preferences; class LightApp_Selection; class LightApp_Operation; class LightApp_SwitchOp; +class LightApp_ShowHideOp; class LightApp_Displayer; class SUIT_Study; @@ -113,7 +114,9 @@ private: QtxPopupMgr* myPopupMgr; MapOfOperation myOperations; LightApp_SwitchOp* mySwitchOp; - int myDisplay, myErase, myDisplayOnly; + +protected: + int myDisplay, myErase, myDisplayOnly, myEraseAll; }; #endif diff --git a/src/LightApp/LightApp_ShowHideOp.cxx b/src/LightApp/LightApp_ShowHideOp.cxx index 6d2ae9d56..3b51a7e86 100644 --- a/src/LightApp/LightApp_ShowHideOp.cxx +++ b/src/LightApp/LightApp_ShowHideOp.cxx @@ -3,6 +3,7 @@ #include "LightApp_Application.h" #include "LightApp_DataOwner.h" #include "LightApp_Module.h" +#include "LightApp_Study.h" #include "LightApp_Displayer.h" #include "CAM_Study.h" @@ -22,10 +23,29 @@ LightApp_ShowHideOp::~LightApp_ShowHideOp() { } +LightApp_Displayer* LightApp_ShowHideOp::displayer( const QString& mod_name ) const +{ + LightApp_Application* app = dynamic_cast( application() ); + LightApp_Module* m = dynamic_cast( app ? app->module( mod_name ) : 0 ); + if( !m ) + { + m = dynamic_cast( app->loadModule( mod_name ) ); + if( m ) + { + app->addModule( m ); + m->connectToStudy( dynamic_cast( app->activeStudy() ) ); + m->setMenuShown( false ); + m->setToolShown( false ); + } + } + return m ? m->displayer() : 0; +} + void LightApp_ShowHideOp::startOperation() { LightApp_Application* app = dynamic_cast( application() ); - if( !app ) + LightApp_Study* study = app ? dynamic_cast( app->activeStudy() ) : 0; + if( !app || !study ) { abort(); return; @@ -33,48 +53,64 @@ void LightApp_ShowHideOp::startOperation() LightApp_SelectionMgr* mgr = app->selectionMgr(); LightApp_Selection sel; sel.init( "", mgr ); - if( sel.count()==0 ) + if( sel.count()==0 && myActionType!=ERASE_ALL ) { abort(); return; } QString aStr = sel.param( 0, "component" ).toString(); QString mod_name = app->moduleTitle( aStr );//sel.param( 0, "component" ).toString() ); - LightApp_Module* m = dynamic_cast( app ? app->module( mod_name ) : 0 ); - if( !m ) - { - m = dynamic_cast( app->loadModule( mod_name ) ); - app->addModule( m ); - m->connectToStudy( dynamic_cast( app->activeStudy() ) ); - m->setMenuShown( false ); - m->setToolShown( false ); - } - - LightApp_Displayer* d = m ? m->displayer(): 0; + LightApp_Displayer* d = displayer( mod_name ); if( !d ) { abort(); return; } - if( myActionType==DISPLAY_ONLY ) - d->EraseAll( false, false, 0 ); + if( myActionType==DISPLAY_ONLY || myActionType==ERASE_ALL ) + { + //ERASE ALL + QStringList comps; + study->components( comps ); + QStringList::const_iterator anIt = comps.begin(), aLast = comps.end(); + for( ; anIt!=aLast; anIt++ ) + { + LightApp_Displayer* disp = displayer( app->moduleTitle( *anIt ) ); + if( disp ) + disp->EraseAll( false, false, 0 ); + } + if( myActionType==ERASE_ALL ) + { + d->UpdateViewer(); + commit(); + return; + } + } SALOME_ListIO selObjs; mgr->selectedObjects( selObjs ); + + QStringList entries; SALOME_ListIteratorOfListIO anIt( selObjs ); for( ; anIt.More(); anIt.Next() ) { if( anIt.Value().IsNull() ) - continue; + if( study->isComponent( anIt.Value()->getEntry() ) ) + study->children( anIt.Value()->getEntry(), entries ); + else + entries.append( anIt.Value()->getEntry() ); + } + + for( QStringList::const_iterator it = entries.begin(), last = entries.end(); it!=last; it++ ) + { + QString e = study->referencedToEntry( *it ); if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY ) - d->Display( anIt.Value()->getEntry(), false, 0 ); + d->Display( e, false, 0 ); else if( myActionType==ERASE ) - d->Erase( anIt.Value()->getEntry(), false, false, 0 ); + d->Erase( e, false, false, 0 ); } d->UpdateViewer(); commit(); } - diff --git a/src/LightApp/LightApp_ShowHideOp.h b/src/LightApp/LightApp_ShowHideOp.h index 248770af6..7c322240c 100644 --- a/src/LightApp/LightApp_ShowHideOp.h +++ b/src/LightApp/LightApp_ShowHideOp.h @@ -4,19 +4,21 @@ #include "LightApp_Operation.h" +class LightApp_Displayer; class LIGHTAPP_EXPORT LightApp_ShowHideOp : public LightApp_Operation { Q_OBJECT public: - typedef enum { DISPLAY, ERASE, DISPLAY_ONLY } ActionType; + typedef enum { DISPLAY, ERASE, DISPLAY_ONLY, ERASE_ALL } ActionType; public: LightApp_ShowHideOp( ActionType ); ~LightApp_ShowHideOp(); - + protected: virtual void startOperation(); + virtual LightApp_Displayer* displayer( const QString& ) const; private: ActionType myActionType; diff --git a/src/LightApp/LightApp_Study.cxx b/src/LightApp/LightApp_Study.cxx index 9b05ef2b2..e575e306d 100644 --- a/src/LightApp/LightApp_Study.cxx +++ b/src/LightApp/LightApp_Study.cxx @@ -186,15 +186,33 @@ void LightApp_Study::closeDocument(bool permanently) // Function : referencedToEntry /*! Purpose : Return current entry*/ //================================================================ -QString LightApp_Study::referencedToEntry( const QString& entry ) +QString LightApp_Study::referencedToEntry( const QString& entry ) const { return entry; } + +//================================================================ +// Function : children +/*! Purpose : Return entries of children of object*/ +//================================================================ +void LightApp_Study::children( const QString&, QStringList& ) const +{ +} + +//================================================================ +// Function : isComponent +/*! Purpose : Return true if entry corresponds to component*/ +//================================================================ +bool LightApp_Study::isComponent( const QString& entry ) const +{ + return false; +} + //================================================================ // Function : componentDataType /*! Purpose : Return component data type from entry*/ //================================================================ -QString LightApp_Study::componentDataType( const QString& entry ) +QString LightApp_Study::componentDataType( const QString& entry ) const { LightApp_DataObject* aCurObj; for ( SUIT_DataObjectIterator it( root(), SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) { @@ -391,3 +409,19 @@ void LightApp_Study::RemoveTemporaryFiles (const char* theModuleName, const bool bool isDirDeleted = true; myDriver->RemoveTemporaryFiles(theModuleName, isDirDeleted); } + +//================================================================ +// Function : RemoveTemporaryFiles +/*! Purpose : to be used by modules*/ +//================================================================ +void LightApp_Study::components( QStringList& comp ) const +{ + DataObjectList children = root()->children(); + DataObjectList::const_iterator anIt = children.begin(), aLast = children.end(); + for( ; anIt!=aLast; anIt++ ) + { + LightApp_DataObject* obj = dynamic_cast( *anIt ); + if( obj && obj->entry()!="Interface Applicative" ) + comp.append( obj->entry() ); + } +} diff --git a/src/LightApp/LightApp_Study.h b/src/LightApp/LightApp_Study.h index 4c206cc09..9d51e6e9e 100644 --- a/src/LightApp/LightApp_Study.h +++ b/src/LightApp/LightApp_Study.h @@ -38,8 +38,11 @@ public: virtual std::string GetTmpDir ( const char* theURL, const bool isMultiFile ); - virtual QString componentDataType( const QString& ); - virtual QString referencedToEntry( const QString& ); + virtual QString componentDataType( const QString& ) const; + virtual QString referencedToEntry( const QString& ) const; + virtual bool isComponent( const QString& ) const; + virtual void children( const QString&, QStringList& ) const; + virtual void components( QStringList& ) const; protected: virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles );