circuitscript 0.0.28 → 0.0.31
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 +6 -1
- package/dist/cjs/antlr/CircuitScriptLexer.js +204 -200
- package/dist/cjs/antlr/CircuitScriptParser.js +1066 -1173
- package/dist/cjs/draw_symbols.js +383 -103
- package/dist/cjs/execute.js +39 -14
- package/dist/cjs/geometry.js +79 -18
- package/dist/cjs/globals.js +41 -7
- package/dist/cjs/helpers.js +40 -2
- package/dist/cjs/layout.js +72 -39
- package/dist/cjs/main.js +10 -4
- package/dist/cjs/objects/ClassComponent.js +2 -0
- package/dist/cjs/objects/ExecutionScope.js +1 -1
- package/dist/cjs/objects/Net.js +3 -2
- package/dist/cjs/objects/PinTypes.js +7 -1
- package/dist/cjs/objects/types.js +11 -1
- package/dist/cjs/regenerate-tests.js +84 -14
- package/dist/cjs/render.js +22 -15
- package/dist/cjs/sizing.js +4 -6
- package/dist/cjs/utils.js +29 -5
- package/dist/cjs/visitor.js +176 -10
- package/dist/esm/BaseVisitor.mjs +6 -1
- package/dist/esm/antlr/CircuitScriptLexer.mjs +204 -200
- package/dist/esm/antlr/CircuitScriptParser.mjs +1061 -1171
- package/dist/esm/antlr/CircuitScriptVisitor.mjs +3 -0
- package/dist/esm/draw_symbols.mjs +378 -102
- package/dist/esm/execute.mjs +40 -15
- package/dist/esm/geometry.mjs +79 -17
- package/dist/esm/globals.mjs +40 -6
- package/dist/esm/helpers.mjs +38 -1
- package/dist/esm/layout.mjs +75 -42
- package/dist/esm/main.mjs +11 -5
- package/dist/esm/objects/ClassComponent.mjs +6 -0
- package/dist/esm/objects/ExecutionScope.mjs +1 -1
- package/dist/esm/objects/Net.mjs +3 -2
- package/dist/esm/objects/PinTypes.mjs +6 -0
- package/dist/esm/objects/types.mjs +14 -0
- package/dist/esm/regenerate-tests.mjs +85 -15
- package/dist/esm/render.mjs +23 -16
- package/dist/esm/sizing.mjs +3 -4
- package/dist/esm/utils.mjs +26 -4
- package/dist/esm/visitor.mjs +179 -13
- package/dist/types/antlr/CircuitScriptLexer.d.ts +42 -41
- package/dist/types/antlr/CircuitScriptParser.d.ts +144 -133
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +6 -0
- package/dist/types/draw_symbols.d.ts +24 -6
- package/dist/types/execute.d.ts +5 -4
- package/dist/types/geometry.d.ts +5 -3
- package/dist/types/globals.d.ts +38 -6
- package/dist/types/helpers.d.ts +12 -0
- package/dist/types/layout.d.ts +2 -1
- package/dist/types/objects/ClassComponent.d.ts +8 -0
- package/dist/types/objects/PinTypes.d.ts +1 -0
- package/dist/types/objects/Wire.d.ts +4 -2
- package/dist/types/objects/types.d.ts +8 -0
- package/dist/types/sizing.d.ts +0 -4
- package/dist/types/utils.d.ts +3 -0
- package/dist/types/visitor.d.ts +8 -1
- package/fonts/Arial.ttf +0 -0
- package/libs/lib.cst +78 -55
- package/package.json +1 -1
package/dist/cjs/draw_symbols.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SymbolDrawingCommands = exports.SymbolDrawing = exports.SymbolCustom = exports.PlaceHolderCommands = exports.SymbolPlaceholder = exports.SymbolText = exports.SymbolPointHidden = exports.SymbolFactory = exports.SymbolGraphic = void 0;
|
|
3
|
+
exports.SymbolDrawingCommands = exports.SymbolDrawing = exports.SymbolCustomModule = exports.SymbolCustom = exports.PlaceHolderCommands = exports.SymbolPlaceholder = exports.SymbolText = exports.SymbolPointHidden = exports.SymbolFactory = exports.SymbolGraphic = void 0;
|
|
4
|
+
const helpers_js_1 = require("./helpers.js");
|
|
4
5
|
const globals_js_1 = require("./globals.js");
|
|
5
6
|
const geometry_js_1 = require("./geometry.js");
|
|
6
7
|
const PinTypes_js_1 = require("./objects/PinTypes.js");
|
|
7
|
-
const
|
|
8
|
+
const utils_js_1 = require("./utils.js");
|
|
8
9
|
class SymbolGraphic {
|
|
9
10
|
constructor() {
|
|
10
11
|
this.drawPortsName = true;
|
|
11
|
-
this.displayBounds =
|
|
12
|
+
this.displayBounds = false;
|
|
12
13
|
this._angle = 0;
|
|
13
14
|
this._flipX = 0;
|
|
14
15
|
this._flipY = 0;
|
|
@@ -53,6 +54,7 @@ class SymbolGraphic {
|
|
|
53
54
|
this.drawPins(innerGroup);
|
|
54
55
|
this.drawLabels(innerGroup);
|
|
55
56
|
this.drawPlaceRemove(innerGroup, extra);
|
|
57
|
+
this.displayBounds && this.drawBounds(group);
|
|
56
58
|
}
|
|
57
59
|
drawPlaceRemove(group, extra) {
|
|
58
60
|
if (extra && extra.place === false) {
|
|
@@ -63,7 +65,7 @@ class SymbolGraphic {
|
|
|
63
65
|
]);
|
|
64
66
|
group.path(path)
|
|
65
67
|
.stroke({
|
|
66
|
-
width: defaultSymbolLineWidth,
|
|
68
|
+
width: globals_js_1.defaultSymbolLineWidth,
|
|
67
69
|
color: 'red'
|
|
68
70
|
});
|
|
69
71
|
}
|
|
@@ -71,8 +73,8 @@ class SymbolGraphic {
|
|
|
71
73
|
pinPosition(id) {
|
|
72
74
|
const pin = this.drawing.getPinPosition(id);
|
|
73
75
|
const [x, y] = pin.start;
|
|
74
|
-
const useX =
|
|
75
|
-
const useY =
|
|
76
|
+
const useX = (0, utils_js_1.roundValue)(x);
|
|
77
|
+
const useY = (0, utils_js_1.roundValue)(y);
|
|
76
78
|
return {
|
|
77
79
|
x: useX,
|
|
78
80
|
y: useY,
|
|
@@ -81,15 +83,16 @@ class SymbolGraphic {
|
|
|
81
83
|
}
|
|
82
84
|
drawBounds(group) {
|
|
83
85
|
const bbox = this.drawing.getBoundingBox();
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
const originSize = (0, helpers_js_1.milsToMM)(10);
|
|
87
|
+
group.circle(originSize)
|
|
88
|
+
.translate(-originSize / 2, -originSize / 2)
|
|
86
89
|
.fill('red')
|
|
87
90
|
.stroke('none');
|
|
88
91
|
group.rect(bbox.width, bbox.height)
|
|
89
92
|
.translate(bbox.start[0], bbox.start[1])
|
|
90
93
|
.fill('none')
|
|
91
94
|
.stroke({
|
|
92
|
-
width:
|
|
95
|
+
width: (0, helpers_js_1.milsToMM)(2),
|
|
93
96
|
color: '#ccc',
|
|
94
97
|
});
|
|
95
98
|
}
|
|
@@ -106,17 +109,20 @@ class SymbolGraphic {
|
|
|
106
109
|
});
|
|
107
110
|
}
|
|
108
111
|
drawPins(group) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
const pinPaths = this.drawing.getPinsPath();
|
|
113
|
+
pinPaths.forEach(({ path, lineColor }) => {
|
|
114
|
+
group.path(path)
|
|
115
|
+
.stroke({
|
|
116
|
+
width: globals_js_1.defaultSymbolLineWidth,
|
|
117
|
+
color: lineColor
|
|
118
|
+
});
|
|
113
119
|
});
|
|
114
120
|
}
|
|
115
121
|
drawLabels(group) {
|
|
116
122
|
const labels = this.drawing.getLabels();
|
|
117
123
|
labels.forEach(label => {
|
|
118
124
|
const tmpLabel = label;
|
|
119
|
-
const { fontSize =
|
|
125
|
+
const { fontSize = 50, anchor = geometry_js_1.HorizontalAlign.Left, vanchor = geometry_js_1.VerticalAlign.Bottom, fontWeight = 'regular', angle: labelAngle = 0, textColor = "#333", } = tmpLabel.style ?? {};
|
|
120
126
|
let anchorStyle = 'start';
|
|
121
127
|
let dominantBaseline = 'auto';
|
|
122
128
|
let useAnchor = anchor;
|
|
@@ -157,15 +163,6 @@ class SymbolGraphic {
|
|
|
157
163
|
}
|
|
158
164
|
const useFont = globals_js_1.defaultFont;
|
|
159
165
|
const textContainer = group.group();
|
|
160
|
-
const text = textContainer.text(tmpLabel.text)
|
|
161
|
-
.fill('#333')
|
|
162
|
-
.font({
|
|
163
|
-
family: useFont,
|
|
164
|
-
size: fontSize,
|
|
165
|
-
anchor: anchorStyle,
|
|
166
|
-
'dominant-baseline': dominantBaseline,
|
|
167
|
-
weight: fontWeight,
|
|
168
|
-
});
|
|
169
166
|
let translateX, translateY;
|
|
170
167
|
let useRotateAngle = 0;
|
|
171
168
|
if (isRotation180) {
|
|
@@ -178,26 +175,121 @@ class SymbolGraphic {
|
|
|
178
175
|
translateY = position[1];
|
|
179
176
|
useRotateAngle = this.angle;
|
|
180
177
|
}
|
|
181
|
-
translateX =
|
|
182
|
-
translateY =
|
|
183
|
-
|
|
178
|
+
translateX = (0, utils_js_1.roundValue)(translateX);
|
|
179
|
+
translateY = (0, utils_js_1.roundValue)(translateY);
|
|
180
|
+
const { portType = null } = tmpLabel.style;
|
|
181
|
+
if (portType !== null) {
|
|
182
|
+
const { x: boundsX, y: boundsY } = tmpLabel.textMeasurementBounds;
|
|
183
|
+
const paddingHorizontal = globals_js_1.PortPaddingHorizontal;
|
|
184
|
+
const paddingVert = globals_js_1.PortPaddingVertical;
|
|
185
|
+
const boundsWidth = tmpLabel.textMeasurementBounds.width
|
|
186
|
+
+ paddingHorizontal * 2;
|
|
187
|
+
const boundsHeight = tmpLabel.textMeasurementBounds.height
|
|
188
|
+
+ paddingVert * 2;
|
|
189
|
+
let path = [];
|
|
190
|
+
let boundsTranslateX = -paddingHorizontal;
|
|
191
|
+
switch (portType) {
|
|
192
|
+
case PinTypes_js_1.PinTypes.Input:
|
|
193
|
+
path = ['M', 0, 0,
|
|
194
|
+
'L', boundsWidth, 0,
|
|
195
|
+
'L', boundsWidth, boundsHeight,
|
|
196
|
+
'L', 0, boundsHeight,
|
|
197
|
+
'L', -globals_js_1.PortArrowSize, boundsHeight / 2,
|
|
198
|
+
'Z',
|
|
199
|
+
];
|
|
200
|
+
break;
|
|
201
|
+
case PinTypes_js_1.PinTypes.Output:
|
|
202
|
+
path = ['M', 0, 0,
|
|
203
|
+
'L', boundsWidth, 0,
|
|
204
|
+
'L', boundsWidth + globals_js_1.PortArrowSize,
|
|
205
|
+
boundsHeight / 2,
|
|
206
|
+
'L', boundsWidth, boundsHeight,
|
|
207
|
+
'L', 0, boundsHeight,
|
|
208
|
+
'Z',
|
|
209
|
+
];
|
|
210
|
+
break;
|
|
211
|
+
case PinTypes_js_1.PinTypes.IO:
|
|
212
|
+
path = ['M', 0, 0,
|
|
213
|
+
'L', boundsWidth, 0,
|
|
214
|
+
'L', boundsWidth + globals_js_1.PortArrowSize,
|
|
215
|
+
boundsHeight / 2,
|
|
216
|
+
'L', boundsWidth, boundsHeight,
|
|
217
|
+
'L', 0, boundsHeight,
|
|
218
|
+
'L', -globals_js_1.PortArrowSize, boundsHeight / 2,
|
|
219
|
+
'Z',
|
|
220
|
+
];
|
|
221
|
+
break;
|
|
222
|
+
case PinTypes_js_1.PinTypes.Any:
|
|
223
|
+
case PinTypes_js_1.PinTypes.Power:
|
|
224
|
+
path = ['M', 0, 0,
|
|
225
|
+
'L', boundsWidth, 0,
|
|
226
|
+
'L', boundsWidth, boundsHeight,
|
|
227
|
+
'L', 0, boundsHeight,
|
|
228
|
+
'Z',
|
|
229
|
+
];
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
if (path.length > 0) {
|
|
233
|
+
let flip = 1;
|
|
234
|
+
if (this.flipX !== 0) {
|
|
235
|
+
flip = -1;
|
|
236
|
+
boundsTranslateX = paddingHorizontal;
|
|
237
|
+
}
|
|
238
|
+
textContainer.path(path)
|
|
239
|
+
.stroke({
|
|
240
|
+
width: (0, helpers_js_1.milsToMM)(5),
|
|
241
|
+
color: '#333'
|
|
242
|
+
})
|
|
243
|
+
.fill('none')
|
|
244
|
+
.scale(flip, 1, 0, 0)
|
|
245
|
+
.translate(boundsTranslateX, boundsY - paddingVert);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const drawTextBounds = false;
|
|
249
|
+
const drawBoxBounds = false;
|
|
250
|
+
const drawOrigin = false;
|
|
251
|
+
if (drawBoxBounds) {
|
|
252
|
+
const box = tmpLabel.box;
|
|
253
|
+
textContainer.rect(box.width, box.height).fill('red')
|
|
254
|
+
.translate(box.xmin, box.ymin)
|
|
255
|
+
.scale(this.flipX !== 0 ? -1 : 1, 1, -box.xmin, box.ymin);
|
|
256
|
+
}
|
|
257
|
+
if (drawTextBounds) {
|
|
258
|
+
const textBounds = tmpLabel.textMeasurementBounds;
|
|
259
|
+
const xOffset = (this.flipX !== 0) ? textBounds.width : 0;
|
|
260
|
+
textContainer.rect(textBounds.width, textBounds.height).fill('#cccccc')
|
|
261
|
+
.translate(textBounds.x - xOffset, textBounds.y);
|
|
262
|
+
}
|
|
184
263
|
textContainer.translate(translateX, translateY)
|
|
185
264
|
.rotate(useRotateAngle, -translateX, -translateY);
|
|
265
|
+
textContainer.text(tmpLabel.text)
|
|
266
|
+
.fill(textColor)
|
|
267
|
+
.font({
|
|
268
|
+
family: useFont,
|
|
269
|
+
size: fontSize * globals_js_1.fontDisplayScale,
|
|
270
|
+
anchor: anchorStyle,
|
|
271
|
+
'dominant-baseline': dominantBaseline,
|
|
272
|
+
weight: fontWeight,
|
|
273
|
+
})
|
|
274
|
+
.rotate(labelAngle);
|
|
186
275
|
const { a, b, c, d, e, f } = textContainer.matrix();
|
|
187
276
|
const newMatrix = {
|
|
188
|
-
a:
|
|
189
|
-
b:
|
|
190
|
-
c:
|
|
191
|
-
d:
|
|
192
|
-
e:
|
|
193
|
-
f:
|
|
277
|
+
a: (0, utils_js_1.roundValue)(a),
|
|
278
|
+
b: (0, utils_js_1.roundValue)(b),
|
|
279
|
+
c: (0, utils_js_1.roundValue)(c),
|
|
280
|
+
d: (0, utils_js_1.roundValue)(d),
|
|
281
|
+
e: (0, utils_js_1.roundValue)(e),
|
|
282
|
+
f: (0, utils_js_1.roundValue)(f),
|
|
194
283
|
};
|
|
195
284
|
textContainer.transform(newMatrix);
|
|
285
|
+
if (drawOrigin) {
|
|
286
|
+
const originSize = (0, helpers_js_1.milsToMM)(10);
|
|
287
|
+
textContainer.circle(originSize)
|
|
288
|
+
.translate(originSize / 2, originSize / 2)
|
|
289
|
+
.fill('green');
|
|
290
|
+
}
|
|
196
291
|
});
|
|
197
292
|
}
|
|
198
|
-
roundValues(value) {
|
|
199
|
-
return +value.toFixed(7);
|
|
200
|
-
}
|
|
201
293
|
flipTextAnchor(value) {
|
|
202
294
|
if (value === geometry_js_1.HorizontalAlign.Left) {
|
|
203
295
|
return geometry_js_1.HorizontalAlign.Right;
|
|
@@ -250,7 +342,7 @@ exports.SymbolPointHidden = SymbolPointHidden;
|
|
|
250
342
|
class SymbolText extends SymbolGraphic {
|
|
251
343
|
constructor(text) {
|
|
252
344
|
super();
|
|
253
|
-
this.fontSize =
|
|
345
|
+
this.fontSize = 40;
|
|
254
346
|
this.fontWeight = 'regular';
|
|
255
347
|
this.text = text;
|
|
256
348
|
}
|
|
@@ -273,8 +365,16 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
273
365
|
drawing.angle = this._angle;
|
|
274
366
|
drawing.flipX = this._flipX;
|
|
275
367
|
drawing.flipY = this._flipY;
|
|
276
|
-
const commands =
|
|
368
|
+
const commands = [
|
|
369
|
+
[PlaceHolderCommands.units, ['mils'], {}],
|
|
370
|
+
[PlaceHolderCommands.lineColor, [globals_js_1.ColorScheme.PinLineColor], {}],
|
|
371
|
+
[PlaceHolderCommands.textColor, [globals_js_1.ColorScheme.PinNameColor], {}],
|
|
372
|
+
[PlaceHolderCommands.lineWidth, [5], {}],
|
|
373
|
+
...drawing.getCommands()
|
|
374
|
+
];
|
|
277
375
|
drawing.log('id: ', drawing.id, 'angle: ', this._angle, "commands:", commands.length);
|
|
376
|
+
let lineColor = "#333";
|
|
377
|
+
let textColor = "#333";
|
|
278
378
|
commands.forEach(([commandName, positionParams, keywordParams]) => {
|
|
279
379
|
switch (commandName) {
|
|
280
380
|
case PlaceHolderCommands.rect:
|
|
@@ -304,6 +404,11 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
304
404
|
break;
|
|
305
405
|
case PlaceHolderCommands.lineColor:
|
|
306
406
|
drawing.addSetLineColor(...positionParams);
|
|
407
|
+
lineColor = positionParams[0];
|
|
408
|
+
break;
|
|
409
|
+
case PlaceHolderCommands.textColor:
|
|
410
|
+
drawing.addSetTextColor(...positionParams);
|
|
411
|
+
textColor = positionParams[0];
|
|
307
412
|
break;
|
|
308
413
|
case PlaceHolderCommands.arc:
|
|
309
414
|
drawing.addArc(...positionParams);
|
|
@@ -318,11 +423,14 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
318
423
|
case PlaceHolderCommands.hpin:
|
|
319
424
|
case PlaceHolderCommands.vpin:
|
|
320
425
|
{
|
|
321
|
-
this.drawPinParams(drawing, commandName, keywordParams, positionParams);
|
|
426
|
+
this.drawPinParams(drawing, commandName, keywordParams, positionParams, lineColor, textColor);
|
|
322
427
|
break;
|
|
323
428
|
}
|
|
324
429
|
case PlaceHolderCommands.label: {
|
|
325
430
|
const style = this.parseLabelStyle(keywordParams);
|
|
431
|
+
if (style['textColor'] === undefined) {
|
|
432
|
+
style['textColor'] = textColor;
|
|
433
|
+
}
|
|
326
434
|
positionParams = [...positionParams];
|
|
327
435
|
positionParams.push(style);
|
|
328
436
|
const labelId = positionParams[0];
|
|
@@ -348,12 +456,17 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
348
456
|
drawing.addTextbox(offsetX, offsetY, content, style);
|
|
349
457
|
break;
|
|
350
458
|
}
|
|
459
|
+
case PlaceHolderCommands.units: {
|
|
460
|
+
drawing.addSetUnits(...positionParams);
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
351
463
|
}
|
|
352
464
|
});
|
|
353
465
|
drawing.log("=== end generate drawing ===");
|
|
354
466
|
}
|
|
355
467
|
parseLabelStyle(keywordParams) {
|
|
356
|
-
const keywords = ['fontSize', 'anchor', 'vanchor',
|
|
468
|
+
const keywords = ['fontSize', 'anchor', 'vanchor',
|
|
469
|
+
'angle', 'textColor', 'portType'];
|
|
357
470
|
const style = {};
|
|
358
471
|
keywords.forEach(item => {
|
|
359
472
|
if (keywordParams.has(item)) {
|
|
@@ -362,13 +475,16 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
362
475
|
});
|
|
363
476
|
return style;
|
|
364
477
|
}
|
|
365
|
-
drawPinParams(drawing, commandName, keywordParams, positionParams) {
|
|
478
|
+
drawPinParams(drawing, commandName, keywordParams, positionParams, lineColor, pinNameColor) {
|
|
366
479
|
drawing.log('add pin', ...positionParams);
|
|
480
|
+
positionParams = [...positionParams];
|
|
367
481
|
const keywordDisplayPinId = 'display_pin_id';
|
|
368
482
|
let displayPinId = true;
|
|
369
|
-
if (keywordParams.has(keywordDisplayPinId)
|
|
370
|
-
|
|
371
|
-
|
|
483
|
+
if (keywordParams.has(keywordDisplayPinId)) {
|
|
484
|
+
const value = keywordParams.get(keywordDisplayPinId);
|
|
485
|
+
if (value === 0 || value === false) {
|
|
486
|
+
displayPinId = false;
|
|
487
|
+
}
|
|
372
488
|
}
|
|
373
489
|
let pinNameParam = null;
|
|
374
490
|
let pinType = PinTypes_js_1.PinTypes.Any;
|
|
@@ -380,10 +496,10 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
380
496
|
pinNameParam = positionParams[1];
|
|
381
497
|
positionParams = [positionParams[0], ...positionParams.slice(2)];
|
|
382
498
|
}
|
|
383
|
-
const startX = positionParams[1];
|
|
384
|
-
const startY = positionParams[2];
|
|
499
|
+
const startX = (0, helpers_js_1.milsToMM)(positionParams[1]);
|
|
500
|
+
const startY = (0, helpers_js_1.milsToMM)(positionParams[2]);
|
|
385
501
|
if (commandName === PlaceHolderCommands.vpin) {
|
|
386
|
-
const magnitude = positionParams[3];
|
|
502
|
+
const magnitude = (0, helpers_js_1.milsToMM)(positionParams[3]);
|
|
387
503
|
positionParams = [
|
|
388
504
|
positionParams[0],
|
|
389
505
|
startX,
|
|
@@ -393,7 +509,7 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
393
509
|
];
|
|
394
510
|
}
|
|
395
511
|
else if (commandName === PlaceHolderCommands.hpin) {
|
|
396
|
-
const magnitude = positionParams[3];
|
|
512
|
+
const magnitude = (0, helpers_js_1.milsToMM)(positionParams[3]);
|
|
397
513
|
positionParams = [
|
|
398
514
|
positionParams[0],
|
|
399
515
|
startX,
|
|
@@ -402,50 +518,64 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
402
518
|
startY
|
|
403
519
|
];
|
|
404
520
|
}
|
|
405
|
-
|
|
521
|
+
else {
|
|
522
|
+
const [, , , endX, endY] = positionParams;
|
|
523
|
+
positionParams = [
|
|
524
|
+
positionParams[0],
|
|
525
|
+
startX,
|
|
526
|
+
startY,
|
|
527
|
+
(0, helpers_js_1.milsToMM)(endX),
|
|
528
|
+
(0, helpers_js_1.milsToMM)(endY)
|
|
529
|
+
];
|
|
530
|
+
}
|
|
531
|
+
drawing.addPinMM(...positionParams, lineColor);
|
|
406
532
|
const lastAddedPin = this.drawing.pins[this.drawing.pins.length - 1];
|
|
407
533
|
const [pinId, , angle] = lastAddedPin;
|
|
408
534
|
const [, , , endX, endY] = positionParams;
|
|
409
535
|
let pinNameAlignment = geometry_js_1.HorizontalAlign.Left;
|
|
410
|
-
|
|
536
|
+
const offset1 = 15;
|
|
537
|
+
const offset2 = 15;
|
|
538
|
+
let pinNameOffsetX = (0, helpers_js_1.milsToMM)(offset1);
|
|
411
539
|
let pinIdOffsetX = 0;
|
|
412
540
|
let pinIdAlignment = geometry_js_1.HorizontalAlign.Left;
|
|
413
541
|
let pinIdVAlignment = geometry_js_1.VerticalAlign.Bottom;
|
|
414
|
-
let pinIdOffsetY = -
|
|
542
|
+
let pinIdOffsetY = (0, helpers_js_1.milsToMM)(-offset2);
|
|
415
543
|
switch (angle) {
|
|
416
544
|
case 0:
|
|
417
545
|
pinNameAlignment = geometry_js_1.HorizontalAlign.Left;
|
|
418
|
-
pinNameOffsetX =
|
|
546
|
+
pinNameOffsetX = (0, helpers_js_1.milsToMM)(offset1);
|
|
419
547
|
pinIdAlignment = geometry_js_1.HorizontalAlign.Right;
|
|
420
|
-
pinIdOffsetX = -
|
|
548
|
+
pinIdOffsetX = (0, helpers_js_1.milsToMM)(-offset2);
|
|
421
549
|
break;
|
|
422
550
|
case 90:
|
|
423
551
|
case 180:
|
|
424
552
|
pinNameAlignment = geometry_js_1.HorizontalAlign.Right;
|
|
425
|
-
pinNameOffsetX = -
|
|
553
|
+
pinNameOffsetX = (0, helpers_js_1.milsToMM)(-offset1);
|
|
426
554
|
pinIdAlignment = geometry_js_1.HorizontalAlign.Left;
|
|
427
|
-
pinIdOffsetX =
|
|
555
|
+
pinIdOffsetX = (0, helpers_js_1.milsToMM)(offset2);
|
|
428
556
|
break;
|
|
429
557
|
case 270:
|
|
430
558
|
pinNameAlignment = geometry_js_1.HorizontalAlign.Left;
|
|
431
|
-
pinNameOffsetX =
|
|
559
|
+
pinNameOffsetX = (0, helpers_js_1.milsToMM)(offset1);
|
|
432
560
|
pinIdAlignment = geometry_js_1.HorizontalAlign.Left;
|
|
433
|
-
pinIdOffsetX =
|
|
434
|
-
pinIdOffsetY =
|
|
561
|
+
pinIdOffsetX = (0, helpers_js_1.milsToMM)(offset2);
|
|
562
|
+
pinIdOffsetY = (0, helpers_js_1.milsToMM)(offset2);
|
|
435
563
|
pinIdVAlignment = geometry_js_1.VerticalAlign.Top;
|
|
436
564
|
break;
|
|
437
565
|
}
|
|
438
566
|
if (angle === 0 || angle === 90 || angle === 180 || angle === 270) {
|
|
439
567
|
const usePinName = pinNameParam ?? "";
|
|
440
568
|
usePinName !== "" && drawing.addLabel(endX + pinNameOffsetX, endY, usePinName, {
|
|
441
|
-
fontSize:
|
|
569
|
+
fontSize: globals_js_1.defaultPinNameTextSize,
|
|
442
570
|
anchor: pinNameAlignment,
|
|
443
571
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
572
|
+
textColor: pinNameColor,
|
|
444
573
|
});
|
|
445
574
|
displayPinId && drawing.addLabel(endX + pinIdOffsetX, endY + pinIdOffsetY, pinId.toString(), {
|
|
446
|
-
fontSize:
|
|
575
|
+
fontSize: globals_js_1.defaultPinIdTextSize,
|
|
447
576
|
anchor: pinIdAlignment,
|
|
448
577
|
vanchor: pinIdVAlignment,
|
|
578
|
+
textColor: lineColor
|
|
449
579
|
});
|
|
450
580
|
}
|
|
451
581
|
}
|
|
@@ -472,18 +602,20 @@ var PlaceHolderCommands;
|
|
|
472
602
|
PlaceHolderCommands["lineWidth"] = "lineWidth";
|
|
473
603
|
PlaceHolderCommands["fill"] = "fill";
|
|
474
604
|
PlaceHolderCommands["lineColor"] = "lineColor";
|
|
605
|
+
PlaceHolderCommands["textColor"] = "textColor";
|
|
475
606
|
PlaceHolderCommands["text"] = "text";
|
|
607
|
+
PlaceHolderCommands["units"] = "units";
|
|
476
608
|
})(PlaceHolderCommands || (exports.PlaceHolderCommands = PlaceHolderCommands = {}));
|
|
477
609
|
class SymbolCustom extends SymbolGraphic {
|
|
478
610
|
constructor(pinDefinition) {
|
|
479
611
|
super();
|
|
480
612
|
this.pinDefinition = [];
|
|
481
|
-
this.bodyWidth =
|
|
482
|
-
this.pinLength =
|
|
483
|
-
this.width = 100;
|
|
484
|
-
this.height = 100;
|
|
485
|
-
this.pinSpacing =
|
|
486
|
-
this.pinTextPadding = 5;
|
|
613
|
+
this.bodyWidth = (0, helpers_js_1.milsToMM)(400);
|
|
614
|
+
this.pinLength = (0, helpers_js_1.milsToMM)(100);
|
|
615
|
+
this.width = (0, helpers_js_1.milsToMM)(100);
|
|
616
|
+
this.height = (0, helpers_js_1.milsToMM)(100);
|
|
617
|
+
this.pinSpacing = (0, helpers_js_1.milsToMM)(100);
|
|
618
|
+
this.pinTextPadding = (0, helpers_js_1.milsToMM)(5);
|
|
487
619
|
this.pins = [];
|
|
488
620
|
this.pinDefinition = pinDefinition;
|
|
489
621
|
}
|
|
@@ -502,59 +634,69 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
502
634
|
drawing.flipY = this._flipY;
|
|
503
635
|
const bodyWidth = this.bodyWidth;
|
|
504
636
|
const bodyHeight = (1 + Math.max(maxLeftPins, maxRightPins)) * this.pinSpacing;
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
637
|
+
const defaultLineColor = globals_js_1.ColorScheme.PinLineColor;
|
|
638
|
+
drawing.addSetLineColor(defaultLineColor);
|
|
639
|
+
drawing.addSetLineWidth(5);
|
|
640
|
+
drawing.addRectMM(0, 0, bodyWidth, bodyHeight);
|
|
641
|
+
this.generateDrawingPins(drawing, bodyWidth, bodyHeight, leftPins, rightPins, defaultLineColor);
|
|
642
|
+
this.drawing = drawing;
|
|
643
|
+
this._cacheLeftPins = leftPins;
|
|
644
|
+
this._cacheRightPins = rightPins;
|
|
645
|
+
}
|
|
646
|
+
generateDrawingPins(drawing, bodyWidthMM, bodyHeightMM, leftPins, rightPins, defaultLineColor) {
|
|
647
|
+
const leftPinStart = -bodyWidthMM / 2;
|
|
648
|
+
const rightPinStart = bodyWidthMM / 2;
|
|
649
|
+
const pinStartY = -bodyHeightMM / 2;
|
|
509
650
|
leftPins.forEach(pin => {
|
|
510
651
|
const position = pin.position;
|
|
511
652
|
const pinY = pinStartY + (position + 1) * this.pinSpacing;
|
|
512
|
-
drawing.
|
|
513
|
-
drawing.addLabel(leftPinStart +
|
|
514
|
-
fontSize:
|
|
653
|
+
drawing.addPinMM(pin.pinId, leftPinStart - this.pinLength, pinY, leftPinStart, pinY, defaultLineColor);
|
|
654
|
+
drawing.addLabel(leftPinStart + (0, helpers_js_1.milsToMM)(20), pinY, pin.text, {
|
|
655
|
+
fontSize: globals_js_1.CustomSymbolPinTextSize,
|
|
515
656
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
516
657
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
658
|
+
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
517
659
|
});
|
|
518
|
-
drawing.addLabel(leftPinStart -
|
|
519
|
-
fontSize:
|
|
660
|
+
drawing.addLabel(leftPinStart - (0, helpers_js_1.milsToMM)(10), pinY - (0, helpers_js_1.milsToMM)(10), pin.pinId.toString(), {
|
|
661
|
+
fontSize: globals_js_1.CustomSymbolPinIdSize,
|
|
520
662
|
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
521
663
|
vanchor: geometry_js_1.VerticalAlign.Bottom,
|
|
664
|
+
textColor: defaultLineColor
|
|
522
665
|
});
|
|
523
666
|
});
|
|
524
667
|
rightPins.forEach(pin => {
|
|
525
668
|
const position = pin.position;
|
|
526
669
|
const pinY = pinStartY + (position + 1) * this.pinSpacing;
|
|
527
|
-
drawing.
|
|
528
|
-
drawing.addLabel(rightPinStart -
|
|
529
|
-
fontSize:
|
|
670
|
+
drawing.addPinMM(pin.pinId, rightPinStart + this.pinLength, pinY, rightPinStart, pinY, defaultLineColor);
|
|
671
|
+
drawing.addLabel(rightPinStart - (0, helpers_js_1.milsToMM)(20), pinY, pin.text, {
|
|
672
|
+
fontSize: globals_js_1.CustomSymbolPinTextSize,
|
|
530
673
|
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
531
674
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
675
|
+
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
532
676
|
});
|
|
533
|
-
drawing.addLabel(rightPinStart +
|
|
534
|
-
fontSize:
|
|
677
|
+
drawing.addLabel(rightPinStart + (0, helpers_js_1.milsToMM)(10), pinY - (0, helpers_js_1.milsToMM)(10), pin.pinId.toString(), {
|
|
678
|
+
fontSize: globals_js_1.CustomSymbolPinIdSize,
|
|
535
679
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
536
680
|
vanchor: geometry_js_1.VerticalAlign.Bottom,
|
|
681
|
+
textColor: defaultLineColor
|
|
537
682
|
});
|
|
538
683
|
});
|
|
539
684
|
const instanceName = this.getLabelValue("refdes");
|
|
540
|
-
instanceName && drawing.addLabel(-
|
|
541
|
-
fontSize:
|
|
685
|
+
instanceName && drawing.addLabel(-bodyWidthMM / 2, -bodyHeightMM / 2 - (0, helpers_js_1.milsToMM)(20), instanceName, {
|
|
686
|
+
fontSize: globals_js_1.CustomSymbolRefDesSize,
|
|
542
687
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
543
688
|
});
|
|
544
689
|
const acceptedMPNKeys = ['MPN', 'mpn', 'manufacturer_pn'];
|
|
545
690
|
acceptedMPNKeys.some(key => {
|
|
546
691
|
const labelValue = this.getLabelValue(key);
|
|
547
692
|
if (labelValue !== undefined) {
|
|
548
|
-
drawing.addLabel(-
|
|
549
|
-
fontSize:
|
|
693
|
+
drawing.addLabel(-bodyWidthMM / 2, bodyHeightMM / 2 + (0, helpers_js_1.milsToMM)(20), labelValue, {
|
|
694
|
+
fontSize: globals_js_1.CustomSymbolParamTextSize,
|
|
550
695
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
551
696
|
vanchor: geometry_js_1.VerticalAlign.Top,
|
|
552
697
|
});
|
|
553
698
|
}
|
|
554
699
|
});
|
|
555
|
-
this.drawing = drawing;
|
|
556
|
-
this._cacheLeftPins = leftPins;
|
|
557
|
-
this._cacheRightPins = rightPins;
|
|
558
700
|
}
|
|
559
701
|
calculateSize() {
|
|
560
702
|
this.width = this.bodyWidth + 2 * this.pinLength;
|
|
@@ -562,6 +704,44 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
562
704
|
}
|
|
563
705
|
}
|
|
564
706
|
exports.SymbolCustom = SymbolCustom;
|
|
707
|
+
class SymbolCustomModule extends SymbolCustom {
|
|
708
|
+
constructor() {
|
|
709
|
+
super(...arguments);
|
|
710
|
+
this.pinLength = 0;
|
|
711
|
+
this.portWidth = (0, helpers_js_1.milsToMM)(100);
|
|
712
|
+
this.portHeight = (0, helpers_js_1.milsToMM)(50);
|
|
713
|
+
}
|
|
714
|
+
generateDrawingPins(drawing, bodyWidthMM, bodyHeightMM, leftPins, rightPins, defaultLineColor) {
|
|
715
|
+
const leftPinStart = -bodyWidthMM / 2;
|
|
716
|
+
const rightPinStart = bodyWidthMM / 2;
|
|
717
|
+
const pinStartY = -bodyHeightMM / 2;
|
|
718
|
+
leftPins.forEach(pin => {
|
|
719
|
+
const position = pin.position;
|
|
720
|
+
const pinY = pinStartY + (position + 1) * this.pinSpacing;
|
|
721
|
+
drawing.addPinMM(pin.pinId, leftPinStart - this.pinLength, pinY, leftPinStart, pinY, defaultLineColor);
|
|
722
|
+
drawing.addModulePort(leftPinStart, pinY, this.portWidth, this.portHeight, pin.pinType);
|
|
723
|
+
drawing.addLabel(leftPinStart + this.portWidth + (0, helpers_js_1.milsToMM)(20), pinY, pin.text, {
|
|
724
|
+
fontSize: 40,
|
|
725
|
+
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
726
|
+
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
727
|
+
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
728
|
+
});
|
|
729
|
+
});
|
|
730
|
+
rightPins.forEach(pin => {
|
|
731
|
+
const position = pin.position;
|
|
732
|
+
const pinY = pinStartY + (position + 1) * this.pinSpacing;
|
|
733
|
+
drawing.addPinMM(pin.pinId, rightPinStart + this.pinLength, pinY, rightPinStart, pinY, defaultLineColor);
|
|
734
|
+
drawing.addModulePort(rightPinStart, pinY, this.portWidth, this.portHeight, pin.pinType, -1);
|
|
735
|
+
drawing.addLabel(rightPinStart - this.portWidth - (0, helpers_js_1.milsToMM)(20), pinY, pin.text, {
|
|
736
|
+
fontSize: 40,
|
|
737
|
+
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
738
|
+
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
739
|
+
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
740
|
+
});
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
exports.SymbolCustomModule = SymbolCustomModule;
|
|
565
745
|
class SymbolDrawing {
|
|
566
746
|
constructor() {
|
|
567
747
|
this.items = [];
|
|
@@ -580,43 +760,68 @@ class SymbolDrawing {
|
|
|
580
760
|
this.logger && this.logger.add(params.join(' '));
|
|
581
761
|
}
|
|
582
762
|
addLine(startX, startY, endX, endY) {
|
|
763
|
+
startX = (0, helpers_js_1.milsToMM)(startX);
|
|
764
|
+
startY = (0, helpers_js_1.milsToMM)(startY);
|
|
765
|
+
endX = (0, helpers_js_1.milsToMM)(endX);
|
|
766
|
+
endY = (0, helpers_js_1.milsToMM)(endY);
|
|
583
767
|
this.items.push(geometry_js_1.Geometry.segment([startX, startY], [endX, endY]));
|
|
584
768
|
return this;
|
|
585
769
|
}
|
|
586
|
-
addPin(pinId, startX, startY, endX, endY) {
|
|
770
|
+
addPin(pinId, startX, startY, endX, endY, lineColor) {
|
|
771
|
+
startX = (0, helpers_js_1.milsToMM)(startX);
|
|
772
|
+
startY = (0, helpers_js_1.milsToMM)(startY);
|
|
773
|
+
endX = (0, helpers_js_1.milsToMM)(endX);
|
|
774
|
+
endY = (0, helpers_js_1.milsToMM)(endY);
|
|
775
|
+
return this.addPinMM(pinId, startX, startY, endX, endY, lineColor);
|
|
776
|
+
}
|
|
777
|
+
addPinMM(pinId, startXMM, startYMM, endXMM, endYMM, lineColor) {
|
|
587
778
|
let angle = 0;
|
|
588
|
-
if (
|
|
589
|
-
if (
|
|
779
|
+
if (startXMM === endXMM) {
|
|
780
|
+
if (startYMM > endYMM) {
|
|
590
781
|
angle = 270;
|
|
591
782
|
}
|
|
592
|
-
else if (
|
|
783
|
+
else if (startYMM < endYMM) {
|
|
593
784
|
angle = 90;
|
|
594
785
|
}
|
|
595
786
|
}
|
|
596
787
|
else {
|
|
597
|
-
if (
|
|
788
|
+
if (startXMM < endXMM) {
|
|
598
789
|
angle = 0;
|
|
599
790
|
}
|
|
600
|
-
else if (
|
|
791
|
+
else if (startXMM > endXMM) {
|
|
601
792
|
angle = 180;
|
|
602
793
|
}
|
|
603
794
|
}
|
|
604
795
|
this.pins.push([
|
|
605
796
|
pinId,
|
|
606
|
-
geometry_js_1.Geometry.segment([
|
|
607
|
-
angle
|
|
797
|
+
geometry_js_1.Geometry.segment([startXMM, startYMM], [endXMM, endYMM]),
|
|
798
|
+
angle,
|
|
799
|
+
lineColor
|
|
608
800
|
]);
|
|
609
801
|
return this;
|
|
610
802
|
}
|
|
611
803
|
addVLine(startX, startY, value) {
|
|
804
|
+
startX = (0, helpers_js_1.milsToMM)(startX);
|
|
805
|
+
startY = (0, helpers_js_1.milsToMM)(startY);
|
|
806
|
+
value = (0, helpers_js_1.milsToMM)(value);
|
|
612
807
|
this.items.push(geometry_js_1.Geometry.segment([startX, startY], [startX, startY + value]));
|
|
613
808
|
return this;
|
|
614
809
|
}
|
|
615
810
|
addHLine(startX, startY, value) {
|
|
811
|
+
startX = (0, helpers_js_1.milsToMM)(startX);
|
|
812
|
+
startY = (0, helpers_js_1.milsToMM)(startY);
|
|
813
|
+
value = (0, helpers_js_1.milsToMM)(value);
|
|
616
814
|
this.items.push(geometry_js_1.Geometry.segment([startX, startY], [startX + value, startY]));
|
|
617
815
|
return this;
|
|
618
816
|
}
|
|
619
817
|
addRect(centerX, centerY, width, height) {
|
|
818
|
+
centerX = (0, helpers_js_1.milsToMM)(centerX);
|
|
819
|
+
centerY = (0, helpers_js_1.milsToMM)(centerY);
|
|
820
|
+
width = (0, helpers_js_1.milsToMM)(width);
|
|
821
|
+
height = (0, helpers_js_1.milsToMM)(height);
|
|
822
|
+
return this.addRectMM(centerX, centerY, width, height);
|
|
823
|
+
}
|
|
824
|
+
addRectMM(centerX, centerY, width, height) {
|
|
620
825
|
const width2 = width / 2;
|
|
621
826
|
const height2 = height / 2;
|
|
622
827
|
this.items.push(geometry_js_1.Geometry.polygon([
|
|
@@ -629,6 +834,11 @@ class SymbolDrawing {
|
|
|
629
834
|
return this;
|
|
630
835
|
}
|
|
631
836
|
addTriangle(startX, startY, endX, endY, width) {
|
|
837
|
+
startX = (0, helpers_js_1.milsToMM)(startX);
|
|
838
|
+
startY = (0, helpers_js_1.milsToMM)(startY);
|
|
839
|
+
endX = (0, helpers_js_1.milsToMM)(endX);
|
|
840
|
+
endY = (0, helpers_js_1.milsToMM)(endY);
|
|
841
|
+
width = (0, helpers_js_1.milsToMM)(width);
|
|
632
842
|
const line = geometry_js_1.Geometry.line(startX, startY, endX, endY);
|
|
633
843
|
const normLine = line.norm;
|
|
634
844
|
const dx1 = normLine.x * width / 2;
|
|
@@ -658,13 +868,67 @@ class SymbolDrawing {
|
|
|
658
868
|
return this;
|
|
659
869
|
}
|
|
660
870
|
addLabelId(id, x, y, textValue, style) {
|
|
871
|
+
x = (0, helpers_js_1.milsToMM)(x);
|
|
872
|
+
y = (0, helpers_js_1.milsToMM)(y);
|
|
661
873
|
this.items.push(geometry_js_1.Geometry.label(id, x, y, textValue, style));
|
|
662
874
|
return this;
|
|
663
875
|
}
|
|
664
876
|
addTextbox(x, y, textValue, style) {
|
|
877
|
+
x = (0, helpers_js_1.milsToMM)(x);
|
|
878
|
+
y = (0, helpers_js_1.milsToMM)(y);
|
|
665
879
|
this.items.push(geometry_js_1.Geometry.textbox(null, x, y, textValue, style));
|
|
666
880
|
return this;
|
|
667
881
|
}
|
|
882
|
+
addModulePort(x, y, width, height, portType = PinTypes_js_1.PinTypes.Any, scaleX = 1) {
|
|
883
|
+
const height2 = height / 2;
|
|
884
|
+
let path = [];
|
|
885
|
+
const arrowSize = (0, helpers_js_1.milsToMM)(30);
|
|
886
|
+
if (portType === PinTypes_js_1.PinTypes.Any) {
|
|
887
|
+
path = [
|
|
888
|
+
[0, -height2],
|
|
889
|
+
[width, -height2],
|
|
890
|
+
[width, +height2],
|
|
891
|
+
[0, +height2],
|
|
892
|
+
[0, -height2]
|
|
893
|
+
];
|
|
894
|
+
}
|
|
895
|
+
else if (portType === PinTypes_js_1.PinTypes.Output) {
|
|
896
|
+
path = [
|
|
897
|
+
[arrowSize, -height2],
|
|
898
|
+
[width, -height2],
|
|
899
|
+
[width, height2],
|
|
900
|
+
[arrowSize, height2],
|
|
901
|
+
[0, 0],
|
|
902
|
+
[arrowSize, -height2]
|
|
903
|
+
];
|
|
904
|
+
}
|
|
905
|
+
else if (portType === PinTypes_js_1.PinTypes.Input) {
|
|
906
|
+
path = [
|
|
907
|
+
[0, -height2],
|
|
908
|
+
[width - arrowSize, -height2],
|
|
909
|
+
[width, 0],
|
|
910
|
+
[width - arrowSize, height2],
|
|
911
|
+
[0, +height2],
|
|
912
|
+
[0, -height2],
|
|
913
|
+
];
|
|
914
|
+
}
|
|
915
|
+
else if (portType === PinTypes_js_1.PinTypes.IO) {
|
|
916
|
+
path = [
|
|
917
|
+
[arrowSize, -height2],
|
|
918
|
+
[width - arrowSize, -height2],
|
|
919
|
+
[width, 0],
|
|
920
|
+
[width - arrowSize, +height2],
|
|
921
|
+
[arrowSize, +height2],
|
|
922
|
+
[0, 0],
|
|
923
|
+
[0 + arrowSize, -height2],
|
|
924
|
+
];
|
|
925
|
+
}
|
|
926
|
+
path = path.map(point => {
|
|
927
|
+
return [x + point[0] * scaleX, y + point[1]];
|
|
928
|
+
});
|
|
929
|
+
this.items.push(geometry_js_1.Geometry.polygon(path));
|
|
930
|
+
return this;
|
|
931
|
+
}
|
|
668
932
|
addPath(...pathParts) {
|
|
669
933
|
const parts = pathParts.reduce((accum, tmp) => {
|
|
670
934
|
if (typeof tmp === "string") {
|
|
@@ -683,14 +947,14 @@ class SymbolDrawing {
|
|
|
683
947
|
if (currentObj !== null) {
|
|
684
948
|
geomObjects.push(currentObj);
|
|
685
949
|
}
|
|
686
|
-
const x = Number(parts[i + 1]);
|
|
687
|
-
const y = Number(parts[i + 2]);
|
|
950
|
+
const x = (0, helpers_js_1.milsToMM)(Number(parts[i + 1]));
|
|
951
|
+
const y = (0, helpers_js_1.milsToMM)(Number(parts[i + 2]));
|
|
688
952
|
currentObj = [[x, y]];
|
|
689
953
|
i += 2;
|
|
690
954
|
}
|
|
691
955
|
else if (command === 'L') {
|
|
692
|
-
const x = Number(parts[i + 1]);
|
|
693
|
-
const y = Number(parts[i + 2]);
|
|
956
|
+
const x = (0, helpers_js_1.milsToMM)(Number(parts[i + 1]));
|
|
957
|
+
const y = (0, helpers_js_1.milsToMM)(Number(parts[i + 2]));
|
|
694
958
|
currentObj.push([x, y]);
|
|
695
959
|
i += 2;
|
|
696
960
|
}
|
|
@@ -716,6 +980,7 @@ class SymbolDrawing {
|
|
|
716
980
|
return this;
|
|
717
981
|
}
|
|
718
982
|
addSetLineWidth(value) {
|
|
983
|
+
value = (0, helpers_js_1.milsToMM)(value);
|
|
719
984
|
this.items.push(new geometry_js_1.GeometryProp('lineWidth', value));
|
|
720
985
|
return this;
|
|
721
986
|
}
|
|
@@ -723,16 +988,27 @@ class SymbolDrawing {
|
|
|
723
988
|
this.items.push(new geometry_js_1.GeometryProp('lineColor', value));
|
|
724
989
|
return this;
|
|
725
990
|
}
|
|
991
|
+
addSetTextColor(value) {
|
|
992
|
+
this.items.push(new geometry_js_1.GeometryProp('textColor', value));
|
|
993
|
+
return this;
|
|
994
|
+
}
|
|
726
995
|
addSetFillColor(value) {
|
|
727
996
|
this.items.push(new geometry_js_1.GeometryProp('fillColor', value));
|
|
728
997
|
return this;
|
|
729
998
|
}
|
|
730
999
|
addArc(x, y, radius, startAngle, endAngle) {
|
|
1000
|
+
x = (0, helpers_js_1.milsToMM)(x);
|
|
1001
|
+
y = (0, helpers_js_1.milsToMM)(y);
|
|
1002
|
+
radius = (0, helpers_js_1.milsToMM)(radius);
|
|
731
1003
|
startAngle = startAngle * Math.PI / 180;
|
|
732
1004
|
endAngle = endAngle * Math.PI / 180;
|
|
733
1005
|
this.items.push(geometry_js_1.Geometry.arc([x, y], radius, startAngle, endAngle, true));
|
|
734
1006
|
return this;
|
|
735
1007
|
}
|
|
1008
|
+
addSetUnits(value) {
|
|
1009
|
+
this.items.push(new geometry_js_1.GeometryProp('units', value));
|
|
1010
|
+
return this;
|
|
1011
|
+
}
|
|
736
1012
|
getPaths() {
|
|
737
1013
|
let currentFill = "#fff";
|
|
738
1014
|
let currentLineWidth = 1;
|
|
@@ -767,11 +1043,15 @@ class SymbolDrawing {
|
|
|
767
1043
|
return pathItems;
|
|
768
1044
|
}
|
|
769
1045
|
getPinsPath() {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
1046
|
+
return this.pins.map(item => {
|
|
1047
|
+
let features = geometry_js_1.Geometry.groupFlip([item[1]], this.flipX, this.flipY);
|
|
1048
|
+
features = geometry_js_1.Geometry.groupRotate(features, this.angle, this.mainOrigin);
|
|
1049
|
+
const { path } = this.featuresToPath(features, this.flipX, this.flipY);
|
|
1050
|
+
return {
|
|
1051
|
+
path,
|
|
1052
|
+
lineColor: item[3],
|
|
1053
|
+
};
|
|
1054
|
+
});
|
|
775
1055
|
}
|
|
776
1056
|
getLabels() {
|
|
777
1057
|
return this.items.filter(item => item instanceof geometry_js_1.Textbox);
|