Salome HOME
Implementation of the "21046: EDF 1610 GUI: To be able to change the width of the...
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI_1.cxx
1 // Copyright (C) 2007-2011  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 #include "GEOMToolsGUI_DeflectionDlg.h"
32 #include "GEOMToolsGUI_MarkerDlg.h"
33 #include "GEOMToolsGUI_PublishDlg.h"
34 #include "GEOMToolsGUI_MaterialPropertiesDlg.h"
35 #include "GEOMToolsGUI_LineWidthDlg.h"
36
37 #include <GeometryGUI.h>
38 #include <GeometryGUI_Operations.h>
39 #include <GEOM_Constants.h>
40 #include <GEOM_Displayer.h>
41
42 #include <GEOMBase.h>
43 #include <GEOM_Actor.h>
44
45 #include <Basics_OCCTVersion.hxx>
46
47 #include <SALOME_ListIO.hxx>
48 #include <SALOME_ListIteratorOfListIO.hxx>
49
50 #include <SOCC_Prs.h>
51
52 #include <SVTK_Prs.h>
53 #include <SVTK_ViewModel.h>
54 #include <SVTK_ViewWindow.h>
55 #include <SVTK_View.h>
56
57 #include <OCCViewer_ViewModel.h>
58
59 #include <SUIT_ViewManager.h>
60 #include <SUIT_Desktop.h>
61 #include <SUIT_ResourceMgr.h>
62 #include <SUIT_Session.h>
63 #include <SUIT_OverrideCursor.h>
64 #include <SUIT_MessageBox.h>
65 #include <SUIT_Tools.h>
66
67 #include <SalomeApp_Application.h>
68 #include <SalomeApp_Study.h>
69 #include <SalomeApp_Module.h>
70
71 #include <LightApp_SelectionMgr.h>
72 #include <LightApp_NameDlg.h>
73
74 #include <GEOMImpl_Types.hxx>
75
76 #include "utilities.h"
77
78 // OCCT Includes
79 #include <AIS_Drawer.hxx>
80 #include <Prs3d_IsoAspect.hxx>
81 #include <Prs3d_PointAspect.hxx>
82 #include <Graphic3d_AspectMarker3d.hxx>
83 #include <Graphic3d_AspectLine3d.hxx>
84
85 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
86 #include <TColStd_HArray1OfByte.hxx>
87 #else
88 #include <Graphic3d_HArray1OfBytes.hxx>
89 #endif
90
91 // QT Includes
92 #include <QColorDialog>
93 #include <QInputDialog>
94 #include <QFileDialog>
95 #include <QList>
96
97 #include <QGridLayout>
98 #include <QGroupBox>
99 #include <QSpinBox>
100 #include <QPushButton>
101 #include <QKeyEvent>
102
103 // VTK includes
104 #include <vtkRenderer.h>
105
106
107 void GEOMToolsGUI::OnCheckGeometry()
108 {
109   SalomeApp_Application* app =
110     dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication());
111   PyConsole_Console* pyConsole = app->pythonConsole();
112
113   if (pyConsole)
114     pyConsole->exec("from GEOM_usinggeom import *");
115 }
116
117 void GEOMToolsGUI::OnAutoColor()
118 {
119   SALOME_ListIO selected;
120   SalomeApp_Application* app =
121     dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication());
122   if (!app)
123     return;
124
125   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
126   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
127   if (!aSelMgr || !appStudy)
128     return;
129
130   aSelMgr->selectedObjects(selected);
131   if (selected.IsEmpty())
132     return;
133
134   Handle(SALOME_InteractiveObject) anIObject = selected.First();
135
136   _PTR(Study) aStudy = appStudy->studyDS();
137   _PTR(SObject) aMainSObject(aStudy->FindObjectID(anIObject->getEntry()));
138   GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
139   if (CORBA::is_nil(aMainObject))
140     return;
141
142   aMainObject->SetAutoColor( true );
143
144   QList<SALOMEDS::Color> aReservedColors;
145
146   GEOM_Displayer aDisp (appStudy);
147
148   SALOME_View* vf = aDisp.GetActiveView();
149
150   SUIT_ViewWindow* window = app->desktop()->activeWindow();
151   bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
152   bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
153
154   for( _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); it->More(); it->Next() )
155   {
156     _PTR(SObject) aChildSObject( it->Value() );
157     GEOM::GEOM_Object_var aChildObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
158     if( CORBA::is_nil( aChildObject ) )
159       continue;
160
161     if( aChildObject->GetType() != GEOM_GROUP )
162       continue;
163
164     SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
165     aChildObject->SetColor( aColor );
166     aReservedColors.append( aColor );
167
168     QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
169
170     SALOME_Prs* aPrs = vf->CreatePrs( aChildSObject->GetID().c_str() );
171
172     if ( isVTK )
173     {
174       SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
175       if ( !vtkVW )
176         return;
177       SVTK_View* aView = vtkVW->getView();
178       SUIT_OverrideCursor();
179       for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
180         aView->SetColor( It.Value(), c );
181     }
182     else if ( isOCC )
183     {
184       OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
185       Handle(AIS_InteractiveContext) ic = vm->getAISContext();
186
187       SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
188       if( !anOCCPrs )
189         continue;
190
191       AIS_ListOfInteractive aList;
192       anOCCPrs->GetObjects( aList );
193       if( !aList.Extent() )
194         continue;
195
196       Handle(AIS_InteractiveObject) io = aList.First();
197       if( io.IsNull() )
198         continue;
199
200       Quantity_Color aQuanColor( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
201
202       // Set color for a point
203       Handle(AIS_Drawer) aCurDrawer = io->Attributes();
204       Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
205       Quantity_Color aCurColor;
206       Standard_Real aCurScale;
207       Aspect_TypeOfMarker aCurTypeOfMarker;
208       aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
209       if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
210         aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aQuanColor, aCurScale) );
211       }
212       else {
213         Standard_Integer aWidth, aHeight;
214         aCurPointAspect->GetTextureSize( aWidth, aHeight );
215
216 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
217         Handle(TColStd_HArray1OfByte) aTexture = aCurPointAspect->GetTexture();
218 #else
219         Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
220 #endif
221
222         aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aQuanColor, 1, aWidth, aHeight, aTexture ) );
223       }
224       ic->SetLocalAttributes( io, aCurDrawer );
225
226       io->SetColor( aQuanColor );
227       if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
228         Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
229         aGAISShape->SetShadingColor( aQuanColor );
230         aGAISShape->storeBoundaryColors();
231       }
232
233       io->Redisplay( Standard_True );
234     }
235   }
236
237   app->updateActions(); //SRN: To update a Save button in the toolbar
238 }
239
240 void GEOMToolsGUI::OnDisableAutoColor()
241 {
242   SALOME_ListIO selected;
243   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
244   if( !app )
245     return;
246
247   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
248   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
249   if( !aSelMgr || !appStudy )
250     return;
251
252   aSelMgr->selectedObjects( selected );
253   if( selected.IsEmpty() )
254     return;
255
256   Handle(SALOME_InteractiveObject) anIObject = selected.First();
257
258   _PTR(Study) aStudy = appStudy->studyDS();
259   _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
260   GEOM::GEOM_Object_var aMainObject =  GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
261   if( CORBA::is_nil( aMainObject ) )
262     return;
263
264   aMainObject->SetAutoColor( false );
265
266 }
267
268 void GEOMToolsGUI::OnColor()
269 {
270   SALOME_ListIO selected;
271   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
272   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
273   if ( app && appStudy ) {
274     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
275     if ( aSelMgr ) {
276       aSelMgr->selectedObjects( selected );
277       if ( !selected.IsEmpty() ) {
278         SUIT_ViewWindow* window = app->desktop()->activeWindow();
279         bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
280         bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
281         int mgrId = window->getViewManager()->getGlobalId();
282         if ( isVTK ) {
283           SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
284           if ( !vtkVW )
285             return;
286           SVTK_View* aView = vtkVW->getView();
287           QColor initcolor = aView->GetColor( selected.First()  );
288           QColor c = QColorDialog::getColor( initcolor, app->desktop() );
289           if ( c.isValid() ) {
290             SUIT_OverrideCursor();
291             for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
292               aView->SetColor( It.Value(), c );
293               appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c);
294             }
295             GeometryGUI::Modified();
296           }
297         } // if ( isVTK )
298         else if ( isOCC ) {
299           Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
300           if ( !io.IsNull() ) {
301             Quantity_Color aColor;
302             io->Color( aColor );
303             QColor initcolor ((int)( aColor.Red() * 255.0 ),
304                               (int)( aColor.Green() * 255.0 ),
305                               (int)( aColor.Blue() * 255.0 ));
306             QColor c =  QColorDialog::getColor( initcolor, app->desktop() );
307             if ( c.isValid() ) {
308               SUIT_OverrideCursor();
309               aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
310               OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
311               Handle (AIS_InteractiveContext) ic = vm->getAISContext();
312               for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
313                 io = GEOMBase::GetAIS( It.Value(), true );
314                 if ( !io.IsNull() ) {
315                   
316                   if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) {
317                     TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
318                     bool onlyVertex = (theShape.ShapeType() == TopAbs_VERTEX || GEOM_Displayer::isCompoundOfVertices( theShape ));
319                     if (onlyVertex) {
320                       // Set color for a point
321
322                       Handle(AIS_Drawer) aCurDrawer = io->Attributes();
323                       Handle(Prs3d_PointAspect) aCurPointAspect =  aCurDrawer->PointAspect();
324                       Quantity_Color aCurColor;
325                       Standard_Real aCurScale;
326                       Aspect_TypeOfMarker aCurTypeOfMarker;
327                       aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
328                       if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
329                         aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aCurTypeOfMarker, aColor, aCurScale));
330                       }
331                       else {
332                         Standard_Integer aWidth, aHeight;
333                         aCurPointAspect->GetTextureSize( aWidth, aHeight );
334
335 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
336                         Handle(TColStd_HArray1OfByte) aTexture = aCurPointAspect->GetTexture();
337 #else
338                         Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
339 #endif
340
341                         aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aColor, 1, aWidth, aHeight, aTexture));
342                       }
343                       ic->SetLocalAttributes(io, aCurDrawer, Standard_False);
344                     }
345                   }
346
347                   io->SetColor( aColor );
348                   if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
349                     Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
350                     aGAISShape->SetShadingColor( aColor );
351                     aGAISShape->storeBoundaryColors();
352                   }
353
354                   appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c);
355
356                   io->Redisplay( Standard_True );
357
358                   // store color to GEOM_Object
359                   _PTR(Study) aStudy = appStudy->studyDS();
360                   _PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) );
361                   GEOM::GEOM_Object_var anObject =
362                     GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
363
364
365                   SALOMEDS::Color aSColor;
366                   aSColor.R = (double)c.red() / 255.0;
367                   aSColor.G = (double)c.green() / 255.0;
368                   aSColor.B = (double)c.blue() / 255.0;
369                   anObject->SetColor( aSColor );
370                   anObject->SetAutoColor( false );
371                 }
372               } // for
373               ic->UpdateCurrentViewer();
374               GeometryGUI::Modified();
375             } // if c.isValid()
376           } // first IO is not null
377         } // if ( isOCC )
378       } // if ( selection not empty )
379     }
380   }
381
382   app->updateActions(); //SRN: To update a Save button in the toolbar
383 }
384
385 void GEOMToolsGUI::OnTexture()
386 {
387   SALOME_ListIO selected;
388   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
389   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
390   if ( app && appStudy ) {
391     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
392     if ( aSelMgr ) {
393       aSelMgr->selectedObjects( selected );
394       if ( !selected.IsEmpty() ) {
395         SUIT_ViewWindow* window = app->desktop()->activeWindow();
396         bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
397         if ( isOCC ) {
398           QString aTexture = QFileDialog::getOpenFileName(window,tr( "GEOM_SELECT_IMAGE"),QString(), tr("OCC_IMAGE_FILES"));
399           if( !aTexture.isEmpty() )
400           {
401             SUIT_OverrideCursor();
402             OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
403             Handle (AIS_InteractiveContext) ic = vm->getAISContext();
404             Handle(AIS_InteractiveObject) io ;
405             for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
406               io = GEOMBase::GetAIS( It.Value(), true );
407               if ( !io.IsNull() ) {
408                 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
409                   Handle(GEOM_AISShape)::DownCast( io )->SetTextureFileName(TCollection_AsciiString(aTexture.toStdString().c_str()));
410                 io->Redisplay( Standard_True );
411               } // if ( !io.IsNull() )
412             } // for
413             ic->UpdateCurrentViewer();
414             GeometryGUI::Modified();
415             GeometryGUI* myGeomGUI = getGeometryGUI();
416             myGeomGUI->OnGUIEvent(GEOMOp::OpTexture);
417           } // if ( !selFile.isEmpty() )
418         } // if ( isOCC )
419       } // if ( selection not empty )
420     }
421   }
422
423   app->updateActions(); //SRN: To update a Save button in the toolbar
424 }
425
426 void GEOMToolsGUI::OnTransparency()
427 {
428   GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
429   dlg.exec();
430 }
431
432 void GEOMToolsGUI::OnChangeTransparency( bool increase )
433 {
434  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
435   if ( !app )
436     return;
437   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
438   if ( !aSelMgr )
439     return;
440   SALOME_ListIO selected;
441   aSelMgr->selectedObjects( selected );
442   if ( selected.IsEmpty() )
443     return;
444
445   Handle(SALOME_InteractiveObject) FirstIOS =  selected.First();
446   if ( FirstIOS.IsNull() )
447     return;
448
449   // Delta
450   float delta = 0.1; // VSR: 23/11/2010 (transparency value <= 0.05 is ignored)
451   if ( !increase )
452     delta *= -1;
453         
454   SUIT_ViewWindow* window = app->desktop()->activeWindow();
455   bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
456   bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
457
458   if ( isVTK ) {
459     SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
460     if ( !vtkVW )
461       return;
462     SVTK_View* aView = vtkVW->getView();
463    
464     float transp = aView->GetTransparency(FirstIOS);
465     
466     // Compute new transparency value
467     transp = transp + delta;
468     if ( transp < 0 )
469       transp = 0;
470     else if ( transp > 1 )
471       transp = 1;
472
473     for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
474       aView->SetTransparency( It.Value(), transp );
475     }
476     aView->Repaint();
477     GeometryGUI::Modified();
478   } // if ( isVTK )
479         
480   else if ( isOCC ) {
481     GEOMBase* gb = new GEOMBase();
482     Handle(GEOM_AISShape) aisShape;
483    
484     aisShape = gb->ConvertIOinGEOMAISShape( FirstIOS, true );
485     if( aisShape.IsNull() )
486       return;
487     float transp = aisShape->Transparency();
488
489     // Compute new transparency value
490     transp = transp + delta;
491     if ( transp < 0 )
492       transp = 0;
493     else if ( transp > 1 )
494       transp = 1;
495
496     OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
497     if ( !vm )
498       return;
499     Handle(AIS_InteractiveContext) ic = vm->getAISContext();
500     for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
501       aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
502       if ( !aisShape.IsNull() ) {
503         ic->SetTransparency( aisShape, transp, false );
504         ic->Redisplay( aisShape, Standard_False, Standard_True );
505       }
506     } // for...
507     ic->UpdateCurrentViewer();
508     GeometryGUI::Modified();
509   } // if ( isOCC )
510 }
511
512 void GEOMToolsGUI::OnNbIsos( ActionType actionType )
513 {
514   SalomeApp_Application* app =
515     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
516   SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
517   SUIT_ViewWindow* window = app->desktop()->activeWindow();
518
519   bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
520   bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
521
522   if(isOCC){ // if is OCCViewer
523
524     OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
525     Handle (AIS_InteractiveContext) ic = vm->getAISContext();
526
527     ic->InitCurrent();
528     if ( ic->MoreCurrent() ) {
529       Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
530       CurObject->restoreIsoNumbers();
531       Handle(AIS_Drawer)    CurDrawer = CurObject->Attributes();
532
533       int UIso = CurDrawer->UIsoAspect()->Number();
534       int VIso = CurDrawer->VIsoAspect()->Number();
535
536       int newNbUIso = -1;
537       int newNbVIso = -1;
538
539       if ( actionType == SHOWDLG ) {
540         GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
541           new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
542
543         NbIsosDlg->setU( UIso );
544         NbIsosDlg->setV( VIso );
545
546         if ( NbIsosDlg->exec() ) {
547           SUIT_OverrideCursor();
548           
549           newNbUIso = NbIsosDlg->getU();
550           newNbVIso = NbIsosDlg->getV();
551         } else //Cancel case
552           return;
553       }
554       else if ( actionType == INCR || actionType == DECR ) {
555         int delta = 1;
556         if (actionType == DECR)
557           delta = -1;
558         
559         newNbUIso = UIso + delta;
560         newNbVIso = VIso + delta;
561
562         if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
563           return;
564       }
565
566       for(; ic->MoreCurrent(); ic->NextCurrent()) {
567         int aMgrId = window->getViewManager()->getGlobalId();
568         CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
569
570         Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
571
572         QVariant v = aStudy->getObjectProperty( aMgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP , QVariant() );
573         
574         int width = v.isValid() ? v.toInt() : 1;
575
576         CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width , newNbUIso) );
577         CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width , newNbVIso) );
578
579         CurObject->storeIsoNumbers();
580         
581         ic->SetLocalAttributes(CurObject, CurDrawer);
582         ic->Redisplay(CurObject);
583
584         QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
585         aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_WIDTH_PROP, anIsos);
586       }
587     }
588     GeometryGUI::Modified();
589   }
590   else if(isVTK){ // if is VTKViewer
591     //
592     // Warning. It's works incorrect. must be recheked.
593     //
594     SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >
595       ( SUIT_Session::session()->activeApplication() );
596     if ( !app )
597       return;
598     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
599     if ( !aSelMgr )
600       return;
601     SALOME_ListIO selected;
602     aSelMgr->selectedObjects( selected );
603     if ( selected.IsEmpty() )
604       return;
605
606     SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
607     if ( !vtkVW )
608       return;
609
610     SALOME_View* view = GEOM_Displayer::GetActiveView();
611
612     vtkActorCollection* aCollection = vtkActorCollection::New();
613
614     for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
615       Handle(SALOME_InteractiveObject) anIObject = It.Value();
616       SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() );
617       SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aPrs );
618       if ( vtkPrs ) {
619         vtkActorCollection* anActors = vtkPrs->GetObjects();
620         anActors->InitTraversal();
621         vtkActor* anAct = anActors->GetNextActor();
622         aCollection->AddItem(anAct);
623       }
624     }
625
626     if(aCollection)
627       aCollection->InitTraversal();
628     else
629       return;
630
631     int UIso = 0;
632     int VIso = 0;
633
634     vtkActor* anAct = aCollection->GetNextActor();
635     if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
636       anActor->RestoreIsoNumbers();
637       anActor->GetNbIsos(UIso,VIso);
638     }
639     else
640       return;
641     
642     int newNbUIso = -1;
643     int newNbVIso = -1;
644
645     if ( actionType == SHOWDLG ) {
646       GEOMToolsGUI_NbIsosDlg* NbIsosDlg =
647         new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
648
649       NbIsosDlg->setU( UIso );
650       NbIsosDlg->setV( VIso );
651
652       if ( NbIsosDlg->exec() ) {
653         SUIT_OverrideCursor();
654
655         newNbUIso = NbIsosDlg->getU();
656         newNbVIso = NbIsosDlg->getV();
657       } else 
658         return; //Cancel case 
659     }
660     else if ( actionType == INCR || actionType == DECR ) {
661       int delta = 1;
662       if (actionType == DECR)
663         delta = -1;
664       
665       newNbUIso = UIso + delta;
666       newNbVIso = VIso + delta;
667       
668       if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
669         return;
670     } 
671     
672     while( anAct!=NULL ) {
673       if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){
674         // There are no casting to needed actor.
675         int aIsos[2]={newNbUIso,newNbVIso};
676         anActor->SetNbIsos(aIsos);
677         anActor->StoreIsoNumbers();
678
679         QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
680         int aMgrId = window->getViewManager()->getGlobalId();
681         aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_PROP, anIsos);
682       }
683       anAct = aCollection->GetNextActor();
684     }
685     view->Repaint();
686     GeometryGUI::Modified();
687   } // end vtkviewer
688 }
689
690 void GEOMToolsGUI::OnDeflection()
691 {
692   SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
693   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
694
695
696   bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
697   bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
698   int mgrId = window->getViewManager()->getGlobalId();
699
700   if (isOCC) { // if is OCCViewer
701     OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
702     Handle (AIS_InteractiveContext) ic = vm->getAISContext();
703
704     ic->InitCurrent();
705     if (ic->MoreCurrent()) {
706       Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
707
708       Standard_Real aDC, aPrevDC;
709       Standard_Boolean isOwnDC = CurObject->OwnDeviationCoefficient(aDC, aPrevDC);
710       if (!isOwnDC)
711         aDC = ic->DeviationCoefficient();
712
713       GEOMToolsGUI_DeflectionDlg * DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
714         (SUIT_Session::session()->activeApplication()->desktop());
715       DeflectionDlg->setTheDC(aDC);
716       double aNewDC = 0.0;
717       bool ok = false;
718       while (!ok) {
719         if (DeflectionDlg->exec()) {
720           SUIT_OverrideCursor();
721           aNewDC = DeflectionDlg->getTheDC();
722           ok = (1e-07 <= aNewDC && aNewDC <= 1.0); // spinbox can return zero
723           if (ok) {
724             for (; ic->MoreCurrent(); ic->NextCurrent()) {
725               CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
726               ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True);
727               ic->Redisplay(CurObject);
728               appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aNewDC);
729             }
730           }
731         }
732         else {
733           ok = true;
734         }
735       }
736     }
737     GeometryGUI::Modified();
738   }
739   else if (isVTK) { // if is VTKViewer
740     SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
741       (SUIT_Session::session()->activeApplication());
742     if (!app)
743       return;
744
745     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
746     if (!aSelMgr)
747       return;
748
749     SALOME_ListIO selected;
750     aSelMgr->selectedObjects(selected);
751     if (selected.IsEmpty())
752       return;
753
754     SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>(window);
755     if (!vtkVW)
756       return;
757
758     SALOME_View* view = GEOM_Displayer::GetActiveView();
759
760     vtkActorCollection* aCollection = vtkActorCollection::New();
761
762     for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) {
763       Handle(SALOME_InteractiveObject) anIObject = It.Value();
764       SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry());
765       SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>(aPrs);
766       if (vtkPrs) {
767         vtkActorCollection* anActors = vtkPrs->GetObjects();
768         anActors->InitTraversal();
769         vtkActor* anAct = anActors->GetNextActor();
770         aCollection->AddItem(anAct);
771       }
772     }
773
774     if (aCollection)
775       aCollection->InitTraversal();
776     else
777       return;
778
779     double aDC = 0.;
780
781     vtkActor* anAct = aCollection->GetNextActor();
782     if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
783       aDC = anActor->GetDeflection();
784     else
785       return;
786
787     GEOMToolsGUI_DeflectionDlg* DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
788       (SUIT_Session::session()->activeApplication()->desktop());
789     DeflectionDlg->setTheDC(aDC);
790     if (DeflectionDlg->exec()) {
791       SUIT_OverrideCursor();
792       aDC = DeflectionDlg->getTheDC();
793       while (anAct != NULL) {
794         if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
795           // There are no casting to needed actor.
796           anActor->SetDeflection(aDC);
797           appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC);
798         }
799         anAct = aCollection->GetNextActor();
800       }
801     }
802     GeometryGUI::Modified();
803   } // end vtkviewer
804 }
805
806 void GEOMToolsGUI::OnSelectOnly(int mode)
807 {
808   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
809   if ( app ) {
810     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
811     GEOM_Displayer aDisp (appStudy);
812     aDisp.GlobalSelection(mode);
813     getGeometryGUI()->setLocalSelectionMode(mode);
814   }
815 }
816
817 void GEOMToolsGUI::OnShowHideChildren( bool show )
818 {
819   SALOME_ListIO selected;
820   SalomeApp_Application* app =
821     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
822   
823   SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
824   
825   GEOM_Displayer* disp  = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
826
827   if ( app && disp ) {
828     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
829     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
830     if ( aSelMgr && appStudy ) {
831       aSelMgr->selectedObjects( selected );
832       if ( !selected.IsEmpty() ) {
833         _PTR(Study) aStudy = appStudy->studyDS();
834         _PTR(StudyBuilder) B = aStudy->NewBuilder();
835
836         bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
837         if ( aLocked ) {
838           SUIT_MessageBox::warning( app->desktop(),
839                                     QObject::tr( "WRN_WARNING" ),
840                                     QObject::tr( "WRN_STUDY_LOCKED" ) );
841           return;
842         }
843
844         for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
845           Handle(SALOME_InteractiveObject) IObject = It.Value();
846
847           _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
848           _PTR(GenericAttribute) anAttr;
849           if ( obj ) {
850             _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
851             aExp->SetExpandable( show );
852             if(!show)
853               disp->EraseWithChildren(IObject,true);
854           } // if ( obj )
855         } // iterator
856       }
857     }
858     app->updateObjectBrowser( false );
859     app->updateActions();
860   }
861 }
862
863 void GEOMToolsGUI::OnPointMarker()
864 {
865   GEOMToolsGUI_MarkerDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
866   dlg.exec();
867 }
868
869 void GEOMToolsGUI::OnMaterialProperties()
870 {
871   GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
872   dlg.exec();
873 }
874
875 void GEOMToolsGUI::OnUnpublishObject() {
876   SALOME_ListIO selected;
877   SalomeApp_Application* app =
878     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
879
880   SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
881
882   GEOM_Displayer* disp  = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
883   
884   if ( app && disp ) {
885     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
886     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
887     if ( aSelMgr && appStudy ) {
888       aSelMgr->selectedObjects( selected );
889       if ( !selected.IsEmpty() ) {
890         _PTR(Study) aStudy = appStudy->studyDS();
891         _PTR(StudyBuilder) B = aStudy->NewBuilder();
892
893         bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
894         if ( aLocked ) {
895           SUIT_MessageBox::warning( app->desktop(),
896                                     QObject::tr( "WRN_WARNING" ),
897                                     QObject::tr( "WRN_STUDY_LOCKED" ) );
898           return;
899         }
900
901         for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
902           Handle(SALOME_InteractiveObject) IObject = It.Value();
903
904           _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
905           _PTR(GenericAttribute) anAttr;
906           if ( obj ) {
907             _PTR(AttributeDrawable) aDrw = B->FindOrCreateAttribute( obj, "AttributeDrawable" );
908             aDrw->SetDrawable( false );
909             disp->EraseWithChildren(IObject);
910           } // if ( obj )
911         } // iterator
912         aSelMgr->clearSelected();
913       }
914     }
915     app->updateObjectBrowser( false );
916     app->updateActions();
917   }
918  
919 }
920
921 void GEOMToolsGUI::OnPublishObject() {
922   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
923   if(!app)
924     return;
925
926   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
927   if(!appStudy)
928     return;
929   
930   _PTR(Study) aStudy = appStudy->studyDS();
931   
932   if(!aStudy)
933     return;
934
935   //Check lock of the study
936   bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
937   if ( aLocked ) {
938     SUIT_MessageBox::warning( app->desktop(),
939                               QObject::tr( "WRN_WARNING" ),
940                               QObject::tr( "WRN_STUDY_LOCKED" ) );
941     return;
942   } 
943   
944   GEOMToolsGUI_PublishDlg * publishDlg =
945     new GEOMToolsGUI_PublishDlg( SUIT_Session::session()->activeApplication()->desktop() );
946   publishDlg->exec();
947 }
948
949
950 void GEOMToolsGUI::OnEdgeWidth()
951 {
952   SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
953   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
954
955
956   bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
957   bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
958   int mgrId = window->getViewManager()->getGlobalId();
959
960   if (isOCC) { // if is OCCViewer
961     OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
962     Handle (AIS_InteractiveContext) ic = vm->getAISContext();
963     ic->InitCurrent();
964     if (ic->MoreCurrent()) {
965       Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
966
967       int aWidth = (int)CurObject->Width();
968
969       GEOMToolsGUI_LineWidthDlg * Dlg = new GEOMToolsGUI_LineWidthDlg
970         (SUIT_Session::session()->activeApplication()->desktop(),"EDGE_WIDTH_TLT");
971       Dlg->setTheLW(aWidth);
972       int aNewWidth = 0;
973       if (Dlg->exec()) {
974         aNewWidth = Dlg->getTheLW();
975         bool ok = (aNewWidth != aWidth && aNewWidth != 0 );
976         if (ok) {
977           for(; ic->MoreCurrent(); ic->NextCurrent()) {
978             CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
979             CurObject->SetWidth(aNewWidth);
980             ic->Redisplay(CurObject);
981             appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP, aNewWidth);
982           }
983         }
984       }
985     }
986     else {
987       return;
988     }
989     GeometryGUI::Modified();
990   }
991   else if (isVTK) { // if is VTKViewer
992     SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
993       (SUIT_Session::session()->activeApplication());
994     if (!app)
995       return;
996
997     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
998     if (!aSelMgr)
999       return;
1000
1001     SALOME_ListIO selected;
1002     aSelMgr->selectedObjects(selected);
1003     if (selected.IsEmpty())
1004       return;
1005
1006     SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>(window);
1007     if (!vtkVW)
1008       return;
1009
1010     SALOME_View* view = GEOM_Displayer::GetActiveView();
1011
1012     vtkActorCollection* aCollection = vtkActorCollection::New();
1013
1014     for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) {
1015       Handle(SALOME_InteractiveObject) anIObject = It.Value();
1016       SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry());
1017       SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>(aPrs);
1018       if (vtkPrs) {
1019         vtkActorCollection* anActors = vtkPrs->GetObjects();
1020         anActors->InitTraversal();
1021         vtkActor* anAct = anActors->GetNextActor();
1022         aCollection->AddItem(anAct);
1023       }
1024     }
1025
1026     if (aCollection)
1027       aCollection->InitTraversal();
1028     else
1029       return;
1030
1031     int aWidth = 1;
1032
1033     vtkActor* anAct = aCollection->GetNextActor();
1034     if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
1035       aWidth = anActor->GetWidth();
1036     else
1037       return;
1038
1039     GEOMToolsGUI_LineWidthDlg * Dlg = new GEOMToolsGUI_LineWidthDlg
1040       (SUIT_Session::session()->activeApplication()->desktop(),"EDGE_WIDTH_TLT");
1041     
1042     Dlg->setTheLW(aWidth);
1043     if (Dlg->exec()) {
1044       SUIT_OverrideCursor();
1045       aWidth = Dlg->getTheLW();
1046       while (anAct != NULL) {
1047         if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
1048           // There are no casting to needed actor.
1049           anActor->SetWidth(aWidth);
1050           appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), EDGE_WIDTH_PROP, aWidth);
1051         }
1052         anAct = aCollection->GetNextActor();
1053       }
1054     }
1055     GeometryGUI::Modified();
1056   } // end vtkviewer
1057 }
1058
1059
1060 void GEOMToolsGUI::OnIsosWidth() {
1061   SalomeApp_Application* app =
1062     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1063   SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1064   SUIT_ViewWindow* window = app->desktop()->activeWindow();
1065
1066   bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1067   bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
1068
1069   if(isOCC){ // if is OCCViewer
1070
1071     OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
1072     Handle (AIS_InteractiveContext) ic = vm->getAISContext();
1073
1074     ic->InitCurrent();
1075     if ( ic->MoreCurrent() ) {
1076       Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
1077       CurObject->restoreIsoNumbers();
1078       Handle(AIS_Drawer)    CurDrawer = CurObject->Attributes();
1079
1080       Handle(Graphic3d_AspectLine3d) asp = CurDrawer->UIsoAspect()->Aspect();
1081       
1082       Quantity_Color C;
1083       Aspect_TypeOfLine T;
1084       Standard_Real W;
1085       asp->Values(C,T,W);
1086
1087       int aWidth = (int)W;
1088
1089       GEOMToolsGUI_LineWidthDlg * Dlg =
1090         new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(),"ISOS_WIDTH_TLT" );
1091
1092       Dlg->setTheLW( aWidth );
1093
1094       if ( Dlg->exec() ) {
1095         SUIT_OverrideCursor();          
1096         aWidth = Dlg->getTheLW();
1097       } else //Cancel case
1098         return;
1099       
1100       for(; ic->MoreCurrent(); ic->NextCurrent()) {
1101         int aMgrId = window->getViewManager()->getGlobalId();
1102         CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
1103         
1104         Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
1105         
1106         CurObject->Attributes()->UIsoAspect()->SetWidth(aWidth);
1107         CurObject->Attributes()->VIsoAspect()->SetWidth(aWidth);
1108         
1109         ic->Redisplay(CurObject);
1110         
1111         aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth);
1112       }
1113       GeometryGUI::Modified();
1114     }
1115   }
1116   else if(isVTK){ // if is VTKViewer
1117     //
1118     // Warning. It's works incorrect. must be recheked.
1119     //
1120     SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >
1121       ( SUIT_Session::session()->activeApplication() );
1122     if ( !app )
1123       return;
1124     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
1125     if ( !aSelMgr )
1126       return;
1127     SALOME_ListIO selected;
1128     aSelMgr->selectedObjects( selected );
1129     if ( selected.IsEmpty() )
1130       return;
1131
1132     SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
1133     if ( !vtkVW )
1134       return;
1135
1136     SALOME_View* view = GEOM_Displayer::GetActiveView();
1137
1138     vtkActorCollection* aCollection = vtkActorCollection::New();
1139
1140     for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
1141       Handle(SALOME_InteractiveObject) anIObject = It.Value();
1142       SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() );
1143       SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aPrs );
1144       if ( vtkPrs ) {
1145         vtkActorCollection* anActors = vtkPrs->GetObjects();
1146         anActors->InitTraversal();
1147         vtkActor* anAct = anActors->GetNextActor();
1148         aCollection->AddItem(anAct);
1149       }
1150     }
1151
1152     if(aCollection)
1153       aCollection->InitTraversal();
1154     else
1155       return;
1156
1157     int aWidth = 1;
1158
1159     vtkActor* anAct = aCollection->GetNextActor();
1160     if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
1161       aWidth = anActor->GetIsosWidth();
1162     }
1163     else
1164       return;
1165     
1166     GEOMToolsGUI_LineWidthDlg* Dlg =
1167       new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(), "ISOS_WIDTH_TLT" );
1168     
1169     Dlg->setTheLW( aWidth );
1170     if (Dlg->exec() ) {
1171       SUIT_OverrideCursor();
1172       aWidth = Dlg->getTheLW();
1173     } else 
1174       return; //Cancel case 
1175     
1176     while( anAct!= NULL ) {
1177       if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
1178         // There are no casting to needed actor.
1179         anActor->SetIsosWidth(aWidth);
1180         int aMgrId = window->getViewManager()->getGlobalId();
1181         aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth);
1182       }
1183       anAct = aCollection->GetNextActor();
1184     }
1185     
1186     view->Repaint();
1187     GeometryGUI::Modified();
1188   } // end vtkviewer  
1189 }