From c1f91ebfd62f62ba0585b8d538f611578e3ddde8 Mon Sep 17 00:00:00 2001 From: ellson Date: Tue, 18 Oct 2005 18:46:29 +0000 Subject: [PATCH] provide for "visited" and "deleted" states, in addition to "active", "selected" --- lib/common/arith.h | 9 ++++++++- lib/common/const.h | 15 ++++++++------- lib/common/emit.c | 29 ++++++++++++++++++++++++++--- lib/common/globals.h | 6 ++++++ lib/common/shapes.c | 14 ++++++++++++++ lib/common/types.h | 15 +++++++++------ 6 files changed, 71 insertions(+), 17 deletions(-) diff --git a/lib/common/arith.h b/lib/common/arith.h index 68f0cc111..727da454f 100644 --- a/lib/common/arith.h +++ b/lib/common/arith.h @@ -59,9 +59,16 @@ extern "C" { #endif #define BETWEEN(a,b,c) (((a) <= (b)) && ((b) <= (c))) +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif +#ifndef PI +#define PI M_PI +#endif + #define ROUND(f) ((f>=0)?(int)(f + .5):(int)(f - .5)) #define RADIANS(deg) ((deg)/180.0 * PI) -#define DEGREES(rad) ((rad)/PI * 180.0) +#define DEGREES(rad) ((rad)/M_PI * 180.0) #define SQR(a) ((a) * (a)) diff --git a/lib/common/const.h b/lib/common/const.h index 12f0d7c58..a91cbf3c8 100644 --- a/lib/common/const.h +++ b/lib/common/const.h @@ -17,13 +17,6 @@ #ifndef GV_CONST_H #define GV_CONST_H -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif -#ifndef PI -#define PI M_PI -#endif - #define SMALLBUF 128 #define LPAREN '(' #define RPAREN ')' @@ -61,8 +54,16 @@ #define DEFAULT_COLOR "black" #define DEFAULT_ACTIVEPENCOLOR "yellow" #define DEFAULT_ACTIVEFILLCOLOR "yellow" +#define DEFAULT_ACTIVEFONTCOLOR "black" #define DEFAULT_SELECTEDPENCOLOR "orange" #define DEFAULT_SELECTEDFILLCOLOR "orange" +#define DEFAULT_SELECTEDFONTCOLOR "black" +#define DEFAULT_DELETEDPENCOLOR "lightgrey" +#define DEFAULT_DELETEDFILLCOLOR "lightgrey" +#define DEFAULT_DELETEDFONTCOLOR "darkgrey" +#define DEFAULT_VISITEDPENCOLOR "paleblue" +#define DEFAULT_VISITEDFILLCOLOR "paleblue" +#define DEFAULT_VISITEDFONTCOLOR "black" #define DEFAULT_FONTSIZE 14.0 #define DEFAULT_LABEL_FONTSIZE 11.0 /* for head/taillabel */ #define MIN_FONTSIZE 1.0 diff --git a/lib/common/emit.c b/lib/common/emit.c index 98cecef4b..8a1695ba0 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -789,6 +789,18 @@ void emit_edge_graphics(GVJ_t * job, edge_t * e) color = late_nnstring(e, E_activefillcolor, DEFAULT_ACTIVEFILLCOLOR); gvrender_set_fillcolor(job, color); } + else if (ED_deleted(e)) { + color = late_nnstring(e, E_deletedpencolor, DEFAULT_DELETEDPENCOLOR); + gvrender_set_pencolor(job, color); + color = late_nnstring(e, E_deletedfillcolor, DEFAULT_DELETEDFILLCOLOR); + gvrender_set_fillcolor(job, color); + } + else if (ED_visited(e)) { + color = late_nnstring(e, E_visitedpencolor, DEFAULT_VISITEDPENCOLOR); + gvrender_set_pencolor(job, color); + color = late_nnstring(e, E_visitedfillcolor, DEFAULT_VISITEDFILLCOLOR); + gvrender_set_fillcolor(job, color); + } /* if more than one color - then generate parallel beziers, one per color */ if (numc) { /* calculate and save offset vector spline and initialize first offset spline */ @@ -990,6 +1002,8 @@ static void init_gvc_from_graph(GVC_t * gvc, graph_t * g) char *p; int i; + gvc->g = g; + /* margins */ gvc->graph_sets_margin = FALSE; if ((p = agget(g, "margin"))) { @@ -1407,6 +1421,18 @@ void emit_clusters(GVJ_t * job, Agraph_t * g, int flags) color = late_nnstring(sg, G_activefillcolor, DEFAULT_ACTIVEFILLCOLOR); gvrender_set_fillcolor(job, color); } + else if (GD_deleted(sg)) { + color = late_nnstring(e, G_deletedpencolor, DEFAULT_DELETEDPENCOLOR); + gvrender_set_pencolor(job, color); + color = late_nnstring(e, G_deletedfillcolor, DEFAULT_DELETEDFILLCOLOR); + gvrender_set_fillcolor(job, color); + } + else if (GD_visited(sg)) { + color = late_nnstring(e, G_visitedpencolor, DEFAULT_VISITEDPENCOLOR); + gvrender_set_pencolor(job, color); + color = late_nnstring(e, G_visitedfillcolor, DEFAULT_VISITEDFILLCOLOR); + gvrender_set_fillcolor(job, color); + } else { if (((color = agget(sg, "pencolor")) != 0) && color[0]) gvrender_set_pencolor(job, color); @@ -1779,8 +1805,6 @@ int gvRenderJobs (GVC_t * gvc, graph_t * g) gvc->numkeys = gvevent_key_binding_size; for (job = gvrender_first_job(gvc); job; job = gvrender_next_job(gvc)) { - job->g = g; - if (!job->output_file) { /* if not yet opened */ if (job->output_filename == NULL) { job->output_file = stdout; @@ -1793,7 +1817,6 @@ int gvRenderJobs (GVC_t * gvc, graph_t * g) agerr (AGERR, "renderer for %s is unavailable\n", job->output_langname); return -1; } - if (gvc->active_jobs && strcmp(job->output_langname,gvc->active_jobs->output_langname) != 0) { /* finalize previous jobs */ diff --git a/lib/common/globals.h b/lib/common/globals.h index 8cb1c4637..3007565d4 100644 --- a/lib/common/globals.h +++ b/lib/common/globals.h @@ -92,11 +92,15 @@ extern "C" { EXTERN attrsym_t *G_activepencolor, *G_activefillcolor, *G_selectedpencolor, *G_selectedfillcolor, + *G_visitedpencolor, *G_visitedfillcolor, + *G_deletedpencolor, *G_deletedfillcolor, *G_peripheries; EXTERN attrsym_t *N_height, *N_width, *N_shape, *N_color, *N_fillcolor, *N_activepencolor, *N_activefillcolor, *N_selectedpencolor, *N_selectedfillcolor, + *N_visitedpencolor, *N_visitedfillcolor, + *N_deletedpencolor, *N_deletedfillcolor, *N_fontsize, *N_fontname, *N_fontcolor, *N_label, *N_nojustify, *N_style, *N_showboxes, *N_sides, *N_peripheries, *N_orientation, @@ -106,6 +110,8 @@ extern "C" { *E_weight, *E_minlen, *E_color, *E_activepencolor, *E_activefillcolor, *E_selectedpencolor, *E_selectedfillcolor, + *E_visitedpencolor, *E_visitedfillcolor, + *E_deletedpencolor, *E_deletedfillcolor, *E_fontsize, *E_fontname, *E_fontcolor, *E_label, *E_dir, *E_style, *E_decorate, *E_showboxes, *E_arrowsz, *E_constr, *E_layer, diff --git a/lib/common/shapes.c b/lib/common/shapes.c index 802e317f8..21eb51de6 100644 --- a/lib/common/shapes.c +++ b/lib/common/shapes.c @@ -1239,6 +1239,20 @@ static void poly_gencode(GVJ_t * job, node_t * n) gvrender_set_fillcolor(job, color); filled = TRUE; } + else if (ND_deleted(n)) { + color = late_nnstring(n, N_deletedpencolor, DEFAULT_DELETEDPENCOLOR); + gvrender_set_pencolor(job, color); + color = late_nnstring(n, N_deletedfillcolor, DEFAULT_DELETEDFILLCOLOR); + gvrender_set_fillcolor(job, color); + filled = TRUE; + } + else if (ND_visited(n)) { + color = late_nnstring(n, N_visitedpencolor, DEFAULT_VISITEDPENCOLOR); + gvrender_set_pencolor(job, color); + color = late_nnstring(n, N_visitedfillcolor, DEFAULT_VISITEDFILLCOLOR); + gvrender_set_fillcolor(job, color); + filled = TRUE; + } else { if (style & FILLED) { gvrender_set_fillcolor(job, findFill(n)); /* emit fill color */ diff --git a/lib/common/types.h b/lib/common/types.h index 55efdc4d4..241cc6fed 100644 --- a/lib/common/types.h +++ b/lib/common/types.h @@ -312,8 +312,7 @@ extern "C" { point border[4]; /* sizes of margins for graph labels */ bool has_labels; bool has_images; - bool active; - bool selected; + bool active, selected, visited, deleted; /* Graph state for GUI ops */ unsigned char charset; /* input character set */ int rankdir; int ht1, ht2; /* below and above extremal ranks */ @@ -370,6 +369,7 @@ extern "C" { #define GD_clust(g) (g)->u.clust #define GD_cluster_was_collapsed(g) (g)->u.cluster_was_collapsed #define GD_comp(g) (g)->u.comp +#define GD_deleted(g) (g)->u.deleted #define GD_dist(g) (g)->u.dist #define GD_drawing(g) (g)->u.drawing #define GD_exact_ranksep(g) (g)->u.exact_ranksep @@ -414,6 +414,7 @@ extern "C" { #define GD_spring(g) (g)->u.spring #define GD_sum_t(g) (g)->u.sum_t #define GD_t(g) (g)->u.t +#define GD_visited(g) (g)->u.visited typedef struct Agnodeinfo_t { shape_desc *shape; @@ -426,8 +427,7 @@ extern "C" { void *alg; char state; bool clustnode; - bool active; - bool selected; + bool active, selected, visited, deleted; /* Node state for GUI ops */ #ifndef DOT_ONLY bool pinned; @@ -474,6 +474,7 @@ extern "C" { #define ND_bb(n) (n)->u.bb #define ND_clust(n) (n)->u.clust #define ND_coord_i(n) (n)->u.coord +#define ND_deleted(n) (n)->u.deleted #define ND_dist(n) (n)->u.dist #define ND_flat_in(n) (n)->u.flat_in #define ND_flat_out(n) (n)->u.flat_out @@ -517,6 +518,7 @@ extern "C" { #define ND_clustnode(n) (n)->u.clustnode #define ND_tree_in(n) (n)->u.tree_in #define ND_tree_out(n) (n)->u.tree_out +#define ND_visited(n) (n)->u.visited #define ND_weight_class(n) (n)->u.weight_class #define ND_width(n) (n)->u.width #define ND_xsize(n) (n)->u.xsize @@ -531,8 +533,7 @@ extern "C" { char label_ontop; edge_t *to_orig; /* for dot's shapes.c */ void *alg; - bool active; - bool selected; + bool active, selected, visited, deleted; /* Edge state for GUI ops */ #ifndef DOT_ONLY double factor; @@ -557,6 +558,7 @@ extern "C" { #define ED_conc_opp_flag(e) (e)->u.conc_opp_flag #define ED_count(e) (e)->u.count #define ED_cutvalue(e) (e)->u.cutvalue +#define ED_deleted(e) (e)->u.deleted #define ED_dist(e) (e)->u.dist #define ED_edge_type(e) (e)->u.edge_type #define ED_adjacent(e) (e)->u.adjacent @@ -575,6 +577,7 @@ extern "C" { #define ED_to_orig(e) (e)->u.to_orig #define ED_to_virt(e) (e)->u.to_virt #define ED_tree_index(e) (e)->u.tree_index +#define ED_visited(e) (e)->u.visited #define ED_weight(e) (e)->u.weight #define ED_xpenalty(e) (e)->u.xpenalty -- 2.40.0