33 QMap<int, SkyMesh *> SkyMesh::pinstances;
34 int SkyMesh::defaultLevel = -1;
39 newInstance = pinstances.value( level, NULL );
41 newInstance =
new SkyMesh( level );
42 pinstances.insert( level, newInstance );
43 if( defaultLevel < 0 )
44 defaultLevel = newInstance->
level();
50 return pinstances.value( defaultLevel, NULL );
55 return pinstances.value( level, NULL );
60 m_drawID(0), m_KSNumbers( 0 )
72 p1.apparentCoord( now,
J2000 );
74 if ( radius == 1.0 ) {
76 printf(
" ra1 = %8.4f dec1 = %8.4f\n", p1.ra().Degrees(), p1.dec().Degrees() );
80 printf(
" ra2 = %8.4f dec2 = %8.4f\n", p2.ra().Degrees(), p2.dec().Degrees() );
89 if ( m_inDraw && bufNum !=
DRAW_BUF )
90 printf(
"Warining: overlapping buffer: %d\n", bufNum);
107 double ra1, ra2, dec1, dec2;
119 if ( m_inDraw && bufNum !=
DRAW_BUF )
120 printf(
"Warining: overlapping buffer: %d\n", bufNum);
147 p2.x() * 15.0, p2.y(),
148 p3.x() * 15.0, p3.y() );
151 void SkyMesh::index(
const QPointF &p1,
const QPointF &p2,
const QPointF &p3,
const QPointF &p4 )
154 p2.x() * 15.0, p2.y(),
155 p3.x() * 15.0, p3.y(),
156 p4.x() * 15.0, p4.y() );
170 if ( points->size() == 0 )
return indexHash;
172 pLast = points->at( 0 );
173 for (
int i=1 ; i < points->size() ; i++ ) {
174 pThis = points->at( i );
180 indexHash[ region.
next() ] =
true;
196 if ( points->size() == 0 )
return indexHash;
198 pLast = points->at( 0 );
199 for (
int i=1 ; i < points->size() ; i++ ) {
200 pThis = points->at( i );
202 if (skip != NULL && skip->contains( i ) ) {
207 index( pThis, pLast );
210 if ( region.
size() > errLimit ) {
211 printf(
"\nSkyMesh::indexLine: too many trixels: %d\n", region.
size() );
212 printf(
" ra1 = %f;\n", pThis->
ra0().
Degrees());
213 printf(
" ra2 = %f;\n", pLast->
ra0().
Degrees());
217 index( pThis, pLast );
226 indexHash[ region.
next() ] =
true;
246 if (points->size() < 3)
return indexHash;
250 int end = points->size() - 2;
253 for(
int p = 1; p <= end; p+= 2 ) {
256 index( startP, points->at(p), points->at(p+1) );
259 index( startP, points->at(p), points->at(p+1), points->at(p+2) );
264 if ( region.
size() > errLimit ) {
265 printf(
"\nSkyMesh::indexPoly: too many trixels: %d\n", region.
size() );
267 printf(
" ra1 = %f;\n", startP->
ra0().
Degrees());
268 printf(
" ra2 = %f;\n", points->at(p)->ra0().Degrees());
269 printf(
" ra3 = %f;\n", points->at(p+1)->ra0().Degrees());
271 printf(
" ra4 = %f;\n", points->at(p+2)->ra0().Degrees());
274 printf(
" dec2 = %f;\n", points->at(p)->dec0().Degrees());
275 printf(
" dec3 = %f;\n", points->at(p+1)->dec0().Degrees());
277 printf(
" dec4 = %f;\n", points->at(p+2)->dec0().Degrees());
283 indexHash[ region.
next() ] =
true;
293 if (points->size() < 3)
return indexHash;
295 const QPointF startP = points->first();
297 int end = points->size() - 2;
299 for(
int p = 1; p <= end; p+= 2 ) {
302 index( startP, points->at(p), points->at(p+1) );
305 index( startP, points->at(p), points->at(p+1), points->at(p+2) );
310 if ( region.
size() > errLimit ) {
311 printf(
"\nSkyMesh::indexPoly: too many trixels: %d\n", region.
size() );
313 printf(
" ra1 = %f;\n", startP.x() );
314 printf(
" ra2 = %f;\n", points->at(p).x() );
315 printf(
" ra3 = %f;\n", points->at(p+1).x()) ;
317 printf(
" ra4 = %f;\n", points->at(p+2).x() );
319 printf(
" dec1 = %f;\n", startP.y() );
320 printf(
" dec2 = %f;\n", points->at(p).y() );
321 printf(
" dec3 = %f;\n", points->at(p+1).y() );
323 printf(
" dec4 = %f;\n", points->at(p+2).y());
329 indexHash[ region.
next() ] =
true;
346 double r1, d1, r2, d2, r3, d3;
351 vertices( trixel, &r1, &d1, &r2, &d2, &r3, &d3 );
361 psky.drawLine( q1, q2 );
362 psky.drawLine( q2, q3 );
363 psky.drawLine( q3, q1 );
365 QString TrixelNumberString;
366 TrixelNumberString.setNum( trixel );
367 psky.drawText( (q1 + q2 + q3 ) / 3.0, TrixelNumberString );
377 skylist << &p1 << &p2 << &p3 << &p4;
const IndexHash & indexPoly(SkyList *points)
Trixel index(double ra, double dec) const
void draw(QPainter &psky, MeshBufNum_t bufNum=DRAW_BUF)
QVector< SkyPoint * > SkyList
KStarsData is the backbone of KStars.
QHash< Trixel, bool > SkyRegion
static KStarsData * Instance()
const double & Degrees() const
static SkyMesh * Create(int level)
virtual void updateCoords(KSNumbers *num, bool includePlanets=true, const dms *lat=0, const dms *LST=0, bool forceRecompute=false)
Determine the current coordinates (RA, Dec) from the catalog coordinates (RA0, Dec0), accounting for both precession and nutation.
Trixel indexStar(StarObject *star)
void getIndexCoords(KSNumbers *num, double *ra, double *dec)
void intersect(double ra, double dec, double radius, BufNum bufNum=0)
finds the trixels that cover the specified circle
The sky coordinates of a point in the sky.
QPointF toScreen(const SkyPoint *o, bool oRefract=true, bool *onVisibleHemisphere=0) const
This is exactly the same as toScreenVec but it returns a QPointF.
void aperture(SkyPoint *center, double radius, MeshBufNum_t bufNum=DRAW_BUF)
finds the set of trixels that cover the circular aperture specified after first performing a reverse ...
void vertices(Trixel id, double *ra1, double *dec1, double *ra2, double *dec2, double *ra3, double *dec3)
long double julianDay() const
static SkyMesh * Instance()
const SkyRegion & skyRegion(const SkyPoint &p1, const SkyPoint &p2)
returns the sky region needed to cover the rectangle defined by two SkyPoints p1 and p2 ...
void EquatorialToHorizontal(const dms *LST, const dms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates, given the local sidereal time and the observer's latitude.
const IndexHash & indexStarLine(SkyList *points)
This is the canvas on which the sky is painted.
static SkyMap * Instance()
const IndexHash & indexLine(SkyList *points)
QHash< Trixel, bool > IndexHash
This is a subclass of SkyObject.
Trixel index(const SkyPoint *p)
const Projector * projector() const
Get the current projector.
dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle=0) const
Computes the angular distance between two SkyObjects.