Commit 02bf541e authored by Mathias Goldau's avatar Mathias Goldau

[FIX #373] Now we subscribed to the Kernel's slice positions.

parent 9f3712a6
......@@ -24,17 +24,23 @@
#include <string>
#include <boost/bind.hpp>
#include "core/common/WCondition.h"
#include "core/common/WPropTransfer.h"
#include "core/common/WItemSelectionItemTyped.h"
#include "core/graphicsEngine/WGEManagedGroupNode.h"
#include "core/kernel/WModuleInputData.h"
#include "core/kernel/WKernel.h"
#include "core/kernel/WSelectionManager.h"
#include "WMAbstractSliceModule.h"
WMAbstractSliceModule::WMAbstractSliceModule()
: WModule(),
m_propCondition( new WCondition() )
{
// subscribe to slice positions of the kernel. Whenever they change, the currently selected axis is choosen to update m_pos
WKernel::getRunningKernel()->getSelectionManager()->getPropAxialPos()->getUpdateCondition()->subscribeSignal( boost::bind( &WMAbstractSliceModule::updatePos, this ) );
WKernel::getRunningKernel()->getSelectionManager()->getPropSagittalPos()->getUpdateCondition()->subscribeSignal( boost::bind( &WMAbstractSliceModule::updatePos, this ) );
WKernel::getRunningKernel()->getSelectionManager()->getPropCoronalPos()->getUpdateCondition()->subscribeSignal( boost::bind( &WMAbstractSliceModule::updatePos, this ) );
}
WMAbstractSliceModule::~WMAbstractSliceModule()
......@@ -43,11 +49,26 @@ WMAbstractSliceModule::~WMAbstractSliceModule()
void WMAbstractSliceModule::connectors()
{
m_posIC = WModuleInputData< WPositionTransfer >::createAndAdd( shared_from_this(), "positions", "Slice positions in x,y,z" );
WModule::connectors();
}
void WMAbstractSliceModule::updatePos()
{
WPropDouble pos;
switch( m_sliceSelection->get( true ).at( 0 )->getAs< AxisType >()->getValue() )
{
case 0 : pos = WKernel::getRunningKernel()->getSelectionManager()->getPropSagittalPos(); break;
case 1 : pos = WKernel::getRunningKernel()->getSelectionManager()->getPropCoronalPos(); break;
case 2 : pos = WKernel::getRunningKernel()->getSelectionManager()->getPropAxialPos(); break;
default : warnLog() << "This indicates a bug: no valid axis selected";
return;
}
double offset = 0.001; // This offset is used to put the graphics slightly over the slice position not onto the same, as then
// graphics would start to flicker
m_pos->set( pos->get() + offset );
}
void WMAbstractSliceModule::properties()
{
m_pos = m_properties->addProperty( "Slice Position", "Where the data shoulde be sliced for drawing contours", 0.0 );
......
......@@ -27,13 +27,11 @@
#include <string>
#include "core/common/WPropTransfer.h"
#include "core/kernel/WModule.h"
// forward declarations to reduce compile dependencies
class WGEManagedGroupNode;
template< class T > class WItemSelectionItemTyped;
template< class T > class WModuleInputData;
/**
* Module containing convinience stuff for slice based modules.
......@@ -85,6 +83,12 @@ protected:
*/
virtual void moduleMain() = 0;
/**
* If the slice positions in the kernel change, our m_pos is updated. This make all slice modules easy to use with navigation slices.
* \note If there is no navigation slice module, there should be no trouble.
*/
virtual void updatePos();
/**
* Initialize the connectors this module is using.
*/
......@@ -115,11 +119,6 @@ protected:
*/
std::pair< WVector3d, WVector3d > sliceBaseVectors( const WVector3d& sizes, const size_t axis ) const;
/**
* Connector for external WPropDouble, so the slice type and position of this module can be controlled from another module.
*/
boost::shared_ptr< WModuleInputData< WPositionTransfer > > m_posIC;
/**
* The OSG root node for this module. All other geodes or OSG nodes will be attached on this single node.
*/
......
......@@ -54,6 +54,7 @@
#include "core/graphicsEngine/WGraphicsEngine.h"
#include "core/kernel/WKernel.h"
#include "core/kernel/WModuleInputData.h"
#include "WMFiberStipples.h"
#include "WMFiberStipples.xpm"
......@@ -275,7 +276,7 @@ void WMFiberStipples::initOSG( boost::shared_ptr< WDataSetScalar > probTract, co
m_pos->setMax( maxV[axis] );
// if this is done the first time, set the slices to the center of the dataset
if( m_first && !m_posIC->getData() )
if( m_first )
{
m_first = false;
m_pos->set( midBB[axis] );
......@@ -377,6 +378,7 @@ void WMFiberStipples::initOSG( boost::shared_ptr< WDataSetScalar > probTract, co
m_output->dirtyBound();
}
void WMFiberStipples::moduleMain()
{
// get notified about data changes
......@@ -384,7 +386,6 @@ void WMFiberStipples::moduleMain()
m_moduleState.add( m_probIC->getDataChangedCondition() );
m_moduleState.add( m_colIC->getDataChangedCondition() );
m_moduleState.add( m_vectorIC->getDataChangedCondition() );
m_moduleState.add( m_posIC->getDataChangedCondition() );
m_moduleState.add( m_propCondition );
ready();
......@@ -418,17 +419,6 @@ void WMFiberStipples::moduleMain()
// determine which axis to draw stipples
size_t axis = m_sliceSelection->get( true ).at( 0 )->getAs< AxisType >()->getValue();
if( m_posIC->getData() )
{
WPosition pos = m_posIC->getData()->getProperty();
double offset = 0.0001; // when the geodes share the exact positions their graphic output will interfere
if( m_pos->get() != pos[axis] + offset )
{
m_pos->set( pos[axis] + offset );
continue;
}
}
if( m_sampleRes->changed() )
{
debugLog() << "New poission sampling resolution";
......
......@@ -184,7 +184,7 @@ void WMIsoLines::initOSG( boost::shared_ptr< WDataSetScalar > scalars, const dou
m_pos->setMin( minV[axis] );
m_pos->setMax( maxV[axis] );
if( m_first && !m_posIC->getData() )
if( m_first )
{
m_first = false;
m_pos->set( midBB[axis] );
......@@ -223,7 +223,6 @@ void WMIsoLines::moduleMain()
// get notified about data changes
m_moduleState.setResetable( true, true );
m_moduleState.add( m_scalarIC->getDataChangedCondition() );
m_moduleState.add( m_posIC->getDataChangedCondition() );
m_moduleState.add( m_propCondition );
ready();
......@@ -249,17 +248,6 @@ void WMIsoLines::moduleMain()
break;
}
if( m_posIC->getData() )
{
WPosition pos = m_posIC->getData()->getProperty();
double offset = 0.0001; // when the geodes share the exact positions their graphic output will interfere
if( m_pos->get() != pos[axis] + offset )
{
m_pos->set( pos[axis] + offset );
continue;
}
}
// save data behind connectors since it might change during processing
boost::shared_ptr< WDataSetScalar > scalarData = m_scalarIC->getData();
......
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