#include "camera_glue.h"

#define camera_glue_init(a,b)\
	spinBox[a][0] = ui.spinBox_##b##1;\
	spinBox[a][1] = ui.spinBox_##b##2;\
	spinBox[a][2] = ui.spinBox_##b##3;

camera_glue::camera_glue(QDialog *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
	this->setWindowFlags(windowFlags()&~Qt::WindowContextHelpButtonHint);
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
	camera_glue_init(0,1)
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1)
	camera_glue_init(1,2)
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2)
	camera_glue_init(2,3)
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3)
	camera_glue_init(3,4)
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4)
	camera_glue_init(4,5)
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5)
	camera_glue_init(5,6)
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6)
	camera_glue_init(6,7)
#endif
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7)
	camera_glue_init(7,8)
#endif
}

camera_glue::~camera_glue()
{

}

void camera_glue::recMsgFromDialogSetup(int ptr[][3])
{
	for(int i=0;i<NumberOfSupportedCameras;i++)
		for(int j=0;j<3;j++)
			spinBox[i][j]->setValue(ptr[i][j]);
}

void camera_glue::on_pushButton_take_released(void)
{
	int mat[NumberOfSupportedCameras][3];
	for(int i=0;i<NumberOfSupportedCameras;i++)
		for(int j=0;j<3;j++)
			mat[i][j]=spinBox[i][j]->value();
	emit sendMsgToDialogSetup(mat);
	this->close();
}