Kstars

skymapcomposite.cpp
1/*
2 SPDX-FileCopyrightText: 2005 Thomas Kabelmann <thomas.kabelmann@gmx.de>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "skymapcomposite.h"
8
9#include "artificialhorizoncomponent.h"
10#include "catalogsdb.h"
11#include "constellationartcomponent.h"
12#include "constellationboundarylines.h"
13#include "constellationlines.h"
14#include "constellationnamescomponent.h"
15#include "culturelist.h"
16#include "deepstarcomponent.h"
17#include "catalogscomponent.h"
18#include "ecliptic.h"
19#include "equator.h"
20#include "equatorialcoordinategrid.h"
21#include "horizoncomponent.h"
22#include "horizontalcoordinategrid.h"
23#include "localmeridiancomponent.h"
24#include "ksasteroid.h"
25#include "kscomet.h"
26#include <kmessagebox.h>
27#ifndef KSTARS_LITE
28#include "kstars.h"
29#endif
30#include "kstarsdata.h"
31#include "milkyway.h"
32#include "satellitescomponent.h"
33#include "skylabeler.h"
34#include "skypainter.h"
35#include "solarsystemcomposite.h"
36#include "starcomponent.h"
37#include "supernovaecomponent.h"
38#include "targetlistcomponent.h"
39#include "projections/projector.h"
40#include "skyobjects/ksplanet.h"
41#include "skyobjects/constellationsart.h"
42
43#ifndef KSTARS_LITE
44#include "flagcomponent.h"
45#include "ksutils.h"
46#include "observinglist.h"
47#include "skymap.h"
48#include "hipscomponent.h"
49#include "terraincomponent.h"
50#include "imageoverlaycomponent.h"
51#include "mosaiccomponent.h"
52#endif
53
54#include <QApplication>
55
56#include <kstars_debug.h>
57
59 : SkyComposite(parent), m_reindexNum(J2000)
60{
61 m_skyLabeler.reset(SkyLabeler::Instance());
62 m_skyMesh = SkyMesh::Create(3); // level 5 mesh = 8192 trixels
63 m_skyMesh->debug(0);
64 // 1 => print "indexing ..."
65 // 2 => prints totals too
66 // 10 => prints detailed lists
67 // You can also set the debug level of individual
68 // appendLine() and appendPoly() calls.
69
70 //Add all components
71 //Stars must come before constellation lines
72#ifdef KSTARS_LITE
73 addComponent(m_MilkyWay = new MilkyWay(this), 50);
74 addComponent(m_Stars = StarComponent::Create(this), 10);
75 addComponent(m_EquatorialCoordinateGrid = new EquatorialCoordinateGrid(this));
76 addComponent(m_HorizontalCoordinateGrid = new HorizontalCoordinateGrid(this));
77
78 // Do add to components.
79 addComponent(m_CBoundLines = new ConstellationBoundaryLines(this), 80);
80 m_Cultures.reset(new CultureList());
81 addComponent(m_CLines = new ConstellationLines(this, m_Cultures.get()), 85);
82 addComponent(m_CNames = new ConstellationNamesComponent(this, m_Cultures.get()), 90);
83 addComponent(m_Equator = new Equator(this), 95);
84 addComponent(m_Ecliptic = new Ecliptic(this), 95);
85 addComponent(m_Horizon = new HorizonComponent(this), 100);
87 m_ConstellationArt = new ConstellationArtComponent(this, m_Cultures.get()), 100);
88
89 addComponent(m_ArtificialHorizon = new ArtificialHorizonComponent(this), 110);
90
91 QStringList allcatalogs = Options::showCatalogNames();
92
93 Options::setShowCatalogNames(allcatalogs);
94
95 addComponent(m_SolarSystem = new SolarSystemComposite(this), 2);
96
97 //addComponent( m_ObservingList = new TargetListComponent( this , 0, QPen(),
98 // &Options::obsListSymbol, &Options::obsListText ), 120 );
99 addComponent(m_StarHopRouteList = new TargetListComponent(this, 0, QPen()), 130);
100 addComponent(m_Satellites = new SatellitesComponent(this), 7);
101 addComponent(m_Supernovae = new SupernovaeComponent(this), 7);
102 SkyMapLite::Instance()->loadingFinished();
103#else
104 addComponent(m_MilkyWay = new MilkyWay(this), 50);
105 addComponent(m_Stars = StarComponent::Create(this), 10);
106 addComponent(m_EquatorialCoordinateGrid = new EquatorialCoordinateGrid(this));
107 addComponent(m_HorizontalCoordinateGrid = new HorizontalCoordinateGrid(this));
108 addComponent(m_LocalMeridianComponent = new LocalMeridianComponent(this));
109
110 // Do add to components.
111 addComponent(m_CBoundLines = new ConstellationBoundaryLines(this), 80);
112 m_Cultures.reset(new CultureList());
113 addComponent(m_CLines = new ConstellationLines(this, m_Cultures.get()), 85);
114 addComponent(m_CNames = new ConstellationNamesComponent(this, m_Cultures.get()), 90);
115 addComponent(m_Equator = new Equator(this), 95);
116 addComponent(m_Ecliptic = new Ecliptic(this), 95);
117 addComponent(m_Horizon = new HorizonComponent(this), 100);
118
119 const auto &path = CatalogsDB::dso_db_path();
120 try
121 {
122 addComponent(m_Catalogs = new CatalogsComponent(this, path, !QFile::exists(path)),
123 5);
124 }
125 catch (const CatalogsDB::DatabaseError &e)
126 {
127 KMessageBox::detailedError(nullptr, i18n("Failed to load the DSO database."),
128 e.what());
129
130 const auto &backup_path =
131 QString("%1.%2").arg(path).arg(QDateTime::currentDateTime().toTime_t());
132
133 const auto &answer = KMessageBox::questionYesNo(
134 nullptr,
135 i18n("Do you want to start over with an empty database?\n"
136 "This will move the current DSO database \"%1\"\n"
137 "to \"%2\"",
138 path, backup_path),
139 "Start over?");
140
141 if (answer == KMessageBox::Yes)
142 {
143 QFile::rename(path, backup_path);
144 addComponent(m_Catalogs = new CatalogsComponent(this, path, true), 5);
145 }
146 else
147 {
149 }
150 }
151
153 m_ConstellationArt = new ConstellationArtComponent(this, m_Cultures.get()), 100);
154
155 // Hips
156 addComponent(m_HiPS = new HIPSComponent(this));
157
158 addComponent(m_Terrain = new TerrainComponent(this));
159
160 addComponent(m_ImageOverlay = new ImageOverlayComponent(this));
161
162 // Mosaic Component
163#ifdef HAVE_INDI
164 addComponent(m_Mosaic = new MosaicComponent(this));
165#endif
166
167 addComponent(m_ArtificialHorizon = new ArtificialHorizonComponent(this), 110);
168
169 addComponent(m_SolarSystem = new SolarSystemComposite(this), 2);
170
171 addComponent(m_Flags = new FlagComponent(this), 4);
172
173 addComponent(m_ObservingList = new TargetListComponent(this, nullptr, QPen(),
174 &Options::obsListSymbol,
175 &Options::obsListText),
176 120);
177 addComponent(m_StarHopRouteList = new TargetListComponent(this, nullptr, QPen()),
178 130);
179 addComponent(m_Satellites = new SatellitesComponent(this), 7);
180 addComponent(m_Supernovae = new SupernovaeComponent(this), 7);
181#endif
182 connect(this, SIGNAL(progressText(QString)), KStarsData::Instance(),
183 SIGNAL(progressText(QString)));
184}
185
187{
188 //printf("updating SkyMapComposite\n");
189 //1. Milky Way
190 //m_MilkyWay->update( data, num );
191 //2. Coordinate grid
192 //m_EquatorialCoordinateGrid->update( num );
193 m_HorizontalCoordinateGrid->update(num);
194#ifndef KSTARS_LITE
195 m_LocalMeridianComponent->update(num);
196#endif
197 //3. Constellation boundaries
198 //m_CBounds->update( data, num );
199 //4. Constellation lines
200 //m_CLines->update( data, num );
201 //5. Constellation names
202 if (m_CNames)
203 m_CNames->update(num);
204 //6. Equator
205 //m_Equator->update( data, num );
206 //7. Ecliptic
207 //m_Ecliptic->update( data, num );
208 //8. Deep sky
209 //m_DeepSky->update( data, num );
210 //10. Stars
211 //m_Stars->update( data, num );
212 //m_CLines->update( data, num ); // MUST follow stars.
213
214 //12. Solar system
215 m_SolarSystem->update(num);
216 //13. Satellites
217 m_Satellites->update(num);
218 //14. Supernovae
219 m_Supernovae->update(num);
220 //15. Horizon
221 m_Horizon->update(num);
222#ifndef KSTARS_LITE
223 //16. Flags
224 m_Flags->update(num);
225#endif
226}
227
229{
230 m_SolarSystem->updateSolarSystemBodies(num);
231}
232
234{
235 m_SolarSystem->updateMoons(num);
236}
237
238//Reimplement draw function so that we have control over the order of
239//elements, and we can add object labels
240//
241//The order in which components are drawn naturally determines the
242//z-ordering (the layering) of the components. Objects which
243//should appear "behind" others should be drawn first.
245{
246 Q_UNUSED(skyp)
247#ifndef KSTARS_LITE
248 SkyMap *map = SkyMap::Instance();
249 KStarsData *data = KStarsData::Instance();
250
251 // We delay one draw cycle before re-indexing
252 // we MUST ensure CLines do not get re-indexed while we use DRAW_BUF
253 // so we do it here.
254 m_CLines->reindex(&m_reindexNum);
255 // This queues re-indexing for the next draw cycle
256 m_reindexNum = KSNumbers(data->updateNum()->julianDay());
257
258 // This ensures that the JIT updates are synchronized for the entire draw
259 // cycle so the sky moves as a single sheet. May not be needed.
260 data->syncUpdateIDs();
261
262 // prepare the aperture
263 // FIXME_FOV: We may want to rejigger this to allow
264 // wide-angle views --hdevalence
265 float radius = map->projector()->fov();
266 if (radius > 180.0 && SkyMap::Instance()->projector()->type() != Projector::Stereographic)
267 radius = 180.0;
268
269 if (m_skyMesh->inDraw())
270 {
271 printf("Warning: aborting concurrent SkyMapComposite::draw()\n");
272 return;
273 }
274
275 m_skyMesh->inDraw(true);
276 SkyPoint *focus = map->focus();
277 m_skyMesh->aperture(focus, radius + 1.0, DRAW_BUF); // divide by 2 for testing
278
279 // create the no-precess aperture if needed
280 if (Options::showEquatorialGrid() || Options::showHorizontalGrid() ||
281 Options::showCBounds() || Options::showEquator())
282 {
283 m_skyMesh->index(focus, radius + 1.0, NO_PRECESS_BUF);
284 }
285
286 // clear marks from old labels and prep fonts
287 m_skyLabeler->reset(map);
288 m_skyLabeler->useStdFont();
289
290 // info boxes have highest label priority
291 // FIXME: REGRESSION. Labeler now know nothing about infoboxes
292 // map->infoBoxes()->reserveBoxes( psky );
293
294 // JM 2016-12-01: Why is this done this way?!! It's too inefficient
295 if (KStars::Instance())
296 {
297 auto &obsList = KStarsData::Instance()->observingList()->sessionList();
298
299 if (Options::obsListText())
300 for (auto &obj_clone : obsList)
301 {
302 // Find the "original" obj
304 obj_clone->name()); // FIXME: This is slow.... and can also fail!!!
305 if (!o)
306 continue;
307 SkyLabeler::AddLabel(o, SkyLabeler::RUDE_LABEL);
308 }
309 }
310
311 m_MilkyWay->draw(skyp);
312
313 // Draw HIPS after milky way but before everything else
314 m_HiPS->draw(skyp);
315
316 if (Options::showImageOverlaysBelowCatalogs())
317 // Draw fits overlay.
318 m_ImageOverlay->draw(skyp);
319
320 m_EquatorialCoordinateGrid->draw(skyp);
321 m_HorizontalCoordinateGrid->draw(skyp);
322 m_LocalMeridianComponent->draw(skyp);
323
324 //Draw constellation boundary lines only if we draw western constellations
325 if (m_Cultures->current() == "Western")
326 {
327 m_CBoundLines->draw(skyp);
328 m_ConstellationArt->draw(skyp);
329 }
330 else if (m_Cultures->current() == "Inuit")
331 {
332 m_ConstellationArt->draw(skyp);
333 }
334
335 m_CLines->draw(skyp);
336
337 m_Equator->draw(skyp);
338
339 m_Ecliptic->draw(skyp);
340
341 m_Catalogs->draw(skyp);
342
343 m_Stars->draw(skyp);
344
345 m_SolarSystem->drawTrails(skyp);
346 m_SolarSystem->draw(skyp);
347
348 m_Satellites->draw(skyp);
349
350 m_Supernovae->draw(skyp);
351
352 map->drawObjectLabels(labelObjects());
353
354 m_skyLabeler->drawQueuedLabels();
355 m_CNames->draw(skyp);
356 m_Stars->drawLabels();
357
358 m_ObservingList->pen =
359 QPen(QColor(data->colorScheme()->colorNamed("ObsListColor")), 1.);
360 m_ObservingList->list2 = KStarsData::Instance()->observingList()->sessionList();
361 m_ObservingList->draw(skyp);
362
363 m_Flags->draw(skyp);
364
365 m_StarHopRouteList->pen =
366 QPen(QColor(data->colorScheme()->colorNamed("StarHopRouteColor")), 1.);
367 m_StarHopRouteList->draw(skyp);
368
369 if (!Options::showImageOverlaysBelowCatalogs())
370 // Draw fits overlay before mosaic and terrain/horizon, but after most things.
371 m_ImageOverlay->draw(skyp);
372
373#ifdef HAVE_INDI
374 m_Mosaic->draw(skyp);
375#endif
376
377 m_ArtificialHorizon->draw(skyp);
378
379 m_Horizon->draw(skyp);
380
381 m_skyMesh->inDraw(false);
382
383 // Draw terrain at the end.
384 m_Terrain->draw(skyp);
385
386 // DEBUG Edit. Keywords: Trixel boundaries. Currently works only in QPainter mode
387 // -jbb uncomment these to see trixel outlines:
388 /*
389 QPainter *psky = dynamic_cast< QPainter *>( skyp );
390 if( psky ) {
391 qCDebug(KSTARS) << "Drawing trixel boundaries for debugging.";
392 psky->setPen( QPen( QBrush( QColor( "yellow" ) ), 1, Qt::SolidLine ) );
393 m_skyMesh->draw( *psky, OBJ_NEAREST_BUF );
394 SkyMesh *p;
395 if( p = SkyMesh::Instance( 6 ) ) {
396 qCDebug(KSTARS) << "We have a deep sky mesh to draw";
397 p->draw( *psky, OBJ_NEAREST_BUF );
398 }
399
400 psky->setPen( QPen( QBrush( QColor( "green" ) ), 1, Qt::SolidLine ) );
401 m_skyMesh->draw( *psky, NO_PRECESS_BUF );
402 if( p )
403 p->draw( *psky, NO_PRECESS_BUF );
404 }
405 */
406#endif
407}
408
409//Select nearest object to the given skypoint, but give preference
410//to certain object types.
411//we multiply each object type's smallest angular distance by the
412//following factors before selecting the final nearest object:
413// faint stars > 12th mag = 1.75
414// stars > 4 and < 12 = 1.5
415// stars brighter than 4th mag = 0.75
416// custom object = 0.5
417// Solar system = 0.25
419{
420 double rTry = maxrad;
421 double rBest = maxrad;
422 SkyObject *oTry = nullptr;
423 SkyObject *oBest = nullptr;
424
425 //printf("%.1f %.1f\n", p->ra().Degrees(), p->dec().Degrees() );
426 m_skyMesh->aperture(p, maxrad + 1.0, OBJ_NEAREST_BUF);
427
428 oBest = m_Stars->objectNearest(p, rBest);
429 //reduce rBest by 0.75 for stars brighter than 4th mag
430 if (oBest && oBest->mag() < 4.0)
431 rBest *= 0.75;
432 // For stars fainter than 12th mag
433 else if (oBest && oBest->mag() > 12.0)
434 rBest *= 2.00;
435 // For stars between 4th and 12th mag
436 else if (oBest)
437 rBest *= 2.5;
438
439 oTry = m_Satellites->objectNearest(p, rTry);
440 if (rTry < rBest)
441 {
442 rBest = rTry;
443 oBest = oTry;
444 }
445
446 for (auto &star : m_DeepStars)
447 {
448 rTry = maxrad;
449 oTry = star->objectNearest(p, rTry);
450 if (rTry < rBest)
451 {
452 rBest = rTry;
453 oBest = oTry;
454 }
455 }
456
457 rTry = maxrad;
458 oTry = m_Catalogs->objectNearest(p, rTry);
459 if (oTry && rTry < rBest)
460 {
461 rBest = rTry;
462 oBest = oTry;
463 }
464
465 rTry = maxrad;
466 oTry = m_Supernovae->objectNearest(p, rTry);
467 //qCDebug(KSTARS)<<rTry<<rBest<<maxrad;
468 if (rTry < rBest)
469 {
470 rBest = rTry;
471 oBest = oTry;
472 }
473
474 rTry = maxrad;
475 oTry = m_SolarSystem->objectNearest(p, rTry);
476 if (!dynamic_cast<KSComet *>(oTry) &&
477 !dynamic_cast<KSAsteroid *>(
478 oTry)) // There are gazillions of faint asteroids and comets; we want to prevent them from getting precedence
479 {
480 rTry *=
481 0.25; // this is either sun, moon, or one of the major planets or their moons.
482 }
483 else
484 {
485 if (std::isfinite(oTry->mag()) && oTry->mag() < 12.0)
486 {
487 rTry *= 0.75; // Bright comets / asteroids get some precedence.
488 }
489 }
490 if (rTry < rBest)
491 {
492 rBest = rTry;
493 oBest = oTry;
494 }
495
496 //if ( oBest && Options::verboseLogging())
497 //qCDebug(KSTARS) << "OBEST=" << oBest->name() << " - " << oBest->name2();
498 maxrad = rBest;
499 return oBest; //will be 0 if no object nearer than maxrad was found
500}
501
503{
504 double rtry = maxrad;
505 SkyObject *star = nullptr;
506
507 m_skyMesh->aperture(p, maxrad + 1.0, OBJ_NEAREST_BUF);
508
509 star = m_Stars->objectNearest(p, rtry);
510 //reduce rBest by 0.75 for stars brighter than 4th mag
511 if (star && star->mag() < 4.0)
512 rtry *= 0.75;
513
514 // TODO: Add Deep Star Catalog support
515
516 maxrad = rtry;
517 return star;
518}
519
520bool SkyMapComposite::addNameLabel(SkyObject *o)
521{
522 if (!o)
523 return false;
524 labelObjects().append(o);
525 return true;
526}
527
528bool SkyMapComposite::removeNameLabel(SkyObject *o)
529{
530 if (!o)
531 return false;
532 int index = labelObjects().indexOf(o);
533 if (index < 0)
534 return false;
535 labelObjects().removeAt(index);
536 return true;
537}
538
539QHash<int, QStringList> &SkyMapComposite::getObjectNames()
540{
541 return m_ObjectNames;
542}
543
544QHash<int, QVector<QPair<QString, const SkyObject *>>> &SkyMapComposite::getObjectLists()
545{
546 return m_ObjectLists;
547}
548
550 const SkyPoint &p2)
551{
552 const SkyRegion &region = m_skyMesh->skyRegion(p1, p2);
554 // call objectsInArea( QList<SkyObject*>&, const SkyRegion& ) for each of the
555 // components of the SkyMapComposite
556 if (m_Stars->selected())
557 m_Stars->objectsInArea(list, region);
558 if (m_Catalogs->selected())
559 m_Catalogs->objectsInArea(list, region);
560 return list;
561}
562
564{
565#ifndef KSTARS_LITE
566 if (KStars::Closing)
567 return nullptr;
568#endif
569
570 //We search the children in an "intelligent" order (most-used
571 //object types first), in order to avoid wasting too much time
572 //looking for a match. The most important part of this ordering
573 //is that stars should be last (because the stars list is so long)
574 SkyObject *o = nullptr;
575 if ((o = m_SolarSystem->findByName(name, exact)))
576 return o;
577 if ((o = m_Catalogs->findByName(name, exact)))
578 return o;
579 if ((o = m_CNames->findByName(name, exact)))
580 return o;
581 if ((o = m_Stars->findByName(name, exact)))
582 return o;
583 if ((o = m_Supernovae->findByName(name, exact)))
584 return o;
585 if ((o = m_Satellites->findByName(name, exact)))
586 return o;
587
588 return nullptr;
589}
590
591SkyObject *SkyMapComposite::findStarByGenetiveName(const QString name)
592{
593 return m_Stars->findStarByGenetiveName(name);
594}
595
596KSPlanetBase *SkyMapComposite::planet(int n)
597{
598 if (n == KSPlanetBase::SUN)
599 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Sun"))));
600 if (n == KSPlanetBase::MERCURY)
601 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Mercury"))));
602 if (n == KSPlanetBase::VENUS)
603 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Venus"))));
604 if (n == KSPlanetBase::MOON)
605 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Moon"))));
606 if (n == KSPlanetBase::MARS)
607 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Mars"))));
608 if (n == KSPlanetBase::JUPITER)
609 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Jupiter"))));
610 if (n == KSPlanetBase::SATURN)
611 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Saturn"))));
612 if (n == KSPlanetBase::URANUS)
613 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Uranus"))));
614 if (n == KSPlanetBase::NEPTUNE)
615 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Neptune"))));
616 //if ( n == KSPlanetBase::PLUTO ) return (KSPlanetBase*)(m_SolarSystem->findByName( i18n( "Pluto" ) ) );
617
618 return nullptr;
619}
620
621void SkyMapComposite::reloadCLines()
622{
623#ifndef KSTARS_LITE
624 Q_ASSERT(!SkyMapDrawAbstract::drawLock());
626 true); // This is not (yet) multithreaded, so I think we don't have to worry about overwriting the state of an existing lock --asimha
627 removeComponent(m_CLines);
628 delete m_CLines;
629 addComponent(m_CLines = new ConstellationLines(this, m_Cultures.get()));
631#endif
632}
633
634void SkyMapComposite::reloadCNames()
635{
636 // Q_ASSERT( !SkyMapDrawAbstract::drawLock() );
637 // SkyMapDrawAbstract::setDrawLock( true ); // This is not (yet) multithreaded, so I think we don't have to worry about overwriting the state of an existing lock --asimha
638 // objectNames(SkyObject::CONSTELLATION).clear();
639 // delete m_CNames;
640 // m_CNames = 0;
641 // m_CNames = new ConstellationNamesComponent( this, m_Cultures.get() );
642 // SkyMapDrawAbstract::setDrawLock( false );
643 objectNames(SkyObject::CONSTELLATION).clear();
644 objectLists(SkyObject::CONSTELLATION).clear();
645 removeComponent(m_CNames);
646 delete m_CNames;
647 addComponent(m_CNames = new ConstellationNamesComponent(this, m_Cultures.get()));
648}
649
650void SkyMapComposite::reloadConstellationArt()
651{
652#ifndef KSTARS_LITE
653 Q_ASSERT(!SkyMapDrawAbstract::drawLock());
655 removeComponent(m_ConstellationArt);
656 delete m_ConstellationArt;
657 addComponent(m_ConstellationArt =
658 new ConstellationArtComponent(this, m_Cultures.get()));
660#endif
661}
662
663void SkyMapComposite::reloadDeepSky()
664{
665#ifndef KSTARS_LITE
666 Q_ASSERT(!SkyMapDrawAbstract::drawLock());
667
668 // Deselect object if selected! If not deselected then InfoBox tries to
669 // get the name of an object which may not exist (getLongName)
670 // FIXME (spacetime): Is there a better way?
671 // Current Solution: Look for the nearest star in the region and select it.
672
673 SkyMap *current_map = KStars::Instance()->map();
674 double maxrad = 30.0;
675 SkyPoint center_point = current_map->getCenterPoint();
676
677 current_map->setClickedObject(
678 KStars::Instance()->data()->skyComposite()->starNearest(&center_point, maxrad));
679 current_map->setClickedPoint(current_map->clickedObject());
680 current_map->slotCenter();
681
682 // Remove and Regenerate set of catalog objects
683 //
684 // FIXME: Why should we do this? Because it messes up observing
685 // list really bad to delete and regenerate SkyObjects.
687
688 // FIXME: We should also reload anything that refers to SkyObject
689 // * in memory, because all the old SkyObjects are now gone! This
690 // includes the observing list. Otherwise, expect a bad, bad crash
691 // that is hard to debug! -- AS
692 m_Catalogs->dropCache();
694#endif
695}
696
697bool SkyMapComposite::isLocalCNames()
698{
699 return m_CNames->isLocalCNames();
700}
701
703{
704 emit progressText(message);
705#ifndef Q_OS_ANDROID
706 //Can cause crashes on Android, investigate it
707 qApp->processEvents(); // -jbb: this seemed to make it work.
708#endif
709 //qCDebug(KSTARS) << QString("PROGRESS TEXT: %1\n").arg( message );
710}
711
712const QList<SkyObject *> &SkyMapComposite::constellationNames() const
713{
714 return m_CNames->objectList();
715}
716
717// Returns only named stars, and should not be used
718const QList<SkyObject *> &SkyMapComposite::stars() const
719{
720 return m_Stars->objectList();
721}
722
723const QList<SkyObject *> &SkyMapComposite::asteroids() const
724{
725 return m_SolarSystem->asteroids();
726}
727
728const QList<SkyObject *> &SkyMapComposite::comets() const
729{
730 return m_SolarSystem->comets();
731}
732
733const QList<SkyObject *> &SkyMapComposite::supernovae() const
734{
735 return m_Supernovae->objectList();
736}
737
738QList<SkyObject *> SkyMapComposite::planets()
739{
740 return solarSystemComposite()->planetObjects();
741}
742
743//Store it permanently
744/*
745QList<SkyObject*> SkyMapComposite::moons()
746{
747 QList<SkyObject*> skyObjects;
748 foreach(PlanetMoonsComponent *pMoons, m_SolarSystem->planetMoonsComponent()) {
749 PlanetMoons *moons = pMoons->getMoons();
750 for(int i = 0; i < moons->nMoons(); ++i) {
751 skyObjects.append(moons->moon(i));
752 }
753 }
754 return skyObjects;
755}
756*/
757
758const QList<SkyObject *> *SkyMapComposite::getSkyObjectsList(SkyObject::TYPE t)
759{
760 switch (t)
761 {
762 case SkyObject::STAR:
763 return &m_Stars->objectList();
764 case SkyObject::CATALOG_STAR:
765 return nullptr;
766 case SkyObject::PLANET:
767 return &m_SolarSystem->planetObjects();
768 case SkyObject::COMET:
769 return &comets();
770 case SkyObject::ASTEROID:
771 return &asteroids();
772 case SkyObject::MOON:
773 return &m_SolarSystem->moons();
774 case SkyObject::GALAXY:
775 case SkyObject::PLANETARY_NEBULA:
776 case SkyObject::GASEOUS_NEBULA:
777 case SkyObject::GLOBULAR_CLUSTER:
778 case SkyObject::OPEN_CLUSTER:
779 return nullptr;
780 case SkyObject::CONSTELLATION:
781 return &constellationNames();
782 case SkyObject::SUPERNOVA:
783 return &supernovae();
784 default:
785 return nullptr;
786 }
787 //return nullptr;
788}
789
790KSPlanet *SkyMapComposite::earth()
791{
792 return m_SolarSystem->earth();
793}
794
795QStringList SkyMapComposite::getCultureNames()
796{
797 return m_Cultures->getNames();
798}
799
800QString SkyMapComposite::getCultureName(int index)
801{
802 return m_Cultures->getName(index);
803}
804
805void SkyMapComposite::setCurrentCulture(QString culture)
806{
807 m_Cultures->setCurrent(culture);
808}
809
810QString SkyMapComposite::currentCulture()
811{
812 return m_Cultures->current();
813}
814#ifndef KSTARS_LITE
815FlagComponent *SkyMapComposite::flags()
816{
817 return m_Flags;
818}
819#endif
820
821SatellitesComponent *SkyMapComposite::satellites()
822{
823 return m_Satellites;
824}
825
826SupernovaeComponent *SkyMapComposite::supernovaeComponent()
827{
828 return m_Supernovae;
829}
830
831ArtificialHorizonComponent *SkyMapComposite::artificialHorizon()
832{
833 return m_ArtificialHorizon;
834}
835
836ImageOverlayComponent *SkyMapComposite::imageOverlay()
837{
838 return m_ImageOverlay;
839}
Represents objects loaded from an sqlite backed, trixel indexed catalog.
SkyObject * objectNearest(SkyPoint *p, double &maxrad) override
Find the SkyObject nearest the given SkyPoint.
SkyObject * findByName(const QString &name, bool exact=true) override
Search the underlying database for an object with the name.
void objectsInArea(QList< SkyObject * > &list, const SkyRegion &region) override
Searches the region(s) and appends the SkyObjects found to the list of sky objects.
void dropCache()
Clear the internal cache and effectively reload all objects from the database.
bool selected() override
Wether to show the DSOs.
void draw(SkyPainter *skyp) override
Draws the objects in the currently visible trixels by dynamically loading them from the database.
Database related error, thrown when database access fails or an action does not succeed.
Definition catalogsdb.h:682
QColor colorNamed(const QString &name) const
Retrieve a color by name.
Represents the ConstellationsArt objects.
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Collection of lines making the 88 constellations.
Represents the constellation names on the sky map.
bool isLocalCNames()
Return true if we are using localized constellation names.
void update(KSNumbers *num) override
we need a custom routine (for now) so we don't precess the locations of the names.
void draw(SkyPainter *skyp) override
Draw constellation names on the sky map.
A list of all cultures FIXME: Why not use a QStringList?
Definition culturelist.h:17
Represents the ecliptic on the sky map.
Definition ecliptic.h:20
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Definition ecliptic.cpp:57
Represents the equator on the sky map.
Definition equator.h:20
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Definition equator.cpp:59
Collection of all the circles in the equatorial coordinate grid.
Represents a flag on the sky map.
void update(KSNumbers *num=nullptr) override
Update the sky position(s) of this component.
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Represents the HIPS progress survey overlay.
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Represents the horizon on the sky map.
void update(KSNumbers *) override
Update the sky position(s) of this component.
void draw(SkyPainter *skyp) override
Draw the Horizon on the Sky map.
Collection of all the circles in the horizontal coordinate grid.
void update(KSNumbers *) override
Update the sky position(s) of this component.
Represents the ImageOverlay overlay.
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
A subclass of KSPlanetBase that implements asteroids.
Definition ksasteroid.h:42
A subclass of KSPlanetBase that implements comets.
Definition kscomet.h:44
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
long double julianDay() const
Definition ksnumbers.h:91
A subclass of TrailObject that provides additional information needed for most solar system objects.
A subclass of KSPlanetBase for seven of the major planets in the solar system (Earth and Pluto have t...
Definition ksplanet.h:33
KStarsData is the backbone of KStars.
Definition kstarsdata.h:72
ColorScheme * colorScheme()
Definition kstarsdata.h:172
SkyMap * map() const
Definition kstars.h:141
static KStars * Instance()
Definition kstars.h:123
static bool Closing
Set to true when the application is being closed.
Definition kstars.h:862
void draw(SkyPainter *skyp) override
The top level draw routine.
SkyObject * findByName(const QString &name, bool exact=true) override
Search the children of this SkyComponent for a SkyObject whose name matches the argument name the nam...
Single local meridian line.
void update(KSNumbers *) override
Update the sky position(s) of this component.
Class that handles drawing of MilkyWay (both filled and non-filled)
Definition milkyway.h:25
void draw(SkyPainter *skyp) override
The top level draw routine.
Definition milkyway.cpp:60
Renders Mosaic Panel on Sky Map in either of two modes depending on scheduler.
QList< QSharedPointer< SkyObject > > & sessionList()
Represents artificial satellites on the sky map.
SkyObject * objectNearest(SkyPoint *p, double &maxrad) override
Search the nearest satellite from point p.
void draw(SkyPainter *skyp) override
Draw all satellites.
SkyObject * findByName(const QString &name, bool exact=true) override
Return object given name.
void update(KSNumbers *num) override
Update satellites position.
SkyComposite is a kind of container class for SkyComponent objects.
void addComponent(SkyComponent *comp, int priority=1024)
Add a new sub component to the composite comp Pointer to the SkyComponent to be added priority A prio...
void removeComponent(SkyComponent *const comp)
Remove a sub component from the composite comp Pointer to the SkyComponent to be removed.
SkyObject * objectNearest(SkyPoint *p, double &maxrad) override
Identify the nearest SkyObject to the given SkyPoint, among the children of this SkyComposite p point...
SkyObject * findByName(const QString &name, bool exact=true) override
Search the children of this SkyComposite for a SkyObject whose name matches the argument.
void draw(SkyPainter *skyp) override
Delegate draw requests to all sub components psky Reference to the QPainter on which to paint.
static void AddLabel(SkyObject *obj, label_t type)
static version of addLabel() below.
Definition skylabeler.h:135
SkyObject * findByName(const QString &name, bool exact=true) override
Search the children of this SkyMapComposite for a SkyObject whose name matches the argument.
SkyObject * starNearest(SkyPoint *p, double &maxrad)
void updateSolarSystemBodies(KSNumbers *num) override
Delegate planet position updates to the SolarSystemComposite.
void update(KSNumbers *num=nullptr) override
Delegate update-position requests to all sub components.
SkyMapComposite(SkyComposite *parent=nullptr)
Constructor parent pointer to the parent SkyComponent.
QList< SkyObject * > findObjectsInArea(const SkyPoint &p1, const SkyPoint &p2)
void draw(SkyPainter *skyp) override
Delegate draw requests to all sub components psky Reference to the QPainter on which to paint.
void emitProgressText(const QString &message) override
Emit signal about progress.
void updateMoons(KSNumbers *num) override
Delegate moon position updates to the SolarSystemComposite.
SkyObject * objectNearest(SkyPoint *p, double &maxrad) override
static void setDrawLock(bool state)
Acquire / release a draw lock.
void loadingFinished()
called when SkyMapComposite finished loading all SkyComponents
Definition skymaplite.h:301
This is the canvas on which the sky is painted.
Definition skymap.h:54
void setClickedPoint(const SkyPoint *f)
Set the ClickedPoint to the skypoint given as an argument.
Definition skymap.cpp:1012
void setClickedObject(SkyObject *o)
Set the ClickedObject pointer to the argument.
Definition skymap.cpp:366
SkyObject * clickedObject() const
Retrieve the object nearest to a mouse click event.
Definition skymap.h:244
void slotCenter()
Center the display at the point ClickedPoint.
Definition skymap.cpp:380
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
Definition skymesh.cpp:312
int debug() const
Returns the debug level.
Definition skymesh.h:255
static SkyMesh * Create(int level)
creates the single instance of SkyMesh.
Definition skymesh.cpp:25
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 ...
Definition skymesh.cpp:56
Trixel index(const SkyPoint *p)
returns the index of the trixel containing p.
Definition skymesh.cpp:74
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
float mag() const
Definition skyobject.h:206
TYPE
The type classification of the SkyObject.
Definition skyobject.h:112
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
The sky coordinates of a point in the sky.
Definition skypoint.h:45
The solar system composite manages all planets, asteroids and comets.
void update(KSNumbers *num) override
Delegate update-position requests to all sub components.
void drawTrails(SkyPainter *skyp) override
Draw trails for objects.
bool selected() override
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
SkyObject * objectNearest(SkyPoint *p, double &maxrad) override
Find the SkyObject nearest the given SkyPoint.
static StarComponent * Create(SkyComposite *)
Create an instance of StarComponent.
void drawLabels()
draw all the labels in the prioritized LabelLists and then clear the LabelLists.
void objectsInArea(QList< SkyObject * > &list, const SkyRegion &region) override
Searches the region(s) and appends the SkyObjects found to the list of sky objects.
This class encapsulates Supernovae.
void draw(SkyPainter *skyp) override
SkyObject * objectNearest(SkyPoint *p, double &maxrad) override
Find the SkyObject nearest the given SkyPoint.
void update(KSNumbers *num=nullptr) override
Update the sky positions of this component.
Highlights objects present in certain lists by drawing "target" symbols around them.
void draw(SkyPainter *skyp) override
Draw this component by iterating over the list.
QPen pen
Pen to use to draw.
QList< QSharedPointer< SkyObject > > list2
Pointer to list of objects to draw.
Represents the terrain overlay.
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
QString i18n(const char *text, const TYPE &arg...)
void detailedError(QWidget *parent, const QString &text, const QString &details, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
QDateTime currentDateTime()
bool exists() const const
bool rename(const QString &newName)
void clear()
void append(QList< T > &&value)
qsizetype indexOf(const AT &value, qsizetype from) const const
void removeAt(qsizetype i)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString arg(Args &&... args) const const
bool close()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 12 2024 12:00:41 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.