Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
OpenGL
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
C-Fu
OpenGL
Commits
30d41f7d
Commit
30d41f7d
authored
Jan 24, 2017
by
Anakin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connected settings window with software
parent
15cd551f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
14 deletions
+108
-14
QtMeshViewer/Form Files/SettingsWindow.ui
QtMeshViewer/Form Files/SettingsWindow.ui
+3
-0
QtMeshViewer/Header/OglViewerWidget.h
QtMeshViewer/Header/OglViewerWidget.h
+7
-1
QtMeshViewer/Header/SettingsWindow.h
QtMeshViewer/Header/SettingsWindow.h
+11
-0
QtMeshViewer/Source/OglViewerWidget.cpp
QtMeshViewer/Source/OglViewerWidget.cpp
+55
-7
QtMeshViewer/Source/SettingsWindow.cpp
QtMeshViewer/Source/SettingsWindow.cpp
+32
-6
No files found.
QtMeshViewer/Form Files/SettingsWindow.ui
View file @
30d41f7d
...
...
@@ -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>
...
...
QtMeshViewer/Header/OglViewerWidget.h
View file @
30d41f7d
...
...
@@ -46,7 +46,8 @@ private:
SettingsWindow
*
m_settings
;
QVector4D
m_backgroundColor
=
{
0.5
f
,
0.8
f
,
1.0
f
,
1.0
f
};
QVector4D
m_backgroundColorOn
=
{
0.02
f
,
0.02
f
,
0.02
f
,
1.0
f
};
QVector4D
m_backgroundColorOff
=
{
0.5
f
,
0.8
f
,
1.0
f
,
1.0
f
};
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
);
...
...
QtMeshViewer/Header/SettingsWindow.h
View file @
30d41f7d
#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
);
};
\ No newline at end of file
QtMeshViewer/Source/OglViewerWidget.cpp
View file @
30d41f7d
...
...
@@ -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.0000
f
);
m_backgroundColor
[
3
]
=
0.0
;
glClearColor
(
m_backgroundColorOn
[
0
],
m_backgroundColorOn
[
1
],
m_backgroundColorOn
[
2
],
0.0000
f
);
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.0000
f
);
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.5
f
,
0.8
f
,
1.0
f
,
1.0
}
;
m_backgroundColor
Off
[
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.0
f
);
if
(
!
m_lightOn
)
update
();
}
void
OglViewerWidget
::
setBGColorOn
(
QVector3D
value
)
{
m_backgroundColorOn
=
QVector4D
(
value
/
255
,
1.0
f
);
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
();
}
QtMeshViewer/Source/SettingsWindow.cpp
View file @
30d41f7d
#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
()));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment