Commit 956e87f5 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[MERGE]

parents de42caf9 f14d9b6b
...@@ -31,7 +31,7 @@ PROJECT_NAME = OpenWalnut ...@@ -31,7 +31,7 @@ PROJECT_NAME = OpenWalnut
# This could be handy for archiving the generated documentation or # This could be handy for archiving the generated documentation or
# if some version control system is used. # if some version control system is used.
PROJECT_NUMBER = 0.1 PROJECT_NUMBER = 1.0+
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put. # base path where the generated documentation will be put.
......
...@@ -31,7 +31,7 @@ PROJECT_NAME = OpenWalnut ...@@ -31,7 +31,7 @@ PROJECT_NAME = OpenWalnut
# This could be handy for archiving the generated documentation or # This could be handy for archiving the generated documentation or
# if some version control system is used. # if some version control system is used.
PROJECT_NUMBER = 0.1 PROJECT_NUMBER = 1.0+
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put. # base path where the generated documentation will be put.
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
* \par * \par
* http://www.openwalnut.org * http://www.openwalnut.org
* \par * \par
* Copyright 2009 OpenWalnut Community, BSV\@Uni-Leipzig and CNCF\@MPI-CBS. * Copyright 2009-2010 OpenWalnut Community, BSV\@Uni-Leipzig and CNCF\@MPI-CBS.
* For more information see http://www.openwalnut.org/copying * For more information see http://www.openwalnut.org/copying
*/ */
...@@ -47,7 +47,7 @@ int main( int argc, char** argv ) ...@@ -47,7 +47,7 @@ int main( int argc, char** argv )
{ {
std::cout << "OpenWalnut ( http://www.openwalnut.org )" << std::endl << std::cout << "OpenWalnut ( http://www.openwalnut.org )" << std::endl <<
"Build from: " << W_VERSION << std::endl << std::endl << "Build from: " << W_VERSION << std::endl << std::endl <<
"Copyright (C) 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS\n" "Copyright (C) 2009-2010 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS\n"
"For more information see http://www.openwalnut.org/copying\n" "For more information see http://www.openwalnut.org/copying\n"
"This program comes with ABSOLUTELY NO WARRANTY.\n" "This program comes with ABSOLUTELY NO WARRANTY.\n"
"This is free software, and you are welcome to redistribute it\n" "This is free software, and you are welcome to redistribute it\n"
......
...@@ -74,6 +74,7 @@ class WThreadedFunctionTest : public CxxTest::TestSuite ...@@ -74,6 +74,7 @@ class WThreadedFunctionTest : public CxxTest::TestSuite
{ {
m_stopped.getWriteTicket()->get() = true; m_stopped.getWriteTicket()->get() = true;
} }
sleep( 1 );
} }
/** /**
......
...@@ -74,6 +74,7 @@ class WWorkerThreadTest : public CxxTest::TestSuite ...@@ -74,6 +74,7 @@ class WWorkerThreadTest : public CxxTest::TestSuite
{ {
m_stopped.getWriteTicket()->get() = true; m_stopped.getWriteTicket()->get() = true;
} }
sleep( 1 );
} }
/** /**
......
...@@ -93,6 +93,8 @@ void WMFiberDisplay::moduleMain() ...@@ -93,6 +93,8 @@ void WMFiberDisplay::moduleMain()
m_moduleState.wait(); // waits for firing of m_moduleState ( dataChanged, shutdown, etc. ) m_moduleState.wait(); // waits for firing of m_moduleState ( dataChanged, shutdown, etc. )
initCullBox();
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
// what caused wait to return? // what caused wait to return?
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
...@@ -151,6 +153,32 @@ void WMFiberDisplay::update() ...@@ -151,6 +153,32 @@ void WMFiberDisplay::update()
m_osgNode->setNodeMask( 0xFFFFFFFF ); m_osgNode->setNodeMask( 0xFFFFFFFF );
} }
} }
if( !m_showCullBox->get() )
{
m_cullBox->setNodeMask( 0x0 );
}
else
{
m_cullBox->setNodeMask( 0xFFFFFFFF );
}
float xMin = m_cullBox->getMinPos()[0];
float yMin = m_cullBox->getMinPos()[1];
float zMin = m_cullBox->getMinPos()[2];
float xMax = m_cullBox->getMaxPos()[0];
float yMax = m_cullBox->getMaxPos()[1];
float zMax = m_cullBox->getMaxPos()[2];
m_uniformUseCullBox->set( m_activateCullBox->get() );
m_uniformInsideCullBox->set( m_insideCullBox->get() );
m_uniformCullBoxLBX->set( static_cast<float>( xMin ) );
m_uniformCullBoxLBY->set( static_cast<float>( yMin ) );
m_uniformCullBoxLBZ->set( static_cast<float>( zMin ) );
m_uniformCullBoxUBX->set( static_cast<float>( xMax ) );
m_uniformCullBoxUBY->set( static_cast<float>( yMax ) );
m_uniformCullBoxUBZ->set( static_cast<float>( zMax ) );
} }
void WMFiberDisplay::create() void WMFiberDisplay::create()
...@@ -237,9 +265,14 @@ void WMFiberDisplay::properties() ...@@ -237,9 +265,14 @@ void WMFiberDisplay::properties()
"Updates the output connector with the currently selected fibers", "Updates the output connector with the currently selected fibers",
WPVBaseTypes::PV_TRIGGER_READY, WPVBaseTypes::PV_TRIGGER_READY,
boost::bind( &WMFiberDisplay::updateOutput, this ) ); boost::bind( &WMFiberDisplay::updateOutput, this ) );
m_cullBoxGroup = m_properties->addPropertyGroup( "Box Culling", "Properties only related to the box culling." );
m_activateCullBox = m_cullBoxGroup->addProperty( "Activate", "activates the cull box", false );
m_showCullBox = m_cullBoxGroup->addProperty( "Show Cull Box", "shows/hides the cull box", false );
m_insideCullBox = m_cullBoxGroup->addProperty( "Inside - Outside", "show fibers inside or outside the cull box", true );
} }
void WMFiberDisplay::toggleTubes() void WMFiberDisplay::updateRenderModes()
{ {
osg::StateSet* rootState = m_osgNode->getOrCreateStateSet(); osg::StateSet* rootState = m_osgNode->getOrCreateStateSet();
...@@ -249,7 +282,7 @@ void WMFiberDisplay::toggleTubes() ...@@ -249,7 +282,7 @@ void WMFiberDisplay::toggleTubes()
updateTexture(); updateTexture();
} }
if( m_useTubesProp->changed() || m_useTextureProp->changed() ) if( m_useTubesProp->changed() || m_useTextureProp->changed() || m_activateCullBox->changed() )
{ {
if ( m_useTubesProp->get( true ) ) if ( m_useTubesProp->get( true ) )
{ {
...@@ -262,12 +295,13 @@ void WMFiberDisplay::toggleTubes() ...@@ -262,12 +295,13 @@ void WMFiberDisplay::toggleTubes()
rootState->addUniform( m_uniformTubeThickness ); rootState->addUniform( m_uniformTubeThickness );
rootState->addUniform( osg::ref_ptr<osg::Uniform>( new osg::Uniform( "useTexture", m_useTextureProp->get() ) ) ); rootState->addUniform( osg::ref_ptr<osg::Uniform>( new osg::Uniform( "useTexture", m_useTextureProp->get() ) ) );
} }
else if ( m_useTextureProp->get( true ) && !m_useTubesProp->get( true ) ) else if ( ( m_useTextureProp->get( true ) && !m_useTubesProp->get( true ) ) || m_activateCullBox->get( true) )
{ {
m_tubeDrawable->setUseTubes( false ); m_tubeDrawable->setUseTubes( false );
updateTexture(); updateTexture();
m_shaderTubes->deactivate( m_osgNode ); m_shaderTubes->deactivate( m_osgNode );
m_shaderTexturedFibers->apply( m_osgNode ); m_shaderTexturedFibers->apply( m_osgNode );
m_uniformUseTexture->set( m_useTextureProp->get() );
} }
else else
{ {
...@@ -376,6 +410,7 @@ void WMFiberDisplay::updateTexture() ...@@ -376,6 +410,7 @@ void WMFiberDisplay::updateTexture()
void WMFiberDisplay::initUniforms( osg::StateSet* rootState ) void WMFiberDisplay::initUniforms( osg::StateSet* rootState )
{ {
m_uniformUseTexture = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "useTexture", false ) );
m_uniformSampler = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "tex", 0 ) ); m_uniformSampler = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "tex", 0 ) );
m_uniformType = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "type", 0 ) ); m_uniformType = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "type", 0 ) );
m_uniformThreshold = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "threshold", 0.0f ) ); m_uniformThreshold = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "threshold", 0.0f ) );
...@@ -385,6 +420,7 @@ void WMFiberDisplay::initUniforms( osg::StateSet* rootState ) ...@@ -385,6 +420,7 @@ void WMFiberDisplay::initUniforms( osg::StateSet* rootState )
m_uniformDimY = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "dimY", 1 ) ); m_uniformDimY = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "dimY", 1 ) );
m_uniformDimZ = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "dimZ", 1 ) ); m_uniformDimZ = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "dimZ", 1 ) );
rootState->addUniform( m_uniformUseTexture );
rootState->addUniform( m_uniformSampler ); rootState->addUniform( m_uniformSampler );
rootState->addUniform( m_uniformType ); rootState->addUniform( m_uniformType );
rootState->addUniform( m_uniformThreshold ); rootState->addUniform( m_uniformThreshold );
...@@ -393,9 +429,48 @@ void WMFiberDisplay::initUniforms( osg::StateSet* rootState ) ...@@ -393,9 +429,48 @@ void WMFiberDisplay::initUniforms( osg::StateSet* rootState )
rootState->addUniform( m_uniformDimX ); rootState->addUniform( m_uniformDimX );
rootState->addUniform( m_uniformDimY ); rootState->addUniform( m_uniformDimY );
rootState->addUniform( m_uniformDimZ ); rootState->addUniform( m_uniformDimZ );
// cull box info
float xMin = m_cullBox->getMinPos()[0];
float yMin = m_cullBox->getMinPos()[1];
float zMin = m_cullBox->getMinPos()[2];
float xMax = m_cullBox->getMaxPos()[0];
float yMax = m_cullBox->getMaxPos()[1];
float zMax = m_cullBox->getMaxPos()[2];
m_uniformUseCullBox = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "useCullBox", false ) );
m_uniformInsideCullBox = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "insideCullBox", false ) );
m_uniformCullBoxLBX = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "cullBoxLBX", static_cast<float>( xMin ) ) );
m_uniformCullBoxLBY = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "cullBoxLBY", static_cast<float>( yMin ) ) );
m_uniformCullBoxLBZ = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "cullBoxLBZ", static_cast<float>( zMin ) ) );
m_uniformCullBoxUBX = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "cullBoxUBX", static_cast<float>( xMax ) ) );
m_uniformCullBoxUBY = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "cullBoxUBY", static_cast<float>( yMax ) ) );
m_uniformCullBoxUBZ = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "cullBoxUBZ", static_cast<float>( zMax ) ) );
rootState->addUniform( m_uniformUseCullBox );
rootState->addUniform( m_uniformCullBoxLBX );
rootState->addUniform( m_uniformCullBoxLBY );
rootState->addUniform( m_uniformCullBoxLBZ );
rootState->addUniform( m_uniformCullBoxUBX );
rootState->addUniform( m_uniformCullBoxUBY );
rootState->addUniform( m_uniformCullBoxUBZ );
rootState->addUniform( m_uniformUseCullBox );
rootState->addUniform( m_uniformInsideCullBox );
} }
void WMFiberDisplay::notifyTextureChange() void WMFiberDisplay::notifyTextureChange()
{ {
m_textureChanged = true; m_textureChanged = true;
} }
void WMFiberDisplay::initCullBox()
{
wmath::WPosition crossHairPos = WKernel::getRunningKernel()->getSelectionManager()->getCrosshair()->getPosition();
wmath::WPosition minROIPos = crossHairPos - wmath::WPosition( 10., 10., 10. );
wmath::WPosition maxROIPos = crossHairPos + wmath::WPosition( 10., 10., 10. );
m_cullBox = osg::ref_ptr< WROIBox >( new WROIBox( minROIPos, maxROIPos ) );
m_cullBox->setColor( osg::Vec4( 1.0, 0., 1.0, 0.4 ) );
}
...@@ -31,13 +31,15 @@ ...@@ -31,13 +31,15 @@
#include "../../../dataHandler/datastructures/WFiberCluster.h" #include "../../../dataHandler/datastructures/WFiberCluster.h"
#include "../../../dataHandler/WDataSetFibers.h" #include "../../../dataHandler/WDataSetFibers.h"
#include "../../../graphicsEngine/WROI.h"
#include "../../../graphicsEngine/WROIBox.h"
#include "../../../graphicsEngine/WShader.h" #include "../../../graphicsEngine/WShader.h"
#include "../../WModule.h" #include "../../WModule.h"
#include "../../WModuleInputData.h" #include "../../WModuleInputData.h"
#include "WTubeDrawable.h" #include "WTubeDrawable.h"
/** /**
* Test module for drawing fibers * Module for drawing fibers
* *
* \ingroup modules * \ingroup modules
*/ */
...@@ -142,6 +144,11 @@ private: ...@@ -142,6 +144,11 @@ private:
WBoolFlag m_noData; //!< Flag indicating whether there is data to display. WBoolFlag m_noData; //!< Flag indicating whether there is data to display.
WPropGroup m_cullBoxGroup; //!< property group for box culling
WPropBool m_activateCullBox; //!< if true fibers are culled depending on a cull box
WPropBool m_showCullBox; //!< Enable/Disable showing of the cull box
WPropBool m_insideCullBox; //!< if true fibers inside the cull box are shown, outside if false
/** /**
* Input connector for a fiber dataset. * Input connector for a fiber dataset.
*/ */
...@@ -190,6 +197,11 @@ private: ...@@ -190,6 +197,11 @@ private:
*/ */
bool m_textureChanged; bool m_textureChanged;
/**
* boolean to notify the shader to use the texture instead of glColor
*/
osg::ref_ptr<osg::Uniform> m_uniformUseTexture;
/** /**
* uniform for type of texture * uniform for type of texture
*/ */
...@@ -214,15 +226,30 @@ private: ...@@ -214,15 +226,30 @@ private:
osg::ref_ptr<osg::Uniform> m_uniformDimY; //!< y dimension of the dataset for calculating the texture coord in the shader osg::ref_ptr<osg::Uniform> m_uniformDimY; //!< y dimension of the dataset for calculating the texture coord in the shader
osg::ref_ptr<osg::Uniform> m_uniformDimZ; //!< z dimension of the dataset for calculating the texture coord in the shader osg::ref_ptr<osg::Uniform> m_uniformDimZ; //!< z dimension of the dataset for calculating the texture coord in the shader
osg::ref_ptr<osg::Uniform> m_uniformUseCullBox; //!< notify shader that cull box is activated
osg::ref_ptr<osg::Uniform> m_uniformInsideCullBox; //!< notify shader that fibers insider or outside cull box are shown
osg::ref_ptr<osg::Uniform> m_uniformCullBoxLBX; //!< cull box lower bound
osg::ref_ptr<osg::Uniform> m_uniformCullBoxLBY; //!< cull box lower bound
osg::ref_ptr<osg::Uniform> m_uniformCullBoxLBZ; //!< cull box lower bound
osg::ref_ptr<osg::Uniform> m_uniformCullBoxUBX; //!< cull box upper bound
osg::ref_ptr<osg::Uniform> m_uniformCullBoxUBY; //!< cull box upper bound
osg::ref_ptr<osg::Uniform> m_uniformCullBoxUBZ; //!< cull box upper bound
/** /**
* To avoid multiple instances of the fiber display. * To avoid multiple instances of the fiber display.
*/ */
static bool m_fiberDisplayRunning; static bool m_fiberDisplayRunning;
osg::ref_ptr< WROIBox > m_cullBox; //!< stores a pointer to the cull box
/** /**
* switches between fiber display and tube representation * switches between fiber display and tube representation,
* texturing and box culling
* activates the neccesary shaders
*/ */
void toggleTubes(); void updateRenderModes();
/** /**
* Enable disable global or local coloring * Enable disable global or local coloring
...@@ -250,6 +277,12 @@ private: ...@@ -250,6 +277,12 @@ private:
*/ */
void updateTexture(); void updateTexture();
/**
* create a selection box to cull the fibers
*/
void initCullBox();
/** /**
* Node callback to handle updates properly * Node callback to handle updates properly
*/ */
...@@ -269,7 +302,7 @@ private: ...@@ -269,7 +302,7 @@ private:
if ( module ) if ( module )
{ {
module->update(); module->update();
module->toggleTubes(); module->updateRenderModes();
module->toggleColoring(); module->toggleColoring();
} }
traverse( node, nv ); traverse( node, nv );
......
varying vec4 myColor; varying vec4 myColor;
varying vec4 VaryingTexCoord0; varying vec4 VaryingTexCoord0;
uniform int dimX, dimY, dimZ; uniform int dimX, dimY, dimZ;
uniform sampler3D tex; uniform sampler3D tex;
...@@ -9,6 +8,16 @@ uniform int type; ...@@ -9,6 +8,16 @@ uniform int type;
uniform float threshold; uniform float threshold;
uniform int cMap; uniform int cMap;
uniform bool useTexture;
uniform bool useCullBox;
uniform bool insideCullBox;
uniform float cullBoxLBX;
uniform float cullBoxLBY;
uniform float cullBoxLBZ;
uniform float cullBoxUBX;
uniform float cullBoxUBY;
uniform float cullBoxUBZ;
#include "WGEColorMaps.glsl" #include "WGEColorMaps.glsl"
#include "WGEUtils.glsl" #include "WGEUtils.glsl"
...@@ -31,19 +40,43 @@ float lookupTex() ...@@ -31,19 +40,43 @@ float lookupTex()
return col1.r; return col1.r;
} }
void checkCullBox()
{
vec3 pos = VaryingTexCoord0.xyz;
if ( insideCullBox )
{
if ( pos.x < cullBoxLBX || pos.x > cullBoxUBX )
discard;
if ( pos.y < cullBoxLBY || pos.y > cullBoxUBY )
discard;
if ( pos.z < cullBoxLBZ || pos.z > cullBoxUBZ )
discard;
}
else
{
if ( ( pos.x > cullBoxLBX && pos.x < cullBoxUBX ) && ( pos.y > cullBoxLBY && pos.y < cullBoxUBY ) && ( pos.z > cullBoxLBZ && pos.z < cullBoxUBZ ) )
discard;
}
}
/* /*
* simple fragment shader that uses a texture on fibers * simple fragment shader that uses a texture on fibers
*/ */
void main() void main()
{ {
vec4 color = vec4( 1.0 ); if ( useCullBox )
checkCullBox();
float value = lookupTex();
colorMap(color.rgb, value, cMap ); vec4 color = myColor;
color.a = 1.0; if ( useTexture )
{
float value = lookupTex();
colorMap(color.rgb, value, cMap );
color.a = 1.0;
}
gl_FragColor = color; gl_FragColor = color;
} }
...@@ -196,7 +196,14 @@ EOF ...@@ -196,7 +196,14 @@ EOF
die "Need exactly one command line argument (module name)\n" unless $#ARGV == 0; die "Need exactly one command line argument (module name)\n" unless $#ARGV == 0;
$modulename = $ARGV[0]; $dirname = lcfirst($ARGV[0]); # directory has to have lower case first letter
use Cwd;
$parentdir = getcwd."/";
$modulename = ucfirst($ARGV[0]); # name has to have upper case first letter
print "Generating for ".$modulename." in ".$parentdir.$dirname.".\n";
mkdir $dirname;
$header =~ s/\#name\#/$modulename/gm; $header =~ s/\#name\#/$modulename/gm;
$impl =~ s/\#name\#/$modulename/gm; $impl =~ s/\#name\#/$modulename/gm;
...@@ -204,10 +211,14 @@ $impl =~ s/\#name\#/$modulename/gm; ...@@ -204,10 +211,14 @@ $impl =~ s/\#name\#/$modulename/gm;
# Set the header guards in capitals # Set the header guards in capitals
$header =~ s/\#NAME\#/\U$modulename/gm; $header =~ s/\#NAME\#/\U$modulename/gm;
open( FILE, ">WM${modulename}.h" ) or die; open( FILE, ">${dirname}/WM${modulename}.h" ) or die;
print FILE $header; print FILE $header;
close( FILE ); close( FILE );
open( FILE, ">WM${modulename}.cpp" ) or die; open( FILE, ">${dirname}/WM${modulename}.cpp" ) or die;
print FILE $impl; print FILE $impl;
close( FILE ); close( FILE );
print "Generating completed.\n";
print "\n";
print "Please make sure to copy an appropriate CMakeLists.txt file to the module directory.\n";
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