[Kstars-devel] branches/kstars/summer/kstars/kstars

Prakash Mohan prak902000 at gmail.com
Sat May 9 13:35:34 CEST 2009


SVN commit 965572 by prakash:

Fixing some compile errors in ksalmanac.. Also, the rise and set times were wrongly computed before. 

CCMAIL: kstars-devel at kde.org


 M  +1 -1      CMakeLists.txt  
 M  +28 -19    ksalmanac.cpp  
 M  +3 -3      ksalmanac.h  
 M  +3 -5      tools/altvstime.cpp  
 M  +59 -58    tools/altvstime.h  


--- branches/kstars/summer/kstars/kstars/CMakeLists.txt #965571:965572
@@ -301,7 +301,7 @@
 	colorscheme.cpp	dms.cpp fov.cpp geolocation.cpp
 	imageviewer.cpp infobox.cpp infoboxes.cpp 
 	ksfilereader.cpp ksnumbers.cpp
-	kspopupmenu.cpp kstars.cpp 
+	kspopupmenu.cpp kstars.cpp ksalmanac.cpp 
 	kstarsactions.cpp kstarsdata.cpp kstarsdatetime.cpp kstarsdcop.cpp kstarsinit.cpp 
 	kstarssplash.cpp ksutils.cpp kswizard.cpp main.cpp 
 	simclock.cpp skymap.cpp skymapdraw.cpp skymapevents.cpp
--- branches/kstars/summer/kstars/kstars/ksalmanac.cpp #965571:965572
@@ -27,7 +27,7 @@
 #include "kstarsdatetime.h"
 #include "ksnumbers.h"
 #include "dms.h"
-
+#include "skyobjects/skyobject.h"
 KSAlmanac* KSAlmanac::pinstance=NULL;
 
 KSAlmanac* KSAlmanac::Instance() {
@@ -39,25 +39,34 @@
     ks = KStars::Instance();
     dt = KStarsDateTime::currentDateTime();
     geo = ks->geo();
+    m_Sun = new KSSun;
+    m_Moon = new KSMoon;
+    SunRise=SunSet=MoonRise=MoonSet=0;
     update();
-	riseRate = 4.0/cos(m_Sun->dec())/14400.0;
+    riseRate = 4.0/ m_Sun->dec()->cos()/14400.0;
 }
 
-void update() {
+void KSAlmanac::update() {
     RiseSetTime( (SkyObject*)m_Sun, &SunRise, &SunSet );
     RiseSetTime( (SkyObject*)m_Moon, &MoonRise, &MoonSet );
+    kDebug()<< SunRise<<" "<<SunSet;
 }
 void KSAlmanac::RiseSetTime( SkyObject *o, double *riseTime, double *setTime ) {
     //Compute Sun rise and set times
-    *riseTime = -1.0 * o->riseSetTime( dt.djd() + 1.0, geo, true ).secsTo(QTime()) / 86400.0;
-    *setTime = -1.0 * o->riseSetTime( dt.djd(), geo, false ).secsTo(QTime()) / 86400.0;
-    //check to see if Sun is circumpolar
+    const KStarsDateTime today = dt;
+    const GeoLocation _geo = geo;
+//    *riseTime = -1.0 * o->riseSetTime( today.djd() + 1.0, geo, true ).secsTo(QTime()) / 86400.0;
+//     *setTime = -1.0 * o->riseSetTime( today.djd(), geo, false ).secsTo(QTime()) / 86400.0;
+    *riseTime = -1.0 * o->riseSetTime( today, &_geo, true ).secsTo(QTime()) / 86400.0; 
+    *setTime = -1.0 * o->riseSetTime( today, &_geo, false ).secsTo(QTime()) / 86400.0;
+  
+  //check to see if Sun is circumpolar
     //requires temporary repositioning of Sun to target date
     KSNumbers *num = new KSNumbers( dt.djd() );
     KSNumbers *oldNum = new KSNumbers( ks->data()->ut().djd() );
-    dms LST = geo->GSTtoLST( dt.gst() );
-    o->updateCoords( num, true, geo->lat(), &LST );
-    if ( o->checkCircumpolar( geo->lat() ) ) {
+    dms LST = ks->geo()->GSTtoLST( dt.gst() );
+    o->updateCoords( num, true, ks->geo()->lat(), &LST );
+    if ( o->checkCircumpolar( ks->geo()->lat() ) ) {
         if ( o->alt()->Degrees() > 0.0 ) {
             //Circumpolar, signal it this way:
             *riseTime = 0.0;
@@ -80,22 +89,22 @@
     update();
 }
 
-void KSAlmanac::setLocation( Geolocation *m_geo ) {
+void KSAlmanac::setLocation( GeoLocation *m_geo ) {
     geo = *m_geo;
     update();
 }
 
-double KSAlmanac::getAstroTwilight( bool begin = true ) {
-	if(begin) return ( SunRise - 18 * riseRate ); 
-	return ( SunSet + 18 * riseRate );
+double KSAlmanac::getAstroTwilight( bool begin ) {
+    if(begin) return ( SunRise - 18 * riseRate ); 
+    return ( SunSet + 18 * riseRate );
 } 
 
-double KSAlmanac::getNauticalTwilight( bool begin = true ) {
-	if(begin) return ( SunRise - 12 * riseRate ); 
-	return ( SunSet + 12 * riseRate );
+double KSAlmanac::getNauticalTwilight( bool begin ) {
+    if(begin) return ( SunRise - 12 * riseRate ); 
+    return ( SunSet + 12 * riseRate );
 }
 
-double KSAlmanac::getCivilTwilight( bool begin = true ) {
-	if(begin) return ( SunRise - 6 * riseRate ); 
-	return ( SunSet + 6 * riseRate );
+double KSAlmanac::getCivilTwilight( bool begin ) {
+    if(begin) return ( SunRise - 6 * riseRate ); 
+    return ( SunSet + 6 * riseRate );
 }
--- branches/kstars/summer/kstars/kstars/ksalmanac.h #965571:965572
@@ -40,11 +40,11 @@
         double getCivilTwilight( bool begin = true );
 
     private:
-        KSAlmanac( ); 
+        KSAlmanac(); 
         void update();
         static KSAlmanac *pinstance;
-        KSSun m_Sun();
-        KSMoon m_Moon();
+        KSSun *m_Sun;
+        KSMoon *m_Moon;
 		KStars *ks;
         KStarsDateTime dt;
         GeoLocation geo;
--- branches/kstars/summer/kstars/kstars/tools/altvstime.cpp #965571:965572
@@ -34,6 +34,7 @@
 #include <kplotwidget.h>
 
 #include "ui_altvstime.h"
+#include "ksalmanac.h"
 #include "dms.h"
 #include "kstars.h"
 #include "kstarsdata.h"
@@ -45,7 +46,6 @@
 #include "dialogs/locationdialog.h"
 #include "widgets/dmsbox.h"
 #include "avtplotwidget.h"
-
 #include "kstarsdatetime.h"
 
 AltVsTimeUI::AltVsTimeUI( QWidget *p ) : QFrame( p ) {
@@ -56,7 +56,7 @@
         KDialog( parent )
 {
     ks = (KStars*) parent;
-
+	ksal = KSAlmanac::Instance();
     QFrame *page = new QFrame( this );
     setMainWidget(page);
     setCaption( i18n( "Altitude vs. Time" ) );
@@ -98,7 +98,6 @@
     avtUI->latBox->show( geo->lat() );
 
     computeSunRiseSetTimes();
-
     setLSTLimits();
 
     connect( avtUI->browseButton, SIGNAL( clicked() ), this, SLOT( slotBrowseObject() ) );
@@ -353,7 +352,6 @@
     SkyObject *oSun = ks->data()->objectNamed( "Sun" );
     double sunRise = -1.0 * oSun->riseSetTime( today.djd() + 1.0, geo, true ).secsTo(QTime()) / 86400.0;
     double sunSet = -1.0 * oSun->riseSetTime( today.djd(), geo, false ).secsTo(QTime()) / 86400.0;
-	kDebug() << sunRise<<"  "<<sunSet;
     //check to see if Sun is circumpolar
     //requires temporary repositioning of Sun to target date
     KSNumbers *num = new KSNumbers( today.djd() );
@@ -371,7 +369,7 @@
             sunSet = -1.0;
         }
     }
-
+	kDebug() << sunRise<<"  "<<sunSet;
     //Notify the View about new sun rise/set times:
     avtUI->View->setSunRiseSetTimes( sunRise, sunSet );
 
--- branches/kstars/summer/kstars/kstars/tools/altvstime.h #965571:965572
@@ -24,6 +24,7 @@
 #include <QPaintEvent>
 
 #include "ui_altvstime.h"
+#include "ksalmanac.h"
 
 class KStarsDateTime;
 class QVBoxLayout;
@@ -41,124 +42,124 @@
 };
 
 /**@class AltVsTime
-	*@short the Altitude vs. Time Tool.
-	*Plot the altitude as a function of time for any list of 
-	*objects, as seen from any location, on any date.
-	*@version 1.0
-	*@author Jason Harris
-	*/
+    *@short the Altitude vs. Time Tool.
+    *Plot the altitude as a function of time for any list of 
+    *objects, as seen from any location, on any date.
+    *@version 1.0
+    *@author Jason Harris
+    */
 class AltVsTime : public KDialog
 {
     Q_OBJECT
 
 public:
     /**Constructor
-    	*/
+        */
     AltVsTime( QWidget* parent = 0);
 
     /**Destructor
-    	*/
+        */
     ~AltVsTime();
 
     /**Determine the limits for the sideral time axis, using
-    	*the sidereal time at midnight for the current date 
-    	*and location settings.
-    	*/
+        *the sidereal time at midnight for the current date 
+        *and location settings.
+        */
     void setLSTLimits();
 
     /**Set the AltVsTime Date according to the current Date
-    	*in the KStars main window.  Currently, this is only 
-    	*used in the ctor to initialize the Date.
-    	*/
+        *in the KStars main window.  Currently, this is only 
+        *used in the ctor to initialize the Date.
+        */
     void showCurrentDate (void);
 
     /**@return a KStarsDateTime object constructed from the
-    	*current setting in the Date widget.
-    	*/
+        *current setting in the Date widget.
+        */
     KStarsDateTime getDate (void);
 
     /**Determine the time of sunset and sunrise for the current
-    	*date and location settings.  Convert the times to doubles, 
-    	*expressing the times as fractions of a full day.
-    	*Calls AVTPlotWidget::setSunRiseSetTimes() to send the 
-    	*numbers to the plot widget.
-    	*/
+        *date and location settings.  Convert the times to doubles, 
+        *expressing the times as fractions of a full day.
+        *Calls AVTPlotWidget::setSunRiseSetTimes() to send the 
+        *numbers to the plot widget.
+        */
     void computeSunRiseSetTimes();
 
     /**Parse a string as an epoch number.  If the string can't
-    	*be parsed, return 2000.0.
-    	*@param eName the epoch string to be parsed
-    	*@return the epoch number
-    	*/
+        *be parsed, return 2000.0.
+        *@param eName the epoch string to be parsed
+        *@return the epoch number
+        */
     double getEpoch( const QString &eName );
 
     /**@short Add a SkyObject to the display.
-    	*Constructs a PLotObject representing the Alt-vs-time curve for the object.
-    	*@param o pointer to the SkyObject to be added
-    	*@param forceAdd if true, then the object will be added, even if there 
-    	*is already a curve for the same coordinates.
-    	*/
+        *Constructs a PLotObject representing the Alt-vs-time curve for the object.
+        *@param o pointer to the SkyObject to be added
+        *@param forceAdd if true, then the object will be added, even if there 
+        *is already a curve for the same coordinates.
+        */
     void processObject( SkyObject *o, bool forceAdd=false );
 
     /**@short Determine the altitude coordinate of a SkyPoint,
-    	*given an hour of the day.
-    	*
-    	*This is called for every 30-minute interval in the displayed Day, 
-    	*in order to construct the altitude curve for a given object.
-    	*@param p the skypoint whose altitude is to be found
-    	*@param hour the time in the displayed day, expressed in hours
-    	*@return the Altitude, expresse in degrees
-    	*/
+        *given an hour of the day.
+        *
+        *This is called for every 30-minute interval in the displayed Day, 
+        *in order to construct the altitude curve for a given object.
+        *@param p the skypoint whose altitude is to be found
+        *@param hour the time in the displayed day, expressed in hours
+        *@return the Altitude, expresse in degrees
+        */
     double findAltitude( SkyPoint *p, double hour );
 
     /**@return the currently highlighted item in the list of displayed
-    	*objects
-    	*/
+        *objects
+        */
     int currentPlotListItem() const;
 
     /**@return a pointer to the list of SkyObjects representing the
-    	*objects being displayed.
-    	*/
+        *objects being displayed.
+        */
     QList<SkyObject*>& skyPointList() { return pList; }
 
 public slots:
     /**@short Update the plot to reflec new Date and Location settings.
-    	*/
+        */
     void slotUpdateDateLoc(void);
 
     /**@short Clear the list of displayed objects.
-    	*/
+        */
     void slotClear(void);
 
     /**@short Clear the edit boxes for specifying a new object.
-    	*/
+        */
     void slotClearBoxes(void);
 
     /**@short Add an object to the list of displayed objects, according
-    	*to the data entered in the edit boxes.
-    	*/
+        *to the data entered in the edit boxes.
+        */
     void slotAddSource(void);
 
     /**@short Launch the Find Object window to select a new object for
-    	*the list of displayed objects.
-    	*/
+        *the list of displayed objects.
+        */
     void slotBrowseObject(void);
 
     /**@short Launch the Location dialog to choose a new location.
-    	*/
+        */
     void slotChooseCity(void);
 
     /**@short Move input keyboard focus to the next logical widget.
-    	*We need a separate slot for this because we are intercepting 
-    	*Enter key events, which close the window by default, to 
-    	*advance input focus instead (when the Enter events occur in 
-    	*certain Edit boxes).
-    	*/
+        *We need a separate slot for this because we are intercepting 
+        *Enter key events, which close the window by default, to 
+        *advance input focus instead (when the Enter events occur in 
+        *certain Edit boxes).
+        */
     void slotAdvanceFocus(void);
 
     /**Update the plot to highlight the altitude curve of the objects
-    	*which is highlighted in the listbox.
-    	*/
+        *which is highlighted in the listbox.
+        */
     void slotHighlight(int);
 
 private:
@@ -169,7 +170,7 @@
     KStars *ks;
     QList<SkyObject*> pList;
     QList<SkyObject*> deleteList;
-
+    KSAlmanac *ksal;
     int DayOffset;
     bool dirtyFlag;
 };


More information about the Kstars-devel mailing list