@buerli.io/react-cad 0.13.0 → 0.13.1-beta.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/build/index.cjs.js +95 -61
- package/build/index.js +95 -61
- package/build/plugins/Sketch/utils/Interaction.d.ts +2 -1
- package/package.json +4 -3
package/build/index.cjs.js
CHANGED
|
@@ -62,6 +62,49 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
62
62
|
var THREE__namespace = /*#__PURE__*/_interopNamespaceDefault(THREE);
|
|
63
63
|
var deepmerge__namespace = /*#__PURE__*/_interopNamespaceDefault(deepmerge);
|
|
64
64
|
|
|
65
|
+
const EMPTYARRAY = [];
|
|
66
|
+
const NOCCID = Number.MIN_SAFE_INTEGER;
|
|
67
|
+
const EMPTYSTR = '';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Wrapper around useDrawing which allows to avoid ReferenceErrors.
|
|
71
|
+
* Use useDrawingArr if you want to get an array from store. It returns EMPTYARRAY if requested one is undefined.
|
|
72
|
+
*
|
|
73
|
+
* @param drawingId
|
|
74
|
+
* @param selector
|
|
75
|
+
* @returns requested by selector array or EMPTYARRAY if requested is undefined or null
|
|
76
|
+
*/
|
|
77
|
+
function useDrawingArr(drawingId, selector) {
|
|
78
|
+
const res = react.useDrawing(drawingId, selector);
|
|
79
|
+
return res || EMPTYARRAY;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Wrapper around useDrawing which allows to avoid ReferenceErrors.
|
|
84
|
+
* Use useDrawingCCId if you want to get an object id from store. It returns NOCCID if requested one is undefined or null.
|
|
85
|
+
*
|
|
86
|
+
* @param drawingId
|
|
87
|
+
* @param selector
|
|
88
|
+
* @returns requested by selector object id or NOCCID if requested is undefined or null
|
|
89
|
+
*/
|
|
90
|
+
function useDrawingCCId(drawingId, selector) {
|
|
91
|
+
const res = react.useDrawing(drawingId, selector);
|
|
92
|
+
return res || NOCCID;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Wrapper around useDrawing which allows to avoid ReferenceErrors.
|
|
97
|
+
* Use useDrawingStr if you want to get a string from store. It returns EMPTYSTR if requested one is undefined.
|
|
98
|
+
*
|
|
99
|
+
* @param drawingId
|
|
100
|
+
* @param selector
|
|
101
|
+
* @returns requested by selector string or EMPTYSTRING if requested one is undefined or null
|
|
102
|
+
*/
|
|
103
|
+
function useDrawingStr(drawingId, selector) {
|
|
104
|
+
const res = react.useDrawing(drawingId, selector);
|
|
105
|
+
return res || EMPTYSTR;
|
|
106
|
+
}
|
|
107
|
+
|
|
65
108
|
function ownKeys$x(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
66
109
|
function _objectSpread$x(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$x(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$x(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
67
110
|
function getGraphicId(tree, refOrObjId) {
|
|
@@ -104,7 +147,11 @@ function getGraphicId(tree, refOrObjId) {
|
|
|
104
147
|
*/
|
|
105
148
|
|
|
106
149
|
function useSelectedItems(drawingId, refOrObjIds) {
|
|
107
|
-
const
|
|
150
|
+
const activeContainers = useDrawingArr(drawingId, d => {
|
|
151
|
+
var _d$structure$tree;
|
|
152
|
+
return (_d$structure$tree = d.structure.tree[d.structure.currentProduct || NOCCID]) == null ? void 0 : _d$structure$tree.solids;
|
|
153
|
+
});
|
|
154
|
+
const visibleContainers = useDrawingArr(drawingId, d => d.structure.visibleContainers);
|
|
108
155
|
const cacheStamp = react.useDrawing(drawingId, d => d.geometry.stamp);
|
|
109
156
|
const cache = core.getDrawing(drawingId).geometry.cache;
|
|
110
157
|
const sortedContainerIds = React.useMemo(() => {
|
|
@@ -115,9 +162,9 @@ function useSelectedItems(drawingId, refOrObjIds) {
|
|
|
115
162
|
3. Remove duplicats from elems array
|
|
116
163
|
*/
|
|
117
164
|
const allContainers = Object.getOwnPropertyNames(cache).map(n => Number(n)).sort((a, b) => b - a);
|
|
118
|
-
const
|
|
119
|
-
return
|
|
120
|
-
}, [cache, visibleContainers]);
|
|
165
|
+
const sortedContainerIds_ = [...activeContainers, ...visibleContainers, ...allContainers];
|
|
166
|
+
return sortedContainerIds_.filter((grId, i) => sortedContainerIds_.indexOf(grId) === i);
|
|
167
|
+
}, [cache, activeContainers, visibleContainers]);
|
|
121
168
|
|
|
122
169
|
// TODO: !!!Important!!! This may not properly create a graphic item for BuerliGeometry in assembly mode, but currently it isn't needed to.
|
|
123
170
|
const prodId = core.getDrawing(drawingId).structure.currentProduct;
|
|
@@ -183,10 +230,6 @@ function useSelectedItems(drawingId, refOrObjIds) {
|
|
|
183
230
|
return selectedItems;
|
|
184
231
|
}
|
|
185
232
|
|
|
186
|
-
const EMPTYARRAY = [];
|
|
187
|
-
const NOCCID = Number.MIN_SAFE_INTEGER;
|
|
188
|
-
const EMPTYSTR = '';
|
|
189
|
-
|
|
190
233
|
function ownKeys$w(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
191
234
|
function _objectSpread$w(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$w(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$w(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
192
235
|
function addMembers(drawingId, ccObjId) {
|
|
@@ -372,6 +415,7 @@ const stringifyValue = (value, type) => {
|
|
|
372
415
|
|
|
373
416
|
// Searches for an object in the tree or graphic containers
|
|
374
417
|
function findObject(drawingId, id, unrollRefs = false) {
|
|
418
|
+
var _drawing$structure$tr;
|
|
375
419
|
const drawing = core.getDrawing(drawingId);
|
|
376
420
|
const tree = drawing.structure.tree;
|
|
377
421
|
const obj = tree[id];
|
|
@@ -388,9 +432,10 @@ function findObject(drawingId, id, unrollRefs = false) {
|
|
|
388
432
|
}
|
|
389
433
|
const cache = drawing.geometry.cache;
|
|
390
434
|
const allContainers = Object.getOwnPropertyNames(cache).map(n => Number(n)).sort((a, b) => b - a);
|
|
391
|
-
const
|
|
392
|
-
const
|
|
393
|
-
|
|
435
|
+
const activeContainers = ((_drawing$structure$tr = drawing.structure.tree[drawing.structure.currentProduct || NOCCID]) == null ? void 0 : _drawing$structure$tr.solids) || [];
|
|
436
|
+
const visibleContainers = drawing.structure.visibleContainers || [];
|
|
437
|
+
let sortedContainerIds = [...activeContainers, ...visibleContainers, ...allContainers];
|
|
438
|
+
sortedContainerIds = sortedContainerIds.filter((grId, i) => sortedContainerIds.indexOf(grId) === i);
|
|
394
439
|
if (cache[graphicId]) {
|
|
395
440
|
return cache[graphicId];
|
|
396
441
|
}
|
|
@@ -506,45 +551,6 @@ function getRegionCoordSys(drawingId, regionObj) {
|
|
|
506
551
|
return [originPos, xAxis, yAxis];
|
|
507
552
|
}
|
|
508
553
|
|
|
509
|
-
/**
|
|
510
|
-
* Wrapper around useDrawing which allows to avoid ReferenceErrors.
|
|
511
|
-
* Use useDrawingArr if you want to get an array from store. It returns EMPTYARRAY if requested one is undefined.
|
|
512
|
-
*
|
|
513
|
-
* @param drawingId
|
|
514
|
-
* @param selector
|
|
515
|
-
* @returns requested by selector array or EMPTYARRAY if requested is undefined or null
|
|
516
|
-
*/
|
|
517
|
-
function useDrawingArr(drawingId, selector) {
|
|
518
|
-
const res = react.useDrawing(drawingId, selector);
|
|
519
|
-
return res || EMPTYARRAY;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* Wrapper around useDrawing which allows to avoid ReferenceErrors.
|
|
524
|
-
* Use useDrawingCCId if you want to get an object id from store. It returns NOCCID if requested one is undefined or null.
|
|
525
|
-
*
|
|
526
|
-
* @param drawingId
|
|
527
|
-
* @param selector
|
|
528
|
-
* @returns requested by selector object id or NOCCID if requested is undefined or null
|
|
529
|
-
*/
|
|
530
|
-
function useDrawingCCId(drawingId, selector) {
|
|
531
|
-
const res = react.useDrawing(drawingId, selector);
|
|
532
|
-
return res || NOCCID;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
|
-
* Wrapper around useDrawing which allows to avoid ReferenceErrors.
|
|
537
|
-
* Use useDrawingStr if you want to get a string from store. It returns EMPTYSTR if requested one is undefined.
|
|
538
|
-
*
|
|
539
|
-
* @param drawingId
|
|
540
|
-
* @param selector
|
|
541
|
-
* @returns requested by selector string or EMPTYSTRING if requested one is undefined or null
|
|
542
|
-
*/
|
|
543
|
-
function useDrawingStr(drawingId, selector) {
|
|
544
|
-
const res = react.useDrawing(drawingId, selector);
|
|
545
|
-
return res || EMPTYSTR;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
554
|
const DimSetContext = /*#__PURE__*/React.createContext({
|
|
549
555
|
globalToLocalM: new THREE__namespace.Matrix4(),
|
|
550
556
|
drawingId: -1
|
|
@@ -2583,6 +2589,9 @@ function useIsSSelected(drawingId, objId) {
|
|
|
2583
2589
|
return false;
|
|
2584
2590
|
}
|
|
2585
2591
|
const object = drawing.structure.tree[objId];
|
|
2592
|
+
if (!object) {
|
|
2593
|
+
return false;
|
|
2594
|
+
}
|
|
2586
2595
|
const selApi = drawing.api.selection;
|
|
2587
2596
|
return selApi.isItemSelected(createTreeObjSelItem(productId, object));
|
|
2588
2597
|
}, [drawingId, objId, selItems]);
|
|
@@ -3081,7 +3090,7 @@ function _objectSpread$t(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
3081
3090
|
const MateScope = 'HLConstraintScope';
|
|
3082
3091
|
const createMateItem = (matePath, csys, flip, reoriented) => {
|
|
3083
3092
|
return {
|
|
3084
|
-
id: `Mate|${matePath.toString()}|${csys.id}
|
|
3093
|
+
id: `Mate|${matePath.toString()}|${csys.id}`,
|
|
3085
3094
|
scope: MateScope,
|
|
3086
3095
|
data: {
|
|
3087
3096
|
matePath,
|
|
@@ -3399,10 +3408,11 @@ const MateRestorer = ({
|
|
|
3399
3408
|
return [createMateItem(matePath, mate, flip, reoriented)];
|
|
3400
3409
|
}, [drawingId, matePath, csysId, flip, reoriented]);
|
|
3401
3410
|
React.useEffect(() => {
|
|
3411
|
+
var _selItems$, _selector$items$, _selItems$2, _selector$items$2;
|
|
3402
3412
|
if (!selectorId) return;
|
|
3403
3413
|
const selector = core.getDrawing(drawingId).selection.refs[selectorId];
|
|
3404
3414
|
const selApi = core.getDrawing(drawingId).api.selection;
|
|
3405
|
-
if (!selApi.areItemsSelected(selItems, selectorId)
|
|
3415
|
+
if (selItems.length !== selector.items.length || !(selApi.areItemsSelected(selItems, selectorId) && ((_selItems$ = selItems[0]) == null ? void 0 : _selItems$.data.flip) === ((_selector$items$ = selector.items[0]) == null ? void 0 : _selector$items$.data.flip) && ((_selItems$2 = selItems[0]) == null ? void 0 : _selItems$2.data.reoriented) === ((_selector$items$2 = selector.items[0]) == null ? void 0 : _selector$items$2.data.reoriented))) {
|
|
3406
3416
|
setMateParam(selItems[0]);
|
|
3407
3417
|
selApi.setItems(selectorId, selItems);
|
|
3408
3418
|
}
|
|
@@ -7894,7 +7904,7 @@ const unhover = (drawingId, pluginId, objId) => {
|
|
|
7894
7904
|
const objectsNew = objects.filter(id => id !== objId);
|
|
7895
7905
|
setHoverState(drawingId, pluginId, 0, objectsNew);
|
|
7896
7906
|
};
|
|
7897
|
-
const select = (drawingId,
|
|
7907
|
+
const select = (drawingId, selectedId) => {
|
|
7898
7908
|
const drawing = core.getDrawing(drawingId);
|
|
7899
7909
|
const curProduct = drawing.structure.currentProduct;
|
|
7900
7910
|
const select_ = drawing.api.interaction.select;
|
|
@@ -7903,6 +7913,16 @@ const select = (drawingId, pluginId, selectedId) => {
|
|
|
7903
7913
|
prodRefId: curProduct
|
|
7904
7914
|
}), true);
|
|
7905
7915
|
};
|
|
7916
|
+
const setSelected = (drawingId, selectedIds) => {
|
|
7917
|
+
const drawing = core.getDrawing(drawingId);
|
|
7918
|
+
const curProduct = drawing.structure.currentProduct;
|
|
7919
|
+
const items = selectedIds.map(id => core.createInfo({
|
|
7920
|
+
objectId: id,
|
|
7921
|
+
prodRefId: curProduct
|
|
7922
|
+
}));
|
|
7923
|
+
const setSelected_ = drawing.api.interaction.setSelected;
|
|
7924
|
+
setSelected_(items);
|
|
7925
|
+
};
|
|
7906
7926
|
const tab = (drawingId, pluginId) => {
|
|
7907
7927
|
const state = getSketchState(drawingId, pluginId);
|
|
7908
7928
|
if (state.rubberBandRectangle || state.isDragged) {
|
|
@@ -8495,7 +8515,7 @@ function Drag(drawingId, pluginId, camControls) {
|
|
|
8495
8515
|
clearSelection();
|
|
8496
8516
|
return;
|
|
8497
8517
|
}
|
|
8498
|
-
select(drawingId,
|
|
8518
|
+
select(drawingId, pressedId);
|
|
8499
8519
|
}
|
|
8500
8520
|
clearIgnoreList();
|
|
8501
8521
|
clearDraggedPoints();
|
|
@@ -15519,21 +15539,18 @@ const ObjTitle = ({
|
|
|
15519
15539
|
const start = Math.min(lastSelected, index);
|
|
15520
15540
|
const end = Math.max(lastSelected, index);
|
|
15521
15541
|
const toSelect = items.slice(start, end + 1);
|
|
15522
|
-
|
|
15523
|
-
set({
|
|
15524
|
-
selected: toSelect
|
|
15525
|
-
});
|
|
15542
|
+
setSelected(drawingId, toSelect);
|
|
15526
15543
|
} else {
|
|
15527
15544
|
if (index !== undefined) {
|
|
15528
15545
|
setLastSelected(index);
|
|
15529
15546
|
}
|
|
15530
|
-
select(drawingId,
|
|
15547
|
+
select(drawingId, objId);
|
|
15531
15548
|
}
|
|
15532
15549
|
} else if (!activeHandler) {
|
|
15533
15550
|
// if no handler is active, some selector should be active
|
|
15534
15551
|
onClickSel && onClickSel(e);
|
|
15535
15552
|
}
|
|
15536
|
-
}, [drawingId,
|
|
15553
|
+
}, [drawingId, objId, index, activeHandler, onClickSel, items, lastSelected, setLastSelected]);
|
|
15537
15554
|
const onContextMenuDefault = React.useCallback(e => {
|
|
15538
15555
|
e.preventDefault();
|
|
15539
15556
|
}, []);
|
|
@@ -21523,6 +21540,22 @@ const usePatternConstraintInfo = drawingId => {
|
|
|
21523
21540
|
instances: isPatternActive ? [instanceId] : undefined
|
|
21524
21541
|
}), [isPatternActive, instanceId]);
|
|
21525
21542
|
};
|
|
21543
|
+
const useIsNestedMateSSelected = (drawingId, instanceId) => {
|
|
21544
|
+
const matePath = React.useMemo(() => getMatePath(drawingId, instanceId), [drawingId, instanceId]);
|
|
21545
|
+
return react.useDrawing(drawingId, d => {
|
|
21546
|
+
const selection = d.selection.refs[d.selection.active || ''];
|
|
21547
|
+
const selItem = selection == null ? void 0 : selection.items[0];
|
|
21548
|
+
if (!selItem || selItem.scope !== MateScope) {
|
|
21549
|
+
return false;
|
|
21550
|
+
}
|
|
21551
|
+
const selPath = selItem.data.matePath;
|
|
21552
|
+
if (matePath.length > selPath.length) {
|
|
21553
|
+
return false;
|
|
21554
|
+
}
|
|
21555
|
+
const shift = selPath.length - matePath.length;
|
|
21556
|
+
return matePath.every((id, index) => id === selPath[index + shift]);
|
|
21557
|
+
}) || false;
|
|
21558
|
+
};
|
|
21526
21559
|
|
|
21527
21560
|
// Sets all products in tree hidden/visible
|
|
21528
21561
|
function setProductsHidden(drawingId, prodId, hidden) {
|
|
@@ -21614,7 +21647,8 @@ const InstanceTitle = ({
|
|
|
21614
21647
|
const selectedIds = (selected == null ? void 0 : selected.map(sel => sel.graphicId && sel.prodRefId ? sel.prodRefId : sel.objectId)) || [];
|
|
21615
21648
|
const isGSelected = selectedIds.indexOf(instanceId) !== -1;
|
|
21616
21649
|
const isSelected = isGSelected || isSSelected;
|
|
21617
|
-
const
|
|
21650
|
+
const isMateSSelected = useIsNestedMateSSelected(drawingId, instanceId);
|
|
21651
|
+
const isHighlighted = isHovered || isSelected || isMateSSelected || ((selectedIds == null ? void 0 : selectedIds.length) === 1 ? hasSelectedChild(drawingId, instanceId, selectedIds[0]) : false);
|
|
21618
21652
|
const isBlocked = react.useDrawing(drawingId, d => {
|
|
21619
21653
|
var _d$selection$refs;
|
|
21620
21654
|
const isSelActive = d.selection.active !== null;
|
package/build/index.js
CHANGED
|
@@ -39,6 +39,49 @@ import { CSS } from '@dnd-kit/utilities';
|
|
|
39
39
|
import Tooltip$1 from 'antd/lib/tooltip';
|
|
40
40
|
import * as deepmerge from 'deepmerge';
|
|
41
41
|
|
|
42
|
+
const EMPTYARRAY = [];
|
|
43
|
+
const NOCCID = Number.MIN_SAFE_INTEGER;
|
|
44
|
+
const EMPTYSTR = '';
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Wrapper around useDrawing which allows to avoid ReferenceErrors.
|
|
48
|
+
* Use useDrawingArr if you want to get an array from store. It returns EMPTYARRAY if requested one is undefined.
|
|
49
|
+
*
|
|
50
|
+
* @param drawingId
|
|
51
|
+
* @param selector
|
|
52
|
+
* @returns requested by selector array or EMPTYARRAY if requested is undefined or null
|
|
53
|
+
*/
|
|
54
|
+
function useDrawingArr(drawingId, selector) {
|
|
55
|
+
const res = useDrawing(drawingId, selector);
|
|
56
|
+
return res || EMPTYARRAY;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Wrapper around useDrawing which allows to avoid ReferenceErrors.
|
|
61
|
+
* Use useDrawingCCId if you want to get an object id from store. It returns NOCCID if requested one is undefined or null.
|
|
62
|
+
*
|
|
63
|
+
* @param drawingId
|
|
64
|
+
* @param selector
|
|
65
|
+
* @returns requested by selector object id or NOCCID if requested is undefined or null
|
|
66
|
+
*/
|
|
67
|
+
function useDrawingCCId(drawingId, selector) {
|
|
68
|
+
const res = useDrawing(drawingId, selector);
|
|
69
|
+
return res || NOCCID;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Wrapper around useDrawing which allows to avoid ReferenceErrors.
|
|
74
|
+
* Use useDrawingStr if you want to get a string from store. It returns EMPTYSTR if requested one is undefined.
|
|
75
|
+
*
|
|
76
|
+
* @param drawingId
|
|
77
|
+
* @param selector
|
|
78
|
+
* @returns requested by selector string or EMPTYSTRING if requested one is undefined or null
|
|
79
|
+
*/
|
|
80
|
+
function useDrawingStr(drawingId, selector) {
|
|
81
|
+
const res = useDrawing(drawingId, selector);
|
|
82
|
+
return res || EMPTYSTR;
|
|
83
|
+
}
|
|
84
|
+
|
|
42
85
|
function ownKeys$x(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
43
86
|
function _objectSpread$x(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$x(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$x(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
44
87
|
function getGraphicId(tree, refOrObjId) {
|
|
@@ -81,7 +124,11 @@ function getGraphicId(tree, refOrObjId) {
|
|
|
81
124
|
*/
|
|
82
125
|
|
|
83
126
|
function useSelectedItems(drawingId, refOrObjIds) {
|
|
84
|
-
const
|
|
127
|
+
const activeContainers = useDrawingArr(drawingId, d => {
|
|
128
|
+
var _d$structure$tree;
|
|
129
|
+
return (_d$structure$tree = d.structure.tree[d.structure.currentProduct || NOCCID]) == null ? void 0 : _d$structure$tree.solids;
|
|
130
|
+
});
|
|
131
|
+
const visibleContainers = useDrawingArr(drawingId, d => d.structure.visibleContainers);
|
|
85
132
|
const cacheStamp = useDrawing(drawingId, d => d.geometry.stamp);
|
|
86
133
|
const cache = getDrawing(drawingId).geometry.cache;
|
|
87
134
|
const sortedContainerIds = React__default.useMemo(() => {
|
|
@@ -92,9 +139,9 @@ function useSelectedItems(drawingId, refOrObjIds) {
|
|
|
92
139
|
3. Remove duplicats from elems array
|
|
93
140
|
*/
|
|
94
141
|
const allContainers = Object.getOwnPropertyNames(cache).map(n => Number(n)).sort((a, b) => b - a);
|
|
95
|
-
const
|
|
96
|
-
return
|
|
97
|
-
}, [cache, visibleContainers]);
|
|
142
|
+
const sortedContainerIds_ = [...activeContainers, ...visibleContainers, ...allContainers];
|
|
143
|
+
return sortedContainerIds_.filter((grId, i) => sortedContainerIds_.indexOf(grId) === i);
|
|
144
|
+
}, [cache, activeContainers, visibleContainers]);
|
|
98
145
|
|
|
99
146
|
// TODO: !!!Important!!! This may not properly create a graphic item for BuerliGeometry in assembly mode, but currently it isn't needed to.
|
|
100
147
|
const prodId = getDrawing(drawingId).structure.currentProduct;
|
|
@@ -160,10 +207,6 @@ function useSelectedItems(drawingId, refOrObjIds) {
|
|
|
160
207
|
return selectedItems;
|
|
161
208
|
}
|
|
162
209
|
|
|
163
|
-
const EMPTYARRAY = [];
|
|
164
|
-
const NOCCID = Number.MIN_SAFE_INTEGER;
|
|
165
|
-
const EMPTYSTR = '';
|
|
166
|
-
|
|
167
210
|
function ownKeys$w(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
168
211
|
function _objectSpread$w(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$w(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$w(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
169
212
|
function addMembers(drawingId, ccObjId) {
|
|
@@ -349,6 +392,7 @@ const stringifyValue = (value, type) => {
|
|
|
349
392
|
|
|
350
393
|
// Searches for an object in the tree or graphic containers
|
|
351
394
|
function findObject(drawingId, id, unrollRefs = false) {
|
|
395
|
+
var _drawing$structure$tr;
|
|
352
396
|
const drawing = getDrawing(drawingId);
|
|
353
397
|
const tree = drawing.structure.tree;
|
|
354
398
|
const obj = tree[id];
|
|
@@ -365,9 +409,10 @@ function findObject(drawingId, id, unrollRefs = false) {
|
|
|
365
409
|
}
|
|
366
410
|
const cache = drawing.geometry.cache;
|
|
367
411
|
const allContainers = Object.getOwnPropertyNames(cache).map(n => Number(n)).sort((a, b) => b - a);
|
|
368
|
-
const
|
|
369
|
-
const
|
|
370
|
-
|
|
412
|
+
const activeContainers = ((_drawing$structure$tr = drawing.structure.tree[drawing.structure.currentProduct || NOCCID]) == null ? void 0 : _drawing$structure$tr.solids) || [];
|
|
413
|
+
const visibleContainers = drawing.structure.visibleContainers || [];
|
|
414
|
+
let sortedContainerIds = [...activeContainers, ...visibleContainers, ...allContainers];
|
|
415
|
+
sortedContainerIds = sortedContainerIds.filter((grId, i) => sortedContainerIds.indexOf(grId) === i);
|
|
371
416
|
if (cache[graphicId]) {
|
|
372
417
|
return cache[graphicId];
|
|
373
418
|
}
|
|
@@ -483,45 +528,6 @@ function getRegionCoordSys(drawingId, regionObj) {
|
|
|
483
528
|
return [originPos, xAxis, yAxis];
|
|
484
529
|
}
|
|
485
530
|
|
|
486
|
-
/**
|
|
487
|
-
* Wrapper around useDrawing which allows to avoid ReferenceErrors.
|
|
488
|
-
* Use useDrawingArr if you want to get an array from store. It returns EMPTYARRAY if requested one is undefined.
|
|
489
|
-
*
|
|
490
|
-
* @param drawingId
|
|
491
|
-
* @param selector
|
|
492
|
-
* @returns requested by selector array or EMPTYARRAY if requested is undefined or null
|
|
493
|
-
*/
|
|
494
|
-
function useDrawingArr(drawingId, selector) {
|
|
495
|
-
const res = useDrawing(drawingId, selector);
|
|
496
|
-
return res || EMPTYARRAY;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* Wrapper around useDrawing which allows to avoid ReferenceErrors.
|
|
501
|
-
* Use useDrawingCCId if you want to get an object id from store. It returns NOCCID if requested one is undefined or null.
|
|
502
|
-
*
|
|
503
|
-
* @param drawingId
|
|
504
|
-
* @param selector
|
|
505
|
-
* @returns requested by selector object id or NOCCID if requested is undefined or null
|
|
506
|
-
*/
|
|
507
|
-
function useDrawingCCId(drawingId, selector) {
|
|
508
|
-
const res = useDrawing(drawingId, selector);
|
|
509
|
-
return res || NOCCID;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Wrapper around useDrawing which allows to avoid ReferenceErrors.
|
|
514
|
-
* Use useDrawingStr if you want to get a string from store. It returns EMPTYSTR if requested one is undefined.
|
|
515
|
-
*
|
|
516
|
-
* @param drawingId
|
|
517
|
-
* @param selector
|
|
518
|
-
* @returns requested by selector string or EMPTYSTRING if requested one is undefined or null
|
|
519
|
-
*/
|
|
520
|
-
function useDrawingStr(drawingId, selector) {
|
|
521
|
-
const res = useDrawing(drawingId, selector);
|
|
522
|
-
return res || EMPTYSTR;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
531
|
const DimSetContext = /*#__PURE__*/React__default.createContext({
|
|
526
532
|
globalToLocalM: new THREE.Matrix4(),
|
|
527
533
|
drawingId: -1
|
|
@@ -2560,6 +2566,9 @@ function useIsSSelected(drawingId, objId) {
|
|
|
2560
2566
|
return false;
|
|
2561
2567
|
}
|
|
2562
2568
|
const object = drawing.structure.tree[objId];
|
|
2569
|
+
if (!object) {
|
|
2570
|
+
return false;
|
|
2571
|
+
}
|
|
2563
2572
|
const selApi = drawing.api.selection;
|
|
2564
2573
|
return selApi.isItemSelected(createTreeObjSelItem(productId, object));
|
|
2565
2574
|
}, [drawingId, objId, selItems]);
|
|
@@ -3058,7 +3067,7 @@ function _objectSpread$t(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
3058
3067
|
const MateScope = 'HLConstraintScope';
|
|
3059
3068
|
const createMateItem = (matePath, csys, flip, reoriented) => {
|
|
3060
3069
|
return {
|
|
3061
|
-
id: `Mate|${matePath.toString()}|${csys.id}
|
|
3070
|
+
id: `Mate|${matePath.toString()}|${csys.id}`,
|
|
3062
3071
|
scope: MateScope,
|
|
3063
3072
|
data: {
|
|
3064
3073
|
matePath,
|
|
@@ -3376,10 +3385,11 @@ const MateRestorer = ({
|
|
|
3376
3385
|
return [createMateItem(matePath, mate, flip, reoriented)];
|
|
3377
3386
|
}, [drawingId, matePath, csysId, flip, reoriented]);
|
|
3378
3387
|
React__default.useEffect(() => {
|
|
3388
|
+
var _selItems$, _selector$items$, _selItems$2, _selector$items$2;
|
|
3379
3389
|
if (!selectorId) return;
|
|
3380
3390
|
const selector = getDrawing(drawingId).selection.refs[selectorId];
|
|
3381
3391
|
const selApi = getDrawing(drawingId).api.selection;
|
|
3382
|
-
if (!selApi.areItemsSelected(selItems, selectorId)
|
|
3392
|
+
if (selItems.length !== selector.items.length || !(selApi.areItemsSelected(selItems, selectorId) && ((_selItems$ = selItems[0]) == null ? void 0 : _selItems$.data.flip) === ((_selector$items$ = selector.items[0]) == null ? void 0 : _selector$items$.data.flip) && ((_selItems$2 = selItems[0]) == null ? void 0 : _selItems$2.data.reoriented) === ((_selector$items$2 = selector.items[0]) == null ? void 0 : _selector$items$2.data.reoriented))) {
|
|
3383
3393
|
setMateParam(selItems[0]);
|
|
3384
3394
|
selApi.setItems(selectorId, selItems);
|
|
3385
3395
|
}
|
|
@@ -7871,7 +7881,7 @@ const unhover = (drawingId, pluginId, objId) => {
|
|
|
7871
7881
|
const objectsNew = objects.filter(id => id !== objId);
|
|
7872
7882
|
setHoverState(drawingId, pluginId, 0, objectsNew);
|
|
7873
7883
|
};
|
|
7874
|
-
const select = (drawingId,
|
|
7884
|
+
const select = (drawingId, selectedId) => {
|
|
7875
7885
|
const drawing = getDrawing(drawingId);
|
|
7876
7886
|
const curProduct = drawing.structure.currentProduct;
|
|
7877
7887
|
const select_ = drawing.api.interaction.select;
|
|
@@ -7880,6 +7890,16 @@ const select = (drawingId, pluginId, selectedId) => {
|
|
|
7880
7890
|
prodRefId: curProduct
|
|
7881
7891
|
}), true);
|
|
7882
7892
|
};
|
|
7893
|
+
const setSelected = (drawingId, selectedIds) => {
|
|
7894
|
+
const drawing = getDrawing(drawingId);
|
|
7895
|
+
const curProduct = drawing.structure.currentProduct;
|
|
7896
|
+
const items = selectedIds.map(id => createInfo({
|
|
7897
|
+
objectId: id,
|
|
7898
|
+
prodRefId: curProduct
|
|
7899
|
+
}));
|
|
7900
|
+
const setSelected_ = drawing.api.interaction.setSelected;
|
|
7901
|
+
setSelected_(items);
|
|
7902
|
+
};
|
|
7883
7903
|
const tab = (drawingId, pluginId) => {
|
|
7884
7904
|
const state = getSketchState(drawingId, pluginId);
|
|
7885
7905
|
if (state.rubberBandRectangle || state.isDragged) {
|
|
@@ -8472,7 +8492,7 @@ function Drag(drawingId, pluginId, camControls) {
|
|
|
8472
8492
|
clearSelection();
|
|
8473
8493
|
return;
|
|
8474
8494
|
}
|
|
8475
|
-
select(drawingId,
|
|
8495
|
+
select(drawingId, pressedId);
|
|
8476
8496
|
}
|
|
8477
8497
|
clearIgnoreList();
|
|
8478
8498
|
clearDraggedPoints();
|
|
@@ -15496,21 +15516,18 @@ const ObjTitle = ({
|
|
|
15496
15516
|
const start = Math.min(lastSelected, index);
|
|
15497
15517
|
const end = Math.max(lastSelected, index);
|
|
15498
15518
|
const toSelect = items.slice(start, end + 1);
|
|
15499
|
-
|
|
15500
|
-
set({
|
|
15501
|
-
selected: toSelect
|
|
15502
|
-
});
|
|
15519
|
+
setSelected(drawingId, toSelect);
|
|
15503
15520
|
} else {
|
|
15504
15521
|
if (index !== undefined) {
|
|
15505
15522
|
setLastSelected(index);
|
|
15506
15523
|
}
|
|
15507
|
-
select(drawingId,
|
|
15524
|
+
select(drawingId, objId);
|
|
15508
15525
|
}
|
|
15509
15526
|
} else if (!activeHandler) {
|
|
15510
15527
|
// if no handler is active, some selector should be active
|
|
15511
15528
|
onClickSel && onClickSel(e);
|
|
15512
15529
|
}
|
|
15513
|
-
}, [drawingId,
|
|
15530
|
+
}, [drawingId, objId, index, activeHandler, onClickSel, items, lastSelected, setLastSelected]);
|
|
15514
15531
|
const onContextMenuDefault = React__default.useCallback(e => {
|
|
15515
15532
|
e.preventDefault();
|
|
15516
15533
|
}, []);
|
|
@@ -21500,6 +21517,22 @@ const usePatternConstraintInfo = drawingId => {
|
|
|
21500
21517
|
instances: isPatternActive ? [instanceId] : undefined
|
|
21501
21518
|
}), [isPatternActive, instanceId]);
|
|
21502
21519
|
};
|
|
21520
|
+
const useIsNestedMateSSelected = (drawingId, instanceId) => {
|
|
21521
|
+
const matePath = React__default.useMemo(() => getMatePath(drawingId, instanceId), [drawingId, instanceId]);
|
|
21522
|
+
return useDrawing(drawingId, d => {
|
|
21523
|
+
const selection = d.selection.refs[d.selection.active || ''];
|
|
21524
|
+
const selItem = selection == null ? void 0 : selection.items[0];
|
|
21525
|
+
if (!selItem || selItem.scope !== MateScope) {
|
|
21526
|
+
return false;
|
|
21527
|
+
}
|
|
21528
|
+
const selPath = selItem.data.matePath;
|
|
21529
|
+
if (matePath.length > selPath.length) {
|
|
21530
|
+
return false;
|
|
21531
|
+
}
|
|
21532
|
+
const shift = selPath.length - matePath.length;
|
|
21533
|
+
return matePath.every((id, index) => id === selPath[index + shift]);
|
|
21534
|
+
}) || false;
|
|
21535
|
+
};
|
|
21503
21536
|
|
|
21504
21537
|
// Sets all products in tree hidden/visible
|
|
21505
21538
|
function setProductsHidden(drawingId, prodId, hidden) {
|
|
@@ -21591,7 +21624,8 @@ const InstanceTitle = ({
|
|
|
21591
21624
|
const selectedIds = (selected == null ? void 0 : selected.map(sel => sel.graphicId && sel.prodRefId ? sel.prodRefId : sel.objectId)) || [];
|
|
21592
21625
|
const isGSelected = selectedIds.indexOf(instanceId) !== -1;
|
|
21593
21626
|
const isSelected = isGSelected || isSSelected;
|
|
21594
|
-
const
|
|
21627
|
+
const isMateSSelected = useIsNestedMateSSelected(drawingId, instanceId);
|
|
21628
|
+
const isHighlighted = isHovered || isSelected || isMateSSelected || ((selectedIds == null ? void 0 : selectedIds.length) === 1 ? hasSelectedChild(drawingId, instanceId, selectedIds[0]) : false);
|
|
21595
21629
|
const isBlocked = useDrawing(drawingId, d => {
|
|
21596
21630
|
var _d$selection$refs;
|
|
21597
21631
|
const isSelActive = d.selection.active !== null;
|
|
@@ -2,5 +2,6 @@ import * as THREE from 'three';
|
|
|
2
2
|
import { DrawingID, PluginID, ObjectID } from '@buerli.io/core';
|
|
3
3
|
export declare const hover: (drawingId: DrawingID, pluginId: PluginID, objIds: ObjectID[], hoverPos?: THREE.Vector3) => void;
|
|
4
4
|
export declare const unhover: (drawingId: DrawingID, pluginId: PluginID, objId: ObjectID) => void;
|
|
5
|
-
export declare const select: (drawingId: DrawingID,
|
|
5
|
+
export declare const select: (drawingId: DrawingID, selectedId: ObjectID) => void;
|
|
6
|
+
export declare const setSelected: (drawingId: DrawingID, selectedIds: ObjectID[]) => void;
|
|
6
7
|
export declare const tab: (drawingId: DrawingID, pluginId: PluginID) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buerli.io/react-cad",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1-beta.2",
|
|
4
4
|
"description": "buerli CAD components",
|
|
5
5
|
"author": "AWV Informatik AG <info@awv-informatik.ch>",
|
|
6
6
|
"repository": {},
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"@typescript-eslint/parser": "^5.21.0",
|
|
57
57
|
"babel-jest": "^26.1.0",
|
|
58
58
|
"babel-plugin-module-resolver": "^4.0.0",
|
|
59
|
+
"babel-plugin-transform-import-meta": "^2.2.1",
|
|
59
60
|
"babel-polyfill": "^6.26.0",
|
|
60
61
|
"eslint": "8.0.0",
|
|
61
62
|
"eslint-config-prettier": "^8.3.0",
|
|
@@ -90,8 +91,8 @@
|
|
|
90
91
|
"react": ">=18.0"
|
|
91
92
|
},
|
|
92
93
|
"dependencies": {
|
|
93
|
-
"@buerli.io/classcad": "0.13.
|
|
94
|
-
"@buerli.io/react": "0.13.
|
|
94
|
+
"@buerli.io/classcad": "0.13.1-beta.2",
|
|
95
|
+
"@buerli.io/react": "0.13.1-beta.2",
|
|
95
96
|
"@dnd-kit/core": "^6.0.8",
|
|
96
97
|
"@dnd-kit/modifiers": "^6.0.1",
|
|
97
98
|
"@dnd-kit/sortable": "^7.0.2",
|