Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
gvrender_core_dot.c File Reference
#include "config.h"
#include <assert.h>
#include <math.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <common/macros.h>
#include <common/const.h>
#include <gvc/gvplugin_render.h>
#include <gvc/gvplugin_device.h>
#include <common/utils.h>
#include <gvc/gvc.h>
#include <gvc/gvio.h>
#include <util/agxbuf.h>
#include <util/alloc.h>
#include <util/gv_ctype.h>
#include <util/prisize_t.h>
#include <util/streq.h>
#include <util/unreachable.h>
#include "core_loadimage_xdot.h"
Include dependency graph for gvrender_core_dot.c:

Go to the source code of this file.

Data Structures

struct  xdot_state_t
 

Macros

#define XDOTVERSION   "1.7"
 
#define NUMXBUFS   (EMIT_HLABEL+1)
 

Typedefs

typedef int(* putstrfn) (void *chan, const char *str)
 
typedef int(* flushfn) (void *chan)
 

Enumerations

enum  format_type {
  FORMAT_DOT , FORMAT_CANON , FORMAT_PLAIN , FORMAT_PLAIN_EXT ,
  FORMAT_XDOT , FORMAT_XDOT12 , FORMAT_XDOT14
}
 

Functions

static void xdot_str_xbuf (agxbuf *xb, char *pfx, const char *s)
 
static void xdot_str (GVJ_t *job, char *pfx, const char *s)
 
static void xdot_str_color_xbuf (agxbuf *xb, const char *prefix, const unsigned char rgba[4])
 
static void xdot_str_color (GVJ_t *job, const char *prefix, const unsigned char rgba[4])
 
static void xdot_fmt_num (agxbuf *buf, double v)
 
static void xdot_point (agxbuf *xb, pointf p)
 
static void xdot_num (agxbuf *xb, double v)
 
static void xdot_points (GVJ_t *job, char c, pointf *A, size_t n)
 
static void xdot_pencolor (GVJ_t *job)
 
static void xdot_fillcolor (GVJ_t *job)
 
static void xdot_style (GVJ_t *job)
 
static void put_escaping_backslashes (Agobj_t *n, Agsym_t *sym, const char *value)
 
static void xdot_end_node (GVJ_t *job)
 
static void xdot_end_edge (GVJ_t *job)
 
static void xdot_end_cluster (GVJ_t *job)
 
static unsigned short versionStr2Version (const char *str)
 
static void xdot_begin_graph (graph_t *g, bool s_arrows, bool e_arrows, format_type id, double yOff)
 
static void dot_begin_graph (GVJ_t *job)
 
static void xdot_end_graph (graph_t *g)
 
static void dot_end_graph (GVJ_t *job)
 
static void xdot_textspan (GVJ_t *job, pointf p, textspan_t *span)
 
static void xdot_color_stop (agxbuf *xb, double v, gvcolor_t *clr)
 
static void xdot_gradient_fillcolor (GVJ_t *job, int filled, pointf *A, size_t n)
 
static void xdot_ellipse (GVJ_t *job, pointf *A, int filled)
 
static void xdot_bezier (GVJ_t *job, pointf *A, size_t n, int filled)
 
static void xdot_polygon (GVJ_t *job, pointf *A, size_t n, int filled)
 
static void xdot_polyline (GVJ_t *job, pointf *A, size_t n)
 
void core_loadimage_xdot (GVJ_t *job, usershape_t *us, boxf b, bool filled)
 

Variables

static agxbuf xbuf [NUMXBUFS]
 
static agxbufxbufs []
 
static double penwidth []
 
static unsigned int textflags [EMIT_ELABEL+1]
 
static xdot_state_txd
 
static const unsigned int flag_masks [] = {0x1F, 0x3F, 0x7F}
 
gvrender_engine_t dot_engine
 
gvrender_engine_t xdot_engine
 
gvrender_features_t render_features_dot
 
gvrender_features_t render_features_xdot
 
gvdevice_features_t device_features_canon
 
gvdevice_features_t device_features_dot
 
gvplugin_installed_t gvrender_dot_types []
 
gvplugin_installed_t gvdevice_dot_types []
 

Macro Definition Documentation

◆ NUMXBUFS

#define NUMXBUFS   (EMIT_HLABEL+1)

Definition at line 48 of file gvrender_core_dot.c.

◆ XDOTVERSION

#define XDOTVERSION   "1.7"

Definition at line 46 of file gvrender_core_dot.c.

Typedef Documentation

◆ flushfn

typedef int(* flushfn) (void *chan)

Definition at line 450 of file gvrender_core_dot.c.

◆ putstrfn

typedef int(* putstrfn) (void *chan, const char *str)

Definition at line 449 of file gvrender_core_dot.c.

Enumeration Type Documentation

◆ format_type

Enumerator
FORMAT_DOT 
FORMAT_CANON 
FORMAT_PLAIN 
FORMAT_PLAIN_EXT 
FORMAT_XDOT 
FORMAT_XDOT12 
FORMAT_XDOT14 

Definition at line 36 of file gvrender_core_dot.c.

Function Documentation

◆ core_loadimage_xdot()

void core_loadimage_xdot ( GVJ_t job,
usershape_t us,
boxf  b,
bool  filled 
)

Definition at line 659 of file gvrender_core_dot.c.

References agxbput(), obj_state_s::emit_state, boxf::LL, usershape_s::name, GVJ_s::obj, boxf::UR, pointf_s::x, xbufs, xdot_fmt_num(), xdot_str(), and pointf_s::y.

Here is the call graph for this function:

◆ dot_begin_graph()

static void dot_begin_graph ( GVJ_t job)
static

Definition at line 398 of file gvrender_core_dot.c.

References attach_attrs(), attach_attrs_and_arrows(), FORMAT_CANON, FORMAT_DOT, FORMAT_PLAIN, FORMAT_PLAIN_EXT, FORMAT_XDOT, FORMAT_XDOT12, FORMAT_XDOT14, obj_state_s::g, HAS_CLUST_EDGE, gvplugin_active_render_s::id, GVJ_s::obj, GVJ_s::render, obj_state_s::u, undoClusterEdges(), UNREACHABLE, and xdot_begin_graph().

Here is the call graph for this function:

◆ dot_end_graph()

static void dot_end_graph ( GVJ_t job)
static

◆ put_escaping_backslashes()

static void put_escaping_backslashes ( Agobj_t n,
Agsym_t sym,
const char *  value 
)
static

set the value of a symbol within a node, escaping backslashes

The back ends that output certain text-based formats, e.g. xdot, assume that all characters that have special meaning within a string have already been escaped, with the exception of double quote ("). Hence, any string being constructed from user-provided input needs to be escaped for other problematic characters (namely ) beforehand. This is a little utility function to do such.

Parameters
nNode to operate on
symSymbol to set
valueUnescaped string

Definition at line 218 of file gvrender_core_dot.c.

References agxbfree(), agxbputc(), agxbuse(), and agxset().

Referenced by xdot_end_edge(), xdot_end_graph(), and xdot_end_node().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ versionStr2Version()

static unsigned short versionStr2Version ( const char *  str)
static

Definition at line 293 of file gvrender_core_dot.c.

References agwarningf(), gv_isdigit(), and str.

Referenced by xdot_begin_graph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_begin_graph()

static void xdot_begin_graph ( graph_t g,
bool  s_arrows,
bool  e_arrows,
format_type  id,
double  yOff 
)
static

Definition at line 333 of file gvrender_core_dot.c.

References AGEDGE, agget(), AGNODE, AGRAPH, xdot_state_t::e_draw, xdot_state_t::e_l_draw, EDGE_LABEL, EDGE_XLABEL, FORMAT_XDOT12, FORMAT_XDOT14, xdot_state_t::g_draw, xdot_state_t::g_l_draw, GD_has_labels, GD_n_cluster, GRAPH_LABEL, gv_alloc(), xdot_state_t::h_draw, HEAD_LABEL, xdot_state_t::hl_draw, xdot_state_t::n_draw, xdot_state_t::n_l_draw, NULL, NUMXBUFS, safe_dcl(), xdot_state_t::t_draw, TAIL_LABEL, xdot_state_t::tl_draw, xdot_state_t::version, xdot_state_t::version_s, versionStr2Version(), xbuf, xd, XDOTVERSION, and xdot_state_t::yOff.

Referenced by dot_begin_graph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_bezier()

static void xdot_bezier ( GVJ_t job,
pointf A,
size_t  n,
int  filled 
)
static

Definition at line 623 of file gvrender_core_dot.c.

References A, GRADIENT, RGRADIENT, xdot_fillcolor(), xdot_gradient_fillcolor(), xdot_pencolor(), xdot_points(), and xdot_style().

Here is the call graph for this function:

◆ xdot_color_stop()

static void xdot_color_stop ( agxbuf xb,
double  v,
gvcolor_t clr 
)
static

Definition at line 537 of file gvrender_core_dot.c.

References agxbprint(), agxbputc(), agxbuf_trim_zeros(), color_s::rgba, color_s::u, and xdot_str_color_xbuf().

Here is the call graph for this function:

◆ xdot_ellipse()

static void xdot_ellipse ( GVJ_t job,
pointf A,
int  filled 
)
static

Definition at line 602 of file gvrender_core_dot.c.

References A, agxbput(), obj_state_s::emit_state, GRADIENT, GVJ_s::obj, RGRADIENT, xbufs, xdot_fillcolor(), xdot_fmt_num(), xdot_gradient_fillcolor(), xdot_pencolor(), and xdot_style().

Here is the call graph for this function:

◆ xdot_end_cluster()

static void xdot_end_cluster ( GVJ_t job)
static

Definition at line 280 of file gvrender_core_dot.c.

References agxbuse(), agxset(), EMIT_CDRAW, EMIT_CLABEL, xdot_state_t::g_draw, xdot_state_t::g_l_draw, GD_label, GVJ_s::obj, penwidth, obj_state_s::sg, textflags, obj_state_s::u, xbufs, and xd.

Here is the call graph for this function:

◆ xdot_end_edge()

static void xdot_end_edge ( GVJ_t job)
static

Definition at line 250 of file gvrender_core_dot.c.

References agxblen(), agxbuse(), agxset(), Agedge_s::base, obj_state_s::e, xdot_state_t::e_draw, xdot_state_t::e_l_draw, EMIT_EDRAW, EMIT_ELABEL, EMIT_HDRAW, EMIT_HLABEL, EMIT_TDRAW, EMIT_TLABEL, xdot_state_t::h_draw, xdot_state_t::hl_draw, GVJ_s::obj, penwidth, put_escaping_backslashes(), xdot_state_t::t_draw, textflags, xdot_state_t::tl_draw, obj_state_s::u, xbufs, and xd.

Here is the call graph for this function:

◆ xdot_end_graph()

static void xdot_end_graph ( graph_t g)
static

Definition at line 427 of file gvrender_core_dot.c.

References AGRAPH, agsafeset(), agxbfree(), agxblen(), agxbuse(), agxset(), Agraph_s::base, EMIT_GDRAW, EMIT_GLABEL, free(), xdot_state_t::g_draw, xdot_state_t::g_l_draw, GD_label, NUMXBUFS, penwidth, put_escaping_backslashes(), safe_dcl(), textflags, xdot_state_t::version_s, xbuf, xbufs, and xd.

Referenced by dot_end_graph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_end_node()

static void xdot_end_node ( GVJ_t job)
static

Definition at line 237 of file gvrender_core_dot.c.

References agxblen(), agxbuse(), agxset(), Agnode_s::base, EMIT_NDRAW, EMIT_NLABEL, obj_state_s::n, xdot_state_t::n_draw, xdot_state_t::n_l_draw, GVJ_s::obj, penwidth, put_escaping_backslashes(), textflags, obj_state_s::u, xbufs, and xd.

Here is the call graph for this function:

◆ xdot_fillcolor()

static void xdot_fillcolor ( GVJ_t job)
static

Definition at line 156 of file gvrender_core_dot.c.

References obj_state_s::fillcolor, GVJ_s::obj, color_s::rgba, color_s::u, and xdot_str_color().

Referenced by xdot_bezier(), xdot_ellipse(), xdot_gradient_fillcolor(), and xdot_polygon().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_fmt_num()

static void xdot_fmt_num ( agxbuf buf,
double  v 
)
static

Definition at line 126 of file gvrender_core_dot.c.

References agxbprint(), agxbputc(), and agxbuf_trim_zeros().

Referenced by core_loadimage_xdot(), xdot_ellipse(), xdot_num(), xdot_point(), and xdot_textspan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_gradient_fillcolor()

static void xdot_gradient_fillcolor ( GVJ_t job,
int  filled,
pointf A,
size_t  n 
)
static

Definition at line 544 of file gvrender_core_dot.c.

References A, agxbfree(), agxbpop(), agxbput(), agxbputc(), agxbuse(), obj_state_s::fillcolor, G, get_gradient_points(), GRADIENT, obj_state_s::gradient_angle, obj_state_s::gradient_frac, M_PI, GVJ_s::obj, obj_state_s::stopcolor, xdot_state_t::version, pointf_s::x, xd, xdot_fillcolor(), xdot_num(), xdot_str(), and pointf_s::y.

Referenced by xdot_bezier(), xdot_ellipse(), and xdot_polygon().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_num()

static void xdot_num ( agxbuf xb,
double  v 
)
static

Definition at line 139 of file gvrender_core_dot.c.

References xdot_fmt_num().

Referenced by xdot_gradient_fillcolor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_pencolor()

static void xdot_pencolor ( GVJ_t job)
static

Definition at line 151 of file gvrender_core_dot.c.

References GVJ_s::obj, obj_state_s::pencolor, color_s::rgba, color_s::u, and xdot_str_color().

Referenced by xdot_bezier(), xdot_ellipse(), xdot_polygon(), xdot_polyline(), and xdot_textspan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_point()

static void xdot_point ( agxbuf xb,
pointf  p 
)
static

Definition at line 132 of file gvrender_core_dot.c.

References NULL, pointf_s::x, xd, xdot_fmt_num(), pointf_s::y, yDir(), and xdot_state_t::yOff.

Here is the call graph for this function:

◆ xdot_points()

static void xdot_points ( GVJ_t job,
char  c,
pointf A,
size_t  n 
)
static

Definition at line 144 of file gvrender_core_dot.c.

References A, agxbprint(), obj_state_s::emit_state, GVJ_s::obj, PRISIZE_T, and xbufs.

Referenced by xdot_bezier(), xdot_polygon(), and xdot_polyline().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_polygon()

static void xdot_polygon ( GVJ_t job,
pointf A,
size_t  n,
int  filled 
)
static

Definition at line 638 of file gvrender_core_dot.c.

References A, GRADIENT, RGRADIENT, xdot_fillcolor(), xdot_gradient_fillcolor(), xdot_pencolor(), xdot_points(), and xdot_style().

Here is the call graph for this function:

◆ xdot_polyline()

static void xdot_polyline ( GVJ_t job,
pointf A,
size_t  n 
)
static

Definition at line 653 of file gvrender_core_dot.c.

References A, xdot_pencolor(), xdot_points(), and xdot_style().

Here is the call graph for this function:

◆ xdot_str()

static void xdot_str ( GVJ_t job,
char *  pfx,
const char *  s 
)
static

Definition at line 88 of file gvrender_core_dot.c.

References obj_state_s::emit_state, GVJ_s::obj, xbufs, and xdot_str_xbuf().

Referenced by core_loadimage_xdot(), xdot_gradient_fillcolor(), xdot_style(), and xdot_textspan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_str_color()

static void xdot_str_color ( GVJ_t job,
const char *  prefix,
const unsigned char  rgba[4] 
)
static

output a color

Parameters
jobJob indicating which state buffer to write to
prefixString prefix to prepend
rgbaColor in RGBA format

Definition at line 115 of file gvrender_core_dot.c.

References obj_state_s::emit_state, GVJ_s::obj, prefix, xbufs, and xdot_str_color_xbuf().

Referenced by xdot_fillcolor(), and xdot_pencolor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_str_color_xbuf()

static void xdot_str_color_xbuf ( agxbuf xb,
const char *  prefix,
const unsigned char  rgba[4] 
)
static

output a color

Parameters
xbBuffer to write to
Stringprefix to prepend
rgbaColor in RGBA format

Definition at line 99 of file gvrender_core_dot.c.

References agxbprint(), prefix, and PRISIZE_T.

Referenced by xdot_color_stop(), and xdot_str_color().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_str_xbuf()

static void xdot_str_xbuf ( agxbuf xb,
char *  pfx,
const char *  s 
)
static

Definition at line 83 of file gvrender_core_dot.c.

References agxbprint(), and PRISIZE_T.

Referenced by xdot_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_style()

static void xdot_style ( GVJ_t job)
static

Definition at line 161 of file gvrender_core_dot.c.

References agxbfree(), agxbprint(), agxbput(), agxbputc(), agxbuf_trim_zeros(), agxbuse(), obj_state_s::emit_state, GVJ_s::obj, obj_state_s::penwidth, penwidth, obj_state_s::rawstyle, streq(), and xdot_str().

Referenced by xdot_bezier(), xdot_ellipse(), xdot_polygon(), and xdot_polyline().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xdot_textspan()

static void xdot_textspan ( GVJ_t job,
pointf  p,
textspan_t span 
)
static

Definition at line 492 of file gvrender_core_dot.c.

References agxbprint(), agxbput(), obj_state_s::emit_state, flag_masks, flags, textfont_t::flags, textspan_t::font, textspan_t::just, textfont_t::name, GVJ_s::obj, textfont_t::size, textspan_t::size, textspan_t::str, textflags, xdot_state_t::version, pointf_s::x, xbufs, xd, xdot_fmt_num(), xdot_pencolor(), xdot_str(), pointf_s::y, and textspan_t::yoffset_centerline.

Here is the call graph for this function:

Variable Documentation

◆ device_features_canon

gvdevice_features_t device_features_canon
Initial value:
= {
{0.,0.},
{0.,0.},
{72.,72.},
}
#define LAYOUT_NOT_REQUIRED
Definition gvcjob.h:107

Definition at line 757 of file gvrender_core_dot.c.

◆ device_features_dot

gvdevice_features_t device_features_dot
Initial value:
= {
0,
{0.,0.},
{0.,0.},
{72.,72.},
}

Definition at line 764 of file gvrender_core_dot.c.

◆ dot_engine

gvrender_engine_t dot_engine

Definition at line 672 of file gvrender_core_dot.c.

◆ flag_masks

const unsigned int flag_masks[] = {0x1F, 0x3F, 0x7F}
static

Definition at line 490 of file gvrender_core_dot.c.

Referenced by xdot_textspan().

◆ gvdevice_dot_types

gvplugin_installed_t gvdevice_dot_types[]
Initial value:
= {
{FORMAT_DOT, "dot:dot", 1, NULL, &device_features_dot},
{FORMAT_DOT, "gv:dot", 1, NULL, &device_features_dot},
{FORMAT_CANON, "canon:dot", 1, NULL, &device_features_canon},
{FORMAT_PLAIN, "plain:dot", 1, NULL, &device_features_dot},
{FORMAT_PLAIN_EXT, "plain-ext:dot", 1, NULL, &device_features_dot},
{FORMAT_XDOT, "xdot:xdot", 1, NULL, &device_features_dot},
{FORMAT_XDOT12, "xdot1.2:xdot", 1, NULL, &device_features_dot},
{FORMAT_XDOT14, "xdot1.4:xdot", 1, NULL, &device_features_dot},
{0, NULL, 0, NULL, NULL}
}
node NULL
Definition grammar.y:163
gvdevice_features_t device_features_canon
gvdevice_features_t device_features_dot
@ FORMAT_PLAIN
@ FORMAT_XDOT12
@ FORMAT_DOT
@ FORMAT_XDOT
@ FORMAT_PLAIN_EXT
@ FORMAT_XDOT14
@ FORMAT_CANON

Definition at line 777 of file gvrender_core_dot.c.

◆ gvrender_dot_types

gvplugin_installed_t gvrender_dot_types[]
Initial value:
= {
{0, NULL, 0, NULL, NULL}
}
gvrender_engine_t dot_engine
gvrender_features_t render_features_dot
gvrender_features_t render_features_xdot
gvrender_engine_t xdot_engine

Definition at line 771 of file gvrender_core_dot.c.

◆ penwidth

◆ render_features_dot

gvrender_features_t render_features_dot
Initial value:
= {
0.,
NULL,
0,
}
@ COLOR_STRING
Definition color.h:27
#define GVRENDER_DOES_TRANSFORM
Definition gvcjob.h:95

Definition at line 738 of file gvrender_core_dot.c.

◆ render_features_xdot

gvrender_features_t render_features_xdot
Initial value:
= {
0.,
NULL,
0,
}
@ RGBA_BYTE
Definition color.h:26
#define GVRENDER_DOES_TOOLTIPS
Definition gvcjob.h:103
#define GVRENDER_DOES_MAPS
Definition gvcjob.h:97
#define GVRENDER_DOES_TARGETS
Definition gvcjob.h:104

Definition at line 746 of file gvrender_core_dot.c.

◆ textflags

unsigned int textflags[EMIT_ELABEL+1]
static

◆ xbuf

agxbuf xbuf[NUMXBUFS]
static

Definition at line 53 of file gvrender_core_dot.c.

Referenced by on_gvprbuttonload_clicked(), xdot_begin_graph(), and xdot_end_graph().

◆ xbufs

agxbuf* xbufs[]
static

◆ xd

◆ xdot_engine

gvrender_engine_t xdot_engine

Definition at line 705 of file gvrender_core_dot.c.