]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
0023083: [CEA 1400] Be able to active stereo in OCC view and to choose which kind...
authorimn <imn@opencascade.com>
Mon, 24 Aug 2015 11:38:39 +0000 (14:38 +0300)
committerimn <imn@opencascade.com>
Tue, 25 Aug 2015 10:21:47 +0000 (13:21 +0300)
0023083: [CEA 1400] Be able to active stereo in OCC view and to choose which kind of stereo mode
- fixed support quad-buffered stereo

src/LightApp/LightApp_Application.cxx
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/SVTK/SVTK_ViewModel.cxx
src/SVTK/SVTK_ViewModel.h
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h

index 0eb31709f6981ae725eb7959f6f5a4c717525167..f50576ea8d68e4be8a404d2945d9a90dcf2dbc87 100644 (file)
@@ -1576,6 +1576,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType
       vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
       vm->setStereoType( resMgr->integerValue( "VTKViewer", "stereo_type", vm->stereoType() ) );
       vm->setAnaglyphFilter( resMgr->integerValue( "VTKViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
+      vm->setQuadBufferSupport( resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
       vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
       vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
                             resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
@@ -3382,6 +3383,27 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
   }
 #endif
 
+#ifndef DISABLE_VTKVIEWER
+  if ( sec == QString( "VTKViewer" ) && param == QString( "enable_quad_buffer_support" ) )
+  {
+    int enable = resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
+    QList<SUIT_ViewManager*> lst;
+#ifndef DISABLE_SALOMEOBJECT
+    viewManagers( SVTK_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> it( lst );
+    while ( it.hasNext() )
+    {
+      SUIT_ViewModel* vm = it.next()->getViewModel();
+      if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
+        continue;
+
+      SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
+      if( vtkVM ) vtkVM->setQuadBufferSupport( enable );
+    }
+#endif
+  }
+#endif
+
 #ifndef DISABLE_VTKVIEWER
   if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
   {
index 94824e67fedf062b40f41a1407a4d128fb99cf30..215d09dae8883d8b5319d50d206e13749e8cea4b 100755 (executable)
@@ -1705,7 +1705,8 @@ void OCCViewer_ViewWindow::onStereoType( bool activate )
     onViewFitAll();
   }
 
-  if ( isQuadBufferSupport() && !isOpenGlStereoSupport() && stereoType() == QuadBuffer )
+  if ( isQuadBufferSupport() && !isOpenGlStereoSupport() && stereoType() == QuadBuffer &&
+       toolMgr()->action( StereoId )->isChecked() )
     SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ),  tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
 #endif
 }
@@ -1776,7 +1777,8 @@ void OCCViewer_ViewWindow::setProjectionType( int mode )
     if ( aPerspectiveAction->isEnabled() ) {
       aPerspectiveAction->setEnabled( false );
       aPerspectiveAction->setChecked( true );
-      if ( isQuadBufferSupport() && !isOpenGlStereoSupport() && stereoType() == QuadBuffer )
+      if ( isQuadBufferSupport() && !isOpenGlStereoSupport() && stereoType() == QuadBuffer &&
+           toolMgr()->action( StereoId )->isChecked() )
         SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ),  tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
     }
     else {
index 4a257b5f7fc07edd40b46805432cf651e6308e5f..defa10ef0293dad73991df1e53f8f2de2ec2c811 100644 (file)
@@ -196,6 +196,7 @@ SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop )
   aViewWindow->SetProjectionMode( projectionMode() );
   aViewWindow->SetStereoType( stereoType() );
   aViewWindow->SetAnaglyphFilter( anaglyphFilter() );
+  aViewWindow->SetQuadBufferSupport( isQuadBufferSupport() );
   aViewWindow->SetInteractionStyle( interactionStyle() );
   aViewWindow->SetZoomingStyle( zoomingStyle() );
   aViewWindow->SetPreSelectionMode( preSelectionMode() );
@@ -358,6 +359,33 @@ void SVTK_Viewer::setAnaglyphFilter( const int theFilter )
   }
 }
 
+/*!
+  \return support quad-buffered stereo
+*/
+bool SVTK_Viewer::isQuadBufferSupport() const
+{
+  return myQuadBufferSupport;
+}
+
+/*!
+  Set support quad-buffered stereo
+  \param theEnable - enable/disable support quad-buffered stereo
+*/
+void SVTK_Viewer::setQuadBufferSupport( const bool theEnable )
+{
+  if ( myQuadBufferSupport != theEnable ) {
+    myQuadBufferSupport = theEnable;
+
+    if (SUIT_ViewManager* aViewManager = getViewManager()) {
+      QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+      for ( uint i = 0; i < aViews.count(); i++ )
+      {
+        if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+          aView->SetQuadBufferSupport( theEnable );
+      }
+    }
+  }
+}
 /*!
   \return interaction style
 */
index b5f04839a3edf5de514ebb2fcbe4c2cb4a4156ec..f3b00cc73dd1cc66cc1ca065e5da3f731614ece5 100644 (file)
@@ -134,6 +134,12 @@ public:
   //! Sets anaglyph filter
   void setAnaglyphFilter( const int );
 
+  //! Get support quad-buffered stereo
+  bool isQuadBufferSupport() const;
+
+  //! Set support quad-buffered stereo
+  void setQuadBufferSupport( const bool );
+
   //! Gets interaction style
   int interactionStyle() const;
 
@@ -228,6 +234,7 @@ private:
   int                  myProjMode;
   int                  myStereoType;
   int                  myAnaglyphFilter;
+  bool                 myQuadBufferSupport;
   int                  myStyle;
   int                  myZoomingStyle;
   Preselection_Mode    myPreSelectionMode;
index 5352ef1450b442e839760ff00d6c6d1b08175305..2d98877d6dc7bff2654dae5b3dfc1811f480f881 100755 (executable)
@@ -903,7 +903,8 @@ void SVTK_ViewWindow::SetProjectionMode(const int theMode)
       aProjectionAction->setEnabled( false );
       aProjectionAction->setChecked( true );
       if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
-           strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 ){
+           strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
+           toolMgr()->action( StereoModeId )->isChecked() ) {
         SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ),  tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
       }
     }
@@ -980,6 +981,16 @@ void SVTK_ViewWindow::SetAnaglyphFilter(const int theFilter)
   }
 }
 
+/*!
+  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
 */
@@ -2076,6 +2087,10 @@ void SVTK_ViewWindow::onStereoMode( bool activate )
       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" ) );
 }
 
 /*!
index cc1beb3e04b98a6c6c9412174b851cddfb79b5b6..2d236d4e32075f630f9c7a36104a256002c965f0 100755 (executable)
@@ -236,6 +236,9 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
   //! Sets anaglyph filter
   virtual void SetAnaglyphFilter( const int );
 
+  //! Set support quad-buffered stereo
+  virtual void SetQuadBufferSupport( const bool );
+
   //! Set interactive style
   virtual void SetInteractionStyle( const int );