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/hole.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _immutable = require("immutable");
|
|
11
|
-
var _export = require("./export");
|
|
12
|
-
var _export2 = require("../utils/export");
|
|
13
|
-
var _snap = require("../utils/snap");
|
|
14
|
-
var _constants = require("../constants");
|
|
15
|
-
var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import { fromJS, List, Map } from 'immutable';
|
|
4
|
+
import { Group, Layer } from "./export";
|
|
5
|
+
import { GeometryUtils, IDBroker } from "../utils/export";
|
|
6
|
+
import { addLineSegmentSnap, nearestSnap } from "../utils/snap";
|
|
7
|
+
import { MODE_DRAGGING_HOLE, MODE_DRAGGING_HOLE_3D, MODE_DRAWING_HOLE, MODE_DRAWING_HOLE_3D, MODE_IDLE, MODE_IDLE_3D } from "../constants";
|
|
8
|
+
var Hole = /*#__PURE__*/function () {
|
|
16
9
|
function Hole() {
|
|
17
|
-
(
|
|
10
|
+
_classCallCheck(this, Hole);
|
|
18
11
|
}
|
|
19
|
-
return (
|
|
12
|
+
return _createClass(Hole, null, [{
|
|
20
13
|
key: "create",
|
|
21
14
|
value: function create(state, layerID, type, lineID, offset, properties, holeX, holeY) {
|
|
22
|
-
var holeID =
|
|
15
|
+
var holeID = IDBroker.acquireID();
|
|
23
16
|
var hole = state.catalog.factoryElement(type, {
|
|
24
17
|
id: holeID,
|
|
25
18
|
url: state.catalog.getIn(['elements', type, 'info', 'url']),
|
|
@@ -80,8 +73,8 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
80
73
|
}, {
|
|
81
74
|
key: "select",
|
|
82
75
|
value: function select(state, layerID, holeID) {
|
|
83
|
-
state =
|
|
84
|
-
state =
|
|
76
|
+
state = Layer.select(state, layerID).updatedState;
|
|
77
|
+
state = Layer.selectElement(state, layerID, 'holes', holeID).updatedState;
|
|
85
78
|
return {
|
|
86
79
|
updatedState: state
|
|
87
80
|
};
|
|
@@ -91,7 +84,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
91
84
|
value: function remove(state, layerID, holeID) {
|
|
92
85
|
var hole = state.getIn(['scene', 'layers', layerID, 'holes', holeID]);
|
|
93
86
|
state = this.unselect(state, layerID, holeID).updatedState;
|
|
94
|
-
state =
|
|
87
|
+
state = Layer.removeElement(state, layerID, 'holes', holeID).updatedState;
|
|
95
88
|
state = state.updateIn(['scene', 'layers', layerID, 'lines', hole.line, 'holes'], function (holes) {
|
|
96
89
|
var index = holes.findIndex(function (ID) {
|
|
97
90
|
return holeID === ID;
|
|
@@ -99,7 +92,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
99
92
|
return index !== -1 ? holes.remove(index) : holes;
|
|
100
93
|
});
|
|
101
94
|
state.getIn(['scene', 'groups']).forEach(function (group) {
|
|
102
|
-
return state =
|
|
95
|
+
return state = Group.removeElement(state, group.id, layerID, 'holes', holeID).updatedState;
|
|
103
96
|
});
|
|
104
97
|
return {
|
|
105
98
|
updatedState: state
|
|
@@ -108,7 +101,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
108
101
|
}, {
|
|
109
102
|
key: "unselect",
|
|
110
103
|
value: function unselect(state, layerID, holeID) {
|
|
111
|
-
state =
|
|
104
|
+
state = Layer.unselect(state, layerID, 'holes', holeID).updatedState;
|
|
112
105
|
return {
|
|
113
106
|
updatedState: state
|
|
114
107
|
};
|
|
@@ -116,7 +109,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
116
109
|
}, {
|
|
117
110
|
key: "selectToolDrawingHole",
|
|
118
111
|
value: function selectToolDrawingHole(state, sceneComponentType) {
|
|
119
|
-
var snapElements = new
|
|
112
|
+
var snapElements = new List().withMutations(function (snapElements) {
|
|
120
113
|
var _state$getIn = state.getIn(['scene', 'layers', state.scene.selectedLayer]),
|
|
121
114
|
lines = _state$getIn.lines,
|
|
122
115
|
vertices = _state$getIn.vertices;
|
|
@@ -127,13 +120,13 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
127
120
|
var _vertices$get2 = vertices.get(line.vertices.get(1)),
|
|
128
121
|
x2 = _vertices$get2.x,
|
|
129
122
|
y2 = _vertices$get2.y;
|
|
130
|
-
|
|
123
|
+
addLineSegmentSnap(snapElements, x1, y1, x2, y2, 20, 1, line.id);
|
|
131
124
|
});
|
|
132
125
|
});
|
|
133
126
|
state = state.merge({
|
|
134
|
-
mode:
|
|
127
|
+
mode: MODE_DRAWING_HOLE,
|
|
135
128
|
snapElements: snapElements,
|
|
136
|
-
drawingSupport:
|
|
129
|
+
drawingSupport: Map({
|
|
137
130
|
type: sceneComponentType
|
|
138
131
|
})
|
|
139
132
|
});
|
|
@@ -144,7 +137,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
144
137
|
}, {
|
|
145
138
|
key: "selectToolDrawingHole3D",
|
|
146
139
|
value: function selectToolDrawingHole3D(state, sceneComponentType) {
|
|
147
|
-
var snapElements = new
|
|
140
|
+
var snapElements = new List().withMutations(function (snapElements) {
|
|
148
141
|
var _state$getIn2 = state.getIn(['scene', 'layers', state.scene.selectedLayer]),
|
|
149
142
|
lines = _state$getIn2.lines,
|
|
150
143
|
vertices = _state$getIn2.vertices;
|
|
@@ -155,13 +148,13 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
155
148
|
var _vertices$get4 = vertices.get(line.vertices.get(1)),
|
|
156
149
|
x2 = _vertices$get4.x,
|
|
157
150
|
y2 = _vertices$get4.y;
|
|
158
|
-
|
|
151
|
+
addLineSegmentSnap(snapElements, x1, y1, x2, y2, 20, 1, line.id);
|
|
159
152
|
});
|
|
160
153
|
});
|
|
161
154
|
state = state.merge({
|
|
162
|
-
mode:
|
|
155
|
+
mode: MODE_DRAWING_HOLE_3D,
|
|
163
156
|
snapElements: snapElements,
|
|
164
|
-
drawingSupport:
|
|
157
|
+
drawingSupport: Map({
|
|
165
158
|
type: sceneComponentType
|
|
166
159
|
})
|
|
167
160
|
});
|
|
@@ -176,7 +169,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
176
169
|
var catalog = state.catalog;
|
|
177
170
|
//calculate snap and overwrite coords if needed
|
|
178
171
|
//force snap to segment
|
|
179
|
-
var snap =
|
|
172
|
+
var snap = nearestSnap(state.snapElements, x, y, state.snapMask.merge({
|
|
180
173
|
SNAP_SEGMENT: true
|
|
181
174
|
}));
|
|
182
175
|
if (snap) {
|
|
@@ -196,14 +189,14 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
196
189
|
y2 = _state$getIn4.y;
|
|
197
190
|
|
|
198
191
|
// // I need min and max vertices on this line segment
|
|
199
|
-
var minVertex =
|
|
192
|
+
var minVertex = GeometryUtils.minVertex({
|
|
200
193
|
x: x1,
|
|
201
194
|
y: y1
|
|
202
195
|
}, {
|
|
203
196
|
x: x2,
|
|
204
197
|
y: y2
|
|
205
198
|
});
|
|
206
|
-
var maxVertex =
|
|
199
|
+
var maxVertex = GeometryUtils.maxVertex({
|
|
207
200
|
x: x1,
|
|
208
201
|
y: y1
|
|
209
202
|
}, {
|
|
@@ -213,10 +206,10 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
213
206
|
var width = catalog.factoryElement(state.drawingSupport.get('type')).properties.getIn(['width', 'length']);
|
|
214
207
|
|
|
215
208
|
// // Now I need min and max possible coordinates for the hole on the line. They depend on the width of the hole
|
|
216
|
-
var lineLength =
|
|
217
|
-
var alpha =
|
|
218
|
-
var cosAlpha =
|
|
219
|
-
var sinAlpha =
|
|
209
|
+
var lineLength = GeometryUtils.pointsDistance(x1, y1, x2, y2);
|
|
210
|
+
var alpha = GeometryUtils.absAngleBetweenTwoPoints(x1, y1, x2, y2);
|
|
211
|
+
var cosAlpha = GeometryUtils.cosWithThreshold(Math.abs(alpha), 0.0000001);
|
|
212
|
+
var sinAlpha = GeometryUtils.sinWithThreshold(Math.abs(alpha), 0.0000001);
|
|
220
213
|
var minLeftVertexHole = {
|
|
221
214
|
x: minVertex.x + (state.mode.includes('ING_HOLE') ? width + 1 : width) / 2 * cosAlpha,
|
|
222
215
|
y: minVertex.y + (state.mode.includes('ING_HOLE') ? width + 1 : width) / 2 * sinAlpha
|
|
@@ -227,24 +220,24 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
227
220
|
};
|
|
228
221
|
var offset;
|
|
229
222
|
if (x < minLeftVertexHole.x) {
|
|
230
|
-
offset =
|
|
223
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, minLeftVertexHole.x, minLeftVertexHole.y);
|
|
231
224
|
offset = minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
232
225
|
} else {
|
|
233
226
|
if (x > maxRightVertexHole.x) {
|
|
234
|
-
offset =
|
|
227
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, maxRightVertexHole.x, maxRightVertexHole.y);
|
|
235
228
|
offset = minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
236
229
|
} else if (x === minLeftVertexHole.x && x === maxRightVertexHole.x) {
|
|
237
230
|
if (y < minLeftVertexHole.y) {
|
|
238
|
-
offset =
|
|
231
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, minLeftVertexHole.x, minLeftVertexHole.y);
|
|
239
232
|
offset = minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
240
233
|
} else if (y > maxRightVertexHole.y) {
|
|
241
|
-
offset =
|
|
234
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, maxRightVertexHole.x, maxRightVertexHole.y);
|
|
242
235
|
offset = minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
243
236
|
} else {
|
|
244
|
-
offset =
|
|
237
|
+
offset = GeometryUtils.pointPositionOnLineSegment(x1, y1, x2, y2, x, y);
|
|
245
238
|
}
|
|
246
239
|
} else {
|
|
247
|
-
offset =
|
|
240
|
+
offset = GeometryUtils.pointPositionOnLineSegment(x1, y1, x2, y2, x, y);
|
|
248
241
|
// offset =
|
|
249
242
|
// minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
250
243
|
}
|
|
@@ -365,7 +358,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
365
358
|
var catalog = state.catalog;
|
|
366
359
|
//calculate snap and overwrite coords if needed
|
|
367
360
|
//force snap to segment
|
|
368
|
-
var snap =
|
|
361
|
+
var snap = nearestSnap(state.snapElements, x, y, state.snapMask.merge({
|
|
369
362
|
SNAP_SEGMENT: true
|
|
370
363
|
}));
|
|
371
364
|
if (snap) {
|
|
@@ -385,14 +378,14 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
385
378
|
y2 = _state$getIn6.y;
|
|
386
379
|
|
|
387
380
|
// // I need min and max vertices on this line segment
|
|
388
|
-
var minVertex =
|
|
381
|
+
var minVertex = GeometryUtils.minVertex({
|
|
389
382
|
x: x1,
|
|
390
383
|
y: y1
|
|
391
384
|
}, {
|
|
392
385
|
x: x2,
|
|
393
386
|
y: y2
|
|
394
387
|
});
|
|
395
|
-
var maxVertex =
|
|
388
|
+
var maxVertex = GeometryUtils.maxVertex({
|
|
396
389
|
x: x1,
|
|
397
390
|
y: y1
|
|
398
391
|
}, {
|
|
@@ -402,10 +395,10 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
402
395
|
var width = catalog.factoryElement(state.drawingSupport.get('type')).properties.getIn(['width', 'length']);
|
|
403
396
|
|
|
404
397
|
// // Now I need min and max possible coordinates for the hole on the line. They depend on the width of the hole
|
|
405
|
-
var lineLength =
|
|
406
|
-
var alpha =
|
|
407
|
-
var cosAlpha =
|
|
408
|
-
var sinAlpha =
|
|
398
|
+
var lineLength = GeometryUtils.pointsDistance(x1, y1, x2, y2);
|
|
399
|
+
var alpha = GeometryUtils.absAngleBetweenTwoPoints(x1, y1, x2, y2);
|
|
400
|
+
var cosAlpha = GeometryUtils.cosWithThreshold(Math.abs(alpha), 0.0000001);
|
|
401
|
+
var sinAlpha = GeometryUtils.sinWithThreshold(Math.abs(alpha), 0.0000001);
|
|
409
402
|
var minLeftVertexHole = {
|
|
410
403
|
x: minVertex.x + (state.mode.includes('ING_HOLE_3D') ? width + 1 : width) / 2 * cosAlpha,
|
|
411
404
|
y: minVertex.y + (state.mode.includes('ING_HOLE_3D') ? width + 1 : width) / 2 * sinAlpha
|
|
@@ -416,28 +409,28 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
416
409
|
};
|
|
417
410
|
var offset;
|
|
418
411
|
if (x < minLeftVertexHole.x) {
|
|
419
|
-
offset =
|
|
412
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, minLeftVertexHole.x, minLeftVertexHole.y);
|
|
420
413
|
} else if (x > maxRightVertexHole.x) {
|
|
421
|
-
offset =
|
|
414
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, maxRightVertexHole.x, maxRightVertexHole.y);
|
|
422
415
|
} else {
|
|
423
416
|
if (x === minLeftVertexHole.x && x === maxRightVertexHole.x) {
|
|
424
417
|
if (y < minLeftVertexHole.y) {
|
|
425
|
-
offset =
|
|
418
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, minLeftVertexHole.x, minLeftVertexHole.y);
|
|
426
419
|
/*
|
|
427
420
|
offset =
|
|
428
421
|
minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
429
422
|
*/
|
|
430
423
|
} else if (y > maxRightVertexHole.y) {
|
|
431
|
-
offset =
|
|
424
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, maxRightVertexHole.x, maxRightVertexHole.y);
|
|
432
425
|
/*
|
|
433
426
|
offset =
|
|
434
427
|
minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
435
428
|
*/
|
|
436
429
|
} else {
|
|
437
|
-
offset =
|
|
430
|
+
offset = GeometryUtils.pointPositionOnLineSegment(x1, y1, x2, y2, x, y);
|
|
438
431
|
}
|
|
439
432
|
} else {
|
|
440
|
-
offset =
|
|
433
|
+
offset = GeometryUtils.pointPositionOnLineSegment(x1, y1, x2, y2, x, y);
|
|
441
434
|
}
|
|
442
435
|
}
|
|
443
436
|
if (this.checkHoleCollide(state.getIn(['scene', 'layers', layerID]), lineID, selectedHole, x, y, width)) {
|
|
@@ -593,16 +586,16 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
593
586
|
key: "endDrawingHole",
|
|
594
587
|
value: function endDrawingHole(state, layerID, x, y) {
|
|
595
588
|
state = this.updateDrawingHole(state, layerID, x, y).updatedState;
|
|
596
|
-
state =
|
|
589
|
+
state = Layer.unselectAll(state, layerID).updatedState;
|
|
597
590
|
var popup = state.get('popup');
|
|
598
591
|
state = state.merge({
|
|
599
|
-
drawingSupport:
|
|
592
|
+
drawingSupport: Map({
|
|
600
593
|
type: state.drawingSupport.get('type')
|
|
601
594
|
}),
|
|
602
595
|
isOpen: !popup,
|
|
603
|
-
mode:
|
|
596
|
+
mode: MODE_IDLE
|
|
604
597
|
});
|
|
605
|
-
state =
|
|
598
|
+
state = Layer.unselectAll(state, layerID).updatedState;
|
|
606
599
|
return {
|
|
607
600
|
updatedState: state
|
|
608
601
|
};
|
|
@@ -611,17 +604,17 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
611
604
|
key: "endDrawingHole3D",
|
|
612
605
|
value: function endDrawingHole3D(state, layerID, x, y) {
|
|
613
606
|
state = state.merge({
|
|
614
|
-
mode:
|
|
607
|
+
mode: MODE_IDLE_3D
|
|
615
608
|
});
|
|
616
609
|
state = this.updateDrawingHole3D(state, layerID, x, y).updatedState;
|
|
617
|
-
state =
|
|
610
|
+
state = Layer.unselectAll(state, layerID).updatedState;
|
|
618
611
|
var popup = state.get('popup');
|
|
619
612
|
state = state.merge({
|
|
620
|
-
drawingSupport:
|
|
613
|
+
drawingSupport: Map({
|
|
621
614
|
type: state.drawingSupport.get('type')
|
|
622
615
|
}),
|
|
623
616
|
isOpen: !popup,
|
|
624
|
-
mode:
|
|
617
|
+
mode: MODE_IDLE_3D
|
|
625
618
|
});
|
|
626
619
|
return {
|
|
627
620
|
updatedState: state
|
|
@@ -635,11 +628,11 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
635
628
|
var line = layer.getIn(['lines', hole.line]);
|
|
636
629
|
var v0 = layer.getIn(['vertices', line.vertices.get(0)]);
|
|
637
630
|
var v1 = layer.getIn(['vertices', line.vertices.get(1)]);
|
|
638
|
-
var snapElements =
|
|
631
|
+
var snapElements = addLineSegmentSnap(List(), v0.x, v0.y, v1.x, v1.y, 9999999, 1, null);
|
|
639
632
|
state = state.merge({
|
|
640
|
-
mode:
|
|
633
|
+
mode: MODE_DRAGGING_HOLE,
|
|
641
634
|
snapElements: snapElements,
|
|
642
|
-
draggingSupport:
|
|
635
|
+
draggingSupport: Map({
|
|
643
636
|
layerID: layerID,
|
|
644
637
|
holeID: holeID,
|
|
645
638
|
startPointX: x,
|
|
@@ -658,7 +651,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
658
651
|
var line = layer.getIn(['lines', hole.line]);
|
|
659
652
|
var v0 = layer.getIn(['vertices', line.vertices.get(0)]);
|
|
660
653
|
var v1 = layer.getIn(['vertices', line.vertices.get(1)]);
|
|
661
|
-
var snapElements =
|
|
654
|
+
var snapElements = addLineSegmentSnap(List(), v0.x, v0.y, v1.x, v1.y, 9999999, 1, null);
|
|
662
655
|
state = state.updateIn(['scene', 'layers', layerID, 'lines', hole.line, 'holes'], function (holes) {
|
|
663
656
|
var index = holes.findIndex(function (ID) {
|
|
664
657
|
return holeID === ID;
|
|
@@ -666,9 +659,9 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
666
659
|
return index !== -1 ? holes.remove(index) : holes;
|
|
667
660
|
});
|
|
668
661
|
state = state.merge({
|
|
669
|
-
mode:
|
|
662
|
+
mode: MODE_DRAGGING_HOLE_3D,
|
|
670
663
|
snapElements: snapElements,
|
|
671
|
-
draggingSupport:
|
|
664
|
+
draggingSupport: Map({
|
|
672
665
|
layerID: layerID,
|
|
673
666
|
holeID: holeID,
|
|
674
667
|
startPointX: x,
|
|
@@ -684,7 +677,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
684
677
|
value: function updateDraggingHole(state, x, y) {
|
|
685
678
|
//calculate snap and overwrite coords if needed
|
|
686
679
|
//force snap to segment
|
|
687
|
-
var snap =
|
|
680
|
+
var snap = nearestSnap(state.snapElements, x, y, state.snapMask.merge({
|
|
688
681
|
SNAP_SEGMENT: true
|
|
689
682
|
}));
|
|
690
683
|
if (!snap) return state;
|
|
@@ -704,13 +697,13 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
704
697
|
var _snap$point3 = snap.point;
|
|
705
698
|
x = _snap$point3.x;
|
|
706
699
|
y = _snap$point3.y;
|
|
707
|
-
var minVertex =
|
|
708
|
-
var maxVertex =
|
|
700
|
+
var minVertex = GeometryUtils.minVertex(v0, v1);
|
|
701
|
+
var maxVertex = GeometryUtils.maxVertex(v0, v1);
|
|
709
702
|
|
|
710
703
|
// Now I need min and max possible coordinates for the hole on the line. They depend on the width of the hole
|
|
711
704
|
|
|
712
705
|
var width = hole.properties.get('width').get('length');
|
|
713
|
-
var lineLength =
|
|
706
|
+
var lineLength = GeometryUtils.pointsDistance(v0.x, v0.y, v1.x, v1.y);
|
|
714
707
|
var alpha = Math.atan2(v1.y - v0.y, Math.abs(v1.x - v0.x));
|
|
715
708
|
var alpha1 = Math.atan2(v1.y - v0.y, v1.x - v0.x);
|
|
716
709
|
var angle_temp;
|
|
@@ -742,27 +735,27 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
742
735
|
var offset;
|
|
743
736
|
if (x < minLeftVertexHole.x) {
|
|
744
737
|
// Snap point is previous the the line
|
|
745
|
-
offset =
|
|
738
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, minLeftVertexHole.x, minLeftVertexHole.y);
|
|
746
739
|
offset = minVertex === v0 ? offset : 1 - offset;
|
|
747
740
|
} else {
|
|
748
741
|
// Snap point is after the line or on the line
|
|
749
742
|
if (x > maxRightVertexHole.x) {
|
|
750
|
-
offset =
|
|
743
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, maxRightVertexHole.x, maxRightVertexHole.y);
|
|
751
744
|
offset = minVertex === v0 ? offset : 1 - offset;
|
|
752
745
|
} else if (x === minLeftVertexHole.x && x === maxRightVertexHole.x) {
|
|
753
746
|
// I am on a vertical line, I need to check y coordinates
|
|
754
747
|
if (y < minLeftVertexHole.y) {
|
|
755
|
-
offset =
|
|
748
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, minLeftVertexHole.x, minLeftVertexHole.y);
|
|
756
749
|
offset = minVertex === v0 ? offset : 1 - offset;
|
|
757
750
|
} else if (y > maxRightVertexHole.y) {
|
|
758
|
-
offset =
|
|
751
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, maxRightVertexHole.x, maxRightVertexHole.y);
|
|
759
752
|
offset = minVertex === v0 ? offset : 1 - offset;
|
|
760
753
|
} else {
|
|
761
|
-
offset =
|
|
754
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, x, y);
|
|
762
755
|
offset = minVertex === v0 ? offset : 1 - offset;
|
|
763
756
|
}
|
|
764
757
|
} else {
|
|
765
|
-
offset =
|
|
758
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, x, y);
|
|
766
759
|
if (angle_temp > 90 && angle_temp < 270) {
|
|
767
760
|
offset = 1 - offset;
|
|
768
761
|
}
|
|
@@ -842,8 +835,8 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
842
835
|
return index === -1 ? holes.push(holeID) : holes;
|
|
843
836
|
});
|
|
844
837
|
state = state.merge({
|
|
845
|
-
mode:
|
|
846
|
-
draggingSupport:
|
|
838
|
+
mode: MODE_IDLE_3D,
|
|
839
|
+
draggingSupport: Map({})
|
|
847
840
|
});
|
|
848
841
|
return {
|
|
849
842
|
updatedState: state
|
|
@@ -871,7 +864,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
871
864
|
value: function endDraggingHole(state, x, y) {
|
|
872
865
|
state = this.updateDraggingHole(state, x, y).updatedState;
|
|
873
866
|
state = state.merge({
|
|
874
|
-
mode:
|
|
867
|
+
mode: MODE_IDLE
|
|
875
868
|
});
|
|
876
869
|
return {
|
|
877
870
|
updatedState: state
|
|
@@ -888,7 +881,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
888
881
|
}, {
|
|
889
882
|
key: "setJsProperties",
|
|
890
883
|
value: function setJsProperties(state, layerID, holeID, properties) {
|
|
891
|
-
return this.setProperties(state, layerID, holeID,
|
|
884
|
+
return this.setProperties(state, layerID, holeID, fromJS(properties));
|
|
892
885
|
}
|
|
893
886
|
}, {
|
|
894
887
|
key: "updateProperties",
|
|
@@ -903,7 +896,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
903
896
|
}, {
|
|
904
897
|
key: "updateJsProperties",
|
|
905
898
|
value: function updateJsProperties(state, layerID, holeID, properties) {
|
|
906
|
-
return this.updateProperties(state, layerID, holeID,
|
|
899
|
+
return this.updateProperties(state, layerID, holeID, fromJS(properties));
|
|
907
900
|
}
|
|
908
901
|
}, {
|
|
909
902
|
key: "setAttributes",
|
|
@@ -915,11 +908,11 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
915
908
|
delete hAttr['offsetA'];
|
|
916
909
|
delete hAttr['offsetB'];
|
|
917
910
|
delete hAttr['offset'];
|
|
918
|
-
var misc = new
|
|
911
|
+
var misc = new Map({
|
|
919
912
|
_unitA: offsetA._unit,
|
|
920
913
|
_unitB: offsetB._unit
|
|
921
914
|
});
|
|
922
|
-
state = state.mergeIn(['scene', 'layers', layerID, 'holes', holeID],
|
|
915
|
+
state = state.mergeIn(['scene', 'layers', layerID, 'holes', holeID], fromJS(hAttr)).mergeDeepIn(['scene', 'layers', layerID, 'holes', holeID], new Map({
|
|
923
916
|
offset: offset,
|
|
924
917
|
misc: misc
|
|
925
918
|
}));
|
|
@@ -928,4 +921,5 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
928
921
|
};
|
|
929
922
|
}
|
|
930
923
|
}]);
|
|
931
|
-
}();
|
|
924
|
+
}();
|
|
925
|
+
export { Hole as default };
|