20 #include <QVBoxLayout>
25 #include <kplotobject.h>
26 #include <kplotwidget.h>
27 #include <kplotaxis.h>
30 #include <QPrintDialog>
31 #include <kdeprintdialog.h>
46 #include "ui_altvstime.h"
59 setCaption( i18n(
"Altitude vs. Time" ) );
60 setButtons( KDialog::Close | KDialog::User1 );
61 setButtonGuiItem( KDialog::User1, KGuiItem( i18n(
"&Print..."),
"document-print", i18n(
"Print the Altitude vs. time plot") ) );
64 QVBoxLayout* topLayout =
new QVBoxLayout( page );
65 topLayout->setMargin( 0 );
66 topLayout->setSpacing( spacingHint() );
70 avtUI->View->setLimits( -12.0, 12.0, -90.0, 90.0 );
71 avtUI->View->setShowGrid(
false );
72 avtUI->View->axis(KPlotWidget::BottomAxis)->setTickLabelFormat(
't' );
73 avtUI->View->axis(KPlotWidget::BottomAxis)->setLabel( i18n(
"Local Time" ) );
74 avtUI->View->axis(KPlotWidget::TopAxis)->setTickLabelFormat(
't' );
75 avtUI->View->axis(KPlotWidget::TopAxis)->setTickLabelsShown(
true );
76 avtUI->View->axis(KPlotWidget::TopAxis)->setLabel( i18n(
"Local Sidereal Time" ) );
77 avtUI->View->axis(KPlotWidget::LeftAxis)->setLabel(
i18nc(
"the angle of an object above (or below) the horizon",
"Altitude" ) );
79 avtUI->raBox->setDegType(
false );
80 avtUI->decBox->setDegType(
true );
84 avtUI->longBox->setReadOnly(
true );
85 avtUI->latBox->setReadOnly(
true );
87 topLayout->addWidget( avtUI );
93 if (
getDate().time().hour() > 12 )
96 avtUI->longBox->show( geo->
lng() );
97 avtUI->latBox->show( geo->
lat() );
103 connect( avtUI->browseButton, SIGNAL( clicked() ),
this, SLOT(
slotBrowseObject() ) );
104 connect( avtUI->cityButton, SIGNAL( clicked() ),
this, SLOT(
slotChooseCity() ) );
105 connect( avtUI->updateButton, SIGNAL( clicked() ),
this, SLOT(
slotUpdateDateLoc() ) );
106 connect( avtUI->clearButton , SIGNAL( clicked() ),
this, SLOT(
slotClear() ) );
107 connect( avtUI->addButton, SIGNAL( clicked() ),
this, SLOT(
slotAddSource() ) );
108 connect( avtUI->nameBox, SIGNAL( returnPressed() ),
this, SLOT(
slotAddSource() ) );
109 connect( avtUI->raBox, SIGNAL( returnPressed() ),
this, SLOT(
slotAddSource() ) );
110 connect( avtUI->decBox, SIGNAL( returnPressed() ),
this, SLOT(
slotAddSource() ) );
111 connect( avtUI->clearFieldsButton, SIGNAL( clicked() ),
this, SLOT(
slotClearBoxes() ) );
112 connect( avtUI->longBox, SIGNAL( returnPressed() ),
this, SLOT(
slotAdvanceFocus() ) );
113 connect( avtUI->latBox, SIGNAL( returnPressed() ),
this, SLOT(
slotAdvanceFocus() ) );
114 connect( avtUI->PlotList, SIGNAL( currentRowChanged(
int) ),
this, SLOT(
slotHighlight(
int) ) );
115 connect( button( KDialog::User1 ), SIGNAL( clicked() ),
this, SLOT(
slotPrint() ) );
118 avtUI->nameBox->setTrapReturnKey(
true );
119 avtUI->raBox->setTrapReturnKey(
true );
120 avtUI->decBox->setTrapReturnKey(
true );
122 setMouseTracking(
true );
144 processObject( obj );
150 if( ! avtUI->nameBox->text().isEmpty() &&
151 ! avtUI->raBox->text().isEmpty() &&
152 ! avtUI->decBox->text().isEmpty() )
155 dms newRA = avtUI->raBox->createDms(
false, &okRA );
156 dms newDec = avtUI->decBox->createDms(
true, &okDec );
157 if( !okRA || !okDec )
163 dt.
setFromEpoch( getEpoch( avtUI->epochName->text() ) );
164 long double jd = dt.
djd();
168 newRA.setH( ptest.
ra().
Hours() );
183 deleteList.append( obj );
184 processObject( obj );
191 if( avtUI->nameBox->text().isEmpty() ) {
192 avtUI->nameBox->QWidget::setFocus();
194 if( avtUI->raBox->text().isEmpty() ) {
195 avtUI->raBox->QWidget::setFocus();
197 if ( avtUI->decBox->text().isEmpty() )
198 avtUI->decBox->QWidget::setFocus();
202 avtUI->View->update();
207 QPointer<FindDialog> fd =
new FindDialog(
this);
208 if ( fd->exec() == QDialog::Accepted ) {
214 avtUI->View->update();
242 if ( found && !forceAdd ) {
243 kDebug() <<
"This point is already displayed; I will not duplicate it.";
248 foreach(KPlotObject* obj, avtUI->View->plotObjects()) {
249 if ( obj->size() == 2 )
250 obj->setLinePen( QPen( Qt::red, 1 ) );
254 KPlotObject *po =
new KPlotObject( Qt::white, KPlotObject::Lines, 2.0 );
255 for (
double h=-12.0; h<=12.0; h+=0.5 ) {
256 int label_pos = -11.0 + avtUI->View->plotObjects().count();
257 while ( label_pos > 11.0 )
262 po->addPoint( h, findAltitude( o, h ) );
264 avtUI->View->addPlotObject( po );
267 avtUI->PlotList->setCurrentRow( avtUI->PlotList->count() - 1 );
268 avtUI->raBox->showInHours(o->
ra() );
269 avtUI->decBox->showInDegrees(o->
dec() );
273 avtUI->epochName->setText( QString().setNum( getDate().epoch() ) );
275 kDebug() <<
"Currently, there are " << avtUI->View->plotObjects().count() <<
" objects displayed.";
287 hour += 24.0 * DayOffset;
292 dms LST = geo->GSTtoLST( ut.
gst() );
300 for (
int i=0; i<objects.count(); ++i ) {
301 KPlotObject *obj = objects.at( i );
304 obj->setLinePen( QPen( Qt::white, 2 ) );
306 obj->setLinePen( QPen( Qt::red, 1 ) );
310 avtUI->View->update();
312 if( row >= 0 && row < pList.size() ) {
314 avtUI->raBox->showInHours( p->
ra() );
315 avtUI->decBox->showInDegrees( p->
dec() );
316 avtUI->nameBox->setText( avtUI->PlotList->currentItem()->text() );
322 if ( sender()->objectName() == QString(
"nameBox" ) ) avtUI->addButton->setFocus();
323 if ( sender()->objectName() == QString(
"raBox" ) ) avtUI->decBox->setFocus();
324 if ( sender()->objectName() == QString(
"decbox" ) ) avtUI->addButton->setFocus();
325 if ( sender()->objectName() == QString(
"longBox" ) ) avtUI->latBox->setFocus();
326 if ( sender()->objectName() == QString(
"latBox" ) ) avtUI->updateButton->setFocus();
332 while( !deleteList.isEmpty() )
333 delete deleteList.takeFirst();
335 avtUI->PlotList->clear();
336 avtUI->nameBox->clear();
337 avtUI->raBox->clear();
338 avtUI->decBox->clear();
339 avtUI->epochName->clear();
340 avtUI->View->removeAllPlotObjects();
341 avtUI->View->update();
345 avtUI->nameBox->clear();
346 avtUI->raBox->clear() ;
347 avtUI->decBox->clear();
348 avtUI->epochName->clear();
360 avtUI->View->setSunRiseSetTimes( sunRise, sunSet );
368 dms LST = geo->GSTtoLST( today.
gst() );
371 computeSunRiseSetTimes();
375 for (
int i = 0; i < avtUI->PlotList->count(); ++i ) {
376 QString oName = avtUI->PlotList->item( i )->text().toLower();
390 pList.replace( i, o );
392 KPlotObject *po =
new KPlotObject( Qt::white, KPlotObject::Lines, 1 );
393 for (
double h=-12.0; h<=12.0; h+=0.5 ) {
394 po->addPoint( h, findAltitude( o, h ) );
396 avtUI->View->replacePlotObject( i, po );
406 pList.at(i)->updateCoords( num );
408 KPlotObject *po =
new KPlotObject( Qt::white, KPlotObject::Lines, 1 );
409 for (
double h=-12.0; h<=12.0; h+=0.5 ) {
410 po->addPoint( h, findAltitude( pList.at(i), h ) );
412 avtUI->View->replacePlotObject( i, po );
416 if ( getDate().time().hour() > 12 )
422 slotHighlight( avtUI->PlotList->currentRow() );
423 avtUI->View->update();
430 if ( ld->exec() == QDialog::Accepted ) {
434 avtUI->latBox->showInDegrees( geo->lat() );
435 avtUI->longBox->showInDegrees( geo->lng() );
445 dms lst = geo->GSTtoLST( ut.
gst() );
446 double h1 = lst.
Hours();
449 double h2 = h1 + 24.0;
450 avtUI->View->setSecondaryLimits( h1, h2, -90.0, 90.0 );
456 if( dt.time() > QTime( 12, 0, 0 ) )
458 avtUI->DateWidget->
setDate( dt.date() );
465 return geo->LTtoUT( dt );
472 double epoch = eName.toDouble(&ok);
474 kDebug() <<
"Invalid Epoch. Assuming 2000.0.";
480 void AltVsTime::setDawnDusk()
484 dms LST = geo->GSTtoLST( today.
gst() );
488 double dawn, da, dusk, du, max_alt, min_alt;
489 double last_h = -12.0;
490 double last_alt = findAltitude( &sun, last_h );
494 for (
double h=-11.95; h<=12.0; h+=0.05 ) {
495 double alt = findAltitude( &sun, h );
496 bool asc = alt - last_alt > 0;
502 if ( asc && last_alt <= -18.0 && alt >= -18.0 )
504 if ( !asc && last_alt >= -18.0 && alt <= -18.0 )
511 if ( dawn < -12.0 || dusk < -12.0 ) {
516 du = ( dusk + 24.0 ) / 24.0;
519 avtUI->View->setDawnDuskTimes( da, du );
520 avtUI->View->setMinMaxSunAlt( min_alt, max_alt );
529 int text_height = 200;
535 printer.setResolution( 300 );
538 QPointer<QPrintDialog> dialog( KdePrint::createPrintDialog( &printer,
this ) );
539 dialog->setWindowTitle( i18n(
"Print elevation vs time plot" ) );
540 if ( dialog->exec() == QDialog::Accepted ) {
542 QApplication::setOverrideCursor( Qt::WaitCursor );
545 plot_font = avtUI->View->font();
547 plot_font_size = plot_font.pointSize();
549 plot_size = avtUI->View->size();
552 str_legend = i18n(
"Elevation vs. Time Plot" );
554 str_legend += geo->fullName();
556 str_legend += avtUI->DateWidget->date().toString(
"dd/MM/yyyy" );
559 QRect text_rect( 0, 0, printer.width(), text_height );
562 plot_font.setPointSize( plot_font_size * 2.5 );
563 avtUI->View->setFont( plot_font );
565 avtUI->View->resize( printer.width(), printer.height() - text_height );
568 QPixmap pixmap( avtUI->View->size() );
569 avtUI->View->render( &pixmap );
574 p.drawText( text_rect, Qt::AlignLeft, str_legend );
576 p.drawPixmap( 0, text_height, pixmap );
581 plot_font.setPointSize( plot_font_size );
582 avtUI->View->setFont( plot_font );
584 avtUI->View->resize( plot_size );
587 QApplication::restoreOverrideCursor();
593 #include "altvstime.moc"
Dialog for changing the geographic location of the observer.
SkyObject * objectNamed(const QString &name)
Find object by name.
KStarsData is the backbone of KStars.
void setDate(KStarsDateTime *newdt)
Set the date for computations to the given date.
AltVsTimeUI(QWidget *p=0)
Child class of KSPlanetBase; encapsulates information about the Sun.
QString translatedName() const
void showCurrentDate()
Set the AltVsTime Date according to the current Date in the KStars main window.
void slotBrowseObject()
Launch the Find Object window to select a new object for the list of displayed objects.
void slotClear()
Clear the list of displayed objects.
KStarsDateTime addDays(int nd) const
Modify the Date/Time by adding a number of days.
static KStarsData * Instance()
const double & Degrees() const
void slotClearBoxes()
Clear the edit boxes for specifying a new object.
double findAltitude(SkyPoint *p, double hour)
Determine the altitude coordinate of a SkyPoint, given an hour of the day.
void setDate(const QDate &d)
Assign the Date according to a QDate object.
virtual void updateCoords(KSNumbers *num, bool includePlanets=true, const dms *lat=0, const dms *LST=0, bool forceRecompute=false)
Determine the current coordinates (RA, Dec) from the catalog coordinates (RA0, Dec0), accounting for both precession and nutation.
A class that implements methods to find sun rise, sun set, twilight begin / end times, moon rise and moon set times.
double getEpoch(const QString &eName)
Parse a string as an epoch number.
bool setFromEpoch(double e)
Set the Date/Time from an epoch value, represented as a double.
void processObject(SkyObject *o, bool forceAdd=false)
Add a SkyObject to the display.
The sky coordinates of a point in the sky.
double getSunRise()
All the functions returns the fraction of the day as their return value.
Contains all relevant information for specifying a location on Earth: City Name, State/Province name...
void slotPrint()
Print plot widget.
static KStarsDateTime currentDateTime(KDateTime::Spec ts=KDateTime::Spec::ClockTime())
KStarsDateTime addSecs(double s) const
i18nc("string from libindi, used in the config dialog","100x")
Extension of KDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day...
bool isSolarSystem() const
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)
void computeSunRiseSetTimes()
Determine the time of sunset and sunrise for the current date and location settings.
AltVsTime(QWidget *parent=0)
Constructor.
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.
There are several time-dependent values used in position calculations, that are not specific to an ob...
void slotAdvanceFocus()
Move input keyboard focus to the next logical widget.
void slotHighlight(int)
Update the plot to highlight the altitude curve of the objects which is highlighted in the listbox...
void precessFromAnyEpoch(long double jd0, long double jdf)
General case of precession.
void slotUpdateDateLoc()
Update the plot to reflec new Date and Location settings.
const KStarsDateTime & ut() const
void setD(const double &x)
Sets floating-point value of angle, in degrees.
virtual QString name(void) const
void setLSTLimits()
Determine the limits for the sideral time axis, using the sidereal time at midnight for the current d...
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.
void slotAddSource()
Add an object to the list of displayed objects, according to the data entered in the edit boxes...
void setLocation(GeoLocation *m_geo)
Set the location for computations to the given location.
void slotChooseCity()
Launch the Location dialog to choose a new location.