Index: trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGAccuracy.cc	(revision 920)
+++ trunk/MagicSoft/Cosy/gui/MGAccuracy.cc	(revision 921)
@@ -190,9 +190,10 @@
     aaz *= d2r;
 
-    const float dphi2 = aaz/2.;
-    const float cos2  = cos(dphi2)*cos(dphi2);
-    const float sin2  = sin(dphi2)*sin(dphi2);
-
-    float dist = acos(cos(azd)*cos2 - cos(2*pzd+azd)*sin2);
+    const double dphi2 = aaz/2.;
+    const double cos2  = cos(dphi2)*cos(dphi2);
+    const double sin2  = sin(dphi2)*sin(dphi2);
+    const double d     = cos(azd)*cos2 - cos(2*pzd+azd)*sin2;
+
+    double dist = acos(d);
 
     dist *= 3600./d2r;
Index: trunk/MagicSoft/Cosy/gui/MGCoordinate.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCoordinate.cc	(revision 920)
+++ trunk/MagicSoft/Cosy/gui/MGCoordinate.cc	(revision 921)
@@ -23,8 +23,8 @@
 };
 
-MGCoordinate::MGCoordinate(const TGWindow* p,
+MGCoordinate::MGCoordinate(const TGWindow* p, const Int_t type=kETypeDeg,
                            const Bool_t flag, const char *txt,
                            const Int_t deg, const UInt_t min, const UInt_t sec)
-: TGFrame(p, 114, flag?76:46, kSunkenFrame|kFixedSize), fDeg(deg), fMin(min), fSec(sec)
+: TGFrame(p, 119, flag?76:46, kSunkenFrame|kFixedSize), fDeg(deg), fMin(min), fSec(sec)
 {
     // p = pointer to MainFrame (not owner)
@@ -37,7 +37,7 @@
         // fTextEntryMin->SetAlignment(kTextCenterX);
         // fTextEntrySec->SetAlignment(kTextCenterX);
-        fTextEntryDeg->Move( 4, 26);
-        fTextEntryMin->Move(44, 26);
-        fTextEntrySec->Move(78, 26);
+        fTextEntryDeg->Move( 7, 26);
+        fTextEntryMin->Move(47, 26);
+        fTextEntrySec->Move(81, 26);
         fTextEntryDeg->MapWindow();
         fTextEntryMin->MapWindow();
@@ -60,7 +60,7 @@
     fLabelMin->SetTextJustify(kTextRight);
     fLabelSec->SetTextJustify(kTextRight);
-    fLabelDeg->Move( 4+6, ypos);
-    fLabelMin->Move(44+6, ypos);
-    fLabelSec->Move(78+6, ypos);
+    fLabelDeg->Move(13, ypos);
+    fLabelMin->Move(53, ypos);
+    fLabelSec->Move(87, ypos);
     fLabelDeg->MapWindow();
     fLabelMin->MapWindow();
@@ -82,40 +82,44 @@
     TGLabel *label;
 
+    const char *deg = type==kETypeDeg ? "\xb0" : "h";
+    const char *min = type==kETypeDeg ? "'"    : "m";
+    const char *sec = type==kETypeDeg ? "\""   : "s";
+
     if (flag)
     {
-        label = new TGLabel(this, "\xb0");
+        label = new TGLabel(this, deg);
         label->SetTextJustify(kTextLeft);
-        label->Move(36, 26);
+        label->Move(39, 26);
         label->MapWindow();
         fList.Add(label);
 
-        label = new TGLabel(this, "'");
+        label = new TGLabel(this, min);
         label->SetTextJustify(kTextLeft);
-        label->Move(70, 26);
+        label->Move(73, 26);
         label->MapWindow();
         fList.Add(label);
 
-        label = new TGLabel(this, "\"");
+        label = new TGLabel(this, sec);
         label->SetTextJustify(kTextLeft);
-        label->Move(104, 26);
+        label->Move(107, 26);
         label->MapWindow();
         fList.Add(label);
     }
 
-    label = new TGLabel(this, "\xb0");
+    label = new TGLabel(this, deg);
     label->SetTextJustify(kTextLeft);
-    label->Move(36, ypos);
+    label->Move(39, ypos);
     label->MapWindow();
     fList.Add(label);
 
-    label = new TGLabel(this, "'");
+    label = new TGLabel(this, min);
     label->SetTextJustify(kTextLeft);
-    label->Move(70, ypos);
+    label->Move(73, ypos);
     label->MapWindow();
     fList.Add(label);
  
-    label = new TGLabel(this, "\"");
+    label = new TGLabel(this, sec);
     label->SetTextJustify(kTextLeft);
-    label->Move(104, ypos);
+    label->Move(107, ypos);
     label->MapWindow();
     fList.Add(label);
Index: trunk/MagicSoft/Cosy/gui/MGCoordinate.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCoordinate.h	(revision 920)
+++ trunk/MagicSoft/Cosy/gui/MGCoordinate.h	(revision 921)
@@ -14,4 +14,9 @@
 #include "MGList.h"
 #endif
+
+enum {
+    kETypeDeg,
+    kETypeH
+};
 
 class TGLabel;
@@ -41,5 +46,5 @@
 
 public:
-    MGCoordinate(const TGWindow* p,
+    MGCoordinate(const TGWindow* p, const Int_t type=kETypeDeg,
                  const Bool_t flag=kTRUE, const char *txt="Coordinates:",
                  const Int_t deg=0, const UInt_t min=0, const UInt_t sec=0);
Index: trunk/MagicSoft/Cosy/gui/MGCoordinates.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCoordinates.cc	(revision 920)
+++ trunk/MagicSoft/Cosy/gui/MGCoordinates.cc	(revision 921)
@@ -12,16 +12,20 @@
 
 MGCoordinates::MGCoordinates(const TGWindow* p,
+                             const Int_t type,
                              const Bool_t flag,
-                             const char *txt1, const char *txt2,
                              const Int_t deg1, const UInt_t min1, const UInt_t sec1,
                              const Int_t deg2, const UInt_t min2, const UInt_t sec2)
-: TGFrame(p, 234, 76, kFixedSize)
+: TGFrame(p, 244, 76, kFixedSize)
 {
+    const Int_t t    = type==kETypeZdAz ? kETypeDeg : kETypeH;
+    const char *txt1 = type==kETypeZdAz ? "Zenith Dist [\xb0]:" : "Right Ascension [h]:";
+    const char *txt2 = type==kETypeZdAz ? "Azimuth [\xb0]:" : "Declination [\xb0]:";
+
     // p = pointer to MainFrame (not owner)
-    fX = new MGCoordinate(this, flag, txt1, deg1, min1, sec1);
+    fX = new MGCoordinate(this, t, flag, txt1, deg1, min1, sec1);
     fX->Move(0, 0);
 
-    fY = new MGCoordinate(this, flag, txt2, deg2, min2, sec2);
-    fY->Move(120, 0);
+    fY = new MGCoordinate(this, kETypeDeg, flag, txt2, deg2, min2, sec2);
+    fY->Move(125, 0);
 
     MapWindow();
Index: trunk/MagicSoft/Cosy/gui/MGCoordinates.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCoordinates.h	(revision 920)
+++ trunk/MagicSoft/Cosy/gui/MGCoordinates.h	(revision 921)
@@ -15,4 +15,9 @@
 #endif
 
+enum {
+    kETypeZdAz,
+    kETypeRaDec
+};
+
 class MGCoordinate;
 
@@ -23,8 +28,6 @@
 
 public:
-    MGCoordinates(const TGWindow* p,
+    MGCoordinates(const TGWindow* p, const Int_t type=kETypeZdAz,
                   const Bool_t flag=kTRUE,
-                  const char *txt1="Coordinate1:",
-                  const char *txt2="Coordinate2:",
                   const Int_t deg1=0, const UInt_t min1=0, const UInt_t sec1=0,
                   const Int_t deg2=0, const UInt_t min2=0, const UInt_t sec2=0);
Index: trunk/MagicSoft/Cosy/gui/MGCosy.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 920)
+++ trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 921)
@@ -191,6 +191,18 @@
 }
 
-void MGCosy::CreateButton(TGCompositeFrame *tf1, TGCompositeFrame *tf2)
-{
+void MGCosy::CreateTabs(TGTab *fTab)
+{
+    TGCompositeFrame *tf1 = fTab->AddTab("Position Zd/Az");
+    TGCompositeFrame *tf2 = fTab->AddTab("Track Ra/Dec");
+
+    fCZdAz = new MGCoordinates(tf1, kETypeZdAz);
+    fCZdAz->Move(27, 105);
+    fList->Add(fCZdAz);
+
+    fCRaDec = new MGCoordinates(tf2, kETypeRaDec);
+    fCRaDec->Move(27, 105);
+    fList->Add(fCRaDec);
+
+
     const int x=15;
     const int y=12;
@@ -235,39 +247,32 @@
     // red:   164, 192, 224, 232
     //
-
-    //    TGTextButton *fButton1 = new TGTextButton(this, "Position Zd/Az", kPB_POSITION);
-    //    TGTextButton *fButton2 = new TGTextButton(this, "Track   Ra/Dec", kPB_TRACK);
-    TGTextButton *fButton4 = new TGTextButton(this, "Calc Zd/Az",  kPB_CALCALTAZ);
-    TGTextButton *fButton5 = new TGTextButton(this, "Set Polaris", kPB_POLARIS);
-    //    fButton1->Move(120,  40);
-    //    fButton2->Move(120,  65);
-    fButton4->Resize(80, 25);
-    fButton5->Resize(80, 25);
-
-    fButton4->Move(40, 257);
-    fButton5->Move(40, 288);
-    //fButton4->SetBackgroundColor(12);
-    //fButton5->SetBackgroundColor(16);
-    //    fButton1->SetToolTipText("Move Telescope to Zd/Az position.");
-    //    fButton2->SetToolTipText("Track the coordinates given in Ra/Dec.");
-    fButton4->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec.");
-    fButton5->SetToolTipText("Set the actual position as the position of Polaris.");
-    //    fList->Add(fButton1);
-    //    fList->Add(fButton2);
-    fList->Add(fButton4);
-    fList->Add(fButton5);
-
-    TGTextButton *fStart = new TGTextButton(this, "Start", kPB_START);
-    TGTextButton *fStop  = new TGTextButton(this, "Stop",  kPB_STOP);
-    fStart->SetBackgroundColor(20);
-    fStop ->SetBackgroundColor(224);
-    fStart->Move(147, 275);
-    fStop ->Move(212, 275);
-    fStart->Resize(60, 25);
-    fStop ->Resize(60, 25);
-    fStart->SetToolTipText("Start a telescope movement.");
-    fStop ->SetToolTipText("Stop any movement of telescope.");
-    fList->Add(fStart);
-    fList->Add(fStop);
+    TGTextButton *but;
+
+    but= new TGTextButton(this, "Calc Zd/Az",  kPB_CALCALTAZ);
+    but->Resize(80, 25);
+    but->Move(37, 257);
+    but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec.");
+    fList->Add(but);
+
+    but = new TGTextButton(this, "Set Polaris", kPB_POLARIS);
+    but->Resize(80, 25);
+    but->Move(37, 288);
+    but->SetToolTipText("Set the actual position as the position of Polaris.");
+    fList->Add(but);
+
+    but = new TGTextButton(this, "Start", kPB_START);
+    but->SetBackgroundColor(20);
+    but->Move(147, 275);
+    but->Resize(62, 25);
+    but->SetToolTipText("Start a telescope movement.");
+    fList->Add(but);
+
+    but = new TGTextButton(this, "Stop",  kPB_STOP);
+    but->SetBackgroundColor(224);
+    but->Move(212, 275);
+    but->Resize(62, 25);
+    but->SetToolTipText("Stop any movement of telescope.");
+    fList->Add(but);
+
 }
 
@@ -284,11 +289,9 @@
 
     fTab = new TGTab(f, 300, 300);
-    TGCompositeFrame *tf1 = fTab->AddTab("Position Zd/Az");
-    TGCompositeFrame *tf2 = fTab->AddTab("Track Ra/Dec");
     fList->Add(fTab);
 
     fSkyPosition = new MGSkyPosition(f, 300);
     fAccuracy    = new MGAccuracy   (f, 300);
-    fVelocity    = new MGVelocity   (f, "Velocity ['/min]", 300);
+    fVelocity    = new MGVelocity   (f, "Velocity [\"/min]", 300);
 //    fOffset      = new MGVelocity   (f, "Offset se-re [']", 300);
 
@@ -304,4 +307,5 @@
     fLog = new TGListBox(f, -1, kSunkenFrame);  //kSunkenFrame|kDoubleBorder,
     fLog->Resize(300, 300);
+    fLog->ChangeBackground(TGFrame::GetBlackPixel());
     fList->Add(fLog);
 
@@ -321,10 +325,5 @@
     // FIXME!
     //
-    fCoord = new MGCoordinates(this, kTRUE,
-                               "Coordinate 1 [\xb0]:", "Coordinate 2 [\xb0]:");
-    fCoord->Move(40, 165);
-    fList->Add(fCoord);
-
-    CreateButton(tf1, tf2);
+    CreateTabs(fTab);
     CreateLabel(frame);
 
@@ -384,5 +383,5 @@
     {
         zd = (Int_t)off.Zd();
-        sprintf(text, "%ld", zd);
+        sprintf(text, "%d", zd);
         fOffsetZd->SetText(new TGString(text));
     }
@@ -390,5 +389,5 @@
     {
         az = (Int_t)off.Az();
-        sprintf(text, "%ld", az);
+        sprintf(text, "%d", az);
         fOffsetAz->SetText(new TGString(text));
     }
@@ -442,24 +441,30 @@
 }
 
-void MGCosy::Start(UInt_t id)
-{
-    cout << "Start " << (id?"tracking.":"positioning.") << endl;
-
-    XY xy = fCoord->GetCoordinates();
-
-    if (id)
-    {
-        RaDec dest(xy.X(), xy.Y());
-        cout << dest.Ra() << kDEG << " " << dest.Dec() << kDEG << endl;
-        fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));
-    }
-    else
-    {
-        ZdAz dest(xy.X(), xy.Y());
-        cout << dest.Zd() << kDEG << " " << dest.Az() << kDEG << endl;
-        fQueue->PostMsg(WM_POSITION, &dest, sizeof(dest));
-    }
-
-    cout << "PostMsg (" << (id?"WM_Track":"WM_Position") << ") returned." << endl;
+void MGCosy::StartTrack()
+{
+    cout << "Start tracking." << endl;
+
+    XY xy = fCRaDec->GetCoordinates();
+    RaDec dest(xy.X()*15., xy.Y()); // xy.X()  [h]->[ø]
+
+    cout << dest.Ra() << "h " << dest.Dec() << "\xb0" << endl;
+
+    fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));
+
+    cout << "PostMsg (WM_Track) returned." << endl;
+}
+
+void MGCosy::StartPos()
+{
+    cout << "Start positioning." << endl;
+
+    XY xy = fCZdAz->GetCoordinates();
+    ZdAz dest(xy.X(), xy.Y());
+
+    cout << dest.Zd() << kDEG << " " << dest.Az() << kDEG << endl;
+
+    fQueue->PostMsg(WM_POSITION, &dest, sizeof(dest));
+
+    cout << "PostMsg (WM_Position) returned." << endl;
 }
 
@@ -482,4 +487,5 @@
             switch (mp1)
             {
+                /*
             case kPB_POSITION:
                 Start(0);
@@ -489,7 +495,7 @@
                 Start(1);
                 return kTRUE;
-
+             */
             case kPB_START:
-                Start(fTab->GetCurrent());
+                fTab->GetCurrent() ? StartTrack() : StartPos();
                 return kTRUE;
 
@@ -505,6 +511,6 @@
                     sla.SetMjd2Now();
 
-                    XY xy = fCoord->GetCoordinates();
-                    RaDec rd(xy.X(), xy.Y());
+                    XY xy = fCRaDec->GetCoordinates();
+                    RaDec rd(xy.X()*15., xy.Y());
 
                     cout << "Ra/Dec: " << rd.Ra() << kDEG << " " << rd.Dec() << kDEG << endl;
Index: trunk/MagicSoft/Cosy/gui/MGCosy.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 920)
+++ trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 921)
@@ -54,5 +54,7 @@
     TGLabel       *fOffsetAz;
 
-    MGCoordinates *fCoord;
+    MGCoordinates *fCZdAz;
+    MGCoordinates *fCRaDec;
+
     MGSkyPosition *fSkyPosition;
     MGAccuracy    *fAccuracy;
@@ -74,7 +76,8 @@
     void CreateMenu();
     void CreateLabel(TGCompositeFrame *f);
-    void CreateButton(TGCompositeFrame *tf1, TGCompositeFrame *tf2);
+    void CreateTabs(TGTab *fTab);
 
-    void Start(UInt_t id);
+    void StartPos();
+    void StartTrack();
 
     void EnableLabel(TGLabel *label, Bool_t stat);
Index: trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc	(revision 920)
+++ trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc	(revision 921)
@@ -259,6 +259,6 @@
     Y = fy;
 
-    float/*int*/ xm = /*(int)floor*/(fmod(fabs(x), 60.));
-    float/*int*/ ym = /*(int)floor*/(fmod(fabs(y), 60.));
+    float xm = fmod(fabs(x), 60.);
+    float ym = fmod(fabs(y), 60.);
 
     char txt[100];
Index: trunk/MagicSoft/Cosy/gui/MGVelocity.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGVelocity.cc	(revision 920)
+++ trunk/MagicSoft/Cosy/gui/MGVelocity.cc	(revision 921)
@@ -167,4 +167,10 @@
     fText->Draw();
     fList->Add(fText);
+
+    fTextVel = new TText(2*70, 2*70, "");
+    fTextVel->SetTextAlign(33);  // right, top
+    fTextVel->SetTextColor(10);  // white
+    fTextVel->Draw();
+    fList->Add(fTextVel);
 }
 
@@ -198,5 +204,5 @@
         sprintf(txt,  "x%.0f", 1./fScale);
 
-    fText->SetText(fText->GetX()/*70*2*/, fText->GetY()/*70*2*/, txt);
+    fText->SetText(fText->GetX(), fText->GetY(), txt);
 }
 
@@ -263,4 +269,27 @@
 }
 
+void MGVelocity::UpdateVelText(Float_t vx, Float_t vy)
+{
+    static int X = ~0;
+    static int Y = ~0;
+
+    vx /= 60.;  //['/min]
+    vy /= 60.;  //['/min]
+
+    int fx = (int)floor(vx*10.);
+    int fy = (int)floor(vy*10.);
+
+    if (X==fx && Y==fy)
+        return;
+
+    X = fx;
+    Y = fy;
+
+    char txt[100];
+    sprintf(txt, "Zd=%.1f'\nAz=%.1f'",
+            vx, vy);
+
+    fTextVel->SetText(fTextVel->GetX(), fTextVel->GetY(), txt);
+}
 
 void MGVelocity::Update(ZdAz &zdaz)
@@ -272,9 +301,11 @@
     //    static int Y = 0xaffe;
 
-    float x = zdaz.Az()*3600.;
-    float y = zdaz.Zd()*3600.;
-
-    int pixx = (int)(x*fScale/fPix);
-    int pixy = (int)(y*fScale/fPix);
+    float vx = zdaz.Az()*3600.; // ["/min]
+    float vy = zdaz.Zd()*3600.; // ["/min]
+
+    UpdateVelText(vx, vy);
+
+    int pixx = (int)(vx*fScale/fPix);
+    int pixy = (int)(vy*fScale/fPix);
 
     //
@@ -284,5 +315,5 @@
 
     if (pixx || pixy)
-        rc = UpdateAvg(x, y);
+        rc = UpdateAvg(vx, vy);
 
     if (rc)
@@ -296,12 +327,12 @@
     //    cout << zdaz.Az()*3600. << " " << zdaz.Zd()*3600. << endl;
 
-    x *= fScale;
-    y *= fScale;
-
-    fArrow->SetX2(x);
-    fArrow->SetY2(y);
-
-    fArrowX->SetX2(x);
-    fArrowY->SetY2(y);
+    vx *= fScale;
+    vy *= fScale;
+
+    fArrow->SetX2(vx);
+    fArrow->SetY2(vy);
+
+    fArrowX->SetX2(vx);
+    fArrowY->SetY2(vy);
 
     fOld->Set(pixx, pixy);
@@ -309,4 +340,3 @@
     SetModified();
     UpdateCanvas();
-
-}
+}
Index: trunk/MagicSoft/Cosy/gui/MGVelocity.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGVelocity.h	(revision 920)
+++ trunk/MagicSoft/Cosy/gui/MGVelocity.h	(revision 921)
@@ -31,4 +31,5 @@
 
     TText *fText;
+    TText *fTextVel;
 
     XY *fOld;
@@ -43,4 +44,5 @@
     void DrawCoordinateSystem();
     void UpdateText();
+    void UpdateVelText(Float_t x, Float_t y);
 
 public:
