connected settings window with software
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user