@itwin/tree-widget-react 4.0.0-alpha.13 → 4.0.0-alpha.14

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.
Files changed (39) hide show
  1. package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
  2. package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.css +1 -1
  3. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +1 -1
  4. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +2 -2
  5. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
  6. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js +13 -8
  7. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js.map +1 -1
  8. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.d.ts +1 -1
  9. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js +4 -3
  10. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js.map +1 -1
  11. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +1 -1
  12. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js +2 -2
  13. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js.map +1 -1
  14. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.d.ts +10 -1
  15. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js +268 -0
  16. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js.map +1 -1
  17. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.d.ts +3 -2
  18. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +46 -8
  19. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js.map +1 -1
  20. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.d.ts +16 -3
  21. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +74 -8
  22. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js.map +1 -1
  23. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.d.ts +2 -2
  24. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.js.map +1 -1
  25. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.d.ts +2 -0
  26. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.js +69 -6
  27. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.js.map +1 -1
  28. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/FilteredTree.d.ts +37 -0
  29. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/FilteredTree.js +193 -0
  30. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/FilteredTree.js.map +1 -0
  31. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.d.ts +18 -0
  32. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.js +51 -0
  33. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.js.map +1 -0
  34. package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js.map +1 -1
  35. package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js.map +1 -1
  36. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  37. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js.map +1 -1
  38. package/lib/public/locales/en/TreeWidget.json +8 -1
  39. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
+ import type { Observable } from "rxjs";
1
2
  import type { Id64Array, Id64String } from "@itwin/core-bentley";
2
- import type { CategoryId, ModelId } from "../../common/internal/Types.js";
3
- import type { LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
3
+ import type { CategoryId, ElementId, ModelId } from "../../common/internal/Types.js";
4
+ import type { HierarchyNodeIdentifiersPath, LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
4
5
  import type { ClassificationsTreeHierarchyConfiguration } from "../ClassificationsTreeDefinition.js";
5
6
  /** @internal */
6
7
  export type ClassificationId = Id64String;
@@ -14,6 +15,7 @@ export declare class ClassificationsTreeIdsCache implements Disposable {
14
15
  private _elementModelsCategories;
15
16
  private _modelWithCategoryModeledElements;
16
17
  private _classificationInfos;
18
+ private _filteredElementsData;
17
19
  constructor(_queryExecutor: LimitingECSqlQueryExecutor, _hierarchyConfig: ClassificationsTreeHierarchyConfiguration);
18
20
  [Symbol.dispose](): void;
19
21
  private queryElementModelCategories;
@@ -21,7 +23,7 @@ export declare class ClassificationsTreeIdsCache implements Disposable {
21
23
  private queryModeledElements;
22
24
  private getModelWithCategoryModeledElements;
23
25
  getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Array): Promise<Id64Array>;
24
- getCategoriesElementModels(categoryIds: Id64Array, includeSubModels?: boolean): Promise<Map<CategoryId, Array<ModelId>>>;
26
+ getCategoriesElementModels(categoryIds: Id64Array, includeSubModels?: boolean): Promise<Map<CategoryId, Set<ModelId>>>;
25
27
  getModelCategoryIds(modelId: Id64String): Promise<{
26
28
  drawing: Id64Array;
27
29
  spatial: Id64Array;
@@ -35,5 +37,16 @@ export declare class ClassificationsTreeIdsCache implements Disposable {
35
37
  spatial: Id64Array;
36
38
  }>;
37
39
  getDirectChildClassifications(classificationOrTableIds: Id64Array): Promise<ClassificationId[]>;
40
+ getClassificationsPathObs(classificationIds: Id64Array): Observable<HierarchyNodeIdentifiersPath>;
41
+ getAllClassifications(): Promise<ClassificationId[]>;
42
+ private queryFilteredElementsData;
43
+ getFilteredElementsData({ element2dIds, element3dIds, }: {
44
+ element2dIds: Id64Array;
45
+ element3dIds: Id64Array;
46
+ }): Promise<Map<ElementId, {
47
+ categoryId: Id64String;
48
+ modelId: Id64String;
49
+ }>>;
50
+ clearFilteredElementsData(): void;
38
51
  }
39
52
  //# sourceMappingURL=ClassificationsTreeIdsCache.d.ts.map
@@ -2,7 +2,7 @@
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 { assert } from "@itwin/core-bentley";
5
+ import { from, map, mergeMap } from "rxjs";
6
6
  import { CLASS_NAME_Classification, CLASS_NAME_ClassificationSystem, CLASS_NAME_ClassificationTable, CLASS_NAME_DrawingCategory, CLASS_NAME_ElementHasClassifications, CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d, CLASS_NAME_SpatialCategory, } from "../../common/internal/ClassNameDefinitions.js";
7
7
  import { ModelCategoryElementsCountCache } from "../../common/internal/ModelCategoryElementsCountCache.js";
8
8
  import { getDistinctMapValues } from "../../common/internal/Utils.js";
@@ -14,6 +14,7 @@ export class ClassificationsTreeIdsCache {
14
14
  _elementModelsCategories;
15
15
  _modelWithCategoryModeledElements;
16
16
  _classificationInfos;
17
+ _filteredElementsData;
17
18
  constructor(_queryExecutor, _hierarchyConfig) {
18
19
  this._queryExecutor = _queryExecutor;
19
20
  this._hierarchyConfig = _hierarchyConfig;
@@ -140,10 +141,10 @@ export class ClassificationsTreeIdsCache {
140
141
  if ((includeSubModels || !isSubModel) && (category2dIds.has(categoryId) || category3dIds.has(categoryId))) {
141
142
  let categoryModels = result.get(categoryId);
142
143
  if (!categoryModels) {
143
- categoryModels = new Array();
144
+ categoryModels = new Set();
144
145
  result.set(categoryId, categoryModels);
145
146
  }
146
- categoryModels.push(modelId);
147
+ categoryModels.add(modelId);
147
148
  }
148
149
  }
149
150
  }
@@ -233,14 +234,20 @@ export class ClassificationsTreeIdsCache {
233
234
  const classificationInfos = new Map();
234
235
  for await (const { id, tableId, parentId, relatedCategories2d, relatedCategories3d } of this.queryClassifications()) {
235
236
  const tableOrParentId = tableId ?? parentId;
236
- assert(!!tableOrParentId);
237
237
  let parentInfo = classificationInfos.get(tableOrParentId);
238
238
  if (!parentInfo) {
239
- parentInfo = { childClassificationIds: [], relatedCategories2d: [], relatedCategories3d: [] };
239
+ parentInfo = { childClassificationIds: [], relatedCategories2d: [], relatedCategories3d: [], parentClassificationOrTableId: undefined };
240
240
  classificationInfos.set(tableOrParentId, parentInfo);
241
241
  }
242
242
  parentInfo.childClassificationIds.push(id);
243
- classificationInfos.set(id, { childClassificationIds: [], relatedCategories2d, relatedCategories3d });
243
+ let classificationEntry = classificationInfos.get(id);
244
+ if (!classificationEntry) {
245
+ classificationEntry = { childClassificationIds: [], relatedCategories2d, relatedCategories3d, parentClassificationOrTableId: tableOrParentId };
246
+ classificationInfos.set(id, classificationEntry);
247
+ }
248
+ else {
249
+ classificationEntry.parentClassificationOrTableId = tableOrParentId;
250
+ }
244
251
  }
245
252
  return classificationInfos;
246
253
  })();
@@ -269,14 +276,73 @@ export class ClassificationsTreeIdsCache {
269
276
  return result;
270
277
  }
271
278
  const classificationsInfo = await this.getClassificationsInfo();
272
- await Promise.all(classificationOrTableIds.map(async (classificationOrTableId) => {
279
+ classificationOrTableIds.forEach((classificationOrTableId) => {
273
280
  const classificationInfo = classificationsInfo.get(classificationOrTableId);
274
281
  if (classificationInfo === undefined) {
275
282
  return;
276
283
  }
277
284
  result.push(...classificationInfo.childClassificationIds);
278
- }));
285
+ });
279
286
  return result;
280
287
  }
288
+ getClassificationsPathObs(classificationIds) {
289
+ return from(this.getClassificationsInfo()).pipe(mergeMap((classificationsInfo) => {
290
+ return from(classificationIds).pipe(map((classificationId) => {
291
+ const path = [{ id: classificationId, className: CLASS_NAME_Classification }];
292
+ let parentId = classificationsInfo.get(classificationId)?.parentClassificationOrTableId;
293
+ while (parentId !== undefined) {
294
+ const parentIdOfParent = classificationsInfo.get(parentId)?.parentClassificationOrTableId;
295
+ if (parentIdOfParent) {
296
+ path.push({ className: CLASS_NAME_Classification, id: parentId });
297
+ }
298
+ else {
299
+ path.push({ className: CLASS_NAME_ClassificationTable, id: parentId });
300
+ }
301
+ parentId = parentIdOfParent;
302
+ }
303
+ return path.reverse();
304
+ }));
305
+ }));
306
+ }
307
+ async getAllClassifications() {
308
+ const classificationsInfo = await this.getClassificationsInfo();
309
+ return [...classificationsInfo.keys()];
310
+ }
311
+ async *queryFilteredElementsData({ element2dIds, element3dIds }) {
312
+ const queries = new Array();
313
+ if (element2dIds.length > 0) {
314
+ queries.push(`
315
+ SELECT Model.Id modelId, Category.Id categoryId, ECInstanceId id
316
+ FROM ${CLASS_NAME_GeometricElement2d}
317
+ WHERE ECInstanceId IN (${element2dIds.join(", ")})
318
+ `);
319
+ }
320
+ if (element3dIds.length > 0) {
321
+ queries.push(`
322
+ SELECT Model.Id modelId, Category.Id categoryId, ECInstanceId id
323
+ FROM ${CLASS_NAME_GeometricElement3d}
324
+ WHERE ECInstanceId IN (${element3dIds.join(", ")})
325
+ `);
326
+ }
327
+ for await (const row of this._queryExecutor.createQueryReader({ ecsql: queries.join(" UNION ALL ") }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded" })) {
328
+ yield { modelId: row.modelId, id: row.id, categoryId: row.categoryId };
329
+ }
330
+ }
331
+ async getFilteredElementsData({ element2dIds, element3dIds, }) {
332
+ if (element2dIds.length === 0 && element3dIds.length === 0) {
333
+ return new Map();
334
+ }
335
+ this._filteredElementsData ??= (async () => {
336
+ const filteredElementsData = new Map();
337
+ for await (const { modelId, id, categoryId } of this.queryFilteredElementsData({ element2dIds, element3dIds })) {
338
+ filteredElementsData.set(id, { modelId, categoryId });
339
+ }
340
+ return filteredElementsData;
341
+ })();
342
+ return this._filteredElementsData;
343
+ }
344
+ clearFilteredElementsData() {
345
+ this._filteredElementsData = undefined;
346
+ }
281
347
  }
282
348
  //# sourceMappingURL=ClassificationsTreeIdsCache.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClassificationsTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAC/B,8BAA8B,EAC9B,0BAA0B,EAC1B,oCAAoC,EACpC,6BAA6B,EAC7B,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,+BAA+B,EAAE,MAAM,0DAA0D,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAmBtE,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IAO5B;IACA;IAPO,sBAAsB,CAAkC;IACjE,wBAAwB,CAA6G;IACrI,iCAAiC,CAA6D;IAC9F,oBAAoB,CAAyF;IAErH,YACU,cAA0C,EAC1C,gBAA2D;QAD3D,mBAAc,GAAd,cAAc,CAA4B;QAC1C,qBAAgB,GAAhB,gBAAgB,CAA2C;QAEnE,IAAI,CAAC,sBAAsB,GAAG,IAAI,+BAA+B,CAAC,cAAc,EAAE,CAAC,4BAA4B,EAAE,4BAA4B,CAAC,CAAC,CAAC;IAClJ,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAChD,CAAC;IAEO,KAAK,CAAC,CAAC,2BAA2B;QAKxC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;KAgBb,CAAC;QACF,IAAI,KAAK,EAA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,MAAM,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;QAC5D,CAAC,CAAC,CACH,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,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 } from \"@itwin/core-bentley\";\nimport {\n CLASS_NAME_Classification,\n CLASS_NAME_ClassificationSystem,\n CLASS_NAME_ClassificationTable,\n CLASS_NAME_DrawingCategory,\n CLASS_NAME_ElementHasClassifications,\n CLASS_NAME_GeometricElement2d,\n CLASS_NAME_GeometricElement3d,\n CLASS_NAME_SpatialCategory,\n} from \"../../common/internal/ClassNameDefinitions.js\";\nimport { ModelCategoryElementsCountCache } from \"../../common/internal/ModelCategoryElementsCountCache.js\";\nimport { getDistinctMapValues } from \"../../common/internal/Utils.js\";\n\nimport type { Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { CategoryId, ElementId, ModelId } from \"../../common/internal/Types.js\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { ClassificationsTreeHierarchyConfiguration } from \"../ClassificationsTreeDefinition.js\";\n/** @internal */\nexport type ClassificationId = Id64String;\n/** @internal */\nexport type ClassificationTableId = Id64String;\n\ninterface ClassificationInfo {\n childClassificationIds: ClassificationId[];\n relatedCategories2d: CategoryId[];\n relatedCategories3d: CategoryId[];\n}\n\ntype ModelCategoryKey = `${ModelId}-${CategoryId}`;\n\n/** @internal */\nexport class ClassificationsTreeIdsCache implements Disposable {\n private readonly _categoryElementCounts: ModelCategoryElementsCountCache;\n private _elementModelsCategories: Promise<Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set; isSubModel: boolean }>> | undefined;\n private _modelWithCategoryModeledElements: Promise<Map<ModelCategoryKey, Set<ElementId>>> | undefined;\n private _classificationInfos: Promise<Map<ClassificationId | ClassificationTableId, ClassificationInfo>> | undefined;\n\n constructor(\n private _queryExecutor: LimitingECSqlQueryExecutor,\n private _hierarchyConfig: ClassificationsTreeHierarchyConfiguration,\n ) {\n this._categoryElementCounts = new ModelCategoryElementsCountCache(_queryExecutor, [\"BisCore.GeometricElement2d\", \"BisCore.GeometricElement3d\"]);\n }\n\n public [Symbol.dispose]() {\n this._categoryElementCounts[Symbol.dispose]();\n }\n\n private async *queryElementModelCategories(): AsyncIterableIterator<{\n modelId: Id64String;\n categoryId: Id64String;\n type: \"2d\" | \"3d\";\n }> {\n const query = `\n SELECT * FROM (\n SELECT '3d' type, this.Model.Id modelId, this.Category.Id categoryId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement3d this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL AND m.IsPrivate = false\n GROUP BY modelId, categoryId\n )\n UNION ALL\n SELECT * FROM (\n SELECT '2d' type, this.Model.Id modelId, this.Category.Id categoryId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement2d this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL AND m.IsPrivate = false\n GROUP BY modelId, categoryId\n )\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/classifications-tree/element-models-and-categories-query\" },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId, type: row.type };\n }\n }\n\n private async getElementModelsCategories() {\n this._elementModelsCategories ??= (async () => {\n const [modelCategories, modelWithCategoryModeledElements] = await Promise.all([\n (async () => {\n const elementModelsCategories = new Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set }>();\n for await (const queriedCategory of this.queryElementModelCategories()) {\n let modelEntry = elementModelsCategories.get(queriedCategory.modelId);\n if (modelEntry === undefined) {\n modelEntry = { category2dIds: new Set(), category3dIds: new Set() };\n elementModelsCategories.set(queriedCategory.modelId, modelEntry);\n }\n switch (queriedCategory.type) {\n case \"2d\":\n modelEntry.category2dIds.add(queriedCategory.categoryId);\n break;\n case \"3d\":\n modelEntry.category3dIds.add(queriedCategory.categoryId);\n break;\n }\n }\n return elementModelsCategories;\n })(),\n this.getModelWithCategoryModeledElements(),\n ]);\n const result = new Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set; isSubModel: boolean }>();\n const subModels = getDistinctMapValues(modelWithCategoryModeledElements);\n for (const [modelId, modelEntry] of modelCategories) {\n const isSubModel = subModels.has(modelId);\n result.set(modelId, { category2dIds: modelEntry.category2dIds, category3dIds: modelEntry.category3dIds, isSubModel });\n }\n return result;\n })();\n return this._elementModelsCategories;\n }\n\n private async *queryModeledElements(): AsyncIterableIterator<{\n modelId: Id64String;\n modeledElementId: Id64String;\n categoryId: Id64String;\n rootCategoryId: Id64String;\n }> {\n const query = `\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement3d pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM BisCore.Element)\n UNION ALL\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement2d pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM BisCore.Element)\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/classifications-tree/modeled-elements-query\" },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId, modeledElementId: row.modeledElementId, rootCategoryId: row.rootCategoryId };\n }\n }\n\n private async getModelWithCategoryModeledElements() {\n this._modelWithCategoryModeledElements ??= (async () => {\n const modelWithCategoryModeledElements = new Map<ModelCategoryKey, Set<ElementId>>();\n for await (const { modelId, categoryId, modeledElementId } of this.queryModeledElements()) {\n const key: ModelCategoryKey = `${modelId}-${categoryId}`;\n const entry = modelWithCategoryModeledElements.get(key);\n if (entry === undefined) {\n modelWithCategoryModeledElements.set(key, new Set([modeledElementId]));\n } else {\n entry.add(modeledElementId);\n }\n }\n return modelWithCategoryModeledElements;\n })();\n return this._modelWithCategoryModeledElements;\n }\n\n public async getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Array): Promise<Id64Array> {\n const modelWithCategoryModeledElements = await this.getModelWithCategoryModeledElements();\n const result = new Array<ElementId>();\n for (const categoryId of categoryIds) {\n const entry = modelWithCategoryModeledElements.get(`${modelId}-${categoryId}`);\n if (entry !== undefined) {\n result.push(...entry);\n }\n }\n return result;\n }\n\n public async getCategoriesElementModels(categoryIds: Id64Array, includeSubModels?: boolean): Promise<Map<CategoryId, Array<ModelId>>> {\n const elementModelsCategories = await this.getElementModelsCategories();\n const result = new Map<CategoryId, Array<ModelId>>();\n for (const categoryId of categoryIds) {\n for (const [modelId, { category2dIds, category3dIds, isSubModel }] of elementModelsCategories) {\n if ((includeSubModels || !isSubModel) && (category2dIds.has(categoryId) || category3dIds.has(categoryId))) {\n let categoryModels = result.get(categoryId);\n if (!categoryModels) {\n categoryModels = new Array<ModelId>();\n result.set(categoryId, categoryModels);\n }\n categoryModels.push(modelId);\n }\n }\n }\n return result;\n }\n\n public async getModelCategoryIds(modelId: Id64String): Promise<{ drawing: Id64Array; spatial: Id64Array }> {\n const elementModelsCategories = await this.getElementModelsCategories();\n return {\n drawing: Array.from(elementModelsCategories.get(modelId)?.category2dIds ?? []),\n spatial: Array.from(elementModelsCategories.get(modelId)?.category3dIds ?? []),\n };\n }\n\n public async hasSubModel(elementId: Id64String): Promise<boolean> {\n const elementModelsCategories = await this.getElementModelsCategories();\n return elementModelsCategories.has(elementId);\n }\n\n public async getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Promise<number> {\n return this._categoryElementCounts.getCategoryElementsCount(modelId, categoryId);\n }\n\n private async *queryClassifications(): AsyncIterableIterator<{\n id: Id64String;\n tableId?: ClassificationTableId;\n parentId?: ClassificationId;\n relatedCategories2d: CategoryId[];\n relatedCategories3d: CategoryId[];\n }> {\n const CLASSIFICATIONS_CTE = \"Classifications\";\n const ctes = [\n `\n ${CLASSIFICATIONS_CTE}(ClassificationId, ClassificationTableId, ParentClassificationId) AS (\n SELECT\n cl.ECInstanceId,\n ct.ECInstanceId,\n NULL\n FROM ${CLASS_NAME_Classification} cl\n JOIN ${CLASS_NAME_ClassificationTable} ct ON ct.ECInstanceId = cl.Model.Id\n JOIN ${CLASS_NAME_ClassificationSystem} cs ON cs.ECInstanceId = ct.Parent.Id\n WHERE\n cs.CodeValue = '${this._hierarchyConfig.rootClassificationSystemCode}'\n AND NOT ct.IsPrivate\n AND NOT cl.IsPrivate\n AND cl.Parent.Id IS NULL\n\n UNION ALL\n\n SELECT\n cl.ECInstanceId,\n NULL,\n cl.Parent.Id\n FROM\n ${CLASSIFICATIONS_CTE} cte\n JOIN ${CLASS_NAME_Classification} cl ON cl.Parent.Id = cte.ClassificationId\n WHERE\n NOT cl.IsPrivate\n )\n `,\n ];\n const ecsql = `\n SELECT\n cl.ClassificationId id,\n cl.ClassificationTableId tableId,\n cl.ParentClassificationId parentId,\n (\n SELECT group_concat(IdToHex(cat.ECInstanceId))\n FROM ${CLASS_NAME_GeometricElement2d} e\n JOIN ${CLASS_NAME_DrawingCategory} cat ON cat.ECInstanceId = e.Category.Id\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId\n WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId\n GROUP BY ehc.TargetECInstanceId\n ) relatedCategories2d,\n (\n SELECT group_concat(IdToHex(cat.ECInstanceId))\n FROM ${CLASS_NAME_GeometricElement3d} e\n JOIN ${CLASS_NAME_SpatialCategory} cat ON cat.ECInstanceId = e.Category.Id\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId\n WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId\n GROUP BY ehc.TargetECInstanceId\n ) relatedCategories3d\n FROM ${CLASSIFICATIONS_CTE} cl\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ctes, ecsql },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/classifications-tree/classifications-query\" },\n )) {\n yield {\n id: row.id,\n tableId: row.tableId,\n parentId: row.parentId,\n relatedCategories2d: row.relatedCategories2d ? (row.relatedCategories2d as string).split(\",\") : [],\n relatedCategories3d: row.relatedCategories3d ? (row.relatedCategories3d as string).split(\",\") : [],\n };\n }\n }\n\n private async getClassificationsInfo() {\n this._classificationInfos ??= (async () => {\n const classificationInfos = new Map<ClassificationId | ClassificationTableId, ClassificationInfo>();\n for await (const { id, tableId, parentId, relatedCategories2d, relatedCategories3d } of this.queryClassifications()) {\n const tableOrParentId = tableId ?? parentId;\n assert(!!tableOrParentId);\n let parentInfo = classificationInfos.get(tableOrParentId);\n if (!parentInfo) {\n parentInfo = { childClassificationIds: [], relatedCategories2d: [], relatedCategories3d: [] };\n classificationInfos.set(tableOrParentId, parentInfo);\n }\n parentInfo.childClassificationIds.push(id);\n\n classificationInfos.set(id, { childClassificationIds: [], relatedCategories2d, relatedCategories3d });\n }\n return classificationInfos;\n })();\n return this._classificationInfos;\n }\n\n public async getAllContainedCategories(classificationOrTableIds: Id64Array): Promise<{ drawing: Id64Array; spatial: Id64Array }> {\n const result = { drawing: new Array<CategoryId>(), spatial: new Array<CategoryId>() };\n if (classificationOrTableIds.length === 0) {\n return result;\n }\n const classificationsInfo = await this.getClassificationsInfo();\n await Promise.all(\n classificationOrTableIds.map(async (classificationOrTableId) => {\n const classificationInfo = classificationsInfo.get(classificationOrTableId);\n if (classificationInfo === undefined) {\n return;\n }\n const childClassificationsResult = await this.getAllContainedCategories(classificationInfo.childClassificationIds);\n result.drawing.push(...classificationInfo.relatedCategories2d, ...childClassificationsResult.drawing);\n result.spatial.push(...classificationInfo.relatedCategories3d, ...childClassificationsResult.spatial);\n }),\n );\n return result;\n }\n\n public async getDirectChildClassifications(classificationOrTableIds: Id64Array): Promise<ClassificationId[]> {\n const result = new Array<ClassificationId>();\n if (classificationOrTableIds.length === 0) {\n return result;\n }\n const classificationsInfo = await this.getClassificationsInfo();\n await Promise.all(\n classificationOrTableIds.map(async (classificationOrTableId) => {\n const classificationInfo = classificationsInfo.get(classificationOrTableId);\n if (classificationInfo === undefined) {\n return;\n }\n result.push(...classificationInfo.childClassificationIds);\n }),\n );\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"ClassificationsTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAC/B,8BAA8B,EAC9B,0BAA0B,EAC1B,oCAAoC,EACpC,6BAA6B,EAC7B,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,+BAA+B,EAAE,MAAM,0DAA0D,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAsBtE,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IAQ5B;IACA;IARO,sBAAsB,CAAkC;IACjE,wBAAwB,CAA6G;IACrI,iCAAiC,CAA6D;IAC9F,oBAAoB,CAAyF;IAC7G,qBAAqB,CAAuF;IAEpH,YACU,cAA0C,EAC1C,gBAA2D;QAD3D,mBAAc,GAAd,cAAc,CAA4B;QA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I,CAAC,aAAa,CAAC,EAAE,EACtC,EAAE,SAAS,EAAE,oBAAoB,EAAE,KAAK,EAAE,WAAW,EAAE,CACxD,EAAE,CAAC;YACF,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC;QACzE,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,uBAAuB,CAAC,EACnC,YAAY,EACZ,YAAY,GAIb;QACC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3D,OAAO,IAAI,GAAG,EAAE,CAAC;QACnB,CAAC;QAED,IAAI,CAAC,qBAAqB,KAAK,CAAC,KAAK,IAAI,EAAE;YACzC,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAE,CAAC;YACvC,IAAI,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,IAAI,CAAC,yBAAyB,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;gBAC/G,oBAAoB,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;YACxD,CAAC;YACD,OAAO,oBAAoB,CAAC;QAC9B,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACpC,CAAC;IAEM,yBAAyB;QAC9B,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACzC,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 { from, map, mergeMap } from \"rxjs\";\nimport {\n CLASS_NAME_Classification,\n CLASS_NAME_ClassificationSystem,\n CLASS_NAME_ClassificationTable,\n CLASS_NAME_DrawingCategory,\n CLASS_NAME_ElementHasClassifications,\n CLASS_NAME_GeometricElement2d,\n CLASS_NAME_GeometricElement3d,\n CLASS_NAME_SpatialCategory,\n} from \"../../common/internal/ClassNameDefinitions.js\";\nimport { ModelCategoryElementsCountCache } from \"../../common/internal/ModelCategoryElementsCountCache.js\";\nimport { getDistinctMapValues } from \"../../common/internal/Utils.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { CategoryId, ElementId, ModelId } from \"../../common/internal/Types.js\";\nimport type { HierarchyNodeIdentifiersPath, LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { ClassificationsTreeHierarchyConfiguration } from \"../ClassificationsTreeDefinition.js\";\n\n/** @internal */\nexport type ClassificationId = Id64String;\n/** @internal */\nexport type ClassificationTableId = Id64String;\n\ninterface ClassificationInfo {\n parentClassificationOrTableId: ClassificationId | ClassificationTableId | undefined;\n childClassificationIds: ClassificationId[];\n relatedCategories2d: CategoryId[];\n relatedCategories3d: CategoryId[];\n}\n\ntype ModelCategoryKey = `${ModelId}-${CategoryId}`;\n\n/** @internal */\nexport class ClassificationsTreeIdsCache implements Disposable {\n private readonly _categoryElementCounts: ModelCategoryElementsCountCache;\n private _elementModelsCategories: Promise<Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set; isSubModel: boolean }>> | undefined;\n private _modelWithCategoryModeledElements: Promise<Map<ModelCategoryKey, Set<ElementId>>> | undefined;\n private _classificationInfos: Promise<Map<ClassificationId | ClassificationTableId, ClassificationInfo>> | undefined;\n private _filteredElementsData: Promise<Map<ElementId, { modelId: Id64String; categoryId: Id64String }>> | undefined;\n\n constructor(\n private _queryExecutor: LimitingECSqlQueryExecutor,\n private _hierarchyConfig: ClassificationsTreeHierarchyConfiguration,\n ) {\n this._categoryElementCounts = new ModelCategoryElementsCountCache(_queryExecutor, [\"BisCore.GeometricElement2d\", \"BisCore.GeometricElement3d\"]);\n }\n\n public [Symbol.dispose]() {\n this._categoryElementCounts[Symbol.dispose]();\n }\n\n private async *queryElementModelCategories(): AsyncIterableIterator<{\n modelId: Id64String;\n categoryId: Id64String;\n type: \"2d\" | \"3d\";\n }> {\n const query = `\n SELECT * FROM (\n SELECT '3d' type, this.Model.Id modelId, this.Category.Id categoryId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement3d this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL AND m.IsPrivate = false\n GROUP BY modelId, categoryId\n )\n UNION ALL\n SELECT * FROM (\n SELECT '2d' type, this.Model.Id modelId, this.Category.Id categoryId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement2d this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL AND m.IsPrivate = false\n GROUP BY modelId, categoryId\n )\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/classifications-tree/element-models-and-categories-query\" },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId, type: row.type };\n }\n }\n\n private async getElementModelsCategories() {\n this._elementModelsCategories ??= (async () => {\n const [modelCategories, modelWithCategoryModeledElements] = await Promise.all([\n (async () => {\n const elementModelsCategories = new Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set }>();\n for await (const queriedCategory of this.queryElementModelCategories()) {\n let modelEntry = elementModelsCategories.get(queriedCategory.modelId);\n if (modelEntry === undefined) {\n modelEntry = { category2dIds: new Set(), category3dIds: new Set() };\n elementModelsCategories.set(queriedCategory.modelId, modelEntry);\n }\n switch (queriedCategory.type) {\n case \"2d\":\n modelEntry.category2dIds.add(queriedCategory.categoryId);\n break;\n case \"3d\":\n modelEntry.category3dIds.add(queriedCategory.categoryId);\n break;\n }\n }\n return elementModelsCategories;\n })(),\n this.getModelWithCategoryModeledElements(),\n ]);\n const result = new Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set; isSubModel: boolean }>();\n const subModels = getDistinctMapValues(modelWithCategoryModeledElements);\n for (const [modelId, modelEntry] of modelCategories) {\n const isSubModel = subModels.has(modelId);\n result.set(modelId, { category2dIds: modelEntry.category2dIds, category3dIds: modelEntry.category3dIds, isSubModel });\n }\n return result;\n })();\n return this._elementModelsCategories;\n }\n\n private async *queryModeledElements(): AsyncIterableIterator<{\n modelId: Id64String;\n modeledElementId: Id64String;\n categoryId: Id64String;\n rootCategoryId: Id64String;\n }> {\n const query = `\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement3d pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM BisCore.Element)\n UNION ALL\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement2d pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM BisCore.Element)\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/classifications-tree/modeled-elements-query\" },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId, modeledElementId: row.modeledElementId, rootCategoryId: row.rootCategoryId };\n }\n }\n\n private async getModelWithCategoryModeledElements() {\n this._modelWithCategoryModeledElements ??= (async () => {\n const modelWithCategoryModeledElements = new Map<ModelCategoryKey, Set<ElementId>>();\n for await (const { modelId, categoryId, modeledElementId } of this.queryModeledElements()) {\n const key: ModelCategoryKey = `${modelId}-${categoryId}`;\n const entry = modelWithCategoryModeledElements.get(key);\n if (entry === undefined) {\n modelWithCategoryModeledElements.set(key, new Set([modeledElementId]));\n } else {\n entry.add(modeledElementId);\n }\n }\n return modelWithCategoryModeledElements;\n })();\n return this._modelWithCategoryModeledElements;\n }\n\n public async getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Array): Promise<Id64Array> {\n const modelWithCategoryModeledElements = await this.getModelWithCategoryModeledElements();\n const result = new Array<ElementId>();\n for (const categoryId of categoryIds) {\n const entry = modelWithCategoryModeledElements.get(`${modelId}-${categoryId}`);\n if (entry !== undefined) {\n result.push(...entry);\n }\n }\n return result;\n }\n\n public async getCategoriesElementModels(categoryIds: Id64Array, includeSubModels?: boolean): Promise<Map<CategoryId, Set<ModelId>>> {\n const elementModelsCategories = await this.getElementModelsCategories();\n const result = new Map<CategoryId, Set<ModelId>>();\n for (const categoryId of categoryIds) {\n for (const [modelId, { category2dIds, category3dIds, isSubModel }] of elementModelsCategories) {\n if ((includeSubModels || !isSubModel) && (category2dIds.has(categoryId) || category3dIds.has(categoryId))) {\n let categoryModels = result.get(categoryId);\n if (!categoryModels) {\n categoryModels = new Set<ModelId>();\n result.set(categoryId, categoryModels);\n }\n categoryModels.add(modelId);\n }\n }\n }\n return result;\n }\n\n public async getModelCategoryIds(modelId: Id64String): Promise<{ drawing: Id64Array; spatial: Id64Array }> {\n const elementModelsCategories = await this.getElementModelsCategories();\n return {\n drawing: Array.from(elementModelsCategories.get(modelId)?.category2dIds ?? []),\n spatial: Array.from(elementModelsCategories.get(modelId)?.category3dIds ?? []),\n };\n }\n\n public async hasSubModel(elementId: Id64String): Promise<boolean> {\n const elementModelsCategories = await this.getElementModelsCategories();\n return elementModelsCategories.has(elementId);\n }\n\n public async getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Promise<number> {\n return this._categoryElementCounts.getCategoryElementsCount(modelId, categoryId);\n }\n\n private async *queryClassifications(): AsyncIterableIterator<\n {\n id: Id64String;\n relatedCategories2d: CategoryId[];\n relatedCategories3d: CategoryId[];\n } & ({ tableId: ClassificationTableId; parentId: undefined } | { tableId: undefined; parentId: ClassificationId })\n > {\n const CLASSIFICATIONS_CTE = \"Classifications\";\n const ctes = [\n `\n ${CLASSIFICATIONS_CTE}(ClassificationId, ClassificationTableId, ParentClassificationId) AS (\n SELECT\n cl.ECInstanceId,\n ct.ECInstanceId,\n NULL\n FROM ${CLASS_NAME_Classification} cl\n JOIN ${CLASS_NAME_ClassificationTable} ct ON ct.ECInstanceId = cl.Model.Id\n JOIN ${CLASS_NAME_ClassificationSystem} cs ON cs.ECInstanceId = ct.Parent.Id\n WHERE\n cs.CodeValue = '${this._hierarchyConfig.rootClassificationSystemCode}'\n AND NOT ct.IsPrivate\n AND NOT cl.IsPrivate\n AND cl.Parent.Id IS NULL\n\n UNION ALL\n\n SELECT\n cl.ECInstanceId,\n NULL,\n cl.Parent.Id\n FROM\n ${CLASSIFICATIONS_CTE} cte\n JOIN ${CLASS_NAME_Classification} cl ON cl.Parent.Id = cte.ClassificationId\n WHERE\n NOT cl.IsPrivate\n )\n `,\n ];\n const ecsql = `\n SELECT\n cl.ClassificationId id,\n cl.ClassificationTableId tableId,\n cl.ParentClassificationId parentId,\n (\n SELECT group_concat(IdToHex(cat.ECInstanceId))\n FROM ${CLASS_NAME_GeometricElement2d} e\n JOIN ${CLASS_NAME_DrawingCategory} cat ON cat.ECInstanceId = e.Category.Id\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId\n WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId\n GROUP BY ehc.TargetECInstanceId\n ) relatedCategories2d,\n (\n SELECT group_concat(IdToHex(cat.ECInstanceId))\n FROM ${CLASS_NAME_GeometricElement3d} e\n JOIN ${CLASS_NAME_SpatialCategory} cat ON cat.ECInstanceId = e.Category.Id\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId\n WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId\n GROUP BY ehc.TargetECInstanceId\n ) relatedCategories3d\n FROM ${CLASSIFICATIONS_CTE} cl\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ctes, ecsql },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/classifications-tree/classifications-query\" },\n )) {\n yield {\n id: row.id,\n tableId: row.tableId,\n parentId: row.parentId,\n relatedCategories2d: row.relatedCategories2d ? (row.relatedCategories2d as string).split(\",\") : [],\n relatedCategories3d: row.relatedCategories3d ? (row.relatedCategories3d as string).split(\",\") : [],\n };\n }\n }\n\n private async getClassificationsInfo() {\n this._classificationInfos ??= (async () => {\n const classificationInfos = new Map<ClassificationId | ClassificationTableId, ClassificationInfo>();\n for await (const { id, tableId, parentId, relatedCategories2d, relatedCategories3d } of this.queryClassifications()) {\n const tableOrParentId = tableId ?? parentId;\n let parentInfo = classificationInfos.get(tableOrParentId);\n if (!parentInfo) {\n parentInfo = { childClassificationIds: [], relatedCategories2d: [], relatedCategories3d: [], parentClassificationOrTableId: undefined };\n classificationInfos.set(tableOrParentId, parentInfo);\n }\n parentInfo.childClassificationIds.push(id);\n let classificationEntry = classificationInfos.get(id);\n if (!classificationEntry) {\n classificationEntry = { childClassificationIds: [], relatedCategories2d, relatedCategories3d, parentClassificationOrTableId: tableOrParentId };\n classificationInfos.set(id, classificationEntry);\n } else {\n classificationEntry.parentClassificationOrTableId = tableOrParentId;\n }\n }\n return classificationInfos;\n })();\n return this._classificationInfos;\n }\n\n public async getAllContainedCategories(classificationOrTableIds: Id64Array): Promise<{ drawing: Id64Array; spatial: Id64Array }> {\n const result = { drawing: new Array<CategoryId>(), spatial: new Array<CategoryId>() };\n if (classificationOrTableIds.length === 0) {\n return result;\n }\n const classificationsInfo = await this.getClassificationsInfo();\n await Promise.all(\n classificationOrTableIds.map(async (classificationOrTableId) => {\n const classificationInfo = classificationsInfo.get(classificationOrTableId);\n if (classificationInfo === undefined) {\n return;\n }\n const childClassificationsResult = await this.getAllContainedCategories(classificationInfo.childClassificationIds);\n result.drawing.push(...classificationInfo.relatedCategories2d, ...childClassificationsResult.drawing);\n result.spatial.push(...classificationInfo.relatedCategories3d, ...childClassificationsResult.spatial);\n }),\n );\n return result;\n }\n\n public async getDirectChildClassifications(classificationOrTableIds: Id64Array): Promise<ClassificationId[]> {\n const result = new Array<ClassificationId>();\n if (classificationOrTableIds.length === 0) {\n return result;\n }\n const classificationsInfo = await this.getClassificationsInfo();\n classificationOrTableIds.forEach((classificationOrTableId) => {\n const classificationInfo = classificationsInfo.get(classificationOrTableId);\n if (classificationInfo === undefined) {\n return;\n }\n result.push(...classificationInfo.childClassificationIds);\n });\n return result;\n }\n\n public getClassificationsPathObs(classificationIds: Id64Array): Observable<HierarchyNodeIdentifiersPath> {\n return from(this.getClassificationsInfo()).pipe(\n mergeMap((classificationsInfo) => {\n return from(classificationIds).pipe(\n map((classificationId) => {\n const path: HierarchyNodeIdentifiersPath = [{ id: classificationId, className: CLASS_NAME_Classification }];\n let parentId = classificationsInfo.get(classificationId)?.parentClassificationOrTableId;\n while (parentId !== undefined) {\n const parentIdOfParent = classificationsInfo.get(parentId)?.parentClassificationOrTableId;\n if (parentIdOfParent) {\n path.push({ className: CLASS_NAME_Classification, id: parentId });\n } else {\n path.push({ className: CLASS_NAME_ClassificationTable, id: parentId });\n }\n parentId = parentIdOfParent;\n }\n return path.reverse();\n }),\n );\n }),\n );\n }\n\n public async getAllClassifications(): Promise<ClassificationId[]> {\n const classificationsInfo = await this.getClassificationsInfo();\n return [...classificationsInfo.keys()];\n }\n\n private async *queryFilteredElementsData({ element2dIds, element3dIds }: { element2dIds: Id64Array; element3dIds: Id64Array }): AsyncIterableIterator<{\n modelId: Id64String;\n id: ElementId;\n categoryId: Id64String;\n }> {\n const queries = new Array<string>();\n if (element2dIds.length > 0) {\n queries.push(`\n SELECT Model.Id modelId, Category.Id categoryId, ECInstanceId id\n FROM ${CLASS_NAME_GeometricElement2d}\n WHERE ECInstanceId IN (${element2dIds.join(\", \")})\n `);\n }\n if (element3dIds.length > 0) {\n queries.push(`\n SELECT Model.Id modelId, Category.Id categoryId, ECInstanceId id\n FROM ${CLASS_NAME_GeometricElement3d}\n WHERE ECInstanceId IN (${element3dIds.join(\", \")})\n `);\n }\n for await (const row of this._queryExecutor.createQueryReader(\n { ecsql: queries.join(\" UNION ALL \") },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" },\n )) {\n yield { modelId: row.modelId, id: row.id, categoryId: row.categoryId };\n }\n }\n\n public async getFilteredElementsData({\n element2dIds,\n element3dIds,\n }: {\n element2dIds: Id64Array;\n element3dIds: Id64Array;\n }): Promise<Map<ElementId, { categoryId: Id64String; modelId: Id64String }>> {\n if (element2dIds.length === 0 && element3dIds.length === 0) {\n return new Map();\n }\n\n this._filteredElementsData ??= (async () => {\n const filteredElementsData = new Map();\n for await (const { modelId, id, categoryId } of this.queryFilteredElementsData({ element2dIds, element3dIds })) {\n filteredElementsData.set(id, { modelId, categoryId });\n }\n return filteredElementsData;\n })();\n return this._filteredElementsData;\n }\n\n public clearFilteredElementsData() {\n this._filteredElementsData = undefined;\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Id64String } from "@itwin/core-bentley";
1
+ import type { Id64Array, Id64String } from "@itwin/core-bentley";
2
2
  import type { HierarchyNodeKey } from "@itwin/presentation-hierarchies";
3
3
  interface ClassificationsTreeNode {
4
4
  key: HierarchyNodeKey;
@@ -11,7 +11,7 @@ export declare namespace ClassificationsTreeNode {
11
11
  const isClassificationTableNode: (node: Pick<ClassificationsTreeNode, "extendedData">) => boolean;
12
12
  const isClassificationNode: (node: Pick<ClassificationsTreeNode, "extendedData">) => boolean;
13
13
  const isGeometricElementNode: (node: Pick<ClassificationsTreeNode, "extendedData">) => boolean;
14
- const getClassificationIds: (node: Pick<ClassificationsTreeNode, "extendedData">) => Id64String[];
14
+ const getClassificationIds: (node: Pick<ClassificationsTreeNode, "extendedData">) => Id64Array;
15
15
  const getModelId: (node: Pick<ClassificationsTreeNode, "extendedData">) => Id64String;
16
16
  const getCategoryId: (node: Pick<ClassificationsTreeNode, "extendedData">) => Id64String;
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ClassificationsTreeNode.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AASxE,gBAAgB;AAChB,MAAM,KAAW,uBAAuB,CA0BvC;AA1BD,WAAiB,uBAAuB;IACzB,iDAAyB,GAAG,CAAC,IAAmD,EAAE,EAAE,CAC/F,WAAW,CAAC,IAAI,CAAC,KAAK,qBAAqB,CAAC;IAEjC,4CAAoB,GAAG,CAAC,IAAmD,EAAE,EAAE,CAC1F,WAAW,CAAC,IAAI,CAAC,KAAK,gBAAgB,CAAC;IAE5B,8CAAsB,GAAG,CAAC,IAAmD,EAAE,EAAE;QAC5F,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,KAAK,oBAAoB,IAAI,IAAI,KAAK,oBAAoB,CAAC;IACxE,CAAC,CAAA;IAEY,4CAAoB,GAAG,CAAC,IAAmD,EAAgB,EAAE;QACxG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,mBAAmB,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QACxE,OAAO,sBAAsB,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IACrE,CAAC,CAAA;IAEY,kCAAU,GAAG,CAAC,IAAmD,EAAc,EAAE;QAC5F,MAAM,CAAC,OAAO,IAAI,CAAC,YAAY,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;IACnC,CAAC,CAAA;IAEY,qCAAa,GAAG,CAAC,IAAmD,EAAc,EAAE;QAC/F,MAAM,CAAC,OAAO,IAAI,CAAC,YAAY,EAAE,UAAU,KAAK,QAAQ,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;IACtC,CAAC,CAAA;AACH,CAAC,EA1BgB,uBAAuB,KAAvB,uBAAuB,QA0BvC;AAED,SAAS,WAAW,CAAC,IAAmD;IACtE,OAAO,IAAI,CAAC,YAAY,IAAI,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/F,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 type { Id64String } from \"@itwin/core-bentley\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { parseIdsSelectorResult } from \"../../common/internal/Utils.js\";\n\nimport type { HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\n\ninterface ClassificationsTreeNode {\n key: HierarchyNodeKey;\n extendedData?: { [id: string]: any };\n}\n\n/** @internal */\nexport namespace ClassificationsTreeNode {\n export const isClassificationTableNode = (node: Pick<ClassificationsTreeNode, \"extendedData\">) =>\n getNodeType(node) === \"ClassificationTable\";\n\n export const isClassificationNode = (node: Pick<ClassificationsTreeNode, \"extendedData\">) =>\n getNodeType(node) === \"Classification\";\n\n export const isGeometricElementNode = (node: Pick<ClassificationsTreeNode, \"extendedData\">) => {\n const type = getNodeType(node);\n return type === \"GeometricElement3d\" || type === \"GeometricElement2d\";\n }\n\n export const getClassificationIds = (node: Pick<ClassificationsTreeNode, \"extendedData\">): Id64String[] => {\n assert(!!node.extendedData && \"classificationIds\" in node.extendedData);\n return parseIdsSelectorResult(node.extendedData.classificationIds);\n }\n\n export const getModelId = (node: Pick<ClassificationsTreeNode, \"extendedData\">): Id64String => {\n assert(typeof node.extendedData?.modelId === \"string\");\n return node.extendedData.modelId;\n }\n\n export const getCategoryId = (node: Pick<ClassificationsTreeNode, \"extendedData\">): Id64String => {\n assert(typeof node.extendedData?.categoryId === \"string\");\n return node.extendedData.categoryId;\n }\n}\n\nfunction getNodeType(node: Pick<ClassificationsTreeNode, \"extendedData\">) {\n return node.extendedData && \"type\" in node.extendedData ? node.extendedData.type : undefined;\n}\n"]}
1
+ {"version":3,"file":"ClassificationsTreeNode.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AASxE,gBAAgB;AAChB,MAAM,KAAW,uBAAuB,CAwBvC;AAxBD,WAAiB,uBAAuB;IACzB,iDAAyB,GAAG,CAAC,IAAmD,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,qBAAqB,CAAC;IAEjI,4CAAoB,GAAG,CAAC,IAAmD,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,gBAAgB,CAAC;IAEvH,8CAAsB,GAAG,CAAC,IAAmD,EAAE,EAAE;QAC5F,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,KAAK,oBAAoB,IAAI,IAAI,KAAK,oBAAoB,CAAC;IACxE,CAAC,CAAC;IAEW,4CAAoB,GAAG,CAAC,IAAmD,EAAa,EAAE;QACrG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,mBAAmB,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QACxE,OAAO,sBAAsB,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IACrE,CAAC,CAAC;IAEW,kCAAU,GAAG,CAAC,IAAmD,EAAc,EAAE;QAC5F,MAAM,CAAC,OAAO,IAAI,CAAC,YAAY,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;IACnC,CAAC,CAAC;IAEW,qCAAa,GAAG,CAAC,IAAmD,EAAc,EAAE;QAC/F,MAAM,CAAC,OAAO,IAAI,CAAC,YAAY,EAAE,UAAU,KAAK,QAAQ,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC,EAxBgB,uBAAuB,KAAvB,uBAAuB,QAwBvC;AAED,SAAS,WAAW,CAAC,IAAmD;IACtE,OAAO,IAAI,CAAC,YAAY,IAAI,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/F,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 type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { parseIdsSelectorResult } from \"../../common/internal/Utils.js\";\n\nimport type { HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\n\ninterface ClassificationsTreeNode {\n key: HierarchyNodeKey;\n extendedData?: { [id: string]: any };\n}\n\n/** @internal */\nexport namespace ClassificationsTreeNode {\n export const isClassificationTableNode = (node: Pick<ClassificationsTreeNode, \"extendedData\">) => getNodeType(node) === \"ClassificationTable\";\n\n export const isClassificationNode = (node: Pick<ClassificationsTreeNode, \"extendedData\">) => getNodeType(node) === \"Classification\";\n\n export const isGeometricElementNode = (node: Pick<ClassificationsTreeNode, \"extendedData\">) => {\n const type = getNodeType(node);\n return type === \"GeometricElement3d\" || type === \"GeometricElement2d\";\n };\n\n export const getClassificationIds = (node: Pick<ClassificationsTreeNode, \"extendedData\">): Id64Array => {\n assert(!!node.extendedData && \"classificationIds\" in node.extendedData);\n return parseIdsSelectorResult(node.extendedData.classificationIds);\n };\n\n export const getModelId = (node: Pick<ClassificationsTreeNode, \"extendedData\">): Id64String => {\n assert(typeof node.extendedData?.modelId === \"string\");\n return node.extendedData.modelId;\n };\n\n export const getCategoryId = (node: Pick<ClassificationsTreeNode, \"extendedData\">): Id64String => {\n assert(typeof node.extendedData?.categoryId === \"string\");\n return node.extendedData.categoryId;\n };\n}\n\nfunction getNodeType(node: Pick<ClassificationsTreeNode, \"extendedData\">) {\n return node.extendedData && \"type\" in node.extendedData ? node.extendedData.type : undefined;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { HierarchyFilteringPath } from "@itwin/presentation-hierarchies";
1
2
  import type { Viewport } from "@itwin/core-frontend";
2
3
  import type { HierarchyVisibilityHandler } from "../../common/UseHierarchyVisibility.js";
3
4
  import type { ECClassHierarchyInspector } from "@itwin/presentation-shared";
@@ -10,6 +11,7 @@ export interface ClassificationsTreeVisibilityHandlerProps {
10
11
  viewport: Viewport;
11
12
  idsCache: ClassificationsTreeIdsCache;
12
13
  imodelAccess: ECClassHierarchyInspector;
14
+ filteredPaths?: HierarchyFilteringPath[];
13
15
  }
14
16
  /**
15
17
  * Creates an instance if `ClassificationsTreeVisibilityHandler`.
@@ -9,11 +9,12 @@ import { HierarchyNode, HierarchyNodeKey } from "@itwin/presentation-hierarchies
9
9
  import { AlwaysAndNeverDrawnElementInfo } from "../../common/internal/AlwaysAndNeverDrawnElementInfo.js";
10
10
  import { toVoidPromise } from "../../common/internal/Rxjs.js";
11
11
  import { createVisibilityStatus } from "../../common/internal/Tooltip.js";
12
- import { setDifference, setIntersection } from "../../common/internal/Utils.js";
12
+ import { getDistinctMapValues, releaseMainThreadOnItemsCount, setDifference, setIntersection } from "../../common/internal/Utils.js";
13
13
  import { createVisibilityChangeEventListener } from "../../common/internal/VisibilityChangeEventListener.js";
14
14
  import { changeElementStateNoChildrenOperator, enableCategoryDisplay, getElementOverriddenVisibility, getElementVisibility, getSubModeledElementsVisibilityStatus, getVisibilityFromAlwaysAndNeverDrawnElementsImpl, mergeVisibilityStatuses, } from "../../common/internal/VisibilityUtils.js";
15
15
  import { createVisibilityHandlerResult } from "../../common/UseHierarchyVisibility.js";
16
16
  import { ClassificationsTreeNode } from "./ClassificationsTreeNode.js";
17
+ import { createFilteredTree } from "./FilteredTree.js";
17
18
  /**
18
19
  * Creates an instance if `ClassificationsTreeVisibilityHandler`.
19
20
  * @internal
@@ -26,6 +27,7 @@ class ClassificationsTreeVisibilityHandlerImpl {
26
27
  _eventListener;
27
28
  _alwaysAndNeverDrawnElements;
28
29
  _idsCache;
30
+ _filteredTree;
29
31
  _elementChangeQueue = new Subject();
30
32
  _subscriptions = [];
31
33
  _changeRequest = new Subject();
@@ -41,6 +43,13 @@ class ClassificationsTreeVisibilityHandlerImpl {
41
43
  });
42
44
  this._alwaysAndNeverDrawnElements = new AlwaysAndNeverDrawnElementInfo(_props.viewport);
43
45
  this._idsCache = this._props.idsCache;
46
+ if (_props.filteredPaths) {
47
+ this._filteredTree = createFilteredTree({
48
+ idsCache: this._idsCache,
49
+ filteringPaths: _props.filteredPaths,
50
+ imodelAccess: this._props.imodelAccess,
51
+ });
52
+ }
44
53
  this._subscriptions.push(this._elementChangeQueue.pipe(concatAll()).subscribe());
45
54
  }
46
55
  [Symbol.dispose]() {
@@ -80,6 +89,9 @@ class ClassificationsTreeVisibilityHandlerImpl {
80
89
  return toVoidPromise(changeObservable);
81
90
  }
82
91
  getVisibilityStatusObs(node) {
92
+ if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {
93
+ return this.getFilteredNodeVisibility({ node });
94
+ }
83
95
  if (!HierarchyNode.isInstancesNode(node)) {
84
96
  return EMPTY;
85
97
  }
@@ -103,6 +115,32 @@ class ClassificationsTreeVisibilityHandlerImpl {
103
115
  elementType: node.extendedData?.type,
104
116
  });
105
117
  }
118
+ getFilteredNodeVisibility(props) {
119
+ return from(this.getVisibilityChangeTargets(props)).pipe(mergeMap(({ classificationIds, classificationTableIds, elements2d, elements3d }) => {
120
+ const observables = new Array();
121
+ if (classificationTableIds?.size) {
122
+ observables.push(this.getClassificationTableDisplayStatus({ classificationTableIds: [...classificationTableIds] }));
123
+ }
124
+ if (classificationIds?.size) {
125
+ observables.push(this.getClassificationDisplayStatus({ classificationIds: [...classificationIds] }));
126
+ }
127
+ if (elements2d?.length) {
128
+ observables.push(from(elements2d).pipe(releaseMainThreadOnItemsCount(50), mergeMap(({ modelId, categoryId, elementIds }) => {
129
+ return from(elementIds).pipe(releaseMainThreadOnItemsCount(1000), mergeMap((elementId) => this.getGeometricElementDisplayStatus({ modelId, categoryId, elementId, elementType: "2d" })));
130
+ })));
131
+ }
132
+ if (elements3d?.length) {
133
+ observables.push(from(elements3d).pipe(releaseMainThreadOnItemsCount(50), mergeMap(({ modelId, categoryId, elementIds }) => {
134
+ return from(elementIds).pipe(releaseMainThreadOnItemsCount(1000), mergeMap((elementId) => this.getGeometricElementDisplayStatus({ modelId, categoryId, elementId, elementType: "3d" })));
135
+ })));
136
+ }
137
+ return merge(...observables);
138
+ }), mergeVisibilityStatuses);
139
+ }
140
+ async getVisibilityChangeTargets({ node }) {
141
+ const filteredTree = await this._filteredTree;
142
+ return filteredTree ? filteredTree.getVisibilityChangeTargets(node) : {};
143
+ }
106
144
  getClassificationTableDisplayStatus(props) {
107
145
  const result = defer(() => {
108
146
  return from(this._idsCache.getAllContainedCategories(props.classificationTableIds)).pipe(mergeMap(({ drawing, spatial }) => merge(of(drawing).pipe(mergeMap((categoryIds) => this.getCategoryDisplayStatus({ categoryIds, type: "DrawingCategory" }))), of(spatial).pipe(mergeMap((categoryIds) => this.getCategoryDisplayStatus({ categoryIds, type: "SpatialCategory" }))))), mergeVisibilityStatuses);
@@ -163,7 +201,7 @@ class ClassificationsTreeVisibilityHandlerImpl {
163
201
  getDefaultCategoryVisibilityStatus({ categoryIds }) {
164
202
  const result = from(categoryIds).pipe(mergeMap(async (categoryId) => {
165
203
  let visibility = "unknown";
166
- const categoryModels = [...(await this._idsCache.getCategoriesElementModels([categoryId], true)).values()].flat();
204
+ const categoryModels = getDistinctMapValues(await this._idsCache.getCategoriesElementModels([categoryId], true));
167
205
  let nonDefaultModelDisplayStatesCount = 0;
168
206
  for (const modelId of categoryModels) {
169
207
  if (!this._props.viewport.view.viewsModel(modelId)) {
@@ -192,7 +230,7 @@ class ClassificationsTreeVisibilityHandlerImpl {
192
230
  continue;
193
231
  }
194
232
  }
195
- if (categoryModels.length > 0 && nonDefaultModelDisplayStatesCount === categoryModels.length) {
233
+ if (categoryModels.size > 0 && nonDefaultModelDisplayStatesCount === categoryModels.size) {
196
234
  assert(visibility === "visible" || visibility === "hidden");
197
235
  return createVisibilityStatus(visibility);
198
236
  }
@@ -216,7 +254,7 @@ class ClassificationsTreeVisibilityHandlerImpl {
216
254
  return of(createVisibilityStatus("disabled"));
217
255
  }
218
256
  const modelsObservable = props.modelId
219
- ? of(new Map(props.categoryIds.map((id) => [id, [props.modelId]])))
257
+ ? of(new Map(props.categoryIds.map((id) => [id, new Set([props.modelId])])))
220
258
  : from(this._idsCache.getCategoriesElementModels(props.categoryIds));
221
259
  return merge(
222
260
  // get visibility status from always and never drawn elements
@@ -308,7 +346,7 @@ class ClassificationsTreeVisibilityHandlerImpl {
308
346
  }));
309
347
  }
310
348
  const { modelId, categoryIds } = props.queryProps;
311
- const totalCount = (modelId ? of(new Map(categoryIds.map((categoryId) => [categoryId, [modelId]]))) : from(this._idsCache.getCategoriesElementModels(categoryIds))).pipe(mergeMap((categoriesMap) => from(categoriesMap)), mergeMap(([categoryId, modelIds]) => {
349
+ const totalCount = (modelId ? of(new Map(categoryIds.map((categoryId) => [categoryId, new Set([modelId])]))) : from(this._idsCache.getCategoriesElementModels(categoryIds))).pipe(mergeMap((categoriesMap) => from(categoriesMap)), mergeMap(([categoryId, modelIds]) => {
312
350
  return from(modelIds).pipe(mergeMap((modelOfCategory) => from(this._idsCache.getCategoryElementsCount(modelOfCategory, categoryId))), reduce((acc, specificModelCategoryCount) => acc + specificModelCategoryCount, 0));
313
351
  }));
314
352
  return forkJoin({
@@ -341,6 +379,9 @@ class ClassificationsTreeVisibilityHandlerImpl {
341
379
  return createVisibilityHandlerResult(this, props, result, undefined);
342
380
  }
343
381
  changeVisibilityObs(node, on) {
382
+ if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {
383
+ return this.changeFilteredNodeVisibility({ node, on });
384
+ }
344
385
  if (!HierarchyNode.isInstancesNode(node)) {
345
386
  return EMPTY;
346
387
  }
@@ -363,6 +404,28 @@ class ClassificationsTreeVisibilityHandlerImpl {
363
404
  on,
364
405
  });
365
406
  }
407
+ changeFilteredNodeVisibility({ on, ...props }) {
408
+ return from(this.getVisibilityChangeTargets(props)).pipe(mergeMap(({ classificationTableIds, classificationIds, elements2d, elements3d }) => {
409
+ const observables = new Array();
410
+ if (classificationTableIds?.size) {
411
+ observables.push(this.changeClassificationTableDisplayState({ classificationTableIds: [...classificationTableIds], on }));
412
+ }
413
+ if (classificationIds?.size) {
414
+ observables.push(this.changeClassificationDisplayState({ classificationIds: [...classificationIds], on }));
415
+ }
416
+ if (elements2d?.length) {
417
+ observables.push(from(elements2d).pipe(mergeMap(({ modelId, categoryId, elementIds }) => {
418
+ return this.changeGeometricElementsDisplayState({ modelId, categoryId, elementIds, on });
419
+ })));
420
+ }
421
+ if (elements3d?.length) {
422
+ observables.push(from(elements3d).pipe(mergeMap(({ modelId, categoryId, elementIds }) => {
423
+ return this.changeGeometricElementsDisplayState({ modelId, categoryId, elementIds, on });
424
+ })));
425
+ }
426
+ return merge(...observables);
427
+ }));
428
+ }
366
429
  changeClassificationTableDisplayState(props) {
367
430
  const result = defer(() => {
368
431
  return from(this._idsCache.getAllContainedCategories(props.classificationTableIds)).pipe(mergeMap(({ drawing, spatial }) => merge(drawing, spatial)), toArray(), mergeMap((categoryIds) => {
@@ -437,7 +500,7 @@ class ClassificationsTreeVisibilityHandlerImpl {
437
500
  const { modelId, categoryIds, on } = props;
438
501
  const viewport = this._props.viewport;
439
502
  const modelIdsObservable = modelId
440
- ? of(new Map(categoryIds.map((id) => [id, [modelId]])))
503
+ ? of(new Map(categoryIds.map((id) => [id, new Set([modelId])])))
441
504
  : from(this._idsCache.getCategoriesElementModels(categoryIds, true));
442
505
  return concat(modelId ? EMPTY : from(enableCategoryDisplay(viewport, categoryIds, on)), on
443
506
  ? modelIdsObservable.pipe(mergeMap((categoriesMap) => from(categoriesMap.values())), mergeAll(), filter((modelIdToCheck) => !viewport.view.viewsModel(modelIdToCheck)), mergeMap((modelIdToCheck) => this.showModelWithoutAnyCategoriesOrElements(modelIdToCheck)))