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