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 LightApp_Displayer* LightApp_ShowHideOp::displayer( const QString& mod_name ) const
28 LightApp_Application* app = dynamic_cast<LightApp_Application*>( application() );
29 LightApp_Module* m = dynamic_cast<LightApp_Module*>( app ? app->module( mod_name ) : 0 );
32 m = dynamic_cast<LightApp_Module*>( app->loadModule( mod_name ) );
36 m->connectToStudy( dynamic_cast<CAM_Study*>( app->activeStudy() ) );
37 m->setMenuShown( false );
38 m->setToolShown( false );
41 return m ? m->displayer() : 0;
44 void LightApp_ShowHideOp::startOperation()
46 LightApp_Application* app = dynamic_cast<LightApp_Application*>( application() );
47 LightApp_Study* study = app ? dynamic_cast<LightApp_Study*>( app->activeStudy() ) : 0;
54 LightApp_SelectionMgr* mgr = app->selectionMgr();
55 LightApp_Selection sel; sel.init( "", mgr );
56 if( sel.count()==0 && myActionType!=ERASE_ALL )
61 QString aStr = sel.param( 0, "component" ).toString();
62 QString mod_name = app->moduleTitle( aStr );//sel.param( 0, "component" ).toString() );
63 LightApp_Displayer* d = displayer( mod_name );
70 if( myActionType==DISPLAY_ONLY || myActionType==ERASE_ALL )
74 study->components( comps );
75 QStringList::const_iterator anIt = comps.begin(), aLast = comps.end();
76 for( ; anIt!=aLast; anIt++ )
78 LightApp_Displayer* disp = displayer( app->moduleTitle( *anIt ) );
80 disp->EraseAll( false, false, 0 );
82 if( myActionType==ERASE_ALL )
90 SALOME_ListIO selObjs;
91 mgr->selectedObjects( selObjs );
94 SALOME_ListIteratorOfListIO anIt( selObjs );
95 for( ; anIt.More(); anIt.Next() )
97 if( anIt.Value().IsNull() )
100 if( study->isComponent( anIt.Value()->getEntry() ) )
101 study->children( anIt.Value()->getEntry(), entries );
103 entries.append( anIt.Value()->getEntry() );
106 for( QStringList::const_iterator it = entries.begin(), last = entries.end(); it!=last; it++ )
108 QString e = study->referencedToEntry( *it );
109 if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
110 d->Display( e, false, 0 );
111 else if( myActionType==ERASE )
112 d->Erase( e, false, false, 0 );