OpenWalnut
1.4.0
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WDENDROGRAMGEODE_H 00026 #define WDENDROGRAMGEODE_H 00027 00028 #include <osg/Geode> 00029 #include <osg/Vec3> 00030 #include <osg/Geometry> 00031 #include <osg/MatrixTransform> 00032 #include <osg/PositionAttitudeTransform> 00033 00034 #include "../../common/WHierarchicalTreeFibers.h" 00035 00036 00037 /** 00038 * Class creates a dendrogram from a hierarchical clustering 00039 */ 00040 class WDendrogramGeode : public osg::Geode // NOLINT 00041 { 00042 public: 00043 /** 00044 * constructor 00045 * 00046 * \param tree reference to the tree object to work on 00047 * \param cluster root cluster for the dendrogram 00048 * \param useLevel if true the height of a node is determined by the level of the cluster 00049 * \param minClusterSize minimum for cluster to be drawn, when i the whole tree is drawn 00050 * \param xSize number of pixel to scale the tree on along the x axis 00051 * \param ySize number of pixel to scale the tree on along the y axis 00052 * \param xOffset translation alogn the x axis 00053 * \param yOffset translation alogn the y axis 00054 * 00055 */ 00056 WDendrogramGeode( WHierarchicalTree* tree, size_t cluster, bool useLevel = true, size_t minClusterSize = 1, float xSize = 1000.f, 00057 float ySize = 500.f, float xOffset = 0.0f, float yOffset = 0.0f ); 00058 00059 /** 00060 * destructor 00061 */ 00062 ~WDendrogramGeode(); 00063 00064 /** 00065 * calculate which cluster was clicked from given pixel coordinates 00066 * \param xClick the x coordinate 00067 * \param yClick the y coordinate 00068 * \return the cluster id, will return the root cluster if no cluster can be determinded 00069 */ 00070 size_t getClickedCluster( int xClick, int yClick ); 00071 00072 protected: 00073 private: 00074 /** 00075 * helper function the starts the layout process from the input data in the constructor 00076 */ 00077 void create(); 00078 00079 /** 00080 * recursive funtion that lays out the tree from top to bottom, 00081 * height of the joins is determined by the level of the cluster 00082 * \param cluster the current cluster to work on 00083 * \param left left border of the current subcluster 00084 * \param right right border of the current subcluster 00085 */ 00086 void layoutLevel( size_t cluster, float left, float right ); 00087 00088 /** 00089 * recursive funtion that lays out the tree from top to bottom, 00090 * height of the joins is determined by the similarity value of the cluster 00091 * \param cluster the current cluster to work on 00092 * \param left left border of the current subcluster 00093 * \param right right border of the current subcluster 00094 */ 00095 void layoutValue( size_t cluster, float left, float right ); 00096 00097 00098 /** 00099 * recurse function that follows the layout to determine the cluster from pixel coordinates, used when the level of the cluster 00100 * is used for height 00101 * 00102 * \param cluster cluster to check against coordinates 00103 * \param left left boundary of cluster 00104 * \param right right boundary of cluster 00105 */ 00106 void getClickClusterRecursive( size_t cluster, float left, float right ); 00107 00108 /** 00109 * recurse function that follows the layout to determine the cluster from pixel coordinates, used when the customData value is used 00110 * for height 00111 * 00112 * \param cluster cluster to check against coordinates 00113 * \param left left boundary of cluster 00114 * \param right right boundary of cluster 00115 */ 00116 void getClickClusterRecursive2( size_t cluster, float left, float right ); 00117 00118 00119 WHierarchicalTree* m_tree; //!< the tree to work on 00120 00121 size_t m_rootCluster; //!< top cluster to draw the tree from 00122 00123 osg::ref_ptr<osg::Vec4Array> m_colors; //!< color array 00124 00125 osg::Vec3Array* m_vertexArray; //!< vertex array 00126 00127 osg::DrawElementsUInt* m_lineArray; //!< line array 00128 00129 size_t m_minClusterSize; //!< minimum cluster size to be considered while laying out the dendrogram 00130 00131 float m_xSize; //!< x size in pixel of the final dendrogram 00132 float m_ySize; //!< y size in pixel of the final dendrogram 00133 float m_xOff; //!< x offset 00134 float m_yOff; //!< y offset 00135 float m_xMult; //!< helper variable for the recursive function 00136 float m_yMult; //!< helper variable for the recursive function 00137 00138 int m_xClicked; //!< stores the click position for use int he recursive function 00139 int m_yClicked; //!< stores the click position for use int he recursive function 00140 00141 bool m_useLevel; //!< flag indicating if the level or the value of a cluster will be used for the height of join 00142 00143 size_t m_clickedCluster; //!< the clicked cluster 00144 }; 00145 00146 #endif // WDENDROGRAMGEODE_H