myFitAllGap = 40;
myIsTraceBoundingRectEnabled = true;
+ // interaction flags
+ myInteractionFlags = All;
+
// background
setBackgroundBrush( QBrush( Qt::white ) );
myIsTraceBoundingRectEnabled = theState;
}
+//================================================================
+// Function : setInteractionFlags
+// Purpose :
+//================================================================
+void GraphicsView_ViewPort::setInteractionFlags( const int theFlags )
+{
+ myInteractionFlags |= theFlags;
+}
+
+//================================================================
+// Function : clearInteractionFlags
+// Purpose :
+//================================================================
+void GraphicsView_ViewPort::clearInteractionFlags( const int theFlags )
+{
+ myInteractionFlags &= ~theFlags;
+}
+
+//================================================================
+// Function : testInteractionFlags
+// Purpose :
+//================================================================
+bool GraphicsView_ViewPort::testInteractionFlags( const int theFlags ) const
+{
+ return ( myInteractionFlags & theFlags ) == theFlags;
+}
+
//================================================================
// Function : setViewNameEnabled
// Purpose :
{
case QEvent::GraphicsSceneMousePress:
{
- bool anAccel = e->modifiers() & GraphicsView_ViewTransformer::accelKey();
- if( ( getHighlightedObject() &&
- getHighlightedObject()->isMovable() &&
- !( anAccel || e->button() == Qt::RightButton ) ) ||
- ( nbSelected() && !anAccel && e->button() == Qt::MidButton ) )
- myIsDragging = true;
+ if( testInteractionFlags( Dragging ) )
+ {
+ bool anAccel = e->modifiers() & GraphicsView_ViewTransformer::accelKey();
+ if( ( getHighlightedObject() &&
+ getHighlightedObject()->isMovable() &&
+ !( anAccel || e->button() == Qt::RightButton ) ) ||
+ ( nbSelected() && !anAccel && e->button() == Qt::MidButton ) )
+ myIsDragging = true;
+ }
break;
}
case QEvent::GraphicsSceneMouseMove:
public:
class NameLabel;
+ enum InteractionFlags
+ {
+ Dragging = 0x0001,
+ WheelScaling = 0x0002,
+ All = Dragging | WheelScaling
+ };
+
enum BlockStatus
{
BS_NoBlock = 0x0000,
void setFitAllGap( double theFitAllGap );
void setTraceBoundingRectEnabled( bool theState );
+ // interaction flags
+ void setInteractionFlags( const int );
+ void clearInteractionFlags( const int );
+ bool testInteractionFlags( const int ) const;
+
// view name
void setViewNamePosition( NamePosition thePosition,
bool theIsForced = false );
bool myIsTraceBoundingRectEnabled;
GraphicsView_ObjectList myObjects;
+ // interaction flags
+ int myInteractionFlags;
+
// view name
NameLabel* myNameLabel;
NamePosition myNamePosition;
{
if( GraphicsView_ViewPort* aViewPort = getActiveViewPort() )
{
- bool anIsScaleUp = e->delta() > 0;
- bool anIsCtrl = e->modifiers() & Qt::ControlModifier;
+ if( aViewPort->testInteractionFlags( GraphicsView_ViewPort::WheelScaling ) )
+ {
+ 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;
+ 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();
- aViewPort->onBoundingRectChanged();
+ if( anIsScaleChanged )
+ {
+ emit wheelScaleChanged();
+ aViewPort->onBoundingRectChanged();
+ }
}
}
}