From: imn Date: Mon, 24 Aug 2015 11:38:39 +0000 (+0300) Subject: 0023083: [CEA 1400] Be able to active stereo in OCC view and to choose which kind... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c4fcee934bc1cc9409e81be34595aeb8828b0e28;p=modules%2Fgui.git 0023083: [CEA 1400] Be able to active stereo in OCC view and to choose which kind of stereo mode (continue) --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 0eb31709f..f50576ea8 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -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 lst; +#ifndef DISABLE_SALOMEOBJECT + viewManagers( SVTK_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "SVTK_Viewer" ) ) + continue; + + SVTK_Viewer* vtkVM = dynamic_cast( vm ); + if( vtkVM ) vtkVM->setQuadBufferSupport( enable ); + } +#endif + } +#endif + #ifndef DISABLE_VTKVIEWER if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) ) { diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index e8a0858e1..994341063 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -153,7 +153,7 @@ - + @@ -171,7 +171,7 @@ - + diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 94824e67f..215d09dae 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -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 { diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 4a257b5f7..defa10ef0 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -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 aViews = aViewManager->getViews(); + for ( uint i = 0; i < aViews.count(); i++ ) + { + if ( TViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetQuadBufferSupport( theEnable ); + } + } + } +} /*! \return interaction style */ diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index b5f04839a..f3b00cc73 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -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; diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 5352ef145..2d98877d6 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -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" ) ); } /*! diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index cc1beb3e0..2d236d4e3 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -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 );