Changeset 4076 for trunk/MagicSoft/Cosy/gui
- Timestamp:
- 05/15/04 16:46:27 (21 years ago)
- Location:
- trunk/MagicSoft/Cosy/gui
- Files:
-
- 10 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 } -
trunk/MagicSoft/Cosy/gui/MGAccuracy.h
r2518 r4076 8 8 // Version: V1.0 (1-8-2000) 9 9 10 #ifndef MGEMBEDDEDCANVAS_H10 #ifndef COSY_MGEmbeddedCanvas 11 11 #include "MGEmbeddedCanvas.h" 12 12 #endif 13 13 14 class TGraph; 14 15 class TLine; 15 16 class TText; … … 26 27 TLine *fBar; 27 28 29 TGraph *fGraph; 30 31 Double_t fTime; 32 28 33 void DrawCoordinateSystem(); 29 34 … … 32 37 void InitBar(); 33 38 34 void UpdateText(Float_t zd, Float_t x, Float_t y);35 39 void UpdateCross(Float_t x, Float_t y); 40 void UpdateText(Float_t acc); 41 void UpdateGraph(Float_t acc); 42 void Update(Float_t zd, Float_t x, Float_t y); 36 43 37 44 public: -
trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.h
r2278 r4076 1 #ifndef MGEMBEDDEDCANVAS_H2 #define MGEMBEDDEDCANVAS_H1 #ifndef COSY_MGEmbeddedCanvas 2 #define COSY_MGEmbeddedCanvas 3 3 4 4 // -
trunk/MagicSoft/Cosy/gui/MGImage.cc
r2613 r4076 7 7 // x11/src/GX11Gui.cxx 8 8 // 9 10 ////////////////////////////////////////////////////////////////////////////// 11 // 12 // MGImage 13 // 14 // If sync-mode is enabled the Redraw function is secured by a mutex (ignore 15 // error messages about it comming from root) This has the advantage that 16 // if you use a timer for screen update reading and writing the image is 17 // synchronized. In this way you don't get flickering half images. 18 // 19 ////////////////////////////////////////////////////////////////////////////// 9 20 #include "MGImage.h" 10 21 … … 17 28 18 29 using namespace std; 19 /*20 class MyX11 : public TGX1121 {22 public:23 Display *GetDisplay() { return fDisplay; }24 Drawable GetRootWin() { return fRootWin; }25 Drawable GetVisRootWin() { return fVisRootWin; }26 Int_t GetDepth() { return fDepth; }27 };28 */29 30 30 31 MGImage::MGImage(const TGWindow* p, UInt_t w, UInt_t h, UInt_t options, ULong_t back) … … 40 41 fMuxPixmap = new TMutex; 41 42 42 Resize( w, h);43 Resize(GetWidth(), GetHeight()); 43 44 44 45 // 45 46 // create empty pixmap 46 47 // 47 fPixmap = gVirtualX->CreatePixmap(fId, fWidth, fHeight);48 48 fDefGC = gVirtualX->CreateGC(fId, 0); 49 49 fImage = (XImage*)gVirtualX->CreateImage(fWidth, fHeight); … … 54 54 MGImage::~MGImage() 55 55 { 56 fMuxPixmap->Lock(); 56 if (fMuxPixmap->Lock()==13) 57 cout << "MGImage::~MGImage - mutex is already locked by this thread" << endl; 57 58 58 59 cout << "Deleting MGImage..." << endl; 59 60 60 gVirtualX->DeletePixmap(fPixmap);61 61 gVirtualX->DeleteGC(fDefGC); 62 62 gVirtualX->DeleteImage((Drawable_t)fImage); … … 69 69 void MGImage::DoRedraw() 70 70 { 71 fMuxPixmap->Lock(); 72 73 if (TestBit(kNeedRedraw)) 74 { 75 gVirtualX->PutImage(fId, fDefGC, (Drawable_t)fImage, 0, 0, 0, 0, fWidth, fHeight); 71 if (TestBit(kSyncMode)) 72 while (fMuxPixmap->Lock()==13) 73 usleep(1); 74 75 // gVirtualX->DrawLine(fId, fDefGC, 0, 0, fWidth+2, 0); 76 // gVirtualX->DrawLine(fId, fDefGC, 0, 0, 0, fHeight+2); 77 // gVirtualX->DrawLine(fId, fDefGC, fWidth+2, 0, fWidth+2, fHeight+2); 78 // gVirtualX->DrawLine(fId, fDefGC, 0, fHeight+2, fWidth+2, fHeight+2); 79 80 // if (TestBit(kNeedRedraw)) 81 { 82 gVirtualX->PutImage(fId, fDefGC, (Drawable_t)fImage, 0, 0, 0, 0, 83 fWidth, fHeight); 76 84 ResetBit(kNeedRedraw); 77 85 } 78 86 79 fMuxPixmap->UnLock(); 87 if (TestBit(kSyncMode)) 88 if (fMuxPixmap->UnLock()==13) 89 cout << "MGImage::DoRedraw - tried to unlock mutex locked by other thread." << endl; 80 90 } 81 91 … … 109 119 void MGImage::DrawImg(const byte *buffer) 110 120 { 111 if (fMuxPixmap->TryLock()) 112 return; 121 if (TestBit(kSyncMode)) 122 while (fMuxPixmap->Lock()==13) 123 usleep(1); 124 else 125 { 126 const Int_t rc = fMuxPixmap->Lock(); 127 if (rc==13) 128 cout << "MGImage::DrawImg - mutex is already locked by this thread" << endl; 129 if (rc) 130 return; 131 } 113 132 114 133 switch (gVirtualX->GetDepth()) … … 129 148 SetBit(kNeedRedraw); 130 149 131 fMuxPixmap->UnLock(); 150 if (fMuxPixmap->UnLock()==13) 151 cout << "MGImage::DrawImage - tried to unlock mutex locked by other thread." << endl; 132 152 } 133 153 … … 143 163 { 144 164 // 00000011 00001100 00110000 145 *d++ = (*s2&0x3) | (*s2&0xb)<<3 | (*s2&0x30)<<7;146 s1++;165 //*d++ = (*s2&0x3) | (*s2&0xb)<<3 | (*s2&0x30)<<7; 166 *d++ = (*s2&0x3)<<3 | (*s2&0xb)<<6 | (*s2&0x30)<<10; 147 167 } 148 168 else … … 150 170 // 11111100 11111000 11111100 151 171 *d++ = (*s1&0xfc) | (*s1&0xf8)<<5 | (*s1&0xfc)<<11; 152 s2++; 153 } 172 } 173 s1++; 174 s2++; 154 175 } 155 176 } … … 181 202 void MGImage::DrawColImg(const byte *gbuf, const byte *cbuf) 182 203 { 183 if (fMuxPixmap->TryLock()) 184 return; 204 if (TestBit(kSyncMode)) 205 while (fMuxPixmap->Lock()==13) 206 usleep(1); 207 else 208 { 209 const Int_t rc = fMuxPixmap->Lock(); 210 if (rc==13) 211 cout << "MGImage::DrawColImg - mutex is already locked by this thread" << endl; 212 if (rc) 213 return; 214 } 185 215 186 216 // FROM libAfterImage: … … 190 220 //#define ALPHA_SOLID 0xFF 191 221 // * Lowermost 8 bits - Blue channel 192 // * bits 8 to 15- Green channel222 // * bits 8 to 15 - Green channel 193 223 // * bits 16 to 23 - Red channel 194 224 // * bits 24 to 31 - Alpha channel … … 211 241 SetBit(kNeedRedraw); 212 242 213 fMuxPixmap->UnLock(); 214 } 243 if (fMuxPixmap->UnLock()==13) 244 cout << "MGImage::DrawColImage - tried to unlock mutex locked by other thread." << endl; 245 } -
trunk/MagicSoft/Cosy/gui/MGImage.h
r2518 r4076 24 24 25 25 GContext_t fDefGC; 26 Pixmap_t fPixmap;26 //Pixmap_t fPixmap; 27 27 28 28 UInt_t fWidth; … … 31 31 TMutex *fMuxPixmap; //! test 32 32 33 enum { kNeedRedraw = BIT(17) }; 33 enum 34 { 35 kNeedRedraw = BIT(17), 36 kSyncMode = BIT(18) 37 }; 34 38 35 39 void DrawImg16(unsigned short *d, char *s, char *e); … … 47 51 void DrawColImg(const byte *gbuf, const byte *cbuf); 48 52 53 void EnableSyncMode() { SetBit(kSyncMode); } 54 void DisableSyncMode() { ResetBit(kSyncMode); } 55 49 56 ClassDef(MGImage, 0) 50 57 }; -
trunk/MagicSoft/Cosy/gui/MGPngReader.cc
r2615 r4076 347 347 const Double_t pixsize = 23.4; 348 348 349 fSao->SetPixSize(pixsize /3600);349 fSao->SetPixSize(pixsize); 350 350 351 351 TString txt; … … 586 586 const Float_t pixsize = atof(fPixSize->GetText()); 587 587 cout << "Pixel Size changed to " << pixsize << "\"/pix" << endl; 588 fSao->SetPixSize(pixsize /3600);588 fSao->SetPixSize(pixsize); 589 589 } 590 590 return kTRUE; -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.h
r2278 r4076 9 9 10 10 11 #ifndef MGEMBEDDEDCANVAS_H11 #ifndef COSY_MGEmbeddedCanvas 12 12 #include "MGEmbeddedCanvas.h" 13 13 #endif -
trunk/MagicSoft/Cosy/gui/MGTPoint.cc
r2615 r4076 151 151 const Double_t pixsize = 23.4; 152 152 153 fSao->SetPixSize(pixsize /3600);153 fSao->SetPixSize(pixsize); 154 154 155 155 TString txt; … … 225 225 const Float_t pixsize = atof(fPixSize->GetText()); 226 226 cout << "Pixel Size changed to " << pixsize << "\"/pix" << endl; 227 fSao->SetPixSize(pixsize /3600);227 fSao->SetPixSize(pixsize); 228 228 } 229 229 return kTRUE; -
trunk/MagicSoft/Cosy/gui/MGVelocity.cc
r2278 r4076 181 181 // calculate actual time for planet positions 182 182 // 183 float vx = zdaz.Az() *3600.; // ["/min]184 float vy = zdaz.Zd() *3600.; // ["/min]183 float vx = zdaz.Az(); // [U_mot/min] 184 float vy = zdaz.Zd(); // [U_mot/min] 185 185 186 186 int pixx = (int)(vx*fScale/fPix); -
trunk/MagicSoft/Cosy/gui/MGVelocity.h
r2278 r4076 8 8 // Version: V1.0 (1-8-2000) 9 9 10 #ifndef MGEMBEDDEDCANVAS_H10 #ifndef COSY_MGEmbeddedCanvas 11 11 #include "MGEmbeddedCanvas.h" 12 12 #endif
Note:
See TracChangeset
for help on using the changeset viewer.