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