[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Fwd: Re: seeking QGraphicsView wisdom
From: Jason Harris <kstars () 30doradus ! org>
Date: 2006-05-31 14:26:00
Message-ID: 200605310726.00183.kstars () 30doradus ! org
[Download RAW message or body]
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 <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic