Graphviz 13.0.0~dev.20250424.1043
Loading...
Searching...
No Matches
topviewfuncs.c
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11#include <assert.h>
12#include "topviewfuncs.h"
13#include <cgraph/cgraph.h>
14#include "smyrna_utils.h"
15#include <common/colorprocs.h>
16#include "draw.h"
17#include "frmobjectui.h"
18#include <xdot/xdot.h>
19#include <glcomp/glutils.h>
20#include "selectionfuncs.h"
21#include <common/types.h>
22#include <common/utils.h>
23#include <limits.h>
24#include <float.h>
25#include <math.h>
26#include <stdbool.h>
27#include <stdlib.h>
28#include <util/alloc.h>
29#include <util/gv_ctype.h>
30
31static xdot *parseXdotwithattrs(void *e)
32{
33 xdot* xDot=NULL;
34 xDot=parseXDotFOn (agget(e,"_draw_" ), OpFns,sizeof(sdot_op), xDot);
35 if (agobjkind(e) == AGRAPH)
36 xDot=parseXDotFOn (agget(e,"_background" ), OpFns,sizeof(sdot_op), xDot);
37 xDot=parseXDotFOn (agget(e,"_ldraw_" ), OpFns,sizeof(sdot_op), xDot);
38 xDot=parseXDotFOn (agget(e,"_hdraw_" ), OpFns,sizeof(sdot_op), xDot);
39 xDot=parseXDotFOn (agget(e,"_tdraw_" ), OpFns,sizeof(sdot_op), xDot);
40 xDot=parseXDotFOn (agget(e,"_hldraw_" ), OpFns,sizeof(sdot_op), xDot);
41 xDot=parseXDotFOn (agget(e,"_tldraw_" ), OpFns,sizeof(sdot_op), xDot);
42 if(xDot)
43 {
44 for (size_t cnt = 0; cnt < xDot->cnt; cnt++)
45 {
46 ((sdot_op*)(xDot->ops))[cnt].obj=e;
47 }
48 }
49 return xDot;
50
51}
52
53static void set_boundaries(Agraph_t * g)
54{
55 Agnode_t *v;
56 Agsym_t* pos_attr = GN_pos(g);
57 glCompPoint pos;
58 float left = FLT_MAX, right = -FLT_MAX, top = -FLT_MAX, bottom = FLT_MAX;
59
60 for (v = agfstnode(g); v; v = agnxtnode(g, v))
61 {
62 pos=getPointFromStr(agxget(v, pos_attr));
63
64 left = fminf(left, pos.x);
65 right = fmaxf(right, pos.x);
66 top = fmaxf(top, pos.y);
67 bottom = fminf(bottom, pos.y);
68 }
69 view->bdxLeft = left;
70 view->bdyTop = top;
72 view->bdyBottom = bottom;
73}
74
75static void draw_xdot(xdot* x, double base_z)
76{
77 sdot_op *op;
78 if (!x)
79 return;
80
81 view->Topview->global_z=base_z;
82
83 op=(sdot_op*)x->ops;
84 for (size_t i = 0; i < x->cnt; i++, op++)
85 {
86 if(op->op.drawfunc)
87 op->op.drawfunc(&op->op,0);
88 }
89
90
91}
92
93
94
96{
97 return getPointFromStr(agget(aghead(edge),"pos"));
98}
100{
101 return getPointFromStr(agget(agtail(edge),"pos"));
102}
103
108 float rv = (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y) + (A.z - B.z) * (A.z - B.z);
109 rv=sqrtf(rv);
110 return rv;
111}
112
113static void glCompColorxlate(glCompColor *c, const char *str) {
114 gvcolor_t cl;
116 c->R=cl.u.RGBA[0];
117 c->G=cl.u.RGBA[1];
118 c->B=cl.u.RGBA[2];
119 c->A=cl.u.RGBA[3];
120}
121
122/* If the "visible" attribute is not set or "", return true
123 * else evaluate as boolean
124 */
125static int visible(Agsym_t* attr, void* obj)
126{
127 char* s;
128
129 if (attr) {
130 s = agxget (obj, attr);
131 if (*s) return mapbool(s);
132 else return 1;
133 }
134 else return 1;
135}
136
137static int object_color(void* obj,glCompColor* c)
138{
139 gvcolor_t cl;
141 Agraph_t* objg=agraphof(obj);
142 int objType;
143 float Alpha = 1;
144 Agsym_t* vis;
145
146 objType=AGTYPE(obj);
147
148 if(objType==AGEDGE) {
149 Alpha=getAttrFloat(g,objg,"defaultedgealpha",1);
150 vis = GE_visible (objg);
151 }
152 else {
153 assert(objType == AGNODE);
154 Alpha=getAttrFloat(g,objg,"defaultnodealpha",1);
155 vis = GN_visible (objg);
156 }
157 if (!visible(vis,obj))
158 return 0;
159
160 char *previous_color_scheme = setColorScheme(agget (obj, "colorscheme"));
161 /*get objects's color attribute */
162 const char *const bf = getAttrStr(g,obj,"color",NULL);
163 if(bf && (*bf)) {
164 colorxlate(bf, &cl, RGBA_DOUBLE);
165 c->R = cl.u.RGBA[0];
166 c->G = cl.u.RGBA[1];
167 c->B = cl.u.RGBA[2];
168 c->A = cl.u.RGBA[3]*Alpha;
169 }
170 else
171 {
172 if(objType==AGEDGE)
174 else
175 {
176 colorxlate(agget(g, "defaultnodecolor"),&cl, RGBA_DOUBLE);
177 c->R = cl.u.RGBA[0];
178 c->G = cl.u.RGBA[1];
179 c->B = cl.u.RGBA[2];
180 c->A = cl.u.RGBA[3];
181 }
182 c->A *= Alpha;
183
184 }
185
186 char *color_scheme = setColorScheme(previous_color_scheme);
187 free(color_scheme);
188 free(previous_color_scheme);
189
190 return 1;
191}
192
193
194/*
195 draws multi edges , single edges
196 this function assumes glBegin(GL_LINES) has been called
197*/
198static void draw_edge(glCompPoint posT, glCompPoint posH) {
199 glVertex3f(posT.x, posT.y, posT.z);
200 glVertex3f(posH.x, posH.y, posH.z);
201}
202
203static char* labelOf (Agraph_t* g, Agnode_t* v)
204{
205 char* lbl;
206 char* s;
207
208 Agsym_t* data_attr = GN_labelattribute(g);
209 if (data_attr)
210 s = agxget (v, data_attr);
211 else
212 s = agxget (g, GG_labelattribute(g));
213 if ((*s == '\0') || !strcmp (s, "name"))
214 lbl = agnameof (v);
215 else {
216 lbl = agget (v, s);
217 if (!lbl) lbl = "";
218 }
219 return lbl;
220}
221
223{
224 Agnode_t *v;
225 xdot * x;
226 glCompPoint pos;
227 Agsym_t* l_color_attr = GG_nodelabelcolor(g);
228 glCompColor c;
229 int defaultNodeShape;
230 float nodeSize;
231
232 glCompColorxlate(&c,agxget(g,l_color_attr));
233
234 defaultNodeShape=getAttrBool(g,g,"defaultnodeshape",0);
235 if(defaultNodeShape==0)
236 glBegin(GL_POINTS);
237
238 for (v = agfstnode(g); v; v = agnxtnode(g, v))
239 {
240 if(!ND_selected(v))
241 continue;
243 draw_xdot(x,-1);
244 if(x)
245 freeXDot (x);
246 }
247
248 for (v = agfstnode(g); v; v = agnxtnode(g, v))
249 {
250 if(!ND_selected(v))
251 continue;
253 pos = ND_A(v);
254 nodeSize = ND_size(v);
255
256 if (defaultNodeShape == 0)
257 glVertex3f(pos.x, pos.y, pos.z + 0.001f);
258 else if (defaultNodeShape == 1)
259 drawCircle(pos.x, pos.y, nodeSize, pos.z + 0.001f);
260 }
261 if(defaultNodeShape==0)
262 glEnd();
263 for (v = agfstnode(g); v; v = agnxtnode(g, v))
264 {
265 if(!ND_selected(v))
266 continue;
267 if (ND_printLabel(v)==1)
268 {
269 pos = ND_A(v);
270 glColor4f(c.R, c.G,c.B, c.A);
271 glprintfglut(view->glutfont, pos.x, pos.y, pos.z + 0.002f, labelOf(g, v));
272 }
273 }
274}
275
276
277
278static void renderNodes(Agraph_t * g)
279{
280 Agnode_t *v;
281 glCompPoint pos;
282 Agsym_t* pos_attr = GN_pos(g);
283 Agsym_t* size_attr = GN_size(g);
284 Agsym_t* selected_attr = GN_selected(g);
285 int defaultNodeShape;
286 float nodeSize;
287 glCompColor c;
288 xdot * x;
289 int ind;
290
291 defaultNodeShape=getAttrInt(g,g,"defaultnodeshape",0);
292
294 if (x) {
295 draw_xdot(x, -0.2);
296 freeXDot (x);
297 }
298 for (v = agfstnode(g); v; v = agnxtnode(g, v))
299 {
300 if (!object_color(v, &(glCompColor){0}))
301 continue;
303 draw_xdot(x, -0.1);
304
305 if(x)
306 freeXDot (x);
307 }
308
309 if(defaultNodeShape==0)
310 glBegin(GL_POINTS);
311
312 ind=0;
313
314 for (v = agfstnode(g); v; v = agnxtnode(g, v))
315 {
316 ND_TVref(v) = ind;
317 if(!object_color(v,&c))
318 {
319 ND_visible(v) = 0;
320 continue;
321 }
322 else
323 ND_visible(v) = 1;
324
325 if(l_int(v, selected_attr,0))
326 {
327 ND_selected(v) = 1;
328 }
329 glColor4f(c.R,c.G,c.B,c.A);
330 pos=getPointFromStr(agxget(v, pos_attr));
331 nodeSize = l_float(v, size_attr, 0);
332
333 ND_A(v) = pos;
334
335 if (nodeSize > 0)
336 nodeSize=nodeSize*view->nodeScale;
337 else
338 nodeSize=view->nodeScale;
339 if(defaultNodeShape==0)
340 nodeSize=1;
341 ND_size(v) = nodeSize;
342 if (defaultNodeShape == 0)
343 glVertex3f(pos.x,pos.y,pos.z);
344 else if (defaultNodeShape == 1)
345 drawCircle(pos.x,pos.y,nodeSize,pos.z);
346 ind++;
347 }
348 if(defaultNodeShape==0)
349 glEnd();
350}
351
352
354{
355
356 Agedge_t *e;
357 Agnode_t *v;
358 xdot * x;
359 glCompPoint posT; /*Tail position*/
360 glCompPoint posH; /*Head position*/
361 /*xdots tend to be drawn as background shapes,that is why they are being rendered before edges*/
362
363 for (v = agfstnode(g); v; v = agnxtnode(g, v))
364 {
365 for (e = agfstout(g, v); e; e = agnxtout(g, e))
366 {
367 if(!ED_selected(e))
368 continue;
369 if (!object_color(e, &(glCompColor){0}))
370 continue;
371
373 draw_xdot(x,0);
374 if(x)
375 freeXDot (x);
376 }
377 }
378
379 glBegin(GL_LINES);
380 for (v = agfstnode(g); v; v = agnxtnode(g, v))
381 {
382 for (e = agfstout(g, v); e; e = agnxtout(g, e))
383 {
384 if(!ED_selected(e))
385 continue;
386
387 if (!object_color(e, &(glCompColor){0}))
388 continue;
389 glColor4f(1,0,0,1);
390 posT = ED_posTail(e);
391 posH = ED_posHead(e);
392 posT.z +=0.01f;
393 posH.z +=0.01f;
394 draw_edge(posT, posH);
395 }
396 }
397 glEnd();
398}
399
400/* skipWS:
401 * Skip whitespace
402 */
403static char* skipWS (char* p)
404{
405 while (gv_isspace(*p)) p++;
406 return p;
407}
408
409/* skipNWS:
410 * Skip non-whitespace
411 */
412static char* skipNWS (char* p)
413{
414 while (*p && !gv_isspace(*p)) p++;
415 return p;
416}
417
418/* readPoint:
419 * Parse x,y[,z] and store in pt.
420 * If z is not specified, set to 0.
421 * Return pointer to next character after reading the point.
422 * Return NULL on error.
423 */
424static char* readPoint (char* p, xdot_point* pt)
425{
426 char* endp;
427
428 pt->z = 0;
429 pt->x = strtod (p, &endp);
430 if (p == endp) {
431 return 0;
432 }
433 else
434 p = endp;
435 if (*p == ',') p++;
436 else return 0;
437
438 pt->y = strtod (p, &endp);
439 if (p == endp) {
440 return 0;
441 }
442 else
443 p = endp;
444 if ((*p == ' ') || (*p == '\0')) return p;
445 else if (*p == ',') p++;
446 else return 0;
447
448 pt->z = strtod (p, &endp);
449 if (p == endp) {
450 return 0;
451 }
452 else
453 return endp;
454}
455
456/* countPoints:
457 * count number of points in pos attribute; store in cntp;
458 * check for e and s points; store if found and increment number of
459 * points by 3 for each.
460 * return start of point list (skip over e and s points).
461 * return NULL on failure
462 */
463static char *countPoints(char *pos, int *have_sp, xdot_point *sp, int *have_ep,
464 xdot_point *ep, size_t *cntp) {
465 size_t cnt = 0;
466 char* p;
467
468 pos = skipWS (pos);
469 if (*pos == 's') {
470 if ((pos = readPoint (pos+2, sp))) {
471 *have_sp = 1;
472 cnt += 3;
473 }
474 else
475 return 0;
476 }
477 else
478 *have_sp = 0;
479
480 pos = skipWS (pos);
481 if (*pos == 'e') {
482 if ((pos = readPoint (pos+2, ep))) {
483 *have_ep = 1;
484 cnt += 3;
485 }
486 else
487 return 0;
488 }
489 else
490 *have_ep = 0;
491
492 p = pos = skipWS (pos);
493
494 while (*p) {
495 cnt++;
496 p = skipNWS (p);
497 p = skipWS (p);
498 }
499 *cntp = cnt;
500
501 return pos;
502}
503
504/* storePoints:
505 * read comma-separated list of points
506 * and store them in ps
507 * Assumes enough storage is available.
508 * return -1 on error
509 */
510static int storePoints (char* pos, xdot_point* ps)
511{
512
513 while (*pos) {
514 if ((pos = readPoint (pos, ps))) {
515 ps++;
516 pos = skipWS(pos);
517 }
518 else
519 return -1;
520 }
521 return 0;
522}
523
524/* makeXDotSpline:
525 * Generate an xdot representation of an edge's pos attribute
526 */
527static xdot* makeXDotSpline (char* pos)
528{
529 xdot_point s, e;
530 int v, have_s, have_e;
531 size_t cnt;
532 static const size_t sz = sizeof(sdot_op);
533
534 if (*pos == '\0') return NULL;
535
536 pos = countPoints (pos, &have_s, &s, &have_e, &e, &cnt);
537 if (pos == 0) return NULL;
538
539 xdot_point* pts = gv_calloc(cnt, sizeof(xdot_point));
540 if (have_s) {
541 v = storePoints (pos, pts+3);
542 pts[0] = pts[1] = s;
543 pts[2] = pts[3];
544 }
545 else
546 v = storePoints (pos, pts);
547 if (v) {
548 free (pts);
549 return NULL;
550 }
551
552 if (have_e) {
553 pts[cnt-1] = pts[cnt-2] = e;
554 pts[cnt-3] = pts[cnt-4];
555 }
556
557 xdot_op* op = gv_calloc(sz, sizeof(char));
560 op->u.bezier.cnt = cnt;
561 op->u.bezier.pts = pts;
562
563 xdot* xd = gv_alloc(sizeof(xdot));
564 xd->cnt = 1;
565 xd->sz = sz;
566 xd->ops = op;
567
568 return xd;
569}
570
571typedef void (*edgefn) (Agraph_t *, Agedge_t*, glCompColor);
572
573static void renderEdgesFn (Agraph_t * g, edgefn ef, int skipSelected)
574{
575 Agedge_t *e;
576 Agnode_t *v;
577 glCompColor c;
578
579 for (v = agfstnode(g); v; v = agnxtnode(g, v))
580 {
581 for (e = agfstout(g, v); e; e = agnxtout(g, e))
582 {
583 if ((ND_visible(agtail(e))==0) || (ND_visible(aghead(e))==0))
584 continue;
585
586 if(!object_color(e,&c)) {
587 continue;
588 }
589 if (ED_selected(e) && skipSelected)
590 continue;
591
592 ef (g, e, c);
593 }
594 }
595}
596
597static void edge_xdot (Agraph_t* g, Agedge_t* e, glCompColor c)
598{
599 (void)g;
600 (void)c;
601
602 xdot * x;
604 draw_xdot(x,0);
605 if(x)
606 freeXDot (x);
607}
608
609static void edge_seg (Agraph_t* g, Agedge_t* e, glCompColor c)
610{
611 Agsym_t* pos_attr = GN_pos(g);
612 glCompPoint posT; /*Tail position*/
613 glCompPoint posH; /*Head position*/
614
615 glColor4f(c.R,c.G,c.B,c.A);
616 posT=getPointFromStr(agxget(agtail(e), pos_attr));
617 posH=getPointFromStr(agxget(aghead(e), pos_attr));
618 draw_edge(posT, posH);
619 ED_posTail(e) = posT;
620 ED_posHead(e) = posH;
621}
622
624{
625 Agsym_t* pos_attr_e = GE_pos(g);
626 xdot * x;
627
628 glColor4f(c.R,c.G,c.B,c.A);
629 x = makeXDotSpline (agxget(e,pos_attr_e));
630 if (x) {
631 draw_xdot(x,0);
632 freeXDot (x);
633 }
634}
635
636static void renderEdges(Agraph_t * g)
637{
638 Agsym_t* pos_attr_e = GE_pos(g);
639 int drawSegs = !(pos_attr_e && view->drawSplines);
640 /*xdots tend to be drawn as background shapes,that is why they are being rendered before edges*/
641
642 renderEdgesFn (g, edge_xdot, 0);
643
644 if (drawSegs) {
645 glBegin(GL_LINES);
646 renderEdgesFn (g, edge_seg, 1);
647 glEnd();
648 }
649 else
651}
652
654{
655 Agnode_t *v;
656 glCompPoint pos;
657 Agsym_t* data_attr = GN_labelattribute(g);
658 Agsym_t* l_color_attr = GG_nodelabelcolor(g);
659 glCompColor c;
660
661 glCompColorxlate(&c,agxget(g,l_color_attr));
662
663 for (v = agfstnode(g); v; v = agnxtnode(g, v))
664 {
665 if(ND_visible(v)==0)
666 continue;
667 if(ND_selected(v)==1)
668 continue;
669
670 pos = ND_A(v);
671 glColor4f(c.R,c.G,c.B,c.A);
672 if(!data_attr)
673 glprintfglut(view->glutfont,pos.x,pos.y,pos.z,agnameof(v));
674 else
675 glprintfglut(view->glutfont,pos.x,pos.y,pos.z,agxget(v,data_attr));
676 }
677}
678
680{
681 Agedge_t *e;
682 Agnode_t *v;
683 glCompPoint posT;
684 glCompPoint posH;
685 Agsym_t* data_attr = GE_labelattribute(g);
686 Agsym_t* l_color_attr = GG_edgelabelcolor(g);
687 glCompColor c;
688
689 glCompColorxlate(&c,agxget(g,l_color_attr));
690
691 if(!data_attr || !l_color_attr)
692 return;
693
694 for (v = agfstnode(g); v; v = agnxtnode(g, v))
695 {
696 for (e = agfstout(g, v); e; e = agnxtout(g, e))
697 {
698
699 if (ND_visible(v)==0)
700 continue;
701
702 posT = ED_posTail(e);
703 posH = ED_posHead(e);
704 glColor4f(c.R,c.G,c.B,c.A);
705 float x = posH.x + (posT.x - posH.x) / 2;
706 float y = posH.y + (posT.y - posH.y) / 2;
707 float z = posH.z + (posT.z - posH.z) / 2;
708 glprintfglut(view->glutfont,x,y,z,agxget(e,data_attr));
709
710 }
711 }
712}
713
714
715
716
717
718static void cacheNodes(Agraph_t * g,topview* t)
719{
720 if (t->cache.node_id != UINT_MAX) // clean existing cache
721 glDeleteLists(t->cache.node_id,1);
722 t->cache.node_id=glGenLists(1);
723 glNewList(t->cache.node_id,GL_COMPILE);
724 renderNodes(g);
725 glEndList();
726
727
728
729
730}
731static void cacheEdges(Agraph_t * g,topview* t)
732{
733 if (t->cache.edge_id != UINT_MAX) // clean existing cache
734 glDeleteLists(t->cache.edge_id,1);
735 t->cache.edge_id=glGenLists(1);
736 glNewList(t->cache.edge_id,GL_COMPILE);
737 renderEdges(g);
738 glEndList();
739
740
741}
743{
744 if (t->cache.seledge_id != UINT_MAX) // clean existing cache
745 glDeleteLists(t->cache.seledge_id,1);
746 t->cache.seledge_id=glGenLists(1);
747 glNewList(t->cache.seledge_id,GL_COMPILE);
749 glEndList();
750
751
752}
754{
755 if (t->cache.selnode_id != UINT_MAX) // clean existing cache
756 glDeleteLists(t->cache.selnode_id,1);
757 t->cache.selnode_id=glGenLists(1);
758 glNewList(t->cache.selnode_id,GL_COMPILE);
760 glEndList();
761}
763{
764 if (t->cache.nodelabel_id != UINT_MAX) // clean existing cache
765 glDeleteLists(t->cache.nodelabel_id,1);
766 t->cache.nodelabel_id=glGenLists(1);
767 glNewList(t->cache.nodelabel_id,GL_COMPILE);
769 glEndList();
770}
772{
773 if (t->cache.edgelabel_id != UINT_MAX) // clean existing cache
774 glDeleteLists(t->cache.edgelabel_id,1);
775 t->cache.edgelabel_id=glGenLists(1);
776 glNewList(t->cache.edgelabel_id,GL_COMPILE);
778 glEndList();
779}
780
782{
783 Agnode_t *v;
784 Agedge_t *e;
785 float eLength=0;
786 float totalELength=0;
787
788 t->Nodecount=0;
789 t->maxedgelen=0;
790
791 t->global_z=0;
792 t->sel.selPoly = (glCompPoly_t){0};
793
794 if(!t)
795 return ;
796 /*Node Loop*/
797 for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
798 for (e = agfstout(g, v); e; e = agnxtout(g, e))
799 {
800 eLength=getEdgeLength(e);
801 if(eLength > t->maxedgelen)
802 t->maxedgelen=eLength;
803 totalELength += eLength;
804 }
805 t->Nodecount++;
806
807 }
808 aginit(g, AGNODE, "nodeRec", sizeof(nodeRec), false);
809 aginit(g, AGEDGE, "edgeRec", sizeof(edgeRec), false);
810
812 view->Topview=t;
813
814
815 /*render nodes once to get set some attributes set,THIS IS A HACK, FIX IT*/
816 renderNodes(g);
817 cacheEdges(g,t);
819 cacheNodes(g,t);
821 cacheEdgeLabels(g,t);
822 cacheNodeLabels(g,t);
823}
825{
826 /*create attribute list*/
828
829 // set topological fisheye to NULL
830 rv->fisheyeParams.h = NULL;
831
832 rv->fisheyeParams.active = 0;
833 rv->cache.node_id = UINT_MAX;
834 rv->cache.selnode_id = UINT_MAX;
835 rv->cache.edge_id = UINT_MAX;
836 rv->cache.seledge_id = UINT_MAX;
837 rv->sel.selectEdges = false;
838 rv->sel.selectNodes = true;
839
840 updateSmGraph(g,rv);
841}
842
844{
845 /*
846 we like to have blending affect where node and edge overlap
847 to achive this depth test should be turned off.
848 */
849
850 glEnable(GL_POINT_SMOOTH);
851 glEnable(GL_DEPTH_TEST);
852 glEnable(GL_DEPTH);
853
854 if(view->drawedges)
855 {
856 glCallList(t->cache.edge_id);
857 glCallList(t->cache.seledge_id);
859 {
860 if(view->zoom*-1 < t->fitin_zoom /(float)view->labelnumberofnodes*-1)
861 glCallList(t->cache.edgelabel_id);
862
863 }
864 }
865 if(view->drawnodes)
866 {
867 glPointSize(view->nodeScale*t->fitin_zoom/view->zoom);
868 glCallList(t->cache.node_id);
869 glCallList(t->cache.selnode_id);
871 {
872 if(view->zoom*-1 < t->fitin_zoom /(float)view->labelnumberofnodes*-1)
873 glCallList(t->cache.nodelabel_id);
874 }
875 }
876
877}
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
Definition alloc.h:26
static void * gv_alloc(size_t size)
Definition alloc.h:47
abstract graph C library, Cgraph API
#define right(i)
Definition closest.c:79
@ RGBA_DOUBLE
Definition color.h:27
COLORPROCS_API char * setColorScheme(const char *s)
Definition colxlate.c:395
void colorxlate(char *str, agxbuf *buf)
Definition colxlate.c:46
bool mapbool(const char *p)
Definition utils.c:337
void drawCircle(float x, float y, float radius, float zdepth)
Definition draw.c:383
drawfunc_t OpFns[]
Definition draw.c:399
#define left
Definition dthdr.h:12
#define A(n, t)
Definition expr.h:76
attr_list * load_attr_list(Agraph_t *g)
void glprintfglut(void *font, float xpos, float ypos, float zpos, char *bf)
Definition glcompfont.c:31
void free(void *)
edge
Definition gmlparse.y:239
node NULL
Definition grammar.y:163
static int cnt(Dict_t *d, Dtlink_t **set)
Definition graph.c:200
char * agget(void *obj, char *name)
Definition attr.c:472
char * agxget(void *obj, Agsym_t *sym)
Definition attr.c:482
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Definition edge.c:24
#define agtail(e)
Definition cgraph.h:986
#define aghead(e)
Definition cgraph.h:987
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Definition edge.c:39
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition node.c:47
Agnode_t * agfstnode(Agraph_t *g)
Definition node.c:40
Agraph_t * agraphof(void *obj)
Definition obj.c:185
char * agnameof(void *)
returns a string descriptor for the object.
Definition id.c:143
#define AGTYPE(obj)
returns AGRAPH, AGNODE, or AGEDGE depending on the type of the object
Definition cgraph.h:216
int agobjkind(void *obj)
Definition obj.c:252
@ AGEDGE
Definition cgraph.h:207
@ AGNODE
Definition cgraph.h:207
@ AGRAPH
Definition cgraph.h:207
void aginit(Agraph_t *g, int kind, const char *rec_name, int rec_size, int move_to_front)
attach new records to objects of specified kind
Definition rec.c:170
replacements for ctype.h functions
static bool gv_isspace(int c)
Definition gv_ctype.h:55
static xdot_state_t * xd
static int z
#define B
Definition hierarchy.c:118
textitem scanner parser str
Definition htmlparse.y:224
static Agedge_t * top(edge_stack_t *sp)
Definition tred.c:73
static int * ps
Definition lu.c:51
float getAttrFloat(Agraph_t *g, void *obj, char *attr_name, float def)
int getAttrInt(Agraph_t *g, void *obj, char *attr_name, int def)
int getAttrBool(Agraph_t *g, void *obj, char *attr_name, int def)
glCompPoint getPointFromStr(const char *str)
char * getAttrStr(Agraph_t *g, void *obj, char *attr_name, char *def)
int l_int(void *obj, Agsym_t *attr, int def)
float l_float(void *obj, Agsym_t *attr, float def)
void getcolorfromschema(const colorschemaset sc, float l, float maxl, glCompColor *c)
Definition viewport.c:548
ViewInfo * view
Definition viewport.c:37
#define GG_labelattribute(g)
Definition smyrnadefs.h:201
#define GG_nodelabelcolor(g)
Definition smyrnadefs.h:199
#define GE_pos(g)
Definition smyrnadefs.h:202
#define ED_posHead(e)
Definition smyrnadefs.h:176
#define ND_TVref(n)
Definition smyrnadefs.h:165
#define GN_labelattribute(g)
Definition smyrnadefs.h:200
#define GN_selected(g)
Definition smyrnadefs.h:198
#define ED_posTail(e)
Definition smyrnadefs.h:175
#define ND_size(n)
Definition smyrnadefs.h:164
#define GG_edgelabelcolor(g)
Definition smyrnadefs.h:205
#define ND_printLabel(n)
Definition smyrnadefs.h:162
#define GE_labelattribute(g)
Definition smyrnadefs.h:206
#define GE_visible(g)
Definition smyrnadefs.h:203
#define GN_size(g)
Definition smyrnadefs.h:196
#define ED_selected(e)
Definition smyrnadefs.h:174
#define ND_selected(n)
Definition smyrnadefs.h:161
#define ND_A(n)
Definition smyrnadefs.h:163
#define GN_visible(g)
Definition smyrnadefs.h:197
#define GN_pos(g)
Definition smyrnadefs.h:195
#define ND_visible(n)
Definition smyrnadefs.h:160
graph or subgraph
Definition cgraph.h:424
string attribute descriptor symbol in Agattr_s.dict
Definition cgraph.h:651
float bdxLeft
Definition smyrnadefs.h:289
topview * Topview
Definition smyrnadefs.h:312
int drawnodes
Definition smyrnadefs.h:322
Agraph_t ** g
Definition smyrnadefs.h:295
int drawnodelabels
Definition smyrnadefs.h:324
int labelnumberofnodes
Definition smyrnadefs.h:331
float bdyTop
Definition smyrnadefs.h:289
int drawedges
Definition smyrnadefs.h:323
float nodeScale
Definition smyrnadefs.h:346
colorschemaset colschms
Definition smyrnadefs.h:339
int activeGraph
Definition smyrnadefs.h:299
glCompColor selectedNodeColor
Definition smyrnadefs.h:273
int drawSplines
Definition smyrnadefs.h:338
float bdxRight
Definition smyrnadefs.h:290
float bdyBottom
Definition smyrnadefs.h:290
float zoom
Definition smyrnadefs.h:257
int drawedgelabels
Definition smyrnadefs.h:325
void * glutfont
Definition smyrnadefs.h:328
glCompPoly_t selPoly
Definition smyrnadefs.h:213
bool selectEdges
Definition smyrnadefs.h:215
bool selectNodes
Definition smyrnadefs.h:214
xdot_kind kind
Definition xdot.h:147
xdot_polyline bezier
Definition xdot.h:152
union _xdot_op::@127 u
drawfunc_t drawfunc
Definition xdot.h:161
double RGBA[4]
Definition color.h:32
union color_s::@72 u
xdot_op op
Definition smyrnadefs.h:86
double global_z
Definition smyrnadefs.h:238
struct topview::@56 fisheyeParams
Hierarchy * h
Definition smyrnadefs.h:227
topviewcache cache
Definition smyrnadefs.h:241
int active
Definition smyrnadefs.h:221
size_t Nodecount
Definition smyrnadefs.h:219
attr_list * attributes
Definition smyrnadefs.h:239
float fitin_zoom
Definition smyrnadefs.h:236
selection sel
Definition smyrnadefs.h:242
float maxedgelen
Definition smyrnadefs.h:235
unsigned selnode_id
Definition smyrnadefs.h:117
unsigned nodelabel_id
Definition smyrnadefs.h:119
unsigned node_id
Definition smyrnadefs.h:115
unsigned edge_id
Definition smyrnadefs.h:116
unsigned seledge_id
Definition smyrnadefs.h:118
unsigned edgelabel_id
Definition smyrnadefs.h:120
double x
Definition xdot.h:79
double z
Definition xdot.h:79
double y
Definition xdot.h:79
size_t cnt
Definition xdot.h:87
xdot_point * pts
Definition xdot.h:88
Definition xdot.h:166
xdot_op * ops
Definition xdot.h:169
size_t cnt
Definition xdot.h:167
static char * skipNWS(char *p)
static int storePoints(char *pos, xdot_point *ps)
void cacheSelectedEdges(Agraph_t *g, topview *t)
static void edge_seg(Agraph_t *g, Agedge_t *e, glCompColor c)
static char * readPoint(char *p, xdot_point *pt)
static float getEdgeLength(Agedge_t *edge)
static void renderSelectedNodes(Agraph_t *g)
static glCompPoint getEdgeHead(Agedge_t *edge)
static xdot * parseXdotwithattrs(void *e)
static void draw_edge(glCompPoint posT, glCompPoint posH)
static void edge_xdot(Agraph_t *g, Agedge_t *e, glCompColor c)
void updateSmGraph(Agraph_t *g, topview *t)
static char * countPoints(char *pos, int *have_sp, xdot_point *sp, int *have_ep, xdot_point *ep, size_t *cntp)
static void cacheNodeLabels(Agraph_t *g, topview *t)
static void cacheEdgeLabels(Agraph_t *g, topview *t)
static void draw_xdot(xdot *x, double base_z)
void(* edgefn)(Agraph_t *, Agedge_t *, glCompColor)
static xdot * makeXDotSpline(char *pos)
static void edge_spline(Agraph_t *g, Agedge_t *e, glCompColor c)
static void renderNodes(Agraph_t *g)
static char * labelOf(Agraph_t *g, Agnode_t *v)
static void renderEdges(Agraph_t *g)
static void renderEdgeLabels(Agraph_t *g)
void renderSmGraph(topview *t)
static void cacheEdges(Agraph_t *g, topview *t)
static void glCompColorxlate(glCompColor *c, const char *str)
static void set_boundaries(Agraph_t *g)
static void renderSelectedEdges(Agraph_t *g)
static int visible(Agsym_t *attr, void *obj)
static void cacheNodes(Agraph_t *g, topview *t)
static char * skipWS(char *p)
static void renderEdgesFn(Agraph_t *g, edgefn ef, int skipSelected)
void initSmGraph(Agraph_t *g, topview *rv)
static void renderNodeLabels(Agraph_t *g)
static glCompPoint getEdgeTail(Agedge_t *edge)
void cacheSelectedNodes(Agraph_t *g, topview *t)
static int object_color(void *obj, glCompColor *c)
graphs, nodes and edges info: Agraphinfo_t, Agnodeinfo_t and Agedgeinfo_t
Definition grammar.c:93
xdot * parseXDotFOn(char *s, drawfunc_t fns[], size_t sz, xdot *x)
Definition xdot.c:340
void freeXDot(xdot *x)
Definition xdot.c:760
parsing and deparsing of xdot operations
@ xop_bezier
Definition xdot.h:130
@ xd_unfilled_bezier
Definition xdot.h:114