Graphviz 13.1.2~dev.20250725.0048
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 "gui/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 if (attr) {
128 const char *const s = agxget(obj, attr);
129 if (*s) return mapbool(s);
130 }
131 return 1;
132}
133
134static int object_color(void* obj,glCompColor* c)
135{
136 gvcolor_t cl;
138 Agraph_t* objg=agraphof(obj);
139 float Alpha = 1;
140 Agsym_t* vis;
141
142 const int objType = AGTYPE(obj);
143
144 if(objType==AGEDGE) {
145 Alpha=getAttrFloat(g,objg,"defaultedgealpha",1);
146 vis = GE_visible (objg);
147 }
148 else {
149 assert(objType == AGNODE);
150 Alpha=getAttrFloat(g,objg,"defaultnodealpha",1);
151 vis = GN_visible (objg);
152 }
153 if (!visible(vis,obj))
154 return 0;
155
156 char *previous_color_scheme = setColorScheme(agget (obj, "colorscheme"));
157 /*get objects's color attribute */
158 const char *const bf = getAttrStr(g,obj,"color",NULL);
159 if(bf && (*bf)) {
160 colorxlate(bf, &cl, RGBA_DOUBLE);
161 c->R = cl.u.RGBA[0];
162 c->G = cl.u.RGBA[1];
163 c->B = cl.u.RGBA[2];
164 c->A = cl.u.RGBA[3]*Alpha;
165 }
166 else
167 {
168 if(objType==AGEDGE)
170 else
171 {
172 colorxlate(agget(g, "defaultnodecolor"),&cl, RGBA_DOUBLE);
173 c->R = cl.u.RGBA[0];
174 c->G = cl.u.RGBA[1];
175 c->B = cl.u.RGBA[2];
176 c->A = cl.u.RGBA[3];
177 }
178 c->A *= Alpha;
179
180 }
181
182 char *color_scheme = setColorScheme(previous_color_scheme);
183 free(color_scheme);
184 free(previous_color_scheme);
185
186 return 1;
187}
188
189
190/*
191 draws multi edges , single edges
192 this function assumes glBegin(GL_LINES) has been called
193*/
194static void draw_edge(glCompPoint posT, glCompPoint posH) {
195 glVertex3f(posT.x, posT.y, posT.z);
196 glVertex3f(posH.x, posH.y, posH.z);
197}
198
199static char* labelOf (Agraph_t* g, Agnode_t* v)
200{
201 char* lbl;
202 char* s;
203
204 Agsym_t* data_attr = GN_labelattribute(g);
205 if (data_attr)
206 s = agxget (v, data_attr);
207 else
208 s = agxget (g, GG_labelattribute(g));
209 if ((*s == '\0') || !strcmp (s, "name"))
210 lbl = agnameof (v);
211 else {
212 lbl = agget (v, s);
213 if (!lbl) lbl = "";
214 }
215 return lbl;
216}
217
219{
220 Agnode_t *v;
221 xdot * x;
222 glCompPoint pos;
223 Agsym_t* l_color_attr = GG_nodelabelcolor(g);
224 glCompColor c;
225 int defaultNodeShape;
226 float nodeSize;
227
228 glCompColorxlate(&c,agxget(g,l_color_attr));
229
230 defaultNodeShape=getAttrBool(g,g,"defaultnodeshape",0);
231 if(defaultNodeShape==0)
232 glBegin(GL_POINTS);
233
234 for (v = agfstnode(g); v; v = agnxtnode(g, v))
235 {
236 if(!ND_selected(v))
237 continue;
239 draw_xdot(x,-1);
240 if(x)
241 freeXDot (x);
242 }
243
244 for (v = agfstnode(g); v; v = agnxtnode(g, v))
245 {
246 if(!ND_selected(v))
247 continue;
249 pos = ND_A(v);
250 nodeSize = ND_size(v);
251
252 if (defaultNodeShape == 0)
253 glVertex3f(pos.x, pos.y, pos.z + 0.001f);
254 else if (defaultNodeShape == 1)
255 drawCircle(pos.x, pos.y, nodeSize, pos.z + 0.001f);
256 }
257 if(defaultNodeShape==0)
258 glEnd();
259 for (v = agfstnode(g); v; v = agnxtnode(g, v))
260 {
261 if(!ND_selected(v))
262 continue;
263 if (ND_printLabel(v)==1)
264 {
265 pos = ND_A(v);
266 glColor4f(c.R, c.G,c.B, c.A);
267 glprintfglut(view->glutfont, pos.x, pos.y, pos.z + 0.002f, labelOf(g, v));
268 }
269 }
270}
271
272
273
274static void renderNodes(Agraph_t * g)
275{
276 Agsym_t* pos_attr = GN_pos(g);
277 Agsym_t* size_attr = GN_size(g);
278 Agsym_t* selected_attr = GN_selected(g);
279 glCompColor c;
280
281 const int defaultNodeShape=getAttrInt(g, g, "defaultnodeshape", 0);
282
283 xdot *x = parseXdotwithattrs(g);
284 if (x) {
285 draw_xdot(x, -0.2);
286 freeXDot (x);
287 }
288 for (Agnode_t *v = agfstnode(g); v; v = agnxtnode(g, v)) {
289 if (!object_color(v, &(glCompColor){0}))
290 continue;
292 draw_xdot(x, -0.1);
293
294 if(x)
295 freeXDot (x);
296 }
297
298 if(defaultNodeShape==0)
299 glBegin(GL_POINTS);
300
301 int ind = 0;
302
303 for (Agnode_t *v = agfstnode(g); v; v = agnxtnode(g, v)) {
304 ND_TVref(v) = ind;
305 if(!object_color(v,&c))
306 {
307 ND_visible(v) = 0;
308 continue;
309 }
310 else
311 ND_visible(v) = 1;
312
313 if(l_int(v, selected_attr,0))
314 {
315 ND_selected(v) = 1;
316 }
317 glColor4f(c.R,c.G,c.B,c.A);
318 const glCompPoint pos = getPointFromStr(agxget(v, pos_attr));
319 float nodeSize = l_float(v, size_attr, 0);
320
321 ND_A(v) = pos;
322
323 if (nodeSize > 0)
324 nodeSize *= view->nodeScale;
325 else
326 nodeSize=view->nodeScale;
327 if(defaultNodeShape==0)
328 nodeSize=1;
329 ND_size(v) = nodeSize;
330 if (defaultNodeShape == 0)
331 glVertex3f(pos.x,pos.y,pos.z);
332 else if (defaultNodeShape == 1)
333 drawCircle(pos.x,pos.y,nodeSize,pos.z);
334 ind++;
335 }
336 if(defaultNodeShape==0)
337 glEnd();
338}
339
340
342{
343 /*xdots tend to be drawn as background shapes,that is why they are being rendered before edges*/
344
345 for (Agnode_t *v = agfstnode(g); v; v = agnxtnode(g, v)) {
346 for (Agedge_t *e = agfstout(g, v); e; e = agnxtout(g, e)) {
347 if(!ED_selected(e))
348 continue;
349 if (!object_color(e, &(glCompColor){0}))
350 continue;
351
352 xdot *const x = parseXdotwithattrs(e);
353 draw_xdot(x,0);
354 if(x)
355 freeXDot (x);
356 }
357 }
358
359 glBegin(GL_LINES);
360 for (Agnode_t *v = agfstnode(g); v; v = agnxtnode(g, v)) {
361 for (Agedge_t *e = agfstout(g, v); e; e = agnxtout(g, e)) {
362 if(!ED_selected(e))
363 continue;
364
365 if (!object_color(e, &(glCompColor){0}))
366 continue;
367 glColor4f(1,0,0,1);
368 glCompPoint posT = ED_posTail(e); // tail position
369 glCompPoint posH = ED_posHead(e); // head position
370 posT.z +=0.01f;
371 posH.z +=0.01f;
372 draw_edge(posT, posH);
373 }
374 }
375 glEnd();
376}
377
378/* skipWS:
379 * Skip whitespace
380 */
381static char* skipWS (char* p)
382{
383 while (gv_isspace(*p)) p++;
384 return p;
385}
386
387/* skipNWS:
388 * Skip non-whitespace
389 */
390static char* skipNWS (char* p)
391{
392 while (*p && !gv_isspace(*p)) p++;
393 return p;
394}
395
396/* readPoint:
397 * Parse x,y[,z] and store in pt.
398 * If z is not specified, set to 0.
399 * Return pointer to next character after reading the point.
400 * Return NULL on error.
401 */
402static char* readPoint (char* p, xdot_point* pt)
403{
404 char* endp;
405
406 pt->z = 0;
407 pt->x = strtod (p, &endp);
408 if (p == endp) {
409 return 0;
410 }
411 else
412 p = endp;
413 if (*p == ',') p++;
414 else return 0;
415
416 pt->y = strtod (p, &endp);
417 if (p == endp) {
418 return 0;
419 }
420 else
421 p = endp;
422 if ((*p == ' ') || (*p == '\0')) return p;
423 else if (*p == ',') p++;
424 else return 0;
425
426 pt->z = strtod (p, &endp);
427 if (p == endp) {
428 return 0;
429 }
430 else
431 return endp;
432}
433
434/* countPoints:
435 * count number of points in pos attribute; store in cntp;
436 * check for e and s points; store if found and increment number of
437 * points by 3 for each.
438 * return start of point list (skip over e and s points).
439 * return NULL on failure
440 */
441static char *countPoints(char *pos, int *have_sp, xdot_point *sp, int *have_ep,
442 xdot_point *ep, size_t *cntp) {
443 size_t cnt = 0;
444 char* p;
445
446 pos = skipWS (pos);
447 if (*pos == 's') {
448 if ((pos = readPoint (pos+2, sp))) {
449 *have_sp = 1;
450 cnt += 3;
451 }
452 else
453 return 0;
454 }
455 else
456 *have_sp = 0;
457
458 pos = skipWS (pos);
459 if (*pos == 'e') {
460 if ((pos = readPoint (pos+2, ep))) {
461 *have_ep = 1;
462 cnt += 3;
463 }
464 else
465 return 0;
466 }
467 else
468 *have_ep = 0;
469
470 p = pos = skipWS (pos);
471
472 while (*p) {
473 cnt++;
474 p = skipNWS (p);
475 p = skipWS (p);
476 }
477 *cntp = cnt;
478
479 return pos;
480}
481
482/* storePoints:
483 * read comma-separated list of points
484 * and store them in ps
485 * Assumes enough storage is available.
486 * return -1 on error
487 */
488static int storePoints (char* pos, xdot_point* ps)
489{
490
491 while (*pos) {
492 if ((pos = readPoint (pos, ps))) {
493 ps++;
494 pos = skipWS(pos);
495 }
496 else
497 return -1;
498 }
499 return 0;
500}
501
502/* makeXDotSpline:
503 * Generate an xdot representation of an edge's pos attribute
504 */
505static xdot* makeXDotSpline (char* pos)
506{
507 xdot_point s, e;
508 int v, have_s, have_e;
509 size_t cnt;
510 static const size_t sz = sizeof(sdot_op);
511
512 if (*pos == '\0') return NULL;
513
514 pos = countPoints (pos, &have_s, &s, &have_e, &e, &cnt);
515 if (pos == 0) return NULL;
516
517 xdot_point* pts = gv_calloc(cnt, sizeof(xdot_point));
518 if (have_s) {
519 v = storePoints (pos, pts+3);
520 pts[0] = pts[1] = s;
521 pts[2] = pts[3];
522 }
523 else
524 v = storePoints (pos, pts);
525 if (v) {
526 free (pts);
527 return NULL;
528 }
529
530 if (have_e) {
531 pts[cnt-1] = pts[cnt-2] = e;
532 pts[cnt-3] = pts[cnt-4];
533 }
534
535 xdot_op* op = gv_calloc(sz, sizeof(char));
538 op->u.bezier.cnt = cnt;
539 op->u.bezier.pts = pts;
540
541 xdot* xd = gv_alloc(sizeof(xdot));
542 xd->cnt = 1;
543 xd->sz = sz;
544 xd->ops = op;
545
546 return xd;
547}
548
549typedef void (*edgefn) (Agraph_t *, Agedge_t*, glCompColor);
550
551static void renderEdgesFn(Agraph_t *g, edgefn ef, bool skipSelected) {
552 glCompColor c;
553
554 for (Agnode_t *v = agfstnode(g); v; v = agnxtnode(g, v)) {
555 for (Agedge_t *e = agfstout(g, v); e; e = agnxtout(g, e)) {
556 if (ND_visible(agtail(e)) == 0 || ND_visible(aghead(e)) == 0)
557 continue;
558
559 if(!object_color(e,&c)) {
560 continue;
561 }
562 if (ED_selected(e) && skipSelected)
563 continue;
564
565 ef (g, e, c);
566 }
567 }
568}
569
570static void edge_xdot (Agraph_t* g, Agedge_t* e, glCompColor c)
571{
572 (void)g;
573 (void)c;
574
575 xdot *const x = parseXdotwithattrs(e);
576 draw_xdot(x,0);
577 if(x)
578 freeXDot (x);
579}
580
581static void edge_seg (Agraph_t* g, Agedge_t* e, glCompColor c)
582{
583 Agsym_t* pos_attr = GN_pos(g);
584
585 glColor4f(c.R,c.G,c.B,c.A);
586 // tail position
587 const glCompPoint posT = getPointFromStr(agxget(agtail(e), pos_attr));
588 // head position
589 const glCompPoint posH = getPointFromStr(agxget(aghead(e), pos_attr));
590 draw_edge(posT, posH);
591 ED_posTail(e) = posT;
592 ED_posHead(e) = posH;
593}
594
596{
597 Agsym_t* pos_attr_e = GE_pos(g);
598
599 glColor4f(c.R,c.G,c.B,c.A);
600 xdot *const x = makeXDotSpline(agxget(e, pos_attr_e));
601 if (x) {
602 draw_xdot(x,0);
603 freeXDot (x);
604 }
605}
606
607static void renderEdges(Agraph_t * g)
608{
609 Agsym_t* pos_attr_e = GE_pos(g);
610 int drawSegs = !(pos_attr_e && view->drawSplines);
611 /*xdots tend to be drawn as background shapes,that is why they are being rendered before edges*/
612
613 renderEdgesFn(g, edge_xdot, false);
614
615 if (drawSegs) {
616 glBegin(GL_LINES);
617 renderEdgesFn(g, edge_seg, true);
618 glEnd();
619 }
620 else
621 renderEdgesFn(g, edge_spline, true);
622}
623
625{
626 Agnode_t *v;
627 glCompPoint pos;
628 Agsym_t* data_attr = GN_labelattribute(g);
629 Agsym_t* l_color_attr = GG_nodelabelcolor(g);
630 glCompColor c;
631
632 glCompColorxlate(&c,agxget(g,l_color_attr));
633
634 for (v = agfstnode(g); v; v = agnxtnode(g, v))
635 {
636 if(ND_visible(v)==0)
637 continue;
638 if(ND_selected(v)==1)
639 continue;
640
641 pos = ND_A(v);
642 glColor4f(c.R,c.G,c.B,c.A);
643 if(!data_attr)
644 glprintfglut(view->glutfont,pos.x,pos.y,pos.z,agnameof(v));
645 else
646 glprintfglut(view->glutfont,pos.x,pos.y,pos.z,agxget(v,data_attr));
647 }
648}
649
651{
652 Agedge_t *e;
653 Agnode_t *v;
654 glCompPoint posT;
655 glCompPoint posH;
656 Agsym_t* data_attr = GE_labelattribute(g);
657 Agsym_t* l_color_attr = GG_edgelabelcolor(g);
658 glCompColor c;
659
660 glCompColorxlate(&c,agxget(g,l_color_attr));
661
662 if(!data_attr || !l_color_attr)
663 return;
664
665 for (v = agfstnode(g); v; v = agnxtnode(g, v))
666 {
667 for (e = agfstout(g, v); e; e = agnxtout(g, e))
668 {
669
670 if (ND_visible(v)==0)
671 continue;
672
673 posT = ED_posTail(e);
674 posH = ED_posHead(e);
675 glColor4f(c.R,c.G,c.B,c.A);
676 float x = posH.x + (posT.x - posH.x) / 2;
677 float y = posH.y + (posT.y - posH.y) / 2;
678 float z = posH.z + (posT.z - posH.z) / 2;
679 glprintfglut(view->glutfont,x,y,z,agxget(e,data_attr));
680
681 }
682 }
683}
684
685
686
687
688
689static void cacheNodes(Agraph_t * g,topview* t)
690{
691 if (t->cache.node_id != UINT_MAX) // clean existing cache
692 glDeleteLists(t->cache.node_id,1);
693 t->cache.node_id=glGenLists(1);
694 glNewList(t->cache.node_id,GL_COMPILE);
695 renderNodes(g);
696 glEndList();
697
698
699
700
701}
702static void cacheEdges(Agraph_t * g,topview* t)
703{
704 if (t->cache.edge_id != UINT_MAX) // clean existing cache
705 glDeleteLists(t->cache.edge_id,1);
706 t->cache.edge_id=glGenLists(1);
707 glNewList(t->cache.edge_id,GL_COMPILE);
708 renderEdges(g);
709 glEndList();
710
711
712}
714{
715 if (t->cache.seledge_id != UINT_MAX) // clean existing cache
716 glDeleteLists(t->cache.seledge_id,1);
717 t->cache.seledge_id=glGenLists(1);
718 glNewList(t->cache.seledge_id,GL_COMPILE);
720 glEndList();
721
722
723}
725{
726 if (t->cache.selnode_id != UINT_MAX) // clean existing cache
727 glDeleteLists(t->cache.selnode_id,1);
728 t->cache.selnode_id=glGenLists(1);
729 glNewList(t->cache.selnode_id,GL_COMPILE);
731 glEndList();
732}
734{
735 if (t->cache.nodelabel_id != UINT_MAX) // clean existing cache
736 glDeleteLists(t->cache.nodelabel_id,1);
737 t->cache.nodelabel_id=glGenLists(1);
738 glNewList(t->cache.nodelabel_id,GL_COMPILE);
740 glEndList();
741}
743{
744 if (t->cache.edgelabel_id != UINT_MAX) // clean existing cache
745 glDeleteLists(t->cache.edgelabel_id,1);
746 t->cache.edgelabel_id=glGenLists(1);
747 glNewList(t->cache.edgelabel_id,GL_COMPILE);
749 glEndList();
750}
751
753{
754 Agnode_t *v;
755 Agedge_t *e;
756 float eLength=0;
757 float totalELength=0;
758
759 t->Nodecount=0;
760 t->maxedgelen=0;
761
762 t->global_z=0;
763 t->sel.selPoly = (glCompPoly_t){0};
764
765 if(!t)
766 return ;
767 /*Node Loop*/
768 for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
769 for (e = agfstout(g, v); e; e = agnxtout(g, e))
770 {
771 eLength=getEdgeLength(e);
772 if(eLength > t->maxedgelen)
773 t->maxedgelen=eLength;
774 totalELength += eLength;
775 }
776 t->Nodecount++;
777
778 }
779 aginit(g, AGNODE, "nodeRec", sizeof(nodeRec), false);
780 aginit(g, AGEDGE, "edgeRec", sizeof(edgeRec), false);
781
783 view->Topview=t;
784
785
786 /*render nodes once to get set some attributes set,THIS IS A HACK, FIX IT*/
787 renderNodes(g);
788 cacheEdges(g,t);
790 cacheNodes(g,t);
792 cacheEdgeLabels(g,t);
793 cacheNodeLabels(g,t);
794}
796{
797 /*create attribute list*/
799
800 // set topological fisheye to NULL
801 rv->fisheyeParams.h = NULL;
802
803 rv->fisheyeParams.active = 0;
804 rv->cache.node_id = UINT_MAX;
805 rv->cache.selnode_id = UINT_MAX;
806 rv->cache.edge_id = UINT_MAX;
807 rv->cache.seledge_id = UINT_MAX;
808 rv->sel.selectEdges = false;
809 rv->sel.selectNodes = true;
810
811 updateSmGraph(g,rv);
812}
813
815{
816 // We would like to have blending affect where node and edge overlap. To
817 // achieve this, depth test should be turned off.
818
819 glEnable(GL_POINT_SMOOTH);
820 glEnable(GL_DEPTH_TEST);
821 glEnable(GL_DEPTH);
822
823 if(view->drawedges)
824 {
825 glCallList(t->cache.edge_id);
826 glCallList(t->cache.seledge_id);
828 {
829 if(view->zoom*-1 < t->fitin_zoom /(float)view->labelnumberofnodes*-1)
830 glCallList(t->cache.edgelabel_id);
831
832 }
833 }
834 if(view->drawnodes)
835 {
836 glPointSize(view->nodeScale*t->fitin_zoom/view->zoom);
837 glCallList(t->cache.node_id);
838 glCallList(t->cache.selnode_id);
840 {
841 if(view->zoom*-1 < t->fitin_zoom /(float)view->labelnumberofnodes*-1)
842 glCallList(t->cache.nodelabel_id);
843 }
844 }
845
846}
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:339
void drawCircle(float x, float y, float radius, float zdepth)
Definition draw.c:361
drawfunc_t OpFns[]
Definition draw.c:375
#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:180
static int cnt(Dict_t *d, Dtlink_t **set)
Definition graph.c:198
char * agget(void *obj, char *name)
Definition attr.c:448
char * agxget(void *obj, Agsym_t *sym)
Definition attr.c:458
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Definition edge.c:26
#define agtail(e)
Definition cgraph.h:988
#define aghead(e)
Definition cgraph.h:989
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Definition edge.c:41
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition node.c:48
Agnode_t * agfstnode(Agraph_t *g)
Definition node.c:41
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:532
ViewInfo * view
Definition viewport.c:37
#define GG_labelattribute(g)
Definition smyrnadefs.h:196
#define GG_nodelabelcolor(g)
Definition smyrnadefs.h:194
#define GE_pos(g)
Definition smyrnadefs.h:197
#define ED_posHead(e)
Definition smyrnadefs.h:171
#define ND_TVref(n)
Definition smyrnadefs.h:160
#define GN_labelattribute(g)
Definition smyrnadefs.h:195
#define GN_selected(g)
Definition smyrnadefs.h:193
#define ED_posTail(e)
Definition smyrnadefs.h:170
#define ND_size(n)
Definition smyrnadefs.h:159
#define GG_edgelabelcolor(g)
Definition smyrnadefs.h:200
#define ND_printLabel(n)
Definition smyrnadefs.h:157
#define GE_labelattribute(g)
Definition smyrnadefs.h:201
#define GE_visible(g)
Definition smyrnadefs.h:198
#define GN_size(g)
Definition smyrnadefs.h:191
#define ED_selected(e)
Definition smyrnadefs.h:169
#define ND_selected(n)
Definition smyrnadefs.h:156
#define ND_A(n)
Definition smyrnadefs.h:158
#define GN_visible(g)
Definition smyrnadefs.h:192
#define GN_pos(g)
Definition smyrnadefs.h:190
#define ND_visible(n)
Definition smyrnadefs.h:155
graph or subgraph
Definition cgraph.h:424
string attribute descriptor symbol in Agattr_s.dict
Definition cgraph.h:651
float bdxLeft
Definition smyrnadefs.h:284
topview * Topview
Definition smyrnadefs.h:307
int drawnodes
Definition smyrnadefs.h:317
Agraph_t ** g
Definition smyrnadefs.h:290
int drawnodelabels
Definition smyrnadefs.h:319
int labelnumberofnodes
Definition smyrnadefs.h:324
float bdyTop
Definition smyrnadefs.h:284
int drawedges
Definition smyrnadefs.h:318
float nodeScale
Definition smyrnadefs.h:337
colorschemaset colschms
Definition smyrnadefs.h:330
int activeGraph
Definition smyrnadefs.h:294
glCompColor selectedNodeColor
Definition smyrnadefs.h:268
int drawSplines
Definition smyrnadefs.h:329
float bdxRight
Definition smyrnadefs.h:285
float bdyBottom
Definition smyrnadefs.h:285
float zoom
Definition smyrnadefs.h:252
int drawedgelabels
Definition smyrnadefs.h:320
void * glutfont
Definition smyrnadefs.h:323
glCompPoly_t selPoly
Definition smyrnadefs.h:208
bool selectEdges
Definition smyrnadefs.h:210
bool selectNodes
Definition smyrnadefs.h:209
xdot_kind kind
Definition xdot.h:147
union _xdot_op::@135 u
xdot_polyline bezier
Definition xdot.h:152
drawfunc_t drawfunc
Definition xdot.h:161
double RGBA[4]
Definition color.h:32
union color_s::@74 u
xdot_op op
Definition smyrnadefs.h:84
double global_z
Definition smyrnadefs.h:233
struct topview::@56 fisheyeParams
Hierarchy * h
Definition smyrnadefs.h:222
topviewcache cache
Definition smyrnadefs.h:236
int active
Definition smyrnadefs.h:216
size_t Nodecount
Definition smyrnadefs.h:214
attr_list * attributes
Definition smyrnadefs.h:234
float fitin_zoom
Definition smyrnadefs.h:231
selection sel
Definition smyrnadefs.h:237
float maxedgelen
Definition smyrnadefs.h:230
unsigned selnode_id
Definition smyrnadefs.h:115
unsigned nodelabel_id
Definition smyrnadefs.h:117
unsigned node_id
Definition smyrnadefs.h:113
unsigned edge_id
Definition smyrnadefs.h:114
unsigned seledge_id
Definition smyrnadefs.h:116
unsigned edgelabel_id
Definition smyrnadefs.h:118
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 void renderEdgesFn(Agraph_t *g, edgefn ef, bool skipSelected)
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)
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:89
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