Commit ccfbc3cc by Sebastian Eichelbaum

[CHANGE] GridRenderer now allows to tune the line widths of the grid and the BB.

parent 8a80211e
......@@ -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;
}
......
......@@ -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
......
......@@ -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 )
{
......
......@@ -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
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment