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