From: erg Date: Fri, 19 Mar 2010 16:07:03 +0000 (+0000) Subject: Fixed various attribute use problems; X-Git-Tag: LAST_LIBGRAPH~32^2~1383 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a5988b604f6f33c89571d4272ffdde0c7aa34481;p=graphviz Fixed various attribute use problems; removed static Agsym_t* in functions and store these now with the graph; use macros for record access; cleaned up unused parts of the GUI. --- diff --git a/cmd/smyrna/Makefile.am b/cmd/smyrna/Makefile.am index f2ba009fe..af2082da2 100644 --- a/cmd/smyrna/Makefile.am +++ b/cmd/smyrna/Makefile.am @@ -35,23 +35,23 @@ bin_PROGRAMS += smyrna_static endif endif -noinst_HEADERS = arcball.h btree.h draw.h drawxdot.h filter.h glexpose.h \ +noinst_HEADERS = arcball.h btree.h draw.h filter.h glexpose.h \ glmotion.h gltemplate.h gui/appmouse.h gui/callbacks.h \ hotkeymap.h materials.h md5.h polytess.h selectionfuncs.h \ smyrna_utils.h smyrnadefs.h support.h topfisheyeview.h \ topviewdata.h topviewdefs.h topviewfuncs.h trackball.h tvnodes.h \ viewport.h viewportcamera.h \ - gui/datalistcallbacks.h gui/filterscallbacks.h gui/frmobjectui.h \ + gui/datalistcallbacks.h gui/frmobjectui.h \ gui/glcompui.h gui/gui.h gui/menucallbacks.h \ gui/toolboxcallbacks.h gui/topviewsettings.h gvprpipe.h hier.h -smyrna_SOURCES = arcball.c btree.c draw.c drawxdot.c filter.c glexpose.c \ +smyrna_SOURCES = arcball.c btree.c draw.c filter.c glexpose.c \ glmotion.c gltemplate.c gui/appmouse.c gui/callbacks.c \ gvprpipe.c hier.c hotkeymap.c main.c md5.c polytess.c \ - selectionfuncs.c smyrna_utils.c support.c template.c topfisheyeview.c \ + selectionfuncs.c smyrna_utils.c support.c topfisheyeview.c \ topviewdata.c topviewfuncs.c trackball.c tvnodes.c \ viewport.c viewportcamera.c \ - gui/datalistcallbacks.c gui/filterscallbacks.c gui/frmobjectui.c \ + gui/datalistcallbacks.c gui/frmobjectui.c \ gui/glcompui.c gui/gui.c gui/menucallbacks.c \ gui/toolboxcallbacks.c gui/topviewsettings.c diff --git a/cmd/smyrna/btree.c b/cmd/smyrna/btree.c index 4bb597847..01861eff8 100644 --- a/cmd/smyrna/btree.c +++ b/cmd/smyrna/btree.c @@ -119,13 +119,11 @@ int print_tree(btree_node * root) int print_children(btree_node * n) { int i = 0; - static int prev_rank = 0; if (n->node_type == 2) printf(" %*s=%s(%i)\n", n->rank * 5 + 1, n->attr_name, n->regex, n->rank); else printf("%*s %c(%i)\n", n->rank * 5 + 1, "", n->op, n->rank); - prev_rank = n->rank; for (i = 0; i < n->child_count; i++) { print_children(n->childs[i]); diff --git a/cmd/smyrna/drawxdot.c b/cmd/smyrna/drawxdot.c deleted file mode 100644 index 89aa41bca..000000000 --- a/cmd/smyrna/drawxdot.c +++ /dev/null @@ -1,352 +0,0 @@ -/* $Id$ $Revision$ */ -/* 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 * -**********************************************************/ - -/* - -XDOT DRAWING FUNCTIONS, maybe need to move them somewhere else - for now keep them at the bottom -*/ -#include "draw.h" -#include "drawxdot.h" -/* #include "topview.h" */ -#include "colorprocs.h" -#include "glutils.h" -#include "math.h" - -#include "xdot.h" -#include "viewport.h" -#include "topfisheyeview.h" - -/* static float globalz = 0.0; */ - -#ifdef UNUSED -//delta values -static float dx = 0.0; -static float dy = 0.0; - -static void set_options(sdot_op * op, int param) -{ - - if ((param == 1) && (view->mouse.mouse_mode == 10) && (view->mouse.mouse_down == 1)) //selected, if there is move, move it - { - dx = view->GLx - view->GLx2; - dy = view->GLy - view->GLy2; - } else { - dx = 0; - dy = 0; - } - -} - -static void SetFont(xdot_op * op, int param) -{ - //activate the right font - view->fontset->activefont = add_font(view->fontset, op->u.font.name); //load or set active font - view->FontSize = (int) op->u.font.size; -} - -static void relocate_spline(sdot_op * sop, int param) -{ - Agedge_t *e; - Agnode_t *tn; //tail node - Agnode_t *hn; //head node - int i = 0; - xdot_op *op = &sop->op; - if (AGTYPE(sop->obj) == AGEDGE) { - e = sop->obj; - tn = agtail(e); - hn = aghead(e); - if ((OD_Selected(hn) == 1) && (OD_Selected(tn) == 0)) { - set_options(sop, 1); - for (i = 1; i < op->u.bezier.cnt - 1; i = i + 1) { - if ((dx != 0) || (dy != 0)) { - op->u.bezier.pts[i].x = - op->u.bezier.pts[i].x - - (int) (dx * (float) i / - (float) (op->u.bezier.cnt)); - op->u.bezier.pts[i].y = - op->u.bezier.pts[i].y - - (int) (dy * (float) i / - (float) (op->u.bezier.cnt)); - } - } - if ((dx != 0) || (dy != 0)) { - op->u.bezier.pts[op->u.bezier.cnt - 1].x = - op->u.bezier.pts[op->u.bezier.cnt - 1].x - (int) dx; - op->u.bezier.pts[op->u.bezier.cnt - 1].y = - op->u.bezier.pts[op->u.bezier.cnt - 1].y - (int) dy; - } - } else if ((OD_Selected(hn) == 0) && (OD_Selected(tn) == 1)) { - set_options(sop, 1); - for (i = op->u.bezier.cnt - 1; i > 0; i = i - 1) { - if ((dx != 0) || (dy != 0)) { - op->u.bezier.pts[i].x = - op->u.bezier.pts[i].x - - (int) (dx * (float) (op->u.bezier.cnt - i) / - (float) (op->u.bezier.cnt)); - op->u.bezier.pts[i].y = - op->u.bezier.pts[i].y - - (int) (dy * (float) (op->u.bezier.cnt - i) / - (float) (op->u.bezier.cnt)); - } - } - if ((dx != 0) || (dy != 0)) { - op->u.bezier.pts[0].x = op->u.bezier.pts[0].x - (int) dx; - op->u.bezier.pts[0].y = op->u.bezier.pts[0].y - (int) dy; - } - } else if ((OD_Selected(hn) == 1) && (OD_Selected(tn) == 1)) { - set_options(sop, 1); - for (i = 0; i < op->u.bezier.cnt; i = i + 1) { - if ((dx != 0) || (dy != 0)) { - op->u.bezier.pts[i].x = - op->u.bezier.pts[i].x - (int) dx; - op->u.bezier.pts[i].y = - op->u.bezier.pts[i].y - (int) dy; - } - } - } - } -} - -static void DrawBeziers(xdot_op * op, int param) -{ - //SEND ALL CONTROL POINTS IN 3D ARRAYS - - GLfloat tempX[4]; - GLfloat tempY[4]; - GLfloat tempZ[4]; - int temp = 0; - int filled; - int i = 0; -// SelectBeziers((sdot_op *) op); - relocate_spline((sdot_op *) op, param); - if (op->kind == xd_filled_bezier) - filled = 1; - else - filled = 0; - - for (i = 0; i < op->u.bezier.cnt; i = i + 1) { - if (temp == 4) { - DrawBezier(tempX, tempY, tempZ, filled, param); - tempX[0] = (GLfloat) op->u.bezier.pts[i - 1].x; - tempY[0] = (GLfloat) op->u.bezier.pts[i - 1].y; - tempZ[0] = (GLfloat) op->u.bezier.pts[i - 1].z; - temp = 1; - tempX[temp] = (GLfloat) op->u.bezier.pts[i].x; - tempY[temp] = (GLfloat) op->u.bezier.pts[i].y; - tempZ[temp] = (GLfloat) op->u.bezier.pts[i].z; - temp = temp + 1; - } else { - tempX[temp] = (GLfloat) op->u.bezier.pts[i].x; - tempY[temp] = (GLfloat) op->u.bezier.pts[i].y; - tempZ[temp] = (GLfloat) op->u.bezier.pts[i].z; - temp = temp + 1; - } - } - DrawBezier(tempX, tempY, tempZ, filled, param); -} -#endif - -/*function to load .raw files*/ -#ifdef UNUSED -static void -load_raw_texture(char *file_name, int width, int height, int depth, - GLenum colour_type, GLenum filter_type) -{ - //Line 3 creates a pointer to an (as yet unallocated) array of gl unsigned bytes - - //this will store our image until we've passed it to opengl. Line 4 stores the file pointer, don't worry about that. - GLubyte *raw_bitmap; - FILE *file; - - //The if statement from line 6-10 opens the file and reports an error if it doesn't exist. - - if ((file = fopen(file_name, "rb")) == NULL) { - printf("File Not Found : %s\n", file_name); - exit(1); - } - //Line 11 allocates the correct number of bytes for the size and depth of the image. Remember, our image depth will usually be 3 -- one 'channel' each for red, green and blue values. - //Lines 13-18 check if the memory was allocated correctly and quit the program if there was a problem. - - raw_bitmap = N_GNEW(width * height * depth, GLubyte); - - if (raw_bitmap == NULL) { - printf("Cannot allocate memory for texture\n"); - fclose(file); - exit(1); - } - //Line 19 reads the required number of bytes from the file and places them into our glubyte array. Line 20 closes the close as it isn't required anymore. - fread(raw_bitmap, width * height * depth, 1, file); - fclose(file); - - //Lines 22-25 set the texture's mapping type and environment settings. GL_TEXTURE_MAG_FILTER and GL_TEXTURE_MIN_FILTER are enumerands that let us change the way in which opengl magnifies and minifies the texture. If we passed GL_LINEAR to the function, our texture would be interpolated using bilinear filtering (in other words, it'd appear smoothed). If we passed GL_NEAREST then no smoothing would occur. By passing GL_MODULATE to the texture environment function, we tell opengl to blend the texture with the base colour of the object. Had we specified GL_DECAL or GL_REPLACE then the base colour (and therefore our lighting effect) would be replaced purely with the colours of the texture. - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter_type); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter_type); - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - //Line 27 passes the image to opengl using the function gluBuild2DMipmaps. - //Read a graphics book for a description of mipmaps. - //This function will also resize the texture map if it doesn't conform - //to the opengl restriction of height and width values being a power of 2. - gluBuild2DMipmaps(GL_TEXTURE_2D, colour_type, width, height, - colour_type, GL_UNSIGNED_BYTE, raw_bitmap); - - //We don't need our texture in the temporary array anymore as it has been passed to opengl. - //We use the standard C library call 'free' to return the allocated memory. - free(raw_bitmap); -} -#endif - - -#if 0 -static void drawXdot(xdot * xDot, int param, void *p) -{ - int id; - sdot_op *ops = (sdot_op *) (xDot->ops); - sdot_op *op; - //to avoid the overlapping , z is slightly increased for each xdot of a particular object - if (AGTYPE(p) == AGEDGE) - globalz = 1; - else - globalz = 0; - - for (id = 0; id < xDot->cnt; id++) { - globalz += GLOBAL_Z_OFFSET; - op = ops + id; - op->obj = p; - op->op.drawfunc(&(op->op), param); - } -} - - - -static void drawXdotwithattr(void *p, char *attr, int param) -{ - xdot *xDot; - if ((xDot = parseXDotF(agget(p, attr), OpFns, sizeof(sdot_op)))) { - drawXdot(xDot, param, p); - freeXDot(xDot); - } -} - -static void drawXdotwithattrs(void *e, int param) -{ - drawXdotwithattr(e, "_draw_", param); - drawXdotwithattr(e, "_ldraw_", param); - drawXdotwithattr(e, "_hdraw_", param); - drawXdotwithattr(e, "_tdraw_", param); - drawXdotwithattr(e, "_hldraw_", param); - drawXdotwithattr(e, "_tldraw_", param); -} -#endif - - - -/* - this function is used to cache fonts in view->fontset -*/ - -#if UNUSED -static void scanXdot(xdot * xDot, void *p) -{ - int id; - sdot_op *ops = (sdot_op *) (xDot->ops); - sdot_op *op; - - for (id = 0; id < xDot->cnt; id++) { - op = ops + id; - op->obj = p; - if (op->op.kind == xd_font) { - add_font(view->fontset, op->op.u.font.name); //load or set active font - } - } -} - - -static void scanXdotwithattr(void *p, char *attr) -{ - xdot *xDot; - if ((xDot = parseXDotF(agget(p, attr), OpFns, sizeof(sdot_op)))) { - scanXdot(xDot, p); - freeXDot(xDot); - } -} - -static void scanXdotwithattrs(void *e) -{ - scanXdotwithattr(e, "_draw_"); - scanXdotwithattr(e, "_ldraw_"); - scanXdotwithattr(e, "_hdraw_"); - scanXdotwithattr(e, "_tdraw_"); - scanXdotwithattr(e, "_hldraw_"); - scanXdotwithattr(e, "_tldraw_"); -} - - - - -/* - iterate in nodes and edges to cache fonts, run this once or whenever a new font is added to the graph -*/ - - -void scanGraph(Agraph_t * g) -{ - Agnode_t *v; - Agedge_t *e; - for (v = agfstnode(g); v; v = agnxtnode(g, v)) { - scanXdotwithattr(v, "_draw_"); - scanXdotwithattr(v, "_ldraw_"); - for (e = agfstout(g, v); e; e = agnxtout(g, e)) { - scanXdotwithattrs(e); - } - } - -} -#endif - - - -#ifdef UNUSED -char *create_us_map() -{ - float x1, y1, x2, y2; - float ox1, oy1, ox2, oy2; - static const char filename[] = "file.txt"; - FILE *file = fopen(filename, "r"); - char line[128]; /* or other suitable maximum line size */ - int firstline = 1; - while (fgets(line, sizeof line, file) != NULL) { /* read a line */ - fputs(line, stdout); /* write the line */ - sscanf(line, "%f %f %f %f", &x1, &y1, &x2, &y2); - - if (firstline) { - ox1 = x1; - oy1 = y1; - ox2 = x2; - oy2 = y2; - firstline = 0; - } else if ((x1 == ox1) && (y1 == oy1) && (x2 == ox2) && (y2 == oy2)) { /*polygon is closed here */ - - - } - - - } - fclose(file); - return 0; -} -#endif diff --git a/cmd/smyrna/gui/appmouse.c b/cmd/smyrna/gui/appmouse.c index 8498ea9ec..7ce9e1a51 100644 --- a/cmd/smyrna/gui/appmouse.c +++ b/cmd/smyrna/gui/appmouse.c @@ -26,9 +26,9 @@ #include "topviewfuncs.h" - static float prevX=0; - static float prevY=0; - static int lastAction; +static float prevX=0; +static float prevY=0; +static int lastAction; static void apply_actions(ViewInfo* v,int x,int y) { int a; @@ -152,16 +152,12 @@ static void appmouse_up(ViewInfo* v,int x,int y) } static void appmouse_drag(ViewInfo* v,int x,int y) { - static float x2,y2; v->mouse.pos.x=x; v->mouse.pos.y=y; to3D( x,y, &v->mouse.GLpos.x,&v->mouse.GLpos.y,&v->mouse.GLpos.z); - x2=v->mouse.GLpos.x; - y2=v->mouse.GLpos.y; - prevX=x2; - prevY=y2; + prevX=v->mouse.GLpos.x; + prevY=v->mouse.GLpos.y; apply_actions(v,x,y); - } void appmouse_left_click_down(ViewInfo* v,int x,int y) diff --git a/cmd/smyrna/gui/gui.c b/cmd/smyrna/gui/gui.c index 95f6f1870..aae268ad8 100755 --- a/cmd/smyrna/gui/gui.c +++ b/cmd/smyrna/gui/gui.c @@ -250,6 +250,7 @@ char *get_attribute_string_value_from_widget(attribute * att) return guibuffer; } } +#if UNUSED void change_selected_graph_attributes(Agraph_t * g, char *attrname, char *attrvalue) { @@ -262,24 +263,31 @@ void change_selected_node_attributes(Agraph_t * g, char *attrname, char *attrvalue) { int ind = 0; - agattr(g, AGNODE, attrname, ""); + Agsym_t* ap = agattr(g, AGNODE, attrname, NULL); + + if (!ap) + ap = agattr(g, AGNODE, attrname, ""); + for (ind = 0; ind < view->Topview->Nodecount; ind++) { if (view->Topview->Nodes[ind].data.Selected == 1) - agset(view->Topview->Nodes[ind].Node, attrname, attrvalue); + agxset(view->Topview->Nodes[ind].Node, ap, attrvalue); } } void change_selected_edge_attributes(Agraph_t * g, char *attrname, char *attrvalue) { int ind = 0; - agattr(g, AGEDGE, attrname, ""); + Agsym_t* ap = agattr(g, AGEDGE, attrname, NULL); + if (!ap) + ap = agattr(g, AGEDGE, attrname, ""); + for (ind = 0; ind < view->Topview->Edgecount; ind++) { if (view->Topview->Edges[ind].data.Selected == 1) - agset(view->Topview->Edges[ind].Edge, attrname, attrvalue); - + agxset(view->Topview->Edges[ind].Edge, ap, attrvalue); } } +#endif void load_attributes(void) { diff --git a/cmd/smyrna/gui/topviewsettings.c b/cmd/smyrna/gui/topviewsettings.c index d1bd4b00e..941b80979 100644 --- a/cmd/smyrna/gui/topviewsettings.c +++ b/cmd/smyrna/gui/topviewsettings.c @@ -269,7 +269,7 @@ static int get_combobox_widget_to_attribute(char *attribute, sprintf(buf, "%f", value); agattr(g, AGRAPH, attribute, buf); - printf ("%s %f \n",attribute,value); + /* printf ("%s %f \n",attribute,value); */ return 1; @@ -296,6 +296,32 @@ int load_settings_from_graph(Agraph_t * g) return 1; } +/* graphRecord: + * add graphRec to graph if necessary. + * update fields of graphRec. + * We assume the graph has attributes nodelabelattribute, edgelabelattribute, + * nodelabelcolor and edgelabelcolor from template.dot. + * We assume nodes have pos attributes. + */ +static void +graphRecord (Agraph_t* g) +{ + agbindrec(g, "graphRec", sizeof(graphRec), 1); + + GG_nodelabelcolor(g) = agattr (g, AGRAPH, "nodelabelcolor", 0); + GG_edgelabelcolor(g) = agattr (g, AGRAPH, "edgelabelcolor", 0); + + GN_pos(g) = agattr (g, AGNODE, "pos", 0); + GN_size(g) = agattr (g, AGNODE, "size", 0); + GN_visible(g) = agattr (g, AGNODE, "visible", 0); + GN_selected(g) = agattr (g, AGNODE, "selected", 0); + GN_labelattribute(g) = agattr (g, AGNODE, agget(g,"nodelabelattribute"), 0); + + GE_visible(g) = agattr (g, AGEDGE, "visible", 0); + GE_selected(g) = agattr (g, AGEDGE, "selected", 0); + GE_labelattribute(g) = agattr (g, AGEDGE, agget(g,"edgelabelattribute"), 0); +} + int update_graph_from_settings(Agraph_t * g) { @@ -314,9 +340,8 @@ int update_graph_from_settings(Agraph_t * g) get_spinbtn_widget_to_attribute(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name),g); if(strncmp (sym->name,"scale_button",strlen("scale_button"))==0) get_scalebtn_widget_to_attribute(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name),g); - - } + graphRecord(g); return 1; } diff --git a/cmd/smyrna/polytess.c b/cmd/smyrna/polytess.c index 579b80bbd..36497e205 100644 --- a/cmd/smyrna/polytess.c +++ b/cmd/smyrna/polytess.c @@ -1,3 +1,19 @@ +/* $Id$Revision: */ +/* 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 "polytess.h" #include "xdot.h" tessPoly TP; @@ -163,6 +179,8 @@ static int Render_Contour2(GLUtesselator *tobj,sdot_op* p) return(1); } + +#if UNUSED static int Render_Contour(GLUtesselator *tobj, GLdouble obj_data[][3],int cnt) { @@ -174,7 +192,7 @@ static int Render_Contour(GLUtesselator *tobj, GLdouble obj_data[][3],int cnt) /* int y=0; */ if (!d) { - d=(GLdouble**) malloc(sizeof(GLdouble)* cnt); + d = (GLdouble**) malloc(sizeof(GLdouble)* cnt); for (x=0;x < cnt; x++) { /* GLdouble temp; */ @@ -211,6 +229,7 @@ static int Render_Contour(GLUtesselator *tobj, GLdouble obj_data[][3],int cnt) return(1); } +#endif diff --git a/cmd/smyrna/selectionfuncs.c b/cmd/smyrna/selectionfuncs.c index f110eab8f..e38f58c83 100644 --- a/cmd/smyrna/selectionfuncs.c +++ b/cmd/smyrna/selectionfuncs.c @@ -20,29 +20,27 @@ static void select_node(Agraph_t* g,Agnode_t* obj,int reverse) { - static Agsym_t* sel_attr=(Agsym_t*)0; + Agsym_t* sel_attr = GN_selected(g); + if(!sel_attr) - sel_attr=agattr(g, AGNODE,"selected","0"); + sel_attr = GN_selected(g) = agattr(g, AGNODE,"selected","0"); if(!reverse) { agxset(obj,sel_attr,"1"); - ((nodeRec*)(aggetrec(obj,"nodeRec",0)))->selected=1; + ND_selected(obj) = 1; } else { - if(((nodeRec*)(aggetrec(obj,"nodeRec",0)))->selected==1) + if(ND_selected(obj)==1) { agxset(obj,sel_attr,"0"); - ((nodeRec*)(aggetrec(obj,"nodeRec",0)))->selected=0; - ((nodeRec*)(aggetrec(obj,"nodeRec",0)))->printLabel=0; - - + ND_selected(obj) = 0; + ND_printLabel(obj) = 0; } else { agxset(obj,sel_attr,"1"); - ((nodeRec*)(aggetrec(obj,"nodeRec",0)))->selected=1; - + ND_selected(obj) = 1; } } @@ -51,26 +49,27 @@ static void select_node(Agraph_t* g,Agnode_t* obj,int reverse) } static void select_edge(Agraph_t* g,Agedge_t* obj,int reverse) { - static Agsym_t* sel_attr=(Agsym_t*)0; - if(!sel_attr) - sel_attr=agattr(g, AGEDGE,"selected","0"); + Agsym_t* sel_attr = GE_selected(g); + + if (!sel_attr) + sel_attr = GE_selected(g) = agattr(g, AGEDGE,"selected","0"); if (!reverse) { agxset(obj,sel_attr,"1"); - ((edgeRec*)(aggetrec(obj,"edgeRec",0)))->selected=1; + ED_selected(obj) = 1; } else { - if(((edgeRec*)(aggetrec(obj,"edgeRec",0)))->selected==1) + if (ED_selected(obj) == 1) { agxset(obj,sel_attr,"0"); - ((edgeRec*)(aggetrec(obj,"edgeRec",0)))->selected=0; - ((edgeRec*)(aggetrec(obj,"edgeRec",0)))->printLabel=0; + ED_selected(obj) = 0; + ED_printLabel(obj) = 0; } else { agxset(obj,sel_attr,"1"); - ((edgeRec*)(aggetrec(obj,"edgeRec",0)))->selected=1; + ED_selected(obj) = 1; } } @@ -80,31 +79,32 @@ static void select_edge(Agraph_t* g,Agedge_t* obj,int reverse) static void pick_objects_in_rect(Agraph_t* g,GLfloat x1,GLfloat y1,GLfloat x2,GLfloat y2) { - static Agnode_t *v; - static Agedge_t *e; - static glCompPoint posT; - static glCompPoint posH; - static glCompPoint posN; + Agnode_t *v; + Agedge_t *e; + glCompPoint posT; + glCompPoint posH; + glCompPoint posN; - for (v = agfstnode(g); v; v = agnxtnode(g, v)) + for (v = agfstnode(g); v; v = agnxtnode(g, v)) { if(view->Topview->sel.selectNodes==1) { - posN=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A; - if(!((nodeRec*)(aggetrec(v,"nodeRec",0)))->visible) + posN = ND_A(v); + if(!ND_visible(v)) continue; if(is_point_in_rectangle(posN.x,posN.y,x1,y1,x2-x1,y2-y1) ) select_node(g,v,0); } - if(view->Topview->sel.selectEdges==1) - for (e = agfstout(g, v); e; e = agnxtout(g, e)) + if(view->Topview->sel.selectEdges==1) { + for (e = agfstout(g, v); e; e = agnxtout(g, e)) { - posT=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posTail; - posH=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posHead; + posT = ED_posTail(e); + posH = ED_posHead(e); if(is_point_in_rectangle(posT.x,posT.y,x1,y1,x2-x1,y2-y1)) if(is_point_in_rectangle(posH.x,posH.y,x1,y1,x2-x1,y2-y1)) select_edge(g,e,0); } + } } } @@ -112,42 +112,31 @@ static void pick_objects_in_rect(Agraph_t* g,GLfloat x1,GLfloat y1,GLfloat x2,GL static void* pick_object(Agraph_t* g,glCompPoint p) { - static Agsym_t* size_attr=(Agsym_t*)0; - static Agsym_t* pos_attr=(Agsym_t*)0; - - static Agnode_t *v; - static Agedge_t *e; - static glCompPoint posT; - static glCompPoint posH; - static glCompPoint posN; + Agnode_t *v; + Agedge_t *e; + glCompPoint posT; + glCompPoint posH; + glCompPoint posN; int defaultNodeShape; - float dist=999999999; - static GLfloat nd=0; /*node distance to point*/ - static GLfloat ed=0; /*edge distance to point*/ - static GLfloat nodeSize=0; - void* rv=(void*)0; - nd=0; /*node distance to point*/ - ed=0; /*edge distance to point*/ - - defaultNodeShape=getAttrBool(g,g,"defaultnodeshape",0); - - if(!size_attr) - size_attr=agattr(g, AGNODE,"size",0); + float dist=999999999; + GLfloat nd; /*node distance to point*/ + GLfloat ed; /*edge distance to point*/ + GLfloat nodeSize=0; + void* rv=(void*)0; - if(!pos_attr) - pos_attr=agattr(g, AGNODE,"pos",0); + defaultNodeShape=getAttrBool(g,g,"defaultnodeshape",0); if(defaultNodeShape==0) nodeSize=GetOGLDistance(view->nodeScale*view->Topview->fitin_zoom/view->zoom); for (v = agfstnode(g); v; v = agnxtnode(g, v)) { - if(!((nodeRec*)(aggetrec(v,"nodeRec",0)))->visible) + if(!ND_visible(v)) continue; - posN=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A; + posN = ND_A(v); if(defaultNodeShape==1) { - nodeSize=((nodeRec*)(aggetrec(v,"nodeRec",0)))->size; + nodeSize = ND_size(v); } nd=distBetweenPts(posN,p,nodeSize); @@ -158,8 +147,8 @@ static void* pick_object(Agraph_t* g,glCompPoint p) for (e = agfstout(g, v); e; e = agnxtout(g, e)) { - posT=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posTail; - posH=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posHead; + posT = ED_posTail(e); + posH = ED_posHead(e); ed=point_to_lineseg_dist(p, posT,posH); if( ed < dist ) {rv=e;dist=ed;} } @@ -169,7 +158,7 @@ static void* pick_object(Agraph_t* g,glCompPoint p) void pick_object_xyz(Agraph_t* g,topview* t,GLfloat x,GLfloat y,GLfloat z) { - static glCompPoint p; + glCompPoint p; void* a; p.x=x;p.y=y;p.z=z; a=pick_object(g,p); @@ -177,9 +166,8 @@ void pick_object_xyz(Agraph_t* g,topview* t,GLfloat x,GLfloat y,GLfloat z) return; if(agobjkind(a)==AGNODE) { - select_node(g,a,1); - ((nodeRec*)(aggetrec(a,"nodeRec",0)))->printLabel=1; + ND_printLabel((Agnode_t*)a) = 1; cacheSelectedNodes(g,t); @@ -188,16 +176,16 @@ void pick_object_xyz(Agraph_t* g,topview* t,GLfloat x,GLfloat y,GLfloat z) { select_edge(g,a,1); cacheSelectedEdges(g,t); - ((edgeRec*)(aggetrec(a,"edgeRec",0)))->printLabel=1; + ED_printLabel((Agedge_t*)a) = 1; } } void pick_objects_rect(Agraph_t* g) { - static GLfloat x1; - static GLfloat y1; - static GLfloat x2; - static GLfloat y2; + GLfloat x1; + GLfloat y1; + GLfloat x2; + GLfloat y2; if(view->mouse.GLfinalPos.x > view->mouse.GLinitPos.x) { x1=view->mouse.GLinitPos.x; @@ -228,31 +216,31 @@ void pick_objects_rect(Agraph_t* g) void deselect_all(Agraph_t* g) { - static Agnode_t *v; - static Agedge_t *e; - static Agsym_t* nsel_attr=(Agsym_t*)0; - static Agsym_t* esel_attr=(Agsym_t*)0; + Agnode_t *v; + Agedge_t *e; + Agsym_t* nsel_attr = GN_selected(g); + Agsym_t* esel_attr = GE_selected(g); if(!nsel_attr) - nsel_attr=agattr(g, AGNODE,"selected","0"); + nsel_attr = GN_selected(g) = agattr(g, AGNODE,"selected","0"); if(!esel_attr) - esel_attr=agattr(g, AGEDGE,"selected","0"); + esel_attr = GE_selected(g) = agattr(g, AGEDGE,"selected","0"); for (v = agfstnode(g); v; v = agnxtnode(g, v)) { agxset(v,nsel_attr,"0"); - ((nodeRec*)(aggetrec(v,"nodeRec",0)))->selected=0; - ((edgeRec*)(aggetrec(v,"nodeRec",0)))->printLabel=0; + ND_selected(v) = 0; + ND_printLabel(v) = 0; for (e = agfstout(g, v); e; e = agnxtout(g, e)) { agxset(e,esel_attr,"0"); - ((edgeRec*)(aggetrec(e,"edgeRec",0)))->selected=0; - ((edgeRec*)(aggetrec(e,"edgeRec",0)))->printLabel=0; + ED_selected(e) = 0; + ED_printLabel(e) = 0; } } cacheSelectedNodes(g,view->Topview); cacheSelectedEdges(g,view->Topview); - } + void clear_selpoly(glCompPoly* sp) { sp->pts=realloc(sp->pts,0); @@ -274,12 +262,12 @@ static int close_poly(glCompPoly* selPoly,glCompPoint pt) static void select_polygon (Agraph_t* g,glCompPoly* selPoly) { - static Agnode_t *v; - static glCompPoint posN; + Agnode_t *v; + glCompPoint posN; - for (v = agfstnode(g); v; v = agnxtnode(g, v)) + for (v = agfstnode(g); v; v = agnxtnode(g, v)) { - posN=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A; + posN = ND_A(v); if(point_in_polygon(selPoly,posN)) select_node(g,v,0); } diff --git a/cmd/smyrna/smyrna_utils.c b/cmd/smyrna/smyrna_utils.c index 0d43ef214..ab206d891 100644 --- a/cmd/smyrna/smyrna_utils.c +++ b/cmd/smyrna/smyrna_utils.c @@ -14,7 +14,7 @@ * AT&T Research, Florham Park NJ * **********************************************************/ #include "smyrna_utils.h" -static int mapbool(char *p) +int mapbool(char *p) { if (p == NULL) return FALSE; @@ -110,18 +110,6 @@ int getAttrBool(Agraph_t* g,void* obj,char* attr_name,int def) attr = agattr(g, AGTYPE(obj), attr_name,0); return late_bool(obj, attr,def); } -/* Differs from getAttrBool in that a value of "" returns def */ -int getAttrBool1(Agraph_t* g,void* obj,char* attr_name,int def) -{ - Agsym_t* attr; - char* s; - if ((attr = agattr(g, AGTYPE(obj), attr_name,0))) { - s = agxget (obj, attr); - if (*s) return mapbool(s); - else return def; - } - else return def; -} int getAttrInt(Agraph_t* g,void* obj,char* attr_name,int def) { Agsym_t* attr; @@ -154,7 +142,7 @@ glCompPoint getPointFromStr(char* str) glCompPoint p; char* a; - static char bf[512]; + char bf[512]; strcpy(bf,str); p.x=0; p.y=0; diff --git a/cmd/smyrna/smyrna_utils.h b/cmd/smyrna/smyrna_utils.h index 1b37f5f2c..d5dbe4385 100644 --- a/cmd/smyrna/smyrna_utils.h +++ b/cmd/smyrna/smyrna_utils.h @@ -21,8 +21,8 @@ extern int l_int(void *obj, Agsym_t * attr, int def); extern float l_float(void *obj, Agsym_t * attr, float def); +extern int mapbool(char *p); extern int getAttrBool(Agraph_t* g,void* obj,char* attr_name,int def); -extern int getAttrBool1(Agraph_t* g,void* obj,char* attr_name,int def); extern int getAttrInt(Agraph_t* g,void* obj,char* attr_name,int def); extern float getAttrFloat(Agraph_t* g,void* obj,char* attr_name,float def); extern char* getAttrStr(Agraph_t* g,void* obj,char* attr_name,char* def); diff --git a/cmd/smyrna/smyrnadefs.h b/cmd/smyrna/smyrnadefs.h index 33a1db510..5340f43de 100644 --- a/cmd/smyrna/smyrnadefs.h +++ b/cmd/smyrna/smyrnadefs.h @@ -393,6 +393,14 @@ typedef struct int printLabel; int TVref; }nodeRec; +#define NREC(n) ((nodeRec*)(aggetrec(n,"nodeRec",0))) +#define ND_visible(n) (NREC(n)->visible) +#define ND_selected(n) (NREC(n)->selected) +#define ND_printLabel(n) (NREC(n)->printLabel) +#define ND_A(n) (NREC(n)->A) +#define ND_size(n) (NREC(n)->size) +#define ND_TVref(n) (NREC(n)->TVref) + typedef struct{ Agrec_t h; glCompPoint posTail; @@ -401,6 +409,37 @@ typedef struct int visible; int printLabel; }edgeRec; +#define EREC(e) ((edgeRec*)(aggetrec(e,"edgeRec",0))) +#define ED_visible(e) (EREC(e)->visible) +#define ED_selected(e) (EREC(e)->selected) +#define ED_printLabel(e) (EREC(e)->printLabel) +#define ED_posTail(e) (EREC(e)->posTail) +#define ED_posHead(e) (EREC(e)->posHead) + + typedef struct{ + Agrec_t h; + Agsym_t* N_pos; + Agsym_t* N_size; + Agsym_t* N_visible; + Agsym_t* N_selected; + Agsym_t* G_nodelabelcolor; + Agsym_t* N_labelattribute; + Agsym_t* E_visible; + Agsym_t* E_selected; + Agsym_t* G_edgelabelcolor; + Agsym_t* E_labelattribute; + } graphRec; +#define GREC(g) ((graphRec*)(AGDATA(g))) +#define GN_pos(g) (GREC(g)->N_pos) +#define GN_size(g) (GREC(g)->N_size) +#define GN_visible(g) (GREC(g)->N_visible) +#define GN_selected(g) (GREC(g)->N_selected) +#define GG_nodelabelcolor(g) (GREC(g)->G_nodelabelcolor) +#define GN_labelattribute(g) (GREC(g)->N_labelattribute) +#define GE_visible(g) (GREC(g)->E_visible) +#define GE_selected(g) (GREC(g)->E_selected) +#define GG_edgelabelcolor(g) (GREC(g)->G_edgelabelcolor) +#define GE_labelattribute(g) (GREC(g)->E_labelattribute) typedef struct _selection { glCompPoly selPoly; diff --git a/cmd/smyrna/template.c b/cmd/smyrna/template.c deleted file mode 100755 index 144a49e47..000000000 --- a/cmd/smyrna/template.c +++ /dev/null @@ -1,566 +0,0 @@ -/* $Id$Revision: */ -/* 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 -#include - -#include -#include - -#include -/*** Use OpenGL extensions. ***/ -/* #include */ - -#ifdef G_OS_WIN32 -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#include -#include - - -/************************************************************************** - * The following section contains all the macro definitions. - **************************************************************************/ - -/*** - *** Change these three macros to customise the - *** default width and height of the drawing - *** area, plus the default title of the window. - ***/ -#define DEFAULT_WIDTH 200 -#define DEFAULT_HEIGHT 200 -#define TIMEOUT_INTERVAL 10 - - -/************************************************************************** - * Global variable declarations. - **************************************************************************/ - - - -/************************************************************************** - * The following section contains the function prototype declarations. - **************************************************************************/ - -#ifdef UNUSED -static void timeout_add(GtkWidget * widget); -static void timeout_remove(GtkWidget * widget); - -static void toggle_animation(GtkWidget * widget); - -static GdkGLConfig *configure_gl(void); - -static GtkWidget *create_popup_menu(GtkWidget * drawing_area); -static GtkWidget *create_window(GdkGLConfig * glconfig); -#endif - - -/************************************************************************** - * The following section contains all the callback function definitions. - **************************************************************************/ - -/*** - *** The "realize" signal handler. All the OpenGL initialization - *** should be performed here, such as default background colour, - *** certain states etc. - ***/ -#ifdef UNUSED -static void realize(GtkWidget * widget, gpointer data) -{ - GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); - - g_print("%s: \"realize\"\n", gtk_widget_get_name(widget)); - - /*** OpenGL BEGIN ***/ - if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) - return; - - /*** Fill in the details here. ***/ - - gdk_gl_drawable_gl_end(gldrawable); - /*** OpenGL END ***/ -} -#endif - -#ifdef UNUSED -/*** - *** The "configure_event" signal handler. Any processing required when - *** the OpenGL-capable drawing area is re-configured should be done here. - *** Almost always it will be used to resize the OpenGL viewport when - *** the window is resized. - ***/ -static gboolean -configure_event(GtkWidget * widget, - GdkEventConfigure * event, gpointer data) -{ - GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); - - GLfloat w = widget->allocation.width; - GLfloat h = widget->allocation.height; - - g_print("%s: \"configure_event\"\n", gtk_widget_get_name(widget)); - - /*** OpenGL BEGIN ***/ - if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) - return FALSE; - - /*** Fill in the details here. ***/ - - glViewport(0, 0, w, h); - - gdk_gl_drawable_gl_end(gldrawable); - /*** OpenGL END ***/ - - return TRUE; -} - -/*** - *** The "expose_event" signal handler. All the OpenGL re-drawing should - *** be done here. This is repeatedly called as the painting routine - *** every time the 'expose'/'draw' event is signalled. - ***/ -static gboolean -expose_event(GtkWidget * widget, GdkEventExpose * event, gpointer data) -{ - GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); - - g_print("%s: \"expose_event\"\n", gtk_widget_get_name(widget)); - - /*** OpenGL BEGIN ***/ - if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) - return FALSE; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - /*** Fill in the details here. ***/ - - /* Swap buffers */ - if (gdk_gl_drawable_is_double_buffered(gldrawable)) - gdk_gl_drawable_swap_buffers(gldrawable); - else - glFlush(); - - gdk_gl_drawable_gl_end(gldrawable); - /*** OpenGL END ***/ - - return TRUE; -} - -/*** - *** The timeout function. Often in animations, - *** timeout functions are suitable for continous - *** frame updates. - ***/ -static gboolean timeout(GtkWidget * widget) -{ - g_print("."); - - /*** Fill in the details here ***/ - - /* Invalidate the whole window. */ - gdk_window_invalidate_rect(widget->window, &widget->allocation, FALSE); - - /* Update synchronously. */ - gdk_window_process_updates(widget->window, FALSE); - - return TRUE; -} - -/*** - *** The "unrealize" signal handler. Any processing required when - *** the OpenGL-capable window is unrealized should be done here. - ***/ -static void unrealize(GtkWidget * widget, gpointer data) -{ - GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); - - g_print("%s: \"unrealize\"\n", gtk_widget_get_name(widget)); - - /*** OpenGL BEGIN ***/ - if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) - return; - - /*** Fill in the details here. ***/ - - gdk_gl_drawable_gl_end(gldrawable); - /*** OpenGL END ***/ -} - -/*** - *** The "motion_notify_event" signal handler. Any processing required when - *** the OpenGL-capable drawing area is under drag motion should be done here. - ***/ -static gboolean -motion_notify_event(GtkWidget * widget, - GdkEventMotion * event, gpointer data) -{ - g_print("%s: \"motion_notify_event\": button", - gtk_widget_get_name(widget)); - - /*** Fill in the details here. ***/ - - if (event->state & GDK_BUTTON1_MASK) { - g_print(" 1"); - } - - if (event->state & GDK_BUTTON2_MASK) { - g_print(" 2"); - } - - if (event->state & GDK_BUTTON3_MASK) { - g_print(" 3"); - } - - g_print("\n"); - - return FALSE; -} - -/*** - *** The "button_press_event" signal handler. Any processing required when - *** mouse buttons (only left and middle buttons) are pressed on the OpenGL- - *** capable drawing area should be done here. - ***/ -static gboolean -button_press_event(GtkWidget * widget, - GdkEventButton * event, gpointer data) -{ - g_print("%s: \"button_press_event\": ", gtk_widget_get_name(widget)); - - if (event->button == 1) { - /*** Fill in the details here. ***/ - g_print("button 1\n"); - - return TRUE; - } - - if (event->button == 2) { - /*** Fill in the details here. ***/ - g_print("button 2\n"); - - return TRUE; - } - - g_print("\n"); - - return FALSE; -} - -/* For popup menu. */ -static gboolean -button_press_event_popup_menu(GtkWidget * widget, - GdkEventButton * event, gpointer data) -{ - g_print("%s: \"button_press_event_popup\": ", - gtk_widget_get_name(widget)); - - if (event->button == 3) { - g_print("button 3\n"); - - /* Popup menu. */ - gtk_menu_popup(GTK_MENU(widget), NULL, NULL, NULL, NULL, - event->button, event->time); - return TRUE; - } - - g_print("\n"); - - return FALSE; -} - -/*** - *** The "key_press_event" signal handler. Any processing required when key - *** presses occur should be done here. - ***/ -static gboolean -key_press_event(GtkWidget * widget, GdkEventKey * event, gpointer data) -{ - g_print("%s: \"key_press_event\": ", gtk_widget_get_name(widget)); - - switch (event->keyval) { - /*** Fill in the details here. ***/ - - case GDK_a: - g_print("a key\n"); -// toggle_animation (widget); - break; - - case GDK_Escape: - g_print("Escape key\n"); - gtk_main_quit(); - break; - - default: - g_print("\n"); - return FALSE; - } - - return TRUE; -} - - -/************************************************************************** - * The following section contains the timeout function management routines. - **************************************************************************/ - -/*** - *** Helper functions to add or remove the timeout function. - ***/ - -static guint timeout_id = 0; - -static void timeout_add(GtkWidget * widget) -{ - if (timeout_id == 0) { - timeout_id = g_timeout_add(TIMEOUT_INTERVAL, - (GSourceFunc) timeout, widget); - } -} - -static void timeout_remove(GtkWidget * widget) -{ - if (timeout_id != 0) { - g_source_remove(timeout_id); - timeout_id = 0; - } -} - -/*** - *** The "map_event" signal handler. Any processing required when the - *** OpenGL-capable drawing area is mapped should be done here. - ***/ -static gboolean -map_event(GtkWidget * widget, GdkEvent * event, gpointer data) -{ - g_print("%s: \"map_event\":\n", gtk_widget_get_name(widget)); - return TRUE; -} - -/*** - *** The "unmap_event" signal handler. Any processing required when the - *** OpenGL-capable drawing area is unmapped should be done here. - ***/ -static gboolean -unmap_event(GtkWidget * widget, GdkEvent * event, gpointer data) -{ - g_print("%s: \"unmap_event\":\n", gtk_widget_get_name(widget)); - timeout_remove(widget); - - return TRUE; -} - -/*** - *** The "visibility_notify_event" signal handler. Any processing required - *** when the OpenGL-capable drawing area is visually obscured should be - *** done here. - ***/ -static gboolean -visibility_notify_event(GtkWidget * widget, - GdkEventVisibility * event, gpointer data) -{ - - return TRUE; -} -#endif - - - -/************************************************************************** - * The following section contains the GUI building function definitions. - **************************************************************************/ - -/*** - *** Creates the popup menu to be displayed. - ***/ -#ifdef UNUSED -static GtkWidget *create_popup_menu(GtkWidget * drawing_area) -{ - GtkWidget *menu; - GtkWidget *menu_item; - - menu = gtk_menu_new(); - - /* Toggle animation */ - menu_item = gtk_menu_item_new_with_label("Toggle Animation"); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); -// g_signal_connect_swapped (G_OBJECT (menu_item), "activate", -// G_CALLBACK (toggle_animation), drawing_area); - gtk_widget_show(menu_item); - - /* Quit */ - menu_item = gtk_menu_item_new_with_label("Quit"); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); - g_signal_connect(G_OBJECT(menu_item), "activate", - G_CALLBACK(gtk_main_quit), NULL); - gtk_widget_show(menu_item); - - return menu; -} -#endif - -/*** - *** Creates the simple application window with one - *** drawing area that has an OpenGL-capable visual. - ***/ -#ifdef UNUSED -static GtkWidget *create_window(GdkGLConfig * glconfig) -{ - GtkWidget *window; - GtkWidget *vbox; - GtkWidget *drawing_area; - GtkWidget *menu; - GtkWidget *button; - - /* - * Top-level window. - */ - -// window = gtk_window_new (GTK_WINDOW_TOPLEVEL); -// gtk_window_set_title (GTK_WINDOW (window), DEFAULT_TITLE); - - /* Get automatically redrawn if any of their children changed allocation. */ - gtk_container_set_reallocate_redraws(GTK_CONTAINER(window), TRUE); - - /* Connect signal handlers to the window */ - g_signal_connect(G_OBJECT(window), "delete_event", - G_CALLBACK(gtk_main_quit), NULL); - - /* - * VBox. - */ - - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(window), vbox); - gtk_widget_show(vbox); - - /* - * Drawing area to draw OpenGL scene. - */ - - drawing_area = gtk_drawing_area_new(); - gtk_widget_set_size_request(drawing_area, DEFAULT_WIDTH, - DEFAULT_HEIGHT); - - /* Set OpenGL-capability to the widget */ - gtk_widget_set_gl_capability(drawing_area, - glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); - - gtk_widget_add_events(drawing_area, - GDK_BUTTON1_MOTION_MASK | - GDK_BUTTON2_MOTION_MASK | - GDK_BUTTON_PRESS_MASK | - GDK_VISIBILITY_NOTIFY_MASK); - - /* Connect signal handlers to the drawing area */ - g_signal_connect_after(G_OBJECT(drawing_area), "realize", - G_CALLBACK(realize), NULL); - g_signal_connect(G_OBJECT(drawing_area), "configure_event", - G_CALLBACK(configure_event), NULL); - g_signal_connect(G_OBJECT(drawing_area), "expose_event", - G_CALLBACK(expose_event), NULL); - g_signal_connect(G_OBJECT(drawing_area), "unrealize", - G_CALLBACK(unrealize), NULL); - - g_signal_connect(G_OBJECT(drawing_area), "motion_notify_event", - G_CALLBACK(motion_notify_event), NULL); - g_signal_connect(G_OBJECT(drawing_area), "button_press_event", - G_CALLBACK(button_press_event), NULL); - - /* key_press_event handler for top-level window */ - g_signal_connect_swapped(G_OBJECT(window), "key_press_event", - G_CALLBACK(key_press_event), drawing_area); - - /* For timeout function. */ - g_signal_connect(G_OBJECT(drawing_area), "map_event", - G_CALLBACK(map_event), NULL); - g_signal_connect(G_OBJECT(drawing_area), "unmap_event", - G_CALLBACK(unmap_event), NULL); - g_signal_connect(G_OBJECT(drawing_area), "visibility_notify_event", - G_CALLBACK(visibility_notify_event), NULL); - - gtk_box_pack_start(GTK_BOX(vbox), drawing_area, TRUE, TRUE, 0); - - gtk_widget_show(drawing_area); - - /* - * Popup menu. - */ - - menu = create_popup_menu(drawing_area); - - g_signal_connect_swapped(G_OBJECT(drawing_area), "button_press_event", - G_CALLBACK(button_press_event_popup_menu), - menu); - - /* - * Simple quit button. - */ - - button = gtk_button_new_with_label("Quit"); - - g_signal_connect(G_OBJECT(button), "clicked", - G_CALLBACK(gtk_main_quit), NULL); - - gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); - - gtk_widget_show(button); - - return window; -} -#endif - - -/************************************************************************** - * The following section contains utility function definitions. - **************************************************************************/ - -/*** - *** Configure the OpenGL framebuffer. - ***/ -#ifdef UNUSED -static GdkGLConfig *configure_gl(void) -{ - GdkGLConfig *glconfig; - - /* Try double-buffered visual */ - glconfig = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGB | - GDK_GL_MODE_DEPTH | - GDK_GL_MODE_DOUBLE); - if (glconfig == NULL) { - g_print("\n*** Cannot find the double-buffered visual.\n"); - g_print("\n*** Trying single-buffered visual.\n"); - - /* Try single-buffered visual */ - glconfig = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGB | - GDK_GL_MODE_DEPTH); - if (glconfig == NULL) { - g_print("*** No appropriate OpenGL-capable visual found.\n"); - exit(1); - } - } - - return glconfig; -} -#endif diff --git a/cmd/smyrna/topfisheyeview.c b/cmd/smyrna/topfisheyeview.c index 7eee94acc..b5644cd65 100644 --- a/cmd/smyrna/topfisheyeview.c +++ b/cmd/smyrna/topfisheyeview.c @@ -222,7 +222,7 @@ static v_data *makeGraph(Agraph_t* gg, int *nedges) ne++; i_nedges++; // *edges++ = ((temp_node_record *) AGDATA(vp))->TVref; - *edges++ =((nodeRec*)(aggetrec(vp,"nodeRec",0)))->TVref; + *edges++ = ND_TVref(vp); *ewgts++ = 1; } @@ -320,8 +320,8 @@ void prepare_topological_fisheye(Agraph_t* g,topview * t) i=0; for (np = agfstnode(g); np; np = agnxtnode(g, np)) { - x_coords[i]=((nodeRec*)(aggetrec(np,"nodeRec",0)))->A.x; - y_coords[i]=((nodeRec*)(aggetrec(np,"nodeRec",0)))->A.y; + x_coords[i]=ND_A(np).x; + y_coords[i]=ND_A(np).y; i++; } hp = t->fisheyeParams.h = diff --git a/cmd/smyrna/topviewfuncs.c b/cmd/smyrna/topviewfuncs.c index 5840bfca3..34a153f6a 100644 --- a/cmd/smyrna/topviewfuncs.c +++ b/cmd/smyrna/topviewfuncs.c @@ -25,21 +25,36 @@ #include "glutils.h" #include "selectionfuncs.h" -#define WITH_CGRAPH 1 -static xdot *parseXdotwithattrs(void *e); -static Agsym_t* pos_attr=(Agsym_t*)0; - - +static xdot *parseXdotwithattrs(void *e) +{ + + int cnt=0; + xdot* xDot=NULL; + xDot=parseXDotFOn (agget(e,"_draw_" ), OpFns,sizeof(sdot_op), xDot); + xDot=parseXDotFOn (agget(e,"_ldraw_" ), OpFns,sizeof(sdot_op), xDot); + xDot=parseXDotFOn (agget(e,"_hdraw_" ), OpFns,sizeof(sdot_op), xDot); + xDot=parseXDotFOn (agget(e,"_tdraw_" ), OpFns,sizeof(sdot_op), xDot); + xDot=parseXDotFOn (agget(e,"_hldraw_" ), OpFns,sizeof(sdot_op), xDot); + xDot=parseXDotFOn (agget(e,"_tldraw_" ), OpFns,sizeof(sdot_op), xDot); + if(xDot) + { + for (cnt=0;cnt < xDot->cnt ; cnt++) + { + ((sdot_op*)(xDot->ops))[cnt].obj=e; + } + } + return xDot; +} static void set_boundaries(Agraph_t * g, topview * t) { Agnode_t *v; - static glCompPoint pos; + Agsym_t* pos_attr = GN_pos(g); + glCompPoint pos; float left, right, top, bottom; int id=0; - if(!pos_attr) - pos_attr=agattr(g, AGNODE,"pos",0); + for (v = agfstnode(g); v; v = agnxtnode(g, v)) { pos=getPointFromStr(agxget(v, pos_attr)); @@ -67,11 +82,9 @@ static void set_boundaries(Agraph_t * g, topview * t) view->bdzTop = 0; view->bdzBottom = 0; - - - } +#if UNUSED static float init_node_size(Agraph_t * g, topview * t) { float vsize; @@ -92,7 +105,7 @@ static float init_node_size(Agraph_t * g, topview * t) return sz; } - +#endif static void draw_xdot(xdot* x,float base_z) @@ -136,7 +149,7 @@ static GLfloat getEdgeLength(Agedge_t * edge) } static void glCompColorxlate(glCompColor* c,char* str) { - static gvcolor_t cl; + gvcolor_t cl; colorxlate(str, &cl, RGBA_DOUBLE); c->R=cl.u.RGBA[0]; c->G=cl.u.RGBA[1]; @@ -144,23 +157,44 @@ static void glCompColorxlate(glCompColor* c,char* str) c->A=cl.u.RGBA[3]; } +/* If the "visible" attribute is not set or "", return true + * else evaluate as boolean + */ +int visible(Agsym_t* attr, void* obj) +{ + char* s; + + if (attr) { + s = agxget (obj, attr); + if (*s) return mapbool(s); + else return 1; + } + else return 1; +} int object_color(void* obj,glCompColor* c) { - static gvcolor_t cl; + gvcolor_t cl; Agraph_t* g=view->g[view->activeGraph]; + Agraph_t* objg=agraphof(obj); int return_value = 1; int objType; float Alpha = 1; char* bf; + Agsym_t* vis; objType=AGTYPE(obj); - if(objType==AGEDGE) - Alpha=getAttrFloat(g,agraphof(obj),"defaultedgealpha",1); - if(objType==AGNODE) - Alpha=getAttrFloat(g,agraphof(obj),"defaultnodealpha",1); - if(!getAttrBool1(g,obj,"visible",1)) + if(objType==AGEDGE) { + Alpha=getAttrFloat(g,objg,"defaultedgealpha",1); + vis = GE_visible (objg); + } + if(objType==AGNODE) { + Alpha=getAttrFloat(g,objg,"defaultnodealpha",1); + vis = GN_visible (objg); + } + if (!visible(vis,obj)) return 0; + /*get edge's color attribute */ setColorScheme (agget (obj, "colorscheme")); bf=getAttrStr(g,obj,"color",NULL); @@ -234,31 +268,22 @@ static void draw_edge(glCompPoint* posT,glCompPoint* posH, GLfloat length,int de void renderSelectedNodes(Agraph_t * g) { Agnode_t *v; - static xdot * x; - static glCompPoint pos; - - - static Agsym_t* l_color_attr=(Agsym_t*)0; - static glCompColor c; - - - - + xdot * x; + glCompPoint pos; + Agsym_t* l_color_attr = GG_nodelabelcolor(g); + glCompColor c; + int defaultNodeShape; + GLfloat nodeSize; - static int defaultNodeShape=0; - static GLfloat nodeSize=0; - if(!l_color_attr) - l_color_attr=agattr(g, AGRAPH,"nodelabelcolor",0); glCompColorxlate(&c,agxget(g,l_color_attr)); - defaultNodeShape=getAttrBool(g,g,"defaultnodeshape",0); if(defaultNodeShape==0) glBegin(GL_POINTS); for (v = agfstnode(g); v; v = agnxtnode(g, v)) { - if(!((nodeRec*)(aggetrec(v,"nodeRec",0)))->selected); + if(!ND_selected(v)); continue; x=parseXdotwithattrs(v); draw_xdot(x,-1); @@ -266,21 +291,20 @@ void renderSelectedNodes(Agraph_t * g) freeXDot (x); } - for (v = agfstnode(g); v; v = agnxtnode(g, v)) { - if(!((nodeRec*)(aggetrec(v,"nodeRec",0)))->selected) + if(!ND_selected(v)) continue; glColor4f(view->selectedNodeColor.R, view->selectedNodeColor.G,view->selectedNodeColor.B, view->selectedNodeColor.A); - pos=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A; - nodeSize=((nodeRec*)(aggetrec(v,"nodeRec",0)))->size; + pos = ND_A(v); + nodeSize = ND_size(v); if (defaultNodeShape == 0) glVertex3f(pos.x,pos.y,pos.z+0.001); else if (defaultNodeShape == 1) drawCircle(pos.x,pos.y,nodeSize,pos.z+0.001); - if(((nodeRec*)(aggetrec(v,"nodeRec",0)))->printLabel==1) + if (ND_printLabel(v)==1) { glColor4f(c.R, c.G,c.B, c.A); glprintfglut(view->glutfont,pos.x+nodeSize,pos.y+nodeSize,pos.z,agnameof(v)); @@ -296,24 +320,17 @@ void renderSelectedNodes(Agraph_t * g) void renderNodes(Agraph_t * g) { Agnode_t *v; - static glCompPoint pos; - static Agsym_t* size_attr=(Agsym_t*)0; - static Agsym_t* selected_attr=(Agsym_t*)0; - static int defaultNodeShape=0; - static GLfloat nodeSize=0; - static glCompColor c; + glCompPoint pos; + Agsym_t* pos_attr = GN_pos(g); + Agsym_t* size_attr = GN_size(g); + Agsym_t* selected_attr = GN_selected(g); + int defaultNodeShape; + GLfloat nodeSize; + glCompColor c; xdot * x; int ind; - defaultNodeShape=getAttrBool(g,g,"defaultnodeshape",0); - if(!pos_attr) - pos_attr=agattr(g, AGNODE,"pos",0); - if(!size_attr) - size_attr=agattr(g, AGNODE,"size",0); - if(!selected_attr) - selected_attr=agattr(g, AGNODE,"selected",0); - for (v = agfstnode(g); v; v = agnxtnode(g, v)) { @@ -322,44 +339,35 @@ void renderNodes(Agraph_t * g) x=parseXdotwithattrs(v); draw_xdot(x,-0.1); - if(x) freeXDot (x); } - - if(defaultNodeShape==0) glBegin(GL_POINTS); - - - - - ind=0; for (v = agfstnode(g); v; v = agnxtnode(g, v)) { - ((nodeRec*)(aggetrec(v,"nodeRec",0)))->TVref=ind; + ND_TVref(v) = ind; if(!object_color(v,&c)) { - ((nodeRec*)(aggetrec(v,"nodeRec",0)))->visible=0; + ND_visible(v) = 0; continue; } else - ((nodeRec*)(aggetrec(v,"nodeRec",0)))->visible=1; - + ND_visible(v) = 1; if(l_int(v, selected_attr,0)) { - ((nodeRec*)(aggetrec(v,"nodeRec",0)))->selected=1; + ND_selected(v) = 1; } glColor4f(c.R,c.G,c.B,c.A); pos=getPointFromStr(agxget(v, pos_attr)); nodeSize=(GLfloat)l_float(v, size_attr,0); - ((nodeRec*)(aggetrec(v,"nodeRec",0)))->A=pos; + ND_A(v) = pos; if (nodeSize > 0) nodeSize=nodeSize*view->nodeScale; @@ -367,7 +375,7 @@ void renderNodes(Agraph_t * g) nodeSize=view->nodeScale; if(defaultNodeShape==0) nodeSize=1; - ((nodeRec*)(aggetrec(v,"nodeRec",0)))->size=nodeSize; + ND_size(v) = nodeSize; if (defaultNodeShape == 0) glVertex3f(pos.x,pos.y,pos.z); else if (defaultNodeShape == 1) @@ -384,17 +392,17 @@ void renderSelectedEdges(Agraph_t * g) Agedge_t *e; Agnode_t *v; - static xdot * x; - static glCompPoint posT; /*Tail position*/ - static glCompPoint posH; /*Head position*/ - static glCompColor c; + xdot * x; + glCompPoint posT; /*Tail position*/ + glCompPoint posH; /*Head position*/ + glCompColor c; /*xdots tend to be drawn as background shapes,that is why they are being rendered before edges*/ for (v = agfstnode(g); v; v = agnxtnode(g, v)) { for (e = agfstout(g, v); e; e = agnxtout(g, e)) { - if(!((edgeRec*)(aggetrec(e,"edgeRec",0)))->selected) + if(!ED_selected(e)) continue; if(!object_color(e,&c)) continue; @@ -414,14 +422,14 @@ void renderSelectedEdges(Agraph_t * g) { for (e = agfstout(g, v); e; e = agnxtout(g, e)) { - if(!((edgeRec*)(aggetrec(e,"edgeRec",0)))->selected) + if(!ED_selected(e)) continue; if(!object_color(e,&c)) continue; glColor4f(1,0,0,1); - posT=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posTail; - posH=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posHead; + posT = ED_posTail(e); + posH = ED_posHead(e); posT.z +=0.01; posH.z +=0.01; draw_edge(&posT,&posH,getEdgeLength(e),0); @@ -435,34 +443,29 @@ void renderSelectedEdges(Agraph_t * g) void renderEdges(Agraph_t * g) { - Agedge_t *e; Agnode_t *v; - static xdot * x; - static glCompPoint posT; /*Tail position*/ - static glCompPoint posH; /*Head position*/ - static glCompColor c; - if(!pos_attr) - pos_attr=agattr(g, AGNODE,"pos",0); + Agsym_t* pos_attr = GN_pos(g); + xdot * x; + glCompPoint posT; /*Tail position*/ + glCompPoint posH; /*Head position*/ + glCompColor c; /*xdots tend to be drawn as background shapes,that is why they are being rendered before edges*/ for (v = agfstnode(g); v; v = agnxtnode(g, v)) { for (e = agfstout(g, v); e; e = agnxtout(g, e)) { - if( - (((nodeRec*)(aggetrec(agtail(e),"nodeRec",0)))->visible==0) - || - (((nodeRec*)(aggetrec(aghead(e),"nodeRec",0)))->visible==0)) + if ((ND_visible(agtail(e))==0) || (ND_visible(aghead(e))==0)) continue; if(!object_color(e,&c)) { - ((edgeRec*)(aggetrec(e,"edgeRec",0)))->visible=0; + ED_visible(e) = 0; continue; } else - ((edgeRec*)(aggetrec(e,"edgeRec",0)))->visible=1; + ED_visible(e) = 1; x=parseXdotwithattrs(e); draw_xdot(x,0); @@ -472,32 +475,24 @@ void renderEdges(Agraph_t * g) } } - - - glBegin(GL_LINES); for (v = agfstnode(g); v; v = agnxtnode(g, v)) { for (e = agfstout(g, v); e; e = agnxtout(g, e)) { - if( - (((nodeRec*)(aggetrec(agtail(e),"nodeRec",0)))->visible==0) - || - (((nodeRec*)(aggetrec(aghead(e),"nodeRec",0)))->visible==0)) + if ((ND_visible(agtail(e))==0) || (ND_visible(aghead(e))==0)) continue; if(!object_color(e,&c)) continue; - if(((edgeRec*)(aggetrec(e,"edgeRec",0)))->selected) + if(ED_selected(e)) continue; glColor4f(c.R,c.G,c.B,c.A); posT=getPointFromStr(agxget(agtail(e), pos_attr)); posH=getPointFromStr(agxget(aghead(e), pos_attr)); draw_edge(&posT,&posH,getEdgeLength(e),0); - ((edgeRec*)(aggetrec(e,"edgeRec",0)))->posTail=posT; - ((edgeRec*)(aggetrec(e,"edgeRec",0)))->posHead=posH; - - + ED_posTail(e) = posT; + ED_posHead(e) = posH; } } glEnd(); @@ -506,31 +501,23 @@ void renderEdges(Agraph_t * g) void renderNodeLabels(Agraph_t * g) { Agnode_t *v; - static glCompPoint pos; - static Agsym_t* data_attr=(Agsym_t*)0; - static Agsym_t* l_color_attr=(Agsym_t*)0; - static GLfloat nodeSize=0; - static glCompColor c; - if(!data_attr) - data_attr=agattr(g, AGNODE,agget(g, "nodelabelattribute"),0); - if(!l_color_attr) - l_color_attr=agattr(g, AGRAPH,"nodelabelcolor",0); - - - + glCompPoint pos; + Agsym_t* data_attr = GN_labelattribute(g); + Agsym_t* l_color_attr = GG_nodelabelcolor(g); + GLfloat nodeSize; + glCompColor c; glCompColorxlate(&c,agxget(g,l_color_attr)); - for (v = agfstnode(g); v; v = agnxtnode(g, v)) { - if(((nodeRec*)(aggetrec(v,"nodeRec",0)))->visible==0) + if(ND_visible(v)==0) continue; - if(((nodeRec*)(aggetrec(v,"nodeRec",0)))->selected==1) + if(ND_selected(v)==1) continue; - pos=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A; - nodeSize=((nodeRec*)(aggetrec(v,"nodeRec",0)))->size; + pos = ND_A(v); + nodeSize = ND_size(v); glColor4f(c.R,c.G,c.B,c.A); if(!data_attr) glprintfglut(view->glutfont,pos.x+nodeSize,pos.y+nodeSize,pos.z,agnameof(v)); @@ -538,26 +525,21 @@ void renderNodeLabels(Agraph_t * g) glprintfglut(view->glutfont,pos.x+nodeSize,pos.y+nodeSize,pos.z,agxget(v,data_attr)); } } + void renderEdgeLabels(Agraph_t * g) { Agedge_t *e; Agnode_t *v; - static glCompPoint posT; - static glCompPoint posH; - static Agsym_t* data_attr=(Agsym_t*)0; - static Agsym_t* l_color_attr=(Agsym_t*)0; - /* static GLfloat nodeSize=0; */ - static glCompColor c; + glCompPoint posT; + glCompPoint posH; + Agsym_t* data_attr = GE_labelattribute(g); + Agsym_t* l_color_attr = GG_edgelabelcolor(g); + glCompColor c; GLfloat x,y,z; - if(!data_attr) - data_attr=agattr(g, AGNODE,agget(g, "edgelabelattribute"),0); - if(!l_color_attr) - l_color_attr=agattr(g, AGRAPH,"edgelabelcolor",0); - glCompColorxlate(&c,agxget(g,l_color_attr)); - if(!data_attr) + if(!data_attr || !l_color_attr) return; for (v = agfstnode(g); v; v = agnxtnode(g, v)) @@ -565,11 +547,11 @@ void renderEdgeLabels(Agraph_t * g) for (e = agfstout(g, v); e; e = agnxtout(g, e)) { - if(((edgeRec*)(aggetrec(v,"nodeRec",0)))->visible==0) + if (ND_visible(v)==0) continue; - posT=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posTail; - posH=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posHead; + posT = ED_posTail(e); + posH = ED_posHead(e); glColor4f(c.R,c.G,c.B,c.A); x=posH.x+(posT.x-posH.x)/2; y=posH.y+(posT.y-posH.y)/2; @@ -585,28 +567,6 @@ void renderEdgeLabels(Agraph_t * g) -static xdot *parseXdotwithattrs(void *e) -{ - - int cnt=0; - xdot* xDot=NULL; - xDot=parseXDotFOn (agget(e,"_draw_" ), OpFns,sizeof(sdot_op), xDot); - xDot=parseXDotFOn (agget(e,"_ldraw_" ), OpFns,sizeof(sdot_op), xDot); - xDot=parseXDotFOn (agget(e,"_hdraw_" ), OpFns,sizeof(sdot_op), xDot); - xDot=parseXDotFOn (agget(e,"_tdraw_" ), OpFns,sizeof(sdot_op), xDot); - xDot=parseXDotFOn (agget(e,"_hldraw_" ), OpFns,sizeof(sdot_op), xDot); - xDot=parseXDotFOn (agget(e,"_tldraw_" ), OpFns,sizeof(sdot_op), xDot); - if(xDot) - { - for (cnt=0;cnt < xDot->cnt ; cnt++) - { - ((sdot_op*)(xDot->ops))[cnt].obj=e; - } - } - return xDot; - -} - void cacheNodes(Agraph_t * g,topview* t) { if(t->cache.node_id!=-1) /*clean existing cache*/ diff --git a/cmd/smyrna/tvnodes.c b/cmd/smyrna/tvnodes.c index b00c9571b..fd72e8504 100755 --- a/cmd/smyrna/tvnodes.c +++ b/cmd/smyrna/tvnodes.c @@ -19,7 +19,6 @@ #include "btree.h" #include "viewport.h" #include "topviewfuncs.h" - #include "memory.h" typedef struct{ @@ -72,25 +71,24 @@ int create_save_subgraph_from_filter(char *filename) static void set_visibility(Agraph_t* g,int visibility) { - Agnode_t *v; - static char bf1[2]; - static char* bf2; - static Agsym_t* visible_attr=(Agsym_t*)0; - static Agsym_t* selected_attr=(Agsym_t*)0; - if(!visible_attr) - visible_attr=agattr(g, AGNODE,"visible","1"); - if(!selected_attr) - selected_attr=agattr(g, AGNODE,"selected",0); + char bf1[2]; + char* bf2; + Agsym_t* visible_attr = GN_visible(g); + Agsym_t* selected_attr = GN_selected(g); + + if (!visible_attr) + visible_attr = GN_visible(g) = agattr(g, AGNODE,"visible","1"); + if (!selected_attr) + return; sprintf(bf1,"%d",visibility); for (v = agfstnode(g); v; v = agnxtnode(g, v)) { bf2=agxget(v,selected_attr); - if((!bf2) || (strcmp(bf2,"0")==0)) + if((*bf2 == '\0') || (strcmp(bf2,"0")==0)) continue; agxset(v,visible_attr,bf1); } - } int tv_show_all(void) @@ -172,6 +170,7 @@ static void create_toggle_column(char* Title,GtkTreeView* tree,int asso,int edit gtk_tree_view_column_set_resizable (column,1); } +#ifdef UNUSED static int boolStrMap(char* str) { if (strcmp(str,"1") ||strcmp(str,"true")|| strcmp(str,"TRUE") || strcmp(str,"True")) @@ -180,7 +179,7 @@ static int boolStrMap(char* str) } - +#endif @@ -297,7 +296,7 @@ GtkTreeView* update_tree (GtkTreeView *tree,grid* g) int id=0; if(tree!=NULL) { - while(column=gtk_tree_view_get_column(tree,0)) /*clear all columns*/ + while ((column=gtk_tree_view_get_column(tree,0))) /*clear all columns*/ gtk_tree_view_remove_column(tree,column); store=(GtkTreeStore*)gtk_tree_view_get_model(tree); } @@ -386,14 +385,10 @@ void setup_tree (Agraph_t* g) G_TYPE_INT: G_TYPE_BOOLEAN: */ - static char* buf=NULL; - static GtkTreeStore *store=NULL; - static GtkTreeView *tree=NULL; - grid* gr=NULL; - buf=agget(g,"datacolumns"); - -// tree=(GtkTreeView *) glade_xml_get_widget(xml, "treeview1"); - gr=update_colums(gr,buf); + char* buf = agget(g,"datacolumns"); + grid* gr = update_colums(NULL,buf); + static GtkTreeView *tree; + tree=update_tree (tree,gr); populate_data(g,gr); } diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index 1de0b87bb..5b3fc9859 100755 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -183,7 +183,7 @@ void set_viewport_settings_from_template(ViewInfo * view, Agraph_t * g) char *buf; colorxlate(get_attribute_value("bordercolor", view, g), &cl, RGBA_DOUBLE); - glEnable(GL_POINT_SMOOTH); + /* glEnable(GL_POINT_SMOOTH); */ view->borderColor.R = (float) cl.u.RGBA[0]; view->borderColor.G = (float) cl.u.RGBA[1]; view->borderColor.B = (float) cl.u.RGBA[2]; @@ -605,7 +605,8 @@ static Agraph_t *loadGraph(char *filename) /* If no position info, run layout with -Txdot */ if (!agattr(g, AGNODE, "pos", NULL)) { - g_print("There is no position info in %s\n", filename); + g_print("There is no position info in graph %s in %s\n", agnameof(g), filename); + agclose (g); return 0; } // free(view->Topview->Graphdata.GraphFileName); diff --git a/share/gui/smyrna.glade b/share/gui/smyrna.glade index 520aa7bea..ce0904bbf 100755 --- a/share/gui/smyrna.glade +++ b/share/gui/smyrna.glade @@ -176,91 +176,6 @@ - - - True - Select - True - - - - - - - True - gtk-select-all - True - - - - - - - True - Unselect All - True - - - - - - - True - Select All Nodes - True - - - - - - - True - Select All Edges - True - - - - - - - True - Select All Clusters - True - - - - - - - True - Unselect All Nodes - True - - - - - - - True - Unselect All Edges - True - - - - - - - True - Unselect All Clusters - True - - - - - - - - True @@ -696,74 +611,6 @@ 0 0 710 0 639 710 0 0 400 0 36 40 - - - 40 - 25 - True - << - True - GTK_RELIEF_NORMAL - True - - - - 5 - 10 - - - - - - 40 - 25 - True - < - True - GTK_RELIEF_NORMAL - True - - - - 51 - 10 - - - - - - 40 - 25 - True - > - True - GTK_RELIEF_NORMAL - True - - - - 95 - 10 - - - - - - 40 - 25 - True - >> - True - GTK_RELIEF_NORMAL - True - - - - 140 - 10 - - - 136 @@ -790,23 +637,6 @@ - - - 90 - 25 - True - Go to page # - True - GTK_RELIEF_NORMAL - True - - - - 317 - 10 - - - 99 @@ -882,451 +712,6 @@ - - 5 - 590 - 196 - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 590 - 350 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - True - False - False - - - - True - False - 2 - - - - True - GTK_BUTTONBOX_END - - - - True - Cancel - True - GTK_RELIEF_NORMAL - True - 2 - - - - - - True - Apply - True - GTK_RELIEF_NORMAL - True - 1 - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - 400 - 400 - 0 0 576 0 518.4 576 - 0 0 400 0 128.7 143 - - - - 419 - 80 - True - 3 - 2 - False - 0 - 0 - - - - True - False - 0 - - - - 15 - True - All - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - True - True - - - - - - 75 - True - Selected - True - GTK_RELIEF_NORMAL - True - False - False - True - rbTVFilterSel1 - - - 0 - True - True - - - - - - 100 - True - Non-selected - True - GTK_RELIEF_NORMAL - True - False - False - True - rbTVFilterSel1 - - - 0 - True - True - - - - - 1 - 2 - 0 - 1 - - - - - - True - Selection - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 0 - 1 - - - - - - True - Visible - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 1 - 2 - - - - - - Highlighted - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 2 - 3 - - - - - - True - False - 0 - - - - 15 - True - All - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - True - True - - - - - - 75 - True - Visible - True - GTK_RELIEF_NORMAL - True - False - False - True - rbTVFilterVisible1 - - - 0 - True - True - - - - - - 100 - True - Hidden - True - GTK_RELIEF_NORMAL - True - False - False - True - rbTVFilterVisible1 - - - 0 - True - True - - - - - 1 - 2 - 1 - 2 - - - - - - True - False - 0 - - - - 15 - All - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - True - True - - - - - - 75 - Highlighted - True - GTK_RELIEF_NORMAL - True - False - False - True - rbTVFilterHigh1 - - - 0 - True - True - - - - - - 100 - Not Highlighted - True - GTK_RELIEF_NORMAL - True - False - False - True - rbTVFilterHigh1 - - - 0 - True - True - - - - - 1 - 2 - 2 - 3 - - - - - 2 - 30 - - - - - - 181 - 20 - True - FILTER CRITERIAS - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 0 - - - - - - 581 - 20 - True - - - 0 - 13 - - - - - - 100 - 29 - True - Clear Filter - True - GTK_RELIEF_NORMAL - True - - - - 467 - 32 - - - - - 0 - True - True - - - - - - 5 676