2 #include "LightApp_ShowHideOp.h"
3 #include "LightApp_Application.h"
4 #include "LightApp_DataOwner.h"
5 #include "LightApp_Module.h"
6 #include "LightApp_Study.h"
7 #include "LightApp_Displayer.h"
10 #include "LightApp_SelectionMgr.h"
11 #include "LightApp_Selection.h"
13 #include <SALOME_ListIO.hxx>
14 #include <SALOME_ListIteratorOfListIO.hxx>
16 LightApp_ShowHideOp::LightApp_ShowHideOp( ActionType type )
17 : LightApp_Operation(),
22 LightApp_ShowHideOp::~LightApp_ShowHideOp()
26 void LightApp_ShowHideOp::startOperation()
28 LightApp_Application* app = dynamic_cast<LightApp_Application*>( application() );
29 LightApp_Study* study = app ? dynamic_cast<LightApp_Study*>( app->activeStudy() ) : 0;
36 LightApp_SelectionMgr* mgr = app->selectionMgr();
37 LightApp_Selection sel; sel.init( "", mgr );
38 if( sel.count()==0 && myActionType!=ERASE_ALL )
43 QString aStr = sel.param( 0, "component" ).toString();
44 QString mod_name = app->moduleTitle( aStr );//sel.param( 0, "component" ).toString() );
45 LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, true );
52 if( myActionType==DISPLAY_ONLY || myActionType==ERASE_ALL )
56 study->components( comps );
57 QStringList::const_iterator anIt = comps.begin(), aLast = comps.end();
58 for( ; anIt!=aLast; anIt++ )
60 LightApp_Displayer* disp = LightApp_Displayer::FindDisplayer( app->moduleTitle( *anIt ), true );
62 disp->EraseAll( false, false, 0 );
64 if( myActionType==ERASE_ALL )
72 SALOME_ListIO selObjs;
73 mgr->selectedObjects( selObjs );
76 SALOME_ListIteratorOfListIO anIt( selObjs );
77 for( ; anIt.More(); anIt.Next() )
79 if( anIt.Value().IsNull() )
82 if( study->isComponent( anIt.Value()->getEntry() ) )
83 study->children( anIt.Value()->getEntry(), entries );
85 entries.append( anIt.Value()->getEntry() );
88 for( QStringList::const_iterator it = entries.begin(), last = entries.end(); it!=last; it++ )
90 QString e = study->referencedToEntry( *it );
91 if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
92 d->Display( e, false, 0 );
93 else if( myActionType==ERASE )
94 d->Erase( e, false, false, 0 );