NodeAnimation Class Reference

#include <NodeAnimation.h>

List of all members.

Public Member Functions

 NodeAnimation ()
void interpolatePolarCoord (Node *node, GLfloat radius_end, GLfloat angle_end, GLuint iter)
void calculateNodeRadiusAndColor (Node *node, GLfloat radius)
void setNodeAnimationSpeed (GLuint *animation_speed)


Detailed Description

This class is reponsable for the animation of one node. The node can be passed using the constructor. Every animation of a node consists of the start position and the end position. The values between these positions will be calculated using 'proceedAnimation()'.

Definition at line 27 of file NodeAnimation.h.


Constructor & Destructor Documentation

NodeAnimation::NodeAnimation  )  [inline]
 

The default constructor.

Definition at line 40 of file NodeAnimation.h.

00040 : 00041 animation_speed_(NULL) 00042 { 00043 }


Member Function Documentation

void NodeAnimation::calculateNodeRadiusAndColor Node node,
GLfloat  radius
 

This calculates the radius of the node depending on the difference to the focus.

Parameters:
radius The difference from the focus.

Definition at line 76 of file NodeAnimation.cpp.

References calculateNodeRadiusAndColor(), Node::setBlue(), Node::setGreen(), Node::setNodeRadius(), and Node::setRed().

Referenced by calculateNodeRadiusAndColor(), and Graph::drawGraph().

00077 { 00078 GLfloat biggest_node = 0.18f; //radius of the node in the focus 00079 GLfloat smallest_node = 0.03f; //radius of the node on the outside of the ring 00080 GLint number_rings = 9; //number of rings in the radial graph 00081 // how much must get the radius of the node smaller between two graph 00082 // circles / 3: 00083 GLfloat node_radius_difference = (biggest_node - smallest_node) / 00084 (number_rings * 6); 00085 00086 GLuint red; 00087 GLuint green; 00088 GLuint blue; 00089 00090 // for the space between the focus and the first ring. We divide with 3 00091 // because we want to make the node smaller for 3 times. That means that 00092 // between the focus and the first ring the radius of the node id 00093 // decreasing each space_sektor for node_radius_differernce 00094 GLfloat space_sector01 = (abs(0.5 - 0.0) / 6); 00095 GLfloat space_sector12 = (abs(0.9 - 0.5) / 6); 00096 GLfloat space_sector23 = (abs(0.9 - 1.22) / 6); 00097 GLfloat space_sector34 = abs(1.22 - 1.476) / 6; 00098 GLfloat space_sector45 = abs(1.476 - 1.6808) / 6; 00099 GLfloat space_sector56 = abs(1.6808 - 1.84464) / 6; 00100 GLfloat space_sector67 = abs(1.84464 - 1.97571) / 6; 00101 GLfloat space_sector78 = abs(1.97571 - 2.08057) / 6; 00102 GLfloat space_sector89 = abs(2.08057 - 2.16446) / 6; 00103 GLfloat space_sector90 = abs(2.16446 - 2.23156) / 6; 00104 GLfloat radius_node; // the actual radius of the node 00105 00106 if (radius <= space_sector01) 00107 { 00108 radius_node = biggest_node; 00109 red = 101; green = 5; blue = 101; 00110 } 00111 else if ((radius > space_sector01) && (radius <= 2 * space_sector01)) 00112 { 00113 radius_node = biggest_node - 1 * node_radius_difference; 00114 red = 107; green = 5; blue = 107; 00115 } 00116 else if ((radius > 2 * space_sector01) && (radius <= 3 * space_sector01)) 00117 { 00118 radius_node= biggest_node - 2 * node_radius_difference; 00119 red = 114; green = 5; blue = 114; 00120 } 00121 else if ((radius > 3 * space_sector01) && (radius <= 4 * space_sector01)) 00122 { 00123 radius_node= biggest_node - 3 * node_radius_difference; 00124 red = 119; green = 6; blue = 119; 00125 } 00126 else if ((radius > 4 * space_sector01) && (radius <= 5 * space_sector01)) 00127 { 00128 radius_node= biggest_node - 4 * node_radius_difference; 00129 red = 125; green = 6; blue = 125; 00130 } 00131 else if ((radius > 5 * space_sector01) && (radius <= 6 * space_sector01)) 00132 { 00133 radius_node= biggest_node - 5 * node_radius_difference; 00134 red = 132; green = 6; blue = 132; 00135 } 00136 00137 // for the space between the first and the second ring: 00138 else if (( radius > 0.5) && (radius <= 0.5 + space_sector12)) 00139 { 00140 radius_node = biggest_node - 6 * node_radius_difference; 00141 red = 137; green = 7; blue = 137; 00142 } 00143 else if ((radius > 0.5 + space_sector12) && (radius <= 0.5 + 2 * space_sector12)) 00144 { 00145 radius_node = biggest_node - 7 * node_radius_difference; 00146 red = 143; green = 7; blue = 143; 00147 } 00148 else if ((radius > 0.5 + 2 * space_sector12) && ( radius <= 0.5 + 3 * space_sector12)) 00149 { 00150 radius_node = biggest_node - 8 * node_radius_difference; 00151 red = 150; green = 7; blue = 150; 00152 } 00153 else if ((radius > 0.5 + 3 * space_sector12) && ( radius <= 0.5 + 4 * space_sector12)) 00154 { 00155 radius_node = biggest_node - 9 * node_radius_difference; 00156 red = 156; green = 7; blue = 156; 00157 } 00158 else if ((radius > 0.5 + 4 * space_sector12) && ( radius <= 0.5 + 5 * space_sector12)) 00159 { 00160 radius_node = biggest_node - 10 * node_radius_difference; 00161 red = 162; green = 9; blue = 162; 00162 } 00163 else if ((radius > 0.5 + 5 * space_sector12) && ( radius <= 0.5 + 6 * space_sector12)) 00164 { 00165 radius_node = biggest_node - 11 * node_radius_difference; 00166 red = 168; green = 9; blue = 168; 00167 } 00168 00169 // for the space between the second and the third ring: 00170 else if (( radius > 0.9) && (radius <= 0.9 + space_sector23)) 00171 { 00172 radius_node = biggest_node - 12 * node_radius_difference; 00173 red = 174; green = 9; blue = 174; 00174 } 00175 else if ((radius > 0.9 + space_sector23) && (radius <= 0.9 + 2 * space_sector23)) 00176 { 00177 radius_node = biggest_node - 13 * node_radius_difference; 00178 red = 180; green = 10; blue = 180; 00179 } 00180 else if ((radius > 0.9 + 2 * space_sector23) && (radius <= 0.9 + 3 * space_sector23)) 00181 { 00182 radius_node = biggest_node - 14 * node_radius_difference; 00183 red = 186; green = 10; blue = 186; 00184 } 00185 else if ((radius > 0.9 + 3 * space_sector23) && (radius <= 0.9 + 4 * space_sector23)) 00186 { 00187 radius_node = biggest_node - 15 * node_radius_difference; 00188 red = 192; green = 10; blue = 192; 00189 } 00190 else if ((radius > 0.9 + 4 * space_sector23) && (radius <= 0.9 + 5 * space_sector23)) 00191 { 00192 radius_node = biggest_node - 16 * node_radius_difference; 00193 red = 199; green = 10; blue = 199; 00194 } 00195 else if ((radius > 0.9 + 5 * space_sector23) && (radius <= 0.9 + 6 * space_sector23)) 00196 { 00197 radius_node = biggest_node - 17 * node_radius_difference; 00198 red = 204; green = 11; blue = 204; 00199 } 00200 00201 // for the space between the third and the fourth ring: 00202 else if (( radius > 1.22) && (radius <= 1.22 + space_sector34)) 00203 { 00204 radius_node = biggest_node - 18 * node_radius_difference; 00205 red = 210; green = 11; blue = 210; 00206 } 00207 else if ((radius > 1.22 + space_sector34) && (radius <= 1.22 + 2 * space_sector34)) 00208 { 00209 radius_node = biggest_node - 19 * node_radius_difference; 00210 red = 217; green = 11; blue = 217; 00211 } 00212 else if ((radius > 1.22 + 2 * space_sector34) && (radius <= 1.22 + 3 * space_sector34)) 00213 { 00214 radius_node = biggest_node - 20 * node_radius_difference; 00215 red = 222; green = 11; blue = 222; 00216 } 00217 else if ((radius > 1.22 + 3 * space_sector34) && (radius <= 1.22 + 4 * space_sector34)) 00218 { 00219 radius_node = biggest_node - 21 * node_radius_difference; 00220 red = 228; green = 12; blue = 228; 00221 } 00222 else if ((radius > 1.22 + 4 * space_sector34) && (radius <= 1.22 + 5 * space_sector34)) 00223 { 00224 radius_node = biggest_node - 22 * node_radius_difference; 00225 red = 235; green = 12; blue = 235; 00226 } 00227 else if ((radius > 1.22 + 5 * space_sector34) && (radius <= 1.22 + 6 * space_sector34)) 00228 { 00229 radius_node = biggest_node - 23 * node_radius_difference; 00230 red = 241; green = 12; blue = 241; 00231 } 00232 00233 // for the space between the fourth and the fifth ring: 00234 else if (( radius > 1.476) && (radius <= 1.476 + space_sector45)) 00235 { 00236 radius_node = biggest_node - 24 * node_radius_difference; 00237 red = 243; green = 16; blue = 243; 00238 } 00239 else if ((radius > 1.476 + space_sector45) && (radius <= 1.476 + 2 * space_sector45)) 00240 { 00241 radius_node = biggest_node - 25 * node_radius_difference; 00242 red = 243; green = 22; blue = 243; 00243 } 00244 else if ((radius > 1.476 + 2 * space_sector45) && (radius <= 1.476 + 3 * space_sector45)) 00245 { 00246 radius_node = biggest_node - 26 * node_radius_difference; 00247 red = 243; green = 29; blue = 243; 00248 } 00249 else if ((radius > 1.476 + 3 * space_sector45) && (radius <= 1.476 + 4 * space_sector45)) 00250 { 00251 radius_node = biggest_node - 27 * node_radius_difference; 00252 red = 244; green = 34; blue = 244; 00253 } 00254 else if ((radius > 1.476 + 4 * space_sector45) && (radius <= 1.476 + 5 * space_sector45)) 00255 { 00256 radius_node = biggest_node - 28 * node_radius_difference; 00257 red = 244; green = 40; blue = 244; 00258 } 00259 else if ((radius > 1.476 + 5 * space_sector45) && (radius <= 1.476 + 6 * space_sector45)) 00260 { 00261 radius_node = biggest_node - 29 * node_radius_difference; 00262 red = 244; green = 47; blue = 244; 00263 } 00264 00265 // for the space between the fifth and the sixth ring: 00266 else if (( radius > 1.6808) && (radius <= 1.6808 + space_sector56)) 00267 { 00268 radius_node = biggest_node - 30 * node_radius_difference; 00269 red = 244; green = 53; blue = 244; 00270 } 00271 else if ((radius > 1.6808 + space_sector56) && (radius <= 1.6808 + 2 * space_sector56)) 00272 { 00273 radius_node = biggest_node - 31 * node_radius_difference; 00274 red = 245; green = 58; blue = 244; 00275 } 00276 else if ((radius > 1.6808 + 2 * space_sector56) && (radius <= 1.6808 + 3 * space_sector56)) 00277 { 00278 radius_node = biggest_node - 32 * node_radius_difference; 00279 red = 245; green = 65; blue = 245; 00280 } 00281 else if ((radius > 1.6808 + 3 * space_sector56) && (radius <= 1.6808 + 4 * space_sector56)) 00282 { 00283 radius_node = biggest_node - 33 * node_radius_difference; 00284 red = 245; green = 71; blue = 245; 00285 } 00286 else if ((radius > 1.6808 + 4 * space_sector56) && (radius <= 1.6808 + 5 * space_sector56)) 00287 { 00288 radius_node = biggest_node - 34 * node_radius_difference; 00289 red = 247; green = 77; blue = 247; 00290 } 00291 else if ((radius > 1.6808 + 5 * space_sector56) && (radius <= 1.6808 + 6 * space_sector56)) 00292 { 00293 radius_node = biggest_node - 35 * node_radius_difference; 00294 red = 247; green = 83; blue = 247; 00295 } 00296 00297 // for the space between the sixth and the seventh ring: 00298 else if (( radius > 1.84464) && (radius <= 1.84464 + space_sector67)) 00299 { 00300 radius_node = biggest_node - 36 * node_radius_difference; 00301 red = 247; green = 89; blue = 247; 00302 } 00303 else if ((radius > 1.84464 + space_sector67) && 00304 (radius <= 1.84464 + 2 * space_sector67)) 00305 { 00306 radius_node = biggest_node - 37 * node_radius_difference; 00307 red = 247; green = 96; blue = 247; 00308 } 00309 else if ((radius > 1.84464 + 2 * space_sector67) && (radius <= 1.84464 + 3 * space_sector67)) 00310 { 00311 radius_node = biggest_node - 38 * node_radius_difference; 00312 red = 248; green = 101; blue = 248; 00313 } 00314 else if ((radius > 1.84464 + 3 * space_sector67) && (radius <= 1.84464 + 4 * space_sector67)) 00315 { 00316 radius_node = biggest_node - 39 * node_radius_difference; 00317 red = 248; green = 107; blue = 248; 00318 } 00319 else if ((radius > 1.84464 + 4 * space_sector67) && (radius <= 1.84464 + 5 * space_sector67)) 00320 { 00321 radius_node = biggest_node - 40 * node_radius_difference; 00322 red = 248; green = 114; blue = 248; 00323 } 00324 else if ((radius > 1.84464 + 5 * space_sector67) && (radius <= 1.84464 + 6 * space_sector67)) 00325 { 00326 radius_node = biggest_node - 41 * node_radius_difference; 00327 red = 249; green = 119; blue = 249; 00328 } 00329 00330 // for the space between the seventh and the eighth ring: 00331 else if (( radius > 1.97571) && (radius <= 1.97571 + space_sector78)) 00332 { 00333 radius_node = biggest_node - 42 * node_radius_difference; 00334 red = 249; green = 125; blue = 249; 00335 } 00336 else if ((radius > 1.97571 + space_sector78) && 00337 (radius <= 1.97571 + 2 * space_sector78)) 00338 { 00339 radius_node = biggest_node - 43 * node_radius_difference; 00340 red = 249; green = 132; blue = 249; 00341 } 00342 else if ((radius > 1.97571 + 2 * space_sector78) && (radius <= 1.97571 + 3 * space_sector78)) 00343 { 00344 radius_node = biggest_node - 44 * node_radius_difference; 00345 red = 249; green = 138; blue = 249; 00346 } 00347 else if ((radius > 1.97571 + 3 * space_sector78) && (radius <= 1.97571 + 4 * space_sector78)) 00348 { 00349 radius_node = biggest_node - 45 * node_radius_difference; 00350 red = 250; green = 143; blue = 250; 00351 } 00352 else if ((radius > 1.97571 + 4 * space_sector78) && (radius <= 1.97571 + 5 * space_sector78)) 00353 { 00354 radius_node = biggest_node - 46 * node_radius_difference; 00355 red = 250; green = 150; blue = 250; 00356 } 00357 else if ((radius > 1.97571 + 5 * space_sector78) && (radius <= 1.97571 + 6 * space_sector78)) 00358 { 00359 radius_node = biggest_node - 47 * node_radius_difference; 00360 red = 250; green = 156; blue = 250; 00361 } 00362 00363 // for the space between the eighth and the nineth ring: 00364 else if (( radius > 2.08057) && (radius <= 2.08057 + space_sector89)) 00365 { 00366 radius_node = biggest_node - 48 * node_radius_difference; 00367 red = 251; green = 162; blue = 251; 00368 } 00369 else if ((radius > 2.08057 + space_sector89) && 00370 (radius <= 2.08057 + 2 * space_sector89)) 00371 { 00372 radius_node = biggest_node - 49 * node_radius_difference; 00373 red = 251; green = 168; blue = 251; 00374 } 00375 else if ((radius > 2.08057 + 2 * space_sector89) && (radius <= 2.08057 + 3 * space_sector89)) 00376 { 00377 radius_node = biggest_node - 50 * node_radius_difference; 00378 red = 251; green = 174; blue = 251; 00379 } 00380 else if ((radius > 2.08057 + 3 * space_sector89) && (radius <= 2.08057 + 4 * space_sector89)) 00381 { 00382 radius_node = biggest_node - 51 * node_radius_difference; 00383 red = 251; green = 181; blue = 251; 00384 } 00385 else if ((radius > 2.08057 + 4 * space_sector89) && (radius <= 2.08057 + 5 * space_sector89)) 00386 { 00387 radius_node = biggest_node - 52 * node_radius_difference; 00388 red = 252; green = 186; blue = 252; 00389 } 00390 else if ((radius > 2.08057 + 5 * space_sector89) && (radius <= 2.08057 + 6 * space_sector89)) 00391 { 00392 radius_node = biggest_node - 53 * node_radius_difference; 00393 red = 252; green = 192; blue = 252; 00394 } 00395 00396 // for the space between the nineth and the tenth ring: 00397 else if (( radius > 2.16446) && (radius <= 2.16446 + space_sector90)) 00398 { 00399 radius_node = biggest_node - 54 * node_radius_difference; 00400 red = 252; green = 199; blue = 252; 00401 } 00402 else if ((radius > 2.16446 + space_sector90) && 00403 (radius <= 2.16446 + 2 * space_sector90)) 00404 { 00405 radius_node = biggest_node - 55 * node_radius_difference; 00406 red = 253; green = 204; blue = 253; 00407 } 00408 else if ((radius > 2.16446 + 2 * space_sector90) && (radius <= 2.16446 + 3 * space_sector90)) 00409 { 00410 radius_node = biggest_node - 56 * node_radius_difference; 00411 red = 253; green = 210; blue = 253; 00412 } 00413 else if ((radius > 2.16446 + 3 * space_sector90) && (radius <= 2.16446 + 4 * space_sector90)) 00414 { 00415 radius_node = biggest_node - 57 * node_radius_difference; 00416 red = 253; green = 217; blue = 253; 00417 } 00418 else if ((radius > 2.16446 + 4 * space_sector90) && (radius <= 2.16446 + 5 * space_sector90)) 00419 { 00420 radius_node = biggest_node - 58 * node_radius_difference; 00421 red = 253; green = 223; blue = 253; 00422 } 00423 else if ((radius > 2.16446 + 5 * space_sector90) && (radius <= 2.16446 + 6 * space_sector90)) 00424 { 00425 radius_node = biggest_node - 59 * node_radius_difference; 00426 red = 254; green = 228; blue = 254; 00427 } 00428 //radius_node = 0.1f; 00429 node->setNodeRadius(radius_node); 00430 node->setRed(red); 00431 node->setGreen(green); 00432 node->setBlue(blue); 00433 }

Here is the call graph for this function:

void NodeAnimation::interpolatePolarCoord Node node,
GLfloat  radius_end,
GLfloat  angle_end,
GLuint  iter
 

This interpolates the polar coordinates for the animation.

Precondition:
node != NULL
Parameters:
radius_end The radius of the final point after the animation
angle_end The angle of the final point after the animation
iter The iterator for the rendering.

Definition at line 22 of file NodeAnimation.cpp.

References Node::getAngle(), Node::getRadius(), interpolatePolarCoord(), is_animation_running_, Node::setAngle(), and Node::setRadius().

Referenced by Graph::drawGraph(), and interpolatePolarCoord().

00024 { 00025 GLint points = (*animation_speed_) - iter; 00026 //cout << "/// " << points << endl; 00027 if (points == 0) 00028 { 00029 is_animation_running_ = false; 00030 return; 00031 } 00032 angle_start_ = node->getAngle(); 00033 radius_start_ = node->getRadius(); 00034 00035 GLfloat angle_difference = 00036 abs((GLfloat)angle_start_ - (GLfloat)angle_end); 00037 GLfloat radius_difference = radius_end - radius_start_; 00038 00039 GLfloat angle_sector = 0; 00040 00041 if (angle_difference > 180) 00042 { 00043 angle_difference = 360 - angle_difference; 00044 } 00045 00046 angle_sector = angle_difference / points; 00047 00048 if (angle_difference > 180) 00049 { 00050 angle_sector = -angle_sector; 00051 } 00052 GLfloat radius_sector = radius_difference / points; 00053 00054 GLfloat angle = angle_start_ + angle_sector; 00055 GLfloat radius = radius_start_ + radius_sector; 00056 00057 if (abs(angle - angle_end) <= 0.000001) 00058 { 00059 points = 0; 00060 node->setAngle(angle_end); 00061 node->setRadius(radius_end); 00062 } 00063 //GLfloat x = radius * cos(angle); 00064 //GLfloat y = radius * sin(angle); 00065 node->setAngle(angle); 00066 node->setRadius(radius); 00067 //node->setPointVector(new Vector3D(x, y, 0.0, 0.0)); 00068 }

Here is the call graph for this function:

void NodeAnimation::setNodeAnimationSpeed GLuint *  animation_speed  ) 
 

This sets the node's animation speed.

Parameters:
animation_speed The node's animation speed.

Definition at line 440 of file NodeAnimation.cpp.

References setNodeAnimationSpeed().

Referenced by Graph::drawGraph(), and setNodeAnimationSpeed().

00441 { 00442 animation_speed_ = animation_speed; 00443 }

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Mon Jun 14 12:49:10 2004 for InfoVis by doxygen 1.3.7