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

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