@buerli.io/react-cad 0.2.1 → 0.3.0-beta.0
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/components/UI/CAD/Drawing.d.ts +1 -22
- package/build/components/UI/CAD/ViewOptionsBar/useOptionCommands.d.ts +1 -0
- package/build/components/UI/CAD/index.d.ts +0 -1
- package/build/components/UI/editors/RefsEditors/RefEditor.d.ts +1 -0
- package/build/components/graphics/CSysDisplay.d.ts +1 -0
- package/build/components/graphics/HoveredConstraintDisplay.d.ts +1 -2
- package/build/components/graphics/Outlines/IDPass.d.ts +11 -0
- package/build/components/graphics/Outlines/Outline.d.ts +25 -0
- package/build/components/graphics/Outlines/OutlineEffect.d.ts +32 -0
- package/build/components/graphics/Outlines/OutlineMaterial.d.ts +7 -0
- package/build/components/graphics/SelectedMateObj.d.ts +12 -0
- package/build/components/graphics/WorkAxisObj.d.ts +10 -0
- package/build/components/graphics/WorkCoordSystemObj.d.ts +10 -0
- package/build/components/graphics/WorkPlaneObj.d.ts +10 -0
- package/build/components/graphics/WorkPointObj.d.ts +10 -0
- package/build/components/graphics/graphics.d.ts +7 -7
- package/build/components/graphics/utils/MatePathTransform.d.ts +9 -0
- package/build/components/graphics/utils/useCsysMatrix.d.ts +4 -0
- package/build/components/utils/CompValidation/ErrorBoundary.d.ts +1 -1
- package/build/index.cjs.js +1349 -677
- package/build/index.d.ts +9 -1
- package/build/index.js +1302 -637
- package/build/plugins/BoundingBoxInfo/Root.d.ts +1 -0
- package/build/plugins/BoundingBoxInfo/View.d.ts +1 -0
- package/build/plugins/Dimensions/index.d.ts +6 -6
- package/build/plugins/Sketch/View/graphics/hooks.d.ts +4 -0
- package/build/plugins/Sketch/View/handlers/HandlersConstructors.d.ts +0 -1
- package/build/utils/getMateRefIds.d.ts +2 -0
- package/build/utils/helpers.d.ts +3 -3
- package/build/utils/selection/filters.d.ts +0 -10
- package/package.json +15 -14
package/build/index.cjs.js
CHANGED
|
@@ -28,6 +28,7 @@ var shallow = require('zustand/shallow');
|
|
|
28
28
|
var threeStdlib = require('three-stdlib');
|
|
29
29
|
var SelectImpl = require('antd/lib/select');
|
|
30
30
|
var pathBrowserify = require('path-browserify');
|
|
31
|
+
var postprocessing = require('postprocessing');
|
|
31
32
|
var reactUid = require('react-uid');
|
|
32
33
|
var SkeletonImpl = require('antd/lib/skeleton/Skeleton');
|
|
33
34
|
var reactSortableHoc = require('react-sortable-hoc');
|
|
@@ -244,7 +245,7 @@ function getGlobalToLocalMatrix(drawingId, objId) {
|
|
|
244
245
|
return matrix.invert();
|
|
245
246
|
} // TODO: !!Remove
|
|
246
247
|
function convertToVector(point) {
|
|
247
|
-
return new THREE__namespace.Vector3(point.value.x, point.value.y, point.value.z);
|
|
248
|
+
return point ? new THREE__namespace.Vector3(point.value.x, point.value.y, point.value.z) : new THREE__namespace.Vector3();
|
|
248
249
|
}
|
|
249
250
|
function convertToArray(point) {
|
|
250
251
|
return [point.value.x, point.value.y, point.value.z];
|
|
@@ -407,7 +408,12 @@ function findObject(drawingId, id, unrollRefs = false) {
|
|
|
407
408
|
const allContainers = Object.getOwnPropertyNames(cache).map(n => Number(n)).sort((a, b) => b - a);
|
|
408
409
|
const visibleContainers = drawing.structure.visibleContainers;
|
|
409
410
|
const notVisibleContainers = visibleContainers && allContainers.filter(c => visibleContainers.indexOf(c) < 0);
|
|
410
|
-
const sortedContainerIds = visibleContainers && notVisibleContainers && visibleContainers.concat(notVisibleContainers);
|
|
411
|
+
const sortedContainerIds = visibleContainers && notVisibleContainers && visibleContainers.concat(notVisibleContainers);
|
|
412
|
+
|
|
413
|
+
if (cache[graphicId]) {
|
|
414
|
+
return cache[graphicId];
|
|
415
|
+
} // TODO: also search for containers (i.e. solid graphics)
|
|
416
|
+
|
|
411
417
|
|
|
412
418
|
for (const contId of sortedContainerIds) {
|
|
413
419
|
const cont = cache[contId];
|
|
@@ -628,15 +634,11 @@ const NumOrExpr = ({
|
|
|
628
634
|
expr: typeof valOrExpr === 'string' ? valOrExpr : '',
|
|
629
635
|
onChange: onChange,
|
|
630
636
|
onUpdate: onUpdate,
|
|
631
|
-
isExprState: [isExpr, setIsExpr],
|
|
632
637
|
defaultOpenState: [defaultOpen, setDefaultOpen]
|
|
633
638
|
}), !isExpr && /*#__PURE__*/React.createElement(NumInput$1, {
|
|
634
|
-
value:
|
|
635
|
-
defaultV: getDefNumValue(drawingId, defaults),
|
|
639
|
+
value: getDefNumValue(drawingId, defaults),
|
|
636
640
|
onChange: onChange,
|
|
637
641
|
onUpdate: onUpdate,
|
|
638
|
-
isExprState: [isExpr, setIsExpr],
|
|
639
|
-
defaultOpenState: [defaultOpen, setDefaultOpen],
|
|
640
642
|
allowExpr: allowExpr
|
|
641
643
|
})), allowExpr && /*#__PURE__*/React.createElement("div", {
|
|
642
644
|
style: {
|
|
@@ -655,8 +657,7 @@ const NumOrExpr = ({
|
|
|
655
657
|
const NumInput$1 = ({
|
|
656
658
|
onChange,
|
|
657
659
|
onUpdate,
|
|
658
|
-
value
|
|
659
|
-
defaultV
|
|
660
|
+
value
|
|
660
661
|
}) => {
|
|
661
662
|
const {
|
|
662
663
|
Input
|
|
@@ -667,8 +668,10 @@ const NumInput$1 = ({
|
|
|
667
668
|
|
|
668
669
|
if (!isNaN(float)) {
|
|
669
670
|
onChange(float); // Call onChange of parent component
|
|
671
|
+
} else {
|
|
672
|
+
onChange(value);
|
|
670
673
|
}
|
|
671
|
-
}, [sValue, onChange]);
|
|
674
|
+
}, [sValue, onChange, value]);
|
|
672
675
|
React.useEffect(() => {
|
|
673
676
|
setSValue(String(value));
|
|
674
677
|
}, [value]);
|
|
@@ -676,19 +679,19 @@ const NumInput$1 = ({
|
|
|
676
679
|
target
|
|
677
680
|
}) => {
|
|
678
681
|
const val = target.value;
|
|
679
|
-
const reg = /^-?(\d
|
|
682
|
+
const reg = /^-?(\d*(\.\d*)?)?$/; // Regexpr for float number
|
|
680
683
|
|
|
681
|
-
if (reg.test(val) || val === '
|
|
682
|
-
setSValue(val
|
|
684
|
+
if (reg.test(val) || val === '') {
|
|
685
|
+
setSValue(val); // Remove extra zeros from the begin
|
|
683
686
|
}
|
|
684
687
|
}, []);
|
|
685
688
|
const onBlur = React.useCallback(() => {
|
|
686
689
|
const float = parseFloat(sValue);
|
|
687
690
|
|
|
688
691
|
if (isNaN(float)) {
|
|
689
|
-
setSValue(String(
|
|
692
|
+
setSValue(String(value));
|
|
690
693
|
}
|
|
691
|
-
}, [
|
|
694
|
+
}, [value, sValue]);
|
|
692
695
|
return /*#__PURE__*/React.createElement(Input, {
|
|
693
696
|
style: {
|
|
694
697
|
paddingRight: '18px'
|
|
@@ -2297,130 +2300,101 @@ var index$y = /*#__PURE__*/Object.freeze({
|
|
|
2297
2300
|
useDimensionSetId: useDimensionSetId
|
|
2298
2301
|
});
|
|
2299
2302
|
|
|
2300
|
-
function
|
|
2301
|
-
|
|
2302
|
-
function _objectSpread$j(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$j(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$j(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2303
|
-
/**
|
|
2304
|
-
* Implies the following data structure:
|
|
2305
|
-
* data: {
|
|
2306
|
-
* matePath: ObjectID[],
|
|
2307
|
-
* csys: IStructureObject,
|
|
2308
|
-
* flip: FlipType,
|
|
2309
|
-
* reoriented: ReorientedType,
|
|
2310
|
-
* }
|
|
2311
|
-
*/
|
|
2312
|
-
|
|
2313
|
-
const MateScope = 'HLConstraintScope';
|
|
2314
|
-
const createMateItem = (matePath, csys, flip, reoriented) => {
|
|
2315
|
-
return {
|
|
2316
|
-
id: `Mate|${matePath.toString()}|${csys.id}|(${flip},${reoriented})`,
|
|
2317
|
-
scope: MateScope,
|
|
2318
|
-
data: {
|
|
2319
|
-
matePath,
|
|
2320
|
-
csys,
|
|
2321
|
-
flip,
|
|
2322
|
-
reoriented
|
|
2323
|
-
},
|
|
2324
|
-
label: 'MATE'
|
|
2325
|
-
};
|
|
2326
|
-
};
|
|
2327
|
-
|
|
2328
|
-
function useIsHovered$1(drawingId, matePath, object) {
|
|
2329
|
-
const hoveredItem = react.useDrawing(drawingId, d => {
|
|
2330
|
-
const activeId = d.selection.active;
|
|
2331
|
-
|
|
2332
|
-
if (!activeId) {
|
|
2333
|
-
return undefined;
|
|
2334
|
-
}
|
|
2303
|
+
function useIdParam(drawingId, objId, memberName) {
|
|
2304
|
+
var _getDrawing$structure;
|
|
2335
2305
|
|
|
2336
|
-
|
|
2306
|
+
const member = (_getDrawing$structure = core.getDrawing(drawingId).structure.tree[objId].members) == null ? void 0 : _getDrawing$structure[memberName];
|
|
2307
|
+
const [userValue, setUserValue] = React.useState(member.value);
|
|
2308
|
+
React.useEffect(() => {
|
|
2309
|
+
setUserValue(member.value);
|
|
2310
|
+
}, [member]);
|
|
2311
|
+
const defaults = React.useMemo(() => {
|
|
2312
|
+
return member.value;
|
|
2313
|
+
}, [member]);
|
|
2314
|
+
const isChanged = React.useCallback(() => {
|
|
2315
|
+
return userValue !== defaults;
|
|
2316
|
+
}, [defaults, userValue]);
|
|
2317
|
+
return useParam({
|
|
2318
|
+
userValue,
|
|
2319
|
+
setUserValue,
|
|
2320
|
+
defaults,
|
|
2321
|
+
isChanged
|
|
2337
2322
|
});
|
|
2338
|
-
if (!hoveredItem) return false;
|
|
2339
|
-
return createMateItem(matePath, object, classcad.FlipType.FLIP_Z, classcad.ReorientedType.REORIENTED_0).id === hoveredItem.id;
|
|
2340
2323
|
}
|
|
2341
2324
|
|
|
2342
|
-
function
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
const
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
}
|
|
2353
|
-
return {
|
|
2354
|
-
onPointerOut,
|
|
2355
|
-
onPointerOver
|
|
2356
|
-
};
|
|
2325
|
+
function refIdChanged(refId, defId, tree) {
|
|
2326
|
+
if (refId && tree[refId] === undefined) {
|
|
2327
|
+
// The graphicId is stored in userValue
|
|
2328
|
+
const {
|
|
2329
|
+
graphicId
|
|
2330
|
+
} = getGraphicId(tree, defId);
|
|
2331
|
+
return refId !== graphicId;
|
|
2332
|
+
} else {
|
|
2333
|
+
// The id of tree obj is stored in userValue
|
|
2334
|
+
return refId !== defId;
|
|
2335
|
+
}
|
|
2357
2336
|
}
|
|
2358
2337
|
|
|
2359
|
-
function
|
|
2360
|
-
const
|
|
2361
|
-
|
|
2362
|
-
const item = createMateItem(matePath, csys, classcad.FlipType.FLIP_Z, classcad.ReorientedType.REORIENTED_0);
|
|
2363
|
-
selApi.isItemSelected(item) ? selApi.unselect(item) : selApi.select(item);
|
|
2364
|
-
e.stopPropagation();
|
|
2365
|
-
}, [selApi, matePath, csys]);
|
|
2366
|
-
return {
|
|
2367
|
-
onClick
|
|
2368
|
-
};
|
|
2369
|
-
} // Returns true if object in tree is currently selected in active selection.
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
function useIsSelected$1(drawingId, matePath, csys) {
|
|
2373
|
-
// Re-render if selectedItems is changed
|
|
2374
|
-
const selectedItems = react.useDrawing(drawingId, d => {
|
|
2375
|
-
const activeId = d.selection.active;
|
|
2376
|
-
|
|
2377
|
-
if (!activeId) {
|
|
2378
|
-
return undefined;
|
|
2379
|
-
}
|
|
2338
|
+
function useRefsParam(drawingId, objId, memberName) {
|
|
2339
|
+
const member = react.useDrawing(drawingId, d => {
|
|
2340
|
+
var _d$structure$tree$obj;
|
|
2380
2341
|
|
|
2381
|
-
return d.
|
|
2342
|
+
return (_d$structure$tree$obj = d.structure.tree[objId].members) == null ? void 0 : _d$structure$tree$obj[memberName];
|
|
2382
2343
|
});
|
|
2344
|
+
const defaults = React.useMemo(() => {
|
|
2345
|
+
return member.members.map(m => m.value);
|
|
2346
|
+
}, [member]);
|
|
2347
|
+
const [userValue, setUserValue] = React.useState(defaults);
|
|
2348
|
+
const validateFns = React.useRef([]);
|
|
2349
|
+
React.useEffect(() => {
|
|
2350
|
+
setUserValue(defaults);
|
|
2351
|
+
}, [defaults]);
|
|
2352
|
+
const isChanged = React.useCallback(idx => {
|
|
2353
|
+
const tree = core.getDrawing(drawingId).structure.tree;
|
|
2383
2354
|
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
const isSelected = useIsSelected$1(drawingId, matePath, csys);
|
|
2396
|
-
const isHovered = useIsHovered$1(drawingId, matePath, csys);
|
|
2397
|
-
const activeSelId = react.useDrawing(drawingId, drawing => drawing.selection.active);
|
|
2398
|
-
const selection = activeSelId ? core.getDrawing(drawingId).selection.refs[activeSelId] : undefined;
|
|
2399
|
-
const isSelectable = Boolean(selection == null ? void 0 : selection.isSelectable(MateScope, {
|
|
2400
|
-
matePath,
|
|
2401
|
-
csys
|
|
2402
|
-
}));
|
|
2403
|
-
const handlers = React.useMemo(() => {
|
|
2404
|
-
if (isSelectable) {
|
|
2405
|
-
return _objectSpread$j(_objectSpread$j({}, hHandlers), sHandlers);
|
|
2355
|
+
if (idx !== undefined) {
|
|
2356
|
+
// If idx is passed check only single refId.
|
|
2357
|
+
return refIdChanged(userValue[idx], defaults[idx], tree);
|
|
2358
|
+
} else if (userValue.length !== defaults.length) {
|
|
2359
|
+
return true;
|
|
2360
|
+
} else {
|
|
2361
|
+
let changed = false;
|
|
2362
|
+
userValue.forEach((el, idx_) => {
|
|
2363
|
+
changed = changed || refIdChanged(el, defaults[idx_], tree);
|
|
2364
|
+
});
|
|
2365
|
+
return changed;
|
|
2406
2366
|
}
|
|
2367
|
+
}, [userValue, defaults, drawingId]);
|
|
2368
|
+
const setValidator = React.useCallback((validator_, idOfValidF) => {
|
|
2369
|
+
validateFns.current[idOfValidF] = validator_ === null ? emptyValidator : validator_;
|
|
2370
|
+
}, []);
|
|
2371
|
+
const validator = React.useCallback(() => {
|
|
2372
|
+
const warnings = [];
|
|
2373
|
+
validateFns.current.forEach((validateF, i) => {
|
|
2374
|
+
if (!validateF) {
|
|
2375
|
+
return;
|
|
2376
|
+
}
|
|
2407
2377
|
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2378
|
+
const res = validateF(userValue[i]);
|
|
2379
|
+
warnings.push(...res);
|
|
2380
|
+
});
|
|
2381
|
+
return warnings;
|
|
2382
|
+
}, [userValue]);
|
|
2383
|
+
return useParam({
|
|
2384
|
+
userValue,
|
|
2385
|
+
setUserValue,
|
|
2386
|
+
defaults,
|
|
2387
|
+
// defaults for a refsParam always contains id of tree objects, graphic Id can't be here.
|
|
2388
|
+
isChanged
|
|
2389
|
+
}, undefined, {
|
|
2390
|
+
setValidator,
|
|
2391
|
+
validator
|
|
2392
|
+
});
|
|
2419
2393
|
}
|
|
2420
2394
|
|
|
2421
|
-
function ownKeys$
|
|
2395
|
+
function ownKeys$j(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2422
2396
|
|
|
2423
|
-
function _objectSpread$
|
|
2397
|
+
function _objectSpread$j(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$j(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$j(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2424
2398
|
/**
|
|
2425
2399
|
* Implies the following data structure:
|
|
2426
2400
|
* data: {
|
|
@@ -2444,7 +2418,7 @@ const createTreeObjSelItem = (productId, object) => {
|
|
|
2444
2418
|
};
|
|
2445
2419
|
};
|
|
2446
2420
|
|
|
2447
|
-
function useSelect(drawingId, objId) {
|
|
2421
|
+
function useSelect$1(drawingId, objId) {
|
|
2448
2422
|
const onClick = React.useCallback(e => {
|
|
2449
2423
|
e.stopPropagation();
|
|
2450
2424
|
|
|
@@ -2465,7 +2439,7 @@ function useSelect(drawingId, objId) {
|
|
|
2465
2439
|
};
|
|
2466
2440
|
}
|
|
2467
2441
|
|
|
2468
|
-
function useIsHovered(drawingId, objId) {
|
|
2442
|
+
function useIsHovered$1(drawingId, objId) {
|
|
2469
2443
|
const activeSelId = react.useDrawing(drawingId, d => d.selection.active);
|
|
2470
2444
|
const isHovered = react.useDrawing(drawingId, d => {
|
|
2471
2445
|
var _d$selection$refs;
|
|
@@ -2482,7 +2456,7 @@ function useIsHovered(drawingId, objId) {
|
|
|
2482
2456
|
return isHovered;
|
|
2483
2457
|
}
|
|
2484
2458
|
|
|
2485
|
-
function useHover(drawingId, objId) {
|
|
2459
|
+
function useHover$1(drawingId, objId) {
|
|
2486
2460
|
const onPointerOver = React.useCallback(e => {
|
|
2487
2461
|
e.stopPropagation();
|
|
2488
2462
|
const structure = core.getDrawing(drawingId).structure;
|
|
@@ -2517,7 +2491,7 @@ function useHover(drawingId, objId) {
|
|
|
2517
2491
|
*/
|
|
2518
2492
|
|
|
2519
2493
|
|
|
2520
|
-
function useIsSelected(drawingId, objId) {
|
|
2494
|
+
function useIsSelected$1(drawingId, objId) {
|
|
2521
2495
|
// Re-render if selectedItems is changed
|
|
2522
2496
|
const activeSelId = react.useDrawing(drawingId, d => d.selection.active);
|
|
2523
2497
|
const selectedItems = react.useDrawing(drawingId, d => {
|
|
@@ -2551,13 +2525,13 @@ function useTreeObjSelection(drawingId, objId) {
|
|
|
2551
2525
|
});
|
|
2552
2526
|
return res;
|
|
2553
2527
|
}, [drawingId, objId, isSelectableFunc]);
|
|
2554
|
-
const hHandlers = useHover(drawingId, objId);
|
|
2555
|
-
const isHovered = useIsHovered(drawingId, objId);
|
|
2556
|
-
const sHandlers = useSelect(drawingId, objId);
|
|
2557
|
-
const isSelected = useIsSelected(drawingId, objId);
|
|
2528
|
+
const hHandlers = useHover$1(drawingId, objId);
|
|
2529
|
+
const isHovered = useIsHovered$1(drawingId, objId);
|
|
2530
|
+
const sHandlers = useSelect$1(drawingId, objId);
|
|
2531
|
+
const isSelected = useIsSelected$1(drawingId, objId);
|
|
2558
2532
|
const handlers = React.useMemo(() => {
|
|
2559
2533
|
if (isSelectable) {
|
|
2560
|
-
return _objectSpread$
|
|
2534
|
+
return _objectSpread$j(_objectSpread$j({}, hHandlers), sHandlers);
|
|
2561
2535
|
}
|
|
2562
2536
|
|
|
2563
2537
|
return {};
|
|
@@ -2573,134 +2547,51 @@ function useTreeObjSelection(drawingId, objId) {
|
|
|
2573
2547
|
}, [isHovered, isSelected, isSelectable, handlers]);
|
|
2574
2548
|
}
|
|
2575
2549
|
|
|
2576
|
-
const
|
|
2577
|
-
const
|
|
2578
|
-
const
|
|
2579
|
-
const
|
|
2580
|
-
const lineFilter = (scope, data) => scope === core.BuerliScope && (data === core.GraphicType.LINE || data === core.GraphicType.EDGE);
|
|
2581
|
-
const lineSegmentsFilter = (scope, data) => scope === core.BuerliScope && (data === core.GraphicType.LINE || data === core.GraphicType.ARC || data === core.GraphicType.EDGE || data === core.GraphicType.CIRCLE);
|
|
2582
|
-
const arcFilter = (scope, data) => scope === core.BuerliScope && data === core.GraphicType.ARC;
|
|
2583
|
-
const circleFilter = (scope, data) => scope === core.BuerliScope && data === core.GraphicType.CIRCLE;
|
|
2584
|
-
const arcCircleFilter = (scope, data) => scope === core.BuerliScope && (data === core.GraphicType.ARC || data === core.GraphicType.CIRCLE);
|
|
2585
|
-
const pointFilter = (scope, data) => scope === core.BuerliScope && data === core.GraphicType.POINT;
|
|
2586
|
-
const meshFilter = (scope, data) => scope === core.BuerliScope && (data === core.GraphicType.PLANE || data === core.GraphicType.CONE || data === core.GraphicType.CYLINDER);
|
|
2587
|
-
const planeFilter = (scope, data) => scope === core.BuerliScope && data === core.GraphicType.PLANE;
|
|
2588
|
-
const loopFilter = (scope, data) => scope === core.BuerliScope && data === core.GraphicType.LOOP;
|
|
2589
|
-
const solidFilter = (scope, data) => scope === core.BuerliScope && data === core.GraphicType.BREP;
|
|
2590
|
-
const axisFilter = (scope, data) => scope === TreeObjScope && (data.object.class === classcad.CCClasses.CCLine || data.object.class === classcad.CCClasses.CCPoint || data.object.class === classcad.CCClasses.CCWorkAxis || data.object.class === classcad.CCClasses.CCWorkPoint) || scope === core.BuerliScope && (data === core.GraphicType.LINE || data === core.GraphicType.EDGE || data === core.GraphicType.POINT);
|
|
2591
|
-
const workPointFilter = (scope, data) => scope === TreeObjScope && data.object.class === classcad.CCClasses.CCWorkPoint;
|
|
2592
|
-
const workPlaneFilter = (scope, data) => scope === TreeObjScope && data.object.class === classcad.CCClasses.CCWorkPlane;
|
|
2593
|
-
const workAxisFilter = (scope, data) => scope === TreeObjScope && data.object.class === classcad.CCClasses.CCWorkAxis;
|
|
2594
|
-
const csysFilter = (scope, data) => scope === TreeObjScope && data.object.class === classcad.CCClasses.CCWorkCoordSystem;
|
|
2595
|
-
const mateFilter = (scope, data) => scope === MateScope && data.csys.class === classcad.CCClasses.CCWorkCoordSystem;
|
|
2596
|
-
|
|
2597
|
-
function useIdParam(drawingId, objId, memberName) {
|
|
2598
|
-
var _getDrawing$structure;
|
|
2550
|
+
const pickGraphicId = itemData => itemData.graphicId;
|
|
2551
|
+
const pickObjId = itemData => itemData.object.id;
|
|
2552
|
+
const pickOwnerId = itemData => itemData.container.ownerId;
|
|
2553
|
+
const pickGrOrObjId = itemData => itemData.graphicId || itemData.object.id;
|
|
2599
2554
|
|
|
2600
|
-
|
|
2601
|
-
const
|
|
2602
|
-
React.useEffect(() => {
|
|
2603
|
-
setUserValue(member.value);
|
|
2604
|
-
}, [member]);
|
|
2605
|
-
const defaults = React.useMemo(() => {
|
|
2606
|
-
return member.value;
|
|
2607
|
-
}, [member]);
|
|
2608
|
-
const isChanged = React.useCallback(() => {
|
|
2609
|
-
return userValue !== defaults;
|
|
2610
|
-
}, [defaults, userValue]);
|
|
2611
|
-
return useParam({
|
|
2612
|
-
userValue,
|
|
2613
|
-
setUserValue,
|
|
2614
|
-
defaults,
|
|
2615
|
-
isChanged
|
|
2616
|
-
});
|
|
2617
|
-
}
|
|
2555
|
+
const isGeometry = (tree, objId) => {
|
|
2556
|
+
const obj = tree[objId];
|
|
2618
2557
|
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
const {
|
|
2623
|
-
graphicId
|
|
2624
|
-
} = getGraphicId(tree, defId);
|
|
2625
|
-
return refId !== graphicId;
|
|
2558
|
+
if (!obj) {
|
|
2559
|
+
// If there is no corresponding object in tree, the BuerliScope (graphic) item should be restored.
|
|
2560
|
+
return true;
|
|
2626
2561
|
} else {
|
|
2627
|
-
//
|
|
2628
|
-
return
|
|
2562
|
+
// If obj isn't one of next classes, the TreeObjScope item should be resstored.
|
|
2563
|
+
return classcad.ccUtils.base.isA(obj.class, classcad.CCClasses.CCSolid) || classcad.ccUtils.base.isA(obj.class, classcad.CCClasses.CCBrepReference);
|
|
2564
|
+
}
|
|
2565
|
+
};
|
|
2566
|
+
const getInteractionInfo = (drawingId, item) => {
|
|
2567
|
+
if (item === null) {
|
|
2568
|
+
return null;
|
|
2629
2569
|
}
|
|
2630
|
-
}
|
|
2631
|
-
|
|
2632
|
-
function useRefsParam(drawingId, objId, memberName) {
|
|
2633
|
-
const member = react.useDrawing(drawingId, d => {
|
|
2634
|
-
var _d$structure$tree$obj;
|
|
2635
2570
|
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
const isChanged = React.useCallback(idx => {
|
|
2647
|
-
const tree = core.getDrawing(drawingId).structure.tree;
|
|
2648
|
-
|
|
2649
|
-
if (idx !== undefined) {
|
|
2650
|
-
// If idx is passed check only single refId.
|
|
2651
|
-
return refIdChanged(userValue[idx], defaults[idx], tree);
|
|
2652
|
-
} else if (userValue.length !== defaults.length) {
|
|
2653
|
-
return true;
|
|
2654
|
-
} else {
|
|
2655
|
-
let changed = false;
|
|
2656
|
-
userValue.forEach((el, idx_) => {
|
|
2657
|
-
changed = changed || refIdChanged(el, defaults[idx_], tree);
|
|
2658
|
-
});
|
|
2659
|
-
return changed;
|
|
2660
|
-
}
|
|
2661
|
-
}, [userValue, defaults, drawingId]);
|
|
2662
|
-
const setValidator = React.useCallback((validator_, idOfValidF) => {
|
|
2663
|
-
validateFns.current[idOfValidF] = validator_ === null ? emptyValidator : validator_;
|
|
2664
|
-
}, []);
|
|
2665
|
-
const validator = React.useCallback(() => {
|
|
2666
|
-
const warnings = [];
|
|
2667
|
-
validateFns.current.forEach((validateF, i) => {
|
|
2668
|
-
if (!validateF) {
|
|
2669
|
-
return;
|
|
2670
|
-
}
|
|
2671
|
-
|
|
2672
|
-
const res = validateF(userValue[i]);
|
|
2673
|
-
warnings.push(...res);
|
|
2571
|
+
if (item.scope === core.BuerliScope) {
|
|
2572
|
+
const objectId = item.data.container.ownerId;
|
|
2573
|
+
const graphicId = item.data.graphicId;
|
|
2574
|
+
const containerId = item.data.container.id;
|
|
2575
|
+
const prodRefId = item.data.productId;
|
|
2576
|
+
return core.createInfo({
|
|
2577
|
+
objectId,
|
|
2578
|
+
graphicId,
|
|
2579
|
+
containerId,
|
|
2580
|
+
prodRefId
|
|
2674
2581
|
});
|
|
2675
|
-
|
|
2676
|
-
}, [userValue]);
|
|
2677
|
-
return useParam({
|
|
2678
|
-
userValue,
|
|
2679
|
-
setUserValue,
|
|
2680
|
-
defaults,
|
|
2681
|
-
// defaults for a refsParam always contains id of tree objects, graphic Id can't be here.
|
|
2682
|
-
isChanged
|
|
2683
|
-
}, undefined, {
|
|
2684
|
-
setValidator,
|
|
2685
|
-
validator
|
|
2686
|
-
});
|
|
2687
|
-
}
|
|
2688
|
-
|
|
2689
|
-
const pickGraphicId = itemData => itemData.graphicId;
|
|
2690
|
-
const pickObjId = itemData => itemData.object.id;
|
|
2691
|
-
const pickOwnerId = itemData => itemData.container.ownerId;
|
|
2692
|
-
const pickGrOrObjId = itemData => itemData.graphicId || itemData.object.id;
|
|
2582
|
+
}
|
|
2693
2583
|
|
|
2694
|
-
|
|
2695
|
-
|
|
2584
|
+
if (item.scope === TreeObjScope) {
|
|
2585
|
+
const objectId = item.data.object.id; // Assume this is only used in part mode...
|
|
2696
2586
|
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
return classcad.ccUtils.base.isA(obj.class, classcad.CCClasses.CCSolid) || classcad.ccUtils.base.isA(obj.class, classcad.CCClasses.CCBrepReference);
|
|
2587
|
+
const prodRefId = core.getDrawing(drawingId).structure.currentProduct;
|
|
2588
|
+
return core.createInfo({
|
|
2589
|
+
objectId,
|
|
2590
|
+
prodRefId
|
|
2591
|
+
});
|
|
2703
2592
|
}
|
|
2593
|
+
|
|
2594
|
+
return null;
|
|
2704
2595
|
};
|
|
2705
2596
|
const RefEditor = ({
|
|
2706
2597
|
children,
|
|
@@ -2786,6 +2677,10 @@ const RefEditor = ({
|
|
|
2786
2677
|
}
|
|
2787
2678
|
}, // TODO: there is dependency array, but customSelect will be used in Selection once on selector creating.
|
|
2788
2679
|
[drawingId, selectorsOrder, setParamRef]);
|
|
2680
|
+
const onHover = React.useCallback(item => {
|
|
2681
|
+
const setHovered = core.getDrawing(drawingId).api.interaction.setHovered;
|
|
2682
|
+
setHovered(getInteractionInfo(drawingId, item));
|
|
2683
|
+
}, [drawingId]);
|
|
2789
2684
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SelectionRestorer, {
|
|
2790
2685
|
drawingId: drawingId,
|
|
2791
2686
|
refId: refId,
|
|
@@ -2800,7 +2695,8 @@ const RefEditor = ({
|
|
|
2800
2695
|
onCreated: setSelectorId,
|
|
2801
2696
|
maxLen: 1,
|
|
2802
2697
|
customSelect: customSetter,
|
|
2803
|
-
customUnSelect: customSetter
|
|
2698
|
+
customUnSelect: customSetter,
|
|
2699
|
+
onHover: onHover
|
|
2804
2700
|
}), children));
|
|
2805
2701
|
};
|
|
2806
2702
|
const GrItemRestorer = ({
|
|
@@ -3048,6 +2944,10 @@ const RefsEditor = ({
|
|
|
3048
2944
|
return () => setUserValue(defaults);
|
|
3049
2945
|
}, [setUserValue, defaults]);
|
|
3050
2946
|
const modes = useModes(drawingId, sketchLines, setRefsFromItems, selectorsOrder);
|
|
2947
|
+
const onHover = React.useCallback(item => {
|
|
2948
|
+
const setHovered = core.getDrawing(drawingId).api.interaction.setHovered;
|
|
2949
|
+
setHovered(getInteractionInfo(drawingId, item));
|
|
2950
|
+
}, [drawingId]);
|
|
3051
2951
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SelectionRestorer, {
|
|
3052
2952
|
drawingId: drawingId,
|
|
3053
2953
|
refIds: userValue,
|
|
@@ -3061,7 +2961,8 @@ const RefsEditor = ({
|
|
|
3061
2961
|
filter: filter,
|
|
3062
2962
|
onCreated: setSelectorId,
|
|
3063
2963
|
maxLen: maxRefLen,
|
|
3064
|
-
modes: modes
|
|
2964
|
+
modes: modes,
|
|
2965
|
+
onHover: onHover
|
|
3065
2966
|
}), children));
|
|
3066
2967
|
};
|
|
3067
2968
|
|
|
@@ -3117,6 +3018,138 @@ const SelectionRestorer = ({
|
|
|
3117
3018
|
return null;
|
|
3118
3019
|
};
|
|
3119
3020
|
|
|
3021
|
+
function ownKeys$i(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
3022
|
+
|
|
3023
|
+
function _objectSpread$i(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$i(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$i(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
3024
|
+
/**
|
|
3025
|
+
* Implies the following data structure:
|
|
3026
|
+
* data: {
|
|
3027
|
+
* matePath: ObjectID[],
|
|
3028
|
+
* csys: IStructureObject,
|
|
3029
|
+
* flip: FlipType,
|
|
3030
|
+
* reoriented: ReorientedType,
|
|
3031
|
+
* }
|
|
3032
|
+
*/
|
|
3033
|
+
|
|
3034
|
+
const MateScope = 'HLConstraintScope';
|
|
3035
|
+
const createMateItem = (matePath, csys, flip, reoriented) => {
|
|
3036
|
+
return {
|
|
3037
|
+
id: `Mate|${matePath.toString()}|${csys.id}|(${flip},${reoriented})`,
|
|
3038
|
+
scope: MateScope,
|
|
3039
|
+
data: {
|
|
3040
|
+
matePath,
|
|
3041
|
+
csys,
|
|
3042
|
+
flip,
|
|
3043
|
+
reoriented
|
|
3044
|
+
},
|
|
3045
|
+
label: 'MATE'
|
|
3046
|
+
};
|
|
3047
|
+
};
|
|
3048
|
+
|
|
3049
|
+
function useIsHovered(drawingId, matePath, object) {
|
|
3050
|
+
const hoveredItem = react.useDrawing(drawingId, d => {
|
|
3051
|
+
const activeId = d.selection.active;
|
|
3052
|
+
|
|
3053
|
+
if (!activeId) {
|
|
3054
|
+
return undefined;
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
return d.selection.refs[activeId].hoveredItem;
|
|
3058
|
+
});
|
|
3059
|
+
if (!hoveredItem) return false;
|
|
3060
|
+
return createMateItem(matePath, object, classcad.FlipType.FLIP_Z, classcad.ReorientedType.REORIENTED_0).id === hoveredItem.id;
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3063
|
+
function useHover(drawingId, matePath, objectId) {
|
|
3064
|
+
const onPointerOver = React.useCallback(e => {
|
|
3065
|
+
const selApi = core.getDrawing(drawingId).api.selection;
|
|
3066
|
+
const object = core.getDrawing(drawingId).structure.tree[objectId];
|
|
3067
|
+
const item = createMateItem(matePath, object, classcad.FlipType.FLIP_Z, classcad.ReorientedType.REORIENTED_0);
|
|
3068
|
+
selApi.setHovered(item);
|
|
3069
|
+
}, [drawingId, objectId, matePath]);
|
|
3070
|
+
const onPointerOut = React.useCallback(e => {
|
|
3071
|
+
const selApi = core.getDrawing(drawingId).api.selection;
|
|
3072
|
+
selApi.setHovered(null);
|
|
3073
|
+
}, [drawingId]);
|
|
3074
|
+
return {
|
|
3075
|
+
onPointerOut,
|
|
3076
|
+
onPointerOver
|
|
3077
|
+
};
|
|
3078
|
+
}
|
|
3079
|
+
|
|
3080
|
+
function useSelect(drawingId, matePath, csys) {
|
|
3081
|
+
const selApi = core.getDrawing(drawingId).api.selection;
|
|
3082
|
+
const onClick = React.useCallback(e => {
|
|
3083
|
+
const item = createMateItem(matePath, csys, classcad.FlipType.FLIP_Z, classcad.ReorientedType.REORIENTED_0);
|
|
3084
|
+
selApi.isItemSelected(item) ? selApi.unselect(item) : selApi.select(item);
|
|
3085
|
+
e.stopPropagation();
|
|
3086
|
+
}, [selApi, matePath, csys]);
|
|
3087
|
+
return {
|
|
3088
|
+
onClick
|
|
3089
|
+
};
|
|
3090
|
+
} // Returns true if object in tree is currently selected in active selection.
|
|
3091
|
+
|
|
3092
|
+
|
|
3093
|
+
function useIsSelected(drawingId, matePath, csys) {
|
|
3094
|
+
// Re-render if selectedItems is changed
|
|
3095
|
+
const selectedItems = react.useDrawing(drawingId, d => {
|
|
3096
|
+
const activeId = d.selection.active;
|
|
3097
|
+
|
|
3098
|
+
if (!activeId) {
|
|
3099
|
+
return undefined;
|
|
3100
|
+
}
|
|
3101
|
+
|
|
3102
|
+
return d.selection.refs[activeId].items;
|
|
3103
|
+
});
|
|
3104
|
+
|
|
3105
|
+
if (!selectedItems) {
|
|
3106
|
+
return false;
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
const selApi = core.getDrawing(drawingId).api.selection;
|
|
3110
|
+
return selApi.isItemSelected(createMateItem(matePath, csys, classcad.FlipType.FLIP_Z, classcad.ReorientedType.REORIENTED_0));
|
|
3111
|
+
}
|
|
3112
|
+
function useMateSelection(drawingId, matePath, csysId) {
|
|
3113
|
+
const csys = react.useDrawing(drawingId, drawing => drawing.structure.tree[csysId]);
|
|
3114
|
+
const hHandlers = useHover(drawingId, matePath, csys.id);
|
|
3115
|
+
const sHandlers = useSelect(drawingId, matePath, csys);
|
|
3116
|
+
const isSelected = useIsSelected(drawingId, matePath, csys);
|
|
3117
|
+
const isHovered = useIsHovered(drawingId, matePath, csys);
|
|
3118
|
+
const activeSelId = react.useDrawing(drawingId, drawing => drawing.selection.active);
|
|
3119
|
+
const selection = activeSelId ? core.getDrawing(drawingId).selection.refs[activeSelId] : undefined;
|
|
3120
|
+
const isSelectable = Boolean(selection == null ? void 0 : selection.isSelectable(MateScope, {
|
|
3121
|
+
matePath,
|
|
3122
|
+
csys
|
|
3123
|
+
}));
|
|
3124
|
+
const handlers = React.useMemo(() => {
|
|
3125
|
+
if (isSelectable) {
|
|
3126
|
+
return _objectSpread$i(_objectSpread$i({}, hHandlers), sHandlers);
|
|
3127
|
+
}
|
|
3128
|
+
|
|
3129
|
+
return {};
|
|
3130
|
+
}, [isSelectable, hHandlers, sHandlers]);
|
|
3131
|
+
return React.useMemo(() => {
|
|
3132
|
+
// If the handlers are switched off immediately after the selection (workplane selection for the sketcher), then hovered would keep being equal to true, making the mesh color wrong.
|
|
3133
|
+
// Thus, we don't want hovered and selected to be true if the object is not selectable.
|
|
3134
|
+
return {
|
|
3135
|
+
isHovered: isHovered && isSelectable,
|
|
3136
|
+
isSelected: isSelected && isSelectable,
|
|
3137
|
+
handlers
|
|
3138
|
+
};
|
|
3139
|
+
}, [isHovered, isSelected, isSelectable, handlers]);
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3142
|
+
const ccPointFilter = (scope, data) => scope === TreeObjScope && data.object.class === classcad.CCClasses.CCPoint;
|
|
3143
|
+
const ccLineFilter = (scope, data) => scope === TreeObjScope && data.object.class === classcad.CCClasses.CCLine;
|
|
3144
|
+
const ccArcFilter = (scope, data) => scope === TreeObjScope && data.object.class === classcad.CCClasses.CCArc;
|
|
3145
|
+
const ccCircleFilter = (scope, data) => scope === TreeObjScope && data.object.class === classcad.CCClasses.CCCircle;
|
|
3146
|
+
const axisFilter = (scope, data) => scope === TreeObjScope && (data.object.class === classcad.CCClasses.CCLine || data.object.class === classcad.CCClasses.CCPoint || data.object.class === classcad.CCClasses.CCWorkAxis || data.object.class === classcad.CCClasses.CCWorkPoint) || scope === core.BuerliScope && (data === core.GraphicType.LINE || data === core.GraphicType.EDGE || data === core.GraphicType.POINT);
|
|
3147
|
+
const workPointFilter = (scope, data) => scope === TreeObjScope && data.object.class === classcad.CCClasses.CCWorkPoint;
|
|
3148
|
+
const workPlaneFilter = (scope, data) => scope === TreeObjScope && data.object.class === classcad.CCClasses.CCWorkPlane;
|
|
3149
|
+
const workAxisFilter = (scope, data) => scope === TreeObjScope && data.object.class === classcad.CCClasses.CCWorkAxis;
|
|
3150
|
+
const csysFilter = (scope, data) => scope === TreeObjScope && data.object.class === classcad.CCClasses.CCWorkCoordSystem;
|
|
3151
|
+
const mateFilter = (scope, data) => scope === MateScope && data.csys.class === classcad.CCClasses.CCWorkCoordSystem;
|
|
3152
|
+
|
|
3120
3153
|
const MateEditor = ({
|
|
3121
3154
|
param,
|
|
3122
3155
|
drawingId,
|
|
@@ -3197,6 +3230,16 @@ const MateEditor = ({
|
|
|
3197
3230
|
}
|
|
3198
3231
|
}, // TODO: there is dependency array, but customSelect will be used in Selection once on selector creating.
|
|
3199
3232
|
[drawingId, selectorsOrder, setMateParam]);
|
|
3233
|
+
const onHover = React.useCallback(item => {
|
|
3234
|
+
const prodRefId = core.getDrawing(drawingId).structure.currentProduct;
|
|
3235
|
+
const setHovered = core.getDrawing(drawingId).api.interaction.setHovered;
|
|
3236
|
+
setHovered(item ? {
|
|
3237
|
+
objectId: item.data.csys.id,
|
|
3238
|
+
prodRefId,
|
|
3239
|
+
userData: item.data,
|
|
3240
|
+
uniqueIdent: [item.data.csys.id, ...item.data.matePath].toString()
|
|
3241
|
+
} : null);
|
|
3242
|
+
}, [drawingId]);
|
|
3200
3243
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MateRestorer, {
|
|
3201
3244
|
drawingId: drawingId,
|
|
3202
3245
|
matePath: matePath,
|
|
@@ -3214,7 +3257,8 @@ const MateEditor = ({
|
|
|
3214
3257
|
onCreated: setSelectorId,
|
|
3215
3258
|
maxLen: 1,
|
|
3216
3259
|
customSelect: customSetter,
|
|
3217
|
-
customUnSelect: customSetter
|
|
3260
|
+
customUnSelect: customSetter,
|
|
3261
|
+
onHover: onHover
|
|
3218
3262
|
}), /*#__PURE__*/React.createElement(MateFlip, {
|
|
3219
3263
|
flipState: flipState,
|
|
3220
3264
|
setFlipState: setFlip,
|
|
@@ -3702,14 +3746,14 @@ function RootImpl$x({
|
|
|
3702
3746
|
drawingId: drawingId,
|
|
3703
3747
|
caption: "Body 1",
|
|
3704
3748
|
param: body1,
|
|
3705
|
-
filter: solidFilter,
|
|
3749
|
+
filter: core.solidFilter,
|
|
3706
3750
|
customIdPicker: pickOwnerId,
|
|
3707
3751
|
selectorsOrder: selOrder
|
|
3708
3752
|
}), /*#__PURE__*/React.createElement(RefsEditor, {
|
|
3709
3753
|
drawingId: drawingId,
|
|
3710
3754
|
caption: "Bodies",
|
|
3711
3755
|
param: body2,
|
|
3712
|
-
filter: solidFilter,
|
|
3756
|
+
filter: core.solidFilter,
|
|
3713
3757
|
customIdPicker: pickOwnerId,
|
|
3714
3758
|
selectorsOrder: selOrder
|
|
3715
3759
|
}));
|
|
@@ -4668,7 +4712,7 @@ const RootImpl$q = ({
|
|
|
4668
4712
|
drawingId: drawingId,
|
|
4669
4713
|
caption: "References",
|
|
4670
4714
|
param: refs,
|
|
4671
|
-
filter: (scope, data) => lineSegmentsFilter(scope, data) || loopFilter(scope, data)
|
|
4715
|
+
filter: (scope, data) => core.lineSegmentsFilter(scope, data) || core.loopFilter(scope, data)
|
|
4672
4716
|
}), /*#__PURE__*/React.createElement(NumberEditor, {
|
|
4673
4717
|
drawingId: drawingId,
|
|
4674
4718
|
caption: "Radius",
|
|
@@ -4767,7 +4811,7 @@ const RootImpl$p = ({
|
|
|
4767
4811
|
drawingId: drawingId,
|
|
4768
4812
|
caption: "References",
|
|
4769
4813
|
param: refs,
|
|
4770
|
-
filter: (scope, data) => lineSegmentsFilter(scope, data) || loopFilter(scope, data)
|
|
4814
|
+
filter: (scope, data) => core.lineSegmentsFilter(scope, data) || core.loopFilter(scope, data)
|
|
4771
4815
|
}), /*#__PURE__*/React.createElement(NumberEditor, {
|
|
4772
4816
|
drawingId: drawingId,
|
|
4773
4817
|
caption: "Offset 1",
|
|
@@ -4854,7 +4898,7 @@ function RootImpl$o({
|
|
|
4854
4898
|
drawingId: drawingId,
|
|
4855
4899
|
caption: 'Solids',
|
|
4856
4900
|
param: solidRefs,
|
|
4857
|
-
filter: solidFilter,
|
|
4901
|
+
filter: core.solidFilter,
|
|
4858
4902
|
customIdPicker: pickOwnerId
|
|
4859
4903
|
}), /*#__PURE__*/React.createElement(RefsEditor, {
|
|
4860
4904
|
drawingId: drawingId,
|
|
@@ -4940,7 +4984,7 @@ function RootImpl$n({
|
|
|
4940
4984
|
drawingId: drawingId,
|
|
4941
4985
|
caption: 'Solids',
|
|
4942
4986
|
param: solidRefs,
|
|
4943
|
-
filter: solidFilter,
|
|
4987
|
+
filter: core.solidFilter,
|
|
4944
4988
|
customIdPicker: pickOwnerId
|
|
4945
4989
|
}), /*#__PURE__*/React.createElement(RefsEditor, {
|
|
4946
4990
|
drawingId: drawingId,
|
|
@@ -5022,7 +5066,7 @@ function RootImpl$m({
|
|
|
5022
5066
|
drawingId: drawingId,
|
|
5023
5067
|
caption: 'Solids',
|
|
5024
5068
|
param: solidRefs,
|
|
5025
|
-
filter: solidFilter,
|
|
5069
|
+
filter: core.solidFilter,
|
|
5026
5070
|
customIdPicker: pickOwnerId
|
|
5027
5071
|
}), /*#__PURE__*/React.createElement(RefEditor, {
|
|
5028
5072
|
drawingId: drawingId,
|
|
@@ -5105,7 +5149,7 @@ function RootImpl$l({
|
|
|
5105
5149
|
drawingId: drawingId,
|
|
5106
5150
|
param: bodiesToCut,
|
|
5107
5151
|
caption: "Solids",
|
|
5108
|
-
filter: solidFilter,
|
|
5152
|
+
filter: core.solidFilter,
|
|
5109
5153
|
customIdPicker: pickOwnerId
|
|
5110
5154
|
}), /*#__PURE__*/React.createElement(RefEditor, {
|
|
5111
5155
|
drawingId: drawingId,
|
|
@@ -5182,14 +5226,14 @@ function RootImpl$k({
|
|
|
5182
5226
|
drawingId: drawingId,
|
|
5183
5227
|
param: bodyToCut,
|
|
5184
5228
|
caption: "Solid",
|
|
5185
|
-
filter: solidFilter,
|
|
5229
|
+
filter: core.solidFilter,
|
|
5186
5230
|
customIdPicker: pickOwnerId,
|
|
5187
5231
|
selectorsOrder: selOrder
|
|
5188
5232
|
}), /*#__PURE__*/React.createElement(RefEditor, {
|
|
5189
5233
|
drawingId: drawingId,
|
|
5190
5234
|
param: sheetBody,
|
|
5191
5235
|
caption: "Sheet",
|
|
5192
|
-
filter: solidFilter,
|
|
5236
|
+
filter: core.solidFilter,
|
|
5193
5237
|
customIdPicker: pickOwnerId,
|
|
5194
5238
|
selectorsOrder: selOrder
|
|
5195
5239
|
}, /*#__PURE__*/React.createElement(BooleanEditor, {
|
|
@@ -5284,7 +5328,7 @@ function RootImpl$j({
|
|
|
5284
5328
|
drawingId: drawingId,
|
|
5285
5329
|
caption: "Solid",
|
|
5286
5330
|
param: solidRefs,
|
|
5287
|
-
filter: solidFilter,
|
|
5331
|
+
filter: core.solidFilter,
|
|
5288
5332
|
customIdPicker: pickOwnerId,
|
|
5289
5333
|
maxLen: 1
|
|
5290
5334
|
}), /*#__PURE__*/React.createElement(RefsEditor, {
|
|
@@ -5405,7 +5449,7 @@ function RootImpl$i({
|
|
|
5405
5449
|
drawingId: drawingId,
|
|
5406
5450
|
caption: "Solid",
|
|
5407
5451
|
param: solidRefs,
|
|
5408
|
-
filter: solidFilter,
|
|
5452
|
+
filter: core.solidFilter,
|
|
5409
5453
|
customIdPicker: pickOwnerId,
|
|
5410
5454
|
maxLen: 1
|
|
5411
5455
|
}), /*#__PURE__*/React.createElement(RefsEditor, {
|
|
@@ -5492,13 +5536,13 @@ const RootImpl$h = ({
|
|
|
5492
5536
|
drawingId: drawingId,
|
|
5493
5537
|
caption: "Solid(s)",
|
|
5494
5538
|
param: solidRefs,
|
|
5495
|
-
filter: solidFilter,
|
|
5539
|
+
filter: core.solidFilter,
|
|
5496
5540
|
customIdPicker: pickOwnerId
|
|
5497
5541
|
}), /*#__PURE__*/React.createElement(RefsEditor, {
|
|
5498
5542
|
drawingId: drawingId,
|
|
5499
5543
|
caption: "Plane(s)",
|
|
5500
5544
|
param: faceRefs,
|
|
5501
|
-
filter: (scope, data) => planeFilter(scope, data) || workPlaneFilter(scope, data),
|
|
5545
|
+
filter: (scope, data) => core.planeFilter(scope, data) || workPlaneFilter(scope, data),
|
|
5502
5546
|
customIdPicker: pickGrOrObjId
|
|
5503
5547
|
}));
|
|
5504
5548
|
};
|
|
@@ -5545,12 +5589,17 @@ const RootImpl$g = ({
|
|
|
5545
5589
|
const filter = React.useCallback((scope, data) => {
|
|
5546
5590
|
return scope === core.BuerliScope && !Excluded.includes(data);
|
|
5547
5591
|
}, []);
|
|
5592
|
+
const onHover = React.useCallback(item => {
|
|
5593
|
+
const setHovered = core.getDrawing(drawingId).api.interaction.setHovered;
|
|
5594
|
+
setHovered(getInteractionInfo(drawingId, item));
|
|
5595
|
+
}, [drawingId]);
|
|
5548
5596
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Wrapper, {
|
|
5549
5597
|
caption: "Items"
|
|
5550
5598
|
}, /*#__PURE__*/React.createElement(Selection, {
|
|
5551
5599
|
drawingId: drawingId,
|
|
5552
5600
|
onCreated: setSelectorId,
|
|
5553
|
-
filter: filter
|
|
5601
|
+
filter: filter,
|
|
5602
|
+
onHover: onHover
|
|
5554
5603
|
})), /*#__PURE__*/React.createElement(Output, {
|
|
5555
5604
|
drawingId: drawingId,
|
|
5556
5605
|
pluginId: pluginId,
|
|
@@ -5625,7 +5674,7 @@ const Point$2 = ({
|
|
|
5625
5674
|
attach: "material",
|
|
5626
5675
|
color: color,
|
|
5627
5676
|
opacity: opacity,
|
|
5628
|
-
transparent:
|
|
5677
|
+
transparent: opacity < 1
|
|
5629
5678
|
}));
|
|
5630
5679
|
};
|
|
5631
5680
|
const Arrow = ({
|
|
@@ -5646,7 +5695,9 @@ const Arrow = ({
|
|
|
5646
5695
|
return /*#__PURE__*/React.createElement("group", _extends({
|
|
5647
5696
|
position: position.clone(),
|
|
5648
5697
|
quaternion: new THREE__namespace.Quaternion().setFromUnitVectors(new THREE__namespace.Vector3(0, 1, 0), direction.clone().normalize())
|
|
5649
|
-
}, handlers
|
|
5698
|
+
}, handlers, {
|
|
5699
|
+
userData: userData
|
|
5700
|
+
}), /*#__PURE__*/React.createElement("mesh", {
|
|
5650
5701
|
position: new THREE__namespace.Vector3(0, cylinderLength / 2.0, 0),
|
|
5651
5702
|
renderOrder: 500,
|
|
5652
5703
|
userData: userData
|
|
@@ -5669,7 +5720,7 @@ const Arrow = ({
|
|
|
5669
5720
|
attach: "material",
|
|
5670
5721
|
color: color,
|
|
5671
5722
|
opacity: opacity,
|
|
5672
|
-
transparent:
|
|
5723
|
+
transparent: opacity < 1
|
|
5673
5724
|
})));
|
|
5674
5725
|
};
|
|
5675
5726
|
const OriginPoint = ({
|
|
@@ -5723,7 +5774,8 @@ const Csys = ({
|
|
|
5723
5774
|
const ref = useScale$1(position.clone(), sf => [2 * sf, 2 * sf, 2 * sf]);
|
|
5724
5775
|
return /*#__PURE__*/React.createElement("group", _extends({
|
|
5725
5776
|
matrix: matrix,
|
|
5726
|
-
matrixAutoUpdate: false
|
|
5777
|
+
matrixAutoUpdate: false,
|
|
5778
|
+
userData: userData
|
|
5727
5779
|
}, handlers), /*#__PURE__*/React.createElement("group", {
|
|
5728
5780
|
ref: ref
|
|
5729
5781
|
}, /*#__PURE__*/React.createElement(OriginPoint, {
|
|
@@ -5753,7 +5805,7 @@ const Csys = ({
|
|
|
5753
5805
|
};
|
|
5754
5806
|
const SelectedCsys = ({
|
|
5755
5807
|
matrix,
|
|
5756
|
-
opacity,
|
|
5808
|
+
opacity = 1.0,
|
|
5757
5809
|
handlers,
|
|
5758
5810
|
color,
|
|
5759
5811
|
userData
|
|
@@ -6795,7 +6847,7 @@ const createArcGeometry = (radialSegments, tubularSegments, instanceLimit) => {
|
|
|
6795
6847
|
return geometry;
|
|
6796
6848
|
};
|
|
6797
6849
|
|
|
6798
|
-
const vertexCode = `
|
|
6850
|
+
const vertexCode$2 = `
|
|
6799
6851
|
attribute float radius;
|
|
6800
6852
|
attribute float tubeRadius;
|
|
6801
6853
|
attribute float angularLength;
|
|
@@ -6815,7 +6867,7 @@ const vertexCode = `
|
|
|
6815
6867
|
vColor = vec4(instanceColor, 1);
|
|
6816
6868
|
}
|
|
6817
6869
|
`;
|
|
6818
|
-
const fragmentCode = `
|
|
6870
|
+
const fragmentCode$3 = `
|
|
6819
6871
|
varying vec4 vColor;
|
|
6820
6872
|
|
|
6821
6873
|
void main() {
|
|
@@ -6826,8 +6878,8 @@ const fragmentCode = `
|
|
|
6826
6878
|
`;
|
|
6827
6879
|
const createArcMaterial = () => {
|
|
6828
6880
|
const material = new THREE__namespace.ShaderMaterial({
|
|
6829
|
-
vertexShader: vertexCode,
|
|
6830
|
-
fragmentShader: fragmentCode,
|
|
6881
|
+
vertexShader: vertexCode$2,
|
|
6882
|
+
fragmentShader: fragmentCode$3,
|
|
6831
6883
|
side: THREE__namespace.DoubleSide
|
|
6832
6884
|
});
|
|
6833
6885
|
return material;
|
|
@@ -10008,7 +10060,7 @@ function UseRef(drawingId, pluginId) {
|
|
|
10008
10060
|
// UseRef shouldn't work with any of sketch objects
|
|
10009
10061
|
const filter = object => false;
|
|
10010
10062
|
|
|
10011
|
-
const filterSel = (scope, data) => lineSegmentsFilter(scope, data) || loopFilter(scope, data) || pointFilter(scope, data);
|
|
10063
|
+
const filterSel = (scope, data) => core.lineSegmentsFilter(scope, data) || core.loopFilter(scope, data) || core.pointFilter(scope, data);
|
|
10012
10064
|
|
|
10013
10065
|
let remove = undefined;
|
|
10014
10066
|
|
|
@@ -10100,7 +10152,7 @@ const useGeomParams = objId => {
|
|
|
10100
10152
|
} = React.useContext(ViewContext);
|
|
10101
10153
|
const lSelected = useSketchState(drawingId, pluginId, state => state.selected.indexOf(objId) !== -1); // gSelected - true if object is selected in a global selection
|
|
10102
10154
|
|
|
10103
|
-
const gSelected = useIsSelected(drawingId, objId);
|
|
10155
|
+
const gSelected = useIsSelected$1(drawingId, objId);
|
|
10104
10156
|
const isSelected = lSelected || gSelected;
|
|
10105
10157
|
const isHighlighted = useSketchState(drawingId, pluginId, state => state.highlighted.indexOf(objId) !== -1);
|
|
10106
10158
|
const isHovered = useSketchState(drawingId, pluginId, state => state.hovered === objId);
|
|
@@ -10268,7 +10320,7 @@ const useColor = (objId, gHovered) => {
|
|
|
10268
10320
|
|
|
10269
10321
|
const lSelected = useSketchState(drawingId, pluginId, state => state.selected.indexOf(objId) !== -1); // Globally selected by some of selection elements.
|
|
10270
10322
|
|
|
10271
|
-
const gSelected = useIsSelected(drawingId, objId);
|
|
10323
|
+
const gSelected = useIsSelected$1(drawingId, objId);
|
|
10272
10324
|
const isSelected = lSelected || gSelected;
|
|
10273
10325
|
const isHighlighted = useSketchState(drawingId, pluginId, state => state.highlighted.indexOf(objId) !== -1);
|
|
10274
10326
|
const isHovered = useSketchState(drawingId, pluginId, state => state.hovered === objId);
|
|
@@ -10291,9 +10343,20 @@ const useColor = (objId, gHovered) => {
|
|
|
10291
10343
|
return color;
|
|
10292
10344
|
};
|
|
10293
10345
|
const useUserData = objId => {
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10346
|
+
const {
|
|
10347
|
+
drawingId,
|
|
10348
|
+
isActive
|
|
10349
|
+
} = React.useContext(ViewContext);
|
|
10350
|
+
return React.useMemo(() => {
|
|
10351
|
+
const tree = core.getDrawing(drawingId).structure.tree;
|
|
10352
|
+
const onHUD = !isActive || is2DConstraint(tree[objId]);
|
|
10353
|
+
return onHUD ? {
|
|
10354
|
+
objId,
|
|
10355
|
+
onHUD
|
|
10356
|
+
} : {
|
|
10357
|
+
objId
|
|
10358
|
+
};
|
|
10359
|
+
}, [drawingId, objId, isActive]);
|
|
10297
10360
|
}; // Fix for interaction until drei support undefined as pointer handlers
|
|
10298
10361
|
|
|
10299
10362
|
const defaultHandlers = {
|
|
@@ -10613,7 +10676,7 @@ const Line = ({
|
|
|
10613
10676
|
|
|
10614
10677
|
if (dist < lineCoef * sketchScale) {
|
|
10615
10678
|
intersects.push({
|
|
10616
|
-
distance:
|
|
10679
|
+
distance: raycaster.ray.origin.distanceTo(pointOnRay),
|
|
10617
10680
|
point: pointOnRay,
|
|
10618
10681
|
face: null,
|
|
10619
10682
|
object: this
|
|
@@ -10642,6 +10705,7 @@ const Line = ({
|
|
|
10642
10705
|
}));
|
|
10643
10706
|
};
|
|
10644
10707
|
|
|
10708
|
+
const closestPos = new THREE__namespace.Vector3();
|
|
10645
10709
|
const pointPos = new THREE__namespace.Vector3();
|
|
10646
10710
|
const pointCoef = 1.3; // Coefficient for increased interaction area
|
|
10647
10711
|
|
|
@@ -10662,8 +10726,9 @@ const Point = ({
|
|
|
10662
10726
|
const sketchScale = getScale(drawingId, pluginId);
|
|
10663
10727
|
|
|
10664
10728
|
if (dist < pointCoef * sketchScale) {
|
|
10729
|
+
raycaster.ray.closestPointToPoint(pointPos, closestPos);
|
|
10665
10730
|
intersects.push({
|
|
10666
|
-
distance:
|
|
10731
|
+
distance: raycaster.ray.origin.distanceTo(closestPos),
|
|
10667
10732
|
point: pointPos.clone(),
|
|
10668
10733
|
face: null,
|
|
10669
10734
|
object: this
|
|
@@ -12025,7 +12090,7 @@ const View$d = ({
|
|
|
12025
12090
|
}));
|
|
12026
12091
|
};
|
|
12027
12092
|
|
|
12028
|
-
const _excluded$
|
|
12093
|
+
const _excluded$4 = ["handlerName", "sideEffect"];
|
|
12029
12094
|
const RadioGroup = styled(RadioGroupImpl)`
|
|
12030
12095
|
display: flex !important;
|
|
12031
12096
|
`;
|
|
@@ -12044,7 +12109,7 @@ const HButton = _ref => {
|
|
|
12044
12109
|
handlerName,
|
|
12045
12110
|
sideEffect = () => undefined
|
|
12046
12111
|
} = _ref,
|
|
12047
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
12112
|
+
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
12048
12113
|
|
|
12049
12114
|
const {
|
|
12050
12115
|
drawingId,
|
|
@@ -12400,7 +12465,7 @@ const PlaneSelection = ({
|
|
|
12400
12465
|
}));
|
|
12401
12466
|
};
|
|
12402
12467
|
|
|
12403
|
-
const _excluded$
|
|
12468
|
+
const _excluded$3 = ["items", "children"];
|
|
12404
12469
|
|
|
12405
12470
|
/**
|
|
12406
12471
|
* Context menu. By default it's rendered as thee dots "...", when user hovers it the menuitems is shown.
|
|
@@ -12418,7 +12483,7 @@ const Menu = _ref => {
|
|
|
12418
12483
|
items,
|
|
12419
12484
|
children
|
|
12420
12485
|
} = _ref,
|
|
12421
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
12486
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
12422
12487
|
|
|
12423
12488
|
const onItemClick = React.useCallback(e => {
|
|
12424
12489
|
e.domEvent.stopPropagation();
|
|
@@ -12646,16 +12711,16 @@ const RefTag = ({
|
|
|
12646
12711
|
const filter = React.useCallback((scope, data) => {
|
|
12647
12712
|
switch (objClass) {
|
|
12648
12713
|
case classcad.CCClasses.CCPoint:
|
|
12649
|
-
return pointFilter(scope, data);
|
|
12714
|
+
return core.pointFilter(scope, data);
|
|
12650
12715
|
|
|
12651
12716
|
case classcad.CCClasses.CCLine:
|
|
12652
|
-
return lineFilter(scope, data);
|
|
12717
|
+
return core.lineFilter(scope, data);
|
|
12653
12718
|
|
|
12654
12719
|
case classcad.CCClasses.CCArc:
|
|
12655
|
-
return arcFilter(scope, data);
|
|
12720
|
+
return core.arcFilter(scope, data);
|
|
12656
12721
|
|
|
12657
12722
|
case classcad.CCClasses.CCCircle:
|
|
12658
|
-
return circleFilter(scope, data);
|
|
12723
|
+
return core.circleFilter(scope, data);
|
|
12659
12724
|
|
|
12660
12725
|
default:
|
|
12661
12726
|
return false;
|
|
@@ -13303,21 +13368,21 @@ const RootImpl$e = ({
|
|
|
13303
13368
|
drawingId: drawingId,
|
|
13304
13369
|
caption: "Curve",
|
|
13305
13370
|
param: refs,
|
|
13306
|
-
filter: (scope, data) => lineSegmentsFilter(scope, data) || ccLineFilter(scope, data) || ccArcFilter(scope, data) || ccCircleFilter(scope, data),
|
|
13371
|
+
filter: (scope, data) => core.lineSegmentsFilter(scope, data) || ccLineFilter(scope, data) || ccArcFilter(scope, data) || ccCircleFilter(scope, data),
|
|
13307
13372
|
customIdPicker: pickGrOrObjId,
|
|
13308
13373
|
idxOfRef: 0
|
|
13309
13374
|
}), type.userValue === classcad.WorkAxisType.WA_2PLANES && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RefsEditor, {
|
|
13310
13375
|
drawingId: drawingId,
|
|
13311
13376
|
param: refs,
|
|
13312
13377
|
caption: "2 Planes",
|
|
13313
|
-
filter: (scope, data) => planeFilter(scope, data) || workPlaneFilter(scope, data),
|
|
13378
|
+
filter: (scope, data) => core.planeFilter(scope, data) || workPlaneFilter(scope, data),
|
|
13314
13379
|
customIdPicker: pickGrOrObjId,
|
|
13315
13380
|
maxLen: 2
|
|
13316
13381
|
})), type.userValue === classcad.WorkAxisType.WA_2POINTS && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RefsEditor, {
|
|
13317
13382
|
drawingId: drawingId,
|
|
13318
13383
|
param: refs,
|
|
13319
13384
|
caption: "2 Points",
|
|
13320
|
-
filter: (scope, data) => pointFilter(scope, data) || ccPointFilter(scope, data) || workPointFilter(scope, data),
|
|
13385
|
+
filter: (scope, data) => core.pointFilter(scope, data) || ccPointFilter(scope, data) || workPointFilter(scope, data),
|
|
13321
13386
|
customIdPicker: pickGrOrObjId,
|
|
13322
13387
|
selectorsOrder: selOrder,
|
|
13323
13388
|
maxLen: 2
|
|
@@ -13325,7 +13390,7 @@ const RootImpl$e = ({
|
|
|
13325
13390
|
drawingId: drawingId,
|
|
13326
13391
|
caption: "Point",
|
|
13327
13392
|
param: refs,
|
|
13328
|
-
filter: (scope, data) => pointFilter(scope, data) || ccPointFilter(scope, data) || workPointFilter(scope, data),
|
|
13393
|
+
filter: (scope, data) => core.pointFilter(scope, data) || ccPointFilter(scope, data) || workPointFilter(scope, data),
|
|
13329
13394
|
customIdPicker: pickGrOrObjId,
|
|
13330
13395
|
idxOfRef: 0,
|
|
13331
13396
|
selectorsOrder: selOrder
|
|
@@ -13333,7 +13398,7 @@ const RootImpl$e = ({
|
|
|
13333
13398
|
drawingId: drawingId,
|
|
13334
13399
|
caption: "Line",
|
|
13335
13400
|
param: refs,
|
|
13336
|
-
filter: (scope, data) => lineSegmentsFilter(scope, data) || ccLineFilter(scope, data) || workAxisFilter(scope, data),
|
|
13401
|
+
filter: (scope, data) => core.lineSegmentsFilter(scope, data) || ccLineFilter(scope, data) || workAxisFilter(scope, data),
|
|
13337
13402
|
customIdPicker: pickGrOrObjId,
|
|
13338
13403
|
idxOfRef: 1,
|
|
13339
13404
|
selectorsOrder: selOrder
|
|
@@ -13353,6 +13418,34 @@ const Root$e = ({
|
|
|
13353
13418
|
}));
|
|
13354
13419
|
};
|
|
13355
13420
|
|
|
13421
|
+
const WorkAxisObj = ({
|
|
13422
|
+
drawingId,
|
|
13423
|
+
objectId,
|
|
13424
|
+
color = 0x111111,
|
|
13425
|
+
opacity = 1,
|
|
13426
|
+
userData,
|
|
13427
|
+
handlers
|
|
13428
|
+
}) => {
|
|
13429
|
+
var _workAxisObj$members, _workAxisObj$members2;
|
|
13430
|
+
|
|
13431
|
+
const workAxisObj = react.useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
|
|
13432
|
+
const position = convertToVector(workAxisObj == null ? void 0 : (_workAxisObj$members = workAxisObj.members) == null ? void 0 : _workAxisObj$members.Position);
|
|
13433
|
+
const direction = convertToVector(workAxisObj == null ? void 0 : (_workAxisObj$members2 = workAxisObj.members) == null ? void 0 : _workAxisObj$members2.Direction);
|
|
13434
|
+
const ref = useScale$1(position.clone(), sf => [3 * sf, 3 * sf, 3 * sf]);
|
|
13435
|
+
return /*#__PURE__*/React.createElement("group", {
|
|
13436
|
+
ref: ref,
|
|
13437
|
+
position: position
|
|
13438
|
+
}, /*#__PURE__*/React.createElement(AxisArrow, {
|
|
13439
|
+
direction: direction,
|
|
13440
|
+
color: color,
|
|
13441
|
+
opacity: opacity,
|
|
13442
|
+
userData: userData,
|
|
13443
|
+
handlers: handlers,
|
|
13444
|
+
width: 0.5,
|
|
13445
|
+
length: 40
|
|
13446
|
+
}));
|
|
13447
|
+
};
|
|
13448
|
+
|
|
13356
13449
|
function getColor(hovered, selected, direction, type) {
|
|
13357
13450
|
if (hovered) {
|
|
13358
13451
|
return 0x28d79f;
|
|
@@ -13373,30 +13466,28 @@ const ViewImpl$c = ({
|
|
|
13373
13466
|
drawingId,
|
|
13374
13467
|
pluginId
|
|
13375
13468
|
}) => {
|
|
13469
|
+
var _workAxisObj$members, _workAxisObj$members2;
|
|
13470
|
+
|
|
13376
13471
|
const {
|
|
13377
13472
|
objectId = -1
|
|
13378
13473
|
} = core.getPlugin(drawingId, pluginId);
|
|
13379
13474
|
const workAxisObj = react.useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
|
|
13380
|
-
const
|
|
13381
|
-
const direction = convertToVector(workAxisObj.members.Direction);
|
|
13475
|
+
const direction = convertToVector(workAxisObj == null ? void 0 : (_workAxisObj$members = workAxisObj.members) == null ? void 0 : _workAxisObj$members.Direction);
|
|
13382
13476
|
const {
|
|
13383
13477
|
isHovered,
|
|
13384
13478
|
isSelected,
|
|
13385
13479
|
handlers
|
|
13386
13480
|
} = useTreeObjSelection(drawingId, objectId);
|
|
13387
|
-
const color = getColor(isHovered, isSelected, direction, workAxisObj.members.Type.value);
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
position: position
|
|
13392
|
-
}, /*#__PURE__*/React.createElement(AxisArrow, {
|
|
13393
|
-
direction: direction,
|
|
13481
|
+
const color = getColor(isHovered, isSelected, direction, workAxisObj == null ? void 0 : (_workAxisObj$members2 = workAxisObj.members) == null ? void 0 : _workAxisObj$members2.Type.value);
|
|
13482
|
+
return /*#__PURE__*/React.createElement(HUD, null, /*#__PURE__*/React.createElement(WorkAxisObj, {
|
|
13483
|
+
drawingId: drawingId,
|
|
13484
|
+
objectId: objectId,
|
|
13394
13485
|
color: color,
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
}))
|
|
13486
|
+
userData: {
|
|
13487
|
+
onHUD: true
|
|
13488
|
+
},
|
|
13489
|
+
handlers: handlers
|
|
13490
|
+
}));
|
|
13400
13491
|
};
|
|
13401
13492
|
|
|
13402
13493
|
const View$c = ({
|
|
@@ -13609,7 +13700,7 @@ const RootImpl$d = ({
|
|
|
13609
13700
|
drawingId: drawingId,
|
|
13610
13701
|
param: refs,
|
|
13611
13702
|
caption: "Plane",
|
|
13612
|
-
filter: (scope, data) => planeFilter(scope, data) || workPlaneFilter(scope, data),
|
|
13703
|
+
filter: (scope, data) => core.planeFilter(scope, data) || workPlaneFilter(scope, data),
|
|
13613
13704
|
idxOfRef: 0,
|
|
13614
13705
|
customIdPicker: pickGrOrObjId,
|
|
13615
13706
|
selectorsOrder: selOrder
|
|
@@ -13617,7 +13708,7 @@ const RootImpl$d = ({
|
|
|
13617
13708
|
drawingId: drawingId,
|
|
13618
13709
|
param: refs,
|
|
13619
13710
|
caption: "Line",
|
|
13620
|
-
filter: (scope, data) => lineSegmentsFilter(scope, data) || ccLineFilter(scope, data) || workAxisFilter(scope, data),
|
|
13711
|
+
filter: (scope, data) => core.lineSegmentsFilter(scope, data) || ccLineFilter(scope, data) || workAxisFilter(scope, data),
|
|
13621
13712
|
customIdPicker: pickGrOrObjId,
|
|
13622
13713
|
idxOfRef: 0,
|
|
13623
13714
|
selectorsOrder: selOrder
|
|
@@ -13625,7 +13716,7 @@ const RootImpl$d = ({
|
|
|
13625
13716
|
drawingId: drawingId,
|
|
13626
13717
|
param: refs,
|
|
13627
13718
|
caption: "Plane",
|
|
13628
|
-
filter: (scope, data) => planeFilter(scope, data) || workPlaneFilter(scope, data),
|
|
13719
|
+
filter: (scope, data) => core.planeFilter(scope, data) || workPlaneFilter(scope, data),
|
|
13629
13720
|
idxOfRef: 1,
|
|
13630
13721
|
customIdPicker: pickGrOrObjId,
|
|
13631
13722
|
selectorsOrder: selOrder
|
|
@@ -13633,7 +13724,7 @@ const RootImpl$d = ({
|
|
|
13633
13724
|
drawingId: drawingId,
|
|
13634
13725
|
caption: "3 Points",
|
|
13635
13726
|
param: refs,
|
|
13636
|
-
filter: (scope, data) => pointFilter(scope, data) || ccPointFilter(scope, data) || workPointFilter(scope, data),
|
|
13727
|
+
filter: (scope, data) => core.pointFilter(scope, data) || ccPointFilter(scope, data) || workPointFilter(scope, data),
|
|
13637
13728
|
customIdPicker: pickGrOrObjId,
|
|
13638
13729
|
maxLen: 3,
|
|
13639
13730
|
selectorsOrder: selOrder
|
|
@@ -13641,7 +13732,7 @@ const RootImpl$d = ({
|
|
|
13641
13732
|
drawingId: drawingId,
|
|
13642
13733
|
param: refs,
|
|
13643
13734
|
caption: "Line",
|
|
13644
|
-
filter: (scope, data) => lineSegmentsFilter(scope, data) || ccLineFilter(scope, data) || workAxisFilter(scope, data),
|
|
13735
|
+
filter: (scope, data) => core.lineSegmentsFilter(scope, data) || ccLineFilter(scope, data) || workAxisFilter(scope, data),
|
|
13645
13736
|
customIdPicker: pickGrOrObjId,
|
|
13646
13737
|
idxOfRef: 0,
|
|
13647
13738
|
selectorsOrder: selOrder
|
|
@@ -13649,7 +13740,7 @@ const RootImpl$d = ({
|
|
|
13649
13740
|
drawingId: drawingId,
|
|
13650
13741
|
param: refs,
|
|
13651
13742
|
caption: "Point",
|
|
13652
|
-
filter: (scope, data) => pointFilter(scope, data) || ccPointFilter(scope, data) || workPointFilter(scope, data),
|
|
13743
|
+
filter: (scope, data) => core.pointFilter(scope, data) || ccPointFilter(scope, data) || workPointFilter(scope, data),
|
|
13653
13744
|
customIdPicker: pickGrOrObjId,
|
|
13654
13745
|
idxOfRef: 1,
|
|
13655
13746
|
selectorsOrder: selOrder
|
|
@@ -13657,7 +13748,7 @@ const RootImpl$d = ({
|
|
|
13657
13748
|
drawingId: drawingId,
|
|
13658
13749
|
param: refs,
|
|
13659
13750
|
caption: "Point",
|
|
13660
|
-
filter: (scope, data) => pointFilter(scope, data) || ccPointFilter(scope, data) || workPointFilter(scope, data),
|
|
13751
|
+
filter: (scope, data) => core.pointFilter(scope, data) || ccPointFilter(scope, data) || workPointFilter(scope, data),
|
|
13661
13752
|
customIdPicker: pickGrOrObjId,
|
|
13662
13753
|
idxOfRef: 0,
|
|
13663
13754
|
selectorsOrder: selOrder
|
|
@@ -13665,7 +13756,7 @@ const RootImpl$d = ({
|
|
|
13665
13756
|
drawingId: drawingId,
|
|
13666
13757
|
param: refs,
|
|
13667
13758
|
caption: "Normal",
|
|
13668
|
-
filter: (scope, data) => lineSegmentsFilter(scope, data) || ccLineFilter(scope, data) || workAxisFilter(scope, data),
|
|
13759
|
+
filter: (scope, data) => core.lineSegmentsFilter(scope, data) || ccLineFilter(scope, data) || workAxisFilter(scope, data),
|
|
13669
13760
|
customIdPicker: pickGrOrObjId,
|
|
13670
13761
|
idxOfRef: 1,
|
|
13671
13762
|
selectorsOrder: selOrder
|
|
@@ -13673,7 +13764,7 @@ const RootImpl$d = ({
|
|
|
13673
13764
|
drawingId: drawingId,
|
|
13674
13765
|
param: refs,
|
|
13675
13766
|
caption: "Point",
|
|
13676
|
-
filter: (scope, data) => pointFilter(scope, data) || ccPointFilter(scope, data) || workPointFilter(scope, data),
|
|
13767
|
+
filter: (scope, data) => core.pointFilter(scope, data) || ccPointFilter(scope, data) || workPointFilter(scope, data),
|
|
13677
13768
|
customIdPicker: pickGrOrObjId,
|
|
13678
13769
|
idxOfRef: 0,
|
|
13679
13770
|
selectorsOrder: selOrder
|
|
@@ -13681,7 +13772,7 @@ const RootImpl$d = ({
|
|
|
13681
13772
|
drawingId: drawingId,
|
|
13682
13773
|
param: refs,
|
|
13683
13774
|
caption: "Plane",
|
|
13684
|
-
filter: (scope, data) => planeFilter(scope, data) || workPlaneFilter(scope, data),
|
|
13775
|
+
filter: (scope, data) => core.planeFilter(scope, data) || workPlaneFilter(scope, data),
|
|
13685
13776
|
customIdPicker: pickGrOrObjId,
|
|
13686
13777
|
idxOfRef: 1,
|
|
13687
13778
|
selectorsOrder: selOrder
|
|
@@ -13711,41 +13802,90 @@ const Root$d = ({
|
|
|
13711
13802
|
}));
|
|
13712
13803
|
};
|
|
13713
13804
|
|
|
13714
|
-
const
|
|
13805
|
+
const WorkPlaneObj = ({
|
|
13715
13806
|
drawingId,
|
|
13716
|
-
|
|
13807
|
+
objectId,
|
|
13808
|
+
color = 0x34424f,
|
|
13809
|
+
opacity = 1,
|
|
13810
|
+
userData,
|
|
13811
|
+
handlers
|
|
13717
13812
|
}) => {
|
|
13718
13813
|
var _workPlaneObj$members2, _workPlaneObj$members3, _workPlaneObj$members4;
|
|
13719
13814
|
|
|
13815
|
+
const workPlaneObj = react.useDrawing(drawingId, drawing => objectId && drawing.structure.tree[objectId]); // It 'probably' is a temporary decision to use 2 front-sided planes with inverted normals; This is needed for Outlines, which currently doesn't respect THREE.DoubleSide
|
|
13816
|
+
|
|
13720
13817
|
const {
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
const quaternion = React.useMemo(() => {
|
|
13818
|
+
quaternion,
|
|
13819
|
+
quaternionInv
|
|
13820
|
+
} = React.useMemo(() => {
|
|
13725
13821
|
var _workPlaneObj$members;
|
|
13726
13822
|
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
|
|
13823
|
+
const up = new THREE__namespace.Vector3(0, 0, 1);
|
|
13824
|
+
const normal = convertToVector(workPlaneObj == null ? void 0 : (_workPlaneObj$members = workPlaneObj.members) == null ? void 0 : _workPlaneObj$members.Normal).normalize();
|
|
13825
|
+
const normalInv = normal.clone().negate();
|
|
13826
|
+
return {
|
|
13827
|
+
quaternion: new THREE__namespace.Quaternion().setFromUnitVectors(up, normal),
|
|
13828
|
+
quaternionInv: new THREE__namespace.Quaternion().setFromUnitVectors(up, normalInv)
|
|
13829
|
+
};
|
|
13830
|
+
}, [workPlaneObj == null ? void 0 : (_workPlaneObj$members2 = workPlaneObj.members) == null ? void 0 : _workPlaneObj$members2.Normal]);
|
|
13831
|
+
const position = convertToVector(workPlaneObj == null ? void 0 : (_workPlaneObj$members3 = workPlaneObj.members) == null ? void 0 : _workPlaneObj$members3.curPosition);
|
|
13832
|
+
const scale = workPlaneObj == null ? void 0 : (_workPlaneObj$members4 = workPlaneObj.members) == null ? void 0 : _workPlaneObj$members4.Size.value;
|
|
13833
|
+
const calScale = React.useCallback(sf => {
|
|
13834
|
+
// 1.2 = (kAxis * axisLength) / (planeDefScale * planeBase) = (3 * 40) / (200 * 0.5)
|
|
13835
|
+
const scale_ = 1.2 * sf * scale;
|
|
13836
|
+
return [scale_, scale_, scale_];
|
|
13837
|
+
}, [scale]);
|
|
13838
|
+
const ref = useScale$1(position.clone(), calScale);
|
|
13839
|
+
const refInv = useScale$1(position.clone(), calScale);
|
|
13840
|
+
return /*#__PURE__*/React.createElement("group", null, /*#__PURE__*/React.createElement("mesh", _extends({
|
|
13841
|
+
ref: ref,
|
|
13842
|
+
position: position,
|
|
13843
|
+
quaternion: quaternion,
|
|
13844
|
+
userData: userData
|
|
13845
|
+
}, handlers), /*#__PURE__*/React.createElement("meshBasicMaterial", {
|
|
13846
|
+
color: color,
|
|
13847
|
+
side: THREE__namespace.FrontSide,
|
|
13848
|
+
opacity: opacity,
|
|
13849
|
+
transparent: opacity < 1,
|
|
13850
|
+
depthWrite: false
|
|
13851
|
+
}), /*#__PURE__*/React.createElement("planeGeometry", {
|
|
13852
|
+
args: [1, 1]
|
|
13853
|
+
})), /*#__PURE__*/React.createElement("mesh", _extends({
|
|
13854
|
+
ref: refInv,
|
|
13855
|
+
position: position,
|
|
13856
|
+
quaternion: quaternionInv,
|
|
13857
|
+
userData: userData
|
|
13858
|
+
}, handlers), /*#__PURE__*/React.createElement("meshBasicMaterial", {
|
|
13859
|
+
color: color,
|
|
13860
|
+
side: THREE__namespace.FrontSide,
|
|
13861
|
+
opacity: opacity,
|
|
13862
|
+
transparent: opacity < 1,
|
|
13863
|
+
depthWrite: false
|
|
13864
|
+
}), /*#__PURE__*/React.createElement("planeGeometry", {
|
|
13865
|
+
args: [1, 1]
|
|
13866
|
+
})));
|
|
13867
|
+
};
|
|
13868
|
+
|
|
13869
|
+
const ViewImpl$b = ({
|
|
13870
|
+
drawingId,
|
|
13871
|
+
pluginId
|
|
13872
|
+
}) => {
|
|
13873
|
+
const {
|
|
13874
|
+
objectId = -1
|
|
13875
|
+
} = core.getPlugin(drawingId, pluginId);
|
|
13730
13876
|
const {
|
|
13731
13877
|
isHovered,
|
|
13732
13878
|
isSelected,
|
|
13733
13879
|
handlers
|
|
13734
13880
|
} = useTreeObjSelection(drawingId, objectId);
|
|
13735
13881
|
const color = isHovered ? 0x18b77f : isSelected ? 0xa70b0b : 0x34424f;
|
|
13736
|
-
return /*#__PURE__*/React.createElement(
|
|
13737
|
-
|
|
13738
|
-
|
|
13739
|
-
scale: scale
|
|
13740
|
-
}, handlers), /*#__PURE__*/React.createElement("meshBasicMaterial", {
|
|
13882
|
+
return /*#__PURE__*/React.createElement(WorkPlaneObj, {
|
|
13883
|
+
drawingId: drawingId,
|
|
13884
|
+
objectId: objectId,
|
|
13741
13885
|
color: color,
|
|
13742
|
-
side: THREE__namespace.DoubleSide,
|
|
13743
13886
|
opacity: 0.5,
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
}), /*#__PURE__*/React.createElement("planeGeometry", {
|
|
13747
|
-
args: [1, 1]
|
|
13748
|
-
}));
|
|
13887
|
+
handlers: handlers
|
|
13888
|
+
});
|
|
13749
13889
|
};
|
|
13750
13890
|
|
|
13751
13891
|
const View$b = ({
|
|
@@ -13838,34 +13978,34 @@ const RootImpl$c = ({
|
|
|
13838
13978
|
drawingId: drawingId,
|
|
13839
13979
|
param: refs,
|
|
13840
13980
|
caption: "Point",
|
|
13841
|
-
filter: (scope, data) => pointFilter(scope, data) || ccPointFilter(scope, data),
|
|
13981
|
+
filter: (scope, data) => core.pointFilter(scope, data) || ccPointFilter(scope, data),
|
|
13842
13982
|
customIdPicker: pickGrOrObjId,
|
|
13843
13983
|
idxOfRef: 0
|
|
13844
13984
|
}), type.userValue === classcad.WorkPointType.WPT_EDGEMIDPOINT && /*#__PURE__*/React.createElement(RefEditor, {
|
|
13845
13985
|
drawingId: drawingId,
|
|
13846
13986
|
param: refs,
|
|
13847
13987
|
caption: "Line",
|
|
13848
|
-
filter: (scope, data) => lineSegmentsFilter(scope, data) || ccLineFilter(scope, data),
|
|
13988
|
+
filter: (scope, data) => core.lineSegmentsFilter(scope, data) || ccLineFilter(scope, data),
|
|
13849
13989
|
customIdPicker: pickGrOrObjId,
|
|
13850
13990
|
idxOfRef: 0
|
|
13851
13991
|
}), type.userValue === classcad.WorkPointType.WPT_CENTER && /*#__PURE__*/React.createElement(RefEditor, {
|
|
13852
13992
|
drawingId: drawingId,
|
|
13853
13993
|
param: refs,
|
|
13854
13994
|
caption: "Arc/Circle",
|
|
13855
|
-
filter: (scope, data) => arcCircleFilter(scope, data) || ccArcFilter(scope, data) || ccCircleFilter(scope, data),
|
|
13995
|
+
filter: (scope, data) => core.arcCircleFilter(scope, data) || ccArcFilter(scope, data) || ccCircleFilter(scope, data),
|
|
13856
13996
|
customIdPicker: pickGrOrObjId,
|
|
13857
13997
|
idxOfRef: 0
|
|
13858
13998
|
}), type.userValue === classcad.WorkPointType.WPT_BARYCENTER && /*#__PURE__*/React.createElement(RefEditor, {
|
|
13859
13999
|
drawingId: drawingId,
|
|
13860
14000
|
param: refs,
|
|
13861
14001
|
caption: "Plane",
|
|
13862
|
-
filter: meshFilter,
|
|
14002
|
+
filter: core.meshFilter,
|
|
13863
14003
|
idxOfRef: 0
|
|
13864
14004
|
}), type.userValue === classcad.WorkPointType.WPT_2POINTS && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RefsEditor, {
|
|
13865
14005
|
drawingId: drawingId,
|
|
13866
14006
|
param: refs,
|
|
13867
14007
|
caption: "2 Points",
|
|
13868
|
-
filter: (scope, data) => pointFilter(scope, data) || ccPointFilter(scope, data),
|
|
14008
|
+
filter: (scope, data) => core.pointFilter(scope, data) || ccPointFilter(scope, data),
|
|
13869
14009
|
customIdPicker: pickGrOrObjId,
|
|
13870
14010
|
selectorsOrder: selOrder,
|
|
13871
14011
|
maxLen: 2
|
|
@@ -13873,7 +14013,7 @@ const RootImpl$c = ({
|
|
|
13873
14013
|
drawingId: drawingId,
|
|
13874
14014
|
param: refs,
|
|
13875
14015
|
caption: "2 Lines",
|
|
13876
|
-
filter: (scope, data) => lineSegmentsFilter(scope, data) || ccLineFilter(scope, data),
|
|
14016
|
+
filter: (scope, data) => core.lineSegmentsFilter(scope, data) || ccLineFilter(scope, data),
|
|
13877
14017
|
customIdPicker: pickGrOrObjId,
|
|
13878
14018
|
selectorsOrder: selOrder,
|
|
13879
14019
|
maxLen: 2
|
|
@@ -13881,7 +14021,7 @@ const RootImpl$c = ({
|
|
|
13881
14021
|
drawingId: drawingId,
|
|
13882
14022
|
param: refs,
|
|
13883
14023
|
caption: "3 Lines",
|
|
13884
|
-
filter: (scope, data) => lineSegmentsFilter(scope, data) || ccLineFilter(scope, data),
|
|
14024
|
+
filter: (scope, data) => core.lineSegmentsFilter(scope, data) || ccLineFilter(scope, data),
|
|
13885
14025
|
customIdPicker: pickGrOrObjId,
|
|
13886
14026
|
maxLen: 3
|
|
13887
14027
|
}));
|
|
@@ -13900,6 +14040,30 @@ const Root$c = ({
|
|
|
13900
14040
|
}));
|
|
13901
14041
|
};
|
|
13902
14042
|
|
|
14043
|
+
const WorkPointObj = ({
|
|
14044
|
+
drawingId,
|
|
14045
|
+
objectId,
|
|
14046
|
+
color = 0x111111,
|
|
14047
|
+
opacity = 1,
|
|
14048
|
+
userData,
|
|
14049
|
+
handlers
|
|
14050
|
+
}) => {
|
|
14051
|
+
var _workPointObj$members;
|
|
14052
|
+
|
|
14053
|
+
const workPointObj = react.useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
|
|
14054
|
+
const position = convertToVector(workPointObj == null ? void 0 : (_workPointObj$members = workPointObj.members) == null ? void 0 : _workPointObj$members.Position);
|
|
14055
|
+
const ref = useScale$1(position.clone(), sf => [3 * sf, 3 * sf, 3 * sf]);
|
|
14056
|
+
return /*#__PURE__*/React.createElement("group", {
|
|
14057
|
+
ref: ref,
|
|
14058
|
+
position: position
|
|
14059
|
+
}, /*#__PURE__*/React.createElement(OriginPoint, {
|
|
14060
|
+
color: color,
|
|
14061
|
+
opacity: opacity,
|
|
14062
|
+
userData: userData,
|
|
14063
|
+
handlers: handlers
|
|
14064
|
+
}));
|
|
14065
|
+
};
|
|
14066
|
+
|
|
13903
14067
|
const ViewImpl$a = ({
|
|
13904
14068
|
drawingId,
|
|
13905
14069
|
pluginId
|
|
@@ -13907,22 +14071,21 @@ const ViewImpl$a = ({
|
|
|
13907
14071
|
const {
|
|
13908
14072
|
objectId = -1
|
|
13909
14073
|
} = core.getPlugin(drawingId, pluginId);
|
|
13910
|
-
const workPointObj = react.useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
|
|
13911
|
-
const position = convertToVector(workPointObj.members.Position);
|
|
13912
14074
|
const {
|
|
13913
14075
|
isHovered,
|
|
13914
14076
|
isSelected,
|
|
13915
14077
|
handlers
|
|
13916
14078
|
} = useTreeObjSelection(drawingId, objectId);
|
|
13917
14079
|
const color = isHovered ? 0x28d79f : isSelected ? 0xa70b0b : 0x111111;
|
|
13918
|
-
|
|
13919
|
-
|
|
13920
|
-
|
|
13921
|
-
position: position
|
|
13922
|
-
}, /*#__PURE__*/React.createElement(OriginPoint, {
|
|
14080
|
+
return /*#__PURE__*/React.createElement(HUD, null, /*#__PURE__*/React.createElement(WorkPointObj, {
|
|
14081
|
+
drawingId: drawingId,
|
|
14082
|
+
objectId: objectId,
|
|
13923
14083
|
color: color,
|
|
14084
|
+
userData: {
|
|
14085
|
+
onHUD: true
|
|
14086
|
+
},
|
|
13924
14087
|
handlers: handlers
|
|
13925
|
-
}))
|
|
14088
|
+
}));
|
|
13926
14089
|
};
|
|
13927
14090
|
|
|
13928
14091
|
const View$a = ({
|
|
@@ -14324,8 +14487,8 @@ function RootImpl$b({
|
|
|
14324
14487
|
|
|
14325
14488
|
return warnings;
|
|
14326
14489
|
}, [drawingId, pluginId, type]);
|
|
14327
|
-
const originFilter = React.useCallback((scope, data) => pointFilter(scope, data) || workPointFilter(scope, data) || ccPointFilter(scope, data) || arcCircleFilter(scope, data), []);
|
|
14328
|
-
const axisFilter = React.useCallback((scope, data) => lineFilter(scope, data) || workAxisFilter(scope, data) || ccLineFilter(scope, data), []);
|
|
14490
|
+
const originFilter = React.useCallback((scope, data) => core.pointFilter(scope, data) || workPointFilter(scope, data) || ccPointFilter(scope, data) || core.arcCircleFilter(scope, data), []);
|
|
14491
|
+
const axisFilter = React.useCallback((scope, data) => core.lineFilter(scope, data) || workAxisFilter(scope, data) || ccLineFilter(scope, data), []);
|
|
14329
14492
|
return /*#__PURE__*/React.createElement(PluginForm, {
|
|
14330
14493
|
drawingId: drawingId,
|
|
14331
14494
|
update: update,
|
|
@@ -14404,6 +14567,37 @@ const Root$b = ({
|
|
|
14404
14567
|
}));
|
|
14405
14568
|
};
|
|
14406
14569
|
|
|
14570
|
+
const WorkCoordSystemObj = ({
|
|
14571
|
+
drawingId,
|
|
14572
|
+
objectId,
|
|
14573
|
+
color,
|
|
14574
|
+
opacity = 1,
|
|
14575
|
+
userData,
|
|
14576
|
+
handlers
|
|
14577
|
+
}) => {
|
|
14578
|
+
const coordSys = react.useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
|
|
14579
|
+
const matrix = React.useMemo(() => {
|
|
14580
|
+
var _coordSys$children, _coordSys$members;
|
|
14581
|
+
|
|
14582
|
+
const tree = core.getDrawing(drawingId).structure.tree;
|
|
14583
|
+
const children = (coordSys == null ? void 0 : (_coordSys$children = coordSys.children) == null ? void 0 : _coordSys$children.map(id => tree[id])) || [];
|
|
14584
|
+
const pos = convertToVector(coordSys == null ? void 0 : (_coordSys$members = coordSys.members) == null ? void 0 : _coordSys$members.Position);
|
|
14585
|
+
const [xAxis, yAxis, zAxis] = ['xAxis', 'yAxis', 'zAxis'].map(name => children.find(child => child.name === name)).map(axis => {
|
|
14586
|
+
var _axis$members;
|
|
14587
|
+
|
|
14588
|
+
return convertToVector(axis == null ? void 0 : (_axis$members = axis.members) == null ? void 0 : _axis$members.Direction);
|
|
14589
|
+
});
|
|
14590
|
+
return new THREE__namespace.Matrix4().makeBasis(xAxis, yAxis, zAxis).setPosition(pos);
|
|
14591
|
+
}, [drawingId, coordSys]);
|
|
14592
|
+
return /*#__PURE__*/React.createElement(Csys, {
|
|
14593
|
+
matrix: matrix,
|
|
14594
|
+
color: color,
|
|
14595
|
+
opacity: opacity,
|
|
14596
|
+
userData: userData,
|
|
14597
|
+
handlers: handlers
|
|
14598
|
+
});
|
|
14599
|
+
};
|
|
14600
|
+
|
|
14407
14601
|
const tolerance = 1e-6; // Calculates a transformation matrix
|
|
14408
14602
|
// xDir and yDir are NOT orthogonal in general case, thus the y-axis is calculated as a series of cross products
|
|
14409
14603
|
|
|
@@ -14438,20 +14632,6 @@ function ViewImpl$9({
|
|
|
14438
14632
|
objectId
|
|
14439
14633
|
} = react.usePlugin(drawingId, pluginId, pluginState => pluginState);
|
|
14440
14634
|
const isActive = react.useDrawing(drawingId, drawing => drawing.plugin.active.feature === pluginId);
|
|
14441
|
-
const coordSys = react.useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
|
|
14442
|
-
const matrix = React.useMemo(() => {
|
|
14443
|
-
var _coordSys$children, _coordSys$members;
|
|
14444
|
-
|
|
14445
|
-
const tree = core.getDrawing(drawingId).structure.tree;
|
|
14446
|
-
const children = ((_coordSys$children = coordSys.children) == null ? void 0 : _coordSys$children.map(id => tree[id])) || [];
|
|
14447
|
-
const pos = convertToVector((_coordSys$members = coordSys.members) == null ? void 0 : _coordSys$members.Position);
|
|
14448
|
-
const [xAxis, yAxis, zAxis] = ['xAxis', 'yAxis', 'zAxis'].map(name => children.find(child => child.name === name)).map(axis => {
|
|
14449
|
-
var _axis$members;
|
|
14450
|
-
|
|
14451
|
-
return convertToVector(axis == null ? void 0 : (_axis$members = axis.members) == null ? void 0 : _axis$members.Direction);
|
|
14452
|
-
});
|
|
14453
|
-
return new THREE__namespace.Matrix4().makeBasis(xAxis, yAxis, zAxis).setPosition(pos);
|
|
14454
|
-
}, [drawingId, coordSys]);
|
|
14455
14635
|
const {
|
|
14456
14636
|
originPos,
|
|
14457
14637
|
xDir,
|
|
@@ -14474,11 +14654,14 @@ function ViewImpl$9({
|
|
|
14474
14654
|
// undefined means default color which defined in Csys component.
|
|
14475
14655
|
|
|
14476
14656
|
const color = isHovered ? 0x28d79f : isSelected ? 0xa70b0b : undefined;
|
|
14477
|
-
return /*#__PURE__*/React.createElement(HUD, null, /*#__PURE__*/React.createElement("group", null, /*#__PURE__*/React.createElement(
|
|
14478
|
-
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14657
|
+
return /*#__PURE__*/React.createElement(HUD, null, /*#__PURE__*/React.createElement("group", null, /*#__PURE__*/React.createElement(WorkCoordSystemObj, {
|
|
14658
|
+
drawingId: drawingId,
|
|
14659
|
+
objectId: objectId,
|
|
14660
|
+
color: color,
|
|
14661
|
+
userData: {
|
|
14662
|
+
onHUD: true
|
|
14663
|
+
},
|
|
14664
|
+
handlers: handlers
|
|
14482
14665
|
}), isActive && /*#__PURE__*/React.createElement(Csys, {
|
|
14483
14666
|
matrix: previewMatrix,
|
|
14484
14667
|
opacity: 0.5,
|
|
@@ -15519,9 +15702,9 @@ const MatePathTransform = ({
|
|
|
15519
15702
|
}) => {
|
|
15520
15703
|
const refId = matePath[currentDepth];
|
|
15521
15704
|
const csys = react.useDrawing(drawingId, drawing => {
|
|
15522
|
-
var _drawing$structure$
|
|
15705
|
+
var _drawing$structure$tr;
|
|
15523
15706
|
|
|
15524
|
-
return (_drawing$structure$
|
|
15707
|
+
return (_drawing$structure$tr = drawing.structure.tree[refId]) == null ? void 0 : _drawing$structure$tr.coordinateSystem;
|
|
15525
15708
|
});
|
|
15526
15709
|
const matrix_ = React.useMemo(() => {
|
|
15527
15710
|
if (!csys) {
|
|
@@ -15717,7 +15900,8 @@ const CSysDisplayImpl = ({
|
|
|
15717
15900
|
csysId,
|
|
15718
15901
|
matePath,
|
|
15719
15902
|
flip: classcad.FlipType.FLIP_Z,
|
|
15720
|
-
reoriented: classcad.ReorientedType.REORIENTED_0
|
|
15903
|
+
reoriented: classcad.ReorientedType.REORIENTED_0,
|
|
15904
|
+
onHUD: true
|
|
15721
15905
|
};
|
|
15722
15906
|
|
|
15723
15907
|
if (!isCSysUnique(csysUserData, hoveredCSysIds_)) {
|
|
@@ -15780,7 +15964,8 @@ const CSysDisplayImpl = ({
|
|
|
15780
15964
|
flip: item.data.flip,
|
|
15781
15965
|
reoriented: item.data.reoriented,
|
|
15782
15966
|
isSelected: true,
|
|
15783
|
-
isActive: activeSelItems.findIndex(item_ => item_.id === item.id) !== -1
|
|
15967
|
+
isActive: activeSelItems.findIndex(item_ => item_.id === item.id) !== -1,
|
|
15968
|
+
onHUD: true
|
|
15784
15969
|
});
|
|
15785
15970
|
});
|
|
15786
15971
|
const ids = hoveredOnly ? hoveredProductIds : activeProducts;
|
|
@@ -15811,7 +15996,8 @@ const CSysDisplayImpl = ({
|
|
|
15811
15996
|
}, csysUDataArray_)) {
|
|
15812
15997
|
csysUDataArray_.push({
|
|
15813
15998
|
csysId,
|
|
15814
|
-
matePath
|
|
15999
|
+
matePath,
|
|
16000
|
+
onHUD: true
|
|
15815
16001
|
});
|
|
15816
16002
|
}
|
|
15817
16003
|
});
|
|
@@ -18377,18 +18563,24 @@ const mateNames$1 = ['firstRefMate', 'secondRefMate'];
|
|
|
18377
18563
|
const getCSysKey = uData => uData.csysId.toString() + ', ' + uData.matePath.toString();
|
|
18378
18564
|
|
|
18379
18565
|
const HoveredConstraintDisplay = ({
|
|
18380
|
-
drawingId
|
|
18381
|
-
hoveredId
|
|
18566
|
+
drawingId
|
|
18382
18567
|
}) => {
|
|
18568
|
+
const hoveredId = react.useDrawing(drawingId, d => {
|
|
18569
|
+
var _d$interaction$hovere;
|
|
18570
|
+
|
|
18571
|
+
return (_d$interaction$hovere = d.interaction.hovered) == null ? void 0 : _d$interaction$hovere.objectId;
|
|
18572
|
+
}) || NOCCID;
|
|
18573
|
+
const hoveredObj = react.useDrawing(drawingId, d => d.structure.tree[hoveredId]);
|
|
18574
|
+
const hoveredConstrId = classcad.ccUtils.base.isA((hoveredObj == null ? void 0 : hoveredObj.class) || '', classcad.CCClasses.CCHLConstraint) ? hoveredId : null;
|
|
18383
18575
|
const csysUDataArray = React.useMemo(() => {
|
|
18384
18576
|
var _getDrawing, _getDrawing$structure;
|
|
18385
18577
|
|
|
18386
|
-
if (!
|
|
18578
|
+
if (!hoveredConstrId) {
|
|
18387
18579
|
return [];
|
|
18388
18580
|
}
|
|
18389
18581
|
|
|
18390
18582
|
const csysUDataArray_ = [];
|
|
18391
|
-
const members = (_getDrawing = core.getDrawing(drawingId)) == null ? void 0 : (_getDrawing$structure = _getDrawing.structure.tree[
|
|
18583
|
+
const members = (_getDrawing = core.getDrawing(drawingId)) == null ? void 0 : (_getDrawing$structure = _getDrawing.structure.tree[hoveredConstrId]) == null ? void 0 : _getDrawing$structure.members;
|
|
18392
18584
|
|
|
18393
18585
|
if (members && members[mateNames$1[0]]) {
|
|
18394
18586
|
mateNames$1.forEach(mateName => {
|
|
@@ -18397,28 +18589,678 @@ const HoveredConstraintDisplay = ({
|
|
|
18397
18589
|
if (member && member.members.length > 2) {
|
|
18398
18590
|
var _member$members$, _member$members$2;
|
|
18399
18591
|
|
|
18400
|
-
const matePath = member.members[0].members.map(memb => memb.value);
|
|
18401
|
-
const csysId = member.members[1].value;
|
|
18402
|
-
const flip = ((_member$members$ = member.members[2]) == null ? void 0 : _member$members$.value) !== undefined ? member.members[2].value : classcad.FlipType.FLIP_Z;
|
|
18403
|
-
const reoriented = ((_member$members$2 = member.members[3]) == null ? void 0 : _member$members$2.value) !== undefined ? member.members[3].value : classcad.ReorientedType.REORIENTED_0;
|
|
18404
|
-
csysUDataArray_.push({
|
|
18405
|
-
matePath,
|
|
18406
|
-
csysId,
|
|
18407
|
-
flip,
|
|
18408
|
-
reoriented,
|
|
18409
|
-
isSelected: true
|
|
18410
|
-
|
|
18411
|
-
|
|
18412
|
-
|
|
18413
|
-
|
|
18592
|
+
const matePath = member.members[0].members.map(memb => memb.value);
|
|
18593
|
+
const csysId = member.members[1].value;
|
|
18594
|
+
const flip = ((_member$members$ = member.members[2]) == null ? void 0 : _member$members$.value) !== undefined ? member.members[2].value : classcad.FlipType.FLIP_Z;
|
|
18595
|
+
const reoriented = ((_member$members$2 = member.members[3]) == null ? void 0 : _member$members$2.value) !== undefined ? member.members[3].value : classcad.ReorientedType.REORIENTED_0;
|
|
18596
|
+
csysUDataArray_.push({
|
|
18597
|
+
matePath,
|
|
18598
|
+
csysId,
|
|
18599
|
+
flip,
|
|
18600
|
+
reoriented,
|
|
18601
|
+
isSelected: true,
|
|
18602
|
+
onHUD: true
|
|
18603
|
+
});
|
|
18604
|
+
}
|
|
18605
|
+
});
|
|
18606
|
+
}
|
|
18607
|
+
|
|
18608
|
+
return csysUDataArray_;
|
|
18609
|
+
}, [drawingId, hoveredConstrId]);
|
|
18610
|
+
return /*#__PURE__*/React.createElement(HUD, null, /*#__PURE__*/React.createElement("group", null, csysUDataArray.map(userData => /*#__PURE__*/React.createElement(CSysWrapper, {
|
|
18611
|
+
key: getCSysKey(userData),
|
|
18612
|
+
drawingId: drawingId,
|
|
18613
|
+
userData: userData
|
|
18614
|
+
}))));
|
|
18615
|
+
};
|
|
18616
|
+
|
|
18617
|
+
const SelectedMateObj = ({
|
|
18618
|
+
drawingId,
|
|
18619
|
+
csysId,
|
|
18620
|
+
matePath,
|
|
18621
|
+
flip,
|
|
18622
|
+
color,
|
|
18623
|
+
reoriented,
|
|
18624
|
+
opacity
|
|
18625
|
+
}) => {
|
|
18626
|
+
const currentNode = react.useDrawing(drawingId, drawing => drawing.structure.currentNode);
|
|
18627
|
+
const matrix = useCsysMatrix(drawingId, csysId, flip, reoriented);
|
|
18628
|
+
return /*#__PURE__*/React.createElement(react.GlobalTransform, {
|
|
18629
|
+
drawingId: drawingId,
|
|
18630
|
+
objectId: currentNode
|
|
18631
|
+
}, /*#__PURE__*/React.createElement(MatePathTransform, {
|
|
18632
|
+
drawingId: drawingId,
|
|
18633
|
+
matePath: matePath
|
|
18634
|
+
}, /*#__PURE__*/React.createElement(SelectedCsys, {
|
|
18635
|
+
matrix: matrix,
|
|
18636
|
+
color: color,
|
|
18637
|
+
opacity: opacity
|
|
18638
|
+
})));
|
|
18639
|
+
};
|
|
18640
|
+
|
|
18641
|
+
const vertexCode$1 = `
|
|
18642
|
+
uniform mat4 modelViewMatrix;
|
|
18643
|
+
uniform mat4 projectionMatrix;
|
|
18644
|
+
|
|
18645
|
+
attribute vec3 position;
|
|
18646
|
+
|
|
18647
|
+
void main() {
|
|
18648
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
18649
|
+
}
|
|
18650
|
+
`;
|
|
18651
|
+
const fragmentCode$2 = `
|
|
18652
|
+
uniform lowp vec3 idColor;
|
|
18653
|
+
|
|
18654
|
+
void main() {
|
|
18655
|
+
gl_FragColor.rgb = idColor;
|
|
18656
|
+
}
|
|
18657
|
+
`;
|
|
18658
|
+
class IDPass extends postprocessing.Pass {
|
|
18659
|
+
constructor(scene, camera) {
|
|
18660
|
+
super('IDPass', scene, camera);
|
|
18661
|
+
|
|
18662
|
+
_defineProperty(this, "material", void 0);
|
|
18663
|
+
|
|
18664
|
+
_defineProperty(this, "oldMaterials", void 0);
|
|
18665
|
+
|
|
18666
|
+
_defineProperty(this, "selection", void 0);
|
|
18667
|
+
|
|
18668
|
+
_defineProperty(this, "id", void 0);
|
|
18669
|
+
|
|
18670
|
+
_defineProperty(this, "channel", void 0);
|
|
18671
|
+
|
|
18672
|
+
this.needsSwap = false;
|
|
18673
|
+
this.material = new THREE__namespace.RawShaderMaterial({
|
|
18674
|
+
uniforms: {
|
|
18675
|
+
idColor: new THREE__namespace.Uniform(new THREE__namespace.Color(0xff0000))
|
|
18676
|
+
},
|
|
18677
|
+
depthWrite: false,
|
|
18678
|
+
depthTest: false,
|
|
18679
|
+
vertexShader: vertexCode$1,
|
|
18680
|
+
fragmentShader: fragmentCode$2
|
|
18681
|
+
});
|
|
18682
|
+
this.oldMaterials = new Map();
|
|
18683
|
+
this.selection = new postprocessing.Selection();
|
|
18684
|
+
this.id = 0;
|
|
18685
|
+
this.channel = 0;
|
|
18686
|
+
}
|
|
18687
|
+
|
|
18688
|
+
render(renderer, inputBuffer) {
|
|
18689
|
+
const scene = this.scene;
|
|
18690
|
+
const camera = this.camera;
|
|
18691
|
+
const mask = camera.layers.mask;
|
|
18692
|
+
const background = scene.background;
|
|
18693
|
+
const shadowMapAutoUpdate = renderer.shadowMap.autoUpdate;
|
|
18694
|
+
renderer.shadowMap.autoUpdate = false;
|
|
18695
|
+
scene.background = null;
|
|
18696
|
+
const color = [0.0, 0.0, 0.0];
|
|
18697
|
+
color[this.channel] = (this.id + 1) / 255.0;
|
|
18698
|
+
this.material.uniforms.idColor.value = new THREE__namespace.Color(...color);
|
|
18699
|
+
this.selection.forEach(mesh_ => {
|
|
18700
|
+
const mesh = mesh_;
|
|
18701
|
+
this.oldMaterials.set(mesh, mesh.material);
|
|
18702
|
+
mesh.material = this.material;
|
|
18703
|
+
});
|
|
18704
|
+
renderer.setRenderTarget(inputBuffer);
|
|
18705
|
+
renderer.render(scene, camera);
|
|
18706
|
+
|
|
18707
|
+
for (const entry of this.oldMaterials) {
|
|
18708
|
+
entry[0].material = entry[1];
|
|
18709
|
+
}
|
|
18710
|
+
|
|
18711
|
+
this.oldMaterials.clear();
|
|
18712
|
+
camera.layers.mask = mask;
|
|
18713
|
+
scene.background = background;
|
|
18714
|
+
renderer.shadowMap.autoUpdate = shadowMapAutoUpdate;
|
|
18715
|
+
}
|
|
18716
|
+
|
|
18717
|
+
}
|
|
18718
|
+
|
|
18719
|
+
const vertexCode = `
|
|
18720
|
+
uniform vec2 texelSize;
|
|
18721
|
+
|
|
18722
|
+
varying vec2 vUv0;
|
|
18723
|
+
varying vec2 vUv1;
|
|
18724
|
+
varying vec2 vUv2;
|
|
18725
|
+
varying vec2 vUv3;
|
|
18726
|
+
|
|
18727
|
+
void main() {
|
|
18728
|
+
vec2 uv = position.xy * 0.5 + 0.5;
|
|
18729
|
+
|
|
18730
|
+
vUv0 = vec2(uv.x + texelSize.x, uv.y);
|
|
18731
|
+
vUv1 = vec2(uv.x - texelSize.x, uv.y);
|
|
18732
|
+
vUv2 = vec2(uv.x, uv.y + texelSize.y);
|
|
18733
|
+
vUv3 = vec2(uv.x, uv.y - texelSize.y);
|
|
18734
|
+
|
|
18735
|
+
gl_Position = vec4(position.xy, 1.0, 1.0);
|
|
18736
|
+
}
|
|
18737
|
+
`;
|
|
18738
|
+
const fragmentCode$1 = `
|
|
18739
|
+
uniform lowp sampler2D inputBuffer;
|
|
18740
|
+
|
|
18741
|
+
varying vec2 vUv0;
|
|
18742
|
+
varying vec2 vUv1;
|
|
18743
|
+
varying vec2 vUv2;
|
|
18744
|
+
varying vec2 vUv3;
|
|
18745
|
+
|
|
18746
|
+
void main() {
|
|
18747
|
+
vec3 c0 = texture2D(inputBuffer, vUv0).rgb;
|
|
18748
|
+
vec3 c1 = texture2D(inputBuffer, vUv1).rgb;
|
|
18749
|
+
vec3 c2 = texture2D(inputBuffer, vUv2).rgb;
|
|
18750
|
+
vec3 c3 = texture2D(inputBuffer, vUv3).rgb;
|
|
18751
|
+
|
|
18752
|
+
if (c0 == c1 && c0 == c2 && c0 == c3) {
|
|
18753
|
+
discard;
|
|
18754
|
+
}
|
|
18755
|
+
|
|
18756
|
+
vec3 maxVec = max(max(c0, c1), max(c2, c3));
|
|
18757
|
+
vec2 kVec = vec2(1.0, 1.0) - step(maxVec.gb, vec2(0.0, 0.0));
|
|
18758
|
+
float k3 = kVec.g;
|
|
18759
|
+
float k2 = (1.0 - k3) * kVec.r;
|
|
18760
|
+
float k1 = (1.0 - k3) * (1.0 - k2);
|
|
18761
|
+
|
|
18762
|
+
gl_FragColor = k1 * vec4(1.0, 0.0, 0.0, 1.0) + k2 * vec4(0.0, 1.0, 0.0, 1.0) + k3 * vec4(0.0, 0.0, 1.0, 1.0);
|
|
18763
|
+
}
|
|
18764
|
+
`;
|
|
18765
|
+
class OutlineMaterial extends THREE__namespace.ShaderMaterial {
|
|
18766
|
+
constructor(texelSize = new THREE__namespace.Vector2()) {
|
|
18767
|
+
super({
|
|
18768
|
+
name: "OutlineMaterial",
|
|
18769
|
+
uniforms: {
|
|
18770
|
+
inputBuffer: new THREE__namespace.Uniform(null),
|
|
18771
|
+
texelSize: new THREE__namespace.Uniform(new THREE__namespace.Vector2()),
|
|
18772
|
+
channel: new THREE__namespace.Uniform(new THREE__namespace.Color(0xff0000))
|
|
18773
|
+
},
|
|
18774
|
+
blending: THREE__namespace.NoBlending,
|
|
18775
|
+
depthWrite: false,
|
|
18776
|
+
depthTest: false,
|
|
18777
|
+
vertexShader: vertexCode,
|
|
18778
|
+
fragmentShader: fragmentCode$1
|
|
18779
|
+
});
|
|
18780
|
+
this.toneMapped = false;
|
|
18781
|
+
this.setTexelSize(texelSize.x, texelSize.y);
|
|
18782
|
+
this.uniforms.maskTexture = this.uniforms.inputBuffer;
|
|
18783
|
+
}
|
|
18784
|
+
|
|
18785
|
+
set inputBuffer(value) {
|
|
18786
|
+
this.uniforms.inputBuffer.value = value;
|
|
18787
|
+
}
|
|
18788
|
+
|
|
18789
|
+
setTexelSize(x, y) {
|
|
18790
|
+
this.uniforms.texelSize.value.set(x, y);
|
|
18791
|
+
}
|
|
18792
|
+
|
|
18793
|
+
setSize(width, height) {
|
|
18794
|
+
this.uniforms.texelSize.value.set(1.0 / width, 1.0 / height);
|
|
18795
|
+
}
|
|
18796
|
+
|
|
18797
|
+
}
|
|
18798
|
+
|
|
18799
|
+
const fragmentCode = `
|
|
18800
|
+
uniform lowp sampler2D edgeTexture;
|
|
18801
|
+
|
|
18802
|
+
uniform float edgeStrength;
|
|
18803
|
+
uniform vec3 edgeColor1;
|
|
18804
|
+
uniform vec3 edgeColor2;
|
|
18805
|
+
uniform vec3 edgeColor3;
|
|
18806
|
+
|
|
18807
|
+
void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
|
|
18808
|
+
vec3 edge = texture2D(edgeTexture, uv).rgb * edgeStrength;
|
|
18809
|
+
|
|
18810
|
+
vec4 kVec = vec4(1.0, 1.0, 1.0, 1.0) - step(edge.bbgg, edge.rgrb);
|
|
18811
|
+
float k3 = kVec.r * kVec.g;
|
|
18812
|
+
float k2 = (1.0 - k3) * kVec.b * kVec.a;
|
|
18813
|
+
float k1 = (1.0 - k3) * (1.0 - k2);
|
|
18814
|
+
vec3 color = k1 * edgeColor1 + k2 * edgeColor2 + k3 * edgeColor3;
|
|
18815
|
+
|
|
18816
|
+
float alpha = 3.0 * max(max(edge.r, edge.g), edge.b) - 2.0;
|
|
18817
|
+
alpha *= step(0.4, alpha);
|
|
18818
|
+
|
|
18819
|
+
outputColor = vec4(color, alpha);
|
|
18820
|
+
}
|
|
18821
|
+
`;
|
|
18822
|
+
class OutlineEffect extends postprocessing.Effect {
|
|
18823
|
+
constructor(scene, camera, {
|
|
18824
|
+
edgeStrength = 1.0,
|
|
18825
|
+
edgeColor1 = 0xffffff,
|
|
18826
|
+
edgeColor2 = 0xffffff,
|
|
18827
|
+
edgeColor3 = 0xffffff,
|
|
18828
|
+
resolutionScale = 1.0,
|
|
18829
|
+
width = postprocessing.Resolution.AUTO_SIZE,
|
|
18830
|
+
height = postprocessing.Resolution.AUTO_SIZE,
|
|
18831
|
+
kernelSize = postprocessing.KernelSize.VERY_SMALL
|
|
18832
|
+
} = {}) {
|
|
18833
|
+
super("OutlineEffect", fragmentCode, {
|
|
18834
|
+
uniforms: new Map([["edgeTexture", new THREE__namespace.Uniform(null)], ["edgeStrength", new THREE__namespace.Uniform(edgeStrength)], ["edgeColor1", new THREE__namespace.Uniform(new THREE__namespace.Color(edgeColor1))], ["edgeColor2", new THREE__namespace.Uniform(new THREE__namespace.Color(edgeColor2))], ["edgeColor3", new THREE__namespace.Uniform(new THREE__namespace.Color(edgeColor3))]])
|
|
18835
|
+
});
|
|
18836
|
+
|
|
18837
|
+
_defineProperty(this, "scene", void 0);
|
|
18838
|
+
|
|
18839
|
+
_defineProperty(this, "camera", void 0);
|
|
18840
|
+
|
|
18841
|
+
_defineProperty(this, "idRT", void 0);
|
|
18842
|
+
|
|
18843
|
+
_defineProperty(this, "outlineRT", void 0);
|
|
18844
|
+
|
|
18845
|
+
_defineProperty(this, "clearPass", void 0);
|
|
18846
|
+
|
|
18847
|
+
_defineProperty(this, "idPass", void 0);
|
|
18848
|
+
|
|
18849
|
+
_defineProperty(this, "outlinePass", void 0);
|
|
18850
|
+
|
|
18851
|
+
_defineProperty(this, "blurPass", void 0);
|
|
18852
|
+
|
|
18853
|
+
_defineProperty(this, "selections1", void 0);
|
|
18854
|
+
|
|
18855
|
+
_defineProperty(this, "selections2", void 0);
|
|
18856
|
+
|
|
18857
|
+
_defineProperty(this, "selections3", void 0);
|
|
18858
|
+
|
|
18859
|
+
_defineProperty(this, "time", void 0);
|
|
18860
|
+
|
|
18861
|
+
_defineProperty(this, "processSelection", void 0);
|
|
18862
|
+
|
|
18863
|
+
this.blendMode.setBlendFunction(postprocessing.BlendFunction.ALPHA);
|
|
18864
|
+
this.scene = scene;
|
|
18865
|
+
this.camera = camera;
|
|
18866
|
+
this.idRT = new THREE__namespace.WebGLRenderTarget(1, 1, {
|
|
18867
|
+
minFilter: THREE__namespace.NearestFilter,
|
|
18868
|
+
magFilter: THREE__namespace.NearestFilter,
|
|
18869
|
+
depthBuffer: false,
|
|
18870
|
+
stencilBuffer: false
|
|
18871
|
+
});
|
|
18872
|
+
this.idRT.texture.name = "Outline.IDs";
|
|
18873
|
+
this.outlineRT = new THREE__namespace.WebGLRenderTarget(1, 1, {
|
|
18874
|
+
minFilter: THREE__namespace.LinearFilter,
|
|
18875
|
+
magFilter: THREE__namespace.LinearFilter,
|
|
18876
|
+
depthBuffer: false,
|
|
18877
|
+
stencilBuffer: false
|
|
18878
|
+
});
|
|
18879
|
+
this.outlineRT.texture.name = "Outline.Edges";
|
|
18880
|
+
const edgeTexture = this.uniforms.get("edgeTexture");
|
|
18881
|
+
edgeTexture.value = this.outlineRT.texture;
|
|
18882
|
+
this.clearPass = new postprocessing.ClearPass();
|
|
18883
|
+
this.clearPass.overrideClearColor = new THREE__namespace.Color(0x000000);
|
|
18884
|
+
this.clearPass.overrideClearAlpha = 0;
|
|
18885
|
+
this.idPass = new IDPass(scene, camera);
|
|
18886
|
+
this.outlinePass = new postprocessing.ShaderPass(new OutlineMaterial());
|
|
18887
|
+
const outlineMaterial = this.outlinePass.fullscreenMaterial;
|
|
18888
|
+
outlineMaterial.inputBuffer = this.idRT.texture;
|
|
18889
|
+
this.blurPass = new postprocessing.KawaseBlurPass({
|
|
18890
|
+
resolutionScale,
|
|
18891
|
+
width,
|
|
18892
|
+
height,
|
|
18893
|
+
kernelSize
|
|
18894
|
+
});
|
|
18895
|
+
const resolution = this.blurPass.resolution;
|
|
18896
|
+
resolution.addEventListener("change", e => this.setSize(resolution.baseWidth, resolution.baseHeight));
|
|
18897
|
+
this.time = 0;
|
|
18898
|
+
this.selections1 = [];
|
|
18899
|
+
this.selections2 = [];
|
|
18900
|
+
this.selections3 = [];
|
|
18901
|
+
|
|
18902
|
+
this.processSelection = (renderer, selection, id) => {
|
|
18903
|
+
selection.layer++;
|
|
18904
|
+
this.idPass.id = id;
|
|
18905
|
+
this.idPass.selection = selection;
|
|
18906
|
+
this.idPass.render(renderer, this.idRT);
|
|
18907
|
+
selection.layer--;
|
|
18908
|
+
this.outlinePass.render(renderer, null, this.outlineRT);
|
|
18909
|
+
};
|
|
18910
|
+
}
|
|
18911
|
+
|
|
18912
|
+
set selectionLayer(value) {
|
|
18913
|
+
this.selections1.forEach(selection => {
|
|
18914
|
+
selection.layer = value;
|
|
18915
|
+
});
|
|
18916
|
+
this.selections2.forEach(selection => {
|
|
18917
|
+
selection.layer = value;
|
|
18918
|
+
});
|
|
18919
|
+
this.selections3.forEach(selection => {
|
|
18920
|
+
selection.layer = value;
|
|
18921
|
+
});
|
|
18922
|
+
}
|
|
18923
|
+
|
|
18924
|
+
update(renderer, inputBuffer, deltaTime) {
|
|
18925
|
+
const scene = this.scene;
|
|
18926
|
+
const camera = this.camera;
|
|
18927
|
+
const selections1 = this.selections1;
|
|
18928
|
+
const selections2 = this.selections2;
|
|
18929
|
+
const selections3 = this.selections3;
|
|
18930
|
+
const background = scene.background;
|
|
18931
|
+
const mask = camera.layers.mask;
|
|
18932
|
+
|
|
18933
|
+
if (selections1.length > 0 || selections2.length > 0 || selections3.length > 0) {
|
|
18934
|
+
var _selections1$, _selections2$, _selections3$;
|
|
18935
|
+
|
|
18936
|
+
scene.background = null;
|
|
18937
|
+
this.time += deltaTime;
|
|
18938
|
+
const layer = ((_selections1$ = selections1[0]) == null ? void 0 : _selections1$.layer) || ((_selections2$ = selections2[0]) == null ? void 0 : _selections2$.layer) || ((_selections3$ = selections3[0]) == null ? void 0 : _selections3$.layer);
|
|
18939
|
+
camera.layers.set(layer + 1);
|
|
18940
|
+
this.clearPass.render(renderer, this.idRT, null);
|
|
18941
|
+
this.clearPass.render(renderer, this.outlineRT, null);
|
|
18942
|
+
let len = Math.min(this.selections1.length, 255);
|
|
18943
|
+
this.idPass.channel = 0;
|
|
18944
|
+
|
|
18945
|
+
for (let i = 0; i < len; i++) {
|
|
18946
|
+
this.processSelection(renderer, selections1[i], i);
|
|
18947
|
+
}
|
|
18948
|
+
|
|
18949
|
+
len = Math.min(this.selections2.length, 255);
|
|
18950
|
+
this.idPass.channel = 1;
|
|
18951
|
+
|
|
18952
|
+
for (let i = 0; i < len; i++) {
|
|
18953
|
+
this.processSelection(renderer, selections2[i], i);
|
|
18954
|
+
}
|
|
18955
|
+
|
|
18956
|
+
len = Math.min(this.selections3.length, 255);
|
|
18957
|
+
this.idPass.channel = 2;
|
|
18958
|
+
|
|
18959
|
+
for (let i = 0; i < len; i++) {
|
|
18960
|
+
this.processSelection(renderer, selections3[i], i);
|
|
18961
|
+
} // Restore the camera layer mask and the scene background.
|
|
18962
|
+
|
|
18963
|
+
|
|
18964
|
+
camera.layers.mask = mask;
|
|
18965
|
+
scene.background = background;
|
|
18966
|
+
|
|
18967
|
+
if (this.blurPass.enabled) {
|
|
18968
|
+
this.blurPass.render(renderer, this.outlineRT, this.outlineRT);
|
|
18969
|
+
}
|
|
18970
|
+
} else if (this.time > 0) {
|
|
18971
|
+
this.clearPass.render(renderer, this.idRT, null);
|
|
18972
|
+
this.clearPass.render(renderer, this.outlineRT, null);
|
|
18973
|
+
this.time = 0;
|
|
18974
|
+
}
|
|
18975
|
+
}
|
|
18976
|
+
|
|
18977
|
+
setSize(width, height) {
|
|
18978
|
+
this.blurPass.setSize(width, height);
|
|
18979
|
+
this.idRT.setSize(width, height);
|
|
18980
|
+
const resolution = this.blurPass.resolution;
|
|
18981
|
+
resolution.setBaseSize(width, height);
|
|
18982
|
+
const w = resolution.width,
|
|
18983
|
+
h = resolution.height;
|
|
18984
|
+
this.outlineRT.setSize(w, h);
|
|
18985
|
+
const outlineMaterial = this.outlinePass.fullscreenMaterial;
|
|
18986
|
+
outlineMaterial.setSize(w, h);
|
|
18987
|
+
}
|
|
18988
|
+
|
|
18989
|
+
initialize(renderer, alpha, frameBufferType) {
|
|
18990
|
+
// No need for high precision: the blur pass operates on a mask texture.
|
|
18991
|
+
this.blurPass.initialize(renderer, alpha, THREE__namespace.UnsignedByteType);
|
|
18992
|
+
|
|
18993
|
+
if (frameBufferType !== undefined) {
|
|
18994
|
+
// These passes ignore the buffer type.
|
|
18995
|
+
this.idPass.initialize(renderer, alpha, frameBufferType);
|
|
18996
|
+
this.outlinePass.initialize(renderer, alpha, frameBufferType);
|
|
18997
|
+
}
|
|
18998
|
+
}
|
|
18999
|
+
|
|
19000
|
+
}
|
|
19001
|
+
|
|
19002
|
+
const _excluded$2 = ["selections1", "selections2", "selections3", "selectionLayer", "edgeStrength", "edgeColor1", "edgeColor2", "edgeColor3", "width", "height", "kernelSize"];
|
|
19003
|
+
const Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
19004
|
+
let {
|
|
19005
|
+
selections1 = [],
|
|
19006
|
+
selections2 = [],
|
|
19007
|
+
selections3 = [],
|
|
19008
|
+
selectionLayer = 10,
|
|
19009
|
+
edgeStrength,
|
|
19010
|
+
edgeColor1,
|
|
19011
|
+
edgeColor2,
|
|
19012
|
+
edgeColor3,
|
|
19013
|
+
width,
|
|
19014
|
+
height,
|
|
19015
|
+
kernelSize
|
|
19016
|
+
} = _ref;
|
|
19017
|
+
_objectWithoutProperties(_ref, _excluded$2);
|
|
19018
|
+
|
|
19019
|
+
const invalidate = fiber.useThree(state => state.invalidate);
|
|
19020
|
+
const {
|
|
19021
|
+
scene,
|
|
19022
|
+
camera
|
|
19023
|
+
} = fiber.useThree();
|
|
19024
|
+
const effect = React.useMemo(() => new OutlineEffect(scene, camera, {
|
|
19025
|
+
edgeStrength,
|
|
19026
|
+
edgeColor1,
|
|
19027
|
+
edgeColor2,
|
|
19028
|
+
edgeColor3,
|
|
19029
|
+
width,
|
|
19030
|
+
height,
|
|
19031
|
+
kernelSize
|
|
19032
|
+
}), [scene, camera, edgeStrength, edgeColor1, edgeColor2, edgeColor3, width, height, kernelSize]);
|
|
19033
|
+
React.useEffect(() => {
|
|
19034
|
+
if (selections1) {
|
|
19035
|
+
effect.selections1 = selections1.map(selection => new postprocessing.Selection(selection, selectionLayer));
|
|
19036
|
+
invalidate();
|
|
19037
|
+
return () => {
|
|
19038
|
+
effect.selections1.forEach(selection => selection.clear());
|
|
19039
|
+
effect.selections1 = [];
|
|
19040
|
+
invalidate();
|
|
19041
|
+
};
|
|
19042
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19043
|
+
|
|
19044
|
+
}, [effect, selections1]);
|
|
19045
|
+
React.useEffect(() => {
|
|
19046
|
+
if (selections2) {
|
|
19047
|
+
effect.selections2 = selections2.map(selection => new postprocessing.Selection(selection, selectionLayer));
|
|
19048
|
+
invalidate();
|
|
19049
|
+
return () => {
|
|
19050
|
+
effect.selections2.forEach(selection => selection.clear());
|
|
19051
|
+
effect.selections2 = [];
|
|
19052
|
+
invalidate();
|
|
19053
|
+
};
|
|
19054
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19055
|
+
|
|
19056
|
+
}, [effect, selections2]);
|
|
19057
|
+
React.useEffect(() => {
|
|
19058
|
+
if (selections3) {
|
|
19059
|
+
effect.selections3 = selections3.map(selection => new postprocessing.Selection(selection, selectionLayer));
|
|
19060
|
+
invalidate();
|
|
19061
|
+
return () => {
|
|
19062
|
+
effect.selections3.forEach(selection => selection.clear());
|
|
19063
|
+
effect.selections3 = [];
|
|
19064
|
+
invalidate();
|
|
19065
|
+
};
|
|
19066
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19067
|
+
|
|
19068
|
+
}, [effect, selections3]);
|
|
19069
|
+
React.useEffect(() => {
|
|
19070
|
+
effect.selectionLayer = selectionLayer;
|
|
19071
|
+
invalidate();
|
|
19072
|
+
}, [effect, selectionLayer, invalidate]);
|
|
19073
|
+
return /*#__PURE__*/React.createElement("primitive", {
|
|
19074
|
+
ref: forwardRef,
|
|
19075
|
+
object: effect
|
|
19076
|
+
});
|
|
19077
|
+
});
|
|
19078
|
+
|
|
19079
|
+
const mateNames = ['firstRefMate', 'secondRefMate'];
|
|
19080
|
+
const getMateRefIds = (drawingId, constrId) => {
|
|
19081
|
+
var _drawing$structure$tr;
|
|
19082
|
+
|
|
19083
|
+
const drawing = core.getDrawing(drawingId);
|
|
19084
|
+
const members = (_drawing$structure$tr = drawing.structure.tree[constrId]) == null ? void 0 : _drawing$structure$tr.members;
|
|
19085
|
+
const pRefIds = [];
|
|
19086
|
+
|
|
19087
|
+
if (members && members[mateNames[0]]) {
|
|
19088
|
+
mateNames.forEach(mateName => {
|
|
19089
|
+
var _member$members$;
|
|
19090
|
+
|
|
19091
|
+
const member = members[mateName];
|
|
19092
|
+
const matePath = member == null ? void 0 : (_member$members$ = member.members[0]) == null ? void 0 : _member$members$.members;
|
|
19093
|
+
|
|
19094
|
+
if (matePath && matePath.length > 0) {
|
|
19095
|
+
pRefIds.push(matePath[matePath.length - 1].value);
|
|
19096
|
+
}
|
|
19097
|
+
});
|
|
19098
|
+
}
|
|
19099
|
+
|
|
19100
|
+
if (pRefIds.length === 0) {
|
|
19101
|
+
return;
|
|
19102
|
+
}
|
|
19103
|
+
|
|
19104
|
+
const curNodeId = drawing.structure.currentNode;
|
|
19105
|
+
const curNode = drawing.structure.tree[curNodeId];
|
|
19106
|
+
const curRefIds = (curNode == null ? void 0 : curNode.instances) || (curNode == null ? void 0 : curNode.children) || [];
|
|
19107
|
+
const mateRefIds = [];
|
|
19108
|
+
curRefIds.forEach(id => {
|
|
19109
|
+
var _drawing$structure$tr2, _drawing$structure$tr3;
|
|
19110
|
+
|
|
19111
|
+
const productRefId = ((_drawing$structure$tr2 = drawing.structure.tree[id].members) == null ? void 0 : (_drawing$structure$tr3 = _drawing$structure$tr2.productRef) == null ? void 0 : _drawing$structure$tr3.value) || id;
|
|
19112
|
+
|
|
19113
|
+
if (pRefIds.indexOf(productRefId) !== -1) {
|
|
19114
|
+
mateRefIds.push(id);
|
|
19115
|
+
}
|
|
19116
|
+
});
|
|
19117
|
+
return mateRefIds;
|
|
19118
|
+
};
|
|
19119
|
+
|
|
19120
|
+
const SectionHeader = ({
|
|
19121
|
+
children
|
|
19122
|
+
}) => {
|
|
19123
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
19124
|
+
style: {
|
|
19125
|
+
height: '42px',
|
|
19126
|
+
backgroundColor: '#fafafa',
|
|
19127
|
+
color: 'rgba(0, 0, 0, 0.85)',
|
|
19128
|
+
fontWeight: 500,
|
|
19129
|
+
textAlign: 'left',
|
|
19130
|
+
background: '#fafafa',
|
|
19131
|
+
borderBottom: '1px solid #f0f0f0',
|
|
19132
|
+
padding: '8px 8px',
|
|
19133
|
+
display: 'flex',
|
|
19134
|
+
justifyContent: 'space-between'
|
|
19135
|
+
}
|
|
19136
|
+
}, children);
|
|
19137
|
+
};
|
|
19138
|
+
|
|
19139
|
+
const SolverState = ({
|
|
19140
|
+
drawingId
|
|
19141
|
+
}) => {
|
|
19142
|
+
const rootId = react.useDrawing(drawingId, d => d.structure.root);
|
|
19143
|
+
const solverState = react.useDrawing(drawingId, d => {
|
|
19144
|
+
var _d$structure$tree$roo, _d$structure$tree$roo2, _d$structure$tree$roo3;
|
|
19145
|
+
|
|
19146
|
+
return (_d$structure$tree$roo = d.structure.tree[rootId]) == null ? void 0 : (_d$structure$tree$roo2 = _d$structure$tree$roo.members) == null ? void 0 : (_d$structure$tree$roo3 = _d$structure$tree$roo2.solverState) == null ? void 0 : _d$structure$tree$roo3.value;
|
|
19147
|
+
});
|
|
19148
|
+
const component = solverState === 0 ? /*#__PURE__*/React.createElement(icons.CheckCircleTwoTone, {
|
|
19149
|
+
twoToneColor: "#52c41a"
|
|
19150
|
+
}) : /*#__PURE__*/React.createElement(icons.CloseCircleTwoTone, {
|
|
19151
|
+
twoToneColor: "#eb2f96"
|
|
19152
|
+
});
|
|
19153
|
+
return solverState === undefined ? null : /*#__PURE__*/React.createElement(antd.Tooltip, {
|
|
19154
|
+
title: solverState === 0 ? 'Solved' : 'Not Solved'
|
|
19155
|
+
}, component);
|
|
19156
|
+
};
|
|
19157
|
+
/**
|
|
19158
|
+
* Shows list of 3d constraints which are contained by currentProduct.
|
|
19159
|
+
*
|
|
19160
|
+
* @param drawingId - id of a drawing in which currentProduct will be found.
|
|
19161
|
+
* @returns
|
|
19162
|
+
*/
|
|
19163
|
+
|
|
19164
|
+
|
|
19165
|
+
const Constraints = ({
|
|
19166
|
+
drawingId
|
|
19167
|
+
}) => {
|
|
19168
|
+
const curProdId = react.useDrawing(drawingId, d => d.structure.currentProduct);
|
|
19169
|
+
const prodChildren = useDrawingArr(drawingId, d => {
|
|
19170
|
+
var _d$structure$tree$cur;
|
|
19171
|
+
|
|
19172
|
+
return (_d$structure$tree$cur = d.structure.tree[curProdId]) == null ? void 0 : _d$structure$tree$cur.children;
|
|
19173
|
+
});
|
|
19174
|
+
const constrSetId = React.useMemo(() => {
|
|
19175
|
+
const tree = core.getDrawing(drawingId).structure.tree;
|
|
19176
|
+
return prodChildren.find(childId => tree[childId].class === classcad.CCClasses.CCConstraintSet) || null;
|
|
19177
|
+
}, [prodChildren, drawingId]);
|
|
19178
|
+
const constrSet = react.useDrawing(drawingId, d => d.structure.tree[constrSetId] || null);
|
|
19179
|
+
const constrIds = React.useMemo(() => {
|
|
19180
|
+
return (constrSet == null ? void 0 : constrSet.children) || []; // If there is no any constraint, children doesn't exist in constrSet object
|
|
19181
|
+
}, [constrSet]);
|
|
19182
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
19183
|
+
style: {
|
|
19184
|
+
display: 'flex',
|
|
19185
|
+
flexDirection: 'column',
|
|
19186
|
+
height: '100%'
|
|
19187
|
+
}
|
|
19188
|
+
}, /*#__PURE__*/React.createElement(SectionHeader, null, /*#__PURE__*/React.createElement(FlexRow, null, /*#__PURE__*/React.createElement(antd.Space, null, "Constraints", /*#__PURE__*/React.createElement(SolverState, {
|
|
19189
|
+
drawingId: drawingId
|
|
19190
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
19191
|
+
style: {
|
|
19192
|
+
overflow: 'auto'
|
|
19193
|
+
}
|
|
19194
|
+
}, /*#__PURE__*/React.createElement(List$2, {
|
|
19195
|
+
drawingId: drawingId,
|
|
19196
|
+
constrIds: constrIds
|
|
19197
|
+
})));
|
|
19198
|
+
};
|
|
19199
|
+
|
|
19200
|
+
const Constraint = ({
|
|
19201
|
+
drawingId,
|
|
19202
|
+
constraintId
|
|
19203
|
+
}) => {
|
|
19204
|
+
const hoveredId = react.useDrawing(drawingId, d => {
|
|
19205
|
+
var _d$interaction$hovere;
|
|
19206
|
+
|
|
19207
|
+
return (_d$interaction$hovere = d.interaction.hovered) == null ? void 0 : _d$interaction$hovere.objectId;
|
|
19208
|
+
});
|
|
19209
|
+
const name = react.useDrawing(drawingId, d => {
|
|
19210
|
+
var _d$structure$tree$con;
|
|
19211
|
+
|
|
19212
|
+
return (_d$structure$tree$con = d.structure.tree[constraintId]) == null ? void 0 : _d$structure$tree$con.name;
|
|
19213
|
+
});
|
|
19214
|
+
const isActive = react.useDrawing(drawingId, d => d.plugin.active.feature === constraintId);
|
|
19215
|
+
const isHovered = hoveredId === constraintId;
|
|
19216
|
+
const [rename, setRename] = React.useState(false);
|
|
19217
|
+
const menuItems = useMenuItems$4(drawingId, constraintId, isActive, setRename);
|
|
19218
|
+
const onDoubleClick = React.useCallback(() => {
|
|
19219
|
+
core.getDrawing(drawingId).api.plugin.setActiveFeature(constraintId);
|
|
19220
|
+
}, [drawingId, constraintId]);
|
|
19221
|
+
const onMouseEnter = React.useCallback(() => {
|
|
19222
|
+
const setHovered = core.getDrawing(drawingId).api.interaction.setHovered;
|
|
19223
|
+
const curNodeId = core.getDrawing(drawingId).structure.currentNode;
|
|
19224
|
+
setHovered(core.createInfo({
|
|
19225
|
+
objectId: constraintId,
|
|
19226
|
+
prodRefId: curNodeId
|
|
19227
|
+
}));
|
|
19228
|
+
}, [drawingId, constraintId]);
|
|
19229
|
+
const onMouseLeave = React.useCallback(() => {
|
|
19230
|
+
const setHovered = core.getDrawing(drawingId).api.interaction.setHovered;
|
|
19231
|
+
setHovered(null);
|
|
19232
|
+
}, [drawingId]);
|
|
19233
|
+
const nameComponent = rename ? /*#__PURE__*/React.createElement(NameEdit, {
|
|
19234
|
+
drawingId: drawingId,
|
|
19235
|
+
objId: constraintId,
|
|
19236
|
+
name: name,
|
|
19237
|
+
setEditName: setRename
|
|
19238
|
+
}) : /*#__PURE__*/React.createElement(EntityName, {
|
|
19239
|
+
name: name,
|
|
19240
|
+
underlined: isHovered,
|
|
19241
|
+
strong: isActive
|
|
19242
|
+
});
|
|
19243
|
+
return /*#__PURE__*/React.createElement(HoveredDiv, {
|
|
19244
|
+
hovered: isHovered,
|
|
19245
|
+
bordered: true,
|
|
19246
|
+
onDoubleClick: onDoubleClick,
|
|
19247
|
+
onMouseEnter: onMouseEnter,
|
|
19248
|
+
onMouseLeave: onMouseLeave
|
|
19249
|
+
}, /*#__PURE__*/React.createElement(antd.Space, null, nameComponent), /*#__PURE__*/React.createElement(Menu, {
|
|
19250
|
+
items: menuItems
|
|
19251
|
+
}));
|
|
19252
|
+
}; // TODO: Create external component
|
|
19253
|
+
|
|
18414
19254
|
|
|
18415
|
-
|
|
18416
|
-
|
|
18417
|
-
|
|
18418
|
-
|
|
19255
|
+
const List$2 = ({
|
|
19256
|
+
constrIds,
|
|
19257
|
+
drawingId
|
|
19258
|
+
}) => {
|
|
19259
|
+
return /*#__PURE__*/React.createElement("div", null, constrIds.map(constrId => /*#__PURE__*/React.createElement(Constraint, {
|
|
19260
|
+
key: constrId,
|
|
18419
19261
|
drawingId: drawingId,
|
|
18420
|
-
|
|
18421
|
-
})))
|
|
19262
|
+
constraintId: constrId
|
|
19263
|
+
})));
|
|
18422
19264
|
};
|
|
18423
19265
|
|
|
18424
19266
|
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -19570,10 +20412,11 @@ const Feature = ({
|
|
|
19570
20412
|
drawingId,
|
|
19571
20413
|
featureRefId
|
|
19572
20414
|
}) => {
|
|
19573
|
-
const {
|
|
19574
|
-
|
|
19575
|
-
|
|
19576
|
-
|
|
20415
|
+
const hoveredId = react.useDrawing(drawingId, d => {
|
|
20416
|
+
var _d$interaction$hovere;
|
|
20417
|
+
|
|
20418
|
+
return (_d$interaction$hovere = d.interaction.hovered) == null ? void 0 : _d$interaction$hovere.objectId;
|
|
20419
|
+
});
|
|
19577
20420
|
const featureId = react.useDrawing(drawingId, d => {
|
|
19578
20421
|
var _d$structure$tree$fea2, _d$structure$tree$fea3;
|
|
19579
20422
|
|
|
@@ -19598,15 +20441,18 @@ const Feature = ({
|
|
|
19598
20441
|
}
|
|
19599
20442
|
}, [disabled, featureId, drawingId]);
|
|
19600
20443
|
const onMouseEnter = React.useCallback(() => {
|
|
19601
|
-
|
|
19602
|
-
|
|
20444
|
+
const setHovered = core.getDrawing(drawingId).api.interaction.setHovered;
|
|
20445
|
+
const curNodeId = core.getDrawing(drawingId).structure.currentNode;
|
|
20446
|
+
const curProdId = core.getDrawing(drawingId).structure.currentProduct;
|
|
20447
|
+
setHovered(core.createInfo({
|
|
19603
20448
|
objectId: featureId,
|
|
19604
|
-
|
|
19605
|
-
});
|
|
19606
|
-
}, [
|
|
20449
|
+
prodRefId: curNodeId || curProdId
|
|
20450
|
+
}));
|
|
20451
|
+
}, [drawingId, featureId]);
|
|
19607
20452
|
const onMouseLeave = React.useCallback(() => {
|
|
19608
|
-
|
|
19609
|
-
|
|
20453
|
+
const setHovered = core.getDrawing(drawingId).api.interaction.setHovered;
|
|
20454
|
+
setHovered(null);
|
|
20455
|
+
}, [drawingId]);
|
|
19610
20456
|
const nameComponent = rename ? /*#__PURE__*/React.createElement(NameEdit, {
|
|
19611
20457
|
drawingId: drawingId,
|
|
19612
20458
|
objId: featureId,
|
|
@@ -19649,7 +20495,7 @@ const Feature = ({
|
|
|
19649
20495
|
hovered: isHovered,
|
|
19650
20496
|
bordered: true,
|
|
19651
20497
|
title: String(featureId),
|
|
19652
|
-
|
|
20498
|
+
onDoubleClick: onNameClick,
|
|
19653
20499
|
onMouseEnter: onMouseEnter,
|
|
19654
20500
|
onMouseLeave: onMouseLeave
|
|
19655
20501
|
}, /*#__PURE__*/React.createElement(antd.Space, {
|
|
@@ -19757,7 +20603,7 @@ const Item$1 = ({
|
|
|
19757
20603
|
});
|
|
19758
20604
|
};
|
|
19759
20605
|
|
|
19760
|
-
const List$
|
|
20606
|
+
const List$1 = ({
|
|
19761
20607
|
drawingId
|
|
19762
20608
|
}) => {
|
|
19763
20609
|
const curPartId = react.useDrawing(drawingId, d => d.structure.currentProduct || d.structure.root);
|
|
@@ -19797,7 +20643,7 @@ const FeatureList = ({
|
|
|
19797
20643
|
}) => {
|
|
19798
20644
|
return /*#__PURE__*/React.createElement(FeatureListValidator, {
|
|
19799
20645
|
drawingId: drawingId
|
|
19800
|
-
}, /*#__PURE__*/React.createElement(List$
|
|
20646
|
+
}, /*#__PURE__*/React.createElement(List$1, {
|
|
19801
20647
|
drawingId: drawingId
|
|
19802
20648
|
}));
|
|
19803
20649
|
};
|
|
@@ -19891,42 +20737,46 @@ const NodeTitle = ({
|
|
|
19891
20737
|
}) => {
|
|
19892
20738
|
var _reference$members, _reference$members$pr, _reference$members2, _reference$members2$l;
|
|
19893
20739
|
|
|
19894
|
-
|
|
19895
|
-
|
|
19896
|
-
|
|
19897
|
-
|
|
19898
|
-
|
|
19899
|
-
|
|
20740
|
+
// Let the selector check if this refId is hovered. In that case only the hovered NodeTitle will be rerendered. If we just listen
|
|
20741
|
+
// to the hovered objectId and check later in the code bode if it equals this refId, all NodeTitle's have to be rerendered.
|
|
20742
|
+
const isHovered = react.useDrawing(drawingId, d => {
|
|
20743
|
+
var _d$interaction$hovere;
|
|
20744
|
+
|
|
20745
|
+
return ((_d$interaction$hovere = d.interaction.hovered) == null ? void 0 : _d$interaction$hovere.objectId) === refId;
|
|
20746
|
+
});
|
|
20747
|
+
const selected = react.useDrawing(drawingId, d => d.interaction.selected);
|
|
20748
|
+
const selectedIds = (selected == null ? void 0 : selected.map(sel => sel.objectId)) || [];
|
|
19900
20749
|
const reference = react.useDrawing(drawingId, d => d.structure.tree[refId]);
|
|
19901
20750
|
const referedId = (reference == null ? void 0 : (_reference$members = reference.members) == null ? void 0 : (_reference$members$pr = _reference$members.productId) == null ? void 0 : _reference$members$pr.value) || NOCCID;
|
|
19902
20751
|
const localPath = (reference == null ? void 0 : (_reference$members2 = reference.members) == null ? void 0 : (_reference$members2$l = _reference$members2.localPath) == null ? void 0 : _reference$members2$l.value) || EMPTYSTR;
|
|
19903
20752
|
const referedObj = react.useDrawing(drawingId, d => d.structure.tree[referedId]);
|
|
19904
20753
|
const name = (referedObj == null ? void 0 : referedObj.name) || localPath;
|
|
19905
|
-
const
|
|
19906
|
-
const
|
|
19907
|
-
const isHighlighted = isHovered || isSelected || (selectedId ? hasSelectedChild(drawingId, refId, selectedId) : false);
|
|
20754
|
+
const isSelected = (selectedIds == null ? void 0 : selectedIds.indexOf(refId)) !== -1;
|
|
20755
|
+
const isHighlighted = isHovered || isSelected || ((selectedIds == null ? void 0 : selectedIds.length) === 1 ? hasSelectedChild(drawingId, refId, selectedIds[0]) : false);
|
|
19908
20756
|
const [rename, setRename] = React.useState(false);
|
|
19909
20757
|
const menuItems = useMenuItems$1(drawingId, refId, setRename);
|
|
19910
|
-
const onClick = React.useCallback(
|
|
19911
|
-
|
|
20758
|
+
const onClick = React.useCallback(e => {
|
|
20759
|
+
const select = core.getDrawing(drawingId).api.interaction.select;
|
|
20760
|
+
const multi = e.shiftKey;
|
|
20761
|
+
select(core.createInfo({
|
|
19912
20762
|
objectId: refId,
|
|
19913
|
-
|
|
19914
|
-
|
|
19915
|
-
|
|
19916
|
-
}, [isSelected, refId, onClick_]);
|
|
20763
|
+
prodRefId: refId
|
|
20764
|
+
}), multi);
|
|
20765
|
+
}, [drawingId, refId]);
|
|
19917
20766
|
const onDoubleClick = React.useCallback(() => {
|
|
19918
20767
|
getCADState().api.assemblyTree.startProdEditing(drawingId, refId);
|
|
19919
20768
|
}, [drawingId, refId]);
|
|
19920
20769
|
const onMouseEnter = React.useCallback(() => {
|
|
19921
|
-
|
|
20770
|
+
const setHovered = core.getDrawing(drawingId).api.interaction.setHovered;
|
|
20771
|
+
setHovered(core.createInfo({
|
|
19922
20772
|
objectId: refId,
|
|
19923
|
-
|
|
19924
|
-
|
|
19925
|
-
|
|
19926
|
-
}, [refId, onHover]);
|
|
20773
|
+
prodRefId: refId
|
|
20774
|
+
}));
|
|
20775
|
+
}, [drawingId, refId]);
|
|
19927
20776
|
const onMouseLeave = React.useCallback(() => {
|
|
19928
|
-
|
|
19929
|
-
|
|
20777
|
+
const setHovered = core.getDrawing(drawingId).api.interaction.setHovered;
|
|
20778
|
+
setHovered(null);
|
|
20779
|
+
}, [drawingId]);
|
|
19930
20780
|
const nameComponent = rename ? /*#__PURE__*/React.createElement(NameEdit, {
|
|
19931
20781
|
drawingId: drawingId,
|
|
19932
20782
|
objId: referedId,
|
|
@@ -20003,25 +20853,6 @@ const AssemblyNode = ({
|
|
|
20003
20853
|
return null;
|
|
20004
20854
|
};
|
|
20005
20855
|
|
|
20006
|
-
const SectionHeader = ({
|
|
20007
|
-
children
|
|
20008
|
-
}) => {
|
|
20009
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
20010
|
-
style: {
|
|
20011
|
-
height: '42px',
|
|
20012
|
-
backgroundColor: '#fafafa',
|
|
20013
|
-
color: 'rgba(0, 0, 0, 0.85)',
|
|
20014
|
-
fontWeight: 500,
|
|
20015
|
-
textAlign: 'left',
|
|
20016
|
-
background: '#fafafa',
|
|
20017
|
-
borderBottom: '1px solid #f0f0f0',
|
|
20018
|
-
padding: '8px 8px',
|
|
20019
|
-
display: 'flex',
|
|
20020
|
-
justifyContent: 'space-between'
|
|
20021
|
-
}
|
|
20022
|
-
}, children);
|
|
20023
|
-
};
|
|
20024
|
-
|
|
20025
20856
|
const Skeleton = styled(SkeletonImpl)`
|
|
20026
20857
|
.ant-skeleton-content {
|
|
20027
20858
|
.ant-skeleton-paragraph {
|
|
@@ -20497,12 +21328,13 @@ const Solid = ({
|
|
|
20497
21328
|
drawingId,
|
|
20498
21329
|
solidId
|
|
20499
21330
|
}) => {
|
|
20500
|
-
const {
|
|
20501
|
-
|
|
20502
|
-
|
|
20503
|
-
|
|
20504
|
-
|
|
20505
|
-
|
|
21331
|
+
const hoveredId = react.useDrawing(drawingId, d => {
|
|
21332
|
+
var _d$interaction$hovere;
|
|
21333
|
+
|
|
21334
|
+
return (_d$interaction$hovere = d.interaction.hovered) == null ? void 0 : _d$interaction$hovere.graphicId;
|
|
21335
|
+
});
|
|
21336
|
+
const selected = react.useDrawing(drawingId, d => d.interaction.selected);
|
|
21337
|
+
const selectedIds = (selected == null ? void 0 : selected.map(sel => sel.graphicId)) || [];
|
|
20506
21338
|
const solidOwner = useDrawingCCId(drawingId, d => {
|
|
20507
21339
|
var _d$graphic$containers;
|
|
20508
21340
|
|
|
@@ -20510,26 +21342,44 @@ const Solid = ({
|
|
|
20510
21342
|
});
|
|
20511
21343
|
const ccSolid = react.useDrawing(drawingId, d => d.structure.tree[solidOwner]);
|
|
20512
21344
|
const isHovered = hoveredId === solidId;
|
|
20513
|
-
const isSelected =
|
|
21345
|
+
const isSelected = (selectedIds == null ? void 0 : selectedIds.indexOf(solidId)) !== -1;
|
|
20514
21346
|
const isHighlighted = isHovered || isSelected;
|
|
20515
21347
|
const [rename, setRename] = React.useState(false);
|
|
20516
|
-
const onClick = React.useCallback(
|
|
20517
|
-
|
|
20518
|
-
|
|
20519
|
-
|
|
20520
|
-
|
|
20521
|
-
|
|
20522
|
-
|
|
21348
|
+
const onClick = React.useCallback(e => {
|
|
21349
|
+
var _getDrawing$structure;
|
|
21350
|
+
|
|
21351
|
+
const select = core.getDrawing(drawingId).api.interaction.select;
|
|
21352
|
+
const multi = e.shiftKey;
|
|
21353
|
+
const objectId = core.getDrawing(drawingId).geometry.cache[solidId].container.ownerId;
|
|
21354
|
+
const curNodeId = core.getDrawing(drawingId).structure.currentNode;
|
|
21355
|
+
const curProdId = core.getDrawing(drawingId).structure.currentProduct;
|
|
21356
|
+
const isPart = classcad.ccUtils.base.isA(((_getDrawing$structure = core.getDrawing(drawingId).structure.tree[curProdId]) == null ? void 0 : _getDrawing$structure.class) || '', classcad.CCClasses.CCPart);
|
|
21357
|
+
select(core.createInfo({
|
|
21358
|
+
objectId,
|
|
21359
|
+
graphicId: solidId,
|
|
21360
|
+
containerId: solidId,
|
|
21361
|
+
prodRefId: isPart ? curProdId : curNodeId
|
|
21362
|
+
}), multi);
|
|
21363
|
+
}, [drawingId, solidId]);
|
|
20523
21364
|
const onMouseEnter = React.useCallback(() => {
|
|
20524
|
-
|
|
20525
|
-
|
|
20526
|
-
|
|
20527
|
-
|
|
20528
|
-
|
|
20529
|
-
|
|
21365
|
+
var _getDrawing$structure2;
|
|
21366
|
+
|
|
21367
|
+
const setHovered = core.getDrawing(drawingId).api.interaction.setHovered;
|
|
21368
|
+
const objectId = core.getDrawing(drawingId).geometry.cache[solidId].container.ownerId;
|
|
21369
|
+
const curNodeId = core.getDrawing(drawingId).structure.currentNode;
|
|
21370
|
+
const curProdId = core.getDrawing(drawingId).structure.currentProduct;
|
|
21371
|
+
const isPart = classcad.ccUtils.base.isA(((_getDrawing$structure2 = core.getDrawing(drawingId).structure.tree[curProdId]) == null ? void 0 : _getDrawing$structure2.class) || '', classcad.CCClasses.CCPart);
|
|
21372
|
+
setHovered(core.createInfo({
|
|
21373
|
+
objectId,
|
|
21374
|
+
graphicId: solidId,
|
|
21375
|
+
containerId: solidId,
|
|
21376
|
+
prodRefId: isPart ? curProdId : curNodeId
|
|
21377
|
+
}));
|
|
21378
|
+
}, [drawingId, solidId]);
|
|
20530
21379
|
const onMouseLeave = React.useCallback(() => {
|
|
20531
|
-
|
|
20532
|
-
|
|
21380
|
+
const setHovered = core.getDrawing(drawingId).api.interaction.setHovered;
|
|
21381
|
+
setHovered(null);
|
|
21382
|
+
}, [drawingId]);
|
|
20533
21383
|
const menuItems = useMenuItems(setRename);
|
|
20534
21384
|
return /*#__PURE__*/React.createElement(HoveredDiv, {
|
|
20535
21385
|
hovered: isHighlighted,
|
|
@@ -20558,7 +21408,7 @@ const Solid = ({
|
|
|
20558
21408
|
}; // TODO: Create external component
|
|
20559
21409
|
|
|
20560
21410
|
|
|
20561
|
-
const List
|
|
21411
|
+
const List = ({
|
|
20562
21412
|
solidsIds,
|
|
20563
21413
|
drawingId
|
|
20564
21414
|
}) => {
|
|
@@ -20590,7 +21440,7 @@ const Solids = ({
|
|
|
20590
21440
|
style: {
|
|
20591
21441
|
overflow: 'auto'
|
|
20592
21442
|
}
|
|
20593
|
-
}, /*#__PURE__*/React.createElement(List
|
|
21443
|
+
}, /*#__PURE__*/React.createElement(List, {
|
|
20594
21444
|
drawingId: drawingId,
|
|
20595
21445
|
solidsIds: solidIds
|
|
20596
21446
|
})));
|
|
@@ -21225,8 +22075,6 @@ const ViewPlugButtons = ({
|
|
|
21225
22075
|
}));
|
|
21226
22076
|
};
|
|
21227
22077
|
|
|
21228
|
-
const InteractionContext = /*#__PURE__*/React.createContext({});
|
|
21229
|
-
|
|
21230
22078
|
const EditDrawing = ({
|
|
21231
22079
|
drawingId,
|
|
21232
22080
|
children
|
|
@@ -21325,31 +22173,17 @@ const Header = ({
|
|
|
21325
22173
|
*
|
|
21326
22174
|
* @param drawingId - id of an existing drawing.
|
|
21327
22175
|
* @param Menu - you can pass custom file menu which will be shown at the left top corner.
|
|
21328
|
-
* @param hoveredId - id of a currently hovered object.
|
|
21329
|
-
* @param selectedId - id of a currently selected object.
|
|
21330
|
-
* @param onHover - callback for hovering features / assembly nodes / solids / constraints.
|
|
21331
|
-
* @param onClick - callback for clicking on assembly nodes / solids.
|
|
21332
22176
|
*/
|
|
21333
22177
|
|
|
21334
22178
|
|
|
21335
22179
|
const Drawing = ({
|
|
21336
22180
|
drawingId,
|
|
21337
22181
|
Menu,
|
|
21338
|
-
children
|
|
21339
|
-
hoveredId,
|
|
21340
|
-
selectedId,
|
|
21341
|
-
onHover,
|
|
21342
|
-
onClick
|
|
22182
|
+
children
|
|
21343
22183
|
}) => {
|
|
21344
22184
|
React.useEffect(() => {
|
|
21345
22185
|
return () => getCADState().api.assemblyTree.clearProdStack();
|
|
21346
22186
|
}, [drawingId]);
|
|
21347
|
-
const contextValue = React.useMemo(() => ({
|
|
21348
|
-
hoveredId,
|
|
21349
|
-
selectedId,
|
|
21350
|
-
onHover,
|
|
21351
|
-
onClick
|
|
21352
|
-
}), [hoveredId, selectedId, onHover, onClick]);
|
|
21353
22187
|
return /*#__PURE__*/React.createElement("div", {
|
|
21354
22188
|
style: {
|
|
21355
22189
|
height: '100%',
|
|
@@ -21364,11 +22198,9 @@ const Drawing = ({
|
|
|
21364
22198
|
style: {
|
|
21365
22199
|
margin: '0'
|
|
21366
22200
|
}
|
|
21367
|
-
}), /*#__PURE__*/React.createElement(
|
|
21368
|
-
value: contextValue
|
|
21369
|
-
}, /*#__PURE__*/React.createElement(EditDrawing, {
|
|
22201
|
+
}), /*#__PURE__*/React.createElement(EditDrawing, {
|
|
21370
22202
|
drawingId: drawingId
|
|
21371
|
-
}, children)
|
|
22203
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
21372
22204
|
style: {
|
|
21373
22205
|
position: 'absolute',
|
|
21374
22206
|
bottom: '4px',
|
|
@@ -21379,173 +22211,6 @@ const Drawing = ({
|
|
|
21379
22211
|
})), /*#__PURE__*/React.createElement(BlankDiv, null));
|
|
21380
22212
|
};
|
|
21381
22213
|
|
|
21382
|
-
const mateNames = ['firstRefMate', 'secondRefMate'];
|
|
21383
|
-
|
|
21384
|
-
const getMateRefIds = (drawingId, constrId) => {
|
|
21385
|
-
var _drawing$structure$tr;
|
|
21386
|
-
|
|
21387
|
-
const drawing = core.getDrawing(drawingId);
|
|
21388
|
-
const members = (_drawing$structure$tr = drawing.structure.tree[constrId]) == null ? void 0 : _drawing$structure$tr.members;
|
|
21389
|
-
const pRefIds = [];
|
|
21390
|
-
|
|
21391
|
-
if (members && members[mateNames[0]]) {
|
|
21392
|
-
mateNames.forEach(mateName => {
|
|
21393
|
-
var _member$members$;
|
|
21394
|
-
|
|
21395
|
-
const member = members[mateName];
|
|
21396
|
-
const matePath = member == null ? void 0 : (_member$members$ = member.members[0]) == null ? void 0 : _member$members$.members;
|
|
21397
|
-
|
|
21398
|
-
if (matePath && matePath.length > 0) {
|
|
21399
|
-
pRefIds.push(matePath[matePath.length - 1].value);
|
|
21400
|
-
}
|
|
21401
|
-
});
|
|
21402
|
-
}
|
|
21403
|
-
|
|
21404
|
-
if (pRefIds.length === 0) {
|
|
21405
|
-
return;
|
|
21406
|
-
}
|
|
21407
|
-
|
|
21408
|
-
const curNodeId = drawing.structure.currentNode;
|
|
21409
|
-
const curNode = drawing.structure.tree[curNodeId];
|
|
21410
|
-
const curRefIds = (curNode == null ? void 0 : curNode.instances) || (curNode == null ? void 0 : curNode.children) || [];
|
|
21411
|
-
const mateRefIds = [];
|
|
21412
|
-
curRefIds.forEach(id => {
|
|
21413
|
-
var _drawing$structure$tr2, _drawing$structure$tr3;
|
|
21414
|
-
|
|
21415
|
-
const productRefId = ((_drawing$structure$tr2 = drawing.structure.tree[id].members) == null ? void 0 : (_drawing$structure$tr3 = _drawing$structure$tr2.productRef) == null ? void 0 : _drawing$structure$tr3.value) || id;
|
|
21416
|
-
|
|
21417
|
-
if (pRefIds.indexOf(productRefId) !== -1) {
|
|
21418
|
-
mateRefIds.push(id);
|
|
21419
|
-
}
|
|
21420
|
-
});
|
|
21421
|
-
return mateRefIds;
|
|
21422
|
-
};
|
|
21423
|
-
|
|
21424
|
-
const SolverState = ({
|
|
21425
|
-
drawingId
|
|
21426
|
-
}) => {
|
|
21427
|
-
const rootId = react.useDrawing(drawingId, d => d.structure.root);
|
|
21428
|
-
const solverState = react.useDrawing(drawingId, d => {
|
|
21429
|
-
var _d$structure$tree$roo, _d$structure$tree$roo2, _d$structure$tree$roo3;
|
|
21430
|
-
|
|
21431
|
-
return (_d$structure$tree$roo = d.structure.tree[rootId]) == null ? void 0 : (_d$structure$tree$roo2 = _d$structure$tree$roo.members) == null ? void 0 : (_d$structure$tree$roo3 = _d$structure$tree$roo2.solverState) == null ? void 0 : _d$structure$tree$roo3.value;
|
|
21432
|
-
});
|
|
21433
|
-
const component = solverState === 0 ? /*#__PURE__*/React.createElement(icons.CheckCircleTwoTone, {
|
|
21434
|
-
twoToneColor: "#52c41a"
|
|
21435
|
-
}) : /*#__PURE__*/React.createElement(icons.CloseCircleTwoTone, {
|
|
21436
|
-
twoToneColor: "#eb2f96"
|
|
21437
|
-
});
|
|
21438
|
-
return solverState === undefined ? null : /*#__PURE__*/React.createElement(antd.Tooltip, {
|
|
21439
|
-
title: solverState === 0 ? 'Solved' : 'Not Solved'
|
|
21440
|
-
}, component);
|
|
21441
|
-
};
|
|
21442
|
-
/**
|
|
21443
|
-
* Shows list of 3d constraints which are contained by currentProduct.
|
|
21444
|
-
*
|
|
21445
|
-
* @param drawingId - id of a drawing in which currentProduct will be found.
|
|
21446
|
-
* @returns
|
|
21447
|
-
*/
|
|
21448
|
-
|
|
21449
|
-
|
|
21450
|
-
const Constraints = ({
|
|
21451
|
-
drawingId
|
|
21452
|
-
}) => {
|
|
21453
|
-
const curProdId = react.useDrawing(drawingId, d => d.structure.currentProduct);
|
|
21454
|
-
const prodChildren = useDrawingArr(drawingId, d => {
|
|
21455
|
-
var _d$structure$tree$cur;
|
|
21456
|
-
|
|
21457
|
-
return (_d$structure$tree$cur = d.structure.tree[curProdId]) == null ? void 0 : _d$structure$tree$cur.children;
|
|
21458
|
-
});
|
|
21459
|
-
const constrSetId = React.useMemo(() => {
|
|
21460
|
-
const tree = core.getDrawing(drawingId).structure.tree;
|
|
21461
|
-
return prodChildren.find(childId => tree[childId].class === classcad.CCClasses.CCConstraintSet) || null;
|
|
21462
|
-
}, [prodChildren, drawingId]);
|
|
21463
|
-
const constrSet = react.useDrawing(drawingId, d => d.structure.tree[constrSetId] || null);
|
|
21464
|
-
const constrIds = React.useMemo(() => {
|
|
21465
|
-
return (constrSet == null ? void 0 : constrSet.children) || []; // If there is no any constraint, children doesn't exist in constrSet object
|
|
21466
|
-
}, [constrSet]);
|
|
21467
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
21468
|
-
style: {
|
|
21469
|
-
display: 'flex',
|
|
21470
|
-
flexDirection: 'column',
|
|
21471
|
-
height: '100%'
|
|
21472
|
-
}
|
|
21473
|
-
}, /*#__PURE__*/React.createElement(SectionHeader, null, /*#__PURE__*/React.createElement(FlexRow, null, /*#__PURE__*/React.createElement(antd.Space, null, "Constraints", /*#__PURE__*/React.createElement(SolverState, {
|
|
21474
|
-
drawingId: drawingId
|
|
21475
|
-
})))), /*#__PURE__*/React.createElement("div", {
|
|
21476
|
-
style: {
|
|
21477
|
-
overflow: 'auto'
|
|
21478
|
-
}
|
|
21479
|
-
}, /*#__PURE__*/React.createElement(List, {
|
|
21480
|
-
drawingId: drawingId,
|
|
21481
|
-
constrIds: constrIds
|
|
21482
|
-
})));
|
|
21483
|
-
};
|
|
21484
|
-
|
|
21485
|
-
const Constraint = ({
|
|
21486
|
-
drawingId,
|
|
21487
|
-
constraintId
|
|
21488
|
-
}) => {
|
|
21489
|
-
const {
|
|
21490
|
-
hoveredId,
|
|
21491
|
-
onHover
|
|
21492
|
-
} = React.useContext(InteractionContext);
|
|
21493
|
-
const name = react.useDrawing(drawingId, d => {
|
|
21494
|
-
var _d$structure$tree$con;
|
|
21495
|
-
|
|
21496
|
-
return (_d$structure$tree$con = d.structure.tree[constraintId]) == null ? void 0 : _d$structure$tree$con.name;
|
|
21497
|
-
});
|
|
21498
|
-
const isActive = react.useDrawing(drawingId, d => d.plugin.active.feature === constraintId);
|
|
21499
|
-
const isHovered = hoveredId === constraintId;
|
|
21500
|
-
const [rename, setRename] = React.useState(false);
|
|
21501
|
-
const menuItems = useMenuItems$4(drawingId, constraintId, isActive, setRename);
|
|
21502
|
-
const onNameClick = React.useCallback(() => {
|
|
21503
|
-
core.getDrawing(drawingId).api.plugin.setActiveFeature(constraintId);
|
|
21504
|
-
}, [drawingId, constraintId]);
|
|
21505
|
-
const onMouseEnter = React.useCallback(() => {
|
|
21506
|
-
const mateRefIds = getMateRefIds(drawingId, constraintId);
|
|
21507
|
-
onHover && onHover({
|
|
21508
|
-
objectId: constraintId,
|
|
21509
|
-
highlightedIds: mateRefIds,
|
|
21510
|
-
type: 'Constraint'
|
|
21511
|
-
});
|
|
21512
|
-
}, [drawingId, constraintId, onHover]);
|
|
21513
|
-
const onMouseLeave = React.useCallback(() => {
|
|
21514
|
-
onHover && onHover(null);
|
|
21515
|
-
}, [onHover]);
|
|
21516
|
-
const nameComponent = rename ? /*#__PURE__*/React.createElement(NameEdit, {
|
|
21517
|
-
drawingId: drawingId,
|
|
21518
|
-
objId: constraintId,
|
|
21519
|
-
name: name,
|
|
21520
|
-
setEditName: setRename
|
|
21521
|
-
}) : /*#__PURE__*/React.createElement(EntityName, {
|
|
21522
|
-
name: name,
|
|
21523
|
-
underlined: isHovered,
|
|
21524
|
-
strong: isActive
|
|
21525
|
-
});
|
|
21526
|
-
return /*#__PURE__*/React.createElement(HoveredDiv, {
|
|
21527
|
-
hovered: isHovered,
|
|
21528
|
-
bordered: true,
|
|
21529
|
-
onClick: onNameClick,
|
|
21530
|
-
onMouseEnter: onMouseEnter,
|
|
21531
|
-
onMouseLeave: onMouseLeave
|
|
21532
|
-
}, /*#__PURE__*/React.createElement(antd.Space, null, nameComponent), /*#__PURE__*/React.createElement(Menu, {
|
|
21533
|
-
items: menuItems
|
|
21534
|
-
}));
|
|
21535
|
-
}; // TODO: Create external component
|
|
21536
|
-
|
|
21537
|
-
|
|
21538
|
-
const List = ({
|
|
21539
|
-
constrIds,
|
|
21540
|
-
drawingId
|
|
21541
|
-
}) => {
|
|
21542
|
-
return /*#__PURE__*/React.createElement("div", null, constrIds.map(constrId => /*#__PURE__*/React.createElement(Constraint, {
|
|
21543
|
-
key: constrId,
|
|
21544
|
-
drawingId: drawingId,
|
|
21545
|
-
constraintId: constrId
|
|
21546
|
-
})));
|
|
21547
|
-
};
|
|
21548
|
-
|
|
21549
22214
|
exports.Boolean = index$x;
|
|
21550
22215
|
exports.BoundingBoxInfo = index$a;
|
|
21551
22216
|
exports.Box = index$u;
|
|
@@ -21575,6 +22240,7 @@ exports.Menu = Menu;
|
|
|
21575
22240
|
exports.Messages = Messages;
|
|
21576
22241
|
exports.Mirror = index$h;
|
|
21577
22242
|
exports.ModelTree = ModelTree;
|
|
22243
|
+
exports.Outline = Outline;
|
|
21578
22244
|
exports.Parallel = index$2;
|
|
21579
22245
|
exports.Planar = index$3;
|
|
21580
22246
|
exports.ProductManagement = index;
|
|
@@ -21582,6 +22248,7 @@ exports.Readfile = Readfile$1;
|
|
|
21582
22248
|
exports.Revolute = index$5;
|
|
21583
22249
|
exports.Revolve = index$v;
|
|
21584
22250
|
exports.Rotate = index$n;
|
|
22251
|
+
exports.SelectedMateObj = SelectedMateObj;
|
|
21585
22252
|
exports.SideBar = SideBar;
|
|
21586
22253
|
exports.Sketch = index$f;
|
|
21587
22254
|
exports.Slice = index$l;
|
|
@@ -21595,10 +22262,15 @@ exports.Translate = index$o;
|
|
|
21595
22262
|
exports.ViewOptionButtons = ViewOptionButtons;
|
|
21596
22263
|
exports.ViewPlugButtons = ViewPlugButtons;
|
|
21597
22264
|
exports.WorkAxis = index$e;
|
|
22265
|
+
exports.WorkAxisObj = WorkAxisObj;
|
|
21598
22266
|
exports.WorkCoordSystem = index$b;
|
|
22267
|
+
exports.WorkCoordSystemObj = WorkCoordSystemObj;
|
|
21599
22268
|
exports.WorkPlane = index$d;
|
|
22269
|
+
exports.WorkPlaneObj = WorkPlaneObj;
|
|
21600
22270
|
exports.WorkPoint = index$c;
|
|
22271
|
+
exports.WorkPointObj = WorkPointObj;
|
|
21601
22272
|
exports.getCADState = getCADState;
|
|
22273
|
+
exports.getMateRefIds = getMateRefIds;
|
|
21602
22274
|
exports.useAllObjects = useAllObjects;
|
|
21603
22275
|
exports.useCADStore = useCADStore;
|
|
21604
22276
|
exports.useHasPending = useHasPending;
|