circuitscript 0.1.0 → 0.1.2

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.
Files changed (61) hide show
  1. package/dist/cjs/BaseVisitor.js +13 -8
  2. package/dist/cjs/antlr/CircuitScriptLexer.js +80 -80
  3. package/dist/cjs/antlr/CircuitScriptParser.js +599 -657
  4. package/dist/cjs/builtinMethods.js +27 -8
  5. package/dist/cjs/draw_symbols.js +314 -190
  6. package/dist/cjs/execute.js +113 -115
  7. package/dist/cjs/export.js +2 -4
  8. package/dist/cjs/geometry.js +52 -19
  9. package/dist/cjs/globals.js +12 -8
  10. package/dist/cjs/helpers.js +16 -3
  11. package/dist/cjs/layout.js +129 -125
  12. package/dist/cjs/logger.js +8 -1
  13. package/dist/cjs/objects/ClassComponent.js +22 -22
  14. package/dist/cjs/objects/ExecutionScope.js +10 -4
  15. package/dist/cjs/objects/Frame.js +2 -1
  16. package/dist/cjs/objects/ParamDefinition.js +120 -4
  17. package/dist/cjs/objects/PinDefinition.js +1 -4
  18. package/dist/cjs/render.js +40 -110
  19. package/dist/cjs/sizing.js +33 -7
  20. package/dist/cjs/utils.js +68 -2
  21. package/dist/cjs/visitor.js +214 -254
  22. package/dist/esm/BaseVisitor.mjs +15 -10
  23. package/dist/esm/antlr/CircuitScriptLexer.mjs +80 -80
  24. package/dist/esm/antlr/CircuitScriptParser.mjs +599 -657
  25. package/dist/esm/builtinMethods.mjs +24 -8
  26. package/dist/esm/draw_symbols.mjs +316 -193
  27. package/dist/esm/execute.mjs +115 -117
  28. package/dist/esm/export.mjs +2 -4
  29. package/dist/esm/geometry.mjs +52 -19
  30. package/dist/esm/globals.mjs +12 -8
  31. package/dist/esm/helpers.mjs +17 -4
  32. package/dist/esm/layout.mjs +131 -127
  33. package/dist/esm/logger.mjs +8 -1
  34. package/dist/esm/objects/ClassComponent.mjs +21 -26
  35. package/dist/esm/objects/ExecutionScope.mjs +10 -4
  36. package/dist/esm/objects/Frame.mjs +2 -1
  37. package/dist/esm/objects/ParamDefinition.mjs +119 -3
  38. package/dist/esm/objects/PinDefinition.mjs +0 -2
  39. package/dist/esm/render.mjs +42 -112
  40. package/dist/esm/sizing.mjs +34 -8
  41. package/dist/esm/utils.mjs +64 -1
  42. package/dist/esm/visitor.mjs +216 -256
  43. package/dist/types/BaseVisitor.d.ts +1 -1
  44. package/dist/types/antlr/CircuitScriptParser.d.ts +2 -3
  45. package/dist/types/draw_symbols.d.ts +71 -45
  46. package/dist/types/execute.d.ts +15 -10
  47. package/dist/types/geometry.d.ts +31 -19
  48. package/dist/types/globals.d.ts +14 -10
  49. package/dist/types/helpers.d.ts +2 -1
  50. package/dist/types/layout.d.ts +21 -21
  51. package/dist/types/logger.d.ts +1 -1
  52. package/dist/types/objects/ClassComponent.d.ts +19 -16
  53. package/dist/types/objects/ExecutionScope.d.ts +2 -1
  54. package/dist/types/objects/Frame.d.ts +2 -2
  55. package/dist/types/objects/ParamDefinition.d.ts +31 -2
  56. package/dist/types/objects/PinDefinition.d.ts +0 -2
  57. package/dist/types/render.d.ts +2 -1
  58. package/dist/types/utils.d.ts +6 -1
  59. package/dist/types/visitor.d.ts +4 -5
  60. package/libs/lib.cst +15 -3
  61. package/package.json +7 -3
@@ -1,9 +1,10 @@
1
1
  import { milsToMM } from "./helpers.mjs";
2
- import { ColorScheme, CustomSymbolParamTextSize, CustomSymbolPinIdSize, CustomSymbolPinTextSize, CustomSymbolRefDesSize, PortArrowSize, PortPaddingHorizontal, PortPaddingVertical, ReferenceTypes, SymbolPinSide, defaultFont, defaultPinIdTextSize, defaultPinNameTextSize, defaultSymbolLineWidth, fontDisplayScale } from "./globals.mjs";
3
- import { Geometry, GeometryProp, HorizontalAlign, Textbox, VerticalAlign } from "./geometry.mjs";
2
+ import { ColorScheme, CustomSymbolParamTextSize, CustomSymbolPinIdSize, CustomSymbolPinTextSize, CustomSymbolRefDesSize, PortArrowSize, PortPaddingHorizontal, PortPaddingVertical, ReferenceTypes, RenderFlags, SymbolPinSide, defaultFont, defaultPinIdTextSize, defaultPinNameTextSize, defaultSymbolLineWidth, fontDisplayScale } from "./globals.mjs";
3
+ import { Geometry, GeometryProp, HorizontalAlign, HorizontalAlignProp, Textbox, VerticalAlign, VerticalAlignProp } from "./geometry.mjs";
4
4
  import { PinTypes } from "./objects/PinTypes.mjs";
5
5
  import { roundValue, throwWithContext } from "./utils.mjs";
6
6
  import { DeclaredReference, UndeclaredReference } from "./objects/types.mjs";
7
+ import { numeric, NumericValue } from "./objects/ParamDefinition.mjs";
7
8
  export class SymbolGraphic {
8
9
  drawPortsName = true;
9
10
  displayBounds = false;
@@ -11,8 +12,8 @@ export class SymbolGraphic {
11
12
  _angle = 0;
12
13
  _flipX = 0;
13
14
  _flipY = 0;
14
- width;
15
- height;
15
+ width = numeric(-1);
16
+ height = numeric(-1);
16
17
  labelTexts = new Map();
17
18
  constructor() {
18
19
  this.drawing = new SymbolDrawing();
@@ -41,15 +42,21 @@ export class SymbolGraphic {
41
42
  }
42
43
  calculateSize() {
43
44
  const { width, height } = this.drawing.getBoundingBox();
44
- this.width = width;
45
- this.height = height;
46
- }
47
- size() {
45
+ this.width = numeric(width);
46
+ this.height = numeric(height);
48
47
  return {
48
+ bodyWidth: numeric(-1),
49
+ bodyHeight: numeric(-1),
49
50
  width: this.width,
50
51
  height: this.height
51
52
  };
52
53
  }
54
+ size() {
55
+ return {
56
+ width: this.width.toNumber(),
57
+ height: this.height.toNumber(),
58
+ };
59
+ }
53
60
  draw(group, extra) {
54
61
  const innerGroup = group.group();
55
62
  this.drawBody(innerGroup);
@@ -86,15 +93,15 @@ export class SymbolGraphic {
86
93
  drawBounds(group) {
87
94
  const bbox = this.drawing.getBoundingBox();
88
95
  const originSize = milsToMM(10);
89
- group.circle(originSize)
90
- .translate(-originSize / 2, -originSize / 2)
96
+ group.circle(originSize.toNumber())
97
+ .translate(originSize.neg().div(2).toNumber(), originSize.neg().div(2).toNumber())
91
98
  .fill('red')
92
99
  .stroke('none');
93
100
  group.rect(bbox.width, bbox.height)
94
101
  .translate(bbox.start[0], bbox.start[1])
95
102
  .fill('none')
96
103
  .stroke({
97
- width: milsToMM(2),
104
+ width: milsToMM(2).toNumber(),
98
105
  color: '#ccc',
99
106
  });
100
107
  }
@@ -104,7 +111,7 @@ export class SymbolGraphic {
104
111
  const { path, lineColor, fillColor, lineWidth } = pathInfo;
105
112
  group.path(path)
106
113
  .stroke({
107
- width: lineWidth,
114
+ width: lineWidth.toNumber(),
108
115
  color: lineColor,
109
116
  })
110
117
  .fill(fillColor);
@@ -124,7 +131,8 @@ export class SymbolGraphic {
124
131
  const labels = this.drawing.getLabels();
125
132
  labels.forEach(label => {
126
133
  const tmpLabel = label;
127
- const { fontSize = 50, anchor = HorizontalAlign.Left, vanchor = VerticalAlign.Bottom, fontWeight = 'regular', angle: labelAngle = 0, textColor = "#333", } = tmpLabel.style ?? {};
134
+ const { fontSize = numeric(50), anchor = HorizontalAlign.Left, vanchor = VerticalAlign.Bottom, fontWeight = 'regular', angle: tmpLabelAngle = numeric(0), textColor = "#333", } = tmpLabel.style ?? {};
135
+ const labelAngle = tmpLabelAngle.toNumber();
128
136
  let anchorStyle = 'start';
129
137
  let dominantBaseline = 'auto';
130
138
  let useAnchor = anchor;
@@ -136,40 +144,44 @@ export class SymbolGraphic {
136
144
  }
137
145
  switch (useAnchor) {
138
146
  case HorizontalAlign.Left:
139
- anchorStyle = (this.flipX === 0) ? 'start' : 'end';
147
+ anchorStyle = (this.flipX === 0)
148
+ ? HorizontalAlignProp.Start : HorizontalAlignProp.End;
140
149
  break;
141
150
  case HorizontalAlign.Middle:
142
- anchorStyle = 'middle';
151
+ anchorStyle = HorizontalAlignProp.Middle;
143
152
  break;
144
153
  case HorizontalAlign.Right:
145
- anchorStyle = (this.flipX === 0) ? 'end' : 'start';
154
+ anchorStyle = (this.flipX === 0)
155
+ ? HorizontalAlignProp.End : HorizontalAlignProp.Start;
146
156
  break;
147
157
  }
148
158
  switch (useDominantBaseline) {
149
159
  case VerticalAlign.Top:
150
- dominantBaseline = (this.flipY === 0) ? 'hanging' : 'text-top';
160
+ dominantBaseline = (this.flipY === 0)
161
+ ? VerticalAlignProp.Hanging : VerticalAlignProp.TextTop;
151
162
  break;
152
163
  case VerticalAlign.Middle:
153
- dominantBaseline = 'middle';
164
+ dominantBaseline = VerticalAlignProp.Central;
154
165
  break;
155
166
  case VerticalAlign.Bottom:
156
- dominantBaseline = (this.flipY === 0) ? 'text-top' : 'hanging';
167
+ dominantBaseline = (this.flipY === 0)
168
+ ? VerticalAlignProp.TextTop : VerticalAlignProp.Hanging;
157
169
  break;
158
170
  }
159
171
  const position = tmpLabel.getLabelPosition();
160
172
  if (this.flipX !== 0) {
161
- position[0] *= -1;
173
+ position[0] = position[0].neg();
162
174
  }
163
175
  if (this.flipY !== 0) {
164
- position[1] *= -1;
176
+ position[1] = position[1].neg();
165
177
  }
166
178
  const useFont = defaultFont;
167
179
  const textContainer = group.group();
168
180
  let translateX, translateY;
169
181
  let useRotateAngle = 0;
170
182
  if (isRotation180) {
171
- translateX = -position[0];
172
- translateY = -position[1];
183
+ translateX = position[0].neg();
184
+ translateY = position[1].neg();
173
185
  useRotateAngle = 0;
174
186
  }
175
187
  else {
@@ -239,7 +251,7 @@ export class SymbolGraphic {
239
251
  }
240
252
  textContainer.path(path)
241
253
  .stroke({
242
- width: milsToMM(5),
254
+ width: milsToMM(5).toNumber(),
243
255
  color: '#333'
244
256
  })
245
257
  .fill('none')
@@ -247,47 +259,55 @@ export class SymbolGraphic {
247
259
  .translate(boundsTranslateX, boundsY - paddingVert);
248
260
  }
249
261
  }
250
- const drawTextBounds = false;
251
- const drawBoxBounds = false;
252
- const drawOrigin = false;
253
- if (drawBoxBounds) {
262
+ if (RenderFlags.ShowLabelBoxBounds) {
254
263
  const box = tmpLabel.box;
255
- textContainer.rect(box.width, box.height).fill('red')
264
+ textContainer.rect(box.width, box.height)
265
+ .fill('none')
266
+ .stroke({
267
+ width: 0.1,
268
+ color: 'blue',
269
+ })
256
270
  .translate(box.xmin, box.ymin)
257
- .scale(this.flipX !== 0 ? -1 : 1, 1, -box.xmin, box.ymin);
271
+ .rotate(labelAngle, -box.xmin, -box.ymin);
258
272
  }
259
- if (drawTextBounds) {
273
+ if (RenderFlags.ShowLabelBounds) {
260
274
  const textBounds = tmpLabel.textMeasurementBounds;
261
275
  const xOffset = (this.flipX !== 0) ? textBounds.width : 0;
262
- textContainer.rect(textBounds.width, textBounds.height).fill('#cccccc')
276
+ textContainer.rect(textBounds.width, textBounds.height)
277
+ .fill('none')
278
+ .stroke({
279
+ width: 0.1,
280
+ color: 'red',
281
+ })
263
282
  .translate(textBounds.x - xOffset, textBounds.y);
264
283
  }
265
- textContainer.translate(translateX, translateY)
266
- .rotate(useRotateAngle, -translateX, -translateY);
284
+ textContainer.translate(translateX.toNumber(), translateY.toNumber())
285
+ .rotate(useRotateAngle, -translateX.toNumber(), -translateY.toNumber());
267
286
  textContainer.text(tmpLabel.text)
268
287
  .fill(textColor)
269
288
  .font({
270
289
  family: useFont,
271
- size: fontSize * fontDisplayScale,
290
+ size: fontSize.toNumber() * fontDisplayScale,
272
291
  anchor: anchorStyle,
273
292
  'dominant-baseline': dominantBaseline,
274
293
  weight: fontWeight,
275
294
  })
276
- .rotate(labelAngle);
295
+ .attr("xml:space", "preserve")
296
+ .rotate(labelAngle, 0, 0);
277
297
  const { a, b, c, d, e, f } = textContainer.matrix();
278
298
  const newMatrix = {
279
- a: roundValue(a),
280
- b: roundValue(b),
281
- c: roundValue(c),
282
- d: roundValue(d),
283
- e: roundValue(e),
284
- f: roundValue(f),
299
+ a: roundValue(numeric(a)).toNumber(),
300
+ b: roundValue(numeric(b)).toNumber(),
301
+ c: roundValue(numeric(c)).toNumber(),
302
+ d: roundValue(numeric(d)).toNumber(),
303
+ e: roundValue(numeric(e)).toNumber(),
304
+ f: roundValue(numeric(f)).toNumber(),
285
305
  };
286
306
  textContainer.transform(newMatrix);
287
- if (drawOrigin) {
288
- const originSize = milsToMM(10);
307
+ if (RenderFlags.ShowLabelOrigin) {
308
+ const originSize = milsToMM(10).toNumber();
289
309
  textContainer.circle(originSize)
290
- .translate(originSize / 2, originSize / 2)
310
+ .translate(-originSize / 2, -originSize / 2)
291
311
  .fill('green');
292
312
  }
293
313
  });
@@ -315,24 +335,9 @@ export class SymbolGraphic {
315
335
  }
316
336
  }
317
337
  }
318
- export function SymbolFactory(name) {
319
- switch (name) {
320
- case 'point':
321
- return new SymbolPointHidden();
322
- }
323
- return null;
324
- }
325
- export class SymbolPointHidden extends SymbolGraphic {
326
- generateDrawing() {
327
- const drawing = this.drawing;
328
- drawing.clear();
329
- drawing.addPin(1, 0, 0, 0, 0);
330
- this.drawing = drawing;
331
- }
332
- }
333
338
  export class SymbolText extends SymbolGraphic {
334
339
  text;
335
- fontSize = 40;
340
+ fontSize = numeric(40);
336
341
  fontWeight = 'regular';
337
342
  constructor(text) {
338
343
  super();
@@ -341,7 +346,7 @@ export class SymbolText extends SymbolGraphic {
341
346
  generateDrawing() {
342
347
  const drawing = this.drawing;
343
348
  drawing.clear();
344
- drawing.addTextbox(0, 0, this.text, {
349
+ drawing.addTextbox(numeric(0), numeric(0), this.text, {
345
350
  fontSize: this.fontSize,
346
351
  anchor: HorizontalAlign.Middle,
347
352
  fontWeight: this.fontWeight,
@@ -361,7 +366,7 @@ export class SymbolPlaceholder extends SymbolGraphic {
361
366
  [PlaceHolderCommands.units, ['mils'], {}],
362
367
  [PlaceHolderCommands.lineColor, [ColorScheme.PinLineColor], {}],
363
368
  [PlaceHolderCommands.textColor, [ColorScheme.PinNameColor], {}],
364
- [PlaceHolderCommands.lineWidth, [5], {}],
369
+ [PlaceHolderCommands.lineWidth, [numeric(5)], {}],
365
370
  ...drawing.getCommands()
366
371
  ];
367
372
  drawing.log('id: ', drawing.id, 'angle: ', this._angle, "commands:", commands.length);
@@ -416,7 +421,7 @@ export class SymbolPlaceholder extends SymbolGraphic {
416
421
  drawing.addArc(...positionParams);
417
422
  break;
418
423
  case PlaceHolderCommands.circle:
419
- drawing.addArc(...positionParams, 0, 360);
424
+ drawing.addArc(...positionParams, numeric(0), numeric(360));
420
425
  break;
421
426
  case PlaceHolderCommands.triangle:
422
427
  drawing.addTriangle(...positionParams);
@@ -449,8 +454,8 @@ export class SymbolPlaceholder extends SymbolGraphic {
449
454
  case PlaceHolderCommands.text: {
450
455
  const style = this.parseLabelStyle(keywordParams);
451
456
  const content = keywordParams.get('content');
452
- let offsetX = 0;
453
- let offsetY = 0;
457
+ let offsetX = numeric(0);
458
+ let offsetY = numeric(0);
454
459
  if (keywordParams.has('offset')) {
455
460
  const offset = keywordParams.get('offset');
456
461
  offsetX = offset[0];
@@ -502,6 +507,9 @@ export class SymbolPlaceholder extends SymbolGraphic {
502
507
  let displayPinId = true;
503
508
  if (keywordParams.has(keywordDisplayPinId)) {
504
509
  const value = keywordParams.get(keywordDisplayPinId);
510
+ if (value instanceof NumericValue && value.toNumber() === 0) {
511
+ displayPinId = false;
512
+ }
505
513
  if (value === 0 || value === false) {
506
514
  displayPinId = false;
507
515
  }
@@ -525,7 +533,7 @@ export class SymbolPlaceholder extends SymbolGraphic {
525
533
  startX,
526
534
  startY,
527
535
  startX,
528
- startY + magnitude
536
+ startY.add(magnitude)
529
537
  ];
530
538
  }
531
539
  else if (commandName === PlaceHolderCommands.hpin) {
@@ -534,7 +542,7 @@ export class SymbolPlaceholder extends SymbolGraphic {
534
542
  positionParams[0],
535
543
  startX,
536
544
  startY,
537
- startX + magnitude,
545
+ startX.add(magnitude),
538
546
  startY
539
547
  ];
540
548
  }
@@ -556,11 +564,12 @@ export class SymbolPlaceholder extends SymbolGraphic {
556
564
  const offset1 = 15;
557
565
  const offset2 = 15;
558
566
  let pinNameOffsetX = milsToMM(offset1);
559
- let pinIdOffsetX = 0;
567
+ let pinIdOffsetX = numeric(0);
560
568
  let pinIdAlignment = HorizontalAlign.Left;
561
569
  let pinIdVAlignment = VerticalAlign.Bottom;
562
570
  let pinIdOffsetY = milsToMM(-offset2);
563
- switch (angle) {
571
+ const angleValue = angle.toNumber();
572
+ switch (angleValue) {
564
573
  case 0:
565
574
  pinNameAlignment = HorizontalAlign.Left;
566
575
  pinNameOffsetX = milsToMM(offset1);
@@ -583,16 +592,16 @@ export class SymbolPlaceholder extends SymbolGraphic {
583
592
  pinIdVAlignment = VerticalAlign.Top;
584
593
  break;
585
594
  }
586
- if (angle === 0 || angle === 90 || angle === 180 || angle === 270) {
595
+ if (angleValue === 0 || angleValue === 90 || angleValue === 180 || angleValue === 270) {
587
596
  const usePinName = pinNameParam ?? "";
588
- usePinName !== "" && drawing.addLabel(endX + pinNameOffsetX, endY, usePinName, {
589
- fontSize: defaultPinNameTextSize,
597
+ usePinName !== "" && drawing.addLabel(endX.add(pinNameOffsetX), endY, usePinName, {
598
+ fontSize: numeric(defaultPinNameTextSize),
590
599
  anchor: pinNameAlignment,
591
600
  vanchor: VerticalAlign.Middle,
592
601
  textColor: pinNameColor,
593
602
  });
594
- displayPinId && drawing.addLabel(endX + pinIdOffsetX, endY + pinIdOffsetY, pinId.toString(), {
595
- fontSize: defaultPinIdTextSize,
603
+ displayPinId && drawing.addLabel(endX.add(pinIdOffsetX), endY.add(pinIdOffsetY), pinId.toDisplayString(), {
604
+ fontSize: numeric(defaultPinIdTextSize),
596
605
  anchor: pinIdAlignment,
597
606
  vanchor: pinIdVAlignment,
598
607
  textColor: lineColor
@@ -629,59 +638,74 @@ export var PlaceHolderCommands;
629
638
  export class SymbolCustom extends SymbolGraphic {
630
639
  pinDefinition = [];
631
640
  bodyWidth = milsToMM(400);
641
+ bodyHeight = milsToMM(100);
632
642
  pinLength = milsToMM(100);
633
643
  width = milsToMM(100);
634
644
  height = milsToMM(100);
635
645
  pinSpacing = milsToMM(100);
636
646
  pinTextPadding = milsToMM(5);
637
647
  pins = [];
638
- _cacheLeftPins;
639
- _cacheRightPins;
640
- constructor(pinDefinition) {
648
+ _cacheLeftPins = [];
649
+ _cacheRightPins = [];
650
+ _cacheTopPins = [];
651
+ _cacheBottomPins = [];
652
+ pinMaxPositions;
653
+ constructor(pinDefinition, pinMaxPositions) {
641
654
  super();
642
655
  this.pinDefinition = pinDefinition;
656
+ this.pinMaxPositions = pinMaxPositions;
643
657
  }
644
658
  generateDrawing() {
645
- const leftPins = this.pinDefinition.filter(item => {
646
- return item.side === SymbolPinSide.Left;
647
- });
648
- const rightPins = this.pinDefinition.filter(item => {
649
- return item.side === SymbolPinSide.Right;
650
- });
651
- const maxLeftPins = Math.max(...leftPins.map(item => item.position)) + 1;
652
- const maxRightPins = Math.max(...rightPins.map(item => item.position)) + 1;
659
+ const leftPins = this.getPins(SymbolPinSide.Left);
660
+ const rightPins = this.getPins(SymbolPinSide.Right);
661
+ const topPins = this.getPins(SymbolPinSide.Top);
662
+ const bottomPins = this.getPins(SymbolPinSide.Bottom);
653
663
  this.drawing.clear();
654
664
  const drawing = this.drawing;
655
665
  drawing.angle = this._angle;
656
666
  drawing.flipX = this._flipX;
657
667
  drawing.flipY = this._flipY;
658
- const bodyWidth = this.bodyWidth;
659
- const bodyHeight = (1 + Math.max(maxLeftPins, maxRightPins)) * this.pinSpacing;
668
+ const { bodyWidth, bodyHeight } = this.calculateSize();
660
669
  const defaultLineColor = ColorScheme.PinLineColor;
661
670
  drawing.addSetLineColor(defaultLineColor);
662
- drawing.addSetLineWidth(5);
663
- drawing.addRectMM(0, 0, bodyWidth, bodyHeight);
664
- this.generateDrawingPins(drawing, bodyWidth, bodyHeight, leftPins, rightPins, defaultLineColor);
671
+ drawing.addSetLineWidth(numeric(5));
672
+ drawing.addRectMM(numeric(0), numeric(0), bodyWidth, bodyHeight);
673
+ this.generateDrawingPins(drawing, bodyWidth, bodyHeight, {
674
+ left: leftPins, right: rightPins, top: topPins, bottom: bottomPins
675
+ }, defaultLineColor);
665
676
  this.drawing = drawing;
666
677
  this._cacheLeftPins = leftPins;
667
678
  this._cacheRightPins = rightPins;
679
+ this._cacheTopPins = topPins;
680
+ this._cacheBottomPins = bottomPins;
668
681
  }
669
- generateDrawingPins(drawing, bodyWidthMM, bodyHeightMM, leftPins, rightPins, defaultLineColor) {
670
- const leftPinStart = -bodyWidthMM / 2;
671
- const rightPinStart = bodyWidthMM / 2;
672
- const pinStartY = -bodyHeightMM / 2;
682
+ getPins(side) {
683
+ const pins = this.pinDefinition.filter(item => {
684
+ return item.side === side;
685
+ });
686
+ return pins;
687
+ }
688
+ generateDrawingPins(drawing, bodyWidthMM, bodyHeightMM, pins, defaultLineColor) {
689
+ const { left: leftPins, right: rightPins, top: topPins, bottom: bottomPins } = pins;
690
+ const leftPinStart = bodyWidthMM.neg().div(2);
691
+ const rightPinStart = bodyWidthMM.div(2);
692
+ const topPinStart = bodyHeightMM.neg().div(2);
693
+ const bottomPinStart = bodyHeightMM.div(2);
694
+ const pinStartY = bodyHeightMM.neg().div(2);
695
+ const pinStartX = bodyWidthMM.neg().div(2);
696
+ const tmpPinSpacing = this.pinSpacing.toNumber();
673
697
  leftPins.forEach(pin => {
674
698
  const position = pin.position;
675
- const pinY = pinStartY + (position + 1) * this.pinSpacing;
676
- drawing.addPinMM(pin.pinId, leftPinStart - this.pinLength, pinY, leftPinStart, pinY, defaultLineColor);
677
- drawing.addLabel(leftPinStart + milsToMM(20), pinY, pin.text, {
678
- fontSize: CustomSymbolPinTextSize,
699
+ const pinY = pinStartY.add((position + 1) * tmpPinSpacing);
700
+ drawing.addPinMM(numeric(pin.pinId), leftPinStart.sub(this.pinLength), pinY, leftPinStart, pinY, defaultLineColor);
701
+ drawing.addLabel(leftPinStart.add(milsToMM(20)), pinY, pin.text, {
702
+ fontSize: numeric(CustomSymbolPinTextSize),
679
703
  anchor: HorizontalAlign.Left,
680
704
  vanchor: VerticalAlign.Middle,
681
705
  textColor: ColorScheme.PinNameColor,
682
706
  });
683
- drawing.addLabel(leftPinStart - milsToMM(10), pinY - milsToMM(10), pin.pinId.toString(), {
684
- fontSize: CustomSymbolPinIdSize,
707
+ drawing.addLabel(leftPinStart.sub(milsToMM(10)), pinY.sub(milsToMM(10)), pin.pinId.toString(), {
708
+ fontSize: numeric(CustomSymbolPinIdSize),
685
709
  anchor: HorizontalAlign.Right,
686
710
  vanchor: VerticalAlign.Bottom,
687
711
  textColor: defaultLineColor
@@ -689,32 +713,70 @@ export class SymbolCustom extends SymbolGraphic {
689
713
  });
690
714
  rightPins.forEach(pin => {
691
715
  const position = pin.position;
692
- const pinY = pinStartY + (position + 1) * this.pinSpacing;
693
- drawing.addPinMM(pin.pinId, rightPinStart + this.pinLength, pinY, rightPinStart, pinY, defaultLineColor);
694
- drawing.addLabel(rightPinStart - milsToMM(20), pinY, pin.text, {
695
- fontSize: CustomSymbolPinTextSize,
716
+ const pinY = pinStartY.add((position + 1) * tmpPinSpacing);
717
+ drawing.addPinMM(numeric(pin.pinId), rightPinStart.add(this.pinLength), pinY, rightPinStart, pinY, defaultLineColor);
718
+ drawing.addLabel(rightPinStart.sub(milsToMM(20)), pinY, pin.text, {
719
+ fontSize: numeric(CustomSymbolPinTextSize),
696
720
  anchor: HorizontalAlign.Right,
697
721
  vanchor: VerticalAlign.Middle,
698
722
  textColor: ColorScheme.PinNameColor,
699
723
  });
700
- drawing.addLabel(rightPinStart + milsToMM(10), pinY - milsToMM(10), pin.pinId.toString(), {
701
- fontSize: CustomSymbolPinIdSize,
724
+ drawing.addLabel(rightPinStart.add(milsToMM(10)), pinY.sub(milsToMM(10)), pin.pinId.toString(), {
725
+ fontSize: numeric(CustomSymbolPinIdSize),
702
726
  anchor: HorizontalAlign.Left,
703
727
  vanchor: VerticalAlign.Bottom,
704
728
  textColor: defaultLineColor
705
729
  });
706
730
  });
731
+ topPins.forEach(pin => {
732
+ const position = pin.position;
733
+ const pinX = pinStartX.add((position + 1) * tmpPinSpacing);
734
+ drawing.addPinMM(numeric(pin.pinId), pinX, topPinStart.sub(this.pinLength), pinX, topPinStart, defaultLineColor);
735
+ drawing.addLabel(pinX, topPinStart.add(milsToMM(20)), pin.text, {
736
+ fontSize: numeric(CustomSymbolPinTextSize),
737
+ anchor: HorizontalAlign.Right,
738
+ vanchor: VerticalAlign.Middle,
739
+ textColor: ColorScheme.PinNameColor,
740
+ angle: numeric(-90),
741
+ });
742
+ drawing.addLabel(pinX.sub(milsToMM(10)), topPinStart.sub(milsToMM(10)), pin.pinId.toString(), {
743
+ fontSize: numeric(CustomSymbolPinIdSize),
744
+ anchor: HorizontalAlign.Left,
745
+ vanchor: VerticalAlign.Bottom,
746
+ textColor: defaultLineColor,
747
+ angle: numeric(-90),
748
+ });
749
+ });
750
+ bottomPins.forEach(pin => {
751
+ const position = pin.position;
752
+ const pinX = pinStartX.add((position + 1) * tmpPinSpacing);
753
+ drawing.addPinMM(numeric(pin.pinId), pinX, bottomPinStart.add(this.pinLength), pinX, bottomPinStart, defaultLineColor);
754
+ drawing.addLabel(pinX, bottomPinStart.sub(milsToMM(20)), pin.text, {
755
+ fontSize: numeric(CustomSymbolPinTextSize),
756
+ anchor: HorizontalAlign.Left,
757
+ vanchor: VerticalAlign.Middle,
758
+ textColor: ColorScheme.PinNameColor,
759
+ angle: numeric(-90),
760
+ });
761
+ drawing.addLabel(pinX.sub(milsToMM(10)), bottomPinStart.add(milsToMM(10)), pin.pinId.toString(), {
762
+ fontSize: numeric(CustomSymbolPinIdSize),
763
+ anchor: HorizontalAlign.Right,
764
+ vanchor: VerticalAlign.Bottom,
765
+ textColor: defaultLineColor,
766
+ angle: numeric(-90)
767
+ });
768
+ });
707
769
  const instanceName = drawing.variables.get('refdes');
708
- instanceName && drawing.addLabel(-bodyWidthMM / 2, -bodyHeightMM / 2 - milsToMM(20), instanceName, {
709
- fontSize: CustomSymbolRefDesSize,
770
+ instanceName && drawing.addLabel(bodyWidthMM.neg().div(2), bodyHeightMM.neg().div(2).sub(milsToMM(20)), instanceName, {
771
+ fontSize: numeric(CustomSymbolRefDesSize),
710
772
  anchor: HorizontalAlign.Left,
711
773
  });
712
774
  const acceptedMPNKeys = ['MPN', 'mpn', 'manufacturer_pn'];
713
775
  acceptedMPNKeys.some(key => {
714
776
  const labelValue = drawing.variables.get(key);
715
777
  if (labelValue !== undefined) {
716
- drawing.addLabel(-bodyWidthMM / 2, bodyHeightMM / 2 + milsToMM(20), labelValue, {
717
- fontSize: CustomSymbolParamTextSize,
778
+ drawing.addLabel(bodyWidthMM.neg().div(2), bodyHeightMM.div(2).add(milsToMM(20)), labelValue, {
779
+ fontSize: numeric(CustomSymbolParamTextSize),
718
780
  anchor: HorizontalAlign.Left,
719
781
  vanchor: VerticalAlign.Top,
720
782
  });
@@ -722,25 +784,55 @@ export class SymbolCustom extends SymbolGraphic {
722
784
  });
723
785
  }
724
786
  calculateSize() {
725
- this.width = this.bodyWidth + 2 * this.pinLength;
726
- this.height = (1 + Math.max(this._cacheLeftPins.length, this._cacheRightPins.length)) * this.pinSpacing;
787
+ const tmpPinSpacing = this.pinSpacing.toNumber();
788
+ const tmpPinLength = this.pinLength.toNumber();
789
+ const { [SymbolPinSide.Top]: maxTopPins, [SymbolPinSide.Bottom]: maxBottomPins, [SymbolPinSide.Left]: maxLeftPins, [SymbolPinSide.Right]: maxRightPins } = this.pinMaxPositions;
790
+ const bodyWidthFromPins = numeric((1 + Math.max(maxTopPins, maxBottomPins)) * tmpPinSpacing);
791
+ const bodyWidth = Math.max(bodyWidthFromPins.toNumber(), this.bodyWidth.toNumber());
792
+ let tmpBodyHeight = 0;
793
+ if (maxLeftPins === 0 && maxRightPins === 0) {
794
+ tmpBodyHeight = 3;
795
+ }
796
+ else {
797
+ tmpBodyHeight = (1 + Math.max(maxLeftPins, maxRightPins));
798
+ }
799
+ const bodyHeight = Math.max(tmpBodyHeight * tmpPinSpacing, this.bodyHeight.toNumber());
800
+ const useHeight = bodyHeight
801
+ + ((this._cacheTopPins.length > 0) ? tmpPinLength : 0)
802
+ + ((this._cacheBottomPins.length > 0) ? tmpPinLength : 0);
803
+ const useWidth = bodyWidth
804
+ + ((this._cacheLeftPins.length > 0) ? tmpPinLength : 0)
805
+ + ((this._cacheRightPins.length > 0) ? tmpPinLength : 0);
806
+ this.width = numeric(useWidth);
807
+ this.height = numeric(useHeight);
808
+ return {
809
+ bodyWidth: numeric(bodyWidth),
810
+ bodyHeight: numeric(bodyHeight),
811
+ width: this.width,
812
+ height: this.height
813
+ };
727
814
  }
728
815
  }
729
816
  export class SymbolCustomModule extends SymbolCustom {
730
- pinLength = 0;
817
+ pinLength = milsToMM(0);
731
818
  portWidth = milsToMM(100);
732
819
  portHeight = milsToMM(50);
733
- generateDrawingPins(drawing, bodyWidthMM, bodyHeightMM, leftPins, rightPins, defaultLineColor) {
734
- const leftPinStart = -bodyWidthMM / 2;
735
- const rightPinStart = bodyWidthMM / 2;
736
- const pinStartY = -bodyHeightMM / 2;
820
+ generateDrawingPins(drawing, bodyWidthMM, bodyHeightMM, pins, defaultLineColor) {
821
+ const leftPinStart = bodyWidthMM.neg().div(2);
822
+ const rightPinStart = bodyWidthMM.div(2);
823
+ const topPinStart = bodyHeightMM.neg().div(2);
824
+ const bottomPinStart = bodyHeightMM.div(2);
825
+ const pinStartY = bodyHeightMM.neg().div(2);
826
+ const pinStartX = bodyWidthMM.neg().div(2);
827
+ const tmpPinSpacing = this.pinSpacing.toNumber();
828
+ const { left: leftPins, right: rightPins, top: topPins, bottom: bottomPins } = pins;
737
829
  leftPins.forEach(pin => {
738
830
  const position = pin.position;
739
- const pinY = pinStartY + (position + 1) * this.pinSpacing;
740
- drawing.addPinMM(pin.pinId, leftPinStart - this.pinLength, pinY, leftPinStart, pinY, defaultLineColor);
831
+ const pinY = pinStartY.add((position + 1) * tmpPinSpacing);
832
+ drawing.addPinMM(numeric(pin.pinId), leftPinStart.sub(this.pinLength), pinY, leftPinStart, pinY, defaultLineColor);
741
833
  drawing.addModulePort(leftPinStart, pinY, this.portWidth, this.portHeight, pin.pinType);
742
- drawing.addLabel(leftPinStart + this.portWidth + milsToMM(20), pinY, pin.text, {
743
- fontSize: 40,
834
+ drawing.addLabel(leftPinStart.add(this.portWidth).add(milsToMM(20)), pinY, pin.text, {
835
+ fontSize: numeric(40),
744
836
  anchor: HorizontalAlign.Left,
745
837
  vanchor: VerticalAlign.Middle,
746
838
  textColor: ColorScheme.PinNameColor,
@@ -748,14 +840,40 @@ export class SymbolCustomModule extends SymbolCustom {
748
840
  });
749
841
  rightPins.forEach(pin => {
750
842
  const position = pin.position;
751
- const pinY = pinStartY + (position + 1) * this.pinSpacing;
752
- drawing.addPinMM(pin.pinId, rightPinStart + this.pinLength, pinY, rightPinStart, pinY, defaultLineColor);
843
+ const pinY = pinStartY.add((position + 1) * tmpPinSpacing);
844
+ drawing.addPinMM(numeric(pin.pinId), rightPinStart.add(this.pinLength), pinY, rightPinStart, pinY, defaultLineColor);
753
845
  drawing.addModulePort(rightPinStart, pinY, this.portWidth, this.portHeight, pin.pinType, -1);
754
- drawing.addLabel(rightPinStart - this.portWidth - milsToMM(20), pinY, pin.text, {
755
- fontSize: 40,
846
+ drawing.addLabel(rightPinStart.sub(this.portWidth).sub(milsToMM(20)), pinY, pin.text, {
847
+ fontSize: numeric(40),
848
+ anchor: HorizontalAlign.Right,
849
+ vanchor: VerticalAlign.Middle,
850
+ textColor: ColorScheme.PinNameColor,
851
+ });
852
+ });
853
+ topPins.forEach(pin => {
854
+ const position = pin.position;
855
+ const pinX = pinStartX.add((position + 1) * tmpPinSpacing);
856
+ drawing.addPinMM(numeric(pin.pinId), pinX, topPinStart.sub(this.pinLength), pinX, topPinStart, defaultLineColor);
857
+ drawing.addModulePort(pinX, topPinStart, this.portWidth, this.portHeight, pin.pinType, 1, 90);
858
+ drawing.addLabel(pinX, topPinStart.add(this.portWidth).add(milsToMM(20)), pin.text, {
859
+ fontSize: numeric(40),
756
860
  anchor: HorizontalAlign.Right,
757
861
  vanchor: VerticalAlign.Middle,
758
862
  textColor: ColorScheme.PinNameColor,
863
+ angle: numeric(-90),
864
+ });
865
+ });
866
+ bottomPins.forEach(pin => {
867
+ const position = pin.position;
868
+ const pinX = pinStartX.add((position + 1) * tmpPinSpacing);
869
+ drawing.addPinMM(numeric(pin.pinId), pinX, bottomPinStart, pinX, bottomPinStart.sub(this.pinLength), defaultLineColor);
870
+ drawing.addModulePort(pinX, bottomPinStart, this.portWidth, this.portHeight, pin.pinType, 1, -90);
871
+ drawing.addLabel(pinX, bottomPinStart.sub(this.portWidth).sub(milsToMM(20)), pin.text, {
872
+ fontSize: numeric(40),
873
+ anchor: HorizontalAlign.Left,
874
+ vanchor: VerticalAlign.Middle,
875
+ textColor: ColorScheme.PinNameColor,
876
+ angle: numeric(-90),
759
877
  });
760
878
  });
761
879
  }
@@ -766,7 +884,7 @@ export class SymbolDrawing {
766
884
  angle = 0;
767
885
  flipX = 0;
768
886
  flipY = 0;
769
- mainOrigin = [0, 0];
887
+ mainOrigin = [numeric(0), numeric(0)];
770
888
  logger = null;
771
889
  variables = new Map();
772
890
  clear() {
@@ -793,26 +911,30 @@ export class SymbolDrawing {
793
911
  }
794
912
  addPinMM(pinId, startXMM, startYMM, endXMM, endYMM, lineColor) {
795
913
  let angle = 0;
796
- if (startXMM === endXMM) {
797
- if (startYMM > endYMM) {
914
+ const tmpStartXMM = startXMM.toNumber();
915
+ const tmpEndXMM = endXMM.toNumber();
916
+ const tmpStartYMM = startYMM.toNumber();
917
+ const tmpEndYMM = endYMM.toNumber();
918
+ if (tmpStartXMM === tmpEndXMM) {
919
+ if (tmpStartYMM > tmpEndYMM) {
798
920
  angle = 270;
799
921
  }
800
- else if (startYMM < endYMM) {
922
+ else if (tmpStartYMM < tmpEndYMM) {
801
923
  angle = 90;
802
924
  }
803
925
  }
804
926
  else {
805
- if (startXMM < endXMM) {
927
+ if (tmpStartXMM < tmpEndXMM) {
806
928
  angle = 0;
807
929
  }
808
- else if (startXMM > endXMM) {
930
+ else if (tmpStartXMM > tmpEndXMM) {
809
931
  angle = 180;
810
932
  }
811
933
  }
812
934
  this.pins.push([
813
935
  pinId,
814
936
  Geometry.segment([startXMM, startYMM], [endXMM, endYMM]),
815
- angle,
937
+ numeric(angle),
816
938
  lineColor
817
939
  ]);
818
940
  return this;
@@ -821,14 +943,14 @@ export class SymbolDrawing {
821
943
  startX = milsToMM(startX);
822
944
  startY = milsToMM(startY);
823
945
  value = milsToMM(value);
824
- this.items.push(Geometry.segment([startX, startY], [startX, startY + value]));
946
+ this.items.push(Geometry.segment([startX, startY], [startX, startY.add(value)]));
825
947
  return this;
826
948
  }
827
949
  addHLine(startX, startY, value) {
828
950
  startX = milsToMM(startX);
829
951
  startY = milsToMM(startY);
830
952
  value = milsToMM(value);
831
- this.items.push(Geometry.segment([startX, startY], [startX + value, startY]));
953
+ this.items.push(Geometry.segment([startX, startY], [startX.add(value), startY]));
832
954
  return this;
833
955
  }
834
956
  addRect(centerX, centerY, width, height) {
@@ -839,14 +961,14 @@ export class SymbolDrawing {
839
961
  return this.addRectMM(centerX, centerY, width, height);
840
962
  }
841
963
  addRectMM(centerX, centerY, width, height) {
842
- const width2 = width / 2;
843
- const height2 = height / 2;
964
+ const width2 = width.div(2);
965
+ const height2 = height.div(2);
844
966
  this.items.push(Geometry.polygon([
845
- [centerX - width2, centerY - height2],
846
- [centerX + width2, centerY - height2],
847
- [centerX + width2, centerY + height2],
848
- [centerX - width2, centerY + height2],
849
- [centerX - width2, centerY - height2]
967
+ [centerX.sub(width2), centerY.sub(height2)],
968
+ [centerX.add(width2), centerY.sub(height2)],
969
+ [centerX.add(width2), centerY.add(height2)],
970
+ [centerX.sub(width2), centerY.add(height2)],
971
+ [centerX.sub(width2), centerY.sub(height2)]
850
972
  ]));
851
973
  return this;
852
974
  }
@@ -858,25 +980,15 @@ export class SymbolDrawing {
858
980
  width = milsToMM(width);
859
981
  const line = Geometry.line(startX, startY, endX, endY);
860
982
  const normLine = line.norm;
861
- const dx1 = normLine.x * width / 2;
862
- const dy1 = normLine.y * width / 2;
863
- const dx2 = normLine.x * -width / 2;
864
- const dy2 = normLine.y * -width / 2;
983
+ const dx1 = numeric(normLine.x).mul(width).div(2);
984
+ const dy1 = numeric(normLine.y).mul(width).div(2);
985
+ const dx2 = numeric(normLine.x).mul(width.neg()).div(2);
986
+ const dy2 = numeric(normLine.y).mul(width.neg()).div(2);
865
987
  this.items.push(Geometry.polygon([
866
- [dx1 + startX, dy1 + startY],
867
- [dx2 + startX, dy2 + startY],
988
+ [dx1.add(startX), dy1.add(startY)],
989
+ [dx2.add(startX), dy2.add(startY)],
868
990
  [endX, endY],
869
- [dx1 + startX, dy1 + startY],
870
- ]));
871
- return this;
872
- }
873
- addRect2(x, y, x2, y2) {
874
- this.items.push(Geometry.polygon([
875
- [x, y],
876
- [x2, y],
877
- [x2, y2],
878
- [x, y2],
879
- [x, y]
991
+ [dx1.add(startX), dy1.add(startY)],
880
992
  ]));
881
993
  return this;
882
994
  }
@@ -896,54 +1008,59 @@ export class SymbolDrawing {
896
1008
  this.items.push(Geometry.textbox(null, x, y, textValue, style));
897
1009
  return this;
898
1010
  }
899
- addModulePort(x, y, width, height, portType = PinTypes.Any, scaleX = 1) {
900
- const height2 = height / 2;
1011
+ addModulePort(x, y, width, height, portType = PinTypes.Any, scaleX = 1, angle = 0) {
1012
+ const height2 = height.div(2);
901
1013
  let path = [];
902
1014
  const arrowSize = milsToMM(30);
903
1015
  if (portType === PinTypes.Any) {
904
1016
  path = [
905
- [0, -height2],
906
- [width, -height2],
907
- [width, +height2],
908
- [0, +height2],
909
- [0, -height2]
1017
+ [numeric(0), height2.neg()],
1018
+ [width, height2.neg()],
1019
+ [width, height2],
1020
+ [numeric(0), height2],
1021
+ [numeric(0), height2.neg()]
910
1022
  ];
911
1023
  }
912
1024
  else if (portType === PinTypes.Output) {
913
1025
  path = [
914
- [arrowSize, -height2],
915
- [width, -height2],
1026
+ [arrowSize, height2.neg()],
1027
+ [width, height2.neg()],
916
1028
  [width, height2],
917
1029
  [arrowSize, height2],
918
- [0, 0],
919
- [arrowSize, -height2]
1030
+ [numeric(0), numeric(0)],
1031
+ [arrowSize, height2.neg()]
920
1032
  ];
921
1033
  }
922
1034
  else if (portType === PinTypes.Input) {
923
1035
  path = [
924
- [0, -height2],
925
- [width - arrowSize, -height2],
926
- [width, 0],
927
- [width - arrowSize, height2],
928
- [0, +height2],
929
- [0, -height2],
1036
+ [numeric(0), height2.neg()],
1037
+ [width.sub(arrowSize), height2.neg()],
1038
+ [width, numeric(0)],
1039
+ [width.sub(arrowSize), height2],
1040
+ [numeric(0), height2],
1041
+ [numeric(0), height2.neg()],
930
1042
  ];
931
1043
  }
932
1044
  else if (portType === PinTypes.IO) {
933
1045
  path = [
934
- [arrowSize, -height2],
935
- [width - arrowSize, -height2],
936
- [width, 0],
937
- [width - arrowSize, +height2],
938
- [arrowSize, +height2],
939
- [0, 0],
940
- [0 + arrowSize, -height2],
1046
+ [arrowSize, height2.neg()],
1047
+ [width.sub(arrowSize), height2.neg()],
1048
+ [width, numeric(0)],
1049
+ [width.sub(arrowSize), height2],
1050
+ [arrowSize, height2],
1051
+ [numeric(0), numeric(0)],
1052
+ [arrowSize, height2.neg()],
941
1053
  ];
942
1054
  }
943
1055
  path = path.map(point => {
944
- return [x + point[0] * scaleX, y + point[1]];
1056
+ return [
1057
+ x.add(point[0].mul(scaleX)),
1058
+ y.add(point[1])
1059
+ ];
945
1060
  });
946
- this.items.push(Geometry.polygon(path));
1061
+ const polygon = Geometry.polygon(path)
1062
+ .rotate(angle * Math.PI / 180, Geometry.point(x, y));
1063
+ this.items.push(polygon);
947
1064
  return this;
948
1065
  }
949
1066
  addPath(...pathParts) {
@@ -952,6 +1069,9 @@ export class SymbolDrawing {
952
1069
  accum = accum.concat(tmp.split(" "));
953
1070
  }
954
1071
  else if (typeof tmp === "number") {
1072
+ accum.push(numeric(tmp));
1073
+ }
1074
+ else if (tmp instanceof NumericValue) {
955
1075
  accum.push(tmp);
956
1076
  }
957
1077
  return accum;
@@ -964,14 +1084,14 @@ export class SymbolDrawing {
964
1084
  if (currentObj !== null) {
965
1085
  geomObjects.push(currentObj);
966
1086
  }
967
- const x = milsToMM(Number(parts[i + 1]));
968
- const y = milsToMM(Number(parts[i + 2]));
1087
+ const x = milsToMM(parts[i + 1]);
1088
+ const y = milsToMM(parts[i + 2]);
969
1089
  currentObj = [[x, y]];
970
1090
  i += 2;
971
1091
  }
972
1092
  else if (command === 'L') {
973
- const x = milsToMM(Number(parts[i + 1]));
974
- const y = milsToMM(Number(parts[i + 2]));
1093
+ const x = milsToMM(parts[i + 1]);
1094
+ const y = milsToMM(parts[i + 2]);
975
1095
  currentObj.push([x, y]);
976
1096
  i += 2;
977
1097
  }
@@ -1017,8 +1137,8 @@ export class SymbolDrawing {
1017
1137
  x = milsToMM(x);
1018
1138
  y = milsToMM(y);
1019
1139
  radius = milsToMM(radius);
1020
- startAngle = startAngle * Math.PI / 180;
1021
- endAngle = endAngle * Math.PI / 180;
1140
+ startAngle = startAngle.mul(Math.PI).div(180);
1141
+ endAngle = endAngle.mul(Math.PI).div(180);
1022
1142
  this.items.push(Geometry.arc([x, y], radius, startAngle, endAngle, true));
1023
1143
  return this;
1024
1144
  }
@@ -1028,7 +1148,7 @@ export class SymbolDrawing {
1028
1148
  }
1029
1149
  getPaths() {
1030
1150
  let currentFill = "#fff";
1031
- let currentLineWidth = 1;
1151
+ let currentLineWidth = numeric(1);
1032
1152
  let currentLineColor = '#333';
1033
1153
  const pathItems = [];
1034
1154
  this.items.forEach(item => {
@@ -1095,7 +1215,7 @@ export class SymbolDrawing {
1095
1215
  }
1096
1216
  getPinPosition(pinId) {
1097
1217
  const pin = this.pins.find(item => {
1098
- return item[0] === pinId;
1218
+ return item[0].toNumber() === pinId;
1099
1219
  });
1100
1220
  if (pin) {
1101
1221
  const [, feature, angle] = pin;
@@ -1133,4 +1253,7 @@ export class SymbolDrawingCommands extends SymbolDrawing {
1133
1253
  cloned.variables = this.variables;
1134
1254
  return cloned;
1135
1255
  }
1256
+ eq(other) {
1257
+ return this.callback === other.callback;
1258
+ }
1136
1259
  }