Qt-interest Archive, June 2007
FW: Translation Vs Move ?
Message 1 in thread
Thank you Bastian. That was enlightening.
But I still feel, I still wonder as to why pos() ignores the change in
position by translate(), for the items position has indeed changed in
scene co-ordinates and pos() should take care of it and return the
actual position in scene co-ordinates of the item irrespective of
transformation it has undergone.
--Prateek
-----Original Message-----
From: Bastian Dittmar [mailto:keulerman@xxxxxxxxxxx]
Sent: Tuesday, June 12, 2007 2:07 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: RE: Translation Vs Move ?
>Yup. You are correct Bastian. On translation, the position pos() does
>not change.
>But since it has the same visual effect as moveBy(), I wonder why
>dosent translate change the position of the item as well ? Why would
>one want to "move" an item and not change its position ?
>In that sense, If an application is a canvas application and needs to
>keep track of the positions of the items, is translate() is safe
>function to use ?
>As I understand, translate() should be used only if you would be
>translating the item back to its original position, such as if one
>wants to rotate/scale an item from any other point except the origin.
>Am I correct ?
>
>Is there are other place where one needs the translate function ?
>
>Thnx
>Prateek
>
>
You kind of answered your questions by yourself with what you said in
the end :) When you move an item to a new position it can be seen as a
transformation of the item which translated it by some offset sx and sy
(in 2D). Because an item might be often moved there is a function moveBy
which is a more efficient than the actual transformation. That raises
the question why not discarding translate as moveBY is more efficient...
well translate is more powerfull. Most complex transformations can be
divided into simpler operations as you already said, first translate,
rotate, ... All of them are expressed by a transformation matrix. The
beauty fo this is, that you can simply multiply the matrices to yield
the matrix for the complex transformation. This wouldnt work if you used
moveBY instead. You would need a single matrix for each accumulated
transformation until a translation occurs as it directly modifies the
item.
What you said is actually a great example. If you wanan have a different
rotation point than your item's origin you translate it, rotate and
translate back. At the end you have only ONE matrix that expresses the
whole transformation!!! If you would move it insteda of translation this
would be way less effecient. Of course there are other complex
transformations as well that need a translation.
If you wanna keep track of your item's position it depends on how you do
it i guess. I havent worked with QGraphicsView and QGraphicsItem yet. If
you are moving items from one point to another i would definately use
moveBy() and setPos() and to keep track i would use pos().
Sorry cant help you more with your main problem :(
_________________________________________________________________
Haben Spinnen Ohren? Finden Sie es heraus - mit dem MSN Suche Superquiz
via http://www.msn-superquiz.de Jetzt mitmachen und gewinnen!
--
[ signature omitted ]
Message 2 in thread
>Thank you Bastian. That was enlightening.
>
>But I still feel, I still wonder as to why pos() ignores the change in
>position by translate(), for the items position has indeed changed in
>scene co-ordinates and pos() should take care of it and return the
>actual position in scene co-ordinates of the item irrespective of
>transformation it has undergone.
>
>--Prateek
>
hmm,
conceptuelly i think this way is fine but maybe scenePos() should return the
actual position of the item within the scene also considering the applied
transformation (as the name already suggests). Did you try that?
As i said i havent really worked with transformations in Qt.
_________________________________________________________________
Sie suchen E-Mails, Dokumente oder Fotos? Die neue MSN Suche Toolbar mit
Windows-Desktopsuche liefert in sekundenschnelle Ergebnisse. Jetzt neu!
http://desktop.msn.de/ Jetzt gratis downloaden!
--
[ signature omitted ]
Message 3 in thread
Yeah. scenePos() gives the actual position in scene co-ordinates.
It all fits in now.
Thanx a lot !
-----Original Message-----
From: Bastian Dittmar [mailto:keulerman@xxxxxxxxxxx]
Sent: Tuesday, June 12, 2007 3:33 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: RE: FW: Translation Vs Move ?
>Thank you Bastian. That was enlightening.
>
>But I still feel, I still wonder as to why pos() ignores the change in
>position by translate(), for the items position has indeed changed in
>scene co-ordinates and pos() should take care of it and return the
>actual position in scene co-ordinates of the item irrespective of
>transformation it has undergone.
>
>--Prateek
>
hmm,
conceptuelly i think this way is fine but maybe scenePos() should return
the actual position of the item within the scene also considering the
applied transformation (as the name already suggests). Did you try that?
As i said i havent really worked with transformations in Qt.
_________________________________________________________________
Sie suchen E-Mails, Dokumente oder Fotos? Die neue MSN Suche Toolbar mit
Windows-Desktopsuche liefert in sekundenschnelle Ergebnisse. Jetzt neu!
http://desktop.msn.de/ Jetzt gratis downloaden!
--
[ signature omitted ]