Changeset 912 for trunk/MagicSoft/Cosy/gui
- Timestamp:
- 08/17/01 15:12:57 (23 years ago)
- Location:
- trunk/MagicSoft/Cosy/gui
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r910 r912 12 12 #include <TApplication.h> // gApplication 13 13 14 #include "timer.h" // Timer14 //#include "timer.h" // Timer 15 15 16 16 #include "MCosy.h" 17 17 #include "MGList.h" 18 #include "MGAccuracy.h" 18 19 #include "MGCoordinates.h" 19 20 #include "MGSkyPosition.h" 20 21 21 #include "Sla lib.h"22 #include "SlaStars.h" 22 23 23 24 #define IDM_EXIT 1 … … 155 156 fList->Add(fCoord); 156 157 157 fSkyPosition = new MGSkyPosition(this); 158 fAccuracy = new MGAccuracy(this, 200, 200); 159 fAccuracy->Move(320, 260); 160 fList->Add(fAccuracy); 161 162 fSkyPosition = new MGSkyPosition(this, 200, 200); 158 163 fSkyPosition->Move(320, 40); 159 fSkyPosition->Resize(200, 200);160 164 fList->Add(fSkyPosition); 161 165 … … 163 167 // Map the window, set up the layout, etc. 164 168 // 165 SetWMSizeHints(550, 250, 550, 250, 10, 10); // set the smallest and biggest size of the Main frame169 SetWMSizeHints(550, 500, 550, 500, 10, 10); // set the smallest and biggest size of the Main frame 166 170 167 171 MapSubwindows(); … … 190 194 191 195 cout << "MGCosy deleted." << endl; 196 } 197 // ====================================================================== 198 void MGCosy::Update(ZdAz pos, ZdAz acc) 199 { 200 fSkyPosition->Update(pos); 201 fAccuracy->Update(acc); 192 202 } 193 203 // ====================================================================== … … 253 263 case kPB_CALCALTAZ: 254 264 { 255 Timer t; 256 t.GetTime(); 257 258 Slalib sla; 259 sla.Set(t.GetMjd()); 265 SlaStars sla; 266 sla.SetMjd2Now(); 260 267 261 268 XY xy = fCoord->GetCoordinates(); -
trunk/MagicSoft/Cosy/gui/MGCosy.h
r910 r912 16 16 #include <iostream.h> 17 17 18 #include "coord.h" 19 18 20 class TGLabel; 19 21 class TGPopupMenu; … … 27 29 class MGCoordinates; 28 30 class MGSkyPosition; 31 class MGAccuracy; 29 32 30 33 class MGCosy : public TGMainFrame … … 46 49 MGCoordinates *fCoord; 47 50 MGSkyPosition *fSkyPosition; 51 MGAccuracy *fAccuracy; 48 52 49 53 MsgQueue *fQueue; … … 63 67 TGLabel **GetLabel3() { return fLabel3; } 64 68 65 MGSkyPosition *GetSkyDisplay() { return fSkyPosition; }69 void Update(ZdAz pos, ZdAz acc); 66 70 67 71 Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2); -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
r911 r912 8 8 9 9 #include <iostream.h> // cout 10 #include <TRootEmbeddedCanvas.h> 11 #include <TGWindow.h> 10 12 11 #include <TArc.h> 12 #include <TLine.h> 13 #include <TList.h> 13 14 #include <TCanvas.h> 14 #include <TH1.h>15 #include <TLine.h>16 15 17 16 #include "coord.h" 18 19 MGSkyPosition::MGSkyPosition(const TGWindow* p) 20 : TRootEmbeddedCanvas("SkyPosition", p, 50, 50, kSunkenFrame)//, 0) //234, 76, kFixedSize) 17 #include "SlaPlanets.h" 18 19 void MGSkyPosition::InitPlanets() 20 { 21 // 22 // Magnitudes: 23 // ----------- 24 // Moon -12.8 25 // Jupiter -4.6 26 // Venus -4.0 27 // Mars -2.0 28 // Merkur 0.0 29 // Saturn 0.7 30 // Uranus 5.5 31 // Neptun 7.8 32 // 33 fSlalib = new SlaPlanets; 34 35 // 36 // Colors: black .. white: 37 // 38 // 1, 12, 13, 14, 15, 16, 17, 18, 19, 10 39 // 40 fMars = new TArc(0, 0, 1); 41 fMars->SetFillStyle(1001); // solid (s. TAttFill) 42 fMars->SetFillColor(13); // light grey (s. TAttFill) 43 fMars->SetLineColor(12); 44 fMars->Draw(); 45 46 fVenus = new TArc(0, 0, 2); 47 fVenus->SetFillStyle(1001); // solid (s. TAttFill) 48 fVenus->SetFillColor(15); // light grey (s. TAttFill) 49 fVenus->SetLineColor(14); 50 fVenus->Draw(); 51 52 fJupiter = new TArc(0, 0, 2); 53 fJupiter->SetFillStyle(1001); // solid (s. TAttFill) 54 fJupiter->SetFillColor(17); // light grey (s. TAttFill) 55 fJupiter->SetLineColor(16); 56 fJupiter->Draw(); 57 58 fMoon = new TArc(0, 0, 3, 290, 70); 59 fMoon->SetFillStyle(1001); // solid (s. TAttFill) 60 fMoon->SetFillColor(19); // light grey (s. TAttFill) 61 fMoon->SetLineColor(15); 62 fMoon->Draw(); 63 64 for (int i=0; i<4; i++) 65 { 66 fSunL[i] = new TLine(0,0,0,0); 67 fSunL[i]->SetLineColor(10); // white gray 68 fSunL[i]->SetLineStyle(1); // solid (s. TAttLine) 69 fSunL[i]->Draw(); 70 71 fList->Add(fSunL[i]); 72 } 73 74 fSun = new TArc(0, 0, 2); 75 fSun->SetFillStyle(1001); // solid (s. TAttFill) 76 fSun->SetFillColor(10); // white (s. TAttFill) 77 fSun->SetLineColor(19); 78 fSun->Draw(); 79 80 fList->Add(fMars); 81 fList->Add(fVenus); 82 fList->Add(fJupiter); 83 fList->Add(fMoon); 84 fList->Add(fSun); 85 86 // 87 // Reset 'static' positions of planets 88 // 89 for (int i=0; i<9; i++) 90 { 91 fX[i] = ~0; 92 fY[i] = ~0; 93 } 94 } 95 96 void MGSkyPosition::DrawCoordinateSystem() 97 { 98 TArc arc; 99 arc.SetFillStyle(4000); // transparent 100 arc.SetLineColor(13); // dark gray 101 arc.SetLineStyle(1); // solid (s. TAttLine) 102 arc.DrawArc(0, 0, 90); 103 arc.DrawArc(0, 0, 67.5); 104 arc.DrawArc(0, 0, 45); 105 arc.DrawArc(0, 0, 22.5); 106 107 TLine line; 108 line.SetLineColor(1); // black 109 line.SetLineStyle(1); // solid (s. TAttLine) 110 line.DrawLine(-95, 0, 95, 0); 111 line.DrawLine( 0, -95, 0, 95); 112 } 113 114 void MGSkyPosition::InitPosition() 115 { 116 fLin1a = new TLine(0, 0, 0, 0); 117 fLin1b = new TLine(0, 0, 0, 0); 118 fLin2 = new TLine(0, 0, 0, 0); 119 120 fLin1a->SetLineColor(5); // yellow (s. TAttFill) 121 fLin1b->SetLineColor(5); // yellow 122 fLin2 ->SetLineColor(10); // white 123 fLin1a->SetLineStyle(1); // solid (s. TAttLine) 124 fLin1b->SetLineStyle(2); // dashed 125 126 fLin1a->Draw(); 127 fLin1b->Draw(); 128 fLin2->Draw(); 129 130 fList->Add(fLin1a); 131 fList->Add(fLin1b); 132 fList->Add(fLin2); 133 } 134 135 MGSkyPosition::MGSkyPosition(const TGWindow* p, const Int_t w, const Int_t h) 136 : TRootEmbeddedCanvas("SkyPosition", p, w-1, h-1, kRaisedFrame),//, 0) //234, 76, kFixedSize) 137 fModified(kFALSE) 21 138 { 22 139 fCanvas = GetCanvas(); 23 140 141 fCanvas->SetFillColor(39); // s. TAttFill 24 142 fCanvas->Range(-100, -100, 100, 100); 25 143 26 fArc = new TArc; 27 fArc->SetLineColor(15); 28 fArc->DrawArc(0, 0, 90); 29 fArc->DrawArc(0, 0, 67.5); 30 fArc->DrawArc(0, 0, 45); 31 fArc->DrawArc(0, 0, 22.5); 32 33 fLin1 = new TLine; 34 fLin1->DrawLine(-95, 0, 95, 0); 35 fLin1->DrawLine( 0, -95, 0, 95); 36 fLin2 = new TLine; 37 38 // fCanvas->Modified(); 39 // fCanvas->Update(); 40 144 fList = new TList; 145 fList->SetOwner(); 146 147 DrawCoordinateSystem(); 148 InitPosition(); 149 InitPlanets(); 150 151 Resize(w, h); //GetDefaultSize()); // ??? 41 152 MapSubwindows(); 42 // MapWindow();43 44 // DrawPosition(66, 25);45 // DrawPosition(22, 278);46 153 } 47 154 48 155 MGSkyPosition::~MGSkyPosition() 49 156 { 50 delete fLin1; 51 delete fLin2; 52 delete fArc; 157 delete fList; 158 delete fSlalib; 53 159 54 160 cout << "MGSkyPosition destroyed." << endl; 161 } 162 163 void MGSkyPosition::SetLin1(int x, int y) 164 { 165 fLin1a->SetX2(x); 166 fLin1a->SetY2(y); 167 fLin1b->SetX2(-x); 168 fLin1b->SetY2(-y); 169 } 170 171 void MGSkyPosition::SetLin2(int x1, int y1, int x2, int y2) 172 { 173 fLin2->SetX1(x1); 174 fLin2->SetX2(x2); 175 fLin2->SetY1(y1); 176 fLin2->SetY2(y2); 55 177 } 56 178 … … 71 193 return; 72 194 73 const int dx = (int)(s*6); 74 const int dy = (int)(c*6); 75 76 delete fArc; 77 fArc = new TArc(x, y, 2); 78 fArc->SetFillStyle(1001); 79 fArc->SetFillColor(43); 80 fArc->Draw(); 81 82 delete fLin1; 83 delete fLin2; 84 //fLin1 = new TLine(x-dx, y-dy, x+dx, y+dy); 85 fLin1 = new TLine(0, 0, s*95, c*95); 86 fLin2 = new TLine(x+dy, y-dx, x-dy, y+dx); 87 fLin1->Draw(); 88 fLin2->Draw(); 89 195 X = x; 196 Y = y; 197 198 const int dx = (int)(s*4); 199 const int dy = (int)(c*4); 200 201 SetLin1(s*95, c*95); 202 SetLin2(x+dy, y-dx, x-dy, y+dx); 203 204 fModified = kTRUE; 205 } 206 207 void MGSkyPosition::Update(ZdAz &pos) 208 { 209 // 210 // calculate actual time for planet positions 211 // 212 fSlalib->SetMjd2Now(); 213 214 DrawPlanet(kESun, fSun); 215 DrawPlanet(kEMoon, fMoon); 216 DrawPlanet(kEJupiter, fJupiter); 217 DrawPlanet(kEVenus, fVenus); 218 DrawPlanet(kEMars, fMars); 219 220 DrawPosition(pos.Zd(), pos.Az()); 221 222 if (!fModified) 223 return; 224 225 // FIXME: Sometimes (if the canvas couldn't be created correctly: 226 // X11 Pixmap error) Update hangs the Gui system. 227 228 fCanvas->Modified(); 90 229 fCanvas->Update(); 91 } 92 93 void MGSkyPosition::DrawPosition(ZdAz &pos) 94 { 95 DrawPosition(pos.Zd(), pos.Az()); 96 } 230 231 fModified = kFALSE; 232 } 233 234 void MGSkyPosition::DrawPlanet(Int_t planet, TArc *arc) 235 { 236 // 237 // calculate actual position of planet 238 // 239 fSlalib->UpdatePlanetPos((ePlanets_t)planet); 240 241 ZdAz zdaz = fSlalib->GetPlanetPos((ePlanets_t)planet); 242 243 // 244 // check whether we have to change the position where it is drawn 245 // 246 const float s = sin(zdaz.Az()); 247 const float c = cos(zdaz.Az()); 248 249 const float deg = 360.0/D2PI*zdaz.Zd(); 250 251 const int x = (int)(s*deg); 252 const int y = (int)(c*deg); 253 254 if (fX[planet]==x && fY[planet]==y) 255 return; 256 257 fX[planet] = x; 258 fY[planet] = y; 259 260 // 261 // Set new position 262 // 263 arc->SetX1(x); 264 arc->SetY1(y); 265 266 fModified = kTRUE; 267 268 if (planet!=kESun) 269 return; 270 271 cout << "Sun: x=" << x << " y=" << y; 272 cout << " Zd=" << deg << " Az=" << 360./D2PI*zdaz.Az() << endl; 273 274 fSunL[0]->SetX1(x-4); fSunL[0]->SetX2(x+4); 275 fSunL[1]->SetX1(x-3); fSunL[1]->SetX2(x+3); 276 fSunL[2]->SetX1(x-3); fSunL[2]->SetX2(x+3); 277 fSunL[3]->SetX1(x ); fSunL[3]->SetX2(x ); 278 279 fSunL[0]->SetY1(y ); fSunL[0]->SetY2(y ); 280 fSunL[1]->SetY1(y-3); fSunL[1]->SetY2(y+3); 281 fSunL[2]->SetY1(y+3); fSunL[2]->SetY2(y-3); 282 fSunL[3]->SetY1(y-4); fSunL[3]->SetY2(y+4); 283 } -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.h
r911 r912 13 13 #endif 14 14 15 class TArc; 16 class TList; 17 class TLine; 15 18 class TCanvas; 16 class TArc; 17 class TLine; 19 18 20 class ZdAz; 21 class SlaPlanets; 19 22 20 23 class MGSkyPosition : public TRootEmbeddedCanvas 21 24 { 22 TCanvas *fCanvas;25 TCanvas *fCanvas; 23 26 24 TArc *fArc; 25 TLine *fLin1; 26 TLine *fLin2; 27 TArc *fMoon; 28 TArc *fJupiter; 29 TArc *fVenus; 30 TArc *fMars; 31 TArc *fSun; 32 33 TLine *fLin1a; 34 TLine *fLin1b; 35 TLine *fLin2; 36 37 TLine *fSunL[4]; 38 39 SlaPlanets *fSlalib; 40 41 TList *fList; 42 43 Int_t fX[9]; 44 Int_t fY[9]; 45 46 Bool_t fModified; 47 48 void InitPlanets(); 49 void InitPosition(); 50 51 void SetLin1(int x, int y); 52 void SetLin2(int x1, int y1, int x2, int y2); 53 54 void DrawPlanet(Int_t planet, TArc *arc); 55 void DrawPosition(Float_t zd, Float_t az); 56 void DrawCoordinateSystem(); 57 58 Bool_t CheckRange(Int_t x, Int_t y) const 59 { 60 return x>-95 && x<95 && y>-95 && y<95; 61 } 27 62 28 63 public: 29 MGSkyPosition(const TGWindow* p );64 MGSkyPosition(const TGWindow* p, const Int_t w, const Int_t h); 30 65 ~MGSkyPosition(); 31 66 32 void DrawPosition(Float_t zd, Float_t az); 33 void DrawPosition(ZdAz &pos); 67 void Update(ZdAz &pos); 34 68 }; 35 69 -
trunk/MagicSoft/Cosy/gui/Makefile
r910 r912 35 35 MGCosy.cc \ 36 36 MGImage.cc \ 37 MGAccuracy.cc \ 37 38 MGSkyPosition.cc 38 39
Note:
See TracChangeset
for help on using the changeset viewer.