_simplify_draw()
authoryu.dongliang <18588496441@163.com>
Tue, 31 Oct 2023 11:19:28 +0000 (19:19 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 31 Oct 2023 11:19:28 +0000 (19:19 +0800)
ses_layout.c
ses_step_simplify.c

index db8603403b57b2b113260f78fc2635093a69f593..2a35545a087d7e35d3ccbc0cd618dd03646f7c8e 100644 (file)
@@ -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;
index 40d824fc0772cfb16925ab8ef3635e9d83f1c14f..d11c6938f72e8cfa4c7196b44df5e1c0fc2e549e 100644 (file)
@@ -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");