@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
|
@@ -2,35 +2,44 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Guid } from "@itwin/core-bentley";
|
|
5
6
|
import { DEFINITION_CONTAINER_CLASS, SUB_CATEGORY_CLASS } from "./ClassNameDefinitions.js";
|
|
6
7
|
/** @internal */
|
|
7
8
|
export class CategoriesTreeIdsCache {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
#definitionContainersInfo;
|
|
10
|
+
#modelsCategoriesInfo;
|
|
11
|
+
#subCategoriesInfo;
|
|
12
|
+
#elementModelsCategories;
|
|
13
|
+
#categoryClass;
|
|
14
|
+
#categoryElementClass;
|
|
15
|
+
#categoryModelClass;
|
|
16
|
+
#isDefinitionContainerSupported;
|
|
17
|
+
#queryExecutor;
|
|
18
|
+
#componentId;
|
|
19
|
+
#componentName;
|
|
20
|
+
constructor(queryExecutor, viewType, componentId) {
|
|
21
|
+
this.#queryExecutor = queryExecutor;
|
|
19
22
|
const { categoryClass, categoryElementClass, categoryModelClass } = getClassesByView(viewType);
|
|
20
|
-
this
|
|
21
|
-
this
|
|
22
|
-
this
|
|
23
|
+
this.#categoryClass = categoryClass;
|
|
24
|
+
this.#categoryElementClass = categoryElementClass;
|
|
25
|
+
this.#categoryModelClass = categoryModelClass;
|
|
26
|
+
this.#componentId = componentId ?? Guid.createValue();
|
|
27
|
+
this.#componentName = "CategoriesTreeIdsCache";
|
|
23
28
|
}
|
|
24
29
|
[Symbol.dispose]() { }
|
|
25
30
|
async *queryElementModelCategories() {
|
|
26
31
|
const query = `
|
|
27
32
|
SELECT this.Model.Id modelId, this.Category.Id categoryId
|
|
28
|
-
FROM ${this
|
|
29
|
-
JOIN ${this
|
|
33
|
+
FROM ${this.#categoryModelClass} m
|
|
34
|
+
JOIN ${this.#categoryElementClass} this ON m.ECInstanceId = this.Model.Id
|
|
30
35
|
WHERE m.IsPrivate = false
|
|
31
36
|
GROUP BY modelId, categoryId
|
|
32
37
|
`;
|
|
33
|
-
for await (const row of this.
|
|
38
|
+
for await (const row of this.#queryExecutor.createQueryReader({ ecsql: query }, {
|
|
39
|
+
rowFormat: "ECSqlPropertyNames",
|
|
40
|
+
limit: "unbounded",
|
|
41
|
+
restartToken: `${this.#componentName}/${this.#componentId}/element-models-and-categories`,
|
|
42
|
+
})) {
|
|
34
43
|
yield { modelId: row.modelId, categoryId: row.categoryId };
|
|
35
44
|
}
|
|
36
45
|
}
|
|
@@ -49,16 +58,16 @@ export class CategoriesTreeIdsCache {
|
|
|
49
58
|
)`
|
|
50
59
|
: "false"} parentDefinitionContainerExists
|
|
51
60
|
FROM
|
|
52
|
-
${this
|
|
61
|
+
${this.#categoryClass} this
|
|
53
62
|
JOIN ${SUB_CATEGORY_CLASS} sc ON sc.Parent.Id = this.ECInstanceId
|
|
54
63
|
JOIN BisCore.Model m ON m.ECInstanceId = this.Model.Id
|
|
55
64
|
WHERE
|
|
56
65
|
NOT this.IsPrivate
|
|
57
66
|
AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))
|
|
58
|
-
AND EXISTS (SELECT 1 FROM ${this
|
|
67
|
+
AND EXISTS (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId)
|
|
59
68
|
GROUP BY this.ECInstanceId
|
|
60
69
|
`;
|
|
61
|
-
for await (const row of this.
|
|
70
|
+
for await (const row of this.#queryExecutor.createQueryReader({ ecsql: categoriesQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/categories` })) {
|
|
62
71
|
yield { id: row.id, modelId: row.modelId, parentDefinitionContainerExists: row.parentDefinitionContainerExists, childCount: row.childCount };
|
|
63
72
|
}
|
|
64
73
|
}
|
|
@@ -73,7 +82,7 @@ export class CategoriesTreeIdsCache {
|
|
|
73
82
|
s.Name = 'BisCore'
|
|
74
83
|
AND c.Name = 'DefinitionContainer'
|
|
75
84
|
`;
|
|
76
|
-
for await (const _row of this.
|
|
85
|
+
for await (const _row of this.#queryExecutor.createQueryReader({ ecsql: query }, { restartToken: `${this.#componentName}/${this.#componentId}/is-definition-container-supported` })) {
|
|
77
86
|
return true;
|
|
78
87
|
}
|
|
79
88
|
return false;
|
|
@@ -93,7 +102,7 @@ export class CategoriesTreeIdsCache {
|
|
|
93
102
|
FROM
|
|
94
103
|
${DEFINITION_CONTAINER_CLASS} dc
|
|
95
104
|
WHERE
|
|
96
|
-
dc.ECInstanceId IN (SELECT c.Model.Id FROM ${this
|
|
105
|
+
dc.ECInstanceId IN (SELECT c.Model.Id FROM ${this.#categoryClass} c WHERE NOT c.IsPrivate AND EXISTS (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = c.ECInstanceId))
|
|
97
106
|
AND NOT dc.IsPrivate
|
|
98
107
|
|
|
99
108
|
UNION ALL
|
|
@@ -112,7 +121,7 @@ export class CategoriesTreeIdsCache {
|
|
|
112
121
|
const definitionsQuery = `
|
|
113
122
|
SELECT dc.ECInstanceId id, dc.ModelId modelId FROM ${DEFINITION_CONTAINERS_CTE} dc GROUP BY dc.ECInstanceId
|
|
114
123
|
`;
|
|
115
|
-
for await (const row of this.
|
|
124
|
+
for await (const row of this.#queryExecutor.createQueryReader({ ctes, ecsql: definitionsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/definition-containers` })) {
|
|
116
125
|
yield { id: row.id, modelId: row.modelId };
|
|
117
126
|
}
|
|
118
127
|
}
|
|
@@ -127,12 +136,12 @@ export class CategoriesTreeIdsCache {
|
|
|
127
136
|
NOT sc.IsPrivate
|
|
128
137
|
AND sc.Parent.Id IN (${categoriesInfo.join(",")})
|
|
129
138
|
`;
|
|
130
|
-
for await (const row of this.
|
|
139
|
+
for await (const row of this.#queryExecutor.createQueryReader({ ecsql: definitionsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/visible-sub-categories` })) {
|
|
131
140
|
yield { id: row.id, parentId: row.categoryId };
|
|
132
141
|
}
|
|
133
142
|
}
|
|
134
143
|
async getModelsCategoriesInfo() {
|
|
135
|
-
this
|
|
144
|
+
this.#modelsCategoriesInfo ??= (async () => {
|
|
136
145
|
const allModelsCategories = new Map();
|
|
137
146
|
for await (const queriedCategory of this.queryCategories()) {
|
|
138
147
|
let modelCategories = allModelsCategories.get(queriedCategory.modelId);
|
|
@@ -144,10 +153,10 @@ export class CategoriesTreeIdsCache {
|
|
|
144
153
|
}
|
|
145
154
|
return allModelsCategories;
|
|
146
155
|
})();
|
|
147
|
-
return this
|
|
156
|
+
return this.#modelsCategoriesInfo;
|
|
148
157
|
}
|
|
149
158
|
async getElementModelsCategories() {
|
|
150
|
-
this
|
|
159
|
+
this.#elementModelsCategories ??= (async () => {
|
|
151
160
|
const elementModelsCategories = new Map();
|
|
152
161
|
for await (const queriedCategory of this.queryElementModelCategories()) {
|
|
153
162
|
let modelEntry = elementModelsCategories.get(queriedCategory.modelId);
|
|
@@ -159,10 +168,10 @@ export class CategoriesTreeIdsCache {
|
|
|
159
168
|
}
|
|
160
169
|
return elementModelsCategories;
|
|
161
170
|
})();
|
|
162
|
-
return this
|
|
171
|
+
return this.#elementModelsCategories;
|
|
163
172
|
}
|
|
164
173
|
async getSubCategoriesInfo() {
|
|
165
|
-
this
|
|
174
|
+
this.#subCategoriesInfo ??= (async () => {
|
|
166
175
|
const allSubCategories = new Map();
|
|
167
176
|
const modelsCategoriesInfo = await this.getModelsCategoriesInfo();
|
|
168
177
|
const categoriesWithMoreThanOneSubCategory = new Array();
|
|
@@ -177,10 +186,10 @@ export class CategoriesTreeIdsCache {
|
|
|
177
186
|
}
|
|
178
187
|
return allSubCategories;
|
|
179
188
|
})();
|
|
180
|
-
return this
|
|
189
|
+
return this.#subCategoriesInfo;
|
|
181
190
|
}
|
|
182
191
|
async getDefinitionContainersInfo() {
|
|
183
|
-
this
|
|
192
|
+
this.#definitionContainersInfo ??= (async () => {
|
|
184
193
|
const definitionContainersInfo = new Map();
|
|
185
194
|
const [isDefinitionContainerSupported, modelsCategoriesInfo] = await Promise.all([
|
|
186
195
|
this.getIsDefinitionContainerSupported(),
|
|
@@ -207,7 +216,7 @@ export class CategoriesTreeIdsCache {
|
|
|
207
216
|
}
|
|
208
217
|
return definitionContainersInfo;
|
|
209
218
|
})();
|
|
210
|
-
return this
|
|
219
|
+
return this.#definitionContainersInfo;
|
|
211
220
|
}
|
|
212
221
|
async getDirectChildDefinitionContainersAndCategories(parentDefinitionContainerIds) {
|
|
213
222
|
const definitionContainersInfo = await this.getDefinitionContainersInfo();
|
|
@@ -268,9 +277,9 @@ export class CategoriesTreeIdsCache {
|
|
|
268
277
|
for (const [modelId, modelCategoriesInfo] of modelsCategoriesInfo) {
|
|
269
278
|
if (modelCategoriesInfo.childCategories.find((childCategory) => childCategory.id === props.categoryId)) {
|
|
270
279
|
if (!modelCategoriesInfo.parentDefinitionContainerExists) {
|
|
271
|
-
return [{ id: props.categoryId, className: this
|
|
280
|
+
return [{ id: props.categoryId, className: this.#categoryClass }];
|
|
272
281
|
}
|
|
273
|
-
return [...(await this.getInstanceKeyPaths({ definitionContainerId: modelId })), { id: props.categoryId, className: this
|
|
282
|
+
return [...(await this.getInstanceKeyPaths({ definitionContainerId: modelId })), { id: props.categoryId, className: this.#categoryClass }];
|
|
274
283
|
}
|
|
275
284
|
}
|
|
276
285
|
return [];
|
|
@@ -322,8 +331,8 @@ export class CategoriesTreeIdsCache {
|
|
|
322
331
|
return result;
|
|
323
332
|
}
|
|
324
333
|
async getIsDefinitionContainerSupported() {
|
|
325
|
-
this
|
|
326
|
-
return this
|
|
334
|
+
this.#isDefinitionContainerSupported ??= this.queryIsDefinitionContainersSupported();
|
|
335
|
+
return this.#isDefinitionContainerSupported;
|
|
327
336
|
}
|
|
328
337
|
}
|
|
329
338
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AA2B3F,gBAAgB;AAChB,MAAM,OAAO,sBAAsB;IAWvB;IAVF,yBAAyB,CAAgE;IACzF,qBAAqB,CAAuD;IAC5E,kBAAkB,CAAwD;IAC1E,wBAAwB,CAAgD;IACxE,cAAc,CAAS;IACvB,qBAAqB,CAAS;IAC9B,mBAAmB,CAAS;IAC5B,+BAA+B,CAA+B;IAEtE,YACU,cAA0C,EAClD,QAAqB;QADb,mBAAc,GAAd,cAAc,CAA4B;QAGlD,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC/F,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAC;QAClD,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC;IAChD,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAI,CAAC;IAEpB,KAAK,CAAC,CAAC,2BAA2B;QAIxC,MAAM,KAAK,GAAG;;aAEL,IAAI,CAAC,mBAAmB;aACxB,IAAI,CAAC,qBAAqB;;;KAGlC,CAAC;QACF,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,iB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EAAE,yBAAyB,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,CAAC;AACvJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { DEFINITION_CONTAINER_CLASS, SUB_CATEGORY_CLASS } from \"./ClassNameDefinitions.js\";\n\nimport type { Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\n\ninterface DefinitionContainerInfo {\n modelId: Id64String;\n parentDefinitionContainerExists: boolean;\n childCategories: CategoryInfo[];\n childDefinitionContainers: Id64Array;\n}\n\ninterface CategoriesInfo {\n childCategories: CategoryInfo[];\n parentDefinitionContainerExists: boolean;\n}\n\ninterface CategoryInfo {\n id: Id64String;\n childCount: number;\n}\n\ninterface SubCategoryInfo {\n categoryId: Id64String;\n}\n\n/** @internal */\nexport class CategoriesTreeIdsCache implements Disposable {\n private _definitionContainersInfo: Promise<Map<Id64String, DefinitionContainerInfo>> | undefined;\n private _modelsCategoriesInfo: Promise<Map<Id64String, CategoriesInfo>> | undefined;\n private _subCategoriesInfo: Promise<Map<Id64String, SubCategoryInfo>> | undefined;\n private _elementModelsCategories: Promise<Map<Id64String, Id64Set>> | undefined;\n private _categoryClass: string;\n private _categoryElementClass: string;\n private _categoryModelClass: string;\n private _isDefinitionContainerSupported: Promise<boolean> | undefined;\n\n constructor(\n private _queryExecutor: LimitingECSqlQueryExecutor,\n viewType: \"3d\" | \"2d\",\n ) {\n const { categoryClass, categoryElementClass, categoryModelClass } = getClassesByView(viewType);\n this._categoryClass = categoryClass;\n this._categoryElementClass = categoryElementClass;\n this._categoryModelClass = categoryModelClass;\n }\n\n public [Symbol.dispose]() {}\n\n private async *queryElementModelCategories(): AsyncIterableIterator<{\n modelId: Id64String;\n categoryId: Id64String;\n }> {\n const query = `\n SELECT this.Model.Id modelId, this.Category.Id categoryId\n FROM ${this._categoryModelClass} m\n JOIN ${this._categoryElementClass} this ON m.ECInstanceId = this.Model.Id\n WHERE m.IsPrivate = false\n GROUP BY modelId, categoryId\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/categories-tree/element-models-and-categories-query\" },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId };\n }\n }\n\n private async *queryCategories(): AsyncIterableIterator<{\n id: Id64String;\n modelId: Id64String;\n parentDefinitionContainerExists: boolean;\n childCount: number;\n }> {\n const isDefinitionContainerSupported = await this.getIsDefinitionContainerSupported();\n const categoriesQuery = `\n SELECT\n this.ECInstanceId id,\n COUNT(sc.ECInstanceId) childCount,\n this.Model.Id modelId,\n ${\n isDefinitionContainerSupported\n ? `\n IIF(this.Model.Id IN (SELECT dc.ECInstanceId FROM ${DEFINITION_CONTAINER_CLASS} dc),\n true,\n false\n )`\n : \"false\"\n } parentDefinitionContainerExists\n FROM\n ${this._categoryClass} this\n JOIN ${SUB_CATEGORY_CLASS} sc ON sc.Parent.Id = this.ECInstanceId\n JOIN BisCore.Model m ON m.ECInstanceId = this.Model.Id\n WHERE\n NOT this.IsPrivate\n AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))\n AND EXISTS (SELECT 1 FROM ${this._categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId)\n GROUP BY this.ECInstanceId\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: categoriesQuery }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { id: row.id, modelId: row.modelId, parentDefinitionContainerExists: row.parentDefinitionContainerExists, childCount: row.childCount };\n }\n }\n\n private async queryIsDefinitionContainersSupported(): Promise<boolean> {\n const query = `\n SELECT\n 1\n FROM\n ECDbMeta.ECSchemaDef s\n JOIN ECDbMeta.ECClassDef c ON c.Schema.Id = s.ECInstanceId\n WHERE\n s.Name = 'BisCore'\n AND c.Name = 'DefinitionContainer'\n `;\n\n for await (const _row of this._queryExecutor.createQueryReader({ ecsql: query })) {\n return true;\n }\n return false;\n }\n\n private async *queryDefinitionContainers(): AsyncIterableIterator<{ id: Id64String; modelId: Id64String }> {\n // DefinitionModel ECInstanceId will always be the same as modeled DefinitionContainer ECInstanceId, if this wasn't the case, we would need to do something like:\n // JOIN BisCore.DefinitionModel dm ON dm.ECInstanceId = ${modelIdAccessor}\n // JOIN BisCore.DefinitionModelBreaksDownDefinitionContainer dr ON dr.SourceECInstanceId = dm.ECInstanceId\n // JOIN BisCore.DefinitionContainer dc ON dc.ECInstanceId = dr.TargetECInstanceId\n const DEFINITION_CONTAINERS_CTE = \"DefinitionContainers\";\n const ctes = [\n `\n ${DEFINITION_CONTAINERS_CTE}(ECInstanceId, ModelId) AS (\n SELECT\n dc.ECInstanceId,\n dc.Model.Id\n FROM\n ${DEFINITION_CONTAINER_CLASS} dc\n WHERE\n dc.ECInstanceId IN (SELECT c.Model.Id FROM ${this._categoryClass} c WHERE NOT c.IsPrivate AND EXISTS (SELECT 1 FROM ${this._categoryElementClass} e WHERE e.Category.Id = c.ECInstanceId))\n AND NOT dc.IsPrivate\n\n UNION ALL\n\n SELECT\n pdc.ECInstanceId,\n pdc.Model.Id\n FROM\n ${DEFINITION_CONTAINERS_CTE} cdc\n JOIN ${DEFINITION_CONTAINER_CLASS} pdc ON pdc.ECInstanceId = cdc.ModelId\n WHERE\n NOT pdc.IsPrivate\n )\n `,\n ];\n const definitionsQuery = `\n SELECT dc.ECInstanceId id, dc.ModelId modelId FROM ${DEFINITION_CONTAINERS_CTE} dc GROUP BY dc.ECInstanceId\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ctes, ecsql: definitionsQuery }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { id: row.id, modelId: row.modelId };\n }\n }\n\n private async *queryVisibleSubCategories(categoriesInfo: Id64Array): AsyncIterableIterator<{ id: Id64String; parentId: Id64String }> {\n const definitionsQuery = `\n SELECT\n sc.ECInstanceId id,\n sc.Parent.Id categoryId\n FROM\n ${SUB_CATEGORY_CLASS} sc\n WHERE\n NOT sc.IsPrivate\n AND sc.Parent.Id IN (${categoriesInfo.join(\",\")})\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: definitionsQuery }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { id: row.id, parentId: row.categoryId };\n }\n }\n\n private async getModelsCategoriesInfo() {\n this._modelsCategoriesInfo ??= (async () => {\n const allModelsCategories = new Map<Id64String, CategoriesInfo>();\n for await (const queriedCategory of this.queryCategories()) {\n let modelCategories = allModelsCategories.get(queriedCategory.modelId);\n if (modelCategories === undefined) {\n modelCategories = { parentDefinitionContainerExists: queriedCategory.parentDefinitionContainerExists, childCategories: [] };\n allModelsCategories.set(queriedCategory.modelId, modelCategories);\n }\n modelCategories.childCategories.push({ id: queriedCategory.id, childCount: queriedCategory.childCount });\n }\n return allModelsCategories;\n })();\n return this._modelsCategoriesInfo;\n }\n\n private async getElementModelsCategories() {\n this._elementModelsCategories ??= (async () => {\n const elementModelsCategories = new Map<Id64String, Id64Set>();\n for await (const queriedCategory of this.queryElementModelCategories()) {\n let modelEntry = elementModelsCategories.get(queriedCategory.modelId);\n if (modelEntry === undefined) {\n modelEntry = new Set();\n elementModelsCategories.set(queriedCategory.modelId, modelEntry);\n }\n modelEntry.add(queriedCategory.categoryId);\n }\n return elementModelsCategories;\n })();\n return this._elementModelsCategories;\n }\n\n private async getSubCategoriesInfo() {\n this._subCategoriesInfo ??= (async () => {\n const allSubCategories = new Map<Id64String, SubCategoryInfo>();\n const modelsCategoriesInfo = await this.getModelsCategoriesInfo();\n const categoriesWithMoreThanOneSubCategory = new Array<Id64String>();\n for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {\n categoriesWithMoreThanOneSubCategory.push(\n ...modelCategoriesInfo.childCategories.filter((categoryInfo) => categoryInfo.childCount > 1).map((categoryInfo) => categoryInfo.id),\n );\n }\n\n if (categoriesWithMoreThanOneSubCategory.length === 0) {\n return allSubCategories;\n }\n\n for await (const queriedSubCategory of this.queryVisibleSubCategories(categoriesWithMoreThanOneSubCategory)) {\n allSubCategories.set(queriedSubCategory.id, { categoryId: queriedSubCategory.parentId });\n }\n return allSubCategories;\n })();\n return this._subCategoriesInfo;\n }\n\n private async getDefinitionContainersInfo() {\n this._definitionContainersInfo ??= (async () => {\n const definitionContainersInfo = new Map<Id64String, DefinitionContainerInfo>();\n const [isDefinitionContainerSupported, modelsCategoriesInfo] = await Promise.all([\n this.getIsDefinitionContainerSupported(),\n this.getModelsCategoriesInfo(),\n ]);\n if (!isDefinitionContainerSupported || modelsCategoriesInfo.size === 0) {\n return definitionContainersInfo;\n }\n\n for await (const queriedDefinitionContainer of this.queryDefinitionContainers()) {\n const modelCategoriesInfo = modelsCategoriesInfo.get(queriedDefinitionContainer.id);\n\n definitionContainersInfo.set(queriedDefinitionContainer.id, {\n childCategories: modelCategoriesInfo?.childCategories ?? [],\n modelId: queriedDefinitionContainer.modelId,\n childDefinitionContainers: [],\n parentDefinitionContainerExists: false,\n });\n }\n\n for (const [definitionContainerId, definitionContainerInfo] of definitionContainersInfo) {\n const parentDefinitionContainer = definitionContainersInfo.get(definitionContainerInfo.modelId);\n if (parentDefinitionContainer !== undefined) {\n parentDefinitionContainer.childDefinitionContainers.push(definitionContainerId);\n definitionContainerInfo.parentDefinitionContainerExists = true;\n }\n }\n\n return definitionContainersInfo;\n })();\n return this._definitionContainersInfo;\n }\n\n public async getDirectChildDefinitionContainersAndCategories(\n parentDefinitionContainerIds: Id64Array,\n ): Promise<{ categories: CategoryInfo[]; definitionContainers: Id64Array }> {\n const definitionContainersInfo = await this.getDefinitionContainersInfo();\n\n const result = { definitionContainers: new Array<Id64String>(), categories: new Array<CategoryInfo>() };\n\n parentDefinitionContainerIds.forEach((parentDefinitionContainerId) => {\n const parentDefinitionContainerInfo = definitionContainersInfo.get(parentDefinitionContainerId);\n if (parentDefinitionContainerInfo !== undefined) {\n result.definitionContainers.push(...parentDefinitionContainerInfo.childDefinitionContainers);\n result.categories.push(...parentDefinitionContainerInfo.childCategories);\n }\n });\n return result;\n }\n\n public async getCategoriesElementModels(categoryIds: Id64Array): Promise<Map<Id64String, Id64Array>> {\n const elementModelsCategories = await this.getElementModelsCategories();\n const result = new Map<Id64String, Id64Array>();\n for (const categoryId of categoryIds) {\n for (const [modelId, categories] of elementModelsCategories) {\n if (categories.has(categoryId)) {\n let categoryModels = result.get(categoryId);\n if (!categoryModels) {\n categoryModels = new Array<Id64String>();\n result.set(categoryId, categoryModels);\n }\n categoryModels.push(modelId);\n }\n }\n }\n return result;\n }\n\n public async getAllContainedCategories(definitionContainerIds: Id64Array): Promise<Id64Array> {\n const result = new Array<Id64String>();\n\n const definitionContainersInfo = await this.getDefinitionContainersInfo();\n const indirectCategories = await Promise.all(\n definitionContainerIds.map(async (definitionContainerId) => {\n const definitionContainerInfo = definitionContainersInfo.get(definitionContainerId);\n if (definitionContainerInfo === undefined) {\n return [];\n }\n result.push(...definitionContainerInfo.childCategories.map((category) => category.id));\n return this.getAllContainedCategories(definitionContainerInfo.childDefinitionContainers);\n }),\n );\n for (const categories of indirectCategories) {\n result.push(...categories);\n }\n\n return result;\n }\n\n public async getInstanceKeyPaths(\n props: { categoryId: Id64String } | { definitionContainerId: Id64String } | { subCategoryId: Id64String },\n ): Promise<InstanceKey[]> {\n if (\"subCategoryId\" in props) {\n const subCategoriesInfo = await this.getSubCategoriesInfo();\n const subCategoryInfo = subCategoriesInfo.get(props.subCategoryId);\n if (subCategoryInfo === undefined) {\n return [];\n }\n return [...(await this.getInstanceKeyPaths({ categoryId: subCategoryInfo.categoryId })), { id: props.subCategoryId, className: SUB_CATEGORY_CLASS }];\n }\n\n if (\"categoryId\" in props) {\n const modelsCategoriesInfo = await this.getModelsCategoriesInfo();\n for (const [modelId, modelCategoriesInfo] of modelsCategoriesInfo) {\n if (modelCategoriesInfo.childCategories.find((childCategory) => childCategory.id === props.categoryId)) {\n if (!modelCategoriesInfo.parentDefinitionContainerExists) {\n return [{ id: props.categoryId, className: this._categoryClass }];\n }\n\n return [...(await this.getInstanceKeyPaths({ definitionContainerId: modelId })), { id: props.categoryId, className: this._categoryClass }];\n }\n }\n return [];\n }\n\n const definitionContainersInfo = await this.getDefinitionContainersInfo();\n const definitionContainerInfo = definitionContainersInfo.get(props.definitionContainerId);\n if (definitionContainerInfo === undefined) {\n return [];\n }\n\n if (!definitionContainerInfo.parentDefinitionContainerExists) {\n return [{ id: props.definitionContainerId, className: DEFINITION_CONTAINER_CLASS }];\n }\n\n return [\n ...(await this.getInstanceKeyPaths({ definitionContainerId: definitionContainerInfo.modelId })),\n { id: props.definitionContainerId, className: DEFINITION_CONTAINER_CLASS },\n ];\n }\n\n public async getAllDefinitionContainersAndCategories(): Promise<{ categories: Id64Array; definitionContainers: Id64Array }> {\n const [modelsCategoriesInfo, definitionContainersInfo] = await Promise.all([this.getModelsCategoriesInfo(), this.getDefinitionContainersInfo()]);\n const result = { definitionContainers: [...definitionContainersInfo.keys()], categories: new Array<Id64String>() };\n for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {\n result.categories.push(...modelCategoriesInfo.childCategories.map((childCategory) => childCategory.id));\n }\n\n return result;\n }\n\n public async getRootDefinitionContainersAndCategories(): Promise<{ categories: CategoryInfo[]; definitionContainers: Id64Array }> {\n const [modelsCategoriesInfo, definitionContainersInfo] = await Promise.all([this.getModelsCategoriesInfo(), this.getDefinitionContainersInfo()]);\n const result = { definitionContainers: new Array<Id64String>(), categories: new Array<CategoryInfo>() };\n for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {\n if (!modelCategoriesInfo.parentDefinitionContainerExists) {\n result.categories.push(...modelCategoriesInfo.childCategories);\n }\n }\n\n for (const [definitionContainerId, definitionContainerInfo] of definitionContainersInfo) {\n if (!definitionContainerInfo.parentDefinitionContainerExists) {\n result.definitionContainers.push(definitionContainerId);\n }\n }\n return result;\n }\n\n public async getSubCategories(categoryId: Id64String): Promise<Id64Array> {\n const subCategoriesInfo = await this.getSubCategoriesInfo();\n const result = new Array<Id64String>();\n for (const [subCategoryId, subCategoryInfo] of subCategoriesInfo) {\n if (subCategoryInfo.categoryId === categoryId) {\n result.push(subCategoryId);\n }\n }\n return result;\n }\n\n public async getIsDefinitionContainerSupported(): Promise<boolean> {\n this._isDefinitionContainerSupported ??= this.queryIsDefinitionContainersSupported();\n return this._isDefinitionContainerSupported;\n }\n}\n\n/** @internal */\nexport function getClassesByView(viewType: \"2d\" | \"3d\") {\n return viewType === \"2d\"\n ? { categoryClass: \"BisCore.DrawingCategory\", categoryElementClass: \"BisCore.GeometricElement2d\", categoryModelClass: \"BisCore.GeometricModel2d\" }\n : { categoryClass: \"BisCore.SpatialCategory\", categoryElementClass: \"BisCore.GeometricElement3d\", categoryModelClass: \"BisCore.GeometricModel3d\" };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AA2B3F,gBAAgB;AAChB,MAAM,OAAO,sBAAsB;IACjC,yBAAyB,CAAgE;IACzF,qBAAqB,CAAuD;IAC5E,kBAAkB,CAAwD;IAC1E,wBAAwB,CAAgD;IACxE,cAAc,CAAS;IACvB,qBAAqB,CAAS;IAC9B,mBAAmB,CAAS;IAC5B,+BAA+B,CAA+B;IAC9D,cAAc,CAA6B;IAC3C,YAAY,CAAa;IACzB,cAAc,CAAS;IAEvB,YAAY,aAAyC,EAA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ACH,CAAC;QAED,KAAK,MAAM,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,IAAI,wBAAwB,EAAE,CAAC;YACxF,IAAI,CAAC,uBAAuB,CAAC,+BAA+B,EAAE,CAAC;gBAC7D,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,UAAsB;QAClD,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5D,MAAM,MAAM,GAAG,IAAI,KAAK,EAAc,CAAC;QACvC,KAAK,MAAM,CAAC,aAAa,EAAE,eAAe,CAAC,IAAI,iBAAiB,EAAE,CAAC;YACjE,IAAI,eAAe,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;gBAC9C,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,iCAAiC;QAC5C,IAAI,CAAC,+BAA+B,KAAK,IAAI,CAAC,oCAAoC,EAAE,CAAC;QACrF,OAAO,IAAI,CAAC,+BAA+B,CAAC;IAC9C,CAAC;CACF;AAED,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,QAAqB;IACpD,OAAO,QAAQ,KAAK,IAAI;QACtB,CAAC,CAAC,EAAE,aAAa,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,0BAA0B,EAAE;QAClJ,CAAC,CAAC,EAAE,aAAa,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,CAAC;AACvJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Guid } from \"@itwin/core-bentley\";\nimport { DEFINITION_CONTAINER_CLASS, SUB_CATEGORY_CLASS } from \"./ClassNameDefinitions.js\";\n\nimport type { GuidString, Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\n\ninterface DefinitionContainerInfo {\n modelId: Id64String;\n parentDefinitionContainerExists: boolean;\n childCategories: CategoryInfo[];\n childDefinitionContainers: Id64Array;\n}\n\ninterface CategoriesInfo {\n childCategories: CategoryInfo[];\n parentDefinitionContainerExists: boolean;\n}\n\ninterface CategoryInfo {\n id: Id64String;\n childCount: number;\n}\n\ninterface SubCategoryInfo {\n categoryId: Id64String;\n}\n\n/** @internal */\nexport class CategoriesTreeIdsCache implements Disposable {\n #definitionContainersInfo: Promise<Map<Id64String, DefinitionContainerInfo>> | undefined;\n #modelsCategoriesInfo: Promise<Map<Id64String, CategoriesInfo>> | undefined;\n #subCategoriesInfo: Promise<Map<Id64String, SubCategoryInfo>> | undefined;\n #elementModelsCategories: Promise<Map<Id64String, Id64Set>> | undefined;\n #categoryClass: string;\n #categoryElementClass: string;\n #categoryModelClass: string;\n #isDefinitionContainerSupported: Promise<boolean> | undefined;\n #queryExecutor: LimitingECSqlQueryExecutor;\n #componentId: GuidString;\n #componentName: string;\n\n constructor(queryExecutor: LimitingECSqlQueryExecutor, viewType: \"3d\" | \"2d\", componentId?: GuidString) {\n this.#queryExecutor = queryExecutor;\n const { categoryClass, categoryElementClass, categoryModelClass } = getClassesByView(viewType);\n this.#categoryClass = categoryClass;\n this.#categoryElementClass = categoryElementClass;\n this.#categoryModelClass = categoryModelClass;\n this.#componentId = componentId ?? Guid.createValue();\n this.#componentName = \"CategoriesTreeIdsCache\";\n }\n\n public [Symbol.dispose]() {}\n\n private async *queryElementModelCategories(): AsyncIterableIterator<{\n modelId: Id64String;\n categoryId: Id64String;\n }> {\n const query = `\n SELECT this.Model.Id modelId, this.Category.Id categoryId\n FROM ${this.#categoryModelClass} m\n JOIN ${this.#categoryElementClass} this ON m.ECInstanceId = this.Model.Id\n WHERE m.IsPrivate = false\n GROUP BY modelId, categoryId\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ecsql: query },\n {\n rowFormat: \"ECSqlPropertyNames\",\n limit: \"unbounded\",\n restartToken: `${this.#componentName}/${this.#componentId}/element-models-and-categories`,\n },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId };\n }\n }\n\n private async *queryCategories(): AsyncIterableIterator<{\n id: Id64String;\n modelId: Id64String;\n parentDefinitionContainerExists: boolean;\n childCount: number;\n }> {\n const isDefinitionContainerSupported = await this.getIsDefinitionContainerSupported();\n const categoriesQuery = `\n SELECT\n this.ECInstanceId id,\n COUNT(sc.ECInstanceId) childCount,\n this.Model.Id modelId,\n ${\n isDefinitionContainerSupported\n ? `\n IIF(this.Model.Id IN (SELECT dc.ECInstanceId FROM ${DEFINITION_CONTAINER_CLASS} dc),\n true,\n false\n )`\n : \"false\"\n } parentDefinitionContainerExists\n FROM\n ${this.#categoryClass} this\n JOIN ${SUB_CATEGORY_CLASS} sc ON sc.Parent.Id = this.ECInstanceId\n JOIN BisCore.Model m ON m.ECInstanceId = this.Model.Id\n WHERE\n NOT this.IsPrivate\n AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))\n AND EXISTS (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId)\n GROUP BY this.ECInstanceId\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ecsql: categoriesQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/categories` },\n )) {\n yield { id: row.id, modelId: row.modelId, parentDefinitionContainerExists: row.parentDefinitionContainerExists, childCount: row.childCount };\n }\n }\n\n private async queryIsDefinitionContainersSupported(): Promise<boolean> {\n const query = `\n SELECT\n 1\n FROM\n ECDbMeta.ECSchemaDef s\n JOIN ECDbMeta.ECClassDef c ON c.Schema.Id = s.ECInstanceId\n WHERE\n s.Name = 'BisCore'\n AND c.Name = 'DefinitionContainer'\n `;\n\n for await (const _row of this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { restartToken: `${this.#componentName}/${this.#componentId}/is-definition-container-supported` },\n )) {\n return true;\n }\n return false;\n }\n\n private async *queryDefinitionContainers(): AsyncIterableIterator<{ id: Id64String; modelId: Id64String }> {\n // DefinitionModel ECInstanceId will always be the same as modeled DefinitionContainer ECInstanceId, if this wasn't the case, we would need to do something like:\n // JOIN BisCore.DefinitionModel dm ON dm.ECInstanceId = ${modelIdAccessor}\n // JOIN BisCore.DefinitionModelBreaksDownDefinitionContainer dr ON dr.SourceECInstanceId = dm.ECInstanceId\n // JOIN BisCore.DefinitionContainer dc ON dc.ECInstanceId = dr.TargetECInstanceId\n const DEFINITION_CONTAINERS_CTE = \"DefinitionContainers\";\n const ctes = [\n `\n ${DEFINITION_CONTAINERS_CTE}(ECInstanceId, ModelId) AS (\n SELECT\n dc.ECInstanceId,\n dc.Model.Id\n FROM\n ${DEFINITION_CONTAINER_CLASS} dc\n WHERE\n dc.ECInstanceId IN (SELECT c.Model.Id FROM ${this.#categoryClass} c WHERE NOT c.IsPrivate AND EXISTS (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = c.ECInstanceId))\n AND NOT dc.IsPrivate\n\n UNION ALL\n\n SELECT\n pdc.ECInstanceId,\n pdc.Model.Id\n FROM\n ${DEFINITION_CONTAINERS_CTE} cdc\n JOIN ${DEFINITION_CONTAINER_CLASS} pdc ON pdc.ECInstanceId = cdc.ModelId\n WHERE\n NOT pdc.IsPrivate\n )\n `,\n ];\n const definitionsQuery = `\n SELECT dc.ECInstanceId id, dc.ModelId modelId FROM ${DEFINITION_CONTAINERS_CTE} dc GROUP BY dc.ECInstanceId\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ctes, ecsql: definitionsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/definition-containers` },\n )) {\n yield { id: row.id, modelId: row.modelId };\n }\n }\n\n private async *queryVisibleSubCategories(categoriesInfo: Id64Array): AsyncIterableIterator<{ id: Id64String; parentId: Id64String }> {\n const definitionsQuery = `\n SELECT\n sc.ECInstanceId id,\n sc.Parent.Id categoryId\n FROM\n ${SUB_CATEGORY_CLASS} sc\n WHERE\n NOT sc.IsPrivate\n AND sc.Parent.Id IN (${categoriesInfo.join(\",\")})\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ecsql: definitionsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/visible-sub-categories` },\n )) {\n yield { id: row.id, parentId: row.categoryId };\n }\n }\n\n private async getModelsCategoriesInfo() {\n this.#modelsCategoriesInfo ??= (async () => {\n const allModelsCategories = new Map<Id64String, CategoriesInfo>();\n for await (const queriedCategory of this.queryCategories()) {\n let modelCategories = allModelsCategories.get(queriedCategory.modelId);\n if (modelCategories === undefined) {\n modelCategories = { parentDefinitionContainerExists: queriedCategory.parentDefinitionContainerExists, childCategories: [] };\n allModelsCategories.set(queriedCategory.modelId, modelCategories);\n }\n modelCategories.childCategories.push({ id: queriedCategory.id, childCount: queriedCategory.childCount });\n }\n return allModelsCategories;\n })();\n return this.#modelsCategoriesInfo;\n }\n\n private async getElementModelsCategories() {\n this.#elementModelsCategories ??= (async () => {\n const elementModelsCategories = new Map<Id64String, Id64Set>();\n for await (const queriedCategory of this.queryElementModelCategories()) {\n let modelEntry = elementModelsCategories.get(queriedCategory.modelId);\n if (modelEntry === undefined) {\n modelEntry = new Set();\n elementModelsCategories.set(queriedCategory.modelId, modelEntry);\n }\n modelEntry.add(queriedCategory.categoryId);\n }\n return elementModelsCategories;\n })();\n return this.#elementModelsCategories;\n }\n\n private async getSubCategoriesInfo() {\n this.#subCategoriesInfo ??= (async () => {\n const allSubCategories = new Map<Id64String, SubCategoryInfo>();\n const modelsCategoriesInfo = await this.getModelsCategoriesInfo();\n const categoriesWithMoreThanOneSubCategory = new Array<Id64String>();\n for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {\n categoriesWithMoreThanOneSubCategory.push(\n ...modelCategoriesInfo.childCategories.filter((categoryInfo) => categoryInfo.childCount > 1).map((categoryInfo) => categoryInfo.id),\n );\n }\n\n if (categoriesWithMoreThanOneSubCategory.length === 0) {\n return allSubCategories;\n }\n\n for await (const queriedSubCategory of this.queryVisibleSubCategories(categoriesWithMoreThanOneSubCategory)) {\n allSubCategories.set(queriedSubCategory.id, { categoryId: queriedSubCategory.parentId });\n }\n return allSubCategories;\n })();\n return this.#subCategoriesInfo;\n }\n\n private async getDefinitionContainersInfo() {\n this.#definitionContainersInfo ??= (async () => {\n const definitionContainersInfo = new Map<Id64String, DefinitionContainerInfo>();\n const [isDefinitionContainerSupported, modelsCategoriesInfo] = await Promise.all([\n this.getIsDefinitionContainerSupported(),\n this.getModelsCategoriesInfo(),\n ]);\n if (!isDefinitionContainerSupported || modelsCategoriesInfo.size === 0) {\n return definitionContainersInfo;\n }\n\n for await (const queriedDefinitionContainer of this.queryDefinitionContainers()) {\n const modelCategoriesInfo = modelsCategoriesInfo.get(queriedDefinitionContainer.id);\n\n definitionContainersInfo.set(queriedDefinitionContainer.id, {\n childCategories: modelCategoriesInfo?.childCategories ?? [],\n modelId: queriedDefinitionContainer.modelId,\n childDefinitionContainers: [],\n parentDefinitionContainerExists: false,\n });\n }\n\n for (const [definitionContainerId, definitionContainerInfo] of definitionContainersInfo) {\n const parentDefinitionContainer = definitionContainersInfo.get(definitionContainerInfo.modelId);\n if (parentDefinitionContainer !== undefined) {\n parentDefinitionContainer.childDefinitionContainers.push(definitionContainerId);\n definitionContainerInfo.parentDefinitionContainerExists = true;\n }\n }\n\n return definitionContainersInfo;\n })();\n return this.#definitionContainersInfo;\n }\n\n public async getDirectChildDefinitionContainersAndCategories(\n parentDefinitionContainerIds: Id64Array,\n ): Promise<{ categories: CategoryInfo[]; definitionContainers: Id64Array }> {\n const definitionContainersInfo = await this.getDefinitionContainersInfo();\n\n const result = { definitionContainers: new Array<Id64String>(), categories: new Array<CategoryInfo>() };\n\n parentDefinitionContainerIds.forEach((parentDefinitionContainerId) => {\n const parentDefinitionContainerInfo = definitionContainersInfo.get(parentDefinitionContainerId);\n if (parentDefinitionContainerInfo !== undefined) {\n result.definitionContainers.push(...parentDefinitionContainerInfo.childDefinitionContainers);\n result.categories.push(...parentDefinitionContainerInfo.childCategories);\n }\n });\n return result;\n }\n\n public async getCategoriesElementModels(categoryIds: Id64Array): Promise<Map<Id64String, Id64Array>> {\n const elementModelsCategories = await this.getElementModelsCategories();\n const result = new Map<Id64String, Id64Array>();\n for (const categoryId of categoryIds) {\n for (const [modelId, categories] of elementModelsCategories) {\n if (categories.has(categoryId)) {\n let categoryModels = result.get(categoryId);\n if (!categoryModels) {\n categoryModels = new Array<Id64String>();\n result.set(categoryId, categoryModels);\n }\n categoryModels.push(modelId);\n }\n }\n }\n return result;\n }\n\n public async getAllContainedCategories(definitionContainerIds: Id64Array): Promise<Id64Array> {\n const result = new Array<Id64String>();\n\n const definitionContainersInfo = await this.getDefinitionContainersInfo();\n const indirectCategories = await Promise.all(\n definitionContainerIds.map(async (definitionContainerId) => {\n const definitionContainerInfo = definitionContainersInfo.get(definitionContainerId);\n if (definitionContainerInfo === undefined) {\n return [];\n }\n result.push(...definitionContainerInfo.childCategories.map((category) => category.id));\n return this.getAllContainedCategories(definitionContainerInfo.childDefinitionContainers);\n }),\n );\n for (const categories of indirectCategories) {\n result.push(...categories);\n }\n\n return result;\n }\n\n public async getInstanceKeyPaths(\n props: { categoryId: Id64String } | { definitionContainerId: Id64String } | { subCategoryId: Id64String },\n ): Promise<InstanceKey[]> {\n if (\"subCategoryId\" in props) {\n const subCategoriesInfo = await this.getSubCategoriesInfo();\n const subCategoryInfo = subCategoriesInfo.get(props.subCategoryId);\n if (subCategoryInfo === undefined) {\n return [];\n }\n return [...(await this.getInstanceKeyPaths({ categoryId: subCategoryInfo.categoryId })), { id: props.subCategoryId, className: SUB_CATEGORY_CLASS }];\n }\n\n if (\"categoryId\" in props) {\n const modelsCategoriesInfo = await this.getModelsCategoriesInfo();\n for (const [modelId, modelCategoriesInfo] of modelsCategoriesInfo) {\n if (modelCategoriesInfo.childCategories.find((childCategory) => childCategory.id === props.categoryId)) {\n if (!modelCategoriesInfo.parentDefinitionContainerExists) {\n return [{ id: props.categoryId, className: this.#categoryClass }];\n }\n\n return [...(await this.getInstanceKeyPaths({ definitionContainerId: modelId })), { id: props.categoryId, className: this.#categoryClass }];\n }\n }\n return [];\n }\n\n const definitionContainersInfo = await this.getDefinitionContainersInfo();\n const definitionContainerInfo = definitionContainersInfo.get(props.definitionContainerId);\n if (definitionContainerInfo === undefined) {\n return [];\n }\n\n if (!definitionContainerInfo.parentDefinitionContainerExists) {\n return [{ id: props.definitionContainerId, className: DEFINITION_CONTAINER_CLASS }];\n }\n\n return [\n ...(await this.getInstanceKeyPaths({ definitionContainerId: definitionContainerInfo.modelId })),\n { id: props.definitionContainerId, className: DEFINITION_CONTAINER_CLASS },\n ];\n }\n\n public async getAllDefinitionContainersAndCategories(): Promise<{ categories: Id64Array; definitionContainers: Id64Array }> {\n const [modelsCategoriesInfo, definitionContainersInfo] = await Promise.all([this.getModelsCategoriesInfo(), this.getDefinitionContainersInfo()]);\n const result = { definitionContainers: [...definitionContainersInfo.keys()], categories: new Array<Id64String>() };\n for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {\n result.categories.push(...modelCategoriesInfo.childCategories.map((childCategory) => childCategory.id));\n }\n\n return result;\n }\n\n public async getRootDefinitionContainersAndCategories(): Promise<{ categories: CategoryInfo[]; definitionContainers: Id64Array }> {\n const [modelsCategoriesInfo, definitionContainersInfo] = await Promise.all([this.getModelsCategoriesInfo(), this.getDefinitionContainersInfo()]);\n const result = { definitionContainers: new Array<Id64String>(), categories: new Array<CategoryInfo>() };\n for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {\n if (!modelCategoriesInfo.parentDefinitionContainerExists) {\n result.categories.push(...modelCategoriesInfo.childCategories);\n }\n }\n\n for (const [definitionContainerId, definitionContainerInfo] of definitionContainersInfo) {\n if (!definitionContainerInfo.parentDefinitionContainerExists) {\n result.definitionContainers.push(definitionContainerId);\n }\n }\n return result;\n }\n\n public async getSubCategories(categoryId: Id64String): Promise<Id64Array> {\n const subCategoriesInfo = await this.getSubCategoriesInfo();\n const result = new Array<Id64String>();\n for (const [subCategoryId, subCategoryInfo] of subCategoriesInfo) {\n if (subCategoryInfo.categoryId === categoryId) {\n result.push(subCategoryId);\n }\n }\n return result;\n }\n\n public async getIsDefinitionContainerSupported(): Promise<boolean> {\n this.#isDefinitionContainerSupported ??= this.queryIsDefinitionContainersSupported();\n return this.#isDefinitionContainerSupported;\n }\n}\n\n/** @internal */\nexport function getClassesByView(viewType: \"2d\" | \"3d\") {\n return viewType === \"2d\"\n ? { categoryClass: \"BisCore.DrawingCategory\", categoryElementClass: \"BisCore.GeometricElement2d\", categoryModelClass: \"BisCore.GeometricModel2d\" }\n : { categoryClass: \"BisCore.SpatialCategory\", categoryElementClass: \"BisCore.GeometricElement3d\", categoryModelClass: \"BisCore.GeometricModel3d\" };\n}\n"]}
|
|
@@ -10,9 +10,7 @@ export interface CategoriesVisibilityHandlerProps {
|
|
|
10
10
|
}
|
|
11
11
|
/** @internal */
|
|
12
12
|
export declare class CategoriesVisibilityHandler implements HierarchyVisibilityHandler {
|
|
13
|
-
private
|
|
14
|
-
private _viewport;
|
|
15
|
-
private _idsCache;
|
|
13
|
+
#private;
|
|
16
14
|
constructor(props: CategoriesVisibilityHandlerProps);
|
|
17
15
|
dispose(): void;
|
|
18
16
|
[Symbol.dispose](): void;
|
|
@@ -10,26 +10,26 @@ import { createVisibilityStatus } from "../../common/Tooltip.js";
|
|
|
10
10
|
import { CategoriesTreeNode } from "./CategoriesTreeNode.js";
|
|
11
11
|
/** @internal */
|
|
12
12
|
export class CategoriesVisibilityHandler {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
#pendingVisibilityChange;
|
|
14
|
+
#viewport;
|
|
15
|
+
#idsCache;
|
|
16
16
|
constructor(props) {
|
|
17
|
-
this
|
|
18
|
-
this
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
17
|
+
this.#idsCache = props.idsCache;
|
|
18
|
+
this.#viewport = props.viewport;
|
|
19
|
+
this.#viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);
|
|
20
|
+
this.#viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);
|
|
21
|
+
this.#viewport.onViewedCategoriesPerModelChanged.addListener(this.onViewedCategoriesPerModelChanged);
|
|
22
|
+
this.#viewport.onViewedModelsChanged.addListener(this.onViewedModelsChanged);
|
|
23
23
|
}
|
|
24
24
|
dispose() {
|
|
25
25
|
this[Symbol.dispose]();
|
|
26
26
|
}
|
|
27
27
|
[Symbol.dispose]() {
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
clearTimeout(this
|
|
28
|
+
this.#viewport.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);
|
|
29
|
+
this.#viewport.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);
|
|
30
|
+
this.#viewport.onViewedCategoriesPerModelChanged.removeListener(this.onViewedCategoriesPerModelChanged);
|
|
31
|
+
this.#viewport.onViewedModelsChanged.removeListener(this.onViewedModelsChanged);
|
|
32
|
+
clearTimeout(this.#pendingVisibilityChange);
|
|
33
33
|
}
|
|
34
34
|
onVisibilityChange = new BeEvent();
|
|
35
35
|
/** Returns visibility status of the tree node. */
|
|
@@ -67,10 +67,10 @@ export class CategoriesVisibilityHandler {
|
|
|
67
67
|
}
|
|
68
68
|
async getSubCategoriesVisibility(subCategoryIds, parentCategoryId) {
|
|
69
69
|
let visibility = "unknown";
|
|
70
|
-
const categoryModels = [...(await this.
|
|
70
|
+
const categoryModels = [...(await this.#idsCache.getCategoriesElementModels([parentCategoryId])).values()].flat();
|
|
71
71
|
let nonDefaultModelDisplayStatesCount = 0;
|
|
72
72
|
for (const modelId of categoryModels) {
|
|
73
|
-
if (!this.
|
|
73
|
+
if (!this.#viewport.view.viewsModel(modelId)) {
|
|
74
74
|
if (visibility === "visible") {
|
|
75
75
|
return "partial";
|
|
76
76
|
}
|
|
@@ -78,7 +78,7 @@ export class CategoriesVisibilityHandler {
|
|
|
78
78
|
++nonDefaultModelDisplayStatesCount;
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
|
-
const override = this.
|
|
81
|
+
const override = this.#viewport.perModelCategoryVisibility.getOverride(modelId, parentCategoryId);
|
|
82
82
|
if (override === PerModelCategoryVisibility.Override.Show) {
|
|
83
83
|
if (visibility === "hidden") {
|
|
84
84
|
return "partial";
|
|
@@ -100,7 +100,7 @@ export class CategoriesVisibilityHandler {
|
|
|
100
100
|
assert(visibility === "visible" || visibility === "hidden");
|
|
101
101
|
return visibility;
|
|
102
102
|
}
|
|
103
|
-
if (!this.
|
|
103
|
+
if (!this.#viewport.view.viewsCategory(parentCategoryId)) {
|
|
104
104
|
return visibility === "visible" ? "partial" : "hidden";
|
|
105
105
|
}
|
|
106
106
|
if (subCategoryIds.length === 0) {
|
|
@@ -110,7 +110,7 @@ export class CategoriesVisibilityHandler {
|
|
|
110
110
|
return "visible";
|
|
111
111
|
}
|
|
112
112
|
for (const subCategoryId of subCategoryIds) {
|
|
113
|
-
const isSubCategoryVisible = this.
|
|
113
|
+
const isSubCategoryVisible = this.#viewport.isSubCategoryVisible(subCategoryId);
|
|
114
114
|
if (isSubCategoryVisible && visibility === "hidden") {
|
|
115
115
|
return "partial";
|
|
116
116
|
}
|
|
@@ -123,12 +123,12 @@ export class CategoriesVisibilityHandler {
|
|
|
123
123
|
return visibility;
|
|
124
124
|
}
|
|
125
125
|
async getDefinitionContainerVisibility(node) {
|
|
126
|
-
const categoryIds = await this.
|
|
126
|
+
const categoryIds = await this.#idsCache.getAllContainedCategories(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node));
|
|
127
127
|
return this.getCategoriesVisibility(categoryIds);
|
|
128
128
|
}
|
|
129
129
|
async getCategoriesVisibility(categoryIds) {
|
|
130
130
|
const subCategoriesVisibilities = await Promise.all(categoryIds.map(async (categoryId) => {
|
|
131
|
-
const subCategories = await this.
|
|
131
|
+
const subCategories = await this.#idsCache.getSubCategories(categoryId);
|
|
132
132
|
return this.getSubCategoriesVisibility(subCategories, categoryId);
|
|
133
133
|
}));
|
|
134
134
|
let visibility = "unknown";
|
|
@@ -148,11 +148,11 @@ export class CategoriesVisibilityHandler {
|
|
|
148
148
|
return visibility;
|
|
149
149
|
}
|
|
150
150
|
async enableCategoriesElementModelsVisibility(categoryIds) {
|
|
151
|
-
const categoriesModelsMap = await this.
|
|
151
|
+
const categoriesModelsMap = await this.#idsCache.getCategoriesElementModels(categoryIds);
|
|
152
152
|
const modelIds = [...categoriesModelsMap.values()].flat();
|
|
153
|
-
const hiddenModels = modelIds.filter((modelId) => !this.
|
|
153
|
+
const hiddenModels = modelIds.filter((modelId) => !this.#viewport.view.viewsModel(modelId));
|
|
154
154
|
if (hiddenModels.length > 0) {
|
|
155
|
-
this.
|
|
155
|
+
this.#viewport.changeModelDisplay(hiddenModels, true);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
async changeSubCategoryVisibility(node, on) {
|
|
@@ -175,7 +175,7 @@ export class CategoriesVisibilityHandler {
|
|
|
175
175
|
}
|
|
176
176
|
async changeDefinitionContainerVisibility(node, on) {
|
|
177
177
|
const definitionContainerId = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);
|
|
178
|
-
const childCategories = await this.
|
|
178
|
+
const childCategories = await this.#idsCache.getAllContainedCategories(definitionContainerId);
|
|
179
179
|
return this.changeCategoryVisibility(childCategories, on);
|
|
180
180
|
}
|
|
181
181
|
onDisplayStyleChanged = () => {
|
|
@@ -191,22 +191,22 @@ export class CategoriesVisibilityHandler {
|
|
|
191
191
|
this.onVisibilityChangeInternal();
|
|
192
192
|
};
|
|
193
193
|
onVisibilityChangeInternal() {
|
|
194
|
-
if (this
|
|
194
|
+
if (this.#pendingVisibilityChange) {
|
|
195
195
|
return;
|
|
196
196
|
}
|
|
197
|
-
this
|
|
197
|
+
this.#pendingVisibilityChange = setTimeout(() => {
|
|
198
198
|
this.onVisibilityChange.raiseEvent();
|
|
199
|
-
this
|
|
199
|
+
this.#pendingVisibilityChange = undefined;
|
|
200
200
|
}, 0);
|
|
201
201
|
}
|
|
202
202
|
static getInstanceIdsFromHierarchyNode(node) {
|
|
203
203
|
return HierarchyNode.isInstancesNode(node) ? node.key.instanceKeys.map((instanceKey) => instanceKey.id) : /* istanbul ignore next */ [];
|
|
204
204
|
}
|
|
205
205
|
async changeCategoryState(ids, enabled, enableAllSubCategories) {
|
|
206
|
-
await enableCategoryDisplay(this
|
|
206
|
+
await enableCategoryDisplay(this.#viewport, ids, enabled, enableAllSubCategories);
|
|
207
207
|
}
|
|
208
208
|
changeSubCategoryState(key, enabled) {
|
|
209
|
-
enableSubCategoryDisplay(this
|
|
209
|
+
enableSubCategoryDisplay(this.#viewport, key, enabled);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
//# sourceMappingURL=CategoriesVisibilityHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesVisibilityHandler.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AA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CAAC,kBAAkB,CAAC,UAAU,EAAE,CAAC;YACrC,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;QAC5C,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAEO,MAAM,CAAC,+BAA+B,CAAC,IAAmB;QAChE,OAAO,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,EAAE,CAAC;IAC1I,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAC,GAAa,EAAE,OAAgB,EAAE,sBAA+B;QAChG,MAAM,qBAAqB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;IACpF,CAAC;IAEO,sBAAsB,CAAC,GAAW,EAAE,OAAgB;QAC1D,wBAAwB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { assert, BeEvent } from \"@itwin/core-bentley\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { enableCategoryDisplay, enableSubCategoryDisplay } from \"../../common/CategoriesVisibilityUtils.js\";\nimport { createVisibilityStatus } from \"../../common/Tooltip.js\";\nimport { CategoriesTreeNode } from \"./CategoriesTreeNode.js\";\n\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { Visibility } from \"../../common/Tooltip.js\";\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyVisibilityHandler, VisibilityStatus } from \"../../common/UseHierarchyVisibility.js\";\nimport type { CategoriesTreeIdsCache } from \"./CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport interface CategoriesVisibilityHandlerProps {\n viewport: Viewport;\n idsCache: CategoriesTreeIdsCache;\n}\n\n/** @internal */\nexport class CategoriesVisibilityHandler implements HierarchyVisibilityHandler {\n private _pendingVisibilityChange: any;\n private _viewport: Viewport;\n private _idsCache: CategoriesTreeIdsCache;\n\n constructor(props: CategoriesVisibilityHandlerProps) {\n this._idsCache = props.idsCache;\n this._viewport = props.viewport;\n this._viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n this._viewport.onViewedCategoriesPerModelChanged.addListener(this.onViewedCategoriesPerModelChanged);\n this._viewport.onViewedModelsChanged.addListener(this.onViewedModelsChanged);\n }\n\n public dispose() {\n this[Symbol.dispose]();\n }\n\n public [Symbol.dispose]() {\n this._viewport.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n this._viewport.onViewedCategoriesPerModelChanged.removeListener(this.onViewedCategoriesPerModelChanged);\n this._viewport.onViewedModelsChanged.removeListener(this.onViewedModelsChanged);\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent();\n\n /** Returns visibility status of the tree node. */\n public async getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> {\n if (!HierarchyNode.isInstancesNode(node)) {\n return { state: \"hidden\", isDisabled: true };\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n if (!node.extendedData?.categoryId) {\n return { state: \"hidden\", isDisabled: true };\n }\n return createVisibilityStatus(\n await this.getSubCategoriesVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node), node.extendedData.categoryId),\n );\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return createVisibilityStatus(await this.getCategoriesVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node)));\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return createVisibilityStatus(await this.getDefinitionContainerVisibility(node));\n }\n\n return { state: \"hidden\", isDisabled: true };\n }\n\n public async changeVisibility(node: HierarchyNode, on: boolean) {\n if (!HierarchyNode.isInstancesNode(node)) {\n return;\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return this.changeCategoryVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node), on);\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n return this.changeSubCategoryVisibility(node, on);\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return this.changeDefinitionContainerVisibility(node, on);\n }\n }\n\n private async getSubCategoriesVisibility(subCategoryIds: Id64Array, parentCategoryId: Id64String): Promise<Visibility> {\n let visibility: \"visible\" | \"hidden\" | \"unknown\" = \"unknown\";\n const categoryModels = [...(await this._idsCache.getCategoriesElementModels([parentCategoryId])).values()].flat();\n let nonDefaultModelDisplayStatesCount = 0;\n for (const modelId of categoryModels) {\n if (!this._viewport.view.viewsModel(modelId)) {\n if (visibility === \"visible\") {\n return \"partial\";\n }\n visibility = \"hidden\";\n ++nonDefaultModelDisplayStatesCount;\n continue;\n }\n const override = this._viewport.perModelCategoryVisibility.getOverride(modelId, parentCategoryId);\n if (override === PerModelCategoryVisibility.Override.Show) {\n if (visibility === \"hidden\") {\n return \"partial\";\n }\n visibility = \"visible\";\n ++nonDefaultModelDisplayStatesCount;\n continue;\n }\n if (override === PerModelCategoryVisibility.Override.Hide) {\n if (visibility === \"visible\") {\n return \"partial\";\n }\n visibility = \"hidden\";\n ++nonDefaultModelDisplayStatesCount;\n continue;\n }\n }\n if (categoryModels.length > 0 && nonDefaultModelDisplayStatesCount === categoryModels.length) {\n assert(visibility === \"visible\" || visibility === \"hidden\");\n return visibility;\n }\n\n if (!this._viewport.view.viewsCategory(parentCategoryId)) {\n return visibility === \"visible\" ? \"partial\" : \"hidden\";\n }\n\n if (subCategoryIds.length === 0) {\n if (visibility === \"hidden\") {\n return \"partial\";\n }\n return \"visible\";\n }\n\n for (const subCategoryId of subCategoryIds) {\n const isSubCategoryVisible = this._viewport.isSubCategoryVisible(subCategoryId);\n if (isSubCategoryVisible && visibility === \"hidden\") {\n return \"partial\";\n }\n if (!isSubCategoryVisible && visibility === \"visible\") {\n return \"partial\";\n }\n visibility = isSubCategoryVisible ? \"visible\" : \"hidden\";\n }\n assert(visibility === \"visible\" || visibility === \"hidden\");\n return visibility;\n }\n\n private async getDefinitionContainerVisibility(node: HierarchyNode): Promise<Visibility> {\n const categoryIds = await this._idsCache.getAllContainedCategories(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node));\n return this.getCategoriesVisibility(categoryIds);\n }\n\n private async getCategoriesVisibility(categoryIds: Id64Array): Promise<Visibility> {\n const subCategoriesVisibilities = await Promise.all(\n categoryIds.map(async (categoryId) => {\n const subCategories = await this._idsCache.getSubCategories(categoryId);\n return this.getSubCategoriesVisibility(subCategories, categoryId);\n }),\n );\n let visibility: \"visible\" | \"hidden\" | \"unknown\" = \"unknown\";\n\n for (const subCategoriesVisibility of subCategoriesVisibilities) {\n if (subCategoriesVisibility === \"partial\") {\n return \"partial\";\n }\n if (subCategoriesVisibility === \"hidden\" && visibility === \"visible\") {\n return \"partial\";\n }\n if (subCategoriesVisibility === \"visible\" && visibility === \"hidden\") {\n return \"partial\";\n }\n visibility = subCategoriesVisibility;\n }\n assert(visibility !== \"unknown\");\n return visibility;\n }\n\n private async enableCategoriesElementModelsVisibility(categoryIds: Id64Array) {\n const categoriesModelsMap = await this._idsCache.getCategoriesElementModels(categoryIds);\n const modelIds = [...categoriesModelsMap.values()].flat();\n const hiddenModels = modelIds.filter((modelId) => !this._viewport.view.viewsModel(modelId));\n if (hiddenModels.length > 0) {\n this._viewport.changeModelDisplay(hiddenModels, true);\n }\n }\n\n private async changeSubCategoryVisibility(node: HierarchyNode, on: boolean) {\n const parentCategoryId = node.extendedData?.categoryId;\n\n // make sure parent category and models are enabled\n if (on && parentCategoryId) {\n await Promise.all([this.enableCategoriesElementModelsVisibility([parentCategoryId]), this.changeCategoryState([parentCategoryId], true, false)]);\n }\n\n const subCategoryIds = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n subCategoryIds.forEach((id) => {\n this.changeSubCategoryState(id, on);\n });\n }\n private async changeCategoryVisibility(categoryIds: Id64Array, on: boolean) {\n // make sure models are enabled\n if (on) {\n await this.enableCategoriesElementModelsVisibility(categoryIds);\n }\n return this.changeCategoryState(categoryIds, on, on);\n }\n\n private async changeDefinitionContainerVisibility(node: HierarchyNode, on: boolean) {\n const definitionContainerId = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n const childCategories = await this._idsCache.getAllContainedCategories(definitionContainerId);\n return this.changeCategoryVisibility(childCategories, on);\n }\n\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onViewedCategoriesPerModelChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onViewedModelsChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange) {\n return;\n }\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n private static getInstanceIdsFromHierarchyNode(node: HierarchyNode) {\n return HierarchyNode.isInstancesNode(node) ? node.key.instanceKeys.map((instanceKey) => instanceKey.id) : /* istanbul ignore next */ [];\n }\n\n private async changeCategoryState(ids: string[], enabled: boolean, enableAllSubCategories: boolean) {\n await enableCategoryDisplay(this._viewport, ids, enabled, enableAllSubCategories);\n }\n\n private changeSubCategoryState(key: string, enabled: boolean) {\n enableSubCategoryDisplay(this._viewport, key, enabled);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesVisibilityHandler.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAC5G,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAc7D,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IACtC,wBAAwB,CAAM;IAC9B,SAAS,CAAW;IACpB,SAAS,CAAyB;IAElC,YAAY,KAAuC;QACjD,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,WAAW,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC7E,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,WAAW,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QACrF,IAAI,CAAC,SAAS,CAAC,iCAAiC,CAAC,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QACrG,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,WAAW,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAC/E,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,c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CAAC;IAEM,qBAAqB,GAAG,GAAG,EAAE;QACnC,IAAI,CAAC,0BAA0B,EAAE,CAAC;IACpC,CAAC,CAAC;IAEM,0BAA0B;QAChC,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAClC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,wBAAwB,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9C,IAAI,CAAC,kBAAkB,CAAC,UAAU,EAAE,CAAC;YACrC,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;QAC5C,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAEO,MAAM,CAAC,+BAA+B,CAAC,IAAmB;QAChE,OAAO,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,EAAE,CAAC;IAC1I,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAC,GAAa,EAAE,OAAgB,EAAE,sBAA+B;QAChG,MAAM,qBAAqB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;IACpF,CAAC;IAEO,sBAAsB,CAAC,GAAW,EAAE,OAAgB;QAC1D,wBAAwB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { assert, BeEvent } from \"@itwin/core-bentley\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { enableCategoryDisplay, enableSubCategoryDisplay } from \"../../common/CategoriesVisibilityUtils.js\";\nimport { createVisibilityStatus } from \"../../common/Tooltip.js\";\nimport { CategoriesTreeNode } from \"./CategoriesTreeNode.js\";\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { Visibility } from \"../../common/Tooltip.js\";\nimport type { HierarchyVisibilityHandler, VisibilityStatus } from \"../../common/UseHierarchyVisibility.js\";\nimport type { CategoriesTreeIdsCache } from \"./CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport interface CategoriesVisibilityHandlerProps {\n viewport: Viewport;\n idsCache: CategoriesTreeIdsCache;\n}\n\n/** @internal */\nexport class CategoriesVisibilityHandler implements HierarchyVisibilityHandler {\n #pendingVisibilityChange: any;\n #viewport: Viewport;\n #idsCache: CategoriesTreeIdsCache;\n\n constructor(props: CategoriesVisibilityHandlerProps) {\n this.#idsCache = props.idsCache;\n this.#viewport = props.viewport;\n this.#viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this.#viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n this.#viewport.onViewedCategoriesPerModelChanged.addListener(this.onViewedCategoriesPerModelChanged);\n this.#viewport.onViewedModelsChanged.addListener(this.onViewedModelsChanged);\n }\n\n public dispose() {\n this[Symbol.dispose]();\n }\n\n public [Symbol.dispose]() {\n this.#viewport.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this.#viewport.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n this.#viewport.onViewedCategoriesPerModelChanged.removeListener(this.onViewedCategoriesPerModelChanged);\n this.#viewport.onViewedModelsChanged.removeListener(this.onViewedModelsChanged);\n clearTimeout(this.#pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent();\n\n /** Returns visibility status of the tree node. */\n public async getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> {\n if (!HierarchyNode.isInstancesNode(node)) {\n return { state: \"hidden\", isDisabled: true };\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n if (!node.extendedData?.categoryId) {\n return { state: \"hidden\", isDisabled: true };\n }\n return createVisibilityStatus(\n await this.getSubCategoriesVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node), node.extendedData.categoryId),\n );\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return createVisibilityStatus(await this.getCategoriesVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node)));\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return createVisibilityStatus(await this.getDefinitionContainerVisibility(node));\n }\n\n return { state: \"hidden\", isDisabled: true };\n }\n\n public async changeVisibility(node: HierarchyNode, on: boolean) {\n if (!HierarchyNode.isInstancesNode(node)) {\n return;\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return this.changeCategoryVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node), on);\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n return this.changeSubCategoryVisibility(node, on);\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return this.changeDefinitionContainerVisibility(node, on);\n }\n }\n\n private async getSubCategoriesVisibility(subCategoryIds: Id64Array, parentCategoryId: Id64String): Promise<Visibility> {\n let visibility: \"visible\" | \"hidden\" | \"unknown\" = \"unknown\";\n const categoryModels = [...(await this.#idsCache.getCategoriesElementModels([parentCategoryId])).values()].flat();\n let nonDefaultModelDisplayStatesCount = 0;\n for (const modelId of categoryModels) {\n if (!this.#viewport.view.viewsModel(modelId)) {\n if (visibility === \"visible\") {\n return \"partial\";\n }\n visibility = \"hidden\";\n ++nonDefaultModelDisplayStatesCount;\n continue;\n }\n const override = this.#viewport.perModelCategoryVisibility.getOverride(modelId, parentCategoryId);\n if (override === PerModelCategoryVisibility.Override.Show) {\n if (visibility === \"hidden\") {\n return \"partial\";\n }\n visibility = \"visible\";\n ++nonDefaultModelDisplayStatesCount;\n continue;\n }\n if (override === PerModelCategoryVisibility.Override.Hide) {\n if (visibility === \"visible\") {\n return \"partial\";\n }\n visibility = \"hidden\";\n ++nonDefaultModelDisplayStatesCount;\n continue;\n }\n }\n if (categoryModels.length > 0 && nonDefaultModelDisplayStatesCount === categoryModels.length) {\n assert(visibility === \"visible\" || visibility === \"hidden\");\n return visibility;\n }\n\n if (!this.#viewport.view.viewsCategory(parentCategoryId)) {\n return visibility === \"visible\" ? \"partial\" : \"hidden\";\n }\n\n if (subCategoryIds.length === 0) {\n if (visibility === \"hidden\") {\n return \"partial\";\n }\n return \"visible\";\n }\n\n for (const subCategoryId of subCategoryIds) {\n const isSubCategoryVisible = this.#viewport.isSubCategoryVisible(subCategoryId);\n if (isSubCategoryVisible && visibility === \"hidden\") {\n return \"partial\";\n }\n if (!isSubCategoryVisible && visibility === \"visible\") {\n return \"partial\";\n }\n visibility = isSubCategoryVisible ? \"visible\" : \"hidden\";\n }\n assert(visibility === \"visible\" || visibility === \"hidden\");\n return visibility;\n }\n\n private async getDefinitionContainerVisibility(node: HierarchyNode): Promise<Visibility> {\n const categoryIds = await this.#idsCache.getAllContainedCategories(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node));\n return this.getCategoriesVisibility(categoryIds);\n }\n\n private async getCategoriesVisibility(categoryIds: Id64Array): Promise<Visibility> {\n const subCategoriesVisibilities = await Promise.all(\n categoryIds.map(async (categoryId) => {\n const subCategories = await this.#idsCache.getSubCategories(categoryId);\n return this.getSubCategoriesVisibility(subCategories, categoryId);\n }),\n );\n let visibility: \"visible\" | \"hidden\" | \"unknown\" = \"unknown\";\n\n for (const subCategoriesVisibility of subCategoriesVisibilities) {\n if (subCategoriesVisibility === \"partial\") {\n return \"partial\";\n }\n if (subCategoriesVisibility === \"hidden\" && visibility === \"visible\") {\n return \"partial\";\n }\n if (subCategoriesVisibility === \"visible\" && visibility === \"hidden\") {\n return \"partial\";\n }\n visibility = subCategoriesVisibility;\n }\n assert(visibility !== \"unknown\");\n return visibility;\n }\n\n private async enableCategoriesElementModelsVisibility(categoryIds: Id64Array) {\n const categoriesModelsMap = await this.#idsCache.getCategoriesElementModels(categoryIds);\n const modelIds = [...categoriesModelsMap.values()].flat();\n const hiddenModels = modelIds.filter((modelId) => !this.#viewport.view.viewsModel(modelId));\n if (hiddenModels.length > 0) {\n this.#viewport.changeModelDisplay(hiddenModels, true);\n }\n }\n\n private async changeSubCategoryVisibility(node: HierarchyNode, on: boolean) {\n const parentCategoryId = node.extendedData?.categoryId;\n\n // make sure parent category and models are enabled\n if (on && parentCategoryId) {\n await Promise.all([this.enableCategoriesElementModelsVisibility([parentCategoryId]), this.changeCategoryState([parentCategoryId], true, false)]);\n }\n\n const subCategoryIds = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n subCategoryIds.forEach((id) => {\n this.changeSubCategoryState(id, on);\n });\n }\n private async changeCategoryVisibility(categoryIds: Id64Array, on: boolean) {\n // make sure models are enabled\n if (on) {\n await this.enableCategoriesElementModelsVisibility(categoryIds);\n }\n return this.changeCategoryState(categoryIds, on, on);\n }\n\n private async changeDefinitionContainerVisibility(node: HierarchyNode, on: boolean) {\n const definitionContainerId = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n const childCategories = await this.#idsCache.getAllContainedCategories(definitionContainerId);\n return this.changeCategoryVisibility(childCategories, on);\n }\n\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onViewedCategoriesPerModelChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onViewedModelsChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this.#pendingVisibilityChange) {\n return;\n }\n\n this.#pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this.#pendingVisibilityChange = undefined;\n }, 0);\n }\n\n private static getInstanceIdsFromHierarchyNode(node: HierarchyNode) {\n return HierarchyNode.isInstancesNode(node) ? node.key.instanceKeys.map((instanceKey) => instanceKey.id) : /* istanbul ignore next */ [];\n }\n\n private async changeCategoryState(ids: string[], enabled: boolean, enableAllSubCategories: boolean) {\n await enableCategoryDisplay(this.#viewport, ids, enabled, enableAllSubCategories);\n }\n\n private changeSubCategoryState(key: string, enabled: boolean) {\n enableSubCategoryDisplay(this.#viewport, key, enabled);\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Id64Array } from "@itwin/core-bentley";
|
|
1
|
+
import type { GuidString, Id64Array } from "@itwin/core-bentley";
|
|
2
2
|
import type { Viewport } from "@itwin/core-frontend";
|
|
3
3
|
/**
|
|
4
4
|
* Data structure that describes category.
|
|
@@ -8,11 +8,6 @@ export interface CategoryInfo {
|
|
|
8
8
|
categoryId: string;
|
|
9
9
|
subCategoryIds?: string[];
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Toggles visibility of categories to show or hide.
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare function toggleAllCategories(viewport: Viewport, display: boolean): Promise<void>;
|
|
16
11
|
/**
|
|
17
12
|
* Changes category display in the viewport.
|
|
18
13
|
* @internal
|
|
@@ -24,7 +19,7 @@ export declare function enableCategoryDisplay(viewport: Viewport, categoryIds: I
|
|
|
24
19
|
*/
|
|
25
20
|
export declare function enableSubCategoryDisplay(viewport: Viewport, key: string, enabled: boolean): void;
|
|
26
21
|
/** @internal */
|
|
27
|
-
export declare function loadCategoriesFromViewport(vp: Viewport): Promise<CategoryInfo[]>;
|
|
22
|
+
export declare function loadCategoriesFromViewport(vp: Viewport, componentId?: GuidString): Promise<CategoryInfo[]>;
|
|
28
23
|
/**
|
|
29
24
|
* Enable display of all given categories.
|
|
30
25
|
* @public
|