connected settings window with software
This commit is contained in:
parent
15cd551f7c
commit
30d41f7d85
@ -442,6 +442,9 @@
|
||||
</item>
|
||||
<item row="2" column="4" colspan="2">
|
||||
<widget class="QDoubleSpinBox" name="ambCoef">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>55</width>
|
||||
|
@ -46,7 +46,8 @@ private:
|
||||
|
||||
SettingsWindow* m_settings;
|
||||
|
||||
QVector4D m_backgroundColor = {0.5f, 0.8f, 1.0f, 1.0f};
|
||||
QVector4D m_backgroundColorOn = {0.02f, 0.02f, 0.02f, 1.0f};
|
||||
QVector4D m_backgroundColorOff = { 0.5f, 0.8f, 1.0f, 1.0f };
|
||||
|
||||
QOpenGLShaderProgram m_program;
|
||||
GeometryEngine *m_dataEngine;
|
||||
@ -86,6 +87,11 @@ public slots:
|
||||
void toggleWireframe();
|
||||
void toggleLight();
|
||||
void showSettings();
|
||||
void setBGColorOff(QVector3D value);
|
||||
void setBGColorOn(QVector3D value);
|
||||
void setLightColor(QVector3D value);
|
||||
void setAttFac(double value);
|
||||
void setAmbCoef(double value);
|
||||
|
||||
signals:
|
||||
void sendMessage(QString message, int severity);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <QWidget>
|
||||
#include "ui_SettingsWindow.h"
|
||||
#include <QVector3D>
|
||||
|
||||
class SettingsWindow : public QWidget
|
||||
{
|
||||
@ -16,4 +17,14 @@ private:
|
||||
private slots:
|
||||
void autoColorToggled();
|
||||
void radioToggled();
|
||||
void backgroundColorOffChanged();
|
||||
void backgroundColorOnChanged();
|
||||
void lightColorChanged();
|
||||
|
||||
signals:
|
||||
void updateBGColorOff(QVector3D value);
|
||||
void updateBGColorOn(QVector3D value);
|
||||
void updateLightColor(QVector3D value);
|
||||
void updateAttFac(double value);
|
||||
void updateAmbCoef(double value);
|
||||
};
|
@ -21,6 +21,11 @@ OglViewerWidget::OglViewerWidget(QWidget *parent)
|
||||
m_translation.setZ(DEFAULT_Z_DISTANCE);
|
||||
setAcceptDrops(true);
|
||||
|
||||
connect(m_settings, &SettingsWindow::updateBGColorOff, this, &OglViewerWidget::setBGColorOff);
|
||||
connect(m_settings, &SettingsWindow::updateBGColorOn, this, &OglViewerWidget::setBGColorOn);
|
||||
connect(m_settings, &SettingsWindow::updateLightColor, this, &OglViewerWidget::setLightColor);
|
||||
connect(m_settings, &SettingsWindow::updateAttFac, this, &OglViewerWidget::setAttFac);
|
||||
connect(m_settings, &SettingsWindow::updateAmbCoef, this, &OglViewerWidget::setAmbCoef);
|
||||
}
|
||||
|
||||
OglViewerWidget::~OglViewerWidget()
|
||||
@ -233,10 +238,15 @@ void OglViewerWidget::resizeGL(int w, int h)
|
||||
|
||||
void OglViewerWidget::paintGL()
|
||||
{
|
||||
if (m_backgroundColor[3] == 1.0)
|
||||
if (m_lightOn && m_backgroundColorOn[3] == 1.0)
|
||||
{
|
||||
glClearColor(m_backgroundColor[0], m_backgroundColor[1], m_backgroundColor[2], 0.0000f);
|
||||
m_backgroundColor[3] = 0.0;
|
||||
glClearColor(m_backgroundColorOn[0], m_backgroundColorOn[1], m_backgroundColorOn[2], 0.0000f);
|
||||
m_backgroundColorOn[3] = 0.0;
|
||||
}
|
||||
else if(!m_lightOn && m_backgroundColorOff[3] == 1.0)
|
||||
{
|
||||
glClearColor(m_backgroundColorOff[0], m_backgroundColorOff[1], m_backgroundColorOff[2], 0.0000f);
|
||||
m_backgroundColorOff[3] = 0.0;
|
||||
}
|
||||
|
||||
// Clear color and depth buffer
|
||||
@ -355,15 +365,13 @@ void OglViewerWidget::toggleLight()
|
||||
|
||||
if (m_lightOn)
|
||||
{
|
||||
m_backgroundColor = { m_light.intensities.x() / 50, m_light.intensities.y() / 50, m_light.intensities.z() / 50, 1.0 };
|
||||
|
||||
m_backgroundColorOn[3] = 1.0;
|
||||
updateLightPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_backgroundColor = { 0.5f, 0.8f, 1.0f, 1.0 };
|
||||
m_backgroundColorOff[3] = 1.0;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@ -371,3 +379,43 @@ void OglViewerWidget::showSettings()
|
||||
{
|
||||
m_settings->show();
|
||||
}
|
||||
|
||||
void OglViewerWidget::setBGColorOff(QVector3D value)
|
||||
{
|
||||
m_backgroundColorOff = QVector4D(value / 255, 1.0f);
|
||||
|
||||
if (!m_lightOn)
|
||||
update();
|
||||
}
|
||||
|
||||
void OglViewerWidget::setBGColorOn(QVector3D value)
|
||||
{
|
||||
m_backgroundColorOn = QVector4D(value / 255, 1.0f);
|
||||
|
||||
if (m_lightOn)
|
||||
update();
|
||||
}
|
||||
|
||||
void OglViewerWidget::setLightColor(QVector3D value)
|
||||
{
|
||||
m_light.intensities = value / 255;
|
||||
|
||||
if (m_lightOn)
|
||||
update();
|
||||
}
|
||||
|
||||
void OglViewerWidget::setAttFac(double value)
|
||||
{
|
||||
m_light.attenuationFactor = (float)value;
|
||||
|
||||
if (m_lightOn)
|
||||
update();
|
||||
}
|
||||
|
||||
void OglViewerWidget::setAmbCoef(double value)
|
||||
{
|
||||
m_light.ambientCoefficient = (float)value;
|
||||
|
||||
if (m_lightOn)
|
||||
update();
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
#include "..\Header\SettingsWindow.h"
|
||||
#include <QString>
|
||||
#include <QLineEdit>
|
||||
#include <QSlider>
|
||||
|
||||
SettingsWindow::SettingsWindow(QWidget * parent)
|
||||
: QWidget(parent)
|
||||
@ -14,37 +12,47 @@ SettingsWindow::SettingsWindow(QWidget * parent)
|
||||
// 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_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_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_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_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_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_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->isCecked()) ui->lightOn_R_S->setValue((int)(value / 50));});
|
||||
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_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->isCecked()) ui->lightOn_G_S->setValue((int)(value / 50));});
|
||||
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_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->isCecked()) ui->lightOn_B_S->setValue((int)(value / 50));});
|
||||
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_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
|
||||
|
||||
|
||||
connect(ui->checkAutoColor, &QCheckBox::toggled, this, &SettingsWindow::autoColorToggled);
|
||||
|
||||
connect(ui->radioDirectLight, &QRadioButton::toggled, this, &SettingsWindow::radioToggled);
|
||||
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); });
|
||||
}
|
||||
|
||||
SettingsWindow::~SettingsWindow()
|
||||
@ -90,9 +98,27 @@ void SettingsWindow::radioToggled()
|
||||
{
|
||||
ui->attFac->setValue(0.0);
|
||||
ui->attFac->setEnabled(false);
|
||||
ui->ambCoef->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->attFac->setEnabled(true);
|
||||
ui->ambCoef->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user