kitchen-simulator 2.0.16 → 2.0.17

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.
@@ -5,7 +5,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import { Map } from 'immutable';
8
- 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, MODE_DRAWING_LINE, 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, EXTERNAL_EVENT_UNDO, EXTERNAL_EVENT_REDO, EXTERNAL_EVENT_SET_MOLDING, EXTERNAL_EVENT_PROJECT_SETTING, PROJECT_SETTING_OPTION, EXTERNAL_EVENT_SYNC_SCENE, INTERNAL_EVENT_SYNC_SCENE, EXTERNAL_EVENT_UPDATE_ATTRIBUTE, ATT_ITEM_POS, ATT_LINE_LENGTH, ATT_VERTEXT_ONE, ATT_VERTEXT_TWO, ATT_HOLE_OFFSET_A, ATT_HOLE_OFFSET_B, UNIT_CENTIMETER, UNIT_INCH, EXTERNAL_EVENT_UPDATE_PROPERTY, PROP_FLIP_DOOR_HANDLE, PROP_OPEN_DOORS, EXTERNAL_EVENT_LOAD_PROJECT, INTERNAL_EVENT_ITEMS_CATALOG, EXTERNAL_EVENT_ADD_HOLE, EXTERNAL_EVENT_CENTERING_2D, EXTERNAL_EVENT_DUPLICATE_ELEMENT, EXTERNAL_EVENT_DELETE_ELEMENT, ELEMENT_HOLE, ELEMENT_ITEM, ELEMENT_LINE, MAX_ZOOM_IN_SCALE } from "../constants";
8
+ 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, MODE_DRAWING_LINE, 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, EXTERNAL_EVENT_UNDO, EXTERNAL_EVENT_REDO, EXTERNAL_EVENT_SET_MOLDING, EXTERNAL_EVENT_PROJECT_SETTING, PROJECT_SETTING_OPTION, EXTERNAL_EVENT_SYNC_SCENE, INTERNAL_EVENT_SYNC_SCENE, EXTERNAL_EVENT_UPDATE_ATTRIBUTE, ATT_ITEM_POS, ATT_LINE_LENGTH, ATT_VERTEXT_ONE, ATT_VERTEXT_TWO, ATT_HOLE_OFFSET_A, ATT_HOLE_OFFSET_B, UNIT_CENTIMETER, UNIT_INCH, EXTERNAL_EVENT_UPDATE_PROPERTY, PROP_FLIP_DOOR_HANDLE, PROP_OPEN_DOORS, EXTERNAL_EVENT_LOAD_PROJECT, INTERNAL_EVENT_ITEMS_CATALOG, EXTERNAL_EVENT_ADD_HOLE, EXTERNAL_EVENT_CENTERING_2D, EXTERNAL_EVENT_DUPLICATE_ELEMENT, EXTERNAL_EVENT_DELETE_ELEMENT, ELEMENT_HOLE, ELEMENT_ITEM, ELEMENT_LINE, MAX_ZOOM_IN_SCALE, EXTERNAL_EVENT_REPLACE_CABINET } from "../constants";
9
9
  import { isEmpty } from "./helper";
10
10
  import exporter from "../catalog/utils/exporter";
11
11
  import { render2DItem, render3DItem, render3DApplianceItem, render3DLightingItem } from "../catalog/utils/item-loader";
@@ -984,7 +984,7 @@ export function handleExternalEvent(_x10) {
984
984
  function _handleExternalEvent() {
985
985
  _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(props) {
986
986
  var _evt$payload3, _evt$payload4;
987
- var evt, state, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, _evt$payload5, moveType, moveValue, value, defaulTitle, _evt$payload6, doorStyle, itemCDS, isAll, _doorStyle, _value, _value2, layer, bb, w, h, viewer, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value3, layerId, _layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i2, _i3, _i4, _props$onInternalEven2, _t5, _t6;
987
+ var evt, state, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, _evt$payload5, moveType, moveValue, value, defaulTitle, _evt$payload6, doorStyle, itemCDS, isAll, _doorStyle, _value, _value2, layer, bb, w, h, viewer, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value3, layerId, _layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i2, _i3, _i4, _evt$payload9, _evt$payload0, _evt$payload1, _evt$payload10, _layerID, _layer2, orginalItemInfo, originalItem, originalItemPos, replaceItem, _props$onInternalEven2, _t5, _t6;
988
988
  return _regeneratorRuntime.wrap(function (_context9) {
989
989
  while (1) switch (_context9.prev = _context9.next) {
990
990
  case 0:
@@ -992,7 +992,7 @@ function _handleExternalEvent() {
992
992
  evt = props.externalEvent;
993
993
  state = props.state.get('KitchenConfigurator');
994
994
  _t5 = evt === null || evt === void 0 ? void 0 : evt.type;
995
- _context9.next = _t5 === EXTERNAL_EVENT_LOAD_PROJECT ? 1 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_3D ? 5 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_2D ? 6 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 7 : _t5 === EXTERNAL_EVENT_ADD_WALL ? 8 : _t5 === EXTERNAL_EVENT_ADD_ITEM ? 9 : _t5 === EXTERNAL_EVENT_ADD_HOLE ? 12 : _t5 === EXTERNAL_EVENT_MOVE_PAN ? 13 : _t5 === EXTERNAL_EVENT_NEW_PROJECT ? 19 : _t5 === EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 20 : _t5 === EXTERNAL_EVENT_SET_INITIAL_DATA ? 21 : _t5 === EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 22 : _t5 === EXTERNAL_EVENT_ZOOM_IN ? 23 : _t5 === EXTERNAL_EVENT_ZOOM_OUT ? 24 : _t5 === EXTERNAL_EVENT_CENTERING_2D ? 25 : _t5 === EXTERNAL_EVENT_UNDO ? 26 : _t5 === EXTERNAL_EVENT_REDO ? 27 : _t5 === EXTERNAL_EVENT_SET_MOLDING ? 28 : _t5 === EXTERNAL_EVENT_DUPLICATE_ELEMENT ? 30 : _t5 === EXTERNAL_EVENT_DELETE_ELEMENT ? 31 : _t5 === EXTERNAL_EVENT_PROJECT_SETTING ? 32 : _t5 === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? 33 : _t5 === EXTERNAL_EVENT_UPDATE_PROPERTY ? 33 : _t5 === EXTERNAL_EVENT_SYNC_SCENE ? 34 : 35;
995
+ _context9.next = _t5 === EXTERNAL_EVENT_LOAD_PROJECT ? 1 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_3D ? 5 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_2D ? 6 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 7 : _t5 === EXTERNAL_EVENT_ADD_WALL ? 8 : _t5 === EXTERNAL_EVENT_ADD_ITEM ? 9 : _t5 === EXTERNAL_EVENT_ADD_HOLE ? 12 : _t5 === EXTERNAL_EVENT_MOVE_PAN ? 13 : _t5 === EXTERNAL_EVENT_NEW_PROJECT ? 19 : _t5 === EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 20 : _t5 === EXTERNAL_EVENT_SET_INITIAL_DATA ? 21 : _t5 === EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 22 : _t5 === EXTERNAL_EVENT_ZOOM_IN ? 23 : _t5 === EXTERNAL_EVENT_ZOOM_OUT ? 24 : _t5 === EXTERNAL_EVENT_CENTERING_2D ? 25 : _t5 === EXTERNAL_EVENT_UNDO ? 26 : _t5 === EXTERNAL_EVENT_REDO ? 27 : _t5 === EXTERNAL_EVENT_SET_MOLDING ? 28 : _t5 === EXTERNAL_EVENT_DUPLICATE_ELEMENT ? 30 : _t5 === EXTERNAL_EVENT_DELETE_ELEMENT ? 31 : _t5 === EXTERNAL_EVENT_PROJECT_SETTING ? 32 : _t5 === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? 33 : _t5 === EXTERNAL_EVENT_UPDATE_PROPERTY ? 33 : _t5 === EXTERNAL_EVENT_REPLACE_CABINET ? 34 : _t5 === EXTERNAL_EVENT_SYNC_SCENE ? 36 : 37;
996
996
  break;
997
997
  case 1:
998
998
  // prepare item data request
@@ -1068,23 +1068,23 @@ function _handleExternalEvent() {
1068
1068
  };
1069
1069
  }());
1070
1070
  }
1071
- return _context9.abrupt("continue", 35);
1071
+ return _context9.abrupt("continue", 37);
1072
1072
  case 5:
1073
1073
  props.projectActions.setMode(MODE_IDLE_3D);
1074
- return _context9.abrupt("continue", 35);
1074
+ return _context9.abrupt("continue", 37);
1075
1075
  case 6:
1076
1076
  props.projectActions.setMode(MODE_IDLE);
1077
- return _context9.abrupt("continue", 35);
1077
+ return _context9.abrupt("continue", 37);
1078
1078
  case 7:
1079
1079
  sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
1080
1080
  if (sLineCnt > 0) props.projectActions.setMode(MODE_ELEVATION_VIEW);
1081
- return _context9.abrupt("continue", 35);
1081
+ return _context9.abrupt("continue", 37);
1082
1082
  case 8:
1083
1083
  if (state.mode === MODE_IDLE || state.mode === MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
1084
1084
  props.projectActions.setMode(MODE_IDLE);
1085
1085
  props.linesActions.selectToolDrawingLine('wall');
1086
1086
  }
1087
- return _context9.abrupt("continue", 35);
1087
+ return _context9.abrupt("continue", 37);
1088
1088
  case 9:
1089
1089
  if (isEmpty(evt === null || evt === void 0 ? void 0 : evt.payload)) {
1090
1090
  _context9.next = 11;
@@ -1115,10 +1115,10 @@ function _handleExternalEvent() {
1115
1115
  props.projectActions.pushLastSelectedCatalogElementToHistory(element);
1116
1116
  props.projectActions.setIsCabinetDrawing(true);
1117
1117
  case 11:
1118
- return _context9.abrupt("continue", 35);
1118
+ return _context9.abrupt("continue", 37);
1119
1119
  case 12:
1120
1120
  ARRAY_3D_MODES.includes(state.mode) ? props.holesActions.selectToolDrawingHole3D(evt === null || evt === void 0 || (_evt$payload3 = evt.payload) === null || _evt$payload3 === void 0 ? void 0 : _evt$payload3.holeName) : props.holesActions.selectToolDrawingHole(evt === null || evt === void 0 || (_evt$payload4 = evt.payload) === null || _evt$payload4 === void 0 ? void 0 : _evt$payload4.holeName);
1121
- return _context9.abrupt("continue", 35);
1121
+ return _context9.abrupt("continue", 37);
1122
1122
  case 13:
1123
1123
  _evt$payload5 = evt.payload, moveType = _evt$payload5.moveType, moveValue = _evt$payload5.moveValue;
1124
1124
  value = state.getIn(['viewer2D']).toJS();
@@ -1139,23 +1139,23 @@ function _handleExternalEvent() {
1139
1139
  return _context9.abrupt("continue", 18);
1140
1140
  case 18:
1141
1141
  updateViwer2D(value, props.viewer2DActions);
1142
- return _context9.abrupt("continue", 35);
1142
+ return _context9.abrupt("continue", 37);
1143
1143
  case 19:
1144
1144
  defaulTitle = 'Untitle';
1145
1145
  props.projectActions.newProject();
1146
1146
  props.projectActions.rename(defaulTitle);
1147
- return _context9.abrupt("continue", 35);
1147
+ return _context9.abrupt("continue", 37);
1148
1148
  case 20:
1149
1149
  _evt$payload6 = evt.payload, doorStyle = _evt$payload6.doorStyle, itemCDS = _evt$payload6.itemCDS, isAll = _evt$payload6.isAll;
1150
1150
  props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
1151
- return _context9.abrupt("continue", 35);
1151
+ return _context9.abrupt("continue", 37);
1152
1152
  case 21:
1153
1153
  _doorStyle = evt.payload.doorStyle;
1154
1154
  props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle);
1155
- return _context9.abrupt("continue", 35);
1155
+ return _context9.abrupt("continue", 37);
1156
1156
  case 22:
1157
1157
  props.projectActions.loadProject(evt.payload);
1158
- return _context9.abrupt("continue", 35);
1158
+ return _context9.abrupt("continue", 37);
1159
1159
  case 23:
1160
1160
  _value = state.getIn(['viewer2D']).toJS();
1161
1161
  _value.a += 0.1;
@@ -1163,7 +1163,7 @@ function _handleExternalEvent() {
1163
1163
  _value.e -= _value.SVGWidth * 0.1 / 2;
1164
1164
  _value.f -= _value.SVGHeight * 0.1 / 2;
1165
1165
  updateViwer2D(_value, props.viewer2DActions);
1166
- return _context9.abrupt("continue", 35);
1166
+ return _context9.abrupt("continue", 37);
1167
1167
  case 24:
1168
1168
  _value2 = state.getIn(['viewer2D']).toJS();
1169
1169
  _value2.a -= 0.1;
@@ -1171,7 +1171,7 @@ function _handleExternalEvent() {
1171
1171
  _value2.e += _value2.SVGWidth * 0.1 / 2;
1172
1172
  _value2.f += _value2.SVGHeight * 0.1 / 2;
1173
1173
  updateViwer2D(_value2, props.viewer2DActions);
1174
- return _context9.abrupt("continue", 35);
1174
+ return _context9.abrupt("continue", 37);
1175
1175
  case 25:
1176
1176
  // calculate the bounding box of all elements in plan
1177
1177
  layer = state.scene.getIn(['layers', state.scene.selectedLayer]);
@@ -1205,28 +1205,28 @@ function _handleExternalEvent() {
1205
1205
  viewer.d = 0.99;
1206
1206
  }
1207
1207
  updateViwer2D(viewer, props.viewer2DActions);
1208
- return _context9.abrupt("continue", 35);
1208
+ return _context9.abrupt("continue", 37);
1209
1209
  case 26:
1210
1210
  props.projectActions.undo();
1211
- return _context9.abrupt("continue", 35);
1211
+ return _context9.abrupt("continue", 37);
1212
1212
  case 27:
1213
1213
  props.projectActions.redo();
1214
- return _context9.abrupt("continue", 35);
1214
+ return _context9.abrupt("continue", 37);
1215
1215
  case 28:
1216
1216
  _evt$payload7 = evt.payload, moldingInfo = _evt$payload7.moldingInfo, isGlobal = _evt$payload7.isGlobal;
1217
1217
  _context9.next = 29;
1218
1218
  return loadMoldingSvg(moldingInfo);
1219
1219
  case 29:
1220
1220
  props.itemsActions.setMolding(moldingInfo, isGlobal);
1221
- return _context9.abrupt("continue", 35);
1221
+ return _context9.abrupt("continue", 37);
1222
1222
  case 30:
1223
1223
  distElement = getElement(evt.payload, state);
1224
1224
  if (distElement) props.itemsActions.duplicateSelected(distElement);
1225
- return _context9.abrupt("continue", 35);
1225
+ return _context9.abrupt("continue", 37);
1226
1226
  case 31:
1227
1227
  _distElement = getElement(evt.payload, state);
1228
1228
  if (_distElement) props.projectActions.remove(_distElement);
1229
- return _context9.abrupt("continue", 35);
1229
+ return _context9.abrupt("continue", 37);
1230
1230
  case 32:
1231
1231
  _evt$payload8 = evt.payload, option = _evt$payload8.option, _value3 = _evt$payload8.value;
1232
1232
  if (option === PROJECT_SETTING_OPTION.UPDATE_CEIL_HEIGHT) {
@@ -1241,7 +1241,7 @@ function _handleExternalEvent() {
1241
1241
  } else if (option === PROJECT_SETTING_OPTION.CHANGE_WINDOW_DOOR_MEASURE) {
1242
1242
  props.viewer2DActions.changeWindowDoorMeasure(_value3);
1243
1243
  }
1244
- return _context9.abrupt("continue", 35);
1244
+ return _context9.abrupt("continue", 37);
1245
1245
  case 33:
1246
1246
  layerId = state.getIn(['scene', 'selectedLayer']);
1247
1247
  _layer = state.getIn(['scene', 'layers', layerId]);
@@ -1249,8 +1249,31 @@ function _handleExternalEvent() {
1249
1249
  for (_i2 = 0; _i2 < selectedLines.size; _i2++) (evt === null || evt === void 0 ? void 0 : evt.type) === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['lines', selectedLines.get(_i2)]), evt.payload, state, _layer, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['lines', selectedLines.get(_i2)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1250
1250
  for (_i3 = 0; _i3 < selectedHoles.size; _i3++) (evt === null || evt === void 0 ? void 0 : evt.type) === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['holes', selectedHoles.get(_i3)]), evt.payload, state, _layer, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['holes', selectedHoles.get(_i3)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1251
1251
  for (_i4 = 0; _i4 < selectedItems.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['items', selectedItems.get(_i4)]), evt.payload, state, _layer, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['items', selectedItems.get(_i4)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1252
- return _context9.abrupt("continue", 35);
1252
+ return _context9.abrupt("continue", 37);
1253
1253
  case 34:
1254
+ _layerID = state.scene.selectedLayer;
1255
+ _layer2 = state.scene.getIn(['layers', _layerID]).toJS();
1256
+ orginalItemInfo = evt === null || evt === void 0 || (_evt$payload9 = evt.payload) === null || _evt$payload9 === void 0 ? void 0 : _evt$payload9.orginalItemInfo;
1257
+ originalItem = _layer2 === null || _layer2 === void 0 ? void 0 : _layer2.items[orginalItemInfo.id];
1258
+ _context9.next = 35;
1259
+ return addItemToCatalog(evt.payload.replaceItemInfo, state, props.catalog, props.projectActions);
1260
+ case 35:
1261
+ originalItemPos = {
1262
+ rotation: originalItem.rotation,
1263
+ selectedItemId: originalItem.id,
1264
+ x: originalItem.x,
1265
+ y: originalItem.y
1266
+ };
1267
+ replaceItem = {
1268
+ name: evt === null || evt === void 0 || (_evt$payload0 = evt.payload) === null || _evt$payload0 === void 0 || (_evt$payload0 = _evt$payload0.replaceItemInfo) === null || _evt$payload0 === void 0 ? void 0 : _evt$payload0.name,
1269
+ info: {
1270
+ width: evt === null || evt === void 0 || (_evt$payload1 = evt.payload) === null || _evt$payload1 === void 0 || (_evt$payload1 = _evt$payload1.replaceItemInfo) === null || _evt$payload1 === void 0 || (_evt$payload1 = _evt$payload1.sizeinfo) === null || _evt$payload1 === void 0 ? void 0 : _evt$payload1.width,
1271
+ height: evt === null || evt === void 0 || (_evt$payload10 = evt.payload) === null || _evt$payload10 === void 0 || (_evt$payload10 = _evt$payload10.replaceItemInfo) === null || _evt$payload10 === void 0 || (_evt$payload10 = _evt$payload10.sizeinfo) === null || _evt$payload10 === void 0 ? void 0 : _evt$payload10.height
1272
+ }
1273
+ };
1274
+ props.itemsActions.replaceItem(originalItemPos, originalItem, replaceItem);
1275
+ return _context9.abrupt("continue", 37);
1276
+ case 36:
1254
1277
  // send scene object from 3DTool to HostApp using internalEvent
1255
1278
  (_props$onInternalEven2 = props.onInternalEvent) === null || _props$onInternalEven2 === void 0 || _props$onInternalEven2.call(props, {
1256
1279
  type: INTERNAL_EVENT_SYNC_SCENE,
@@ -1258,8 +1281,8 @@ function _handleExternalEvent() {
1258
1281
  scene: state.scene.toJS()
1259
1282
  }
1260
1283
  });
1261
- return _context9.abrupt("continue", 35);
1262
- case 35:
1284
+ return _context9.abrupt("continue", 37);
1285
+ case 37:
1263
1286
  case "end":
1264
1287
  return _context9.stop();
1265
1288
  }
@@ -577,6 +577,7 @@ function Viewer2D(_ref, _ref2) {
577
577
  // let evt = new Event('mousemove-planner-event');
578
578
  // evt.viewerEvent = viewerEvent;
579
579
  // document.dispatchEvent(evt);
580
+ var elementPrototype, internalType;
580
581
  var _mapCursorPosition = mapCursorPosition(viewerEvent),
581
582
  x = _mapCursorPosition.x,
582
583
  y = _mapCursorPosition.y;
@@ -590,56 +591,168 @@ function Viewer2D(_ref, _ref2) {
590
591
  y: y - sPoint.y
591
592
  };
592
593
  projectActions.selectAll(differs);
593
- } else switch (mode) {
594
- case constants.MODE_DRAWING_LINE:
595
- // check whether the drawing line is started.
596
- if (drawStart || state.getIn(['scene', 'setLineAttributes'])) {
594
+ } else {
595
+ switch (mode) {
596
+ case constants.MODE_DRAWING_LINE:
597
+ elementPrototype = 'lines';
598
+ internalType = _constants.INTERNAL_EVENT_DRAW_ELEMENT;
599
+ break;
600
+ case constants.MODE_DRAWING_HOLE:
601
+ elementPrototype = 'holes';
602
+ internalType = _constants.INTERNAL_EVENT_DRAW_ELEMENT;
603
+ break;
604
+ case constants.MODE_DRAWING_ITEM:
605
+ elementPrototype = 'items';
606
+ internalType = _constants.INTERNAL_EVENT_DRAW_ELEMENT;
607
+ break;
608
+ case constants.MODE_DRAGGING_HOLE:
609
+ elementPrototype = 'holes';
610
+ internalType = _constants.INTERNAL_EVENT_DRAG_ELEMENT;
611
+ break;
612
+ case constants.MODE_DRAGGING_LINE:
613
+ elementPrototype = 'lines';
614
+ internalType = _constants.INTERNAL_EVENT_DRAG_ELEMENT;
615
+ break;
616
+ case constants.MODE_DRAGGING_VERTEX:
617
+ elementPrototype = 'lines';
618
+ internalType = _constants.INTERNAL_EVENT_DRAG_ELEMENT;
619
+ break;
620
+ case constants.MODE_DRAGGING_ITEM:
621
+ elementPrototype = 'items';
622
+ internalType = _constants.INTERNAL_EVENT_DRAG_ELEMENT;
623
+ break;
624
+ case constants.MODE_ROTATING_ITEM:
625
+ elementPrototype = 'items';
626
+ internalType = _constants.INTERNAL_EVENT_ROTATE_ELEMENT;
627
+ break;
628
+ }
629
+ switch (mode) {
630
+ case constants.MODE_DRAWING_LINE:
631
+ // check whether the drawing line is started.
597
632
  var lineID = state.getIn(['scene', 'layers', layerID, 'selected', 'lines']).first();
598
- var _vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
599
633
  var lines = state.getIn(['scene', 'layers', layerID, 'lines']).toJS();
600
634
  var drawingLine = state.getIn(['scene', 'layers', layerID, 'lines', lineID]).toJS();
601
635
  var tlines = [];
602
- setdrawStart(false);
603
- // get the lines that have same points with drawing line.
604
- getRelatedLines(tlines, drawingLine, _vertices, lines);
605
- setRelatedLines(tlines);
606
- linesActions.updateDrawingLine(x, y, tlines, state.snapMask);
607
- } else {
608
- linesActions.updateDrawingLine(x, y, relatedLines, state.snapMask);
609
- }
610
- // Blocked 90 degree snap.
611
- // let prevVertexID = state.getIn(['scene', 'layers', layerID, 'selected', 'vertices']).toJS()[0];
612
- // let prevVertex = state.getIn(['scene', 'layers', layerID, 'vertices', prevVertexID]);
613
- // let dx = Math.abs(x - prevVertex.x);
614
- // let dy = Math.abs(y - prevVertex.y);
615
- // if (dx > dy) y = prevVertex.y
616
- // else x = prevVertex.x;
617
- break;
618
- case constants.MODE_DRAWING_HOLE:
619
- holesActions.updateDrawingHole(layerID, x, y);
620
- break;
621
- case constants.MODE_DRAWING_ITEM:
622
- var _layer = scene.layers.get(layerID);
623
- var flag = false;
624
- _layer.items.some(function (item) {
625
- if (item.selected) {
626
- item.counterTop.uri = _layer.counterTop.uri;
627
- current_sel_obj_id = item.id;
628
- flag = true;
636
+ if (drawStart || state.getIn(['scene', 'setLineAttributes'])) {
637
+ var _vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
638
+ setdrawStart(false);
639
+ // get the lines that have same points with drawing line.
640
+ getRelatedLines(tlines, drawingLine, _vertices, lines);
641
+ setRelatedLines(tlines);
642
+ linesActions.updateDrawingLine(x, y, tlines, state.snapMask);
643
+ } else {
644
+ linesActions.updateDrawingLine(x, y, relatedLines, state.snapMask);
629
645
  }
630
- });
631
- if (current_sel_obj_id === null || !flag) {
632
- itemsActions.updateDrawingItem(layerID, x, y);
633
- endPoint.x = x;
634
- endPoint.y = y;
635
- } else {
646
+
647
+ // Blocked 90 degree snap.
648
+ // let prevVertexID = state.getIn(['scene', 'layers', layerID, 'selected', 'vertices']).toJS()[0];
649
+ // let prevVertex = state.getIn(['scene', 'layers', layerID, 'vertices', prevVertexID]);
650
+ // let dx = Math.abs(x - prevVertex.x);
651
+ // let dy = Math.abs(y - prevVertex.y);
652
+ // if (dx > dy) y = prevVertex.y
653
+ // else x = prevVertex.x;
654
+ break;
655
+ case constants.MODE_DRAWING_HOLE:
656
+ holesActions.updateDrawingHole(layerID, x, y);
657
+ break;
658
+ case constants.MODE_DRAWING_ITEM:
659
+ var _layer = scene.layers.get(layerID);
660
+ var flag = false;
661
+ _layer.items.some(function (item) {
662
+ if (item.selected) {
663
+ item.counterTop.uri = _layer.counterTop.uri;
664
+ current_sel_obj_id = item.id;
665
+ flag = true;
666
+ }
667
+ });
668
+ if (current_sel_obj_id === null || !flag) {
669
+ itemsActions.updateDrawingItem(layerID, x, y);
670
+ endPoint.x = x;
671
+ endPoint.y = y;
672
+ } else {
673
+ prepareSnap();
674
+ var _GeometryUtils$calcSn = _export2.GeometryUtils.calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea),
675
+ nx = _GeometryUtils$calcSn.nx,
676
+ ny = _GeometryUtils$calcSn.ny,
677
+ rot = _GeometryUtils$calcSn.rot,
678
+ rotRad = _GeometryUtils$calcSn.rotRad;
679
+ var _val = {
680
+ pos: {
681
+ x: x,
682
+ y: y
683
+ },
684
+ rotRad: rotRad,
685
+ size: allItemRect.cur && allItemRect.cur.size,
686
+ layoutpos: allItemRect.cur && allItemRect.cur.layoutpos,
687
+ is_corner: allItemRect.cur && allItemRect.cur.is_corner
688
+ };
689
+ var _GeometryUtils$getAll = _export2.GeometryUtils.getAllHoleRect(scene, _val),
690
+ _isSect = _GeometryUtils$getAll.isSect,
691
+ _snap = _GeometryUtils$getAll.snap;
692
+ if (!(0, _helper.isEmpty)(_snap) && _isSect) {
693
+ if (_snap.length == 1) _val.pos = {
694
+ x: _snap[0].x,
695
+ y: _snap[0].y
696
+ };else {
697
+ 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 = {
698
+ x: _snap[0].x,
699
+ y: _snap[0].y
700
+ };else _val.pos = {
701
+ x: _snap[1].x,
702
+ y: _snap[1].y
703
+ };
704
+ }
705
+ var interSect = _export2.GeometryUtils.validInterSect(allItemRect.others, _val);
706
+ if (interSect) {
707
+ nx = _val.pos.x;
708
+ ny = _val.pos.y;
709
+ }
710
+ }
711
+ _val.pos = {
712
+ x: nx,
713
+ y: ny
714
+ };
715
+ var _isrectSect = _export2.GeometryUtils.validInterSect(allItemRect.others, _val);
716
+ if (_isrectSect && _isSect) {
717
+ itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
718
+ itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
719
+ endPoint.x = nx;
720
+ endPoint.y = ny;
721
+ }
722
+ if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('cabinet')) {
723
+ itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
724
+ itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
725
+ endPoint.x = nx;
726
+ endPoint.y = ny;
727
+ }
728
+ 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')) {
729
+ itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
730
+ itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
731
+ endPoint.x = nx;
732
+ endPoint.y = ny;
733
+ }
734
+ }
735
+ break;
736
+ case constants.MODE_DRAGGING_HOLE:
737
+ holesActions.updateDraggingHole(x, y);
738
+ break;
739
+ case constants.MODE_DRAGGING_LINE:
740
+ linesActions.updateDraggingLine(x, y, relatedLines, state.snapMask);
741
+ break;
742
+ case constants.MODE_DRAGGING_VERTEX:
743
+ var vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
744
+ getConnectedLines();
745
+ var result = getEndPoint(vertices, x, y, 'DRAGGING_VERTEX');
746
+ verticesActions.updateDraggingVertex(result.x, result.y, state.snapMask);
747
+ break;
748
+ case constants.MODE_DRAGGING_ITEM:
636
749
  prepareSnap();
637
- var _GeometryUtils$calcSn = _export2.GeometryUtils.calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea),
638
- nx = _GeometryUtils$calcSn.nx,
639
- ny = _GeometryUtils$calcSn.ny,
640
- rot = _GeometryUtils$calcSn.rot,
641
- rotRad = _GeometryUtils$calcSn.rotRad;
642
- var _val = {
750
+ var _GeometryUtils$calcSn2 = _export2.GeometryUtils.calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea),
751
+ nx = _GeometryUtils$calcSn2.nx,
752
+ ny = _GeometryUtils$calcSn2.ny,
753
+ rot = _GeometryUtils$calcSn2.rot,
754
+ rotRad = _GeometryUtils$calcSn2.rotRad;
755
+ var val = {
643
756
  pos: {
644
757
  x: x,
645
758
  y: y
@@ -649,125 +762,58 @@ function Viewer2D(_ref, _ref2) {
649
762
  layoutpos: allItemRect.cur && allItemRect.cur.layoutpos,
650
763
  is_corner: allItemRect.cur && allItemRect.cur.is_corner
651
764
  };
652
- var _GeometryUtils$getAll = _export2.GeometryUtils.getAllHoleRect(scene, _val),
653
- _isSect = _GeometryUtils$getAll.isSect,
654
- _snap = _GeometryUtils$getAll.snap;
655
- if (!(0, _helper.isEmpty)(_snap) && _isSect) {
656
- if (_snap.length == 1) _val.pos = {
657
- x: _snap[0].x,
658
- y: _snap[0].y
659
- };else {
660
- 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 = {
661
- x: _snap[0].x,
662
- y: _snap[0].y
663
- };else _val.pos = {
664
- x: _snap[1].x,
665
- y: _snap[1].y
765
+ var _GeometryUtils$getAll2 = _export2.GeometryUtils.getAllHoleRect(scene, val),
766
+ isSect = _GeometryUtils$getAll2.isSect,
767
+ snap = _GeometryUtils$getAll2.snap;
768
+ if (!(0, _helper.isEmpty)(snap) && isSect) {
769
+ if (snap.length == 1) val.pos = {
770
+ x: snap[0].x,
771
+ y: snap[0].y
772
+ };else if (snap.length == 2) {
773
+ 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 = {
774
+ x: snap[0].x,
775
+ y: snap[0].y
776
+ };else val.pos = {
777
+ x: snap[1].x,
778
+ y: snap[1].y
666
779
  };
667
780
  }
668
- var interSect = _export2.GeometryUtils.validInterSect(allItemRect.others, _val);
669
- if (interSect) {
670
- nx = _val.pos.x;
671
- ny = _val.pos.y;
781
+ var _interSect = _export2.GeometryUtils.validInterSect(allItemRect.others, val);
782
+ if (_interSect) {
783
+ nx = val.pos.x;
784
+ ny = val.pos.y;
672
785
  }
673
786
  }
674
- _val.pos = {
787
+ val.pos = {
675
788
  x: nx,
676
789
  y: ny
677
790
  };
678
- var _isrectSect = _export2.GeometryUtils.validInterSect(allItemRect.others, _val);
679
- if (_isrectSect && _isSect) {
791
+ var isrectSect = _export2.GeometryUtils.validInterSect(allItemRect.others, val);
792
+ if (isrectSect && isSect) {
680
793
  itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
681
794
  itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
682
- endPoint.x = nx;
683
- endPoint.y = ny;
684
795
  }
685
- if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('cabinet')) {
796
+ if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cabinet')) {
686
797
  itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
687
798
  itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
688
- endPoint.x = nx;
689
- endPoint.y = ny;
690
799
  }
691
800
  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')) {
692
801
  itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
693
802
  itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
694
- endPoint.x = nx;
695
- endPoint.y = ny;
696
- }
697
- }
698
- break;
699
- case constants.MODE_DRAGGING_HOLE:
700
- holesActions.updateDraggingHole(x, y);
701
- break;
702
- case constants.MODE_DRAGGING_LINE:
703
- linesActions.updateDraggingLine(x, y, relatedLines, state.snapMask);
704
- break;
705
- case constants.MODE_DRAGGING_VERTEX:
706
- var vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
707
- getConnectedLines();
708
- var result = getEndPoint(vertices, x, y, 'DRAGGING_VERTEX');
709
- verticesActions.updateDraggingVertex(result.x, result.y, state.snapMask);
710
- break;
711
- case constants.MODE_DRAGGING_ITEM:
712
- prepareSnap();
713
- var _GeometryUtils$calcSn2 = _export2.GeometryUtils.calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea),
714
- nx = _GeometryUtils$calcSn2.nx,
715
- ny = _GeometryUtils$calcSn2.ny,
716
- rot = _GeometryUtils$calcSn2.rot,
717
- rotRad = _GeometryUtils$calcSn2.rotRad;
718
- var val = {
719
- pos: {
720
- x: x,
721
- y: y
722
- },
723
- rotRad: rotRad,
724
- size: allItemRect.cur && allItemRect.cur.size,
725
- layoutpos: allItemRect.cur && allItemRect.cur.layoutpos,
726
- is_corner: allItemRect.cur && allItemRect.cur.is_corner
727
- };
728
- var _GeometryUtils$getAll2 = _export2.GeometryUtils.getAllHoleRect(scene, val),
729
- isSect = _GeometryUtils$getAll2.isSect,
730
- snap = _GeometryUtils$getAll2.snap;
731
- if (!(0, _helper.isEmpty)(snap) && isSect) {
732
- if (snap.length == 1) val.pos = {
733
- x: snap[0].x,
734
- y: snap[0].y
735
- };else if (snap.length == 2) {
736
- 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 = {
737
- x: snap[0].x,
738
- y: snap[0].y
739
- };else val.pos = {
740
- x: snap[1].x,
741
- y: snap[1].y
742
- };
743
- }
744
- var _interSect = _export2.GeometryUtils.validInterSect(allItemRect.others, val);
745
- if (_interSect) {
746
- nx = val.pos.x;
747
- ny = val.pos.y;
748
803
  }
749
- }
750
- val.pos = {
751
- x: nx,
752
- y: ny
753
- };
754
- var isrectSect = _export2.GeometryUtils.validInterSect(allItemRect.others, val);
755
- if (isrectSect && isSect) {
756
- itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
757
- itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
758
- }
759
- if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cabinet')) {
760
- itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
761
- itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
762
- }
763
- 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')) {
764
- itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
765
- itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
766
- }
767
- break;
768
- case constants.MODE_ROTATING_ITEM:
769
- itemsActions.updateRotatingItem(x, y);
770
- break;
804
+ break;
805
+ case constants.MODE_ROTATING_ITEM:
806
+ itemsActions.updateRotatingItem(x, y);
807
+ break;
808
+ }
809
+ }
810
+ if (!(0, _helper.isEmpty)(elementPrototype)) {
811
+ var elementID = state.getIn(['scene', 'layers', layerID, 'selected', elementPrototype]).first();
812
+ var currentObject = state.getIn(['scene', 'layers', layerID, elementPrototype, elementID]);
813
+ onInternalEvent === null || onInternalEvent === void 0 || onInternalEvent({
814
+ type: internalType,
815
+ value: currentObject === null || currentObject === void 0 ? void 0 : currentObject.toJS()
816
+ });
771
817
  }
772
818
  viewerEvent.originalEvent.stopPropagation();
773
819
  };
@@ -789,6 +835,10 @@ function Viewer2D(_ref, _ref2) {
789
835
  return;
790
836
  }
791
837
  }
838
+ if (mode === constants.MODE_DRAWING_ITEM) {
839
+ endPoint.x = x;
840
+ endPoint.y = y;
841
+ }
792
842
  if (mode === constants.MODE_IDLE) {
793
843
  var elementData = extractElementData(event.target);
794
844
  if (!elementData) return;
@@ -828,9 +878,22 @@ function Viewer2D(_ref, _ref2) {
828
878
  break;
829
879
  }
830
880
  var currentObject = state.getIn(['scene', 'layers', layerID, elementData.prototype, elementData.id]);
881
+ if (elementData.prototype === 'lines' && currentObject) {
882
+ // caculating length of selected line//
883
+ var v_a = layer.vertices.get(currentObject.vertices.get(0));
884
+ var v_b = layer.vertices.get(currentObject.vertices.get(1));
885
+ var distance = _export2.GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
886
+ var _length = (0, _convertUnitsLite.convert)(distance).from('cm').to('in');
887
+ elementData.length = _length;
888
+ //////////////////////////////////////
889
+ }
890
+ // Adding length field to internal event payload when selected lines
891
+ var payloadValue = (elementData === null || elementData === void 0 ? void 0 : elementData.prototype) === 'lines' ? _objectSpread(_objectSpread({}, currentObject === null || currentObject === void 0 ? void 0 : currentObject.toJS()), {}, {
892
+ length: elementData === null || elementData === void 0 ? void 0 : elementData.length
893
+ }) : currentObject === null || currentObject === void 0 ? void 0 : currentObject.toJS();
831
894
  onInternalEvent === null || onInternalEvent === void 0 || onInternalEvent({
832
895
  type: _constants.INTERNAL_EVENT_SELECT_ELEMENT,
833
- value: currentObject === null || currentObject === void 0 ? void 0 : currentObject.toJS()
896
+ value: payloadValue
834
897
  });
835
898
  } else {
836
899
  sPoint.x = x;
@@ -954,6 +1017,10 @@ function Viewer2D(_ref, _ref2) {
954
1017
  if (document.getElementById('setting_dialog')) {
955
1018
  document.getElementById('setting_dialog').style.display = 'none';
956
1019
  }
1020
+ onInternalEvent === null || onInternalEvent === void 0 || onInternalEvent({
1021
+ type: constants.INTERNAL_EVENT_REPLACE_CABINET,
1022
+ value: state.getIn(['scene', 'layers', layerID, 'items', elementData.id]).toJS()
1023
+ });
957
1024
  itemsActions.selectItem(elementData.layer, elementData.id);
958
1025
  replaceCabinet(true);
959
1026
  break;