2017-01-23 15:09:06 +00:00
|
|
|
#include "..\Header\SettingsWindow.h"
|
|
|
|
#include <QString>
|
|
|
|
|
2017-01-26 17:17:54 +00:00
|
|
|
SettingsWindow::SettingsWindow(QVector3D bgOffColor, QVector3D bgOnColor, QVector3D lightColor, bool autoColor, double ambCoef, double attFac, int lightType, QWidget * parent)
|
2017-01-23 15:09:06 +00:00
|
|
|
: QWidget(parent)
|
|
|
|
, ui(new Ui::SettingsWindow)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
setWindowFlags(Qt::Tool | Qt::NoDropShadowWindowHint);
|
|
|
|
|
2017-01-26 17:17:54 +00:00
|
|
|
setupConnections();
|
|
|
|
|
|
|
|
// set default values
|
|
|
|
ui->lightOff_R_SB->setValue((int)bgOffColor[0]);
|
|
|
|
ui->lightOff_G_SB->setValue((int)bgOffColor[1]);
|
|
|
|
ui->lightOff_B_SB->setValue((int)bgOffColor[2]);
|
|
|
|
|
|
|
|
ui->lightOn_R_SB->setValue((int)bgOnColor[0]);
|
|
|
|
ui->lightOn_G_SB->setValue((int)bgOnColor[1]);
|
|
|
|
ui->lightOn_B_SB->setValue((int)bgOnColor[2]);
|
|
|
|
|
|
|
|
ui->light_R_SB->setValue((int)lightColor[0]);
|
|
|
|
ui->light_G_SB->setValue((int)lightColor[1]);
|
|
|
|
ui->light_B_SB->setValue((int)lightColor[2]);
|
|
|
|
|
|
|
|
ui->ambCoef->setValue(ambCoef);
|
|
|
|
ui->attFac->setValue(attFac);
|
|
|
|
|
|
|
|
ui->checkAutoColor->setChecked(autoColor);
|
|
|
|
if (lightType == 1)
|
|
|
|
ui->radioDirectLight->setChecked(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SettingsWindow::~SettingsWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::setupConnections()
|
|
|
|
{
|
2017-01-23 15:09:06 +00:00
|
|
|
// light off
|
2017-01-26 17:17:54 +00:00
|
|
|
connect(ui->lightOff_R_SB, SIGNAL(valueChanged(int)), ui->lightOff_R_S, SLOT(setValue(int)));
|
|
|
|
connect(ui->lightOff_R_S, SIGNAL(valueChanged(int)), ui->lightOff_R_SB, SLOT(setValue(int)));
|
2017-01-24 16:09:51 +00:00
|
|
|
connect(ui->lightOff_R_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOffChanged);
|
2017-01-23 15:09:06 +00:00
|
|
|
|
2017-01-26 17:17:54 +00:00
|
|
|
connect(ui->lightOff_G_SB, SIGNAL(valueChanged(int)), ui->lightOff_G_S, SLOT(setValue(int)));
|
|
|
|
connect(ui->lightOff_G_S, SIGNAL(valueChanged(int)), ui->lightOff_G_SB, SLOT(setValue(int)));
|
2017-01-24 16:09:51 +00:00
|
|
|
connect(ui->lightOff_G_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOffChanged);
|
2017-01-23 15:09:06 +00:00
|
|
|
|
2017-01-26 17:17:54 +00:00
|
|
|
connect(ui->lightOff_B_SB, SIGNAL(valueChanged(int)), ui->lightOff_B_S, SLOT(setValue(int)));
|
|
|
|
connect(ui->lightOff_B_S, SIGNAL(valueChanged(int)), ui->lightOff_B_SB, SLOT(setValue(int)));
|
2017-01-24 16:09:51 +00:00
|
|
|
connect(ui->lightOff_B_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOffChanged);
|
2017-01-23 15:09:06 +00:00
|
|
|
|
|
|
|
// light on
|
2017-01-26 17:17:54 +00:00
|
|
|
connect(ui->lightOn_R_SB, SIGNAL(valueChanged(int)), ui->lightOn_R_S, SLOT(setValue(int)));
|
|
|
|
connect(ui->lightOn_R_S, SIGNAL(valueChanged(int)), ui->lightOn_R_SB, SLOT(setValue(int)));
|
2017-01-24 16:09:51 +00:00
|
|
|
connect(ui->lightOn_R_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOnChanged);
|
2017-01-23 15:09:06 +00:00
|
|
|
|
2017-01-26 17:17:54 +00:00
|
|
|
connect(ui->lightOn_G_SB, SIGNAL(valueChanged(int)), ui->lightOn_G_S, SLOT(setValue(int)));
|
|
|
|
connect(ui->lightOn_G_S, SIGNAL(valueChanged(int)), ui->lightOn_G_SB, SLOT(setValue(int)));
|
2017-01-24 16:09:51 +00:00
|
|
|
connect(ui->lightOn_G_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOnChanged);
|
2017-01-23 15:09:06 +00:00
|
|
|
|
2017-01-26 17:17:54 +00:00
|
|
|
connect(ui->lightOn_B_SB, SIGNAL(valueChanged(int)), ui->lightOn_B_S, SLOT(setValue(int)));
|
|
|
|
connect(ui->lightOn_B_S, SIGNAL(valueChanged(int)), ui->lightOn_B_SB, SLOT(setValue(int)));
|
2017-01-24 16:09:51 +00:00
|
|
|
connect(ui->lightOn_B_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOnChanged);
|
2017-01-23 15:09:06 +00:00
|
|
|
|
|
|
|
// light
|
2017-01-26 17:17:54 +00:00
|
|
|
connect(ui->light_R_SB, SIGNAL(valueChanged(int)), ui->light_R_S, SLOT(setValue(int)));
|
|
|
|
connect(ui->light_R_S, SIGNAL(valueChanged(int)), ui->light_R_SB, SLOT(setValue(int)));
|
2017-01-24 16:09:51 +00:00
|
|
|
connect(ui->light_R_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
|
2017-01-23 15:09:06 +00:00
|
|
|
|
2017-01-26 17:17:54 +00:00
|
|
|
connect(ui->light_G_SB, SIGNAL(valueChanged(int)), ui->light_G_S, SLOT(setValue(int)));
|
|
|
|
connect(ui->light_G_S, SIGNAL(valueChanged(int)), ui->light_G_SB, SLOT(setValue(int)));
|
2017-01-24 16:09:51 +00:00
|
|
|
connect(ui->light_G_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
|
2017-01-23 15:09:06 +00:00
|
|
|
|
2017-01-26 17:17:54 +00:00
|
|
|
connect(ui->light_B_SB, SIGNAL(valueChanged(int)), ui->light_B_S, SLOT(setValue(int)));
|
|
|
|
connect(ui->light_B_S, SIGNAL(valueChanged(int)), ui->light_B_SB, SLOT(setValue(int)));
|
2017-01-24 16:09:51 +00:00
|
|
|
connect(ui->light_B_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
|
2017-01-23 15:09:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
connect(ui->checkAutoColor, &QCheckBox::toggled, this, &SettingsWindow::autoColorToggled);
|
|
|
|
connect(ui->radioDirectLight, &QRadioButton::toggled, this, &SettingsWindow::radioToggled);
|
2017-01-24 16:09:51 +00:00
|
|
|
connect(ui->ambCoef, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double value) {emit updateAmbCoef(value); });
|
|
|
|
connect(ui->attFac, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double value) {emit updateAttFac(value); });
|
2017-01-23 15:09:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2017-01-24 10:40:38 +00:00
|
|
|
// connection slots
|
2017-01-23 15:09:06 +00:00
|
|
|
|
|
|
|
void SettingsWindow::autoColorToggled()
|
|
|
|
{
|
|
|
|
if (!ui->checkAutoColor->isChecked())
|
|
|
|
{
|
2017-01-26 17:17:54 +00:00
|
|
|
ui->lightOn_R_SB->setEnabled(true);
|
2017-01-23 15:09:06 +00:00
|
|
|
ui->lightOn_R_S->setEnabled(true);
|
2017-01-26 17:17:54 +00:00
|
|
|
ui->lightOn_G_SB->setEnabled(true);
|
2017-01-23 15:09:06 +00:00
|
|
|
ui->lightOn_G_S->setEnabled(true);
|
2017-01-26 17:17:54 +00:00
|
|
|
ui->lightOn_B_SB->setEnabled(true);
|
2017-01-23 15:09:06 +00:00
|
|
|
ui->lightOn_B_S->setEnabled(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-26 17:17:54 +00:00
|
|
|
ui->lightOn_R_SB->setEnabled(false);
|
2017-01-23 15:09:06 +00:00
|
|
|
ui->lightOn_R_S->setEnabled(false);
|
2017-01-26 17:17:54 +00:00
|
|
|
ui->lightOn_G_SB->setEnabled(false);
|
2017-01-23 15:09:06 +00:00
|
|
|
ui->lightOn_G_S->setEnabled(false);
|
2017-01-26 17:17:54 +00:00
|
|
|
ui->lightOn_B_SB->setEnabled(false);
|
2017-01-23 15:09:06 +00:00
|
|
|
ui->lightOn_B_S->setEnabled(false);
|
|
|
|
|
|
|
|
ui->lightOn_R_S->setValue((int)(ui->light_R_S->value() / 50));
|
|
|
|
ui->lightOn_G_S->setValue((int)(ui->light_G_S->value() / 50));
|
|
|
|
ui->lightOn_B_S->setValue((int)(ui->light_B_S->value() / 50));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::radioToggled()
|
|
|
|
{
|
2017-01-26 17:17:54 +00:00
|
|
|
if (ui->radioDirectLight->isChecked())
|
2017-01-23 15:09:06 +00:00
|
|
|
{
|
|
|
|
ui->attFac->setValue(0.0);
|
|
|
|
ui->attFac->setEnabled(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->attFac->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
2017-01-24 16:09:51 +00:00
|
|
|
|
|
|
|
void SettingsWindow::backgroundColorOffChanged()
|
|
|
|
{
|
|
|
|
emit updateBGColorOff(QVector3D(ui->lightOff_R_S->value(), ui->lightOff_G_S->value(), ui->lightOff_B_S->value()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::backgroundColorOnChanged()
|
|
|
|
{
|
|
|
|
emit updateBGColorOn(QVector3D(ui->lightOn_R_S->value(), ui->lightOn_G_S->value(), ui->lightOn_B_S->value()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::lightColorChanged()
|
|
|
|
{
|
|
|
|
emit updateLightColor(QVector3D(ui->light_R_S->value(), ui->light_G_S->value(), ui->light_B_S->value()));
|
2017-01-26 17:17:54 +00:00
|
|
|
|
|
|
|
if (ui->checkAutoColor->isChecked())
|
|
|
|
{
|
|
|
|
ui->lightOn_R_S->setValue((int)(ui->light_R_S->value() / 50));
|
|
|
|
ui->lightOn_G_S->setValue((int)(ui->light_G_S->value() / 50));
|
|
|
|
ui->lightOn_B_S->setValue((int)(ui->light_B_S->value() / 50));
|
|
|
|
}
|
2017-01-24 16:09:51 +00:00
|
|
|
}
|
|
|
|
|