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

Last change on this file since 1760 was 1760, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 5.9 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 dphi2 = aaz/2.;
198 const double cos2 = cos(dphi2)*cos(dphi2);
199 const double sin2 = sin(dphi2)*sin(dphi2);
200 const double d = cos(azd)*cos2 - cos(2*pzd+azd)*sin2;
201
202 double dist = acos(d);
203
204 dist *= 3600./d2r;
205
206 int rs = (int)floor(fmod(dist, 60.));
207 dist /= 60.;
208 int rm = (int)dist;//floor(fmod(dist, 60.));
209
210 char txt[100];
211 rm ? sprintf(txt, "%d'%02d\"", rm, rs) : sprintf(txt, "%d\"", rs);
212
213 fTxt->SetText(fTxt->GetX(), fTxt->GetY(), txt);
214}
215
216void MGAccuracy::UpdateCross(Float_t x, Float_t y)
217{
218 fLin1->SetX1(x-5.);
219 fLin1->SetX2(x+5.);
220
221 fLin2->SetX1(x-5.);
222 fLin2->SetX2(x+5.);
223
224 fLin1->SetY1(y-5.);
225 fLin1->SetY2(y+5.);
226
227 fLin2->SetY1(y+5.);
228 fLin2->SetY2(y-5.);
229}
230
231void MGAccuracy::Update(ZdAz &pos, ZdAz &acc)
232{
233 //
234 // calculate actual time for planet positions
235 //
236 static int X = ~0;
237 static int Y = ~0;
238
239 float x = acc.Az()*3600.; // ["]
240 float y = acc.Zd()*3600.; // ["]
241
242 int pixx = (int)(x/fPix); // [pix]
243 int pixy = (int)(y/fPix); // [pix]
244
245 if (X==pixx && Y==pixy)
246 return;
247
248 X = pixx;
249 Y = pixy;
250
251 UpdateCross(x, y);
252 UpdateText(pos.Zd(), acc.Az(), acc.Zd());
253
254 SetModified();
255 UpdateCanvas();
256}
Note: See TracBrowser for help on using the repository browser.