QGraphicsScene::mouseDoubleClickEvent( e );
}
+//================================================================
+// Function : wheelEvent
+// Purpose :
+//================================================================
+void GraphicsView_Scene::wheelEvent( QGraphicsSceneWheelEvent* e )
+{
+ emit gsWheelEvent( e );
+
+ // accept the event to prevent calling QAbstractScrollArea::wheelEvent()
+ // from QGraphicsView::wheelEvent(), which will change values of scroll-bars
+ e->accept();
+
+ //QGraphicsScene::wheelEvent( e ); // don't uncomment
+}
+
//================================================================
// Function : contextMenuEvent
// Purpose :
#include "GraphicsView_Viewer.h"
+#include "GraphicsView_Object.h"
#include "GraphicsView_Selector.h"
#include "GraphicsView_Scene.h"
#include "GraphicsView_ViewFrame.h"
{
switch( e->type() )
{
- case QEvent::Wheel:
+ case QEvent::GraphicsSceneWheel:
handleWheel( e );
break;
default: break;
void GraphicsView_Viewer::handleMouseRelease( QGraphicsSceneMouseEvent* e )
{
// selection
- if( e->button() == Qt::LeftButton &&
- !( getActiveViewPort()->currentBlock() & GraphicsView_ViewPort::BS_Selection ) )
+ if( GraphicsView_ViewPort* aViewPort = getActiveViewPort() )
{
- if ( getSelector() )
+ if( e->button() == Qt::LeftButton &&
+ !( aViewPort->currentBlock() & GraphicsView_ViewPort::BS_Selection ) )
{
- bool append = bool ( e->modifiers() & GraphicsView_Selector::getAppendKey() );
- getSelector()->select( QRectF(), append );
+ if ( getSelector() )
+ {
+ bool append = bool ( e->modifiers() & GraphicsView_Selector::getAppendKey() );
+ getSelector()->select( QRectF(), append );
+ }
}
}
void GraphicsView_Viewer::startOperations( QGraphicsSceneMouseEvent* e )
{
GraphicsView_ViewPort* aViewPort = getActiveViewPort();
+ if( !aViewPort )
+ return;
// If the 'immediate selection' mode is enabled,
// try to perform selection before invoking context menu
bool GraphicsView_Viewer::updateOperations( QGraphicsSceneMouseEvent* e )
{
GraphicsView_ViewPort* aViewPort = getActiveViewPort();
+ if( !aViewPort )
+ return false;
if( aViewPort->isPulling() )
{
bool GraphicsView_Viewer::finishOperations( QGraphicsSceneMouseEvent* e )
{
GraphicsView_ViewPort* aViewPort = getActiveViewPort();
+ if( !aViewPort )
+ return false;
if( aViewPort->isPulling() )
{
return false;
}
+
+//================================================================
+// Function : startOperations
+// Purpose :
+//================================================================
+void GraphicsView_Viewer::startOperations( QGraphicsSceneWheelEvent* e )
+{
+ GraphicsView_ViewPort* aViewPort = getActiveViewPort();
+ if( !aViewPort )
+ return;
+
+ bool anIsScaleUp = e->delta() > 0;
+ bool anIsCtrl = e->modifiers() & Qt::ControlModifier;
+
+ bool anIsScaleChanged = false;
+ for( aViewPort->initSelected(); aViewPort->moreSelected(); aViewPort->nextSelected() )
+ if( GraphicsView_Object* anObject = aViewPort->selectedObject() )
+ anIsScaleChanged = anObject->updateScale( anIsScaleUp, anIsCtrl ) || anIsScaleChanged;
+
+ if( anIsScaleChanged )
+ emit wheelScaleChanged();
+}
signals:
void selectionChanged( GV_SelectionChangeStatus );
+ void wheelScaleChanged();
protected:
virtual GraphicsView_ViewTransformer* createTransformer( int );
virtual void startOperations( QGraphicsSceneMouseEvent* );
virtual bool updateOperations( QGraphicsSceneMouseEvent* );
virtual bool finishOperations( QGraphicsSceneMouseEvent* );
- virtual void startOperations( QGraphicsSceneWheelEvent* ) {}
+ virtual void startOperations( QGraphicsSceneWheelEvent* );
protected slots:
virtual void onMouseEvent( QGraphicsSceneMouseEvent* );