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