X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOCCViewer%2FOCCViewer_ViewPort3d.cxx;h=73f89e2137839f024228ee8851d135612ebcb3ff;hb=331294345d3e1716fbf79ae25a2851011729be79;hp=06029fb30c09cf042bc534d694c289be73e27bb0;hpb=c4b058d18583af7f94042eb55d4b933dd222d2e6;p=modules%2Fgui.git diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 06029fb30..73f89e213 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 @@ -28,6 +28,8 @@ #include #include +#include +#include #include #include @@ -36,23 +38,17 @@ #include #include #include +#include -#include -#include - -#if OCC_VERSION_LARGE > 0x06070100 #include -#else -#include -#include -#endif +#include #include "utilities.h" #if defined WIN32 #include #else -#include +//#include #endif static double rx = 0.; @@ -75,20 +71,11 @@ 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 - setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background + setDefaultParams(); + + myCursor = NULL; } /*! @@ -96,6 +83,12 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V */ OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d() { + if ( myCursor ) + { + delete myCursor; + myCursor = NULL; + } + emit vpClosed(this); Handle(V3d_View) aView = activeView(); if (!aView.IsNull()) @@ -224,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 @@ -389,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; @@ -486,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: @@ -514,7 +483,8 @@ void OCCViewer_ViewPort3d::startRotation( int x, int y, default: break; } - activeView()->DepthFitAll(); + // VSR: 10.06.2015: next line commented out - causes ugly blinking on starting rotation with Perspective projection mode + //activeView()->DepthFitAll(); } } @@ -527,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: @@ -561,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 ); } @@ -581,10 +547,12 @@ void OCCViewer_ViewPort3d::paintEvent( QPaintEvent* e ) mapView( activeView() ); #endif if ( !myWindow.IsNull() ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) QApplication::syncX(); - QRect rc = e->rect(); - if ( !myPaintersRedrawing ) - activeView()->Redraw( rc.x(), rc.y(), rc.width(), rc.height() ); +#endif + if ( !myPaintersRedrawing ) { + activeView()->Redraw(); + } } OCCViewer_ViewPort::paintEvent( e ); myBusy = false; @@ -595,14 +563,25 @@ void OCCViewer_ViewPort3d::paintEvent( QPaintEvent* e ) */ void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e ) { -#ifdef WIN32 +#if defined WIN32 || QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) /* Win32 : map before first show to avoid flicker */ if ( !mapped( activeView() ) ) mapView( activeView() ); #endif - QApplication::syncX(); - if ( !activeView().IsNull() ) +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QApplication::syncX(); +#endif + QTimer::singleShot( 0, this, SLOT( repaintViewAfterMove() ) ); +} + +/*! + Moved the viewport +*/ +void OCCViewer_ViewPort3d::repaintViewAfterMove( ) +{ + if ( !activeView().IsNull() ){ activeView()->MustBeResized(); + } } /*! @@ -618,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 ); } @@ -733,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 ); @@ -764,3 +731,45 @@ void OCCViewer_ViewPort3d::showStaticTrihedron( bool on ) } aView->Update(); } + +/* + * Create default cursor with a specific shape + */ +void OCCViewer_ViewPort3d::setDefaultCursor( Qt::CursorShape theCursorShape ) +{ + if ( !myCursor ) + myCursor = new QCursor(); + + myCursor->setShape( theCursorShape ); +} + +/* + * Get default cursor with a specific shape + */ +QCursor* OCCViewer_ViewPort3d::getDefaultCursor() const +{ + return myCursor; +} + +/* + * Set default parameters from preferences + */ +void OCCViewer_ViewPort3d::setDefaultParams() +{ + setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background + + // get ray tracing parameters from preferences + int aDepth = SUIT_Session::session()->resourceMgr()->integerValue( "OCCViewer", "rt_depth", 3 ); + bool aReflection = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_reflection", true ); + bool anAntialiasing = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_antialiasing", false ); + bool aShadow = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_shadow", true ); + bool aTransparentShadow = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_trans_shadow", true ); + + Graphic3d_RenderingParams& aParams = myActiveView->ChangeRenderingParams(); + aParams.RaytracingDepth = aDepth; + aParams.IsReflectionEnabled = aReflection; + aParams.IsAntialiasingEnabled = anAntialiasing; + aParams.IsShadowEnabled = aShadow; + aParams.IsTransparentShadowEnabled = aTransparentShadow; + myActiveView->Redraw(); +}