~ubuntu-branches/ubuntu/lucid/graphviz/lucid-updates

« back to all changes in this revision

Viewing changes to cmd/tools/gvcolor.c

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2008-06-19 20:23:23 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080619202323-ls23h96ntj9ny94m
Tags: 2.18-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Build depend on liblualib50-dev instead of liblua5.1-0-dev.
  - Drop libttf-dev (libttf-dev is in universe) (LP: #174749).
  - Replace gs-common with ghostscript.
  - Build-depend on python-dev instead of python2.4-dev or python2.5-dev.
  - Mention the correct python version for the python bindings in the
    package description.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: gvcolor.c,v 1.5 2007/08/08 23:00:58 erg Exp $ $Revision: 1.5 $ */
 
1
/* $Id: gvcolor.c,v 1.6 2008/01/09 20:50:35 erg Exp $ $Revision: 1.6 $ */
2
2
/* vim:set shiftwidth=4 ts=8: */
3
3
 
4
4
/**********************************************************
27
27
/* if NC changes, a bunch of scanf calls below are in trouble */
28
28
#define NC      3               /* size of HSB color vector */
29
29
 
 
30
#ifdef USE_CGRAPH
 
31
#include <cgraph.h>
 
32
#include <stdlib.h>
 
33
typedef struct Agnodeinfo_t {
 
34
    Agrec_t h;
 
35
    double relrank;     /* coordinate of its rank, smaller means lower rank */
 
36
    double x[NC];       /* color vector */
 
37
} Agnodeinfo_t;
 
38
 
 
39
#define ND_relrank(n) (((Agnodeinfo_t*)((n)->base.data))->relrank)
 
40
#define ND_x(n) (((Agnodeinfo_t*)((n)->base.data))->x)
 
41
 
 
42
#else
30
43
typedef struct Agnodeinfo_t {
31
44
    double relrank;             /* coordinate of its rank, smaller means lower rank */
32
45
    double x[NC];               /* color vector */
41
54
 
42
55
#define ND_relrank(n) (n)->u.relrank
43
56
#define ND_x(n) (n)->u.x
 
57
#define aghead(e) ((e)->head)
 
58
#define agtail(e) ((e)->tail)
44
59
 
45
60
#include <graph.h>
 
61
#endif
46
62
#include <ingraphs.h>
47
63
#include <stdio.h>
48
64
#ifdef HAVE_UNISTD_H
68
84
static int cmpf(Agnode_t ** n0, Agnode_t ** n1)
69
85
{
70
86
    double t;
71
 
    t = ((*n0)->u.relrank - (*n1)->u.relrank);
 
87
    t = ND_relrank(*n0) - ND_relrank(*n1);
72
88
    if (t < 0.0)
73
89
        return -1;
74
90
    if (t > 0.0)
128
144
    double x, y, maxrank = 0.0;
129
145
    double sum[NC], d, lowsat, highsat;
130
146
 
 
147
#ifdef USE_CGRAPH
 
148
    if (agattr(g, AGNODE, "pos", 0) == NULL) {
 
149
#else
131
150
    if (agfindattr(g->proto->n, "pos") == NULL) {
 
151
#endif
132
152
        fprintf(stderr,
133
153
                "graph must be run through 'dot' before 'gvcolor'\n");
134
154
        exit(1);
135
155
    }
 
156
#ifdef USE_CGRAPH
 
157
    aginit(g, AGNODE, "nodeinfo", sizeof(Agnodeinfo_t), TRUE);
 
158
    if (agattr(g, AGNODE, "style", 0) == NULL)
 
159
        agattr(g, AGNODE, "style", "filled");
 
160
#else
136
161
    if (agfindattr(g->proto->n, "style") == NULL)
137
162
        agnodeattr(g, "style", "filled");
 
163
#endif
138
164
    if ((p = agget(g, "Defcolor")))
139
165
        setcolor(p, Defcolor);
140
166
 
188
214
            sum[j] = 0.0;
189
215
        cnt = 0;
190
216
        for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
191
 
            v = e->head;
 
217
            v = aghead(e);
192
218
            if (v == n)
193
 
                v = e->tail;
 
219
                v = agtail(e);
194
220
            d = ND_relrank(v) - ND_relrank(n) - 0.01;
195
221
            if (d < 0) {
196
222
                double t = 0.0;
239
265
    }
240
266
}
241
267
 
 
268
#ifdef USE_CGRAPH
 
269
static Agraph_t *gread(FILE * fp)
 
270
{
 
271
    return agread(fp, (Agdisc_t *) 0);
 
272
}
 
273
#endif
 
274
 
242
275
int main(int argc, char **argv)
243
276
{
244
277
    Agraph_t *g;
245
278
    ingraph_state ig;
246
279
 
247
280
    init(argc, argv);
 
281
#ifdef USE_CGRAPH
 
282
    newIngraph(&ig, Files, gread);
 
283
#else
248
284
    newIngraph(&ig, Files, agread);
249
285
    aginit();
 
286
#endif
250
287
 
251
288
    while ((g = nextGraph(&ig)) != 0) {
252
289
        color(g);