From c0ff764a2eb9774fbb02f6e07344ef44545634fc Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Sun, 16 Jul 2023 12:48:54 +0800 Subject: [PATCH] ses layout --- main.c | 2 +- ses_layout.c | 29 +++++++++++++++++++++-------- ses_layout.h | 2 +- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/main.c b/main.c index b66b5fc..14184b6 100644 --- a/main.c +++ b/main.c @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) ScfEboard* b = scf_eboard__unpack(NULL, len, pb); - ses_layout_board(b, 0, 0, 500, 500); + ses_layout_board(b); #if 0 size_t i; size_t j; diff --git a/ses_layout.c b/ses_layout.c index 4d7df78..edb1427 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -346,7 +346,7 @@ int ses_lines_same_components(ScfEfunction* f) return 0; } -int ses_layout_function(ScfEfunction* f, uint32_t d, uint32_t bx, uint32_t by, uint32_t bw, uint32_t bh) +int ses_layout_function(ScfEfunction* f, int d) { ScfEcomponent* c0; ScfEcomponent* c1; @@ -370,8 +370,8 @@ int ses_layout_function(ScfEfunction* f, uint32_t d, uint32_t bx, uint32_t by, u size_t m; size_t n; - f->x = bx; - f->y = by; + f->x = 0; + f->y = 0; f->w = 0; f->h = 0; @@ -382,9 +382,9 @@ int ses_layout_function(ScfEfunction* f, uint32_t d, uint32_t bx, uint32_t by, u if (!l0) return -ENOMEM; - l0->x0 = bx; - l0->x1 = bx; - l0->y0 = by + i * d; + l0->x0 = d; + l0->x1 = d; + l0->y0 = d + i * d; l0->y1 = l0->y0; if (scf_eline__add_line(el0, l0) < 0) { @@ -504,6 +504,9 @@ int ses_layout_function(ScfEfunction* f, uint32_t d, uint32_t bx, uint32_t by, u } } + f->w += d; + f->h += d; + scf_loge("f->x: %d, y: %d, w: %d, h: %d\n", f->x, f->y, f->w, f->h); for (i = 0; i < f->n_components; i++) { @@ -813,7 +816,7 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_ return 0; } -int ses_layout_board(ScfEboard* b, uint32_t x, uint32_t y, uint32_t w, uint32_t h) +int ses_layout_board(ScfEboard* b) { ScfEfunction* f; @@ -821,6 +824,11 @@ int ses_layout_board(ScfEboard* b, uint32_t x, uint32_t y, uint32_t w, uint32_t size_t j; size_t k; + int x = 0; + int y = 0; + int w = 0; + int h = 0; + for (i = 0; i < b->n_functions; i++) { f = b->functions[i]; @@ -830,11 +838,16 @@ int ses_layout_board(ScfEboard* b, uint32_t x, uint32_t y, uint32_t w, uint32_t ses_lines_same_components(f); - int ret = ses_layout_function(f, 50, x + 50, y + 50, w - 50, h - 50); + int ret = ses_layout_function(f, 50); if (ret < 0) { scf_loge("\n"); return ret; } + + x = f->x; + y = f->y; + w = f->w; + h = f->h; } ses_layout_draw(b, x, y, w, h); diff --git a/ses_layout.h b/ses_layout.h index a53b757..ae33f7b 100644 --- a/ses_layout.h +++ b/ses_layout.h @@ -5,6 +5,6 @@ #include"scf_eda_pb.h" #include"scf_vector.h" -int ses_layout_board(ScfEboard* b, uint32_t x, uint32_t y, uint32_t w, uint32_t h); +int ses_layout_board(ScfEboard* b); #endif -- 2.25.1