#include <SUIT_ResourceMgr.h>
#include <SVTK_ViewWindow.h>
+#include <SVTK_ViewModel.h>
#include <OCCViewer_ViewWindow.h>
#include <OCCViewer_ViewPort3d.h>
+#include <SOCC_ViewModel.h>
#include <GLViewer_ViewFrame.h>
#include <GLViewer_ViewPort.h>
#include <Plot2d_ViewWindow.h>
#include <Plot2d_ViewFrame.h>
+#include <SPlot2d_ViewModel.h>
#include <OB_Browser.h>
mySwitchOp( 0 ),
myDisplay( -1 ),
myErase( -1 ),
- myDisplayOnly( -1 )
+ myDisplayOnly( -1 ),
+ myEraseAll( -1 )
{
}
*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' )";
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;
}
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;
}
class LightApp_Selection;
class LightApp_Operation;
class LightApp_SwitchOp;
+class LightApp_ShowHideOp;
class LightApp_Displayer;
class SUIT_Study;
QtxPopupMgr* myPopupMgr;
MapOfOperation myOperations;
LightApp_SwitchOp* mySwitchOp;
- int myDisplay, myErase, myDisplayOnly;
+
+protected:
+ int myDisplay, myErase, myDisplayOnly, myEraseAll;
};
#endif
#include "LightApp_Application.h"
#include "LightApp_DataOwner.h"
#include "LightApp_Module.h"
+#include "LightApp_Study.h"
#include "LightApp_Displayer.h"
#include "CAM_Study.h"
{
}
+LightApp_Displayer* LightApp_ShowHideOp::displayer( const QString& mod_name ) const
+{
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>( application() );
+ LightApp_Module* m = dynamic_cast<LightApp_Module*>( app ? app->module( mod_name ) : 0 );
+ if( !m )
+ {
+ m = dynamic_cast<LightApp_Module*>( app->loadModule( mod_name ) );
+ if( m )
+ {
+ app->addModule( m );
+ m->connectToStudy( dynamic_cast<CAM_Study*>( app->activeStudy() ) );
+ m->setMenuShown( false );
+ m->setToolShown( false );
+ }
+ }
+ return m ? m->displayer() : 0;
+}
+
void LightApp_ShowHideOp::startOperation()
{
LightApp_Application* app = dynamic_cast<LightApp_Application*>( application() );
- if( !app )
+ LightApp_Study* study = app ? dynamic_cast<LightApp_Study*>( app->activeStudy() ) : 0;
+ if( !app || !study )
{
abort();
return;
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<LightApp_Module*>( app ? app->module( mod_name ) : 0 );
- if( !m )
- {
- m = dynamic_cast<LightApp_Module*>( app->loadModule( mod_name ) );
- app->addModule( m );
- m->connectToStudy( dynamic_cast<CAM_Study*>( 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();
}
-
#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;
// 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 ) {
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<LightApp_DataObject*>( *anIt );
+ if( obj && obj->entry()!="Interface Applicative" )
+ comp.append( obj->entry() );
+ }
+}
\r
virtual std::string GetTmpDir ( const char* theURL, const bool isMultiFile );\r
\r
- virtual QString componentDataType( const QString& );\r
- virtual QString referencedToEntry( const QString& );\r
+ virtual QString componentDataType( const QString& ) const;\r
+ virtual QString referencedToEntry( const QString& ) const;\r
+ virtual bool isComponent( const QString& ) const;\r
+ virtual void children( const QString&, QStringList& ) const;\r
+ virtual void components( QStringList& ) const;\r
\r
protected:\r
virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles );\r