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

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 (359) hide show
  1. package/lib/KitchenConfiguratorApp.js +3 -0
  2. package/package.json +1 -1
  3. package/es/@history.js +0 -2
  4. package/es/AppContext.js +0 -3
  5. package/es/KitchenConfigurator.js +0 -645
  6. package/es/KitchenConfiguratorApp.js +0 -478
  7. package/es/actions/area-actions.js +0 -14
  8. package/es/actions/export.js +0 -23
  9. package/es/actions/groups-actions.js +0 -89
  10. package/es/actions/holes-actions.js +0 -119
  11. package/es/actions/items-actions.js +0 -313
  12. package/es/actions/lines-actions.js +0 -81
  13. package/es/actions/project-actions.js +0 -281
  14. package/es/actions/scene-actions.js +0 -33
  15. package/es/actions/vertices-actions.js +0 -27
  16. package/es/actions/viewer2d-actions.js +0 -58
  17. package/es/actions/viewer3d-actions.js +0 -23
  18. package/es/catalog/areas/area/planner-element.js +0 -40
  19. package/es/catalog/areas/area/textures/ceramic-tile.jpg +0 -0
  20. package/es/catalog/areas/area/textures/grass.jpg +0 -0
  21. package/es/catalog/areas/area/textures/parquet.jpg +0 -0
  22. package/es/catalog/areas/area/textures/strand-porcelain.jpg +0 -0
  23. package/es/catalog/areas/area/textures/tile1.jpg +0 -0
  24. package/es/catalog/catalog.js +0 -277
  25. package/es/catalog/envMap/nx.hdr +0 -0
  26. package/es/catalog/envMap/ny.hdr +0 -0
  27. package/es/catalog/envMap/nz.hdr +0 -0
  28. package/es/catalog/envMap/px.hdr +0 -0
  29. package/es/catalog/envMap/py.hdr +0 -0
  30. package/es/catalog/envMap/pz.hdr +0 -0
  31. package/es/catalog/factories/area-factory-3d.js +0 -181
  32. package/es/catalog/factories/area-factory.js +0 -81
  33. package/es/catalog/factories/export.js +0 -7
  34. package/es/catalog/factories/wall-factory-3d.js +0 -202
  35. package/es/catalog/factories/wall-factory.js +0 -268
  36. package/es/catalog/holes/door-closet/planner-element.js +0 -222
  37. package/es/catalog/holes/door-double/door_double.png +0 -0
  38. package/es/catalog/holes/door-double/planner-element.js +0 -315
  39. package/es/catalog/holes/door-exterior/planner-element.js +0 -215
  40. package/es/catalog/holes/door-interior/planner-element.js +0 -227
  41. package/es/catalog/holes/door-panic/panicDoor.png +0 -0
  42. package/es/catalog/holes/door-panic/planner-element.js +0 -503
  43. package/es/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
  44. package/es/catalog/holes/door-panic-double/planner-element.js +0 -463
  45. package/es/catalog/holes/door-sliding/planner-element.js +0 -225
  46. package/es/catalog/holes/doorway-framed/planner-element.js +0 -145
  47. package/es/catalog/holes/doorway-frameless/planner-element.js +0 -104
  48. package/es/catalog/holes/export.js +0 -13
  49. package/es/catalog/holes/gate/gate.jpg +0 -0
  50. package/es/catalog/holes/window-clear/planner-element.js +0 -166
  51. package/es/catalog/holes/window-clear/texture.png +0 -0
  52. package/es/catalog/holes/window-cross/planner-element.js +0 -165
  53. package/es/catalog/holes/window-cross/texture.png +0 -0
  54. package/es/catalog/holes/window-double-hung/planner-element.js +0 -303
  55. package/es/catalog/holes/window-double-hung/texture.png +0 -0
  56. package/es/catalog/holes/window-vertical/planner-element.js +0 -276
  57. package/es/catalog/holes/window-vertical/texture.png +0 -0
  58. package/es/catalog/lines/wall/planner-element.js +0 -70
  59. package/es/catalog/lines/wall/textures/bricks-normal.jpg +0 -0
  60. package/es/catalog/lines/wall/textures/bricks-normal2.jpg +0 -0
  61. package/es/catalog/lines/wall/textures/bricks.jpg +0 -0
  62. package/es/catalog/lines/wall/textures/bricks2.jpg +0 -0
  63. package/es/catalog/lines/wall/textures/bricks3.jpg +0 -0
  64. package/es/catalog/lines/wall/textures/morden-normal.jpg +0 -0
  65. package/es/catalog/lines/wall/textures/morden.jpg +0 -0
  66. package/es/catalog/lines/wall/textures/painted-normal.jpg +0 -0
  67. package/es/catalog/lines/wall/textures/painted.jpg +0 -0
  68. package/es/catalog/lines/wall/textures/plaster-normal.jpg +0 -0
  69. package/es/catalog/lines/wall/textures/plaster.jpg +0 -0
  70. package/es/catalog/lines/wall/wall.png +0 -0
  71. package/es/catalog/molding/molding-dcm/planner-element.js +0 -28
  72. package/es/catalog/molding/molding-dcm/texture.png +0 -0
  73. package/es/catalog/molding/molding-fbm/planner-element.js +0 -28
  74. package/es/catalog/molding/molding-fbm/texture.png +0 -0
  75. package/es/catalog/molding/molding-lrm/planner-element.js +0 -28
  76. package/es/catalog/molding/molding-lrm/texture.png +0 -0
  77. package/es/catalog/properties/export.js +0 -21
  78. package/es/catalog/properties/property-checkbox.js +0 -116
  79. package/es/catalog/properties/property-color.js +0 -39
  80. package/es/catalog/properties/property-enum.js +0 -97
  81. package/es/catalog/properties/property-hidden.js +0 -19
  82. package/es/catalog/properties/property-lenght-measure.js +0 -101
  83. package/es/catalog/properties/property-length-measure.js +0 -134
  84. package/es/catalog/properties/property-length-measure_hole.js +0 -101
  85. package/es/catalog/properties/property-number.js +0 -48
  86. package/es/catalog/properties/property-read-only.js +0 -26
  87. package/es/catalog/properties/property-string.js +0 -48
  88. package/es/catalog/properties/property-toggle.js +0 -39
  89. package/es/catalog/properties/shared-property-style.js +0 -14
  90. package/es/catalog/utils/FuseUtils.js +0 -82
  91. package/es/catalog/utils/exporter.js +0 -148
  92. package/es/catalog/utils/geom-utils.js +0 -189
  93. package/es/catalog/utils/item-loader.js +0 -1521
  94. package/es/catalog/utils/load-obj.js +0 -91
  95. package/es/catalog/utils/mtl-loader.js +0 -358
  96. package/es/catalog/utils/obj-loader.js +0 -477
  97. package/es/class/FuseUtils.js +0 -82
  98. package/es/class/area.js +0 -145
  99. package/es/class/export.js +0 -24
  100. package/es/class/group.js +0 -440
  101. package/es/class/guide.js +0 -62
  102. package/es/class/hole.js +0 -929
  103. package/es/class/item.js +0 -1883
  104. package/es/class/layer.js +0 -667
  105. package/es/class/line.js +0 -1180
  106. package/es/class/project.js +0 -793
  107. package/es/class/vertex.js +0 -202
  108. package/es/components/content.js +0 -107
  109. package/es/components/disclaimer/disclaimer.js +0 -97
  110. package/es/components/export.js +0 -9
  111. package/es/components/style/button.js +0 -113
  112. package/es/components/style/cancel-button.js +0 -22
  113. package/es/components/style/content-container.js +0 -33
  114. package/es/components/style/content-title.js +0 -29
  115. package/es/components/style/delete-button.js +0 -25
  116. package/es/components/style/export.js +0 -31
  117. package/es/components/style/form-block.js +0 -24
  118. package/es/components/style/form-color-input.js +0 -27
  119. package/es/components/style/form-label.js +0 -26
  120. package/es/components/style/form-number-input.js +0 -213
  121. package/es/components/style/form-number-input_2.js +0 -206
  122. package/es/components/style/form-select.js +0 -68
  123. package/es/components/style/form-slider.js +0 -61
  124. package/es/components/style/form-submit-button.js +0 -26
  125. package/es/components/style/form-text-input.js +0 -95
  126. package/es/components/viewer2d/area.js +0 -81
  127. package/es/components/viewer2d/export.js +0 -31
  128. package/es/components/viewer2d/grids/grid-horizontal-streak.js +0 -37
  129. package/es/components/viewer2d/grids/grid-streak.js +0 -37
  130. package/es/components/viewer2d/grids/grid-vertical-streak.js +0 -37
  131. package/es/components/viewer2d/grids/grids.js +0 -35
  132. package/es/components/viewer2d/group.js +0 -53
  133. package/es/components/viewer2d/item.js +0 -513
  134. package/es/components/viewer2d/layer.js +0 -164
  135. package/es/components/viewer2d/line.js +0 -882
  136. package/es/components/viewer2d/ruler.js +0 -100
  137. package/es/components/viewer2d/rulerDist.js +0 -146
  138. package/es/components/viewer2d/rulerX.js +0 -151
  139. package/es/components/viewer2d/rulerY.js +0 -153
  140. package/es/components/viewer2d/scene.js +0 -140
  141. package/es/components/viewer2d/snap.js +0 -74
  142. package/es/components/viewer2d/state.js +0 -78
  143. package/es/components/viewer2d/utils.js +0 -198
  144. package/es/components/viewer2d/vertex.js +0 -65
  145. package/es/components/viewer2d/viewer2d.js +0 -1398
  146. package/es/components/viewer3d/camera-controls-module/camera-controls.module.js +0 -2592
  147. package/es/components/viewer3d/dcm.js +0 -401
  148. package/es/components/viewer3d/fbm.js +0 -414
  149. package/es/components/viewer3d/front3D.js +0 -66
  150. package/es/components/viewer3d/grid-creator.js +0 -25
  151. package/es/components/viewer3d/grids/grid-horizontal-streak.js +0 -36
  152. package/es/components/viewer3d/grids/grid-streak.js +0 -27
  153. package/es/components/viewer3d/grids/grid-vertical-streak.js +0 -36
  154. package/es/components/viewer3d/libs/first-person-controls.js +0 -67
  155. package/es/components/viewer3d/libs/helvetiker_regular.typeface.js +0 -1281
  156. package/es/components/viewer3d/libs/mtl-loader.js +0 -357
  157. package/es/components/viewer3d/libs/obj-loader.js +0 -462
  158. package/es/components/viewer3d/libs/orbit-controls.js +0 -699
  159. package/es/components/viewer3d/libs/pointer-lock-controls.js +0 -46
  160. package/es/components/viewer3d/lrm.js +0 -305
  161. package/es/components/viewer3d/model.js +0 -708
  162. package/es/components/viewer3d/pointer-lock-navigation.js +0 -115
  163. package/es/components/viewer3d/ruler-utils/itemRect.js +0 -61
  164. package/es/components/viewer3d/ruler-utils/layer3D.js +0 -495
  165. package/es/components/viewer3d/ruler-utils/ruler3D.js +0 -227
  166. package/es/components/viewer3d/ruler-utils/scene3D.js +0 -60
  167. package/es/components/viewer3d/ruler-utils/state3D.js +0 -18
  168. package/es/components/viewer3d/scene-creator.js +0 -3608
  169. package/es/components/viewer3d/three-memory-cleaner.js +0 -51
  170. package/es/components/viewer3d/viewer3d-first-person.js +0 -315
  171. package/es/components/viewer3d/viewer3d.js +0 -2527
  172. package/es/constants.js +0 -636
  173. package/es/index.js +0 -16
  174. package/es/models.js +0 -510
  175. package/es/plugins/SVGLoader.js +0 -1412
  176. package/es/plugins/autosave.js +0 -33
  177. package/es/plugins/console-debugger.js +0 -37
  178. package/es/plugins/export.js +0 -9
  179. package/es/plugins/keyboard.js +0 -101
  180. package/es/reducers/areas-reducer.js +0 -12
  181. package/es/reducers/export.js +0 -25
  182. package/es/reducers/groups-reducer.js +0 -38
  183. package/es/reducers/holes-reducer.js +0 -62
  184. package/es/reducers/items-reducer.js +0 -140
  185. package/es/reducers/lines-reducer.js +0 -45
  186. package/es/reducers/project-reducer.js +0 -129
  187. package/es/reducers/reducer.js +0 -19
  188. package/es/reducers/scene-reducer.js +0 -28
  189. package/es/reducers/user-reducer.js +0 -40
  190. package/es/reducers/vertices-reducer.js +0 -19
  191. package/es/reducers/viewer2d-reducer.js +0 -75
  192. package/es/reducers/viewer3d-reducer.js +0 -56
  193. package/es/shared-style.js +0 -66
  194. package/es/styles/export.js +0 -5
  195. package/es/styles/tabs.css +0 -40
  196. package/es/translator/en.js +0 -104
  197. package/es/translator/it.js +0 -79
  198. package/es/translator/ru.js +0 -79
  199. package/es/translator/translator.js +0 -84
  200. package/es/utils/browser.js +0 -33
  201. package/es/utils/email-validator.js +0 -4
  202. package/es/utils/export.js +0 -25
  203. package/es/utils/geometry.js +0 -2420
  204. package/es/utils/get-edges-of-subgraphs.js +0 -27
  205. package/es/utils/graph-cycles.js +0 -237
  206. package/es/utils/graph-inner-cycles.js +0 -46
  207. package/es/utils/graph.js +0 -150
  208. package/es/utils/helper.js +0 -268
  209. package/es/utils/history.js +0 -29
  210. package/es/utils/id-broker.js +0 -19
  211. package/es/utils/logger.js +0 -8
  212. package/es/utils/math.js +0 -50
  213. package/es/utils/molding.js +0 -871
  214. package/es/utils/name-generator.js +0 -18
  215. package/es/utils/objects-utils.js +0 -50
  216. package/es/utils/phone-validator.js +0 -4
  217. package/es/utils/process-black-list.js +0 -18
  218. package/es/utils/react-if.js +0 -18
  219. package/es/utils/snap-scene.js +0 -99
  220. package/es/utils/snap.js +0 -237
  221. package/es/utils/summarizeCart.js +0 -24
  222. package/es/utils/threeCSG.es6.js +0 -498
  223. package/es/version.js +0 -2
  224. package/lib/catalog/properties/property-string.js +0 -55
  225. package/lib/catalog/properties/property-toggle.js +0 -46
  226. package/lib/catalog/properties/shared-property-style.js +0 -20
  227. package/lib/catalog/utils/FuseUtils.js +0 -88
  228. package/lib/catalog/utils/exporter.js +0 -155
  229. package/lib/catalog/utils/geom-utils.js +0 -205
  230. package/lib/catalog/utils/item-loader.js +0 -1533
  231. package/lib/catalog/utils/load-obj.js +0 -99
  232. package/lib/catalog/utils/mtl-loader.js +0 -363
  233. package/lib/catalog/utils/obj-loader.js +0 -482
  234. package/lib/class/FuseUtils.js +0 -88
  235. package/lib/class/area.js +0 -150
  236. package/lib/class/export.js +0 -96
  237. package/lib/class/group.js +0 -445
  238. package/lib/class/guide.js +0 -67
  239. package/lib/class/hole.js +0 -934
  240. package/lib/class/item.js +0 -1889
  241. package/lib/class/layer.js +0 -672
  242. package/lib/class/line.js +0 -1186
  243. package/lib/class/project.js +0 -799
  244. package/lib/class/vertex.js +0 -207
  245. package/lib/components/content.js +0 -116
  246. package/lib/components/disclaimer/disclaimer.js +0 -105
  247. package/lib/components/export.js +0 -33
  248. package/lib/components/style/button.js +0 -120
  249. package/lib/components/style/cancel-button.js +0 -29
  250. package/lib/components/style/content-container.js +0 -40
  251. package/lib/components/style/content-title.js +0 -37
  252. package/lib/components/style/delete-button.js +0 -34
  253. package/lib/components/style/export.js +0 -121
  254. package/lib/components/style/form-block.js +0 -31
  255. package/lib/components/style/form-color-input.js +0 -34
  256. package/lib/components/style/form-label.js +0 -33
  257. package/lib/components/style/form-number-input.js +0 -220
  258. package/lib/components/style/form-number-input_2.js +0 -213
  259. package/lib/components/style/form-select.js +0 -75
  260. package/lib/components/style/form-slider.js +0 -68
  261. package/lib/components/style/form-submit-button.js +0 -35
  262. package/lib/components/style/form-text-input.js +0 -101
  263. package/lib/components/viewer2d/area.js +0 -88
  264. package/lib/components/viewer2d/export.js +0 -121
  265. package/lib/components/viewer2d/grids/grid-horizontal-streak.js +0 -44
  266. package/lib/components/viewer2d/grids/grid-streak.js +0 -44
  267. package/lib/components/viewer2d/grids/grid-vertical-streak.js +0 -44
  268. package/lib/components/viewer2d/grids/grids.js +0 -44
  269. package/lib/components/viewer2d/group.js +0 -62
  270. package/lib/components/viewer2d/item.js +0 -521
  271. package/lib/components/viewer2d/layer.js +0 -171
  272. package/lib/components/viewer2d/line.js +0 -892
  273. package/lib/components/viewer2d/ruler.js +0 -107
  274. package/lib/components/viewer2d/rulerDist.js +0 -153
  275. package/lib/components/viewer2d/rulerX.js +0 -158
  276. package/lib/components/viewer2d/rulerY.js +0 -160
  277. package/lib/components/viewer2d/scene.js +0 -147
  278. package/lib/components/viewer2d/snap.js +0 -83
  279. package/lib/components/viewer2d/state.js +0 -87
  280. package/lib/components/viewer2d/utils.js +0 -210
  281. package/lib/components/viewer2d/vertex.js +0 -74
  282. package/lib/components/viewer2d/viewer2d.js +0 -1405
  283. package/lib/components/viewer3d/camera-controls-module/camera-controls.module.js +0 -2597
  284. package/lib/components/viewer3d/dcm.js +0 -407
  285. package/lib/components/viewer3d/fbm.js +0 -420
  286. package/lib/components/viewer3d/front3D.js +0 -75
  287. package/lib/components/viewer3d/grid-creator.js +0 -34
  288. package/lib/components/viewer3d/grids/grid-horizontal-streak.js +0 -44
  289. package/lib/components/viewer3d/grids/grid-streak.js +0 -35
  290. package/lib/components/viewer3d/grids/grid-vertical-streak.js +0 -44
  291. package/lib/components/viewer3d/libs/first-person-controls.js +0 -74
  292. package/lib/components/viewer3d/libs/helvetiker_regular.typeface.js +0 -1287
  293. package/lib/components/viewer3d/libs/mtl-loader.js +0 -363
  294. package/lib/components/viewer3d/libs/obj-loader.js +0 -468
  295. package/lib/components/viewer3d/libs/orbit-controls.js +0 -705
  296. package/lib/components/viewer3d/libs/pointer-lock-controls.js +0 -52
  297. package/lib/components/viewer3d/lrm.js +0 -311
  298. package/lib/components/viewer3d/model.js +0 -714
  299. package/lib/components/viewer3d/pointer-lock-navigation.js +0 -122
  300. package/lib/components/viewer3d/ruler-utils/itemRect.js +0 -68
  301. package/lib/components/viewer3d/ruler-utils/layer3D.js +0 -502
  302. package/lib/components/viewer3d/ruler-utils/ruler3D.js +0 -234
  303. package/lib/components/viewer3d/ruler-utils/scene3D.js +0 -68
  304. package/lib/components/viewer3d/ruler-utils/state3D.js +0 -25
  305. package/lib/components/viewer3d/scene-creator.js +0 -3642
  306. package/lib/components/viewer3d/three-memory-cleaner.js +0 -60
  307. package/lib/components/viewer3d/viewer3d-first-person.js +0 -320
  308. package/lib/components/viewer3d/viewer3d.js +0 -2532
  309. package/lib/constants.js +0 -645
  310. package/lib/index.js +0 -96
  311. package/lib/models.js +0 -517
  312. package/lib/plugins/SVGLoader.js +0 -1417
  313. package/lib/plugins/autosave.js +0 -39
  314. package/lib/plugins/console-debugger.js +0 -44
  315. package/lib/plugins/export.js +0 -33
  316. package/lib/plugins/keyboard.js +0 -107
  317. package/lib/reducers/areas-reducer.js +0 -18
  318. package/lib/reducers/export.js +0 -97
  319. package/lib/reducers/groups-reducer.js +0 -44
  320. package/lib/reducers/holes-reducer.js +0 -68
  321. package/lib/reducers/items-reducer.js +0 -146
  322. package/lib/reducers/lines-reducer.js +0 -51
  323. package/lib/reducers/project-reducer.js +0 -135
  324. package/lib/reducers/reducer.js +0 -26
  325. package/lib/reducers/scene-reducer.js +0 -34
  326. package/lib/reducers/user-reducer.js +0 -46
  327. package/lib/reducers/vertices-reducer.js +0 -25
  328. package/lib/reducers/viewer2d-reducer.js +0 -82
  329. package/lib/reducers/viewer3d-reducer.js +0 -63
  330. package/lib/shared-style.js +0 -72
  331. package/lib/styles/export.js +0 -13
  332. package/lib/translator/en.js +0 -110
  333. package/lib/translator/it.js +0 -85
  334. package/lib/translator/ru.js +0 -85
  335. package/lib/translator/translator.js +0 -90
  336. package/lib/utils/browser.js +0 -40
  337. package/lib/utils/email-validator.js +0 -10
  338. package/lib/utils/export.js +0 -56
  339. package/lib/utils/geometry.js +0 -2516
  340. package/lib/utils/get-edges-of-subgraphs.js +0 -34
  341. package/lib/utils/graph-cycles.js +0 -240
  342. package/lib/utils/graph-inner-cycles.js +0 -54
  343. package/lib/utils/graph.js +0 -157
  344. package/lib/utils/helper.js +0 -291
  345. package/lib/utils/history.js +0 -36
  346. package/lib/utils/id-broker.js +0 -25
  347. package/lib/utils/logger.js +0 -14
  348. package/lib/utils/math.js +0 -57
  349. package/lib/utils/molding.js +0 -895
  350. package/lib/utils/name-generator.js +0 -23
  351. package/lib/utils/objects-utils.js +0 -60
  352. package/lib/utils/phone-validator.js +0 -10
  353. package/lib/utils/process-black-list.js +0 -24
  354. package/lib/utils/react-if.js +0 -24
  355. package/lib/utils/snap-scene.js +0 -105
  356. package/lib/utils/snap.js +0 -249
  357. package/lib/utils/summarizeCart.js +0 -30
  358. package/lib/utils/threeCSG.es6.js +0 -503
  359. package/lib/version.js +0 -8
package/es/class/line.js DELETED
@@ -1,1180 +0,0 @@
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 };