From 2ec0f7ed94c040853b2cc3a9ed150562abacadd1 Mon Sep 17 00:00:00 2001 From: imn Date: Fri, 17 Jul 2015 17:15:09 +0300 Subject: [PATCH] OCCT 6.9.0 compatibility (OCCT stereo render integrated in IR-2015-06-25) --- src/LightApp/LightApp_Application.cxx | 10 ++++++---- src/OCCViewer/OCCViewer_ViewFrame.cxx | 4 ++-- src/OCCViewer/OCCViewer_ViewFrame.h | 4 ++-- src/OCCViewer/OCCViewer_ViewModel.cxx | 10 ++++++---- src/OCCViewer/OCCViewer_ViewModel.h | 8 ++++++-- src/OCCViewer/OCCViewer_ViewWindow.cxx | 27 +++++++++++++++++++++++--- src/OCCViewer/OCCViewer_ViewWindow.h | 4 ++-- 7 files changed, 48 insertions(+), 19 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index f046da319..7c6116350 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1538,6 +1538,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() )); vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) ); vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) ); + #if OCC_VERSION_LARGE > 0x06090000 vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_type", vm->stereoType() ) ); vm->setAnaglyphFilter( resMgr->integerValue( "OCCViewer", "anaglyph_filter", vm->anaglyphFilter() ) ); vm->setStereographicFocus( resMgr->integerValue( "OCCViewer", "focus_type", vm->stereographicFocusType() ), @@ -1548,6 +1549,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) ); vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) ); vm->setQuadBufferSupport( resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) ); + #endif vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) ); vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) ); vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) ); @@ -2350,7 +2352,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) anIndicesList << 0 << 1; pref->setItemProperty( "strings", aValuesList, occProjMode ); pref->setItemProperty( "indexes", anIndicesList, occProjMode ); - +#if OCC_VERSION_LARGE > 0x06090000 // .... -> Stereo group int stereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), occGroup); pref->setItemProperty( "columns", 2, stereoGroup ); @@ -2421,7 +2423,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) // .... -> Enable quad-buffer support pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup, LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" ); - +#endif // ... "Background" group <> int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup ); // pref->setItemProperty( "columns", 2, bgGroup ); @@ -3126,7 +3128,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } } #endif - +#if OCC_VERSION_LARGE > 0x06090000 #ifndef DISABLE_OCCVIEWER if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) ) { @@ -3263,7 +3265,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } } #endif - +#endif if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) ) { int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 ); diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 5907af309..23945aead 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -327,7 +327,7 @@ void OCCViewer_ViewFrame::setProjectionType( int t) aView->setProjectionType(t); } } - +#if OCC_VERSION_LARGE > 0x06090000 //************************************************************************************** int OCCViewer_ViewFrame::stereoType() const { @@ -437,7 +437,7 @@ void OCCViewer_ViewFrame::setQuadBufferSupport( bool t) aView->setQuadBufferSupport(t); } } - +#endif //************************************************************************************** void OCCViewer_ViewFrame::setZoomingStyle( const int i ) { diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h index 1e56502da..8fd06d6c5 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.h +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -72,7 +72,7 @@ public: virtual int projectionType() const; virtual void setProjectionType( int ); - +#if OCC_VERSION_LARGE > 0x06090000 virtual int stereoType() const; virtual void setStereoType( const int ); @@ -95,7 +95,7 @@ public: virtual bool isQuadBufferSupport() const; virtual void setQuadBufferSupport( const bool ); - +#endif virtual int zoomingStyle() const { return getView(MAIN_VIEW)->zoomingStyle(); } virtual void setZoomingStyle( const int ); diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 1195d82b2..f94fbba33 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -169,7 +169,7 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) // set projection type to orthographic myProjectionType = 0; - +#if OCC_VERSION_LARGE > 0x06090000 // set stereo parameters myStereoType = 0; myAnaglyphFilter = 0; @@ -180,7 +180,7 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) myInterocularDistanceType = 1; myStereographicFocusValue = 1.0; myInterocularDistanceValue = 0.05; - +#endif //set clipping color and texture to standard myClippingColor = QColor( 50, 50, 50 ); myDefaultTextureUsed = true; @@ -245,6 +245,7 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) view->initSketchers(); view->setInteractionStyle( interactionStyle() ); view->setProjectionType( projectionType() ); +#if OCC_VERSION_LARGE > 0x06090000 view->setStereoType( stereoType() ); view->setAnaglyphFilter( anaglyphFilter() ); view->setStereographicFocus( stereographicFocusType(), stereographicFocusValue() ); @@ -252,6 +253,7 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) view->setReverseStereo( isReverseStereo() ); view->setVSync( isVSync() ); view->setQuadBufferSupport( isQuadBufferSupport() ); +#endif view->setZoomingStyle( zoomingStyle() ); view->enablePreselection( isPreselectionEnabled() ); view->enableSelection( isSelectionEnabled() ); @@ -542,7 +544,7 @@ void OCCViewer_Viewer::setProjectionType( const int theType ) } } } - +#if OCC_VERSION_LARGE > 0x06090000 /*! \return stereo type */ @@ -758,7 +760,7 @@ void OCCViewer_Viewer::setQuadBufferSupport( const bool theEnable ) win->setQuadBufferSupport( theEnable ); } } - +#endif /*! \return zooming style */ diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 04fd3d53e..191e41760 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -143,7 +143,7 @@ public: int projectionType() const; void setProjectionType( const int ); - +#if OCC_VERSION_LARGE > 0x06090000 int stereoType() const; void setStereoType( const int ); @@ -166,7 +166,7 @@ public: bool isQuadBufferSupport() const; void setQuadBufferSupport( const bool ); - +#endif int zoomingStyle() const; void setZoomingStyle( const int ); @@ -243,10 +243,12 @@ protected: int myInteractionStyle; int myZoomingStyle; int myProjectionType; +#if OCC_VERSION_LARGE > 0x06090000 int myStereoType; int myAnaglyphFilter; int myStereographicFocusType; int myInterocularDistanceType; +#endif double myStereographicFocusValue; double myInterocularDistanceValue; @@ -255,9 +257,11 @@ protected: bool mySelectionEnabled; bool myMultiSelectionEnabled; bool myIsRelative; +#if OCC_VERSION_LARGE > 0x06090000 bool myToReverseStereo; bool myVSyncMode; bool myQuadBufferSupport; +#endif int myTopLayerId; diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index aeb42a107..31e415c4e 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -77,8 +77,10 @@ #include #include #include +#if OCC_VERSION_LARGE > 0x06090000 #include #include +#endif #include @@ -1300,7 +1302,7 @@ void OCCViewer_ViewWindow::createActions() aAction->setCheckable(true); //connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onProjectionType())); toolMgr()->registerAction( aAction, PerspectiveId ); - +#if OCC_VERSION_LARGE > 0x06090000 // - stereo projection aAction = new QtxAction(tr("MNU_STEREO_MODE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_STEREO" ) ), tr( "MNU_STEREO_MODE" ), 0, this); @@ -1308,12 +1310,14 @@ void OCCViewer_ViewWindow::createActions() aAction->setCheckable(true); toolMgr()->registerAction( aAction, StereoId ); //connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onProjectionType())); - +#endif // - add exclusive action group QActionGroup* aProjectionGroup = new QActionGroup( this ); aProjectionGroup->addAction( toolMgr()->action( OrthographicId ) ); aProjectionGroup->addAction( toolMgr()->action( PerspectiveId ) ); +#if OCC_VERSION_LARGE > 0x06090000 aProjectionGroup->addAction( toolMgr()->action( StereoId ) ); +#endif connect(aProjectionGroup, SIGNAL(triggered(QAction*)), this, SLOT(onProjectionType())); // Reset @@ -1650,8 +1654,10 @@ void OCCViewer_ViewWindow::onProjectionType() setProjectionType( Orthographic); if (toolMgr()->action( PerspectiveId )->isChecked()) setProjectionType( Perspective); +#if OCC_VERSION_LARGE > 0x06090000 if (toolMgr()->action( StereoId )->isChecked()) setProjectionType( Stereo); +#endif emit vpTransformationFinished( PROJECTION ); } @@ -2824,6 +2830,7 @@ void OCCViewer_ViewWindow::setProjectionType( int mode ) myModel->setProjectionType(Orthographic); aCamera->SetProjectionType ( Graphic3d_Camera::Projection_Orthographic ); } + #if OCC_VERSION_LARGE > 0x06090000 if (mode == Stereo) { aCamera->SetProjectionType ( Graphic3d_Camera::Projection_Stereo ); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); @@ -2833,21 +2840,29 @@ void OCCViewer_ViewWindow::setProjectionType( int mode ) setVSync( aResMgr->booleanValue( "OCCViewer", "enable_vsync", true ) ); setQuadBufferSupport( aResMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", false ) ); } + #endif aView3d->Redraw(); onViewFitAll(); } // update action state if method is called outside QtxAction* anOrthographicAction = dynamic_cast( toolMgr()->action( OrthographicId ) ); QtxAction* aPerspectiveAction = dynamic_cast( toolMgr()->action( PerspectiveId ) ); +#if OCC_VERSION_LARGE > 0x06090000 QtxAction* aStereoAction = dynamic_cast( toolMgr()->action( StereoId ) ); +#endif if ( mode == Orthographic && !anOrthographicAction->isChecked() ) { anOrthographicAction->setChecked( true ); + #if OCC_VERSION_LARGE > 0x06090000 aStereoAction->setChecked( false ); + #endif } if ( mode == Perspective && !aPerspectiveAction->isChecked() ) { aPerspectiveAction->setChecked( true ); + #if OCC_VERSION_LARGE > 0x06090000 aStereoAction->setChecked( false ); + #endif } +#if OCC_VERSION_LARGE > 0x06090000 if ( mode == Stereo ) { aStereoAction->setChecked( true ); if ( anOrthographicAction->isEnabled() ) { @@ -2863,8 +2878,10 @@ void OCCViewer_ViewWindow::setProjectionType( int mode ) if ( aPerspectiveAction->isEnabled() ) { aPerspectiveAction->setEnabled( false ); aPerspectiveAction->setChecked( true ); + #if OCC_VERSION_LARGE > 0x06090000 if ( isQuadBufferSupport() && !isOpenGlStereoSupport() && stereoType() == QuadBuffer ) SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) ); + #endif } else { aPerspectiveAction->setEnabled( true ); @@ -2879,6 +2896,7 @@ void OCCViewer_ViewWindow::setProjectionType( int mode ) if ( !aPerspectiveAction->isEnabled() ) aPerspectiveAction->setEnabled( true ); } +#endif } int OCCViewer_ViewWindow::projectionType() const @@ -2891,12 +2909,15 @@ int OCCViewer_ViewWindow::projectionType() const mode = Perspective; if (aCamera->ProjectionType() == Graphic3d_Camera::Projection_Orthographic) mode = Orthographic; + #if OCC_VERSION_LARGE > 0x06090000 if (aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo) mode = Stereo; + #endif } return mode; } +#if OCC_VERSION_LARGE > 0x06090000 void OCCViewer_ViewWindow::setStereoType( int type ) { Handle(V3d_View) aView3d = myViewPort->getView(); @@ -3072,7 +3093,7 @@ bool OCCViewer_ViewWindow::isQuadBufferSupport() const } return enable; } - +#endif bool OCCViewer_ViewWindow::isOpenGlStereoSupport() const { GLboolean support[1]; diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 08f4202e3..5a1ef0424 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -216,7 +216,7 @@ public: virtual int projectionType() const; virtual void setProjectionType( int ); - +#if OCC_VERSION_LARGE > 0x06090000 virtual int stereoType() const; virtual void setStereoType( const int ); @@ -239,7 +239,7 @@ public: virtual bool isQuadBufferSupport() const; virtual void setQuadBufferSupport( const bool ); - +#endif void setTransformEnabled( const OperationType, const bool ); bool transformEnabled( const OperationType ) const; -- 2.39.2