#include "VTKTutorialWidget.h"
#include "ritkDebugManager.h"

#include <vtkSphereSource.h>



VTKTutorialWidget::VTKTutorialWidget()
{
	setupUi(this);

	this->m_VisualizationWidget3D->update();
	this->m_VisualizationWidget3D->show();

	connect(this->m_RadioButtonPoints, SIGNAL(clicked()), this, SLOT(RadioButtonPolyDataClicked()));
	connect(this->m_RadioButtonTriangleStrips, SIGNAL(clicked()), this, SLOT(RadioButtonPolyDataClicked()));
	connect(this->m_RadioButtonDelaunayTriangles, SIGNAL(clicked()), this, SLOT(RadioButtonPolyDataClicked()));

	connect(this->m_RadioButtonVisMonochrome, SIGNAL(clicked()), this, SLOT(RadioButtonVisTypeClicked()));
	connect(this->m_RadioButtonVisZBuffer, SIGNAL(clicked()), this, SLOT(RadioButtonVisTypeClicked()));
	connect(this->m_RadioButtonVisZBufferJet, SIGNAL(clicked()), this, SLOT(RadioButtonVisTypeClicked()));
	connect(this->m_RadioButtonVisRGB, SIGNAL(clicked()), this, SLOT(RadioButtonVisTypeClicked()));
	connect(this->m_RadioButtonVisRGBJet, SIGNAL(clicked()), this, SLOT(RadioButtonVisTypeClicked()));	
	connect(this->m_RadioButtonVisFlags, SIGNAL(clicked()), this, SLOT(RadioButtonVisTypeClicked()));	
	connect(this->m_RadioButtonVisFrameDifference, SIGNAL(clicked()), this, SLOT(RadioButtonVisTypeClicked()));	

	//connect(this->m_PushButtonGetLocalNeighborhood, SIGNAL(clicked()), this, SLOT(GetLocalNeighborhoodClicked()));
}

VTKTutorialWidget::~VTKTutorialWidget()
{
}

void VTKTutorialWidget::UpdateGUI()
{
	this->m_VisualizationWidget3D->UpdateGUI();
}

void VTKTutorialWidget::RadioButtonPolyDataClicked()
{
	ritk::RImageVTKData::PolyDataType Type;

	if(this->m_RadioButtonPoints->isChecked())
	{
		Type = ritk::RImageVTKData::POINTCLOUD;
	}
	else if(this->m_RadioButtonTriangleStrips->isChecked())
	{
		Type = ritk::RImageVTKData::TRIANGLESTRIPS;
	}
	else if(this->m_RadioButtonDelaunayTriangles->isChecked())
	{
		Type = ritk::RImageVTKData::DELAUNAYTRIANGLES;
	}

	emit PolyDataTypeChanged(Type);
}

void VTKTutorialWidget::RadioButtonVisTypeClicked()
{
	VisualizationMode Type;
	bool UseLUT = false;

	if(this->m_RadioButtonVisMonochrome->isChecked())
	{
		Type = MONOCHROME;
	}
	else if(this->m_RadioButtonVisZBuffer->isChecked())
	{
		Type = ZBUFFER;
	}
	else if(this->m_RadioButtonVisZBufferJet->isChecked())
	{
		Type = ZBUFFER;
		UseLUT = true;
	}
	else if(this->m_RadioButtonVisRGB->isChecked())
	{
		Type = RGB;
	}
	else if(this->m_RadioButtonVisRGBJet->isChecked())
	{
		Type = RGB;
		UseLUT = true;
	}
	else if(this->m_RadioButtonVisFlags->isChecked())
	{
		Type = FLAGS;
	}
	else if(this->m_RadioButtonVisFrameDifference->isChecked())
	{
		Type = FRAMEDIFFERENCE;
		UseLUT = true;
	}

	emit VisualizationTypeChanged(Type,UseLUT);
}

void VTKTutorialWidget::GetLocalNeighborhoodClicked()
{
	emit GetLocalNeighborhood();

	return;
}
