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

Last change on this file since 3797 was 3710, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 6.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 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 kNoToolTips = BIT(20) // suppress tooltips
131 };
132
133 TList fList; // List of stars loaded
134 MVector3 fRaDec; // pointing position
135
136 MObservatory *fObservatory; // Possible obervatory location
137 MTime *fTime; // Possible observation time
138
139 virtual TString GetPadTitle() const;
140 TRotation GetGrid(Bool_t local);
141 void DrawStar(Double_t x, Double_t y, const TVector3 &v, Bool_t t, const char *txt=0);
142 void Update(Bool_t upd=kFALSE);
143
144 void ExecuteEventKbd(Int_t keycode, Int_t keysym);
145 void ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2);
146 TObject *PickObject(Int_t px, Int_t py, TString &str) const;
147 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
154public:
155 MAstroCatalog();
156 ~MAstroCatalog();
157
158 void SetTime(const MTime &time);
159 void SetObservatory(const MObservatory &obs);
160 void SetLimMag(Double_t mag) { fLimMag=mag; Update(); } // *MENU* *ARGS={mag=>fLimMag}
161 void SetRadiusFOV(Double_t deg)
162 {
163 //const Double_t max = TestBit(kPlainScreen) ? 90 : 55;
164 const Double_t max = TestBit(kPlainScreen) ? 180 : 90;
165 if (deg>max)
166 deg=max;
167 if (deg<1)
168 deg=1;
169
170 fRadiusFOV=deg;
171
172 Update();
173 } // *MENU* *ARGS={deg=>fRadiusFOV}
174 void SetRaDec(Double_t ra, Double_t dec) { fRaDec.SetRaDec(ra, dec, 1); Update(); }
175 void SetRaDec(const TVector3 &v) { fRaDec=v; Update(); }
176 void SetGuiActive(Bool_t b=kTRUE) { b ? SetBit(kGuiActive) : ResetBit(kGuiActive); }
177
178 void SetPlainScreen(Bool_t b=kTRUE) { b ? SetBit(kPlainScreen) : ResetBit(kPlainScreen); Update(); } // *TOGGLE* *GETTER=IsPlainScreen
179 Bool_t IsPlainScreen() const { return TestBit(kPlainScreen); }
180
181 void SetNoToolTips(Bool_t b=kTRUE) { b ? SetBit(kNoToolTips) : ResetBit(kNoToolTips); } // *TOGGLE* *GETTER=HasNoToolTips
182 Bool_t HasNoToolTips() const { return TestBit(kNoToolTips); }
183
184 Double_t GetLimMag() const { return fLimMag; } // Get Limiting Magnitude
185 Double_t GetRadiusFOV() const { return fRadiusFOV; } // Get maximum radius of Field Of View
186
187 void Delete(Option_t *o="") { fList.Delete(); DeleteMap(); } // Delete list of stars
188
189 Int_t ReadXephem(TString catalog = "/usr/X11R6/lib/xephem/catalogs/YBS.edb");
190 Int_t ReadNGC2000(TString catalog = "ngc2000.dat");
191 Int_t ReadBSC(TString catalog = "bsc5.dat");
192
193 void Print(Option_t *o="") const { fList.Print(); } // Print all stars
194
195 TList *GetList() { return &fList; } // Return list of stars
196
197 void Draw(Option_t *o="");
198 void SetDrawOption(Option_t *option="")
199 {
200 TObject::SetDrawOption(option);
201 Update(kTRUE);
202 } //*MENU*
203
204 virtual void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected=0);
205
206 ClassDef(MAstroCatalog, 1) // Display class for star catalogs
207};
208#endif
Note: See TracBrowser for help on using the repository browser.