X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGraphicsView%2FGraphicsView_Viewer.cxx;h=cc55ba5d7361d6457e0bc8f6f97680ee21e72fc0;hb=efe3cdefadc31ad9cdaa9fd7fc368e2931cebdf1;hp=0573ebb5e9c8b5b6a05676cc4feb543372a50cfa;hpb=d26f738c9c427a45409bacf3848fd8c224edf6ed;p=modules%2Fgui.git diff --git a/src/GraphicsView/GraphicsView_Viewer.cxx b/src/GraphicsView/GraphicsView_Viewer.cxx index 0573ebb5e..cc55ba5d7 100644 --- a/src/GraphicsView/GraphicsView_Viewer.cxx +++ b/src/GraphicsView/GraphicsView_Viewer.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -37,6 +37,8 @@ #include #include +#include + // testing ImageViewer /* #include "GraphicsView_PrsImage.h" @@ -48,10 +50,11 @@ // Name : GraphicsView_Viewer // Purpose : Constructor //======================================================================= -GraphicsView_Viewer::GraphicsView_Viewer( const QString& title ) +GraphicsView_Viewer::GraphicsView_Viewer( const QString& title, QWidget* widget ) : SUIT_ViewModel(), mySelector( 0 ), myTransformer( 0 ), + myWidget( widget ), myIsInitialized( false ) { } @@ -65,13 +68,18 @@ GraphicsView_Viewer::~GraphicsView_Viewer() delete mySelector; } +GraphicsView_ViewFrame* GraphicsView_Viewer::createViewFrame( SUIT_Desktop* theDesktop, QWidget* theWidget ) +{ + return new GraphicsView_ViewFrame( theDesktop, this, theWidget ); +} + //================================================================ // Function : createView // Purpose : //================================================================ SUIT_ViewWindow* GraphicsView_Viewer::createView( SUIT_Desktop* theDesktop ) { - GraphicsView_ViewFrame* aViewFrame = new GraphicsView_ViewFrame( theDesktop, this ); + GraphicsView_ViewFrame* aViewFrame = createViewFrame( theDesktop, myWidget ); connect( aViewFrame, SIGNAL( keyPressed( QKeyEvent* ) ), this, SLOT( onKeyEvent( QKeyEvent* ) ) ); @@ -398,7 +406,9 @@ void GraphicsView_Viewer::handleMousePress( QGraphicsSceneMouseEvent* e ) } else if( e->button() == Qt::LeftButton && !( aViewPort->currentBlock() & GraphicsView_ViewPort::BS_Selection ) && - !aViewPort->getHighlightedObject() ) + !aViewPort->getHighlightedObject() && + ( !aViewPort->isDraggingSelectedByLeftButton() || + aViewPort->isDraggingSelectedByLeftButton() && aViewPort->nbSelected() == 0 ) ) { // Start rectangular selection if pulling was not started QPoint p = aViewPort->mapFromScene( e->scenePos() ); @@ -520,6 +530,16 @@ void GraphicsView_Viewer::handleWheel( QGraphicsSceneWheelEvent* e ) { if( GraphicsView_ViewPort* aViewPort = getActiveViewPort() ) { + if( aViewPort->hasInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling ) ) + { + const double d = 1.05; + double q = pow( d, e->delta()/120 ); + QGraphicsView::ViewportAnchor old_anchor = aViewPort->transformationAnchor(); + aViewPort->setTransformationAnchor( QGraphicsView::AnchorUnderMouse ); + aViewPort->scale( q, q ); + aViewPort->setTransformationAnchor( old_anchor ); + } + if( aViewPort->hasInteractionFlag( GraphicsView_ViewPort::WheelScaling ) ) { bool anIsScaleUp = e->delta() > 0;