Graphviz 14.1.6~dev.20260414.0900
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1
3/*************************************************************************
4 * Copyright (c) 2011 AT&T Intellectual Property
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v2.0
7 * which accompanies this distribution, and is available at
8 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
9 *
10 * Contributors: Details at https://graphviz.org
11 *************************************************************************/
12
13#pragma once
14
15#include "config.h"
16
17#include <common/geom.h>
18#include <common/types.h>
19#include <common/usershape.h>
20#include <stdbool.h>
21#include <stddef.h>
22#include <util/agxbuf.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#ifdef GVDLL
29#ifdef GVC_EXPORTS
30#define UTILS_API __declspec(dllexport)
31#else
32#define UTILS_API __declspec(dllimport)
33#endif
34#endif
35
36#ifndef UTILS_API
37#define UTILS_API /* nothing */
38#endif
39
40UTILS_API pointf Bezier(const pointf *, double, pointf *, pointf *);
41
43UTILS_API double attach_attrs_and_arrows(graph_t *, bool *, bool *);
44
45UTILS_API void write_plain(GVJ_t *job, graph_t *g, void *f, bool extend);
46
48UTILS_API double yDir(double y, double yOff);
49
62UTILS_API char *ps_string(char *s, int chset);
63
64UTILS_API char *strdup_and_subst_obj(char *str, void *obj);
65UTILS_API void epsf_emit_body(GVJ_t *job, usershape_t *us);
66UTILS_API void epsf_define(GVJ_t *job);
67UTILS_API void undoClusterEdges(graph_t *g);
68UTILS_API Dt_t *mkClustMap(Agraph_t *g);
69UTILS_API Agraph_t *findCluster(Dt_t *map, char *name);
70UTILS_API attrsym_t *safe_dcl(graph_t *g, int obj_kind, char *name,
71 char *defaultValue);
72
73UTILS_API int late_int(void *obj, Agsym_t *attr, int defaultValue, int minimum);
74UTILS_API double late_double(void *obj, Agsym_t *attr, double defaultValue,
75 double minimum);
76UTILS_API char *late_nnstring(void *obj, Agsym_t *attr, char *defaultValue);
77UTILS_API char *late_string(void *obj, Agsym_t *attr, char *defaultValue);
78UTILS_API bool late_bool(void *obj, Agsym_t *attr, bool defaultValue);
79UTILS_API double get_inputscale(graph_t *g);
80
81// routines for supporting “union-find”, a.k.a. “disjoint-set forest”
82// https://en.wikipedia.org/wiki/Disjoint-set_data_structure
83UTILS_API Agnode_t *UF_find(Agnode_t *);
84UTILS_API Agnode_t *UF_union(Agnode_t *, Agnode_t *);
85UTILS_API void UF_singleton(Agnode_t *);
86UTILS_API void UF_setname(Agnode_t *, Agnode_t *);
87
88UTILS_API const char *safefile(const char *filename);
89
90UTILS_API bool mapBool(const char *p, bool defaultValue);
91UTILS_API bool mapbool(const char *p);
92UTILS_API int maptoken(char *, char **, int *);
93
94UTILS_API bool findStopColor(const char *colorlist, char *clrs[2],
95 double *frac);
96UTILS_API int test_toggle(void);
97
98UTILS_API void common_init_node(node_t *n);
99UTILS_API void common_init_edge(edge_t *e);
100
101UTILS_API void updateBB(graph_t *g, textlabel_t *lp);
102UTILS_API void compute_bb(Agraph_t *);
103UTILS_API boxf polyBB(polygon_t *poly);
104UTILS_API bool overlap_node(node_t *n, boxf b);
105UTILS_API bool overlap_label(textlabel_t *lp, boxf b);
106UTILS_API bool overlap_edge(edge_t *e, boxf b);
107
108UTILS_API void get_gradient_points(pointf *A, pointf *G, size_t n, double angle,
109 int flags);
110
111UTILS_API void processClusterEdges(graph_t *g);
112
113UTILS_API char *latin1ToUTF8(char *);
114UTILS_API char *htmlEntityUTF8(char *, graph_t *g);
115UTILS_API char *utf8ToLatin1(char *ins);
116UTILS_API char *scanEntity(char *t, agxbuf *xb);
117
118UTILS_API pointf dotneato_closest(splines *spl, pointf p);
119
120UTILS_API Agsym_t *setAttr(graph_t *, void *, char *name, char *value,
121 Agsym_t *);
122UTILS_API void setEdgeType(graph_t *g, int defaultValue);
123UTILS_API bool is_a_cluster(Agraph_t *g);
124
125/* from postproc.c */
126UTILS_API void gv_nodesize(Agnode_t *n, bool flip);
127
128#ifndef HAVE_DRAND48
129UTILS_API double drand48(void);
130#endif
131
132/* from timing.c */
133UTILS_API void start_timer(void);
134UTILS_API double elapsed_sec(void);
135
136/* from psusershape.c */
137UTILS_API void cat_libfile(GVJ_t *job, const char **arglib,
138 const char **stdlib);
139
140#undef UTILS_API
141
142#ifdef __cplusplus
143}
144#endif
Dynamically expanding string buffers.
static void ins(Dict_t *d, Dtlink_t **set, Agedge_t *e)
Definition edge.c:151
#define A(n, t)
Definition expr.h:76
static int flags
Definition gc.c:63
#define G
Definition gdefs.h:7
geometric types and macros (e.g. points and boxes)
textitem scanner parser str
Definition htmlparse.y:218
graph or subgraph
Definition cgraph.h:424
string attribute descriptor symbol in Agattr_s.dict
Definition cgraph.h:640
Definition geom.h:41
Definition cdt.h:98
graphs, nodes and edges info: Agraphinfo_t, Agnodeinfo_t and Agedgeinfo_t
Definition grammar.c:90
void processClusterEdges(graph_t *g)
Definition utils.c:930
void undoClusterEdges(graph_t *g)
Definition utils.c:1030
char * scanEntity(char *t, agxbuf *xb)
Definition utils.c:1082
char * late_string(void *obj, Agsym_t *attr, char *defaultValue)
Definition utils.c:85
char * strdup_and_subst_obj(char *str, void *obj)
Processes graph object escape sequences; also collapses \ to .
Definition labels.c:387
bool mapbool(const char *p)
Definition utils.c:341
char * htmlEntityUTF8(char *, graph_t *g)
Definition utils.c:1183
void UF_setname(Agnode_t *, Agnode_t *)
Definition utils.c:150
pointf Bezier(const pointf *, double, pointf *, pointf *)
Definition utils.c:175
Agnode_t * UF_union(Agnode_t *, Agnode_t *)
Definition utils.c:115
Dt_t * mkClustMap(Agraph_t *g)
Definition utils.c:1592
void setEdgeType(graph_t *g, int defaultValue)
Definition utils.c:1423
boxf polyBB(polygon_t *poly)
Definition utils.c:604
void common_init_node(node_t *n)
Definition utils.c:427
bool overlap_label(textlabel_t *lp, boxf b)
Definition utils.c:1323
double elapsed_sec(void)
Definition timing.c:23
Agsym_t * setAttr(graph_t *, void *, char *name, char *value, Agsym_t *)
Definition utils.c:704
bool findStopColor(const char *colorlist, char *clrs[2], double *frac)
Definition emit.c:4335
bool late_bool(void *obj, Agsym_t *attr, bool defaultValue)
Definition utils.c:98
bool overlap_node(node_t *n, boxf b)
Definition utils.c:1311
Agnode_t * UF_find(Agnode_t *)
Definition utils.c:105
void UF_singleton(Agnode_t *)
Definition utils.c:143
void common_init_edge(edge_t *e)
Definition utils.c:509
const char * safefile(const char *filename)
Definition utils.c:266
void write_plain(GVJ_t *job, graph_t *g, void *f, bool extend)
Definition output.c:129
void epsf_define(GVJ_t *job)
double attach_attrs_and_arrows(graph_t *, bool *, bool *)
Definition output.c:254
char * late_nnstring(void *obj, Agsym_t *attr, char *defaultValue)
Definition utils.c:91
char * ps_string(char *s, int chset)
attrsym_t * safe_dcl(graph_t *g, int obj_kind, char *name, char *defaultValue)
Definition utils.c:1065
double yDir(double y, double yOff)
Definition output.c:35
void compute_bb(Agraph_t *)
Definition utils.c:633
double get_inputscale(graph_t *g)
Definition utils.c:78
void start_timer(void)
Definition timing.c:21
void updateBB(graph_t *g, textlabel_t *lp)
Definition utils.c:624
int late_int(void *obj, Agsym_t *attr, int defaultValue, int minimum)
Definition utils.c:40
bool overlap_edge(edge_t *e, boxf b)
Definition utils.c:1358
void cat_libfile(GVJ_t *job, const char **arglib, const char **stdlib)
char * latin1ToUTF8(char *)
Converts string from Latin1 encoding to utf8. Also translates HTML entities.
Definition utils.c:1260
void gv_nodesize(Agnode_t *n, bool flip)
Definition utils.c:1536
bool mapBool(const char *p, bool defaultValue)
Definition utils.c:325
double late_double(void *obj, Agsym_t *attr, double defaultValue, double minimum)
Definition utils.c:55
void epsf_emit_body(GVJ_t *job, usershape_t *us)
int maptoken(char *, char **, int *)
Definition utils.c:315
pointf dotneato_closest(splines *spl, pointf p)
Definition utils.c:346
void get_gradient_points(pointf *A, pointf *G, size_t n, double angle, int flags)
Definition utils.c:1446
char * utf8ToLatin1(char *ins)
Definition utils.c:1293
int test_toggle(void)
Definition utils.c:416
bool is_a_cluster(Agraph_t *g)
Definition utils.c:695
Agraph_t * findCluster(Dt_t *map, char *name)
Definition utils.c:1602
double drand48(void)
Definition utils.c:1550