fdp.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*************************************************************************
  2. * Copyright (c) 2011 AT&T Intellectual Property
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: Details at https://graphviz.org
  9. *************************************************************************/
  10. #pragma once
  11. #include <common/render.h>
  12. #ifdef FDP_PRIVATE
  13. #define NDIM 2
  14. typedef struct bport_s {
  15. edge_t *e;
  16. node_t *n;
  17. double alpha;
  18. } bport_t;
  19. /* gdata is attached to the root graph, each cluster graph,
  20. * and to each derived graph.
  21. * Graphs also use "builtin" fields:
  22. * n_cluster, clust - to record clusters
  23. */
  24. typedef struct {
  25. bport_t *ports; /* boundary ports. 0-terminated */
  26. int nports; /* no. of ports */
  27. boxf bb; /* bounding box of graph */
  28. int flags;
  29. int level; /* depth in graph hierarchy */
  30. graph_t *parent; /* smallest containing cluster */
  31. #ifdef DEBUG
  32. graph_t *orig; /* original of derived graph */
  33. #endif
  34. } gdata;
  35. #define GDATA(g) ((gdata*)(GD_alg(g)))
  36. #define BB(g) (GDATA(g)->bb)
  37. #define PORTS(g) (GDATA(g)->ports)
  38. #define NPORTS(g) (GDATA(g)->nports)
  39. #define LEVEL(g) (GDATA(g)->level)
  40. #define GPARENT(g) (GDATA(g)->parent)
  41. #ifdef DEBUG
  42. #define GORIG(g) (GDATA(g)->orig)
  43. #endif
  44. /*
  45. * Real nodes use "builtin" fields:
  46. * ND_pos - position information
  47. * ND_width,ND_height - node dimensions
  48. * ND_pinned
  49. * ND_lw,ND_rw,ND_ht - node dimensions in points
  50. * ND_id
  51. * ND_shape, ND_shape_info
  52. *
  53. * In addition, we use two of the dot fields for parent and derived node.
  54. * Previously, we attached these via ND_alg, but ND_alg may be needed for
  55. * spline routing, and splines=compound also requires the parent field.
  56. */
  57. #define DNODE(n) (ND_next(n))
  58. #define PARENT(n) (ND_clust(n))
  59. /* dndata is attached to nodes in derived graphs.
  60. * Derived nodes also use "builtin" fields:
  61. * clust - for cluster nodes, points to cluster in real graph.
  62. * pos - position information
  63. * width,height - node dimensions
  64. */
  65. typedef struct {
  66. int deg; /* degree of node */
  67. int wdeg; /* weighted degree of node */
  68. node_t *dn; /* If derived node is not a cluster, */
  69. /* dn points real node. */
  70. double disp[NDIM]; /* incremental displacement */
  71. } dndata;
  72. #define DNDATA(n) ((dndata*)(ND_alg(n)))
  73. #define DISP(n) (DNDATA(n)->disp)
  74. #define ANODE(n) (DNDATA(n)->dn)
  75. #define DEG(n) (DNDATA(n)->deg)
  76. #define WDEG(n) (DNDATA(n)->wdeg)
  77. #define IS_PORT(n) (!ANODE(n) && !ND_clust(n))
  78. #endif /* FDP_PRIVATE */
  79. #ifdef __cplusplus
  80. extern "C" {
  81. #endif
  82. struct fdpParms_s {
  83. int useGrid; /* use grid for speed up */
  84. int useNew; /* encode x-K into attractive force */
  85. int numIters; /* actual iterations in layout */
  86. int unscaled; /* % of iterations used in pass 1 */
  87. double C; /* Repulsion factor in xLayout */
  88. double Tfact; /* scale temp from default expression */
  89. double K; /* spring constant; ideal distance */
  90. double T0; /* initial temperature */
  91. };
  92. typedef struct fdpParms_s fdpParms_t;
  93. extern void fdp_layout(Agraph_t * g);
  94. extern void fdp_init_node_edge(Agraph_t * g);
  95. extern void fdp_cleanup(Agraph_t * g);
  96. #ifdef __cplusplus
  97. }
  98. #endif