Salome HOME
2b117e65515c8a458399bb94a4b6ff9c5e49397b
[modules/geom.git] / src / DisplayGUI / DisplayGUI.cxx
1 // Copyright (C) 2007-2023  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, or (at your option) any later version.
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 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : DisplayGUI.cxx
25 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
26
27 #include "DisplayGUI.h"
28 #include <GeometryGUI.h>
29 #include "GeometryGUI_Operations.h"
30 #include <GEOM_Constants.h>
31 #include <GEOM_Displayer.h>
32 #include <GEOM_AISShape.hxx>
33 #include <GEOM_Actor.h>
34
35 #include <SUIT_Desktop.h>
36 #include <SUIT_ViewWindow.h>
37 #include <SUIT_OverrideCursor.h>
38
39 #include <OCCViewer_ViewManager.h>
40 #include <OCCViewer_ViewModel.h>
41
42 #include <SALOME_ListIO.hxx>
43
44 #include <SVTK_ViewWindow.h>
45 #include <SVTK_View.h>
46 #include <SVTK_ViewModel.h>
47 #include <SOCC_ViewModel.h>
48 #include <SVTK_Prs.h>
49 #include <SOCC_Prs.h>
50
51 #include <QtxActionMenuMgr.h>
52
53 #include <SalomeApp_Application.h>
54 #include <LightApp_SelectionMgr.h>
55 #include <SalomeApp_Study.h>
56
57 #include <AIS_ListIteratorOfListOfInteractive.hxx>
58
59 #include <vtkActorCollection.h>
60 #include <vtkRenderer.h>
61
62 #include <QAction>
63
64 //=======================================================================
65 // function : DisplayGUI::DisplayGUI()
66 // purpose  : Constructor
67 //=======================================================================
68 DisplayGUI::DisplayGUI( GeometryGUI* parent ) : GEOMGUI( parent )
69 {
70 }
71
72 //=======================================================================
73 // function : DisplayGUI::~DisplayGUI()
74 // purpose  : Destructor
75 //=======================================================================
76 DisplayGUI::~DisplayGUI()
77 {
78 }
79
80
81 //=======================================================================
82 // function : DisplayGUI::OnGUIEvent()
83 // purpose  : Dispatch menu command
84 //=======================================================================
85 bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* /*parent*/)
86 {
87   SalomeApp_Application* app = getGeometryGUI()->getApp();
88   if (!app) return false;
89
90   LightApp_SelectionMgr *Sel = app->selectionMgr();
91   SALOME_ListIO selected;
92   Sel->selectedObjects( selected );
93
94   switch ( theCommandID ) {
95   case GEOMOp::OpDMWireframe:         // MENU VIEW - DISPLAY MODE - WIREFRAME
96     SetDisplayMode( 0 );
97     break;
98   case GEOMOp::OpDMShading:           // MENU VIEW - DISPLAY MODE - SHADING
99     SetDisplayMode( 1 );
100     break;
101   case GEOMOp::OpDMShadingWithEdges:  // MENU VIEW - DISPLAY MODE - SHADING WITH EDGES
102     SetDisplayMode( 2 );
103     break;
104   case GEOMOp::OpDMTexture:           // MENU VIEW - DISPLAY MODE - TEXTURE
105     SetDisplayMode( 3 );
106     break;
107   case GEOMOp::OpShowAll:        // MENU VIEW - SHOW ALL
108     getGeometryGUI()->EmitSignalDeactivateDialog();
109     DisplayAll();
110     break;
111   case GEOMOp::OpShowOnly:       // POPUP MENU - SHOW ONLY
112     getGeometryGUI()->EmitSignalDeactivateDialog();
113     DisplayOnly();
114     break;
115   case GEOMOp::OpShowOnlyChildren: // POPUP MENU - SHOW ONLY CHILDREN
116     getGeometryGUI()->EmitSignalDeactivateDialog();
117     DisplayOnlyChildren();
118     break;
119   case GEOMOp::OpHideAll:        // MENU VIEW - HIDE ALL
120     EraseAll();
121     break;
122   case GEOMOp::OpHide:           // POPUP MENU - HIDE
123     Erase();
124     break;
125   case GEOMOp::OpShow:           // POPUP MENU - SHOW
126     getGeometryGUI()->EmitSignalDeactivateDialog();
127     Display();
128     break;
129   case GEOMOp::OpSwitchVectors:  // MENU VIEW - DISPLAY MODE - SHOW EDGE DIRECTION
130     SetVectorMode(!GetVectorMode());
131     getGeometryGUI()->action( GEOMOp::OpSwitchVectors )->setText
132       ( GetVectorMode() ? tr("MEN_VECTOR_MODE_ON") : tr( "MEN_VECTOR_MODE_OFF" ) );
133     getGeometryGUI()->menuMgr()->update();
134     break;
135   case GEOMOp::OpSwitchVertices:  // MENU VIEW - DISPLAY MODE - SHOW/HIDE VERTICES
136     SetVerticesMode(!GetVerticesMode());
137     getGeometryGUI()->action( GEOMOp::OpSwitchVertices )->setText
138       ( GetVerticesMode() ? tr("MEN_VERTICES_MODE_ON") : tr( "MEN_VERTICES_MODE_OFF" ) );
139     getGeometryGUI()->menuMgr()->update();
140     break;
141   case GEOMOp::OpSwitchName:  // MENU VIEW - DISPLAY MODE - SHOW/HIDE NAME
142     SetNameMode(!GetNameMode());
143     getGeometryGUI()->action( GEOMOp::OpSwitchName )->setText
144       ( GetNameMode() ? tr("MEN_NAME_MODE_ON") : tr( "MEN_NAME_MODE_OFF" ) );
145     getGeometryGUI()->menuMgr()->update();
146     break;
147   case GEOMOp::OpWireframe:      // POPUP MENU - DISPLAY MODE - WIREFRAME
148     ChangeDisplayMode( 0 );
149     break;
150   case GEOMOp::OpShading:        // POPUP MENU - DISPLAY MODE - SHADING
151     ChangeDisplayMode( 1 );
152     break;
153   case GEOMOp::OpShadingWithEdges: // POPUP MENU - DISPLAY MODE - SHADING WITH EDGES
154     ChangeDisplayMode( 2 );
155     break;
156   case GEOMOp::OpTexture:        // POPUP MENU - DISPLAY MODE - TEXTURE
157     ChangeDisplayMode( 3 );
158     break;
159   case GEOMOp::OpVectors:        // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION
160     ChangeDisplayMode( 4 );
161     break;
162   case GEOMOp::OpVertices:       // POPUP MENU - DISPLAY MODE - SHOW VERTICES
163     ChangeDisplayMode( 5 );
164     break;
165   case GEOMOp::OpShowName:       // POPUP MENU - DISPLAY MODE - SHOW NAME
166     ChangeDisplayMode( 6 );
167     break;
168   default:
169     app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
170     break;
171   }
172   Sel->setSelectedObjects( selected );
173   GEOM_Displayer().UpdateColorScale();
174   return true;
175 }
176
177 //=====================================================================================
178 // function : DisplayGUI::DisplayAll()
179 // purpose  : Display all GEOM objects
180 //=====================================================================================
181 void DisplayGUI::DisplayAll()
182 {
183   _PTR(Study) aStudy = SalomeApp_Application::getStudy();
184   if ( !aStudy ) return;
185   _PTR(SComponent) SC ( aStudy->FindComponent( "GEOM" ) );
186   if ( !SC )
187     return;
188
189   SALOME_ListIO listIO;
190   _PTR(ChildIterator) anIter ( aStudy->NewChildIterator( SC ) );
191   anIter->InitEx( true );
192
193   SUIT_OverrideCursor wc;
194
195   while( anIter->More() ) {
196     _PTR(SObject) valSO ( anIter->Value() );
197     _PTR(SObject) refSO;
198     if ( !valSO->ReferencedObject( refSO ) ) {
199       listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(),
200                                                   SC->ComponentDataType().c_str(),
201                                                   valSO->GetName().c_str()) );
202     } 
203     anIter->Next();
204   }
205   GEOM_Displayer().Display( listIO, true );
206 }
207
208 //=====================================================================================
209 // function : DisplayGUI::EraseAll()
210 // purpose  : Erase all GEOM objects
211 //=====================================================================================
212 void DisplayGUI::EraseAll()
213 {
214   SUIT_OverrideCursor wc;
215
216   SUIT_Application* app = getGeometryGUI()->getApp();
217   if ( app ) {
218     SUIT_ViewWindow* vw = app->desktop()->activeWindow();
219     if ( vw ) {
220       SUIT_ViewManager* vman = vw->getViewManager();
221       if ( vman->getType() == OCCViewer_Viewer::Type() || 
222            vman->getType() == SVTK_Viewer::Type() ) {
223         GEOM_Displayer().EraseAll(true);
224       }
225     }
226   }
227 }
228
229 //=====================================================================================
230 // function : DisplayGUI::DisplayOnly()
231 // purpose  : Display selected GEOM objects and erase other
232 //=====================================================================================
233 void DisplayGUI::DisplayOnly()
234 {
235   EraseAll();
236   Display();
237 }
238
239 //=====================================================================================
240 // function : DisplayGUI::DisplayOnlyChildren()
241 // purpose  : Display only children of selected GEOM objects and erase other
242 //=====================================================================================
243 void DisplayGUI::DisplayOnlyChildren()
244 {
245   EraseAll();
246
247   SALOME_ListIO listIO;
248
249   SalomeApp_Application* app = getGeometryGUI()->getApp();
250   if (!app) return;
251
252   SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
253   if (!aStudy) return;
254
255   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
256   if (!aSelMgr) return;
257
258   // get selection
259   SALOME_ListIO aList;
260   //aSelMgr->selectedObjects(aList);
261   aSelMgr->selectedObjects(aList, "ObjectBrowser", false);
262   SALOME_ListIteratorOfListIO It (aList);
263
264   SUIT_OverrideCursor wc;
265
266   for (; It.More(); It.Next()) {
267     Handle(SALOME_InteractiveObject) anIObject = It.Value();
268     if (anIObject->hasEntry()) {
269       _PTR(SObject) SO (aStudy->studyDS()->FindObjectID(anIObject->getEntry()));
270       if (SO) {
271         _PTR(SComponent) SC (SO->GetFatherComponent());
272         if (QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str())) {
273           // if component is selected, pass it
274         }
275         else {
276           _PTR(ChildIterator) anIter (aStudy->studyDS()->NewChildIterator(SO));
277           anIter->InitEx(true);
278           while (anIter->More()) {
279             _PTR(SObject) valSO (anIter->Value());
280             _PTR(SObject) refSO;
281             if (!valSO->ReferencedObject(refSO)) {
282               listIO.Append(new SALOME_InteractiveObject(valSO->GetID().c_str(),
283                                                          SC->ComponentDataType().c_str(),
284                                                          valSO->GetName().c_str()));
285             }
286             anIter->Next();
287           }
288         }
289       }
290     }
291   }
292   GEOM_Displayer().Display(listIO, true);
293 }
294
295 //=====================================================================================
296 // function : DisplayGUI::Display()
297 // purpose  : Display selected GEOM objects
298 //=====================================================================================
299 void DisplayGUI::Display()
300 {
301   SALOME_ListIO listIO;
302
303   SalomeApp_Application* app = getGeometryGUI()->getApp();
304   if ( !app ) return;
305
306   SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
307   if ( !aStudy ) return;
308
309   //get SalomeApp selection manager
310   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
311   if ( !aSelMgr ) return;
312
313   SALOME_ListIO aList;
314   aSelMgr->selectedObjects( aList );
315   SALOME_ListIteratorOfListIO It( aList );
316
317   SUIT_OverrideCursor wc;
318
319   for( ;It.More();It.Next() ) {
320     Handle(SALOME_InteractiveObject) anIObject = It.Value();
321     if ( anIObject->hasEntry() ) {
322       _PTR(SObject) SO ( aStudy->studyDS()->FindObjectID( anIObject->getEntry() ) );
323       if ( SO && QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str()) ) {
324         _PTR(SComponent) SC ( SO->GetFatherComponent() );
325         // if component is selected
326         listIO.Clear();
327         _PTR(ChildIterator) anIter ( aStudy->studyDS()->NewChildIterator( SO ) );
328         anIter->InitEx( true );
329         while( anIter->More() ) {
330           _PTR(SObject) valSO ( anIter->Value() );
331           _PTR(SObject) refSO;
332           if ( !valSO->ReferencedObject( refSO ) ) {
333             listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(),
334                                                         SC->ComponentDataType().c_str(),
335                                                         valSO->GetName().c_str()) );
336           }
337           anIter->Next();
338         }
339         break;
340       }
341       else {
342         listIO.Append( anIObject );
343       }
344     }
345     else {
346       listIO.Append( anIObject );
347     }
348   }
349   GEOM_Displayer().Display( listIO, true );
350 }
351
352
353 //=====================================================================================
354 // function : DisplayGUI::Erase()
355 // purpose  : Erase selected GEOM objects
356 //=====================================================================================
357 void DisplayGUI::Erase()
358 {
359   SALOME_ListIO listIO;
360
361   SalomeApp_Application* app = getGeometryGUI()->getApp();
362   if ( !app ) return;
363
364   SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
365   if ( !aStudy ) return;
366
367   //get SalomeApp selection manager
368   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
369   if ( !aSelMgr ) return;
370
371   SALOME_ListIO aList;
372   aSelMgr->selectedObjects( aList );
373   SALOME_ListIteratorOfListIO It( aList );
374
375   SUIT_OverrideCursor wc;
376
377   for( ; It.More(); It.Next() ) {
378     Handle(SALOME_InteractiveObject) anIObject = It.Value();
379     if ( anIObject->hasEntry() ) {
380       _PTR(SObject) SO ( aStudy->studyDS()->FindObjectID( anIObject->getEntry() ) );
381       if ( SO && QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str()) ) {
382         _PTR(SComponent) SC ( SO->GetFatherComponent() );
383         // if component is selected
384         listIO.Clear();
385         _PTR(ChildIterator) anIter ( aStudy->studyDS()->NewChildIterator( SO ) );
386         anIter->InitEx( true );
387         while( anIter->More() ) {
388           _PTR(SObject) valSO ( anIter->Value() );
389           _PTR(SObject) refSO;
390           if ( !valSO->ReferencedObject( refSO ) ) {
391             listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(),
392                                                         SC->ComponentDataType().c_str(),
393                                                         valSO->GetName().c_str()) );
394           }
395           anIter->Next();
396         }
397         break;
398       }
399       else {
400         listIO.Append( anIObject );
401       }
402     }
403     else {
404       listIO.Append( anIObject );
405     }
406   }
407
408   SUIT_ViewWindow* viewWindow = app->desktop()->activeWindow();
409   bool aIsForced = true;
410   if(viewWindow->getViewManager()->getType() == SVTK_Viewer::Type())
411     aIsForced = false;
412
413   GEOM_Displayer().Erase( listIO, aIsForced);
414   getGeometryGUI()->getApp()->selectionMgr()->clearSelected();
415 }
416
417 //=====================================================================================
418 // function : DisplayGUI::SetDisplayMode()
419 // purpose  : Set display mode for the viewer (current viewer if <viewWindow> - 0 )
420 //=====================================================================================
421 void DisplayGUI::SetDisplayMode( const int mode, SUIT_ViewWindow* viewWindow )
422 {
423   SUIT_OverrideCursor wc;
424
425   SalomeApp_Application* app = getGeometryGUI()->getApp();
426   if ( !app ) return;
427
428   if ( !viewWindow ) 
429     viewWindow = app->desktop()->activeWindow();
430
431   SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
432   if ( !aStudy ) return;
433
434   GEOM_Displayer displayer;
435
436   int mgrId = viewWindow->getViewManager()->getGlobalId();
437
438   SALOME_View* window = displayer.GetActiveView();
439   if ( !window ) return;
440
441   SALOME_ListIO anIOlst;
442   window->GetVisible( anIOlst );
443
444   for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
445     Handle( SALOME_InteractiveObject ) io = It.Value();
446     aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::DisplayMode ), mode );
447     displayer.Redisplay( io, false );
448   }
449   displayer.UpdateViewer();
450   GeometryGUI::Modified();
451 }
452
453 //=====================================================================================
454 // function : DisplayGUI::SetVectorsMode()
455 // purpose  : Set vector mode for the viewer
456 //=====================================================================================
457 void DisplayGUI::SetVectorMode( const bool mode, SUIT_ViewWindow* viewWindow )
458 {
459   SUIT_OverrideCursor wc;
460
461   SalomeApp_Application* app = getGeometryGUI()->getApp();
462   if ( !app ) return;
463
464   SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
465   if ( !aStudy ) return;
466
467   if ( !viewWindow ) 
468     viewWindow = app->desktop()->activeWindow();
469
470   GEOM_Displayer displayer;
471
472   viewWindow->setProperty( "VectorsMode", mode );
473
474   int aMgrId = viewWindow->getViewManager()->getGlobalId();
475
476   SALOME_View* window = displayer.GetActiveView();
477   if ( !window ) return;
478
479   SALOME_ListIO anIOlst;
480   window->GetVisible( anIOlst );
481
482   for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
483     Handle( SALOME_InteractiveObject ) io = It.Value();
484     aStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::EdgesDirection ), mode );
485     displayer.Redisplay( io, false );
486   }
487   displayer.UpdateViewer();
488   GeometryGUI::Modified();
489 }
490
491 //=====================================================================================
492 // function : DisplayGUI::GetVectorMode()
493 // purpose  : Get the "show edge direction" mode of the viewer
494 //=====================================================================================
495 int DisplayGUI::GetVectorMode( SUIT_ViewWindow* viewWindow )
496 {
497   if ( !viewWindow ) 
498     viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
499   return viewWindow->property( "VectorsMode" ).toBool();
500 }
501
502 //=====================================================================================
503 // function : DisplayGUI::SetVerticesMode()
504 // purpose  : Set vertices mode for the viewer
505 //=====================================================================================
506 void DisplayGUI::SetVerticesMode( const bool mode, SUIT_ViewWindow* viewWindow )
507 {
508   SUIT_OverrideCursor wc;
509
510   SalomeApp_Application* app = getGeometryGUI()->getApp();
511   if ( !app ) return;
512
513   SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
514   if ( !aStudy ) return;
515
516   if ( !viewWindow ) 
517     viewWindow = app->desktop()->activeWindow();
518
519   GEOM_Displayer displayer;
520
521   viewWindow->setProperty( "VerticesMode", mode );
522
523   int aMgrId = viewWindow->getViewManager()->getGlobalId();
524
525   SALOME_View* window = displayer.GetActiveView();
526   if ( !window ) return;
527
528   SALOME_ListIO anIOlst;
529   window->GetVisible( anIOlst );
530
531   for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
532     Handle( SALOME_InteractiveObject ) io = It.Value();
533     aStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::Vertices ), mode );
534     displayer.Redisplay( io, false );
535   }
536   displayer.UpdateViewer();
537   GeometryGUI::Modified();
538 }
539
540 //=====================================================================================
541 // function : DisplayGUI::GetVerticesMode()
542 // purpose  : Get the "show vertices" mode of the viewer
543 //=====================================================================================
544 int DisplayGUI::GetVerticesMode( SUIT_ViewWindow* viewWindow )
545 {
546   if ( !viewWindow ) 
547     viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
548   return viewWindow->property( "VerticesMode" ).toBool();
549 }
550
551 //=====================================================================================
552 // function : DisplayGUI::SetNameMode()
553 // purpose  : Set name mode for the viewer
554 //=====================================================================================
555 void DisplayGUI::SetNameMode( const bool mode, SUIT_ViewWindow* viewWindow )
556 {
557   SUIT_OverrideCursor();
558
559   SalomeApp_Application* app = getGeometryGUI()->getApp();
560   if ( !app ) return;
561
562   SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
563   if ( !aStudy ) return;
564
565   if ( !viewWindow )
566     viewWindow = app->desktop()->activeWindow();
567
568   viewWindow->setProperty( "NameMode", mode );
569
570   GEOM_Displayer displayer;
571
572   int aMgrId = viewWindow->getViewManager()->getGlobalId();
573
574   SALOME_View* window = displayer.GetActiveView();
575   if ( !window ) return;
576
577   SALOME_ListIO anIOlst;
578   window->GetVisible( anIOlst );
579
580   for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
581     Handle( SALOME_InteractiveObject ) io = It.Value();
582     aStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), mode );
583     displayer.Redisplay( io, false );
584   }
585   displayer.UpdateViewer();
586   GeometryGUI::Modified();
587 }
588
589 //=====================================================================================
590 // function : DisplayGUI::GetNameMode()
591 // purpose  : Get the "show name" mode of the viewer
592 //=====================================================================================
593 int DisplayGUI::GetNameMode( SUIT_ViewWindow* viewWindow )
594 {
595   if ( !viewWindow )
596     viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
597   return viewWindow->property( "NameMode" ).toBool();
598 }
599
600 //=====================================================================================
601 // function : DisplayGUI::ChangeDisplayMode()
602 // purpose  : Set display mode for selected objects in the viewer given
603 //            (current viewer if <viewWindow> = 0 )
604 //=====================================================================================
605 void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow )
606 {
607   SalomeApp_Application* app = getGeometryGUI()->getApp();
608   if ( !app ) return;
609
610   if ( !viewWindow ) 
611     viewWindow = app->desktop()->activeWindow();
612
613   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
614   if ( !aSelMgr ) return;
615
616   SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
617   if ( !aStudy ) return;
618
619   SUIT_OverrideCursor wc;
620
621   SALOME_ListIO selected;
622   aSelMgr->selectedObjects( selected );
623   if ( selected.IsEmpty() ) return;
624
625   GEOM_Displayer displayer;
626
627   int mgrId = viewWindow->getViewManager()->getGlobalId();
628
629   QVariant v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::EdgesDirection ), QVariant() );
630   bool vectorMode =  v.isValid() ? !v.toBool() : false;
631   v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Vertices ), QVariant() );
632   bool verticesMode =  v.isValid() ? !v.toBool() : false;
633   v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::ShowName ), QVariant() );
634   bool nameMode =  v.isValid() ? !v.toBool() : false;
635
636   for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
637     Handle( SALOME_InteractiveObject ) io = It.Value();
638     if ( mode == 0 || mode == 1 || mode == 2 || mode == 3 ) {
639       aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::DisplayMode ), mode );
640     }
641     else if ( mode == 4 ) {
642       aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::EdgesDirection ), vectorMode );
643     }
644     else if ( mode == 5 ) {
645       aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::Vertices ), verticesMode );
646     }
647     else if ( mode == 6 ) {
648       aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), nameMode );
649     }
650     displayer.Redisplay( io, false );
651   }
652   displayer.UpdateViewer();
653   GeometryGUI::Modified();
654 }
655
656 //=====================================================================================
657 // EXPORTED METHODS
658 //=====================================================================================
659 extern "C"
660 {
661 #ifdef WIN32
662   __declspec( dllexport )
663 #endif
664   GEOMGUI* GetLibGUI( GeometryGUI* parent )
665   {
666     return new DisplayGUI( parent );
667   }
668 }