1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOMEGUI_Application.cxx
25 // Author : Nicolas REJNERI
30 #include "SALOMEGUI_Application.h"
31 #include "SALOMEGUI_Desktop.h"
32 #include "SALOMEGUI_ImportOperation.h"
33 #include "SALOME_Selection.h"
34 #include "SALOME_ListIO.hxx"
35 #include "SALOME_ListIteratorOfListIO.hxx"
36 #include "SALOME_InteractiveObject.hxx"
38 #include "QAD_Desktop.h"
39 #include "QAD_RightFrame.h"
40 #include "QAD_LeftFrame.h"
41 #include "QAD_ObjectBrowser.h"
42 #include "QAD_Resource.h"
43 #include "QAD_Tools.h"
44 #include "QAD_WaitCursor.h"
47 #include <qapplication.h>
48 #include <qpopupmenu.h>
49 #include <qmessagebox.h>
51 // Open CASCADE Include
52 #include <Standard_Failure.hxx>
53 #include <TCollection_AsciiString.hxx>
58 SALOMEGUI_Application::SALOMEGUI_Application( const QString& format,
59 const QString& description,
60 const QString& filters) :
61 QAD_Application( format, description, filters )
65 QAD_ResourceMgr* resMgr = QAD_Desktop::getResourceManager();
66 if ( !resMgr ) resMgr = QAD_Desktop::createResourceManager();
67 if ( resMgr ) resMgr->loadResources( "SALOMEGUI", message );
69 QPalette* palette = QAD_Desktop::getPalette();
70 if ( !palette) palette = QAD_Desktop::createPalette();
71 // if ( !palette) palette->loadPalette();
73 //myViewActions.setAutoDelete( true );
75 /* We need to know that the desktop is created to have
76 some additional internal initialization */
77 QAD_ASSERT( connect( this, SIGNAL(desktopCreated()), SLOT(onDesktopCreated()) ));
83 SALOMEGUI_Application::~SALOMEGUI_Application()
88 Creates the actions provided by this application( internal )
90 void SALOMEGUI_Application::createActions()
93 /* this function must be called only once */
94 static bool created = false;
95 QAD_ASSERT_DEBUG_ONLY( !created );
99 /* Create 'View' actions
101 QToolBar* tbView = createToolBar( ViewToolBarId, tr("MEN_DESK_VIEWERTOOLBAR") );
103 QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager();
104 #define CREATE_ACTION(ID,NAME) \
105 if(!myViewActions.at(ID)){ \
106 QActionP* action = new QActionP(tr("TOT_APP_VIEW_" #NAME), \
107 rmgr->loadPixmap("SALOMEGUI", tr("ICON_APP_VIEW_" #NAME)), \
108 tr("MEN_APP_VIEW_" #NAME), 0, QAD_Application::getDesktop()); \
109 action->setStatusTip(tr("PRP_APP_VIEW_" #NAME)); \
110 myViewActions.insert(ID,action); \
113 CREATE_ACTION(ViewDumpId,DUMP);
114 CREATE_ACTION(ViewTrihedronId,TRIHEDRON);
115 CREATE_ACTION(ViewFitAllId,FITALL);
116 CREATE_ACTION(ViewFitAreaId,FITAREA);
117 CREATE_ACTION(ViewZoomId,ZOOM);
118 CREATE_ACTION(ViewPanId,PAN);
119 CREATE_ACTION(ViewRotateId,ROTATE);
120 CREATE_ACTION(ViewGlobalPanId,GLOBALPAN);
121 CREATE_ACTION(ViewFrontId,FRONT);
122 CREATE_ACTION(ViewBackId,BACK);
123 CREATE_ACTION(ViewTopId,TOP);
124 CREATE_ACTION(ViewBottomId,BOTTOM);
125 CREATE_ACTION(ViewLeftId,LEFT);
126 CREATE_ACTION(ViewRightId,RIGHT);
127 CREATE_ACTION(ViewResetId,RESET);
133 Enables/disables the actions provided by this
134 application( internal )
136 void SALOMEGUI_Application::updateActions()
141 Creates CAF application
143 bool SALOMEGUI_Application::initApp(SALOME_NamingService* name_service)
145 if ( myStudyMgr->_is_nil() ) {
147 CORBA::Object_ptr obj = name_service->Resolve("/myStudyManager");
148 myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
150 catch ( Standard_Failure ) {
159 Creates the main desktop
161 bool SALOMEGUI_Application::createDesktop( SALOME_NamingService* name_service )
163 QAD_ASSERT_DEBUG_ONLY( !desktop );
164 desktop = new SALOMEGUI_Desktop(name_service);
165 return ( desktop != NULL );
169 Called when the main desktop is created ( internal )
171 void SALOMEGUI_Application::onDesktopCreated()
177 Called for customization when study is created
179 void SALOMEGUI_Application::onStudyCreated( QAD_Study* study )
184 Called for customization when study is opened
186 void SALOMEGUI_Application::onStudyOpened( QAD_Study* study )
191 Called for customization when study is activated (shown)
193 void SALOMEGUI_Application::onStudyShown( QAD_Study* study )
195 SALOMEDS::Study_var aStudy = study->getStudyDocument();
197 //srn: Forbid appending Interface Applicative and its children to UseCase
198 aStudy->EnableUseCaseAutoFilling(false);
200 /* mpv: study may be locked */
201 int aLocked = aStudy->GetProperties()->IsLocked();
202 if (aLocked) aStudy->GetProperties()->SetLocked(false);
204 /* update Object Browser */
205 SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder();
206 SALOMEDS::SComponentIterator_var itcomp = aStudy->NewComponentIterator();
207 for (; itcomp->More(); itcomp->Next()) {
208 SALOMEDS::SComponent_var SC = itcomp->Value();
209 Standard_CString dataType = SC->ComponentDataType();
210 if ( QString(dataType).compare("Interface Applicative") == 0 ) {
211 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SC);
212 for (; it->More();it->Next()) {
213 SALOMEDS::SObject_var CSO = it->Value();
214 B->RemoveObject(CSO);
219 QAD_StudyFrame* sf = myActiveStudy->getActiveStudyFrame();
220 Standard_CString name = strdup(sf->title().latin1());
222 SALOMEDS::SComponent_var father = aStudy->FindComponent("Interface Applicative");
223 SALOMEDS::SObject_var newObj = B->NewObject(father);
224 SALOMEDS::GenericAttribute_var anAttr;
225 SALOMEDS::AttributeName_var aName;
226 SALOMEDS::AttributeComment_var aComment;
227 SALOMEDS::AttributeSelectable_var aSelAttr;
229 anAttr = B->FindOrCreateAttribute(newObj, "AttributeName");
230 aName = SALOMEDS::AttributeName::_narrow(anAttr);
231 aName->SetValue(name);
233 anAttr = B->FindOrCreateAttribute(newObj, "AttributeSelectable");
234 aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
235 aSelAttr->SetSelectable(false);
237 if (sf->getTypeView() == VIEW_OCC) {
238 anAttr = B->FindOrCreateAttribute(newObj, "AttributeComment");
239 aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
240 aComment->SetValue("OCC");
242 else if (sf->getTypeView() == VIEW_VTK) {
243 anAttr = B->FindOrCreateAttribute(newObj, "AttributeComment");
244 aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
245 aComment->SetValue("VTK");
247 anAttr = B->FindOrCreateAttribute(newObj, "AttributeComment");
248 aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
249 aComment->SetValue("GRAPH");
251 sf->setEntry(newObj->GetID());
253 if (aLocked) aStudy->GetProperties()->SetLocked(true);
255 study->updateObjBrowser( false );
257 aStudy->EnableUseCaseAutoFilling(true);
261 Called for customization when the active study is changed
263 void SALOMEGUI_Application::onActiveStudyChanged( QAD_Study* oldActiveStudy,
264 QAD_Study* newActiveStudy )
266 // MESSAGE ("SALOMEGUI_Application::onActiveStudyChanged init.");
267 /* superclass MUST be called */
268 QAD_Application::onActiveStudyChanged( oldActiveStudy, newActiveStudy );
270 if ( oldActiveStudy ) {
271 int count = oldActiveStudy->getStudyFramesCount();
272 for ( int i = 0; i < count; i++ ) {
273 disconnectFromViewer( oldActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame() );
277 if ( newActiveStudy && newActiveStudy->getActiveStudyFrame() ) {
278 connectToViewer( newActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame() );
282 void SALOMEGUI_Application::connectToViewer( QAD_ViewFrame* vf )
284 #define CONNECT_ACTION(NAME) \
285 QAD_ASSERT(connect(myViewActions.at(View ##NAME ##Id), SIGNAL(activated()), vf, SLOT(onView ##NAME())))
288 QToolBar* tbView = getToolBar( ViewToolBarId );
289 for ( int cmd = ViewDumpId; cmd <= ViewResetId; cmd++ )
290 if ( myViewActions.at( cmd ) )
291 myViewActions.at( cmd )->removeFrom(tbView);
292 if( vf->getTypeView() == VIEW_GRAPHSUPERV ) {
293 //myViewActions.at(ViewDumpId)->addTo(tbView);
294 //myViewActions.at(ViewFitAllId)->addTo(tbView);
295 //myViewActions.at(ViewFitAreaId)->addTo(tbView);
296 //myViewActions.at(ViewZoomId)->addTo(tbView);
297 myViewActions.at(ViewPanId)->addTo(tbView);
298 //myViewActions.at(ViewGlobalPanId)->addTo(tbView);
299 myViewActions.at(ViewResetId)->addTo(tbView);
301 else if( vf->getTypeView() == VIEW_PLOT2D ) {
302 myViewActions.at(ViewDumpId)->addTo(tbView);
303 myViewActions.at(ViewFitAllId)->addTo(tbView);
304 myViewActions.at(ViewFitAreaId)->addTo(tbView);
305 myViewActions.at(ViewZoomId)->addTo(tbView);
306 myViewActions.at(ViewPanId)->addTo(tbView);
307 //myViewActions.at(ViewGlobalPanId)->addTo(tbView);
308 //myViewActions.at(ViewResetId)->addTo(tbView);
311 for ( int cmd = ViewDumpId; cmd <= ViewResetId; cmd++ )
312 if ( myViewActions.at( cmd ) )
313 myViewActions.at( cmd )->addTo(tbView);
315 //CONNECT_ACTION(Mu4Id)
316 CONNECT_ACTION(Dump);
317 CONNECT_ACTION(Trihedron);
318 CONNECT_ACTION(FitAll);
319 CONNECT_ACTION(FitArea);
320 CONNECT_ACTION(Zoom);
322 CONNECT_ACTION(Rotate);
323 CONNECT_ACTION(GlobalPan);
324 CONNECT_ACTION(Front);
325 CONNECT_ACTION(Back);
327 CONNECT_ACTION(Bottom);
328 CONNECT_ACTION(Left);
329 CONNECT_ACTION(Right);
330 CONNECT_ACTION(Reset);
333 #undef CONNECT_ACTION
336 void SALOMEGUI_Application::disconnectFromViewer( QAD_ViewFrame* vf )
338 #define DISCONNECT_ACTION(NAME) \
339 QAD_ASSERT(disconnect(myViewActions.at(View ##NAME ##Id), SIGNAL(activated()), vf, SLOT(onView ##NAME())));
341 if ( !vf || myViewActions.isEmpty() )
343 //DISCONNECT_ACTION(Mu4Id)
344 DISCONNECT_ACTION(Dump);
345 DISCONNECT_ACTION(Trihedron);
346 DISCONNECT_ACTION(FitAll);
347 DISCONNECT_ACTION(FitArea);
348 DISCONNECT_ACTION(Zoom);
349 DISCONNECT_ACTION(Pan);
350 DISCONNECT_ACTION(Rotate);
351 DISCONNECT_ACTION(GlobalPan);
352 DISCONNECT_ACTION(Front);
353 DISCONNECT_ACTION(Back);
354 DISCONNECT_ACTION(Top);
355 DISCONNECT_ACTION(Bottom);
356 DISCONNECT_ACTION(Left);
357 DISCONNECT_ACTION(Right);
358 DISCONNECT_ACTION(Reset);
360 #undef DISCONNECT_ACTION
364 Customizes 'View' menu of the desktop
366 int SALOMEGUI_Application::onUpdateViewActions ( QPopupMenu* popup, bool add, int index )
368 int nItemsAdded = QAD_Application::onUpdateViewActions( popup, add, index );
371 // index += nItemsAdded;
372 // QAD_ASSERT_DEBUG_ONLY( !myViewActions.isEmpty() );
373 // popup->insertSeparator( index++ );
374 // myViewActions.at( ViewTrihedronId )->addTo( popup );
376 // popup->insertSeparator( index++ );
377 // for ( int i = (int)ViewMu4Id; i <= (int)ViewRightId; i++ ) {
378 // myViewActions.at( i )->addTo( popup );
381 // popup->insertSeparator( index++ );
382 // myViewActions.at( ViewResetId )->addTo( popup );
385 // for ( int i = (int)ViewTrihedronId; i <= (int)ViewResetId; i++ ) {
386 // popup->removeItemAt(index);
389 // /* remove separators */
390 // popup->removeItemAt( index );
391 // popup->removeItemAt( index );
392 // popup->removeItemAt( index );
399 Adds the context popup items
401 void SALOMEGUI_Application::onCreatePopup()
403 // Here common menu items should be added (Display, Erase, etc.).
404 // They should be obtained through the standard XML-based mechanism,
405 // i.e. corresponding XML file should be loaded somewhere in advance
406 // and desktop->getOperatorsMenu() should return the default popup menu.
407 // These items are always added; if necessary any of them can be hidden
408 // during popup customization by means of the corresponding unique ID defined in QAD_Resource.h.
409 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
411 if ( Sel->IObjectCount() > 0 ) {
412 myPopup->insertItem (tr ("MEN_APP_DISPLAY"), this, SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
413 myPopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), this, SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
414 myPopup->insertItem (tr ("MEN_APP_ERASE"), this, SLOT(onErase()), 0, QAD_Erase_Popup_ID);
420 void SALOMEGUI_Application::onDisplay(int id)
422 QAD_WaitCursor waitCursor;
424 // Obtain the component to deal with (according to selected object's parent component)
425 SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection() );
427 QString parentComp = ((SALOMEGUI_Desktop*)desktop)->getComponentFromSelection();
428 if (parentComp.isNull()) { // objects from several components are selected -> do nothing
432 // Obtain the component's GUI library
433 // Library cashing will be implemented soon in QAD_Desktop to increase performance
434 OSD_Function osdF, osdViewTypeFunc;
435 OSD_SharedLibrary foreignGUI;
436 void (*builder)(const Handle(SALOME_InteractiveObject)&);
437 bool isForeignGUIUsed = false;
438 bool isViewTypeOK = true;
439 int viewTypes[VIEW_TYPE_MAX];
441 for (int i = 0; i < VIEW_TYPE_MAX; i++)
444 if (parentComp.compare(desktop->getActiveComponent()) == 0) { // use active GUI library
445 const OSD_SharedLibrary& compGUI = desktop->getHandle();
446 osdF = compGUI.DlSymb("buildPresentation");
447 if ( osdF == NULL ) {
448 MESSAGE("BuildPresentation method not found in component's GUI")
451 osdViewTypeFunc = compGUI.DlSymb("supportedViewType");
452 if ( osdViewTypeFunc == NULL ) {
453 MESSAGE("supportedViewType method not found in component's GUI")
455 MESSAGE("onDisplay(): using active GUI to build presentations")
456 } else { // use native GUI library
457 QString ComponentLib;
461 if ( getenv("SALOME_SITE_DIR") ) {
463 dir.sprintf("%s",getenv("SALOME_SITE_DIR"));
464 dir = QAD_Tools::addSlash(dir) ;
466 dir = QAD_Tools::addSlash(dir) ;
468 dir = dir + "lib" + parentComp.latin1() + "GUI.dll" ;
470 dir = dir + "lib" + parentComp.latin1() + "GUI.so" ;
472 MESSAGE ( " GUI library = " << dir )
473 fileInfo.setFile(dir) ;
474 if (fileInfo.exists()) {
475 ComponentLib = fileInfo.fileName();
477 MESSAGE ( " found " )
479 MESSAGE ( " Not found " )
482 if ( !found && getenv("SALOME_ROOT_DIR") ) {
484 dir.sprintf("%s", getenv("SALOME_ROOT_DIR"));
485 dir = QAD_Tools::addSlash(dir) ;
487 dir = QAD_Tools::addSlash(dir) ;
489 dir = dir + "lib" + parentComp.latin1() + "GUI.dll" ;
491 dir = dir + "lib" + parentComp.latin1() + "GUI.so" ;
493 MESSAGE ( " GUI library = " << dir )
494 fileInfo.setFile(dir) ;
495 if (fileInfo.exists()) {
496 ComponentLib = fileInfo.fileName() ;
498 MESSAGE ( " found " )
500 MESSAGE ( " Not found " )
503 if ( !found && getenv( QAD_Application::getDesktop()->getComponentName(parentComp) + "_ROOT_DIR") ) {
505 dir.sprintf("%s", getenv( QAD_Application::getDesktop()->getComponentName(parentComp) + "_ROOT_DIR"));
506 dir = QAD_Tools::addSlash(dir) ;
508 dir = QAD_Tools::addSlash(dir) ;
509 dir = dir + "salome" ;
510 dir = QAD_Tools::addSlash(dir) ;
512 dir = dir + "lib" + parentComp.latin1() + "GUI.dll" ;
514 dir = dir + "lib" + parentComp.latin1() + "GUI.so" ;
516 MESSAGE ( " GUI library = " << dir )
517 fileInfo.setFile(dir) ;
518 if (fileInfo.exists()) {
519 ComponentLib = fileInfo.fileName() ;
521 MESSAGE ( " found " )
523 MESSAGE ( " Not found " )
527 if (ComponentLib.isEmpty()) {
529 QMessageBox::critical( desktop,
531 "Empty name of component "+ parentComp + " library");
535 foreignGUI.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
537 bool ok = foreignGUI.DlOpen(OSD_RTLD_LAZY);
540 QMessageBox::critical( desktop,
542 tr( foreignGUI.DlError() ) );
546 osdF = foreignGUI.DlSymb("buildPresentation");
547 if ( osdF == NULL ) {
548 MESSAGE("BuildPresentation method not found in component's GUI")
549 foreignGUI.DlClose();
552 osdViewTypeFunc = foreignGUI.DlSymb("supportedViewType");
553 if ( osdViewTypeFunc == NULL ) {
554 MESSAGE("supportedViewType method not found in component's GUI")
556 isForeignGUIUsed = true;
557 MESSAGE("onDisplay(): using parent component's GUI to build presentations")
560 // Check if another view type is required (if viewToActivate < 0 then any type of view is acceptable)
561 if (osdViewTypeFunc) {
562 void (*viewTypeChecker)(int*, int) = (void (*)(int*, int)) osdViewTypeFunc;
563 (*viewTypeChecker)(viewTypes, VIEW_TYPE_MAX);
564 if (viewTypes[0] >= 0) { // not all the view types are supported
565 for (int i = 0; i < VIEW_TYPE_MAX; i++) {
566 if (viewTypes[i] < 0) // no more types supported
568 isViewTypeOK = ((int)myActiveStudy->getActiveStudyFrame()->getTypeView() == viewTypes[i]);
569 if (isViewTypeOK) // one of supported views is already active
575 // Try to activate a view of one of supported types
577 MESSAGE("onDisplay(): view type is not acceptable")
578 unsigned frameCount = myActiveStudy->getStudyFramesCount();
579 for (unsigned i = 0; i < frameCount; i++) {
580 QAD_StudyFrame* frame = myActiveStudy->getStudyFrame(i);
581 for (int j = 0; j < VIEW_TYPE_MAX; j++) {
582 if (frame->getTypeView() == viewTypes[j]) {
583 MESSAGE("onDisplay(): activating other frame")
592 QMessageBox::warning( desktop,
594 tr("ERR_APP_WRONG_VIEW_TYPE"));
599 QAD_ViewFrame* viewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
601 // Build the graphic presentation (it is stored in the corresponding viewer)
602 builder = (void (*) (const Handle(SALOME_InteractiveObject)&)) osdF;
604 // Copy the selection
605 SALOME_ListIteratorOfListIO itInit( Sel->StoredIObjects() );
606 SALOME_ListIO selList;
607 for (; itInit.More(); itInit.Next()) {
608 selList.Append(itInit.Value());
611 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
613 bool needRepaint = false;
615 if (id == QAD_DisplayOnly_Popup_ID)
616 viewFrame->EraseAll();
618 SALOME_ListIteratorOfListIO It( selList );
619 for(;It.More();It.Next()) {
620 Handle(SALOME_InteractiveObject) IObject = It.Value();
622 // First check whether the object is a component or a child object
623 bool isComponent = false;
625 if (!IObject->hasEntry()) continue;
627 SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
628 if (!obj->_is_nil()) {
629 SALOMEDS::SComponent_var comp = obj->GetFatherComponent();
630 isComponent = (strcmp(comp->GetID(), obj->GetID()) == 0);
633 // For component -> display all children
635 SALOMEDS::ChildIterator_ptr it = aStudy->NewChildIterator(obj);
637 for ( ; it->More(); it->Next()) {
638 SALOMEDS::SObject_ptr child = it->Value();
639 Handle(SALOME_InteractiveObject) childIObject = new SALOME_InteractiveObject();
640 childIObject->setEntry(child->GetID());
642 // Ensure that proper 3D presentation exists for IObject
643 (*builder)(childIObject);
644 viewFrame->Display(childIObject, false);
647 } else { // for child object -> simply display it (no children are displayed)
648 // Ensure that proper 3D presentation exists for IObject
650 viewFrame->Display(IObject, false);
657 viewFrame->Repaint();
659 if (isForeignGUIUsed)
660 foreignGUI.DlClose();
661 myActiveStudy->updateObjBrowser(true);
666 void SALOMEGUI_Application::onErase()
668 QAD_WaitCursor waitCursor;
670 SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection() );
671 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
672 QAD_ViewFrame* viewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
673 bool needRepaint = false;
675 // Copy the selection
676 SALOME_ListIteratorOfListIO itInit( Sel->StoredIObjects() );
677 SALOME_ListIO selList;
678 for (; itInit.More(); itInit.Next()) {
679 selList.Append(itInit.Value());
682 SALOME_ListIteratorOfListIO It( selList );
683 for(;It.More();It.Next()) {
684 Handle(SALOME_InteractiveObject) IObject = It.Value();
686 // First check whether the object is a component or a child object
687 bool isComponent = false;
688 SALOMEDS::SObject_var obj;
690 if (IObject->hasEntry()) {
691 obj = aStudy->FindObjectID(IObject->getEntry());
692 if (!obj->_is_nil()) {
693 SALOMEDS::SComponent_var comp = obj->GetFatherComponent();
694 isComponent = (strcmp(comp->GetID(), obj->GetID()) == 0);
698 // For component -> erase all children
700 SALOMEDS::ChildIterator_ptr it = aStudy->NewChildIterator(obj);
702 for ( ; it->More(); it->Next()) {
703 SALOMEDS::SObject_ptr child = it->Value();
704 Handle(SALOME_InteractiveObject) childIObject = new SALOME_InteractiveObject();
705 childIObject->setEntry(child->GetID());
706 viewFrame->Erase(childIObject, false);
708 } else { // for child object -> simply erase it (no children are erased)
709 viewFrame->Erase(IObject, false);
715 viewFrame->Repaint();