]> SALOME platform Git repositories - modules/gui.git/blob - src/LightApp/LightApp_ShowHideOp.cxx
Salome HOME
Has functionality from SalomeApp without dependency from CORBA
[modules/gui.git] / src / LightApp / LightApp_ShowHideOp.cxx
1
2 #include "LightApp_ShowHideOp.h"
3 #include "LightApp_Application.h"
4 #include "LightApp_DataOwner.h"
5 #include "LightApp_Module.h"
6 #include "LightApp_Displayer.h"
7 #include "CAM_Study.h"
8
9 #include "LightApp_SelectionMgr.h"
10 #include "LightApp_Selection.h"
11
12 #include <SALOME_ListIO.hxx>
13 #include <SALOME_ListIteratorOfListIO.hxx>
14
15 LightApp_ShowHideOp::LightApp_ShowHideOp( ActionType type )
16 : LightApp_Operation(),
17   myActionType( type )
18 {
19 }
20
21 LightApp_ShowHideOp::~LightApp_ShowHideOp()
22 {
23 }
24
25 void LightApp_ShowHideOp::startOperation()
26 {
27   LightApp_Application* app = dynamic_cast<LightApp_Application*>( application() );
28   if( !app )
29   {
30     abort();
31     return;
32   }
33
34   LightApp_SelectionMgr* mgr = app->selectionMgr();
35   LightApp_Selection sel; sel.init( "", mgr );
36   if( sel.count()==0 )
37   {
38     abort();
39     return;
40   }
41   QString aStr =  sel.param( 0, "component" ).toString();
42   QString mod_name = app->moduleTitle( aStr );//sel.param( 0, "component" ).toString() );
43   LightApp_Module* m = dynamic_cast<LightApp_Module*>( app ? app->module( mod_name ) : 0 );
44   if( !m )
45   {
46     m = dynamic_cast<LightApp_Module*>( app->loadModule( mod_name ) );
47     app->addModule( m );
48     m->connectToStudy( dynamic_cast<CAM_Study*>( app->activeStudy() ) );
49     m->setMenuShown( false );
50     m->setToolShown( false );
51   }
52
53   LightApp_Displayer* d = m ? m->displayer(): 0;
54   if( !d )
55   {
56     abort();
57     return;
58   }
59
60   if( myActionType==DISPLAY_ONLY )
61     d->EraseAll( false, false, 0 );
62
63   SALOME_ListIO selObjs;
64   mgr->selectedObjects( selObjs );
65   SALOME_ListIteratorOfListIO anIt( selObjs );
66   for( ; anIt.More(); anIt.Next() )
67   {
68     if( anIt.Value().IsNull() )
69
70       continue;
71
72     if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
73       d->Display( anIt.Value()->getEntry(), false, 0 );
74     else if( myActionType==ERASE )
75       d->Erase( anIt.Value()->getEntry(), false, false, 0 );
76   }
77   d->UpdateViewer();
78   commit();
79 }
80