kitchen-simulator 1.0.0-alin.17 → 1.0.0-alin.20

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.
@@ -475,7 +475,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
475
475
 
476
476
  // handle external events
477
477
  if (this.props.externalEvent !== externalEvent) {
478
- handleExternalEvent(externalEvent, this.props);
478
+ handleExternalEvent(nextProps);
479
479
  }
480
480
  var plannerState = stateExtractor(state);
481
481
  var catalogReady = plannerState.getIn(['catalog', 'ready']);
@@ -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
  }
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
  };
@@ -29,7 +29,8 @@ export default function Item(_ref, _ref2) {
29
29
  var itemsActions = _ref2.itemsActions;
30
30
  var x = item.x,
31
31
  y = item.y,
32
- rotation = item.rotation;
32
+ rotation = item.rotation,
33
+ id = item.id;
33
34
  var showBaseCabinetMeasure = scene.showBaseCabinetMeasure,
34
35
  showWallCabinetMeasure = scene.showWallCabinetMeasure;
35
36
  var vertices = layer.vertices;
@@ -281,6 +282,9 @@ export default function Item(_ref, _ref2) {
281
282
  PointArray.forEach(function (pointElement, index) {
282
283
  if (pointElement[0] == undefined) PointArray[index][0] = 0;
283
284
  });
285
+ if (Array.isArray(PointArray)) {
286
+ itemsActions.storeDistArray(layerID, id, PointArray);
287
+ }
284
288
  var renderedRuler = [];
285
289
  var ep = 0.1;
286
290
  if (item.selected) {
@@ -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,4 +1,3 @@
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; }
@@ -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;
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';
@@ -5,10 +5,13 @@ import mockProps from "./mocks/mockProps.json";
5
5
  import mockCategoryData from "./mocks/categoryData.json";
6
6
  import mockDataBundle from "./mocks/dataBundle.json";
7
7
  import cabinetPaylod from "./mocks/cabinetPayload.json";
8
+ import doorStylePaylod from "./mocks/doorStylePayload.json";
9
+ import oStylePaylod from "./mocks/oStylePayload.json";
10
+ import rectangleData from "./mocks/rectangleShape.json";
8
11
  import ReactDOM from 'react-dom';
9
12
  import LiteRenderer from "./LiteRenderer";
10
13
  import { Button } from 'antd';
11
- import { LEFT, RIGHT, TOP, BOTTOM, EXTERNAL_EVENT_ADD_ITEM, EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, EXTERNAL_EVENT_NEW_PROJECT } from "./constants";
14
+ import { LEFT, RIGHT, TOP, BOTTOM, EXTERNAL_EVENT_ADD_ITEM, EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, EXTERNAL_EVENT_NEW_PROJECT, EXTERNAL_EVENT_CHANGE_DOORSTYLE, EXTERNAL_EVENT_SET_INITIAL_DATA, EXTERNAL_EVENT_ADD_ROOM_SHAPE, EXTERNAL_EVENT_ZOOM_IN, EXTERNAL_EVENT_ZOOM_OUT } from "./constants";
12
15
 
13
16
  // --- renderer props ---
14
17
  var options = {
@@ -22,6 +25,18 @@ function WorkSpace(props) {
22
25
  externalEvent = _useState2[0],
23
26
  setExternalEvent = _useState2[1];
24
27
  var offset = 5;
28
+ useEffect(function () {
29
+ var evt = {
30
+ type: EXTERNAL_EVENT_SET_INITIAL_DATA,
31
+ payload: {
32
+ doorStyle: {
33
+ doorStyle: doorStylePaylod,
34
+ oStyle: oStylePaylod
35
+ }
36
+ }
37
+ };
38
+ setExternalEvent(evt);
39
+ }, []);
25
40
  return /*#__PURE__*/React.createElement("div", {
26
41
  className: "flex gap-4"
27
42
  }, /*#__PURE__*/React.createElement(Button, {
@@ -107,6 +122,28 @@ function WorkSpace(props) {
107
122
  }
108
123
  }, /*#__PURE__*/React.createElement("img", {
109
124
  src: "/assets/img/svg/bottombar/arrow-right.svg"
125
+ })), /*#__PURE__*/React.createElement(Button, {
126
+ actionType: "primary",
127
+ onClick: function onClick() {
128
+ var evt = {
129
+ type: EXTERNAL_EVENT_ZOOM_IN,
130
+ payload: {}
131
+ };
132
+ setExternalEvent(evt);
133
+ }
134
+ }, /*#__PURE__*/React.createElement("img", {
135
+ src: "/assets/img/svg/bottombar/arrow-minus.svg"
136
+ })), /*#__PURE__*/React.createElement(Button, {
137
+ actionType: "primary",
138
+ onClick: function onClick() {
139
+ var evt = {
140
+ type: EXTERNAL_EVENT_ZOOM_OUT,
141
+ payload: {}
142
+ };
143
+ setExternalEvent(evt);
144
+ }
145
+ }, /*#__PURE__*/React.createElement("img", {
146
+ src: "/assets/img/svg/bottombar/arrow-plus.svg"
110
147
  })), /*#__PURE__*/React.createElement(Button, {
111
148
  actionType: "primary",
112
149
  onClick: function onClick() {
@@ -134,9 +171,30 @@ function WorkSpace(props) {
134
171
  };
135
172
  setExternalEvent(evt);
136
173
  }
137
- }, "Add B12 Cabinet"), /*#__PURE__*/React.createElement(LiteRenderer, {
138
- width: 1200,
139
- height: 953,
174
+ }, "Add B12 Cabinet"), /*#__PURE__*/React.createElement(Button, {
175
+ actionType: "danger",
176
+ onClick: function onClick() {
177
+ var evt = {
178
+ type: EXTERNAL_EVENT_CHANGE_DOORSTYLE,
179
+ payload: {
180
+ doorStyle: doorStylePaylod,
181
+ isAll: true
182
+ }
183
+ };
184
+ setExternalEvent(evt);
185
+ }
186
+ }, "DoorStyle (Change into Midtown White Shaker)"), /*#__PURE__*/React.createElement(Button, {
187
+ actionType: "danger",
188
+ onClick: function onClick() {
189
+ var evt = {
190
+ type: EXTERNAL_EVENT_ADD_ROOM_SHAPE,
191
+ payload: rectangleData
192
+ };
193
+ setExternalEvent(evt);
194
+ }
195
+ }, "Add Room shape(rectangle)"), /*#__PURE__*/React.createElement(LiteRenderer, {
196
+ width: props.width,
197
+ height: props.height,
140
198
  projectElement: mockProps.projectElement,
141
199
  categoryData: mockCategoryData,
142
200
  dataBundle: mockDataBundle,
@@ -158,4 +216,11 @@ function WorkSpace(props) {
158
216
  }
159
217
  }));
160
218
  }
161
- ReactDOM.render(/*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(WorkSpace, null)), document.getElementById('app'));
219
+ ReactDOM.render(/*#__PURE__*/React.createElement(ContainerDimensions, null, function (_ref) {
220
+ var width = _ref.width,
221
+ height = _ref.height;
222
+ return /*#__PURE__*/React.createElement(WorkSpace, {
223
+ width: width,
224
+ height: height
225
+ });
226
+ }), document.getElementById('app'));
@@ -105,7 +105,7 @@ export default function (state, action) {
105
105
  case SELECT_TOOL_DRAWING_ITEM_3D:
106
106
  return Item.selectToolDrawingItem3D(state, action.sceneComponentType).updatedState;
107
107
  case SET_DOOR_STYLE:
108
- return Item.setDoorStyle(state, action.doorStyle, action.pathes, action.isAll).updatedState;
108
+ return Item.setDoorStyle(state, action.doorStyle, action.isAll).updatedState;
109
109
  case SET_HANDLE_MATERIAL:
110
110
  return Item.setHandleMaterial(state, action.material).updatedState;
111
111
  case SET_DOOR_HANDLE:
@@ -4,7 +4,7 @@ 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 _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import { fromJS, List, Map, Record } from 'immutable';
7
- import { EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, MODE_IDLE, MODE_2D_PAN, EXTERNAL_EVENT_ADD_ITEM, ARRAY_3D_MODES, MODE_IDLE_3D, MODE_ELEVATION_VIEW, TOP, BOTTOM, LEFT, RIGHT, EXTERNAL_EVENT_NEW_PROJECT } from "../constants";
7
+ import { EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, MODE_IDLE, MODE_2D_PAN, EXTERNAL_EVENT_ADD_ITEM, ARRAY_3D_MODES, MODE_IDLE_3D, MODE_ELEVATION_VIEW, TOP, BOTTOM, LEFT, RIGHT, EXTERNAL_EVENT_NEW_PROJECT, EXTERNAL_EVENT_CHANGE_DOORSTYLE, EXTERNAL_EVENT_SET_INITIAL_DATA, EXTERNAL_EVENT_ADD_ROOM_SHAPE, EXTERNAL_EVENT_ZOOM_IN, EXTERNAL_EVENT_ZOOM_OUT, ZOOM_VARIABLE } from "../constants";
8
8
  import { isEmpty } from "./helper";
9
9
  import exporter from "../catalog/utils/exporter";
10
10
  import { render2DItem, render3DItem } from "../catalog/utils/item-loader";
@@ -62,42 +62,46 @@ var loadSVGsByItem = /*#__PURE__*/function () {
62
62
  return _ref.apply(this, arguments);
63
63
  };
64
64
  }();
65
- export function handleExternalEvent(_x2, _x3) {
65
+ var compareSVGRect = function compareSVGRect(value) {
66
+ return value.e <= 10 && value.e + value.a * value.SVGWidth + 10 >= value.viewerWidth && value.f <= 80 && value.f + value.d * value.SVGHeight + 10 >= value.viewerHeight ? true : false;
67
+ };
68
+ export function handleExternalEvent(_x2) {
66
69
  return _handleExternalEvent.apply(this, arguments);
67
70
  }
68
71
  function _handleExternalEvent() {
69
- _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(evt, props) {
70
- var state, sLineCnt, element, catalog, outlineSVGData, catalogInstance, elementJs, _evt$payload, moveType, moveValue, value, defaulTitle, _t2, _t3;
72
+ _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(props) {
73
+ var evt, state, sLineCnt, element, catalog, outlineSVGData, catalogInstance, elementJs, _evt$payload, moveType, moveValue, value, defaulTitle, _evt$payload2, doorStyle, isAll, _doorStyle, _value, _zoomValue, _value2, _zoomValue2, _t2, _t3;
71
74
  return _regeneratorRuntime.wrap(function (_context2) {
72
75
  while (1) switch (_context2.prev = _context2.next) {
73
76
  case 0:
74
- state = props.state;
77
+ evt = props.externalEvent;
78
+ state = props.state.get('KitchenConfigurator');
75
79
  _t2 = evt === null || evt === void 0 ? void 0 : evt.type;
76
- _context2.next = _t2 === EXTERNAL_EVENT_TOGGLE_TO_3D ? 1 : _t2 === EXTERNAL_EVENT_TOGGLE_TO_2D ? 2 : _t2 === EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 3 : _t2 === EXTERNAL_EVENT_ADD_WALL ? 4 : _t2 === EXTERNAL_EVENT_ADD_ITEM ? 5 : _t2 === EXTERNAL_EVENT_MOVE_PAN ? 9 : _t2 === EXTERNAL_EVENT_NEW_PROJECT ? 15 : 16;
80
+ _context2.next = _t2 === EXTERNAL_EVENT_TOGGLE_TO_3D ? 1 : _t2 === EXTERNAL_EVENT_TOGGLE_TO_2D ? 2 : _t2 === EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 3 : _t2 === EXTERNAL_EVENT_ADD_WALL ? 4 : _t2 === EXTERNAL_EVENT_ADD_ITEM ? 5 : _t2 === EXTERNAL_EVENT_MOVE_PAN ? 9 : _t2 === EXTERNAL_EVENT_NEW_PROJECT ? 15 : _t2 === EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 16 : _t2 === EXTERNAL_EVENT_SET_INITIAL_DATA ? 17 : _t2 === EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 18 : _t2 === EXTERNAL_EVENT_ZOOM_IN ? 19 : _t2 === EXTERNAL_EVENT_ZOOM_OUT ? 22 : 25;
77
81
  break;
78
82
  case 1:
79
83
  props.projectActions.setMode(MODE_IDLE_3D);
80
- return _context2.abrupt("continue", 16);
84
+ return _context2.abrupt("continue", 25);
81
85
  case 2:
82
86
  props.projectActions.setMode(MODE_IDLE);
83
- return _context2.abrupt("continue", 16);
87
+ return _context2.abrupt("continue", 25);
84
88
  case 3:
85
- sLineCnt = state.getIn(['KitchenConfigurator', 'scene', 'layers', 'layer-1', 'selected', 'lines']).size;
89
+ sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
86
90
  if (sLineCnt > 0) props.projectActions.setMode(MODE_ELEVATION_VIEW);
87
- return _context2.abrupt("continue", 16);
91
+ return _context2.abrupt("continue", 25);
88
92
  case 4:
89
93
  if (state.mode === MODE_IDLE || state.mode === MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
90
94
  props.projectActions.setMode(MODE_IDLE);
91
95
  props.linesActions.selectToolDrawingLine('wall');
92
96
  }
93
- return _context2.abrupt("continue", 16);
97
+ return _context2.abrupt("continue", 25);
94
98
  case 5:
95
99
  if (isEmpty(evt === null || evt === void 0 ? void 0 : evt.payload)) {
96
100
  _context2.next = 8;
97
101
  break;
98
102
  }
99
103
  element = evt.payload;
100
- catalog = state.getIn(['KitchenConfigurator', 'catalog']).toJS(); // add item to catalog of state
104
+ catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
101
105
  if (!isEmpty(catalog === null || catalog === void 0 ? void 0 : catalog.elements[element.name])) {
102
106
  _context2.next = 7;
103
107
  break;
@@ -122,10 +126,10 @@ function _handleExternalEvent() {
122
126
  props.projectActions.pushLastSelectedCatalogElementToHistory(element);
123
127
  props.projectActions.setIsCabinetDrawing(true);
124
128
  case 8:
125
- return _context2.abrupt("continue", 16);
129
+ return _context2.abrupt("continue", 25);
126
130
  case 9:
127
131
  _evt$payload = evt.payload, moveType = _evt$payload.moveType, moveValue = _evt$payload.moveValue;
128
- value = state.getIn(['KitchenConfigurator', 'viewer2D']).toJS();
132
+ value = state.getIn(['viewer2D']).toJS();
129
133
  _t3 = moveType;
130
134
  _context2.next = _t3 === TOP ? 10 : _t3 === BOTTOM ? 11 : _t3 === RIGHT ? 12 : _t3 === LEFT ? 13 : 14;
131
135
  break;
@@ -142,14 +146,79 @@ function _handleExternalEvent() {
142
146
  value.e -= moveValue;
143
147
  return _context2.abrupt("continue", 14);
144
148
  case 14:
145
- if (value.e <= 10 && value.e + value.a * value.SVGWidth + 10 >= value.viewerWidth && value.f <= 80 && value.f + value.d * value.SVGHeight + 10 >= value.viewerHeight) props.viewer2DActions.updateCameraView(value);
146
- return _context2.abrupt("continue", 16);
149
+ if (compareSVGRect(value)) props.viewer2DActions.updateCameraView(value);
150
+ return _context2.abrupt("continue", 25);
147
151
  case 15:
148
152
  defaulTitle = 'Untitle';
149
153
  props.projectActions.newProject();
150
154
  props.projectActions.rename(defaulTitle);
151
- return _context2.abrupt("continue", 16);
155
+ return _context2.abrupt("continue", 25);
152
156
  case 16:
157
+ _evt$payload2 = evt.payload, doorStyle = _evt$payload2.doorStyle, isAll = _evt$payload2.isAll;
158
+ props.itemsActions.setDoorStyle(doorStyle, isAll);
159
+ return _context2.abrupt("continue", 25);
160
+ case 17:
161
+ _doorStyle = evt.payload.doorStyle;
162
+ props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle, _doorStyle.oStyle);
163
+ return _context2.abrupt("continue", 25);
164
+ case 18:
165
+ props.projectActions.loadProject(evt.payload, props.categoryData);
166
+ return _context2.abrupt("continue", 25);
167
+ case 19:
168
+ _value = state.getIn(['viewer2D']).toJS();
169
+ _value.a -= 0.1;
170
+ _value.d -= 0.1;
171
+ _value.e += _value.SVGWidth * 0.1 / 2;
172
+ _value.f += _value.SVGHeight * 0.1 / 2;
173
+ _zoomValue = parseInt((_value.a - 0.5) / ZOOM_VARIABLE);
174
+ if (!(_zoomValue > 404)) {
175
+ _context2.next = 20;
176
+ break;
177
+ }
178
+ return _context2.abrupt("return");
179
+ case 20:
180
+ if (!(_zoomValue < 35 || Number.isNaN(_zoomValue))) {
181
+ _context2.next = 21;
182
+ break;
183
+ }
184
+ return _context2.abrupt("return");
185
+ case 21:
186
+ while (!(_value.e <= 10)) {
187
+ _value.e -= 0.1;
188
+ }
189
+ while (!(_value.e + _value.a * _value.SVGWidth + 10 >= _value.viewerWidth)) {
190
+ _value.e += 0.1;
191
+ }
192
+ while (!(_value.f <= 80)) {
193
+ _value.f -= 0.1;
194
+ }
195
+ while (!(_value.f + _value.a * _value.SVGHeight + 10 >= _value.viewerHeight)) {
196
+ _value.f += 0.1;
197
+ }
198
+ if (compareSVGRect(_value)) props.viewer2DActions.updateCameraView(_value);
199
+ return _context2.abrupt("continue", 25);
200
+ case 22:
201
+ _value2 = state.getIn(['viewer2D']).toJS();
202
+ _value2.a += 0.1;
203
+ _value2.d += 0.1;
204
+ _value2.e -= _value2.SVGWidth * 0.1 / 2;
205
+ _value2.f -= _value2.SVGHeight * 0.1 / 2;
206
+ _zoomValue2 = parseInt((_value2.a - 0.5) / ZOOM_VARIABLE);
207
+ if (!(_zoomValue2 > 404)) {
208
+ _context2.next = 23;
209
+ break;
210
+ }
211
+ return _context2.abrupt("return");
212
+ case 23:
213
+ if (!(_zoomValue2 < 35 || Number.isNaN(_zoomValue2))) {
214
+ _context2.next = 24;
215
+ break;
216
+ }
217
+ return _context2.abrupt("return");
218
+ case 24:
219
+ if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2);
220
+ return _context2.abrupt("continue", 25);
221
+ case 25:
153
222
  case "end":
154
223
  return _context2.stop();
155
224
  }
@@ -484,7 +484,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
484
484
 
485
485
  // handle external events
486
486
  if (this.props.externalEvent !== externalEvent) {
487
- (0, _isolateEventHandler.handleExternalEvent)(externalEvent, this.props);
487
+ (0, _isolateEventHandler.handleExternalEvent)(nextProps);
488
488
  }
489
489
  var plannerState = stateExtractor(state);
490
490
  var catalogReady = plannerState.getIn(['catalog', 'ready']);
@@ -274,11 +274,10 @@ function updateItemsAltitude(layerID, itemID, value) {
274
274
  value: value
275
275
  };
276
276
  }
277
- function setDoorStyle(doorStyle, pathes, isAll) {
277
+ function setDoorStyle(doorStyle, isAll) {
278
278
  return {
279
279
  type: _constants.SET_DOOR_STYLE,
280
280
  doorStyle: doorStyle,
281
- pathes: pathes,
282
281
  isAll: isAll
283
282
  };
284
283
  }
package/lib/class/item.js CHANGED
@@ -1171,7 +1171,7 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1171
1171
  }
1172
1172
  }, {
1173
1173
  key: "setDoorStyle",
1174
- value: function setDoorStyle(state, doorStyle, pathes, isAll) {
1174
+ value: function setDoorStyle(state, doorStyle, isAll) {
1175
1175
  var _this2 = this;
1176
1176
  var keys = Object.keys(doorStyle.doorStyles);
1177
1177
  keys = keys.filter(function (elem) {