PDA

View Full Version : QTransform doubts .



tonnot
25th July 2011, 14:13
I have my QTranform defined and applied to the Painter of a QWidget.
It works fine, I draw my objetcs .
I have two questions unresolved
1.- 'Map' works bad. ( I have very strange results)
I dont understand how I can draw right and however the map function return bad coords
2.- Setwindow and setviewport gives me the same results of Qtransform??
Thanks

ChrisW67
26th July 2011, 02:18
I have two questions unresolved
1.- 'Map' works bad. ( I have very strange results)
I dont understand how I can draw right and however the map function return bad coords

What is the question? You don't tell us what exactly you are doing or expecting so we don't know exactly what to tell you.


2.- Setwindow and setviewport gives me the same results of Qtransform??

Maybe, they are possibly related: Window-Viewport Conversion

tonnot
26th July 2011, 19:05
For the question 1, I can draw my objects ok (in the custom world I have defined using Qtransform).
But Qtransform.Map (mouse_x, mouse_y, realX, realY) does not give me correct values for realX and realY.
Thanks.

wysota
26th July 2011, 19:16
Care to give an example?

tonnot
26th July 2011, 20:36
AFT.reset(); // AFT is a Qtranform
AFT.translate(scrollh, scrollv); // pixles
AFT.scale(escalex, -escaley); // escale = widget pixels siz e / world
AFT.translate(-xc, -yc); // center of my world


I have two private vars double real_x, real_y;
And at mousemove event

mouse_x = event->pos().x(); mouse_y = event->pos().y();
AFT.map(mouse_x,mouse_y, &real_x, &real_y);

My world is : -70,70,30,30 (xmin,xmax, ymin,ymax) , a widget size of 600x300 and center of my world 0,800.
I draw a line from -70,790 to 70,810 without any problem
I have real coords in range : 300 3000 (x) 3200 - 4000 ?????

My code was exactly as one I have developed on Java. Java has AFT.inversetransform (and it worked fine )
Thanks.