kitchen-simulator 1.1.1-test.72 → 1.1.1-test.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/@history.js +2 -5
- package/es/AppContext.js +3 -6
- package/es/KitchenConfigurator.js +86 -86
- package/es/KitchenConfiguratorApp.js +134 -128
- package/es/actions/area-actions.js +5 -8
- package/es/actions/export.js +12 -24
- package/es/actions/groups-actions.js +27 -41
- package/es/actions/holes-actions.js +34 -51
- package/es/actions/items-actions.js +94 -141
- package/es/actions/lines-actions.js +21 -32
- package/es/actions/project-actions.js +94 -141
- package/es/actions/scene-actions.js +11 -17
- package/es/actions/vertices-actions.js +7 -11
- package/es/actions/viewer2d-actions.js +21 -32
- package/es/actions/viewer3d-actions.js +9 -14
- package/es/catalog/areas/area/planner-element.js +2 -5
- package/es/catalog/catalog.js +15 -17
- package/es/catalog/factories/area-factory-3d.js +22 -26
- package/es/catalog/factories/area-factory.js +13 -15
- package/es/catalog/factories/export.js +6 -10
- package/es/catalog/factories/wall-factory-3d.js +31 -36
- package/es/catalog/factories/wall-factory.js +21 -26
- package/es/catalog/holes/door-closet/planner-element.js +15 -19
- package/es/catalog/holes/door-double/planner-element.js +15 -19
- package/es/catalog/holes/door-exterior/planner-element.js +16 -20
- package/es/catalog/holes/door-interior/planner-element.js +16 -20
- package/es/catalog/holes/door-panic/planner-element.js +7 -11
- package/es/catalog/holes/door-panic-double/planner-element.js +15 -19
- package/es/catalog/holes/door-sliding/planner-element.js +17 -21
- package/es/catalog/holes/doorway-framed/planner-element.js +11 -15
- package/es/catalog/holes/doorway-frameless/planner-element.js +7 -11
- package/es/catalog/holes/export.js +13 -29
- package/es/catalog/holes/window-clear/planner-element.js +10 -14
- package/es/catalog/holes/window-cross/planner-element.js +10 -14
- package/es/catalog/holes/window-double-hung/planner-element.js +10 -14
- package/es/catalog/holes/window-vertical/planner-element.js +10 -14
- package/es/catalog/lines/wall/planner-element.js +2 -5
- package/es/catalog/molding/molding-dcm/planner-element.js +5 -9
- package/es/catalog/molding/molding-fbm/planner-element.js +5 -9
- package/es/catalog/molding/molding-lrm/planner-element.js +5 -9
- package/es/catalog/properties/export.js +20 -31
- package/es/catalog/properties/property-checkbox.js +28 -29
- package/es/catalog/properties/property-color.js +16 -19
- package/es/catalog/properties/property-enum.js +24 -27
- package/es/catalog/properties/property-hidden.js +9 -12
- package/es/catalog/properties/property-lenght-measure.js +38 -41
- package/es/catalog/properties/property-length-measure.js +36 -39
- package/es/catalog/properties/property-length-measure_hole.js +38 -41
- package/es/catalog/properties/property-number.js +17 -20
- package/es/catalog/properties/property-read-only.js +16 -19
- package/es/catalog/properties/property-string.js +16 -19
- package/es/catalog/properties/property-toggle.js +16 -19
- package/es/catalog/properties/shared-property-style.js +1 -3
- package/es/catalog/utils/FuseUtils.js +12 -13
- package/es/catalog/utils/exporter.js +10 -11
- package/es/catalog/utils/geom-utils.js +13 -24
- package/es/catalog/utils/item-loader.js +86 -92
- package/es/catalog/utils/load-obj.js +20 -24
- package/es/catalog/utils/mtl-loader.js +3 -4
- package/es/catalog/utils/obj-loader.js +3 -4
- package/es/class/FuseUtils.js +12 -13
- package/es/class/area.js +24 -24
- package/es/class/export.js +23 -36
- package/es/class/group.js +53 -55
- package/es/class/guide.js +15 -17
- package/es/class/hole.js +83 -85
- package/es/class/item.js +155 -155
- package/es/class/layer.js +59 -61
- package/es/class/line.js +135 -138
- package/es/class/project.js +93 -94
- package/es/class/vertex.js +29 -31
- package/es/components/content.js +19 -23
- package/es/components/disclaimer/disclaimer.js +10 -13
- package/es/components/export.js +8 -13
- package/es/components/style/button.js +25 -25
- package/es/components/style/cancel-button.js +7 -10
- package/es/components/style/content-container.js +11 -12
- package/es/components/style/content-title.js +13 -15
- package/es/components/style/delete-button.js +8 -12
- package/es/components/style/export.js +30 -46
- package/es/components/style/form-block.js +10 -11
- package/es/components/style/form-color-input.js +7 -10
- package/es/components/style/form-label.js +10 -11
- package/es/components/style/form-number-input.js +45 -43
- package/es/components/style/form-number-input_2.js +41 -39
- package/es/components/style/form-select.js +19 -20
- package/es/components/style/form-slider.js +10 -13
- package/es/components/style/form-submit-button.js +8 -12
- package/es/components/style/form-text-input.js +30 -28
- package/es/components/viewer2d/area.js +17 -20
- package/es/components/viewer2d/export.js +30 -46
- package/es/components/viewer2d/grids/grid-horizontal-streak.js +10 -13
- package/es/components/viewer2d/grids/grid-streak.js +10 -13
- package/es/components/viewer2d/grids/grid-vertical-streak.js +10 -13
- package/es/components/viewer2d/grids/grids.js +10 -14
- package/es/components/viewer2d/group.js +15 -19
- package/es/components/viewer2d/item.js +61 -65
- package/es/components/viewer2d/layer.js +23 -26
- package/es/components/viewer2d/line.js +101 -106
- package/es/components/viewer2d/ruler.js +22 -25
- package/es/components/viewer2d/rulerDist.js +21 -24
- package/es/components/viewer2d/rulerX.js +46 -44
- package/es/components/viewer2d/rulerY.js +44 -42
- package/es/components/viewer2d/scene.js +34 -34
- package/es/components/viewer2d/snap.js +13 -17
- package/es/components/viewer2d/state.js +18 -22
- package/es/components/viewer2d/utils.js +24 -33
- package/es/components/viewer2d/vertex.js +8 -12
- package/es/components/viewer2d/viewer2d.js +156 -159
- package/es/components/viewer3d/camera-controls-module/camera-controls.module.js +21 -19
- package/es/components/viewer3d/dcm.js +1 -3
- package/es/components/viewer3d/fbm.js +1 -3
- package/es/components/viewer3d/front3D.js +12 -16
- package/es/components/viewer3d/grid-creator.js +8 -12
- package/es/components/viewer3d/grids/grid-horizontal-streak.js +6 -9
- package/es/components/viewer3d/grids/grid-streak.js +5 -8
- package/es/components/viewer3d/grids/grid-vertical-streak.js +6 -9
- package/es/components/viewer3d/libs/first-person-controls.js +2 -5
- package/es/components/viewer3d/libs/helvetiker_regular.typeface.js +1 -3
- package/es/components/viewer3d/libs/mtl-loader.js +1 -3
- package/es/components/viewer3d/libs/obj-loader.js +1 -3
- package/es/components/viewer3d/libs/orbit-controls.js +2 -4
- package/es/components/viewer3d/libs/pointer-lock-controls.js +2 -4
- package/es/components/viewer3d/lrm.js +1 -3
- package/es/components/viewer3d/model.js +1 -3
- package/es/components/viewer3d/pointer-lock-navigation.js +3 -6
- package/es/components/viewer3d/ruler-utils/itemRect.js +18 -21
- package/es/components/viewer3d/ruler-utils/layer3D.js +59 -62
- package/es/components/viewer3d/ruler-utils/ruler3D.js +42 -43
- package/es/components/viewer3d/ruler-utils/scene3D.js +9 -13
- package/es/components/viewer3d/ruler-utils/state3D.js +4 -7
- package/es/components/viewer3d/scene-creator.js +197 -223
- package/es/components/viewer3d/three-memory-cleaner.js +3 -7
- package/es/components/viewer3d/viewer3d-first-person.js +42 -42
- package/es/components/viewer3d/viewer3d.js +200 -198
- package/es/constants.js +349 -354
- package/es/index.js +7 -11
- package/es/models.js +193 -191
- package/es/plugins/SVGLoader.js +48 -49
- package/es/plugins/autosave.js +3 -5
- package/es/plugins/console-debugger.js +6 -7
- package/es/plugins/export.js +8 -13
- package/es/plugins/keyboard.js +29 -31
- package/es/reducers/areas-reducer.js +7 -9
- package/es/reducers/export.js +24 -37
- package/es/reducers/groups-reducer.js +31 -33
- package/es/reducers/holes-reducer.js +43 -45
- package/es/reducers/items-reducer.js +106 -108
- package/es/reducers/lines-reducer.js +28 -30
- package/es/reducers/project-reducer.js +105 -107
- package/es/reducers/reducer.js +16 -19
- package/es/reducers/scene-reducer.js +15 -17
- package/es/reducers/user-reducer.js +5 -7
- package/es/reducers/vertices-reducer.js +11 -13
- package/es/reducers/viewer2d-reducer.js +18 -20
- package/es/reducers/viewer3d-reducer.js +16 -18
- package/es/shared-style.js +10 -12
- package/es/styles/export.js +3 -6
- package/es/translator/en.js +1 -3
- package/es/translator/it.js +1 -3
- package/es/translator/ru.js +1 -3
- package/es/translator/translator.js +13 -15
- package/es/utils/browser.js +2 -5
- package/es/utils/convert-units-lite.js +1 -3
- package/es/utils/email-validator.js +1 -3
- package/es/utils/export.js +15 -29
- package/es/utils/geometry.js +190 -280
- package/es/utils/get-edges-of-subgraphs.js +2 -5
- package/es/utils/graph-cycles.js +8 -7
- package/es/utils/graph-inner-cycles.js +10 -14
- package/es/utils/graph.js +9 -13
- package/es/utils/helper.js +41 -58
- package/es/utils/history.js +8 -11
- package/es/utils/id-broker.js +8 -11
- package/es/utils/logger.js +1 -3
- package/es/utils/math.js +5 -8
- package/es/utils/molding.js +130 -146
- package/es/utils/name-generator.js +7 -9
- package/es/utils/objects-utils.js +7 -14
- package/es/utils/phone-validator.js +1 -3
- package/es/utils/process-black-list.js +5 -6
- package/es/utils/react-if.js +7 -9
- package/es/utils/snap-scene.js +27 -30
- package/es/utils/snap.js +53 -57
- package/es/utils/summarizeCart.js +1 -3
- package/es/utils/threeCSG.es6.js +13 -17
- package/es/version.js +1 -3
- package/package.json +1 -1
package/es/class/hole.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var _snap = require("../utils/snap");
|
|
10
|
-
var _constants = require("../constants");
|
|
11
|
-
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 () {
|
|
12
9
|
function Hole() {
|
|
13
|
-
(
|
|
10
|
+
_classCallCheck(this, Hole);
|
|
14
11
|
}
|
|
15
|
-
return (
|
|
12
|
+
return _createClass(Hole, null, [{
|
|
16
13
|
key: "create",
|
|
17
14
|
value: function create(state, layerID, type, lineID, offset, properties, holeX, holeY) {
|
|
18
|
-
var holeID =
|
|
15
|
+
var holeID = IDBroker.acquireID();
|
|
19
16
|
var hole = state.catalog.factoryElement(type, {
|
|
20
17
|
id: holeID,
|
|
21
18
|
url: state.catalog.getIn(['elements', type, 'info', 'url']),
|
|
@@ -76,8 +73,8 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
76
73
|
}, {
|
|
77
74
|
key: "select",
|
|
78
75
|
value: function select(state, layerID, holeID) {
|
|
79
|
-
state =
|
|
80
|
-
state =
|
|
76
|
+
state = Layer.select(state, layerID).updatedState;
|
|
77
|
+
state = Layer.selectElement(state, layerID, 'holes', holeID).updatedState;
|
|
81
78
|
return {
|
|
82
79
|
updatedState: state
|
|
83
80
|
};
|
|
@@ -87,7 +84,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
87
84
|
value: function remove(state, layerID, holeID) {
|
|
88
85
|
var hole = state.getIn(['scene', 'layers', layerID, 'holes', holeID]);
|
|
89
86
|
state = this.unselect(state, layerID, holeID).updatedState;
|
|
90
|
-
state =
|
|
87
|
+
state = Layer.removeElement(state, layerID, 'holes', holeID).updatedState;
|
|
91
88
|
state = state.updateIn(['scene', 'layers', layerID, 'lines', hole.line, 'holes'], function (holes) {
|
|
92
89
|
var index = holes.findIndex(function (ID) {
|
|
93
90
|
return holeID === ID;
|
|
@@ -95,7 +92,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
95
92
|
return index !== -1 ? holes.remove(index) : holes;
|
|
96
93
|
});
|
|
97
94
|
state.getIn(['scene', 'groups']).forEach(function (group) {
|
|
98
|
-
return state =
|
|
95
|
+
return state = Group.removeElement(state, group.id, layerID, 'holes', holeID).updatedState;
|
|
99
96
|
});
|
|
100
97
|
return {
|
|
101
98
|
updatedState: state
|
|
@@ -104,7 +101,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
104
101
|
}, {
|
|
105
102
|
key: "unselect",
|
|
106
103
|
value: function unselect(state, layerID, holeID) {
|
|
107
|
-
state =
|
|
104
|
+
state = Layer.unselect(state, layerID, 'holes', holeID).updatedState;
|
|
108
105
|
return {
|
|
109
106
|
updatedState: state
|
|
110
107
|
};
|
|
@@ -112,7 +109,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
112
109
|
}, {
|
|
113
110
|
key: "selectToolDrawingHole",
|
|
114
111
|
value: function selectToolDrawingHole(state, sceneComponentType) {
|
|
115
|
-
var snapElements = new
|
|
112
|
+
var snapElements = new List().withMutations(function (snapElements) {
|
|
116
113
|
var _state$getIn = state.getIn(['scene', 'layers', state.scene.selectedLayer]),
|
|
117
114
|
lines = _state$getIn.lines,
|
|
118
115
|
vertices = _state$getIn.vertices;
|
|
@@ -123,13 +120,13 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
123
120
|
var _vertices$get2 = vertices.get(line.vertices.get(1)),
|
|
124
121
|
x2 = _vertices$get2.x,
|
|
125
122
|
y2 = _vertices$get2.y;
|
|
126
|
-
|
|
123
|
+
addLineSegmentSnap(snapElements, x1, y1, x2, y2, 20, 1, line.id);
|
|
127
124
|
});
|
|
128
125
|
});
|
|
129
126
|
state = state.merge({
|
|
130
|
-
mode:
|
|
127
|
+
mode: MODE_DRAWING_HOLE,
|
|
131
128
|
snapElements: snapElements,
|
|
132
|
-
drawingSupport:
|
|
129
|
+
drawingSupport: Map({
|
|
133
130
|
type: sceneComponentType
|
|
134
131
|
})
|
|
135
132
|
});
|
|
@@ -140,7 +137,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
140
137
|
}, {
|
|
141
138
|
key: "selectToolDrawingHole3D",
|
|
142
139
|
value: function selectToolDrawingHole3D(state, sceneComponentType) {
|
|
143
|
-
var snapElements = new
|
|
140
|
+
var snapElements = new List().withMutations(function (snapElements) {
|
|
144
141
|
var _state$getIn2 = state.getIn(['scene', 'layers', state.scene.selectedLayer]),
|
|
145
142
|
lines = _state$getIn2.lines,
|
|
146
143
|
vertices = _state$getIn2.vertices;
|
|
@@ -151,13 +148,13 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
151
148
|
var _vertices$get4 = vertices.get(line.vertices.get(1)),
|
|
152
149
|
x2 = _vertices$get4.x,
|
|
153
150
|
y2 = _vertices$get4.y;
|
|
154
|
-
|
|
151
|
+
addLineSegmentSnap(snapElements, x1, y1, x2, y2, 20, 1, line.id);
|
|
155
152
|
});
|
|
156
153
|
});
|
|
157
154
|
state = state.merge({
|
|
158
|
-
mode:
|
|
155
|
+
mode: MODE_DRAWING_HOLE_3D,
|
|
159
156
|
snapElements: snapElements,
|
|
160
|
-
drawingSupport:
|
|
157
|
+
drawingSupport: Map({
|
|
161
158
|
type: sceneComponentType
|
|
162
159
|
})
|
|
163
160
|
});
|
|
@@ -172,7 +169,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
172
169
|
var catalog = state.catalog;
|
|
173
170
|
//calculate snap and overwrite coords if needed
|
|
174
171
|
//force snap to segment
|
|
175
|
-
var snap =
|
|
172
|
+
var snap = nearestSnap(state.snapElements, x, y, state.snapMask.merge({
|
|
176
173
|
SNAP_SEGMENT: true
|
|
177
174
|
}));
|
|
178
175
|
if (snap) {
|
|
@@ -192,14 +189,14 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
192
189
|
y2 = _state$getIn4.y;
|
|
193
190
|
|
|
194
191
|
// // I need min and max vertices on this line segment
|
|
195
|
-
var minVertex =
|
|
192
|
+
var minVertex = GeometryUtils.minVertex({
|
|
196
193
|
x: x1,
|
|
197
194
|
y: y1
|
|
198
195
|
}, {
|
|
199
196
|
x: x2,
|
|
200
197
|
y: y2
|
|
201
198
|
});
|
|
202
|
-
var maxVertex =
|
|
199
|
+
var maxVertex = GeometryUtils.maxVertex({
|
|
203
200
|
x: x1,
|
|
204
201
|
y: y1
|
|
205
202
|
}, {
|
|
@@ -209,10 +206,10 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
209
206
|
var width = catalog.factoryElement(state.drawingSupport.get('type')).properties.getIn(['width', 'length']);
|
|
210
207
|
|
|
211
208
|
// // Now I need min and max possible coordinates for the hole on the line. They depend on the width of the hole
|
|
212
|
-
var lineLength =
|
|
213
|
-
var alpha =
|
|
214
|
-
var cosAlpha =
|
|
215
|
-
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);
|
|
216
213
|
var minLeftVertexHole = {
|
|
217
214
|
x: minVertex.x + (state.mode.includes('ING_HOLE') ? width + 1 : width) / 2 * cosAlpha,
|
|
218
215
|
y: minVertex.y + (state.mode.includes('ING_HOLE') ? width + 1 : width) / 2 * sinAlpha
|
|
@@ -223,24 +220,24 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
223
220
|
};
|
|
224
221
|
var offset;
|
|
225
222
|
if (x < minLeftVertexHole.x) {
|
|
226
|
-
offset =
|
|
223
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, minLeftVertexHole.x, minLeftVertexHole.y);
|
|
227
224
|
offset = minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
228
225
|
} else {
|
|
229
226
|
if (x > maxRightVertexHole.x) {
|
|
230
|
-
offset =
|
|
227
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, maxRightVertexHole.x, maxRightVertexHole.y);
|
|
231
228
|
offset = minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
232
229
|
} else if (x === minLeftVertexHole.x && x === maxRightVertexHole.x) {
|
|
233
230
|
if (y < minLeftVertexHole.y) {
|
|
234
|
-
offset =
|
|
231
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, minLeftVertexHole.x, minLeftVertexHole.y);
|
|
235
232
|
offset = minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
236
233
|
} else if (y > maxRightVertexHole.y) {
|
|
237
|
-
offset =
|
|
234
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, maxRightVertexHole.x, maxRightVertexHole.y);
|
|
238
235
|
offset = minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
239
236
|
} else {
|
|
240
|
-
offset =
|
|
237
|
+
offset = GeometryUtils.pointPositionOnLineSegment(x1, y1, x2, y2, x, y);
|
|
241
238
|
}
|
|
242
239
|
} else {
|
|
243
|
-
offset =
|
|
240
|
+
offset = GeometryUtils.pointPositionOnLineSegment(x1, y1, x2, y2, x, y);
|
|
244
241
|
// offset =
|
|
245
242
|
// minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
246
243
|
}
|
|
@@ -361,7 +358,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
361
358
|
var catalog = state.catalog;
|
|
362
359
|
//calculate snap and overwrite coords if needed
|
|
363
360
|
//force snap to segment
|
|
364
|
-
var snap =
|
|
361
|
+
var snap = nearestSnap(state.snapElements, x, y, state.snapMask.merge({
|
|
365
362
|
SNAP_SEGMENT: true
|
|
366
363
|
}));
|
|
367
364
|
if (snap) {
|
|
@@ -381,14 +378,14 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
381
378
|
y2 = _state$getIn6.y;
|
|
382
379
|
|
|
383
380
|
// // I need min and max vertices on this line segment
|
|
384
|
-
var minVertex =
|
|
381
|
+
var minVertex = GeometryUtils.minVertex({
|
|
385
382
|
x: x1,
|
|
386
383
|
y: y1
|
|
387
384
|
}, {
|
|
388
385
|
x: x2,
|
|
389
386
|
y: y2
|
|
390
387
|
});
|
|
391
|
-
var maxVertex =
|
|
388
|
+
var maxVertex = GeometryUtils.maxVertex({
|
|
392
389
|
x: x1,
|
|
393
390
|
y: y1
|
|
394
391
|
}, {
|
|
@@ -398,10 +395,10 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
398
395
|
var width = catalog.factoryElement(state.drawingSupport.get('type')).properties.getIn(['width', 'length']);
|
|
399
396
|
|
|
400
397
|
// // Now I need min and max possible coordinates for the hole on the line. They depend on the width of the hole
|
|
401
|
-
var lineLength =
|
|
402
|
-
var alpha =
|
|
403
|
-
var cosAlpha =
|
|
404
|
-
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);
|
|
405
402
|
var minLeftVertexHole = {
|
|
406
403
|
x: minVertex.x + (state.mode.includes('ING_HOLE_3D') ? width + 1 : width) / 2 * cosAlpha,
|
|
407
404
|
y: minVertex.y + (state.mode.includes('ING_HOLE_3D') ? width + 1 : width) / 2 * sinAlpha
|
|
@@ -412,28 +409,28 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
412
409
|
};
|
|
413
410
|
var offset;
|
|
414
411
|
if (x < minLeftVertexHole.x) {
|
|
415
|
-
offset =
|
|
412
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, minLeftVertexHole.x, minLeftVertexHole.y);
|
|
416
413
|
} else if (x > maxRightVertexHole.x) {
|
|
417
|
-
offset =
|
|
414
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, maxRightVertexHole.x, maxRightVertexHole.y);
|
|
418
415
|
} else {
|
|
419
416
|
if (x === minLeftVertexHole.x && x === maxRightVertexHole.x) {
|
|
420
417
|
if (y < minLeftVertexHole.y) {
|
|
421
|
-
offset =
|
|
418
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, minLeftVertexHole.x, minLeftVertexHole.y);
|
|
422
419
|
/*
|
|
423
420
|
offset =
|
|
424
421
|
minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
425
422
|
*/
|
|
426
423
|
} else if (y > maxRightVertexHole.y) {
|
|
427
|
-
offset =
|
|
424
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, maxRightVertexHole.x, maxRightVertexHole.y);
|
|
428
425
|
/*
|
|
429
426
|
offset =
|
|
430
427
|
minVertex.x === x1 && minVertex.y === y1 ? offset : 1 - offset;
|
|
431
428
|
*/
|
|
432
429
|
} else {
|
|
433
|
-
offset =
|
|
430
|
+
offset = GeometryUtils.pointPositionOnLineSegment(x1, y1, x2, y2, x, y);
|
|
434
431
|
}
|
|
435
432
|
} else {
|
|
436
|
-
offset =
|
|
433
|
+
offset = GeometryUtils.pointPositionOnLineSegment(x1, y1, x2, y2, x, y);
|
|
437
434
|
}
|
|
438
435
|
}
|
|
439
436
|
if (this.checkHoleCollide(state.getIn(['scene', 'layers', layerID]), lineID, selectedHole, x, y, width)) {
|
|
@@ -589,16 +586,16 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
589
586
|
key: "endDrawingHole",
|
|
590
587
|
value: function endDrawingHole(state, layerID, x, y) {
|
|
591
588
|
state = this.updateDrawingHole(state, layerID, x, y).updatedState;
|
|
592
|
-
state =
|
|
589
|
+
state = Layer.unselectAll(state, layerID).updatedState;
|
|
593
590
|
var popup = state.get('popup');
|
|
594
591
|
state = state.merge({
|
|
595
|
-
drawingSupport:
|
|
592
|
+
drawingSupport: Map({
|
|
596
593
|
type: state.drawingSupport.get('type')
|
|
597
594
|
}),
|
|
598
595
|
isOpen: !popup,
|
|
599
|
-
mode:
|
|
596
|
+
mode: MODE_IDLE
|
|
600
597
|
});
|
|
601
|
-
state =
|
|
598
|
+
state = Layer.unselectAll(state, layerID).updatedState;
|
|
602
599
|
return {
|
|
603
600
|
updatedState: state
|
|
604
601
|
};
|
|
@@ -607,17 +604,17 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
607
604
|
key: "endDrawingHole3D",
|
|
608
605
|
value: function endDrawingHole3D(state, layerID, x, y) {
|
|
609
606
|
state = state.merge({
|
|
610
|
-
mode:
|
|
607
|
+
mode: MODE_IDLE_3D
|
|
611
608
|
});
|
|
612
609
|
state = this.updateDrawingHole3D(state, layerID, x, y).updatedState;
|
|
613
|
-
state =
|
|
610
|
+
state = Layer.unselectAll(state, layerID).updatedState;
|
|
614
611
|
var popup = state.get('popup');
|
|
615
612
|
state = state.merge({
|
|
616
|
-
drawingSupport:
|
|
613
|
+
drawingSupport: Map({
|
|
617
614
|
type: state.drawingSupport.get('type')
|
|
618
615
|
}),
|
|
619
616
|
isOpen: !popup,
|
|
620
|
-
mode:
|
|
617
|
+
mode: MODE_IDLE_3D
|
|
621
618
|
});
|
|
622
619
|
return {
|
|
623
620
|
updatedState: state
|
|
@@ -631,11 +628,11 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
631
628
|
var line = layer.getIn(['lines', hole.line]);
|
|
632
629
|
var v0 = layer.getIn(['vertices', line.vertices.get(0)]);
|
|
633
630
|
var v1 = layer.getIn(['vertices', line.vertices.get(1)]);
|
|
634
|
-
var snapElements =
|
|
631
|
+
var snapElements = addLineSegmentSnap(List(), v0.x, v0.y, v1.x, v1.y, 9999999, 1, null);
|
|
635
632
|
state = state.merge({
|
|
636
|
-
mode:
|
|
633
|
+
mode: MODE_DRAGGING_HOLE,
|
|
637
634
|
snapElements: snapElements,
|
|
638
|
-
draggingSupport:
|
|
635
|
+
draggingSupport: Map({
|
|
639
636
|
layerID: layerID,
|
|
640
637
|
holeID: holeID,
|
|
641
638
|
startPointX: x,
|
|
@@ -654,7 +651,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
654
651
|
var line = layer.getIn(['lines', hole.line]);
|
|
655
652
|
var v0 = layer.getIn(['vertices', line.vertices.get(0)]);
|
|
656
653
|
var v1 = layer.getIn(['vertices', line.vertices.get(1)]);
|
|
657
|
-
var snapElements =
|
|
654
|
+
var snapElements = addLineSegmentSnap(List(), v0.x, v0.y, v1.x, v1.y, 9999999, 1, null);
|
|
658
655
|
state = state.updateIn(['scene', 'layers', layerID, 'lines', hole.line, 'holes'], function (holes) {
|
|
659
656
|
var index = holes.findIndex(function (ID) {
|
|
660
657
|
return holeID === ID;
|
|
@@ -662,9 +659,9 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
662
659
|
return index !== -1 ? holes.remove(index) : holes;
|
|
663
660
|
});
|
|
664
661
|
state = state.merge({
|
|
665
|
-
mode:
|
|
662
|
+
mode: MODE_DRAGGING_HOLE_3D,
|
|
666
663
|
snapElements: snapElements,
|
|
667
|
-
draggingSupport:
|
|
664
|
+
draggingSupport: Map({
|
|
668
665
|
layerID: layerID,
|
|
669
666
|
holeID: holeID,
|
|
670
667
|
startPointX: x,
|
|
@@ -680,7 +677,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
680
677
|
value: function updateDraggingHole(state, x, y) {
|
|
681
678
|
//calculate snap and overwrite coords if needed
|
|
682
679
|
//force snap to segment
|
|
683
|
-
var snap =
|
|
680
|
+
var snap = nearestSnap(state.snapElements, x, y, state.snapMask.merge({
|
|
684
681
|
SNAP_SEGMENT: true
|
|
685
682
|
}));
|
|
686
683
|
if (!snap) return state;
|
|
@@ -700,13 +697,13 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
700
697
|
var _snap$point3 = snap.point;
|
|
701
698
|
x = _snap$point3.x;
|
|
702
699
|
y = _snap$point3.y;
|
|
703
|
-
var minVertex =
|
|
704
|
-
var maxVertex =
|
|
700
|
+
var minVertex = GeometryUtils.minVertex(v0, v1);
|
|
701
|
+
var maxVertex = GeometryUtils.maxVertex(v0, v1);
|
|
705
702
|
|
|
706
703
|
// Now I need min and max possible coordinates for the hole on the line. They depend on the width of the hole
|
|
707
704
|
|
|
708
705
|
var width = hole.properties.get('width').get('length');
|
|
709
|
-
var lineLength =
|
|
706
|
+
var lineLength = GeometryUtils.pointsDistance(v0.x, v0.y, v1.x, v1.y);
|
|
710
707
|
var alpha = Math.atan2(v1.y - v0.y, Math.abs(v1.x - v0.x));
|
|
711
708
|
var alpha1 = Math.atan2(v1.y - v0.y, v1.x - v0.x);
|
|
712
709
|
var angle_temp;
|
|
@@ -738,27 +735,27 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
738
735
|
var offset;
|
|
739
736
|
if (x < minLeftVertexHole.x) {
|
|
740
737
|
// Snap point is previous the the line
|
|
741
|
-
offset =
|
|
738
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, minLeftVertexHole.x, minLeftVertexHole.y);
|
|
742
739
|
offset = minVertex === v0 ? offset : 1 - offset;
|
|
743
740
|
} else {
|
|
744
741
|
// Snap point is after the line or on the line
|
|
745
742
|
if (x > maxRightVertexHole.x) {
|
|
746
|
-
offset =
|
|
743
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, maxRightVertexHole.x, maxRightVertexHole.y);
|
|
747
744
|
offset = minVertex === v0 ? offset : 1 - offset;
|
|
748
745
|
} else if (x === minLeftVertexHole.x && x === maxRightVertexHole.x) {
|
|
749
746
|
// I am on a vertical line, I need to check y coordinates
|
|
750
747
|
if (y < minLeftVertexHole.y) {
|
|
751
|
-
offset =
|
|
748
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, minLeftVertexHole.x, minLeftVertexHole.y);
|
|
752
749
|
offset = minVertex === v0 ? offset : 1 - offset;
|
|
753
750
|
} else if (y > maxRightVertexHole.y) {
|
|
754
|
-
offset =
|
|
751
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, maxRightVertexHole.x, maxRightVertexHole.y);
|
|
755
752
|
offset = minVertex === v0 ? offset : 1 - offset;
|
|
756
753
|
} else {
|
|
757
|
-
offset =
|
|
754
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, x, y);
|
|
758
755
|
offset = minVertex === v0 ? offset : 1 - offset;
|
|
759
756
|
}
|
|
760
757
|
} else {
|
|
761
|
-
offset =
|
|
758
|
+
offset = GeometryUtils.pointPositionOnLineSegment(minVertex.x, minVertex.y, maxVertex.x, maxVertex.y, x, y);
|
|
762
759
|
if (angle_temp > 90 && angle_temp < 270) {
|
|
763
760
|
offset = 1 - offset;
|
|
764
761
|
}
|
|
@@ -838,8 +835,8 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
838
835
|
return index === -1 ? holes.push(holeID) : holes;
|
|
839
836
|
});
|
|
840
837
|
state = state.merge({
|
|
841
|
-
mode:
|
|
842
|
-
draggingSupport:
|
|
838
|
+
mode: MODE_IDLE_3D,
|
|
839
|
+
draggingSupport: Map({})
|
|
843
840
|
});
|
|
844
841
|
return {
|
|
845
842
|
updatedState: state
|
|
@@ -867,7 +864,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
867
864
|
value: function endDraggingHole(state, x, y) {
|
|
868
865
|
state = this.updateDraggingHole(state, x, y).updatedState;
|
|
869
866
|
state = state.merge({
|
|
870
|
-
mode:
|
|
867
|
+
mode: MODE_IDLE
|
|
871
868
|
});
|
|
872
869
|
return {
|
|
873
870
|
updatedState: state
|
|
@@ -884,7 +881,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
884
881
|
}, {
|
|
885
882
|
key: "setJsProperties",
|
|
886
883
|
value: function setJsProperties(state, layerID, holeID, properties) {
|
|
887
|
-
return this.setProperties(state, layerID, holeID,
|
|
884
|
+
return this.setProperties(state, layerID, holeID, fromJS(properties));
|
|
888
885
|
}
|
|
889
886
|
}, {
|
|
890
887
|
key: "updateProperties",
|
|
@@ -899,7 +896,7 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
899
896
|
}, {
|
|
900
897
|
key: "updateJsProperties",
|
|
901
898
|
value: function updateJsProperties(state, layerID, holeID, properties) {
|
|
902
|
-
return this.updateProperties(state, layerID, holeID,
|
|
899
|
+
return this.updateProperties(state, layerID, holeID, fromJS(properties));
|
|
903
900
|
}
|
|
904
901
|
}, {
|
|
905
902
|
key: "setAttributes",
|
|
@@ -911,11 +908,11 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
911
908
|
delete hAttr['offsetA'];
|
|
912
909
|
delete hAttr['offsetB'];
|
|
913
910
|
delete hAttr['offset'];
|
|
914
|
-
var misc = new
|
|
911
|
+
var misc = new Map({
|
|
915
912
|
_unitA: offsetA._unit,
|
|
916
913
|
_unitB: offsetB._unit
|
|
917
914
|
});
|
|
918
|
-
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({
|
|
919
916
|
offset: offset,
|
|
920
917
|
misc: misc
|
|
921
918
|
}));
|
|
@@ -924,4 +921,5 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
|
|
|
924
921
|
};
|
|
925
922
|
}
|
|
926
923
|
}]);
|
|
927
|
-
}();
|
|
924
|
+
}();
|
|
925
|
+
export { Hole as default };
|