Changeset 2518 for trunk/MagicSoft/Cosy/gui
- Timestamp:
- 11/17/03 13:50:48 (21 years ago)
- Location:
- trunk/MagicSoft/Cosy/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
r2278 r2518 149 149 } 150 150 151 void MGAccuracy::InitBar() 152 { 153 fBar = new TLine(0, 0, 0, 0); 154 fBar->SetLineColor(kBlack); 155 fBar->SetLineStyle(1); 156 fBar->SetLineWidth(5); 157 fBar->Draw(); 158 159 fList->Add(fBar); 160 } 161 151 162 void MGAccuracy::InitCross() 152 163 { … … 176 187 InitText(); 177 188 InitCross(); 189 InitBar(); 178 190 179 191 InitCanvas(); … … 215 227 double dist = acos(d); 216 228 217 dist *= 3600./d2r; 229 dist *= 3600./d2r; // [min] 218 230 219 231 int rs = (int)floor(fmod(dist, 60.)); 232 220 233 dist /= 60.; 221 234 int rm = (int)dist;//floor(fmod(dist, 60.)); … … 225 238 226 239 fTxt->SetText(fTxt->GetX(), fTxt->GetY(), txt); 240 241 fBar->SetX2(dist*60); 242 if (dist*16384<1*360*60) 243 fBar->SetLineColor(kGreen); 244 else 245 if (dist*16384<2*360*60) 246 fBar->SetLineColor(kYellow); 247 else 248 fBar->SetLineColor(kRed); 227 249 } 228 250 -
trunk/MagicSoft/Cosy/gui/MGAccuracy.h
r1111 r2518 24 24 TText *fTxt; 25 25 26 TLine *fBar; 27 26 28 void DrawCoordinateSystem(); 27 29 28 30 void InitText(); 29 31 void InitCross(); 32 void InitBar(); 30 33 31 34 void UpdateText(Float_t zd, Float_t x, Float_t y); -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r2514 r2518 53 53 kPB_CALCALTAZ, 54 54 kPB_TPOINT, 55 kPB_ENDSWITCH, 55 56 kPB_START, 56 57 kPB_DISPLAY1, … … 270 271 fStopped->SetBackgroundColor(color); 271 272 272 fError ->Move (10, 25);273 fMoving ->Move (10, 25+20);274 fTracking->Move (10, 25+40);275 fStopping->Move (10, 25+60);276 fStopped ->Move (10, 25+80);277 fAvailMac1->Move (10, 25+120);278 fAvailMac2->Move (10, 25+140);273 fError ->MoveResize(10, 25, 60, 20); 274 fMoving ->MoveResize(10, 25+20, 60, 20); 275 fTracking->MoveResize(10, 25+40, 60, 20); 276 fStopping->MoveResize(10, 25+60, 60, 20); 277 fStopped ->MoveResize(10, 25+80, 60, 20); 278 fAvailMac1->MoveResize(10, 25+120, 60, 20); 279 fAvailMac2->MoveResize(10, 25+140, 60, 20); 279 280 //fAvailMac3->Move(10, 25+160); 280 fAvailSe1->Move(10, 25+180); 281 fAvailSe2->Move(10, 25+200); 282 fAvailSe3->Move(10, 25+220); 283 284 fError ->Resize(60, 20); 285 fMoving ->Resize(60, 20); 286 fTracking->Resize(60, 20); 287 fStopping->Resize(60, 20); 288 fStopped ->Resize(60, 20); 289 fAvailMac1->Resize(60, 20); 290 fAvailMac2->Resize(60, 20); 291 //fAvailMac3->Resize(60, 20); 292 fAvailSe1->Resize(60, 20); 293 fAvailSe2->Resize(60, 20); 294 fAvailSe3->Resize(60, 20); 281 fAvailSe1->MoveResize(10, 25+200, 60, 20); 282 fAvailSe2->MoveResize(10, 25+220, 60, 20); 283 fAvailSe3->MoveResize(10, 25+180, 60, 20); 295 284 296 285 fList->Add(fError); … … 486 475 487 476 but= new TGTextButton(tf2, "Ra -", kPB_RAm); 488 but->Resize(50, 25); 489 but->Move(25, 210); 477 but->MoveResize(25, 210, 50, 25); 490 478 but->SetToolTipText("Right ascension -= 1'"); 491 479 but->Associate(this); 492 480 fList->Add(but); 493 481 but= new TGTextButton(tf2, "RA +", kPB_RAp); 494 but->Resize(50, 25); 495 but->Move(90, 210); 482 but->MoveResize(90, 210, 50, 25); 496 483 but->SetToolTipText("Right ascension += 1'"); 497 484 but->Associate(this); 498 485 fList->Add(but); 499 486 but= new TGTextButton(tf2, "DEC +", kPB_DECp); 500 but->Resize(50, 25); 501 but->Move(55, 185); 487 but->MoveResize(55, 185, 50, 25); 502 488 but->SetToolTipText("Declination += 1'"); 503 489 but->Associate(this); 504 490 fList->Add(but); 505 491 but= new TGTextButton(tf2, "DEC -", kPB_DECm); 506 but->Resize(50, 25); 507 but->Move(55, 235); 492 but->MoveResize(55, 235, 50, 25); 508 493 but->SetToolTipText("Declination -= 1'"); 509 494 but->Associate(this); … … 511 496 512 497 but = new TGTextButton(tf1, "Move'n'Track", kPB_TRACKPOS); 513 but->Resize(100, 25); 514 but->Move(25, 242); 498 but->MoveResize(25, 242, 100, 25); 515 499 but->SetToolTipText("Move telescope to a Zd/Az position and start tracking."); 516 500 but->Associate(this); … … 518 502 519 503 but= new TGTextButton(tf2, "Calc Zd/Az", kPB_CALCALTAZ); 520 but->Resize(80, 25); 521 but->Move(165, 197); 504 but->MoveResize(165, 197, 80, 25); 522 505 but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec."); 523 506 but->Associate(this); … … 525 508 526 509 but = new TGTextButton(tf4, "TPoint", kPB_TPOINT); 527 but->Resize(50, 25); 528 but->Move(176/*231*/, 213); 510 but->MoveResize(139, 213, 62, 25); 529 511 but->SetToolTipText("Trigger writing a tpoint coordinate pair."); 512 but->Associate(this); 513 fList->Add(but); 514 515 but = new TGTextButton(tf4, "Endswitch", kPB_ENDSWITCH); 516 but->MoveResize(204, 213, 62, 25); 517 but->SetToolTipText("Print coordinates in 'Endswitch-Position' units."); 530 518 but->Associate(this); 531 519 fList->Add(but); … … 533 521 #ifdef EXPERT 534 522 but= new TGTextButton(tf1, "New Position", kPB_SavePreDef); 535 but->Resize(80, 25); 536 but->Move(165, 197); 523 but->MoveResize(165, 197, 80, 25); 537 524 but->SetToolTipText("Save new predefined position."); 538 525 but->Associate(this); … … 540 527 541 528 but= new TGTextButton(tf4, "New", kPB_SaveStar); 542 but->Resize(60, 23); 543 but->Move(211, 69); 529 but->MoveResize(211, 69, 60, 23); 544 530 but->SetToolTipText("Save new Source position."); 545 531 but->Associate(this); … … 547 533 548 534 but = new TGTextButton(tf5, "Display", kPB_DISPLAY1); 549 but->Resize(80, 25); 550 but->Move(160, 197); 535 but->MoveResize(160, 197, 80, 25); 551 536 but->SetToolTipText("Display Histogram."); 552 537 but->Associate(this); … … 554 539 555 540 but = new TGTextButton(tf6, "Display", kPB_DISPLAY2); 556 but->Resize(80, 25); 557 but->Move(160, 197); 541 but->MoveResize(160, 197, 80, 25); 558 542 but->SetToolTipText("Display Histogram."); 559 543 but->Associate(this); … … 561 545 562 546 but = new TGTextButton(tf4, "Load", kPB_LoadBending); 563 but->Resize(50, 25); 564 but->Move(151, 185); 547 but->ResizeMove(151, 185, 50, 25); 565 548 but->SetToolTipText("Load bending corrections from file 'bending.txt'"); 566 549 but->Associate(this); … … 568 551 569 552 but = new TGTextButton(tf4, "Reset", kPB_ResetBending); 570 but->Resize(50, 25); 571 but->Move(206, 185); 553 but->MoveResize(206, 185, 50, 25); 572 554 but->SetToolTipText("Reset bending correction (coefficients=0)"); 573 555 but->Associate(this); … … 575 557 576 558 but= new TGTextButton(tf4, "Zd -", kPB_ZDm); 577 but->Resize(50, 25); 578 but->Move(25, 210); 559 but->MoveResize(25, 210, 50, 25); 579 560 but->SetToolTipText("Zenith Distance -= 1SE"); 580 561 but->Associate(this); 581 562 fList->Add(but); 582 563 but= new TGTextButton(tf4, "Zd +", kPB_ZDp); 583 but->Resize(50, 25); 584 but->Move(90, 210); 564 but->MoveResize(90, 210, 50, 25); 585 565 but->SetToolTipText("Zenith Distance += 1SE"); 586 566 but->Associate(this); 587 567 fList->Add(but); 588 568 but= new TGTextButton(tf4, "Az +", kPB_AZp); 589 but->Resize(50, 25); 590 but->Move(55, 185); 569 but->MoveResize(55, 185, 50, 25); 591 570 but->SetToolTipText("Azimuth += 1SE"); 592 571 but->Associate(this); 593 572 fList->Add(but); 594 573 but= new TGTextButton(tf4, "Az -", kPB_AZm); 595 but->Resize(50, 25); 596 but->Move(55, 235); 574 but->MoveResize(55, 235, 50, 25); 597 575 but->SetToolTipText("Azimuth -= 1SE"); 598 576 but->Associate(this); … … 605 583 gClient->GetColorByName("Green", color); 606 584 but->SetBackgroundColor(color); 607 but->Move(147, 295); 608 but->Resize(62, 25); 585 but->MoveResize(147, 295, 62, 25); 609 586 but->SetToolTipText("Start a telescope movement."); 610 587 fList->Add(but); … … 614 591 gClient->GetColorByName("Red", color); 615 592 but->SetBackgroundColor(color); 616 but->Move(212, 295); 617 but->Resize(62, 25); 593 but->MoveResize(212, 295, 62, 25); 618 594 but->SetToolTipText("Stop any movement of telescope."); 619 595 fList->Add(but); … … 989 965 void MGCosy::UpdateZdAz(ZdAz &soll) 990 966 { 991 soll *= kRad2Deg;992 993 967 static Int_t zd=~0; 994 968 static Int_t az=~0; … … 996 970 char text[21]; 997 971 998 ZdAz test = soll*600; 999 972 UShort_t z, a; 973 Double_t zm, am; 974 Char_t sz, sa; 975 976 Slalib::Rad2Dm(soll.Zd(), sz, z, zm); 977 Slalib::Rad2Dm(soll.Az(), sa, a, am); 978 979 const ZdAz test = soll*kRad2Deg*600; 1000 980 if (zd!=(int)test.Zd()) 1001 981 { 1002 982 zd = (int)test.Zd(); 1003 sprintf(text, "%c%dd %.1fm", s oll.Zd()<0?'-':'+', abs((int)soll.Zd()), 0.1*(abs((int)test.Zd())%600));983 sprintf(text, "%c%dd %.1fm", sz, z, zm); 1004 984 fZdSoll->SetText(new TGString(text)); 1005 985 } … … 1007 987 { 1008 988 az = (int)test.Az(); 1009 sprintf(text, "%c%dd %.1fm", s oll.Az()<0?'-':'+' , abs((int)soll.Az()), 0.1*(abs((int)test.Az())%600));989 sprintf(text, "%c%dd %.1fm", sa, a, am); 1010 990 fAzSoll->SetText(new TGString(text)); 1011 991 } … … 1113 1093 // TGMainFrame::CloseWindow(); 1114 1094 cout << "Closing window - waiting until all nodes are stopped." << endl; 1115 fQueue->PostMsg(WM_QUIT , 0, 0);1095 fQueue->PostMsg(WM_QUIT); 1116 1096 cout << "Closing window - done." << endl; 1117 1097 // gApplication->Terminate(0); … … 1376 1356 StopDemo(); 1377 1357 #endif 1378 fQueue->PostMsg(WM_STOP , 0, 0);1358 fQueue->PostMsg(WM_STOP); 1379 1359 if (fTab->GetCurrent()==3) 1380 fQueue->Proc(WM_TESTSE , NULL);1360 fQueue->Proc(WM_TESTSE); 1381 1361 if (fTab->GetCurrent()==4) 1382 fQueue->Proc(WM_GEAR , NULL);1362 fQueue->Proc(WM_GEAR); 1383 1363 cout << "PostMsg (WM_Stop) returned." << endl; 1384 1364 return kTRUE; … … 1458 1438 StartTPoint(); 1459 1439 return kTRUE; 1440 1441 case kPB_ENDSWITCH: 1442 fQueue->Proc(WM_ENDSWITCH); 1443 return kTRUE; 1460 1444 /* 1461 1445 case kPB_CALIBSE: … … 1464 1448 */ 1465 1449 case kPB_LoadBending: 1466 fQueue->Proc(WM_LOADBENDING , NULL);1450 fQueue->Proc(WM_LOADBENDING); 1467 1451 return kTRUE; 1468 1452 case kPB_ResetBending: 1469 fQueue->Proc(WM_RESETBENDING , NULL);1453 fQueue->Proc(WM_RESETBENDING); 1470 1454 return kTRUE; 1471 1455 /* … … 1479 1463 case kPB_DISPLAY1: 1480 1464 case kPB_DISPLAY2: 1481 fQueue->PostMsg(WM_DISPLAY , 0, 0);1465 fQueue->PostMsg(WM_DISPLAY); 1482 1466 return kTRUE; 1483 1467 … … 1493 1477 case IDM_EXIT: 1494 1478 cout << "IDM_EXIT: Posting WM_QUIT." << endl; 1495 fQueue->PostMsg(WM_QUIT , 0, 0);1479 fQueue->PostMsg(WM_QUIT); 1496 1480 cout << "IDM_EXIT: WM_QUIT done." << endl; 1497 1481 //cout << "Idm_Exit." << endl; -
trunk/MagicSoft/Cosy/gui/MGImage.cc
r2514 r2518 9 9 #include "MGImage.h" 10 10 11 #include <iostream.h> 12 #include <pthread.h> 13 14 #include <X11/Xlib.h> 15 16 #include <TTimer.h> 17 #include <TSystem.h> 18 #include <TVirtualX.h> 11 #include <iostream> 12 19 13 #include <TGX11.h> 14 #include <TMutex.h> 20 15 21 16 ClassImp(MGImage); 17 18 using namespace std; 22 19 /* 23 20 class MyX11 : public TGX11 … … 41 38 // Creat drawing semaphore 42 39 // 43 fMuxPixmap = new pthread_mutex_t; 44 pthread_mutex_init((pthread_mutex_t*)fMuxPixmap, NULL); 40 fMuxPixmap = new TMutex; 45 41 46 42 Resize(w, h); … … 58 54 MGImage::~MGImage() 59 55 { 60 pthread_mutex_lock((pthread_mutex_t*)fMuxPixmap);56 fMuxPixmap->Lock(); 61 57 62 58 cout << "Deleting MGImage..." << endl; … … 66 62 gVirtualX->DeleteImage((Drawable_t)fImage); 67 63 68 pthread_mutex_destroy((pthread_mutex_t*)fMuxPixmap);64 delete fMuxPixmap; 69 65 70 66 cout << "MGImage destroyed." << endl; … … 73 69 void MGImage::DoRedraw() 74 70 { 75 pthread_mutex_lock((pthread_mutex_t*)fMuxPixmap);71 fMuxPixmap->Lock(); 76 72 77 73 if (TestBit(kNeedRedraw)) … … 81 77 } 82 78 83 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap);79 fMuxPixmap->UnLock(); 84 80 } 85 81 … … 91 87 while (s<e) 92 88 { 89 // 11111100 11111000 11111100 93 90 *d++ = (*s&0xfc) | (*s&0xf8)<<5 | (*s&0xfc)<<11; 94 91 s++; … … 107 104 *d++ = *s++; 108 105 d++; 106 } 107 } 108 109 void MGImage::DrawImg(const byte *buffer) 110 { 111 if (fMuxPixmap->TryLock()==13) 112 return; 113 114 switch (gVirtualX->GetDepth()) 115 { 116 case 8: 117 memcpy(fImage->data, buffer, fWidth*fHeight); 118 break; 119 case 16: 120 DrawImg16((unsigned short*)fImage->data, (char*)buffer, (char*)(buffer+fWidth*fHeight)); 121 break; 122 case 24: 123 DrawImg24(fImage->data, (char*)buffer, (char*)(buffer+fWidth*fHeight)); 124 break; 125 default: 126 cout << "Sorry, " << gVirtualX->GetDepth() << "bit color depth not yet implemented." << endl; 127 } 128 129 SetBit(kNeedRedraw); 130 131 fMuxPixmap->UnLock(); 132 } 133 134 void MGImage::DrawColImg16(unsigned short *d, char *s1, char *s2, char *e) 135 { 136 // d=destination, s1=source1, s2=source2, e=end 137 // d: rrrrrggg gggbbbbb 138 // s2: 00rrggbb 139 // 140 while (s1<e) 141 { 142 if (*s2) 143 { 144 // 00000011 00001100 00110000 145 *d++ = (*s2&0x3) | (*s2&0xb)<<3 | (*s2&0x30)<<7; 146 s1++; 147 } 148 else 149 { 150 // 11111100 11111000 11111100 151 *d++ = (*s1&0xfc) | (*s1&0xf8)<<5 | (*s1&0xfc)<<11; 152 s2++; 153 } 109 154 } 110 155 } … … 134 179 } 135 180 136 void MGImage::DrawImg(const byte *buffer)137 {138 if (pthread_mutex_trylock((pthread_mutex_t*)fMuxPixmap))139 return;140 141 switch (gVirtualX->GetDepth())142 {143 case 8:144 memcpy(fImage->data, buffer, fWidth*fHeight);145 break;146 case 16:147 DrawImg16((unsigned short*)fImage->data, (char*)buffer, (char*)(buffer+fWidth*fHeight));148 break;149 case 24:150 DrawImg24(fImage->data, (char*)buffer, (char*)(buffer+fWidth*fHeight));151 break;152 default:153 cout << "Sorry, " << gVirtualX->GetDepth() << "bit color depth not yet implemented." << endl;154 }155 156 SetBit(kNeedRedraw);157 158 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap);159 }160 161 181 void MGImage::DrawColImg(const byte *gbuf, const byte *cbuf) 162 182 { 163 if ( pthread_mutex_trylock((pthread_mutex_t*)fMuxPixmap))183 if (fMuxPixmap->TryLock()==13) 164 184 return; 165 185 … … 179 199 switch (gVirtualX->GetDepth()) 180 200 { 201 case 16: 202 DrawColImg16((unsigned short*)fImage->data, (char*)gbuf, (char*)cbuf, (char*)(gbuf+fWidth*fHeight)); 203 break; 181 204 case 24: 182 DrawColImg 32(fImage->data, (char*)gbuf, (char*)cbuf, (char*)(gbuf+fWidth*fHeight));205 DrawColImg24(fImage->data, (char*)gbuf, (char*)cbuf, (char*)(gbuf+fWidth*fHeight)); 183 206 break; 184 207 default: … … 188 211 SetBit(kNeedRedraw); 189 212 190 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap);191 } 213 fMuxPixmap->UnLock(); 214 } -
trunk/MagicSoft/Cosy/gui/MGImage.h
r2514 r2518 15 15 #endif 16 16 17 class T Timer;17 class TMutex; 18 18 19 19 typedef unsigned char byte; … … 29 29 UInt_t fHeight; 30 30 31 void *fMuxPixmap; //! test 32 33 TTimer *fTimer; 31 TMutex *fMuxPixmap; //! test 34 32 35 33 enum { kNeedRedraw = BIT(17) }; … … 37 35 void DrawImg16(unsigned short *d, char *s, char *e); 38 36 void DrawImg24(char *d, char *s, char *e); 37 void DrawColImg16(unsigned short *d, char *s1, char *s2, char *e); 39 38 void DrawColImg24(char *d, char *s1, char *s2, char *e); 40 39
Note:
See TracChangeset
for help on using the changeset viewer.