Index: trunk/MagicSoft/Cosy/Changelog
===================================================================
--- trunk/MagicSoft/Cosy/Changelog	(revision 8183)
+++ trunk/MagicSoft/Cosy/Changelog	(revision 8184)
@@ -1,3 +1,12 @@
                                                                   -*-*- END -*-*-
+
+ 2006/11/01 Thomas Bretz
+
+   * tpoint/gui.C:
+     - added the horizon
+     - got rid of a warning about a TGraph with 0 points in case
+       the tpoint-file didn't contain magnitudes.
+
+
 
  2006/07/18 Thomas Bretz
@@ -214,4 +223,6 @@
      - fixed a bug which gave a starguider mispointing which was wrong
        by the pointing position.
+     - fixed also the position of the displayed rings wrt to the catalog
+       sky
 
    * catalog/StarCatalog.cc:
Index: trunk/MagicSoft/Cosy/tpoint/gui.C
===================================================================
--- trunk/MagicSoft/Cosy/tpoint/gui.C	(revision 8183)
+++ trunk/MagicSoft/Cosy/tpoint/gui.C	(revision 8184)
@@ -15,4 +15,5 @@
 #include <TText.h>
 #include <TProfile.h>
+#include <TPolyLine.h>
 #include <TGraphErrors.h>
 
@@ -232,5 +233,5 @@
     }
 
-    void DrawMarker(TVirtualPad *pad, Double_t r0, Double_t phi0, Double_t r1, Double_t phi1)
+    void DrawMarker(TVirtualPad *pad, Double_t r0, Double_t phi0)
     {
         TView *view = pad->GetView();
@@ -243,24 +244,15 @@
 
         TMarker mark0;
-        //TMarker mark1;
-        mark0.SetMarkerStyle(kStar);
-        //mark1.SetMarkerStyle(kStar);
-        //mark1.SetMarkerColor(kRed);
+        mark0.SetMarkerStyle(kFullDotLarge);
+        mark0.SetMarkerColor(kBlue);
     
         r0 /= 90;
-        //r1 /= 90;
         phi0 *= TMath::DegToRad();
-        //phi1 *= TMath::DegToRad();
-
-        Double_t x0[3] = { r0*cos(phi0), r0*sin(phi0), 0};
-        //Double_t x1[3] = { r1*cos(phi1), r1*sin(phi1), 0};
-
-        Double_t y0[3];//, y1[3];
-    
-        view->WCtoNDC(x0, y0);
-        //view->WCtoNDC(x1, y1);
-    
-        mark0.DrawMarker(-y0[0], y0[1]);
-        //mark1.DrawMarker(y1[0], y1[1]);
+
+        Double_t x[6] = { r0*cos(phi0), r0*sin(phi0), 0, 0, 0, 0};
+
+        view->WCtoNDC(x, x+3);
+    
+        mark0.DrawMarker(-x[3], x[4]);
     }
     
@@ -295,8 +287,8 @@
         line.SetLineWidth(2);
         line.SetLineColor(kBlue);
-    
+
         Double_t p0 = phi0<phi1?phi0:phi1;
         Double_t p1 = phi0<phi1?phi1:phi0;
-    
+
         if (phi0>phi1)
         {
@@ -305,30 +297,30 @@
             r0 = d;
         }
-    
+
         r0 /= 90;
         r1 /= 90;
-    
+
         Double_t dr = r1-r0;
         Double_t dp = p1-p0;
-    
+
         Double_t x0[3] = { r0*cos(p0*TMath::DegToRad()), r0*sin(p0*TMath::DegToRad()), 0};
-    
+
         for (double i=p0+10; i<p1+10; i+=10)
         {
             if (i>p1)
                 i=p1;
-    
+
             Double_t r = dr/dp*(i-p0)+r0;
             Double_t p = TMath::DegToRad()*i;
-    
+
             Double_t x1[3] = { r*cos(p), r*sin(p), 0};
-    
+
             Double_t y0[3], y1[3];
-    
+
             view->WCtoNDC(x0, y0);
             view->WCtoNDC(x1, y1);
-    
+
             line.DrawLine(y0[0], y0[1], y1[0], y1[1]);
-    
+
             x0[0] = x1[0];
             x0[1] = x1[1];
@@ -342,5 +334,5 @@
         Double_t r1   = set.GetStarZd();
         Double_t phi1 = set.GetStarAz()-angle;
-    
+
         if (r0<0)
         {
@@ -353,14 +345,14 @@
             phi1 += 180;
         }
-    
+
         phi0 = fmod(phi0+360, 360);
         phi1 = fmod(phi1+360, 360);
-    
+
         if (phi1-phi0<-180)
             phi1+=360;
-    
+
         if (scale<0 || scale>1000)
             scale = -1;
-    
+
         if (scale>0)
         {
@@ -371,10 +363,56 @@
             phi0 += scale*d;
             phi1 -= scale*d;
-    
+
             DrawPolLine(pad, r0, phi0, r1, phi1);
-            DrawMarker(pad,  r0, phi0, r1, phi1);
+            DrawMarker(pad,  r0, phi0);
         }
         else
-            DrawMarker(pad,  r1, phi1, 0 ,0);
+            DrawMarker(pad,  r1, phi1);
+    }
+
+    void DrawHorizon(TVirtualPad *pad, const char *fname="horizon.dat") const
+    {
+        TView *view = pad->GetView();
+    
+        if (!view)
+        {
+            cout << "No View!" << endl;
+            return;
+        }
+
+        ifstream fin("horizon.dat");
+        if (!fin)
+        {
+            cout << "ERROR - horizon.dat not found." << endl;
+            return;
+        }
+
+        TPolyLine poly;
+        poly.SetLineWidth(2);
+        poly.SetLineColor(12);
+        poly.SetLineStyle(8);
+
+        while (1)
+        {
+            TString line;
+            line.ReadLine(fin);
+            if (!fin)
+                break;
+
+            Float_t az, alt;
+            sscanf(line.Data(), "%f %f", &az, &alt);
+
+            Float_t zd = 90-alt;
+
+            az *= TMath::DegToRad();
+            zd /= 90;
+
+            Double_t x[6] = { zd*cos(az), zd*sin(az), 0, 0, 0, 0};
+            view->WCtoNDC(x, x+3);
+            poly.SetNextPoint(-x[3], x[4]);
+        }
+
+        poly.DrawClone()->SetBit(kCanDelete);
+
     }
 
@@ -679,10 +717,13 @@
         gPad->SetGridx();
         gPad->SetGridy();
-        g=(TGraph*)gmaz.DrawClone("A*");
-        g->SetBit(kCanDelete);
-        g->GetHistogram()->SetXTitle("Mag");
-        g->GetHistogram()->SetYTitle("\\Delta Az [\\circ]");
-        line.DrawLine(g->GetXaxis()->GetXmin(),  360./16384, g->GetXaxis()->GetXmax(),  360./16384);
-        line.DrawLine(g->GetXaxis()->GetXmin(), -360./16384, g->GetXaxis()->GetXmax(), -360./16384);
+        if (gmaz.GetN()>0)
+        {
+            g=(TGraph*)gmaz.DrawClone("A*");
+            g->SetBit(kCanDelete);
+            g->GetHistogram()->SetXTitle("Mag");
+            g->GetHistogram()->SetYTitle("\\Delta Az [\\circ]");
+            line.DrawLine(g->GetXaxis()->GetXmin(),  360./16384, g->GetXaxis()->GetXmax(),  360./16384);
+            line.DrawLine(g->GetXaxis()->GetXmin(), -360./16384, g->GetXaxis()->GetXmax(), -360./16384);
+        }
 #endif
 
@@ -726,10 +767,13 @@
         gPad->SetGridx();
         gPad->SetGridy();
-        g=(TGraph*)gmzd.DrawClone("A*");
-        g->SetBit(kCanDelete);
-        g->GetHistogram()->SetXTitle("Mag");
-        g->GetHistogram()->SetYTitle("\\Delta Zd [\\circ]");
-        line.DrawLine(g->GetXaxis()->GetXmin(),  360./16384, g->GetXaxis()->GetXmax(),  360./16384);
-        line.DrawLine(g->GetXaxis()->GetXmin(), -360./16384, g->GetXaxis()->GetXmax(), -360./16384);
+        if (gmzd.GetN()>0)
+        {
+            g=(TGraph*)gmzd.DrawClone("A*");
+            g->SetBit(kCanDelete);
+            g->GetHistogram()->SetXTitle("Mag");
+            g->GetHistogram()->SetYTitle("\\Delta Zd [\\circ]");
+            line.DrawLine(g->GetXaxis()->GetXmin(),  360./16384, g->GetXaxis()->GetXmax(),  360./16384);
+            line.DrawLine(g->GetXaxis()->GetXmin(), -360./16384, g->GetXaxis()->GetXmax(), -360./16384);
+        }
 #endif
 
@@ -780,10 +824,12 @@
         gPad->SetGridx();
         gPad->SetGridy();
-        g=(TGraph*)grmag.DrawClone("AP");
-        g->SetBit(kCanDelete);
-        g->GetHistogram()->SetXTitle("Mag");
-        g->GetHistogram()->SetYTitle("\\Delta [\\circ]");
-        line.DrawLine(g->GetXaxis()->GetXmin(),  360./16384, g->GetXaxis()->GetXmax(),  360./16384);
-
+        if (grmag.GetN()>0)
+        {
+            g=(TGraph*)grmag.DrawClone("AP");
+            g->SetBit(kCanDelete);
+            g->GetHistogram()->SetXTitle("Mag");
+            g->GetHistogram()->SetYTitle("\\Delta [\\circ]");
+            line.DrawLine(g->GetXaxis()->GetXmin(),  360./16384, g->GetXaxis()->GetXmax(),  360./16384);
+        }
         promag.SetLineWidth(2);
         promag.SetLineColor(kBlue);
@@ -877,4 +923,5 @@
         gPad->Modified();
         gPad->Update();
+        DrawHorizon(gPad);
         for (int i=0; i<fOriginal.GetSize(); i++)
             DrawSet(gPad, *(Set*)fOriginal.At(i));//, 10./hres1.GetMean());
