Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI_1.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File   : GEOMToolsGUI_1.cxx
24 // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
25 //
26 #include <PyConsole_Console.h>
27
28 #include "GEOMToolsGUI.h"
29 #include "GEOMToolsGUI_TransparencyDlg.h"
30 #include "GEOMToolsGUI_NbIsosDlg.h"
31
32 #include <GeometryGUI.h>
33 #include <GEOM_Displayer.h>
34
35 #include <GEOMBase.h>
36 #include <GEOM_Actor.h>
37
38 #include <SALOME_ListIO.hxx>
39 #include <SALOME_ListIteratorOfListIO.hxx>
40
41 #include <SOCC_Prs.h>
42
43 #include <SVTK_Prs.h>
44 #include <SVTK_ViewModel.h>
45 #include <SVTK_ViewWindow.h>
46 #include <SVTK_View.h>
47
48 #include <OCCViewer_ViewModel.h>
49
50 #include <SUIT_ViewManager.h>
51 #include <SUIT_Desktop.h>
52 #include <SUIT_ResourceMgr.h>
53 #include <SUIT_Session.h>
54 #include <SUIT_OverrideCursor.h>
55 #include <SUIT_MessageBox.h>
56
57 #include <SalomeApp_Application.h>
58 #include <SalomeApp_Study.h>
59 #include <SalomeApp_Module.h>
60
61 #include <LightApp_SelectionMgr.h>
62 #include <LightApp_NameDlg.h>
63
64 #include <GEOMImpl_Types.hxx>
65
66 #include "utilities.h"
67
68 // OCCT Includes
69 #include <AIS_Drawer.hxx>
70 #include <Prs3d_IsoAspect.hxx>
71 #include <Prs3d_PointAspect.hxx>
72 #include <Graphic3d_AspectMarker3d.hxx>
73
74 // QT Includes
75 #include <QColorDialog>
76 #include <QList>
77
78 // VTK includes
79 #include <vtkRenderer.h>
80
81 void GEOMToolsGUI::OnSettingsColor()
82 {
83   SUIT_Session* sess = SUIT_Session::session();
84   SUIT_ResourceMgr* resMgr = sess->resourceMgr();
85   SUIT_Desktop* desk = sess->activeApplication()->desktop();
86
87   QColor anInitColor = resMgr->colorValue( "Geometry", "SettingsShadingColor", QColor( "yellow" ) );
88
89   QColor aDialogColor = QColorDialog::getColor(anInitColor, desk );
90   if( aDialogColor.isValid() )
91   {
92     QString type = desk->activeWindow()->getViewManager()->getType();
93     if( type != OCCViewer_Viewer::Type() && type != SVTK_Viewer::Type() )
94       MESSAGE("Settings Color is not supported for current Viewer");
95
96     resMgr->setValue( "Geometry", "SettingsShadingColor", aDialogColor );
97   }
98 }
99
100 void GEOMToolsGUI::OnRename()
101 {
102   SALOME_ListIO selected;
103   SalomeApp_Application* app =
104     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
105   if ( app ) {
106     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
107     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
108     if ( aSelMgr && appStudy ) {
109       aSelMgr->selectedObjects( selected );
110       if ( !selected.IsEmpty() ) {
111         _PTR(Study) aStudy = appStudy->studyDS();
112
113         bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
114         if ( aLocked ) {
115           SUIT_MessageBox::warning ( app->desktop(),
116                                      QObject::tr("WRN_WARNING"),
117                                      QObject::tr("WRN_STUDY_LOCKED") );
118           return;
119         }
120
121         bool isAny = false; // is there any appropriate object selected
122         for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
123           Handle(SALOME_InteractiveObject) IObject = It.Value();
124
125           _PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) );
126           _PTR(GenericAttribute) anAttr;
127           if ( obj ) {
128             if ( obj->FindAttribute(anAttr, "AttributeName") ) {
129               _PTR(AttributeName) aName (anAttr);
130
131               GEOM::GEOM_Object_var anObj =
132                 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
133               if (!CORBA::is_nil(anObj)) {
134                 isAny = true;
135                 QString newName = LightApp_NameDlg::getName( app->desktop(), aName->Value().c_str() );
136                 if (!newName.isEmpty()) {
137                   aName->SetValue( newName.toLatin1().data() ); // rename the SObject
138                   IObject->setName( newName.toLatin1().data() );// rename the InteractiveObject
139                   anObj->SetName( newName.toLatin1().data() );  // Rename the corresponding GEOM_Object
140                   (dynamic_cast<SalomeApp_Module*>(app->activeModule()))->updateObjBrowser( false );
141                 }
142               } // if ( anObj )
143             } // if ( name attribute )
144           } // if ( obj )
145         } // iterator
146
147         if (!isAny) {
148           SUIT_MessageBox::warning( app->desktop(),
149                                     QObject::tr("WRN_WARNING"),
150                                     QObject::tr("GEOM_WRN_NO_APPROPRIATE_SELECTION") );
151           return;
152         }
153       }
154     }
155   }
156   
157   app->updateActions(); //SRN: To update a Save button in the toolbar
158 }
159
160 void GEOMToolsGUI::OnCheckGeometry()
161 {
162   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
163   PyConsole_Console* pyConsole = app->pythonConsole();
164
165   if(pyConsole)
166     pyConsole->exec("from GEOM_usinggeom import *");
167 }
168
169 void GEOMToolsGUI::OnAutoColor()
170 {
171   SALOME_ListIO selected;
172   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
173   if( !app )
174     return;
175
176   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
177   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
178   if( !aSelMgr || !appStudy )
179     return;
180
181   aSelMgr->selectedObjects( selected );
182   if( selected.IsEmpty() )
183     return;
184
185   Handle(SALOME_InteractiveObject) anIObject = selected.First();
186
187   _PTR(Study) aStudy = appStudy->studyDS();
188   _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
189   GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
190   if( CORBA::is_nil( aMainObject ) )
191     return;
192
193   aMainObject->SetAutoColor( true );
194
195   QList<SALOMEDS::Color> aReservedColors;
196
197   GEOM_Displayer aDisp (appStudy);
198
199   SALOME_View* vf = aDisp.GetActiveView();
200
201   SUIT_ViewWindow* window = app->desktop()->activeWindow();
202   bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
203   bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
204
205   for( _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); it->More(); it->Next() )
206   {
207     _PTR(SObject) aChildSObject( it->Value() );
208     GEOM::GEOM_Object_var aChildObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
209     if( CORBA::is_nil( aChildObject ) )
210       continue;
211
212     if( aChildObject->GetType() != GEOM_GROUP )
213       continue;
214
215     SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
216     aChildObject->SetColor( aColor );
217     aReservedColors.append( aColor );
218
219     QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
220
221     SALOME_Prs* aPrs = vf->CreatePrs( aChildSObject->GetID().c_str() );
222
223     if ( isVTK )
224     {
225       SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
226       if ( !vtkVW )
227         return;
228       SVTK_View* aView = vtkVW->getView();
229       SUIT_OverrideCursor();
230       for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
231         aView->SetColor( It.Value(), c );
232     }
233     else if ( isOCC )
234     {
235       OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
236       Handle(AIS_InteractiveContext) ic = vm->getAISContext();
237
238       SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
239       if( !anOCCPrs )
240         continue;
241
242       AIS_ListOfInteractive aList;
243       anOCCPrs->GetObjects( aList );
244       if( !aList.Extent() )
245         continue;
246
247       Handle(AIS_InteractiveObject) io = aList.First();
248       if( io.IsNull() )
249         continue;
250
251       Quantity_Color aQuanColor( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
252
253       // Set color for a point
254       Handle(AIS_Drawer) aCurDrawer = io->Attributes();
255       Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
256       Quantity_Color aCurColor;
257       Standard_Real aCurScale;
258       Aspect_TypeOfMarker aCurTypeOfMarker;
259       aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
260       aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aQuanColor, aCurScale) );
261       ic->SetLocalAttributes( io, aCurDrawer );
262
263       io->SetColor( aQuanColor );
264       if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
265         Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aQuanColor );
266
267       io->Redisplay( Standard_True );
268     }
269   }
270
271   app->updateActions(); //SRN: To update a Save button in the toolbar
272 }
273
274 void GEOMToolsGUI::OnDisableAutoColor()
275 {
276   SALOME_ListIO selected;
277   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
278   if( !app )
279     return;
280
281   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
282   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
283   if( !aSelMgr || !appStudy )
284     return;
285
286   aSelMgr->selectedObjects( selected );
287   if( selected.IsEmpty() )
288     return;
289
290   Handle(SALOME_InteractiveObject) anIObject = selected.First();
291
292   _PTR(Study) aStudy = appStudy->studyDS();
293   _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
294   GEOM::GEOM_Object_var aMainObject =  GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
295   if( CORBA::is_nil( aMainObject ) )
296     return;
297
298   aMainObject->SetAutoColor( false );
299
300 }
301
302 void GEOMToolsGUI::OnColor()
303 {
304   SALOME_ListIO selected;
305   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
306   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
307   if ( app && appStudy ) {
308     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
309     if ( aSelMgr ) {
310       aSelMgr->selectedObjects( selected );
311       if ( !selected.IsEmpty() ) {
312         SUIT_ViewWindow* window = app->desktop()->activeWindow();
313         bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
314         bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
315         if ( isVTK ) {
316           SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
317           if ( !vtkVW )
318             return;
319           SVTK_View* aView = vtkVW->getView();
320           QColor initcolor = aView->GetColor( selected.First()  );
321           QColor c = QColorDialog::getColor( initcolor, app->desktop() );
322           if ( c.isValid() ) {
323             SUIT_OverrideCursor();
324             for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
325               aView->SetColor( It.Value(), c );
326             }
327           }
328         } // if ( isVTK )
329         else if ( isOCC ) {
330           Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
331           if ( !io.IsNull() ) {
332             Quantity_Color aColor;
333             io->Color( aColor );
334             QColor initcolor( (int)( aColor.Red() * 255.0 ), (int)( aColor.Green() * 255.0 ), (int)( aColor.Blue() * 255.0 ) );
335             QColor c =  QColorDialog::getColor( initcolor, app->desktop() );
336             if ( c.isValid() ) {
337               SUIT_OverrideCursor();
338               aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
339               for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
340                 io = GEOMBase::GetAIS( It.Value(), true );
341                 if ( !io.IsNull() ) {
342                   // Set color for a point
343                   OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
344                   Handle (AIS_InteractiveContext) ic = vm->getAISContext();
345                   Handle(AIS_Drawer) aCurDrawer = io->Attributes();
346                   Handle(Prs3d_PointAspect) aCurPointAspect =  aCurDrawer->PointAspect();
347                   Quantity_Color aCurColor;
348                   Standard_Real aCurScale;
349                   Aspect_TypeOfMarker aCurTypeOfMarker;
350                   aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
351                   aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aColor, aCurScale) );
352                   ic->SetLocalAttributes(io, aCurDrawer);
353                   
354                   io->SetColor( aColor );
355                   if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
356                     Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aColor );
357
358                   io->Redisplay( Standard_True );
359
360                   // store color to GEOM_Object
361                   _PTR(Study) aStudy = appStudy->studyDS();
362                   _PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) );
363                   GEOM::GEOM_Object_var anObject =
364                     GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
365
366                   SALOMEDS::Color aSColor;
367                   aSColor.R = (double)c.red() / 255.0;
368                   aSColor.G = (double)c.green() / 255.0;
369                   aSColor.B = (double)c.blue() / 255.0;
370                   anObject->SetColor( aSColor );
371                   anObject->SetAutoColor( false );
372                 }
373               }
374             } // if c.isValid()
375           } // first IO is not null
376         } // if ( isOCC )
377       } // if ( selection not empty )
378     }
379   }
380   
381   app->updateActions(); //SRN: To update a Save button in the toolbar
382 }
383
384 void GEOMToolsGUI::OnTransparency()
385 {
386   GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
387   dlg.exec();
388 }
389
390 void GEOMToolsGUI::OnNbIsos()
391 {
392   SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
393   
394   bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
395   bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
396
397   if(isOCC){ // if is OCCViewer
398
399     OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
400     Handle (AIS_InteractiveContext) ic = vm->getAISContext();
401
402     ic->InitCurrent();
403     if ( ic->MoreCurrent() ) {
404       Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
405       Handle(AIS_Drawer)    CurDrawer = CurObject->Attributes();
406       
407       int UIso = CurDrawer->UIsoAspect()->Number();
408       int VIso = CurDrawer->VIsoAspect()->Number();
409       
410       GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
411         new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
412       
413       NbIsosDlg->setU( UIso );
414       NbIsosDlg->setV( VIso );
415       
416       if ( NbIsosDlg->exec() ) {
417         SUIT_OverrideCursor();
418         for(; ic->MoreCurrent(); ic->NextCurrent()) {
419           CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
420           Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
421           
422           int nbUIso = NbIsosDlg->getU();
423           int nbVIso = NbIsosDlg->getV();
424           
425           CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbUIso) );
426           CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbVIso) );
427           
428           ic->SetLocalAttributes(CurObject, CurDrawer);
429           ic->Redisplay(CurObject);
430         }
431       }
432     }
433   }
434   else if(isVTK){ // if is VTKViewer
435     //
436     // Warning. It's works incorrect. must be recheked.
437     //
438     SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
439     if ( !app )
440       return;
441     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
442     if ( !aSelMgr )
443       return;
444     SALOME_ListIO selected;
445     aSelMgr->selectedObjects( selected );
446     if ( selected.IsEmpty() )
447       return;
448     
449     SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
450     if ( !vtkVW )
451       return;
452
453     SALOME_View* view = GEOM_Displayer::GetActiveView();
454
455     vtkActorCollection* aCollection = vtkActorCollection::New();
456     
457     for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
458       Handle(SALOME_InteractiveObject) anIObject = It.Value();
459       SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() ); 
460       SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aPrs );
461       if ( vtkPrs ) {
462         vtkActorCollection* anActors = vtkPrs->GetObjects();
463         anActors->InitTraversal();
464         vtkActor* anAct = anActors->GetNextActor();
465         aCollection->AddItem(anAct);
466       }
467     }
468   
469     if(aCollection)
470       aCollection->InitTraversal();
471     else
472       return;
473    
474     int UIso = 0;
475     int VIso = 0;
476     
477     vtkActor* anAct = aCollection->GetNextActor();
478     if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
479       anActor->GetNbIsos(UIso,VIso);
480     else
481       return;
482     
483     GEOMToolsGUI_NbIsosDlg* NbIsosDlg =
484       new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
485
486     NbIsosDlg->setU( UIso );
487     NbIsosDlg->setV( VIso );
488
489     if ( NbIsosDlg->exec() ) {
490       SUIT_OverrideCursor();
491       
492       while( anAct!=NULL ) {
493         if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){
494           // There are no casting to needed actor.
495           UIso = NbIsosDlg->getU();
496           VIso = NbIsosDlg->getV();
497           int aIsos[2]={UIso,VIso};
498           anActor->SetNbIsos(aIsos);
499         }
500         anAct = aCollection->GetNextActor();
501       }
502     }
503   } // end vtkviewer
504 }
505
506 void GEOMToolsGUI::OnOpen()
507 {
508 /*
509   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
510   _PTR(Study) aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
511
512   SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
513   Handle(SALOME_InteractiveObject) anIObject;
514   for(;It.More();It.Next()) {
515     anIObject = It.Value();
516     _PTR(SObject) obj ( aStudy->FindObjectID(anIObject->getEntry()) );
517     _PTR(AttributePersistentRef) aPersist;
518     _PTR(AttributeIOR) anIOR;
519     if(obj) {
520       // this SObject may be GEOM module root SObject
521       _PTR(ChildIterator) anIter ( aStudy->NewChildIterator() );
522       _PTR(GenericAttribute) anAttr;
523       bool useSubItems = false;
524       while (anIter->More() && !useSubItems) {
525         _PTR(SObject) subobj ( anIter->Value() );
526         if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) {
527           useSubItems = true;
528           obj =  subobj;
529         }
530         else
531           anIter->Next();
532       }
533       obj->FindAttribute(anAttr, "AttributePersistentRef");
534
535       while(useSubItems?anIter->More():!anAttr->_is_nil()) {
536         if(!obj->FindAttribute(anAttr, "AttributeIOR") &&
537            obj->FindAttribute(anAttr, "AttributePersistentRef")) {
538           _PTR(SComponent) FComp ( obj->GetFatherComponent() );
539           if (FComp) {
540             if (FComp->FindAttribute(anAttr, "AttributeName")) {
541               _PTR(AttributeName) aName ( anAttr );
542               QString compName = QAD_Application::getDesktop()->getComponentName(aName->Value().c_str());
543               //                    parent->loadComponentData(parent->getComponentName(aName->Value()));
544               Engines::Component_var comp ;
545               if ( compName.compare("SUPERV") == 0 ) {
546                 comp = QAD_Application::getDesktop()->getEngine( "SuperVisionContainer", compName) ;
547               }
548               else {
549                 comp = QAD_Application::getDesktop()->getEngine( "FactoryServer", compName);
550                 if ( comp->_is_nil() )
551                   comp = QAD_Application::getDesktop()->getEngine( "FactoryServerPy", compName);
552               }
553
554               if (!CORBA::is_nil(comp)) {
555                 SALOMEDS::Driver_var   driver = SALOMEDS::Driver::_narrow(comp);
556                 if (!CORBA::is_nil(driver)) {
557                   SALOMEDS::StudyBuilder_var  B = dynamic_cast<SALOMEDS_Study*>(aStudy.get())->GetStudy()->NewBuilder();
558                   if (!CORBA::is_nil(B)) {
559                     B->LoadWith(FComp,driver);
560                   } else {
561                     return;
562                   }
563                 }
564                 else {
565                   MESSAGE("loadComponentData(): Driver is null");
566                   return;
567                 }
568               }
569               else {
570                 MESSAGE("loadComponentData(): Engine is null");
571                 return;
572               }
573                 //              // load
574                 //              Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer","GEOM");
575                 //              if (!CORBA::is_nil(comp)) {
576                 //                SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
577                 //                SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
578                 //                SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM");
579                 //                if (!CORBA::is_nil(SC))
580                 //                  aStudyBuilder->LoadWith(SC,driver);
581             }
582           }
583           else {
584             MESSAGE("Component is null");
585           }
586         }
587         if(useSubItems) {
588           anIter->Next();
589           obj.reset( anIter->Value() );
590         }
591         else
592           anAttr = NULL;
593       }
594     }
595   }
596 */
597 }
598
599 void GEOMToolsGUI::OnSelectOnly(int mode)
600 {
601   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
602   if ( app ) {
603     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
604     GEOM_Displayer aDisp (appStudy);
605     aDisp.GlobalSelection(mode);
606     getGeometryGUI()->setLocalSelectionMode(mode);
607   }
608 }