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