circuitscript 0.0.32 → 0.0.34
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 +187 -39
- package/dist/cjs/antlr/CircuitScriptLexer.js +226 -185
- package/dist/cjs/antlr/CircuitScriptParser.js +1439 -902
- package/dist/cjs/draw_symbols.js +1 -0
- package/dist/cjs/execute.js +14 -12
- package/dist/cjs/globals.js +14 -2
- package/dist/cjs/helpers.js +62 -19
- package/dist/cjs/layout.js +88 -36
- package/dist/cjs/objects/ClassComponent.js +3 -0
- package/dist/cjs/objects/ExecutionScope.js +1 -0
- package/dist/cjs/objects/Frame.js +4 -1
- package/dist/cjs/objects/ParamDefinition.js +1 -7
- package/dist/cjs/objects/types.js +6 -0
- package/dist/cjs/regenerate-tests.js +2 -1
- package/dist/cjs/render.js +238 -42
- package/dist/cjs/visitor.js +162 -27
- package/dist/esm/BaseVisitor.mjs +189 -41
- package/dist/esm/antlr/CircuitScriptLexer.mjs +226 -185
- package/dist/esm/antlr/CircuitScriptParser.mjs +1428 -899
- package/dist/esm/antlr/CircuitScriptVisitor.mjs +9 -2
- package/dist/esm/draw_symbols.mjs +1 -0
- package/dist/esm/execute.mjs +14 -12
- package/dist/esm/globals.mjs +13 -1
- package/dist/esm/helpers.mjs +61 -20
- package/dist/esm/layout.mjs +88 -37
- package/dist/esm/objects/ClassComponent.mjs +3 -0
- package/dist/esm/objects/ExecutionScope.mjs +1 -0
- package/dist/esm/objects/Frame.mjs +5 -1
- package/dist/esm/objects/ParamDefinition.mjs +0 -6
- package/dist/esm/objects/types.mjs +6 -0
- package/dist/esm/regenerate-tests.mjs +2 -1
- package/dist/esm/render.mjs +234 -43
- package/dist/esm/visitor.mjs +164 -29
- package/dist/types/BaseVisitor.d.ts +8 -2
- package/dist/types/antlr/CircuitScriptLexer.d.ts +41 -30
- package/dist/types/antlr/CircuitScriptParser.d.ts +169 -81
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +18 -4
- package/dist/types/draw_symbols.d.ts +2 -1
- package/dist/types/execute.d.ts +6 -3
- package/dist/types/globals.d.ts +11 -0
- package/dist/types/helpers.d.ts +12 -0
- package/dist/types/layout.d.ts +17 -9
- package/dist/types/objects/ClassComponent.d.ts +2 -1
- package/dist/types/objects/ExecutionScope.d.ts +2 -0
- package/dist/types/objects/Frame.d.ts +6 -2
- package/dist/types/objects/ParamDefinition.d.ts +0 -4
- package/dist/types/objects/types.d.ts +4 -2
- package/dist/types/render.d.ts +6 -14
- package/dist/types/visitor.d.ts +10 -2
- package/libs/lib.cst +283 -0
- package/package.json +1 -1
package/dist/cjs/draw_symbols.js
CHANGED
|
@@ -605,6 +605,7 @@ var PlaceHolderCommands;
|
|
|
605
605
|
PlaceHolderCommands["textColor"] = "textColor";
|
|
606
606
|
PlaceHolderCommands["text"] = "text";
|
|
607
607
|
PlaceHolderCommands["units"] = "units";
|
|
608
|
+
PlaceHolderCommands["for"] = "for";
|
|
608
609
|
})(PlaceHolderCommands || (exports.PlaceHolderCommands = PlaceHolderCommands = {}));
|
|
609
610
|
class SymbolCustom extends SymbolGraphic {
|
|
610
611
|
constructor(pinDefinition) {
|
package/dist/cjs/execute.js
CHANGED
|
@@ -439,12 +439,16 @@ class ExecutionContext {
|
|
|
439
439
|
this.log('did not find block point');
|
|
440
440
|
return null;
|
|
441
441
|
}
|
|
442
|
-
|
|
443
|
-
this.log('break
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
442
|
+
addBreakContext(ctx) {
|
|
443
|
+
this.log('add break context');
|
|
444
|
+
this.scope.breakStack.push(ctx);
|
|
445
|
+
}
|
|
446
|
+
popBreakContext() {
|
|
447
|
+
this.log('pop break context');
|
|
448
|
+
return this.scope.breakStack.pop();
|
|
449
|
+
}
|
|
450
|
+
getBreakContext() {
|
|
451
|
+
return this.scope.breakStack[this.scope.breakStack.length - 1];
|
|
448
452
|
}
|
|
449
453
|
createFunction(functionName, __runFunc) {
|
|
450
454
|
this.scope.functions.set(functionName, __runFunc);
|
|
@@ -776,9 +780,9 @@ class ExecutionContext {
|
|
|
776
780
|
}
|
|
777
781
|
}
|
|
778
782
|
}
|
|
779
|
-
enterFrame() {
|
|
783
|
+
enterFrame(frameType) {
|
|
780
784
|
const frameId = this.scope.frames.length + 1;
|
|
781
|
-
const frameObject = new Frame_js_1.Frame(frameId);
|
|
785
|
+
const frameObject = new Frame_js_1.Frame(frameId, frameType);
|
|
782
786
|
this.log('Enter frame', frameId);
|
|
783
787
|
this.scope.frames.push(frameObject);
|
|
784
788
|
this.scope.sequence.push([ExecutionScope_js_1.SequenceAction.Frame,
|
|
@@ -843,10 +847,8 @@ function getPortSide(pins, arrangeProps) {
|
|
|
843
847
|
}
|
|
844
848
|
let position = 0;
|
|
845
849
|
useItems.forEach(item => {
|
|
846
|
-
if (typeof item === 'object') {
|
|
847
|
-
|
|
848
|
-
position += item.blank;
|
|
849
|
-
}
|
|
850
|
+
if (typeof item === 'object' && Array.isArray(item)) {
|
|
851
|
+
position += item[0];
|
|
850
852
|
}
|
|
851
853
|
if (existingPinIds.indexOf(item) !== -1) {
|
|
852
854
|
result.push({
|
package/dist/cjs/globals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BlockTypes = exports.ReferenceTypes = exports.ComponentTypes = exports.ColorScheme = exports.PortPaddingVertical = exports.PortPaddingHorizontal = exports.PortArrowSize = exports.junctionSize = exports.defaultFontSize = exports.defaultFontBold = exports.defaultFont = exports.displayUnits = exports.defaultFrameTitleTextSize = exports.CustomSymbolParamTextSize = exports.CustomSymbolRefDesSize = exports.CustomSymbolPinIdSize = exports.CustomSymbolPinTextSize = exports.defaultPinIdTextSize = exports.defaultPinNameTextSize = exports.defaultWireLineWidth = exports.defaultSymbolLineWidth = exports.fontDisplayScale = exports.defaultZoomScale = exports.defaultGridSizeUnits = exports.portHeight = exports.portWidth = exports.PxToMM = exports.MMToPt = exports.MMToPx = exports.MilsToMM = exports.WireAutoDirection = exports.LengthUnit = exports.SymbolPinSide = exports.LayoutDirection = exports.ParamKeys = exports.NoNetText = exports.GlobalNames = void 0;
|
|
3
|
+
exports.RenderFlags = exports.GlobalDocumentName = exports.FrameType = exports.BlockTypes = exports.ReferenceTypes = exports.ComponentTypes = exports.ColorScheme = exports.PortPaddingVertical = exports.PortPaddingHorizontal = exports.PortArrowSize = exports.junctionSize = exports.defaultFontSize = exports.defaultFontBold = exports.defaultFont = exports.displayUnits = exports.defaultFrameTitleTextSize = exports.CustomSymbolParamTextSize = exports.CustomSymbolRefDesSize = exports.CustomSymbolPinIdSize = exports.CustomSymbolPinTextSize = exports.defaultPageSpacingMM = exports.defaultPageMarginMM = exports.defaultPinIdTextSize = exports.defaultPinNameTextSize = exports.defaultWireLineWidth = exports.defaultSymbolLineWidth = exports.fontDisplayScale = exports.defaultZoomScale = exports.defaultGridSizeUnits = exports.portHeight = exports.portWidth = exports.PxToMM = exports.MMToPt = exports.MMToPx = exports.MilsToMM = exports.WireAutoDirection = exports.LengthUnit = exports.SymbolPinSide = exports.LayoutDirection = exports.ParamKeys = exports.NoNetText = exports.GlobalNames = void 0;
|
|
4
4
|
var GlobalNames;
|
|
5
5
|
(function (GlobalNames) {
|
|
6
6
|
GlobalNames["__root"] = "__root";
|
|
@@ -50,6 +50,8 @@ exports.defaultSymbolLineWidth = exports.MilsToMM * 6;
|
|
|
50
50
|
exports.defaultWireLineWidth = exports.MilsToMM * 6;
|
|
51
51
|
exports.defaultPinNameTextSize = 40;
|
|
52
52
|
exports.defaultPinIdTextSize = 30;
|
|
53
|
+
exports.defaultPageMarginMM = 10;
|
|
54
|
+
exports.defaultPageSpacingMM = 10;
|
|
53
55
|
exports.CustomSymbolPinTextSize = exports.defaultPinNameTextSize;
|
|
54
56
|
exports.CustomSymbolPinIdSize = exports.defaultPinIdTextSize;
|
|
55
57
|
exports.CustomSymbolRefDesSize = 50;
|
|
@@ -65,7 +67,7 @@ exports.PortPaddingHorizontal = exports.MilsToMM * 10;
|
|
|
65
67
|
exports.PortPaddingVertical = exports.MilsToMM * 10;
|
|
66
68
|
exports.ColorScheme = {
|
|
67
69
|
BodyColor: 'rgb(255, 255, 194)',
|
|
68
|
-
JunctionColor: '
|
|
70
|
+
JunctionColor: 'rgb(0, 132, 0)',
|
|
69
71
|
WireColor: 'rgb(0, 132, 0)',
|
|
70
72
|
PinLineColor: '#333',
|
|
71
73
|
PinNameColor: '#333',
|
|
@@ -92,3 +94,13 @@ var BlockTypes;
|
|
|
92
94
|
BlockTypes[BlockTypes["Parallel"] = 3] = "Parallel";
|
|
93
95
|
BlockTypes[BlockTypes["Point"] = 4] = "Point";
|
|
94
96
|
})(BlockTypes || (exports.BlockTypes = BlockTypes = {}));
|
|
97
|
+
var FrameType;
|
|
98
|
+
(function (FrameType) {
|
|
99
|
+
FrameType[FrameType["Frame"] = 1] = "Frame";
|
|
100
|
+
FrameType[FrameType["Sheet"] = 2] = "Sheet";
|
|
101
|
+
})(FrameType || (exports.FrameType = FrameType = {}));
|
|
102
|
+
exports.GlobalDocumentName = 'document';
|
|
103
|
+
exports.RenderFlags = {
|
|
104
|
+
ShowElementFrames: false,
|
|
105
|
+
ShowOrigin: false,
|
|
106
|
+
};
|
package/dist/cjs/helpers.js
CHANGED
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.pxToMM = exports.milsToMM = exports.UnitDimension = exports.getPackageVersion = exports.getDefaultLibsPath = exports.getFontsPath = exports.getCurrentPath = exports.detectJSModuleType = exports.renderScript = exports.validateScript = exports.ParseErrorStrategy = exports.getSemanticTokens = exports.getScriptText = exports.prepareFile = exports.JSModuleType = void 0;
|
|
6
|
+
exports.getPaperSize = exports.isSupportedPaperSize = exports.PaperGridReferences = exports.pxToMM = exports.milsToMM = exports.UnitDimension = exports.getPackageVersion = exports.getDefaultLibsPath = exports.getFontsPath = exports.getCurrentPath = exports.detectJSModuleType = exports.renderScript = exports.validateScript = exports.ParseErrorStrategy = exports.getSemanticTokens = exports.getScriptText = exports.prepareFile = exports.JSModuleType = void 0;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const pdfkit_1 = __importDefault(require("pdfkit"));
|
|
9
|
-
const svg_to_pdfkit_1 = __importDefault(require("svg-to-pdfkit"));
|
|
10
10
|
const export_js_1 = require("./export.js");
|
|
11
11
|
const layout_js_1 = require("./layout.js");
|
|
12
12
|
const ExecutionScope_js_1 = require("./objects/ExecutionScope.js");
|
|
@@ -20,8 +20,8 @@ const antlr4ng_1 = require("antlr4ng");
|
|
|
20
20
|
const lexer_js_1 = require("./lexer.js");
|
|
21
21
|
const CircuitScriptParser_js_1 = require("./antlr/CircuitScriptParser.js");
|
|
22
22
|
const SemanticTokenVisitor_js_1 = require("./SemanticTokenVisitor.js");
|
|
23
|
-
const path_1 = __importDefault(require("path"));
|
|
24
23
|
const globals_js_1 = require("./globals.js");
|
|
24
|
+
const Frame_js_1 = require("./objects/Frame.js");
|
|
25
25
|
var JSModuleType;
|
|
26
26
|
(function (JSModuleType) {
|
|
27
27
|
JSModuleType["CommonJs"] = "cjs";
|
|
@@ -187,6 +187,7 @@ function renderScript(scriptData, outputPath, options) {
|
|
|
187
187
|
console.log('Error while parsing');
|
|
188
188
|
return null;
|
|
189
189
|
}
|
|
190
|
+
const { frameComponent } = visitor.applySheetFrameComponent();
|
|
190
191
|
try {
|
|
191
192
|
visitor.annotateComponents();
|
|
192
193
|
}
|
|
@@ -219,43 +220,43 @@ function renderScript(scriptData, outputPath, options) {
|
|
|
219
220
|
return tmp.join(" | ");
|
|
220
221
|
});
|
|
221
222
|
dumpData && (0, fs_1.writeFileSync)('dump/raw-sequence.txt', tmpSequence.join('\n'));
|
|
222
|
-
let svgOutput =
|
|
223
|
+
let svgOutput = "";
|
|
223
224
|
try {
|
|
224
225
|
let fileExtension = null;
|
|
225
|
-
let
|
|
226
|
+
let outputDefaultZoom = globals_js_1.defaultZoomScale;
|
|
226
227
|
if (outputPath) {
|
|
227
228
|
fileExtension = path_1.default.extname(outputPath).substring(1);
|
|
228
|
-
if (fileExtension ===
|
|
229
|
-
|
|
229
|
+
if (fileExtension === "pdf") {
|
|
230
|
+
outputDefaultZoom = 1;
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
|
-
const layoutEngine = new layout_js_1.LayoutEngine(
|
|
233
|
-
showBaseFrame,
|
|
234
|
-
});
|
|
233
|
+
const layoutEngine = new layout_js_1.LayoutEngine();
|
|
235
234
|
const layoutTimer = new utils_js_1.SimpleStopwatch();
|
|
236
|
-
const
|
|
235
|
+
const sheetFrames = layoutEngine.runLayout(sequence, nets);
|
|
237
236
|
layoutEngine.printWarnings();
|
|
238
237
|
showStats && console.log('Layout took:', layoutTimer.lap());
|
|
239
238
|
dumpData && (0, fs_1.writeFileSync)('dump/raw-layout.txt', layoutEngine.logger.dump());
|
|
240
239
|
const generateSvgTimer = new utils_js_1.SimpleStopwatch();
|
|
241
|
-
const
|
|
242
|
-
svgOutput = generatedSvg;
|
|
240
|
+
const svgCanvas = (0, render_js_1.renderSheetsToSVG)(sheetFrames);
|
|
243
241
|
showStats && console.log('Render took:', generateSvgTimer.lap());
|
|
242
|
+
svgOutput = (0, render_js_1.generateSvgOutput)(svgCanvas, outputDefaultZoom);
|
|
244
243
|
if (outputPath) {
|
|
245
244
|
if (fileExtension === 'svg') {
|
|
246
245
|
(0, fs_1.writeFileSync)(outputPath, svgOutput);
|
|
247
246
|
}
|
|
248
247
|
else if (fileExtension === 'pdf') {
|
|
248
|
+
let sheetSize = "A4";
|
|
249
|
+
let sheetSizeDefined = false;
|
|
250
|
+
if (frameComponent) {
|
|
251
|
+
sheetSize = frameComponent.getParam(Frame_js_1.FrameParamKeys.PaperSize);
|
|
252
|
+
sheetSizeDefined = true;
|
|
253
|
+
}
|
|
249
254
|
const doc = new pdfkit_1.default({
|
|
250
255
|
layout: 'landscape',
|
|
251
|
-
size:
|
|
256
|
+
size: sheetSize
|
|
252
257
|
});
|
|
253
258
|
const outputStream = (0, fs_1.createWriteStream)(outputPath);
|
|
254
|
-
|
|
255
|
-
const paperHeightMM = 210;
|
|
256
|
-
const xOffset = (paperWidthMM - svgWidth) / 2;
|
|
257
|
-
const yOffset = (paperHeightMM - svgHeight) / 2;
|
|
258
|
-
(0, svg_to_pdfkit_1.default)(doc, svgOutput, xOffset * globals_js_1.MMToPt, yOffset * globals_js_1.MMToPt);
|
|
259
|
+
(0, render_js_1.generatePdfOutput)(doc, svgCanvas, sheetSize, sheetSizeDefined, outputDefaultZoom);
|
|
259
260
|
doc.pipe(outputStream);
|
|
260
261
|
doc.end();
|
|
261
262
|
}
|
|
@@ -341,3 +342,45 @@ function pxToMM(value) {
|
|
|
341
342
|
return value * globals_js_1.PxToMM;
|
|
342
343
|
}
|
|
343
344
|
exports.pxToMM = pxToMM;
|
|
345
|
+
const PaperSizes = {
|
|
346
|
+
'A0': [1189, 841],
|
|
347
|
+
'A1': [841, 594],
|
|
348
|
+
'A2': [594, 420],
|
|
349
|
+
'A3': [420, 297],
|
|
350
|
+
'A4': [297, 210],
|
|
351
|
+
'A5': [210, 148],
|
|
352
|
+
'A6': [148, 105],
|
|
353
|
+
};
|
|
354
|
+
exports.PaperGridReferences = {
|
|
355
|
+
'A0': [16, 24],
|
|
356
|
+
'A1': [12, 16],
|
|
357
|
+
'A2': [8, 12],
|
|
358
|
+
'A3': [6, 8],
|
|
359
|
+
'A4': [4, 6],
|
|
360
|
+
};
|
|
361
|
+
function isSupportedPaperSize(type) {
|
|
362
|
+
if (PaperSizes[type]) {
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
exports.isSupportedPaperSize = isSupportedPaperSize;
|
|
368
|
+
function getPaperSize(type, margin = globals_js_1.defaultPageMarginMM) {
|
|
369
|
+
if (PaperSizes[type]) {
|
|
370
|
+
const [width, height] = PaperSizes[type];
|
|
371
|
+
const useWidth = width - margin * 2;
|
|
372
|
+
const useHeight = height - margin * 2;
|
|
373
|
+
return {
|
|
374
|
+
width: Math.floor(useWidth * (1 / globals_js_1.MilsToMM)),
|
|
375
|
+
height: Math.floor(useHeight * (1 / globals_js_1.MilsToMM)),
|
|
376
|
+
widthMM: useWidth,
|
|
377
|
+
heightMM: useHeight,
|
|
378
|
+
originalWidthMM: width,
|
|
379
|
+
originalHeightMM: height,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
return getPaperSize('A4');
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
exports.getPaperSize = getPaperSize;
|
package/dist/cjs/layout.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CalculatePinPositions = exports.RenderJunction = exports.RenderFrameType = exports.RenderFrame = exports.RenderText = exports.RenderComponent = exports.RenderWire = exports.RenderObject = exports.getBounds = exports.LayoutEngine = void 0;
|
|
3
|
+
exports.ExtractDrawingRects = exports.CalculatePinPositions = exports.RenderJunction = exports.RenderFrameType = exports.RenderFrame = exports.RenderText = exports.RenderComponent = exports.RenderWire = exports.RenderObject = exports.getBounds = exports.LayoutEngine = void 0;
|
|
4
4
|
const graphlib_1 = require("@dagrejs/graphlib");
|
|
5
5
|
const draw_symbols_js_1 = require("./draw_symbols.js");
|
|
6
6
|
const ExecutionScope_js_1 = require("./objects/ExecutionScope.js");
|
|
@@ -63,38 +63,51 @@ class LayoutEngine {
|
|
|
63
63
|
this.print('-- items:', item.components);
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
const {
|
|
66
|
+
const { elementFrames } = this.placeFrames(graph, subgraphInfo, containerFrames);
|
|
67
67
|
const frameObjects = [...elementFrames, ...containerFrames];
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
const sheetFrames = frameObjects.filter(item => {
|
|
69
|
+
return item.frame.frameType === globals_js_1.FrameType.Sheet;
|
|
70
|
+
});
|
|
71
|
+
if (sheetFrames.length === 0) {
|
|
72
|
+
sheetFrames.push(containerFrames[0]);
|
|
73
|
+
}
|
|
74
|
+
const sheetFrameObjects = sheetFrames.map(sheet => {
|
|
75
|
+
const items = this.flattenFrameItems(sheet);
|
|
76
|
+
const components = items.filter(item => item instanceof RenderComponent);
|
|
77
|
+
const wires = items.filter(item => item instanceof RenderWire);
|
|
78
|
+
const textObjects = items.filter(item => item instanceof RenderText);
|
|
79
|
+
const frames = items.filter(item => item instanceof RenderFrame);
|
|
80
|
+
const wireGroups = new Map();
|
|
81
|
+
wires.forEach(wire => {
|
|
82
|
+
const { netName } = wire;
|
|
83
|
+
if (!wireGroups.has(netName)) {
|
|
84
|
+
wireGroups.set(netName, []);
|
|
85
|
+
}
|
|
86
|
+
wireGroups.get(netName).push(wire);
|
|
87
|
+
});
|
|
88
|
+
const { junctions, mergedWires } = this.findJunctions(wireGroups);
|
|
89
|
+
return {
|
|
90
|
+
frame: sheet,
|
|
91
|
+
frames,
|
|
92
|
+
components,
|
|
93
|
+
wires,
|
|
94
|
+
textObjects,
|
|
95
|
+
junctions,
|
|
96
|
+
mergedWires,
|
|
97
|
+
};
|
|
80
98
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
return sheetFrameObjects;
|
|
100
|
+
}
|
|
101
|
+
flattenFrameItems(frame) {
|
|
102
|
+
const items = [];
|
|
103
|
+
frame.innerItems.forEach(item => {
|
|
104
|
+
items.push(item);
|
|
105
|
+
if (item instanceof RenderFrame) {
|
|
106
|
+
const inner = this.flattenFrameItems(item);
|
|
107
|
+
items.push(...inner);
|
|
86
108
|
}
|
|
87
|
-
wireGroups.get(netName).push(wire);
|
|
88
109
|
});
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
components: placedComponents,
|
|
92
|
-
wires: placedWires,
|
|
93
|
-
mergedWires,
|
|
94
|
-
junctions,
|
|
95
|
-
frameObjects,
|
|
96
|
-
textObjects,
|
|
97
|
-
};
|
|
110
|
+
return items;
|
|
98
111
|
}
|
|
99
112
|
findJunctions(wireGroups) {
|
|
100
113
|
const junctions = [];
|
|
@@ -178,8 +191,14 @@ class LayoutEngine {
|
|
|
178
191
|
this.print(level, "".padStart(level * 4), 'frame', frame.x, frame.y);
|
|
179
192
|
const innerItems = frame.innerItems;
|
|
180
193
|
innerItems.forEach(innerFrame => {
|
|
181
|
-
innerFrame.
|
|
182
|
-
|
|
194
|
+
if (innerFrame.frame.frameType === globals_js_1.FrameType.Sheet) {
|
|
195
|
+
innerFrame.x = 0;
|
|
196
|
+
innerFrame.y = 0;
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
innerFrame.x += frame.x;
|
|
200
|
+
innerFrame.y += frame.y;
|
|
201
|
+
}
|
|
183
202
|
if (innerFrame.type === RenderFrameType.Elements) {
|
|
184
203
|
this.print(level, "".padStart(level * 4), 'element frame', innerFrame.x, innerFrame.y);
|
|
185
204
|
innerFrame.innerItems.forEach(item2 => {
|
|
@@ -267,12 +286,33 @@ class LayoutEngine {
|
|
|
267
286
|
}
|
|
268
287
|
boundPoints.push([innerFrame.x, innerFrame.y], [innerFrame.x + frameWidth, innerFrame.y + frameHeight]);
|
|
269
288
|
});
|
|
270
|
-
|
|
271
|
-
if (frame.
|
|
272
|
-
|
|
289
|
+
const contentsBounds = (0, utils_js_1.resizeBounds)(getBoundsFromPoints(boundPoints), frame.padding);
|
|
290
|
+
if (frame.frame.parameters.has(Frame_js_1.FrameParamKeys.SheetFrame)) {
|
|
291
|
+
const frameComponent = frame.frame.parameters.get(Frame_js_1.FrameParamKeys.SheetFrame);
|
|
292
|
+
const rects = ExtractDrawingRects(frameComponent.displayProp);
|
|
293
|
+
let frameWidth = 0;
|
|
294
|
+
let frameHeight = 0;
|
|
295
|
+
if (rects[1]) {
|
|
296
|
+
frameWidth = (0, helpers_js_1.milsToMM)(rects[1].width);
|
|
297
|
+
frameHeight = (0, helpers_js_1.milsToMM)(rects[1].height);
|
|
298
|
+
}
|
|
299
|
+
const contentsWidth = contentsBounds.xmax - contentsBounds.xmin;
|
|
300
|
+
const contentsHeight = contentsBounds.ymax - contentsBounds.ymin;
|
|
301
|
+
const frameOffsetX = (0, utils_js_1.toNearestGrid)((frameWidth - contentsWidth) / 2, gridSize);
|
|
302
|
+
const frameOffsetY = (0, utils_js_1.toNearestGrid)((frameHeight - contentsHeight) / 2, gridSize);
|
|
303
|
+
innerFrames.forEach(innerFrame => {
|
|
304
|
+
innerFrame.x += frameOffsetX;
|
|
305
|
+
innerFrame.y += frameOffsetY;
|
|
306
|
+
});
|
|
307
|
+
frame.bounds = {
|
|
308
|
+
xmin: 0,
|
|
309
|
+
ymin: 0,
|
|
310
|
+
xmax: frameWidth,
|
|
311
|
+
ymax: frameHeight
|
|
312
|
+
};
|
|
273
313
|
}
|
|
274
|
-
|
|
275
|
-
frame.bounds
|
|
314
|
+
else {
|
|
315
|
+
frame.bounds = contentsBounds;
|
|
276
316
|
}
|
|
277
317
|
}
|
|
278
318
|
dumpFrame(frame, level = 0) {
|
|
@@ -1261,6 +1301,7 @@ class RenderFrame extends RenderObject {
|
|
|
1261
1301
|
this.borderWidth = 5;
|
|
1262
1302
|
this.width = null;
|
|
1263
1303
|
this.height = null;
|
|
1304
|
+
this.size = null;
|
|
1264
1305
|
this.subgraphId = "";
|
|
1265
1306
|
this.containsTitle = false;
|
|
1266
1307
|
this.frame = frame;
|
|
@@ -1309,6 +1350,17 @@ function CalculatePinPositions(component) {
|
|
|
1309
1350
|
return pinPositionMapping;
|
|
1310
1351
|
}
|
|
1311
1352
|
exports.CalculatePinPositions = CalculatePinPositions;
|
|
1353
|
+
function ExtractDrawingRects(drawing) {
|
|
1354
|
+
return drawing.getCommands().filter(item => {
|
|
1355
|
+
return (item[0] === draw_symbols_js_1.PlaceHolderCommands.rect);
|
|
1356
|
+
}).map(item => {
|
|
1357
|
+
return {
|
|
1358
|
+
width: item[1][2],
|
|
1359
|
+
height: item[1][3],
|
|
1360
|
+
};
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
exports.ExtractDrawingRects = ExtractDrawingRects;
|
|
1312
1364
|
function isPointOverlap(x, y, other) {
|
|
1313
1365
|
return (x >= other.x && y >= other.y && x <= (other.x + other.width) && y <= (other.y + other.height));
|
|
1314
1366
|
}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FramePlotDirection = exports.FrameParamKeys = exports.Frame = void 0;
|
|
4
4
|
class Frame {
|
|
5
|
-
constructor(frameId) {
|
|
5
|
+
constructor(frameId, frameType) {
|
|
6
6
|
this.parameters = new Map();
|
|
7
7
|
this.frameId = frameId;
|
|
8
|
+
this.frameType = frameType;
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
exports.Frame = Frame;
|
|
@@ -16,6 +17,8 @@ var FrameParamKeys;
|
|
|
16
17
|
FrameParamKeys["Border"] = "border";
|
|
17
18
|
FrameParamKeys["Width"] = "width";
|
|
18
19
|
FrameParamKeys["Height"] = "height";
|
|
20
|
+
FrameParamKeys["PaperSize"] = "paper_size";
|
|
21
|
+
FrameParamKeys["SheetFrame"] = "sheet_frame";
|
|
19
22
|
})(FrameParamKeys || (exports.FrameParamKeys = FrameParamKeys = {}));
|
|
20
23
|
var FramePlotDirection;
|
|
21
24
|
(function (FramePlotDirection) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PercentageValue = exports.NumericValue = exports.ParamDefinition = void 0;
|
|
4
4
|
class ParamDefinition {
|
|
5
5
|
constructor(paramName, paramValue) {
|
|
6
6
|
this.paramName = paramName;
|
|
@@ -34,9 +34,3 @@ class PercentageValue {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
exports.PercentageValue = PercentageValue;
|
|
37
|
-
class PinBlankValue {
|
|
38
|
-
constructor(value) {
|
|
39
|
-
this.blank = value;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.PinBlankValue = PinBlankValue;
|
|
@@ -5,6 +5,9 @@ class UndeclaredReference {
|
|
|
5
5
|
constructor(reference) {
|
|
6
6
|
this.reference = reference;
|
|
7
7
|
}
|
|
8
|
+
throwMessage() {
|
|
9
|
+
return `Unknown symbol: ${this.reference.name}`;
|
|
10
|
+
}
|
|
8
11
|
}
|
|
9
12
|
exports.UndeclaredReference = UndeclaredReference;
|
|
10
13
|
class DeclaredReference {
|
|
@@ -15,6 +18,9 @@ class DeclaredReference {
|
|
|
15
18
|
this.type = refType.type;
|
|
16
19
|
this.value = refType.value;
|
|
17
20
|
}
|
|
21
|
+
toString() {
|
|
22
|
+
return `[DeclaredReference name: ${this.name} trailers:${this.trailers} found: ${this.found}]`;
|
|
23
|
+
}
|
|
18
24
|
}
|
|
19
25
|
exports.DeclaredReference = DeclaredReference;
|
|
20
26
|
var ParseSymbolType;
|
|
@@ -31,7 +31,8 @@ async function regenerateTests(extra = "") {
|
|
|
31
31
|
return cstFiles;
|
|
32
32
|
}
|
|
33
33
|
(async () => {
|
|
34
|
-
const generateDiff =
|
|
34
|
+
const generateDiff = (process.argv.indexOf('-diff') !== -1);
|
|
35
|
+
console.log('diff flag: ', generateDiff);
|
|
35
36
|
const nextExtra = generateDiff ? '.next' : '';
|
|
36
37
|
const cstFiles = await regenerateTests(nextExtra);
|
|
37
38
|
const allFiles = [];
|