2017-01-23 15:09:06 +00:00
|
|
|
#include "..\Header\SettingsWindow.h"
|
2017-02-08 13:29:22 +00:00
|
|
|
#include "..\Header\SettingsManager.h"
|
2017-05-31 08:09:20 +00:00
|
|
|
#include <QFileDialog>
|
2017-06-16 03:31:11 +00:00
|
|
|
#include <QListWidgetItem>
|
|
|
|
|
2017-01-28 15:54:36 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
// constructor/destructor
|
2017-01-23 15:09:06 +00:00
|
|
|
|
2017-02-08 13:29:22 +00:00
|
|
|
SettingsWindow::SettingsWindow(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
|
2017-02-08 13:29:22 +00:00
|
|
|
SettingsManager* sm = SettingsManager::getInstance(this);
|
2017-01-26 17:17:54 +00:00
|
|
|
|
2017-06-16 04:28:47 +00:00
|
|
|
// set dirList for passing to Main and then fill settings manager dir list window
|
|
|
|
dirList = sm->getListOfDirs();
|
|
|
|
QStringList values;
|
|
|
|
values = dirList.split(';');
|
|
|
|
for (int i = 0; i < values.size(); i++) {
|
|
|
|
ui->dirListWidget->insertItem(0,values[i]);
|
|
|
|
}
|
|
|
|
|
2017-02-08 13:29:22 +00:00
|
|
|
ui->lightOff_R_SB->setValue((int)(sm->getBgColorOff()[0]));
|
|
|
|
ui->lightOff_G_SB->setValue((int)(sm->getBgColorOff()[1]));
|
|
|
|
ui->lightOff_B_SB->setValue((int)(sm->getBgColorOff()[2]));
|
2017-01-26 17:17:54 +00:00
|
|
|
|
2017-02-08 13:29:22 +00:00
|
|
|
ui->lightOn_R_SB->setValue((int)(sm->getBgColorOn()[0]));
|
|
|
|
ui->lightOn_G_SB->setValue((int)(sm->getBgColorOn()[1]));
|
|
|
|
ui->lightOn_B_SB->setValue((int)(sm->getBgColorOn()[2]));
|
2017-01-26 17:17:54 +00:00
|
|
|
|
2017-02-08 13:29:22 +00:00
|
|
|
ui->light_R_SB->setValue((int)(sm->getLightColor()[0]));
|
|
|
|
ui->light_G_SB->setValue((int)(sm->getLightColor()[1]));
|
|
|
|
ui->light_B_SB->setValue((int)(sm->getLightColor()[2]));
|
2017-01-26 17:17:54 +00:00
|
|
|
|
2017-02-08 13:29:22 +00:00
|
|
|
ui->ambCoef->setValue(sm->getAmbient());
|
|
|
|
ui->attFac->setValue(sm->getAttenuation());
|
|
|
|
|
|
|
|
ui->checkBackfaceCulling->setChecked(sm->isBfCulling());
|
|
|
|
ui->checkAutoColor->setChecked(sm->isAutoColor());
|
|
|
|
ui->checkHeadlight->setChecked(sm->isHeadlight());
|
|
|
|
|
|
|
|
if (sm->getLightType() == 1)
|
2017-01-26 17:17:54 +00:00
|
|
|
ui->radioDirectLight->setChecked(true);
|
2017-02-08 13:29:22 +00:00
|
|
|
else
|
|
|
|
ui->radioPointLight->setChecked(true);
|
|
|
|
|
|
|
|
connect(this, &SettingsWindow::updateBGColorOff, sm, &SettingsManager::setBgColorOff);
|
|
|
|
connect(this, &SettingsWindow::updateBGColorOn, sm, &SettingsManager::setBgColorOn);
|
|
|
|
connect(this, &SettingsWindow::updateLightColor, sm, &SettingsManager::setLightColor);
|
|
|
|
connect(this, &SettingsWindow::updateAttFac, sm, &SettingsManager::setAttenuation);
|
|
|
|
connect(this, &SettingsWindow::updateAmbCoef, sm, &SettingsManager::setAmbient);
|
|
|
|
connect(this, &SettingsWindow::sendHeadlight, sm, &SettingsManager::setHeadlight);
|
|
|
|
connect(this, &SettingsWindow::sendBackfaceCulling, sm, &SettingsManager::setBfCulling);
|
|
|
|
connect(ui->checkAutoColor, &QCheckBox::stateChanged, sm, &SettingsManager::setAutoColor);
|
|
|
|
connect(this, &SettingsWindow::changeLightType, sm, &SettingsManager::setLightType);
|
2017-01-26 17:17:54 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SettingsWindow::~SettingsWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2017-01-28 15:54:36 +00:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
// functions
|
|
|
|
|
2017-05-31 02:38:51 +00:00
|
|
|
QString SettingsWindow::getDirList()
|
|
|
|
{
|
2017-05-31 08:09:20 +00:00
|
|
|
return dirList;
|
|
|
|
}
|
2017-05-31 02:38:51 +00:00
|
|
|
|
2017-01-26 17:17:54 +00:00
|
|
|
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-29 22:47:14 +00:00
|
|
|
|
|
|
|
connect(ui->checkBackfaceCulling, &QCheckBox::toggled, [this]() {emit sendBackfaceCulling(ui->checkBackfaceCulling->isChecked()); });
|
|
|
|
connect(ui->spinZSpeed, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this](int value) {emit sendZommSpeed(value); });
|
2017-01-30 10:31:37 +00:00
|
|
|
connect(ui->checkHeadlight, &QCheckBox::toggled, [this]() {emit sendHeadlight(ui->checkHeadlight->isChecked()); });
|
2017-01-23 15:09:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-28 15:54:36 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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);
|
2017-02-08 13:29:22 +00:00
|
|
|
emit changeLightType(1);
|
2017-01-23 15:09:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->attFac->setEnabled(true);
|
2017-02-08 13:29:22 +00:00
|
|
|
emit changeLightType(2);
|
2017-01-23 15:09:06 +00:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
2017-05-31 08:09:20 +00:00
|
|
|
|
|
|
|
void SettingsWindow::on_addItem_clicked()
|
|
|
|
{
|
|
|
|
QString dirName = QFileDialog::getExistingDirectory(this, tr("Open Directory"), "/home",
|
|
|
|
QFileDialog::ShowDirsOnly |
|
|
|
|
QFileDialog::DontResolveSymlinks);
|
2017-06-16 04:28:47 +00:00
|
|
|
ui->dirListWidget->insertItem(0,dirName);
|
2017-06-16 08:16:30 +00:00
|
|
|
updateDirList();
|
2017-05-31 08:09:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::on_removeItem_clicked()
|
|
|
|
{
|
2017-06-16 04:28:47 +00:00
|
|
|
qDeleteAll(ui->dirListWidget->selectedItems());
|
2017-06-16 08:16:30 +00:00
|
|
|
updateDirList();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::updateDirList()
|
|
|
|
{
|
|
|
|
int size = ui->dirListWidget->count();
|
|
|
|
QString dirs;
|
|
|
|
|
|
|
|
for (int i = 0; i < size; i++)
|
|
|
|
dirs += ui->dirListWidget->item(i)->text() + ";";
|
|
|
|
|
|
|
|
SettingsManager::getInstance()->setListOfDirs(dirs);
|
2017-05-31 08:09:20 +00:00
|
|
|
}
|