#include "dlg_rotate_point_cloud.h"
#include "main_window.h"
#include "paint_canvas.h"


DlgRotatePointCloud::DlgRotatePointCloud(QWidget *parent)
	: QDialog(parent)
{
	setupUi(this);

	mainWindow_ = dynamic_cast<MainWindow*>(parent);

	// default value
	lineEditRotationX->setText("0");
	lineEditRotationY->setText("0");
	lineEditRotationZ->setText("0");

	connect(reverseButton, SIGNAL(clicked()), this, SLOT(reverse()));
	connect(applyButton, SIGNAL(clicked()), this, SLOT(apply()));
}

DlgRotatePointCloud::~DlgRotatePointCloud()
{
}

void DlgRotatePointCloud::apply() {
	float angle_x = lineEditRotationX->text().toFloat();
	float angle_y = lineEditRotationY->text().toFloat();
	float angle_z = lineEditRotationZ->text().toFloat();
	mainWindow_->canvas()->rotatePointCloud(angle_x, angle_y, angle_z);
}

void DlgRotatePointCloud::reverse() {
	float angle_x = lineEditRotationX->text().toFloat();
	float angle_y = lineEditRotationY->text().toFloat();
	float angle_z = lineEditRotationZ->text().toFloat();
	mainWindow_->canvas()->rotatePointCloud(-angle_x, -angle_y, -angle_z);
}

