[Qt-interest] Translation of a graphicsItem

Sujan Dasmahapatra sdh at lmglasfiber.com
Tue Jun 30 08:58:58 CEST 2009


Dear Shashank and all

I am facing the same rotation problem for translation.I want to
translate my graphicsitem to a point (dx,dy) with respect to scene
coordinate..so I am trying lilke this

QPointF centreScene(dx,dy);

QPointF centreItem = geometry->mapFromScene(centreScene);

Geometry->translate(centreItem.x(),centreItem.y());

 

But it's failing after translating for the first time it stops it
doesn't translate 2nd  time onwards.Please reply.          

 

 

Kind regards, 
Sujan Dasmahapatra
  

From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Shashank Singh
Sent: Monday, June 29, 2009 8:25 PM
To: Sean Harmer
Cc: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Rotation of a graphicsItem

 

hi
if it's only one item in scene ,you rotate the view itslef,,you will get
the same effect

On Mon, Jun 29, 2009 at 7:21 PM, Sean Harmer
<sean.harmer at maps-technology.com> wrote:

Hi,


On Monday 29 Jun 2009 10:21:49 Sujan Dasmahapatra wrote:
> Dear Friends
>
> For rotating a graphicsitem about an  arbitrary point(x,y)
>
> I am doing like this
>
> geometry->translate(xc,yc);
> geometry->rotate(angle);
> geometry->translate(-xc,-yc);
>
> but its rotating about the point on the graphicsitem itself I want to
> roate it with respect to view coordinate system.what I am doing wrong
> here.

You need to map the coordinates of the point in the scene coord system
about
which you wish to rotate into local item coordinates. for e.g.

// Centre of rotation in scene coords
QPointF centreScene( 0.0, 0.0 );

// Centre of rotation in item coords
QPointF centreItem = mapFromScene( centreScene );

// Do the translate, rotate, rtanslate back again thing
translate( centreItem.x(), centreItem.y() );
rotate( angle );
translate( -centreItem.x(), -centreItem.y() );

HTH,

Sean


_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




-- 
Regards:
Shashank Singh
Associate - Software | New Technologies team
Geodesic Limited |  <http://www.geodesic.com> 
Tel: +91 22 2831 2872 

Blog:http://techfreaks4u.com/blog
Marble contributor : http://edu.kde.org/marble/
KDE-in Volunteer : http://www.kde.in/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090630/3128852e/attachment.html 


More information about the Qt-interest-old mailing list