Salome HOME
Merge branch 'hydro/imps_2015'
[modules/geom.git] / src / DisplayGUI / DisplayGUI.cxx
index 67665f66e955fdf6141b9baedbc8fb7e66640277..edbeca37877ce70bf66a43cd56229def3f004feb 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,6 +18,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 // GEOM GEOMGUI : GUI for Geometry component
 // File   : DisplayGUI.cxx
@@ -39,7 +40,6 @@
 #include <OCCViewer_ViewModel.h>
 
 #include <SALOME_ListIO.hxx>
-#include <SALOME_ListIteratorOfListIO.hxx>
 
 #include <SVTK_ViewWindow.h>
 #include <SVTK_View.h>
@@ -87,6 +87,9 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
   SalomeApp_Application* app = getGeometryGUI()->getApp();
   if (!app) return false;
 
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+  if ( !appStudy ) return false;
+
   LightApp_SelectionMgr *Sel = app->selectionMgr();
   SALOME_ListIO selected;
   Sel->selectedObjects( selected );
@@ -101,6 +104,9 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
   case GEOMOp::OpDMShadingWithEdges:  // MENU VIEW - DISPLAY MODE - SHADING WITH EDGES
     SetDisplayMode( 2 );
     break;
+  case GEOMOp::OpDMTexture:           // MENU VIEW - DISPLAY MODE - TEXTURE
+    SetDisplayMode( 3 );
+    break;
   case GEOMOp::OpShowAll:        // MENU VIEW - SHOW ALL
     getGeometryGUI()->EmitSignalDeactivateDialog();
     DisplayAll();
@@ -129,6 +135,18 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
       ( GetVectorMode() ? tr("MEN_VECTOR_MODE_ON") : tr( "MEN_VECTOR_MODE_OFF" ) );
     getGeometryGUI()->menuMgr()->update();
     break;
+  case GEOMOp::OpSwitchVertices:  // MENU VIEW - DISPLAY MODE - SHOW/HIDE VERTICES
+    SetVerticesMode(!GetVerticesMode());
+    getGeometryGUI()->action( GEOMOp::OpSwitchVertices )->setText
+      ( GetVerticesMode() ? tr("MEN_VERTICES_MODE_ON") : tr( "MEN_VERTICES_MODE_OFF" ) );
+    getGeometryGUI()->menuMgr()->update();
+    break;
+  case GEOMOp::OpSwitchName:  // MENU VIEW - DISPLAY MODE - SHOW/HIDE NAME
+    SetNameMode(!GetNameMode());
+    getGeometryGUI()->action( GEOMOp::OpSwitchName )->setText
+      ( GetNameMode() ? tr("MEN_NAME_MODE_ON") : tr( "MEN_NAME_MODE_OFF" ) );
+    getGeometryGUI()->menuMgr()->update();
+    break;
   case GEOMOp::OpWireframe:      // POPUP MENU - DISPLAY MODE - WIREFRAME
     ChangeDisplayMode( 0 );
     break;
@@ -141,14 +159,21 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
   case GEOMOp::OpTexture:        // POPUP MENU - DISPLAY MODE - TEXTURE
     ChangeDisplayMode( 3 );
     break;
-    case GEOMOp::OpVectors:        // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION
+  case GEOMOp::OpVectors:        // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION
     ChangeDisplayMode( 4 );
     break;
+  case GEOMOp::OpVertices:       // POPUP MENU - DISPLAY MODE - SHOW VERTICES
+    ChangeDisplayMode( 5 );
+    break;
+  case GEOMOp::OpShowName:       // POPUP MENU - DISPLAY MODE - SHOW NAME
+    ChangeDisplayMode( 6 );
+    break;
   default:
     app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
     break;
   }
   Sel->setSelectedObjects( selected );
+  GEOM_Displayer( appStudy ).UpdateColorScale();
   return true;
 }
 
@@ -173,7 +198,7 @@ void DisplayGUI::DisplayAll()
   _PTR(ChildIterator) anIter ( aStudy->NewChildIterator( SC ) );
   anIter->InitEx( true );
 
-  SUIT_OverrideCursor();
+  SUIT_OverrideCursor wc;
 
   while( anIter->More() ) {
     _PTR(SObject) valSO ( anIter->Value() );
@@ -194,7 +219,7 @@ void DisplayGUI::DisplayAll()
 //=====================================================================================
 void DisplayGUI::EraseAll()
 {
-  SUIT_OverrideCursor();
+  SUIT_OverrideCursor wc;
 
   SUIT_Application* app = getGeometryGUI()->getApp();
   if ( app ) {
@@ -204,7 +229,7 @@ void DisplayGUI::EraseAll()
       SUIT_ViewManager* vman = vw->getViewManager();
       if ( vman->getType() == OCCViewer_Viewer::Type() || 
            vman->getType() == SVTK_Viewer::Type() ) {
-        GEOM_Displayer( appStudy ).EraseAll();
+        GEOM_Displayer( appStudy ).EraseAll(true);
       }
     }
   }
@@ -245,7 +270,7 @@ void DisplayGUI::DisplayOnlyChildren()
   aSelMgr->selectedObjects(aList, "ObjectBrowser", false);
   SALOME_ListIteratorOfListIO It (aList);
 
-  SUIT_OverrideCursor();
+  SUIT_OverrideCursor wc;
 
   for (; It.More(); It.Next()) {
     Handle(SALOME_InteractiveObject) anIObject = It.Value();
@@ -298,7 +323,7 @@ void DisplayGUI::Display()
   aSelMgr->selectedObjects( aList );
   SALOME_ListIteratorOfListIO It( aList );
 
-  SUIT_OverrideCursor();
+  SUIT_OverrideCursor wc;
 
   for( ;It.More();It.Next() ) {
     Handle(SALOME_InteractiveObject) anIObject = It.Value();
@@ -356,7 +381,7 @@ void DisplayGUI::Erase()
   aSelMgr->selectedObjects( aList );
   SALOME_ListIteratorOfListIO It( aList );
 
-  SUIT_OverrideCursor();
+  SUIT_OverrideCursor wc;
 
   for( ; It.More(); It.Next() ) {
     Handle(SALOME_InteractiveObject) anIObject = It.Value();
@@ -404,61 +429,34 @@ void DisplayGUI::Erase()
 //=====================================================================================
 void DisplayGUI::SetDisplayMode( const int mode, SUIT_ViewWindow* viewWindow )
 {
-  SUIT_OverrideCursor();
+  SUIT_OverrideCursor wc;
+
+  SalomeApp_Application* app = getGeometryGUI()->getApp();
+  if ( !app ) return;
 
   if ( !viewWindow ) 
-    viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
-  if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
-    SVTK_View* aView = ((SVTK_ViewWindow*)viewWindow)->getView();
-    aView->SetDisplayMode( mode );
-    GeometryGUI::Modified();
-  } 
-  else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
-    OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
-    Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
-
-    AIS_DisplayMode newmode;
-    switch (mode) {
-    case 0:
-      newmode = AIS_WireFrame;
-      break;
-    case 1:
-      newmode = AIS_Shaded;
-      break;
-    case 2:
-      newmode = AIS_DisplayMode( GEOM_AISShape::ShadingWithEdges );
-      break;
-    case 3:
-      newmode = AIS_DisplayMode( GEOM_AISShape::TexturedShape );
-      break;
-    default:
-      break;
-    }
+    viewWindow = app->desktop()->activeWindow();
 
-    AIS_ListOfInteractive List;
-    ic->DisplayedObjects( List );
-    AIS_ListOfInteractive List1;
-    ic->ObjectsInCollector( List1 );
-    List.Append( List1 );
-    
-    AIS_ListIteratorOfListOfInteractive ite( List );
-    while( ite.More() ) {
-      if( ite.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) {
-       Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( ite.Value() );
-        if(aSh->isTopLevel()) {
-           aSh->setPrevDisplayMode(Standard_Integer( newmode ));
-        }
-        else {
-          ic->SetDisplayMode( aSh, Standard_Integer( newmode ),true );
-        }
-      }
-      ite.Next();
-    }
-      
-    ic->SetDisplayMode( newmode, Standard_False );
+  SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
+  if ( !aStudy ) return;
+
+  GEOM_Displayer displayer( aStudy );
+
+  int mgrId = viewWindow->getViewManager()->getGlobalId();
+
+  SALOME_View* window = displayer.GetActiveView();
+  if ( !window ) return;
 
-    GeometryGUI::Modified();
+  SALOME_ListIO anIOlst;
+  window->GetVisible( anIOlst );
+
+  for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
+    Handle( SALOME_InteractiveObject ) io = It.Value();
+    aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::DisplayMode ), mode );
+    displayer.Redisplay( io, false );
   }
+  displayer.UpdateViewer();
+  GeometryGUI::Modified();
 }
 
 //=====================================================================================
@@ -467,48 +465,36 @@ void DisplayGUI::SetDisplayMode( const int mode, SUIT_ViewWindow* viewWindow )
 //=====================================================================================
 void DisplayGUI::SetVectorMode( const bool mode, SUIT_ViewWindow* viewWindow )
 {
-  SUIT_OverrideCursor();
+  SUIT_OverrideCursor wc;
+
+  SalomeApp_Application* app = getGeometryGUI()->getApp();
+  if ( !app ) return;
+
+  SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
+  if ( !aStudy ) return;
 
   if ( !viewWindow ) 
-    viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
-  if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
-    viewWindow->setProperty( "VectorsMode", mode );
-    SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( viewWindow );
-    vtkActorCollection* allActors = vw->getRenderer()->GetActors();
-    allActors->InitTraversal();
-    while (vtkActor* actor = allActors->GetNextActor()) {
-      if (actor->GetVisibility()) { // only for visible actors
-        GEOM_Actor* aGeomActor = 0;
-        if ( actor->IsA( "GEOM_Actor" ) ) {
-          aGeomActor = GEOM_Actor::SafeDownCast( actor );
-          if ( aGeomActor )
-            aGeomActor->SetVectorMode( mode );
-        }
-      }
-    }
-    GeometryGUI::Modified();
-  }
-  else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
-    viewWindow->setProperty( "VectorsMode", mode );
-    OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
-    Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
-    AIS_ListOfInteractive List;
-    ic->DisplayedObjects( List );
-    AIS_ListOfInteractive List1;
-    ic->ObjectsInCollector( List1 );
-    List.Append( List1 );
-
-    AIS_ListIteratorOfListOfInteractive ite( List );
-    while( ite.More() ) {
-      if( ite.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) {
-        Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( ite.Value() );
-        aSh->SetDisplayVectors(mode);
-        ic->RecomputePrsOnly(ite.Value());
-      }
-      ite.Next();
-    }
-    GeometryGUI::Modified();
+    viewWindow = app->desktop()->activeWindow();
+
+  GEOM_Displayer displayer( aStudy );
+
+  viewWindow->setProperty( "VectorsMode", mode );
+
+  int aMgrId = viewWindow->getViewManager()->getGlobalId();
+
+  SALOME_View* window = displayer.GetActiveView();
+  if ( !window ) return;
+
+  SALOME_ListIO anIOlst;
+  window->GetVisible( anIOlst );
+
+  for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
+    Handle( SALOME_InteractiveObject ) io = It.Value();
+    aStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::EdgesDirection ), mode );
+    displayer.Redisplay( io, false );
   }
+  displayer.UpdateViewer();
+  GeometryGUI::Modified();
 }
 
 //=====================================================================================
@@ -522,6 +508,104 @@ int DisplayGUI::GetVectorMode( SUIT_ViewWindow* viewWindow )
   return viewWindow->property( "VectorsMode" ).toBool();
 }
 
+//=====================================================================================
+// function : DisplayGUI::SetVerticesMode()
+// purpose  : Set vertices mode for the viewer
+//=====================================================================================
+void DisplayGUI::SetVerticesMode( const bool mode, SUIT_ViewWindow* viewWindow )
+{
+  SUIT_OverrideCursor wc;
+
+  SalomeApp_Application* app = getGeometryGUI()->getApp();
+  if ( !app ) return;
+
+  SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
+  if ( !aStudy ) return;
+
+  if ( !viewWindow ) 
+    viewWindow = app->desktop()->activeWindow();
+
+  GEOM_Displayer displayer( aStudy );
+
+  viewWindow->setProperty( "VerticesMode", mode );
+
+  int aMgrId = viewWindow->getViewManager()->getGlobalId();
+
+  SALOME_View* window = displayer.GetActiveView();
+  if ( !window ) return;
+
+  SALOME_ListIO anIOlst;
+  window->GetVisible( anIOlst );
+
+  for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
+    Handle( SALOME_InteractiveObject ) io = It.Value();
+    aStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::Vertices ), mode );
+    displayer.Redisplay( io, false );
+  }
+  displayer.UpdateViewer();
+  GeometryGUI::Modified();
+}
+
+//=====================================================================================
+// function : DisplayGUI::GetVerticesMode()
+// purpose  : Get the "show vertices" mode of the viewer
+//=====================================================================================
+int DisplayGUI::GetVerticesMode( SUIT_ViewWindow* viewWindow )
+{
+  if ( !viewWindow ) 
+    viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
+  return viewWindow->property( "VerticesMode" ).toBool();
+}
+
+//=====================================================================================
+// function : DisplayGUI::SetNameMode()
+// purpose  : Set name mode for the viewer
+//=====================================================================================
+void DisplayGUI::SetNameMode( const bool mode, SUIT_ViewWindow* viewWindow )
+{
+  SUIT_OverrideCursor();
+
+  SalomeApp_Application* app = getGeometryGUI()->getApp();
+  if ( !app ) return;
+
+  SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
+  if ( !aStudy ) return;
+
+  if ( !viewWindow )
+    viewWindow = app->desktop()->activeWindow();
+
+  viewWindow->setProperty( "NameMode", mode );
+
+  GEOM_Displayer displayer( aStudy );
+
+  int aMgrId = viewWindow->getViewManager()->getGlobalId();
+
+  SALOME_View* window = displayer.GetActiveView();
+  if ( !window ) return;
+
+  SALOME_ListIO anIOlst;
+  window->GetVisible( anIOlst );
+
+  for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
+    Handle( SALOME_InteractiveObject ) io = It.Value();
+    aStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), mode );
+    displayer.Redisplay( io, false );
+  }
+  displayer.UpdateViewer();
+  GeometryGUI::Modified();
+}
+
+//=====================================================================================
+// function : DisplayGUI::GetNameMode()
+// purpose  : Get the "show name" mode of the viewer
+//=====================================================================================
+int DisplayGUI::GetNameMode( SUIT_ViewWindow* viewWindow )
+{
+  if ( !viewWindow )
+    viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
+  return viewWindow->property( "NameMode" ).toBool();
+}
+
 //=====================================================================================
 // function : DisplayGUI::ChangeDisplayMode()
 // purpose  : Set display mode for selected objects in the viewer given
@@ -538,103 +622,44 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow
   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
   if ( !aSelMgr ) return;
 
-  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
-  
-  if(!aStudy)
-    return;
+  SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
+  if ( !aStudy ) return;
 
-  SUIT_OverrideCursor();
+  SUIT_OverrideCursor wc;
 
-  SALOME_ListIO aList;
+  SALOME_ListIO selected;
+  aSelMgr->selectedObjects( selected );
+  if ( selected.IsEmpty() ) return;
 
-  if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
-    SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( viewWindow );
-    SVTK_View* aView = vw->getView();
-    int mgrId = viewWindow->getViewManager()->getGlobalId();
-    bool vectorMode = false;
-
-    aSelMgr->selectedObjects( aList );
-    SALOME_ListIteratorOfListIO It( aList );
-
-    for( ;It.More(); It.Next() ) {
-      SVTK_Viewer* stvkViewer = dynamic_cast<SVTK_Viewer*>(vw->getViewManager()->getViewModel());
-      SVTK_Prs* vtkPrs =
-        stvkViewer ? dynamic_cast<SVTK_Prs*>( stvkViewer->CreatePrs( It.Value()->getEntry() ) ) : 0;
-      if ( vtkPrs && !vtkPrs->IsNull() ) {
-       if (mode == 0 )
-          aView->ChangeRepresentationToWireframe( vtkPrs->GetObjects() );
-       else if ( mode == 1 )
-          aView->ChangeRepresentationToSurface( vtkPrs->GetObjects() );
-       else if ( mode == 2 )
-         aView->ChangeRepresentationToSurfaceWithEdges( vtkPrs->GetObjects() );
-       else if ( mode == 4 ) {
-          vtkActorCollection* anActors = vtkPrs->GetObjects();
-          anActors->InitTraversal();
-          while (vtkActor* anAct = anActors->GetNextActor()) {
-            GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(anAct);
-            vectorMode = !aGeomActor->GetVectorMode();
-            aGeomActor->SetVectorMode(vectorMode);
-          }
-        }
-       if(mode == 0 || mode == 1 || mode == 2) {
-         aStudy->setObjectProperty(mgrId,It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
-       }
-       else if (mode == 4) {
-         aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);        
-       }
-      }
+  GEOM_Displayer displayer( aStudy );
+
+  int mgrId = viewWindow->getViewManager()->getGlobalId();
+
+  QVariant v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::EdgesDirection ), QVariant() );
+  bool vectorMode =  v.isValid() ? !v.toBool() : false;
+  v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Vertices ), QVariant() );
+  bool verticesMode =  v.isValid() ? !v.toBool() : false;
+  v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::ShowName ), QVariant() );
+  bool nameMode =  v.isValid() ? !v.toBool() : false;
+
+  for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+    Handle( SALOME_InteractiveObject ) io = It.Value();
+    if ( mode == 0 || mode == 1 || mode == 2 || mode == 3 ) {
+      aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::DisplayMode ), mode );
     }
-    aView->Repaint();
-    GeometryGUI::Modified();
-  }
-  else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
-    OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
-    Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
-
-    aSelMgr->selectedObjects( aList );
-    SALOME_ListIteratorOfListIO It( aList );
-    int mgrId = viewWindow->getViewManager()->getGlobalId();
-    bool vectorMode = 0;
-
-    for( ;It.More(); It.Next() ) {
-      SOCC_Viewer* soccViewer = (SOCC_Viewer*)(viewWindow->getViewManager()->getViewModel());
-      SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( It.Value()->getEntry() ) );
-      if ( occPrs && !occPrs->IsNull() ) {
-        AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
-        AIS_ListIteratorOfListOfInteractive interIter( shapes );
-        for ( ; interIter.More(); interIter.Next() ) {
-          Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
-          if ( !aSh.IsNull() ) {
-            if(!aSh->isTopLevel()) {
-                   if ( mode == 0 )
-                ic->SetDisplayMode( interIter.Value(), AIS_WireFrame, false );
-                   else if ( mode == 1 )
-                ic->SetDisplayMode( interIter.Value(), AIS_Shaded, false );
-                   else if ( mode == 2 )
-                     ic->SetDisplayMode( interIter.Value(), GEOM_AISShape::ShadingWithEdges, false );
-                   else if ( mode == 3 )
-                ic->SetDisplayMode( interIter.Value(), AIS_ExactHLR, false );
-            } else {
-              aSh->setPrevDisplayMode(mode);
-            }
-               if (mode == 4 ) {           
-              vectorMode = !aSh->isShowVectors();      
-              aSh->SetDisplayVectors(vectorMode);
-              ic->RecomputePrsOnly(interIter.Value());
-            }
-          }
-        }
-       if(mode == 0 || mode == 1 || mode == 2 || mode == 3) {
-         aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
-       }
-       else if (mode == 4) {
-         aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);
-       }
-      }
+    else if ( mode == 4 ) {
+      aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::EdgesDirection ), vectorMode );
+    }
+    else if ( mode == 5 ) {
+      aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::Vertices ), verticesMode );
+    }
+    else if ( mode == 6 ) {
+      aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), nameMode );
     }
-    ic->UpdateCurrentViewer();
-    GeometryGUI::Modified();
+    displayer.Redisplay( io, false );
   }
+  displayer.UpdateViewer();
+  GeometryGUI::Modified();
 }
 
 //=====================================================================================