]> granicus.if.org Git - graphviz/commitdiff
Fix some small errors in outputs;
authorerg <devnull@localhost>
Wed, 8 Oct 2008 18:30:25 +0000 (18:30 +0000)
committererg <devnull@localhost>
Wed, 8 Oct 2008 18:30:25 +0000 (18:30 +0000)
add more detail on adding a plugin

doc/addingLayout.txt
doc/info/output.html
doc/infosrc/outputs

index 777b132352bb3ef8b3da23eab0c0e12cde5b86a0..2f14fdb95bdaf8c7ad3275d25cd9e6aeacdf3a5a 100644 (file)
@@ -1,6 +1,6 @@
-New layout: xxx
-
-Entry points: 
+To create a new layout plugin called xxx, you first need
+to provide two functions: xxx_layout and xxx_cleanup. The
+semantics of these are described below.
 
 ========================
 
@@ -28,8 +28,26 @@ Entry points:
 
     Layout the graph. When finished, each node should have its coordinates
   stored in points in ND_coord_i(n), each edge should have its layout
-  described in ED_spl(e). Note: If spline_edges() is used, the coordinates
-  in ND_pos will be correctly copied into ND_coord_i.
+  described in ED_spl(e). 
+  (N.B. As of version 2.21, ND_coord_i has been replaced by ND_coord,
+  which are now floating point coordinates.)
+
+    To add edges, there are 3 functions available:
+
+      - spline_edges1 (Agraph_t*, int edgeType)
+          Assumes the node coordinates are stored in ND_coord_i, and that
+        GD_bb is set. For each edge, this function constructs the appropriate 
+        data and stores it in ED_spl.
+      - spline_edges0 (Agraph_t*)
+          Assumes the node coordinates are stored in ND_pos, and that
+        GD_bb is set. This function uses the ratio attribute if set, 
+        copies the values in ND_pos to ND_coord_i (converting from 
+        inches to points); and calls spline_edges1 using the edge type
+        specified by setEdgeType().
+      - spline_edges (Agraph_t*)
+          Assumes the node coordinates are stored in ND_pos. This
+        function calculates the bounding box of g and stores it in GD_bb,
+        then calls spline_edges0().
 
     If the algorithm only works with connected components, the code can
   use the pack library to get components, lay them out individually, and
@@ -85,6 +103,48 @@ Entry points:
 
        dotneato_postprocess(g);
 
+  The following template will work in most cases, ignoring the problems of
+  handling disconnected graphs and removing node overlaps:
+
+  static void
+  xxx_init_node(node_t * n)
+  {
+    neato_init_node(n);
+    /* add algorithm-specific data, if desired */
+  }
+
+  static void
+  xxx_init_edge(edge_t * e)
+  {
+    common_init_edge(e);
+    /* add algorithm-specific data, if desired */
+  }
+
+  static void
+  xxx_init_node_edge(graph_t * g)
+  {
+    node_t *n;
+    edge_t *e;
+
+    for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
+        xxx_init_node(n);
+    }
+    for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
+        for (e = agfstout(g, n); e; e = agnxtout(g, e)){          
+            xxx_init_edge(e);
+        }
+    }
+  }
+
+  void
+  xxx_layout (Agraph_t* g)
+  {
+    xxx_init_node_edge(g);
+    /* Set ND_pos(n) for each node n */
+    spline_edges(g);
+    dotneato_postprocess(g);
+  }  
+
 ======================
 
   void xxx_cleanup(Agraph_t * g)
@@ -102,6 +162,40 @@ Entry points:
   libgvc does a final cleanup to the root graph, freeing any drawing,
   freeing its label, and zeroing out Agraphinfo_t of the root graph.
 
+  The following template will work in most cases:
+
+  static void xxx_cleanup_graph(Agraph_t * g)
+  {
+    /* Free any algorithm-specific data attached to the graph */
+    if (g != g->root) memset(&(g->u), 0, sizeof(Agraphinfo_t));
+  }
+
+  static void xxx_cleanup_edge (Agedge_t* e)
+  {
+    /* Free any algorithm-specific data attached to the edge */
+    gv_cleanup_edge(e);
+  }
+
+  static void xxx_cleanup_node (Agnode_t* n)
+  {
+    /* Free any algorithm-specific data attached to the node */
+    gv_cleanup_node(e);
+  }
+
+  void xxx_cleanup(Agraph_t * g)
+  {
+    Agnode_t *n;
+    Agedge_t *e;
+
+    for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
+        for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
+            xxx_cleanup_edge(e);
+        }
+        xxx_cleanup_node(n);
+    }
+    xxx_cleanup_graph(g);
+  }   
+
 ==================
 
 Most layouts use auxiliary routines similar to neato, so
index ffb10483102edf9fd695a9e1f624d583f53d4a12..9fdd7fa723a93a6b5ae12f75335606e5979fb563 100644 (file)
@@ -154,8 +154,8 @@ suggestions for better representations are welcome.
 To allow for changes in the format, Graphviz attaches the attribute
 <TT>xdotversion</TT> to the graph.
 <P>
-At present, additional drawing attributes are only attached to nodes
-and edges. There are six new attributes:
+Additional drawing attributes can appear on nodes, edges, clusters and 
+on the graph itself. There are six new attributes: 
 <SPACER TYPE=VERTICAL size=10>
 <TABLE  border bgcolor=beige>
 <TR><TD>_draw_<TD colspan=2>Drawing operations
@@ -166,8 +166,12 @@ and edges. There are six new attributes:
 <TR><TD>_tldraw_<TD>Tail label<TD>Edge only
 </TABLE>
 <P>
+For a given graph object, one will typically a draw directive before the
+label directive. For example, for a node, one would first use the commands
+in <B>_draw_</B> followed by the commands in <B>_ldraw_</B>.
+<P>
 The value of these attributes consists of the concatenation of some
-(multi-)set of the following 12 rendering or attribute operations.
+(multi-)set of the following 13 rendering or attribute operations.
 (The number is parentheses gives the xdot version when the operation
 was added to the format. If no version number is given, the operation
 was in the original specification.)
index f8162e21be31b46b88c2bd1aff39ac5df209a469..b64b999215b68739f494a253148c3d6bfff93225 100644 (file)
@@ -192,8 +192,8 @@ suggestions for better representations are welcome.
 To allow for changes in the format, Graphviz attaches the attribute
 <TT>xdotversion</TT> to the graph.
 <P>
-At present, additional drawing attributes are only attached to nodes
-and edges. There are six new attributes:
+Additional drawing attributes can appear on nodes, edges, clusters and 
+on the graph itself. There are six new attributes: 
 <SPACER TYPE=VERTICAL size=10>
 <TABLE  border bgcolor=beige>
 <TR><TD>_draw_<TD colspan=2>Drawing operations
@@ -204,8 +204,12 @@ and edges. There are six new attributes:
 <TR><TD>_tldraw_<TD>Tail label<TD>Edge only
 </TABLE>
 <P>
+For a given graph object, one will typically a draw directive before the
+label directive. For example, for a node, one would first use the commands
+in <B>_draw_</B> followed by the commands in <B>_ldraw_</B>.
+<P>
 The value of these attributes consists of the concatenation of some
-(multi-)set of the following 12 rendering or attribute operations.
+(multi-)set of the following 13 rendering or attribute operations.
 (The number is parentheses gives the xdot version when the operation
 was added to the format. If no version number is given, the operation
 was in the original specification.)