@modular-circuit/transpiler 0.0.91 → 0.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,6 @@
1
1
  import type { BOX2 } from '@modular-circuit/electronics-model';
2
2
  export declare const GRID_SIZE: number;
3
3
  export declare const FONT_SIZE: number;
4
- export declare function get_power_pos(pwr_number: number): {
5
- x: number;
6
- y: number;
7
- };
8
4
  export declare const BLOCK_PIN_GAP: number;
9
5
  export declare const BLOCK_PIN_TB_MARGIN: number;
10
6
  export declare const WIRE_PADDING: number;
@@ -21,10 +17,24 @@ export interface BoxGeometry {
21
17
  box: BOX2;
22
18
  bounding_box: BOX2;
23
19
  }
20
+ export declare function get_power_pos(pwr_number: number): {
21
+ x: number;
22
+ y: number;
23
+ };
24
24
  export declare class Layout {
25
- private width;
26
- private height;
27
- private max_height;
28
- get_block_geometry(factor: BlockLabelPadding): BoxGeometry;
25
+ private PAGE_MAX_WIDTH;
26
+ private blocks;
27
+ private assignments;
28
+ add_block(factor: BlockLabelPadding): void;
29
+ /**
30
+ * PHASE 1: Create provisional columns using greedy online assignment.
31
+ */
32
+ private initial_column_assign;
33
+ /**
34
+ * PHASE 2: Rebalance columns globally.
35
+ * Produce near-equal column heights for professional appearance.
36
+ */
37
+ private rebalance_columns;
38
+ finalize(): BoxGeometry[];
29
39
  }
30
40
  //# sourceMappingURL=layout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAA;AAI9D,eAAO,MAAM,SAAS,QAAiB,CAAA;AAEvC,eAAO,MAAM,SAAS,QAAY,CAAA;AAQlC,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM;;;EAE/C;AAKD,eAAO,MAAM,aAAa,QAAgB,CAAA;AAE1C,eAAO,MAAM,mBAAmB,QAAgB,CAAA;AAQhD,eAAO,MAAM,YAAY,QAAY,CAAA;AAErC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,YAAY,CAAA;IACtB,KAAK,EAAE,YAAY,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,IAAI,CAAA;IACT,YAAY,EAAE,IAAI,CAAA;CACnB;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAgB;IAE7B,OAAO,CAAC,MAAM,CAAgB;IAE9B,OAAO,CAAC,UAAU,CAAI;IAEf,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW;CAoDlE"}
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAA;AAI9D,eAAO,MAAM,SAAS,QAAiB,CAAA;AACvC,eAAO,MAAM,SAAS,QAAY,CAAA;AAKlC,eAAO,MAAM,aAAa,QAAgB,CAAA;AAC1C,eAAO,MAAM,mBAAmB,QAAgB,CAAA;AAMhD,eAAO,MAAM,YAAY,QAAY,CAAA;AAErC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,YAAY,CAAA;IACtB,KAAK,EAAE,YAAY,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,IAAI,CAAA;IACT,YAAY,EAAE,IAAI,CAAA;CACnB;AAcD,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM;;;EAE/C;AACD,qBAAa,MAAM;IACjB,OAAO,CAAC,cAAc,CAAkC;IAExD,OAAO,CAAC,MAAM,CAAyB;IAGvC,OAAO,CAAC,WAAW,CAAe;IAE3B,SAAS,CAAC,MAAM,EAAE,iBAAiB;IAsB1C;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAwD7B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IA8ClB,QAAQ,IAAI,WAAW,EAAE;CA8CjC"}
@@ -1,66 +1,205 @@
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
1
12
  import { PAPER_SIZE } from '../../utils/constraints';
2
13
  var MIL_TO_MM = 0.0254;
3
14
  export var GRID_SIZE = 50 * MIL_TO_MM;
4
15
  export var FONT_SIZE = GRID_SIZE;
16
+ var BLOCK_START_Y = 5 * GRID_SIZE;
17
+ var BLOCK_START_X = 5 * GRID_SIZE;
18
+ export var BLOCK_PIN_GAP = 4 * GRID_SIZE;
19
+ export var BLOCK_PIN_TB_MARGIN = 2 * GRID_SIZE;
20
+ var BLOCK_MARGIN_TOP = 6 * GRID_SIZE;
21
+ var BLOCK_MARGIN_LEFT = 4 * GRID_SIZE;
22
+ var INTERNAL_LABEL_MARGIN = 3 * FONT_SIZE;
23
+ var MIN_BLOCK_WIDTH = 8 * GRID_SIZE;
24
+ export var WIRE_PADDING = GRID_SIZE;
5
25
  var POWER_START_Y = 30 * GRID_SIZE;
6
26
  var POWER_START_X = (PAPER_SIZE.A4.height - 30) * GRID_SIZE;
7
27
  var POWER_Y_STEP = 16 * GRID_SIZE;
8
28
  export function get_power_pos(pwr_number) {
9
29
  return { x: POWER_START_X, y: POWER_START_Y + POWER_Y_STEP * pwr_number };
10
30
  }
11
- var BLOCK_START_Y = 36 * GRID_SIZE;
12
- var BLOCK_START_X = BLOCK_START_Y;
13
- export var BLOCK_PIN_GAP = 4 * GRID_SIZE;
14
- export var BLOCK_PIN_TB_MARGIN = 2 * GRID_SIZE;
15
- var BLOCK_MARGIN_TOP = 8 * GRID_SIZE;
16
- var MIN_BLOCK_WIDTH = 8 * GRID_SIZE;
17
- var BLOCK_MARGIN_LEFT = 16 * GRID_SIZE;
18
- var BLOCK_MARGIN_RIGHT = BLOCK_MARGIN_LEFT;
19
- var INTERNAL_LABEL_MARGIN = 8 * FONT_SIZE;
20
- export var WIRE_PADDING = GRID_SIZE;
21
31
  var Layout = /** @class */ (function () {
22
32
  function Layout() {
23
- this.width = BLOCK_START_X;
24
- this.height = BLOCK_START_Y;
25
- this.max_height = 0;
33
+ this.PAGE_MAX_WIDTH = PAPER_SIZE.A4.width * GRID_SIZE;
34
+ this.blocks = [];
35
+ // Provisional placement: column index for each block
36
+ this.assignments = [];
26
37
  }
27
- Layout.prototype.get_block_geometry = function (factor) {
38
+ Layout.prototype.add_block = function (factor) {
28
39
  var block_height = Math.floor(factor.total_pin_num / 2) * BLOCK_PIN_GAP + 2 * BLOCK_PIN_TB_MARGIN;
29
40
  var block_width = Math.max(MIN_BLOCK_WIDTH, factor.internal.l_side + factor.internal.r_side + INTERNAL_LABEL_MARGIN);
30
- var block_bounding_width = Math.max(block_width, factor.internal.l_side +
31
- factor.internal.r_side +
32
- factor.outer.l_side +
33
- factor.outer.r_side +
34
- // | txt | | txt |
35
- WIRE_PADDING * 4);
36
- var box = {
37
- pos: {
38
- x: this.width,
39
- y: this.height,
40
- },
41
- size: {
42
- x: block_width,
43
- y: block_height,
44
- },
41
+ var bounding_width = Math.max(block_width, factor.internal.l_side + factor.internal.r_side + factor.outer.l_side + factor.outer.r_side + WIRE_PADDING * 2);
42
+ var measurement = {
43
+ block_width: block_width,
44
+ bounding_width: bounding_width,
45
+ height: block_height,
45
46
  };
46
- var bounding_box = {
47
- pos: {
48
- x: this.width,
49
- y: this.height,
50
- },
51
- size: {
52
- x: block_bounding_width,
53
- y: block_height,
54
- },
55
- };
56
- this.max_height = Math.max(this.max_height, block_height);
57
- this.width += block_bounding_width + BLOCK_MARGIN_LEFT;
58
- if (this.width + BLOCK_MARGIN_RIGHT + MIN_BLOCK_WIDTH + BLOCK_MARGIN_LEFT > POWER_START_X) {
59
- this.width = BLOCK_START_X;
60
- this.height += this.max_height + BLOCK_MARGIN_TOP;
61
- this.max_height = 0;
47
+ this.blocks.push(measurement);
48
+ };
49
+ /**
50
+ * PHASE 1: Create provisional columns using greedy online assignment.
51
+ */
52
+ Layout.prototype.initial_column_assign = function () {
53
+ var cols = [];
54
+ for (var i = 0; i < this.blocks.length; i++) {
55
+ var b = this.blocks[i];
56
+ if (cols.length === 0) {
57
+ cols.push({ height: 0, width: b.bounding_width });
58
+ this.assignments.push(0);
59
+ cols[0].height += b.height + BLOCK_MARGIN_TOP;
60
+ cols[0].width = Math.max(cols[0].width, b.bounding_width);
61
+ continue;
62
+ }
63
+ // find shortest column
64
+ var bestIdx = 0;
65
+ for (var c = 1; c < cols.length; c++) {
66
+ if (cols[c].height < cols[bestIdx].height)
67
+ bestIdx = c;
68
+ }
69
+ var best = cols[bestIdx];
70
+ var newColWidth = Math.max(best.width, b.bounding_width);
71
+ // Check if expanding this column fits page width
72
+ var currentTotalWidth = cols.reduce(function (s, c) { return s + c.width; }, 0) + BLOCK_MARGIN_LEFT * (cols.length - 1);
73
+ var totalIfExpand = currentTotalWidth - best.width + newColWidth;
74
+ if (totalIfExpand <= this.PAGE_MAX_WIDTH - BLOCK_START_X) {
75
+ // expand best column
76
+ best.width = newColWidth;
77
+ this.assignments.push(bestIdx);
78
+ best.height += b.height + BLOCK_MARGIN_TOP;
79
+ }
80
+ else {
81
+ // try new column
82
+ var widthIfNew = currentTotalWidth + BLOCK_MARGIN_LEFT + b.bounding_width;
83
+ if (widthIfNew <= this.PAGE_MAX_WIDTH - BLOCK_START_X) {
84
+ cols.push({
85
+ height: b.height + BLOCK_MARGIN_TOP,
86
+ width: b.bounding_width,
87
+ });
88
+ this.assignments.push(cols.length - 1);
89
+ }
90
+ else {
91
+ // fallback: place in best column even if slightly overflowing
92
+ best.width = newColWidth;
93
+ this.assignments.push(bestIdx);
94
+ best.height += b.height + BLOCK_MARGIN_TOP;
95
+ }
96
+ }
97
+ }
98
+ return cols;
99
+ };
100
+ /**
101
+ * PHASE 2: Rebalance columns globally.
102
+ * Produce near-equal column heights for professional appearance.
103
+ */
104
+ Layout.prototype.rebalance_columns = function (initialCols) {
105
+ var _this = this;
106
+ var colCount = initialCols.length;
107
+ var itemsPerColumn = Array.from({ length: colCount }, function () { return []; });
108
+ for (var i = 0; i < this.blocks.length; i++) {
109
+ itemsPerColumn[this.assignments[i]].push(i);
110
+ }
111
+ // Compute heights per column
112
+ var heights = itemsPerColumn.map(function (colIndices) {
113
+ return colIndices.reduce(function (sum, idx) { return sum + _this.blocks[idx].height + BLOCK_MARGIN_TOP; }, 0);
114
+ });
115
+ // Simple redistribution: move from tallest to shortest until balanced
116
+ var changed = true;
117
+ while (changed) {
118
+ changed = false;
119
+ // Find tallest & shortest
120
+ var maxIdx = 0;
121
+ var minIdx = 0;
122
+ for (var i = 1; i < colCount; i++) {
123
+ if (heights[i] > heights[maxIdx])
124
+ maxIdx = i;
125
+ if (heights[i] < heights[minIdx])
126
+ minIdx = i;
127
+ }
128
+ if (heights[maxIdx] - heights[minIdx] < BLOCK_MARGIN_TOP * 2)
129
+ break; // good enough
130
+ // Move one block (the last one) from max column to min column
131
+ var from = itemsPerColumn[maxIdx];
132
+ if (from.length <= 1)
133
+ break;
134
+ var idxToMove = from.pop();
135
+ var b = this.blocks[idxToMove];
136
+ heights[maxIdx] -= b.height + BLOCK_MARGIN_TOP;
137
+ itemsPerColumn[minIdx].push(idxToMove);
138
+ heights[minIdx] += b.height + BLOCK_MARGIN_TOP;
139
+ this.assignments[idxToMove] = minIdx;
140
+ changed = true;
141
+ }
142
+ return itemsPerColumn;
143
+ };
144
+ Layout.prototype.finalize = function () {
145
+ var e_1, _a, e_2, _b;
146
+ var initialCols = this.initial_column_assign();
147
+ var itemsPerColumn = this.rebalance_columns(initialCols);
148
+ var colCount = itemsPerColumn.length;
149
+ // Recompute column widths after rebalancing
150
+ var finalColWidths = new Array(colCount).fill(0);
151
+ for (var c = 0; c < colCount; c++) {
152
+ try {
153
+ for (var _c = (e_1 = void 0, __values(itemsPerColumn[c])), _d = _c.next(); !_d.done; _d = _c.next()) {
154
+ var idx = _d.value;
155
+ finalColWidths[c] = Math.max(finalColWidths[c], this.blocks[idx].bounding_width);
156
+ }
157
+ }
158
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
159
+ finally {
160
+ try {
161
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
162
+ }
163
+ finally { if (e_1) throw e_1.error; }
164
+ }
165
+ }
166
+ // Compute X positions
167
+ var colX = [];
168
+ var x = BLOCK_START_X;
169
+ for (var c = 0; c < colCount; c++) {
170
+ colX[c] = x;
171
+ x += finalColWidths[c] + BLOCK_MARGIN_LEFT;
172
+ }
173
+ // Produce final coordinates
174
+ var result = new Array(this.blocks.length);
175
+ var colY = new Array(colCount).fill(BLOCK_START_Y);
176
+ for (var c = 0; c < colCount; c++) {
177
+ try {
178
+ for (var _e = (e_2 = void 0, __values(itemsPerColumn[c])), _f = _e.next(); !_f.done; _f = _e.next()) {
179
+ var idx = _f.value;
180
+ var b = this.blocks[idx];
181
+ result[idx] = {
182
+ box: {
183
+ pos: { x: colX[c], y: colY[c] },
184
+ size: { x: b.block_width, y: b.height },
185
+ },
186
+ bounding_box: {
187
+ pos: { x: colX[c], y: colY[c] },
188
+ size: { x: finalColWidths[c], y: b.height },
189
+ },
190
+ };
191
+ colY[c] += b.height + BLOCK_MARGIN_TOP;
192
+ }
193
+ }
194
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
195
+ finally {
196
+ try {
197
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
198
+ }
199
+ finally { if (e_2) throw e_2.error; }
200
+ }
62
201
  }
63
- return { box: box, bounding_box: bounding_box };
202
+ return result;
64
203
  };
65
204
  return Layout;
66
205
  }());
@@ -2,7 +2,6 @@ import { type SCHEMATIC } from '@modular-circuit/ir';
2
2
  import type { NetlistToKicadContext } from './context';
3
3
  export declare class NetListConverter {
4
4
  private ctx;
5
- private block_calc;
6
5
  private sheet_pwr_count;
7
6
  private net_name;
8
7
  private wires;
@@ -18,7 +17,6 @@ export declare class NetListConverter {
18
17
  * @returns
19
18
  */
20
19
  private convert_sch;
21
- private convert_hierarchical_label;
22
20
  private convert_pwr_symbol;
23
21
  private get_sheet_symbol_lb_padding;
24
22
  private convert_sheet_symbol;
@@ -1 +1 @@
1
- {"version":3,"file":"netlist_converter.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/netlist_converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,SAAS,EAGf,MAAM,qBAAqB,CAAA;AAM5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAKtD,qBAAa,gBAAgB;IASR,OAAO,CAAC,GAAG;IAR9B,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,eAAe,CAAI;IAE3B,OAAO,CAAC,QAAQ,CAA6B;IAE7C,OAAO,CAAC,KAAK,CAAiB;gBAEH,GAAG,EAAE,qBAAqB;IAQrD,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAI3B,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAIpB,gBAAgB;IAYvB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IA+DnB,OAAO,CAAC,0BAA0B;IAYlC,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,2BAA2B;IA+CnC,OAAO,CAAC,oBAAoB;IAsC5B,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,iBAAiB;CAQ1B"}
1
+ {"version":3,"file":"netlist_converter.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/netlist_converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,SAAS,EAGf,MAAM,qBAAqB,CAAA;AAM5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAatD,qBAAa,gBAAgB;IAOR,OAAO,CAAC,GAAG;IAN9B,OAAO,CAAC,eAAe,CAAI;IAE3B,OAAO,CAAC,QAAQ,CAA6B;IAE7C,OAAO,CAAC,KAAK,CAAiB;gBAEH,GAAG,EAAE,qBAAqB;IAQrD,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAI3B,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAIpB,gBAAgB;IAWvB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAqFnB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,2BAA2B;IA+CnC,OAAO,CAAC,oBAAoB;IAsC5B,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,iBAAiB;CAQ1B"}
@@ -32,7 +32,7 @@ import { gen_hierarchical_label, gen_net_label, gen_sheet_pin } from '../../kica
32
32
  import { gen_sch_sheet } from '../../kicad/sheet';
33
33
  import { gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc } from '../../kicad/symbols';
34
34
  import { GENERATOR_NAME, GENERATOR_VERSION, SCH_VERSION } from '../../utils/constraints';
35
- import { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, FONT_SIZE, Layout, WIRE_PADDING, get_power_pos } from './layout';
35
+ import { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, FONT_SIZE, Layout, WIRE_PADDING, get_power_pos, } from './layout';
36
36
  import { gen_wire } from '../../kicad/wire/gen_wire';
37
37
  var NetListConverter = /** @class */ (function () {
38
38
  function NetListConverter(ctx) {
@@ -80,7 +80,6 @@ var NetListConverter = /** @class */ (function () {
80
80
  for (var _b = __values(Object.entries(this.ctx.netlist.schematics)), _c = _b.next(); !_c.done; _c = _b.next()) {
81
81
  var _d = __read(_c.value, 2), k = _d[0], v = _d[1];
82
82
  this.sheet_pwr_count = 0;
83
- this.block_calc = new Layout();
84
83
  all_sch[k] = this.convert_sch(k, v);
85
84
  }
86
85
  }
@@ -101,8 +100,8 @@ var NetListConverter = /** @class */ (function () {
101
100
  * @returns
102
101
  */
103
102
  NetListConverter.prototype.convert_sch = function (name, schematic) {
104
- var e_4, _a, e_5, _b, e_6, _c;
105
- var _d, _e;
103
+ var e_4, _a, e_5, _b;
104
+ var _c, _d;
106
105
  var powers = new Set();
107
106
  this.wires = [];
108
107
  var sch = {
@@ -131,15 +130,15 @@ var NetListConverter = /** @class */ (function () {
131
130
  sheets: [],
132
131
  };
133
132
  try {
134
- for (var _f = __values(schematic.powers), _g = _f.next(); !_g.done; _g = _f.next()) {
135
- var it_2 = _g.value;
133
+ for (var _e = __values(schematic.powers), _f = _e.next(); !_f.done; _f = _e.next()) {
134
+ var it_2 = _f.value;
136
135
  if (!powers.has(it_2.value)) {
137
136
  switch (it_2.shape) {
138
137
  case PowerShape.VCC:
139
- (_d = sch.lib_symbols) === null || _d === void 0 ? void 0 : _d.symbols.push(gen_lib_vcc(it_2.value));
138
+ (_c = sch.lib_symbols) === null || _c === void 0 ? void 0 : _c.symbols.push(gen_lib_vcc(it_2.value));
140
139
  break;
141
140
  case PowerShape.GND:
142
- (_e = sch.lib_symbols) === null || _e === void 0 ? void 0 : _e.symbols.push(gen_lib_gnd(it_2.value));
141
+ (_d = sch.lib_symbols) === null || _d === void 0 ? void 0 : _d.symbols.push(gen_lib_gnd(it_2.value));
143
142
  break;
144
143
  }
145
144
  powers.add(it_2.value);
@@ -150,7 +149,7 @@ var NetListConverter = /** @class */ (function () {
150
149
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
151
150
  finally {
152
151
  try {
153
- if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
152
+ if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
154
153
  }
155
154
  finally { if (e_4) throw e_4.error; }
156
155
  }
@@ -158,12 +157,12 @@ var NetListConverter = /** @class */ (function () {
158
157
  var ordered_sheets = schematic.sheet_symbols.sort(function (a, b) {
159
158
  return b.pins.length - a.pins.length;
160
159
  });
160
+ var layout = new Layout();
161
161
  try {
162
162
  for (var ordered_sheets_1 = __values(ordered_sheets), ordered_sheets_1_1 = ordered_sheets_1.next(); !ordered_sheets_1_1.done; ordered_sheets_1_1 = ordered_sheets_1.next()) {
163
163
  var it_3 = ordered_sheets_1_1.value;
164
164
  var sheet_padding = this.get_sheet_symbol_lb_padding(it_3);
165
- var block_geo = this.block_calc.get_block_geometry(sheet_padding);
166
- this.convert_sheet_symbol(it_3, block_geo.box, sch, sheet_names_count);
165
+ layout.add_block(sheet_padding);
167
166
  }
168
167
  }
169
168
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
@@ -173,31 +172,28 @@ var NetListConverter = /** @class */ (function () {
173
172
  }
174
173
  finally { if (e_5) throw e_5.error; }
175
174
  }
176
- try {
177
- for (var _h = __values(schematic.hiera_labels), _j = _h.next(); !_j.done; _j = _h.next()) {
178
- var it_4 = _j.value;
179
- this.convert_hierarchical_label(it_4, sch);
180
- }
181
- }
182
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
183
- finally {
184
- try {
185
- if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
186
- }
187
- finally { if (e_6) throw e_6.error; }
175
+ var result = layout.finalize();
176
+ for (var i = 0; i < ordered_sheets.length; i++) {
177
+ var sheet_sym = ordered_sheets[i];
178
+ var rect = result[i].box;
179
+ this.convert_sheet_symbol(sheet_sym, rect, sch, sheet_names_count);
188
180
  }
181
+ // for (const it of schematic.hiera_labels) {
182
+ // this.convert_hierarchical_label(it, sch)
183
+ // }
189
184
  sch.wires = this.wires;
190
185
  return sch;
191
186
  };
192
- NetListConverter.prototype.convert_hierarchical_label = function (pin, sch) {
193
- var _a;
194
- var pin_pos = this.block_calc.get_block_geometry({
195
- internal: { l_side: 0, r_side: 0 },
196
- outer: { l_side: 0, r_side: 0 },
197
- total_pin_num: 1,
198
- }).box.pos;
199
- (_a = sch.labels) === null || _a === void 0 ? void 0 : _a.push(gen_hierarchical_label(pin.name, pin_pos, { horizontal: 'left', vertical: 'bottom' }, 0, pin.shape));
200
- };
187
+ // private convert_hierarchical_label(pin: NL_HierarchicalLabel, sch: SCHEMATIC) {
188
+ // const layout = new Layout()
189
+ // layout.add_block({
190
+ // internal: { l_side: 0, r_side: 0 },
191
+ // outer: { l_side: 0, r_side: 0 },
192
+ // total_pin_num: 1,
193
+ // })
194
+ // const pos = layout.finalize()[0].box.pos
195
+ // sch.labels?.push(gen_hierarchical_label(pin.name, pos, { horizontal: 'left', vertical: 'bottom' }, 0, pin.shape))
196
+ // }
201
197
  NetListConverter.prototype.convert_pwr_symbol = function (pwr, at, sch) {
202
198
  // NOTE : The power uuid is used as the uuid of its pin ,cause all power symbols have only one pin
203
199
  var pin_id = pwr.uuid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/transpiler",
3
- "version": "0.0.91",
3
+ "version": "0.0.92",
4
4
  "description": "Intermediate representation of the modular circuit",
5
5
  "main": "./build/index.js",
6
6
  "files": [
@@ -27,9 +27,9 @@
27
27
  "js-base64": "^3.7.7",
28
28
  "jszip": "^3.10.1",
29
29
  "@modular-circuit/electronics-model": "0.0.54",
30
+ "@modular-circuit/perc": "0.0.61",
30
31
  "@modular-circuit/ir": "0.0.63",
31
- "@modular-circuit/utils": "0.0.41",
32
- "@modular-circuit/perc": "0.0.61"
32
+ "@modular-circuit/utils": "0.0.41"
33
33
  },
34
34
  "scripts": {
35
35
  "clean": "rimraf build",