Index: trunk/MagicSoft/Cosy/catalog/Makefile
===================================================================
--- trunk/MagicSoft/Cosy/catalog/Makefile	(revision 911)
+++ trunk/MagicSoft/Cosy/catalog/Makefile	(revision 912)
@@ -33,4 +33,6 @@
 SRCFILES = SaoFile.cc \
 	   Slalib.cc \
+	   SlaStars.cc \
+	   SlaPlanets.cc \
 	   StarCatalog.cc
 
Index: trunk/MagicSoft/Cosy/catalog/SlaPlanets.cc
===================================================================
--- trunk/MagicSoft/Cosy/catalog/SlaPlanets.cc	(revision 912)
+++ trunk/MagicSoft/Cosy/catalog/SlaPlanets.cc	(revision 912)
@@ -0,0 +1,73 @@
+#include "SlaPlanets.h"
+
+#include <iostream.h>
+
+#include "slalib.h"
+
+SlaPlanets::SlaPlanets() : Slalib(), fDt(slaDt(2000.0)/60./60./24.)
+{
+}
+
+SlaPlanets::~SlaPlanets()
+{
+}
+
+void SlaPlanets::SetMjd(const double mjd)
+{
+    Slalib::SetMjd(mjd);
+
+    //
+    // coordinates of earth: heliocentric, equatoril, J2000
+    //
+    double veb[3]; // barycentric velocity
+    double ceb[3]; // barycentric coordinates
+    double veh[3]; // heliocentric velocity
+
+    slaEvp(mjd + fDt, 2000.0, veb, ceb, veh, fEarth);
+}
+
+void SlaPlanets::UpdatePlanetPos(ePlanets_t planet)
+{
+    double cp[6] = { 0, 0, 0, 0, 0, 0 };
+
+    double coord[6];
+
+    switch (planet)
+    {
+    case kEMoon:
+        //
+        // -- approximate geocentric pos and vel --
+        //
+        slaDmoon(GetMjd() + fDt, coord);
+        break;
+
+    case kEMercury:
+    case kEVenus:
+    case kEMars:
+    case kEJupiter:
+    case kESaturn:
+    case kEUranus:
+    case kENeptune:
+    case kEPluto:
+        {
+            //
+            // coordinates of planet: heliocentric, equatoril, J2000
+            //
+
+            int rc;
+            slaPlanet(GetMjd(), planet, cp, &rc);
+
+            if (rc)
+                return;
+        }
+        // !! Fall through!
+
+    case kESun:
+        coord[0] = cp[0] - fEarth[0];
+        coord[1] = cp[1] - fEarth[1];
+        coord[2] = cp[2] - fEarth[2];
+        break;
+    }
+
+    fZdAz[planet] = XYZ2ZdAz(coord);
+}
Index: trunk/MagicSoft/Cosy/catalog/SlaPlanets.h
===================================================================
--- trunk/MagicSoft/Cosy/catalog/SlaPlanets.h	(revision 912)
+++ trunk/MagicSoft/Cosy/catalog/SlaPlanets.h	(revision 912)
@@ -0,0 +1,48 @@
+#ifndef SLAPLANETS_H
+#define SLAPLANETS_H
+
+#ifndef SLALIB_H
+#include "Slalib.h"
+#endif
+
+typedef enum
+{
+    kESun      = 0,
+    kEMercury  = 1,
+    kEVenus    = 2,
+    kEMoon     = 3, // earth moon barycentre
+    kEMars     = 4,
+    kEJupiter  = 5,
+    kESaturn   = 6,
+    kEUranus   = 7,
+    kENeptune  = 8,
+    kEPluto    = 9
+} ePlanets_t;
+
+class SlaPlanets : public Slalib
+{
+private:
+    const double fDt;
+
+    ZdAz fZdAz[10];    // [rad]
+
+    double fEarth[3];  // heliocentric coordinates
+
+    ZdAz   GetMoonPos() const;
+
+public:
+    SlaPlanets();
+    virtual ~SlaPlanets();
+
+    //    const AltAz GetAltAz() const { return fAltAz*360/D2PI; }
+    //    const ZdAz  GetZdAz()  const { return ZdAz(DPI/2-fAltAz.Alt(), fAltAz.Az())*360/D2PI; }
+    //    const RaDec GetRaDec() const { return fRaDec*360/D2PI; }
+
+    void SetMjd(const double mjd);
+
+    void UpdatePlanetPos(ePlanets_t planet);
+    ZdAz GetPlanetPos(ePlanets_t planet) const { return fZdAz[planet]; }
+
+};
+
+#endif
Index: trunk/MagicSoft/Cosy/catalog/SlaStars.cc
===================================================================
--- trunk/MagicSoft/Cosy/catalog/SlaStars.cc	(revision 912)
+++ trunk/MagicSoft/Cosy/catalog/SlaStars.cc	(revision 912)
@@ -0,0 +1,108 @@
+#include "SlaStars.h"
+
+#include "slalib.h"
+
+SlaStars::SlaStars() : Slalib()
+{
+}
+
+SlaStars::~SlaStars()
+{
+}
+
+void SlaStars::Set(const AltAz &altaz)
+{
+    fAltAz = altaz * D2PI/360.0;
+    fRaDec = CalcRaDec(fAltAz);
+}
+
+void SlaStars::Set(const ZdAz &zdaz)
+{
+    fAltAz = AltAz(DPI/2-zdaz.Zd(), zdaz.Az()) * D2PI/360.0;
+    fRaDec = CalcRaDec(fAltAz);
+}
+
+void SlaStars::Set(const RaDec &radec)
+{
+    fRaDec = radec * D2PI/360.0;
+    fAltAz = CalcAltAz(fRaDec);
+}
+
+void SlaStars::SetMjd(const double mjd)
+{
+    Slalib::SetMjd(mjd);
+
+    //
+    // ----- calculate star independent parameters ----------
+    //
+    slaMappa(2000.0, mjd, fAmprms);
+    slaAoppa(mjd, 0,                    // mjd, UT1-UTC
+             GetElong(), GetPhi(), 148, // gttingen long, lat, height
+             0, 0,                      // polar motion x, y-coordinate (radians)
+             273.155, 1013.25, 0.5,     // temp, pressure, humidity
+             0.2, 0.0065,               // wavelength, tropo lapse rate
+             fAoprms);
+}
+
+RaDec SlaStars::CalcRaDec(const AltAz &altaz) const
+{
+    return CalcRaDec(ZdAz(DPI/2-altaz.Alt(), altaz.Az()));
+}
+
+RaDec SlaStars::CalcRaDec(const ZdAz &zdaz) const
+{
+    //
+    // -- observed to apparent --
+    //  Workaraound for slalib: discard const
+    //
+    double r=0, d=0;
+    slaOapqk((char*)"A", zdaz.Az(), zdaz.Zd(), (double*)fAoprms, &r, &d);
+
+    //
+    // -- apparent to mean --
+    //  Workaraound for slalib: discard const
+    //
+    double ra, dec;
+    slaAmpqk(r, d, (double*)fAmprms, &ra, &dec);
+
+    return RaDec(ra, dec);
+}
+
+ZdAz SlaStars::CalcZdAz(const RaDec &radec) const
+{
+    //
+    // ---- Mean to apparent ----
+    //
+
+    double r=0, d=0;
+    slaMapqkz(radec.Ra(), radec.Dec(), (double*)fAmprms, &r, &d);
+    //
+    // Doesn't work - don't know why
+    //
+    //    slaMapqk (radec.Ra(), radec.Dec(), rdpm.Ra(), rdpm.Dec(),
+    //              0, 0, (double*)fAmprms, &r, &d);
+    //
+
+    //
+    // -- apparent to observed --
+    //
+    double r1=0;  // ra
+    double d1=0;  // dec
+    double h0=0;  // ha
+
+    double zd;
+    double az;
+    slaAopqk (r, d, (double*)fAoprms,
+              &az,    // observed azimuth (radians: N=0,E=90)
+              &zd,    // observed zenith distance (radians) [-pi/2, pi/2]
+              &h0,    // observed hour angle (radians)
+              &d1,    // observed declination (radians)
+              &r1);   // observed right ascension (radians)
+
+    return ZdAz(zd, az);
+}
+AltAz SlaStars::CalcAltAz(const RaDec &radec) const
+{
+    ZdAz zdaz = CalcZdAz(radec);
+    return AltAz(DPI/2-zdaz.Zd(), zdaz.Az());
+}
Index: trunk/MagicSoft/Cosy/catalog/SlaStars.h
===================================================================
--- trunk/MagicSoft/Cosy/catalog/SlaStars.h	(revision 912)
+++ trunk/MagicSoft/Cosy/catalog/SlaStars.h	(revision 912)
@@ -0,0 +1,36 @@
+#ifndef SLASTARS_H
+#define SLASTARS_H
+
+#include "Slalib.h"
+
+class SlaStars : public Slalib
+{
+private:
+    AltAz    fAltAz;    // [rad]
+    RaDec    fRaDec;    // [rad]
+
+    double   fAmprms[21];
+    double   fAoprms[14];
+
+public:
+    SlaStars();
+    virtual ~SlaStars();
+
+    //    const AltAz GetAltAz() const { return fAltAz*360/D2PI; }
+    //    const ZdAz  GetZdAz()  const { return ZdAz(DPI/2-fAltAz.Alt(), fAltAz.Az())*360/D2PI; }
+    //    const RaDec GetRaDec() const { return fRaDec*360/D2PI; }
+
+    virtual void SetMjd(const double mjd);
+
+    void   Set(const AltAz &altaz);
+    void   Set(const ZdAz  &zdaz);
+    void   Set(const RaDec &radec);
+
+    RaDec  CalcRaDec(const AltAz &altaz) const;
+    RaDec  CalcRaDec(const ZdAz  &altaz) const;
+
+    AltAz  CalcAltAz(const RaDec &radec) const;
+    ZdAz   CalcZdAz (const RaDec &radec) const;
+};
+
+#endif
Index: trunk/MagicSoft/Cosy/catalog/Slalib.cc
===================================================================
--- trunk/MagicSoft/Cosy/catalog/Slalib.cc	(revision 911)
+++ trunk/MagicSoft/Cosy/catalog/Slalib.cc	(revision 912)
@@ -6,5 +6,5 @@
 #include "slalib.h"
 
-Slalib::Slalib()
+Slalib::Slalib() : Timer()
 {
     // p = pointer to MainFrame (not owner)
@@ -25,100 +25,43 @@
 }
 
-void Slalib::Set(const AltAz &altaz)
-{
-    fAltAz = altaz * D2PI/360.0;
-    fRaDec = CalcRaDec(fAltAz);
-}
-
-void Slalib::Set(const ZdAz &zdaz)
-{
-    fAltAz = AltAz(DPI/2-zdaz.Zd(), zdaz.Az()) * D2PI/360.0;
-    fRaDec = CalcRaDec(fAltAz);
-}
-
-void Slalib::Set(const RaDec &radec)
-{
-    fRaDec = radec * D2PI/360.0;
-    fAltAz = CalcAltAz(fRaDec);
-}
-
-void Slalib::Set(const double mjd)
+void Slalib::SetMjd(const double mjd)
 {
     fMjd   = mjd;
     fAlpha = slaGmst(fMjd) + fElong;
+}
+
+void Slalib::SetMjd2Now()
+{
+    Now();
+    SetMjd(CalcMjd());
+//    cout << "GetMjd: "<< (*this)() << " " << GetMjd() << endl;
+}
+
+void Slalib::SetMjd(const struct timeval *tm)
+{
+    SetTimer(tm);
+    SetMjd(CalcMjd());
+}
+
+
+ZdAz Slalib::XYZ2ZdAz(double coord[3]) const
+{
+    //
+    // -- xyz to spherical coordinates --
+    //
+    double ra, dec;
+    slaDcc2s(coord, &ra, &dec);
 
     //
-    // ----- calculate star independent parameters ----------
+    // radec[rad] -> hadec[rad]
     //
-    slaMappa(2000.0, fMjd, fAmprms);
-    slaAoppa(fMjd, 0,                // mjd, UT1-UTC
-             fElong, fPhi, 148,      // gttingen long, lat, height
-             0, 0,                   // polar motion x, y-coordinate (radians)
-             273.155, 1013.25, 0.5,  // temp, pressure, humidity
-             0.2, 0.0065,            // wavelength, tropo lapse rate
-             fAoprms);
-}
-
-RaDec Slalib::CalcRaDec(const AltAz &altaz) const
-{
-    return CalcRaDec(ZdAz(DPI/2-altaz.Alt(), altaz.Az()));
-}
-
-RaDec Slalib::CalcRaDec(const ZdAz &zdaz) const
-{
-    //
-    // -- observed to apparent --
-    //  Workaraound for slalib: discard const
-    //
-    double r=0, d=0;
-    slaOapqk ("A", zdaz.Az(), zdaz.Zd(), (double*)fAoprms, &r, &d);
+    const double ha = fAlpha-ra;
 
     //
-    // -- apparent to mean --
-    //  Workaraound for slalib: discard const
+    // hadec[rad] -> altaz[rad]
     //
-    double ra, dec;
-    slaAmpqk(r, d, (double*)fAmprms, &ra, &dec);
+    double alt, az;
+    slaDe2h(ha, dec, fPhi, &az, &alt);
 
-    return RaDec(ra, dec);
+    return ZdAz(DPI/2-alt, az);
 }
-
-ZdAz Slalib::CalcZdAz(const RaDec &radec) const
-{
-    //
-    // ---- Mean to apparent ----
-    //
-
-    double r=0, d=0;
-    slaMapqkz(radec.Ra(), radec.Dec(), (double*)fAmprms, &r, &d);
-    //
-    // Doesn't work - don't know why
-    //
-    //    slaMapqk (radec.Ra(), radec.Dec(), rdpm.Ra(), rdpm.Dec(),
-    //              0, 0, (double*)fAmprms, &r, &d);
-    //
-
-    //
-    // -- apparent to observed --
-    //
-    double r1=0;  // ra
-    double d1=0;  // dec
-    double h0=0;  // ha
-
-    double zd;
-    double az;
-    slaAopqk (r, d, (double*)fAoprms,
-              &az,    // observed azimuth (radians: N=0,E=90)
-              &zd,    // observed zenith distance (radians) [-pi/2, pi/2]
-              &h0,    // observed hour angle (radians)
-              &d1,    // observed declination (radians)
-              &r1);   // observed right ascension (radians)
-
-    return ZdAz(zd, az);
-}
-AltAz Slalib::CalcAltAz(const RaDec &radec) const
-{
-    ZdAz zdaz = CalcZdAz(radec);
-    return AltAz(DPI/2-zdaz.Zd(), zdaz.Az());
-}
-
Index: trunk/MagicSoft/Cosy/catalog/Slalib.h
===================================================================
--- trunk/MagicSoft/Cosy/catalog/Slalib.h	(revision 911)
+++ trunk/MagicSoft/Cosy/catalog/Slalib.h	(revision 912)
@@ -3,19 +3,14 @@
 
 #include "coord.h"
+#include "base/timer.h"
 
-class Slalib
+class Slalib : public Timer
 {
 private:
-    double   fPhi;      // location of observatory
-    double   fElong;
-
-    AltAz    fAltAz;    // [rad]
-    RaDec    fRaDec;    // [rad]
-
     double   fAlpha;
     double   fMjd;
 
-    double   fAmprms[21];
-    double   fAoprms[14];
+    double   fPhi;      // location of observatory
+    double   fElong;
 
 public:
@@ -27,21 +22,16 @@
     //    const RaDec GetRaDec() const { return fRaDec*360/D2PI; }
 
-    void   Set(const double mjd);
+    void SetMjd2Now();
+    void SetMjd(const struct timeval *tm);
 
-    void   Set(const AltAz &altaz);
-    void   Set(const ZdAz  &zdaz);
-    void   Set(const RaDec &radec);
+    virtual void SetMjd(const double mjd);
 
     double GetAlpha() const { return fAlpha; }
+    double GetMjd() const   { return fMjd; }
 
     double GetPhi() const   { return fPhi; }
     double GetElong() const { return fElong; }
 
-    RaDec  CalcRaDec(const AltAz &altaz) const;
-    RaDec  CalcRaDec(const ZdAz  &altaz) const;
-
-    AltAz  CalcAltAz(const RaDec &radec) const;
-    ZdAz   CalcZdAz (const RaDec &radec) const;
-
+    ZdAz   XYZ2ZdAz(double coord[3]) const;
 };
 
Index: trunk/MagicSoft/Cosy/catalog/StarCatalog.cc
===================================================================
--- trunk/MagicSoft/Cosy/catalog/StarCatalog.cc	(revision 911)
+++ trunk/MagicSoft/Cosy/catalog/StarCatalog.cc	(revision 912)
@@ -9,7 +9,6 @@
 #include "slamac.h"
 #include "File.h"
-#include "timer.h"
-
-StarCatalog::StarCatalog() : fEntries(0)
+
+StarCatalog::StarCatalog() : SlaStars(), fEntries(0)
 {
     // p = pointer to MainFrame (not owner)
@@ -68,5 +67,5 @@
     cout << "  Az: " << fAltAz.Az() << endl;
 
-    fRaDec = sla.CalcRaDec(fAltAz);
+    fRaDec = CalcRaDec(fAltAz);
 
     cout << "Ra: " << 360.0/D2PI*fRaDec.Ra();
@@ -82,5 +81,5 @@
     fRaDec *= D2PI/360.0;
 
-    fAltAz = sla.CalcAltAz(fRaDec);
+    fAltAz = CalcAltAz(fRaDec);
 
     cout << "Alt: " << 360.0/D2PI*fAltAz.Alt() << "  ";
@@ -215,6 +214,6 @@
     double de0, de1;
 
-    const double phi   = sla.GetPhi();
-    const double alpha = sla.GetAlpha();
+    const double phi   = GetPhi();
+    const double alpha = GetAlpha();
     //
     // scan horizontal border
@@ -401,5 +400,5 @@
     memset(cimg, 0, 768*576);
 
-    sla.Set(utc);
+    SetMjd(utc);
     //fAlpha = sla.GetAlpha();
     SetRaDec(radec);
@@ -419,5 +418,5 @@
     memset(cimg, 0, 768*576);
 
-    sla.Set(utc);
+    SetMjd(utc);
     //fAlpha = sla.GetAlpha();
     SetAltAz(altaz);
@@ -496,5 +495,5 @@
     // ---- mean to observed ---
     //
-    AltAz altaz=sla.CalcAltAz(sao->GetRaDec()) * 360.0/D2PI;
+    AltAz altaz=CalcAltAz(sao->GetRaDec()) * 360.0/D2PI;
 
     if (sao->MagV() > fLimitMag)
@@ -520,5 +519,5 @@
     // radec[rad] -> hadec[rad]
     //
-    const double ha = sla.GetAlpha()-ra;
+    const double ha = GetAlpha()-ra;
 
     //
@@ -526,5 +525,5 @@
     //
     double alt, az;
-    slaDe2h(ha, dec, sla.GetPhi(), &az, &alt);
+    slaDe2h(ha, dec, GetPhi(), &az, &alt);
 
     //
Index: trunk/MagicSoft/Cosy/catalog/StarCatalog.h
===================================================================
--- trunk/MagicSoft/Cosy/catalog/StarCatalog.h	(revision 911)
+++ trunk/MagicSoft/Cosy/catalog/StarCatalog.h	(revision 912)
@@ -8,6 +8,6 @@
 #include "SaoFile.h"
 #endif
-#ifndef SLALIB_H
-#include "Slalib.h"
+#ifndef SLASTARS_H
+#include "SlaStars.h"
 #endif
 
@@ -16,5 +16,5 @@
 typedef unsigned char byte;
 
-class StarCatalog
+class StarCatalog : public SlaStars
 {
 private:
@@ -22,9 +22,4 @@
     sort_t  *fSrt;
     int      fEntries;
-
-    Slalib   sla;
-
-//    double   fPhi;      // location of observatory
-//    double   fElong;
 
     double   fPixSize;  // [rad/pix] size of one pixel
@@ -46,9 +41,4 @@
     int      fDecMax;
 
-//    double   fAlpha;
-//    double   fMjd;
-//    double   fAmprms[21];
-//    double   fAoprms[14];
-
     void DrawCross(byte *img, const int x, const int y);
     void DrawCircle(int color, byte *img, int xx, int yy, int size);
@@ -65,5 +55,4 @@
     void   SetRaDec(const RaDec &radec);
     void   SetAltAz(const AltAz &altaz);
-//    void   SetMjd(const double mjd);
     void   DrawSCAltAz(byte *img, const int color);
     void   DrawSCRaDec(byte *img, const int color);
