+int OCCViewer_ViewWindow::projectionType() const
+{
+ int mode = Orthographic;
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+ if (aCamera->ProjectionType() == Graphic3d_Camera::Projection_Perspective)
+ mode = Perspective;
+ if (aCamera->ProjectionType() == Graphic3d_Camera::Projection_Orthographic)
+ mode = Orthographic;
+ if (aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo)
+ mode = Stereo;
+ }
+ return mode;
+}
+
+void OCCViewer_ViewWindow::setStereoType( int type )
+{
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams();
+ aParams->StereoMode = (Graphic3d_StereoMode)type;
+ }
+}
+
+int OCCViewer_ViewWindow::stereoType() const
+{
+ int type = QuadBuffer;
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams();
+ type = (OCCViewer_ViewWindow::StereoType)aParams->StereoMode;
+ }
+ return type;
+}
+
+void OCCViewer_ViewWindow::setAnaglyphFilter( int type )
+{
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams();
+ if (type == RedCyan)
+ aParams->AnaglyphFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized;
+ if (type == YellowBlue)
+ aParams->AnaglyphFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized;
+ if (type == GreenMagenta)
+ aParams->AnaglyphFilter = Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple;
+ }
+}
+
+int OCCViewer_ViewWindow::anaglyphFilter() const
+{
+ int type = RedCyan;
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams();
+ if (aParams->AnaglyphFilter == Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized)
+ type = RedCyan;
+ if (aParams->AnaglyphFilter == Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized)
+ type = YellowBlue;
+ if (aParams->AnaglyphFilter == Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple)
+ type = GreenMagenta;
+ }
+ return type;
+}
+
+void OCCViewer_ViewWindow::setStereographicFocus( int type, double value )
+{
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+ aCamera->SetZFocus( (Graphic3d_Camera::FocusType) type, value );
+ }
+}
+
+int OCCViewer_ViewWindow::stereographicFocusType() const
+{
+ int type = Relative;
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+ type = (OCCViewer_ViewWindow::FocusIODType)aCamera->ZFocusType();
+ }
+ return type;
+}
+
+double OCCViewer_ViewWindow::stereographicFocusValue() const
+{
+ double value = 1.0;
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+ value = aCamera->ZFocus();
+ }
+ return value;
+}
+
+void OCCViewer_ViewWindow::setInterocularDistance( int type, double value )
+{
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+ aCamera->SetIOD( (Graphic3d_Camera::IODType) type, value );
+ }
+}
+
+int OCCViewer_ViewWindow::interocularDistanceType() const
+{
+ int type = Relative;
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+ type = (OCCViewer_ViewWindow::FocusIODType)aCamera->GetIODType();
+ }
+ return type;
+}
+
+double OCCViewer_ViewWindow::interocularDistanceValue() const
+{
+ double value = 0.05;
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+ value = aCamera->IOD();
+ }
+ return value;
+}
+
+void OCCViewer_ViewWindow::setReverseStereo( bool reverse )
+{
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams();
+ aParams->ToReverseStereo = reverse;
+ }
+}
+
+bool OCCViewer_ViewWindow::isReverseStereo() const
+{
+ int reverse = false;
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams();
+ reverse = aParams->ToReverseStereo;
+ }
+ return reverse;
+}
+
+void OCCViewer_ViewWindow::setVSync( bool enable )
+{
+ Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext();
+ if ( !anIntCont.IsNull() ) {
+ Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver());
+ OpenGl_Caps* aCaps = &aDriver->ChangeOptions();
+ aCaps->swapInterval = enable;
+ }
+}
+
+bool OCCViewer_ViewWindow::isVSync() const
+{
+ int enable = true;
+ Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext();
+ if ( !anIntCont.IsNull() ) {
+ Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver());
+ OpenGl_Caps* aCaps = &aDriver->ChangeOptions();
+ enable = aCaps->swapInterval;
+ }
+ return enable;
+}
+
+void OCCViewer_ViewWindow::setQuadBufferSupport( bool enable )
+{
+ Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext();
+ if ( !anIntCont.IsNull() ) {
+ Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver());
+ OpenGl_Caps* aCaps = &aDriver->ChangeOptions();
+ aCaps->contextStereo = enable;
+ }
+}
+
+bool OCCViewer_ViewWindow::isQuadBufferSupport() const
+{
+ int enable = true;
+ Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext();
+ if ( !anIntCont.IsNull() ) {
+ Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver());
+ OpenGl_Caps* aCaps = &aDriver->ChangeOptions();
+ enable = aCaps->contextStereo;
+ }
+ return enable;
+}
+
+
+bool OCCViewer_ViewWindow::isOpenGlStereoSupport() const
+{
+ GLboolean support[1];
+ glGetBooleanv (GL_STEREO, support);
+ if ( support[0] )
+ return true;
+ return false;
+}
+
+// obsolete