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