Changeset 7790 for trunk/MagicSoft/Cosy/gui/MGStarg.cc
- Timestamp:
- 07/14/06 13:19:54 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/gui/MGStarg.cc
r7788 r7790 1 1 #include "MGStarg.h" 2 2 3 #include <iostream.h> // cout4 5 #include <TArc.h>6 #include <TLine.h>7 #include <TText.h>8 #include <TWbox.h>9 #include <TList.h>10 #include <TGaxis.h>11 #include <TGraph.h>12 3 #include <TCanvas.h> 13 4 14 5 #include <MHexagon.h> 15 6 16 #include "coord.h"17 #include "MTime.h"18 #include "MAstro.h"19 20 7 ClassImp(MGStarg); 21 8 22 void MGStarg::Draw CoordinateSystem()9 void MGStarg::DrawHexagon() 23 10 { 24 TWbox box; 25 box.DrawWbox(-145*2, 145*2, -15*2, 120*2, 18, 2, 1); 26 27 TText text; 28 text.SetTextAlign(22); // centered, centered (s.TAttText) 29 text.DrawText(-80*2, 132.5*2, "Misspointing [min]"); 11 fCanvas->SetEditable(kTRUE); 12 fCanvas->cd(); 30 13 31 14 MHexagon hex; 32 hex.SetFillColor(39);33 15 hex.SetFillStyle(4000); 34 16 hex.SetLineColor(17); 35 hex.DrawHexagon(0, 0,177.5*2);17 hex.DrawHexagon(0, 0, 177.5*2); 36 18 37 text.SetTextAlign(11); // left, bottom (s.TAttText) 38 text.SetTextColor(3); 39 text.DrawText(220, -220, "0.75'"); 40 41 text.SetTextColor(5); 42 text.DrawText(220, -250, "1.50'"); 43 44 text.SetTextColor(2); 45 text.DrawText(220, -280, "3.00'"); 46 47 48 TLine line; 49 line.DrawLine(-65*4, 0, 65*4, 0); 50 line.DrawLine( 0, -65*4, 0, 65*4); 51 52 // 53 // Can be replaced by TGaxis axe; in a later root version 54 // than 3.01/06. I talked to Rene 55 // 56 TGaxis *axe; 57 axe = new TGaxis(-60*4, 0, 60*4, 0, -4, 4, 30204, "+-N"); 58 axe->SetTitle("Az"); // \xb0 59 axe->SetBit(kCanDelete); 60 axe->Draw(); 61 62 axe = new TGaxis( 0, -60*4, 0, 60*4, -4, 4, 304, "+-N"); 63 axe->SetTitle("Zd"); // \xb0 64 axe->SetLabelOffset(-0.02); 65 axe->SetBit(kCanDelete); 66 axe->Draw(); 67 } 68 69 void MGStarg::InitText() 70 { 71 fTxt = new TText(280, 280, "0' / 0'"); 72 fTxt->SetTextAlign(33); // right, top 73 fTxt->SetTextColor(10); 74 fTxt->Draw(); 75 76 fList->Add(fTxt); 77 } 78 79 void MGStarg::InitBar() 80 { 81 fBar = new TLine(0, 0, 0, 0); 82 fBar->SetLineColor(kBlack); 83 fBar->SetLineStyle(1); 84 fBar->SetLineWidth(5); 85 fBar->Draw(); 86 87 fList->Add(fBar); 88 } 89 90 void MGStarg::InitCross() 91 { 92 fLin1 = new TLine(0, 0, 0, 0); 93 fLin2 = new TLine(0, 0, 0, 0); 94 95 fLin1->SetLineColor(10); // white (s. TAttFill) 96 fLin2->SetLineColor(10); // white 97 fLin1->SetLineStyle(1); // solid (s. TAttLine) 98 fLin2->SetLineStyle(1); 99 100 fLin1->SetLineWidth(2); 101 fLin2->SetLineWidth(2); 102 103 fLin1->Draw(); 104 fLin2->Draw(); 105 106 fList->Add(fLin1); 107 fList->Add(fLin2); 19 fCanvas->SetEditable(kFALSE); 108 20 } 109 21 110 22 MGStarg::MGStarg(const TGWindow* p, const UInt_t w) 111 : MG EmbeddedCanvas("Starg", p, w, 300)23 : MGAccuracy(p, w) 112 24 { 113 // FIXME: Overload MapWindow in newer Root versions to remove 114 // the contents of the graph! 115 fGraph = new TGraph; 116 fGraph->SetPoint(0, 0, 0); 117 fGraph->SetLineColor(kBlue); 118 fGraph->SetMarkerColor(kBlue); 119 fGraph->SetMarkerStyle(kFullDotMedium); 120 fGraph->Draw("LP"); 121 fList->Add(fGraph); 122 //fGraph->SetNameTitle("AccVsT", "Accuracy vs Min of Time"); 123 //fGraph->Draw("APL"); 124 //fGraph->SetMarkerSize(2); 125 126 DrawCoordinateSystem(); 127 128 InitText(); 129 InitCross(); 130 InitBar(); 131 132 InitCanvas(); 133 134 SetNoContextMenu(); 135 136 MTime t(-1); 137 fTime = t.GetAxisTime(); 25 SetColorScale(1.5); 138 26 } 139 140 MGStarg::~MGStarg()141 {142 // cout << "MGStarg destroyed." << endl;143 }144 145 // dist [deg]146 void MGStarg::UpdateText(Float_t dist)147 {148 dist *= 3600.; // [sec]149 150 int rs = (int)floor(fmod(dist, 60.));151 152 dist /= 60.; // [min]153 int rm = (int)dist;154 155 char txt[100];156 rm ? sprintf(txt, "%d'%02d\"", rm, rs) : sprintf(txt, "%d\"", rs);157 158 fTxt->SetText(fTxt->GetX(), fTxt->GetY(), txt);159 160 fBar->SetY2(dist*60); // [sec]161 if (dist<1.5)162 fBar->SetLineColor(kGreen);163 else164 if (dist<3)165 fBar->SetLineColor(kYellow);166 else167 fBar->SetLineColor(kRed);168 169 SetModified();170 }171 172 // dist [deg]173 void MGStarg::UpdateGraph(Float_t dist)174 {175 MTime t(-1);176 const Double_t dtime = t.GetAxisTime()-fTime; // range [-0.5h, 0h]177 178 dist *= 60; // min179 180 static int odist = -1;181 if (odist==(int)(dist*10*60) && dtime<10)182 return;183 184 odist = (int)(dist*10*60);185 186 fGraph->SetPoint(fGraph->GetN(), dtime, dist*60);187 188 const Double_t ntime = dtime;189 for (int i=0; i<fGraph->GetN(); i++)190 {191 Double_t x, y;192 fGraph->GetPoint(i, x, y);193 fGraph->SetPoint(i, x-ntime, y);194 //cout << i << ": " << x-ntime << " / " << y << endl;195 }196 while (fGraph->GetN()>0)197 {198 Double_t x, y;199 fGraph->GetPoint(0, x, y);200 201 if (x==-ntime && y==0)202 {203 fGraph->RemovePoint(0);204 continue;205 }206 207 if (x>-4.75*60)208 break;209 210 fGraph->RemovePoint(0);211 }212 213 fTime = t.GetAxisTime();214 215 SetModified();216 217 }218 219 void MGStarg::Update(Float_t pzd, Float_t azd, Float_t aaz)220 {221 const double dist = MAstro::GetDevAbs(pzd, azd, aaz);222 223 UpdateText(dist);224 UpdateGraph(dist);225 }226 227 void MGStarg::UpdateCross(Float_t x, Float_t y)228 {229 //230 // x["], y["]231 //232 static int X = ~0;233 static int Y = ~0;234 235 int pixx = (int)(x/fPix); // [pix]236 int pixy = (int)(y/fPix); // [pix]237 238 if (X==pixx && Y==pixy)239 return;240 241 X = pixx;242 Y = pixy;243 244 fLin1->SetX1(x-5.);245 fLin1->SetX2(x+5.);246 247 fLin2->SetX1(x-5.);248 fLin2->SetX2(x+5.);249 250 fLin1->SetY1(y-5.);251 fLin1->SetY2(y+5.);252 253 fLin2->SetY1(y+5.);254 fLin2->SetY2(y-5.);255 256 SetModified();257 }258 259 void MGStarg::Update(ZdAz &pos, ZdAz &dev)260 {261 // Estimate the distance in az direction on the camera plane262 const double daz = MAstro::GetDevAbs(pos.Zd(), 0, dev.Az())*3600.;263 264 //cout << "--> S: " << dev.Az()*60 << " " << dev.Zd()*60. << endl;265 266 UpdateCross(TMath::Sign(daz, dev.Az()), dev.Zd()*3600.);267 Update(pos.Zd(), dev.Zd(), dev.Az());268 269 UpdateCanvas();270 }
Note:
See TracChangeset
for help on using the changeset viewer.