| 1 |
/// @file |
| 2 |
/// @ingroup common_utils |
| 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 v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* https://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: Details at https://graphviz.org |
| 11 |
*************************************************************************/ |
| 12 |
|
| 13 |
#pragma once |
| 14 |
|
| 15 |
#include "config.h" |
| 16 |
|
| 17 |
#include <stdbool.h> |
| 18 |
#include <stddef.h> |
| 19 |
#include <util/agxbuf.h> |
| 20 |
|
| 21 |
#ifdef __cplusplus |
| 22 |
extern "C" { |
| 23 |
#endif |
| 24 |
|
| 25 |
#ifdef GVDLL |
| 26 |
#ifdef GVC_EXPORTS |
| 27 |
#define UTILS_API __declspec(dllexport) |
| 28 |
#else |
| 29 |
#define UTILS_API __declspec(dllimport) |
| 30 |
#endif |
| 31 |
#endif |
| 32 |
|
| 33 |
#ifndef UTILS_API |
| 34 |
#define UTILS_API /* nothing */ |
| 35 |
#endif |
| 36 |
|
| 37 |
UTILS_API pointf Bezier(const pointf *, double, pointf *, pointf *); |
| 38 |
|
| 39 |
/// @return Computed ymin + ymax |
| 40 |
UTILS_API double attach_attrs_and_arrows(graph_t *, bool *, bool *); |
| 41 |
|
| 42 |
UTILS_API void write_plain(GVJ_t *job, graph_t *g, void *f, bool extend); |
| 43 |
|
| 44 |
/// @param yOff Displacement to apply to `y` |
| 45 |
UTILS_API double yDir(double y, double yOff); |
| 46 |
|
| 47 |
/// translate string for emitting into a PostScript file |
| 48 |
/// |
| 49 |
/// Internally, strings are always UTF-8. If `chset` is `CHAR_LATIN1`, we know |
| 50 |
/// all of the values can be represented by Latin-1; if `chset` is `CHAR_UTF8`, |
| 51 |
/// we use the string as is; otherwise, we test to see if the string is ASCII, |
| 52 |
/// Latin-1 or non-Latin, and translate to Latin-l if possible. |
| 53 |
/// |
| 54 |
/// The caller must free the returned string. |
| 55 |
/// |
| 56 |
/// @param s String to translate |
| 57 |
/// @param chset Character set |
| 58 |
/// @return Translated string |
| 59 |
UTILS_API char *ps_string(char *s, int chset); |
| 60 |
|
| 61 |
UTILS_API char *strdup_and_subst_obj(char *str, void *obj); |
| 62 |
UTILS_API void epsf_emit_body(GVJ_t *job, usershape_t *us); |
| 63 |
UTILS_API void epsf_define(GVJ_t *job); |
| 64 |
UTILS_API void undoClusterEdges(graph_t *g); |
| 65 |
UTILS_API Dt_t *mkClustMap(Agraph_t *g); |
| 66 |
UTILS_API Agraph_t *findCluster(Dt_t *map, char *name); |
| 67 |
UTILS_API attrsym_t *safe_dcl(graph_t *g, int obj_kind, char *name, |
| 68 |
char *defaultValue); |
| 69 |
|
| 70 |
UTILS_API int late_int(void *obj, Agsym_t *attr, int defaultValue, int minimum); |
| 71 |
UTILS_API double late_double(void *obj, Agsym_t *attr, double defaultValue, |
| 72 |
double minimum); |
| 73 |
UTILS_API char *late_nnstring(void *obj, Agsym_t *attr, char *defaultValue); |
| 74 |
UTILS_API char *late_string(void *obj, Agsym_t *attr, char *defaultValue); |
| 75 |
UTILS_API bool late_bool(void *obj, Agsym_t *attr, bool defaultValue); |
| 76 |
UTILS_API double get_inputscale(graph_t *g); |
| 77 |
|
| 78 |
// routines for supporting “union-find”, a.k.a. “disjoint-set forest” |
| 79 |
// https://en.wikipedia.org/wiki/Disjoint-set_data_structure |
| 80 |
UTILS_API Agnode_t *UF_find(Agnode_t *); |
| 81 |
UTILS_API Agnode_t *UF_union(Agnode_t *, Agnode_t *); |
| 82 |
UTILS_API void UF_singleton(Agnode_t *); |
| 83 |
UTILS_API void UF_setname(Agnode_t *, Agnode_t *); |
| 84 |
|
| 85 |
UTILS_API const char *safefile(const char *filename); |
| 86 |
|
| 87 |
UTILS_API bool mapBool(const char *p, bool defaultValue); |
| 88 |
UTILS_API bool mapbool(const char *p); |
| 89 |
UTILS_API int maptoken(char *, char **, int *); |
| 90 |
|
| 91 |
UTILS_API bool findStopColor(const char *colorlist, char *clrs[2], |
| 92 |
double *frac); |
| 93 |
UTILS_API int test_toggle(void); |
| 94 |
|
| 95 |
UTILS_API void common_init_node(node_t *n); |
| 96 |
UTILS_API void common_init_edge(edge_t *e); |
| 97 |
|
| 98 |
UTILS_API void updateBB(graph_t *g, textlabel_t *lp); |
| 99 |
UTILS_API void compute_bb(Agraph_t *); |
| 100 |
UTILS_API boxf polyBB(polygon_t *poly); |
| 101 |
UTILS_API bool overlap_node(node_t *n, boxf b); |
| 102 |
UTILS_API bool overlap_label(textlabel_t *lp, boxf b); |
| 103 |
UTILS_API bool overlap_edge(edge_t *e, boxf b); |
| 104 |
|
| 105 |
UTILS_API void get_gradient_points(pointf *A, pointf *G, size_t n, double angle, |
| 106 |
int flags); |
| 107 |
|
| 108 |
UTILS_API void processClusterEdges(graph_t *g); |
| 109 |
|
| 110 |
UTILS_API char *latin1ToUTF8(char *); |
| 111 |
UTILS_API char *htmlEntityUTF8(char *, graph_t *g); |
| 112 |
UTILS_API char *utf8ToLatin1(char *ins); |
| 113 |
UTILS_API char *scanEntity(char *t, agxbuf *xb); |
| 114 |
|
| 115 |
UTILS_API pointf dotneato_closest(splines *spl, pointf p); |
| 116 |
|
| 117 |
UTILS_API Agsym_t *setAttr(graph_t *, void *, char *name, char *value, |
| 118 |
Agsym_t *); |
| 119 |
UTILS_API void setEdgeType(graph_t *g, int defaultValue); |
| 120 |
UTILS_API bool is_a_cluster(Agraph_t *g); |
| 121 |
|
| 122 |
/* from postproc.c */ |
| 123 |
UTILS_API void gv_nodesize(Agnode_t *n, bool flip); |
| 124 |
|
| 125 |
#ifndef HAVE_DRAND48 |
| 126 |
UTILS_API double drand48(void); |
| 127 |
#endif |
| 128 |
|
| 129 |
/* from timing.c */ |
| 130 |
UTILS_API void start_timer(void); |
| 131 |
UTILS_API double elapsed_sec(void); |
| 132 |
|
| 133 |
/* from psusershape.c */ |
| 134 |
UTILS_API void cat_libfile(GVJ_t *job, const char **arglib, |
| 135 |
const char **stdlib); |
| 136 |
|
| 137 |
#undef UTILS_API |
| 138 |
|
| 139 |
#ifdef __cplusplus |
| 140 |
} |
| 141 |
#endif |