@design-core/core 0.0.5 → 0.0.7
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/.eslintrc.json +4 -0
- package/TODO.md +49 -6
- package/core/core/core.js +0 -3
- package/core/dimensions/alignedDimension.js +5 -4
- package/core/dimensions/angularDimension.js +6 -5
- package/core/dimensions/baseCircularDimension.js +3 -2
- package/core/dimensions/baseDimension.js +59 -93
- package/core/dimensions/baseLinearDimension.js +6 -5
- package/core/dimensions/diametricDimension.js +4 -3
- package/core/dimensions/dimension.js +21 -14
- package/core/dimensions/radialDimension.js +4 -3
- package/core/dimensions/rotatedDimension.js +12 -11
- package/core/entities/arc.js +112 -145
- package/core/entities/arctext.js +212 -174
- package/core/entities/basePolyline.js +33 -284
- package/core/entities/circle.js +77 -99
- package/core/entities/entity.js +114 -93
- package/core/entities/hatch.js +322 -249
- package/core/entities/insert.js +66 -81
- package/core/entities/line.js +21 -142
- package/core/entities/lwpolyline.js +16 -11
- package/core/entities/polyline.js +4 -4
- package/core/entities/rectangle.js +3 -1
- package/core/entities/solid.js +6 -15
- package/core/entities/text.js +188 -199
- package/core/lib/auxiliary/rubberBand.js +32 -0
- package/core/lib/auxiliary/selectionWindow.js +63 -0
- package/core/lib/auxiliary/snapPoint.js +113 -0
- package/core/lib/auxiliary/trackingLine.js +76 -0
- package/core/lib/canvas.js +228 -166
- package/core/lib/clipboard.js +7 -1
- package/core/lib/colour.js +16 -0
- package/core/lib/commandLine.js +1 -6
- package/core/lib/commandManager.js +18 -8
- package/core/lib/constants.js +28 -0
- package/core/lib/dxf/dxf.js +4 -3
- package/core/lib/entityManager.js +18 -11
- package/core/lib/inputManager.js +36 -13
- package/core/lib/intersect.js +25 -0
- package/core/lib/patterns.js +8 -1
- package/core/lib/plotOptions.js +67 -0
- package/core/lib/polylineUtils.js +75 -0
- package/core/lib/renderers/cairoRenderer.js +371 -0
- package/core/lib/renderers/canvasRenderer.js +315 -0
- package/core/lib/renderers/pdfRenderer.js +366 -0
- package/core/lib/renderers/rendererBase.js +284 -0
- package/core/lib/renderers/svgRenderer.js +343 -0
- package/core/lib/scene.js +27 -5
- package/core/lib/selectionManager.js +2 -2
- package/core/lib/settings.js +4 -2
- package/core/lib/snapping.js +4 -191
- package/core/lib/stateManager.js +30 -1
- package/core/lib/utils.js +21 -2
- package/core/properties/entityProperties.js +104 -0
- package/core/properties/property.js +106 -2
- package/core/properties/propertyManager.js +29 -13
- package/core/tables/block.js +4 -37
- package/core/tables/endblk.js +1 -1
- package/core/tables/layer.js +8 -0
- package/core/tables/styleManagerBase.js +3 -2
- package/core/tables/tableManagerBase.js +8 -3
- package/core/tools/chamfer.js +111 -137
- package/core/tools/chamferFilletBase.js +135 -34
- package/core/tools/copy.js +3 -3
- package/core/tools/explode.js +2 -2
- package/core/tools/extend.js +132 -19
- package/core/tools/fillet.js +86 -183
- package/core/tools/matchProp.js +2 -11
- package/core/tools/mirror.js +7 -6
- package/core/tools/move.js +3 -3
- package/core/tools/offset.js +3 -5
- package/core/tools/pasteclip.js +1 -1
- package/core/tools/rotate.js +6 -3
- package/core/tools/scale.js +1 -1
- package/core/tools/trim.js +265 -23
- package/core/tools/zoom.js +1 -1
- package/jest.config.js +6 -0
- package/package.json +5 -3
- package/test/dimensions/alignedDimension.test.js +14 -7
- package/test/dimensions/angularDimension.test.js +6 -6
- package/test/dimensions/baseDimension.test.js +69 -8
- package/test/dimensions/baseLinearDimension.test.js +62 -0
- package/test/dimensions/diametricDimension.test.js +6 -6
- package/test/dimensions/radialDimension.test.js +6 -6
- package/test/dimensions/rotatedDimension.test.js +14 -7
- package/test/entities/arc.test.js +80 -83
- package/test/entities/arctext.test.js +180 -53
- package/test/entities/basePolyline.test.js +129 -2
- package/test/entities/circle.test.js +57 -85
- package/test/entities/entity.test.js +42 -8
- package/test/entities/hatch.test.js +543 -70
- package/test/entities/insert.test.js +96 -1
- package/test/entities/line.test.js +15 -41
- package/test/entities/lwpolyline.test.js +104 -0
- package/test/entities/polyline.test.js +11 -0
- package/test/entities/rectangle.test.js +11 -0
- package/test/entities/solid.test.js +1 -1
- package/test/entities/text.test.js +294 -69
- package/test/integration/exportIntegration.reference.dxf +9 -9
- package/test/integration/exportIntegration.test.js +2 -2
- package/test/integration/intersectionIntegration.test.js +4 -5
- package/test/integration/pdfRendererIntegration.reference.pdf +17709 -0
- package/test/integration/pdfRendererIntegration.test.js +61 -0
- package/test/integration/svgRendererIntegration.reference.svg +3343 -0
- package/test/integration/svgRendererIntegration.test.js +61 -0
- package/test/integration/userInputIntegration.reference.dxf +1165 -105
- package/test/integration/userInputIntegration.test.js +239 -132
- package/test/lib/canvas.test.js +742 -123
- package/test/lib/constants.test.js +27 -0
- package/test/lib/entityManager.test.js +4 -4
- package/test/lib/inputManager.test.js +80 -19
- package/test/lib/intersect.test.js +83 -0
- package/test/lib/plotOptions.test.js +179 -0
- package/test/lib/rubberBand.test.js +84 -0
- package/test/lib/settings.test.js +5 -6
- package/test/lib/snapping.test.js +71 -129
- package/test/lib/stateManager.test.js +7 -7
- package/test/lib/utils.test.js +36 -2
- package/test/properties/entityProperties.test.js +132 -0
- package/test/properties/property.test.js +53 -0
- package/test/properties/propertyManager.test.js +3 -3
- package/test/renderers/canvasRenderer.test.js +317 -0
- package/test/renderers/pdfRenderer.test.js +271 -0
- package/test/renderers/rendererBase.test.js +213 -0
- package/test/renderers/svgRenderer.test.js +326 -0
- package/test/tables/block.test.js +31 -1
- package/test/tables/endblk.test.js +2 -2
- package/test/tables/layer.test.js +30 -0
- package/test/test-helpers/hatchGridRenderer.js +180 -0
- package/test/test-helpers/test-helpers.js +152 -0
- package/test/tools/chamfer.test.js +227 -5
- package/test/tools/chamferFilletBase.test.js +98 -9
- package/test/tools/copy.test.js +2 -2
- package/test/tools/explode.test.js +3 -3
- package/test/tools/extend.test.js +331 -0
- package/test/tools/fillet.test.js +296 -0
- package/test/tools/matchProp.test.js +5 -5
- package/test/tools/mirror.test.js +13 -13
- package/test/tools/offset.test.js +170 -3
- package/test/tools/pasteclip.test.js +5 -5
- package/test/tools/rotate.test.js +32 -2
- package/test/tools/scale.test.js +5 -5
- package/test/tools/trim.test.js +526 -0
- package/test/tools/zoom.test.js +7 -7
- package/core/lib/selectionWindow.js +0 -83
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { DesignCore } from '../designCore.js';
|
|
2
|
-
import { Point } from '../entities/point.js';
|
|
3
|
-
import { Colours } from './colours.js';
|
|
4
|
-
|
|
5
|
-
/** SelectionWindow Class */
|
|
6
|
-
export class SelectionWindow {
|
|
7
|
-
/**
|
|
8
|
-
* Create a SelectionWindow
|
|
9
|
-
* @param {Object} data
|
|
10
|
-
*/
|
|
11
|
-
constructor(data) {
|
|
12
|
-
this.colour = DesignCore.Settings.selectionWindow;
|
|
13
|
-
this.lineWidth = 1;
|
|
14
|
-
this.dashPattern = [];
|
|
15
|
-
|
|
16
|
-
if (data) {
|
|
17
|
-
if (data.hasOwnProperty('points')) {
|
|
18
|
-
if (data.points[1].y > data.points[0].y) {
|
|
19
|
-
this.colour = DesignCore.Settings.selectionWindow;
|
|
20
|
-
this.dashPattern = [5];
|
|
21
|
-
} else {
|
|
22
|
-
this.colour = DesignCore.Settings.crossingWindow;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
this.points = [];
|
|
26
|
-
const point1 = new Point(data.points[0].x, data.points[0].y);
|
|
27
|
-
const point2 = new Point(data.points[1].x, data.points[1].y);
|
|
28
|
-
|
|
29
|
-
this.points.push(point1);
|
|
30
|
-
this.points.push(point2);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Draw the entity
|
|
37
|
-
* @param {Object} ctx - context
|
|
38
|
-
* @param {number} scale
|
|
39
|
-
*/
|
|
40
|
-
draw(ctx, scale) {
|
|
41
|
-
const colour = this.colour;
|
|
42
|
-
ctx.fillStyle = colour;
|
|
43
|
-
|
|
44
|
-
const scaledPattern = this.dashPattern.map((x) => x / scale);
|
|
45
|
-
|
|
46
|
-
try { // HTML Canvas
|
|
47
|
-
ctx.strokeStyle = Colours.rgbToString(colour);
|
|
48
|
-
ctx.fillStyle = Colours.rgbToString(colour);
|
|
49
|
-
ctx.lineWidth = this.lineWidth / scale;
|
|
50
|
-
ctx.beginPath();
|
|
51
|
-
ctx.globalAlpha = 0.2;
|
|
52
|
-
const width = this.points[1].x - this.points[0].x;
|
|
53
|
-
const height = this.points[1].y - this.points[0].y;
|
|
54
|
-
ctx.fillRect(this.points[0].x, this.points[0].y, width, height);
|
|
55
|
-
ctx.globalAlpha = 1.0;
|
|
56
|
-
this.drawRect(ctx);
|
|
57
|
-
ctx.setLineDash(scaledPattern);
|
|
58
|
-
ctx.stroke();
|
|
59
|
-
} catch { // Cairo
|
|
60
|
-
ctx.setLineWidth(this.lineWidth / scale);
|
|
61
|
-
const rgbColour = Colours.rgbToScaledRGB(colour);
|
|
62
|
-
ctx.setSourceRGBA(rgbColour.r, rgbColour.g, rgbColour.b, 0.2);
|
|
63
|
-
this.drawRect(ctx);
|
|
64
|
-
ctx.fillPreserve();
|
|
65
|
-
ctx.setSourceRGB(rgbColour.r, rgbColour.g, rgbColour.b);
|
|
66
|
-
|
|
67
|
-
ctx.setDash(scaledPattern, 1);
|
|
68
|
-
ctx.stroke();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Draw a rectangle
|
|
74
|
-
* @param {Object} ctx
|
|
75
|
-
*/
|
|
76
|
-
drawRect(ctx) {
|
|
77
|
-
ctx.moveTo(this.points[0].x, this.points[0].y);
|
|
78
|
-
ctx.lineTo(this.points[1].x, this.points[0].y);
|
|
79
|
-
ctx.lineTo(this.points[1].x, this.points[1].y);
|
|
80
|
-
ctx.lineTo(this.points[0].x, this.points[1].y);
|
|
81
|
-
ctx.lineTo(this.points[0].x, this.points[0].y);
|
|
82
|
-
}
|
|
83
|
-
}
|