@itwin/tree-widget-react 2.0.2 → 2.2.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/CHANGELOG.md +22 -2
- package/README.md +105 -0
- package/lib/cjs/components/SelectableTree.d.ts +4 -0
- package/lib/cjs/components/SelectableTree.js +1 -1
- package/lib/cjs/components/SelectableTree.js.map +1 -1
- package/lib/cjs/components/TreeSelector.d.ts +2 -0
- package/lib/cjs/components/TreeSelector.js +4 -1
- package/lib/cjs/components/TreeSelector.js.map +1 -1
- package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +4 -0
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js +7 -7
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.d.ts +1 -0
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +6 -4
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +1 -1
- package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +11 -3
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js +8 -5
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +13 -0
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js +14 -2
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +17 -8
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/common/ReportingTreeEventHandler.d.ts +27 -0
- package/lib/cjs/components/trees/common/ReportingTreeEventHandler.js +51 -0
- package/lib/cjs/components/trees/common/ReportingTreeEventHandler.js.map +1 -0
- package/lib/cjs/components/trees/common/TreeRenderer.d.ts +17 -2
- package/lib/cjs/components/trees/common/TreeRenderer.js +19 -3
- package/lib/cjs/components/trees/common/TreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeRenderer.scss +1 -1
- package/lib/cjs/components/trees/common/UseFeatureReporting.d.ts +23 -0
- package/lib/cjs/components/trees/common/UseFeatureReporting.js +30 -0
- package/lib/cjs/components/trees/common/UseFeatureReporting.js.map +1 -0
- package/lib/cjs/components/trees/common/UsePerformanceReporting.d.ts +18 -0
- package/lib/cjs/components/trees/common/UsePerformanceReporting.js +25 -0
- package/lib/cjs/components/trees/common/UsePerformanceReporting.js.map +1 -0
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.d.ts +8 -1
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.js +5 -3
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +13 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +21 -5
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +13 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +22 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +13 -0
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +24 -10
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +27 -12
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.d.ts +10 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js +5 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.d.ts +4 -1
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +43 -28
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/lib/esm/components/SelectableTree.d.ts +4 -0
- package/lib/esm/components/SelectableTree.js +1 -1
- package/lib/esm/components/SelectableTree.js.map +1 -1
- package/lib/esm/components/TreeSelector.d.ts +2 -0
- package/lib/esm/components/TreeSelector.js +4 -1
- package/lib/esm/components/TreeSelector.js.map +1 -1
- package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +4 -0
- package/lib/esm/components/TreeWidgetUiItemsProvider.js +7 -7
- package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/components/tree-header/TreeHeader.d.ts +1 -0
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js +7 -5
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +1 -1
- package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +11 -3
- package/lib/esm/components/trees/VisibilityTreeRenderer.js +8 -5
- package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +13 -0
- package/lib/esm/components/trees/category-tree/CategoriesTree.js +14 -2
- package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +17 -8
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/common/ReportingTreeEventHandler.d.ts +27 -0
- package/lib/esm/components/trees/common/ReportingTreeEventHandler.js +47 -0
- package/lib/esm/components/trees/common/ReportingTreeEventHandler.js.map +1 -0
- package/lib/esm/components/trees/common/TreeRenderer.d.ts +17 -2
- package/lib/esm/components/trees/common/TreeRenderer.js +19 -3
- package/lib/esm/components/trees/common/TreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/common/TreeRenderer.scss +1 -1
- package/lib/esm/components/trees/common/UseFeatureReporting.d.ts +23 -0
- package/lib/esm/components/trees/common/UseFeatureReporting.js +26 -0
- package/lib/esm/components/trees/common/UseFeatureReporting.js.map +1 -0
- package/lib/esm/components/trees/common/UsePerformanceReporting.d.ts +18 -0
- package/lib/esm/components/trees/common/UsePerformanceReporting.js +21 -0
- package/lib/esm/components/trees/common/UsePerformanceReporting.js.map +1 -0
- package/lib/esm/components/trees/common/UseVisibilityTreeState.d.ts +8 -1
- package/lib/esm/components/trees/common/UseVisibilityTreeState.js +5 -3
- package/lib/esm/components/trees/common/UseVisibilityTreeState.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +13 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +22 -6
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +13 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +23 -2
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +13 -0
- package/lib/esm/components/trees/models-tree/ModelsTree.js +24 -10
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +27 -12
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.d.ts +10 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js +5 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.d.ts +4 -1
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +43 -28
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/package.json +20 -20
|
@@ -11,9 +11,12 @@ import { isPresentationTreeNodeItem, PresentationTree } from "@itwin/presentatio
|
|
|
11
11
|
import { TreeWidget } from "../../../TreeWidget";
|
|
12
12
|
import { FilterableTreeRenderer } from "../common/TreeRenderer";
|
|
13
13
|
import { ClassGroupingOption } from "../common/Types";
|
|
14
|
+
import { useFeatureReporting } from "../common/UseFeatureReporting";
|
|
15
|
+
import { usePerformanceReporting } from "../common/UsePerformanceReporting";
|
|
14
16
|
import { useVisibilityTreeState } from "../common/UseVisibilityTreeState";
|
|
15
17
|
import { addCustomTreeNodeItemLabelRenderer, addTreeNodeItemCheckbox, combineTreeNodeItemCustomizations } from "../common/Utils";
|
|
16
18
|
import { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from "../VisibilityTreeRenderer";
|
|
19
|
+
import { ModelsTreeComponent } from "./ModelsTreeComponent";
|
|
17
20
|
import { ModelsTreeEventHandler } from "./ModelsTreeEventHandler";
|
|
18
21
|
import { ModelsVisibilityHandler, SubjectModelIdsCache } from "./ModelsVisibilityHandler";
|
|
19
22
|
import { addModelsTreeNodeItemIcons, createRuleset, createSearchRuleset } from "./Utils";
|
|
@@ -25,9 +28,11 @@ const PAGING_SIZE = 20;
|
|
|
25
28
|
* @public
|
|
26
29
|
*/
|
|
27
30
|
export function ModelsTree(props) {
|
|
28
|
-
const { hierarchyLevelConfig, density, height, width, selectionMode } = props;
|
|
29
|
-
const
|
|
31
|
+
const { hierarchyLevelConfig, density, height, width, selectionMode, onFeatureUsed } = props;
|
|
32
|
+
const { reportUsage } = useFeatureReporting({ treeIdentifier: ModelsTreeComponent.id, onFeatureUsed });
|
|
33
|
+
const state = useModelsTreeState({ ...props, reportUsage });
|
|
30
34
|
const baseRendererProps = {
|
|
35
|
+
reportUsage,
|
|
31
36
|
contextMenuItems: props.contextMenuItems,
|
|
32
37
|
nodeLabelRenderer: props.nodeLabelRenderer,
|
|
33
38
|
density: props.density,
|
|
@@ -36,6 +41,7 @@ export function ModelsTree(props) {
|
|
|
36
41
|
descriptionEnabled: false,
|
|
37
42
|
levelOffset: 10,
|
|
38
43
|
disableRootNodeCollapse: true,
|
|
44
|
+
onVisibilityToggled: () => reportUsage({ featureId: "visibility-change", reportInteraction: true }),
|
|
39
45
|
},
|
|
40
46
|
};
|
|
41
47
|
// istanbul ignore next
|
|
@@ -52,7 +58,7 @@ export function ModelsTree(props) {
|
|
|
52
58
|
: createVisibilityTreeRenderer(baseRendererProps), noDataRenderer: isFilterApplied ? noFilteredDataRenderer : undefined, width: width, height: height }), overlay] }));
|
|
53
59
|
}
|
|
54
60
|
function ModelsTreeNodeRenderer(props) {
|
|
55
|
-
return (_jsx(FilterableVisibilityTreeNodeRenderer, { ...props, iconsEnabled: true, descriptionEnabled: false, levelOffset: 10, disableRootNodeCollapse: true, isEnlarged: props.density === "enlarged" }));
|
|
61
|
+
return (_jsx(FilterableVisibilityTreeNodeRenderer, { ...props, iconsEnabled: true, descriptionEnabled: false, levelOffset: 10, disableRootNodeCollapse: true, isEnlarged: props.density === "enlarged", onVisibilityToggled: () => props.reportUsage?.({ featureId: "visibility-change", reportInteraction: true }) }));
|
|
56
62
|
}
|
|
57
63
|
function useModelsTreeState({ filterInfo, onFilterApplied, ...props }) {
|
|
58
64
|
const rulesets = {
|
|
@@ -78,20 +84,28 @@ function useModelsTreeState({ filterInfo, onFilterApplied, ...props }) {
|
|
|
78
84
|
});
|
|
79
85
|
return filterInfo?.filter ? filteredTreeState : treeState;
|
|
80
86
|
}
|
|
81
|
-
function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate, hierarchyConfig, iModel, ruleset, filterInfo, onFilterApplied, hierarchyLevelConfig, }) {
|
|
87
|
+
function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate, hierarchyConfig, iModel, ruleset, filterInfo, onFilterApplied, hierarchyLevelConfig, onPerformanceMeasured, reportUsage, }) {
|
|
82
88
|
const visibilityHandler = useVisibilityHandler(ruleset.id, iModel, activeView, modelsVisibilityHandler);
|
|
83
89
|
const selectionPredicateRef = useRef(selectionPredicate);
|
|
84
90
|
useEffect(() => {
|
|
85
91
|
selectionPredicateRef.current = selectionPredicate;
|
|
86
92
|
}, [selectionPredicate]);
|
|
87
93
|
const onFilterChange = useCallback((dataProvider, matchesCount) => {
|
|
88
|
-
if (
|
|
89
|
-
|
|
94
|
+
if (dataProvider && matchesCount !== undefined) {
|
|
95
|
+
reportUsage({ featureId: "filtering", reportInteraction: false });
|
|
96
|
+
onFilterApplied?.(dataProvider, matchesCount);
|
|
90
97
|
}
|
|
91
98
|
if (visibilityHandler) {
|
|
92
99
|
visibilityHandler.setFilteredDataProvider(dataProvider);
|
|
93
100
|
}
|
|
94
|
-
}, [onFilterApplied, visibilityHandler]);
|
|
101
|
+
}, [onFilterApplied, reportUsage, visibilityHandler]);
|
|
102
|
+
const { onNodeLoaded } = usePerformanceReporting({
|
|
103
|
+
treeIdentifier: ModelsTreeComponent.id,
|
|
104
|
+
onPerformanceMeasured,
|
|
105
|
+
});
|
|
106
|
+
const eventHandlerFactory = useCallback((handlerProps) => {
|
|
107
|
+
return new ModelsTreeEventHandler({ ...handlerProps, reportUsage });
|
|
108
|
+
}, [reportUsage]);
|
|
95
109
|
return useVisibilityTreeState({
|
|
96
110
|
imodel: iModel,
|
|
97
111
|
ruleset,
|
|
@@ -107,11 +121,11 @@ function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate,
|
|
|
107
121
|
: selectionPredicateRef.current(node.key, ModelsVisibilityHandler.getNodeType(node)), []),
|
|
108
122
|
eventHandler: eventHandlerFactory,
|
|
109
123
|
hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
|
|
124
|
+
onNodeLoaded: filterInfo ? undefined : onNodeLoaded,
|
|
125
|
+
reportUsage: filterInfo ? undefined : reportUsage,
|
|
126
|
+
onHierarchyLimitExceeded: () => reportUsage({ featureId: "hierarchy-level-size-limit-hit", reportInteraction: false }),
|
|
110
127
|
});
|
|
111
128
|
}
|
|
112
|
-
function eventHandlerFactory(props) {
|
|
113
|
-
return new ModelsTreeEventHandler(props);
|
|
114
|
-
}
|
|
115
129
|
function useVisibilityHandler(rulesetId, iModel, activeView, visibilityHandler, hierarchyAutoUpdateEnabled) {
|
|
116
130
|
const subjectModelIdsCache = useMemo(() => new SubjectModelIdsCache(iModel), [iModel]);
|
|
117
131
|
const [state, setState] = useState();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,kCAAkC,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AACjI,OAAO,EAAE,4BAA4B,EAAE,oCAAoC,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAC7I,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,0BAA0B,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AASzF,MAAM,WAAW,GAAG,EAAE,CAAC;AAoDvB;;;;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D,SAAS;YACT,QAAQ,EAAE,UAAU;YACpB,0BAA0B;YAC1B,oBAAoB;SACrB,CAAC;QAEF,MAAM,OAAO,GAAG,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;QACpI,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClB,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEjG,OAAO,iBAAiB,IAAI,OAAO,iBAAiB,KAAK,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC;AAClG,CAAC;AAED,MAAM,qBAAqB,GAAG,iCAAiC,CAAC,CAAC,kCAAkC,EAAE,uBAAuB,EAAE,0BAA0B,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { isPresentationTreeNodeItem, PresentationTree } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { ClassGroupingOption } from \"../common/Types\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, addTreeNodeItemCheckbox, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { ModelsTreeEventHandler } from \"./ModelsTreeEventHandler\";\nimport { ModelsVisibilityHandler, SubjectModelIdsCache } from \"./ModelsVisibilityHandler\";\nimport { addModelsTreeNodeItemIcons, createRuleset, createSearchRuleset } from \"./Utils\";\n\nimport type { VisibilityTreeEventHandlerParams } from \"../VisibilityTreeEventHandler\";\nimport type { Ruleset, SingleSchemaClassSpecification } from \"@itwin/presentation-common\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeNodeItem } from \"@itwin/components-react\";\nimport type { IFilteredPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { ModelsTreeSelectionPredicate, ModelsVisibilityHandlerProps } from \"./ModelsVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Props for configuring the hierarchy in [[ModelsTree]].\n * @public\n */\nexport interface ModelsTreeHierarchyConfiguration {\n /** Should the tree group displayed element nodes by class. Defaults to `ClassGroupingOption.No`. */\n enableElementsClassGrouping?: ClassGroupingOption;\n /**\n * Defines the `bis.GeometricElement3d` sub-class that should be used to load element nodes.\n * Defaults to `bis.GeometricElement3d`. It's expected for the given class to derive from it.\n */\n elementClassSpecification?: SingleSchemaClassSpecification;\n /** Should the tree show models without elements. */\n showEmptyModels?: boolean;\n}\n\n/**\n * Props for [[ModelsTree]] component.\n * @public\n */\nexport interface ModelsTreeProps extends BaseFilterableTreeProps {\n /**\n * Predicate which indicates whether node can be selected or no\n */\n selectionPredicate?: ModelsTreeSelectionPredicate;\n /**\n * Active view used to determine and control visibility\n */\n activeView: Viewport;\n /**\n * Configuration options for the hierarchy loaded in the component.\n */\n hierarchyConfig?: ModelsTreeHierarchyConfiguration;\n /**\n * Auto-update the hierarchy when data in the iModel changes.\n * @alpha\n * @deprecated in 2.0.1. It does not have any effect, auto update is always on.\n */\n enableHierarchyAutoUpdate?: boolean;\n /**\n * Custom visibility handler.\n */\n modelsVisibilityHandler?: ModelsVisibilityHandler | ((props: ModelsVisibilityHandlerProps) => ModelsVisibilityHandler);\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n}\n\n/**\n * A tree component that shows a subject - model - category - element\n * hierarchy along with checkboxes that represent and allow changing\n * the display of those instances.\n * @public\n */\nexport function ModelsTree(props: ModelsTreeProps) {\n const { hierarchyLevelConfig, density, height, width, selectionMode } = props;\n const state = useModelsTreeState(props);\n\n const baseRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: true,\n descriptionEnabled: false,\n levelOffset: 10,\n disableRootNodeCollapse: true,\n },\n };\n\n // istanbul ignore next\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData title={TreeWidget.translate(\"modelTree.noModelFound\")} message={TreeWidget.translate(\"modelTree.noMatchingModelNames\")} />\n );\n }, []);\n\n if (!state) {\n return null;\n }\n\n const isFilterApplied = state.filteringResult?.filteredProvider !== undefined;\n const overlay = state.filteringResult?.isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n return (\n <div className={classNames(\"tree-widget-visibility-tree-base\", \"tree-widget-tree-container\")}>\n <PresentationTree\n state={state}\n selectionMode={selectionMode || SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <ModelsTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n width={width}\n height={height}\n />\n {overlay}\n </div>\n );\n}\n\nfunction ModelsTreeNodeRenderer(props: PresentationTreeNodeRendererProps & { density?: \"default\" | \"enlarged\" }) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={true}\n descriptionEnabled={false}\n levelOffset={10}\n disableRootNodeCollapse={true}\n isEnlarged={props.density === \"enlarged\"}\n />\n );\n}\n\nfunction useModelsTreeState({ filterInfo, onFilterApplied, ...props }: ModelsTreeProps) {\n const rulesets = {\n general: useMemo(\n () =>\n createRuleset({\n enableElementsClassGrouping: !!props.hierarchyConfig?.enableElementsClassGrouping,\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n showEmptyModels: props.hierarchyConfig?.showEmptyModels,\n }),\n [props.hierarchyConfig?.enableElementsClassGrouping, props.hierarchyConfig?.elementClassSpecification, props.hierarchyConfig?.showEmptyModels],\n ),\n search: useMemo(\n () =>\n createSearchRuleset({\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n showEmptyModels: props.hierarchyConfig?.showEmptyModels,\n }),\n [props.hierarchyConfig?.elementClassSpecification, props.hierarchyConfig?.showEmptyModels],\n ),\n };\n\n const treeState = useTreeState({\n ...props,\n ruleset: rulesets.general,\n });\n\n const filteredTreeState = useTreeState({\n ...props,\n ruleset: rulesets.search,\n filterInfo,\n onFilterApplied,\n });\n\n return filterInfo?.filter ? filteredTreeState : treeState;\n}\n\ninterface UseTreeProps extends ModelsTreeProps {\n ruleset: Ruleset;\n}\n\nfunction useTreeState({\n modelsVisibilityHandler,\n activeView,\n selectionPredicate,\n hierarchyConfig,\n iModel,\n ruleset,\n filterInfo,\n onFilterApplied,\n hierarchyLevelConfig,\n}: UseTreeProps) {\n const visibilityHandler = useVisibilityHandler(ruleset.id, iModel, activeView, modelsVisibilityHandler);\n const selectionPredicateRef = useRef(selectionPredicate);\n useEffect(() => {\n selectionPredicateRef.current = selectionPredicate;\n }, [selectionPredicate]);\n\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (onFilterApplied && dataProvider && matchesCount !== undefined) {\n onFilterApplied(dataProvider, matchesCount);\n }\n\n if (visibilityHandler) {\n visibilityHandler.setFilteredDataProvider(dataProvider);\n }\n },\n [onFilterApplied, visibilityHandler],\n );\n\n return useVisibilityTreeState({\n imodel: iModel,\n ruleset,\n pagingSize: PAGING_SIZE,\n appendChildrenCountForGroupingNodes: hierarchyConfig?.enableElementsClassGrouping === ClassGroupingOption.YesWithCounts,\n enableHierarchyAutoUpdate: true,\n customizeTreeNodeItem,\n visibilityHandler,\n filterInfo,\n onFilterChange,\n selectionPredicate: useCallback(\n (node: TreeNodeItem) =>\n !selectionPredicateRef.current || !isPresentationTreeNodeItem(node)\n ? true\n : selectionPredicateRef.current(node.key, ModelsVisibilityHandler.getNodeType(node)),\n [],\n ),\n eventHandler: eventHandlerFactory,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n });\n}\n\nfunction eventHandlerFactory(props: VisibilityTreeEventHandlerParams) {\n return new ModelsTreeEventHandler(props);\n}\n\nfunction useVisibilityHandler(\n rulesetId: string,\n iModel: IModelConnection,\n activeView: Viewport,\n visibilityHandler?: ModelsVisibilityHandler | ((props: ModelsVisibilityHandlerProps) => ModelsVisibilityHandler),\n hierarchyAutoUpdateEnabled?: boolean,\n) {\n const subjectModelIdsCache = useMemo(() => new SubjectModelIdsCache(iModel), [iModel]);\n const [state, setState] = useState<ModelsVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler && typeof visibilityHandler !== \"function\") {\n return;\n }\n\n const visibilityHandlerProps: ModelsVisibilityHandlerProps = {\n rulesetId,\n viewport: activeView,\n hierarchyAutoUpdateEnabled,\n subjectModelIdsCache,\n };\n\n const handler = visibilityHandler ? visibilityHandler(visibilityHandlerProps) : new ModelsVisibilityHandler(visibilityHandlerProps);\n setState(handler);\n return () => {\n handler.dispose();\n };\n }, [rulesetId, activeView, hierarchyAutoUpdateEnabled, subjectModelIdsCache, visibilityHandler]);\n\n return visibilityHandler && typeof visibilityHandler !== \"function\" ? visibilityHandler : state;\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer, addTreeNodeItemCheckbox, addModelsTreeNodeItemIcons]);\n"]}
|
|
1
|
+
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,kCAAkC,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AACjI,OAAO,EAAE,4BAA4B,EAAE,oCAAoC,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAC7I,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,0BAA0B,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAA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B,CAAC,CAAC,CAAC,CAAC,IAAI,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;QACpI,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClB,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEjG,OAAO,iBAAiB,IAAI,OAAO,iBAAiB,KAAK,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC;AAClG,CAAC;AAED,MAAM,qBAAqB,GAAG,iCAAiC,CAAC,CAAC,kCAAkC,EAAE,uBAAuB,EAAE,0BAA0B,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { isPresentationTreeNodeItem, PresentationTree } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { ClassGroupingOption } from \"../common/Types\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, addTreeNodeItemCheckbox, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { ModelsTreeComponent } from \"./ModelsTreeComponent\";\nimport { ModelsTreeEventHandler } from \"./ModelsTreeEventHandler\";\nimport { ModelsVisibilityHandler, SubjectModelIdsCache } from \"./ModelsVisibilityHandler\";\nimport { addModelsTreeNodeItemIcons, createRuleset, createSearchRuleset } from \"./Utils\";\n\nimport type { FilterableTreeNodeRendererProps } from \"../common/TreeRenderer\";\nimport type { UsageTrackedFeatures } from \"../common/UseFeatureReporting\";\nimport type { VisibilityTreeEventHandlerParams } from \"../VisibilityTreeEventHandler\";\nimport type { Ruleset, SingleSchemaClassSpecification } from \"@itwin/presentation-common\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeNodeItem } from \"@itwin/components-react\";\nimport type { IFilteredPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { ModelsTreeSelectionPredicate, ModelsVisibilityHandlerProps } from \"./ModelsVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Props for configuring the hierarchy in [[ModelsTree]].\n * @public\n */\nexport interface ModelsTreeHierarchyConfiguration {\n /** Should the tree group displayed element nodes by class. Defaults to `ClassGroupingOption.No`. */\n enableElementsClassGrouping?: ClassGroupingOption;\n /**\n * Defines the `bis.GeometricElement3d` sub-class that should be used to load element nodes.\n * Defaults to `bis.GeometricElement3d`. It's expected for the given class to derive from it.\n */\n elementClassSpecification?: SingleSchemaClassSpecification;\n /** Should the tree show models without elements. */\n showEmptyModels?: boolean;\n}\n\n/**\n * Props for [[ModelsTree]] component.\n * @public\n */\nexport interface ModelsTreeProps extends BaseFilterableTreeProps {\n /**\n * Predicate which indicates whether node can be selected or no\n */\n selectionPredicate?: ModelsTreeSelectionPredicate;\n /**\n * Active view used to determine and control visibility\n */\n activeView: Viewport;\n /**\n * Configuration options for the hierarchy loaded in the component.\n */\n hierarchyConfig?: ModelsTreeHierarchyConfiguration;\n /**\n * Auto-update the hierarchy when data in the iModel changes.\n * @alpha\n * @deprecated in 2.0.1. It does not have any effect, auto update is always on.\n */\n enableHierarchyAutoUpdate?: boolean;\n /**\n * Custom visibility handler.\n */\n modelsVisibilityHandler?: ModelsVisibilityHandler | ((props: ModelsVisibilityHandlerProps) => ModelsVisibilityHandler);\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Reports performance of a feature.\n * @param featureId ID of the feature.\n * @param elapsedTime Elapsed time of the feature.\n * @beta\n */\n onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;\n /**\n * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A tree component that shows a subject - model - category - element\n * hierarchy along with checkboxes that represent and allow changing\n * the display of those instances.\n * @public\n */\nexport function ModelsTree(props: ModelsTreeProps) {\n const { hierarchyLevelConfig, density, height, width, selectionMode, onFeatureUsed } = props;\n const { reportUsage } = useFeatureReporting({ treeIdentifier: ModelsTreeComponent.id, onFeatureUsed });\n const state = useModelsTreeState({ ...props, reportUsage });\n\n const baseRendererProps = {\n reportUsage,\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: true,\n descriptionEnabled: false,\n levelOffset: 10,\n disableRootNodeCollapse: true,\n onVisibilityToggled: () => reportUsage({ featureId: \"visibility-change\", reportInteraction: true }),\n },\n };\n\n // istanbul ignore next\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData title={TreeWidget.translate(\"modelTree.noModelFound\")} message={TreeWidget.translate(\"modelTree.noMatchingModelNames\")} />\n );\n }, []);\n\n if (!state) {\n return null;\n }\n\n const isFilterApplied = state.filteringResult?.filteredProvider !== undefined;\n const overlay = state.filteringResult?.isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n return (\n <div className={classNames(\"tree-widget-visibility-tree-base\", \"tree-widget-tree-container\")}>\n <PresentationTree\n state={state}\n selectionMode={selectionMode || SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <ModelsTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n width={width}\n height={height}\n />\n {overlay}\n </div>\n );\n}\n\ninterface ModelsTreeNodeRendererProps extends FilterableTreeNodeRendererProps {\n density?: \"default\" | \"enlarged\";\n}\n\nfunction ModelsTreeNodeRenderer(props: ModelsTreeNodeRendererProps) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={true}\n descriptionEnabled={false}\n levelOffset={10}\n disableRootNodeCollapse={true}\n isEnlarged={props.density === \"enlarged\"}\n onVisibilityToggled={() => props.reportUsage?.({ featureId: \"visibility-change\", reportInteraction: true })}\n />\n );\n}\n\ninterface UseModelsTreeStateProps extends Omit<ModelsTreeProps, \"onFeatureUsed\"> {\n reportUsage: (props: { featureId?: UsageTrackedFeatures; reportInteraction: boolean }) => void;\n}\n\nfunction useModelsTreeState({ filterInfo, onFilterApplied, ...props }: UseModelsTreeStateProps) {\n const rulesets = {\n general: useMemo(\n () =>\n createRuleset({\n enableElementsClassGrouping: !!props.hierarchyConfig?.enableElementsClassGrouping,\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n showEmptyModels: props.hierarchyConfig?.showEmptyModels,\n }),\n [props.hierarchyConfig?.enableElementsClassGrouping, props.hierarchyConfig?.elementClassSpecification, props.hierarchyConfig?.showEmptyModels],\n ),\n search: useMemo(\n () =>\n createSearchRuleset({\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n showEmptyModels: props.hierarchyConfig?.showEmptyModels,\n }),\n [props.hierarchyConfig?.elementClassSpecification, props.hierarchyConfig?.showEmptyModels],\n ),\n };\n\n const treeState = useTreeState({\n ...props,\n ruleset: rulesets.general,\n });\n\n const filteredTreeState = useTreeState({\n ...props,\n ruleset: rulesets.search,\n filterInfo,\n onFilterApplied,\n });\n\n return filterInfo?.filter ? filteredTreeState : treeState;\n}\n\ninterface UseTreeProps extends Omit<ModelsTreeProps, \"onFeatureUsed\"> {\n ruleset: Ruleset;\n reportUsage: (props: { featureId?: UsageTrackedFeatures; reportInteraction: boolean }) => void;\n}\n\nfunction useTreeState({\n modelsVisibilityHandler,\n activeView,\n selectionPredicate,\n hierarchyConfig,\n iModel,\n ruleset,\n filterInfo,\n onFilterApplied,\n hierarchyLevelConfig,\n onPerformanceMeasured,\n reportUsage,\n}: UseTreeProps) {\n const visibilityHandler = useVisibilityHandler(ruleset.id, iModel, activeView, modelsVisibilityHandler);\n const selectionPredicateRef = useRef(selectionPredicate);\n useEffect(() => {\n selectionPredicateRef.current = selectionPredicate;\n }, [selectionPredicate]);\n\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (dataProvider && matchesCount !== undefined) {\n reportUsage({ featureId: \"filtering\", reportInteraction: false });\n onFilterApplied?.(dataProvider, matchesCount);\n }\n\n if (visibilityHandler) {\n visibilityHandler.setFilteredDataProvider(dataProvider);\n }\n },\n [onFilterApplied, reportUsage, visibilityHandler],\n );\n\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: ModelsTreeComponent.id,\n onPerformanceMeasured,\n });\n\n const eventHandlerFactory = useCallback(\n (handlerProps: VisibilityTreeEventHandlerParams) => {\n return new ModelsTreeEventHandler({ ...handlerProps, reportUsage });\n },\n [reportUsage],\n );\n\n return useVisibilityTreeState({\n imodel: iModel,\n ruleset,\n pagingSize: PAGING_SIZE,\n appendChildrenCountForGroupingNodes: hierarchyConfig?.enableElementsClassGrouping === ClassGroupingOption.YesWithCounts,\n enableHierarchyAutoUpdate: true,\n customizeTreeNodeItem,\n visibilityHandler,\n filterInfo,\n onFilterChange,\n selectionPredicate: useCallback(\n (node: TreeNodeItem) =>\n !selectionPredicateRef.current || !isPresentationTreeNodeItem(node)\n ? true\n : selectionPredicateRef.current(node.key, ModelsVisibilityHandler.getNodeType(node)),\n [],\n ),\n eventHandler: eventHandlerFactory,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n onNodeLoaded: filterInfo ? undefined : onNodeLoaded,\n reportUsage: filterInfo ? undefined : reportUsage,\n onHierarchyLimitExceeded: () => reportUsage({ featureId: \"hierarchy-level-size-limit-hit\", reportInteraction: false }),\n });\n}\n\nfunction useVisibilityHandler(\n rulesetId: string,\n iModel: IModelConnection,\n activeView: Viewport,\n visibilityHandler?: ModelsVisibilityHandler | ((props: ModelsVisibilityHandlerProps) => ModelsVisibilityHandler),\n hierarchyAutoUpdateEnabled?: boolean,\n) {\n const subjectModelIdsCache = useMemo(() => new SubjectModelIdsCache(iModel), [iModel]);\n const [state, setState] = useState<ModelsVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler && typeof visibilityHandler !== \"function\") {\n return;\n }\n\n const visibilityHandlerProps: ModelsVisibilityHandlerProps = {\n rulesetId,\n viewport: activeView,\n hierarchyAutoUpdateEnabled,\n subjectModelIdsCache,\n };\n\n const handler = visibilityHandler ? visibilityHandler(visibilityHandlerProps) : new ModelsVisibilityHandler(visibilityHandlerProps);\n setState(handler);\n return () => {\n handler.dispose();\n };\n }, [rulesetId, activeView, hierarchyAutoUpdateEnabled, subjectModelIdsCache, visibilityHandler]);\n\n return visibilityHandler && typeof visibilityHandler !== \"function\" ? visibilityHandler : state;\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer, addTreeNodeItemCheckbox, addModelsTreeNodeItemIcons]);\n"]}
|
|
@@ -4,6 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
import "../VisibilityTreeBase.scss";
|
|
7
|
+
import classNames from "classnames";
|
|
7
8
|
import { Fragment, useEffect, useMemo, useState } from "react";
|
|
8
9
|
import { useActiveIModelConnection, useActiveViewport } from "@itwin/appui-react";
|
|
9
10
|
import { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from "@itwin/itwinui-icons-react";
|
|
@@ -15,7 +16,6 @@ import { AutoSizer } from "../../utils/AutoSizer";
|
|
|
15
16
|
import { ModelsTree } from "./ModelsTree";
|
|
16
17
|
import { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from "./ModelsVisibilityHandler";
|
|
17
18
|
import { queryModelsForHeaderActions } from "./Utils";
|
|
18
|
-
import classNames from "classnames";
|
|
19
19
|
/**
|
|
20
20
|
* A component that renders [[ModelsTree]] and a header with filtering capabilities
|
|
21
21
|
* and header buttons.
|
|
@@ -80,23 +80,32 @@ function ModelsTreeComponentImpl(props) {
|
|
|
80
80
|
}, [iModel]);
|
|
81
81
|
const filterInfo = useMemo(() => ({ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }), [filterString, searchOptions.activeMatchIndex]);
|
|
82
82
|
return (_jsxs("div", { className: "tree-widget-tree-with-header", children: [_jsx(TreeHeader, { onFilterClear: searchOptions.onFilterCancel, onFilterStart: searchOptions.onFilterStart, onSelectedChanged: searchOptions.onResultSelectedChanged, resultCount: searchOptions.matchedResultCount, selectedIndex: searchOptions.activeMatchIndex, density: props.density, children: props.headerButtons
|
|
83
|
-
? props.headerButtons.map((btn, index) => _jsx(Fragment, { children: btn({ viewport, models: availableModels }) }, index))
|
|
83
|
+
? props.headerButtons.map((btn, index) => (_jsx(Fragment, { children: btn({ viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed }) }, index)))
|
|
84
84
|
: [
|
|
85
|
-
_jsx(ShowAllButton, { viewport: viewport, models: availableModels, density: props.density }, "show-all-btn"),
|
|
86
|
-
_jsx(HideAllButton, { viewport: viewport, models: availableModels, density: props.density }, "hide-all-btn"),
|
|
87
|
-
_jsx(InvertButton, { viewport: viewport, models: availableModels, density: props.density }, "invert-all-btn"),
|
|
88
|
-
_jsx(View2DButton, { viewport: viewport, models: availableModels, density: props.density }, "view-2d-btn"),
|
|
89
|
-
_jsx(View3DButton, { viewport: viewport, models: availableModels, density: props.density }, "view-3d-btn"),
|
|
85
|
+
_jsx(ShowAllButton, { viewport: viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed }, "show-all-btn"),
|
|
86
|
+
_jsx(HideAllButton, { viewport: viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed }, "hide-all-btn"),
|
|
87
|
+
_jsx(InvertButton, { viewport: viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed }, "invert-all-btn"),
|
|
88
|
+
_jsx(View2DButton, { viewport: viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed }, "view-2d-btn"),
|
|
89
|
+
_jsx(View3DButton, { viewport: viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed }, "view-3d-btn"),
|
|
90
90
|
] }), _jsx("div", { className: contentClassName, children: _jsx(AutoSizer, { children: ({ width, height }) => (_jsx(ModelsTree, { ...props, iModel: iModel, activeView: viewport, width: width, height: height, filterInfo: filterInfo, onFilterApplied: onFilterApplied })) }) })] }));
|
|
91
91
|
}
|
|
92
92
|
function ShowAllButton(props) {
|
|
93
|
-
return (_jsx(IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("showAll"), onClick: () =>
|
|
93
|
+
return (_jsx(IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("showAll"), onClick: () => {
|
|
94
|
+
props.onFeatureUsed?.(`${ModelsTreeComponent.id}-showall`);
|
|
95
|
+
void showAllModels(props.models.map((model) => model.id), props.viewport);
|
|
96
|
+
}, children: _jsx(SvgVisibilityShow, {}) }));
|
|
94
97
|
}
|
|
95
98
|
function HideAllButton(props) {
|
|
96
|
-
return (_jsx(IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("hideAll"), onClick: () =>
|
|
99
|
+
return (_jsx(IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("hideAll"), onClick: () => {
|
|
100
|
+
props.onFeatureUsed?.(`${ModelsTreeComponent.id}-hideall`);
|
|
101
|
+
void hideAllModels(props.models.map((model) => model.id), props.viewport);
|
|
102
|
+
}, children: _jsx(SvgVisibilityHide, {}) }));
|
|
97
103
|
}
|
|
98
104
|
function InvertButton(props) {
|
|
99
|
-
return (_jsx(IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("invert"), onClick: () =>
|
|
105
|
+
return (_jsx(IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("invert"), onClick: () => {
|
|
106
|
+
props.onFeatureUsed?.(`${ModelsTreeComponent.id}-invert`);
|
|
107
|
+
void invertAllModels(props.models.map((model) => model.id), props.viewport);
|
|
108
|
+
}, children: _jsx(SvgVisibilityHalf, {}) }));
|
|
100
109
|
}
|
|
101
110
|
function View2DButton(props) {
|
|
102
111
|
const models2d = useMemo(() => {
|
|
@@ -107,7 +116,10 @@ function View2DButton(props) {
|
|
|
107
116
|
setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));
|
|
108
117
|
return props.viewport.onViewedModelsChanged.addListener((vp) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));
|
|
109
118
|
}, [models2d, props.viewport]);
|
|
110
|
-
return (_jsx(Button, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("toggle2DViews"), onClick: () =>
|
|
119
|
+
return (_jsx(Button, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("toggle2DViews"), onClick: () => {
|
|
120
|
+
props.onFeatureUsed?.(`${ModelsTreeComponent.id}-view2d`);
|
|
121
|
+
void toggleModels(models2d, is2dToggleActive, props.viewport);
|
|
122
|
+
}, disabled: models2d.length === 0, endIcon: is2dToggleActive ? _jsx(SvgVisibilityShow, {}) : _jsx(SvgVisibilityHide, {}), children: TreeWidget.translate("label2D") }));
|
|
111
123
|
}
|
|
112
124
|
function View3DButton(props) {
|
|
113
125
|
const models3d = useMemo(() => {
|
|
@@ -118,6 +130,9 @@ function View3DButton(props) {
|
|
|
118
130
|
setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));
|
|
119
131
|
return props.viewport.onViewedModelsChanged.addListener((vp) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));
|
|
120
132
|
}, [models3d, props.viewport]);
|
|
121
|
-
return (_jsx(Button, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("toggle3DViews"), onClick: () =>
|
|
133
|
+
return (_jsx(Button, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("toggle3DViews"), onClick: () => {
|
|
134
|
+
props.onFeatureUsed?.(`${ModelsTreeComponent.id}-view3d`);
|
|
135
|
+
void toggleModels(models3d, is3dToggleActive, props.viewport);
|
|
136
|
+
}, disabled: models3d.length === 0, endIcon: is3dToggleActive ? _jsx(SvgVisibilityShow, {}) : _jsx(SvgVisibilityHide, {}), children: TreeWidget.translate("label3D") }));
|
|
122
137
|
}
|
|
123
138
|
//# sourceMappingURL=ModelsTreeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,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CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EACtD,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,eAAe,CAAC,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAC5E,QAAQ,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,EAC/B,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAC,iBAAiB,KAAG,CAAC,CAAC,CAAC,KAAC,iBAAiB,KAAG,YAExE,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,GACzB,CACV,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { Fragment, useEffect, useMemo, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { ModelsTree } from \"./ModelsTree\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./ModelsVisibilityHandler\";\nimport { queryModelsForHeaderActions } from \"./Utils\";\n\nimport type { IModelConnection, ScreenViewport, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { ModelsTreeProps } from \"./ModelsTree\";\nimport classNames from \"classnames\";\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to [[ModelsTreeComponent]] header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/**\n * Props for [[ModelsTreeComponent]].\n * @public\n */\nexport interface ModelTreeComponentProps extends Omit<ModelsTreeProps, \"iModel\" | \"activeView\" | \"width\" | \"height\" | \"filterInfo\" | \"onFilterApplied\"> {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n}\n\n/**\n * A component that renders [[ModelsTree]] and a header with filtering capabilities\n * and header buttons.\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton;\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nModelsTreeComponent.id = \"models-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"models\");\n\nfunction ModelsTreeComponentImpl(props: ModelTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n const { viewport, iModel } = props;\n const { searchOptions, filterString, onFilterApplied } = useTreeFilteringState();\n const contentClassName = classNames(\"tree-widget-tree-content\", props.density === \"enlarged\" && \"enlarge\");\n\n useEffect(() => {\n queryModelsForHeaderActions(iModel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch((_e) => {\n setAvailableModels([]);\n });\n }, [iModel]);\n\n const filterInfo = useMemo(\n () => ({ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }),\n [filterString, searchOptions.activeMatchIndex],\n );\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n density={props.density}\n >\n {props.headerButtons\n ? props.headerButtons.map((btn, index) => <Fragment key={index}>{btn({ viewport, models: availableModels })}</Fragment>)\n : [\n <ShowAllButton viewport={viewport} models={availableModels} key=\"show-all-btn\" density={props.density} />,\n <HideAllButton viewport={viewport} models={availableModels} key=\"hide-all-btn\" density={props.density} />,\n <InvertButton viewport={viewport} models={availableModels} key=\"invert-all-btn\" density={props.density} />,\n <View2DButton viewport={viewport} models={availableModels} key=\"view-2d-btn\" density={props.density} />,\n <View3DButton viewport={viewport} models={availableModels} key=\"view-3d-btn\" density={props.density} />,\n ]}\n </TreeHeader>\n <div className={contentClassName}>\n <AutoSizer>\n {({ width, height }) => (\n <ModelsTree\n {...props}\n iModel={iModel}\n activeView={viewport}\n width={width}\n height={height}\n filterInfo={filterInfo}\n onFilterApplied={onFilterApplied}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nfunction ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() =>\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n )\n }\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() =>\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n )\n }\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"invert\")}\n onClick={() =>\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n )\n }\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\nfunction View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));\n }, [models2d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"toggle2DViews\")}\n onClick={() => void toggleModels(models2d, is2dToggleActive, props.viewport)}\n disabled={models2d.length === 0}\n endIcon={is2dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"label2D\")}\n </Button>\n );\n}\n\nfunction View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));\n }, [models3d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"toggle3DViews\")}\n onClick={() => void toggleModels(models3d, is3dToggleActive, props.viewport)}\n disabled={models3d.length === 0}\n endIcon={is3dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"label3D\")}\n </Button>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MA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AAG,EAAE;QACb,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnE,OAAO,KAAK,CAAC,QAAQ,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,EAAY,EAAE,EAAE,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACpI,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/B,OAAO,CACL,KAAC,MAAM,IACL,IAAI,EAAE,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EACtD,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,eAAe,CAAC,EAC5C,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,CAAC,aAAa,EAAE,CAAC,GAAG,mBAAmB,CAAC,EAAE,SAAS,CAAC,CAAC;YAC1D,KAAK,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChE,CAAC,EACD,QAAQ,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,EAC/B,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAC,iBAAiB,KAAG,CAAC,CAAC,CAAC,KAAC,iBAAiB,KAAG,YAExE,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,GACzB,CACV,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { Fragment, useEffect, useMemo, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { ModelsTree } from \"./ModelsTree\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./ModelsVisibilityHandler\";\nimport { queryModelsForHeaderActions } from \"./Utils\";\n\nimport type { IModelConnection, ScreenViewport, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { ModelsTreeProps } from \"./ModelsTree\";\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to [[ModelsTreeComponent]] header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/**\n * Props for [[ModelsTreeComponent]].\n * @public\n */\nexport interface ModelTreeComponentProps extends Omit<ModelsTreeProps, \"iModel\" | \"activeView\" | \"width\" | \"height\" | \"filterInfo\" | \"onFilterApplied\"> {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n}\n\n/**\n * A component that renders [[ModelsTree]] and a header with filtering capabilities\n * and header buttons.\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton;\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nModelsTreeComponent.id = \"models-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"models\");\n\nfunction ModelsTreeComponentImpl(props: ModelTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n const { viewport, iModel } = props;\n const { searchOptions, filterString, onFilterApplied } = useTreeFilteringState();\n const contentClassName = classNames(\"tree-widget-tree-content\", props.density === \"enlarged\" && \"enlarge\");\n\n useEffect(() => {\n queryModelsForHeaderActions(iModel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch((_e) => {\n setAvailableModels([]);\n });\n }, [iModel]);\n\n const filterInfo = useMemo(\n () => ({ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }),\n [filterString, searchOptions.activeMatchIndex],\n );\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n density={props.density}\n >\n {props.headerButtons\n ? props.headerButtons.map((btn, index) => (\n <Fragment key={index}>{btn({ viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed })}</Fragment>\n ))\n : [\n <ShowAllButton viewport={viewport} models={availableModels} key=\"show-all-btn\" density={props.density} onFeatureUsed={props.onFeatureUsed} />,\n <HideAllButton viewport={viewport} models={availableModels} key=\"hide-all-btn\" density={props.density} onFeatureUsed={props.onFeatureUsed} />,\n <InvertButton viewport={viewport} models={availableModels} key=\"invert-all-btn\" density={props.density} onFeatureUsed={props.onFeatureUsed} />,\n <View2DButton viewport={viewport} models={availableModels} key=\"view-2d-btn\" density={props.density} onFeatureUsed={props.onFeatureUsed} />,\n <View3DButton viewport={viewport} models={availableModels} key=\"view-3d-btn\" density={props.density} onFeatureUsed={props.onFeatureUsed} />,\n ]}\n </TreeHeader>\n <div className={contentClassName}>\n <AutoSizer>\n {({ width, height }) => (\n <ModelsTree\n {...props}\n iModel={iModel}\n activeView={viewport}\n width={width}\n height={height}\n filterInfo={filterInfo}\n onFilterApplied={onFilterApplied}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nfunction ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() => {\n props.onFeatureUsed?.(`${ModelsTreeComponent.id}-showall`);\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() => {\n props.onFeatureUsed?.(`${ModelsTreeComponent.id}-hideall`);\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"invert\")}\n onClick={() => {\n props.onFeatureUsed?.(`${ModelsTreeComponent.id}-invert`);\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\nfunction View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));\n }, [models2d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"toggle2DViews\")}\n onClick={() => {\n props.onFeatureUsed?.(`${ModelsTreeComponent.id}-view2d`);\n void toggleModels(models2d, is2dToggleActive, props.viewport);\n }}\n disabled={models2d.length === 0}\n endIcon={is2dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"label2D\")}\n </Button>\n );\n}\n\nfunction View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));\n }, [models3d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"toggle3DViews\")}\n onClick={() => {\n props.onFeatureUsed?.(`${ModelsTreeComponent.id}-view3d`);\n void toggleModels(models3d, is3dToggleActive, props.viewport);\n }}\n disabled={models3d.length === 0}\n endIcon={is3dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"label3D\")}\n </Button>\n );\n}\n"]}
|
|
@@ -2,8 +2,18 @@
|
|
|
2
2
|
* @module IModelComponents
|
|
3
3
|
*/
|
|
4
4
|
import { VisibilityTreeEventHandler } from "../VisibilityTreeEventHandler";
|
|
5
|
+
import type { VisibilityTreeEventHandlerParams } from "../VisibilityTreeEventHandler";
|
|
5
6
|
import type { TreeNodeEventArgs } from "@itwin/components-react";
|
|
7
|
+
import type { UsageTrackedFeatures } from "../common/UseFeatureReporting";
|
|
8
|
+
export interface ModelsTreeEventHandlerProps extends VisibilityTreeEventHandlerParams {
|
|
9
|
+
reportUsage: (props: {
|
|
10
|
+
featureId?: UsageTrackedFeatures;
|
|
11
|
+
reportInteraction: boolean;
|
|
12
|
+
}) => void;
|
|
13
|
+
}
|
|
6
14
|
export declare class ModelsTreeEventHandler extends VisibilityTreeEventHandler {
|
|
15
|
+
private _reportUsage;
|
|
16
|
+
constructor(props: ModelsTreeEventHandlerProps);
|
|
7
17
|
onNodeDoubleClick({ nodeId }: TreeNodeEventArgs): Promise<void>;
|
|
8
18
|
}
|
|
9
19
|
//# sourceMappingURL=ModelsTreeEventHandler.d.ts.map
|
|
@@ -11,6 +11,10 @@ import { isPresentationTreeNodeItem } from "@itwin/presentation-components";
|
|
|
11
11
|
import { VisibilityTreeEventHandler } from "../VisibilityTreeEventHandler";
|
|
12
12
|
import { ModelsTreeNodeType, ModelsVisibilityHandler } from "./ModelsVisibilityHandler";
|
|
13
13
|
export class ModelsTreeEventHandler extends VisibilityTreeEventHandler {
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super(props);
|
|
16
|
+
this._reportUsage = props.reportUsage;
|
|
17
|
+
}
|
|
14
18
|
async onNodeDoubleClick({ nodeId }) {
|
|
15
19
|
const model = this.modelSource.getModel();
|
|
16
20
|
const node = model.getNode(nodeId);
|
|
@@ -22,6 +26,7 @@ export class ModelsTreeEventHandler extends VisibilityTreeEventHandler {
|
|
|
22
26
|
}
|
|
23
27
|
const instanceIds = node.item.key.instanceKeys.map((instanceKey) => instanceKey.id);
|
|
24
28
|
await IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);
|
|
29
|
+
this._reportUsage({ featureId: "zoom-to-node", reportInteraction: false });
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
//# sourceMappingURL=ModelsTreeEventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeEventHandler.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeEventHandler.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"ModelsTreeEventHandler.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeEventHandler.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAUxF,MAAM,OAAO,sBAAuB,SAAQ,0BAA0B;IAGpE,YAAY,KAAkC;QAC5C,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC;IACxC,CAAC;IAEe,KAAK,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAqB;QACnE,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEnC,IACE,CAAC,IAAI;YACL,CAAC,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC;YACtC,uBAAuB,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,kBAAkB,CAAC,OAAO;YAC7E,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAC1C;YACA,OAAO;SACR;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAEpF,MAAM,SAAS,CAAC,WAAW,CAAC,YAAY,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;QAEtE,IAAI,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModelComponents\n */\n\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { NodeKey } from \"@itwin/presentation-common\";\nimport { isPresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { VisibilityTreeEventHandler } from \"../VisibilityTreeEventHandler\";\nimport { ModelsTreeNodeType, ModelsVisibilityHandler } from \"./ModelsVisibilityHandler\";\n\nimport type { VisibilityTreeEventHandlerParams } from \"../VisibilityTreeEventHandler\";\nimport type { TreeNodeEventArgs } from \"@itwin/components-react\";\nimport type { UsageTrackedFeatures } from \"../common/UseFeatureReporting\";\n\nexport interface ModelsTreeEventHandlerProps extends VisibilityTreeEventHandlerParams {\n reportUsage: (props: { featureId?: UsageTrackedFeatures; reportInteraction: boolean }) => void;\n}\n\nexport class ModelsTreeEventHandler extends VisibilityTreeEventHandler {\n private _reportUsage: (props: { featureId: \"zoom-to-node\"; reportInteraction: false }) => void;\n\n constructor(props: ModelsTreeEventHandlerProps) {\n super(props);\n this._reportUsage = props.reportUsage;\n }\n\n public override async onNodeDoubleClick({ nodeId }: TreeNodeEventArgs) {\n const model = this.modelSource.getModel();\n const node = model.getNode(nodeId);\n\n if (\n !node ||\n !isPresentationTreeNodeItem(node.item) ||\n ModelsVisibilityHandler.getNodeType(node.item) !== ModelsTreeNodeType.Element ||\n !NodeKey.isInstancesNodeKey(node.item.key)\n ) {\n return;\n }\n\n const instanceIds = node.item.key.instanceKeys.map((instanceKey) => instanceKey.id);\n\n await IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);\n\n this._reportUsage({ featureId: \"zoom-to-node\", reportInteraction: false });\n }\n}\n"]}
|
|
@@ -72,8 +72,11 @@ export declare class ModelsVisibilityHandler implements IVisibilityHandler {
|
|
|
72
72
|
protected changeModelsVisibility(ids: Id64String[], visible: boolean): Promise<void>;
|
|
73
73
|
protected changeCategoryState(categoryId: Id64String, parentModelId: Id64String | undefined, on: boolean): void;
|
|
74
74
|
protected changeElementGroupingNodeState(key: ECClassGroupingNodeKey, on: boolean): Promise<void>;
|
|
75
|
-
protected changeElementState(id: Id64String, modelId: Id64String | undefined, categoryId: Id64String | undefined, on: boolean): Promise<void>;
|
|
75
|
+
protected changeElementState(id: Id64String, modelId: Id64String | undefined, categoryId: Id64String | undefined, on: boolean, hasChildren?: boolean): Promise<void>;
|
|
76
76
|
protected changeElementsState(modelId: Id64String | undefined, categoryId: Id64String | undefined, elementIds: AsyncGenerator<Id64String>, on: boolean): Promise<void>;
|
|
77
|
+
private changeElementStateInternal;
|
|
78
|
+
private isElementDisplayedByDefault;
|
|
79
|
+
private hasExclusiveAlwaysDrawnElements;
|
|
77
80
|
private onVisibilityChangeInternal;
|
|
78
81
|
private onViewChanged;
|
|
79
82
|
private onElementAlwaysDrawnChanged;
|
|
@@ -120,10 +120,10 @@ export class ModelsVisibilityHandler {
|
|
|
120
120
|
}
|
|
121
121
|
/** Changes visibility of the items represented by the tree node. */
|
|
122
122
|
async changeVisibility(node, on) {
|
|
123
|
-
|
|
124
|
-
if (!nodeKey) {
|
|
123
|
+
if (!isPresentationTreeNodeItem(node)) {
|
|
125
124
|
return;
|
|
126
125
|
}
|
|
126
|
+
const nodeKey = node.key;
|
|
127
127
|
if (NodeKey.isClassGroupingNodeKey(nodeKey)) {
|
|
128
128
|
await this.changeElementGroupingNodeState(nodeKey, on);
|
|
129
129
|
return;
|
|
@@ -141,7 +141,7 @@ export class ModelsVisibilityHandler {
|
|
|
141
141
|
this.changeCategoryState(nodeKey.instanceKeys[0].id, this.getCategoryParentModelId(node), on);
|
|
142
142
|
}
|
|
143
143
|
else {
|
|
144
|
-
await this.changeElementState(nodeKey.instanceKeys[0].id, this.getElementModelId(node), this.getElementCategoryId(node), on);
|
|
144
|
+
await this.changeElementState(nodeKey.instanceKeys[0].id, this.getElementModelId(node), this.getElementCategoryId(node), on, node.hasChildren);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
async getSubjectNodeVisibility(ids, node) {
|
|
@@ -314,40 +314,55 @@ export class ModelsVisibilityHandler {
|
|
|
314
314
|
const { modelId, categoryId, elementIds } = await this.getGroupedElementIds(key);
|
|
315
315
|
await this.changeElementsState(modelId, categoryId, elementIds.getElementIds(), on);
|
|
316
316
|
}
|
|
317
|
-
async changeElementState(id, modelId, categoryId, on) {
|
|
317
|
+
async changeElementState(id, modelId, categoryId, on, hasChildren) {
|
|
318
|
+
const isDisplayedByDefault = this.isElementDisplayedByDefault(modelId, categoryId);
|
|
319
|
+
const isHiddenDueToExclusiveAlwaysDrawnElements = this.hasExclusiveAlwaysDrawnElements();
|
|
320
|
+
this.changeElementStateInternal(id, on, isDisplayedByDefault, isHiddenDueToExclusiveAlwaysDrawnElements);
|
|
321
|
+
if (!hasChildren) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
318
324
|
const childIdsContainer = this.getAssemblyElementIds(id);
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
for await (const childId of childIdsContainer.getElementIds()) {
|
|
322
|
-
yield childId;
|
|
323
|
-
}
|
|
325
|
+
for await (const childId of childIdsContainer.getElementIds()) {
|
|
326
|
+
this.changeElementStateInternal(childId, on, isDisplayedByDefault, isHiddenDueToExclusiveAlwaysDrawnElements);
|
|
324
327
|
}
|
|
325
|
-
await this.changeElementsState(modelId, categoryId, elementIds(), on);
|
|
326
328
|
}
|
|
327
329
|
async changeElementsState(modelId, categoryId, elementIds, on) {
|
|
328
|
-
const isDisplayedByDefault = modelId
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
this.
|
|
332
|
-
|
|
330
|
+
const isDisplayedByDefault = this.isElementDisplayedByDefault(modelId, categoryId);
|
|
331
|
+
const isHiddenDueToExclusiveAlwaysDrawnElements = this.hasExclusiveAlwaysDrawnElements();
|
|
332
|
+
for await (const elementId of elementIds) {
|
|
333
|
+
this.changeElementStateInternal(elementId, on, isDisplayedByDefault, isHiddenDueToExclusiveAlwaysDrawnElements);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
changeElementStateInternal(elementId, on, isDisplayedByDefault, isHiddenDueToExclusiveAlwaysDrawnElements) {
|
|
337
|
+
let changedNeverDraw = false;
|
|
338
|
+
let changedAlwaysDrawn = false;
|
|
333
339
|
const currNeverDrawn = new Set(this._props.viewport.neverDrawn ? this._props.viewport.neverDrawn : []);
|
|
334
340
|
const currAlwaysDrawn = new Set(this._props.viewport.alwaysDrawn ? this._props.viewport.alwaysDrawn : /* istanbul ignore next */ []);
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
+
if (on) {
|
|
342
|
+
changedNeverDraw = changedNeverDraw || currNeverDrawn.delete(elementId);
|
|
343
|
+
if ((!isDisplayedByDefault || isHiddenDueToExclusiveAlwaysDrawnElements) && !currAlwaysDrawn.has(elementId)) {
|
|
344
|
+
currAlwaysDrawn.add(elementId);
|
|
345
|
+
changedAlwaysDrawn = true;
|
|
341
346
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
changedAlwaysDrawn = changedAlwaysDrawn || currAlwaysDrawn.delete(elementId);
|
|
350
|
+
if (isDisplayedByDefault && !isHiddenDueToExclusiveAlwaysDrawnElements && !currNeverDrawn.has(elementId)) {
|
|
351
|
+
currNeverDrawn.add(elementId);
|
|
352
|
+
changedNeverDraw = true;
|
|
347
353
|
}
|
|
348
354
|
}
|
|
349
|
-
this._props.viewport.setNeverDrawn(currNeverDrawn);
|
|
350
|
-
this._props.viewport.setAlwaysDrawn(currAlwaysDrawn, this._props.viewport.isAlwaysDrawnExclusive);
|
|
355
|
+
changedNeverDraw && this._props.viewport.setNeverDrawn(currNeverDrawn);
|
|
356
|
+
changedAlwaysDrawn && this._props.viewport.setAlwaysDrawn(currAlwaysDrawn, this._props.viewport.isAlwaysDrawnExclusive);
|
|
357
|
+
}
|
|
358
|
+
isElementDisplayedByDefault(modelId, categoryId) {
|
|
359
|
+
return (!!modelId &&
|
|
360
|
+
this.getModelDisplayStatus(modelId).state === "visible" &&
|
|
361
|
+
!!categoryId &&
|
|
362
|
+
this.getCategoryDisplayStatus(categoryId, modelId).state === "visible");
|
|
363
|
+
}
|
|
364
|
+
hasExclusiveAlwaysDrawnElements() {
|
|
365
|
+
return this._props.viewport.isAlwaysDrawnExclusive && 0 !== this._props.viewport.alwaysDrawn?.size;
|
|
351
366
|
}
|
|
352
367
|
onVisibilityChangeInternal() {
|
|
353
368
|
if (this._pendingVisibilityChange) {
|