switch from QLineEdit to QSpinBox,
init SettingsWindow with default values from OglViewerWidget, removed old qt project
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="4" column="5">
|
||||
<widget class="QLineEdit" name="lightOn_G_LE">
|
||||
<widget class="QSpinBox" name="lightOn_G_SB">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@@ -31,8 +31,11 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -86,7 +89,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="8">
|
||||
<widget class="QLineEdit" name="lightOn_B_LE">
|
||||
<widget class="QSpinBox" name="lightOn_B_SB">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@@ -96,8 +99,11 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -123,28 +129,34 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="5">
|
||||
<widget class="QLineEdit" name="lightOff_G_LE">
|
||||
<widget class="QSpinBox" name="lightOff_G_SB">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>204</string>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="8">
|
||||
<widget class="QLineEdit" name="lightOff_B_LE">
|
||||
<widget class="QSpinBox" name="lightOff_B_SB">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>255</string>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -162,7 +174,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLineEdit" name="lightOff_R_LE">
|
||||
<widget class="QSpinBox" name="lightOff_R_SB">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@@ -172,8 +184,11 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>127</string>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -225,7 +240,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QLineEdit" name="lightOn_R_LE">
|
||||
<widget class="QSpinBox" name="lightOn_R_SB">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@@ -235,8 +250,11 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -314,28 +332,34 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QLineEdit" name="light_G_LE">
|
||||
<widget class="QSpinBox" name="light_G_SB">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>255</string>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="light_R_LE">
|
||||
<widget class="QSpinBox" name="light_R_SB">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>255</string>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -350,15 +374,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="7">
|
||||
<widget class="QLineEdit" name="light_B_LE">
|
||||
<widget class="QSpinBox" name="light_B_SB">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>255</string>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -443,7 +470,7 @@
|
||||
<item row="2" column="4" colspan="2">
|
||||
<widget class="QDoubleSpinBox" name="ambCoef">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
|
@@ -8,12 +8,14 @@ class SettingsWindow : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SettingsWindow(QWidget * parent = Q_NULLPTR);
|
||||
SettingsWindow(QVector3D bgOffColor, QVector3D bgOnColor, QVector3D lightColor, bool autoColor, double ambCoef, double attFac, int lightType, QWidget * parent = Q_NULLPTR);
|
||||
~SettingsWindow();
|
||||
|
||||
private:
|
||||
Ui::SettingsWindow* ui;
|
||||
|
||||
void setupConnections();
|
||||
|
||||
private slots:
|
||||
void autoColorToggled();
|
||||
void radioToggled();
|
||||
|
@@ -15,12 +15,13 @@
|
||||
OglViewerWidget::OglViewerWidget(QWidget *parent)
|
||||
: QOpenGLWidget(parent)
|
||||
, m_dataEngine(0)
|
||||
, m_settings(new SettingsWindow(this))
|
||||
{
|
||||
setFocus();
|
||||
m_translation.setZ(DEFAULT_Z_DISTANCE);
|
||||
setAcceptDrops(true);
|
||||
|
||||
m_settings = new SettingsWindow(m_backgroundColorOff.toVector3D() * 255, m_backgroundColorOn.toVector3D() * 255, m_light.intensities * 255, true, m_light.ambientCoefficient, m_light.attenuationFactor, 1, this);
|
||||
|
||||
connect(m_settings, &SettingsWindow::updateBGColorOff, this, &OglViewerWidget::setBGColorOff);
|
||||
connect(m_settings, &SettingsWindow::updateBGColorOn, this, &OglViewerWidget::setBGColorOn);
|
||||
connect(m_settings, &SettingsWindow::updateLightColor, this, &OglViewerWidget::setLightColor);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include "..\Header\SettingsWindow.h"
|
||||
#include <QString>
|
||||
|
||||
SettingsWindow::SettingsWindow(QWidget * parent)
|
||||
SettingsWindow::SettingsWindow(QVector3D bgOffColor, QVector3D bgOnColor, QVector3D lightColor, bool autoColor, double ambCoef, double attFac, int lightType, QWidget * parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::SettingsWindow)
|
||||
{
|
||||
@@ -9,43 +9,74 @@ SettingsWindow::SettingsWindow(QWidget * parent)
|
||||
|
||||
setWindowFlags(Qt::Tool | Qt::NoDropShadowWindowHint);
|
||||
|
||||
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()
|
||||
{
|
||||
// light off
|
||||
connect(ui->lightOff_R_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOff_R_S->setValue(value.toInt());});
|
||||
connect(ui->lightOff_R_S, &QSlider::valueChanged, [this](const int& value){ui->lightOff_R_LE->setText(QString::number(value));});
|
||||
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)));
|
||||
connect(ui->lightOff_R_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOffChanged);
|
||||
|
||||
connect(ui->lightOff_G_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOff_G_S->setValue(value.toInt());});
|
||||
connect(ui->lightOff_G_S, &QSlider::valueChanged, [this](const int& value){ui->lightOff_G_LE->setText(QString::number(value));});
|
||||
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)));
|
||||
connect(ui->lightOff_G_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOffChanged);
|
||||
|
||||
connect(ui->lightOff_B_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOff_B_S->setValue(value.toInt());});
|
||||
connect(ui->lightOff_B_S, &QSlider::valueChanged, [this](const int& value){ui->lightOff_B_LE->setText(QString::number(value));});
|
||||
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)));
|
||||
connect(ui->lightOff_B_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOffChanged);
|
||||
|
||||
// light on
|
||||
connect(ui->lightOn_R_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOn_R_S->setValue(value.toInt());});
|
||||
connect(ui->lightOn_R_S, &QSlider::valueChanged, [this](const int& value){ui->lightOn_R_LE->setText(QString::number(value));});
|
||||
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)));
|
||||
connect(ui->lightOn_R_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOnChanged);
|
||||
|
||||
connect(ui->lightOn_G_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOn_G_S->setValue(value.toInt());});
|
||||
connect(ui->lightOn_G_S, &QSlider::valueChanged, [this](const int& value){ui->lightOn_G_LE->setText(QString::number(value));});
|
||||
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)));
|
||||
connect(ui->lightOn_G_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOnChanged);
|
||||
|
||||
connect(ui->lightOn_B_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOn_B_S->setValue(value.toInt());});
|
||||
connect(ui->lightOn_B_S, &QSlider::valueChanged, [this](const int& value){ui->lightOn_B_LE->setText(QString::number(value));});
|
||||
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)));
|
||||
connect(ui->lightOn_B_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOnChanged);
|
||||
|
||||
// light
|
||||
connect(ui->light_R_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_R_S->setValue(value.toInt());});
|
||||
connect(ui->light_R_S, &QSlider::valueChanged, [this](const int& value){ui->light_R_LE->setText(QString::number(value)); if(ui->checkAutoColor->isChecked()) ui->lightOn_R_S->setValue((int)(value / 50));});
|
||||
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)));
|
||||
connect(ui->light_R_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
|
||||
|
||||
connect(ui->light_G_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_G_S->setValue(value.toInt());});
|
||||
connect(ui->light_G_S, &QSlider::valueChanged, [this](const int& value){ui->light_G_LE->setText(QString::number(value)); if(ui->checkAutoColor->isChecked()) ui->lightOn_G_S->setValue((int)(value / 50));});
|
||||
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)));
|
||||
connect(ui->light_G_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
|
||||
|
||||
connect(ui->light_B_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_B_S->setValue(value.toInt());});
|
||||
connect(ui->light_B_S, &QSlider::valueChanged, [this](const int& value){ui->light_B_LE->setText(QString::number(value)); if(ui->checkAutoColor->isChecked()) ui->lightOn_B_S->setValue((int)(value / 50));});
|
||||
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)));
|
||||
connect(ui->light_B_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
|
||||
|
||||
|
||||
@@ -55,10 +86,6 @@ SettingsWindow::SettingsWindow(QWidget * parent)
|
||||
connect(ui->attFac, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double value) {emit updateAttFac(value); });
|
||||
}
|
||||
|
||||
SettingsWindow::~SettingsWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// connection slots
|
||||
@@ -67,43 +94,38 @@ void SettingsWindow::autoColorToggled()
|
||||
{
|
||||
if (!ui->checkAutoColor->isChecked())
|
||||
{
|
||||
ui->lightOn_R_LE->setEnabled(true);
|
||||
ui->lightOn_R_SB->setEnabled(true);
|
||||
ui->lightOn_R_S->setEnabled(true);
|
||||
ui->lightOn_G_LE->setEnabled(true);
|
||||
ui->lightOn_G_SB->setEnabled(true);
|
||||
ui->lightOn_G_S->setEnabled(true);
|
||||
ui->lightOn_B_LE->setEnabled(true);
|
||||
ui->lightOn_B_SB->setEnabled(true);
|
||||
ui->lightOn_B_S->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->lightOn_R_LE->setEnabled(false);
|
||||
ui->lightOn_R_SB->setEnabled(false);
|
||||
ui->lightOn_R_S->setEnabled(false);
|
||||
ui->lightOn_G_LE->setEnabled(false);
|
||||
ui->lightOn_G_SB->setEnabled(false);
|
||||
ui->lightOn_G_S->setEnabled(false);
|
||||
ui->lightOn_B_LE->setEnabled(false);
|
||||
ui->lightOn_B_SB->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())
|
||||
if (ui->radioDirectLight->isChecked())
|
||||
{
|
||||
ui->attFac->setValue(0.0);
|
||||
ui->attFac->setEnabled(false);
|
||||
ui->ambCoef->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->attFac->setEnabled(true);
|
||||
ui->ambCoef->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,5 +142,12 @@ void SettingsWindow::backgroundColorOnChanged()
|
||||
void SettingsWindow::lightColorChanged()
|
||||
{
|
||||
emit updateLightColor(QVector3D(ui->light_R_S->value(), ui->light_G_S->value(), ui->light_B_S->value()));
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user