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

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