From b854b13f77bf9e8154800bf33e5608e187fc0041 Mon Sep 17 00:00:00 2001 From: "Emden R. Gansner" Date: Wed, 14 Aug 2013 14:45:38 -0400 Subject: [PATCH] Purify globals.h to allow its inclusion with only cgraph.h; removed second declaration of Verbose in general.h as second declarations confuse VS. --- lib/common/args.c | 15 ++++++++------- lib/common/globals.c | 4 +++- lib/common/globals.h | 12 ++++++------ lib/common/types.h.in | 12 ------------ lib/fdpgen/fdp.h | 12 ++++++++++++ lib/fdpgen/fdpinit.c | 2 +- lib/fdpgen/tlayout.c | 16 ++++++++-------- lib/sparse/general.h | 4 +++- 8 files changed, 41 insertions(+), 36 deletions(-) diff --git a/lib/common/args.c b/lib/common/args.c index 4778a056f..902656f9c 100644 --- a/lib/common/args.c +++ b/lib/common/args.c @@ -24,6 +24,7 @@ #include "render.h" #include "tlayout.h" #include "gvc.h" +#include "fdp.h" /* neato_extra_args: * Handle special neato arguments. @@ -204,26 +205,26 @@ setFDPAttr (char* arg) { switch (*arg++) { case 'g' : - fdp_parms.useGrid = 0; + fdp_parms->useGrid = 0; break; case 'O' : - fdp_parms.useNew = 0; + fdp_parms->useNew = 0; break; case 'n' : - if (setInt (&fdp_parms.numIters, arg)) return 1; + if (setInt (&fdp_parms->numIters, arg)) return 1; break; case 'U' : - if (setInt (&fdp_parms.unscaled, arg)) return 1; + if (setInt (&fdp_parms->unscaled, arg)) return 1; break; case 'C' : - if (setDouble (&fdp_parms.C, arg)) return 1; + if (setDouble (&fdp_parms->C, arg)) return 1; break; case 'T' : if (*arg == '*') { - if (setDouble (&fdp_parms.Tfact, arg+1)) return 1; + if (setDouble (&fdp_parms->Tfact, arg+1)) return 1; } else { - if (setDouble (&fdp_parms.T0, arg)) return 1; + if (setDouble (&fdp_parms->T0, arg)) return 1; } break; default : diff --git a/lib/common/globals.c b/lib/common/globals.c index 65640dfef..f359bc585 100644 --- a/lib/common/globals.c +++ b/lib/common/globals.c @@ -18,9 +18,10 @@ #define EXTERN #include "types.h" #include "globals.h" +#include "fdp.h" /* Default layout values, possibly set via command line; -1 indicates unset */ -fdpParms_t fdp_parms = { +static fdpParms_t fdpParms = { 1, /* useGrid */ 1, /* useNew */ -1, /* numIters */ @@ -31,3 +32,4 @@ fdpParms_t fdp_parms = { -1.0, /* T0 */ }; +struct fdpParms_s* fdp_parms = &fdpParms; diff --git a/lib/common/globals.h b/lib/common/globals.h index cd6c7b89e..dbbd2bec0 100644 --- a/lib/common/globals.h +++ b/lib/common/globals.h @@ -71,7 +71,7 @@ extern "C" { EXTERN char *Gvimagepath; /* Per-graph path of files allowed in image attributes (also ps libs) */ EXTERN unsigned char Verbose; - EXTERN boolean Reduce; + EXTERN unsigned char Reduce; EXTERN int MemTest; EXTERN char *HTTPServerEnVar; EXTERN char *Output_file_name; @@ -82,7 +82,7 @@ extern "C" { EXTERN int Show_cnt; EXTERN char** Show_boxes; /* emit code for correct box coordinates */ EXTERN int CL_type; /* NONE, LOCAL, GLOBAL */ - EXTERN boolean Concentrate; /* if parallel edges should be merged */ + EXTERN unsigned char Concentrate; /* if parallel edges should be merged */ EXTERN double Epsilon; /* defined in input_graph */ EXTERN int MaxIter; EXTERN int Ndim; @@ -93,14 +93,14 @@ extern "C" { EXTERN int Y_invert; /* invert y in dot & plain output */ EXTERN int GvExitOnUsage; /* gvParseArgs() should exit on usage or error */ - EXTERN attrsym_t + EXTERN Agsym_t *G_activepencolor, *G_activefillcolor, *G_selectedpencolor, *G_selectedfillcolor, *G_visitedpencolor, *G_visitedfillcolor, *G_deletedpencolor, *G_deletedfillcolor, *G_ordering, *G_peripheries, *G_penwidth, *G_gradientangle, *G_margin; - EXTERN attrsym_t + EXTERN Agsym_t *N_height, *N_width, *N_shape, *N_color, *N_fillcolor, *N_activepencolor, *N_activefillcolor, *N_selectedpencolor, *N_selectedfillcolor, @@ -112,7 +112,7 @@ extern "C" { *N_skew, *N_distortion, *N_fixed, *N_imagescale, *N_layer, *N_group, *N_comment, *N_vertices, *N_z, *N_penwidth, *N_gradientangle; - EXTERN attrsym_t + EXTERN Agsym_t *E_weight, *E_minlen, *E_color, *E_fillcolor, *E_activepencolor, *E_activefillcolor, *E_selectedpencolor, *E_selectedfillcolor, @@ -130,7 +130,7 @@ extern "C" { *E_tailclip, *E_headclip, *E_penwidth; - extern fdpParms_t fdp_parms; + extern struct fdpParms_s* fdp_parms; #undef external #undef EXTERN diff --git a/lib/common/types.h.in b/lib/common/types.h.in index 38b012501..9297149c6 100644 --- a/lib/common/types.h.in +++ b/lib/common/types.h.in @@ -751,18 +751,6 @@ typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind; #define agcanonStr(s) agcanonical(s) #endif - - typedef struct { - int useGrid; /* use grid for speed up */ - int useNew; /* encode x-K into attractive force */ - int numIters; /* actual iterations in layout */ - int unscaled; /* % of iterations used in pass 1 */ - double C; /* Repulsion factor in xLayout */ - double Tfact; /* scale temp from default expression */ - double K; /* spring constant; ideal distance */ - double T0; /* initial temperature */ - } fdpParms_t; - typedef struct { int flags; } gvlayout_features_t; diff --git a/lib/fdpgen/fdp.h b/lib/fdpgen/fdp.h index 8afceed85..c68ceb5eb 100644 --- a/lib/fdpgen/fdp.h +++ b/lib/fdpgen/fdp.h @@ -115,6 +115,18 @@ typedef struct { extern "C" { #endif +struct fdpParms_s { + int useGrid; /* use grid for speed up */ + int useNew; /* encode x-K into attractive force */ + int numIters; /* actual iterations in layout */ + int unscaled; /* % of iterations used in pass 1 */ + double C; /* Repulsion factor in xLayout */ + double Tfact; /* scale temp from default expression */ + double K; /* spring constant; ideal distance */ + double T0; /* initial temperature */ +}; +typedef struct fdpParms_s fdpParms_t; + extern void fdp_layout(Agraph_t * g); extern void fdp_nodesize(node_t *, boolean); extern void fdp_init_graph(Agraph_t * g); diff --git a/lib/fdpgen/fdpinit.c b/lib/fdpgen/fdpinit.c index 2d7fe3f96..5ae2c226f 100644 --- a/lib/fdpgen/fdpinit.c +++ b/lib/fdpgen/fdpinit.c @@ -86,7 +86,7 @@ static void init_edge(edge_t * e, attrsym_t * E_len) agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data #endif /* WITH_CGRAPH */ ED_factor(e) = late_double(e, E_weight, 1.0, 0.0); - ED_dist(e) = late_double(e, E_len, fdp_parms.K, 0.0); + ED_dist(e) = late_double(e, E_len, fdp_parms->K, 0.0); common_init_edge(e); } diff --git a/lib/fdpgen/tlayout.c b/lib/fdpgen/tlayout.c index 120e9e034..c3da60f06 100644 --- a/lib/fdpgen/tlayout.c +++ b/lib/fdpgen/tlayout.c @@ -57,14 +57,14 @@ extern double drand48(void); #include "tlayout.h" #include "globals.h" -#define D_useGrid (fdp_parms.useGrid) -#define D_useNew (fdp_parms.useNew) -#define D_numIters (fdp_parms.numIters) -#define D_unscaled (fdp_parms.unscaled) -#define D_C (fdp_parms.C) -#define D_Tfact (fdp_parms.Tfact) -#define D_K (fdp_parms.K) -#define D_T0 (fdp_parms.T0) +#define D_useGrid (fdp_parms->useGrid) +#define D_useNew (fdp_parms->useNew) +#define D_numIters (fdp_parms->numIters) +#define D_unscaled (fdp_parms->unscaled) +#define D_C (fdp_parms->C) +#define D_Tfact (fdp_parms->Tfact) +#define D_K (fdp_parms->K) +#define D_T0 (fdp_parms->T0) /* Actual parameters used; initialized using fdp_parms, then possibly * updated with graph-specific values. diff --git a/lib/sparse/general.h b/lib/sparse/general.h index 054f58fef..9411d86fd 100644 --- a/lib/sparse/general.h +++ b/lib/sparse/general.h @@ -24,6 +24,8 @@ * In particular, note that Verbose is declared but undefined. */ #ifndef STANDALONE +#include +#include #include #include #include @@ -61,6 +63,7 @@ #define POINTS(inch) 72*(inch) typedef unsigned int boolean; +extern unsigned char Verbose; #else /* STANDALONE */ #define MALLOC gmalloc @@ -78,7 +81,6 @@ typedef unsigned int boolean; extern double _statistics[10]; #endif -extern unsigned char Verbose; extern int irand(int n); extern real drand(void); -- 2.40.0