virtual int getPriority() const { return myPriority; }
+ virtual bool isOnTop() const { return myIsOnTop; }
+ virtual void setIsOnTop( bool theIsOnTop ) { myIsOnTop = theIsOnTop; }
+
virtual bool isSelectable() const { return true; }
virtual bool isMovable() const { return true; }
virtual void finishPulling() {}
virtual bool isPulling() { return false; }
+ virtual bool handleMousePress( QGraphicsSceneMouseEvent* ) { return false; }
+ virtual bool handleMouseMove( QGraphicsSceneMouseEvent* ) { return false; }
+ virtual bool handleMouseRelease( QGraphicsSceneMouseEvent* ) { return false; }
+
protected:
virtual bool checkHighlight( double theX, double theY ) const;
QString myName;
int myPriority;
+ bool myIsOnTop;
bool myIsHighlighted;
bool myIsSelected;
// to append selected objects after their non-selected siblings with similar priority
int aCurrentPriority = -1;
GraphicsView_ObjectList aSelectedObjects;
+ GraphicsView_ObjectList aTopmostObjects;
GraphicsView_ObjectList aList;
GraphicsView_ObjectListIterator anIter( myObjects );
{
if( GraphicsView_Object* anObject = anIter.next() )
{
+ if( anObject->isOnTop() )
+ {
+ aTopmostObjects.append( anObject );
+ continue;
+ }
+
int aPriority = anObject->getPriority();
if( aPriority > aCurrentPriority )
{
aSelectedObjects.clear();
}
+ aList.append( aTopmostObjects );
+
return aList;
}
{
emit vpMouseEvent( e );
+ bool anIsHandled = false;
switch( e->type() )
{
case QEvent::GraphicsSceneMousePress:
{
- if( testInteractionFlags( Dragging ) )
+ if( nbSelected() )
+ for( initSelected(); moreSelected() && !anIsHandled; nextSelected() )
+ if( GraphicsView_Object* anObject = selectedObject() )
+ anIsHandled = anObject->handleMousePress( e );
+
+ if( !anIsHandled && 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;
+ myIsDragging = true;
}
break;
}
case QEvent::GraphicsSceneMouseMove:
{
- if( !isPulling() && myIsDragging )
+ if( nbSelected() )
+ for( initSelected(); moreSelected() && !anIsHandled; nextSelected() )
+ if( GraphicsView_Object* anObject = selectedObject() )
+ anIsHandled = anObject->handleMousePress( e );
+
+ if( !anIsHandled && !isPulling() && myIsDragging )
dragObjects( e );
break;
}
case QEvent::GraphicsSceneMouseRelease:
{
- if( !isPulling() && myIsDragging )
+ if( nbSelected() )
+ for( initSelected(); moreSelected() && !anIsHandled; nextSelected() )
+ if( GraphicsView_Object* anObject = selectedObject() )
+ anIsHandled = anObject->handleMousePress( e );
+
+ if( !anIsHandled && !isPulling() && myIsDragging )
{
emit vpObjectBeforeMoving();