Salome HOME
Fix on regression:
[modules/kernel.git] / src / VTKViewer / VTKViewer_ViewFrame.cxx
index f16a93f4cd30b8fba296731c2cd2df49c3d12164..796620871a5530af0baa0fe2c019251ceb04b037 100644 (file)
@@ -29,6 +29,7 @@
 #include "VTKViewer_ViewFrame.h"
 #include "VTKViewer_Utilities.h"
 #include "VTKViewer_Trihedron.h"
+#include "SALOME_CubeAxesActor2D.h"
 #include "VTKViewer_RenderWindow.h"
 #include "VTKViewer_RenderWindowInteractor.h"
 #include "VTKViewer_InteractorStyleSALOME.h"
@@ -40,6 +41,7 @@
 #include "SALOME_Transform.h"
 #include "SALOME_TransformFilter.h"
 #include "SALOME_GeometryFilter.h"
+#include "SALOMEGUI.h"
 
 #include "QAD_Settings.h"
 #include "QAD_Config.h"
@@ -47,6 +49,8 @@
 #include "QAD_Desktop.h"
 #include "SALOME_Selection.h"
 #include "SALOME_InteractiveObject.hxx"
+#include "ToolsGUI.h"
+#include "SALOMEDS_Tool.hxx"
 
 #include "utilities.h"
 
 #include <vtkRenderer.h>
 #include <vtkTransform.h>
 #include <vtkActorCollection.h>
+#include <vtkTextProperty.h>
 
 #include <TColStd_IndexedMapOfInteger.hxx>
 
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
 using namespace std;
 
 /*!
@@ -76,11 +87,13 @@ VTKViewer_ViewFrame::VTKViewer_ViewFrame(QWidget* parent, const char* name)
   m_ViewUp[0] = 0; m_ViewUp[1] = 0; m_ViewUp[2] = -1;
   m_ViewNormal[0] = 0; m_ViewNormal[1] = 0; m_ViewNormal[2] = 1;
   m_Triedron = VTKViewer_Trihedron::New();
+  m_CubeAxes = SALOME_CubeAxesActor2D::New();
   m_Transform = SALOME_Transform::New();
   //m_Renderer = VTKViewer_Renderer::New() ;
   m_Renderer = vtkRenderer::New() ;
 
   m_Triedron->AddToRender(m_Renderer);
+  m_Renderer->AddProp(m_CubeAxes);
   InitialSetup();
 }  
 
@@ -115,11 +128,31 @@ void VTKViewer_ViewFrame::InitialSetup() {
 
   m_RWInteractor->Initialize();
   m_RWInteractor->setViewFrame(this);
-  RWS->setTriedron(m_Triedron);
+
   RWS->setViewFrame(this);
   //SRN: additional initialization, to init CurrentRenderer of vtkInteractorStyle 
   RWS->FindPokedRenderer(0, 0);
 
+  vtkTextProperty* tprop = vtkTextProperty::New();
+  tprop->SetColor(1, 1, 1);
+  tprop->ShadowOn();
+  
+  float bnd[6];
+  bnd[0] = bnd[2] = bnd[4] = 0;
+  bnd[1] = bnd[3] = bnd[5] = m_Triedron->GetSize();
+  m_CubeAxes->SetLabelFormat("%6.4g");
+  m_CubeAxes->SetBounds(bnd);
+  m_CubeAxes->SetCamera(m_Renderer->GetActiveCamera());
+  m_CubeAxes->SetLabelFormat("%6.4g");
+  m_CubeAxes->SetFlyModeToOuterEdges(); // ENK remarks: it must bee
+  m_CubeAxes->SetFontFactor(0.8);
+  m_CubeAxes->SetAxisTitleTextProperty(tprop);
+  m_CubeAxes->SetAxisLabelTextProperty(tprop);
+  m_CubeAxes->SetCornerOffset(0.0);
+  m_CubeAxes->SetScaling(0);
+  m_CubeAxes->SetNumberOfLabels(5);
+  tprop->Delete();
+  
   setCentralWidget( m_RW );
   onViewReset();
 }
@@ -136,6 +169,8 @@ VTKViewer_ViewFrame::~VTKViewer_ViewFrame() {
   m_Renderer->RemoveAllProps();
   // NRI : BugID 1137:  m_Renderer->Delete() ;
   m_Triedron->Delete();
+
+  m_CubeAxes->Delete();
   INFOS("VTKViewer_ViewFrame::~VTKViewer_ViewFrame()");
 }
 
@@ -150,44 +185,8 @@ bool VTKViewer_ViewFrame::isTrihedronDisplayed(){
   return m_Triedron->GetVisibility() == VTKViewer_Trihedron::eOn;
 }
 
-bool VTKViewer_ViewFrame::ComputeTrihedronSize( double& theNewSize, double& theSize )
-{
-  // calculating diagonal of visible props of the renderer
-  float bnd[ 6 ];
-  m_Triedron->VisibilityOff();
-  if ( ::ComputeVisiblePropBounds( m_Renderer, bnd ) == 0 )
-  {
-    bnd[ 1 ] = bnd[ 3 ] = bnd[ 5 ] = 100;
-    bnd[ 0 ] = bnd[ 2 ] = bnd[ 100 ] = 0;
-  }
-  m_Triedron->VisibilityOn();
-  float aLength = 0;
-  static bool CalcByDiag = false;
-  if ( CalcByDiag )
-  {
-    aLength = sqrt( ( bnd[1]-bnd[0])*(bnd[1]-bnd[0] )+
-                    ( bnd[3]-bnd[2])*(bnd[3]-bnd[2] )+
-                    ( bnd[5]-bnd[4])*(bnd[5]-bnd[4] ) );
-  }
-  else
-  {
-    aLength = bnd[ 1 ]-bnd[ 0 ];
-    aLength = max( ( bnd[ 3 ] - bnd[ 2 ] ),aLength );
-    aLength = max( ( bnd[ 5 ] - bnd[ 4 ] ),aLength );
-  }
-
-  static float aSizeInPercents = 105;
-  QString aSetting = QAD_CONFIG->getSetting( "Viewer:TrihedronSize" );
-  if ( !aSetting.isEmpty() )
-    aSizeInPercents = aSetting.toFloat();
-
-  static float EPS_SIZE = 5.0E-3;
-  theSize = m_Triedron->GetSize();
-  theNewSize = aLength * aSizeInPercents / 100.0;
-
-  // if the new trihedron size have sufficient difference, then apply the value
-  return fabs( theNewSize - theSize) > theSize * EPS_SIZE ||
-         fabs( theNewSize-theSize ) > theNewSize * EPS_SIZE;
+bool VTKViewer_ViewFrame::isCubeAxesDisplayed(){
+  return m_CubeAxes->GetVisibility() == 1;
 }
 
 double VTKViewer_ViewFrame::GetTrihedronSize() const
@@ -195,17 +194,42 @@ double VTKViewer_ViewFrame::GetTrihedronSize() const
   return m_Triedron->GetSize();
 }
 
-void VTKViewer_ViewFrame::AdjustTrihedrons( const bool forcedUpdate )
+void VTKViewer_ViewFrame::AdjustTrihedrons(const bool forced)
 {
-  if ( !isTrihedronDisplayed() && !forcedUpdate )
+  
+  if ( (!isCubeAxesDisplayed() || !isTrihedronDisplayed()) && forced)
     return;
 
+  float bnd[ 6 ];
+  float newbnd[6];
+  newbnd[ 0 ] = newbnd[ 2 ] = newbnd[ 4 ] = VTK_LARGE_FLOAT;
+  newbnd[ 1 ] = newbnd[ 3 ] = newbnd[ 5 ] = -VTK_LARGE_FLOAT;
+
+  m_CubeAxes->GetBounds(bnd);
+  if(MYDEBUG)
+    cout << "Bounds: BEFORE\n"
+        << "\txMin=" << bnd[ 0 ] << " xMax=" << bnd[ 1 ] << "\n"
+        << "\tyMin=" << bnd[ 2 ] << " yMax=" << bnd[ 3 ] << "\n"
+        << "\tzMin=" << bnd[ 4 ] << " zMax=" << bnd[ 5 ] << "\n";
+
   int aVisibleNum = m_Triedron->GetVisibleActorCount( m_Renderer );
-  if ( aVisibleNum || forcedUpdate )
+  if ( aVisibleNum )
   {
     // if the new trihedron size have sufficient difference, then apply the value
-    double aNewSize = 100, anOldSize;
-    if ( ComputeTrihedronSize( aNewSize, anOldSize ) || forcedUpdate )
+    double aNewSize = 100, anOldSize=m_Triedron->GetSize();
+    bool aTDisplayed = isTrihedronDisplayed();
+    bool aCDisplayed = isCubeAxesDisplayed();
+    if(aTDisplayed) m_Triedron->VisibilityOff();
+    if(aCDisplayed) m_CubeAxes->VisibilityOff();
+    static float aSizeInPercents = 105;
+    QString aSetting = QAD_CONFIG->getSetting( "Viewer:TrihedronSize" );
+    if ( !aSetting.isEmpty() )
+      aSizeInPercents = aSetting.toFloat();
+    bool isComputeTrihedronSize = ::ComputeTrihedronSize(m_Renderer, aNewSize, anOldSize, aSizeInPercents);
+    if(aTDisplayed) m_Triedron->VisibilityOn();
+    if(aCDisplayed) m_CubeAxes->VisibilityOn();
+    
+    if ( isComputeTrihedronSize )
     {
       m_Triedron->SetSize( aNewSize );
       // itearte throuh displayed objects and set size if necessary
@@ -218,32 +242,72 @@ void VTKViewer_ViewFrame::AdjustTrihedrons( const bool forcedUpdate )
         {
           if ( aSActor->IsResizable() )
             aSActor->SetSize( 0.5 * aNewSize );
+         if( aSActor->GetVisibility()){
+           float abounds[6];
+           aSActor->GetBounds(abounds);
+           if(MYDEBUG)
+             cout << "Bounds: Actor="<<aSActor<<"\n"
+                  << "\txMin=" << abounds[ 0 ] << " xMax=" << abounds[ 1 ] << "\n"
+                  << "\tyMin=" << abounds[ 2 ] << " yMax=" << abounds[ 3 ] << "\n"
+                  << "\tzMin=" << abounds[ 4 ] << " zMax=" << abounds[ 5 ] << "\n";
+           if (  abounds[0] > -VTK_LARGE_FLOAT && abounds[1] < VTK_LARGE_FLOAT &&
+                 abounds[2] > -VTK_LARGE_FLOAT && abounds[3] < VTK_LARGE_FLOAT &&
+                 abounds[4] > -VTK_LARGE_FLOAT && abounds[5] < VTK_LARGE_FLOAT)
+             for(int i=0;i<5;i=i+2){
+               if(abounds[i]<newbnd[i]) newbnd[i]=abounds[i];
+               if(abounds[i+1]>newbnd[i+1]) newbnd[i+1]=abounds[i+1];
+               
+             }
+         }
         }
       }
     }
   }
+  if( newbnd[0]<VTK_LARGE_FLOAT && newbnd[2]<VTK_LARGE_FLOAT && newbnd[4]<VTK_LARGE_FLOAT &&
+      newbnd[1]>-VTK_LARGE_FLOAT && newbnd[3]>-VTK_LARGE_FLOAT && newbnd[5]>-VTK_LARGE_FLOAT){
+    for(int i=0;i<6;i++) bnd[i] = newbnd[i];
+    m_CubeAxes->SetBounds(bnd);
+  }
+  if(MYDEBUG)
+    cout << "Bounds AFTER: VisibleActors="<<aVisibleNum<<"\n"
+        << "\txMin=" << bnd[ 0 ] << " xMax=" << bnd[ 1 ] << "\n"
+        << "\tyMin=" << bnd[ 2 ] << " yMax=" << bnd[ 3 ] << "\n"
+        << "\tzMin=" << bnd[ 4 ] << " zMax=" << bnd[ 5 ] << "\n";
+  
+  m_CubeAxes->SetBounds(bnd);
 
   ::ResetCameraClippingRange(m_Renderer);
 }
 
 void VTKViewer_ViewFrame::onAdjustTrihedron()
+{
+  AdjustTrihedrons(false);
+}
+
+void VTKViewer_ViewFrame::onAdjustCubeAxes()
 {   
-  AdjustTrihedrons( false );
+  AdjustTrihedrons(false);
 }
 
 /*!
   Display/hide Trihedron
 */
 void VTKViewer_ViewFrame::onViewTrihedron(){
+  onViewCubeAxes();
   if(!m_Triedron) return;
-  if(isTrihedronDisplayed())
-    m_Triedron->VisibilityOff();
-  else{
-    m_Triedron->VisibilityOn();
-  }
+  if(isTrihedronDisplayed()) m_Triedron->VisibilityOff();
+  else m_Triedron->VisibilityOn();
   Repaint();
 }
 
+void VTKViewer_ViewFrame::onViewCubeAxes(){
+  if(!m_CubeAxes) return;
+  if(isCubeAxesDisplayed()) m_CubeAxes->VisibilityOff();
+  else m_CubeAxes->VisibilityOn();
+  Repaint();
+}
+
+
 /*!
   Provides top projection of the active view
 */
@@ -314,7 +378,33 @@ void VTKViewer_ViewFrame::onViewFront(){
   Fits all objects in the active view
 */
 void VTKViewer_ViewFrame::onViewFitAll(){
-  m_RWInteractor->GetInteractorStyleSALOME()->ViewFitAll();
+
+  int aTriedronWasVisible = false;
+  int aCubeAxesWasVisible = false;
+  if(m_Triedron){
+    aTriedronWasVisible = isTrihedronDisplayed();
+    if(aTriedronWasVisible) m_Triedron->VisibilityOff();
+  }
+  if(m_CubeAxes){
+    aCubeAxesWasVisible = isCubeAxesDisplayed();
+    if(aCubeAxesWasVisible) m_CubeAxes->VisibilityOff();
+  }
+
+  if(m_Triedron->GetVisibleActorCount(m_Renderer)){
+    m_Triedron->VisibilityOff();
+    m_CubeAxes->VisibilityOff();
+    ::ResetCamera(m_Renderer);
+  }else{
+    m_Triedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
+    m_CubeAxes->SetVisibility(2);
+    ::ResetCamera(m_Renderer,true);
+  }
+  if(aTriedronWasVisible) m_Triedron->VisibilityOn();
+  else m_Triedron->VisibilityOff();
+  if(aCubeAxesWasVisible) m_CubeAxes->VisibilityOn();
+  else m_CubeAxes->VisibilityOff();
+  ::ResetCameraClippingRange(m_Renderer);
+
   Repaint();
 }
 
@@ -323,14 +413,23 @@ void VTKViewer_ViewFrame::onViewFitAll(){
 */
 void VTKViewer_ViewFrame::onViewReset(){
   int aTriedronIsVisible = isTrihedronDisplayed();
+  int aCubeAxesIsVisible = isCubeAxesDisplayed();
+  
   m_Triedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
+  m_CubeAxes->SetVisibility(0);
+  
   ::ResetCamera(m_Renderer,true);  
   vtkCamera* aCamera = m_Renderer->GetActiveCamera();
   aCamera->SetPosition(1,-1,1);
   aCamera->SetViewUp(0,0,1);
   ::ResetCamera(m_Renderer,true);  
+  
   if(aTriedronIsVisible) m_Triedron->VisibilityOn();
   else m_Triedron->VisibilityOff();
+  
+  if(aCubeAxesIsVisible) m_CubeAxes->VisibilityOn();
+  else m_CubeAxes->VisibilityOff();
+
   static float aCoeff = 3.0;
   aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale());
   Repaint();
@@ -476,10 +575,12 @@ Handle(SALOME_InteractiveObject) VTKViewer_ViewFrame::FindIObject(const char* th
 /* display */          
 void VTKViewer_ViewFrame::Display(const Handle(SALOME_InteractiveObject)& theIObject, bool update)
 {
-  QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy();
-  SALOME_Selection* aSel = SALOME_Selection::Selection(aStudy->getSelection());
+  QAD_Study*          aQADStudy = QAD_Application::getDesktop()->getActiveStudy();
+  SALOME_Selection*   aSel      = SALOME_Selection::Selection( aQADStudy->getSelection() );
+  SALOMEDS::Study_var aStudy    = aQADStudy->getStudyDocument();
 
   m_RWInteractor->Display(theIObject,false);
+  ToolsGUI::SetVisibility( aStudy, theIObject->getEntry(), true, this );
   aSel->AddIObject(theIObject,false);
 
   if(update)
@@ -506,13 +607,17 @@ void VTKViewer_ViewFrame::DisplayOnly(const Handle(SALOME_InteractiveObject)& th
   SALOME_Selection* aSel = SALOME_Selection::Selection(aStudy->getSelection());
 
   aSel->ClearIObjects();
-  m_RWInteractor->EraseAll();
+  //m_RWInteractor->EraseAll();
+  EraseAll();
 
   using namespace SALOME::VTK;
   ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TDisplayAction(aSel,theIObject));
 
+  ToolsGUI::SetVisibility(
+    aStudy->getStudyDocument(), theIObject->getEntry(), true, this );
+
   Repaint();
 }
 
@@ -541,6 +646,9 @@ void VTKViewer_ViewFrame::Erase(const Handle(SALOME_InteractiveObject)& theIObje
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TEraseAction(aSel,theIObject,m_RWInteractor));
 
+  ToolsGUI::SetVisibility(
+    aStudy->getStudyDocument(), theIObject->getEntry(), false, this );
+
   if(update)
     Repaint();
 }
@@ -549,18 +657,49 @@ void VTKViewer_ViewFrame::Erase(const Handle(SALOME_InteractiveObject)& theIObje
 void VTKViewer_ViewFrame::DisplayAll()
 {
   m_RWInteractor->DisplayAll();
+
+  // update flag of visibility
+  QAD_Study*               aQADStudy  = QAD_Application::getDesktop()->getActiveStudy();
+  SALOMEDS::Study_var      aStudy     = aQADStudy->getStudyDocument();
+  QAD_Desktop*             aDesktop   = QAD_Application::getDesktop();
+  const QString&           aCompName  = aDesktop->getComponentDataType();
+  SALOMEDS::SObject_var    aComponent =
+    SALOMEDS::SObject::_narrow( aStudy->FindComponent ( aCompName.latin1() ) );
+    
+  std::list<SALOMEDS::SObject_var> aList;
+  SALOMEDS_Tool::GetAllChildren( aStudy, aComponent, aList );
+
+  std::list<SALOMEDS::SObject_var>::iterator anIter = aList.begin();
+  for ( ; anIter != aList.end(); ++anIter )
+    ToolsGUI::SetVisibility( aStudy, (*anIter)->GetID(), true, this );
 }
 
 
 void VTKViewer_ViewFrame::EraseAll()
 {
   m_RWInteractor->EraseAll();
+
+  // update flag of visibility
+  QAD_Study*               aQADStudy  = QAD_Application::getDesktop()->getActiveStudy();
+  SALOMEDS::Study_var      aStudy     = aQADStudy->getStudyDocument();
+  QAD_Desktop*             aDesktop   = QAD_Application::getDesktop();
+  const QString&           aCompName  = aDesktop->getComponentDataType();
+  SALOMEDS::SObject_var    aComponent =
+    SALOMEDS::SObject::_narrow( aStudy->FindComponent ( aCompName.latin1() ) );
+
+  std::list<SALOMEDS::SObject_var> aList;
+  SALOMEDS_Tool::GetAllChildren( aStudy, aComponent, aList );
+
+  std::list<SALOMEDS::SObject_var>::iterator anIter = aList.begin();
+  for ( ; anIter != aList.end(); ++anIter )
+    ToolsGUI::SetVisibility( aStudy, (*anIter)->GetID(), false, this );
 }
 
 
 void VTKViewer_ViewFrame::Repaint(bool theUpdateTrihedron)
 {
   if (theUpdateTrihedron) onAdjustTrihedron();
+  //if (theUpdateCubeAxes) onAdjustCubeAxes();
   m_RW->update();
 }
 
@@ -625,6 +764,16 @@ void VTKViewer_ViewFrame::Display( const SALOME_VTKPrs* prs )
     {
       // just display the object
       m_RWInteractor->Display( salomeActor, false );
+      
+      // Set visibility flag
+      Handle(SALOME_InteractiveObject) anObj = salomeActor->getIO();
+      if ( !anObj.IsNull() && anObj->hasEntry() )
+      {
+        SALOMEDS::Study_var aStudy =
+          QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
+        ToolsGUI::SetVisibility( aStudy, anObj->getEntry(), true, this );
+      }
+
       if ( salomeActor->IsSetCamera() )
         salomeActor->SetCamera( getRenderer()->GetActiveCamera() );
     }
@@ -648,13 +797,27 @@ void VTKViewer_ViewFrame::Erase( const SALOME_VTKPrs* prs, const bool forced )
   if ( !actors )
     return;
 
+  SALOMEDS::Study_var aStudy =
+    QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
+
   actors->InitTraversal();
   vtkActor* actor;
   while( ( actor = actors->GetNextActor() ) ) {
     SALOME_Actor* salomeActor = SALOME_Actor::SafeDownCast( actor );
     if ( salomeActor ) {
       // just erase the object
-      m_RWInteractor->Erase( salomeActor, forced );
+      if ( forced )
+        m_RWInteractor->Remove( salomeActor, false );
+      else
+        m_RWInteractor->Erase( salomeActor, forced );
+
+      // Set visibility flag if necessary
+      if ( !forced )
+      {
+        Handle(SALOME_InteractiveObject) anObj = salomeActor->getIO();
+        if ( !anObj.IsNull() && anObj->hasEntry() )
+          ToolsGUI::SetVisibility( aStudy, anObj->getEntry(), true, this );
+      }
     }
   }
 }
@@ -703,3 +866,168 @@ void  VTKViewer_ViewFrame::AfterDisplay( SALOME_Displayer* d )
 {
   d->AfterDisplay( this, SALOME_VTKViewType() );
 }
+
+//==========================================================
+/*!
+ *  VTKViewer_ViewFrame::undo
+ *  Redisplay all objects in viewer
+ */
+//==========================================================
+void VTKViewer_ViewFrame::undo( QAD_Study* theQADStudy, const char* /*StudyFrameEntry*/ )
+{
+  redisplayAll( theQADStudy, true );
+}
+
+//==========================================================
+/*!
+ *  VTKViewer_ViewFrame::redo
+ *  Redisplay all objects in viewer
+ */
+//==========================================================
+void VTKViewer_ViewFrame::redo( QAD_Study* theQADStudy, const char* /*StudyFrameEntry*/ )
+{
+  redisplayAll( theQADStudy, true );
+}
+
+//==========================================================
+/*!
+ *  VTKViewer_ViewFrame::redisplayAll
+ *  Redisplay all objects in viewer
+ */
+//==========================================================
+void VTKViewer_ViewFrame::redisplayAll( QAD_Study* theQADStudy, const bool theToUpdate )
+{
+  SALOMEDS::Study_var      aStudy     = theQADStudy->getStudyDocument();
+  SALOME_Selection*        aSel       = SALOME_Selection::Selection( theQADStudy->getSelection() );
+  QAD_Desktop*             aDesktop   = QAD_Application::getDesktop();
+  SALOMEGUI*               aGUI       = aDesktop->getActiveGUI();
+  const QString&           aCompName  = aDesktop->getComponentDataType();
+  SALOMEDS::SObject_var    aComponent =
+    SALOMEDS::SObject::_narrow( aStudy->FindComponent ( aCompName.latin1() ) );
+
+  if ( aComponent->_is_nil() )
+    return;
+
+  m_RWInteractor->RemoveAll( false );
+  //m_RWInteractor->EraseAll();
+
+  aSel->ClearIObjects();
+
+  /*  
+   //   ENK commented, already added to renderer in 
+   //   VTKViewer_ViewFrame::VTKViewer_ViewFrame(...)
+  if ( isTrhDisplayed )
+      m_Triedron->AddToRender( m_Renderer );
+  */
+
+  std::list<SALOMEDS::SObject_var> aList;
+  SALOMEDS_Tool::GetAllChildren( aStudy, aComponent, aList );
+
+  std::list<SALOMEDS::SObject_var>::iterator anIter = aList.begin();
+  for ( ; anIter != aList.end(); ++anIter )
+  {
+    SALOMEDS::SObject_var anObj = (*anIter);
+    if ( ToolsGUI::GetVisibility( aStudy, anObj, this ) )
+    {
+      Handle(SALOME_InteractiveObject) anIObj = new SALOME_InteractiveObject();
+      anIObj->setEntry( anObj->GetID() );
+      aGUI->BuildPresentation( anIObj, this );
+    }
+    
+  }
+
+  if ( theToUpdate )
+    Repaint();
+}
+
+#define INCREMENT_FOR_OP 10
+
+//=======================================================================
+// name    : onPanLeft
+// Purpose : Performs incremental panning to the left
+//=======================================================================
+void VTKViewer_ViewFrame::onPanLeft()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalPan( -INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// name    : onPanRight
+// Purpose : Performs incremental panning to the right
+//=======================================================================
+void VTKViewer_ViewFrame::onPanRight()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalPan( INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// name    : onPanUp
+// Purpose : Performs incremental panning to the top
+//=======================================================================
+void VTKViewer_ViewFrame::onPanUp()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalPan( 0, INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onPanDown
+// Purpose : Performs incremental panning to the bottom
+//=======================================================================
+void VTKViewer_ViewFrame::onPanDown()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalPan( 0, -INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onZoomIn
+// Purpose : Performs incremental zooming in
+//=======================================================================
+void VTKViewer_ViewFrame::onZoomIn()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalZoom( INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onZoomOut
+// Purpose : Performs incremental zooming out
+//=======================================================================
+void VTKViewer_ViewFrame::onZoomOut()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalZoom( -INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onRotateLeft
+// Purpose : Performs incremental rotating to the left
+//=======================================================================
+void VTKViewer_ViewFrame::onRotateLeft()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalRotate( -INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// name    : onRotateRight
+// Purpose : Performs incremental rotating to the right
+//=======================================================================
+void VTKViewer_ViewFrame::onRotateRight()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalRotate( INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// name    : onRotateUp
+// Purpose : Performs incremental rotating to the top
+//=======================================================================
+void VTKViewer_ViewFrame::onRotateUp()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalRotate( 0, -INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onRotateDown
+// Purpose : Performs incremental rotating to the bottom
+//=======================================================================
+void VTKViewer_ViewFrame::onRotateDown()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalRotate( 0, INCREMENT_FOR_OP );
+}