Changeset 4058 for trunk/MagicSoft/Mars/mastro
- Timestamp:
- 05/12/04 20:22:24 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mastro
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mastro/MAstroCamera.cc
r3957 r4058 90 90 91 91 #include "../mhist/MHCamera.h" // FIXME: This dependancy is very bad! 92 92 // HOW TO GET RID OF IT? Move MHCamera to mgeom? 93 93 94 94 //#include "MStarLocalPos.h" … … 292 292 // 'c' Use the underlaying MHCamera as histogram 293 293 // '0' Draw the reflection on a virtual perfect mirror 294 // '=' Draw '0' or '*' propotional to the star magnitude 294 295 // 295 296 // If the Pad contains an object MHCamera of type MHCamera it is used. … … 312 313 const Bool_t hasdot = o.Contains(".", TString::kIgnoreCase); 313 314 const Bool_t usecam = o.Contains("c", TString::kIgnoreCase); 315 const Bool_t resize = o.Contains("=", TString::kIgnoreCase); 314 316 315 317 // Get camera … … 389 391 m->SetMarkerColor(kMagenta); 390 392 m->SetMarkerStyle(kDot); 391 AddMap(m);393 fMapG.Add(m); 392 394 } 393 395 if (h) … … 402 404 // transform meters into millimeters (camera display works with mm) 403 405 mean *= 1./num; 404 DrawStar(mean(0), mean(1), *radec, !hasmean, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)));406 DrawStar(mean(0), mean(1), *radec, hasmean?kBlack:-1, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)), resize); 405 407 406 408 if (hasnull) … … 409 411 star *= rot; 410 412 const TVector3 spot = fMirror0->GetReflection(star, fGeom->GetCameraDist())*1000; 411 DrawStar(spot(0), spot(1), *radec, !hasmean, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1))); 413 DrawStar(spot(0), spot(1), *radec, hasmean?kBlack:-1, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)), resize); 414 // This can be used to get the abberation... 412 415 //cout << TMath::Hypot(spot(0), spot(1)) << " " << TMath::Hypot(mean(0)-spot(0), mean(1)-spot(1)) << endl; 413 416 } … … 481 484 // x [mm]: x coordinate in the camera plane (assuming a perfect mirror) 482 485 // y [mm]: y coordinate in the camera plane (assuming a perfect mirror) 486 // 487 // We assume (0, 0) to be the center of the FOV 483 488 // 484 489 // dzd [deg]: Delta Zd -
trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc
r3710 r4058 128 128 129 129 #include "MTime.h" 130 //#include "MString.h" 130 131 #include "MAstro.h" 131 132 #include "MAstroSky2Local.h" … … 144 145 using namespace std; 145 146 147 void MVector3::WriteBinary(ostream &out) const 148 { 149 const Double_t t = Theta(); 150 const Double_t p = Phi(); 151 const Float_t m = Mag(); 152 out.write((char*)&t, 8); 153 out.write((char*)&p, 8); 154 out.write((char*)&m, 4); 155 out << fName << endl; 156 } 157 158 void MVector3::ReadBinary(istream &in) 159 { 160 Double_t t, p; 161 Float_t m; 162 163 in.read((char*)&t, 8); 164 in.read((char*)&p, 8); 165 in.read((char*)&m, 4); 166 fName.ReadLine(in); 167 168 SetMagThetaPhi(m, t, p); 169 } 170 146 171 // -------------------------------------------------------------------------- 147 172 // … … 153 178 { 154 179 fList.SetOwner(); 180 fMapG.SetOwner(); 155 181 fToolTip = new TGToolTip(0, "", 0); 156 182 } … … 179 205 fToolTip->Hide(); 180 206 delete fToolTip; 181 182 DeleteMap();183 207 } 184 208 … … 253 277 if (!fin) 254 278 { 255 gLog << err << "Cannot open file " << catalog << ": ";279 gLog << err << "Cannot open catalog file " << catalog << ": "; 256 280 gLog << strerror(errno) << endl; 257 281 return 0; … … 345 369 if (!fin) 346 370 { 347 gLog << err << "Cannot open file " << catalog << ": ";371 gLog << err << "Cannot open catalog file " << catalog << ": "; 348 372 gLog << strerror(errno) << endl; 349 373 return 0; … … 420 444 if (!fin) 421 445 { 422 gLog << err << "Cannot open file " << catalog << ": ";446 gLog << err << "Cannot open catalog file " << catalog << ": "; 423 447 gLog << strerror(errno) << endl; 424 448 return 0; … … 484 508 // -------------------------------------------------------------------------- 485 509 // 510 // Read from a ascii heasarc ppm catalog. set bit kHasChanged 511 // Already read data is not deleted. To delete the stored data call 512 // Delete(). 513 // If the second argument is given all survived stars are written 514 // to a file outname. This files will contain an apropriate compressed 515 // file format. You can read such files again using ReadCompressed. 516 // 517 Int_t MAstroCatalog::ReadHeasarcPPM(TString catalog, TString outname) 518 { 519 SetBit(kHasChanged); 520 521 gLog << inf << "Reading Heasarc PPM catalog: " << catalog << endl; 522 523 ifstream fin(catalog); 524 if (!fin) 525 { 526 gLog << err << "Cannot open catalog file " << catalog << ": "; 527 gLog << strerror(errno) << endl; 528 return 0; 529 } 530 531 ofstream *fout = outname.IsNull() ? 0 : new ofstream(outname); 532 if (fout && !*fout) 533 { 534 gLog << warn << "Cannot open output file " << outname << ": "; 535 gLog << strerror(errno) << endl; 536 delete fout; 537 fout = 0; 538 } 539 540 Int_t add=0; 541 Int_t cnt=0; 542 Int_t n =0; 543 544 Double_t maxmag=0; 545 546 while (1) 547 { 548 TString row; 549 row.ReadLine(fin); 550 if (!fin) 551 break; 552 553 cnt++; 554 555 if (!row.BeginsWith("PPM ")) 556 continue; 557 558 const TString name = row(0, row.First('|')); 559 row = row(row.First('|')+1, row.Length()); 560 row = row(row.First('|')+1, row.Length()); 561 562 const TString vmag = row(0, row.First('|')); 563 564 n++; 565 const Double_t mag = atof(vmag.Data()); 566 maxmag = TMath::Max(maxmag, mag); 567 if (mag>fLimMag) 568 continue; 569 570 row = row(row.First('|')+1, row.Length()); 571 row = row(row.First('|')+1, row.Length()); 572 573 row = row(row.First('|')+1, row.Length()); 574 row = row(row.First('|')+1, row.Length()); 575 576 row = row(row.First('|')+1, row.Length()); 577 row = row(row.First('|')+1, row.Length()); 578 579 const TString ra = row(0, row.First('|')); 580 row = row(row.First('|')+1, row.Length()); 581 const TString de = row(0, row.First('|')); 582 row = row(row.First('|')+1, row.Length()); 583 584 Char_t sgn; 585 Int_t d, m; 586 Float_t s; 587 if (sscanf(ra.Data(), "%d %d %f", &d, &m, &s)!=3) 588 { 589 // gLog << "Error loading entry in line " << i << endl; 590 continue; 591 } 592 const Double_t ra0 = MAstro::Hms2Rad(d, m, s); 593 594 if (sscanf(de.Data(), "%c%d %d %f", &sgn, &d, &m, &s)!=4) 595 { 596 // gLog << "Error loading entry in line " << i << endl; 597 continue; 598 } 599 const Double_t de0 = MAstro::Dms2Rad(d, m, s, sgn); 600 601 MVector3 *star=new MVector3; 602 star->SetRaDec(ra0, de0, mag); 603 star->SetName(name); 604 if (star->Angle(fRaDec)*TMath::RadToDeg()>fRadiusFOV) 605 { 606 delete star; 607 continue; 608 } 609 610 fList.Add(star); 611 add++; 612 613 if (fout) 614 star->WriteBinary(*fout); 615 } 616 617 gLog << inf << "Read " << add << " out of " << n << " (Total max mag=" << maxmag << ")" << endl; 618 619 return add; 620 } 621 622 // -------------------------------------------------------------------------- 623 // 624 // Read from a MAstroCatalog compressed catalog. set bit kHasChanged 625 // Already read data is not deleted. To delete the stored data call 626 // Delete(). 627 // 628 Int_t MAstroCatalog::ReadCompressed(TString catalog) 629 { 630 SetBit(kHasChanged); 631 632 gLog << inf << "Reading MAstroCatalog compressed catalog: " << catalog << endl; 633 634 ifstream fin(catalog); 635 if (!fin) 636 { 637 gLog << err << "Cannot open catalog file " << catalog << ": "; 638 gLog << strerror(errno) << endl; 639 return 0; 640 } 641 642 Int_t add=0; 643 Int_t cnt=0; 644 Int_t n =0; 645 646 Double_t maxmag=0; 647 648 MVector3 entry; 649 650 while (1) 651 { 652 cnt++; 653 654 entry.ReadBinary(fin); 655 if (!fin) 656 break; 657 658 n++; 659 660 const Double_t mag = entry.Magnitude(); 661 maxmag = TMath::Max(maxmag, mag); 662 if (mag>fLimMag) 663 continue; 664 665 if (entry.Angle(fRaDec)*TMath::RadToDeg()>fRadiusFOV) 666 continue; 667 668 fList.Add(entry.Clone()); 669 add++; 670 } 671 672 gLog << inf << "Read " << add << " out of " << n << " (Total max mag=" << maxmag << ")" << endl; 673 674 return add; 675 } 676 677 // -------------------------------------------------------------------------- 678 // 486 679 // Set Range of pad. If something has changed create and draw new primitives. 487 680 // Paint all gui primitives. … … 494 687 DrawPrimitives(o); 495 688 496 PaintMap(); 689 fMapG.Paint(); 690 } 691 692 // -------------------------------------------------------------------------- 693 // 694 // Set Range of pad if pad available. If something has changed create 695 // and draw new primitives. Paint all gui primitives to the Drawable with 696 // Id id. This can be used to be able to 697 // 698 /* 699 void MAstroCatalog::PaintImg(Int_t id, Option_t *o) 700 { 701 if (gPad) 702 SetRangePad(o); 703 704 if (TestBit(kHasChanged)) 705 { 706 if (id>0) 707 gPad=0; 708 DrawPrimitives(o); 709 } 710 711 fMapG.Paint(id, fRadiusFOV); 712 } 713 */ 714 715 // -------------------------------------------------------------------------- 716 // 717 // Set Range of pad. If something has changed create and draw new primitives. 718 // Paint all gui primitives. 719 // 720 // Because in some kind of multi-threaded environments gPad doesn't stay 721 // the same in a single thread (because it might be changed in the same 722 // thread inside a gui updating timer for example) we have to secure the 723 // usage of gPad with a bit. This is also not multi-thread safe against 724 // calling this function, but the function should work well in multi- 725 // threaded environments. Never call this function from different threads 726 // simultaneously. 727 // 728 void MAstroCatalog::PaintImg(unsigned char *buf, int w, int h) 729 { 730 const char * o = "local mirrorx yellow *"; 731 732 if (TestBit(kHasChanged)) 733 { 734 SetBit(kDrawingImage); 735 DrawPrimitives(o); 736 ResetBit(kDrawingImage); 737 } 738 739 fMapG.Paint(buf, w, h, fRadiusFOV); 497 740 } 498 741 … … 503 746 // x, y: Pad Coordinates to draw star 504 747 // v: Sky position (Ra/Dec) of the star 505 // transparent: Draw marker or tooltip only748 // col: Color of marker (<0 mean transparent) 506 749 // txt: additional tooltip text 507 // 508 void MAstroCatalog::DrawStar(Double_t x, Double_t y, const TVector3 &v, Bool_t transparent, const char *txt) 750 // resize: means resize the marker according to the magnitude 751 // 752 void MAstroCatalog::DrawStar(Double_t x, Double_t y, const TVector3 &v, Int_t col, const char *txt, Bool_t resize) 509 753 { 510 754 const Double_t ra = v.Phi()*TMath::RadToDeg()/15; 511 755 const Double_t dec = (TMath::Pi()/2-v.Theta())*TMath::RadToDeg(); 512 756 513 TString str = v.GetName(); 514 str += Form(": Ra=%.2fh", ra); 515 str += Form(" Dec=%.1fd", dec); 516 str += Form(" Mag=%.1f", -2.5*log10(v.Mag())); 757 const Double_t mag = -2.5*log10(v.Mag()); 758 759 //MString str; 760 //str.Print("%s: Ra=%.2fh Dec=%.1fd Mag=%.1f", v.GetName(), ra, dec, mag); 761 TString str(Form("%s: Ra=%.2fh Dec=%.1fd Mag=%.1f", v.GetName(), ra, dec, mag)); 517 762 if (txt) 518 str += Form(" (%s)", txt); 763 { 764 str += " ("; 765 str += txt; 766 str += ")"; 767 } 519 768 520 769 // draw star on the camera display 521 TMarker *tip=new TMarker(x, y, transparent ? kDot : kFullDotMedium);; 522 tip->SetMarkerColor(kBlack); 523 AddMap(tip, new TString(str)); 770 TMarker *tip=new TMarker(x, y, col<0 ? kDot : kFullDotMedium);; 771 tip->SetMarkerColor(col); 772 fMapG.Add(tip, new TString(str)); 773 774 if (!resize) 775 return; 776 777 tip->SetMarkerSize((10 - (mag>1 ? mag : 1))/15); 778 tip->SetMarkerStyle(kCircle); 524 779 } 525 780 … … 530 785 void MAstroCatalog::Update(Bool_t upd) 531 786 { 787 SetBit(kHasChanged); 532 788 if (gPad && TestBit(kMustCleanup)) 533 789 { 534 SetBit(kHasChanged);535 790 gPad->Modified(); 536 791 if (upd) … … 560 815 if (fObservatory) 561 816 delete fObservatory; 562 fObservatory=(MObservatory*)obs.Clone(); 817 fObservatory=new MObservatory; 818 obs.Copy(*fObservatory); 563 819 } 564 820 … … 588 844 return kERROR; 589 845 846 if (TestBit(kDrawingImage) || !gPad) 847 return v.Mod2()<fRadiusFOV*fRadiusFOV; 848 590 849 return v.X()>gPad->GetX1() && v.Y()>gPad->GetY1() && 591 850 v.X()<gPad->GetX2() && v.Y()<gPad->GetY2(); … … 612 871 // corresponding pad coordinates. 613 872 // 614 Bool_t MAstroCatalog::DrawLine(const TVector2 &v, Double_t dx, Double_t dy, const TRotation &rot, Int_t type)873 Bool_t MAstroCatalog::DrawLine(const TVector2 &v, Int_t dx, Int_t dy, const TRotation &rot, Int_t type) 615 874 { 616 875 const TVector2 add(dx*TMath::DegToRad(), dy*TMath::DegToRad()); 617 876 618 TVector2 v0 = v; 619 TVector2 v1 = v+add; 877 // Define all lines in the same direction 878 const TVector2 va(dy==1?v:v+add); 879 const TVector2 vb(dy==1?v+add:v); 880 881 TVector2 v0(va); 882 TVector2 v1(vb); 620 883 621 884 const Int_t rc0 = Convert(rot, v0); … … 629 892 line->SetLineStyle(kDashDotted); //kDashed, kDotted, kDashDotted 630 893 line->SetLineColor(kWhite+type*2); 631 AddMap(line); 632 633 const TVector2 deg = v*TMath::RadToDeg(); 634 TString txt = type==1 ? 635 Form("Ra=%.2fh Dec=%.1fd", fmod(deg.X()/15+48, 24), fmod(90-deg.Y()+270,180)-90) : 636 Form("Zd=%.1fd Az=%.1fd", fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360)); 894 fMapG.Add(line); 895 896 if (dx!=0) 897 return kTRUE; 898 899 const TVector2 deg = va*TMath::RadToDeg(); 900 /* 901 MString txt; 902 if (type==1) 903 txt.Print("Ra=%.2fh Dec=%.1fd", fmod(deg.X()/15+48, 24), fmod(90-deg.Y()+270,180)-90); 904 else 905 txt.Print("Zd=%.1fd Az=%.1fd", fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360)); 906 */ 907 TString txt; 908 if (type==1) 909 txt = Form("Ra=%.2fh Dec=%.1fd", fmod(deg.X()/15+48, 24), fmod(90-deg.Y()+270,180)-90); 910 else 911 txt = Form("Zd=%.1fd Az=%.1fd", fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360)); 637 912 638 913 TMarker *tip=new TMarker(v0.X(), v0.Y(), kDot); 639 914 tip->SetMarkerColor(kWhite+type*2); 640 AddMap(tip, new TString(txt));915 fMapG.Add(tip, new TString(txt)); 641 916 642 917 return kTRUE; … … 885 1160 // be more far away from the center than the display shows. 886 1161 // 1162 // If you want the stars to be displayed as circles with a size 1163 // showing their magnitude use "*" as an option. 1164 // 1165 // Use 'white' to display white instead of black stars 1166 // Use 'yellow' to display white instead of black stars 1167 // 887 1168 // 888 1169 void MAstroCatalog::AddPrimitives(TString o) … … 893 1174 const Bool_t miry = o.Contains("mirrory", TString::kIgnoreCase); 894 1175 const Bool_t mirror = o.Contains("mirror", TString::kIgnoreCase) && !mirx && !miry; 1176 const Bool_t size = o.Contains("*", TString::kIgnoreCase); 1177 const Bool_t white = o.Contains("white", TString::kIgnoreCase); 1178 const Bool_t yellow = o.Contains("yellow", TString::kIgnoreCase) && !white; 895 1179 896 1180 // X is vice versa, because ra is defined anti-clockwise … … 901 1185 902 1186 TIter Next(&fList); 903 TVector3 *v=0; 904 while ((v=(TVector3*)Next())) 905 { 906 // FIXME: Check Magnitude! 1187 MVector3 *v=0; 1188 while ((v=(MVector3*)Next())) 1189 { 1190 if (v->Magnitude()>fLimMag) 1191 continue; 1192 907 1193 TVector2 s(v->Phi(), v->Theta()); 908 1194 if (Convert(rot, s)==kTRUE) 909 DrawStar(s.X(), s.Y(), *v, kFALSE);910 } 911 912 if (!same )1195 DrawStar(s.X(), s.Y(), *v, yellow?kYellow:(white?kWhite:kBlack), 0, size); 1196 } 1197 1198 if (!same && !TestBit(kDrawingImage) && gPad) 913 1199 { 914 1200 TPaveText *pv = new TPaveText(0.01, 0.90, 0.63, 0.99, "brNDC"); 915 1201 pv->AddText(GetPadTitle()); 916 AddMap(pv);1202 fMapG.Add(pv); 917 1203 } 918 1204 919 1205 TMarker *mk=new TMarker(0, 0, kMultiply); 920 mk->SetMarkerColor( kBlack);1206 mk->SetMarkerColor(white||yellow?kWhite:kBlack); 921 1207 mk->SetMarkerSize(1.5); 922 AddMap(mk);1208 fMapG.Add(mk); 923 1209 } 924 1210 … … 935 1221 936 1222 const Double_t edge = fRadiusFOV/TMath::Sqrt(2.); 937 gPad->Range(-edge, -edge, edge, edge);1223 //gPad->Range(-edge, -edge, edge, edge); 938 1224 939 1225 const Float_t w = gPad->GetWw(); … … 956 1242 void MAstroCatalog::DrawPrimitives(Option_t *o) 957 1243 { 958 DeleteMap(); 959 960 SetRangePad(o); 1244 fMapG.Delete(); 1245 1246 if (!TestBit(kDrawingImage) && gPad) 1247 SetRangePad(o); 961 1248 962 1249 #ifdef DEBUG … … 971 1258 972 1259 // Append to a possible second pad 973 if (! gPad->GetListOfPrimitives()->FindObject(this))1260 if (!TestBit(kDrawingImage) && gPad && !gPad->GetListOfPrimitives()->FindObject(this)) 974 1261 AppendPad(o); 975 1262 976 1263 ResetBit(kHasChanged); 977 }978 979 // --------------------------------------------------------------------------980 //981 // Call Paint() of all gui elements982 //983 void MAstroCatalog::PaintMap()984 {985 Long_t key, val;986 TExMapIter map(&fMapG);987 while (map.Next(key, val))988 ((TObject*)key)->Paint();989 1264 } 990 1265 … … 1014 1289 // -------------------------------------------------------------------------- 1015 1290 // 1016 // Search for an object at px, py in fMapG. Return the pointer to it1017 // if found. Set str accordingly if a tooltip string is found.1018 //1019 TObject *MAstroCatalog::PickObject(Int_t px, Int_t py, TString &str) const1020 {1021 Long_t key, val;1022 TExMapIter map(&fMapG);1023 while (map.Next(key, val))1024 {1025 if (!val)1026 continue;1027 1028 TObject *o=(TObject*)key;1029 if (o->DistancetoPrimitive(px, py)>TPad::GetMaxPickDistance())1030 continue;1031 1032 str = *(TString*)val;1033 return o;1034 }1035 return NULL;1036 }1037 1038 // --------------------------------------------------------------------------1039 //1040 1291 // This function was connected to all created canvases. It is used 1041 1292 // to redirect GetObjectInfo into our own status bar. … … 1051 1302 if (!gPad) 1052 1303 return; 1304 1053 1305 1054 1306 // Try to find a corresponding object with kCannotPick set and … … 1056 1308 TString str; 1057 1309 if (!selected || selected==this) 1058 selected = PickObject(px, py, str);1310 selected = fMapG.PickObject(px, py, str); 1059 1311 1060 1312 if (!selected) … … 1137 1389 // -------------------------------------------------------------------------- 1138 1390 // 1139 // Calculate distance to primitive by checking all gui elements1140 //1141 Int_t MAstroCatalog::DistancetoPrimitive(Int_t px, Int_t py)1142 {1143 Int_t min = INT_MAX;1144 1145 Long_t key, val;1146 TExMapIter map(&fMapG);1147 while (map.Next(key, val))1148 {1149 TObject *o=(TObject*)key;1150 1151 const Int_t d = o->DistancetoPrimitive(px, py);1152 1153 if (d<TPad::GetMaxPickDistance())1154 return 0;1155 1156 if (d<min)1157 min=d;1158 }1159 1160 return min;1161 }1162 1163 // --------------------------------------------------------------------------1164 //1165 1391 // Displays a tooltip 1166 1392 // … … 1184 1410 } 1185 1411 1412 // -------------------------------------------------------------------------- 1413 // 1414 // Calculate distance to primitive by checking all gui elements 1415 // 1416 Int_t MAstroCatalog::DistancetoPrimitive(Int_t px, Int_t py) 1417 { 1418 return fMapG.DistancetoPrimitive(px, py); 1419 } 1420 1186 1421 // ------------------------------------------------------------------------ 1187 1422 // … … 1191 1426 char *MAstroCatalog::GetObjectInfo(Int_t px, Int_t py) const 1192 1427 { 1193 1194 TString str; 1195 PickObject(px, py, str); 1196 1197 static char txt[129]; 1198 txt[128]=0; 1199 1200 return strncpy(txt, str.Data(), 128); 1201 } 1202 1203 1204 /* 1205 void MAstroCatalog::RecursiveRemove(TObject *obj) 1206 { 1207 ULong_t hash; 1208 Long_t key, val; 1209 1210 TExMapIter map(&fMapG); 1211 while (map.Next(hash, key, val)) 1212 { 1213 if (key != (Long_t)obj) 1214 continue; 1215 1216 fMapG.Remove(hash, key); 1217 delete (TObject*)(key); 1218 if (val) 1219 delete (TString*)(val); 1220 break; 1221 } 1222 } 1223 */ 1428 return fMapG.GetObjectInfo(px, py); 1429 } -
trunk/MagicSoft/Mars/mastro/MAstroCatalog.h
r3959 r4058 5 5 #include <TVector3.h> 6 6 #endif 7 #ifndef ROOT_TExMap8 #include <TExMap.h>9 #endif10 7 #ifndef ROOT_TList 11 8 #include <TList.h> 9 #endif 10 #ifndef MARS_MGMap 11 #include <MGMap.h> 12 12 #endif 13 13 … … 57 57 const char *GetName() const { return fName; } 58 58 59 void WriteBinary(ostream &out) const; 60 void ReadBinary(istream &in); 61 59 62 ClassDef(MVector3, 1) // A specialized TVector3 storeing a star-name 60 63 }; … … 66 69 Double_t fRadiusFOV; // [deg] Radius of Field of View 67 70 68 TExMap fMapG; //! A map with all gui primitives and tooltips69 71 TGToolTip *fToolTip; //! The tooltip currently displayed 70 72 … … 80 82 //#if ROOT_VERSION_CODE < ROOT_VERSION(4,00,03) 81 83 Bool_t fPlainScreen; //! Just a dummy!!!! ([Set,Is]Freezed) 84 Bool_t fNoToolTips; //! Just a dummy!!!! ([Set,Is]Freezed) 82 85 //#endif 83 86 … … 86 89 virtual void SetRangePad(Option_t *o); 87 90 88 Int_t Convert(const TRotation &rot, TVector2 &v) const; 89 void Draw(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Int_t stepx, Int_t stepy, Int_t type); 90 void DrawPrimitives(Option_t *o); 91 Bool_t DrawLine(const TVector2 &v0, Double_t dx, Double_t dy, const TRotation &rot, Int_t type); 92 void DrawGrid(const TVector3 &v0, const TRotation &rot, Int_t type); 93 void Paint(Option_t *o=""); 94 Int_t DistancetoPrimitive(Int_t px, Int_t py); 95 //void RecursiveRemove(TObject *obj); 96 void PaintMap(); 97 void DeleteMap() 98 { 99 Long_t key, val; 100 TExMapIter map(&fMapG); 101 while (map.Next(key, val)) 102 { 103 delete (TObject*)(key); 104 if (!val) 105 continue; 106 107 delete (TString*)(val); 108 /* 109 Long_t key2, val2; 110 TExMapIter map2(&fMapG); 111 while (map2.Next(key2, val2)) 112 if (val==val2) 113 { 114 delete (TObject*)key; 115 fMapG.Remove(key); 116 } 117 */ 118 } 119 fMapG.Delete(); 120 } 91 Int_t Convert(const TRotation &rot, TVector2 &v) const; 92 void Draw(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Int_t stepx, Int_t stepy, Int_t type); 93 void DrawPrimitives(Option_t *o); 94 Bool_t DrawLine(const TVector2 &v0, Int_t dx, Int_t dy, const TRotation &rot, Int_t type); 95 void DrawGrid(const TVector3 &v0, const TRotation &rot, Int_t type); 96 void Paint(Option_t *o=""); 97 Int_t DistancetoPrimitive(Int_t px, Int_t py); 121 98 122 99 protected: 123 100 enum { 124 kHasChanged = BIT(15), // Display has changed 125 kGuiActive = BIT(16), // GUI is interactive 126 kPlainScreen = BIT(17), // View is a plain screen view 127 kMirrorX = BIT(18), // Mirror display in X 128 kMirrorY = BIT(19), // Mirror display in Y 129 kNoToolTips = BIT(20) // suppress tooltips 101 kHasChanged = BIT(15), // Display has changed 102 kGuiActive = BIT(16), // GUI is interactive 103 kPlainScreen = BIT(17), // View is a plain screen view 104 kMirrorX = BIT(18), // Mirror display in X 105 kMirrorY = BIT(19), // Mirror display in Y 106 kNoToolTips = BIT(20), // suppress tooltips 107 kDrawingImage = BIT(21) // just drawing into a bitmap 130 108 }; 131 109 132 TList fList; // List of stars loaded 133 MVector3 fRaDec; // pointing position 110 MGMap fMapG; //! A map with all gui primitives and tooltips 134 111 135 MObservatory *fObservatory; // Possible obervatory location 136 MTime *fTime; // Possible observation time 112 TList fList; // List of stars loaded 113 MVector3 fRaDec; // pointing position 114 115 MObservatory *fObservatory; // Possible obervatory location 116 MTime *fTime; // Possible observation time 137 117 138 118 TRotation AlignCoordinates(const TVector3 &v) const; 139 119 virtual TString GetPadTitle() const; 140 120 TRotation GetGrid(Bool_t local); 141 void DrawStar(Double_t x, Double_t y, const TVector3 &v, Bool_t t, const char *txt=0);121 void DrawStar(Double_t x, Double_t y, const TVector3 &v, Int_t col, const char *txt=0, Bool_t resize=kFALSE); 142 122 void Update(Bool_t upd=kFALSE); 143 123 144 124 void ExecuteEventKbd(Int_t keycode, Int_t keysym); 145 125 void ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2); 146 TObject *PickObject(Int_t px, Int_t py, TString &str) const;147 126 char *GetObjectInfo(Int_t px, Int_t py) const; 148 149 void AddMap(TObject *k, void *v=0)150 {151 fMapG.Add(fMapG.GetSize(), (Long_t)k, (Long_t)v);152 }153 127 154 128 public: … … 172 146 Update(); 173 147 } // *MENU* *ARGS={deg=>fRadiusFOV} 148 void SetRadiusFOV(Double_t pixsize, Double_t w, Double_t h) 149 { 150 // pixsize [arcsec/pixel] 151 // w [pixel] 152 // h [pixel] 153 const Double_t scale = TMath::Hypot(w, h)/2; 154 SetRadiusFOV(scale*pixsize/3600); 155 } // Set Radius of FOV using the pixsize [arcsec/pix], width and height [pixel] of image 156 174 157 void SetRaDec(Double_t ra, Double_t dec) { fRaDec.SetRaDec(ra, dec, 1); Update(); } 175 158 void SetRaDec(const TVector3 &v) { fRaDec=v; Update(); } … … 185 168 Double_t GetRadiusFOV() const { return fRadiusFOV; } // Get maximum radius of Field Of View 186 169 187 void Delete(Option_t *o="") { fList.Delete(); DeleteMap(); } // Delete list of stars170 void Delete(Option_t *o="") { fList.Delete(); fMapG.Delete(); } // Delete list of stars 188 171 189 172 Int_t ReadXephem(TString catalog = "/usr/X11R6/lib/xephem/catalogs/YBS.edb"); 190 173 Int_t ReadNGC2000(TString catalog = "ngc2000.dat"); 191 174 Int_t ReadBSC(TString catalog = "bsc5.dat"); 175 Int_t ReadHeasarcPPM(TString catalog = "heasarc_ppm.tdat", TString fout=""); 176 Int_t ReadCompressed(TString catalog); 192 177 193 178 void Print(Option_t *o="") const { fList.Print(); } // Print all stars … … 195 180 TList *GetList() { return &fList; } // Return list of stars 196 181 182 //void PaintImg(Int_t id=0, Option_t *o=""); 183 void PaintImg(unsigned char *buf, int w=768, int h=576); 197 184 void Draw(Option_t *o=""); 198 185 void SetDrawOption(Option_t *option="")
Note:
See TracChangeset
for help on using the changeset viewer.