@threekit-tools/treble 0.0.94-next-02 → 0.0.95
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/Treble/Treble.d.ts +2 -2
- package/dist/Treble/Treble.js +2 -2
- package/dist/Treble/index.d.ts +1 -1
- package/dist/Treble/index.js +1 -1
- package/dist/hooks/useNestedConfigurator/index.js +2 -1
- package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +95 -0
- package/dist/hooks/useRoomBuilder/RoomBuilderState.js +1237 -0
- package/dist/hooks/useRoomBuilder/constants.d.ts +41 -0
- package/dist/hooks/useRoomBuilder/constants.js +48 -0
- package/dist/hooks/useRoomBuilder/dataHandlers.d.ts +18 -0
- package/dist/hooks/useRoomBuilder/dataHandlers.js +187 -0
- package/dist/hooks/useRoomBuilder/draw.d.ts +55 -0
- package/dist/hooks/useRoomBuilder/draw.js +573 -0
- package/dist/hooks/useRoomBuilder/findLoops.d.ts +5 -0
- package/dist/hooks/{useSpaces/geometry → useRoomBuilder}/findLoops.js +13 -31
- package/dist/hooks/useRoomBuilder/geometry.d.ts +33 -0
- package/dist/hooks/useRoomBuilder/geometry.js +325 -0
- package/dist/hooks/useRoomBuilder/index.d.ts +40 -0
- package/dist/hooks/useRoomBuilder/index.js +303 -0
- package/dist/hooks/{useSpaces/validators → useRoomBuilder}/messaging.js +1 -1
- package/dist/hooks/{useSpaces/themes/index.d.ts → useRoomBuilder/themes.d.ts} +4 -3
- package/dist/hooks/useRoomBuilder/themes.js +273 -0
- package/dist/hooks/useRoomBuilder/types.d.ts +238 -0
- package/dist/hooks/{useSpaces → useRoomBuilder}/types.js +1 -19
- package/dist/hooks/useRoomBuilder/validators.d.ts +36 -0
- package/dist/hooks/useRoomBuilder/validators.js +362 -0
- package/dist/icons/Draw.js +3 -3
- package/dist/icons/Window.js +4 -4
- package/dist/icons/index.js +0 -28
- package/dist/icons/types.d.ts +1 -1
- package/dist/index.d.ts +2 -17
- package/dist/index.js +5 -35
- package/dist/store/attributes.d.ts +0 -1
- package/dist/store/index.d.ts +0 -10
- package/dist/store/index.js +1 -3
- package/dist/store/product.js +7 -4
- package/dist/store/treble.d.ts +1 -1
- package/dist/store/treble.js +21 -14
- package/dist/types.d.ts +1 -3
- package/package.json +1 -1
- package/dist/hooks/useSpaces/SpacesLayout.d.ts +0 -11
- package/dist/hooks/useSpaces/SpacesLayout.js +0 -74
- package/dist/hooks/useSpaces/SpacesState.d.ts +0 -177
- package/dist/hooks/useSpaces/SpacesState.js +0 -1816
- package/dist/hooks/useSpaces/constants.d.ts +0 -79
- package/dist/hooks/useSpaces/constants.js +0 -130
- package/dist/hooks/useSpaces/dataHandlers.d.ts +0 -38
- package/dist/hooks/useSpaces/dataHandlers.js +0 -407
- package/dist/hooks/useSpaces/draw/clearCanvas.d.ts +0 -2
- package/dist/hooks/useSpaces/draw/clearCanvas.js +0 -9
- package/dist/hooks/useSpaces/draw/drawBackground.d.ts +0 -2
- package/dist/hooks/useSpaces/draw/drawBackground.js +0 -12
- package/dist/hooks/useSpaces/draw/drawDimensions.d.ts +0 -3
- package/dist/hooks/useSpaces/draw/drawDimensions.js +0 -53
- package/dist/hooks/useSpaces/draw/drawDoors.d.ts +0 -9
- package/dist/hooks/useSpaces/draw/drawDoors.js +0 -99
- package/dist/hooks/useSpaces/draw/drawFloor.d.ts +0 -3
- package/dist/hooks/useSpaces/draw/drawFloor.js +0 -36
- package/dist/hooks/useSpaces/draw/drawGrid.d.ts +0 -3
- package/dist/hooks/useSpaces/draw/drawGrid.js +0 -36
- package/dist/hooks/useSpaces/draw/drawGuides.d.ts +0 -3
- package/dist/hooks/useSpaces/draw/drawGuides.js +0 -23
- package/dist/hooks/useSpaces/draw/drawOpenings.d.ts +0 -9
- package/dist/hooks/useSpaces/draw/drawOpenings.js +0 -72
- package/dist/hooks/useSpaces/draw/drawVertices.d.ts +0 -8
- package/dist/hooks/useSpaces/draw/drawVertices.js +0 -61
- package/dist/hooks/useSpaces/draw/drawWalls.d.ts +0 -11
- package/dist/hooks/useSpaces/draw/drawWalls.js +0 -90
- package/dist/hooks/useSpaces/draw/drawWindows.d.ts +0 -9
- package/dist/hooks/useSpaces/draw/drawWindows.js +0 -82
- package/dist/hooks/useSpaces/draw/index.d.ts +0 -11
- package/dist/hooks/useSpaces/draw/index.js +0 -129
- package/dist/hooks/useSpaces/geometry/addThicknessToLine.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/addThicknessToLine.js +0 -13
- package/dist/hooks/useSpaces/geometry/areLinesEqual.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/areLinesEqual.js +0 -17
- package/dist/hooks/useSpaces/geometry/arePointsEqual.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/arePointsEqual.js +0 -8
- package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.js +0 -11
- package/dist/hooks/useSpaces/geometry/closestPointOnLine.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/closestPointOnLine.js +0 -13
- package/dist/hooks/useSpaces/geometry/doLinesOverlap.d.ts +0 -2
- package/dist/hooks/useSpaces/geometry/doLinesOverlap.js +0 -16
- package/dist/hooks/useSpaces/geometry/euclideanMod.d.ts +0 -2
- package/dist/hooks/useSpaces/geometry/euclideanMod.js +0 -6
- package/dist/hooks/useSpaces/geometry/findLoops.d.ts +0 -6
- package/dist/hooks/useSpaces/geometry/getAllLineIntersections.d.ts +0 -6
- package/dist/hooks/useSpaces/geometry/getAllLineIntersections.js +0 -23
- package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.js +0 -7
- package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.js +0 -17
- package/dist/hooks/useSpaces/geometry/getDistanceToLine.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getDistanceToLine.js +0 -10
- package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.js +0 -7
- package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.js +0 -17
- package/dist/hooks/useSpaces/geometry/getLineOtherPoint.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getLineOtherPoint.js +0 -11
- package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.js +0 -43
- package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.js +0 -9
- package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.js +0 -20
- package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.js +0 -11
- package/dist/hooks/useSpaces/geometry/getPolygonArea.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getPolygonArea.js +0 -15
- package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.js +0 -16
- package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.d.ts +0 -6
- package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.js +0 -17
- package/dist/hooks/useSpaces/geometry/getTriangleArea.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getTriangleArea.js +0 -9
- package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.js +0 -12
- package/dist/hooks/useSpaces/geometry/index.d.ts +0 -30
- package/dist/hooks/useSpaces/geometry/index.js +0 -64
- package/dist/hooks/useSpaces/geometry/isPointInPolygon.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/isPointInPolygon.js +0 -21
- package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.js +0 -25
- package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.js +0 -11
- package/dist/hooks/useSpaces/geometry/splitLineAtOffset.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/splitLineAtOffset.js +0 -12
- package/dist/hooks/useSpaces/geometry/splitLineAtPoint.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/splitLineAtPoint.js +0 -9
- package/dist/hooks/useSpaces/geometry/splitLineAtPoints.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/splitLineAtPoints.js +0 -28
- package/dist/hooks/useSpaces/index.d.ts +0 -95
- package/dist/hooks/useSpaces/index.js +0 -557
- package/dist/hooks/useSpaces/themes/blueprint.d.ts +0 -3
- package/dist/hooks/useSpaces/themes/blueprint.js +0 -96
- package/dist/hooks/useSpaces/themes/default.d.ts +0 -3
- package/dist/hooks/useSpaces/themes/default.js +0 -96
- package/dist/hooks/useSpaces/themes/index.js +0 -21
- package/dist/hooks/useSpaces/themes/light.d.ts +0 -3
- package/dist/hooks/useSpaces/themes/light.js +0 -96
- package/dist/hooks/useSpaces/types.d.ts +0 -378
- package/dist/hooks/useSpaces/validators/areWallsDuplicated.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/areWallsDuplicated.js +0 -61
- package/dist/hooks/useSpaces/validators/areWallsIntersecting.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/areWallsIntersecting.js +0 -42
- package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.js +0 -52
- package/dist/hooks/useSpaces/validators/areWallsTooShort.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/areWallsTooShort.js +0 -37
- package/dist/hooks/useSpaces/validators/index.d.ts +0 -15
- package/dist/hooks/useSpaces/validators/index.js +0 -40
- package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.js +0 -31
- package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.js +0 -19
- package/dist/hooks/useSpaces/validators/isLineTooShort.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isLineTooShort.js +0 -26
- package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.d.ts +0 -4
- package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.js +0 -19
- package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.js +0 -19
- package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.js +0 -41
- package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.js +0 -54
- package/dist/hooks/useSpaces/validators/isWallTooShort.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isWallTooShort.js +0 -10
- package/dist/icons/AngleSnapping.d.ts +0 -3
- package/dist/icons/AngleSnapping.js +0 -28
- package/dist/icons/Boundary.d.ts +0 -3
- package/dist/icons/Boundary.js +0 -21
- package/dist/icons/Center.d.ts +0 -3
- package/dist/icons/Center.js +0 -24
- package/dist/icons/GridSnapping.d.ts +0 -3
- package/dist/icons/GridSnapping.js +0 -28
- package/dist/icons/LayoutAlt.d.ts +0 -3
- package/dist/icons/LayoutAlt.js +0 -21
- package/dist/icons/Magnet.d.ts +0 -3
- package/dist/icons/Magnet.js +0 -27
- package/dist/icons/Player3D.d.ts +0 -3
- package/dist/icons/Player3D.js +0 -21
- package/dist/icons/RulerBlank.d.ts +0 -3
- package/dist/icons/RulerBlank.js +0 -25
- package/dist/icons/RulerDetailed.d.ts +0 -3
- package/dist/icons/RulerDetailed.js +0 -27
- package/dist/icons/Save.d.ts +0 -3
- package/dist/icons/Save.js +0 -21
- package/dist/icons/UnitCm.d.ts +0 -3
- package/dist/icons/UnitCm.js +0 -22
- package/dist/icons/UnitFeet.d.ts +0 -3
- package/dist/icons/UnitFeet.js +0 -22
- package/dist/icons/UnitInch.d.ts +0 -3
- package/dist/icons/UnitInch.js +0 -22
- package/dist/icons/UnitMeter.d.ts +0 -3
- package/dist/icons/UnitMeter.js +0 -21
- package/dist/store/spaces.d.ts +0 -74
- package/dist/store/spaces.js +0 -354
- /package/dist/Treble/{snapshot.d.ts → snapshots.d.ts} +0 -0
- /package/dist/Treble/{snapshot.js → snapshots.js} +0 -0
- /package/dist/hooks/{useSpaces/validators → useRoomBuilder}/messaging.d.ts +0 -0
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.drawRoom = exports.drawElements = exports.drawOpenings = exports.drawDoors = exports.drawWindows = exports.drawDimensions = exports.drawVertices = exports.drawWalls = exports.drawNewWall = exports.drawVertex = exports.drawFloor = exports.drawGrid = exports.drawBackground = exports.clearCanvas = void 0;
|
|
13
|
+
var types_1 = require("./types");
|
|
14
|
+
var types_2 = require("./types");
|
|
15
|
+
var geometry_1 = require("./geometry");
|
|
16
|
+
var debug = false;
|
|
17
|
+
function clearCanvas(canvas) {
|
|
18
|
+
var ctx = canvas.getContext('2d');
|
|
19
|
+
if (!ctx)
|
|
20
|
+
return;
|
|
21
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
22
|
+
}
|
|
23
|
+
exports.clearCanvas = clearCanvas;
|
|
24
|
+
function drawBackground(canvas, color) {
|
|
25
|
+
if (!color)
|
|
26
|
+
return;
|
|
27
|
+
var ctx = canvas.getContext('2d');
|
|
28
|
+
if (!ctx)
|
|
29
|
+
return;
|
|
30
|
+
ctx.fillStyle = color;
|
|
31
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
32
|
+
}
|
|
33
|
+
exports.drawBackground = drawBackground;
|
|
34
|
+
function drawGrid(canvas, styles) {
|
|
35
|
+
var ctx = canvas.getContext('2d');
|
|
36
|
+
if (!ctx)
|
|
37
|
+
return;
|
|
38
|
+
ctx.strokeStyle = styles.lineColor;
|
|
39
|
+
var numHorizontalLines = Math.ceil(canvas.width / styles.gridStepGap);
|
|
40
|
+
var numVerticalLines = Math.ceil(canvas.height / styles.gridStepGap);
|
|
41
|
+
for (var i = 0; i < numHorizontalLines; i++) {
|
|
42
|
+
var y = i * styles.gridStepGap;
|
|
43
|
+
ctx.lineWidth =
|
|
44
|
+
styles.secondaryLineIncrement !== undefined &&
|
|
45
|
+
i % styles.secondaryLineIncrement === 0
|
|
46
|
+
? styles.secondaryLineThickness
|
|
47
|
+
: styles.lineThickness;
|
|
48
|
+
ctx.beginPath();
|
|
49
|
+
ctx.moveTo(0, y);
|
|
50
|
+
ctx.lineTo(canvas.width, y);
|
|
51
|
+
ctx.stroke();
|
|
52
|
+
}
|
|
53
|
+
for (var i = 0; i < numVerticalLines; i++) {
|
|
54
|
+
var x = i * styles.gridStepGap;
|
|
55
|
+
ctx.lineWidth =
|
|
56
|
+
styles.secondaryLineIncrement !== undefined &&
|
|
57
|
+
i % styles.secondaryLineIncrement === 0
|
|
58
|
+
? styles.secondaryLineThickness
|
|
59
|
+
: styles.lineThickness;
|
|
60
|
+
ctx.beginPath();
|
|
61
|
+
ctx.moveTo(x, 0);
|
|
62
|
+
ctx.lineTo(x, canvas.height);
|
|
63
|
+
ctx.stroke();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.drawGrid = drawGrid;
|
|
67
|
+
function drawFloor(canvas, enclosedSpaces, styles) {
|
|
68
|
+
var ctx = canvas.getContext('2d');
|
|
69
|
+
if (!ctx)
|
|
70
|
+
return;
|
|
71
|
+
if (!enclosedSpaces.length)
|
|
72
|
+
return;
|
|
73
|
+
for (var _i = 0, enclosedSpaces_1 = enclosedSpaces; _i < enclosedSpaces_1.length; _i++) {
|
|
74
|
+
var enclosedSpace = enclosedSpaces_1[_i];
|
|
75
|
+
var loop = enclosedSpace.loop;
|
|
76
|
+
ctx.fillStyle = styles.color;
|
|
77
|
+
if (debug)
|
|
78
|
+
ctx.fillStyle = 'rgba(255,0,0,.2)';
|
|
79
|
+
ctx.beginPath();
|
|
80
|
+
ctx.moveTo.apply(ctx, loop[0]);
|
|
81
|
+
for (var i = 1; i < loop.length; i++)
|
|
82
|
+
ctx.lineTo.apply(ctx, loop[i]);
|
|
83
|
+
ctx.fill();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.drawFloor = drawFloor;
|
|
87
|
+
function drawWall(canvas, wall, style, mode) {
|
|
88
|
+
var _a;
|
|
89
|
+
var ctx = canvas.getContext('2d');
|
|
90
|
+
if (!ctx)
|
|
91
|
+
return;
|
|
92
|
+
var path = (_a = wall.path) !== null && _a !== void 0 ? _a : (0, geometry_1.addThicknessToLine)(wall.line, style.thickness);
|
|
93
|
+
var stroke = style.stroke, fill = style.fill, strokeWidth = style.strokeWidth;
|
|
94
|
+
if (mode) {
|
|
95
|
+
stroke = style[mode].stroke;
|
|
96
|
+
fill = style[mode].fill;
|
|
97
|
+
}
|
|
98
|
+
ctx.strokeStyle = stroke || fill;
|
|
99
|
+
ctx.fillStyle = fill;
|
|
100
|
+
ctx.lineWidth = strokeWidth || 1;
|
|
101
|
+
ctx.beginPath();
|
|
102
|
+
ctx.moveTo.apply(ctx, path[0]);
|
|
103
|
+
for (var i = 1; i < path.length; i++) {
|
|
104
|
+
ctx.lineTo.apply(ctx, path[i]);
|
|
105
|
+
}
|
|
106
|
+
ctx.lineTo.apply(ctx, path[0]);
|
|
107
|
+
ctx.fill();
|
|
108
|
+
if (style.stroke && style.strokeWidth)
|
|
109
|
+
ctx.stroke();
|
|
110
|
+
}
|
|
111
|
+
function drawFloorArea(canvas, enclosedSpaces, styles) {
|
|
112
|
+
var ctx = canvas.getContext('2d');
|
|
113
|
+
if (!ctx)
|
|
114
|
+
return;
|
|
115
|
+
if (!enclosedSpaces.length)
|
|
116
|
+
return;
|
|
117
|
+
for (var _i = 0, enclosedSpaces_2 = enclosedSpaces; _i < enclosedSpaces_2.length; _i++) {
|
|
118
|
+
var enclosedSpace = enclosedSpaces_2[_i];
|
|
119
|
+
var center = enclosedSpace.center, area = enclosedSpace.area;
|
|
120
|
+
ctx.font = '20px Arial';
|
|
121
|
+
ctx.fillStyle = styles.textColor;
|
|
122
|
+
ctx.fillText(area, center[0], center[1]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function drawDimension(canvas, line, styles, message) {
|
|
126
|
+
var ctx = canvas.getContext('2d');
|
|
127
|
+
if (!ctx)
|
|
128
|
+
return;
|
|
129
|
+
var dimensionsBoxHeight = styles.fontSize + 6;
|
|
130
|
+
var dimensionsHeight = dimensionsBoxHeight + 6;
|
|
131
|
+
var line1 = (0, geometry_1.getParallelLineSegmentAtDistance)(line, styles.padding);
|
|
132
|
+
var line2 = (0, geometry_1.getParallelLineSegmentAtDistance)(line, styles.padding + dimensionsHeight / 2);
|
|
133
|
+
var line3 = (0, geometry_1.getParallelLineSegmentAtDistance)(line, styles.padding + dimensionsHeight);
|
|
134
|
+
var textLine = (0, geometry_1.getParallelLineSegmentAtDistance)(line, styles.padding + dimensionsHeight / 2 - dimensionsBoxHeight / 2);
|
|
135
|
+
var textCoordinates = (0, geometry_1.getMidpointOfLineSegment)(textLine);
|
|
136
|
+
var textAngle = (0, geometry_1.getAngleOfLineSegment)(textLine);
|
|
137
|
+
ctx.strokeStyle = styles.lineColor;
|
|
138
|
+
ctx.lineWidth = 1;
|
|
139
|
+
ctx.beginPath();
|
|
140
|
+
ctx.moveTo.apply(ctx, line2[0]);
|
|
141
|
+
ctx.lineTo.apply(ctx, line2[1]);
|
|
142
|
+
ctx.stroke();
|
|
143
|
+
ctx.beginPath();
|
|
144
|
+
ctx.moveTo.apply(ctx, line1[0]);
|
|
145
|
+
ctx.lineTo.apply(ctx, line3[0]);
|
|
146
|
+
ctx.stroke();
|
|
147
|
+
ctx.beginPath();
|
|
148
|
+
ctx.moveTo.apply(ctx, line1[1]);
|
|
149
|
+
ctx.lineTo.apply(ctx, line3[1]);
|
|
150
|
+
ctx.stroke();
|
|
151
|
+
ctx.beginPath();
|
|
152
|
+
ctx.font = "".concat(styles.fontSize, "px ").concat(styles.font);
|
|
153
|
+
ctx.font = "".concat(styles.fontSize, "px ").concat(styles.font);
|
|
154
|
+
ctx.translate.apply(ctx, textCoordinates);
|
|
155
|
+
ctx.rotate(textAngle);
|
|
156
|
+
ctx.fillStyle = styles.textBackgroundColor;
|
|
157
|
+
var textWidth = ctx.measureText(message).width + 12;
|
|
158
|
+
ctx.fillRect(-(textWidth / 2), -((dimensionsBoxHeight * 3) / 4), textWidth, dimensionsBoxHeight);
|
|
159
|
+
ctx.fillStyle = styles.textColor;
|
|
160
|
+
ctx.textAlign = 'center';
|
|
161
|
+
ctx.fillText(message, 0, 0);
|
|
162
|
+
ctx.resetTransform();
|
|
163
|
+
}
|
|
164
|
+
function drawVertex(canvas, point, style, mode) {
|
|
165
|
+
var ctx = canvas.getContext('2d');
|
|
166
|
+
if (!ctx)
|
|
167
|
+
return;
|
|
168
|
+
var stroke = style.stroke, innerFill = style.innerFill, outerFill = style.outerFill, strokeWidth = style.strokeWidth, outerRadius = style.outerRadius;
|
|
169
|
+
if (mode) {
|
|
170
|
+
stroke = style[mode].stroke;
|
|
171
|
+
innerFill = style[mode].innerFill;
|
|
172
|
+
outerFill = style[mode].outerFill;
|
|
173
|
+
}
|
|
174
|
+
ctx.lineWidth = strokeWidth || 1;
|
|
175
|
+
ctx.strokeStyle = stroke || innerFill;
|
|
176
|
+
ctx.fillStyle = outerFill;
|
|
177
|
+
if (outerRadius) {
|
|
178
|
+
ctx.beginPath();
|
|
179
|
+
ctx.arc(point[0], point[1], outerRadius, 0, 2 * Math.PI);
|
|
180
|
+
if (style.strokeWidth)
|
|
181
|
+
ctx.stroke();
|
|
182
|
+
ctx.fill();
|
|
183
|
+
}
|
|
184
|
+
ctx.lineWidth = strokeWidth || 1;
|
|
185
|
+
ctx.fillStyle = innerFill;
|
|
186
|
+
ctx.strokeStyle = stroke || innerFill;
|
|
187
|
+
ctx.beginPath();
|
|
188
|
+
ctx.arc(point[0], point[1], style.innerRadius, 0, 2 * Math.PI);
|
|
189
|
+
ctx.fill();
|
|
190
|
+
if (!outerRadius && strokeWidth)
|
|
191
|
+
ctx.stroke();
|
|
192
|
+
if (debug) {
|
|
193
|
+
ctx.font = '20px Arial';
|
|
194
|
+
ctx.fillStyle = 'red';
|
|
195
|
+
ctx.fillText.apply(ctx, __spreadArray([Math.round(point[0]) + ',' + Math.round(point[1])], point, false));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.drawVertex = drawVertex;
|
|
199
|
+
function drawWindow(canvas, wall, offset, length, style, mode) {
|
|
200
|
+
var ctx = canvas.getContext('2d');
|
|
201
|
+
if (!ctx)
|
|
202
|
+
return;
|
|
203
|
+
var windowLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(wall.line, offset, length);
|
|
204
|
+
var windowRectangleLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(wall.line, offset + style.thickness / 2, length - style.thickness);
|
|
205
|
+
var points = (0, geometry_1.addThicknessToLine)(windowLine, style.thickness);
|
|
206
|
+
var rectanglePoints = (0, geometry_1.addThicknessToLine)(windowRectangleLine, style.thickness);
|
|
207
|
+
var stroke = style.stroke, fill = style.fill, strokeWidth = style.strokeWidth;
|
|
208
|
+
if (mode) {
|
|
209
|
+
stroke = style[mode].stroke;
|
|
210
|
+
fill = style[mode].fill;
|
|
211
|
+
}
|
|
212
|
+
ctx.fillStyle = 'white';
|
|
213
|
+
ctx.beginPath();
|
|
214
|
+
ctx.moveTo.apply(ctx, points[0]);
|
|
215
|
+
for (var i = 1; i < points.length; i++) {
|
|
216
|
+
ctx.lineTo.apply(ctx, points[i]);
|
|
217
|
+
}
|
|
218
|
+
ctx.lineTo.apply(ctx, points[0]);
|
|
219
|
+
ctx.fill();
|
|
220
|
+
ctx.closePath();
|
|
221
|
+
ctx.strokeStyle = stroke || fill;
|
|
222
|
+
ctx.fillStyle = fill;
|
|
223
|
+
ctx.lineWidth = strokeWidth || 1;
|
|
224
|
+
ctx.moveTo.apply(ctx, rectanglePoints[0]);
|
|
225
|
+
ctx.beginPath();
|
|
226
|
+
for (var i = 1; i < points.length; i++) {
|
|
227
|
+
ctx.lineTo.apply(ctx, rectanglePoints[i]);
|
|
228
|
+
}
|
|
229
|
+
ctx.lineTo.apply(ctx, rectanglePoints[0]);
|
|
230
|
+
ctx.fill();
|
|
231
|
+
ctx.closePath();
|
|
232
|
+
ctx.beginPath();
|
|
233
|
+
ctx.moveTo.apply(ctx, windowLine[0]);
|
|
234
|
+
ctx.lineTo.apply(ctx, windowLine[1]);
|
|
235
|
+
if (style.stroke)
|
|
236
|
+
ctx.stroke();
|
|
237
|
+
ctx.closePath();
|
|
238
|
+
var angle = (0, geometry_1.getAngleOfLineSegment)(windowLine);
|
|
239
|
+
ctx.beginPath();
|
|
240
|
+
ctx.arc(windowLine[0][0], windowLine[0][1], style.thickness / 2, angle - Math.PI / 2, angle + Math.PI / 2);
|
|
241
|
+
ctx.fill();
|
|
242
|
+
ctx.closePath();
|
|
243
|
+
ctx.beginPath();
|
|
244
|
+
ctx.arc(windowLine[1][0], windowLine[1][1], style.thickness / 2, angle + Math.PI / 2, angle - Math.PI / 2);
|
|
245
|
+
ctx.fill();
|
|
246
|
+
}
|
|
247
|
+
function drawDoor(canvas, wall, offset, length, style, mode) {
|
|
248
|
+
var ctx = canvas.getContext('2d');
|
|
249
|
+
if (!ctx)
|
|
250
|
+
return;
|
|
251
|
+
var doorLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(wall.line, offset, length);
|
|
252
|
+
var points = (0, geometry_1.addThicknessToLine)(doorLine, style.thickness);
|
|
253
|
+
var stroke = style.stroke, fill = style.fill, strokeWidth = style.strokeWidth;
|
|
254
|
+
if (mode) {
|
|
255
|
+
stroke = style[mode].stroke;
|
|
256
|
+
fill = style[mode].fill;
|
|
257
|
+
}
|
|
258
|
+
ctx.strokeStyle = stroke || fill;
|
|
259
|
+
ctx.fillStyle = fill;
|
|
260
|
+
ctx.lineWidth = strokeWidth || 1;
|
|
261
|
+
ctx.beginPath();
|
|
262
|
+
ctx.moveTo.apply(ctx, points[0]);
|
|
263
|
+
for (var i = 1; i < points.length; i++) {
|
|
264
|
+
ctx.lineTo.apply(ctx, points[i]);
|
|
265
|
+
}
|
|
266
|
+
ctx.lineTo.apply(ctx, points[0]);
|
|
267
|
+
ctx.fill();
|
|
268
|
+
if (style.stroke)
|
|
269
|
+
ctx.stroke();
|
|
270
|
+
}
|
|
271
|
+
function drawOpening(canvas, wall, offset, length, style, mode) {
|
|
272
|
+
var ctx = canvas.getContext('2d');
|
|
273
|
+
if (!ctx)
|
|
274
|
+
return;
|
|
275
|
+
var openingLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(wall.line, offset, length);
|
|
276
|
+
var points = (0, geometry_1.addThicknessToLine)(openingLine, style.thickness);
|
|
277
|
+
var stroke = style.stroke, fill = style.fill, strokeWidth = style.strokeWidth;
|
|
278
|
+
if (mode) {
|
|
279
|
+
stroke = style[mode].stroke;
|
|
280
|
+
fill = style[mode].fill;
|
|
281
|
+
}
|
|
282
|
+
ctx.fillStyle = 'white';
|
|
283
|
+
ctx.beginPath();
|
|
284
|
+
ctx.moveTo.apply(ctx, points[0]);
|
|
285
|
+
for (var i = 1; i < points.length; i++) {
|
|
286
|
+
ctx.lineTo.apply(ctx, points[i]);
|
|
287
|
+
}
|
|
288
|
+
ctx.lineTo.apply(ctx, points[0]);
|
|
289
|
+
ctx.fill();
|
|
290
|
+
ctx.beginPath();
|
|
291
|
+
ctx.strokeStyle = stroke || fill;
|
|
292
|
+
ctx.fillStyle = fill;
|
|
293
|
+
ctx.lineWidth = strokeWidth || 1;
|
|
294
|
+
ctx.setLineDash([10, 10]);
|
|
295
|
+
ctx.moveTo.apply(ctx, openingLine[0]);
|
|
296
|
+
ctx.lineTo.apply(ctx, openingLine[1]);
|
|
297
|
+
ctx.stroke();
|
|
298
|
+
ctx.closePath();
|
|
299
|
+
ctx.beginPath();
|
|
300
|
+
ctx.setLineDash([]);
|
|
301
|
+
var angle = (0, geometry_1.getAngleOfLineSegment)(openingLine);
|
|
302
|
+
ctx.arc(openingLine[0][0], openingLine[0][1], style.thickness / 2, angle - Math.PI / 2, angle + Math.PI / 2);
|
|
303
|
+
ctx.fill();
|
|
304
|
+
ctx.closePath();
|
|
305
|
+
ctx.beginPath();
|
|
306
|
+
ctx.arc(openingLine[1][0], openingLine[1][1], style.thickness / 2, angle + Math.PI / 2, angle - Math.PI / 2);
|
|
307
|
+
ctx.fill();
|
|
308
|
+
}
|
|
309
|
+
function drawNewWall(canvas, line, styles, mode) {
|
|
310
|
+
drawWall(canvas, {
|
|
311
|
+
line: line,
|
|
312
|
+
path: (0, geometry_1.addThicknessToLine)(line, styles.wall.thickness),
|
|
313
|
+
}, styles.wall, mode !== null && mode !== void 0 ? mode : types_1.IElementStyleModes.ACTIVE);
|
|
314
|
+
line.forEach(function (point) {
|
|
315
|
+
return drawVertex(canvas, point, styles.vertex, mode !== null && mode !== void 0 ? mode : types_1.IElementStyleModes.HIGHLIGHT);
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
exports.drawNewWall = drawNewWall;
|
|
319
|
+
function drawWalls(canvas, walls, selections, styles) {
|
|
320
|
+
var styled = [
|
|
321
|
+
selections.active,
|
|
322
|
+
selections.highlighted,
|
|
323
|
+
selections.error,
|
|
324
|
+
selections.hidden,
|
|
325
|
+
];
|
|
326
|
+
var defaultOpenings = walls.reduce(function (output, _, i) {
|
|
327
|
+
if (!styled.flat().includes(i))
|
|
328
|
+
output.push(i);
|
|
329
|
+
return output;
|
|
330
|
+
}, []);
|
|
331
|
+
var wallsMap = [
|
|
332
|
+
[types_1.IElementStyleModes.ACTIVE, selections.active],
|
|
333
|
+
[types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
|
|
334
|
+
[types_1.IElementStyleModes.ERROR, selections.error],
|
|
335
|
+
[undefined, defaultOpenings],
|
|
336
|
+
];
|
|
337
|
+
wallsMap.forEach(function (_a) {
|
|
338
|
+
var mode = _a[0], wallIndexes = _a[1];
|
|
339
|
+
return wallIndexes.forEach(function (index) { return drawWall(canvas, walls[index], styles, mode); });
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
exports.drawWalls = drawWalls;
|
|
343
|
+
function drawVertices(canvas, vertices, selections, styles) {
|
|
344
|
+
var styled = [
|
|
345
|
+
selections.active,
|
|
346
|
+
selections.highlighted,
|
|
347
|
+
selections.error,
|
|
348
|
+
selections.hidden,
|
|
349
|
+
];
|
|
350
|
+
var defaultOpenings = vertices.reduce(function (output, _, i) {
|
|
351
|
+
if (!styled.flat().includes(i))
|
|
352
|
+
output.push(i);
|
|
353
|
+
return output;
|
|
354
|
+
}, []);
|
|
355
|
+
var verticesMap = [
|
|
356
|
+
[types_1.IElementStyleModes.ACTIVE, selections.active],
|
|
357
|
+
[types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
|
|
358
|
+
[types_1.IElementStyleModes.ERROR, selections.error],
|
|
359
|
+
[undefined, defaultOpenings],
|
|
360
|
+
];
|
|
361
|
+
verticesMap.forEach(function (_a) {
|
|
362
|
+
var mode = _a[0], vertexIndexes = _a[1];
|
|
363
|
+
return vertexIndexes.forEach(function (index) {
|
|
364
|
+
var point = vertices[index].point;
|
|
365
|
+
drawVertex(canvas, point, styles, mode);
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
exports.drawVertices = drawVertices;
|
|
370
|
+
function drawDimensions(canvas, dimensions, config) {
|
|
371
|
+
dimensions.forEach(function (_a) {
|
|
372
|
+
var line = _a.line, label = _a.label;
|
|
373
|
+
drawDimension(canvas, line, config.styles.dimensions, label);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
exports.drawDimensions = drawDimensions;
|
|
377
|
+
function drawWindows(canvas, walls, windows, selections, styles) {
|
|
378
|
+
var styled = [
|
|
379
|
+
selections.active,
|
|
380
|
+
selections.highlighted,
|
|
381
|
+
selections.error,
|
|
382
|
+
selections.hidden,
|
|
383
|
+
];
|
|
384
|
+
var defaultOpenings = windows.reduce(function (output, _, i) {
|
|
385
|
+
if (!styled.flat().includes(i))
|
|
386
|
+
output.push(i);
|
|
387
|
+
return output;
|
|
388
|
+
}, []);
|
|
389
|
+
var windowsMap = [
|
|
390
|
+
[types_1.IElementStyleModes.ACTIVE, selections.active],
|
|
391
|
+
[types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
|
|
392
|
+
[types_1.IElementStyleModes.ERROR, selections.error],
|
|
393
|
+
[undefined, defaultOpenings],
|
|
394
|
+
];
|
|
395
|
+
windowsMap.forEach(function (_a) {
|
|
396
|
+
var mode = _a[0], windowIndexes = _a[1];
|
|
397
|
+
return windowIndexes.forEach(function (index) {
|
|
398
|
+
var window = windows[index];
|
|
399
|
+
if (!(window === null || window === void 0 ? void 0 : window.connectedTo.length))
|
|
400
|
+
return;
|
|
401
|
+
var wallIndex = window.connectedTo[1];
|
|
402
|
+
drawWindow(canvas, walls[wallIndex], window.offset, window.length, styles.feature, mode);
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
exports.drawWindows = drawWindows;
|
|
407
|
+
function drawDoors(canvas, walls, doors, selections, styles) {
|
|
408
|
+
var styled = [
|
|
409
|
+
selections.active,
|
|
410
|
+
selections.highlighted,
|
|
411
|
+
selections.error,
|
|
412
|
+
selections.hidden,
|
|
413
|
+
];
|
|
414
|
+
var defaultOpenings = doors.reduce(function (output, _, i) {
|
|
415
|
+
if (!styled.flat().includes(i))
|
|
416
|
+
output.push(i);
|
|
417
|
+
return output;
|
|
418
|
+
}, []);
|
|
419
|
+
var doorsMap = [
|
|
420
|
+
[types_1.IElementStyleModes.ACTIVE, selections.active],
|
|
421
|
+
[types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
|
|
422
|
+
[types_1.IElementStyleModes.ERROR, selections.error],
|
|
423
|
+
[undefined, defaultOpenings],
|
|
424
|
+
];
|
|
425
|
+
doorsMap.forEach(function (_a) {
|
|
426
|
+
var mode = _a[0], doorsIndexes = _a[1];
|
|
427
|
+
return doorsIndexes.forEach(function (index) {
|
|
428
|
+
var door = doors[index];
|
|
429
|
+
if (!(door === null || door === void 0 ? void 0 : door.connectedTo.length))
|
|
430
|
+
return;
|
|
431
|
+
var wallIndex = door.connectedTo[1];
|
|
432
|
+
drawDoor(canvas, walls[wallIndex], door.offset, door.length, styles.feature, mode);
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
exports.drawDoors = drawDoors;
|
|
437
|
+
function drawOpenings(canvas, walls, openings, selections, styles) {
|
|
438
|
+
var styled = [
|
|
439
|
+
selections.active,
|
|
440
|
+
selections.highlighted,
|
|
441
|
+
selections.error,
|
|
442
|
+
selections.hidden,
|
|
443
|
+
];
|
|
444
|
+
var defaultOpenings = openings.reduce(function (output, _, i) {
|
|
445
|
+
if (!styled.flat().includes(i))
|
|
446
|
+
output.push(i);
|
|
447
|
+
return output;
|
|
448
|
+
}, []);
|
|
449
|
+
var openingsMap = [
|
|
450
|
+
[types_1.IElementStyleModes.ACTIVE, selections.active],
|
|
451
|
+
[types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
|
|
452
|
+
[types_1.IElementStyleModes.ERROR, selections.error],
|
|
453
|
+
[undefined, defaultOpenings],
|
|
454
|
+
];
|
|
455
|
+
openingsMap.forEach(function (_a) {
|
|
456
|
+
var mode = _a[0], openingsIndexes = _a[1];
|
|
457
|
+
return openingsIndexes.forEach(function (index) {
|
|
458
|
+
var opening = openings[index];
|
|
459
|
+
if (!(opening === null || opening === void 0 ? void 0 : opening.connectedTo.length))
|
|
460
|
+
return;
|
|
461
|
+
var wallIndex = opening.connectedTo[1];
|
|
462
|
+
drawOpening(canvas, walls[wallIndex], opening.offset, opening.length, styles.feature, mode);
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
exports.drawOpenings = drawOpenings;
|
|
467
|
+
function drawElements(canvas, walls, vertices, features, selections, styles) {
|
|
468
|
+
var wallSelections = {
|
|
469
|
+
active: [],
|
|
470
|
+
highlighted: [],
|
|
471
|
+
hidden: [],
|
|
472
|
+
error: [],
|
|
473
|
+
};
|
|
474
|
+
var verticesSelections = {
|
|
475
|
+
active: [],
|
|
476
|
+
highlighted: [],
|
|
477
|
+
hidden: [],
|
|
478
|
+
error: [],
|
|
479
|
+
};
|
|
480
|
+
var windowSelections = {
|
|
481
|
+
active: [],
|
|
482
|
+
highlighted: [],
|
|
483
|
+
hidden: [],
|
|
484
|
+
error: [],
|
|
485
|
+
};
|
|
486
|
+
var doorSelections = {
|
|
487
|
+
active: [],
|
|
488
|
+
highlighted: [],
|
|
489
|
+
hidden: [],
|
|
490
|
+
error: [],
|
|
491
|
+
};
|
|
492
|
+
var openingSelections = {
|
|
493
|
+
active: [],
|
|
494
|
+
highlighted: [],
|
|
495
|
+
hidden: [],
|
|
496
|
+
error: [],
|
|
497
|
+
};
|
|
498
|
+
selections.active.forEach(function (address) {
|
|
499
|
+
if (address.type === types_2.IElements.WALL)
|
|
500
|
+
wallSelections.active.push(address.index);
|
|
501
|
+
else if (address.type === types_2.IElements.VERTEX)
|
|
502
|
+
verticesSelections.active.push(address.index);
|
|
503
|
+
else if (address.type === types_2.IElements.WINDOW)
|
|
504
|
+
windowSelections.active.push(address.index);
|
|
505
|
+
else if (address.type === types_2.IElements.DOOR)
|
|
506
|
+
doorSelections.active.push(address.index);
|
|
507
|
+
else if (address.type === types_2.IElements.OPENING)
|
|
508
|
+
openingSelections.active.push(address.index);
|
|
509
|
+
});
|
|
510
|
+
selections.highlighted.forEach(function (address) {
|
|
511
|
+
if (address.type === types_2.IElements.WALL)
|
|
512
|
+
wallSelections.highlighted.push(address.index);
|
|
513
|
+
else if (address.type === types_2.IElements.VERTEX)
|
|
514
|
+
verticesSelections.highlighted.push(address.index);
|
|
515
|
+
else if (address.type === types_2.IElements.WINDOW)
|
|
516
|
+
windowSelections.highlighted.push(address.index);
|
|
517
|
+
else if (address.type === types_2.IElements.DOOR)
|
|
518
|
+
doorSelections.highlighted.push(address.index);
|
|
519
|
+
else if (address.type === types_2.IElements.OPENING)
|
|
520
|
+
openingSelections.highlighted.push(address.index);
|
|
521
|
+
});
|
|
522
|
+
selections.hidden.forEach(function (address) {
|
|
523
|
+
if (address.type === types_2.IElements.WALL)
|
|
524
|
+
wallSelections.hidden.push(address.index);
|
|
525
|
+
else if (address.type === types_2.IElements.VERTEX)
|
|
526
|
+
verticesSelections.hidden.push(address.index);
|
|
527
|
+
else if (address.type === types_2.IElements.WINDOW)
|
|
528
|
+
windowSelections.hidden.push(address.index);
|
|
529
|
+
else if (address.type === types_2.IElements.DOOR)
|
|
530
|
+
doorSelections.hidden.push(address.index);
|
|
531
|
+
else if (address.type === types_2.IElements.OPENING)
|
|
532
|
+
openingSelections.hidden.push(address.index);
|
|
533
|
+
});
|
|
534
|
+
selections.error.forEach(function (address) {
|
|
535
|
+
if (address.type === types_2.IElements.WALL)
|
|
536
|
+
wallSelections.error.push(address.index);
|
|
537
|
+
else if (address.type === types_2.IElements.VERTEX)
|
|
538
|
+
verticesSelections.error.push(address.index);
|
|
539
|
+
else if (address.type === types_2.IElements.WINDOW)
|
|
540
|
+
windowSelections.error.push(address.index);
|
|
541
|
+
else if (address.type === types_2.IElements.DOOR)
|
|
542
|
+
doorSelections.error.push(address.index);
|
|
543
|
+
else if (address.type === types_2.IElements.OPENING)
|
|
544
|
+
openingSelections.error.push(address.index);
|
|
545
|
+
});
|
|
546
|
+
drawWalls(canvas, walls, wallSelections, styles.wall);
|
|
547
|
+
drawVertices(canvas, vertices, verticesSelections, styles.vertex);
|
|
548
|
+
if (features[types_2.IElements.WINDOW])
|
|
549
|
+
drawWindows(canvas, walls, features[types_2.IElements.WINDOW] || [], windowSelections, styles);
|
|
550
|
+
if (features[types_2.IElements.DOOR])
|
|
551
|
+
drawDoors(canvas, walls, features[types_2.IElements.DOOR] || [], doorSelections, styles);
|
|
552
|
+
if (features[types_2.IElements.OPENING])
|
|
553
|
+
drawOpenings(canvas, walls, features[types_2.IElements.OPENING] || [], openingSelections, styles);
|
|
554
|
+
}
|
|
555
|
+
exports.drawElements = drawElements;
|
|
556
|
+
function drawRoom(canvas, enclosedSpaces, walls, vertices, features, dimensions, selections, config) {
|
|
557
|
+
var preppedSelections = {
|
|
558
|
+
active: [(selections === null || selections === void 0 ? void 0 : selections.active) || []].flat(),
|
|
559
|
+
highlighted: [(selections === null || selections === void 0 ? void 0 : selections.highlighted) || []].flat(),
|
|
560
|
+
error: [(selections === null || selections === void 0 ? void 0 : selections.error) || []].flat(),
|
|
561
|
+
hidden: [(selections === null || selections === void 0 ? void 0 : selections.hidden) || []].flat(),
|
|
562
|
+
};
|
|
563
|
+
clearCanvas(canvas);
|
|
564
|
+
drawBackground(canvas, config.styles.grid.backgroundColor);
|
|
565
|
+
drawGrid(canvas, config.styles.grid);
|
|
566
|
+
drawFloor(canvas, enclosedSpaces, config.styles.floor);
|
|
567
|
+
drawElements(canvas, walls, vertices, features, preppedSelections, config.styles);
|
|
568
|
+
if (dimensions) {
|
|
569
|
+
drawDimensions(canvas, dimensions, config);
|
|
570
|
+
drawFloorArea(canvas, enclosedSpaces, config.styles.floor);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
exports.drawRoom = drawRoom;
|
|
@@ -8,18 +8,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
8
8
|
}
|
|
9
9
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
var getAngleOfLineSegment_1 = __importDefault(require("./getAngleOfLineSegment"));
|
|
18
|
-
var getLineOtherPoint_1 = __importDefault(require("./getLineOtherPoint"));
|
|
12
|
+
exports.findLoops = void 0;
|
|
13
|
+
var geometry_1 = require("./geometry");
|
|
19
14
|
var areSidesEqual = function (_a, _b) {
|
|
20
15
|
var lineIndex0 = _a[0], fromPoint0 = _a[1];
|
|
21
16
|
var lineIndex1 = _b[0], fromPoint1 = _b[1];
|
|
22
|
-
return lineIndex0 === lineIndex1 && (0,
|
|
17
|
+
return lineIndex0 === lineIndex1 && (0, geometry_1.arePointsEqual)(fromPoint0, fromPoint1);
|
|
23
18
|
};
|
|
24
19
|
var composeSideKey = function (_a) {
|
|
25
20
|
var lineIndex = _a[0], point = _a[1];
|
|
@@ -48,8 +43,8 @@ function findLoops(lines) {
|
|
|
48
43
|
function nextAdjacentWallSide(side) {
|
|
49
44
|
var lineIndex = side[0], fromPoint = side[1];
|
|
50
45
|
var line = lines[lineIndex];
|
|
51
|
-
var toPoint = (0,
|
|
52
|
-
var lineAng = (0,
|
|
46
|
+
var toPoint = (0, geometry_1.getLineOtherPoint)(line, fromPoint);
|
|
47
|
+
var lineAng = (0, geometry_1.getAngleOfLineSegment)([fromPoint, toPoint]);
|
|
53
48
|
var adjacentLineIndices = pointToLinesIndices[JSON.stringify(toPoint)];
|
|
54
49
|
var nextLineIndex;
|
|
55
50
|
if (adjacentLineIndices.length === 0)
|
|
@@ -65,9 +60,9 @@ function findLoops(lines) {
|
|
|
65
60
|
if (adjacentLineIndex === lineIndex)
|
|
66
61
|
continue;
|
|
67
62
|
var adjacentLine = lines[adjacentLineIndex];
|
|
68
|
-
var adjacentPoint = (0,
|
|
69
|
-
var adjacentLineAng = (0,
|
|
70
|
-
var angDiff = (0,
|
|
63
|
+
var adjacentPoint = (0, geometry_1.getLineOtherPoint)(adjacentLine, toPoint);
|
|
64
|
+
var adjacentLineAng = (0, geometry_1.getAngleOfLineSegment)([toPoint, adjacentPoint]);
|
|
65
|
+
var angDiff = (0, geometry_1.euclideanMod)(lineAng - adjacentLineAng + Math.PI, Math.PI * 2);
|
|
71
66
|
if (angDiff < smallestAngDiff) {
|
|
72
67
|
smallestAngDiff = angDiff;
|
|
73
68
|
nextLineIndex = adjacentLineIndex;
|
|
@@ -82,11 +77,7 @@ function findLoops(lines) {
|
|
|
82
77
|
var curr = start;
|
|
83
78
|
do {
|
|
84
79
|
path.push(curr[1]);
|
|
85
|
-
|
|
86
|
-
if (!unvisitedSides.has(currSideKey)) {
|
|
87
|
-
throw new Error('Unexpected case when computing floor area (are there parallel overlapping walls?)');
|
|
88
|
-
}
|
|
89
|
-
unvisitedSides.delete(currSideKey);
|
|
80
|
+
unvisitedSides.delete(composeSideKey(curr));
|
|
90
81
|
curr = nextAdjacentWallSide(curr);
|
|
91
82
|
} while (!areSidesEqual(start, curr));
|
|
92
83
|
return path;
|
|
@@ -96,22 +87,13 @@ function findLoops(lines) {
|
|
|
96
87
|
while (unvisitedSides.size > 0) {
|
|
97
88
|
sumCurvature = 0;
|
|
98
89
|
var start = decomposeSideKey(unvisitedSides.values().next().value);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
(isClockwise ? innerLoops : outerLoops).push(path);
|
|
103
|
-
}
|
|
104
|
-
catch (e) {
|
|
105
|
-
console.log(e);
|
|
106
|
-
return {
|
|
107
|
-
inner: innerLoops,
|
|
108
|
-
outer: outerLoops,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
90
|
+
var path = traverseLoop(start);
|
|
91
|
+
var isClockwise = sumCurvature < 0;
|
|
92
|
+
(isClockwise ? innerLoops : outerLoops).push(path);
|
|
111
93
|
}
|
|
112
94
|
return {
|
|
113
95
|
inner: innerLoops,
|
|
114
96
|
outer: outerLoops,
|
|
115
97
|
};
|
|
116
98
|
}
|
|
117
|
-
exports.
|
|
99
|
+
exports.findLoops = findLoops;
|