11#include "dialogs/detaildialog.h"
12#include "dialogs/locationdialog.h"
13#include "dialogs/timedialog.h"
14#include "skyobjects/kssun.h"
15#include "skyobjects/ksmoon.h"
16#include "skycomponents/skymapcomposite.h"
17#include "tools/observinglist.h"
18#include "catalogsdb.h"
21#include <KLocalizedString>
30 :
QDialog(parent), session(_session), T0(_lt), geo(_geo)
35 WUT =
new WUTDialogUI(
this);
50 if (T0.time().hour() < 6)
54 T0.setTime(
QTime(0, 0, 0));
56 UT0 = geo->LTtoUT(T0);
59 Tomorrow = T0.addSecs(12 * 3600);
60 TomorrowUT = geo->LTtoUT(Tomorrow);
63 Evening = T0.addSecs(-6 * 3600);
64 EveningUT = geo->LTtoUT(Evening);
70 WUT->LocationLabel->setText(
i18n(
"at %1", sGeo));
71 WUT->DateLabel->setText(
74 WUT->MagnitudeEdit->setValue(m_Mag);
76 WUT->MagnitudeEdit->setSingleStep(0.100);
82void WUTDialog::makeConnections()
84 connect(WUT->DateButton, SIGNAL(clicked()), SLOT(slotChangeDate()));
85 connect(WUT->LocationButton, SIGNAL(clicked()), SLOT(slotChangeLocation()));
86 connect(WUT->CenterButton, SIGNAL(clicked()), SLOT(slotCenter()));
87 connect(WUT->DetailButton, SIGNAL(clicked()), SLOT(slotDetails()));
88 connect(WUT->ObslistButton, SIGNAL(clicked()), SLOT(slotObslist()));
89 connect(WUT->CategoryListWidget, SIGNAL(currentTextChanged(
QString)),
91 connect(WUT->ObjectListWidget, SIGNAL(currentTextChanged(
QString)),
92 SLOT(slotDisplayObject(
QString)));
93 connect(WUT->EveningMorningBox, SIGNAL(activated(
int)),
94 SLOT(slotEveningMorning(
int)));
95 connect(WUT->MagnitudeEdit, SIGNAL(valueChanged(
double)),
96 SLOT(slotChangeMagnitude()));
99void WUTDialog::initCategories()
101 m_Categories <<
i18n(
"Planets") <<
i18n(
"Stars") <<
i18n(
"Nebulae")
102 <<
i18n(
"Galaxies") <<
i18n(
"Star Clusters") <<
i18n(
"Constellations")
103 <<
i18n(
"Asteroids") <<
i18n(
"Comets");
105 foreach (
const QString &c, m_Categories)
106 WUT->CategoryListWidget->addItem(c);
108 WUT->CategoryListWidget->setCurrentRow(0);
113 QString sRise, sSet, sDuration;
118 foreach (
const QString &c, m_Categories)
121 visibleObjects(c).clear();
125 m_CategoryInitialized[c] =
false;
133 sunRiseTomorrow = oSun->
riseSetTime(TomorrowUT, geo,
true);
134 sunSetToday = oSun->
riseSetTime(EveningUT, geo,
false);
135 sunRiseToday = oSun->
riseSetTime(EveningUT, geo,
true);
140 CachingDms LST = geo->GSTtoLST(T0.gst());
145 if (oSun->
alt().Degrees() > 0.0)
147 sRise =
i18n(
"circumpolar");
148 sSet =
i18n(
"circumpolar");
150 Dur = hDur = mDur = 0;
154 sRise =
i18n(
"does not rise");
155 sSet =
i18n(
"does not rise");
167 Dur = 24.0 + (float)sunRiseTomorrow.
hour() +
168 (float)sunRiseTomorrow.
minute() / 60.0 +
169 (float)sunRiseTomorrow.
second() / 3600.0 - (float)sunSetToday.
hour() -
170 (float)sunSetToday.
minute() / 60.0 - (float)sunSetToday.
second() / 3600.0;
172 mDur = int(60.0 * (Dur - (
float)hDur));
173 QTime tDur(hDur, mDur);
179 WUT->SunSetLabel->setText(
180 i18nc(
"Sunset at time %1 on date %2",
"Sunset: %1 on %2", sSet,
182 WUT->SunRiseLabel->setText(
183 i18nc(
"Sunrise at time %1 on date %2",
"Sunrise: %1 on %2", sRise,
186 WUT->NightDurationLabel->setText(
i18n(
"Night duration: %1", sDuration));
188 WUT->NightDurationLabel->setText(
i18n(
"Night duration: %1 hours", sDuration));
190 WUT->NightDurationLabel->setText(
i18n(
"Night duration: %1 hour", sDuration));
192 WUT->NightDurationLabel->setText(
i18n(
"Night duration: %1 minutes", sDuration));
194 WUT->NightDurationLabel->setText(
i18n(
"Night duration: %1 minute", sDuration));
205 if (oMoon->
alt().Degrees() > 0.0)
207 sRise =
i18n(
"circumpolar");
208 sSet =
i18n(
"circumpolar");
212 sRise =
i18n(
"does not rise");
213 sSet =
i18n(
"does not rise");
223 WUT->MoonRiseLabel->setText(
224 i18n(
"Moon rises at: %1 on %2", sRise,
230 if (moonSet > moonRise)
231 WUT->MoonSetLabel->setText(
232 i18n(
"Moon sets at: %1 on %2", sSet,
235 WUT->MoonSetLabel->setText(
236 i18n(
"Moon sets at: %1 on %2", sSet,
239 WUT->MoonIllumLabel->setText(
i18nc(
"%2 is the value, % is the percent sign",
"%1 (%2%)", oMoon->
phaseName(),
int(100.0 * oMoon->
illum())));
246 if (WUT->CategoryListWidget->currentItem())
247 slotLoadList(WUT->CategoryListWidget->currentItem()->text());
255 return m_VisibleList[category];
260 for (
const auto &oneList : m_VisibleList)
262 for (
const auto &oneObject : oneList)
264 if (oneObject->name() == name)
272bool WUTDialog::isCategoryInitialized(
const QString &category)
274 return m_CategoryInitialized[
category];
278 const std::vector<SkyObject::TYPE> &types)
283 auto &lst = m_CatalogObjects[
category];
286 for (
const auto type : types)
288 lst.splice(lst.end(), db.get_objects(type, m_Mag));
291 objects.reserve(lst.size());
292 for (
const auto &obj : lst)
294 objects.push_back({ obj.name(), &obj });
300void WUTDialog::slotLoadList(
const QString &c)
303 if (!m_VisibleList.contains(c))
306 WUT->ObjectListWidget->clear();
309 const bool isDSO = c == m_Categories[2] || c == m_Categories[3] || c == m_Categories[4];
311 if (!isCategoryInitialized(c))
313 if (c == m_Categories[0])
321 visibleObjects(c).insert(o);
324 m_CategoryInitialized[c] =
true;
327 else if (c == m_Categories[1])
332 data->
skyComposite()->objectLists(SkyObject::CATALOG_STAR));
333 starObjects.
append(load_dso(c, { SkyObject::STAR, SkyObject::CATALOG_STAR }));
335 for (
const auto &
object : starObjects)
341 visibleObjects(c).insert(o);
344 m_CategoryInitialized[c] =
true;
347 else if (c == m_Categories[5])
351 visibleObjects(c).insert(o);
353 m_CategoryInitialized[c] =
true;
356 else if (c == m_Categories[6])
359 if (o->
mag() <= m_Mag &&
360 o->
name() !=
i18nc(
"Asteroid name (optional)",
"Pluto") &&
362 visibleObjects(c).insert(o);
364 m_CategoryInitialized[c] =
true;
367 else if (c == m_Categories[7])
371 visibleObjects(c).insert(o);
373 m_CategoryInitialized[c] =
true;
378 auto dsos{ load_dso(c,
380 SkyObject::OPEN_CLUSTER, SkyObject::GLOBULAR_CLUSTER,
381 SkyObject::GASEOUS_NEBULA, SkyObject::PLANETARY_NEBULA,
382 SkyObject::SUPERNOVA_REMNANT, SkyObject::SUPERNOVA,
386 for (
auto &dso : dsos)
393 case SkyObject::OPEN_CLUSTER:
394 case SkyObject::GLOBULAR_CLUSTER:
395 visibleObjects(m_Categories[4]).insert(o);
397 case SkyObject::GASEOUS_NEBULA:
398 case SkyObject::PLANETARY_NEBULA:
399 case SkyObject::SUPERNOVA:
400 case SkyObject::SUPERNOVA_REMNANT:
401 visibleObjects(m_Categories[2]).insert(o);
403 case SkyObject::GALAXY:
404 visibleObjects(m_Categories[3]).insert(o);
410 m_CategoryInitialized[m_Categories[2]] =
true;
411 m_CategoryInitialized[m_Categories[3]] =
true;
412 m_CategoryInitialized[m_Categories[4]] =
true;
419 for (
const auto &oneObject : visibleObjects(c))
420 WUT->ObjectListWidget->addItem(oneObject->name());
424 for (
const auto &oneObject : visibleObjects(c))
425 WUT->ObjectListWidget->addItem(oneObject->longname());
431 if (WUT->ObjectListWidget->count())
433 WUT->ObjectListWidget->setCurrentRow(0);
449 KStarsDateTime T1 = Evening;
450 T1.setTime(sunSetToday);
451 KStarsDateTime T2 = Tomorrow;
452 T2.setTime(sunRiseTomorrow);
455 if (EveningFlag == 0)
459 else if (EveningFlag == 1)
464 for (KStarsDateTime test = T1; test < T2; test = test.addSecs(3600))
467 KStarsDateTime ut = geo->LTtoUT(test);
468 dms LST = geo->GSTtoLST(ut.gst());
472 sp.EquatorialToHorizontal(&LST, geo->
lat());
474 if (sp.alt().Degrees() > minAlt)
484void WUTDialog::slotDisplayObject(
const QString &name)
486 QTime tRise, tSet, tTransit;
498 WUT->ObjectBox->setTitle(
i18n(
"No Object Selected"));
507 WUT->ObjectBox->setTitle(
i18n(
"Object Not Found"));
512 WUT->ObjectBox->setTitle(o->
name());
516 if (o->
alt().Degrees() > 0.0)
518 sRise =
i18n(
"circumpolar");
519 sSet =
i18n(
"circumpolar");
523 sRise =
i18n(
"does not rise");
524 sSet =
i18n(
"does not rise");
542 WUT->ObjectRiseLabel->setText(
i18n(
"Rises at: %1", sRise));
543 WUT->ObjectTransitLabel->setText(
i18n(
"Transits at: %1", sTransit));
544 WUT->ObjectSetLabel->setText(
i18n(
"Sets at: %1", sSet));
547void WUTDialog::slotCenter()
552 if (WUT->ObjectListWidget->currentItem() !=
nullptr)
554 o = kstars->
data()->
objectNamed(WUT->ObjectListWidget->currentItem()->text());
564void WUTDialog::slotDetails()
569 if (WUT->ObjectListWidget->currentItem() !=
nullptr)
571 o = kstars->
data()->
objectNamed(WUT->ObjectListWidget->currentItem()->text());
581void WUTDialog::slotObslist()
585 if (WUT->ObjectListWidget->currentItem() !=
nullptr)
588 WUT->ObjectListWidget->currentItem()->text());
592 KStarsData::Instance()->observingList()->
slotAddObject(o, session);
596void WUTDialog::slotChangeDate()
600 T0.setTime(
QTime(18, 0, 0));
605 T0 = td->selectedDateTime();
608 if (T0.time() ==
QTime(0, 0, 0))
609 T0.setTime(
QTime(0, 0, 1));
612 if (T0.time().hour() < 6)
616 T0.setTime(
QTime(0, 0, 0));
618 UT0 = geo->LTtoUT(T0);
621 Tomorrow = T0.addSecs(12 * 3600);
622 TomorrowUT = geo->LTtoUT(Tomorrow);
625 Evening = T0.addSecs(-6 * 3600);
626 EveningUT = geo->LTtoUT(Evening);
628 WUT->DateLabel->setText(
i18n(
632 slotLoadList(WUT->CategoryListWidget->currentItem()->text());
637void WUTDialog::slotChangeLocation()
646 UT0 = geo->LTtoUT(T0);
647 TomorrowUT = geo->LTtoUT(Tomorrow);
648 EveningUT = geo->LTtoUT(Evening);
650 WUT->LocationLabel->setText(
i18n(
"at %1", geo->
fullName()));
653 slotLoadList(WUT->CategoryListWidget->currentItem()->text());
659void WUTDialog::slotEveningMorning(
int index)
661 if (EveningFlag != index)
665 slotLoadList(WUT->CategoryListWidget->currentItem()->text());
669void WUTDialog::updateMag()
671 m_Mag = WUT->MagnitudeEdit->value();
673 slotLoadList(WUT->CategoryListWidget->currentItem()->text());
676void WUTDialog::slotChangeMagnitude()
685 timer->setSingleShot(
true);
686 connect(timer, SIGNAL(timeout()),
this, SLOT(updateMag()));
Manages the catalog database and provides an interface to provide an interface to query and modify th...
DetailDialog is a window showing detailed information for a selected object.
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
const CachingDms * lat() const
QString translatedCountry() const
QString translatedName() const
QString translatedProvince() const
Provides necessary information about the Moon.
QString phaseName() const
void findPhase(const KSSun *Sun=nullptr)
Determine the phase angle of the moon, and assign the appropriate moon image.
There are several time-dependent values used in position calculations, that are not specific to an ob...
void updateCoords(const KSNumbers *num, bool includePlanets=true, const CachingDms *lat=nullptr, const CachingDms *LST=nullptr, bool forceRecompute=false) override
Update position of the planet (reimplemented from SkyPoint)
Child class of KSPlanetBase; encapsulates information about the Sun.
KStarsData is the backbone of KStars.
SkyObject * objectNamed(const QString &name)
Find object by name.
const KStarsDateTime & ut() const
SkyMapComposite * skyComposite()
This is the main window for KStars.
static KStars * Instance()
KStarsData * data() const
Dialog for changing the geographic location of the observer.
void slotAddObject(const SkyObject *o=nullptr, bool session=false, bool update=false)
add a new object to list o pointer to the object to add to the list session flag toggle adding the ob...
SkyObject * findByName(const QString &name, bool exact=true) override
Search the children of this SkyMapComposite for a SkyObject whose name matches the argument.
SkyPoint * focusPoint()
retrieve the FocusPoint position.
void setDestination(const SkyPoint &f)
sets the destination point of the sky map.
void setFocusObject(SkyObject *o)
Set the FocusObject pointer to the argument.
void setFocusPoint(SkyPoint *f)
set the FocusPoint; the position that is to be the next Destination.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
virtual QString name(void) const
QTime transitTime(const KStarsDateTime &dt, const GeoLocation *geo) const
The same iteration technique described in riseSetTime() is used here.
QTime riseSetTime(const KStarsDateTime &dt, const GeoLocation *geo, bool rst, bool exact=true) const
Determine the time at which the point will rise or set.
SkyPoint recomputeCoords(const KStarsDateTime &dt, const GeoLocation *geo=nullptr) const
The equatorial coordinates for the object on date dt are computed and returned, but the object's inte...
bool checkCircumpolar(const dms *gLat) const
Check if this point is circumpolar at the given geographic latitude.
WUTDialog(QWidget *ks, bool session=false, GeoLocation *geo=KStarsData::Instance() ->geo(), KStarsDateTime lt=KStarsData::Instance() ->lt())
Constructor.
void init()
Determine which objects are visible, and store them in an array of lists, classified by object type.
bool checkVisibility(const SkyObject *o)
Check visibility of object o the object to check.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
Category category(StandardShortcut id)
void setModal(bool modal)
bool contains(const Key &key) const const
void append(QList< T > &&value)
QString toString(QDate date, FormatType format) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString arg(Args &&... args) const const
bool isEmpty() const const
QTime addSecs(int s) const const
QString toString(QStringView format) const const