kitchen-simulator 3.1.15 → 4.0.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/es/LiteKitchenConfigurator.js +204 -21
  2. package/es/LiteRenderer.js +277 -12
  3. package/es/actions/items-actions.js +6 -10
  4. package/es/actions/lines-actions.js +1 -3
  5. package/es/actions/project-actions.js +5 -15
  6. package/es/assets/Window.hdr +2100 -0
  7. package/es/assets/gltf/door_sliding.bin +0 -0
  8. package/es/assets/img/1.jpg +0 -0
  9. package/es/catalog/areas/area/planner-element.js +5 -10
  10. package/es/catalog/catalog.js +4 -1
  11. package/es/catalog/factories/area-factory-3d.js +17 -18
  12. package/es/catalog/factories/wall-factory-3d.js +2 -2
  13. package/es/catalog/factories/wall-factory.js +8 -8
  14. package/es/catalog/lines/wall/planner-element.js +9 -18
  15. package/es/catalog/utils/exporter.js +3 -6
  16. package/es/catalog/utils/item-loader.js +197 -202
  17. package/es/catalog/utils/mtl-loader.js +2 -2
  18. package/es/catalog/utils/obj-loader.js +2 -2
  19. package/es/class/item.js +127 -107
  20. package/es/class/line.js +2 -14
  21. package/es/class/project.js +44 -150
  22. package/es/components/content.js +6 -19
  23. package/es/components/viewer2d/grids/grid-streak.js +1 -1
  24. package/es/components/viewer2d/item.js +51 -84
  25. package/es/components/viewer2d/line.js +243 -315
  26. package/es/components/viewer2d/ruler.js +36 -16
  27. package/es/components/viewer2d/rulerDist.js +75 -44
  28. package/es/components/viewer2d/utils.js +0 -6
  29. package/es/components/viewer2d/viewer2d.js +205 -301
  30. package/es/components/viewer3d/front3D.js +2 -3
  31. package/es/components/viewer3d/libs/mtl-loader.js +2 -2
  32. package/es/components/viewer3d/libs/obj-loader.js +2 -2
  33. package/es/components/viewer3d/libs/orbit-controls.js +4 -3
  34. package/es/components/viewer3d/libs/pointer-lock-controls.js +7 -6
  35. package/es/components/viewer3d/viewer3d.js +80 -127
  36. package/es/constants.js +3 -110
  37. package/es/devLiteRenderer.js +38 -597
  38. package/es/index.js +86 -16
  39. package/es/models.js +5 -8
  40. package/es/plugins/SVGLoader.js +5 -7
  41. package/es/plugins/keyboard.js +6 -15
  42. package/es/reducers/items-reducer.js +5 -5
  43. package/es/reducers/lines-reducer.js +1 -1
  44. package/es/reducers/project-reducer.js +3 -5
  45. package/es/shared-style.js +4 -4
  46. package/es/utils/geometry.js +0 -161
  47. package/es/utils/get-edges-of-subgraphs.js +1 -1
  48. package/es/utils/graph-cycles.js +1 -1
  49. package/es/utils/graph.js +1 -1
  50. package/es/utils/helper.js +2 -67
  51. package/es/utils/isolate-event-handler.js +124 -1367
  52. package/es/utils/molding.js +2 -238
  53. package/lib/LiteKitchenConfigurator.js +205 -22
  54. package/lib/LiteRenderer.js +278 -13
  55. package/lib/actions/items-actions.js +6 -10
  56. package/lib/actions/lines-actions.js +1 -3
  57. package/lib/actions/project-actions.js +4 -15
  58. package/lib/assets/Window.hdr +2100 -0
  59. package/lib/assets/gltf/door_sliding.bin +0 -0
  60. package/lib/assets/img/1.jpg +0 -0
  61. package/lib/catalog/areas/area/planner-element.js +5 -11
  62. package/lib/catalog/catalog.js +4 -1
  63. package/lib/catalog/factories/area-factory-3d.js +14 -15
  64. package/lib/catalog/factories/wall-factory-3d.js +2 -2
  65. package/lib/catalog/factories/wall-factory.js +8 -8
  66. package/lib/catalog/lines/wall/planner-element.js +9 -19
  67. package/lib/catalog/utils/exporter.js +3 -6
  68. package/lib/catalog/utils/item-loader.js +194 -199
  69. package/lib/catalog/utils/mtl-loader.js +2 -9
  70. package/lib/catalog/utils/obj-loader.js +2 -10
  71. package/lib/class/item.js +125 -105
  72. package/lib/class/line.js +1 -13
  73. package/lib/class/project.js +43 -149
  74. package/lib/components/content.js +6 -19
  75. package/lib/components/viewer2d/grids/grid-streak.js +1 -1
  76. package/lib/components/viewer2d/item.js +50 -83
  77. package/lib/components/viewer2d/line.js +242 -315
  78. package/lib/components/viewer2d/ruler.js +35 -15
  79. package/lib/components/viewer2d/rulerDist.js +75 -44
  80. package/lib/components/viewer2d/utils.js +0 -7
  81. package/lib/components/viewer2d/viewer2d.js +205 -299
  82. package/lib/components/viewer3d/front3D.js +2 -3
  83. package/lib/components/viewer3d/libs/mtl-loader.js +2 -9
  84. package/lib/components/viewer3d/libs/obj-loader.js +2 -9
  85. package/lib/components/viewer3d/libs/orbit-controls.js +5 -11
  86. package/lib/components/viewer3d/libs/pointer-lock-controls.js +7 -13
  87. package/lib/components/viewer3d/viewer3d.js +79 -125
  88. package/lib/constants.js +7 -115
  89. package/lib/devLiteRenderer.js +33 -592
  90. package/lib/index.js +86 -16
  91. package/lib/models.js +5 -8
  92. package/lib/plugins/SVGLoader.js +5 -7
  93. package/lib/plugins/keyboard.js +6 -15
  94. package/lib/reducers/items-reducer.js +5 -5
  95. package/lib/reducers/lines-reducer.js +1 -1
  96. package/lib/reducers/project-reducer.js +2 -4
  97. package/lib/shared-style.js +4 -4
  98. package/lib/utils/geometry.js +0 -162
  99. package/lib/utils/get-edges-of-subgraphs.js +1 -6
  100. package/lib/utils/graph-cycles.js +8 -7
  101. package/lib/utils/graph.js +1 -6
  102. package/lib/utils/helper.js +3 -70
  103. package/lib/utils/isolate-event-handler.js +121 -1364
  104. package/lib/utils/molding.js +0 -238
  105. package/package.json +1 -1
@@ -1,429 +1,15 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import _typeof from "@babel/runtime/helpers/esm/typeof";
3
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
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_ADD_ROOM_SHAPE, EXTERNAL_EVENT_ZOOM_IN, EXTERNAL_EVENT_ZOOM_OUT, 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, EXTERNAL_EVENT_REPLACE_CABINET, FINISHING_TYPE, EXTERNAL_EVENT_SET_FINISHING, EXTERNAL_EVENT_ROTATE_PAN } from "../constants";
9
- import { isEmpty, updateViwer2D, centering2D } from "./helper";
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, 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
+ import { isEmpty } from "./helper";
10
9
  import exporter from "../catalog/utils/exporter";
11
- import { render2DItem, render3DItem, render3DApplianceItem, render3DLightingItem } from "../catalog/utils/item-loader";
12
- import { convert } from "./convert-units-lite";
13
- import { GeometryUtils, MathUtils } from "./export";
14
- import { returnReplaceableDeepSearchType } from "../components/viewer2d/utils";
15
- import { SVGLoader } from 'three/addons/loaders/SVGLoader';
16
- import { getMoldingDataOfScene } from "./molding";
17
- var PRECISION = 2;
18
- function loadJSON(_x) {
19
- return _loadJSON.apply(this, arguments);
20
- }
21
- /********Parse TempPlaceholder from cabinetPayloadData **************/
22
- function _loadJSON() {
23
- _loadJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(path) {
24
- return _regeneratorRuntime.wrap(function (_context2) {
25
- while (1) switch (_context2.prev = _context2.next) {
26
- case 0:
27
- return _context2.abrupt("return", new Promise(function (resolve, reject) {
28
- var xhr = new XMLHttpRequest();
29
- xhr.onreadystatechange = function () {
30
- if (xhr.readyState === XMLHttpRequest.DONE) {
31
- if (xhr.status === 200) {
32
- resolve(JSON.parse(xhr.responseText));
33
- } else {
34
- reject(xhr);
35
- }
36
- }
37
- };
38
- xhr.open('GET', path, true);
39
- xhr.send();
40
- }));
41
- case 1:
42
- case "end":
43
- return _context2.stop();
44
- }
45
- }, _callee2);
46
- }));
47
- return _loadJSON.apply(this, arguments);
48
- }
49
- function parseTempPlaceholdersFromCabinetPayload(_x2) {
50
- return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
51
- }
52
- /***** Update cabinetPayloadData with updatedTempPlaceholders *****/
53
- function _parseTempPlaceholdersFromCabinetPayload() {
54
- _parseTempPlaceholdersFromCabinetPayload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(cabinetPayload) {
55
- var link, keys, temp, i, _cabinetPayload$struc, _cabinetPayload$struc2, el, tempPlaceholdersData, tempData, doorKey, drawerKey, fixedKey, doorPHs, drawerPHs, has_single_door, fixedPHs, _t2, _t3, _t4;
56
- return _regeneratorRuntime.wrap(function (_context3) {
57
- while (1) switch (_context3.prev = _context3.next) {
58
- case 0:
59
- link = '';
60
- keys = Object.keys(cabinetPayload.structure_json);
61
- temp = [];
62
- i = 0;
63
- case 1:
64
- if (!(i < keys.length)) {
65
- _context3.next = 4;
66
- break;
67
- }
68
- if (!((_cabinetPayload$struc = cabinetPayload.structure_json[keys[i]]) !== null && _cabinetPayload$struc !== void 0 && (_cabinetPayload$struc = _cabinetPayload$struc.toString()) !== null && _cabinetPayload$struc !== void 0 && _cabinetPayload$struc.includes('.gltf') && (_cabinetPayload$struc2 = cabinetPayload.structure_json[keys[i]]) !== null && _cabinetPayload$struc2 !== void 0 && (_cabinetPayload$struc2 = _cabinetPayload$struc2.toString()) !== null && _cabinetPayload$struc2 !== void 0 && _cabinetPayload$struc2.startsWith('http'))) {
69
- _context3.next = 3;
70
- break;
71
- }
72
- link = cabinetPayload.structure_json[keys[i]];
73
- _t2 = temp;
74
- _t3 = keys[i];
75
- _context3.next = 2;
76
- return loadJSON(link);
77
- case 2:
78
- _t4 = _context3.sent;
79
- _t2.push.call(_t2, {
80
- name: _t3,
81
- data: _t4
82
- });
83
- case 3:
84
- i++;
85
- _context3.next = 1;
86
- break;
87
- case 4:
88
- el = cabinetPayload.structure_json.tempPlaceholders[0].id;
89
- tempPlaceholdersData = [];
90
- tempData = {};
91
- doorKey = 0;
92
- drawerKey = 0;
93
- fixedKey = 0;
94
- doorPHs = 0;
95
- drawerPHs = 0;
96
- has_single_door = false;
97
- fixedPHs = 0;
98
- temp.forEach(function (t, index) {
99
- var nodes = t.data.nodes;
100
- if (nodes === undefined) {
101
- nodes = [];
102
- }
103
- var tempPlaceholders = nodes.filter(function (element) {
104
- return element.name.startsWith('ph_');
105
- });
106
- tempPlaceholders.sort(function (a, b) {
107
- return a.name > b.name ? 1 : -1;
108
- });
109
- if (tempPlaceholders.length > 0) {
110
- if (t.name === 'base') {
111
- tempPlaceholders.map(function (element) {
112
- var sink_match = element.name.match(/\d_(sink_[^LR12]*)(_[LR12])?$/);
113
- if (sink_match && sink_match.length >= 2) {
114
- var _process$env$API_URL, _cabinetPayload$struc3;
115
- tempData['sink'] = tempData['sink'] || [];
116
- tempData['sink'].push(element.name);
117
- var sink_url = (_process$env$API_URL = process.env.API_URL) !== null && _process$env$API_URL !== void 0 ? _process$env$API_URL :
118
- // server url from 3DTool env
119
- import.meta.env.VITE_APP_API_URL + // server url from Host env
120
- "/uploads/assets/default/".concat(sink_match[1], ".gltf");
121
- if (cabinetPayload !== null && cabinetPayload !== void 0 && (_cabinetPayload$struc3 = cabinetPayload.structure_json) !== null && _cabinetPayload$struc3 !== void 0 && (_cabinetPayload$struc3 = _cabinetPayload$struc3.tempPlaceholders[0]) !== null && _cabinetPayload$struc3 !== void 0 && _cabinetPayload$struc3.structure) cabinetPayload.structure_json.tempPlaceholders[0].structure.sink = sink_url;
122
- } else if (temp.some(function (felement) {
123
- return felement.name.includes('base_drawer');
124
- }) && element.name.includes('interior_drawer')) {
125
- var objCnt = temp.filter(function (felement) {
126
- return felement.name.includes('base_drawer') && !felement.name.includes('_door');
127
- }).length;
128
- var phCnt = tempPlaceholders.filter(function (felement) {
129
- return felement.name.includes('interior');
130
- }).length;
131
- drawerPHs = phCnt;
132
- if (objCnt === 1 || phCnt % objCnt !== 0) {
133
- if (tempData['base_drawer_1'] === undefined) {
134
- tempData['base_drawer_1'] = [];
135
- }
136
- tempData['base_drawer_1'].push(element.name);
137
- drawerKey++;
138
- } else if (objCnt > 1 && phCnt % objCnt === 0) {
139
- if (tempData['base_drawer_' + (drawerKey % objCnt + 1)] === undefined) {
140
- tempData['base_drawer_' + (drawerKey % objCnt + 1)] = [];
141
- }
142
- tempData['base_drawer_' + (drawerKey % objCnt + 1)].push(element.name);
143
- drawerKey++;
144
- }
145
- } else if (temp.some(function (felement) {
146
- return felement.name.includes('base_door');
147
- }) && !element.name.includes('interior_drawer') && !element.name.includes('drawer') && element.name.includes('door')) {
148
- var _objCnt = temp.filter(function (felement) {
149
- return felement.name.includes('base_door');
150
- }).length;
151
- var _phCnt = tempPlaceholders.filter(function (felement) {
152
- return !felement.name.includes('interior') && !felement.name.includes('drawer') && felement.name.includes('door');
153
- }).length;
154
- doorPHs = _phCnt;
155
- if (_objCnt === 1 || _phCnt % _objCnt !== 0) {
156
- if (tempData['base_door_1'] === undefined) {
157
- tempData['base_door_1'] = [];
158
- }
159
- tempData['base_door_1'].push(element.name);
160
- doorKey++;
161
- } else if (_objCnt > 1) {
162
- if (tempData['base_door_' + (doorKey % _objCnt + 1)] === undefined) {
163
- tempData['base_door_' + (doorKey % _objCnt + 1)] = [];
164
- }
165
- tempData['base_door_' + (doorKey % _objCnt + 1)].push(element.name);
166
- doorKey++;
167
- }
168
- } else if (temp.some(function (felement) {
169
- return felement.name.includes('base_fixed_drawer_door');
170
- }) && element.name.includes('_drawer_door_fixed')) {
171
- var _objCnt2 = temp.filter(function (felement) {
172
- return felement.name.includes('base_fixed_drawer_door');
173
- }).length;
174
- var _phCnt2 = tempPlaceholders.filter(function (felement) {
175
- return felement.name.includes('_drawer_door_fixed');
176
- }).length;
177
- fixedPHs = _phCnt2;
178
- if (_objCnt2 === 1 || _phCnt2 % _objCnt2 !== 0) {
179
- if (tempData['base_fixed_drawer_door_1'] === undefined) {
180
- tempData['base_fixed_drawer_door_1'] = [];
181
- }
182
- tempData['base_fixed_drawer_door_1'].push(element.name);
183
- fixedKey++;
184
- } else if (_objCnt2 > 1) {
185
- if (tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] === undefined) {
186
- tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] = [];
187
- }
188
- tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)].push(element.name);
189
- fixedKey++;
190
- }
191
- }
192
- });
193
- } else if (t.name.includes('base_drawer') && !t.name.includes('_door')) {
194
- var objCnt = temp.filter(function (felement) {
195
- return felement.name.includes('base_drawer') && !felement.name.includes('_door');
196
- }).length;
197
- if (objCnt === 1 || drawerPHs % objCnt !== 0) {
198
- if (tempData['base_drawer_door_1'] === undefined) tempData['base_drawer_door_1'] = [];
199
- //get drawer door handle placeholders
200
- var ph_temp = temp.find(function (felement) {
201
- return felement.name === 'base_drawer_door_1';
202
- });
203
- if (ph_temp != undefined) {
204
- var ph_drawer_door_handle = ph_temp.data.nodes;
205
- ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
206
- return element.name.startsWith('ph_') && element.name.includes('handle');
207
- });
208
- for (var w = 0; w < drawerPHs; w++) {
209
- if (!tempData['base_drawer_door_1'].some(function (el) {
210
- return el === 'base_drawer_door_1/' + tempPlaceholders[0].name;
211
- })) {
212
- tempData['base_drawer_door_1'].push('base_drawer_1/' + tempPlaceholders[0].name);
213
- //add drawer door handle placeholders
214
- if (tempData['drawer_door_handle_1'] === undefined) tempData['drawer_door_handle_1'] = [];
215
- if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle_1'].push('base_drawer_door_1/' + ph_drawer_door_handle[0].name);
216
- }
217
- }
218
- }
219
- } else if (objCnt > 1 && drawerPHs > 0 && drawerPHs % objCnt === 0) {
220
- if (tempData['base_drawer_door' + t.name.slice(-2)] === undefined) tempData['base_drawer_door' + t.name.slice(-2)] = [];
221
- //get drawer door handle placeholders
222
- var ph_temp = temp.find(function (felement) {
223
- return felement.name === 'base_drawer_door' + t.name.slice(-2);
224
- });
225
- if (ph_temp != undefined) {
226
- var ph_drawer_door_handle = ph_temp.data.nodes;
227
- ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
228
- return element.name.startsWith('ph_') && element.name.includes('handle');
229
- });
230
- tempPlaceholders.forEach(function (element) {
231
- if (!tempData['base_drawer_door' + t.name.slice(-2)].some(function (el) {
232
- return el === t.name + '/' + element.name;
233
- })) {
234
- tempData['base_drawer_door' + t.name.slice(-2)].push(t.name + '/' + element.name);
235
- //add drawer door handle placeholders
236
- if (tempData['drawer_door_handle' + t.name.slice(-2)] === undefined) tempData['drawer_door_handle' + t.name.slice(-2)] = [];
237
- if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle' + t.name.slice(-2)].push('base_drawer_door' + t.name.slice(-2) + '/' + ph_drawer_door_handle[0].name);
238
- }
239
- });
240
- }
241
- }
242
- } else if (t.name.includes('base_door')) {
243
- var _objCnt3 = temp.filter(function (felement) {
244
- return felement.name.includes('base_door');
245
- }).length;
246
- tempPlaceholders = tempPlaceholders.filter(function (el) {
247
- return el.name.includes('handle');
248
- });
249
- if (tempPlaceholders.length > 0) if (_objCnt3 === 1 || doorPHs % _objCnt3 !== 0) {
250
- if (tempData['door_handle_1'] === undefined) {
251
- tempData['door_handle_1'] = [];
252
- }
253
- var _loop = function _loop() {
254
- var phname = tempPlaceholders[0].name;
255
- var newph = undefined;
256
- if (tempData['base_door_1'][_w].isLeftPlaceholder()) {
257
- newph = tempPlaceholders.find(function (el) {
258
- return el.name.isRightPlaceholder();
259
- });
260
- }
261
- if (tempData['base_door_1'][_w].isRightPlaceholder()) {
262
- newph = tempPlaceholders.find(function (el) {
263
- return el.name.isLeftPlaceholder();
264
- });
265
- }
266
- if (newph != undefined) {
267
- phname = newph.name;
268
- }
269
- if (doorPHs === 1 && tempPlaceholders.find(function (el) {
270
- return el.name.isLeftPlaceholder();
271
- }) != undefined && tempPlaceholders.find(function (el) {
272
- return el.name.isRightPlaceholder();
273
- }) != undefined) {
274
- has_single_door = true;
275
- }
276
- if (!tempData['door_handle_1'].some(function (el) {
277
- return el === 'door_handle_1/' + phname;
278
- })) {
279
- tempData['door_handle_1'].push('base_door_1/' + phname);
280
- }
281
- };
282
- for (var _w = 0; _w < doorPHs; _w++) {
283
- _loop();
284
- }
285
- } else if (_objCnt3 > 1 && doorPHs > 0 && doorPHs % _objCnt3 === 0) {
286
- if (tempData['door_handle' + t.name.slice(-2)] === undefined) tempData['door_handle' + t.name.slice(-2)] = [];
287
- var phname = tempPlaceholders[0].name;
288
- var newph = undefined;
289
- var blAdd = true;
290
- if (cabinetPayload.is_corner) {
291
- if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
292
- newph = tempPlaceholders.find(function (el) {
293
- return el.name.isLeftPlaceholder();
294
- });
295
- } else {
296
- blAdd = false;
297
- }
298
- } else {
299
- if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
300
- newph = tempPlaceholders.find(function (el) {
301
- return el.name.isRightPlaceholder();
302
- });
303
- }
304
- if (tempData['base_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
305
- newph = tempPlaceholders.find(function (el) {
306
- return el.name.isLeftPlaceholder();
307
- });
308
- }
309
- }
310
- if (blAdd) {
311
- if (newph != undefined) {
312
- phname = newph.name;
313
- }
314
- if (!tempData['door_handle' + t.name.slice(-2)].some(function (el) {
315
- return el === t.name + '/' + phname;
316
- })) {
317
- tempData['door_handle' + t.name.slice(-2)].push(t.name + '/' + phname);
318
- }
319
- }
320
- }
321
- } else if (t.name.includes('base_fixed_drawer_door')) {
322
- var _objCnt4 = temp.filter(function (felement) {
323
- return felement.name.includes('base_fixed_drawer_door');
324
- }).length;
325
- tempPlaceholders = tempPlaceholders.filter(function (el) {
326
- return el.name.includes('handle');
327
- });
328
- if (tempPlaceholders.length > 0) if (_objCnt4 === 1 || fixedPHs % _objCnt4 !== 0) {
329
- if (tempData['fixed_drawer_door_handle_1'] === undefined) tempData['fixed_drawer_door_handle_1'] = [];
330
- var _loop2 = function _loop2() {
331
- var phname = tempPlaceholders[0].name;
332
- var newph = undefined;
333
- if (tempData['base_fixed_drawer_door_1'][_w2].isLeftPlaceholder()) {
334
- newph = tempPlaceholders.find(function (el) {
335
- return el.name.isRightPlaceholder();
336
- });
337
- }
338
- if (tempData['base_fixed_drawer_door_1'][_w2].isRightPlaceholder()) {
339
- newph = tempPlaceholders.find(function (el) {
340
- return el.name.isLeftPlaceholder();
341
- });
342
- }
343
- if (newph != undefined) {
344
- phname = newph.name;
345
- }
346
- if (!tempData['fixed_drawer_door_handle_1'].some(function (el) {
347
- return el === 'fixed_drawer_door_handle_1/' + phname;
348
- })) {
349
- tempData['fixed_drawer_door_handle_1'].push('base_fixed_drawer_door_1/' + phname);
350
- }
351
- };
352
- for (var _w2 = 0; _w2 < fixedPHs; _w2++) {
353
- _loop2();
354
- }
355
- } else if (_objCnt4 > 1 && fixedPHs > 0 && fixedPHs % _objCnt4 === 0) {
356
- if (tempData['fixed_drawer_door_handle' + t.name.slice(-2)] === undefined) {
357
- tempData['fixed_drawer_door_handle' + t.name.slice(-2)] = [];
358
- }
359
- var _phname = tempPlaceholders[0].name;
360
- var _newph = undefined;
361
- if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
362
- _newph = tempPlaceholders.find(function (el) {
363
- return el.name.isRightPlaceholder();
364
- });
365
- }
366
- if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
367
- _newph = tempPlaceholders.find(function (el) {
368
- return el.name.isLeftPlaceholder();
369
- });
370
- }
371
- if (_newph != undefined) {
372
- _phname = _newph.name;
373
- }
374
- if (!tempData['fixed_drawer_door_handle' + t.name.slice(-2)].some(function (el) {
375
- return el === t.name + '/' + _phname;
376
- })) {
377
- tempData['fixed_drawer_door_handle' + t.name.slice(-2)].push(t.name + '/' + _phname);
378
- }
379
- }
380
- }
381
- }
382
- });
383
- tempPlaceholdersData.push({
384
- id: parseInt(el, 10),
385
- placeholders: tempData,
386
- structure: cabinetPayload.structure_json.tempPlaceholders[0].structure
387
- });
388
- return _context3.abrupt("return", tempPlaceholdersData);
389
- case 5:
390
- case "end":
391
- return _context3.stop();
392
- }
393
- }, _callee3);
394
- }));
395
- return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
396
- }
397
- function updateCabinetPayload(_x3) {
398
- return _updateCabinetPayload.apply(this, arguments);
399
- }
400
- function _updateCabinetPayload() {
401
- _updateCabinetPayload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(cabinetPayload) {
402
- var tempPlaceholders, cabinetPayloadKeys, i;
403
- return _regeneratorRuntime.wrap(function (_context4) {
404
- while (1) switch (_context4.prev = _context4.next) {
405
- case 0:
406
- tempPlaceholders = [];
407
- _context4.next = 1;
408
- return parseTempPlaceholdersFromCabinetPayload(cabinetPayload);
409
- case 1:
410
- tempPlaceholders = _context4.sent;
411
- cabinetPayloadKeys = Object.keys(cabinetPayload);
412
- for (i = 0; i < cabinetPayloadKeys.length; i++) {
413
- if (cabinetPayloadKeys[i] === 'structure_json') {
414
- cabinetPayload[cabinetPayloadKeys[i]]['placeholders'] = tempPlaceholders[0].placeholders;
415
- cabinetPayload[cabinetPayloadKeys[i]]['tempPlaceholders'] = tempPlaceholders;
416
- }
417
- }
418
- return _context4.abrupt("return", cabinetPayload);
419
- case 2:
420
- case "end":
421
- return _context4.stop();
422
- }
423
- }, _callee4);
424
- }));
425
- return _updateCabinetPayload.apply(this, arguments);
426
- }
10
+ import { render2DItem, render3DItem } from "../catalog/utils/item-loader";
11
+ import Catalog from "../catalog/catalog";
12
+ import { CatalogElement, safeLoadMapList } from "../models";
427
13
  var loadSVGsByItem = /*#__PURE__*/function () {
428
14
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(item) {
429
15
  var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t;
@@ -472,1000 +58,171 @@ var loadSVGsByItem = /*#__PURE__*/function () {
472
58
  }
473
59
  }, _callee, null, [[1, 5]]);
474
60
  }));
475
- return function loadSVGsByItem(_x4) {
61
+ return function loadSVGsByItem(_x) {
476
62
  return _ref.apply(this, arguments);
477
63
  };
478
64
  }();
479
- function addItemToCatalog(_x5, _x6, _x7, _x8) {
480
- return _addItemToCatalog.apply(this, arguments);
481
- } // Get attributs of current selected element
482
- function _addItemToCatalog() {
483
- _addItemToCatalog = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(element, state, catalogInstance, projectActions) {
484
- var _element, _element2;
485
- var elementJs, catalog, outlineSVGData, _element$structure_js, _element$structure_js2, _element$structure_js3, updatedStructureJson;
486
- return _regeneratorRuntime.wrap(function (_context5) {
487
- while (1) switch (_context5.prev = _context5.next) {
488
- case 0:
489
- if (!isEmpty((_element = element) === null || _element === void 0 ? void 0 : _element.name)) {
490
- _context5.next = 1;
491
- break;
492
- }
493
- return _context5.abrupt("return");
494
- case 1:
495
- elementJs = element;
496
- catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
497
- // if (isEmpty(catalog?.elements[element.name])) {
498
- _context5.next = 2;
499
- return loadSVGsByItem(element);
500
- case 2:
501
- outlineSVGData = _context5.sent;
502
- if (!(((_element2 = element) === null || _element2 === void 0 ? void 0 : _element2.type) === 'cabinet')) {
503
- _context5.next = 4;
504
- break;
505
- }
506
- // make placeholders of element and tempPlaceholder
507
- updatedStructureJson = _objectSpread(_objectSpread({}, element.structure_json), (_element$structure_js = (_element$structure_js2 = element.structure_json) === null || _element$structure_js2 === void 0 || (_element$structure_js2 = _element$structure_js2.tempPlaceholders[0]) === null || _element$structure_js2 === void 0 ? void 0 : _element$structure_js2.structure) !== null && _element$structure_js !== void 0 ? _element$structure_js : {});
508
- element.structure_json = updatedStructureJson;
509
- element = _objectSpread(_objectSpread({}, element), {}, {
510
- cds: {
511
- data: [_objectSpread({}, element.customer_property)],
512
- itemID: element.itemID
513
- }
514
- });
515
- if (isEmpty((_element$structure_js3 = element.structure_json) === null || _element$structure_js3 === void 0 ? void 0 : _element$structure_js3.tempPlaceholders)) {
516
- _context5.next = 4;
517
- break;
518
- }
519
- _context5.next = 3;
520
- return updateCabinetPayload(element);
521
- case 3:
522
- elementJs = _context5.sent;
523
- case 4:
524
- elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
525
- outlineSVGData: outlineSVGData,
526
- type: element.type,
527
- render2DItem: render2DItem
528
- });
529
- if (element.type === 'appliance' || element.type === 'furnishing') elementJs.render3DItem = render3DApplianceItem;else if (element.type === 'lighting') elementJs.render3DItem = render3DLightingItem;else elementJs.render3DItem = render3DItem;
530
- elementJs = exporter(elementJs);
531
- if (catalogInstance !== null && catalogInstance !== void 0 && catalogInstance.validateElement(elementJs)) {
532
- catalogInstance.registerElement(elementJs);
533
- projectActions.addElementToCatalog(elementJs);
534
- }
535
- // }
536
- case 5:
537
- case "end":
538
- return _context5.stop();
539
- }
540
- }, _callee5);
541
- }));
542
- return _addItemToCatalog.apply(this, arguments);
543
- }
544
- function initAttrData(element, layer, state) {
545
- element = _typeof(element.misc) === 'object' ? element.set('misc', new Map(element.misc)) : element;
546
- switch (element.prototype) {
547
- case 'items':
548
- {
549
- return new Map(element);
550
- }
551
- case 'lines':
552
- {
553
- var v_a = layer.vertices.get(element.vertices.get(0));
554
- var v_b = layer.vertices.get(element.vertices.get(1));
555
- var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
556
- var _unit = element.misc.get('_unitLength') || UNIT_INCH;
557
- var _length = convert(distance).from(UNIT_CENTIMETER).to(_unit);
558
- if (state.mode == MODE_DRAWING_LINE) {
559
- return new Map({
560
- vertexOne: v_a,
561
- vertexTwo: v_b,
562
- lineLength: new Map({
563
- length: distance,
564
- _length: _length,
565
- _unit: _unit
566
- }),
567
- focus: element.focus
568
- });
569
- } else {
570
- var allLines = layer.lines.toArray();
571
- var relatedLine = allLines.filter(function (line) {
572
- return line.vertices.toArray().includes(v_b.id) && line.id != element.id;
573
- })[0];
574
- var relatedVertexID = relatedLine && (relatedLine.vertices.toArray()[0] == v_b.id ? relatedLine.vertices.toArray()[1] : relatedLine.vertices.toArray()[0]);
575
- var v_d = relatedVertexID && layer.getIn(['vertices', relatedVertexID]);
576
- var lineToExtend = relatedVertexID && allLines.filter(function (line) {
577
- return line.vertices.toArray().includes(relatedVertexID) && line.id != relatedLine.id;
578
- })[0];
579
- var v_c = lineToExtend && layer.getIn(['vertices', lineToExtend.vertices.toArray()[0] == v_d.id ? lineToExtend.vertices.toArray()[1] : lineToExtend.vertices.toArray()[0]]);
580
- return new Map({
581
- vertexOne: v_a,
582
- vertexTwo: v_b,
583
- vertexThree: v_c,
584
- vertexFour: v_d,
585
- lineToExtend: lineToExtend,
586
- lineLength: new Map({
587
- length: distance,
588
- _length: _length,
589
- _unit: _unit
590
- }),
591
- focus: element.focus
592
- });
593
- }
594
- }
595
- case 'holes':
596
- {
597
- var line = layer.lines.get(element.line);
598
- var _layer$vertices$get = layer.vertices.get(line.vertices.get(0)),
599
- x0 = _layer$vertices$get.x,
600
- y0 = _layer$vertices$get.y;
601
- var _layer$vertices$get2 = layer.vertices.get(line.vertices.get(1)),
602
- x1 = _layer$vertices$get2.x,
603
- y1 = _layer$vertices$get2.y;
604
- var lineLength = GeometryUtils.pointsDistance(x0, y0, x1, y1);
605
- var startAt = lineLength * element.offset - element.properties.get('width').get('length') / 2;
606
- var endAt = lineLength - lineLength * element.offset - element.properties.get('width').get('length') / 2;
607
- var _unitA = element.misc.get('_unitA') || UNIT_INCH;
608
- var _lengthA = convert(x0 > x1 ? endAt : startAt).from(UNIT_CENTIMETER).to(_unitA);
609
- var _unitB = element.misc.get('_unitB') || UNIT_INCH;
610
- var _lengthB = convert(x0 > x1 ? startAt : endAt).from(UNIT_CENTIMETER).to(_unitB);
611
- return new Map({
612
- offset: element.offset,
613
- offsetA: new Map({
614
- length: MathUtils.toFixedFloat(x0 > x1 ? endAt : startAt, PRECISION),
615
- _length: MathUtils.toFixedFloat(_lengthA, PRECISION),
616
- _unit: _unitA
617
- }),
618
- offsetB: new Map({
619
- length: MathUtils.toFixedFloat(x0 > x1 ? startAt : endAt, PRECISION),
620
- _length: MathUtils.toFixedFloat(_lengthB, PRECISION),
621
- _unit: _unitB
622
- })
623
- });
624
- }
625
- case 'areas':
626
- {
627
- return new Map({});
628
- }
629
- default:
630
- return null;
631
- }
632
- }
633
- // Get properties of current selected element
634
- function initPropData(element, catalog) {
635
- var mapped = {};
636
- if (!catalog.elements.hasOwnProperty(element.type) && !(!catalog.elements[element.type] && !!catalog.elements[returnReplaceableDeepSearchType(element.type)])) {
637
- console.log("Last Selected ".concat(element.type, " Element does not exist in catalog."));
638
- return new Map(mapped);
639
- }
640
- var catalogElement = catalog.getElement(element.type);
641
- var isFiller = catalogElement.long_name ? catalogElement.long_name.toUpperCase().includes('FILLER') : false;
642
- if (isFiller) {
643
- var height = {
644
- defaultValue: element.properties.get('height').toJS(),
645
- label: 'Height',
646
- type: 'length-measure'
647
- };
648
- var depth = {
649
- defaultValue: element.properties.get('depth').toJS(),
650
- label: 'Depth',
651
- type: 'length-measure'
652
- };
653
- catalogElement.properties = {
654
- altitude: catalogElement.properties.altitude,
655
- width: catalogElement.properties.width,
656
- height: height,
657
- depth: depth,
658
- flip_doorhandle: catalogElement.properties.flip_doorhandle,
659
- resize_and_scaling: catalogElement.properties.resize_and_scaling
660
- };
661
- }
662
- for (var name in catalogElement.properties) {
663
- mapped[name] = new Map({
664
- currentValue: element.properties.has(name) ? element.properties.get(name) : fromJS(catalogElement.properties[name].defaultValue),
665
- configs: catalogElement.properties[name]
666
- });
667
- }
668
- return new Map(mapped);
669
- }
670
- function updateAttributeOfSelectedElement(element, attrPayload, state, layer, catalog, projectActions) {
671
- var _attributesFormData;
672
- var callback = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
673
- var attributesFormData = initAttrData(element, layer, state);
674
- var value = attrPayload.value;
675
- var attributeName = attrPayload.attributeName;
676
- // pre process
677
- if (attributeName === ATT_ITEM_POS) {
678
- // calculate the new position of movement
679
- var rotRad = (value.directionAng + element.rotation) / 180 * Math.PI;
680
- var newX = element.x + convert((value.oldDistance - value.newDistance) * Math.cos(rotRad)).from('in').to('cm');
681
- var newY = element.y + convert((value.oldDistance - value.newDistance) * Math.sin(rotRad)).from('in').to('cm');
682
- // const reversedDirection =
683
- // value.directionAng === LEFT_DIST_ANG
684
- // ? RIGHT_DIST_ANG
685
- // : value.directionAng === RIGHT_DIST_ANG
686
- // ? LEFT_DIST_ANG
687
- // : value.directionAng === BACK_DIST_ANG
688
- // ? FRONT_DIST_ANG
689
- // : BACK_DIST_ANG;
690
- // let dist = convert(
691
- // element.distArray?.find(v => v[1] === reversedDirection)
692
- // ? element.distArray?.find(v => v[1] === reversedDirection)[0]
693
- // : 0
694
- // )
695
- // .from('cm')
696
- // .to('in');
697
- // if (dist + (value.oldDistance - value.newDistance) <= 0 || value.newDistance < 0) {
698
- // // confirm "The item will be placed outside the floor plan. Are you sure?"
699
- // setPopupOpen(true);
700
- // return;
701
- // }
702
- value = {
703
- x: newX,
704
- y: newY
705
- };
706
- } else if (attributeName === ATT_LINE_LENGTH || attributeName === ATT_HOLE_OFFSET_A || attributeName === ATT_HOLE_OFFSET_B) {
707
- var att = attributesFormData.has(attributeName) ? attributesFormData.get(attributeName) : element[attributeName];
708
- if (att) value = att.merge({
709
- _length: value,
710
- _unit: UNIT_INCH,
711
- length: convert(value).from(UNIT_INCH).to(UNIT_CENTIMETER)
712
- });
713
- }
714
- // make the new attrivutes
715
- switch (element.prototype) {
716
- case 'items':
717
- {
718
- if (attributeName == ATT_ITEM_POS) {
719
- var xVal = value.x;
720
- var yVal = value.y;
721
- attributesFormData = attributesFormData.set('x', xVal);
722
- attributesFormData = attributesFormData.set('y', yVal);
723
- } else {
724
- attributesFormData = attributesFormData.set(attributeName, value);
725
- // update the distances from wall
726
- var _GeometryUtils$calcDi = GeometryUtils.calcDistancesFromItemToWalls(attributesFormData, layer),
727
- PointArray = _GeometryUtils$calcDi.PointArray;
728
- attributesFormData = attributesFormData.set('distArray', PointArray);
729
- }
730
- break;
731
- }
732
- case 'lines':
733
- {
734
- switch (attributeName) {
735
- case ATT_LINE_LENGTH:
736
- {
737
- var v_0 = attributesFormData.get('vertexOne');
738
- var v_1 = attributesFormData.get('vertexTwo');
739
- var v_b_new = GeometryUtils.extendLine(v_0.x, v_0.y, v_1.x, v_1.y, value.get('length'), PRECISION);
740
- attributesFormData = attributesFormData.withMutations(function (attr) {
741
- attr.set('vertexTwo', v_1.merge(v_b_new));
742
- attr.set('lineLength', value);
743
- });
744
- break;
745
- }
746
- case ATT_VERTEXT_ONE:
747
- case ATT_VERTEXT_TWO:
748
- {
749
- attributesFormData = attributesFormData.withMutations(function (attr) {
750
- attr.set(attributeName, attr.get(attributeName).merge(value));
751
- var newDistance = GeometryUtils.verticesDistance(attr.get('vertexOne'), attr.get('vertexTwo'));
752
- attr.mergeIn(['lineLength'], attr.get('lineLength').merge({
753
- length: newDistance,
754
- _length: convert(newDistance).from(UNIT_CENTIMETER).to(attr.get('lineLength').get('_unit'))
755
- }));
756
- });
757
- break;
758
- }
759
- default:
760
- {
761
- attributesFormData = attributesFormData.set(attributeName, value);
762
- break;
763
- }
764
- }
765
- break;
766
- }
767
- case 'holes':
768
- {
769
- switch (attributeName) {
770
- case ATT_HOLE_OFFSET_A:
771
- {
772
- var line = layer.lines.get(element.line);
773
- var _layer$vertices$get3 = layer.vertices.get(line.vertices.get(0)),
774
- x0 = _layer$vertices$get3.x,
775
- y0 = _layer$vertices$get3.y;
776
- var _layer$vertices$get4 = layer.vertices.get(line.vertices.get(1)),
777
- x1 = _layer$vertices$get4.x,
778
- y1 = _layer$vertices$get4.y;
779
- var alpha = GeometryUtils.angleBetweenTwoPoints(x0, y0, x1, y1);
780
- var lineLength = GeometryUtils.pointsDistance(x0, y0, x1, y1);
781
- var widthLength = element.properties.get('width').get('length');
782
- var halfWidthLength = widthLength / 2;
783
- var lengthValue = value.get('length');
784
- lengthValue = Math.max(lengthValue, 0);
785
- lengthValue = Math.min(lengthValue, lineLength - widthLength);
786
- var xp = (lengthValue + halfWidthLength) * Math.cos(alpha) + x0;
787
- var yp = (lengthValue + halfWidthLength) * Math.sin(alpha) + y0;
788
- var offset = GeometryUtils.pointPositionOnLineSegment(x0, y0, x1, y1, xp, yp);
789
- /*
790
- if (x0 > x1) offset = 1 - offset;
791
- */
792
- var endAt = MathUtils.toFixedFloat(lineLength - lineLength * offset - halfWidthLength, PRECISION);
793
- var offsetUnit = attributesFormData.getIn(['offsetB', '_unit']);
794
- var offsetB = new Map({
795
- length: endAt,
796
- _length: convert(endAt).from(UNIT_CENTIMETER).to(offsetUnit),
797
- _unit: offsetUnit
798
- });
799
- attributesFormData = attributesFormData.set('offsetB', offsetB).set('offset', offset);
800
- var offsetAttribute = new Map({
801
- length: MathUtils.toFixedFloat(lengthValue, PRECISION),
802
- _unit: value.get('_unit'),
803
- _length: MathUtils.toFixedFloat(convert(lengthValue).from(UNIT_CENTIMETER).to(value.get('_unit')), PRECISION)
804
- });
805
- attributesFormData = attributesFormData.set(attributeName, offsetAttribute);
806
- break;
807
- }
808
- case ATT_HOLE_OFFSET_B:
809
- {
810
- var _line = layer.lines.get(element.line);
811
- var _layer$vertices$get5 = layer.vertices.get(_line.vertices.get(0)),
812
- _x9 = _layer$vertices$get5.x,
813
- _y = _layer$vertices$get5.y;
814
- var _layer$vertices$get6 = layer.vertices.get(_line.vertices.get(1)),
815
- _x0 = _layer$vertices$get6.x,
816
- _y2 = _layer$vertices$get6.y;
817
- var _alpha = GeometryUtils.angleBetweenTwoPoints(_x9, _y, _x0, _y2);
818
- var _lineLength = GeometryUtils.pointsDistance(_x9, _y, _x0, _y2);
819
- var _widthLength = element.properties.get('width').get('length');
820
- var _halfWidthLength = _widthLength / 2;
821
- var _lengthValue = value.get('length');
822
- _lengthValue = Math.max(_lengthValue, 0);
823
- _lengthValue = Math.min(_lengthValue, _lineLength - _widthLength);
824
- var _xp = _x0 - (_lengthValue + _halfWidthLength) * Math.cos(_alpha);
825
- var _yp = _y2 - (_lengthValue + _halfWidthLength) * Math.sin(_alpha);
826
- var _offset = GeometryUtils.pointPositionOnLineSegment(_x9, _y, _x0, _y2, _xp, _yp);
827
- /*
828
- if (x0 > x1) offset = 1 - offset;
829
- */
830
- var startAt = MathUtils.toFixedFloat(_lineLength * _offset - _halfWidthLength, PRECISION);
831
- var _offsetUnit = attributesFormData.getIn(['offsetA', '_unit']);
832
- var offsetA = new Map({
833
- length: startAt,
834
- _length: convert(startAt).from(UNIT_CENTIMETER).to(_offsetUnit),
835
- _unit: _offsetUnit
836
- });
837
- attributesFormData = attributesFormData.set('offsetA', offsetA).set('offset', _offset);
838
- var _offsetAttribute = new Map({
839
- length: MathUtils.toFixedFloat(_lengthValue, PRECISION),
840
- _unit: value.get('_unit'),
841
- _length: MathUtils.toFixedFloat(convert(_lengthValue).from(UNIT_CENTIMETER).to(value.get('_unit')), PRECISION)
842
- });
843
- attributesFormData = attributesFormData.set(attributeName, _offsetAttribute);
844
- break;
845
- }
846
- default:
847
- {
848
- attributesFormData = attributesFormData.set(attributeName, value);
849
- break;
850
- }
851
- }
852
- break;
853
- }
854
- default:
855
- break;
856
- }
857
-
858
- // update attribute action
859
- switch (element.prototype) {
860
- case 'items':
861
- {
862
- projectActions.setItemsAttributes(attributesFormData);
863
- break;
864
- }
865
- case 'lines':
866
- {
867
- projectActions.setLinesAttributes(attributesFormData);
868
- break;
869
- }
870
- case 'holes':
871
- {
872
- projectActions.setHolesAttributes(attributesFormData);
873
- break;
874
- }
875
- }
876
-
877
- // invoke callback
878
- if (callback) callback((_attributesFormData = attributesFormData) === null || _attributesFormData === void 0 ? void 0 : _attributesFormData.toJS());
879
- }
880
- function updatePropertyOfSelectedElement(element, propertyPayload, catalog,
881
- // class instance of Catalog, get from props
882
- projectActions) {
883
- var _propertiesFormData;
884
- var callback = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
885
- var propertiesFormData = initPropData(element, catalog);
886
- var value = propertyPayload.value;
887
- var propertyName = propertyPayload.propertyName;
888
- // make new properties
889
- if (propertyName === PROP_FLIP_DOOR_HANDLE && element.properties.get(PROP_OPEN_DOORS)) {
890
- alert('Doors are already open.');
891
- return;
892
- }
893
- propertiesFormData = propertiesFormData.setIn([propertyName, 'currentValue'], value);
894
-
895
- // update property action
896
- if (propertiesFormData) {
897
- var properties = propertiesFormData.map(function (data) {
898
- return data.get('currentValue');
899
- });
900
- projectActions.setProperties(properties);
901
- }
902
-
903
- // invoke callback
904
- if (callback) callback((_propertiesFormData = propertiesFormData) === null || _propertiesFormData === void 0 ? void 0 : _propertiesFormData.toJS());
905
- }
906
- function getElement(objProps, state) {
907
- var layerID = state.scene.selectedLayer;
908
- var curObject = null;
909
- if (!isEmpty(objProps === null || objProps === void 0 ? void 0 : objProps.elementPrototype) && !isEmpty(objProps === null || objProps === void 0 ? void 0 : objProps.elementId)) curObject = state.getIn(['scene', 'layers', layerID, objProps.elementPrototype, objProps.elementId]);else {
910
- // if no specified object property then get the first selected element
911
- var layer = state.scene.layers.get(state.scene.selectedLayer);
912
- var selected = [];
913
- layer.selected.forEach(function (data, prototype) {
914
- if (prototype == 'vertices') return;
915
- if (data.size > 0) {
916
- var values = data.toJS();
917
- for (var i = 0; i < values.length; i++) {
918
- selected.push({
919
- type: prototype,
920
- id: values[i]
921
- });
922
- }
923
- }
924
- });
925
- if (selected.length === 1) {
926
- var selData = selected[0];
927
- switch (selData.type) {
928
- case ELEMENT_HOLE:
929
- curObject = layer.holes.get(selData.id);
930
- break;
931
- case ELEMENT_ITEM:
932
- curObject = layer.items.get(selData.id);
933
- break;
934
- case ELEMENT_LINE:
935
- curObject = layer.lines.get(selData.id);
936
- break;
937
- }
938
- }
939
- }
940
- return curObject;
941
- }
942
- function loadMoldingSvg(_x1) {
943
- return _loadMoldingSvg.apply(this, arguments);
944
- }
945
- function _loadMoldingSvg() {
946
- _loadMoldingSvg = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(molding) {
947
- return _regeneratorRuntime.wrap(function (_context6) {
948
- while (1) switch (_context6.prev = _context6.next) {
949
- case 0:
950
- return _context6.abrupt("return", new Promise(function (resolve, reject) {
951
- var url = molding === null || molding === void 0 ? void 0 : molding.shape_svg;
952
- if (!url) {
953
- // Skip if no SVG URL available
954
- return resolve();
955
- }
956
- var loader = new SVGLoader();
957
- loader.load(url, function (data) {
958
- var _data$xml$viewBox$ani, _data$xml, _data$xml$viewBox$ani2, _data$xml2;
959
- molding.data = {
960
- paths: data.paths,
961
- svg_width: (_data$xml$viewBox$ani = (_data$xml = data.xml) === null || _data$xml === void 0 || (_data$xml = _data$xml.viewBox) === null || _data$xml === void 0 || (_data$xml = _data$xml.animVal) === null || _data$xml === void 0 ? void 0 : _data$xml.width) !== null && _data$xml$viewBox$ani !== void 0 ? _data$xml$viewBox$ani : 0,
962
- svg_height: (_data$xml$viewBox$ani2 = (_data$xml2 = data.xml) === null || _data$xml2 === void 0 || (_data$xml2 = _data$xml2.viewBox) === null || _data$xml2 === void 0 || (_data$xml2 = _data$xml2.animVal) === null || _data$xml2 === void 0 ? void 0 : _data$xml2.height) !== null && _data$xml$viewBox$ani2 !== void 0 ? _data$xml$viewBox$ani2 : 0
963
- };
964
- resolve();
965
- }, null, function (error) {
966
- console.error(error);
967
- reject(error);
968
- });
969
- }));
970
- case 1:
971
- case "end":
972
- return _context6.stop();
973
- }
974
- }, _callee6);
975
- }));
976
- return _loadMoldingSvg.apply(this, arguments);
977
- }
978
- function setFinishing(props, state, payload) {
979
- switch (payload.category) {
980
- case FINISHING_TYPE.WALL_COLOR:
981
- if (state.mode !== MODE_ELEVATION_VIEW) props.itemsActions.setWallColor(payload.color);
982
- break;
983
- case FINISHING_TYPE.COUNTER_TOP:
984
- props.itemsActions.setCounterTop({
985
- uri: payload.texture
986
- });
987
- break;
988
- case FINISHING_TYPE.FLOOR_STYLE:
989
- if (state.mode !== MODE_ELEVATION_VIEW) props.areaActions.setFloorStyles({
990
- uri: payload.texture
991
- });
992
- break;
993
- case FINISHING_TYPE.BACKSPLASH:
994
- if (state.mode !== MODE_ELEVATION_VIEW) props.itemsActions.setBacksplash({
995
- uri: payload.texture
996
- });
997
- break;
998
- case FINISHING_TYPE.DOOR_HANDLE:
999
- props.itemsActions.setDoorHandle(payload.gltf);
1000
- break;
1001
- }
1002
- }
1003
- function moveAndRotatePan2D3D(eventType, props, payload, state) {
1004
- if (eventType === EXTERNAL_EVENT_MOVE_PAN) {
1005
- var moveType = payload.moveType,
1006
- moveValue = payload.moveValue;
1007
- var value = state.getIn(['viewer2D']).toJS();
1008
- if (state.mode === MODE_IDLE) {
1009
- switch (moveType) {
1010
- case TOP:
1011
- value.f -= moveValue;
1012
- break;
1013
- case BOTTOM:
1014
- value.f += moveValue;
1015
- break;
1016
- case RIGHT:
1017
- value.e += moveValue;
1018
- break;
1019
- case LEFT:
1020
- value.e -= moveValue;
1021
- break;
1022
- }
1023
- updateViwer2D(value, props.viewer2DActions);
1024
- } else if (state.mode === MODE_IDLE_3D) {
1025
- switch (moveType) {
1026
- case TOP:
1027
- window.interval = setTimeout(function () {
1028
- window.tDKeyDown({
1029
- keyCode: 38
1030
- });
1031
- }, 50);
1032
- break;
1033
- case BOTTOM:
1034
- window.interval = setTimeout(function () {
1035
- window.tDKeyDown({
1036
- keyCode: 40
1037
- });
1038
- }, 50);
1039
- break;
1040
- case RIGHT:
1041
- window.interval = setTimeout(function () {
1042
- window.tDKeyDown({
1043
- keyCode: 37
1044
- });
1045
- }, 50);
1046
- break;
1047
- case LEFT:
1048
- window.interval = setTimeout(function () {
1049
- window.tDKeyDown({
1050
- keyCode: 39
1051
- });
1052
- }, 50);
1053
- break;
1054
- }
1055
- }
1056
- } else if (eventType === EXTERNAL_EVENT_ROTATE_PAN) {
1057
- var rotateType = payload.rotateType;
1058
- switch (rotateType) {
1059
- case TOP:
1060
- window.interval = setTimeout(function () {
1061
- window.SPKeyDown({
1062
- keyCode: 87
1063
- });
1064
- }, 50);
1065
- break;
1066
- case BOTTOM:
1067
- window.interval = setTimeout(function () {
1068
- window.SPKeyDown({
1069
- keyCode: 83
1070
- });
1071
- }, 50);
1072
- break;
1073
- case RIGHT:
1074
- window.interval = setTimeout(function () {
1075
- window.SPKeyDown({
1076
- keyCode: 68
1077
- });
1078
- }, 50);
1079
- break;
1080
- case LEFT:
1081
- window.interval = setTimeout(function () {
1082
- window.SPKeyDown({
1083
- keyCode: 65
1084
- });
1085
- }, 50);
1086
- break;
1087
- }
1088
- }
1089
- }
1090
- export function handleExternalEvent(_x10) {
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) {
1091
69
  return _handleExternalEvent.apply(this, arguments);
1092
70
  }
1093
71
  function _handleExternalEvent() {
1094
- _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(props) {
1095
- var _evt$payload3, _evt$payload4;
1096
- var evt, state, layerId, layer, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, _state$getIn, element, cds, _cds$find, currentCdsId, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, defaulTitle, _Object$keys, _evt$payload5, doorStyle, itemCDS, isAll, _layerId, _cdsItems, allItems, selectedItemId, _itemKeys, _loop4, _i2, _props$onInternalEven2, _evt$payload6, roomShapeType, width, height, _doorStyle, value, _value, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value2, _layerId2, _layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i4, _i5, _i6, _evt$payload9, _evt$payload0, _evt$payload1, _evt$payload10, _layerID, _layer2, orginalItemInfo, originalItem, originalItemPos, replaceItem, _props$onInternalEven3, sceneData, currentTexture, _t5, _t6;
1097
- return _regeneratorRuntime.wrap(function (_context1) {
1098
- while (1) switch (_context1.prev = _context1.next) {
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;
74
+ return _regeneratorRuntime.wrap(function (_context2) {
75
+ while (1) switch (_context2.prev = _context2.next) {
1099
76
  case 0:
1100
- // console.log('***external event****', props);
1101
77
  evt = props.externalEvent;
1102
78
  state = props.state.get('KitchenConfigurator');
1103
- layerId = state.getIn(['scene', 'selectedLayer']);
1104
- layer = state.getIn(['scene', 'layers', layerId]);
1105
- _t5 = evt === null || evt === void 0 ? void 0 : evt.type;
1106
- _context1.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_ROTATE_PAN ? 13 : _t5 === EXTERNAL_EVENT_MOVE_PAN ? 13 : _t5 === EXTERNAL_EVENT_NEW_PROJECT ? 14 : _t5 === EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 15 : _t5 === EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 19 : _t5 === EXTERNAL_EVENT_ZOOM_IN ? 20 : _t5 === EXTERNAL_EVENT_ZOOM_OUT ? 21 : _t5 === EXTERNAL_EVENT_CENTERING_2D ? 22 : _t5 === EXTERNAL_EVENT_UNDO ? 23 : _t5 === EXTERNAL_EVENT_REDO ? 24 : _t5 === EXTERNAL_EVENT_SET_MOLDING ? 25 : _t5 === EXTERNAL_EVENT_DUPLICATE_ELEMENT ? 27 : _t5 === EXTERNAL_EVENT_DELETE_ELEMENT ? 28 : _t5 === EXTERNAL_EVENT_PROJECT_SETTING ? 29 : _t5 === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? 38 : _t5 === EXTERNAL_EVENT_UPDATE_PROPERTY ? 38 : _t5 === EXTERNAL_EVENT_REPLACE_CABINET ? 39 : _t5 === EXTERNAL_EVENT_SET_FINISHING ? 41 : _t5 === EXTERNAL_EVENT_SYNC_SCENE ? 42 : 43;
79
+ _t2 = evt === null || evt === void 0 ? void 0 : evt.type;
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;
1107
81
  break;
1108
82
  case 1:
1109
- // prepare item data request
1110
- cdsItems = [];
1111
- itemKeys = Object.keys(evt === null || evt === void 0 || (_evt$payload = evt.payload) === null || _evt$payload === void 0 || (_evt$payload = _evt$payload.layers['layer-1']) === null || _evt$payload === void 0 ? void 0 : _evt$payload.items) || [];
1112
- _loop3 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop3() {
1113
- var _evt$payload2, _it$doorStyle2;
1114
- var it;
1115
- return _regeneratorRuntime.wrap(function (_context8) {
1116
- while (1) switch (_context8.prev = _context8.next) {
1117
- case 0:
1118
- it = evt === null || evt === void 0 || (_evt$payload2 = evt.payload) === null || _evt$payload2 === void 0 || (_evt$payload2 = _evt$payload2.layers['layer-1']) === null || _evt$payload2 === void 0 ? void 0 : _evt$payload2.items[itemKeys[i]]; //////// check altitude of item property and change length from _length (convert length from 'in' fo 'cm')
1119
- if (it.properties.altitude.length !== convert(it.properties.altitude._length).from('in').to('cm')) {
1120
- it.properties.altitude.length = convert(it.properties.altitude._length).from('in').to('cm');
1121
- }
1122
- /////////
1123
- if (!cdsItems.some(function (v) {
1124
- var _it$doorStyle;
1125
- return it.itemID === v.itemID && it.name === v.name && ((_it$doorStyle = it.doorStyle) === null || _it$doorStyle === void 0 || (_it$doorStyle = _it$doorStyle.doorStyles) === null || _it$doorStyle === void 0 ? void 0 : _it$doorStyle.cabinet_door_style_id) === v.cdsId;
1126
- })) cdsItems.push({
1127
- itemID: it.itemID,
1128
- prototype: it.prototype,
1129
- category: it.category,
1130
- name: it.name,
1131
- type: it.type,
1132
- sku_number: it.sku_number,
1133
- cdsId: (_it$doorStyle2 = it.doorStyle) === null || _it$doorStyle2 === void 0 || (_it$doorStyle2 = _it$doorStyle2.doorStyles) === null || _it$doorStyle2 === void 0 ? void 0 : _it$doorStyle2.cabinet_door_style_id
1134
- });
1135
- case 1:
1136
- case "end":
1137
- return _context8.stop();
1138
- }
1139
- }, _loop3);
1140
- });
1141
- i = 0;
1142
- case 2:
1143
- if (!(i < itemKeys.length)) {
1144
- _context1.next = 4;
1145
- break;
1146
- }
1147
- return _context1.delegateYield(_loop3(), "t0", 3);
1148
- case 3:
1149
- i++;
1150
- _context1.next = 2;
1151
- break;
1152
- case 4:
1153
- // request item catalog data to host app
1154
- if (cdsItems.length > 0) {
1155
- (_props$onInternalEven = props.onInternalEvent) === null || _props$onInternalEven === void 0 || _props$onInternalEven.call(props, {
1156
- type: INTERNAL_EVENT_ITEMS_CATALOG,
1157
- value: {
1158
- cdsItems: cdsItems
1159
- }
1160
- }, /*#__PURE__*/function () {
1161
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(result) {
1162
- var _i, _result$elements;
1163
- return _regeneratorRuntime.wrap(function (_context7) {
1164
- while (1) switch (_context7.prev = _context7.next) {
1165
- case 0:
1166
- _i = 0;
1167
- case 1:
1168
- if (!(_i < (result === null || result === void 0 || (_result$elements = result.elements) === null || _result$elements === void 0 ? void 0 : _result$elements.length))) {
1169
- _context7.next = 3;
1170
- break;
1171
- }
1172
- _context7.next = 2;
1173
- return addItemToCatalog(result.elements[_i], state, props.catalog, props.projectActions);
1174
- case 2:
1175
- _i++;
1176
- _context7.next = 1;
1177
- break;
1178
- case 3:
1179
- props.projectActions.loadProject(evt.payload);
1180
- case 4:
1181
- case "end":
1182
- return _context7.stop();
1183
- }
1184
- }, _callee7);
1185
- }));
1186
- return function (_x11) {
1187
- return _ref2.apply(this, arguments);
1188
- };
1189
- }());
1190
- }
1191
- return _context1.abrupt("continue", 43);
1192
- case 5:
1193
83
  props.projectActions.setMode(MODE_IDLE_3D);
1194
- return _context1.abrupt("continue", 43);
1195
- case 6:
84
+ return _context2.abrupt("continue", 25);
85
+ case 2:
1196
86
  props.projectActions.setMode(MODE_IDLE);
1197
- return _context1.abrupt("continue", 43);
1198
- case 7:
1199
- sLineCnt = layer.selected.lines.size;
87
+ return _context2.abrupt("continue", 25);
88
+ case 3:
89
+ sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
1200
90
  if (sLineCnt > 0) props.projectActions.setMode(MODE_ELEVATION_VIEW);
1201
- return _context1.abrupt("continue", 43);
1202
- case 8:
91
+ return _context2.abrupt("continue", 25);
92
+ case 4:
1203
93
  if (state.mode === MODE_IDLE || state.mode === MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
1204
94
  props.projectActions.setMode(MODE_IDLE);
1205
95
  props.linesActions.selectToolDrawingLine('wall');
1206
96
  }
1207
- return _context1.abrupt("continue", 43);
1208
- case 9:
97
+ return _context2.abrupt("continue", 25);
98
+ case 5:
1209
99
  if (isEmpty(evt === null || evt === void 0 ? void 0 : evt.payload)) {
1210
- _context1.next = 11;
100
+ _context2.next = 8;
101
+ break;
102
+ }
103
+ element = evt.payload;
104
+ catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
105
+ if (!isEmpty(catalog === null || catalog === void 0 ? void 0 : catalog.elements[element.name])) {
106
+ _context2.next = 7;
1211
107
  break;
1212
108
  }
1213
- element = evt.payload; ///// filter the tempPlaceholders using layer-doorstyle-cds
1214
- cds = (_state$getIn = state.getIn(['scene', 'layers', 'layer-1', 'doorStyle'])) === null || _state$getIn === void 0 ? void 0 : _state$getIn.cds;
1215
- if (cds) {
1216
- currentCdsId = (_cds$find = cds.find(function (c) {
1217
- return c.itemID === element.itemID;
1218
- })) === null || _cds$find === void 0 ? void 0 : _cds$find.cabinet_door_style_id;
1219
- if (currentCdsId && element.structure_json.tempPlaceholders.length > 0) {
1220
- element.structure_json.tempPlaceholders[0] = element.structure_json.tempPlaceholders.find(function (tPlaceholder) {
1221
- return tPlaceholder.id === currentCdsId;
1222
- });
1223
- }
109
+ _context2.next = 6;
110
+ return loadSVGsByItem(element);
111
+ case 6:
112
+ outlineSVGData = _context2.sent;
113
+ catalogInstance = props.catalog;
114
+ elementJs = exporter(_objectSpread(_objectSpread({}, element), {}, {
115
+ outlineSVGData: outlineSVGData,
116
+ type: 'cabinet',
117
+ render2DItem: render2DItem,
118
+ render3DItem: render3DItem
119
+ }));
120
+ if (catalogInstance !== null && catalogInstance !== void 0 && catalogInstance.validateElement(elementJs)) {
121
+ props.projectActions.addElementToCatalog(elementJs);
1224
122
  }
1225
- /////
1226
- _context1.next = 10;
1227
- return addItemToCatalog(element, state, props.catalog, props.projectActions);
1228
- case 10:
123
+ case 7:
1229
124
  // start drawing item
1230
- if (ARRAY_3D_MODES.includes(state.mode)) {
1231
- // in 3d view
1232
- props.itemsActions.selectToolDrawingItem3D(element.name);
1233
- } else {
1234
- // in 2d view
1235
- // create cabinet
1236
- props.itemsActions.selectToolDrawingItem(element.name);
1237
- // mapping the initial position of client coord to viewer2D coord
1238
- _evt$payload$initialP = evt.payload.initialPosition, mouseX = _evt$payload$initialP.mouseX, mouseY = _evt$payload$initialP.mouseY;
1239
- v2d = (_state$viewer2D = state.viewer2D) === null || _state$viewer2D === void 0 ? void 0 : _state$viewer2D.toJS();
1240
- if (mouseX && mouseY && v2d) {
1241
- vPosX = (mouseX - v2d.e) / v2d.a;
1242
- vPosY = (mouseY - v2d.f) / v2d.d;
1243
- layerID = state.scene.selectedLayer; // move cabinet to initial position
1244
- props.itemsActions.updateDrawingItem(layerID, vPosX, -vPosY + state.scene.height, true);
1245
- }
1246
- }
125
+ ARRAY_3D_MODES.includes(state.mode) ? props.itemsActions.selectToolDrawingItem3D(element.name) : props.itemsActions.selectToolDrawingItem(element.name);
1247
126
  props.projectActions.pushLastSelectedCatalogElementToHistory(element);
1248
127
  props.projectActions.setIsCabinetDrawing(true);
128
+ case 8:
129
+ return _context2.abrupt("continue", 25);
130
+ case 9:
131
+ _evt$payload = evt.payload, moveType = _evt$payload.moveType, moveValue = _evt$payload.moveValue;
132
+ value = state.getIn(['viewer2D']).toJS();
133
+ _t3 = moveType;
134
+ _context2.next = _t3 === TOP ? 10 : _t3 === BOTTOM ? 11 : _t3 === RIGHT ? 12 : _t3 === LEFT ? 13 : 14;
135
+ break;
136
+ case 10:
137
+ value.f -= moveValue;
138
+ return _context2.abrupt("continue", 14);
1249
139
  case 11:
1250
- return _context1.abrupt("continue", 43);
140
+ value.f += moveValue;
141
+ return _context2.abrupt("continue", 14);
1251
142
  case 12:
1252
- 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);
1253
- return _context1.abrupt("continue", 43);
143
+ value.e += moveValue;
144
+ return _context2.abrupt("continue", 14);
1254
145
  case 13:
1255
- moveAndRotatePan2D3D(evt.type, props, evt.payload, state);
1256
- return _context1.abrupt("continue", 43);
146
+ value.e -= moveValue;
147
+ return _context2.abrupt("continue", 14);
1257
148
  case 14:
149
+ if (compareSVGRect(value)) props.viewer2DActions.updateCameraView(value);
150
+ return _context2.abrupt("continue", 25);
151
+ case 15:
1258
152
  defaulTitle = 'Untitle';
1259
153
  props.projectActions.newProject();
1260
154
  props.projectActions.rename(defaulTitle);
1261
- return _context1.abrupt("continue", 43);
1262
- case 15:
1263
- _evt$payload5 = evt.payload, doorStyle = _evt$payload5.doorStyle, itemCDS = _evt$payload5.itemCDS, isAll = _evt$payload5.isAll; // prepare item data request
1264
- _layerId = state.getIn(['scene', 'selectedLayer']);
1265
- _cdsItems = [];
1266
- allItems = state.getIn(['scene', 'layers', _layerId, 'items']).toJS();
1267
- selectedItemId = state.getIn(['scene', 'layers', _layerId]).selected.items.toJS()[0];
1268
- _itemKeys = isAll ? (_Object$keys = Object.keys(allItems)) !== null && _Object$keys !== void 0 ? _Object$keys : [] : [selectedItemId];
1269
- _loop4 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop4() {
1270
- var _itemCDS$find;
1271
- var item, cdsId;
1272
- return _regeneratorRuntime.wrap(function (_context0) {
1273
- while (1) switch (_context0.prev = _context0.next) {
1274
- case 0:
1275
- item = allItems[_itemKeys[_i2]];
1276
- cdsId = (_itemCDS$find = itemCDS.find(function (itCDS) {
1277
- return itCDS.itemID === item.itemID;
1278
- })) === null || _itemCDS$find === void 0 ? void 0 : _itemCDS$find.cabinet_door_style_id;
1279
- if (cdsId && !_cdsItems.some(function (v) {
1280
- return item.itemID === v.itemID && item.name === v.name && cdsId === v.cdsId;
1281
- })) _cdsItems.push({
1282
- itemID: item.itemID,
1283
- prototype: item.prototype,
1284
- category: item.category,
1285
- name: item.name,
1286
- type: item.type,
1287
- sku_number: item.sku_number,
1288
- cdsId: cdsId
1289
- });
1290
- case 1:
1291
- case "end":
1292
- return _context0.stop();
1293
- }
1294
- }, _loop4);
1295
- });
1296
- _i2 = 0;
155
+ return _context2.abrupt("continue", 25);
1297
156
  case 16:
1298
- if (!(_i2 < _itemKeys.length)) {
1299
- _context1.next = 18;
1300
- break;
1301
- }
1302
- return _context1.delegateYield(_loop4(), "t1", 17);
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);
1303
160
  case 17:
1304
- _i2++;
1305
- _context1.next = 16;
1306
- break;
161
+ _doorStyle = evt.payload.doorStyle;
162
+ props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle, _doorStyle.oStyle);
163
+ return _context2.abrupt("continue", 25);
1307
164
  case 18:
1308
- // request item catalog data to host app
1309
- if (_cdsItems.length > 0) {
1310
- (_props$onInternalEven2 = props.onInternalEvent) === null || _props$onInternalEven2 === void 0 || _props$onInternalEven2.call(props, {
1311
- type: INTERNAL_EVENT_ITEMS_CATALOG,
1312
- value: {
1313
- cdsItems: _cdsItems
1314
- }
1315
- }, /*#__PURE__*/function () {
1316
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(result) {
1317
- var _i3, _result$elements2;
1318
- return _regeneratorRuntime.wrap(function (_context9) {
1319
- while (1) switch (_context9.prev = _context9.next) {
1320
- case 0:
1321
- _i3 = 0;
1322
- case 1:
1323
- if (!(_i3 < (result === null || result === void 0 || (_result$elements2 = result.elements) === null || _result$elements2 === void 0 ? void 0 : _result$elements2.length))) {
1324
- _context9.next = 3;
1325
- break;
1326
- }
1327
- _context9.next = 2;
1328
- return addItemToCatalog(result.elements[_i3], state, props.catalog, props.projectActions);
1329
- case 2:
1330
- _i3++;
1331
- _context9.next = 1;
1332
- break;
1333
- case 3:
1334
- props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
1335
- case 4:
1336
- case "end":
1337
- return _context9.stop();
1338
- }
1339
- }, _callee8);
1340
- }));
1341
- return function (_x12) {
1342
- return _ref3.apply(this, arguments);
1343
- };
1344
- }());
1345
- } else props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
1346
- return _context1.abrupt("continue", 43);
165
+ props.projectActions.loadProject(evt.payload, props.categoryData);
166
+ return _context2.abrupt("continue", 25);
1347
167
  case 19:
1348
- _evt$payload6 = evt.payload, roomShapeType = _evt$payload6.roomShapeType, width = _evt$payload6.width, height = _evt$payload6.height, _doorStyle = _evt$payload6.doorStyle;
1349
- props.projectActions.createRoomWithShape(roomShapeType, width, height, _doorStyle);
1350
- return _context1.abrupt("continue", 43);
1351
- case 20:
1352
- value = state.getIn(['viewer2D']).toJS();
1353
- value.a += 0.1;
1354
- value.d += 0.1;
1355
- value.e -= value.SVGWidth * 0.1 / 2;
1356
- value.f -= value.SVGHeight * 0.1 / 2;
1357
- updateViwer2D(value, props.viewer2DActions);
1358
- return _context1.abrupt("continue", 43);
1359
- case 21:
1360
168
  _value = state.getIn(['viewer2D']).toJS();
1361
169
  _value.a -= 0.1;
1362
170
  _value.d -= 0.1;
1363
171
  _value.e += _value.SVGWidth * 0.1 / 2;
1364
172
  _value.f += _value.SVGHeight * 0.1 / 2;
1365
- updateViwer2D(_value, props.viewer2DActions);
1366
- return _context1.abrupt("continue", 43);
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);
1367
200
  case 22:
1368
- centering2D(state, props.viewer2DActions);
1369
- return _context1.abrupt("continue", 43);
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");
1370
212
  case 23:
1371
- props.projectActions.undo();
1372
- return _context1.abrupt("continue", 43);
213
+ if (!(_zoomValue2 < 35 || Number.isNaN(_zoomValue2))) {
214
+ _context2.next = 24;
215
+ break;
216
+ }
217
+ return _context2.abrupt("return");
1373
218
  case 24:
1374
- props.projectActions.redo();
1375
- return _context1.abrupt("continue", 43);
219
+ if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2);
220
+ return _context2.abrupt("continue", 25);
1376
221
  case 25:
1377
- _evt$payload7 = evt.payload, moldingInfo = _evt$payload7.moldingInfo, isGlobal = _evt$payload7.isGlobal;
1378
- _context1.next = 26;
1379
- return loadMoldingSvg(moldingInfo);
1380
- case 26:
1381
- props.itemsActions.setMolding(moldingInfo, isGlobal);
1382
- return _context1.abrupt("continue", 43);
1383
- case 27:
1384
- distElement = getElement(evt.payload, state);
1385
- if (distElement) props.itemsActions.duplicateSelected(distElement, props.onInternalEvent);
1386
- return _context1.abrupt("continue", 43);
1387
- case 28:
1388
- _distElement = getElement(evt.payload, state);
1389
- if (_distElement) props.projectActions.remove(_distElement);
1390
- return _context1.abrupt("continue", 43);
1391
- case 29:
1392
- _evt$payload8 = evt.payload, option = _evt$payload8.option, _value2 = _evt$payload8.value;
1393
- _t6 = option;
1394
- _context1.next = _t6 === PROJECT_SETTING_OPTION.CHANGE_MEASUREMENT_UNIT ? 30 : _t6 === PROJECT_SETTING_OPTION.UPDATE_CEIL_HEIGHT ? 31 : _t6 === PROJECT_SETTING_OPTION.CHANGE_WALL_LENGTH_MEASURE ? 32 : _t6 === PROJECT_SETTING_OPTION.CHANGE_BASE_CABINET_MEASURE ? 33 : _t6 === PROJECT_SETTING_OPTION.CHANGE_WALL_CABINET_MEASURE ? 34 : _t6 === PROJECT_SETTING_OPTION.CHANGE_WINDOW_DOOR_MEASURE ? 35 : 36;
1395
- break;
1396
- case 30:
1397
- props.viewer2DActions.updateCeilHeightUnit(_value2);
1398
- case 31:
1399
- props.viewer2DActions.updateCeilHeight(_value2);
1400
- props.viewer3DActions.update3DCeilHeight(_value2);
1401
- return _context1.abrupt("continue", 37);
1402
- case 32:
1403
- props.viewer2DActions.changeWallLengthMeasure(_value2);
1404
- return _context1.abrupt("continue", 37);
1405
- case 33:
1406
- props.viewer2DActions.changeBaseCabinetMeasure(_value2);
1407
- return _context1.abrupt("continue", 37);
1408
- case 34:
1409
- props.viewer2DActions.changeWallCabinetMeasure(_value2);
1410
- return _context1.abrupt("continue", 37);
1411
- case 35:
1412
- props.viewer2DActions.changeWindowDoorMeasure(_value2);
1413
- return _context1.abrupt("continue", 37);
1414
- case 36:
1415
- return _context1.abrupt("continue", 37);
1416
- case 37:
1417
- return _context1.abrupt("continue", 43);
1418
- case 38:
1419
- _layerId2 = state.getIn(['scene', 'selectedLayer']);
1420
- _layer = state.getIn(['scene', 'layers', _layerId2]);
1421
- _layer$getIn = _layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
1422
- for (_i4 = 0; _i4 < selectedLines.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, state, _layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1423
- for (_i5 = 0; _i5 < selectedHoles.size; _i5++) (evt === null || evt === void 0 ? void 0 : evt.type) === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, state, _layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1424
- for (_i6 = 0; _i6 < selectedItems.size; _i6++) (evt === null || evt === void 0 ? void 0 : evt.type) === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, state, _layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1425
- return _context1.abrupt("continue", 43);
1426
- case 39:
1427
- _layerID = state.scene.selectedLayer;
1428
- _layer2 = state.scene.getIn(['layers', _layerID]).toJS();
1429
- orginalItemInfo = evt === null || evt === void 0 || (_evt$payload9 = evt.payload) === null || _evt$payload9 === void 0 ? void 0 : _evt$payload9.orginalItemInfo;
1430
- originalItem = _layer2 === null || _layer2 === void 0 ? void 0 : _layer2.items[orginalItemInfo.id];
1431
- _context1.next = 40;
1432
- return addItemToCatalog(evt.payload.replaceItemInfo, state, props.catalog, props.projectActions);
1433
- case 40:
1434
- originalItemPos = {
1435
- rotation: originalItem.rotation,
1436
- selectedItemId: originalItem.id,
1437
- x: originalItem.x,
1438
- y: originalItem.y
1439
- };
1440
- replaceItem = {
1441
- 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,
1442
- info: {
1443
- 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,
1444
- 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
1445
- }
1446
- };
1447
- props.itemsActions.replaceItem(originalItemPos, originalItem, replaceItem);
1448
- return _context1.abrupt("continue", 43);
1449
- case 41:
1450
- setFinishing(props, state, evt.payload);
1451
- return _context1.abrupt("continue", 43);
1452
- case 42:
1453
- sceneData = state.scene.toJS(); // get molding data for "ReviewForQuote"
1454
- currentTexture = layer.doorStyle !== null || layer.doorStyle !== undefined ? layer.doorStyle : props.state.doorStyle.toJS();
1455
- sceneData.layers[layerId].moldingData = getMoldingDataOfScene(layer, props.catalog, currentTexture);
1456
- // send scene object from 3DTool to HostApp using internalEvent
1457
- (_props$onInternalEven3 = props.onInternalEvent) === null || _props$onInternalEven3 === void 0 || _props$onInternalEven3.call(props, {
1458
- type: INTERNAL_EVENT_SYNC_SCENE,
1459
- value: {
1460
- scene: sceneData
1461
- }
1462
- });
1463
- return _context1.abrupt("continue", 43);
1464
- case 43:
1465
222
  case "end":
1466
- return _context1.stop();
223
+ return _context2.stop();
1467
224
  }
1468
- }, _callee9);
225
+ }, _callee2);
1469
226
  }));
1470
227
  return _handleExternalEvent.apply(this, arguments);
1471
228
  }