From: arif Date: Tue, 3 Aug 2010 17:44:18 +0000 (+0000) Subject: edge position support added. X-Git-Tag: LAST_LIBGRAPH~32^2~1234 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=458e67a9d2caafee268f493a7cd1e5ed74e234bb;p=graphviz edge position support added. --- diff --git a/cmd/smyrna/glexpose.c b/cmd/smyrna/glexpose.c index 662c2d8a4..77ec5ab2f 100644 --- a/cmd/smyrna/glexpose.c +++ b/cmd/smyrna/glexpose.c @@ -259,7 +259,7 @@ int glexpose_main(ViewInfo * view) if (!glupdatecamera(view)) return 0; - draw_cube(); +// draw_cube(); if (view->activeGraph >= 0) { diff --git a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user index 3dd9b1604..f2fba747f 100644 --- a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user +++ b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user @@ -11,7 +11,7 @@ N_selected) #define GG_nodelabelcolor(g) (GREC(g)->G_nodelabelcolor) #define GN_labelattribute(g) (GREC(g)->N_labelattribute) +#define GE_pos(g) (GREC(g)->E_pos) #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) + #define GUI_WINDOWED 0 #define GUI_FULLSCREEN 1 diff --git a/cmd/smyrna/topviewfuncs.c b/cmd/smyrna/topviewfuncs.c index 6087e358f..a1f1910d0 100644 --- a/cmd/smyrna/topviewfuncs.c +++ b/cmd/smyrna/topviewfuncs.c @@ -449,15 +449,50 @@ static void renderSelectedEdges(Agraph_t * g) } glEnd(); } +static int removeChar(char* str,char r) +{ + char* ptr=str; + int rv=0; + while (*ptr!='\0') + { + if(*ptr == r) + { + *ptr=' '; + rv++; + } + ptr++; + } + return rv; +} +char* pos_to_xdot(char* xdots,char* buf) +{ +/* +"e,227.75,177.25 186.27,218.73 196.2,208.8 209.32,195.68 220.44,184.56", +"B 4 186 219 196 209 209 196 220 185 ", _hdraw_="S 5 -solid c 9 -#000000ff C 9 -#000000ff P 3 223 187 228 177 218 182 ";*/ + char* pt; + int spaceCnt=0; + strcpy(buf,xdots); + pt=buf; + while ((spaceCnt == 0) && (*pt!='\0')) + { + if(*pt==' ') + spaceCnt++; + pt++; + } + return pt; +} static void renderEdges(Agraph_t * g) { + char Buf[1024]; + char posBuf[1024]; Agedge_t *e; Agnode_t *v; Agsym_t* pos_attr = GN_pos(g); + Agsym_t* pos_attr_e = GE_pos(g); xdot * x; glCompPoint posT; /*Tail position*/ glCompPoint posH; /*Head position*/ @@ -499,12 +534,27 @@ static void renderEdges(Agraph_t * g) continue; 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); - ED_posTail(e) = posT; - ED_posHead(e) = posH; + glColor4f(c.R,c.G,c.B,c.A); + if(!pos_attr_e) + { + posT=getPointFromStr(agxget(agtail(e), pos_attr)); + posH=getPointFromStr(agxget(aghead(e), pos_attr)); + draw_edge(&posT,&posH,getEdgeLength(e),0); + ED_posTail(e) = posT; + ED_posHead(e) = posH; + } + else/*NOT IMPLEMENTED YET*/ + { + int pCount=0; + char* bf; + bf=pos_to_xdot(agxget(e,pos_attr_e),Buf); + pCount=removeChar(bf,','); + sprintf(posBuf,"B %d %s ",pCount,bf); + x=parseXDotFOn (posBuf, OpFns,sizeof(sdot_op), NULL); + draw_xdot(x,0); + if(x) + freeXDot (x); + } } } glEnd(); diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index 01e759b2c..fe5e1801c 100755 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -662,6 +662,7 @@ graphRecord (Agraph_t* g) GN_selected(g) = agattr (g, AGNODE, "selected", 0); GN_labelattribute(g) = agattr (g, AGNODE, agget(g,"nodelabelattribute"), 0); + GE_pos(g)=agattr(g,AGEDGE,"pos",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);