This abstract class is used for drawing a graph. You don't have to derive a new class, but if you do provide SetNodeX and SetNodeY members, these will automatically be called to position your nodes. If you do not derive a new class and override these members, you need to call GetNodeX and GetNodeY for each node after the call to DoLayout.
Nodes are identified by long integer identifiers. The application should call AddNode and AddArc to register the nodes and arcs with wxGraphLayout, before calling DoLayout to do the graph layout. Depending on how the derived class has been defined, either wxGraphLayout::Draw must be called (for example by the OnDraw member of a wxCanvas) or the application-defined drawing code should be called as normal.
For example, if you have an image drawing system already defined, you may want wxGraphLayout to position existing node images in that system. So you just need a way for wxGraphLayout to set the node image positions according to the layout algorithm, and the rest will be done by your own image drawing system.
wxGraphLayout::wxGraphLayout
wxGraphLayout::ActivateNode
wxGraphLayout::AddArc
wxGraphLayout::AddNode
wxGraphLayout::Clear
wxGraphLayout::DoLayout
wxGraphLayout::Draw
wxGraphLayout::DrawArc
wxGraphLayout::DrawArcs
wxGraphLayout::DrawNode
wxGraphLayout::DrawNodes
wxGraphLayout::GetDC
wxGraphLayout::GetNextNode
wxGraphLayout::GetNodeSize
wxGraphLayout::GetNodeX
wxGraphLayout::GetNodeY
wxGraphLayout::GetLeftMargin
wxGraphLayout::GetRotation
wxGraphLayout::GetTopMargin
wxGraphLayout::GetXSpacing
wxGraphLayout::GetYSpacing
wxGraphLayout::Initialize
wxGraphLayout::CalcLayout
wxGraphLayout::NodeActive
wxGraphLayout::SetBoundingBox
wxGraphLayout::SetDC
wxGraphLayout::SetNodeName
wxGraphLayout::SetNodeX
wxGraphLayout::SetNodeY
wxGraphLayout::SetRotation
wxGraphLayout::SetSpacing
wxGraphLayout::SetMargins
void wxGraphLayout(wxDC *dc = NULL)
Constructor. dc is an optional device context for the class to draw the graph into.
void ActivateNode(long id, Bool active)
Call this to turn off nodes in the graph (not implemented yet). See also NodeActive.
void AddArc(long id, long fromId, long toId, char *name = NULL)
Call this to add an arc to the graph, with optional name to display.
void AddNode(long id, char *name = NULL)
Call this to add a node to the graph, with optional name to display.
void Clear(void)
Clears the graph so another graph may be defined and laid out.
void DoLayout(void)
Calculates the layout for the graph.
void Draw(void)
Call this to let wxGraphLayout draw the graph itself, once the layout has been calculated with DoLayout. The device context must have been set in the constructor or using SetDC.
void DrawArc(long from, long to)
Defined by wxGraphLayout to draw an arc between two nodes.
void DrawArcs(void)
Defined by wxGraphLayout to draw the arcs between nodes.
void DrawNode(long id)
Defined by wxGraphLayout to draw a node.
void DrawNodes(void)
Defined by wxGraphLayout to draw the nodes.
long GetDC(void)
Gets the (optional) device context associated with the graph.
long GetNextNode(long id)
Must be defined to return the next node after id, so that wxGraphLayout can iterate through all relevant nodes. The ordering is not important. The function should return -1 if there are no more nodes.
void GetNodeSize(long id, float *x, float *y)
Can be defined to indicate a node's size, or left to wxGraphLayout to use the name as an indication of size.
float GetNodeX(long id)
Must be defined to return the current X position of the node. Note that coordinates are assumed to be at the top-left of the node so some conversion may be necessary for your application.
float GetNodeY(long id)
Must be defined to return the current Y position of the node. Note that coordinates are assumed to be at the top-left of the node so some conversion may be necessary for your application.
float GetLeftMargin(void)
Gets the left margin set with SetMargins.
int GetRotation(void)
Get the rotation factor.
float GetTopMargin(void)
Gets the top margin set with SetMargins.
float GetXSpacing(void)
Gets the horizontal spacing between nodes.
float GetYSpacing(void)
Gets the vertical spacing between nodes.
void Initialize(void)
Initializes wxGraphLayout. Call from application or overridden Initialize or constructor.
void CalcLayout(long node_id, int level)
Private function for laying out a branch.
Bool NodeActive(long id)
Define this so wxGraphLayout can know which nodes are to be drawn (not all nodes may be connected in the graph). See also ActivateNode.
void SetBoundingBox(float x1, float y1, float x2, float y2)
Sets the size of the bounding box to which the graph will be scaled. Pass the top left corner and bottom right corner.
void SetDC(wxDC *dc)
Use this to set the graph's device context, if leaving the drawing up to wxGraphLayout.
void SetNodeName(long id, char * name)
May optionally be defined to set a node's name.
void SetNodeX(long id, float x)
Must be defined to set the current X position of the node. Note that coordinates are assumed to be at the top-left of the node so some conversion may be necessary for your application.
void SetNodeY(long id, float y)
Must be defined to set the current Y position of the node. Note that coordinates are assumed to be at the top-left of the node so some conversion may be necessary for your application.
void SetRotation(int rot)
Set the rotation factor (multipled by 90 degrees by wxGraphLayout).
void SetSpacing(float x, float y)
Sets the horizontal and vertical spacing between nodes in the graph.
void SetMargins(float x, float y)
Sets the left and top margins of the whole graph.