return true;
}
+//================================================================
+// Function : setViewTransform
+// Purpose :
+//================================================================
+void GraphicsView_Object::setViewTransform( const QTransform& theTransform )
+{
+ myViewTransform = theTransform;
+}
+
//================================================================
// Function : centerPoint
// Purpose :
virtual bool handleMouseMove( QGraphicsSceneMouseEvent* ) { return false; }
virtual bool handleMouseRelease( QGraphicsSceneMouseEvent* ) { return false; }
+ virtual QTransform getViewTransform() const { return myViewTransform; }
+ virtual void setViewTransform( const QTransform& theTransform );
+
virtual QPointF centerPoint();
public:
bool myIsMoving;
+ QTransform myViewTransform;
+
private:
QCursor* myHighlightCursor;
};
//=======================================================================
GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::UnscaledGraphicsEllipseItem( QGraphicsItem* theParent )
: QGraphicsEllipseItem( theParent ),
- myRotationAngle( 0.0 ),
- myScale( 1.0 )
+ myRotationAngle( 0.0 )
{
}
{
QRectF aRect = QGraphicsEllipseItem::boundingRect();
- if( fabs( myScale ) < 1e-10 )
+ GraphicsView_Object* aParent = dynamic_cast<GraphicsView_Object*>( parentItem() );
+ if( !aParent )
+ return aRect;
+
+ QTransform aTransform = aParent->getViewTransform();
+ double aScale = aTransform.m11(); // same as m22(), viewer specific
+ if( fabs( aScale ) < 1e-10 )
return aRect;
QPointF aCenter = aRect.center();
- double aWidth = aRect.width() / myScale;
- double aHeight = aRect.height() / myScale;
+ double aWidth = aRect.width() / aScale;
+ double aHeight = aRect.height() / aScale;
- double anOffsetX = myOffset.x() / myScale;
- double anOffsetY = myOffset.y() / myScale;
+ double anOffsetX = myOffset.x() / aScale;
+ double anOffsetY = myOffset.y() / aScale;
aRect = QRectF( aCenter.x() - aWidth / 2 + anOffsetX,
aCenter.y() - aHeight / 2 + anOffsetY,
aWidth, aHeight );
+
return aRect;
}
const QStyleOptionGraphicsItem* theOption,
QWidget* theWidget )
{
- QTransform aTransform = thePainter->transform();
- aTransform.rotate( -myRotationAngle ); // exclude rotation from matrix
- myScale = aTransform.m11(); // same as m22(), viewer specific
-
// draw a connection line (mainly, for top-most anchor)
thePainter->drawLine( myBasePoint, boundingRect().center() );
QPointF myOffset;
double myRotationAngle;
- double myScale;
};
#endif
myNameLabel->setAcceptMoveEvents( true );
myIsTransforming = false;
+
+ applyTransform();
}
//================================================================
centerOn( theX, theY );
myIsTransforming = false;
+
+ applyTransform();
}
//================================================================
setTransform( aTransform );
myIsTransforming = false;
+
+ applyTransform();
}
//================================================================
fitInView( theRect, Qt::KeepAspectRatio );
myIsTransforming = false;
+
+ applyTransform();
}
//================================================================
}
myIsTransforming = false;
+
+ applyTransform();
}
//================================================================
fitInView( aRect.adjusted( -aGap, -aGap, aGap, aGap ), Qt::KeepAspectRatio );
myIsTransforming = false;
+
+ applyTransform();
}
//================================================================
ensureVisible( aLeft, aTop, aMargin, aMargin, 0, aGap );
myIsTransforming = false;
+
+ applyTransform();
+}
+
+//================================================================
+// Function : applyTransform
+// Purpose :
+//================================================================
+void GraphicsView_ViewPort::applyTransform()
+{
+ GraphicsView_ObjectListIterator anIter( getObjects() );
+ while( anIter.hasNext() )
+ if( GraphicsView_Object* anObject = anIter.next() )
+ anObject->setViewTransform( transform() );
}
//================================================================
bool isTransforming() const { return myIsTransforming; }
+ void applyTransform();
+
// block status
BlockStatus currentBlock();