00001
00004
00005
00006
00007
00008
#ifndef _GRAPH_H_
00009
#define _GRAPH_H_
00010
00011
00012
#include <vector>
00013
#include "../src/main.h"
00014
#include "../src/Node.h"
00015
#include "../src/NodeAnimation.h"
00016
#include "../src/RadialLayout.h"
00017
00018
00019
using std::vector;
00020
00021
00026
00027 class Graph
00028 {
00029
protected:
00031 vector<Node*>
nodes_;
00034 vector<Node*>
nodes_copy_;
00036 vector<Node*>
nodes_end_pos_;
00038 NodeAnimation *
node_animation_;
00040 RadialLayout *
radial_layout_;
00042 Node *
centroid_;
00044 GLuint
num_ring_;
00046 bool animation_mode_;
00048 bool render_mode_;
00050 bool caption_mode_;
00051
00052 GLuint *
animation_speed_;
00053
00054 GLuint
last_animation_speed_;
00056 GLfloat
x_rotation_;
00058 GLfloat
y_rotation_;
00060 GLfloat
z_rotation_;
00061
00062
protected:
00063
00067 Graph() {};
00068
00069
public:
00070
00074 Graph(
NodeAnimation *node_animation,
RadialLayout *radial_layout) :
00075
node_animation_(node_animation),
00076
radial_layout_(radial_layout),
00077
centroid_(NULL),
00078
num_ring_(0),
00079
render_mode_(true),
00080
caption_mode_(true),
00081
animation_mode_(false),
00082
last_animation_speed_(0)
00083 {
00084 }
00085
00086
00090 virtual ~Graph()
00091 {
00092 vector<Node*>::iterator iter_1 =
nodes_.begin();
00093
while (iter_1 !=
nodes_.end())
00094 {
00095
delete (*iter_1);
00096 *iter_1 = NULL;
00097 ++iter_1;
00098 }
00099
00100 vector<Node*>::iterator iter_2 =
nodes_copy_.begin();
00101
while (iter_2 !=
nodes_copy_.end())
00102 {
00103
delete (*iter_2);
00104 *iter_2 = NULL;
00105 ++iter_2;
00106 }
00107
00108 vector<Node*>::iterator iter_3 =
nodes_end_pos_.begin();
00109
while (iter_3 !=
nodes_end_pos_.end())
00110 {
00111
delete (*iter_3);
00112 *iter_3 = NULL;
00113 ++iter_3;
00114 }
00115 }
00116
00117
00124
void createGraph(
char *file_name);
00125
00126
00130
void makeDeepCopyOfGraph(vector<Node*> *nodes_copy);
00131
00132
00138
void getCentreNodeOfGraph(vector<Node*> *nodes);
00139
00140
00145
void setOneNodeIntoGraph(
Node *node);
00146
00147
00152
void calcCartesianCoordinates(vector<Node*> *nodes);
00153
00154
00160
void initStartPositions(
Node *centroid,
Node *predecessor);
00161
00162
00168
void updateNumOfLeafs(vector<Node*> *nodes);
00169
00170
00175
void drawGraph(GLUquadricObj *quadric);
00176
00177
00181
void drawLine();
00182
00188
void setCenterNode (GLuint
id);
00189
00190
00196
Node *
getCenterNode();
00197
00198
00203
bool isANodeClicked(GLuint object_id);
00204
00205
00210
void highlightNodeIfSelected(GLuint node_id);
00211
00212
00218
void resetAngleOffsetTo(vector<Node*> *nodes, GLfloat angle_offset);
00219
00220
00225
void setAnimationMode(
bool animation_mode);
00226
00227
00231
void toggleRenderMode();
00232
00233
00237
void toggleCaptionMode();
00238
00239
00244
void setAnimationSpeed(GLuint *animation_speed);
00245
00246
00253
void setSceneRotation(GLfloat x_rotation, GLfloat y_rotation,
00254 GLfloat z_rotation);
00255 };
00256
00257
00258
#endif // _GRAPH_H_
00259
00260