43 for (i=0; i < ind; i++) fputs(
" ", stderr);
65 static double getArea (
void* obj,
attrsym_t* ap)
79 p->
area = getArea (n, ap);
86 #define INSERT(cp) if(!first) first=cp; if(prev) prev->rightsib=cp; prev=cp;
100 int i, n_children = 0;
108 cp = mkTree (subg, gp, ap, mp);
117 cp = mkTreeNode (n, ap);
127 p->
area = fullArea (p, mp);
130 p->
area = getArea (g, gp);
139 double diff = (*p0)->area - (*p1)->area;
141 if (diff < 0)
return 1;
142 else if (diff > 0)
return -1;
150 double* areas_sorted;
160 for (i = 0; i < nc; i++) {
166 areas_sorted =
N_NEW(nc,
double);
167 for (i = 0; i < nc; i++) {
168 areas_sorted[i] = nodes[i]->
area;
171 recs =
tree_map(nc, areas_sorted, tree->
r);
174 double disc, delta, m, h = tree->
r.
size[1], w = tree->
r.
size[0];
175 crec.
x[0] = tree->
r.
x[0];
176 crec.
x[1] = tree->
r.
x[1];
178 disc = sqrt(delta*delta + 4.0*tree->
child_area);
179 m = (h + w - disc)/2.0;
180 crec.
size[0] = w - m;
181 crec.
size[1] = h - m;
182 recs =
tree_map(nc, areas_sorted, crec);
185 fprintf (stderr,
"rec %f %f %f %f\n", tree->
r.
x[0], tree->
r.
x[1], tree->
r.
size[0], tree->
r.
size[1]);
186 for (i = 0; i < nc; i++) {
187 nodes[i]->
r = recs[i];
189 fprintf (stderr,
"%f - %f %f %f %f = %f (%f %f %f %f)\n", areas_sorted[i],
190 recs[i].x[0]-recs[i].size[0]*0.5, recs[i].x[1]-recs[i].size[1]*0.5,
191 recs[i].x[0]+recs[i].size[0]*0.5, recs[i].x[1]+recs[i].size[1]*0.5, recs[i].size[0]*recs[i].size[1],
192 recs[i].x[0], recs[i].x[1], recs[i].size[0], recs[i].size[1]);
200 for (i = 0; i < nc; i++) {
207 static void finishNode(
node_t * n)
213 sprintf (buf,
"%.03f",
ND_ht(n)*0.7);
227 double x0, y0, wd, ht;
234 wd = tree->
r.
size[0];
235 ht = tree->
r.
size[1];
236 r.
LL.
x = x0 - wd/2.0;
237 r.
LL.
y = y0 - ht/2.0;
254 fprintf(stderr,
"%s coord %.5g %.5g ht %f width %f\n",
266 for (i = 0; i < nc; i++) {
283 root = mkTree (g,gp,ap,mp);
285 root->
r =
rectangle_new(0, 0, sqrt(total + 0.1), sqrt(total + 0.1));
void patchworkLayout(Agraph_t *g)
int agxset(void *obj, Agsym_t *sym, char *value)
EXTERN Agsym_t * N_fontsize
void common_init_node(node_t *n)
#define PS2INCH(a_points)
CGRAPH_API Agraph_t * agraphof(void *obj)
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
rectangle * tree_map(int n, real *area, rectangle fillrec)
CGRAPH_API char * agnameof(void *)
rectangle rectangle_new(real x, real y, real width, real height)
int(* qsort_cmpf)(const void *, const void *)
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
#define agfindgraphattr(g, a)
double late_double(void *obj, attrsym_t *attr, double def, double low)
EXTERN unsigned char Verbose
void gv_nodesize(node_t *n, boolean flip)
char * agxget(void *obj, Agsym_t *sym)
#define agfindnodeattr(g, a)