Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
KennethVanhoey
CGoGN
Commits
3194ec6e
Commit
3194ec6e
authored
Sep 23, 2014
by
Sylvain Thery
Browse files
color interface for schnapps render plugin
parent
9b43aa64
Changes
5
Hide whitespace changes
Inline
Side-by-side
SCHNApps/Plugins/surface_render/forms/surface_render.ui
View file @
3194ec6e
...
...
@@ -6,7 +6,7 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
2
00
</width>
<width>
2
46
</width>
<height>
600
</height>
</rect>
</property>
...
...
@@ -14,12 +14,23 @@
<string>
Form
</string>
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_2"
>
<property
name=
"text"
>
<string>
Position :
</string>
</property>
</widget>
<item
row=
"9"
column=
"0"
rowspan=
"2"
colspan=
"2"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_3"
>
<item>
<widget
class=
"QCheckBox"
name=
"check_renderEdges"
>
<property
name=
"text"
>
<string>
render edges
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"scolorButton"
>
<property
name=
"text"
>
<string>
Color
</string>
</property>
</widget>
</item>
</layout>
</item>
<item
row=
"1"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"combo_normalVBO"
>
...
...
@@ -36,27 +47,27 @@
</item>
</widget>
</item>
<item
row=
"
3
"
column=
"0"
colspan=
"2"
>
<
widget
class=
"QCheckBox"
name=
"check_renderVertices
"
>
<property
name=
"
text
"
>
<
string>
render vertices
</string
>
<item
row=
"
20
"
column=
"0"
colspan=
"2"
>
<
spacer
name=
"verticalSpacer
"
>
<property
name=
"
orientation
"
>
<
enum>
Qt::Vertical
</enum
>
</property>
</widget>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
156
</width>
<height>
161
</height>
</size>
</property>
</spacer>
</item>
<item
row=
"
7
"
column=
"0"
>
<widget
class=
"Q
RadioButton"
name=
"radio_flatShading
"
>
<item
row=
"
1
"
column=
"0"
>
<widget
class=
"Q
Label"
name=
"label_3
"
>
<property
name=
"text"
>
<string>
Flat
</string>
</property>
<property
name=
"checked"
>
<bool>
true
</bool>
<string>
Normal :
</string>
</property>
<attribute
name=
"buttonGroup"
>
<string
notr=
"true"
>
group_faceShading
</string>
</attribute>
</widget>
</item>
<item
row=
"
7
"
column=
"1"
>
<item
row=
"
15
"
column=
"1"
>
<widget
class=
"QRadioButton"
name=
"radio_phongShading"
>
<property
name=
"text"
>
<string>
Phong
</string>
...
...
@@ -66,38 +77,42 @@
</attribute>
</widget>
</item>
<item
row=
"
1
"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_
3
"
>
<item
row=
"
0
"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_
2
"
>
<property
name=
"text"
>
<string>
Normal
:
</string>
<string>
Position
:
</string>
</property>
</widget>
</item>
<item
row=
"6"
column=
"0"
colspan=
"2"
>
<widget
class=
"Q
CheckBox"
name=
"check_renderFaces
"
>
<property
name=
"
text
"
>
<
string>
render faces
</string
>
<widget
class=
"Q
Slider"
name=
"slider_verticesScaleFactor
"
>
<property
name=
"
value
"
>
<
number>
50
</number
>
</property>
<property
name=
"
checked
"
>
<
bool>
true
</bool
>
<property
name=
"
orientation
"
>
<
enum>
Qt::Horizontal
</enum
>
</property>
</widget>
</item>
<item
row=
"2"
column=
"0"
colspan=
"2"
>
<widget
class=
"Line"
name=
"line"
/>
<item
row=
"16"
column=
"0"
colspan=
"2"
>
<widget
class=
"QCheckBox"
name=
"check_renderBoundary"
>
<property
name=
"text"
>
<string>
render boundary
</string>
</property>
</widget>
</item>
<item
row=
"
9
"
column=
"0"
colspan=
"2"
>
<
spacer
name=
"verticalSpacer
"
>
<property
name=
"
orientation
"
>
<
enum>
Qt::Vertical
</enum
>
<item
row=
"
15
"
column=
"0"
>
<
widget
class=
"QRadioButton"
name=
"radio_flatShading
"
>
<property
name=
"
text
"
>
<
string>
Flat
</string
>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
156
</width>
<height>
161
</height>
</size>
<property
name=
"checked"
>
<bool>
true
</bool>
</property>
</spacer>
<attribute
name=
"buttonGroup"
>
<string
notr=
"true"
>
group_faceShading
</string>
</attribute>
</widget>
</item>
<item
row=
"0"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"combo_positionVBO"
>
...
...
@@ -114,29 +129,165 @@
</item>
</widget>
</item>
<item
row=
"5"
column=
"0"
colspan=
"2"
>
<widget
class=
"QCheckBox"
name=
"check_renderEdges"
>
<property
name=
"text"
>
<string>
render edges
</string>
</property>
</widget>
<item
row=
"2"
column=
"0"
colspan=
"2"
>
<widget
class=
"Line"
name=
"line"
/>
</item>
<item
row=
"4"
column=
"0"
colspan=
"2"
>
<widget
class=
"QSlider"
name=
"slider_verticesScaleFactor"
>
<property
name=
"value"
>
<number>
50
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
<item
row=
"12"
column=
"0"
rowspan=
"2"
colspan=
"2"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<item>
<widget
class=
"QCheckBox"
name=
"check_renderFaces"
>
<property
name=
"text"
>
<string>
render faces
</string>
</property>
<property
name=
"checked"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"dcolorButton"
>
<property
name=
"palette"
>
<palette>
<active>
<colorrole
role=
"WindowText"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
255
</red>
<green>
0
</green>
<blue>
0
</blue>
</color>
</brush>
</colorrole>
<colorrole
role=
"Button"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
0
</red>
<green>
255
</green>
<blue>
0
</blue>
</color>
</brush>
</colorrole>
<colorrole
role=
"Base"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
255
</red>
<green>
255
</green>
<blue>
255
</blue>
</color>
</brush>
</colorrole>
<colorrole
role=
"Window"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
170
</red>
<green>
0
</green>
<blue>
255
</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole
role=
"WindowText"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
255
</red>
<green>
0
</green>
<blue>
0
</blue>
</color>
</brush>
</colorrole>
<colorrole
role=
"Button"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
0
</red>
<green>
255
</green>
<blue>
0
</blue>
</color>
</brush>
</colorrole>
<colorrole
role=
"Base"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
255
</red>
<green>
255
</green>
<blue>
255
</blue>
</color>
</brush>
</colorrole>
<colorrole
role=
"Window"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
170
</red>
<green>
0
</green>
<blue>
255
</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole
role=
"WindowText"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
143
</red>
<green>
146
</green>
<blue>
147
</blue>
</color>
</brush>
</colorrole>
<colorrole
role=
"Button"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
0
</red>
<green>
255
</green>
<blue>
0
</blue>
</color>
</brush>
</colorrole>
<colorrole
role=
"Base"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
170
</red>
<green>
0
</green>
<blue>
255
</blue>
</color>
</brush>
</colorrole>
<colorrole
role=
"Window"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
170
</red>
<green>
0
</green>
<blue>
255
</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property
name=
"text"
>
<string>
Color
</string>
</property>
</widget>
</item>
</layout>
</item>
<item
row=
"8"
column=
"0"
colspan=
"2"
>
<widget
class=
"QCheckBox"
name=
"check_renderBoundary"
>
<property
name=
"text"
>
<string>
render boundary
</string>
</property>
</widget>
<item
row=
"3"
column=
"0"
rowspan=
"2"
colspan=
"2"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_4"
>
<item>
<widget
class=
"QCheckBox"
name=
"check_renderVertices"
>
<property
name=
"text"
>
<string>
render vertices
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"vcolorButton"
>
<property
name=
"text"
>
<string>
Color
</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
...
...
SCHNApps/Plugins/surface_render/include/surface_render.h
View file @
3194ec6e
...
...
@@ -32,7 +32,11 @@ struct MapParameters
renderVertices
(
false
),
renderEdges
(
false
),
renderFaces
(
true
),
faceStyle
(
FLAT
)
faceStyle
(
FLAT
),
diffuseColor
(
0.8
,
0.9
,
0.7
,
0.0
),
simpleColor
(
0.0
,
0.0
,
0.0
,
0.0
),
vertexColor
(
0.0
,
0.0
,
1.0
,
0.0
)
{}
Utils
::
VBO
*
positionVBO
;
...
...
@@ -43,6 +47,10 @@ struct MapParameters
bool
renderFaces
;
bool
renderBoundary
;
FaceShadingStyle
faceStyle
;
Geom
::
Vec4f
diffuseColor
;
Geom
::
Vec4f
simpleColor
;
Geom
::
Vec4f
vertexColor
;
};
class
Surface_Render_Plugin
:
public
PluginInteraction
...
...
SCHNApps/Plugins/surface_render/include/surface_render_dockTab.h
View file @
3194ec6e
...
...
@@ -3,6 +3,7 @@
#include
"ui_surface_render.h"
#include
"Utils/vbo.h"
#include
<QColorDialog>
namespace
CGoGN
{
...
...
@@ -27,6 +28,11 @@ private:
SCHNApps
*
m_schnapps
;
Surface_Render_Plugin
*
m_plugin
;
bool
b_updatingUI
;
QColorDialog
*
m_colorDial
;
QColor
m_diffuseColor
;
QColor
m_simpleColor
;
QColor
m_vertexColor
;
int
m_currentColorDial
;
private
slots
:
void
positionVBOChanged
(
int
index
);
...
...
@@ -38,6 +44,13 @@ private slots:
void
faceStyleChanged
(
QAbstractButton
*
b
);
void
renderBoundaryChanged
(
bool
b
);
void
diffuseColorClicked
();
void
simpleColorClicked
();
void
vertexColorClicked
();
void
colorSelected
(
const
QColor
&
col
);
private:
void
addPositionVBO
(
QString
name
);
void
removePositionVBO
(
QString
name
);
...
...
SCHNApps/Plugins/surface_render/src/surface_render.cpp
View file @
3194ec6e
...
...
@@ -74,7 +74,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
{
m_pointSprite
->
setSize
(
map
->
getBBdiagSize
()
/
200.0
f
*
p
.
verticesScaleFactor
);
m_pointSprite
->
setAttributePosition
(
p
.
positionVBO
);
m_pointSprite
->
setColor
(
CGoGN
::
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
1.0
f
,
1.0
f
)
);
m_pointSprite
->
setColor
(
p
.
vertexColor
);
map
->
draw
(
m_pointSprite
,
CGoGN
::
Algo
::
Render
::
GL2
::
POINTS
);
}
if
(
p
.
renderEdges
)
...
...
@@ -83,6 +83,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
CGoGN
::
Geom
::
Vec4f
c
(
0.1
f
,
0.1
f
,
0.1
f
,
1.0
f
);
m_simpleColorShader
->
setColor
(
c
);
m_simpleColorShader
->
setAttributePosition
(
p
.
positionVBO
);
m_simpleColorShader
->
setColor
(
p
.
simpleColor
);
map
->
draw
(
m_simpleColorShader
,
CGoGN
::
Algo
::
Render
::
GL2
::
LINES
);
}
if
(
p
.
renderFaces
)
...
...
@@ -95,6 +96,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
{
case
MapParameters
::
FLAT
:
m_flatShader
->
setAttributePosition
(
p
.
positionVBO
);
m_flatShader
->
setDiffuse
(
p
.
diffuseColor
);
map
->
draw
(
m_flatShader
,
CGoGN
::
Algo
::
Render
::
GL2
::
TRIANGLES
);
break
;
case
MapParameters
::
PHONG
:
...
...
@@ -102,6 +104,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
{
m_phongShader
->
setAttributePosition
(
p
.
positionVBO
);
m_phongShader
->
setAttributeNormal
(
p
.
normalVBO
);
m_phongShader
->
setDiffuse
(
p
.
diffuseColor
);
map
->
draw
(
m_phongShader
,
CGoGN
::
Algo
::
Render
::
GL2
::
TRIANGLES
);
}
break
;
...
...
SCHNApps/Plugins/surface_render/src/surface_render_dockTab.cpp
View file @
3194ec6e
...
...
@@ -13,7 +13,9 @@ namespace SCHNApps
Surface_Render_DockTab
::
Surface_Render_DockTab
(
SCHNApps
*
s
,
Surface_Render_Plugin
*
p
)
:
m_schnapps
(
s
),
m_plugin
(
p
),
b_updatingUI
(
false
)
b_updatingUI
(
false
),
m_currentColorDial
(
0
)
{
setupUi
(
this
);
...
...
@@ -25,6 +27,91 @@ Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugi
connect
(
check_renderFaces
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
renderFacesChanged
(
bool
)));
connect
(
group_faceShading
,
SIGNAL
(
buttonClicked
(
QAbstractButton
*
)),
this
,
SLOT
(
faceStyleChanged
(
QAbstractButton
*
)));
connect
(
check_renderBoundary
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
renderBoundaryChanged
(
bool
)));
m_colorDial
=
new
QColorDialog
(
m_diffuseColor
,
NULL
);
connect
(
dcolorButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
diffuseColorClicked
()));
connect
(
scolorButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
simpleColorClicked
()));
connect
(
vcolorButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
vertexColorClicked
()));
connect
(
m_colorDial
,
SIGNAL
(
colorSelected
(
const
QColor
&
)),
this
,
SLOT
(
colorSelected
(
const
QColor
&
)));
}
void
Surface_Render_DockTab
::
diffuseColorClicked
()
{
m_colorDial
->
show
();
m_colorDial
->
setCurrentColor
(
m_diffuseColor
);
m_currentColorDial
=
1
;
}
void
Surface_Render_DockTab
::
simpleColorClicked
()
{
m_colorDial
->
show
();
m_colorDial
->
setCurrentColor
(
m_simpleColor
);
m_currentColorDial
=
2
;
}
void
Surface_Render_DockTab
::
vertexColorClicked
()
{
m_colorDial
->
show
();
m_colorDial
->
setCurrentColor
(
m_vertexColor
);
m_currentColorDial
=
3
;
}
void
Surface_Render_DockTab
::
colorSelected
(
const
QColor
&
col
)
{
if
(
m_currentColorDial
==
1
)
{
m_diffuseColor
=
col
;
dcolorButton
->
setStyleSheet
(
"QPushButton { background-color:"
+
col
.
name
()
+
"}"
);
Geom
::
Vec4f
rgbCol
(
1.0
/
255.0
*
m_diffuseColor
.
red
(),
1.0
/
255.0
*
m_diffuseColor
.
green
(),
1.0
/
255.0
*
m_diffuseColor
.
blue
(),
0.0
f
);
View
*
view
=
m_schnapps
->
getSelectedView
();
MapHandlerGen
*
map
=
m_schnapps
->
getSelectedMap
();
if
(
view
&&
map
)
{
m_plugin
->
h_viewParameterSet
[
view
][
map
].
diffuseColor
=
rgbCol
;
view
->
updateGL
();
}
}
if
(
m_currentColorDial
==
2
)
{
m_simpleColor
=
col
;
scolorButton
->
setStyleSheet
(
"QPushButton { background-color:"
+
col
.
name
()
+
"}"
);
Geom
::
Vec4f
rgbCol
(
1.0
/
255.0
*
m_simpleColor
.
red
(),
1.0
/
255.0
*
m_simpleColor
.
green
(),
1.0
/
255.0
*
m_simpleColor
.
blue
(),
0.0
f
);
View
*
view
=
m_schnapps
->
getSelectedView
();
MapHandlerGen
*
map
=
m_schnapps
->
getSelectedMap
();
if
(
view
&&
map
)
{
m_plugin
->
h_viewParameterSet
[
view
][
map
].
simpleColor
=
rgbCol
;
view
->
updateGL
();
}
}
if
(
m_currentColorDial
==
3
)
{
m_vertexColor
=
col
;
vcolorButton
->
setStyleSheet
(
"QPushButton { background-color:"
+
col
.
name
()
+
"}"
);
Geom
::
Vec4f
rgbCol
(
1.0
/
255.0
*
m_vertexColor
.
red
(),
1.0
/
255.0
*
m_vertexColor
.
green
(),
1.0
/
255.0
*
m_vertexColor
.
blue
(),
0.0
f
);
View
*
view
=
m_schnapps
->
getSelectedView
();
MapHandlerGen
*
map
=
m_schnapps
->
getSelectedMap
();
if
(
view
&&
map
)
{
m_plugin
->
h_viewParameterSet
[
view
][
map
].
vertexColor
=
rgbCol
;
view
->
updateGL
();
}
}
}
...
...
@@ -226,6 +313,17 @@ void Surface_Render_DockTab::updateMapParameters()
check_renderFaces
->
setChecked
(
p
.
renderFaces
);
radio_flatShading
->
setChecked
(
p
.
faceStyle
==
MapParameters
::
FLAT
);
radio_phongShading
->
setChecked
(
p
.
faceStyle
==
MapParameters
::
PHONG
);
m_diffuseColor
=
QColor
(
255
*
p
.
diffuseColor
[
0
],
255
*
p
.
diffuseColor
[
1
],
255
*
p
.
diffuseColor
[
2
]);
dcolorButton
->
setStyleSheet
(
"QPushButton { background-color:"
+
m_diffuseColor
.
name
()
+
" }"
);
m_simpleColor
=
QColor
(
255
*
p
.
simpleColor
[
0
],
255
*
p
.
simpleColor
[
1
],
255
*
p
.
simpleColor
[
2
]);
scolorButton
->
setStyleSheet
(
"QPushButton { background-color:"
+
m_simpleColor
.
name
()
+
" }"
);
m_vertexColor
=
QColor
(
255
*
p
.
simpleColor
[
0
],
255
*
p
.
vertexColor
[
1
],
255
*
p
.
vertexColor
[
2
]);
vcolorButton
->
setStyleSheet
(
"QPushButton { background-color:"
+
m_vertexColor
.
name
()
+
" }"
);
}
b_updatingUI
=
false
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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