circuitscript 0.4.1 → 0.5.0
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.
- package/dist/cjs/BaseVisitor.js +16 -10
- package/dist/cjs/BomGeneration.js +3 -3
- package/dist/cjs/ComponentMatchConditions.js +2 -2
- package/dist/cjs/annotate/RefdesAnnotationVisitor.js +4 -0
- package/dist/cjs/builtinMethods.js +10 -10
- package/dist/cjs/execute.js +25 -23
- package/dist/cjs/globals.js +7 -14
- package/dist/cjs/helpers.js +4 -3
- package/dist/cjs/lexer.js +8 -4
- package/dist/cjs/objects/BlockTypes.js +10 -0
- package/dist/cjs/objects/NumericValue.js +196 -0
- package/dist/cjs/objects/ParamDefinition.js +1 -149
- package/dist/cjs/objects/PercentageValue.js +15 -0
- package/dist/cjs/objects/PinDefinition.js +2 -2
- package/dist/cjs/objects/WrappedNumber.js +15 -0
- package/dist/cjs/pipeline.js +2 -2
- package/dist/cjs/render/draw_symbols.js +78 -78
- package/dist/cjs/render/export.js +2 -2
- package/dist/cjs/render/geometry.js +11 -12
- package/dist/cjs/render/graph.js +2 -2
- package/dist/cjs/render/layout.js +46 -46
- package/dist/cjs/render/render.js +19 -19
- package/dist/cjs/semantic-tokens/SemanticTokenVisitor.js +59 -59
- package/dist/cjs/utils.js +21 -83
- package/dist/cjs/visitor.js +45 -31
- package/dist/esm/BaseVisitor.js +8 -2
- package/dist/esm/BomGeneration.js +1 -1
- package/dist/esm/ComponentMatchConditions.js +1 -1
- package/dist/esm/annotate/RefdesAnnotationVisitor.js +4 -0
- package/dist/esm/builtinMethods.js +2 -2
- package/dist/esm/execute.js +4 -2
- package/dist/esm/globals.js +1 -8
- package/dist/esm/helpers.js +3 -2
- package/dist/esm/lexer.js +8 -4
- package/dist/esm/objects/BlockTypes.js +7 -0
- package/dist/esm/objects/NumericValue.js +189 -0
- package/dist/esm/objects/ParamDefinition.js +0 -148
- package/dist/esm/objects/PercentageValue.js +12 -0
- package/dist/esm/objects/PinDefinition.js +1 -1
- package/dist/esm/objects/WrappedNumber.js +12 -0
- package/dist/esm/pipeline.js +2 -2
- package/dist/esm/render/draw_symbols.js +2 -2
- package/dist/esm/render/export.js +1 -1
- package/dist/esm/render/geometry.js +1 -2
- package/dist/esm/render/graph.js +1 -1
- package/dist/esm/render/layout.js +2 -2
- package/dist/esm/render/render.js +1 -1
- package/dist/esm/semantic-tokens/SemanticTokenVisitor.js +58 -58
- package/dist/esm/utils.js +16 -74
- package/dist/esm/visitor.js +17 -3
- package/dist/types/ComponentMatchConditions.d.ts +1 -1
- package/dist/types/annotate/RefdesAnnotationVisitor.d.ts +3 -1
- package/dist/types/execute.d.ts +4 -2
- package/dist/types/globals.d.ts +1 -7
- package/dist/types/helpers.d.ts +2 -2
- package/dist/types/lexer.d.ts +1 -0
- package/dist/types/objects/BlockTypes.d.ts +6 -0
- package/dist/types/objects/ClassComponent.d.ts +1 -1
- package/dist/types/objects/ExecutionScope.d.ts +2 -1
- package/dist/types/objects/NumericValue.d.ts +35 -0
- package/dist/types/objects/ParamDefinition.d.ts +0 -41
- package/dist/types/objects/PercentageValue.d.ts +6 -0
- package/dist/types/objects/PinDefinition.d.ts +1 -1
- package/dist/types/objects/WrappedNumber.d.ts +6 -0
- package/dist/types/objects/types.d.ts +2 -1
- package/dist/types/render/draw_symbols.d.ts +1 -1
- package/dist/types/render/geometry.d.ts +1 -1
- package/dist/types/render/layout.d.ts +1 -1
- package/dist/types/semantic-tokens/SemanticTokenVisitor.d.ts +3 -4
- package/dist/types/utils.d.ts +1 -7
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ const geometry_js_1 = require("./geometry.js");
|
|
|
7
7
|
const PinTypes_js_1 = require("../objects/PinTypes.js");
|
|
8
8
|
const utils_js_1 = require("../utils.js");
|
|
9
9
|
const types_js_1 = require("../objects/types.js");
|
|
10
|
-
const
|
|
10
|
+
const NumericValue_js_1 = require("../objects/NumericValue.js");
|
|
11
11
|
const PinDefinition_js_1 = require("../objects/PinDefinition.js");
|
|
12
12
|
class SymbolGraphic {
|
|
13
13
|
constructor() {
|
|
@@ -16,8 +16,8 @@ class SymbolGraphic {
|
|
|
16
16
|
this._angle = 0;
|
|
17
17
|
this._flipX = 0;
|
|
18
18
|
this._flipY = 0;
|
|
19
|
-
this.width = (0,
|
|
20
|
-
this.height = (0,
|
|
19
|
+
this.width = (0, NumericValue_js_1.numeric)(-1);
|
|
20
|
+
this.height = (0, NumericValue_js_1.numeric)(-1);
|
|
21
21
|
this.labelTexts = new Map();
|
|
22
22
|
this.drawing = new SymbolDrawing();
|
|
23
23
|
}
|
|
@@ -45,11 +45,11 @@ class SymbolGraphic {
|
|
|
45
45
|
}
|
|
46
46
|
calculateSize() {
|
|
47
47
|
const { width, height } = this.drawing.getBoundingBox();
|
|
48
|
-
this.width = (0,
|
|
49
|
-
this.height = (0,
|
|
48
|
+
this.width = (0, NumericValue_js_1.numeric)(width);
|
|
49
|
+
this.height = (0, NumericValue_js_1.numeric)(height);
|
|
50
50
|
return {
|
|
51
|
-
bodyWidth: (0,
|
|
52
|
-
bodyHeight: (0,
|
|
51
|
+
bodyWidth: (0, NumericValue_js_1.numeric)(-1),
|
|
52
|
+
bodyHeight: (0, NumericValue_js_1.numeric)(-1),
|
|
53
53
|
width: this.width,
|
|
54
54
|
height: this.height
|
|
55
55
|
};
|
|
@@ -88,8 +88,8 @@ class SymbolGraphic {
|
|
|
88
88
|
throw new utils_js_1.RuntimeExecutionError(`Could not determine pin ${id} position`);
|
|
89
89
|
}
|
|
90
90
|
const [x, y] = pin.start;
|
|
91
|
-
const useX = (0,
|
|
92
|
-
const useY = (0,
|
|
91
|
+
const useX = (0, NumericValue_js_1.roundValue)(x);
|
|
92
|
+
const useY = (0, NumericValue_js_1.roundValue)(y);
|
|
93
93
|
return {
|
|
94
94
|
x: useX,
|
|
95
95
|
y: useY,
|
|
@@ -137,7 +137,7 @@ class SymbolGraphic {
|
|
|
137
137
|
const labels = this.drawing.getLabels();
|
|
138
138
|
for (const label of labels) {
|
|
139
139
|
const tmpLabel = label;
|
|
140
|
-
const { fontSize = (0,
|
|
140
|
+
const { fontSize = (0, NumericValue_js_1.numeric)(50), anchor = geometry_js_1.HorizontalAlign.Left, vanchor = geometry_js_1.VerticalAlign.Bottom, fontWeight = 'regular', angle: tmpLabelAngle = (0, NumericValue_js_1.numeric)(0), textColor = "#333", } = tmpLabel.style ?? {};
|
|
141
141
|
let anchorStyle = 'start';
|
|
142
142
|
let dominantBaseline = 'auto';
|
|
143
143
|
let useAnchor = anchor;
|
|
@@ -193,8 +193,8 @@ class SymbolGraphic {
|
|
|
193
193
|
translateX = position[0];
|
|
194
194
|
translateY = position[1];
|
|
195
195
|
useRotateAngle = this.angle;
|
|
196
|
-
translateX = (0,
|
|
197
|
-
translateY = (0,
|
|
196
|
+
translateX = (0, NumericValue_js_1.roundValue)(translateX);
|
|
197
|
+
translateY = (0, NumericValue_js_1.roundValue)(translateY);
|
|
198
198
|
const { portType = null } = tmpLabel.style;
|
|
199
199
|
if (portType !== null) {
|
|
200
200
|
const { x: boundsX, y: boundsY } = tmpLabel.textMeasurementBounds;
|
|
@@ -304,12 +304,12 @@ class SymbolGraphic {
|
|
|
304
304
|
.rotate(useLabelAngle, 0, 0);
|
|
305
305
|
const { a, b, c, d, e, f } = textContainer.matrix();
|
|
306
306
|
const newMatrix = {
|
|
307
|
-
a: (0,
|
|
308
|
-
b: (0,
|
|
309
|
-
c: (0,
|
|
310
|
-
d: (0,
|
|
311
|
-
e: (0,
|
|
312
|
-
f: (0,
|
|
307
|
+
a: (0, NumericValue_js_1.roundValue)((0, NumericValue_js_1.numeric)(a)).toNumber(),
|
|
308
|
+
b: (0, NumericValue_js_1.roundValue)((0, NumericValue_js_1.numeric)(b)).toNumber(),
|
|
309
|
+
c: (0, NumericValue_js_1.roundValue)((0, NumericValue_js_1.numeric)(c)).toNumber(),
|
|
310
|
+
d: (0, NumericValue_js_1.roundValue)((0, NumericValue_js_1.numeric)(d)).toNumber(),
|
|
311
|
+
e: (0, NumericValue_js_1.roundValue)((0, NumericValue_js_1.numeric)(e)).toNumber(),
|
|
312
|
+
f: (0, NumericValue_js_1.roundValue)((0, NumericValue_js_1.numeric)(f)).toNumber(),
|
|
313
313
|
};
|
|
314
314
|
textContainer.transform(newMatrix);
|
|
315
315
|
if (globals_js_1.RenderFlags.ShowLabelOrigin) {
|
|
@@ -347,14 +347,14 @@ exports.SymbolGraphic = SymbolGraphic;
|
|
|
347
347
|
class SymbolText extends SymbolGraphic {
|
|
348
348
|
constructor(text) {
|
|
349
349
|
super();
|
|
350
|
-
this.fontSize = (0,
|
|
350
|
+
this.fontSize = (0, NumericValue_js_1.numeric)(40);
|
|
351
351
|
this.fontWeight = 'regular';
|
|
352
352
|
this.text = text;
|
|
353
353
|
}
|
|
354
354
|
generateDrawing() {
|
|
355
355
|
const drawing = this.drawing;
|
|
356
356
|
drawing.clear();
|
|
357
|
-
drawing.addTextbox((0,
|
|
357
|
+
drawing.addTextbox((0, NumericValue_js_1.numeric)(0), (0, NumericValue_js_1.numeric)(0), this.text, {
|
|
358
358
|
fontSize: this.fontSize,
|
|
359
359
|
anchor: geometry_js_1.HorizontalAlign.Middle,
|
|
360
360
|
fontWeight: this.fontWeight,
|
|
@@ -375,7 +375,7 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
375
375
|
[PlaceHolderCommands.units, ['mils'], {}],
|
|
376
376
|
[PlaceHolderCommands.lineColor, [globals_js_1.ColorScheme.PinLineColor], {}],
|
|
377
377
|
[PlaceHolderCommands.textColor, [globals_js_1.ColorScheme.PinNameColor], {}],
|
|
378
|
-
[PlaceHolderCommands.lineWidth, [(0,
|
|
378
|
+
[PlaceHolderCommands.lineWidth, [(0, NumericValue_js_1.numeric)(5)], {}],
|
|
379
379
|
...drawing.getCommands()
|
|
380
380
|
];
|
|
381
381
|
drawing.log('id: ', drawing.id, 'angle: ', this._angle, "commands:", commands.length);
|
|
@@ -430,8 +430,8 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
430
430
|
drawing.addArc(...positionParams);
|
|
431
431
|
break;
|
|
432
432
|
case PlaceHolderCommands.circle:
|
|
433
|
-
drawing.addArc(...positionParams, (0,
|
|
434
|
-
drawing.addArc(...positionParams, (0,
|
|
433
|
+
drawing.addArc(...positionParams, (0, NumericValue_js_1.numeric)(0), (0, NumericValue_js_1.numeric)(180));
|
|
434
|
+
drawing.addArc(...positionParams, (0, NumericValue_js_1.numeric)(180), (0, NumericValue_js_1.numeric)(360));
|
|
435
435
|
break;
|
|
436
436
|
case PlaceHolderCommands.triangle:
|
|
437
437
|
drawing.addTriangle(...positionParams);
|
|
@@ -464,8 +464,8 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
464
464
|
case PlaceHolderCommands.text: {
|
|
465
465
|
const style = this.parseLabelStyle(keywordParams);
|
|
466
466
|
const content = keywordParams.get('content');
|
|
467
|
-
let offsetX = (0,
|
|
468
|
-
let offsetY = (0,
|
|
467
|
+
let offsetX = (0, NumericValue_js_1.numeric)(0);
|
|
468
|
+
let offsetY = (0, NumericValue_js_1.numeric)(0);
|
|
469
469
|
if (keywordParams.has('offset')) {
|
|
470
470
|
const offset = keywordParams.get('offset');
|
|
471
471
|
offsetX = offset[0];
|
|
@@ -519,13 +519,13 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
519
519
|
let displayPinName = true;
|
|
520
520
|
if (keywordParams.has(keywordDisplayPinId)) {
|
|
521
521
|
const value = keywordParams.get(keywordDisplayPinId);
|
|
522
|
-
displayPinId = ((value instanceof
|
|
522
|
+
displayPinId = ((value instanceof NumericValue_js_1.NumericValue && value.toNumber() === 0)
|
|
523
523
|
|| (value === 0)
|
|
524
524
|
|| (value === false)) ? false : true;
|
|
525
525
|
}
|
|
526
526
|
if (keywordParams.has(keywordDisplayPinName)) {
|
|
527
527
|
const value = keywordParams.get(keywordDisplayPinName);
|
|
528
|
-
displayPinName = ((value instanceof
|
|
528
|
+
displayPinName = ((value instanceof NumericValue_js_1.NumericValue && value.toNumber() === 0)
|
|
529
529
|
|| (value === 0)
|
|
530
530
|
|| (value === false)) ? false : true;
|
|
531
531
|
}
|
|
@@ -575,7 +575,7 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
575
575
|
(0, helpers_js_1.milsToMM)(endY)
|
|
576
576
|
];
|
|
577
577
|
}
|
|
578
|
-
if (positionParams[0] instanceof
|
|
578
|
+
if (positionParams[0] instanceof NumericValue_js_1.NumericValue) {
|
|
579
579
|
positionParams[0] = new PinDefinition_js_1.PinId(positionParams[0].toNumber());
|
|
580
580
|
}
|
|
581
581
|
else if (typeof positionParams[0] === 'number' || typeof positionParams[0] === 'string') {
|
|
@@ -590,7 +590,7 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
590
590
|
const offset2 = 15;
|
|
591
591
|
let pinNameOffsetX = (0, helpers_js_1.milsToMM)(0);
|
|
592
592
|
let pinNameOffsetY = (0, helpers_js_1.milsToMM)(0);
|
|
593
|
-
let pinIdOffsetX = (0,
|
|
593
|
+
let pinIdOffsetX = (0, NumericValue_js_1.numeric)(0);
|
|
594
594
|
let pinIdAlignment = geometry_js_1.HorizontalAlign.Left;
|
|
595
595
|
let pinIdVAlignment = geometry_js_1.VerticalAlign.Bottom;
|
|
596
596
|
let pinIdOffsetY = (0, helpers_js_1.milsToMM)(-offset2);
|
|
@@ -633,19 +633,19 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
633
633
|
if (angleValue === 0 || angleValue === 90 || angleValue === 180 || angleValue === 270) {
|
|
634
634
|
const usePinName = pinNameParam ?? "";
|
|
635
635
|
displayPinName && usePinName !== "" && drawing.addLabel(endX.add(pinNameOffsetX), endY.add(pinNameOffsetY), usePinName, {
|
|
636
|
-
fontSize: (0,
|
|
636
|
+
fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.defaultPinNameTextSize),
|
|
637
637
|
anchor: pinNameAlignment,
|
|
638
638
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
639
639
|
textColor: pinNameColor,
|
|
640
|
-
angle: (0,
|
|
640
|
+
angle: (0, NumericValue_js_1.numeric)(usePinIdAngle)
|
|
641
641
|
});
|
|
642
642
|
const pinDisplayText = pinId.toString();
|
|
643
643
|
displayPinId && drawing.addLabel(endX.add(pinIdOffsetX), endY.add(pinIdOffsetY), pinDisplayText, {
|
|
644
|
-
fontSize: (0,
|
|
644
|
+
fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.defaultPinIdTextSize),
|
|
645
645
|
anchor: pinIdAlignment,
|
|
646
646
|
vanchor: pinIdVAlignment,
|
|
647
647
|
textColor: lineColor,
|
|
648
|
-
angle: (0,
|
|
648
|
+
angle: (0, NumericValue_js_1.numeric)(usePinIdAngle)
|
|
649
649
|
});
|
|
650
650
|
}
|
|
651
651
|
}
|
|
@@ -710,7 +710,7 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
710
710
|
const { bodyWidth, bodyHeight } = this.calculateSize();
|
|
711
711
|
const defaultLineColor = globals_js_1.ColorScheme.PinLineColor;
|
|
712
712
|
drawing.addSetLineColor(defaultLineColor);
|
|
713
|
-
drawing.addSetLineWidth((0,
|
|
713
|
+
drawing.addSetLineWidth((0, NumericValue_js_1.numeric)(5));
|
|
714
714
|
const xBody = bodyWidth.half().neg();
|
|
715
715
|
const yBody = bodyHeight.half().neg();
|
|
716
716
|
drawing.addRectMM(xBody, yBody, bodyWidth, bodyHeight);
|
|
@@ -743,13 +743,13 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
743
743
|
const pinY = pinStartY.add((position + 1) * tmpPinSpacing);
|
|
744
744
|
drawing.addPinMM(pin.pinId, leftPinStart.sub(this.pinLength), pinY, leftPinStart, pinY, defaultLineColor);
|
|
745
745
|
drawing.addLabel(leftPinStart.add((0, helpers_js_1.milsToMM)(20)), pinY, pin.text, {
|
|
746
|
-
fontSize: (0,
|
|
746
|
+
fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolPinTextSize),
|
|
747
747
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
748
748
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
749
749
|
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
750
750
|
});
|
|
751
751
|
drawing.addLabel(leftPinStart.sub((0, helpers_js_1.milsToMM)(10)), pinY.sub((0, helpers_js_1.milsToMM)(10)), pin.pinId.toString(), {
|
|
752
|
-
fontSize: (0,
|
|
752
|
+
fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolPinIdSize),
|
|
753
753
|
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
754
754
|
vanchor: geometry_js_1.VerticalAlign.Bottom,
|
|
755
755
|
textColor: defaultLineColor
|
|
@@ -760,13 +760,13 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
760
760
|
const pinY = pinStartY.add((position + 1) * tmpPinSpacing);
|
|
761
761
|
drawing.addPinMM(pin.pinId, rightPinStart.add(this.pinLength), pinY, rightPinStart, pinY, defaultLineColor);
|
|
762
762
|
drawing.addLabel(rightPinStart.sub((0, helpers_js_1.milsToMM)(20)), pinY, pin.text, {
|
|
763
|
-
fontSize: (0,
|
|
763
|
+
fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolPinTextSize),
|
|
764
764
|
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
765
765
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
766
766
|
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
767
767
|
});
|
|
768
768
|
drawing.addLabel(rightPinStart.add((0, helpers_js_1.milsToMM)(10)), pinY.sub((0, helpers_js_1.milsToMM)(10)), pin.pinId.toString(), {
|
|
769
|
-
fontSize: (0,
|
|
769
|
+
fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolPinIdSize),
|
|
770
770
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
771
771
|
vanchor: geometry_js_1.VerticalAlign.Bottom,
|
|
772
772
|
textColor: defaultLineColor
|
|
@@ -777,18 +777,18 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
777
777
|
const pinX = pinStartX.add((position + 1) * tmpPinSpacing);
|
|
778
778
|
drawing.addPinMM(pin.pinId, pinX, topPinStart.sub(this.pinLength), pinX, topPinStart, defaultLineColor);
|
|
779
779
|
drawing.addLabel(pinX, topPinStart.add((0, helpers_js_1.milsToMM)(20)), pin.text, {
|
|
780
|
-
fontSize: (0,
|
|
780
|
+
fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolPinTextSize),
|
|
781
781
|
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
782
782
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
783
783
|
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
784
|
-
angle: (0,
|
|
784
|
+
angle: (0, NumericValue_js_1.numeric)(-90),
|
|
785
785
|
});
|
|
786
786
|
drawing.addLabel(pinX.sub((0, helpers_js_1.milsToMM)(10)), topPinStart.sub((0, helpers_js_1.milsToMM)(10)), pin.pinId.toString(), {
|
|
787
|
-
fontSize: (0,
|
|
787
|
+
fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolPinIdSize),
|
|
788
788
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
789
789
|
vanchor: geometry_js_1.VerticalAlign.Bottom,
|
|
790
790
|
textColor: defaultLineColor,
|
|
791
|
-
angle: (0,
|
|
791
|
+
angle: (0, NumericValue_js_1.numeric)(-90),
|
|
792
792
|
});
|
|
793
793
|
}
|
|
794
794
|
for (const pin of bottomPins) {
|
|
@@ -796,23 +796,23 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
796
796
|
const pinX = pinStartX.add((position + 1) * tmpPinSpacing);
|
|
797
797
|
drawing.addPinMM(pin.pinId, pinX, bottomPinStart.add(this.pinLength), pinX, bottomPinStart, defaultLineColor);
|
|
798
798
|
drawing.addLabel(pinX, bottomPinStart.sub((0, helpers_js_1.milsToMM)(20)), pin.text, {
|
|
799
|
-
fontSize: (0,
|
|
799
|
+
fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolPinTextSize),
|
|
800
800
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
801
801
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
802
802
|
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
803
|
-
angle: (0,
|
|
803
|
+
angle: (0, NumericValue_js_1.numeric)(-90),
|
|
804
804
|
});
|
|
805
805
|
drawing.addLabel(pinX.sub((0, helpers_js_1.milsToMM)(10)), bottomPinStart.add((0, helpers_js_1.milsToMM)(10)), pin.pinId.toString(), {
|
|
806
|
-
fontSize: (0,
|
|
806
|
+
fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolPinIdSize),
|
|
807
807
|
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
808
808
|
vanchor: geometry_js_1.VerticalAlign.Bottom,
|
|
809
809
|
textColor: defaultLineColor,
|
|
810
|
-
angle: (0,
|
|
810
|
+
angle: (0, NumericValue_js_1.numeric)(-90)
|
|
811
811
|
});
|
|
812
812
|
}
|
|
813
813
|
const instanceName = drawing.variables.get('refdes');
|
|
814
814
|
instanceName && drawing.addLabel(bodyWidthMM.neg().half(), bodyHeightMM.neg().half().sub((0, helpers_js_1.milsToMM)(20)), instanceName, {
|
|
815
|
-
fontSize: (0,
|
|
815
|
+
fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolRefDesSize),
|
|
816
816
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
817
817
|
});
|
|
818
818
|
const acceptedMPNKeys = ['MPN', 'mpn', 'manufacturer_pn'];
|
|
@@ -820,7 +820,7 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
820
820
|
const labelValue = drawing.variables.get(key);
|
|
821
821
|
if (labelValue !== undefined) {
|
|
822
822
|
drawing.addLabel(bodyWidthMM.neg().half(), bodyHeightMM.half().add((0, helpers_js_1.milsToMM)(20)), labelValue, {
|
|
823
|
-
fontSize: (0,
|
|
823
|
+
fontSize: (0, NumericValue_js_1.numeric)(globals_js_1.CustomSymbolParamTextSize),
|
|
824
824
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
825
825
|
vanchor: geometry_js_1.VerticalAlign.Top,
|
|
826
826
|
});
|
|
@@ -834,7 +834,7 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
834
834
|
const maxBottomPins = this.pinMaxPositions.get(globals_js_1.SymbolPinSide.Bottom);
|
|
835
835
|
const maxLeftPins = this.pinMaxPositions.get(globals_js_1.SymbolPinSide.Left);
|
|
836
836
|
const maxRightPins = this.pinMaxPositions.get(globals_js_1.SymbolPinSide.Right);
|
|
837
|
-
const bodyWidthFromPins = (0,
|
|
837
|
+
const bodyWidthFromPins = (0, NumericValue_js_1.numeric)((1 + Math.max(maxTopPins, maxBottomPins)) * tmpPinSpacing);
|
|
838
838
|
const bodyWidth = Math.max(bodyWidthFromPins.toNumber(), this.bodyWidth.toNumber());
|
|
839
839
|
let tmpBodyHeight = 0;
|
|
840
840
|
if (maxLeftPins === 0 && maxRightPins === 0) {
|
|
@@ -850,11 +850,11 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
850
850
|
const useWidth = bodyWidth
|
|
851
851
|
+ ((this._cacheLeftPins.length > 0) ? tmpPinLength : 0)
|
|
852
852
|
+ ((this._cacheRightPins.length > 0) ? tmpPinLength : 0);
|
|
853
|
-
this.width = (0,
|
|
854
|
-
this.height = (0,
|
|
853
|
+
this.width = (0, NumericValue_js_1.numeric)(useWidth);
|
|
854
|
+
this.height = (0, NumericValue_js_1.numeric)(useHeight);
|
|
855
855
|
return {
|
|
856
|
-
bodyWidth: (0,
|
|
857
|
-
bodyHeight: (0,
|
|
856
|
+
bodyWidth: (0, NumericValue_js_1.numeric)(bodyWidth),
|
|
857
|
+
bodyHeight: (0, NumericValue_js_1.numeric)(bodyHeight),
|
|
858
858
|
width: this.width,
|
|
859
859
|
height: this.height
|
|
860
860
|
};
|
|
@@ -883,7 +883,7 @@ class SymbolCustomModule extends SymbolCustom {
|
|
|
883
883
|
drawing.addPinMM(pin.pinId, leftPinStart.sub(this.pinLength), pinY, leftPinStart, pinY, defaultLineColor);
|
|
884
884
|
drawing.addModulePort(leftPinStart, pinY, this.portWidth, this.portHeight, pin.pinType);
|
|
885
885
|
drawing.addLabel(leftPinStart.add(this.portWidth).add((0, helpers_js_1.milsToMM)(20)), pinY, pin.text, {
|
|
886
|
-
fontSize: (0,
|
|
886
|
+
fontSize: (0, NumericValue_js_1.numeric)(40),
|
|
887
887
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
888
888
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
889
889
|
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
@@ -895,7 +895,7 @@ class SymbolCustomModule extends SymbolCustom {
|
|
|
895
895
|
drawing.addPinMM(pin.pinId, rightPinStart.add(this.pinLength), pinY, rightPinStart, pinY, defaultLineColor);
|
|
896
896
|
drawing.addModulePort(rightPinStart, pinY, this.portWidth, this.portHeight, pin.pinType, -1);
|
|
897
897
|
drawing.addLabel(rightPinStart.sub(this.portWidth).sub((0, helpers_js_1.milsToMM)(20)), pinY, pin.text, {
|
|
898
|
-
fontSize: (0,
|
|
898
|
+
fontSize: (0, NumericValue_js_1.numeric)(40),
|
|
899
899
|
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
900
900
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
901
901
|
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
@@ -907,11 +907,11 @@ class SymbolCustomModule extends SymbolCustom {
|
|
|
907
907
|
drawing.addPinMM(pin.pinId, pinX, topPinStart.sub(this.pinLength), pinX, topPinStart, defaultLineColor);
|
|
908
908
|
drawing.addModulePort(pinX, topPinStart, this.portWidth, this.portHeight, pin.pinType, 1, 90);
|
|
909
909
|
drawing.addLabel(pinX, topPinStart.add(this.portWidth).add((0, helpers_js_1.milsToMM)(20)), pin.text, {
|
|
910
|
-
fontSize: (0,
|
|
910
|
+
fontSize: (0, NumericValue_js_1.numeric)(40),
|
|
911
911
|
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
912
912
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
913
913
|
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
914
|
-
angle: (0,
|
|
914
|
+
angle: (0, NumericValue_js_1.numeric)(-90),
|
|
915
915
|
});
|
|
916
916
|
});
|
|
917
917
|
bottomPins.forEach(pin => {
|
|
@@ -920,11 +920,11 @@ class SymbolCustomModule extends SymbolCustom {
|
|
|
920
920
|
drawing.addPinMM(pin.pinId, pinX, bottomPinStart, pinX, bottomPinStart.sub(this.pinLength), defaultLineColor);
|
|
921
921
|
drawing.addModulePort(pinX, bottomPinStart, this.portWidth, this.portHeight, pin.pinType, 1, -90);
|
|
922
922
|
drawing.addLabel(pinX, bottomPinStart.sub(this.portWidth).sub((0, helpers_js_1.milsToMM)(20)), pin.text, {
|
|
923
|
-
fontSize: (0,
|
|
923
|
+
fontSize: (0, NumericValue_js_1.numeric)(40),
|
|
924
924
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
925
925
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
926
926
|
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
927
|
-
angle: (0,
|
|
927
|
+
angle: (0, NumericValue_js_1.numeric)(-90),
|
|
928
928
|
});
|
|
929
929
|
});
|
|
930
930
|
}
|
|
@@ -937,7 +937,7 @@ class SymbolDrawing {
|
|
|
937
937
|
this.angle = 0;
|
|
938
938
|
this.flipX = 0;
|
|
939
939
|
this.flipY = 0;
|
|
940
|
-
this.mainOrigin = [(0,
|
|
940
|
+
this.mainOrigin = [(0, NumericValue_js_1.numeric)(0), (0, NumericValue_js_1.numeric)(0)];
|
|
941
941
|
this.logger = null;
|
|
942
942
|
this.variables = new Map();
|
|
943
943
|
}
|
|
@@ -981,7 +981,7 @@ class SymbolDrawing {
|
|
|
981
981
|
this.pins.push([
|
|
982
982
|
pinId,
|
|
983
983
|
geometry_js_1.Geometry.segment([startXMM, startYMM], [endXMM, endYMM]),
|
|
984
|
-
(0,
|
|
984
|
+
(0, NumericValue_js_1.numeric)(angle),
|
|
985
985
|
lineColor
|
|
986
986
|
]);
|
|
987
987
|
return this;
|
|
@@ -1023,10 +1023,10 @@ class SymbolDrawing {
|
|
|
1023
1023
|
width = (0, helpers_js_1.milsToMM)(width);
|
|
1024
1024
|
const line = geometry_js_1.Geometry.line(startX, startY, endX, endY);
|
|
1025
1025
|
const normLine = line.norm;
|
|
1026
|
-
const dx1 = (0,
|
|
1027
|
-
const dy1 = (0,
|
|
1028
|
-
const dx2 = (0,
|
|
1029
|
-
const dy2 = (0,
|
|
1026
|
+
const dx1 = (0, NumericValue_js_1.numeric)(normLine.x).mul(width).half();
|
|
1027
|
+
const dy1 = (0, NumericValue_js_1.numeric)(normLine.y).mul(width).half();
|
|
1028
|
+
const dx2 = (0, NumericValue_js_1.numeric)(normLine.x).mul(width.neg()).half();
|
|
1029
|
+
const dy2 = (0, NumericValue_js_1.numeric)(normLine.y).mul(width.neg()).half();
|
|
1030
1030
|
this.items.push(geometry_js_1.Geometry.polygon([
|
|
1031
1031
|
[dx1.add(startX), dy1.add(startY)],
|
|
1032
1032
|
[dx2.add(startX), dy2.add(startY)],
|
|
@@ -1057,11 +1057,11 @@ class SymbolDrawing {
|
|
|
1057
1057
|
const arrowSize = (0, helpers_js_1.milsToMM)(30);
|
|
1058
1058
|
if (portType === PinTypes_js_1.PinTypes.Any) {
|
|
1059
1059
|
path = [
|
|
1060
|
-
[(0,
|
|
1060
|
+
[(0, NumericValue_js_1.numeric)(0), height2.neg()],
|
|
1061
1061
|
[width, height2.neg()],
|
|
1062
1062
|
[width, height2],
|
|
1063
|
-
[(0,
|
|
1064
|
-
[(0,
|
|
1063
|
+
[(0, NumericValue_js_1.numeric)(0), height2],
|
|
1064
|
+
[(0, NumericValue_js_1.numeric)(0), height2.neg()]
|
|
1065
1065
|
];
|
|
1066
1066
|
}
|
|
1067
1067
|
else if (portType === PinTypes_js_1.PinTypes.Output) {
|
|
@@ -1070,28 +1070,28 @@ class SymbolDrawing {
|
|
|
1070
1070
|
[width, height2.neg()],
|
|
1071
1071
|
[width, height2],
|
|
1072
1072
|
[arrowSize, height2],
|
|
1073
|
-
[(0,
|
|
1073
|
+
[(0, NumericValue_js_1.numeric)(0), (0, NumericValue_js_1.numeric)(0)],
|
|
1074
1074
|
[arrowSize, height2.neg()]
|
|
1075
1075
|
];
|
|
1076
1076
|
}
|
|
1077
1077
|
else if (portType === PinTypes_js_1.PinTypes.Input) {
|
|
1078
1078
|
path = [
|
|
1079
|
-
[(0,
|
|
1079
|
+
[(0, NumericValue_js_1.numeric)(0), height2.neg()],
|
|
1080
1080
|
[width.sub(arrowSize), height2.neg()],
|
|
1081
|
-
[width, (0,
|
|
1081
|
+
[width, (0, NumericValue_js_1.numeric)(0)],
|
|
1082
1082
|
[width.sub(arrowSize), height2],
|
|
1083
|
-
[(0,
|
|
1084
|
-
[(0,
|
|
1083
|
+
[(0, NumericValue_js_1.numeric)(0), height2],
|
|
1084
|
+
[(0, NumericValue_js_1.numeric)(0), height2.neg()],
|
|
1085
1085
|
];
|
|
1086
1086
|
}
|
|
1087
1087
|
else if (portType === PinTypes_js_1.PinTypes.IO) {
|
|
1088
1088
|
path = [
|
|
1089
1089
|
[arrowSize, height2.neg()],
|
|
1090
1090
|
[width.sub(arrowSize), height2.neg()],
|
|
1091
|
-
[width, (0,
|
|
1091
|
+
[width, (0, NumericValue_js_1.numeric)(0)],
|
|
1092
1092
|
[width.sub(arrowSize), height2],
|
|
1093
1093
|
[arrowSize, height2],
|
|
1094
|
-
[(0,
|
|
1094
|
+
[(0, NumericValue_js_1.numeric)(0), (0, NumericValue_js_1.numeric)(0)],
|
|
1095
1095
|
[arrowSize, height2.neg()],
|
|
1096
1096
|
];
|
|
1097
1097
|
}
|
|
@@ -1112,9 +1112,9 @@ class SymbolDrawing {
|
|
|
1112
1112
|
accum = accum.concat(tmp.split(" "));
|
|
1113
1113
|
}
|
|
1114
1114
|
else if (typeof tmp === "number") {
|
|
1115
|
-
accum.push((0,
|
|
1115
|
+
accum.push((0, NumericValue_js_1.numeric)(tmp));
|
|
1116
1116
|
}
|
|
1117
|
-
else if (tmp instanceof
|
|
1117
|
+
else if (tmp instanceof NumericValue_js_1.NumericValue) {
|
|
1118
1118
|
accum.push(tmp);
|
|
1119
1119
|
}
|
|
1120
1120
|
return accum;
|
|
@@ -1191,7 +1191,7 @@ class SymbolDrawing {
|
|
|
1191
1191
|
}
|
|
1192
1192
|
getPaths() {
|
|
1193
1193
|
let currentFill = "#fff";
|
|
1194
|
-
let currentLineWidth = (0,
|
|
1194
|
+
let currentLineWidth = (0, NumericValue_js_1.numeric)(1);
|
|
1195
1195
|
let currentLineColor = '#333';
|
|
1196
1196
|
const pathItems = [];
|
|
1197
1197
|
this.items.forEach(item => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SExpObject = exports._id = exports.IdObject = exports.printTree = exports.generateKiCadNetList = void 0;
|
|
4
4
|
const globals_js_1 = require("../globals.js");
|
|
5
|
-
const
|
|
5
|
+
const NumericValue_js_1 = require("../objects/NumericValue.js");
|
|
6
6
|
function generateKiCadNetList(netlist) {
|
|
7
7
|
const componentsList = [];
|
|
8
8
|
const nets = {};
|
|
@@ -16,7 +16,7 @@ function generateKiCadNetList(netlist) {
|
|
|
16
16
|
];
|
|
17
17
|
if (instance.parameters.has('value')) {
|
|
18
18
|
let value = instance.parameters.get('value');
|
|
19
|
-
if (value instanceof
|
|
19
|
+
if (value instanceof NumericValue_js_1.NumericValue) {
|
|
20
20
|
value = value.value;
|
|
21
21
|
}
|
|
22
22
|
instanceDetails.push([Id('value'), value]);
|
|
@@ -7,9 +7,8 @@ exports.VerticalAlignProp = exports.HorizontalAlignProp = exports.VerticalAlign
|
|
|
7
7
|
const core_1 = __importDefault(require("@flatten-js/core"));
|
|
8
8
|
const sizing_js_1 = require("../sizing.js");
|
|
9
9
|
const globals_js_1 = require("../globals.js");
|
|
10
|
-
const
|
|
10
|
+
const NumericValue_js_1 = require("../objects/NumericValue.js");
|
|
11
11
|
const PinTypes_js_1 = require("../objects/PinTypes.js");
|
|
12
|
-
const utils_js_1 = require("../utils.js");
|
|
13
12
|
class Textbox extends core_1.default.Polygon {
|
|
14
13
|
get box() {
|
|
15
14
|
return this.polygon.box;
|
|
@@ -17,7 +16,7 @@ class Textbox extends core_1.default.Polygon {
|
|
|
17
16
|
constructor(id, text, anchorPoint, polygon, style, bounds, label) {
|
|
18
17
|
super(polygon.vertices);
|
|
19
18
|
this.anchorPoint = [
|
|
20
|
-
(0,
|
|
19
|
+
(0, NumericValue_js_1.numeric)(0), (0, NumericValue_js_1.numeric)(0)
|
|
21
20
|
];
|
|
22
21
|
this.boundingBox = { width: -1, height: -1 };
|
|
23
22
|
this.font = 'default';
|
|
@@ -36,7 +35,7 @@ class Textbox extends core_1.default.Polygon {
|
|
|
36
35
|
useText = text.toString();
|
|
37
36
|
}
|
|
38
37
|
else if (typeof text === 'object'
|
|
39
|
-
&& text instanceof
|
|
38
|
+
&& text instanceof NumericValue_js_1.NumericValue) {
|
|
40
39
|
useText = text.toDisplayString();
|
|
41
40
|
}
|
|
42
41
|
else if (typeof text === 'string') {
|
|
@@ -45,7 +44,7 @@ class Textbox extends core_1.default.Polygon {
|
|
|
45
44
|
else {
|
|
46
45
|
throw 'Invalid string passed into textbox';
|
|
47
46
|
}
|
|
48
|
-
const { fontSize = (0,
|
|
47
|
+
const { fontSize = (0, NumericValue_js_1.numeric)(50), anchor = HorizontalAlign.Left, vanchor = VerticalAlign.Bottom, fontWeight = 'regular', portType = null, } = style ?? {};
|
|
49
48
|
const { box } = (0, sizing_js_1.measureTextSize2)(useText, globals_js_1.defaultFont, fontSize.mul(globals_js_1.fontDisplayScale).toNumber(), fontWeight, anchor, vanchor);
|
|
50
49
|
let polygonCoords = [];
|
|
51
50
|
let anchorOffsetX = 0;
|
|
@@ -111,8 +110,8 @@ class Textbox extends core_1.default.Polygon {
|
|
|
111
110
|
const feature = super.rotate(angle, origin);
|
|
112
111
|
const newAnchorPoint = this.transformAnchorPoint(segment => segment.rotate(angle, origin));
|
|
113
112
|
const tmpAnchorPoint = [
|
|
114
|
-
(0,
|
|
115
|
-
(0,
|
|
113
|
+
(0, NumericValue_js_1.numeric)(newAnchorPoint[0]),
|
|
114
|
+
(0, NumericValue_js_1.numeric)(newAnchorPoint[1])
|
|
116
115
|
];
|
|
117
116
|
return new Textbox(this.id, this.text, tmpAnchorPoint, feature, this.style, this.textMeasurementBounds, this.label);
|
|
118
117
|
}
|
|
@@ -120,8 +119,8 @@ class Textbox extends core_1.default.Polygon {
|
|
|
120
119
|
const feature = super.transform(matrix);
|
|
121
120
|
const newAnchorPoint = this.transformAnchorPoint(segment => segment.transform(matrix));
|
|
122
121
|
const tmpAnchorPoint = [
|
|
123
|
-
(0,
|
|
124
|
-
(0,
|
|
122
|
+
(0, NumericValue_js_1.numeric)(newAnchorPoint[0]),
|
|
123
|
+
(0, NumericValue_js_1.numeric)(newAnchorPoint[1])
|
|
125
124
|
];
|
|
126
125
|
return new Textbox(this.id, this.text, tmpAnchorPoint, feature, this.style, this.textMeasurementBounds, this.label);
|
|
127
126
|
}
|
|
@@ -185,7 +184,7 @@ class Geometry {
|
|
|
185
184
|
static getCoords(item) {
|
|
186
185
|
const points = item.vertices.map(vertex => {
|
|
187
186
|
return [
|
|
188
|
-
(0,
|
|
187
|
+
(0, NumericValue_js_1.numeric)(vertex.x), (0, NumericValue_js_1.numeric)(vertex.y)
|
|
189
188
|
];
|
|
190
189
|
});
|
|
191
190
|
return points;
|
|
@@ -321,8 +320,8 @@ class Geometry {
|
|
|
321
320
|
const existingSegments = [];
|
|
322
321
|
wirePoints.forEach(points => {
|
|
323
322
|
const tmpPoints = points.map(pt => {
|
|
324
|
-
const roundedX = (0,
|
|
325
|
-
const roundedY = (0,
|
|
323
|
+
const roundedX = (0, NumericValue_js_1.roundValue)(pt.x).toNumber();
|
|
324
|
+
const roundedY = (0, NumericValue_js_1.roundValue)(pt.y).toNumber();
|
|
326
325
|
return new core_1.default.Point(roundedX, roundedY);
|
|
327
326
|
});
|
|
328
327
|
for (let i = 0; i < tmpPoints.length - 1; i++) {
|
package/dist/cjs/render/graph.js
CHANGED
|
@@ -31,7 +31,7 @@ const helpers_js_1 = require("../helpers.js");
|
|
|
31
31
|
const layout_js_1 = require("./layout.js");
|
|
32
32
|
const ExecutionScope_js_1 = require("../objects/ExecutionScope.js");
|
|
33
33
|
const Frame_js_1 = require("../objects/Frame.js");
|
|
34
|
-
const
|
|
34
|
+
const NumericValue_js_1 = require("../objects/NumericValue.js");
|
|
35
35
|
const types_js_1 = require("../objects/types.js");
|
|
36
36
|
const ml_matrix_1 = __importStar(require("ml-matrix"));
|
|
37
37
|
const PinDefinition_js_1 = require("../objects/PinDefinition.js");
|
|
@@ -126,7 +126,7 @@ class NetGraph {
|
|
|
126
126
|
useNet = prevNodeItem.net;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
const renderWire = new layout_js_1.RenderWire(useNet, (0,
|
|
129
|
+
const renderWire = new layout_js_1.RenderWire(useNet, (0, NumericValue_js_1.numeric)(0), (0, NumericValue_js_1.numeric)(0), wireSegments, wire);
|
|
130
130
|
renderWire.id = wireId;
|
|
131
131
|
renderWire.netName = useNet.toString();
|
|
132
132
|
const wireName = getWireName(renderWire.id);
|