From kde-devel Wed May 31 14:26:00 2006 From: Jason Harris Date: Wed, 31 May 2006 14:26:00 +0000 To: kde-devel Subject: Re: Fwd: Re: seeking QGraphicsView wisdom Message-Id: <200605310726.00183.kstars () 30doradus ! org> X-MARC-Message: https://marc.info/?l=kde-devel&m=114908721105433 On Wednesday 31 May 2006 07:04, Andreas Aardal Hanssen wrote: > On Wednesday 31 May 2006 15:45, Jason Harris wrote: > > As long as the shapes are small compared to the radius of the sphere, you > > can trivially use the local tangent plane to draw these shapes in the > > QPolygonF QGraphicsView::mapToScene(const QRect &rect) const > > How much sense does this make for a scene that operates in > spherical coordinates? > It makes perfect sense. So this function will map an input QRect (in the spherical coordinate system) to a QPolygonF in screen coordinates, right? That's easy. Pseudocode for the override would look something like: QPolygonF SphericalView::mapToScene( const QRect &rect ) { QPolygonF result; //The edges need to be composed of short //line-segments to account for their curvature //SphericalView assumes that the input coordinates are in degrees. //line segments 1 degree long are sufficiently short. //Start at the bottom left corner, go around the perimeter //counter-clockwise int x = rect.left(); int y = rect.bottom(); int s = 1 while ( x < rect.right() ) result << toScreen( x++, y ); while ( y < rect.top() ) result << toScreen( x, y++ ); while ( x > rect.left() ) result << toScreen( x--, y ); while ( y > rect.bottom() ) result << toScreen( x, y-- ); return result; } Voila! Jason -- KStars: http://edu.kde.org/kstars Community Forums: http://kstars.30doradus.org >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<