Salome HOME
EDF 2281 : Add 2 primitives for hexa mesh
[modules/geom.git] / src / DisplayGUI / DisplayGUI.cxx
1 // Copyright (C) 2007-2012  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   : DisplayGUI.cxx
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25
26 #include "DisplayGUI.h"
27 #include <GeometryGUI.h>
28 #include "GeometryGUI_Operations.h"
29 #include <GEOM_Constants.h>
30 #include <GEOM_Displayer.h>
31 #include <GEOM_AISShape.hxx>
32 #include <GEOM_Actor.h>
33
34 #include <SUIT_Desktop.h>
35 #include <SUIT_ViewWindow.h>
36 #include <SUIT_OverrideCursor.h>
37
38 #include <OCCViewer_ViewManager.h>
39 #include <OCCViewer_ViewModel.h>
40
41 #include <SALOME_ListIO.hxx>
42 #include <SALOME_ListIteratorOfListIO.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::OpShowAll:        // MENU VIEW - SHOW ALL
105     getGeometryGUI()->EmitSignalDeactivateDialog();
106     DisplayAll();
107     break;
108   case GEOMOp::OpShowOnly:       // POPUP MENU - SHOW ONLY
109     getGeometryGUI()->EmitSignalDeactivateDialog();
110     DisplayOnly();
111     break;
112   case GEOMOp::OpShowOnlyChildren: // POPUP MENU - SHOW ONLY CHILDREN
113     getGeometryGUI()->EmitSignalDeactivateDialog();
114     DisplayOnlyChildren();
115     break;
116   case GEOMOp::OpHideAll:        // MENU VIEW - HIDE ALL
117     EraseAll();
118     break;
119   case GEOMOp::OpHide:           // POPUP MENU - HIDE
120     Erase();
121     break;
122   case GEOMOp::OpShow:           // POPUP MENU - SHOW
123     getGeometryGUI()->EmitSignalDeactivateDialog();
124     Display();
125     break;
126   case GEOMOp::OpSwitchVectors:  // MENU VIEW - DISPLAY MODE - SHOW EDGE DIRECTION
127     SetVectorMode(!GetVectorMode());
128     getGeometryGUI()->action( GEOMOp::OpSwitchVectors )->setText
129       ( GetVectorMode() ? tr("MEN_VECTOR_MODE_ON") : tr( "MEN_VECTOR_MODE_OFF" ) );
130     getGeometryGUI()->menuMgr()->update();
131     break;
132   case GEOMOp::OpWireframe:      // POPUP MENU - DISPLAY MODE - WIREFRAME
133     ChangeDisplayMode( 0 );
134     break;
135   case GEOMOp::OpShading:        // POPUP MENU - DISPLAY MODE - SHADING
136     ChangeDisplayMode( 1 );
137     break;
138   case GEOMOp::OpShadingWithEdges: // POPUP MENU - DISPLAY MODE - SHADING WITH EDGES
139     ChangeDisplayMode( 2 );
140     break;
141   case GEOMOp::OpTexture:        // POPUP MENU - DISPLAY MODE - TEXTURE
142     ChangeDisplayMode( 3 );
143     break;
144     case GEOMOp::OpVectors:        // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION
145     ChangeDisplayMode( 4 );
146     break;
147   default:
148     app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
149     break;
150   }
151   Sel->setSelectedObjects( selected );
152   return true;
153 }
154
155 //=====================================================================================
156 // function : DisplayGUI::DisplayAll()
157 // purpose  : Display all GEOM objects
158 //=====================================================================================
159 void DisplayGUI::DisplayAll()
160 {
161   SalomeApp_Application* app = getGeometryGUI()->getApp();
162   if ( !app ) return;
163
164   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
165   if ( !appStudy ) return;
166   _PTR(Study) aStudy = appStudy->studyDS();
167   if ( !aStudy ) return;
168   _PTR(SComponent) SC ( aStudy->FindComponent( "GEOM" ) );
169   if ( !SC )
170     return;
171
172   SALOME_ListIO listIO;
173   _PTR(ChildIterator) anIter ( aStudy->NewChildIterator( SC ) );
174   anIter->InitEx( true );
175
176   SUIT_OverrideCursor();
177
178   while( anIter->More() ) {
179     _PTR(SObject) valSO ( anIter->Value() );
180     _PTR(SObject) refSO;
181     if ( !valSO->ReferencedObject( refSO ) ) {
182       listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(),
183                                                   SC->ComponentDataType().c_str(),
184                                                   valSO->GetName().c_str()) );
185     } 
186     anIter->Next();
187   }
188   GEOM_Displayer( appStudy ).Display( listIO, true );
189 }
190
191 //=====================================================================================
192 // function : DisplayGUI::EraseAll()
193 // purpose  : Erase all GEOM objects
194 //=====================================================================================
195 void DisplayGUI::EraseAll()
196 {
197   SUIT_OverrideCursor();
198
199   SUIT_Application* app = getGeometryGUI()->getApp();
200   if ( app ) {
201     SUIT_ViewWindow* vw = app->desktop()->activeWindow();
202     if ( vw ) {
203       SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
204       SUIT_ViewManager* vman = vw->getViewManager();
205       if ( vman->getType() == OCCViewer_Viewer::Type() || 
206            vman->getType() == SVTK_Viewer::Type() ) {
207         GEOM_Displayer( appStudy ).EraseAll();
208       }
209     }
210   }
211 }
212
213 //=====================================================================================
214 // function : DisplayGUI::DisplayOnly()
215 // purpose  : Display selected GEOM objects and erase other
216 //=====================================================================================
217 void DisplayGUI::DisplayOnly()
218 {
219   EraseAll();
220   Display();
221 }
222
223 //=====================================================================================
224 // function : DisplayGUI::DisplayOnlyChildren()
225 // purpose  : Display only children of selected GEOM objects and erase other
226 //=====================================================================================
227 void DisplayGUI::DisplayOnlyChildren()
228 {
229   EraseAll();
230
231   SALOME_ListIO listIO;
232
233   SalomeApp_Application* app = getGeometryGUI()->getApp();
234   if (!app) return;
235
236   SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
237   if (!anActiveStudy) return;
238
239   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
240   if (!aSelMgr) return;
241
242   // get selection
243   SALOME_ListIO aList;
244   //aSelMgr->selectedObjects(aList);
245   aSelMgr->selectedObjects(aList, "ObjectBrowser", false);
246   SALOME_ListIteratorOfListIO It (aList);
247
248   SUIT_OverrideCursor();
249
250   for (; It.More(); It.Next()) {
251     Handle(SALOME_InteractiveObject) anIObject = It.Value();
252     if (anIObject->hasEntry()) {
253       _PTR(SObject) SO (anActiveStudy->studyDS()->FindObjectID(anIObject->getEntry()));
254       if (SO) {
255         _PTR(SComponent) SC (SO->GetFatherComponent());
256         if (QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str())) {
257           // if component is selected, pass it
258         }
259         else {
260           _PTR(ChildIterator) anIter (anActiveStudy->studyDS()->NewChildIterator(SO));
261           anIter->InitEx(true);
262           while (anIter->More()) {
263             _PTR(SObject) valSO (anIter->Value());
264             _PTR(SObject) refSO;
265             if (!valSO->ReferencedObject(refSO)) {
266               listIO.Append(new SALOME_InteractiveObject(valSO->GetID().c_str(),
267                                                          SC->ComponentDataType().c_str(),
268                                                          valSO->GetName().c_str()));
269             }
270             anIter->Next();
271           }
272         }
273       }
274     }
275   }
276   GEOM_Displayer(anActiveStudy).Display(listIO, true);
277 }
278
279 //=====================================================================================
280 // function : DisplayGUI::Display()
281 // purpose  : Display selected GEOM objects
282 //=====================================================================================
283 void DisplayGUI::Display()
284 {
285   SALOME_ListIO listIO;
286
287   SalomeApp_Application* app = getGeometryGUI()->getApp();
288   if ( !app ) return;
289
290   SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
291   if ( !anActiveStudy ) return;
292
293   //get SalomeApp selection manager
294   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
295   if ( !aSelMgr ) return;
296
297   SALOME_ListIO aList;
298   aSelMgr->selectedObjects( aList );
299   SALOME_ListIteratorOfListIO It( aList );
300
301   SUIT_OverrideCursor();
302
303   for( ;It.More();It.Next() ) {
304     Handle(SALOME_InteractiveObject) anIObject = It.Value();
305     if ( anIObject->hasEntry() ) {
306       _PTR(SObject) SO ( anActiveStudy->studyDS()->FindObjectID( anIObject->getEntry() ) );
307       if ( SO && QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str()) ) {
308         _PTR(SComponent) SC ( SO->GetFatherComponent() );
309         // if component is selected
310         listIO.Clear();
311         _PTR(ChildIterator) anIter ( anActiveStudy->studyDS()->NewChildIterator( SO ) );
312         anIter->InitEx( true );
313         while( anIter->More() ) {
314           _PTR(SObject) valSO ( anIter->Value() );
315           _PTR(SObject) refSO;
316           if ( !valSO->ReferencedObject( refSO ) ) {
317             listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(),
318                                                         SC->ComponentDataType().c_str(),
319                                                         valSO->GetName().c_str()) );
320           }
321           anIter->Next();
322         }
323         break;
324       }
325       else {
326         listIO.Append( anIObject );
327       }
328     }
329     else {
330       listIO.Append( anIObject );
331     }
332   }
333   GEOM_Displayer( anActiveStudy ).Display( listIO, true );
334 }
335
336
337 //=====================================================================================
338 // function : DisplayGUI::Erase()
339 // purpose  : Erase selected GEOM objects
340 //=====================================================================================
341 void DisplayGUI::Erase()
342 {
343   SALOME_ListIO listIO;
344
345   SalomeApp_Application* app = getGeometryGUI()->getApp();
346   if ( !app ) return;
347
348   SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
349   if ( !anActiveStudy ) return;
350
351   //get SalomeApp selection manager
352   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
353   if ( !aSelMgr ) return;
354
355   SALOME_ListIO aList;
356   aSelMgr->selectedObjects( aList );
357   SALOME_ListIteratorOfListIO It( aList );
358
359   SUIT_OverrideCursor();
360
361   for( ; It.More(); It.Next() ) {
362     Handle(SALOME_InteractiveObject) anIObject = It.Value();
363     if ( anIObject->hasEntry() ) {
364       _PTR(SObject) SO ( anActiveStudy->studyDS()->FindObjectID( anIObject->getEntry() ) );
365       if ( SO && QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str()) ) {
366         _PTR(SComponent) SC ( SO->GetFatherComponent() );
367         // if component is selected
368         listIO.Clear();
369         _PTR(ChildIterator) anIter ( anActiveStudy->studyDS()->NewChildIterator( SO ) );
370         anIter->InitEx( true );
371         while( anIter->More() ) {
372           _PTR(SObject) valSO ( anIter->Value() );
373           _PTR(SObject) refSO;
374           if ( !valSO->ReferencedObject( refSO ) ) {
375             listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(),
376                                                         SC->ComponentDataType().c_str(),
377                                                         valSO->GetName().c_str()) );
378           }
379           anIter->Next();
380         }
381         break;
382       }
383       else {
384         listIO.Append( anIObject );
385       }
386     }
387     else {
388       listIO.Append( anIObject );
389     }
390   }
391
392   SUIT_ViewWindow* viewWindow = app->desktop()->activeWindow();
393   bool aIsForced = true;
394   if(viewWindow->getViewManager()->getType() == SVTK_Viewer::Type())
395     aIsForced = false;
396
397   GEOM_Displayer(anActiveStudy).Erase( listIO, aIsForced);
398   getGeometryGUI()->getApp()->selectionMgr()->clearSelected();
399 }
400
401 //=====================================================================================
402 // function : DisplayGUI::SetDisplayMode()
403 // purpose  : Set display mode for the viewer (current viewer if <viewWindow> - 0 )
404 //=====================================================================================
405 void DisplayGUI::SetDisplayMode( const int mode, SUIT_ViewWindow* viewWindow )
406 {
407   SUIT_OverrideCursor();
408
409   if ( !viewWindow ) 
410     viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
411   if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
412     SVTK_View* aView = ((SVTK_ViewWindow*)viewWindow)->getView();
413     aView->SetDisplayMode( mode );
414     GeometryGUI::Modified();
415   } 
416   else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
417     OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
418     Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
419
420     AIS_DisplayMode newmode;
421     switch (mode) {
422     case 0:
423       newmode = AIS_WireFrame;
424       break;
425     case 1:
426       newmode = AIS_Shaded;
427       break;
428     case 2:
429       newmode = AIS_DisplayMode( GEOM_AISShape::ShadingWithEdges );
430       break;
431     case 3:
432       newmode = AIS_DisplayMode( GEOM_AISShape::TexturedShape );
433       break;
434     default:
435       break;
436     }
437
438     AIS_ListOfInteractive List;
439     ic->DisplayedObjects( List );
440     AIS_ListOfInteractive List1;
441     ic->ObjectsInCollector( List1 );
442     List.Append( List1 );
443     
444     AIS_ListIteratorOfListOfInteractive ite( List );
445     while( ite.More() ) {
446       if( ite.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) {
447         Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( ite.Value() );
448         if(aSh->isTopLevel()) {
449            aSh->setPrevDisplayMode(Standard_Integer( newmode ));
450         }
451         else {
452            ic->SetDisplayMode( aSh, Standard_Integer( newmode ),true );
453         }
454       }
455       ite.Next();
456     }
457       
458     ic->SetDisplayMode( newmode, Standard_False );
459
460     GeometryGUI::Modified();
461   }
462 }
463
464 //=====================================================================================
465 // function : DisplayGUI::SetVectorsMode()
466 // purpose  : Set vector mode for the viewer
467 //=====================================================================================
468 void DisplayGUI::SetVectorMode( const bool mode, SUIT_ViewWindow* viewWindow )
469 {
470   SUIT_OverrideCursor();
471
472   if ( !viewWindow ) 
473     viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
474   if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
475     viewWindow->setProperty( "VectorsMode", mode );
476     SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( viewWindow );
477     vtkActorCollection* allActors = vw->getRenderer()->GetActors();
478     allActors->InitTraversal();
479     while (vtkActor* actor = allActors->GetNextActor()) {
480       if (actor->GetVisibility()) { // only for visible actors
481         GEOM_Actor* aGeomActor = 0;
482         if ( actor->IsA( "GEOM_Actor" ) ) {
483           aGeomActor = GEOM_Actor::SafeDownCast( actor );
484           if ( aGeomActor )
485             aGeomActor->SetVectorMode( mode );
486         }
487       }
488     }
489     GeometryGUI::Modified();
490   }
491   else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
492     viewWindow->setProperty( "VectorsMode", mode );
493     OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
494     Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
495     AIS_ListOfInteractive List;
496     ic->DisplayedObjects( List );
497     AIS_ListOfInteractive List1;
498     ic->ObjectsInCollector( List1 );
499     List.Append( List1 );
500
501     AIS_ListIteratorOfListOfInteractive ite( List );
502     while( ite.More() ) {
503       if( ite.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) {
504         Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( ite.Value() );
505         aSh->SetDisplayVectors(mode);
506         ic->RecomputePrsOnly(ite.Value());
507       }
508       ite.Next();
509     }
510     GeometryGUI::Modified();
511   }
512 }
513
514 //=====================================================================================
515 // function : DisplayGUI::GetVectorMode()
516 // purpose  : Get the "show edge direction" mode of the viewer
517 //=====================================================================================
518 int DisplayGUI::GetVectorMode( SUIT_ViewWindow* viewWindow )
519 {
520   if ( !viewWindow ) 
521     viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
522   return viewWindow->property( "VectorsMode" ).toBool();
523 }
524
525 //=====================================================================================
526 // function : DisplayGUI::ChangeDisplayMode()
527 // purpose  : Set display mode for selected objects in the viewer given
528 //            (current viewer if <viewWindow> = 0 )
529 //=====================================================================================
530 void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow )
531 {
532   SalomeApp_Application* app = getGeometryGUI()->getApp();
533   if ( !app ) return;
534
535   if ( !viewWindow ) 
536     viewWindow = app->desktop()->activeWindow();
537
538   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
539   if ( !aSelMgr ) return;
540
541   SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
542   
543   if(!aStudy)
544     return;
545
546   SUIT_OverrideCursor();
547
548   SALOME_ListIO aList;
549
550   if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
551     SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( viewWindow );
552     SVTK_View* aView = vw->getView();
553     int mgrId = viewWindow->getViewManager()->getGlobalId();
554     bool vectorMode = false;
555
556     aSelMgr->selectedObjects( aList );
557     SALOME_ListIteratorOfListIO It( aList );
558
559     for( ;It.More(); It.Next() ) {
560       SVTK_Viewer* stvkViewer = dynamic_cast<SVTK_Viewer*>(vw->getViewManager()->getViewModel());
561       SVTK_Prs* vtkPrs =
562         stvkViewer ? dynamic_cast<SVTK_Prs*>( stvkViewer->CreatePrs( It.Value()->getEntry() ) ) : 0;
563       if ( vtkPrs && !vtkPrs->IsNull() ) {
564         if (mode == 0 )
565           aView->ChangeRepresentationToWireframe( vtkPrs->GetObjects() );
566         else if ( mode == 1 )
567           aView->ChangeRepresentationToSurface( vtkPrs->GetObjects() );
568         else if ( mode == 2 )
569           aView->ChangeRepresentationToSurfaceWithEdges( vtkPrs->GetObjects() );
570         else if ( mode == 4 ) {
571           vtkActorCollection* anActors = vtkPrs->GetObjects();
572           anActors->InitTraversal();
573           while (vtkActor* anAct = anActors->GetNextActor()) {
574             GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(anAct);
575             vectorMode = !aGeomActor->GetVectorMode();
576             aGeomActor->SetVectorMode(vectorMode);
577           }
578         }
579         if(mode == 0 || mode == 1 || mode == 2) {
580           aStudy->setObjectProperty(mgrId,It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
581         }
582         else if (mode == 4) {
583           aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);        
584         }
585       }
586     }
587     aView->Repaint();
588     GeometryGUI::Modified();
589   }
590   else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
591     OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
592     Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
593
594     aSelMgr->selectedObjects( aList );
595     SALOME_ListIteratorOfListIO It( aList );
596     int mgrId = viewWindow->getViewManager()->getGlobalId();
597     bool vectorMode = 0;
598
599     for( ;It.More(); It.Next() ) {
600       SOCC_Viewer* soccViewer = (SOCC_Viewer*)(viewWindow->getViewManager()->getViewModel());
601       SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( It.Value()->getEntry() ) );
602       if ( occPrs && !occPrs->IsNull() ) {
603         AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
604         AIS_ListIteratorOfListOfInteractive interIter( shapes );
605         for ( ; interIter.More(); interIter.Next() ) {
606           Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
607           if ( !aSh.IsNull() ) {
608             if(!aSh->isTopLevel()) {
609                     if ( mode == 0 )
610                 ic->SetDisplayMode( interIter.Value(), AIS_WireFrame, false );
611                     else if ( mode == 1 )
612                 ic->SetDisplayMode( interIter.Value(), AIS_Shaded, false );
613                     else if ( mode == 2 )
614                       ic->SetDisplayMode( interIter.Value(), GEOM_AISShape::ShadingWithEdges, false );
615                     else if ( mode == 3 )
616                 ic->SetDisplayMode( interIter.Value(), AIS_ExactHLR, false );
617             } else {
618               aSh->setPrevDisplayMode(mode);
619             }
620                 if (mode == 4 ) {           
621               vectorMode = !aSh->isShowVectors();      
622               aSh->SetDisplayVectors(vectorMode);
623               ic->RecomputePrsOnly(interIter.Value());
624             }
625           }
626         }
627         if(mode == 0 || mode == 1 || mode == 2 || mode == 3) {
628           aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
629         }
630         else if (mode == 4) {
631           aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);
632         }
633       }
634     }
635     ic->UpdateCurrentViewer();
636     GeometryGUI::Modified();
637   }
638 }
639
640 //=====================================================================================
641 // EXPORTED METHODS
642 //=====================================================================================
643 extern "C"
644 {
645 #ifdef WIN32
646   __declspec( dllexport )
647 #endif
648   GEOMGUI* GetLibGUI( GeometryGUI* parent )
649   {
650     return new DisplayGUI( parent );
651   }
652 }