kitchen-simulator 5.0.0-test.4 → 5.0.0-test.5

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 (406) hide show
  1. package/package.json +1 -2
  2. package/src/@history.js +0 -3
  3. package/src/AppContext.js +0 -5
  4. package/src/KitchenConfigurator.jsx +0 -1517
  5. package/src/KitchenConfiguratorApp.jsx +0 -443
  6. package/src/actions/area-actions.js +0 -15
  7. package/src/actions/export.js +0 -38
  8. package/src/actions/groups-actions.js +0 -102
  9. package/src/actions/holes-actions.js +0 -152
  10. package/src/actions/items-actions.js +0 -393
  11. package/src/actions/lines-actions.js +0 -103
  12. package/src/actions/project-actions.js +0 -391
  13. package/src/actions/scene-actions.js +0 -44
  14. package/src/actions/user-actions.js +0 -75
  15. package/src/actions/vertices-actions.js +0 -34
  16. package/src/actions/viewer2d-actions.js +0 -79
  17. package/src/actions/viewer3d-actions.js +0 -32
  18. package/src/catalog/areas/area/planner-element.jsx +0 -43
  19. package/src/catalog/areas/area/textures/ceramic-tile.jpg +0 -0
  20. package/src/catalog/areas/area/textures/grass.jpg +0 -0
  21. package/src/catalog/areas/area/textures/parquet.jpg +0 -0
  22. package/src/catalog/areas/area/textures/strand-porcelain.jpg +0 -0
  23. package/src/catalog/areas/area/textures/tile1.jpg +0 -0
  24. package/src/catalog/back.png +0 -0
  25. package/src/catalog/catalog.js +0 -258
  26. package/src/catalog/doors.png +0 -0
  27. package/src/catalog/doorways.png +0 -0
  28. package/src/catalog/envMap/nx.hdr +0 -0
  29. package/src/catalog/envMap/ny.hdr +0 -0
  30. package/src/catalog/envMap/nz.hdr +0 -0
  31. package/src/catalog/envMap/px.hdr +0 -0
  32. package/src/catalog/envMap/py.hdr +0 -0
  33. package/src/catalog/envMap/pz.hdr +0 -0
  34. package/src/catalog/factories/area-factory-3d.js +0 -252
  35. package/src/catalog/factories/area-factory.jsx +0 -102
  36. package/src/catalog/factories/export.js +0 -9
  37. package/src/catalog/factories/wall-factory-3d.js +0 -296
  38. package/src/catalog/factories/wall-factory.jsx +0 -321
  39. package/src/catalog/holes/door-closet/planner-element.jsx +0 -251
  40. package/src/catalog/holes/door-double/door_double.png +0 -0
  41. package/src/catalog/holes/door-double/planner-element.jsx +0 -391
  42. package/src/catalog/holes/door-exterior/planner-element.jsx +0 -245
  43. package/src/catalog/holes/door-interior/planner-element.jsx +0 -256
  44. package/src/catalog/holes/door-panic/panicDoor.png +0 -0
  45. package/src/catalog/holes/door-panic/planner-element.jsx +0 -594
  46. package/src/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
  47. package/src/catalog/holes/door-panic-double/planner-element.jsx +0 -574
  48. package/src/catalog/holes/door-sliding/planner-element.jsx +0 -256
  49. package/src/catalog/holes/doorway-framed/planner-element.jsx +0 -169
  50. package/src/catalog/holes/doorway-frameless/planner-element.jsx +0 -116
  51. package/src/catalog/holes/gate/gate.jpg +0 -0
  52. package/src/catalog/holes/window-clear/planner-element.jsx +0 -181
  53. package/src/catalog/holes/window-clear/texture.png +0 -0
  54. package/src/catalog/holes/window-cross/planner-element.jsx +0 -180
  55. package/src/catalog/holes/window-cross/texture.png +0 -0
  56. package/src/catalog/holes/window-double-hung/planner-element.jsx +0 -366
  57. package/src/catalog/holes/window-double-hung/texture.png +0 -0
  58. package/src/catalog/holes/window-vertical/planner-element.jsx +0 -290
  59. package/src/catalog/holes/window-vertical/texture.png +0 -0
  60. package/src/catalog/lines/wall/planner-element.jsx +0 -73
  61. package/src/catalog/lines/wall/textures/bricks-normal.jpg +0 -0
  62. package/src/catalog/lines/wall/textures/bricks-normal2.jpg +0 -0
  63. package/src/catalog/lines/wall/textures/bricks.jpg +0 -0
  64. package/src/catalog/lines/wall/textures/bricks2.jpg +0 -0
  65. package/src/catalog/lines/wall/textures/bricks3.jpg +0 -0
  66. package/src/catalog/lines/wall/textures/morden-normal.jpg +0 -0
  67. package/src/catalog/lines/wall/textures/morden.jpg +0 -0
  68. package/src/catalog/lines/wall/textures/painted-normal.jpg +0 -0
  69. package/src/catalog/lines/wall/textures/painted.jpg +0 -0
  70. package/src/catalog/lines/wall/textures/plaster-normal.jpg +0 -0
  71. package/src/catalog/lines/wall/textures/plaster.jpg +0 -0
  72. package/src/catalog/lines/wall/wall.png +0 -0
  73. package/src/catalog/molding/molding-dcm/planner-element.jsx +0 -35
  74. package/src/catalog/molding/molding-dcm/texture.png +0 -0
  75. package/src/catalog/molding/molding-fbm/planner-element.jsx +0 -35
  76. package/src/catalog/molding/molding-fbm/texture.png +0 -0
  77. package/src/catalog/molding/molding-lrm/planner-element.jsx +0 -35
  78. package/src/catalog/molding/molding-lrm/texture.png +0 -0
  79. package/src/catalog/properties/export.js +0 -33
  80. package/src/catalog/properties/property-checkbox.jsx +0 -123
  81. package/src/catalog/properties/property-color.jsx +0 -52
  82. package/src/catalog/properties/property-enum.jsx +0 -87
  83. package/src/catalog/properties/property-hidden.jsx +0 -22
  84. package/src/catalog/properties/property-lenght-measure.jsx +0 -113
  85. package/src/catalog/properties/property-length-measure.jsx +0 -129
  86. package/src/catalog/properties/property-length-measure_hole.jsx +0 -110
  87. package/src/catalog/properties/property-number.jsx +0 -63
  88. package/src/catalog/properties/property-read-only.jsx +0 -37
  89. package/src/catalog/properties/property-string.jsx +0 -59
  90. package/src/catalog/properties/property-toggle.jsx +0 -51
  91. package/src/catalog/properties/shared-property-style.js +0 -13
  92. package/src/catalog/utils/FuseUtils.js +0 -61
  93. package/src/catalog/utils/exporter.js +0 -173
  94. package/src/catalog/utils/geom-utils.js +0 -301
  95. package/src/catalog/utils/item-loader.jsx +0 -2122
  96. package/src/catalog/utils/load-obj.js +0 -113
  97. package/src/catalog/utils/mtl-loader.js +0 -462
  98. package/src/catalog/utils/obj-loader.js +0 -544
  99. package/src/catalog/windows.png +0 -0
  100. package/src/class/FuseUtils.js +0 -61
  101. package/src/class/area.js +0 -159
  102. package/src/class/export.js +0 -37
  103. package/src/class/group.js +0 -565
  104. package/src/class/guide.js +0 -44
  105. package/src/class/hole.js +0 -1359
  106. package/src/class/item.js +0 -2050
  107. package/src/class/layer.js +0 -926
  108. package/src/class/line.js +0 -1780
  109. package/src/class/project.js +0 -875
  110. package/src/class/vertex.js +0 -409
  111. package/src/components/atoms/Snackbar/index.jsx +0 -43
  112. package/src/components/atoms/radio-button/index.jsx +0 -20
  113. package/src/components/atoms/radio-button/styles.js +0 -56
  114. package/src/components/button/MainButton.jsx +0 -157
  115. package/src/components/button/ToggleMeasureButton.jsx +0 -65
  116. package/src/components/catalog-view/catalog-breadcrumb.jsx +0 -53
  117. package/src/components/catalog-view/catalog-item.jsx +0 -229
  118. package/src/components/catalog-view/catalog-list.jsx +0 -173
  119. package/src/components/catalog-view/catalog-page-item.jsx +0 -110
  120. package/src/components/catalog-view/catalog-turn-back-page-item.jsx +0 -80
  121. package/src/components/configurator/custom-configurator.jsx +0 -77
  122. package/src/components/configurator/project-configurator.jsx +0 -120
  123. package/src/components/content.jsx +0 -136
  124. package/src/components/export.js +0 -36
  125. package/src/components/firstsetting/button/styles.js +0 -223
  126. package/src/components/firstsetting/export.js +0 -9
  127. package/src/components/firstsetting/firstsetting-content-button.jsx +0 -198
  128. package/src/components/firstsetting/firstsetting-toggle-button.jsx +0 -101
  129. package/src/components/firstsetting/firstsetting.jsx +0 -814
  130. package/src/components/footerbar/button/ControlButton.jsx +0 -43
  131. package/src/components/footerbar/button/DirectionButton.jsx +0 -54
  132. package/src/components/footerbar/button/DirectionPanSpinButton.jsx +0 -36
  133. package/src/components/footerbar/button/ToggleButton.jsx +0 -58
  134. package/src/components/footerbar/button/ToggleConvertButton.jsx +0 -48
  135. package/src/components/footerbar/button/ToggleMeasureButton.jsx +0 -33
  136. package/src/components/footerbar/button/styles.js +0 -217
  137. package/src/components/footerbar/export.js +0 -9
  138. package/src/components/footerbar/footer-content-button.jsx +0 -198
  139. package/src/components/footerbar/footer-toggle-button.jsx +0 -101
  140. package/src/components/footerbar/footerbar.jsx +0 -1103
  141. package/src/components/footerbar/styles.js +0 -263
  142. package/src/components/header/button/MenuButton.jsx +0 -46
  143. package/src/components/header/button/SaveButton.jsx +0 -54
  144. package/src/components/header/button/styles.js +0 -181
  145. package/src/components/header/export.js +0 -5
  146. package/src/components/header/header.jsx +0 -631
  147. package/src/components/header/header.style.css +0 -47
  148. package/src/components/header/styles.js +0 -320
  149. package/src/components/login/Login.js +0 -77
  150. package/src/components/login/LoginForm/index.js +0 -108
  151. package/src/components/login/Register.js +0 -83
  152. package/src/components/login/RegisterForm/index.js +0 -171
  153. package/src/components/login/jwtService.js +0 -201
  154. package/src/components/login/style.css +0 -158
  155. package/src/components/login/style.scss +0 -260
  156. package/src/components/molecules/slider/index.jsx +0 -15
  157. package/src/components/molecules/slider/styles.js +0 -0
  158. package/src/components/molecules/slider/styles.scss +0 -3
  159. package/src/components/myprojects/export.js +0 -5
  160. package/src/components/myprojects/index.jsx +0 -445
  161. package/src/components/myprojects/styles.js +0 -241
  162. package/src/components/sidebar/custom-accordion.jsx +0 -48
  163. package/src/components/sidebar/export.js +0 -15
  164. package/src/components/sidebar/panel-element-editor/attributes-editor/attributes-editor.jsx +0 -73
  165. package/src/components/sidebar/panel-element-editor/attributes-editor/confirm-popup.jsx +0 -101
  166. package/src/components/sidebar/panel-element-editor/attributes-editor/hole-attributes-editor.jsx +0 -149
  167. package/src/components/sidebar/panel-element-editor/attributes-editor/item-attributes-editor.jsx +0 -316
  168. package/src/components/sidebar/panel-element-editor/attributes-editor/line-attributes-editor.jsx +0 -108
  169. package/src/components/sidebar/panel-element-editor/element-editor.jsx +0 -1070
  170. package/src/components/sidebar/panel-element-editor/multi-elements-editor.jsx +0 -0
  171. package/src/components/sidebar/panel-element-editor/panel-element-editor.jsx +0 -104
  172. package/src/components/sidebar/panel-element-editor/panel-multi-elements-editor.jsx +0 -155
  173. package/src/components/sidebar/panel-group-editor.jsx +0 -272
  174. package/src/components/sidebar/panel-groups.jsx +0 -310
  175. package/src/components/sidebar/panel-guides.jsx +0 -192
  176. package/src/components/sidebar/panel-layer-elements.jsx +0 -298
  177. package/src/components/sidebar/panel-layers.jsx +0 -381
  178. package/src/components/sidebar/panel.jsx +0 -71
  179. package/src/components/sidebar/sidebar.jsx +0 -106
  180. package/src/components/sidebar/toolbar-panel.jsx +0 -139
  181. package/src/components/sign/export.js +0 -7
  182. package/src/components/sign/main/index.jsx +0 -523
  183. package/src/components/sign/main/styles.js +0 -163
  184. package/src/components/style/button.jsx +0 -95
  185. package/src/components/style/cancel-button.jsx +0 -20
  186. package/src/components/style/content-container.jsx +0 -29
  187. package/src/components/style/content-title.jsx +0 -20
  188. package/src/components/style/delete-button.jsx +0 -23
  189. package/src/components/style/export.jsx +0 -48
  190. package/src/components/style/form-block.jsx +0 -13
  191. package/src/components/style/form-color-input.jsx +0 -27
  192. package/src/components/style/form-label.jsx +0 -15
  193. package/src/components/style/form-number-input.jsx +0 -196
  194. package/src/components/style/form-number-input_2.jsx +0 -191
  195. package/src/components/style/form-select.jsx +0 -38
  196. package/src/components/style/form-slider.jsx +0 -36
  197. package/src/components/style/form-submit-button.jsx +0 -23
  198. package/src/components/style/form-text-input.jsx +0 -65
  199. package/src/components/toolbar/button/ControlButton.jsx +0 -41
  200. package/src/components/toolbar/button/DirectionButton.jsx +0 -34
  201. package/src/components/toolbar/button/RightButton.jsx +0 -103
  202. package/src/components/toolbar/button/ToggleButton.jsx +0 -41
  203. package/src/components/toolbar/button/index.jsx +0 -55
  204. package/src/components/toolbar/button/styles.js +0 -127
  205. package/src/components/toolbar/components/DoorStyleMenu.jsx +0 -103
  206. package/src/components/toolbar/components/Pricing.jsx +0 -126
  207. package/src/components/toolbar/components/ReviewForQuote.jsx +0 -635
  208. package/src/components/toolbar/export.js +0 -21
  209. package/src/components/toolbar/main/Alert.js +0 -122
  210. package/src/components/toolbar/main/TakePictureModal.jsx +0 -104
  211. package/src/components/toolbar/main/confirm-popup.jsx +0 -99
  212. package/src/components/toolbar/main/index.jsx +0 -5687
  213. package/src/components/toolbar/main/lShaped.json +0 -311
  214. package/src/components/toolbar/main/longNarrow.json +0 -238
  215. package/src/components/toolbar/main/myComponents.js +0 -123
  216. package/src/components/toolbar/main/oRectangle.json +0 -220
  217. package/src/components/toolbar/main/rectangle.json +0 -238
  218. package/src/components/toolbar/main/style.css +0 -107
  219. package/src/components/toolbar/main/styles.js +0 -696
  220. package/src/components/toolbar/plugin-item.jsx +0 -123
  221. package/src/components/toolbar/popup/appliance/appliance-category/index.jsx +0 -73
  222. package/src/components/toolbar/popup/appliance/choose-appliance/index.jsx +0 -102
  223. package/src/components/toolbar/popup/appliance/index.jsx +0 -83
  224. package/src/components/toolbar/popup/autosaveprompt/index.jsx +0 -150
  225. package/src/components/toolbar/popup/autosaveprompt/styles.css +0 -64
  226. package/src/components/toolbar/popup/autosaveprompt/styles.js +0 -40
  227. package/src/components/toolbar/popup/cabinet/cabinet-category/index.jsx +0 -73
  228. package/src/components/toolbar/popup/cabinet/choose-product/index.jsx +0 -119
  229. package/src/components/toolbar/popup/cabinet/index.jsx +0 -85
  230. package/src/components/toolbar/popup/doorStyle/choose-style/index.jsx +0 -63
  231. package/src/components/toolbar/popup/doorStyle/index.jsx +0 -71
  232. package/src/components/toolbar/popup/doorStyle/style-category/index.jsx +0 -139
  233. package/src/components/toolbar/popup/downloadsummary/downloadSummaryContext.js +0 -2
  234. package/src/components/toolbar/popup/downloadsummary/downloadSummaryTemp.jsx +0 -157
  235. package/src/components/toolbar/popup/downloadsummary/index.jsx +0 -643
  236. package/src/components/toolbar/popup/downloadsummary/show2D/show2DView.jsx +0 -51
  237. package/src/components/toolbar/popup/downloadsummary/show2D/viewer2DDownLoad.jsx +0 -175
  238. package/src/components/toolbar/popup/downloadsummary/show3D/show3DView.jsx +0 -283
  239. package/src/components/toolbar/popup/downloadsummary/show3D/viewer3DDownLoad.jsx +0 -2257
  240. package/src/components/toolbar/popup/downloadsummary/showCabinetInfo.js +0 -93
  241. package/src/components/toolbar/popup/downloadsummary/showElevation/showElevationView.jsx +0 -132
  242. package/src/components/toolbar/popup/downloadsummary/showElevation/viewer3DElevationDownload.jsx +0 -2198
  243. package/src/components/toolbar/popup/downloadsummary/showElevation/viewerElevationDownload.jsx +0 -152
  244. package/src/components/toolbar/popup/downloadsummary/showWarranty.jsx +0 -149
  245. package/src/components/toolbar/popup/downloadsummary/styles.css +0 -177
  246. package/src/components/toolbar/popup/downloadsummary/styles.js +0 -453
  247. package/src/components/toolbar/popup/finishingtouch/category/index.jsx +0 -34
  248. package/src/components/toolbar/popup/finishingtouch/index.jsx +0 -58
  249. package/src/components/toolbar/popup/finishingtouch/material-edit.jsx +0 -112
  250. package/src/components/toolbar/popup/finishingtouch/product/index.jsx +0 -116
  251. package/src/components/toolbar/popup/floorplan/choose-floor/confirm-popup.jsx +0 -101
  252. package/src/components/toolbar/popup/floorplan/choose-floor/index.jsx +0 -254
  253. package/src/components/toolbar/popup/floorplan/choose-floor/lShaped.json +0 -311
  254. package/src/components/toolbar/popup/floorplan/choose-floor/longNarrow.json +0 -238
  255. package/src/components/toolbar/popup/floorplan/choose-floor/oRectangle.json +0 -220
  256. package/src/components/toolbar/popup/floorplan/choose-floor/rectangle.json +0 -238
  257. package/src/components/toolbar/popup/floorplan/choose-floor/styles.js +0 -86
  258. package/src/components/toolbar/popup/floorplan/floor-category/index.jsx +0 -109
  259. package/src/components/toolbar/popup/floorplan/index.jsx +0 -60
  260. package/src/components/toolbar/popup/index.jsx +0 -241
  261. package/src/components/toolbar/popup/newproject/index.jsx +0 -59
  262. package/src/components/toolbar/popup/newproject/styles.css +0 -64
  263. package/src/components/toolbar/popup/newproject/styles.js +0 -41
  264. package/src/components/toolbar/popup/product/appliance.jsx +0 -54
  265. package/src/components/toolbar/popup/product/cabinetproduct.jsx +0 -15
  266. package/src/components/toolbar/popup/product/doorstyle.jsx +0 -58
  267. package/src/components/toolbar/popup/product/doorstyleproduct.jsx +0 -47
  268. package/src/components/toolbar/popup/product/floor.jsx +0 -36
  269. package/src/components/toolbar/popup/product/floorproduct.jsx +0 -42
  270. package/src/components/toolbar/popup/product/index.jsx +0 -36
  271. package/src/components/toolbar/popup/product/primary.jsx +0 -77
  272. package/src/components/toolbar/popup/product/productline.jsx +0 -93
  273. package/src/components/toolbar/popup/product/reviewItem.jsx +0 -427
  274. package/src/components/toolbar/popup/product/reviewMolding.jsx +0 -310
  275. package/src/components/toolbar/popup/product/style.css +0 -54
  276. package/src/components/toolbar/popup/product/styles.js +0 -260
  277. package/src/components/toolbar/popup/savedesign/FullPictureForm.jsx +0 -146
  278. package/src/components/toolbar/popup/savedesign/index.jsx +0 -495
  279. package/src/components/toolbar/popup/savedesign/savedesign.style.css +0 -16
  280. package/src/components/toolbar/popup/savedesign/styles.js +0 -151
  281. package/src/components/toolbar/popup/setDoorStyleOption/index.jsx +0 -87
  282. package/src/components/toolbar/popup/styles.js +0 -909
  283. package/src/components/toolbar/popup/submitforquote/AddToCartOptions.jsx +0 -192
  284. package/src/components/toolbar/popup/submitforquote/CustomerRequestsForm.jsx +0 -96
  285. package/src/components/toolbar/popup/submitforquote/SkipDesignerReview.jsx +0 -54
  286. package/src/components/toolbar/popup/submitforquote/StepDots.jsx +0 -25
  287. package/src/components/toolbar/popup/submitforquote/cart-choice.jsx +0 -116
  288. package/src/components/toolbar/popup/submitforquote/doorstyle-menus.js +0 -38
  289. package/src/components/toolbar/popup/submitforquote/index.jsx +0 -698
  290. package/src/components/toolbar/popup/submitforquote/styles.css +0 -105
  291. package/src/components/toolbar/popup/submitforquote/styles.js +0 -294
  292. package/src/components/toolbar/popup/submitprompt/index.jsx +0 -89
  293. package/src/components/toolbar/popup/submitprompt/styles.css +0 -64
  294. package/src/components/toolbar/popup/submitprompt/styles.js +0 -42
  295. package/src/components/toolbar/toolbar-button.jsx +0 -90
  296. package/src/components/toolbar/toolbar-load-button.jsx +0 -36
  297. package/src/components/toolbar/toolbar-save-button.jsx +0 -32
  298. package/src/components/tutorial-view/Modal.jsx +0 -584
  299. package/src/components/tutorial-view/style.css +0 -111
  300. package/src/components/tutorial-view/styles.js +0 -65
  301. package/src/components/viewer2d/area.jsx +0 -98
  302. package/src/components/viewer2d/export.js +0 -48
  303. package/src/components/viewer2d/grids/grid-horizontal-streak.jsx +0 -40
  304. package/src/components/viewer2d/grids/grid-streak.jsx +0 -32
  305. package/src/components/viewer2d/grids/grid-vertical-streak.jsx +0 -41
  306. package/src/components/viewer2d/grids/grids.jsx +0 -30
  307. package/src/components/viewer2d/group.jsx +0 -57
  308. package/src/components/viewer2d/item.jsx +0 -618
  309. package/src/components/viewer2d/layer.jsx +0 -214
  310. package/src/components/viewer2d/line.jsx +0 -1358
  311. package/src/components/viewer2d/ruler.jsx +0 -136
  312. package/src/components/viewer2d/rulerDist.jsx +0 -192
  313. package/src/components/viewer2d/rulerX.jsx +0 -141
  314. package/src/components/viewer2d/rulerY.jsx +0 -138
  315. package/src/components/viewer2d/scene.jsx +0 -94
  316. package/src/components/viewer2d/snap.jsx +0 -118
  317. package/src/components/viewer2d/state.jsx +0 -77
  318. package/src/components/viewer2d/utils.js +0 -195
  319. package/src/components/viewer2d/vertex.jsx +0 -76
  320. package/src/components/viewer2d/viewer2d.jsx +0 -1830
  321. package/src/components/viewer3d/camera-controls-module/camera-controls.module.js +0 -3078
  322. package/src/components/viewer3d/dcm.js +0 -226
  323. package/src/components/viewer3d/fbm.js +0 -383
  324. package/src/components/viewer3d/front3D.jsx +0 -63
  325. package/src/components/viewer3d/grid-creator.js +0 -25
  326. package/src/components/viewer3d/grids/grid-horizontal-streak.js +0 -41
  327. package/src/components/viewer3d/grids/grid-streak.js +0 -34
  328. package/src/components/viewer3d/grids/grid-vertical-streak.js +0 -42
  329. package/src/components/viewer3d/libs/first-person-controls.js +0 -70
  330. package/src/components/viewer3d/libs/helvetiker_regular.typeface.js +0 -1265
  331. package/src/components/viewer3d/libs/mtl-loader.js +0 -462
  332. package/src/components/viewer3d/libs/obj-loader.js +0 -653
  333. package/src/components/viewer3d/libs/orbit-controls.js +0 -945
  334. package/src/components/viewer3d/libs/pointer-lock-controls.js +0 -67
  335. package/src/components/viewer3d/lrm.js +0 -358
  336. package/src/components/viewer3d/model.js +0 -830
  337. package/src/components/viewer3d/pointer-lock-navigation.js +0 -140
  338. package/src/components/viewer3d/ruler-utils/itemRect.jsx +0 -91
  339. package/src/components/viewer3d/ruler-utils/layer3D.jsx +0 -528
  340. package/src/components/viewer3d/ruler-utils/ruler3D.jsx +0 -218
  341. package/src/components/viewer3d/ruler-utils/scene3D.jsx +0 -87
  342. package/src/components/viewer3d/ruler-utils/state3D.jsx +0 -25
  343. package/src/components/viewer3d/scene-creator.js +0 -5172
  344. package/src/components/viewer3d/three-memory-cleaner.js +0 -65
  345. package/src/components/viewer3d/viewer3d-first-person.js +0 -395
  346. package/src/components/viewer3d/viewer3d.js +0 -3376
  347. package/src/components/wizardstep/button/styles.js +0 -677
  348. package/src/components/wizardstep/export.js +0 -5
  349. package/src/components/wizardstep/index.jsx +0 -1372
  350. package/src/components/wizardstep/styles.js +0 -688
  351. package/src/components/wizardstep/wizardstep-content-button.jsx +0 -198
  352. package/src/components/wizardstep/wizardstep-toggle-button.jsx +0 -101
  353. package/src/constants.js +0 -731
  354. package/src/hooks/useCheckCart.js +0 -38
  355. package/src/hooks/useGetPricesBySku.js +0 -59
  356. package/src/hooks/useValidateToken.js +0 -181
  357. package/src/index.js +0 -32
  358. package/src/models.js +0 -541
  359. package/src/plugins/SVGLoader.js +0 -1991
  360. package/src/plugins/autosave.js +0 -39
  361. package/src/plugins/console-debugger.js +0 -36
  362. package/src/plugins/export.js +0 -11
  363. package/src/plugins/keyboard.js +0 -194
  364. package/src/reducers/areas-reducer.js +0 -13
  365. package/src/reducers/export.js +0 -39
  366. package/src/reducers/groups-reducer.js +0 -73
  367. package/src/reducers/holes-reducer.js +0 -125
  368. package/src/reducers/items-reducer.js +0 -286
  369. package/src/reducers/lines-reducer.js +0 -96
  370. package/src/reducers/project-reducer.js +0 -239
  371. package/src/reducers/reducer.js +0 -59
  372. package/src/reducers/scene-reducer.js +0 -41
  373. package/src/reducers/user-reducer.js +0 -30
  374. package/src/reducers/vertices-reducer.js +0 -34
  375. package/src/reducers/viewer2d-reducer.js +0 -81
  376. package/src/reducers/viewer3d-reducer.js +0 -65
  377. package/src/shared-style.js +0 -72
  378. package/src/styles/export.js +0 -7
  379. package/src/styles/tabs.css +0 -40
  380. package/src/translator/en.js +0 -106
  381. package/src/translator/it.js +0 -80
  382. package/src/translator/ru.js +0 -80
  383. package/src/translator/translator.js +0 -81
  384. package/src/utils/browser.js +0 -36
  385. package/src/utils/email-validator.js +0 -5
  386. package/src/utils/export.js +0 -39
  387. package/src/utils/geometry.js +0 -2572
  388. package/src/utils/get-edges-of-subgraphs.js +0 -29
  389. package/src/utils/graph-cycles.js +0 -259
  390. package/src/utils/graph-inner-cycles.js +0 -49
  391. package/src/utils/graph.js +0 -147
  392. package/src/utils/helper.js +0 -431
  393. package/src/utils/history.js +0 -37
  394. package/src/utils/id-broker.js +0 -9
  395. package/src/utils/logger.js +0 -8
  396. package/src/utils/math.js +0 -51
  397. package/src/utils/molding.js +0 -973
  398. package/src/utils/name-generator.js +0 -5
  399. package/src/utils/objects-utils.js +0 -56
  400. package/src/utils/phone-validator.js +0 -4
  401. package/src/utils/process-black-list.js +0 -10
  402. package/src/utils/react-if.jsx +0 -20
  403. package/src/utils/snap-scene.js +0 -102
  404. package/src/utils/snap.js +0 -184
  405. package/src/utils/threeCSG.es6.js +0 -578
  406. package/src/version.js +0 -1
package/src/class/line.js DELETED
@@ -1,1780 +0,0 @@
1
- import { Map, List, fromJS } from 'immutable';
2
- import { Group, Layer, Hole, Vertex } from './export';
3
- import {
4
- IDBroker,
5
- NameGenerator,
6
- GeometryUtils,
7
- history,
8
- SnapUtils,
9
- SnapSceneUtils
10
- } from '../utils/export';
11
- import * as Three from 'three';
12
- import {
13
- MODE_IDLE,
14
- MODE_WAITING_DRAWING_LINE,
15
- MODE_DRAWING_LINE,
16
- MODE_DRAGGING_LINE,
17
- MIN_ANGLE_DISALLOW_DRAW_WALL,
18
- UNIT_ANGLE
19
- } from '../constants';
20
- import { getRelatedLines } from '../../src/utils/geometry';
21
- import { isEmpty } from '../../src/utils/helper';
22
-
23
- let timeGlobal = 0;
24
-
25
- class TimeRecorder {
26
- constructor(name) {
27
- this.name = name;
28
-
29
- if (name === "beginDrawingLine") {
30
- console.log("time__ Start Drawing");
31
- }
32
- }
33
-
34
- start() {
35
- this.first = Date.now();
36
- }
37
-
38
- end() {
39
- this.second = Date.now();
40
- const elapsed = this.second - this.first;
41
- console.log("time__ ", this.name, " : ", elapsed, "ms");
42
-
43
- if (["beginDrawingLine", "updateDrawingLine", "endDrawingLine"].includes(this.name))
44
- timeGlobal += elapsed;
45
-
46
- if (this.name === "endDrawingLine") {
47
- console.log("time__ Drawing Ended. Passed Time : ", timeGlobal, "ms");
48
- timeGlobal = 0;
49
- }
50
- }
51
- }
52
-
53
- class Line {
54
- static create(
55
- state,
56
- layerID,
57
- type,
58
- x0,
59
- y0,
60
- x1,
61
- y1,
62
- properties,
63
- lineCreatedDateTime = new Date().getTime()
64
- ) {
65
- // if end drawing by created area
66
- // if (state.mode == MODE_IDLE) {
67
- // return { updatedState: state };
68
- // }
69
- // ///////////////
70
- let lineID = IDBroker.acquireID();
71
- let { updatedState: stateV0, vertex: v0 } = Vertex.add(
72
- state,
73
- layerID,
74
- x0,
75
- y0,
76
- 'lines',
77
- lineID
78
- );
79
- let { updatedState: stateV1, vertex: v1 } = Vertex.add(
80
- stateV0,
81
- layerID,
82
- x1,
83
- y1,
84
- 'lines',
85
- lineID
86
- );
87
- state = stateV1;
88
-
89
- let line = state.catalog.factoryElement(
90
- type,
91
- {
92
- id: lineID,
93
- name: NameGenerator.generateName(
94
- 'lines',
95
- state.catalog.getIn(['elements', type, 'info', 'title'])
96
- ),
97
- vertices: new List([v0.id, v1.id]),
98
- type
99
- },
100
- properties
101
- );
102
- line = line.set(
103
- 'createdDateTime',
104
- lineCreatedDateTime !== undefined
105
- ? lineCreatedDateTime
106
- : new Date().getTime()
107
- );
108
- state = state.setIn(['scene', 'layers', layerID, 'lines', lineID], line);
109
- // set default texture//
110
- let defaultTexture = {
111
- textureA: 'plaster',
112
- textureB: 'plaster'
113
- };
114
- state = this.setJsProperties(
115
- state,
116
- layerID,
117
- lineID,
118
- defaultTexture
119
- ).updatedState;
120
- // /////////////////////
121
- return { updatedState: state, line };
122
- }
123
-
124
- static select(state, layerID, lineID) {
125
- // Try selecting the layer first
126
- const layerResult = Layer.select(state, layerID);
127
- if (!layerResult || !layerResult.updatedState) {
128
- return { updatedState: state }; // no update if layer not found
129
- }
130
- state = layerResult.updatedState;
131
-
132
- // Try getting the line
133
- const line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
134
- if (!line) {
135
- return { updatedState: state }; // no update if line not found
136
- }
137
-
138
- // Select the line element
139
- const lineSelectResult = Layer.selectElement(
140
- state,
141
- layerID,
142
- 'lines',
143
- lineID
144
- );
145
- if (lineSelectResult?.updatedState) {
146
- state = lineSelectResult.updatedState;
147
- }
148
-
149
- // Select the first vertex (if available)
150
- const firstVertex = line.vertices?.get?.(0);
151
- if (firstVertex !== undefined) {
152
- const v1Result = Layer.selectElement(
153
- state,
154
- layerID,
155
- 'vertices',
156
- firstVertex
157
- );
158
- if (v1Result?.updatedState) {
159
- state = v1Result.updatedState;
160
- }
161
- }
162
-
163
- // Select the second vertex (if available)
164
- const secondVertex = line.vertices?.get?.(1);
165
- if (secondVertex !== undefined) {
166
- const v2Result = Layer.selectElement(
167
- state,
168
- layerID,
169
- 'vertices',
170
- secondVertex
171
- );
172
- if (v2Result?.updatedState) {
173
- state = v2Result.updatedState;
174
- }
175
- }
176
-
177
- return { updatedState: state };
178
- }
179
-
180
- static remove(state, layerID, lineID) {
181
- let line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
182
-
183
- if (line) {
184
- state = this.unselect(state, layerID, lineID).updatedState;
185
- line.holes.forEach(
186
- holeID => (state = Hole.remove(state, layerID, holeID).updatedState)
187
- );
188
- state = Layer.removeElement(state, layerID, 'lines', lineID).updatedState;
189
-
190
- line.vertices.forEach(
191
- vertexID =>
192
- (state = Vertex.remove(
193
- state,
194
- layerID,
195
- vertexID,
196
- 'lines',
197
- lineID
198
- ).updatedState)
199
- );
200
-
201
- state
202
- .getIn(['scene', 'groups'])
203
- .forEach(
204
- group =>
205
- (state = Group.removeElement(
206
- state,
207
- group.id,
208
- layerID,
209
- 'lines',
210
- lineID
211
- ).updatedState)
212
- );
213
- }
214
-
215
- return { updatedState: state };
216
- }
217
-
218
- static setRelatedLine(state, layerID, lineID, intersection) {
219
- let curIntersection = state.getIn([
220
- 'scene',
221
- 'layers',
222
- layerID,
223
- 'lines',
224
- lineID,
225
- 'relatedVertices'
226
- ]);
227
- if (curIntersection == undefined) return { updatedState: state };
228
-
229
- let isEqualIntersection = (a, b) => {
230
- return (
231
- a.index == b.index && a.point.x == b.point.x && a.point.y == b.point.y
232
- );
233
- };
234
- let equal =
235
- curIntersection.size == intersection.length &&
236
- curIntersection.every((curint, index) => {
237
- return isEqualIntersection(curint, intersection[index]);
238
- });
239
- if (!equal)
240
- state = state.mergeIn(
241
- ['scene', 'layers', layerID, 'lines', lineID, 'relatedVertices'],
242
- intersection
243
- );
244
- return { updatedState: state };
245
- }
246
-
247
- static unselect(state, layerID, lineID) {
248
- let line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
249
- if (line) {
250
- state = Layer.unselect(
251
- state,
252
- layerID,
253
- 'vertices',
254
- line.vertices.get(0)
255
- ).updatedState;
256
- state = Layer.unselect(
257
- state,
258
- layerID,
259
- 'vertices',
260
- line.vertices.get(1)
261
- ).updatedState;
262
- state = Layer.unselect(state, layerID, 'lines', lineID).updatedState;
263
- }
264
-
265
- return { updatedState: state };
266
- }
267
-
268
- static split(state, layerID, lineID, x, y) {
269
- let line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
270
- let v0 = state.getIn([
271
- 'scene',
272
- 'layers',
273
- layerID,
274
- 'vertices',
275
- line.vertices.get(0)
276
- ]);
277
- let v1 = state.getIn([
278
- 'scene',
279
- 'layers',
280
- layerID,
281
- 'vertices',
282
- line.vertices.get(1)
283
- ]);
284
- let { x: x0, y: y0 } = v0;
285
- let { x: x1, y: y1 } = v1;
286
-
287
- let { updatedState: stateL1, line: line0 } = Line.create(
288
- state,
289
- layerID,
290
- line.type,
291
- x0,
292
- y0,
293
- x,
294
- y,
295
- line.get('properties'),
296
- line.createdDateTime !== undefined
297
- ? line.createdDateTime - 2
298
- : new Date().getTime()
299
- );
300
- let { updatedState: stateL2, line: line1 } = Line.create(
301
- stateL1,
302
- layerID,
303
- line.type,
304
- x1,
305
- y1,
306
- x,
307
- y,
308
- line.get('properties'),
309
- line.createdDateTime !== undefined
310
- ? line.createdDateTime - 1
311
- : new Date().getTime()
312
- );
313
- state = stateL2;
314
-
315
- let splitPointOffset = GeometryUtils.pointPositionOnLineSegment(
316
- x0,
317
- y0,
318
- x1,
319
- y1,
320
- x,
321
- y
322
- );
323
- let minVertex = GeometryUtils.minVertex(v0, v1);
324
-
325
- line.holes.forEach(holeID => {
326
- let hole = state.getIn(['scene', 'layers', layerID, 'holes', holeID]);
327
-
328
- let holeOffset = hole.offset;
329
- if (minVertex.x === x1 && minVertex.y === y1) {
330
- splitPointOffset = 1 - splitPointOffset;
331
- holeOffset = 1 - hole.offset;
332
- }
333
-
334
- if (holeOffset < splitPointOffset) {
335
- let offset = holeOffset / splitPointOffset;
336
- /*
337
- if (minVertex.x === x1 && minVertex.y === y1) {
338
- offset = 1 - offset;
339
- }
340
- */
341
- state = Hole.create(
342
- state,
343
- layerID,
344
- hole.type,
345
- line0.id,
346
- offset,
347
- hole.properties
348
- ).updatedState;
349
- } else {
350
- let offset = (holeOffset - splitPointOffset) / (1 - splitPointOffset);
351
- /*
352
- if (minVertex.x === x1 && minVertex.y === y1) {
353
- offset = 1 - offset;
354
- }
355
- */
356
- state = Hole.create(
357
- state,
358
- layerID,
359
- hole.type,
360
- line1.id,
361
- offset,
362
- hole.properties
363
- ).updatedState;
364
- }
365
- });
366
-
367
- //add splitted lines to the original line's group
368
- let lineGroups = state.getIn(['scene', 'groups']).filter(group => {
369
- const lines = group.getIn(['elements', layerID, 'lines']);
370
- return lines && lines.contains(lineID);
371
- });
372
-
373
- lineGroups.forEach(group => {
374
- state = Group.addElement(
375
- state,
376
- group.id,
377
- layerID,
378
- 'lines',
379
- line0.id
380
- ).updatedState;
381
- state = Group.addElement(
382
- state,
383
- group.id,
384
- layerID,
385
- 'lines',
386
- line1.id
387
- ).updatedState;
388
- });
389
-
390
- state = Line.remove(state, layerID, lineID).updatedState;
391
-
392
- return { updatedState: state, lines: new List([line0, line1]) };
393
- }
394
-
395
- static addFromPoints(
396
- state,
397
- layerID,
398
- type,
399
- points,
400
- properties,
401
- holes,
402
- lineCreatedDateTime = new Date().getTime()
403
- ) {
404
- points = new List(points);
405
- //.sort(({ x: x1, y: y1 }, { x: x2, y: y2 }) => x1 === x2 ? y1 - y2 : x1 - x2);
406
-
407
- let pointsPair = points
408
- .zip(points.skip(1))
409
- .filterNot(
410
- ([{ x: x1, y: y1 }, { x: x2, y: y2 }]) => x1 === x2 && y1 === y2
411
- );
412
-
413
- let usedObjects = {};
414
- let objectsArray = pointsPair;
415
- pointsPair = objectsArray.filter(element => {
416
- let so = JSON.stringify(element[0]);
417
- let so1 = JSON.stringify(element[1]);
418
- if (!usedObjects[so] && !usedObjects[so1]) {
419
- usedObjects[so] = true;
420
- usedObjects[so1] = true;
421
- return element;
422
- }
423
- });
424
-
425
- let lines = [];
426
- let newLine;
427
-
428
- pointsPair.forEach(([{ x: x1, y: y1 }, { x: x2, y: y2 }]) => {
429
- let { updatedState: stateL, line } = this.create(
430
- state,
431
- layerID,
432
- type,
433
- x1,
434
- y1,
435
- x2,
436
- y2,
437
- properties,
438
- lineCreatedDateTime
439
- );
440
- state = stateL;
441
- let lineLength = GeometryUtils.pointsDistance(x1, y1, x2, y2);
442
- let alpha = GeometryUtils.absAngleBetweenTwoPoints(x1, y1, x2, y2);
443
- let cosAlpha = GeometryUtils.cosWithThreshold(Math.abs(alpha), 0.0000001);
444
- let sinAlpha = GeometryUtils.sinWithThreshold(Math.abs(alpha), 0.0000001);
445
-
446
- if (holes) {
447
- holes.forEach(holeWithOffsetPoint => {
448
- let offset = holeWithOffsetPoint.hole.toJS().offset;
449
- // if (invert) offset = 1 - offset;
450
- let { x: xp, y: yp } = holeWithOffsetPoint.offsetPosition;
451
-
452
- if (GeometryUtils.isPointOnLineSegment(x1, y1, x2, y2, xp, yp)) {
453
- let newOffset = GeometryUtils.pointPositionOnLineSegment(
454
- x1,
455
- y1,
456
- x2,
457
- y2,
458
- xp,
459
- yp
460
- );
461
-
462
- if (newOffset >= 0 && newOffset <= 1) {
463
- //add the position of hole
464
- let temp = Hole.create(
465
- state,
466
- layerID,
467
- holeWithOffsetPoint.hole.type,
468
- line.id,
469
- newOffset,
470
- holeWithOffsetPoint.hole.properties,
471
- xp,
472
- yp
473
- );
474
- state = temp.updatedState;
475
- let holeX = 0,
476
- holeY = 0,
477
- holeID = temp.hole.id;
478
-
479
- if (GeometryUtils.almostEqual(y1, y2)) {
480
- if (x1 > x2) {
481
- holeX = x1 - lineLength * newOffset;
482
- holeY = y1;
483
- } else {
484
- holeX = x1 + lineLength * newOffset;
485
- holeY = y1;
486
- }
487
- } else if (GeometryUtils.almostEqual(x1, x2)) {
488
- if (y1 > y2) {
489
- holeX = x1;
490
- holeY = y1 - lineLength * newOffset;
491
- } else {
492
- holeX = x1;
493
- holeY = y1 + lineLength * newOffset;
494
- }
495
- } else if (x1 > x2) {
496
- if (y1 > y2) {
497
- holeX = x1 - lineLength * newOffset * cosAlpha;
498
- holeY = y1 - lineLength * newOffset * sinAlpha;
499
- } else if (y1 < y2) {
500
- holeX = x1 - lineLength * newOffset * cosAlpha;
501
- holeY = y1 + lineLength * newOffset * sinAlpha;
502
- }
503
- } else if (x1 < x2) {
504
- if (y1 > y2) {
505
- holeX = x1 + lineLength * newOffset * cosAlpha;
506
- holeY = y1 - lineLength * newOffset * sinAlpha;
507
- } else if (y1 < y2) {
508
- holeX = x1 + lineLength * newOffset * cosAlpha;
509
- holeY = y1 + lineLength * newOffset * sinAlpha;
510
- }
511
- }
512
- state = state.setIn(
513
- ['scene', 'layers', layerID, 'holes', holeID, 'x'],
514
- holeX
515
- );
516
- state = state.setIn(
517
- ['scene', 'layers', layerID, 'holes', holeID, 'y'],
518
- holeY
519
- );
520
- }
521
- }
522
- });
523
- }
524
-
525
- lines.push(line);
526
- newLine = line;
527
- });
528
-
529
- return { updatedState: state, lines: new List(lines), newline: newLine };
530
- }
531
-
532
- static createAvoidingIntersections(
533
- state,
534
- layerID,
535
- type,
536
- x0,
537
- y0,
538
- x1,
539
- y1,
540
- oldProperties,
541
- oldHoles,
542
- lineCreatedDateTime = new Date().getTime()
543
- ) {
544
- let points = [
545
- { x: x0, y: y0 },
546
- { x: x1, y: y1 }
547
- ];
548
-
549
- state = state
550
- .getIn(['scene', 'layers', layerID, 'lines'])
551
- .reduce((reducedState, line) => {
552
- let [v0, v1] = line.vertices
553
- .map(vertexID =>
554
- reducedState
555
- .getIn(['scene', 'layers', layerID, 'vertices'])
556
- .get(vertexID)
557
- )
558
- .toArray();
559
-
560
- let hasCommonEndpoint =
561
- GeometryUtils.samePoints(v0, points[0]) ||
562
- GeometryUtils.samePoints(v0, points[1]) ||
563
- GeometryUtils.samePoints(v1, points[0]) ||
564
- GeometryUtils.samePoints(v1, points[1]);
565
-
566
- let intersection = GeometryUtils.twoLineSegmentsIntersection(
567
- points[0],
568
- points[1],
569
- v0,
570
- v1
571
- );
572
-
573
- if (intersection.type === 'colinear' && !hasCommonEndpoint) {
574
- if (!oldHoles) {
575
- oldHoles = [];
576
- }
577
-
578
- let orderedVertices = GeometryUtils.orderVertices(points);
579
-
580
- reducedState
581
- .getIn(['scene', 'layers', layerID, 'lines', line.id, 'holes'])
582
- .forEach(holeID => {
583
- let hole = reducedState.getIn([
584
- 'scene',
585
- 'layers',
586
- layerID,
587
- 'holes',
588
- holeID
589
- ]);
590
- let oldLineLength = GeometryUtils.pointsDistance(
591
- v0.x,
592
- v0.y,
593
- v1.x,
594
- v1.y
595
- );
596
- let offset = GeometryUtils.samePoints(
597
- orderedVertices[1],
598
- line.vertices.get(1)
599
- )
600
- ? 1 - hole.offset
601
- : hole.offset;
602
- let offsetPosition = GeometryUtils.extendLine(
603
- v0.x,
604
- v0.y,
605
- v1.x,
606
- v1.y,
607
- oldLineLength * offset
608
- );
609
-
610
- oldHoles.push({ hole, offsetPosition });
611
- });
612
-
613
- reducedState = this.remove(
614
- reducedState,
615
- layerID,
616
- line.id
617
- ).updatedState;
618
-
619
- points.push(v0, v1);
620
- }
621
-
622
- if (intersection.type === 'intersecting' && !hasCommonEndpoint) {
623
- reducedState = this.split(
624
- reducedState,
625
- layerID,
626
- line.id,
627
- intersection.point.x,
628
- intersection.point.y
629
- ).updatedState;
630
- points.push(intersection.point);
631
- }
632
-
633
- return reducedState;
634
- }, state);
635
-
636
- let { updatedState, lines, newline } = Line.addFromPoints(
637
- state,
638
- layerID,
639
- type,
640
- points,
641
- oldProperties,
642
- oldHoles,
643
- lineCreatedDateTime
644
- );
645
-
646
- return { updatedState, lines, newline };
647
- }
648
-
649
- static replaceVertex(state, layerID, lineID, vertexIndex, x, y) {
650
- let vertexID = state.getIn([
651
- 'scene',
652
- 'layers',
653
- layerID,
654
- 'lines',
655
- lineID,
656
- 'vertices',
657
- vertexIndex
658
- ]);
659
-
660
- state = Vertex.remove(
661
- state,
662
- layerID,
663
- vertexID,
664
- 'lines',
665
- lineID
666
- ).updatedState;
667
- let { updatedState: stateV, vertex } = Vertex.add(
668
- state,
669
- layerID,
670
- x,
671
- y,
672
- 'lines',
673
- lineID
674
- );
675
- state = stateV;
676
-
677
- state = state.setIn(
678
- ['scene', 'layers', layerID, 'lines', lineID, 'vertices', vertexIndex],
679
- vertex.id
680
- );
681
- state = state.setIn(
682
- ['scene', 'layers', layerID, 'lines', lineID],
683
- state.getIn(['scene', 'layers', layerID, 'lines', lineID])
684
- );
685
-
686
- return {
687
- updatedState: state,
688
- line: state.getIn(['scene', 'layers', layerID, 'lines', lineID]),
689
- vertex
690
- };
691
- }
692
-
693
- static selectToolDrawingLine(state, sceneComponentType) {
694
- state = state.merge({
695
- mode: MODE_WAITING_DRAWING_LINE,
696
- drawingSupport: new Map({
697
- type: sceneComponentType
698
- })
699
- });
700
-
701
- return { updatedState: state };
702
- }
703
-
704
- static beginDrawingLine(state, layerID, x, y) {
705
- // if end drawing by created area
706
- if (state.mode == MODE_IDLE) {
707
- return { updatedState: state };
708
- }
709
- // ///////////////
710
- let snapElements = SnapSceneUtils.sceneSnapElements(
711
- state.scene,
712
- new List(),
713
- state.snapMask
714
- );
715
- let snap = null;
716
- if (state.snapMask && !state.snapMask.isEmpty()) {
717
- snap = SnapUtils.nearestSnap(snapElements, x, y, state.snapMask);
718
- if (snap) ({ x, y } = snap.point);
719
-
720
- snapElements = snapElements.withMutations(snapElements => {
721
- let a, b, c;
722
- ({ a, b, c } = GeometryUtils.horizontalLine(y));
723
- SnapUtils.addLineSnap(snapElements, a, b, c, 10, 3, null);
724
- ({ a, b, c } = GeometryUtils.verticalLine(x));
725
- SnapUtils.addLineSnap(snapElements, a, b, c, 10, 3, null);
726
- ({ a, b, c } = GeometryUtils.upcrossLine(x, y));
727
- SnapUtils.addLineSnap(snapElements, a, b, c, 10, 3, null);
728
- ({ a, b, c } = GeometryUtils.downcrossLine(x, y));
729
- SnapUtils.addLineSnap(snapElements, a, b, c, 10, 3, null);
730
- });
731
- }
732
-
733
- let drawingSupport = state.get('drawingSupport').set('layerID', layerID);
734
-
735
- state = Layer.unselectAll(state, layerID).updatedState;
736
-
737
- let { updatedState: stateL, line } = Line.create(
738
- state,
739
- layerID,
740
- drawingSupport.get('type'),
741
- x,
742
- y,
743
- x,
744
- y
745
- );
746
- state = Line.select(stateL, layerID, line.id).updatedState;
747
-
748
- state = state.merge({
749
- mode: MODE_DRAWING_LINE,
750
- snapElements,
751
- activeSnapElement: snap ? snap.snap : null,
752
- drawingSupport
753
- });
754
-
755
- return { updatedState: state };
756
- }
757
-
758
- static updateDrawingLine(state, x, y, relatedLines) {
759
- let snap = null;
760
- if (state.snapMask && !state.snapMask.isEmpty()) {
761
- snap = SnapUtils.nearestSnap(state.snapElements, x, y, state.snapMask);
762
- if (snap) ({ x, y } = snap.point);
763
- }
764
- let layerID = state.getIn(['drawingSupport', 'layerID']);
765
- let lineID = state
766
- .getIn(['scene', 'layers', layerID, 'selected', 'lines'])
767
- .first();
768
-
769
- // let relatedLines = [];
770
- let vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
771
- let drawingLine = state
772
- .getIn(['scene', 'layers', layerID, 'lines', lineID])
773
- .toJS();
774
- let moveFlag = true;
775
- let tx = vertices[drawingLine.vertices[1]].x;
776
- let ty = vertices[drawingLine.vertices[1]].y;
777
-
778
- if (!isEmpty(relatedLines)) {
779
- vertices[drawingLine.vertices[1]].x = x;
780
- vertices[drawingLine.vertices[1]].y = y;
781
- }
782
-
783
- let absAngle, lineAngle;
784
-
785
- // get the angle of two lines and check the angle
786
- if (drawingLine.vertices[0] !== drawingLine.vertices[1]) {
787
- relatedLines.forEach(line => {
788
- // get the points of two lines(drawing line and related line)
789
- if (!isEmpty(line)) {
790
- // the angle between two lines(line, drawingLine)
791
- lineAngle = GeometryUtils.angleBetweenTwoLines(
792
- line,
793
- drawingLine,
794
- vertices
795
- );
796
- // check whether the angle is less than or bigger than specific value.
797
- absAngle = Math.abs(lineAngle);
798
- if (
799
- absAngle < MIN_ANGLE_DISALLOW_DRAW_WALL ||
800
- absAngle > 360 - MIN_ANGLE_DISALLOW_DRAW_WALL
801
- ) {
802
- moveFlag = false;
803
- } else moveFlag = true;
804
- }
805
- });
806
- }
807
-
808
- // if the angle is bigger or less than specific value, the wall mustn't be drawn at new position
809
- if (moveFlag) {
810
- tx = x;
811
- ty = y;
812
- } else {
813
- let rest = MIN_ANGLE_DISALLOW_DRAW_WALL - absAngle;
814
- // the origin point of rotation(snapping)
815
- let ox = vertices[drawingLine.vertices[0]].x;
816
- let oy = vertices[drawingLine.vertices[0]].y;
817
- // determine the direction of rotation.
818
- rest = lineAngle > 0 ? -rest : rest;
819
- // rotate the current point to last point around the first point of drawing line.
820
- let res = GeometryUtils.rotatePointAroundPoint(x, y, ox, oy, rest);
821
- tx = res.x;
822
- ty = res.y;
823
- }
824
- // angle snapping as a value of UNIT_ANGLE
825
- if (moveFlag && !isEmpty(absAngle) && absAngle % UNIT_ANGLE !== 0) {
826
- let result = GeometryUtils.snapAngleByUnit(
827
- lineAngle,
828
- vertices,
829
- drawingLine,
830
- tx,
831
- ty,
832
- drawingLine.vertices[1]
833
- );
834
- tx = result.x;
835
- ty = result.y;
836
- }
837
- let { updatedState: stateLV, vertex } = Line.replaceVertex(
838
- state,
839
- layerID,
840
- lineID,
841
- 1,
842
- tx,
843
- ty
844
- );
845
- state = stateLV;
846
- state = this.select(state, layerID, lineID).updatedState;
847
- state = state.merge({ activeSnapElement: snap ? snap.snap : null });
848
- state = state.setIn(['scene', 'setLineAttributes'], false);
849
- return { updatedState: state };
850
- }
851
-
852
- static drawLineByAttributes(state, layerID, lineID, lineAttributes) {
853
- let lAttr = lineAttributes.toJS();
854
- let { vertexOne, vertexTwo } = lAttr;
855
- // state = state.mergeIn(
856
- // ['scene', 'layers', layerID, 'lines', lineID],
857
- // fromJS(lAttr)
858
- // );
859
-
860
- let layer = state.getIn(['scene', 'layers', layerID]);
861
- let line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
862
-
863
- // let relatedLines = layer.lines.toArray().filter(line => {
864
- // return line.vertices.includes(vertexOne.id) && line.id != lineID;
865
- // });
866
- let lines = state.getIn(['scene', 'layers', layerID, 'lines']).toJS();
867
- let vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
868
- let relatedLines = [];
869
- let drawingLine = line.toJS();
870
- getRelatedLines(relatedLines, drawingLine, vertices, lines);
871
-
872
- //if lineAngle is 180 degree between two lines
873
- let lineAngle;
874
- let holesWithOffsetPosition = [];
875
- let v0;
876
- for (let i = 0; i < relatedLines.length; i++) {
877
- // A variable j, k is the number of points in the line
878
- for (let j = 0; j < 2; j++) {
879
- for (let k = 0; k < 2; k++) {
880
- // lineAngle is that angle between the two lines
881
- lineAngle = Math.abs(
882
- GeometryUtils.angleBetweenTwoLines(
883
- relatedLines[i],
884
- drawingLine,
885
- vertices
886
- )
887
- );
888
- //when the related line is one, drawing a new line
889
- if (lineAngle === 180 && relatedLines.length === 1) {
890
- if (relatedLines[i].vertices[j] !== drawingLine.vertices[k]) {
891
- continue;
892
- } else {
893
- v0 = layer.vertices.get(relatedLines[i].vertices[1 - j]);
894
- let v1 = layer.vertices.get(relatedLines[i].vertices[j]);
895
- //remove the drawing line and related line
896
- state = Line.remove(
897
- state,
898
- layerID,
899
- relatedLines[i].id
900
- ).updatedState;
901
- //get the data of hole included in the related line
902
- layer.lines.get(relatedLines[i].id).holes.forEach(holeID => {
903
- let lineLength = GeometryUtils.pointsDistance(
904
- v0.x,
905
- v0.y,
906
- v1.x,
907
- v1.y
908
- );
909
- let minV = GeometryUtils.minVertex(v0, v1);
910
- let maxV = GeometryUtils.maxVertex(v0, v1);
911
- let alpha = Math.atan2(maxV.y - minV.y, maxV.x - minV.x);
912
- let hole = layer.holes.get(holeID);
913
- let pointOnLine = lineLength * hole.offset;
914
- // Calculate the hole position
915
- let offsetPosition = {
916
- x: pointOnLine * Math.cos(alpha) + minV.x,
917
- y: pointOnLine * Math.sin(alpha) + minV.y
918
- };
919
-
920
- holesWithOffsetPosition.push({ hole, offsetPosition });
921
- });
922
- }
923
- }
924
- }
925
- }
926
- }
927
- // state = state.mergeIn(
928
- // ['scene', 'layers', layerID, 'lines', lineID, 'focus'],
929
- // true
930
- // );
931
- let v2 = layer.vertices.get(line.vertices.get(0));
932
- let v3 = layer.vertices.get(line.vertices.get(1));
933
- state = this.select(state, layerID, lineID).updatedState;
934
- state = Line.remove(state, layerID, lineID).updatedState;
935
- let minV = GeometryUtils.minVertex(v2, v3);
936
- let maxV = GeometryUtils.maxVertex(v2, v3);
937
- let alpha = Math.atan2(maxV.y - minV.y, maxV.x - minV.x);
938
- layer.lines.get(lineID).holes.forEach(holeID => {
939
- let lineLength = GeometryUtils.pointsDistance(v2.x, v2.y, v3.x, v3.y);
940
- let hole = layer.holes.get(holeID);
941
- let pointOnLine = lineLength * hole.offset;
942
-
943
- let offsetPosition = {
944
- x: pointOnLine * Math.cos(alpha) + minV.x,
945
- y: pointOnLine * Math.sin(alpha) + minV.y
946
- };
947
-
948
- holesWithOffsetPosition.push({ hole, offsetPosition });
949
- });
950
- let checkVertex = lineAngle === 180 && relatedLines.length === 1 ? v0 : v2;
951
- if (
952
- !GeometryUtils.samePoints(checkVertex, {
953
- x: vertexTwo.x,
954
- y: vertexTwo.y
955
- })
956
- ) {
957
- let ret = Line.createAvoidingIntersections(
958
- state,
959
- layerID,
960
- line.type,
961
- checkVertex.x,
962
- checkVertex.y,
963
- vertexTwo.x,
964
- vertexTwo.y,
965
- line.properties,
966
- holesWithOffsetPosition,
967
- line.createdDateTime
968
- );
969
- state = ret.updatedState;
970
- }
971
- // state = Line.createAvoidingIntersections(state, layerID, line.type, v0.x, v0.y, x, y).updatedState;
972
-
973
- // origin area count
974
- let areaCount = layer.areas.size;
975
-
976
- state = Layer.detectAndUpdateAreas(state, layerID).updatedState;
977
-
978
- state = state.merge({
979
- sceneHistory: history.historyPush(state.sceneHistory, state.scene)
980
- });
981
-
982
- // state = state.merge({
983
- // mode: MODE_WAITING_DRAWING_LINE,
984
- // snapElements: new List(),
985
- // activeSnapElement: null
986
- // });
987
-
988
- if (state.mode.endsWith('_LINE')) {
989
- state = state.setIn(['scene', 'setLineAttributes'], true);
990
- state = this.beginDrawingLine(
991
- state,
992
- layerID,
993
- vertexTwo.x,
994
- vertexTwo.y
995
- ).updatedState;
996
- }
997
-
998
- // update area//
999
- layer = state.getIn(['scene', 'layers', layerID]);
1000
- // if new area created
1001
- // this.interiorsurfacedetect(state);
1002
-
1003
- return { updatedState: state };
1004
- }
1005
-
1006
- static stopDrawingLine(state) {
1007
- console.log('line aCtion');
1008
- }
1009
-
1010
- /**
1011
- * check the [curVertId] point
1012
- * @param {*} state scene state
1013
- * @param {*} curVertId id of vertex
1014
- * returns colinear two line array - [line1, line2]
1015
- * if there is no colinear lines or the count of colinear lines more than
1016
- */
1017
- static hasColinearTwoLines(state, curVertId, layerID) {
1018
- let lineGroup = [];
1019
- let layer = state.getIn(['scene', 'layers', layerID]);
1020
- let vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
1021
-
1022
- layer.lines.forEach(line => {
1023
- if (line.vertices.some(v => v === curVertId)) lineGroup.push(line.toJS());
1024
- });
1025
- if (lineGroup.length !== 2) return null;
1026
-
1027
- let lineAngle = Math.abs(
1028
- GeometryUtils.angleBetweenTwoLines(lineGroup[0], lineGroup[1], vertices)
1029
- );
1030
- if (lineAngle === 180) return lineGroup;
1031
-
1032
- return null;
1033
- }
1034
-
1035
- static mergeTwoColinearLines(state, line1, line2, layerID, lineProperties) {
1036
- let nv0, nv1, nv2;
1037
- let layer = state.getIn(['scene', 'layers', layerID]);
1038
-
1039
- let holesWithOffsetPosition = [];
1040
-
1041
- line1.vertices.forEach(v1 => {
1042
- line2.vertices.forEach(v2 => {
1043
- if (v2 === v1) {
1044
- nv1 = layer.vertices.get(v1);
1045
- }
1046
- });
1047
- });
1048
- line1.vertices.forEach(v1 => {
1049
- if (v1 !== nv1.id) nv0 = layer.vertices.get(v1);
1050
- });
1051
- line2.vertices.forEach(v2 => {
1052
- if (v2 !== nv1.id) nv2 = layer.vertices.get(v2);
1053
- });
1054
-
1055
- state = Line.remove(state, layerID, line1.id).updatedState;
1056
- //get the data of hole included in the related line
1057
- layer.lines.get(line1.id).holes.forEach(holeID => {
1058
- let lineLength = GeometryUtils.pointsDistance(nv0.x, nv0.y, nv1.x, nv1.y);
1059
- let minV = GeometryUtils.minVertex(nv0, nv1);
1060
- let maxV = GeometryUtils.maxVertex(nv0, nv1);
1061
- let alpha = Math.atan2(maxV.y - minV.y, maxV.x - minV.x);
1062
- let hole = layer.holes.get(holeID);
1063
- let pointOnLine = lineLength * hole.offset;
1064
- // Calculate the hole position
1065
- let offsetPosition = {
1066
- x: pointOnLine * Math.cos(alpha) + minV.x,
1067
- y: pointOnLine * Math.sin(alpha) + minV.y
1068
- };
1069
-
1070
- holesWithOffsetPosition.push({ hole, offsetPosition });
1071
- });
1072
- state = Line.remove(state, layerID, line2.id).updatedState;
1073
- layer.lines.get(line2.id).holes.forEach(holeID => {
1074
- let lineLength = GeometryUtils.pointsDistance(nv1.x, nv1.y, nv2.x, nv2.y);
1075
- let minV = GeometryUtils.minVertex(nv1, nv2);
1076
- let maxV = GeometryUtils.maxVertex(nv1, nv2);
1077
- let alpha = Math.atan2(maxV.y - minV.y, maxV.x - minV.x);
1078
- let hole = layer.holes.get(holeID);
1079
- let pointOnLine = lineLength * hole.offset;
1080
- // Calculate the hole position
1081
- let offsetPosition = {
1082
- x: pointOnLine * Math.cos(alpha) + minV.x,
1083
- y: pointOnLine * Math.sin(alpha) + minV.y
1084
- };
1085
-
1086
- holesWithOffsetPosition.push({ hole, offsetPosition });
1087
- });
1088
- let ret = Line.createAvoidingIntersections(
1089
- state,
1090
- layerID,
1091
- line1.type,
1092
- nv0.x,
1093
- nv0.y,
1094
- nv2.x,
1095
- nv2.y,
1096
- lineProperties,
1097
- holesWithOffsetPosition,
1098
- line1.createdDateTime
1099
- );
1100
- state = ret.updatedState;
1101
-
1102
- // origin area count
1103
- let areaCount = layer.areas.size;
1104
-
1105
- let drawingInfor = {
1106
- drawingLine: ret.newline,
1107
- vertices: layer.vertices
1108
- };
1109
- state = Layer.detectAndUpdateAreas(
1110
- state,
1111
- layerID,
1112
- drawingInfor
1113
- ).updatedState;
1114
-
1115
- //update area//
1116
- layer = state.getIn(['scene', 'layers', layerID]);
1117
- // if new area created
1118
- // this.interiorsurfacedetect(state);
1119
-
1120
- return { updatedState: state, drawingInfor };
1121
- }
1122
-
1123
- static endDrawingLine(state, x, y, relatedLines) {
1124
- if (state.snapMask && !state.snapMask.isEmpty()) {
1125
- let snap = SnapUtils.nearestSnap(
1126
- state.snapElements,
1127
- x,
1128
- y,
1129
- state.snapMask
1130
- );
1131
- if (snap) ({ x, y } = snap.point);
1132
- }
1133
-
1134
- let layerID = state.getIn(['drawingSupport', 'layerID']);
1135
- let layer = state.getIn(['scene', 'layers', layerID]);
1136
- let lineID = state
1137
- .getIn(['scene', 'layers', layerID, 'selected', 'lines'])
1138
- .first();
1139
- let line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
1140
-
1141
- let drawingLine = line.toJS();
1142
-
1143
- if (drawingLine.vertices[0] === drawingLine.vertices[1]) {
1144
- state = Line.remove(state, layerID, lineID).updatedState;
1145
- state = state.merge({
1146
- mode: MODE_IDLE,
1147
- snapElements: new List(),
1148
- activeSnapElement: null
1149
- });
1150
- return { updatedState: state };
1151
- }
1152
-
1153
-
1154
- /// 180 merge lines - start ////
1155
- let vertexGroup = [];
1156
- let drawingInfor = {};
1157
-
1158
- line.vertices.forEach(vertexID => {
1159
- let colinearLines = state.getIn([
1160
- 'scene',
1161
- 'layers',
1162
- layerID,
1163
- 'vertices',
1164
- vertexID,
1165
- 'lines'
1166
- ]);
1167
- colinearLines.forEach(lineID => {
1168
- let line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
1169
-
1170
- line.vertices.forEach(vertex => {
1171
- if (vertex !== vertexID) vertexGroup.push(vertex);
1172
- });
1173
- });
1174
- });
1175
-
1176
- vertexGroup.forEach(vertexId => {
1177
- let lineGroup = [];
1178
-
1179
- lineGroup = this.hasColinearTwoLines(state, vertexId, layerID);
1180
- if (!isEmpty(lineGroup)) {
1181
- let ret = this.mergeTwoColinearLines(
1182
- state,
1183
- lineGroup[0],
1184
- lineGroup[1],
1185
- layerID,
1186
- line.properties
1187
- );
1188
- state = ret.updatedState;
1189
- drawingInfor = ret.drawingInfor;
1190
- }
1191
- });
1192
-
1193
- /// 180 merge lines - end ////
1194
-
1195
- if (isEmpty(drawingInfor)) {
1196
- drawingInfor = {
1197
- drawingLine: line,
1198
- vertices: layer.vertices
1199
- };
1200
- state = Layer.detectAndUpdateAreas(
1201
- state,
1202
- layerID,
1203
- drawingInfor
1204
- ).updatedState;
1205
- }
1206
-
1207
- //update area//
1208
- layer = state.getIn(['scene', 'layers', layerID]);
1209
- // if new area created
1210
- // this.interiorsurfacedetect(state);
1211
-
1212
- state = state.merge({
1213
- mode: MODE_WAITING_DRAWING_LINE,
1214
- snapElements: new List(),
1215
- activeSnapElement: null
1216
- });
1217
- return { updatedState: state };
1218
- }
1219
-
1220
- static beginDraggingLine(state, layerID, lineID, x, y) {
1221
- let snapElements = SnapSceneUtils.sceneSnapElements(
1222
- state.scene,
1223
- new List(),
1224
- state.snapMask
1225
- );
1226
-
1227
- let layer = state.scene.layers.get(layerID);
1228
- let line = layer.lines.get(lineID);
1229
-
1230
- let vertex0 = layer.vertices.get(line.vertices.get(0));
1231
- let vertex1 = layer.vertices.get(line.vertices.get(1));
1232
-
1233
- state = state.merge({
1234
- mode: MODE_DRAGGING_LINE,
1235
- snapElements,
1236
- draggingSupport: Map({
1237
- layerID,
1238
- lineID,
1239
- startPointX: x,
1240
- startPointY: y,
1241
- startVertex0X: vertex0.x,
1242
- startVertex0Y: vertex0.y,
1243
- startVertex1X: vertex1.x,
1244
- startVertex1Y: vertex1.y
1245
- })
1246
- });
1247
-
1248
- return { updatedState: state };
1249
- }
1250
-
1251
- static getNewDraggedPoints(
1252
- newPoints,
1253
- allVertices,
1254
- draggingLine,
1255
- relatedLines
1256
- ) {
1257
- if (
1258
- !newPoints ||
1259
- !allVertices ||
1260
- !draggingLine ||
1261
- !Array.isArray(relatedLines)
1262
- ) {
1263
- return newPoints; // Invalid input, just return
1264
- }
1265
-
1266
- const draggingVertices = Array.isArray(draggingLine.vertices)
1267
- ? draggingLine.vertices
1268
- : [];
1269
- const mvFlag = [];
1270
-
1271
- relatedLines.forEach(relLine => {
1272
- if (!relLine || !Array.isArray(relLine.vertices)) return;
1273
-
1274
- relLine.vertices.forEach((vertexId, i) => {
1275
- if (draggingVertices.includes(vertexId)) return; // skip shared vertices
1276
- const vData = allVertices[vertexId];
1277
- if (!vData) return; // guard: vertex missing
1278
-
1279
- const center =
1280
- i === 0
1281
- ? new Three.Vector2(
1282
- newPoints?.newVertex0X ?? 0,
1283
- newPoints?.newVertex0Y ?? 0
1284
- )
1285
- : new Three.Vector2(
1286
- newPoints?.newVertex1X ?? 0,
1287
- newPoints?.newVertex1Y ?? 0
1288
- );
1289
-
1290
- const pos1 = new Three.Vector2(vData.x ?? 0, vData.y ?? 0);
1291
- const pos2 =
1292
- i === 0
1293
- ? new Three.Vector2(
1294
- newPoints?.newVertex1X ?? 0,
1295
- newPoints?.newVertex1Y ?? 0
1296
- )
1297
- : new Three.Vector2(
1298
- newPoints?.newVertex0X ?? 0,
1299
- newPoints?.newVertex0Y ?? 0
1300
- );
1301
-
1302
- const cen = center.clone();
1303
- const vec1 = pos1.clone().sub(cen).normalize();
1304
- const vec2 = pos2.clone().sub(cen).normalize();
1305
-
1306
- const angle = Math.floor(
1307
- (vec1.angle() * 180) / Math.PI - (vec2.angle() * 180) / Math.PI + 0.5
1308
- );
1309
-
1310
- if (
1311
- Math.abs(angle) < MIN_ANGLE_DISALLOW_DRAW_WALL ||
1312
- Math.abs(angle) > 360 - MIN_ANGLE_DISALLOW_DRAW_WALL
1313
- ) {
1314
- mvFlag.push(false);
1315
- } else {
1316
- mvFlag.push(true);
1317
- }
1318
- });
1319
- });
1320
-
1321
- // If any flag is false, revert newPoints to original dragging line positions
1322
- if (mvFlag.includes(false) && draggingVertices.length >= 2) {
1323
- const v0 = allVertices[draggingVertices[0]];
1324
- const v1 = allVertices[draggingVertices[1]];
1325
- if (v0 && v1) {
1326
- newPoints.newVertex0X = v0.x;
1327
- newPoints.newVertex0Y = v0.y;
1328
- newPoints.newVertex1X = v1.x;
1329
- newPoints.newVertex1Y = v1.y;
1330
- }
1331
- }
1332
-
1333
- return newPoints;
1334
- }
1335
-
1336
- static updateDraggingLine(state, x, y, relatedLines) {
1337
- let draggingSupport = state.draggingSupport;
1338
- let snapElements = state.snapElements;
1339
-
1340
- let layerID = draggingSupport.get('layerID');
1341
- let lineID = draggingSupport.get('lineID');
1342
- let diffX = x - draggingSupport.get('startPointX');
1343
- let diffY = y - draggingSupport.get('startPointY');
1344
- let newVertex0X = draggingSupport.get('startVertex0X') + diffX;
1345
- let newVertex0Y = draggingSupport.get('startVertex0Y') + diffY;
1346
- let newVertex1X = draggingSupport.get('startVertex1X') + diffX;
1347
- let newVertex1Y = draggingSupport.get('startVertex1Y') + diffY;
1348
- let drawingLine = state
1349
- .getIn(['scene', 'layers', layerID, 'lines', lineID])
1350
- .toJS();
1351
- let allVertices = state
1352
- .getIn(['scene', 'layers', layerID, 'vertices'])
1353
- .toJS();
1354
-
1355
- let activeSnapElement = null;
1356
- let curSnap0 = null,
1357
- curSnap1 = null;
1358
- if (state.snapMask && !state.snapMask.isEmpty()) {
1359
- curSnap0 = SnapUtils.nearestSnap(
1360
- snapElements,
1361
- newVertex0X,
1362
- newVertex0Y,
1363
- state.snapMask
1364
- );
1365
- curSnap1 = SnapUtils.nearestSnap(
1366
- snapElements,
1367
- newVertex1X,
1368
- newVertex1Y,
1369
- state.snapMask
1370
- );
1371
- }
1372
-
1373
- let deltaX = 0,
1374
- deltaY = 0;
1375
- if (curSnap0 && curSnap1) {
1376
- if (curSnap0.point.distance < curSnap1.point.distance) {
1377
- deltaX = curSnap0.point.x - newVertex0X;
1378
- deltaY = curSnap0.point.y - newVertex0Y;
1379
- activeSnapElement = curSnap0.snap;
1380
- } else {
1381
- deltaX = curSnap1.point.x - newVertex1X;
1382
- deltaY = curSnap1.point.y - newVertex1Y;
1383
- activeSnapElement = curSnap1.snap;
1384
- }
1385
- } else {
1386
- if (curSnap0) {
1387
- deltaX = curSnap0.point.x - newVertex0X;
1388
- deltaY = curSnap0.point.y - newVertex0Y;
1389
- activeSnapElement = curSnap0.snap;
1390
- }
1391
- if (curSnap1) {
1392
- deltaX = curSnap1.point.x - newVertex1X;
1393
- deltaY = curSnap1.point.y - newVertex1Y;
1394
- activeSnapElement = curSnap1.snap;
1395
- }
1396
- }
1397
-
1398
- newVertex0X += deltaX;
1399
- newVertex0Y += deltaY;
1400
- newVertex1X += deltaX;
1401
- newVertex1Y += deltaY;
1402
- let newPoints = {
1403
- newVertex0X: newVertex0X,
1404
- newVertex0Y: newVertex0Y,
1405
- newVertex1X: newVertex1X,
1406
- newVertex1Y: newVertex1Y
1407
- };
1408
- let newResult = this.getNewDraggedPoints(
1409
- newPoints,
1410
- allVertices,
1411
- drawingLine,
1412
- relatedLines
1413
- );
1414
- newVertex0X = newResult.newVertex0X;
1415
- newVertex0Y = newResult.newVertex0Y;
1416
- newVertex1X = newResult.newVertex1X;
1417
- newVertex1Y = newResult.newVertex1Y;
1418
-
1419
- state = state.merge({
1420
- activeSnapElement,
1421
- scene: state.scene.updateIn(['layers', layerID], layer =>
1422
- layer.withMutations(layer => {
1423
- let lineVertices = layer.getIn(['lines', lineID, 'vertices']);
1424
- layer.updateIn(['vertices', lineVertices.get(0)], vertex =>
1425
- vertex.merge({ x: newVertex0X, y: newVertex0Y })
1426
- );
1427
- layer.updateIn(['vertices', lineVertices.get(1)], vertex =>
1428
- vertex.merge({ x: newVertex1X, y: newVertex1Y })
1429
- );
1430
- return layer;
1431
- })
1432
- )
1433
- });
1434
-
1435
- return { updatedState: state };
1436
- }
1437
-
1438
- static endDraggingLine(state, x, y, relatedLines) {
1439
- let { draggingSupport } = state;
1440
-
1441
- let layerID = draggingSupport.get('layerID');
1442
- let layer = state.scene.layers.get(layerID);
1443
- let lineID = draggingSupport.get('lineID');
1444
- let line = layer.lines.get(lineID);
1445
- let drawedLine = line.toJS();
1446
- let allVertices = state
1447
- .getIn(['scene', 'layers', layerID, 'vertices'])
1448
- .toJS();
1449
-
1450
- let vertex0 = layer.vertices.get(line.vertices.get(0));
1451
- let vertex1 = layer.vertices.get(line.vertices.get(1));
1452
- let maxV = GeometryUtils.maxVertex(vertex0, vertex1);
1453
- let minV = GeometryUtils.minVertex(vertex0, vertex1);
1454
- let lineLength = GeometryUtils.verticesDistance(minV, maxV);
1455
- let alpha = Math.atan2(maxV.y - minV.y, maxV.x - minV.x);
1456
- let holesWithOffsetPosition = [];
1457
- layer.lines.get(lineID).holes.forEach(holeID => {
1458
- let hole = layer.holes.get(holeID);
1459
- let pointOnLine = lineLength * hole.offset;
1460
- let offsetPosition = {
1461
- x: pointOnLine * Math.cos(alpha) + minV.x,
1462
- y: pointOnLine * Math.sin(alpha) + minV.y
1463
- };
1464
- holesWithOffsetPosition.push({ hole, offsetPosition });
1465
- });
1466
-
1467
- let diffX = x - draggingSupport.get('startPointX');
1468
- let diffY = y - draggingSupport.get('startPointY');
1469
- let newVertex0X = draggingSupport.get('startVertex0X') + diffX;
1470
- let newVertex0Y = draggingSupport.get('startVertex0Y') + diffY;
1471
- let newVertex1X = draggingSupport.get('startVertex1X') + diffX;
1472
- let newVertex1Y = draggingSupport.get('startVertex1Y') + diffY;
1473
-
1474
- if (state.snapMask && !state.snapMask.isEmpty()) {
1475
- let curSnap0 = SnapUtils.nearestSnap(
1476
- state.snapElements,
1477
- newVertex0X,
1478
- newVertex0Y,
1479
- state.snapMask
1480
- );
1481
- let curSnap1 = SnapUtils.nearestSnap(
1482
- state.snapElements,
1483
- newVertex1X,
1484
- newVertex1Y,
1485
- state.snapMask
1486
- );
1487
-
1488
- let deltaX = 0,
1489
- deltaY = 0;
1490
- if (curSnap0 && curSnap1) {
1491
- if (curSnap0.point.distance < curSnap1.point.distance) {
1492
- deltaX = curSnap0.point.x - newVertex0X;
1493
- deltaY = curSnap0.point.y - newVertex0Y;
1494
- } else {
1495
- deltaX = curSnap1.point.x - newVertex1X;
1496
- deltaY = curSnap1.point.y - newVertex1Y;
1497
- }
1498
- } else {
1499
- if (curSnap0) {
1500
- deltaX = curSnap0.point.x - newVertex0X;
1501
- deltaY = curSnap0.point.y - newVertex0Y;
1502
- }
1503
- if (curSnap1) {
1504
- deltaX = curSnap1.point.x - newVertex1X;
1505
- deltaY = curSnap1.point.y - newVertex1Y;
1506
- }
1507
- }
1508
-
1509
- newVertex0X += deltaX;
1510
- newVertex0Y += deltaY;
1511
- newVertex1X += deltaX;
1512
- newVertex1Y += deltaY;
1513
- }
1514
- let newPoints = {
1515
- newVertex0X: newVertex0X,
1516
- newVertex0Y: newVertex0Y,
1517
- newVertex1X: newVertex1X,
1518
- newVertex1Y: newVertex1Y
1519
- };
1520
- let newResult = this.getNewDraggedPoints(
1521
- newPoints,
1522
- allVertices,
1523
- drawedLine,
1524
- relatedLines
1525
- );
1526
- newVertex0X = newResult.newVertex0X;
1527
- newVertex0Y = newResult.newVertex0Y;
1528
- newVertex1X = newResult.newVertex1X;
1529
- newVertex1Y = newResult.newVertex1Y;
1530
-
1531
- let lineGroups = state //get groups membership if present
1532
- .getIn(['scene', 'groups'])
1533
- .filter(group => {
1534
- const lines = group.getIn(['elements', layerID, 'lines']);
1535
- return lines && lines.contains(lineID);
1536
- });
1537
-
1538
- state = Layer.mergeEqualsVertices(
1539
- state,
1540
- layerID,
1541
- line.vertices.get(0)
1542
- ).updatedState;
1543
- state = Layer.mergeEqualsVertices(
1544
- state,
1545
- layerID,
1546
- line.vertices.get(1)
1547
- ).updatedState;
1548
- state = Line.remove(state, layerID, lineID).updatedState;
1549
- if (
1550
- !GeometryUtils.samePoints(
1551
- { newVertex0X, newVertex0Y },
1552
- { newVertex1X, newVertex1Y }
1553
- )
1554
- ) {
1555
- let ret = Line.createAvoidingIntersections(
1556
- state,
1557
- layerID,
1558
- line.type,
1559
- newVertex0X,
1560
- newVertex0Y,
1561
- newVertex1X,
1562
- newVertex1Y,
1563
- line.properties,
1564
- holesWithOffsetPosition,
1565
- line.createdDateTime
1566
- );
1567
-
1568
- state = ret.updatedState;
1569
- //re-add to old line's groups if present
1570
- ret.lines.forEach(addedLine => {
1571
- lineGroups.forEach(oldLineGroup => {
1572
- state = Group.addElement(
1573
- state,
1574
- oldLineGroup.id,
1575
- layerID,
1576
- 'lines',
1577
- addedLine.id
1578
- ).updatedState;
1579
- });
1580
- });
1581
- }
1582
-
1583
- /// merge line if line angle is 180 degree ----> start
1584
- let draggingLineID = state.draggingSupport.get('lineID');
1585
- let draggingLine = layer.lines.get(draggingLineID);
1586
- let vertexGroup = [];
1587
-
1588
- draggingLine.vertices.forEach(vertexID => {
1589
- let colinearLines = state.getIn([
1590
- 'scene',
1591
- 'layers',
1592
- layerID,
1593
- 'vertices',
1594
- vertexID,
1595
- 'lines'
1596
- ]);
1597
- if (!isEmpty(colinearLines)) {
1598
- colinearLines.forEach(lineID => {
1599
- let line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
1600
-
1601
- line.vertices.forEach(vertex => {
1602
- if (vertex !== vertexID) vertexGroup.push(vertex);
1603
- });
1604
- });
1605
- }
1606
- });
1607
-
1608
- vertexGroup.forEach(vertexId => {
1609
- let lineGroup = [];
1610
-
1611
- lineGroup = this.hasColinearTwoLines(state, vertexId, layerID);
1612
- if (!isEmpty(lineGroup)) {
1613
- state = this.mergeTwoColinearLines(
1614
- state,
1615
- lineGroup[0],
1616
- lineGroup[1],
1617
- layerID,
1618
- line.properties
1619
- ).updatedState;
1620
- }
1621
- });
1622
-
1623
- /// ------> end
1624
- state = Layer.detectAndUpdateAreas(state, layerID, {}).updatedState;
1625
-
1626
- state = state.merge({
1627
- mode: MODE_IDLE,
1628
- draggingSupport: null,
1629
- activeSnapElement: null,
1630
- snapElements: new List()
1631
- });
1632
-
1633
- return { updatedState: state };
1634
- }
1635
-
1636
- static setProperties(state, layerID, lineID, properties) {
1637
- state = state.mergeIn(
1638
- ['scene', 'layers', layerID, 'lines', lineID, 'properties'],
1639
- properties
1640
- );
1641
-
1642
- return { updatedState: state };
1643
- }
1644
-
1645
- static setJsProperties(state, layerID, lineID, properties) {
1646
- return this.setProperties(state, layerID, lineID, fromJS(properties));
1647
- }
1648
-
1649
- static updateProperties(state, layerID, lineID, properties) {
1650
- properties.forEach((v, k) => {
1651
- if (
1652
- state.hasIn([
1653
- 'scene',
1654
- 'layers',
1655
- layerID,
1656
- 'lines',
1657
- lineID,
1658
- 'properties',
1659
- k
1660
- ])
1661
- )
1662
- state = state.mergeIn(
1663
- ['scene', 'layers', layerID, 'lines', lineID, 'properties', k],
1664
- v
1665
- );
1666
- });
1667
-
1668
- return { updatedState: state };
1669
- }
1670
-
1671
- static updateJsProperties(state, layerID, lineID, properties) {
1672
- return this.updateProperties(state, layerID, lineID, fromJS(properties));
1673
- }
1674
-
1675
- static setAttributes(state, layerID, lineID, lineAttributes) {
1676
- if (state.mode === MODE_WAITING_DRAWING_LINE)
1677
- return this.drawLineByAttributes(state, layerID, lineID, lineAttributes);
1678
-
1679
- let lAttr = lineAttributes.toJS();
1680
- let {
1681
- vertexOne,
1682
- vertexTwo,
1683
- vertexThree,
1684
- vertexFour,
1685
- lineLength,
1686
- lineToExtend
1687
- } = lAttr;
1688
- delete lAttr['vertexOne'];
1689
- delete lAttr['vertexTwo'];
1690
- delete lAttr['vertexThree'];
1691
- delete lAttr['vertexFour'];
1692
- delete lAttr['lineToExtend'];
1693
- delete lAttr['lineLength'];
1694
- let line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
1695
- state = state
1696
- .mergeIn(['scene', 'layers', layerID, 'lines', lineID], fromJS(lAttr))
1697
- .mergeIn(['scene', 'layers', layerID, 'vertices', vertexOne.id], {
1698
- x: vertexOne.x,
1699
- y: vertexOne.y
1700
- })
1701
- .mergeIn(['scene', 'layers', layerID, 'vertices', vertexTwo.id], {
1702
- x: vertexTwo.x,
1703
- y: vertexTwo.y
1704
- })
1705
- .mergeIn(
1706
- ['scene', 'layers', layerID, 'lines', lineID, 'misc'],
1707
- new Map({ _unitLength: lineLength._unit })
1708
- )
1709
- .mergeIn(['scene', 'layers', layerID, 'lines', lineID, 'focus'], true);
1710
- if (lineToExtend) {
1711
- state = state
1712
- .mergeIn(
1713
- ['scene', 'layers', layerID, 'lines', lineToExtend.id],
1714
- fromJS(lAttr)
1715
- )
1716
- .mergeIn(
1717
- ['scene', 'layers', layerID, 'lines', lineToExtend.id, 'misc'],
1718
- new Map({ _unitLength: lineLength._unit })
1719
- );
1720
- }
1721
- if (vertexThree) {
1722
- state = state.mergeIn(
1723
- ['scene', 'layers', layerID, 'vertices', vertexThree.id],
1724
- { x: vertexThree.x, y: vertexThree.y }
1725
- );
1726
- }
1727
- if (vertexFour) {
1728
- state = state.mergeIn(
1729
- ['scene', 'layers', layerID, 'vertices', vertexFour.id],
1730
- { x: vertexFour.x, y: vertexFour.y }
1731
- );
1732
- }
1733
- state = Layer.mergeEqualsVertices(
1734
- state,
1735
- layerID,
1736
- vertexOne.id
1737
- ).updatedState;
1738
- if (vertexOne.x != vertexTwo.x && vertexOne.y != vertexTwo.y) {
1739
- state = Layer.mergeEqualsVertices(
1740
- state,
1741
- layerID,
1742
- vertexTwo.id
1743
- ).updatedState;
1744
- }
1745
- state = Layer.detectAndUpdateAreas(state, layerID, {}).updatedState;
1746
- state = state.merge({
1747
- sceneHistory: history.historyPush(state.sceneHistory, state.scene)
1748
- });
1749
- if (state.mode.endsWith('_LINE')) {
1750
- state = this.beginDrawingLine(
1751
- state,
1752
- layerID,
1753
- vertexTwo.x,
1754
- vertexTwo.y
1755
- ).updatedState;
1756
- }
1757
-
1758
- return { updatedState: state };
1759
- }
1760
-
1761
- static setVerticesCoords(state, layerID, lineID, x1, y1, x2, y2) {
1762
- let line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
1763
- state = Vertex.setAttributes(
1764
- state,
1765
- layerID,
1766
- line.vertices.get(0),
1767
- new Map({ x: x1, y: y1 })
1768
- ).updatedState;
1769
- state = Vertex.setAttributes(
1770
- state,
1771
- layerID,
1772
- line.vertices.get(1),
1773
- new Map({ x: x2, y: y2 })
1774
- ).updatedState;
1775
-
1776
- return { updatedState: state };
1777
- }
1778
- }
1779
-
1780
- export { Line as default };