ui: graph view layouting and member rendering

Added simple layouting functions (implementations for simple grid and circle layout).
Also the graph displays class members and connections (edges) to or from them "correctly" now.

fortune cookie message = Your exotic ideas will lead you to many exciting new adventures.
This commit is contained in:
Manuel Dobusch
2014-07-15 16:40:52 +02:00
parent 61cb4afd91
commit ec42ef708d
24 changed files with 839 additions and 165 deletions
@@ -0,0 +1,48 @@
#include "component/controller/GraphLayouter.h"
#include "component/view/graphElements/GraphNode.h"
void GraphLayouter::layoutSimpleRaster(std::vector<DummyNode>& nodes)
{
int x = 0;
int y = 0;
int offset = 150;
for(unsigned int i = 0; i < nodes.size(); i++)
{
nodes[i].position = Vec2i(x, y);
if(x > 0)
{
y += offset;
x = 0;
}
else
{
x += offset;
}
}
}
void GraphLayouter::layoutSimpleRing(std::vector<DummyNode>& nodes)
{
if(nodes.size() >= 1)
{
nodes[0].position = Vec2i(0, 0);
if(nodes.size() > 1)
{
int offset = 150;
for(unsigned int i = 1; i < nodes.size(); i++)
{
float rad = ((2.0f*3.14159265359f) / float(nodes.size()-1)) * i-1;
int x = (int)((float)offset * std::cos(rad));
int y = (int)((float)offset * std::sin(rad));
nodes[i].position = Vec2i(x, y);
}
}
}
}