Skip to content
Stefanie Alfonso edited this page Apr 23, 2015 · 9 revisions

*Note: The following is documentation for a feature that is not finished being implemented and is not pushed to the main branch

##Creating a mark (node):

ForceGraphNode(Shape* anchorShape, Shape* nodeShape, const Geodetic3D &position);

anchorShape: Shape used to draw this node if it is ever set as an anchor nodeShape: Shape used to draw this node if it is ever set as a non-anchor position: Geodetic3D position where the node will be drawn if it is an anchor. Non-anchor nodes will have a different calculated position based off of their anchors and neighbors.

##Creating the graph - anchors and neighbors

Sets the node’s anchor. A node may only have one anchor at a time. Calling addAnchor will override the previous anchor.

ForceGraphNode::addAnchor(ForceGraphNode anchor);

Adds to a node’s list of neighbors. A node may have any number of neighbors. This is equivalent to adding outgoing edges.

ForceGraphNode::addNeighbor(ForceGraphNode* neighbor);

##Creating a Renderer

ForceGraphRenderer(int maxVisibleMarks);

maxVisibleMarks (optional): how many marks should be displayed at one time at most

##Adding Marks to the Renderer

Just as for every other type of mark, you have to add each mark to a renderer for them to display. void ForceGraphRenderer::addMark(ForceGraphNode* mark);

mark: mark to add to the renderer. Only marks added to the renderer will be renderered

##Adding Renderer to Builder

Lastly, you have to add the renderer to your builder so that it actually gets called.

void addRenderer(Renderer* renderer);

renderer: Renderer, such as ForceGraphRenderer, to be added to the builder


##Example:

//create some spheres:
Shape* sphere = new EllipsoidShape(new Geodetic3D(Angle::fromDegrees(0),
                                                  Angle::fromDegrees(0),
                                                  40),
                                   ABSOLUTE,
                                   Vector3D(100000, 100000, 100000),
                                   16,
                                   0,
                                   false,
                                   false,
                                   Color::fromRGBA(1, 0, 0, .9));

    Shape* anchor_sphere = new EllipsoidShape(new Geodetic3D(Angle::fromDegrees(0),
                                                         Angle::fromDegrees(0),
                                                         40),
                                          ABSOLUTE,
                                          Vector3D(100000, 100000, 100000),
                                          16,
                                          0,
                                          false,
                                          false,
                                          Color::fromRGBA(0, 1, 0, .9));
//Create marks - an anchor and a node
ForceGraphNode *anchor = new ForceGraphNode(anchor_sphere, sphere, Geodetic3D::fromDegrees(0, 0, 2));
ForceGraphNode *node = new ForceGraphNode(sphere, anchor_sphere, Geodetic3D::fromDegrees(4, 0, 2));

//add anchor to node
node->addAnchor(anchor);
//create renderer
ForceGraphRenderer *forceGraphRenderer = new ForceGraphRenderer();
//add marks to renderer
forceGraphRenderer->addMark(node);
forceGraphRenderer->addMark(anchor);

//add to builder
builder.addRenderer(forceGraphRenderer);

Clone this wiki locally