@buerli.io/react-cad 0.0.23-beta.4 → 0.0.23
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 +208 -180
- package/build/index.js +209 -181
- package/build/plugins/Sketch/types.d.ts +0 -1
- package/build/utils/defaultValues.d.ts +3 -0
- package/build/utils/drawing/index.d.ts +3 -0
- package/build/utils/drawing/useDrawingArr.d.ts +2 -0
- package/build/utils/drawing/useDrawingCCId.d.ts +2 -0
- package/build/utils/drawing/useDrawingStr.d.ts +2 -0
- package/package.json +3 -3
package/build/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useDrawing, CameraHelper, useBuerli, usePlugin, useEmbeddedPlugin, useGeometryInteraction, GlobalTransform, BuerliGeometry, usePluginExists, useFeaturePluginDef, raycastFilter } from '@buerli.io/react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useMemo, useRef, useCallback, useState, useEffect, memo, useContext, useReducer } from 'react';
|
|
4
|
-
import { getDrawing, createGraphicItem, GraphicType, MemberType, MathUtils, api, getPlugin,
|
|
4
|
+
import { getDrawing, createGraphicItem, GraphicType, MemberType, MathUtils, api, getPlugin, BuerliScope, Measure, MeasureResultType } from '@buerli.io/core';
|
|
5
5
|
import { CCClasses, ccAPI, ReorientedType, FlipType, BooleanOperationType, ExtrusionType, ChamferType, WorkAxisType, WorkPlaneType, WorkPointType, WorkCoordSystemType, DataType } from '@buerli.io/classcad';
|
|
6
6
|
import * as THREE from 'three';
|
|
7
7
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
@@ -1641,6 +1641,25 @@ class ErrorBoundary extends React__default.Component {
|
|
|
1641
1641
|
|
|
1642
1642
|
}
|
|
1643
1643
|
|
|
1644
|
+
const EMPTYARRAY = [];
|
|
1645
|
+
const NOCCID = Number.MIN_SAFE_INTEGER;
|
|
1646
|
+
const EMPTYSTR = '';
|
|
1647
|
+
|
|
1648
|
+
function useDrawingArr(drawingId, selector) {
|
|
1649
|
+
const res = useDrawing(drawingId, selector);
|
|
1650
|
+
return res || EMPTYARRAY;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
function useDrawingCCId(drawingId, selector) {
|
|
1654
|
+
const res = useDrawing(drawingId, selector);
|
|
1655
|
+
return res || NOCCID;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
function useDrawingStr(drawingId, selector) {
|
|
1659
|
+
const res = useDrawing(drawingId, selector);
|
|
1660
|
+
return res || EMPTYSTR;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1644
1663
|
/**
|
|
1645
1664
|
* !!! Important !!!
|
|
1646
1665
|
*
|
|
@@ -1676,11 +1695,11 @@ function useDrawingVerifier(drawingId, warnings) {
|
|
|
1676
1695
|
}
|
|
1677
1696
|
}
|
|
1678
1697
|
function useCurProductVerifier(drawingId, warnings) {
|
|
1679
|
-
const currProdId =
|
|
1698
|
+
const currProdId = useDrawingCCId(drawingId, d => {
|
|
1680
1699
|
var _d$structure;
|
|
1681
1700
|
|
|
1682
1701
|
return d == null ? void 0 : (_d$structure = d.structure) == null ? void 0 : _d$structure.currentProduct;
|
|
1683
|
-
})
|
|
1702
|
+
});
|
|
1684
1703
|
const currProdExists = useDrawing(drawingId, d => {
|
|
1685
1704
|
var _d$structure2, _d$structure2$tree$cu;
|
|
1686
1705
|
|
|
@@ -1696,11 +1715,11 @@ function useCurProductVerifier(drawingId, warnings) {
|
|
|
1696
1715
|
}
|
|
1697
1716
|
}
|
|
1698
1717
|
function useCurNodeVerifier(drawingId, warnings) {
|
|
1699
|
-
const currNodeId =
|
|
1718
|
+
const currNodeId = useDrawingCCId(drawingId, d => {
|
|
1700
1719
|
var _d$structure3;
|
|
1701
1720
|
|
|
1702
1721
|
return d == null ? void 0 : (_d$structure3 = d.structure) == null ? void 0 : _d$structure3.currentNode;
|
|
1703
|
-
})
|
|
1722
|
+
});
|
|
1704
1723
|
const currNodeExists = useDrawing(drawingId, d => {
|
|
1705
1724
|
var _d$structure4;
|
|
1706
1725
|
|
|
@@ -1716,11 +1735,11 @@ function useCurNodeVerifier(drawingId, warnings) {
|
|
|
1716
1735
|
}
|
|
1717
1736
|
}
|
|
1718
1737
|
function useRootVerifier(drawingId, warnings) {
|
|
1719
|
-
const rootId =
|
|
1738
|
+
const rootId = useDrawingCCId(drawingId, d => {
|
|
1720
1739
|
var _d$structure5;
|
|
1721
1740
|
|
|
1722
1741
|
return d == null ? void 0 : (_d$structure5 = d.structure) == null ? void 0 : _d$structure5.root;
|
|
1723
|
-
})
|
|
1742
|
+
});
|
|
1724
1743
|
const rootExists = useDrawing(drawingId, d => {
|
|
1725
1744
|
var _d$structure6;
|
|
1726
1745
|
|
|
@@ -1736,21 +1755,21 @@ function useRootVerifier(drawingId, warnings) {
|
|
|
1736
1755
|
}
|
|
1737
1756
|
}
|
|
1738
1757
|
function useRootOrProdVerifier(drawingId, warnings) {
|
|
1739
|
-
const rootId =
|
|
1758
|
+
const rootId = useDrawingCCId(drawingId, d => {
|
|
1740
1759
|
var _d$structure7;
|
|
1741
1760
|
|
|
1742
1761
|
return d == null ? void 0 : (_d$structure7 = d.structure) == null ? void 0 : _d$structure7.root;
|
|
1743
|
-
})
|
|
1762
|
+
});
|
|
1744
1763
|
const rootExists = useDrawing(drawingId, d => {
|
|
1745
1764
|
var _d$structure8;
|
|
1746
1765
|
|
|
1747
1766
|
return Boolean(d == null ? void 0 : (_d$structure8 = d.structure) == null ? void 0 : _d$structure8.tree[rootId]);
|
|
1748
1767
|
});
|
|
1749
|
-
const currProdId =
|
|
1768
|
+
const currProdId = useDrawingCCId(drawingId, d => {
|
|
1750
1769
|
var _d$structure9;
|
|
1751
1770
|
|
|
1752
1771
|
return d == null ? void 0 : (_d$structure9 = d.structure) == null ? void 0 : _d$structure9.currentProduct;
|
|
1753
|
-
})
|
|
1772
|
+
});
|
|
1754
1773
|
const currProdExists = useDrawing(drawingId, d => {
|
|
1755
1774
|
var _d$structure10, _d$structure10$tree$c;
|
|
1756
1775
|
|
|
@@ -1766,11 +1785,11 @@ function useRootOrProdVerifier(drawingId, warnings) {
|
|
|
1766
1785
|
}
|
|
1767
1786
|
}
|
|
1768
1787
|
function usePluginObjVerifier(drawingId, pluginId, warnings) {
|
|
1769
|
-
const objectId = usePlugin(drawingId, pluginId, p => p == null ? void 0 : p.objectId);
|
|
1788
|
+
const objectId = usePlugin(drawingId, pluginId, p => p == null ? void 0 : p.objectId) || NOCCID;
|
|
1770
1789
|
const objectExists = useDrawing(drawingId, d => {
|
|
1771
1790
|
var _d$structure11;
|
|
1772
1791
|
|
|
1773
|
-
return Boolean(d == null ? void 0 : (_d$structure11 = d.structure) == null ? void 0 : _d$structure11.tree[objectId
|
|
1792
|
+
return Boolean(d == null ? void 0 : (_d$structure11 = d.structure) == null ? void 0 : _d$structure11.tree[objectId]);
|
|
1774
1793
|
});
|
|
1775
1794
|
|
|
1776
1795
|
if (!objectExists) {
|
|
@@ -1783,7 +1802,7 @@ function usePluginObjVerifier(drawingId, pluginId, warnings) {
|
|
|
1783
1802
|
}
|
|
1784
1803
|
function usePartAndAssemblyContVerifier(drawingId, warnings) {
|
|
1785
1804
|
// <<< Code below is a copypaste from `useAllObjects` hook. Check comment in the beginnig of the file.
|
|
1786
|
-
const root =
|
|
1805
|
+
const root = useDrawingCCId(drawingId, d => {
|
|
1787
1806
|
var _d$structure12;
|
|
1788
1807
|
|
|
1789
1808
|
return d == null ? void 0 : (_d$structure12 = d.structure) == null ? void 0 : _d$structure12.root;
|
|
@@ -1791,7 +1810,7 @@ function usePartAndAssemblyContVerifier(drawingId, warnings) {
|
|
|
1791
1810
|
const rootExists = useDrawing(drawingId, d => {
|
|
1792
1811
|
var _d$structure13;
|
|
1793
1812
|
|
|
1794
|
-
return Boolean(d == null ? void 0 : (_d$structure13 = d.structure) == null ? void 0 : _d$structure13.tree[root
|
|
1813
|
+
return Boolean(d == null ? void 0 : (_d$structure13 = d.structure) == null ? void 0 : _d$structure13.tree[root]);
|
|
1795
1814
|
});
|
|
1796
1815
|
const allObjId = React__default.useMemo(() => {
|
|
1797
1816
|
const drawing = getDrawing(drawingId);
|
|
@@ -1824,7 +1843,7 @@ function usePartAndAssemblyContVerifier(drawingId, warnings) {
|
|
|
1824
1843
|
var _getDrawing, _getDrawing$structure, _getDrawing$structure2;
|
|
1825
1844
|
|
|
1826
1845
|
return ((_getDrawing = getDrawing(drawingId)) == null ? void 0 : (_getDrawing$structure = _getDrawing.structure) == null ? void 0 : (_getDrawing$structure2 = _getDrawing$structure.tree[id]) == null ? void 0 : _getDrawing$structure2.class) === CCClasses.CCPartContainer;
|
|
1827
|
-
}) ||
|
|
1846
|
+
}) || NOCCID;
|
|
1828
1847
|
const partContExists = useDrawing(drawingId, d => {
|
|
1829
1848
|
var _d$structure15;
|
|
1830
1849
|
|
|
@@ -1834,7 +1853,7 @@ function usePartAndAssemblyContVerifier(drawingId, warnings) {
|
|
|
1834
1853
|
var _getDrawing$structure3, _getDrawing$structure4;
|
|
1835
1854
|
|
|
1836
1855
|
return ((_getDrawing$structure3 = getDrawing(drawingId).structure) == null ? void 0 : (_getDrawing$structure4 = _getDrawing$structure3.tree[id]) == null ? void 0 : _getDrawing$structure4.class) === CCClasses.CCAssemblyContainer;
|
|
1837
|
-
}) ||
|
|
1856
|
+
}) || NOCCID;
|
|
1838
1857
|
const asmContExists = useDrawing(drawingId, d => {
|
|
1839
1858
|
var _d$structure16;
|
|
1840
1859
|
|
|
@@ -1850,16 +1869,16 @@ function usePartAndAssemblyContVerifier(drawingId, warnings) {
|
|
|
1850
1869
|
}
|
|
1851
1870
|
}
|
|
1852
1871
|
function useExprSetVerifier(drawingId, warnings) {
|
|
1853
|
-
const productId =
|
|
1872
|
+
const productId = useDrawingCCId(drawingId, d => {
|
|
1854
1873
|
var _d$structure17;
|
|
1855
1874
|
|
|
1856
1875
|
return d == null ? void 0 : (_d$structure17 = d.structure) == null ? void 0 : _d$structure17.currentProduct;
|
|
1857
|
-
})
|
|
1858
|
-
const exprSetId =
|
|
1876
|
+
});
|
|
1877
|
+
const exprSetId = useDrawingCCId(drawingId, d => {
|
|
1859
1878
|
var _d$structure18, _d$structure18$tree$p;
|
|
1860
1879
|
|
|
1861
1880
|
return d == null ? void 0 : (_d$structure18 = d.structure) == null ? void 0 : (_d$structure18$tree$p = _d$structure18.tree[productId]) == null ? void 0 : _d$structure18$tree$p.expressionSet;
|
|
1862
|
-
})
|
|
1881
|
+
});
|
|
1863
1882
|
const exprSetExists = useDrawing(drawingId, d => {
|
|
1864
1883
|
var _d$structure19;
|
|
1865
1884
|
|
|
@@ -2086,7 +2105,7 @@ function _objectSpread$j(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
2086
2105
|
const MateScope = 'HLConstraintScope';
|
|
2087
2106
|
const createMateItem = (matePath, csys, flip, reoriented) => {
|
|
2088
2107
|
return {
|
|
2089
|
-
id: `Mate|${matePath.toString()}|${csys.id}`,
|
|
2108
|
+
id: `Mate|${matePath.toString()}|${csys.id}|(${flip},${reoriented})`,
|
|
2090
2109
|
scope: MateScope,
|
|
2091
2110
|
data: {
|
|
2092
2111
|
matePath,
|
|
@@ -2880,24 +2899,15 @@ const MateEditor = ({
|
|
|
2880
2899
|
defaults
|
|
2881
2900
|
} = param;
|
|
2882
2901
|
const [matePath, csysId, flipState, reorientedState] = userValue;
|
|
2902
|
+
const isSelected = matePath !== undefined && csysId !== undefined;
|
|
2883
2903
|
const [selectorId, setSelectorId] = React__default.useState();
|
|
2884
|
-
const
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
const
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
const reorientedState_ = selectedItem == null ? void 0 : selectedItem.data.reoriented;
|
|
2892
|
-
|
|
2893
|
-
if (matePath_ && csysId_) {
|
|
2894
|
-
setUserValue([matePath_, csysId_, flipState_, reorientedState_]);
|
|
2895
|
-
|
|
2896
|
-
if (selectorId !== undefined) {
|
|
2897
|
-
selectorsOrder ? selectorsOrder.switchToNext(selectorId) : getDrawing(drawingId).api.selection.activateSelector(null);
|
|
2898
|
-
}
|
|
2899
|
-
}
|
|
2900
|
-
}, [setUserValue, selectedItem, drawingId, selectorsOrder, selectorId]); // Update the selected item with changed flip / reoriented value(s)
|
|
2904
|
+
const setMateParam = React__default.useCallback(selItem => {
|
|
2905
|
+
const matePath_ = selItem == null ? void 0 : selItem.data.matePath;
|
|
2906
|
+
const csysId_ = selItem == null ? void 0 : selItem.data.csys.id;
|
|
2907
|
+
const flipState_ = (selItem == null ? void 0 : selItem.data.flip) !== undefined ? selItem == null ? void 0 : selItem.data.flip : FlipType.FLIP_Z;
|
|
2908
|
+
const reorientedState_ = (selItem == null ? void 0 : selItem.data.reoriented) !== undefined ? selItem == null ? void 0 : selItem.data.reoriented : ReorientedType.REORIENTED_0;
|
|
2909
|
+
setUserValue([matePath_, csysId_, flipState_, reorientedState_]);
|
|
2910
|
+
}, [setUserValue]); // Update the selected item with changed flip / reoriented value(s)
|
|
2901
2911
|
// TODO: Don't store flip / reoriented states inside the selector state at all?
|
|
2902
2912
|
|
|
2903
2913
|
const setOrientation = React__default.useCallback(({
|
|
@@ -2910,11 +2920,9 @@ const MateEditor = ({
|
|
|
2910
2920
|
const flip_ = flip !== undefined ? flip : selMate.data.flip;
|
|
2911
2921
|
const reoriented_ = reoriented !== undefined ? reoriented : selMate.data.reoriented;
|
|
2912
2922
|
const newItem = createMateItem(selMate.data.matePath, selMate.data.csys, flip_, reoriented_);
|
|
2913
|
-
|
|
2914
|
-
const selectionActions = getDrawing(drawingId).api.selection;
|
|
2915
|
-
selectionActions.setItems(selectorId, [newItem]);
|
|
2923
|
+
setMateParam(newItem);
|
|
2916
2924
|
}
|
|
2917
|
-
}, [drawingId, selectorId]);
|
|
2925
|
+
}, [drawingId, setMateParam, selectorId]);
|
|
2918
2926
|
const setFlip = React__default.useCallback(value => {
|
|
2919
2927
|
setOrientation({
|
|
2920
2928
|
flip: value
|
|
@@ -2944,15 +2952,25 @@ const MateEditor = ({
|
|
|
2944
2952
|
React__default.useEffect(() => {
|
|
2945
2953
|
setValidateF(validatorWrapper, 1);
|
|
2946
2954
|
return () => setValidateF(null, 1);
|
|
2947
|
-
}, [validatorWrapper, setValidateF]);
|
|
2948
|
-
|
|
2955
|
+
}, [validatorWrapper, setValidateF]); // Function which will be called when user clicks on the mate csys
|
|
2956
|
+
|
|
2957
|
+
const customSetter = React__default.useCallback((selId, items) => {
|
|
2958
|
+
//Change reference in the param
|
|
2959
|
+
setMateParam(items[0]); // If items len === 0 selector should not be switched
|
|
2960
|
+
|
|
2961
|
+
if (items.length !== 0) {
|
|
2962
|
+
selectorsOrder ? selectorsOrder.switchToNext(selId) : getDrawing(drawingId).api.selection.activateSelector(null);
|
|
2963
|
+
}
|
|
2964
|
+
}, // TODO: there is dependency array, but customSelect will be used in Selection once on selector creating.
|
|
2965
|
+
[drawingId, selectorsOrder, setMateParam]);
|
|
2966
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MateRestorer, {
|
|
2949
2967
|
drawingId: drawingId,
|
|
2950
2968
|
matePath: matePath,
|
|
2951
2969
|
csysId: csysId,
|
|
2952
2970
|
flip: flipState,
|
|
2953
2971
|
reoriented: reorientedState,
|
|
2954
2972
|
selectorId: selectorId,
|
|
2955
|
-
|
|
2973
|
+
setMateParam: setMateParam
|
|
2956
2974
|
}), /*#__PURE__*/React__default.createElement(Wrapper, {
|
|
2957
2975
|
caption: caption,
|
|
2958
2976
|
highlighted: param.isChanged()
|
|
@@ -2960,13 +2978,17 @@ const MateEditor = ({
|
|
|
2960
2978
|
drawingId: drawingId,
|
|
2961
2979
|
filter: mateFilter,
|
|
2962
2980
|
onCreated: setSelectorId,
|
|
2963
|
-
maxLen: 1
|
|
2981
|
+
maxLen: 1,
|
|
2982
|
+
customSelect: customSetter,
|
|
2983
|
+
customUnSelect: customSetter
|
|
2964
2984
|
}), /*#__PURE__*/React__default.createElement(MateFlip, {
|
|
2965
2985
|
flipState: flipState,
|
|
2966
|
-
setFlipState: setFlip
|
|
2986
|
+
setFlipState: setFlip,
|
|
2987
|
+
disabled: !isSelected
|
|
2967
2988
|
}), /*#__PURE__*/React__default.createElement(MateReorient, {
|
|
2968
2989
|
reorientedState: reorientedState,
|
|
2969
|
-
setReorientedState: setReoriented
|
|
2990
|
+
setReorientedState: setReoriented,
|
|
2991
|
+
disabled: !isSelected
|
|
2970
2992
|
}))));
|
|
2971
2993
|
};
|
|
2972
2994
|
|
|
@@ -2977,7 +2999,7 @@ const MateRestorer = ({
|
|
|
2977
2999
|
flip,
|
|
2978
3000
|
reoriented,
|
|
2979
3001
|
selectorId,
|
|
2980
|
-
|
|
3002
|
+
setMateParam
|
|
2981
3003
|
}) => {
|
|
2982
3004
|
const selItems = React__default.useMemo(() => {
|
|
2983
3005
|
if (!matePath || !csysId) {
|
|
@@ -2990,10 +3012,14 @@ const MateRestorer = ({
|
|
|
2990
3012
|
}, [drawingId, matePath, csysId, flip, reoriented]);
|
|
2991
3013
|
React__default.useEffect(() => {
|
|
2992
3014
|
if (!selectorId) return;
|
|
2993
|
-
const
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
3015
|
+
const selector = getDrawing(drawingId).selection.refs[selectorId];
|
|
3016
|
+
const selApi = getDrawing(drawingId).api.selection;
|
|
3017
|
+
|
|
3018
|
+
if (!selApi.areItemsSelected(selItems, selectorId) || selItems.length !== selector.items.length) {
|
|
3019
|
+
setMateParam(selItems[0]);
|
|
3020
|
+
selApi.setItems(selectorId, selItems);
|
|
3021
|
+
}
|
|
3022
|
+
}, [drawingId, selItems, setMateParam, selectorId]);
|
|
2997
3023
|
return null;
|
|
2998
3024
|
};
|
|
2999
3025
|
|
|
@@ -3038,7 +3064,8 @@ const flipStates = {
|
|
|
3038
3064
|
|
|
3039
3065
|
const MateFlip = ({
|
|
3040
3066
|
flipState,
|
|
3041
|
-
setFlipState
|
|
3067
|
+
setFlipState,
|
|
3068
|
+
disabled = false
|
|
3042
3069
|
}) => {
|
|
3043
3070
|
const {
|
|
3044
3071
|
Group,
|
|
@@ -3057,7 +3084,8 @@ const MateFlip = ({
|
|
|
3057
3084
|
value: flipState,
|
|
3058
3085
|
onChange: onChange,
|
|
3059
3086
|
showArrow: false,
|
|
3060
|
-
bordered: false
|
|
3087
|
+
bordered: false,
|
|
3088
|
+
disabled: disabled
|
|
3061
3089
|
}, flipTypes.map(flip => /*#__PURE__*/React__default.createElement(Select.Option, {
|
|
3062
3090
|
key: flip,
|
|
3063
3091
|
value: flip,
|
|
@@ -3080,7 +3108,8 @@ const reorientedTypes = [ReorientedType.REORIENTED_0, ReorientedType.REORIENTED_
|
|
|
3080
3108
|
|
|
3081
3109
|
const MateReorient = ({
|
|
3082
3110
|
reorientedState,
|
|
3083
|
-
setReorientedState
|
|
3111
|
+
setReorientedState,
|
|
3112
|
+
disabled = false
|
|
3084
3113
|
}) => {
|
|
3085
3114
|
const {
|
|
3086
3115
|
Group,
|
|
@@ -3099,7 +3128,8 @@ const MateReorient = ({
|
|
|
3099
3128
|
value: reorientedState,
|
|
3100
3129
|
onChange: onChange,
|
|
3101
3130
|
showArrow: false,
|
|
3102
|
-
bordered: false
|
|
3131
|
+
bordered: false,
|
|
3132
|
+
disabled: disabled
|
|
3103
3133
|
}, reorientedTypes.map(reoriented => /*#__PURE__*/React__default.createElement(Select.Option, {
|
|
3104
3134
|
key: reoriented,
|
|
3105
3135
|
value: reoriented,
|
|
@@ -5615,7 +5645,6 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
5615
5645
|
description: description$g
|
|
5616
5646
|
});
|
|
5617
5647
|
|
|
5618
|
-
const UNDEFINEDID = -1;
|
|
5619
5648
|
// TODO use it as key in object
|
|
5620
5649
|
// TODO: move to view/handlers ?
|
|
5621
5650
|
let HandlersList;
|
|
@@ -5815,7 +5844,7 @@ const initialState = {
|
|
|
5815
5844
|
handlers: {},
|
|
5816
5845
|
tmpObjects: {},
|
|
5817
5846
|
selected: [],
|
|
5818
|
-
hovered:
|
|
5847
|
+
hovered: NOCCID,
|
|
5819
5848
|
highlighted: [],
|
|
5820
5849
|
scale: 1,
|
|
5821
5850
|
step: 1,
|
|
@@ -6088,7 +6117,7 @@ const unhover = (drawingId, pluginId, hoveredId) => {
|
|
|
6088
6117
|
const highlighted = state_.highlighted;
|
|
6089
6118
|
const highlightedConstraints = highlighted.filter(id => is2DConstraint(tree[id]));
|
|
6090
6119
|
return {
|
|
6091
|
-
hovered: state_.hovered === hoveredId ?
|
|
6120
|
+
hovered: state_.hovered === hoveredId ? NOCCID : state_.hovered,
|
|
6092
6121
|
highlighted: highlightedConstraints
|
|
6093
6122
|
};
|
|
6094
6123
|
});
|
|
@@ -6200,7 +6229,7 @@ const snapToGrid = mousePosition => {
|
|
|
6200
6229
|
|
|
6201
6230
|
const snapPoint = point => {
|
|
6202
6231
|
let snapResult = {
|
|
6203
|
-
objId:
|
|
6232
|
+
objId: NOCCID,
|
|
6204
6233
|
distance: snapDistance,
|
|
6205
6234
|
point: new THREE.Vector3()
|
|
6206
6235
|
};
|
|
@@ -6220,7 +6249,7 @@ const snapPoint = point => {
|
|
|
6220
6249
|
}
|
|
6221
6250
|
});
|
|
6222
6251
|
|
|
6223
|
-
if (snapResult.objId !==
|
|
6252
|
+
if (snapResult.objId !== NOCCID) {
|
|
6224
6253
|
return snapResult.point;
|
|
6225
6254
|
} else {
|
|
6226
6255
|
return snapToGrid(point);
|
|
@@ -6347,7 +6376,7 @@ function Drag(drawingId, pluginId, camControls) {
|
|
|
6347
6376
|
let isRectSelectionActive = false;
|
|
6348
6377
|
let rectClickPoint = new THREE.Vector3();
|
|
6349
6378
|
let rectSelected = [];
|
|
6350
|
-
let pressedId =
|
|
6379
|
+
let pressedId = NOCCID;
|
|
6351
6380
|
let moveFrom = new THREE.Vector3();
|
|
6352
6381
|
let promise = null;
|
|
6353
6382
|
let defferedDiff = null;
|
|
@@ -6400,7 +6429,7 @@ function Drag(drawingId, pluginId, camControls) {
|
|
|
6400
6429
|
};
|
|
6401
6430
|
|
|
6402
6431
|
const deleteHandler = () => {
|
|
6403
|
-
if (pressedId !==
|
|
6432
|
+
if (pressedId !== NOCCID) {
|
|
6404
6433
|
return;
|
|
6405
6434
|
}
|
|
6406
6435
|
|
|
@@ -6435,7 +6464,7 @@ function Drag(drawingId, pluginId, camControls) {
|
|
|
6435
6464
|
|
|
6436
6465
|
isRectSelectionActive = true;
|
|
6437
6466
|
rectClickPoint = e.point.project(e.camera);
|
|
6438
|
-
pressedId =
|
|
6467
|
+
pressedId = NOCCID;
|
|
6439
6468
|
camControls.enabled = false;
|
|
6440
6469
|
e.target.setPointerCapture(e.pointerId);
|
|
6441
6470
|
e.stopPropagation();
|
|
@@ -6444,13 +6473,13 @@ function Drag(drawingId, pluginId, camControls) {
|
|
|
6444
6473
|
min: rectClickPoint.clone(),
|
|
6445
6474
|
max: rectClickPoint.clone()
|
|
6446
6475
|
},
|
|
6447
|
-
hovered:
|
|
6476
|
+
hovered: NOCCID
|
|
6448
6477
|
});
|
|
6449
6478
|
return;
|
|
6450
6479
|
}
|
|
6451
6480
|
|
|
6452
6481
|
if (pressedObj.class === CCClasses.CCSketch) {
|
|
6453
|
-
pressedId =
|
|
6482
|
+
pressedId = NOCCID;
|
|
6454
6483
|
return;
|
|
6455
6484
|
}
|
|
6456
6485
|
|
|
@@ -6492,7 +6521,7 @@ function Drag(drawingId, pluginId, camControls) {
|
|
|
6492
6521
|
}
|
|
6493
6522
|
|
|
6494
6523
|
if (isMoved === false) {
|
|
6495
|
-
if (pressedId ===
|
|
6524
|
+
if (pressedId === NOCCID) {
|
|
6496
6525
|
clearSelection();
|
|
6497
6526
|
return;
|
|
6498
6527
|
}
|
|
@@ -6502,7 +6531,7 @@ function Drag(drawingId, pluginId, camControls) {
|
|
|
6502
6531
|
|
|
6503
6532
|
clearIgnoreList();
|
|
6504
6533
|
clearDraggedPoints();
|
|
6505
|
-
pressedId =
|
|
6534
|
+
pressedId = NOCCID;
|
|
6506
6535
|
e.target.releasePointerCapture(e.pointerId);
|
|
6507
6536
|
e.stopPropagation();
|
|
6508
6537
|
};
|
|
@@ -6570,7 +6599,7 @@ function Drag(drawingId, pluginId, camControls) {
|
|
|
6570
6599
|
return;
|
|
6571
6600
|
}
|
|
6572
6601
|
|
|
6573
|
-
if (pressedId ===
|
|
6602
|
+
if (pressedId === NOCCID) return;
|
|
6574
6603
|
const pressedObj = getDrawing(drawingId).structure.tree[pressedId];
|
|
6575
6604
|
if (is2DConstraint(pressedObj)) return;
|
|
6576
6605
|
const intersectionPosition = getPointOnPlane(e.unprojectedPoint, e.camera, getGlobalToLocalMatrix(drawingId, sketchId));
|
|
@@ -6710,7 +6739,7 @@ function DrawLine(drawingId, pluginId) {
|
|
|
6710
6739
|
const sketchId = getPlugin(drawingId, pluginId).objectId; // Local state:
|
|
6711
6740
|
|
|
6712
6741
|
let firstPointIsSet = false;
|
|
6713
|
-
let lastAddedEndPointId =
|
|
6742
|
+
let lastAddedEndPointId = NOCCID;
|
|
6714
6743
|
let isMoved = false;
|
|
6715
6744
|
let promise = null;
|
|
6716
6745
|
const tmpStartPId = guid();
|
|
@@ -6734,7 +6763,7 @@ function DrawLine(drawingId, pluginId) {
|
|
|
6734
6763
|
|
|
6735
6764
|
const destructor = () => {
|
|
6736
6765
|
firstPointIsSet = false;
|
|
6737
|
-
lastAddedEndPointId =
|
|
6766
|
+
lastAddedEndPointId = NOCCID;
|
|
6738
6767
|
set({
|
|
6739
6768
|
tmpObjects: {},
|
|
6740
6769
|
mousePos: undefined
|
|
@@ -6751,7 +6780,7 @@ function DrawLine(drawingId, pluginId) {
|
|
|
6751
6780
|
return true;
|
|
6752
6781
|
} else {
|
|
6753
6782
|
firstPointIsSet = false;
|
|
6754
|
-
lastAddedEndPointId =
|
|
6783
|
+
lastAddedEndPointId = NOCCID;
|
|
6755
6784
|
set(state => ({
|
|
6756
6785
|
tmpObjects: {
|
|
6757
6786
|
[tmpEndPId]: state.tmpObjects[tmpEndPId]
|
|
@@ -6799,7 +6828,7 @@ function DrawLine(drawingId, pluginId) {
|
|
|
6799
6828
|
const startPos = tmpObjects[tmpStartPId].position.clone();
|
|
6800
6829
|
const endPos = tmpObjects[tmpEndPId].position.clone();
|
|
6801
6830
|
|
|
6802
|
-
if (lastAddedEndPointId ===
|
|
6831
|
+
if (lastAddedEndPointId === NOCCID) {
|
|
6803
6832
|
promise = ccAPI.sketcher.addGeometry(drawingId, sketchId, 'Line', [startPos, endPos], {
|
|
6804
6833
|
fixation: true,
|
|
6805
6834
|
incidence: true,
|
|
@@ -7247,7 +7276,7 @@ function DrawArc(drawingId, pluginId, arcType) {
|
|
|
7247
7276
|
const sketch = getDrawing(drawingId).structure.tree[sketchId]; // Local state:
|
|
7248
7277
|
|
|
7249
7278
|
let additionIndex = 0;
|
|
7250
|
-
let lastAddedEndPointId =
|
|
7279
|
+
let lastAddedEndPointId = NOCCID;
|
|
7251
7280
|
let isMoved = false;
|
|
7252
7281
|
let tangent = new THREE.Vector3();
|
|
7253
7282
|
let lastMousePos = new THREE.Vector3();
|
|
@@ -7274,7 +7303,7 @@ function DrawArc(drawingId, pluginId, arcType) {
|
|
|
7274
7303
|
|
|
7275
7304
|
const destructor = () => {
|
|
7276
7305
|
additionIndex = 0;
|
|
7277
|
-
lastAddedEndPointId =
|
|
7306
|
+
lastAddedEndPointId = NOCCID;
|
|
7278
7307
|
set({
|
|
7279
7308
|
tmpObjects: {},
|
|
7280
7309
|
mousePos: undefined
|
|
@@ -7291,7 +7320,7 @@ function DrawArc(drawingId, pluginId, arcType) {
|
|
|
7291
7320
|
return true;
|
|
7292
7321
|
} else if (additionIndex === 1 || additionIndex === 2 && arcType === HandlersList.DRAWARCTANGENT) {
|
|
7293
7322
|
additionIndex = 0;
|
|
7294
|
-
lastAddedEndPointId =
|
|
7323
|
+
lastAddedEndPointId = NOCCID;
|
|
7295
7324
|
set(state => {
|
|
7296
7325
|
const tmpStartP = _objectSpread$b(_objectSpread$b({}, state.tmpObjects[tmpStartPId]), {}, {
|
|
7297
7326
|
position: lastMousePos.clone()
|
|
@@ -7495,7 +7524,7 @@ function DrawArc(drawingId, pluginId, arcType) {
|
|
|
7495
7524
|
radius: 1
|
|
7496
7525
|
}); // calculateMidPoint(startPos, endPos, centerPos, clockwise)
|
|
7497
7526
|
|
|
7498
|
-
if (lastAddedEndPointId ===
|
|
7527
|
+
if (lastAddedEndPointId === NOCCID) {
|
|
7499
7528
|
promise = ccAPI.sketcher.addGeometry(drawingId, sketchId, 'Arc', [startPos, midInfo.mid, endPos], {
|
|
7500
7529
|
fixation: true,
|
|
7501
7530
|
incidence: true,
|
|
@@ -8483,7 +8512,7 @@ function Trim(drawingId, pluginId) {
|
|
|
8483
8512
|
|
|
8484
8513
|
const onPointerOut = e => {
|
|
8485
8514
|
set({
|
|
8486
|
-
hovered:
|
|
8515
|
+
hovered: NOCCID,
|
|
8487
8516
|
highlighted: []
|
|
8488
8517
|
});
|
|
8489
8518
|
e.stopPropagation();
|
|
@@ -8724,7 +8753,7 @@ const getOriginByPoint = (drawingId, pointId, objectIds) => {
|
|
|
8724
8753
|
|
|
8725
8754
|
const getDefaultOriginId = (drawingId, objectIds) => {
|
|
8726
8755
|
const tree = getDrawing(drawingId).structure.tree;
|
|
8727
|
-
let originId =
|
|
8756
|
+
let originId = NOCCID;
|
|
8728
8757
|
let currentMinPos = new THREE.Vector3(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, 0.0);
|
|
8729
8758
|
objectIds.forEach(objId => {
|
|
8730
8759
|
const object = tree[objId];
|
|
@@ -8890,7 +8919,7 @@ const CircPattern = () => {
|
|
|
8890
8919
|
}
|
|
8891
8920
|
|
|
8892
8921
|
const tree = getDrawing(drawingId).structure.tree;
|
|
8893
|
-
const selectedOrigin = originId !==
|
|
8922
|
+
const selectedOrigin = originId !== NOCCID ? tree[originId] : undefined;
|
|
8894
8923
|
const rotationOriginPoint = selectedOrigin ? convertToVector(selectedOrigin.members.pos) : new THREE.Vector3(0.0, 0.0, 0.0);
|
|
8895
8924
|
const angleStep = degreesToRadians(angle);
|
|
8896
8925
|
ccAPI.sketcher.copyCircularPattern(drawingId, sketchId, rigidSetId, rotationOriginPoint, angleStep, numSteps - 1).then(() => {
|
|
@@ -10781,14 +10810,14 @@ api.subscribe(drawingIds => {
|
|
|
10781
10810
|
}, state => state.drawing.ids); //#endregion buerli store subscription
|
|
10782
10811
|
|
|
10783
10812
|
const useCurrentProduct = drawingId => {
|
|
10784
|
-
const currProdId =
|
|
10785
|
-
const currProd = useDrawing(drawingId, d => d.structure.tree[currProdId
|
|
10813
|
+
const currProdId = useDrawingCCId(drawingId, d => d.structure.currentProduct);
|
|
10814
|
+
const currProd = useDrawing(drawingId, d => d.structure.tree[currProdId]);
|
|
10786
10815
|
return currProd;
|
|
10787
10816
|
};
|
|
10788
10817
|
|
|
10789
10818
|
const useCurrentNode = drawingId => {
|
|
10790
|
-
const currNodeId =
|
|
10791
|
-
const currNode = useDrawing(drawingId, d => d.structure.tree[currNodeId
|
|
10819
|
+
const currNodeId = useDrawingCCId(drawingId, d => d.structure.currentNode);
|
|
10820
|
+
const currNode = useDrawing(drawingId, d => d.structure.tree[currNodeId]);
|
|
10792
10821
|
return currNode;
|
|
10793
10822
|
};
|
|
10794
10823
|
|
|
@@ -10801,17 +10830,17 @@ let EditMode;
|
|
|
10801
10830
|
})(EditMode || (EditMode = {}));
|
|
10802
10831
|
|
|
10803
10832
|
const useEditMode = drawingId => {
|
|
10804
|
-
const rootId =
|
|
10805
|
-
const currProdId =
|
|
10833
|
+
const rootId = useDrawingCCId(drawingId, d => d.structure.root);
|
|
10834
|
+
const currProdId = useDrawingCCId(drawingId, d => d.structure.currentProduct);
|
|
10806
10835
|
const rootClass = useDrawing(drawingId, d => {
|
|
10807
|
-
var _d$structure$tree;
|
|
10836
|
+
var _d$structure$tree$roo;
|
|
10808
10837
|
|
|
10809
|
-
return (_d$structure$tree = d.structure.tree[rootId
|
|
10838
|
+
return (_d$structure$tree$roo = d.structure.tree[rootId]) == null ? void 0 : _d$structure$tree$roo.class;
|
|
10810
10839
|
});
|
|
10811
10840
|
const currProdClass = useDrawing(drawingId, d => {
|
|
10812
|
-
var _d$structure$
|
|
10841
|
+
var _d$structure$tree$cur;
|
|
10813
10842
|
|
|
10814
|
-
return (_d$structure$
|
|
10843
|
+
return (_d$structure$tree$cur = d.structure.tree[currProdId]) == null ? void 0 : _d$structure$tree$cur.class;
|
|
10815
10844
|
});
|
|
10816
10845
|
return React__default.useMemo(() => {
|
|
10817
10846
|
const isPartRoot = Boolean(rootClass === CCClasses.CCPart);
|
|
@@ -10824,8 +10853,8 @@ const useEditMode = drawingId => {
|
|
|
10824
10853
|
|
|
10825
10854
|
const useObjectDetails = (drawingId, objectId) => {
|
|
10826
10855
|
const rootId = useDrawing(drawingId, d => d.structure.root);
|
|
10827
|
-
const currProdId =
|
|
10828
|
-
const currNodeId =
|
|
10856
|
+
const currProdId = useDrawingCCId(drawingId, d => d.structure.currentProduct);
|
|
10857
|
+
const currNodeId = useDrawingCCId(drawingId, d => d.structure.currentNode);
|
|
10829
10858
|
return React__default.useMemo(() => {
|
|
10830
10859
|
const drawing = getDrawing(drawingId);
|
|
10831
10860
|
|
|
@@ -10833,7 +10862,7 @@ const useObjectDetails = (drawingId, objectId) => {
|
|
|
10833
10862
|
const {
|
|
10834
10863
|
tree
|
|
10835
10864
|
} = drawing.structure;
|
|
10836
|
-
const obj = tree[objectId
|
|
10865
|
+
const obj = tree[objectId];
|
|
10837
10866
|
|
|
10838
10867
|
if (obj) {
|
|
10839
10868
|
const clazz = obj.class;
|
|
@@ -10874,12 +10903,12 @@ const useOperationSequence = (drawingId, partId) => {
|
|
|
10874
10903
|
} = drawing.structure;
|
|
10875
10904
|
|
|
10876
10905
|
if (children) {
|
|
10877
|
-
const opSeqId = children == null ? void 0 : children.find(id => {
|
|
10906
|
+
const opSeqId = (children == null ? void 0 : children.find(id => {
|
|
10878
10907
|
var _tree$id;
|
|
10879
10908
|
|
|
10880
10909
|
return ((_tree$id = tree[id]) == null ? void 0 : _tree$id.class) === CCClasses.CCOperationSequence;
|
|
10881
|
-
});
|
|
10882
|
-
const opSeq = tree[opSeqId
|
|
10910
|
+
})) || NOCCID;
|
|
10911
|
+
const opSeq = tree[opSeqId];
|
|
10883
10912
|
|
|
10884
10913
|
if (opSeq) {
|
|
10885
10914
|
return opSeq.id;
|
|
@@ -10892,11 +10921,11 @@ const useOperationSequence = (drawingId, partId) => {
|
|
|
10892
10921
|
};
|
|
10893
10922
|
|
|
10894
10923
|
const useRollbackBar = (drawingId, partId) => {
|
|
10895
|
-
const opSeqId = useOperationSequence(drawingId, partId);
|
|
10924
|
+
const opSeqId = useOperationSequence(drawingId, partId) || NOCCID;
|
|
10896
10925
|
const opSeqChildren = useDrawing(drawingId, d => {
|
|
10897
|
-
var _d$structure$tree;
|
|
10926
|
+
var _d$structure$tree$opS;
|
|
10898
10927
|
|
|
10899
|
-
return (_d$structure$tree = d.structure.tree[opSeqId
|
|
10928
|
+
return (_d$structure$tree$opS = d.structure.tree[opSeqId]) == null ? void 0 : _d$structure$tree$opS.children;
|
|
10900
10929
|
});
|
|
10901
10930
|
return React__default.useMemo(() => {
|
|
10902
10931
|
const drawing = getDrawing(drawingId);
|
|
@@ -10905,18 +10934,18 @@ const useRollbackBar = (drawingId, partId) => {
|
|
|
10905
10934
|
const {
|
|
10906
10935
|
tree
|
|
10907
10936
|
} = drawing.structure;
|
|
10908
|
-
const opSeq = tree[opSeqId
|
|
10937
|
+
const opSeq = tree[opSeqId];
|
|
10909
10938
|
|
|
10910
10939
|
if (opSeq && opSeqChildren) {
|
|
10911
|
-
const rollbackBarId = opSeqChildren == null ? void 0 : opSeqChildren.find(id => {
|
|
10940
|
+
const rollbackBarId = (opSeqChildren == null ? void 0 : opSeqChildren.find(id => {
|
|
10912
10941
|
var _tree$id;
|
|
10913
10942
|
|
|
10914
10943
|
return ((_tree$id = tree[id]) == null ? void 0 : _tree$id.class) === CCClasses.CCRollbackBar;
|
|
10915
|
-
});
|
|
10916
|
-
const rollbackBarIndex = (opSeqChildren == null ? void 0 : opSeqChildren.indexOf(rollbackBarId
|
|
10944
|
+
})) || NOCCID;
|
|
10945
|
+
const rollbackBarIndex = (opSeqChildren == null ? void 0 : opSeqChildren.indexOf(rollbackBarId)) || -1;
|
|
10917
10946
|
return {
|
|
10918
10947
|
operationSequence: opSeq,
|
|
10919
|
-
rollbackBar: tree[rollbackBarId
|
|
10948
|
+
rollbackBar: tree[rollbackBarId],
|
|
10920
10949
|
rollbackBarIndex: rollbackBarIndex
|
|
10921
10950
|
};
|
|
10922
10951
|
}
|
|
@@ -11151,8 +11180,8 @@ const ObjTitle = ({
|
|
|
11151
11180
|
drawingId,
|
|
11152
11181
|
pluginId
|
|
11153
11182
|
} = React__default.useContext(RootContext);
|
|
11154
|
-
const name =
|
|
11155
|
-
const objClass =
|
|
11183
|
+
const name = useDrawingStr(drawingId, d => d.structure.tree[objId].name);
|
|
11184
|
+
const objClass = useDrawingStr(drawingId, d => d.structure.tree[objId].class);
|
|
11156
11185
|
const isHovered = useSketchState(drawingId, pluginId, s => s.hovered === objId);
|
|
11157
11186
|
const isSelected = useSketchState(drawingId, pluginId, s => s.selected.indexOf(objId) !== -1);
|
|
11158
11187
|
const color = isSelected ? '#ffa500' : isHovered ? '#28d79f' : undefined; // TODO: Rename resources so that they have more generic names, i.e. 'CC_Point' instead of 'drawPoint', etc
|
|
@@ -11232,7 +11261,7 @@ const SketchObj = ({
|
|
|
11232
11261
|
const {
|
|
11233
11262
|
drawingId
|
|
11234
11263
|
} = React__default.useContext(RootContext);
|
|
11235
|
-
const children =
|
|
11264
|
+
const children = useDrawingArr(drawingId, d => d.structure.tree[objId].children);
|
|
11236
11265
|
const [collapsed, setCollapsed] = React__default.useState(true);
|
|
11237
11266
|
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(FlexRow, null, /*#__PURE__*/React__default.createElement(Indents, {
|
|
11238
11267
|
level: level
|
|
@@ -11311,8 +11340,8 @@ const PlaneSelectionMode = ({
|
|
|
11311
11340
|
} = useBuerli(buerli => buerli.options.elements);
|
|
11312
11341
|
const sketchId = usePlugin(drawingId, pluginId, plugin => plugin.objectId);
|
|
11313
11342
|
const curProduct = useDrawing(drawingId, d => d.structure.currentProduct);
|
|
11314
|
-
const opSeqId = useOperationSequence(drawingId, curProduct) ||
|
|
11315
|
-
const opSeqChildren =
|
|
11343
|
+
const opSeqId = useOperationSequence(drawingId, curProduct) || NOCCID;
|
|
11344
|
+
const opSeqChildren = useDrawingArr(drawingId, d => d.structure.tree[opSeqId].children); // Makes base planes visible when just created, and turns them off after initialization (i.e. selecting a plane)
|
|
11316
11345
|
|
|
11317
11346
|
React__default.useEffect(() => {
|
|
11318
11347
|
if (opSeqChildren.length < 7) {
|
|
@@ -11501,7 +11530,7 @@ const RootImpl$f = ({
|
|
|
11501
11530
|
plugin.set({
|
|
11502
11531
|
tmpObjects: {},
|
|
11503
11532
|
selected: [],
|
|
11504
|
-
hovered:
|
|
11533
|
+
hovered: NOCCID,
|
|
11505
11534
|
highlighted: []
|
|
11506
11535
|
});
|
|
11507
11536
|
}
|
|
@@ -11585,8 +11614,8 @@ function useRefsReset(type, refs) {
|
|
|
11585
11614
|
}
|
|
11586
11615
|
|
|
11587
11616
|
const useAllObjects = drawingId => {
|
|
11588
|
-
const root =
|
|
11589
|
-
const rootExists = useDrawing(drawingId, d => Boolean(d.structure.tree[root
|
|
11617
|
+
const root = useDrawingCCId(drawingId, d => d.structure.root);
|
|
11618
|
+
const rootExists = useDrawing(drawingId, d => Boolean(d.structure.tree[root]));
|
|
11590
11619
|
return React__default.useMemo(() => {
|
|
11591
11620
|
const drawing = getDrawing(drawingId);
|
|
11592
11621
|
|
|
@@ -12553,8 +12582,8 @@ function RootImpl$b({
|
|
|
12553
12582
|
|
|
12554
12583
|
// We do not expect that the 'currentProduct' can change while a plugin is open,
|
|
12555
12584
|
// so we don't have to listen for changes to 'currentProduct' and access it statically.
|
|
12556
|
-
const geomSetId = (_structure$tree = structure.tree[structure.currentProduct]) == null ? void 0 : _structure$tree.geometrySet;
|
|
12557
|
-
const geomSet = structure.tree[geomSetId
|
|
12585
|
+
const geomSetId = ((_structure$tree = structure.tree[structure.currentProduct]) == null ? void 0 : _structure$tree.geometrySet) || NOCCID;
|
|
12586
|
+
const geomSet = structure.tree[geomSetId];
|
|
12558
12587
|
|
|
12559
12588
|
if (geomSet && geomSet.children && geomSet.children.length > 0) {
|
|
12560
12589
|
const geomObjects = geomSet.children.map(childId => structure.tree[childId]);
|
|
@@ -13741,30 +13770,30 @@ function useFeaturesIds(drawingId, curNodeId) {
|
|
|
13741
13770
|
|
|
13742
13771
|
return curNodeId;
|
|
13743
13772
|
});
|
|
13744
|
-
const opSeqId = useOperationSequence(drawingId, prodId);
|
|
13745
|
-
const opSeqChildren =
|
|
13746
|
-
var _d$structure$tree;
|
|
13773
|
+
const opSeqId = useOperationSequence(drawingId, prodId) || NOCCID;
|
|
13774
|
+
const opSeqChildren = useDrawingArr(drawingId, d => {
|
|
13775
|
+
var _d$structure$tree$opS;
|
|
13747
13776
|
|
|
13748
|
-
return (_d$structure$tree = d.structure.tree[opSeqId
|
|
13777
|
+
return (_d$structure$tree$opS = d.structure.tree[opSeqId]) == null ? void 0 : _d$structure$tree$opS.children;
|
|
13749
13778
|
});
|
|
13750
13779
|
const tree = getDrawing(drawingId).structure.tree;
|
|
13751
|
-
const featureIds =
|
|
13780
|
+
const featureIds = opSeqChildren.map(refId => tree[refId].members.refObj.value);
|
|
13752
13781
|
return featureIds;
|
|
13753
13782
|
}
|
|
13754
13783
|
function getFeaturesIds(drawingId, curNodeId) {
|
|
13755
|
-
var _tree$prodId, _tree;
|
|
13784
|
+
var _tree$prodId, _tree$opSeqId;
|
|
13756
13785
|
|
|
13757
13786
|
const tree = getDrawing(drawingId).structure.tree;
|
|
13758
13787
|
const curClass = tree[curNodeId].class;
|
|
13759
13788
|
const prodId = curClass === CCClasses.CCProductReference || curClass === CCClasses.CCProductReferenceET ? tree[curNodeId].members.productId.value : curNodeId;
|
|
13760
|
-
const prodChildren = (_tree$prodId = tree[prodId]) == null ? void 0 : _tree$prodId.children;
|
|
13761
|
-
const opSeqId = prodChildren
|
|
13789
|
+
const prodChildren = ((_tree$prodId = tree[prodId]) == null ? void 0 : _tree$prodId.children) || [];
|
|
13790
|
+
const opSeqId = prodChildren.find(id => {
|
|
13762
13791
|
var _tree$id;
|
|
13763
13792
|
|
|
13764
13793
|
return ((_tree$id = tree[id]) == null ? void 0 : _tree$id.class) === CCClasses.CCOperationSequence;
|
|
13765
|
-
});
|
|
13766
|
-
const opSeqChildren = (_tree = tree[opSeqId
|
|
13767
|
-
const featureIds =
|
|
13794
|
+
}) || NOCCID;
|
|
13795
|
+
const opSeqChildren = ((_tree$opSeqId = tree[opSeqId]) == null ? void 0 : _tree$opSeqId.children) || [];
|
|
13796
|
+
const featureIds = opSeqChildren.map(refId => tree[refId].members.refObj.value);
|
|
13768
13797
|
return featureIds;
|
|
13769
13798
|
}
|
|
13770
13799
|
|
|
@@ -16191,20 +16220,20 @@ const Parts = ({
|
|
|
16191
16220
|
pluginId
|
|
16192
16221
|
}) => {
|
|
16193
16222
|
const allObjId = useAllObjects(drawingId);
|
|
16194
|
-
const allObjsChilds =
|
|
16223
|
+
const allObjsChilds = useDrawingArr(drawingId, d => {
|
|
16195
16224
|
var _d$structure$tree$all;
|
|
16196
16225
|
|
|
16197
|
-
return (
|
|
16226
|
+
return (_d$structure$tree$all = d.structure.tree[allObjId]) == null ? void 0 : _d$structure$tree$all.children;
|
|
16198
16227
|
});
|
|
16199
16228
|
const partContId = allObjsChilds.find(id => {
|
|
16200
16229
|
var _getDrawing$structure;
|
|
16201
16230
|
|
|
16202
16231
|
return ((_getDrawing$structure = getDrawing(drawingId).structure.tree[id]) == null ? void 0 : _getDrawing$structure.class) === CCClasses.CCPartContainer;
|
|
16203
16232
|
});
|
|
16204
|
-
const partsIds =
|
|
16233
|
+
const partsIds = useDrawingArr(drawingId, d => {
|
|
16205
16234
|
var _d$structure$tree$par;
|
|
16206
16235
|
|
|
16207
|
-
return (
|
|
16236
|
+
return (_d$structure$tree$par = d.structure.tree[partContId]) == null ? void 0 : _d$structure$tree$par.children;
|
|
16208
16237
|
});
|
|
16209
16238
|
const [createMode, setCreateMode] = React__default.useState(false);
|
|
16210
16239
|
const data = useTableData(partsIds, 'part', createMode);
|
|
@@ -16239,20 +16268,20 @@ const Assemblies = ({
|
|
|
16239
16268
|
pluginId
|
|
16240
16269
|
}) => {
|
|
16241
16270
|
const allObjId = useAllObjects(drawingId);
|
|
16242
|
-
const allObjsChilds =
|
|
16271
|
+
const allObjsChilds = useDrawingArr(drawingId, d => {
|
|
16243
16272
|
var _d$structure$tree$all2;
|
|
16244
16273
|
|
|
16245
|
-
return (
|
|
16274
|
+
return (_d$structure$tree$all2 = d.structure.tree[allObjId]) == null ? void 0 : _d$structure$tree$all2.children;
|
|
16246
16275
|
});
|
|
16247
16276
|
const assemblyContId = allObjsChilds.find(id => {
|
|
16248
16277
|
var _getDrawing$structure2;
|
|
16249
16278
|
|
|
16250
16279
|
return ((_getDrawing$structure2 = getDrawing(drawingId).structure.tree[id]) == null ? void 0 : _getDrawing$structure2.class) === CCClasses.CCAssemblyContainer;
|
|
16251
16280
|
});
|
|
16252
|
-
const assembliesIds =
|
|
16281
|
+
const assembliesIds = useDrawingArr(drawingId, d => {
|
|
16253
16282
|
var _d$structure$tree$ass;
|
|
16254
16283
|
|
|
16255
|
-
return (
|
|
16284
|
+
return (_d$structure$tree$ass = d.structure.tree[assemblyContId]) == null ? void 0 : _d$structure$tree$ass.children;
|
|
16256
16285
|
});
|
|
16257
16286
|
const [createMode, setCreateMode] = React__default.useState(false);
|
|
16258
16287
|
const data = useTableData(assembliesIds, 'asm', createMode);
|
|
@@ -17789,14 +17818,14 @@ const FPluginWindow = ({
|
|
|
17789
17818
|
const FeaturePlugin = ({
|
|
17790
17819
|
drawingId
|
|
17791
17820
|
}) => {
|
|
17792
|
-
const activeFeature = useDrawing(drawingId, d => d.plugin.active.feature); // Feature plugins are lazy loaded, so it's possible that recently activated feature plugins hasn't been created yet
|
|
17821
|
+
const activeFeature = useDrawing(drawingId, d => d.plugin.active.feature) || NOCCID; // Feature plugins are lazy loaded, so it's possible that recently activated feature plugins hasn't been created yet
|
|
17793
17822
|
|
|
17794
|
-
const isCreated = usePluginExists(drawingId, activeFeature
|
|
17795
|
-
const name =
|
|
17796
|
-
if (!activeFeature || !isCreated) return
|
|
17823
|
+
const isCreated = usePluginExists(drawingId, activeFeature);
|
|
17824
|
+
const name = useDrawingStr(drawingId, d => {
|
|
17825
|
+
if (!activeFeature || !isCreated) return undefined;
|
|
17797
17826
|
const objId = d.plugin.refs[activeFeature].objectId;
|
|
17798
17827
|
const plugin = d.structure.tree[objId];
|
|
17799
|
-
return
|
|
17828
|
+
return plugin == null ? void 0 : plugin.name;
|
|
17800
17829
|
});
|
|
17801
17830
|
const pluginAPI = getDrawing(drawingId).api.plugin;
|
|
17802
17831
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(DraggableModalProvider, null, activeFeature && isCreated && /*#__PURE__*/React__default.createElement(DraggableModal, {
|
|
@@ -17898,35 +17927,35 @@ function useMenuItems$2(drawingId, featureId, isActive, setEditName) {
|
|
|
17898
17927
|
|
|
17899
17928
|
function useIsCustom(drawingId, featureRefId) {
|
|
17900
17929
|
const curProduct = useDrawing(drawingId, d => d.structure.currentProduct);
|
|
17901
|
-
const opSeqId = useOperationSequence(drawingId, curProduct);
|
|
17902
|
-
const opSeqChildren =
|
|
17903
|
-
var _d$structure$tree;
|
|
17930
|
+
const opSeqId = useOperationSequence(drawingId, curProduct) || NOCCID;
|
|
17931
|
+
const opSeqChildren = useDrawingArr(drawingId, d => {
|
|
17932
|
+
var _d$structure$tree$opS;
|
|
17904
17933
|
|
|
17905
|
-
return (_d$structure$tree = d.structure.tree[opSeqId
|
|
17906
|
-
})
|
|
17934
|
+
return (_d$structure$tree$opS = d.structure.tree[opSeqId]) == null ? void 0 : _d$structure$tree$opS.children;
|
|
17935
|
+
}); // First 7 elements in operationSequence are features created by default (origin, x,y,z axes and planes) => they're not custom
|
|
17907
17936
|
|
|
17908
17937
|
return opSeqChildren.indexOf(featureRefId) > 6;
|
|
17909
17938
|
}
|
|
17910
17939
|
|
|
17911
17940
|
function usePrecheckErrorId(drawingId, featureId) {
|
|
17912
17941
|
const curProduct = useDrawing(drawingId, d => d.structure.currentProduct);
|
|
17913
|
-
const opSeqId = useOperationSequence(drawingId, curProduct) ||
|
|
17914
|
-
const opSeqChildren =
|
|
17915
|
-
var _d$structure$tree$
|
|
17942
|
+
const opSeqId = useOperationSequence(drawingId, curProduct) || NOCCID;
|
|
17943
|
+
const opSeqChildren = useDrawingArr(drawingId, d => {
|
|
17944
|
+
var _d$structure$tree$opS2;
|
|
17916
17945
|
|
|
17917
|
-
return (_d$structure$tree$
|
|
17918
|
-
})
|
|
17946
|
+
return (_d$structure$tree$opS2 = d.structure.tree[opSeqId]) == null ? void 0 : _d$structure$tree$opS2.children;
|
|
17947
|
+
});
|
|
17919
17948
|
const refId = opSeqChildren.find(chId => {
|
|
17920
17949
|
var _ref_$members;
|
|
17921
17950
|
|
|
17922
17951
|
const ref_ = getDrawing(drawingId).structure.tree[chId];
|
|
17923
17952
|
return featureId === (ref_ == null ? void 0 : (_ref_$members = ref_.members) == null ? void 0 : _ref_$members.refObj.value);
|
|
17924
|
-
});
|
|
17925
|
-
const refChildren =
|
|
17926
|
-
var _d$structure$
|
|
17953
|
+
}) || NOCCID;
|
|
17954
|
+
const refChildren = useDrawingArr(drawingId, d => {
|
|
17955
|
+
var _d$structure$tree$ref;
|
|
17927
17956
|
|
|
17928
|
-
return (_d$structure$
|
|
17929
|
-
})
|
|
17957
|
+
return (_d$structure$tree$ref = d.structure.tree[refId]) == null ? void 0 : _d$structure$tree$ref.children;
|
|
17958
|
+
});
|
|
17930
17959
|
const errorId = refChildren.find(chId => {
|
|
17931
17960
|
var _getDrawing$structure;
|
|
17932
17961
|
|
|
@@ -18091,21 +18120,21 @@ const Item$1 = ({
|
|
|
18091
18120
|
featureRefId
|
|
18092
18121
|
}) => {
|
|
18093
18122
|
const curPartId = useDrawing(drawingId, d => d.structure.currentProduct || d.structure.root);
|
|
18094
|
-
const opSeqId = useOperationSequence(drawingId, curPartId);
|
|
18123
|
+
const opSeqId = useOperationSequence(drawingId, curPartId) || NOCCID;
|
|
18095
18124
|
const idx = useDrawing(drawingId, d => {
|
|
18096
|
-
var _d$structure$tree, _d$structure$tree$
|
|
18125
|
+
var _d$structure$tree$opS, _d$structure$tree$opS2;
|
|
18097
18126
|
|
|
18098
|
-
return (_d$structure$tree = d.structure.tree[opSeqId
|
|
18127
|
+
return (_d$structure$tree$opS = d.structure.tree[opSeqId]) == null ? void 0 : (_d$structure$tree$opS2 = _d$structure$tree$opS.children) == null ? void 0 : _d$structure$tree$opS2.indexOf(featureRefId);
|
|
18099
18128
|
}) || -1;
|
|
18100
18129
|
const featureId = useDrawing(drawingId, d => {
|
|
18101
18130
|
var _d$structure$tree$fea, _d$structure$tree$fea2;
|
|
18102
18131
|
|
|
18103
18132
|
return (_d$structure$tree$fea = d.structure.tree[featureRefId]) == null ? void 0 : (_d$structure$tree$fea2 = _d$structure$tree$fea.members) == null ? void 0 : _d$structure$tree$fea2.refObj.value;
|
|
18104
18133
|
});
|
|
18105
|
-
const objClass =
|
|
18134
|
+
const objClass = useDrawingStr(drawingId, d => {
|
|
18106
18135
|
var _d$structure$tree$fea3;
|
|
18107
18136
|
|
|
18108
|
-
return (
|
|
18137
|
+
return (_d$structure$tree$fea3 = d.structure.tree[featureId]) == null ? void 0 : _d$structure$tree$fea3.class;
|
|
18109
18138
|
});
|
|
18110
18139
|
const isFeatureActive = useDrawing(drawingId, d => d.plugin.active.feature !== null) || false;
|
|
18111
18140
|
const isRollbackBar = objClass === CCClasses.CCRollbackBar;
|
|
@@ -18123,12 +18152,12 @@ const List$2 = ({
|
|
|
18123
18152
|
drawingId
|
|
18124
18153
|
}) => {
|
|
18125
18154
|
const curPartId = useDrawing(drawingId, d => d.structure.currentProduct || d.structure.root);
|
|
18126
|
-
const opSeqId = useOperationSequence(drawingId, curPartId);
|
|
18127
|
-
const featureRefIds =
|
|
18128
|
-
var _d$structure$
|
|
18155
|
+
const opSeqId = useOperationSequence(drawingId, curPartId) || NOCCID;
|
|
18156
|
+
const featureRefIds = useDrawingArr(drawingId, d => {
|
|
18157
|
+
var _d$structure$tree$opS3;
|
|
18129
18158
|
|
|
18130
|
-
return (_d$structure$
|
|
18131
|
-
})
|
|
18159
|
+
return (_d$structure$tree$opS3 = d.structure.tree[opSeqId]) == null ? void 0 : _d$structure$tree$opS3.children;
|
|
18160
|
+
});
|
|
18132
18161
|
return /*#__PURE__*/React__default.createElement(SortableCont, {
|
|
18133
18162
|
helperClass: "row-dragging",
|
|
18134
18163
|
lockAxis: "y",
|
|
@@ -18263,7 +18292,7 @@ const ProdReferenceNode = ({
|
|
|
18263
18292
|
level,
|
|
18264
18293
|
onClick
|
|
18265
18294
|
}) => {
|
|
18266
|
-
const children =
|
|
18295
|
+
const children = useDrawingArr(drawingId, d => d.structure.tree[refId].children);
|
|
18267
18296
|
const [collapsed, setCollapsed] = React__default.useState(true);
|
|
18268
18297
|
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(FlexRow, null, /*#__PURE__*/React__default.createElement(Indents, {
|
|
18269
18298
|
level: level
|
|
@@ -18347,7 +18376,7 @@ const AssemblyTreeHeader = ({
|
|
|
18347
18376
|
const mode = useEditMode(drawingId);
|
|
18348
18377
|
const currProd = useCurrentProduct(drawingId);
|
|
18349
18378
|
const currNode = useCurrentNode(drawingId);
|
|
18350
|
-
const objDetails = useObjectDetails(drawingId, (currNode == null ? void 0 : currNode.id) ||
|
|
18379
|
+
const objDetails = useObjectDetails(drawingId, (currNode == null ? void 0 : currNode.id) || NOCCID);
|
|
18351
18380
|
const showBackBtn = React__default.useMemo(() => pStackNotEmpty || !objDetails.isRoot && (objDetails.isAssemblyNode || objDetails.isAssembly), [objDetails.isAssembly, objDetails.isAssemblyNode, objDetails.isRoot, pStackNotEmpty]);
|
|
18352
18381
|
const isFeatureActive = useDrawing(drawingId, d => d.plugin.active.feature !== null) || false;
|
|
18353
18382
|
const name = currProd ? currProd.name : currNode ? currNode.name : '';
|
|
@@ -18395,7 +18424,7 @@ const AssemblyTreeHeader = ({
|
|
|
18395
18424
|
}));
|
|
18396
18425
|
const nameComponent = rename ? /*#__PURE__*/React__default.createElement(NameEdit, {
|
|
18397
18426
|
drawingId: drawingId,
|
|
18398
|
-
objId: (currProd == null ? void 0 : currProd.id) ||
|
|
18427
|
+
objId: (currProd == null ? void 0 : currProd.id) || NOCCID,
|
|
18399
18428
|
setEditName: setRename,
|
|
18400
18429
|
name: name
|
|
18401
18430
|
}) : /*#__PURE__*/React__default.createElement(EntityName, {
|
|
@@ -18480,10 +18509,10 @@ const AssemblyTreeImpl = ({
|
|
|
18480
18509
|
const api = useCADStore(s => s.api);
|
|
18481
18510
|
const mode = useEditMode(drawingId);
|
|
18482
18511
|
const currNode = useCurrentNode(drawingId);
|
|
18483
|
-
const children =
|
|
18512
|
+
const children = useDrawingArr(drawingId, d => {
|
|
18484
18513
|
var _d$structure$tree;
|
|
18485
18514
|
|
|
18486
|
-
return (
|
|
18515
|
+
return (_d$structure$tree = d.structure.tree[(currNode == null ? void 0 : currNode.id) || NOCCID]) == null ? void 0 : _d$structure$tree.children;
|
|
18487
18516
|
});
|
|
18488
18517
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
18489
18518
|
style: {
|
|
@@ -18500,13 +18529,13 @@ const AssemblyTreeImpl = ({
|
|
|
18500
18529
|
}
|
|
18501
18530
|
}, mode === EditMode.Part && /*#__PURE__*/React__default.createElement(FeatureList, {
|
|
18502
18531
|
drawingId: drawingId
|
|
18503
|
-
}), mode === EditMode.Assembly &&
|
|
18532
|
+
}), mode === EditMode.Assembly && children.map(childId => /*#__PURE__*/React__default.createElement(AssemblyNode, {
|
|
18504
18533
|
drawingId: drawingId,
|
|
18505
18534
|
nodeId: childId,
|
|
18506
18535
|
key: childId,
|
|
18507
18536
|
level: 0,
|
|
18508
18537
|
onClick: refId => api.assemblyTree.startProdEditing(drawingId, refId)
|
|
18509
|
-
}))))
|
|
18538
|
+
}))));
|
|
18510
18539
|
};
|
|
18511
18540
|
|
|
18512
18541
|
const AssemblyTree = ({
|
|
@@ -18542,12 +18571,11 @@ const Constraints = ({
|
|
|
18542
18571
|
drawingId
|
|
18543
18572
|
}) => {
|
|
18544
18573
|
const curProdId = useDrawing(drawingId, d => d.structure.currentProduct);
|
|
18545
|
-
const prodChildren =
|
|
18574
|
+
const prodChildren = useDrawingArr(drawingId, d => {
|
|
18546
18575
|
var _d$structure$tree$cur;
|
|
18547
18576
|
|
|
18548
|
-
return (
|
|
18549
|
-
});
|
|
18550
|
-
|
|
18577
|
+
return (_d$structure$tree$cur = d.structure.tree[curProdId]) == null ? void 0 : _d$structure$tree$cur.children;
|
|
18578
|
+
});
|
|
18551
18579
|
const constrSetId = React__default.useMemo(() => {
|
|
18552
18580
|
const tree = getDrawing(drawingId).structure.tree;
|
|
18553
18581
|
return prodChildren.find(childId => tree[childId].class === CCClasses.CCConstraintSet) || null;
|
|
@@ -18675,11 +18703,11 @@ const ColorPicker = ({
|
|
|
18675
18703
|
|
|
18676
18704
|
return (_d$geometry$cache$sol3 = d.geometry.cache[solidId]) == null ? void 0 : (_d$geometry$cache$sol4 = _d$geometry$cache$sol3.meshes[0]) == null ? void 0 : _d$geometry$cache$sol4.opacity;
|
|
18677
18705
|
}) || 1;
|
|
18678
|
-
const solidOwner =
|
|
18706
|
+
const solidOwner = useDrawingCCId(drawingId, d => {
|
|
18679
18707
|
var _d$graphic$containers;
|
|
18680
18708
|
|
|
18681
18709
|
return (_d$graphic$containers = d.graphic.containers[solidId]) == null ? void 0 : _d$graphic$containers.owner;
|
|
18682
|
-
})
|
|
18710
|
+
}); // Color which is set by colorPicker
|
|
18683
18711
|
|
|
18684
18712
|
const [userColor, setUColor] = React__default.useState({
|
|
18685
18713
|
r,
|
|
@@ -18829,11 +18857,11 @@ const Solid = ({
|
|
|
18829
18857
|
drawingId,
|
|
18830
18858
|
solidId
|
|
18831
18859
|
}) => {
|
|
18832
|
-
const solidOwner =
|
|
18860
|
+
const solidOwner = useDrawingCCId(drawingId, d => {
|
|
18833
18861
|
var _d$graphic$containers;
|
|
18834
18862
|
|
|
18835
18863
|
return (_d$graphic$containers = d.graphic.containers[solidId]) == null ? void 0 : _d$graphic$containers.owner;
|
|
18836
|
-
})
|
|
18864
|
+
});
|
|
18837
18865
|
const ccSolid = useDrawing(drawingId, d => d.structure.tree[solidOwner]);
|
|
18838
18866
|
const [rename, setRename] = React__default.useState(false);
|
|
18839
18867
|
const [isMenuHovered, setIsMenuHovered] = React__default.useState(false);
|
|
@@ -18874,7 +18902,7 @@ const Solids = ({
|
|
|
18874
18902
|
drawingId
|
|
18875
18903
|
}) => {
|
|
18876
18904
|
const curProdId = useDrawing(drawingId, d => d.structure.currentProduct);
|
|
18877
|
-
const solidsIds =
|
|
18905
|
+
const solidsIds = useDrawingArr(drawingId, d => d.structure.tree[curProdId].solids);
|
|
18878
18906
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
18879
18907
|
style: {
|
|
18880
18908
|
display: 'flex',
|