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