gvc.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /**
  2. * @file
  3. * @brief Graphviz context library
  4. * @ingroup gvc_api
  5. *
  6. * **libgvc** provides a context for applications wishing to manipulate
  7. * and render graphs. It provides command line parsing,
  8. * common rendering code, and a plugin mechanism for renderers.
  9. *
  10. * [man 3 gvc](https://graphviz.org/pdf/gvc.3.pdf)
  11. *
  12. */
  13. /*************************************************************************
  14. * Copyright (c) 2011 AT&T Intellectual Property
  15. * All rights reserved. This program and the accompanying materials
  16. * are made available under the terms of the Eclipse Public License v1.0
  17. * which accompanies this distribution, and is available at
  18. * https://www.eclipse.org/legal/epl-v10.html
  19. *
  20. * Contributors: Details at https://graphviz.org
  21. *************************************************************************/
  22. #pragma once
  23. #include <stdbool.h>
  24. #include "types.h"
  25. #include "gvplugin.h"
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #ifdef GVDLL
  30. #ifdef GVC_EXPORTS
  31. #define GVC_API __declspec(dllexport)
  32. #else
  33. #define GVC_API __declspec(dllimport)
  34. #endif
  35. #endif
  36. #ifndef GVC_API
  37. #define GVC_API /* nothing */
  38. #endif
  39. /// @defgroup gvc_api Graphviz context library (GVC) API
  40. /// @ingroup public_apis
  41. /// @{
  42. #define LAYOUT_DONE(g) (agbindrec(g, "Agraphinfo_t", 0, true) && GD_drawing(g))
  43. /* misc */
  44. /* FIXME - this needs eliminating or renaming */
  45. GVC_API void gvToggle(int);
  46. /* set up a graphviz context */
  47. GVC_API GVC_t *gvNEWcontext(const lt_symlist_t *builtins, int demand_loading);
  48. /* set up a graphviz context - and init graph - retaining old API */
  49. GVC_API GVC_t *gvContext(void);
  50. /* set up a graphviz context - and init graph - with builtins */
  51. GVC_API GVC_t *gvContextPlugins(const lt_symlist_t *builtins, int demand_loading);
  52. /* get information associated with a graphviz context */
  53. GVC_API char **gvcInfo(GVC_t*);
  54. GVC_API char *gvcVersion(GVC_t*);
  55. GVC_API char *gvcBuildDate(GVC_t*);
  56. /* parse command line args - minimally argv[0] sets layout engine */
  57. GVC_API int gvParseArgs(GVC_t *gvc, int argc, char **argv);
  58. GVC_API graph_t *gvNextInputGraph(GVC_t *gvc);
  59. GVC_API graph_t *gvPluginsGraph(GVC_t *gvc);
  60. /* Compute a layout using a specified engine */
  61. GVC_API int gvLayout(GVC_t *gvc, graph_t *g, const char *engine);
  62. /* Compute a layout using layout engine from command line args */
  63. GVC_API int gvLayoutJobs(GVC_t *gvc, graph_t *g);
  64. /* Check if a layout has been done */
  65. GVC_API bool gvLayoutDone(graph_t *g);
  66. /* Render layout into string attributes of the graph */
  67. GVC_API void attach_attrs(graph_t *g);
  68. /* Render layout in a specified format to an open FILE */
  69. GVC_API int gvRender(GVC_t *gvc, graph_t *g, const char *format, FILE *out);
  70. /* Render layout in a specified format to a file with the given name */
  71. GVC_API int gvRenderFilename(GVC_t *gvc, graph_t *g, const char *format, const char *filename);
  72. /* Render layout in a specified format to an GVC_APIal context */
  73. GVC_API int gvRenderContext(GVC_t *gvc, graph_t *g, const char *format, void *context);
  74. /* Render layout in a specified format to a malloc'ed string */
  75. GVC_API int gvRenderData(GVC_t *gvc, graph_t *g, const char *format, char **result, unsigned int *length);
  76. /* Free memory allocated and pointed to by *result in gvRenderData */
  77. GVC_API void gvFreeRenderData (char* data);
  78. /* Render layout according to -T and -o options found by gvParseArgs */
  79. GVC_API int gvRenderJobs(GVC_t *gvc, graph_t *g);
  80. /* Clean up layout data structures - layouts are not nestable (yet) */
  81. GVC_API int gvFreeLayout(GVC_t *gvc, graph_t *g);
  82. /* Clean up graphviz context */
  83. GVC_API void gvFinalize(GVC_t *gvc);
  84. GVC_API int gvFreeContext(GVC_t *gvc);
  85. /* Return list of plugins of type kind.
  86. * kind would normally be "render" "layout" "textlayout" "device" "loadimage"
  87. * The size of the list is stored in sz.
  88. * The caller is responsible for freeing the storage. This involves
  89. * freeing each item, then the list.
  90. * Returns NULL on error, or if there are no plugins.
  91. * In the former case, sz is unchanged; in the latter, sz = 0.
  92. */
  93. GVC_API char **gvPluginList(GVC_t *gvc, const char *kind, int *sz);
  94. /** Add a library from your user application
  95. * @param gvc Graphviz context to add library to
  96. * @param lib library to add
  97. */
  98. GVC_API void gvAddLibrary(GVC_t *gvc, gvplugin_library_t *lib);
  99. /** Perform a Transitive Reduction on a graph
  100. * @param g graph to be transformed.
  101. */
  102. GVC_API int gvToolTred(graph_t *g);
  103. /// @}
  104. #undef GVC_API
  105. #ifdef __cplusplus
  106. }
  107. #endif