source: trunk/MagicSoft/Mars/mastro/MAstroCatalog.h@ 4875

Last change on this file since 4875 was 4817, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 6.7 KB
Line 
1#ifndef MARS_MAstroCatalog
2#define MARS_MAstroCatalog
3
4#ifndef ROOT_TVector3
5#include <TVector3.h>
6#endif
7#ifndef ROOT_TList
8#include <TList.h>
9#endif
10#ifndef MARS_MGMap
11#include <MGMap.h>
12#endif
13
14class MTime;
15class MObservatory;
16class TArrayI;
17class TGToolTip;
18
19class MVector3 : public TVector3
20{
21private:
22 enum VectorType_t
23 {
24 kIsInvalid,
25 kIsRaDec,
26 kIsZdAz,
27 kIsAltAz,
28 kIsArbitrary
29 };
30
31 VectorType_t fType;
32
33 TString fName;
34
35public:
36 MVector3() { fType=kIsInvalid; }
37 MVector3(const TVector3 &v3) : TVector3(v3) { fType=kIsArbitrary; }
38 Double_t Magnitude() const { return -2.5*TMath::Log10(Mag()); }
39
40 void SetRaDec(Double_t ra, Double_t dec, Double_t mag=0)
41 {
42 fType = kIsRaDec;
43 SetMagThetaPhi(pow(10, -mag/2.5), TMath::Pi()/2-dec, ra);
44 }
45 void SetName(const TString &str) { fName = str.Strip(TString::kBoth); }
46 void SetZdAz(Double_t zd, Double_t az, Double_t mag=0)
47 {
48 fType = kIsZdAz;
49 SetMagThetaPhi(pow(10, -mag/2.5), zd, az);
50 }
51 void SetAltAz(Double_t alt, Double_t az, Double_t mag=0)
52 {
53 fType = kIsAltAz;
54 SetMagThetaPhi(pow(10, -mag/2.5), TMath::Pi()/2-alt, az);
55 }
56
57 const char *GetName() const { return fName; }
58
59 void WriteBinary(ostream &out) const;
60 void ReadBinary(istream &in);
61
62 ClassDef(MVector3, 1) // A specialized TVector3 storing a star-name
63};
64
65class MAstroCatalog : public TObject
66{
67private:
68 Double_t fLimMag; // [1] Limiting Magnitude
69 Double_t fRadiusFOV; // [deg] Radius of Field of View
70
71 TGToolTip *fToolTip; //! The tooltip currently displayed
72
73 void ShowToolTip(Int_t px, Int_t py, const char *txt);
74
75 TString FindToken(TString &line, Char_t tok=',');
76
77 Int_t atoi(const TSubString &sub);
78 Float_t atof(const TSubString &sub);
79 Int_t atoi(const TString &s);
80 Float_t atof(const TString &s);
81
82//#if ROOT_VERSION_CODE < ROOT_VERSION(4,00,03)
83 Bool_t fPlainScreen; //! Just a dummy!!!! ([Set,Is]Freezed)
84 Bool_t fNoToolTips; //! Just a dummy!!!! ([Set,Is]Freezed)
85//#endif
86
87 virtual Int_t ConvertToPad(const TVector3 &w, TVector2 &v) const;
88 virtual void AddPrimitives(TString o);
89 virtual void SetRangePad(Option_t *o);
90
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);
98
99protected:
100 enum {
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
108 };
109
110 MGMap fMapG; //! A map with all gui primitives and tooltips
111
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
117
118 TRotation AlignCoordinates(const TVector3 &v) const;
119 virtual TString GetPadTitle() const;
120 TRotation GetGrid(Bool_t local);
121 void DrawStar(Double_t x, Double_t y, const TVector3 &v, Int_t col, const char *txt=0, Bool_t resize=kFALSE);
122 void Update(Bool_t upd=kFALSE);
123
124 void ExecuteEventKbd(Int_t keycode, Int_t keysym);
125 void ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2);
126 char *GetObjectInfo(Int_t px, Int_t py) const;
127
128public:
129 MAstroCatalog();
130 ~MAstroCatalog();
131
132 void SetTime(const MTime &time);
133 void SetObservatory(const MObservatory &obs);
134 void SetLimMag(Double_t mag) { fLimMag=mag; Update(); } // *MENU* *ARGS={mag=>fLimMag}
135 void SetRadiusFOV(Double_t deg)
136 {
137 //const Double_t max = TestBit(kPlainScreen) ? 90 : 55;
138 const Double_t max = TestBit(kPlainScreen) ? 180 : 90;
139 if (deg>max)
140 deg=max;
141 if (deg<1)
142 deg=1;
143
144 fRadiusFOV=deg;
145
146 Update();
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
157 void SetRaDec(Double_t ra, Double_t dec) { fRaDec.SetRaDec(ra, dec, 1); Update(); }
158 void SetRaDec(const TVector3 &v) { fRaDec=v; Update(); }
159 void SetGuiActive(Bool_t b=kTRUE) { b ? SetBit(kGuiActive) : ResetBit(kGuiActive); }
160
161 void SetPlainScreen(Bool_t b=kTRUE) { b ? SetBit(kPlainScreen) : ResetBit(kPlainScreen); Update(); } // *TOGGLE* *GETTER=IsPlainScreen
162 Bool_t IsPlainScreen() const { return TestBit(kPlainScreen); }
163
164 void SetNoToolTips(Bool_t b=kTRUE) { b ? SetBit(kNoToolTips) : ResetBit(kNoToolTips); } // *TOGGLE* *GETTER=HasNoToolTips
165 Bool_t HasNoToolTips() const { return TestBit(kNoToolTips); }
166
167 Double_t GetLimMag() const { return fLimMag; } // Get Limiting Magnitude
168 Double_t GetRadiusFOV() const { return fRadiusFOV; } // Get maximum radius of Field Of View
169
170 void Delete(Option_t *o="") { fList.Delete(); fMapG.Delete(); } // Delete list of stars
171
172 Int_t ReadXephem(TString catalog = "/usr/X11R6/lib/xephem/catalogs/YBS.edb");
173 Int_t ReadNGC2000(TString catalog = "ngc2000.dat");
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);
177 Bool_t AddObject(Float_t ra, Float_t dec, Float_t mag, TString name="");
178
179 void Print(Option_t *o="") const { fList.Print(); } // Print all stars
180
181 TList *GetList() { return &fList; } // Return list of stars
182
183 //void PaintImg(Int_t id=0, Option_t *o="");
184 void PaintImg(unsigned char *buf, int w=768, int h=576, Option_t *o=0);
185 void Draw(Option_t *o="");
186 void SetDrawOption(Option_t *option="")
187 {
188 TObject::SetDrawOption(option);
189 Update(kTRUE);
190 } //*MENU*
191
192 virtual void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected=0);
193
194 ClassDef(MAstroCatalog, 1) // Display class for star catalogs
195};
196
197#endif
Note: See TracBrowser for help on using the repository browser.