kitchen-simulator 3.1.14 → 4.0.0-alpha.12

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.
Files changed (105) hide show
  1. package/es/LiteKitchenConfigurator.js +204 -24
  2. package/es/LiteRenderer.js +277 -12
  3. package/es/actions/items-actions.js +6 -10
  4. package/es/actions/lines-actions.js +1 -3
  5. package/es/actions/project-actions.js +5 -15
  6. package/es/assets/Window.hdr +2100 -0
  7. package/es/assets/gltf/door_sliding.bin +0 -0
  8. package/es/assets/img/1.jpg +0 -0
  9. package/es/catalog/areas/area/planner-element.js +5 -10
  10. package/es/catalog/catalog.js +4 -1
  11. package/es/catalog/factories/area-factory-3d.js +17 -18
  12. package/es/catalog/factories/wall-factory-3d.js +2 -2
  13. package/es/catalog/factories/wall-factory.js +8 -8
  14. package/es/catalog/lines/wall/planner-element.js +9 -18
  15. package/es/catalog/utils/exporter.js +3 -6
  16. package/es/catalog/utils/item-loader.js +197 -202
  17. package/es/catalog/utils/mtl-loader.js +2 -2
  18. package/es/catalog/utils/obj-loader.js +2 -2
  19. package/es/class/item.js +127 -107
  20. package/es/class/line.js +2 -14
  21. package/es/class/project.js +44 -150
  22. package/es/components/content.js +6 -19
  23. package/es/components/viewer2d/grids/grid-streak.js +1 -1
  24. package/es/components/viewer2d/item.js +51 -84
  25. package/es/components/viewer2d/line.js +243 -315
  26. package/es/components/viewer2d/ruler.js +36 -16
  27. package/es/components/viewer2d/rulerDist.js +75 -44
  28. package/es/components/viewer2d/utils.js +0 -6
  29. package/es/components/viewer2d/viewer2d.js +205 -301
  30. package/es/components/viewer3d/front3D.js +2 -3
  31. package/es/components/viewer3d/libs/mtl-loader.js +2 -2
  32. package/es/components/viewer3d/libs/obj-loader.js +2 -2
  33. package/es/components/viewer3d/libs/orbit-controls.js +4 -3
  34. package/es/components/viewer3d/libs/pointer-lock-controls.js +7 -6
  35. package/es/components/viewer3d/viewer3d.js +80 -127
  36. package/es/constants.js +3 -110
  37. package/es/devLiteRenderer.js +38 -597
  38. package/es/index.js +86 -16
  39. package/es/models.js +5 -8
  40. package/es/plugins/SVGLoader.js +5 -7
  41. package/es/plugins/keyboard.js +6 -15
  42. package/es/reducers/items-reducer.js +5 -5
  43. package/es/reducers/lines-reducer.js +1 -1
  44. package/es/reducers/project-reducer.js +3 -5
  45. package/es/shared-style.js +4 -4
  46. package/es/utils/geometry.js +0 -161
  47. package/es/utils/get-edges-of-subgraphs.js +1 -1
  48. package/es/utils/graph-cycles.js +1 -1
  49. package/es/utils/graph.js +1 -1
  50. package/es/utils/helper.js +2 -67
  51. package/es/utils/isolate-event-handler.js +124 -1367
  52. package/es/utils/molding.js +2 -238
  53. package/lib/LiteKitchenConfigurator.js +205 -25
  54. package/lib/LiteRenderer.js +278 -13
  55. package/lib/actions/items-actions.js +6 -10
  56. package/lib/actions/lines-actions.js +1 -3
  57. package/lib/actions/project-actions.js +4 -15
  58. package/lib/assets/Window.hdr +2100 -0
  59. package/lib/assets/gltf/door_sliding.bin +0 -0
  60. package/lib/assets/img/1.jpg +0 -0
  61. package/lib/catalog/areas/area/planner-element.js +5 -11
  62. package/lib/catalog/catalog.js +4 -1
  63. package/lib/catalog/factories/area-factory-3d.js +14 -15
  64. package/lib/catalog/factories/wall-factory-3d.js +2 -2
  65. package/lib/catalog/factories/wall-factory.js +8 -8
  66. package/lib/catalog/lines/wall/planner-element.js +9 -19
  67. package/lib/catalog/utils/exporter.js +3 -6
  68. package/lib/catalog/utils/item-loader.js +194 -199
  69. package/lib/catalog/utils/mtl-loader.js +2 -9
  70. package/lib/catalog/utils/obj-loader.js +2 -10
  71. package/lib/class/item.js +125 -105
  72. package/lib/class/line.js +1 -13
  73. package/lib/class/project.js +43 -149
  74. package/lib/components/content.js +6 -19
  75. package/lib/components/viewer2d/grids/grid-streak.js +1 -1
  76. package/lib/components/viewer2d/item.js +50 -83
  77. package/lib/components/viewer2d/line.js +242 -315
  78. package/lib/components/viewer2d/ruler.js +35 -15
  79. package/lib/components/viewer2d/rulerDist.js +75 -44
  80. package/lib/components/viewer2d/utils.js +0 -7
  81. package/lib/components/viewer2d/viewer2d.js +205 -299
  82. package/lib/components/viewer3d/front3D.js +2 -3
  83. package/lib/components/viewer3d/libs/mtl-loader.js +2 -9
  84. package/lib/components/viewer3d/libs/obj-loader.js +2 -9
  85. package/lib/components/viewer3d/libs/orbit-controls.js +5 -11
  86. package/lib/components/viewer3d/libs/pointer-lock-controls.js +7 -13
  87. package/lib/components/viewer3d/viewer3d.js +79 -125
  88. package/lib/constants.js +7 -115
  89. package/lib/devLiteRenderer.js +33 -592
  90. package/lib/index.js +86 -16
  91. package/lib/models.js +5 -8
  92. package/lib/plugins/SVGLoader.js +5 -7
  93. package/lib/plugins/keyboard.js +6 -15
  94. package/lib/reducers/items-reducer.js +5 -5
  95. package/lib/reducers/lines-reducer.js +1 -1
  96. package/lib/reducers/project-reducer.js +2 -4
  97. package/lib/shared-style.js +4 -4
  98. package/lib/utils/geometry.js +0 -162
  99. package/lib/utils/get-edges-of-subgraphs.js +1 -6
  100. package/lib/utils/graph-cycles.js +8 -7
  101. package/lib/utils/graph.js +1 -6
  102. package/lib/utils/helper.js +3 -70
  103. package/lib/utils/isolate-event-handler.js +121 -1364
  104. package/lib/utils/molding.js +0 -238
  105. package/package.json +1 -1
@@ -4,9 +4,9 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
4
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; }
5
5
  import React, { useEffect, useRef, useState } from 'react';
6
6
  import PropTypes from 'prop-types';
7
- import { ReactSVGPanZoom, TOOL_AUTO, TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT } from 'react-svg-pan-zoom';
7
+ import { ReactSVGPanZoom, TOOL_AUTO, TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT, zoom } from 'react-svg-pan-zoom';
8
8
  import * as constants from "../../constants";
9
- import { DECIMAL_PLACES_2, LINE_THICKNESS, MIN_ANGLE_DISALLOW_DRAW_WALL, MODE_ELEVATION_VIEW, MODE_IDLE, UNIT_ANGLE, INTERNAL_EVENT_SELECT_ELEMENT, INTERNAL_EVENT_DRAG_ELEMENT, INTERNAL_EVENT_DRAW_ELEMENT, INTERNAL_EVENT_ROTATE_ELEMENT } from "../../constants";
9
+ import { DECIMAL_PLACES_2, LINE_THICKNESS, MIN_ANGLE_DISALLOW_DRAW_WALL, MODE_ELEVATION_VIEW, MODE_IDLE, UNIT_ANGLE } from "../../constants";
10
10
  import State from "./state";
11
11
  import * as SharedStyle from "../../shared-style";
12
12
  import { RulerX, RulerY } from "./export";
@@ -16,13 +16,10 @@ import { convert } from "../../utils/convert-units-lite";
16
16
  import { Map } from 'immutable';
17
17
  import { formatNumber } from "../../utils/math";
18
18
  import { isEmpty } from "../../utils/helper"; // variables
19
- import { isWarningItem } from "./utils";
20
- import { MoldingUtils } from "../../utils/export";
21
19
  // variables
22
20
  var pinFlag = false;
23
21
  var sFlag = false; //for all object move
24
22
  var sPoint = {}; //for all object move
25
- var mouseDownPoint = {}; // mouse clicked point
26
23
  var endPoint = {};
27
24
  var current_sel_obj_id = null;
28
25
  var allItemRect;
@@ -126,8 +123,7 @@ export default function Viewer2D(_ref, _ref2) {
126
123
  width = _ref.width,
127
124
  height = _ref.height,
128
125
  setToolbar = _ref.setToolbar,
129
- replaceCabinet = _ref.replaceCabinet,
130
- onInternalEvent = _ref.onInternalEvent;
126
+ replaceCabinet = _ref.replaceCabinet;
131
127
  var viewer2DActions = _ref2.viewer2DActions,
132
128
  linesActions = _ref2.linesActions,
133
129
  holesActions = _ref2.holesActions,
@@ -582,134 +578,56 @@ export default function Viewer2D(_ref, _ref2) {
582
578
  y: y - sPoint.y
583
579
  };
584
580
  projectActions.selectAll(differs);
585
- } else {
586
- switch (mode) {
587
- case constants.MODE_DRAWING_LINE:
588
- // check whether the drawing line is started.
581
+ } else switch (mode) {
582
+ case constants.MODE_DRAWING_LINE:
583
+ // check whether the drawing line is started.
584
+ if (drawStart || state.getIn(['scene', 'setLineAttributes'])) {
589
585
  var lineID = state.getIn(['scene', 'layers', layerID, 'selected', 'lines']).first();
586
+ var _vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
590
587
  var lines = state.getIn(['scene', 'layers', layerID, 'lines']).toJS();
591
588
  var drawingLine = state.getIn(['scene', 'layers', layerID, 'lines', lineID]).toJS();
592
589
  var tlines = [];
593
- if (drawStart || state.getIn(['scene', 'setLineAttributes'])) {
594
- var _vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
595
- setdrawStart(false);
596
- // get the lines that have same points with drawing line.
597
- getRelatedLines(tlines, drawingLine, _vertices, lines);
598
- setRelatedLines(tlines);
599
- linesActions.updateDrawingLine(x, y, tlines, state.snapMask);
600
- } else {
601
- linesActions.updateDrawingLine(x, y, relatedLines, state.snapMask);
602
- }
603
-
604
- // Blocked 90 degree snap.
605
- // let prevVertexID = state.getIn(['scene', 'layers', layerID, 'selected', 'vertices']).toJS()[0];
606
- // let prevVertex = state.getIn(['scene', 'layers', layerID, 'vertices', prevVertexID]);
607
- // let dx = Math.abs(x - prevVertex.x);
608
- // let dy = Math.abs(y - prevVertex.y);
609
- // if (dx > dy) y = prevVertex.y
610
- // else x = prevVertex.x;
611
- break;
612
- case constants.MODE_DRAWING_HOLE:
613
- holesActions.updateDrawingHole(layerID, x, y);
614
- break;
615
- case constants.MODE_DRAWING_ITEM:
616
- var _layer = scene.layers.get(layerID);
617
- var flag = false;
618
- _layer.items.some(function (item) {
619
- if (item.selected) {
620
- item.counterTop.uri = _layer.counterTop.uri;
621
- current_sel_obj_id = item.id;
622
- flag = true;
623
- }
624
- });
625
- if (current_sel_obj_id === null || !flag) {
626
- itemsActions.updateDrawingItem(layerID, x, y);
627
- endPoint.x = x;
628
- endPoint.y = y;
629
- } else {
630
- prepareSnap();
631
- var _GeometryUtils$calcSn = GeometryUtils.calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea),
632
- nx = _GeometryUtils$calcSn.nx,
633
- ny = _GeometryUtils$calcSn.ny,
634
- rot = _GeometryUtils$calcSn.rot,
635
- rotRad = _GeometryUtils$calcSn.rotRad;
636
- var _val = {
637
- pos: {
638
- x: x,
639
- y: y
640
- },
641
- rotRad: rotRad,
642
- size: allItemRect.cur && allItemRect.cur.size,
643
- layoutpos: allItemRect.cur && allItemRect.cur.layoutpos,
644
- is_corner: allItemRect.cur && allItemRect.cur.is_corner
645
- };
646
- var _GeometryUtils$getAll = GeometryUtils.getAllHoleRect(scene, _val),
647
- _isSect = _GeometryUtils$getAll.isSect,
648
- _snap = _GeometryUtils$getAll.snap;
649
- if (!isEmpty(_snap) && _isSect) {
650
- if (_snap.length == 1) _val.pos = {
651
- x: _snap[0].x,
652
- y: _snap[0].y
653
- };else {
654
- if ((_snap[0].x - x) * (_snap[0].x - x) + (_snap[0].y - y) * (_snap[0].y - y) < (_snap[1].x - x) * (_snap[1].x - x) + (_snap[1].y - y) * (_snap[1].y - y)) _val.pos = {
655
- x: _snap[0].x,
656
- y: _snap[0].y
657
- };else _val.pos = {
658
- x: _snap[1].x,
659
- y: _snap[1].y
660
- };
661
- }
662
- var interSect = GeometryUtils.validInterSect(allItemRect.others, _val);
663
- if (interSect) {
664
- nx = _val.pos.x;
665
- ny = _val.pos.y;
666
- }
667
- }
668
- _val.pos = {
669
- x: nx,
670
- y: ny
671
- };
672
- var _isrectSect = GeometryUtils.validInterSect(allItemRect.others, _val);
673
- if (_isrectSect && _isSect) {
674
- itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
675
- itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
676
- endPoint.x = nx;
677
- endPoint.y = ny;
678
- }
679
- if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('cabinet')) {
680
- itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
681
- itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
682
- endPoint.x = nx;
683
- endPoint.y = ny;
684
- }
685
- if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Hood') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Range') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top')) {
686
- itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
687
- itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
688
- endPoint.x = nx;
689
- endPoint.y = ny;
690
- }
590
+ setdrawStart(false);
591
+ // get the lines that have same points with drawing line.
592
+ getRelatedLines(tlines, drawingLine, _vertices, lines);
593
+ setRelatedLines(tlines);
594
+ linesActions.updateDrawingLine(x, y, tlines, state.snapMask);
595
+ } else {
596
+ linesActions.updateDrawingLine(x, y, relatedLines, state.snapMask);
597
+ }
598
+ // Blocked 90 degree snap.
599
+ // let prevVertexID = state.getIn(['scene', 'layers', layerID, 'selected', 'vertices']).toJS()[0];
600
+ // let prevVertex = state.getIn(['scene', 'layers', layerID, 'vertices', prevVertexID]);
601
+ // let dx = Math.abs(x - prevVertex.x);
602
+ // let dy = Math.abs(y - prevVertex.y);
603
+ // if (dx > dy) y = prevVertex.y
604
+ // else x = prevVertex.x;
605
+ break;
606
+ case constants.MODE_DRAWING_HOLE:
607
+ holesActions.updateDrawingHole(layerID, x, y);
608
+ break;
609
+ case constants.MODE_DRAWING_ITEM:
610
+ var _layer = scene.layers.get(layerID);
611
+ var flag = false;
612
+ _layer.items.some(function (item) {
613
+ if (item.selected) {
614
+ item.counterTop.uri = _layer.counterTop.uri;
615
+ current_sel_obj_id = item.id;
616
+ flag = true;
691
617
  }
692
- break;
693
- case constants.MODE_DRAGGING_HOLE:
694
- holesActions.updateDraggingHole(x, y);
695
- break;
696
- case constants.MODE_DRAGGING_LINE:
697
- linesActions.updateDraggingLine(x, y, relatedLines, state.snapMask);
698
- break;
699
- case constants.MODE_DRAGGING_VERTEX:
700
- var vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
701
- getConnectedLines();
702
- var result = getEndPoint(vertices, x, y, 'DRAGGING_VERTEX');
703
- verticesActions.updateDraggingVertex(result.x, result.y, state.snapMask);
704
- break;
705
- case constants.MODE_DRAGGING_ITEM:
618
+ });
619
+ if (current_sel_obj_id === null || !flag) {
620
+ itemsActions.updateDrawingItem(layerID, x, y);
621
+ endPoint.x = x;
622
+ endPoint.y = y;
623
+ } else {
706
624
  prepareSnap();
707
- var _GeometryUtils$calcSn2 = GeometryUtils.calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea),
708
- nx = _GeometryUtils$calcSn2.nx,
709
- ny = _GeometryUtils$calcSn2.ny,
710
- rot = _GeometryUtils$calcSn2.rot,
711
- rotRad = _GeometryUtils$calcSn2.rotRad;
712
- var val = {
625
+ var _GeometryUtils$calcSn = GeometryUtils.calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea),
626
+ nx = _GeometryUtils$calcSn.nx,
627
+ ny = _GeometryUtils$calcSn.ny,
628
+ rot = _GeometryUtils$calcSn.rot,
629
+ rotRad = _GeometryUtils$calcSn.rotRad;
630
+ var _val = {
713
631
  pos: {
714
632
  x: x,
715
633
  y: y
@@ -719,50 +637,125 @@ export default function Viewer2D(_ref, _ref2) {
719
637
  layoutpos: allItemRect.cur && allItemRect.cur.layoutpos,
720
638
  is_corner: allItemRect.cur && allItemRect.cur.is_corner
721
639
  };
722
- var _GeometryUtils$getAll2 = GeometryUtils.getAllHoleRect(scene, val),
723
- isSect = _GeometryUtils$getAll2.isSect,
724
- snap = _GeometryUtils$getAll2.snap;
725
- if (!isEmpty(snap) && isSect) {
726
- if (snap.length == 1) val.pos = {
727
- x: snap[0].x,
728
- y: snap[0].y
729
- };else if (snap.length == 2) {
730
- if ((snap[0].x - x) * (snap[0].x - x) + (snap[0].y - y) * (snap[0].y - y) < (snap[1].x - x) * (snap[1].x - x) + (snap[1].y - y) * (snap[1].y - y)) val.pos = {
731
- x: snap[0].x,
732
- y: snap[0].y
733
- };else val.pos = {
734
- x: snap[1].x,
735
- y: snap[1].y
640
+ var _GeometryUtils$getAll = GeometryUtils.getAllHoleRect(scene, _val),
641
+ _isSect = _GeometryUtils$getAll.isSect,
642
+ _snap = _GeometryUtils$getAll.snap;
643
+ if (!isEmpty(_snap) && _isSect) {
644
+ if (_snap.length == 1) _val.pos = {
645
+ x: _snap[0].x,
646
+ y: _snap[0].y
647
+ };else {
648
+ if ((_snap[0].x - x) * (_snap[0].x - x) + (_snap[0].y - y) * (_snap[0].y - y) < (_snap[1].x - x) * (_snap[1].x - x) + (_snap[1].y - y) * (_snap[1].y - y)) _val.pos = {
649
+ x: _snap[0].x,
650
+ y: _snap[0].y
651
+ };else _val.pos = {
652
+ x: _snap[1].x,
653
+ y: _snap[1].y
736
654
  };
737
655
  }
738
- var _interSect = GeometryUtils.validInterSect(allItemRect.others, val);
739
- if (_interSect) {
740
- nx = val.pos.x;
741
- ny = val.pos.y;
656
+ var interSect = GeometryUtils.validInterSect(allItemRect.others, _val);
657
+ if (interSect) {
658
+ nx = _val.pos.x;
659
+ ny = _val.pos.y;
742
660
  }
743
661
  }
744
- val.pos = {
662
+ _val.pos = {
745
663
  x: nx,
746
664
  y: ny
747
665
  };
748
- var isrectSect = GeometryUtils.validInterSect(allItemRect.others, val);
749
- if (isrectSect && isSect) {
666
+ var _isrectSect = GeometryUtils.validInterSect(allItemRect.others, _val);
667
+ if (_isrectSect && _isSect) {
750
668
  itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
751
669
  itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
670
+ endPoint.x = nx;
671
+ endPoint.y = ny;
752
672
  }
753
- if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cabinet')) {
673
+ if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('cabinet')) {
754
674
  itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
755
675
  itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
676
+ endPoint.x = nx;
677
+ endPoint.y = ny;
756
678
  }
757
679
  if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Hood') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Range') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top')) {
758
680
  itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
759
681
  itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
682
+ endPoint.x = nx;
683
+ endPoint.y = ny;
760
684
  }
761
- break;
762
- case constants.MODE_ROTATING_ITEM:
763
- itemsActions.updateRotatingItem(x, y);
764
- break;
765
- }
685
+ }
686
+ break;
687
+ case constants.MODE_DRAGGING_HOLE:
688
+ holesActions.updateDraggingHole(x, y);
689
+ break;
690
+ case constants.MODE_DRAGGING_LINE:
691
+ linesActions.updateDraggingLine(x, y, relatedLines, state.snapMask);
692
+ break;
693
+ case constants.MODE_DRAGGING_VERTEX:
694
+ var vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
695
+ getConnectedLines();
696
+ var result = getEndPoint(vertices, x, y, 'DRAGGING_VERTEX');
697
+ verticesActions.updateDraggingVertex(result.x, result.y, state.snapMask);
698
+ break;
699
+ case constants.MODE_DRAGGING_ITEM:
700
+ prepareSnap();
701
+ var _GeometryUtils$calcSn2 = GeometryUtils.calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea),
702
+ nx = _GeometryUtils$calcSn2.nx,
703
+ ny = _GeometryUtils$calcSn2.ny,
704
+ rot = _GeometryUtils$calcSn2.rot,
705
+ rotRad = _GeometryUtils$calcSn2.rotRad;
706
+ var val = {
707
+ pos: {
708
+ x: x,
709
+ y: y
710
+ },
711
+ rotRad: rotRad,
712
+ size: allItemRect.cur && allItemRect.cur.size,
713
+ layoutpos: allItemRect.cur && allItemRect.cur.layoutpos,
714
+ is_corner: allItemRect.cur && allItemRect.cur.is_corner
715
+ };
716
+ var _GeometryUtils$getAll2 = GeometryUtils.getAllHoleRect(scene, val),
717
+ isSect = _GeometryUtils$getAll2.isSect,
718
+ snap = _GeometryUtils$getAll2.snap;
719
+ if (!isEmpty(snap) && isSect) {
720
+ if (snap.length == 1) val.pos = {
721
+ x: snap[0].x,
722
+ y: snap[0].y
723
+ };else if (snap.length == 2) {
724
+ if ((snap[0].x - x) * (snap[0].x - x) + (snap[0].y - y) * (snap[0].y - y) < (snap[1].x - x) * (snap[1].x - x) + (snap[1].y - y) * (snap[1].y - y)) val.pos = {
725
+ x: snap[0].x,
726
+ y: snap[0].y
727
+ };else val.pos = {
728
+ x: snap[1].x,
729
+ y: snap[1].y
730
+ };
731
+ }
732
+ var _interSect = GeometryUtils.validInterSect(allItemRect.others, val);
733
+ if (_interSect) {
734
+ nx = val.pos.x;
735
+ ny = val.pos.y;
736
+ }
737
+ }
738
+ val.pos = {
739
+ x: nx,
740
+ y: ny
741
+ };
742
+ var isrectSect = GeometryUtils.validInterSect(allItemRect.others, val);
743
+ if (isrectSect && isSect) {
744
+ itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
745
+ itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
746
+ }
747
+ if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cabinet')) {
748
+ itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
749
+ itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
750
+ }
751
+ if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Hood') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Range') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top')) {
752
+ itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
753
+ itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
754
+ }
755
+ break;
756
+ case constants.MODE_ROTATING_ITEM:
757
+ itemsActions.updateRotatingItem(x, y);
758
+ break;
766
759
  }
767
760
  viewerEvent.originalEvent.stopPropagation();
768
761
  };
@@ -784,44 +777,38 @@ export default function Viewer2D(_ref, _ref2) {
784
777
  return;
785
778
  }
786
779
  }
787
- mouseDownPoint = {
788
- x: x,
789
- y: y
790
- };
791
780
  if (mode === constants.MODE_IDLE) {
792
781
  var elementData = extractElementData(event.target);
793
782
  if (!elementData) return;
794
- if (sCount < 2) {
795
- switch (elementData.prototype) {
796
- case 'lines':
797
- if (elementData.selected) {
798
- if (elementData.part === 'remove') break;else if (elementData.part === 'elevation') break;
799
- linesActions.beginDraggingLine(elementData.layer, elementData.id, x, y, state.snapMask);
800
- }
801
- break;
802
- case 'vertices':
803
- verticesActions.beginDraggingVertex(elementData.layer, elementData.id, x, y, state.snapMask);
804
- break;
805
- case 'items':
806
- setToolbar('');
807
- current_sel_obj_id = elementData.id;
808
- if (elementData.part === 'rotation-anchor') itemsActions.beginRotatingItem(elementData.layer, elementData.id, x, y);else if (elementData.part === 'remove') break;else if (elementData.part === 'duplicate') break;else if (elementData.part === 'warning_edit') break;else {
809
- // closes the setting dialog
810
- if (document.getElementById('setting_dialog')) {
811
- document.getElementById('setting_dialog').style.display = 'none';
812
- }
813
- itemsActions.selectItem(elementData.layer, elementData.id);
814
- // projectActions.setMode(constants.MODE_DRAGGING_ITEM);
815
- itemsActions.beginDraggingItem(elementData.layer, elementData.id, x, y);
816
- replaceCabinet(false);
783
+ if (sCount < 2) switch (elementData.prototype) {
784
+ case 'lines':
785
+ if (elementData.selected) {
786
+ if (elementData.part === 'remove') break;else if (elementData.part === 'elevation') break;
787
+ linesActions.beginDraggingLine(elementData.layer, elementData.id, x, y, state.snapMask);
788
+ }
789
+ break;
790
+ case 'vertices':
791
+ verticesActions.beginDraggingVertex(elementData.layer, elementData.id, x, y, state.snapMask);
792
+ break;
793
+ case 'items':
794
+ setToolbar('');
795
+ current_sel_obj_id = elementData.id;
796
+ if (elementData.part === 'rotation-anchor') itemsActions.beginRotatingItem(elementData.layer, elementData.id, x, y);else if (elementData.part === 'remove') break;else if (elementData.part === 'duplicate') break;else if (elementData.part === 'warning_edit') break;else {
797
+ // closes the setting dialog
798
+ if (document.getElementById('setting_dialog')) {
799
+ document.getElementById('setting_dialog').style.display = 'none';
817
800
  }
818
- break;
819
- case 'holes':
820
- if (elementData.selected) holesActions.beginDraggingHole(elementData.layer, elementData.id, x, y);
821
- break;
822
- default:
823
- break;
824
- }
801
+ itemsActions.selectItem(elementData.layer, elementData.id);
802
+ // projectActions.setMode(constants.MODE_DRAGGING_ITEM);
803
+ itemsActions.beginDraggingItem(elementData.layer, elementData.id, x, y);
804
+ replaceCabinet(false);
805
+ }
806
+ break;
807
+ case 'holes':
808
+ if (elementData.selected) holesActions.beginDraggingHole(elementData.layer, elementData.id, x, y);
809
+ break;
810
+ default:
811
+ break;
825
812
  } else {
826
813
  sPoint.x = x;
827
814
  sPoint.y = y;
@@ -855,63 +842,12 @@ export default function Viewer2D(_ref, _ref2) {
855
842
  var _mapCursorPosition3 = mapCursorPosition(viewerEvent),
856
843
  x = _mapCursorPosition3.x,
857
844
  y = _mapCursorPosition3.y;
858
- var draggingDistance = Math.sqrt((x - mouseDownPoint.x) * (x - mouseDownPoint.x) + (y - mouseDownPoint.y) * (y - mouseDownPoint.y));
859
845
  var vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
860
846
  var lines = state.getIn(['scene', 'layers', layerID, 'lines']).toJS();
861
- var elementData = extractElementData(event.target);
862
- var selectedLayer = scene.getIn(['layers', layerID]);
863
- var elementPrototype = null;
864
- var internalType = null;
865
- switch (mode) {
866
- case constants.MODE_DRAWING_LINE:
867
- elementPrototype = 'lines';
868
- internalType = INTERNAL_EVENT_DRAW_ELEMENT;
869
- break;
870
- case constants.MODE_DRAWING_HOLE:
871
- elementPrototype = 'holes';
872
- internalType = INTERNAL_EVENT_DRAW_ELEMENT;
873
- break;
874
- case constants.MODE_DRAWING_ITEM:
875
- elementPrototype = 'items';
876
- internalType = INTERNAL_EVENT_DRAW_ELEMENT;
877
- break;
878
- case constants.MODE_DRAGGING_LINE:
879
- elementPrototype = 'lines';
880
- internalType = INTERNAL_EVENT_DRAG_ELEMENT;
881
- break;
882
- case constants.MODE_DRAGGING_HOLE:
883
- elementPrototype = 'holes';
884
- internalType = INTERNAL_EVENT_DRAG_ELEMENT;
885
- break;
886
- case constants.MODE_DRAGGING_VERTEX:
887
- elementPrototype = 'lines';
888
- internalType = INTERNAL_EVENT_DRAG_ELEMENT;
889
- break;
890
- case constants.MODE_ROTATING_ITEM:
891
- elementPrototype = 'items';
892
- internalType = INTERNAL_EVENT_ROTATE_ELEMENT;
893
- break;
894
-
895
- // item selection be came from dragging mode
896
- case constants.MODE_DRAGGING_ITEM:
897
- elementPrototype = 'items';
898
- internalType = INTERNAL_EVENT_SELECT_ELEMENT;
899
- break;
900
- case constants.MODE_IDLE:
901
- switch (elementData === null || elementData === void 0 ? void 0 : elementData.prototype) {
902
- case 'areas':
903
- case 'lines':
904
- case 'holes':
905
- if (isEmpty(elementData === null || elementData === void 0 ? void 0 : elementData.part)) {
906
- elementPrototype = elementData === null || elementData === void 0 ? void 0 : elementData.prototype;
907
- internalType = INTERNAL_EVENT_SELECT_ELEMENT;
908
- }
909
- break;
910
- }
911
- break;
912
- }
913
847
  switch (mode) {
914
848
  case constants.MODE_IDLE:
849
+ var elementData = extractElementData(event.target);
850
+ var selectedLayer = scene.getIn(['layers', layerID]);
915
851
  switch (elementData ? elementData.prototype : 'none') {
916
852
  case 'areas':
917
853
  if (document.getElementById('setting_dialog')) {
@@ -948,7 +884,7 @@ export default function Viewer2D(_ref, _ref2) {
948
884
  case 'items':
949
885
  if (elementData.part === 'duplicate') {
950
886
  var currentObject = state.getIn(['scene', 'layers', layerID, 'items', elementData.id]);
951
- if (!isWarningItem(currentObject)) itemsActions.duplicateSelected(currentObject, onInternalEvent); // send draw internal event when duplicating
887
+ itemsActions.duplicateSelected(currentObject);
952
888
  break;
953
889
  } else if (elementData.part === 'remove') {
954
890
  projectActions.remove();
@@ -958,7 +894,6 @@ export default function Viewer2D(_ref, _ref2) {
958
894
  if (document.getElementById('setting_dialog')) {
959
895
  document.getElementById('setting_dialog').style.display = 'none';
960
896
  }
961
- internalType = constants.INTERNAL_EVENT_REPLACE_CABINET;
962
897
  itemsActions.selectItem(elementData.layer, elementData.id);
963
898
  replaceCabinet(true);
964
899
  break;
@@ -973,12 +908,14 @@ export default function Viewer2D(_ref, _ref2) {
973
908
  id: "ruler_numberInput",
974
909
  style: {
975
910
  position: 'absolute',
976
- left: bbox.left - (200 - bbox.width) / 2,
911
+ left: bbox.left - (150 - bbox.width) / 2,
977
912
  top: bbox.top - (50 - bbox.height) / 2,
978
913
  zIndex: 1000
979
914
  }
980
915
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
981
916
  style: {
917
+ width: 150,
918
+ height: 50,
982
919
  textAlign: 'center',
983
920
  paddingRight: 10,
984
921
  fontSize: '16px',
@@ -1005,12 +942,14 @@ export default function Viewer2D(_ref, _ref2) {
1005
942
  id: "ruler_numberInput",
1006
943
  style: {
1007
944
  position: 'absolute',
1008
- left: bbox.left - (200 - bbox.width) / 2,
945
+ left: bbox.left - (150 - bbox.width) / 2,
1009
946
  top: bbox.top - (50 - bbox.height) / 2,
1010
947
  zIndex: 1000
1011
948
  }
1012
949
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
1013
950
  style: {
951
+ width: 150,
952
+ height: 50,
1014
953
  textAlign: 'center',
1015
954
  paddingRight: 10,
1016
955
  fontSize: '16px',
@@ -1038,12 +977,14 @@ export default function Viewer2D(_ref, _ref2) {
1038
977
  id: "ruler_numberInput",
1039
978
  style: {
1040
979
  position: 'absolute',
1041
- left: bbox.left - (200 - bbox.width) / 2,
980
+ left: bbox.left - (150 - bbox.width) / 2,
1042
981
  top: bbox.top - (50 - bbox.height) / 2,
1043
982
  zIndex: 1000
1044
983
  }
1045
984
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
1046
985
  style: {
986
+ width: 150,
987
+ height: 50,
1047
988
  textAlign: 'center',
1048
989
  padding: 'auto',
1049
990
  fontSize: '16px',
@@ -1071,12 +1012,14 @@ export default function Viewer2D(_ref, _ref2) {
1071
1012
  id: "ruler_numberInput",
1072
1013
  style: {
1073
1014
  position: 'absolute',
1074
- left: bbox.left - (200 - bbox.width) / 2,
1015
+ left: bbox.left - (150 - bbox.width) / 2,
1075
1016
  top: bbox.top - (50 - bbox.height) / 2,
1076
1017
  zIndex: 1000
1077
1018
  }
1078
1019
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
1079
1020
  style: {
1021
+ width: 150,
1022
+ height: 50,
1080
1023
  textAlign: 'center',
1081
1024
  paddingRight: 10,
1082
1025
  fontSize: '16px',
@@ -1104,12 +1047,14 @@ export default function Viewer2D(_ref, _ref2) {
1104
1047
  id: "ruler_numberInput",
1105
1048
  style: {
1106
1049
  position: 'absolute',
1107
- left: bbox.left - (200 - bbox.width) / 2,
1050
+ left: bbox.left - (150 - bbox.width) / 2,
1108
1051
  top: bbox.top - (50 - bbox.height) / 2,
1109
1052
  zIndex: 1000
1110
1053
  }
1111
1054
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
1112
1055
  style: {
1056
+ width: 150,
1057
+ height: 50,
1113
1058
  textAlign: 'center',
1114
1059
  paddingRight: 10,
1115
1060
  fontSize: '16px',
@@ -1137,12 +1082,14 @@ export default function Viewer2D(_ref, _ref2) {
1137
1082
  id: "ruler_numberInput",
1138
1083
  style: {
1139
1084
  position: 'absolute',
1140
- left: bbox.left - (200 - bbox.width) / 2,
1085
+ left: bbox.left - (150 - bbox.width) / 2,
1141
1086
  top: bbox.top - (50 - bbox.height) / 2,
1142
1087
  zIndex: 1000
1143
1088
  }
1144
1089
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
1145
1090
  style: {
1091
+ width: 150,
1092
+ height: 50,
1146
1093
  textAlign: 'center',
1147
1094
  paddingRight: 10,
1148
1095
  fontSize: '16px',
@@ -1169,7 +1116,7 @@ export default function Viewer2D(_ref, _ref2) {
1169
1116
  id: "ruler_numberInput",
1170
1117
  style: {
1171
1118
  position: 'absolute',
1172
- left: bbox.left - (200 - bbox.width) / 2,
1119
+ left: bbox.left - (150 - bbox.width) / 2,
1173
1120
  top: bbox.top - (50 - bbox.height) / 2,
1174
1121
  zIndex: 1000
1175
1122
  }
@@ -1199,7 +1146,7 @@ export default function Viewer2D(_ref, _ref2) {
1199
1146
  break;
1200
1147
  case constants.MODE_WAITING_DRAWING_LINE:
1201
1148
  setdrawStart(true);
1202
- linesActions.beginDrawingLine(layerID, x, y, state.snapMask, onInternalEvent);
1149
+ linesActions.beginDrawingLine(layerID, x, y, state.snapMask);
1203
1150
  break;
1204
1151
  case constants.MODE_DRAWING_LINE:
1205
1152
  // Blocked 90 degree snap.
@@ -1213,16 +1160,13 @@ export default function Viewer2D(_ref, _ref2) {
1213
1160
  getConnectedLines();
1214
1161
  var endInfor = getEndPoint(vertices, x, y, 'END_DRAWIN_LINE');
1215
1162
  linesActions.endDrawingLine(endInfor.x, endInfor.y, state.snapMask);
1216
- linesActions.beginDrawingLine(layerID, endInfor.x, endInfor.y, state.snapMask, onInternalEvent);
1163
+ linesActions.beginDrawingLine(layerID, endInfor.x, endInfor.y, state.snapMask);
1217
1164
  break;
1218
1165
  case constants.MODE_DRAWING_HOLE:
1219
1166
  holesActions.endDrawingHole(layerID, x, y);
1220
1167
  break;
1221
1168
  case constants.MODE_DRAWING_ITEM:
1222
- {
1223
- var itemData = state.getIn(['scene', 'layers', layerID, elementData === null || elementData === void 0 ? void 0 : elementData.prototype, elementData === null || elementData === void 0 ? void 0 : elementData.id]);
1224
- itemsActions.endDrawingItem(layerID, itemData.isInitialPos ? itemData.x : endPoint.x, itemData.isInitialPos ? itemData.y : endPoint.y);
1225
- }
1169
+ itemsActions.endDrawingItem(layerID, endPoint.x, endPoint.y);
1226
1170
  break;
1227
1171
  case constants.MODE_DRAGGING_LINE:
1228
1172
  linesActions.endDraggingLine(x, y, relatedLines, state.snapMask);
@@ -1243,58 +1187,18 @@ export default function Viewer2D(_ref, _ref2) {
1243
1187
  itemsActions.endRotatingItem(x, y);
1244
1188
  break;
1245
1189
  }
1246
- if (internalType) {
1247
- var _currentObject2;
1248
- var _currentObject = state.getIn(['scene', 'layers', layerID, elementData === null || elementData === void 0 ? void 0 : elementData.prototype, elementData === null || elementData === void 0 ? void 0 : elementData.id]);
1249
- if (internalType === INTERNAL_EVENT_SELECT_ELEMENT && ((_currentObject2 = _currentObject) === null || _currentObject2 === void 0 ? void 0 : _currentObject2.prototype) === 'items' && draggingDistance > constants.EPSILON) internalType = INTERNAL_EVENT_DRAG_ELEMENT;else if (internalType === INTERNAL_EVENT_DRAW_ELEMENT || draggingDistance > constants.EPSILON) {
1250
- var elementID = state.getIn(['scene', 'layers', layerID, 'selected', elementPrototype]).first();
1251
- _currentObject = state.getIn(['scene', 'layers', layerID, elementPrototype, elementID]);
1252
- }
1253
- if (_currentObject) {
1254
- var _currentObject3, _currentObject4, _currentObject5;
1255
- var payload = (_currentObject3 = _currentObject) === null || _currentObject3 === void 0 ? void 0 : _currentObject3.toJS();
1256
- if (((_currentObject4 = _currentObject) === null || _currentObject4 === void 0 ? void 0 : _currentObject4.prototype) === 'lines') {
1257
- // caculating length of selected line//
1258
- var v_a = layer.vertices.get(_currentObject.vertices.get(0));
1259
- var v_b = layer.vertices.get(_currentObject.vertices.get(1));
1260
- var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
1261
- var _length3 = convert(distance).from('cm').to(layer.unit);
1262
- payload.length = _length3;
1263
- //////////////////////////////////////
1264
- } else if (((_currentObject5 = _currentObject) === null || _currentObject5 === void 0 ? void 0 : _currentObject5.prototype) === 'items') {
1265
- // check this cabinet has warning box
1266
- payload.isWarning = isWarningItem(_currentObject);
1267
- // check this item is available molding
1268
- payload.isMoldingAvailable = MoldingUtils.isEnableItemForMolding(layer, _currentObject);
1269
- // check this item is snapped to wall
1270
- payload.isAttachedWall = MoldingUtils.isAttachedWall(layer, _currentObject);
1271
- }
1272
-
1273
- // send selection event befor replace event
1274
- if (internalType === constants.INTERNAL_EVENT_REPLACE_CABINET) {
1275
- onInternalEvent === null || onInternalEvent === void 0 || onInternalEvent({
1276
- type: INTERNAL_EVENT_SELECT_ELEMENT,
1277
- value: payload
1278
- });
1279
- }
1280
- onInternalEvent === null || onInternalEvent === void 0 || onInternalEvent({
1281
- type: internalType,
1282
- value: payload
1283
- });
1284
- }
1285
- }
1286
1190
  event.stopPropagation();
1287
1191
  };
1288
1192
  var onChangeValue = function onChangeValue(value) {
1289
1193
  if (sFlag) return;
1290
1194
  var _zoomValue = parseInt((value.a - 0.5) / constants.ZOOM_VARIABLE);
1291
- if (_zoomValue > constants.MAX_ZOOM_IN_SCALE) return;
1195
+ if (_zoomValue > 404) return;
1292
1196
  if (_zoomValue < 0 || Number.isNaN(_zoomValue)) return;
1293
1197
  if (rulerEdit !== null && value.startX && value.startY || value.lastAction === 'zoom') {
1294
- var _rulerEdit = document.getElementById('ruler_numberInput') && document.getElementById('ruler_numberInput'),
1198
+ var _rulerEdit = document.getElementById('ruler_numberInput'),
1295
1199
  _rect;
1296
1200
  if (rulerEditID !== null) {
1297
- _rect = document.getElementById(rulerEditID) && document.getElementById(rulerEditID);
1201
+ _rect = document.getElementById(rulerEditID);
1298
1202
  }
1299
1203
  var bbox;
1300
1204
  if (_rect && _rulerEdit) {