From: yu.dongliang <18588496441@163.com> Date: Tue, 31 Oct 2023 11:19:28 +0000 (+0800) Subject: _simplify_draw() X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=0c9234910705427989b0655fa2dce3a4ede8c58c;p=ses.git _simplify_draw() --- diff --git a/ses_layout.c b/ses_layout.c index db86034..2a35545 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -481,14 +481,14 @@ int ses_lines_same_components(ScfEfunction* f) el0->n_lines = 0; - scf_logd("el0: %ld, n_conns: %ld, n_pins: %ld, flags: %#lx\n", el0->id, el0->n_conns, el0->n_pins, el0->flags); + scf_logw("el0: %ld, n_conns: %ld, n_pins: %ld, flags: %#lx\n", el0->id, el0->n_conns, el0->n_pins, el0->flags); for (j = 0; j < el0->n_conns; j++) { ec = el0->conns[j]; - scf_logd("j: %ld, lid: %ld, n_cids: %ld, cid[0]: %ld\n", j, ec->lid, ec->n_cids, ec->cids[0]); + scf_logi("j: %ld, lid: %ld, n_cids: %ld, cid[0]: %ld\n", j, ec->lid, ec->n_cids, ec->cids[0]); } -// printf("\n"); + printf("\n"); } #endif @@ -1476,7 +1476,7 @@ int ses_layout_board(ScfEboard* b) return ret; } -// ses_steps_analyse(f, 5, 1); + ses_steps_analyse(f, 5, 1); x = f->x; y = f->y; diff --git a/ses_step_simplify.c b/ses_step_simplify.c index 40d824f..d11c693 100644 --- a/ses_step_simplify.c +++ b/ses_step_simplify.c @@ -153,6 +153,7 @@ static int _simplify_draw(ScfEfunction* f, uint32_t bx, uint32_t by, uint32_t bw cairo_line_to(cr, p->x, p->y); } + cairo_stroke(cr); break; case SCF_EDA_Resistor: @@ -173,6 +174,8 @@ static int _simplify_draw(ScfEfunction* f, uint32_t bx, uint32_t by, uint32_t bw p = c->pins[1]; cairo_move_to (cr, p->x, p->y); cairo_line_to (cr, c->x + dx1, c->y + dy1); + + cairo_stroke(cr); break; case SCF_EDA_Diode: @@ -195,6 +198,8 @@ static int _simplify_draw(ScfEfunction* f, uint32_t bx, uint32_t by, uint32_t bw cairo_line_to (cr, c->x + dx1, c->y + dy1); cairo_rel_move_to(cr, dx0, dy0); cairo_rel_line_to(cr, -dx0 * 2, -dy0 * 2); + + cairo_stroke(cr); break; case SCF_EDA_NPN: @@ -211,26 +216,49 @@ static int _simplify_draw(ScfEfunction* f, uint32_t bx, uint32_t by, uint32_t bw cairo_line_to (cr, c->x - dx3, c->y - dy3); cairo_rel_move_to(cr, dx0, dy0); cairo_rel_line_to(cr, -dx0 * 2, -dy0 * 2); + cairo_stroke(cr); + + if ((c->x + dx3 + dx0 > c->x + dx3 - dx0 && pe->x > pc->x) + || (c->x + dx3 + dx0 < c->x + dx3 - dx0 && pe->x < pc->x)) { - cairo_move_to(cr, c->x - dx3, c->y - dy3); - cairo_line_to(cr, c->x + dx3 + dx0, c->y + dy3 + dy0); - cairo_line_to(cr, pe->x, pe->y); + cairo_move_to(cr, c->x - dx3, c->y - dy3); + cairo_line_to(cr, c->x + dx3 + dx0, c->y + dy3 + dy0); + cairo_line_to(cr, pe->x, pe->y); - vertical(&dx1, &dy1, dx3 * 2 + dx0, dy3 * 2 + dy0, 3); - forward (&dx4, &dy4, dx3 * 2 + dx0, dy3 * 2 + dy0, 8); + vertical(&dx1, &dy1, dx3 * 2 + dx0, dy3 * 2 + dy0, 3); + forward (&dx4, &dy4, dx3 * 2 + dx0, dy3 * 2 + dy0, 8); - cairo_move_to(cr, c->x - dx3 + dx4 + dx1, c->y - dy3 + dy4 + dy1); - cairo_line_to(cr, c->x + dx3 + dx0, c->y + dy3 + dy0); - cairo_line_to(cr, c->x - dx3 + dx4 - dx1, c->y - dy3 + dy4 - dy1); + cairo_move_to(cr, c->x - dx3 + dx4 + dx1, c->y - dy3 + dy4 + dy1); + cairo_line_to(cr, c->x + dx3 + dx0, c->y + dy3 + dy0); + cairo_line_to(cr, c->x - dx3 + dx4 - dx1, c->y - dy3 + dy4 - dy1); + cairo_stroke(cr); - cairo_move_to(cr, c->x - dx3, c->y - dy3); - cairo_line_to(cr, c->x + dx3 - dx0, c->y + dy3 - dy0); - cairo_line_to(cr, pc->x, pc->y); + cairo_move_to(cr, c->x - dx3, c->y - dy3); + cairo_line_to(cr, c->x + dx3 - dx0, c->y + dy3 - dy0); + cairo_line_to(cr, pc->x, pc->y); + cairo_stroke(cr); + } else { + cairo_move_to(cr, c->x - dx3, c->y - dy3); + cairo_line_to(cr, c->x + dx3 + dx0, c->y + dy3 + dy0); + cairo_line_to(cr, pc->x, pc->y); + cairo_stroke(cr); + + cairo_move_to(cr, c->x - dx3, c->y - dy3); + cairo_line_to(cr, c->x + dx3 - dx0, c->y + dy3 - dy0); + cairo_line_to(cr, pe->x, pe->y); + + vertical(&dx1, &dy1, dx3 * 2 - dx0, dy3 * 2 - dy0, 3); + forward (&dx4, &dy4, dx3 * 2 - dx0, dy3 * 2 - dy0, 8); + + cairo_move_to(cr, c->x - dx3 + dx4 + dx1, c->y - dy3 + dy4 + dy1); + cairo_line_to(cr, c->x + dx3 - dx0, c->y + dy3 - dy0); + cairo_line_to(cr, c->x - dx3 + dx4 - dx1, c->y - dy3 + dy4 - dy1); + cairo_stroke(cr); + } break; default: break; }; - cairo_stroke(cr); } cairo_surface_write_to_png(surface, "./simplify.png");