#include "CUDANormalizedConvolutionRImageFilterWidget.h"


//----------------------------------------------------------------------------
CUDANormalizedConvolutionRImageFilterWidget::CUDANormalizedConvolutionRImageFilterWidget(QWidget *parent) :
	QWidget(parent)
{
	setupUi(this);

	// Connect signals and slots
	connect(this->m_RangeCheckBox,			SIGNAL(toggled(bool)),				this,	SIGNAL(RangeDataCheckBoxChanged(bool))		);
	connect(this->m_RangeSimgaSlider,		SIGNAL(sliderMoved(int)),			this,	SLOT(RangeSigmaSliderChanged(int))			);
	connect(this->m_RangeKernelComboBox,	SIGNAL(currentIndexChanged(int)),	this,	SLOT(RangeKernelSizeComboboxChanged(int))	);

	// Range filtering by default
	this->m_RangeCheckBox->setChecked(true);

	// Default is an unscaled value of 10 (currently equals 10/2 = 5)
	this->m_RangeSimgaSlider->setValue(50);
	RangeSigmaSliderChanged(50);
}


//----------------------------------------------------------------------------
CUDANormalizedConvolutionRImageFilterWidget::~CUDANormalizedConvolutionRImageFilterWidget()
{
}


//----------------------------------------------------------------------------
void
CUDANormalizedConvolutionRImageFilterWidget::RangeSigmaSliderChanged(int Value)
{
	float scaled = Value*0.5;
	this->m_RangeSigmaLabel->setText(QString::number(scaled));
	emit RangeSigmaChanged(scaled);
}


//----------------------------------------------------------------------------
void
CUDANormalizedConvolutionRImageFilterWidget::RangeKernelSizeComboboxChanged(int Index)
{
	emit RangeKernelSizeChanged(Index+1);
}


//----------------------------------------------------------------------------
void
CUDANormalizedConvolutionRImageFilterWidget::UpdateRangeKernelSize(int value)
{
	this->m_RangeKernelComboBox->setCurrentIndex(value);
	RangeKernelSizeComboboxChanged(value+1);
}


//----------------------------------------------------------------------------
void
CUDANormalizedConvolutionRImageFilterWidget::UpdateRangeSigma(int value)
{
	RangeSigmaSliderChanged(value);
}

