Changeset 3457 for trunk/MagicSoft
- Timestamp:
- 03/10/04 17:07:24 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r3456 r3457 20 20 2004/03/10: Markus Gaug 21 21 22 * mcalib/MCalibrationChargeCalc.cc 23 * mcalib/MCalibrationChargePix.[h,cc]24 * mcalib/MCalibrationChargeCam.[h,cc]22 * mcalib/MCalibrationChargeCalc.cc, 23 mcalib/MCalibrationChargePix.[h,cc], 24 mcalib/MCalibrationChargeCam.[h,cc]: 25 25 - calculation of conversion factor with F-Factor method from 26 26 same mean number of photons, derived from weighted mean number 27 27 of photo-electrons from inner and outer pixels, respectively 28 28 29 * mjobs/MJPedestal.cc 30 * mjobs/MJCalibration.cc 31 * macros/calibration.C 29 * mjobs/MJPedestal.cc, mjobs/MJCalibration.cc, macros/calibration.C: 32 30 - fixed the projections (did only display inner pixels up to now) 33 31 32 34 33 35 34 2004/03/10: Thomas Bretz … … 37 36 * mfilter/MFSoftwareTrigger.[h,cc]: 38 37 - changed to support also a predifined number of NN 38 39 * mastro/MAstroCatalog.[h,cc]: 40 - many enhancements 41 - many speed improvements 39 42 40 43 -
trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc
r3415 r3457 34 34 35 35 #include <fstream> 36 36 #include <stdlib.h> 37 38 #include <KeySymbols.h> 39 40 #include <TPad.h> // TPad::GetMaxPickDistance 37 41 #include <TLine.h> 38 42 #include <TMarker.h> 43 #include <TCanvas.h> 39 44 #include <TArrayI.h> 45 #include <TGToolTip.h> 40 46 #include <TRotation.h> 41 47 #include <TStopwatch.h> 42 #include <TVirtualPad.h>43 44 #include <stdlib.h>45 48 46 49 #include "MLog.h" 47 50 #include "MLogManip.h" 48 51 52 #include "MTime.h" 49 53 #include "MAstro.h" 50 #include "MTime.h"51 54 #include "MObservatory.h" 52 55 … … 66 69 zdaz.SetZdAz(Theta(), alpha-Phi(), Mag()); 67 70 zdaz.RotateY(obs.GetPhi()-TMath::Pi()/2); 71 68 72 return zdaz; 69 73 … … 83 87 } 84 88 89 MVector3 MVector3::GetRaDec(const MObservatory &obs, Double_t gmst) const 90 { 91 if (!fType==kIsZdAz) 92 return MVector3(); 93 94 const Double_t alpha = gmst + obs.GetElong(); 95 96 MVector3 v(*this); 97 v.RotateY(TMath::Pi()/2-obs.GetPhi()); 98 99 MVector3 rd; 100 rd.SetRaDec(alpha-v.Phi(), TMath::Pi()/2-v.Theta(), Mag()); 101 return rd; 102 103 /* 104 // ------ The same using slalib, tested in the drive system ------- 105 const Double_t alpha = slaGmst(mjd) + obs.GetElong(); 106 Double_t el; 107 slaDe2h(fAlpha-ra, dec, obs.GetPhi(), &az, &el); 108 zd = TMath::Pi()/2-el; 109 return; 110 */ 111 } 112 113 MVector3 MVector3::GetRaDec(const MTime &time, MObservatory &obs) const 114 { 115 return GetRaDec(obs, time.GetGmst()); 116 } 117 118 MAstroCatalog::MAstroCatalog() : fLimMag(99), fRadiusFOV(99), fToolTip(0), fObservatory(0), fTime(0) 119 { 120 fList.SetOwner(); 121 fToolTip = new TGToolTip(0, "", 0); 122 } 123 124 MAstroCatalog::~MAstroCatalog() 125 { 126 if (fTime) 127 delete fTime; 128 if (fObservatory) 129 delete fObservatory; 130 131 fToolTip->Hide(); 132 delete fToolTip; 133 134 DeleteMap(); 135 136 // FIXME: There must be an easier way! 137 TIter Next(gROOT->GetListOfCanvases()); 138 TCanvas *c; 139 while ((c=(TCanvas*)Next())) 140 c->Disconnect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", this, 141 "EventInfo(Int_t,Int_t,Int_t,TObject*)"); 142 143 } 144 85 145 TString MAstroCatalog::FindToken(TString &line, Char_t tok) 86 146 { … … 120 180 Int_t MAstroCatalog::ReadXephem(TString catalog) 121 181 { 182 SetBit(kHasChanged); 183 122 184 gLog << inf << "Reading Xephem catalog: " << catalog << endl; 123 185 … … 181 243 MVector3 *star=new MVector3; 182 244 star->SetRaDec(ra0, dec0, mag); 245 star->SetName(name); 183 246 if (star->Angle(fRaDec)*TMath::RadToDeg()>fRadiusFOV) 184 247 { … … 197 260 Int_t MAstroCatalog::ReadNGC2000(TString catalog) 198 261 { 262 SetBit(kHasChanged); 263 199 264 gLog << inf << "Reading NGC2000 catalog: " << catalog << endl; 200 265 … … 240 305 MVector3 *star=new MVector3; 241 306 star->SetRaDec(ra, dec, mag); 307 star->SetName(row(0, 8)); 242 308 if (star->Angle(fRaDec)*TMath::RadToDeg()>fRadiusFOV) 243 309 { … … 257 323 Int_t MAstroCatalog::ReadBSC(TString catalog) 258 324 { 325 SetBit(kHasChanged); 326 259 327 gLog << inf << "Reading Bright Star Catalog (BSC5) catalog: " << catalog << endl; 260 328 … … 302 370 MVector3 *star=new MVector3; 303 371 star->SetRaDec(ra, dec, mag); 372 star->SetName(row(4,9)); 304 373 if (star->Angle(fRaDec)*TMath::RadToDeg()>fRadiusFOV) 305 374 { … … 317 386 } 318 387 319 Bool_t MAstroCatalog::Convert(const TRotation &rot, TVector2 &v, Int_t type)388 Int_t MAstroCatalog::Convert(const TRotation &rot, TVector2 &v, Int_t type) 320 389 { 321 390 MVector3 w; 322 w.SetRaDec(v.Y(), v.X()-fRaDec.Phi(), v.Y()); 391 392 switch (type) 393 { 394 case 1: 395 w.SetRaDec(v.X()-fRaDec.Phi(), v.Y(), 1); 396 break; 397 398 case 2: 399 if (!fTime || !fObservatory) 400 return kFALSE; 401 w.SetZdAz(v.Y(), v.X(), 1); 402 w = w.GetRaDec(*fTime, *fObservatory); 403 w.RotateZ(-fRaDec.Phi()); 404 break; 405 406 default: 407 return kFALSE; 408 } 409 323 410 w *= rot; 324 411 325 v.Set(w.Phi(), w.Theta()); 326 327 return w.Angle(TVector3(1, 0, 0))*TMath::RadToDeg()<=fRadiusFOV; 328 } 329 330 Bool_t MAstroCatalog::PaintLine(const TVector2 &v, Double_t dx, Double_t dy, const TRotation &rot, Int_t type) 412 // Stretch such, that the X-component is alwas the same. Now 413 // Y and Z contains the crossing point between the star-light 414 // and the plain of a virtual screen (ccd...) 415 if (TestBit(kPlainScreen)) 416 w *= TMath::RadToDeg()/w.X(); 417 else 418 w.SetMag(TMath::RadToDeg()); 419 420 v.Set(w(1), w(2)); 421 422 if (w(0)<0) 423 return kERROR; 424 425 return w(1)>gPad->GetX1() && w(2)>gPad->GetY1() && 426 w(1)<gPad->GetX2() && w(2)<gPad->GetY2(); 427 } 428 429 Bool_t MAstroCatalog::DrawLine(const TVector2 &v, Double_t dx, Double_t dy, const TRotation &rot, Int_t type) 331 430 { 332 431 const TVector2 add(dx*TMath::DegToRad(), dy*TMath::DegToRad()); … … 335 434 TVector2 v1 = v+add; 336 435 337 const Bool_t rc0 = Convert(rot, v0, type); 338 const Bool_t rc1 = Convert(rot, v1, type); 339 if (!rc0 && !rc1) 436 const Int_t rc0 = Convert(rot, v0, type); 437 const Int_t rc1 = Convert(rot, v1, type); 438 // Both are kFALSE or both are kERROR 439 if ((rc0|rc1)==kFALSE || (rc0&rc1)==kERROR) 340 440 return kFALSE; 341 441 342 TLine line; 343 line.SetLineColor(kGreen); 344 line.PaintLine(v0.X(), TMath::Pi()/2-v0.Y(), 345 v1.X(), TMath::Pi()/2-v1.Y()); 442 TLine *line = new TLine(v0.X(), v0.Y(), v1.X(), v1.Y()); 443 line->SetBit(kCanDelete); 444 line->SetLineStyle(kDashDotted); //kDashed, kDotted, kDashDotted 445 line->SetLineColor(kWhite+type*2); 446 line->SetBit(kCannotPick); 447 fMapG.Add((Long_t)line, 0); 448 449 const TVector2 deg = v*TMath::RadToDeg(); 450 TString txt = type==1 ? 451 Form("Ra=%.1fh Dec=%.1fd", fmod(deg.X()/15+48, 24), fmod(deg.Y()+270,180)-90) : 452 Form("Zd=%.1fd Az=%.1fd", fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360)); 453 454 TMarker *tip=new TMarker(v0.X(), v0.Y(), kDot); 455 tip->SetBit(kCanDelete); 456 tip->SetMarkerColor(kWhite+type*2); 457 fMapG.Add((Long_t)tip, (Long_t)new TString(txt)); 346 458 347 459 return kTRUE; 348 460 } 349 461 350 void MAstroCatalog::Paint(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Byte_t type) 351 { 462 void MAstroCatalog::Draw(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Int_t stepx, Int_t stepy, Int_t type) 463 { 464 const TVector2 v1 = v0 + TVector2(dx[0]*TMath::DegToRad(), dy[0]*TMath::DegToRad()); 465 466 // if (TMath::Abs(v1.Y())>TMath::Pi()/2) 467 // return; 468 469 const Int_t v0x = (int)(v0.X()*TMath::RadToDeg()); 470 const Int_t v0y = (int)(v0.Y()*TMath::RadToDeg()); 471 352 472 Int_t idx[] = {1, 1, 1, 1}; 353 473 354 Int_t dirs[4][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} };474 Int_t dirs[4][2] = { {0, stepy}, {stepx, 0}, {0, -stepy}, {-stepx, 0} }; 355 475 356 476 for (int i=0; i<dx.GetSize(); i++) 357 477 { 358 478 for (int j=0; j<4; j++) 359 if (dx[i]==dx[0]+dirs[j][0] && dy[i]==dy[0]+dirs[j][1]) 479 { 480 const Bool_t rcx0 = (dx[i]+720)%360==(dx[0]+dirs[j][0]+720)%360; 481 const Bool_t rcy0 = (dy[i]+360)%180==(dy[0]+dirs[j][1]+360)%180; 482 if (rcx0&&rcy0) 360 483 idx[j] = 0; 361 } 362 363 TVector2 v1 = v0 + TVector2(dx[0]*TMath::DegToRad(), dy[0]*TMath::DegToRad()); 484 } 485 } 486 487 // Enhance size of array by 1, copy current 488 // position as last entry 489 dx.Set(dx.GetSize()+1); 490 dy.Set(dy.GetSize()+1); 491 492 dx[dx.GetSize()-1] = dx[0]; 493 dy[dy.GetSize()-1] = dy[0]; 494 495 // Store current positon 496 const Int_t d[2] = { dx[0], dy[0] }; 364 497 365 498 for (int i=0; i<4; i++) 366 499 if (idx[i]) 367 500 { 368 dx.Set(dx.GetSize()+1); 369 dy.Set(dy.GetSize()+1); 370 371 dx[dx.GetSize()-1] = dx[0]; 372 dy[dy.GetSize()-1] = dy[0]; 373 374 dx[0] += dirs[i][0]; 375 dy[0] += dirs[i][1]; 376 377 if (PaintLine(v1, dirs[i][0], dirs[i][1], rot, type)) 378 Paint(v0, rot, dx, dy, type); 379 380 dx[0] -= dirs[i][0]; 381 dy[0] -= dirs[i][1]; 501 // Calculate new position 502 //dx[0] = (d[0]+dirs[i][0]+540-v0x)%360-180+v0x; 503 //dy[0] = (d[1]+dirs[i][1]+270-v0y)%180- 90+v0y; 504 dx[0] = d[0]+dirs[i][0]; 505 dy[0] = d[1]+dirs[i][1]; 506 507 // Draw corresponding line and iterate through grid 508 if (DrawLine(v1, dirs[i][0], dirs[i][1], rot, type)) 509 Draw(v0, rot, dx, dy, stepx, stepy, type); 510 511 dx[0]=d[0]; dy[0]=d[1]; 382 512 } 383 513 } 384 514 385 void MAstroCatalog:: PaintNet(const TVector2 &v0, const TRotation &rot, Int_t type)515 void MAstroCatalog::DrawNet(const TVector2 &v0, const TRotation &rot, Int_t type) 386 516 { 387 517 //const Double_t step = TMath::DegToRad(); … … 390 520 TArrayI dy(1); 391 521 522 // align to 1deg boundary 392 523 TVector2 v = v0*TMath::RadToDeg(); 393 v.Set(TMath::Floor(v.X()), TMath::Floor(v.Y())); 524 v.Set((Float_t)TMath::Nint(v.X()), (Float_t)TMath::Nint(v.Y())); 525 526 // calculate stepsizes based on visible FOV 527 Int_t stepx=1; 528 if (fabs(v.Y())>90-fRadiusFOV || fabs(v.Y())<fRadiusFOV) 529 stepx = 180/10; 530 else 531 { 532 // This is a rough estimate how many degrees are visible 533 const Float_t m = log(fRadiusFOV/180.)/log(90./fRadiusFOV-1); 534 const Float_t t = log(180.)-m*log(fRadiusFOV); 535 const Int_t n = (Int_t)(exp(m*log(90-fabs(v.Y()))+t)+0.5); 536 stepx = n<4 ? 1 : n/4; 537 } 538 539 const Int_t n = (Int_t)(fRadiusFOV+1); 540 Int_t stepy = n<4 ? 1 : n/4; 541 542 // align stepsizes to be devisor or 180 and 90 543 while (180%stepx) 544 stepx++; 545 while (90%stepy) 546 stepy++; 547 548 // align to step-size boundary 549 while ((int)(v.X())%stepx) 550 v.Set(v.X()+1, v.Y()); 551 552 while ((int)(v.Y())%stepy) 553 v.Set(v.X(), v.Y()+1); 554 555 // draw... 394 556 v *= TMath::DegToRad(); 395 396 Paint(v, rot, dx, dy, type); 557 Draw(v, rot, dx, dy, stepx, stepy, type); 397 558 } 398 559 399 560 void MAstroCatalog::Paint(Option_t *o) 400 561 { 401 Double_t ra = fRaDec.Phi(); 402 Double_t dec = TMath::Pi()/2-fRaDec.Theta(); 403 404 TIter Next(&fList); 405 TVector3 *v; 406 407 Double_t minra=360, maxra=0, mindec=360, maxdec=0; 408 409 while ((v=(TVector3*)Next())) 410 { 411 minra = TMath::Min(minra, v->Phi()); 412 maxra = TMath::Max(maxra, v->Phi()); 413 414 mindec = TMath::Min(mindec, TMath::Pi()/2-v->Theta()); 415 maxdec = TMath::Max(maxdec, TMath::Pi()/2-v->Theta()); 416 } 417 418 cout << gPad << endl; 419 420 cout << "Minra: " << (minra-ra)*TMath::RadToDeg() << endl; 421 cout << "Maxra: " << (maxra-ra)*TMath::RadToDeg() << endl; 422 423 cout << "Mindec: " << (mindec-dec)*TMath::RadToDeg() << endl; 424 cout << "Maxdec: " << (maxdec-dec)*TMath::RadToDeg() << endl; 425 426 //gPad->Range(minra-ra, mindec-dec, maxra-ra, maxdec-dec); 427 gPad->Range(-fRadiusFOV*TMath::DegToRad()/TMath::Sqrt(2.), -fRadiusFOV*TMath::DegToRad()/TMath::Sqrt(2.), 428 fRadiusFOV*TMath::DegToRad()/TMath::Sqrt(2.), fRadiusFOV*TMath::DegToRad()/TMath::Sqrt(2.)); 429 430 Next.Reset(); 431 432 cout << "Dec: " << dec*TMath::RadToDeg() << endl; 433 cout << "Ra: " << ra*TMath::RadToDeg() << endl; 562 if (!gPad->IsBatch()) 563 gVirtualX->ClearWindow(); 564 565 if (TestBit(kHasChanged)) 566 DrawPrimitives(o); 567 } 568 569 void MAstroCatalog::DrawStar(Double_t x, Double_t y, const TVector3 &v, Bool_t transparent) 570 { 571 const Double_t ra = v.Phi()*TMath::RadToDeg()/15; 572 const Double_t dec = (TMath::Pi()/2-v.Theta())*TMath::RadToDeg(); 573 574 TString str = v.GetName(); 575 str += Form(": Ra=%.1fh", ra); 576 str += Form(" Dec=%.1fd", dec); 577 str += Form(" Mag=%.1f", -2.5*log10(v.Mag())); 578 579 // draw star on the camera display 580 TMarker *tip=new TMarker(x, y, transparent ? kDot : kFullDotLarge);; 581 tip->SetMarkerColor(kBlack); 582 tip->SetBit(kCanDelete); 583 tip->SetBit(kCannotPick); 584 fMapG.Add((Long_t)tip, (Long_t)new TString(str)); 585 } 586 587 void MAstroCatalog::Update() 588 { 589 if (gPad && TestBit(kMustCleanup)) 590 { 591 SetBit(kHasChanged); 592 gPad->Modified(); 593 } 594 } 595 596 void MAstroCatalog::SetTime(const MTime &time) 597 { 598 if (fTime) 599 delete fTime; 600 fTime=(MTime*)time.Clone(); 601 } 602 603 void MAstroCatalog::SetObservatory(const MObservatory &obs) 604 { 605 if (fObservatory) 606 delete fObservatory; 607 fObservatory=(MObservatory*)obs.Clone(); 608 } 609 610 void MAstroCatalog::AddPrimitives(Option_t *o) 611 { 612 const Double_t ra = fRaDec.Phi(); 613 const Double_t dec = TMath::Pi()/2-fRaDec.Theta(); 434 614 435 615 // Precalc Sin/Cos... … … 437 617 trans.Rotate(dec, TVector3(0, 1, 0)); 438 618 619 const TVector3 zdaz0 = fRaDec.GetZdAz(*fTime, *fObservatory); 620 TVector2 zdaz(zdaz0.Phi(), zdaz0.Theta()); 621 MAstroCatalog::DrawNet(zdaz, trans, 2); 622 623 TVector2 radec(ra, dec); 624 MAstroCatalog::DrawNet(radec, trans, 1); 625 626 TIter Next(&fList); 627 TVector3 *v=0; 628 while ((v=(TVector3*)Next())) 629 { 630 // FIXME: Check Magnitude! 631 TVector2 s(v->Phi(), TMath::Pi()/2-v->Theta()); 632 if (Convert(trans, s, 1)==kTRUE) 633 DrawStar(s.X(), s.Y(), *v, kFALSE); 634 } 635 } 636 637 void MAstroCatalog::SetRangePad() 638 { 639 const Double_t edge = fRadiusFOV/TMath::Sqrt(2.); 640 gPad->Range(-edge, -edge, edge, edge); 641 642 cout << gPad->GetWw() << " " << gPad->GetWh() << endl; 643 644 const Float_t w = gPad->GetWw(); 645 const Float_t h = gPad->GetWh(); 646 647 if (w<h) 648 gPad->Range(-edge, -edge*h/w, edge, edge*h/w); 649 else 650 gPad->Range(-edge*w/h, -edge, edge*w/h, edge); 651 } 652 653 void MAstroCatalog::DrawPrimitives(Option_t *o) 654 { 655 DeleteMap(); 656 657 SetRangePad(); 658 439 659 TStopwatch clk; 440 660 clk.Start(); 441 442 TMarker mark; 443 mark.SetMarkerColor(kBlack); 444 mark.SetMarkerStyle(kCircle); 445 while ((v=(TVector3*)Next())) 446 { 447 MVector3 v0; 448 v0.SetRaDec(v->Phi()-ra, TMath::Pi()/2-v->Theta(), 1); 449 v0 *= trans; 450 451 mark.SetMarkerSize((fLimMag-TMath::Log(v->Mag()))/4); 452 mark.PaintMarker(v0.Phi(), TMath::Pi()/2-v0.Theta()); 453 } 454 455 TMarker m; 456 m.SetMarkerStyle(kCross); 457 m.PaintMarker(0, 0); 458 459 m.SetMarkerColor(kRed); 460 m.SetMarkerStyle(kFullDotSmall); 461 462 TVector2 v0(ra, dec); 463 PaintNet(v0, trans); 464 661 AddPrimitives(o); 465 662 clk.Stop(); 466 663 clk.Print(); 467 } 664 665 // Append all objects to pad 666 DrawMap(); 667 668 ResetBit(kHasChanged); 669 } 670 671 void MAstroCatalog::Draw(Option_t *o) 672 { 673 TObject::Draw(o); 674 675 if (!TestBit(kHasChanged)) 676 DrawPrimitives(o); 677 678 // Connect all TCanvas::ProcessedEvent to this->EventInfo 679 // This means, that after TCanvas has processed an event 680 // EventInfo of this class is called, see TCanvas::HandleInput 681 gPad->GetCanvas()->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", 682 "MAstroCatalog", this, 683 "EventInfo(Int_t,Int_t,Int_t,TObject*)"); 684 685 // Do this instead of fListG.Draw, because 686 // TCollection overwrites Draw 687 // Would be nice, but doesn't work because the single 688 // graphical object are not handled by TPad anymore... 689 // fListG.AppendPad(); 690 } 691 692 // -------------------------------------------------------------------------- 693 // 694 // This function was connected to all created canvases. It is used 695 // to redirect GetObjectInfo into our own status bar. 696 // 697 // The 'connection' is done in AddTab 698 // 699 void MAstroCatalog::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected) 700 { 701 if (!selected) 702 return; 703 704 TCanvas *c = (TCanvas*)gTQSender; 705 706 TVirtualPad* save=gPad; 707 708 gPad = c ? c->GetSelectedPad() : NULL; 709 if (!gPad) 710 return; 711 712 switch (event) 713 { 714 case kMouseMotion: 715 { 716 TString *s = (TString*)fMapG.GetValue((Long_t)selected); 717 if (!fToolTip->IsMapped() && s) 718 ShowToolTip(px, py, *s); 719 } 720 break; 721 722 case kMouseLeave: 723 if (fToolTip->IsMapped()) 724 fToolTip->Hide(); 725 break; 726 727 case kKeyPress: // Unresolved keyboard event 728 /* 729 switch (px) 730 { 731 case kKey_Plus: 732 case kKey_Minus:*/ 733 ExecuteEvent(kKeyPress, px, py);/* 734 break; 735 } 736 break;*/ 737 } 738 739 gPad=save; 740 } 741 742 void MAstroCatalog::ExecuteEventKbd(Int_t keycode, Int_t keysym) 743 { 744 Double_t dra =0; 745 Double_t ddec=0; 746 747 switch (keysym) 748 { 749 case kKey_Left: 750 dra = -TMath::DegToRad(); 751 break; 752 case kKey_Right: 753 dra = +TMath::DegToRad(); 754 break; 755 case kKey_Up: 756 ddec = +TMath::DegToRad(); 757 break; 758 case kKey_Down: 759 ddec = -TMath::DegToRad(); 760 break; 761 case kKey_Plus: 762 SetRadiusFOV(fRadiusFOV+1); 763 break; 764 case kKey_Minus: 765 SetRadiusFOV(fRadiusFOV-1); 766 break; 767 768 default: 769 return; 770 } 771 772 const Double_t r = fRaDec.Phi(); 773 const Double_t d = TMath::Pi()/2-fRaDec.Theta(); 774 775 SetRaDec(r+dra, d+ddec); 776 777 gPad->Update(); 778 } 779 780 // ------------------------------------------------------------------------ 781 // 782 // Execute a gui event on the camera 783 // 784 void MAstroCatalog::ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2) 785 { 786 if (!TestBit(kGuiActive)) 787 return; 788 789 if (event==kKeyPress) 790 ExecuteEventKbd(mp1, mp2); 791 792 } 793 794 Int_t MAstroCatalog::DistancetoPrimitive(Int_t px, Int_t py) 795 { 796 Int_t min = INT_MAX; 797 798 Long_t key, val; 799 TExMapIter map(&fMapG); 800 while (map.Next(key, val)) 801 { 802 TObject *o=(TObject*)key; 803 804 const Int_t d = o->DistancetoPrimitive(px, py); 805 806 if (d<TPad::GetMaxPickDistance()) 807 return 0; 808 809 if (d<min) 810 min=d; 811 } 812 813 return min; 814 } 815 816 void MAstroCatalog::ShowToolTip(Int_t px, Int_t py, const char *txt) 817 { 818 Int_t x=0; 819 Int_t y=0; 820 821 const Window_t id1 = gVirtualX->GetWindowID(gPad->GetCanvasID()); 822 const Window_t id2 = fToolTip->GetParent()->GetId(); 823 824 Window_t id3; 825 gVirtualX->TranslateCoordinates(id1, id2, px, py, x, y, id3); 826 827 // Show tool tip 828 fToolTip->SetText(txt); 829 fToolTip->Show(x+4, y+4); 830 } 831 -
trunk/MagicSoft/Mars/mastro/MAstroCatalog.h
r3402 r3457 4 4 #ifndef ROOT_TVector3 5 5 #include <TVector3.h> 6 #endif 7 #ifndef ROOT_TExMap 8 #include <TExMap.h> 6 9 #endif 7 10 #ifndef ROOT_TList … … 12 15 class MObservatory; 13 16 class TArrayI; 17 class TGToolTip; 14 18 15 19 class MVector3 : public TVector3 16 20 { 21 private: 17 22 enum VectorType_t 18 23 { … … 26 31 VectorType_t fType; 27 32 33 TString fName; 34 28 35 public: 29 36 /* … … 34 41 MVector3() { fType=kIsInvalid; } 35 42 MVector3(const TVector3 &v3) : TVector3(v3) { fType=kIsArbitrary; } 36 Double_t Magnitude() const { return TMath::Log(Mag()); }43 Double_t Magnitude() const { return -2.5*TMath::Log10(Mag()); } 37 44 38 45 void SetRaDec(Double_t ra, Double_t dec, Double_t mag) 39 46 { 40 47 fType = kIsRaDec; 41 SetMagThetaPhi( exp(mag), TMath::Pi()/2-dec, ra);48 SetMagThetaPhi(pow(10, -mag/2.5), TMath::Pi()/2-dec, ra); 42 49 } 50 void SetName(const TString &str) { fName = str.Strip(TString::kBoth); } 43 51 void SetZdAz(Double_t zd, Double_t az, Double_t mag) 44 52 { 45 53 fType = kIsZdAz; 46 SetMagThetaPhi( exp(mag), zd, az);54 SetMagThetaPhi(pow(10, -mag/2.5), zd, az); 47 55 } 48 56 void SetAltAz(Double_t alt, Double_t az, Double_t mag) 49 57 { 50 58 fType = kIsAltAz; 51 SetMagThetaPhi( exp(mag), TMath::Pi()/2-alt, az);59 SetMagThetaPhi(pow(10, -mag/2.5), TMath::Pi()/2-alt, az); 52 60 } 61 62 const char *GetName() const { return fName; } 53 63 54 64 MVector3 GetZdAz(const MObservatory &obs, Double_t gmst) const; 55 65 MVector3 GetZdAz(const MTime &time, MObservatory &obs) const; 66 MVector3 GetRaDec(const MObservatory &obs, Double_t gmst) const; 67 MVector3 GetRaDec(const MTime &time, MObservatory &obs) const; 56 68 57 ClassDef(MVector3, 0)69 ClassDef(MVector3, 1) 58 70 }; 59 71 … … 63 75 Double_t fLimMag; // [1] Limiting Magnitude 64 76 Double_t fRadiusFOV; // [deg] Radius of Field of View 65 MVector3 fRaDec; // pointing position66 77 67 TList fList; 78 TGToolTip *fToolTip; //! 79 80 void ShowToolTip(Int_t px, Int_t py, const char *txt); 68 81 69 82 TString FindToken(TString &line, Char_t tok=','); … … 74 87 Float_t atof(const TString &s); 75 88 76 public: 77 MAstroCatalog() : fLimMag(99), fRadiusFOV(99) 89 Bool_t fPlainScreen; //! Just a dummy!!!! ([Set,Is]Freezed) 90 91 protected: 92 enum { 93 kHasChanged = BIT(15), 94 kGuiActive = BIT(16), 95 kPlainScreen = BIT(17) 96 }; 97 98 TExMap fMapG; 99 TList fList; // List of stars loaded 100 MVector3 fRaDec; // pointing position 101 102 MObservatory *fObservatory; // Possible obervatora location 103 MTime *fTime; // Possible observation time 104 105 virtual Int_t Convert(const TRotation &rot, TVector2 &v, Int_t type=0); 106 virtual Bool_t DrawLine(const TVector2 &v0, Double_t dx, Double_t dy, const TRotation &rot, Int_t type); 107 virtual void AddPrimitives(Option_t *o); 108 virtual void DrawPrimitives(Option_t *o); 109 virtual void SetRangePad(); 110 void Draw(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Int_t stepx, Int_t stepy, Int_t type); 111 void DrawNet(const TVector2 &v0, const TRotation &rot, Int_t type); 112 void DrawStar(Double_t x, Double_t y, const TVector3 &v, Bool_t t); 113 void Paint(Option_t *o=""); 114 Int_t DistancetoPrimitive(Int_t px, Int_t py); 115 void Update(); 116 117 void ExecuteEventKbd(Int_t keycode, Int_t keysym); 118 void ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2); 119 120 void DeleteMap() 78 121 { 79 fList.SetOwner(); 122 Long_t key, val; 123 TExMapIter map(&fMapG); 124 while (map.Next(key, val)) 125 { 126 delete (TObject*)(key); 127 if (!val) 128 continue; 129 130 delete (TString*)(val); 131 /* 132 Long_t key2, val2; 133 TExMapIter map2(&fMapG); 134 while (map2.Next(key2, val2)) 135 if (val==val2) 136 { 137 delete (TObject*)key; 138 fMapG.Remove(key); 139 }*/ 140 } 141 fMapG.Delete(); 142 } 143 void DrawMap() 144 { 145 Long_t key, val; 146 TExMapIter map(&fMapG); 147 while (map.Next(key, val)) 148 ((TObject*)key)->Draw(); 80 149 } 81 150 82 void SetLimMag(Double_t mag) { fLimMag=mag; } 83 void SetRadiusFOV(Double_t deg) { fRadiusFOV=deg; } 84 void SetRaDec(Double_t ra, Double_t dec) { fRaDec.SetRaDec(ra, dec, 1); } 85 void SetRaDec(const TVector3 &v) { fRaDec=v; } 86 void Delete(Option_t *o="") { fList.Delete(o); } 151 public: 152 MAstroCatalog(); 153 ~MAstroCatalog(); 154 155 void SetTime(const MTime &time); 156 void SetObservatory(const MObservatory &obs); 157 void SetLimMag(Double_t mag) { fLimMag=mag; Update(); } // *MENU* *ARGS={mag=>fLimMag} 158 void SetRadiusFOV(Double_t deg) 159 { 160 //const Double_t max = TestBit(kPlainScreen) ? 90 : 55; 161 const Double_t max = TestBit(kPlainScreen) ? 180 : 90; 162 if (deg>max) 163 deg=max; 164 if (deg<=0) 165 deg=1; 166 167 fRadiusFOV=deg; 168 169 Update(); 170 } // *MENU* *ARGS={deg=>fRadiusFOV} 171 void SetRaDec(Double_t ra, Double_t dec) { fRaDec.SetRaDec(ra, dec, 1); Update(); } 172 void SetRaDec(const TVector3 &v) { fRaDec=v; Update(); } 173 void SetGuiActive(Bool_t b=kTRUE) { b ? SetBit(kGuiActive) : ResetBit(kGuiActive); } 174 175 void SetPlainScreen(Bool_t b=kTRUE) { b ? SetBit(kPlainScreen) : ResetBit(kPlainScreen); Update(); } // *TOGGLE* 176 Bool_t IsPlainScreen() const { return TestBit(kPlainScreen); } 177 178 Double_t GetLimMag() const { return fLimMag; } 179 Double_t GetRadiusFOV() const { return fRadiusFOV; } 180 181 void Delete(Option_t *o="") { fList.Delete(); DeleteMap(); } 87 182 88 183 Int_t ReadXephem(TString catalog = "/usr/X11R6/lib/xephem/catalogs/YBS.edb"); … … 94 189 TList *GetList() { return &fList; } 95 190 96 virtual Bool_t Convert(const TRotation &rot, TVector2 &v, Int_t type); 97 virtual Bool_t PaintLine(const TVector2 &v0, Double_t dx, Double_t dy, const TRotation &rot, Int_t type); 191 void Draw(Option_t *o=""); 98 192 99 void Paint(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Byte_t type); 100 void PaintNet(const TVector2 &v0, const TRotation &rot, Int_t type=0); 101 void Paint(Option_t *o=""); 193 void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected); 102 194 103 ClassDef(MAstroCatalog, 0)195 ClassDef(MAstroCatalog, 1) 104 196 }; 105 197 #endif
Note:
See TracChangeset
for help on using the changeset viewer.