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