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 =
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 {
144 addComponent(m_Catalogs = new CatalogsComponent(this, path, true), 5);
145 }
146 else
147 {
148 KStars::Instance()->close();
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
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{
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)
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 o = m_SolarSystem->findByName(name);
576 if (o)
577 return o;
578 o = m_Catalogs->findByName(name, exact);
579 if (o)
580 return o;
581 o = m_CNames->findByName(name);
582 if (o)
583 return o;
584 o = m_Stars->findByName(name);
585 if (o)
586 return o;
587 o = m_Supernovae->findByName(name);
588 if (o)
589 return o;
590 o = m_Satellites->findByName(name);
591 if (o)
592 return o;
593
594 return nullptr;
595}
596
597SkyObject *SkyMapComposite::findStarByGenetiveName(const QString name)
598{
599 return m_Stars->findStarByGenetiveName(name);
600}
601
602KSPlanetBase *SkyMapComposite::planet(int n)
603{
604 if (n == KSPlanetBase::SUN)
605 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Sun"))));
606 if (n == KSPlanetBase::MERCURY)
607 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Mercury"))));
608 if (n == KSPlanetBase::VENUS)
609 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Venus"))));
610 if (n == KSPlanetBase::MOON)
611 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Moon"))));
612 if (n == KSPlanetBase::MARS)
613 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Mars"))));
614 if (n == KSPlanetBase::JUPITER)
615 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Jupiter"))));
616 if (n == KSPlanetBase::SATURN)
617 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Saturn"))));
618 if (n == KSPlanetBase::URANUS)
619 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Uranus"))));
620 if (n == KSPlanetBase::NEPTUNE)
621 return dynamic_cast<KSPlanetBase *>((m_SolarSystem->findByName(i18n("Neptune"))));
622 //if ( n == KSPlanetBase::PLUTO ) return (KSPlanetBase*)(m_SolarSystem->findByName( i18n( "Pluto" ) ) );
623
624 return nullptr;
625}
626
627void SkyMapComposite::reloadCLines()
628{
629#ifndef KSTARS_LITE
632 true); // This is not (yet) multithreaded, so I think we don't have to worry about overwriting the state of an existing lock --asimha
633 removeComponent(m_CLines);
634 delete m_CLines;
635 addComponent(m_CLines = new ConstellationLines(this, m_Cultures.get()));
637#endif
638}
639
640void SkyMapComposite::reloadCNames()
641{
642 // Q_ASSERT( !SkyMapDrawAbstract::drawLock() );
643 // 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
644 // objectNames(SkyObject::CONSTELLATION).clear();
645 // delete m_CNames;
646 // m_CNames = 0;
647 // m_CNames = new ConstellationNamesComponent( this, m_Cultures.get() );
648 // SkyMapDrawAbstract::setDrawLock( false );
649 objectNames(SkyObject::CONSTELLATION).clear();
650 objectLists(SkyObject::CONSTELLATION).clear();
651 removeComponent(m_CNames);
652 delete m_CNames;
653 addComponent(m_CNames = new ConstellationNamesComponent(this, m_Cultures.get()));
654}
655
656void SkyMapComposite::reloadConstellationArt()
657{
658#ifndef KSTARS_LITE
661 removeComponent(m_ConstellationArt);
662 delete m_ConstellationArt;
663 addComponent(m_ConstellationArt =
664 new ConstellationArtComponent(this, m_Cultures.get()));
666#endif
667}
668
669void SkyMapComposite::reloadDeepSky()
670{
671#ifndef KSTARS_LITE
673
674 // Deselect object if selected! If not deselected then InfoBox tries to
675 // get the name of an object which may not exist (getLongName)
676 // FIXME (spacetime): Is there a better way?
677 // Current Solution: Look for the nearest star in the region and select it.
678
680 double maxrad = 30.0;
681 SkyPoint center_point = current_map->getCenterPoint();
682
683 current_map->setClickedObject(
684 KStars::Instance()->data()->skyComposite()->starNearest(&center_point, maxrad));
685 current_map->setClickedPoint(current_map->clickedObject());
686 current_map->slotCenter();
687
688 // Remove and Regenerate set of catalog objects
689 //
690 // FIXME: Why should we do this? Because it messes up observing
691 // list really bad to delete and regenerate SkyObjects.
693
694 // FIXME: We should also reload anything that refers to SkyObject
695 // * in memory, because all the old SkyObjects are now gone! This
696 // includes the observing list. Otherwise, expect a bad, bad crash
697 // that is hard to debug! -- AS
698 m_Catalogs->dropCache();
700#endif
701}
702
703bool SkyMapComposite::isLocalCNames()
704{
705 return m_CNames->isLocalCNames();
706}
707
709{
710 emit progressText(message);
711#ifndef Q_OS_ANDROID
712 //Can cause crashes on Android, investigate it
713 qApp->processEvents(); // -jbb: this seemed to make it work.
714#endif
715 //qCDebug(KSTARS) << QString("PROGRESS TEXT: %1\n").arg( message );
716}
717
718const QList<SkyObject *> &SkyMapComposite::constellationNames() const
719{
720 return m_CNames->objectList();
721}
722
723// Returns only named stars, and should not be used
724const QList<SkyObject *> &SkyMapComposite::stars() const
725{
726 return m_Stars->objectList();
727}
728
729const QList<SkyObject *> &SkyMapComposite::asteroids() const
730{
731 return m_SolarSystem->asteroids();
732}
733
734const QList<SkyObject *> &SkyMapComposite::comets() const
735{
736 return m_SolarSystem->comets();
737}
738
739const QList<SkyObject *> &SkyMapComposite::supernovae() const
740{
741 return m_Supernovae->objectList();
742}
743
744QList<SkyObject *> SkyMapComposite::planets()
745{
746 return solarSystemComposite()->planetObjects();
747}
748
749//Store it permanently
750/*
751QList<SkyObject*> SkyMapComposite::moons()
752{
753 QList<SkyObject*> skyObjects;
754 foreach(PlanetMoonsComponent *pMoons, m_SolarSystem->planetMoonsComponent()) {
755 PlanetMoons *moons = pMoons->getMoons();
756 for(int i = 0; i < moons->nMoons(); ++i) {
757 skyObjects.append(moons->moon(i));
758 }
759 }
760 return skyObjects;
761}
762*/
763
764const QList<SkyObject *> *SkyMapComposite::getSkyObjectsList(SkyObject::TYPE t)
765{
766 switch (t)
767 {
768 case SkyObject::STAR:
769 return &m_Stars->objectList();
770 case SkyObject::CATALOG_STAR:
771 return nullptr;
772 case SkyObject::PLANET:
773 return &m_SolarSystem->planetObjects();
774 case SkyObject::COMET:
775 return &comets();
776 case SkyObject::ASTEROID:
777 return &asteroids();
778 case SkyObject::MOON:
779 return &m_SolarSystem->moons();
780 case SkyObject::GALAXY:
781 case SkyObject::PLANETARY_NEBULA:
782 case SkyObject::GASEOUS_NEBULA:
783 case SkyObject::GLOBULAR_CLUSTER:
784 case SkyObject::OPEN_CLUSTER:
785 return nullptr;
786 case SkyObject::CONSTELLATION:
787 return &constellationNames();
788 case SkyObject::SUPERNOVA:
789 return &supernovae();
790 default:
791 return nullptr;
792 }
793 //return nullptr;
794}
795
796KSPlanet *SkyMapComposite::earth()
797{
798 return m_SolarSystem->earth();
799}
800
801QStringList SkyMapComposite::getCultureNames()
802{
803 return m_Cultures->getNames();
804}
805
806QString SkyMapComposite::getCultureName(int index)
807{
808 return m_Cultures->getName(index);
809}
810
811void SkyMapComposite::setCurrentCulture(QString culture)
812{
813 m_Cultures->setCurrent(culture);
814}
815
816QString SkyMapComposite::currentCulture()
817{
818 return m_Cultures->current();
819}
820#ifndef KSTARS_LITE
821FlagComponent *SkyMapComposite::flags()
822{
823 return m_Flags;
824}
825#endif
826
827SatellitesComponent *SkyMapComposite::satellites()
828{
829 return m_Satellites;
830}
831
832SupernovaeComponent *SkyMapComposite::supernovaeComponent()
833{
834 return m_Supernovae;
835}
836
837ArtificialHorizonComponent *SkyMapComposite::artificialHorizon()
838{
839 return m_ArtificialHorizon;
840}
841
842ImageOverlayComponent *SkyMapComposite::imageOverlay()
843{
844 return m_ImageOverlay;
845}
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
static KStars * Instance()
Definition kstars.h:123
static bool Closing
Set to true when the application is being closed.
Definition kstars.h:855
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:57
Renders Mosaic Panel on Sky Map in either of two modes depending on scheduler.
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.
This is the canvas on which the sky is painted.
Definition skymap.h:54
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.