kitchen-simulator 4.0.0-queuedEvents → 4.0.0

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