kitchen-simulator 3.1.0 → 3.1.2
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/devLiteRenderer.js
CHANGED
|
@@ -20,6 +20,7 @@ import ReactDOM from 'react-dom';
|
|
|
20
20
|
import LiteRenderer from "./LiteRenderer";
|
|
21
21
|
import { Button } from 'antd';
|
|
22
22
|
import { LEFT, RIGHT, TOP, BOTTOM, EXTERNAL_EVENT_ADD_ITEM, EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, EXTERNAL_EVENT_NEW_PROJECT, EXTERNAL_EVENT_CHANGE_DOORSTYLE, EXTERNAL_EVENT_ADD_ROOM_SHAPE, EXTERNAL_EVENT_ZOOM_IN, EXTERNAL_EVENT_ZOOM_OUT, EXTERNAL_EVENT_UNDO, EXTERNAL_EVENT_REDO, EXTERNAL_EVENT_SET_MOLDING, EXTERNAL_EVENT_PROJECT_SETTING, PROJECT_SETTING_OPTION, EXTERNAL_EVENT_SYNC_SCENE, EXTERNAL_EVENT_UPDATE_ATTRIBUTE, BACK_DIST_ANG, ATT_ITEM_POS, ATT_ITEM_ROTATION, ATT_LINE_LENGTH, EXTERNAL_EVENT_UPDATE_PROPERTY, PROP_FLIP_DOOR_HANDLE, PROP_OPEN_DOORS, EXTERNAL_EVENT_LOAD_PROJECT, INTERNAL_EVENT_ITEMS_CATALOG, EXTERNAL_EVENT_ADD_HOLE, HOLE_NAMES, EXTERNAL_EVENT_CENTERING_2D, PROP_ALTITUDE, EXTERNAL_EVENT_DUPLICATE_ELEMENT, ELEMENT_ITEM, EXTERNAL_EVENT_DELETE_ELEMENT, PROP_RESIZE_WIDTH, EXTERNAL_EVENT_REPLACE_CABINET, EXTERNAL_EVENT_SET_FINISHING, FINISHING_TYPE } from "./constants";
|
|
23
|
+
import { convert } from "./utils/convert-units-lite";
|
|
23
24
|
|
|
24
25
|
// --- renderer props ---
|
|
25
26
|
var options = {
|
|
@@ -659,7 +660,26 @@ function WorkSpace(props) {
|
|
|
659
660
|
};
|
|
660
661
|
setExternalEvent(evt);
|
|
661
662
|
}
|
|
662
|
-
}, "Add room shape from width, height")
|
|
663
|
+
}, "Add room shape from width, height"), /*#__PURE__*/React.createElement(Button, {
|
|
664
|
+
actionType: "danger",
|
|
665
|
+
onClick: function onClick() {
|
|
666
|
+
var _tl = Math.floor(Math.random() * 50);
|
|
667
|
+
var tl = convert(_tl).from('in').to('cm');
|
|
668
|
+
var evt = {
|
|
669
|
+
type: EXTERNAL_EVENT_UPDATE_PROPERTY,
|
|
670
|
+
payload: {
|
|
671
|
+
propertyName: PROP_RESIZE_WIDTH,
|
|
672
|
+
value: new Map({
|
|
673
|
+
_length: _tl,
|
|
674
|
+
// inch
|
|
675
|
+
_unit: 'in',
|
|
676
|
+
length: tl // cm
|
|
677
|
+
})
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
setExternalEvent(evt);
|
|
681
|
+
}
|
|
682
|
+
}, "random width")), /*#__PURE__*/React.createElement(LiteRenderer, {
|
|
663
683
|
width: props.width,
|
|
664
684
|
height: props.height,
|
|
665
685
|
configData: mockProps.configData,
|
package/es/utils/geometry.js
CHANGED
|
@@ -2443,4 +2443,209 @@ export function validRect(itemRect, rects) {
|
|
|
2443
2443
|
return rects.every(function (rect) {
|
|
2444
2444
|
return !intersectRect(rect.rect, updatedItemRect.rect);
|
|
2445
2445
|
});
|
|
2446
|
+
}
|
|
2447
|
+
function getCalcRectFromItem2(itemInfo) {
|
|
2448
|
+
var x = itemInfo.pos.x;
|
|
2449
|
+
var y = itemInfo.pos.y;
|
|
2450
|
+
var w = itemInfo.size.width / 2;
|
|
2451
|
+
var h = itemInfo.size.height / 2;
|
|
2452
|
+
var rotRad = itemInfo.rotRad;
|
|
2453
|
+
var mh = 3 * h / 4;
|
|
2454
|
+
var mx = x - w * Math.cos(rotRad) - mh * Math.sin(rotRad);
|
|
2455
|
+
var my = y - w * Math.sin(rotRad) + mh * Math.cos(rotRad);
|
|
2456
|
+
var m2x = x + w * Math.cos(rotRad) - mh * Math.sin(rotRad);
|
|
2457
|
+
var m2y = y + w * Math.sin(rotRad) + mh * Math.cos(rotRad);
|
|
2458
|
+
var m3x = x - h * Math.sin(rotRad);
|
|
2459
|
+
var m3y = y + h * Math.cos(rotRad);
|
|
2460
|
+
var m1x = x + h * Math.sin(rotRad);
|
|
2461
|
+
var m1y = y - h * Math.cos(rotRad);
|
|
2462
|
+
var x0 = mx + h * Math.sin(rotRad);
|
|
2463
|
+
var y0 = my - h * Math.cos(rotRad);
|
|
2464
|
+
var x3 = mx * 2 - x0;
|
|
2465
|
+
var y3 = my * 2 - y0;
|
|
2466
|
+
var x1 = x * 2 - x3;
|
|
2467
|
+
var y1 = y * 2 - y3;
|
|
2468
|
+
var x2 = x * 2 - x0;
|
|
2469
|
+
var y2 = y * 2 - y0;
|
|
2470
|
+
return {
|
|
2471
|
+
rectCenterPoint: [[point(mx, my), 180], [point(m1x, m1y), -90], [point(m2x, m2y), 0], [point(m3x, m3y), 90]]
|
|
2472
|
+
};
|
|
2473
|
+
}
|
|
2474
|
+
function getAllItems2(layer, catalog) {
|
|
2475
|
+
var rectarray = [];
|
|
2476
|
+
var currentItem;
|
|
2477
|
+
var selectedItem;
|
|
2478
|
+
if (layer.selected.items.size > 0) {
|
|
2479
|
+
selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
|
|
2480
|
+
var catid = selectedItem.type;
|
|
2481
|
+
var cat = findCatalogElement(catalog, catid);
|
|
2482
|
+
currentItem = {
|
|
2483
|
+
selectedItem: selectedItem,
|
|
2484
|
+
cat: cat
|
|
2485
|
+
};
|
|
2486
|
+
}
|
|
2487
|
+
layer.items.forEach(function (item) {
|
|
2488
|
+
var val = {
|
|
2489
|
+
pos: {
|
|
2490
|
+
x: item.x,
|
|
2491
|
+
y: item.y
|
|
2492
|
+
},
|
|
2493
|
+
rotRad: item.rotation / 180 * Math.PI
|
|
2494
|
+
};
|
|
2495
|
+
var catid = item.type;
|
|
2496
|
+
var cat = findCatalogElement(catalog, catid);
|
|
2497
|
+
var width = convert(item.properties.getIn(['width', '_length'])).from('in').to('cm');
|
|
2498
|
+
var height = convert(item.properties.getIn(['depth', '_length'])).from('in').to('cm');
|
|
2499
|
+
// let width = cat.info.sizeinfo.width;
|
|
2500
|
+
// let height = cat.info.sizeinfo.depth;
|
|
2501
|
+
val.size = {
|
|
2502
|
+
width: width,
|
|
2503
|
+
height: height
|
|
2504
|
+
};
|
|
2505
|
+
var otherItem = {
|
|
2506
|
+
item: item,
|
|
2507
|
+
cat: cat
|
|
2508
|
+
};
|
|
2509
|
+
|
|
2510
|
+
// if (!GeometryUtils.needSnap(currentItem, otherItem)) {
|
|
2511
|
+
// return;
|
|
2512
|
+
// }
|
|
2513
|
+
|
|
2514
|
+
if (!item.selected) {
|
|
2515
|
+
var detectObjectsAtSameAltitudeFlag = layoutpos === 'Base' ? item.properties.getIn(['altitude', '_length']) <= altitude + tempHeight.get('_length') : item.properties.getIn(['altitude', '_length']) + item.properties.getIn(['height', '_length']) >= altitude;
|
|
2516
|
+
if (detectObjectsAtSameAltitudeFlag) {
|
|
2517
|
+
var x = val.pos.x;
|
|
2518
|
+
var y = val.pos.y;
|
|
2519
|
+
var rotRad = val.rotRad;
|
|
2520
|
+
var w = val.size.width / 2;
|
|
2521
|
+
var h = val.size.height / 2;
|
|
2522
|
+
var mx = x - w * Math.cos(rotRad);
|
|
2523
|
+
var my = y - w * Math.sin(rotRad);
|
|
2524
|
+
var x0 = mx + h * Math.sin(rotRad);
|
|
2525
|
+
var y0 = my - h * Math.cos(rotRad);
|
|
2526
|
+
var x3 = mx * 2 - x0;
|
|
2527
|
+
var y3 = my * 2 - y0;
|
|
2528
|
+
var x1 = x * 2 - x3;
|
|
2529
|
+
var y1 = y * 2 - y3;
|
|
2530
|
+
var x2 = x * 2 - x0;
|
|
2531
|
+
var y2 = y * 2 - y0;
|
|
2532
|
+
rectarray.push({
|
|
2533
|
+
rect: [point(x0, y0), point(x1, y1), point(x0, y0), point(x1, y1)]
|
|
2534
|
+
});
|
|
2535
|
+
rectarray.push({
|
|
2536
|
+
rect: [point(x1, y1), point(x2, y2), point(x1, y1), point(x2, y2)]
|
|
2537
|
+
});
|
|
2538
|
+
rectarray.push({
|
|
2539
|
+
rect: [point(x2, y2), point(x3, y3), point(x2, y2), point(x3, y3)]
|
|
2540
|
+
});
|
|
2541
|
+
rectarray.push({
|
|
2542
|
+
rect: [point(x3, y3), point(x0, y0), point(x3, y3), point(x0, y0)]
|
|
2543
|
+
});
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
});
|
|
2547
|
+
|
|
2548
|
+
// layer.holes.forEach(hole => {
|
|
2549
|
+
// let val = {pos:{x:hole.x, y:hole.y}, rotRad:hole.rotation};
|
|
2550
|
+
// let catid = hole.type;
|
|
2551
|
+
// let cat = catalog.elements[catid];
|
|
2552
|
+
// let width = hole.properties.getIn(['width']).getIn(['length']);
|
|
2553
|
+
// let height = hole.properties.getIn(['height']).getIn(['length']);
|
|
2554
|
+
// val.size = {width, height};
|
|
2555
|
+
// let otherItem = {
|
|
2556
|
+
// hole,
|
|
2557
|
+
// cat
|
|
2558
|
+
// }
|
|
2559
|
+
|
|
2560
|
+
// // if (!GeometryUtils.needSnap(currentItem, otherItem)) {
|
|
2561
|
+
// // return;
|
|
2562
|
+
// // }
|
|
2563
|
+
|
|
2564
|
+
// if (!hole.selected) {
|
|
2565
|
+
// let x = val.pos.x;
|
|
2566
|
+
// let y = val.pos.y;
|
|
2567
|
+
// let rotRad = val.rotRad;
|
|
2568
|
+
// let w = val.size.width / 2;
|
|
2569
|
+
// let mx = x - w * Math.cos(rotRad);
|
|
2570
|
+
// let my = y - w * Math.sin(rotRad);
|
|
2571
|
+
// let kx = x + w * Math.cos(rotRad);
|
|
2572
|
+
// let ky = y + w * Math.sin(rotRad);
|
|
2573
|
+
// let x0 = mx - 10 * Math.sin(rotRad);
|
|
2574
|
+
// let y0 = my + 10 * Math.cos(rotRad);
|
|
2575
|
+
// let x3 = mx + 10 * Math.sin(rotRad);
|
|
2576
|
+
// let y3 = my - 10 * Math.cos(rotRad);
|
|
2577
|
+
// let x1 = kx - 10 * Math.sin(rotRad);
|
|
2578
|
+
// let y1 = ky + 10 * Math.cos(rotRad);
|
|
2579
|
+
// let x2 = kx + 10 * Math.sin(rotRad);
|
|
2580
|
+
// let y2 = ky - 10 * Math.cos(rotRad);
|
|
2581
|
+
// rectarray.push({'rect':[point(x0,y0), point(x1,y1) ,point(x0,y0), point(x1,y1)]});
|
|
2582
|
+
// rectarray.push({'rect':[point(x1,y1), point(x2,y2), point(x1,y1), point(x2,y2)]}); // right
|
|
2583
|
+
// rectarray.push({'rect':[point(x2,y2), point(x3,y3), point(x2,y2), point(x3,y3)]}); // front
|
|
2584
|
+
// rectarray.push({'rect':[point(x3,y3), point(x0,y0), point(x3,y3), point(x0,y0)]}); // left
|
|
2585
|
+
// }
|
|
2586
|
+
// });
|
|
2587
|
+
return {
|
|
2588
|
+
others: rectarray
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2591
|
+
export function calcDistancesFromItemToWalls(attributesFormData, layer, catalog) {
|
|
2592
|
+
if (isEmpty(attributesFormData)) return [];
|
|
2593
|
+
var x = attributesFormData.get('x');
|
|
2594
|
+
var y = attributesFormData.get('y');
|
|
2595
|
+
var rotRad = attributesFormData.get('rotation') / 180 * Math.PI;
|
|
2596
|
+
var width, height;
|
|
2597
|
+
if (attributesFormData.get('properties').get('width') || attributesFormData.get('properties').get('depth')) {
|
|
2598
|
+
width = convert(attributesFormData.get('properties').get('width').get('_length')).from(attributesFormData.get('properties').get('width').get('_unit')).to('cm');
|
|
2599
|
+
height = convert(attributesFormData.get('properties').get('depth').get('_length')).from(attributesFormData.get('properties').get('depth').get('_unit')).to('cm');
|
|
2600
|
+
} else {
|
|
2601
|
+
width = convert(attributesFormData.info.sizeinfo.width).from('in').to('cm');
|
|
2602
|
+
height = convert(attributesFormData.info.sizeinfo.depth).from('in').to('cm');
|
|
2603
|
+
}
|
|
2604
|
+
var center_h = 3 * height / 8;
|
|
2605
|
+
var center_x = x;
|
|
2606
|
+
var center_y = y;
|
|
2607
|
+
var center_x1 = x - center_h * Math.sin(rotRad);
|
|
2608
|
+
var center_y1 = y + center_h * Math.cos(rotRad);
|
|
2609
|
+
var PointArray = [];
|
|
2610
|
+
var itemInfo = {
|
|
2611
|
+
pos: {
|
|
2612
|
+
x: x,
|
|
2613
|
+
y: y
|
|
2614
|
+
},
|
|
2615
|
+
rotRad: rotRad
|
|
2616
|
+
};
|
|
2617
|
+
itemInfo.size = {
|
|
2618
|
+
width: width,
|
|
2619
|
+
height: height
|
|
2620
|
+
};
|
|
2621
|
+
var curiteminfo = getCalcRectFromItem2(itemInfo);
|
|
2622
|
+
var allItemRect = getAllItems2(layer, catalog);
|
|
2623
|
+
var allLines = getAllLines(layer);
|
|
2624
|
+
var allLineRects = buildRectFromLines(layer, allLines);
|
|
2625
|
+
var allRect = allLineRects.concat(allItemRect.others);
|
|
2626
|
+
curiteminfo.rectCenterPoint.forEach(function (centerpoint) {
|
|
2627
|
+
var comparelength = [];
|
|
2628
|
+
var a;
|
|
2629
|
+
var RectLineFuction;
|
|
2630
|
+
if (centerpoint[1] === 180 || centerpoint[1] === 0) RectLineFuction = linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x1, center_y1);else RectLineFuction = linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x, center_y);
|
|
2631
|
+
allRect.forEach(function (linerect) {
|
|
2632
|
+
var p0 = clone_point(linerect.rect[2]);
|
|
2633
|
+
var p1 = clone_point(linerect.rect[3]);
|
|
2634
|
+
var lineFunction = {};
|
|
2635
|
+
if (p0.x !== p1.x || p0.y !== p1.y) lineFunction = linePassingThroughTwoPoints(p0.x, p0.y, p1.x, p1.y);
|
|
2636
|
+
var coordinatePoint = twoLinesIntersection(lineFunction.a, lineFunction.b, lineFunction.c, RectLineFuction.a, RectLineFuction.b, RectLineFuction.c);
|
|
2637
|
+
if (coordinatePoint !== undefined) {
|
|
2638
|
+
if (pointsDistance(p0.x, p0.y, p1.x, p1.y) > pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && pointsDistance(p0.x, p0.y, p1.x, p1.y) > pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
|
|
2639
|
+
if (pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
|
|
2640
|
+
comparelength.push(pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y));
|
|
2641
|
+
a = Math.min.apply(null, comparelength);
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
});
|
|
2646
|
+
PointArray.push([a, centerpoint[1]]);
|
|
2647
|
+
});
|
|
2648
|
+
return {
|
|
2649
|
+
PointArray: PointArray
|
|
2650
|
+
};
|
|
2446
2651
|
}
|
|
@@ -666,9 +666,9 @@ function initPropData(element, catalog) {
|
|
|
666
666
|
}
|
|
667
667
|
return new Map(mapped);
|
|
668
668
|
}
|
|
669
|
-
function updateAttributeOfSelectedElement(element, attrPayload, state, layer, projectActions) {
|
|
669
|
+
function updateAttributeOfSelectedElement(element, attrPayload, state, layer, catalog, projectActions) {
|
|
670
670
|
var _attributesFormData;
|
|
671
|
-
var callback = arguments.length >
|
|
671
|
+
var callback = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
672
672
|
var attributesFormData = initAttrData(element, layer, state);
|
|
673
673
|
var value = attrPayload.value;
|
|
674
674
|
var attributeName = attrPayload.attributeName;
|
|
@@ -721,6 +721,10 @@ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, pr
|
|
|
721
721
|
attributesFormData = attributesFormData.set('y', yVal);
|
|
722
722
|
} else {
|
|
723
723
|
attributesFormData = attributesFormData.set(attributeName, value);
|
|
724
|
+
// update the distances from wall
|
|
725
|
+
var _GeometryUtils$calcDi = GeometryUtils.calcDistancesFromItemToWalls(attributesFormData, layer, catalog),
|
|
726
|
+
PointArray = _GeometryUtils$calcDi.PointArray;
|
|
727
|
+
attributesFormData = attributesFormData.set('distArray', PointArray);
|
|
724
728
|
}
|
|
725
729
|
break;
|
|
726
730
|
}
|
|
@@ -1350,9 +1354,9 @@ function _handleExternalEvent() {
|
|
|
1350
1354
|
_layerId = state.getIn(['scene', 'selectedLayer']);
|
|
1351
1355
|
layer = state.getIn(['scene', 'layers', _layerId]);
|
|
1352
1356
|
_layer$getIn = layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
|
|
1353
|
-
for (_i4 = 0; _i4 < selectedLines.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, state, layer, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, props.catalog, props.projectActions, evt.callback);
|
|
1354
|
-
for (_i5 = 0; _i5 < selectedHoles.size; _i5++) (evt === null || evt === void 0 ? void 0 : evt.type) === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, state, layer, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, props.catalog, props.projectActions, evt.callback);
|
|
1355
|
-
for (_i6 = 0; _i6 < selectedItems.size; _i6++) (evt === null || evt === void 0 ? void 0 : evt.type) === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, state, layer, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, props.catalog, props.projectActions, evt.callback);
|
|
1357
|
+
for (_i4 = 0; _i4 < selectedLines.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, state, layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, props.catalog, props.projectActions, evt.callback);
|
|
1358
|
+
for (_i5 = 0; _i5 < selectedHoles.size; _i5++) (evt === null || evt === void 0 ? void 0 : evt.type) === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, state, layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, props.catalog, props.projectActions, evt.callback);
|
|
1359
|
+
for (_i6 = 0; _i6 < selectedItems.size; _i6++) (evt === null || evt === void 0 ? void 0 : evt.type) === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, state, layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, props.catalog, props.projectActions, evt.callback);
|
|
1356
1360
|
return _context1.abrupt("continue", 35);
|
|
1357
1361
|
case 31:
|
|
1358
1362
|
_layerID = state.scene.selectedLayer;
|
package/lib/devLiteRenderer.js
CHANGED
|
@@ -24,6 +24,7 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
|
24
24
|
var _LiteRenderer = _interopRequireDefault(require("./LiteRenderer"));
|
|
25
25
|
var _antd = require("antd");
|
|
26
26
|
var _constants = require("./constants");
|
|
27
|
+
var _convertUnitsLite = require("./utils/convert-units-lite");
|
|
27
28
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
28
29
|
// --- renderer props ---
|
|
29
30
|
var options = {
|
|
@@ -663,7 +664,26 @@ function WorkSpace(props) {
|
|
|
663
664
|
};
|
|
664
665
|
setExternalEvent(evt);
|
|
665
666
|
}
|
|
666
|
-
}, "Add room shape from width, height")
|
|
667
|
+
}, "Add room shape from width, height"), /*#__PURE__*/_react["default"].createElement(_antd.Button, {
|
|
668
|
+
actionType: "danger",
|
|
669
|
+
onClick: function onClick() {
|
|
670
|
+
var _tl = Math.floor(Math.random() * 50);
|
|
671
|
+
var tl = (0, _convertUnitsLite.convert)(_tl).from('in').to('cm');
|
|
672
|
+
var evt = {
|
|
673
|
+
type: _constants.EXTERNAL_EVENT_UPDATE_PROPERTY,
|
|
674
|
+
payload: {
|
|
675
|
+
propertyName: _constants.PROP_RESIZE_WIDTH,
|
|
676
|
+
value: new _immutable.Map({
|
|
677
|
+
_length: _tl,
|
|
678
|
+
// inch
|
|
679
|
+
_unit: 'in',
|
|
680
|
+
length: tl // cm
|
|
681
|
+
})
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
setExternalEvent(evt);
|
|
685
|
+
}
|
|
686
|
+
}, "random width")), /*#__PURE__*/_react["default"].createElement(_LiteRenderer["default"], {
|
|
667
687
|
width: props.width,
|
|
668
688
|
height: props.height,
|
|
669
689
|
configData: _mockProps["default"].configData,
|
package/lib/utils/geometry.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.angleBetweenTwoPoints = angleBetweenTwoPoints;
|
|
|
14
14
|
exports.angleBetweenTwoPointsAndOrigin = angleBetweenTwoPointsAndOrigin;
|
|
15
15
|
exports.buildRectFromLines = buildRectFromLines;
|
|
16
16
|
exports.calcCreateSnap = calcCreateSnap;
|
|
17
|
+
exports.calcDistancesFromItemToWalls = calcDistancesFromItemToWalls;
|
|
17
18
|
exports.calcSnap = calcSnap;
|
|
18
19
|
exports.calcSnap1 = calcSnap1;
|
|
19
20
|
exports.calcSnap2 = calcSnap2;
|
|
@@ -2542,4 +2543,209 @@ function validRect(itemRect, rects) {
|
|
|
2542
2543
|
return rects.every(function (rect) {
|
|
2543
2544
|
return !intersectRect(rect.rect, updatedItemRect.rect);
|
|
2544
2545
|
});
|
|
2546
|
+
}
|
|
2547
|
+
function getCalcRectFromItem2(itemInfo) {
|
|
2548
|
+
var x = itemInfo.pos.x;
|
|
2549
|
+
var y = itemInfo.pos.y;
|
|
2550
|
+
var w = itemInfo.size.width / 2;
|
|
2551
|
+
var h = itemInfo.size.height / 2;
|
|
2552
|
+
var rotRad = itemInfo.rotRad;
|
|
2553
|
+
var mh = 3 * h / 4;
|
|
2554
|
+
var mx = x - w * Math.cos(rotRad) - mh * Math.sin(rotRad);
|
|
2555
|
+
var my = y - w * Math.sin(rotRad) + mh * Math.cos(rotRad);
|
|
2556
|
+
var m2x = x + w * Math.cos(rotRad) - mh * Math.sin(rotRad);
|
|
2557
|
+
var m2y = y + w * Math.sin(rotRad) + mh * Math.cos(rotRad);
|
|
2558
|
+
var m3x = x - h * Math.sin(rotRad);
|
|
2559
|
+
var m3y = y + h * Math.cos(rotRad);
|
|
2560
|
+
var m1x = x + h * Math.sin(rotRad);
|
|
2561
|
+
var m1y = y - h * Math.cos(rotRad);
|
|
2562
|
+
var x0 = mx + h * Math.sin(rotRad);
|
|
2563
|
+
var y0 = my - h * Math.cos(rotRad);
|
|
2564
|
+
var x3 = mx * 2 - x0;
|
|
2565
|
+
var y3 = my * 2 - y0;
|
|
2566
|
+
var x1 = x * 2 - x3;
|
|
2567
|
+
var y1 = y * 2 - y3;
|
|
2568
|
+
var x2 = x * 2 - x0;
|
|
2569
|
+
var y2 = y * 2 - y0;
|
|
2570
|
+
return {
|
|
2571
|
+
rectCenterPoint: [[point(mx, my), 180], [point(m1x, m1y), -90], [point(m2x, m2y), 0], [point(m3x, m3y), 90]]
|
|
2572
|
+
};
|
|
2573
|
+
}
|
|
2574
|
+
function getAllItems2(layer, catalog) {
|
|
2575
|
+
var rectarray = [];
|
|
2576
|
+
var currentItem;
|
|
2577
|
+
var selectedItem;
|
|
2578
|
+
if (layer.selected.items.size > 0) {
|
|
2579
|
+
selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
|
|
2580
|
+
var catid = selectedItem.type;
|
|
2581
|
+
var cat = findCatalogElement(catalog, catid);
|
|
2582
|
+
currentItem = {
|
|
2583
|
+
selectedItem: selectedItem,
|
|
2584
|
+
cat: cat
|
|
2585
|
+
};
|
|
2586
|
+
}
|
|
2587
|
+
layer.items.forEach(function (item) {
|
|
2588
|
+
var val = {
|
|
2589
|
+
pos: {
|
|
2590
|
+
x: item.x,
|
|
2591
|
+
y: item.y
|
|
2592
|
+
},
|
|
2593
|
+
rotRad: item.rotation / 180 * Math.PI
|
|
2594
|
+
};
|
|
2595
|
+
var catid = item.type;
|
|
2596
|
+
var cat = findCatalogElement(catalog, catid);
|
|
2597
|
+
var width = (0, _convertUnitsLite.convert)(item.properties.getIn(['width', '_length'])).from('in').to('cm');
|
|
2598
|
+
var height = (0, _convertUnitsLite.convert)(item.properties.getIn(['depth', '_length'])).from('in').to('cm');
|
|
2599
|
+
// let width = cat.info.sizeinfo.width;
|
|
2600
|
+
// let height = cat.info.sizeinfo.depth;
|
|
2601
|
+
val.size = {
|
|
2602
|
+
width: width,
|
|
2603
|
+
height: height
|
|
2604
|
+
};
|
|
2605
|
+
var otherItem = {
|
|
2606
|
+
item: item,
|
|
2607
|
+
cat: cat
|
|
2608
|
+
};
|
|
2609
|
+
|
|
2610
|
+
// if (!GeometryUtils.needSnap(currentItem, otherItem)) {
|
|
2611
|
+
// return;
|
|
2612
|
+
// }
|
|
2613
|
+
|
|
2614
|
+
if (!item.selected) {
|
|
2615
|
+
var detectObjectsAtSameAltitudeFlag = layoutpos === 'Base' ? item.properties.getIn(['altitude', '_length']) <= altitude + tempHeight.get('_length') : item.properties.getIn(['altitude', '_length']) + item.properties.getIn(['height', '_length']) >= altitude;
|
|
2616
|
+
if (detectObjectsAtSameAltitudeFlag) {
|
|
2617
|
+
var x = val.pos.x;
|
|
2618
|
+
var y = val.pos.y;
|
|
2619
|
+
var rotRad = val.rotRad;
|
|
2620
|
+
var w = val.size.width / 2;
|
|
2621
|
+
var h = val.size.height / 2;
|
|
2622
|
+
var mx = x - w * Math.cos(rotRad);
|
|
2623
|
+
var my = y - w * Math.sin(rotRad);
|
|
2624
|
+
var x0 = mx + h * Math.sin(rotRad);
|
|
2625
|
+
var y0 = my - h * Math.cos(rotRad);
|
|
2626
|
+
var x3 = mx * 2 - x0;
|
|
2627
|
+
var y3 = my * 2 - y0;
|
|
2628
|
+
var x1 = x * 2 - x3;
|
|
2629
|
+
var y1 = y * 2 - y3;
|
|
2630
|
+
var x2 = x * 2 - x0;
|
|
2631
|
+
var y2 = y * 2 - y0;
|
|
2632
|
+
rectarray.push({
|
|
2633
|
+
rect: [point(x0, y0), point(x1, y1), point(x0, y0), point(x1, y1)]
|
|
2634
|
+
});
|
|
2635
|
+
rectarray.push({
|
|
2636
|
+
rect: [point(x1, y1), point(x2, y2), point(x1, y1), point(x2, y2)]
|
|
2637
|
+
});
|
|
2638
|
+
rectarray.push({
|
|
2639
|
+
rect: [point(x2, y2), point(x3, y3), point(x2, y2), point(x3, y3)]
|
|
2640
|
+
});
|
|
2641
|
+
rectarray.push({
|
|
2642
|
+
rect: [point(x3, y3), point(x0, y0), point(x3, y3), point(x0, y0)]
|
|
2643
|
+
});
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
});
|
|
2647
|
+
|
|
2648
|
+
// layer.holes.forEach(hole => {
|
|
2649
|
+
// let val = {pos:{x:hole.x, y:hole.y}, rotRad:hole.rotation};
|
|
2650
|
+
// let catid = hole.type;
|
|
2651
|
+
// let cat = catalog.elements[catid];
|
|
2652
|
+
// let width = hole.properties.getIn(['width']).getIn(['length']);
|
|
2653
|
+
// let height = hole.properties.getIn(['height']).getIn(['length']);
|
|
2654
|
+
// val.size = {width, height};
|
|
2655
|
+
// let otherItem = {
|
|
2656
|
+
// hole,
|
|
2657
|
+
// cat
|
|
2658
|
+
// }
|
|
2659
|
+
|
|
2660
|
+
// // if (!GeometryUtils.needSnap(currentItem, otherItem)) {
|
|
2661
|
+
// // return;
|
|
2662
|
+
// // }
|
|
2663
|
+
|
|
2664
|
+
// if (!hole.selected) {
|
|
2665
|
+
// let x = val.pos.x;
|
|
2666
|
+
// let y = val.pos.y;
|
|
2667
|
+
// let rotRad = val.rotRad;
|
|
2668
|
+
// let w = val.size.width / 2;
|
|
2669
|
+
// let mx = x - w * Math.cos(rotRad);
|
|
2670
|
+
// let my = y - w * Math.sin(rotRad);
|
|
2671
|
+
// let kx = x + w * Math.cos(rotRad);
|
|
2672
|
+
// let ky = y + w * Math.sin(rotRad);
|
|
2673
|
+
// let x0 = mx - 10 * Math.sin(rotRad);
|
|
2674
|
+
// let y0 = my + 10 * Math.cos(rotRad);
|
|
2675
|
+
// let x3 = mx + 10 * Math.sin(rotRad);
|
|
2676
|
+
// let y3 = my - 10 * Math.cos(rotRad);
|
|
2677
|
+
// let x1 = kx - 10 * Math.sin(rotRad);
|
|
2678
|
+
// let y1 = ky + 10 * Math.cos(rotRad);
|
|
2679
|
+
// let x2 = kx + 10 * Math.sin(rotRad);
|
|
2680
|
+
// let y2 = ky - 10 * Math.cos(rotRad);
|
|
2681
|
+
// rectarray.push({'rect':[point(x0,y0), point(x1,y1) ,point(x0,y0), point(x1,y1)]});
|
|
2682
|
+
// rectarray.push({'rect':[point(x1,y1), point(x2,y2), point(x1,y1), point(x2,y2)]}); // right
|
|
2683
|
+
// rectarray.push({'rect':[point(x2,y2), point(x3,y3), point(x2,y2), point(x3,y3)]}); // front
|
|
2684
|
+
// rectarray.push({'rect':[point(x3,y3), point(x0,y0), point(x3,y3), point(x0,y0)]}); // left
|
|
2685
|
+
// }
|
|
2686
|
+
// });
|
|
2687
|
+
return {
|
|
2688
|
+
others: rectarray
|
|
2689
|
+
};
|
|
2690
|
+
}
|
|
2691
|
+
function calcDistancesFromItemToWalls(attributesFormData, layer, catalog) {
|
|
2692
|
+
if ((0, _helper.isEmpty)(attributesFormData)) return [];
|
|
2693
|
+
var x = attributesFormData.get('x');
|
|
2694
|
+
var y = attributesFormData.get('y');
|
|
2695
|
+
var rotRad = attributesFormData.get('rotation') / 180 * Math.PI;
|
|
2696
|
+
var width, height;
|
|
2697
|
+
if (attributesFormData.get('properties').get('width') || attributesFormData.get('properties').get('depth')) {
|
|
2698
|
+
width = (0, _convertUnitsLite.convert)(attributesFormData.get('properties').get('width').get('_length')).from(attributesFormData.get('properties').get('width').get('_unit')).to('cm');
|
|
2699
|
+
height = (0, _convertUnitsLite.convert)(attributesFormData.get('properties').get('depth').get('_length')).from(attributesFormData.get('properties').get('depth').get('_unit')).to('cm');
|
|
2700
|
+
} else {
|
|
2701
|
+
width = (0, _convertUnitsLite.convert)(attributesFormData.info.sizeinfo.width).from('in').to('cm');
|
|
2702
|
+
height = (0, _convertUnitsLite.convert)(attributesFormData.info.sizeinfo.depth).from('in').to('cm');
|
|
2703
|
+
}
|
|
2704
|
+
var center_h = 3 * height / 8;
|
|
2705
|
+
var center_x = x;
|
|
2706
|
+
var center_y = y;
|
|
2707
|
+
var center_x1 = x - center_h * Math.sin(rotRad);
|
|
2708
|
+
var center_y1 = y + center_h * Math.cos(rotRad);
|
|
2709
|
+
var PointArray = [];
|
|
2710
|
+
var itemInfo = {
|
|
2711
|
+
pos: {
|
|
2712
|
+
x: x,
|
|
2713
|
+
y: y
|
|
2714
|
+
},
|
|
2715
|
+
rotRad: rotRad
|
|
2716
|
+
};
|
|
2717
|
+
itemInfo.size = {
|
|
2718
|
+
width: width,
|
|
2719
|
+
height: height
|
|
2720
|
+
};
|
|
2721
|
+
var curiteminfo = getCalcRectFromItem2(itemInfo);
|
|
2722
|
+
var allItemRect = getAllItems2(layer, catalog);
|
|
2723
|
+
var allLines = getAllLines(layer);
|
|
2724
|
+
var allLineRects = buildRectFromLines(layer, allLines);
|
|
2725
|
+
var allRect = allLineRects.concat(allItemRect.others);
|
|
2726
|
+
curiteminfo.rectCenterPoint.forEach(function (centerpoint) {
|
|
2727
|
+
var comparelength = [];
|
|
2728
|
+
var a;
|
|
2729
|
+
var RectLineFuction;
|
|
2730
|
+
if (centerpoint[1] === 180 || centerpoint[1] === 0) RectLineFuction = linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x1, center_y1);else RectLineFuction = linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x, center_y);
|
|
2731
|
+
allRect.forEach(function (linerect) {
|
|
2732
|
+
var p0 = clone_point(linerect.rect[2]);
|
|
2733
|
+
var p1 = clone_point(linerect.rect[3]);
|
|
2734
|
+
var lineFunction = {};
|
|
2735
|
+
if (p0.x !== p1.x || p0.y !== p1.y) lineFunction = linePassingThroughTwoPoints(p0.x, p0.y, p1.x, p1.y);
|
|
2736
|
+
var coordinatePoint = twoLinesIntersection(lineFunction.a, lineFunction.b, lineFunction.c, RectLineFuction.a, RectLineFuction.b, RectLineFuction.c);
|
|
2737
|
+
if (coordinatePoint !== undefined) {
|
|
2738
|
+
if (pointsDistance(p0.x, p0.y, p1.x, p1.y) > pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && pointsDistance(p0.x, p0.y, p1.x, p1.y) > pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
|
|
2739
|
+
if (pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
|
|
2740
|
+
comparelength.push(pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y));
|
|
2741
|
+
a = Math.min.apply(null, comparelength);
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
});
|
|
2746
|
+
PointArray.push([a, centerpoint[1]]);
|
|
2747
|
+
});
|
|
2748
|
+
return {
|
|
2749
|
+
PointArray: PointArray
|
|
2750
|
+
};
|
|
2545
2751
|
}
|
|
@@ -673,9 +673,9 @@ function initPropData(element, catalog) {
|
|
|
673
673
|
}
|
|
674
674
|
return new _immutable.Map(mapped);
|
|
675
675
|
}
|
|
676
|
-
function updateAttributeOfSelectedElement(element, attrPayload, state, layer, projectActions) {
|
|
676
|
+
function updateAttributeOfSelectedElement(element, attrPayload, state, layer, catalog, projectActions) {
|
|
677
677
|
var _attributesFormData;
|
|
678
|
-
var callback = arguments.length >
|
|
678
|
+
var callback = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
679
679
|
var attributesFormData = initAttrData(element, layer, state);
|
|
680
680
|
var value = attrPayload.value;
|
|
681
681
|
var attributeName = attrPayload.attributeName;
|
|
@@ -728,6 +728,10 @@ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, pr
|
|
|
728
728
|
attributesFormData = attributesFormData.set('y', yVal);
|
|
729
729
|
} else {
|
|
730
730
|
attributesFormData = attributesFormData.set(attributeName, value);
|
|
731
|
+
// update the distances from wall
|
|
732
|
+
var _GeometryUtils$calcDi = _export.GeometryUtils.calcDistancesFromItemToWalls(attributesFormData, layer, catalog),
|
|
733
|
+
PointArray = _GeometryUtils$calcDi.PointArray;
|
|
734
|
+
attributesFormData = attributesFormData.set('distArray', PointArray);
|
|
731
735
|
}
|
|
732
736
|
break;
|
|
733
737
|
}
|
|
@@ -1357,9 +1361,9 @@ function _handleExternalEvent() {
|
|
|
1357
1361
|
_layerId = state.getIn(['scene', 'selectedLayer']);
|
|
1358
1362
|
layer = state.getIn(['scene', 'layers', _layerId]);
|
|
1359
1363
|
_layer$getIn = layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
|
|
1360
|
-
for (_i4 = 0; _i4 < selectedLines.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, state, layer, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, props.catalog, props.projectActions, evt.callback);
|
|
1361
|
-
for (_i5 = 0; _i5 < selectedHoles.size; _i5++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, state, layer, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, props.catalog, props.projectActions, evt.callback);
|
|
1362
|
-
for (_i6 = 0; _i6 < selectedItems.size; _i6++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, state, layer, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, props.catalog, props.projectActions, evt.callback);
|
|
1364
|
+
for (_i4 = 0; _i4 < selectedLines.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, state, layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, props.catalog, props.projectActions, evt.callback);
|
|
1365
|
+
for (_i5 = 0; _i5 < selectedHoles.size; _i5++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, state, layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, props.catalog, props.projectActions, evt.callback);
|
|
1366
|
+
for (_i6 = 0; _i6 < selectedItems.size; _i6++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, state, layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, props.catalog, props.projectActions, evt.callback);
|
|
1363
1367
|
return _context1.abrupt("continue", 35);
|
|
1364
1368
|
case 31:
|
|
1365
1369
|
_layerID = state.scene.selectedLayer;
|