@itwin/tree-widget-react 3.15.0 → 3.16.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/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 +5 -13
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +70 -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 +189 -197
- 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 +5 -13
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +71 -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 +192 -200
- 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.
|
|
62
|
-
}))));
|
|
61
|
+
this.#eventListener.onVisibilityChange.removeListener(handler);
|
|
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,113 +322,58 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
298
322
|
}));
|
|
299
323
|
}));
|
|
300
324
|
});
|
|
301
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, { node }, result, this._props.overrides?.getElementGroupingNodeDisplayStatus);
|
|
302
325
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return
|
|
326
|
+
/** Changes visibility of the items represented by the tree node. */
|
|
327
|
+
changeVisibilityObs(node, on) {
|
|
328
|
+
const changeObs = (0, rxjs_1.defer)(() => {
|
|
329
|
+
if (presentation_hierarchies_1.HierarchyNode.isClassGroupingNode(node)) {
|
|
330
|
+
if (node.extendedData?.hasDirectNonFilteredTargets && !node.filtering?.hasFilterTargetAncestor) {
|
|
331
|
+
return this.changeFilteredNodeVisibility({ node, on });
|
|
332
|
+
}
|
|
333
|
+
return this.changeElementGroupingNodeState(node, on);
|
|
311
334
|
}
|
|
312
|
-
if (
|
|
313
|
-
return
|
|
335
|
+
if (!presentation_hierarchies_1.HierarchyNode.isInstancesNode(node)) {
|
|
336
|
+
return rxjs_1.EMPTY;
|
|
314
337
|
}
|
|
315
|
-
|
|
316
|
-
|
|
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));
|
|
338
|
+
if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {
|
|
339
|
+
return this.changeFilteredNodeVisibility({ node, on });
|
|
322
340
|
}
|
|
323
|
-
if (
|
|
324
|
-
return
|
|
341
|
+
if (ModelsTreeNode_js_1.ModelsTreeNode.isSubjectNode(node)) {
|
|
342
|
+
return this.changeSubjectNodeState(node.key.instanceKeys.map((key) => key.id), on);
|
|
325
343
|
}
|
|
326
|
-
|
|
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));
|
|
344
|
+
if (ModelsTreeNode_js_1.ModelsTreeNode.isModelNode(node)) {
|
|
345
|
+
return this.changeModelState({ ids: node.key.instanceKeys.map(({ id }) => id), on });
|
|
334
346
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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;
|
|
347
|
+
const modelId = ModelsTreeNode_js_1.ModelsTreeNode.getModelId(node);
|
|
348
|
+
if (!modelId) {
|
|
349
|
+
return rxjs_1.EMPTY;
|
|
343
350
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
-
}
|
|
363
|
-
/** Changes visibility of the items represented by the tree node. */
|
|
364
|
-
changeVisibilityObs(node, on) {
|
|
365
|
-
if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {
|
|
366
|
-
return this.changeFilteredNodeVisibility({ node, on });
|
|
367
|
-
}
|
|
368
|
-
if (presentation_hierarchies_1.HierarchyNode.isClassGroupingNode(node)) {
|
|
369
|
-
return this.changeElementGroupingNodeState(node, on);
|
|
370
|
-
}
|
|
371
|
-
if (!presentation_hierarchies_1.HierarchyNode.isInstancesNode(node)) {
|
|
372
|
-
return rxjs_1.EMPTY;
|
|
373
|
-
}
|
|
374
|
-
if (ModelsTreeNode_js_1.ModelsTreeNode.isSubjectNode(node)) {
|
|
375
|
-
return this.changeSubjectNodeState(node.key.instanceKeys.map((key) => key.id), on);
|
|
376
|
-
}
|
|
377
|
-
if (ModelsTreeNode_js_1.ModelsTreeNode.isModelNode(node)) {
|
|
378
|
-
return this.changeModelState({ ids: node.key.instanceKeys.map(({ id }) => id), on });
|
|
379
|
-
}
|
|
380
|
-
const modelId = ModelsTreeNode_js_1.ModelsTreeNode.getModelId(node);
|
|
381
|
-
if (!modelId) {
|
|
382
|
-
return rxjs_1.EMPTY;
|
|
383
|
-
}
|
|
384
|
-
if (ModelsTreeNode_js_1.ModelsTreeNode.isCategoryNode(node)) {
|
|
385
|
-
return this.changeCategoryState({
|
|
386
|
-
categoryIds: node.key.instanceKeys.map(({ id }) => id),
|
|
351
|
+
if (ModelsTreeNode_js_1.ModelsTreeNode.isCategoryNode(node)) {
|
|
352
|
+
return this.changeCategoryState({
|
|
353
|
+
categoryIds: node.key.instanceKeys.map(({ id }) => id),
|
|
354
|
+
modelId,
|
|
355
|
+
on,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
const categoryId = ModelsTreeNode_js_1.ModelsTreeNode.getCategoryId(node);
|
|
359
|
+
if (!categoryId) {
|
|
360
|
+
return rxjs_1.EMPTY;
|
|
361
|
+
}
|
|
362
|
+
return this.changeElementsState({
|
|
363
|
+
elementIds: new Set([...node.key.instanceKeys.map(({ id }) => id)]),
|
|
387
364
|
modelId,
|
|
365
|
+
categoryId,
|
|
388
366
|
on,
|
|
389
367
|
});
|
|
390
|
-
}
|
|
391
|
-
const categoryId = ModelsTreeNode_js_1.ModelsTreeNode.getCategoryId(node);
|
|
392
|
-
if (!categoryId) {
|
|
393
|
-
return rxjs_1.EMPTY;
|
|
394
|
-
}
|
|
395
|
-
return this.changeElementsState({
|
|
396
|
-
elementIds: new Set([...node.key.instanceKeys.map(({ id }) => id)]),
|
|
397
|
-
modelId,
|
|
398
|
-
categoryId,
|
|
399
|
-
on,
|
|
400
368
|
});
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
return
|
|
369
|
+
if (this.#props.viewport.isAlwaysDrawnExclusive) {
|
|
370
|
+
return (0, rxjs_1.concat)(this.removeAlwaysDrawnExclusive(), changeObs);
|
|
371
|
+
}
|
|
372
|
+
return changeObs;
|
|
405
373
|
}
|
|
406
374
|
changeFilteredNodeVisibility({ on, ...props }) {
|
|
407
|
-
|
|
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 }) => {
|
|
408
377
|
const observables = new Array();
|
|
409
378
|
if (subjects?.size) {
|
|
410
379
|
observables.push(this.changeSubjectNodeState([...subjects], on));
|
|
@@ -419,22 +388,30 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
419
388
|
})));
|
|
420
389
|
}
|
|
421
390
|
if (elements?.size) {
|
|
422
|
-
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]) => {
|
|
423
392
|
const { modelId, categoryId } = (0, FilteredTree_js_1.parseCategoryKey)(categoryKey);
|
|
424
|
-
return this.changeElementsState({ modelId, categoryId, elementIds, on });
|
|
393
|
+
return this.changeElementsState({ modelId, categoryId, elementIds: new Set([...elementsMap.keys()]), on });
|
|
425
394
|
})));
|
|
426
395
|
}
|
|
427
396
|
return (0, rxjs_1.merge)(...observables);
|
|
428
397
|
}));
|
|
429
398
|
}
|
|
399
|
+
removeAlwaysDrawnExclusive() {
|
|
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());
|
|
405
|
+
}));
|
|
406
|
+
}
|
|
430
407
|
changeSubjectNodeState(ids, on) {
|
|
431
408
|
const result = (0, rxjs_1.defer)(() => {
|
|
432
|
-
if (!this.
|
|
409
|
+
if (!this.#props.viewport.view.isSpatialView()) {
|
|
433
410
|
return rxjs_1.EMPTY;
|
|
434
411
|
}
|
|
435
|
-
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 })));
|
|
436
413
|
});
|
|
437
|
-
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);
|
|
438
415
|
}
|
|
439
416
|
changeModelState(props) {
|
|
440
417
|
const { ids, on } = props;
|
|
@@ -442,31 +419,31 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
442
419
|
return rxjs_1.EMPTY;
|
|
443
420
|
}
|
|
444
421
|
const result = (0, rxjs_1.defer)(() => {
|
|
445
|
-
const viewport = this.
|
|
422
|
+
const viewport = this.#props.viewport;
|
|
446
423
|
if (!viewport.view.isSpatialView()) {
|
|
447
424
|
return rxjs_1.EMPTY;
|
|
448
425
|
}
|
|
449
426
|
const idsObs = (0, rxjs_1.from)(core_bentley_1.Id64.iterable(ids));
|
|
450
427
|
if (!on) {
|
|
451
428
|
viewport.changeModelDisplay(ids, false);
|
|
452
|
-
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 })));
|
|
453
430
|
}
|
|
454
431
|
return (0, rxjs_1.concat)((0, rxjs_1.defer)(() => {
|
|
455
432
|
viewport.perModelCategoryVisibility.clearOverrides(ids);
|
|
456
433
|
return (0, rxjs_1.from)(viewport.addViewedModels(ids));
|
|
457
434
|
}), idsObs.pipe((0, rxjs_1.mergeMap)((modelId) => {
|
|
458
|
-
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 })));
|
|
459
436
|
})));
|
|
460
437
|
});
|
|
461
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.
|
|
438
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.#props.overrides?.changeModelState);
|
|
462
439
|
}
|
|
463
440
|
showModelWithoutAnyCategoriesOrElements(modelId) {
|
|
464
|
-
const viewport = this.
|
|
441
|
+
const viewport = this.#props.viewport;
|
|
465
442
|
return (0, rxjs_1.forkJoin)({
|
|
466
|
-
categories: this.
|
|
467
|
-
alwaysDrawnElements: this.
|
|
443
|
+
categories: this.#idsCache.getModelCategories(modelId),
|
|
444
|
+
alwaysDrawnElements: this.getAlwaysOrNeverDrawnElements({ modelIds: modelId, setType: "always" }),
|
|
468
445
|
}).pipe((0, rxjs_1.mergeMap)(async ({ categories, alwaysDrawnElements }) => {
|
|
469
|
-
const alwaysDrawn = this.
|
|
446
|
+
const alwaysDrawn = this.#props.viewport.alwaysDrawn;
|
|
470
447
|
if (alwaysDrawn && alwaysDrawnElements) {
|
|
471
448
|
viewport.setAlwaysDrawn(setDifference(alwaysDrawn, alwaysDrawnElements));
|
|
472
449
|
}
|
|
@@ -477,7 +454,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
477
454
|
}));
|
|
478
455
|
}
|
|
479
456
|
changeCategoryStateInViewportAccordingToModelVisibility(modelId, categoryId, on) {
|
|
480
|
-
const viewport = this.
|
|
457
|
+
const viewport = this.#props.viewport;
|
|
481
458
|
const isDisplayedInSelector = viewport.view.viewsCategory(categoryId);
|
|
482
459
|
const override = on === isDisplayedInSelector
|
|
483
460
|
? core_frontend_1.PerModelCategoryVisibility.Override.None
|
|
@@ -493,26 +470,26 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
493
470
|
}
|
|
494
471
|
changeCategoryState(props) {
|
|
495
472
|
const result = (0, rxjs_1.defer)(() => {
|
|
496
|
-
const viewport = this.
|
|
473
|
+
const viewport = this.#props.viewport;
|
|
497
474
|
const { modelId, categoryIds, on } = props;
|
|
498
475
|
return (0, rxjs_1.concat)(props.on && !viewport.view.viewsModel(modelId) ? this.showModelWithoutAnyCategoriesOrElements(modelId) : rxjs_1.EMPTY, (0, rxjs_1.defer)(() => {
|
|
499
476
|
for (const categoryId of core_bentley_1.Id64.iterable(categoryIds)) {
|
|
500
477
|
this.changeCategoryStateInViewportAccordingToModelVisibility(modelId, categoryId, on);
|
|
501
478
|
}
|
|
502
479
|
return this.clearAlwaysAndNeverDrawnElements(props);
|
|
503
|
-
}), (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 }))));
|
|
504
481
|
});
|
|
505
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.
|
|
482
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.#props.overrides?.changeCategoryState);
|
|
506
483
|
}
|
|
507
484
|
doChangeElementsState(props) {
|
|
508
485
|
return (0, rxjs_1.defer)(() => {
|
|
509
486
|
const { modelId, categoryId, elementIds, on } = props;
|
|
510
|
-
const viewport = this.
|
|
487
|
+
const viewport = this.#props.viewport;
|
|
511
488
|
return (0, rxjs_1.concat)(on && !viewport.view.viewsModel(modelId) ? this.showModelWithoutAnyCategoriesOrElements(modelId) : rxjs_1.EMPTY, (0, rxjs_1.defer)(() => {
|
|
512
489
|
const categoryVisibility = this.getDefaultCategoryVisibilityStatus({ categoryIds: categoryId, modelId, ignoreTooltip: true });
|
|
513
490
|
const isDisplayedByDefault = categoryVisibility.state === "visible";
|
|
514
491
|
return this.queueElementsVisibilityChange(elementIds, on, isDisplayedByDefault);
|
|
515
|
-
}), (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 }))));
|
|
516
493
|
});
|
|
517
494
|
}
|
|
518
495
|
/**
|
|
@@ -521,7 +498,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
521
498
|
*/
|
|
522
499
|
changeElementGroupingNodeState(node, on) {
|
|
523
500
|
const result = this.doChangeElementsState({ ...this.getGroupingNodeInfo(node), on });
|
|
524
|
-
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);
|
|
525
502
|
}
|
|
526
503
|
/**
|
|
527
504
|
* Updates visibility of an element and all its child elements by adding them to the always/never drawn list.
|
|
@@ -529,7 +506,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
529
506
|
*/
|
|
530
507
|
changeElementsState(props) {
|
|
531
508
|
const result = this.doChangeElementsState(props);
|
|
532
|
-
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.
|
|
509
|
+
return (0, UseHierarchyVisibility_js_1.createVisibilityHandlerResult)(this, props, result, this.#props.overrides?.changeElementsState);
|
|
533
510
|
}
|
|
534
511
|
queueElementsVisibilityChange(elementIds, on, visibleByDefault) {
|
|
535
512
|
const finishedSubject = new rxjs_1.Subject();
|
|
@@ -544,7 +521,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
544
521
|
},
|
|
545
522
|
}));
|
|
546
523
|
// queue visibility change. `changeObservable` will be subscribed to when other queue changes are finished
|
|
547
|
-
this.
|
|
524
|
+
this.#elementChangeQueue.next(changeObservable);
|
|
548
525
|
// return observable that will emit when visibility change is finished
|
|
549
526
|
return changeFinished.pipe((0, rxjs_1.take)(1), (0, rxjs_1.tap)({
|
|
550
527
|
unsubscribe: () => {
|
|
@@ -556,11 +533,11 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
556
533
|
changeElementStateNoChildrenOperator(props) {
|
|
557
534
|
return (elementIds) => {
|
|
558
535
|
const { on, isDisplayedByDefault } = props;
|
|
559
|
-
const isAlwaysDrawnExclusive = this.
|
|
536
|
+
const isAlwaysDrawnExclusive = this.#props.viewport.isAlwaysDrawnExclusive;
|
|
560
537
|
return elementIds.pipe((0, Utils_js_1.releaseMainThreadOnItemsCount)(500), (0, rxjs_1.reduce)((acc, elementId) => {
|
|
561
538
|
if (acc.alwaysDrawn === undefined || acc.neverDrawn === undefined) {
|
|
562
|
-
acc.alwaysDrawn = new Set(this.
|
|
563
|
-
acc.neverDrawn = new Set(this.
|
|
539
|
+
acc.alwaysDrawn = new Set(this.#props.viewport.alwaysDrawn || []);
|
|
540
|
+
acc.neverDrawn = new Set(this.#props.viewport.neverDrawn || []);
|
|
564
541
|
}
|
|
565
542
|
if (on) {
|
|
566
543
|
const wasRemoved = acc.neverDrawn.delete(elementId);
|
|
@@ -587,8 +564,8 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
587
564
|
neverDrawn: undefined,
|
|
588
565
|
alwaysDrawn: undefined,
|
|
589
566
|
}), (0, rxjs_1.map)((state) => {
|
|
590
|
-
state.changedNeverDrawn && state.neverDrawn && this.
|
|
591
|
-
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);
|
|
592
569
|
}));
|
|
593
570
|
};
|
|
594
571
|
}
|
|
@@ -603,7 +580,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
603
580
|
if (alwaysDrawn?.size === totalCount) {
|
|
604
581
|
return (0, Tooltip_js_1.createVisibilityStatus)("visible", getTooltipOptions(props.tooltips.allElementsInAlwaysDrawnList, ignoreTooltip));
|
|
605
582
|
}
|
|
606
|
-
const viewport = this.
|
|
583
|
+
const viewport = this.#props.viewport;
|
|
607
584
|
if (viewport.isAlwaysDrawnExclusive && viewport.alwaysDrawn?.size) {
|
|
608
585
|
return alwaysDrawn?.size
|
|
609
586
|
? (0, Tooltip_js_1.createVisibilityStatus)("partial", getTooltipOptions(props.tooltips.elementsInBothAlwaysAndNeverDrawn, ignoreTooltip))
|
|
@@ -616,7 +593,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
616
593
|
return status;
|
|
617
594
|
}
|
|
618
595
|
getVisibilityFromAlwaysAndNeverDrawnElements({ ignoreTooltip, ...props }) {
|
|
619
|
-
const viewport = this.
|
|
596
|
+
const viewport = this.#props.viewport;
|
|
620
597
|
if (viewport.isAlwaysDrawnExclusive) {
|
|
621
598
|
if (!viewport?.alwaysDrawn?.size) {
|
|
622
599
|
return (0, rxjs_1.of)((0, Tooltip_js_1.createVisibilityStatus)("hidden", getTooltipOptions(props.tooltips.noElementsInExclusiveAlwaysDrawnList, ignoreTooltip)));
|
|
@@ -630,17 +607,17 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
630
607
|
...props,
|
|
631
608
|
alwaysDrawn: viewport.alwaysDrawn?.size ? setIntersection(props.elements, viewport.alwaysDrawn) : undefined,
|
|
632
609
|
neverDrawn: viewport.neverDrawn?.size ? setIntersection(props.elements, viewport.neverDrawn) : undefined,
|
|
633
|
-
totalCount: props.elements
|
|
610
|
+
totalCount: core_bentley_1.Id64.sizeOf(props.elements),
|
|
634
611
|
ignoreTooltip,
|
|
635
612
|
}));
|
|
636
613
|
}
|
|
637
614
|
const { modelId, categoryIds } = props.categoryProps;
|
|
638
615
|
return (0, rxjs_1.from)(core_bentley_1.Id64.iterable(categoryIds)).pipe((0, rxjs_1.mergeMap)((categoryId) => {
|
|
639
|
-
const totalCount = this.
|
|
616
|
+
const totalCount = this.#idsCache.getCategoryElementsCount(modelId, categoryId);
|
|
640
617
|
return (0, rxjs_1.forkJoin)({
|
|
641
618
|
totalCount,
|
|
642
|
-
alwaysDrawn: this.
|
|
643
|
-
neverDrawn: this.
|
|
619
|
+
alwaysDrawn: this.getAlwaysOrNeverDrawnElements({ modelIds: modelId, categoryIds: categoryId, setType: "always" }),
|
|
620
|
+
neverDrawn: this.getAlwaysOrNeverDrawnElements({ modelIds: modelId, categoryIds: categoryId, setType: "never" }),
|
|
644
621
|
}).pipe(
|
|
645
622
|
// There is a known bug:
|
|
646
623
|
// Categories that don't have root elements will make visibility result incorrect
|
|
@@ -660,18 +637,17 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
660
637
|
}));
|
|
661
638
|
}), mergeVisibilityStatuses());
|
|
662
639
|
}
|
|
663
|
-
|
|
664
|
-
return this
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
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 })));
|
|
668
644
|
}
|
|
669
645
|
clearAlwaysAndNeverDrawnElements(props) {
|
|
670
646
|
return (0, rxjs_1.forkJoin)({
|
|
671
|
-
alwaysDrawn: this.
|
|
672
|
-
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" }),
|
|
673
649
|
}).pipe((0, rxjs_1.map)(({ alwaysDrawn, neverDrawn }) => {
|
|
674
|
-
const viewport = this.
|
|
650
|
+
const viewport = this.#props.viewport;
|
|
675
651
|
if (viewport.alwaysDrawn?.size && alwaysDrawn.size) {
|
|
676
652
|
viewport.setAlwaysDrawn(setDifference(viewport.alwaysDrawn, alwaysDrawn));
|
|
677
653
|
}
|
|
@@ -695,11 +671,11 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
695
671
|
if (haveSubModel === "yes") {
|
|
696
672
|
return (0, rxjs_1.of)(modeledElementIds);
|
|
697
673
|
}
|
|
698
|
-
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)());
|
|
699
675
|
}),
|
|
700
676
|
// combine visibility status of sub-models with visibility status of parent node
|
|
701
677
|
(0, rxjs_1.mergeMap)((modeledElementIds) => {
|
|
702
|
-
if (modeledElementIds
|
|
678
|
+
if (core_bentley_1.Id64.sizeOf(modeledElementIds) === 0) {
|
|
703
679
|
return (0, rxjs_1.of)(parentNodeVisibilityStatus);
|
|
704
680
|
}
|
|
705
681
|
return this.getModelVisibilityStatus({ modelIds: modeledElementIds }).pipe((0, rxjs_1.startWith)(parentNodeVisibilityStatus), mergeVisibilityStatuses(tooltips, ignoreTooltips));
|
|
@@ -731,24 +707,40 @@ function mergeVisibilityStatuses(tooltipMap, ignoreTooltip) {
|
|
|
731
707
|
}
|
|
732
708
|
function setDifference(lhs, rhs) {
|
|
733
709
|
const result = new Set();
|
|
734
|
-
|
|
710
|
+
for (const x of lhs) {
|
|
711
|
+
if (!rhs.has(x)) {
|
|
712
|
+
result.add(x);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
735
715
|
return result;
|
|
736
716
|
}
|
|
737
717
|
function setIntersection(lhs, rhs) {
|
|
738
718
|
const result = new Set();
|
|
739
|
-
|
|
719
|
+
for (const x of lhs) {
|
|
720
|
+
if (rhs.has(x)) {
|
|
721
|
+
result.add(x);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
740
724
|
return result;
|
|
741
725
|
}
|
|
742
726
|
/**
|
|
743
727
|
* Enables display of all given models. Also enables display of all categories and clears always and
|
|
744
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.
|
|
745
732
|
* @public
|
|
746
733
|
*/
|
|
747
|
-
async function showAllModels(models, viewport) {
|
|
734
|
+
async function showAllModels(models, viewport, componentId) {
|
|
748
735
|
await viewport.addViewedModels(models);
|
|
749
736
|
viewport.clearNeverDrawn();
|
|
750
737
|
viewport.clearAlwaysDrawn();
|
|
751
|
-
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);
|
|
752
744
|
}
|
|
753
745
|
/**
|
|
754
746
|
* Disables display of all given models.
|