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

Last change on this file since 1819 was 1819, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 6.2 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::InitCross()
152{
153 fLin1 = new TLine(0, 0, 0, 0);
154 fLin2 = new TLine(0, 0, 0, 0);
155
156 fLin1->SetLineColor(10); // white (s. TAttFill)
157 fLin2->SetLineColor(10); // white
158 fLin1->SetLineStyle(1); // solid (s. TAttLine)
159 fLin2->SetLineStyle(1);
160
161 fLin1->SetLineWidth(2);
162 fLin2->SetLineWidth(2);
163
164 fLin1->Draw();
165 fLin2->Draw();
166
167 fList->Add(fLin1);
168 fList->Add(fLin2);
169}
170
171MGAccuracy::MGAccuracy(const TGWindow* p, const UInt_t w)
172: MGEmbeddedCanvas("Accuracy", p, w, 75*4)
173{
174 DrawCoordinateSystem();
175
176 InitText();
177 InitCross();
178
179 InitCanvas();
180
181 SetNoContextMenu();
182}
183
184MGAccuracy::~MGAccuracy()
185{
186 // cout << "MGAccuracy destroyed." << endl;
187}
188
189void MGAccuracy::UpdateText(Float_t pzd, Float_t azd, Float_t aaz)
190{
191 const Float_t d2r = TMath::Pi()/180.;
192
193 pzd *= d2r;
194 azd *= d2r;
195 aaz *= d2r;
196
197 const double el = TMath::Pi()/2-pzd;
198
199 const double dphi2 = aaz/2.;
200 const double cos2 = cos(dphi2)*cos(dphi2);
201 const double sin2 = sin(dphi2)*sin(dphi2);
202 const double d = cos(azd)*cos2 - cos(2*el)*sin2;
203
204 //
205 // Original:
206 // cos(Zd1)*cos(Zd2)+sin(Zd1)*sin(Zd2)*cos(dAz)
207 //
208 // Correct:
209 // const double d = cos(azd)*cos2 - cos(el1+el2)*sin2;
210 //
211 // Estimated:
212 // const double d = cos(azd)*cos2 - cos(2*el)*sin2;
213 //
214
215 double dist = acos(d);
216
217 dist *= 3600./d2r;
218
219 int rs = (int)floor(fmod(dist, 60.));
220 dist /= 60.;
221 int rm = (int)dist;//floor(fmod(dist, 60.));
222
223 char txt[100];
224 rm ? sprintf(txt, "%d'%02d\"", rm, rs) : sprintf(txt, "%d\"", rs);
225
226 fTxt->SetText(fTxt->GetX(), fTxt->GetY(), txt);
227}
228
229void MGAccuracy::UpdateCross(Float_t x, Float_t y)
230{
231 fLin1->SetX1(x-5.);
232 fLin1->SetX2(x+5.);
233
234 fLin2->SetX1(x-5.);
235 fLin2->SetX2(x+5.);
236
237 fLin1->SetY1(y-5.);
238 fLin1->SetY2(y+5.);
239
240 fLin2->SetY1(y+5.);
241 fLin2->SetY2(y-5.);
242}
243
244void MGAccuracy::Update(ZdAz &pos, ZdAz &acc)
245{
246 //
247 // calculate actual time for planet positions
248 //
249 static int X = ~0;
250 static int Y = ~0;
251
252 float x = acc.Az()*3600.; // ["]
253 float y = acc.Zd()*3600.; // ["]
254
255 int pixx = (int)(x/fPix); // [pix]
256 int pixy = (int)(y/fPix); // [pix]
257
258 if (X==pixx && Y==pixy)
259 return;
260
261 X = pixx;
262 Y = pixy;
263
264 UpdateCross(x, y);
265 UpdateText(pos.Zd(), acc.Zd(), acc.Az());
266
267 SetModified();
268 UpdateCanvas();
269}
Note: See TracBrowser for help on using the repository browser.