00001
00005 #ifndef __GRAPHMANAGER__H__
00006 #define __GRAPHMANAGER__H__
00007
00008 #include <string>
00009 #include <vector>
00010 #include <map>
00011 using namespace std;
00012
00013 #include "../Util/Singleton.h"
00014 #include "../Util/Vector2.h"
00015
00016 #include "../Main/TreeMap.h"
00017
00020 typedef enum BlendMode
00021 {
00022 NONE=0,
00023 ALPHA,
00024 MAX
00025 };
00026
00029 typedef enum TreeLayout
00030 {
00031 RADIAL=0,
00032 CLASSIC,
00033 TREEMAP_SLICE,
00034 TREEMAP_SQUARED,
00035 TREEMAP_STRIP
00036 };
00037
00040 class GraphManager : public Singleton<GraphManager>
00041 {
00042 friend class Singleton<GraphManager>;
00043 public:
00046 GraphManager(void);
00049 ~GraphManager(void);
00050
00053 void Init(void);
00056 void Clear(void);
00057
00061 void LoadRSFFile(string filename);
00062
00065 void BuildSplines();
00068 void CalculateSplines();
00071 void BuildLayouts();
00072
00076 void SetTreeLayout(TreeLayout newTreeLayout);
00080 void SetBeta(float newBeta);
00083 void SortSplines(void);
00084
00087 void Render(void);
00090 void RenderRadialTree(void);
00093 void RenderClassicTree(void);
00096 void RenderTreeMap(void);
00099 void RenderTreeStructure(void);
00102 void RenderSplines(void);
00103
00106 void Exit(void);
00107
00108 public:
00111 TreeLayout treeLayout;
00114 BlendMode blendMode;
00117 float minAlpha;
00120 float alphaExponent;
00123 bool flipAlpha;
00126 float lineWidth;
00129 float splineWidth;
00132 bool showTreeStructure;
00135 bool showSplines;
00138 unsigned int currentColorTexture;
00139
00142 unsigned int numTreeNodes;
00145 unsigned int numAdjRelations;
00148 float treeMapLayoutSpacing;
00149 private:
00152 struct TreeNode {
00155 unsigned int id;
00158 string name;
00161 TreeNode* parent;
00164 vector<TreeNode*> children;
00165
00168 Vector2 pos;
00169
00172 unsigned int depth;
00178 float widthOffset;
00184 float width;
00185
00188 TreeNode(unsigned int _id) : id(_id), parent(NULL), name(""), width(0), widthOffset(0), depth(0) {}
00189 };
00190
00193 struct AdjEdgeRelation {
00196 int index;
00199 TreeNode* start;
00202 TreeNode* end;
00205 int* controlPolygonIndices;
00208 unsigned int controlPolygonSize;
00209
00212 float length;
00213
00216 AdjEdgeRelation(TreeNode* _start, TreeNode* _end) : start(_start), end(_end), controlPolygonIndices(NULL), controlPolygonSize(0) {}
00217 };
00218
00222 float CalculateTreeWidth(TreeNode* node);
00226 void CalculateTreeWidthOffset(TreeNode* node);
00230 unsigned int AdaptDepths(TreeNode* node);
00234 unsigned int CalculateDepths(TreeNode* node);
00235
00240 TreeMapItem* CalculateTreeMap(TreeNode* node, unsigned int idx);
00245 void CalculateTreeMapLayout(TreeNode* node, TreeMapItem* tmi);
00246
00249 void LoadColorMap(void);
00250
00256 float B(int i, int n, float t);
00261 float B(int i, float t);
00267 Vector2 CalculateBSpline(float t, int* controlPolygon, int controlPolygonSize);
00274 Vector2 CalculateStraightenedSpline(float beta, float t, int* controlPolygon, int controlPolygonSize);
00275
00280 static bool SortRelations(const AdjEdgeRelation* var1, const AdjEdgeRelation* var2);
00281
00284 TreeNode* treeRoot;
00287 vector<TreeNode*> treeNodes;
00290 unsigned int treeDepth;
00293 vector<AdjEdgeRelation*> adjEdgeRelations;
00294
00297 float splineMinLength;
00300 float splineMaxLength;
00301
00304 float* beta0Spline;
00307 float* beta1Spline;
00310 float* currentSpline;
00313 unsigned int vboSplines;
00316 unsigned int vboTexCoords;
00317
00320 float beta;
00321
00324 float radius;
00327 float ringWidth;
00328
00331 TreeMap* treeMap;
00332
00335 unsigned int screenBuffer;
00338 unsigned int screenTexture;
00341 int textureWidth;
00344 int textureHeight;
00345
00348 unsigned int colorTextures[5];
00349 };
00350
00351 #endif