Commit ef840dc6 authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[ADD #289] added progress and avoided unnecessary update of the graphics

parent b65dda88
......@@ -128,6 +128,9 @@ void WMVectorPlot::moduleMain()
break;
}
boost::shared_ptr< WProgress > progress = boost::shared_ptr< WProgress >( new WProgress( "Vector Plot", 2 ) );
m_progress->addSubProgress( progress );
boost::shared_ptr< WDataSetVector > newDataSet = m_input->getData();
bool dataChanged = ( m_dataSet != newDataSet );
bool dataValid = ( newDataSet );
......@@ -144,6 +147,8 @@ void WMVectorPlot::moduleMain()
newRootNode->addDrawable( buildPlotSlices() );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
++*progress;
m_rootNode = newRootNode;
m_rootNode->setNodeMask( m_active->get() ? 0xFFFFFFFF : 0x0 );
m_rootNode->addUpdateCallback( new SafeUpdateCallback( this ) );
......@@ -152,6 +157,7 @@ void WMVectorPlot::moduleMain()
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_rootNode );
}
progress->finish();
}
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
......@@ -159,6 +165,9 @@ void WMVectorPlot::moduleMain()
osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
{
boost::shared_ptr< WProgress > progress = boost::shared_ptr< WProgress >( new WProgress( "Vector Plot", 4 ) );
m_progress->addSubProgress( progress );
wmath::WPosition current = WKernel::getRunningKernel()->getSelectionManager()->getCrosshair()->getPosition();
int xPos = current[0];
......@@ -209,7 +218,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
{
vertices->push_back( osg::Vec3( x + 0.5f - xx, y + 0.5f - yy, zPos + 0.5f - zz ) );
vertices->push_back( osg::Vec3( x + 0.5f + xx, y + 0.5f + yy, zPos + 0.5f + zz ) );
if ( m_coloringMode->get() )
if ( m_coloringMode->get( true ) )
{
colors->push_back( osg::Vec4( fabs( xx ), fabs( yy ), fabs( zz ), 1.0 ) );
colors->push_back( osg::Vec4( fabs( xx ), fabs( yy ), fabs( zz ), 1.0 ) );
......@@ -226,7 +235,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
vertices->push_back( osg::Vec3( x + 0.5f + xx, y + 0.5f + yy, zPos + 0.4f ) );
vertices->push_back( osg::Vec3( x + 0.5f - xx, y + 0.5f - yy, zPos + 0.6f ) );
vertices->push_back( osg::Vec3( x + 0.5f + xx, y + 0.5f + yy, zPos + 0.6f ) );
if ( m_coloringMode->get() )
if ( m_coloringMode->get( true ) )
{
colors->push_back( osg::Vec4( fabs( xx ), fabs( yy ), fabs( zz ), 1.0 ) );
colors->push_back( osg::Vec4( fabs( xx ), fabs( yy ), fabs( zz ), 1.0 ) );
......@@ -245,6 +254,8 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
}
}
++*progress;
if ( m_showonY->get() )
{
for ( int x = 0; x < maxX; ++x )
......@@ -259,7 +270,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
{
vertices->push_back( osg::Vec3( x + 0.5f - xx, yPos + 0.5f - yy, z + 0.5f - zz ) );
vertices->push_back( osg::Vec3( x + 0.5f + xx, yPos + 0.5f + yy, z + 0.5f + zz ) );
if ( m_coloringMode->get() )
if ( m_coloringMode->get( true ) )
{
colors->push_back( osg::Vec4( fabs( xx ), fabs( yy ), fabs( zz ), 1.0 ) );
colors->push_back( osg::Vec4( fabs( xx ), fabs( yy ), fabs( zz ), 1.0 ) );
......@@ -276,7 +287,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
vertices->push_back( osg::Vec3( x + 0.5f + xx, yPos + 0.4f, z + 0.5f + zz ) );
vertices->push_back( osg::Vec3( x + 0.5f - xx, yPos + 0.6f, z + 0.5f - zz ) );
vertices->push_back( osg::Vec3( x + 0.5f + xx, yPos + 0.6f, z + 0.5f + zz ) );
if ( m_coloringMode->get() )
if ( m_coloringMode->get( true ) )
{
colors->push_back( osg::Vec4( fabs( xx ), fabs( yy ), fabs( zz ), 1.0 ) );
colors->push_back( osg::Vec4( fabs( xx ), fabs( yy ), fabs( zz ), 1.0 ) );
......@@ -295,6 +306,8 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
}
}
++*progress;
if ( m_showonX->get() )
{
for ( int y = 0; y < maxY; ++y )
......@@ -309,7 +322,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
{
vertices->push_back( osg::Vec3( xPos + 0.5f + xx, y + 0.5f + yy, z + 0.5f + zz ) );
vertices->push_back( osg::Vec3( xPos + 0.5f - xx, y + 0.5f - yy, z + 0.5f - zz ) );
if ( m_coloringMode->get() )
if ( m_coloringMode->get( true ) )
{
colors->push_back( osg::Vec4( fabs( xx ), fabs( yy ), fabs( zz ), 1.0 ) );
colors->push_back( osg::Vec4( fabs( xx ), fabs( yy ), fabs( zz ), 1.0 ) );
......@@ -326,7 +339,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
vertices->push_back( osg::Vec3( xPos + 0.4f, y + 0.5f - yy, z + 0.5f - zz ) );
vertices->push_back( osg::Vec3( xPos + 0.6f, y + 0.5f + yy, z + 0.5f + zz ) );
vertices->push_back( osg::Vec3( xPos + 0.6f, y + 0.5f - yy, z + 0.5f - zz ) );
if ( m_coloringMode->get() )
if ( m_coloringMode->get( true ) )
{
colors->push_back( osg::Vec4( fabs( xx ), fabs( yy ), fabs( zz ), 1.0 ) );
colors->push_back( osg::Vec4( fabs( xx ), fabs( yy ), fabs( zz ), 1.0 ) );
......@@ -345,6 +358,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
}
}
++*progress;
for ( size_t i = 0; i < vertices->size(); ++i )
{
......@@ -360,6 +374,8 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
geometry->setColorArray( colors );
geometry->setColorBinding( osg::Geometry::BIND_PER_VERTEX );
progress->finish();
return geometry;
}
......@@ -369,7 +385,7 @@ void WMVectorPlot::SafeUpdateCallback::operator()( osg::Node* node, osg::NodeVis
wmath::WPosition current = WKernel::getRunningKernel()->getSelectionManager()->getCrosshair()->getPosition();
wmath::WPosition old( m_module->m_xPos->get(), m_module->m_yPos->get(), m_module->m_zPos->get() );
if ( ( old != current ) || m_module->m_coloringMode->changed() || m_module->m_aColor->changed() || m_initialUpdate )
if ( ( old != current ) || m_module->m_coloringMode->changed() || m_module->m_aColor->changed() )
{
osg::ref_ptr<osg::Drawable> old = osg::ref_ptr<osg::Drawable>( m_module->m_rootNode->getDrawable( 0 ) );
m_module->m_rootNode->removeDrawable( old );
......
......@@ -165,7 +165,7 @@ private:
*
* \param module just set the creating module as pointer for later reference.
*/
explicit SafeUpdateCallback( WMVectorPlot* module ): m_module( module ), m_initialUpdate( true )
explicit SafeUpdateCallback( WMVectorPlot* module ): m_module( module )
{
};
......@@ -181,11 +181,6 @@ private:
* Pointer used to access members of the module to modify the node.
*/
WMVectorPlot* m_module;
/**
* Denotes whether the update callback is called the first time.
*/
bool m_initialUpdate;
};
};
......
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