@itwin/tree-widget-react 3.15.1 → 3.16.1
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/lib/cjs/tree-widget-react/TreeWidget.d.ts +1 -2
- package/lib/cjs/tree-widget-react/TreeWidget.js +12 -12
- package/lib/cjs/tree-widget-react/TreeWidget.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.d.ts +2 -3
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +5 -4
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +4 -7
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +39 -31
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +6 -2
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +3 -11
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +45 -36
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +1 -3
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +30 -30
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +2 -7
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +8 -21
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.d.ts +3 -0
- package/lib/cjs/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js +7 -7
- package/lib/cjs/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/useGuid.d.ts +2 -0
- package/lib/cjs/tree-widget-react/components/trees/common/useGuid.js +14 -0
- package/lib/cjs/tree-widget-react/components/trees/common/useGuid.js.map +1 -0
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +4 -1
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.d.ts +4 -6
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +31 -26
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +4 -2
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +1 -5
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +44 -44
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.d.ts +3 -6
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +20 -16
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +3 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +6 -10
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +107 -64
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js +18 -8
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.d.ts +24 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.js +46 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +40 -9
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +68 -39
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/FilteredTree.d.ts +13 -5
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js +20 -14
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +4 -13
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +66 -60
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +6 -2
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +155 -177
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/TreeWidget.d.ts +1 -2
- package/lib/esm/tree-widget-react/TreeWidget.js +12 -12
- package/lib/esm/tree-widget-react/TreeWidget.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.d.ts +2 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +5 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +4 -7
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +39 -31
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +6 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +3 -11
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +45 -36
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +1 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +30 -30
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +2 -7
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +8 -20
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.d.ts +3 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js +7 -7
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/useGuid.d.ts +2 -0
- package/lib/esm/tree-widget-react/components/trees/common/useGuid.js +11 -0
- package/lib/esm/tree-widget-react/components/trees/common/useGuid.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +4 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.d.ts +4 -6
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +31 -26
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +4 -2
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +1 -5
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +44 -44
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.d.ts +3 -6
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +21 -17
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +3 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +6 -10
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +107 -64
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +18 -8
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.d.ts +24 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js +44 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +40 -9
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +70 -41
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.d.ts +13 -5
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js +22 -16
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +4 -13
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +67 -61
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +6 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +157 -179
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/package.json +8 -8
|
@@ -31,49 +31,49 @@ function createModelsTreeVisibilityHandler(props) {
|
|
|
31
31
|
return new ModelsTreeVisibilityHandlerImpl(props);
|
|
32
32
|
}
|
|
33
33
|
class ModelsTreeVisibilityHandlerImpl {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
constructor(
|
|
43
|
-
this
|
|
44
|
-
this
|
|
45
|
-
this
|
|
46
|
-
this
|
|
47
|
-
this
|
|
48
|
-
this.
|
|
34
|
+
#eventListener;
|
|
35
|
+
#alwaysAndNeverDrawnElements;
|
|
36
|
+
#idsCache;
|
|
37
|
+
#filteredTree;
|
|
38
|
+
#elementChangeQueue = new rxjs_1.Subject();
|
|
39
|
+
#subscriptions = [];
|
|
40
|
+
#changeRequest = new rxjs_1.Subject();
|
|
41
|
+
#props;
|
|
42
|
+
constructor(props) {
|
|
43
|
+
this.#props = props;
|
|
44
|
+
this.#eventListener = (0, VisibilityChangeEventListener_js_1.createVisibilityChangeEventListener)(this.#props.viewport);
|
|
45
|
+
this.#alwaysAndNeverDrawnElements = new AlwaysAndNeverDrawnElementInfo_js_1.AlwaysAndNeverDrawnElementInfo(this.#props.viewport, this.#props.componentId);
|
|
46
|
+
this.#idsCache = this.#props.idsCache;
|
|
47
|
+
this.#filteredTree = this.#props.filteredPaths ? (0, FilteredTree_js_1.createFilteredTree)(this.#props.imodelAccess, this.#props.filteredPaths) : undefined;
|
|
48
|
+
this.#subscriptions.push(this.#elementChangeQueue.pipe((0, rxjs_1.concatAll)()).subscribe());
|
|
49
49
|
}
|
|
50
50
|
get onVisibilityChange() {
|
|
51
|
-
return this.
|
|
51
|
+
return this.#eventListener.onVisibilityChange;
|
|
52
52
|
}
|
|
53
53
|
async getVisibilityStatus(node) {
|
|
54
54
|
return (0, rxjs_1.firstValueFrom)(this.getVisibilityStatusObs(node).pipe(
|
|
55
55
|
// unsubscribe from the observable if the change request for this node is received
|
|
56
|
-
(0, rxjs_1.takeUntil)(this.
|
|
56
|
+
(0, rxjs_1.takeUntil)(this.#changeRequest.pipe((0, rxjs_1.filter)(({ key, depth }) => depth === node.parentKeys.length && presentation_hierarchies_1.HierarchyNodeKey.equals(node.key, key)))),
|
|
57
57
|
// unsubscribe if visibility changes
|
|
58
58
|
(0, rxjs_1.takeUntil)((0, rxjs_1.fromEventPattern)((handler) => {
|
|
59
|
-
this.
|
|
59
|
+
this.#eventListener.onVisibilityChange.addListener(handler);
|
|
60
60
|
}, (handler) => {
|
|
61
|
-
this.
|
|
61
|
+
this.#eventListener.onVisibilityChange.removeListener(handler);
|
|
62
62
|
})), (0, rxjs_1.defaultIfEmpty)((0, Tooltip_js_1.createVisibilityStatus)("hidden"))));
|
|
63
63
|
}
|
|
64
64
|
async changeVisibility(node, shouldDisplay) {
|
|
65
65
|
// notify about new change request
|
|
66
|
-
this.
|
|
66
|
+
this.#changeRequest.next({ key: node.key, depth: node.parentKeys.length });
|
|
67
67
|
const changeObservable = this.changeVisibilityObs(node, shouldDisplay).pipe(
|
|
68
68
|
// unsubscribe from the observable if the change request for this node is received
|
|
69
|
-
(0, rxjs_1.takeUntil)(this.
|
|
69
|
+
(0, rxjs_1.takeUntil)(this.#changeRequest.pipe((0, rxjs_1.filter)(({ key, depth }) => depth === node.parentKeys.length && presentation_hierarchies_1.HierarchyNodeKey.equals(node.key, key)))), (0, rxjs_1.tap)({
|
|
70
70
|
subscribe: () => {
|
|
71
|
-
this.
|
|
72
|
-
this.
|
|
71
|
+
this.#eventListener.suppressChangeEvents();
|
|
72
|
+
this.#alwaysAndNeverDrawnElements.suppressChangeEvents();
|
|
73
73
|
},
|
|
74
74
|
finalize: () => {
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
75
|
+
this.#eventListener.resumeChangeEvents();
|
|
76
|
+
this.#alwaysAndNeverDrawnElements.resumeChangeEvents();
|
|
77
77
|
},
|
|
78
78
|
}));
|
|
79
79
|
return (0, Rxjs_js_1.toVoidPromise)(changeObservable);
|
|
@@ -82,20 +82,23 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
82
82
|
this[Symbol.dispose]();
|
|
83
83
|
}
|
|
84
84
|
[Symbol.dispose]() {
|
|
85
|
-
this
|
|
86
|
-
this
|
|
87
|
-
this.
|
|
85
|
+
this.#eventListener[Symbol.dispose]();
|
|
86
|
+
this.#alwaysAndNeverDrawnElements[Symbol.dispose]();
|
|
87
|
+
this.#subscriptions.forEach((x) => x.unsubscribe());
|
|
88
88
|
}
|
|
89
89
|
getVisibilityStatusObs(node) {
|
|
90
|
-
if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {
|
|
91
|
-
return this.getFilteredNodeVisibility({ node });
|
|
92
|
-
}
|
|
93
90
|
if (presentation_hierarchies_1.HierarchyNode.isClassGroupingNode(node)) {
|
|
91
|
+
if (node.extendedData?.hasDirectNonFilteredTargets && !node.filtering?.hasFilterTargetAncestor) {
|
|
92
|
+
return this.getFilteredNodeVisibility({ node });
|
|
93
|
+
}
|
|
94
94
|
return this.getClassGroupingNodeDisplayStatus(node);
|
|
95
95
|
}
|
|
96
96
|
if (!presentation_hierarchies_1.HierarchyNode.isInstancesNode(node)) {
|
|
97
97
|
return (0, rxjs_1.of)((0, Tooltip_js_1.createVisibilityStatus)("disabled"));
|
|
98
98
|
}
|
|
99
|
+
if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {
|
|
100
|
+
return this.getFilteredNodeVisibility({ node });
|
|
101
|
+
}
|
|
99
102
|
if (ModelsTreeNode_js_1.ModelsTreeNode.isSubjectNode(node)) {
|
|
100
103
|
// note: subject nodes may be merged to represent multiple subject instances
|
|
101
104
|
return this.getSubjectNodeVisibilityStatus({ subjectIds: node.key.instanceKeys.map((key) => key.id) });
|
|
@@ -118,13 +121,14 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
118
121
|
return (0, rxjs_1.of)((0, Tooltip_js_1.createVisibilityStatus)("disabled"));
|
|
119
122
|
}
|
|
120
123
|
return this.getElementDisplayStatus({
|
|
121
|
-
|
|
124
|
+
elementIds: node.key.instanceKeys.map(({ id }) => id),
|
|
122
125
|
modelId,
|
|
123
126
|
categoryId,
|
|
124
127
|
});
|
|
125
128
|
}
|
|
126
129
|
getFilteredNodeVisibility(props) {
|
|
127
|
-
|
|
130
|
+
(0, core_bentley_1.assert)(this.#filteredTree !== undefined);
|
|
131
|
+
return (0, rxjs_1.from)(this.#filteredTree).pipe((0, rxjs_1.map)((filteredTree) => filteredTree.getVisibilityChangeTargets(props.node)), (0, rxjs_1.mergeMap)(({ subjects, models, categories, elements }) => {
|
|
128
132
|
const observables = new Array();
|
|
129
133
|
if (subjects?.size) {
|
|
130
134
|
observables.push(this.getSubjectNodeVisibilityStatus({ subjectIds: [...subjects], ignoreTooltip: true }));
|
|
@@ -139,9 +143,13 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
139
143
|
})));
|
|
140
144
|
}
|
|
141
145
|
if (elements?.size) {
|
|
142
|
-
observables.push((0, rxjs_1.from)(elements).pipe((0, Utils_js_1.releaseMainThreadOnItemsCount)(50), (0, rxjs_1.mergeMap)(([categoryKey,
|
|
146
|
+
observables.push((0, rxjs_1.from)(elements).pipe((0, Utils_js_1.releaseMainThreadOnItemsCount)(50), (0, rxjs_1.mergeMap)(([categoryKey, elementsMap]) => {
|
|
143
147
|
const { modelId, categoryId } = (0, FilteredTree_js_1.parseCategoryKey)(categoryKey);
|
|
144
|
-
return
|
|
148
|
+
return this.getElementsDisplayStatus({
|
|
149
|
+
elementIds: [...elementsMap.keys()],
|
|
150
|
+
modelId,
|
|
151
|
+
categoryId,
|
|
152
|
+
});
|
|
145
153
|
})));
|
|
146
154
|
}
|
|
147
155
|
return (0, rxjs_1.merge)(...observables);
|
|
@@ -149,49 +157,49 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
149
157
|
}
|
|
150
158
|
getSubjectNodeVisibilityStatus({ subjectIds, ignoreTooltip }) {
|
|
151
159
|
const result = (0, rxjs_1.defer)(() => {
|
|
152
|
-
if (!this.
|
|
160
|
+
if (!this.#props.viewport.view.isSpatialView()) {
|
|
153
161
|
return (0, rxjs_1.of)((0, Tooltip_js_1.createVisibilityStatus)("disabled", getTooltipOptions("modelsTree.subject.nonSpatialView", ignoreTooltip)));
|
|
154
162
|
}
|
|
155
|
-
return (0, rxjs_1.from)(this.
|
|
163
|
+
return (0, rxjs_1.from)(this.#idsCache.getSubjectModelIds(subjectIds)).pipe((0, rxjs_1.mergeMap)((modelIds) => this.getModelVisibilityStatus({ modelIds, ignoreTooltip: true })), mergeVisibilityStatuses({
|
|
156
164
|
visible: "modelsTree.subject.allModelsVisible",
|
|
157
165
|
hidden: "modelsTree.subject.allModelsHidden",
|
|
158
166
|
partial: "modelsTree.subject.someModelsHidden",
|
|
159
167
|
}, ignoreTooltip));
|
|
160
168
|
});
|
|
161
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, { ids: subjectIds }, result, this.
|
|
169
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, { ids: subjectIds }, result, this.#props.overrides?.getSubjectNodeVisibility);
|
|
162
170
|
}
|
|
163
171
|
getModelVisibilityStatus({ modelIds, ignoreTooltip }) {
|
|
164
172
|
const result = (0, rxjs_1.defer)(() => {
|
|
165
|
-
const viewport = this.
|
|
173
|
+
const viewport = this.#props.viewport;
|
|
166
174
|
if (!viewport.view.isSpatialView()) {
|
|
167
175
|
return (0, rxjs_1.of)((0, Tooltip_js_1.createVisibilityStatus)("disabled", getTooltipOptions("modelsTree.model.nonSpatialView", ignoreTooltip)));
|
|
168
176
|
}
|
|
169
|
-
return (0, rxjs_1.from)(modelIds).pipe((0, rxjs_1.distinct)(), (0, rxjs_1.mergeMap)((modelId) => {
|
|
177
|
+
return (0, rxjs_1.from)(core_bentley_1.Id64.iterable(modelIds)).pipe((0, rxjs_1.distinct)(), (0, rxjs_1.mergeMap)((modelId) => {
|
|
170
178
|
if (!viewport.view.viewsModel(modelId)) {
|
|
171
|
-
return (0, rxjs_1.from)(this.
|
|
179
|
+
return (0, rxjs_1.from)(this.#idsCache.getModelCategories(modelId)).pipe((0, rxjs_1.mergeMap)((categoryIds) => (0, rxjs_1.from)(this.#idsCache.getCategoriesModeledElements(modelId, categoryIds))), this.getSubModeledElementsVisibilityStatus({
|
|
172
180
|
ignoreTooltips: ignoreTooltip,
|
|
173
181
|
haveSubModel: "yes",
|
|
174
182
|
tooltips: { visible: undefined, hidden: "modelsTree.model.hiddenThroughModelSelector", partial: "modelsTree.model.someSubModelsVisible" },
|
|
175
183
|
parentNodeVisibilityStatus: (0, Tooltip_js_1.createVisibilityStatus)("hidden"),
|
|
176
184
|
}));
|
|
177
185
|
}
|
|
178
|
-
return (0, rxjs_1.from)(this.
|
|
186
|
+
return (0, rxjs_1.from)(this.#idsCache.getModelCategories(modelId)).pipe((0, rxjs_1.mergeMap)((categoryIds) => categoryIds.length === 0 ? (0, rxjs_1.of)((0, Tooltip_js_1.createVisibilityStatus)("visible")) : this.getCategoryDisplayStatus({ modelId, categoryIds, ignoreTooltip: true })), mergeVisibilityStatuses({
|
|
179
187
|
visible: "modelsTree.model.allCategoriesVisible",
|
|
180
188
|
partial: "modelsTree.model.someCategoriesHidden",
|
|
181
189
|
hidden: "modelsTree.model.allCategoriesHidden",
|
|
182
190
|
}));
|
|
183
191
|
}), mergeVisibilityStatuses());
|
|
184
192
|
});
|
|
185
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, { ids: modelIds }, result, this.
|
|
193
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, { ids: modelIds }, result, this.#props.overrides?.getModelDisplayStatus);
|
|
186
194
|
}
|
|
187
195
|
getDefaultCategoryVisibilityStatus({ modelId, categoryIds, ignoreTooltip, }) {
|
|
188
|
-
const viewport = this.
|
|
196
|
+
const viewport = this.#props.viewport;
|
|
189
197
|
if (!viewport.view.viewsModel(modelId) || core_bentley_1.Id64.sizeOf(categoryIds) === 0) {
|
|
190
198
|
return (0, Tooltip_js_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.category.hiddenThroughModel", ignoreTooltip));
|
|
191
199
|
}
|
|
192
200
|
let visibility = "unknown";
|
|
193
201
|
for (const categoryId of core_bentley_1.Id64.iterable(categoryIds)) {
|
|
194
|
-
const override = this.
|
|
202
|
+
const override = this.#props.viewport.perModelCategoryVisibility.getOverride(modelId, categoryId);
|
|
195
203
|
if (override === core_frontend_1.PerModelCategoryVisibility.Override.Show) {
|
|
196
204
|
if (visibility === "hidden") {
|
|
197
205
|
return (0, Tooltip_js_1.createVisibilityStatus)("partial");
|
|
@@ -220,8 +228,8 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
220
228
|
}
|
|
221
229
|
getCategoryDisplayStatus({ ignoreTooltip, ...props }) {
|
|
222
230
|
const result = (0, rxjs_1.defer)(() => {
|
|
223
|
-
if (!this.
|
|
224
|
-
return (0, rxjs_1.from)(this.
|
|
231
|
+
if (!this.#props.viewport.view.viewsModel(props.modelId)) {
|
|
232
|
+
return (0, rxjs_1.from)(this.#idsCache.getCategoriesModeledElements(props.modelId, props.categoryIds)).pipe(this.getSubModeledElementsVisibilityStatus({
|
|
225
233
|
ignoreTooltips: ignoreTooltip,
|
|
226
234
|
parentNodeVisibilityStatus: (0, Tooltip_js_1.createVisibilityStatus)("hidden"),
|
|
227
235
|
tooltips: {
|
|
@@ -245,7 +253,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
245
253
|
: this.getDefaultCategoryVisibilityStatus({ modelId: props.modelId, categoryIds: props.categoryIds }),
|
|
246
254
|
ignoreTooltip,
|
|
247
255
|
}).pipe((0, rxjs_1.mergeMap)((visibilityStatusAlwaysAndNeverDraw) => {
|
|
248
|
-
return (0, rxjs_1.from)(this.
|
|
256
|
+
return (0, rxjs_1.from)(this.#idsCache.getCategoriesModeledElements(props.modelId, props.categoryIds)).pipe(this.getSubModeledElementsVisibilityStatus({
|
|
249
257
|
tooltips: {
|
|
250
258
|
visible: undefined,
|
|
251
259
|
hidden: "modelsTree.category.allElementsAndSubModelsHidden",
|
|
@@ -257,14 +265,30 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
257
265
|
}));
|
|
258
266
|
}));
|
|
259
267
|
});
|
|
260
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.
|
|
268
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.#props.overrides?.getCategoryDisplayStatus);
|
|
261
269
|
}
|
|
262
270
|
getClassGroupingNodeDisplayStatus(node) {
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
271
|
+
const { elementIds, modelId, categoryId } = this.getGroupingNodeInfo(node);
|
|
272
|
+
const result = this.getElementsDisplayStatus({
|
|
273
|
+
elementIds,
|
|
274
|
+
modelId,
|
|
275
|
+
categoryId,
|
|
276
|
+
});
|
|
277
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, { node }, result, this.#props.overrides?.getElementGroupingNodeDisplayStatus);
|
|
278
|
+
}
|
|
279
|
+
getElementDisplayStatus({ elementIds, modelId, categoryId, }) {
|
|
280
|
+
const result = this.getElementsDisplayStatus({
|
|
281
|
+
elementIds,
|
|
282
|
+
modelId,
|
|
283
|
+
categoryId,
|
|
284
|
+
});
|
|
285
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, { elementId: elementIds[0], modelId, categoryId }, result, this.#props.overrides?.getElementDisplayStatus);
|
|
286
|
+
}
|
|
287
|
+
getElementsDisplayStatus(props) {
|
|
288
|
+
return (0, rxjs_1.defer)(() => {
|
|
289
|
+
const { modelId, categoryId, elementIds } = props;
|
|
290
|
+
if (!this.#props.viewport.view.viewsModel(modelId)) {
|
|
291
|
+
return (0, rxjs_1.of)(elementIds).pipe(this.getSubModeledElementsVisibilityStatus({
|
|
268
292
|
tooltips: {
|
|
269
293
|
visible: undefined,
|
|
270
294
|
hidden: undefined,
|
|
@@ -287,7 +311,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
287
311
|
noElementsInExclusiveAlwaysDrawnList: "modelsTree.groupingNode.allElementsHidden",
|
|
288
312
|
},
|
|
289
313
|
}).pipe((0, rxjs_1.mergeMap)((visibilityStatusAlwaysAndNeverDraw) => {
|
|
290
|
-
return (0, rxjs_1.of)(
|
|
314
|
+
return (0, rxjs_1.of)(elementIds).pipe(this.getSubModeledElementsVisibilityStatus({
|
|
291
315
|
tooltips: {
|
|
292
316
|
visible: undefined,
|
|
293
317
|
hidden: "modelsTree.groupingNode.allElementsAndSubModelsHidden",
|
|
@@ -298,80 +322,22 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
298
322
|
}));
|
|
299
323
|
}));
|
|
300
324
|
});
|
|
301
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, { node }, result, this._props.overrides?.getElementGroupingNodeDisplayStatus);
|
|
302
|
-
}
|
|
303
|
-
getElementOverriddenVisibility(elementId, ignoreTooltip) {
|
|
304
|
-
const viewport = this._props.viewport;
|
|
305
|
-
if (viewport.neverDrawn?.has(elementId)) {
|
|
306
|
-
return (0, Tooltip_js_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.element.hiddenThroughNeverDrawnList", ignoreTooltip));
|
|
307
|
-
}
|
|
308
|
-
if (viewport.alwaysDrawn?.size) {
|
|
309
|
-
if (viewport.alwaysDrawn.has(elementId)) {
|
|
310
|
-
return (0, Tooltip_js_1.createVisibilityStatus)("visible", getTooltipOptions("modelsTree.element.displayedThroughAlwaysDrawnList", ignoreTooltip));
|
|
311
|
-
}
|
|
312
|
-
if (viewport.isAlwaysDrawnExclusive) {
|
|
313
|
-
return (0, Tooltip_js_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.element.hiddenDueToOtherElementsExclusivelyAlwaysDrawn", ignoreTooltip));
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
return undefined;
|
|
317
|
-
}
|
|
318
|
-
getElementVisibility(ignoreTooltip, viewsModel, overriddenVisibility, categoryVisibility, subModelVisibilityStatus) {
|
|
319
|
-
if (subModelVisibilityStatus === undefined) {
|
|
320
|
-
if (!viewsModel) {
|
|
321
|
-
return (0, Tooltip_js_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.element.hiddenThroughModel", ignoreTooltip));
|
|
322
|
-
}
|
|
323
|
-
if (overriddenVisibility) {
|
|
324
|
-
return overriddenVisibility;
|
|
325
|
-
}
|
|
326
|
-
return (0, Tooltip_js_1.createVisibilityStatus)(categoryVisibility.state, getTooltipOptions(categoryVisibility.state === "visible" ? undefined : "modelsTree.element.hiddenThroughCategory", ignoreTooltip));
|
|
327
|
-
}
|
|
328
|
-
if (subModelVisibilityStatus.state === "partial") {
|
|
329
|
-
return (0, Tooltip_js_1.createVisibilityStatus)("partial", getTooltipOptions("modelsTree.element.someElementsAreHidden", ignoreTooltip));
|
|
330
|
-
}
|
|
331
|
-
if (subModelVisibilityStatus.state === "visible") {
|
|
332
|
-
if (!viewsModel || overriddenVisibility?.state === "hidden" || (categoryVisibility.state === "hidden" && !overriddenVisibility)) {
|
|
333
|
-
return (0, Tooltip_js_1.createVisibilityStatus)("partial", getTooltipOptions("modelsTree.element.partialThroughSubModel", ignoreTooltip));
|
|
334
|
-
}
|
|
335
|
-
return (0, Tooltip_js_1.createVisibilityStatus)("visible", getTooltipOptions(undefined, ignoreTooltip));
|
|
336
|
-
}
|
|
337
|
-
if (!viewsModel) {
|
|
338
|
-
return (0, Tooltip_js_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.element.hiddenThroughModel", ignoreTooltip));
|
|
339
|
-
}
|
|
340
|
-
if (overriddenVisibility) {
|
|
341
|
-
if (overriddenVisibility.state === "hidden") {
|
|
342
|
-
return overriddenVisibility;
|
|
343
|
-
}
|
|
344
|
-
return (0, Tooltip_js_1.createVisibilityStatus)("partial", getTooltipOptions("modelsTree.element.partialThroughElement", ignoreTooltip));
|
|
345
|
-
}
|
|
346
|
-
if (categoryVisibility.state === "visible") {
|
|
347
|
-
return (0, Tooltip_js_1.createVisibilityStatus)("partial", getTooltipOptions("modelsTree.element.partialThroughCategory", ignoreTooltip));
|
|
348
|
-
}
|
|
349
|
-
return (0, Tooltip_js_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.element.hiddenThroughCategory", ignoreTooltip));
|
|
350
|
-
}
|
|
351
|
-
getElementDisplayStatus({ ignoreTooltip, ...props }) {
|
|
352
|
-
const result = (0, rxjs_1.defer)(() => {
|
|
353
|
-
const viewport = this._props.viewport;
|
|
354
|
-
const { elementId, modelId, categoryId } = props;
|
|
355
|
-
const viewsModel = viewport.view.viewsModel(modelId);
|
|
356
|
-
const elementStatus = this.getElementOverriddenVisibility(elementId, ignoreTooltip);
|
|
357
|
-
return (0, rxjs_1.from)(this._idsCache.hasSubModel(elementId)).pipe((0, rxjs_1.mergeMap)((hasSubModel) => (hasSubModel ? this.getModelVisibilityStatus({ modelIds: [elementId] }) : (0, rxjs_1.of)(undefined))), (0, rxjs_1.map)((subModelVisibilityStatus) => this.getElementVisibility(ignoreTooltip, viewsModel, elementStatus,
|
|
358
|
-
// Single category will always return "visible" or "hidden"
|
|
359
|
-
this.getDefaultCategoryVisibilityStatus({ categoryIds: categoryId, modelId, ignoreTooltip: true }), subModelVisibilityStatus)));
|
|
360
|
-
});
|
|
361
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this._props.overrides?.getElementDisplayStatus);
|
|
362
325
|
}
|
|
363
326
|
/** Changes visibility of the items represented by the tree node. */
|
|
364
327
|
changeVisibilityObs(node, on) {
|
|
365
328
|
const changeObs = (0, rxjs_1.defer)(() => {
|
|
366
|
-
if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {
|
|
367
|
-
return this.changeFilteredNodeVisibility({ node, on });
|
|
368
|
-
}
|
|
369
329
|
if (presentation_hierarchies_1.HierarchyNode.isClassGroupingNode(node)) {
|
|
330
|
+
if (node.extendedData?.hasDirectNonFilteredTargets && !node.filtering?.hasFilterTargetAncestor) {
|
|
331
|
+
return this.changeFilteredNodeVisibility({ node, on });
|
|
332
|
+
}
|
|
370
333
|
return this.changeElementGroupingNodeState(node, on);
|
|
371
334
|
}
|
|
372
335
|
if (!presentation_hierarchies_1.HierarchyNode.isInstancesNode(node)) {
|
|
373
336
|
return rxjs_1.EMPTY;
|
|
374
337
|
}
|
|
338
|
+
if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {
|
|
339
|
+
return this.changeFilteredNodeVisibility({ node, on });
|
|
340
|
+
}
|
|
375
341
|
if (ModelsTreeNode_js_1.ModelsTreeNode.isSubjectNode(node)) {
|
|
376
342
|
return this.changeSubjectNodeState(node.key.instanceKeys.map((key) => key.id), on);
|
|
377
343
|
}
|
|
@@ -400,17 +366,14 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
400
366
|
on,
|
|
401
367
|
});
|
|
402
368
|
});
|
|
403
|
-
if (this.
|
|
369
|
+
if (this.#props.viewport.isAlwaysDrawnExclusive) {
|
|
404
370
|
return (0, rxjs_1.concat)(this.removeAlwaysDrawnExclusive(), changeObs);
|
|
405
371
|
}
|
|
406
372
|
return changeObs;
|
|
407
373
|
}
|
|
408
|
-
async getVisibilityChangeTargets({ node }) {
|
|
409
|
-
const filteredTree = await this._filteredTree;
|
|
410
|
-
return filteredTree ? filteredTree.getVisibilityChangeTargets(node) : {};
|
|
411
|
-
}
|
|
412
374
|
changeFilteredNodeVisibility({ on, ...props }) {
|
|
413
|
-
|
|
375
|
+
(0, core_bentley_1.assert)(this.#filteredTree !== undefined);
|
|
376
|
+
return (0, rxjs_1.from)(this.#filteredTree).pipe((0, rxjs_1.map)((filteredTree) => filteredTree.getVisibilityChangeTargets(props.node)), (0, rxjs_1.mergeMap)(({ subjects, models, categories, elements }) => {
|
|
414
377
|
const observables = new Array();
|
|
415
378
|
if (subjects?.size) {
|
|
416
379
|
observables.push(this.changeSubjectNodeState([...subjects], on));
|
|
@@ -425,30 +388,30 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
425
388
|
})));
|
|
426
389
|
}
|
|
427
390
|
if (elements?.size) {
|
|
428
|
-
observables.push((0, rxjs_1.from)(elements).pipe((0, rxjs_1.mergeMap)(([categoryKey,
|
|
391
|
+
observables.push((0, rxjs_1.from)(elements).pipe((0, rxjs_1.mergeMap)(([categoryKey, elementsMap]) => {
|
|
429
392
|
const { modelId, categoryId } = (0, FilteredTree_js_1.parseCategoryKey)(categoryKey);
|
|
430
|
-
return this.changeElementsState({ modelId, categoryId, elementIds, on });
|
|
393
|
+
return this.changeElementsState({ modelId, categoryId, elementIds: new Set([...elementsMap.keys()]), on });
|
|
431
394
|
})));
|
|
432
395
|
}
|
|
433
396
|
return (0, rxjs_1.merge)(...observables);
|
|
434
397
|
}));
|
|
435
398
|
}
|
|
436
399
|
removeAlwaysDrawnExclusive() {
|
|
437
|
-
return (0, rxjs_1.from)(this.
|
|
438
|
-
this.
|
|
439
|
-
this.
|
|
440
|
-
this.
|
|
441
|
-
this.
|
|
400
|
+
return (0, rxjs_1.from)(this.#idsCache.getAllCategories()).pipe((0, rxjs_1.map)((categoryIds) => {
|
|
401
|
+
this.#props.viewport.changeCategoryDisplay(categoryIds, false, false);
|
|
402
|
+
this.#props.viewport.clearNeverDrawn();
|
|
403
|
+
this.#props.viewport.perModelCategoryVisibility.clearOverrides();
|
|
404
|
+
this.#props.viewport.setAlwaysDrawn(this.#props.viewport.alwaysDrawn ?? new Set());
|
|
442
405
|
}));
|
|
443
406
|
}
|
|
444
407
|
changeSubjectNodeState(ids, on) {
|
|
445
408
|
const result = (0, rxjs_1.defer)(() => {
|
|
446
|
-
if (!this.
|
|
409
|
+
if (!this.#props.viewport.view.isSpatialView()) {
|
|
447
410
|
return rxjs_1.EMPTY;
|
|
448
411
|
}
|
|
449
|
-
return (0, rxjs_1.from)(this.
|
|
412
|
+
return (0, rxjs_1.from)(this.#idsCache.getSubjectModelIds(ids)).pipe((0, rxjs_1.mergeMap)((modelIds) => this.changeModelState({ ids: modelIds, on })));
|
|
450
413
|
});
|
|
451
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, { ids, on }, result, this.
|
|
414
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, { ids, on }, result, this.#props.overrides?.changeSubjectNodeState);
|
|
452
415
|
}
|
|
453
416
|
changeModelState(props) {
|
|
454
417
|
const { ids, on } = props;
|
|
@@ -456,31 +419,31 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
456
419
|
return rxjs_1.EMPTY;
|
|
457
420
|
}
|
|
458
421
|
const result = (0, rxjs_1.defer)(() => {
|
|
459
|
-
const viewport = this.
|
|
422
|
+
const viewport = this.#props.viewport;
|
|
460
423
|
if (!viewport.view.isSpatialView()) {
|
|
461
424
|
return rxjs_1.EMPTY;
|
|
462
425
|
}
|
|
463
426
|
const idsObs = (0, rxjs_1.from)(core_bentley_1.Id64.iterable(ids));
|
|
464
427
|
if (!on) {
|
|
465
428
|
viewport.changeModelDisplay(ids, false);
|
|
466
|
-
return idsObs.pipe((0, rxjs_1.mergeMap)(async (modelId) => ({ modelId, categoryIds: await this.
|
|
429
|
+
return idsObs.pipe((0, rxjs_1.mergeMap)(async (modelId) => ({ modelId, categoryIds: await this.#idsCache.getModelCategories(modelId) })), (0, rxjs_1.mergeMap)(({ modelId, categoryIds }) => (0, rxjs_1.from)(this.#idsCache.getCategoriesModeledElements(modelId, categoryIds))), (0, rxjs_1.mergeMap)((modeledElementIds) => this.changeModelState({ ids: modeledElementIds, on })));
|
|
467
430
|
}
|
|
468
431
|
return (0, rxjs_1.concat)((0, rxjs_1.defer)(() => {
|
|
469
432
|
viewport.perModelCategoryVisibility.clearOverrides(ids);
|
|
470
433
|
return (0, rxjs_1.from)(viewport.addViewedModels(ids));
|
|
471
434
|
}), idsObs.pipe((0, rxjs_1.mergeMap)((modelId) => {
|
|
472
|
-
return (0, rxjs_1.from)(this.
|
|
435
|
+
return (0, rxjs_1.from)(this.#idsCache.getModelCategories(modelId)).pipe((0, rxjs_1.mergeMap)((categoryIds) => this.changeCategoryState({ categoryIds, modelId, on: true })));
|
|
473
436
|
})));
|
|
474
437
|
});
|
|
475
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.
|
|
438
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.#props.overrides?.changeModelState);
|
|
476
439
|
}
|
|
477
440
|
showModelWithoutAnyCategoriesOrElements(modelId) {
|
|
478
|
-
const viewport = this.
|
|
441
|
+
const viewport = this.#props.viewport;
|
|
479
442
|
return (0, rxjs_1.forkJoin)({
|
|
480
|
-
categories: this.
|
|
481
|
-
alwaysDrawnElements: this.
|
|
443
|
+
categories: this.#idsCache.getModelCategories(modelId),
|
|
444
|
+
alwaysDrawnElements: this.getAlwaysOrNeverDrawnElements({ modelIds: modelId, setType: "always" }),
|
|
482
445
|
}).pipe((0, rxjs_1.mergeMap)(async ({ categories, alwaysDrawnElements }) => {
|
|
483
|
-
const alwaysDrawn = this.
|
|
446
|
+
const alwaysDrawn = this.#props.viewport.alwaysDrawn;
|
|
484
447
|
if (alwaysDrawn && alwaysDrawnElements) {
|
|
485
448
|
viewport.setAlwaysDrawn(setDifference(alwaysDrawn, alwaysDrawnElements));
|
|
486
449
|
}
|
|
@@ -491,7 +454,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
491
454
|
}));
|
|
492
455
|
}
|
|
493
456
|
changeCategoryStateInViewportAccordingToModelVisibility(modelId, categoryId, on) {
|
|
494
|
-
const viewport = this.
|
|
457
|
+
const viewport = this.#props.viewport;
|
|
495
458
|
const isDisplayedInSelector = viewport.view.viewsCategory(categoryId);
|
|
496
459
|
const override = on === isDisplayedInSelector
|
|
497
460
|
? core_frontend_1.PerModelCategoryVisibility.Override.None
|
|
@@ -507,26 +470,26 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
507
470
|
}
|
|
508
471
|
changeCategoryState(props) {
|
|
509
472
|
const result = (0, rxjs_1.defer)(() => {
|
|
510
|
-
const viewport = this.
|
|
473
|
+
const viewport = this.#props.viewport;
|
|
511
474
|
const { modelId, categoryIds, on } = props;
|
|
512
475
|
return (0, rxjs_1.concat)(props.on && !viewport.view.viewsModel(modelId) ? this.showModelWithoutAnyCategoriesOrElements(modelId) : rxjs_1.EMPTY, (0, rxjs_1.defer)(() => {
|
|
513
476
|
for (const categoryId of core_bentley_1.Id64.iterable(categoryIds)) {
|
|
514
477
|
this.changeCategoryStateInViewportAccordingToModelVisibility(modelId, categoryId, on);
|
|
515
478
|
}
|
|
516
479
|
return this.clearAlwaysAndNeverDrawnElements(props);
|
|
517
|
-
}), (0, rxjs_1.from)(this.
|
|
480
|
+
}), (0, rxjs_1.from)(this.#idsCache.getCategoriesModeledElements(modelId, categoryIds)).pipe((0, rxjs_1.mergeMap)((modeledElementIds) => this.changeModelState({ ids: modeledElementIds, on }))));
|
|
518
481
|
});
|
|
519
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.
|
|
482
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.#props.overrides?.changeCategoryState);
|
|
520
483
|
}
|
|
521
484
|
doChangeElementsState(props) {
|
|
522
485
|
return (0, rxjs_1.defer)(() => {
|
|
523
486
|
const { modelId, categoryId, elementIds, on } = props;
|
|
524
|
-
const viewport = this.
|
|
487
|
+
const viewport = this.#props.viewport;
|
|
525
488
|
return (0, rxjs_1.concat)(on && !viewport.view.viewsModel(modelId) ? this.showModelWithoutAnyCategoriesOrElements(modelId) : rxjs_1.EMPTY, (0, rxjs_1.defer)(() => {
|
|
526
489
|
const categoryVisibility = this.getDefaultCategoryVisibilityStatus({ categoryIds: categoryId, modelId, ignoreTooltip: true });
|
|
527
490
|
const isDisplayedByDefault = categoryVisibility.state === "visible";
|
|
528
491
|
return this.queueElementsVisibilityChange(elementIds, on, isDisplayedByDefault);
|
|
529
|
-
}), (0, rxjs_1.from)(elementIds).pipe((0, rxjs_1.mergeMap)(async (elementId) => ({ elementId, isSubModel: await this.
|
|
492
|
+
}), (0, rxjs_1.from)(elementIds).pipe((0, rxjs_1.mergeMap)(async (elementId) => ({ elementId, isSubModel: await this.#idsCache.hasSubModel(elementId) })), (0, rxjs_1.filter)(({ isSubModel }) => isSubModel), (0, rxjs_1.map)(({ elementId }) => elementId), (0, rxjs_1.toArray)(), (0, rxjs_1.mergeMap)((subModelIds) => this.changeModelState({ ids: subModelIds, on }))));
|
|
530
493
|
});
|
|
531
494
|
}
|
|
532
495
|
/**
|
|
@@ -535,7 +498,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
535
498
|
*/
|
|
536
499
|
changeElementGroupingNodeState(node, on) {
|
|
537
500
|
const result = this.doChangeElementsState({ ...this.getGroupingNodeInfo(node), on });
|
|
538
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, { node, on }, result, this.
|
|
501
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, { node, on }, result, this.#props.overrides?.changeElementGroupingNodeState);
|
|
539
502
|
}
|
|
540
503
|
/**
|
|
541
504
|
* Updates visibility of an element and all its child elements by adding them to the always/never drawn list.
|
|
@@ -543,7 +506,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
543
506
|
*/
|
|
544
507
|
changeElementsState(props) {
|
|
545
508
|
const result = this.doChangeElementsState(props);
|
|
546
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.
|
|
509
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.#props.overrides?.changeElementsState);
|
|
547
510
|
}
|
|
548
511
|
queueElementsVisibilityChange(elementIds, on, visibleByDefault) {
|
|
549
512
|
const finishedSubject = new rxjs_1.Subject();
|
|
@@ -558,7 +521,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
558
521
|
},
|
|
559
522
|
}));
|
|
560
523
|
// queue visibility change. `changeObservable` will be subscribed to when other queue changes are finished
|
|
561
|
-
this.
|
|
524
|
+
this.#elementChangeQueue.next(changeObservable);
|
|
562
525
|
// return observable that will emit when visibility change is finished
|
|
563
526
|
return changeFinished.pipe((0, rxjs_1.take)(1), (0, rxjs_1.tap)({
|
|
564
527
|
unsubscribe: () => {
|
|
@@ -570,11 +533,11 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
570
533
|
changeElementStateNoChildrenOperator(props) {
|
|
571
534
|
return (elementIds) => {
|
|
572
535
|
const { on, isDisplayedByDefault } = props;
|
|
573
|
-
const isAlwaysDrawnExclusive = this.
|
|
536
|
+
const isAlwaysDrawnExclusive = this.#props.viewport.isAlwaysDrawnExclusive;
|
|
574
537
|
return elementIds.pipe((0, Utils_js_1.releaseMainThreadOnItemsCount)(500), (0, rxjs_1.reduce)((acc, elementId) => {
|
|
575
538
|
if (acc.alwaysDrawn === undefined || acc.neverDrawn === undefined) {
|
|
576
|
-
acc.alwaysDrawn = new Set(this.
|
|
577
|
-
acc.neverDrawn = new Set(this.
|
|
539
|
+
acc.alwaysDrawn = new Set(this.#props.viewport.alwaysDrawn || []);
|
|
540
|
+
acc.neverDrawn = new Set(this.#props.viewport.neverDrawn || []);
|
|
578
541
|
}
|
|
579
542
|
if (on) {
|
|
580
543
|
const wasRemoved = acc.neverDrawn.delete(elementId);
|
|
@@ -601,8 +564,8 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
601
564
|
neverDrawn: undefined,
|
|
602
565
|
alwaysDrawn: undefined,
|
|
603
566
|
}), (0, rxjs_1.map)((state) => {
|
|
604
|
-
state.changedNeverDrawn && state.neverDrawn && this.
|
|
605
|
-
state.changedAlwaysDrawn && state.alwaysDrawn && this.
|
|
567
|
+
state.changedNeverDrawn && state.neverDrawn && this.#props.viewport.setNeverDrawn(state.neverDrawn);
|
|
568
|
+
state.changedAlwaysDrawn && state.alwaysDrawn && this.#props.viewport.setAlwaysDrawn(state.alwaysDrawn, this.#props.viewport.isAlwaysDrawnExclusive);
|
|
606
569
|
}));
|
|
607
570
|
};
|
|
608
571
|
}
|
|
@@ -617,7 +580,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
617
580
|
if (alwaysDrawn?.size === totalCount) {
|
|
618
581
|
return (0, Tooltip_js_1.createVisibilityStatus)("visible", getTooltipOptions(props.tooltips.allElementsInAlwaysDrawnList, ignoreTooltip));
|
|
619
582
|
}
|
|
620
|
-
const viewport = this.
|
|
583
|
+
const viewport = this.#props.viewport;
|
|
621
584
|
if (viewport.isAlwaysDrawnExclusive && viewport.alwaysDrawn?.size) {
|
|
622
585
|
return alwaysDrawn?.size
|
|
623
586
|
? (0, Tooltip_js_1.createVisibilityStatus)("partial", getTooltipOptions(props.tooltips.elementsInBothAlwaysAndNeverDrawn, ignoreTooltip))
|
|
@@ -630,7 +593,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
630
593
|
return status;
|
|
631
594
|
}
|
|
632
595
|
getVisibilityFromAlwaysAndNeverDrawnElements({ ignoreTooltip, ...props }) {
|
|
633
|
-
const viewport = this.
|
|
596
|
+
const viewport = this.#props.viewport;
|
|
634
597
|
if (viewport.isAlwaysDrawnExclusive) {
|
|
635
598
|
if (!viewport?.alwaysDrawn?.size) {
|
|
636
599
|
return (0, rxjs_1.of)((0, Tooltip_js_1.createVisibilityStatus)("hidden", getTooltipOptions(props.tooltips.noElementsInExclusiveAlwaysDrawnList, ignoreTooltip)));
|
|
@@ -644,17 +607,17 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
644
607
|
...props,
|
|
645
608
|
alwaysDrawn: viewport.alwaysDrawn?.size ? setIntersection(props.elements, viewport.alwaysDrawn) : undefined,
|
|
646
609
|
neverDrawn: viewport.neverDrawn?.size ? setIntersection(props.elements, viewport.neverDrawn) : undefined,
|
|
647
|
-
totalCount: props.elements
|
|
610
|
+
totalCount: core_bentley_1.Id64.sizeOf(props.elements),
|
|
648
611
|
ignoreTooltip,
|
|
649
612
|
}));
|
|
650
613
|
}
|
|
651
614
|
const { modelId, categoryIds } = props.categoryProps;
|
|
652
615
|
return (0, rxjs_1.from)(core_bentley_1.Id64.iterable(categoryIds)).pipe((0, rxjs_1.mergeMap)((categoryId) => {
|
|
653
|
-
const totalCount = this.
|
|
616
|
+
const totalCount = this.#idsCache.getCategoryElementsCount(modelId, categoryId);
|
|
654
617
|
return (0, rxjs_1.forkJoin)({
|
|
655
618
|
totalCount,
|
|
656
|
-
alwaysDrawn: this.
|
|
657
|
-
neverDrawn: this.
|
|
619
|
+
alwaysDrawn: this.getAlwaysOrNeverDrawnElements({ modelIds: modelId, categoryIds: categoryId, setType: "always" }),
|
|
620
|
+
neverDrawn: this.getAlwaysOrNeverDrawnElements({ modelIds: modelId, categoryIds: categoryId, setType: "never" }),
|
|
658
621
|
}).pipe(
|
|
659
622
|
// There is a known bug:
|
|
660
623
|
// Categories that don't have root elements will make visibility result incorrect
|
|
@@ -674,18 +637,17 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
674
637
|
}));
|
|
675
638
|
}), mergeVisibilityStatuses());
|
|
676
639
|
}
|
|
677
|
-
|
|
678
|
-
return this
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
return this._alwaysAndNeverDrawnElements.getElements({ modelId: props.modelId, categoryIds: props.categoryIds, setType: "never" });
|
|
640
|
+
getAlwaysOrNeverDrawnElements(props) {
|
|
641
|
+
return this.#alwaysAndNeverDrawnElements
|
|
642
|
+
.getElementsTree(props)
|
|
643
|
+
.pipe((0, rxjs_1.map)((childrenTree) => (0, Utils_js_1.getIdsFromChildrenTree)({ tree: childrenTree, predicate: ({ treeEntry }) => treeEntry.isInAlwaysOrNeverDrawnSet })));
|
|
682
644
|
}
|
|
683
645
|
clearAlwaysAndNeverDrawnElements(props) {
|
|
684
646
|
return (0, rxjs_1.forkJoin)({
|
|
685
|
-
alwaysDrawn: this.
|
|
686
|
-
neverDrawn: this.
|
|
647
|
+
alwaysDrawn: this.getAlwaysOrNeverDrawnElements({ modelIds: props.modelId, categoryIds: props.categoryIds, setType: "always" }),
|
|
648
|
+
neverDrawn: this.getAlwaysOrNeverDrawnElements({ modelIds: props.modelId, categoryIds: props.categoryIds, setType: "never" }),
|
|
687
649
|
}).pipe((0, rxjs_1.map)(({ alwaysDrawn, neverDrawn }) => {
|
|
688
|
-
const viewport = this.
|
|
650
|
+
const viewport = this.#props.viewport;
|
|
689
651
|
if (viewport.alwaysDrawn?.size && alwaysDrawn.size) {
|
|
690
652
|
viewport.setAlwaysDrawn(setDifference(viewport.alwaysDrawn, alwaysDrawn));
|
|
691
653
|
}
|
|
@@ -709,11 +671,11 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
709
671
|
if (haveSubModel === "yes") {
|
|
710
672
|
return (0, rxjs_1.of)(modeledElementIds);
|
|
711
673
|
}
|
|
712
|
-
return (0, rxjs_1.from)(modeledElementIds).pipe((0, rxjs_1.mergeMap)(async (elementId) => ({ elementId, hasSubModel: await this.
|
|
674
|
+
return (0, rxjs_1.from)(core_bentley_1.Id64.iterable(modeledElementIds)).pipe((0, rxjs_1.mergeMap)(async (elementId) => ({ elementId, hasSubModel: await this.#idsCache.hasSubModel(elementId) })), (0, rxjs_1.filter)(({ hasSubModel }) => hasSubModel), (0, rxjs_1.map)(({ elementId }) => elementId), (0, rxjs_1.toArray)());
|
|
713
675
|
}),
|
|
714
676
|
// combine visibility status of sub-models with visibility status of parent node
|
|
715
677
|
(0, rxjs_1.mergeMap)((modeledElementIds) => {
|
|
716
|
-
if (modeledElementIds
|
|
678
|
+
if (core_bentley_1.Id64.sizeOf(modeledElementIds) === 0) {
|
|
717
679
|
return (0, rxjs_1.of)(parentNodeVisibilityStatus);
|
|
718
680
|
}
|
|
719
681
|
return this.getModelVisibilityStatus({ modelIds: modeledElementIds }).pipe((0, rxjs_1.startWith)(parentNodeVisibilityStatus), mergeVisibilityStatuses(tooltips, ignoreTooltips));
|
|
@@ -745,24 +707,40 @@ function mergeVisibilityStatuses(tooltipMap, ignoreTooltip) {
|
|
|
745
707
|
}
|
|
746
708
|
function setDifference(lhs, rhs) {
|
|
747
709
|
const result = new Set();
|
|
748
|
-
|
|
710
|
+
for (const x of lhs) {
|
|
711
|
+
if (!rhs.has(x)) {
|
|
712
|
+
result.add(x);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
749
715
|
return result;
|
|
750
716
|
}
|
|
751
717
|
function setIntersection(lhs, rhs) {
|
|
752
718
|
const result = new Set();
|
|
753
|
-
|
|
719
|
+
for (const x of lhs) {
|
|
720
|
+
if (rhs.has(x)) {
|
|
721
|
+
result.add(x);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
754
724
|
return result;
|
|
755
725
|
}
|
|
756
726
|
/**
|
|
757
727
|
* Enables display of all given models. Also enables display of all categories and clears always and
|
|
758
728
|
* never drawn lists in the viewport.
|
|
729
|
+
*
|
|
730
|
+
* @param componentId Optional unique id of the component that consumes this function.
|
|
731
|
+
* It can be any string, as long as it is not shared across different components.
|
|
759
732
|
* @public
|
|
760
733
|
*/
|
|
761
|
-
async function showAllModels(models, viewport) {
|
|
734
|
+
async function showAllModels(models, viewport, componentId) {
|
|
762
735
|
await viewport.addViewedModels(models);
|
|
763
736
|
viewport.clearNeverDrawn();
|
|
764
737
|
viewport.clearAlwaysDrawn();
|
|
765
|
-
await (0, CategoriesVisibilityUtils_js_1.
|
|
738
|
+
const categories = await (0, CategoriesVisibilityUtils_js_1.loadCategoriesFromViewport)(viewport, componentId);
|
|
739
|
+
if (categories.length === 0) {
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
const ids = categories.map((category) => category.categoryId);
|
|
743
|
+
await (0, CategoriesVisibilityUtils_js_1.enableCategoryDisplay)(viewport, ids, true);
|
|
766
744
|
}
|
|
767
745
|
/**
|
|
768
746
|
* Disables display of all given models.
|