From f9b2d5da305bbccec2f6df8029c257dd0b43fc03 Mon Sep 17 00:00:00 2001 From: imn Date: Fri, 17 Jul 2015 20:08:48 +0300 Subject: [PATCH] OCCT 6.9.0 compatibility (OCCT stereo render integrated in IR-2015-06-25) edited --- src/OCCViewer/OCCViewer_ViewFrame.cxx | 4 +-- src/OCCViewer/OCCViewer_ViewFrame.h | 4 +-- src/OCCViewer/OCCViewer_ViewModel.cxx | 8 ++---- src/OCCViewer/OCCViewer_ViewModel.h | 6 ----- src/OCCViewer/OCCViewer_ViewWindow.cxx | 36 ++++++++++++++++++++++++-- src/OCCViewer/OCCViewer_ViewWindow.h | 4 +-- 6 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 23945aead..5907af309 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 8fd06d6c5..1e56502da 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 f94fbba33..afa24d375 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -169,7 +169,6 @@ 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 +179,6 @@ 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,7 +243,6 @@ 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() ); @@ -253,7 +250,6 @@ 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() ); @@ -544,7 +540,7 @@ void OCCViewer_Viewer::setProjectionType( const int theType ) } } } -#if OCC_VERSION_LARGE > 0x06090000 + /*! \return stereo type */ @@ -760,7 +756,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 191e41760..0115104bf 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -143,7 +143,6 @@ public: int projectionType() const; void setProjectionType( const int ); -#if OCC_VERSION_LARGE > 0x06090000 int stereoType() const; void setStereoType( const int ); @@ -166,7 +165,6 @@ public: bool isQuadBufferSupport() const; void setQuadBufferSupport( const bool ); -#endif int zoomingStyle() const; void setZoomingStyle( const int ); @@ -243,12 +241,10 @@ 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; @@ -257,11 +253,9 @@ 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 31e415c4e..6d03da7df 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -2917,13 +2917,14 @@ int OCCViewer_ViewWindow::projectionType() const return mode; } -#if OCC_VERSION_LARGE > 0x06090000 void OCCViewer_ViewWindow::setStereoType( int type ) { Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); aParams->StereoMode = (Graphic3d_StereoMode)type; + #endif } } @@ -2932,8 +2933,10 @@ int OCCViewer_ViewWindow::stereoType() const int type = QuadBuffer; Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); type = (OCCViewer_ViewWindow::StereoType)aParams->StereoMode; + #endif } return type; } @@ -2942,6 +2945,7 @@ void OCCViewer_ViewWindow::setAnaglyphFilter( int type ) { Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); if (type == RedCyan) aParams->AnaglyphFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized; @@ -2949,6 +2953,7 @@ void OCCViewer_ViewWindow::setAnaglyphFilter( int type ) aParams->AnaglyphFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized; if (type == GreenMagenta) aParams->AnaglyphFilter = Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple; + #endif } } @@ -2957,6 +2962,7 @@ int OCCViewer_ViewWindow::anaglyphFilter() const int type = RedCyan; Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); if (aParams->AnaglyphFilter == Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized) type = RedCyan; @@ -2964,6 +2970,7 @@ int OCCViewer_ViewWindow::anaglyphFilter() const type = YellowBlue; if (aParams->AnaglyphFilter == Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple) type = GreenMagenta; + #endif } return type; } @@ -2972,8 +2979,10 @@ void OCCViewer_ViewWindow::setStereographicFocus( int type, double value ) { Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); aCamera->SetZFocus( (Graphic3d_Camera::FocusType) type, value ); + #endif } } @@ -2982,8 +2991,10 @@ int OCCViewer_ViewWindow::stereographicFocusType() const int type = Relative; Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); type = (OCCViewer_ViewWindow::FocusIODType)aCamera->ZFocusType(); + #endif } return type; } @@ -2993,8 +3004,10 @@ double OCCViewer_ViewWindow::stereographicFocusValue() const double value = 1.0; Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); value = aCamera->ZFocus(); + #endif } return value; } @@ -3003,8 +3016,10 @@ void OCCViewer_ViewWindow::setInterocularDistance( int type, double value ) { Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); aCamera->SetIOD( (Graphic3d_Camera::IODType) type, value ); + #endif } } @@ -3013,8 +3028,10 @@ int OCCViewer_ViewWindow::interocularDistanceType() const int type = Relative; Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); type = (OCCViewer_ViewWindow::FocusIODType)aCamera->GetIODType(); + #endif } return type; } @@ -3024,8 +3041,10 @@ double OCCViewer_ViewWindow::interocularDistanceValue() const double value = 0.05; Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); value = aCamera->IOD(); + #endif } return value; } @@ -3034,8 +3053,10 @@ void OCCViewer_ViewWindow::setReverseStereo( bool reverse ) { Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); aParams->ToReverseStereo = reverse; + #endif } } @@ -3044,8 +3065,10 @@ bool OCCViewer_ViewWindow::isReverseStereo() const int reverse = false; Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); reverse = aParams->ToReverseStereo; + #endif } return reverse; } @@ -3054,9 +3077,11 @@ void OCCViewer_ViewWindow::setVSync( bool enable ) { Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext(); if ( !anIntCont.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver()); OpenGl_Caps* aCaps = &aDriver->ChangeOptions(); aCaps->swapInterval = enable; + #endif } } @@ -3065,9 +3090,11 @@ bool OCCViewer_ViewWindow::isVSync() const int enable = true; Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext(); if ( !anIntCont.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver()); OpenGl_Caps* aCaps = &aDriver->ChangeOptions(); enable = aCaps->swapInterval; + #endif } return enable; } @@ -3076,9 +3103,11 @@ void OCCViewer_ViewWindow::setQuadBufferSupport( bool enable ) { Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext(); if ( !anIntCont.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver()); OpenGl_Caps* aCaps = &aDriver->ChangeOptions(); aCaps->contextStereo = enable; + #endif } } @@ -3087,13 +3116,16 @@ bool OCCViewer_ViewWindow::isQuadBufferSupport() const int enable = true; Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext(); if ( !anIntCont.IsNull() ) { + #if OCC_VERSION_LARGE > 0x06090000 Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver()); OpenGl_Caps* aCaps = &aDriver->ChangeOptions(); enable = aCaps->contextStereo; + #endif } 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 5a1ef0424..08f4202e3 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