From: yu.dongliang <18588496441@163.com>
Date: Fri, 20 Oct 2023 07:17:35 +0000 (+0800)
Subject: _simplify_draw()
X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=edda30fc5b56946b4d4ffe444a430ec3c9dd9945;p=ses.git

_simplify_draw()
---

diff --git a/ses_step_dc_input.c b/ses_step_dc_input.c
index 2daed43..5b6fb05 100644
--- a/ses_step_dc_input.c
+++ b/ses_step_dc_input.c
@@ -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;
diff --git a/ses_step_simplify.c b/ses_step_simplify.c
index e021f9a..b4ec223 100644
--- a/ses_step_simplify.c
+++ b/ses_step_simplify.c
@@ -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;
 }