19 #include <QVBoxLayout>
22 #include <knuminput.h>
23 #include <kpushbutton.h>
45 setCaption( i18n(
"Observing List Wizard") );
46 setButtons( KDialog::User1|KDialog::User2|KDialog::Ok|KDialog::Cancel );
47 setButtonGuiItem( KDialog::User2, KGuiItem( i18n(
"< &Back"), QString(), i18n(
"Go to previous Wizard page") ) );
48 setButtonGuiItem( KDialog::User1, KGuiItem( i18n(
"&Next >"), QString(), i18n(
"Go to next Wizard page") ) );
49 enableButton( KDialog::User2,
false );
51 connect( olw->AllButton, SIGNAL( clicked() ),
this, SLOT( slotAllButton() ) );
52 connect( olw->NoneButton, SIGNAL( clicked() ),
this, SLOT( slotNoneButton() ) );
53 connect( olw->DeepSkyButton, SIGNAL( clicked() ),
this, SLOT( slotDeepSkyButton() ) );
54 connect( olw->SolarSystemButton, SIGNAL( clicked() ),
this, SLOT( slotSolarSystemButton() ) );
55 connect( olw->LocationButton, SIGNAL( clicked() ),
this, SLOT( slotChangeLocation() ) );
57 connect(
this, SIGNAL( user1Clicked() ),
this, SLOT( slotNextPage() ) );
58 connect(
this, SIGNAL( user2Clicked() ),
this, SLOT( slotPrevPage() ) );
61 connect( olw->updateButton, SIGNAL( clicked() ),
this, SLOT( slotUpdateObjectCount() ) );
64 connect( olw->TypeList, SIGNAL( itemSelectionChanged() ),
this, SLOT( slotObjectCountDirty() ) );
65 connect( olw->ConstellationList, SIGNAL( itemSelectionChanged() ),
this, SLOT( slotObjectCountDirty() ) );
66 connect( olw->RAMin, SIGNAL( lostFocus() ),
this, SLOT( slotParseRegion() ) );
67 connect( olw->RAMax, SIGNAL( lostFocus() ),
this, SLOT( slotParseRegion() ) );
68 connect( olw->DecMin, SIGNAL( lostFocus() ),
this, SLOT( slotParseRegion() ) );
69 connect( olw->DecMax, SIGNAL( lostFocus() ),
this, SLOT( slotParseRegion() ) );
70 connect( olw->RA, SIGNAL( lostFocus() ),
this, SLOT( slotParseRegion() ) );
71 connect( olw->Dec, SIGNAL( lostFocus() ),
this, SLOT( slotParseRegion() ) );
72 connect( olw->Radius, SIGNAL( lostFocus() ),
this, SLOT( slotObjectCountDirty() ) );
73 connect( olw->Date, SIGNAL( dateChanged(
const QDate&) ),
this, SLOT( slotObjectCountDirty() ) );
74 connect( olw->Mag, SIGNAL( valueChanged(
double ) ),
this, SLOT( slotObjectCountDirty() ) );
75 connect( olw->IncludeNoMag, SIGNAL( clicked() ),
this, SLOT( slotObjectCountDirty() ) );
76 connect (olw->timeTo, SIGNAL(timeChanged(
const QTime&)),
this, SLOT(slotObjectCountDirty()));
77 connect (olw->timeFrom, SIGNAL(timeChanged(
const QTime&)),
this, SLOT(slotObjectCountDirty()));
78 connect (olw->minAlt, SIGNAL(valueChanged(
double)),
this, SLOT(slotObjectCountDirty()));
79 connect (olw->maxAlt, SIGNAL(valueChanged(
double)),
this, SLOT(slotObjectCountDirty()));
81 connect( olw->SelectByDate, SIGNAL( clicked() ),
this, SLOT( slotToggleDateWidgets() ) );
82 connect( olw->SelectByMagnitude, SIGNAL( clicked() ),
this, SLOT( slotToggleMagWidgets() ) );
84 connect(
this, SIGNAL( okClicked() ),
this, SLOT( slotApplyFilters() ) );
87 olw->LocationButton->setText( geo->
fullName() );
88 olw->Date->setDate(KStarsDateTime::currentLocalDate());
89 olw->timeFrom->setTime(QTime(18, 0));
90 olw->timeTo->setTime(QTime(23, 59));
99 void ObsListWizard::initialize()
102 olw->olwStack->setCurrentIndex( 0 );
106 olw->ConstellationList->addItem( p->
name() );
109 olw->TypeList->clearSelection();
111 olw->Mag->setMinimum( -5.0 );
112 olw->Mag->setMaximum( 20.0 );
113 olw->Mag->setValue( 6.0 );
115 olw->RA->setDegType(
false );
116 olw->RAMin->setDegType(
false );
117 olw->RAMax->setDegType(
false );
126 OpenClusterCount = 0;
127 GlobClusterCount = 0;
142 bool ObsListWizard::isItemSelected(
const QString &name, QListWidget *listWidget,
bool *ok ) {
146 return items.size() && listWidget->isItemSelected( items[0] );;
149 void ObsListWizard::setItemSelected(
const QString &name, QListWidget *listWidget,
bool value,
bool *ok ) {
154 listWidget->setItemSelected( items[0], value );
170 void ObsListWizard::slotNextPage() {
171 int NextPage = olw->olwStack->currentIndex() + 1;
173 if ( olw->olwStack->currentIndex() == 2 ) {
177 if ( isItemSelected( i18n(
"in a rectangular region"), olw->RegionList ) )
179 if ( isItemSelected( i18n(
"in a circular region"), olw->RegionList ) )
181 if ( isItemSelected( i18n(
"all over the sky"), olw->RegionList ) )
185 if ( olw->olwStack->currentIndex() == 3 || olw->olwStack->currentIndex() == 4 )
188 olw->olwStack->setCurrentIndex( NextPage );
189 if ( olw->olwStack->currentIndex() == olw->olwStack->count() - 1 )
190 enableButton( KDialog::User1,
false );
192 enableButton( KDialog::User2,
true );
200 void ObsListWizard::slotPrevPage() {
201 int PrevPage = olw->olwStack->currentIndex() - 1;
203 if ( olw->olwStack->currentIndex() == 4
204 || olw->olwStack->currentIndex() == 5
205 || olw->olwStack->currentIndex() == 6 )
208 olw->olwStack->setCurrentIndex( PrevPage );
209 if ( olw->olwStack->currentIndex() == 0 )
210 enableButton( KDialog::User2,
false );
212 enableButton( KDialog::User1,
true );
215 void ObsListWizard::slotAllButton() {
216 for (
int i=0; i<olw->TypeList->count(); ++i )
217 olw->TypeList->setItemSelected( olw->TypeList->item(i), true );
220 void ObsListWizard::slotNoneButton() { olw->TypeList->clearSelection(); }
222 void ObsListWizard::slotDeepSkyButton()
224 olw->TypeList->clearSelection();
225 setItemSelected( i18n(
"Open clusters" ), olw->TypeList,
true );
226 setItemSelected( i18n(
"Globular clusters" ), olw->TypeList,
true );
227 setItemSelected( i18n(
"Gaseous nebulae" ), olw->TypeList,
true );
228 setItemSelected( i18n(
"Planetary nebulae" ), olw->TypeList,
true );
229 setItemSelected( i18n(
"Galaxies" ), olw->TypeList,
true );
232 void ObsListWizard::slotSolarSystemButton()
234 olw->TypeList->clearSelection();
235 setItemSelected( i18n(
"Sun, moon, planets" ), olw->TypeList,
true );
236 setItemSelected( i18n(
"Comets" ), olw->TypeList,
true );
237 setItemSelected( i18n(
"Asteroids" ), olw->TypeList,
true );
240 void ObsListWizard::slotChangeLocation()
244 if ( ld->exec() == QDialog::Accepted ) {
246 if ( ld->selectedCity() ) {
247 geo = ld->selectedCity();
248 olw->LocationButton->setText( geo->fullName() );
254 void ObsListWizard::slotToggleDateWidgets()
256 olw->Date->setEnabled( olw->SelectByDate->isChecked() );
257 olw->LocationButton->setEnabled( olw->SelectByDate->isChecked() );
258 olw->timeTo->setEnabled(olw->SelectByDate->isChecked() );
259 olw->timeFrom->setEnabled(olw->SelectByDate->isChecked() );
260 olw->minAlt->setEnabled(olw->SelectByDate->isChecked() );
261 olw->maxAlt->setEnabled(olw->SelectByDate->isChecked() );
264 slotObjectCountDirty();
267 void ObsListWizard::slotToggleMagWidgets()
269 olw->Mag->setEnabled( olw->SelectByMagnitude->isChecked() );
270 olw->IncludeNoMag->setEnabled( olw->SelectByMagnitude->isChecked() );
271 slotObjectCountDirty();
275 void ObsListWizard::slotParseRegion()
277 if ( sender()->objectName() ==
"RAMin" || sender()->objectName() ==
"RAMax"
278 || sender()->objectName() ==
"DecMin" || sender()->objectName() ==
"DecMax" ) {
279 if ( ! olw->RAMin->isEmpty() && ! olw->RAMax->isEmpty()
280 && ! olw->DecMin->isEmpty() && ! olw->DecMax->isEmpty() ) {
287 xRect1 = olw->RAMin->createDms(
false, &rectOk ).Hours();
288 if ( rectOk ) xRect2 = olw->RAMax->createDms(
false, &rectOk ).Hours();
289 if ( rectOk ) yRect1 = olw->DecMin->createDms(
true, &rectOk ).Degrees();
290 if ( rectOk ) yRect2 = olw->DecMax->createDms(
true, &rectOk ).Degrees();
291 if ( xRect2 == 0.0 ) xRect2 = 24.0;
299 if ( yRect1 > yRect2 ) {
300 double temp = yRect2;
306 if ( xRect1 > xRect2 ) {
307 if ( xRect1 - xRect2 > 12.0 ) {
310 double temp = xRect2;
317 slotObjectCountDirty();
320 }
else if ( ! olw->RA->isEmpty() && ! olw->Dec->isEmpty() && ! olw->Radius->isEmpty() ) {
322 dms ra = olw->RA->createDms(
false, &circOk );
325 dc = olw->Dec->createDms(
true, &circOk );
328 rCirc = olw->Radius->createDms(
true, &circOk ).
Degrees();
330 kWarning() << i18n(
"Illegal circle specified, no region selection possible." ) ;
334 slotObjectCountDirty();
338 void ObsListWizard::slotObjectCountDirty() {
339 olw->updateButton->setDisabled(
false );
342 void ObsListWizard::slotUpdateObjectCount()
344 QApplication::setOverrideCursor( Qt::WaitCursor );
346 if ( isItemSelected( i18n(
"Stars" ), olw->TypeList ) )
347 ObjectCount += StarCount;
348 if ( isItemSelected( i18n(
"Sun, moon, planets" ), olw->TypeList ) )
349 ObjectCount += PlanetCount;
350 if ( isItemSelected( i18n(
"Comets" ), olw->TypeList ) )
351 ObjectCount += CometCount;
352 if ( isItemSelected( i18n(
"Asteroids" ), olw->TypeList ) )
353 ObjectCount += AsteroidCount;
354 if ( isItemSelected( i18n(
"Galaxies" ), olw->TypeList ) )
355 ObjectCount += GalaxyCount;
356 if ( isItemSelected( i18n(
"Open clusters" ), olw->TypeList ) )
357 ObjectCount += OpenClusterCount;
358 if ( isItemSelected( i18n(
"Globular clusters" ), olw->TypeList ) )
359 ObjectCount += GlobClusterCount;
360 if ( isItemSelected( i18n(
"Gaseous nebulae" ), olw->TypeList ) )
361 ObjectCount += GasNebCount;
362 if ( isItemSelected( i18n(
"Planetary nebulae" ), olw->TypeList ) )
363 ObjectCount += PlanNebCount;
365 applyFilters(
false );
366 QApplication::restoreOverrideCursor();
367 olw->updateButton->setDisabled(
true );
370 void ObsListWizard::applyFilters(
bool doBuildList )
372 bool filterPass =
true;
379 bool needRegion =
true;
380 if ( !doBuildList && isItemSelected( i18n(
"all over the sky" ), olw->RegionList ) )
383 double maglimit = 100.;
384 if ( olw->SelectByMagnitude->isChecked() )
385 maglimit = olw->Mag->value();
388 if ( isItemSelected( i18n(
"Stars" ), olw->TypeList ) )
391 int starIndex( starList.size() );
392 if ( maglimit < 100. )
395 int low(0), high(starList.size()-1), middle(high);
398 middle = (low + high)/2;
399 if ( maglimit == starList.at(middle)->mag() )
401 if ( maglimit < starList.at(middle)->mag() )
403 if ( maglimit > starList.at(middle)->mag() )
407 for ( starIndex=middle+1; starIndex < starList.size(); ++starIndex )
409 if ( starList.at(starIndex)->mag() > maglimit )
415 kDebug() << QString(
"starIndex for mag %1: %2").arg(maglimit).arg(starIndex) << endl;
420 ObjectCount -= StarCount;
421 ObjectCount += starIndex;
423 for (
int i=0; i < starIndex; ++i )
428 if (o->
name() ==
"star")
436 filterPass = applyRegionFilter( o, doBuildList, !doBuildList);
438 if ( olw->SelectByDate->isChecked() && filterPass)
439 applyObservableFilter( o, doBuildList, !doBuildList);
444 if ( isItemSelected( i18n(
"Sun, moon, planets" ), olw->TypeList ) )
446 if (maglimit < data->skyComposite()->findByName(
"Sun")->mag())
455 if ( needRegion && filterPass)
457 if ( olw->SelectByDate->isChecked() && filterPass)
460 if (maglimit < data->skyComposite()->findByName(
"Moon")->mag())
466 else filterPass =
true;
468 if ( needRegion && filterPass)
470 if ( olw->SelectByDate->isChecked() && filterPass)
473 if (maglimit < data->skyComposite()->findByName(
"Mercury")->mag())
481 if ( needRegion && filterPass)
483 if ( olw->SelectByDate->isChecked() && filterPass)
486 if (maglimit < data->skyComposite()->findByName(
"Venus")->mag())
495 if ( needRegion && filterPass)
497 if ( olw->SelectByDate->isChecked() && filterPass)
500 if (maglimit < data->skyComposite()->findByName(
"Mars")->mag())
508 if ( needRegion && filterPass)
510 if ( olw->SelectByDate->isChecked() && filterPass)
513 if (maglimit < data->skyComposite()->findByName(
"Jupiter")->mag())
521 if ( needRegion && filterPass)
523 if ( olw->SelectByDate->isChecked() && filterPass)
526 if (maglimit < data->skyComposite()->findByName(
"Saturn")->mag())
535 if ( needRegion && filterPass)
537 if ( olw->SelectByDate->isChecked() && filterPass)
540 if (maglimit < data->skyComposite()->findByName(
"Uranus")->mag())
549 if ( needRegion && filterPass)
551 if ( olw->SelectByDate->isChecked() && filterPass)
554 if (maglimit < data->skyComposite()->findByName(
"Neptune")->mag())
564 if ( needRegion && filterPass)
566 if ( olw->SelectByDate->isChecked() && filterPass)
569 if (maglimit < data->skyComposite()->findByName(
"Pluto")->mag())
578 if ( needRegion && filterPass)
580 if ( olw->SelectByDate->isChecked() && filterPass)
585 bool dso = ( isItemSelected( i18n(
"Open clusters" ), olw->TypeList )
586 || isItemSelected( i18n(
"Globular clusters" ), olw->TypeList )
587 || isItemSelected( i18n(
"Gaseous nebulae" ), olw->TypeList )
588 || isItemSelected( i18n(
"Planetary nebulae" ), olw->TypeList )
589 || isItemSelected( i18n(
"Galaxies" ), olw->TypeList ) );
595 if ( needRegion || olw->SelectByMagnitude->isChecked() || olw->SelectByDate->isChecked())
600 bool typeSelected =
false;
607 if (isItemSelected( i18n(
"Open clusters" ), olw->TypeList ))
612 if (isItemSelected( i18n(
"Globular clusters" ), olw->TypeList ) )
618 if (isItemSelected( i18n(
"Gaseous nebulae" ), olw->TypeList ) )
623 if (isItemSelected( i18n(
"Planetary nebulae" ), olw->TypeList ) )
627 if (isItemSelected( i18n(
"Galaxies" ), olw->TypeList ) )
633 if ( ! typeSelected )
continue;
635 if ( olw->SelectByMagnitude->isChecked() )
637 if ( o->
mag() > 90. )
639 if ( olw->IncludeNoMag->isChecked() )
642 filterPass = applyRegionFilter( o, doBuildList );
643 if ( olw->SelectByDate->isChecked() && filterPass)
644 applyObservableFilter( o, doBuildList );
646 else if ( ! doBuildList )
651 if ( o->
mag() <= maglimit )
654 filterPass = applyRegionFilter( o, doBuildList );
655 if ( olw->SelectByDate->isChecked() && filterPass)
656 applyObservableFilter( o, doBuildList );
657 }
else if ( ! doBuildList )
664 filterPass = applyRegionFilter( o, doBuildList );
665 if ( olw->SelectByDate->isChecked() && filterPass)
666 applyObservableFilter( o, doBuildList );
673 if ( isItemSelected( i18n(
"Comets" ), olw->TypeList ) )
678 filterPass = applyRegionFilter( o, doBuildList );
679 if ( olw->SelectByDate->isChecked() && filterPass)
680 applyObservableFilter( o, doBuildList );
685 if ( isItemSelected( i18n(
"Asteroids" ), olw->TypeList ) )
689 if ( olw->SelectByMagnitude->isChecked() )
691 if ( o->
mag() > 90. )
693 if ( olw->IncludeNoMag->isChecked() )
695 filterPass = applyRegionFilter( o, doBuildList );
696 if ( olw->SelectByDate->isChecked() && filterPass)
697 applyObservableFilter( o, doBuildList );
698 else if ( ! doBuildList )
703 if ( o->
mag() <= maglimit )
705 filterPass = applyRegionFilter( o, doBuildList );
706 if ( olw->SelectByDate->isChecked() && filterPass)
707 applyObservableFilter( o, doBuildList );
708 else if ( ! doBuildList )
715 filterPass = applyRegionFilter( o, doBuildList );
716 if ( olw->SelectByDate->isChecked() && filterPass)
717 applyObservableFilter( o, doBuildList );
724 ObjectCount = obsList().size();
726 olw->CountLabel->setText( i18np(
"Your observing list currently has 1 object",
"Your observing list currently has %1 objects", ObjectCount ) );
729 bool ObsListWizard::applyRegionFilter(
SkyObject *o,
bool doBuildList,
733 if ( isItemSelected( i18n(
"by constellation"), olw->RegionList ) )
736 if ( isItemSelected( c, olw->ConstellationList ) )
739 obsList().append ( o );
743 else if ( doAdjustCount )
753 else if ( isItemSelected( i18n(
"in a rectangular region"), olw->RegionList ) )
757 bool addObject =
false;
758 if ( dec >= yRect1 && dec <= yRect2 ) {
759 if ( xRect1 < 0.0 ) {
760 addObject = ra >= xRect1 + 24.0 || ra <= xRect2;
762 addObject = ra >= xRect1 && ra <= xRect2;
769 obsList().append( o );
785 else if ( isItemSelected( i18n(
"in a circular region"), olw->RegionList ) )
790 obsList().append( o );
794 else if ( doAdjustCount )
804 else if ( doBuildList )
806 obsList().append( o );
812 bool ObsListWizard::applyObservableFilter(
SkyObject *o,
bool doBuildList,
bool doAdjustCount)
819 KStarsDateTime Midnight( olw->Date->date().addDays(1), QTime( 0, 0, 0 ) );
820 double minAlt=15, maxAlt=90;
823 if (olw->timeFrom->time() < olw->timeTo->time())
825 Evening.
setTime(olw->timeFrom->time());
826 Midnight.setTime(olw->timeTo->time());
827 Midnight.setDate(olw->Date->date());
830 if (olw->minAlt->value() < olw->maxAlt->value())
832 minAlt = olw->minAlt->value();
833 maxAlt = olw->maxAlt->value();
836 bool visible =
false;
839 dms LST = geo->GSTtoLST( t.gst() );
856 obsList().takeAt( obsList().indexOf(o) );
862 #include "obslistwizard.moc"
Dialog for changing the geographic location of the observer.
KStarsData is the backbone of KStars.
const QList< SkyObject * > & asteroids() const
static KStarsData * Instance()
const double & Degrees() const
const QList< DeepSkyObject * > & deepSkyObjects() const
const QList< SkyObject * > & constellationNames() const
void setTime(const QTime &t)
Assign the Time according to a QTime object.
The sky coordinates of a point in the sky.
~ObsListWizard()
Destructor.
ObsListWizardUI(QWidget *p)
const QList< SkyObject * > & comets() const
KStarsDateTime addSecs(double s) const
const QList< SkyObject * > & stars() const
Extension of KDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day...
SkyMapComposite * skyComposite()
An angle, stored as degrees, but expressible in many ways.
void EquatorialToHorizontal(const dms *LST, const dms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates, given the local sidereal time and the observer's latitude.
Provides all necessary information about a deep-sky object: data inherited from SkyObject (coordinate...
virtual SkyObject * findByName(const QString &name)
Search the children of this SkyMapComposite for a SkyObject whose name matches the argument...
ConstellationBoundaryLines * getConstellationBoundary()
QString constellationName(SkyPoint *p)
virtual QString name(void) const
Provides all necessary information about an object in the sky: its coordinates, name(s), type, magnitude, and QStringLists of URLs for images and webpages regarding the object.
dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle=0) const
Computes the angular distance between two SkyObjects.
ObsListWizard(QWidget *parent)
Constructor.