\hy-9{0}{
}



\hy-5{2}{Manual for wxGraphLayout 1.0: a graph layout library for wxWindows}

\hy-6{3}{Julian Smart
Artificial Intelligence Applications Institute

University of Edinburgh
EH1 1HN}

November 1993






\hy-5{1}{Contents}

\hy-6{4}{Copyright notice}

\hy-6{6}{Introduction}

\hy-6{9}{wxGraphLayout Class Reference}


\hy-10{5}{Copyright notice}




Copyright (c) 1993 Artificial Intelligence Applications Institute,
The University of Edinburgh.

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose is hereby granted without fee, provided that the
above copyright notice, author statement and this permission notice appear in
all copies of this software and related documentation.

THE SOFTWARE IS PROVIDED ``AS-IS'' AND WITHOUT WARRANTY OF ANY KIND, EXPRESS,
IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

IN NO EVENT SHALL THE ARTIFICIAL INTELLIGENCE APPLICATIONS INSTITUTE OR THE
UNIVERSITY OF EDINBURGH BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF
DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.

`Graphplace', the basis for this class library, is copyright Dr. Jos
T.J. van Eijndhoven of Eindhoven University of Technology. The code has
been used in wxGraphLayout with his permission.


\hy-10{7}{Introduction}




This manual describes a graph layout class library for wxWindows. It is
an encapsulation of the main code from Jos van Eijndhoven's graphplace
tool which he has distributed to the net.

Below is the example graph generated by the program test.cc.


11cm;0cmgraphtst.ps
Figure 1.1: Example graph



Sorry, the documentation for wxGraphLayout is sparse at present, but
see the class reference and the test program. Here is the message from Jos
introducing his original graphplace tool:

\hy-7{8}{
We are using in our group a locally developed graph placement and drawing
program, which was noticed as being very nice by several visitors.
The program was made as general applicable tool,
and indeed quickly gained use in several very different applications.
Therefore we decided to make it available to all of you...

In general it will try to find a placement with 'short' edges, and in a
'breath-first-search' (sorted on level) order. The program works for any
graph (also cyclic or not fully connected). The placement algorithm is a
very fast linear-time heuristic, which often gives surprisingly nice
results.

If you are interested, you can fetch the program from 'ftp.es.ele.tue.nl'
as 'pub/down/graphplace.tar.Z'.
}


\hy-10{10}{wxGraphLayout Class Reference}




The member functions are given in alphabetical order except for the
constructors and destructors which appear first.

\hy-8{11}{wxGraphLayout: wxObject}


\hy-10{12}{wxGraphLayout: wxObject}



This abstract class is used for drawing a graph. You don't have to derive
a new class, but if you do provide \hy-13{13}{SetNodeX} and \hy-13{14}{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 \hy-13{15}{GetNodeX}
and \hy-13{16}{GetNodeY} for each node after the call to \hy-13{17}{DoLayout}.

Nodes are identified by long integer identifiers. The application should
call \hy-13{18}{AddNode} and \hy-13{19}{AddArc} to register
the nodes and arcs with wxGraphLayout, before calling
\hy-13{20}{DoLayout} to do the graph layout. Depending on how
the derived class has been defined, either
\hy-13{21}{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.

\hy-8{22}{wxGraphLayout::wxGraphLayout}

\hy-8{27}{wxGraphLayout::ActivateNode}

\hy-8{33}{wxGraphLayout::AddArc}

\hy-8{40}{wxGraphLayout::AddNode}

\hy-8{45}{wxGraphLayout::Clear}

\hy-8{48}{wxGraphLayout::DoLayout}

\hy-8{51}{wxGraphLayout::Draw}

\hy-8{56}{wxGraphLayout::DrawArc}

\hy-8{61}{wxGraphLayout::DrawArcs}

\hy-8{64}{wxGraphLayout::DrawNode}

\hy-8{68}{wxGraphLayout::DrawNodes}

\hy-8{71}{wxGraphLayout::GetDC}

\hy-8{74}{wxGraphLayout::GetNextNode}

\hy-8{79}{wxGraphLayout::GetNodeSize}

\hy-8{85}{wxGraphLayout::GetNodeX}

\hy-8{89}{wxGraphLayout::GetNodeY}

\hy-8{93}{wxGraphLayout::GetLeftMargin}

\hy-8{97}{wxGraphLayout::GetRotation}

\hy-8{100}{wxGraphLayout::GetTopMargin}

\hy-8{104}{wxGraphLayout::GetXSpacing}

\hy-8{107}{wxGraphLayout::GetYSpacing}

\hy-8{110}{wxGraphLayout::Initialize}

\hy-8{114}{wxGraphLayout::CalcLayout}

\hy-8{119}{wxGraphLayout::NodeActive}

\hy-8{124}{wxGraphLayout::SetBoundingBox}

\hy-8{131}{wxGraphLayout::SetDC}

\hy-8{135}{wxGraphLayout::SetNodeName}

\hy-8{140}{wxGraphLayout::SetNodeX}

\hy-8{145}{wxGraphLayout::SetNodeY}

\hy-8{150}{wxGraphLayout::SetRotation}

\hy-8{154}{wxGraphLayout::SetSpacing}

\hy-8{159}{wxGraphLayout::SetMargins}


\hy-10{23}{wxGraphLayout::wxGraphLayout}



\hy-8{24}{void wxGraphLayout(wxDC * \hy-8{25}{dc = NULL})}

Constructor. \hy-7{26}{dc} is an optional device context for the class
to draw the graph into.


\hy-10{28}{wxGraphLayout::ActivateNode}



\hy-8{29}{void ActivateNode(long \hy-8{30}{ id}, Bool  \hy-8{31}{active})}

Call this to turn off nodes in the graph (not implemented yet).
See also \hy-13{32}{NodeActive}.


\hy-10{34}{wxGraphLayout::AddArc}



\hy-8{35}{void AddArc(long \hy-8{36}{ id}, long \hy-8{37}{ fromId}, long \hy-8{38}{ toId},
char * \hy-8{39}{name = NULL})}

Call this to add an arc to the graph, with optional name to display.


\hy-10{41}{wxGraphLayout::AddNode}



\hy-8{42}{void AddNode(long \hy-8{43}{ id}, char * \hy-8{44}{name = NULL})}

Call this to add a node to the graph, with optional name to display.


\hy-10{46}{wxGraphLayout::Clear}



\hy-8{47}{void Clear(void)}

Clears the graph so another graph may be defined and laid out.


\hy-10{49}{wxGraphLayout::DoLayout}



\hy-8{50}{void DoLayout(void)}

Calculates the layout for the graph.


\hy-10{52}{wxGraphLayout::Draw}



\hy-8{53}{void Draw(void)}

Call this to let wxGraphLayout draw the graph itself, once the layout has been
calculated with \hy-13{54}{DoLayout}. The device context must
have been set in the constructor or using \hy-13{55}{SetDC}.


\hy-10{57}{wxGraphLayout::DrawArc}



\hy-8{58}{void DrawArc(long \hy-8{59}{ from}, long \hy-8{60}{ to})}

Defined by wxGraphLayout to draw an arc between two nodes.


\hy-10{62}{wxGraphLayout::DrawArcs}



\hy-8{63}{void DrawArcs(void)}

Defined by wxGraphLayout to draw the arcs between nodes.


\hy-10{65}{wxGraphLayout::DrawNode}



\hy-8{66}{void DrawNode(long \hy-8{67}{ id})}

Defined by wxGraphLayout to draw a node.


\hy-10{69}{wxGraphLayout::DrawNodes}



\hy-8{70}{void DrawNodes(void)}

Defined by wxGraphLayout to draw the nodes.


\hy-10{72}{wxGraphLayout::GetDC}



\hy-8{73}{long GetDC(void)}

Gets the (optional) device context associated with the graph.


\hy-10{75}{wxGraphLayout::GetNextNode}



\hy-8{76}{long GetNextNode(long \hy-8{77}{ id})}

Must be defined to return the next node after \hy-7{78}{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.


\hy-10{80}{wxGraphLayout::GetNodeSize}



\hy-8{81}{void GetNodeSize(long \hy-8{82}{ id}, float \hy-8{83}{ *x}, float \hy-8{84}{ *y})}

Can be defined to indicate a node's size, or left to wxGraphLayout to use the
name as an indication of size.


\hy-10{86}{wxGraphLayout::GetNodeX}



\hy-8{87}{float GetNodeX(long \hy-8{88}{ 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.


\hy-10{90}{wxGraphLayout::GetNodeY}



\hy-8{91}{float GetNodeY(long \hy-8{92}{ 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.


\hy-10{94}{wxGraphLayout::GetLeftMargin}



\hy-8{95}{float GetLeftMargin(void)}

Gets the left margin set with \hy-13{96}{SetMargins}.


\hy-10{98}{wxGraphLayout::GetRotation}



\hy-8{99}{int GetRotation(void)}

Get the rotation factor.


\hy-10{101}{wxGraphLayout::GetTopMargin}



\hy-8{102}{float GetTopMargin(void)}

Gets the top margin set with \hy-13{103}{SetMargins}.


\hy-10{105}{wxGraphLayout::GetXSpacing}



\hy-8{106}{float GetXSpacing(void)}

Gets the horizontal spacing between nodes.


\hy-10{108}{wxGraphLayout::GetYSpacing}



\hy-8{109}{float GetYSpacing(void)}

Gets the vertical spacing between nodes.


\hy-10{111}{wxGraphLayout::Initialize}



\hy-8{112}{void Initialize(void)}

Initializes wxGraphLayout. Call from application or overridden \hy-8{113}{Initialize}
or constructor.


\hy-10{115}{wxGraphLayout::CalcLayout}



\hy-8{116}{void CalcLayout(long \hy-8{117}{ node_id}, int \hy-8{118}{ level})}

Private function for laying out a branch.


\hy-10{120}{wxGraphLayout::NodeActive}



\hy-8{121}{Bool NodeActive(long \hy-8{122}{ id})}

Define this so wxGraphLayout can know which nodes are to be drawn (not all
nodes may be connected in the graph). See also \hy-13{123}{ActivateNode}.


\hy-10{125}{wxGraphLayout::SetBoundingBox}



\hy-8{126}{void SetBoundingBox(float \hy-8{127}{ x1}, float \hy-8{128}{ y1}, float \hy-8{129}{ x2}, float \hy-8{130}{ y2})}

Sets the size of the bounding box to which the graph will be scaled. Pass the
top left corner and bottom right corner.


\hy-10{132}{wxGraphLayout::SetDC}



\hy-8{133}{void SetDC(wxDC * \hy-8{134}{dc})}

Use this to set the graph's device context, if leaving the drawing up
to wxGraphLayout.


\hy-10{136}{wxGraphLayout::SetNodeName}



\hy-8{137}{void SetNodeName(long \hy-8{138}{ id}, char * \hy-8{139}{ name})}

May optionally be defined to set a node's name.


\hy-10{141}{wxGraphLayout::SetNodeX}



\hy-8{142}{void SetNodeX(long \hy-8{143}{ id}, float \hy-8{144}{ 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.


\hy-10{146}{wxGraphLayout::SetNodeY}



\hy-8{147}{void SetNodeY(long \hy-8{148}{ id}, float \hy-8{149}{ 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.


\hy-10{151}{wxGraphLayout::SetRotation}



\hy-8{152}{void SetRotation(int \hy-8{153}{ rot})}

Set the rotation factor (multipled by 90 degrees by wxGraphLayout).


\hy-10{155}{wxGraphLayout::SetSpacing}



\hy-8{156}{void SetSpacing(float \hy-8{157}{ x}, float \hy-8{158}{ y})}

Sets the horizontal and vertical spacing between nodes in the graph.


\hy-10{160}{wxGraphLayout::SetMargins}



\hy-8{161}{void SetMargins(float \hy-8{162}{ x}, float \hy-8{163}{ y})}

Sets the left and top margins of the whole graph.




\hyindex{
"wxGraphLayout Manual"
4 5
6 7
9 10
11 12
22 23
27 28
33 34
40 41
45 46
48 49
51 52
56 57
61 62
64 65
68 69
71 72
74 75
79 80
85 86
89 90
93 94
97 98
100 101
104 105
107 108
110 111
114 115
119 120
124 125
131 132
135 136
140 141
145 146
150 151
154 155
159 160
13 141
14 146
15 86
16 90
17 49
18 41
19 34
20 49
21 52
32 120
54 49
55 132
96 160
103 160
123 28
13 141
14 146
15 86
16 90
17 49
18 41
19 34
20 49
21 52
32 120
54 49
55 132
96 160
103 160
123 28
}
