kitchen-simulator 4.0.0-react-18 → 4.0.2-react-18
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/es/LiteKitchenConfigurator.js +7 -17
- package/es/LiteRenderer.js +0 -3
- package/es/components/content.js +91 -0
- package/es/components/viewer2d/item.js +296 -311
- package/es/components/viewer2d/rulerX.js +2 -1
- package/lib/LiteKitchenConfigurator.js +7 -17
- package/lib/LiteRenderer.js +0 -3
- package/lib/components/content.js +92 -1
- package/lib/components/viewer2d/item.js +294 -309
- package/lib/components/viewer2d/rulerX.js +2 -1
- package/package.json +1 -1
- package/es/plugins/console-debugger.js +0 -34
- package/es/plugins/export.js +0 -7
- package/es/plugins/keyboard.js +0 -110
- package/lib/plugins/console-debugger.js +0 -42
- package/lib/plugins/export.js +0 -25
- package/lib/plugins/keyboard.js +0 -117
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import React, { useState } from 'react';
|
|
2
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import RulerDist from "./rulerDist";
|
|
5
5
|
import { convert } from "../../utils/convert-units-lite";
|
|
6
6
|
import { GeometryUtils } from "../../utils/export";
|
|
7
7
|
import { MODE_ROTATING_ITEM, WALL_CABINET_LAYOUTPOS } from "../../constants";
|
|
8
|
-
import {
|
|
8
|
+
import { isWarningItem } from "./utils";
|
|
9
9
|
import { findCatalogElement } from "../../utils/geometry";
|
|
10
10
|
import { useAppContext } from "../../useAppContext";
|
|
11
11
|
var STYLE_LINE = {
|
|
@@ -38,14 +38,8 @@ export default function Item(_ref) {
|
|
|
38
38
|
layoutpos = item.layoutpos;
|
|
39
39
|
var showBaseCabinetMeasure = scene.showBaseCabinetMeasure,
|
|
40
40
|
showWallCabinetMeasure = scene.showWallCabinetMeasure;
|
|
41
|
-
var vertices = layer.vertices;
|
|
42
41
|
var layerID = scene.selectedLayer;
|
|
43
42
|
var element = catalog.getElement(item.type);
|
|
44
|
-
var allLines;
|
|
45
|
-
var curiteminfo;
|
|
46
|
-
var allLineRects;
|
|
47
|
-
var allItemRect;
|
|
48
|
-
var width, height;
|
|
49
43
|
var altitude = item.properties.getIn(['altitude', '_length']);
|
|
50
44
|
var _useState = useState(false),
|
|
51
45
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -55,118 +49,79 @@ export default function Item(_ref) {
|
|
|
55
49
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
56
50
|
antiClockRotateState = _useState4[0],
|
|
57
51
|
setAntiClockRotateState = _useState4[1];
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
y: item.y
|
|
62
|
-
},
|
|
63
|
-
rotRad: item.rotation / 180 * Math.PI
|
|
64
|
-
};
|
|
65
|
-
var tempWidth = item.properties.get('width');
|
|
66
|
-
var tempHeight = item.properties.get('depth');
|
|
67
|
-
if (tempWidth || tempHeight) {
|
|
68
|
-
width = convert(tempWidth.get('_length')).from(tempWidth.get('_unit')).to('cm');
|
|
69
|
-
height = convert(tempHeight.get('_length')).from(tempHeight.get('_unit')).to('cm');
|
|
70
|
-
} else {
|
|
71
|
-
width = convert(element.info.sizeinfo.width).from('in').to('cm');
|
|
72
|
-
height = convert(element.info.sizeinfo.depth).from('in').to('cm');
|
|
73
|
-
}
|
|
74
|
-
var angle = rotation + 90;
|
|
75
|
-
val.size = {
|
|
76
|
-
width: width,
|
|
77
|
-
height: height
|
|
78
|
-
};
|
|
79
|
-
function point(x, y) {
|
|
52
|
+
|
|
53
|
+
// ----- helpers -----
|
|
54
|
+
function point(px, py) {
|
|
80
55
|
return {
|
|
81
|
-
x:
|
|
82
|
-
y:
|
|
56
|
+
x: px,
|
|
57
|
+
y: py
|
|
83
58
|
};
|
|
84
59
|
}
|
|
85
60
|
function getCalcRectFromItem(items) {
|
|
86
|
-
var
|
|
87
|
-
var
|
|
61
|
+
var ix = items.pos.x;
|
|
62
|
+
var iy = items.pos.y;
|
|
88
63
|
var w = items.size.width / 2;
|
|
89
64
|
var h = items.size.height / 2;
|
|
90
65
|
var rotRad = items.rotRad;
|
|
91
66
|
var mh = 3 * h / 4;
|
|
92
|
-
var mx =
|
|
93
|
-
var my =
|
|
94
|
-
var m2x =
|
|
95
|
-
var m2y =
|
|
96
|
-
var m3x =
|
|
97
|
-
var m3y =
|
|
98
|
-
var m1x =
|
|
99
|
-
var m1y =
|
|
100
|
-
var x0 = mx + h * Math.sin(rotRad);
|
|
101
|
-
var y0 = my - h * Math.cos(rotRad);
|
|
102
|
-
var x3 = mx * 2 - x0;
|
|
103
|
-
var y3 = my * 2 - y0;
|
|
104
|
-
var x1 = x * 2 - x3;
|
|
105
|
-
var y1 = y * 2 - y3;
|
|
106
|
-
var x2 = x * 2 - x0;
|
|
107
|
-
var y2 = y * 2 - y0;
|
|
67
|
+
var mx = ix - w * Math.cos(rotRad) - mh * Math.sin(rotRad);
|
|
68
|
+
var my = iy - w * Math.sin(rotRad) + mh * Math.cos(rotRad);
|
|
69
|
+
var m2x = ix + w * Math.cos(rotRad) - mh * Math.sin(rotRad);
|
|
70
|
+
var m2y = iy + w * Math.sin(rotRad) + mh * Math.cos(rotRad);
|
|
71
|
+
var m3x = ix - h * Math.sin(rotRad);
|
|
72
|
+
var m3y = iy + h * Math.cos(rotRad);
|
|
73
|
+
var m1x = ix + h * Math.sin(rotRad);
|
|
74
|
+
var m1y = iy - h * Math.cos(rotRad);
|
|
108
75
|
return {
|
|
109
76
|
rectCenterPoint: [[point(mx, my), 180], [point(m1x, m1y), -90], [point(m2x, m2y), 0], [point(m3x, m3y), 90]]
|
|
110
77
|
};
|
|
111
78
|
}
|
|
112
|
-
function
|
|
79
|
+
function getAllItemsRectangles(_ref2) {
|
|
80
|
+
var layer = _ref2.layer,
|
|
81
|
+
catalog = _ref2.catalog,
|
|
82
|
+
layoutpos = _ref2.layoutpos,
|
|
83
|
+
altitude = _ref2.altitude,
|
|
84
|
+
tempHeightLen = _ref2.tempHeightLen;
|
|
113
85
|
var rectarray = [];
|
|
114
|
-
|
|
115
|
-
|
|
86
|
+
|
|
87
|
+
// keeping your selectedItem logic (even though not used right now)
|
|
116
88
|
if (layer.selected.items.size > 0) {
|
|
117
|
-
selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
currentItem = {
|
|
121
|
-
selectedItem: selectedItem,
|
|
122
|
-
cat: _cat
|
|
123
|
-
};
|
|
89
|
+
var selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
|
|
90
|
+
var catid = selectedItem.type;
|
|
91
|
+
findCatalogElement(catalog, catid);
|
|
124
92
|
}
|
|
125
|
-
layer.items.forEach(function (
|
|
93
|
+
layer.items.forEach(function (other) {
|
|
126
94
|
var val = {
|
|
127
95
|
pos: {
|
|
128
|
-
x:
|
|
129
|
-
y:
|
|
96
|
+
x: other.x,
|
|
97
|
+
y: other.y
|
|
130
98
|
},
|
|
131
|
-
rotRad:
|
|
99
|
+
rotRad: other.rotation / 180 * Math.PI
|
|
132
100
|
};
|
|
133
|
-
var
|
|
134
|
-
var
|
|
135
|
-
var width = convert(item.properties.getIn(['width', '_length'])).from('in').to('cm');
|
|
136
|
-
var height = convert(item.properties.getIn(['depth', '_length'])).from('in').to('cm');
|
|
137
|
-
// let width = cat.info.sizeinfo.width;
|
|
138
|
-
// let height = cat.info.sizeinfo.depth;
|
|
101
|
+
var widthCm = convert(other.properties.getIn(['width', '_length'])).from('in').to('cm');
|
|
102
|
+
var heightCm = convert(other.properties.getIn(['depth', '_length'])).from('in').to('cm');
|
|
139
103
|
val.size = {
|
|
140
|
-
width:
|
|
141
|
-
height:
|
|
104
|
+
width: widthCm,
|
|
105
|
+
height: heightCm
|
|
142
106
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
cat: cat
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
// if (!GeometryUtils.needSnap(currentItem, otherItem)) {
|
|
149
|
-
// return;
|
|
150
|
-
// }
|
|
151
|
-
|
|
152
|
-
if (!item.selected) {
|
|
153
|
-
var detectObjectsAtSameAltitudeFlag = layoutpos === 'Base' ? item.properties.getIn(['altitude', '_length']) <= altitude + tempHeight.get('_length') : item.properties.getIn(['altitude', '_length']) + item.properties.getIn(['height', '_length']) >= altitude;
|
|
107
|
+
if (!other.selected) {
|
|
108
|
+
var detectObjectsAtSameAltitudeFlag = layoutpos === 'Base' ? other.properties.getIn(['altitude', '_length']) <= altitude + tempHeightLen : other.properties.getIn(['altitude', '_length']) + other.properties.getIn(['height', '_length']) >= altitude;
|
|
154
109
|
if (detectObjectsAtSameAltitudeFlag) {
|
|
155
|
-
var
|
|
156
|
-
var
|
|
110
|
+
var ox = val.pos.x;
|
|
111
|
+
var oy = val.pos.y;
|
|
157
112
|
var rotRad = val.rotRad;
|
|
158
113
|
var w = val.size.width / 2;
|
|
159
114
|
var h = val.size.height / 2;
|
|
160
|
-
var mx =
|
|
161
|
-
var my =
|
|
115
|
+
var mx = ox - w * Math.cos(rotRad);
|
|
116
|
+
var my = oy - w * Math.sin(rotRad);
|
|
162
117
|
var x0 = mx + h * Math.sin(rotRad);
|
|
163
118
|
var y0 = my - h * Math.cos(rotRad);
|
|
164
119
|
var x3 = mx * 2 - x0;
|
|
165
120
|
var y3 = my * 2 - y0;
|
|
166
|
-
var x1 =
|
|
167
|
-
var y1 =
|
|
168
|
-
var x2 =
|
|
169
|
-
var y2 =
|
|
121
|
+
var x1 = ox * 2 - x3;
|
|
122
|
+
var y1 = oy * 2 - y3;
|
|
123
|
+
var x2 = ox * 2 - x0;
|
|
124
|
+
var y2 = oy * 2 - y0;
|
|
170
125
|
rectarray.push({
|
|
171
126
|
rect: [point(x0, y0), point(x1, y1), point(x0, y0), point(x1, y1)]
|
|
172
127
|
});
|
|
@@ -182,126 +137,156 @@ export default function Item(_ref) {
|
|
|
182
137
|
}
|
|
183
138
|
}
|
|
184
139
|
});
|
|
185
|
-
|
|
186
|
-
// layer.holes.forEach(hole => {
|
|
187
|
-
// let val = {pos:{x:hole.x, y:hole.y}, rotRad:hole.rotation};
|
|
188
|
-
// let catid = hole.type;
|
|
189
|
-
// let cat = catalog.elements[catid];
|
|
190
|
-
// let width = hole.properties.getIn(['width']).getIn(['length']);
|
|
191
|
-
// let height = hole.properties.getIn(['height']).getIn(['length']);
|
|
192
|
-
// val.size = {width, height};
|
|
193
|
-
// let otherItem = {
|
|
194
|
-
// hole,
|
|
195
|
-
// cat
|
|
196
|
-
// }
|
|
197
|
-
|
|
198
|
-
// // if (!GeometryUtils.needSnap(currentItem, otherItem)) {
|
|
199
|
-
// // return;
|
|
200
|
-
// // }
|
|
201
|
-
|
|
202
|
-
// if (!hole.selected) {
|
|
203
|
-
// let x = val.pos.x;
|
|
204
|
-
// let y = val.pos.y;
|
|
205
|
-
// let rotRad = val.rotRad;
|
|
206
|
-
// let w = val.size.width / 2;
|
|
207
|
-
// let mx = x - w * Math.cos(rotRad);
|
|
208
|
-
// let my = y - w * Math.sin(rotRad);
|
|
209
|
-
// let kx = x + w * Math.cos(rotRad);
|
|
210
|
-
// let ky = y + w * Math.sin(rotRad);
|
|
211
|
-
// let x0 = mx - 10 * Math.sin(rotRad);
|
|
212
|
-
// let y0 = my + 10 * Math.cos(rotRad);
|
|
213
|
-
// let x3 = mx + 10 * Math.sin(rotRad);
|
|
214
|
-
// let y3 = my - 10 * Math.cos(rotRad);
|
|
215
|
-
// let x1 = kx - 10 * Math.sin(rotRad);
|
|
216
|
-
// let y1 = ky + 10 * Math.cos(rotRad);
|
|
217
|
-
// let x2 = kx + 10 * Math.sin(rotRad);
|
|
218
|
-
// let y2 = ky - 10 * Math.cos(rotRad);
|
|
219
|
-
// rectarray.push({'rect':[point(x0,y0), point(x1,y1) ,point(x0,y0), point(x1,y1)]});
|
|
220
|
-
// rectarray.push({'rect':[point(x1,y1), point(x2,y2), point(x1,y1), point(x2,y2)]}); // right
|
|
221
|
-
// rectarray.push({'rect':[point(x2,y2), point(x3,y3), point(x2,y2), point(x3,y3)]}); // front
|
|
222
|
-
// rectarray.push({'rect':[point(x3,y3), point(x0,y0), point(x3,y3), point(x0,y0)]}); // left
|
|
223
|
-
// }
|
|
224
|
-
// });
|
|
225
140
|
return {
|
|
226
141
|
others: rectarray
|
|
227
142
|
};
|
|
228
143
|
}
|
|
229
|
-
allItemRect = getAllItems();
|
|
230
|
-
allLines = GeometryUtils.getAllLines(layer);
|
|
231
|
-
allLineRects = GeometryUtils.buildRectFromLines(layer, allLines);
|
|
232
|
-
var allRect = allLineRects.concat(allItemRect.others);
|
|
233
|
-
curiteminfo = getCalcRectFromItem(val);
|
|
234
144
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
145
|
+
// ----- item size -----
|
|
146
|
+
var tempWidth = item.properties.get('width');
|
|
147
|
+
var tempHeight = item.properties.get('depth');
|
|
148
|
+
var _useMemo = useMemo(function () {
|
|
149
|
+
var w, h;
|
|
150
|
+
if (tempWidth || tempHeight) {
|
|
151
|
+
w = convert(tempWidth.get('_length')).from(tempWidth.get('_unit')).to('cm');
|
|
152
|
+
h = convert(tempHeight.get('_length')).from(tempHeight.get('_unit')).to('cm');
|
|
153
|
+
} else {
|
|
154
|
+
w = convert(element.info.sizeinfo.width).from('in').to('cm');
|
|
155
|
+
h = convert(element.info.sizeinfo.depth).from('in').to('cm');
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
width: w,
|
|
159
|
+
height: h
|
|
160
|
+
};
|
|
161
|
+
}, [tempWidth, tempHeight, element]),
|
|
162
|
+
width = _useMemo.width,
|
|
163
|
+
height = _useMemo.height;
|
|
164
|
+
var nw = width / 2;
|
|
165
|
+
var nh = height / 2;
|
|
166
|
+
|
|
167
|
+
// val used in geometry calc
|
|
168
|
+
var val = useMemo(function () {
|
|
169
|
+
return {
|
|
170
|
+
pos: {
|
|
171
|
+
x: item.x,
|
|
172
|
+
y: item.y
|
|
173
|
+
},
|
|
174
|
+
rotRad: item.rotation / 180 * Math.PI,
|
|
175
|
+
size: {
|
|
176
|
+
width: width,
|
|
177
|
+
height: height
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}, [item.x, item.y, item.rotation, width, height]);
|
|
181
|
+
|
|
182
|
+
// ----- heavy geometry (memoized) -----
|
|
183
|
+
var _useMemo2 = useMemo(function () {
|
|
184
|
+
var allItemRect = getAllItemsRectangles({
|
|
185
|
+
layer: layer,
|
|
186
|
+
catalog: catalog,
|
|
187
|
+
layoutpos: layoutpos,
|
|
188
|
+
altitude: altitude,
|
|
189
|
+
tempHeightLen: tempHeight ? tempHeight.get('_length') : 0
|
|
190
|
+
});
|
|
191
|
+
var allLines = GeometryUtils.getAllLines(layer);
|
|
192
|
+
var allLineRects = GeometryUtils.buildRectFromLines(layer, allLines);
|
|
193
|
+
var allRect = allLineRects.concat(allItemRect.others);
|
|
194
|
+
var curiteminfo = getCalcRectFromItem(val);
|
|
195
|
+
var getDistant = function getDistant(px, py, rotRad) {
|
|
196
|
+
var center_h = 3 * height / 8;
|
|
197
|
+
var center_x = px;
|
|
198
|
+
var center_y = py;
|
|
199
|
+
var center_x1 = px - center_h * Math.sin(rotRad);
|
|
200
|
+
var center_y1 = py + center_h * Math.cos(rotRad);
|
|
201
|
+
var PointArray = [];
|
|
202
|
+
curiteminfo.rectCenterPoint.forEach(function (centerpoint) {
|
|
203
|
+
var a;
|
|
204
|
+
var RectLineFuction;
|
|
205
|
+
if (centerpoint[1] === 180 || centerpoint[1] === 0) {
|
|
206
|
+
RectLineFuction = GeometryUtils.linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x1, center_y1);
|
|
207
|
+
} else {
|
|
208
|
+
RectLineFuction = GeometryUtils.linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x, center_y);
|
|
265
209
|
}
|
|
210
|
+
var comparelength = [];
|
|
211
|
+
allRect.forEach(function (linerect) {
|
|
212
|
+
var p0 = GeometryUtils.clone_point(linerect.rect[2]);
|
|
213
|
+
var p1 = GeometryUtils.clone_point(linerect.rect[3]);
|
|
214
|
+
var lineFunction = {};
|
|
215
|
+
if (p0.x !== p1.x || p0.y !== p1.y) {
|
|
216
|
+
lineFunction = GeometryUtils.linePassingThroughTwoPoints(p0.x, p0.y, p1.x, p1.y);
|
|
217
|
+
}
|
|
218
|
+
var coordinatePoint = GeometryUtils.twoLinesIntersection(lineFunction.a, lineFunction.b, lineFunction.c, RectLineFuction.a, RectLineFuction.b, RectLineFuction.c);
|
|
219
|
+
if (coordinatePoint !== undefined) {
|
|
220
|
+
if (GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > GeometryUtils.pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > GeometryUtils.pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
|
|
221
|
+
if (GeometryUtils.pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > GeometryUtils.pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
|
|
222
|
+
comparelength.push(GeometryUtils.pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y));
|
|
223
|
+
a = Math.min.apply(null, comparelength);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
PointArray.push([a, centerpoint[1]]);
|
|
229
|
+
});
|
|
230
|
+
return {
|
|
231
|
+
PointArray: PointArray
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
var _getDistant = getDistant(x, y, val.rotRad),
|
|
235
|
+
PointArray = _getDistant.PointArray;
|
|
236
|
+
var catid = item.type;
|
|
237
|
+
var catLocal = catalog.elements[catid];
|
|
238
|
+
|
|
239
|
+
// normalize like your original code
|
|
240
|
+
PointArray.forEach(function (pointElement, index) {
|
|
241
|
+
if (pointElement[0] == undefined) PointArray[index][0] = 0;
|
|
242
|
+
if (pointElement[1] === -90 && catLocal.info.is_corner !== 1) {
|
|
243
|
+
PointArray[index][0] -= 4;
|
|
266
244
|
}
|
|
267
245
|
});
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
246
|
+
return {
|
|
247
|
+
pointArray: PointArray,
|
|
248
|
+
cat: catLocal
|
|
249
|
+
};
|
|
250
|
+
}, [layer, catalog, layoutpos, altitude, tempHeight, item.type, x, y, val, height]),
|
|
251
|
+
pointArray = _useMemo2.pointArray,
|
|
252
|
+
cat = _useMemo2.cat;
|
|
253
|
+
|
|
254
|
+
// ----- FIX: dispatch AFTER render (no setState/dispatch in render) -----
|
|
255
|
+
var lastSigRef = useRef('');
|
|
256
|
+
useEffect(function () {
|
|
257
|
+
if (!Array.isArray(pointArray)) return;
|
|
258
|
+
|
|
259
|
+
// small signature to prevent dispatching repeatedly with same values
|
|
260
|
+
// rounding reduces noise from floating point jitter
|
|
261
|
+
var sig = pointArray.map(function (_ref3) {
|
|
262
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
263
|
+
dist = _ref4[0],
|
|
264
|
+
dir = _ref4[1];
|
|
265
|
+
return "".concat(dir, ":").concat(Math.round((dist || 0) * 1000));
|
|
266
|
+
}).join('|');
|
|
267
|
+
if (sig === lastSigRef.current) return;
|
|
268
|
+
lastSigRef.current = sig;
|
|
269
|
+
itemsActions.storeDistArray(layerID, id, pointArray);
|
|
270
|
+
}, [itemsActions, layerID, id, pointArray]);
|
|
271
|
+
|
|
272
|
+
// ----- rulers -----
|
|
273
|
+
var renderedRuler = useMemo(function () {
|
|
274
|
+
var rulers = [];
|
|
275
|
+
var ep = 0.1;
|
|
276
|
+
if (!item.selected || !Array.isArray(pointArray)) return rulers;
|
|
277
|
+
pointArray.forEach(function (element, key) {
|
|
293
278
|
var itemDistanceFromLine = element[0];
|
|
294
|
-
var
|
|
279
|
+
var dir = element[1];
|
|
295
280
|
if (itemDistanceFromLine > ep || itemDistanceFromLine < -ep) {
|
|
296
|
-
|
|
281
|
+
rulers.push(/*#__PURE__*/React.createElement("g", {
|
|
297
282
|
"data-element-root": true,
|
|
298
283
|
"data-prototype": "rulerDist",
|
|
299
284
|
"data-id": item.id,
|
|
300
285
|
"data-selected": item.selected,
|
|
301
286
|
"data-layer": layer.id,
|
|
302
287
|
key: key,
|
|
303
|
-
"data-length":
|
|
304
|
-
"data-direct":
|
|
288
|
+
"data-length": itemDistanceFromLine,
|
|
289
|
+
"data-direct": dir
|
|
305
290
|
}, /*#__PURE__*/React.createElement(RulerDist, {
|
|
306
291
|
key: key,
|
|
307
292
|
layer: layer,
|
|
@@ -309,126 +294,126 @@ export default function Item(_ref) {
|
|
|
309
294
|
rulerUnit: scene.rulerUnit,
|
|
310
295
|
length: itemDistanceFromLine,
|
|
311
296
|
angle: rotation,
|
|
312
|
-
rotation:
|
|
313
|
-
transform: "translate(".concat(
|
|
297
|
+
rotation: dir,
|
|
298
|
+
transform: "translate(".concat(dir === 180 ? -nw : dir === 0 ? nw : 0, ", ").concat(dir === 90 ? nh : dir === -90 ? cat.info.is_corner !== 1 ? -(nh + 4) : -nh : 0, ") rotate(").concat(dir, ", 0, 0)")
|
|
314
299
|
})));
|
|
315
300
|
}
|
|
316
301
|
});
|
|
317
|
-
|
|
302
|
+
return rulers;
|
|
303
|
+
}, [item.selected, pointArray, item.id, layer, scene.unit, scene.rulerUnit, rotation, nw, nh, cat]);
|
|
304
|
+
|
|
305
|
+
// ----- rendered item -----
|
|
318
306
|
var renderedItem = element === null || element === void 0 || (_element$render2D = element.render2D) === null || _element$render2D === void 0 ? void 0 : _element$render2D.call(element, item, layer, scene);
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
var parts =
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
"
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
"
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
transform: 'rotateX(180deg)'
|
|
430
|
-
}
|
|
431
|
-
}))];
|
|
307
|
+
|
|
308
|
+
// ----- action icons -----
|
|
309
|
+
var parts = useMemo(function () {
|
|
310
|
+
if (!item.selected) return [];
|
|
311
|
+
return [/*#__PURE__*/React.createElement("g", {
|
|
312
|
+
key: 0,
|
|
313
|
+
"data-element-root": true,
|
|
314
|
+
"data-prototype": item.prototype,
|
|
315
|
+
"data-id": item.id,
|
|
316
|
+
"data-selected": item.selected,
|
|
317
|
+
"data-layer": layer.id,
|
|
318
|
+
"data-part": "rotation-anchor",
|
|
319
|
+
style: {
|
|
320
|
+
cursor: 'w-resize'
|
|
321
|
+
}
|
|
322
|
+
}, /*#__PURE__*/React.createElement("image", {
|
|
323
|
+
href: clockRotateState ? '/assets/img/svg/rotate.png' : '/assets/img/svg/blank_div.svg',
|
|
324
|
+
style: {
|
|
325
|
+
transform: "scale(-1, -1) translate(".concat(width / 2, "px, ").concat(height / 2, "px) rotate(25deg)")
|
|
326
|
+
},
|
|
327
|
+
height: "20",
|
|
328
|
+
width: "20",
|
|
329
|
+
onMouseEnter: function onMouseEnter() {
|
|
330
|
+
setClockRotateState(true);
|
|
331
|
+
setAntiClockRotateState(false);
|
|
332
|
+
},
|
|
333
|
+
onMouseLeave: function onMouseLeave() {
|
|
334
|
+
return setClockRotateState(mode === MODE_ROTATING_ITEM ? true : false);
|
|
335
|
+
}
|
|
336
|
+
}), /*#__PURE__*/React.createElement("image", {
|
|
337
|
+
href: antiClockRotateState ? '/assets/img/svg/rotate.png' : '/assets/img/svg/blank_div.svg',
|
|
338
|
+
style: {
|
|
339
|
+
transform: "scale(1, -1) translate(".concat(width / 2, "px, ").concat(height / 2, "px) rotate(25deg)")
|
|
340
|
+
},
|
|
341
|
+
height: "20",
|
|
342
|
+
width: "20",
|
|
343
|
+
onMouseEnter: function onMouseEnter() {
|
|
344
|
+
setAntiClockRotateState(true);
|
|
345
|
+
setClockRotateState(false);
|
|
346
|
+
},
|
|
347
|
+
onMouseLeave: function onMouseLeave() {
|
|
348
|
+
return setAntiClockRotateState(mode === MODE_ROTATING_ITEM ? true : false);
|
|
349
|
+
}
|
|
350
|
+
})), /*#__PURE__*/React.createElement("g", {
|
|
351
|
+
key: 1,
|
|
352
|
+
style: {
|
|
353
|
+
cursor: 'pointer',
|
|
354
|
+
transform: "rotate(".concat(360 - item.rotation, "deg) translate(").concat(-width / 2 - 27, "px, ", 0, "px)")
|
|
355
|
+
},
|
|
356
|
+
"data-element-root": true,
|
|
357
|
+
"data-prototype": item.prototype,
|
|
358
|
+
"data-id": item.id,
|
|
359
|
+
"data-selected": item.selected,
|
|
360
|
+
"data-layer": layer.id,
|
|
361
|
+
"data-part": "duplicate"
|
|
362
|
+
}, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("filter", {
|
|
363
|
+
id: "shadow"
|
|
364
|
+
}, /*#__PURE__*/React.createElement("feDropShadow", {
|
|
365
|
+
dx: "0",
|
|
366
|
+
dy: "0",
|
|
367
|
+
stdDeviation: "0.6"
|
|
368
|
+
}))), /*#__PURE__*/React.createElement("rect", {
|
|
369
|
+
rx: "4",
|
|
370
|
+
ry: "4",
|
|
371
|
+
height: "22",
|
|
372
|
+
width: "22",
|
|
373
|
+
fill: "white",
|
|
374
|
+
filter: "url(#shadow)"
|
|
375
|
+
}), /*#__PURE__*/React.createElement("image", {
|
|
376
|
+
href: "/assets/img/svg/duplicate.svg",
|
|
377
|
+
x: "3",
|
|
378
|
+
y: "-19",
|
|
379
|
+
height: "16",
|
|
380
|
+
width: "16",
|
|
381
|
+
style: isWarningItem(item) ? {
|
|
382
|
+
transform: 'rotateX(180deg)',
|
|
383
|
+
opacity: 0.5
|
|
384
|
+
} : {
|
|
385
|
+
transform: 'rotateX(180deg)'
|
|
386
|
+
}
|
|
387
|
+
})), /*#__PURE__*/React.createElement("g", {
|
|
388
|
+
key: 2,
|
|
389
|
+
style: {
|
|
390
|
+
cursor: 'pointer',
|
|
391
|
+
transform: "rotate(".concat(360 - item.rotation, "deg) translate(").concat(-width / 2 - 27, "px, ").concat(-27, "px)")
|
|
392
|
+
},
|
|
393
|
+
"data-element-root": true,
|
|
394
|
+
"data-prototype": item.prototype,
|
|
395
|
+
"data-id": item.id,
|
|
396
|
+
"data-selected": item.selected,
|
|
397
|
+
"data-layer": layer.id,
|
|
398
|
+
"data-part": "remove"
|
|
399
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
400
|
+
rx: "4",
|
|
401
|
+
ry: "4",
|
|
402
|
+
height: "22",
|
|
403
|
+
width: "22",
|
|
404
|
+
fill: "white",
|
|
405
|
+
filter: "url(#shadow)"
|
|
406
|
+
}), /*#__PURE__*/React.createElement("image", {
|
|
407
|
+
href: "/assets/img/svg/delete.svg",
|
|
408
|
+
x: "3",
|
|
409
|
+
y: "-19",
|
|
410
|
+
height: "16",
|
|
411
|
+
width: "16",
|
|
412
|
+
style: {
|
|
413
|
+
transform: 'rotateX(180deg)'
|
|
414
|
+
}
|
|
415
|
+
}))];
|
|
416
|
+
}, [item.selected, item.prototype, item.id, item.rotation, layer.id, clockRotateState, antiClockRotateState, width, height, mode, item]);
|
|
432
417
|
var measure = item.layoutpos === WALL_CABINET_LAYOUTPOS ? showWallCabinetMeasure : showBaseCabinetMeasure;
|
|
433
418
|
return /*#__PURE__*/React.createElement("g", {
|
|
434
419
|
"data-element-root": true,
|