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

kstars

modcalcdaylength.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           modcalcdaylength.cpp  -  description
00003                              -------------------
00004     begin                : wed jun 12 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 "modcalcdaylength.h"
00019 #include "modcalcprec.h"
00020 #include "dms.h"
00021 #include "dmsbox.h"
00022 #include "skyobject.h"
00023 #include "geolocation.h"
00024 #include "kstars.h"
00025 #include "timebox.h"
00026 #include "kssun.h"
00027 #include "ksnumbers.h"
00028 #include "kstarsdatetime.h"
00029 #include "libkdeedu/extdate/extdatetimeedit.h"
00030 
00031 #include <kapplication.h> 
00032 
00033 modCalcDayLength::modCalcDayLength(QWidget *parentSplit, const char *name) : modCalcDayLengthDlg(parentSplit,name) {
00034     showCurrentDate();
00035     initGeo();
00036     show();
00037 }
00038 
00039 modCalcDayLength::~modCalcDayLength() {}
00040 
00041 void modCalcDayLength::showCurrentDate (void)
00042 {
00043     KStarsDateTime dt( KStarsDateTime::currentDateTime() );
00044     datBox->setDate( dt.date() );
00045 }
00046 
00047 void modCalcDayLength::initGeo(void)
00048 {
00049     KStars *ks = (KStars*) parent()->parent()->parent(); // QSplitter->AstroCalc->KStars
00050     geoPlace = ks->geo();
00051     longBox->show( geoPlace->lng() );
00052     latBox->show( geoPlace->lat() );
00053 }
00054 
00055 void modCalcDayLength::getGeoLocation (void)
00056 {
00057     geoPlace->setLong( longBox->createDms() );
00058     geoPlace->setLat(  latBox->createDms() );
00059     geoPlace->setHeight( 0.0);
00060 }
00061 
00062 KStarsDateTime modCalcDayLength::getDateTime (void)
00063 {
00064     return KStarsDateTime( datBox->date() , QTime(8,0,0) );
00065 }
00066 
00067 void modCalcDayLength::slotClearCoords(){
00068 
00069     azSetBox->clearFields();
00070     azRiseBox->clearFields();
00071     elTransitBox->clearFields();
00072 
00073     // reset to current date
00074     datBox->setDate(ExtDate::currentDate());
00075 
00076 // reset times to 00:00:00
00077     setTimeBox->clearFields();
00078     riseTimeBox->clearFields();
00079     transitTimeBox->clearFields();
00080 
00081 //  dayLBox->setTime(time);
00082     dayLBox->clearFields();
00083 }
00084 
00085 QTime modCalcDayLength::lengthOfDay(QTime setQTime, QTime riseQTime){
00086     QTime dL(0,0,0);
00087     int dds = riseQTime.secsTo(setQTime);
00088     QTime dLength = dL.addSecs( dds );
00089 
00090     return dLength;
00091 }
00092 
00093 void modCalcDayLength::slotComputePosTime()
00094 {
00095     long double jd0 = getDateTime().djd();
00096     getGeoLocation();
00097 
00098     KSNumbers * num = new KSNumbers(jd0);
00099     KSSun *Sun = new KSSun(((KStars*) parent()->parent()->parent())->data());
00100     Sun->findPosition(num);
00101 
00102     QTime setQtime = Sun->riseSetTime( jd0 , geoPlace, false );
00103     QTime riseQtime = Sun->riseSetTime( jd0 , geoPlace, true );
00104     QTime transitQtime = Sun->transitTime(jd0 , geoPlace);
00105 
00106     dms setAz = Sun->riseSetTimeAz(jd0, geoPlace, false);
00107     dms riseAz = Sun->riseSetTimeAz(jd0, geoPlace, true);
00108     dms transAlt = Sun->transitAltitude(jd0, geoPlace);
00109 
00110     if (setQtime.isValid() ) {
00111         azSetBox->show( setAz );
00112         elTransitBox->show( transAlt );
00113         azRiseBox->show( riseAz );
00114 
00115         setTimeBox->showTime( setQtime );
00116         riseTimeBox->showTime( riseQtime );
00117         transitTimeBox->showTime( transitQtime );
00118 
00119         QTime dayLQtime = lengthOfDay (setQtime,riseQtime);
00120 
00121         dayLBox->showTime( dayLQtime );
00122     } else if (transAlt.Degrees() > 0. ) {
00123         azSetBox->setDMS(i18n("Circumpolar"));
00124         elTransitBox->show( transAlt );
00125         azRiseBox->setDMS(i18n("Circumpolar"));
00126 
00127         setTimeBox->showTime( setQtime );
00128         riseTimeBox->showTime( riseQtime );
00129         transitTimeBox->showTime( transitQtime );
00130 
00131         dayLBox->setEntry("24:00:00");
00132 
00133     } else if (transAlt.Degrees() < 0. ) {
00134         azSetBox->setDMS("does not rise");
00135         elTransitBox->setDMS("does not rise");
00136         azRiseBox->setDMS("does not rise");
00137 
00138         setTimeBox->clearFields();
00139         riseTimeBox->clearFields();
00140         transitTimeBox->clearFields();
00141 
00142         dayLBox->showTime( QTime(0,0,0) );
00143     }
00144 
00145     delete num;
00146 }
00147 
00148 #include "modcalcdaylength.moc"

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