kitchen-simulator 1.0.0-alin.4 → 1.0.0-alin.45

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.
@@ -1,6 +1,5 @@
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";
5
4
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
6
5
  import _createClass from "@babel/runtime/helpers/esm/createClass";
@@ -9,7 +8,6 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
9
8
  import _inherits from "@babel/runtime/helpers/esm/inherits";
10
9
  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)); }
@@ -103,7 +101,8 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
103
101
  redirectURL: '',
104
102
  snackBarMessage: '',
105
103
  isSaved: false,
106
- isLeaving: false
104
+ isLeaving: false,
105
+ stateCatalog: _this.props.catalog
107
106
  };
108
107
 
109
108
  // For UTM tracking
@@ -344,116 +343,17 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
344
343
  }, {
345
344
  key: "componentDidMount",
346
345
  value: function componentDidMount() {
347
- var _this3 = this;
348
346
  window.addEventListener('beforeunload', this.handleBeforeUnload);
349
347
  console.log('context =>', this.context);
350
348
  window.forRedo = [];
351
349
  var store = this.context.store;
352
350
  var _this$props2 = this.props,
353
- projectActions = _this$props2.projectActions,
354
- catalog = _this$props2.catalog,
355
351
  stateExtractor = _this$props2.stateExtractor,
356
- state = _this$props2.state,
357
352
  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
353
  var newplugins = _toConsumableArray(plugins);
367
354
  newplugins.forEach(function (newplugin) {
368
355
  return newplugin(store, stateExtractor);
369
356
  });
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
357
  }
458
358
  }, {
459
359
  key: "componentWillUnmount",
@@ -467,6 +367,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
467
367
  }, {
468
368
  key: "componentWillReceiveProps",
469
369
  value: function componentWillReceiveProps(nextProps) {
370
+ var _oldState$catalog, _plannerState$catalog;
470
371
  var stateExtractor = nextProps.stateExtractor,
471
372
  state = nextProps.state,
472
373
  projectActions = nextProps.projectActions,
@@ -475,9 +376,18 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
475
376
 
476
377
  // handle external events
477
378
  if (this.props.externalEvent !== externalEvent) {
478
- handleExternalEvent(externalEvent, this.props);
379
+ handleExternalEvent(nextProps);
479
380
  }
480
381
  var plannerState = stateExtractor(state);
382
+ var oldState = stateExtractor(this.props.state);
383
+ 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)) {
384
+ // copy state.catalog to the props.catalog
385
+ // let catalog = this.state.stateCatalog;
386
+ // console.log('111111', plannerState?.catalog?.elements.toJS());
387
+ // catalog.elements = plannerState?.catalog?.elements.toJS();
388
+ // console.log('222222', catalog);
389
+ // this.setState({ stateCatalog: catalog });
390
+ }
481
391
  var catalogReady = plannerState.getIn(['catalog', 'ready']);
482
392
  if (!catalogReady) {
483
393
  projectActions.initCatalog(catalog);
@@ -573,7 +483,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
573
483
  }, /*#__PURE__*/React.createElement(Content, _extends({
574
484
  width: contentW,
575
485
  height: contentH,
576
- catalog: this.props.catalog,
486
+ catalog: this.state.stateCatalog,
577
487
  state: extractedState,
578
488
  toolBar: this.state.toolbar,
579
489
  setToolbar: this.setToolbar,
@@ -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";
@@ -489,7 +489,7 @@ export default function LiteRenderer(props) {
489
489
  }();
490
490
  initCatalog();
491
491
  // eslint-disable-next-line react-hooks/exhaustive-deps
492
- }, []);
492
+ }, [categoryData, data, id, catalogs, colorAlias, subgroups]);
493
493
 
494
494
  // Register items once SVGs are loaded
495
495
  useEffect(function () {
@@ -529,6 +529,13 @@ export default function LiteRenderer(props) {
529
529
  useEffect(function () {
530
530
  if (projectElement.length === 0) return;
531
531
  if (!catalogInitiated) return;
532
+ store.dispatch(initCatalog(MyCatalog));
533
+ if (sessionStorage.getItem(window.location.href)) {
534
+ var _jsonData = sessionStorage.getItem(window.location.href);
535
+ store.dispatch(loadProject(JSON.parse(_jsonData), categoryData));
536
+ sessionStorage.removeItem(window.location.href);
537
+ return;
538
+ }
532
539
  sessionStorage.setItem('projectTitle', projectElement[0].title);
533
540
  store.dispatch(rename(projectElement[0].title));
534
541
  sessionStorage.setItem('projectId', projectElement[0].id);
@@ -223,11 +223,10 @@ export function updateItemsAltitude(layerID, itemID, value) {
223
223
  value: value
224
224
  };
225
225
  }
226
- export function setDoorStyle(doorStyle, pathes, isAll) {
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
  }
@@ -247,7 +247,10 @@ var Catalog = /*#__PURE__*/function () {
247
247
  if (name === '') {
248
248
  throw new Error('Category has empty name');
249
249
  }
250
- return !this.hasCategory(name);
250
+ if (this.hasCategory(name)) {
251
+ throw new Error('Category has already been registered');
252
+ }
253
+ return true;
251
254
  }
252
255
 
253
256
  /**
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, pathes, isAll) {
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) {
@@ -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('initCatalogError', error);
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.elements[catid];
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.elements[catid];
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
- }), lineData, itemData, itemWall, itemSelected, mode !== MODE_DRAWING_LINE && vertices.valueSeq().filter(function (v) {
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: "'Microsoft YaHei UI', Courier, monospace"
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(25);
758
+ var textTranslation = vec1.clone().add(vec2).normalize().multiplyScalar(minLineLength * 2 / 3);
750
759
  angleTextO.add(textTranslation);
751
- angleTextO.y -= 5; // half the height of text `angle`
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(35);
756
- vec1 = vec1.multiplyScalar(35);
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 30,30 ").concat(angle, " 0 ").concat(t > 0 ? 1 : 0, " ").concat(pos2.x, ",").concat(pos2.y, " z\n ")
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(1.5, -1.5)"),
792
+ transform: "translate(".concat(angleTextO.x, ", ").concat(angleTextO.y, ") scale(").concat(minLineLength / 20, ", ").concat(-minLineLength / 20, ")"),
784
793
  style: STYLE_TEXT
785
- }, angle), /*#__PURE__*/React.createElement("circle", {
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, zoom } from 'react-svg-pan-zoom';
7
+ import { INITIAL_VALUE, ReactSVGPanZoom, TOOL_AUTO, TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT, POSITION_NONE } 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 calcDistanceArray = function calcDistanceArray() {
540
- var items = layer === null || layer === void 0 ? void 0 : layer.get('items');
541
- if (!items) return;
542
- items.forEach(function (item) {
543
- if ((item === null || item === void 0 ? void 0 : item.selected) === true) {
544
- var x = item.x,
545
- y = item.y,
546
- rotation = item.rotation,
547
- id = item.id;
548
- if (x == null || y == null) return;
549
- var val = {
550
- pos: {
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 _tlines = [];
893
- var _drawingLine = state.getIn(['scene', 'layers', layerID, 'lines', elementData.id]).toJS();
894
- getRelatedLines(_tlines, _drawingLine, vertices, lines);
895
- setRelatedLines(_tlines);
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
- var lineID = state.getIn(['scene', 'layers', layerID, 'selected', 'lines']).first();
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;
@@ -1345,7 +1309,7 @@ export default function Viewer2D(_ref, _ref2) {
1345
1309
  },
1346
1310
  width: width - rulerSize,
1347
1311
  height: height - rulerSize,
1348
- value: viewer2D.isEmpty() ? null : viewer2D.toJS(),
1312
+ value: viewer2D.isEmpty() ? INITIAL_VALUE : viewer2D.toJS(),
1349
1313
  onChangeValue: onChangeValue,
1350
1314
  tool: mode2Tool(mode),
1351
1315
  onChangeTool: onChangeTool,
@@ -1353,8 +1317,9 @@ export default function Viewer2D(_ref, _ref2) {
1353
1317
  onMouseDown: onMouseDown,
1354
1318
  onMouseMove: onMouseMove,
1355
1319
  onMouseUp: onMouseUp,
1356
- miniaturePosition: "none",
1357
- toolbarPosition: "none",
1320
+ toolbarProps: {
1321
+ position: POSITION_NONE
1322
+ },
1358
1323
  detectPinchGesture: false,
1359
1324
  disableDoubleClickZoomWithToolAuto: true,
1360
1325
  ref: Viewer
@@ -2559,7 +2559,6 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
2559
2559
  }));
2560
2560
  } else {
2561
2561
  document.getElementById('front') && (document.getElementById('front').style.display = 'none');
2562
- document.getElementById('error').style.display = 'none';
2563
2562
  this.renderer.domElement.style.display = 'none';
2564
2563
  return /*#__PURE__*/React.createElement("div", {
2565
2564
  style: {
@@ -2594,7 +2593,6 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
2594
2593
  alt: "img"
2595
2594
  }));
2596
2595
  } else {
2597
- !this.props.downloadFlag && (document.getElementById('error').style.display = 'block');
2598
2596
  this.renderer.domElement.style.pointerEvents = 'auto';
2599
2597
  this.renderer.domElement.style.opacity = '1';
2600
2598
  !this.props.downloadFlag && document.getElementById('front') && (document.getElementById('front').style.display = 'block');
package/es/constants.js CHANGED
@@ -579,6 +579,7 @@ export var ANIMATE_OBJECT_OPEN_DOOR_ROTATION_UNIT = 0.1;
579
579
  export var DIFFERENT_VALUES_PATH_LENGTH = 5;
580
580
  export var MIN_ANGLE_DISALLOW_DRAW_WALL = 45;
581
581
  export var UNIT_ANGLE = 5;
582
+ export var MAX_ANGLE_SCALE = 30;
582
583
  export var HDR_URLS = ['px.hdr', 'nx.hdr', 'py.hdr', 'ny.hdr', 'pz.hdr', 'nz.hdr'];
583
584
  export var SUBMIT_REQUEST_ASSIST = 'submit';
584
585
  export var SUBMIT_ADD_CART = 'addCart';
@@ -650,4 +651,9 @@ export var EXTERNAL_EVENT_TOGGLE_TO_ELEVATION = 'EXTERNAL_EVENT_TOGGLE_TO_ELEVAT
650
651
  export var EXTERNAL_EVENT_ADD_WALL = 'EXTERNAL_EVENT_ADD_WALL';
651
652
  export var EXTERNAL_EVENT_ADD_ITEM = 'EXTERNAL_EVENT_ADD_ITEM';
652
653
  export var EXTERNAL_EVENT_MOVE_PAN = 'EXTERNAL_EVENT_MOVE_PAN';
653
- export var EXTERNAL_EVENT_NEW_PROJECT = 'EXTERNAL_EVENT_NEW_PROJECT';
654
+ export var EXTERNAL_EVENT_NEW_PROJECT = 'EXTERNAL_EVENT_NEW_PROJECT';
655
+ export var EXTERNAL_EVENT_CHANGE_DOORSTYLE = 'EXTERNAL_EVENT_CHANGE_DOORSTYLE';
656
+ export var EXTERNAL_EVENT_SET_INITIAL_DATA = 'EXTERNAL_EVENT_SET_INITIAL_DATA';
657
+ export var EXTERNAL_EVENT_ADD_ROOM_SHAPE = 'EXTERNAL_EVENT_ADD_ROOM_SHAPE';
658
+ export var EXTERNAL_EVENT_ZOOM_IN = 'EXTERNAL_EVENT_ZOOM_IN';
659
+ export var EXTERNAL_EVENT_ZOOM_OUT = 'EXTERNAL_EVENT_ZOOM_OUT';