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