Salome HOME
Unicode support: correct handling of unicode on GUI level
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewPort3d.cxx
index b0ba526d440ae4db77d3cfc0cc9e2074180b359d..73f89e2137839f024228ee8851d135612ebcb3ff 100755 (executable)
 #include <QPaintEvent>
 #include <QResizeEvent>
 #include <QApplication>
+#include <QTimer>
 
-#include <Visual3d_View.hxx>
-#include <V3d_Viewer.hxx>
-
-#if OCC_VERSION_LARGE > 0x06070100
 #include <V3d_View.hxx>
-#else
-#include <V3d_PerspectiveView.hxx>
-#include <V3d_OrthographicView.hxx>
-#endif
+#include <Quantity_Ratio.hxx>
 
 #include "utilities.h"
 
@@ -77,18 +71,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 > 0x06070100
   myActiveView = new V3d_View( viewer, type );
-#else
-  if ( type == V3d_ORTHOGRAPHIC ) {
-    myOrthoView = new V3d_OrthographicView( viewer );
-    myActiveView = myOrthoView;
-    myPerspView = 0;
-  } else {
-    myPerspView = new V3d_PerspectiveView( viewer );
-    myActiveView = myPerspView;
-  }
-#endif
 
   setDefaultParams();
 
@@ -234,40 +217,16 @@ 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 <= 0x06070100
-  refView->Center( x, y ); tgtView->SetCenter( x, y );
-#endif
   tgtView->SetScale( refView->Scale() );
   tgtView->SetTwist( refView->Twist() );
 
   /* update */
   tgtView->Update();
   tgtView->SetImmediateUpdate( Standard_True );
-  tgtView->ZFitAll();
-  return true;
-}
 
-/*!
-  Returns Z-size of this view. [ public ]
-*/
-double OCCViewer_ViewPort3d::getZSize() const
-{
-  if ( !activeView().IsNull() )
-    return activeView()->ZSize();
-  return 0;
+  return true;
 }
 
-/*!
-  Sets Z-size of this view ( for both orthographic and perspective ). [ public ]
-*/
-void OCCViewer_ViewPort3d::setZSize( double zsize )
-{
-  myActiveView->SetZSize( zsize );
-  /*    if ( !myOrthoView.IsNull() )
-        myOrthoView->SetZSize( zsize );
-        if ( !myPerspView.IsNull() )
-        myPerspView->SetZSize( zsize );*/
-}
 
 /*!
   Get axial scale to the view
@@ -399,13 +358,13 @@ void OCCViewer_ViewPort3d::updateBackground()
       // set texture image: file name and fill mode
       switch ( textureMode ) {
       case Qtx::CenterTexture:
-       activeView()->SetBackgroundImage( fi.absoluteFilePath().toLatin1().constData(), Aspect_FM_CENTERED );
+       activeView()->SetBackgroundImage( fi.absoluteFilePath().toUtf8().constData(), Aspect_FM_CENTERED );
        break;
       case Qtx::TileTexture:
-       activeView()->SetBackgroundImage( fi.absoluteFilePath().toLatin1().constData(), Aspect_FM_TILED );
+       activeView()->SetBackgroundImage( fi.absoluteFilePath().toUtf8().constData(), Aspect_FM_TILED );
        break;
       case Qtx::StretchTexture:
-       activeView()->SetBackgroundImage( fi.absoluteFilePath().toLatin1().constData(), Aspect_FM_STRETCH );
+       activeView()->SetBackgroundImage( fi.absoluteFilePath().toUtf8().constData(), Aspect_FM_STRETCH );
        break;
       default:
        break;
@@ -496,7 +455,7 @@ void OCCViewer_ViewPort3d::startRotation( int x, int y,
     //activeView()->Gravity(gx,gy,gz);
 
     switch ( theRotationPointType ) {
-    case OCCViewer_ViewWindow::GRAVITY:
+    case OCCViewer_ViewWindow::BBCENTER:
       activeView()->StartRotation( x, y, 0.45 );
       break;
     case OCCViewer_ViewWindow::SELECTED:
@@ -538,7 +497,7 @@ void OCCViewer_ViewPort3d::rotate( int x, int y,
 {
   if ( !activeView().IsNull() ) {
     switch ( theRotationPointType ) {
-    case OCCViewer_ViewWindow::GRAVITY:
+    case OCCViewer_ViewWindow::BBCENTER:
       activeView()->Rotation( x, y );
       break;
     case OCCViewer_ViewWindow::SELECTED:
@@ -572,10 +531,6 @@ void OCCViewer_ViewPort3d::rotate( int x, int y,
 void OCCViewer_ViewPort3d::endRotation()
 {
   if ( !activeView().IsNull() ) {
-    activeView()->ZFitAll( 1.0 );
-#if OCC_VERSION_LARGE <= 0x06070100
-    activeView()->SetZSize( 0.0 );
-#endif
     activeView()->Update();
     emit vpTransformed( this );
   }
@@ -595,9 +550,9 @@ void OCCViewer_ViewPort3d::paintEvent( QPaintEvent* e )
 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
     QApplication::syncX();
 #endif
-    QRect rc = e->rect();
-    if ( !myPaintersRedrawing )
-      activeView()->Redraw( rc.x(), rc.y(), rc.width(), rc.height() );
+    if ( !myPaintersRedrawing ) {
+      activeView()->Redraw();
+    }
   }
   OCCViewer_ViewPort::paintEvent( e );
   myBusy = false;
@@ -616,21 +571,19 @@ void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e )
 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
     QApplication::syncX();
 #endif
-  if ( !activeView().IsNull() )
-    activeView()->MustBeResized();
+  QTimer::singleShot( 0, this, SLOT( repaintViewAfterMove() ) );
 }
 
 /*!
   Moved the viewport
 */
-/*
 void OCCViewer_ViewPort3d::repaintViewAfterMove( )
 {
   if ( !activeView().IsNull() ){
     activeView()->MustBeResized();
   }
 }
-*/
+
 /*!
   Fits all objects in view. [ virtual protected ]
 */
@@ -644,14 +597,8 @@ void OCCViewer_ViewPort3d::fitAll( bool keepScale, bool withZ, bool upd )
 
   Standard_Real margin = 0.01;
   
-#if OCC_VERSION_LARGE > 0x06070100
   activeView()->FitAll( margin, upd );
-  if(withZ)
-    activeView()->ZFitAll();
-#else 
-  activeView()->FitAll( margin, withZ, upd );
-#endif
-  activeView()->SetZSize(0.);
+
   emit vpTransformed( this );
 }
 
@@ -759,13 +706,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 > 0x06070100
     aView3d->Camera()->Copy( aRefView3d->Camera() );
-#else
-    aView3d->SetViewMapping( aRefView3d->ViewMapping() );
-    aView3d->SetViewOrientation( aRefView3d->ViewOrientation() );
-#endif
-    aView3d->ZFitAll();
     aView3d->SetImmediateUpdate( Standard_True );
     aView3d->Update();
     blockSignals( blocked );