20 #include <TGSplitter.h> 21 #include <TGTextEntry.h> 27 #include "../src/DimSetup.h" 135 const TGWindow *p=gClient->GetRoot();
137 fInterpol =
new TGPopupMenu(p);
146 fInterpol->Associate(
this);
149 TString disp=gVirtualX->DisplayName();
150 cout <<
"Display: " << disp << endl;
151 if (disp.First(
':')>=0)
152 disp=disp(0, disp.First(
':'));
154 if (disp.IsNull() || disp==(TString)
"localhost")
186 fMenu =
new TGMenuBar(
this, 0, 0, kHorizontalFrame);
187 fDisplay = fMenu->AddPopup(
"&Display");
190 fSetup = fMenu->AddPopup(
"&Setup");
192 fMenu->Resize(fMenu->GetDefaultSize());
201 fDisplay->AddSeparator();
210 fDisplay->Associate(
this);
224 fSetup->AddPopup(
"Disp. &Interpolation", fInterpol);
225 fSetup->Associate(
this);
358 fImage =
new MGImage(
this, 768, 576);
359 fImage->Move(0, fMenu->GetDefaultHeight());
364 SetWMSizeHints(w, h, w, h, 1, 1);
369 SetWindowName(
"TPoint Main Window");
370 SetIconName(
"TPoint");
399 fDimData(
"TPOINT/DATA",
"D:11", (void*)NULL, 0),
400 fDimTPoint(
"TPOINT/EXECUTE",
"", this),
401 fDimScreenshot(
"TPOINT/SCREENSHOT",
"B:1;C", this),
402 fRadius(200), fFindStarCut(2.), fFindStarBox(30), fTPointMode(0)
404 cout <<
" #### FIXME: Make MCaos Thread safe!" << endl;
415 fTimer=
new TTimer(
this, 1000/25);
418 gVirtualX->GrabButton(
fId, kButton2, 0, 0, 0, 0, kTRUE);
433 gVirtualX->GrabButton(
fId, kButton2, 0, 0, 0, 0, kFALSE);
443 cout <<
"Camera Display destroyed." << endl;
479 cout <<
"EventDisplay::CloseWindow: Exit Application Loop." << endl;
519 if (p->IsEntryChecked(
id))
528 switch (GET_MSG(msg))
531 if (GET_SUBMSG(msg)==kTE_ENTER)
559 switch (GET_SUBMSG(msg))
979 if (fname.size()<4 || fname.compare(fname.size()-4,4,
".png")==0)
982 cout <<
"Writing PNG '" << fname <<
"'" << endl;
988 FILE *fd = fopen(fname.c_str(),
"w");
991 cout <<
"Warning: Cannot open file for writing." << endl;
998 png_structp fPng = png_create_write_struct(PNG_LIBPNG_VER_STRING,
1003 cout <<
"Warning: Unable to create PNG structure" << endl;
1009 png_infop fInfo = png_create_info_struct(fPng);
1013 cout <<
"Warning: Unable to create PNG info structure" << endl;
1014 png_destroy_write_struct (&fPng, NULL);
1020 fInfo->height = 576;
1021 fInfo->bit_depth = 8;
1022 fInfo->color_type = PNG_COLOR_TYPE_RGB;
1028 if (setjmp(fPng->jmpbuf))
1030 cout <<
"longjmp Warning: PNG encounterd an error!" << endl;
1031 png_destroy_write_struct (&fPng, &fInfo);
1039 png_init_io(fPng, fd);
1046 png_write_info(fPng, fInfo);
1048 png_byte buf[768*576*3];
1051 const byte *g = gbuf;
1052 const byte *c = cbuf;
1055 while (d<buf+768*576*3)
1059 *d++ = ((*c>>4)&0x3)*85;
1060 *d++ = ((*c>>2)&0x3)*85;
1061 *d++ = ((*c++ )&0x3)*85;
1076 for (
unsigned int y=0; y<768*576*3; y+=768*3)
1077 png_write_row (fPng, buf+y);
1082 png_write_end (fPng, fInfo);
1087 png_destroy_write_struct (&fPng, &fInfo);
1091 cout <<
"Sorry, no png support compiled into tpoint." << endl;
1102 static unsigned short myimg[768*576];
1104 unsigned short *f = myimg;
1106 const byte *
end = img+768*576;
1118 *img = (*img + *f)/rate;
1140 memset(cimg, 0, 768*576);
1152 f.
Execute(leds, 768/2, 576/2);
1153 for (
auto it=leds.begin(); it!=leds.end(); it++)
1160 Ring center(-1, -1);
1173 if (center.
GetX()>0 && center.
GetY()>0)
1190 f2.
MarkPoint(leds[0].GetX(), leds[0].GetY(), 2<<2);
1245 const double abberation = 1.0638;
1246 const double sec_per_pix = 45.14;
1248 const double conv = sec_per_pix/abberation;
1250 const double dx = star.
GetX()-center.
GetX();
1251 const double dy = star.
GetY()-center.
GetY();
1256 const double dphi = - center.
GetPhi() * M_PI/180;
1260 const double dxx = - conv * (dx*cos(dphi) - dy*sin(dphi));
1261 const double dyy = conv * (dx*sin(dphi) + dy*cos(dphi));
1265 double(numleds), double(numrings),
1333 cout <<
"DimCommand[TPOINT]: " << cmd->
itsSize <<
" " << string((
char*)cmd->
itsData, cmd->
itsSize) << endl;
1349 cout <<
"DimCommand[UNKNOWN]: " << cmd->
itsSize <<
" " << string((
char*)cmd->
itsData, cmd->
itsSize) << endl;
void InitGui(Int_t channel)
void DrawColImg(const byte *gbuf, const byte *cbuf)
std::string fScreenshotName
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
void Toggle(TGPopupMenu *p, UInt_t id)
void MarkPoint(const Led &led) const
void setQuality(int quality)
void Execute(std::vector< Led > &leds, int xc, int yc, double &bright) const
bool Interpolate(const unsigned long n, byte *img) const
DimCommand * getCommand()
void setTimestamp(int secs, int millisecs)
void setData(void *data, int size)
void SwitchOff(TGPopupMenu *p, UInt_t id)
DimCommand fDimScreenshot
void ProcessFrame(const unsigned long n, byte *img, struct timeval *tm)
int32_t GetNumDetectedRings() const
Bool_t HandleTimer(TTimer *t)
void commandHandler()
Overwritten DimCommand::commandHandler.
void WritePNG(const char *name, const byte *gbuf, const byte *cbuf)
void DrawCircle(float cx, float cy, float r, uint8_t col=0x40) const
int32_t GetNumDetectedLEDs() const
void DrawImg(const byte *buffer)
MStarguider(Int_t channel)
static void setNoDataCopy()
void FindStar(std::vector< Led > &leds, int xc, int yc, bool circle=false) const
void ReadResources(const char *name="leds.txt")