source: trunk/Mars/mastro/MAstroCatalog.h@ 14906

Last change on this file since 14906 was 9292, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 6.8 KB
Line 
1#ifndef MARS_MAstroCatalog
2#define MARS_MAstroCatalog
3
4#ifndef MARS_MVector3
5#include "MVector3.h"
6#endif
7#ifndef ROOT_TList
8#include <TList.h>
9#endif
10#ifndef ROOT_TAttLine
11#include <TAttLine.h>
12#endif
13#ifndef ROOT_TAttMarker
14#include <TAttMarker.h>
15#endif
16#ifndef MARS_MGMap
17#include <MGMap.h>
18#endif
19
20class MTime;
21class MObservatory;
22class TArrayI;
23class TGToolTip;
24class TGraph;
25
26class MAttLine : public TObject, public TAttLine
27{
28public:
29 MAttLine() { }
30 ClassDef(MAttLine, 1) // Helper class to have a TAttLine derving from TObject (for standalone GED editor)
31};
32
33class MAstroCatalog : public TObject, public TAttMarker
34{
35private:
36 static const TString kDefaultPath; //! Datacenter default path for catalogs
37
38 Double_t fLimMag; // [1] Limiting Magnitude
39 Double_t fRadiusFOV; // [deg] Radius of Field of View
40
41 TGToolTip *fToolTip; //! The tooltip currently displayed
42 Double_t fAngle; //! Rotation angle of map
43
44 MAttLine fAttLineSky; // Line Style and color for sky coordinates
45 MAttLine fAttLineLocal; // Line Style and color for local coordinates
46
47 void ShowToolTip(Int_t px, Int_t py, const char *txt);
48 void SetLineAttributes(MAttLine &att);
49
50 TString FindToken(TString &line, Char_t tok=',');
51
52 Int_t atoi(const TString &s);
53 Float_t atof(const TString &s);
54
55//#if ROOT_VERSION_CODE < ROOT_VERSION(4,00,03)
56// Bool_t fPlainScreen; //! Just a dummy!!!! ([Set,Is]Freezed)
57// Bool_t fNoToolTips; //! Just a dummy!!!! ([Set,Is]Freezed)
58//#endif
59
60 virtual Int_t ConvertToPad(const TVector3 &w, TVector2 &v) const;
61 virtual void AddPrimitives(TString o);
62 virtual void SetRangePad(Option_t *o);
63
64 Int_t Convert(const TRotation &rot, TVector2 &v) const;
65 void Draw(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Int_t stepx, Int_t stepy, Int_t type);
66 void DrawPrimitives(Option_t *o);
67 Bool_t DrawLine(const TVector2 &v0, Int_t dx, Int_t dy, const TRotation &rot, Int_t type);
68 void DrawGrid(const TVector3 &v0, const TRotation &rot, Int_t type);
69 void Paint(Option_t *o="");
70 Int_t DistancetoPrimitive(Int_t px, Int_t py);
71
72protected:
73 enum {
74 kMark = BIT(14), // A mark for the sources in the list
75 kHasChanged = BIT(15), // Display has changed
76 kGuiActive = BIT(16), // GUI is interactive
77 kPlainScreen = BIT(17), // View is a plain screen view
78 kMirrorX = BIT(18), // Mirror display in X
79 kMirrorY = BIT(19), // Mirror display in Y
80 kNoToolTips = BIT(20), // suppress tooltips
81 kDrawingImage = BIT(21) // just drawing into a bitmap
82 };
83
84 MGMap fMapG; //! A map with all gui primitives and tooltips
85
86 TList fList; // List of stars loaded
87 MVector3 fRaDec; // pointing position
88
89 MObservatory *fObservatory; // Possible obervatory location
90 MTime *fTime; // Possible observation time
91
92 TRotation AlignCoordinates(const TVector3 &v) const;
93 virtual TString GetPadTitle() const;
94 TRotation GetGrid(Bool_t local);
95 void DrawStar(Double_t x, Double_t y, const TVector3 &v, Int_t col, const char *txt=0, Bool_t resize=kFALSE);
96 void Update(Bool_t upd=kFALSE);
97
98 void ExecuteEventKbd(Int_t keycode, Int_t keysym);
99 void ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2);
100 char *GetObjectInfo(Int_t px, Int_t py) const;
101
102public:
103 MAstroCatalog();
104 ~MAstroCatalog();
105
106 void ForceUpdate() { Update(kTRUE); } // Slot for marker handling
107
108 // Setter to control the sky position and behaviour
109 void SetTime(const MTime &time);
110 void SetObservatory(const MObservatory &obs);
111 void SetLimMag(Double_t mag) { fLimMag=mag; Update(); } // *MENU* *ARGS={mag=>fLimMag}
112
113 void SetRadiusFOV(Double_t pixsize, Double_t w, Double_t h);
114 void SetRadiusFOV(Double_t deg)
115 {
116 //const Double_t max = TestBit(kPlainScreen) ? 90 : 55;
117 const Double_t max = TestBit(kPlainScreen) ? 180 : 90;
118 if (deg>max)
119 deg=max;
120 if (deg<1)
121 deg=1;
122
123 fRadiusFOV=deg;
124
125 Update();
126 } // *MENU* *ARGS={deg=>fRadiusFOV}
127
128 void SetRaDec(Double_t ra, Double_t dec) { fRaDec.SetRaDec(ra, dec, 1); Update(); }
129 void SetRaDec(const TVector3 &v) { fRaDec=v; Update(); }
130 void SetGuiActive(Bool_t b=kTRUE) { b ? SetBit(kGuiActive) : ResetBit(kGuiActive); }
131
132 void SetPlainScreen(Bool_t b=kTRUE) { b ? SetBit(kPlainScreen) : ResetBit(kPlainScreen); Update(); } // *TOGGLE* *GETTER=IsPlainScreen
133 Bool_t IsPlainScreen() const { return TestBit(kPlainScreen); }
134
135 void SetNoToolTips(Bool_t b=kTRUE) { b ? SetBit(kNoToolTips) : ResetBit(kNoToolTips); } // *TOGGLE* *GETTER=HasNoToolTips
136 Bool_t HasNoToolTips() const { return TestBit(kNoToolTips); }
137
138 Double_t GetLimMag() const { return fLimMag; } // Get Limiting Magnitude
139 Double_t GetRadiusFOV() const { return fRadiusFOV; } // Get maximum radius of Field Of View
140
141 // Interface to set stars
142 Int_t ReadXephem(TString catalog = "/usr/X11R6/lib/xephem/catalogs/YBS.edb");
143 Int_t ReadNGC2000(TString catalog = "ngc2000.dat");
144 Int_t ReadBSC(TString catalog = "bsc5.dat");
145 Int_t ReadHeasarcPPM(TString catalog = "heasarc_ppm.tdat", TString fout="");
146 Int_t ReadCompressed(TString catalog);
147 Bool_t AddObject(Float_t ra, Float_t dec, Float_t mag, TString name="");
148
149 // Interface to get stars
150 TList *GetList() { return &fList; } // Return list of stars
151 UInt_t GetNumStars() const { return fList.GetEntries(); }
152 TObject *FindObject(const char *name) const { return fList.FindObject(name); }
153 TObject *FindObject(const TObject *obj) const { return fList.FindObject(obj); }
154 void MarkObject(const char *name) const { TObject *o=FindObject(name); if (o) o->SetBit(kMark); }
155
156 void GetVisibilityCurve(TGraph &g, const char *name=0) const;
157
158 // TObject
159 void Delete(Option_t *o="") { fList.Delete(); fMapG.Delete(); } // Delete list of stars
160 void Print(Option_t *o="") const { fList.Print(); } // Print all stars
161 void Draw(Option_t *o="");
162 void SetDrawOption(Option_t *option="")
163 {
164 TObject::SetDrawOption(option);
165 Update(kTRUE);
166 } //*MENU*
167
168 // Interface to Cosy
169 void PaintImg(unsigned char *buf, int w=768, int h=576, Option_t *o=0);
170
171 // Interface to line styles
172 void SetLineAttributesLocal() { SetLineAttributes(fAttLineLocal); } //*MENU*
173 void SetLineAttributesSky() { SetLineAttributes(fAttLineSky); } //*MENU*
174 void SetMarkerAttributes(); //*MENU*
175
176 TAttLine &GetAttLineSky() { return fAttLineSky; }
177 TAttLine &GetAttLineLocal() { return fAttLineLocal; }
178
179 virtual void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected=0);
180
181 ClassDef(MAstroCatalog, 2) // Display class for star catalogs
182};
183
184#endif
Note: See TracBrowser for help on using the repository browser.