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