Commit ba1eb5a7 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[MERGE]

parents 0aafa7da 2081ad51
......@@ -12,7 +12,7 @@ allowOnlyOneFiberDataSet = yes # This will prevent you from accidently loading m
# default=HUD
## A list of modules that will be provided through the GUI.
## If the list is empty all available modules are provided.
whiteList = Arbitrary Plane,Coordinate System,Image Extractor,Paint Texture,Arbitrary Rois,Bounding Box,Distance Map Isosurface,Gauss Filtering,HUD,Isosurface,Isosurface Raytracer,LIC,Mesh Reader,Voxelizer,Superquadric Glyphs,Triangle Mesh Renderer,Vector Plot,Write NIfTI
whiteList = Arbitrary Plane,Coordinate System,Image Extractor,Paint Texture,Arbitrary Rois,Bounding Box,Distance Map Isosurface,Gauss Filtering,HUD,Isosurface,Isosurface Raytracer,LIC,Read Mesh,Voxelizer,Superquadric Glyphs,Triangle Mesh Renderer,Vector Plot,Write NIfTI
## Specify a ";" separated list of additional paths for modules. The order of appearance is the order of loading. The following additional rules apply here:
## 1. if the directory contains one or more libOWmodule_XYZ it/they get loaded
......
......@@ -24,8 +24,8 @@
#include <vector>
#include "../../dataHandler/WDataSetFibers.h"
#include "../../kernel/WKernel.h"
#include "../kernel/WKernel.h"
#include "WFiberDrawable.h"
// The constructor here does nothing. One thing that may be necessary is
......@@ -35,9 +35,7 @@
// time (that is, the vertices drawn change from time to time).
WFiberDrawable::WFiberDrawable():
osg::Drawable(),
m_useTubes( false ),
m_globalColoring( true ),
m_customColoring( false )
m_useTubes( false )
{
setSupportsDisplayList( false );
// This contructor intentionally left blank. Duh.
......@@ -85,35 +83,17 @@ void WFiberDrawable::drawImplementation( osg::RenderInfo& renderInfo ) const //N
void WFiberDrawable::drawFibers( osg::RenderInfo& renderInfo ) const //NOLINT
{
boost::shared_ptr< std::vector< size_t > > startIndexes = m_dataset->getLineStartIndexes();
boost::shared_ptr< std::vector< size_t > > pointsPerLine = m_dataset->getLineLengths();
boost::shared_ptr< std::vector< float > > verts = m_dataset->getVertices();
boost::shared_ptr< std::vector< float > > tangents = m_dataset->getTangents();
boost::shared_ptr< std::vector< float > > colors;
if ( m_customColoring )
{
colors = colors = m_dataset->getColorScheme( "Custom Color" )->getColor();
}
else
{
colors = ( m_globalColoring ? m_dataset->getGlobalColors() : m_dataset->getLocalColors() );
}
boost::shared_ptr< std::vector< bool > > active = m_fiberSelector->getBitfield();
osg::State& state = *renderInfo.getState();
state.disableAllVertexArrays();
state.setVertexPointer( 3, GL_FLOAT , 0, &( *verts )[0] );
state.setColorPointer( 3 , GL_FLOAT , 0, &( *colors )[0] );
state.setNormalPointer( GL_FLOAT , 0, &( *tangents )[0] );
for ( size_t i = 0; i < active->size(); ++i )
state.setVertexPointer( 3, GL_FLOAT , 0, &( *m_verts )[0] );
state.setColorPointer( 3 , GL_FLOAT , 0, &( *m_colors )[0] );
//state.setNormalPointer( GL_FLOAT , 0, &( *m_tangents )[0] );
for ( size_t i = 0; i < m_active->size(); ++i )
{
if ( (*active)[i] )
if ( (*m_active)[i] )
{
state.glDrawArraysInstanced( GL_LINE_STRIP, (*startIndexes)[i], (*pointsPerLine)[i], 1);
state.glDrawArraysInstanced( GL_LINE_STRIP, (*m_startIndexes)[i], (*m_pointsPerLine)[i], 1);
}
}
......@@ -123,38 +103,20 @@ void WFiberDrawable::drawFibers( osg::RenderInfo& renderInfo ) const //NOLINT
void WFiberDrawable::drawTubes() const
{
boost::shared_ptr< std::vector< size_t > > startIndexes = m_dataset->getLineStartIndexes();
boost::shared_ptr< std::vector< size_t > > pointsPerLine = m_dataset->getLineLengths();
boost::shared_ptr< std::vector< float > > verts = m_dataset->getVertices();
boost::shared_ptr< std::vector< float > > tangents = m_dataset->getTangents();
boost::shared_ptr< std::vector< float > > colors;
if ( m_customColoring )
{
colors = m_dataset->getColorScheme( "Custom Color" )->getColor();
}
else
for( size_t i = 0; i < m_active->size(); ++i )
{
colors = ( m_globalColoring ? m_dataset->getGlobalColors() : m_dataset->getLocalColors() );
}
boost::shared_ptr< std::vector< bool > > active = m_fiberSelector->getBitfield();
for( size_t i = 0; i < active->size(); ++i )
{
if ( active->at( i ) )
if ( (*m_active)[i] )
{
glBegin( GL_QUAD_STRIP );
int idx = startIndexes->at( i ) * 3;
for ( size_t k = 0; k < pointsPerLine->at( i ); ++k )
int idx = m_startIndexes->at( i ) * 3;
for ( size_t k = 0; k < m_pointsPerLine->at( i ); ++k )
{
glNormal3f( tangents->at( idx ), tangents->at( idx + 1 ), tangents->at( idx + 2 ) );
glColor3f( colors->at( idx ), colors->at( idx + 1 ), colors->at( idx + 2 ) );
glNormal3f( m_tangents->at( idx ), m_tangents->at( idx + 1 ), m_tangents->at( idx + 2 ) );
glColor3f( m_colors->at( idx ), m_colors->at( idx + 1 ), m_colors->at( idx + 2 ) );
glTexCoord1f( -1.0f );
glVertex3f( verts->at( idx ), verts->at( idx + 1 ), verts->at( idx + 2 ) );
glVertex3f( m_verts->at( idx ), m_verts->at( idx + 1 ), m_verts->at( idx + 2 ) );
glTexCoord1f( 1.0f );
glVertex3f( verts->at( idx ), verts->at( idx + 1 ), verts->at( idx + 2 ) );
glVertex3f( m_verts->at( idx ), m_verts->at( idx + 1 ), m_verts->at( idx + 2 ) );
idx += 3;
//
}
......@@ -162,3 +124,8 @@ void WFiberDrawable::drawTubes() const
}
}
}
void WFiberDrawable::setDataset( boost::shared_ptr< const WDataSetFibers > dataset )
{
m_dataset = dataset;
}
......@@ -35,12 +35,8 @@
#include <osg/ShapeDrawable>
#include <osg/Group>
#include "WFiberSelector.h"
class WDataSetFibers;
/**
* TODO(schurade): Document this!
* Class implements an osg::Drawable that paints fiber representations either using lines or tubes
*/
class WFiberDrawable: public osg::Drawable
{
......@@ -108,49 +104,46 @@ public:
void setUseTubes( bool flag );
/**
* Set the coloring modes of the fibers.
*
* \param globalColoring If true is given global coloring is applied ( default ), else local coloring
* Set the bounding box of all fibers.
* \param bb The new bounding box.
*/
void setColoringMode( bool globalColoring );
void setBoundingBox( const osg::BoundingBox & bb );
/**
* Set the use of custom colors
*
* \param custom
* setter
* \param bitField selected fibers to draw
*/
void setCustomColoring( bool custom );
void setBitfield( boost::shared_ptr< std::vector< bool > > bitField );
/**
* In which mode coloring for the fibers is applied.
*
* \return True for global, false for local coloring
* setter
* \param idx
*/
bool getColoringMode() const;
void setStartIndexes( boost::shared_ptr< std::vector< size_t > > idx );
/**
* Set the bounding box of all fibers.
* \param bb The new bounding box.
* setter
* \param ppl
*/
void setBoundingBox( const osg::BoundingBox & bb );
void setPointsPerLine( boost::shared_ptr< std::vector< size_t > > ppl );
/**
* setter
* \param bitField selected fibers to draw
* \param verts
*/
void setBitfield( boost::shared_ptr< std::vector< bool > > bitField );
void setVerts( boost::shared_ptr< std::vector< float > > verts );
/**
* setter
* \param selector the selector object which provides the bitfield for fiber selection
* \param tangents
*/
void setSelector( boost::shared_ptr< WFiberSelector > selector );
void setTangents( boost::shared_ptr< std::vector< float > > tangents );
/**
* setter
* \param colors
* \param color
*/
void setCustomColors( boost::shared_ptr< std::vector< float > > colors );
void setColor( boost::shared_ptr< std::vector< float > > color );
protected:
private:
......@@ -172,54 +165,53 @@ private:
bool m_useTubes; //!< flag
bool m_globalColoring; //!< True indicates global, false local coloring
bool m_customColoring; //!< True indicates use of custom colors
boost::shared_ptr< std::vector< bool > > m_active; //!< pointer to the bitfield of active fibers
boost::shared_ptr< WFiberSelector > m_fiberSelector; //!< the selector object which provides the bitfield for fiber selection
boost::shared_ptr< std::vector< size_t > > m_startIndexes; //!< pointer to the field of line start indexes
boost::shared_ptr< std::vector< size_t > > m_pointsPerLine; //!< pointer to the field of points per line
boost::shared_ptr< std::vector< float > > m_verts; //!< pointer to the field of vertexes
boost::shared_ptr< std::vector< float > > m_tangents; //!< pointer to the field of line tangents
boost::shared_ptr< std::vector< float > > m_colors; //!< pointer to the field of colors per vertex
};
inline void WFiberDrawable::setDataset( boost::shared_ptr< const WDataSetFibers > dataset )
inline void WFiberDrawable::setUseTubes( bool flag )
{
m_dataset = dataset;
m_useTubes = flag;
}
inline void WFiberDrawable::setUseTubes( bool flag )
inline void WFiberDrawable::setBoundingBox( const osg::BoundingBox & bb )
{
m_useTubes = flag;
setBound( bb );
}
inline void WFiberDrawable::setColoringMode( bool globalColoring )
inline void WFiberDrawable::setBitfield( boost::shared_ptr< std::vector< bool > > bitField )
{
m_globalColoring = globalColoring;
m_active = bitField;
}
inline bool WFiberDrawable::getColoringMode() const
inline void WFiberDrawable::setStartIndexes( boost::shared_ptr< std::vector< size_t > > idx )
{
return m_globalColoring;
m_startIndexes = idx;
}
inline void WFiberDrawable::setCustomColoring( bool custom )
inline void WFiberDrawable::setPointsPerLine( boost::shared_ptr< std::vector< size_t > > ppl )
{
m_customColoring = custom;
m_pointsPerLine = ppl;
}
inline void WFiberDrawable::setBoundingBox( const osg::BoundingBox & bb )
inline void WFiberDrawable::setVerts( boost::shared_ptr< std::vector< float > > verts )
{
setBound( bb );
m_verts = verts;
}
inline void WFiberDrawable::setBitfield( boost::shared_ptr< std::vector< bool > > bitField )
inline void WFiberDrawable::setTangents( boost::shared_ptr< std::vector< float > > tangents )
{
m_active = bitField;
m_tangents = tangents;
}
inline void WFiberDrawable::setSelector( boost::shared_ptr< WFiberSelector > selector )
inline void WFiberDrawable::setColor( boost::shared_ptr< std::vector< float > > color )
{
m_fiberSelector = selector;
m_colors = color;
}
#endif // WFIBERDRAWABLE_H
......@@ -24,7 +24,7 @@
#include <iostream>
#include "../../kernel/WKernel.h"
#include "../kernel/WKernel.h"
#include "WFiberSelector.h"
......@@ -136,28 +136,33 @@ void WFiberSelector::recalculate()
{
if ( m_branches.empty() )
{
m_outputBitfield = boost::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_size, true ) );
return;
m_workerBitfield = boost::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_size, true ) );
}
else
{
m_workerBitfield = boost::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_size, false ) );
}
for ( std::list< boost::shared_ptr< WSelectorBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
{
boost::shared_ptr< std::vector< bool > > bf = ( *iter )->getBitField();
for ( size_t i = 0; i < m_size; ++i )
for ( std::list< boost::shared_ptr< WSelectorBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
{
( *m_workerBitfield )[i] = ( *m_workerBitfield )[i] | ( *bf )[i];
boost::shared_ptr< std::vector< bool > > bf = ( *iter )->getBitField();
for ( size_t i = 0; i < m_size; ++i )
{
( *m_workerBitfield )[i] = ( *m_workerBitfield )[i] | ( *bf )[i];
}
}
}
for ( size_t i = 0; i < m_size; ++i )
{
( *m_outputBitfield )[i] = ( *m_workerBitfield )[i];
}
m_dirty = false;
m_outputBitfield = m_workerBitfield;
//m_outputBitfield = m_workerBitfield;
}
void WFiberSelector::setDirty()
{
recalculate();
m_dirty = true;
}
......@@ -28,7 +28,7 @@
#include <list>
#include <vector>
#include "../../dataHandler/WDataSetFibers.h"
#include "../dataHandler/WDataSetFibers.h"
#include "WSelectorRoi.h"
#include "WSelectorBranch.h"
......@@ -102,20 +102,6 @@ protected:
*/
void slotRemoveBranch( boost::shared_ptr< WRMBranch > branch );
/**
* setter
* \param colors
*/
void setCustomColors( boost::shared_ptr< std::vector< float > > colors );
/**
* getter
* \return colors
*/
boost::shared_ptr< std::vector< float > > getCustomColors();
private:
/**
* update the bitfield when there was a change in the roi structure
......
......@@ -25,8 +25,8 @@
#include <algorithm>
#include <vector>
#include "../../common/WAssert.h"
#include "../../common/WLogger.h"
#include "../common/WAssert.h"
#include "../common/WLogger.h"
#include "WKdTree.h"
......
......@@ -28,7 +28,7 @@
#include <algorithm>
#include <vector>
#include "../../common/WThreadedRunner.h"
#include "../common/WThreadedRunner.h"
/**
* implements the compare function for std::nth_element on a point array
......
......@@ -61,6 +61,9 @@ void WRMBranch::propertyChanged()
void WRMBranch::addRoi( osg::ref_ptr< WROI > roi )
{
m_rois.push_back( roi );
boost::function< void() > changeRoiSignal = boost::bind( &WRMBranch::setDirty, this );
roi->addChangeNotifier( changeRoiSignal );
setDirty();
}
......
......@@ -29,7 +29,7 @@
#include <vector>
#include "WSelectorRoi.h"
#include "../../kernel/WRMBranch.h"
#include "../kernel/WRMBranch.h"
/**
* TODO(schurade): Document this!
......
......@@ -23,8 +23,8 @@
//---------------------------------------------------------------------------
//#include "../../../graphicsEngine/WGraphicsEngine.h"
#include "../../graphicsEngine/WROIBox.h"
#include "../../graphicsEngine/WROIArbitrary.h"
#include "../graphicsEngine/WROIBox.h"
#include "../graphicsEngine/WROIArbitrary.h"
#include "WSelectorRoi.h"
......
......@@ -27,9 +27,9 @@
#include <vector>
#include "../../dataHandler/WDataSetFibers.h"
#include "../dataHandler/WDataSetFibers.h"
#include "../../graphicsEngine/WROI.h"
#include "../graphicsEngine/WROI.h"
#include "WKdTree.h"
/**
......
......@@ -25,12 +25,13 @@
#include <iostream>
#include "../../graphicsEngine/WGEUtils.h"
#include "WDendrogram.h"
#include "WDendrogramGeode.h"
/**
* Class implements a dendrogram as an osg geode
*/
WDendrogram::WDendrogram( WHierarchicalTree* tree, size_t cluster, size_t minClusterSize, float xSize, float ySize, float xOffset, float yOffset ) :
WDendrogramGeode::WDendrogramGeode( WHierarchicalTree* tree, size_t cluster, size_t minClusterSize,
float xSize, float ySize, float xOffset, float yOffset ) :
osg::Geode(),
m_tree( tree ),
m_rootCluster( cluster ),
......@@ -43,11 +44,11 @@ WDendrogram::WDendrogram( WHierarchicalTree* tree, size_t cluster, size_t minClu
create();
}
WDendrogram::~WDendrogram()
WDendrogramGeode::~WDendrogramGeode()
{
}
void WDendrogram::create()
void WDendrogramGeode::create()
{
m_colors = osg::ref_ptr<osg::Vec4Array>( new osg::Vec4Array );
......@@ -80,10 +81,11 @@ void WDendrogram::create()
osg::StateSet* state = geometry->getOrCreateStateSet();
state->setMode( GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED );
addDrawable( geometry );
}
void WDendrogram::layout( size_t cluster, float left, float right )
void WDendrogramGeode::layout( size_t cluster, float left, float right )
{
float height = m_tree->getLevel( cluster );
......@@ -159,7 +161,7 @@ void WDendrogram::layout( size_t cluster, float left, float right )
}
}
size_t WDendrogram::getClickedCluster( int xClick, int yClick )
size_t WDendrogramGeode::getClickedCluster( int xClick, int yClick )
{
m_xClicked = ( xClick - m_xOff ) / m_xSize * ( m_tree->size( m_rootCluster ) - 1 );
m_yClicked = ( yClick - m_yOff ) / m_ySize * ( m_tree->getLevel( m_rootCluster ) - 1 );
......@@ -171,7 +173,7 @@ size_t WDendrogram::getClickedCluster( int xClick, int yClick )
return m_clickedCluster;
}
void WDendrogram::getClickClusterRecursive( size_t cluster, float left, float right )
void WDendrogramGeode::getClickClusterRecursive( size_t cluster, float left, float right )
{
int height = m_tree->getLevel( cluster );
......
......@@ -22,8 +22,8 @@
//
//---------------------------------------------------------------------------
#ifndef WDENDROGRAM_H
#define WDENDROGRAM_H
#ifndef WDENDROGRAMGEODE_H
#define WDENDROGRAMGEODE_H
#include <osg/Geode>
#include <osg/Vec3>
......@@ -36,7 +36,7 @@
/**
* Class creates a dendrogram from a hierarchical clustering
*/
class WDendrogram : public osg::Geode
class WDendrogramGeode : public osg::Geode
{
public:
/**
......@@ -51,13 +51,13 @@ public:
* \param yOffset translation alogn the y axis
*
*/
WDendrogram( WHierarchicalTree* tree, size_t cluster, size_t minClusterSize = 1, float xSize = 1000.f,
WDendrogramGeode( WHierarchicalTree* tree, size_t cluster, size_t minClusterSize = 1, float xSize = 1000.f,
float ySize = 500.f, float xOffset = 0.0f, float yOffset = 0.0f );
/**
* destructor
*/
~WDendrogram();
~WDendrogramGeode();
/**
* calculate which cluster was clicked from given pixel coordinates
......@@ -116,4 +116,4 @@ private:
size_t m_clickedCluster; //!< the clicked cluster
};
#endif // WDENDROGRAM_H
#endif // WDENDROGRAMGEODE_H
......@@ -87,7 +87,7 @@ void WHierarchicalTree::addCluster( size_t cluster1, size_t cluster2, size_t lev
++m_clusterCount;
}
boost::shared_ptr< std::vector<bool> >WHierarchicalTree::getOutputBitfield( size_t cluster )
boost::shared_ptr< std::vector<bool> > WHierarchicalTree::getOutputBitfield( size_t cluster )
{
boost::shared_ptr< std::vector< bool > > bf;
// only a single fiber selected
......@@ -311,7 +311,6 @@ std::vector<size_t> WHierarchicalTree::getBestClustersFittingRoi( float ratio, s
float WHierarchicalTree::getRatio( size_t cluster )
{
boost::shared_ptr< std::vector< bool > > roiSelection = WKernel::getRunningKernel()->getRoiManager()->getRoiBitfield();
std::vector<size_t>fibersInCluster = getLeafesForCluster( cluster );
size_t countFibersInCluster = fibersInCluster.size();
......@@ -319,7 +318,7 @@ float WHierarchicalTree::getRatio( size_t cluster )
for ( size_t i = 0; i < countFibersInCluster; ++i )
{
if ( ( *roiSelection )[fibersInCluster[i]] )
if ( ( *m_roiSelection )[fibersInCluster[i]] )
{
++fibersFromClusterActive;
}
......
......@@ -187,6 +187,12 @@ public:
*/
size_t size( size_t cluster );
/**
* setter
* \param bitfield
*/
void setRoiBitField( boost::shared_ptr< std::vector<bool> > bitfield );
protected:
private:
/**
......@@ -247,6 +253,11 @@ private:
* a color value for each cluster
*/
std::vector<WColor>m_colors;
/**
* stores a pointer to the bitfield by the current roi setting
*/
boost::shared_ptr< std::vector<bool> > m_roiSelection;
};
inline size_t WHierarchicalTree::getLeafCount()
......@@ -320,5 +331,9 @@ inline WColor WHierarchicalTree::getColor( size_t cluster )
return m_colors[cluster];
}
inline void WHierarchicalTree::setRoiBitField( boost::shared_ptr< std::vector<bool> > bitfield )
{
m_roiSelection = bitfield;
}
#endif // WHIERARCHICALTREE_H
......@@ -211,6 +211,7 @@ bool WMClusterDisplay::loadTreeAscii( std::string fileName )
{
return true;
}
debugLog() << "something is wrong with the tree file";
return false;
}
......@@ -416,6 +417,9 @@ void WMClusterDisplay::moduleMain()
}
}
m_fiberSelector = boost::shared_ptr<WFiberSelector>( new WFiberSelector( m_dataSet ) );
m_tree.setRoiBitField( m_fiberSelector->getBitfield() );
m_propTreeFile->setHidden( true );
m_readTriggerProp->setHidden( true );
......@@ -430,18 +434,17 @@ void WMClusterDisplay::moduleMain