kitchen-simulator 1.0.0-alin.5 → 1.0.0-alin.51
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 +15 -133
- package/es/LiteRenderer.js +2 -26
- package/es/actions/items-actions.js +1 -2
- package/es/class/item.js +1 -1
- package/es/class/project.js +8 -1
- package/es/components/viewer2d/item.js +10 -10
- package/es/components/viewer2d/layer.js +1 -1
- package/es/components/viewer2d/line.js +20 -17
- package/es/components/viewer2d/viewer2d.js +20 -56
- package/es/components/viewer3d/viewer3d.js +0 -2
- package/es/constants.js +7 -1
- package/es/devLiteRenderer.js +70 -5
- package/es/index.js +13 -12
- package/es/reducers/items-reducer.js +1 -1
- package/es/utils/geometry.js +6 -6
- package/es/utils/isolate-event-handler.js +87 -17
- package/lib/LiteKitchenConfigurator.js +16 -134
- package/lib/LiteRenderer.js +1 -25
- package/lib/actions/items-actions.js +1 -2
- package/lib/class/item.js +1 -1
- package/lib/class/project.js +8 -1
- package/lib/components/viewer2d/item.js +10 -10
- package/lib/components/viewer2d/layer.js +1 -1
- package/lib/components/viewer2d/line.js +19 -16
- package/lib/components/viewer2d/viewer2d.js +19 -55
- package/lib/components/viewer3d/viewer3d.js +0 -2
- package/lib/constants.js +11 -5
- package/lib/devLiteRenderer.js +69 -4
- package/lib/index.js +13 -12
- package/lib/reducers/items-reducer.js +1 -1
- package/lib/utils/geometry.js +6 -6
- package/lib/utils/isolate-event-handler.js +86 -16
- package/package.json +3 -3
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
5
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
6
6
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
7
7
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
8
8
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
9
9
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
10
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
11
10
|
var _excluded = ["width", "height", "state", "stateExtractor"];
|
|
12
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
13
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
13
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
@@ -42,23 +40,6 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
42
40
|
_this = _callSuper(this, LiteKitchenConfigurator, [props]);
|
|
43
41
|
|
|
44
42
|
// utm tracking
|
|
45
|
-
_defineProperty(_this, "handleBeforeUnload", function (e) {
|
|
46
|
-
var areas = _this.props.stateExtractor(_this.props.state).getIn(['scene', 'layers', _this.props.stateExtractor(_this.props.state).scene.selectedLayer, 'areas']);
|
|
47
|
-
if (!_this.state.isSaved && areas.size > 0) {
|
|
48
|
-
setTimeout(function () {
|
|
49
|
-
_this.setState({
|
|
50
|
-
savePromptVisible: true,
|
|
51
|
-
isLeaving: true
|
|
52
|
-
});
|
|
53
|
-
}, 500);
|
|
54
|
-
_this.saveProjectToStorage();
|
|
55
|
-
|
|
56
|
-
// This line is required to trigger the browser confirmation dialog
|
|
57
|
-
e.preventDefault();
|
|
58
|
-
e.returnValue = '';
|
|
59
|
-
return '';
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
43
|
var utmDetailParams = new URLSearchParams(_this.props.location && _this.props.location.search);
|
|
63
44
|
var utmStrEncoded = utmDetailParams.get('details');
|
|
64
45
|
var utmRequestData = null;
|
|
@@ -103,7 +84,8 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
103
84
|
redirectURL: '',
|
|
104
85
|
snackBarMessage: '',
|
|
105
86
|
isSaved: false,
|
|
106
|
-
isLeaving: false
|
|
87
|
+
isLeaving: false,
|
|
88
|
+
stateCatalog: _this.props.catalog
|
|
107
89
|
};
|
|
108
90
|
|
|
109
91
|
// For UTM tracking
|
|
@@ -344,129 +326,20 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
344
326
|
}, {
|
|
345
327
|
key: "componentDidMount",
|
|
346
328
|
value: function componentDidMount() {
|
|
347
|
-
var _this3 = this;
|
|
348
|
-
window.addEventListener('beforeunload', this.handleBeforeUnload);
|
|
349
|
-
console.log('context =>', this.context);
|
|
350
329
|
window.forRedo = [];
|
|
351
330
|
var store = this.context.store;
|
|
352
331
|
var _this$props2 = this.props,
|
|
353
|
-
projectActions = _this$props2.projectActions,
|
|
354
|
-
catalog = _this$props2.catalog,
|
|
355
332
|
stateExtractor = _this$props2.stateExtractor,
|
|
356
|
-
state = _this$props2.state,
|
|
357
333
|
plugins = _this$props2.plugins;
|
|
358
|
-
projectActions.initCatalog(catalog);
|
|
359
|
-
var match = this.props.match;
|
|
360
|
-
if (sessionStorage.getItem(window.location.href)) {
|
|
361
|
-
var jsonData = sessionStorage.getItem(window.location.href);
|
|
362
|
-
projectActions.loadProject(JSON.parse(jsonData), this.props.categoryData);
|
|
363
|
-
sessionStorage.removeItem(window.location.href);
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
334
|
var newplugins = _toConsumableArray(plugins);
|
|
367
335
|
newplugins.forEach(function (newplugin) {
|
|
368
336
|
return newplugin(store, stateExtractor);
|
|
369
337
|
});
|
|
370
|
-
if (match && match.params.pid === undefined) {
|
|
371
|
-
projectActions.newProject();
|
|
372
|
-
sessionStorage.setItem('projectTitle', 'Untitled');
|
|
373
|
-
projectActions.rename('Untitled');
|
|
374
|
-
sessionStorage.removeItem('projectId');
|
|
375
|
-
sessionStorage.removeItem('email');
|
|
376
|
-
sessionStorage.removeItem('firstName');
|
|
377
|
-
sessionStorage.removeItem('lastName');
|
|
378
|
-
sessionStorage.removeItem('usedObjects');
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
if (match && match.params.pid !== undefined) {
|
|
382
|
-
if (match.params.pid === 'new') {
|
|
383
|
-
projectActions.newProject();
|
|
384
|
-
sessionStorage.setItem('projectTitle', 'Untitled');
|
|
385
|
-
projectActions.rename('Untitled');
|
|
386
|
-
sessionStorage.removeItem('projectId');
|
|
387
|
-
sessionStorage.removeItem('email');
|
|
388
|
-
sessionStorage.removeItem('firstName');
|
|
389
|
-
sessionStorage.removeItem('lastName');
|
|
390
|
-
sessionStorage.removeItem('usedObjects');
|
|
391
|
-
} else {
|
|
392
|
-
axios.post("".concat(constants.API_SERVER_URL, "/api/project/loadPidProject"), {
|
|
393
|
-
pid: match.params.pid,
|
|
394
|
-
visualizerName: sessionStorage.getItem('visualizerName')
|
|
395
|
-
}).then(/*#__PURE__*/function () {
|
|
396
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(response) {
|
|
397
|
-
var projectElement, jsonData, _t;
|
|
398
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
399
|
-
while (1) switch (_context.prev = _context.next) {
|
|
400
|
-
case 0:
|
|
401
|
-
projectElement = response.data.projectElement;
|
|
402
|
-
if (!(projectElement.length === 0)) {
|
|
403
|
-
_context.next = 1;
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
return _context.abrupt("return");
|
|
407
|
-
case 1:
|
|
408
|
-
sessionStorage.setItem('projectTitle', projectElement[0].title);
|
|
409
|
-
projectActions.rename(projectElement[0].title);
|
|
410
|
-
sessionStorage.setItem('projectId', projectElement[0].id);
|
|
411
|
-
sessionStorage.setItem('email', projectElement[0].email);
|
|
412
|
-
sessionStorage.setItem('firstName', projectElement[0].firstName);
|
|
413
|
-
sessionStorage.setItem('lastName', projectElement[0].lastName);
|
|
414
|
-
sessionStorage.setItem('phone', projectElement[0].phone);
|
|
415
|
-
if (!projectElement[0].project_data) {
|
|
416
|
-
_context.next = 2;
|
|
417
|
-
break;
|
|
418
|
-
}
|
|
419
|
-
jsonData = JSON.parse(projectElement[0].project_data);
|
|
420
|
-
_context.next = 5;
|
|
421
|
-
break;
|
|
422
|
-
case 2:
|
|
423
|
-
_context.prev = 2;
|
|
424
|
-
_context.next = 3;
|
|
425
|
-
return axios.post("".concat(constants.API_SERVER_URL, "/api/project/loadPidData"), {
|
|
426
|
-
pid: match.params.pid
|
|
427
|
-
}).data.data;
|
|
428
|
-
case 3:
|
|
429
|
-
jsonData = _context.sent;
|
|
430
|
-
_context.next = 5;
|
|
431
|
-
break;
|
|
432
|
-
case 4:
|
|
433
|
-
_context.prev = 4;
|
|
434
|
-
_t = _context["catch"](2);
|
|
435
|
-
_this3.setState({
|
|
436
|
-
isSnackBarOpen: true,
|
|
437
|
-
snackBarMessage: _t
|
|
438
|
-
});
|
|
439
|
-
case 5:
|
|
440
|
-
jsonData.isLoadingCabinet = false;
|
|
441
|
-
projectActions.loadProject(jsonData, _this3.props.categoryData);
|
|
442
|
-
case 6:
|
|
443
|
-
case "end":
|
|
444
|
-
return _context.stop();
|
|
445
|
-
}
|
|
446
|
-
}, _callee, null, [[2, 4]]);
|
|
447
|
-
}));
|
|
448
|
-
return function (_x) {
|
|
449
|
-
return _ref.apply(this, arguments);
|
|
450
|
-
};
|
|
451
|
-
}());
|
|
452
|
-
}
|
|
453
|
-
sessionStorage.removeItem('user_type');
|
|
454
|
-
sessionStorage.removeItem('project_type');
|
|
455
|
-
sessionStorage.removeItem('project_timeline');
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}, {
|
|
459
|
-
key: "componentWillUnmount",
|
|
460
|
-
value: function componentWillUnmount() {
|
|
461
|
-
window.addEventListener('beforeunload', this.handleBeforeUnload);
|
|
462
|
-
window.onbeforeunload = null;
|
|
463
338
|
}
|
|
464
|
-
}, {
|
|
465
|
-
key: "componentWillMount",
|
|
466
|
-
value: function componentWillMount() {}
|
|
467
339
|
}, {
|
|
468
340
|
key: "componentWillReceiveProps",
|
|
469
341
|
value: function componentWillReceiveProps(nextProps) {
|
|
342
|
+
var _oldState$catalog, _plannerState$catalog;
|
|
470
343
|
var stateExtractor = nextProps.stateExtractor,
|
|
471
344
|
state = nextProps.state,
|
|
472
345
|
projectActions = nextProps.projectActions,
|
|
@@ -475,9 +348,18 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
475
348
|
|
|
476
349
|
// handle external events
|
|
477
350
|
if (this.props.externalEvent !== externalEvent) {
|
|
478
|
-
handleExternalEvent(
|
|
351
|
+
handleExternalEvent(nextProps);
|
|
479
352
|
}
|
|
480
353
|
var plannerState = stateExtractor(state);
|
|
354
|
+
var oldState = stateExtractor(this.props.state);
|
|
355
|
+
if ((oldState === null || oldState === void 0 || (_oldState$catalog = oldState.catalog) === null || _oldState$catalog === void 0 ? void 0 : _oldState$catalog.elements) !== (plannerState === null || plannerState === void 0 || (_plannerState$catalog = plannerState.catalog) === null || _plannerState$catalog === void 0 ? void 0 : _plannerState$catalog.elements)) {
|
|
356
|
+
// copy state.catalog to the props.catalog
|
|
357
|
+
// let catalog = this.state.stateCatalog;
|
|
358
|
+
// console.log('111111', plannerState?.catalog?.elements.toJS());
|
|
359
|
+
// catalog.elements = plannerState?.catalog?.elements.toJS();
|
|
360
|
+
// console.log('222222', catalog);
|
|
361
|
+
// this.setState({ stateCatalog: catalog });
|
|
362
|
+
}
|
|
481
363
|
var catalogReady = plannerState.getIn(['catalog', 'ready']);
|
|
482
364
|
if (!catalogReady) {
|
|
483
365
|
projectActions.initCatalog(catalog);
|
|
@@ -573,7 +455,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
573
455
|
}, /*#__PURE__*/React.createElement(Content, _extends({
|
|
574
456
|
width: contentW,
|
|
575
457
|
height: contentH,
|
|
576
|
-
catalog: this.
|
|
458
|
+
catalog: this.state.stateCatalog,
|
|
577
459
|
state: extractedState,
|
|
578
460
|
toolBar: this.state.toolbar,
|
|
579
461
|
setToolbar: this.setToolbar,
|
package/es/LiteRenderer.js
CHANGED
|
@@ -33,7 +33,7 @@ import { render2DItem, render3DApplianceItem, render3DItem, render3DLightingItem
|
|
|
33
33
|
import { ConsoleDebugger, Keyboard } from "./plugins/export";
|
|
34
34
|
import { Map } from 'immutable';
|
|
35
35
|
import * as Sentry from '@sentry/react';
|
|
36
|
-
import { loadProject, rename } from "./actions/project-actions";
|
|
36
|
+
import { initCatalog, loadProject, rename } from "./actions/project-actions";
|
|
37
37
|
import exporter from "./catalog/utils/exporter";
|
|
38
38
|
import * as THREE from 'three';
|
|
39
39
|
import LiteKitchenConfigurator from "./LiteKitchenConfigurator";
|
|
@@ -257,8 +257,6 @@ export default function LiteRenderer(props) {
|
|
|
257
257
|
furnishing = _ref2$furnishing === void 0 ? [] : _ref2$furnishing,
|
|
258
258
|
_ref2$lighting = _ref2.lighting,
|
|
259
259
|
lighting = _ref2$lighting === void 0 ? [] : _ref2$lighting;
|
|
260
|
-
var _projectElement = _slicedToArray(projectElement, 1),
|
|
261
|
-
project_data = _projectElement[0].project_data;
|
|
262
260
|
var id = configData.id,
|
|
263
261
|
logoImg = configData.logoImg,
|
|
264
262
|
companyUrl = configData.companyUrl;
|
|
@@ -266,10 +264,6 @@ export default function LiteRenderer(props) {
|
|
|
266
264
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
267
265
|
outlineSVGData = _React$useState2[0],
|
|
268
266
|
setOutlineSVGData = _React$useState2[1];
|
|
269
|
-
var _React$useState3 = React.useState(false),
|
|
270
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
271
|
-
catalogInitiated = _React$useState4[0],
|
|
272
|
-
setCatalogInitiated = _React$useState4[1];
|
|
273
267
|
useEffect(function () {
|
|
274
268
|
var initMyCatalog = /*#__PURE__*/function () {
|
|
275
269
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
@@ -466,7 +460,6 @@ export default function LiteRenderer(props) {
|
|
|
466
460
|
return _regeneratorRuntime.wrap(function (_context5) {
|
|
467
461
|
while (1) switch (_context5.prev = _context5.next) {
|
|
468
462
|
case 0:
|
|
469
|
-
setCatalogInitiated(false);
|
|
470
463
|
_context5.next = 1;
|
|
471
464
|
return initMyCatalog();
|
|
472
465
|
case 1:
|
|
@@ -476,8 +469,6 @@ export default function LiteRenderer(props) {
|
|
|
476
469
|
_context5.next = 3;
|
|
477
470
|
return loadSVGs();
|
|
478
471
|
case 3:
|
|
479
|
-
setCatalogInitiated(true);
|
|
480
|
-
case 4:
|
|
481
472
|
case "end":
|
|
482
473
|
return _context5.stop();
|
|
483
474
|
}
|
|
@@ -489,7 +480,7 @@ export default function LiteRenderer(props) {
|
|
|
489
480
|
}();
|
|
490
481
|
initCatalog();
|
|
491
482
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
492
|
-
}, []);
|
|
483
|
+
}, [categoryData, data, id, catalogs, colorAlias, subgroups]);
|
|
493
484
|
|
|
494
485
|
// Register items once SVGs are loaded
|
|
495
486
|
useEffect(function () {
|
|
@@ -526,21 +517,6 @@ export default function LiteRenderer(props) {
|
|
|
526
517
|
});
|
|
527
518
|
for (var x in Item) MyCatalog.registerElement(Item[x]);
|
|
528
519
|
}, [outlineSVGData, data, appliances, furnishing, lighting]);
|
|
529
|
-
useEffect(function () {
|
|
530
|
-
if (projectElement.length === 0) return;
|
|
531
|
-
if (!catalogInitiated) return;
|
|
532
|
-
sessionStorage.setItem('projectTitle', projectElement[0].title);
|
|
533
|
-
store.dispatch(rename(projectElement[0].title));
|
|
534
|
-
sessionStorage.setItem('projectId', projectElement[0].id);
|
|
535
|
-
sessionStorage.setItem('email', projectElement[0].email);
|
|
536
|
-
sessionStorage.setItem('firstName', projectElement[0].firstName);
|
|
537
|
-
sessionStorage.setItem('lastName', projectElement[0].lastName);
|
|
538
|
-
sessionStorage.setItem('phone', projectElement[0].phone);
|
|
539
|
-
var jsonData;
|
|
540
|
-
jsonData = JSON.parse(projectElement[0].project_data);
|
|
541
|
-
jsonData.isLoadingCabinet = false;
|
|
542
|
-
store.dispatch(loadProject(jsonData, categoryData));
|
|
543
|
-
}, [project_data, catalogInitiated]);
|
|
544
520
|
return /*#__PURE__*/React.createElement(AppContext.Provider, null, /*#__PURE__*/React.createElement(Provider, {
|
|
545
521
|
store: store
|
|
546
522
|
}, /*#__PURE__*/React.createElement(ToolErrorBoundary, {
|
|
@@ -223,11 +223,10 @@ export function updateItemsAltitude(layerID, itemID, value) {
|
|
|
223
223
|
value: value
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
|
-
export function setDoorStyle(doorStyle,
|
|
226
|
+
export function setDoorStyle(doorStyle, isAll) {
|
|
227
227
|
return {
|
|
228
228
|
type: SET_DOOR_STYLE,
|
|
229
229
|
doorStyle: doorStyle,
|
|
230
|
-
pathes: pathes,
|
|
231
230
|
isAll: isAll
|
|
232
231
|
};
|
|
233
232
|
}
|
package/es/class/item.js
CHANGED
|
@@ -1164,7 +1164,7 @@ var Item = /*#__PURE__*/function () {
|
|
|
1164
1164
|
}
|
|
1165
1165
|
}, {
|
|
1166
1166
|
key: "setDoorStyle",
|
|
1167
|
-
value: function setDoorStyle(state, doorStyle,
|
|
1167
|
+
value: function setDoorStyle(state, doorStyle, isAll) {
|
|
1168
1168
|
var _this2 = this;
|
|
1169
1169
|
var keys = Object.keys(doorStyle.doorStyles);
|
|
1170
1170
|
keys = keys.filter(function (elem) {
|
package/es/class/project.js
CHANGED
|
@@ -478,6 +478,10 @@ var Project = /*#__PURE__*/function () {
|
|
|
478
478
|
};
|
|
479
479
|
}
|
|
480
480
|
var mode;
|
|
481
|
+
var isLineAction = false;
|
|
482
|
+
if (state.mode.includes('LINE')) {
|
|
483
|
+
isLineAction = true;
|
|
484
|
+
}
|
|
481
485
|
if (state.mode == MODE_DRAWING_ITEM_3D) {
|
|
482
486
|
mode = MODE_IDLE_3D;
|
|
483
487
|
if (state.drawingSupport.has('currentID')) state = Layer.removeElement(state, state.scene.selectedLayer, 'items', state.drawingSupport.get('currentID')).updatedState;
|
|
@@ -520,6 +524,9 @@ var Project = /*#__PURE__*/function () {
|
|
|
520
524
|
draggingSupport: new Map(),
|
|
521
525
|
rotatingSupport: new Map()
|
|
522
526
|
});
|
|
527
|
+
if (isLineAction) {
|
|
528
|
+
state = Line.applyWallChanges(state, END_DRAWING_LINE).updatedState;
|
|
529
|
+
}
|
|
523
530
|
return {
|
|
524
531
|
updatedState: state
|
|
525
532
|
};
|
|
@@ -604,7 +611,7 @@ var Project = /*#__PURE__*/function () {
|
|
|
604
611
|
updatedState: state
|
|
605
612
|
};
|
|
606
613
|
} catch (error) {
|
|
607
|
-
console.log('
|
|
614
|
+
console.log('addElementToCatalogError', error);
|
|
608
615
|
return {
|
|
609
616
|
updatedState: state
|
|
610
617
|
};
|
|
@@ -6,6 +6,7 @@ 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
8
|
import { isEmpty, returnReplaceableDeepSearchType } from "./utils";
|
|
9
|
+
import { findCatalogElement } from "../../utils/geometry";
|
|
9
10
|
var STYLE_LINE = {
|
|
10
11
|
fill: '#0096fd',
|
|
11
12
|
stroke: '#0096fd'
|
|
@@ -21,6 +22,7 @@ var STYLE_CIRCLE2 = {
|
|
|
21
22
|
cursor: 'ew-resize'
|
|
22
23
|
};
|
|
23
24
|
export default function Item(_ref, _ref2) {
|
|
25
|
+
var _element$render2D;
|
|
24
26
|
var layer = _ref.layer,
|
|
25
27
|
item = _ref.item,
|
|
26
28
|
scene = _ref.scene,
|
|
@@ -29,7 +31,8 @@ export default function Item(_ref, _ref2) {
|
|
|
29
31
|
var itemsActions = _ref2.itemsActions;
|
|
30
32
|
var x = item.x,
|
|
31
33
|
y = item.y,
|
|
32
|
-
rotation = item.rotation
|
|
34
|
+
rotation = item.rotation,
|
|
35
|
+
id = item.id;
|
|
33
36
|
var showBaseCabinetMeasure = scene.showBaseCabinetMeasure,
|
|
34
37
|
showWallCabinetMeasure = scene.showWallCabinetMeasure;
|
|
35
38
|
var vertices = layer.vertices;
|
|
@@ -116,12 +119,7 @@ export default function Item(_ref, _ref2) {
|
|
|
116
119
|
if (layer.selected.items.size > 0) {
|
|
117
120
|
selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
|
|
118
121
|
var catid = selectedItem.type;
|
|
119
|
-
var cat = catalog
|
|
120
|
-
if (!cat) cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
|
|
121
|
-
if (cat === undefined || cat === null) {
|
|
122
|
-
cat = catalog.getIn(['elements', catid]);
|
|
123
|
-
if (!cat) cat = catalog.getIn(['elements', returnReplaceableDeepSearchType(catid)]);
|
|
124
|
-
}
|
|
122
|
+
var cat = findCatalogElement(catalog, catid);
|
|
125
123
|
currentItem = {
|
|
126
124
|
selectedItem: selectedItem,
|
|
127
125
|
cat: cat
|
|
@@ -136,8 +134,7 @@ export default function Item(_ref, _ref2) {
|
|
|
136
134
|
rotRad: item.rotation / 180 * Math.PI
|
|
137
135
|
};
|
|
138
136
|
var catid = item.type;
|
|
139
|
-
var cat = catalog
|
|
140
|
-
if (!cat) cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
|
|
137
|
+
var cat = findCatalogElement(catalog, catid);
|
|
141
138
|
var width = convert(item.properties.getIn(['width', '_length'])).from('in').to('cm');
|
|
142
139
|
var height = convert(item.properties.getIn(['depth', '_length'])).from('in').to('cm');
|
|
143
140
|
// let width = cat.info.sizeinfo.width;
|
|
@@ -281,6 +278,9 @@ export default function Item(_ref, _ref2) {
|
|
|
281
278
|
PointArray.forEach(function (pointElement, index) {
|
|
282
279
|
if (pointElement[0] == undefined) PointArray[index][0] = 0;
|
|
283
280
|
});
|
|
281
|
+
if (Array.isArray(PointArray)) {
|
|
282
|
+
itemsActions.storeDistArray(layerID, id, PointArray);
|
|
283
|
+
}
|
|
284
284
|
var renderedRuler = [];
|
|
285
285
|
var ep = 0.1;
|
|
286
286
|
if (item.selected) {
|
|
@@ -310,7 +310,7 @@ export default function Item(_ref, _ref2) {
|
|
|
310
310
|
}
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
|
-
var renderedItem = element.render2D.call(element, item, layer, scene);
|
|
313
|
+
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);
|
|
314
314
|
var isSmall = false;
|
|
315
315
|
if (width < 40) isSmall = true;
|
|
316
316
|
var parts = [];
|
|
@@ -137,7 +137,7 @@ export default function Layer(_ref) {
|
|
|
137
137
|
unit: unit,
|
|
138
138
|
catalog: catalog
|
|
139
139
|
});
|
|
140
|
-
}),
|
|
140
|
+
}), itemData, itemWall, lineData, itemSelected, mode !== MODE_DRAWING_LINE && vertices.valueSeq().filter(function (v) {
|
|
141
141
|
return v.selected;
|
|
142
142
|
}).map(function (vertex) {
|
|
143
143
|
return /*#__PURE__*/React.createElement(Vertex, {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { GeometryUtils } from "../../utils/export";
|
|
4
4
|
import Ruler from "./ruler";
|
|
5
|
-
import { BASE_CABINET_LAYOUTPOS, LINE_THICKNESS, WALL_CABINET_LAYOUTPOS } from "../../constants";
|
|
5
|
+
import { BASE_CABINET_LAYOUTPOS, LINE_THICKNESS, MODE_DRAGGING_LINE, MODE_DRAWING_LINE, WALL_CABINET_LAYOUTPOS, MAX_ANGLE_SCALE } from "../../constants";
|
|
6
6
|
import * as Three from 'three';
|
|
7
7
|
import { isEmpty } from "./utils";
|
|
8
8
|
var STYLE = {
|
|
@@ -21,7 +21,7 @@ var STYLE_TEXT = {
|
|
|
21
21
|
textAnchor: 'middle',
|
|
22
22
|
fontSize: '7px',
|
|
23
23
|
fontWeight: 'middle',
|
|
24
|
-
fontFamily: "'
|
|
24
|
+
fontFamily: "'Courier New', Courier, monospace"
|
|
25
25
|
};
|
|
26
26
|
export function compareVertices(v0, v1) {
|
|
27
27
|
return v0.x === v1.x ? v0.y - v1.y : v0.x - v1.x;
|
|
@@ -710,22 +710,32 @@ export default function Line(_ref) {
|
|
|
710
710
|
"data-layer": layer.id,
|
|
711
711
|
"data-length": length
|
|
712
712
|
}, showWallLengthMeasure ? renderedRuler : null), line.selected && angleVertices.map(function (vertex, index) {
|
|
713
|
+
var _relateLineLengthArra2;
|
|
713
714
|
var lineGroup = vertex[0].lines;
|
|
714
715
|
var angles = [];
|
|
715
716
|
var thickness = [];
|
|
716
717
|
var vectories = [];
|
|
718
|
+
var relateLineLengthArray = [];
|
|
719
|
+
|
|
717
720
|
// get the vector of lines
|
|
718
721
|
lineGroup.forEach(function (line) {
|
|
722
|
+
var _relateLineLengthArra;
|
|
719
723
|
line = layer.lines.get(line);
|
|
720
724
|
var vertex0 = layer.vertices.get(line.vertices.get(0));
|
|
721
725
|
var vertex1 = layer.vertices.get(line.vertices.get(1));
|
|
722
726
|
var vec = vertex0 === vertex[0] ? new Three.Vector2(vertex1.x - vertex0.x, vertex1.y - vertex0.y) : new Three.Vector2(vertex0.x - vertex1.x, vertex0.y - vertex1.y);
|
|
727
|
+
(_relateLineLengthArra = relateLineLengthArray) === null || _relateLineLengthArra === void 0 || _relateLineLengthArra.push(GeometryUtils.verticesDistance(vertex0, vertex1));
|
|
723
728
|
var angle = vec.angle();
|
|
724
729
|
var thick = 15;
|
|
725
730
|
angles.push(angle);
|
|
726
731
|
thickness.push(thick);
|
|
727
732
|
vectories.push(vec.normalize());
|
|
728
733
|
});
|
|
734
|
+
relateLineLengthArray = (_relateLineLengthArra2 = relateLineLengthArray) === null || _relateLineLengthArra2 === void 0 ? void 0 : _relateLineLengthArra2.sort(function (a, b) {
|
|
735
|
+
return a - b;
|
|
736
|
+
});
|
|
737
|
+
var minLineLength = relateLineLengthArray[0] < MAX_ANGLE_SCALE * 2 ? relateLineLengthArray[0] / 2 // scale down to half of the smallest adjacent surface
|
|
738
|
+
: MAX_ANGLE_SCALE;
|
|
729
739
|
|
|
730
740
|
// calculate the angle between two lines
|
|
731
741
|
var center = new Three.Vector2(vertex[0].x, vertex[0].y);
|
|
@@ -744,16 +754,15 @@ export default function Line(_ref) {
|
|
|
744
754
|
var rotDir = vec1.cross(vec2) > 0; // true: rotate CCW, false: rotate CW
|
|
745
755
|
|
|
746
756
|
// Angle Text Position
|
|
747
|
-
|
|
748
757
|
var angleTextO = center.clone();
|
|
749
|
-
var textTranslation = vec1.clone().add(vec2).normalize().multiplyScalar(
|
|
758
|
+
var textTranslation = vec1.clone().add(vec2).normalize().multiplyScalar(minLineLength * 2 / 3);
|
|
750
759
|
angleTextO.add(textTranslation);
|
|
751
|
-
angleTextO.y -=
|
|
752
|
-
|
|
760
|
+
angleTextO.y -= minLineLength / 10; // half the height of text `angle`
|
|
761
|
+
angleTextO.x += minLineLength / 10;
|
|
753
762
|
var tx = 0;
|
|
754
763
|
var ty = 0;
|
|
755
|
-
vec = vec.multiplyScalar(
|
|
756
|
-
vec1 = vec1.multiplyScalar(
|
|
764
|
+
vec = vec.multiplyScalar(minLineLength);
|
|
765
|
+
vec1 = vec1.multiplyScalar(minLineLength);
|
|
757
766
|
var cen1 = center.clone(),
|
|
758
767
|
cen2 = center.clone();
|
|
759
768
|
center = center.add(vec);
|
|
@@ -766,7 +775,7 @@ export default function Line(_ref) {
|
|
|
766
775
|
// Angle SVG Path
|
|
767
776
|
lines.push(/*#__PURE__*/React.createElement("path", {
|
|
768
777
|
style: STYLE_ANGLE,
|
|
769
|
-
d: "\n M ".concat(vertex[0].x, ",").concat(vertex[0].y, " L ").concat(pos1.x, ",").concat(pos1.y, " A
|
|
778
|
+
d: "\n M ".concat(vertex[0].x, ",").concat(vertex[0].y, " L ").concat(pos1.x, ",").concat(pos1.y, " A ").concat(minLineLength, " ").concat(minLineLength, " ").concat(angle, " 0 ").concat(t > 0 ? 1 : 0, " ").concat(pos2.x, ",").concat(pos2.y, " z\n ")
|
|
770
779
|
}));
|
|
771
780
|
var length = angle;
|
|
772
781
|
// draw angle and angle text
|
|
@@ -780,15 +789,9 @@ export default function Line(_ref) {
|
|
|
780
789
|
"data-id": [vertex[0].id, vertex[1].id, rotDir],
|
|
781
790
|
"data-length": length
|
|
782
791
|
}, lines, /*#__PURE__*/React.createElement("text", {
|
|
783
|
-
transform: "translate(".concat(angleTextO.x, ", ").concat(angleTextO.y, ") scale(
|
|
792
|
+
transform: "translate(".concat(angleTextO.x, ", ").concat(angleTextO.y, ") scale(").concat(minLineLength / 20, ", ").concat(-minLineLength / 20, ")"),
|
|
784
793
|
style: STYLE_TEXT
|
|
785
|
-
}, angle
|
|
786
|
-
transform: "translate(".concat(angleTextO.x, ", ").concat(angleTextO.y, ") translate(10, 9)"),
|
|
787
|
-
fill: "transparent",
|
|
788
|
-
stroke: "rgb(77, 77, 77)",
|
|
789
|
-
strokeWidth: 1,
|
|
790
|
-
r: 2
|
|
791
|
-
}));
|
|
794
|
+
}, angle + '° '));
|
|
792
795
|
}), showWindowDoorMeasure ? renderedAllRuler : null, showBaseCabinetMeasure ? baseRuler : null, showWallCabinetMeasure ? wallRuler : null, /*#__PURE__*/React.createElement("g", {
|
|
793
796
|
"data-element-root": true,
|
|
794
797
|
"data-prototype": line.prototype,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
5
|
import React, { useEffect, useRef, useState } from 'react';
|
|
7
6
|
import PropTypes from 'prop-types';
|
|
8
|
-
import { ReactSVGPanZoom, TOOL_AUTO, TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT
|
|
7
|
+
import { ReactSVGPanZoom, TOOL_AUTO, TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT } from 'react-svg-pan-zoom';
|
|
9
8
|
import * as constants from "../../constants";
|
|
10
9
|
import { DECIMAL_PLACES_2, LINE_THICKNESS, MIN_ANGLE_DISALLOW_DRAW_WALL, MODE_ELEVATION_VIEW, MODE_IDLE, UNIT_ANGLE } from "../../constants";
|
|
11
10
|
import State from "./state";
|
|
@@ -536,48 +535,18 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
536
535
|
rectCenterPoint: [[point(mx, my), 180], [point(m1x, m1y), -90], [point(m2x, m2y), 0], [point(m3x, m3y), 90]]
|
|
537
536
|
};
|
|
538
537
|
};
|
|
539
|
-
var
|
|
540
|
-
var
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
x: x,
|
|
552
|
-
y: y
|
|
553
|
-
},
|
|
554
|
-
rotRad: rotation / 180 * Math.PI
|
|
555
|
-
};
|
|
556
|
-
var _width = getProperties(item, 'width');
|
|
557
|
-
var depth = getProperties(item, 'depth');
|
|
558
|
-
val.size = {
|
|
559
|
-
width: _width,
|
|
560
|
-
height: depth
|
|
561
|
-
};
|
|
562
|
-
|
|
563
|
-
// collect geometry
|
|
564
|
-
var _allLines = GeometryUtils.getAllLines(layer) || [];
|
|
565
|
-
var _allLineRects = GeometryUtils.buildRectFromLines(layer, _allLines) || [];
|
|
566
|
-
var _allItemRect = GeometryUtils.getAllItems(scene, catalog, _allLineRects) || {
|
|
567
|
-
others: []
|
|
568
|
-
};
|
|
569
|
-
var _allRect = [].concat(_toConsumableArray(_allItemRect.others || []), _toConsumableArray(_allLineRects));
|
|
570
|
-
|
|
571
|
-
// current item
|
|
572
|
-
var curItemInfo = getCalcRectFromItem(val);
|
|
573
|
-
var pointArray = getDistant(x, y, val.rotRad, curItemInfo, _allRect);
|
|
574
|
-
|
|
575
|
-
// store results safely
|
|
576
|
-
if (Array.isArray(pointArray)) {
|
|
577
|
-
itemsActions.storeDistArray(layerID, id, pointArray);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
});
|
|
538
|
+
var getConnectedLines = function getConnectedLines() {
|
|
539
|
+
var _state$getIn;
|
|
540
|
+
var vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
|
|
541
|
+
var lines = state.getIn(['scene', 'layers', layerID, 'lines']).toJS();
|
|
542
|
+
var lineID = state.getIn(['scene', 'layers', layerID, 'selected', 'lines']).first();
|
|
543
|
+
var drawingLine = (_state$getIn = state.getIn(['scene', 'layers', layerID, 'lines', lineID])) === null || _state$getIn === void 0 ? void 0 : _state$getIn.toJS();
|
|
544
|
+
// get the lines that have same points with drawing line.
|
|
545
|
+
if (!isEmpty(drawingLine)) {
|
|
546
|
+
var tlines = [];
|
|
547
|
+
getRelatedLines(tlines, drawingLine, vertices, lines);
|
|
548
|
+
setRelatedLines(tlines);
|
|
549
|
+
}
|
|
581
550
|
};
|
|
582
551
|
var onMouseMove = function onMouseMove(viewerEvent) {
|
|
583
552
|
//workaround that allow imageful component to work
|
|
@@ -627,7 +596,6 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
627
596
|
holesActions.updateDrawingHole(layerID, x, y);
|
|
628
597
|
break;
|
|
629
598
|
case constants.MODE_DRAWING_ITEM:
|
|
630
|
-
calcDistanceArray();
|
|
631
599
|
var _layer = scene.layers.get(layerID);
|
|
632
600
|
var flag = false;
|
|
633
601
|
_layer.items.some(function (item) {
|
|
@@ -713,11 +681,11 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
713
681
|
break;
|
|
714
682
|
case constants.MODE_DRAGGING_VERTEX:
|
|
715
683
|
var vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
|
|
684
|
+
getConnectedLines();
|
|
716
685
|
var result = getEndPoint(vertices, x, y, 'DRAGGING_VERTEX');
|
|
717
686
|
verticesActions.updateDraggingVertex(result.x, result.y, state.snapMask);
|
|
718
687
|
break;
|
|
719
688
|
case constants.MODE_DRAGGING_ITEM:
|
|
720
|
-
calcDistanceArray();
|
|
721
689
|
prepareSnap();
|
|
722
690
|
var _GeometryUtils$calcSn2 = GeometryUtils.calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea),
|
|
723
691
|
nx = _GeometryUtils$calcSn2.nx,
|
|
@@ -889,10 +857,10 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
889
857
|
projectActions.setMode(_mode);
|
|
890
858
|
break;
|
|
891
859
|
} else {
|
|
892
|
-
var
|
|
893
|
-
var
|
|
894
|
-
getRelatedLines(
|
|
895
|
-
setRelatedLines(
|
|
860
|
+
var tlines = [];
|
|
861
|
+
var drawingLine = state.getIn(['scene', 'layers', layerID, 'lines', elementData.id]).toJS();
|
|
862
|
+
getRelatedLines(tlines, drawingLine, vertices, lines);
|
|
863
|
+
setRelatedLines(tlines);
|
|
896
864
|
linesActions.selectLine(elementData.layer, elementData.id);
|
|
897
865
|
break;
|
|
898
866
|
}
|
|
@@ -1178,12 +1146,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1178
1146
|
// if (dx > dy) y = prevVertex.y
|
|
1179
1147
|
// else x = prevVertex.x;
|
|
1180
1148
|
setdrawStart(true);
|
|
1181
|
-
|
|
1182
|
-
var drawingLine = state.getIn(['scene', 'layers', layerID, 'lines', lineID]).toJS();
|
|
1183
|
-
// get the lines that have same points with drawing line.
|
|
1184
|
-
var tlines = [];
|
|
1185
|
-
getRelatedLines(tlines, drawingLine, vertices, lines);
|
|
1186
|
-
setRelatedLines(tlines);
|
|
1149
|
+
getConnectedLines();
|
|
1187
1150
|
var endInfor = getEndPoint(vertices, x, y, 'END_DRAWIN_LINE');
|
|
1188
1151
|
linesActions.endDrawingLine(endInfor.x, endInfor.y, state.snapMask);
|
|
1189
1152
|
linesActions.beginDrawingLine(layerID, endInfor.x, endInfor.y, state.snapMask);
|
|
@@ -1198,6 +1161,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1198
1161
|
linesActions.endDraggingLine(x, y, relatedLines, state.snapMask);
|
|
1199
1162
|
break;
|
|
1200
1163
|
case constants.MODE_DRAGGING_VERTEX:
|
|
1164
|
+
getConnectedLines();
|
|
1201
1165
|
var result = getEndPoint(vertices, x, y, 'DRAGGING_VERTEX');
|
|
1202
1166
|
verticesActions.endDraggingVertex(result.x, result.y, state.snapMask);
|
|
1203
1167
|
break;
|