From a06005cbf85594588adfb0c7e333877098e0533d Mon Sep 17 00:00:00 2001 From: glenlow Date: Mon, 25 May 2009 08:18:50 +0000 Subject: [PATCH] Support building with Visual Studio 2005+ --- lib/neatogen/neatoinit.c | 74 +++++++-------------------------------- lib/patchwork/patchwork.c | 10 +++--- 2 files changed, 16 insertions(+), 68 deletions(-) diff --git a/lib/neatogen/neatoinit.c b/lib/neatogen/neatoinit.c index 90f8a65b7..58459a2f3 100644 --- a/lib/neatogen/neatoinit.c +++ b/lib/neatogen/neatoinit.c @@ -654,12 +654,6 @@ static void translate(Agraph_t * g, pos_edge posEdges) * clusters, edges and labels. If certain position information * is missing, init_nop will use a standard neato technique to * supply it. - * - * If adjust is false, init_nop does nothing but initialize all - * of the basic graph information. No tweaking of positions or - * filling in edge splines is done. - * - * Returns 0 on success. */ int init_nop(Agraph_t * g, int adjust) { @@ -668,7 +662,6 @@ int init_nop(Agraph_t * g, int adjust) pos_edge posEdges; /* How many edges have spline info */ attrsym_t *G_lp = agfindgraphattr(g, "lp"); attrsym_t *G_bb = agfindgraphattr(g, "bb"); - int didAdjust = 0; /* Have nodes been moved? */ /* If G_bb not defined, define it */ if (!G_bb) @@ -689,20 +682,13 @@ int init_nop(Agraph_t * g, int adjust) nop_init_graphs(g, G_lp, G_bb); posEdges = nop_init_edges(g); - if (adjust && (Nop == 1)) - didAdjust = adjustNodes(g); - - if (didAdjust) { - if (GD_label(g)) GD_label(g)->set = FALSE; -/* FIX: - * - if nodes are moved, clusters are no longer valid. - */ - } + if (adjust && Nop == 1) + adjustNodes(g); /* If g does not have a good "bb" attribute or we adjusted the nodes, * compute it. */ - if (!chkBB(g, G_bb) || didAdjust) + if (!chkBB(g, G_bb) || (adjust && Nop == 1)) compute_bb(g); /* At this point, all bounding boxes should be correctly defined. @@ -745,7 +731,7 @@ static int neatoModel(graph_t * g) char *p = agget(g, "model"); char c; - if (!p || (!(c = *p))) /* if p is NULL or "" */ + if (!p || (!(c = *p))) return MODEL_SHORTPATH; if ((c == 'c') && streq(p, "circuit")) return MODEL_CIRCUIT; @@ -755,20 +741,6 @@ static int neatoModel(graph_t * g) else if (streq(p, "shortpath")) return MODEL_SHORTPATH; } - if ((c == 'm') && streq(p, "mds")) { -#ifndef WITH_CGRAPH - if (agindex(g->root->proto->e, "len") >= 0) -#else /* WITH_CGRAPH */ - if (agattr(g, AGEDGE, "len", 0)) -#endif /* WITH_CGRAPH */ - return MODEL_MDS; - else { - agerr(AGWARN, - "edges in graph %s have no len attribute. Hence, the mds model\n", agnameof(g)); - agerr(AGPREV, "is inappropriate. Reverting to the shortest path model.\n"); - return MODEL_SHORTPATH; - } - } agerr(AGWARN, "Unknown value %s for attribute \"model\" in graph %s - ignored\n", p, agnameof(g)); @@ -1117,7 +1089,7 @@ setSeed (graph_t * G, int dflt, long* seedp) long seed; /* Check for seed value */ if (!isdigit(*(unsigned char *)p) || sscanf(p, "%ld", &seed) < 1) { -#ifdef MSWIN32 +#if defined(MSWIN32) || defined(WIN32) seed = (unsigned) time(NULL); #else seed = (unsigned) getpid() ^ (unsigned) time(NULL); @@ -1185,8 +1157,8 @@ void dumpData(graph_t * g, vtx_data * gp, int nv, int ne) /* majorization: * Solve stress using majorization. * Old neato attributes to incorporate: - * weight - * mode will be MODE_MAJOR, MODE_HIER or MODE_IPSEP + * weight? + * model will be MODE_MAJOR, MODE_HIER or MODE_IPSEP */ static void majorization(graph_t *mg, graph_t * g, int nv, int mode, int model, int dim, int steps) @@ -1337,27 +1309,6 @@ static void subset_model(Agraph_t * G, int nG) freeGraphData(gp); } -/* mds_model: - * Assume the matrix already contains shortest path values. - * Use the actual lengths provided the input for edges. - */ -static void mds_model(graph_t * g, int nG) -{ - long i, j; - node_t *v; - edge_t *e; - - for (v = agfstnode(g); v; v = agnxtnode(g, v)) { - for (e = agfstout(g, v); e; e = agnxtout(g, e)) { - i = AGID(agtail(e)); - j = AGID(aghead(e)); - if (i == j) - continue; - GD_dist(g)[i][j] = GD_dist(g)[j][i] = GD_dist(e); - } - } -} - /* kkNeato: * Solve using gradient descent a la Kamada-Kawai. */ @@ -1377,9 +1328,6 @@ static void kkNeato(Agraph_t * g, int nG, int model) agerr(AGPREV, "the graph into connected components.\n"); shortest_path(g, nG); } - } else if (model == MODEL_MDS) { - shortest_path(g, nG); - mds_model(g, nG); } else shortest_path(g, nG); initial_positions(g, nG); @@ -1448,7 +1396,6 @@ void neato_layout(Agraph_t * g) int layoutMode; int model; pack_mode mode; - pack_info pinfo; if (Nop) { int save = PSinputscale; @@ -1466,7 +1413,7 @@ void neato_layout(Agraph_t * g) neato_init_graph(g); layoutMode = neatoMode(g); model = neatoModel(g); - mode = getPackModeInfo (g, l_undef, &pinfo); + mode = getPackMode(g, l_undef); Pack = getPack(g, -1, CL_OFFSET); /* pack if just packmode defined. */ if (mode == l_undef) { @@ -1475,7 +1422,7 @@ void neato_layout(Agraph_t * g) */ if ((Pack < 0) && layoutMode) Pack = CL_OFFSET; - pinfo.mode = l_node; + mode = l_node; } else if (Pack < 0) Pack = CL_OFFSET; if (Pack >= 0) { @@ -1483,6 +1430,7 @@ void neato_layout(Agraph_t * g) graph_t **cc; int n_cc; int i; + pack_info pinfo; boolean pin; cc = pccomps(g, &n_cc, cc_pfx, &pin); @@ -1501,6 +1449,8 @@ void neato_layout(Agraph_t * g) } else bp = 0; pinfo.margin = Pack; + pinfo.doSplines = 0; + pinfo.mode = mode; pinfo.fixed = bp; packGraphs(n_cc, cc, 0, &pinfo); if (bp) diff --git a/lib/patchwork/patchwork.c b/lib/patchwork/patchwork.c index 9fa09abb5..f3bb9f57d 100644 --- a/lib/patchwork/patchwork.c +++ b/lib/patchwork/patchwork.c @@ -5,6 +5,10 @@ extern void patchwork_init_graph(graph_t * g); +#ifndef HAVE_DRAND48 +extern double drand48(void); +#endif + typedef boxf rect_t; typedef struct treenode_t { @@ -157,14 +161,12 @@ static void printer(treenode_t *tree) static void finishNode (node_t* n) { -#ifdef OLD_AND_UNIMPROVED char* str = strdup_and_subst_obj(NODENAME_ESC, (void*)n); ND_shape(n) = bind_shape("box", n); ND_label(n) = make_label((void*)n, str, LT_NONE, late_double(n, N_fontsize, DEFAULT_FONTSIZE, MIN_FONTSIZE), late_nnstring(n, N_fontname, DEFAULT_FONTNAME), late_nnstring(n, N_fontcolor, DEFAULT_COLOR)); -#endif ND_shape(n)->fns->initfn(n); } @@ -206,10 +208,6 @@ static rect_t walker(treenode_t *tree) r = walker(p); EXPANDBB(rr,r); } - rr.LL.x -= 2./72.; - rr.LL.y -= 2./72.; - rr.UR.x += 2./72.; - rr.UR.y += 2./72.; GD_bb(tree->u.subg) = rr; } return rr; -- 2.40.0