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