• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kstars

modcalcjd.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           modcalcjd.cpp  -  description
00003                              -------------------
00004     begin                : Tue Jan 15 2002
00005     copyright            : (C) 2002 by Pablo de Vicente
00006     email                : vicente@oan.es
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "modcalcjd.h"
00019 #include "modcalcjd.moc"
00020 #include "kstars.h"
00021 #include "kstarsdata.h"
00022 #include "geolocation.h"
00023 #include "libkdeedu/extdate/extdatetimeedit.h"
00024 
00025 #include <qdatetimeedit.h>  //need for QTimeEdit
00026 #include <qradiobutton.h>
00027 #include <klineedit.h>
00028 #include <klocale.h>
00029 #include <kglobal.h>
00030 
00031 #include "kstarsdatetime.h"
00032 
00033 #define MJD0 2400000.5
00034 
00035 modCalcJD::modCalcJD(QWidget *parentSplit, const char *name) : modCalcJdDlg(parentSplit,name) {
00036     
00037     showCurrentTime();
00038     show();
00039 }
00040 
00041 modCalcJD::~modCalcJD(void)
00042 {
00043 }
00044 
00045 void modCalcJD::slotComputeTime (void)
00046 {
00047     
00048     if(DateRadio->isChecked()) {
00049         computeFromCalendar();
00050     } else if (JdRadio->isChecked()) {
00051         JdName->setFocus();
00052         computeFromJd();
00053     } else if (MjdRadio->isChecked()) {
00054         MjdName->setFocus();
00055         computeFromMjd();
00056     }
00057 }
00058 
00059 void modCalcJD::computeFromCalendar (void)
00060 {
00061     long double julianDay, modjulianDay;
00062     
00063     julianDay = getDateTime().djd();
00064     showJd( julianDay );
00065 
00066     modjulianDay = julianDay - MJD0;
00067     showMjd(modjulianDay);
00068 }
00069 
00070 void modCalcJD::computeFromMjd (void)
00071 {
00072     long double julianDay, modjulianDay;
00073 
00074     modjulianDay = KGlobal::locale()->readNumber( MjdName->text() );
00075     julianDay = MJD0 + modjulianDay;
00076     showJd( julianDay );
00077     computeFromJd();
00078 }
00079 
00080 void modCalcJD::computeFromJd (void)
00081 {
00082     long double julianDay, modjulianDay;
00083     julianDay = KGlobal::locale()->readNumber( JdName->text() );
00084     KStarsDateTime dt( julianDay );
00085 
00086     datBox->setDate( dt.date() );
00087     timBox->setTime( dt.time() );
00088 
00089     modjulianDay = julianDay - MJD0;
00090     showMjd( modjulianDay );
00091 }
00092 
00093 
00094 void modCalcJD::slotClearTime (void)
00095 {
00096     JdName->setText ("");
00097     MjdName->setText ("");
00098     datBox->setDate( ExtDate::currentDate() );
00099     timBox->setTime(QTime(0,0,0));
00100 }
00101 
00102 void modCalcJD::showCurrentTime (void)
00103 {
00104     KStars *ks = (KStars*) parent()->parent()->parent();
00105 
00106     KStarsDateTime dt = ks->data()->geo()->LTtoUT( KStarsDateTime::currentDateTime() );
00107     datBox->setDate( dt.date() );
00108     timBox->setTime( dt.time() );
00109     computeFromCalendar();
00110 }
00111 
00112 KStarsDateTime modCalcJD::getDateTime (void)
00113 {
00114     return KStarsDateTime( datBox->date() , timBox->time() );
00115 }
00116 
00117 void modCalcJD::showJd(long double julianDay)
00118 {
00119     JdName->setText(KGlobal::locale()->formatNumber( (double)julianDay, 5 ) );
00120 }
00121 
00122 void modCalcJD::showMjd(long double modjulianDay)
00123 {
00124     MjdName->setText(KGlobal::locale()->formatNumber( (double)modjulianDay, 5 ) );
00125 }

kstars

Skip menu "kstars"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal