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

[ADD #288] Allow scaling of vectors in vector plot module by property

parent 478e15a7
......@@ -112,6 +112,10 @@ void WMVectorPlot::properties()
m_showOnCoronal = m_properties->addProperty( "Show coronal", "Show vectors on coronal slice.", true );
m_showOnAxial = m_properties->addProperty( "Show axial", "Show vectors on axial slice.", true );
m_scale = m_properties->addProperty( "Scaling",
"Scaling the length of the plotted vectors",
1.0 );
WModule::properties();
}
......@@ -207,7 +211,7 @@ void WMVectorPlot::updateCallback()
WPosition current = WKernel::getRunningKernel()->getSelectionManager()->getCrosshair()->getPosition();
if( ( m_oldPos != current ) || m_coloringMode->changed() || m_aColor->changed() || m_projectOnSlice->changed() ||
m_showOnSagittal->changed() || m_showOnCoronal->changed() || m_showOnAxial->changed() )
m_showOnSagittal->changed() || m_showOnCoronal->changed() || m_showOnAxial->changed() || m_scale->changed() )
{
m_oldPos = current; // for next run
osg::ref_ptr<osg::Drawable> old = osg::ref_ptr<osg::Drawable>( m_rootNode->getDrawable( 0 ) );
......
......@@ -136,7 +136,6 @@ private:
*/
void transformVerts( osg::ref_ptr< osg::Vec3Array > verts );
/**
* An input connector used to get datasets from other modules. The connection management between connectors must not be handled by the module.
*/
......@@ -171,6 +170,8 @@ private:
WPropColor m_aColor; //!< color
WPropDouble m_scale; //!< Scaling of arrow length.
osg::ref_ptr< WGEShader > m_shader; //!< the shader object for this module
WPosition m_oldPos; //!< The previous position of the slides.
......@@ -217,6 +218,8 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
WColor color = m_aColor->get( true );
float scaling = m_scale->get( true );
if( ( ( *m_dataSet ).getValueSet()->order() == 1 ) && ( ( *m_dataSet ).getValueSet()->dimension() == 3 ) )
{
if( m_showOnAxial->get( true ) )
......@@ -225,9 +228,9 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
{
for( int y = 0; y < nbY; ++y )
{
float vecCompX = vals->getScalar( ( x + y * nbX + static_cast< int >( zSlice ) * nbX * nbY ) * 3 ) / 2.;
float vecCompY = vals->getScalar( ( x + y * nbX + static_cast< int >( zSlice ) * nbX * nbY ) * 3 + 1 ) / 2.;
float vecCompZ = vals->getScalar( ( x + y * nbX + static_cast< int >( zSlice ) * nbX * nbY ) * 3 + 2 ) / 2.;
float vecCompX = vals->getScalar( ( x + y * nbX + static_cast< int >( zSlice ) * nbX * nbY ) * 3 ) / 2. * scaling;
float vecCompY = vals->getScalar( ( x + y * nbX + static_cast< int >( zSlice ) * nbX * nbY ) * 3 + 1 ) / 2. * scaling;
float vecCompZ = vals->getScalar( ( x + y * nbX + static_cast< int >( zSlice ) * nbX * nbY ) * 3 + 2 ) / 2. * scaling;
if( !m_projectOnSlice->get( true ) )
{
......@@ -277,9 +280,9 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
{
for( int z = 0; z < nbZ; ++z )
{
float vecCompX = vals->getScalar( ( x + static_cast< int >( ySlice ) * nbX + z * nbX * nbY ) * 3 ) / 2.;
float vecCompY = vals->getScalar( ( x + static_cast< int >( ySlice ) * nbX + z * nbX * nbY ) * 3 + 1 ) / 2.;
float vecCompZ = vals->getScalar( ( x + static_cast< int >( ySlice ) * nbX + z * nbX * nbY ) * 3 + 2 ) / 2.;
float vecCompX = vals->getScalar( ( x + static_cast< int >( ySlice ) * nbX + z * nbX * nbY ) * 3 ) / 2. * scaling;
float vecCompY = vals->getScalar( ( x + static_cast< int >( ySlice ) * nbX + z * nbX * nbY ) * 3 + 1 ) / 2. * scaling;
float vecCompZ = vals->getScalar( ( x + static_cast< int >( ySlice ) * nbX + z * nbX * nbY ) * 3 + 2 ) / 2. * scaling;
if( !m_projectOnSlice->get( true ) )
{
......@@ -329,9 +332,9 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
{
for( int z = 0; z < nbZ; ++z )
{
float vecCompX = vals->getScalar( ( static_cast< int >( xSlice ) + y * nbX + z * nbX * nbY ) * 3 ) / 2.;
float vecCompY = vals->getScalar( ( static_cast< int >( xSlice ) + y * nbX + z * nbX * nbY ) * 3 + 1 ) / 2.;
float vecCompZ = vals->getScalar( ( static_cast< int >( xSlice ) + y * nbX + z * nbX * nbY ) * 3 + 2 ) / 2.;
float vecCompX = vals->getScalar( ( static_cast< int >( xSlice ) + y * nbX + z * nbX * nbY ) * 3 ) / 2. * scaling;
float vecCompY = vals->getScalar( ( static_cast< int >( xSlice ) + y * nbX + z * nbX * nbY ) * 3 + 1 ) / 2. * scaling;
float vecCompZ = vals->getScalar( ( static_cast< int >( xSlice ) + y * nbX + z * nbX * nbY ) * 3 + 2 ) / 2. * scaling;
if( !m_projectOnSlice->get( true ) )
{
......
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