source: branches/FACT++_lidctrl_new_eth/drive/MStarguider.cc@ 19225

Last change on this file since 19225 was 18627, checked in by tbretz, 10 years ago
Disentengle from root and Mars were possible, clean up of gui from all obsolete stuff
File size: 39.5 KB
Line 
1#undef EXPERT
2#define FACT
3
4#include "MStarguider.h"
5
6#ifdef HAVE_PNG
7#include <png.h>
8#endif
9#include <iostream>
10#include <fstream>
11
12#include <math.h>
13
14#include <TEnv.h>
15#include <TSystem.h>
16
17#include <TGMenu.h>
18#include <TGLabel.h>
19#include <TGButton.h>
20#include <TGSplitter.h> // TGHorizontal3DLine
21#include <TGTextEntry.h>
22#include <TGLayout.h>
23
24#include "MCaos.h"
25#include "MGImage.h"
26#include "Camera.h"
27#include "../src/DimSetup.h"
28#include "Led.h"
29//#include "Writer.h"
30#include "FilterLed.h"
31//#include "CaosFilter.h"
32
33using namespace std;
34
35enum {
36 IDM_kFilter,
37 IDM_kFindStar,
38 IDM_kCaosFilter,
39 IDM_kStarguider,
40 IDM_kStretch,
41 IDM_kInput,
42 IDM_kSetup,
43 IDM_kCut,
44 IDM_kInterpol250,
45 IDM_kInterpol125,
46 IDM_kInterpol50,
47 IDM_kInterpol25,
48 IDM_kInterpol10,
49 IDM_kInterpol5,
50 IDM_kInterpol2,
51 IDM_kInterpol1,
52 //IDM_kCaosPrintRings,
53 //IDM_kCaosPrintLeds,
54 IDM_kCaosWriteStart,
55 IDM_kCaosWriteStop,
56 IDM_kResetHistograms,
57};
58
59Bool_t MStarguider::HandleTimer(TTimer *)
60{
61 if (IsMapped())
62 fImage->DoRedraw();
63
64 return kTRUE;
65}
66
67#define kZOOM 96
68/*
69XY MStarguider::GetCoordinates() const
70{
71 return fPZdAz->GetCoordinates();
72}
73*/
74void MStarguider::InitGui(Int_t)
75{
76 //fList = new MGList;
77 //fList->SetOwner();
78
79/*
80 const TGWindow *p=gClient->GetRoot();
81
82 fChannel = new TGPopupMenu(p);
83 fChannel->AddEntry("Starfield Camera", IDM_kChannel1);
84 fChannel->AddEntry("TPoint Camera", IDM_kChannel2);
85 //fChannel->AddEntry("Read from File", IDM_kChannel3);
86 //if (channel<0)
87 // fChannel->CheckEntry(IDM_kChannel3);
88 //else
89 fChannel->CheckEntry(channel==0?IDM_kChannel1:IDM_kChannel2);
90 fChannel->Associate(this);
91 fList->Add(fChannel);
92
93 fFileType = new TGPopupMenu(p);
94 fFileType->AddEntry("PP&M", IDM_kPPM);
95 fFileType->AddEntry("&PNG", IDM_kPNG);
96 fFileType->CheckEntry(IDM_kPNG);
97 fFileType->Associate(this);
98 fList->Add(fFileType);
99
100 fWriteType = new TGPopupMenu(p);
101 fWriteType->AddEntry("&Once", IDM_kOnce);
102 fWriteType->AddEntry("&Continous", IDM_kContinous);
103 fWriteType->CheckEntry(IDM_kOnce);
104 fWriteType->Associate(this);
105 fList->Add(fWriteType);
106
107 fWriteRate = new TGPopupMenu(p);
108 fWriteRate->AddEntry("25/s", IDM_kRate25ps);
109 fWriteRate->AddEntry("5/s", IDM_kRate5ps);
110 fWriteRate->AddEntry("1s", IDM_kRate1s);
111 fWriteRate->AddEntry("5s", IDM_kRate5s);
112 fWriteRate->AddEntry("30s", IDM_kRate30s);
113 fWriteRate->AddEntry("1min", IDM_kRate1m);
114 fWriteRate->AddEntry("5min", IDM_kRate5m);
115 fWriteRate->CheckEntry(IDM_kRate1m);
116 fWriteRate->Associate(this);
117 fList->Add(fWriteRate);
118
119 fWrtRate = 25*60;
120
121 fLimMag = new TGPopupMenu(p);
122 fLimMag->AddEntry("3", IDM_kLimMag3);
123 fLimMag->AddEntry("4", IDM_kLimMag4);
124 fLimMag->AddEntry("5", IDM_kLimMag5);
125 fLimMag->AddEntry("6", IDM_kLimMag6);
126 fLimMag->AddEntry("7", IDM_kLimMag7);
127 fLimMag->AddEntry("8", IDM_kLimMag8);
128 fLimMag->AddEntry("9", IDM_kLimMag9);
129 fLimMag->CheckEntry(IDM_kLimMag9);
130 fLimMag->Associate(this);
131 fList->Add(fLimMag);
132 */
133 //fSao->SetLimitMag(9.0);
134
135 const TGWindow *p=gClient->GetRoot();
136
137 fInterpol = new TGPopupMenu(p);
138 fInterpol->AddEntry("250", IDM_kInterpol250);
139 fInterpol->AddEntry("125", IDM_kInterpol125);
140 fInterpol->AddEntry("50", IDM_kInterpol50);
141 fInterpol->AddEntry("25", IDM_kInterpol25);
142 fInterpol->AddEntry("10", IDM_kInterpol10);
143 fInterpol->AddEntry("5", IDM_kInterpol5);
144 fInterpol->AddEntry("2", IDM_kInterpol2);
145 fInterpol->AddEntry("Off", IDM_kInterpol1);
146 fInterpol->Associate(this);
147 //fList->Add(fInterpol);
148
149 TString disp=gVirtualX->DisplayName();
150 cout << "Display: " << disp << endl;
151 if (disp.First(':')>=0)
152 disp=disp(0, disp.First(':'));
153
154 if (disp.IsNull() || disp==(TString)"localhost")
155 {
156 fInterpol->CheckEntry(IDM_kInterpol25);
157 fIntRate = 25;
158 }
159 else
160 {
161 fInterpol->CheckEntry(IDM_kInterpol125);
162 fIntRate = 125;
163 }
164
165/*
166 fCaosPrint = new TGPopupMenu(p);
167 fCaosPrint->AddEntry("&Leds", IDM_kCaosPrintLeds);
168 fCaosPrint->AddEntry("&Rings", IDM_kCaosPrintRings);
169 fCaosPrint->Associate(this);
170 fList->Add(fCaosPrint);
171
172 fCaosWrite = new TGPopupMenu(p);
173 fCaosWrite->AddEntry("&Start", IDM_kCaosWriteStart);
174 fCaosWrite->AddEntry("Sto&p", IDM_kCaosWriteStop);
175 fCaosWrite->DisableEntry(IDM_kCaosWriteStop);
176 fCaosWrite->Associate(this);
177 fList->Add(fCaosWrite);
178
179 fCaosAnalyse = new TGPopupMenu(p);
180 fCaosAnalyse->AddEntry("S&tart Analysis", IDM_kCaosAnalStart);
181 fCaosAnalyse->AddEntry("St&op Analysis", IDM_kCaosAnalStop);
182 fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop);
183 fCaosAnalyse->Associate(this);
184 fList->Add(fCaosAnalyse);
185*/
186 fMenu = new TGMenuBar(this, 0, 0, kHorizontalFrame);
187 fDisplay = fMenu->AddPopup("&Display");
188 //fMode = fMenu->AddPopup("&Mode");
189 //fWritePictures = fMenu->AddPopup("&WritePics");
190 fSetup = fMenu->AddPopup("&Setup");
191 //fOperations = fMenu->AddPopup("&Operations");
192 fMenu->Resize(fMenu->GetDefaultSize());
193 AddFrame(fMenu);
194
195 //
196 // Create Menu for MStarguider Display
197 //
198 //fDisplay = new MMGPopupMenu(p);
199 fDisplay->AddEntry("&Filter", IDM_kFilter);
200 fDisplay->AddEntry("Stretch", IDM_kStretch);
201 fDisplay->AddSeparator();
202 fDisplay->AddEntry("Find &Star", IDM_kFindStar);
203 fDisplay->AddEntry("C&aos Filter", IDM_kCaosFilter);
204 //fDisplay->AddSeparator();
205 //if (channel>=0)
206 // fDisplay->AddPopup("&Input", fChannel);
207 // fDisplay->CheckEntry(IDM_kStretch);
208 fDisplay->CheckEntry(IDM_kFindStar);
209 fDisplay->CheckEntry(IDM_kCaosFilter);
210 fDisplay->Associate(this);
211
212 //fMode->AddEntry("Tpoint", IDM_kTpointMode);
213 //fMode->Associate(this);
214/*
215 fWritePictures->AddEntry("&Start", IDM_kStart);
216 fWritePictures->AddEntry("Sto&p", IDM_kStop);
217 fWritePictures->AddSeparator();
218 //fWritePictures->AddPopup("File &Type", fFileType);
219 fWritePictures->AddPopup("&Write Type", fWriteType);
220 fWritePictures->AddPopup("Write &Rate", fWriteRate);
221 fWritePictures->DisableEntry(IDM_kStop);
222 fWritePictures->Associate(this);
223 */
224 fSetup->AddPopup("Disp. &Interpolation", fInterpol);
225 fSetup->Associate(this);
226
227/*
228 fCaOs = new TGPopupMenu(p);
229 //fCaOs->AddPopup("&Write", fCaosWrite);
230 fCaOs->AddPopup("&Print", fCaosPrint);
231 //fCaOs->AddPopup("&Analyse", fCaosAnalyse);
232 fCaOs->Associate(this);
233 fList->Add(fCaOs);
234*/
235 //RA,Dec for catalog
236 /*
237 fCRaDec = new MGCoordinates(this, kETypeRaDec);
238 fCRaDec->Move(4, fMenu->GetDefaultHeight()+584);
239 AddFrame(fCRaDec);
240
241 //telescope position
242 fCZdAz = new MGCoordinates(this, kETypeZdAz, 2);
243 fCZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+597);
244 AddFrame(fCZdAz);
245
246 //starguider position
247 fPZdAz = new MGCoordinates(this, kETypeZdAz, 2);
248 fPZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+640);
249 AddFrame(fPZdAz);
250
251 //mispointing
252 fDZdAz = new MGCoordinates(this, kETypeZdAz, 2);
253 fDZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+683);
254 AddFrame(fDZdAz);
255
256 fSZdAz = new MGCoordinates(this, kETypeZdAz, 2);
257 fSZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+795);
258 AddFrame(fSZdAz);
259
260 fGNumStars = new MGNumStars(this, 235);
261 fGNumStars->DrawText("Number of stars");
262 fGNumStars->Move(278, fMenu->GetDefaultHeight()+713);
263 fList->Add(fGNumStars);
264
265 fTPoint = new TGTextButton(this, "TPoint");
266 //fTPoint->Move(4, fMenu->GetDefaultHeight()+785);
267 fTPoint->Move(170, fMenu->GetDefaultHeight()+785);
268 fTPoint->AllowStayDown(kTRUE);
269 AddFrame(fTPoint);
270
271 fStargTPoint = new TGTextButton(this, "StargTPoint");
272 fStargTPoint->Move(170, fMenu->GetDefaultHeight()+785);
273 fStargTPoint->AllowStayDown(kTRUE);
274 AddFrame(fStargTPoint);
275
276 fFps = new TGLabel(this, "---fps");
277 fFps->SetTextJustify(kTextRight);
278 fFps->Move(650-495, fMenu->GetDefaultHeight()+714+23);
279 AddFrame(fFps);
280
281 fPosZoom = new TGLabel(this, "(----, ----) ----.--d/----.--d");
282 fPosZoom->SetTextJustify(kTextLeft);
283 fPosZoom->Move(4, fMenu->GetDefaultHeight()+765);
284 AddFrame(fPosZoom);
285
286 fSkyBright = new TGLabel(this, "Sky Brightness: --- ");
287 fSkyBright->SetTextJustify(kTextLeft);
288 fSkyBright->Move(4, fMenu->GetDefaultHeight()+785);
289 AddFrame(fSkyBright);
290
291 TGLabel *l = new TGLabel(this, "deg");
292 l->SetTextJustify(kTextLeft);
293 l->Move(606-412, fMenu->GetDefaultHeight()+669);
294 AddFrame(l);
295
296 l = new TGLabel(this, "arcsec/pix");
297 l->SetTextJustify(kTextLeft);
298 l->Move(606-412, fMenu->GetDefaultHeight()+692);
299 AddFrame(l);
300
301 l = new TGLabel(this, "sigma");
302 l->SetTextJustify(kTextLeft);
303 l->Move(606-412, fMenu->GetDefaultHeight()+715);
304 AddFrame(l);
305
306 fCZdAzText = new TGLabel(this, "Zd/Az telescope pointing at");
307 fCZdAzText->SetTextJustify(kTextLeft);
308 fCZdAzText->Move(240+12+20+7, fMenu->GetDefaultHeight()+584-5);
309 AddFrame(fCZdAzText);
310
311 fPZdAzText = new TGLabel(this, "Zd/Az starguider pointing at");
312 fPZdAzText->SetTextJustify(kTextLeft);
313 fPZdAzText->Move(240+12+20+7, fMenu->GetDefaultHeight()+630+20-5-23);
314 AddFrame(fPZdAzText);
315
316 fDZdAzText = new TGLabel(this, "Zd/Az mispointing");
317 fDZdAzText->SetTextJustify(kTextLeft);
318 fDZdAzText->Move(240+12+20+7, fMenu->GetDefaultHeight()+676+2*20-5-46);
319 AddFrame(fDZdAzText);
320*/
321 // Set input box for rotation angle
322 /*
323 fAngle = new TGTextEntry(this, " ", IDM_kAngle);
324 fAngle->SetAlignment(kTextCenterX);
325 fAngle->Move(547-410, fMenu->GetDefaultHeight()+667);
326 AddFrame(fAngle);
327
328 //SetRotationAngle(-0.2);
329
330 // Set input box for pixel size
331 fPixSize = new TGTextEntry(this, " ", IDM_kPixSize);
332 fPixSize->SetAlignment(kTextCenterX);
333 fPixSize->Move(547-410, fMenu->GetDefaultHeight()+690);
334 AddFrame(fPixSize);
335 */
336 //SetPixSize(48.9);
337
338 // Set input box for cleaning cut
339 //fCut = new TGTextEntry(this, " ", IDM_kCut);
340 //fCut->SetAlignment(kTextCenterX);
341 //fCut->Move(547-410, fMenu->GetDefaultHeight()+713);
342 //AddFrame(fCut);
343
344 //SetCut(3.0);
345
346 // TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this);
347 // AddFrame(fLineSep, new TGLayoutHints (kLHintsNormal | kLHintsExpandX));
348 // fList->Add(fLineSep);
349
350 //
351 // Create Image Display
352 /*
353 fZoomImage = new MGImage(this, kZOOM, kZOOM);
354 // fZoomImage->Move(768-kZOOM-2, 700-kZOOM-2);
355 fZoomImage->Move(4, 700-kZOOM-2+85);
356 AddFrame(fZoomImage);
357 */
358 fImage = new MGImage(this, 768, 576);
359 fImage->Move(0, fMenu->GetDefaultHeight());
360 AddFrame(fImage);
361
362 const Int_t w = 768;
363 const Int_t h = 576;
364 SetWMSizeHints(w, h, w, h, 1, 1); // set the smallest and biggest size of the Main frame
365
366 //
367 // Make everything visible
368 //
369 SetWindowName("TPoint Main Window");
370 SetIconName("TPoint");
371
372 MapSubwindows();
373 //fTPoint->UnmapWindow();
374 //fStargTPoint->UnmapWindow();
375 //fGStarg->UnmapWindow();
376 //fGNumStars->UnmapWindow();
377 //fCRaDec->UnmapWindow();
378 //fCZdAz->UnmapWindow();
379 //fCZdAzText->UnmapWindow();
380 //fPZdAz->UnmapWindow();
381 //fPZdAzText->UnmapWindow();
382 //fDZdAz->UnmapWindow();
383 //fDZdAzText->UnmapWindow();
384 //fSZdAz->UnmapWindow();
385 //fSkyBright->UnmapWindow();
386 MapWindow();
387
388
389 //IconifyWindow();
390
391 //------------------------------------------------------------
392 // XY xy(3.819444, 24.05333);
393 // fCRaDec->SetCoordinates(xy);
394 // fRaDec->Set(xy.X()*360/24, xy.Y());
395 //------------------------------------------------------------
396}
397
398MStarguider::MStarguider(Int_t channel) : TGMainFrame(gClient->GetRoot(), 768, 840),
399fDimData("TPOINT/DATA", "D:11", (void*)NULL, 0),
400fDimTPoint("TPOINT/EXECUTE", "", this),
401fDimScreenshot("TPOINT/SCREENSHOT", "B:1;C", this),
402fRadius(200), fFindStarCut(2.), fFindStarBox(30), fTPointMode(0)
403{
404 cout << " #### FIXME: Make MCaos Thread safe!" << endl;
405
406 // This means that all objects added with AddFrame are deleted
407 // automatically, including all LayoutHints.
408 SetCleanup();
409
410 fCaos = new MCaos;
411 fCaos->ReadResources("leds_fact.txt");
412
413 InitGui(channel);
414
415 fTimer=new TTimer(this, 1000/25); // 40ms
416 fTimer->TurnOn();
417
418 gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kTRUE);
419
420 fGetter = new Camera(*this, channel);
421
422 DimClient::setNoDataCopy();
423 DimServer::start("TPOINT");
424}
425
426MStarguider::~MStarguider()
427{
428 DimServer::stop();
429
430 fGetter->ExitLoop();
431 delete fGetter;
432
433 gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kFALSE);
434
435 fTimer->TurnOff();
436 delete fTimer;
437
438 delete fInterpol;
439
440 //delete fList;
441 delete fCaos;
442
443 cout << "Camera Display destroyed." << endl;
444}
445
446/*
447void MStarguider::SetupEnv(TEnv &env)
448{
449 fCaos->ReadEnv(env, "TPointLeds", kTRUE);
450 //fStargCaos->ReadEnv(env, "StarguiderLeds", kTRUE);
451
452 //SetRotationAngle(env.GetValue("Starguider.RotationAngle", fSao->GetRotationAngle()));
453 //SetCut(env.GetValue("Starguider.CleaningLevel", atof(fCut->GetText())));
454
455 //SetPixSize(env.GetValue("StarguiderLeds.ArcsecPerPixel", fSao->GetPixSize()));
456
457 fRadius = env.GetValue("Leds.Radius", fRadius);
458
459 fStarguiderW = env.GetValue("Starguider.Width", fStarguiderW);
460 fStarguiderH = env.GetValue("Starguider.Height", fStarguiderH);
461 fStarguiderX = env.GetValue("Starguider.X", fStarguiderX);
462 fStarguiderY = env.GetValue("Starguider.Y", fStarguiderY);
463
464 fSkyOffsetX = env.GetValue("Starguider.SkyOffsetX", fSkyOffsetX);
465 fSkyOffsetY = env.GetValue("Starguider.SkyOffsetY", fSkyOffsetY);
466
467 fFindStarBox = env.GetValue("FindStar.SizeBox", fFindStarBox);
468 fFindStarCut = env.GetValue("FindStar.CleaningLevel", fFindStarCut);
469}
470*/
471
472void MStarguider::Layout()
473{
474 // Resize(GetDefaultSize());
475}
476
477void MStarguider::CloseWindow()
478{
479 cout << "EventDisplay::CloseWindow: Exit Application Loop." << endl;
480
481 //fClient.ExitLoop();
482 // cout << "FIXME: ExitLoop not called!!!!!!" << endl;
483 fGetter->ExitLoop();
484 gSystem->ExitLoop();
485}
486
487void MStarguider::SwitchOff(TGPopupMenu *p, UInt_t id)
488{
489 p->UnCheckEntry(id);
490 p->DisableEntry(id);
491}
492
493/*
494void MStarguider::SetChannel()
495{
496 if (fChannel->IsEntryChecked(IDM_kChannel3))
497 {
498 if (dynamic_cast<PngReader*>(fGetter)==0)
499 {
500 delete fGetter;
501 fGetter=new PngReader(*this);
502 }
503 }
504 else
505 {
506 const Int_t ch = fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1;
507 if (dynamic_cast<Camera*>(fGetter)==0)
508 {
509 delete fGetter;
510 fGetter = new Camera(*this, ch);
511 }
512 else
513 fGetter->SetChannel(ch);
514 }
515}*/
516
517void MStarguider::Toggle(TGPopupMenu *p, UInt_t id)
518{
519 if (p->IsEntryChecked(id))
520 p->UnCheckEntry(id);
521 else
522 p->CheckEntry(id);
523}
524
525
526Bool_t MStarguider::ProcessMessage(Long_t msg, Long_t mp1, Long_t)
527{
528 switch (GET_MSG(msg))
529 {
530 case kC_TEXTENTRY:
531 if (GET_SUBMSG(msg)==kTE_ENTER)
532 switch (mp1)
533 {
534 /*
535 case IDM_kPixSize:
536 {
537 const Float_t pixsize = atof(fPixSize->GetText());
538 gLog << all << "Pixel Size changed to " << pixsize << "\"/pix" << endl;
539 fSao->SetPixSize(pixsize);
540 return kTRUE;
541 }
542 case IDM_kAngle:
543 {
544 const Float_t angle = atof(fAngle->GetText());
545 gLog << all << "Rotation Angle changed to " << angle << "deg" << endl;
546 fSao->SetRotationAngle(angle);
547 return kTRUE;
548 }
549 case IDM_kCut:
550 {
551 const Float_t cut = atof(fCut->GetText());
552 gLog << all << "Starguider cleaning level changed to " << cut << " sigma." << endl;
553 return kTRUE;
554 }*/
555 }
556 return kTRUE;
557
558 case kC_COMMAND:
559 switch (GET_SUBMSG(msg))
560 {
561 case kCM_MENU:
562 switch (mp1)
563 {
564/*
565 case IDM_kTpointMode:
566 Toggle(fMode, IDM_kTpointMode);
567
568 if (fMode->IsEntryChecked(IDM_kTpointMode))
569 {
570 //unchecking not needed items
571 //general
572 SwitchOff(fDisplay, IDM_kFilter);
573 SwitchOff(fChannel, IDM_kChannel3);
574
575 //from starguider
576 //SwitchOff(fDisplay, IDM_kStargCaosFilter);
577 //SwitchOff(fDisplay, IDM_kCatalog);
578 //SwitchOff(fDisplay, IDM_kStarguider);
579 //ToggleStarguider();
580 //fMode->UnCheckEntry(IDM_kStarguiderMode);
581 //SwitchOff(fOperations, IDM_kStargAnalysis);
582 //ToggleStargAnalysis();
583
584 //switch camera
585 SwitchOff(fChannel, IDM_kChannel1);
586 fChannel->CheckEntry(IDM_kChannel2);
587
588 SetChannel();
589
590 //checking needed items
591 fDisplay->UnCheckEntry(IDM_kStretch);
592 fDisplay->CheckEntry(IDM_kCaosFilter);
593 ToggleCaosFilter();
594 fDisplay->CheckEntry(IDM_kFindStar);
595 fTPoint->MapWindow();
596 }
597 else
598 {
599 //enable
600 //starguider items
601 //fDisplay->EnableEntry(IDM_kStargCaosFilter);
602 //fDisplay->EnableEntry(IDM_kCatalog);
603 //fDisplay->EnableEntry(IDM_kStarguider);
604 //fOperations->EnableEntry(IDM_kStargAnalysis);
605
606 //general
607 fDisplay->EnableEntry(IDM_kFilter);
608 fChannel->EnableEntry(IDM_kChannel1);
609 fChannel->EnableEntry(IDM_kChannel3);
610
611 //tpoint
612 fDisplay->UnCheckEntry(IDM_kCaosFilter);
613 ToggleCaosFilter();
614 fDisplay->UnCheckEntry(IDM_kFindStar);
615 fTPoint->UnmapWindow();
616 }
617 return kTRUE;
618*/
619 case IDM_kFilter:
620 Toggle(fDisplay, IDM_kFilter);
621 return kTRUE;
622
623 case IDM_kFindStar:
624 Toggle(fDisplay, IDM_kFindStar);
625 //ToggleFindStar();
626 return kTRUE;
627
628 case IDM_kStretch:
629 Toggle(fDisplay, IDM_kStretch);
630 return kTRUE;
631
632 case IDM_kCaosFilter:
633 Toggle(fDisplay, IDM_kCaosFilter);
634 //ToggleCaosFilter();
635 return kTRUE;
636/*
637 case IDM_kCaosPrintLeds:
638 case IDM_kCaosPrintRings:
639 Toggle(fCaosPrint, mp1);
640 return kTRUE;
641
642 case IDM_kCaosAnalStart:
643 fCaosAnalyse->DisableEntry(IDM_kCaosAnalStart);
644 fCaosAnalyse->EnableEntry(IDM_kCaosAnalStop);
645 //fCaos->InitHistograms();
646 return kTRUE;
647
648 case IDM_kCaosAnalStop:
649 fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop);
650 fCaosAnalyse->EnableEntry(IDM_kCaosAnalStart);
651 fCaos->ShowHistograms();
652 fCaos->DeleteHistograms();
653 return kTRUE;
654
655 case IDM_kCaosWriteStart:
656 fCaosWrite->DisableEntry(IDM_kCaosWriteStart);
657 fCaosWrite->EnableEntry(IDM_kCaosWriteStop);
658 fCaos->OpenFile();
659 return kTRUE;
660
661 case IDM_kCaosWriteStop:
662 fCaosWrite->DisableEntry(IDM_kCaosWriteStop);
663 fCaosWrite->EnableEntry(IDM_kCaosWriteStart);
664 fCaos->CloseFile();
665 return kTRUE;
666
667 case IDM_kStart:
668 fWritePictures->DisableEntry(IDM_kStart);
669 fWritePictures->EnableEntry(IDM_kStop);
670 return kTRUE;
671
672 case IDM_kStop:
673 fWritePictures->DisableEntry(IDM_kStop);
674 fWritePictures->EnableEntry(IDM_kStart);
675 return kTRUE;
676
677 case IDM_kPNG:
678 fFileType->CheckEntry(IDM_kPNG);
679 fFileType->UnCheckEntry(IDM_kPPM);
680 return kTRUE;
681
682 case IDM_kPPM:
683 fFileType->CheckEntry(IDM_kPPM);
684 fFileType->UnCheckEntry(IDM_kPNG);
685 return kTRUE;
686
687 case IDM_kOnce:
688 fWriteType->CheckEntry(IDM_kOnce);
689 fWriteType->UnCheckEntry(IDM_kContinous);
690 return kTRUE;
691
692 case IDM_kContinous:
693 fWriteType->CheckEntry(IDM_kContinous);
694 fWriteType->UnCheckEntry(IDM_kOnce);
695 return kTRUE;
696
697 case IDM_kRate25ps:
698 case IDM_kRate5ps:
699 case IDM_kRate1s:
700 case IDM_kRate5s:
701 case IDM_kRate30s:
702 case IDM_kRate1m:
703 case IDM_kRate5m:
704 for (int i=IDM_kRate25ps; i<=IDM_kRate5m; i++)
705 if (mp1==i)
706 fWriteRate->CheckEntry(i);
707 else
708 fWriteRate->UnCheckEntry(i);
709 switch (mp1)
710 {
711 case IDM_kRate25ps:
712 fWrtRate = 1;
713 return kTRUE;
714 case IDM_kRate5ps:
715 fWrtRate = 5;
716 return kTRUE;
717 case IDM_kRate1s:
718 fWrtRate = 25;
719 return kTRUE;
720 case IDM_kRate5s:
721 fWrtRate = 5*25;
722 return kTRUE;
723 case IDM_kRate30s:
724 fWrtRate = 30*25;
725 return kTRUE;
726 case IDM_kRate1m:
727 fWrtRate = 60*25;
728 return kTRUE;
729 case IDM_kRate5m:
730 fWrtRate = 5*60*25;
731 return kTRUE;
732 }
733 return kTRUE;
734
735 case IDM_kChannel1:
736 case IDM_kChannel2:
737 {
738 const Int_t ch0 = fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1;
739 const Int_t ch1 = mp1==IDM_kChannel1 ? 0 : 1;
740
741 if (ch0==ch1)
742 return kTRUE;
743
744 fChannel->CheckEntry (ch1==0?IDM_kChannel1:IDM_kChannel2);
745 fChannel->UnCheckEntry(ch1==1?IDM_kChannel1:IDM_kChannel2);
746
747 SetChannel();
748 }
749 return kTRUE;
750 */
751 case IDM_kInterpol250:
752 case IDM_kInterpol125:
753 case IDM_kInterpol50:
754 case IDM_kInterpol25:
755 case IDM_kInterpol10:
756 case IDM_kInterpol5:
757 case IDM_kInterpol2:
758 case IDM_kInterpol1:
759 for (int i=IDM_kInterpol250; i<=IDM_kInterpol1; i++)
760 if (mp1==i)
761 fInterpol->CheckEntry(i);
762 else
763 fInterpol->UnCheckEntry(i);
764 switch (mp1)
765 {
766 case IDM_kInterpol1:
767 fIntRate = 1;
768 return kTRUE;
769 case IDM_kInterpol2:
770 fIntRate = 2;
771 return kTRUE;
772 case IDM_kInterpol5:
773 fIntRate = 5;
774 return kTRUE;
775 case IDM_kInterpol10:
776 fIntRate = 10;
777 return kTRUE;
778 case IDM_kInterpol25:
779 fIntRate = 25;
780 return kTRUE;
781 case IDM_kInterpol50:
782 fIntRate = 50;
783 return kTRUE;
784 case IDM_kInterpol125:
785 fIntRate = 125;
786 return kTRUE;
787 case IDM_kInterpol250:
788 fIntRate = 250;
789 return kTRUE;
790 }
791 return kTRUE;
792 }
793 break;
794 }
795 break;
796 }
797
798 return kTRUE;
799}
800/*
801void MStarguider::DrawZoomImage(const byte *img)
802{
803 byte zimg[kZOOM*kZOOM];
804 for (int y=0; y<kZOOM; y++)
805 for (int x=0; x<kZOOM; x++)
806 zimg[x+y*kZOOM] = img[(fDx+(x-kZOOM/2)/2)+(fDy+(y-kZOOM/2)/2)*768];
807
808 fZoomImage->DrawImg(zimg);
809}
810
811void MStarguider::DrawCosyImage(const byte *img)
812{
813 if (!fCosy)
814 return;
815
816 byte simg[(768/2-1)*(576/2-1)];
817 for (int y=0; y<576/2-1; y++)
818 for (int x=0; x<768/2-1; x++)
819 simg[x+y*(768/2-1)] = ((unsigned int)img[2*x+2*y*768]+img[2*x+2*y*768+1]+img[2*x+2*(y+1)*768]+img[2*x+2*(y+1)*768+1])/4;
820
821 fCosy->GetWin()->GetImage()->DrawImg(simg);
822}
823
824Led MStarguider::FindStar(const FilterLed &f, const FilterLed &f2, const Ring &center, Int_t numleds, Int_t numrings)
825{
826 // Get tracking coordinates
827 //const XY xy = fCRaDec->GetCoordinates(); // [h, deg]
828
829 if (center.GetX()<=0 && center.GetY()<=0)
830 {
831 cout << "Couldn't determine center of the camera." << endl;
832 //if (fTPoint->IsDown() && fCosy && fCosy->GetDriveCom())
833 // fCosy->GetDriveCom()->SendTPoint(false, 'T', fTPointStarMag, fTPointStarName, AltAz(), ZdAz(), xy, 0, 0, t, center, Led(), numleds, numrings); // Report
834 return;
835 }
836
837 // Try to find the star
838 Leds leds;
839 f.FindStar(leds, (Int_t)center.GetX(), (Int_t)center.GetY(), true);
840
841 // Check whether star found
842 if (leds.size()==0)
843 {
844 cout << "No star found." << endl;
845 //if (fTPoint->IsDown() && fCosy && fCosy->GetDriveCom())
846 // fCosy->GetDriveCom()->SendTPoint(false, 'T', fTPointStarMag, fTPointStarName, AltAz(), ZdAz(), xy, 0, 0, t, center, Led(), numleds, numrings); // Report
847 return;
848 }
849
850 cout << "Found star @ " << flush;
851
852 const Led &star = leds.front();
853
854 star.Print();
855 f2.MarkPoint(star.GetX(), star.GetY(), 2<<2);
856
857 return star;
858
859 const RaDec rd(xy.X()*MAstro::HorToRad(), xy.Y()*TMath::DegToRad());
860
861 // Initialize Star Catalog on the camera plane
862 MGeomCamMagic geom;
863 MAstroCamera ac;
864 ac.SetGeom(geom);
865 ac.SetRadiusFOV(3);
866 //ac.SetObservatory(*fSao);
867 ac.SetTime(t);
868 ac.SetRaDec(rd.Ra(), rd.Dec());
869
870 // Convert from Pixel to millimeter (1pix=2.6mm) [deg/pix / deg/mm = mm/pix]
871 // Correct for abberation.
872 const double sec_per_pix = 45.311;
873 const double mm_to_deg = 0.011693;
874 const Double_t conv = sec_per_pix/3600/mm_to_deg / 1.0713;
875
876 // Adapt coordinate system (GUIs and humans are counting Y in different directions)
877 const Double_t dx = (star->GetX()-center.GetX())*conv;
878 const Double_t dy = (center.GetY()-star->GetY())*conv;
879
880 // Convert offset from camera plane into local ccordinates
881 Double_t dzd, daz;
882 ac.GetDiffZdAz(dx, dy, dzd, daz);
883
884 ZdAz zdaz(dzd,daz);
885
886 // Check TPoint data set request
887 if (!fMode->IsEntryChecked(IDM_kTpointMode) || !fTPoint->IsDown())
888 return;
889
890 // If no file open: open new file
891 if (!fOutTp)
892 {
893 //
894 // open tpoint file
895 //
896
897 const TString name = MCosy::GetFileName("tpoint", "tpoint", "txt");
898 cout << "TPoint File ********* " << name << " ********** " << endl;
899
900 fOutTp = new ofstream(name);
901 *fOutTp << "Magic Model TPOINT data file" << endl;
902 *fOutTp << ": ALTAZ" << endl;
903 *fOutTp << "49 48 0 ";
904 *fOutTp << t << endl;
905 // temp(°C) pressure(mB) height(m) humidity(1) wavelength(microm) troplapserate(K/m
906 }
907
908 // Output Ra/Dec the drive system thinks that it is currently tracking
909 //cout << "TPoint Star: " << xy.X() << "h " << xy.Y() << "°" << endl;
910
911 // From the star position in the camera we calculate the Alt/Az
912 // position we are currently tracking (real pointing position)
913 fSao->SetMjd(t.GetMjd());
914 AltAz za0 = fSao->CalcAltAz(rd)*kRad2Deg;
915
916 //ZdAz za0 = fSao->GetZdAz();
917 za0 -= AltAz(-dzd, daz);
918 fAltAzOffsetFromTp = AltAz(-dzd, daz);
919 fTimeFromTp=t;
920
921 // From the Shaftencoders we get the current 'pointing' position
922 // as it is seen by the drive system (system pointing position)
923 const ZdAz za1 = fCosy->GetSePos()*360; // [deg]
924
925
926 // Write real pointing position
927 //cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl;
928 *fOutTp << setprecision(7) << za0.Az() << " " << za0.Alt() << " ";
929
930 // Write system pointing position
931 //cout << " SE-Pos: " << 90-za1.Zd() << "° " << za1.Az() << "°" << endl;
932 *fOutTp << fmod(za1.Az()+360, 360) << " " << 90-za1.Zd();
933
934 *fOutTp << " " << xy.X() << " " << xy.Y();
935 *fOutTp << " " << -dzd << " " << -daz;
936 *fOutTp << " " << setprecision(11) << t.GetMjd();
937 *fOutTp << " " << setprecision(4) << center.GetMag();
938 *fOutTp << " " << star->GetMag();
939 *fOutTp << " " << center.GetX() << " " << center.GetY();
940 *fOutTp << " " << star->GetX() << " " << star->GetY();
941 *fOutTp << " " << numleds << " " << numrings;
942 *fOutTp << " 0 0 0";
943 *fOutTp << " " << fTPointStarMag << " " << fTPointStarName;
944 *fOutTp << endl;
945
946 gLog << all << "TPoint successfully taken." << endl;
947
948 MLog &outrep = *fCosy->GetOutRep();
949 if (outrep.Lock("MStarguider::FindStar"))
950 {
951 outrep << "FINDSTAR-REPORT 00 " << MTime(-1) << " " << setprecision(7);
952 outrep << 90-za0.Alt() << " " << za0.Az() << " ";
953 outrep << za1.Zd() << " " << za1.Az() << " ";
954 outrep << xy.X() << " " << xy.Y() << " ";
955 outrep << -dzd << " " << -daz << " ";
956 outrep << star->GetX() << " " << star->GetY() << " ";
957 outrep << center.GetX() << " " << center.GetY() << " ";
958 outrep << dx/conv << " " << dy/conv << " " << star->GetMag();
959 outrep << setprecision(11) << t.GetMjd() << endl;
960 outrep.UnLock("MStarguider::FindStar");
961 }
962
963// return zdaz;
964
965 if (!fCosy)
966 return;
967
968 MDriveCom *com = fCosy->GetDriveCom();
969 if (!com)
970 return;
971
972 com->SendTPoint(true, 'T', fTPointStarMag, fTPointStarName, za0, za1, xy, -dzd, -daz, t, center, *star, numleds, numrings); // Report
973}
974*/
975
976void MStarguider::WritePNG(const char *name, const byte *gbuf, const byte *cbuf)
977{
978 string fname(name);
979 if (fname.size()<4 || fname.compare(fname.size()-4,4, ".png")==0)
980 fname += ".png";
981
982 cout << "Writing PNG '" << fname << "'" << endl;
983
984#ifdef HAVE_PNG
985 //
986 // open file
987 //
988 FILE *fd = fopen(fname.c_str(), "w");
989 if (!fd)
990 {
991 cout << "Warning: Cannot open file for writing." << endl;
992 return;
993 }
994
995 //
996 // allocate memory
997 //
998 png_structp fPng = png_create_write_struct(PNG_LIBPNG_VER_STRING,
999 NULL, NULL, NULL);
1000
1001 if (!fPng)
1002 {
1003 cout << "Warning: Unable to create PNG structure" << endl;
1004 fclose(fd);
1005 return;
1006 }
1007
1008
1009 png_infop fInfo = png_create_info_struct(fPng);
1010
1011 if (!fInfo)
1012 {
1013 cout << "Warning: Unable to create PNG info structure" << endl;
1014 png_destroy_write_struct (&fPng, NULL);
1015 fclose(fd);
1016 return;
1017 }
1018
1019 fInfo->width = 768;
1020 fInfo->height = 576;
1021 fInfo->bit_depth = 8;
1022 fInfo->color_type = PNG_COLOR_TYPE_RGB;
1023// fInfo->color_type = PNG_COLOR_TYPE_GRAY;
1024
1025 //
1026 // set jump-back point in case of errors
1027 //
1028 if (setjmp(fPng->jmpbuf))
1029 {
1030 cout << "longjmp Warning: PNG encounterd an error!" << endl;
1031 png_destroy_write_struct (&fPng, &fInfo);
1032 fclose(fd);
1033 return;
1034 }
1035
1036 //
1037 // connect file to PNG-Structure
1038 //
1039 png_init_io(fPng, fd);
1040
1041 // png_set_compression_level (fPng, Z_BEST_COMPRESSION);
1042
1043 //
1044 // Write header
1045 //
1046 png_write_info(fPng, fInfo);
1047
1048 png_byte buf[768*576*3];
1049
1050 png_byte *d = buf;
1051 const byte *g = gbuf;
1052 const byte *c = cbuf;
1053
1054 // d=destination, s1=source1, s2=source2, e=end
1055 while (d<buf+768*576*3)
1056 {
1057 if (fScreenshotColor && *c)
1058 {
1059 *d++ = ((*c>>4)&0x3)*85;
1060 *d++ = ((*c>>2)&0x3)*85;
1061 *d++ = ((*c++ )&0x3)*85;
1062 g++;
1063 }
1064 else
1065 {
1066 *d++ = *g;
1067 *d++ = *g;
1068 *d++ = *g++;
1069 c++;
1070 }
1071 }
1072
1073 //
1074 // Write bitmap data
1075 //
1076 for (unsigned int y=0; y<768*576*3; y+=768*3)
1077 png_write_row (fPng, buf+y);
1078
1079 //
1080 // Write footer
1081 //
1082 png_write_end (fPng, fInfo);
1083
1084 //
1085 // free memory
1086 //
1087 png_destroy_write_struct (&fPng, &fInfo);
1088
1089 fclose(fd);
1090#else
1091 cout << "Sorry, no png support compiled into tpoint." << endl;
1092#endif
1093}
1094
1095bool MStarguider::Interpolate(const unsigned long n, byte *img) const
1096{
1097 if (fIntRate<=1)
1098 return true;
1099
1100 const int rate = fTPointMode>0 ? 5*25 : fIntRate;
1101
1102 static unsigned short myimg[768*576];
1103
1104 unsigned short *f = myimg;
1105
1106 const byte *end = img+768*576;
1107
1108 if (n%rate)
1109 {
1110 while (img<end)
1111 *f++ += *img++;
1112 return false;
1113 }
1114 else
1115 {
1116 while (img<end)
1117 {
1118 *img = (*img + *f)/rate;
1119 ++img;
1120 *f++ = 0;
1121 }
1122
1123 return true;
1124 }
1125}
1126
1127void MStarguider::ProcessFrame(const unsigned long n, byte *img,
1128 struct timeval *tm)
1129{
1130 if (!Interpolate(n, img))
1131 return;
1132
1133 if (fTPointMode==2)
1134 {
1135 fTPointMode=1;
1136 return;
1137 }
1138
1139 byte cimg[768*576];
1140 memset(cimg, 0, 768*576);
1141
1142 FilterLed f (img, 768, 576, 2.5); // 2.5
1143 FilterLed f2(cimg, 768, 576); // former color 0xb0
1144
1145 if (!fTPointMode && fScreenshotName.empty() && fDisplay->IsEntryChecked(IDM_kStretch))
1146 f.Stretch();
1147
1148 // Visual Filter, whole FOV
1149 if (!fTPointMode && fDisplay->IsEntryChecked(IDM_kFilter))
1150 {
1151 vector<Led> leds;
1152 f.Execute(leds, 768/2, 576/2);
1153 for (auto it=leds.begin(); it!=leds.end(); it++)
1154 f.MarkPoint(*it);
1155 }
1156
1157 // Find Center of Camera for Caos and Tpoints
1158 int numleds = 0;
1159 int numrings = 0;
1160 Ring center(-1, -1);//(5, 5);
1161
1162 if (fTPointMode || fDisplay->IsEntryChecked(IDM_kCaosFilter))
1163 {
1164 center = fCaos->Run(img);
1165 numleds = fCaos->GetNumDetectedLEDs();
1166 numrings = fCaos->GetNumDetectedRings();
1167 }
1168
1169 //cout << "cx=" << center.GetX() << " cy=" << center.GetY() << " Nled=" << numleds << " Nrings=" << numrings << endl;
1170
1171 // Find Star at Center---for Tpoint Procedure
1172 Led star(-1, -1);
1173 if (center.GetX()>0 && center.GetY()>0)
1174 {
1175 if (fTPointMode || fDisplay->IsEntryChecked(IDM_kFindStar))
1176 {
1177 // Set search Paremeters (FIXME: Get them from user input!)
1178 f.SetCut(fFindStarCut+1.5); // FindStar.CleaningLevel
1179 f.SetBox(fFindStarBox+12/*+80*/); // FindStar.SizeBox
1180
1181 // Try to find the star
1182 vector<Led> leds;
1183 f.FindStar(leds, (Int_t)center.GetX(), (Int_t)center.GetY(), true);
1184
1185 // Check whether star found
1186 if (leds.size()>0)
1187 {
1188 //cout << "Found star @ " << flush;
1189 //leds[0].Print();
1190 f2.MarkPoint(leds[0].GetX(), leds[0].GetY(), 2<<2);
1191 star = leds[0];
1192 }
1193 }
1194
1195 // DrawZoomImage(img);
1196 // DrawCosyImage(img);
1197
1198 // Position corresponding to the camera center (53.2, 293.6)
1199 // Draw Circles around center of Camera
1200 if (fTPointMode || fDisplay->IsEntryChecked(IDM_kCaosFilter))
1201 {
1202 f2.DrawCircle(center, 0x0a);
1203 f2.DrawCircle(center, 7.0,
1204 fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0);
1205 //f2.DrawCircle(center, 115.0, 0x0a);
1206 //f2.DrawCircle(center, 230.0, 0x0a);
1207 //f2.DrawCircle(center, 245.0, 0x0a);
1208 }
1209 }
1210
1211 if (fTPointMode ||
1212 fDisplay->IsEntryChecked(IDM_kCaosFilter) ||
1213 fDisplay->IsEntryChecked(IDM_kFindStar))
1214 fImage->DrawColImg(img, cimg);
1215 else
1216 fImage->DrawImg(img);
1217
1218 if (fTPointMode && !fScreenshotName.empty())
1219 {
1220 WritePNG(fScreenshotName.c_str(), img, cimg);
1221 fScreenshotName = "";
1222 fTPointMode = 0;
1223 return;
1224 }
1225
1226
1227 if (star.GetX()<0 || star.GetY()<0 || fTPointMode==0)
1228 return;
1229
1230 if (fTPointMode==1)
1231 fTPointMode=0;
1232
1233 // Convert from Pixel to millimeter (1pix=2.6mm) [deg/pix / deg/mm = mm/pix]
1234 // Correct for abberation.
1235
1236 //const float Dleds = 510; // 5.96344 deg
1237 //const float Dpix = 2*237.58;
1238
1239 // The DC reflector elongates light from off axis sources
1240 // This is a correction. It is 7% for MAGIC (1:1) and
1241 // less for FACT (1:1.4). This is an estimate from a
1242 // Orbit mode observation at 0.17deg distance to the
1243 // camera center [4.90m might also not be very accurate
1244 // depending on the position of the CCD camera]
1245 const double abberation = 1.0638; //1.0713;
1246 const double sec_per_pix = 45.14; //45.311; (atan(510mm/2 / 4.90m) / 237.58) // FACT LEDs
1247
1248 const double conv = sec_per_pix/abberation;
1249
1250 const double dx = star.GetX()-center.GetX();
1251 const double dy = star.GetY()-center.GetY();
1252
1253 //const double dxx = - conv * (star.GetX()-center.GetX());
1254 //const double dyy = conv * (star.GetY()-center.GetY());
1255
1256 const double dphi = - center.GetPhi() * M_PI/180;
1257
1258 // The sign is because the pixels are not counted in
1259 // both directions in the same direction as Zd/Az
1260 const double dxx = - conv * (dx*cos(dphi) - dy*sin(dphi));
1261 const double dyy = conv * (dx*sin(dphi) + dy*cos(dphi));
1262
1263 double arr[11] = {
1264 dxx, dyy,
1265 double(numleds), double(numrings),
1266 center.GetX(), center.GetY(), center.GetMag(),
1267 star.GetX(), star.GetY(), star.GetMag(),
1268 center.GetPhi()
1269 };
1270
1271 fDimData.setData(arr, 11*sizeof(double));
1272 fDimData.setQuality(0);
1273 fDimData.setTimestamp(tm->tv_sec, tm->tv_usec/1000);
1274 fDimData.updateService();
1275}
1276
1277/*
1278void MStarguider::UpdatePosZoom()
1279{
1280 MString txt;
1281 if (fDisplay->IsEntryChecked(IDM_kCatalog))
1282 {
1283 // FIXME: Necessary?
1284 fSao->Now();
1285 AltAz aa = fSao->CalcAltAzFromPix(fDx, fDy)*kRad2Deg;
1286 if (aa.Az()<0)
1287 aa.Az(aa.Az()+360);
1288 txt.Form("(%d, %d) %.1fd/%.1fd", fDx, fDy, -aa.Alt(), aa.Az()-180);
1289 }
1290 else
1291 txt.Form("(%d, %d)", fDx, fDy);
1292 fPosZoom->SetText(txt);
1293}
1294
1295Bool_t MStarguider::HandleDoubleClick(Event_t *event)
1296{
1297 const Int_t w = fImage->GetWidth();
1298 const Int_t h = fImage->GetHeight();
1299 const Int_t x = fImage->GetX();
1300 const Int_t y = fImage->GetY();
1301
1302 if (!(event->fX>x && event->fX<x+w && event->fY>y && event->fY<y+h))
1303 return kTRUE;
1304
1305 Int_t dx = event->fX-x;
1306 Int_t dy = event->fY-y;
1307
1308 if (dx<kZOOM/4) dx=kZOOM/4;
1309 if (dy<kZOOM/4) dy=kZOOM/4;
1310 if (dx>766-kZOOM/4) dx=766-kZOOM/4;
1311 if (dy>574-kZOOM/4) dy=574-kZOOM/4;
1312
1313 fDx = dx;
1314 fDy = dy;
1315
1316 //UpdatePosZoom();
1317 return kTRUE;
1318}
1319
1320*/
1321
1322/// Overwritten DimCommand::commandHandler
1323void MStarguider::commandHandler()
1324{
1325 DimCommand *cmd = getCommand();
1326 if (!cmd)
1327 return;
1328
1329 if (cmd==&fDimTPoint)
1330 {
1331 fTPointMode = 2;
1332 fScreenshotName = "";
1333 cout << "DimCommand[TPOINT]: " << cmd->itsSize << " " << string((char*)cmd->itsData, cmd->itsSize) << endl;
1334 return;
1335 }
1336
1337 if (cmd==&fDimScreenshot && fTPointMode==0)
1338 {
1339 if (cmd->itsSize<2)
1340 return;
1341
1342 fTPointMode = 2;
1343 fScreenshotColor = ((uint8_t*)cmd->itsData)[0];
1344 fScreenshotName = string((char*)cmd->itsData+1, cmd->itsSize-1);
1345 cout << "DimCommand[SCREENSHOT]: " << fScreenshotName << endl;
1346 return;
1347 }
1348
1349 cout << "DimCommand[UNKNOWN]: " << cmd->itsSize << " " << string((char*)cmd->itsData, cmd->itsSize) << endl;
1350}
Note: See TracBrowser for help on using the repository browser.