Salome HOME
A revision of documentation changes in the new version. Very minor corrections.
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewPort3d.cxx
index 328090d6038df064d096c772e996de48bae3e3af..b0df1877e4e2526f1316a735432d498a5ab3707f 100755 (executable)
@@ -26,8 +26,6 @@
 #include "OCCViewer_ViewWindow.h"
 #include "OCCViewer_ViewModel.h"
 
-#include <Basics_OCCTVersion.hxx>
-
 #include <SUIT_ViewManager.h>
 #include <SUIT_ViewModel.h>
 
@@ -42,7 +40,7 @@
 #include <Visual3d_View.hxx>
 #include <V3d_Viewer.hxx>
 
-#if OCC_VERSION_LARGE > 0x06070000
+#if OCC_VERSION_LARGE > 0x06070100
 #include <V3d_View.hxx>
 #else
 #include <V3d_PerspectiveView.hxx>
@@ -77,7 +75,7 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V
   // VSR: 01/07/2010 commented to avoid SIGSEGV at SALOME exit
   //selectVisualId();
 
-#if OCC_VERSION_LARGE > 0x06070000
+#if OCC_VERSION_LARGE > 0x06070100
   myActiveView = new V3d_View( viewer, type );
 #else
   if ( type == V3d_ORTHOGRAPHIC ) {
@@ -98,7 +96,7 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V
 */
 OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d()
 {
-  emit vpClosed();
+  emit vpClosed(this);
   Handle(V3d_View) aView = activeView();
   if (!aView.IsNull())
     aView->Remove();
@@ -136,17 +134,7 @@ bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view )
       view->View()->Deactivate();
   }
 
-  /* create static trihedron (16551: EDF PAL 501) */
-  OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
-  if ( aVW ) {
-    OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
-    if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){
-      view->ZBufferTriedronSetup();
-      view->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
-    }
-  }
-
-  emit( vpMapped() );
+  emit( vpMapped(this) );
 
   return true;
 }
@@ -236,7 +224,7 @@ bool OCCViewer_ViewPort3d::syncronize( const OCCViewer_ViewPort3d* ref )
   refView->Up( x, y, z ); tgtView->SetUp( x, y, z );
   refView->Eye( x, y, z ); tgtView->SetEye( x, y, z );
   refView->Proj( x, y, z ); tgtView->SetProj( x, y, z );
-#if OCC_VERSION_LARGE <= 0x06070000
+#if OCC_VERSION_LARGE <= 0x06070100
   refView->Center( x, y ); tgtView->SetCenter( x, y );
 #endif
   tgtView->SetScale( refView->Scale() );
@@ -325,22 +313,6 @@ void OCCViewer_ViewPort3d::updateBackground()
   if ( activeView().IsNull() ) return;
   if ( !myBackground.isValid() ) return;
 
-  // VSR: Important note on below code.
-  // In OCCT (in version 6.5.2), things about the background drawing
-  // are not straightforward and not clearly understandable:
-  // - Horizontal gradient is drawn vertically (!), well ok, from top side to bottom one.
-  // - Vertical gradient is drawn horizontally (!), from right side to left one (!!!).
-  // - First and second diagonal gradients are confused.
-  // - Image texture, once set, can not be removed (!).
-  // - Texture image fill mode Aspect_FM_NONE is not taken into account (and means the same
-  //   as Aspect_FM_CENTERED).
-  // - The only way to cancel gradient background (and get back to single colored) is to
-  //   set gradient background style to Aspect_GFM_NONE while passing two colors is also needed
-  //   (see V3d_View::SetBgGradientColors() function).
-  // - Also, it is impossible to draw texture image above the gradiented background (only above
-  //   single-colored).
-  // In OCCT 6.5.3 all above mentioned problems are fixed; so, above comment should be removed as soon
-  // as SALOME is migrated to OCCT 6.5.3. The same concerns #ifdef statements in the below code
   switch ( myBackground.mode() ) {
   case Qtx::ColorBackground:
     {
@@ -349,13 +321,8 @@ void OCCViewer_ViewPort3d::updateBackground()
        // Unset texture should be done here
        // ...
        Quantity_Color qCol( c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB );
-#if OCC_VERSION_LARGE > 0x06050200 // available since OCCT 6.5.3
        activeView()->SetBgGradientStyle( Aspect_GFM_NONE ); // cancel gradient background
        activeView()->SetBgImageStyle( Aspect_FM_NONE );     // cancel texture background
-#else
-       // cancel gradient background (in OCC before v6.5.3 the only way to do this is to set it to NONE type passing arbitrary colors as parameters)
-       activeView()->SetBgGradientColors( qCol, qCol, Aspect_GFM_NONE );
-#endif
        // then change background color
        activeView()->SetBackgroundColor( qCol );
        // update viewer
@@ -377,38 +344,16 @@ void OCCViewer_ViewPort3d::updateBackground()
        activeView()->SetBgImageStyle( Aspect_FM_NONE );    // cancel texture background
        switch ( type ) {
        case OCCViewer_Viewer::HorizontalGradient:
-#if OCC_VERSION_LARGE > 0x06050200 // available since OCCT 6.5.3
          activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_HOR, Standard_True );
-#else
-         // in OCCT before v6.5.3, to draw horizontal gradient it's necessary to use Aspect_GFM_VER type
-         // and interchange the colors
-         activeView()->SetBgGradientColors( qCol2, qCol1, Aspect_GFM_VER, Standard_True );
-#endif
          break;
        case OCCViewer_Viewer::VerticalGradient:
-#if OCC_VERSION_LARGE > 0x06050200 // available since OCCT 6.5.3
          activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_VER, Standard_True );
-#else
-         // in OCCT before v6.5.3, to draw vertical gradient it's necessary to use Aspect_GFM_HOR type
-         activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_HOR, Standard_True );
-#endif
          break;
        case OCCViewer_Viewer::Diagonal1Gradient:
-#if OCC_VERSION_LARGE > 0x06050200 // available since OCCT 6.5.3
          activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_DIAG1, Standard_True );
-#else
-         // in OCCT before v6.5.3, to draw 1st dialognal gradient it's necessary to use Aspect_GFM_DIAG2 type
-         // and interchange the colors
-         activeView()->SetBgGradientColors( qCol2, qCol1, Aspect_GFM_DIAG2, Standard_True );
-#endif
          break;
        case OCCViewer_Viewer::Diagonal2Gradient:
-#if OCC_VERSION_LARGE > 0x06050200 // available since OCCT 6.5.3
          activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_DIAG2, Standard_True );
-#else
-         // in OCCT before v6.5.3, to draw 2nd dialognal gradient it's necessary to use Aspect_GFM_DIAG1 type
-         activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_DIAG1, Standard_True );
-#endif
          break;
        case OCCViewer_Viewer::Corner1Gradient:
          activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_CORNER1, Standard_True );
@@ -436,9 +381,6 @@ void OCCViewer_ViewPort3d::updateBackground()
   default:
     break;
   }
-#if OCC_VERSION_LARGE > 0x06050200 // available since OCCT 6.5.3
-  // VSR: In OCCT before v6.5.3 below code can't be used because of very ugly bug - it has been impossible to
-  // clear the background texture image as soon as it was once set to the viewer.
   if ( myBackground.isTextureShown() ) {
     QString fileName;
     int textureMode = myBackground.texture( fileName );
@@ -461,7 +403,6 @@ void OCCViewer_ViewPort3d::updateBackground()
       activeView()->Update();
     }
   }
-#endif
 }
 
 /*!
@@ -489,10 +430,8 @@ void OCCViewer_ViewPort3d::fitRect( const QRect& rect )
 */
 void OCCViewer_ViewPort3d::startZoomAtPoint( int x, int y )
 {
-#if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
   if ( !activeView().IsNull() && isAdvancedZoomingEnabled() )
     activeView()->StartZoomAtPoint( x, y );
-#endif
 }
 
 /*!
@@ -504,11 +443,9 @@ void OCCViewer_ViewPort3d::zoom( int x0, int y0, int x, int y )
     // as OCCT respects a sign of only dx,
     // but we want both signes to be taken into account
     //activeView()->Zoom( x0, y0, x, y );
-#if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
     if ( isAdvancedZoomingEnabled() )
       activeView()->ZoomAtPoint( x0, y0, x, y );
     else
-#endif
       activeView()->Zoom( x0 + y0, 0, x + y, 0 );
     emit vpTransformed( this );
   }
@@ -625,7 +562,7 @@ void OCCViewer_ViewPort3d::endRotation()
 {
   if ( !activeView().IsNull() ) {
     activeView()->ZFitAll( 1.0 );
-#if OCC_VERSION_LARGE <= 0x06070000
+#if OCC_VERSION_LARGE <= 0x06070100
     activeView()->SetZSize( 0.0 );
 #endif
     activeView()->Update();
@@ -681,7 +618,7 @@ void OCCViewer_ViewPort3d::fitAll( bool keepScale, bool withZ, bool upd )
 
   Standard_Real margin = 0.01;
   
-#if OCC_VERSION_LARGE > 0x06070000
+#if OCC_VERSION_LARGE > 0x06070100
   activeView()->FitAll( margin, upd );
   if(withZ)
     activeView()->ZFitAll();
@@ -796,7 +733,7 @@ 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
+#if OCC_VERSION_LARGE > 0x06070100
     aView3d->Camera()->Copy( aRefView3d->Camera() );
 #else
     aView3d->SetViewMapping( aRefView3d->ViewMapping() );
@@ -814,18 +751,16 @@ bool OCCViewer_ViewPort3d::synchronize( OCCViewer_ViewPort* view )
 /*
  * Show/Hide static triedron
  */
-void OCCViewer_ViewPort3d::updateStaticTriedronVisibility() {
-  OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
-  if ( aVW ) {
-    OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
-    Handle(V3d_View) aView = activeView();
-    if ( aViewModel ){
-      if(aViewModel->isStaticTrihedronDisplayed()) {
-       aView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
-      } else {
-       aView->TriedronErase();
-      }
-      aView->Update();
-    }
+void OCCViewer_ViewPort3d::showStaticTrihedron( bool on )
+{
+  Handle(V3d_View) aView = activeView();
+  if ( !aView ) return;
+  
+  if ( on ) {
+    aView->ZBufferTriedronSetup();
+    aView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
+  } else {
+    aView->TriedronErase();
   }
+  aView->Update();
 }