Salome HOME
RNV: Fix compilation with the DEV version of the OCCT.
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewPort3d.cxx
index 3dd08a8129a0ec1deda20976fe31eb4ffff6ebb0..096ea27823d090678436cb7bd56950e1b161d55e 100755 (executable)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 
 #include <Visual3d_View.hxx>
 #include <V3d_Viewer.hxx>
+
+#if OCC_VERSION_LARGE > 0x06070000
+#include <V3d_View.hxx>
+#else
 #include <V3d_PerspectiveView.hxx>
 #include <V3d_OrthographicView.hxx>
+#endif
 
 #include "utilities.h"
 
-#if defined WNT
+#if defined WIN32
 #include <WNT_Window.hxx>
 #else
 #include <Xw_Window.hxx>
@@ -66,14 +71,15 @@ static Standard_Boolean zRotation = Standard_False;
 OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_Viewer)& viewer, V3d_TypeOfView  type )
   : OCCViewer_ViewPort( parent ),
     myScale( 1.0 ),
-    myDegenerated( true ),
-    myAnimate( false ),
     myBusy( true ),
     myIsAdvancedZoomingEnabled( false )
 {
   // VSR: 01/07/2010 commented to avoid SIGSEGV at SALOME exit
   //selectVisualId();
 
+#if OCC_VERSION_LARGE > 0x06070000
+  myActiveView = new V3d_View( viewer, type );
+#else
   if ( type == V3d_ORTHOGRAPHIC ) {
     myOrthoView = new V3d_OrthographicView( viewer );
     myActiveView = myOrthoView;
@@ -82,8 +88,8 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V
     myPerspView = new V3d_PerspectiveView( viewer );
     myActiveView = myPerspView;
   }
-  if ( myDegenerated )
-    activeView()->SetDegenerateModeOn();
+#endif
+
   setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
 }
 
@@ -139,6 +145,9 @@ bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view )
       view->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
     }
   }
+
+  emit( vpMapped() );
+
   return true;
 }
 
@@ -161,11 +170,6 @@ Handle( V3d_View ) OCCViewer_ViewPort3d::setView( const Handle( V3d_View )& view
     view->SetBackgroundColor( oldView->BackgroundColor() );
   }
 
-  if ( myDegenerated )
-    view->SetDegenerateModeOn();
-  else
-    view->SetDegenerateModeOff();
-
   view->View()->Activate();
   activeView() = view;
   return oldView;
@@ -457,18 +461,6 @@ void OCCViewer_ViewPort3d::updateBackground()
 #endif
 }
 
-/*!
-  Set animation mode
-  \param theDegenerated - degenerated mode
-*/
-void OCCViewer_ViewPort3d::setAnimationMode(bool theDegenerated)
-{
-  if ( !activeView().IsNull() ) {
-    myAnimate = theDegenerated;
-    activeView()->SetAnimationMode(true, theDegenerated);
-  }
-}
-
 /*!
   Updates the active viewport. [ virtual public ]
 */
@@ -549,10 +541,6 @@ void OCCViewer_ViewPort3d::startRotation( int x, int y,
                                           const gp_Pnt& theSelectedPoint )
 {
   if ( !activeView().IsNull() ) {
-    myDegenerated = activeView()->DegenerateModeIsOn();
-    activeView()->SetDegenerateModeOn();
-    if (myAnimate) activeView()->SetAnimationModeOn();
-
     //double gx, gy, gz;
     //double gx = activeView()->gx;
     //activeView()->Gravity(gx,gy,gz);
@@ -633,9 +621,6 @@ void OCCViewer_ViewPort3d::rotate( int x, int y,
 void OCCViewer_ViewPort3d::endRotation()
 {
   if ( !activeView().IsNull() ) {
-    if (myAnimate) activeView()->SetAnimationModeOff();
-    if ( !myDegenerated )
-      activeView()->SetDegenerateModeOff();
     activeView()->ZFitAll(1.);
     activeView()->SetZSize(0.);
     activeView()->Update();
@@ -648,7 +633,7 @@ void OCCViewer_ViewPort3d::endRotation()
 */
 void OCCViewer_ViewPort3d::paintEvent( QPaintEvent* e )
 {
-#ifndef WNT
+#ifndef WIN32
   /* X11 : map before show doesn't work */
   if ( !mapped( activeView() ) )
     mapView( activeView() );
@@ -668,7 +653,7 @@ void OCCViewer_ViewPort3d::paintEvent( QPaintEvent* e )
 */
 void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e )
 {
-#ifdef WNT
+#ifdef WIN32
   /* Win32 : map before first show to avoid flicker */
   if ( !mapped( activeView() ) )
     mapView( activeView() );
@@ -690,7 +675,14 @@ void OCCViewer_ViewPort3d::fitAll( bool keepScale, bool withZ, bool upd )
     myScale = activeView()->Scale();
 
   Standard_Real margin = 0.01;
+  
+#if OCC_VERSION_LARGE > 0x06070000
+  activeView()->FitAll( margin, upd );
+  if(withZ)
+    activeView()->ZFitAll();
+#else 
   activeView()->FitAll( margin, withZ, upd );
+#endif
   activeView()->SetZSize(0.);
   emit vpTransformed( this );
 }
@@ -746,15 +738,7 @@ bool OCCViewer_ViewPort3d::setWindow( const Handle(V3d_View)& view )
   if ( view.IsNull() )
     return false;
 
-  int hwnd = (int)winId();
-  if ( !hwnd )
-    return false;
-
-  /* set this widget as the drawing window */
-  short lo = (short)hwnd;
-  short hi = (short)( hwnd >> 16 );
-
-  attachWindow( view, OCCViewer_VService::CreateWindow( view, (int)hi, (int)lo, Xw_WQ_SAMEQUALITY ) );
+  attachWindow( view, OCCViewer_VService::CreateWindow( view, winId() ) );
 
   myWindow = view->Window();
   return !myWindow.IsNull();
@@ -807,8 +791,12 @@ bool OCCViewer_ViewPort3d::synchronize( OCCViewer_ViewPort* view )
     Handle(V3d_View) aView3d = getView();
     Handle(V3d_View) aRefView3d = vp3d->getView();
     aView3d->SetImmediateUpdate( Standard_False );
+#if OCC_VERSION_LARGE > 0x06070000
+    aView3d->Camera()->Copy( aRefView3d->Camera() );
+#else    
     aView3d->SetViewMapping( aRefView3d->ViewMapping() );
     aView3d->SetViewOrientation( aRefView3d->ViewOrientation() );
+#endif
     aView3d->ZFitAll();
     aView3d->SetImmediateUpdate( Standard_True );
     aView3d->Update();