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

Last change on this file since 3622 was 3568, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 6.2 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
35
36public:
37 /*
38 MVector3(Double_t theta=0, Double_t phi=0, Double_t mag=1)
39 {
40 SetMagThetaPhi(exp(mag), theta, phi);
41 }*/
42 MVector3() { fType=kIsInvalid; }
43 MVector3(const TVector3 &v3) : TVector3(v3) { fType=kIsArbitrary; }
44 Double_t Magnitude() const { return -2.5*TMath::Log10(Mag()); }
45
46 void SetRaDec(Double_t ra, Double_t dec, Double_t mag)
47 {
48 fType = kIsRaDec;
49 SetMagThetaPhi(pow(10, -mag/2.5), TMath::Pi()/2-dec, ra);
50 }
51 void SetName(const TString &str) { fName = str.Strip(TString::kBoth); }
52 void SetZdAz(Double_t zd, Double_t az, Double_t mag)
53 {
54 fType = kIsZdAz;
55 SetMagThetaPhi(pow(10, -mag/2.5), zd, az);
56 }
57 void SetAltAz(Double_t alt, Double_t az, Double_t mag)
58 {
59 fType = kIsAltAz;
60 SetMagThetaPhi(pow(10, -mag/2.5), TMath::Pi()/2-alt, az);
61 }
62
63 const char *GetName() const { return fName; }
64/*
65 MVector3 GetZdAz(const MObservatory &obs, Double_t gmst) const;
66 MVector3 GetZdAz(const MTime &time, MObservatory &obs) const;
67 MVector3 GetRaDec(const MObservatory &obs, Double_t gmst) const;
68 MVector3 GetRaDec(const MTime &time, MObservatory &obs) const;
69 */
70 ClassDef(MVector3, 1)
71};
72
73class MAstroCatalog : public TObject
74{
75private:
76 Double_t fLimMag; // [1] Limiting Magnitude
77 Double_t fRadiusFOV; // [deg] Radius of Field of View
78
79 TExMap fMapG; //! A map with all gui primitives and tooltips
80 TGToolTip *fToolTip; //! The tooltip currently displayed
81
82 void ShowToolTip(Int_t px, Int_t py, const char *txt);
83
84 TString FindToken(TString &line, Char_t tok=',');
85
86 Int_t atoi(const TSubString &sub);
87 Float_t atof(const TSubString &sub);
88 Int_t atoi(const TString &s);
89 Float_t atof(const TString &s);
90
91//#if ROOT_VERSION_CODE < ROOT_VERSION(4,00,03)
92 Bool_t fPlainScreen; //! Just a dummy!!!! ([Set,Is]Freezed)
93//#endif
94
95 virtual Int_t ConvertToPad(const TVector3 &w, TVector2 &v) const;
96 virtual void AddPrimitives(Option_t *o);
97 virtual void SetRangePad();
98
99 Int_t Convert(const TRotation &rot, TVector2 &v) const;
100 void Draw(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Int_t stepx, Int_t stepy, Int_t type);
101 void DrawPrimitives(Option_t *o);
102 Bool_t DrawLine(const TVector2 &v0, Double_t dx, Double_t dy, const TRotation &rot, Int_t type);
103 void DrawGrid(const TVector3 &v0, const TRotation &rot, Int_t type);
104 TRotation AlignCoordinates(const TVector3 &v) const;
105 void Paint(Option_t *o="");
106 Int_t DistancetoPrimitive(Int_t px, Int_t py);
107 void DrawMap();
108 void DeleteMap()
109 {
110 Long_t key, val;
111 TExMapIter map(&fMapG);
112 while (map.Next(key, val))
113 {
114 delete (TObject*)(key);
115 if (!val)
116 continue;
117
118 delete (TString*)(val);
119 /*
120 Long_t key2, val2;
121 TExMapIter map2(&fMapG);
122 while (map2.Next(key2, val2))
123 if (val==val2)
124 {
125 delete (TObject*)key;
126 fMapG.Remove(key);
127 }*/
128 }
129 fMapG.Delete();
130 }
131
132protected:
133 enum {
134 kHasChanged = BIT(15),
135 kGuiActive = BIT(16),
136 kPlainScreen = BIT(17)
137 };
138
139 TList fList; // List of stars loaded
140 MVector3 fRaDec; // pointing position
141
142 MObservatory *fObservatory; // Possible obervatora location
143 MTime *fTime; // Possible observation time
144
145 virtual TString GetPadTitle() const;
146 TRotation GetGrid(Bool_t local);
147 void DrawStar(Double_t x, Double_t y, const TVector3 &v, Bool_t t, const char *txt=0);
148 void Update(Bool_t upd=kFALSE);
149
150 void ExecuteEventKbd(Int_t keycode, Int_t keysym);
151 void ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2);
152
153 void AddMap(TObject *k, void *v=0)
154 {
155 k->SetBit(kCanDelete);
156 k->SetBit(kCannotPick);
157 fMapG.Add(fMapG.GetSize(), (Long_t)k, (Long_t)v);
158 }
159
160public:
161 MAstroCatalog();
162 ~MAstroCatalog();
163
164 void SetTime(const MTime &time);
165 void SetObservatory(const MObservatory &obs);
166 void SetLimMag(Double_t mag) { fLimMag=mag; Update(); } // *MENU* *ARGS={mag=>fLimMag}
167 void SetRadiusFOV(Double_t deg)
168 {
169 //const Double_t max = TestBit(kPlainScreen) ? 90 : 55;
170 const Double_t max = TestBit(kPlainScreen) ? 180 : 90;
171 if (deg>max)
172 deg=max;
173 if (deg<1)
174 deg=1;
175
176 fRadiusFOV=deg;
177
178 Update();
179 } // *MENU* *ARGS={deg=>fRadiusFOV}
180 void SetRaDec(Double_t ra, Double_t dec) { fRaDec.SetRaDec(ra, dec, 1); Update(); }
181 void SetRaDec(const TVector3 &v) { fRaDec=v; Update(); }
182 void SetGuiActive(Bool_t b=kTRUE) { b ? SetBit(kGuiActive) : ResetBit(kGuiActive); }
183
184 void SetPlainScreen(Bool_t b=kTRUE) { b ? SetBit(kPlainScreen) : ResetBit(kPlainScreen); Update(); } // *TOGGLE* *GETTER=IsPlainScreen
185 Bool_t IsPlainScreen() const { return TestBit(kPlainScreen); }
186
187 Double_t GetLimMag() const { return fLimMag; }
188 Double_t GetRadiusFOV() const { return fRadiusFOV; }
189
190 void Delete(Option_t *o="") { fList.Delete(); DeleteMap(); }
191
192 Int_t ReadXephem(TString catalog = "/usr/X11R6/lib/xephem/catalogs/YBS.edb");
193 Int_t ReadNGC2000(TString catalog = "ngc2000.dat");
194 Int_t ReadBSC(TString catalog = "bsc5.dat");
195
196 void Print(Option_t *o="") const { fList.Print(); }
197
198 TList *GetList() { return &fList; }
199
200 void Draw(Option_t *o="");
201 void SetDrawOption(Option_t *option="")
202 {
203 TObject::SetDrawOption(option);
204 Update(kTRUE);
205 } //*MENU*
206
207 virtual void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected=0);
208
209 ClassDef(MAstroCatalog, 1)
210};
211#endif
Note: See TracBrowser for help on using the repository browser.