@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.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useDrawing, CameraHelper, useBuerli, usePlugin, useEmbeddedPlugin, GlobalTransform, findBuerliGeometry, BuerliGeometry, usePluginExists, useFeaturePluginDef } from '@buerli.io/react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useMemo, forwardRef, useState, useCallback, useEffect, useRef, memo, useContext, useReducer } from 'react';
|
|
4
|
-
import { getDrawing, createGraphicItem, MemberType, MathUtils, api, getPlugin, BuerliScope, GraphicType, EntityTypes, Measure, MeasureResultType } from '@buerli.io/core';
|
|
4
|
+
import { getDrawing, createGraphicItem, MemberType, MathUtils, api, getPlugin, BuerliScope, createInfo, GraphicType, solidFilter, lineSegmentsFilter, loopFilter, planeFilter, EntityTypes, Measure, MeasureResultType, pointFilter, circleFilter, arcFilter, lineFilter, arcCircleFilter, meshFilter } from '@buerli.io/core';
|
|
5
5
|
import { ccUtils, CCClasses, ccAPI, ReorientedType, FlipType, BooleanOperationType, ExtrusionType, ChamferType, WorkAxisType, WorkPlaneType, WorkPointType, WorkCoordSystemType, DataType } from '@buerli.io/classcad';
|
|
6
6
|
import * as THREE from 'three';
|
|
7
7
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
@@ -18,13 +18,14 @@ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
18
18
|
import Tooltip from 'antd/lib/tooltip';
|
|
19
19
|
import RadioGroupImpl from 'antd/lib/radio/group';
|
|
20
20
|
import RadioButtonImpl from 'antd/lib/radio/radioButton';
|
|
21
|
-
import { Menu as Menu$1, Dropdown, Input, Typography, Space, Tag, Table, Tabs, Divider as Divider$1, Button,
|
|
21
|
+
import { Menu as Menu$1, Dropdown, Input, Typography, Space, Tag, Table, Tabs, Divider as Divider$1, Button, Tooltip as Tooltip$1, Badge, Modal, Skeleton as Skeleton$1 } from 'antd';
|
|
22
22
|
import AntdButton from 'antd/lib/button';
|
|
23
23
|
import guid from 'uuid';
|
|
24
24
|
import shallow from 'zustand/shallow';
|
|
25
25
|
import { Geometry } from 'three-stdlib';
|
|
26
26
|
import SelectImpl from 'antd/lib/select';
|
|
27
27
|
import { basename, extname } from 'path-browserify';
|
|
28
|
+
import { Pass, Selection, Effect, Resolution, KernelSize, BlendFunction, ClearPass, ShaderPass, KawaseBlurPass } from 'postprocessing';
|
|
28
29
|
import { useUID } from 'react-uid';
|
|
29
30
|
import SkeletonImpl from 'antd/lib/skeleton/Skeleton';
|
|
30
31
|
import { SortableContainer, SortableElement } from 'react-sortable-hoc';
|
|
@@ -218,7 +219,7 @@ function getGlobalToLocalMatrix(drawingId, objId) {
|
|
|
218
219
|
return matrix.invert();
|
|
219
220
|
} // TODO: !!Remove
|
|
220
221
|
function convertToVector(point) {
|
|
221
|
-
return new THREE.Vector3(point.value.x, point.value.y, point.value.z);
|
|
222
|
+
return point ? new THREE.Vector3(point.value.x, point.value.y, point.value.z) : new THREE.Vector3();
|
|
222
223
|
}
|
|
223
224
|
function convertToArray(point) {
|
|
224
225
|
return [point.value.x, point.value.y, point.value.z];
|
|
@@ -381,7 +382,12 @@ function findObject(drawingId, id, unrollRefs = false) {
|
|
|
381
382
|
const allContainers = Object.getOwnPropertyNames(cache).map(n => Number(n)).sort((a, b) => b - a);
|
|
382
383
|
const visibleContainers = drawing.structure.visibleContainers;
|
|
383
384
|
const notVisibleContainers = visibleContainers && allContainers.filter(c => visibleContainers.indexOf(c) < 0);
|
|
384
|
-
const sortedContainerIds = visibleContainers && notVisibleContainers && visibleContainers.concat(notVisibleContainers);
|
|
385
|
+
const sortedContainerIds = visibleContainers && notVisibleContainers && visibleContainers.concat(notVisibleContainers);
|
|
386
|
+
|
|
387
|
+
if (cache[graphicId]) {
|
|
388
|
+
return cache[graphicId];
|
|
389
|
+
} // TODO: also search for containers (i.e. solid graphics)
|
|
390
|
+
|
|
385
391
|
|
|
386
392
|
for (const contId of sortedContainerIds) {
|
|
387
393
|
const cont = cache[contId];
|
|
@@ -602,15 +608,11 @@ const NumOrExpr = ({
|
|
|
602
608
|
expr: typeof valOrExpr === 'string' ? valOrExpr : '',
|
|
603
609
|
onChange: onChange,
|
|
604
610
|
onUpdate: onUpdate,
|
|
605
|
-
isExprState: [isExpr, setIsExpr],
|
|
606
611
|
defaultOpenState: [defaultOpen, setDefaultOpen]
|
|
607
612
|
}), !isExpr && /*#__PURE__*/React__default.createElement(NumInput$1, {
|
|
608
|
-
value:
|
|
609
|
-
defaultV: getDefNumValue(drawingId, defaults),
|
|
613
|
+
value: getDefNumValue(drawingId, defaults),
|
|
610
614
|
onChange: onChange,
|
|
611
615
|
onUpdate: onUpdate,
|
|
612
|
-
isExprState: [isExpr, setIsExpr],
|
|
613
|
-
defaultOpenState: [defaultOpen, setDefaultOpen],
|
|
614
616
|
allowExpr: allowExpr
|
|
615
617
|
})), allowExpr && /*#__PURE__*/React__default.createElement("div", {
|
|
616
618
|
style: {
|
|
@@ -629,8 +631,7 @@ const NumOrExpr = ({
|
|
|
629
631
|
const NumInput$1 = ({
|
|
630
632
|
onChange,
|
|
631
633
|
onUpdate,
|
|
632
|
-
value
|
|
633
|
-
defaultV
|
|
634
|
+
value
|
|
634
635
|
}) => {
|
|
635
636
|
const {
|
|
636
637
|
Input
|
|
@@ -641,8 +642,10 @@ const NumInput$1 = ({
|
|
|
641
642
|
|
|
642
643
|
if (!isNaN(float)) {
|
|
643
644
|
onChange(float); // Call onChange of parent component
|
|
645
|
+
} else {
|
|
646
|
+
onChange(value);
|
|
644
647
|
}
|
|
645
|
-
}, [sValue, onChange]);
|
|
648
|
+
}, [sValue, onChange, value]);
|
|
646
649
|
React__default.useEffect(() => {
|
|
647
650
|
setSValue(String(value));
|
|
648
651
|
}, [value]);
|
|
@@ -650,19 +653,19 @@ const NumInput$1 = ({
|
|
|
650
653
|
target
|
|
651
654
|
}) => {
|
|
652
655
|
const val = target.value;
|
|
653
|
-
const reg = /^-?(\d
|
|
656
|
+
const reg = /^-?(\d*(\.\d*)?)?$/; // Regexpr for float number
|
|
654
657
|
|
|
655
|
-
if (reg.test(val) || val === '
|
|
656
|
-
setSValue(val
|
|
658
|
+
if (reg.test(val) || val === '') {
|
|
659
|
+
setSValue(val); // Remove extra zeros from the begin
|
|
657
660
|
}
|
|
658
661
|
}, []);
|
|
659
662
|
const onBlur = React__default.useCallback(() => {
|
|
660
663
|
const float = parseFloat(sValue);
|
|
661
664
|
|
|
662
665
|
if (isNaN(float)) {
|
|
663
|
-
setSValue(String(
|
|
666
|
+
setSValue(String(value));
|
|
664
667
|
}
|
|
665
|
-
}, [
|
|
668
|
+
}, [value, sValue]);
|
|
666
669
|
return /*#__PURE__*/React__default.createElement(Input, {
|
|
667
670
|
style: {
|
|
668
671
|
paddingRight: '18px'
|
|
@@ -2271,130 +2274,101 @@ var index$y = /*#__PURE__*/Object.freeze({
|
|
|
2271
2274
|
useDimensionSetId: useDimensionSetId
|
|
2272
2275
|
});
|
|
2273
2276
|
|
|
2274
|
-
function
|
|
2275
|
-
|
|
2276
|
-
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; }
|
|
2277
|
-
/**
|
|
2278
|
-
* Implies the following data structure:
|
|
2279
|
-
* data: {
|
|
2280
|
-
* matePath: ObjectID[],
|
|
2281
|
-
* csys: IStructureObject,
|
|
2282
|
-
* flip: FlipType,
|
|
2283
|
-
* reoriented: ReorientedType,
|
|
2284
|
-
* }
|
|
2285
|
-
*/
|
|
2286
|
-
|
|
2287
|
-
const MateScope = 'HLConstraintScope';
|
|
2288
|
-
const createMateItem = (matePath, csys, flip, reoriented) => {
|
|
2289
|
-
return {
|
|
2290
|
-
id: `Mate|${matePath.toString()}|${csys.id}|(${flip},${reoriented})`,
|
|
2291
|
-
scope: MateScope,
|
|
2292
|
-
data: {
|
|
2293
|
-
matePath,
|
|
2294
|
-
csys,
|
|
2295
|
-
flip,
|
|
2296
|
-
reoriented
|
|
2297
|
-
},
|
|
2298
|
-
label: 'MATE'
|
|
2299
|
-
};
|
|
2300
|
-
};
|
|
2301
|
-
|
|
2302
|
-
function useIsHovered$1(drawingId, matePath, object) {
|
|
2303
|
-
const hoveredItem = useDrawing(drawingId, d => {
|
|
2304
|
-
const activeId = d.selection.active;
|
|
2305
|
-
|
|
2306
|
-
if (!activeId) {
|
|
2307
|
-
return undefined;
|
|
2308
|
-
}
|
|
2277
|
+
function useIdParam(drawingId, objId, memberName) {
|
|
2278
|
+
var _getDrawing$structure;
|
|
2309
2279
|
|
|
2310
|
-
|
|
2280
|
+
const member = (_getDrawing$structure = getDrawing(drawingId).structure.tree[objId].members) == null ? void 0 : _getDrawing$structure[memberName];
|
|
2281
|
+
const [userValue, setUserValue] = React__default.useState(member.value);
|
|
2282
|
+
React__default.useEffect(() => {
|
|
2283
|
+
setUserValue(member.value);
|
|
2284
|
+
}, [member]);
|
|
2285
|
+
const defaults = React__default.useMemo(() => {
|
|
2286
|
+
return member.value;
|
|
2287
|
+
}, [member]);
|
|
2288
|
+
const isChanged = React__default.useCallback(() => {
|
|
2289
|
+
return userValue !== defaults;
|
|
2290
|
+
}, [defaults, userValue]);
|
|
2291
|
+
return useParam({
|
|
2292
|
+
userValue,
|
|
2293
|
+
setUserValue,
|
|
2294
|
+
defaults,
|
|
2295
|
+
isChanged
|
|
2311
2296
|
});
|
|
2312
|
-
if (!hoveredItem) return false;
|
|
2313
|
-
return createMateItem(matePath, object, FlipType.FLIP_Z, ReorientedType.REORIENTED_0).id === hoveredItem.id;
|
|
2314
2297
|
}
|
|
2315
2298
|
|
|
2316
|
-
function
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
const
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
}
|
|
2327
|
-
return {
|
|
2328
|
-
onPointerOut,
|
|
2329
|
-
onPointerOver
|
|
2330
|
-
};
|
|
2299
|
+
function refIdChanged(refId, defId, tree) {
|
|
2300
|
+
if (refId && tree[refId] === undefined) {
|
|
2301
|
+
// The graphicId is stored in userValue
|
|
2302
|
+
const {
|
|
2303
|
+
graphicId
|
|
2304
|
+
} = getGraphicId(tree, defId);
|
|
2305
|
+
return refId !== graphicId;
|
|
2306
|
+
} else {
|
|
2307
|
+
// The id of tree obj is stored in userValue
|
|
2308
|
+
return refId !== defId;
|
|
2309
|
+
}
|
|
2331
2310
|
}
|
|
2332
2311
|
|
|
2333
|
-
function
|
|
2334
|
-
const
|
|
2335
|
-
|
|
2336
|
-
const item = createMateItem(matePath, csys, FlipType.FLIP_Z, ReorientedType.REORIENTED_0);
|
|
2337
|
-
selApi.isItemSelected(item) ? selApi.unselect(item) : selApi.select(item);
|
|
2338
|
-
e.stopPropagation();
|
|
2339
|
-
}, [selApi, matePath, csys]);
|
|
2340
|
-
return {
|
|
2341
|
-
onClick
|
|
2342
|
-
};
|
|
2343
|
-
} // Returns true if object in tree is currently selected in active selection.
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
function useIsSelected$1(drawingId, matePath, csys) {
|
|
2347
|
-
// Re-render if selectedItems is changed
|
|
2348
|
-
const selectedItems = useDrawing(drawingId, d => {
|
|
2349
|
-
const activeId = d.selection.active;
|
|
2350
|
-
|
|
2351
|
-
if (!activeId) {
|
|
2352
|
-
return undefined;
|
|
2353
|
-
}
|
|
2312
|
+
function useRefsParam(drawingId, objId, memberName) {
|
|
2313
|
+
const member = useDrawing(drawingId, d => {
|
|
2314
|
+
var _d$structure$tree$obj;
|
|
2354
2315
|
|
|
2355
|
-
return d.
|
|
2316
|
+
return (_d$structure$tree$obj = d.structure.tree[objId].members) == null ? void 0 : _d$structure$tree$obj[memberName];
|
|
2356
2317
|
});
|
|
2318
|
+
const defaults = React__default.useMemo(() => {
|
|
2319
|
+
return member.members.map(m => m.value);
|
|
2320
|
+
}, [member]);
|
|
2321
|
+
const [userValue, setUserValue] = React__default.useState(defaults);
|
|
2322
|
+
const validateFns = React__default.useRef([]);
|
|
2323
|
+
React__default.useEffect(() => {
|
|
2324
|
+
setUserValue(defaults);
|
|
2325
|
+
}, [defaults]);
|
|
2326
|
+
const isChanged = React__default.useCallback(idx => {
|
|
2327
|
+
const tree = getDrawing(drawingId).structure.tree;
|
|
2357
2328
|
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
const isSelected = useIsSelected$1(drawingId, matePath, csys);
|
|
2370
|
-
const isHovered = useIsHovered$1(drawingId, matePath, csys);
|
|
2371
|
-
const activeSelId = useDrawing(drawingId, drawing => drawing.selection.active);
|
|
2372
|
-
const selection = activeSelId ? getDrawing(drawingId).selection.refs[activeSelId] : undefined;
|
|
2373
|
-
const isSelectable = Boolean(selection == null ? void 0 : selection.isSelectable(MateScope, {
|
|
2374
|
-
matePath,
|
|
2375
|
-
csys
|
|
2376
|
-
}));
|
|
2377
|
-
const handlers = React__default.useMemo(() => {
|
|
2378
|
-
if (isSelectable) {
|
|
2379
|
-
return _objectSpread$j(_objectSpread$j({}, hHandlers), sHandlers);
|
|
2329
|
+
if (idx !== undefined) {
|
|
2330
|
+
// If idx is passed check only single refId.
|
|
2331
|
+
return refIdChanged(userValue[idx], defaults[idx], tree);
|
|
2332
|
+
} else if (userValue.length !== defaults.length) {
|
|
2333
|
+
return true;
|
|
2334
|
+
} else {
|
|
2335
|
+
let changed = false;
|
|
2336
|
+
userValue.forEach((el, idx_) => {
|
|
2337
|
+
changed = changed || refIdChanged(el, defaults[idx_], tree);
|
|
2338
|
+
});
|
|
2339
|
+
return changed;
|
|
2380
2340
|
}
|
|
2341
|
+
}, [userValue, defaults, drawingId]);
|
|
2342
|
+
const setValidator = React__default.useCallback((validator_, idOfValidF) => {
|
|
2343
|
+
validateFns.current[idOfValidF] = validator_ === null ? emptyValidator : validator_;
|
|
2344
|
+
}, []);
|
|
2345
|
+
const validator = React__default.useCallback(() => {
|
|
2346
|
+
const warnings = [];
|
|
2347
|
+
validateFns.current.forEach((validateF, i) => {
|
|
2348
|
+
if (!validateF) {
|
|
2349
|
+
return;
|
|
2350
|
+
}
|
|
2381
2351
|
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2352
|
+
const res = validateF(userValue[i]);
|
|
2353
|
+
warnings.push(...res);
|
|
2354
|
+
});
|
|
2355
|
+
return warnings;
|
|
2356
|
+
}, [userValue]);
|
|
2357
|
+
return useParam({
|
|
2358
|
+
userValue,
|
|
2359
|
+
setUserValue,
|
|
2360
|
+
defaults,
|
|
2361
|
+
// defaults for a refsParam always contains id of tree objects, graphic Id can't be here.
|
|
2362
|
+
isChanged
|
|
2363
|
+
}, undefined, {
|
|
2364
|
+
setValidator,
|
|
2365
|
+
validator
|
|
2366
|
+
});
|
|
2393
2367
|
}
|
|
2394
2368
|
|
|
2395
|
-
function ownKeys$
|
|
2369
|
+
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; }
|
|
2396
2370
|
|
|
2397
|
-
function _objectSpread$
|
|
2371
|
+
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; }
|
|
2398
2372
|
/**
|
|
2399
2373
|
* Implies the following data structure:
|
|
2400
2374
|
* data: {
|
|
@@ -2418,7 +2392,7 @@ const createTreeObjSelItem = (productId, object) => {
|
|
|
2418
2392
|
};
|
|
2419
2393
|
};
|
|
2420
2394
|
|
|
2421
|
-
function useSelect(drawingId, objId) {
|
|
2395
|
+
function useSelect$1(drawingId, objId) {
|
|
2422
2396
|
const onClick = React__default.useCallback(e => {
|
|
2423
2397
|
e.stopPropagation();
|
|
2424
2398
|
|
|
@@ -2439,7 +2413,7 @@ function useSelect(drawingId, objId) {
|
|
|
2439
2413
|
};
|
|
2440
2414
|
}
|
|
2441
2415
|
|
|
2442
|
-
function useIsHovered(drawingId, objId) {
|
|
2416
|
+
function useIsHovered$1(drawingId, objId) {
|
|
2443
2417
|
const activeSelId = useDrawing(drawingId, d => d.selection.active);
|
|
2444
2418
|
const isHovered = useDrawing(drawingId, d => {
|
|
2445
2419
|
var _d$selection$refs;
|
|
@@ -2456,7 +2430,7 @@ function useIsHovered(drawingId, objId) {
|
|
|
2456
2430
|
return isHovered;
|
|
2457
2431
|
}
|
|
2458
2432
|
|
|
2459
|
-
function useHover(drawingId, objId) {
|
|
2433
|
+
function useHover$1(drawingId, objId) {
|
|
2460
2434
|
const onPointerOver = React__default.useCallback(e => {
|
|
2461
2435
|
e.stopPropagation();
|
|
2462
2436
|
const structure = getDrawing(drawingId).structure;
|
|
@@ -2491,7 +2465,7 @@ function useHover(drawingId, objId) {
|
|
|
2491
2465
|
*/
|
|
2492
2466
|
|
|
2493
2467
|
|
|
2494
|
-
function useIsSelected(drawingId, objId) {
|
|
2468
|
+
function useIsSelected$1(drawingId, objId) {
|
|
2495
2469
|
// Re-render if selectedItems is changed
|
|
2496
2470
|
const activeSelId = useDrawing(drawingId, d => d.selection.active);
|
|
2497
2471
|
const selectedItems = useDrawing(drawingId, d => {
|
|
@@ -2525,13 +2499,13 @@ function useTreeObjSelection(drawingId, objId) {
|
|
|
2525
2499
|
});
|
|
2526
2500
|
return res;
|
|
2527
2501
|
}, [drawingId, objId, isSelectableFunc]);
|
|
2528
|
-
const hHandlers = useHover(drawingId, objId);
|
|
2529
|
-
const isHovered = useIsHovered(drawingId, objId);
|
|
2530
|
-
const sHandlers = useSelect(drawingId, objId);
|
|
2531
|
-
const isSelected = useIsSelected(drawingId, objId);
|
|
2502
|
+
const hHandlers = useHover$1(drawingId, objId);
|
|
2503
|
+
const isHovered = useIsHovered$1(drawingId, objId);
|
|
2504
|
+
const sHandlers = useSelect$1(drawingId, objId);
|
|
2505
|
+
const isSelected = useIsSelected$1(drawingId, objId);
|
|
2532
2506
|
const handlers = React__default.useMemo(() => {
|
|
2533
2507
|
if (isSelectable) {
|
|
2534
|
-
return _objectSpread$
|
|
2508
|
+
return _objectSpread$j(_objectSpread$j({}, hHandlers), sHandlers);
|
|
2535
2509
|
}
|
|
2536
2510
|
|
|
2537
2511
|
return {};
|
|
@@ -2547,134 +2521,51 @@ function useTreeObjSelection(drawingId, objId) {
|
|
|
2547
2521
|
}, [isHovered, isSelected, isSelectable, handlers]);
|
|
2548
2522
|
}
|
|
2549
2523
|
|
|
2550
|
-
const
|
|
2551
|
-
const
|
|
2552
|
-
const
|
|
2553
|
-
const
|
|
2554
|
-
const lineFilter = (scope, data) => scope === BuerliScope && (data === GraphicType.LINE || data === GraphicType.EDGE);
|
|
2555
|
-
const lineSegmentsFilter = (scope, data) => scope === BuerliScope && (data === GraphicType.LINE || data === GraphicType.ARC || data === GraphicType.EDGE || data === GraphicType.CIRCLE);
|
|
2556
|
-
const arcFilter = (scope, data) => scope === BuerliScope && data === GraphicType.ARC;
|
|
2557
|
-
const circleFilter = (scope, data) => scope === BuerliScope && data === GraphicType.CIRCLE;
|
|
2558
|
-
const arcCircleFilter = (scope, data) => scope === BuerliScope && (data === GraphicType.ARC || data === GraphicType.CIRCLE);
|
|
2559
|
-
const pointFilter = (scope, data) => scope === BuerliScope && data === GraphicType.POINT;
|
|
2560
|
-
const meshFilter = (scope, data) => scope === BuerliScope && (data === GraphicType.PLANE || data === GraphicType.CONE || data === GraphicType.CYLINDER);
|
|
2561
|
-
const planeFilter = (scope, data) => scope === BuerliScope && data === GraphicType.PLANE;
|
|
2562
|
-
const loopFilter = (scope, data) => scope === BuerliScope && data === GraphicType.LOOP;
|
|
2563
|
-
const solidFilter = (scope, data) => scope === BuerliScope && data === GraphicType.BREP;
|
|
2564
|
-
const axisFilter = (scope, data) => scope === TreeObjScope && (data.object.class === CCClasses.CCLine || data.object.class === CCClasses.CCPoint || data.object.class === CCClasses.CCWorkAxis || data.object.class === CCClasses.CCWorkPoint) || scope === BuerliScope && (data === GraphicType.LINE || data === GraphicType.EDGE || data === GraphicType.POINT);
|
|
2565
|
-
const workPointFilter = (scope, data) => scope === TreeObjScope && data.object.class === CCClasses.CCWorkPoint;
|
|
2566
|
-
const workPlaneFilter = (scope, data) => scope === TreeObjScope && data.object.class === CCClasses.CCWorkPlane;
|
|
2567
|
-
const workAxisFilter = (scope, data) => scope === TreeObjScope && data.object.class === CCClasses.CCWorkAxis;
|
|
2568
|
-
const csysFilter = (scope, data) => scope === TreeObjScope && data.object.class === CCClasses.CCWorkCoordSystem;
|
|
2569
|
-
const mateFilter = (scope, data) => scope === MateScope && data.csys.class === CCClasses.CCWorkCoordSystem;
|
|
2570
|
-
|
|
2571
|
-
function useIdParam(drawingId, objId, memberName) {
|
|
2572
|
-
var _getDrawing$structure;
|
|
2524
|
+
const pickGraphicId = itemData => itemData.graphicId;
|
|
2525
|
+
const pickObjId = itemData => itemData.object.id;
|
|
2526
|
+
const pickOwnerId = itemData => itemData.container.ownerId;
|
|
2527
|
+
const pickGrOrObjId = itemData => itemData.graphicId || itemData.object.id;
|
|
2573
2528
|
|
|
2574
|
-
|
|
2575
|
-
const
|
|
2576
|
-
React__default.useEffect(() => {
|
|
2577
|
-
setUserValue(member.value);
|
|
2578
|
-
}, [member]);
|
|
2579
|
-
const defaults = React__default.useMemo(() => {
|
|
2580
|
-
return member.value;
|
|
2581
|
-
}, [member]);
|
|
2582
|
-
const isChanged = React__default.useCallback(() => {
|
|
2583
|
-
return userValue !== defaults;
|
|
2584
|
-
}, [defaults, userValue]);
|
|
2585
|
-
return useParam({
|
|
2586
|
-
userValue,
|
|
2587
|
-
setUserValue,
|
|
2588
|
-
defaults,
|
|
2589
|
-
isChanged
|
|
2590
|
-
});
|
|
2591
|
-
}
|
|
2529
|
+
const isGeometry = (tree, objId) => {
|
|
2530
|
+
const obj = tree[objId];
|
|
2592
2531
|
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
const {
|
|
2597
|
-
graphicId
|
|
2598
|
-
} = getGraphicId(tree, defId);
|
|
2599
|
-
return refId !== graphicId;
|
|
2532
|
+
if (!obj) {
|
|
2533
|
+
// If there is no corresponding object in tree, the BuerliScope (graphic) item should be restored.
|
|
2534
|
+
return true;
|
|
2600
2535
|
} else {
|
|
2601
|
-
//
|
|
2602
|
-
return
|
|
2536
|
+
// If obj isn't one of next classes, the TreeObjScope item should be resstored.
|
|
2537
|
+
return ccUtils.base.isA(obj.class, CCClasses.CCSolid) || ccUtils.base.isA(obj.class, CCClasses.CCBrepReference);
|
|
2538
|
+
}
|
|
2539
|
+
};
|
|
2540
|
+
const getInteractionInfo = (drawingId, item) => {
|
|
2541
|
+
if (item === null) {
|
|
2542
|
+
return null;
|
|
2603
2543
|
}
|
|
2604
|
-
}
|
|
2605
|
-
|
|
2606
|
-
function useRefsParam(drawingId, objId, memberName) {
|
|
2607
|
-
const member = useDrawing(drawingId, d => {
|
|
2608
|
-
var _d$structure$tree$obj;
|
|
2609
2544
|
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
const isChanged = React__default.useCallback(idx => {
|
|
2621
|
-
const tree = getDrawing(drawingId).structure.tree;
|
|
2622
|
-
|
|
2623
|
-
if (idx !== undefined) {
|
|
2624
|
-
// If idx is passed check only single refId.
|
|
2625
|
-
return refIdChanged(userValue[idx], defaults[idx], tree);
|
|
2626
|
-
} else if (userValue.length !== defaults.length) {
|
|
2627
|
-
return true;
|
|
2628
|
-
} else {
|
|
2629
|
-
let changed = false;
|
|
2630
|
-
userValue.forEach((el, idx_) => {
|
|
2631
|
-
changed = changed || refIdChanged(el, defaults[idx_], tree);
|
|
2632
|
-
});
|
|
2633
|
-
return changed;
|
|
2634
|
-
}
|
|
2635
|
-
}, [userValue, defaults, drawingId]);
|
|
2636
|
-
const setValidator = React__default.useCallback((validator_, idOfValidF) => {
|
|
2637
|
-
validateFns.current[idOfValidF] = validator_ === null ? emptyValidator : validator_;
|
|
2638
|
-
}, []);
|
|
2639
|
-
const validator = React__default.useCallback(() => {
|
|
2640
|
-
const warnings = [];
|
|
2641
|
-
validateFns.current.forEach((validateF, i) => {
|
|
2642
|
-
if (!validateF) {
|
|
2643
|
-
return;
|
|
2644
|
-
}
|
|
2645
|
-
|
|
2646
|
-
const res = validateF(userValue[i]);
|
|
2647
|
-
warnings.push(...res);
|
|
2545
|
+
if (item.scope === BuerliScope) {
|
|
2546
|
+
const objectId = item.data.container.ownerId;
|
|
2547
|
+
const graphicId = item.data.graphicId;
|
|
2548
|
+
const containerId = item.data.container.id;
|
|
2549
|
+
const prodRefId = item.data.productId;
|
|
2550
|
+
return createInfo({
|
|
2551
|
+
objectId,
|
|
2552
|
+
graphicId,
|
|
2553
|
+
containerId,
|
|
2554
|
+
prodRefId
|
|
2648
2555
|
});
|
|
2649
|
-
|
|
2650
|
-
}, [userValue]);
|
|
2651
|
-
return useParam({
|
|
2652
|
-
userValue,
|
|
2653
|
-
setUserValue,
|
|
2654
|
-
defaults,
|
|
2655
|
-
// defaults for a refsParam always contains id of tree objects, graphic Id can't be here.
|
|
2656
|
-
isChanged
|
|
2657
|
-
}, undefined, {
|
|
2658
|
-
setValidator,
|
|
2659
|
-
validator
|
|
2660
|
-
});
|
|
2661
|
-
}
|
|
2662
|
-
|
|
2663
|
-
const pickGraphicId = itemData => itemData.graphicId;
|
|
2664
|
-
const pickObjId = itemData => itemData.object.id;
|
|
2665
|
-
const pickOwnerId = itemData => itemData.container.ownerId;
|
|
2666
|
-
const pickGrOrObjId = itemData => itemData.graphicId || itemData.object.id;
|
|
2556
|
+
}
|
|
2667
2557
|
|
|
2668
|
-
|
|
2669
|
-
|
|
2558
|
+
if (item.scope === TreeObjScope) {
|
|
2559
|
+
const objectId = item.data.object.id; // Assume this is only used in part mode...
|
|
2670
2560
|
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
return ccUtils.base.isA(obj.class, CCClasses.CCSolid) || ccUtils.base.isA(obj.class, CCClasses.CCBrepReference);
|
|
2561
|
+
const prodRefId = getDrawing(drawingId).structure.currentProduct;
|
|
2562
|
+
return createInfo({
|
|
2563
|
+
objectId,
|
|
2564
|
+
prodRefId
|
|
2565
|
+
});
|
|
2677
2566
|
}
|
|
2567
|
+
|
|
2568
|
+
return null;
|
|
2678
2569
|
};
|
|
2679
2570
|
const RefEditor = ({
|
|
2680
2571
|
children,
|
|
@@ -2760,6 +2651,10 @@ const RefEditor = ({
|
|
|
2760
2651
|
}
|
|
2761
2652
|
}, // TODO: there is dependency array, but customSelect will be used in Selection once on selector creating.
|
|
2762
2653
|
[drawingId, selectorsOrder, setParamRef]);
|
|
2654
|
+
const onHover = React__default.useCallback(item => {
|
|
2655
|
+
const setHovered = getDrawing(drawingId).api.interaction.setHovered;
|
|
2656
|
+
setHovered(getInteractionInfo(drawingId, item));
|
|
2657
|
+
}, [drawingId]);
|
|
2763
2658
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(SelectionRestorer, {
|
|
2764
2659
|
drawingId: drawingId,
|
|
2765
2660
|
refId: refId,
|
|
@@ -2774,7 +2669,8 @@ const RefEditor = ({
|
|
|
2774
2669
|
onCreated: setSelectorId,
|
|
2775
2670
|
maxLen: 1,
|
|
2776
2671
|
customSelect: customSetter,
|
|
2777
|
-
customUnSelect: customSetter
|
|
2672
|
+
customUnSelect: customSetter,
|
|
2673
|
+
onHover: onHover
|
|
2778
2674
|
}), children));
|
|
2779
2675
|
};
|
|
2780
2676
|
const GrItemRestorer = ({
|
|
@@ -3022,6 +2918,10 @@ const RefsEditor = ({
|
|
|
3022
2918
|
return () => setUserValue(defaults);
|
|
3023
2919
|
}, [setUserValue, defaults]);
|
|
3024
2920
|
const modes = useModes(drawingId, sketchLines, setRefsFromItems, selectorsOrder);
|
|
2921
|
+
const onHover = React__default.useCallback(item => {
|
|
2922
|
+
const setHovered = getDrawing(drawingId).api.interaction.setHovered;
|
|
2923
|
+
setHovered(getInteractionInfo(drawingId, item));
|
|
2924
|
+
}, [drawingId]);
|
|
3025
2925
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(SelectionRestorer, {
|
|
3026
2926
|
drawingId: drawingId,
|
|
3027
2927
|
refIds: userValue,
|
|
@@ -3035,7 +2935,8 @@ const RefsEditor = ({
|
|
|
3035
2935
|
filter: filter,
|
|
3036
2936
|
onCreated: setSelectorId,
|
|
3037
2937
|
maxLen: maxRefLen,
|
|
3038
|
-
modes: modes
|
|
2938
|
+
modes: modes,
|
|
2939
|
+
onHover: onHover
|
|
3039
2940
|
}), children));
|
|
3040
2941
|
};
|
|
3041
2942
|
|
|
@@ -3091,6 +2992,138 @@ const SelectionRestorer = ({
|
|
|
3091
2992
|
return null;
|
|
3092
2993
|
};
|
|
3093
2994
|
|
|
2995
|
+
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; }
|
|
2996
|
+
|
|
2997
|
+
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; }
|
|
2998
|
+
/**
|
|
2999
|
+
* Implies the following data structure:
|
|
3000
|
+
* data: {
|
|
3001
|
+
* matePath: ObjectID[],
|
|
3002
|
+
* csys: IStructureObject,
|
|
3003
|
+
* flip: FlipType,
|
|
3004
|
+
* reoriented: ReorientedType,
|
|
3005
|
+
* }
|
|
3006
|
+
*/
|
|
3007
|
+
|
|
3008
|
+
const MateScope = 'HLConstraintScope';
|
|
3009
|
+
const createMateItem = (matePath, csys, flip, reoriented) => {
|
|
3010
|
+
return {
|
|
3011
|
+
id: `Mate|${matePath.toString()}|${csys.id}|(${flip},${reoriented})`,
|
|
3012
|
+
scope: MateScope,
|
|
3013
|
+
data: {
|
|
3014
|
+
matePath,
|
|
3015
|
+
csys,
|
|
3016
|
+
flip,
|
|
3017
|
+
reoriented
|
|
3018
|
+
},
|
|
3019
|
+
label: 'MATE'
|
|
3020
|
+
};
|
|
3021
|
+
};
|
|
3022
|
+
|
|
3023
|
+
function useIsHovered(drawingId, matePath, object) {
|
|
3024
|
+
const hoveredItem = useDrawing(drawingId, d => {
|
|
3025
|
+
const activeId = d.selection.active;
|
|
3026
|
+
|
|
3027
|
+
if (!activeId) {
|
|
3028
|
+
return undefined;
|
|
3029
|
+
}
|
|
3030
|
+
|
|
3031
|
+
return d.selection.refs[activeId].hoveredItem;
|
|
3032
|
+
});
|
|
3033
|
+
if (!hoveredItem) return false;
|
|
3034
|
+
return createMateItem(matePath, object, FlipType.FLIP_Z, ReorientedType.REORIENTED_0).id === hoveredItem.id;
|
|
3035
|
+
}
|
|
3036
|
+
|
|
3037
|
+
function useHover(drawingId, matePath, objectId) {
|
|
3038
|
+
const onPointerOver = React__default.useCallback(e => {
|
|
3039
|
+
const selApi = getDrawing(drawingId).api.selection;
|
|
3040
|
+
const object = getDrawing(drawingId).structure.tree[objectId];
|
|
3041
|
+
const item = createMateItem(matePath, object, FlipType.FLIP_Z, ReorientedType.REORIENTED_0);
|
|
3042
|
+
selApi.setHovered(item);
|
|
3043
|
+
}, [drawingId, objectId, matePath]);
|
|
3044
|
+
const onPointerOut = React__default.useCallback(e => {
|
|
3045
|
+
const selApi = getDrawing(drawingId).api.selection;
|
|
3046
|
+
selApi.setHovered(null);
|
|
3047
|
+
}, [drawingId]);
|
|
3048
|
+
return {
|
|
3049
|
+
onPointerOut,
|
|
3050
|
+
onPointerOver
|
|
3051
|
+
};
|
|
3052
|
+
}
|
|
3053
|
+
|
|
3054
|
+
function useSelect(drawingId, matePath, csys) {
|
|
3055
|
+
const selApi = getDrawing(drawingId).api.selection;
|
|
3056
|
+
const onClick = React__default.useCallback(e => {
|
|
3057
|
+
const item = createMateItem(matePath, csys, FlipType.FLIP_Z, ReorientedType.REORIENTED_0);
|
|
3058
|
+
selApi.isItemSelected(item) ? selApi.unselect(item) : selApi.select(item);
|
|
3059
|
+
e.stopPropagation();
|
|
3060
|
+
}, [selApi, matePath, csys]);
|
|
3061
|
+
return {
|
|
3062
|
+
onClick
|
|
3063
|
+
};
|
|
3064
|
+
} // Returns true if object in tree is currently selected in active selection.
|
|
3065
|
+
|
|
3066
|
+
|
|
3067
|
+
function useIsSelected(drawingId, matePath, csys) {
|
|
3068
|
+
// Re-render if selectedItems is changed
|
|
3069
|
+
const selectedItems = useDrawing(drawingId, d => {
|
|
3070
|
+
const activeId = d.selection.active;
|
|
3071
|
+
|
|
3072
|
+
if (!activeId) {
|
|
3073
|
+
return undefined;
|
|
3074
|
+
}
|
|
3075
|
+
|
|
3076
|
+
return d.selection.refs[activeId].items;
|
|
3077
|
+
});
|
|
3078
|
+
|
|
3079
|
+
if (!selectedItems) {
|
|
3080
|
+
return false;
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
const selApi = getDrawing(drawingId).api.selection;
|
|
3084
|
+
return selApi.isItemSelected(createMateItem(matePath, csys, FlipType.FLIP_Z, ReorientedType.REORIENTED_0));
|
|
3085
|
+
}
|
|
3086
|
+
function useMateSelection(drawingId, matePath, csysId) {
|
|
3087
|
+
const csys = useDrawing(drawingId, drawing => drawing.structure.tree[csysId]);
|
|
3088
|
+
const hHandlers = useHover(drawingId, matePath, csys.id);
|
|
3089
|
+
const sHandlers = useSelect(drawingId, matePath, csys);
|
|
3090
|
+
const isSelected = useIsSelected(drawingId, matePath, csys);
|
|
3091
|
+
const isHovered = useIsHovered(drawingId, matePath, csys);
|
|
3092
|
+
const activeSelId = useDrawing(drawingId, drawing => drawing.selection.active);
|
|
3093
|
+
const selection = activeSelId ? getDrawing(drawingId).selection.refs[activeSelId] : undefined;
|
|
3094
|
+
const isSelectable = Boolean(selection == null ? void 0 : selection.isSelectable(MateScope, {
|
|
3095
|
+
matePath,
|
|
3096
|
+
csys
|
|
3097
|
+
}));
|
|
3098
|
+
const handlers = React__default.useMemo(() => {
|
|
3099
|
+
if (isSelectable) {
|
|
3100
|
+
return _objectSpread$i(_objectSpread$i({}, hHandlers), sHandlers);
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
return {};
|
|
3104
|
+
}, [isSelectable, hHandlers, sHandlers]);
|
|
3105
|
+
return React__default.useMemo(() => {
|
|
3106
|
+
// 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.
|
|
3107
|
+
// Thus, we don't want hovered and selected to be true if the object is not selectable.
|
|
3108
|
+
return {
|
|
3109
|
+
isHovered: isHovered && isSelectable,
|
|
3110
|
+
isSelected: isSelected && isSelectable,
|
|
3111
|
+
handlers
|
|
3112
|
+
};
|
|
3113
|
+
}, [isHovered, isSelected, isSelectable, handlers]);
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
const ccPointFilter = (scope, data) => scope === TreeObjScope && data.object.class === CCClasses.CCPoint;
|
|
3117
|
+
const ccLineFilter = (scope, data) => scope === TreeObjScope && data.object.class === CCClasses.CCLine;
|
|
3118
|
+
const ccArcFilter = (scope, data) => scope === TreeObjScope && data.object.class === CCClasses.CCArc;
|
|
3119
|
+
const ccCircleFilter = (scope, data) => scope === TreeObjScope && data.object.class === CCClasses.CCCircle;
|
|
3120
|
+
const axisFilter = (scope, data) => scope === TreeObjScope && (data.object.class === CCClasses.CCLine || data.object.class === CCClasses.CCPoint || data.object.class === CCClasses.CCWorkAxis || data.object.class === CCClasses.CCWorkPoint) || scope === BuerliScope && (data === GraphicType.LINE || data === GraphicType.EDGE || data === GraphicType.POINT);
|
|
3121
|
+
const workPointFilter = (scope, data) => scope === TreeObjScope && data.object.class === CCClasses.CCWorkPoint;
|
|
3122
|
+
const workPlaneFilter = (scope, data) => scope === TreeObjScope && data.object.class === CCClasses.CCWorkPlane;
|
|
3123
|
+
const workAxisFilter = (scope, data) => scope === TreeObjScope && data.object.class === CCClasses.CCWorkAxis;
|
|
3124
|
+
const csysFilter = (scope, data) => scope === TreeObjScope && data.object.class === CCClasses.CCWorkCoordSystem;
|
|
3125
|
+
const mateFilter = (scope, data) => scope === MateScope && data.csys.class === CCClasses.CCWorkCoordSystem;
|
|
3126
|
+
|
|
3094
3127
|
const MateEditor = ({
|
|
3095
3128
|
param,
|
|
3096
3129
|
drawingId,
|
|
@@ -3171,6 +3204,16 @@ const MateEditor = ({
|
|
|
3171
3204
|
}
|
|
3172
3205
|
}, // TODO: there is dependency array, but customSelect will be used in Selection once on selector creating.
|
|
3173
3206
|
[drawingId, selectorsOrder, setMateParam]);
|
|
3207
|
+
const onHover = React__default.useCallback(item => {
|
|
3208
|
+
const prodRefId = getDrawing(drawingId).structure.currentProduct;
|
|
3209
|
+
const setHovered = getDrawing(drawingId).api.interaction.setHovered;
|
|
3210
|
+
setHovered(item ? {
|
|
3211
|
+
objectId: item.data.csys.id,
|
|
3212
|
+
prodRefId,
|
|
3213
|
+
userData: item.data,
|
|
3214
|
+
uniqueIdent: [item.data.csys.id, ...item.data.matePath].toString()
|
|
3215
|
+
} : null);
|
|
3216
|
+
}, [drawingId]);
|
|
3174
3217
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MateRestorer, {
|
|
3175
3218
|
drawingId: drawingId,
|
|
3176
3219
|
matePath: matePath,
|
|
@@ -3188,7 +3231,8 @@ const MateEditor = ({
|
|
|
3188
3231
|
onCreated: setSelectorId,
|
|
3189
3232
|
maxLen: 1,
|
|
3190
3233
|
customSelect: customSetter,
|
|
3191
|
-
customUnSelect: customSetter
|
|
3234
|
+
customUnSelect: customSetter,
|
|
3235
|
+
onHover: onHover
|
|
3192
3236
|
}), /*#__PURE__*/React__default.createElement(MateFlip, {
|
|
3193
3237
|
flipState: flipState,
|
|
3194
3238
|
setFlipState: setFlip,
|
|
@@ -5519,12 +5563,17 @@ const RootImpl$g = ({
|
|
|
5519
5563
|
const filter = React__default.useCallback((scope, data) => {
|
|
5520
5564
|
return scope === BuerliScope && !Excluded.includes(data);
|
|
5521
5565
|
}, []);
|
|
5566
|
+
const onHover = React__default.useCallback(item => {
|
|
5567
|
+
const setHovered = getDrawing(drawingId).api.interaction.setHovered;
|
|
5568
|
+
setHovered(getInteractionInfo(drawingId, item));
|
|
5569
|
+
}, [drawingId]);
|
|
5522
5570
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Wrapper, {
|
|
5523
5571
|
caption: "Items"
|
|
5524
5572
|
}, /*#__PURE__*/React__default.createElement(Selection, {
|
|
5525
5573
|
drawingId: drawingId,
|
|
5526
5574
|
onCreated: setSelectorId,
|
|
5527
|
-
filter: filter
|
|
5575
|
+
filter: filter,
|
|
5576
|
+
onHover: onHover
|
|
5528
5577
|
})), /*#__PURE__*/React__default.createElement(Output, {
|
|
5529
5578
|
drawingId: drawingId,
|
|
5530
5579
|
pluginId: pluginId,
|
|
@@ -5599,7 +5648,7 @@ const Point$2 = ({
|
|
|
5599
5648
|
attach: "material",
|
|
5600
5649
|
color: color,
|
|
5601
5650
|
opacity: opacity,
|
|
5602
|
-
transparent:
|
|
5651
|
+
transparent: opacity < 1
|
|
5603
5652
|
}));
|
|
5604
5653
|
};
|
|
5605
5654
|
const Arrow = ({
|
|
@@ -5620,7 +5669,9 @@ const Arrow = ({
|
|
|
5620
5669
|
return /*#__PURE__*/React__default.createElement("group", _extends({
|
|
5621
5670
|
position: position.clone(),
|
|
5622
5671
|
quaternion: new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0, 1, 0), direction.clone().normalize())
|
|
5623
|
-
}, handlers
|
|
5672
|
+
}, handlers, {
|
|
5673
|
+
userData: userData
|
|
5674
|
+
}), /*#__PURE__*/React__default.createElement("mesh", {
|
|
5624
5675
|
position: new THREE.Vector3(0, cylinderLength / 2.0, 0),
|
|
5625
5676
|
renderOrder: 500,
|
|
5626
5677
|
userData: userData
|
|
@@ -5643,7 +5694,7 @@ const Arrow = ({
|
|
|
5643
5694
|
attach: "material",
|
|
5644
5695
|
color: color,
|
|
5645
5696
|
opacity: opacity,
|
|
5646
|
-
transparent:
|
|
5697
|
+
transparent: opacity < 1
|
|
5647
5698
|
})));
|
|
5648
5699
|
};
|
|
5649
5700
|
const OriginPoint = ({
|
|
@@ -5697,7 +5748,8 @@ const Csys = ({
|
|
|
5697
5748
|
const ref = useScale$1(position.clone(), sf => [2 * sf, 2 * sf, 2 * sf]);
|
|
5698
5749
|
return /*#__PURE__*/React__default.createElement("group", _extends({
|
|
5699
5750
|
matrix: matrix,
|
|
5700
|
-
matrixAutoUpdate: false
|
|
5751
|
+
matrixAutoUpdate: false,
|
|
5752
|
+
userData: userData
|
|
5701
5753
|
}, handlers), /*#__PURE__*/React__default.createElement("group", {
|
|
5702
5754
|
ref: ref
|
|
5703
5755
|
}, /*#__PURE__*/React__default.createElement(OriginPoint, {
|
|
@@ -5727,7 +5779,7 @@ const Csys = ({
|
|
|
5727
5779
|
};
|
|
5728
5780
|
const SelectedCsys = ({
|
|
5729
5781
|
matrix,
|
|
5730
|
-
opacity,
|
|
5782
|
+
opacity = 1.0,
|
|
5731
5783
|
handlers,
|
|
5732
5784
|
color,
|
|
5733
5785
|
userData
|
|
@@ -6769,7 +6821,7 @@ const createArcGeometry = (radialSegments, tubularSegments, instanceLimit) => {
|
|
|
6769
6821
|
return geometry;
|
|
6770
6822
|
};
|
|
6771
6823
|
|
|
6772
|
-
const vertexCode = `
|
|
6824
|
+
const vertexCode$2 = `
|
|
6773
6825
|
attribute float radius;
|
|
6774
6826
|
attribute float tubeRadius;
|
|
6775
6827
|
attribute float angularLength;
|
|
@@ -6789,7 +6841,7 @@ const vertexCode = `
|
|
|
6789
6841
|
vColor = vec4(instanceColor, 1);
|
|
6790
6842
|
}
|
|
6791
6843
|
`;
|
|
6792
|
-
const fragmentCode = `
|
|
6844
|
+
const fragmentCode$3 = `
|
|
6793
6845
|
varying vec4 vColor;
|
|
6794
6846
|
|
|
6795
6847
|
void main() {
|
|
@@ -6800,8 +6852,8 @@ const fragmentCode = `
|
|
|
6800
6852
|
`;
|
|
6801
6853
|
const createArcMaterial = () => {
|
|
6802
6854
|
const material = new THREE.ShaderMaterial({
|
|
6803
|
-
vertexShader: vertexCode,
|
|
6804
|
-
fragmentShader: fragmentCode,
|
|
6855
|
+
vertexShader: vertexCode$2,
|
|
6856
|
+
fragmentShader: fragmentCode$3,
|
|
6805
6857
|
side: THREE.DoubleSide
|
|
6806
6858
|
});
|
|
6807
6859
|
return material;
|
|
@@ -10074,7 +10126,7 @@ const useGeomParams = objId => {
|
|
|
10074
10126
|
} = React__default.useContext(ViewContext);
|
|
10075
10127
|
const lSelected = useSketchState(drawingId, pluginId, state => state.selected.indexOf(objId) !== -1); // gSelected - true if object is selected in a global selection
|
|
10076
10128
|
|
|
10077
|
-
const gSelected = useIsSelected(drawingId, objId);
|
|
10129
|
+
const gSelected = useIsSelected$1(drawingId, objId);
|
|
10078
10130
|
const isSelected = lSelected || gSelected;
|
|
10079
10131
|
const isHighlighted = useSketchState(drawingId, pluginId, state => state.highlighted.indexOf(objId) !== -1);
|
|
10080
10132
|
const isHovered = useSketchState(drawingId, pluginId, state => state.hovered === objId);
|
|
@@ -10242,7 +10294,7 @@ const useColor = (objId, gHovered) => {
|
|
|
10242
10294
|
|
|
10243
10295
|
const lSelected = useSketchState(drawingId, pluginId, state => state.selected.indexOf(objId) !== -1); // Globally selected by some of selection elements.
|
|
10244
10296
|
|
|
10245
|
-
const gSelected = useIsSelected(drawingId, objId);
|
|
10297
|
+
const gSelected = useIsSelected$1(drawingId, objId);
|
|
10246
10298
|
const isSelected = lSelected || gSelected;
|
|
10247
10299
|
const isHighlighted = useSketchState(drawingId, pluginId, state => state.highlighted.indexOf(objId) !== -1);
|
|
10248
10300
|
const isHovered = useSketchState(drawingId, pluginId, state => state.hovered === objId);
|
|
@@ -10265,9 +10317,20 @@ const useColor = (objId, gHovered) => {
|
|
|
10265
10317
|
return color;
|
|
10266
10318
|
};
|
|
10267
10319
|
const useUserData = objId => {
|
|
10268
|
-
|
|
10269
|
-
|
|
10270
|
-
|
|
10320
|
+
const {
|
|
10321
|
+
drawingId,
|
|
10322
|
+
isActive
|
|
10323
|
+
} = React__default.useContext(ViewContext);
|
|
10324
|
+
return React__default.useMemo(() => {
|
|
10325
|
+
const tree = getDrawing(drawingId).structure.tree;
|
|
10326
|
+
const onHUD = !isActive || is2DConstraint(tree[objId]);
|
|
10327
|
+
return onHUD ? {
|
|
10328
|
+
objId,
|
|
10329
|
+
onHUD
|
|
10330
|
+
} : {
|
|
10331
|
+
objId
|
|
10332
|
+
};
|
|
10333
|
+
}, [drawingId, objId, isActive]);
|
|
10271
10334
|
}; // Fix for interaction until drei support undefined as pointer handlers
|
|
10272
10335
|
|
|
10273
10336
|
const defaultHandlers = {
|
|
@@ -10587,7 +10650,7 @@ const Line = ({
|
|
|
10587
10650
|
|
|
10588
10651
|
if (dist < lineCoef * sketchScale) {
|
|
10589
10652
|
intersects.push({
|
|
10590
|
-
distance:
|
|
10653
|
+
distance: raycaster.ray.origin.distanceTo(pointOnRay),
|
|
10591
10654
|
point: pointOnRay,
|
|
10592
10655
|
face: null,
|
|
10593
10656
|
object: this
|
|
@@ -10616,6 +10679,7 @@ const Line = ({
|
|
|
10616
10679
|
}));
|
|
10617
10680
|
};
|
|
10618
10681
|
|
|
10682
|
+
const closestPos = new THREE.Vector3();
|
|
10619
10683
|
const pointPos = new THREE.Vector3();
|
|
10620
10684
|
const pointCoef = 1.3; // Coefficient for increased interaction area
|
|
10621
10685
|
|
|
@@ -10636,8 +10700,9 @@ const Point = ({
|
|
|
10636
10700
|
const sketchScale = getScale(drawingId, pluginId);
|
|
10637
10701
|
|
|
10638
10702
|
if (dist < pointCoef * sketchScale) {
|
|
10703
|
+
raycaster.ray.closestPointToPoint(pointPos, closestPos);
|
|
10639
10704
|
intersects.push({
|
|
10640
|
-
distance:
|
|
10705
|
+
distance: raycaster.ray.origin.distanceTo(closestPos),
|
|
10641
10706
|
point: pointPos.clone(),
|
|
10642
10707
|
face: null,
|
|
10643
10708
|
object: this
|
|
@@ -11999,7 +12064,7 @@ const View$d = ({
|
|
|
11999
12064
|
}));
|
|
12000
12065
|
};
|
|
12001
12066
|
|
|
12002
|
-
const _excluded$
|
|
12067
|
+
const _excluded$4 = ["handlerName", "sideEffect"];
|
|
12003
12068
|
const RadioGroup = styled(RadioGroupImpl)`
|
|
12004
12069
|
display: flex !important;
|
|
12005
12070
|
`;
|
|
@@ -12018,7 +12083,7 @@ const HButton = _ref => {
|
|
|
12018
12083
|
handlerName,
|
|
12019
12084
|
sideEffect = () => undefined
|
|
12020
12085
|
} = _ref,
|
|
12021
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
12086
|
+
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
12022
12087
|
|
|
12023
12088
|
const {
|
|
12024
12089
|
drawingId,
|
|
@@ -12374,7 +12439,7 @@ const PlaneSelection = ({
|
|
|
12374
12439
|
}));
|
|
12375
12440
|
};
|
|
12376
12441
|
|
|
12377
|
-
const _excluded$
|
|
12442
|
+
const _excluded$3 = ["items", "children"];
|
|
12378
12443
|
|
|
12379
12444
|
/**
|
|
12380
12445
|
* Context menu. By default it's rendered as thee dots "...", when user hovers it the menuitems is shown.
|
|
@@ -12392,7 +12457,7 @@ const Menu = _ref => {
|
|
|
12392
12457
|
items,
|
|
12393
12458
|
children
|
|
12394
12459
|
} = _ref,
|
|
12395
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
12460
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
12396
12461
|
|
|
12397
12462
|
const onItemClick = React__default.useCallback(e => {
|
|
12398
12463
|
e.domEvent.stopPropagation();
|
|
@@ -13327,6 +13392,34 @@ const Root$e = ({
|
|
|
13327
13392
|
}));
|
|
13328
13393
|
};
|
|
13329
13394
|
|
|
13395
|
+
const WorkAxisObj = ({
|
|
13396
|
+
drawingId,
|
|
13397
|
+
objectId,
|
|
13398
|
+
color = 0x111111,
|
|
13399
|
+
opacity = 1,
|
|
13400
|
+
userData,
|
|
13401
|
+
handlers
|
|
13402
|
+
}) => {
|
|
13403
|
+
var _workAxisObj$members, _workAxisObj$members2;
|
|
13404
|
+
|
|
13405
|
+
const workAxisObj = useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
|
|
13406
|
+
const position = convertToVector(workAxisObj == null ? void 0 : (_workAxisObj$members = workAxisObj.members) == null ? void 0 : _workAxisObj$members.Position);
|
|
13407
|
+
const direction = convertToVector(workAxisObj == null ? void 0 : (_workAxisObj$members2 = workAxisObj.members) == null ? void 0 : _workAxisObj$members2.Direction);
|
|
13408
|
+
const ref = useScale$1(position.clone(), sf => [3 * sf, 3 * sf, 3 * sf]);
|
|
13409
|
+
return /*#__PURE__*/React__default.createElement("group", {
|
|
13410
|
+
ref: ref,
|
|
13411
|
+
position: position
|
|
13412
|
+
}, /*#__PURE__*/React__default.createElement(AxisArrow, {
|
|
13413
|
+
direction: direction,
|
|
13414
|
+
color: color,
|
|
13415
|
+
opacity: opacity,
|
|
13416
|
+
userData: userData,
|
|
13417
|
+
handlers: handlers,
|
|
13418
|
+
width: 0.5,
|
|
13419
|
+
length: 40
|
|
13420
|
+
}));
|
|
13421
|
+
};
|
|
13422
|
+
|
|
13330
13423
|
function getColor(hovered, selected, direction, type) {
|
|
13331
13424
|
if (hovered) {
|
|
13332
13425
|
return 0x28d79f;
|
|
@@ -13347,30 +13440,28 @@ const ViewImpl$c = ({
|
|
|
13347
13440
|
drawingId,
|
|
13348
13441
|
pluginId
|
|
13349
13442
|
}) => {
|
|
13443
|
+
var _workAxisObj$members, _workAxisObj$members2;
|
|
13444
|
+
|
|
13350
13445
|
const {
|
|
13351
13446
|
objectId = -1
|
|
13352
13447
|
} = getPlugin(drawingId, pluginId);
|
|
13353
13448
|
const workAxisObj = useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
|
|
13354
|
-
const
|
|
13355
|
-
const direction = convertToVector(workAxisObj.members.Direction);
|
|
13449
|
+
const direction = convertToVector(workAxisObj == null ? void 0 : (_workAxisObj$members = workAxisObj.members) == null ? void 0 : _workAxisObj$members.Direction);
|
|
13356
13450
|
const {
|
|
13357
13451
|
isHovered,
|
|
13358
13452
|
isSelected,
|
|
13359
13453
|
handlers
|
|
13360
13454
|
} = useTreeObjSelection(drawingId, objectId);
|
|
13361
|
-
const color = getColor(isHovered, isSelected, direction, workAxisObj.members.Type.value);
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
position: position
|
|
13366
|
-
}, /*#__PURE__*/React__default.createElement(AxisArrow, {
|
|
13367
|
-
direction: direction,
|
|
13455
|
+
const color = getColor(isHovered, isSelected, direction, workAxisObj == null ? void 0 : (_workAxisObj$members2 = workAxisObj.members) == null ? void 0 : _workAxisObj$members2.Type.value);
|
|
13456
|
+
return /*#__PURE__*/React__default.createElement(HUD, null, /*#__PURE__*/React__default.createElement(WorkAxisObj, {
|
|
13457
|
+
drawingId: drawingId,
|
|
13458
|
+
objectId: objectId,
|
|
13368
13459
|
color: color,
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
}))
|
|
13460
|
+
userData: {
|
|
13461
|
+
onHUD: true
|
|
13462
|
+
},
|
|
13463
|
+
handlers: handlers
|
|
13464
|
+
}));
|
|
13374
13465
|
};
|
|
13375
13466
|
|
|
13376
13467
|
const View$c = ({
|
|
@@ -13685,41 +13776,90 @@ const Root$d = ({
|
|
|
13685
13776
|
}));
|
|
13686
13777
|
};
|
|
13687
13778
|
|
|
13688
|
-
const
|
|
13779
|
+
const WorkPlaneObj = ({
|
|
13689
13780
|
drawingId,
|
|
13690
|
-
|
|
13781
|
+
objectId,
|
|
13782
|
+
color = 0x34424f,
|
|
13783
|
+
opacity = 1,
|
|
13784
|
+
userData,
|
|
13785
|
+
handlers
|
|
13691
13786
|
}) => {
|
|
13692
13787
|
var _workPlaneObj$members2, _workPlaneObj$members3, _workPlaneObj$members4;
|
|
13693
13788
|
|
|
13789
|
+
const workPlaneObj = 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
|
|
13790
|
+
|
|
13694
13791
|
const {
|
|
13695
|
-
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
const quaternion = React__default.useMemo(() => {
|
|
13792
|
+
quaternion,
|
|
13793
|
+
quaternionInv
|
|
13794
|
+
} = React__default.useMemo(() => {
|
|
13699
13795
|
var _workPlaneObj$members;
|
|
13700
13796
|
|
|
13701
|
-
|
|
13702
|
-
|
|
13703
|
-
|
|
13797
|
+
const up = new THREE.Vector3(0, 0, 1);
|
|
13798
|
+
const normal = convertToVector(workPlaneObj == null ? void 0 : (_workPlaneObj$members = workPlaneObj.members) == null ? void 0 : _workPlaneObj$members.Normal).normalize();
|
|
13799
|
+
const normalInv = normal.clone().negate();
|
|
13800
|
+
return {
|
|
13801
|
+
quaternion: new THREE.Quaternion().setFromUnitVectors(up, normal),
|
|
13802
|
+
quaternionInv: new THREE.Quaternion().setFromUnitVectors(up, normalInv)
|
|
13803
|
+
};
|
|
13804
|
+
}, [workPlaneObj == null ? void 0 : (_workPlaneObj$members2 = workPlaneObj.members) == null ? void 0 : _workPlaneObj$members2.Normal]);
|
|
13805
|
+
const position = convertToVector(workPlaneObj == null ? void 0 : (_workPlaneObj$members3 = workPlaneObj.members) == null ? void 0 : _workPlaneObj$members3.curPosition);
|
|
13806
|
+
const scale = workPlaneObj == null ? void 0 : (_workPlaneObj$members4 = workPlaneObj.members) == null ? void 0 : _workPlaneObj$members4.Size.value;
|
|
13807
|
+
const calScale = React__default.useCallback(sf => {
|
|
13808
|
+
// 1.2 = (kAxis * axisLength) / (planeDefScale * planeBase) = (3 * 40) / (200 * 0.5)
|
|
13809
|
+
const scale_ = 1.2 * sf * scale;
|
|
13810
|
+
return [scale_, scale_, scale_];
|
|
13811
|
+
}, [scale]);
|
|
13812
|
+
const ref = useScale$1(position.clone(), calScale);
|
|
13813
|
+
const refInv = useScale$1(position.clone(), calScale);
|
|
13814
|
+
return /*#__PURE__*/React__default.createElement("group", null, /*#__PURE__*/React__default.createElement("mesh", _extends({
|
|
13815
|
+
ref: ref,
|
|
13816
|
+
position: position,
|
|
13817
|
+
quaternion: quaternion,
|
|
13818
|
+
userData: userData
|
|
13819
|
+
}, handlers), /*#__PURE__*/React__default.createElement("meshBasicMaterial", {
|
|
13820
|
+
color: color,
|
|
13821
|
+
side: THREE.FrontSide,
|
|
13822
|
+
opacity: opacity,
|
|
13823
|
+
transparent: opacity < 1,
|
|
13824
|
+
depthWrite: false
|
|
13825
|
+
}), /*#__PURE__*/React__default.createElement("planeGeometry", {
|
|
13826
|
+
args: [1, 1]
|
|
13827
|
+
})), /*#__PURE__*/React__default.createElement("mesh", _extends({
|
|
13828
|
+
ref: refInv,
|
|
13829
|
+
position: position,
|
|
13830
|
+
quaternion: quaternionInv,
|
|
13831
|
+
userData: userData
|
|
13832
|
+
}, handlers), /*#__PURE__*/React__default.createElement("meshBasicMaterial", {
|
|
13833
|
+
color: color,
|
|
13834
|
+
side: THREE.FrontSide,
|
|
13835
|
+
opacity: opacity,
|
|
13836
|
+
transparent: opacity < 1,
|
|
13837
|
+
depthWrite: false
|
|
13838
|
+
}), /*#__PURE__*/React__default.createElement("planeGeometry", {
|
|
13839
|
+
args: [1, 1]
|
|
13840
|
+
})));
|
|
13841
|
+
};
|
|
13842
|
+
|
|
13843
|
+
const ViewImpl$b = ({
|
|
13844
|
+
drawingId,
|
|
13845
|
+
pluginId
|
|
13846
|
+
}) => {
|
|
13847
|
+
const {
|
|
13848
|
+
objectId = -1
|
|
13849
|
+
} = getPlugin(drawingId, pluginId);
|
|
13704
13850
|
const {
|
|
13705
13851
|
isHovered,
|
|
13706
13852
|
isSelected,
|
|
13707
13853
|
handlers
|
|
13708
13854
|
} = useTreeObjSelection(drawingId, objectId);
|
|
13709
13855
|
const color = isHovered ? 0x18b77f : isSelected ? 0xa70b0b : 0x34424f;
|
|
13710
|
-
return /*#__PURE__*/React__default.createElement(
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
scale: scale
|
|
13714
|
-
}, handlers), /*#__PURE__*/React__default.createElement("meshBasicMaterial", {
|
|
13856
|
+
return /*#__PURE__*/React__default.createElement(WorkPlaneObj, {
|
|
13857
|
+
drawingId: drawingId,
|
|
13858
|
+
objectId: objectId,
|
|
13715
13859
|
color: color,
|
|
13716
|
-
side: THREE.DoubleSide,
|
|
13717
13860
|
opacity: 0.5,
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
}), /*#__PURE__*/React__default.createElement("planeGeometry", {
|
|
13721
|
-
args: [1, 1]
|
|
13722
|
-
}));
|
|
13861
|
+
handlers: handlers
|
|
13862
|
+
});
|
|
13723
13863
|
};
|
|
13724
13864
|
|
|
13725
13865
|
const View$b = ({
|
|
@@ -13874,6 +14014,30 @@ const Root$c = ({
|
|
|
13874
14014
|
}));
|
|
13875
14015
|
};
|
|
13876
14016
|
|
|
14017
|
+
const WorkPointObj = ({
|
|
14018
|
+
drawingId,
|
|
14019
|
+
objectId,
|
|
14020
|
+
color = 0x111111,
|
|
14021
|
+
opacity = 1,
|
|
14022
|
+
userData,
|
|
14023
|
+
handlers
|
|
14024
|
+
}) => {
|
|
14025
|
+
var _workPointObj$members;
|
|
14026
|
+
|
|
14027
|
+
const workPointObj = useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
|
|
14028
|
+
const position = convertToVector(workPointObj == null ? void 0 : (_workPointObj$members = workPointObj.members) == null ? void 0 : _workPointObj$members.Position);
|
|
14029
|
+
const ref = useScale$1(position.clone(), sf => [3 * sf, 3 * sf, 3 * sf]);
|
|
14030
|
+
return /*#__PURE__*/React__default.createElement("group", {
|
|
14031
|
+
ref: ref,
|
|
14032
|
+
position: position
|
|
14033
|
+
}, /*#__PURE__*/React__default.createElement(OriginPoint, {
|
|
14034
|
+
color: color,
|
|
14035
|
+
opacity: opacity,
|
|
14036
|
+
userData: userData,
|
|
14037
|
+
handlers: handlers
|
|
14038
|
+
}));
|
|
14039
|
+
};
|
|
14040
|
+
|
|
13877
14041
|
const ViewImpl$a = ({
|
|
13878
14042
|
drawingId,
|
|
13879
14043
|
pluginId
|
|
@@ -13881,22 +14045,21 @@ const ViewImpl$a = ({
|
|
|
13881
14045
|
const {
|
|
13882
14046
|
objectId = -1
|
|
13883
14047
|
} = getPlugin(drawingId, pluginId);
|
|
13884
|
-
const workPointObj = useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
|
|
13885
|
-
const position = convertToVector(workPointObj.members.Position);
|
|
13886
14048
|
const {
|
|
13887
14049
|
isHovered,
|
|
13888
14050
|
isSelected,
|
|
13889
14051
|
handlers
|
|
13890
14052
|
} = useTreeObjSelection(drawingId, objectId);
|
|
13891
14053
|
const color = isHovered ? 0x28d79f : isSelected ? 0xa70b0b : 0x111111;
|
|
13892
|
-
|
|
13893
|
-
|
|
13894
|
-
|
|
13895
|
-
position: position
|
|
13896
|
-
}, /*#__PURE__*/React__default.createElement(OriginPoint, {
|
|
14054
|
+
return /*#__PURE__*/React__default.createElement(HUD, null, /*#__PURE__*/React__default.createElement(WorkPointObj, {
|
|
14055
|
+
drawingId: drawingId,
|
|
14056
|
+
objectId: objectId,
|
|
13897
14057
|
color: color,
|
|
14058
|
+
userData: {
|
|
14059
|
+
onHUD: true
|
|
14060
|
+
},
|
|
13898
14061
|
handlers: handlers
|
|
13899
|
-
}))
|
|
14062
|
+
}));
|
|
13900
14063
|
};
|
|
13901
14064
|
|
|
13902
14065
|
const View$a = ({
|
|
@@ -14378,6 +14541,37 @@ const Root$b = ({
|
|
|
14378
14541
|
}));
|
|
14379
14542
|
};
|
|
14380
14543
|
|
|
14544
|
+
const WorkCoordSystemObj = ({
|
|
14545
|
+
drawingId,
|
|
14546
|
+
objectId,
|
|
14547
|
+
color,
|
|
14548
|
+
opacity = 1,
|
|
14549
|
+
userData,
|
|
14550
|
+
handlers
|
|
14551
|
+
}) => {
|
|
14552
|
+
const coordSys = useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
|
|
14553
|
+
const matrix = React__default.useMemo(() => {
|
|
14554
|
+
var _coordSys$children, _coordSys$members;
|
|
14555
|
+
|
|
14556
|
+
const tree = getDrawing(drawingId).structure.tree;
|
|
14557
|
+
const children = (coordSys == null ? void 0 : (_coordSys$children = coordSys.children) == null ? void 0 : _coordSys$children.map(id => tree[id])) || [];
|
|
14558
|
+
const pos = convertToVector(coordSys == null ? void 0 : (_coordSys$members = coordSys.members) == null ? void 0 : _coordSys$members.Position);
|
|
14559
|
+
const [xAxis, yAxis, zAxis] = ['xAxis', 'yAxis', 'zAxis'].map(name => children.find(child => child.name === name)).map(axis => {
|
|
14560
|
+
var _axis$members;
|
|
14561
|
+
|
|
14562
|
+
return convertToVector(axis == null ? void 0 : (_axis$members = axis.members) == null ? void 0 : _axis$members.Direction);
|
|
14563
|
+
});
|
|
14564
|
+
return new THREE.Matrix4().makeBasis(xAxis, yAxis, zAxis).setPosition(pos);
|
|
14565
|
+
}, [drawingId, coordSys]);
|
|
14566
|
+
return /*#__PURE__*/React__default.createElement(Csys, {
|
|
14567
|
+
matrix: matrix,
|
|
14568
|
+
color: color,
|
|
14569
|
+
opacity: opacity,
|
|
14570
|
+
userData: userData,
|
|
14571
|
+
handlers: handlers
|
|
14572
|
+
});
|
|
14573
|
+
};
|
|
14574
|
+
|
|
14381
14575
|
const tolerance = 1e-6; // Calculates a transformation matrix
|
|
14382
14576
|
// xDir and yDir are NOT orthogonal in general case, thus the y-axis is calculated as a series of cross products
|
|
14383
14577
|
|
|
@@ -14412,20 +14606,6 @@ function ViewImpl$9({
|
|
|
14412
14606
|
objectId
|
|
14413
14607
|
} = usePlugin(drawingId, pluginId, pluginState => pluginState);
|
|
14414
14608
|
const isActive = useDrawing(drawingId, drawing => drawing.plugin.active.feature === pluginId);
|
|
14415
|
-
const coordSys = useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
|
|
14416
|
-
const matrix = React__default.useMemo(() => {
|
|
14417
|
-
var _coordSys$children, _coordSys$members;
|
|
14418
|
-
|
|
14419
|
-
const tree = getDrawing(drawingId).structure.tree;
|
|
14420
|
-
const children = ((_coordSys$children = coordSys.children) == null ? void 0 : _coordSys$children.map(id => tree[id])) || [];
|
|
14421
|
-
const pos = convertToVector((_coordSys$members = coordSys.members) == null ? void 0 : _coordSys$members.Position);
|
|
14422
|
-
const [xAxis, yAxis, zAxis] = ['xAxis', 'yAxis', 'zAxis'].map(name => children.find(child => child.name === name)).map(axis => {
|
|
14423
|
-
var _axis$members;
|
|
14424
|
-
|
|
14425
|
-
return convertToVector(axis == null ? void 0 : (_axis$members = axis.members) == null ? void 0 : _axis$members.Direction);
|
|
14426
|
-
});
|
|
14427
|
-
return new THREE.Matrix4().makeBasis(xAxis, yAxis, zAxis).setPosition(pos);
|
|
14428
|
-
}, [drawingId, coordSys]);
|
|
14429
14609
|
const {
|
|
14430
14610
|
originPos,
|
|
14431
14611
|
xDir,
|
|
@@ -14448,11 +14628,14 @@ function ViewImpl$9({
|
|
|
14448
14628
|
// undefined means default color which defined in Csys component.
|
|
14449
14629
|
|
|
14450
14630
|
const color = isHovered ? 0x28d79f : isSelected ? 0xa70b0b : undefined;
|
|
14451
|
-
return /*#__PURE__*/React__default.createElement(HUD, null, /*#__PURE__*/React__default.createElement("group", null, /*#__PURE__*/React__default.createElement(
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
|
|
14631
|
+
return /*#__PURE__*/React__default.createElement(HUD, null, /*#__PURE__*/React__default.createElement("group", null, /*#__PURE__*/React__default.createElement(WorkCoordSystemObj, {
|
|
14632
|
+
drawingId: drawingId,
|
|
14633
|
+
objectId: objectId,
|
|
14634
|
+
color: color,
|
|
14635
|
+
userData: {
|
|
14636
|
+
onHUD: true
|
|
14637
|
+
},
|
|
14638
|
+
handlers: handlers
|
|
14456
14639
|
}), isActive && /*#__PURE__*/React__default.createElement(Csys, {
|
|
14457
14640
|
matrix: previewMatrix,
|
|
14458
14641
|
opacity: 0.5,
|
|
@@ -15493,9 +15676,9 @@ const MatePathTransform = ({
|
|
|
15493
15676
|
}) => {
|
|
15494
15677
|
const refId = matePath[currentDepth];
|
|
15495
15678
|
const csys = useDrawing(drawingId, drawing => {
|
|
15496
|
-
var _drawing$structure$
|
|
15679
|
+
var _drawing$structure$tr;
|
|
15497
15680
|
|
|
15498
|
-
return (_drawing$structure$
|
|
15681
|
+
return (_drawing$structure$tr = drawing.structure.tree[refId]) == null ? void 0 : _drawing$structure$tr.coordinateSystem;
|
|
15499
15682
|
});
|
|
15500
15683
|
const matrix_ = React__default.useMemo(() => {
|
|
15501
15684
|
if (!csys) {
|
|
@@ -15691,7 +15874,8 @@ const CSysDisplayImpl = ({
|
|
|
15691
15874
|
csysId,
|
|
15692
15875
|
matePath,
|
|
15693
15876
|
flip: FlipType.FLIP_Z,
|
|
15694
|
-
reoriented: ReorientedType.REORIENTED_0
|
|
15877
|
+
reoriented: ReorientedType.REORIENTED_0,
|
|
15878
|
+
onHUD: true
|
|
15695
15879
|
};
|
|
15696
15880
|
|
|
15697
15881
|
if (!isCSysUnique(csysUserData, hoveredCSysIds_)) {
|
|
@@ -15754,7 +15938,8 @@ const CSysDisplayImpl = ({
|
|
|
15754
15938
|
flip: item.data.flip,
|
|
15755
15939
|
reoriented: item.data.reoriented,
|
|
15756
15940
|
isSelected: true,
|
|
15757
|
-
isActive: activeSelItems.findIndex(item_ => item_.id === item.id) !== -1
|
|
15941
|
+
isActive: activeSelItems.findIndex(item_ => item_.id === item.id) !== -1,
|
|
15942
|
+
onHUD: true
|
|
15758
15943
|
});
|
|
15759
15944
|
});
|
|
15760
15945
|
const ids = hoveredOnly ? hoveredProductIds : activeProducts;
|
|
@@ -15785,7 +15970,8 @@ const CSysDisplayImpl = ({
|
|
|
15785
15970
|
}, csysUDataArray_)) {
|
|
15786
15971
|
csysUDataArray_.push({
|
|
15787
15972
|
csysId,
|
|
15788
|
-
matePath
|
|
15973
|
+
matePath,
|
|
15974
|
+
onHUD: true
|
|
15789
15975
|
});
|
|
15790
15976
|
}
|
|
15791
15977
|
});
|
|
@@ -18351,18 +18537,24 @@ const mateNames$1 = ['firstRefMate', 'secondRefMate'];
|
|
|
18351
18537
|
const getCSysKey = uData => uData.csysId.toString() + ', ' + uData.matePath.toString();
|
|
18352
18538
|
|
|
18353
18539
|
const HoveredConstraintDisplay = ({
|
|
18354
|
-
drawingId
|
|
18355
|
-
hoveredId
|
|
18540
|
+
drawingId
|
|
18356
18541
|
}) => {
|
|
18542
|
+
const hoveredId = useDrawing(drawingId, d => {
|
|
18543
|
+
var _d$interaction$hovere;
|
|
18544
|
+
|
|
18545
|
+
return (_d$interaction$hovere = d.interaction.hovered) == null ? void 0 : _d$interaction$hovere.objectId;
|
|
18546
|
+
}) || NOCCID;
|
|
18547
|
+
const hoveredObj = useDrawing(drawingId, d => d.structure.tree[hoveredId]);
|
|
18548
|
+
const hoveredConstrId = ccUtils.base.isA((hoveredObj == null ? void 0 : hoveredObj.class) || '', CCClasses.CCHLConstraint) ? hoveredId : null;
|
|
18357
18549
|
const csysUDataArray = React__default.useMemo(() => {
|
|
18358
18550
|
var _getDrawing, _getDrawing$structure;
|
|
18359
18551
|
|
|
18360
|
-
if (!
|
|
18552
|
+
if (!hoveredConstrId) {
|
|
18361
18553
|
return [];
|
|
18362
18554
|
}
|
|
18363
18555
|
|
|
18364
18556
|
const csysUDataArray_ = [];
|
|
18365
|
-
const members = (_getDrawing = getDrawing(drawingId)) == null ? void 0 : (_getDrawing$structure = _getDrawing.structure.tree[
|
|
18557
|
+
const members = (_getDrawing = getDrawing(drawingId)) == null ? void 0 : (_getDrawing$structure = _getDrawing.structure.tree[hoveredConstrId]) == null ? void 0 : _getDrawing$structure.members;
|
|
18366
18558
|
|
|
18367
18559
|
if (members && members[mateNames$1[0]]) {
|
|
18368
18560
|
mateNames$1.forEach(mateName => {
|
|
@@ -18371,28 +18563,678 @@ const HoveredConstraintDisplay = ({
|
|
|
18371
18563
|
if (member && member.members.length > 2) {
|
|
18372
18564
|
var _member$members$, _member$members$2;
|
|
18373
18565
|
|
|
18374
|
-
const matePath = member.members[0].members.map(memb => memb.value);
|
|
18375
|
-
const csysId = member.members[1].value;
|
|
18376
|
-
const flip = ((_member$members$ = member.members[2]) == null ? void 0 : _member$members$.value) !== undefined ? member.members[2].value : FlipType.FLIP_Z;
|
|
18377
|
-
const reoriented = ((_member$members$2 = member.members[3]) == null ? void 0 : _member$members$2.value) !== undefined ? member.members[3].value : ReorientedType.REORIENTED_0;
|
|
18378
|
-
csysUDataArray_.push({
|
|
18379
|
-
matePath,
|
|
18380
|
-
csysId,
|
|
18381
|
-
flip,
|
|
18382
|
-
reoriented,
|
|
18383
|
-
isSelected: true
|
|
18384
|
-
|
|
18385
|
-
|
|
18386
|
-
|
|
18387
|
-
|
|
18566
|
+
const matePath = member.members[0].members.map(memb => memb.value);
|
|
18567
|
+
const csysId = member.members[1].value;
|
|
18568
|
+
const flip = ((_member$members$ = member.members[2]) == null ? void 0 : _member$members$.value) !== undefined ? member.members[2].value : FlipType.FLIP_Z;
|
|
18569
|
+
const reoriented = ((_member$members$2 = member.members[3]) == null ? void 0 : _member$members$2.value) !== undefined ? member.members[3].value : ReorientedType.REORIENTED_0;
|
|
18570
|
+
csysUDataArray_.push({
|
|
18571
|
+
matePath,
|
|
18572
|
+
csysId,
|
|
18573
|
+
flip,
|
|
18574
|
+
reoriented,
|
|
18575
|
+
isSelected: true,
|
|
18576
|
+
onHUD: true
|
|
18577
|
+
});
|
|
18578
|
+
}
|
|
18579
|
+
});
|
|
18580
|
+
}
|
|
18581
|
+
|
|
18582
|
+
return csysUDataArray_;
|
|
18583
|
+
}, [drawingId, hoveredConstrId]);
|
|
18584
|
+
return /*#__PURE__*/React__default.createElement(HUD, null, /*#__PURE__*/React__default.createElement("group", null, csysUDataArray.map(userData => /*#__PURE__*/React__default.createElement(CSysWrapper, {
|
|
18585
|
+
key: getCSysKey(userData),
|
|
18586
|
+
drawingId: drawingId,
|
|
18587
|
+
userData: userData
|
|
18588
|
+
}))));
|
|
18589
|
+
};
|
|
18590
|
+
|
|
18591
|
+
const SelectedMateObj = ({
|
|
18592
|
+
drawingId,
|
|
18593
|
+
csysId,
|
|
18594
|
+
matePath,
|
|
18595
|
+
flip,
|
|
18596
|
+
color,
|
|
18597
|
+
reoriented,
|
|
18598
|
+
opacity
|
|
18599
|
+
}) => {
|
|
18600
|
+
const currentNode = useDrawing(drawingId, drawing => drawing.structure.currentNode);
|
|
18601
|
+
const matrix = useCsysMatrix(drawingId, csysId, flip, reoriented);
|
|
18602
|
+
return /*#__PURE__*/React__default.createElement(GlobalTransform, {
|
|
18603
|
+
drawingId: drawingId,
|
|
18604
|
+
objectId: currentNode
|
|
18605
|
+
}, /*#__PURE__*/React__default.createElement(MatePathTransform, {
|
|
18606
|
+
drawingId: drawingId,
|
|
18607
|
+
matePath: matePath
|
|
18608
|
+
}, /*#__PURE__*/React__default.createElement(SelectedCsys, {
|
|
18609
|
+
matrix: matrix,
|
|
18610
|
+
color: color,
|
|
18611
|
+
opacity: opacity
|
|
18612
|
+
})));
|
|
18613
|
+
};
|
|
18614
|
+
|
|
18615
|
+
const vertexCode$1 = `
|
|
18616
|
+
uniform mat4 modelViewMatrix;
|
|
18617
|
+
uniform mat4 projectionMatrix;
|
|
18618
|
+
|
|
18619
|
+
attribute vec3 position;
|
|
18620
|
+
|
|
18621
|
+
void main() {
|
|
18622
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
18623
|
+
}
|
|
18624
|
+
`;
|
|
18625
|
+
const fragmentCode$2 = `
|
|
18626
|
+
uniform lowp vec3 idColor;
|
|
18627
|
+
|
|
18628
|
+
void main() {
|
|
18629
|
+
gl_FragColor.rgb = idColor;
|
|
18630
|
+
}
|
|
18631
|
+
`;
|
|
18632
|
+
class IDPass extends Pass {
|
|
18633
|
+
constructor(scene, camera) {
|
|
18634
|
+
super('IDPass', scene, camera);
|
|
18635
|
+
|
|
18636
|
+
_defineProperty(this, "material", void 0);
|
|
18637
|
+
|
|
18638
|
+
_defineProperty(this, "oldMaterials", void 0);
|
|
18639
|
+
|
|
18640
|
+
_defineProperty(this, "selection", void 0);
|
|
18641
|
+
|
|
18642
|
+
_defineProperty(this, "id", void 0);
|
|
18643
|
+
|
|
18644
|
+
_defineProperty(this, "channel", void 0);
|
|
18645
|
+
|
|
18646
|
+
this.needsSwap = false;
|
|
18647
|
+
this.material = new THREE.RawShaderMaterial({
|
|
18648
|
+
uniforms: {
|
|
18649
|
+
idColor: new THREE.Uniform(new THREE.Color(0xff0000))
|
|
18650
|
+
},
|
|
18651
|
+
depthWrite: false,
|
|
18652
|
+
depthTest: false,
|
|
18653
|
+
vertexShader: vertexCode$1,
|
|
18654
|
+
fragmentShader: fragmentCode$2
|
|
18655
|
+
});
|
|
18656
|
+
this.oldMaterials = new Map();
|
|
18657
|
+
this.selection = new Selection();
|
|
18658
|
+
this.id = 0;
|
|
18659
|
+
this.channel = 0;
|
|
18660
|
+
}
|
|
18661
|
+
|
|
18662
|
+
render(renderer, inputBuffer) {
|
|
18663
|
+
const scene = this.scene;
|
|
18664
|
+
const camera = this.camera;
|
|
18665
|
+
const mask = camera.layers.mask;
|
|
18666
|
+
const background = scene.background;
|
|
18667
|
+
const shadowMapAutoUpdate = renderer.shadowMap.autoUpdate;
|
|
18668
|
+
renderer.shadowMap.autoUpdate = false;
|
|
18669
|
+
scene.background = null;
|
|
18670
|
+
const color = [0.0, 0.0, 0.0];
|
|
18671
|
+
color[this.channel] = (this.id + 1) / 255.0;
|
|
18672
|
+
this.material.uniforms.idColor.value = new THREE.Color(...color);
|
|
18673
|
+
this.selection.forEach(mesh_ => {
|
|
18674
|
+
const mesh = mesh_;
|
|
18675
|
+
this.oldMaterials.set(mesh, mesh.material);
|
|
18676
|
+
mesh.material = this.material;
|
|
18677
|
+
});
|
|
18678
|
+
renderer.setRenderTarget(inputBuffer);
|
|
18679
|
+
renderer.render(scene, camera);
|
|
18680
|
+
|
|
18681
|
+
for (const entry of this.oldMaterials) {
|
|
18682
|
+
entry[0].material = entry[1];
|
|
18683
|
+
}
|
|
18684
|
+
|
|
18685
|
+
this.oldMaterials.clear();
|
|
18686
|
+
camera.layers.mask = mask;
|
|
18687
|
+
scene.background = background;
|
|
18688
|
+
renderer.shadowMap.autoUpdate = shadowMapAutoUpdate;
|
|
18689
|
+
}
|
|
18690
|
+
|
|
18691
|
+
}
|
|
18692
|
+
|
|
18693
|
+
const vertexCode = `
|
|
18694
|
+
uniform vec2 texelSize;
|
|
18695
|
+
|
|
18696
|
+
varying vec2 vUv0;
|
|
18697
|
+
varying vec2 vUv1;
|
|
18698
|
+
varying vec2 vUv2;
|
|
18699
|
+
varying vec2 vUv3;
|
|
18700
|
+
|
|
18701
|
+
void main() {
|
|
18702
|
+
vec2 uv = position.xy * 0.5 + 0.5;
|
|
18703
|
+
|
|
18704
|
+
vUv0 = vec2(uv.x + texelSize.x, uv.y);
|
|
18705
|
+
vUv1 = vec2(uv.x - texelSize.x, uv.y);
|
|
18706
|
+
vUv2 = vec2(uv.x, uv.y + texelSize.y);
|
|
18707
|
+
vUv3 = vec2(uv.x, uv.y - texelSize.y);
|
|
18708
|
+
|
|
18709
|
+
gl_Position = vec4(position.xy, 1.0, 1.0);
|
|
18710
|
+
}
|
|
18711
|
+
`;
|
|
18712
|
+
const fragmentCode$1 = `
|
|
18713
|
+
uniform lowp sampler2D inputBuffer;
|
|
18714
|
+
|
|
18715
|
+
varying vec2 vUv0;
|
|
18716
|
+
varying vec2 vUv1;
|
|
18717
|
+
varying vec2 vUv2;
|
|
18718
|
+
varying vec2 vUv3;
|
|
18719
|
+
|
|
18720
|
+
void main() {
|
|
18721
|
+
vec3 c0 = texture2D(inputBuffer, vUv0).rgb;
|
|
18722
|
+
vec3 c1 = texture2D(inputBuffer, vUv1).rgb;
|
|
18723
|
+
vec3 c2 = texture2D(inputBuffer, vUv2).rgb;
|
|
18724
|
+
vec3 c3 = texture2D(inputBuffer, vUv3).rgb;
|
|
18725
|
+
|
|
18726
|
+
if (c0 == c1 && c0 == c2 && c0 == c3) {
|
|
18727
|
+
discard;
|
|
18728
|
+
}
|
|
18729
|
+
|
|
18730
|
+
vec3 maxVec = max(max(c0, c1), max(c2, c3));
|
|
18731
|
+
vec2 kVec = vec2(1.0, 1.0) - step(maxVec.gb, vec2(0.0, 0.0));
|
|
18732
|
+
float k3 = kVec.g;
|
|
18733
|
+
float k2 = (1.0 - k3) * kVec.r;
|
|
18734
|
+
float k1 = (1.0 - k3) * (1.0 - k2);
|
|
18735
|
+
|
|
18736
|
+
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);
|
|
18737
|
+
}
|
|
18738
|
+
`;
|
|
18739
|
+
class OutlineMaterial extends THREE.ShaderMaterial {
|
|
18740
|
+
constructor(texelSize = new THREE.Vector2()) {
|
|
18741
|
+
super({
|
|
18742
|
+
name: "OutlineMaterial",
|
|
18743
|
+
uniforms: {
|
|
18744
|
+
inputBuffer: new THREE.Uniform(null),
|
|
18745
|
+
texelSize: new THREE.Uniform(new THREE.Vector2()),
|
|
18746
|
+
channel: new THREE.Uniform(new THREE.Color(0xff0000))
|
|
18747
|
+
},
|
|
18748
|
+
blending: THREE.NoBlending,
|
|
18749
|
+
depthWrite: false,
|
|
18750
|
+
depthTest: false,
|
|
18751
|
+
vertexShader: vertexCode,
|
|
18752
|
+
fragmentShader: fragmentCode$1
|
|
18753
|
+
});
|
|
18754
|
+
this.toneMapped = false;
|
|
18755
|
+
this.setTexelSize(texelSize.x, texelSize.y);
|
|
18756
|
+
this.uniforms.maskTexture = this.uniforms.inputBuffer;
|
|
18757
|
+
}
|
|
18758
|
+
|
|
18759
|
+
set inputBuffer(value) {
|
|
18760
|
+
this.uniforms.inputBuffer.value = value;
|
|
18761
|
+
}
|
|
18762
|
+
|
|
18763
|
+
setTexelSize(x, y) {
|
|
18764
|
+
this.uniforms.texelSize.value.set(x, y);
|
|
18765
|
+
}
|
|
18766
|
+
|
|
18767
|
+
setSize(width, height) {
|
|
18768
|
+
this.uniforms.texelSize.value.set(1.0 / width, 1.0 / height);
|
|
18769
|
+
}
|
|
18770
|
+
|
|
18771
|
+
}
|
|
18772
|
+
|
|
18773
|
+
const fragmentCode = `
|
|
18774
|
+
uniform lowp sampler2D edgeTexture;
|
|
18775
|
+
|
|
18776
|
+
uniform float edgeStrength;
|
|
18777
|
+
uniform vec3 edgeColor1;
|
|
18778
|
+
uniform vec3 edgeColor2;
|
|
18779
|
+
uniform vec3 edgeColor3;
|
|
18780
|
+
|
|
18781
|
+
void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
|
|
18782
|
+
vec3 edge = texture2D(edgeTexture, uv).rgb * edgeStrength;
|
|
18783
|
+
|
|
18784
|
+
vec4 kVec = vec4(1.0, 1.0, 1.0, 1.0) - step(edge.bbgg, edge.rgrb);
|
|
18785
|
+
float k3 = kVec.r * kVec.g;
|
|
18786
|
+
float k2 = (1.0 - k3) * kVec.b * kVec.a;
|
|
18787
|
+
float k1 = (1.0 - k3) * (1.0 - k2);
|
|
18788
|
+
vec3 color = k1 * edgeColor1 + k2 * edgeColor2 + k3 * edgeColor3;
|
|
18789
|
+
|
|
18790
|
+
float alpha = 3.0 * max(max(edge.r, edge.g), edge.b) - 2.0;
|
|
18791
|
+
alpha *= step(0.4, alpha);
|
|
18792
|
+
|
|
18793
|
+
outputColor = vec4(color, alpha);
|
|
18794
|
+
}
|
|
18795
|
+
`;
|
|
18796
|
+
class OutlineEffect extends Effect {
|
|
18797
|
+
constructor(scene, camera, {
|
|
18798
|
+
edgeStrength = 1.0,
|
|
18799
|
+
edgeColor1 = 0xffffff,
|
|
18800
|
+
edgeColor2 = 0xffffff,
|
|
18801
|
+
edgeColor3 = 0xffffff,
|
|
18802
|
+
resolutionScale = 1.0,
|
|
18803
|
+
width = Resolution.AUTO_SIZE,
|
|
18804
|
+
height = Resolution.AUTO_SIZE,
|
|
18805
|
+
kernelSize = KernelSize.VERY_SMALL
|
|
18806
|
+
} = {}) {
|
|
18807
|
+
super("OutlineEffect", fragmentCode, {
|
|
18808
|
+
uniforms: new Map([["edgeTexture", new THREE.Uniform(null)], ["edgeStrength", new THREE.Uniform(edgeStrength)], ["edgeColor1", new THREE.Uniform(new THREE.Color(edgeColor1))], ["edgeColor2", new THREE.Uniform(new THREE.Color(edgeColor2))], ["edgeColor3", new THREE.Uniform(new THREE.Color(edgeColor3))]])
|
|
18809
|
+
});
|
|
18810
|
+
|
|
18811
|
+
_defineProperty(this, "scene", void 0);
|
|
18812
|
+
|
|
18813
|
+
_defineProperty(this, "camera", void 0);
|
|
18814
|
+
|
|
18815
|
+
_defineProperty(this, "idRT", void 0);
|
|
18816
|
+
|
|
18817
|
+
_defineProperty(this, "outlineRT", void 0);
|
|
18818
|
+
|
|
18819
|
+
_defineProperty(this, "clearPass", void 0);
|
|
18820
|
+
|
|
18821
|
+
_defineProperty(this, "idPass", void 0);
|
|
18822
|
+
|
|
18823
|
+
_defineProperty(this, "outlinePass", void 0);
|
|
18824
|
+
|
|
18825
|
+
_defineProperty(this, "blurPass", void 0);
|
|
18826
|
+
|
|
18827
|
+
_defineProperty(this, "selections1", void 0);
|
|
18828
|
+
|
|
18829
|
+
_defineProperty(this, "selections2", void 0);
|
|
18830
|
+
|
|
18831
|
+
_defineProperty(this, "selections3", void 0);
|
|
18832
|
+
|
|
18833
|
+
_defineProperty(this, "time", void 0);
|
|
18834
|
+
|
|
18835
|
+
_defineProperty(this, "processSelection", void 0);
|
|
18836
|
+
|
|
18837
|
+
this.blendMode.setBlendFunction(BlendFunction.ALPHA);
|
|
18838
|
+
this.scene = scene;
|
|
18839
|
+
this.camera = camera;
|
|
18840
|
+
this.idRT = new THREE.WebGLRenderTarget(1, 1, {
|
|
18841
|
+
minFilter: THREE.NearestFilter,
|
|
18842
|
+
magFilter: THREE.NearestFilter,
|
|
18843
|
+
depthBuffer: false,
|
|
18844
|
+
stencilBuffer: false
|
|
18845
|
+
});
|
|
18846
|
+
this.idRT.texture.name = "Outline.IDs";
|
|
18847
|
+
this.outlineRT = new THREE.WebGLRenderTarget(1, 1, {
|
|
18848
|
+
minFilter: THREE.LinearFilter,
|
|
18849
|
+
magFilter: THREE.LinearFilter,
|
|
18850
|
+
depthBuffer: false,
|
|
18851
|
+
stencilBuffer: false
|
|
18852
|
+
});
|
|
18853
|
+
this.outlineRT.texture.name = "Outline.Edges";
|
|
18854
|
+
const edgeTexture = this.uniforms.get("edgeTexture");
|
|
18855
|
+
edgeTexture.value = this.outlineRT.texture;
|
|
18856
|
+
this.clearPass = new ClearPass();
|
|
18857
|
+
this.clearPass.overrideClearColor = new THREE.Color(0x000000);
|
|
18858
|
+
this.clearPass.overrideClearAlpha = 0;
|
|
18859
|
+
this.idPass = new IDPass(scene, camera);
|
|
18860
|
+
this.outlinePass = new ShaderPass(new OutlineMaterial());
|
|
18861
|
+
const outlineMaterial = this.outlinePass.fullscreenMaterial;
|
|
18862
|
+
outlineMaterial.inputBuffer = this.idRT.texture;
|
|
18863
|
+
this.blurPass = new KawaseBlurPass({
|
|
18864
|
+
resolutionScale,
|
|
18865
|
+
width,
|
|
18866
|
+
height,
|
|
18867
|
+
kernelSize
|
|
18868
|
+
});
|
|
18869
|
+
const resolution = this.blurPass.resolution;
|
|
18870
|
+
resolution.addEventListener("change", e => this.setSize(resolution.baseWidth, resolution.baseHeight));
|
|
18871
|
+
this.time = 0;
|
|
18872
|
+
this.selections1 = [];
|
|
18873
|
+
this.selections2 = [];
|
|
18874
|
+
this.selections3 = [];
|
|
18875
|
+
|
|
18876
|
+
this.processSelection = (renderer, selection, id) => {
|
|
18877
|
+
selection.layer++;
|
|
18878
|
+
this.idPass.id = id;
|
|
18879
|
+
this.idPass.selection = selection;
|
|
18880
|
+
this.idPass.render(renderer, this.idRT);
|
|
18881
|
+
selection.layer--;
|
|
18882
|
+
this.outlinePass.render(renderer, null, this.outlineRT);
|
|
18883
|
+
};
|
|
18884
|
+
}
|
|
18885
|
+
|
|
18886
|
+
set selectionLayer(value) {
|
|
18887
|
+
this.selections1.forEach(selection => {
|
|
18888
|
+
selection.layer = value;
|
|
18889
|
+
});
|
|
18890
|
+
this.selections2.forEach(selection => {
|
|
18891
|
+
selection.layer = value;
|
|
18892
|
+
});
|
|
18893
|
+
this.selections3.forEach(selection => {
|
|
18894
|
+
selection.layer = value;
|
|
18895
|
+
});
|
|
18896
|
+
}
|
|
18897
|
+
|
|
18898
|
+
update(renderer, inputBuffer, deltaTime) {
|
|
18899
|
+
const scene = this.scene;
|
|
18900
|
+
const camera = this.camera;
|
|
18901
|
+
const selections1 = this.selections1;
|
|
18902
|
+
const selections2 = this.selections2;
|
|
18903
|
+
const selections3 = this.selections3;
|
|
18904
|
+
const background = scene.background;
|
|
18905
|
+
const mask = camera.layers.mask;
|
|
18906
|
+
|
|
18907
|
+
if (selections1.length > 0 || selections2.length > 0 || selections3.length > 0) {
|
|
18908
|
+
var _selections1$, _selections2$, _selections3$;
|
|
18909
|
+
|
|
18910
|
+
scene.background = null;
|
|
18911
|
+
this.time += deltaTime;
|
|
18912
|
+
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);
|
|
18913
|
+
camera.layers.set(layer + 1);
|
|
18914
|
+
this.clearPass.render(renderer, this.idRT, null);
|
|
18915
|
+
this.clearPass.render(renderer, this.outlineRT, null);
|
|
18916
|
+
let len = Math.min(this.selections1.length, 255);
|
|
18917
|
+
this.idPass.channel = 0;
|
|
18918
|
+
|
|
18919
|
+
for (let i = 0; i < len; i++) {
|
|
18920
|
+
this.processSelection(renderer, selections1[i], i);
|
|
18921
|
+
}
|
|
18922
|
+
|
|
18923
|
+
len = Math.min(this.selections2.length, 255);
|
|
18924
|
+
this.idPass.channel = 1;
|
|
18925
|
+
|
|
18926
|
+
for (let i = 0; i < len; i++) {
|
|
18927
|
+
this.processSelection(renderer, selections2[i], i);
|
|
18928
|
+
}
|
|
18929
|
+
|
|
18930
|
+
len = Math.min(this.selections3.length, 255);
|
|
18931
|
+
this.idPass.channel = 2;
|
|
18932
|
+
|
|
18933
|
+
for (let i = 0; i < len; i++) {
|
|
18934
|
+
this.processSelection(renderer, selections3[i], i);
|
|
18935
|
+
} // Restore the camera layer mask and the scene background.
|
|
18936
|
+
|
|
18937
|
+
|
|
18938
|
+
camera.layers.mask = mask;
|
|
18939
|
+
scene.background = background;
|
|
18940
|
+
|
|
18941
|
+
if (this.blurPass.enabled) {
|
|
18942
|
+
this.blurPass.render(renderer, this.outlineRT, this.outlineRT);
|
|
18943
|
+
}
|
|
18944
|
+
} else if (this.time > 0) {
|
|
18945
|
+
this.clearPass.render(renderer, this.idRT, null);
|
|
18946
|
+
this.clearPass.render(renderer, this.outlineRT, null);
|
|
18947
|
+
this.time = 0;
|
|
18948
|
+
}
|
|
18949
|
+
}
|
|
18950
|
+
|
|
18951
|
+
setSize(width, height) {
|
|
18952
|
+
this.blurPass.setSize(width, height);
|
|
18953
|
+
this.idRT.setSize(width, height);
|
|
18954
|
+
const resolution = this.blurPass.resolution;
|
|
18955
|
+
resolution.setBaseSize(width, height);
|
|
18956
|
+
const w = resolution.width,
|
|
18957
|
+
h = resolution.height;
|
|
18958
|
+
this.outlineRT.setSize(w, h);
|
|
18959
|
+
const outlineMaterial = this.outlinePass.fullscreenMaterial;
|
|
18960
|
+
outlineMaterial.setSize(w, h);
|
|
18961
|
+
}
|
|
18962
|
+
|
|
18963
|
+
initialize(renderer, alpha, frameBufferType) {
|
|
18964
|
+
// No need for high precision: the blur pass operates on a mask texture.
|
|
18965
|
+
this.blurPass.initialize(renderer, alpha, THREE.UnsignedByteType);
|
|
18966
|
+
|
|
18967
|
+
if (frameBufferType !== undefined) {
|
|
18968
|
+
// These passes ignore the buffer type.
|
|
18969
|
+
this.idPass.initialize(renderer, alpha, frameBufferType);
|
|
18970
|
+
this.outlinePass.initialize(renderer, alpha, frameBufferType);
|
|
18971
|
+
}
|
|
18972
|
+
}
|
|
18973
|
+
|
|
18974
|
+
}
|
|
18975
|
+
|
|
18976
|
+
const _excluded$2 = ["selections1", "selections2", "selections3", "selectionLayer", "edgeStrength", "edgeColor1", "edgeColor2", "edgeColor3", "width", "height", "kernelSize"];
|
|
18977
|
+
const Outline = /*#__PURE__*/React__default.forwardRef(function Outline(_ref, forwardRef) {
|
|
18978
|
+
let {
|
|
18979
|
+
selections1 = [],
|
|
18980
|
+
selections2 = [],
|
|
18981
|
+
selections3 = [],
|
|
18982
|
+
selectionLayer = 10,
|
|
18983
|
+
edgeStrength,
|
|
18984
|
+
edgeColor1,
|
|
18985
|
+
edgeColor2,
|
|
18986
|
+
edgeColor3,
|
|
18987
|
+
width,
|
|
18988
|
+
height,
|
|
18989
|
+
kernelSize
|
|
18990
|
+
} = _ref;
|
|
18991
|
+
_objectWithoutProperties(_ref, _excluded$2);
|
|
18992
|
+
|
|
18993
|
+
const invalidate = useThree(state => state.invalidate);
|
|
18994
|
+
const {
|
|
18995
|
+
scene,
|
|
18996
|
+
camera
|
|
18997
|
+
} = useThree();
|
|
18998
|
+
const effect = React__default.useMemo(() => new OutlineEffect(scene, camera, {
|
|
18999
|
+
edgeStrength,
|
|
19000
|
+
edgeColor1,
|
|
19001
|
+
edgeColor2,
|
|
19002
|
+
edgeColor3,
|
|
19003
|
+
width,
|
|
19004
|
+
height,
|
|
19005
|
+
kernelSize
|
|
19006
|
+
}), [scene, camera, edgeStrength, edgeColor1, edgeColor2, edgeColor3, width, height, kernelSize]);
|
|
19007
|
+
React__default.useEffect(() => {
|
|
19008
|
+
if (selections1) {
|
|
19009
|
+
effect.selections1 = selections1.map(selection => new Selection(selection, selectionLayer));
|
|
19010
|
+
invalidate();
|
|
19011
|
+
return () => {
|
|
19012
|
+
effect.selections1.forEach(selection => selection.clear());
|
|
19013
|
+
effect.selections1 = [];
|
|
19014
|
+
invalidate();
|
|
19015
|
+
};
|
|
19016
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19017
|
+
|
|
19018
|
+
}, [effect, selections1]);
|
|
19019
|
+
React__default.useEffect(() => {
|
|
19020
|
+
if (selections2) {
|
|
19021
|
+
effect.selections2 = selections2.map(selection => new Selection(selection, selectionLayer));
|
|
19022
|
+
invalidate();
|
|
19023
|
+
return () => {
|
|
19024
|
+
effect.selections2.forEach(selection => selection.clear());
|
|
19025
|
+
effect.selections2 = [];
|
|
19026
|
+
invalidate();
|
|
19027
|
+
};
|
|
19028
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19029
|
+
|
|
19030
|
+
}, [effect, selections2]);
|
|
19031
|
+
React__default.useEffect(() => {
|
|
19032
|
+
if (selections3) {
|
|
19033
|
+
effect.selections3 = selections3.map(selection => new Selection(selection, selectionLayer));
|
|
19034
|
+
invalidate();
|
|
19035
|
+
return () => {
|
|
19036
|
+
effect.selections3.forEach(selection => selection.clear());
|
|
19037
|
+
effect.selections3 = [];
|
|
19038
|
+
invalidate();
|
|
19039
|
+
};
|
|
19040
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19041
|
+
|
|
19042
|
+
}, [effect, selections3]);
|
|
19043
|
+
React__default.useEffect(() => {
|
|
19044
|
+
effect.selectionLayer = selectionLayer;
|
|
19045
|
+
invalidate();
|
|
19046
|
+
}, [effect, selectionLayer, invalidate]);
|
|
19047
|
+
return /*#__PURE__*/React__default.createElement("primitive", {
|
|
19048
|
+
ref: forwardRef,
|
|
19049
|
+
object: effect
|
|
19050
|
+
});
|
|
19051
|
+
});
|
|
19052
|
+
|
|
19053
|
+
const mateNames = ['firstRefMate', 'secondRefMate'];
|
|
19054
|
+
const getMateRefIds = (drawingId, constrId) => {
|
|
19055
|
+
var _drawing$structure$tr;
|
|
19056
|
+
|
|
19057
|
+
const drawing = getDrawing(drawingId);
|
|
19058
|
+
const members = (_drawing$structure$tr = drawing.structure.tree[constrId]) == null ? void 0 : _drawing$structure$tr.members;
|
|
19059
|
+
const pRefIds = [];
|
|
19060
|
+
|
|
19061
|
+
if (members && members[mateNames[0]]) {
|
|
19062
|
+
mateNames.forEach(mateName => {
|
|
19063
|
+
var _member$members$;
|
|
19064
|
+
|
|
19065
|
+
const member = members[mateName];
|
|
19066
|
+
const matePath = member == null ? void 0 : (_member$members$ = member.members[0]) == null ? void 0 : _member$members$.members;
|
|
19067
|
+
|
|
19068
|
+
if (matePath && matePath.length > 0) {
|
|
19069
|
+
pRefIds.push(matePath[matePath.length - 1].value);
|
|
19070
|
+
}
|
|
19071
|
+
});
|
|
19072
|
+
}
|
|
19073
|
+
|
|
19074
|
+
if (pRefIds.length === 0) {
|
|
19075
|
+
return;
|
|
19076
|
+
}
|
|
19077
|
+
|
|
19078
|
+
const curNodeId = drawing.structure.currentNode;
|
|
19079
|
+
const curNode = drawing.structure.tree[curNodeId];
|
|
19080
|
+
const curRefIds = (curNode == null ? void 0 : curNode.instances) || (curNode == null ? void 0 : curNode.children) || [];
|
|
19081
|
+
const mateRefIds = [];
|
|
19082
|
+
curRefIds.forEach(id => {
|
|
19083
|
+
var _drawing$structure$tr2, _drawing$structure$tr3;
|
|
19084
|
+
|
|
19085
|
+
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;
|
|
19086
|
+
|
|
19087
|
+
if (pRefIds.indexOf(productRefId) !== -1) {
|
|
19088
|
+
mateRefIds.push(id);
|
|
19089
|
+
}
|
|
19090
|
+
});
|
|
19091
|
+
return mateRefIds;
|
|
19092
|
+
};
|
|
19093
|
+
|
|
19094
|
+
const SectionHeader = ({
|
|
19095
|
+
children
|
|
19096
|
+
}) => {
|
|
19097
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
19098
|
+
style: {
|
|
19099
|
+
height: '42px',
|
|
19100
|
+
backgroundColor: '#fafafa',
|
|
19101
|
+
color: 'rgba(0, 0, 0, 0.85)',
|
|
19102
|
+
fontWeight: 500,
|
|
19103
|
+
textAlign: 'left',
|
|
19104
|
+
background: '#fafafa',
|
|
19105
|
+
borderBottom: '1px solid #f0f0f0',
|
|
19106
|
+
padding: '8px 8px',
|
|
19107
|
+
display: 'flex',
|
|
19108
|
+
justifyContent: 'space-between'
|
|
19109
|
+
}
|
|
19110
|
+
}, children);
|
|
19111
|
+
};
|
|
19112
|
+
|
|
19113
|
+
const SolverState = ({
|
|
19114
|
+
drawingId
|
|
19115
|
+
}) => {
|
|
19116
|
+
const rootId = useDrawing(drawingId, d => d.structure.root);
|
|
19117
|
+
const solverState = useDrawing(drawingId, d => {
|
|
19118
|
+
var _d$structure$tree$roo, _d$structure$tree$roo2, _d$structure$tree$roo3;
|
|
19119
|
+
|
|
19120
|
+
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;
|
|
19121
|
+
});
|
|
19122
|
+
const component = solverState === 0 ? /*#__PURE__*/React__default.createElement(CheckCircleTwoTone, {
|
|
19123
|
+
twoToneColor: "#52c41a"
|
|
19124
|
+
}) : /*#__PURE__*/React__default.createElement(CloseCircleTwoTone, {
|
|
19125
|
+
twoToneColor: "#eb2f96"
|
|
19126
|
+
});
|
|
19127
|
+
return solverState === undefined ? null : /*#__PURE__*/React__default.createElement(Tooltip$1, {
|
|
19128
|
+
title: solverState === 0 ? 'Solved' : 'Not Solved'
|
|
19129
|
+
}, component);
|
|
19130
|
+
};
|
|
19131
|
+
/**
|
|
19132
|
+
* Shows list of 3d constraints which are contained by currentProduct.
|
|
19133
|
+
*
|
|
19134
|
+
* @param drawingId - id of a drawing in which currentProduct will be found.
|
|
19135
|
+
* @returns
|
|
19136
|
+
*/
|
|
19137
|
+
|
|
19138
|
+
|
|
19139
|
+
const Constraints = ({
|
|
19140
|
+
drawingId
|
|
19141
|
+
}) => {
|
|
19142
|
+
const curProdId = useDrawing(drawingId, d => d.structure.currentProduct);
|
|
19143
|
+
const prodChildren = useDrawingArr(drawingId, d => {
|
|
19144
|
+
var _d$structure$tree$cur;
|
|
19145
|
+
|
|
19146
|
+
return (_d$structure$tree$cur = d.structure.tree[curProdId]) == null ? void 0 : _d$structure$tree$cur.children;
|
|
19147
|
+
});
|
|
19148
|
+
const constrSetId = React__default.useMemo(() => {
|
|
19149
|
+
const tree = getDrawing(drawingId).structure.tree;
|
|
19150
|
+
return prodChildren.find(childId => tree[childId].class === CCClasses.CCConstraintSet) || null;
|
|
19151
|
+
}, [prodChildren, drawingId]);
|
|
19152
|
+
const constrSet = useDrawing(drawingId, d => d.structure.tree[constrSetId] || null);
|
|
19153
|
+
const constrIds = React__default.useMemo(() => {
|
|
19154
|
+
return (constrSet == null ? void 0 : constrSet.children) || []; // If there is no any constraint, children doesn't exist in constrSet object
|
|
19155
|
+
}, [constrSet]);
|
|
19156
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
19157
|
+
style: {
|
|
19158
|
+
display: 'flex',
|
|
19159
|
+
flexDirection: 'column',
|
|
19160
|
+
height: '100%'
|
|
19161
|
+
}
|
|
19162
|
+
}, /*#__PURE__*/React__default.createElement(SectionHeader, null, /*#__PURE__*/React__default.createElement(FlexRow, null, /*#__PURE__*/React__default.createElement(Space, null, "Constraints", /*#__PURE__*/React__default.createElement(SolverState, {
|
|
19163
|
+
drawingId: drawingId
|
|
19164
|
+
})))), /*#__PURE__*/React__default.createElement("div", {
|
|
19165
|
+
style: {
|
|
19166
|
+
overflow: 'auto'
|
|
19167
|
+
}
|
|
19168
|
+
}, /*#__PURE__*/React__default.createElement(List$2, {
|
|
19169
|
+
drawingId: drawingId,
|
|
19170
|
+
constrIds: constrIds
|
|
19171
|
+
})));
|
|
19172
|
+
};
|
|
19173
|
+
|
|
19174
|
+
const Constraint = ({
|
|
19175
|
+
drawingId,
|
|
19176
|
+
constraintId
|
|
19177
|
+
}) => {
|
|
19178
|
+
const hoveredId = useDrawing(drawingId, d => {
|
|
19179
|
+
var _d$interaction$hovere;
|
|
19180
|
+
|
|
19181
|
+
return (_d$interaction$hovere = d.interaction.hovered) == null ? void 0 : _d$interaction$hovere.objectId;
|
|
19182
|
+
});
|
|
19183
|
+
const name = useDrawing(drawingId, d => {
|
|
19184
|
+
var _d$structure$tree$con;
|
|
19185
|
+
|
|
19186
|
+
return (_d$structure$tree$con = d.structure.tree[constraintId]) == null ? void 0 : _d$structure$tree$con.name;
|
|
19187
|
+
});
|
|
19188
|
+
const isActive = useDrawing(drawingId, d => d.plugin.active.feature === constraintId);
|
|
19189
|
+
const isHovered = hoveredId === constraintId;
|
|
19190
|
+
const [rename, setRename] = React__default.useState(false);
|
|
19191
|
+
const menuItems = useMenuItems$4(drawingId, constraintId, isActive, setRename);
|
|
19192
|
+
const onDoubleClick = React__default.useCallback(() => {
|
|
19193
|
+
getDrawing(drawingId).api.plugin.setActiveFeature(constraintId);
|
|
19194
|
+
}, [drawingId, constraintId]);
|
|
19195
|
+
const onMouseEnter = React__default.useCallback(() => {
|
|
19196
|
+
const setHovered = getDrawing(drawingId).api.interaction.setHovered;
|
|
19197
|
+
const curNodeId = getDrawing(drawingId).structure.currentNode;
|
|
19198
|
+
setHovered(createInfo({
|
|
19199
|
+
objectId: constraintId,
|
|
19200
|
+
prodRefId: curNodeId
|
|
19201
|
+
}));
|
|
19202
|
+
}, [drawingId, constraintId]);
|
|
19203
|
+
const onMouseLeave = React__default.useCallback(() => {
|
|
19204
|
+
const setHovered = getDrawing(drawingId).api.interaction.setHovered;
|
|
19205
|
+
setHovered(null);
|
|
19206
|
+
}, [drawingId]);
|
|
19207
|
+
const nameComponent = rename ? /*#__PURE__*/React__default.createElement(NameEdit, {
|
|
19208
|
+
drawingId: drawingId,
|
|
19209
|
+
objId: constraintId,
|
|
19210
|
+
name: name,
|
|
19211
|
+
setEditName: setRename
|
|
19212
|
+
}) : /*#__PURE__*/React__default.createElement(EntityName, {
|
|
19213
|
+
name: name,
|
|
19214
|
+
underlined: isHovered,
|
|
19215
|
+
strong: isActive
|
|
19216
|
+
});
|
|
19217
|
+
return /*#__PURE__*/React__default.createElement(HoveredDiv, {
|
|
19218
|
+
hovered: isHovered,
|
|
19219
|
+
bordered: true,
|
|
19220
|
+
onDoubleClick: onDoubleClick,
|
|
19221
|
+
onMouseEnter: onMouseEnter,
|
|
19222
|
+
onMouseLeave: onMouseLeave
|
|
19223
|
+
}, /*#__PURE__*/React__default.createElement(Space, null, nameComponent), /*#__PURE__*/React__default.createElement(Menu, {
|
|
19224
|
+
items: menuItems
|
|
19225
|
+
}));
|
|
19226
|
+
}; // TODO: Create external component
|
|
19227
|
+
|
|
18388
19228
|
|
|
18389
|
-
|
|
18390
|
-
|
|
18391
|
-
|
|
18392
|
-
|
|
19229
|
+
const List$2 = ({
|
|
19230
|
+
constrIds,
|
|
19231
|
+
drawingId
|
|
19232
|
+
}) => {
|
|
19233
|
+
return /*#__PURE__*/React__default.createElement("div", null, constrIds.map(constrId => /*#__PURE__*/React__default.createElement(Constraint, {
|
|
19234
|
+
key: constrId,
|
|
18393
19235
|
drawingId: drawingId,
|
|
18394
|
-
|
|
18395
|
-
})))
|
|
19236
|
+
constraintId: constrId
|
|
19237
|
+
})));
|
|
18396
19238
|
};
|
|
18397
19239
|
|
|
18398
19240
|
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; }
|
|
@@ -19544,10 +20386,11 @@ const Feature = ({
|
|
|
19544
20386
|
drawingId,
|
|
19545
20387
|
featureRefId
|
|
19546
20388
|
}) => {
|
|
19547
|
-
const {
|
|
19548
|
-
|
|
19549
|
-
|
|
19550
|
-
|
|
20389
|
+
const hoveredId = useDrawing(drawingId, d => {
|
|
20390
|
+
var _d$interaction$hovere;
|
|
20391
|
+
|
|
20392
|
+
return (_d$interaction$hovere = d.interaction.hovered) == null ? void 0 : _d$interaction$hovere.objectId;
|
|
20393
|
+
});
|
|
19551
20394
|
const featureId = useDrawing(drawingId, d => {
|
|
19552
20395
|
var _d$structure$tree$fea2, _d$structure$tree$fea3;
|
|
19553
20396
|
|
|
@@ -19572,15 +20415,18 @@ const Feature = ({
|
|
|
19572
20415
|
}
|
|
19573
20416
|
}, [disabled, featureId, drawingId]);
|
|
19574
20417
|
const onMouseEnter = React__default.useCallback(() => {
|
|
19575
|
-
|
|
19576
|
-
|
|
20418
|
+
const setHovered = getDrawing(drawingId).api.interaction.setHovered;
|
|
20419
|
+
const curNodeId = getDrawing(drawingId).structure.currentNode;
|
|
20420
|
+
const curProdId = getDrawing(drawingId).structure.currentProduct;
|
|
20421
|
+
setHovered(createInfo({
|
|
19577
20422
|
objectId: featureId,
|
|
19578
|
-
|
|
19579
|
-
});
|
|
19580
|
-
}, [
|
|
20423
|
+
prodRefId: curNodeId || curProdId
|
|
20424
|
+
}));
|
|
20425
|
+
}, [drawingId, featureId]);
|
|
19581
20426
|
const onMouseLeave = React__default.useCallback(() => {
|
|
19582
|
-
|
|
19583
|
-
|
|
20427
|
+
const setHovered = getDrawing(drawingId).api.interaction.setHovered;
|
|
20428
|
+
setHovered(null);
|
|
20429
|
+
}, [drawingId]);
|
|
19584
20430
|
const nameComponent = rename ? /*#__PURE__*/React__default.createElement(NameEdit, {
|
|
19585
20431
|
drawingId: drawingId,
|
|
19586
20432
|
objId: featureId,
|
|
@@ -19623,7 +20469,7 @@ const Feature = ({
|
|
|
19623
20469
|
hovered: isHovered,
|
|
19624
20470
|
bordered: true,
|
|
19625
20471
|
title: String(featureId),
|
|
19626
|
-
|
|
20472
|
+
onDoubleClick: onNameClick,
|
|
19627
20473
|
onMouseEnter: onMouseEnter,
|
|
19628
20474
|
onMouseLeave: onMouseLeave
|
|
19629
20475
|
}, /*#__PURE__*/React__default.createElement(Space, {
|
|
@@ -19731,7 +20577,7 @@ const Item$1 = ({
|
|
|
19731
20577
|
});
|
|
19732
20578
|
};
|
|
19733
20579
|
|
|
19734
|
-
const List$
|
|
20580
|
+
const List$1 = ({
|
|
19735
20581
|
drawingId
|
|
19736
20582
|
}) => {
|
|
19737
20583
|
const curPartId = useDrawing(drawingId, d => d.structure.currentProduct || d.structure.root);
|
|
@@ -19771,7 +20617,7 @@ const FeatureList = ({
|
|
|
19771
20617
|
}) => {
|
|
19772
20618
|
return /*#__PURE__*/React__default.createElement(FeatureListValidator, {
|
|
19773
20619
|
drawingId: drawingId
|
|
19774
|
-
}, /*#__PURE__*/React__default.createElement(List$
|
|
20620
|
+
}, /*#__PURE__*/React__default.createElement(List$1, {
|
|
19775
20621
|
drawingId: drawingId
|
|
19776
20622
|
}));
|
|
19777
20623
|
};
|
|
@@ -19865,42 +20711,46 @@ const NodeTitle = ({
|
|
|
19865
20711
|
}) => {
|
|
19866
20712
|
var _reference$members, _reference$members$pr, _reference$members2, _reference$members2$l;
|
|
19867
20713
|
|
|
19868
|
-
|
|
19869
|
-
|
|
19870
|
-
|
|
19871
|
-
|
|
19872
|
-
|
|
19873
|
-
|
|
20714
|
+
// Let the selector check if this refId is hovered. In that case only the hovered NodeTitle will be rerendered. If we just listen
|
|
20715
|
+
// to the hovered objectId and check later in the code bode if it equals this refId, all NodeTitle's have to be rerendered.
|
|
20716
|
+
const isHovered = useDrawing(drawingId, d => {
|
|
20717
|
+
var _d$interaction$hovere;
|
|
20718
|
+
|
|
20719
|
+
return ((_d$interaction$hovere = d.interaction.hovered) == null ? void 0 : _d$interaction$hovere.objectId) === refId;
|
|
20720
|
+
});
|
|
20721
|
+
const selected = useDrawing(drawingId, d => d.interaction.selected);
|
|
20722
|
+
const selectedIds = (selected == null ? void 0 : selected.map(sel => sel.objectId)) || [];
|
|
19874
20723
|
const reference = useDrawing(drawingId, d => d.structure.tree[refId]);
|
|
19875
20724
|
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;
|
|
19876
20725
|
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;
|
|
19877
20726
|
const referedObj = useDrawing(drawingId, d => d.structure.tree[referedId]);
|
|
19878
20727
|
const name = (referedObj == null ? void 0 : referedObj.name) || localPath;
|
|
19879
|
-
const
|
|
19880
|
-
const
|
|
19881
|
-
const isHighlighted = isHovered || isSelected || (selectedId ? hasSelectedChild(drawingId, refId, selectedId) : false);
|
|
20728
|
+
const isSelected = (selectedIds == null ? void 0 : selectedIds.indexOf(refId)) !== -1;
|
|
20729
|
+
const isHighlighted = isHovered || isSelected || ((selectedIds == null ? void 0 : selectedIds.length) === 1 ? hasSelectedChild(drawingId, refId, selectedIds[0]) : false);
|
|
19882
20730
|
const [rename, setRename] = React__default.useState(false);
|
|
19883
20731
|
const menuItems = useMenuItems$1(drawingId, refId, setRename);
|
|
19884
|
-
const onClick = React__default.useCallback(
|
|
19885
|
-
|
|
20732
|
+
const onClick = React__default.useCallback(e => {
|
|
20733
|
+
const select = getDrawing(drawingId).api.interaction.select;
|
|
20734
|
+
const multi = e.shiftKey;
|
|
20735
|
+
select(createInfo({
|
|
19886
20736
|
objectId: refId,
|
|
19887
|
-
|
|
19888
|
-
|
|
19889
|
-
|
|
19890
|
-
}, [isSelected, refId, onClick_]);
|
|
20737
|
+
prodRefId: refId
|
|
20738
|
+
}), multi);
|
|
20739
|
+
}, [drawingId, refId]);
|
|
19891
20740
|
const onDoubleClick = React__default.useCallback(() => {
|
|
19892
20741
|
getCADState().api.assemblyTree.startProdEditing(drawingId, refId);
|
|
19893
20742
|
}, [drawingId, refId]);
|
|
19894
20743
|
const onMouseEnter = React__default.useCallback(() => {
|
|
19895
|
-
|
|
20744
|
+
const setHovered = getDrawing(drawingId).api.interaction.setHovered;
|
|
20745
|
+
setHovered(createInfo({
|
|
19896
20746
|
objectId: refId,
|
|
19897
|
-
|
|
19898
|
-
|
|
19899
|
-
|
|
19900
|
-
}, [refId, onHover]);
|
|
20747
|
+
prodRefId: refId
|
|
20748
|
+
}));
|
|
20749
|
+
}, [drawingId, refId]);
|
|
19901
20750
|
const onMouseLeave = React__default.useCallback(() => {
|
|
19902
|
-
|
|
19903
|
-
|
|
20751
|
+
const setHovered = getDrawing(drawingId).api.interaction.setHovered;
|
|
20752
|
+
setHovered(null);
|
|
20753
|
+
}, [drawingId]);
|
|
19904
20754
|
const nameComponent = rename ? /*#__PURE__*/React__default.createElement(NameEdit, {
|
|
19905
20755
|
drawingId: drawingId,
|
|
19906
20756
|
objId: referedId,
|
|
@@ -19977,25 +20827,6 @@ const AssemblyNode = ({
|
|
|
19977
20827
|
return null;
|
|
19978
20828
|
};
|
|
19979
20829
|
|
|
19980
|
-
const SectionHeader = ({
|
|
19981
|
-
children
|
|
19982
|
-
}) => {
|
|
19983
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
19984
|
-
style: {
|
|
19985
|
-
height: '42px',
|
|
19986
|
-
backgroundColor: '#fafafa',
|
|
19987
|
-
color: 'rgba(0, 0, 0, 0.85)',
|
|
19988
|
-
fontWeight: 500,
|
|
19989
|
-
textAlign: 'left',
|
|
19990
|
-
background: '#fafafa',
|
|
19991
|
-
borderBottom: '1px solid #f0f0f0',
|
|
19992
|
-
padding: '8px 8px',
|
|
19993
|
-
display: 'flex',
|
|
19994
|
-
justifyContent: 'space-between'
|
|
19995
|
-
}
|
|
19996
|
-
}, children);
|
|
19997
|
-
};
|
|
19998
|
-
|
|
19999
20830
|
const Skeleton = styled(SkeletonImpl)`
|
|
20000
20831
|
.ant-skeleton-content {
|
|
20001
20832
|
.ant-skeleton-paragraph {
|
|
@@ -20471,12 +21302,13 @@ const Solid = ({
|
|
|
20471
21302
|
drawingId,
|
|
20472
21303
|
solidId
|
|
20473
21304
|
}) => {
|
|
20474
|
-
const {
|
|
20475
|
-
|
|
20476
|
-
|
|
20477
|
-
|
|
20478
|
-
|
|
20479
|
-
|
|
21305
|
+
const hoveredId = useDrawing(drawingId, d => {
|
|
21306
|
+
var _d$interaction$hovere;
|
|
21307
|
+
|
|
21308
|
+
return (_d$interaction$hovere = d.interaction.hovered) == null ? void 0 : _d$interaction$hovere.graphicId;
|
|
21309
|
+
});
|
|
21310
|
+
const selected = useDrawing(drawingId, d => d.interaction.selected);
|
|
21311
|
+
const selectedIds = (selected == null ? void 0 : selected.map(sel => sel.graphicId)) || [];
|
|
20480
21312
|
const solidOwner = useDrawingCCId(drawingId, d => {
|
|
20481
21313
|
var _d$graphic$containers;
|
|
20482
21314
|
|
|
@@ -20484,26 +21316,44 @@ const Solid = ({
|
|
|
20484
21316
|
});
|
|
20485
21317
|
const ccSolid = useDrawing(drawingId, d => d.structure.tree[solidOwner]);
|
|
20486
21318
|
const isHovered = hoveredId === solidId;
|
|
20487
|
-
const isSelected =
|
|
21319
|
+
const isSelected = (selectedIds == null ? void 0 : selectedIds.indexOf(solidId)) !== -1;
|
|
20488
21320
|
const isHighlighted = isHovered || isSelected;
|
|
20489
21321
|
const [rename, setRename] = React__default.useState(false);
|
|
20490
|
-
const onClick = React__default.useCallback(
|
|
20491
|
-
|
|
20492
|
-
|
|
20493
|
-
|
|
20494
|
-
|
|
20495
|
-
|
|
20496
|
-
|
|
21322
|
+
const onClick = React__default.useCallback(e => {
|
|
21323
|
+
var _getDrawing$structure;
|
|
21324
|
+
|
|
21325
|
+
const select = getDrawing(drawingId).api.interaction.select;
|
|
21326
|
+
const multi = e.shiftKey;
|
|
21327
|
+
const objectId = getDrawing(drawingId).geometry.cache[solidId].container.ownerId;
|
|
21328
|
+
const curNodeId = getDrawing(drawingId).structure.currentNode;
|
|
21329
|
+
const curProdId = getDrawing(drawingId).structure.currentProduct;
|
|
21330
|
+
const isPart = ccUtils.base.isA(((_getDrawing$structure = getDrawing(drawingId).structure.tree[curProdId]) == null ? void 0 : _getDrawing$structure.class) || '', CCClasses.CCPart);
|
|
21331
|
+
select(createInfo({
|
|
21332
|
+
objectId,
|
|
21333
|
+
graphicId: solidId,
|
|
21334
|
+
containerId: solidId,
|
|
21335
|
+
prodRefId: isPart ? curProdId : curNodeId
|
|
21336
|
+
}), multi);
|
|
21337
|
+
}, [drawingId, solidId]);
|
|
20497
21338
|
const onMouseEnter = React__default.useCallback(() => {
|
|
20498
|
-
|
|
20499
|
-
|
|
20500
|
-
|
|
20501
|
-
|
|
20502
|
-
|
|
20503
|
-
|
|
21339
|
+
var _getDrawing$structure2;
|
|
21340
|
+
|
|
21341
|
+
const setHovered = getDrawing(drawingId).api.interaction.setHovered;
|
|
21342
|
+
const objectId = getDrawing(drawingId).geometry.cache[solidId].container.ownerId;
|
|
21343
|
+
const curNodeId = getDrawing(drawingId).structure.currentNode;
|
|
21344
|
+
const curProdId = getDrawing(drawingId).structure.currentProduct;
|
|
21345
|
+
const isPart = ccUtils.base.isA(((_getDrawing$structure2 = getDrawing(drawingId).structure.tree[curProdId]) == null ? void 0 : _getDrawing$structure2.class) || '', CCClasses.CCPart);
|
|
21346
|
+
setHovered(createInfo({
|
|
21347
|
+
objectId,
|
|
21348
|
+
graphicId: solidId,
|
|
21349
|
+
containerId: solidId,
|
|
21350
|
+
prodRefId: isPart ? curProdId : curNodeId
|
|
21351
|
+
}));
|
|
21352
|
+
}, [drawingId, solidId]);
|
|
20504
21353
|
const onMouseLeave = React__default.useCallback(() => {
|
|
20505
|
-
|
|
20506
|
-
|
|
21354
|
+
const setHovered = getDrawing(drawingId).api.interaction.setHovered;
|
|
21355
|
+
setHovered(null);
|
|
21356
|
+
}, [drawingId]);
|
|
20507
21357
|
const menuItems = useMenuItems(setRename);
|
|
20508
21358
|
return /*#__PURE__*/React__default.createElement(HoveredDiv, {
|
|
20509
21359
|
hovered: isHighlighted,
|
|
@@ -20532,7 +21382,7 @@ const Solid = ({
|
|
|
20532
21382
|
}; // TODO: Create external component
|
|
20533
21383
|
|
|
20534
21384
|
|
|
20535
|
-
const List
|
|
21385
|
+
const List = ({
|
|
20536
21386
|
solidsIds,
|
|
20537
21387
|
drawingId
|
|
20538
21388
|
}) => {
|
|
@@ -20564,7 +21414,7 @@ const Solids = ({
|
|
|
20564
21414
|
style: {
|
|
20565
21415
|
overflow: 'auto'
|
|
20566
21416
|
}
|
|
20567
|
-
}, /*#__PURE__*/React__default.createElement(List
|
|
21417
|
+
}, /*#__PURE__*/React__default.createElement(List, {
|
|
20568
21418
|
drawingId: drawingId,
|
|
20569
21419
|
solidsIds: solidIds
|
|
20570
21420
|
})));
|
|
@@ -21199,8 +22049,6 @@ const ViewPlugButtons = ({
|
|
|
21199
22049
|
}));
|
|
21200
22050
|
};
|
|
21201
22051
|
|
|
21202
|
-
const InteractionContext = /*#__PURE__*/React__default.createContext({});
|
|
21203
|
-
|
|
21204
22052
|
const EditDrawing = ({
|
|
21205
22053
|
drawingId,
|
|
21206
22054
|
children
|
|
@@ -21299,31 +22147,17 @@ const Header = ({
|
|
|
21299
22147
|
*
|
|
21300
22148
|
* @param drawingId - id of an existing drawing.
|
|
21301
22149
|
* @param Menu - you can pass custom file menu which will be shown at the left top corner.
|
|
21302
|
-
* @param hoveredId - id of a currently hovered object.
|
|
21303
|
-
* @param selectedId - id of a currently selected object.
|
|
21304
|
-
* @param onHover - callback for hovering features / assembly nodes / solids / constraints.
|
|
21305
|
-
* @param onClick - callback for clicking on assembly nodes / solids.
|
|
21306
22150
|
*/
|
|
21307
22151
|
|
|
21308
22152
|
|
|
21309
22153
|
const Drawing = ({
|
|
21310
22154
|
drawingId,
|
|
21311
22155
|
Menu,
|
|
21312
|
-
children
|
|
21313
|
-
hoveredId,
|
|
21314
|
-
selectedId,
|
|
21315
|
-
onHover,
|
|
21316
|
-
onClick
|
|
22156
|
+
children
|
|
21317
22157
|
}) => {
|
|
21318
22158
|
React__default.useEffect(() => {
|
|
21319
22159
|
return () => getCADState().api.assemblyTree.clearProdStack();
|
|
21320
22160
|
}, [drawingId]);
|
|
21321
|
-
const contextValue = React__default.useMemo(() => ({
|
|
21322
|
-
hoveredId,
|
|
21323
|
-
selectedId,
|
|
21324
|
-
onHover,
|
|
21325
|
-
onClick
|
|
21326
|
-
}), [hoveredId, selectedId, onHover, onClick]);
|
|
21327
22161
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
21328
22162
|
style: {
|
|
21329
22163
|
height: '100%',
|
|
@@ -21338,11 +22172,9 @@ const Drawing = ({
|
|
|
21338
22172
|
style: {
|
|
21339
22173
|
margin: '0'
|
|
21340
22174
|
}
|
|
21341
|
-
}), /*#__PURE__*/React__default.createElement(
|
|
21342
|
-
value: contextValue
|
|
21343
|
-
}, /*#__PURE__*/React__default.createElement(EditDrawing, {
|
|
22175
|
+
}), /*#__PURE__*/React__default.createElement(EditDrawing, {
|
|
21344
22176
|
drawingId: drawingId
|
|
21345
|
-
}, children)
|
|
22177
|
+
}, children), /*#__PURE__*/React__default.createElement("div", {
|
|
21346
22178
|
style: {
|
|
21347
22179
|
position: 'absolute',
|
|
21348
22180
|
bottom: '4px',
|
|
@@ -21353,171 +22185,4 @@ const Drawing = ({
|
|
|
21353
22185
|
})), /*#__PURE__*/React__default.createElement(BlankDiv, null));
|
|
21354
22186
|
};
|
|
21355
22187
|
|
|
21356
|
-
|
|
21357
|
-
|
|
21358
|
-
const getMateRefIds = (drawingId, constrId) => {
|
|
21359
|
-
var _drawing$structure$tr;
|
|
21360
|
-
|
|
21361
|
-
const drawing = getDrawing(drawingId);
|
|
21362
|
-
const members = (_drawing$structure$tr = drawing.structure.tree[constrId]) == null ? void 0 : _drawing$structure$tr.members;
|
|
21363
|
-
const pRefIds = [];
|
|
21364
|
-
|
|
21365
|
-
if (members && members[mateNames[0]]) {
|
|
21366
|
-
mateNames.forEach(mateName => {
|
|
21367
|
-
var _member$members$;
|
|
21368
|
-
|
|
21369
|
-
const member = members[mateName];
|
|
21370
|
-
const matePath = member == null ? void 0 : (_member$members$ = member.members[0]) == null ? void 0 : _member$members$.members;
|
|
21371
|
-
|
|
21372
|
-
if (matePath && matePath.length > 0) {
|
|
21373
|
-
pRefIds.push(matePath[matePath.length - 1].value);
|
|
21374
|
-
}
|
|
21375
|
-
});
|
|
21376
|
-
}
|
|
21377
|
-
|
|
21378
|
-
if (pRefIds.length === 0) {
|
|
21379
|
-
return;
|
|
21380
|
-
}
|
|
21381
|
-
|
|
21382
|
-
const curNodeId = drawing.structure.currentNode;
|
|
21383
|
-
const curNode = drawing.structure.tree[curNodeId];
|
|
21384
|
-
const curRefIds = (curNode == null ? void 0 : curNode.instances) || (curNode == null ? void 0 : curNode.children) || [];
|
|
21385
|
-
const mateRefIds = [];
|
|
21386
|
-
curRefIds.forEach(id => {
|
|
21387
|
-
var _drawing$structure$tr2, _drawing$structure$tr3;
|
|
21388
|
-
|
|
21389
|
-
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;
|
|
21390
|
-
|
|
21391
|
-
if (pRefIds.indexOf(productRefId) !== -1) {
|
|
21392
|
-
mateRefIds.push(id);
|
|
21393
|
-
}
|
|
21394
|
-
});
|
|
21395
|
-
return mateRefIds;
|
|
21396
|
-
};
|
|
21397
|
-
|
|
21398
|
-
const SolverState = ({
|
|
21399
|
-
drawingId
|
|
21400
|
-
}) => {
|
|
21401
|
-
const rootId = useDrawing(drawingId, d => d.structure.root);
|
|
21402
|
-
const solverState = useDrawing(drawingId, d => {
|
|
21403
|
-
var _d$structure$tree$roo, _d$structure$tree$roo2, _d$structure$tree$roo3;
|
|
21404
|
-
|
|
21405
|
-
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;
|
|
21406
|
-
});
|
|
21407
|
-
const component = solverState === 0 ? /*#__PURE__*/React__default.createElement(CheckCircleTwoTone, {
|
|
21408
|
-
twoToneColor: "#52c41a"
|
|
21409
|
-
}) : /*#__PURE__*/React__default.createElement(CloseCircleTwoTone, {
|
|
21410
|
-
twoToneColor: "#eb2f96"
|
|
21411
|
-
});
|
|
21412
|
-
return solverState === undefined ? null : /*#__PURE__*/React__default.createElement(Tooltip$1, {
|
|
21413
|
-
title: solverState === 0 ? 'Solved' : 'Not Solved'
|
|
21414
|
-
}, component);
|
|
21415
|
-
};
|
|
21416
|
-
/**
|
|
21417
|
-
* Shows list of 3d constraints which are contained by currentProduct.
|
|
21418
|
-
*
|
|
21419
|
-
* @param drawingId - id of a drawing in which currentProduct will be found.
|
|
21420
|
-
* @returns
|
|
21421
|
-
*/
|
|
21422
|
-
|
|
21423
|
-
|
|
21424
|
-
const Constraints = ({
|
|
21425
|
-
drawingId
|
|
21426
|
-
}) => {
|
|
21427
|
-
const curProdId = useDrawing(drawingId, d => d.structure.currentProduct);
|
|
21428
|
-
const prodChildren = useDrawingArr(drawingId, d => {
|
|
21429
|
-
var _d$structure$tree$cur;
|
|
21430
|
-
|
|
21431
|
-
return (_d$structure$tree$cur = d.structure.tree[curProdId]) == null ? void 0 : _d$structure$tree$cur.children;
|
|
21432
|
-
});
|
|
21433
|
-
const constrSetId = React__default.useMemo(() => {
|
|
21434
|
-
const tree = getDrawing(drawingId).structure.tree;
|
|
21435
|
-
return prodChildren.find(childId => tree[childId].class === CCClasses.CCConstraintSet) || null;
|
|
21436
|
-
}, [prodChildren, drawingId]);
|
|
21437
|
-
const constrSet = useDrawing(drawingId, d => d.structure.tree[constrSetId] || null);
|
|
21438
|
-
const constrIds = React__default.useMemo(() => {
|
|
21439
|
-
return (constrSet == null ? void 0 : constrSet.children) || []; // If there is no any constraint, children doesn't exist in constrSet object
|
|
21440
|
-
}, [constrSet]);
|
|
21441
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
21442
|
-
style: {
|
|
21443
|
-
display: 'flex',
|
|
21444
|
-
flexDirection: 'column',
|
|
21445
|
-
height: '100%'
|
|
21446
|
-
}
|
|
21447
|
-
}, /*#__PURE__*/React__default.createElement(SectionHeader, null, /*#__PURE__*/React__default.createElement(FlexRow, null, /*#__PURE__*/React__default.createElement(Space, null, "Constraints", /*#__PURE__*/React__default.createElement(SolverState, {
|
|
21448
|
-
drawingId: drawingId
|
|
21449
|
-
})))), /*#__PURE__*/React__default.createElement("div", {
|
|
21450
|
-
style: {
|
|
21451
|
-
overflow: 'auto'
|
|
21452
|
-
}
|
|
21453
|
-
}, /*#__PURE__*/React__default.createElement(List, {
|
|
21454
|
-
drawingId: drawingId,
|
|
21455
|
-
constrIds: constrIds
|
|
21456
|
-
})));
|
|
21457
|
-
};
|
|
21458
|
-
|
|
21459
|
-
const Constraint = ({
|
|
21460
|
-
drawingId,
|
|
21461
|
-
constraintId
|
|
21462
|
-
}) => {
|
|
21463
|
-
const {
|
|
21464
|
-
hoveredId,
|
|
21465
|
-
onHover
|
|
21466
|
-
} = React__default.useContext(InteractionContext);
|
|
21467
|
-
const name = useDrawing(drawingId, d => {
|
|
21468
|
-
var _d$structure$tree$con;
|
|
21469
|
-
|
|
21470
|
-
return (_d$structure$tree$con = d.structure.tree[constraintId]) == null ? void 0 : _d$structure$tree$con.name;
|
|
21471
|
-
});
|
|
21472
|
-
const isActive = useDrawing(drawingId, d => d.plugin.active.feature === constraintId);
|
|
21473
|
-
const isHovered = hoveredId === constraintId;
|
|
21474
|
-
const [rename, setRename] = React__default.useState(false);
|
|
21475
|
-
const menuItems = useMenuItems$4(drawingId, constraintId, isActive, setRename);
|
|
21476
|
-
const onNameClick = React__default.useCallback(() => {
|
|
21477
|
-
getDrawing(drawingId).api.plugin.setActiveFeature(constraintId);
|
|
21478
|
-
}, [drawingId, constraintId]);
|
|
21479
|
-
const onMouseEnter = React__default.useCallback(() => {
|
|
21480
|
-
const mateRefIds = getMateRefIds(drawingId, constraintId);
|
|
21481
|
-
onHover && onHover({
|
|
21482
|
-
objectId: constraintId,
|
|
21483
|
-
highlightedIds: mateRefIds,
|
|
21484
|
-
type: 'Constraint'
|
|
21485
|
-
});
|
|
21486
|
-
}, [drawingId, constraintId, onHover]);
|
|
21487
|
-
const onMouseLeave = React__default.useCallback(() => {
|
|
21488
|
-
onHover && onHover(null);
|
|
21489
|
-
}, [onHover]);
|
|
21490
|
-
const nameComponent = rename ? /*#__PURE__*/React__default.createElement(NameEdit, {
|
|
21491
|
-
drawingId: drawingId,
|
|
21492
|
-
objId: constraintId,
|
|
21493
|
-
name: name,
|
|
21494
|
-
setEditName: setRename
|
|
21495
|
-
}) : /*#__PURE__*/React__default.createElement(EntityName, {
|
|
21496
|
-
name: name,
|
|
21497
|
-
underlined: isHovered,
|
|
21498
|
-
strong: isActive
|
|
21499
|
-
});
|
|
21500
|
-
return /*#__PURE__*/React__default.createElement(HoveredDiv, {
|
|
21501
|
-
hovered: isHovered,
|
|
21502
|
-
bordered: true,
|
|
21503
|
-
onClick: onNameClick,
|
|
21504
|
-
onMouseEnter: onMouseEnter,
|
|
21505
|
-
onMouseLeave: onMouseLeave
|
|
21506
|
-
}, /*#__PURE__*/React__default.createElement(Space, null, nameComponent), /*#__PURE__*/React__default.createElement(Menu, {
|
|
21507
|
-
items: menuItems
|
|
21508
|
-
}));
|
|
21509
|
-
}; // TODO: Create external component
|
|
21510
|
-
|
|
21511
|
-
|
|
21512
|
-
const List = ({
|
|
21513
|
-
constrIds,
|
|
21514
|
-
drawingId
|
|
21515
|
-
}) => {
|
|
21516
|
-
return /*#__PURE__*/React__default.createElement("div", null, constrIds.map(constrId => /*#__PURE__*/React__default.createElement(Constraint, {
|
|
21517
|
-
key: constrId,
|
|
21518
|
-
drawingId: drawingId,
|
|
21519
|
-
constraintId: constrId
|
|
21520
|
-
})));
|
|
21521
|
-
};
|
|
21522
|
-
|
|
21523
|
-
export { index$x as Boolean, index$a as BoundingBoxInfo, index$u as Box, CADApi, CSysDisplay, index$p as Chamfer, index$i as CircularPattern, index$r as Cone, Constraints, index$s as Cylinder, index$4 as Cylindrical, index$y as Dimensions, Drawing, index$9 as Expressions, index$w as Extrusion, index$7 as Fastened, index$8 as FastenedOrigin, FeaturePlugin, index$q as Fillet, FtVisibilityController$1 as FtVisibilityController, GlobalPlugins, HoveredConstraintDisplay, index$1 as Import, index$j as LinearPattern, index$g as Measure, Menu, Messages, index$h as Mirror, ModelTree, index$2 as Parallel, index$3 as Planar, index as ProductManagement, Readfile$1 as Readfile, index$5 as Revolute, index$v as Revolve, index$n as Rotate, SideBar, index$f as Sketch, index$l as Slice, index$k as SliceBySheet, index$6 as Slider, Solids, index$t as Sphere, ToolBar, index$m as TransformByCsys, index$o as Translate, ViewOptionButtons, ViewPlugButtons, index$e as WorkAxis, index$b as WorkCoordSystem, index$d as WorkPlane, index$c as WorkPoint, getCADState, useAllObjects, useCADStore, useHasPending, useIsLoading };
|
|
22188
|
+
export { index$x as Boolean, index$a as BoundingBoxInfo, index$u as Box, CADApi, CSysDisplay, index$p as Chamfer, index$i as CircularPattern, index$r as Cone, Constraints, index$s as Cylinder, index$4 as Cylindrical, index$y as Dimensions, Drawing, index$9 as Expressions, index$w as Extrusion, index$7 as Fastened, index$8 as FastenedOrigin, FeaturePlugin, index$q as Fillet, FtVisibilityController$1 as FtVisibilityController, GlobalPlugins, HoveredConstraintDisplay, index$1 as Import, index$j as LinearPattern, index$g as Measure, Menu, Messages, index$h as Mirror, ModelTree, Outline, index$2 as Parallel, index$3 as Planar, index as ProductManagement, Readfile$1 as Readfile, index$5 as Revolute, index$v as Revolve, index$n as Rotate, SelectedMateObj, SideBar, index$f as Sketch, index$l as Slice, index$k as SliceBySheet, index$6 as Slider, Solids, index$t as Sphere, ToolBar, index$m as TransformByCsys, index$o as Translate, ViewOptionButtons, ViewPlugButtons, index$e as WorkAxis, WorkAxisObj, index$b as WorkCoordSystem, WorkCoordSystemObj, index$d as WorkPlane, WorkPlaneObj, index$c as WorkPoint, WorkPointObj, getCADState, getMateRefIds, useAllObjects, useCADStore, useHasPending, useIsLoading };
|