PDA

View Full Version : setTransformOriginPoint changes the Item after transofrmation



aremar
27th November 2010, 21:31
Hi again,
I want to transform a QGraphicsItem , but I want to transform it around custom transformOriginPoint. That's why I made a class witch sends new transformOriginPoint to my Item. But when there are transformations already made, the change of transformOriginPoint, causes my transofrmation to be recalculated around the new transformOriginPoint and my Item hops. Can You help me to avoid this behavior?

nightroad
29th July 2011, 09:48
I have exactly same problem ...

aprayaga
26th September 2014, 15:48
I'm facing the same issue. In my opinion, changing transformOriginPoint should not affect the current graphic state but should only be applicable for only subsequent transformations. Can somebody explain why the transformation is recalculated and how can it be prevented?

wysota
28th September 2014, 08:13
The transformation is not really "recalculated". Each item has an internal transformation matrix that is used to transform it. If you add a new transformation then it modifies the transformation matrix and then the transformation is applied to the item using the set transform origin. Thus changing the origin affects all transformations as all operate on the same transformation matrix. A solution is to apply a translate operation to the item which moves the origin to where you want it to be, then apply the actual transformation you want to perform and then another translate operation that will reverse the effect of the first one. Alternatively you can probably set your operation on a separate transformation matrix and then multiply the two matrices.