kitchen-simulator 1.1.1-test.72 → 1.1.1-test.74
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.
- package/es/@history.js +2 -5
- package/es/AppContext.js +3 -6
- package/es/KitchenConfigurator.js +86 -86
- package/es/KitchenConfiguratorApp.js +134 -128
- package/es/actions/area-actions.js +5 -8
- package/es/actions/export.js +12 -24
- package/es/actions/groups-actions.js +27 -41
- package/es/actions/holes-actions.js +34 -51
- package/es/actions/items-actions.js +94 -141
- package/es/actions/lines-actions.js +21 -32
- package/es/actions/project-actions.js +94 -141
- package/es/actions/scene-actions.js +11 -17
- package/es/actions/vertices-actions.js +7 -11
- package/es/actions/viewer2d-actions.js +21 -32
- package/es/actions/viewer3d-actions.js +9 -14
- package/es/catalog/areas/area/planner-element.js +2 -5
- package/es/catalog/catalog.js +15 -17
- package/es/catalog/factories/area-factory-3d.js +22 -26
- package/es/catalog/factories/area-factory.js +13 -15
- package/es/catalog/factories/export.js +6 -10
- package/es/catalog/factories/wall-factory-3d.js +31 -36
- package/es/catalog/factories/wall-factory.js +21 -26
- package/es/catalog/holes/door-closet/planner-element.js +15 -19
- package/es/catalog/holes/door-double/planner-element.js +15 -19
- package/es/catalog/holes/door-exterior/planner-element.js +16 -20
- package/es/catalog/holes/door-interior/planner-element.js +16 -20
- package/es/catalog/holes/door-panic/planner-element.js +7 -11
- package/es/catalog/holes/door-panic-double/planner-element.js +15 -19
- package/es/catalog/holes/door-sliding/planner-element.js +17 -21
- package/es/catalog/holes/doorway-framed/planner-element.js +11 -15
- package/es/catalog/holes/doorway-frameless/planner-element.js +7 -11
- package/es/catalog/holes/export.js +13 -29
- package/es/catalog/holes/window-clear/planner-element.js +10 -14
- package/es/catalog/holes/window-cross/planner-element.js +10 -14
- package/es/catalog/holes/window-double-hung/planner-element.js +10 -14
- package/es/catalog/holes/window-vertical/planner-element.js +10 -14
- package/es/catalog/lines/wall/planner-element.js +2 -5
- package/es/catalog/molding/molding-dcm/planner-element.js +5 -9
- package/es/catalog/molding/molding-fbm/planner-element.js +5 -9
- package/es/catalog/molding/molding-lrm/planner-element.js +5 -9
- package/es/catalog/properties/export.js +20 -31
- package/es/catalog/properties/property-checkbox.js +28 -29
- package/es/catalog/properties/property-color.js +16 -19
- package/es/catalog/properties/property-enum.js +24 -27
- package/es/catalog/properties/property-hidden.js +9 -12
- package/es/catalog/properties/property-lenght-measure.js +38 -41
- package/es/catalog/properties/property-length-measure.js +36 -39
- package/es/catalog/properties/property-length-measure_hole.js +38 -41
- package/es/catalog/properties/property-number.js +17 -20
- package/es/catalog/properties/property-read-only.js +16 -19
- package/es/catalog/properties/property-string.js +16 -19
- package/es/catalog/properties/property-toggle.js +16 -19
- package/es/catalog/properties/shared-property-style.js +1 -3
- package/es/catalog/utils/FuseUtils.js +12 -13
- package/es/catalog/utils/exporter.js +10 -11
- package/es/catalog/utils/geom-utils.js +13 -24
- package/es/catalog/utils/item-loader.js +86 -92
- package/es/catalog/utils/load-obj.js +20 -24
- package/es/catalog/utils/mtl-loader.js +3 -4
- package/es/catalog/utils/obj-loader.js +3 -4
- package/es/class/FuseUtils.js +12 -13
- package/es/class/area.js +24 -24
- package/es/class/export.js +23 -36
- package/es/class/group.js +53 -55
- package/es/class/guide.js +15 -17
- package/es/class/hole.js +83 -85
- package/es/class/item.js +155 -155
- package/es/class/layer.js +59 -61
- package/es/class/line.js +135 -138
- package/es/class/project.js +93 -94
- package/es/class/vertex.js +29 -31
- package/es/components/content.js +19 -23
- package/es/components/disclaimer/disclaimer.js +10 -13
- package/es/components/export.js +8 -13
- package/es/components/style/button.js +25 -25
- package/es/components/style/cancel-button.js +7 -10
- package/es/components/style/content-container.js +11 -12
- package/es/components/style/content-title.js +13 -15
- package/es/components/style/delete-button.js +8 -12
- package/es/components/style/export.js +30 -46
- package/es/components/style/form-block.js +10 -11
- package/es/components/style/form-color-input.js +7 -10
- package/es/components/style/form-label.js +10 -11
- package/es/components/style/form-number-input.js +45 -43
- package/es/components/style/form-number-input_2.js +41 -39
- package/es/components/style/form-select.js +19 -20
- package/es/components/style/form-slider.js +10 -13
- package/es/components/style/form-submit-button.js +8 -12
- package/es/components/style/form-text-input.js +30 -28
- package/es/components/viewer2d/area.js +17 -20
- package/es/components/viewer2d/export.js +30 -46
- package/es/components/viewer2d/grids/grid-horizontal-streak.js +10 -13
- package/es/components/viewer2d/grids/grid-streak.js +10 -13
- package/es/components/viewer2d/grids/grid-vertical-streak.js +10 -13
- package/es/components/viewer2d/grids/grids.js +10 -14
- package/es/components/viewer2d/group.js +15 -19
- package/es/components/viewer2d/item.js +61 -65
- package/es/components/viewer2d/layer.js +23 -26
- package/es/components/viewer2d/line.js +101 -106
- package/es/components/viewer2d/ruler.js +22 -25
- package/es/components/viewer2d/rulerDist.js +21 -24
- package/es/components/viewer2d/rulerX.js +46 -44
- package/es/components/viewer2d/rulerY.js +44 -42
- package/es/components/viewer2d/scene.js +34 -34
- package/es/components/viewer2d/snap.js +13 -17
- package/es/components/viewer2d/state.js +18 -22
- package/es/components/viewer2d/utils.js +24 -33
- package/es/components/viewer2d/vertex.js +8 -12
- package/es/components/viewer2d/viewer2d.js +156 -159
- package/es/components/viewer3d/camera-controls-module/camera-controls.module.js +21 -19
- package/es/components/viewer3d/dcm.js +1 -3
- package/es/components/viewer3d/fbm.js +1 -3
- package/es/components/viewer3d/front3D.js +12 -16
- package/es/components/viewer3d/grid-creator.js +8 -12
- package/es/components/viewer3d/grids/grid-horizontal-streak.js +6 -9
- package/es/components/viewer3d/grids/grid-streak.js +5 -8
- package/es/components/viewer3d/grids/grid-vertical-streak.js +6 -9
- package/es/components/viewer3d/libs/first-person-controls.js +2 -5
- package/es/components/viewer3d/libs/helvetiker_regular.typeface.js +1 -3
- package/es/components/viewer3d/libs/mtl-loader.js +1 -3
- package/es/components/viewer3d/libs/obj-loader.js +1 -3
- package/es/components/viewer3d/libs/orbit-controls.js +2 -4
- package/es/components/viewer3d/libs/pointer-lock-controls.js +2 -4
- package/es/components/viewer3d/lrm.js +1 -3
- package/es/components/viewer3d/model.js +1 -3
- package/es/components/viewer3d/pointer-lock-navigation.js +3 -6
- package/es/components/viewer3d/ruler-utils/itemRect.js +18 -21
- package/es/components/viewer3d/ruler-utils/layer3D.js +59 -62
- package/es/components/viewer3d/ruler-utils/ruler3D.js +42 -43
- package/es/components/viewer3d/ruler-utils/scene3D.js +9 -13
- package/es/components/viewer3d/ruler-utils/state3D.js +4 -7
- package/es/components/viewer3d/scene-creator.js +197 -223
- package/es/components/viewer3d/three-memory-cleaner.js +3 -7
- package/es/components/viewer3d/viewer3d-first-person.js +42 -42
- package/es/components/viewer3d/viewer3d.js +200 -198
- package/es/constants.js +349 -354
- package/es/index.js +7 -11
- package/es/models.js +193 -191
- package/es/plugins/SVGLoader.js +48 -49
- package/es/plugins/autosave.js +3 -5
- package/es/plugins/console-debugger.js +6 -7
- package/es/plugins/export.js +8 -13
- package/es/plugins/keyboard.js +29 -31
- package/es/reducers/areas-reducer.js +7 -9
- package/es/reducers/export.js +24 -37
- package/es/reducers/groups-reducer.js +31 -33
- package/es/reducers/holes-reducer.js +43 -45
- package/es/reducers/items-reducer.js +106 -108
- package/es/reducers/lines-reducer.js +28 -30
- package/es/reducers/project-reducer.js +105 -107
- package/es/reducers/reducer.js +16 -19
- package/es/reducers/scene-reducer.js +15 -17
- package/es/reducers/user-reducer.js +5 -7
- package/es/reducers/vertices-reducer.js +11 -13
- package/es/reducers/viewer2d-reducer.js +18 -20
- package/es/reducers/viewer3d-reducer.js +16 -18
- package/es/shared-style.js +10 -12
- package/es/styles/export.js +3 -6
- package/es/translator/en.js +1 -3
- package/es/translator/it.js +1 -3
- package/es/translator/ru.js +1 -3
- package/es/translator/translator.js +13 -15
- package/es/utils/browser.js +2 -5
- package/es/utils/convert-units-lite.js +1 -3
- package/es/utils/email-validator.js +1 -3
- package/es/utils/export.js +15 -29
- package/es/utils/geometry.js +190 -280
- package/es/utils/get-edges-of-subgraphs.js +2 -5
- package/es/utils/graph-cycles.js +8 -7
- package/es/utils/graph-inner-cycles.js +10 -14
- package/es/utils/graph.js +9 -13
- package/es/utils/helper.js +41 -58
- package/es/utils/history.js +8 -11
- package/es/utils/id-broker.js +8 -11
- package/es/utils/logger.js +1 -3
- package/es/utils/math.js +5 -8
- package/es/utils/molding.js +130 -146
- package/es/utils/name-generator.js +7 -9
- package/es/utils/objects-utils.js +7 -14
- package/es/utils/phone-validator.js +1 -3
- package/es/utils/process-black-list.js +5 -6
- package/es/utils/react-if.js +7 -9
- package/es/utils/snap-scene.js +27 -30
- package/es/utils/snap.js +53 -57
- package/es/utils/summarizeCart.js +1 -3
- package/es/utils/threeCSG.es6.js +13 -17
- package/es/version.js +1 -3
- package/package.json +1 -1
package/es/class/line.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _export2 = require("../utils/export");
|
|
11
|
-
var Three = _interopRequireWildcard(require("three"));
|
|
12
|
-
var _constants = require("../constants");
|
|
13
|
-
var _helper = require("../utils/helper");
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import { fromJS, List, Map } from 'immutable';
|
|
5
|
+
import { Group, Hole, Layer, Vertex } from "./export";
|
|
6
|
+
import { GeometryUtils, history, IDBroker, NameGenerator, SnapSceneUtils, SnapUtils } from "../utils/export";
|
|
7
|
+
import * as Three from 'three';
|
|
8
|
+
import { END_DRAGGING_LINE, END_DRAGGING_VERTEX, END_DRAWING_LINE, EPSILON, MIN_ANGLE_DISALLOW_DRAW_WALL, MODE_DRAGGING_LINE, MODE_DRAWING_LINE, MODE_IDLE, MODE_WAITING_DRAWING_LINE, UNIT_ANGLE } from "../constants";
|
|
9
|
+
import { isEmpty } from "../utils/helper";
|
|
14
10
|
var timeGlobal = 0;
|
|
15
11
|
var TimeRecorder = /*#__PURE__*/function () {
|
|
16
12
|
function TimeRecorder(name) {
|
|
17
|
-
(
|
|
13
|
+
_classCallCheck(this, TimeRecorder);
|
|
18
14
|
this.name = name;
|
|
19
15
|
if (name === 'beginDrawingLine') {
|
|
20
16
|
console.log('time__ Start Drawing');
|
|
21
17
|
}
|
|
22
18
|
}
|
|
23
|
-
return (
|
|
19
|
+
return _createClass(TimeRecorder, [{
|
|
24
20
|
key: "start",
|
|
25
21
|
value: function start() {
|
|
26
22
|
this.first = Date.now();
|
|
@@ -39,11 +35,11 @@ var TimeRecorder = /*#__PURE__*/function () {
|
|
|
39
35
|
}
|
|
40
36
|
}]);
|
|
41
37
|
}();
|
|
42
|
-
var Line =
|
|
38
|
+
var Line = /*#__PURE__*/function () {
|
|
43
39
|
function Line() {
|
|
44
|
-
(
|
|
40
|
+
_classCallCheck(this, Line);
|
|
45
41
|
}
|
|
46
|
-
return (
|
|
42
|
+
return _createClass(Line, null, [{
|
|
47
43
|
key: "create",
|
|
48
44
|
value: function create(state, layerID, type, x0, y0, x1, y1, properties) {
|
|
49
45
|
var lineCreatedDateTime = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : new Date().getTime();
|
|
@@ -52,18 +48,18 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
52
48
|
// return { updatedState: state };
|
|
53
49
|
// }
|
|
54
50
|
// ///////////////
|
|
55
|
-
var lineID =
|
|
56
|
-
var _Vertex$add =
|
|
51
|
+
var lineID = IDBroker.acquireID();
|
|
52
|
+
var _Vertex$add = Vertex.add(state, layerID, x0, y0, 'lines', lineID),
|
|
57
53
|
stateV0 = _Vertex$add.updatedState,
|
|
58
54
|
v0 = _Vertex$add.vertex;
|
|
59
|
-
var _Vertex$add2 =
|
|
55
|
+
var _Vertex$add2 = Vertex.add(stateV0, layerID, x1, y1, 'lines', lineID),
|
|
60
56
|
stateV1 = _Vertex$add2.updatedState,
|
|
61
57
|
v1 = _Vertex$add2.vertex;
|
|
62
58
|
state = stateV1;
|
|
63
59
|
var line = state.catalog.factoryElement(type, {
|
|
64
60
|
id: lineID,
|
|
65
|
-
name:
|
|
66
|
-
vertices: new
|
|
61
|
+
name: NameGenerator.generateName('lines', state.catalog.getIn(['elements', type, 'info', 'title'])),
|
|
62
|
+
vertices: new List([v0.id, v1.id]),
|
|
67
63
|
type: type
|
|
68
64
|
}, properties);
|
|
69
65
|
line = line.set('createdDateTime', lineCreatedDateTime !== undefined ? lineCreatedDateTime : new Date().getTime());
|
|
@@ -85,7 +81,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
85
81
|
value: function select(state, layerID, lineID) {
|
|
86
82
|
var _line$vertices, _line$vertices$get, _line$vertices2, _line$vertices2$get;
|
|
87
83
|
// Try selecting the layer first
|
|
88
|
-
var layerResult =
|
|
84
|
+
var layerResult = Layer.select(state, layerID);
|
|
89
85
|
if (!layerResult || !layerResult.updatedState) {
|
|
90
86
|
return {
|
|
91
87
|
updatedState: state
|
|
@@ -102,7 +98,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
102
98
|
}
|
|
103
99
|
|
|
104
100
|
// Select the line element
|
|
105
|
-
var lineSelectResult =
|
|
101
|
+
var lineSelectResult = Layer.selectElement(state, layerID, 'lines', lineID);
|
|
106
102
|
if (lineSelectResult !== null && lineSelectResult !== void 0 && lineSelectResult.updatedState) {
|
|
107
103
|
state = lineSelectResult.updatedState;
|
|
108
104
|
}
|
|
@@ -110,7 +106,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
110
106
|
// Select the first vertex (if available)
|
|
111
107
|
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);
|
|
112
108
|
if (firstVertex !== undefined) {
|
|
113
|
-
var v1Result =
|
|
109
|
+
var v1Result = Layer.selectElement(state, layerID, 'vertices', firstVertex);
|
|
114
110
|
if (v1Result !== null && v1Result !== void 0 && v1Result.updatedState) {
|
|
115
111
|
state = v1Result.updatedState;
|
|
116
112
|
}
|
|
@@ -119,7 +115,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
119
115
|
// Select the second vertex (if available)
|
|
120
116
|
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);
|
|
121
117
|
if (secondVertex !== undefined) {
|
|
122
|
-
var v2Result =
|
|
118
|
+
var v2Result = Layer.selectElement(state, layerID, 'vertices', secondVertex);
|
|
123
119
|
if (v2Result !== null && v2Result !== void 0 && v2Result.updatedState) {
|
|
124
120
|
state = v2Result.updatedState;
|
|
125
121
|
}
|
|
@@ -135,14 +131,14 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
135
131
|
if (line) {
|
|
136
132
|
state = this.unselect(state, layerID, lineID).updatedState;
|
|
137
133
|
line.holes.forEach(function (holeID) {
|
|
138
|
-
return state =
|
|
134
|
+
return state = Hole.remove(state, layerID, holeID).updatedState;
|
|
139
135
|
});
|
|
140
|
-
state =
|
|
136
|
+
state = Layer.removeElement(state, layerID, 'lines', lineID).updatedState;
|
|
141
137
|
line.vertices.forEach(function (vertexID) {
|
|
142
|
-
return state =
|
|
138
|
+
return state = Vertex.remove(state, layerID, vertexID, 'lines', lineID).updatedState;
|
|
143
139
|
});
|
|
144
140
|
state.getIn(['scene', 'groups']).forEach(function (group) {
|
|
145
|
-
return state =
|
|
141
|
+
return state = Group.removeElement(state, group.id, layerID, 'lines', lineID).updatedState;
|
|
146
142
|
});
|
|
147
143
|
}
|
|
148
144
|
return {
|
|
@@ -172,9 +168,9 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
172
168
|
value: function unselect(state, layerID, lineID) {
|
|
173
169
|
var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
|
|
174
170
|
if (line) {
|
|
175
|
-
state =
|
|
176
|
-
state =
|
|
177
|
-
state =
|
|
171
|
+
state = Layer.unselect(state, layerID, 'vertices', line.vertices.get(0)).updatedState;
|
|
172
|
+
state = Layer.unselect(state, layerID, 'vertices', line.vertices.get(1)).updatedState;
|
|
173
|
+
state = Layer.unselect(state, layerID, 'lines', lineID).updatedState;
|
|
178
174
|
}
|
|
179
175
|
return {
|
|
180
176
|
updatedState: state
|
|
@@ -197,8 +193,8 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
197
193
|
stateL2 = _Line$create2.updatedState,
|
|
198
194
|
line1 = _Line$create2.line;
|
|
199
195
|
state = stateL2;
|
|
200
|
-
var splitPointOffset =
|
|
201
|
-
var minVertex =
|
|
196
|
+
var splitPointOffset = GeometryUtils.pointPositionOnLineSegment(x0, y0, x1, y1, x, y);
|
|
197
|
+
var minVertex = GeometryUtils.minVertex(v0, v1);
|
|
202
198
|
line.holes.forEach(function (holeID) {
|
|
203
199
|
var hole = state.getIn(['scene', 'layers', layerID, 'holes', holeID]);
|
|
204
200
|
var holeOffset = hole.offset;
|
|
@@ -213,7 +209,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
213
209
|
offset = 1 - offset;
|
|
214
210
|
}
|
|
215
211
|
*/
|
|
216
|
-
state =
|
|
212
|
+
state = Hole.create(state, layerID, hole.type, line0.id, offset, hole.properties).updatedState;
|
|
217
213
|
} else {
|
|
218
214
|
var _offset = (holeOffset - splitPointOffset) / (1 - splitPointOffset);
|
|
219
215
|
/*
|
|
@@ -221,7 +217,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
221
217
|
offset = 1 - offset;
|
|
222
218
|
}
|
|
223
219
|
*/
|
|
224
|
-
state =
|
|
220
|
+
state = Hole.create(state, layerID, hole.type, line1.id, _offset, hole.properties).updatedState;
|
|
225
221
|
}
|
|
226
222
|
});
|
|
227
223
|
|
|
@@ -231,13 +227,13 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
231
227
|
return lines && lines.contains(lineID);
|
|
232
228
|
});
|
|
233
229
|
lineGroups.forEach(function (group) {
|
|
234
|
-
state =
|
|
235
|
-
state =
|
|
230
|
+
state = Group.addElement(state, group.id, layerID, 'lines', line0.id).updatedState;
|
|
231
|
+
state = Group.addElement(state, group.id, layerID, 'lines', line1.id).updatedState;
|
|
236
232
|
});
|
|
237
233
|
state = Line.remove(state, layerID, lineID).updatedState;
|
|
238
234
|
return {
|
|
239
235
|
updatedState: state,
|
|
240
|
-
lines: new
|
|
236
|
+
lines: new List([line0, line1])
|
|
241
237
|
};
|
|
242
238
|
}
|
|
243
239
|
}, {
|
|
@@ -245,7 +241,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
245
241
|
value: function addFromPoints(state, layerID, type, points, properties, holes) {
|
|
246
242
|
var _this = this;
|
|
247
243
|
var lineCreatedDateTime = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new Date().getTime();
|
|
248
|
-
points = new
|
|
244
|
+
points = new List(points).sort(function (_ref, _ref2) {
|
|
249
245
|
var x1 = _ref.x,
|
|
250
246
|
y1 = _ref.y;
|
|
251
247
|
var x2 = _ref2.x,
|
|
@@ -253,7 +249,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
253
249
|
return x1 === x2 ? y1 - y2 : x1 - x2;
|
|
254
250
|
});
|
|
255
251
|
var pointsPair = points.zip(points.skip(1)).filterNot(function (_ref3) {
|
|
256
|
-
var _ref4 = (
|
|
252
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
257
253
|
_ref4$ = _ref4[0],
|
|
258
254
|
x1 = _ref4$.x,
|
|
259
255
|
y1 = _ref4$.y,
|
|
@@ -264,7 +260,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
264
260
|
});
|
|
265
261
|
var lines = [];
|
|
266
262
|
pointsPair.forEach(function (_ref5) {
|
|
267
|
-
var _ref6 = (
|
|
263
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
268
264
|
_ref6$ = _ref6[0],
|
|
269
265
|
x1 = _ref6$.x,
|
|
270
266
|
y1 = _ref6$.y,
|
|
@@ -275,10 +271,10 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
275
271
|
stateL = _this$create.updatedState,
|
|
276
272
|
line = _this$create.line;
|
|
277
273
|
state = stateL;
|
|
278
|
-
var lineLength =
|
|
279
|
-
var alpha =
|
|
280
|
-
var cosAlpha =
|
|
281
|
-
var sinAlpha =
|
|
274
|
+
var lineLength = GeometryUtils.pointsDistance(x1, y1, x2, y2);
|
|
275
|
+
var alpha = GeometryUtils.absAngleBetweenTwoPoints(x1, y1, x2, y2);
|
|
276
|
+
var cosAlpha = GeometryUtils.cosWithThreshold(Math.abs(alpha), 0.0000001);
|
|
277
|
+
var sinAlpha = GeometryUtils.sinWithThreshold(Math.abs(alpha), 0.0000001);
|
|
282
278
|
if (holes) {
|
|
283
279
|
holes.forEach(function (holeWithOffsetPoint) {
|
|
284
280
|
var offset = holeWithOffsetPoint.hole.toJS().offset;
|
|
@@ -286,16 +282,16 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
286
282
|
var _holeWithOffsetPoint$ = holeWithOffsetPoint.offsetPosition,
|
|
287
283
|
xp = _holeWithOffsetPoint$.x,
|
|
288
284
|
yp = _holeWithOffsetPoint$.y;
|
|
289
|
-
if (
|
|
290
|
-
var newOffset =
|
|
285
|
+
if (GeometryUtils.isPointOnLineSegment(x1, y1, x2, y2, xp, yp)) {
|
|
286
|
+
var newOffset = GeometryUtils.pointPositionOnLineSegment(x1, y1, x2, y2, xp, yp);
|
|
291
287
|
if (newOffset >= 0 && newOffset <= 1) {
|
|
292
288
|
//add the position of hole
|
|
293
|
-
var temp =
|
|
289
|
+
var temp = Hole.create(state, layerID, holeWithOffsetPoint.hole.type, line.id, newOffset, holeWithOffsetPoint.hole.properties, xp, yp);
|
|
294
290
|
state = temp.updatedState;
|
|
295
291
|
var holeX = 0,
|
|
296
292
|
holeY = 0,
|
|
297
293
|
holeID = temp.hole.id;
|
|
298
|
-
if (
|
|
294
|
+
if (GeometryUtils.almostEqual(y1, y2)) {
|
|
299
295
|
if (x1 > x2) {
|
|
300
296
|
holeX = x1 - lineLength * newOffset;
|
|
301
297
|
holeY = y1;
|
|
@@ -303,7 +299,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
303
299
|
holeX = x1 + lineLength * newOffset;
|
|
304
300
|
holeY = y1;
|
|
305
301
|
}
|
|
306
|
-
} else if (
|
|
302
|
+
} else if (GeometryUtils.almostEqual(x1, x2)) {
|
|
307
303
|
if (y1 > y2) {
|
|
308
304
|
holeX = x1;
|
|
309
305
|
holeY = y1 - lineLength * newOffset;
|
|
@@ -338,7 +334,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
338
334
|
});
|
|
339
335
|
return {
|
|
340
336
|
updatedState: state,
|
|
341
|
-
lines: new
|
|
337
|
+
lines: new List(lines),
|
|
342
338
|
newline: lines[0]
|
|
343
339
|
};
|
|
344
340
|
}
|
|
@@ -358,21 +354,21 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
358
354
|
var _line$vertices$map$to = line.vertices.map(function (vertexID) {
|
|
359
355
|
return reducedState.getIn(['scene', 'layers', layerID, 'vertices']).get(vertexID);
|
|
360
356
|
}).toArray(),
|
|
361
|
-
_line$vertices$map$to2 = (
|
|
357
|
+
_line$vertices$map$to2 = _slicedToArray(_line$vertices$map$to, 2),
|
|
362
358
|
v0 = _line$vertices$map$to2[0],
|
|
363
359
|
v1 = _line$vertices$map$to2[1];
|
|
364
|
-
var hasCommonEndpoint =
|
|
365
|
-
var intersection =
|
|
360
|
+
var hasCommonEndpoint = GeometryUtils.samePoints(v0, points[0]) || GeometryUtils.samePoints(v0, points[1]) || GeometryUtils.samePoints(v1, points[0]) || GeometryUtils.samePoints(v1, points[1]);
|
|
361
|
+
var intersection = GeometryUtils.twoLineSegmentsIntersection(points[0], points[1], v0, v1);
|
|
366
362
|
if (intersection.type === 'colinear') {
|
|
367
363
|
if (!oldHoles) {
|
|
368
364
|
oldHoles = [];
|
|
369
365
|
}
|
|
370
|
-
var orderedVertices =
|
|
366
|
+
var orderedVertices = GeometryUtils.orderVertices(points);
|
|
371
367
|
reducedState.getIn(['scene', 'layers', layerID, 'lines', line.id, 'holes']).forEach(function (holeID) {
|
|
372
368
|
var hole = reducedState.getIn(['scene', 'layers', layerID, 'holes', holeID]);
|
|
373
|
-
var oldLineLength =
|
|
374
|
-
var offset =
|
|
375
|
-
var offsetPosition =
|
|
369
|
+
var oldLineLength = GeometryUtils.pointsDistance(v0.x, v0.y, v1.x, v1.y);
|
|
370
|
+
var offset = GeometryUtils.samePoints(orderedVertices[1], line.vertices.get(1)) ? 1 - hole.offset : hole.offset;
|
|
371
|
+
var offsetPosition = GeometryUtils.extendLine(v0.x, v0.y, v1.x, v1.y, oldLineLength * offset);
|
|
376
372
|
oldHoles.push({
|
|
377
373
|
hole: hole,
|
|
378
374
|
offsetPosition: offsetPosition
|
|
@@ -401,8 +397,8 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
401
397
|
key: "replaceVertex",
|
|
402
398
|
value: function replaceVertex(state, layerID, lineID, vertexIndex, x, y) {
|
|
403
399
|
var vertexID = state.getIn(['scene', 'layers', layerID, 'lines', lineID, 'vertices', vertexIndex]);
|
|
404
|
-
state =
|
|
405
|
-
var _Vertex$add3 =
|
|
400
|
+
state = Vertex.remove(state, layerID, vertexID, 'lines', lineID).updatedState;
|
|
401
|
+
var _Vertex$add3 = Vertex.add(state, layerID, x, y, 'lines', lineID),
|
|
406
402
|
stateV = _Vertex$add3.updatedState,
|
|
407
403
|
vertex = _Vertex$add3.vertex;
|
|
408
404
|
state = stateV;
|
|
@@ -418,8 +414,8 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
418
414
|
key: "selectToolDrawingLine",
|
|
419
415
|
value: function selectToolDrawingLine(state, sceneComponentType) {
|
|
420
416
|
state = state.merge({
|
|
421
|
-
mode:
|
|
422
|
-
drawingSupport: new
|
|
417
|
+
mode: MODE_WAITING_DRAWING_LINE,
|
|
418
|
+
drawingSupport: new Map({
|
|
423
419
|
type: sceneComponentType
|
|
424
420
|
})
|
|
425
421
|
});
|
|
@@ -431,16 +427,16 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
431
427
|
key: "beginDrawingLine",
|
|
432
428
|
value: function beginDrawingLine(state, layerID, x, y) {
|
|
433
429
|
// if end drawing by created area
|
|
434
|
-
if (state.mode ==
|
|
430
|
+
if (state.mode == MODE_IDLE) {
|
|
435
431
|
return {
|
|
436
432
|
updatedState: state
|
|
437
433
|
};
|
|
438
434
|
}
|
|
439
435
|
// ///////////////
|
|
440
|
-
var snapElements =
|
|
436
|
+
var snapElements = SnapSceneUtils.sceneSnapElements(state.scene, new List(), state.snapMask);
|
|
441
437
|
var snap = null;
|
|
442
438
|
if (state.snapMask && !state.snapMask.isEmpty()) {
|
|
443
|
-
snap =
|
|
439
|
+
snap = SnapUtils.nearestSnap(snapElements, x, y, state.snapMask);
|
|
444
440
|
if (snap) {
|
|
445
441
|
var _snap$point = snap.point;
|
|
446
442
|
x = _snap$point.x;
|
|
@@ -448,36 +444,36 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
448
444
|
}
|
|
449
445
|
snapElements = snapElements.withMutations(function (snapElements) {
|
|
450
446
|
var a, b, c;
|
|
451
|
-
var _GeometryUtils$horizo =
|
|
447
|
+
var _GeometryUtils$horizo = GeometryUtils.horizontalLine(y);
|
|
452
448
|
a = _GeometryUtils$horizo.a;
|
|
453
449
|
b = _GeometryUtils$horizo.b;
|
|
454
450
|
c = _GeometryUtils$horizo.c;
|
|
455
|
-
|
|
456
|
-
var _GeometryUtils$vertic =
|
|
451
|
+
SnapUtils.addLineSnap(snapElements, a, b, c, 10, 3, null);
|
|
452
|
+
var _GeometryUtils$vertic = GeometryUtils.verticalLine(x);
|
|
457
453
|
a = _GeometryUtils$vertic.a;
|
|
458
454
|
b = _GeometryUtils$vertic.b;
|
|
459
455
|
c = _GeometryUtils$vertic.c;
|
|
460
|
-
|
|
461
|
-
var _GeometryUtils$upcros =
|
|
456
|
+
SnapUtils.addLineSnap(snapElements, a, b, c, 10, 3, null);
|
|
457
|
+
var _GeometryUtils$upcros = GeometryUtils.upcrossLine(x, y);
|
|
462
458
|
a = _GeometryUtils$upcros.a;
|
|
463
459
|
b = _GeometryUtils$upcros.b;
|
|
464
460
|
c = _GeometryUtils$upcros.c;
|
|
465
|
-
|
|
466
|
-
var _GeometryUtils$downcr =
|
|
461
|
+
SnapUtils.addLineSnap(snapElements, a, b, c, 10, 3, null);
|
|
462
|
+
var _GeometryUtils$downcr = GeometryUtils.downcrossLine(x, y);
|
|
467
463
|
a = _GeometryUtils$downcr.a;
|
|
468
464
|
b = _GeometryUtils$downcr.b;
|
|
469
465
|
c = _GeometryUtils$downcr.c;
|
|
470
|
-
|
|
466
|
+
SnapUtils.addLineSnap(snapElements, a, b, c, 10, 3, null);
|
|
471
467
|
});
|
|
472
468
|
}
|
|
473
469
|
var drawingSupport = state.get('drawingSupport').set('layerID', layerID);
|
|
474
|
-
state =
|
|
470
|
+
state = Layer.unselectAll(state, layerID).updatedState;
|
|
475
471
|
var _Line$create3 = Line.create(state, layerID, drawingSupport.get('type'), x, y, x, y),
|
|
476
472
|
stateL = _Line$create3.updatedState,
|
|
477
473
|
line = _Line$create3.line;
|
|
478
474
|
state = Line.select(stateL, layerID, line.id).updatedState;
|
|
479
475
|
state = state.merge({
|
|
480
|
-
mode:
|
|
476
|
+
mode: MODE_DRAWING_LINE,
|
|
481
477
|
snapElements: snapElements,
|
|
482
478
|
activeSnapElement: snap ? snap.snap : null,
|
|
483
479
|
drawingSupport: drawingSupport
|
|
@@ -491,7 +487,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
491
487
|
value: function updateDrawingLine(state, x, y, relatedLines) {
|
|
492
488
|
var snap = null;
|
|
493
489
|
if (state.snapMask && !state.snapMask.isEmpty()) {
|
|
494
|
-
snap =
|
|
490
|
+
snap = SnapUtils.nearestSnap(state.snapElements, x, y, state.snapMask);
|
|
495
491
|
if (snap) {
|
|
496
492
|
var _snap$point2 = snap.point;
|
|
497
493
|
x = _snap$point2.x;
|
|
@@ -507,7 +503,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
507
503
|
var moveFlag = true;
|
|
508
504
|
var tx = vertices[drawingLine.vertices[1]].x;
|
|
509
505
|
var ty = vertices[drawingLine.vertices[1]].y;
|
|
510
|
-
if (!
|
|
506
|
+
if (!isEmpty(relatedLines)) {
|
|
511
507
|
vertices[drawingLine.vertices[1]].x = x;
|
|
512
508
|
vertices[drawingLine.vertices[1]].y = y;
|
|
513
509
|
}
|
|
@@ -517,12 +513,12 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
517
513
|
if (drawingLine.vertices[0] !== drawingLine.vertices[1]) {
|
|
518
514
|
relatedLines.forEach(function (line) {
|
|
519
515
|
// get the points of two lines(drawing line and related line)
|
|
520
|
-
if (!
|
|
516
|
+
if (!isEmpty(line)) {
|
|
521
517
|
// the angle between two lines(line, drawingLine)
|
|
522
|
-
lineAngle =
|
|
518
|
+
lineAngle = GeometryUtils.angleBetweenTwoLines(line, drawingLine, vertices);
|
|
523
519
|
// check whether the angle is less than or bigger than specific value.
|
|
524
520
|
absAngle = Math.abs(lineAngle);
|
|
525
|
-
if (absAngle <
|
|
521
|
+
if (absAngle < MIN_ANGLE_DISALLOW_DRAW_WALL || absAngle > 360 - MIN_ANGLE_DISALLOW_DRAW_WALL) {
|
|
526
522
|
moveFlag = false;
|
|
527
523
|
} else moveFlag = true;
|
|
528
524
|
}
|
|
@@ -534,20 +530,20 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
534
530
|
tx = x;
|
|
535
531
|
ty = y;
|
|
536
532
|
} else {
|
|
537
|
-
var rest =
|
|
533
|
+
var rest = MIN_ANGLE_DISALLOW_DRAW_WALL - absAngle;
|
|
538
534
|
// the origin point of rotation(snapping)
|
|
539
535
|
var ox = vertices[drawingLine.vertices[0]].x;
|
|
540
536
|
var oy = vertices[drawingLine.vertices[0]].y;
|
|
541
537
|
// determine the direction of rotation.
|
|
542
538
|
rest = lineAngle > 0 ? -rest : rest;
|
|
543
539
|
// rotate the current point to last point around the first point of drawing line.
|
|
544
|
-
var res =
|
|
540
|
+
var res = GeometryUtils.rotatePointAroundPoint(x, y, ox, oy, rest);
|
|
545
541
|
tx = res.x;
|
|
546
542
|
ty = res.y;
|
|
547
543
|
}
|
|
548
544
|
// angle snapping as a value of UNIT_ANGLE
|
|
549
|
-
if (moveFlag && !
|
|
550
|
-
var result =
|
|
545
|
+
if (moveFlag && !isEmpty(absAngle) && absAngle % UNIT_ANGLE !== 0) {
|
|
546
|
+
var result = GeometryUtils.snapAngleByUnit(lineAngle, vertices, drawingLine, tx, ty, drawingLine.vertices[1]);
|
|
551
547
|
tx = result.x;
|
|
552
548
|
ty = result.y;
|
|
553
549
|
}
|
|
@@ -577,9 +573,9 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
577
573
|
var _layer$lines$get;
|
|
578
574
|
var holeOffset = [];
|
|
579
575
|
(_layer$lines$get = layer.lines.get(lineID)) === null || _layer$lines$get === void 0 || _layer$lines$get.holes.forEach(function (holeID) {
|
|
580
|
-
var lineLength =
|
|
581
|
-
var minV =
|
|
582
|
-
var maxV =
|
|
576
|
+
var lineLength = GeometryUtils.pointsDistance(nv0.x, nv0.y, nv1.x, nv1.y);
|
|
577
|
+
var minV = GeometryUtils.minVertex(nv0, nv1);
|
|
578
|
+
var maxV = GeometryUtils.maxVertex(nv0, nv1);
|
|
583
579
|
var alpha = Math.atan2(maxV.y - minV.y, maxV.x - minV.x);
|
|
584
580
|
var hole = layer.holes.get(holeID);
|
|
585
581
|
var pointOnLine = lineLength * hole.offset;
|
|
@@ -620,7 +616,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
620
616
|
return mgline.id === lineID;
|
|
621
617
|
});
|
|
622
618
|
});
|
|
623
|
-
if (!
|
|
619
|
+
if (!isEmpty(relatedLineID)) {
|
|
624
620
|
var relatedLine = layer.lines.get(relatedLineID[0]);
|
|
625
621
|
var intersectionPoint = vertex;
|
|
626
622
|
var startPoint, endPoint;
|
|
@@ -637,8 +633,8 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
637
633
|
var tline2 = {
|
|
638
634
|
vertices: [intersectionPoint.id, endPoint.id]
|
|
639
635
|
};
|
|
640
|
-
var angle = Math.abs(
|
|
641
|
-
if (Math.abs(angle - 180) <=
|
|
636
|
+
var angle = Math.abs(GeometryUtils.angleBetweenTwoLines(tline1, tline2, allVertices.toJS()));
|
|
637
|
+
if (Math.abs(angle - 180) <= EPSILON) {
|
|
642
638
|
selectedLineInfo.mergelines.push(relatedLine);
|
|
643
639
|
selectedLineInfo.points[0] = startPoint;
|
|
644
640
|
selectedLineInfo.points[1] = endPoint;
|
|
@@ -656,7 +652,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
656
652
|
var allVertices = state.getIn(['scene', 'layers', layerID, 'vertices']);
|
|
657
653
|
var lineID = state.getIn(['scene', 'layers', layerID, 'selected', 'lines']).first();
|
|
658
654
|
var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
|
|
659
|
-
if (
|
|
655
|
+
if (isEmpty(line)) {
|
|
660
656
|
return {
|
|
661
657
|
updatedState: state
|
|
662
658
|
};
|
|
@@ -688,13 +684,13 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
688
684
|
var holesWithOffsetPosition = [];
|
|
689
685
|
var lineID = layer.getIn(['selected', 'lines']).first(); // lines : [id]
|
|
690
686
|
var line = layer.getIn(['lines', lineID]);
|
|
691
|
-
if (
|
|
687
|
+
if (isEmpty(line)) {
|
|
692
688
|
return {
|
|
693
689
|
updatedState: state
|
|
694
690
|
};
|
|
695
691
|
}
|
|
696
692
|
mergeInfo.mergelines.forEach(function (line) {
|
|
697
|
-
if ([
|
|
693
|
+
if ([END_DRAGGING_LINE, END_DRAGGING_VERTEX].includes(actionType)) {
|
|
698
694
|
var tmpGroups = state //get groups membership if present
|
|
699
695
|
.getIn(['scene', 'groups']).filter(function (group) {
|
|
700
696
|
var lines = group.getIn(['elements', layerID, 'lines']);
|
|
@@ -713,20 +709,20 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
713
709
|
state = Line.remove(state, layerID, line.id).updatedState;
|
|
714
710
|
});
|
|
715
711
|
var ret;
|
|
716
|
-
if (!
|
|
712
|
+
if (!GeometryUtils.samePoints(mergeInfo.points[0], mergeInfo.points[1])) {
|
|
717
713
|
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);
|
|
718
714
|
state = ret.updatedState;
|
|
719
715
|
}
|
|
720
|
-
if ([
|
|
716
|
+
if ([END_DRAGGING_LINE, END_DRAGGING_VERTEX].includes(actionType)) {
|
|
721
717
|
//re-add to old line's groups if present
|
|
722
718
|
ret.lines.forEach(function (addedLine) {
|
|
723
719
|
lineGroups.forEach(function (oldLineGroup) {
|
|
724
|
-
state =
|
|
720
|
+
state = Group.addElement(state, oldLineGroup.id, layerID, 'lines', addedLine.id).updatedState;
|
|
725
721
|
});
|
|
726
722
|
});
|
|
727
723
|
}
|
|
728
|
-
state =
|
|
729
|
-
if (!
|
|
724
|
+
state = Layer.removeZeroLengthLines(state, layerID).updatedState;
|
|
725
|
+
if (!isEmpty((_ret = ret) === null || _ret === void 0 ? void 0 : _ret.newline)) {
|
|
730
726
|
state = this.select(state, layerID, ret.newline.get('id')).updatedState;
|
|
731
727
|
}
|
|
732
728
|
return {
|
|
@@ -741,10 +737,10 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
741
737
|
var lineID = layer.getIn(['selected', 'lines']).first(); // lines : [id]
|
|
742
738
|
var line = layer.getIn(['lines', lineID]);
|
|
743
739
|
var drawingInfo = {};
|
|
744
|
-
if (!
|
|
740
|
+
if (!isEmpty(line)) {
|
|
745
741
|
drawingInfo.drawingLine = line;
|
|
746
742
|
}
|
|
747
|
-
state =
|
|
743
|
+
state = Layer.detectAndUpdateAreas(state, layerID, drawingInfo).updatedState;
|
|
748
744
|
return {
|
|
749
745
|
updatedState: state
|
|
750
746
|
};
|
|
@@ -766,16 +762,16 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
766
762
|
var layerID = state.getIn(['scene', 'selectedLayer']);
|
|
767
763
|
var lineID = state.getIn(['scene', 'layers', layerID, 'selected', 'lines']).first();
|
|
768
764
|
var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
|
|
769
|
-
if (
|
|
765
|
+
if (isEmpty(line)) {
|
|
770
766
|
return {
|
|
771
767
|
updatedState: state
|
|
772
768
|
};
|
|
773
769
|
}
|
|
774
|
-
if (!
|
|
770
|
+
if (!isEmpty(v0)) {
|
|
775
771
|
state = state.setIn(['scene', 'layers', layerID, 'vertices', line.vertices.get(0), 'x'], v0.x);
|
|
776
772
|
state = state.setIn(['scene', 'layers', layerID, 'vertices', line.vertices.get(0), 'y'], v0.y);
|
|
777
773
|
}
|
|
778
|
-
if (!
|
|
774
|
+
if (!isEmpty(v1)) {
|
|
779
775
|
state = state.setIn(['scene', 'layers', layerID, 'vertices', line.vertices.get(1), 'x'], v1.x);
|
|
780
776
|
state = state.setIn(['scene', 'layers', layerID, 'vertices', line.vertices.get(1), 'y'], v1.y);
|
|
781
777
|
}
|
|
@@ -789,7 +785,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
789
785
|
key: "endDrawingLine",
|
|
790
786
|
value: function endDrawingLine(state, x, y) {
|
|
791
787
|
if (state.snapMask && !state.snapMask.isEmpty()) {
|
|
792
|
-
var snap =
|
|
788
|
+
var snap = SnapUtils.nearestSnap(state.snapElements, x, y, state.snapMask);
|
|
793
789
|
if (snap) {
|
|
794
790
|
var _snap$point3 = snap.point;
|
|
795
791
|
x = _snap$point3.x;
|
|
@@ -802,8 +798,8 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
802
798
|
if (drawingLine.vertices[0] === drawingLine.vertices[1]) {
|
|
803
799
|
state = Line.remove(state, layerID, lineID).updatedState;
|
|
804
800
|
state = state.merge({
|
|
805
|
-
mode:
|
|
806
|
-
snapElements: new
|
|
801
|
+
mode: MODE_IDLE,
|
|
802
|
+
snapElements: new List(),
|
|
807
803
|
activeSnapElement: null
|
|
808
804
|
});
|
|
809
805
|
return {
|
|
@@ -814,10 +810,10 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
814
810
|
x: x,
|
|
815
811
|
y: y
|
|
816
812
|
}, state).updatedState;
|
|
817
|
-
state = this.applyWallChanges(state,
|
|
813
|
+
state = this.applyWallChanges(state, END_DRAWING_LINE).updatedState;
|
|
818
814
|
state = state.merge({
|
|
819
|
-
mode:
|
|
820
|
-
snapElements: new
|
|
815
|
+
mode: MODE_WAITING_DRAWING_LINE,
|
|
816
|
+
snapElements: new List(),
|
|
821
817
|
activeSnapElement: null
|
|
822
818
|
});
|
|
823
819
|
return {
|
|
@@ -827,15 +823,15 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
827
823
|
}, {
|
|
828
824
|
key: "beginDraggingLine",
|
|
829
825
|
value: function beginDraggingLine(state, layerID, lineID, x, y) {
|
|
830
|
-
var snapElements =
|
|
826
|
+
var snapElements = SnapSceneUtils.sceneSnapElements(state.scene, new List(), state.snapMask);
|
|
831
827
|
var layer = state.scene.layers.get(layerID);
|
|
832
828
|
var line = layer.lines.get(lineID);
|
|
833
829
|
var vertex0 = layer.vertices.get(line.vertices.get(0));
|
|
834
830
|
var vertex1 = layer.vertices.get(line.vertices.get(1));
|
|
835
831
|
state = state.merge({
|
|
836
|
-
mode:
|
|
832
|
+
mode: MODE_DRAGGING_LINE,
|
|
837
833
|
snapElements: snapElements,
|
|
838
|
-
draggingSupport:
|
|
834
|
+
draggingSupport: Map({
|
|
839
835
|
layerID: layerID,
|
|
840
836
|
lineID: lineID,
|
|
841
837
|
startPointX: x,
|
|
@@ -873,7 +869,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
873
869
|
var vec1 = pos1.clone().sub(cen).normalize();
|
|
874
870
|
var vec2 = pos2.clone().sub(cen).normalize();
|
|
875
871
|
var angle = Math.floor(vec1.angle() * 180 / Math.PI - vec2.angle() * 180 / Math.PI + 0.5);
|
|
876
|
-
if (Math.abs(angle) <
|
|
872
|
+
if (Math.abs(angle) < MIN_ANGLE_DISALLOW_DRAW_WALL || Math.abs(angle) > 360 - MIN_ANGLE_DISALLOW_DRAW_WALL) {
|
|
877
873
|
mvFlag.push(false);
|
|
878
874
|
} else {
|
|
879
875
|
mvFlag.push(true);
|
|
@@ -913,8 +909,8 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
913
909
|
var curSnap0 = null,
|
|
914
910
|
curSnap1 = null;
|
|
915
911
|
if (state.snapMask && !state.snapMask.isEmpty()) {
|
|
916
|
-
curSnap0 =
|
|
917
|
-
curSnap1 =
|
|
912
|
+
curSnap0 = SnapUtils.nearestSnap(snapElements, newVertex0X, newVertex0Y, state.snapMask);
|
|
913
|
+
curSnap1 = SnapUtils.nearestSnap(snapElements, newVertex1X, newVertex1Y, state.snapMask);
|
|
918
914
|
}
|
|
919
915
|
var deltaX = 0,
|
|
920
916
|
deltaY = 0;
|
|
@@ -998,8 +994,8 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
998
994
|
var newVertex1X = draggingSupport.get('startVertex1X') + diffX;
|
|
999
995
|
var newVertex1Y = draggingSupport.get('startVertex1Y') + diffY;
|
|
1000
996
|
if (state.snapMask && !state.snapMask.isEmpty()) {
|
|
1001
|
-
var curSnap0 =
|
|
1002
|
-
var curSnap1 =
|
|
997
|
+
var curSnap0 = SnapUtils.nearestSnap(state.snapElements, newVertex0X, newVertex0Y, state.snapMask);
|
|
998
|
+
var curSnap1 = SnapUtils.nearestSnap(state.snapElements, newVertex1X, newVertex1Y, state.snapMask);
|
|
1003
999
|
var deltaX = 0,
|
|
1004
1000
|
deltaY = 0;
|
|
1005
1001
|
if (curSnap0 && curSnap1) {
|
|
@@ -1036,9 +1032,9 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
1036
1032
|
newVertex0Y = newResult.newVertex0Y;
|
|
1037
1033
|
newVertex1X = newResult.newVertex1X;
|
|
1038
1034
|
newVertex1Y = newResult.newVertex1Y;
|
|
1039
|
-
state =
|
|
1040
|
-
state =
|
|
1041
|
-
if (
|
|
1035
|
+
state = Layer.mergeEqualsVertices(state, layerID, line.vertices.get(0)).updatedState;
|
|
1036
|
+
state = Layer.mergeEqualsVertices(state, layerID, line.vertices.get(1)).updatedState;
|
|
1037
|
+
if (GeometryUtils.samePoints({
|
|
1042
1038
|
newVertex0X: newVertex0X,
|
|
1043
1039
|
newVertex0Y: newVertex0Y
|
|
1044
1040
|
}, {
|
|
@@ -1054,13 +1050,13 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
1054
1050
|
x: newVertex1X,
|
|
1055
1051
|
y: newVertex1Y
|
|
1056
1052
|
}, state).updatedState;
|
|
1057
|
-
state = this.applyWallChanges(state,
|
|
1053
|
+
state = this.applyWallChanges(state, END_DRAGGING_LINE).updatedState;
|
|
1058
1054
|
}
|
|
1059
1055
|
state = state.merge({
|
|
1060
|
-
mode:
|
|
1056
|
+
mode: MODE_IDLE,
|
|
1061
1057
|
draggingSupport: null,
|
|
1062
1058
|
activeSnapElement: null,
|
|
1063
|
-
snapElements: new
|
|
1059
|
+
snapElements: new List()
|
|
1064
1060
|
});
|
|
1065
1061
|
return {
|
|
1066
1062
|
updatedState: state
|
|
@@ -1077,7 +1073,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
1077
1073
|
}, {
|
|
1078
1074
|
key: "setJsProperties",
|
|
1079
1075
|
value: function setJsProperties(state, layerID, lineID, properties) {
|
|
1080
|
-
return this.setProperties(state, layerID, lineID,
|
|
1076
|
+
return this.setProperties(state, layerID, lineID, fromJS(properties));
|
|
1081
1077
|
}
|
|
1082
1078
|
}, {
|
|
1083
1079
|
key: "updateProperties",
|
|
@@ -1092,7 +1088,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
1092
1088
|
}, {
|
|
1093
1089
|
key: "updateJsProperties",
|
|
1094
1090
|
value: function updateJsProperties(state, layerID, lineID, properties) {
|
|
1095
|
-
return this.updateProperties(state, layerID, lineID,
|
|
1091
|
+
return this.updateProperties(state, layerID, lineID, fromJS(properties));
|
|
1096
1092
|
}
|
|
1097
1093
|
}, {
|
|
1098
1094
|
key: "setAttributes",
|
|
@@ -1111,17 +1107,17 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
1111
1107
|
delete lAttr['lineToExtend'];
|
|
1112
1108
|
delete lAttr['lineLength'];
|
|
1113
1109
|
var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
|
|
1114
|
-
state = state.mergeIn(['scene', 'layers', layerID, 'lines', lineID],
|
|
1110
|
+
state = state.mergeIn(['scene', 'layers', layerID, 'lines', lineID], fromJS(lAttr)).mergeIn(['scene', 'layers', layerID, 'vertices', vertexOne.id], {
|
|
1115
1111
|
x: vertexOne.x,
|
|
1116
1112
|
y: vertexOne.y
|
|
1117
1113
|
}).mergeIn(['scene', 'layers', layerID, 'vertices', vertexTwo.id], {
|
|
1118
1114
|
x: vertexTwo.x,
|
|
1119
1115
|
y: vertexTwo.y
|
|
1120
|
-
}).mergeIn(['scene', 'layers', layerID, 'lines', lineID, 'misc'], new
|
|
1116
|
+
}).mergeIn(['scene', 'layers', layerID, 'lines', lineID, 'misc'], new Map({
|
|
1121
1117
|
_unitLength: lineLength._unit
|
|
1122
1118
|
})).mergeIn(['scene', 'layers', layerID, 'lines', lineID, 'focus'], true);
|
|
1123
1119
|
if (lineToExtend) {
|
|
1124
|
-
state = state.mergeIn(['scene', 'layers', layerID, 'lines', lineToExtend.id],
|
|
1120
|
+
state = state.mergeIn(['scene', 'layers', layerID, 'lines', lineToExtend.id], fromJS(lAttr)).mergeIn(['scene', 'layers', layerID, 'lines', lineToExtend.id, 'misc'], new Map({
|
|
1125
1121
|
_unitLength: lineLength._unit
|
|
1126
1122
|
}));
|
|
1127
1123
|
}
|
|
@@ -1137,14 +1133,14 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
1137
1133
|
y: vertexFour.y
|
|
1138
1134
|
});
|
|
1139
1135
|
}
|
|
1140
|
-
state =
|
|
1136
|
+
state = Layer.mergeEqualsVertices(state, layerID, vertexOne.id).updatedState;
|
|
1141
1137
|
if (vertexOne.x != vertexTwo.x && vertexOne.y != vertexTwo.y) {
|
|
1142
|
-
state =
|
|
1138
|
+
state = Layer.mergeEqualsVertices(state, layerID, vertexTwo.id).updatedState;
|
|
1143
1139
|
}
|
|
1144
1140
|
state = this.select(state, layerID, lineID).updatedState;
|
|
1145
|
-
state = this.applyWallChanges(state,
|
|
1141
|
+
state = this.applyWallChanges(state, END_DRAWING_LINE).updatedState;
|
|
1146
1142
|
state = state.merge({
|
|
1147
|
-
sceneHistory:
|
|
1143
|
+
sceneHistory: history.historyPush(state.sceneHistory, state.scene)
|
|
1148
1144
|
});
|
|
1149
1145
|
if (state.mode.endsWith('_LINE')) {
|
|
1150
1146
|
state = state.setIn(['scene', 'setLineAttributes'], true);
|
|
@@ -1158,11 +1154,11 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
1158
1154
|
key: "setVerticesCoords",
|
|
1159
1155
|
value: function setVerticesCoords(state, layerID, lineID, x1, y1, x2, y2) {
|
|
1160
1156
|
var line = state.getIn(['scene', 'layers', layerID, 'lines', lineID]);
|
|
1161
|
-
state =
|
|
1157
|
+
state = Vertex.setAttributes(state, layerID, line.vertices.get(0), new Map({
|
|
1162
1158
|
x: x1,
|
|
1163
1159
|
y: y1
|
|
1164
1160
|
})).updatedState;
|
|
1165
|
-
state =
|
|
1161
|
+
state = Vertex.setAttributes(state, layerID, line.vertices.get(1), new Map({
|
|
1166
1162
|
x: x2,
|
|
1167
1163
|
y: y2
|
|
1168
1164
|
})).updatedState;
|
|
@@ -1171,4 +1167,5 @@ var Line = exports["default"] = /*#__PURE__*/function () {
|
|
|
1171
1167
|
};
|
|
1172
1168
|
}
|
|
1173
1169
|
}]);
|
|
1174
|
-
}();
|
|
1170
|
+
}();
|
|
1171
|
+
export { Line as default };
|