From: erg Date: Wed, 19 Mar 2008 21:43:58 +0000 (+0000) Subject: Clean up smyrna files: X-Git-Tag: LAST_LIBGRAPH~32^2~4475 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=801a2653cf96e3f2ceb68da8d7ef832c24908437;p=graphviz Clean up smyrna files: remove unnecessary globals modify libraries not to rely on code in cmd/smyrna remove static declarations from .h files remove unnecessary libraries mark unused code and clean up warnings --- diff --git a/cmd/smyrna/hier.c b/cmd/smyrna/hier.c index 557c3140c..33e1d5c26 100644 --- a/cmd/smyrna/hier.c +++ b/cmd/smyrna/hier.c @@ -1,5 +1,19 @@ /* vim:set shiftwidth=4 ts=8: */ +/********************************************************** +* This software is part of the graphviz package * +* http://www.graphviz.org/ * +* * +* Copyright (c) 1994-2004 AT&T Corp. * +* and is licensed under the * +* Common Public License, Version 1.0 * +* by AT&T Corp. * +* * +* Information and Software Systems Research * +* AT&T Research, Florham Park NJ * +**********************************************************/ + + #include #include "hier.h" #include "memory.h" @@ -33,166 +47,181 @@ release (hierarchy); */ -static void -scale_coords (double* x_coords, double* y_coords, int n, hierparms_t* parms) +static void +scale_coords(double *x_coords, double *y_coords, int n, + hierparms_t * parms) { int i; double w = parms->ClientWidth; double h = parms->ClientHeight; double margin = parms->margin; - double minX,maxX,minY,maxY; + double minX, maxX, minY, maxY; double scale_ratioX; double scale_ratioY; double scale_ratio; - w*=parms->graphSize/100.0; h*=parms->graphSize/100.0; - w-=2*margin; h-=2*margin; - - minX=maxX=x_coords[0]; minY=maxY=y_coords[0]; - for (i=1; igraphSize / 100.0; + h *= parms->graphSize / 100.0; + w -= 2 * margin; + h -= 2 * margin; + + minX = maxX = x_coords[0]; + minY = maxY = y_coords[0]; + for (i = 1; i < n; i++) { if (x_coords[i] < minX) - minX=x_coords[i]; + minX = x_coords[i]; if (y_coords[i] < minY) - minY=y_coords[i]; + minY = y_coords[i]; if (x_coords[i] > maxX) - maxX=x_coords[i]; + maxX = x_coords[i]; if (y_coords[i] > maxY) - maxY=y_coords[i]; + maxY = y_coords[i]; } - for (i=0; invtxs[0], double); - double* y_coords = N_NEW(hp->nvtxs[0], double); - int max_level = hp->nlevels-1; // coarsest level + double *x_coords = N_NEW(hp->nvtxs[0], double); + double *y_coords = N_NEW(hp->nvtxs[0], double); + int max_level = hp->nlevels - 1; // coarsest level int ClientWidth = parms->ClientWidth; int ClientHeight = parms->ClientHeight; int margin = parms->margin; /* get all logical coordinates of active nodes */ - for (i=0; invtxs[max_level]; i++) { - counter = extract_active_logical_coords(hp, i, max_level, x_coords, y_coords, counter); + for (i = 0; i < hp->nvtxs[max_level]; i++) { + counter = + extract_active_logical_coords(hp, i, max_level, x_coords, + y_coords, counter); } /* distort logical coordinates in order to get uniform density * (equivalent to concentrating on the focus area) */ - if (fs->num_foci==0) { - scale_coords(x_coords, y_coords, counter, parms); - } - else switch (parms->rescale_type) { - case Polar: - rescale_layout_polar(x_coords, y_coords, fs->x_foci, fs->y_foci, fs->num_foci, counter, interval, ClientWidth, ClientHeight, margin); - break; - case Rectilinear: - rescale_layout(x_coords, y_coords, counter, interval, ClientWidth, ClientHeight, margin); - break; - case NoRescale: + if (fs->num_foci == 0) { scale_coords(x_coords, y_coords, counter, parms); - break; - } + } else + switch (parms->rescale_type) { + case Polar: + rescale_layout_polar(x_coords, y_coords, fs->x_foci, + fs->y_foci, fs->num_foci, counter, + interval, ClientWidth, ClientHeight, + margin); + break; + case Rectilinear: + rescale_layout(x_coords, y_coords, counter, interval, + ClientWidth, ClientHeight, margin); + break; + case NoRescale: + scale_coords(x_coords, y_coords, counter, parms); + break; + } /* Update the final physical coordinates of the active nodes */ - for (counter = 0,i=0; invtxs[max_level]; i++) { - counter = set_active_physical_coords(hp, i, max_level, x_coords, y_coords, counter); + for (counter = 0, i = 0; i < hp->nvtxs[max_level]; i++) { + counter = + set_active_physical_coords(hp, i, max_level, x_coords, + y_coords, counter); } - free (x_coords); - free (y_coords); + free(x_coords); + free(y_coords); } -vtx_data* -makeGraph (topview* tv, int* nedges) +vtx_data *makeGraph(topview * tv, int *nedges) { int i; - int ne = tv->Edgecount; /* upper bound */ + int ne = tv->Edgecount; /* upper bound */ int nv = tv->Nodecount; vtx_data *graph = N_NEW(nv, vtx_data); - int *edges = N_NEW(2 * ne + nv, int); /* reserve space for self loops */ - Agnode_t* np; - Agedge_t* ep; - Agraph_t* g = NULL; + int *edges = N_NEW(2 * ne + nv, int); /* reserve space for self loops */ + Agnode_t *np; + Agedge_t *ep; + Agraph_t *g = NULL; int i_nedges; ne = 0; for (i = 0; i < nv; i++) { - graph[i].edges = edges++; /* reserve space for the self loop */ - graph[i].ewgts = NULL; - graph[i].styles = NULL; - i_nedges = 1; /* one for the self */ - - np = tv->Nodes[i].Node; - if (!g) g = agraphof (np); + graph[i].edges = edges++; /* reserve space for the self loop */ + graph[i].ewgts = NULL; + graph[i].styles = NULL; + i_nedges = 1; /* one for the self */ + + np = tv->Nodes[i].Node; + if (!g) + g = agraphof(np); for (ep = agfstedge(g, np); ep; ep = agnxtedge(g, ep, np)) { - Agnode_t* vp; - Agnode_t* tp = agtail(ep); - Agnode_t* hp = aghead(ep); - assert (hp != tp); - /* FIX: handle multiedges */ + Agnode_t *vp; + Agnode_t *tp = agtail(ep); + Agnode_t *hp = aghead(ep); + assert(hp != tp); + /* FIX: handle multiedges */ vp = (tp == np ? hp : tp); ne++; - *edges++ = ((custom_object_data*)AGDATA(vp))->TVRef; + *edges++ = ((custom_object_data *) AGDATA(vp))->TVRef; } - graph[i].nedges = i_nedges; - graph[i].edges[0] = i; + graph[i].nedges = i_nedges; + graph[i].edges[0] = i; } - ne /= 2; /* each edge counted twice */ + ne /= 2; /* each edge counted twice */ *nedges = ne; return graph; } -Hierarchy* -makeHier (int nn, int ne, vtx_data* graph, double* x_coords, double* y_coords) +Hierarchy *makeHier(int nn, int ne, vtx_data * graph, double *x_coords, + double *y_coords) { - vtx_data* delaunay; - ex_vtx_data* geom_graph; + vtx_data *delaunay; + ex_vtx_data *geom_graph; int ngeom_edges; - Hierarchy* hp = NEW(Hierarchy); + Hierarchy *hp = NEW(Hierarchy); delaunay = UG_graph(x_coords, y_coords, nn, 0); - ngeom_edges = init_ex_graph(delaunay, graph, nn, x_coords, y_coords, &geom_graph); - free (delaunay[0].edges); free (delaunay); + ngeom_edges = + init_ex_graph(delaunay, graph, nn, x_coords, y_coords, + &geom_graph); + free(delaunay[0].edges); + free(delaunay); - hp = create_hierarchy(graph, nn, ne, geom_graph, ngeom_edges, 20); - free (geom_graph[0].edges); free (geom_graph); + hp = create_hierarchy(graph, nn, ne, geom_graph, ngeom_edges, 20); + free(geom_graph[0].edges); + free(geom_graph); set_horizontal_active_level(hp, 0); return hp; } -focus_t* initFocus (int ncnt) + +focus_t *initFocus(int ncnt) { - focus_t* fs = NEW(focus_t); + focus_t *fs = NEW(focus_t); fs->num_foci = 0; fs->foci_nodes = N_NEW(ncnt, int); fs->x_foci = N_NEW(ncnt, double); - fs->y_foci = N_NEW(ncnt,double); + fs->y_foci = N_NEW(ncnt, double); return fs; } - diff --git a/cmd/smyrna/hier.h b/cmd/smyrna/hier.h index 433954d6f..aee84d583 100644 --- a/cmd/smyrna/hier.h +++ b/cmd/smyrna/hier.h @@ -1,3 +1,18 @@ +/* vim:set shiftwidth=4 ts=8: */ + +/********************************************************** +* This software is part of the graphviz package * +* http://www.graphviz.org/ * +* * +* Copyright (c) 1994-2004 AT&T Corp. * +* and is licensed under the * +* Common Public License, Version 1.0 * +* by AT&T Corp. * +* * +* Information and Software Systems Research * +* AT&T Research, Florham Park NJ * +**********************************************************/ + #ifndef HIER_H #define HIER_H @@ -5,9 +20,9 @@ #include "topview.h" typedef struct { int num_foci; - int* foci_nodes; - double* x_foci; - double* y_foci; + int *foci_nodes; + double *x_foci; + double *y_foci; } focus_t; typedef struct { @@ -15,12 +30,13 @@ typedef struct { int ClientWidth; int ClientHeight; int margin; - RescaleType rescale_type; // use Polar by default + RescaleType rescale_type; // use Polar by default } hierparms_t; -void positionAllItems (Hierarchy* hp, focus_t* fs, hierparms_t* parms); -vtx_data* makeGraph (topview* tv, int* nedges); -Hierarchy* makeHier (int nnodes, int nedges, vtx_data*, double*, double*); -focus_t* initFocus (int ncnt); +void positionAllItems(Hierarchy * hp, focus_t * fs, hierparms_t * parms); +vtx_data *makeGraph(topview * tv, int *nedges); +Hierarchy *makeHier(int nnodes, int nedges, vtx_data *, double *, + double *); +focus_t *initFocus(int ncnt); #endif diff --git a/cmd/smyrna/main.c b/cmd/smyrna/main.c index 122b81d0c..4dacea8d1 100755 --- a/cmd/smyrna/main.c +++ b/cmd/smyrna/main.c @@ -30,58 +30,63 @@ #include "viewport.h" #include "menucallbacks.h" #include "gltemplate.h" +#ifdef ENABLE_NLS +#include "libintl.h" +#endif -gchar *package_prefix ; +gchar *package_prefix; gchar *package_data_dir; gchar *package_locale_dir; -int main (int argc, char *argv[]) +int main(int argc, char *argv[]) { - GdkGLConfig *glconfig; - load_attributes(); + GdkGLConfig *glconfig; + load_attributes(); #ifdef G_OS_WIN32 - package_prefix = g_win32_get_package_installation_directory (NULL, NULL); - package_data_dir = g_build_filename (package_prefix, "share", NULL); - package_locale_dir = g_build_filename (package_prefix, "share", "locale", NULL); -#endif# + package_prefix = + g_win32_get_package_installation_directory(NULL, NULL); + package_data_dir = g_build_filename(package_prefix, "share", NULL); + package_locale_dir = + g_build_filename(package_prefix, "share", "locale", NULL); +#endif /* # */ #ifdef ENABLE_NLS - bindtextdomain (GETTEXT_PACKAGE, package_locale_dir); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); + bindtextdomain(GETTEXT_PACKAGE, package_locale_dir); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); #endif - view=malloc(sizeof(ViewInfo)); - init_viewport(view); + view = malloc(sizeof(ViewInfo)); + init_viewport(view); - gtk_set_locale (); - gtk_init (&argc, &argv); + gtk_set_locale(); + gtk_init(&argc, &argv); #ifdef _WIN32 #define GTKTOPVIEW_ICONSDIR "C:\\Projects\\ATT\\GTK\\GTKTest2\\GUI\\images\\" #endif - xml = glade_xml_new(SMYRNA_GLADE, NULL, NULL); - gladewidget = glade_xml_get_widget(xml, "frmMain"); - gtk_widget_show (gladewidget); - g_signal_connect ((gpointer) gladewidget, "destroy", G_CALLBACK(mQuitSlot), - NULL); - glade_xml_signal_autoconnect(xml); - gtk_gl_init (0,0); - /* Configure OpenGL framebuffer. */ - glconfig = configure_gl (); - gladewidget = glade_xml_get_widget(xml, "vbox2"); - create_window (glconfig,gladewidget); - /*first arg is used as file name*/ - if(argc>1) - add_graph_to_viewport_from_file (argv[1]); - gtk_main (); + xml = glade_xml_new(SMYRNA_GLADE, NULL, NULL); + gladewidget = glade_xml_get_widget(xml, "frmMain"); + gtk_widget_show(gladewidget); + g_signal_connect((gpointer) gladewidget, "destroy", + G_CALLBACK(mQuitSlot), NULL); + glade_xml_signal_autoconnect(xml); + gtk_gl_init(0, 0); + /* Configure OpenGL framebuffer. */ + glconfig = configure_gl(); + gladewidget = glade_xml_get_widget(xml, "vbox2"); + create_window(glconfig, gladewidget); + /*first arg is used as file name */ + if (argc > 1) + add_graph_to_viewport_from_file(argv[1]); + gtk_main(); #ifdef G_OS_WIN32 - g_free (package_prefix); - g_free (package_data_dir); - g_free (package_locale_dir); + g_free(package_prefix); + g_free(package_data_dir); + g_free(package_locale_dir); #endif - clear_viewport(view); - return 0; + clear_viewport(view); + return 0; }