circuitscript 0.5.3 → 0.5.4
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/annotate/ComponentAnnotater.js +3 -2
- package/dist/cjs/globals.js +10 -6
- package/dist/cjs/objects/Frame.js +7 -0
- package/dist/cjs/pipeline.js +4 -1
- package/dist/cjs/render/draw_symbols.js +23 -8
- package/dist/cjs/render/graph.js +4 -0
- package/dist/cjs/render/render.js +19 -8
- package/dist/cjs/styles.js +19 -0
- package/dist/esm/annotate/ComponentAnnotater.js +3 -2
- package/dist/esm/globals.js +8 -4
- package/dist/esm/objects/Frame.js +7 -0
- package/dist/esm/pipeline.js +4 -1
- package/dist/esm/render/draw_symbols.js +26 -9
- package/dist/esm/render/graph.js +5 -0
- package/dist/esm/render/render.js +18 -7
- package/dist/esm/styles.js +20 -0
- package/dist/libs/std.cst +6 -6
- package/dist/types/globals.d.ts +8 -4
- package/dist/types/objects/Frame.d.ts +7 -0
- package/dist/types/render/draw_symbols.d.ts +8 -3
- package/dist/types/render/graph.d.ts +3 -0
- package/dist/types/render/render.d.ts +2 -1
- package/dist/types/styles.d.ts +11 -0
- package/libs/std.cst +6 -6
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ComponentAnnotater = void 0;
|
|
4
4
|
const visitor_js_1 = require("./../visitor.js");
|
|
5
|
+
const globals_js_1 = require("../globals.js");
|
|
5
6
|
class ComponentAnnotater {
|
|
6
7
|
constructor() {
|
|
7
8
|
this.counter = {};
|
|
@@ -14,8 +15,8 @@ class ComponentAnnotater {
|
|
|
14
15
|
getAnnotation(instance) {
|
|
15
16
|
let usePrefix;
|
|
16
17
|
let useCounterKey;
|
|
17
|
-
if (instance.hasParam(
|
|
18
|
-
const prefix = instance.getParam(
|
|
18
|
+
if (instance.hasParam(globals_js_1.KeywordRefdesPrefix)) {
|
|
19
|
+
const prefix = instance.getParam(globals_js_1.KeywordRefdesPrefix);
|
|
19
20
|
if (this.counter[prefix] === undefined) {
|
|
20
21
|
this.counter[prefix] = 1;
|
|
21
22
|
}
|
package/dist/cjs/globals.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.PinTypesList = exports.DefaultComponentUnit = exports.TrailerArrayIndex = void 0;
|
|
3
|
+
exports.RenderFlags = exports.KeywordRefdesPrefix = exports.GlobalDocumentName = exports.ModuleContainsKeyword = exports.FrameType = exports.NetGraphicsParams = 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.defaultSymbolLineWidth = exports.Defaults = exports.fontDisplayScale = exports.defaultZoomScale = exports.defaultGridSizeUnits = exports.portHeight = exports.portWidth = exports.PxToMM = exports.MMToPt = exports.MMToPx = exports.MilsToMM = exports.WireAutoDirection = exports.LengthUnit = exports.ValidPinSides = exports.SymbolPinSide = exports.LayoutDirection = exports.ParamKeys = exports.NoNetText = exports.GlobalNames = exports.RefdesFileSuffix = exports.BaseNamespace = exports.DoubleDelimiter1 = exports.Delimiter1 = exports.TOOL_VERSION = void 0;
|
|
4
|
+
exports.PinTypesList = exports.DefaultComponentUnit = exports.TrailerArrayIndex = exports.SymbolValidatorContext = void 0;
|
|
5
5
|
const NumericValue_js_1 = require("./objects/NumericValue.js");
|
|
6
6
|
const PinTypes_js_1 = require("./objects/PinTypes.js");
|
|
7
7
|
exports.TOOL_VERSION = '0.1.5';
|
|
@@ -60,8 +60,11 @@ exports.portHeight = 2;
|
|
|
60
60
|
exports.defaultGridSizeUnits = (0, NumericValue_js_1.numeric)(exports.MilsToMM).mul(100).toNumber();
|
|
61
61
|
exports.defaultZoomScale = 2.5;
|
|
62
62
|
exports.fontDisplayScale = 0.032;
|
|
63
|
+
exports.Defaults = {
|
|
64
|
+
WireLineWidth: (0, NumericValue_js_1.numeric)(6),
|
|
65
|
+
LineWidth: (0, NumericValue_js_1.numeric)(5),
|
|
66
|
+
};
|
|
63
67
|
exports.defaultSymbolLineWidth = (0, NumericValue_js_1.numeric)(exports.MilsToMM).mul(6).toNumber();
|
|
64
|
-
exports.defaultWireLineWidth = (0, NumericValue_js_1.numeric)(exports.MilsToMM).mul(6).toNumber();
|
|
65
68
|
exports.defaultPinNameTextSize = 40;
|
|
66
69
|
exports.defaultPinIdTextSize = 30;
|
|
67
70
|
exports.defaultPageMarginMM = 10;
|
|
@@ -107,10 +110,10 @@ var ReferenceTypes;
|
|
|
107
110
|
var NetGraphicsParams;
|
|
108
111
|
(function (NetGraphicsParams) {
|
|
109
112
|
NetGraphicsParams["Color"] = "color";
|
|
110
|
-
NetGraphicsParams["LineWidth"] = "
|
|
113
|
+
NetGraphicsParams["LineWidth"] = "line_width";
|
|
111
114
|
NetGraphicsParams["Highlight"] = "highlight";
|
|
112
|
-
NetGraphicsParams["HighlightWidth"] = "
|
|
113
|
-
NetGraphicsParams["HighlightOpacity"] = "
|
|
115
|
+
NetGraphicsParams["HighlightWidth"] = "highlight_width";
|
|
116
|
+
NetGraphicsParams["HighlightOpacity"] = "highlight_opacity";
|
|
114
117
|
})(NetGraphicsParams || (exports.NetGraphicsParams = NetGraphicsParams = {}));
|
|
115
118
|
var FrameType;
|
|
116
119
|
(function (FrameType) {
|
|
@@ -119,6 +122,7 @@ var FrameType;
|
|
|
119
122
|
})(FrameType || (exports.FrameType = FrameType = {}));
|
|
120
123
|
exports.ModuleContainsKeyword = 'contains';
|
|
121
124
|
exports.GlobalDocumentName = 'document';
|
|
125
|
+
exports.KeywordRefdesPrefix = 'refdes_prefix';
|
|
122
126
|
exports.RenderFlags = {
|
|
123
127
|
ShowElementFrames: false,
|
|
124
128
|
ShowOrigin: false,
|
|
@@ -27,6 +27,13 @@ var FrameParamKeys;
|
|
|
27
27
|
FrameParamKeys["SheetType"] = "sheet_type";
|
|
28
28
|
FrameParamKeys["GridStyle"] = "grid_style";
|
|
29
29
|
FrameParamKeys["GridColor"] = "grid_color";
|
|
30
|
+
FrameParamKeys["BackgroundColor"] = "background_color";
|
|
31
|
+
FrameParamKeys["LineColor"] = "line_color";
|
|
32
|
+
FrameParamKeys["LineWidth"] = "line_width";
|
|
33
|
+
FrameParamKeys["FillColor"] = "fill_color";
|
|
34
|
+
FrameParamKeys["TextColor"] = "text_color";
|
|
35
|
+
FrameParamKeys["WireColor"] = "wire_color";
|
|
36
|
+
FrameParamKeys["WireWidth"] = "wire_width";
|
|
30
37
|
FrameParamKeys["TitleAlign"] = "title_align";
|
|
31
38
|
FrameParamKeys["HorizontalAlign"] = "align";
|
|
32
39
|
FrameParamKeys["VerticalAlign"] = "valign";
|
package/dist/cjs/pipeline.js
CHANGED
|
@@ -20,6 +20,7 @@ const render_js_1 = require("./render/render.js");
|
|
|
20
20
|
const rules_js_1 = require("./rules-check/rules.js");
|
|
21
21
|
const utils_js_1 = require("./utils.js");
|
|
22
22
|
const visitor_js_1 = require("./visitor.js");
|
|
23
|
+
const styles_js_1 = require("./styles.js");
|
|
23
24
|
async function renderScript(scriptData, outputPath, options) {
|
|
24
25
|
const parseHandlers = [
|
|
25
26
|
new KiCadNetListOutputHandler_js_1.KiCadNetListOutputHandler(),
|
|
@@ -194,8 +195,10 @@ async function renderScriptCustom(scriptData, outputPath, options, parseHandlers
|
|
|
194
195
|
const graphEngine = new graph_js_1.NetGraph(logger);
|
|
195
196
|
const layoutEngine = new layout_js_1.LayoutEngine(logger);
|
|
196
197
|
const layoutTimer = new utils_js_1.SimpleStopwatch();
|
|
198
|
+
const styles = (0, styles_js_1.getStylesFromDocument)(documentVariable);
|
|
197
199
|
let sheetFrames;
|
|
198
200
|
try {
|
|
201
|
+
graphEngine.setStyles(styles);
|
|
199
202
|
const { graph, containerFrames } = graphEngine.generateLayoutGraph(sequence, nets);
|
|
200
203
|
sheetFrames = layoutEngine.runLayout(graph, containerFrames, nets);
|
|
201
204
|
if (enableErc) {
|
|
@@ -221,7 +224,7 @@ async function renderScriptCustom(scriptData, outputPath, options, parseHandlers
|
|
|
221
224
|
const renderLogger = new logger_js_1.Logger();
|
|
222
225
|
let svgCanvas;
|
|
223
226
|
try {
|
|
224
|
-
svgCanvas = (0, render_js_1.renderSheetsToSVG)(sheetFrames, renderLogger, documentVariable);
|
|
227
|
+
svgCanvas = (0, render_js_1.renderSheetsToSVG)(sheetFrames, renderLogger, documentVariable, styles);
|
|
225
228
|
}
|
|
226
229
|
catch (err) {
|
|
227
230
|
throw new utils_js_1.RenderError(`Error during SVG generation: ${err}`, 'svg_generation');
|
|
@@ -54,6 +54,9 @@ class SymbolGraphic {
|
|
|
54
54
|
height: this.height
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
setStyles(styles) {
|
|
58
|
+
this.styles = styles;
|
|
59
|
+
}
|
|
57
60
|
size() {
|
|
58
61
|
return {
|
|
59
62
|
width: this.width.toNumber(),
|
|
@@ -371,16 +374,25 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
371
374
|
drawing.angle = this._angle;
|
|
372
375
|
drawing.flipX = this._flipX;
|
|
373
376
|
drawing.flipY = this._flipY;
|
|
377
|
+
const styles = this.styles ?? {
|
|
378
|
+
lineColor: globals_js_1.ColorScheme.PinLineColor,
|
|
379
|
+
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
380
|
+
lineWidth: globals_js_1.Defaults.LineWidth,
|
|
381
|
+
};
|
|
382
|
+
const defaultLineColor = styles.lineColor;
|
|
383
|
+
const defaultLineWidth = styles.lineWidth;
|
|
384
|
+
const defaultTextColor = styles.textColor;
|
|
374
385
|
const commands = [
|
|
375
386
|
[PlaceHolderCommands.units, ['mils'], {}],
|
|
376
|
-
[PlaceHolderCommands.lineColor, [
|
|
377
|
-
[PlaceHolderCommands.textColor, [
|
|
378
|
-
[PlaceHolderCommands.lineWidth, [
|
|
387
|
+
[PlaceHolderCommands.lineColor, [defaultLineColor], {}],
|
|
388
|
+
[PlaceHolderCommands.textColor, [defaultTextColor], {}],
|
|
389
|
+
[PlaceHolderCommands.lineWidth, [defaultLineWidth], {}],
|
|
390
|
+
[PlaceHolderCommands.fill, ['none']],
|
|
379
391
|
...drawing.getCommands()
|
|
380
392
|
];
|
|
381
393
|
drawing.log('id: ', drawing.id, 'angle: ', this._angle, "commands:", commands.length);
|
|
382
|
-
let lineColor =
|
|
383
|
-
let textColor =
|
|
394
|
+
let lineColor = defaultLineColor;
|
|
395
|
+
let textColor = defaultTextColor;
|
|
384
396
|
commands.forEach(([commandName, positionParams, keywordParams, ctx]) => {
|
|
385
397
|
positionParams = positionParams.map(param => {
|
|
386
398
|
return this.resolveReference(param);
|
|
@@ -653,6 +665,9 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
653
665
|
super();
|
|
654
666
|
this.drawing = drawing;
|
|
655
667
|
}
|
|
668
|
+
setStyles(styles) {
|
|
669
|
+
this.styles = styles;
|
|
670
|
+
}
|
|
656
671
|
}
|
|
657
672
|
exports.SymbolPlaceholder = SymbolPlaceholder;
|
|
658
673
|
var PlaceHolderCommands;
|
|
@@ -670,10 +685,10 @@ var PlaceHolderCommands;
|
|
|
670
685
|
PlaceHolderCommands["line"] = "line";
|
|
671
686
|
PlaceHolderCommands["label"] = "label";
|
|
672
687
|
PlaceHolderCommands["path"] = "path";
|
|
673
|
-
PlaceHolderCommands["lineWidth"] = "
|
|
688
|
+
PlaceHolderCommands["lineWidth"] = "line_width";
|
|
674
689
|
PlaceHolderCommands["fill"] = "fill";
|
|
675
|
-
PlaceHolderCommands["lineColor"] = "
|
|
676
|
-
PlaceHolderCommands["textColor"] = "
|
|
690
|
+
PlaceHolderCommands["lineColor"] = "line_color";
|
|
691
|
+
PlaceHolderCommands["textColor"] = "text_color";
|
|
677
692
|
PlaceHolderCommands["text"] = "text";
|
|
678
693
|
PlaceHolderCommands["units"] = "units";
|
|
679
694
|
PlaceHolderCommands["for"] = "for";
|
package/dist/cjs/render/graph.js
CHANGED
|
@@ -39,6 +39,9 @@ class NetGraph {
|
|
|
39
39
|
constructor(logger) {
|
|
40
40
|
this.logger = logger;
|
|
41
41
|
}
|
|
42
|
+
setStyles(styles) {
|
|
43
|
+
this.styles = styles;
|
|
44
|
+
}
|
|
42
45
|
generateLayoutGraph(sequence, nets) {
|
|
43
46
|
this.print('===== creating graph and populating with nodes =====');
|
|
44
47
|
let previousNode = null;
|
|
@@ -72,6 +75,7 @@ class NetGraph {
|
|
|
72
75
|
let tmpSymbol;
|
|
73
76
|
if (displayProp instanceof draw_symbols_js_1.SymbolDrawing) {
|
|
74
77
|
tmpSymbol = new draw_symbols_js_1.SymbolPlaceholder(displayProp);
|
|
78
|
+
tmpSymbol.setStyles(this.styles);
|
|
75
79
|
tmpSymbol.drawing.logger = this.logger;
|
|
76
80
|
}
|
|
77
81
|
else {
|
|
@@ -25,7 +25,7 @@ function createSvgCanvas() {
|
|
|
25
25
|
(0, sizing_js_1.applyFontsToSVG)(canvas);
|
|
26
26
|
return canvas;
|
|
27
27
|
}
|
|
28
|
-
function renderSheetsToSVG(sheetFrames, logger, documentVariable) {
|
|
28
|
+
function renderSheetsToSVG(sheetFrames, logger, documentVariable, styles) {
|
|
29
29
|
const canvas = createSvgCanvas();
|
|
30
30
|
sheetFrames.forEach((sheet, index) => {
|
|
31
31
|
const sheetGroup = canvas.group();
|
|
@@ -87,8 +87,9 @@ function renderSheetsToSVG(sheetFrames, logger, documentVariable) {
|
|
|
87
87
|
extendGrid,
|
|
88
88
|
style: documentVariable[Frame_js_1.FrameParamKeys.GridStyle],
|
|
89
89
|
color: documentVariable[Frame_js_1.FrameParamKeys.GridColor],
|
|
90
|
+
backgroundColor: documentVariable[Frame_js_1.FrameParamKeys.BackgroundColor],
|
|
90
91
|
};
|
|
91
|
-
generateSVGChild(sheetElements, components, wires, junctions, mergedWires, allFrames, textObjects, gridProperties, logger);
|
|
92
|
+
generateSVGChild(sheetElements, components, wires, junctions, mergedWires, allFrames, textObjects, gridProperties, styles, logger);
|
|
92
93
|
sheetElements.translate(xOffset, yOffset);
|
|
93
94
|
sheetGroup.translate(0, sheetYOffset.toNumber());
|
|
94
95
|
});
|
|
@@ -135,7 +136,7 @@ function generatePdfOutput(doc, canvas, sheetSize, sheetSizeDefined, zoomScale =
|
|
|
135
136
|
});
|
|
136
137
|
}
|
|
137
138
|
exports.generatePdfOutput = generatePdfOutput;
|
|
138
|
-
function generateSVGChild(canvas, components, wires, junctions, mergedWires, frameObjects, textObjects, gridProperties, logger) {
|
|
139
|
+
function generateSVGChild(canvas, components, wires, junctions, mergedWires, frameObjects, textObjects, gridProperties, styles, logger) {
|
|
139
140
|
const displayWireId = false;
|
|
140
141
|
if (gridProperties.gridBounds === null) {
|
|
141
142
|
logger.add('get grid bounds');
|
|
@@ -189,19 +190,22 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
|
|
|
189
190
|
}
|
|
190
191
|
const mergedWireHighlightGroup = canvas.group();
|
|
191
192
|
const mergedWireGroup = canvas.group();
|
|
193
|
+
styles = styles ?? {};
|
|
194
|
+
const defaultWireColor = styles.wireColor;
|
|
195
|
+
const defaultWireLineWidth = (0, helpers_js_1.milsToMM)(styles.wireWidth).toNumber();
|
|
192
196
|
mergedWires.forEach(tmpItem => {
|
|
193
197
|
const { intersectPoints, net = null, lines = null } = tmpItem;
|
|
194
198
|
let useJunctionColor = globals_js_1.ColorScheme.JunctionColor;
|
|
195
|
-
let useColor =
|
|
196
|
-
let useLineWidth =
|
|
199
|
+
let useColor = defaultWireColor;
|
|
200
|
+
let useLineWidth = defaultWireLineWidth;
|
|
197
201
|
let displayHighlight = false;
|
|
198
202
|
let displayHighlightColor = null;
|
|
199
203
|
let displayHighlightOpacity = 0.3;
|
|
200
204
|
let displayHighlightWidth = 5 * globals_js_1.MilsToMM;
|
|
201
205
|
if (net !== null) {
|
|
202
|
-
useColor = net.color ??
|
|
206
|
+
useColor = net.color ?? defaultWireColor;
|
|
203
207
|
useJunctionColor = net.color ?? globals_js_1.ColorScheme.JunctionColor;
|
|
204
|
-
useLineWidth = net.lineWidth ??
|
|
208
|
+
useLineWidth = net.lineWidth ?? defaultWireLineWidth;
|
|
205
209
|
if (net.highlight !== null) {
|
|
206
210
|
displayHighlight = true;
|
|
207
211
|
displayHighlightColor = net.highlight ?? null;
|
|
@@ -302,7 +306,7 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
|
|
|
302
306
|
.stroke('none').fill('red');
|
|
303
307
|
}
|
|
304
308
|
function drawGrid(group, gridProperties, logger) {
|
|
305
|
-
const { gridBounds: canvasSize, extendGrid, style: gridStyle = "dots", color: gridColor = "#000" } = gridProperties;
|
|
309
|
+
const { gridBounds: canvasSize, extendGrid, style: gridStyle = "dots", color: gridColor = "#000", backgroundColor = "", } = gridProperties;
|
|
306
310
|
const gridSize = globals_js_1.defaultGridSizeUnits;
|
|
307
311
|
const { xmin, ymin, xmax, ymax } = canvasSize;
|
|
308
312
|
const extraValue = extendGrid ? 1 : 0;
|
|
@@ -330,6 +334,13 @@ function drawGrid(group, gridProperties, logger) {
|
|
|
330
334
|
const startX = gridStartX.add(numericGridSize.mul(i)).toNumber();
|
|
331
335
|
lines.push(`M ${startX} ${startY.toNumber()} L ${startX} ${endY.toNumber()}`);
|
|
332
336
|
}
|
|
337
|
+
if (backgroundColor !== "") {
|
|
338
|
+
const width = gridEndX.sub(gridStartX).toNumber();
|
|
339
|
+
const height = gridEndY.sub(gridStartY).toNumber();
|
|
340
|
+
group
|
|
341
|
+
.rect(width, height).fill(backgroundColor)
|
|
342
|
+
.translate(gridStartX.toNumber(), gridStartY.toNumber());
|
|
343
|
+
}
|
|
333
344
|
const strokeSize = (0, helpers_js_1.milsToMM)(3);
|
|
334
345
|
group.addClass('grid')
|
|
335
346
|
.path(lines.join(" "))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStylesFromDocument = exports.Styles = void 0;
|
|
4
|
+
const globals_js_1 = require("./globals.js");
|
|
5
|
+
const Frame_js_1 = require("./objects/Frame.js");
|
|
6
|
+
class Styles {
|
|
7
|
+
}
|
|
8
|
+
exports.Styles = Styles;
|
|
9
|
+
function getStylesFromDocument(document) {
|
|
10
|
+
const styles = new Styles();
|
|
11
|
+
styles.lineColor = document[Frame_js_1.FrameParamKeys.LineColor] ?? globals_js_1.ColorScheme.PinLineColor;
|
|
12
|
+
styles.lineWidth = document[Frame_js_1.FrameParamKeys.LineWidth] ?? globals_js_1.Defaults.LineWidth;
|
|
13
|
+
styles.fillColor = document[Frame_js_1.FrameParamKeys.FillColor];
|
|
14
|
+
styles.textColor = document[Frame_js_1.FrameParamKeys.TextColor] ?? globals_js_1.ColorScheme.PinNameColor;
|
|
15
|
+
styles.wireColor = document[Frame_js_1.FrameParamKeys.WireColor] ?? globals_js_1.ColorScheme.WireColor;
|
|
16
|
+
styles.wireWidth = document[Frame_js_1.FrameParamKeys.WireWidth] ?? globals_js_1.Defaults.WireLineWidth;
|
|
17
|
+
return styles;
|
|
18
|
+
}
|
|
19
|
+
exports.getStylesFromDocument = getStylesFromDocument;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ComponentRefDesPrefixes } from './../visitor.js';
|
|
2
|
+
import { KeywordRefdesPrefix } from '../globals.js';
|
|
2
3
|
export class ComponentAnnotater {
|
|
3
4
|
counter = {};
|
|
4
5
|
indexedContextPrefix = new Map();
|
|
@@ -11,8 +12,8 @@ export class ComponentAnnotater {
|
|
|
11
12
|
getAnnotation(instance) {
|
|
12
13
|
let usePrefix;
|
|
13
14
|
let useCounterKey;
|
|
14
|
-
if (instance.hasParam(
|
|
15
|
-
const prefix = instance.getParam(
|
|
15
|
+
if (instance.hasParam(KeywordRefdesPrefix)) {
|
|
16
|
+
const prefix = instance.getParam(KeywordRefdesPrefix);
|
|
16
17
|
if (this.counter[prefix] === undefined) {
|
|
17
18
|
this.counter[prefix] = 1;
|
|
18
19
|
}
|
package/dist/esm/globals.js
CHANGED
|
@@ -56,8 +56,11 @@ export const portHeight = 2;
|
|
|
56
56
|
export const defaultGridSizeUnits = numeric(MilsToMM).mul(100).toNumber();
|
|
57
57
|
export const defaultZoomScale = 2.5;
|
|
58
58
|
export const fontDisplayScale = 0.032;
|
|
59
|
+
export const Defaults = {
|
|
60
|
+
WireLineWidth: numeric(6),
|
|
61
|
+
LineWidth: numeric(5),
|
|
62
|
+
};
|
|
59
63
|
export const defaultSymbolLineWidth = numeric(MilsToMM).mul(6).toNumber();
|
|
60
|
-
export const defaultWireLineWidth = numeric(MilsToMM).mul(6).toNumber();
|
|
61
64
|
export const defaultPinNameTextSize = 40;
|
|
62
65
|
export const defaultPinIdTextSize = 30;
|
|
63
66
|
export const defaultPageMarginMM = 10;
|
|
@@ -103,10 +106,10 @@ export var ReferenceTypes;
|
|
|
103
106
|
export var NetGraphicsParams;
|
|
104
107
|
(function (NetGraphicsParams) {
|
|
105
108
|
NetGraphicsParams["Color"] = "color";
|
|
106
|
-
NetGraphicsParams["LineWidth"] = "
|
|
109
|
+
NetGraphicsParams["LineWidth"] = "line_width";
|
|
107
110
|
NetGraphicsParams["Highlight"] = "highlight";
|
|
108
|
-
NetGraphicsParams["HighlightWidth"] = "
|
|
109
|
-
NetGraphicsParams["HighlightOpacity"] = "
|
|
111
|
+
NetGraphicsParams["HighlightWidth"] = "highlight_width";
|
|
112
|
+
NetGraphicsParams["HighlightOpacity"] = "highlight_opacity";
|
|
110
113
|
})(NetGraphicsParams || (NetGraphicsParams = {}));
|
|
111
114
|
export var FrameType;
|
|
112
115
|
(function (FrameType) {
|
|
@@ -115,6 +118,7 @@ export var FrameType;
|
|
|
115
118
|
})(FrameType || (FrameType = {}));
|
|
116
119
|
export const ModuleContainsKeyword = 'contains';
|
|
117
120
|
export const GlobalDocumentName = 'document';
|
|
121
|
+
export const KeywordRefdesPrefix = 'refdes_prefix';
|
|
118
122
|
export const RenderFlags = {
|
|
119
123
|
ShowElementFrames: false,
|
|
120
124
|
ShowOrigin: false,
|
|
@@ -25,6 +25,13 @@ export var FrameParamKeys;
|
|
|
25
25
|
FrameParamKeys["SheetType"] = "sheet_type";
|
|
26
26
|
FrameParamKeys["GridStyle"] = "grid_style";
|
|
27
27
|
FrameParamKeys["GridColor"] = "grid_color";
|
|
28
|
+
FrameParamKeys["BackgroundColor"] = "background_color";
|
|
29
|
+
FrameParamKeys["LineColor"] = "line_color";
|
|
30
|
+
FrameParamKeys["LineWidth"] = "line_width";
|
|
31
|
+
FrameParamKeys["FillColor"] = "fill_color";
|
|
32
|
+
FrameParamKeys["TextColor"] = "text_color";
|
|
33
|
+
FrameParamKeys["WireColor"] = "wire_color";
|
|
34
|
+
FrameParamKeys["WireWidth"] = "wire_width";
|
|
28
35
|
FrameParamKeys["TitleAlign"] = "title_align";
|
|
29
36
|
FrameParamKeys["HorizontalAlign"] = "align";
|
|
30
37
|
FrameParamKeys["VerticalAlign"] = "valign";
|
package/dist/esm/pipeline.js
CHANGED
|
@@ -14,6 +14,7 @@ import { renderSheetsToSVG, generateSvgOutput, generatePdfOutput } from "./rende
|
|
|
14
14
|
import { EvaluateERCRules } from "./rules-check/rules.js";
|
|
15
15
|
import { RuntimeExecutionError, ParseSyntaxError, ParseError, printWarnings, RenderError, generateDebugSequenceAction, sequenceActionString, SimpleStopwatch } from "./utils.js";
|
|
16
16
|
import { ParserVisitor } from "./visitor.js";
|
|
17
|
+
import { getStylesFromDocument } from "./styles.js";
|
|
17
18
|
export async function renderScript(scriptData, outputPath, options) {
|
|
18
19
|
const parseHandlers = [
|
|
19
20
|
new KiCadNetListOutputHandler(),
|
|
@@ -187,8 +188,10 @@ export async function renderScriptCustom(scriptData, outputPath, options, parseH
|
|
|
187
188
|
const graphEngine = new NetGraph(logger);
|
|
188
189
|
const layoutEngine = new LayoutEngine(logger);
|
|
189
190
|
const layoutTimer = new SimpleStopwatch();
|
|
191
|
+
const styles = getStylesFromDocument(documentVariable);
|
|
190
192
|
let sheetFrames;
|
|
191
193
|
try {
|
|
194
|
+
graphEngine.setStyles(styles);
|
|
192
195
|
const { graph, containerFrames } = graphEngine.generateLayoutGraph(sequence, nets);
|
|
193
196
|
sheetFrames = layoutEngine.runLayout(graph, containerFrames, nets);
|
|
194
197
|
if (enableErc) {
|
|
@@ -214,7 +217,7 @@ export async function renderScriptCustom(scriptData, outputPath, options, parseH
|
|
|
214
217
|
const renderLogger = new Logger();
|
|
215
218
|
let svgCanvas;
|
|
216
219
|
try {
|
|
217
|
-
svgCanvas = renderSheetsToSVG(sheetFrames, renderLogger, documentVariable);
|
|
220
|
+
svgCanvas = renderSheetsToSVG(sheetFrames, renderLogger, documentVariable, styles);
|
|
218
221
|
}
|
|
219
222
|
catch (err) {
|
|
220
223
|
throw new RenderError(`Error during SVG generation: ${err}`, 'svg_generation');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { milsToMM } from "../helpers.js";
|
|
2
|
-
import { ColorScheme, CustomSymbolParamTextSize, CustomSymbolPinIdSize, CustomSymbolPinTextSize, CustomSymbolRefDesSize, PinTypesList, PortArrowSize, PortPaddingHorizontal, PortPaddingVertical, ReferenceTypes, RenderFlags, SymbolPinSide, defaultFont, defaultPinIdTextSize, defaultPinNameTextSize, defaultSymbolLineWidth, fontDisplayScale } from "../globals.js";
|
|
2
|
+
import { ColorScheme, CustomSymbolParamTextSize, CustomSymbolPinIdSize, CustomSymbolPinTextSize, CustomSymbolRefDesSize, Defaults, PinTypesList, PortArrowSize, PortPaddingHorizontal, PortPaddingVertical, ReferenceTypes, RenderFlags, SymbolPinSide, defaultFont, defaultPinIdTextSize, defaultPinNameTextSize, defaultSymbolLineWidth, fontDisplayScale } from "../globals.js";
|
|
3
3
|
import { Geometry, GeometryProp, HorizontalAlign, HorizontalAlignProp, Textbox, VerticalAlign, VerticalAlignProp } from "./geometry.js";
|
|
4
4
|
import { PinTypes } from "../objects/PinTypes.js";
|
|
5
5
|
import { RuntimeExecutionError, throwWithContext } from "../utils.js";
|
|
@@ -16,6 +16,7 @@ export class SymbolGraphic {
|
|
|
16
16
|
width = numeric(-1);
|
|
17
17
|
height = numeric(-1);
|
|
18
18
|
labelTexts = new Map();
|
|
19
|
+
styles;
|
|
19
20
|
constructor() {
|
|
20
21
|
this.drawing = new SymbolDrawing();
|
|
21
22
|
}
|
|
@@ -52,6 +53,9 @@ export class SymbolGraphic {
|
|
|
52
53
|
height: this.height
|
|
53
54
|
};
|
|
54
55
|
}
|
|
56
|
+
setStyles(styles) {
|
|
57
|
+
this.styles = styles;
|
|
58
|
+
}
|
|
55
59
|
size() {
|
|
56
60
|
return {
|
|
57
61
|
width: this.width.toNumber(),
|
|
@@ -361,6 +365,7 @@ export class SymbolText extends SymbolGraphic {
|
|
|
361
365
|
}
|
|
362
366
|
}
|
|
363
367
|
export class SymbolPlaceholder extends SymbolGraphic {
|
|
368
|
+
styles;
|
|
364
369
|
generateDrawing() {
|
|
365
370
|
const drawing = this.drawing;
|
|
366
371
|
drawing.log("=== start generate drawing ===");
|
|
@@ -368,16 +373,25 @@ export class SymbolPlaceholder extends SymbolGraphic {
|
|
|
368
373
|
drawing.angle = this._angle;
|
|
369
374
|
drawing.flipX = this._flipX;
|
|
370
375
|
drawing.flipY = this._flipY;
|
|
376
|
+
const styles = this.styles ?? {
|
|
377
|
+
lineColor: ColorScheme.PinLineColor,
|
|
378
|
+
textColor: ColorScheme.PinNameColor,
|
|
379
|
+
lineWidth: Defaults.LineWidth,
|
|
380
|
+
};
|
|
381
|
+
const defaultLineColor = styles.lineColor;
|
|
382
|
+
const defaultLineWidth = styles.lineWidth;
|
|
383
|
+
const defaultTextColor = styles.textColor;
|
|
371
384
|
const commands = [
|
|
372
385
|
[PlaceHolderCommands.units, ['mils'], {}],
|
|
373
|
-
[PlaceHolderCommands.lineColor, [
|
|
374
|
-
[PlaceHolderCommands.textColor, [
|
|
375
|
-
[PlaceHolderCommands.lineWidth, [
|
|
386
|
+
[PlaceHolderCommands.lineColor, [defaultLineColor], {}],
|
|
387
|
+
[PlaceHolderCommands.textColor, [defaultTextColor], {}],
|
|
388
|
+
[PlaceHolderCommands.lineWidth, [defaultLineWidth], {}],
|
|
389
|
+
[PlaceHolderCommands.fill, ['none']],
|
|
376
390
|
...drawing.getCommands()
|
|
377
391
|
];
|
|
378
392
|
drawing.log('id: ', drawing.id, 'angle: ', this._angle, "commands:", commands.length);
|
|
379
|
-
let lineColor =
|
|
380
|
-
let textColor =
|
|
393
|
+
let lineColor = defaultLineColor;
|
|
394
|
+
let textColor = defaultTextColor;
|
|
381
395
|
commands.forEach(([commandName, positionParams, keywordParams, ctx]) => {
|
|
382
396
|
positionParams = positionParams.map(param => {
|
|
383
397
|
return this.resolveReference(param);
|
|
@@ -650,6 +664,9 @@ export class SymbolPlaceholder extends SymbolGraphic {
|
|
|
650
664
|
super();
|
|
651
665
|
this.drawing = drawing;
|
|
652
666
|
}
|
|
667
|
+
setStyles(styles) {
|
|
668
|
+
this.styles = styles;
|
|
669
|
+
}
|
|
653
670
|
}
|
|
654
671
|
export var PlaceHolderCommands;
|
|
655
672
|
(function (PlaceHolderCommands) {
|
|
@@ -666,10 +683,10 @@ export var PlaceHolderCommands;
|
|
|
666
683
|
PlaceHolderCommands["line"] = "line";
|
|
667
684
|
PlaceHolderCommands["label"] = "label";
|
|
668
685
|
PlaceHolderCommands["path"] = "path";
|
|
669
|
-
PlaceHolderCommands["lineWidth"] = "
|
|
686
|
+
PlaceHolderCommands["lineWidth"] = "line_width";
|
|
670
687
|
PlaceHolderCommands["fill"] = "fill";
|
|
671
|
-
PlaceHolderCommands["lineColor"] = "
|
|
672
|
-
PlaceHolderCommands["textColor"] = "
|
|
688
|
+
PlaceHolderCommands["lineColor"] = "line_color";
|
|
689
|
+
PlaceHolderCommands["textColor"] = "text_color";
|
|
673
690
|
PlaceHolderCommands["text"] = "text";
|
|
674
691
|
PlaceHolderCommands["units"] = "units";
|
|
675
692
|
PlaceHolderCommands["for"] = "for";
|
package/dist/esm/render/graph.js
CHANGED
|
@@ -11,9 +11,13 @@ import Matrix, { solve } from "ml-matrix";
|
|
|
11
11
|
import { getPinDefinition, PinId } from "../objects/PinDefinition.js";
|
|
12
12
|
export class NetGraph {
|
|
13
13
|
logger;
|
|
14
|
+
styles;
|
|
14
15
|
constructor(logger) {
|
|
15
16
|
this.logger = logger;
|
|
16
17
|
}
|
|
18
|
+
setStyles(styles) {
|
|
19
|
+
this.styles = styles;
|
|
20
|
+
}
|
|
17
21
|
generateLayoutGraph(sequence, nets) {
|
|
18
22
|
this.print('===== creating graph and populating with nodes =====');
|
|
19
23
|
let previousNode = null;
|
|
@@ -47,6 +51,7 @@ export class NetGraph {
|
|
|
47
51
|
let tmpSymbol;
|
|
48
52
|
if (displayProp instanceof SymbolDrawing) {
|
|
49
53
|
tmpSymbol = new SymbolPlaceholder(displayProp);
|
|
54
|
+
tmpSymbol.setStyles(this.styles);
|
|
50
55
|
tmpSymbol.drawing.logger = this.logger;
|
|
51
56
|
}
|
|
52
57
|
else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SVG, registerWindow } from '@svgdotjs/svg.js';
|
|
2
2
|
import { ExtractDrawingRects, RenderFrameType, getBounds } from "./layout.js";
|
|
3
3
|
import { applyFontsToSVG } from '../sizing.js';
|
|
4
|
-
import { ColorScheme, ComponentTypes, FrameType, MMToPt, MMToPx, MilsToMM, ParamKeys, RenderFlags, defaultGridSizeUnits, defaultPageSpacingMM,
|
|
4
|
+
import { ColorScheme, ComponentTypes, FrameType, MMToPt, MMToPx, MilsToMM, ParamKeys, RenderFlags, defaultGridSizeUnits, defaultPageSpacingMM, fontDisplayScale, junctionSize } from '../globals.js';
|
|
5
5
|
import { NumericValue, numeric } from '../objects/NumericValue.js';
|
|
6
6
|
import { combineMaps, getBoundsSize } from '../utils.js';
|
|
7
7
|
import { milsToMM } from '../helpers.js';
|
|
@@ -19,7 +19,7 @@ function createSvgCanvas() {
|
|
|
19
19
|
applyFontsToSVG(canvas);
|
|
20
20
|
return canvas;
|
|
21
21
|
}
|
|
22
|
-
export function renderSheetsToSVG(sheetFrames, logger, documentVariable) {
|
|
22
|
+
export function renderSheetsToSVG(sheetFrames, logger, documentVariable, styles) {
|
|
23
23
|
const canvas = createSvgCanvas();
|
|
24
24
|
sheetFrames.forEach((sheet, index) => {
|
|
25
25
|
const sheetGroup = canvas.group();
|
|
@@ -81,8 +81,9 @@ export function renderSheetsToSVG(sheetFrames, logger, documentVariable) {
|
|
|
81
81
|
extendGrid,
|
|
82
82
|
style: documentVariable[FrameParamKeys.GridStyle],
|
|
83
83
|
color: documentVariable[FrameParamKeys.GridColor],
|
|
84
|
+
backgroundColor: documentVariable[FrameParamKeys.BackgroundColor],
|
|
84
85
|
};
|
|
85
|
-
generateSVGChild(sheetElements, components, wires, junctions, mergedWires, allFrames, textObjects, gridProperties, logger);
|
|
86
|
+
generateSVGChild(sheetElements, components, wires, junctions, mergedWires, allFrames, textObjects, gridProperties, styles, logger);
|
|
86
87
|
sheetElements.translate(xOffset, yOffset);
|
|
87
88
|
sheetGroup.translate(0, sheetYOffset.toNumber());
|
|
88
89
|
});
|
|
@@ -126,7 +127,7 @@ export function generatePdfOutput(doc, canvas, sheetSize, sheetSizeDefined, zoom
|
|
|
126
127
|
}
|
|
127
128
|
});
|
|
128
129
|
}
|
|
129
|
-
function generateSVGChild(canvas, components, wires, junctions, mergedWires, frameObjects, textObjects, gridProperties, logger) {
|
|
130
|
+
function generateSVGChild(canvas, components, wires, junctions, mergedWires, frameObjects, textObjects, gridProperties, styles, logger) {
|
|
130
131
|
const displayWireId = false;
|
|
131
132
|
if (gridProperties.gridBounds === null) {
|
|
132
133
|
logger.add('get grid bounds');
|
|
@@ -180,17 +181,20 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
|
|
|
180
181
|
}
|
|
181
182
|
const mergedWireHighlightGroup = canvas.group();
|
|
182
183
|
const mergedWireGroup = canvas.group();
|
|
184
|
+
styles = styles ?? {};
|
|
185
|
+
const defaultWireColor = styles.wireColor;
|
|
186
|
+
const defaultWireLineWidth = milsToMM(styles.wireWidth).toNumber();
|
|
183
187
|
mergedWires.forEach(tmpItem => {
|
|
184
188
|
const { intersectPoints, net = null, lines = null } = tmpItem;
|
|
185
189
|
let useJunctionColor = ColorScheme.JunctionColor;
|
|
186
|
-
let useColor =
|
|
190
|
+
let useColor = defaultWireColor;
|
|
187
191
|
let useLineWidth = defaultWireLineWidth;
|
|
188
192
|
let displayHighlight = false;
|
|
189
193
|
let displayHighlightColor = null;
|
|
190
194
|
let displayHighlightOpacity = 0.3;
|
|
191
195
|
let displayHighlightWidth = 5 * MilsToMM;
|
|
192
196
|
if (net !== null) {
|
|
193
|
-
useColor = net.color ??
|
|
197
|
+
useColor = net.color ?? defaultWireColor;
|
|
194
198
|
useJunctionColor = net.color ?? ColorScheme.JunctionColor;
|
|
195
199
|
useLineWidth = net.lineWidth ?? defaultWireLineWidth;
|
|
196
200
|
if (net.highlight !== null) {
|
|
@@ -293,7 +297,7 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
|
|
|
293
297
|
.stroke('none').fill('red');
|
|
294
298
|
}
|
|
295
299
|
function drawGrid(group, gridProperties, logger) {
|
|
296
|
-
const { gridBounds: canvasSize, extendGrid, style: gridStyle = "dots", color: gridColor = "#000" } = gridProperties;
|
|
300
|
+
const { gridBounds: canvasSize, extendGrid, style: gridStyle = "dots", color: gridColor = "#000", backgroundColor = "", } = gridProperties;
|
|
297
301
|
const gridSize = defaultGridSizeUnits;
|
|
298
302
|
const { xmin, ymin, xmax, ymax } = canvasSize;
|
|
299
303
|
const extraValue = extendGrid ? 1 : 0;
|
|
@@ -321,6 +325,13 @@ function drawGrid(group, gridProperties, logger) {
|
|
|
321
325
|
const startX = gridStartX.add(numericGridSize.mul(i)).toNumber();
|
|
322
326
|
lines.push(`M ${startX} ${startY.toNumber()} L ${startX} ${endY.toNumber()}`);
|
|
323
327
|
}
|
|
328
|
+
if (backgroundColor !== "") {
|
|
329
|
+
const width = gridEndX.sub(gridStartX).toNumber();
|
|
330
|
+
const height = gridEndY.sub(gridStartY).toNumber();
|
|
331
|
+
group
|
|
332
|
+
.rect(width, height).fill(backgroundColor)
|
|
333
|
+
.translate(gridStartX.toNumber(), gridStartY.toNumber());
|
|
334
|
+
}
|
|
324
335
|
const strokeSize = milsToMM(3);
|
|
325
336
|
group.addClass('grid')
|
|
326
337
|
.path(lines.join(" "))
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ColorScheme, Defaults } from "./globals.js";
|
|
2
|
+
import { FrameParamKeys } from "./objects/Frame.js";
|
|
3
|
+
export class Styles {
|
|
4
|
+
lineColor;
|
|
5
|
+
lineWidth;
|
|
6
|
+
fillColor;
|
|
7
|
+
textColor;
|
|
8
|
+
wireColor;
|
|
9
|
+
wireWidth;
|
|
10
|
+
}
|
|
11
|
+
export function getStylesFromDocument(document) {
|
|
12
|
+
const styles = new Styles();
|
|
13
|
+
styles.lineColor = document[FrameParamKeys.LineColor] ?? ColorScheme.PinLineColor;
|
|
14
|
+
styles.lineWidth = document[FrameParamKeys.LineWidth] ?? Defaults.LineWidth;
|
|
15
|
+
styles.fillColor = document[FrameParamKeys.FillColor];
|
|
16
|
+
styles.textColor = document[FrameParamKeys.TextColor] ?? ColorScheme.PinNameColor;
|
|
17
|
+
styles.wireColor = document[FrameParamKeys.WireColor] ?? ColorScheme.WireColor;
|
|
18
|
+
styles.wireWidth = document[FrameParamKeys.WireWidth] ?? Defaults.WireLineWidth;
|
|
19
|
+
return styles;
|
|
20
|
+
}
|
package/dist/libs/std.cst
CHANGED
|
@@ -24,7 +24,7 @@ def label(value, anchor="left"):
|
|
|
24
24
|
copy: true
|
|
25
25
|
followWireOrientation: false
|
|
26
26
|
display: create graphic (params):
|
|
27
|
-
|
|
27
|
+
text_color: "#222"
|
|
28
28
|
label: params.value, 0, -10, fontSize=50, anchor=anchor
|
|
29
29
|
pin: 1, 0, 0, 0, 0, display_id=false
|
|
30
30
|
type: "net"
|
|
@@ -38,7 +38,7 @@ def port(value, portType="input"):
|
|
|
38
38
|
pins: 1
|
|
39
39
|
copy: true
|
|
40
40
|
display: create graphic (params):
|
|
41
|
-
|
|
41
|
+
text_color: "#222"
|
|
42
42
|
label: params.value, 0, 0, fontSize=40, anchor="left", vanchor="middle", portType=portType
|
|
43
43
|
pin: 1, 0, 0, 0, 0, display_id=false
|
|
44
44
|
type: "port"
|
|
@@ -73,7 +73,7 @@ def cap(value):
|
|
|
73
73
|
return create component:
|
|
74
74
|
pins: 2
|
|
75
75
|
display: create graphic (params):
|
|
76
|
-
|
|
76
|
+
line_width: 13
|
|
77
77
|
hline: -width/2, 20, width
|
|
78
78
|
hline: -width/2, -20, width
|
|
79
79
|
vpin: 1, 0, -100, 80, display_id=false
|
|
@@ -208,7 +208,7 @@ def arrow_point():
|
|
|
208
208
|
pins: 1
|
|
209
209
|
followWireOrientation: false
|
|
210
210
|
display: create graphic:
|
|
211
|
-
|
|
211
|
+
line_width: 2
|
|
212
212
|
path: ("M", -10, -5, "L", -5, 0, "L", -10, 5)
|
|
213
213
|
path: ("M", -5, 0, "L", -20, 0)
|
|
214
214
|
hpin: 1, 0, 0, 0, display_id=false
|
|
@@ -269,12 +269,12 @@ def sheet_generator(paper_size_name, paper_width, paper_height, margin_x, margin
|
|
|
269
269
|
fill: "none"
|
|
270
270
|
|
|
271
271
|
# outer rect
|
|
272
|
-
|
|
272
|
+
line_color: "#cccccc"
|
|
273
273
|
crect: (paper_width/2, paper_height/2,
|
|
274
274
|
paper_width, paper_height, class="paper-area")
|
|
275
275
|
|
|
276
276
|
# inner rect
|
|
277
|
-
|
|
277
|
+
line_color: "#111111"
|
|
278
278
|
crect: (paper_width/2, paper_height/2,
|
|
279
279
|
inner_width, inner_height, class="plot-area")
|
|
280
280
|
|
package/dist/types/globals.d.ts
CHANGED
|
@@ -46,8 +46,11 @@ export declare const portHeight = 2;
|
|
|
46
46
|
export declare const defaultGridSizeUnits: number;
|
|
47
47
|
export declare const defaultZoomScale = 2.5;
|
|
48
48
|
export declare const fontDisplayScale = 0.032;
|
|
49
|
+
export declare const Defaults: {
|
|
50
|
+
WireLineWidth: import("./objects/NumericValue.js").NumericValue;
|
|
51
|
+
LineWidth: import("./objects/NumericValue.js").NumericValue;
|
|
52
|
+
};
|
|
49
53
|
export declare const defaultSymbolLineWidth: number;
|
|
50
|
-
export declare const defaultWireLineWidth: number;
|
|
51
54
|
export declare const defaultPinNameTextSize = 40;
|
|
52
55
|
export declare const defaultPinIdTextSize = 30;
|
|
53
56
|
export declare const defaultPageMarginMM = 10;
|
|
@@ -90,10 +93,10 @@ export declare enum ReferenceTypes {
|
|
|
90
93
|
}
|
|
91
94
|
export declare enum NetGraphicsParams {
|
|
92
95
|
Color = "color",
|
|
93
|
-
LineWidth = "
|
|
96
|
+
LineWidth = "line_width",
|
|
94
97
|
Highlight = "highlight",
|
|
95
|
-
HighlightWidth = "
|
|
96
|
-
HighlightOpacity = "
|
|
98
|
+
HighlightWidth = "highlight_width",
|
|
99
|
+
HighlightOpacity = "highlight_opacity"
|
|
97
100
|
}
|
|
98
101
|
export declare enum FrameType {
|
|
99
102
|
Frame = 1,
|
|
@@ -101,6 +104,7 @@ export declare enum FrameType {
|
|
|
101
104
|
}
|
|
102
105
|
export declare const ModuleContainsKeyword = "contains";
|
|
103
106
|
export declare const GlobalDocumentName = "document";
|
|
107
|
+
export declare const KeywordRefdesPrefix = "refdes_prefix";
|
|
104
108
|
export declare const RenderFlags: {
|
|
105
109
|
ShowElementFrames: boolean;
|
|
106
110
|
ShowOrigin: boolean;
|
|
@@ -20,6 +20,13 @@ export declare enum FrameParamKeys {
|
|
|
20
20
|
SheetType = "sheet_type",
|
|
21
21
|
GridStyle = "grid_style",
|
|
22
22
|
GridColor = "grid_color",
|
|
23
|
+
BackgroundColor = "background_color",
|
|
24
|
+
LineColor = "line_color",
|
|
25
|
+
LineWidth = "line_width",
|
|
26
|
+
FillColor = "fill_color",
|
|
27
|
+
TextColor = "text_color",
|
|
28
|
+
WireColor = "wire_color",
|
|
29
|
+
WireWidth = "wire_width",
|
|
23
30
|
TitleAlign = "title_align",
|
|
24
31
|
HorizontalAlign = "align",
|
|
25
32
|
VerticalAlign = "valign",
|
|
@@ -5,6 +5,7 @@ import { PinTypes } from "../objects/PinTypes.js";
|
|
|
5
5
|
import { ParserRuleContext } from "antlr4ng";
|
|
6
6
|
import { NumericValue } from "../objects/NumericValue.js";
|
|
7
7
|
import { PinId } from "../objects/PinDefinition.js";
|
|
8
|
+
import { Styles } from "src/styles.js";
|
|
8
9
|
export declare abstract class SymbolGraphic {
|
|
9
10
|
drawPortsName: boolean;
|
|
10
11
|
displayBounds: boolean;
|
|
@@ -15,6 +16,7 @@ export declare abstract class SymbolGraphic {
|
|
|
15
16
|
width: NumericValue;
|
|
16
17
|
height: NumericValue;
|
|
17
18
|
labelTexts: Map<string, string>;
|
|
19
|
+
styles?: Styles;
|
|
18
20
|
constructor();
|
|
19
21
|
get angle(): number;
|
|
20
22
|
set angle(value: number);
|
|
@@ -29,6 +31,7 @@ export declare abstract class SymbolGraphic {
|
|
|
29
31
|
width: NumericValue;
|
|
30
32
|
height: NumericValue;
|
|
31
33
|
};
|
|
34
|
+
setStyles(styles: Styles): void;
|
|
32
35
|
abstract generateDrawing(): void;
|
|
33
36
|
size(): {
|
|
34
37
|
width: number;
|
|
@@ -58,6 +61,7 @@ export declare class SymbolText extends SymbolGraphic {
|
|
|
58
61
|
generateDrawing(): void;
|
|
59
62
|
}
|
|
60
63
|
export declare class SymbolPlaceholder extends SymbolGraphic {
|
|
64
|
+
styles: Styles;
|
|
61
65
|
generateDrawing(): void;
|
|
62
66
|
private resolveReference;
|
|
63
67
|
parseLabelStyle(keywordParams: Map<string, any>): {
|
|
@@ -65,6 +69,7 @@ export declare class SymbolPlaceholder extends SymbolGraphic {
|
|
|
65
69
|
};
|
|
66
70
|
drawPinParams(drawing: SymbolDrawingCommands, commandName: string, keywordParams: Map<string, any>, positionParams: any[], lineColor: string, pinNameColor: string): void;
|
|
67
71
|
constructor(drawing: SymbolDrawing);
|
|
72
|
+
setStyles(styles: Styles): void;
|
|
68
73
|
}
|
|
69
74
|
export declare enum PlaceHolderCommands {
|
|
70
75
|
arc = "arc",
|
|
@@ -80,10 +85,10 @@ export declare enum PlaceHolderCommands {
|
|
|
80
85
|
line = "line",
|
|
81
86
|
label = "label",
|
|
82
87
|
path = "path",
|
|
83
|
-
lineWidth = "
|
|
88
|
+
lineWidth = "line_width",
|
|
84
89
|
fill = "fill",
|
|
85
|
-
lineColor = "
|
|
86
|
-
textColor = "
|
|
90
|
+
lineColor = "line_color",
|
|
91
|
+
textColor = "text_color",
|
|
87
92
|
text = "text",
|
|
88
93
|
units = "units",
|
|
89
94
|
for = "for"
|
|
@@ -7,9 +7,12 @@ import { Net } from "../objects/Net.js";
|
|
|
7
7
|
import { Logger } from "../logger.js";
|
|
8
8
|
import { ComponentPinNetPair } from "../objects/types.js";
|
|
9
9
|
import { PinId } from "../objects/PinDefinition.js";
|
|
10
|
+
import { Styles } from "src/styles.js";
|
|
10
11
|
export declare class NetGraph {
|
|
11
12
|
logger: Logger;
|
|
13
|
+
styles: Styles;
|
|
12
14
|
constructor(logger: Logger);
|
|
15
|
+
setStyles(styles: Styles): void;
|
|
13
16
|
generateLayoutGraph(sequence: SequenceItem[], nets: [ClassComponent, pin: PinId, net: Net][]): {
|
|
14
17
|
graph: Graph;
|
|
15
18
|
containerFrames: RenderFrame[];
|
|
@@ -3,6 +3,7 @@ import { Svg } from '@svgdotjs/svg.js';
|
|
|
3
3
|
import { SheetFrame } from "./layout.js";
|
|
4
4
|
import { Logger } from '../logger.js';
|
|
5
5
|
import { DocumentVariable } from 'src/objects/types.js';
|
|
6
|
-
|
|
6
|
+
import { Styles } from 'src/styles.js';
|
|
7
|
+
export declare function renderSheetsToSVG(sheetFrames: SheetFrame[], logger: Logger, documentVariable: DocumentVariable, styles: Styles): Svg;
|
|
7
8
|
export declare function generateSvgOutput(canvas: Svg, zoomScale?: number): string;
|
|
8
9
|
export declare function generatePdfOutput(doc: PDFKit.PDFDocument, canvas: Svg, sheetSize: string, sheetSizeDefined: boolean, zoomScale?: number): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NumericValue } from "./objects/NumericValue.js";
|
|
2
|
+
import { DocumentVariable } from "./objects/types.js";
|
|
3
|
+
export declare class Styles {
|
|
4
|
+
lineColor?: string;
|
|
5
|
+
lineWidth?: NumericValue;
|
|
6
|
+
fillColor?: string;
|
|
7
|
+
textColor?: string;
|
|
8
|
+
wireColor?: string;
|
|
9
|
+
wireWidth?: NumericValue;
|
|
10
|
+
}
|
|
11
|
+
export declare function getStylesFromDocument(document: DocumentVariable): Styles;
|
package/libs/std.cst
CHANGED
|
@@ -24,7 +24,7 @@ def label(value, anchor="left"):
|
|
|
24
24
|
copy: true
|
|
25
25
|
followWireOrientation: false
|
|
26
26
|
display: create graphic (params):
|
|
27
|
-
|
|
27
|
+
text_color: "#222"
|
|
28
28
|
label: params.value, 0, -10, fontSize=50, anchor=anchor
|
|
29
29
|
pin: 1, 0, 0, 0, 0, display_id=false
|
|
30
30
|
type: "net"
|
|
@@ -38,7 +38,7 @@ def port(value, portType="input"):
|
|
|
38
38
|
pins: 1
|
|
39
39
|
copy: true
|
|
40
40
|
display: create graphic (params):
|
|
41
|
-
|
|
41
|
+
text_color: "#222"
|
|
42
42
|
label: params.value, 0, 0, fontSize=40, anchor="left", vanchor="middle", portType=portType
|
|
43
43
|
pin: 1, 0, 0, 0, 0, display_id=false
|
|
44
44
|
type: "port"
|
|
@@ -73,7 +73,7 @@ def cap(value):
|
|
|
73
73
|
return create component:
|
|
74
74
|
pins: 2
|
|
75
75
|
display: create graphic (params):
|
|
76
|
-
|
|
76
|
+
line_width: 13
|
|
77
77
|
hline: -width/2, 20, width
|
|
78
78
|
hline: -width/2, -20, width
|
|
79
79
|
vpin: 1, 0, -100, 80, display_id=false
|
|
@@ -208,7 +208,7 @@ def arrow_point():
|
|
|
208
208
|
pins: 1
|
|
209
209
|
followWireOrientation: false
|
|
210
210
|
display: create graphic:
|
|
211
|
-
|
|
211
|
+
line_width: 2
|
|
212
212
|
path: ("M", -10, -5, "L", -5, 0, "L", -10, 5)
|
|
213
213
|
path: ("M", -5, 0, "L", -20, 0)
|
|
214
214
|
hpin: 1, 0, 0, 0, display_id=false
|
|
@@ -269,12 +269,12 @@ def sheet_generator(paper_size_name, paper_width, paper_height, margin_x, margin
|
|
|
269
269
|
fill: "none"
|
|
270
270
|
|
|
271
271
|
# outer rect
|
|
272
|
-
|
|
272
|
+
line_color: "#cccccc"
|
|
273
273
|
crect: (paper_width/2, paper_height/2,
|
|
274
274
|
paper_width, paper_height, class="paper-area")
|
|
275
275
|
|
|
276
276
|
# inner rect
|
|
277
|
-
|
|
277
|
+
line_color: "#111111"
|
|
278
278
|
crect: (paper_width/2, paper_height/2,
|
|
279
279
|
inner_width, inner_height, class="plot-area")
|
|
280
280
|
|