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

Last change on this file since 3707 was 3704, 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
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)
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)
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)
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 ClassDef(MVector3, 1) // A specialized TVector3 storeing a star-name
60};
61
62class MAstroCatalog : public TObject
63{
64private:
65 Double_t fLimMag; // [1] Limiting Magnitude
66 Double_t fRadiusFOV; // [deg] Radius of Field of View
67
68 TExMap fMapG; //! A map with all gui primitives and tooltips
69 TGToolTip *fToolTip; //! The tooltip currently displayed
70
71 void ShowToolTip(Int_t px, Int_t py, const char *txt);
72
73 TString FindToken(TString &line, Char_t tok=',');
74
75 Int_t atoi(const TSubString &sub);
76 Float_t atof(const TSubString &sub);
77 Int_t atoi(const TString &s);
78 Float_t atof(const TString &s);
79
80//#if ROOT_VERSION_CODE < ROOT_VERSION(4,00,03)
81 Bool_t fPlainScreen; //! Just a dummy!!!! ([Set,Is]Freezed)
82//#endif
83
84 virtual Int_t ConvertToPad(const TVector3 &w, TVector2 &v) const;
85 virtual void AddPrimitives(TString o);
86 virtual void SetRangePad(Option_t *o);
87
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 TRotation AlignCoordinates(const TVector3 &v) const;
94 void Paint(Option_t *o="");
95 Int_t DistancetoPrimitive(Int_t px, Int_t py);
96 //void RecursiveRemove(TObject *obj);
97 void PaintMap();
98 void DeleteMap()
99 {
100 Long_t key, val;
101 TExMapIter map(&fMapG);
102 while (map.Next(key, val))
103 {
104 delete (TObject*)(key);
105 if (!val)
106 continue;
107
108 delete (TString*)(val);
109 /*
110 Long_t key2, val2;
111 TExMapIter map2(&fMapG);
112 while (map2.Next(key2, val2))
113 if (val==val2)
114 {
115 delete (TObject*)key;
116 fMapG.Remove(key);
117 }
118 */
119 }
120 fMapG.Delete();
121 }
122
123protected:
124 enum {
125 kHasChanged = BIT(15), // Display has changed
126 kGuiActive = BIT(16), // GUI is interactive
127 kPlainScreen = BIT(17), // View is a plain screen view
128 kMirrorX = BIT(18), // Mirror display in X
129 kMirrorY = BIT(19) // Mirror display in Y
130 };
131
132 TList fList; // List of stars loaded
133 MVector3 fRaDec; // pointing position
134
135 MObservatory *fObservatory; // Possible obervatory location
136 MTime *fTime; // Possible observation time
137
138 virtual TString GetPadTitle() const;
139 TRotation GetGrid(Bool_t local);
140 void DrawStar(Double_t x, Double_t y, const TVector3 &v, Bool_t t, const char *txt=0);
141 void Update(Bool_t upd=kFALSE);
142
143 void ExecuteEventKbd(Int_t keycode, Int_t keysym);
144 void ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2);
145
146 void AddMap(TObject *k, void *v=0)
147 {
148 fMapG.Add(fMapG.GetSize(), (Long_t)k, (Long_t)v);
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<1)
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* *GETTER=IsPlainScreen
176 Bool_t IsPlainScreen() const { return TestBit(kPlainScreen); }
177
178 Double_t GetLimMag() const { return fLimMag; } // Get Limiting Magnitude
179 Double_t GetRadiusFOV() const { return fRadiusFOV; } // Get maximum radius of Field Of View
180
181 void Delete(Option_t *o="") { fList.Delete(); DeleteMap(); } // Delete list of stars
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(); } // Print all stars
188
189 TList *GetList() { return &fList; } // Return list of stars
190
191 void Draw(Option_t *o="");
192 void SetDrawOption(Option_t *option="")
193 {
194 TObject::SetDrawOption(option);
195 Update(kTRUE);
196 } //*MENU*
197
198 virtual void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected=0);
199
200 ClassDef(MAstroCatalog, 1) // Display class for star catalogs
201};
202#endif
Note: See TracBrowser for help on using the repository browser.