@itwin/tree-widget-react 4.0.0-alpha.14 → 4.0.0-alpha.16
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 +116 -1
- package/README.md +88 -11
- package/lib/esm/tree-widget-react/components/tree-header/SelectableTree.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/tree-header/SelectableTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.d.ts +5 -5
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +4 -2
- 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/CategoriesTreeComponent.d.ts +8 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +4 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +26 -20
- 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.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +28 -17
- 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 +8 -7
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +27 -15
- 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/UseFilteredPaths.js +4 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.d.ts +51 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js +283 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.d.ts +62 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js +84 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/FilteredTree.d.ts +33 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/FilteredTree.js +218 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/FilteredTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +9 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.d.ts +3 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +21 -8
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.d.ts +12 -8
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +41 -21
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.d.ts +37 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js +170 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHelper.d.ts +55 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHelper.js +53 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHelper.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/FilteredTree.d.ts +27 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/FilteredTree.js +165 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/FilteredTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +8 -4
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +22 -19
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/TreeWidgetViewport.d.ts +186 -0
- package/lib/esm/tree-widget-react/components/trees/common/TreeWidgetViewport.js +79 -0
- package/lib/esm/tree-widget-react/components/trees/common/TreeWidgetViewport.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.d.ts +11 -3
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js +24 -19
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +12 -6
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js +56 -13
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.d.ts +6 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js +4 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +2 -3
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +4 -4
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.d.ts +34 -8
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js +26 -5
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js +7 -8
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js +10 -9
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.d.ts +6 -12
- package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js +53 -61
- package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js +54 -34
- package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseActiveTreeWidgetViewport.d.ts +6 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseActiveTreeWidgetViewport.js +24 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseActiveTreeWidgetViewport.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.d.ts +7 -17
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js +26 -16
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityChangeEventListener.d.ts +3 -2
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityChangeEventListener.js +10 -6
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityChangeEventListener.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.d.ts +10 -29
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js +28 -64
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.d.ts +53 -15
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.js +142 -4
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseFilteredTree.d.ts +87 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseFilteredTree.js +107 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseFilteredTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.d.ts +235 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js +584 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +2 -2
- 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/ExternalSourcesTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +4 -0
- 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 +2 -2
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +2 -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/IModelContentTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/index.d.ts +4 -1
- package/lib/esm/tree-widget-react/components/trees/index.js +4 -0
- package/lib/esm/tree-widget-react/components/trees/index.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +3 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.d.ts +3 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +12 -9
- 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/ModelsTreeComponent.d.ts +8 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +9 -9
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +37 -33
- 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.d.ts +28 -9
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +31 -16
- 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/internal/ModelsTreeIdsCache.d.ts +9 -7
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +51 -51
- 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/UseFilteredPaths.d.ts +14 -4
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js +112 -36
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/FilteredTree.d.ts +24 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/FilteredTree.js +148 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/FilteredTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.d.ts +76 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js +263 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.d.ts +53 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.js +71 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.js.map +1 -0
- package/lib/esm/tree-widget-react-internal.d.ts +2 -2
- package/lib/esm/tree-widget-react-internal.js +2 -2
- package/lib/esm/tree-widget-react-internal.js.map +1 -1
- package/lib/public/locales/en/TreeWidget.json +3 -0
- package/package.json +19 -18
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.d.ts +0 -23
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js +0 -713
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/FilteredTree.d.ts +0 -39
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/FilteredTree.js +0 -221
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/FilteredTree.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.d.ts +0 -21
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.js +0 -551
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/FilteredTree.d.ts +0 -37
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/FilteredTree.js +0 -193
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/FilteredTree.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseNodeHighlighting.d.ts +0 -20
- package/lib/esm/tree-widget-react/components/trees/common/UseNodeHighlighting.js +0 -125
- package/lib/esm/tree-widget-react/components/trees/common/UseNodeHighlighting.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseActiveViewport.d.ts +0 -7
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseActiveViewport.js +0 -21
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseActiveViewport.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.d.ts +0 -23
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js +0 -171
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +0 -80
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +0 -507
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +0 -1
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { concat, concatAll, defaultIfEmpty, defer, distinct, EMPTY, filter, firstValueFrom, forkJoin, from, fromEventPattern, map, merge, mergeMap, of, shareReplay, startWith, Subject, take, takeUntil, tap, toArray, } from "rxjs";
|
|
6
|
-
import { assert, Id64 } from "@itwin/core-bentley";
|
|
7
|
-
import { PerModelCategoryVisibility } from "@itwin/core-frontend";
|
|
8
|
-
import { HierarchyNode, HierarchyNodeKey } from "@itwin/presentation-hierarchies";
|
|
9
|
-
import { AlwaysAndNeverDrawnElementInfo } from "../../common/internal/AlwaysAndNeverDrawnElementInfo.js";
|
|
10
|
-
import { CLASS_NAME_GeometricElement3d } from "../../common/internal/ClassNameDefinitions.js";
|
|
11
|
-
import { toVoidPromise } from "../../common/internal/Rxjs.js";
|
|
12
|
-
import { createVisibilityStatus } from "../../common/internal/Tooltip.js";
|
|
13
|
-
import { releaseMainThreadOnItemsCount, setDifference, setIntersection } from "../../common/internal/Utils.js";
|
|
14
|
-
import { createVisibilityChangeEventListener } from "../../common/internal/VisibilityChangeEventListener.js";
|
|
15
|
-
import { changeElementStateNoChildrenOperator, filterSubModeledElementIds, getElementOverriddenVisibility, getElementVisibility, getSubModeledElementsVisibilityStatus, getVisibilityFromAlwaysAndNeverDrawnElementsImpl, mergeVisibilityStatuses, } from "../../common/internal/VisibilityUtils.js";
|
|
16
|
-
import { createVisibilityHandlerResult } from "../../common/UseHierarchyVisibility.js";
|
|
17
|
-
import { createFilteredTree, parseCategoryKey } from "./FilteredTree.js";
|
|
18
|
-
import { ModelsTreeNode } from "./ModelsTreeNode.js";
|
|
19
|
-
/**
|
|
20
|
-
* Creates an instance if `ModelsTreeVisibilityHandler`.
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export function createModelsTreeVisibilityHandler(props) {
|
|
24
|
-
return new ModelsTreeVisibilityHandlerImpl(props);
|
|
25
|
-
}
|
|
26
|
-
class ModelsTreeVisibilityHandlerImpl {
|
|
27
|
-
_props;
|
|
28
|
-
_eventListener;
|
|
29
|
-
_alwaysAndNeverDrawnElements;
|
|
30
|
-
_idsCache;
|
|
31
|
-
_filteredTree;
|
|
32
|
-
_elementChangeQueue = new Subject();
|
|
33
|
-
_subscriptions = [];
|
|
34
|
-
_changeRequest = new Subject();
|
|
35
|
-
constructor(_props) {
|
|
36
|
-
this._props = _props;
|
|
37
|
-
this._eventListener = createVisibilityChangeEventListener({
|
|
38
|
-
viewport: _props.viewport,
|
|
39
|
-
listeners: {
|
|
40
|
-
models: true,
|
|
41
|
-
categories: true,
|
|
42
|
-
elements: true,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
this._alwaysAndNeverDrawnElements = new AlwaysAndNeverDrawnElementInfo(_props.viewport, CLASS_NAME_GeometricElement3d);
|
|
46
|
-
this._idsCache = this._props.idsCache;
|
|
47
|
-
this._filteredTree = _props.filteredPaths ? createFilteredTree(this._props.imodelAccess, _props.filteredPaths) : undefined;
|
|
48
|
-
this._subscriptions.push(this._elementChangeQueue.pipe(concatAll()).subscribe());
|
|
49
|
-
}
|
|
50
|
-
get onVisibilityChange() {
|
|
51
|
-
return this._eventListener.onVisibilityChange;
|
|
52
|
-
}
|
|
53
|
-
async getVisibilityStatus(node) {
|
|
54
|
-
return firstValueFrom(this.getVisibilityStatusObs(node).pipe(
|
|
55
|
-
// unsubscribe from the observable if the change request for this node is received
|
|
56
|
-
takeUntil(this._changeRequest.pipe(filter(({ key, depth }) => depth === node.parentKeys.length && HierarchyNodeKey.equals(node.key, key)))),
|
|
57
|
-
// unsubscribe if visibility changes
|
|
58
|
-
takeUntil(fromEventPattern((handler) => {
|
|
59
|
-
this._eventListener.onVisibilityChange.addListener(handler);
|
|
60
|
-
}, (handler) => {
|
|
61
|
-
this._eventListener.onVisibilityChange.removeListener(handler);
|
|
62
|
-
})), defaultIfEmpty(createVisibilityStatus("hidden"))));
|
|
63
|
-
}
|
|
64
|
-
async changeVisibility(node, shouldDisplay) {
|
|
65
|
-
// notify about new change request
|
|
66
|
-
this._changeRequest.next({ key: node.key, depth: node.parentKeys.length });
|
|
67
|
-
const changeObservable = this.changeVisibilityObs(node, shouldDisplay).pipe(
|
|
68
|
-
// unsubscribe from the observable if the change request for this node is received
|
|
69
|
-
takeUntil(this._changeRequest.pipe(filter(({ key, depth }) => depth === node.parentKeys.length && HierarchyNodeKey.equals(node.key, key)))), tap({
|
|
70
|
-
subscribe: () => {
|
|
71
|
-
this._eventListener.suppressChangeEvents();
|
|
72
|
-
this._alwaysAndNeverDrawnElements.suppressChangeEvents();
|
|
73
|
-
},
|
|
74
|
-
finalize: () => {
|
|
75
|
-
this._eventListener.resumeChangeEvents();
|
|
76
|
-
this._alwaysAndNeverDrawnElements.resumeChangeEvents();
|
|
77
|
-
},
|
|
78
|
-
}));
|
|
79
|
-
return toVoidPromise(changeObservable);
|
|
80
|
-
}
|
|
81
|
-
dispose() {
|
|
82
|
-
this[Symbol.dispose]();
|
|
83
|
-
}
|
|
84
|
-
[Symbol.dispose]() {
|
|
85
|
-
this._eventListener[Symbol.dispose]();
|
|
86
|
-
this._alwaysAndNeverDrawnElements[Symbol.dispose]();
|
|
87
|
-
this._subscriptions.forEach((x) => x.unsubscribe());
|
|
88
|
-
}
|
|
89
|
-
getVisibilityStatusObs(node) {
|
|
90
|
-
if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {
|
|
91
|
-
return this.getFilteredNodeVisibility({ node });
|
|
92
|
-
}
|
|
93
|
-
if (HierarchyNode.isClassGroupingNode(node)) {
|
|
94
|
-
return this.getClassGroupingNodeDisplayStatus(node);
|
|
95
|
-
}
|
|
96
|
-
if (!HierarchyNode.isInstancesNode(node)) {
|
|
97
|
-
return of(createVisibilityStatus("disabled"));
|
|
98
|
-
}
|
|
99
|
-
if (ModelsTreeNode.isSubjectNode(node)) {
|
|
100
|
-
// note: subject nodes may be merged to represent multiple subject instances
|
|
101
|
-
return this.getSubjectNodeVisibilityStatus({ subjectIds: node.key.instanceKeys.map((key) => key.id) });
|
|
102
|
-
}
|
|
103
|
-
if (ModelsTreeNode.isModelNode(node)) {
|
|
104
|
-
return this.getModelVisibilityStatus({ modelIds: node.key.instanceKeys.map(({ id }) => id) });
|
|
105
|
-
}
|
|
106
|
-
const modelId = ModelsTreeNode.getModelId(node);
|
|
107
|
-
if (!modelId) {
|
|
108
|
-
return of(createVisibilityStatus("disabled"));
|
|
109
|
-
}
|
|
110
|
-
if (ModelsTreeNode.isCategoryNode(node)) {
|
|
111
|
-
return this.getCategoryDisplayStatus({
|
|
112
|
-
categoryIds: node.key.instanceKeys.map(({ id }) => id),
|
|
113
|
-
modelId,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
const categoryId = ModelsTreeNode.getCategoryId(node);
|
|
117
|
-
if (!categoryId) {
|
|
118
|
-
return of(createVisibilityStatus("disabled"));
|
|
119
|
-
}
|
|
120
|
-
return this.getElementDisplayStatus({
|
|
121
|
-
elementId: node.key.instanceKeys[0].id,
|
|
122
|
-
modelId,
|
|
123
|
-
categoryId,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
getFilteredNodeVisibility(props) {
|
|
127
|
-
return from(this.getVisibilityChangeTargets(props)).pipe(mergeMap(({ subjectIds: subjects, modelIds: models, categories, elements }) => {
|
|
128
|
-
const observables = new Array();
|
|
129
|
-
if (subjects?.size) {
|
|
130
|
-
observables.push(this.getSubjectNodeVisibilityStatus({ subjectIds: [...subjects] }));
|
|
131
|
-
}
|
|
132
|
-
if (models?.size) {
|
|
133
|
-
observables.push(this.getModelVisibilityStatus({ modelIds: models }));
|
|
134
|
-
}
|
|
135
|
-
if (categories?.size) {
|
|
136
|
-
observables.push(from(categories).pipe(mergeMap((key) => {
|
|
137
|
-
const { modelId, categoryId } = parseCategoryKey(key);
|
|
138
|
-
return this.getCategoryDisplayStatus({ modelId, categoryIds: categoryId });
|
|
139
|
-
})));
|
|
140
|
-
}
|
|
141
|
-
if (elements?.size) {
|
|
142
|
-
observables.push(from(elements).pipe(releaseMainThreadOnItemsCount(50), mergeMap(([categoryKey, elementIds]) => {
|
|
143
|
-
const { modelId, categoryId } = parseCategoryKey(categoryKey);
|
|
144
|
-
return from(elementIds).pipe(releaseMainThreadOnItemsCount(1000), mergeMap((elementId) => this.getElementDisplayStatus({ modelId, categoryId, elementId })));
|
|
145
|
-
})));
|
|
146
|
-
}
|
|
147
|
-
return merge(...observables);
|
|
148
|
-
}), mergeVisibilityStatuses);
|
|
149
|
-
}
|
|
150
|
-
getSubjectNodeVisibilityStatus({ subjectIds }) {
|
|
151
|
-
const result = defer(() => {
|
|
152
|
-
if (!this._props.viewport.view.isSpatialView()) {
|
|
153
|
-
return of(createVisibilityStatus("disabled"));
|
|
154
|
-
}
|
|
155
|
-
return from(this._idsCache.getSubjectModelIds(subjectIds)).pipe(mergeMap((modelIds) => this.getModelVisibilityStatus({ modelIds })), mergeVisibilityStatuses);
|
|
156
|
-
});
|
|
157
|
-
return createVisibilityHandlerResult(this, { ids: subjectIds }, result, this._props.overrides?.getSubjectNodeVisibility);
|
|
158
|
-
}
|
|
159
|
-
getModelVisibilityStatus({ modelIds }) {
|
|
160
|
-
const result = defer(() => {
|
|
161
|
-
const viewport = this._props.viewport;
|
|
162
|
-
if (!viewport.view.isSpatialView()) {
|
|
163
|
-
return of(createVisibilityStatus("disabled"));
|
|
164
|
-
}
|
|
165
|
-
return from(modelIds).pipe(distinct(), mergeMap((modelId) => {
|
|
166
|
-
if (!viewport.view.viewsModel(modelId)) {
|
|
167
|
-
return from(this._idsCache.getModelCategoryIds(modelId)).pipe(mergeMap((categoryIds) => from(this._idsCache.getCategoriesModeledElements(modelId, categoryIds))), getSubModeledElementsVisibilityStatus({
|
|
168
|
-
parentNodeVisibilityStatus: createVisibilityStatus("hidden"),
|
|
169
|
-
getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),
|
|
170
|
-
}));
|
|
171
|
-
}
|
|
172
|
-
return from(this._idsCache.getModelCategoryIds(modelId)).pipe(mergeMap((categoryIds) => categoryIds.length === 0 ? of(createVisibilityStatus("visible")) : this.getCategoryDisplayStatus({ modelId, categoryIds })), mergeVisibilityStatuses);
|
|
173
|
-
}), mergeVisibilityStatuses);
|
|
174
|
-
});
|
|
175
|
-
return createVisibilityHandlerResult(this, { ids: modelIds }, result, this._props.overrides?.getModelDisplayStatus);
|
|
176
|
-
}
|
|
177
|
-
getDefaultCategoryVisibilityStatus({ modelId, categoryIds }) {
|
|
178
|
-
const viewport = this._props.viewport;
|
|
179
|
-
if (!viewport.view.viewsModel(modelId) || Id64.sizeOf(categoryIds) === 0) {
|
|
180
|
-
return createVisibilityStatus("hidden");
|
|
181
|
-
}
|
|
182
|
-
let visibility = "unknown";
|
|
183
|
-
for (const categoryId of Id64.iterable(categoryIds)) {
|
|
184
|
-
const override = this._props.viewport.perModelCategoryVisibility.getOverride(modelId, categoryId);
|
|
185
|
-
if (override === PerModelCategoryVisibility.Override.Show) {
|
|
186
|
-
if (visibility === "hidden") {
|
|
187
|
-
return createVisibilityStatus("partial");
|
|
188
|
-
}
|
|
189
|
-
visibility = "visible";
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
if (override === PerModelCategoryVisibility.Override.Hide) {
|
|
193
|
-
if (visibility === "visible") {
|
|
194
|
-
return createVisibilityStatus("partial");
|
|
195
|
-
}
|
|
196
|
-
visibility = "hidden";
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
const isVisible = viewport.view.viewsCategory(categoryId);
|
|
200
|
-
if (isVisible && visibility === "hidden") {
|
|
201
|
-
return createVisibilityStatus("partial");
|
|
202
|
-
}
|
|
203
|
-
if (!isVisible && visibility === "visible") {
|
|
204
|
-
return createVisibilityStatus("partial");
|
|
205
|
-
}
|
|
206
|
-
visibility = isVisible ? "visible" : "hidden";
|
|
207
|
-
}
|
|
208
|
-
assert(visibility !== "unknown");
|
|
209
|
-
return createVisibilityStatus(visibility);
|
|
210
|
-
}
|
|
211
|
-
getCategoryDisplayStatus(props) {
|
|
212
|
-
const result = defer(() => {
|
|
213
|
-
if (!this._props.viewport.view.viewsModel(props.modelId)) {
|
|
214
|
-
return from(this._idsCache.getCategoriesModeledElements(props.modelId, props.categoryIds)).pipe(getSubModeledElementsVisibilityStatus({
|
|
215
|
-
parentNodeVisibilityStatus: createVisibilityStatus("hidden"),
|
|
216
|
-
getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),
|
|
217
|
-
}));
|
|
218
|
-
}
|
|
219
|
-
return this.getVisibilityFromAlwaysAndNeverDrawnElements({
|
|
220
|
-
categoryProps: { categoryIds: props.categoryIds, modelId: props.modelId },
|
|
221
|
-
defaultStatus: (categoryId) => categoryId
|
|
222
|
-
? this.getDefaultCategoryVisibilityStatus({ modelId: props.modelId, categoryIds: categoryId })
|
|
223
|
-
: this.getDefaultCategoryVisibilityStatus({ modelId: props.modelId, categoryIds: props.categoryIds }),
|
|
224
|
-
}).pipe(mergeMap((visibilityStatusAlwaysAndNeverDraw) => {
|
|
225
|
-
return from(this._idsCache.getCategoriesModeledElements(props.modelId, props.categoryIds)).pipe(getSubModeledElementsVisibilityStatus({
|
|
226
|
-
parentNodeVisibilityStatus: visibilityStatusAlwaysAndNeverDraw,
|
|
227
|
-
getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),
|
|
228
|
-
}));
|
|
229
|
-
}));
|
|
230
|
-
});
|
|
231
|
-
return createVisibilityHandlerResult(this, props, result, this._props.overrides?.getCategoryDisplayStatus);
|
|
232
|
-
}
|
|
233
|
-
getClassGroupingNodeDisplayStatus(node) {
|
|
234
|
-
const result = defer(() => {
|
|
235
|
-
const info = this.getGroupingNodeInfo(node);
|
|
236
|
-
const { modelId, categoryId, elementIds } = info;
|
|
237
|
-
if (!this._props.viewport.view.viewsModel(modelId)) {
|
|
238
|
-
return of([...elementIds]).pipe(filterSubModeledElementIds({ doesSubModelExist: async (id) => this._idsCache.hasSubModel(id) }), getSubModeledElementsVisibilityStatus({
|
|
239
|
-
parentNodeVisibilityStatus: createVisibilityStatus("hidden"),
|
|
240
|
-
getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),
|
|
241
|
-
}));
|
|
242
|
-
}
|
|
243
|
-
return this.getVisibilityFromAlwaysAndNeverDrawnElements({
|
|
244
|
-
elements: elementIds,
|
|
245
|
-
defaultStatus: () => this.getDefaultCategoryVisibilityStatus({ categoryIds: categoryId, modelId }),
|
|
246
|
-
}).pipe(mergeMap((visibilityStatusAlwaysAndNeverDraw) => {
|
|
247
|
-
return of([...elementIds]).pipe(filterSubModeledElementIds({ doesSubModelExist: async (id) => this._idsCache.hasSubModel(id) }), getSubModeledElementsVisibilityStatus({
|
|
248
|
-
parentNodeVisibilityStatus: visibilityStatusAlwaysAndNeverDraw,
|
|
249
|
-
getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),
|
|
250
|
-
}));
|
|
251
|
-
}));
|
|
252
|
-
});
|
|
253
|
-
return createVisibilityHandlerResult(this, { node }, result, this._props.overrides?.getElementGroupingNodeDisplayStatus);
|
|
254
|
-
}
|
|
255
|
-
getElementDisplayStatus(props) {
|
|
256
|
-
const result = defer(() => {
|
|
257
|
-
const viewport = this._props.viewport;
|
|
258
|
-
const { elementId, modelId, categoryId } = props;
|
|
259
|
-
const viewsModel = viewport.view.viewsModel(modelId);
|
|
260
|
-
const elementStatus = getElementOverriddenVisibility({
|
|
261
|
-
elementId,
|
|
262
|
-
viewport,
|
|
263
|
-
});
|
|
264
|
-
return from(this._idsCache.hasSubModel(elementId)).pipe(mergeMap((hasSubModel) => (hasSubModel ? this.getModelVisibilityStatus({ modelIds: [elementId] }) : of(undefined))), map((subModelVisibilityStatus) => getElementVisibility(viewsModel, elementStatus,
|
|
265
|
-
// Single category will always return "visible" or "hidden"
|
|
266
|
-
this.getDefaultCategoryVisibilityStatus({ categoryIds: categoryId, modelId }), subModelVisibilityStatus)));
|
|
267
|
-
});
|
|
268
|
-
return createVisibilityHandlerResult(this, props, result, this._props.overrides?.getElementDisplayStatus);
|
|
269
|
-
}
|
|
270
|
-
/** Changes visibility of the items represented by the tree node. */
|
|
271
|
-
changeVisibilityObs(node, on) {
|
|
272
|
-
if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {
|
|
273
|
-
return this.changeFilteredNodeVisibility({ node, on });
|
|
274
|
-
}
|
|
275
|
-
if (HierarchyNode.isClassGroupingNode(node)) {
|
|
276
|
-
return this.changeElementGroupingNodeState(node, on);
|
|
277
|
-
}
|
|
278
|
-
if (!HierarchyNode.isInstancesNode(node)) {
|
|
279
|
-
return EMPTY;
|
|
280
|
-
}
|
|
281
|
-
if (ModelsTreeNode.isSubjectNode(node)) {
|
|
282
|
-
return this.changeSubjectNodeState(node.key.instanceKeys.map((key) => key.id), on);
|
|
283
|
-
}
|
|
284
|
-
if (ModelsTreeNode.isModelNode(node)) {
|
|
285
|
-
return this.changeModelState({ ids: node.key.instanceKeys.map(({ id }) => id), on });
|
|
286
|
-
}
|
|
287
|
-
const modelId = ModelsTreeNode.getModelId(node);
|
|
288
|
-
if (!modelId) {
|
|
289
|
-
return EMPTY;
|
|
290
|
-
}
|
|
291
|
-
if (ModelsTreeNode.isCategoryNode(node)) {
|
|
292
|
-
return this.changeCategoryState({
|
|
293
|
-
categoryIds: node.key.instanceKeys.map(({ id }) => id),
|
|
294
|
-
modelId,
|
|
295
|
-
on,
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
const categoryId = ModelsTreeNode.getCategoryId(node);
|
|
299
|
-
if (!categoryId) {
|
|
300
|
-
return EMPTY;
|
|
301
|
-
}
|
|
302
|
-
return this.changeElementsState({
|
|
303
|
-
elementIds: new Set([...node.key.instanceKeys.map(({ id }) => id)]),
|
|
304
|
-
modelId,
|
|
305
|
-
categoryId,
|
|
306
|
-
on,
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
async getVisibilityChangeTargets({ node }) {
|
|
310
|
-
const filteredTree = await this._filteredTree;
|
|
311
|
-
return filteredTree ? filteredTree.getVisibilityChangeTargets(node) : {};
|
|
312
|
-
}
|
|
313
|
-
changeFilteredNodeVisibility({ on, ...props }) {
|
|
314
|
-
return from(this.getVisibilityChangeTargets(props)).pipe(mergeMap(({ subjectIds: subjects, modelIds: models, categories, elements }) => {
|
|
315
|
-
const observables = new Array();
|
|
316
|
-
if (subjects?.size) {
|
|
317
|
-
observables.push(this.changeSubjectNodeState([...subjects], on));
|
|
318
|
-
}
|
|
319
|
-
if (models?.size) {
|
|
320
|
-
observables.push(this.changeModelState({ ids: models, on }));
|
|
321
|
-
}
|
|
322
|
-
if (categories?.size) {
|
|
323
|
-
observables.push(from(categories).pipe(mergeMap((key) => {
|
|
324
|
-
const { modelId, categoryId } = parseCategoryKey(key);
|
|
325
|
-
return this.changeCategoryState({ modelId, categoryIds: categoryId, on });
|
|
326
|
-
})));
|
|
327
|
-
}
|
|
328
|
-
if (elements?.size) {
|
|
329
|
-
observables.push(from(elements).pipe(mergeMap(([categoryKey, elementIds]) => {
|
|
330
|
-
const { modelId, categoryId } = parseCategoryKey(categoryKey);
|
|
331
|
-
return this.changeElementsState({ modelId, categoryId, elementIds, on });
|
|
332
|
-
})));
|
|
333
|
-
}
|
|
334
|
-
return merge(...observables);
|
|
335
|
-
}));
|
|
336
|
-
}
|
|
337
|
-
changeSubjectNodeState(subjectIds, on) {
|
|
338
|
-
const result = defer(() => {
|
|
339
|
-
if (!this._props.viewport.view.isSpatialView()) {
|
|
340
|
-
return EMPTY;
|
|
341
|
-
}
|
|
342
|
-
return from(this._idsCache.getSubjectModelIds(subjectIds)).pipe(mergeMap((modelIds) => this.changeModelState({ ids: modelIds, on })));
|
|
343
|
-
});
|
|
344
|
-
return createVisibilityHandlerResult(this, { ids: subjectIds, on }, result, this._props.overrides?.changeSubjectNodeState);
|
|
345
|
-
}
|
|
346
|
-
changeModelState(props) {
|
|
347
|
-
const { ids, on } = props;
|
|
348
|
-
if (Id64.sizeOf(ids) === 0) {
|
|
349
|
-
return EMPTY;
|
|
350
|
-
}
|
|
351
|
-
const result = defer(() => {
|
|
352
|
-
const viewport = this._props.viewport;
|
|
353
|
-
if (!viewport.view.isSpatialView()) {
|
|
354
|
-
return EMPTY;
|
|
355
|
-
}
|
|
356
|
-
const idsObs = from(Id64.iterable(ids));
|
|
357
|
-
if (!on) {
|
|
358
|
-
viewport.changeModelDisplay(ids, false);
|
|
359
|
-
return idsObs.pipe(mergeMap(async (modelId) => ({ modelId, categoryIds: await this._idsCache.getModelCategoryIds(modelId) })), mergeMap(({ modelId, categoryIds }) => from(this._idsCache.getCategoriesModeledElements(modelId, categoryIds))), mergeMap((modeledElementIds) => this.changeModelState({ ids: modeledElementIds, on })));
|
|
360
|
-
}
|
|
361
|
-
return concat(defer(() => {
|
|
362
|
-
viewport.perModelCategoryVisibility.clearOverrides(ids);
|
|
363
|
-
return from(viewport.addViewedModels(ids));
|
|
364
|
-
}), idsObs.pipe(mergeMap((modelId) => {
|
|
365
|
-
return from(this._idsCache.getModelCategoryIds(modelId)).pipe(mergeMap((categoryIds) => this.changeCategoryState({ categoryIds, modelId, on: true })));
|
|
366
|
-
})));
|
|
367
|
-
});
|
|
368
|
-
return createVisibilityHandlerResult(this, props, result, this._props.overrides?.changeModelState);
|
|
369
|
-
}
|
|
370
|
-
showModelWithoutAnyCategoriesOrElements(modelId) {
|
|
371
|
-
const viewport = this._props.viewport;
|
|
372
|
-
return forkJoin({
|
|
373
|
-
categories: this._idsCache.getModelCategoryIds(modelId),
|
|
374
|
-
alwaysDrawnElements: this._alwaysAndNeverDrawnElements.getAlwaysDrawnElements({ modelId }),
|
|
375
|
-
}).pipe(mergeMap(async ({ categories, alwaysDrawnElements }) => {
|
|
376
|
-
const alwaysDrawn = this._props.viewport.alwaysDrawn;
|
|
377
|
-
if (alwaysDrawn && alwaysDrawnElements) {
|
|
378
|
-
viewport.setAlwaysDrawn(setDifference(alwaysDrawn, alwaysDrawnElements));
|
|
379
|
-
}
|
|
380
|
-
categories.forEach((categoryId) => {
|
|
381
|
-
this.changeCategoryStateInViewportAccordingToModelVisibility(modelId, categoryId, false);
|
|
382
|
-
});
|
|
383
|
-
await viewport.addViewedModels(modelId);
|
|
384
|
-
}));
|
|
385
|
-
}
|
|
386
|
-
changeCategoryStateInViewportAccordingToModelVisibility(modelId, categoryId, on) {
|
|
387
|
-
const viewport = this._props.viewport;
|
|
388
|
-
const isDisplayedInSelector = viewport.view.viewsCategory(categoryId);
|
|
389
|
-
const override = on === isDisplayedInSelector
|
|
390
|
-
? PerModelCategoryVisibility.Override.None
|
|
391
|
-
: on
|
|
392
|
-
? PerModelCategoryVisibility.Override.Show
|
|
393
|
-
: PerModelCategoryVisibility.Override.Hide;
|
|
394
|
-
viewport.perModelCategoryVisibility.setOverride(modelId, categoryId, override);
|
|
395
|
-
if (override === PerModelCategoryVisibility.Override.None && on) {
|
|
396
|
-
// we took off the override which means the category is displayed in selector, but
|
|
397
|
-
// doesn't mean all its subcategories are displayed - this call ensures that
|
|
398
|
-
viewport.changeCategoryDisplay(categoryId, true, true);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
changeCategoryState(props) {
|
|
402
|
-
const result = defer(() => {
|
|
403
|
-
const viewport = this._props.viewport;
|
|
404
|
-
const { modelId, categoryIds, on } = props;
|
|
405
|
-
return concat(props.on && !viewport.view.viewsModel(modelId) ? this.showModelWithoutAnyCategoriesOrElements(modelId) : EMPTY, defer(() => {
|
|
406
|
-
for (const categoryId of Id64.iterable(categoryIds)) {
|
|
407
|
-
this.changeCategoryStateInViewportAccordingToModelVisibility(modelId, categoryId, on);
|
|
408
|
-
}
|
|
409
|
-
return this._alwaysAndNeverDrawnElements.clearAlwaysAndNeverDrawnElements(props);
|
|
410
|
-
}), from(this._idsCache.getCategoriesModeledElements(modelId, categoryIds)).pipe(mergeMap((modeledElementIds) => this.changeModelState({ ids: modeledElementIds, on }))));
|
|
411
|
-
});
|
|
412
|
-
return createVisibilityHandlerResult(this, props, result, this._props.overrides?.changeCategoryState);
|
|
413
|
-
}
|
|
414
|
-
doChangeElementsState(props) {
|
|
415
|
-
return defer(() => {
|
|
416
|
-
const { modelId, categoryId, elementIds, on } = props;
|
|
417
|
-
const viewport = this._props.viewport;
|
|
418
|
-
return concat(on && !viewport.view.viewsModel(modelId) ? this.showModelWithoutAnyCategoriesOrElements(modelId) : EMPTY, defer(() => {
|
|
419
|
-
const categoryVisibility = this.getDefaultCategoryVisibilityStatus({ categoryIds: categoryId, modelId });
|
|
420
|
-
const isDisplayedByDefault = categoryVisibility.state === "visible";
|
|
421
|
-
return this.queueElementsVisibilityChange(elementIds, on, isDisplayedByDefault);
|
|
422
|
-
}), from(elementIds).pipe(mergeMap(async (elementId) => ({ elementId, isSubModel: await this._idsCache.hasSubModel(elementId) })), filter(({ isSubModel }) => isSubModel), map(({ elementId }) => elementId), toArray(), mergeMap((subModelIds) => this.changeModelState({ ids: subModelIds, on }))));
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Updates visibility of all grouping node's elements.
|
|
427
|
-
* @see `changeElementState`
|
|
428
|
-
*/
|
|
429
|
-
changeElementGroupingNodeState(node, on) {
|
|
430
|
-
const result = this.doChangeElementsState({ ...this.getGroupingNodeInfo(node), on });
|
|
431
|
-
return createVisibilityHandlerResult(this, { node, on }, result, this._props.overrides?.changeElementGroupingNodeState);
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Updates visibility of an element and all its child elements by adding them to the always/never drawn list.
|
|
435
|
-
* @note If element is to be enabled and model is hidden, it will be enabled.
|
|
436
|
-
*/
|
|
437
|
-
changeElementsState(props) {
|
|
438
|
-
const result = this.doChangeElementsState(props);
|
|
439
|
-
return createVisibilityHandlerResult(this, props, result, this._props.overrides?.changeElementsState);
|
|
440
|
-
}
|
|
441
|
-
queueElementsVisibilityChange(elementIds, on, visibleByDefault) {
|
|
442
|
-
const finishedSubject = new Subject();
|
|
443
|
-
// observable to track if visibility change is finished/cancelled
|
|
444
|
-
const changeFinished = finishedSubject.pipe(startWith(false), shareReplay(1), filter((finished) => finished));
|
|
445
|
-
const changeObservable = from(elementIds).pipe(
|
|
446
|
-
// check if visibility change is not finished (cancelled) due to change overall change request being cancelled
|
|
447
|
-
takeUntil(changeFinished), changeElementStateNoChildrenOperator({ on, isDisplayedByDefault: visibleByDefault, viewport: this._props.viewport }), tap({
|
|
448
|
-
next: () => {
|
|
449
|
-
// notify that visibility change is finished
|
|
450
|
-
finishedSubject.next(true);
|
|
451
|
-
},
|
|
452
|
-
}));
|
|
453
|
-
// queue visibility change. `changeObservable` will be subscribed to when other queue changes are finished
|
|
454
|
-
this._elementChangeQueue.next(changeObservable);
|
|
455
|
-
// return observable that will emit when visibility change is finished
|
|
456
|
-
return changeFinished.pipe(take(1), tap({
|
|
457
|
-
unsubscribe: () => {
|
|
458
|
-
// if this observable is unsubscribed before visibility change is finished, we have to notify that it queued change request is cancelled
|
|
459
|
-
finishedSubject.next(true);
|
|
460
|
-
},
|
|
461
|
-
}), map(() => undefined));
|
|
462
|
-
}
|
|
463
|
-
getVisibilityFromAlwaysAndNeverDrawnElements(props) {
|
|
464
|
-
const viewport = this._props.viewport;
|
|
465
|
-
if (viewport.isAlwaysDrawnExclusive) {
|
|
466
|
-
if (!viewport?.alwaysDrawn?.size) {
|
|
467
|
-
return of(createVisibilityStatus("hidden"));
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
else if (!viewport?.neverDrawn?.size && !viewport?.alwaysDrawn?.size) {
|
|
471
|
-
return of(props.defaultStatus());
|
|
472
|
-
}
|
|
473
|
-
if ("elements" in props) {
|
|
474
|
-
return of(getVisibilityFromAlwaysAndNeverDrawnElementsImpl({
|
|
475
|
-
...props,
|
|
476
|
-
alwaysDrawn: viewport.alwaysDrawn?.size ? setIntersection(props.elements, viewport.alwaysDrawn) : undefined,
|
|
477
|
-
neverDrawn: viewport.neverDrawn?.size ? setIntersection(props.elements, viewport.neverDrawn) : undefined,
|
|
478
|
-
totalCount: props.elements.size,
|
|
479
|
-
viewport,
|
|
480
|
-
}));
|
|
481
|
-
}
|
|
482
|
-
const { modelId, categoryIds } = props.categoryProps;
|
|
483
|
-
return from(Id64.iterable(categoryIds)).pipe(mergeMap((categoryId) => {
|
|
484
|
-
const totalCount = this._idsCache.getCategoryElementsCount(modelId, categoryId);
|
|
485
|
-
return forkJoin({
|
|
486
|
-
totalCount,
|
|
487
|
-
alwaysDrawn: this._alwaysAndNeverDrawnElements.getAlwaysDrawnElements({ categoryIds: categoryId, modelId }),
|
|
488
|
-
neverDrawn: this._alwaysAndNeverDrawnElements.getNeverDrawnElements({ categoryIds: categoryId, modelId }),
|
|
489
|
-
}).pipe(map((state) => {
|
|
490
|
-
return getVisibilityFromAlwaysAndNeverDrawnElementsImpl({
|
|
491
|
-
...props,
|
|
492
|
-
...state,
|
|
493
|
-
defaultStatus: () => props.defaultStatus(categoryId),
|
|
494
|
-
viewport,
|
|
495
|
-
});
|
|
496
|
-
}));
|
|
497
|
-
}), mergeVisibilityStatuses);
|
|
498
|
-
}
|
|
499
|
-
getGroupingNodeInfo(node) {
|
|
500
|
-
const modelId = ModelsTreeNode.getModelId(node);
|
|
501
|
-
const categoryId = ModelsTreeNode.getCategoryId(node);
|
|
502
|
-
assert(!!modelId && !!categoryId);
|
|
503
|
-
const elementIds = new Set(node.groupedInstanceKeys.map((key) => key.id));
|
|
504
|
-
return { modelId, categoryId, elementIds };
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
//# sourceMappingURL=ModelsTreeVisibilityHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeVisibilityHandler.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EACL,MAAM,EACN,SAAS,EACT,cAAc,EACd,KAAK,EACL,QAAQ,EACR,KAAK,EACL,MAAM,EACN,cAAc,EACd,QAAQ,EACR,IAAI,EACJ,gBAAgB,EAChB,GAAG,EACH,KAAK,EACL,QAAQ,EACR,EAAE,EACF,WAAW,EACX,SAAS,EACT,OAAO,EACP,IAAI,EACJ,SAAS,EACT,GAAG,EACH,OAAO,GACR,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,yDAAyD,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,6BAA6B,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAC/G,OAAO,EAAE,mCAAmC,EAAE,MAAM,wDAAwD,CAAC;AAC7G,OAAO,EACL,oCAAoC,EACpC,0BAA0B,EAC1B,8BAA8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AAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;IAC7C,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 {\n concat,\n concatAll,\n defaultIfEmpty,\n defer,\n distinct,\n EMPTY,\n filter,\n firstValueFrom,\n forkJoin,\n from,\n fromEventPattern,\n map,\n merge,\n mergeMap,\n of,\n shareReplay,\n startWith,\n Subject,\n take,\n takeUntil,\n tap,\n toArray,\n} from \"rxjs\";\nimport { assert, Id64 } from \"@itwin/core-bentley\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\nimport { HierarchyNode, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { AlwaysAndNeverDrawnElementInfo } from \"../../common/internal/AlwaysAndNeverDrawnElementInfo.js\";\nimport { CLASS_NAME_GeometricElement3d } from \"../../common/internal/ClassNameDefinitions.js\";\nimport { toVoidPromise } from \"../../common/internal/Rxjs.js\";\nimport { createVisibilityStatus } from \"../../common/internal/Tooltip.js\";\nimport { releaseMainThreadOnItemsCount, setDifference, setIntersection } from \"../../common/internal/Utils.js\";\nimport { createVisibilityChangeEventListener } from \"../../common/internal/VisibilityChangeEventListener.js\";\nimport {\n changeElementStateNoChildrenOperator,\n filterSubModeledElementIds,\n getElementOverriddenVisibility,\n getElementVisibility,\n getSubModeledElementsVisibilityStatus,\n getVisibilityFromAlwaysAndNeverDrawnElementsImpl,\n mergeVisibilityStatuses,\n} from \"../../common/internal/VisibilityUtils.js\";\nimport { createVisibilityHandlerResult } from \"../../common/UseHierarchyVisibility.js\";\nimport { createFilteredTree, parseCategoryKey } from \"./FilteredTree.js\";\nimport { ModelsTreeNode } from \"./ModelsTreeNode.js\";\n\nimport type { NonPartialVisibilityStatus } from \"../../common/internal/Tooltip.js\";\nimport type { GetVisibilityFromAlwaysAndNeverDrawnElementsProps } from \"../../common/internal/VisibilityUtils.js\";\nimport type { Observable, Subscription } from \"rxjs\";\nimport type { GroupingHierarchyNode, HierarchyFilteringPath } from \"@itwin/presentation-hierarchies\";\nimport type { HierarchyVisibilityHandler, HierarchyVisibilityHandlerOverridableMethod, VisibilityStatus } from \"../../common/UseHierarchyVisibility.js\";\nimport type { ModelsTreeIdsCache } from \"./ModelsTreeIdsCache.js\";\nimport type { Id64Arg, Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { ECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport type { FilteredTree } from \"./FilteredTree.js\";\nimport type { IVisibilityChangeEventListener } from \"../../common/internal/VisibilityChangeEventListener.js\";\nimport type { ElementId } from \"../../common/internal/Types.js\";\n\n/** @beta */\ninterface GetCategoryVisibilityStatusProps {\n categoryIds: Id64Arg;\n modelId: Id64String;\n}\n\n/** @beta */\ninterface ChangeCategoryVisibilityStateProps extends GetCategoryVisibilityStatusProps {\n on: boolean;\n}\n\n/** @beta */\ninterface GetGeometricElementVisibilityStatusProps {\n elementId: Id64String;\n modelId: Id64String;\n categoryId: Id64String;\n}\n\n/** @beta */\ninterface ChangeGeometricElementsDisplayStateProps {\n elementIds: Id64Set;\n modelId: Id64String;\n categoryId: Id64String;\n on: boolean;\n}\n\n/** @beta */\ninterface ChangeModelVisibilityStateProps {\n ids: Id64Arg;\n on: boolean;\n}\n\n/** @beta */\ninterface GetFilteredNodeVisibilityProps {\n node: HierarchyNode;\n}\n\n/** @beta */\ninterface ChangeFilteredNodeVisibilityProps extends GetFilteredNodeVisibilityProps {\n on: boolean;\n}\n\n/**\n * Functionality of Models tree visibility handler that can be overridden.\n * Each callback is provided original implementation and reference to a `HierarchyVisibilityHandler`.\n * @beta\n */\nexport interface ModelsTreeVisibilityHandlerOverrides {\n getSubjectNodeVisibility?: HierarchyVisibilityHandlerOverridableMethod<(props: { ids: Id64Array }) => Promise<VisibilityStatus>>;\n getModelDisplayStatus?: HierarchyVisibilityHandlerOverridableMethod<(props: { ids: Id64Arg }) => Promise<VisibilityStatus>>;\n getCategoryDisplayStatus?: HierarchyVisibilityHandlerOverridableMethod<(props: GetCategoryVisibilityStatusProps) => Promise<VisibilityStatus>>;\n getElementGroupingNodeDisplayStatus?: HierarchyVisibilityHandlerOverridableMethod<(props: { node: GroupingHierarchyNode }) => Promise<VisibilityStatus>>;\n getElementDisplayStatus?: HierarchyVisibilityHandlerOverridableMethod<(props: GetGeometricElementVisibilityStatusProps) => Promise<VisibilityStatus>>;\n\n changeSubjectNodeState?: HierarchyVisibilityHandlerOverridableMethod<(props: { ids: Id64Array; on: boolean }) => Promise<void>>;\n changeModelState?: HierarchyVisibilityHandlerOverridableMethod<(props: ChangeModelVisibilityStateProps) => Promise<void>>;\n changeCategoryState?: HierarchyVisibilityHandlerOverridableMethod<(props: ChangeCategoryVisibilityStateProps) => Promise<void>>;\n changeElementGroupingNodeState?: HierarchyVisibilityHandlerOverridableMethod<(props: { node: GroupingHierarchyNode; on: boolean }) => Promise<void>>;\n changeElementsState?: HierarchyVisibilityHandlerOverridableMethod<(props: ChangeGeometricElementsDisplayStateProps) => Promise<void>>;\n}\n\n/**\n * Props for `createModelsTreeVisibilityHandler`.\n * @internal\n */\nexport interface ModelsTreeVisibilityHandlerProps {\n viewport: Viewport;\n idsCache: ModelsTreeIdsCache;\n imodelAccess: ECClassHierarchyInspector;\n overrides?: ModelsTreeVisibilityHandlerOverrides;\n filteredPaths?: HierarchyFilteringPath[];\n}\n\n/**\n * Creates an instance if `ModelsTreeVisibilityHandler`.\n * @internal\n */\nexport function createModelsTreeVisibilityHandler(props: ModelsTreeVisibilityHandlerProps): HierarchyVisibilityHandler & Disposable {\n return new ModelsTreeVisibilityHandlerImpl(props);\n}\n\nclass ModelsTreeVisibilityHandlerImpl implements HierarchyVisibilityHandler {\n private readonly _eventListener: IVisibilityChangeEventListener;\n private readonly _alwaysAndNeverDrawnElements: AlwaysAndNeverDrawnElementInfo;\n private readonly _idsCache: ModelsTreeIdsCache;\n private _filteredTree: Promise<FilteredTree> | undefined;\n private _elementChangeQueue = new Subject<Observable<void>>();\n private _subscriptions: Subscription[] = [];\n private _changeRequest = new Subject<{ key: HierarchyNodeKey; depth: number }>();\n\n constructor(private readonly _props: ModelsTreeVisibilityHandlerProps) {\n this._eventListener = createVisibilityChangeEventListener({\n viewport: _props.viewport,\n listeners: {\n models: true,\n categories: true,\n elements: true,\n },\n });\n this._alwaysAndNeverDrawnElements = new AlwaysAndNeverDrawnElementInfo(_props.viewport, CLASS_NAME_GeometricElement3d);\n this._idsCache = this._props.idsCache;\n this._filteredTree = _props.filteredPaths ? createFilteredTree(this._props.imodelAccess, _props.filteredPaths) : undefined;\n this._subscriptions.push(this._elementChangeQueue.pipe(concatAll()).subscribe());\n }\n\n public get onVisibilityChange() {\n return this._eventListener.onVisibilityChange;\n }\n\n public async getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> {\n return firstValueFrom(\n this.getVisibilityStatusObs(node).pipe(\n // unsubscribe from the observable if the change request for this node is received\n takeUntil(this._changeRequest.pipe(filter(({ key, depth }) => depth === node.parentKeys.length && HierarchyNodeKey.equals(node.key, key)))),\n // unsubscribe if visibility changes\n takeUntil(\n fromEventPattern(\n (handler) => {\n this._eventListener.onVisibilityChange.addListener(handler);\n },\n (handler) => {\n this._eventListener.onVisibilityChange.removeListener(handler);\n },\n ),\n ),\n defaultIfEmpty(createVisibilityStatus(\"hidden\")),\n ),\n );\n }\n\n public async changeVisibility(node: HierarchyNode, shouldDisplay: boolean): Promise<void> {\n // notify about new change request\n this._changeRequest.next({ key: node.key, depth: node.parentKeys.length });\n\n const changeObservable = this.changeVisibilityObs(node, shouldDisplay).pipe(\n // unsubscribe from the observable if the change request for this node is received\n takeUntil(this._changeRequest.pipe(filter(({ key, depth }) => depth === node.parentKeys.length && HierarchyNodeKey.equals(node.key, key)))),\n tap({\n subscribe: () => {\n this._eventListener.suppressChangeEvents();\n this._alwaysAndNeverDrawnElements.suppressChangeEvents();\n },\n finalize: () => {\n this._eventListener.resumeChangeEvents();\n this._alwaysAndNeverDrawnElements.resumeChangeEvents();\n },\n }),\n );\n\n return toVoidPromise(changeObservable);\n }\n\n public dispose() {\n this[Symbol.dispose]();\n }\n\n public [Symbol.dispose]() {\n this._eventListener[Symbol.dispose]();\n this._alwaysAndNeverDrawnElements[Symbol.dispose]();\n this._subscriptions.forEach((x) => x.unsubscribe());\n }\n\n private getVisibilityStatusObs(node: HierarchyNode): Observable<VisibilityStatus> {\n if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {\n return this.getFilteredNodeVisibility({ node });\n }\n\n if (HierarchyNode.isClassGroupingNode(node)) {\n return this.getClassGroupingNodeDisplayStatus(node);\n }\n\n if (!HierarchyNode.isInstancesNode(node)) {\n return of(createVisibilityStatus(\"disabled\"));\n }\n\n if (ModelsTreeNode.isSubjectNode(node)) {\n // note: subject nodes may be merged to represent multiple subject instances\n return this.getSubjectNodeVisibilityStatus({ subjectIds: node.key.instanceKeys.map((key) => key.id) });\n }\n\n if (ModelsTreeNode.isModelNode(node)) {\n return this.getModelVisibilityStatus({ modelIds: node.key.instanceKeys.map(({ id }) => id) });\n }\n\n const modelId = ModelsTreeNode.getModelId(node);\n if (!modelId) {\n return of(createVisibilityStatus(\"disabled\"));\n }\n\n if (ModelsTreeNode.isCategoryNode(node)) {\n return this.getCategoryDisplayStatus({\n categoryIds: node.key.instanceKeys.map(({ id }) => id),\n modelId,\n });\n }\n\n const categoryId = ModelsTreeNode.getCategoryId(node);\n if (!categoryId) {\n return of(createVisibilityStatus(\"disabled\"));\n }\n\n return this.getElementDisplayStatus({\n elementId: node.key.instanceKeys[0].id,\n modelId,\n categoryId,\n });\n }\n\n private getFilteredNodeVisibility(props: GetFilteredNodeVisibilityProps) {\n return from(this.getVisibilityChangeTargets(props)).pipe(\n mergeMap(({ subjectIds: subjects, modelIds: models, categories, elements }) => {\n const observables = new Array<Observable<VisibilityStatus>>();\n if (subjects?.size) {\n observables.push(this.getSubjectNodeVisibilityStatus({ subjectIds: [...subjects] }));\n }\n\n if (models?.size) {\n observables.push(this.getModelVisibilityStatus({ modelIds: models }));\n }\n\n if (categories?.size) {\n observables.push(\n from(categories).pipe(\n mergeMap((key) => {\n const { modelId, categoryId } = parseCategoryKey(key);\n return this.getCategoryDisplayStatus({ modelId, categoryIds: categoryId });\n }),\n ),\n );\n }\n\n if (elements?.size) {\n observables.push(\n from(elements).pipe(\n releaseMainThreadOnItemsCount(50),\n mergeMap(([categoryKey, elementIds]) => {\n const { modelId, categoryId } = parseCategoryKey(categoryKey);\n return from(elementIds).pipe(\n releaseMainThreadOnItemsCount(1000),\n mergeMap((elementId) => this.getElementDisplayStatus({ modelId, categoryId, elementId })),\n );\n }),\n ),\n );\n }\n\n return merge(...observables);\n }),\n mergeVisibilityStatuses,\n );\n }\n\n private getSubjectNodeVisibilityStatus({ subjectIds }: { subjectIds: Id64Array }): Observable<VisibilityStatus> {\n const result = defer(() => {\n if (!this._props.viewport.view.isSpatialView()) {\n return of(createVisibilityStatus(\"disabled\"));\n }\n\n return from(this._idsCache.getSubjectModelIds(subjectIds)).pipe(\n mergeMap((modelIds) => this.getModelVisibilityStatus({ modelIds })),\n mergeVisibilityStatuses,\n );\n });\n return createVisibilityHandlerResult(this, { ids: subjectIds }, result, this._props.overrides?.getSubjectNodeVisibility);\n }\n\n private getModelVisibilityStatus({ modelIds }: { modelIds: Id64Set | Id64Array }): Observable<VisibilityStatus> {\n const result = defer(() => {\n const viewport = this._props.viewport;\n if (!viewport.view.isSpatialView()) {\n return of(createVisibilityStatus(\"disabled\"));\n }\n\n return from(modelIds).pipe(\n distinct(),\n mergeMap((modelId) => {\n if (!viewport.view.viewsModel(modelId)) {\n return from(this._idsCache.getModelCategoryIds(modelId)).pipe(\n mergeMap((categoryIds) => from(this._idsCache.getCategoriesModeledElements(modelId, categoryIds))),\n getSubModeledElementsVisibilityStatus({\n parentNodeVisibilityStatus: createVisibilityStatus(\"hidden\"),\n getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),\n }),\n );\n }\n\n return from(this._idsCache.getModelCategoryIds(modelId)).pipe(\n mergeMap((categoryIds) =>\n categoryIds.length === 0 ? of(createVisibilityStatus(\"visible\")) : this.getCategoryDisplayStatus({ modelId, categoryIds }),\n ),\n mergeVisibilityStatuses,\n );\n }),\n mergeVisibilityStatuses,\n );\n });\n return createVisibilityHandlerResult(this, { ids: modelIds }, result, this._props.overrides?.getModelDisplayStatus);\n }\n\n private getDefaultCategoryVisibilityStatus({ modelId, categoryIds }: { categoryIds: Id64Arg; modelId: Id64String }): VisibilityStatus {\n const viewport = this._props.viewport;\n\n if (!viewport.view.viewsModel(modelId) || Id64.sizeOf(categoryIds) === 0) {\n return createVisibilityStatus(\"hidden\");\n }\n\n let visibility: \"visible\" | \"hidden\" | \"unknown\" = \"unknown\";\n for (const categoryId of Id64.iterable(categoryIds)) {\n const override = this._props.viewport.perModelCategoryVisibility.getOverride(modelId, categoryId);\n if (override === PerModelCategoryVisibility.Override.Show) {\n if (visibility === \"hidden\") {\n return createVisibilityStatus(\"partial\");\n }\n visibility = \"visible\";\n continue;\n }\n if (override === PerModelCategoryVisibility.Override.Hide) {\n if (visibility === \"visible\") {\n return createVisibilityStatus(\"partial\");\n }\n visibility = \"hidden\";\n continue;\n }\n const isVisible = viewport.view.viewsCategory(categoryId);\n if (isVisible && visibility === \"hidden\") {\n return createVisibilityStatus(\"partial\");\n }\n if (!isVisible && visibility === \"visible\") {\n return createVisibilityStatus(\"partial\");\n }\n visibility = isVisible ? \"visible\" : \"hidden\";\n }\n assert(visibility !== \"unknown\");\n\n return createVisibilityStatus(visibility);\n }\n\n private getCategoryDisplayStatus(props: GetCategoryVisibilityStatusProps): Observable<VisibilityStatus> {\n const result = defer(() => {\n if (!this._props.viewport.view.viewsModel(props.modelId)) {\n return from(this._idsCache.getCategoriesModeledElements(props.modelId, props.categoryIds)).pipe(\n getSubModeledElementsVisibilityStatus({\n parentNodeVisibilityStatus: createVisibilityStatus(\"hidden\"),\n getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),\n }),\n );\n }\n\n return this.getVisibilityFromAlwaysAndNeverDrawnElements({\n categoryProps: { categoryIds: props.categoryIds, modelId: props.modelId },\n defaultStatus: (categoryId) =>\n categoryId\n ? this.getDefaultCategoryVisibilityStatus({ modelId: props.modelId, categoryIds: categoryId })\n : this.getDefaultCategoryVisibilityStatus({ modelId: props.modelId, categoryIds: props.categoryIds }),\n }).pipe(\n mergeMap((visibilityStatusAlwaysAndNeverDraw) => {\n return from(this._idsCache.getCategoriesModeledElements(props.modelId, props.categoryIds)).pipe(\n getSubModeledElementsVisibilityStatus({\n parentNodeVisibilityStatus: visibilityStatusAlwaysAndNeverDraw,\n getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),\n }),\n );\n }),\n );\n });\n return createVisibilityHandlerResult(this, props, result, this._props.overrides?.getCategoryDisplayStatus);\n }\n\n private getClassGroupingNodeDisplayStatus(node: GroupingHierarchyNode): Observable<VisibilityStatus> {\n const result = defer(() => {\n const info = this.getGroupingNodeInfo(node);\n\n const { modelId, categoryId, elementIds } = info;\n if (!this._props.viewport.view.viewsModel(modelId)) {\n return of([...elementIds]).pipe(\n filterSubModeledElementIds({ doesSubModelExist: async (id) => this._idsCache.hasSubModel(id) }),\n getSubModeledElementsVisibilityStatus({\n parentNodeVisibilityStatus: createVisibilityStatus(\"hidden\"),\n getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),\n }),\n );\n }\n\n return this.getVisibilityFromAlwaysAndNeverDrawnElements({\n elements: elementIds,\n defaultStatus: () => this.getDefaultCategoryVisibilityStatus({ categoryIds: categoryId, modelId }),\n }).pipe(\n mergeMap((visibilityStatusAlwaysAndNeverDraw) => {\n return of([...elementIds]).pipe(\n filterSubModeledElementIds({ doesSubModelExist: async (id) => this._idsCache.hasSubModel(id) }),\n getSubModeledElementsVisibilityStatus({\n parentNodeVisibilityStatus: visibilityStatusAlwaysAndNeverDraw,\n getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),\n }),\n );\n }),\n );\n });\n return createVisibilityHandlerResult(this, { node }, result, this._props.overrides?.getElementGroupingNodeDisplayStatus);\n }\n\n private getElementDisplayStatus(props: GetGeometricElementVisibilityStatusProps): Observable<VisibilityStatus> {\n const result: Observable<VisibilityStatus> = defer(() => {\n const viewport = this._props.viewport;\n const { elementId, modelId, categoryId } = props;\n\n const viewsModel = viewport.view.viewsModel(modelId);\n const elementStatus = getElementOverriddenVisibility({\n elementId,\n viewport,\n });\n\n return from(this._idsCache.hasSubModel(elementId)).pipe(\n mergeMap((hasSubModel) => (hasSubModel ? this.getModelVisibilityStatus({ modelIds: [elementId] }) : of(undefined))),\n map((subModelVisibilityStatus) =>\n getElementVisibility(\n viewsModel,\n elementStatus,\n // Single category will always return \"visible\" or \"hidden\"\n this.getDefaultCategoryVisibilityStatus({ categoryIds: categoryId, modelId }) as NonPartialVisibilityStatus,\n subModelVisibilityStatus,\n ),\n ),\n );\n });\n return createVisibilityHandlerResult(this, props, result, this._props.overrides?.getElementDisplayStatus);\n }\n\n /** Changes visibility of the items represented by the tree node. */\n private changeVisibilityObs(node: HierarchyNode, on: boolean): Observable<void> {\n if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {\n return this.changeFilteredNodeVisibility({ node, on });\n }\n\n if (HierarchyNode.isClassGroupingNode(node)) {\n return this.changeElementGroupingNodeState(node, on);\n }\n\n if (!HierarchyNode.isInstancesNode(node)) {\n return EMPTY;\n }\n\n if (ModelsTreeNode.isSubjectNode(node)) {\n return this.changeSubjectNodeState(\n node.key.instanceKeys.map((key) => key.id),\n on,\n );\n }\n\n if (ModelsTreeNode.isModelNode(node)) {\n return this.changeModelState({ ids: node.key.instanceKeys.map(({ id }) => id), on });\n }\n\n const modelId = ModelsTreeNode.getModelId(node);\n if (!modelId) {\n return EMPTY;\n }\n\n if (ModelsTreeNode.isCategoryNode(node)) {\n return this.changeCategoryState({\n categoryIds: node.key.instanceKeys.map(({ id }) => id),\n modelId,\n on,\n });\n }\n\n const categoryId = ModelsTreeNode.getCategoryId(node);\n if (!categoryId) {\n return EMPTY;\n }\n\n return this.changeElementsState({\n elementIds: new Set([...node.key.instanceKeys.map(({ id }) => id)]),\n modelId,\n categoryId,\n on,\n });\n }\n\n private async getVisibilityChangeTargets({ node }: GetFilteredNodeVisibilityProps) {\n const filteredTree = await this._filteredTree;\n return filteredTree ? filteredTree.getVisibilityChangeTargets(node) : {};\n }\n\n private changeFilteredNodeVisibility({ on, ...props }: ChangeFilteredNodeVisibilityProps) {\n return from(this.getVisibilityChangeTargets(props)).pipe(\n mergeMap(({ subjectIds: subjects, modelIds: models, categories, elements }) => {\n const observables = new Array<Observable<void>>();\n if (subjects?.size) {\n observables.push(this.changeSubjectNodeState([...subjects], on));\n }\n\n if (models?.size) {\n observables.push(this.changeModelState({ ids: models, on }));\n }\n\n if (categories?.size) {\n observables.push(\n from(categories).pipe(\n mergeMap((key) => {\n const { modelId, categoryId } = parseCategoryKey(key);\n return this.changeCategoryState({ modelId, categoryIds: categoryId, on });\n }),\n ),\n );\n }\n\n if (elements?.size) {\n observables.push(\n from(elements).pipe(\n mergeMap(([categoryKey, elementIds]) => {\n const { modelId, categoryId } = parseCategoryKey(categoryKey);\n return this.changeElementsState({ modelId, categoryId, elementIds, on });\n }),\n ),\n );\n }\n\n return merge(...observables);\n }),\n );\n }\n\n private changeSubjectNodeState(subjectIds: Id64Array, on: boolean): Observable<void> {\n const result = defer(() => {\n if (!this._props.viewport.view.isSpatialView()) {\n return EMPTY;\n }\n\n return from(this._idsCache.getSubjectModelIds(subjectIds)).pipe(mergeMap((modelIds) => this.changeModelState({ ids: modelIds, on })));\n });\n return createVisibilityHandlerResult(this, { ids: subjectIds, on }, result, this._props.overrides?.changeSubjectNodeState);\n }\n\n private changeModelState(props: ChangeModelVisibilityStateProps): Observable<void> {\n const { ids, on } = props;\n\n if (Id64.sizeOf(ids) === 0) {\n return EMPTY;\n }\n\n const result = defer(() => {\n const viewport = this._props.viewport;\n if (!viewport.view.isSpatialView()) {\n return EMPTY;\n }\n\n const idsObs = from(Id64.iterable(ids));\n if (!on) {\n viewport.changeModelDisplay(ids, false);\n return idsObs.pipe(\n mergeMap(async (modelId) => ({ modelId, categoryIds: await this._idsCache.getModelCategoryIds(modelId) })),\n mergeMap(({ modelId, categoryIds }) => from(this._idsCache.getCategoriesModeledElements(modelId, categoryIds))),\n mergeMap((modeledElementIds) => this.changeModelState({ ids: modeledElementIds, on })),\n );\n }\n\n return concat(\n defer(() => {\n viewport.perModelCategoryVisibility.clearOverrides(ids);\n return from(viewport.addViewedModels(ids));\n }),\n idsObs.pipe(\n mergeMap((modelId) => {\n return from(this._idsCache.getModelCategoryIds(modelId)).pipe(\n mergeMap((categoryIds) => this.changeCategoryState({ categoryIds, modelId, on: true })),\n );\n }),\n ),\n );\n });\n return createVisibilityHandlerResult(this, props, result, this._props.overrides?.changeModelState);\n }\n\n private showModelWithoutAnyCategoriesOrElements(modelId: Id64String): Observable<void> {\n const viewport = this._props.viewport;\n return forkJoin({\n categories: this._idsCache.getModelCategoryIds(modelId),\n alwaysDrawnElements: this._alwaysAndNeverDrawnElements.getAlwaysDrawnElements({ modelId }),\n }).pipe(\n mergeMap(async ({ categories, alwaysDrawnElements }) => {\n const alwaysDrawn = this._props.viewport.alwaysDrawn;\n if (alwaysDrawn && alwaysDrawnElements) {\n viewport.setAlwaysDrawn(setDifference(alwaysDrawn, alwaysDrawnElements));\n }\n categories.forEach((categoryId) => {\n this.changeCategoryStateInViewportAccordingToModelVisibility(modelId, categoryId, false);\n });\n await viewport.addViewedModels(modelId);\n }),\n );\n }\n\n private changeCategoryStateInViewportAccordingToModelVisibility(modelId: Id64String, categoryId: Id64String, on: boolean) {\n const viewport = this._props.viewport;\n const isDisplayedInSelector = viewport.view.viewsCategory(categoryId);\n const override =\n on === isDisplayedInSelector\n ? PerModelCategoryVisibility.Override.None\n : on\n ? PerModelCategoryVisibility.Override.Show\n : PerModelCategoryVisibility.Override.Hide;\n viewport.perModelCategoryVisibility.setOverride(modelId, categoryId, override);\n if (override === PerModelCategoryVisibility.Override.None && on) {\n // we took off the override which means the category is displayed in selector, but\n // doesn't mean all its subcategories are displayed - this call ensures that\n viewport.changeCategoryDisplay(categoryId, true, true);\n }\n }\n\n private changeCategoryState(props: ChangeCategoryVisibilityStateProps): Observable<void> {\n const result = defer(() => {\n const viewport = this._props.viewport;\n const { modelId, categoryIds, on } = props;\n return concat(\n props.on && !viewport.view.viewsModel(modelId) ? this.showModelWithoutAnyCategoriesOrElements(modelId) : EMPTY,\n defer(() => {\n for (const categoryId of Id64.iterable(categoryIds)) {\n this.changeCategoryStateInViewportAccordingToModelVisibility(modelId, categoryId, on);\n }\n return this._alwaysAndNeverDrawnElements.clearAlwaysAndNeverDrawnElements(props);\n }),\n from(this._idsCache.getCategoriesModeledElements(modelId, categoryIds)).pipe(\n mergeMap((modeledElementIds) => this.changeModelState({ ids: modeledElementIds, on })),\n ),\n );\n });\n return createVisibilityHandlerResult(this, props, result, this._props.overrides?.changeCategoryState);\n }\n\n private doChangeElementsState(props: ChangeGeometricElementsDisplayStateProps): Observable<void | undefined> {\n return defer(() => {\n const { modelId, categoryId, elementIds, on } = props;\n const viewport = this._props.viewport;\n return concat(\n on && !viewport.view.viewsModel(modelId) ? this.showModelWithoutAnyCategoriesOrElements(modelId) : EMPTY,\n defer(() => {\n const categoryVisibility = this.getDefaultCategoryVisibilityStatus({ categoryIds: categoryId, modelId });\n const isDisplayedByDefault = categoryVisibility.state === \"visible\";\n return this.queueElementsVisibilityChange(elementIds, on, isDisplayedByDefault);\n }),\n from(elementIds).pipe(\n mergeMap(async (elementId) => ({ elementId, isSubModel: await this._idsCache.hasSubModel(elementId) })),\n filter(({ isSubModel }) => isSubModel),\n map(({ elementId }) => elementId),\n toArray(),\n mergeMap((subModelIds) => this.changeModelState({ ids: subModelIds, on })),\n ),\n );\n });\n }\n\n /**\n * Updates visibility of all grouping node's elements.\n * @see `changeElementState`\n */\n private changeElementGroupingNodeState(node: GroupingHierarchyNode, on: boolean): Observable<void> {\n const result = this.doChangeElementsState({ ...this.getGroupingNodeInfo(node), on });\n return createVisibilityHandlerResult(this, { node, on }, result, this._props.overrides?.changeElementGroupingNodeState);\n }\n\n /**\n * Updates visibility of an element and all its child elements by adding them to the always/never drawn list.\n * @note If element is to be enabled and model is hidden, it will be enabled.\n */\n private changeElementsState(props: ChangeGeometricElementsDisplayStateProps): Observable<void> {\n const result = this.doChangeElementsState(props);\n return createVisibilityHandlerResult(this, props, result, this._props.overrides?.changeElementsState);\n }\n\n private queueElementsVisibilityChange(elementIds: Id64Set, on: boolean, visibleByDefault: boolean) {\n const finishedSubject = new Subject<boolean>();\n // observable to track if visibility change is finished/cancelled\n const changeFinished = finishedSubject.pipe(\n startWith(false),\n shareReplay(1),\n filter((finished) => finished),\n );\n\n const changeObservable = from(elementIds).pipe(\n // check if visibility change is not finished (cancelled) due to change overall change request being cancelled\n takeUntil(changeFinished),\n changeElementStateNoChildrenOperator({ on, isDisplayedByDefault: visibleByDefault, viewport: this._props.viewport }),\n tap({\n next: () => {\n // notify that visibility change is finished\n finishedSubject.next(true);\n },\n }),\n );\n\n // queue visibility change. `changeObservable` will be subscribed to when other queue changes are finished\n this._elementChangeQueue.next(changeObservable);\n\n // return observable that will emit when visibility change is finished\n return changeFinished.pipe(\n take(1),\n tap({\n unsubscribe: () => {\n // if this observable is unsubscribed before visibility change is finished, we have to notify that it queued change request is cancelled\n finishedSubject.next(true);\n },\n }),\n map(() => undefined),\n );\n }\n\n private getVisibilityFromAlwaysAndNeverDrawnElements(\n props: GetVisibilityFromAlwaysAndNeverDrawnElementsProps &\n ({ elements: Set<ElementId> } | { categoryProps: { categoryIds: Id64Arg; modelId: Id64String } }),\n ): Observable<VisibilityStatus> {\n const viewport = this._props.viewport;\n if (viewport.isAlwaysDrawnExclusive) {\n if (!viewport?.alwaysDrawn?.size) {\n return of(createVisibilityStatus(\"hidden\"));\n }\n } else if (!viewport?.neverDrawn?.size && !viewport?.alwaysDrawn?.size) {\n return of(props.defaultStatus());\n }\n\n if (\"elements\" in props) {\n return of(\n getVisibilityFromAlwaysAndNeverDrawnElementsImpl({\n ...props,\n alwaysDrawn: viewport.alwaysDrawn?.size ? setIntersection(props.elements, viewport.alwaysDrawn) : undefined,\n neverDrawn: viewport.neverDrawn?.size ? setIntersection(props.elements, viewport.neverDrawn) : undefined,\n totalCount: props.elements.size,\n viewport,\n }),\n );\n }\n\n const { modelId, categoryIds } = props.categoryProps;\n return from(Id64.iterable(categoryIds)).pipe(\n mergeMap((categoryId) => {\n const totalCount = this._idsCache.getCategoryElementsCount(modelId, categoryId);\n return forkJoin({\n totalCount,\n alwaysDrawn: this._alwaysAndNeverDrawnElements.getAlwaysDrawnElements({ categoryIds: categoryId, modelId }),\n neverDrawn: this._alwaysAndNeverDrawnElements.getNeverDrawnElements({ categoryIds: categoryId, modelId }),\n }).pipe(\n map((state) => {\n return getVisibilityFromAlwaysAndNeverDrawnElementsImpl({\n ...props,\n ...state,\n defaultStatus: () => props.defaultStatus(categoryId),\n viewport,\n });\n }),\n );\n }),\n mergeVisibilityStatuses,\n );\n }\n\n private getGroupingNodeInfo(node: GroupingHierarchyNode) {\n const modelId = ModelsTreeNode.getModelId(node);\n const categoryId = ModelsTreeNode.getCategoryId(node);\n assert(!!modelId && !!categoryId);\n\n const elementIds = new Set(node.groupedInstanceKeys.map((key) => key.id));\n return { modelId, categoryId, elementIds };\n }\n}\n"]}
|