Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
ccfbc3cc
Commit
ccfbc3cc
authored
Sep 02, 2015
by
Sebastian Eichelbaum
Browse files
[CHANGE] GridRenderer now allows to tune the line widths of the grid and the BB.
parent
8a80211e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
2 deletions
+93
-2
src/core/graphicsEngine/geodes/WGEGridNode.cpp
src/core/graphicsEngine/geodes/WGEGridNode.cpp
+33
-2
src/core/graphicsEngine/geodes/WGEGridNode.h
src/core/graphicsEngine/geodes/WGEGridNode.h
+38
-0
src/modules/gridRenderer/WMGridRenderer.cpp
src/modules/gridRenderer/WMGridRenderer.cpp
+18
-0
src/modules/gridRenderer/WMGridRenderer.h
src/modules/gridRenderer/WMGridRenderer.h
+4
-0
No files found.
src/core/graphicsEngine/geodes/WGEGridNode.cpp
View file @
ccfbc3cc
...
...
@@ -39,7 +39,9 @@ WGEGridNode::WGEGridNode( WGridRegular3D::ConstSPtr grid ):
m_gridGeometryUpdate
(
true
),
m_showLabels
(
true
),
m_bbColor
(
WColor
(
0.3
,
0.3
,
0.3
,
1.0
)
),
m_gridColor
(
WColor
(
0.1
,
0.1
,
0.1
,
1.0
)
)
m_gridColor
(
WColor
(
0.1
,
0.1
,
0.1
,
1.0
)
),
m_gridLineWidth
(
1
),
m_boxLineWidth
(
4
)
{
m_grid
.
getWriteTicket
()
->
get
()
=
grid
;
...
...
@@ -109,7 +111,8 @@ WGEGridNode::WGEGridNode( WGridRegular3D::ConstSPtr grid ):
addChild
(
m_innerGridGeode
);
addChild
(
m_labelGeode
);
m_boundaryGeode
->
getOrCreateStateSet
()
->
setAttributeAndModes
(
new
osg
::
LineWidth
(
4.0
),
osg
::
StateAttribute
::
ON
);
m_boundaryGeode
->
getOrCreateStateSet
()
->
setAttributeAndModes
(
new
osg
::
LineWidth
(
m_boxLineWidth
),
osg
::
StateAttribute
::
ON
);
m_innerGridGeode
->
getOrCreateStateSet
()
->
setAttributeAndModes
(
new
osg
::
LineWidth
(
m_gridLineWidth
),
osg
::
StateAttribute
::
ON
);
addUpdateCallback
(
new
WGEFunctorCallback
<
osg
::
Node
>
(
boost
::
bind
(
&
WGEGridNode
::
callback
,
this
,
_1
)
)
);
...
...
@@ -191,6 +194,28 @@ void WGEGridNode::setGridColor( const WColor& color )
m_gridUpdate
=
true
;
}
void
WGEGridNode
::
setGridLineWidth
(
int
linewidth
)
{
m_gridLineWidth
=
linewidth
;
m_gridUpdate
=
true
;
}
void
WGEGridNode
::
setBoxLineWidth
(
int
linewidth
)
{
m_boxLineWidth
=
linewidth
;
m_gridUpdate
=
true
;
}
int
WGEGridNode
::
getGridLineWidth
()
const
{
return
m_gridLineWidth
;
}
int
WGEGridNode
::
getBoxLineWidth
()
const
{
return
m_boxLineWidth
;
}
/**
* Simply converts the vector to an string.
*
...
...
@@ -244,6 +269,9 @@ void WGEGridNode::callback( osg::Node* /*node*/ )
m_innerGridGeode
->
getDrawable
(
0
)
->
asGeometry
()
->
setColorBinding
(
osg
::
Geometry
::
BIND_OVERALL
);
}
m_innerGridGeode
->
getOrCreateStateSet
()
->
setAttributeAndModes
(
new
osg
::
LineWidth
(
m_gridLineWidth
),
osg
::
StateAttribute
::
ON
);
m_boundaryGeode
->
getOrCreateStateSet
()
->
setAttributeAndModes
(
new
osg
::
LineWidth
(
m_boxLineWidth
),
osg
::
StateAttribute
::
ON
);
m_gridUpdate
=
false
;
}
...
...
@@ -314,6 +342,9 @@ void WGEGridNode::callback( osg::Node* /*node*/ )
m_innerGridGeode
->
addDrawable
(
gridGeometry
);
}
m_innerGridGeode
->
getOrCreateStateSet
()
->
setAttributeAndModes
(
new
osg
::
LineWidth
(
m_gridLineWidth
),
osg
::
StateAttribute
::
ON
);
m_boundaryGeode
->
getOrCreateStateSet
()
->
setAttributeAndModes
(
new
osg
::
LineWidth
(
m_boxLineWidth
),
osg
::
StateAttribute
::
ON
);
// we create a unit cube here as the transformation matrix already contains the proper scaling.
m_gridGeometryUpdate
=
false
;
}
...
...
src/core/graphicsEngine/geodes/WGEGridNode.h
View file @
ccfbc3cc
...
...
@@ -146,6 +146,34 @@ public:
*/
void
setGridColor
(
const
WColor
&
color
);
/**
* Set the line width of the gird.
*
* \param linewidth the linewidth. Default is 1.
*/
void
setGridLineWidth
(
int
linewidth
=
1
);
/**
* Set the line width of the bounding box.
*
* \param linewidth the linewidth. Default is 4.
*/
void
setBoxLineWidth
(
int
linewidth
=
4
);
/**
* Get the line width of the gird.
*
* \return the linewidth.
*/
int
getGridLineWidth
()
const
;
/**
* get the line width of the bounding box.
*
* \return the linewidth.
*/
int
getBoxLineWidth
()
const
;
protected:
private:
/**
...
...
@@ -214,6 +242,16 @@ private:
* The color of the grid.
*/
WColor
m_gridColor
;
/**
* Line width used for the grid
*/
int
m_gridLineWidth
;
/**
* The line width of the box.
*/
int
m_boxLineWidth
;
};
#endif // WGEGRIDNODE_H
...
...
src/modules/gridRenderer/WMGridRenderer.cpp
View file @
ccfbc3cc
...
...
@@ -178,6 +178,8 @@ void WMGridRenderer::moduleMain()
m_gridNode
->
setBBoxColor
(
*
m_bboxColor
);
m_gridNode
->
setGridColor
(
*
m_gridColor
);
m_gridNode
->
setGridLineWidth
(
m_gridLineWidth
->
get
()
);
m_gridNode
->
setBoxLineWidth
(
m_boxLineWidth
->
get
()
);
updateNode
(
m_mode
);
m_gridNode
->
setGrid
(
regGrid
);
}
...
...
@@ -205,8 +207,14 @@ void WMGridRenderer::properties()
WPropertyBase
::
PropertyChangeNotifierType
notifier
=
boost
::
bind
(
&
WMGridRenderer
::
updateNode
,
this
,
_1
);
m_bboxColor
=
m_properties
->
addProperty
(
"Bounding box color"
,
"The color of the bounding box."
,
WColor
(
0.3
,
0.3
,
0.3
,
1.0
),
notifier
);
m_boxLineWidth
=
m_properties
->
addProperty
(
"Bounding box line width"
,
"The width of the grid lines."
,
4
,
notifier
);
m_boxLineWidth
->
setMin
(
1
);
m_boxLineWidth
->
setMax
(
10
);
m_gridColor
=
m_properties
->
addProperty
(
"Grid color"
,
"The color of the grid."
,
WColor
(
0.1
,
0.1
,
0.1
,
1.0
),
notifier
);
m_gridLineWidth
=
m_properties
->
addProperty
(
"Grid line width"
,
"The width of the grid lines."
,
1
,
notifier
);
m_gridLineWidth
->
setMin
(
1
);
m_gridLineWidth
->
setMax
(
10
);
m_possibleModes
=
WItemSelection
::
SPtr
(
new
WItemSelection
()
);
m_possibleModes
->
addItem
(
"Labels"
,
"Show the boundary labels."
,
WMGridRenderer_label_xpm
);
// NOTE: you can add XPM images here.
...
...
@@ -241,6 +249,16 @@ void WMGridRenderer::updateNode( WPropertyBase::SPtr property )
m_gridNode
->
setGridColor
(
*
m_gridColor
);
}
if
(
property
==
m_gridLineWidth
)
{
m_gridNode
->
setGridLineWidth
(
m_gridLineWidth
->
get
()
);
}
if
(
property
==
m_boxLineWidth
)
{
m_gridNode
->
setBoxLineWidth
(
m_boxLineWidth
->
get
()
);
}
// mode changed
if
(
property
==
m_mode
)
{
...
...
src/modules/gridRenderer/WMGridRenderer.h
View file @
ccfbc3cc
...
...
@@ -115,6 +115,10 @@ private:
WPropColor
m_gridColor
;
//!< the color of the grid
WPropInt
m_boxLineWidth
;
//!< the width of the boundary lines
WPropInt
m_gridLineWidth
;
//!< the width of the grid lines
/**
* This condition denotes whether we need to recompute the surface
*/
...
...
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