#include #include "IupControlDlg.h" #include "ChessVideo.h" int IupControlDlg::_calibrateColorsCB(Ihandle* self) { IupControlDlg* dlg; dlg = (IupControlDlg*)IupGetAttribute(self, "this"); if(!dlg) return IUP_DEFAULT; dlg->colorCalibrationDlg->show(); return IUP_DEFAULT; } int IupControlDlg::_cameraSetupCB(Ihandle* self) { IupControlDlg* dlg; dlg = (IupControlDlg*)IupGetAttribute(self, "this"); if(!dlg) return IUP_DEFAULT; dlg->cameraSetupDlg->show(); return IUP_DEFAULT; } int IupControlDlg::_generateImageCB(Ihandle* self) { IupControlDlg* dlg; dlg = (IupControlDlg*)IupGetAttribute(self, "this"); if(!dlg) return IUP_DEFAULT; float rf, gf, bf; dlg->colorCalibrationDlg->getColorFactors(rf, gf, bf); float ex, ey, ez, ax, ay, az, distEyes; int width, height; dlg->cameraSetupDlg->getEye(ex, ey, ez); dlg->cameraSetupDlg->getAt(ax, ay, az); dlg->cameraSetupDlg->getDistEyes(distEyes); dlg->cameraSetupDlg->getImgDim(width, height); generateImage(ex, ey, ez, ax, ay, az, distEyes, rf, gf, bf, width, height, false); return IUP_DEFAULT; } int IupControlDlg::_generateVideoCB(Ihandle* self) { IupControlDlg* dlg; dlg = (IupControlDlg*)IupGetAttribute(self, "this"); if(!dlg) return IUP_DEFAULT; float rf, gf, bf; dlg->colorCalibrationDlg->getColorFactors(rf, gf, bf); float distEyes; int width, height; dlg->cameraSetupDlg->getDistEyes(distEyes); dlg->cameraSetupDlg->getImgDim(width, height); generateImage(0, 0, 0, 0, 0, 0, distEyes, rf, gf, bf, width, height, true); return IUP_DEFAULT; } int IupControlDlg::_exitCB(Ihandle* self) { return IUP_CLOSE; } IupControlDlg::IupControlDlg() { Ihandle *calibratecolorsbtn, *camerasetupbtn, *genimgbtn, *genvidbtn, *exitbtn, *box; colorCalibrationDlg = new IupColorCalibrationDlg(); cameraSetupDlg = new IupCameraSetupDlg(); calibratecolorsbtn = IupButton("Calibrate Colors", "_calibrateColorsCB"); IupSetFunction("_calibrateColorsCB", (Icallback)_calibrateColorsCB); IupSetAttribute(calibratecolorsbtn, "this", (char*)this); IupSetAttribute(calibratecolorsbtn, IUP_EXPAND, IUP_HORIZONTAL); camerasetupbtn = IupButton("Camera Setup", "_cameraSetupCB"); IupSetFunction("_cameraSetupCB", (Icallback)_cameraSetupCB); IupSetAttribute(camerasetupbtn, "this", (char*)this); IupSetAttribute(camerasetupbtn, IUP_EXPAND, IUP_HORIZONTAL); genimgbtn = IupButton("Generate Image", "_generateImageCB"); IupSetFunction("_generateImageCB", (Icallback)_generateImageCB); IupSetAttribute(genimgbtn, "this", (char*)this); IupSetAttribute(genimgbtn, IUP_EXPAND, IUP_HORIZONTAL); genvidbtn = IupButton("Generate Video", "_generateVideoCB"); IupSetFunction("_generateVideoCB", (Icallback)_generateVideoCB); IupSetAttribute(genvidbtn, "this", (char*)this); IupSetAttribute(genvidbtn, IUP_EXPAND, IUP_HORIZONTAL); exitbtn = IupButton("Exit", "_exitCB"); IupSetFunction("_exitCB", (Icallback)_exitCB); IupSetAttribute(exitbtn, "this", (char*)this); IupSetAttribute(exitbtn, IUP_EXPAND, IUP_HORIZONTAL); box = IupVbox(calibratecolorsbtn, camerasetupbtn, genimgbtn, genvidbtn, exitbtn, 0); dlg = IupDialog(box); IupStoreAttribute(dlg, "this", (char*)this); IupStoreAttribute(dlg,IUP_MAXBOX,IUP_NO); IupStoreAttribute(dlg,IUP_RESIZE,IUP_NO); IupSetAttribute(dlg, IUP_TITLE, "Stereoscopic Vision"); IupStoreAttribute(dlg, IUP_CLOSE_CB, "_close"); IupSetFunction("_close", (Icallback)_exitCB); } IupControlDlg::~IupControlDlg() { IupDestroy(dlg); delete(colorCalibrationDlg); delete(cameraSetupDlg); } void IupControlDlg::show() { IupShowXY(dlg, IUP_CENTER, IUP_CENTER); }