Salome HOME
NPAL19769: Null rotation do a translation (sometime).
[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::OnSettingsIsos()
120 {
121 /*
122   SUIT_Session* sess = SUIT_Session::session();
123   SUIT_ResourceMgr* resMgr = sess->resourceMgr();
124   SUIT_Desktop* desk = sess->activeApplication()->desktop();
125
126   SUIT_ViewManager* vman = desk->activeWindow()->getViewManager();
127   QString type = vman->getType();
128
129   if ( type != OCCViewer_Viewer::Type() )
130     return;
131
132   OCCViewer_Viewer* vm = (OCCViewer_Viewer*)vman->getViewModel();
133   Handle (AIS_InteractiveContext) ic = vm->getAISContext();
134
135   int IsoU = resMgr->integerValue( "Geometry:SettingsIsoU", 1 );
136   int IsoV = resMgr->integerValue( "Geometry:SettingsIsoV", 1 );
137
138   ic->DefaultDrawer()->UIsoAspect()->SetNumber( IsoU );
139   ic->DefaultDrawer()->VIsoAspect()->SetNumber( IsoV );
140
141   GEOMBase_NbIsosDlg* NbIsosDlg = new GEOMBase_NbIsosDlg(desk, tr("GEOM_MEN_ISOS"), TRUE);
142
143   NbIsosDlg->SpinBoxU->setValue(IsoU);
144   NbIsosDlg->SpinBoxV->setValue(IsoV);
145
146   if(NbIsosDlg->exec()) {
147     IsoU = NbIsosDlg->SpinBoxU->text().toInt();
148     IsoV = NbIsosDlg->SpinBoxV->text().toInt();
149
150     ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso);
151     ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso);
152     resMgr->setValue("Geometry:SettingsIsoU", isoU);
153     resMgr->setValue("Geometry:SettingsIsoV", isoV);
154   }
155 */
156 }
157
158 void GEOMToolsGUI::OnSettingsStep()
159 {
160   SUIT_Session* sess = SUIT_Session::session();
161   SUIT_ResourceMgr* resMgr = sess->resourceMgr();
162
163   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100. );
164
165   Standard_Boolean res = false;
166   double dd = GEOMBase::Parameter( res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3);
167   if(res) {
168     resMgr->setValue( "Geometry", "SettingsGeomStep", dd );
169
170     /* Emit signal to GeometryGUI_SpinBoxes */
171     getGeometryGUI()->EmitSignalDefaultStepValueChanged( dd );
172   }
173   else
174     sess->activeApplication()->putInfo(tr("GEOM_PRP_ABORT"));
175 }
176
177 void GEOMToolsGUI::OnRename()
178 {
179   SALOME_ListIO selected;
180   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
181   if ( app ) {
182     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
183     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
184     if ( aSelMgr && appStudy ) {
185       aSelMgr->selectedObjects( selected );
186       if ( !selected.IsEmpty() ) {
187         _PTR(Study) aStudy = appStudy->studyDS();
188
189         bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
190         if ( aLocked ) {
191           SUIT_MessageBox::warn1 ( app->desktop(),
192                                    QObject::tr("WRN_WARNING"),
193                                    QObject::tr("WRN_STUDY_LOCKED"),
194                                    QObject::tr("BUT_OK") );
195           return;
196         }
197
198         for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
199           Handle(SALOME_InteractiveObject) IObject = It.Value();
200
201           _PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) );
202           _PTR(GenericAttribute) anAttr;
203           if ( obj ) {
204             if( obj->FindAttribute(anAttr, "AttributeName") ) {
205               _PTR(AttributeName) aName (anAttr);
206
207               QString newName = LightApp_NameDlg::getName( app->desktop(), aName->Value().c_str() );
208               if ( !newName.isEmpty() ) {
209                 aName->SetValue( newName.latin1() ); // rename the SObject
210                 IObject->setName( newName.latin1() );// rename the InteractiveObject
211                 // Rename the corresponding GEOM_Object
212                 GEOM::GEOM_Object_var anObj =  GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
213                 if (!CORBA::is_nil( anObj ))
214                   anObj->SetName( newName.latin1() );
215                 (dynamic_cast<SalomeApp_Module*>(app->activeModule()))->updateObjBrowser( false );
216               }
217             } // if ( name attribute )
218           } // if ( obj )
219         } // iterator
220       }
221     }
222   }
223   
224   app->updateActions(); //SRN: To update a Save button in the toolbar
225 }
226
227 void GEOMToolsGUI::OnCheckGeometry()
228 {
229   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
230   PythonConsole* pyConsole = app->pythonConsole();
231
232   if(pyConsole)
233     pyConsole->exec("from GEOM_usinggeom import *");
234 }
235
236 void GEOMToolsGUI::OnAutoColor()
237 {
238   QPtrList<SALOME_Prs> aListOfGroups;
239
240   SALOME_ListIO selected;
241   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
242   if( !app )
243     return;
244
245   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
246   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
247   if( !aSelMgr || !appStudy )
248     return;
249
250   aSelMgr->selectedObjects( selected );
251   if( selected.IsEmpty() )
252     return;
253
254   Handle(SALOME_InteractiveObject) anIObject = selected.First();
255
256   _PTR(Study) aStudy = appStudy->studyDS();
257   _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
258   GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
259   if( CORBA::is_nil( aMainObject ) )
260     return;
261
262   aMainObject->SetAutoColor( true );
263
264   QValueList<SALOMEDS::Color> aReservedColors;
265
266   GEOM_Displayer aDisp (appStudy);
267
268   SALOME_View* vf = aDisp.GetActiveView();
269
270   SUIT_ViewWindow* window = app->desktop()->activeWindow();
271   bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
272   bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
273
274   for( _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); it->More(); it->Next() )
275   {
276     _PTR(SObject) aChildSObject( it->Value() );
277     GEOM::GEOM_Object_var aChildObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
278     if( CORBA::is_nil( aChildObject ) )
279       continue;
280
281     if( aChildObject->GetType() != GEOM_GROUP )
282       continue;
283
284     SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
285     aChildObject->SetColor( aColor );
286     aReservedColors.append( aColor );
287
288     QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
289
290     SALOME_Prs* aPrs = vf->CreatePrs( aChildSObject->GetID().c_str() );
291
292     if ( isVTK )
293     {
294       SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
295       if ( !vtkVW )
296         return;
297       SVTK_View* aView = vtkVW->getView();
298       SUIT_OverrideCursor();
299       for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
300         aView->SetColor( It.Value(), c );
301     }
302     else if ( isOCC )
303     {
304       OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
305       Handle(AIS_InteractiveContext) ic = vm->getAISContext();
306
307       SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
308       if( !anOCCPrs )
309         continue;
310
311       AIS_ListOfInteractive aList;
312       anOCCPrs->GetObjects( aList );
313       if( !aList.Extent() )
314         continue;
315
316       Handle(AIS_InteractiveObject) io = aList.First();
317       if( io.IsNull() )
318         continue;
319
320       Quantity_Color aQuanColor( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
321
322       // Set color for a point
323       Handle(AIS_Drawer) aCurDrawer = io->Attributes();
324       Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
325       Quantity_Color aCurColor;
326       Standard_Real aCurScale;
327       Aspect_TypeOfMarker aCurTypeOfMarker;
328       aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
329       aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aQuanColor, aCurScale) );
330       ic->SetLocalAttributes( io, aCurDrawer );
331
332       io->SetColor( aQuanColor );
333       if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
334         Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aQuanColor );
335
336       io->Redisplay( Standard_True );
337     }
338   }
339
340   app->updateActions(); //SRN: To update a Save button in the toolbar
341 }
342
343 void GEOMToolsGUI::OnDisableAutoColor()
344 {
345   SALOME_ListIO selected;
346   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
347   if( !app )
348     return;
349
350   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
351   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
352   if( !aSelMgr || !appStudy )
353     return;
354
355   aSelMgr->selectedObjects( selected );
356   if( selected.IsEmpty() )
357     return;
358
359   Handle(SALOME_InteractiveObject) anIObject = selected.First();
360
361   _PTR(Study) aStudy = appStudy->studyDS();
362   _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
363   GEOM::GEOM_Object_var aMainObject =  GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
364   if( CORBA::is_nil( aMainObject ) )
365     return;
366
367   aMainObject->SetAutoColor( false );
368
369 }
370
371 void GEOMToolsGUI::OnColor()
372 {
373   SALOME_ListIO selected;
374   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
375   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
376   if ( app && appStudy ) {
377     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
378     if ( aSelMgr ) {
379       aSelMgr->selectedObjects( selected );
380       if ( !selected.IsEmpty() ) {
381         SUIT_ViewWindow* window = app->desktop()->activeWindow();
382         bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
383         bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
384         if ( isVTK ) {
385           SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
386           if ( !vtkVW )
387             return;
388           SVTK_View* aView = vtkVW->getView();
389           QColor initcolor = aView->GetColor( selected.First()  );
390           QColor c = QColorDialog::getColor( initcolor, app->desktop() );
391           if ( c.isValid() ) {
392             SUIT_OverrideCursor();
393             for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
394               aView->SetColor( It.Value(), c );
395             }
396           }
397         } // if ( isVTK )
398         else if ( isOCC ) {
399           Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
400           if ( !io.IsNull() ) {
401             Quantity_Color aColor;
402             io->Color( aColor );
403             QColor initcolor( (int)( aColor.Red() * 255.0 ), (int)( aColor.Green() * 255.0 ), (int)( aColor.Blue() * 255.0 ) );
404             QColor c =  QColorDialog::getColor( initcolor, app->desktop() );
405             if ( c.isValid() ) {
406               SUIT_OverrideCursor();
407               aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
408               for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
409                 io = GEOMBase::GetAIS( It.Value(), true );
410                 if ( !io.IsNull() ) {
411                   // Set color for a point
412                   OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
413                   Handle (AIS_InteractiveContext) ic = vm->getAISContext();
414                   Handle(AIS_Drawer) aCurDrawer = io->Attributes();
415                   Handle(Prs3d_PointAspect) aCurPointAspect =  aCurDrawer->PointAspect();
416                   Quantity_Color aCurColor;
417                   Standard_Real aCurScale;
418                   Aspect_TypeOfMarker aCurTypeOfMarker;
419                   aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
420                   aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aColor, aCurScale) );
421                   ic->SetLocalAttributes(io, aCurDrawer);
422                   
423                   io->SetColor( aColor );
424                   if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
425                     Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aColor );
426
427                   io->Redisplay( Standard_True );
428
429                   // store color to GEOM_Object
430                   _PTR(Study) aStudy = appStudy->studyDS();
431                   _PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) );
432                   GEOM::GEOM_Object_var anObject =
433                     GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
434
435                   SALOMEDS::Color aSColor;
436                   aSColor.R = (double)c.red() / 255.0;
437                   aSColor.G = (double)c.green() / 255.0;
438                   aSColor.B = (double)c.blue() / 255.0;
439                   anObject->SetColor( aSColor );
440                   anObject->SetAutoColor( false );
441                 }
442               }
443             } // if c.isValid()
444           } // first IO is not null
445         } // if ( isOCC )
446       } // if ( selection not empty )
447     }
448   }
449   
450   app->updateActions(); //SRN: To update a Save button in the toolbar
451 }
452
453 void GEOMToolsGUI::OnTransparency()
454 {
455   GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
456   dlg.exec();
457 }
458
459 void GEOMToolsGUI::OnNbIsos()
460 {
461   SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
462   
463   bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
464   const bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
465
466   // if is OCCViewer
467   if(isOCC){
468
469     OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
470     Handle (AIS_InteractiveContext) ic = vm->getAISContext();
471
472     ic->InitCurrent();
473     if ( ic->MoreCurrent() ) {
474       Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
475       Handle(AIS_Drawer)    CurDrawer = CurObject->Attributes();
476       
477       int UIso = CurDrawer->UIsoAspect()->Number();
478       int VIso = CurDrawer->VIsoAspect()->Number();
479       
480       GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
481         new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
482       
483       NbIsosDlg->setU( UIso );
484       NbIsosDlg->setV( VIso );
485       
486       if ( NbIsosDlg->exec() ) {
487         SUIT_OverrideCursor();
488         for(; ic->MoreCurrent(); ic->NextCurrent()) {
489           CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
490           Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
491           
492           int nbUIso = NbIsosDlg->getU();
493           int nbVIso = NbIsosDlg->getV();
494           
495           CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbUIso) );
496           CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbVIso) );
497           
498           ic->SetLocalAttributes(CurObject, CurDrawer);
499           ic->Redisplay(CurObject);
500         }
501       }
502     }
503   } else if(isVTK){ // if is VTKViewer
504
505     //
506     // Warning. It's works incorrect. must be recheked.
507     //
508     SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
509     if ( !app )
510       return;
511     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
512     if ( !aSelMgr )
513       return;
514     SALOME_ListIO selected;
515     aSelMgr->selectedObjects( selected );
516     if ( selected.IsEmpty() )
517       return;
518     
519     Handle(SALOME_InteractiveObject) FirstIOS =  selected.First();
520     if ( FirstIOS.IsNull() )
521       return;
522     
523     SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
524     if ( !vtkVW )
525       return;
526     
527     SVTK_View* aView = vtkVW->getView();
528     vtkActorCollection* aCollection = aView->getRenderer()->GetActors();
529     
530     int UIso = 0;
531     int VIso = 0;
532     if(aCollection){
533       aCollection->InitTraversal();
534     }
535     
536     vtkActor *anAct = aCollection->GetNextActor();
537     if(GEOM_Actor *anActor = dynamic_cast<GEOM_Actor*>(anAct)){
538       anActor->GetNbIsos(UIso,VIso);
539     }
540     
541     
542     GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
543       new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
544     
545     NbIsosDlg->setU( UIso );
546     NbIsosDlg->setV( VIso );
547     
548     if ( NbIsosDlg->exec() ) {
549       SUIT_OverrideCursor();
550       
551       while(anAct = aCollection->GetNextActor()) {
552         if(GEOM_Actor *anActor = dynamic_cast<GEOM_Actor*>(anAct)){
553           // There are no casting to needed actor.
554           UIso = NbIsosDlg->getU();
555           VIso = NbIsosDlg->getV();
556           int aIsos[2]={UIso,VIso};
557           anActor->SetNbIsos(aIsos);
558         }
559       }
560     }
561   } // end vtkviewer
562
563 }
564
565 void GEOMToolsGUI::OnOpen()
566 {
567 /*
568   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
569   _PTR(Study) aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
570
571   SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
572   Handle(SALOME_InteractiveObject) anIObject;
573   for(;It.More();It.Next()) {
574     anIObject = It.Value();
575     _PTR(SObject) obj ( aStudy->FindObjectID(anIObject->getEntry()) );
576     _PTR(AttributePersistentRef) aPersist;
577     _PTR(AttributeIOR) anIOR;
578     if(obj) {
579       // this SObject may be GEOM module root SObject
580       _PTR(ChildIterator) anIter ( aStudy->NewChildIterator() );
581       _PTR(GenericAttribute) anAttr;
582       bool useSubItems = false;
583       while (anIter->More() && !useSubItems) {
584         _PTR(SObject) subobj ( anIter->Value() );
585         if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) {
586           useSubItems = true;
587           obj =  subobj;
588         }
589         else
590           anIter->Next();
591       }
592       obj->FindAttribute(anAttr, "AttributePersistentRef");
593
594       while(useSubItems?anIter->More():!anAttr->_is_nil()) {
595         if(!obj->FindAttribute(anAttr, "AttributeIOR") &&
596            obj->FindAttribute(anAttr, "AttributePersistentRef")) {
597           _PTR(SComponent) FComp ( obj->GetFatherComponent() );
598           if (FComp) {
599             if (FComp->FindAttribute(anAttr, "AttributeName")) {
600               _PTR(AttributeName) aName ( anAttr );
601               QString compName = QAD_Application::getDesktop()->getComponentName(aName->Value().c_str());
602               //                    parent->loadComponentData(parent->getComponentName(aName->Value()));
603               Engines::Component_var comp ;
604               if ( compName.compare("SUPERV") == 0 ) {
605                 comp = QAD_Application::getDesktop()->getEngine( "SuperVisionContainer", compName) ;
606               }
607               else {
608                 comp = QAD_Application::getDesktop()->getEngine( "FactoryServer", compName);
609                 if ( comp->_is_nil() )
610                   comp = QAD_Application::getDesktop()->getEngine( "FactoryServerPy", compName);
611               }
612
613               if (!CORBA::is_nil(comp)) {
614                 SALOMEDS::Driver_var   driver = SALOMEDS::Driver::_narrow(comp);
615                 if (!CORBA::is_nil(driver)) {
616                   SALOMEDS::StudyBuilder_var  B = dynamic_cast<SALOMEDS_Study*>(aStudy.get())->GetStudy()->NewBuilder();
617                   if (!CORBA::is_nil(B)) {
618                     B->LoadWith(FComp,driver);
619                   } else {
620                     return;
621                   }
622                 }
623                 else {
624                   MESSAGE("loadComponentData(): Driver is null");
625                   return;
626                 }
627               }
628               else {
629                 MESSAGE("loadComponentData(): Engine is null");
630                 return;
631               }
632                 //              // load
633                 //              Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer","GEOM");
634                 //              if (!CORBA::is_nil(comp)) {
635                 //                SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
636                 //                SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
637                 //                SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM");
638                 //                if (!CORBA::is_nil(SC))
639                 //                  aStudyBuilder->LoadWith(SC,driver);
640             }
641           }
642           else {
643             MESSAGE("Component is null");
644           }
645         }
646         if(useSubItems) {
647           anIter->Next();
648           obj.reset( anIter->Value() );
649         }
650         else
651           anAttr = NULL;
652       }
653     }
654   }
655 */
656 }
657
658 void GEOMToolsGUI::OnSelectOnly(int mode)
659 {
660   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
661   if ( app ) {
662     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
663     GEOM_Displayer aDisp (appStudy);
664     aDisp.GlobalSelection(mode);
665     getGeometryGUI()->setLocalSelectionMode(mode);
666   }
667 }