source: trunk/MagicSoft/Cosy/gui/MGAccuracy.cc@ 924

Last change on this file since 924 was 921, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 5.8 KB
Line 
1//
2// This File contains the definition of the MGCoordinates-class
3//
4// Author: Thomas Bretz
5// Version: V1.0 (1-8-2000)
6
7#include "MGAccuracy.h"
8
9#include <iostream.h> // cout
10
11#include <TArc.h>
12#include <TLine.h>
13#include <TText.h>
14#include <TWbox.h>
15#include <TList.h>
16#include <TGaxis.h>
17#include <TCanvas.h>
18
19#include "coord.h"
20
21void MGAccuracy::DrawCoordinateSystem()
22{
23 TWbox box;
24 box.DrawWbox(-145*2, 145*2, -15*2, 120*2, 18, 2, 1);
25
26 TText text;
27 text.SetTextAlign(22); // centered, centered (s.TAttText)
28 text.DrawText(-80*2, 132.5*2, "Tracking Error [']");
29
30
31 TArc arc;
32 arc.SetFillStyle(4000); // transparent
33 arc.SetFillColor(39);
34 arc.SetLineColor(3); // green
35 arc.SetLineStyle(2); // dashed (s. TAttLine)
36 arc.DrawArc(0, 0, 79.1/2.); // 0.5se
37
38 arc.SetLineColor(5); // yellow
39 arc.DrawArc(0, 0, 79.1); // 1.0se
40
41 arc.SetLineColor(2); // red
42 arc.DrawArc(0, 0, 79.1*2.); // 2.0se
43
44
45 text.SetTextAlign(11); // left, bottom (s.TAttText)
46 text.SetTextColor(3);
47 text.DrawText(220, -220, "0.5se");
48
49 text.SetTextColor(5);
50 text.DrawText(220, -250, "1.0se");
51
52 text.SetTextColor(2);
53 text.DrawText(220, -280, "2.0se");
54
55
56 TLine line;
57 line.DrawLine(-65*4, 0, 65*4, 0);
58 line.DrawLine( 0, -65*4, 0, 65*4);
59
60 //
61 // Can be replaced by TGaxis axe; in a later root version
62 // than 3.01/06. I talked to Rene
63 //
64 TGaxis *axe;
65 axe = new TGaxis(-60*4, 0, 60*4, 0, -4, 4, 30204, "+-N");
66 axe->SetTitle("Az"); // \xb0
67 axe->SetBit(kCanDelete);
68 axe->Draw();
69
70 axe = new TGaxis( 0, -60*4, 0, 60*4, -4, 4, 304, "+-N");
71 axe->SetTitle("Zd"); // \xb0
72 axe->SetBit(kCanDelete);
73 axe->Draw();
74
75 //
76 // FIXME? Use TAxis?
77 //
78/*
79 TLine line;
80 line.SetLineColor(13);
81 line.SetLineStyle(3); // dotted (s. TAttLine)
82 line.DrawLine(-30, -65, -30, 65);
83 line.DrawLine(-65, -30, 65, -30);
84 line.DrawLine( 30, -65, 30, 65);
85 line.DrawLine(-65, 30, 65, 30);
86
87 line.DrawLine(-15, -65, -15, 65);
88 line.DrawLine(-65, -15, 65, -15);
89 line.DrawLine( 15, -65, 15, 65);
90 line.DrawLine(-65, 15, 65, 15);
91
92 line.DrawLine(-45, -65, -45, 65);
93 line.DrawLine(-65, -45, 65, -45);
94 line.DrawLine( 45, -65, 45, 65);
95 line.DrawLine(-65, 45, 65, 45);
96
97 line.SetLineColor(12);
98 line.SetLineStyle(2); // dashed (s. TAttLine)
99 line.DrawLine(-60, -65, -60, 65);
100 line.DrawLine(-65, -60, 65, -60);
101 line.DrawLine( 60, -65, 60, 65);
102 line.DrawLine(-65, 60, 65, 60);
103
104 line.SetLineColor(1); // black
105 line.SetLineStyle(1); // solid (s. TAttLine)
106 line.DrawLine(-65, 0, 65, 0);
107 line.DrawLine( 0, -65, 0, 65);
108
109 line.DrawLine(-1, 60, 1, 60);
110 line.DrawLine(-1, -60, 1, -60);
111 line.DrawLine(-1, 30, 1, 30);
112 line.DrawLine(-1, -30, 1, -30);
113
114 line.DrawLine( 60, -1, 60, 1);
115 line.DrawLine(-60, -1, -60, 1);
116 line.DrawLine( 30, -1, 30, 1);
117 line.DrawLine(-30, -1, -30, 1);
118
119 TText text;
120 text.SetTextAlign(22); // centered, centered (s.TAttText)
121 text.DrawText(60, 5, "dAz[\xb0]");
122 text.DrawText(0, 70, "dZd[\xb0]");
123
124 text.SetTextAlign(23); // centered, centered (s.TAttText)
125 text.DrawText(-60, -2, "-1'");
126 text.DrawText( 60, -2, "1'");
127 text.DrawText(-30, -2, "-30\"");
128 text.DrawText( 30, -2, "30\"");
129
130 text.SetTextAlign(32); // centered, centered (s.TAttText)
131 text.DrawText(-2, -60, "-1'");
132 text.DrawText(-2, 60, "1'");
133 text.DrawText(-2, -30, "-30\"");
134 text.DrawText(-2, 30, "30\"");
135 */
136}
137
138void MGAccuracy::InitText()
139{
140 fTxt = new TText(280, 280, "0' / 0'");
141 fTxt->SetTextAlign(33); // right, top
142 fTxt->SetTextColor(10);
143 fTxt->Draw();
144
145 fList->Add(fTxt);
146}
147
148void MGAccuracy::InitCross()
149{
150 fLin1 = new TLine(0, 0, 0, 0);
151 fLin2 = new TLine(0, 0, 0, 0);
152
153 fLin1->SetLineColor(10); // white (s. TAttFill)
154 fLin2->SetLineColor(10); // white
155 fLin1->SetLineStyle(1); // solid (s. TAttLine)
156 fLin2->SetLineStyle(1);
157
158 fLin1->SetLineWidth(2);
159 fLin2->SetLineWidth(2);
160
161 fLin1->Draw();
162 fLin2->Draw();
163
164 fList->Add(fLin1);
165 fList->Add(fLin2);
166}
167
168MGAccuracy::MGAccuracy(const TGWindow* p, const UInt_t w)
169: MGEmbeddedCanvas("Accuracy", p, w, 75*4)
170{
171 DrawCoordinateSystem();
172
173 InitText();
174 InitCross();
175
176 InitCanvas();
177}
178
179MGAccuracy::~MGAccuracy()
180{
181 // cout << "MGAccuracy destroyed." << endl;
182}
183
184void MGAccuracy::UpdateText(Float_t pzd, Float_t azd, Float_t aaz)
185{
186 const Float_t d2r = TMath::Pi()/180.;
187
188 pzd *= d2r;
189 azd *= d2r;
190 aaz *= d2r;
191
192 const double dphi2 = aaz/2.;
193 const double cos2 = cos(dphi2)*cos(dphi2);
194 const double sin2 = sin(dphi2)*sin(dphi2);
195 const double d = cos(azd)*cos2 - cos(2*pzd+azd)*sin2;
196
197 double dist = acos(d);
198
199 dist *= 3600./d2r;
200
201 int rs = (int)floor(fmod(dist, 60.));
202 dist /= 60.;
203 int rm = (int)floor(fmod(dist, 60.));
204
205 char txt[100];
206 rm ? sprintf(txt, "%d'%02d\"", rm, rs) : sprintf(txt, "%d\"", rs);
207
208 fTxt->SetText(fTxt->GetX(), fTxt->GetY(), txt);
209}
210
211void MGAccuracy::UpdateCross(Float_t x, Float_t y)
212{
213 fLin1->SetX1(x-5.);
214 fLin1->SetX2(x+5.);
215
216 fLin2->SetX1(x-5.);
217 fLin2->SetX2(x+5.);
218
219 fLin1->SetY1(y-5.);
220 fLin1->SetY2(y+5.);
221
222 fLin2->SetY1(y+5.);
223 fLin2->SetY2(y-5.);
224}
225
226void MGAccuracy::Update(ZdAz &pos, ZdAz &acc)
227{
228 //
229 // calculate actual time for planet positions
230 //
231 static int X = ~0;
232 static int Y = ~0;
233
234 float x = acc.Az()*3600.; // ["]
235 float y = acc.Zd()*3600.; // ["]
236
237 int pixx = (int)(x/fPix); // [pix]
238 int pixy = (int)(y/fPix); // [pix]
239
240 if (X==pixx && Y==pixy)
241 return;
242
243 X = pixx;
244 Y = pixy;
245
246 UpdateCross(x, y);
247 UpdateText(pos.Zd(), acc.Az(), acc.Zd());
248
249 SetModified();
250 UpdateCanvas();
251}
Note: See TracBrowser for help on using the repository browser.