7#include "obslistwizard.h"
10#include "geolocation.h"
11#include "kstarsdata.h"
12#include "dialogs/locationdialog.h"
13#include "skycomponents/constellationboundarylines.h"
14#include "skycomponents/catalogscomponent.h"
15#include "skycomponents/skymapcomposite.h"
16#include "catalogobject.h"
17#include "catalogsdb.h"
29 olw =
new ObsListWizardUI(
this);
32 setLayout(mainLayout);
34 setWindowTitle(
i18nc(
"@title:window",
"Observing List Wizard"));
38 nextB->setDefault(
true);
40 backB->setEnabled(
false);
46 connect(nextB, SIGNAL(clicked()),
this, SLOT(slotNextPage()));
47 connect(backB, SIGNAL(clicked()),
this, SLOT(slotPrevPage()));
48 connect(buttonBox, SIGNAL(accepted()),
this, SLOT(slotApplyFilters()));
49 connect(buttonBox, SIGNAL(accepted()),
this, SLOT(accept()));
50 connect(buttonBox, SIGNAL(rejected()),
this, SLOT(reject()));
52 connect(olw->AllButton, SIGNAL(clicked()),
this, SLOT(slotAllButton()));
53 connect(olw->NoneButton, SIGNAL(clicked()),
this, SLOT(slotNoneButton()));
54 connect(olw->DeepSkyButton, SIGNAL(clicked()),
this, SLOT(slotDeepSkyButton()));
55 connect(olw->SolarSystemButton, SIGNAL(clicked()),
this, SLOT(slotSolarSystemButton()));
56 connect(olw->LocationButton, SIGNAL(clicked()),
this, SLOT(slotChangeLocation()));
59 connect(olw->updateButton, SIGNAL(clicked()),
this, SLOT(slotUpdateObjectCount()));
76 connect(olw->SelectByDate, SIGNAL(clicked()),
this, SLOT(slotToggleDateWidgets()));
81 &ObsListWizard::slotObjectCountDirty);
83 &ObsListWizard::slotObjectCountDirty);
84 olw->coverage->setValue(Options::obsListCoverage());
87 Options::setObsListCoverage(value);
88 slotObjectCountDirty();
91 connect(olw->SelectByMagnitude, SIGNAL(clicked()),
this, SLOT(slotToggleMagWidgets()));
93 &ObsListWizard::slotObjectCountDirty);
98 geo = KStarsData::Instance()->
geo();
99 olw->LocationButton->setText(
geo->fullName());
101 olw->timeFrom->setTime(
QTime(18, 0));
102 olw->timeTo->setTime(
QTime(23, 59));
107void ObsListWizard::initialize()
110 olw->olwStack->setCurrentIndex(0);
114 olw->ConstellationList->addItem(p->
name());
117 olw->TypeList->clearSelection();
119 olw->Mag->setMinimum(-5.0);
120 olw->Mag->setMaximum(20.0);
121 olw->Mag->setValue(6.0);
123 olw->RA->setUnits(dmsBox::HOURS);
124 olw->RAMin->setUnits(dmsBox::HOURS);
125 olw->RAMax->setUnits(dmsBox::HOURS);
131 PlanetCount = std::size(sun_moon_planets_list);
135 OpenClusterCount = 0;
136 GlobClusterCount = 0;
143 const auto &stats{ manager.get_master_statistics() };
147 for (
const auto &element : stats.second.object_counts)
149 auto cnt = element.second;
150 switch (element.first)
152 case SkyObject::GALAXY:
155 case SkyObject::STAR:
157 case SkyObject::OPEN_CLUSTER:
158 OpenClusterCount += cnt;
160 case SkyObject::GLOBULAR_CLUSTER:
161 GlobClusterCount += cnt;
163 case SkyObject::GASEOUS_NEBULA:
164 case SkyObject::SUPERNOVA_REMNANT:
167 case SkyObject::PLANETARY_NEBULA:
186void ObsListWizard::setItemSelected(
const QString &name,
QListWidget *listWidget,
bool value)
190 items[0]->setSelected(value);
209void ObsListWizard::slotNextPage()
211 int NextPage = olw->olwStack->currentIndex() + 1;
213 if (olw->olwStack->currentIndex() == PAGE_ID_REGION_TYPE)
217 if (isItemSelected(
i18n(IN_A_RECTANGULAR_REGION), olw->RegionList))
218 NextPage = PAGE_ID_RECTANGULAR;
219 else if (isItemSelected(
i18n(IN_A_CIRCULAR_REGION), olw->RegionList))
220 NextPage = PAGE_ID_CIRCULAR;
221 else if (isItemSelected(
i18n(ALL_OVER_THE_SKY), olw->RegionList))
222 NextPage = PAGE_ID_DATE;
225 if ( olw->olwStack->currentIndex() == PAGE_ID_CONSTELLATION ||
226 olw->olwStack->currentIndex() == PAGE_ID_RECTANGULAR)
227 NextPage = PAGE_ID_DATE;
229 olw->olwStack->setCurrentIndex(NextPage);
231 if (olw->olwStack->currentIndex() == olw->olwStack->count() - 1)
242void ObsListWizard::slotPrevPage()
244 int PrevPage = olw->olwStack->currentIndex() - 1;
246 if ( olw->olwStack->currentIndex() == PAGE_ID_RECTANGULAR ||
247 olw->olwStack->currentIndex() == PAGE_ID_CIRCULAR ||
248 olw->olwStack->currentIndex() == PAGE_ID_DATE)
249 PrevPage = PAGE_ID_REGION_TYPE;
251 olw->olwStack->setCurrentIndex(PrevPage);
253 if (olw->olwStack->currentIndex() == 0)
259void ObsListWizard::slotAllButton()
261 for (
int i = 0; i < olw->TypeList->count(); ++i)
262 olw->TypeList->item(i)->setSelected(
true);
265void ObsListWizard::slotNoneButton()
267 olw->TypeList->clearSelection();
270void ObsListWizard::slotDeepSkyButton()
272 olw->TypeList->clearSelection();
273 setItemSelected(
i18n(
"Open clusters"), olw->TypeList,
true);
274 setItemSelected(
i18n(
"Globular clusters"), olw->TypeList,
true);
275 setItemSelected(
i18n(
"Gaseous nebulae"), olw->TypeList,
true);
276 setItemSelected(
i18n(
"Planetary nebulae"), olw->TypeList,
true);
277 setItemSelected(
i18n(
"Galaxies"), olw->TypeList,
true);
280void ObsListWizard::slotSolarSystemButton()
282 olw->TypeList->clearSelection();
283 setItemSelected(
i18n(
"Sun, moon, planets"), olw->TypeList,
true);
284 setItemSelected(
i18n(
"Comets"), olw->TypeList,
true);
285 setItemSelected(
i18n(
"Asteroids"), olw->TypeList,
true);
288void ObsListWizard::slotChangeLocation() {
294 if (ld->selectedCity())
296 geo = ld->selectedCity();
297 olw->LocationButton->setText(geo->
fullName());
303void ObsListWizard::slotToggleDateWidgets()
305 bool needDate = olw->SelectByDate->isChecked();
313 slotObjectCountDirty();
316void ObsListWizard::slotToggleMagWidgets()
318 bool needMagnitude = olw->SelectByMagnitude->isChecked();
322 slotObjectCountDirty();
326void ObsListWizard::slotParseRegion()
328 if ( isItemSelected(
i18n(IN_A_RECTANGULAR_REGION), olw->RegionList) &&
332 if (!olw->RAMin->isEmpty() && !olw->RAMax->isEmpty() &&
333 !olw->DecMin->isEmpty() && !olw->DecMax->isEmpty())
341 xRect1 = olw->RAMin->createDms(&rectOk).Hours();
343 xRect2 = olw->RAMax->createDms(&rectOk).Hours();
345 yRect1 = olw->DecMin->createDms(&rectOk).Degrees();
347 yRect2 = olw->DecMax->createDms(&rectOk).Degrees();
353 qWarning() <<
i18n(
"Illegal rectangle specified, no region selection possible." ) ;
358 std::swap(yRect1, yRect2);
363 if (xRect1 - xRect2 > 12.0)
369 double temp = xRect2;
374 slotObjectCountDirty();
379 if ( isItemSelected(
i18n(IN_A_CIRCULAR_REGION), olw->RegionList) &&
380 (!olw->RA->isEmpty() && !olw->Dec->isEmpty() && !olw->Radius->isEmpty()))
385 dms ra = olw->RA->createDms(&circOk1);
386 dms dc = olw->Dec->createDms(&circOk2);
388 rCirc = olw->Radius->createDms(&circOk3).Degrees();
389 if (circOk1 && circOk2 && circOk3)
390 slotObjectCountDirty();
392 qWarning() <<
i18n(
"Illegal circle specified, no region selection possible.");
396void ObsListWizard::slotObjectCountDirty()
401void ObsListWizard::slotUpdateObjectCount()
405 if (isItemSelected(
i18n(
"Stars"), olw->TypeList))
406 ObjectCount += StarCount;
407 if (isItemSelected(
i18n(
"Sun, moon, planets"), olw->TypeList))
408 ObjectCount += PlanetCount;
409 if (isItemSelected(
i18n(
"Comets"), olw->TypeList))
410 ObjectCount += CometCount;
411 if (isItemSelected(
i18n(
"Asteroids"), olw->TypeList))
412 ObjectCount += AsteroidCount;
413 if (isItemSelected(
i18n(
"Galaxies"), olw->TypeList))
414 ObjectCount += GalaxyCount;
415 if (isItemSelected(
i18n(
"Open clusters"), olw->TypeList))
416 ObjectCount += OpenClusterCount;
417 if (isItemSelected(
i18n(
"Globular clusters"), olw->TypeList))
418 ObjectCount += GlobClusterCount;
419 if (isItemSelected(
i18n(
"Gaseous nebulae"), olw->TypeList))
420 ObjectCount += GasNebCount;
421 if (isItemSelected(
i18n(
"Planetary nebulae"), olw->TypeList))
422 ObjectCount += PlanNebCount;
429void ObsListWizard::applyFilters(
bool doBuildList)
436 bool needRegion = !isItemSelected(
i18n(ALL_OVER_THE_SKY), olw->RegionList);
438 double maglimit = 100.;
439 bool needMagnitude = olw->SelectByMagnitude->isChecked();
440 bool needNoMagnitude =
true;
443 maglimit = olw->Mag->value();
444 needNoMagnitude = olw->IncludeNoMag->isChecked();
446 bool needDate = olw->SelectByDate->isChecked();
447 FilterParameters filterParameters = { maglimit, needMagnitude, needNoMagnitude, needRegion, needDate, doBuildList};
449 if (isItemSelected(
i18n(
"Stars"), olw->TypeList))
452 int starIndex(starList.
size());
453 qDebug() << Q_FUNC_INFO <<
QString(
"starIndex: [%1] and maglimit: [%2]").
arg(starIndex).
arg(maglimit);
454 for (
int i = 0; i < starIndex; ++i)
457 applyMagnitudeAndRegionAndObservableFilter(obj, filterParameters);
461 if (isItemSelected(
i18n(
"Sun, moon, planets"), olw->TypeList))
463 for (
auto name : sun_moon_planets_list)
469 qWarning() << Q_FUNC_INFO
470 <<
QString(
"Failed to find element by name: [%1]").
arg(name);
474 applyMagnitudeAndRegionAndObservableFilter(obj, filterParameters);
478 bool dso = (isItemSelected(
i18n(
"Open clusters"), olw->TypeList) ||
479 isItemSelected(
i18n(
"Globular clusters"), olw->TypeList) ||
480 isItemSelected(
i18n(
"Gaseous nebulae"), olw->TypeList) ||
481 isItemSelected(
i18n(
"Planetary nebulae"), olw->TypeList) ||
482 isItemSelected(
i18n(
"Galaxies"), olw->TypeList));
489 for (
auto &o : cObjectList)
492 bool typeSelected =
false;
495 case SkyObject::OPEN_CLUSTER:
496 if (isItemSelected(
i18n(
"Open clusters"), olw->TypeList))
500 case SkyObject::GLOBULAR_CLUSTER:
501 if (isItemSelected(
i18n(
"Globular clusters"), olw->TypeList))
505 case SkyObject::GASEOUS_NEBULA:
506 case SkyObject::SUPERNOVA_REMNANT:
507 if (isItemSelected(
i18n(
"Gaseous nebulae"), olw->TypeList))
511 case SkyObject::PLANETARY_NEBULA:
512 if (isItemSelected(
i18n(
"Planetary nebulae"), olw->TypeList))
515 case SkyObject::GALAXY:
516 if (isItemSelected(
i18n(
"Galaxies"), olw->TypeList))
525 applyMagnitudeAndRegionAndObservableFilter(obj, filterParameters);
529 if (isItemSelected(
i18n(
"Comets"), olw->TypeList))
532 applyMagnitudeAndRegionAndObservableFilter(o, filterParameters);
535 if (isItemSelected(
i18n(
"Asteroids"), olw->TypeList))
538 applyMagnitudeAndRegionAndObservableFilter(o, filterParameters);
545 olw->CountLabel->setText(
i18np(
"Your observing list currently has 1 object",
546 "Your observing list currently has %1 objects", ObjectCount));
549bool ObsListWizard::applyMagnitudeAndRegionAndObservableFilter(
SkyObject *o, FilterParameters filterParameters )
551 bool needMagnitude = filterParameters.needMagnitude;
552 bool needRegion = filterParameters.needRegion;
553 bool needDate = filterParameters.needDate;
554 bool doBuildList = filterParameters.doBuildList;
556 bool filterPass =
true;
558 if (filterPass && needMagnitude)
559 filterPass = applyMagnitudeFilter(o, filterParameters);
560 if (filterPass && (needRegion || doBuildList))
562 filterPass = applyRegionFilter(o, doBuildList);
563 if (filterPass && needDate )
564 filterPass = applyObservableFilter(o, doBuildList);
568bool ObsListWizard::applyMagnitudeFilter(
SkyObject *o, FilterParameters filterParameters)
570 bool needMagnitude = filterParameters.needMagnitude;
571 bool needNoMagnitude = filterParameters.needNoMagnitude;
572 if (needMagnitude && ((std::isnan(o->
mag()) && (!needNoMagnitude)) ||
573 (o->
mag() > filterParameters.maglimit)))
583bool ObsListWizard::applyRegionFilter(
SkyObject *o,
bool doBuildList)
586 if (isItemSelected(
i18n(BY_CONSTELLATION), olw->RegionList))
588 QString constellationName = KStarsData::Instance()
590 ->constellationBoundary()
591 ->constellationName(o);
593 if (isItemSelected(constellationName, olw->ConstellationList))
604 else if (isItemSelected(
i18n(IN_A_RECTANGULAR_REGION), olw->RegionList))
608 bool addObject =
false;
609 if (dec >= yRect1 && dec <= yRect2)
613 addObject = ra >= xRect1 + 24.0 || ra <= xRect2;
617 addObject = ra >= xRect1 && ra <= xRect2;
633 else if (isItemSelected(
i18n(IN_A_CIRCULAR_REGION), olw->RegionList))
646 else if (doBuildList)
657bool ObsListWizard::applyObservableFilter(
SkyObject *o,
bool doBuildList)
665 double minAlt = 15, maxAlt = 90;
668 if (olw->timeFrom->time().isValid() && olw->timeTo->time().isValid())
670 Evening.setTime(olw->timeFrom->time());
671 Midnight.setTime(olw->timeTo->time());
675 if (olw->timeFrom->time() < olw->timeTo->time())
677 Midnight.setDate(olw->Date->date());
682 Midnight.setDate(olw->Date->date().addDays(1));
686 minAlt = olw->minAlt->value();
687 maxAlt = olw->maxAlt->value();
692 double totalCount = 0, visibleCount = 0;
695 dms LST = geo->GSTtoLST(t.gst());
704 if (visibleCount / totalCount >= olw->coverage->value() / 100.0)
CatalogObject & insertStaticObject(const CatalogObject &obj)
Insert an object obj into m_static_objects and return a reference to the newly inserted object.
Manages the catalog database and provides an interface to provide an interface to query and modify th...
CatalogObjectList get_objects_all()
Get all objects from the database.
const CachingDms * lat() const
KStarsData is the backbone of KStars.
SkyMapComposite * skyComposite()
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
KStarsDateTime addSecs(double s) const
static KStarsDateTime currentDateTime()
Dialog for changing the geographic location of the observer.
QList< SkyObject * > & obsList()
SkyObject * findByName(const QString &name, bool exact=true) override
Search the children of this SkyMapComposite for a SkyObject whose name matches the argument.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
virtual QString name(void) const
The sky coordinates of a point in the sky.
const CachingDms & dec() const
const CachingDms & ra() const
dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle=nullptr) const
Computes the angular distance between two SkyObjects.
void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
void set(const dms &r, const dms &d)
Sets RA, Dec and RA0, Dec0 according to arguments.
An angle, stored as degrees, but expressible in many ways.
const double & Degrees() const
QString i18np(const char *singular, const char *plural, const TYPE &arg...)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
KCRASH_EXPORT void initialize()
GeoCoordinates geo(const QVariant &location)
void dateChanged(QDate date)
void timeChanged(QTime time)
void valueChanged(double d)
void restoreOverrideCursor()
void setOverrideCursor(const QCursor &cursor)
void append(QList< T > &&value)
qsizetype size() const const
QString text() const const
QObject * sender() const const
QString arg(Args &&... args) const const
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
QTextStream & dec(QTextStream &stream)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)