1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
20 #include "LightApp_ShowHideOp.h"
21 #include "LightApp_Application.h"
22 #include "LightApp_DataOwner.h"
23 #include "LightApp_Module.h"
24 #include "LightApp_Study.h"
25 #include "LightApp_Displayer.h"
26 #include "CAM_Study.h"
28 #include "LightApp_SelectionMgr.h"
29 #include "LightApp_Selection.h"
31 #include <SALOME_ListIO.hxx>
32 #include <SALOME_ListIteratorOfListIO.hxx>
34 LightApp_ShowHideOp::LightApp_ShowHideOp( ActionType type )
35 : LightApp_Operation(),
40 LightApp_ShowHideOp::~LightApp_ShowHideOp()
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 )
65 QString aStr = sel.param( 0, "component" ).toString();
66 mod_name = app->moduleTitle( aStr );
68 else if( app->activeModule() )
69 mod_name = app->moduleTitle( app->activeModule()->name() );
71 LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, true );
78 if( myActionType==DISPLAY_ONLY || myActionType==ERASE_ALL )
82 study->components( comps );
83 QStringList::const_iterator anIt = comps.begin(), aLast = comps.end();
84 for( ; anIt!=aLast; anIt++ )
86 LightApp_Displayer* disp = LightApp_Displayer::FindDisplayer( app->moduleTitle( *anIt ), true );
88 disp->EraseAll( false, false, 0 );
90 if( myActionType==ERASE_ALL )
98 SALOME_ListIO selObjs;
99 mgr->selectedObjects( selObjs );
102 SALOME_ListIteratorOfListIO anIt( selObjs );
103 for( ; anIt.More(); anIt.Next() )
105 if( anIt.Value().IsNull() )
108 if( study->isComponent( anIt.Value()->getEntry() ) )
109 study->children( anIt.Value()->getEntry(), entries );
111 entries.append( anIt.Value()->getEntry() );
114 for( QStringList::const_iterator it = entries.begin(), last = entries.end(); it!=last; it++ )
116 QString e = study->referencedToEntry( *it );
117 if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
118 d->Display( e, false, 0 );
119 else if( myActionType==ERASE )
120 d->Erase( e, false, false, 0 );