}
else return 1;
}
+
static int object_color(void* obj,glCompColor* c)
{
gvcolor_t cl;
Alpha=getAttrFloat(g,objg,"defaultedgealpha",1);
vis = GE_visible (objg);
}
- if(objType==AGNODE) {
+ else if(objType==AGNODE) {
Alpha=getAttrFloat(g,objg,"defaultnodealpha",1);
vis = GN_visible (objg);
}
if (!visible(vis,obj))
return 0;
- /*get edge's color attribute */
setColorScheme (agget (obj, "colorscheme"));
- bf=getAttrStr(g,obj,"color",NULL);
- if((bf)&&(strlen(bf)>0))
- {
+ /*get objects's color attribute */
+ bf = getAttrStr(g,obj,"color",NULL);
+ if(bf && (*bf)) {
colorxlate(bf, &cl, RGBA_DOUBLE);
- c->R=cl.u.RGBA[0];
- c->G=cl.u.RGBA[1];
- c->B=cl.u.RGBA[2];
- c->A=cl.u.RGBA[3];
-
+ c->R = cl.u.RGBA[0];
+ c->G = cl.u.RGBA[1];
+ c->B = cl.u.RGBA[2];
+ c->A = cl.u.RGBA[3]*Alpha;
}
else
{
else
{
colorxlate(agget(g, "defaultnodecolor"),&cl, RGBA_DOUBLE);
- c->R=cl.u.RGBA[0];
- c->G=cl.u.RGBA[1];
- c->B=cl.u.RGBA[2];
- c->A=cl.u.RGBA[3];
+ c->R = cl.u.RGBA[0];
+ c->G = cl.u.RGBA[1];
+ c->B = cl.u.RGBA[2];
+ c->A = cl.u.RGBA[3];
}
- c->A=c->A*Alpha;
+ c->A = c->A*Alpha;
}
return return_value;
}
-
-
/*
draws multi edges , single edges
this function assumes glBegin(GL_LINES) has been called
}
}
-
-
-
glBegin(GL_LINES);
for (v = agfstnode(g); v; v = agnxtnode(g, v))
{
if ((ND_visible(agtail(e))==0) || (ND_visible(aghead(e))==0))
continue;
- if(!object_color(e,&c))
- {
+ if(!object_color(e,&c)) {
ED_visible(e) = 0;
continue;
}
glCompPoint posT; /*Tail position*/
glCompPoint posH; /*Head position*/
- glColor4f(c.R,c.G,c.B,1);
+ glColor4f(c.R,c.G,c.B,c.A);
posT=getPointFromStr(agxget(agtail(e), pos_attr));
posH=getPointFromStr(agxget(aghead(e), pos_attr));
draw_edge(&posT,&posH,getEdgeLength(e),0);
Agsym_t* pos_attr_e = GE_pos(g);
xdot * x;
- glColor4f(c.R,c.G,c.B,1);
+ glColor4f(c.R,c.G,c.B,c.A);
x = makeXDotSpline (agxget(e,pos_attr_e));
if (x) {
draw_xdot(x,0);
return add_graph_to_viewport(graph, fileName);
}
+/* updateRecord:
+ * Update fields which may be added dynamically.
+ */
+void updateRecord (Agraph_t* g)
+{
+ GN_size(g) = agattr (g, AGNODE, "size", 0);
+ GN_visible(g) = agattr (g, AGNODE, "visible", 0);
+ GN_selected(g) = agattr (g, AGNODE, "selected", 0);
+
+ GE_pos(g)=agattr(g,AGEDGE,"pos",0);
+ GE_visible(g) = agattr (g, AGEDGE, "visible", 0);
+ GE_selected(g) = agattr (g, AGEDGE, "selected", 0);
+}
/* graphRecord:
* add graphRec to graph if necessary.
* We assume the graph has attributes nodelabelattribute, edgelabelattribute,
* nodelabelcolor and edgelabelcolor from template.dot.
* We assume nodes have pos attributes.
+ * Only size, visible, selected and edge pos may or may not be defined.
*/
static void
graphRecord (Agraph_t* g)
GG_edgelabelcolor(g) = agattr (g, AGRAPH, "edgelabelcolor", 0);
GN_pos(g) = agattr (g, AGNODE, "pos", 0);
- GN_size(g) = agattr (g, AGNODE, "size", 0);
- GN_visible(g) = agattr (g, AGNODE, "visible", 0);
- GN_selected(g) = agattr (g, AGNODE, "selected", 0);
GN_labelattribute(g) = agattr (g, AGNODE, agget(g,"nodelabelattribute"), 0);
- GE_pos(g)=agattr(g,AGEDGE,"pos",0);
- GE_visible(g) = agattr (g, AGEDGE, "visible", 0);
- GE_selected(g) = agattr (g, AGEDGE, "selected", 0);
GE_labelattribute(g) = agattr (g, AGEDGE, agget(g,"edgelabelattribute"), 0);
-}
-
+ updateRecord (g);
+}
void refreshViewport(int doClear)
{
glCompColor * c)
{
int ind;
- /* float cuml=0.00; */
- float percl = l / maxl * 100.00;
- for (ind = 0; ind < sc->schemacount; ind++) {
- if (percl < sc->s[ind].perc)
- break;
- }
+ float percl = l / maxl;
- if (sc->s[ind].smooth) {
+ if (sc->smooth) {
+ /* For smooth schemas, s[0].perc = 0, so we start with ind=1 */
+ for (ind = 1; ind < sc->schemacount-1; ind++) {
+ if (percl < sc->s[ind].perc)
+ break;
+ }
c->R =
interpol(sc->s[ind - 1].perc, sc->s[ind].perc,
sc->s[ind - 1].c.R, sc->s[ind].c.R, percl);
c->B =
interpol(sc->s[ind - 1].perc, sc->s[ind].perc,
sc->s[ind - 1].c.B, sc->s[ind].c.B, percl);
- c->A = 1;
- } else {
+ }
+ else {
+ for (ind = 0; ind < sc->schemacount-1; ind++) {
+ if (percl < sc->s[ind].perc)
+ break;
+ }
c->R = sc->s[ind].c.R;
c->G = sc->s[ind].c.G;
c->B = sc->s[ind].c.B;
- c->A = 1;
}
+
+ c->A = 1;
}
/* set_color_theme_color:
int colorcnt = sc->schemacount;
gvcolor_t cl;
float av_perc;
- av_perc = 100.00 / (float) (colorcnt - 1);
- for (ind = 0; ind < colorcnt; ind++) {
- colorxlate(colorstr[ind], &cl, RGBA_DOUBLE);
- sc->s[ind].c.R = cl.u.RGBA[0];
- sc->s[ind].c.G = cl.u.RGBA[1];
- sc->s[ind].c.B = cl.u.RGBA[2];
- sc->s[ind].c.A = cl.u.RGBA[3];
- sc->s[ind].perc = ind * av_perc;
- sc->s[ind].smooth = smooth;
+
+ sc->smooth = smooth;
+ if (smooth) {
+ av_perc = 1.0 / (float) (colorcnt-1);
+ for (ind = 0; ind < colorcnt; ind++) {
+ colorxlate(colorstr[ind], &cl, RGBA_DOUBLE);
+ sc->s[ind].c.R = cl.u.RGBA[0];
+ sc->s[ind].c.G = cl.u.RGBA[1];
+ sc->s[ind].c.B = cl.u.RGBA[2];
+ sc->s[ind].c.A = cl.u.RGBA[3];
+ sc->s[ind].perc = ind * av_perc;
+ }
+ }
+ else {
+ av_perc = 1.0 / (float) (colorcnt);
+ for (ind = 0; ind < colorcnt; ind++) {
+ colorxlate(colorstr[ind], &cl, RGBA_DOUBLE);
+ sc->s[ind].c.R = cl.u.RGBA[0];
+ sc->s[ind].c.G = cl.u.RGBA[1];
+ sc->s[ind].c.B = cl.u.RGBA[2];
+ sc->s[ind].c.A = cl.u.RGBA[3];
+ sc->s[ind].perc = (ind+1) * av_perc;
+ }
}
}