[Kstars-devel] KDE/kdeedu/kstars/kstars/skyobjects

Akarsh Simha akarshsimha at gmail.com
Mon Aug 16 19:00:06 CEST 2010


SVN commit 1164397 by asimha:

Adding useful methods to KSMoon, that retrieve the iPhase and the moon
image file in use. These are to be later used in a moon phase
calendar.

CCMAIL: kstars-devel at kde.org

 M  +2 -1      ksmoon.cpp  
 M  +12 -2     ksmoon.h  


--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/ksmoon.cpp #1164396:1164397
@@ -235,12 +235,13 @@
     KSSun *Sun = (KSSun*)KStarsData::Instance()->skyComposite()->findByName( "Sun" );
     Phase = (ecLong()- Sun->ecLong()).Degrees(); // Phase is obviously in degrees
     double DegPhase = dms( Phase ).reduce().Degrees();
-    int iPhase = int( 0.1*DegPhase+0.5 ) % 36; // iPhase must be in [0,36) range
+    iPhase = int( 0.1*DegPhase+0.5 ) % 36; // iPhase must be in [0,36) range
     QString imName = QString().sprintf("moon%02d.png", iPhase);
 
     QFile imFile;
     if ( KSUtils::openDataFile( imFile, imName ) ) {
         imFile.close();
+        imFileName = imFile.fileName();
         image0()->load( imFile.fileName() );
         image()->load( imFile.fileName() );
     }
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/ksmoon.h #1164396:1164397
@@ -65,7 +65,16 @@
     	*/
     virtual bool loadData();
 
-protected:
+    /**
+     * @return iPhase, which is used as a key to find the right image file
+     */
+    inline short int getIPhase() { return iPhase; }
+
+    /**
+     * @return the file name for the correct moon image
+     */
+    inline QString getImageFileName() { return imFileName; }
+
     /**Reimplemented from KSPlanetBase, this function employs unique algorithms for
     	*estimating the lunar coordinates.  Finding the position of the moon is
     	*much more difficult than the other planets.  For one thing, the Moon is
@@ -122,7 +131,8 @@
     };
 
     static QList<MoonBData> BData;
-
+    QString imFileName;
+    unsigned int iPhase;
 };
 
 #endif


More information about the Kstars-devel mailing list