#include "cmwcomplight.h"
#include "ui_cmwcomplight.h"
#include "logic.h"
CMWCompLight::CMWCompLight(QWidget *parent) :
    CMWidget(parent),
    ui(new Ui::CMWCompLight)
{
    ui->setupUi(this);
}

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

void CMWCompLight::MFresh()
{
    ui->horizontalSlider_DLight2X->setValue(
                m_gSystem.get_lightdata(CAM2X,
                                        true));
    ui->horizontalSlider_SLight2X->setValue(
                m_gSystem.get_lightdata(CAM2X,
                                        false));

    ui->horizontalSlider_DLight6X->setValue(
                m_gSystem.get_lightdata(CAM6X,
                                        true));
    ui->horizontalSlider_SLight6X->setValue(
                m_gSystem.get_lightdata(CAM6X,
                                        false));
#ifdef __USE_THIRD_CAMERA__
	ui->horizontalSlider_DLight4X->setValue(
				m_gSystem.get_lightdata(CAMKerf,
				true));
	ui->horizontalSlider_SLight4X->setValue(
				m_gSystem.get_lightdata(CAMKerf,
				false));

    ui->widget_muti_d4X->setVisible(false);
    ui->widget_muti_s4X->setVisible(false);
#endif

	ui->widget_muti_d2X->setVisible(false);
	ui->widget_muti_s2X->setVisible(false);
	ui->widget_muti_d6X->setVisible(false);
	ui->widget_muti_s6X->setVisible(false);


}

void CMWCompLight::MInit()
{
    CLight* pLight=0;
    pLight=GET_CHDIRECT(LIGHT_DIRECT2X,CLight);
    Q_ASSERT(pLight);
    ui->widget_muti_d2X->MParamInit(pLight->m_Variants.get_Variant(Var_Light_Multiplier_ID));

    pLight=GET_CHDIRECT(LIGHT_SIDE2X,CLight);
    Q_ASSERT(pLight);
    ui->widget_muti_s2X->MParamInit(pLight->m_Variants.get_Variant(Var_Light_Multiplier_ID));

    pLight=GET_CHDIRECT(LIGHT_DIRECT6X,CLight);
    Q_ASSERT(pLight);
    ui->widget_muti_d6X->MParamInit(pLight->m_Variants.get_Variant(Var_Light_Multiplier_ID));

    pLight=GET_CHDIRECT(LIGHT_SIDE6X,CLight);
    Q_ASSERT(pLight);
    ui->widget_muti_s6X->MParamInit(pLight->m_Variants.get_Variant(Var_Light_Multiplier_ID));
#ifdef __USE_THIRD_CAMERA__
    pLight=GET_CHDIRECT(LIGHT_DIRECT4X,CLight);
    Q_ASSERT(pLight);
    ui->widget_muti_d4X->MParamInit(pLight->m_Variants.get_Variant(Var_Light_Multiplier_ID));


    pLight=GET_CHDIRECT(LIGHT_SIDE4X,CLight);
    Q_ASSERT(pLight);
    ui->widget_muti_s4X->MParamInit(pLight->m_Variants.get_Variant(Var_Light_Multiplier_ID));
#endif

    mchildwidgets[intptr_t(ui->widget_muti_d2X)]=ui->widget_muti_d2X;
    mchildwidgets[intptr_t(ui->widget_muti_s2X)]=ui->widget_muti_s2X;
    mchildwidgets[intptr_t(ui->widget_muti_d6X)]=ui->widget_muti_d6X;
    mchildwidgets[intptr_t(ui->widget_muti_s6X)]=ui->widget_muti_s6X;
#ifdef __USE_THIRD_CAMERA__
    mchildwidgets[intptr_t(ui->widget_muti_d4X)]=ui->widget_muti_d4X;
    mchildwidgets[intptr_t(ui->widget_muti_s4X)]=ui->widget_muti_s4X;
#endif


    CMWidget::MInit();

}

void CMWCompLight::MApply()
{
    CMWidget::MApply();
    //V_MsgQueue msgqueue;
    //msgqueue.pushback_Msg(VarMsg_Driver_ID,
    //                      QObject::trUtf8("Set Multiplier Sig"),
    //                      QVariantList()
    //                      <<LIGHT_DRIVER<<CLightDriver::SETALLMULTIPLIER,0);
    //m_gSystem.start_test(SM_MAIN, msgqueue,false);

}

void CMWCompLight::on_horizontalSlider_DLight2X_valueChanged(int value)
{
    V_MsgQueue msgqueue;
    m_gSystem.SetCamLight_sig(CAM2X,value,true,false,msgqueue);
    m_gSystem.start_test(SM_MAIN, msgqueue,false);
}

void CMWCompLight::on_horizontalSlider_SLight2X_valueChanged(int value)
{
    V_MsgQueue msgqueue;
    m_gSystem.SetCamLight_sig(CAM2X,value,false,false,msgqueue);
    m_gSystem.start_test(SM_MAIN, msgqueue,false);
}

void CMWCompLight::on_horizontalSlider_DLight6X_valueChanged(int value)
{
    V_MsgQueue msgqueue;
    m_gSystem.SetCamLight_sig(CAM6X,value,true,false,msgqueue);
    m_gSystem.start_test(SM_MAIN, msgqueue,false);
}

void CMWCompLight::on_horizontalSlider_SLight6X_valueChanged(int value)
{
    V_MsgQueue msgqueue;
    m_gSystem.SetCamLight_sig(CAM6X,value,false,false,msgqueue);
    m_gSystem.start_test(SM_MAIN, msgqueue,false);
}

void CMWCompLight::on_horizontalSlider_DLight4X_valueChanged(int value)
{
    V_MsgQueue msgqueue;
    m_gSystem.SetCamLight_sig(CAMKerf,value,true,false,msgqueue);
    m_gSystem.start_test(SM_MAIN, msgqueue,false);
}

void CMWCompLight::on_horizontalSlider_SLight4X_valueChanged(int value)
{
    V_MsgQueue msgqueue;
    m_gSystem.SetCamLight_sig(CAMKerf,value,false,false,msgqueue);
    m_gSystem.start_test(SM_MAIN, msgqueue,false);
}
