Index: trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGAccuracy.cc	(revision 912)
+++ trunk/MagicSoft/Cosy/gui/MGAccuracy.cc	(revision 912)
@@ -0,0 +1,141 @@
+//
+// This File contains the definition of the MGCoordinates-class
+//
+//   Author: Thomas Bretz
+//   Version: V1.0 (1-8-2000)
+
+#include "MGAccuracy.h"
+
+#include <iostream.h>  // cout
+
+#include <TArc.h>
+#include <TLine.h>
+#include <TList.h>
+#include <TCanvas.h>
+
+#include "coord.h"
+
+void MGAccuracy::DrawCoordinateSystem()
+{
+    TLine line;
+
+    line.SetLineColor(13);
+    line.SetLineStyle(3);  // dotted  (s. TAttLine)
+    line.DrawLine(-.5,  -1.05, -.5,   1.05);
+    line.DrawLine( -1.05, -.5,   1.05, -.5);
+    line.DrawLine( .5,  -1.05,  .5,   1.05);
+    line.DrawLine( -1.05,  .5,   1.05,  .5);
+
+    line.DrawLine(-.25,  -1.05, -.25,   1.05);
+    line.DrawLine( -1.05, -.25,   1.05, -.25);
+    line.DrawLine( .25,  -1.05,  .25,   1.05);
+    line.DrawLine( -1.05,  .25,   1.05,  .25);
+
+    line.DrawLine(-.75,  -1.05, -.75,   1.05);
+    line.DrawLine( -1.05, -.75,   1.05, -.75);
+    line.DrawLine( .75,  -1.05,  .75,   1.05);
+    line.DrawLine( -1.05,  .75,   1.05,  .75);
+
+    line.SetLineColor(12);
+    line.SetLineStyle(2);  // dashed  (s. TAttLine)
+    line.DrawLine(-1, -1.05, -1,  1.05);
+    line.DrawLine(-1.05, -1,  1.05, -1);
+    line.DrawLine( 1, -1.05,  1,  1.05);
+    line.DrawLine(-1.05,  1,  1.05,  1);
+
+    line.SetLineColor(1);  // black
+    line.SetLineStyle(1);  // solid  (s. TAttLine)
+    line.DrawLine(-1.05,     0, 1.05,    0);
+    line.DrawLine(    0, -1.05,    0, 1.05);
+
+    TArc arc;
+    arc.SetFillStyle(4000);  // transparent
+    arc.SetFillColor(39);
+    arc.SetLineColor(3);     // green
+    arc.SetLineStyle(2);     // dashed  (s. TAttLine)
+    arc.DrawArc(0, 0, 20./60);
+
+    arc.SetLineColor(5);     // yellow
+    arc.DrawArc(0, 0, 40./60);
+
+    arc.SetLineColor(2);     // red
+    arc.DrawArc(0, 0, 1);
+}
+
+void MGAccuracy::InitPosition()
+{
+    fLin1 = new TLine(0, 0, 0, 0);
+    fLin2 = new TLine(0, 0, 0, 0);
+
+    fLin1->SetLineColor(10); // white (s. TAttFill)
+    fLin2->SetLineColor(10); // white
+    fLin1->SetLineStyle(1);  // solid (s. TAttLine)
+    fLin2->SetLineStyle(1); 
+
+    fLin1->Draw();
+    fLin2->Draw();
+
+    fList->Add(fLin1);
+    fList->Add(fLin2);
+}
+
+MGAccuracy::MGAccuracy(const TGWindow* p, const Int_t w, const Int_t h)
+    : TRootEmbeddedCanvas("Accuracy", p, w-1, h-1, kRaisedFrame),//, 0) //234, 76, kFixedSize)
+    fModified(kFALSE)
+{
+    fCanvas = GetCanvas();
+
+    fCanvas->SetFillColor(39); // s. TAttFill
+    fCanvas->Range(-1.1, -1.1, 1.1, 1.1);
+
+    fList = new TList;
+    fList->SetOwner();
+
+    DrawCoordinateSystem();
+    InitPosition();
+
+    Resize(w, h); //GetDefaultSize()); // ???
+
+    MapSubwindows();
+}
+
+MGAccuracy::~MGAccuracy()
+{
+    delete fList;
+
+    cout << "MGAccuracy destroyed." << endl;
+}
+
+void MGAccuracy::Update(ZdAz &zdaz)
+{
+    //
+    // calculate actual time for planet positions
+    //
+
+    fLin1->SetX1(zdaz.Zd()*60.-0.02);
+    fLin1->SetX2(zdaz.Zd()*60.+0.02);
+
+    fLin2->SetX1(zdaz.Zd()*60.-0.02);
+    fLin2->SetX2(zdaz.Zd()*60.+0.02);
+
+    fLin1->SetY1(zdaz.Az()*60.-0.02);
+    fLin1->SetY2(zdaz.Az()*60.+0.02);
+
+    fLin2->SetY1(zdaz.Az()*60.+0.02);
+    fLin2->SetY2(zdaz.Az()*60.-0.02);
+
+    fCanvas->Modified();
+    fCanvas->Update();
+
+    /*
+    DrawPosition(pos.Zd(), pos.Az());
+
+    if (!fModified)
+        return;
+
+    // FIXME: Sometimes (if the canvas couldn't be created correctly:
+    // X11 Pixmap error) Update hangs the Gui system.
+
+    fModified = kFALSE;
+    */
+}
Index: trunk/MagicSoft/Cosy/gui/MGAccuracy.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGAccuracy.h	(revision 912)
+++ trunk/MagicSoft/Cosy/gui/MGAccuracy.h	(revision 912)
@@ -0,0 +1,49 @@
+#ifndef MGACCURACY_H
+#define MGACCURACY_H
+
+//
+// This File contains the declaration of the MGCoordinates-class
+//
+//   Author: Thomas Bretz
+//   Version: V1.0 (1-8-2000)
+
+
+#ifndef ROOT_TRootEmbeddedCanvas
+#include <TRootEmbeddedCanvas.h>
+#endif
+
+class TList;
+class TLine;
+class TCanvas;
+
+class ZdAz;
+class SlaPlanets;
+
+class MGAccuracy : public TRootEmbeddedCanvas
+{
+    TCanvas    *fCanvas;
+
+    TLine      *fLin1;
+    TLine      *fLin2;
+/*
+    TLine      *fLin2;
+*/
+    TList      *fList;
+
+    Bool_t fModified;
+
+    void InitPosition();
+
+    //    void SetLin1(int x, int y);
+    //    void SetLin2(int x1, int y1, int x2, int y2);
+
+    void DrawCoordinateSystem();
+
+public:
+    MGAccuracy(const TGWindow* p, const Int_t w, const Int_t h);
+    ~MGAccuracy();
+
+    void Update(ZdAz &pos);
+};
+
+#endif // MGSKYPOSITION_H
Index: trunk/MagicSoft/Cosy/gui/MGCosy.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 911)
+++ trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 912)
@@ -12,12 +12,13 @@
 #include <TApplication.h>  // gApplication
 
-#include "timer.h"         // Timer
+//#include "timer.h"         // Timer
 
 #include "MCosy.h"
 #include "MGList.h"
+#include "MGAccuracy.h"
 #include "MGCoordinates.h"
 #include "MGSkyPosition.h"
 
-#include "Slalib.h"
+#include "SlaStars.h"
 
 #define IDM_EXIT 1
@@ -155,7 +156,10 @@
     fList->Add(fCoord);
 
-    fSkyPosition = new MGSkyPosition(this);
+    fAccuracy = new MGAccuracy(this, 200, 200);
+    fAccuracy->Move(320, 260);
+    fList->Add(fAccuracy);
+
+    fSkyPosition = new MGSkyPosition(this, 200, 200);
     fSkyPosition->Move(320, 40);
-    fSkyPosition->Resize(200, 200);
     fList->Add(fSkyPosition);
 
@@ -163,5 +167,5 @@
     //   Map the window, set up the layout, etc.
     //
-    SetWMSizeHints(550, 250, 550, 250, 10, 10);  // set the smallest and biggest size of the Main frame
+    SetWMSizeHints(550, 500, 550, 500, 10, 10);  // set the smallest and biggest size of the Main frame
 
     MapSubwindows();
@@ -190,4 +194,10 @@
 
     cout << "MGCosy deleted." << endl;
+}
+// ======================================================================
+void MGCosy::Update(ZdAz pos, ZdAz acc)
+{
+    fSkyPosition->Update(pos);
+    fAccuracy->Update(acc);
 }
 // ======================================================================
@@ -253,9 +263,6 @@
             case kPB_CALCALTAZ:
                 {
-                    Timer t;
-                    t.GetTime();
-
-                    Slalib sla;
-                    sla.Set(t.GetMjd());
+                    SlaStars sla;
+                    sla.SetMjd2Now();
 
                     XY xy = fCoord->GetCoordinates();
Index: trunk/MagicSoft/Cosy/gui/MGCosy.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 911)
+++ trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 912)
@@ -16,4 +16,6 @@
 #include <iostream.h>
 
+#include "coord.h"
+
 class TGLabel;
 class TGPopupMenu;
@@ -27,4 +29,5 @@
 class MGCoordinates;
 class MGSkyPosition;
+class MGAccuracy;
 
 class MGCosy : public TGMainFrame
@@ -46,4 +49,5 @@
     MGCoordinates *fCoord;
     MGSkyPosition *fSkyPosition;
+    MGAccuracy    *fAccuracy;
 
     MsgQueue      *fQueue;
@@ -63,5 +67,5 @@
     TGLabel **GetLabel3() { return fLabel3; }
 
-    MGSkyPosition *GetSkyDisplay() { return fSkyPosition; }
+    void Update(ZdAz pos, ZdAz acc);
 
     Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2);
Index: trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc	(revision 911)
+++ trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc	(revision 912)
@@ -8,49 +8,171 @@
 
 #include <iostream.h>  // cout
-#include <TRootEmbeddedCanvas.h>
-#include <TGWindow.h>
+
 #include <TArc.h>
+#include <TLine.h>
+#include <TList.h>
 #include <TCanvas.h>
-#include <TH1.h>
-#include <TLine.h>
 
 #include "coord.h"
-
-MGSkyPosition::MGSkyPosition(const TGWindow* p)
-: TRootEmbeddedCanvas("SkyPosition", p, 50, 50, kSunkenFrame)//, 0) //234, 76, kFixedSize)
+#include "SlaPlanets.h"
+
+void MGSkyPosition::InitPlanets()
+{
+    //
+    // Magnitudes:
+    // -----------
+    //   Moon     -12.8
+    //   Jupiter   -4.6
+    //   Venus     -4.0
+    //   Mars      -2.0
+    //   Merkur     0.0
+    //   Saturn     0.7
+    //   Uranus     5.5
+    //   Neptun     7.8
+    //
+    fSlalib = new SlaPlanets;
+
+    //
+    // Colors: black .. white:
+    //
+    //   1, 12, 13, 14, 15, 16, 17, 18, 19, 10
+    //
+    fMars = new TArc(0, 0, 1);
+    fMars->SetFillStyle(1001);     // solid      (s. TAttFill)
+    fMars->SetFillColor(13);       // light grey (s. TAttFill)
+    fMars->SetLineColor(12);
+    fMars->Draw();
+
+    fVenus = new TArc(0, 0, 2);
+    fVenus->SetFillStyle(1001);    // solid      (s. TAttFill)
+    fVenus->SetFillColor(15);      // light grey (s. TAttFill)
+    fVenus->SetLineColor(14);
+    fVenus->Draw();
+
+    fJupiter = new TArc(0, 0, 2);
+    fJupiter->SetFillStyle(1001);  // solid      (s. TAttFill)
+    fJupiter->SetFillColor(17);    // light grey (s. TAttFill)
+    fJupiter->SetLineColor(16);
+    fJupiter->Draw();
+
+    fMoon = new TArc(0, 0, 3, 290, 70);
+    fMoon->SetFillStyle(1001);     // solid      (s. TAttFill)
+    fMoon->SetFillColor(19);       // light grey (s. TAttFill)
+    fMoon->SetLineColor(15);
+    fMoon->Draw();
+
+    for (int i=0; i<4; i++)
+    {
+        fSunL[i] = new TLine(0,0,0,0);
+        fSunL[i]->SetLineColor(10);    // white gray
+        fSunL[i]->SetLineStyle(1);     // solid  (s. TAttLine)
+        fSunL[i]->Draw();
+
+        fList->Add(fSunL[i]);
+    }
+
+    fSun = new TArc(0, 0, 2);
+    fSun->SetFillStyle(1001);     // solid      (s. TAttFill)
+    fSun->SetFillColor(10);       // white      (s. TAttFill)
+    fSun->SetLineColor(19);
+    fSun->Draw();
+
+    fList->Add(fMars);
+    fList->Add(fVenus);
+    fList->Add(fJupiter);
+    fList->Add(fMoon);
+    fList->Add(fSun);
+
+    //
+    // Reset 'static' positions of planets
+    //
+    for (int i=0; i<9; i++)
+    {
+        fX[i] = ~0;
+        fY[i] = ~0;
+    }
+}
+
+void MGSkyPosition::DrawCoordinateSystem()
+{
+    TArc arc;
+    arc.SetFillStyle(4000);  // transparent
+    arc.SetLineColor(13);    // dark gray
+    arc.SetLineStyle(1);     // solid  (s. TAttLine)
+    arc.DrawArc(0, 0, 90);
+    arc.DrawArc(0, 0, 67.5);
+    arc.DrawArc(0, 0, 45);
+    arc.DrawArc(0, 0, 22.5);
+
+    TLine line;
+    line.SetLineColor(1);  // black
+    line.SetLineStyle(1);  // solid  (s. TAttLine)
+    line.DrawLine(-95,   0, 95,  0);
+    line.DrawLine(  0, -95,  0, 95);
+}
+
+void MGSkyPosition::InitPosition()
+{
+    fLin1a = new TLine(0, 0, 0, 0);
+    fLin1b = new TLine(0, 0, 0, 0);
+    fLin2  = new TLine(0, 0, 0, 0);
+
+    fLin1a->SetLineColor(5);  // yellow (s. TAttFill)
+    fLin1b->SetLineColor(5);  // yellow
+    fLin2 ->SetLineColor(10); // white
+    fLin1a->SetLineStyle(1);  // solid  (s. TAttLine)
+    fLin1b->SetLineStyle(2);  // dashed
+
+    fLin1a->Draw();
+    fLin1b->Draw();
+    fLin2->Draw();
+
+    fList->Add(fLin1a);
+    fList->Add(fLin1b);
+    fList->Add(fLin2);
+}
+
+MGSkyPosition::MGSkyPosition(const TGWindow* p, const Int_t w, const Int_t h)
+    : TRootEmbeddedCanvas("SkyPosition", p, w-1, h-1, kRaisedFrame),//, 0) //234, 76, kFixedSize)
+    fModified(kFALSE)
 {
     fCanvas = GetCanvas();
 
+    fCanvas->SetFillColor(39); // s. TAttFill
     fCanvas->Range(-100, -100, 100, 100);
 
-    fArc = new TArc;
-    fArc->SetLineColor(15);
-    fArc->DrawArc(0, 0, 90);
-    fArc->DrawArc(0, 0, 67.5);
-    fArc->DrawArc(0, 0, 45);
-    fArc->DrawArc(0, 0, 22.5);
-
-    fLin1 = new TLine;
-    fLin1->DrawLine(-95,   0, 95,  0);
-    fLin1->DrawLine(  0, -95,  0, 95);
-    fLin2 = new TLine;
-
-    //    fCanvas->Modified();
-    //    fCanvas->Update();
-
+    fList = new TList;
+    fList->SetOwner();
+
+    DrawCoordinateSystem();
+    InitPosition();
+    InitPlanets();
+
+    Resize(w, h); //GetDefaultSize()); // ???
     MapSubwindows();
-    //    MapWindow();
-
-    //    DrawPosition(66, 25);
-    //    DrawPosition(22, 278);
 }
 
 MGSkyPosition::~MGSkyPosition()
 {
-    delete fLin1;
-    delete fLin2;
-    delete fArc;
+    delete fList;
+    delete fSlalib;
 
     cout << "MGSkyPosition destroyed." << endl;
+}
+
+void MGSkyPosition::SetLin1(int x, int y)
+{
+    fLin1a->SetX2(x);
+    fLin1a->SetY2(y);
+    fLin1b->SetX2(-x);
+    fLin1b->SetY2(-y);
+}
+
+void MGSkyPosition::SetLin2(int x1, int y1, int x2, int y2)
+{
+    fLin2->SetX1(x1);
+    fLin2->SetX2(x2);
+    fLin2->SetY1(y1);
+    fLin2->SetY2(y2);
 }
 
@@ -71,26 +193,91 @@
         return;
 
-    const int dx = (int)(s*6);
-    const int dy = (int)(c*6);
-
-    delete fArc;
-    fArc = new TArc(x, y, 2);
-    fArc->SetFillStyle(1001);
-    fArc->SetFillColor(43);
-    fArc->Draw();
-
-    delete fLin1;
-    delete fLin2;
-    //fLin1 = new TLine(x-dx, y-dy, x+dx, y+dy);
-    fLin1 = new TLine(0, 0, s*95, c*95);
-    fLin2 = new TLine(x+dy, y-dx, x-dy, y+dx);
-    fLin1->Draw();
-    fLin2->Draw();
-
+    X = x;
+    Y = y;
+
+    const int dx = (int)(s*4);
+    const int dy = (int)(c*4);
+
+    SetLin1(s*95, c*95);
+    SetLin2(x+dy, y-dx, x-dy, y+dx);
+
+    fModified = kTRUE;
+}
+
+void MGSkyPosition::Update(ZdAz &pos)
+{
+    //
+    // calculate actual time for planet positions
+    //
+    fSlalib->SetMjd2Now();
+
+    DrawPlanet(kESun,     fSun);
+    DrawPlanet(kEMoon,    fMoon);
+    DrawPlanet(kEJupiter, fJupiter);
+    DrawPlanet(kEVenus,   fVenus);
+    DrawPlanet(kEMars,    fMars);
+
+    DrawPosition(pos.Zd(), pos.Az());
+
+    if (!fModified)
+        return;
+
+    // FIXME: Sometimes (if the canvas couldn't be created correctly:
+    // X11 Pixmap error) Update hangs the Gui system.
+
+    fCanvas->Modified();
     fCanvas->Update();
-}
-
-void MGSkyPosition::DrawPosition(ZdAz &pos)
-{
-    DrawPosition(pos.Zd(), pos.Az());
-}
+
+    fModified = kFALSE;
+}
+
+void MGSkyPosition::DrawPlanet(Int_t planet, TArc *arc)
+{
+    //
+    // calculate actual position of planet
+    //
+    fSlalib->UpdatePlanetPos((ePlanets_t)planet);
+
+    ZdAz zdaz = fSlalib->GetPlanetPos((ePlanets_t)planet);
+
+    //
+    // check whether we have to change the position where it is drawn
+    //
+    const float s = sin(zdaz.Az());
+    const float c = cos(zdaz.Az());
+
+    const float deg = 360.0/D2PI*zdaz.Zd();
+
+    const int x = (int)(s*deg);
+    const int y = (int)(c*deg);
+
+    if (fX[planet]==x && fY[planet]==y)
+        return;
+
+    fX[planet] = x;
+    fY[planet] = y;
+
+    //
+    // Set new position
+    //
+    arc->SetX1(x);
+    arc->SetY1(y);
+
+    fModified = kTRUE;
+
+    if (planet!=kESun)
+        return;
+
+    cout << "Sun: x=" << x << " y=" << y;
+    cout << "   Zd=" << deg << " Az=" << 360./D2PI*zdaz.Az() << endl;
+
+    fSunL[0]->SetX1(x-4); fSunL[0]->SetX2(x+4);
+    fSunL[1]->SetX1(x-3); fSunL[1]->SetX2(x+3);
+    fSunL[2]->SetX1(x-3); fSunL[2]->SetX2(x+3);
+    fSunL[3]->SetX1(x  ); fSunL[3]->SetX2(x  );
+
+    fSunL[0]->SetY1(y  ); fSunL[0]->SetY2(y  );
+    fSunL[1]->SetY1(y-3); fSunL[1]->SetY2(y+3);
+    fSunL[2]->SetY1(y+3); fSunL[2]->SetY2(y-3);
+    fSunL[3]->SetY1(y-4); fSunL[3]->SetY2(y+4);
+}
Index: trunk/MagicSoft/Cosy/gui/MGSkyPosition.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGSkyPosition.h	(revision 911)
+++ trunk/MagicSoft/Cosy/gui/MGSkyPosition.h	(revision 912)
@@ -13,23 +13,57 @@
 #endif
 
+class TArc;
+class TList;
+class TLine;
 class TCanvas;
-class TArc;
-class TLine;
+
 class ZdAz;
+class SlaPlanets;
 
 class MGSkyPosition : public TRootEmbeddedCanvas
 {
-    TCanvas *fCanvas;
+    TCanvas    *fCanvas;
 
-    TArc    *fArc;
-    TLine   *fLin1;
-    TLine   *fLin2;
+    TArc       *fMoon;
+    TArc       *fJupiter;
+    TArc       *fVenus;
+    TArc       *fMars;
+    TArc       *fSun;
+
+    TLine      *fLin1a;
+    TLine      *fLin1b;
+    TLine      *fLin2;
+
+    TLine      *fSunL[4];
+
+    SlaPlanets *fSlalib;
+
+    TList      *fList;
+
+    Int_t fX[9];
+    Int_t fY[9];
+
+    Bool_t fModified;
+
+    void InitPlanets();
+    void InitPosition();
+
+    void SetLin1(int x, int y);
+    void SetLin2(int x1, int y1, int x2, int y2);
+
+    void DrawPlanet(Int_t planet, TArc *arc);
+    void DrawPosition(Float_t zd, Float_t az);
+    void DrawCoordinateSystem();
+
+    Bool_t CheckRange(Int_t x, Int_t y) const
+    {
+        return x>-95 && x<95 && y>-95 && y<95;
+    }
 
 public:
-    MGSkyPosition(const TGWindow* p);
+    MGSkyPosition(const TGWindow* p, const Int_t w, const Int_t h);
     ~MGSkyPosition();
 
-    void DrawPosition(Float_t zd, Float_t az);
-    void DrawPosition(ZdAz &pos);
+    void Update(ZdAz &pos);
 };
 
Index: trunk/MagicSoft/Cosy/gui/Makefile
===================================================================
--- trunk/MagicSoft/Cosy/gui/Makefile	(revision 911)
+++ trunk/MagicSoft/Cosy/gui/Makefile	(revision 912)
@@ -35,4 +35,5 @@
 	   MGCosy.cc \
 	   MGImage.cc \
+	   MGAccuracy.cc \
 	   MGSkyPosition.cc
 
