Salome HOME
Unicode support: correct handling of unicode on GUI level
[modules/gui.git] / src / SVTK / SVTK_ViewWindow.cxx
index fba7c6f7637c19b03d2c310ef553c0fd12360c62..3a63b154fb6b911ba5061346828a6bb8f95dab44 100755 (executable)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  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
@@ -23,6 +23,7 @@
 #include "SVTK_NonIsometricDlg.h"
 #include "SVTK_UpdateRateDlg.h"
 #include "SVTK_CubeAxesDlg.h"
+#include "SVTK_PsOptionsDlg.h"
 #include "SVTK_SetRotationPointDlg.h"
 #include "SVTK_ViewParameterDlg.h"
 #include "SVTK_ViewModel.h"
@@ -76,6 +77,7 @@
 
 #include "VTKViewer_Utilities.h"
 #include "VTKViewer_Trihedron.h"
+#include "VTKViewer_Actor.h"
 
 #include "SVTK_View.h"
 #include "SVTK_Selector.h"
 #include "SVTK_Recorder.h"
 #include "SVTK_RecorderDlg.h"
 
-#include "vtkPVAxesWidget.h"
-#include "vtkPVAxesActor.h"
+#include "salomevtkPVAxesWidget.h"
+#include "salomevtkPVAxesActor.h"
 
-#include "SALOME_ListIteratorOfListIO.hxx"
+#include "SALOME_ListIO.hxx"
 
 #include "VTKViewer_Algorithm.h"
 #include "SVTK_Functor.h"
 
 #include <OpenGLUtils_FrameBuffer.h>
 
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
+#include <GL/gl.h>
+#endif
 
 namespace SVTK
 {
@@ -124,10 +131,6 @@ namespace SVTK
   }
 }
 
-
-
-
-
 /*!
   Constructor
 */
@@ -148,6 +151,7 @@ SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
 */
 void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
 {
+  myModel = theModel;
   myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
   
   SVTK_Selector* aSelector = SVTK_Selector::New();
@@ -172,8 +176,13 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
   aRenderer->Delete();
   aSelector->Delete();
   
-  myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), false, Qt::AllToolBarAreas, -1, this );
-  myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), false, Qt::AllToolBarAreas, -1, this );
+  myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"),                       // title (language-dependant)
+                                       QString( "VTKViewerViewOperations" ),          // name (language-independant)
+                                       false );                                       // disable floatable toolbar
+
+  myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"),       // title (language-dependant)
+                                                QString( "VTKRecordingOperations" ),  // name (language-independant)
+                                                false );                              // disable floatable toolbar
   
   createActions( SUIT_Session::session()->resourceMgr() );
   createToolBar();
@@ -182,6 +191,9 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
   myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground
   myInteractor->setFocusPolicy(Qt::StrongFocus);
   myInteractor->setFocus();
+  bool isSupportQuadBuffer = SUIT_Session::session()->resourceMgr()->
+    booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
+  myInteractor->getRenderWindow()->SetStereoCapableWindow((int)isSupportQuadBuffer);
   setFocusProxy(myInteractor);
   
   myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" );
@@ -207,14 +219,14 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
   
   setCentralWidget(myInteractor);
   
-  myAxesWidget = vtkPVAxesWidget::New();
+  myAxesWidget = salomevtk::vtkPVAxesWidget::New();
   myAxesWidget->SetParentRenderer(aRenderer->GetDevice());
   myAxesWidget->SetViewport(0, 0, 0.25, 0.25);
   myAxesWidget->SetInteractor(myInteractor->GetDevice());
   myAxesWidget->SetEnabled(1);
   myAxesWidget->SetInteractive(0);
 
-  vtkPVAxesActor* anAxesActor = myAxesWidget->GetAxesActor();
+  salomevtk::vtkPVAxesActor* anAxesActor = myAxesWidget->GetAxesActor();
   anAxesActor->GetXAxisTipProperty()->SetColor(   1.0, 0.0, 0.0 );
   anAxesActor->GetXAxisShaftProperty()->SetColor( 1.0, 0.0, 0.0 );
   anAxesActor->GetXAxisLabelProperty()->SetColor( 1.0, 0.0, 0.0 );
@@ -437,6 +449,16 @@ void SVTK_ViewWindow::onFitAll()
   emit transformed( this );
 }
 
+/*!
+  Processes transformation "fit selection"
+*/
+void SVTK_ViewWindow::onFitSelection()
+{
+  GetRenderer()->onFitSelection();
+  Repaint();
+  emit transformed( this );
+}
+
 /*!
   SLOT: called if selection is changed
 */
@@ -656,7 +678,7 @@ void SVTK_ViewWindow::setBackground( const Qtx::BackgroundData& bgData )
          aReader = vtkMetaImageReader::New();           
        if ( aReader ) {
          // create texture
-         aReader->SetFileName( fi.absoluteFilePath().toLatin1().constData() );
+         aReader->SetFileName( fi.absoluteFilePath().toUtf8().constData() );
          aReader->Update();      
          VTKViewer_Texture* aTexture = VTKViewer_Texture::New();           
          vtkImageMapToColors* aMap = 0;
@@ -798,9 +820,9 @@ bool SVTK_ViewWindow::isCubeAxesDisplayed()
 /*!
   Redirect the request to #SVTK_Renderer::OnViewTrihedron
 */
-void SVTK_ViewWindow::onViewTrihedron()
+void SVTK_ViewWindow::onViewTrihedron(bool show)
 {
-  GetRenderer()->OnViewTrihedron();
+  GetRenderer()->SetTrihedronVisibility(show);
   Repaint();
 }
 
@@ -839,13 +861,153 @@ double SVTK_ViewWindow::GetTrihedronSize() const
 
 /*!
   Sets projection mode
-  \param theMode - projection mode ( 0 - orthogonal, 1 - perspective )
+  \param theMode - projection mode ( 0 - orthogonal, 1 - perspective, 2 - stereo )
 */
 void SVTK_ViewWindow::SetProjectionMode(const int theMode)
 {
-  activateProjectionMode( theMode );
+  QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
+  QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
+  QtxAction* aStereoAction = dynamic_cast<QtxAction*>( toolMgr()->action( StereoModeId ) );
+
+  switch ( theMode ) {
+    case Parallel:
+      onProjectionMode( aParallelAction );
+      break;
+    case Projection:
+      onProjectionMode( aProjectionAction );
+      break;
+    case Stereo:
+      onStereoMode( true );
+      break;
+  }
+
+  // update action state if method is called outside
+  SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
+  QtxAction* aSwitchZoomingStyle = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );
+  if ( theMode == Parallel && !aParallelAction->isChecked() ) {
+      aParallelAction->setChecked( true );
+         aSwitchZoomingStyle->setEnabled(true);
+         aStereoAction->setChecked( false );
+  }
+  if ( theMode == Projection && !aProjectionAction->isChecked() ) {
+      aProjectionAction->setChecked( true );
+         aSwitchZoomingStyle->setEnabled(false);
+  }
+  if ( theMode == Stereo ) {
+    aStereoAction->setChecked( true );
+    if ( aParallelAction->isEnabled() ) {
+        aParallelAction->setEnabled( false );
+        aParallelAction->setChecked( false );
+        aStereoAction->setChecked( false );
+    }
+    else {
+      aParallelAction->setEnabled( true );
+      aStereoAction->setChecked( false );
+      aParallelAction->setChecked( aViewer->projectionMode() == Parallel );
+    }
+    if ( aProjectionAction->isEnabled() ) {
+      aProjectionAction->setEnabled( false );
+      aProjectionAction->setChecked( true );
+      if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
+           strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
+           toolMgr()->action( StereoModeId )->isChecked() ) {
+        SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ),  tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
+      }
+    }
+    else {
+      aProjectionAction->setEnabled( true );
+      aStereoAction->setChecked( false );
+      aProjectionAction->setChecked( aViewer->projectionMode() == Projection );
+      onProjectionMode();
+    }
+  }
+  else {
+    if ( !aParallelAction->isEnabled() )
+      aParallelAction->setEnabled( true );
+    if ( !aProjectionAction->isEnabled() )
+      aProjectionAction->setEnabled( true );
+  }
+}
+
+/*!
+  Sets stereo type
+  \param theType - stereo type
+*/
+void SVTK_ViewWindow::SetStereoType(const int theType)
+{
+  vtkRenderWindow* aWindow = getRenderWindow();
+  switch (theType ) {
+  case CrystalEyes:
+    aWindow->SetStereoTypeToCrystalEyes();
+    break;
+  case RedBlue:
+    aWindow->SetStereoTypeToRedBlue();
+    break;
+  case Interlaced:
+    aWindow->SetStereoTypeToInterlaced();
+    break;
+  case Left:
+    aWindow->SetStereoTypeToLeft();
+    break;
+  case Right:
+    aWindow->SetStereoTypeToRight();
+    break;
+  case Dresden:
+    aWindow->SetStereoTypeToDresden();
+    break;
+  case Anaglyph:
+    aWindow->SetStereoTypeToAnaglyph();
+    break;
+  case Checkerboard:
+    aWindow->SetStereoTypeToCheckerboard();
+    break;
+  case SplitViewPortHorizontal:
+    aWindow->SetStereoTypeToSplitViewportHorizontal();
+    break;
+  }
+}
+
+/*!
+  Sets anaglyph filter
+  \param theFilter - anaglyph filter
+*/
+void SVTK_ViewWindow::SetAnaglyphFilter(const int theFilter)
+{
+  vtkRenderWindow* aWindow = getRenderWindow();
+  switch (theFilter ) {
+  case RedCyan:
+    aWindow->SetAnaglyphColorMask(4,3);
+    break;
+  case YellowBlue:
+    aWindow->SetAnaglyphColorMask(6,1);
+    break;
+  case GreenMagenta:
+    aWindow->SetAnaglyphColorMask(2,5);
+    break;
+  }
 }
 
+/*!
+  Set support quad-buffered stereo
+  \param theEnable - enable/disable support quad-buffered stereo
+*/
+void SVTK_ViewWindow::SetQuadBufferSupport(const bool theEnable)
+{
+  vtkRenderWindow* aWindow = getRenderWindow();
+  aWindow->SetStereoCapableWindow((int)theEnable);
+}
+
+/*!
+  \return OpenGl stereo support
+*/
+bool SVTK_ViewWindow::isOpenGlStereoSupport() const
+{
+  GLboolean support[1];
+  glGetBooleanv (GL_STEREO, support);
+  if ( support[0] )
+    return true;
+  return false;
+}
 
 /*!
   Set the gravity center as a focal point
@@ -873,10 +1035,17 @@ void SVTK_ViewWindow::activateStartFocalPointSelection()
 
 void SVTK_ViewWindow::activateProjectionMode(int theMode)
 {
+  QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
+  QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
   if (theMode)
-    toolMgr()->action( ProjectionModeId )->setChecked( true );
+    aParallelAction->setChecked( true );
   else
-    toolMgr()->action( ParallelModeId )->setChecked( true );
+    aProjectionAction->setChecked( true );
+
+  if ( !aParallelAction->isEnabled() )
+    aParallelAction->setEnabled( true );
+  if ( !aProjectionAction->isEnabled() )
+    aProjectionAction->setEnabled( true );
 }
 
 /*!
@@ -912,7 +1081,23 @@ void SVTK_ViewWindow::SetPreSelectionMode( Preselection_Mode theMode )
 */
 void SVTK_ViewWindow::SetSelectionEnabled( bool theEnable )
 {
-  onEnableSelection( theEnable );
+  GetSelector()->SetSelectionEnabled( theEnable );
+  QtxAction* a = getAction( EnableSelectionId );
+  if ( a->isChecked() !=  theEnable)
+    a->setChecked( theEnable );
+  QtxActionGroup* aPreselectionGroup = 
+    dynamic_cast<QtxActionGroup*>( getAction( PreselectionId ) );
+  if ( aPreselectionGroup )
+    aPreselectionGroup->setEnabled( theEnable );
+
+  // notify actors
+  vtkActorCollection *actors = getRenderer()->GetActors();
+  for (int i = 0; i < actors->GetNumberOfItems(); ++i )
+    if (VTKViewer_Actor *actor = dynamic_cast<VTKViewer_Actor*>(actors->GetItemAsObject(i)))
+    {
+      cout << "actor " << actor << endl;
+      actor->EnableSelection( theEnable );
+    }
 }
 
 /*!
@@ -982,16 +1167,9 @@ void SVTK_ViewWindow::onSwitchPreSelectionMode( int theMode )
 */
 void SVTK_ViewWindow::onEnableSelection( bool on )
 {
-  GetSelector()->SetSelectionEnabled( on );
-
-  // update action state if method is called outside
-  QtxAction* a = getAction( EnableSelectionId );
-  if ( a->isChecked() != on )
-    a->setChecked( on );
-  QtxActionGroup* aPreselectionGroup = 
-    dynamic_cast<QtxActionGroup*>( getAction( PreselectionId ) );
-  if ( aPreselectionGroup )
-    aPreselectionGroup->setEnabled( on );
+  SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
+  if(aViewer)
+    aViewer->enableSelection(on);  
 }
 
 /*!
@@ -1153,6 +1331,7 @@ QImage SVTK_ViewWindow::dumpViewContent()
   int aWidth = aSize[0];
   int aHeight = aSize[1];
   
+#ifndef DISABLE_GLVIEWER
   OpenGLUtils_FrameBuffer aFrameBuffer;
   if( aFrameBuffer.init( aWidth, aHeight ) )
   {
@@ -1176,6 +1355,7 @@ QImage SVTK_ViewWindow::dumpViewContent()
     anImage = anImage.mirrored();
     return anImage;
   }
+#endif
 
   // if frame buffers are unsupported, use old functionality
   unsigned char *aData = 
@@ -1210,33 +1390,43 @@ bool SVTK_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileNa
   if ( format != "PS" && format != "EPS" && format != "PDF" )
     return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
 
-  SUIT_OverrideCursor wc;
-
-  vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
-  anExporter->SetRenderWindow(getRenderWindow());
+  SVTK_PsOptionsDlg* optionsDlg = new SVTK_PsOptionsDlg(this);
+  if ( optionsDlg->exec() == QDialog::Accepted ) {
+    SUIT_OverrideCursor wc;
 
-  if ( format == "PS" ) {
-    anExporter->SetFileFormatToPS();
-    anExporter->CompressOff();
-  }
+    vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
+    anExporter->SetRenderWindow(getRenderWindow());
 
-  if ( format == "EPS" ) {
-    anExporter->SetFileFormatToEPS();
-    anExporter->CompressOff();
-  }
+    // Set options
+    anExporter->SetLineWidthFactor(optionsDlg->getLineFactor());
+    anExporter->SetPointSizeFactor(optionsDlg->getPointFactor());
+    anExporter->SetSort((vtkGL2PSExporter::SortScheme)optionsDlg->getSortType());
+    anExporter->SetWrite3DPropsAsRasterImage((int)optionsDlg->isRasterize3D());
+    anExporter->SetPS3Shading((int)optionsDlg->isPs3Shading());
+    
+    if ( format == "PS" ) {
+      anExporter->SetFileFormatToPS();
+      anExporter->CompressOff();
+    }
+    
+    if ( format == "EPS" ) {
+      anExporter->SetFileFormatToEPS();
+      anExporter->CompressOff();
+    }
 
-  if ( format == "PDF" ) {
-    anExporter->SetFileFormatToPDF();
+    if ( format == "PDF" ) {
+      anExporter->SetFileFormatToPDF();
+    }
+    
+    QString aFilePrefix(fileName);
+    QString anExtension(SUIT_Tools::extension(fileName));
+    aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
+    anExporter->SetFilePrefix(aFilePrefix.toUtf8().data());
+    anExporter->Write();
+    anExporter->Delete();
   }
-
-  QString aFilePrefix(fileName);
-  QString anExtension(SUIT_Tools::extension(fileName));
-  aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
-  anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
-  anExporter->Write();
-  anExporter->Delete();
-
-  return true;
+  delete optionsDlg;
+  return true;  
 }
 
 /*!
@@ -1458,7 +1648,7 @@ void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor)
   //printf("#### Color: %f, %f, %f\n", color[0], color[1], color[2]);
 
   actor->SetTitleVisibility( isVisible );
-  actor->SetTitle( title.toLatin1() );
+  actor->SetTitle( title.toUtf8() );
   vtkTextProperty* txtProp = actor->GetTitleTextProperty();
   if ( txtProp ) {
     txtProp->SetColor( color );
@@ -1543,7 +1733,7 @@ void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params )
     int shadow = paramsLst[10].toInt();
 
     actor->SetTitleVisibility( isVisible );
-    actor->SetTitle( title.toLatin1() );
+    actor->SetTitle( title.toUtf8() );
     vtkTextProperty* txtProp = actor->GetTitleTextProperty();
     if ( txtProp ) {
       txtProp->SetColor( color );
@@ -1865,28 +2055,80 @@ void SVTK_ViewWindow::activateSetRotationSelected(void* theData)
 }
 
 /*!
-  Set the point selected by user as a rotation point
+  Set the gravity center of element selected by user as a rotation point
 */
-void SVTK_ViewWindow::activateStartPointSelection()
+void SVTK_ViewWindow::activateStartPointSelection( Selection_Mode theSelectionMode )
 {
+  SetSelectionMode( theSelectionMode );
   myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
 }
 
 /*!
-  Set the view projection mode: orthogonal or perspective
+  \brief Set the given projection mode.
+
+  Set the given projection mode: Orthographic or Perspective.
 */
-void SVTK_ViewWindow::onPerspectiveMode()
+void SVTK_ViewWindow::onProjectionMode( QAction* theAction )
 {
-  bool anIsParallelMode = toolMgr()->action( ParallelModeId )->isChecked();
-
-  // advanced zooming is not available in perspective mode
-  if( QtxAction* anAction = getAction( SwitchZoomingStyleId ) )
-    anAction->setEnabled( anIsParallelMode );
-
+  int aMode = Parallel;
+  if (theAction == toolMgr()->action( ProjectionModeId ))
+    aMode = Projection;
+  SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
+  aViewer->setProjectionMode(aMode);
+  bool anIsParallelMode = (aMode == Parallel);
   vtkCamera* aCamera = getRenderer()->GetActiveCamera();
   aCamera->SetParallelProjection(anIsParallelMode);
   GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
+  getRenderWindow()->SetStereoRender(0);
+  Repaint();
+}
+
+/*!
+  \brief Sets Stereo projection mode.
+
+  Sets Stereo projection mode.
+*/
+void SVTK_ViewWindow::onStereoMode( bool activate )
+{
+  if (activate) {
+    toolMgr()->action( ProjectionModeId )->setChecked(true);
+    vtkCamera* aCamera = getRenderer()->GetActiveCamera();
+    aCamera->SetParallelProjection(false);
+    toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(false);
+    SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+    SetStereoType( aResMgr->integerValue( "VTKViewer", "stereo_type", 0 ) );
+    getRenderWindow()->SetStereoRender(1);
+    Repaint();
+  }
+  else {
+    toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(true);
+    SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
+    if (aViewer->projectionMode() == Parallel) {
+      toolMgr()->action( ParallelModeId )->setChecked(true);
+      onProjectionMode(toolMgr()->action( ParallelModeId ));
+    }
+    else if (aViewer->projectionMode() == Projection) {
+      toolMgr()->action( ProjectionModeId )->setChecked(true);
+      onProjectionMode(toolMgr()->action( ProjectionModeId ));
+    }
+  }
+  if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
+       strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
+       toolMgr()->action( StereoModeId )->isChecked() )
+    SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ),  tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
+}
 
+/*!
+  Set the view projection mode: orthogonal or perspective
+*/
+void SVTK_ViewWindow::onProjectionMode()
+{
+  if (toolMgr()->action( ParallelModeId )->isChecked())
+    SetProjectionMode( Parallel);
+  if (toolMgr()->action( ProjectionModeId )->isChecked())
+    SetProjectionMode( Projection);
+  if (toolMgr()->action( StereoModeId )->isChecked())
+    SetProjectionMode( Stereo);
   emit transformed( this );
 }
 
@@ -1908,7 +2150,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
                            tr( "MNU_DUMP_VIEW" ), 0, this);
   anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(onDumpView()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(onDumpView()));
   mgr->registerAction( anAction, DumpId );
 
   // FitAll
@@ -1916,7 +2158,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
                            tr( "MNU_FITALL" ), 0, this);
   anAction->setStatusTip(tr("DSC_FITALL"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(onFitAll()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(onFitAll()));
   mgr->registerAction( anAction, FitAllId );
 
   // FitRect
@@ -1924,15 +2166,23 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
                            tr( "MNU_FITRECT" ), 0, this);
   anAction->setStatusTip(tr("DSC_FITRECT"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));
   mgr->registerAction( anAction, FitRectId );
 
+  // FitSelection
+  anAction = new QtxAction(tr("MNU_FITSELECTION"),
+                           theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITSELECTION" ) ),
+                           tr( "MNU_FITSELECTION" ), 0, this);
+  anAction->setStatusTip(tr("DSC_FITSELECTION"));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(onFitSelection()));
+  mgr->registerAction( anAction, FitSelectionId );
+
   // Zoom
   anAction = new QtxAction(tr("MNU_ZOOM_VIEW"), 
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
                            tr( "MNU_ZOOM_VIEW" ), 0, this);
   anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(activateZoom()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(activateZoom()));
   mgr->registerAction( anAction, ZoomId );
 
   // Panning
@@ -1940,7 +2190,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
                            tr( "MNU_PAN_VIEW" ), 0, this);
   anAction->setStatusTip(tr("DSC_PAN_VIEW"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(activatePanning()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
   mgr->registerAction( anAction, PanId );
 
   // Global Panning
@@ -1948,7 +2198,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
                            tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
   anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));
   mgr->registerAction( anAction, GlobalPanId );
 
   // Change rotation point
@@ -1965,7 +2215,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
                            tr( "MNU_ROTATE_VIEW" ), 0, this);
   anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(activateRotation()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(activateRotation()));
   mgr->registerAction( anAction, RotationId );
 
   // Projections
@@ -1973,7 +2223,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
                            tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");
   anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(onFrontView()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(onFrontView()));
   this->addAction(anAction);
   mgr->registerAction( anAction, FrontId );
 
@@ -1981,7 +2231,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
                            tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
   anAction->setStatusTip(tr("DSC_BACK_VIEW"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(onBackView()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(onBackView()));
   this->addAction(anAction);
   mgr->registerAction( anAction, BackId );
 
@@ -1989,7 +2239,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
                            tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
   anAction->setStatusTip(tr("DSC_TOP_VIEW"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(onTopView()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(onTopView()));
   this->addAction(anAction);
   mgr->registerAction( anAction, TopId );
 
@@ -1997,7 +2247,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
                            tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
   anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(onBottomView()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(onBottomView()));
   this->addAction(anAction);
   mgr->registerAction( anAction, BottomId );
 
@@ -2005,7 +2255,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
                            tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
   anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(onLeftView()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(onLeftView()));
   this->addAction(anAction);
   mgr->registerAction( anAction, LeftId );
 
@@ -2013,7 +2263,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
                            tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
   anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(onRightView()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(onRightView()));
   this->addAction(anAction);
   mgr->registerAction( anAction, RightId );
 
@@ -2040,7 +2290,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
                            tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");
   anAction->setStatusTip(tr("DSC_RESET_VIEW"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(onResetView()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(onResetView()));
   this->addAction(anAction);
   mgr->registerAction( anAction, ResetId );
 
@@ -2048,8 +2298,11 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
   anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), 
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
                            tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
+  anAction->setCheckable( true );
+  anAction->setChecked( true );
+  
   anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
-  connect(anAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
+  connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewTrihedron(bool)));
   mgr->registerAction( anAction, ViewTrihedronId );
 
   // onNonIsometric: Manage non-isometric params
@@ -2085,7 +2338,6 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            tr( "MNU_SVTK_PARALLEL_MODE" ), 0, this);
   anAction->setStatusTip(tr("DSC_SVTK_PARALLEL_MODE"));
   anAction->setCheckable(true);
-  connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
   mgr->registerAction( anAction, ParallelModeId );
 
   anAction = new QtxAction(tr("MNU_SVTK_PERSPECTIVE_MODE"), 
@@ -2093,12 +2345,20 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            tr( "MNU_SVTK_PERSPECTIVE_MODE" ), 0, this);
   anAction->setStatusTip(tr("DSC_SVTK_PERSPECTIVE_MODE"));
   anAction->setCheckable(true);
-  connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
   mgr->registerAction( anAction, ProjectionModeId );
 
+  anAction = new QtxAction(tr("MNU_SVTK_STEREO_MODE"),
+                             theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_STEREO" ) ),
+                             tr( "MNU_SVTK_STEREO_MODE" ), 0, this);
+  anAction->setStatusTip(tr("DSC_SVTK_STEREO_MODE"));
+  anAction->setCheckable(true);
+  connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onStereoMode(bool)));
+  mgr->registerAction( anAction, StereoModeId );
+
   QActionGroup* aPerspectiveGroup = new QActionGroup( this );
   aPerspectiveGroup->addAction( mgr->action( ParallelModeId ) );
   aPerspectiveGroup->addAction( mgr->action( ProjectionModeId ) );
+  connect(aPerspectiveGroup, SIGNAL(triggered(QAction*)), this, SLOT(onProjectionMode(QAction*)));
 
   // View Parameters
   anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"), 
@@ -2139,7 +2399,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            tr( "MNU_SVTK_PRESELECTION_STANDARD" ), 0, this);
   anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_STANDARD"));
   anAction->setCheckable(true);
-  connect(anAction, SIGNAL(activated()), aSignalMapper, SLOT(map()));
+  connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
   aSignalMapper->setMapping( anAction, Standard_Preselection );
   mgr->registerAction( anAction, StandardPreselectionId );
   
@@ -2148,7 +2408,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            tr( "MNU_SVTK_PRESELECTION_DYNAMIC" ), 0, this);
   anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DYNAMIC"));
   anAction->setCheckable(true);
-  connect(anAction, SIGNAL(activated()), aSignalMapper, SLOT(map()));
+  connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
   aSignalMapper->setMapping( anAction, Dynamic_Preselection );
   mgr->registerAction( anAction, DynamicPreselectionId );
 
@@ -2157,7 +2417,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
                            tr( "MNU_SVTK_PRESELECTION_DISABLED" ), 0, this);
   anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DISABLED"));
   anAction->setCheckable(true);
-  connect(anAction, SIGNAL(activated()), aSignalMapper, SLOT(map()));
+  connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
   aSignalMapper->setMapping( anAction, Preselection_Disabled );
   mgr->registerAction( anAction, DisablePreselectionId );
 
@@ -2235,6 +2495,7 @@ void SVTK_ViewWindow::createToolBar()
   QtxMultiAction* aScaleAction = new QtxMultiAction( this );
   aScaleAction->insertAction( getAction( FitAllId ) );
   aScaleAction->insertAction( getAction( FitRectId ) );
+  aScaleAction->insertAction( getAction( FitSelectionId ) );
   aScaleAction->insertAction( getAction( ZoomId ) );
   mgr->append( aScaleAction, myToolBar );
 
@@ -2272,6 +2533,7 @@ void SVTK_ViewWindow::createToolBar()
 
   mgr->append( ParallelModeId, myToolBar );
   mgr->append( ProjectionModeId, myToolBar );
+  mgr->append( StereoModeId, myToolBar );
 
   mgr->append( StartRecordingId, myRecordingToolBar );
   mgr->append( PlayRecordingId, myRecordingToolBar );
@@ -2489,22 +2751,22 @@ SUIT_CameraProperties SVTK_ViewWindow::cameraProperties()
   double anAxialScale[3];
 
   aCamera->OrthogonalizeViewUp();
-  aCamera->GetFocalPoint(aFocalPoint);
-  aCamera->GetPosition(aPosition);
-  aCamera->GetViewUp(aViewUp);
+  aCamera->GetFocalPoint( aFocalPoint );
+  aCamera->GetPosition( aPosition );
+  aCamera->GetViewUp( aViewUp );
   
-  aProps.setFocalPoint(aFocalPoint[0], aFocalPoint[1], aFocalPoint[2]);
-  aProps.setPosition(aPosition[0], aPosition[1], aPosition[2]);
-  aProps.setViewUp(aViewUp[0], aViewUp[1], aViewUp[2]);
-  aProps.setMappingScale(aCamera->GetParallelScale());
+  aProps.setFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
+  aProps.setPosition( aPosition[0], aPosition[1], aPosition[2] );
+  aProps.setViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
+  aProps.setMappingScale( aCamera->GetParallelScale() * 2.0 );
 
-  if (aProps.getProjection() == SUIT_CameraProperties::PrjPerspective)
+  if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
   {
-    aProps.setViewAngle(aCamera->GetViewAngle());
+    aProps.setViewAngle( aCamera->GetViewAngle() );
   }
 
-  GetRenderer()->GetScale(anAxialScale);
-  aProps.setAxialScale(anAxialScale[0], anAxialScale[1], anAxialScale[2]);
+  GetRenderer()->GetScale( anAxialScale );
+  aProps.setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
   
   return aProps;
 }
@@ -2534,26 +2796,26 @@ void SVTK_ViewWindow::synchronize( SUIT_ViewWindow* theView )
   double anAxialScale[3];
 
   // get common properties
-  aProps.getViewUp(aViewUp[0], aViewUp[1], aViewUp[2]);
-  aProps.getPosition(aPosition[0], aPosition[1], aPosition[2]);
-  aProps.getFocalPoint(aFocalPoint[0], aFocalPoint[1], aFocalPoint[2]);
-  aProps.getAxialScale(anAxialScale[0], anAxialScale[1], anAxialScale[2]);
+  aProps.getViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
+  aProps.getPosition( aPosition[0], aPosition[1], aPosition[2] );
+  aProps.getFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
+  aProps.getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
   
   // restore properties to the camera
-  aCamera->SetViewUp(aViewUp);
-  aCamera->SetPosition(aPosition);
-  aCamera->SetFocalPoint(aFocalPoint);
-  aCamera->SetParallelScale(aProps.getMappingScale());
+  aCamera->SetViewUp( aViewUp );
+  aCamera->SetPosition( aPosition );
+  aCamera->SetFocalPoint( aFocalPoint );
+  aCamera->SetParallelScale( aProps.getMappingScale() / 2.0 );
 
-  if (aProps.getProjection() == SUIT_CameraProperties::PrjPerspective)
+  if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
   {
-    aCamera->SetViewAngle(aProps.getViewAngle());
+    aCamera->SetViewAngle( aProps.getViewAngle() );
   }
 
-  GetRenderer()->SetScale(anAxialScale);
+  GetRenderer()->SetScale( anAxialScale );
 
   getRenderer()->ResetCameraClippingRange();
-  Repaint(false);
+  Repaint( false );
 
   blockSignals( blocked );
 }