SWBF2-Classic-Msh-Viewer/QtMeshViewer/Source/SettingsWindow.cpp

238 lines
6.5 KiB
C++
Raw Normal View History

#include "..\Header\SettingsWindow.h"
#include <QString>
#include <QLineEdit>
#include <QSlider>
SettingsWindow::SettingsWindow(QWidget * parent)
: QWidget(parent)
, ui(new Ui::SettingsWindow)
{
ui->setupUi(this);
setWindowFlags(Qt::Tool | Qt::NoDropShadowWindowHint);
// light off
connect(ui->lightOff_R_LE, SIGNAL(textChanged(QString)), this, SLOT(lightOffRValueChanged(QString)));
connect(ui->lightOff_R_S, SIGNAL(valueChanged(int)), this, SLOT(lightOffRValueChanged(int)));
connect(ui->lightOff_G_LE, SIGNAL(textChanged(QString)), this, SLOT(lightOffGValueChanged(QString)));
connect(ui->lightOff_G_S, SIGNAL(valueChanged(int)), this, SLOT(lightOffGValueChanged(int)));
connect(ui->lightOff_B_LE, SIGNAL(textChanged(QString)), this, SLOT(lightOffBValueChanged(QString)));
connect(ui->lightOff_B_S, SIGNAL(valueChanged(int)), this, SLOT(lightOffBValueChanged(int)));
// light on
connect(ui->lightOn_R_LE, SIGNAL(textChanged(QString)), this, SLOT(lightOnRValueChanged(QString)));
connect(ui->lightOn_R_S, SIGNAL(valueChanged(int)), this, SLOT(lightOnRValueChanged(int)));
connect(ui->lightOn_G_LE, SIGNAL(textChanged(QString)), this, SLOT(lightOnGValueChanged(QString)));
connect(ui->lightOn_G_S, SIGNAL(valueChanged(int)), this, SLOT(lightOnGValueChanged(int)));
connect(ui->lightOn_B_LE, SIGNAL(textChanged(QString)), this, SLOT(lightOnBValueChanged(QString)));
connect(ui->lightOn_B_S, SIGNAL(valueChanged(int)), this, SLOT(lightOnBValueChanged(int)));
// light
connect(ui->light_R_LE, SIGNAL(textChanged(QString)), this, SLOT(lightRValueChanged(QString)));
connect(ui->light_R_S, SIGNAL(valueChanged(int)), this, SLOT(lightRValueChanged(int)));
connect(ui->light_G_LE, SIGNAL(textChanged(QString)), this, SLOT(lightGValueChanged(QString)));
connect(ui->light_G_S, SIGNAL(valueChanged(int)), this, SLOT(lightGValueChanged(int)));
connect(ui->light_B_LE, SIGNAL(textChanged(QString)), this, SLOT(lightBValueChanged(QString)));
connect(ui->light_B_S, SIGNAL(valueChanged(int)), this, SLOT(lightBValueChanged(int)));
connect(ui->checkAutoColor, &QCheckBox::toggled, this, &SettingsWindow::autoColorToggled);
connect(ui->radioDirectLight, &QRadioButton::toggled, this, &SettingsWindow::radioToggled);
}
SettingsWindow::~SettingsWindow()
{
delete ui;
}
////////////////////////////////////////////////////////////////////////////////
// Slider - LineEdit connections
#pragma region light off
void SettingsWindow::lightOffRValueChanged(QString value)
{
ui->lightOff_R_S->setValue(value.toInt());
}
void SettingsWindow::lightOffRValueChanged(int value)
{
ui->lightOff_R_LE->setText(QString::number(value));
}
void SettingsWindow::lightOffGValueChanged(QString value)
{
ui->lightOff_G_S->setValue(value.toInt());
}
void SettingsWindow::lightOffGValueChanged(int value)
{
ui->lightOff_G_LE->setText(QString::number(value));
}
void SettingsWindow::lightOffBValueChanged(QString value)
{
ui->lightOff_B_S->setValue(value.toInt());
}
void SettingsWindow::lightOffBValueChanged(int value)
{
ui->lightOff_B_LE->setText(QString::number(value));
}
#pragma endregion
#pragma region light on
void SettingsWindow::lightOnRValueChanged(QString value)
{
ui->lightOn_R_S->setValue(value.toInt());
}
void SettingsWindow::lightOnRValueChanged(int value)
{
ui->lightOn_R_LE->setText(QString::number(value));
}
void SettingsWindow::lightOnGValueChanged(QString value)
{
ui->lightOn_G_S->setValue(value.toInt());
}
void SettingsWindow::lightOnGValueChanged(int value)
{
ui->lightOn_G_LE->setText(QString::number(value));
}
void SettingsWindow::lightOnBValueChanged(QString value)
{
ui->lightOn_B_S->setValue(value.toInt());
}
void SettingsWindow::lightOnBValueChanged(int value)
{
ui->lightOn_B_LE->setText(QString::number(value));
}
#pragma endregion
#pragma region light
void SettingsWindow::lightRValueChanged(QString value)
{
ui->light_R_S->setValue(value.toInt());
if (ui->checkAutoColor->isChecked())
{
ui->lightOn_R_LE->setText(QString::number((int)(value.toInt() / 50)));
ui->lightOn_R_S->setValue((int)(value.toInt() / 50));
}
}
void SettingsWindow::lightRValueChanged(int value)
{
ui->light_R_LE->setText(QString::number(value));
if (ui->checkAutoColor->isChecked())
{
ui->lightOn_R_LE->setText(QString::number((int)(value / 50)));
ui->lightOn_R_S->setValue((int)(value / 50));
}
}
void SettingsWindow::lightGValueChanged(QString value)
{
ui->light_G_S->setValue(value.toInt());
if (ui->checkAutoColor->isChecked())
{
ui->lightOn_G_LE->setText(QString::number((int)(value.toInt() / 50)));
ui->lightOn_G_S->setValue((int)(value.toInt() / 50));
}
}
void SettingsWindow::lightGValueChanged(int value)
{
ui->light_G_LE->setText(QString::number(value));
if (ui->checkAutoColor->isChecked())
{
ui->lightOn_G_LE->setText(QString::number((int)(value / 50)));
ui->lightOn_G_S->setValue((int)(value / 50));
}
}
void SettingsWindow::lightBValueChanged(QString value)
{
ui->light_B_S->setValue(value.toInt());
if (ui->checkAutoColor->isChecked())
{
ui->lightOn_B_LE->setText(QString::number((int)(value.toInt() / 50)));
ui->lightOn_B_S->setValue((int)(value.toInt() / 50));
}
}
void SettingsWindow::lightBValueChanged(int value)
{
ui->light_B_LE->setText(QString::number(value));
if (ui->checkAutoColor->isChecked())
{
ui->lightOn_B_LE->setText(QString::number((int)(value / 50)));
ui->lightOn_B_S->setValue((int)(value / 50));
}
}
#pragma endregion
void SettingsWindow::autoColorToggled()
{
if (!ui->checkAutoColor->isChecked())
{
ui->lightOn_R_LE->setEnabled(true);
ui->lightOn_R_S->setEnabled(true);
ui->lightOn_G_LE->setEnabled(true);
ui->lightOn_G_S->setEnabled(true);
ui->lightOn_B_LE->setEnabled(true);
ui->lightOn_B_S->setEnabled(true);
}
else
{
ui->lightOn_R_LE->setEnabled(false);
ui->lightOn_R_S->setEnabled(false);
ui->lightOn_G_LE->setEnabled(false);
ui->lightOn_G_S->setEnabled(false);
ui->lightOn_B_LE->setEnabled(false);
ui->lightOn_B_S->setEnabled(false);
ui->lightOn_R_LE->setText(QString::number((int)(ui->light_R_S->value() / 50)));
ui->lightOn_R_S->setValue((int)(ui->light_R_S->value() / 50));
ui->lightOn_G_LE->setText(QString::number((int)(ui->light_G_S->value() / 50)));
ui->lightOn_G_S->setValue((int)(ui->light_G_S->value() / 50));
ui->lightOn_B_LE->setText(QString::number((int)(ui->light_B_S->value() / 50)));
ui->lightOn_B_S->setValue((int)(ui->light_B_S->value() / 50));
}
}
void SettingsWindow::radioToggled()
{
if(ui->radioDirectLight->isChecked())
{
ui->attFac->setValue(0.0);
ui->attFac->setEnabled(false);
}
else
{
ui->attFac->setEnabled(true);
}
}