xlabels.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 <stddef.h>
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include <geom.h>
  16. typedef struct {
  17. pointf sz; /* Size of label (input) */
  18. pointf pos; /* Position of lower-left corner of label (output) */
  19. void *lbl; /* Pointer to label in the graph */
  20. unsigned char set; /* True if the position has been set (input/output) */
  21. } xlabel_t;
  22. typedef struct {
  23. pointf pos; /* Position of lower-left corner of object */
  24. pointf sz; /* Size of object; may be zero for a point */
  25. xlabel_t *lbl; /* Label attached to object, or NULL */
  26. } object_t;
  27. typedef struct {
  28. boxf bb; /* Bounding box of all objects */
  29. unsigned char force; /* If true, all labels must be placed */
  30. } label_params_t;
  31. int placeLabels(object_t *objs, size_t n_objs, xlabel_t *lbls, size_t n_lbls,
  32. label_params_t *params);
  33. #ifdef XLABEL_INT
  34. #include <label/index.h>
  35. #include <cdt.h>
  36. #ifndef XLXDENOM
  37. #define XLXDENOM 8
  38. #endif /*XLXDENOM*/
  39. #ifndef XLYDENOM
  40. #define XLYDENOM 2
  41. #endif /*XLYDENOM*/
  42. #define XLNBR 9
  43. // indexes of neighbors in certain arrays
  44. // the node of interest is usually in node 4
  45. // 6 7 8
  46. // 3 4 5
  47. // 0 1 2
  48. #define XLPXPY 0
  49. #define XLCXPY 1
  50. #define XLNXPY 2
  51. #define XLPXCY 3
  52. #define XLCXCY 4
  53. #define XLNXCY 5
  54. #define XLPXNY 6
  55. #define XLCXNY 7
  56. #define XLNXNY 8
  57. typedef struct best_p_s {
  58. int n;
  59. double area;
  60. pointf pos;
  61. } BestPos_t;
  62. typedef struct obyh {
  63. Dtlink_t link;
  64. int key;
  65. Leaf_t d;
  66. } HDict_t;
  67. typedef struct XLabels_s {
  68. object_t *objs;
  69. size_t n_objs;
  70. xlabel_t *lbls;
  71. size_t n_lbls;
  72. label_params_t *params;
  73. Dt_t *hdx; // splay tree keyed with hilbert spatial codes
  74. RTree_t *spdx; // rtree
  75. } XLabels_t;
  76. #endif /* XLABEL_INT */
  77. #ifdef __cplusplus
  78. }
  79. #endif