#include "LazerProbeSimPage.h"
#include "ui_LazerProbeSimPage.h"


CLazerProbeSimPage::CLazerProbeSimPage(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CLazerProbeSimPage)
{
    ui->setupUi(this);

    connect(ui->mMeasurementValueSlider,SIGNAL(valueChanged(int)),this,SLOT(ProbeValueChanged(int)));
    ui->mValueDisplayLabel->setText(QString("%1").arg(ui->mMeasurementValueSlider->value()));

    connect(ui->mEnableProbeChkBx,SIGNAL(stateChanged(int)),this,SLOT(EnableProbeChanged(int)));
    connect(ui->mOutOfRangeChkBx,SIGNAL(stateChanged(int)),this,SLOT(OutOfRangeChanged(int)));

}

CLazerProbeSimPage::~CLazerProbeSimPage()
{
    delete ui;
}

void CLazerProbeSimPage::ProbeValueChanged(int Value)
{
    if(ui->mOutOfRangeChkBx->isChecked())
    {
        Value = 0;
    }

    ui->mValueDisplayLabel->setText(QString("%1").arg(Value));
    mLazerProbe.SetProbeCurRange(Value);
}

void CLazerProbeSimPage::EnableProbeChanged(int State)
{
    if(State == Qt::Checked)
    {
        mLazerProbe.EnableProbe(true);
    }
    else if(State == Qt::Unchecked)
    {
        mLazerProbe.EnableProbe(false);
    }
}

void CLazerProbeSimPage::OutOfRangeChanged(int State)
{
    if(State == Qt::Checked)
    {
        ProbeValueChanged(0);
    }
    else if(State == Qt::Unchecked)
    {
        ProbeValueChanged(ui->mMeasurementValueSlider->value());
    }
}
