Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

bool LabeledGraph::doForceDirectedLayout (  )  [inline, private]

Definition at line 80 of file LabeledGraph.h.

References cap(), OglGui::OglWindow::GetDimensions(), OglGui::OglWindow::H(), OglGui::Graph::mNodes, and OglGui::OglWindow::W().

Referenced by doLayout().

00080                                      {
00081                 int x, y, w, h;
00082                 mNodes[0].nodeVector[0]->GetDimensions(x, y, w, h);
00083                 uint cx = (W()-w)/2, cy = (H()-h)/2;
00084                 mNodes[0].nodeVector[0]->SetDimensions(cx, cy, w, h);
00085 
00086                 float energy = 0;
00087                 float alpha = 0.01;
00088                 for(uint i = 0; i < mNodes.size(); i++) {
00089                         mNodes[i].nodeVector[0]->GetDimensions(x, y, w, h);
00090 
00091                         int nX, nY, nW, nH;
00092                         // Move away nodes that are too close
00093                         for(uint j = 0; j < mNodes.size(); j++) {
00094                                 if(i==j) continue;
00095                                 mNodes[j].nodeVector[0]->GetDimensions(nX, nY, nW, nH);
00096                                 int distX = nX-x, distY = nY-y;
00097                                 /*if(ABSRND(20) == 1) {
00098                                         nX = (distX > 0) ? nX + 1 : nX - 1;
00099                                         nY = (distY > 0) ? nY + 1 : nY - 1;
00100                                 }*/
00101                                 int pX = nX, pY = nY;
00102                                 if((abs(distX) < (nW)) && (abs(distY) < (nH))) {
00103                                         nX += (distX > 0) ? nW: -nW;
00104                                         nY += (distY > 0) ? nH : -nH;
00105                                 }
00106                                 nX = cap(nX, 0, W()-nW);
00107                                 nY = cap(nY, 0, H()-nH);
00108                                 float delta = sqrt(pow(nX-pX, 2.0) + pow(nY-pY, 2.0));
00109                                 if(delta > 0) {
00110                                         energy += delta;
00111                                         mNodes[j].nodeVector[0]->SetDimensions(nX, nY, nW, nH);
00112                                 }
00113                         }
00114                         for(uint j = 1; j < mNodes[i].nodeVector.size(); j++){
00115                                 mNodes[i].nodeVector[j]->GetDimensions(nX, nY, nW, nH);
00116                                 //if(sqrt(pow(nX-x, 2) + pow(nY-y, 2)) < 2*nW) continue;
00117                                 mNodes[i].nodeVector[0]->SetDimensions(nX*alpha+x*(1-alpha), nY*alpha+y*(1-alpha), w, h);
00118                                 mNodes[i].nodeVector[j]->SetDimensions(x*alpha+nX*(1-alpha), y*alpha+nY*(1-alpha), nW, nH);
00119                         }
00120                 }
00121                 return(energy == 0);
00122         }

Here is the call graph for this function:


Generated on Fri Mar 19 10:32:26 2010 for ImpalaSrc by  doxygen 1.5.1