27 #include "../../graphicsEngine/WGEUtils.h"
29 #include "WDendrogramGeode.h"
35 float xSize,
float ySize,
float xOffset,
float yOffset ) :
38 m_rootCluster( cluster ),
39 m_minClusterSize( minClusterSize ),
44 m_useLevel( useLevel )
55 m_colors = osg::ref_ptr<osg::Vec4Array>(
new osg::Vec4Array );
59 m_lineArray =
new osg::DrawElementsUInt( osg::PrimitiveSet::LINES, 0 );
80 (*m_vertexArray)[i].x() = (*m_vertexArray)[i].x() *
m_xMult +
m_xOff;
81 (*m_vertexArray)[i].y() = (*m_vertexArray)[i].y() *
m_yMult +
m_yOff;
84 osg::ref_ptr< osg::Geometry > geometry = osg::ref_ptr< osg::Geometry >(
new osg::Geometry() );
91 geometry->setColorBinding( osg::Geometry::BIND_PER_VERTEX );
93 osg::StateSet* state = geometry->getOrCreateStateSet();
94 state->setMode( GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED );
96 addDrawable( geometry );
103 float size = right - left;
111 float leftSize =
static_cast<float>(
m_tree->
size( leftCluster ) );
114 float rightSize =
static_cast<float>(
m_tree->
size( rightCluster ) );
120 m_vertexArray->push_back( osg::Vec3( ( left + size / 2.0 ), height, 0 ) );
121 m_vertexArray->push_back( osg::Vec3( ( left + size / 2.0 ), leftHeight, 0 ) );
135 m_vertexArray->push_back( osg::Vec3( ( left + size / 2.0 ), height, 0 ) );
136 m_vertexArray->push_back( osg::Vec3( ( left + size / 2.0 ), rightHeight, 0 ) );
148 float mult = size / ( leftSize + rightSize );
150 m_vertexArray->push_back( osg::Vec3( ( left + leftSize * mult / 2.0 ), height, 0 ) );
151 m_vertexArray->push_back( osg::Vec3( ( right - rightSize * mult / 2.0 ), height, 0 ) );
156 m_vertexArray->push_back( osg::Vec3( ( left + leftSize * mult / 2.0 ), leftHeight, 0 ) );
157 m_vertexArray->push_back( osg::Vec3( ( right - rightSize * mult / 2.0 ), rightHeight, 0 ) );
169 layoutLevel( leftCluster, left, left + leftSize * mult );
170 layoutLevel( rightCluster, right - rightSize * mult, right );
179 float size = right - left;
187 float leftSize =
static_cast<float>(
m_tree->
size( leftCluster ) );
190 float rightSize =
static_cast<float>(
m_tree->
size( rightCluster ) );
196 m_vertexArray->push_back( osg::Vec3( ( left + size / 2.0 ), height, 0 ) );
197 m_vertexArray->push_back( osg::Vec3( ( left + size / 2.0 ), leftHeight, 0 ) );
211 m_vertexArray->push_back( osg::Vec3( ( left + size / 2.0 ), height, 0 ) );
212 m_vertexArray->push_back( osg::Vec3( ( left + size / 2.0 ), rightHeight, 0 ) );
224 float mult = size / ( leftSize + rightSize );
226 m_vertexArray->push_back( osg::Vec3( ( left + leftSize * mult / 2.0 ), height, 0 ) );
227 m_vertexArray->push_back( osg::Vec3( ( right - rightSize * mult / 2.0 ), height, 0 ) );
232 m_vertexArray->push_back( osg::Vec3( ( left + leftSize * mult / 2.0 ), leftHeight, 0 ) );
233 m_vertexArray->push_back( osg::Vec3( ( right - rightSize * mult / 2.0 ), rightHeight, 0 ) );
245 layoutValue( leftCluster, left, left + leftSize * mult );
246 layoutValue( rightCluster, right - rightSize * mult, right );
281 int size = right - left;
288 float leftSize =
static_cast<float>(
m_tree->
size( leftCluster ) );
289 float rightSize =
static_cast<float>(
m_tree->
size( rightCluster ) );
303 float mult = size / ( leftSize + rightSize );
327 int size = right - left;
334 float leftSize =
static_cast<float>(
m_tree->
size( leftCluster ) );
335 float rightSize =
static_cast<float>(
m_tree->
size( rightCluster ) );
349 float mult = size / ( leftSize + rightSize );
bool m_useLevel
flag indicating if the level or the value of a cluster will be used for the height of join
void getClickClusterRecursive(size_t cluster, float left, float right)
recurse function that follows the layout to determine the cluster from pixel coordinates,...
size_t getClickedCluster(int xClick, int yClick)
calculate which cluster was clicked from given pixel coordinates
int m_xClicked
stores the click position for use int he recursive function
int m_yClicked
stores the click position for use int he recursive function
size_t m_rootCluster
top cluster to draw the tree from
float m_xMult
helper variable for the recursive function
osg::ref_ptr< osg::Vec4Array > m_colors
color array
WHierarchicalTree * m_tree
the tree to work on
float m_ySize
y size in pixel of the final dendrogram
void layoutValue(size_t cluster, float left, float right)
recursive funtion that lays out the tree from top to bottom, height of the joins is determined by the...
bool inDendrogramArea(const WVector2f &pos) const
calculates if the given position is within the view area of the dendrogram
~WDendrogramGeode()
destructor
WDendrogramGeode(WHierarchicalTree *tree, size_t cluster, bool useLevel=true, size_t minClusterSize=1, float xSize=1000.f, float ySize=500.f, float xOffset=0.0f, float yOffset=0.0f)
constructor
osg::DrawElementsUInt * m_lineArray
line array
size_t m_minClusterSize
minimum cluster size to be considered while laying out the dendrogram
size_t m_clickedCluster
the clicked cluster
float m_yMult
helper variable for the recursive function
void layoutLevel(size_t cluster, float left, float right)
recursive funtion that lays out the tree from top to bottom, height of the joins is determined by the...
osg::Vec3Array * m_vertexArray
vertex array
void create()
helper function the starts the layout process from the input data in the constructor
float m_xSize
x size in pixel of the final dendrogram
void getClickClusterRecursive2(size_t cluster, float left, float right)
recurse function that follows the layout to determine the cluster from pixel coordinates,...
base class for hierarchical tree implementations
size_t size(size_t cluster) const
getter
std::pair< size_t, size_t > getChildren(size_t cluster) const
getter
WColor getColor(size_t cluster) const
getter
float getCustomData(size_t cluster) const
getter
size_t getLevel(size_t cluster) const
getter
A fixed size matrix class.