kitchen-simulator 1.1.1-test.49 → 1.1.1-test.50

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 (358) hide show
  1. package/es/@history.js +2 -0
  2. package/es/AppContext.js +3 -0
  3. package/es/KitchenConfigurator.js +645 -0
  4. package/es/KitchenConfiguratorApp.js +480 -0
  5. package/es/actions/area-actions.js +14 -0
  6. package/es/actions/export.js +23 -0
  7. package/es/actions/groups-actions.js +89 -0
  8. package/es/actions/holes-actions.js +119 -0
  9. package/es/actions/items-actions.js +313 -0
  10. package/es/actions/lines-actions.js +81 -0
  11. package/es/actions/project-actions.js +281 -0
  12. package/es/actions/scene-actions.js +33 -0
  13. package/es/actions/vertices-actions.js +27 -0
  14. package/es/actions/viewer2d-actions.js +58 -0
  15. package/es/actions/viewer3d-actions.js +23 -0
  16. package/es/catalog/areas/area/planner-element.js +40 -0
  17. package/es/catalog/areas/area/textures/ceramic-tile.jpg +0 -0
  18. package/es/catalog/areas/area/textures/grass.jpg +0 -0
  19. package/es/catalog/areas/area/textures/parquet.jpg +0 -0
  20. package/es/catalog/areas/area/textures/strand-porcelain.jpg +0 -0
  21. package/es/catalog/areas/area/textures/tile1.jpg +0 -0
  22. package/es/catalog/catalog.js +277 -0
  23. package/es/catalog/envMap/nx.hdr +0 -0
  24. package/es/catalog/envMap/ny.hdr +0 -0
  25. package/es/catalog/envMap/nz.hdr +0 -0
  26. package/es/catalog/envMap/px.hdr +0 -0
  27. package/es/catalog/envMap/py.hdr +0 -0
  28. package/es/catalog/envMap/pz.hdr +0 -0
  29. package/es/catalog/factories/area-factory-3d.js +181 -0
  30. package/es/catalog/factories/area-factory.js +81 -0
  31. package/es/catalog/factories/export.js +7 -0
  32. package/es/catalog/factories/wall-factory-3d.js +202 -0
  33. package/es/catalog/factories/wall-factory.js +268 -0
  34. package/es/catalog/holes/door-closet/planner-element.js +222 -0
  35. package/es/catalog/holes/door-double/door_double.png +0 -0
  36. package/es/catalog/holes/door-double/planner-element.js +315 -0
  37. package/es/catalog/holes/door-exterior/planner-element.js +215 -0
  38. package/es/catalog/holes/door-interior/planner-element.js +227 -0
  39. package/es/catalog/holes/door-panic/panicDoor.png +0 -0
  40. package/es/catalog/holes/door-panic/planner-element.js +503 -0
  41. package/es/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
  42. package/es/catalog/holes/door-panic-double/planner-element.js +463 -0
  43. package/es/catalog/holes/door-sliding/planner-element.js +225 -0
  44. package/es/catalog/holes/doorway-framed/planner-element.js +145 -0
  45. package/es/catalog/holes/doorway-frameless/planner-element.js +104 -0
  46. package/es/catalog/holes/export.js +13 -0
  47. package/es/catalog/holes/gate/gate.jpg +0 -0
  48. package/es/catalog/holes/window-clear/planner-element.js +166 -0
  49. package/es/catalog/holes/window-clear/texture.png +0 -0
  50. package/es/catalog/holes/window-cross/planner-element.js +165 -0
  51. package/es/catalog/holes/window-cross/texture.png +0 -0
  52. package/es/catalog/holes/window-double-hung/planner-element.js +303 -0
  53. package/es/catalog/holes/window-double-hung/texture.png +0 -0
  54. package/es/catalog/holes/window-vertical/planner-element.js +276 -0
  55. package/es/catalog/holes/window-vertical/texture.png +0 -0
  56. package/es/catalog/lines/wall/planner-element.js +70 -0
  57. package/es/catalog/lines/wall/textures/bricks-normal.jpg +0 -0
  58. package/es/catalog/lines/wall/textures/bricks-normal2.jpg +0 -0
  59. package/es/catalog/lines/wall/textures/bricks.jpg +0 -0
  60. package/es/catalog/lines/wall/textures/bricks2.jpg +0 -0
  61. package/es/catalog/lines/wall/textures/bricks3.jpg +0 -0
  62. package/es/catalog/lines/wall/textures/morden-normal.jpg +0 -0
  63. package/es/catalog/lines/wall/textures/morden.jpg +0 -0
  64. package/es/catalog/lines/wall/textures/painted-normal.jpg +0 -0
  65. package/es/catalog/lines/wall/textures/painted.jpg +0 -0
  66. package/es/catalog/lines/wall/textures/plaster-normal.jpg +0 -0
  67. package/es/catalog/lines/wall/textures/plaster.jpg +0 -0
  68. package/es/catalog/lines/wall/wall.png +0 -0
  69. package/es/catalog/molding/molding-dcm/planner-element.js +28 -0
  70. package/es/catalog/molding/molding-dcm/texture.png +0 -0
  71. package/es/catalog/molding/molding-fbm/planner-element.js +28 -0
  72. package/es/catalog/molding/molding-fbm/texture.png +0 -0
  73. package/es/catalog/molding/molding-lrm/planner-element.js +28 -0
  74. package/es/catalog/molding/molding-lrm/texture.png +0 -0
  75. package/es/catalog/properties/export.js +21 -0
  76. package/es/catalog/properties/property-checkbox.js +116 -0
  77. package/es/catalog/properties/property-color.js +39 -0
  78. package/es/catalog/properties/property-enum.js +97 -0
  79. package/es/catalog/properties/property-hidden.js +19 -0
  80. package/es/catalog/properties/property-lenght-measure.js +101 -0
  81. package/es/catalog/properties/property-length-measure.js +134 -0
  82. package/es/catalog/properties/property-length-measure_hole.js +101 -0
  83. package/es/catalog/properties/property-number.js +48 -0
  84. package/es/catalog/properties/property-read-only.js +26 -0
  85. package/es/catalog/properties/property-string.js +48 -0
  86. package/es/catalog/properties/property-toggle.js +39 -0
  87. package/es/catalog/properties/shared-property-style.js +14 -0
  88. package/es/catalog/utils/FuseUtils.js +82 -0
  89. package/es/catalog/utils/exporter.js +148 -0
  90. package/es/catalog/utils/geom-utils.js +189 -0
  91. package/es/catalog/utils/item-loader.js +1521 -0
  92. package/es/catalog/utils/load-obj.js +91 -0
  93. package/es/catalog/utils/mtl-loader.js +358 -0
  94. package/es/catalog/utils/obj-loader.js +477 -0
  95. package/es/class/FuseUtils.js +82 -0
  96. package/es/class/area.js +145 -0
  97. package/es/class/export.js +24 -0
  98. package/es/class/group.js +440 -0
  99. package/es/class/guide.js +62 -0
  100. package/es/class/hole.js +929 -0
  101. package/es/class/item.js +1883 -0
  102. package/es/class/layer.js +667 -0
  103. package/es/class/line.js +1180 -0
  104. package/es/class/project.js +793 -0
  105. package/es/class/vertex.js +202 -0
  106. package/es/components/content.js +107 -0
  107. package/es/components/disclaimer/disclaimer.js +97 -0
  108. package/es/components/export.js +9 -0
  109. package/es/components/style/button.js +113 -0
  110. package/es/components/style/cancel-button.js +22 -0
  111. package/es/components/style/content-container.js +33 -0
  112. package/es/components/style/content-title.js +29 -0
  113. package/es/components/style/delete-button.js +25 -0
  114. package/es/components/style/export.js +31 -0
  115. package/es/components/style/form-block.js +24 -0
  116. package/es/components/style/form-color-input.js +27 -0
  117. package/es/components/style/form-label.js +26 -0
  118. package/es/components/style/form-number-input.js +213 -0
  119. package/es/components/style/form-number-input_2.js +206 -0
  120. package/es/components/style/form-select.js +68 -0
  121. package/es/components/style/form-slider.js +61 -0
  122. package/es/components/style/form-submit-button.js +26 -0
  123. package/es/components/style/form-text-input.js +95 -0
  124. package/es/components/viewer2d/area.js +81 -0
  125. package/es/components/viewer2d/export.js +31 -0
  126. package/es/components/viewer2d/grids/grid-horizontal-streak.js +37 -0
  127. package/es/components/viewer2d/grids/grid-streak.js +37 -0
  128. package/es/components/viewer2d/grids/grid-vertical-streak.js +37 -0
  129. package/es/components/viewer2d/grids/grids.js +35 -0
  130. package/es/components/viewer2d/group.js +53 -0
  131. package/es/components/viewer2d/item.js +513 -0
  132. package/es/components/viewer2d/layer.js +164 -0
  133. package/es/components/viewer2d/line.js +882 -0
  134. package/es/components/viewer2d/ruler.js +100 -0
  135. package/es/components/viewer2d/rulerDist.js +146 -0
  136. package/es/components/viewer2d/rulerX.js +151 -0
  137. package/es/components/viewer2d/rulerY.js +153 -0
  138. package/es/components/viewer2d/scene.js +140 -0
  139. package/es/components/viewer2d/snap.js +74 -0
  140. package/es/components/viewer2d/state.js +78 -0
  141. package/es/components/viewer2d/utils.js +198 -0
  142. package/es/components/viewer2d/vertex.js +65 -0
  143. package/es/components/viewer2d/viewer2d.js +1398 -0
  144. package/es/components/viewer3d/camera-controls-module/camera-controls.module.js +2592 -0
  145. package/es/components/viewer3d/dcm.js +401 -0
  146. package/es/components/viewer3d/fbm.js +414 -0
  147. package/es/components/viewer3d/front3D.js +66 -0
  148. package/es/components/viewer3d/grid-creator.js +25 -0
  149. package/es/components/viewer3d/grids/grid-horizontal-streak.js +36 -0
  150. package/es/components/viewer3d/grids/grid-streak.js +27 -0
  151. package/es/components/viewer3d/grids/grid-vertical-streak.js +36 -0
  152. package/es/components/viewer3d/libs/first-person-controls.js +67 -0
  153. package/es/components/viewer3d/libs/helvetiker_regular.typeface.js +1281 -0
  154. package/es/components/viewer3d/libs/mtl-loader.js +357 -0
  155. package/es/components/viewer3d/libs/obj-loader.js +462 -0
  156. package/es/components/viewer3d/libs/orbit-controls.js +699 -0
  157. package/es/components/viewer3d/libs/pointer-lock-controls.js +46 -0
  158. package/es/components/viewer3d/lrm.js +305 -0
  159. package/es/components/viewer3d/model.js +708 -0
  160. package/es/components/viewer3d/pointer-lock-navigation.js +115 -0
  161. package/es/components/viewer3d/ruler-utils/itemRect.js +61 -0
  162. package/es/components/viewer3d/ruler-utils/layer3D.js +495 -0
  163. package/es/components/viewer3d/ruler-utils/ruler3D.js +227 -0
  164. package/es/components/viewer3d/ruler-utils/scene3D.js +60 -0
  165. package/es/components/viewer3d/ruler-utils/state3D.js +18 -0
  166. package/es/components/viewer3d/scene-creator.js +3608 -0
  167. package/es/components/viewer3d/three-memory-cleaner.js +51 -0
  168. package/es/components/viewer3d/viewer3d-first-person.js +315 -0
  169. package/es/components/viewer3d/viewer3d.js +2527 -0
  170. package/es/constants.js +636 -0
  171. package/es/index.js +16 -0
  172. package/es/models.js +510 -0
  173. package/es/plugins/SVGLoader.js +1412 -0
  174. package/es/plugins/autosave.js +33 -0
  175. package/es/plugins/console-debugger.js +37 -0
  176. package/es/plugins/export.js +9 -0
  177. package/es/plugins/keyboard.js +101 -0
  178. package/es/reducers/areas-reducer.js +12 -0
  179. package/es/reducers/export.js +25 -0
  180. package/es/reducers/groups-reducer.js +38 -0
  181. package/es/reducers/holes-reducer.js +62 -0
  182. package/es/reducers/items-reducer.js +140 -0
  183. package/es/reducers/lines-reducer.js +45 -0
  184. package/es/reducers/project-reducer.js +129 -0
  185. package/es/reducers/reducer.js +19 -0
  186. package/es/reducers/scene-reducer.js +28 -0
  187. package/es/reducers/user-reducer.js +40 -0
  188. package/es/reducers/vertices-reducer.js +19 -0
  189. package/es/reducers/viewer2d-reducer.js +75 -0
  190. package/es/reducers/viewer3d-reducer.js +56 -0
  191. package/es/shared-style.js +66 -0
  192. package/es/styles/export.js +5 -0
  193. package/es/styles/tabs.css +40 -0
  194. package/es/translator/en.js +104 -0
  195. package/es/translator/it.js +79 -0
  196. package/es/translator/ru.js +79 -0
  197. package/es/translator/translator.js +84 -0
  198. package/es/utils/browser.js +33 -0
  199. package/es/utils/email-validator.js +4 -0
  200. package/es/utils/export.js +25 -0
  201. package/es/utils/geometry.js +2420 -0
  202. package/es/utils/get-edges-of-subgraphs.js +27 -0
  203. package/es/utils/graph-cycles.js +237 -0
  204. package/es/utils/graph-inner-cycles.js +46 -0
  205. package/es/utils/graph.js +150 -0
  206. package/es/utils/helper.js +268 -0
  207. package/es/utils/history.js +29 -0
  208. package/es/utils/id-broker.js +19 -0
  209. package/es/utils/logger.js +8 -0
  210. package/es/utils/math.js +50 -0
  211. package/es/utils/molding.js +871 -0
  212. package/es/utils/name-generator.js +18 -0
  213. package/es/utils/objects-utils.js +50 -0
  214. package/es/utils/phone-validator.js +4 -0
  215. package/es/utils/process-black-list.js +18 -0
  216. package/es/utils/react-if.js +18 -0
  217. package/es/utils/snap-scene.js +99 -0
  218. package/es/utils/snap.js +237 -0
  219. package/es/utils/summarizeCart.js +24 -0
  220. package/es/utils/threeCSG.es6.js +498 -0
  221. package/es/version.js +2 -0
  222. package/lib/catalog/properties/property-string.js +55 -0
  223. package/lib/catalog/properties/property-toggle.js +46 -0
  224. package/lib/catalog/properties/shared-property-style.js +20 -0
  225. package/lib/catalog/utils/FuseUtils.js +88 -0
  226. package/lib/catalog/utils/exporter.js +155 -0
  227. package/lib/catalog/utils/geom-utils.js +205 -0
  228. package/lib/catalog/utils/item-loader.js +1533 -0
  229. package/lib/catalog/utils/load-obj.js +99 -0
  230. package/lib/catalog/utils/mtl-loader.js +363 -0
  231. package/lib/catalog/utils/obj-loader.js +482 -0
  232. package/lib/class/FuseUtils.js +88 -0
  233. package/lib/class/area.js +150 -0
  234. package/lib/class/export.js +96 -0
  235. package/lib/class/group.js +445 -0
  236. package/lib/class/guide.js +67 -0
  237. package/lib/class/hole.js +934 -0
  238. package/lib/class/item.js +1889 -0
  239. package/lib/class/layer.js +672 -0
  240. package/lib/class/line.js +1186 -0
  241. package/lib/class/project.js +799 -0
  242. package/lib/class/vertex.js +207 -0
  243. package/lib/components/content.js +116 -0
  244. package/lib/components/disclaimer/disclaimer.js +105 -0
  245. package/lib/components/export.js +33 -0
  246. package/lib/components/style/button.js +120 -0
  247. package/lib/components/style/cancel-button.js +29 -0
  248. package/lib/components/style/content-container.js +40 -0
  249. package/lib/components/style/content-title.js +37 -0
  250. package/lib/components/style/delete-button.js +34 -0
  251. package/lib/components/style/export.js +121 -0
  252. package/lib/components/style/form-block.js +31 -0
  253. package/lib/components/style/form-color-input.js +34 -0
  254. package/lib/components/style/form-label.js +33 -0
  255. package/lib/components/style/form-number-input.js +220 -0
  256. package/lib/components/style/form-number-input_2.js +213 -0
  257. package/lib/components/style/form-select.js +75 -0
  258. package/lib/components/style/form-slider.js +68 -0
  259. package/lib/components/style/form-submit-button.js +35 -0
  260. package/lib/components/style/form-text-input.js +101 -0
  261. package/lib/components/viewer2d/area.js +88 -0
  262. package/lib/components/viewer2d/export.js +121 -0
  263. package/lib/components/viewer2d/grids/grid-horizontal-streak.js +44 -0
  264. package/lib/components/viewer2d/grids/grid-streak.js +44 -0
  265. package/lib/components/viewer2d/grids/grid-vertical-streak.js +44 -0
  266. package/lib/components/viewer2d/grids/grids.js +44 -0
  267. package/lib/components/viewer2d/group.js +62 -0
  268. package/lib/components/viewer2d/item.js +521 -0
  269. package/lib/components/viewer2d/layer.js +171 -0
  270. package/lib/components/viewer2d/line.js +892 -0
  271. package/lib/components/viewer2d/ruler.js +107 -0
  272. package/lib/components/viewer2d/rulerDist.js +153 -0
  273. package/lib/components/viewer2d/rulerX.js +158 -0
  274. package/lib/components/viewer2d/rulerY.js +160 -0
  275. package/lib/components/viewer2d/scene.js +147 -0
  276. package/lib/components/viewer2d/snap.js +83 -0
  277. package/lib/components/viewer2d/state.js +87 -0
  278. package/lib/components/viewer2d/utils.js +210 -0
  279. package/lib/components/viewer2d/vertex.js +74 -0
  280. package/lib/components/viewer2d/viewer2d.js +1405 -0
  281. package/lib/components/viewer3d/camera-controls-module/camera-controls.module.js +2597 -0
  282. package/lib/components/viewer3d/dcm.js +407 -0
  283. package/lib/components/viewer3d/fbm.js +420 -0
  284. package/lib/components/viewer3d/front3D.js +75 -0
  285. package/lib/components/viewer3d/grid-creator.js +34 -0
  286. package/lib/components/viewer3d/grids/grid-horizontal-streak.js +44 -0
  287. package/lib/components/viewer3d/grids/grid-streak.js +35 -0
  288. package/lib/components/viewer3d/grids/grid-vertical-streak.js +44 -0
  289. package/lib/components/viewer3d/libs/first-person-controls.js +74 -0
  290. package/lib/components/viewer3d/libs/helvetiker_regular.typeface.js +1287 -0
  291. package/lib/components/viewer3d/libs/mtl-loader.js +363 -0
  292. package/lib/components/viewer3d/libs/obj-loader.js +468 -0
  293. package/lib/components/viewer3d/libs/orbit-controls.js +705 -0
  294. package/lib/components/viewer3d/libs/pointer-lock-controls.js +52 -0
  295. package/lib/components/viewer3d/lrm.js +311 -0
  296. package/lib/components/viewer3d/model.js +714 -0
  297. package/lib/components/viewer3d/pointer-lock-navigation.js +122 -0
  298. package/lib/components/viewer3d/ruler-utils/itemRect.js +68 -0
  299. package/lib/components/viewer3d/ruler-utils/layer3D.js +502 -0
  300. package/lib/components/viewer3d/ruler-utils/ruler3D.js +234 -0
  301. package/lib/components/viewer3d/ruler-utils/scene3D.js +68 -0
  302. package/lib/components/viewer3d/ruler-utils/state3D.js +25 -0
  303. package/lib/components/viewer3d/scene-creator.js +3642 -0
  304. package/lib/components/viewer3d/three-memory-cleaner.js +60 -0
  305. package/lib/components/viewer3d/viewer3d-first-person.js +320 -0
  306. package/lib/components/viewer3d/viewer3d.js +2532 -0
  307. package/lib/constants.js +645 -0
  308. package/lib/index.js +96 -0
  309. package/lib/models.js +517 -0
  310. package/lib/plugins/SVGLoader.js +1417 -0
  311. package/lib/plugins/autosave.js +39 -0
  312. package/lib/plugins/console-debugger.js +44 -0
  313. package/lib/plugins/export.js +33 -0
  314. package/lib/plugins/keyboard.js +107 -0
  315. package/lib/reducers/areas-reducer.js +18 -0
  316. package/lib/reducers/export.js +97 -0
  317. package/lib/reducers/groups-reducer.js +44 -0
  318. package/lib/reducers/holes-reducer.js +68 -0
  319. package/lib/reducers/items-reducer.js +146 -0
  320. package/lib/reducers/lines-reducer.js +51 -0
  321. package/lib/reducers/project-reducer.js +135 -0
  322. package/lib/reducers/reducer.js +26 -0
  323. package/lib/reducers/scene-reducer.js +34 -0
  324. package/lib/reducers/user-reducer.js +46 -0
  325. package/lib/reducers/vertices-reducer.js +25 -0
  326. package/lib/reducers/viewer2d-reducer.js +82 -0
  327. package/lib/reducers/viewer3d-reducer.js +63 -0
  328. package/lib/shared-style.js +72 -0
  329. package/lib/styles/export.js +13 -0
  330. package/lib/translator/en.js +110 -0
  331. package/lib/translator/it.js +85 -0
  332. package/lib/translator/ru.js +85 -0
  333. package/lib/translator/translator.js +90 -0
  334. package/lib/utils/browser.js +40 -0
  335. package/lib/utils/email-validator.js +10 -0
  336. package/lib/utils/export.js +56 -0
  337. package/lib/utils/geometry.js +2516 -0
  338. package/lib/utils/get-edges-of-subgraphs.js +34 -0
  339. package/lib/utils/graph-cycles.js +240 -0
  340. package/lib/utils/graph-inner-cycles.js +54 -0
  341. package/lib/utils/graph.js +157 -0
  342. package/lib/utils/helper.js +291 -0
  343. package/lib/utils/history.js +36 -0
  344. package/lib/utils/id-broker.js +25 -0
  345. package/lib/utils/logger.js +14 -0
  346. package/lib/utils/math.js +57 -0
  347. package/lib/utils/molding.js +895 -0
  348. package/lib/utils/name-generator.js +23 -0
  349. package/lib/utils/objects-utils.js +60 -0
  350. package/lib/utils/phone-validator.js +10 -0
  351. package/lib/utils/process-black-list.js +24 -0
  352. package/lib/utils/react-if.js +24 -0
  353. package/lib/utils/snap-scene.js +105 -0
  354. package/lib/utils/snap.js +249 -0
  355. package/lib/utils/summarizeCart.js +30 -0
  356. package/lib/utils/threeCSG.es6.js +503 -0
  357. package/lib/version.js +8 -0
  358. package/package.json +3 -3
@@ -0,0 +1,1186 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _immutable = require("immutable");
8
+ var _export = require("./export");
9
+ var _export2 = require("../utils/export");
10
+ var Three = _interopRequireWildcard(require("three"));
11
+ var _constants = require("../constants");
12
+ var _helper = require("../utils/helper");
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
14
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
15
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
17
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
18
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
19
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
20
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
21
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
22
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
23
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
24
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
25
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
26
+ var timeGlobal = 0;
27
+ var TimeRecorder = /*#__PURE__*/function () {
28
+ function TimeRecorder(name) {
29
+ _classCallCheck(this, TimeRecorder);
30
+ this.name = name;
31
+ if (name === 'beginDrawingLine') {
32
+ console.log('time__ Start Drawing');
33
+ }
34
+ }
35
+ return _createClass(TimeRecorder, [{
36
+ key: "start",
37
+ value: function start() {
38
+ this.first = Date.now();
39
+ }
40
+ }, {
41
+ key: "end",
42
+ value: function end() {
43
+ this.second = Date.now();
44
+ var elapsed = this.second - this.first;
45
+ console.log('time__ ', this.name, ' : ', elapsed, 'ms');
46
+ if (['beginDrawingLine', 'updateDrawingLine', 'endDrawingLine'].includes(this.name)) timeGlobal += elapsed;
47
+ if (this.name === 'endDrawingLine') {
48
+ console.log('time__ Drawing Ended. Passed Time : ', timeGlobal, 'ms');
49
+ timeGlobal = 0;
50
+ }
51
+ }
52
+ }]);
53
+ }();
54
+ var Line = exports["default"] = /*#__PURE__*/function () {
55
+ function Line() {
56
+ _classCallCheck(this, Line);
57
+ }
58
+ return _createClass(Line, null, [{
59
+ key: "create",
60
+ value: function create(state, layerID, type, x0, y0, x1, y1, properties) {
61
+ var lineCreatedDateTime = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : new Date().getTime();
62
+ // if end drawing by created area
63
+ // if (state.mode == MODE_IDLE) {
64
+ // return { updatedState: state };
65
+ // }
66
+ // ///////////////
67
+ var lineID = _export2.IDBroker.acquireID();
68
+ var _Vertex$add = _export.Vertex.add(state, layerID, x0, y0, 'lines', lineID),
69
+ stateV0 = _Vertex$add.updatedState,
70
+ v0 = _Vertex$add.vertex;
71
+ var _Vertex$add2 = _export.Vertex.add(stateV0, layerID, x1, y1, 'lines', lineID),
72
+ stateV1 = _Vertex$add2.updatedState,
73
+ v1 = _Vertex$add2.vertex;
74
+ state = stateV1;
75
+ var line = state.catalog.factoryElement(type, {
76
+ id: lineID,
77
+ name: _export2.NameGenerator.generateName('lines', state.catalog.getIn(['elements', type, 'info', 'title'])),
78
+ vertices: new _immutable.List([v0.id, v1.id]),
79
+ type: type
80
+ }, properties);
81
+ line = line.set('createdDateTime', lineCreatedDateTime !== undefined ? lineCreatedDateTime : new Date().getTime());
82
+ state = state.setIn(['scene', 'layers', layerID, 'lines', lineID], line);
83
+ // set default texture//
84
+ var defaultTexture = {
85
+ textureA: 'plaster',
86
+ textureB: 'plaster'
87
+ };
88
+ state = this.setJsProperties(state, layerID, lineID, defaultTexture).updatedState;
89
+ // /////////////////////
90
+ return {
91
+ updatedState: state,
92
+ line: line
93
+ };
94
+ }
95
+ }, {
96
+ key: "select",
97
+ value: function select(state, layerID, lineID) {
98
+ var _line$vertices, _line$vertices$get, _line$vertices2, _line$vertices2$get;
99
+ // Try selecting the layer first
100
+ var layerResult = _export.Layer.select(state, layerID);
101
+ if (!layerResult || !layerResult.updatedState) {
102
+ return {
103
+ updatedState: state
104
+ }; // no update if layer not found
105
+ }
106
+ state = layerResult.updatedState;
107
+
108
+ // Try getting the line
109
+ var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
110
+ if (!line) {
111
+ return {
112
+ updatedState: state
113
+ }; // no update if line not found
114
+ }
115
+
116
+ // Select the line element
117
+ var lineSelectResult = _export.Layer.selectElement(state, layerID, 'lines', lineID);
118
+ if (lineSelectResult !== null && lineSelectResult !== void 0 && lineSelectResult.updatedState) {
119
+ state = lineSelectResult.updatedState;
120
+ }
121
+
122
+ // Select the first vertex (if available)
123
+ var firstVertex = (_line$vertices = line.vertices) === null || _line$vertices === void 0 || (_line$vertices$get = _line$vertices.get) === null || _line$vertices$get === void 0 ? void 0 : _line$vertices$get.call(_line$vertices, 0);
124
+ if (firstVertex !== undefined) {
125
+ var v1Result = _export.Layer.selectElement(state, layerID, 'vertices', firstVertex);
126
+ if (v1Result !== null && v1Result !== void 0 && v1Result.updatedState) {
127
+ state = v1Result.updatedState;
128
+ }
129
+ }
130
+
131
+ // Select the second vertex (if available)
132
+ var secondVertex = (_line$vertices2 = line.vertices) === null || _line$vertices2 === void 0 || (_line$vertices2$get = _line$vertices2.get) === null || _line$vertices2$get === void 0 ? void 0 : _line$vertices2$get.call(_line$vertices2, 1);
133
+ if (secondVertex !== undefined) {
134
+ var v2Result = _export.Layer.selectElement(state, layerID, 'vertices', secondVertex);
135
+ if (v2Result !== null && v2Result !== void 0 && v2Result.updatedState) {
136
+ state = v2Result.updatedState;
137
+ }
138
+ }
139
+ return {
140
+ updatedState: state
141
+ };
142
+ }
143
+ }, {
144
+ key: "remove",
145
+ value: function remove(state, layerID, lineID) {
146
+ var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
147
+ if (line) {
148
+ state = this.unselect(state, layerID, lineID).updatedState;
149
+ line.holes.forEach(function (holeID) {
150
+ return state = _export.Hole.remove(state, layerID, holeID).updatedState;
151
+ });
152
+ state = _export.Layer.removeElement(state, layerID, 'lines', lineID).updatedState;
153
+ line.vertices.forEach(function (vertexID) {
154
+ return state = _export.Vertex.remove(state, layerID, vertexID, 'lines', lineID).updatedState;
155
+ });
156
+ state.getIn(['scene', 'groups']).forEach(function (group) {
157
+ return state = _export.Group.removeElement(state, group.id, layerID, 'lines', lineID).updatedState;
158
+ });
159
+ }
160
+ return {
161
+ updatedState: state
162
+ };
163
+ }
164
+ }, {
165
+ key: "setRelatedLine",
166
+ value: function setRelatedLine(state, layerID, lineID, intersection) {
167
+ var curIntersection = state.getIn(['scene', 'layers', layerID, 'lines', lineID, 'relatedVertices']);
168
+ if (curIntersection == undefined) return {
169
+ updatedState: state
170
+ };
171
+ var isEqualIntersection = function isEqualIntersection(a, b) {
172
+ return a.index == b.index && a.point.x == b.point.x && a.point.y == b.point.y;
173
+ };
174
+ var equal = curIntersection.size == intersection.length && curIntersection.every(function (curint, index) {
175
+ return isEqualIntersection(curint, intersection[index]);
176
+ });
177
+ if (!equal) state = state.mergeIn(['scene', 'layers', layerID, 'lines', lineID, 'relatedVertices'], intersection);
178
+ return {
179
+ updatedState: state
180
+ };
181
+ }
182
+ }, {
183
+ key: "unselect",
184
+ value: function unselect(state, layerID, lineID) {
185
+ var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
186
+ if (line) {
187
+ state = _export.Layer.unselect(state, layerID, 'vertices', line.vertices.get(0)).updatedState;
188
+ state = _export.Layer.unselect(state, layerID, 'vertices', line.vertices.get(1)).updatedState;
189
+ state = _export.Layer.unselect(state, layerID, 'lines', lineID).updatedState;
190
+ }
191
+ return {
192
+ updatedState: state
193
+ };
194
+ }
195
+ }, {
196
+ key: "split",
197
+ value: function split(state, layerID, lineID, x, y) {
198
+ var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
199
+ var v0 = state.getIn(['scene', 'layers', layerID, 'vertices', line.vertices.get(0)]);
200
+ var v1 = state.getIn(['scene', 'layers', layerID, 'vertices', line.vertices.get(1)]);
201
+ var x0 = v0.x,
202
+ y0 = v0.y;
203
+ var x1 = v1.x,
204
+ y1 = v1.y;
205
+ var _Line$create = Line.create(state, layerID, line.type, x0, y0, x, y, line.get('properties'), line.createdDateTime !== undefined ? line.createdDateTime - 2 : new Date().getTime()),
206
+ stateL1 = _Line$create.updatedState,
207
+ line0 = _Line$create.line;
208
+ var _Line$create2 = Line.create(stateL1, layerID, line.type, x1, y1, x, y, line.get('properties'), line.createdDateTime !== undefined ? line.createdDateTime - 1 : new Date().getTime()),
209
+ stateL2 = _Line$create2.updatedState,
210
+ line1 = _Line$create2.line;
211
+ state = stateL2;
212
+ var splitPointOffset = _export2.GeometryUtils.pointPositionOnLineSegment(x0, y0, x1, y1, x, y);
213
+ var minVertex = _export2.GeometryUtils.minVertex(v0, v1);
214
+ line.holes.forEach(function (holeID) {
215
+ var hole = state.getIn(['scene', 'layers', layerID, 'holes', holeID]);
216
+ var holeOffset = hole.offset;
217
+ if (minVertex.x === x1 && minVertex.y === y1) {
218
+ splitPointOffset = 1 - splitPointOffset;
219
+ holeOffset = 1 - hole.offset;
220
+ }
221
+ if (holeOffset < splitPointOffset) {
222
+ var offset = holeOffset / splitPointOffset;
223
+ /*
224
+ if (minVertex.x === x1 && minVertex.y === y1) {
225
+ offset = 1 - offset;
226
+ }
227
+ */
228
+ state = _export.Hole.create(state, layerID, hole.type, line0.id, offset, hole.properties).updatedState;
229
+ } else {
230
+ var _offset = (holeOffset - splitPointOffset) / (1 - splitPointOffset);
231
+ /*
232
+ if (minVertex.x === x1 && minVertex.y === y1) {
233
+ offset = 1 - offset;
234
+ }
235
+ */
236
+ state = _export.Hole.create(state, layerID, hole.type, line1.id, _offset, hole.properties).updatedState;
237
+ }
238
+ });
239
+
240
+ //add splitted lines to the original line's group
241
+ var lineGroups = state.getIn(['scene', 'groups']).filter(function (group) {
242
+ var lines = group.getIn(['elements', layerID, 'lines']);
243
+ return lines && lines.contains(lineID);
244
+ });
245
+ lineGroups.forEach(function (group) {
246
+ state = _export.Group.addElement(state, group.id, layerID, 'lines', line0.id).updatedState;
247
+ state = _export.Group.addElement(state, group.id, layerID, 'lines', line1.id).updatedState;
248
+ });
249
+ state = Line.remove(state, layerID, lineID).updatedState;
250
+ return {
251
+ updatedState: state,
252
+ lines: new _immutable.List([line0, line1])
253
+ };
254
+ }
255
+ }, {
256
+ key: "addFromPoints",
257
+ value: function addFromPoints(state, layerID, type, points, properties, holes) {
258
+ var _this = this;
259
+ var lineCreatedDateTime = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new Date().getTime();
260
+ points = new _immutable.List(points).sort(function (_ref, _ref2) {
261
+ var x1 = _ref.x,
262
+ y1 = _ref.y;
263
+ var x2 = _ref2.x,
264
+ y2 = _ref2.y;
265
+ return x1 === x2 ? y1 - y2 : x1 - x2;
266
+ });
267
+ var pointsPair = points.zip(points.skip(1)).filterNot(function (_ref3) {
268
+ var _ref4 = _slicedToArray(_ref3, 2),
269
+ _ref4$ = _ref4[0],
270
+ x1 = _ref4$.x,
271
+ y1 = _ref4$.y,
272
+ _ref4$2 = _ref4[1],
273
+ x2 = _ref4$2.x,
274
+ y2 = _ref4$2.y;
275
+ return x1 === x2 && y1 === y2;
276
+ });
277
+ var lines = [];
278
+ pointsPair.forEach(function (_ref5) {
279
+ var _ref6 = _slicedToArray(_ref5, 2),
280
+ _ref6$ = _ref6[0],
281
+ x1 = _ref6$.x,
282
+ y1 = _ref6$.y,
283
+ _ref6$2 = _ref6[1],
284
+ x2 = _ref6$2.x,
285
+ y2 = _ref6$2.y;
286
+ var _this$create = _this.create(state, layerID, type, x1, y1, x2, y2, properties, lineCreatedDateTime),
287
+ stateL = _this$create.updatedState,
288
+ line = _this$create.line;
289
+ state = stateL;
290
+ var lineLength = _export2.GeometryUtils.pointsDistance(x1, y1, x2, y2);
291
+ var alpha = _export2.GeometryUtils.absAngleBetweenTwoPoints(x1, y1, x2, y2);
292
+ var cosAlpha = _export2.GeometryUtils.cosWithThreshold(Math.abs(alpha), 0.0000001);
293
+ var sinAlpha = _export2.GeometryUtils.sinWithThreshold(Math.abs(alpha), 0.0000001);
294
+ if (holes) {
295
+ holes.forEach(function (holeWithOffsetPoint) {
296
+ var offset = holeWithOffsetPoint.hole.toJS().offset;
297
+ // if (invert) offset = 1 - offset;
298
+ var _holeWithOffsetPoint$ = holeWithOffsetPoint.offsetPosition,
299
+ xp = _holeWithOffsetPoint$.x,
300
+ yp = _holeWithOffsetPoint$.y;
301
+ if (_export2.GeometryUtils.isPointOnLineSegment(x1, y1, x2, y2, xp, yp)) {
302
+ var newOffset = _export2.GeometryUtils.pointPositionOnLineSegment(x1, y1, x2, y2, xp, yp);
303
+ if (newOffset >= 0 && newOffset <= 1) {
304
+ //add the position of hole
305
+ var temp = _export.Hole.create(state, layerID, holeWithOffsetPoint.hole.type, line.id, newOffset, holeWithOffsetPoint.hole.properties, xp, yp);
306
+ state = temp.updatedState;
307
+ var holeX = 0,
308
+ holeY = 0,
309
+ holeID = temp.hole.id;
310
+ if (_export2.GeometryUtils.almostEqual(y1, y2)) {
311
+ if (x1 > x2) {
312
+ holeX = x1 - lineLength * newOffset;
313
+ holeY = y1;
314
+ } else {
315
+ holeX = x1 + lineLength * newOffset;
316
+ holeY = y1;
317
+ }
318
+ } else if (_export2.GeometryUtils.almostEqual(x1, x2)) {
319
+ if (y1 > y2) {
320
+ holeX = x1;
321
+ holeY = y1 - lineLength * newOffset;
322
+ } else {
323
+ holeX = x1;
324
+ holeY = y1 + lineLength * newOffset;
325
+ }
326
+ } else if (x1 > x2) {
327
+ if (y1 > y2) {
328
+ holeX = x1 - lineLength * newOffset * cosAlpha;
329
+ holeY = y1 - lineLength * newOffset * sinAlpha;
330
+ } else if (y1 < y2) {
331
+ holeX = x1 - lineLength * newOffset * cosAlpha;
332
+ holeY = y1 + lineLength * newOffset * sinAlpha;
333
+ }
334
+ } else if (x1 < x2) {
335
+ if (y1 > y2) {
336
+ holeX = x1 + lineLength * newOffset * cosAlpha;
337
+ holeY = y1 - lineLength * newOffset * sinAlpha;
338
+ } else if (y1 < y2) {
339
+ holeX = x1 + lineLength * newOffset * cosAlpha;
340
+ holeY = y1 + lineLength * newOffset * sinAlpha;
341
+ }
342
+ }
343
+ state = state.setIn(['scene', 'layers', layerID, 'holes', holeID, 'x'], holeX);
344
+ state = state.setIn(['scene', 'layers', layerID, 'holes', holeID, 'y'], holeY);
345
+ }
346
+ }
347
+ });
348
+ }
349
+ lines.push(line);
350
+ });
351
+ return {
352
+ updatedState: state,
353
+ lines: new _immutable.List(lines),
354
+ newline: lines[0]
355
+ };
356
+ }
357
+ }, {
358
+ key: "createAvoidingIntersections",
359
+ value: function createAvoidingIntersections(state, layerID, type, x0, y0, x1, y1, oldProperties, oldHoles) {
360
+ var _this2 = this;
361
+ var lineCreatedDateTime = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : new Date().getTime();
362
+ var points = [{
363
+ x: x0,
364
+ y: y0
365
+ }, {
366
+ x: x1,
367
+ y: y1
368
+ }];
369
+ state = state.getIn(['scene', 'layers', layerID, 'lines']).reduce(function (reducedState, line) {
370
+ var _line$vertices$map$to = line.vertices.map(function (vertexID) {
371
+ return reducedState.getIn(['scene', 'layers', layerID, 'vertices']).get(vertexID);
372
+ }).toArray(),
373
+ _line$vertices$map$to2 = _slicedToArray(_line$vertices$map$to, 2),
374
+ v0 = _line$vertices$map$to2[0],
375
+ v1 = _line$vertices$map$to2[1];
376
+ var hasCommonEndpoint = _export2.GeometryUtils.samePoints(v0, points[0]) || _export2.GeometryUtils.samePoints(v0, points[1]) || _export2.GeometryUtils.samePoints(v1, points[0]) || _export2.GeometryUtils.samePoints(v1, points[1]);
377
+ var intersection = _export2.GeometryUtils.twoLineSegmentsIntersection(points[0], points[1], v0, v1);
378
+ if (intersection.type === 'colinear') {
379
+ if (!oldHoles) {
380
+ oldHoles = [];
381
+ }
382
+ var orderedVertices = _export2.GeometryUtils.orderVertices(points);
383
+ reducedState.getIn(['scene', 'layers', layerID, 'lines', line.id, 'holes']).forEach(function (holeID) {
384
+ var hole = reducedState.getIn(['scene', 'layers', layerID, 'holes', holeID]);
385
+ var oldLineLength = _export2.GeometryUtils.pointsDistance(v0.x, v0.y, v1.x, v1.y);
386
+ var offset = _export2.GeometryUtils.samePoints(orderedVertices[1], line.vertices.get(1)) ? 1 - hole.offset : hole.offset;
387
+ var offsetPosition = _export2.GeometryUtils.extendLine(v0.x, v0.y, v1.x, v1.y, oldLineLength * offset);
388
+ oldHoles.push({
389
+ hole: hole,
390
+ offsetPosition: offsetPosition
391
+ });
392
+ });
393
+ reducedState = _this2.remove(reducedState, layerID, line.id).updatedState;
394
+ points.push(v0, v1);
395
+ }
396
+ if (intersection.type === 'intersecting' && !hasCommonEndpoint) {
397
+ reducedState = _this2.split(reducedState, layerID, line.id, intersection.point.x, intersection.point.y).updatedState;
398
+ points.push(intersection.point);
399
+ }
400
+ return reducedState;
401
+ }, state);
402
+ var _Line$addFromPoints = Line.addFromPoints(state, layerID, type, points, oldProperties, oldHoles, lineCreatedDateTime),
403
+ updatedState = _Line$addFromPoints.updatedState,
404
+ lines = _Line$addFromPoints.lines,
405
+ newline = _Line$addFromPoints.newline;
406
+ return {
407
+ updatedState: updatedState,
408
+ lines: lines,
409
+ newline: newline
410
+ };
411
+ }
412
+ }, {
413
+ key: "replaceVertex",
414
+ value: function replaceVertex(state, layerID, lineID, vertexIndex, x, y) {
415
+ var vertexID = state.getIn(['scene', 'layers', layerID, 'lines', lineID, 'vertices', vertexIndex]);
416
+ state = _export.Vertex.remove(state, layerID, vertexID, 'lines', lineID).updatedState;
417
+ var _Vertex$add3 = _export.Vertex.add(state, layerID, x, y, 'lines', lineID),
418
+ stateV = _Vertex$add3.updatedState,
419
+ vertex = _Vertex$add3.vertex;
420
+ state = stateV;
421
+ state = state.setIn(['scene', 'layers', layerID, 'lines', lineID, 'vertices', vertexIndex], vertex.id);
422
+ state = state.setIn(['scene', 'layers', layerID, 'lines', lineID], state.getIn(['scene', 'layers', layerID, 'lines', lineID]));
423
+ return {
424
+ updatedState: state,
425
+ line: state.getIn(['scene', 'layers', layerID, 'lines', lineID]),
426
+ vertex: vertex
427
+ };
428
+ }
429
+ }, {
430
+ key: "selectToolDrawingLine",
431
+ value: function selectToolDrawingLine(state, sceneComponentType) {
432
+ state = state.merge({
433
+ mode: _constants.MODE_WAITING_DRAWING_LINE,
434
+ drawingSupport: new _immutable.Map({
435
+ type: sceneComponentType
436
+ })
437
+ });
438
+ return {
439
+ updatedState: state
440
+ };
441
+ }
442
+ }, {
443
+ key: "beginDrawingLine",
444
+ value: function beginDrawingLine(state, layerID, x, y) {
445
+ // if end drawing by created area
446
+ if (state.mode == _constants.MODE_IDLE) {
447
+ return {
448
+ updatedState: state
449
+ };
450
+ }
451
+ // ///////////////
452
+ var snapElements = _export2.SnapSceneUtils.sceneSnapElements(state.scene, new _immutable.List(), state.snapMask);
453
+ var snap = null;
454
+ if (state.snapMask && !state.snapMask.isEmpty()) {
455
+ snap = _export2.SnapUtils.nearestSnap(snapElements, x, y, state.snapMask);
456
+ if (snap) {
457
+ var _snap$point = snap.point;
458
+ x = _snap$point.x;
459
+ y = _snap$point.y;
460
+ }
461
+ snapElements = snapElements.withMutations(function (snapElements) {
462
+ var a, b, c;
463
+ var _GeometryUtils$horizo = _export2.GeometryUtils.horizontalLine(y);
464
+ a = _GeometryUtils$horizo.a;
465
+ b = _GeometryUtils$horizo.b;
466
+ c = _GeometryUtils$horizo.c;
467
+ _export2.SnapUtils.addLineSnap(snapElements, a, b, c, 10, 3, null);
468
+ var _GeometryUtils$vertic = _export2.GeometryUtils.verticalLine(x);
469
+ a = _GeometryUtils$vertic.a;
470
+ b = _GeometryUtils$vertic.b;
471
+ c = _GeometryUtils$vertic.c;
472
+ _export2.SnapUtils.addLineSnap(snapElements, a, b, c, 10, 3, null);
473
+ var _GeometryUtils$upcros = _export2.GeometryUtils.upcrossLine(x, y);
474
+ a = _GeometryUtils$upcros.a;
475
+ b = _GeometryUtils$upcros.b;
476
+ c = _GeometryUtils$upcros.c;
477
+ _export2.SnapUtils.addLineSnap(snapElements, a, b, c, 10, 3, null);
478
+ var _GeometryUtils$downcr = _export2.GeometryUtils.downcrossLine(x, y);
479
+ a = _GeometryUtils$downcr.a;
480
+ b = _GeometryUtils$downcr.b;
481
+ c = _GeometryUtils$downcr.c;
482
+ _export2.SnapUtils.addLineSnap(snapElements, a, b, c, 10, 3, null);
483
+ });
484
+ }
485
+ var drawingSupport = state.get('drawingSupport').set('layerID', layerID);
486
+ state = _export.Layer.unselectAll(state, layerID).updatedState;
487
+ var _Line$create3 = Line.create(state, layerID, drawingSupport.get('type'), x, y, x, y),
488
+ stateL = _Line$create3.updatedState,
489
+ line = _Line$create3.line;
490
+ state = Line.select(stateL, layerID, line.id).updatedState;
491
+ state = state.merge({
492
+ mode: _constants.MODE_DRAWING_LINE,
493
+ snapElements: snapElements,
494
+ activeSnapElement: snap ? snap.snap : null,
495
+ drawingSupport: drawingSupport
496
+ });
497
+ return {
498
+ updatedState: state
499
+ };
500
+ }
501
+ }, {
502
+ key: "updateDrawingLine",
503
+ value: function updateDrawingLine(state, x, y, relatedLines) {
504
+ var snap = null;
505
+ if (state.snapMask && !state.snapMask.isEmpty()) {
506
+ snap = _export2.SnapUtils.nearestSnap(state.snapElements, x, y, state.snapMask);
507
+ if (snap) {
508
+ var _snap$point2 = snap.point;
509
+ x = _snap$point2.x;
510
+ y = _snap$point2.y;
511
+ }
512
+ }
513
+ var layerID = state.getIn(['drawingSupport', 'layerID']);
514
+ var lineID = state.getIn(['scene', 'layers', layerID, 'selected', 'lines']).first();
515
+
516
+ // let relatedLines = [];
517
+ var vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
518
+ var drawingLine = state.getIn(['scene', 'layers', layerID, 'lines', lineID]).toJS();
519
+ var moveFlag = true;
520
+ var tx = vertices[drawingLine.vertices[1]].x;
521
+ var ty = vertices[drawingLine.vertices[1]].y;
522
+ if (!(0, _helper.isEmpty)(relatedLines)) {
523
+ vertices[drawingLine.vertices[1]].x = x;
524
+ vertices[drawingLine.vertices[1]].y = y;
525
+ }
526
+ var absAngle, lineAngle;
527
+
528
+ // get the angle of two lines and check the angle
529
+ if (drawingLine.vertices[0] !== drawingLine.vertices[1]) {
530
+ relatedLines.forEach(function (line) {
531
+ // get the points of two lines(drawing line and related line)
532
+ if (!(0, _helper.isEmpty)(line)) {
533
+ // the angle between two lines(line, drawingLine)
534
+ lineAngle = _export2.GeometryUtils.angleBetweenTwoLines(line, drawingLine, vertices);
535
+ // check whether the angle is less than or bigger than specific value.
536
+ absAngle = Math.abs(lineAngle);
537
+ if (absAngle < _constants.MIN_ANGLE_DISALLOW_DRAW_WALL || absAngle > 360 - _constants.MIN_ANGLE_DISALLOW_DRAW_WALL) {
538
+ moveFlag = false;
539
+ } else moveFlag = true;
540
+ }
541
+ });
542
+ }
543
+
544
+ // if the angle is bigger or less than specific value, the wall mustn't be drawn at new position
545
+ if (moveFlag) {
546
+ tx = x;
547
+ ty = y;
548
+ } else {
549
+ var rest = _constants.MIN_ANGLE_DISALLOW_DRAW_WALL - absAngle;
550
+ // the origin point of rotation(snapping)
551
+ var ox = vertices[drawingLine.vertices[0]].x;
552
+ var oy = vertices[drawingLine.vertices[0]].y;
553
+ // determine the direction of rotation.
554
+ rest = lineAngle > 0 ? -rest : rest;
555
+ // rotate the current point to last point around the first point of drawing line.
556
+ var res = _export2.GeometryUtils.rotatePointAroundPoint(x, y, ox, oy, rest);
557
+ tx = res.x;
558
+ ty = res.y;
559
+ }
560
+ // angle snapping as a value of UNIT_ANGLE
561
+ if (moveFlag && !(0, _helper.isEmpty)(absAngle) && absAngle % _constants.UNIT_ANGLE !== 0) {
562
+ var result = _export2.GeometryUtils.snapAngleByUnit(lineAngle, vertices, drawingLine, tx, ty, drawingLine.vertices[1]);
563
+ tx = result.x;
564
+ ty = result.y;
565
+ }
566
+ var _Line$replaceVertex = Line.replaceVertex(state, layerID, lineID, 1, tx, ty),
567
+ stateLV = _Line$replaceVertex.updatedState,
568
+ vertex = _Line$replaceVertex.vertex;
569
+ state = stateLV;
570
+ state = this.select(state, layerID, lineID).updatedState;
571
+ state = state.merge({
572
+ activeSnapElement: snap ? snap.snap : null
573
+ });
574
+ state = state.setIn(['scene', 'setLineAttributes'], false);
575
+ return {
576
+ updatedState: state
577
+ };
578
+ }
579
+ }, {
580
+ key: "stopDrawingLine",
581
+ value: function stopDrawingLine(state) {
582
+ console.log('line aCtion');
583
+ }
584
+
585
+ // Recalculate the hole position
586
+ }, {
587
+ key: "getHolePosition",
588
+ value: function getHolePosition(layer, lineID, nv0, nv1) {
589
+ var _layer$lines$get;
590
+ var holeOffset = [];
591
+ (_layer$lines$get = layer.lines.get(lineID)) === null || _layer$lines$get === void 0 || _layer$lines$get.holes.forEach(function (holeID) {
592
+ var lineLength = _export2.GeometryUtils.pointsDistance(nv0.x, nv0.y, nv1.x, nv1.y);
593
+ var minV = _export2.GeometryUtils.minVertex(nv0, nv1);
594
+ var maxV = _export2.GeometryUtils.maxVertex(nv0, nv1);
595
+ var alpha = Math.atan2(maxV.y - minV.y, maxV.x - minV.x);
596
+ var hole = layer.holes.get(holeID);
597
+ var pointOnLine = lineLength * hole.offset;
598
+ // Calculate the hole position
599
+ var offsetPosition = {
600
+ x: pointOnLine * Math.cos(alpha) + minV.x,
601
+ y: pointOnLine * Math.sin(alpha) + minV.y
602
+ };
603
+ holeOffset.push({
604
+ hole: hole,
605
+ offsetPosition: offsetPosition
606
+ });
607
+ });
608
+ return holeOffset;
609
+ }
610
+
611
+ /**
612
+ *
613
+ * @param {state} state
614
+ * @param {selectedLineInfo} selectedLineInfo
615
+ * @param {layerID} layerID
616
+ * @returns selectedLineInfo {
617
+ * mergelines: [line1, line2,...], // lines that will be merged
618
+ * points: [stpoint, edpoint] // start and end point of new line that merged.
619
+ * }
620
+ */
621
+ }, {
622
+ key: "mergeAllLines",
623
+ value: function mergeAllLines(state, selectedLineInfo, layerID) {
624
+ var _this3 = this;
625
+ var layer = state.getIn(['scene', 'layers', layerID]);
626
+ var allVertices = state.getIn(['scene', 'layers', layerID, 'vertices']);
627
+ selectedLineInfo.points.forEach(function (vertex, index) {
628
+ vertex = vertex.toJS();
629
+ if (vertex.lines.length === 2) {
630
+ var relatedLineID = vertex.lines.filter(function (lineID) {
631
+ return !selectedLineInfo.mergelines.some(function (mgline) {
632
+ return mgline.id === lineID;
633
+ });
634
+ });
635
+ if (!(0, _helper.isEmpty)(relatedLineID)) {
636
+ var relatedLine = layer.lines.get(relatedLineID[0]);
637
+ var intersectionPoint = vertex;
638
+ var startPoint, endPoint;
639
+ if (relatedLine.vertices.get(0) === intersectionPoint.id) {
640
+ endPoint = allVertices.get(relatedLine.vertices.get(1));
641
+ startPoint = selectedLineInfo.points[1 - index];
642
+ } else {
643
+ startPoint = allVertices.get(relatedLine.vertices.get(0));
644
+ endPoint = selectedLineInfo.points[1 - index];
645
+ }
646
+ var tline1 = {
647
+ vertices: [startPoint.id, intersectionPoint.id]
648
+ };
649
+ var tline2 = {
650
+ vertices: [intersectionPoint.id, endPoint.id]
651
+ };
652
+ var angle = Math.abs(_export2.GeometryUtils.angleBetweenTwoLines(tline1, tline2, allVertices.toJS()));
653
+ if (Math.abs(angle - 180) <= _constants.EPSILON) {
654
+ selectedLineInfo.mergelines.push(relatedLine);
655
+ selectedLineInfo.points[0] = startPoint;
656
+ selectedLineInfo.points[1] = endPoint;
657
+ return _this3.mergeAllLines(state, selectedLineInfo, layerID);
658
+ }
659
+ }
660
+ }
661
+ });
662
+ return selectedLineInfo;
663
+ }
664
+ }, {
665
+ key: "mergeLines",
666
+ value: function mergeLines(state) {
667
+ var layerID = state.getIn(['scene', 'selectedLayer']);
668
+ var allVertices = state.getIn(['scene', 'layers', layerID, 'vertices']);
669
+ var lineID = state.getIn(['scene', 'layers', layerID, 'selected', 'lines']).first();
670
+ var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
671
+ if ((0, _helper.isEmpty)(line)) {
672
+ return {
673
+ updatedState: state
674
+ };
675
+ }
676
+ var tmpStPoint = allVertices.get(line.vertices.get(0));
677
+ var tmpEdPoint = allVertices.get(line.vertices.get(1));
678
+ var selectedLineInfo = {
679
+ mergelines: [line],
680
+ points: [tmpStPoint, tmpEdPoint]
681
+ };
682
+ var mergeInfo = this.mergeAllLines(state, selectedLineInfo, layerID);
683
+ return mergeInfo;
684
+ }
685
+
686
+ /**
687
+ *
688
+ * @param {mode} mode
689
+ * @param {state} state
690
+ * @returns updatedState
691
+ */
692
+ }, {
693
+ key: "createLines",
694
+ value: function createLines(state, actionType, mergeInfo) {
695
+ var _this4 = this,
696
+ _ret;
697
+ var layerID = state.getIn(['scene', 'selectedLayer']);
698
+ var layer = state.getIn(['scene', 'layers', layerID]);
699
+ var lineGroups = [];
700
+ var holesWithOffsetPosition = [];
701
+ var lineID = layer.getIn(['selected', 'lines']).first(); // lines : [id]
702
+ var line = layer.getIn(['lines', lineID]);
703
+ if ((0, _helper.isEmpty)(line)) {
704
+ return {
705
+ updatedState: state
706
+ };
707
+ }
708
+ mergeInfo.mergelines.forEach(function (line) {
709
+ if ([_constants.END_DRAGGING_LINE, _constants.END_DRAGGING_VERTEX].includes(actionType)) {
710
+ var tmpGroups = state //get groups membership if present
711
+ .getIn(['scene', 'groups']).filter(function (group) {
712
+ var lines = group.getIn(['elements', layerID, 'lines']);
713
+ return lines && lines.contains(line.id);
714
+ });
715
+ tmpGroups.forEach(function (group) {
716
+ return lineGroups.push(group);
717
+ });
718
+ }
719
+ var nv0 = layer.getIn(['vertices', line.vertices.get(0)]);
720
+ var nv1 = layer.getIn(['vertices', line.vertices.get(1)]);
721
+ var tmpholeposition = _this4.getHolePosition(layer, line.id, nv0, nv1);
722
+ tmpholeposition.forEach(function (holeInfo) {
723
+ return holesWithOffsetPosition.push(holeInfo);
724
+ });
725
+ state = Line.remove(state, layerID, line.id).updatedState;
726
+ });
727
+ var ret;
728
+ if (!_export2.GeometryUtils.samePoints(mergeInfo.points[0], mergeInfo.points[1])) {
729
+ ret = Line.createAvoidingIntersections(state, layerID, line.type, mergeInfo.points[0].x, mergeInfo.points[0].y, mergeInfo.points[1].x, mergeInfo.points[1].y, line.properties, holesWithOffsetPosition, line.createdDateTime);
730
+ state = ret.updatedState;
731
+ }
732
+ if ([_constants.END_DRAGGING_LINE, _constants.END_DRAGGING_VERTEX].includes(actionType)) {
733
+ //re-add to old line's groups if present
734
+ ret.lines.forEach(function (addedLine) {
735
+ lineGroups.forEach(function (oldLineGroup) {
736
+ state = _export.Group.addElement(state, oldLineGroup.id, layerID, 'lines', addedLine.id).updatedState;
737
+ });
738
+ });
739
+ }
740
+ state = _export.Layer.removeZeroLengthLines(state, layerID).updatedState;
741
+ if (!(0, _helper.isEmpty)((_ret = ret) === null || _ret === void 0 ? void 0 : _ret.newline)) {
742
+ state = this.select(state, layerID, ret.newline.get('id')).updatedState;
743
+ }
744
+ return {
745
+ updatedState: state
746
+ };
747
+ }
748
+ }, {
749
+ key: "updateArea",
750
+ value: function updateArea(state) {
751
+ var layerID = state.getIn(['scene', 'selectedLayer']);
752
+ var layer = state.getIn(['scene', 'layers', layerID]);
753
+ var lineID = layer.getIn(['selected', 'lines']).first(); // lines : [id]
754
+ var line = layer.getIn(['lines', lineID]);
755
+ var drawingInfo = {};
756
+ if (!(0, _helper.isEmpty)(line)) {
757
+ drawingInfo.drawingLine = line;
758
+ }
759
+ state = _export.Layer.detectAndUpdateAreas(state, layerID, drawingInfo).updatedState;
760
+ return {
761
+ updatedState: state
762
+ };
763
+ }
764
+ }, {
765
+ key: "applyWallChanges",
766
+ value: function applyWallChanges(state, actionType) {
767
+ var mergeInfo = this.mergeLines(state); // merge lines
768
+ state = this.createLines(state, actionType, mergeInfo).updatedState; // creating lines
769
+ state = this.updateArea(state).updatedState; // detecting areas
770
+ return {
771
+ updatedState: state
772
+ };
773
+ }
774
+ }, {
775
+ key: "prepareApplyWallChanges",
776
+ value: function prepareApplyWallChanges(v0, v1, state) {
777
+ var oldMode = state.getIn(['mode']);
778
+ var layerID = state.getIn(['scene', 'selectedLayer']);
779
+ var lineID = state.getIn(['scene', 'layers', layerID, 'selected', 'lines']).first();
780
+ var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
781
+ if ((0, _helper.isEmpty)(line)) {
782
+ return {
783
+ updatedState: state
784
+ };
785
+ }
786
+ if (!(0, _helper.isEmpty)(v0)) {
787
+ state = state.setIn(['scene', 'layers', layerID, 'vertices', line.vertices.get(0), 'x'], v0.x);
788
+ state = state.setIn(['scene', 'layers', layerID, 'vertices', line.vertices.get(0), 'y'], v0.y);
789
+ }
790
+ if (!(0, _helper.isEmpty)(v1)) {
791
+ state = state.setIn(['scene', 'layers', layerID, 'vertices', line.vertices.get(1), 'x'], v1.x);
792
+ state = state.setIn(['scene', 'layers', layerID, 'vertices', line.vertices.get(1), 'y'], v1.y);
793
+ }
794
+ state = this.select(state, layerID, lineID).updatedState;
795
+ state = state.setIn(['mode'], oldMode);
796
+ return {
797
+ updatedState: state
798
+ };
799
+ }
800
+ }, {
801
+ key: "endDrawingLine",
802
+ value: function endDrawingLine(state, x, y) {
803
+ if (state.snapMask && !state.snapMask.isEmpty()) {
804
+ var snap = _export2.SnapUtils.nearestSnap(state.snapElements, x, y, state.snapMask);
805
+ if (snap) {
806
+ var _snap$point3 = snap.point;
807
+ x = _snap$point3.x;
808
+ y = _snap$point3.y;
809
+ }
810
+ }
811
+ var layerID = state.getIn(['drawingSupport', 'layerID']);
812
+ var lineID = state.getIn(['scene', 'layers', layerID, 'selected', 'lines']).first();
813
+ var drawingLine = state.getIn(['scene', 'layers', layerID, 'lines', lineID]).toJS();
814
+ if (drawingLine.vertices[0] === drawingLine.vertices[1]) {
815
+ state = Line.remove(state, layerID, lineID).updatedState;
816
+ state = state.merge({
817
+ mode: _constants.MODE_IDLE,
818
+ snapElements: new _immutable.List(),
819
+ activeSnapElement: null
820
+ });
821
+ return {
822
+ updatedState: state
823
+ };
824
+ }
825
+ state = this.prepareApplyWallChanges({}, {
826
+ x: x,
827
+ y: y
828
+ }, state).updatedState;
829
+ state = this.applyWallChanges(state, _constants.END_DRAWING_LINE).updatedState;
830
+ state = state.merge({
831
+ mode: _constants.MODE_WAITING_DRAWING_LINE,
832
+ snapElements: new _immutable.List(),
833
+ activeSnapElement: null
834
+ });
835
+ return {
836
+ updatedState: state
837
+ };
838
+ }
839
+ }, {
840
+ key: "beginDraggingLine",
841
+ value: function beginDraggingLine(state, layerID, lineID, x, y) {
842
+ var snapElements = _export2.SnapSceneUtils.sceneSnapElements(state.scene, new _immutable.List(), state.snapMask);
843
+ var layer = state.scene.layers.get(layerID);
844
+ var line = layer.lines.get(lineID);
845
+ var vertex0 = layer.vertices.get(line.vertices.get(0));
846
+ var vertex1 = layer.vertices.get(line.vertices.get(1));
847
+ state = state.merge({
848
+ mode: _constants.MODE_DRAGGING_LINE,
849
+ snapElements: snapElements,
850
+ draggingSupport: (0, _immutable.Map)({
851
+ layerID: layerID,
852
+ lineID: lineID,
853
+ startPointX: x,
854
+ startPointY: y,
855
+ startVertex0X: vertex0.x,
856
+ startVertex0Y: vertex0.y,
857
+ startVertex1X: vertex1.x,
858
+ startVertex1Y: vertex1.y
859
+ })
860
+ });
861
+ return {
862
+ updatedState: state
863
+ };
864
+ }
865
+ }, {
866
+ key: "getNewDraggedPoints",
867
+ value: function getNewDraggedPoints(newPoints, allVertices, draggingLine, relatedLines) {
868
+ if (!newPoints || !allVertices || !draggingLine || !Array.isArray(relatedLines)) {
869
+ return newPoints; // Invalid input, just return
870
+ }
871
+ var draggingVertices = Array.isArray(draggingLine.vertices) ? draggingLine.vertices : [];
872
+ var mvFlag = [];
873
+ relatedLines.forEach(function (relLine) {
874
+ if (!relLine || !Array.isArray(relLine.vertices)) return;
875
+ relLine.vertices.forEach(function (vertexId, i) {
876
+ var _newPoints$newVertex, _newPoints$newVertex2, _newPoints$newVertex3, _newPoints$newVertex4, _vData$x, _vData$y, _newPoints$newVertex5, _newPoints$newVertex6, _newPoints$newVertex7, _newPoints$newVertex8;
877
+ if (draggingVertices.includes(vertexId)) return; // skip shared vertices
878
+ var vData = allVertices[vertexId];
879
+ if (!vData) return; // guard: vertex missing
880
+
881
+ var center = i === 0 ? new Three.Vector2((_newPoints$newVertex = newPoints === null || newPoints === void 0 ? void 0 : newPoints.newVertex0X) !== null && _newPoints$newVertex !== void 0 ? _newPoints$newVertex : 0, (_newPoints$newVertex2 = newPoints === null || newPoints === void 0 ? void 0 : newPoints.newVertex0Y) !== null && _newPoints$newVertex2 !== void 0 ? _newPoints$newVertex2 : 0) : new Three.Vector2((_newPoints$newVertex3 = newPoints === null || newPoints === void 0 ? void 0 : newPoints.newVertex1X) !== null && _newPoints$newVertex3 !== void 0 ? _newPoints$newVertex3 : 0, (_newPoints$newVertex4 = newPoints === null || newPoints === void 0 ? void 0 : newPoints.newVertex1Y) !== null && _newPoints$newVertex4 !== void 0 ? _newPoints$newVertex4 : 0);
882
+ var pos1 = new Three.Vector2((_vData$x = vData.x) !== null && _vData$x !== void 0 ? _vData$x : 0, (_vData$y = vData.y) !== null && _vData$y !== void 0 ? _vData$y : 0);
883
+ var pos2 = i === 0 ? new Three.Vector2((_newPoints$newVertex5 = newPoints === null || newPoints === void 0 ? void 0 : newPoints.newVertex1X) !== null && _newPoints$newVertex5 !== void 0 ? _newPoints$newVertex5 : 0, (_newPoints$newVertex6 = newPoints === null || newPoints === void 0 ? void 0 : newPoints.newVertex1Y) !== null && _newPoints$newVertex6 !== void 0 ? _newPoints$newVertex6 : 0) : new Three.Vector2((_newPoints$newVertex7 = newPoints === null || newPoints === void 0 ? void 0 : newPoints.newVertex0X) !== null && _newPoints$newVertex7 !== void 0 ? _newPoints$newVertex7 : 0, (_newPoints$newVertex8 = newPoints === null || newPoints === void 0 ? void 0 : newPoints.newVertex0Y) !== null && _newPoints$newVertex8 !== void 0 ? _newPoints$newVertex8 : 0);
884
+ var cen = center.clone();
885
+ var vec1 = pos1.clone().sub(cen).normalize();
886
+ var vec2 = pos2.clone().sub(cen).normalize();
887
+ var angle = Math.floor(vec1.angle() * 180 / Math.PI - vec2.angle() * 180 / Math.PI + 0.5);
888
+ if (Math.abs(angle) < _constants.MIN_ANGLE_DISALLOW_DRAW_WALL || Math.abs(angle) > 360 - _constants.MIN_ANGLE_DISALLOW_DRAW_WALL) {
889
+ mvFlag.push(false);
890
+ } else {
891
+ mvFlag.push(true);
892
+ }
893
+ });
894
+ });
895
+
896
+ // If any flag is false, revert newPoints to original dragging line positions
897
+ if (mvFlag.includes(false) && draggingVertices.length >= 2) {
898
+ var v0 = allVertices[draggingVertices[0]];
899
+ var v1 = allVertices[draggingVertices[1]];
900
+ if (v0 && v1) {
901
+ newPoints.newVertex0X = v0.x;
902
+ newPoints.newVertex0Y = v0.y;
903
+ newPoints.newVertex1X = v1.x;
904
+ newPoints.newVertex1Y = v1.y;
905
+ }
906
+ }
907
+ return newPoints;
908
+ }
909
+ }, {
910
+ key: "updateDraggingLine",
911
+ value: function updateDraggingLine(state, x, y, relatedLines) {
912
+ var draggingSupport = state.draggingSupport;
913
+ var snapElements = state.snapElements;
914
+ var layerID = draggingSupport.get('layerID');
915
+ var lineID = draggingSupport.get('lineID');
916
+ var diffX = x - draggingSupport.get('startPointX');
917
+ var diffY = y - draggingSupport.get('startPointY');
918
+ var newVertex0X = draggingSupport.get('startVertex0X') + diffX;
919
+ var newVertex0Y = draggingSupport.get('startVertex0Y') + diffY;
920
+ var newVertex1X = draggingSupport.get('startVertex1X') + diffX;
921
+ var newVertex1Y = draggingSupport.get('startVertex1Y') + diffY;
922
+ var drawingLine = state.getIn(['scene', 'layers', layerID, 'lines', lineID]).toJS();
923
+ var allVertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
924
+ var activeSnapElement = null;
925
+ var curSnap0 = null,
926
+ curSnap1 = null;
927
+ if (state.snapMask && !state.snapMask.isEmpty()) {
928
+ curSnap0 = _export2.SnapUtils.nearestSnap(snapElements, newVertex0X, newVertex0Y, state.snapMask);
929
+ curSnap1 = _export2.SnapUtils.nearestSnap(snapElements, newVertex1X, newVertex1Y, state.snapMask);
930
+ }
931
+ var deltaX = 0,
932
+ deltaY = 0;
933
+ if (curSnap0 && curSnap1) {
934
+ if (curSnap0.point.distance < curSnap1.point.distance) {
935
+ deltaX = curSnap0.point.x - newVertex0X;
936
+ deltaY = curSnap0.point.y - newVertex0Y;
937
+ activeSnapElement = curSnap0.snap;
938
+ } else {
939
+ deltaX = curSnap1.point.x - newVertex1X;
940
+ deltaY = curSnap1.point.y - newVertex1Y;
941
+ activeSnapElement = curSnap1.snap;
942
+ }
943
+ } else {
944
+ if (curSnap0) {
945
+ deltaX = curSnap0.point.x - newVertex0X;
946
+ deltaY = curSnap0.point.y - newVertex0Y;
947
+ activeSnapElement = curSnap0.snap;
948
+ }
949
+ if (curSnap1) {
950
+ deltaX = curSnap1.point.x - newVertex1X;
951
+ deltaY = curSnap1.point.y - newVertex1Y;
952
+ activeSnapElement = curSnap1.snap;
953
+ }
954
+ }
955
+ newVertex0X += deltaX;
956
+ newVertex0Y += deltaY;
957
+ newVertex1X += deltaX;
958
+ newVertex1Y += deltaY;
959
+ var newPoints = {
960
+ newVertex0X: newVertex0X,
961
+ newVertex0Y: newVertex0Y,
962
+ newVertex1X: newVertex1X,
963
+ newVertex1Y: newVertex1Y
964
+ };
965
+ var newResult = this.getNewDraggedPoints(newPoints, allVertices, drawingLine, relatedLines);
966
+ newVertex0X = newResult.newVertex0X;
967
+ newVertex0Y = newResult.newVertex0Y;
968
+ newVertex1X = newResult.newVertex1X;
969
+ newVertex1Y = newResult.newVertex1Y;
970
+ state = state.merge({
971
+ activeSnapElement: activeSnapElement,
972
+ scene: state.scene.updateIn(['layers', layerID], function (layer) {
973
+ return layer.withMutations(function (layer) {
974
+ var lineVertices = layer.getIn(['lines', lineID, 'vertices']);
975
+ layer.updateIn(['vertices', lineVertices.get(0)], function (vertex) {
976
+ return vertex.merge({
977
+ x: newVertex0X,
978
+ y: newVertex0Y
979
+ });
980
+ });
981
+ layer.updateIn(['vertices', lineVertices.get(1)], function (vertex) {
982
+ return vertex.merge({
983
+ x: newVertex1X,
984
+ y: newVertex1Y
985
+ });
986
+ });
987
+ return layer;
988
+ });
989
+ })
990
+ });
991
+ return {
992
+ updatedState: state
993
+ };
994
+ }
995
+ }, {
996
+ key: "endDraggingLine",
997
+ value: function endDraggingLine(state, x, y, relatedLines) {
998
+ var _state = state,
999
+ draggingSupport = _state.draggingSupport;
1000
+ var layerID = draggingSupport.get('layerID');
1001
+ var layer = state.scene.layers.get(layerID);
1002
+ var lineID = draggingSupport.get('lineID');
1003
+ var line = layer.lines.get(lineID);
1004
+ var drawedLine = line.toJS();
1005
+ var allVertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
1006
+ var diffX = x - draggingSupport.get('startPointX');
1007
+ var diffY = y - draggingSupport.get('startPointY');
1008
+ var newVertex0X = draggingSupport.get('startVertex0X') + diffX;
1009
+ var newVertex0Y = draggingSupport.get('startVertex0Y') + diffY;
1010
+ var newVertex1X = draggingSupport.get('startVertex1X') + diffX;
1011
+ var newVertex1Y = draggingSupport.get('startVertex1Y') + diffY;
1012
+ if (state.snapMask && !state.snapMask.isEmpty()) {
1013
+ var curSnap0 = _export2.SnapUtils.nearestSnap(state.snapElements, newVertex0X, newVertex0Y, state.snapMask);
1014
+ var curSnap1 = _export2.SnapUtils.nearestSnap(state.snapElements, newVertex1X, newVertex1Y, state.snapMask);
1015
+ var deltaX = 0,
1016
+ deltaY = 0;
1017
+ if (curSnap0 && curSnap1) {
1018
+ if (curSnap0.point.distance < curSnap1.point.distance) {
1019
+ deltaX = curSnap0.point.x - newVertex0X;
1020
+ deltaY = curSnap0.point.y - newVertex0Y;
1021
+ } else {
1022
+ deltaX = curSnap1.point.x - newVertex1X;
1023
+ deltaY = curSnap1.point.y - newVertex1Y;
1024
+ }
1025
+ } else {
1026
+ if (curSnap0) {
1027
+ deltaX = curSnap0.point.x - newVertex0X;
1028
+ deltaY = curSnap0.point.y - newVertex0Y;
1029
+ }
1030
+ if (curSnap1) {
1031
+ deltaX = curSnap1.point.x - newVertex1X;
1032
+ deltaY = curSnap1.point.y - newVertex1Y;
1033
+ }
1034
+ }
1035
+ newVertex0X += deltaX;
1036
+ newVertex0Y += deltaY;
1037
+ newVertex1X += deltaX;
1038
+ newVertex1Y += deltaY;
1039
+ }
1040
+ var newPoints = {
1041
+ newVertex0X: newVertex0X,
1042
+ newVertex0Y: newVertex0Y,
1043
+ newVertex1X: newVertex1X,
1044
+ newVertex1Y: newVertex1Y
1045
+ };
1046
+ var newResult = this.getNewDraggedPoints(newPoints, allVertices, drawedLine, relatedLines);
1047
+ newVertex0X = newResult.newVertex0X;
1048
+ newVertex0Y = newResult.newVertex0Y;
1049
+ newVertex1X = newResult.newVertex1X;
1050
+ newVertex1Y = newResult.newVertex1Y;
1051
+ state = _export.Layer.mergeEqualsVertices(state, layerID, line.vertices.get(0)).updatedState;
1052
+ state = _export.Layer.mergeEqualsVertices(state, layerID, line.vertices.get(1)).updatedState;
1053
+ if (_export2.GeometryUtils.samePoints({
1054
+ newVertex0X: newVertex0X,
1055
+ newVertex0Y: newVertex0Y
1056
+ }, {
1057
+ newVertex1X: newVertex1X,
1058
+ newVertex1Y: newVertex1Y
1059
+ })) {
1060
+ state = Line.remove(state, layerID, lineID).updatedState;
1061
+ } else {
1062
+ state = this.prepareApplyWallChanges({
1063
+ x: newVertex0X,
1064
+ y: newVertex0Y
1065
+ }, {
1066
+ x: newVertex1X,
1067
+ y: newVertex1Y
1068
+ }, state).updatedState;
1069
+ state = this.applyWallChanges(state, _constants.END_DRAGGING_LINE).updatedState;
1070
+ }
1071
+ state = state.merge({
1072
+ mode: _constants.MODE_IDLE,
1073
+ draggingSupport: null,
1074
+ activeSnapElement: null,
1075
+ snapElements: new _immutable.List()
1076
+ });
1077
+ return {
1078
+ updatedState: state
1079
+ };
1080
+ }
1081
+ }, {
1082
+ key: "setProperties",
1083
+ value: function setProperties(state, layerID, lineID, properties) {
1084
+ state = state.mergeIn(['scene', 'layers', layerID, 'lines', lineID, 'properties'], properties);
1085
+ return {
1086
+ updatedState: state
1087
+ };
1088
+ }
1089
+ }, {
1090
+ key: "setJsProperties",
1091
+ value: function setJsProperties(state, layerID, lineID, properties) {
1092
+ return this.setProperties(state, layerID, lineID, (0, _immutable.fromJS)(properties));
1093
+ }
1094
+ }, {
1095
+ key: "updateProperties",
1096
+ value: function updateProperties(state, layerID, lineID, properties) {
1097
+ properties.forEach(function (v, k) {
1098
+ if (state.hasIn(['scene', 'layers', layerID, 'lines', lineID, 'properties', k])) state = state.mergeIn(['scene', 'layers', layerID, 'lines', lineID, 'properties', k], v);
1099
+ });
1100
+ return {
1101
+ updatedState: state
1102
+ };
1103
+ }
1104
+ }, {
1105
+ key: "updateJsProperties",
1106
+ value: function updateJsProperties(state, layerID, lineID, properties) {
1107
+ return this.updateProperties(state, layerID, lineID, (0, _immutable.fromJS)(properties));
1108
+ }
1109
+ }, {
1110
+ key: "setAttributes",
1111
+ value: function setAttributes(state, layerID, lineID, lineAttributes) {
1112
+ var lAttr = lineAttributes.toJS();
1113
+ var vertexOne = lAttr.vertexOne,
1114
+ vertexTwo = lAttr.vertexTwo,
1115
+ vertexThree = lAttr.vertexThree,
1116
+ vertexFour = lAttr.vertexFour,
1117
+ lineLength = lAttr.lineLength,
1118
+ lineToExtend = lAttr.lineToExtend;
1119
+ delete lAttr['vertexOne'];
1120
+ delete lAttr['vertexTwo'];
1121
+ delete lAttr['vertexThree'];
1122
+ delete lAttr['vertexFour'];
1123
+ delete lAttr['lineToExtend'];
1124
+ delete lAttr['lineLength'];
1125
+ var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
1126
+ state = state.mergeIn(['scene', 'layers', layerID, 'lines', lineID], (0, _immutable.fromJS)(lAttr)).mergeIn(['scene', 'layers', layerID, 'vertices', vertexOne.id], {
1127
+ x: vertexOne.x,
1128
+ y: vertexOne.y
1129
+ }).mergeIn(['scene', 'layers', layerID, 'vertices', vertexTwo.id], {
1130
+ x: vertexTwo.x,
1131
+ y: vertexTwo.y
1132
+ }).mergeIn(['scene', 'layers', layerID, 'lines', lineID, 'misc'], new _immutable.Map({
1133
+ _unitLength: lineLength._unit
1134
+ })).mergeIn(['scene', 'layers', layerID, 'lines', lineID, 'focus'], true);
1135
+ if (lineToExtend) {
1136
+ state = state.mergeIn(['scene', 'layers', layerID, 'lines', lineToExtend.id], (0, _immutable.fromJS)(lAttr)).mergeIn(['scene', 'layers', layerID, 'lines', lineToExtend.id, 'misc'], new _immutable.Map({
1137
+ _unitLength: lineLength._unit
1138
+ }));
1139
+ }
1140
+ if (vertexThree) {
1141
+ state = state.mergeIn(['scene', 'layers', layerID, 'vertices', vertexThree.id], {
1142
+ x: vertexThree.x,
1143
+ y: vertexThree.y
1144
+ });
1145
+ }
1146
+ if (vertexFour) {
1147
+ state = state.mergeIn(['scene', 'layers', layerID, 'vertices', vertexFour.id], {
1148
+ x: vertexFour.x,
1149
+ y: vertexFour.y
1150
+ });
1151
+ }
1152
+ state = _export.Layer.mergeEqualsVertices(state, layerID, vertexOne.id).updatedState;
1153
+ if (vertexOne.x != vertexTwo.x && vertexOne.y != vertexTwo.y) {
1154
+ state = _export.Layer.mergeEqualsVertices(state, layerID, vertexTwo.id).updatedState;
1155
+ }
1156
+ state = this.select(state, layerID, lineID).updatedState;
1157
+ state = this.applyWallChanges(state, _constants.END_DRAWING_LINE).updatedState;
1158
+ state = state.merge({
1159
+ sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
1160
+ });
1161
+ if (state.mode.endsWith('_LINE')) {
1162
+ state = state.setIn(['scene', 'setLineAttributes'], true);
1163
+ state = this.beginDrawingLine(state, layerID, vertexTwo.x, vertexTwo.y).updatedState;
1164
+ }
1165
+ return {
1166
+ updatedState: state
1167
+ };
1168
+ }
1169
+ }, {
1170
+ key: "setVerticesCoords",
1171
+ value: function setVerticesCoords(state, layerID, lineID, x1, y1, x2, y2) {
1172
+ var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
1173
+ state = _export.Vertex.setAttributes(state, layerID, line.vertices.get(0), new _immutable.Map({
1174
+ x: x1,
1175
+ y: y1
1176
+ })).updatedState;
1177
+ state = _export.Vertex.setAttributes(state, layerID, line.vertices.get(1), new _immutable.Map({
1178
+ x: x2,
1179
+ y: y2
1180
+ })).updatedState;
1181
+ return {
1182
+ updatedState: state
1183
+ };
1184
+ }
1185
+ }]);
1186
+ }();