Changeset 1531 for trunk/MagicSoft/Cosy/gui
- Timestamp:
- 09/24/02 14:35:10 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy/gui
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/gui/MGCoordinate.cc
r1111 r1531 28 28 const Bool_t flag, const char *txt, 29 29 const Int_t deg, const UInt_t min, const UInt_t sec) 30 : TGFrame(p, 119, flag?76:46, kSunkenFrame|kFixedSize), f Deg(deg), fMin(min), fSec(sec)30 : TGFrame(p, 119, flag?76:46, kSunkenFrame|kFixedSize), fSign('+'), fDeg(deg), fMin(min), fSec(sec) 31 31 { 32 32 fList = new MGList; … … 139 139 Double_t MGCoordinate::GetVal() const 140 140 { 141 const Int_t deg = fDeg<0 ? -fDeg : fDeg; 142 const Int_t sgn = fDeg<0 ? -1 : 1; 143 144 return (Double_t)sgn*(60*(60*deg+fMin)+fSec)/3600; 141 const Int_t sgn = fSign=='-' ? -1 : 1; 142 143 return (Double_t)sgn*(60*(60*fDeg+fMin)+fSec)/3600; 145 144 } 146 145 147 146 void MGCoordinate::Print() 148 147 { 149 cout << fLabel->GetText()->GetString() << " " << f Deg << "\xb0 " << fMin << "' " << fSec << "\"" << endl;148 cout << fLabel->GetText()->GetString() << " " << fSign << fDeg << "\xb0 " << fMin << "' " << fSec << "\"" << endl; 150 149 } 151 150 … … 154 153 char txt[20]; 155 154 156 sprintf(txt, "% d", val);155 sprintf(txt, "%s%d", label == fLabelDeg && fSign=='-'?"-":"", val); 157 156 158 157 label->SetText(new TGString(txt)); … … 163 162 char txt[20]; 164 163 165 sprintf(txt, "% d", val);164 sprintf(txt, "%s%d", entry == fTextEntryDeg && fSign=='-'?"-":"", val); 166 165 167 166 entry->SetText(txt); … … 180 179 slaDr2af(0, d*D2PI/360.0, &sign, dms); 181 180 182 183 fDeg = sign=='-'?-dms[0]:dms[0];181 fSign = sign; 182 fDeg = dms[0]; 184 183 fMin = dms[1]; 185 184 fSec = dms[2]; … … 197 196 Bool_t MGCoordinate::Set(TGLabel *label, Int_t &val, TGTextEntry *entry) 198 197 { 199 Int_t newval = atoi(entry->GetText()); 198 TString text = entry->GetText(); 199 200 Int_t newval = abs(atoi(text)); 200 201 201 202 Bool_t ok = (entry == fTextEntryDeg || (newval>=0 && newval<60)); 203 204 if (entry==fTextEntryDeg) 205 fSign = text.Contains("-") ? '-' : '+'; 202 206 203 207 if (ok) -
trunk/MagicSoft/Cosy/gui/MGCoordinate.h
r1111 r1531 25 25 class MGCoordinate : public TGFrame 26 26 { 27 Char_t fSign; 28 27 29 Int_t fDeg; 28 30 Int_t fMin; -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r1275 r1531 15 15 #include <TGListBox.h> // TGListBox 16 16 #include <TG3DLine.h> // TGHorizontal3DLine (TGSplitter) 17 #include <TGTextEntry.h> // TGTextEntry 17 18 #include <TGFrame.h> // TGGroupFrame 18 19 #include <TApplication.h> // gApplication … … 34 35 #define IDM_TEXT 2 35 36 36 #define kPB_POSITION 0x1001 37 #define kPB_TRACK 0x1002 38 #define kPB_STOP 0x1003 39 #define kPB_CALCALTAZ 0x1004 40 #define kPB_POLARIS 0x1005 41 #define kPB_START 0x1006 42 43 #define kEF_A 0x1010 44 #define kEF_B 0x1011 37 enum 38 { 39 kPB_POSITION, 40 kPB_TRACK, 41 kPB_STOP, 42 kPB_CALCALTAZ, 43 kPB_TPOINT, 44 kPB_START, 45 kPB_RAp, 46 kPB_RAm, 47 kPB_DECp, 48 kPB_DECm, 49 kPB_LoadBending, 50 kPB_CALIBSE 51 }; 45 52 46 53 void MGCosy::CreateMenu() … … 81 88 TGLabel *l; 82 89 83 l = new TGLabel(f, " SE-Az:");90 l = new TGLabel(f, "UTC:"); 84 91 l->Move(x-60, y); 85 92 fList->Add(l); 86 93 87 l = new TGLabel(f, " SE-Zd1:");94 l = new TGLabel(f, "Mjd:"); 88 95 l->Move(x-60, y+20); 89 96 fList->Add(l); 90 97 98 fUtc = new TGLabel(f, "0000/00/00 00:00:00.0"); 99 fMjd = new TGLabel(f, "00000.000000"); 100 fUtc->Move(x-25, y); 101 fMjd->Move(x-25, y+20); 102 fList->Add(fUtc); 103 fList->Add(fMjd); 104 105 l = new TGLabel(f, "SE-Az:"); 106 l->Move(x-60, y+60); 107 fList->Add(l); 108 109 l = new TGLabel(f, "SE-Zd1:"); 110 l->Move(x-60, y+80); 111 fList->Add(l); 112 91 113 l = new TGLabel(f, "SE-Zd2:"); 92 l->Move(x-60, y+ 40);114 l->Move(x-60, y+100); 93 115 fList->Add(l); 94 95 116 96 117 fLabel1 = new TGLabel*[3]; … … 101 122 fLabel1[1]->SetTextJustify(kTextRight); 102 123 fLabel1[2]->SetTextJustify(kTextRight); 103 fLabel1[0]->Move(x, y );104 fLabel1[1]->Move(x+43, y );105 fLabel1[2]->Move(x+70, y );124 fLabel1[0]->Move(x, y+60); 125 fLabel1[1]->Move(x+43, y+60); 126 fLabel1[2]->Move(x+70, y+60); 106 127 fList->Add(fLabel1[0]); 107 128 fList->Add(fLabel1[1]); … … 118 139 fLabel2[1]->SetTextJustify(kTextRight); 119 140 fLabel2[2]->SetTextJustify(kTextRight); 120 fLabel2[0]->Move(x, y+ 20);121 fLabel2[1]->Move(x+43, y+ 20);122 fLabel2[2]->Move(x+70, y+ 20);141 fLabel2[0]->Move(x, y+80); 142 fLabel2[1]->Move(x+43, y+80); 143 fLabel2[2]->Move(x+70, y+80); 123 144 fList->Add(fLabel2[0]); 124 145 fList->Add(fLabel2[1]); … … 135 156 fLabel3[1]->SetTextJustify(kTextRight); 136 157 fLabel3[2]->SetTextJustify(kTextRight); 137 fLabel3[0]->Move(x, y+ 40);138 fLabel3[1]->Move(x+43, y+ 40);139 fLabel3[2]->Move(x+70, y+ 40);158 fLabel3[0]->Move(x, y+100); 159 fLabel3[1]->Move(x+43, y+100); 160 fLabel3[2]->Move(x+70, y+100); 140 161 fList->Add(fLabel3[0]); 141 162 fList->Add(fLabel3[1]); … … 146 167 147 168 l = new TGLabel(f, "Offset-Zd:"); 148 l->Move(x-60, y+ 80);169 l->Move(x-60, y+140); 149 170 fList->Add(l); 150 171 151 172 l = new TGLabel(f, "Offset-Az:"); 152 l->Move(x-60, y+1 00);173 l->Move(x-60, y+160); 153 174 fList->Add(l); 154 175 … … 157 178 fOffsetZd->SetTextJustify(kTextRight); 158 179 fOffsetAz->SetTextJustify(kTextRight); 159 fOffsetZd->Move(x, y+ 80);160 fOffsetAz->Move(x, y+1 00);180 fOffsetZd->Move(x, y+140); 181 fOffsetAz->Move(x, y+160); 161 182 fList->Add(fOffsetZd); 162 183 fList->Add(fOffsetAz); … … 204 225 void MGCosy::CreateTabs(TGTab *fTab) 205 226 { 206 TGCompositeFrame *tf1 = fTab->AddTab("Position Zd/Az"); 207 TGCompositeFrame *tf2 = fTab->AddTab("Track Ra/Dec"); 208 TGCompositeFrame *tf3 = fTab->AddTab("Demo Mode"); 227 TGCompositeFrame *tf1 = fTab->AddTab("Position"); 228 TGCompositeFrame *tf2 = fTab->AddTab("Track"); 229 TGCompositeFrame *tf4 = fTab->AddTab("Calibration"); 230 TGCompositeFrame *tf3 = fTab->AddTab("Demo"); 209 231 210 232 fCZdAz = new MGCoordinates(tf1, kETypeZdAz); … … 216 238 fList->Add(fCRaDec); 217 239 240 fCCalib = new MGCoordinates(tf4, kETypeRaDec); 241 fCCalib->Move(27, 105); 242 fList->Add(fCCalib); 218 243 219 244 const int x=15; … … 239 264 l1 = new TGLabel(tf2, "Track a position given in sky coordinates."); 240 265 l2 = new TGLabel(tf2, "Right Ascension and declination must be given"); 241 l3 = new TGLabel(tf2, "in the FK5, J2000 coordinate system ");266 l3 = new TGLabel(tf2, "in the FK5, J2000 coordinate system."); 242 267 l1->Move(x, y); 243 268 l2->Move(x, y+h); … … 246 271 fList->Add(l2); 247 272 fList->Add(l3); 273 274 l1 = new TGLabel(tf4, "Start the calibration using the Start button."); 275 l2 = new TGLabel(tf4, "Write a coordinate pair to a TPoint file using"); 276 l3 = new TGLabel(tf4, "the TPoint button. To set the Shaftencoder offset"); 277 l4 = new TGLabel(tf4, "use the Calib SE button."); 278 l1->Move(x, y); 279 l2->Move(x, y+h); 280 l3->Move(x, y+2*h); 281 l4->Move(x, y+3*h); 282 fList->Add(l1); 283 fList->Add(l2); 284 fList->Add(l3); 285 fList->Add(l4); 248 286 249 287 // … … 261 299 TGTextButton *but; 262 300 263 but= new TGTextButton(this, "Calc Zd/Az", kPB_CALCALTAZ); 301 but= new TGTextButton(tf2, "Ra -", kPB_RAm); 302 but->Resize(50, 25); 303 but->Move(25, 210); 304 but->SetToolTipText("Right ascension -= 1'"); 305 but->Associate(this); 306 fList->Add(but); 307 but= new TGTextButton(tf2, "RA +", kPB_RAp); 308 but->Resize(50, 25); 309 but->Move(90, 210); 310 but->SetToolTipText("Right ascension += 1'"); 311 but->Associate(this); 312 fList->Add(but); 313 but= new TGTextButton(tf2, "DEC +", kPB_DECp); 314 but->Resize(50, 25); 315 but->Move(55, 185); 316 but->SetToolTipText("Declination += 1'"); 317 but->Associate(this); 318 fList->Add(but); 319 but= new TGTextButton(tf2, "DEC -", kPB_DECm); 320 but->Resize(50, 25); 321 but->Move(55, 235); 322 but->SetToolTipText("Declination -= 1'"); 323 but->Associate(this); 324 fList->Add(but); 325 326 but= new TGTextButton(tf2, "Calc Zd/Az", kPB_CALCALTAZ); 264 327 but->Resize(80, 25); 265 but->Move( 37, 257);328 but->Move(165, 197); 266 329 but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec."); 330 but->Associate(this); 267 331 fList->Add(but); 268 332 269 but = new TGTextButton(t his, "Set Polaris", kPB_POLARIS);333 but = new TGTextButton(tf4, "TPoint", kPB_TPOINT); 270 334 but->Resize(80, 25); 271 but->Move(37, 288); 272 but->SetToolTipText("Set the actual position as the position of Polaris."); 335 but->Move(25, 197); 336 but->SetToolTipText("Trigger writing a tpoint coordinate pair."); 337 but->Associate(this); 338 fList->Add(but); 339 340 but = new TGTextButton(tf4, "Calib SE", kPB_CALIBSE); 341 but->Resize(80, 25); 342 but->Move(160, 197); 343 but->SetToolTipText("Set SE to given coordinates."); 344 but->Associate(this); 345 fList->Add(but); 346 347 but = new TGTextButton(tf4, "Load", kPB_LoadBending); 348 but->Resize(80, 25); 349 but->Move(25, 227); 350 but->SetToolTipText("Load bending corrections from file 'bending.txt'"); 351 but->Associate(this); 273 352 fList->Add(but); 274 353 … … 278 357 gClient->GetColorByName("Green", color); 279 358 but->SetBackgroundColor(color); 280 but->Move(147, 2 75);359 but->Move(147, 295); 281 360 but->Resize(62, 25); 282 361 but->SetToolTipText("Start a telescope movement."); … … 287 366 gClient->GetColorByName("Red", color); 288 367 but->SetBackgroundColor(color); 289 but->Move(212, 2 75);368 but->Move(212, 295); 290 369 but->Resize(62, 25); 291 370 but->SetToolTipText("Stop any movement of telescope."); 292 371 fList->Add(but); 293 372 373 /* 374 const Double_t ca = 0; // Left-Right Collimation Error 375 const Double_t an = 0; // Azimuth Axis Misalignment (N-S) 376 const Double_t aw = 0; // Azimuth Axis Misalignment (E-W) 377 const Double_t npae = 0; // Az-El Nonperpendicularity 378 const Double_t nrx = 0; // Nasmyth rotator displacement, horizontan 379 const Double_t nry = 0; // Nasmyth rotator displacement, vertical 380 const Double_t crx = 0; // Alt/Az Coude Displacement (N-S) 381 const Double_t cry = 0; // Alt/Az Coude Displacement (E-W) 382 l1 = new TGLabel(tf5, "CA"); 383 l1->SetTextJustify(kTextLeft); 384 l1->Move(x, y+2*h*1.5); 385 l1->MapWindow(); 386 fList->Add(l1); 387 l1 = new TGLabel(tf5, "AN"); 388 l1->SetTextJustify(kTextLeft); 389 l1->Move(x, y+3*h*1.5); 390 l1->MapWindow(); 391 fList->Add(l1); 392 l1 = new TGLabel(tf5, "AW"); 393 l1->SetTextJustify(kTextLeft); 394 l1->Move(x, y+4*h*1.5); 395 l1->MapWindow(); 396 fList->Add(l1); 397 l1 = new TGLabel(tf5, "NPAE"); 398 l1->SetTextJustify(kTextLeft); 399 l1->Move(x, y+5*h*1.5); 400 l1->MapWindow(); 401 fList->Add(l1); 402 l1 = new TGLabel(tf5, "NRX"); 403 l1->SetTextJustify(kTextLeft); 404 l1->Move(x, y+6*h*1.5); 405 l1->MapWindow(); 406 fList->Add(l1); 407 l1 = new TGLabel(tf5, "NRY"); 408 l1->SetTextJustify(kTextLeft); 409 l1->Move(x, y+7*h*1.5); 410 l1->MapWindow(); 411 fList->Add(l1); 412 l1 = new TGLabel(tf5, "CRX"); 413 l1->SetTextJustify(kTextLeft); 414 l1->Move(x, y+8*h*1.5); 415 l1->MapWindow(); 416 fList->Add(l1); 417 l1 = new TGLabel(tf5, "CRY"); 418 l1->SetTextJustify(kTextLeft); 419 l1->Move(x, y+9*h*1.5); 420 l1->MapWindow(); 421 fList->Add(l1); 422 const Double_t ie = 0; // Index Error in Elevation 423 const Double_t ia = 0; // Index Error in Azimuth 424 const Double_t eces = 0; // Elevation Centering Error (sin) 425 const Double_t ecec = 0; // Elevation Centering Error (cos) 426 const Double_t aces = 0; // Azimuth Centering Error (sin) 427 const Double_t acec = 0; // Azimuth Centering Error (cos) 428 l1 = new TGLabel(tf5, "IE"); 429 l1->SetTextJustify(kTextLeft); 430 l1->Move(x+150, y+3*h*1.5); 431 l1->MapWindow(); 432 fList->Add(l1); 433 l1 = new TGLabel(tf5, "IA"); 434 l1->SetTextJustify(kTextLeft); 435 l1->Move(x+150, y+4*h*1.5); 436 l1->MapWindow(); 437 fList->Add(l1); 438 l1 = new TGLabel(tf5, "ECES"); 439 l1->SetTextJustify(kTextLeft); 440 l1->Move(x+150, y+5*h*1.5); 441 l1->MapWindow(); 442 fList->Add(l1); 443 l1 = new TGLabel(tf5, "ECEC"); 444 l1->SetTextJustify(kTextLeft); 445 l1->Move(x+150, y+6*h*1.5); 446 l1->MapWindow(); 447 fList->Add(l1); 448 l1 = new TGLabel(tf5, "ACES"); 449 l1->SetTextJustify(kTextLeft); 450 l1->Move(x+150, y+4*h*1.5); 451 l1->MapWindow(); 452 fList->Add(l1); 453 l1 = new TGLabel(tf5, "IA"); 454 l1->SetTextJustify(kTextLeft); 455 l1->Move(x+150, y+4*h*1.5); 456 l1->MapWindow(); 457 fList->Add(l1); 458 459 460 TGTextEntry *entry = new TGTextEntry(tf5, "****", kEF_BendIE); 461 entry->Associate(this); 462 entry->Move(x+50, y+2*h*1.5); 463 entry->MapWindow(); 464 fList->Add(entry); 465 466 entry = new TGTextEntry(tf5, "*****", kEF_BendIA); 467 entry->Associate(this); 468 entry->Move(x+50, y+3*h*1.5); 469 entry->MapWindow(); 470 fList->Add(entry); 471 */ 294 472 } 295 473 … … 423 601 } 424 602 603 double MGCosy::UpdateTime() 604 { 605 Timer time; 606 time.Now(); 607 608 char text[256]; 609 610 strcpy(text, time.GetTimeStr()); 611 612 char *dot = strrchr(text, '.'); 613 614 if (dot) 615 dot[2] = 0; 616 617 fUtc->SetText(new TGString(text)); 618 619 double mjd = time.CalcMjd(); 620 621 sprintf(text, "%12.6f", mjd); 622 fMjd->SetText(new TGString(text)); 623 624 return mjd; 625 } 626 425 627 void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off, UInt_t stat) 426 628 { 427 fSkyPosition->Update(pos); 629 double mjd = UpdateTime(); 630 fSkyPosition->Update(pos, mjd); 428 631 fAccuracy->Update(pos, acc); 429 632 fVelocity->Update(vel); 430 633 UpdateOffset(off); 634 431 635 432 636 #define kError 0x01 … … 522 726 tm.Now(); 523 727 524 Float_t h = 2.+tm.H()+( 8.+tm.M())/60.;525 RaDec dest(h*15, 1 30);728 Float_t h = 2.+tm.H()+(10.7+tm.M())/60.; 729 RaDec dest(h*15, 129.7); 526 730 527 731 cout << dest.Ra()/15 << "h " << dest.Dec() << "°" << endl; … … 530 734 531 735 int i = 0; 532 while (!HasStopFlag() && i++< 130) // 2.5min736 while (!HasStopFlag() && i++<60) // 2.5min 533 737 usleep(1000000); 534 738 if (HasStopFlag()) … … 537 741 //fQueue->PostMsg(WM_STOP, 0, 0); 538 742 539 ZdAz dest1(fRand.Integer( 56)+5, fRand.Integer(360));743 ZdAz dest1(fRand.Integer(36)+25, fRand.Integer(360)); 540 744 541 745 cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl; … … 544 748 545 749 i = 0; 546 while (!HasStopFlag() && i++< 30) // 30s750 while (!HasStopFlag() && i++<15) // 30s 547 751 usleep(1000000); 548 752 if (HasStopFlag()) … … 581 785 demo.Stop(); 582 786 } 787 788 void MGCosy::StartCalib() 789 { 790 cout << "Start Calibration." << endl; 791 792 XY xy = fCCalib->GetCoordinates(); 793 RaDec pos(xy.X()*360/24, xy.Y()); 794 795 fQueue->PostMsg(WM_CALIB, &pos, sizeof(pos)); 796 797 cout << "PostMsg (WM_Calib) returned." << endl; 798 } 799 800 void MGCosy::StartTPoint() 801 { 802 cout << "Start writing tpoint pair." << endl; 803 804 XY xy = fCCalib->GetCoordinates(); 805 RaDec pos(xy.X()*360/24, xy.Y()); 806 807 //fQueue->PostMsg(WM_TPOINT, &pos, sizeof(pos)); 808 fQueue->Proc(WM_TPOINT, &pos); 809 810 cout << "PostMsg (WM_TPoint) returned." << endl; 811 } 583 812 // 584 813 // ****************************************************************** … … 622 851 return kTRUE; 623 852 case 2: 853 fCRaDec->SetCoordinates(fCCalib->GetCoordinates()); 854 return kTRUE; 855 case 3: 624 856 StartDemo(); 625 857 return kTRUE; … … 637 869 case kPB_CALCALTAZ: 638 870 { 639 SlaStars sla;640 sla.SetMjd2Now();641 642 871 XY xy = fCRaDec->GetCoordinates(); 643 RaDec rd(xy.X()*15., xy.Y()); 644 645 cout << "Ra/Dec: " << rd.Ra() << kDEG << " " << rd.Dec() << kDEG << endl; 646 ZdAz aa=sla.CalcZdAz(rd*kDeg2Rad)*kRad2Deg; 647 cout << "Zd/Az: " << aa.Zd() << kDEG << " " << aa.Az() << kDEG << endl; 872 fQueue->Proc(WM_CALCALTAZ, &xy); 648 873 } 649 874 return kTRUE; 650 875 651 case kPB_POLARIS: 652 fQueue->PostMsg(WM_POLARIS, 0, 0); 876 case kPB_RAp: 877 case kPB_RAm: 878 case kPB_DECp: 879 case kPB_DECm: 880 { 881 XY xy = fCRaDec->GetCoordinates(); 882 switch (mp1) 883 { 884 case kPB_RAp: 885 xy.X(xy.X()+1./60); 886 break; 887 case kPB_RAm: 888 xy.X(xy.X()-1./60); 889 break; 890 case kPB_DECp: 891 xy.Y(xy.Y()+1./60); 892 break; 893 case kPB_DECm: 894 xy.Y(xy.Y()-1./60); 895 break; 896 } 897 RaDec dest(xy.X()*15., xy.Y()); // xy.X() [h]->[ø] 898 fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest)); 899 //fQueue->Proc(WM_NEWTRACK, &dest); 900 fCRaDec->SetCoordinates(xy); 901 902 cout << "New Ra/Dec: " << dest.Ra() << "h " << dest.Dec() << "\xb0" << endl; 903 } 904 return kTRUE; 905 906 case kPB_TPOINT: 907 StartTPoint(); 908 return kTRUE; 909 case kPB_CALIBSE: 910 StartCalib(); 911 return kTRUE; 912 case kPB_LoadBending: 913 fQueue->Proc(WM_LOADBENDING, NULL); 653 914 return kTRUE; 654 915 -
trunk/MagicSoft/Cosy/gui/MGCosy.h
r1275 r1531 47 47 TGLabel *fOffsetAz; 48 48 49 TGLabel *fUtc; 50 TGLabel *fMjd; 51 49 52 MGCoordinates *fCZdAz; 50 53 MGCoordinates *fCRaDec; 54 MGCoordinates *fCCalib; 51 55 52 56 MGSkyPosition *fSkyPosition; … … 74 78 void StartTrack(); 75 79 void StartDemo(); 80 void StartCalib(); 81 void StartTPoint(); 76 82 77 83 void EnableLabel(TGLabel *label, Bool_t stat); 78 84 void UpdateOffset(ZdAz &off); 85 double UpdateTime(); 79 86 80 87 public: -
trunk/MagicSoft/Cosy/gui/MGStarguider.cc
r1111 r1531 1 1 #include "MGStarguider.h" 2 2 3 #include <iostream.h> // cout 4 3 #include <fstream.h> // ifstream 4 #include <iostream.h> // cout 5 # 5 6 #include <TGMenu.h> 6 7 #include <TSystem.h> 7 8 #include <TGSplitter.h> // TGHorizontal3DLine 9 #include <TGTextEntry.h> 8 10 9 11 #include "MGImage.h" … … 15 17 16 18 #include "Filter.h" 19 #include "Filter2.h" 17 20 #include "Writer.h" 18 21 #include "base/timer.h" 22 23 #include "MStarList.h" 19 24 20 25 ClassImp(MGStarguider); … … 23 28 IDM_kFilter, 24 29 IDM_kCatalog, 30 IDM_kStarguider, 25 31 IDM_kStart, 26 32 IDM_kStop, … … 29 35 IDM_kPNG, 30 36 IDM_kOnce, 37 IDM_kUseFileRaDec, 31 38 IDM_kContinous, 32 39 IDM_kRate25ps, … … 44 51 IDM_kLimMag7, 45 52 IDM_kLimMag8, 46 IDM_kLimMag9 53 IDM_kLimMag9, 54 IDM_kPixSize, 55 IDM_kInterpol125, 56 IDM_kInterpol25, 57 IDM_kInterpol10, 58 IDM_kInterpol5, 59 IDM_kInterpol2, 60 IDM_kInterpol1 47 61 }; 48 62 63 #define kZOOM 96 64 49 65 MGStarguider::MGStarguider() 50 : Camera(), TGMainFrame(gClient->GetRoot(), 768, 700) 51 { 66 : Camera(), TGMainFrame(gClient->GetRoot(), 768, 700), fDx((768-kZOOM)/2), fDy((512-kZOOM)/2) 67 { 68 gVirtualX->GrabButton(fId, kButton2, /*kButtonPressMask|kButtonReleaseMask|*/kNone, kNone, kNone, kNone); 69 70 52 71 fList = new MGList; 53 72 … … 65 84 fDisplay->AddEntry("&Filter", IDM_kFilter); 66 85 fDisplay->AddEntry("Sao &Catalog", IDM_kCatalog); 86 fDisplay->AddEntry("Starguider", IDM_kStarguider); 67 87 fDisplay->Associate(this); 68 88 fList->Add(fDisplay); … … 121 141 fSao->SetLimitMag(8.0); 122 142 143 fInterpol = new TGPopupMenu(p); 144 fInterpol->AddEntry("125", IDM_kInterpol125); 145 fInterpol->AddEntry("25", IDM_kInterpol25); 146 fInterpol->AddEntry("10", IDM_kInterpol10); 147 fInterpol->AddEntry("5", IDM_kInterpol5); 148 fInterpol->AddEntry("2", IDM_kInterpol2); 149 fInterpol->AddEntry("Off", IDM_kInterpol1); 150 fInterpol->CheckEntry(IDM_kInterpol25); 151 fInterpol->Associate(this); 152 fList->Add(fInterpol); 153 154 fIntRate = 25; 155 123 156 fSetup = new TGPopupMenu(p); 124 fSetup->AddPopup("Lim. &Magnitude", fLimMag); 157 fSetup->AddPopup("Lim. &Magnitude", fLimMag); 158 fSetup->AddPopup("Disp. &Interpolation", fInterpol); 159 fSetup->AddEntry("Use Ra/Dec from file", IDM_kUseFileRaDec); 125 160 fSetup->Associate(this); 126 161 fList->Add(fSetup); … … 140 175 141 176 fCZdAz = new MGCoordinates(this, kETypeZdAz); 142 fCZdAz->Move(240+12 , fMenu->GetDefaultHeight()+584);177 fCZdAz->Move(240+12+10, fMenu->GetDefaultHeight()+584); 143 178 AddFrame(fCZdAz); 144 179 fList->Add(fCZdAz); 180 181 const Double_t pixsize = 23.4; 182 183 fSao->SetPixSize(pixsize/3600); 184 185 TString txt; 186 txt += pixsize; 187 188 fPixSize = new TGTextEntry(this, txt, IDM_kPixSize); 189 fPixSize->SetAlignment(kTextCenterX); 190 fPixSize->Move(600, fMenu->GetDefaultHeight()+584); 191 AddFrame(fPixSize); 192 fList->Add(fPixSize); 145 193 146 194 // TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this); … … 156 204 fList->Add(fImage); 157 205 206 fZoomImage = new MGImage(this, kZOOM, kZOOM); 207 fZoomImage->Move(768-kZOOM-2, 700-kZOOM-2); 208 AddFrame(fZoomImage); 209 fList->Add(fZoomImage); 210 158 211 // 159 212 // Make everything visible … … 164 217 MapSubwindows(); 165 218 MapWindow(); 166 167 fSao->SetPixSize(0.006);168 219 } 169 220 … … 191 242 } 192 243 244 void MGStarguider::Toggle(TGPopupMenu *p, UInt_t id) 245 { 246 if (p->IsEntryChecked(id)) 247 p->UnCheckEntry(id); 248 else 249 p->CheckEntry(id); 250 251 } 252 193 253 Bool_t MGStarguider::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2) 194 254 { 195 255 switch (GET_MSG(msg)) 196 256 { 257 case kC_TEXTENTRY: 258 if (GET_SUBMSG(msg)==kTE_ENTER) 259 { 260 const Float_t pixsize = atof(fPixSize->GetText()); 261 cout << "Pixel Size changed to " << pixsize << "\"/pix" << endl; 262 fSao->SetPixSize(pixsize/3600); 263 } 264 return kTRUE; 265 197 266 case kC_COMMAND: 198 267 switch (GET_SUBMSG(msg)) … … 202 271 { 203 272 case IDM_kCatalog: 273 Toggle(fDisplay, IDM_kCatalog); 204 274 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 205 fDisplay-> UnCheckEntry(IDM_kCatalog);275 fDisplay->EnableEntry(IDM_kStarguider); 206 276 else 207 fDisplay->CheckEntry(IDM_kCatalog); 277 { 278 fDisplay->UnCheckEntry(IDM_kStarguider); 279 fDisplay->DisableEntry(IDM_kStarguider); 280 } 281 return kTRUE; 282 283 case IDM_kStarguider: 284 Toggle(fDisplay, IDM_kStarguider); 208 285 return kTRUE; 209 286 210 287 case IDM_kFilter: 288 Toggle(fDisplay, IDM_kFilter); 211 289 if (fDisplay->IsEntryChecked(IDM_kFilter)) 212 fDisplay-> UnCheckEntry(IDM_kFilter);290 fDisplay->EnableEntry(IDM_kStarguider); 213 291 else 214 fDisplay->CheckEntry(IDM_kFilter); 292 { 293 fDisplay->UnCheckEntry(IDM_kStarguider); 294 fDisplay->DisableEntry(IDM_kStarguider); 295 } 296 return kTRUE; 297 298 case IDM_kUseFileRaDec: 299 Toggle(fSetup, IDM_kUseFileRaDec); 215 300 return kTRUE; 216 301 … … 283 368 return kTRUE; 284 369 370 case IDM_kInterpol125: 371 case IDM_kInterpol25: 372 case IDM_kInterpol10: 373 case IDM_kInterpol5: 374 case IDM_kInterpol2: 375 case IDM_kInterpol1: 376 for (int i=IDM_kInterpol125; i<=IDM_kInterpol1; i++) 377 if (mp1==i) 378 fInterpol->CheckEntry(i); 379 else 380 fInterpol->UnCheckEntry(i); 381 switch (mp1) 382 { 383 case IDM_kInterpol1: 384 fIntRate = 1; 385 return kTRUE; 386 case IDM_kInterpol2: 387 fIntRate = 2; 388 return kTRUE; 389 case IDM_kInterpol5: 390 fIntRate = 5; 391 return kTRUE; 392 case IDM_kInterpol10: 393 fIntRate = 10; 394 return kTRUE; 395 case IDM_kInterpol25: 396 fIntRate = 25; 397 return kTRUE; 398 case IDM_kInterpol125: 399 fIntRate = 125; 400 return kTRUE; 401 } 402 return kTRUE; 403 285 404 case IDM_kLimMag3: 286 405 case IDM_kLimMag4: … … 303 422 break; 304 423 } 424 305 425 return kTRUE; 306 426 } 307 427 428 void MGStarguider::GetCoordinates() 429 { 430 XY xy = fCRaDec->GetCoordinates(); 431 432 if (fSetup->IsEntryChecked(IDM_kUseFileRaDec)) 433 { 434 ifstream fin("coordinates.txt"); 435 if (!fin) 436 cout << "Error: Cannot open 'coordinates.txt' using fall back solution." << endl; 437 else 438 fin >> xy; 439 } 440 441 fCRaDec->SetCoordinates(xy); 442 fRaDec->Set(xy.X()*360/24, xy.Y()); 443 } 444 445 void MGStarguider::CalcTrackingError(MStarList &spots, MStarList &stars) 446 { 447 if (stars.GetRealEntries() < 3) 448 { 449 cout << "Sorry, less than 3 stars in FOV!" << endl; 450 return; 451 } 452 453 if (spots.GetRealEntries() < 1) 454 { 455 cout << "Sorry, less than 1 detected spot in FOV!" << endl; 456 return; 457 } 458 459 Int_t idx = 0; 460 461 MStarList sortedspots; 462 463 MStar *star; 464 MStar *spot; 465 MStarListIter NextStar(&stars); 466 MStarListIter NextSpot(&spots); 467 468 while ((spot=NextSpot())) 469 { 470 AltAz aa = fSao->CalcAltAzFromPix(spot->GetX(), spot->GetY()); 471 spot->Set(aa.Az(), aa.Alt()); 472 } 473 474 while ((star=NextStar())) 475 { 476 AltAz aa = fSao->CalcAltAzFromPix(star->GetX(), star->GetY()); 477 star->Set(aa.Az(), aa.Alt()); 478 479 const double aaz = star->GetX(); 480 const double dphi2 = aaz/2.; 481 const double cos2 = cos(dphi2)*cos(dphi2); 482 const double sin2 = sin(dphi2)*sin(dphi2); 483 484 Double_t min = 800; 485 486 NextSpot.Reset(); 487 while ((spot=NextSpot())) 488 { 489 const double pzd = TMath::Pi()/2-spot->GetY(); 490 const double azd = TMath::Pi()/2-star->GetY(); 491 492 const double d = cos(azd)*cos2 - cos(2*pzd+azd)*sin2; 493 494 const Double_t dist = acos(d); 495 496 if (dist>=min) 497 continue; 498 499 min = dist; 500 sortedspots.AddAt(idx, spot->GetX(), spot->GetY(), spot->GetMag()); 501 } 502 if (min>768) 503 { 504 cout << "ERROR!!!!!!!!" << endl; 505 return; 506 } 507 idx++; 508 } 509 510 // 511 // Now we have in sortedspots the entries with the shortest distances 512 // to the corresponding ones in stars. 513 // Now calculate the tracking error. 514 // 515 NextStar.Reset(); 516 MStarListIter NextSpot2(&sortedspots); 517 518 Double_t meanx=0; 519 Double_t meany=0; 520 521 while ((star=NextStar())) 522 { 523 spot = NextSpot2(); 524 525 meanx += star->GetX() - spot->GetX(); 526 meany += star->GetY() - spot->GetY(); 527 } 528 529 meanx /= idx; 530 meany /= idx; 531 532 cout << "Tracking Error: dAlt=" << meany*180/TMath::Pi(); 533 cout << "° dAz=" << meanx*180/TMath::Pi() << "° (calculated"; 534 cout << " with " << idx << " stars/spots)" << endl; 535 } 536 308 537 void MGStarguider::ProcessFrame(const unsigned long n, byte *img, struct timeval *tm) 309 538 { 310 311 539 if (!fWrite->IsEntryEnabled(IDM_kStart) && 312 540 (!(n%fWrtRate) || fWriteType->IsEntryChecked(IDM_kOnce))) … … 315 543 { 316 544 static int num = 0; 317 318 545 char name[80]; 319 sprintf(name, "pix/file%04d.png", num );546 sprintf(name, "pix/file%04d.png", num++); 320 547 Writer::Png(name, img, tm); 321 548 } … … 325 552 static int num = 0; 326 553 char name[80]; 327 sprintf(name, "pix/file%04d.ppm", num );554 sprintf(name, "pix/file%04d.ppm", num++); 328 555 Writer::Ppm(name, img); 329 556 } … … 333 560 } 334 561 335 if (!(n%25)) 336 { 337 cout << "Img: " << n << endl; 338 562 static float myimg[768*576]; 563 564 for (int i=0; i<768*576; i++) 565 myimg[i] += img[i]; 566 567 if (n%fIntRate) 568 return; 569 570 cout << "Img: " << n << endl; 571 572 byte c[768*576]; 573 for (int i=0; i<768*576; i++) 574 c[i] = (byte)(myimg[i]/fIntRate+.5); 575 576 MStarList spots; 577 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 578 Filter2::Execute(spots, c); 579 else 339 580 if (fDisplay->IsEntryChecked(IDM_kFilter)) 340 Filter::Execute(img); 341 342 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 343 { 344 byte cimg[768*576]; 345 346 XY xy = fCRaDec->GetCoordinates(); 347 348 fRaDec->Set(xy.X(), xy.Y()); 349 350 Timer time(tm); 351 fSao->GetImg(img, cimg, time.CalcMjd(), *fRaDec); 352 fImage->DrawColImg(img, cimg); 353 354 fCZdAz->SetCoordinates(fSao->GetZdAz()); 355 } 356 else 357 fImage->DrawImg(img); 358 } 359 360 } 581 Filter::Execute(c); 582 583 byte zimg[kZOOM*kZOOM]; 584 for (int y=0; y<kZOOM; y++) 585 for (int x=0; x<kZOOM; x++) 586 zimg[x+y*kZOOM] = c[(fDx+(x-kZOOM/2)/2)+(fDy+(y-kZOOM/2)/2)*768]; 587 588 fZoomImage->DrawImg(zimg); 589 590 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 591 { 592 byte cimg[768*576]; 593 594 GetCoordinates(); 595 596 Timer time(tm); 597 598 MStarList stars; 599 fSao->GetStars(stars, time.CalcMjd(), *fRaDec); 600 fSao->GetImg(c, cimg, stars); 601 //fSao->GetImg(c, cimg, time.CalcMjd(), *fRaDec); 602 603 fImage->DrawColImg(c, cimg); 604 605 fCZdAz->SetCoordinates(fSao->GetZdAz()); 606 607 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 608 CalcTrackingError(spots, stars); 609 } 610 else 611 fImage->DrawImg(c); 612 613 memset(myimg, 0, 768*576*sizeof(float)); 614 } 615 616 Bool_t MGStarguider::HandleDoubleClick(Event_t *event) 617 { 618 const Int_t w = fImage->GetWidth(); 619 const Int_t h = fImage->GetHeight(); 620 const Int_t x = fImage->GetX(); 621 const Int_t y = fImage->GetY(); 622 623 if (!(event->fX>x && event->fX<x+w && event->fY>y && event->fY<y+h)) 624 return kTRUE; 625 626 Int_t dx = event->fX-x; 627 Int_t dy = event->fY-y; 628 629 if (dx<kZOOM/4) dx=kZOOM/4; 630 if (dy<kZOOM/4) dy=kZOOM/4; 631 if (dx>766-kZOOM/2) dx=766-kZOOM/4; 632 if (dy>510-kZOOM/2) dy=510-kZOOM/4; 633 634 fDx = dx; 635 fDy = dy; 636 637 cout << "New coordinates for zoom: " << fDx << " " << fDy << endl; 638 639 return kTRUE; 640 } -
trunk/MagicSoft/Cosy/gui/MGStarguider.h
r1111 r1531 12 12 #include "MGImage.h" 13 13 14 class AltAz; 14 15 class RaDec; 15 16 16 17 class TGMenuBar; 17 18 class TGPopupMenu; 19 class TGTextEntry; 18 20 19 21 class MGImage; … … 21 23 22 24 class StarCatalog; 25 class MStarList; 23 26 24 27 class MGStarguider : public Camera, public TGMainFrame … … 29 32 TGMenuBar *fMenu; 30 33 MGImage *fImage; 34 MGImage *fZoomImage; 31 35 32 36 TGPopupMenu *fDisplay; … … 35 39 TGPopupMenu *fWriteType; 36 40 TGPopupMenu *fWriteRate; 41 TGPopupMenu *fInterpol; 37 42 TGPopupMenu *fSetup; 38 43 TGPopupMenu *fLimMag; … … 41 46 MGCoordinates *fCZdAz; 42 47 48 TGTextEntry *fPixSize; 49 43 50 StarCatalog *fSao; 44 51 45 52 RaDec *fRaDec; 46 53 54 Int_t fDx; 55 Int_t fDy; 56 57 int fIntRate; 47 58 int fWrtRate; 48 59 49 60 void SetPixSize(const double pixsize); 61 void Toggle(TGPopupMenu *p, UInt_t id); 62 void GetCoordinates(); 63 void CalcTrackingError(MStarList &, MStarList &); 50 64 51 65 public: … … 59 73 60 74 Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2); 75 Bool_t HandleDoubleClick(Event_t *event); 61 76 62 77 //
Note:
See TracChangeset
for help on using the changeset viewer.