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

Last change on this file since 3478 was 3457, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.6 KB
Line 
1#ifndef MARS_MAstroCatalog
2#define MARS_MAstroCatalog
3
4#ifndef ROOT_TVector3
5#include <TVector3.h>
6#endif
7#ifndef ROOT_TExMap
8#include <TExMap.h>
9#endif
10#ifndef ROOT_TList
11#include <TList.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 /*
37 MVector3(Double_t theta=0, Double_t phi=0, Double_t mag=1)
38 {
39 SetMagThetaPhi(exp(mag), theta, phi);
40 }*/
41 MVector3() { fType=kIsInvalid; }
42 MVector3(const TVector3 &v3) : TVector3(v3) { fType=kIsArbitrary; }
43 Double_t Magnitude() const { return -2.5*TMath::Log10(Mag()); }
44
45 void SetRaDec(Double_t ra, Double_t dec, Double_t mag)
46 {
47 fType = kIsRaDec;
48 SetMagThetaPhi(pow(10, -mag/2.5), TMath::Pi()/2-dec, ra);
49 }
50 void SetName(const TString &str) { fName = str.Strip(TString::kBoth); }
51 void SetZdAz(Double_t zd, Double_t az, Double_t mag)
52 {
53 fType = kIsZdAz;
54 SetMagThetaPhi(pow(10, -mag/2.5), zd, az);
55 }
56 void SetAltAz(Double_t alt, Double_t az, Double_t mag)
57 {
58 fType = kIsAltAz;
59 SetMagThetaPhi(pow(10, -mag/2.5), TMath::Pi()/2-alt, az);
60 }
61
62 const char *GetName() const { return fName; }
63
64 MVector3 GetZdAz(const MObservatory &obs, Double_t gmst) const;
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;
68
69 ClassDef(MVector3, 1)
70};
71
72class MAstroCatalog : public TObject
73{
74private:
75 Double_t fLimMag; // [1] Limiting Magnitude
76 Double_t fRadiusFOV; // [deg] Radius of Field of View
77
78 TGToolTip *fToolTip; //!
79
80 void ShowToolTip(Int_t px, Int_t py, const char *txt);
81
82 TString FindToken(TString &line, Char_t tok=',');
83
84 Int_t atoi(const TSubString &sub);
85 Float_t atof(const TSubString &sub);
86 Int_t atoi(const TString &s);
87 Float_t atof(const TString &s);
88
89 Bool_t fPlainScreen; //! Just a dummy!!!! ([Set,Is]Freezed)
90
91protected:
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()
121 {
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();
149 }
150
151public:
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(); }
182
183 Int_t ReadXephem(TString catalog = "/usr/X11R6/lib/xephem/catalogs/YBS.edb");
184 Int_t ReadNGC2000(TString catalog = "ngc2000.dat");
185 Int_t ReadBSC(TString catalog = "bsc5.dat");
186
187 void Print(Option_t *o="") const { fList.Print(); }
188
189 TList *GetList() { return &fList; }
190
191 void Draw(Option_t *o="");
192
193 void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
194
195 ClassDef(MAstroCatalog, 1)
196};
197#endif
Note: See TracBrowser for help on using the repository browser.