const ScfEline* el0 = *(const ScfEline**)v0;
const ScfEline* el1 = *(const ScfEline**)v1;
- if (el0->n_pins < el1->n_pins)
+ if (el0->n_conns < el1->n_conns)
return 1;
- if (el0->n_pins > el1->n_pins)
+ if (el0->n_conns > el1->n_conns)
return -1;
- if (el0->n_conns < el1->n_conns)
+ if (el0->n_pins < el1->n_pins)
return 1;
- if (el0->n_conns > el1->n_conns)
+ if (el0->n_pins > el1->n_pins)
return -1;
return 0;
f->x = bx;
f->y = by;
+ f->w = 0;
+ f->h = 0;
n = 0;
for (i = 0; i < f->n_elines; i++) {
el = f->elines[i];
w = el->n_pins * d;
+ m = (w + bw - 1) / bw;
+ h = (n + m) * d;
- if (w <= bw)
- n++;
- else
- n += (w + bw - 1) / bw;
- }
-
- f->h = n * d;
-
- if (f->h > bh) {
- scf_loge("board's height too small, f->n_elines: %ld, n: %ld, f->h: %d, bh: %d\n", f->n_elines, n, f->h, bh);
- return -EINVAL;
- }
-
- n = (n + 1) >> 1;
- m = 0;
-
- for (i = 0; i < f->n_elines; i++) {
- el = f->elines[i];
-
- w = el->n_pins * d;
- k = (w + bw - 1) / bw;
- m += k;
+ if (h > bh) {
+ scf_loge("board's height too small, h: %d, bh: %d\n", h, bh);
+ return -EINVAL;
+ }
- if (m < n)
- h = (n - m % n) * d;
- else
- h = (n + m % n) * d;
+ if (f->w < w)
+ f->w = w;
+ f->h = h;
- for (j = 0; j < k; j++) {
+ for (j = 0; j < m; j++) {
- l = malloc(sizeof(ScfLine));
+ l = malloc(sizeof(ScfLine));
if (!l)
return -ENOMEM;
l->x0 = bx;
- l->y0 = by + h - j * d;
+ l->y0 = by + (n + j) * d;
l->x1 = l->x0 + w;
l->y1 = l->y0;
- scf_logi("el i: %ld, j: %ld, h: %d y0: %d, w: %d, bw: %d\n", i, j, h, l->y0, w, bw);
+ scf_logi("i: %ld, el->id: %ld, j: %ld, n: %ld, y0: %d, w: %d\n", i, el->id, j, n, l->y0, w);
if (scf_eline__add_line(el, l) < 0) {
free(l);
}
printf("\n");
+
+ n += m;
}
return 0;
ses_lines_same_components(f);
- ses_layout_function(f, 5, x + 20, y + 20, w - 20, h - 20);
+ ses_layout_function(f, 5, x , y , w , h );
}
// ses_layout_draw();