| 1 | #include "MGCosy.h"
|
|---|
| 2 |
|
|---|
| 3 | #include <iostream.h>
|
|---|
| 4 |
|
|---|
| 5 | #include "msgqueue.h"
|
|---|
| 6 |
|
|---|
| 7 | #include <TROOT.h>
|
|---|
| 8 |
|
|---|
| 9 | #include <TGTab.h> // TGTab
|
|---|
| 10 | #include <TGMenu.h> // TGPopupMenu
|
|---|
| 11 | #include <TGButton.h> // TGButton
|
|---|
| 12 | #include <TSystem.h> // gSystem
|
|---|
| 13 | #include <TGLabel.h> // TGLabel
|
|---|
| 14 | #include <TGListBox.h> // TGListBox
|
|---|
| 15 | #include <TG3DLine.h> // TGHorizontal3DLine (TGSplitter)
|
|---|
| 16 | #include <TGFrame.h> // TGGroupFrame
|
|---|
| 17 | #include <TApplication.h> // gApplication
|
|---|
| 18 |
|
|---|
| 19 | //#include "timer.h" // Timer
|
|---|
| 20 |
|
|---|
| 21 | #include "MCosy.h"
|
|---|
| 22 | #include "MGList.h"
|
|---|
| 23 | #include "MGAccuracy.h"
|
|---|
| 24 | #include "MGCoordinates.h"
|
|---|
| 25 | #include "MGSkyPosition.h"
|
|---|
| 26 | #include "MGVelocity.h"
|
|---|
| 27 |
|
|---|
| 28 | #include "SlaStars.h"
|
|---|
| 29 |
|
|---|
| 30 | #define IDM_EXIT 1
|
|---|
| 31 | #define IDM_TEXT 2
|
|---|
| 32 |
|
|---|
| 33 | #define kPB_POSITION 0x1001
|
|---|
| 34 | #define kPB_TRACK 0x1002
|
|---|
| 35 | #define kPB_STOP 0x1003
|
|---|
| 36 | #define kPB_CALCALTAZ 0x1004
|
|---|
| 37 | #define kPB_POLARIS 0x1005
|
|---|
| 38 | #define kPB_START 0x1006
|
|---|
| 39 |
|
|---|
| 40 | #define kEF_A 0x1010
|
|---|
| 41 | #define kEF_B 0x1011
|
|---|
| 42 |
|
|---|
| 43 | void MGCosy::CreateMenu()
|
|---|
| 44 | {
|
|---|
| 45 | fLayMenuBar = new TGLayoutHints (kLHintsNormal | kLHintsExpandX);
|
|---|
| 46 | fLayMenuItem = new TGLayoutHints (kLHintsNormal, 0, 4, 0, 0);
|
|---|
| 47 |
|
|---|
| 48 | //
|
|---|
| 49 | // crate the menu bar
|
|---|
| 50 | //
|
|---|
| 51 | TGPopupMenu *fFileMenu = new TGPopupMenu(gClient->GetRoot());
|
|---|
| 52 | fFileMenu->AddEntry ("Exit", IDM_EXIT) ;
|
|---|
| 53 | //fFileMenu->Associate(this);
|
|---|
| 54 | fList->Add(fFileMenu);
|
|---|
| 55 |
|
|---|
| 56 | //
|
|---|
| 57 | // the button messages are handled by main frame (this)
|
|---|
| 58 | //
|
|---|
| 59 | TGMenuBar *fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
|
|---|
| 60 | fMenuBar->AddPopup("File", fFileMenu, fLayMenuItem);
|
|---|
| 61 | AddFrame(fMenuBar, fLayMenuBar);
|
|---|
| 62 | fList->Add(fMenuBar);
|
|---|
| 63 |
|
|---|
| 64 | //
|
|---|
| 65 | // Seperator beyond menubar
|
|---|
| 66 | //
|
|---|
| 67 |
|
|---|
| 68 | TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this);
|
|---|
| 69 | AddFrame(fLineSep, fLayMenuBar);
|
|---|
| 70 | fList->Add(fLineSep);
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | void MGCosy::CreateLabel(TGCompositeFrame *f)
|
|---|
| 74 | {
|
|---|
| 75 | const int x = 180;
|
|---|
| 76 | const int y = 25;
|
|---|
| 77 |
|
|---|
| 78 | TGLabel *l;
|
|---|
| 79 |
|
|---|
| 80 | l = new TGLabel(f, "SE-Az:");
|
|---|
| 81 | l->Move(x-60, y);
|
|---|
| 82 | fList->Add(l);
|
|---|
| 83 |
|
|---|
| 84 | l = new TGLabel(f, "SE-Zd1:");
|
|---|
| 85 | l->Move(x-60, y+20);
|
|---|
| 86 | fList->Add(l);
|
|---|
| 87 |
|
|---|
| 88 | l = new TGLabel(f, "SE-Zd2:");
|
|---|
| 89 | l->Move(x-60, y+40);
|
|---|
| 90 | fList->Add(l);
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 | fLabel1 = new TGLabel*[3];
|
|---|
| 94 | fLabel1[0] = new TGLabel(f, "00000"); // Max: 16384
|
|---|
| 95 | fLabel1[1] = new TGLabel(f, "000"); // Max: 256
|
|---|
| 96 | fLabel1[2] = new TGLabel(f, "000"); // Max: 256
|
|---|
| 97 | fLabel1[0]->SetTextJustify(kTextRight);
|
|---|
| 98 | fLabel1[1]->SetTextJustify(kTextRight);
|
|---|
| 99 | fLabel1[2]->SetTextJustify(kTextRight);
|
|---|
| 100 | fLabel1[0]->Move(x, y);
|
|---|
| 101 | fLabel1[1]->Move(x+43, y);
|
|---|
| 102 | fLabel1[2]->Move(x+70, y);
|
|---|
| 103 | fList->Add(fLabel1[0]);
|
|---|
| 104 | fList->Add(fLabel1[1]);
|
|---|
| 105 | fList->Add(fLabel1[2]);
|
|---|
| 106 | //f->AddFrame(fLabel1[0]);
|
|---|
| 107 | //f->AddFrame(fLabel1[1]);
|
|---|
| 108 | //f->AddFrame(fLabel1[2]);
|
|---|
| 109 |
|
|---|
| 110 | fLabel2 = new TGLabel*[3];
|
|---|
| 111 | fLabel2[0] = new TGLabel(f, "00000");
|
|---|
| 112 | fLabel2[1] = new TGLabel(f, "000");
|
|---|
| 113 | fLabel2[2] = new TGLabel(f, "000");
|
|---|
| 114 | fLabel2[0]->SetTextJustify(kTextRight);
|
|---|
| 115 | fLabel2[1]->SetTextJustify(kTextRight);
|
|---|
| 116 | fLabel2[2]->SetTextJustify(kTextRight);
|
|---|
| 117 | fLabel2[0]->Move(x, y+20);
|
|---|
| 118 | fLabel2[1]->Move(x+43, y+20);
|
|---|
| 119 | fLabel2[2]->Move(x+70, y+20);
|
|---|
| 120 | fList->Add(fLabel2[0]);
|
|---|
| 121 | fList->Add(fLabel2[1]);
|
|---|
| 122 | fList->Add(fLabel2[2]);
|
|---|
| 123 | //f->AddFrame(fLabel2[0]);
|
|---|
| 124 | //f->AddFrame(fLabel2[1]);
|
|---|
| 125 | //f->AddFrame(fLabel2[2]);
|
|---|
| 126 |
|
|---|
| 127 | fLabel3 = new TGLabel*[3];
|
|---|
| 128 | fLabel3[0] = new TGLabel(f, "00000");
|
|---|
| 129 | fLabel3[1] = new TGLabel(f, "000");
|
|---|
| 130 | fLabel3[2] = new TGLabel(f, "000");
|
|---|
| 131 | fLabel3[0]->SetTextJustify(kTextRight);
|
|---|
| 132 | fLabel3[1]->SetTextJustify(kTextRight);
|
|---|
| 133 | fLabel3[2]->SetTextJustify(kTextRight);
|
|---|
| 134 | fLabel3[0]->Move(x, y+40);
|
|---|
| 135 | fLabel3[1]->Move(x+43, y+40);
|
|---|
| 136 | fLabel3[2]->Move(x+70, y+40);
|
|---|
| 137 | fList->Add(fLabel3[0]);
|
|---|
| 138 | fList->Add(fLabel3[1]);
|
|---|
| 139 | fList->Add(fLabel3[2]);
|
|---|
| 140 | //f->AddFrame(fLabel3[0]);
|
|---|
| 141 | //f->AddFrame(fLabel3[1]);
|
|---|
| 142 | //f->AddFrame(fLabel3[2]);
|
|---|
| 143 |
|
|---|
| 144 | l = new TGLabel(f, "Offset-Zd:");
|
|---|
| 145 | l->Move(x-60, y+80);
|
|---|
| 146 | fList->Add(l);
|
|---|
| 147 |
|
|---|
| 148 | l = new TGLabel(f, "Offset-Az:");
|
|---|
| 149 | l->Move(x-60, y+100);
|
|---|
| 150 | fList->Add(l);
|
|---|
| 151 |
|
|---|
| 152 | fOffsetZd = new TGLabel(f, "0000000");
|
|---|
| 153 | fOffsetAz = new TGLabel(f, "0000000");
|
|---|
| 154 | fOffsetZd->SetTextJustify(kTextRight);
|
|---|
| 155 | fOffsetAz->SetTextJustify(kTextRight);
|
|---|
| 156 | fOffsetZd->Move(x, y+80);
|
|---|
| 157 | fOffsetAz->Move(x, y+100);
|
|---|
| 158 | fList->Add(fOffsetZd);
|
|---|
| 159 | fList->Add(fOffsetAz);
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 | fError = new TGLabel(f, "Error");
|
|---|
| 163 | fMoving = new TGLabel(f, "Moving");
|
|---|
| 164 | fTracking = new TGLabel(f, "Tracking");
|
|---|
| 165 | fStopping = new TGLabel(f, "Stopping");
|
|---|
| 166 | fStopped = new TGLabel(f, "Stopped");
|
|---|
| 167 |
|
|---|
| 168 | fError ->SetBackgroundColor(224); // red
|
|---|
| 169 | fMoving ->SetBackgroundColor(10); // blue
|
|---|
| 170 | fTracking->SetBackgroundColor(47); // blue
|
|---|
| 171 | fStopping->SetBackgroundColor(164); // orange
|
|---|
| 172 | fStopped ->SetBackgroundColor(20); // green
|
|---|
| 173 |
|
|---|
| 174 | fError ->Move(10, 25);
|
|---|
| 175 | fMoving ->Move(10, 25+20);
|
|---|
| 176 | fTracking->Move(10, 25+40);
|
|---|
| 177 | fStopping->Move(10, 25+60);
|
|---|
| 178 | fStopped ->Move(10, 25+80);
|
|---|
| 179 |
|
|---|
| 180 | fError ->Resize(60, 20);
|
|---|
| 181 | fMoving ->Resize(60, 20);
|
|---|
| 182 | fTracking->Resize(60, 20);
|
|---|
| 183 | fStopping->Resize(60, 20);
|
|---|
| 184 | fStopped ->Resize(60, 20);
|
|---|
| 185 |
|
|---|
| 186 | fList->Add(fError);
|
|---|
| 187 | fList->Add(fMoving);
|
|---|
| 188 | fList->Add(fTracking);
|
|---|
| 189 | fList->Add(fStopping);
|
|---|
| 190 | fList->Add(fStopped);
|
|---|
| 191 | }
|
|---|
| 192 |
|
|---|
| 193 | void MGCosy::CreateTabs(TGTab *fTab)
|
|---|
| 194 | {
|
|---|
| 195 | TGCompositeFrame *tf1 = fTab->AddTab("Position Zd/Az");
|
|---|
| 196 | TGCompositeFrame *tf2 = fTab->AddTab("Track Ra/Dec");
|
|---|
| 197 |
|
|---|
| 198 | fCZdAz = new MGCoordinates(tf1, kETypeZdAz);
|
|---|
| 199 | fCZdAz->Move(27, 105);
|
|---|
| 200 | fList->Add(fCZdAz);
|
|---|
| 201 |
|
|---|
| 202 | fCRaDec = new MGCoordinates(tf2, kETypeRaDec);
|
|---|
| 203 | fCRaDec->Move(27, 105);
|
|---|
| 204 | fList->Add(fCRaDec);
|
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 | const int x=15;
|
|---|
| 208 | const int y=12;
|
|---|
| 209 | const int h=16;
|
|---|
| 210 |
|
|---|
| 211 | TGLabel *l1 = new TGLabel(tf1, "Move the telescope to a position given in");
|
|---|
| 212 | TGLabel *l2 = new TGLabel(tf1, "local coordinates. The given coordinates");
|
|---|
| 213 | TGLabel *l3 = new TGLabel(tf1, "are pointing coordinates, which means that the");
|
|---|
| 214 | TGLabel *l4 = new TGLabel(tf1, "coordinates are corrected for the bending of");
|
|---|
| 215 | TGLabel *l5 = new TGLabel(tf1, "the telescope.");
|
|---|
| 216 | l1->Move(x, y);
|
|---|
| 217 | l2->Move(x, y+h);
|
|---|
| 218 | l3->Move(x, y+2*h);
|
|---|
| 219 | l4->Move(x, y+3*h);
|
|---|
| 220 | l5->Move(x, y+4*h);
|
|---|
| 221 | fList->Add(l1);
|
|---|
| 222 | fList->Add(l2);
|
|---|
| 223 | fList->Add(l3);
|
|---|
| 224 | fList->Add(l4);
|
|---|
| 225 | fList->Add(l5);
|
|---|
| 226 |
|
|---|
| 227 | l1 = new TGLabel(tf2, "Track a position given in sky coordinates.");
|
|---|
| 228 | l2 = new TGLabel(tf2, "Right Ascension and declination must be given");
|
|---|
| 229 | l3 = new TGLabel(tf2, "in the FK5, J2000 coordinate system");
|
|---|
| 230 | l1->Move(x, y);
|
|---|
| 231 | l2->Move(x, y+h);
|
|---|
| 232 | l3->Move(x, y+2*h);
|
|---|
| 233 | fList->Add(l1);
|
|---|
| 234 | fList->Add(l2);
|
|---|
| 235 | fList->Add(l3);
|
|---|
| 236 |
|
|---|
| 237 | //
|
|---|
| 238 | // light green: 3 light red: 2 blue?: 2
|
|---|
| 239 | // dark green: 8 dark red: 50 dark blue?: 1
|
|---|
| 240 |
|
|---|
| 241 | //
|
|---|
| 242 | // blue: 0-7, 9, 10,11, 14, 15, 18, 19, 22, 23, 27, 31, 33-39, 41-43
|
|---|
| 243 | // 46, 47
|
|---|
| 244 | // green: 8, 12,13, 16, 17, 20, 21, 24, 25, 26, 28, 29, 30, 40, 44
|
|---|
| 245 | // 45, 48
|
|---|
| 246 | // gray: 31, 113-
|
|---|
| 247 | // red: 164, 192, 224, 232
|
|---|
| 248 | //
|
|---|
| 249 | TGTextButton *but;
|
|---|
| 250 |
|
|---|
| 251 | but= new TGTextButton(this, "Calc Zd/Az", kPB_CALCALTAZ);
|
|---|
| 252 | but->Resize(80, 25);
|
|---|
| 253 | but->Move(37, 257);
|
|---|
| 254 | but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec.");
|
|---|
| 255 | fList->Add(but);
|
|---|
| 256 |
|
|---|
| 257 | but = new TGTextButton(this, "Set Polaris", kPB_POLARIS);
|
|---|
| 258 | but->Resize(80, 25);
|
|---|
| 259 | but->Move(37, 288);
|
|---|
| 260 | but->SetToolTipText("Set the actual position as the position of Polaris.");
|
|---|
| 261 | fList->Add(but);
|
|---|
| 262 |
|
|---|
| 263 | but = new TGTextButton(this, "Start", kPB_START);
|
|---|
| 264 | but->SetBackgroundColor(20);
|
|---|
| 265 | but->Move(147, 275);
|
|---|
| 266 | but->Resize(62, 25);
|
|---|
| 267 | but->SetToolTipText("Start a telescope movement.");
|
|---|
| 268 | fList->Add(but);
|
|---|
| 269 |
|
|---|
| 270 | but = new TGTextButton(this, "Stop", kPB_STOP);
|
|---|
| 271 | but->SetBackgroundColor(224);
|
|---|
| 272 | but->Move(212, 275);
|
|---|
| 273 | but->Resize(62, 25);
|
|---|
| 274 | but->SetToolTipText("Stop any movement of telescope.");
|
|---|
| 275 | fList->Add(but);
|
|---|
| 276 |
|
|---|
| 277 | }
|
|---|
| 278 |
|
|---|
| 279 | MGCosy::MGCosy(MsgQueue *q, const TGWindow *p, UInt_t w, UInt_t h)
|
|---|
| 280 | : TGMainFrame(p, w, h), fQueue(q)
|
|---|
| 281 | {
|
|---|
| 282 | fList = new MGList;
|
|---|
| 283 |
|
|---|
| 284 | CreateMenu();
|
|---|
| 285 |
|
|---|
| 286 | TGCompositeFrame *f = new TGCompositeFrame(this, 0, 0);
|
|---|
| 287 | f->SetLayoutManager(new TGMatrixLayout(f, 3, 2, 10));
|
|---|
| 288 | fList->Add(f);
|
|---|
| 289 |
|
|---|
| 290 | fTab = new TGTab(f, 300, 300);
|
|---|
| 291 | fList->Add(fTab);
|
|---|
| 292 |
|
|---|
| 293 | fSkyPosition = new MGSkyPosition(f, 300);
|
|---|
| 294 | fAccuracy = new MGAccuracy (f, 300);
|
|---|
| 295 | fVelocity = new MGVelocity (f, "Velocity [\"/min]", 300);
|
|---|
| 296 | // fOffset = new MGVelocity (f, "Offset se-re [']", 300);
|
|---|
| 297 |
|
|---|
| 298 | fList->Add(fSkyPosition);
|
|---|
| 299 | fList->Add(fAccuracy);
|
|---|
| 300 | fList->Add(fVelocity);
|
|---|
| 301 | // fList->Add(fOffset);
|
|---|
| 302 |
|
|---|
| 303 | TGGroupFrame *frame = new TGGroupFrame(f, "Status");
|
|---|
| 304 | frame->Resize(300, 300);
|
|---|
| 305 | fList->Add(frame);
|
|---|
| 306 |
|
|---|
| 307 | fLog = new TGListBox(f, -1, kSunkenFrame); //kSunkenFrame|kDoubleBorder,
|
|---|
| 308 | fLog->Resize(300, 300);
|
|---|
| 309 | fLog->ChangeBackground(TGFrame::GetBlackPixel());
|
|---|
| 310 | fList->Add(fLog);
|
|---|
| 311 |
|
|---|
| 312 | //
|
|---|
| 313 | // Layout the window, tile by tile...
|
|---|
| 314 | //
|
|---|
| 315 | f->AddFrame(fTab);
|
|---|
| 316 | f->AddFrame(fSkyPosition);
|
|---|
| 317 | f->AddFrame(fAccuracy);
|
|---|
| 318 | f->AddFrame(frame);
|
|---|
| 319 | f->AddFrame(fVelocity);
|
|---|
| 320 | f->AddFrame(fLog);
|
|---|
| 321 |
|
|---|
| 322 | AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 1, 0));
|
|---|
| 323 |
|
|---|
| 324 | //
|
|---|
| 325 | // FIXME!
|
|---|
| 326 | //
|
|---|
| 327 | CreateTabs(fTab);
|
|---|
| 328 | CreateLabel(frame);
|
|---|
| 329 |
|
|---|
| 330 | //
|
|---|
| 331 | // Map the window, set up the layout, etc.
|
|---|
| 332 | //
|
|---|
| 333 | const Int_t w = 940;
|
|---|
| 334 | const Int_t h = 660;
|
|---|
| 335 | SetWMSizeHints(w, h, w, h, 10, 10); // set the smallest and biggest size of the Main frame
|
|---|
| 336 |
|
|---|
| 337 | SetWindowName("Cosy Main Window");
|
|---|
| 338 | SetIconName("Cosy");
|
|---|
| 339 |
|
|---|
| 340 | MapSubwindows();
|
|---|
| 341 | Resize(GetDefaultSize());
|
|---|
| 342 | MapWindow();
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 | // ======================================================================
|
|---|
| 346 |
|
|---|
| 347 | MGCosy::~MGCosy()
|
|---|
| 348 | {
|
|---|
| 349 | cout << "MGCosy::~MGCosy called." << endl;
|
|---|
| 350 |
|
|---|
| 351 | delete fLayMenuBar;
|
|---|
| 352 | delete fLayMenuItem;
|
|---|
| 353 |
|
|---|
| 354 | cout << "Deleting MGCosy::fList" << endl;
|
|---|
| 355 |
|
|---|
| 356 | delete fList;
|
|---|
| 357 |
|
|---|
| 358 | cout << "MGCosy::~MGCosy done." << endl;
|
|---|
| 359 | }
|
|---|
| 360 | // ======================================================================
|
|---|
| 361 | void MGCosy::EnableLabel(TGLabel *label, Bool_t stat)
|
|---|
| 362 | {
|
|---|
| 363 | stat ? label->MapWindow() : label->UnmapWindow();
|
|---|
| 364 |
|
|---|
| 365 | /*
|
|---|
| 366 | TGGC *fRedTextGC(TGButton::GetDefaultGC())
|
|---|
| 367 | // Set foreground color in graphics context for drawing of
|
|---|
| 368 | // TGlabel and TGButtons with text in red.
|
|---|
| 369 | ULong_t red;
|
|---|
| 370 | gClient->GetColorByName("red", red);
|
|---|
| 371 | fRedTextGC.SetForeground(red);
|
|---|
| 372 | */
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 | void MGCosy::UpdateOffset(ZdAz &off)
|
|---|
| 376 | {
|
|---|
| 377 | static Int_t zd=~0;
|
|---|
| 378 | static Int_t az=~0;
|
|---|
| 379 |
|
|---|
| 380 | char text[21];
|
|---|
| 381 |
|
|---|
| 382 | if (zd!=(Int_t)off.Zd())
|
|---|
| 383 | {
|
|---|
| 384 | zd = (Int_t)off.Zd();
|
|---|
| 385 | sprintf(text, "%d", zd);
|
|---|
| 386 | fOffsetZd->SetText(new TGString(text));
|
|---|
| 387 | }
|
|---|
| 388 | if (az!=(Int_t)off.Az())
|
|---|
| 389 | {
|
|---|
| 390 | az = (Int_t)off.Az();
|
|---|
| 391 | sprintf(text, "%d", az);
|
|---|
| 392 | fOffsetAz->SetText(new TGString(text));
|
|---|
| 393 | }
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 | void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off, UInt_t stat)
|
|---|
| 397 | {
|
|---|
| 398 | fSkyPosition->Update(pos);
|
|---|
| 399 | fAccuracy->Update(pos, acc);
|
|---|
| 400 | fVelocity->Update(vel);
|
|---|
| 401 | UpdateOffset(off);
|
|---|
| 402 |
|
|---|
| 403 | #define kError 0x01
|
|---|
| 404 | #define kMoving 0x02
|
|---|
| 405 | #define kTracking 0x04
|
|---|
| 406 | #define kStopping 0x08
|
|---|
| 407 | #define kStopped 0x10
|
|---|
| 408 |
|
|---|
| 409 | EnableLabel(fError, stat&kError);
|
|---|
| 410 | EnableLabel(fMoving, stat&kMoving);
|
|---|
| 411 | EnableLabel(fTracking, stat&kTracking);
|
|---|
| 412 | EnableLabel(fStopping, stat&kStopping);
|
|---|
| 413 | EnableLabel(fStopped, stat&kStopped);
|
|---|
| 414 |
|
|---|
| 415 | stat&kTracking ? fAccuracy->MapWindow() : fAccuracy->UnmapWindow();
|
|---|
| 416 | stat&kTracking ? fVelocity->MapWindow() : fVelocity->UnmapWindow();
|
|---|
| 417 | // stat&kTracking ? fOffset->MapWindow() : fOffset->UnmapWindow();
|
|---|
| 418 |
|
|---|
| 419 | if (!fLog->TestBit(kHasChanged))
|
|---|
| 420 | return;
|
|---|
| 421 |
|
|---|
| 422 | fLog->MapSubwindows();
|
|---|
| 423 | fLog->Layout();
|
|---|
| 424 | fLog->ResetBit(kHasChanged);
|
|---|
| 425 | }
|
|---|
| 426 | // ======================================================================
|
|---|
| 427 |
|
|---|
| 428 | void MGCosy::CloseWindow()
|
|---|
| 429 | {
|
|---|
| 430 | // Got close message for this MainFrame. Calls parent CloseWindow()
|
|---|
| 431 | // (which destroys the window) and terminate the application.
|
|---|
| 432 | // The close message is generated by the window manager when its close
|
|---|
| 433 | // window menu item is selected.
|
|---|
| 434 |
|
|---|
| 435 | // gSystem->ExitLoop();
|
|---|
| 436 | // gSystem->DispatchOneEvent(kTRUE);
|
|---|
| 437 |
|
|---|
| 438 | // TGMainFrame::CloseWindow();
|
|---|
| 439 | cout << "Closing window - waiting until all nodes are stopped." << endl;
|
|---|
| 440 | fQueue->PostMsg(WM_QUIT, 0, 0);
|
|---|
| 441 | // gApplication->Terminate(0);
|
|---|
| 442 | }
|
|---|
| 443 |
|
|---|
| 444 | void MGCosy::StartTrack()
|
|---|
| 445 | {
|
|---|
| 446 | cout << "Start tracking." << endl;
|
|---|
| 447 |
|
|---|
| 448 | XY xy = fCRaDec->GetCoordinates();
|
|---|
| 449 | RaDec dest(xy.X()*15., xy.Y()); // xy.X() [h]->[ø]
|
|---|
| 450 |
|
|---|
| 451 | cout << dest.Ra() << "h " << dest.Dec() << "\xb0" << endl;
|
|---|
| 452 |
|
|---|
| 453 | fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));
|
|---|
| 454 |
|
|---|
| 455 | cout << "PostMsg (WM_Track) returned." << endl;
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | void MGCosy::StartPos()
|
|---|
| 459 | {
|
|---|
| 460 | cout << "Start positioning." << endl;
|
|---|
| 461 |
|
|---|
| 462 | XY xy = fCZdAz->GetCoordinates();
|
|---|
| 463 | ZdAz dest(xy.X(), xy.Y());
|
|---|
| 464 |
|
|---|
| 465 | cout << dest.Zd() << kDEG << " " << dest.Az() << kDEG << endl;
|
|---|
| 466 |
|
|---|
| 467 | fQueue->PostMsg(WM_POSITION, &dest, sizeof(dest));
|
|---|
| 468 |
|
|---|
| 469 | cout << "PostMsg (WM_Position) returned." << endl;
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|
| 472 | Bool_t MGCosy::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
|
|---|
| 473 | {
|
|---|
| 474 | //
|
|---|
| 475 | // This processing is serialized!
|
|---|
| 476 | //
|
|---|
| 477 | switch (GET_MSG(msg))
|
|---|
| 478 | {
|
|---|
| 479 | case kC_COMMAND:
|
|---|
| 480 | switch (GET_SUBMSG(msg))
|
|---|
| 481 | {
|
|---|
| 482 | case kCM_TAB:
|
|---|
| 483 | //cout << "Tab: " << mp1 << endl;
|
|---|
| 484 | return kTRUE;
|
|---|
| 485 |
|
|---|
| 486 | case kCM_BUTTON:
|
|---|
| 487 |
|
|---|
| 488 | switch (mp1)
|
|---|
| 489 | {
|
|---|
| 490 | /*
|
|---|
| 491 | case kPB_POSITION:
|
|---|
| 492 | Start(0);
|
|---|
| 493 | return kTRUE;
|
|---|
| 494 |
|
|---|
| 495 | case kPB_TRACK:
|
|---|
| 496 | Start(1);
|
|---|
| 497 | return kTRUE;
|
|---|
| 498 | */
|
|---|
| 499 | case kPB_START:
|
|---|
| 500 | fTab->GetCurrent() ? StartTrack() : StartPos();
|
|---|
| 501 | return kTRUE;
|
|---|
| 502 |
|
|---|
| 503 | case kPB_STOP:
|
|---|
| 504 | cout << "Sending stop movement msg." << endl;
|
|---|
| 505 | fQueue->PostMsg(WM_STOP, 0, 0);
|
|---|
| 506 | cout << "PostMsg (WM_Stop) returned." << endl;
|
|---|
| 507 | return kTRUE;
|
|---|
| 508 |
|
|---|
| 509 | case kPB_CALCALTAZ:
|
|---|
| 510 | {
|
|---|
| 511 | SlaStars sla;
|
|---|
| 512 | sla.SetMjd2Now();
|
|---|
| 513 |
|
|---|
| 514 | XY xy = fCRaDec->GetCoordinates();
|
|---|
| 515 | RaDec rd(xy.X()*15., xy.Y());
|
|---|
| 516 |
|
|---|
| 517 | cout << "Ra/Dec: " << rd.Ra() << kDEG << " " << rd.Dec() << kDEG << endl;
|
|---|
| 518 | ZdAz aa=sla.CalcZdAz(rd*D2PI/360.0)*360.0/D2PI;
|
|---|
| 519 | cout << "Zd/Az: " << aa.Zd() << kDEG << " " << aa.Az() << kDEG << endl;
|
|---|
| 520 | }
|
|---|
| 521 | return kTRUE;
|
|---|
| 522 |
|
|---|
| 523 | case kPB_POLARIS:
|
|---|
| 524 | fQueue->PostMsg(WM_POLARIS, 0, 0);
|
|---|
| 525 | return kTRUE;
|
|---|
| 526 |
|
|---|
| 527 | default:
|
|---|
| 528 | return kTRUE;
|
|---|
| 529 | }
|
|---|
| 530 | return kTRUE;
|
|---|
| 531 |
|
|---|
| 532 | case kCM_MENU:
|
|---|
| 533 |
|
|---|
| 534 | switch (mp1)
|
|---|
| 535 | {
|
|---|
| 536 | case IDM_EXIT:
|
|---|
| 537 | fQueue->PostMsg(WM_QUIT, 0, 0);
|
|---|
| 538 | //cout << "Idm_Exit." << endl;
|
|---|
| 539 | //CloseWindow();
|
|---|
| 540 | return kTRUE;
|
|---|
| 541 | }
|
|---|
| 542 | return kTRUE;
|
|---|
| 543 | }
|
|---|
| 544 | }
|
|---|
| 545 |
|
|---|
| 546 | //
|
|---|
| 547 | // Start a thread to process the message.
|
|---|
| 548 | //
|
|---|
| 549 | // fQueue->PostMsg(msg, mp1, mp2);
|
|---|
| 550 | return kTRUE;
|
|---|
| 551 |
|
|---|
| 552 | }
|
|---|