Commit 04b4a5d5 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] pick coloring for nav views disabled

parent e8db3f86
......@@ -23,6 +23,7 @@
//---------------------------------------------------------------------------
#include <osg/Vec3>
#include <osg/LineWidth>
#include <osg/MatrixTransform>
#include "core/common/WPropertyHelper.h"
......@@ -111,6 +112,9 @@ void WMNavigationSlices::initOSG()
{
// remove the old slices
m_output->clear();
m_axialOutput->clear();
m_sagittalOutput->clear();
m_coronalOutput->clear();
///////////////////////////////////////////////////////////////////////////////////////////////
// Property Setup
......@@ -242,6 +246,10 @@ void WMNavigationSlices::initOSG()
m_ySlicePicker = PickCallback::SPtr( new PickCallback( ySlice, m_yPos, true ) );
m_zSlicePicker = PickCallback::SPtr( new PickCallback( zSlice, m_zPos ) );
// transparency property
osg::ref_ptr< osg::Uniform > transparencyUniform = new osg::Uniform( "u_noTransparency", false );
transparencyUniform->setUpdateCallback( new WGEPropertyUniformCallback< WPropBool >( m_noTransparency ) );
///////////////////////////////////////////////////////////////////////////////////////////////
// Done
///////////////////////////////////////////////////////////////////////////////////////////////
......@@ -255,9 +263,10 @@ void WMNavigationSlices::initOSG()
animationUniform->setUpdateCallback( new WGEShaderAnimationCallback() );
// transparency property
osg::ref_ptr< osg::Uniform > transparencyUniform = new osg::Uniform( "u_noTransparency", false );
state->addUniform( transparencyUniform );
transparencyUniform->setUpdateCallback( new WGEPropertyUniformCallback< WPropBool >( m_noTransparency ) );
m_axialOutput->getOrCreateStateSet()->addUniform( transparencyUniform );
m_sagittalOutput->getOrCreateStateSet()->addUniform( transparencyUniform );
m_coronalOutput->getOrCreateStateSet()->addUniform( transparencyUniform );
// add the transformation nodes to the output group
m_output->insert( mX );
......@@ -323,6 +332,10 @@ void WMNavigationSlices::moduleMain()
// done.
ready();
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Slices Setup
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// create the root node for all the geometry
m_output = osg::ref_ptr< WGEManagedGroupNode > ( new WGEManagedGroupNode( m_active ) );
......@@ -336,6 +349,12 @@ void WMNavigationSlices::moduleMain()
WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "Coronal View" )->getScene()->insert( m_coronalOutput );
WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "Sagittal View" )->getScene()->insert( m_sagittalOutput );
// disable the pick-coloring for the side views
m_axialOutput->getOrCreateStateSet()->addUniform( new osg::Uniform( "u_pickColorEnabled", 0.0f ) );
m_sagittalOutput->getOrCreateStateSet()->addUniform( new osg::Uniform( "u_pickColorEnabled", 0.0f ) );
m_coronalOutput->getOrCreateStateSet()->addUniform( new osg::Uniform( "u_pickColorEnabled", 0.0f ) );
m_output->getOrCreateStateSet()->addUniform( new osg::Uniform( "u_pickColorEnabled", 1.0f ) );
m_output->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON );
m_axialOutput->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON );
m_sagittalOutput->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON );
......@@ -350,13 +369,13 @@ void WMNavigationSlices::moduleMain()
nodes.push_back( m_coronalOutput );
WGEColormapping::apply( nodes, shader ); // this automatically applies the shader
// we need to be informed if the bounding box of the volume containing all the data changes.
m_moduleState.add( WGEColormapping::instance()->getChangeCondition() );
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main loop
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// we need to be informed if the bounding box of the volume containing all the data changes.
m_moduleState.add( WGEColormapping::instance()->getChangeCondition() );
// main loop
while( !m_shutdownFlag() )
{
......@@ -380,8 +399,9 @@ void WMNavigationSlices::moduleMain()
m_zSlicePicker.reset();
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_output );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_axialOutput );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_coronalOutput );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_sagittalOutput );
WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "Axial View" )->getScene()->remove( m_axialOutput );
WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "Coronal View" )->getScene()->remove( m_coronalOutput );
WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "Sagittal View" )->getScene()->remove( m_sagittalOutput );
}
......@@ -32,6 +32,9 @@ const vec4 pickColor = vec4( 0.25, 0.0, 0.75, 1.0 );
// if this is 1, the slice is currently in pick mode
uniform float u_picked;
// if allows disabling pick coloring if 0
uniform float u_pickColorEnabled;
// animation time. Used for pick-animation
uniform int u_timer;
......@@ -52,13 +55,16 @@ void main()
// as we use this for blending, we want it to swing in [0.5-0.75]
pickColorIntensity = ( pickColorIntensity * 0.25 ) + 0.5;
// pick-coloring?
float picked = u_pickColorEnabled * u_picked;
// remove transparency?
float removeTransparency = clamp( u_picked + float( u_noTransparency ), 0.0, 1.0 );
float removeTransparency = clamp( picked + float( u_noTransparency ), 0.0, 1.0 );
cmap.a = ( ( 1.0 - removeTransparency ) * cmap.a ) + removeTransparency;
// mix colormapping and pick color
vec4 finalColor = mix( pickColor, cmap,
( 1.0 - u_picked ) + ( u_picked * pickColorIntensity ) // mix intensity. This is influenced by the pick-state.
( 1.0 - picked ) + ( picked * pickColorIntensity ) // mix intensity. This is influenced by the pick-state.
);
// set as fragColor and remove transparency if needed.
......
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