_simplify_draw()
authoryu.dongliang <18588496441@163.com>
Fri, 20 Oct 2023 07:17:35 +0000 (15:17 +0800)
committeryu.dongliang <18588496441@163.com>
Fri, 20 Oct 2023 07:17:35 +0000 (15:17 +0800)
ses_step_dc_input.c
ses_step_simplify.c

index 2daed43d333c38e1b594e722cfb0cd0411eae975..5b6fb05c1cd4b25b514c1468de332953054ad53e 100644 (file)
@@ -3,10 +3,14 @@
 static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
 {
        ScfEcomponent*   B;
+       ScfEcomponent*   c;
        ScfEline*        el;
+       ScfEline*        el2;
        ScfEpin*         p;
 
        size_t i;
+       size_t j;
+       int    k;
 
        B = f->components[0];
 
@@ -15,13 +19,29 @@ static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx
        for (i = 0; i < f->n_elines; i++) {
                el =        f->elines[i];
 
-               if (SCF_EDA_PIN_IN & el->flags) {
+               if (!(SCF_EDA_PIN_IN & el->flags))
+                       continue;
 
-                       el->v = (0x0) * B->v;
-                       el->vconst = 1;
+               k   = SCF_EDA_Battery_POS;
+               el2 = f->elines[B->pins[k]->lid];
 
-                       scf_logw("IN el: %ld, V: %lg\n", el->id, el->v);
+               el->v      = k * B->v;
+               el->vconst = 1;
+
+               for (j = 0; j + 1 < el->n_pins; j += 2) {
+
+                       c  = f->components[el->pins[j]];
+                       p  = c->pins      [el->pins[j + 1]];
+
+                       int ret = scf_eline__add_pin(el2, c->id, p->id);
+                       if (ret < 0)
+                               return ret;
+
+                       p->lid = el2->id;
+                       scf_logw("c%ld, p%ld, l%ld --> l%ld\n", c->id, p->id, p->c_lid, p->lid);
                }
+
+               scf_logw("IN el: %ld, V: %lg\n", el->id, el->v);
        }
 
        return 0;
index e021f9a0832bba6f41d422e6c6975d63e47d2575..b4ec223db5f49a84f0e7f648857c162af6fe4948 100644 (file)
@@ -72,10 +72,6 @@ static int _simplify_draw(ScfEfunction* f, uint32_t bx, uint32_t by, uint32_t bw
        for (j = 0; j < f->n_components; j++) {
                c  =        f->components[j];
 
-               if ((SCF_EDA_Diode == c->type || SCF_EDA_NPN == c->type)
-                               && SCF_EDA_Status_OFF == c->status)
-                       continue;
-
                cairo_set_line_width(cr, 2);
 
                uint8_t text[64];
@@ -88,7 +84,11 @@ static int _simplify_draw(ScfEfunction* f, uint32_t bx, uint32_t by, uint32_t bw
                cairo_show_text       (cr, text);
                cairo_stroke(cr);
 
-               cairo_set_source_rgb(cr, 0.6, 0.6, 0.0);
+               if ((SCF_EDA_Diode == c->type || SCF_EDA_NPN == c->type)
+                               && SCF_EDA_Status_OFF == c->status)
+                       cairo_set_source_rgb(cr, 0.0, 0.6, 0.6);
+               else
+                       cairo_set_source_rgb(cr, 0.6, 0.6, 0.0);
 
                for (k = 0; k < c->n_pins; k++) {
                        p  =        c->pins[k];
@@ -234,57 +234,7 @@ static int _simplify_draw(ScfEfunction* f, uint32_t bx, uint32_t by, uint32_t bw
 
 static int _simplify_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
 {
-       ScfEcomponent*   c;
-       ScfEcomponent*   B;
-       ScfEline*        el;
-       ScfEline*        el2;
-       ScfEline*        elp;
-       ScfEline*        eln;
-       ScfEpin*         p;
-
-       size_t i;
-       size_t j;
-       size_t k;
-
-       B = f->components[0];
-
-       elp = f->elines[B->pins[SCF_EDA_Battery_POS]->lid];
-       eln = f->elines[B->pins[SCF_EDA_Battery_NEG]->lid];
-
-       for (i = 0; i < f->n_elines; i++) {
-               el =        f->elines[i];
-
-               if (!(SCF_EDA_PIN_IN & el->flags))
-                       continue;
-
-               if (el->v == elp->v)
-                       el2    = elp;
-               else if (el->v == eln->v)
-                       el2    = eln;
-               else
-                       continue;
-
-               for (j = 0; j + 1 < el->n_pins; j += 2) {
-
-                       c  = f->components[el->pins[j]];
-                       p  = c->pins      [el->pins[j + 1]];
-
-                       if (SCF_EDA_Status_OFF == c->status)
-                               continue;
-
-                       int ret = scf_eline__add_pin(el2, c->id, p->id);
-                       if (ret < 0)
-                               return ret;
-
-                       p->lid = el2->id;
-
-                       scf_logw("c%ld, p%ld, l%ld --> l%ld\n", c->id, p->id, p->c_lid, p->lid);
-               }
-       }
-
        _simplify_draw(f, f->x, f->y, f->w, f->h);
-
-       printf("\n");
        return 0;
 }