22 #include <QListWidgetItem>
24 #include <kcombobox.h>
26 #include <kpushbutton.h>
28 #include "ui_wutdialog.h"
56 setCaption( i18n(
"What's up Tonight") );
57 setButtons( KDialog::Close );
61 if ( T0.time().hour() < 6 )
70 Tomorrow = T0.
addSecs( 12*3600 );
71 TomorrowUT = geo->
LTtoUT( Tomorrow );
74 Evening = T0.
addSecs( -6*3600 );
75 EveningUT = geo->
LTtoUT( Evening );
80 WUT->LocationLabel->setText( i18n(
"at %1", sGeo ) );
81 WUT->DateLabel->setText( i18n(
"The night of %1", KGlobal::locale()->formatDate( Evening.date(), KLocale::LongDate ) ) );
83 WUT->MagnitudeEdit->setValue( m_Mag );
84 WUT->MagnitudeEdit->setSliderEnabled(
true );
85 WUT->MagnitudeEdit->setSingleStep(0.100);
90 QTimer::singleShot(0,
this, SLOT(
init()));
96 void WUTDialog::makeConnections() {
97 connect( WUT->DateButton, SIGNAL( clicked() ), SLOT( slotChangeDate() ) );
98 connect( WUT->LocationButton, SIGNAL( clicked() ), SLOT( slotChangeLocation() ) );
99 connect( WUT->CenterButton, SIGNAL( clicked() ), SLOT( slotCenter() ) );
100 connect( WUT->DetailButton, SIGNAL( clicked() ), SLOT( slotDetails() ) );
101 connect( WUT->ObslistButton, SIGNAL( clicked() ), SLOT( slotObslist() ) );
102 connect( WUT->CategoryListWidget, SIGNAL( currentTextChanged(
const QString &) ),
103 SLOT( slotLoadList(
const QString &) ) );
104 connect( WUT->ObjectListWidget, SIGNAL( currentTextChanged(
const QString &) ),
105 SLOT( slotDisplayObject(
const QString &) ) );
106 connect( WUT->EveningMorningBox, SIGNAL( activated(
int) ), SLOT( slotEveningMorning(
int) ) );
107 connect( WUT->MagnitudeEdit, SIGNAL( valueChanged(
double ) ), SLOT( slotChangeMagnitude() ) );
110 void WUTDialog::initCategories() {
111 m_Categories << i18n(
"Planets" ) << i18n(
"Stars" )
112 << i18n(
"Nebulae" ) << i18n(
"Galaxies" )
113 << i18n(
"Star Clusters" ) << i18n(
"Constellations" )
114 << i18n(
"Asteroids" ) << i18n(
"Comets" );
116 foreach (
const QString &c, m_Categories )
117 WUT->CategoryListWidget->addItem( c );
119 WUT->CategoryListWidget->setCurrentRow( 0 );
123 QString sRise, sSet, sDuration;
128 foreach (
const QString &c, m_Categories ) {
129 if ( m_VisibleList.contains( c ) )
130 visibleObjects( c ).clear();
134 m_CategoryInitialized[ c ] =
false;
139 sunRiseTomorrow = oSun->
riseSetTime( TomorrowUT, geo,
true );
140 sunSetToday = oSun->
riseSetTime( EveningUT, geo,
false );
141 sunRiseToday = oSun->
riseSetTime( EveningUT, geo,
true );
146 dms LST = geo->GSTtoLST( T0.gst() );
151 sRise = i18n(
"circumpolar" );
152 sSet = i18n(
"circumpolar" );
154 Dur = hDur = mDur = 0;
156 sRise = i18n(
"does not rise" );
157 sSet = i18n(
"does not rise" );
164 sRise = KGlobal::locale()->formatTime( sunRiseTomorrow );
165 sSet = KGlobal::locale()->formatTime( sunSetToday );
167 Dur = 24.0 + (float)sunRiseTomorrow.hour()
168 + (float)sunRiseTomorrow.minute()/60.0
169 + (float)sunRiseTomorrow.second()/3600.0
170 - (float)sunSetToday.hour()
171 - (float)sunSetToday.minute()/60.0
172 - (float)sunSetToday.second()/3600.0;
174 mDur = int(60.0*(Dur - (
float)hDur));
175 QTime tDur( hDur, mDur );
176 sDuration = KGlobal::locale()->formatTime( tDur,
false,
true );
179 WUT->SunSetLabel->setText(
i18nc(
"Sunset at time %1 on date %2",
"Sunset: %1 on %2" , sSet, KGlobal::locale()->formatDate( Evening.date(), KLocale::LongDate) ) );
180 WUT->SunRiseLabel->setText(
i18nc(
"Sunrise at time %1 on date %2",
"Sunrise: %1 on %2" , sRise, KGlobal::locale()->formatDate( Tomorrow.date(), KLocale::LongDate) ) );
182 WUT->NightDurationLabel->setText( i18n(
"Night duration: %1", sDuration ) );
184 WUT->NightDurationLabel->setText( i18n(
"Night duration: %1 hours", sDuration ) );
186 WUT->NightDurationLabel->setText( i18n(
"Night duration: %1 hour", sDuration ) );
188 WUT->NightDurationLabel->setText( i18n(
"Night duration: %1 minutes", sDuration ) );
190 WUT->NightDurationLabel->setText( i18n(
"Night duration: %1 minute", sDuration ) );
201 sRise = i18n(
"circumpolar" );
202 sSet = i18n(
"circumpolar" );
204 sRise = i18n(
"does not rise" );
205 sSet = i18n(
"does not rise" );
209 sRise = KGlobal::locale()->formatTime( moonRise.addSecs(30) );
210 sSet = KGlobal::locale()->formatTime( moonSet.addSecs(30) );
213 WUT->MoonRiseLabel->setText( i18n(
"Moon rises at: %1 on %2", sRise, KGlobal::locale()->formatDate( Evening.date(), KLocale::LongDate) ) );
217 if( moonSet > moonRise )
218 WUT->MoonSetLabel->setText( i18n(
"Moon sets at: %1 on %2", sSet, KGlobal::locale()->formatDate( Evening.date(), KLocale::LongDate) ) );
220 WUT->MoonSetLabel->setText( i18n(
"Moon sets at: %1 on %2", sSet, KGlobal::locale()->formatDate( Tomorrow.date(), KLocale::LongDate) ) );
222 WUT->MoonIllumLabel->setText( oMoon->
phaseName() + QString(
" (%1%)" ).arg(
223 int(100.0*oMoon->
illum() ) ) );
230 if ( WUT->CategoryListWidget->currentItem() )
231 slotLoadList( WUT->CategoryListWidget->currentItem()->text() );
238 return m_VisibleList[ category ];
241 bool WUTDialog::isCategoryInitialized(
const QString &category ) {
242 return m_CategoryInitialized[ category ];
245 void WUTDialog::slotLoadList(
const QString &c ) {
247 if ( ! m_VisibleList.contains( c ) )
250 WUT->ObjectListWidget->clear();
251 setCursor(QCursor(Qt::WaitCursor));
253 if ( ! isCategoryInitialized(c) ) {
255 if ( c == m_Categories[0] ) {
259 if ( checkVisibility( o ) && o->
mag() <= m_Mag )
260 visibleObjects(c).append(o);
263 m_CategoryInitialized[ c ] =
true;
266 else if ( c == m_Categories[1] ) {
268 if ( o->
name() != i18n(
"star") && checkVisibility(o) && o->
mag() <= m_Mag )
269 visibleObjects(c).append(o);
271 m_CategoryInitialized[ c ] =
true;
274 else if ( c == m_Categories[5] ) {
276 if ( checkVisibility(o) )
277 visibleObjects(c).append(o);
279 m_CategoryInitialized[ c ] =
true;
282 else if ( c == m_Categories[6] ) {
284 if ( checkVisibility(o) && o->
name() != i18n(
"Pluto") && o->
mag() <= m_Mag )
285 visibleObjects(c).append(o);
287 m_CategoryInitialized[ c ] =
true;
290 else if ( c == m_Categories[7] ) {
292 if ( checkVisibility(o) )
293 visibleObjects(c).append(o);
295 m_CategoryInitialized[ c ] =
true;
301 if ( checkVisibility(o) && o->
mag() <= m_Mag ) {
302 switch( o->
type() ) {
305 visibleObjects(m_Categories[4]).append(o);
310 visibleObjects(m_Categories[2]).append(o);
313 visibleObjects(m_Categories[3]).append(o);
319 m_CategoryInitialized[ m_Categories[2] ] =
true;
320 m_CategoryInitialized[ m_Categories[3] ] =
true;
321 m_CategoryInitialized[ m_Categories[4] ] =
true;
326 foreach (
SkyObject *o, visibleObjects(c) )
327 WUT->ObjectListWidget->addItem( o->
name() );
329 setCursor(QCursor(Qt::ArrowCursor));
332 if ( WUT->ObjectListWidget->count() ) {
333 WUT->ObjectListWidget->setCurrentRow( 0 );
334 WUT->ObjectListWidget->setFocus();
339 bool visible(
false );
352 if ( EveningFlag==0 ) {
354 }
else if ( EveningFlag==1 ) {
361 dms LST = geo->GSTtoLST( ut.
gst() );
376 void WUTDialog::slotDisplayObject(
const QString &name ) {
377 QTime tRise, tSet, tTransit;
378 QString sRise, sTransit, sSet;
383 WUT->DetailButton->setEnabled(
false );
386 if ( name.isEmpty() )
388 WUT->ObjectBox->setTitle( i18n(
"No Object Selected" ) );
394 WUT->ObjectBox->setTitle( i18n(
"Object Not Found" ) );
398 WUT->ObjectBox->setTitle( o->
name() );
402 sRise = i18n(
"circumpolar" );
403 sSet = i18n(
"circumpolar" );
405 sRise = i18n(
"does not rise" );
406 sSet = i18n(
"does not rise" );
415 sRise.sprintf(
"%02d:%02d", tRise.hour(), tRise.minute() );
417 sSet.sprintf(
"%02d:%02d", tSet.hour(), tSet.minute() );
425 sTransit.sprintf(
"%02d:%02d", tTransit.hour(), tTransit.minute() );
427 WUT->DetailButton->setEnabled(
true );
430 WUT->ObjectRiseLabel->setText( i18n(
"Rises at: %1", sRise ) );
431 WUT->ObjectTransitLabel->setText( i18n(
"Transits at: %1", sTransit ) );
432 WUT->ObjectSetLabel->setText( i18n(
"Sets at: %1", sSet ) );
435 void WUTDialog::slotCenter() {
439 if (WUT->ObjectListWidget->currentItem() != 0) {
440 o = kstars->
data()->
objectNamed( WUT->ObjectListWidget->currentItem()->text() );
449 void WUTDialog::slotDetails() {
453 if (WUT->ObjectListWidget->currentItem() != 0) {
454 o = kstars->
data()->
objectNamed( WUT->ObjectListWidget->currentItem()->text() );
457 QPointer<DetailDialog> detail =
new DetailDialog(o, kstars->
data()->
lt(), geo, kstars);
462 void WUTDialog::slotObslist() {
466 if (WUT->ObjectListWidget->currentItem() != 0) {
467 o = kstars->
data()->
objectNamed( WUT->ObjectListWidget->currentItem()->text() );
474 void WUTDialog::slotChangeDate() {
478 T0.setTime( QTime( 18, 0, 0 ) );
481 if ( td->exec() == QDialog::Accepted ) {
482 T0 = td->selectedDateTime();
485 if ( T0.time() == QTime( 0, 0, 0 ) )
486 T0.setTime( QTime( 0, 0, 1 ) );
489 if ( T0.time().hour() < 6 )
490 T0 = T0.addDays( -1 );
493 T0.setTime( QTime( 0, 0, 0 ) );
494 T0 = T0.addDays( 1 );
495 UT0 = geo->LTtoUT( T0 );
498 Tomorrow = T0.addSecs( 12*3600 );
499 TomorrowUT = geo->LTtoUT( Tomorrow );
502 Evening = T0.addSecs( -6*3600 );
503 EveningUT = geo->LTtoUT( Evening );
505 WUT->DateLabel->setText( i18n(
"The night of %1", KGlobal::locale()->formatDate( Evening.date(), KLocale::LongDate ) ) );
508 slotLoadList( WUT->CategoryListWidget->currentItem()->text() );
513 void WUTDialog::slotChangeLocation() {
515 if ( ld->exec() == QDialog::Accepted ) {
520 TomorrowUT = geo->LTtoUT( Tomorrow );
521 EveningUT = geo->LTtoUT( Evening );
523 WUT->LocationLabel->setText( i18n(
"at %1", geo->fullName() ) );
526 slotLoadList( WUT->CategoryListWidget->currentItem()->text() );
532 void WUTDialog::slotEveningMorning(
int index ) {
533 if ( EveningFlag != index ) {
536 slotLoadList( WUT->CategoryListWidget->currentItem()->text() );
540 void WUTDialog::updateMag() {
541 m_Mag = WUT->MagnitudeEdit->value();
543 slotLoadList( WUT->CategoryListWidget->currentItem()->text() );
546 void WUTDialog::slotChangeMagnitude() {
550 timer =
new QTimer(
this );
551 timer->setSingleShot(
true );
552 connect( timer, SIGNAL( timeout() ),
this, SLOT( updateMag() ) );
556 #include "wutdialog.moc"
Dialog for changing the geographic location of the observer.
window showing detailed information for a selected object.
SkyObject * objectNamed(const QString &name)
Find object by name.
KStarsData is the backbone of KStars.
QString translatedName() const
Child class of KSPlanetBase; encapsulates information about the Sun.
void init()
Determine which objects are visible, and store them in an array of lists, classified by object type...
void setFocusObject(SkyObject *o)
Set the FocusObject pointer to the argument.
const QList< SkyObject * > & asteroids() const
KStarsDateTime addDays(int nd) const
Modify the Date/Time by adding a number of days.
void setDestination(const SkyPoint &f)
sets the destination point of the sky map.
static KStarsData * Instance()
const double & Degrees() const
const QList< DeepSkyObject * > & deepSkyObjects() const
QTime riseSetTime(const KStarsDateTime &dt, const GeoLocation *geo, bool rst, bool exact=true)
Determine the time at which the point will rise or set.
const QList< SkyObject * > & constellationNames() const
KStarsDateTime LTtoUT(const KStarsDateTime <) const
static KStars * Instance()
SkyPoint * focusPoint()
retrieve the FocusPoint position.
QTime transitTime(const KStarsDateTime &dt, const GeoLocation *geo)
The same iteration technique described in riseSetTime() is used here.
This is the main window for KStars.
void setTime(const QTime &t)
Assign the Time according to a QTime object.
virtual void findPhase(const KSSun *Sun=0)
Determine the phase angle of the moon, and assign the appropriate moon image.
WUTDialogUI(QWidget *p=0)
QString translatedProvince() const
The sky coordinates of a point in the sky.
bool checkCircumpolar(const dms *gLat)
Check if this point is circumpolar at the given geographic latitude.
bool checkVisibility(SkyObject *o)
Check visibility of object o the object to check.
const KStarsDateTime & lt() const
ObservingList * observingList() const
Contains all relevant information for specifying a location on Earth: City Name, State/Province name...
const QList< SkyObject * > & comets() const
KStarsDateTime addSecs(double s) const
i18nc("string from libindi, used in the config dialog","100x")
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.
virtual void updateCoords(KSNumbers *num, bool includePlanets=true, const dms *lat=0, const dms *LST=0, bool forceRecompute=false)
Update position of the planet (reimplemented from SkyPoint)
WUTDialog(QWidget *ks, bool session=false, GeoLocation *geo=KStarsData::Instance() ->geo(), KStarsDateTime lt=KStarsData::Instance() ->lt())
Constructor.
QString phaseName() const
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...
There are several time-dependent values used in position calculations, that are not specific to an ob...
A subclass of SkyObject that provides information needed for the Moon.
SkyPoint recomputeCoords(const KStarsDateTime &dt, const GeoLocation *geo=0)
The coordinates for the object on date dt are computed and returned, but the object's internal coordi...
virtual SkyObject * findByName(const QString &name)
Search the children of this SkyMapComposite for a SkyObject whose name matches the argument...
KStarsData * data() const
const KStarsDateTime & ut() const
virtual QString name(void) const
void setFocusPoint(SkyPoint *f)
set the FocusPoint; the position that is to be the next Destination.
QHash< int, QStringList > & objectNames()
QString translatedCountry() 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.