51 #include "core/graphicsEngine/WGEUtils.h" 
   53 #include "WNonBinDendroGeode.h" 
   59                 float xSize, 
float ySize, 
float xOffset, 
float yOffset, 
bool useHLevel, 
bool triangleLeaves, 
float hozLine ) :
 
   60     osg::Geode(), m_tree( tree ), m_rootCluster( cluster ), m_displayColors( displayColors ), m_xSize( xSize ), m_ySize( ySize ),
 
   61                     m_xOff( xOffset ), m_yOff( yOffset ), m_useHLevel( useHLevel ), m_triangleLeaves( triangleLeaves ),
 
   74     m_lineColors = osg::ref_ptr< osg::Vec4Array >( 
new osg::Vec4Array );
 
   78     m_lineArray = 
new osg::DrawElementsUInt( osg::PrimitiveSet::LINES, 0 );
 
   82     float subTreeSize( 
static_cast< float > ( currentRoot.
getSize() ) );
 
   85     float topLevel( 0 ), topRoot( 0 );
 
   92         topRoot = topLevel + ( 20 / 
m_yUnit );
 
  106             topRoot = topLevel + ( 20 / 
m_yUnit );
 
  111     m_vertexArray->push_back( osg::Vec3( subTreeSize / 2.0, topRoot, 0 ) );
 
  112     m_vertexArray->push_back( osg::Vec3( subTreeSize / 2.0, topLevel, 0 ) );
 
  130     layout( currentRoot, 0.0f, 
static_cast< float > ( subTreeSize ) );
 
  134         ( *m_vertexArray )[i].x() = ( *m_vertexArray )[i].x() * 
m_xUnit + 
m_xOff;
 
  135         ( *m_vertexArray )[i].y() = ( *m_vertexArray )[i].y() * 
m_yUnit + 
m_yOff;
 
  138     osg::ref_ptr< osg::Geometry > geometry = osg::ref_ptr< osg::Geometry >( 
new osg::Geometry() );
 
  145     geometry->setColorBinding( osg::Geometry::BIND_PER_VERTEX );
 
  147     osg::StateSet* state = geometry->getOrCreateStateSet();
 
  148     state->setMode( GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED );
 
  150     addDrawable( geometry );
 
  166     float leftStart( leftLimit );
 
  169     std::vector< nodeID_t > kids( cluster.
getChildren() );
 
  171     bool horizontalNotDone( 
true );
 
  172     for( 
unsigned int i = 0; i < kids.size(); ++i )
 
  179             m_vertexArray->push_back( osg::Vec3( ( leftLimit + rightLimit ) / 2.0, height, 0 ) );
 
  180             m_vertexArray->push_back( osg::Vec3( leftStart + 0.5, 0, 0 ) );
 
  191         if( horizontalNotDone )
 
  193             float leftHozPoint( leftStart + ( thisKid.
getSize() * 0.5 ) );
 
  194             if( leftHozPoint > ( ( leftLimit + rightLimit ) / 2.0 ) )
 
  195                 leftHozPoint = ( leftLimit + rightLimit ) / 2.0;
 
  198             m_vertexArray->push_back( osg::Vec3( leftHozPoint, height, 0 ) );
 
  205             horizontalNotDone = 
false;
 
  210         float kidHeight( 0 );
 
  228             layout( thisKid, leftStart, leftStart + ( thisKid.
getSize() ) );
 
  231         leftStart += thisKid.
getSize();
 
  251     float diffX( 
m_xClicked - ( ( leftLimit + rightLimit ) * 0.5 ) );
 
  274         float leftStart( leftLimit );
 
  279         for( 
size_t i = 0; i < kids.size(); ++i )
 
  296                 leftStart += thisKid.
getSize();
 
this class implements a hierarchical tree node with several relevant attributes
 
size_t getSize() const
returns number of elements contained by the node
 
bool isLeaf() const
returns true if object is a leaf
 
size_t getHLevel() const
returns maximum number of nodes between the node and a leaf element
 
size_t getID() const
returns node/leaf ID
 
dist_t getDistLevel() const
returns distance level at which the element was formed
 
bool isNode() const
returns true if object is a node
 
std::vector< nodeID_t > getChildren() const
returns a vector with the ids of the children of that node
 
this class implements a hierarchical tree and provides functions for creation, partitioning,...
 
const WHnode & getRoot() const
returns a const reference to the root node
 
const WHnode & getNode(const nodeID_t &thisNode) const
returns a const pointer to the node indicated by the ID
 
void sortBySize(std::vector< size_t > *const nodeVector) const
Reorders the nodes in the vector according to their size.
 
float m_yUnit
helper variable for y position in the node selection recursive function
 
float m_xOff
x offset for dendrogram drawing in the screen
 
bool m_useHLevel
flag indicating if the level or the value of a cluster will be used for the height of join
 
const std::vector< WColor > & m_displayColors
stores a the current colors each node should be displayed, given the current selection
 
const WHtree m_tree
the tree to work on
 
bool inDendrogramArea(int xClick, int yClick) const
calculates if the given position is within the view area of the dendrogram
 
~WNonBinDendroGeode()
destructor
 
void layout(const WHnode &cluster, const float leftLimit, const float rightLimit)
recursive function that lays out the tree from top to bottom, height of the joins is determined by th...
 
bool m_triangleLeaves
option to join leaves with straight lines, giving a triangle appearance to the bottom level
 
void create()
helper function the starts the layout process from the input data in the constructor
 
size_t m_clickedCluster
ID of the clicked cluster.
 
float m_xClicked
stores the click x position for use in the node selection recursive function
 
size_t getClickedCluster(int xClick, int yClick)
calculate which cluster was clicked from given pixel coordinates
 
float m_hozLine
determines if a horizontal line will be drawn to indicate aprtition level
 
WNonBinDendroGeode(const WHtree &tree, const std::vector< WColor > &displayColors, size_t cluster, float xSize, float ySize, float xOffset, float yOffset, bool useHLevel=false, bool triangleLeaves=false, float hozLine=0)
constructor
 
float m_yOff
y offset for dendrogram drawing in the screen
 
float m_yClicked
stores the click y position for use in the node selection recursive function
 
size_t m_rootCluster
top cluster to draw the tree from
 
float m_xUnit
helper variable for x position in the node selection recursive function
 
osg::Vec3Array * m_vertexArray
vertex array
 
float m_ySize
y size in pixel of the final dendrogram
 
osg::ref_ptr< osg::Vec4Array > m_lineColors
stores a the colors of each line that should be drawn
 
float m_xSize
x size in pixel of the final dendrogram
 
void findClickedCluster(size_t cluster, float leftLimit, float rightLimit)
recurse function that follows the layout to determine the cluster from pixel coordinates
 
osg::DrawElementsUInt * m_lineArray
line array