Changeset 4076 for trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
- Timestamp:
- 05/15/04 16:46:27 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
r2518 r4076 15 15 #include <TList.h> 16 16 #include <TGaxis.h> 17 #include <TGraph.h> 17 18 #include <TCanvas.h> 18 19 19 20 #include "coord.h" 21 #include "MTime.h" 20 22 21 23 ClassImp(MGAccuracy); … … 28 30 TText text; 29 31 text.SetTextAlign(22); // centered, centered (s.TAttText) 30 text.DrawText(-80*2, 132.5*2, " Tracking Error [']");32 text.DrawText(-80*2, 132.5*2, "Ctrl Deviation [min]"); 31 33 32 34 … … 75 77 axe->SetBit(kCanDelete); 76 78 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); // black108 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 79 } 140 80 … … 183 123 : MGEmbeddedCanvas("Accuracy", p, w, 300) 184 124 { 125 // FIXME: Overload MapWindow in newer Root versions to remove 126 // the contents of the graph! 127 fGraph = new TGraph; 128 fGraph->SetPoint(0, 0, 0); 129 fGraph->SetLineColor(kBlue); 130 fGraph->SetMarkerColor(kBlue); 131 fGraph->SetMarkerStyle(kFullDotMedium); 132 fGraph->Draw("LP"); 133 fList->Add(fGraph); 134 //fGraph->SetNameTitle("AccVsT", "Accuracy vs Min of Time"); 135 //fGraph->Draw("APL"); 136 //fGraph->SetMarkerSize(2); 137 185 138 DrawCoordinateSystem(); 186 139 … … 192 145 193 146 SetNoContextMenu(); 147 148 MTime t(-1); 149 fTime = t.GetAxisTime(); 194 150 } 195 151 … … 199 155 } 200 156 201 void 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] 157 // dist [deg] 158 void MGAccuracy::UpdateText(Float_t dist) 159 { 160 dist *= 3600.; // [sec] 230 161 231 162 int rs = (int)floor(fmod(dist, 60.)); 232 163 233 dist /= 60.; 234 int rm = (int)dist; //floor(fmod(dist, 60.));164 dist /= 60.; // [min] 165 int rm = (int)dist; 235 166 236 167 char txt[100]; … … 239 170 fTxt->SetText(fTxt->GetX(), fTxt->GetY(), txt); 240 171 241 fBar->Set X2(dist*60);172 fBar->SetY2(dist*60); // [sec] 242 173 if (dist*16384<1*360*60) 243 174 fBar->SetLineColor(kGreen); … … 247 178 else 248 179 fBar->SetLineColor(kRed); 180 181 SetModified(); 182 } 183 184 // dist [deg] 185 void MGAccuracy::UpdateGraph(Float_t dist) 186 { 187 MTime t(-1); 188 const Double_t dtime = t.GetAxisTime()-fTime; // range [-0.5h, 0h] 189 190 dist *= 60; // min 191 192 static int odist = -1; 193 if (odist==(int)(dist*10*60) && dtime<10) 194 return; 195 196 odist = (int)(dist*10*60); 197 198 fGraph->SetPoint(fGraph->GetN(), dtime, dist*60); 199 200 const Double_t ntime = dtime; 201 for (int i=0; i<fGraph->GetN(); i++) 202 { 203 Double_t x, y; 204 fGraph->GetPoint(i, x, y); 205 fGraph->SetPoint(i, x-ntime, y); 206 //cout << i << ": " << x-ntime << " / " << y << endl; 207 } 208 while (fGraph->GetN()>0) 209 { 210 Double_t x, y; 211 fGraph->GetPoint(0, x, y); 212 213 if (x==-ntime && y==0) 214 { 215 fGraph->RemovePoint(0); 216 continue; 217 } 218 219 if (x>-4.75*60) 220 break; 221 222 fGraph->RemovePoint(0); 223 } 224 225 fTime = t.GetAxisTime(); 226 227 SetModified(); 228 229 //cout << "N1 == " << fGraph->GetN() << endl; 230 231 //fGraph->GetHistogram()->SetXTitle("Time"); 232 //fGraph->GetHistogram()->SetYTitle("\\Delta [arcmin]"); 233 //fGraph->GetHistogram()->GetXaxis()->SetTimeFormat("%M %F1995-01-01 00:00:00"); 234 //fGraph->GetHistogram()->GetXaxis()->SetTimeDisplay(1); 235 //fGraph->GetHistogram()->GetXaxis()->SetLabelSize(0.033); 236 } 237 238 void MGAccuracy::Update(Float_t pzd, Float_t azd, Float_t aaz) 239 { 240 const Float_t d2r = TMath::Pi()/180.; 241 242 pzd *= d2r; 243 azd *= d2r; 244 aaz *= d2r; 245 246 const double el = TMath::Pi()/2-pzd; 247 248 const double dphi2 = aaz/2.; 249 const double cos2 = cos(dphi2)*cos(dphi2); 250 const double sin2 = sin(dphi2)*sin(dphi2); 251 const double d = cos(azd)*cos2 - cos(2*el)*sin2; 252 253 // 254 // Original: 255 // cos(Zd1)*cos(Zd2)+sin(Zd1)*sin(Zd2)*cos(dAz) 256 // 257 // Correct: 258 // const double d = cos(azd)*cos2 - cos(el1+el2)*sin2; 259 // 260 // Estimated: 261 // const double d = cos(azd)*cos2 - cos(2*el)*sin2; 262 // 263 264 double dist = acos(d)*TMath::RadToDeg(); 265 266 UpdateText(dist); 267 UpdateGraph(dist); 249 268 } 250 269 251 270 void MGAccuracy::UpdateCross(Float_t x, Float_t y) 252 271 { 272 // 273 // calculate actual time for planet positions 274 // acc [deg] 275 // 276 // x["], y["] 277 // 278 static int X = ~0; 279 static int Y = ~0; 280 281 int pixx = (int)(x/fPix); // [pix] 282 int pixy = (int)(y/fPix); // [pix] 283 284 if (X==pixx && Y==pixy) 285 return; 286 287 X = pixx; 288 Y = pixy; 289 253 290 fLin1->SetX1(x-5.); 254 291 fLin1->SetX2(x+5.); … … 262 299 fLin2->SetY1(y+5.); 263 300 fLin2->SetY2(y-5.); 301 302 SetModified(); 264 303 } 265 304 266 305 void MGAccuracy::Update(ZdAz &pos, ZdAz &acc) 267 306 { 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(); 307 UpdateCross(acc.Az()*3600., acc.Zd()*3600.); 308 Update(pos.Zd(), acc.Zd(), acc.Az()); 309 291 310 UpdateCanvas(); 292 311 }
Note:
See TracChangeset
for help on using the changeset viewer.