@itwin/tree-widget-react 3.14.0 → 3.14.2
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 +19 -2
- package/README.md +3 -0
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +2 -0
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.d.ts +2 -2
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +22 -10
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +2 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +1 -0
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.d.ts +17 -0
- package/lib/cjs/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js +49 -0
- package/lib/cjs/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js.map +1 -0
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +4 -0
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +3 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +4 -4
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js +16 -23
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +8 -11
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +67 -76
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +13 -9
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +7 -7
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +2 -0
- 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/UseCategoriesTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +22 -10
- 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 +2 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.d.ts +17 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js +46 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js.map +1 -0
- 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/models-tree/ModelsTreeButtons.js +3 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +1 -1
- 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 +4 -4
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +16 -23
- 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/AlwaysAndNeverDrawnElementInfo.d.ts +8 -11
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +68 -77
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +13 -9
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +7 -7
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react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;QACrC,CAAC;IACH,CAAC;YAAS,CAAC;QACT,KAAK,WAAW,CAAC,WAAW,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,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 { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgFolder, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from \"@itwin/itwinui-icons-react\";\nimport { Anchor, Text } from \"@itwin/itwinui-react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { HierarchyFilteringPath, HierarchyNode, HierarchyNodeIdentifier, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors.js\";\nimport { useIModelChangeListener } from \"../common/UseIModelChangeListener.js\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext.js\";\nimport { joinHierarchyFilteringPaths } from \"../common/Utils.js\";\nimport { ModelsTreeIdsCache } from \"./internal/ModelsTreeIdsCache.js\";\nimport { ModelsTreeNode } from \"./internal/ModelsTreeNode.js\";\nimport { createModelsTreeVisibilityHandler } from \"./internal/ModelsTreeVisibilityHandler.js\";\nimport { defaultHierarchyConfiguration, ModelsTreeDefinition } from \"./ModelsTreeDefinition.js\";\n\nimport type { NormalizedHierarchyFilteringPath } from \"../common/Utils.js\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { GroupingHierarchyNode, HierarchyNodeIdentifiersPath, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport type { ReactElement } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { ClassGroupingHierarchyNode, ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from \"./ModelsTreeDefinition.js\";\nimport type { ModelsTreeVisibilityHandlerOverrides } from \"./internal/ModelsTreeVisibilityHandler.js\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { VisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\n\ntype ModelsTreeFilteringError = \"tooManyFilterMatches\" | \"tooManyInstancesFocused\" | \"unknownFilterError\" | \"unknownInstanceFocusError\";\ntype ModelsTreeSubTreeError = \"unknownSubTreeError\";\n\n/** @beta */\nexport interface UseModelsTreeProps {\n /**\n * Optional search string used to filter tree nodes by label, as well as highlight matching substrings in the tree.\n * Nodes that do not contain this string in their label will be filtered out.\n *\n * If `getFilteredPaths` function is provided, it will take precedence and automatic filtering by this string will not be applied.\n * Instead, the string will be supplied to the given `getFilteredPaths` function for consumers to apply the filtering.\n */\n filter?: string;\n activeView: Viewport;\n hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;\n visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;\n /**\n * Optional function for applying custom filtering on the hierarchy. Use it when you want full control over which nodes should be displayed, based on more complex logic or known instance keys.\n *\n * When defined, this function takes precedence over filtering by `filter` string. If both are supplied, the `filter` is provided as an argument to `getFilteredPaths`.\n *\n * @param props Parameters provided when `getFilteredPaths` is called:\n * - `createInstanceKeyPaths`: Helper function to create filter paths.\n * - `filter`: The filter string which would otherwise be used for default filtering.\n *\n * **Example use cases:**\n * - You have a list of `InstanceKey` items, which you want to use for filtering the hierarchy.\n * - You want to create filter paths based on node label, but also apply some extra conditions (for example exclude paths with sub-models).\n * - You want to construct custom filtered paths. For example: create a filter path for each geometric element which has a parent element.\n *\n * @note Paths returned by `createInstanceKeyPaths` will not have `autoExpand` flag set. If you want nodes to be expanded, iterate over the paths and\n * set `autoExpand: true` manually.\n */\n getFilteredPaths?: (props: {\n /** A function that creates filtering paths based on provided target instance keys or node label. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> } | { label: string }) => Promise<NormalizedHierarchyFilteringPath[]>;\n /** Filter which would be used to create filter paths if `getFilteredPaths` wouldn't be provided. */\n filter?: string;\n }) => Promise<HierarchyFilteringPath[] | undefined>;\n /**\n * Optional function for restricting the visible hierarchy to a specific sub-tree of nodes, without changing how filtering works.\n *\n * Use when you want to display only part of the hierarchy, but still allow normal filtering within that sub-tree.\n *\n * When defined, only nodes that are in the provided paths or children of target nodes will be part of the hierarchy.\n * Filtering (by label or custom logic) will still apply within this sub-tree.\n *\n * Key difference:\n * - `getFilteredPaths` determines which nodes should be shown, giving you full control over filtering logic.\n * - `getSubTreePaths` restricts the hierarchy to a sub-tree, but does not override the filtering logic — filtering is still applied within the restricted sub-tree.\n */\n getSubTreePaths?: (props: {\n /** A function that creates filtering paths based on provided target instance keys. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> }) => Promise<NormalizedHierarchyFilteringPath[]>;\n }) => Promise<HierarchyFilteringPath[]>;\n onModelsFiltered?: (modelIds: Id64String[] | undefined) => void;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (props: { node: PresentationHierarchyNode; type: \"subject\" | \"model\" | \"category\" | \"element\" | \"elements-class-group\" }) => boolean;\n}\n\n/** @beta */\ninterface UseModelsTreeResult {\n modelsTreeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"visibilityHandlerFactory\" | \"highlight\" | \"noDataMessage\" | \"selectionPredicate\"\n >;\n rendererProps: Required<Pick<VisibilityTreeRendererProps, \"getIcon\" | \"onNodeDoubleClick\">>;\n}\n\n/**\n * Custom hook to create and manage state for the models tree.\n * @beta\n */\nexport function useModelsTree({\n activeView,\n filter,\n hierarchyConfig,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n selectionPredicate: nodeTypeSelectionPredicate,\n getSubTreePaths,\n}: UseModelsTreeProps): UseModelsTreeResult {\n const [filteringError, setFilteringError] = useState<ModelsTreeFilteringError | undefined>(undefined);\n const [subTreeError, setSubTreeError] = useState<ModelsTreeSubTreeError | undefined>(undefined);\n const hierarchyConfiguration = useMemo<ModelsTreeHierarchyConfiguration>(\n () => ({\n ...defaultHierarchyConfiguration,\n ...hierarchyConfig,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfig ?? {}),\n );\n const { onFeatureUsed } = useTelemetryContext();\n\n const { getModelsTreeIdsCache, visibilityHandlerFactory, onFilteredPathsChanged } = useCachedVisibility(\n activeView,\n hierarchyConfiguration,\n visibilityHandlerOverrides,\n );\n const { loadFocusedItems } = useFocusedInstancesContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => new ModelsTreeDefinition({ imodelAccess, idsCache: getModelsTreeIdsCache(), hierarchyConfig: hierarchyConfiguration }),\n [getModelsTreeIdsCache, hierarchyConfiguration],\n );\n\n const onNodeDoubleClick = useCallback(\n async ({ nodeData, extendedData }: PresentationHierarchyNode) => {\n if (!HierarchyNode.isInstancesNode(nodeData) || (extendedData && (extendedData.isSubject || extendedData.isModel || extendedData.isCategory))) {\n return;\n }\n const instanceIds = nodeData.key.instanceKeys.map((instanceKey) => instanceKey.id);\n await IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);\n onFeatureUsed({ featureId: \"zoom-to-node\", reportInteraction: false });\n },\n [onFeatureUsed],\n );\n\n const getSubTreePathsInternal = useMemo<\n ((...props: Parameters<Required<VisibilityTreeProps>[\"getFilteredPaths\"]>) => Promise<HierarchyNodeIdentifiersPath[]>) | undefined\n >(() => {\n if (!getSubTreePaths) {\n return undefined;\n }\n return async ({ imodelAccess, abortSignal }) => {\n try {\n const paths = await getSubTreePaths({\n createInstanceKeyPaths: async ({ targetItems }) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n targetItems,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n abortSignal,\n }),\n });\n return paths.map(HierarchyFilteringPath.normalize).map(({ path }) => path);\n } catch (e) {\n const newError = \"unknownSubTreeError\";\n setSubTreeError(newError);\n return [];\n }\n };\n }, [getModelsTreeIdsCache, hierarchyConfiguration, getSubTreePaths]);\n\n const getPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n onModelsFiltered?.(undefined);\n\n // reset filtered paths if there is no filters applied. This allows to keep current filtered paths until new paths are loaded.\n if (!loadFocusedItems && !getFilteredPaths && !filter && !getSubTreePathsInternal) {\n onFilteredPathsChanged(undefined);\n }\n\n const handlePaths = async (filteredPaths: HierarchyFilteringPath[] | undefined, classInspector: ECClassHierarchyInspector) => {\n onFilteredPathsChanged(filteredPaths);\n if (!onModelsFiltered) {\n return;\n }\n\n const modelIds = filteredPaths ? await getModels(filteredPaths, getModelsTreeIdsCache(), classInspector) : undefined;\n onModelsFiltered(modelIds);\n };\n\n if (loadFocusedItems) {\n return async ({ imodelAccess, abortSignal }) => {\n try {\n const focusedItems = await collectFocusedItems(loadFocusedItems);\n return await createFilteringPathsResult({\n getFilteringPaths: async () => {\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n targetItems: focusedItems,\n hierarchyConfig: hierarchyConfiguration,\n abortSignal,\n });\n return paths.map(({ path, options }) => ({ path, options: { ...options, autoExpand: true } }));\n },\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyInstancesFocused\" : \"unknownInstanceFocusError\";\n if (newError !== \"tooManyInstancesFocused\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (getFilteredPaths) {\n return async ({ imodelAccess, abortSignal }) => {\n try {\n return await createFilteringPathsResult({\n getFilteringPaths: async () => {\n const paths = await getFilteredPaths({\n createInstanceKeyPaths: async (props) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n ...props,\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n abortSignal,\n }),\n filter,\n });\n return paths?.map(HierarchyFilteringPath.normalize);\n },\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (filter) {\n return async ({ imodelAccess, abortSignal }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n return await createFilteringPathsResult({\n getFilteringPaths: async () => {\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: filter,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n abortSignal,\n });\n return paths.map(({ path, options }) => ({ path, options: { ...options, autoExpand: true } }));\n },\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n return getSubTreePathsInternal;\n }, [\n filter,\n loadFocusedItems,\n getModelsTreeIdsCache,\n onFeatureUsed,\n getFilteredPaths,\n hierarchyConfiguration,\n onModelsFiltered,\n onFilteredPathsChanged,\n getSubTreePathsInternal,\n ]);\n\n const nodeSelectionPredicate = useCallback<NonNullable<VisibilityTreeProps[\"selectionPredicate\"]>>(\n (node) => {\n if (!nodeTypeSelectionPredicate) {\n return true;\n }\n return nodeTypeSelectionPredicate({ node, type: ModelsTreeNode.getType(node.nodeData) });\n },\n [nodeTypeSelectionPredicate],\n );\n\n return {\n modelsTreeProps: {\n treeName: \"models-tree-v2\",\n visibilityHandlerFactory,\n getHierarchyDefinition,\n getFilteredPaths: getPaths,\n noDataMessage: getNoDataMessage(filter, subTreeError, filteringError),\n highlight: filter ? { text: filter } : undefined,\n selectionPredicate: nodeSelectionPredicate,\n },\n rendererProps: {\n onNodeDoubleClick,\n getIcon,\n },\n };\n}\n\nasync function getModels(paths: HierarchyFilteringPath[], idsCache: ModelsTreeIdsCache, classInspector: ECClassHierarchyInspector) {\n if (!paths) {\n return undefined;\n }\n\n const targetModels = new Set<Id64String>();\n const targetSubjects = new Set<Id64String>();\n for (const path of paths) {\n const currPath = Array.isArray(path) ? path : path.path;\n for (let i = 0; i < currPath.length; i++) {\n const currStep = currPath[i];\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(currStep)) {\n break;\n }\n\n // if paths end with subject need to get all models under that subject\n if (i === currPath.length - 1 && currStep.className === \"BisCore.Subject\") {\n targetSubjects.add(currStep.id);\n break;\n }\n\n // collect all the models from the filtered path\n if (await classInspector.classDerivesFrom(currStep.className, \"BisCore.GeometricModel3d\")) {\n targetModels.add(currStep.id);\n }\n }\n }\n\n const matchingModels = await idsCache.getSubjectModelIds([...targetSubjects]);\n return [...targetModels, ...matchingModels];\n}\n\nfunction getNoDataMessage(filter?: string, subTreeError?: ModelsTreeSubTreeError, filteringError?: ModelsTreeFilteringError) {\n if (isSubTreeError(subTreeError)) {\n return <Text>{TreeWidget.translate(`modelsTree.subTree.${subTreeError}`)}</Text>;\n }\n if (isInstanceFocusError(filteringError)) {\n return <InstanceFocusError error={filteringError} />;\n }\n if (isFilterError(filteringError)) {\n return <Text>{TreeWidget.translate(`modelsTree.filtering.${filteringError}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"modelsTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction isSubTreeError(error: ModelsTreeSubTreeError | undefined) {\n return error === \"unknownSubTreeError\";\n}\n\nfunction isFilterError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyFilterMatches\" || error === \"unknownFilterError\";\n}\n\nfunction isInstanceFocusError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyInstancesFocused\" || error === \"unknownInstanceFocusError\";\n}\n\nfunction InstanceFocusError({ error }: { error: ModelsTreeFilteringError }) {\n const { toggle } = useFocusedInstancesContext();\n const localizedMessage = createLocalizedMessage(TreeWidget.translate(`modelsTree.filtering.${error}`), () => toggle());\n return <Text>{localizedMessage}</Text>;\n}\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return <SvgLayers />;\n case \"icon-item\":\n return <SvgItem />;\n case \"icon-ec-class\":\n return <SvgClassGrouping />;\n case \"icon-imodel-hollow-2\":\n return <SvgImodelHollow />;\n case \"icon-folder\":\n return <SvgFolder />;\n case \"icon-model\":\n return <SvgModel />;\n }\n\n return undefined;\n}\n\nfunction createVisibilityHandlerFactory(\n activeView: Viewport,\n idsCacheGetter: () => ModelsTreeIdsCache,\n overrides?: ModelsTreeVisibilityHandlerOverrides,\n filteredPaths?: HierarchyFilteringPath[],\n): VisibilityTreeProps[\"visibilityHandlerFactory\"] {\n return ({ imodelAccess }) => createModelsTreeVisibilityHandler({ viewport: activeView, idsCache: idsCacheGetter(), imodelAccess, overrides, filteredPaths });\n}\n\nfunction useCachedVisibility(activeView: Viewport, hierarchyConfig: ModelsTreeHierarchyConfiguration, overrides?: ModelsTreeVisibilityHandlerOverrides) {\n const cacheRef = useRef<ModelsTreeIdsCache>();\n const currentIModelRef = useRef(activeView.iModel);\n\n const resetModelsTreeIdsCache = () => {\n cacheRef.current?.[Symbol.dispose]();\n cacheRef.current = undefined;\n };\n const getModelsTreeIdsCache = useCallback(() => {\n if (!cacheRef.current) {\n cacheRef.current = new ModelsTreeIdsCache(createECSqlQueryExecutor(currentIModelRef.current), hierarchyConfig);\n }\n return cacheRef.current;\n }, [hierarchyConfig]);\n\n const [filteredPaths, setFilteredPaths] = useState<HierarchyFilteringPath[]>();\n const [visibilityHandlerFactory, setVisibilityHandlerFactory] = useState<VisibilityTreeProps[\"visibilityHandlerFactory\"]>(() =>\n createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides, filteredPaths),\n );\n\n useIModelChangeListener({\n imodel: activeView.iModel,\n action: useCallback(() => {\n resetModelsTreeIdsCache();\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides, filteredPaths));\n }, [activeView, getModelsTreeIdsCache, overrides, filteredPaths]),\n });\n\n useEffect(() => {\n currentIModelRef.current = activeView.iModel;\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides, filteredPaths));\n return () => resetModelsTreeIdsCache();\n }, [activeView, getModelsTreeIdsCache, overrides, filteredPaths]);\n\n return {\n getModelsTreeIdsCache,\n visibilityHandlerFactory,\n onFilteredPathsChanged: useCallback((paths: HierarchyFilteringPath[] | undefined) => setFilteredPaths(paths), []),\n };\n}\n\nfunction SvgClassGrouping() {\n return (\n <svg id=\"Calque_1\" data-name=\"Calque 1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <path d=\"M8.00933,0,0,3.97672V11.986L8.00933,16,16,11.93V3.97651ZM1.66173,11.27642c-.26155.03734-.59754-.26154-.76553-.69085-.168-.41066-.09334-.784.168-.82152.26154-.03734.59754.26154.76553.67219C1.99772,10.86577,1.92306,11.23909,1.66173,11.27642Zm0-3.32319c-.26155.03733-.59754-.28-.76553-.69086-.168-.42932-.09334-.80285.168-.84.26133-.03733.59754.28.76532.69086C1.99772,7.54236,1.92306,7.89723,1.66173,7.95323Zm4.31276,5.52621a.18186.18186,0,0,1-.16821-.01866L3.41657,12.15394a.94275.94275,0,0,1-.29887-.80285c.03754-.33621.22421-.52265.41108-.41066L5.9185,12.24727a.88656.88656,0,0,1,.28.80285A.5057.5057,0,0,1,5.97449,13.47944Zm0-3.37919a.18184.18184,0,0,1-.16821-.01867L3.41657,8.77475a.943.943,0,0,1-.29887-.80286c.03754-.3362.22421-.52286.41108-.42953L5.9185,8.86786a.83112.83112,0,0,1,.28.78419A.51684.51684,0,0,1,5.97449,10.10025Z\" />\n </svg>\n );\n}\n\nasync function collectFocusedItems(loadFocusedItems: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>) {\n const focusedItems: Array<InstanceKey | ElementsGroupInfo> = [];\n const groupingNodeInfos: Array<{\n parentKey: InstancesNodeKey;\n parentType: \"element\" | \"category\";\n groupingNode: ClassGroupingHierarchyNode;\n modelIds: Id64String[];\n }> = [];\n for await (const key of loadFocusedItems()) {\n if (\"id\" in key) {\n focusedItems.push(key);\n continue;\n }\n\n if (!HierarchyNodeKey.isClassGrouping(key.key)) {\n continue;\n }\n\n const groupingNode = key as ClassGroupingHierarchyNode;\n if (!groupingNode.nonGroupingAncestor || !HierarchyNodeKey.isInstances(groupingNode.nonGroupingAncestor.key)) {\n continue;\n }\n\n const parentKey = groupingNode.nonGroupingAncestor.key;\n const type = groupingNode.nonGroupingAncestor.extendedData?.isCategory ? \"category\" : \"element\";\n const modelIds = ((groupingNode.nonGroupingAncestor.extendedData?.modelIds as Id64String[][]) ?? []).flatMap((ids) => ids);\n groupingNodeInfos.push({ groupingNode, parentType: type, parentKey, modelIds });\n }\n focusedItems.push(\n ...groupingNodeInfos.map(({ parentKey, parentType, groupingNode, modelIds }) => ({\n parent:\n parentType === \"element\"\n ? { type: \"element\" as const, ids: parentKey.instanceKeys.map((key) => key.id) }\n : { type: \"category\" as const, ids: parentKey.instanceKeys.map((key) => key.id), modelIds },\n groupingNode,\n })),\n );\n return focusedItems;\n}\n\nfunction createLocalizedMessage(message: string, onClick?: () => void) {\n const exp = new RegExp(\"<link>(.*)</link>\");\n const match = message.match(exp);\n if (!match) {\n return message;\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = message.split(fullText);\n\n return (\n <>\n {textBefore ? textBefore : null}\n <Anchor\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? textAfter : null}\n </>\n );\n}\n\nasync function createFilteringPathsResult({\n getSubTreePaths,\n getFilteringPaths,\n handlePaths,\n}: {\n getSubTreePaths: () => Promise<HierarchyNodeIdentifiersPath[] | undefined>;\n getFilteringPaths: () => Promise<NormalizedHierarchyFilteringPath[] | undefined>;\n handlePaths: (filteredPaths: HierarchyFilteringPath[] | undefined) => Promise<void>;\n}): Promise<HierarchyFilteringPath[] | undefined> {\n const [subTreePaths, filterPaths] = await Promise.all([getSubTreePaths(), getFilteringPaths()]);\n let joinedPaths: HierarchyFilteringPath[] | undefined;\n try {\n if (subTreePaths && filterPaths) {\n return (joinedPaths = joinHierarchyFilteringPaths(subTreePaths, filterPaths));\n }\n if (subTreePaths) {\n return (joinedPaths = subTreePaths);\n }\n if (filterPaths) {\n return (joinedPaths = filterPaths);\n }\n } finally {\n void handlePaths(joinedPaths);\n }\n return joinedPaths;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/UseModelsTree.tsx"],"names":[],"mappings":";;AA+GA,sCAsOC;;AArVD;;;gGAGgG;AAEhG,iCAA0E;AAC1E,wDAAiD;AACjD,oEAAsG;AACtG,wDAAoD;AACpD,gFAA4E;AAC5E,8EAAmI;AACnI,0DAAoD;AACpD,qFAAkF;AAClF,mFAA6E;AAC7E,2DAAmE;AACnE,6EAAuE;AACvE,iDAAiE;AACjE,4EAAsE;AACtE,oEAA8D;AAC9D,8FAA8F;AAC9F,uEAAgG;AAuFhG;;;GAGG;AACH,SAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,MAAM,EACN,eAAe,EACf,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAAE,0BAA0B,EAC9C,eAAe,GACI;IACnB,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAuC,SAAS,CAAC,CAAC;IACtG,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAqC,SAAS,CAAC,CAAC;IAChG,MAAM,sBAAsB,GAAG,IAAA,eAAO,EACpC,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,uDAA6B;QAChC,GAAG,eAAe;KACnB,CAAC;IACF,uDAAuD;IACvD,MAAM,CAAC,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC,CACrC,CAAC;IACF,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,4CAAmB,GAAE,CAAC;IAEhD,MAAM,EAAE,QAAQ,EAAE,qBAAqB,EAAE,GAAG,IAAA,4BAAW,EAA4E;QACjI,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,WAAW;QACX,kBAAkB,EAAE,IAAA,eAAO,EAAC,GAAG,EA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CAAC,eAAe,EAAE,CAAC;oBACpB,OAAO,EAAE,EAAE,CAAC;gBACd,CAAC,YAEA,SAAS,GACH,EACR,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAC5B,CACJ,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,0BAA0B,CAAC,EACxC,eAAe,EACf,iBAAiB,EACjB,WAAW,GAKZ;IACC,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC;IAChG,IAAI,WAAiD,CAAC;IACtD,IAAI,CAAC;QACH,IAAI,YAAY,IAAI,WAAW,EAAE,CAAC;YAChC,OAAO,CAAC,WAAW,GAAG,IAAA,sCAA2B,EAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;YAAS,CAAC;QACT,KAAK,WAAW,CAAC,WAAW,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,WAAW,CAAC,KAA8E;IACjG,OAAO,IAAI,0CAAkB,CAAC,IAAA,oDAAwB,EAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;AAC7G,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 { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgFolder, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from \"@itwin/itwinui-icons-react\";\nimport { Anchor, Text } from \"@itwin/itwinui-react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { HierarchyFilteringPath, HierarchyNode, HierarchyNodeIdentifier, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { useIdsCache } from \"../common/internal/useTreeHooks/UseIdsCache.js\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors.js\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext.js\";\nimport { joinHierarchyFilteringPaths } from \"../common/Utils.js\";\nimport { ModelsTreeIdsCache } from \"./internal/ModelsTreeIdsCache.js\";\nimport { ModelsTreeNode } from \"./internal/ModelsTreeNode.js\";\nimport { createModelsTreeVisibilityHandler } from \"./internal/ModelsTreeVisibilityHandler.js\";\nimport { defaultHierarchyConfiguration, ModelsTreeDefinition } from \"./ModelsTreeDefinition.js\";\n\nimport type { ReactElement } from \"react\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { GroupingHierarchyNode, HierarchyNodeIdentifiersPath, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { VisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\nimport type { CreateCacheProps } from \"../common/internal/useTreeHooks/UseIdsCache.js\";\nimport type { NormalizedHierarchyFilteringPath } from \"../common/Utils.js\";\nimport type { ModelsTreeVisibilityHandlerOverrides } from \"./internal/ModelsTreeVisibilityHandler.js\";\nimport type { ClassGroupingHierarchyNode, ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from \"./ModelsTreeDefinition.js\";\n\ntype ModelsTreeFilteringError = \"tooManyFilterMatches\" | \"tooManyInstancesFocused\" | \"unknownFilterError\" | \"unknownInstanceFocusError\";\ntype ModelsTreeSubTreeError = \"unknownSubTreeError\";\n\n/** @beta */\nexport interface UseModelsTreeProps {\n /**\n * Optional search string used to filter tree nodes by label, as well as highlight matching substrings in the tree.\n * Nodes that do not contain this string in their label will be filtered out.\n *\n * If `getFilteredPaths` function is provided, it will take precedence and automatic filtering by this string will not be applied.\n * Instead, the string will be supplied to the given `getFilteredPaths` function for consumers to apply the filtering.\n */\n filter?: string;\n activeView: Viewport;\n hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;\n visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;\n /**\n * Optional function for applying custom filtering on the hierarchy. Use it when you want full control over which nodes should be displayed, based on more complex logic or known instance keys.\n *\n * When defined, this function takes precedence over filtering by `filter` string. If both are supplied, the `filter` is provided as an argument to `getFilteredPaths`.\n *\n * @param props Parameters provided when `getFilteredPaths` is called:\n * - `createInstanceKeyPaths`: Helper function to create filter paths.\n * - `filter`: The filter string which would otherwise be used for default filtering.\n *\n * **Example use cases:**\n * - You have a list of `InstanceKey` items, which you want to use for filtering the hierarchy.\n * - You want to create filter paths based on node label, but also apply some extra conditions (for example exclude paths with sub-models).\n * - You want to construct custom filtered paths. For example: create a filter path for each geometric element which has a parent element.\n *\n * @note Paths returned by `createInstanceKeyPaths` will not have `autoExpand` flag set. If you want nodes to be expanded, iterate over the paths and\n * set `autoExpand: true` manually.\n */\n getFilteredPaths?: (props: {\n /** A function that creates filtering paths based on provided target instance keys or node label. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> } | { label: string }) => Promise<NormalizedHierarchyFilteringPath[]>;\n /** Filter which would be used to create filter paths if `getFilteredPaths` wouldn't be provided. */\n filter?: string;\n }) => Promise<HierarchyFilteringPath[] | undefined>;\n /**\n * Optional function for restricting the visible hierarchy to a specific sub-tree of nodes, without changing how filtering works.\n *\n * Use when you want to display only part of the hierarchy, but still allow normal filtering within that sub-tree.\n *\n * When defined, only nodes that are in the provided paths or children of target nodes will be part of the hierarchy.\n * Filtering (by label or custom logic) will still apply within this sub-tree.\n *\n * Key difference:\n * - `getFilteredPaths` determines which nodes should be shown, giving you full control over filtering logic.\n * - `getSubTreePaths` restricts the hierarchy to a sub-tree, but does not override the filtering logic — filtering is still applied within the restricted sub-tree.\n */\n getSubTreePaths?: (props: {\n /** A function that creates filtering paths based on provided target instance keys. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> }) => Promise<NormalizedHierarchyFilteringPath[]>;\n }) => Promise<HierarchyFilteringPath[]>;\n onModelsFiltered?: (modelIds: Id64String[] | undefined) => void;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (props: { node: PresentationHierarchyNode; type: \"subject\" | \"model\" | \"category\" | \"element\" | \"elements-class-group\" }) => boolean;\n}\n\n/** @beta */\ninterface UseModelsTreeResult {\n modelsTreeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"visibilityHandlerFactory\" | \"highlight\" | \"noDataMessage\" | \"selectionPredicate\"\n >;\n rendererProps: Required<Pick<VisibilityTreeRendererProps, \"getIcon\" | \"onNodeDoubleClick\">>;\n}\n\n/**\n * Custom hook to create and manage state for the models tree.\n * @beta\n */\nexport function useModelsTree({\n activeView,\n filter,\n hierarchyConfig,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n selectionPredicate: nodeTypeSelectionPredicate,\n getSubTreePaths,\n}: UseModelsTreeProps): UseModelsTreeResult {\n const [filteringError, setFilteringError] = useState<ModelsTreeFilteringError | undefined>(undefined);\n const [subTreeError, setSubTreeError] = useState<ModelsTreeSubTreeError | undefined>(undefined);\n const hierarchyConfiguration = useMemo<ModelsTreeHierarchyConfiguration>(\n () => ({\n ...defaultHierarchyConfiguration,\n ...hierarchyConfig,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfig ?? {}),\n );\n const { onFeatureUsed } = useTelemetryContext();\n\n const { getCache: getModelsTreeIdsCache } = useIdsCache<ModelsTreeIdsCache, { hierarchyConfig: ModelsTreeHierarchyConfiguration }>({\n imodel: activeView.iModel,\n createCache,\n cacheSpecificProps: useMemo(() => ({ hierarchyConfig: hierarchyConfiguration }), [hierarchyConfiguration]),\n });\n\n const { visibilityHandlerFactory, onFilteredPathsChanged } = useCachedVisibility({\n activeView,\n overrides: visibilityHandlerOverrides,\n getModelsTreeIdsCache,\n });\n const { loadFocusedItems } = useFocusedInstancesContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => new ModelsTreeDefinition({ imodelAccess, idsCache: getModelsTreeIdsCache(), hierarchyConfig: hierarchyConfiguration }),\n [getModelsTreeIdsCache, hierarchyConfiguration],\n );\n\n const onNodeDoubleClick = useCallback(\n async ({ nodeData, extendedData }: PresentationHierarchyNode) => {\n if (!HierarchyNode.isInstancesNode(nodeData) || (extendedData && (extendedData.isSubject || extendedData.isModel || extendedData.isCategory))) {\n return;\n }\n const instanceIds = nodeData.key.instanceKeys.map((instanceKey) => instanceKey.id);\n await IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);\n onFeatureUsed({ featureId: \"zoom-to-node\", reportInteraction: false });\n },\n [onFeatureUsed],\n );\n\n const getSubTreePathsInternal = useMemo<\n ((...props: Parameters<Required<VisibilityTreeProps>[\"getFilteredPaths\"]>) => Promise<HierarchyNodeIdentifiersPath[]>) | undefined\n >(() => {\n if (!getSubTreePaths) {\n return undefined;\n }\n return async ({ imodelAccess, abortSignal }) => {\n try {\n const paths = await getSubTreePaths({\n createInstanceKeyPaths: async ({ targetItems }) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n targetItems,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n abortSignal,\n }),\n });\n return paths.map(HierarchyFilteringPath.normalize).map(({ path }) => path);\n } catch (e) {\n const newError = \"unknownSubTreeError\";\n setSubTreeError(newError);\n return [];\n }\n };\n }, [getModelsTreeIdsCache, hierarchyConfiguration, getSubTreePaths]);\n\n const getPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n onModelsFiltered?.(undefined);\n\n // reset filtered paths if there is no filters applied. This allows to keep current filtered paths until new paths are loaded.\n if (!loadFocusedItems && !getFilteredPaths && !filter && !getSubTreePathsInternal) {\n onFilteredPathsChanged(undefined);\n }\n\n const handlePaths = async (filteredPaths: HierarchyFilteringPath[] | undefined, classInspector: ECClassHierarchyInspector) => {\n onFilteredPathsChanged(filteredPaths);\n if (!onModelsFiltered) {\n return;\n }\n\n const modelIds = filteredPaths ? await getModels(filteredPaths, getModelsTreeIdsCache(), classInspector) : undefined;\n onModelsFiltered(modelIds);\n };\n\n if (loadFocusedItems) {\n return async ({ imodelAccess, abortSignal }) => {\n try {\n const focusedItems = await collectFocusedItems(loadFocusedItems);\n return await createFilteringPathsResult({\n getFilteringPaths: async () => {\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n targetItems: focusedItems,\n hierarchyConfig: hierarchyConfiguration,\n abortSignal,\n });\n return paths.map(({ path, options }) => ({ path, options: { ...options, autoExpand: true } }));\n },\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyInstancesFocused\" : \"unknownInstanceFocusError\";\n if (newError !== \"tooManyInstancesFocused\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (getFilteredPaths) {\n return async ({ imodelAccess, abortSignal }) => {\n try {\n return await createFilteringPathsResult({\n getFilteringPaths: async () => {\n const paths = await getFilteredPaths({\n createInstanceKeyPaths: async (props) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n ...props,\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n abortSignal,\n }),\n filter,\n });\n return paths?.map(HierarchyFilteringPath.normalize);\n },\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (filter) {\n return async ({ imodelAccess, abortSignal }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n return await createFilteringPathsResult({\n getFilteringPaths: async () => {\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: filter,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n abortSignal,\n });\n return paths.map(({ path, options }) => ({ path, options: { ...options, autoExpand: true } }));\n },\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n return getSubTreePathsInternal;\n }, [\n filter,\n loadFocusedItems,\n getModelsTreeIdsCache,\n onFeatureUsed,\n getFilteredPaths,\n hierarchyConfiguration,\n onModelsFiltered,\n onFilteredPathsChanged,\n getSubTreePathsInternal,\n ]);\n\n const nodeSelectionPredicate = useCallback<NonNullable<VisibilityTreeProps[\"selectionPredicate\"]>>(\n (node) => {\n if (!nodeTypeSelectionPredicate) {\n return true;\n }\n return nodeTypeSelectionPredicate({ node, type: ModelsTreeNode.getType(node.nodeData) });\n },\n [nodeTypeSelectionPredicate],\n );\n\n return {\n modelsTreeProps: {\n treeName: \"models-tree-v2\",\n visibilityHandlerFactory,\n getHierarchyDefinition,\n getFilteredPaths: getPaths,\n noDataMessage: getNoDataMessage(filter, subTreeError, filteringError),\n highlight: filter ? { text: filter } : undefined,\n selectionPredicate: nodeSelectionPredicate,\n },\n rendererProps: {\n onNodeDoubleClick,\n getIcon,\n },\n };\n}\n\nasync function getModels(paths: HierarchyFilteringPath[], idsCache: ModelsTreeIdsCache, classInspector: ECClassHierarchyInspector) {\n if (!paths) {\n return undefined;\n }\n\n const targetModels = new Set<Id64String>();\n const targetSubjects = new Set<Id64String>();\n for (const path of paths) {\n const currPath = Array.isArray(path) ? path : path.path;\n for (let i = 0; i < currPath.length; i++) {\n const currStep = currPath[i];\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(currStep)) {\n break;\n }\n\n // if paths end with subject need to get all models under that subject\n if (i === currPath.length - 1 && currStep.className === \"BisCore.Subject\") {\n targetSubjects.add(currStep.id);\n break;\n }\n\n // collect all the models from the filtered path\n if (await classInspector.classDerivesFrom(currStep.className, \"BisCore.GeometricModel3d\")) {\n targetModels.add(currStep.id);\n }\n }\n }\n\n const matchingModels = await idsCache.getSubjectModelIds([...targetSubjects]);\n return [...targetModels, ...matchingModels];\n}\n\nfunction getNoDataMessage(filter?: string, subTreeError?: ModelsTreeSubTreeError, filteringError?: ModelsTreeFilteringError) {\n if (isSubTreeError(subTreeError)) {\n return <Text>{TreeWidget.translate(`modelsTree.subTree.${subTreeError}`)}</Text>;\n }\n if (isInstanceFocusError(filteringError)) {\n return <InstanceFocusError error={filteringError} />;\n }\n if (isFilterError(filteringError)) {\n return <Text>{TreeWidget.translate(`modelsTree.filtering.${filteringError}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"modelsTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction isSubTreeError(error: ModelsTreeSubTreeError | undefined) {\n return error === \"unknownSubTreeError\";\n}\n\nfunction isFilterError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyFilterMatches\" || error === \"unknownFilterError\";\n}\n\nfunction isInstanceFocusError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyInstancesFocused\" || error === \"unknownInstanceFocusError\";\n}\n\nfunction InstanceFocusError({ error }: { error: ModelsTreeFilteringError }) {\n const { toggle } = useFocusedInstancesContext();\n const localizedMessage = createLocalizedMessage(TreeWidget.translate(`modelsTree.filtering.${error}`), () => toggle());\n return <Text>{localizedMessage}</Text>;\n}\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return <SvgLayers />;\n case \"icon-item\":\n return <SvgItem />;\n case \"icon-ec-class\":\n return <SvgClassGrouping />;\n case \"icon-imodel-hollow-2\":\n return <SvgImodelHollow />;\n case \"icon-folder\":\n return <SvgFolder />;\n case \"icon-model\":\n return <SvgModel />;\n }\n\n return undefined;\n}\n\nfunction createVisibilityHandlerFactory(\n activeView: Viewport,\n idsCacheGetter: () => ModelsTreeIdsCache,\n overrides?: ModelsTreeVisibilityHandlerOverrides,\n filteredPaths?: HierarchyFilteringPath[],\n): VisibilityTreeProps[\"visibilityHandlerFactory\"] {\n return ({ imodelAccess }) => createModelsTreeVisibilityHandler({ viewport: activeView, idsCache: idsCacheGetter(), imodelAccess, overrides, filteredPaths });\n}\n\nfunction useCachedVisibility(props: {\n activeView: Viewport;\n getModelsTreeIdsCache: () => ModelsTreeIdsCache;\n overrides?: ModelsTreeVisibilityHandlerOverrides;\n}) {\n const { activeView, getModelsTreeIdsCache, overrides } = props;\n const currentIModelRef = useRef(activeView.iModel);\n\n const [filteredPaths, setFilteredPaths] = useState<HierarchyFilteringPath[]>();\n const [visibilityHandlerFactory, setVisibilityHandlerFactory] = useState<VisibilityTreeProps[\"visibilityHandlerFactory\"]>(() =>\n createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides, filteredPaths),\n );\n\n useEffect(() => {\n currentIModelRef.current = activeView.iModel;\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides, filteredPaths));\n }, [activeView, getModelsTreeIdsCache, overrides, filteredPaths]);\n\n return {\n visibilityHandlerFactory,\n onFilteredPathsChanged: useCallback((paths: HierarchyFilteringPath[] | undefined) => setFilteredPaths(paths), []),\n };\n}\n\nfunction SvgClassGrouping() {\n return (\n <svg id=\"Calque_1\" data-name=\"Calque 1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <path d=\"M8.00933,0,0,3.97672V11.986L8.00933,16,16,11.93V3.97651ZM1.66173,11.27642c-.26155.03734-.59754-.26154-.76553-.69085-.168-.41066-.09334-.784.168-.82152.26154-.03734.59754.26154.76553.67219C1.99772,10.86577,1.92306,11.23909,1.66173,11.27642Zm0-3.32319c-.26155.03733-.59754-.28-.76553-.69086-.168-.42932-.09334-.80285.168-.84.26133-.03733.59754.28.76532.69086C1.99772,7.54236,1.92306,7.89723,1.66173,7.95323Zm4.31276,5.52621a.18186.18186,0,0,1-.16821-.01866L3.41657,12.15394a.94275.94275,0,0,1-.29887-.80285c.03754-.33621.22421-.52265.41108-.41066L5.9185,12.24727a.88656.88656,0,0,1,.28.80285A.5057.5057,0,0,1,5.97449,13.47944Zm0-3.37919a.18184.18184,0,0,1-.16821-.01867L3.41657,8.77475a.943.943,0,0,1-.29887-.80286c.03754-.3362.22421-.52286.41108-.42953L5.9185,8.86786a.83112.83112,0,0,1,.28.78419A.51684.51684,0,0,1,5.97449,10.10025Z\" />\n </svg>\n );\n}\n\nasync function collectFocusedItems(loadFocusedItems: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>) {\n const focusedItems: Array<InstanceKey | ElementsGroupInfo> = [];\n const groupingNodeInfos: Array<{\n parentKey: InstancesNodeKey;\n parentType: \"element\" | \"category\";\n groupingNode: ClassGroupingHierarchyNode;\n modelIds: Id64String[];\n }> = [];\n for await (const key of loadFocusedItems()) {\n if (\"id\" in key) {\n focusedItems.push(key);\n continue;\n }\n\n if (!HierarchyNodeKey.isClassGrouping(key.key)) {\n continue;\n }\n\n const groupingNode = key as ClassGroupingHierarchyNode;\n if (!groupingNode.nonGroupingAncestor || !HierarchyNodeKey.isInstances(groupingNode.nonGroupingAncestor.key)) {\n continue;\n }\n\n const parentKey = groupingNode.nonGroupingAncestor.key;\n const type = groupingNode.nonGroupingAncestor.extendedData?.isCategory ? \"category\" : \"element\";\n const modelIds = ((groupingNode.nonGroupingAncestor.extendedData?.modelIds as Id64String[][]) ?? []).flatMap((ids) => ids);\n groupingNodeInfos.push({ groupingNode, parentType: type, parentKey, modelIds });\n }\n focusedItems.push(\n ...groupingNodeInfos.map(({ parentKey, parentType, groupingNode, modelIds }) => ({\n parent:\n parentType === \"element\"\n ? { type: \"element\" as const, ids: parentKey.instanceKeys.map((key) => key.id) }\n : { type: \"category\" as const, ids: parentKey.instanceKeys.map((key) => key.id), modelIds },\n groupingNode,\n })),\n );\n return focusedItems;\n}\n\nfunction createLocalizedMessage(message: string, onClick?: () => void) {\n const exp = new RegExp(\"<link>(.*)</link>\");\n const match = message.match(exp);\n if (!match) {\n return message;\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = message.split(fullText);\n\n return (\n <>\n {textBefore ? textBefore : null}\n <Anchor\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? textAfter : null}\n </>\n );\n}\n\nasync function createFilteringPathsResult({\n getSubTreePaths,\n getFilteringPaths,\n handlePaths,\n}: {\n getSubTreePaths: () => Promise<HierarchyNodeIdentifiersPath[] | undefined>;\n getFilteringPaths: () => Promise<NormalizedHierarchyFilteringPath[] | undefined>;\n handlePaths: (filteredPaths: HierarchyFilteringPath[] | undefined) => Promise<void>;\n}): Promise<HierarchyFilteringPath[] | undefined> {\n const [subTreePaths, filterPaths] = await Promise.all([getSubTreePaths(), getFilteringPaths()]);\n let joinedPaths: HierarchyFilteringPath[] | undefined;\n try {\n if (subTreePaths && filterPaths) {\n return (joinedPaths = joinHierarchyFilteringPaths(subTreePaths, filterPaths));\n }\n if (subTreePaths) {\n return (joinedPaths = subTreePaths);\n }\n if (filterPaths) {\n return (joinedPaths = filterPaths);\n }\n } finally {\n void handlePaths(joinedPaths);\n }\n return joinedPaths;\n}\n\nfunction createCache(props: CreateCacheProps<{ hierarchyConfig: ModelsTreeHierarchyConfiguration }>) {\n return new ModelsTreeIdsCache(createECSqlQueryExecutor(props.imodel), props.specificProps.hierarchyConfig);\n}\n"]}
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import type { Id64Arg, Id64Set, Id64String } from "@itwin/core-bentley";
|
|
2
2
|
import type { Observable } from "rxjs";
|
|
3
3
|
import type { Viewport } from "@itwin/core-frontend";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export declare const SET_CHANGE_DEBOUNCE_TIME = 20;
|
|
6
|
+
type SetType = "always" | "never";
|
|
7
|
+
/** @internal */
|
|
4
8
|
export interface AlwaysOrNeverDrawnElementsQueryProps {
|
|
5
9
|
modelId: Id64String;
|
|
6
10
|
categoryIds?: Id64Arg;
|
|
7
11
|
}
|
|
8
|
-
export declare const SET_CHANGE_DEBOUNCE_TIME = 20;
|
|
9
12
|
export declare class AlwaysAndNeverDrawnElementInfo implements Disposable {
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
private _alwaysDrawn;
|
|
13
|
-
private _neverDrawn;
|
|
14
|
-
private _disposeSubject;
|
|
15
|
-
private _suppressors;
|
|
16
|
-
private _suppress;
|
|
17
|
-
private _forceUpdate;
|
|
18
|
-
constructor(_viewport: Viewport);
|
|
13
|
+
#private;
|
|
14
|
+
constructor(viewport: Viewport);
|
|
19
15
|
suppressChangeEvents(): void;
|
|
20
16
|
resumeChangeEvents(): void;
|
|
21
17
|
getElements({ setType, modelId, categoryIds }: {
|
|
22
|
-
setType:
|
|
18
|
+
setType: SetType;
|
|
23
19
|
} & AlwaysOrNeverDrawnElementsQueryProps): Observable<Id64Set>;
|
|
24
20
|
private createCacheEntryObservable;
|
|
25
21
|
[Symbol.dispose](): void;
|
|
26
22
|
private queryAlwaysOrNeverDrawnElementInfo;
|
|
27
23
|
private queryElementInfo;
|
|
28
24
|
}
|
|
25
|
+
export {};
|
|
29
26
|
//# sourceMappingURL=AlwaysAndNeverDrawnElementInfo.d.ts.map
|
|
@@ -9,45 +9,31 @@ const rxjs_1 = require("rxjs");
|
|
|
9
9
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
10
10
|
const presentation_core_interop_1 = require("@itwin/presentation-core-interop");
|
|
11
11
|
const Utils_js_1 = require("../../common/Utils.js");
|
|
12
|
+
/** @internal */
|
|
12
13
|
exports.SET_CHANGE_DEBOUNCE_TIME = 20;
|
|
13
14
|
class AlwaysAndNeverDrawnElementInfo {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this
|
|
24
|
-
this
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
id: "alwaysDrawn",
|
|
28
|
-
});
|
|
29
|
-
this._neverDrawn = this.createCacheEntryObservable({
|
|
30
|
-
event: this._viewport.onNeverDrawnChanged,
|
|
31
|
-
getSet: () => this._viewport.neverDrawn,
|
|
32
|
-
id: "neverDrawn",
|
|
33
|
-
});
|
|
34
|
-
this._suppressors = this._suppress.pipe((0, rxjs_1.scan)((acc, suppress) => acc + (suppress ? 1 : -1), 0), (0, rxjs_1.startWith)(0), (0, rxjs_1.shareReplay)(1));
|
|
35
|
-
this._subscriptions = [
|
|
36
|
-
this._alwaysDrawn.subscribe(),
|
|
37
|
-
this._neverDrawn.subscribe(),
|
|
38
|
-
this._suppressors.pipe((0, rxjs_1.filter)((suppressors) => suppressors === 0)).subscribe({
|
|
39
|
-
next: () => this._forceUpdate.next(),
|
|
40
|
-
}),
|
|
41
|
-
];
|
|
15
|
+
#subscriptions;
|
|
16
|
+
#alwaysDrawn;
|
|
17
|
+
#neverDrawn;
|
|
18
|
+
#disposeSubject = new rxjs_1.Subject();
|
|
19
|
+
#viewport;
|
|
20
|
+
#suppressors;
|
|
21
|
+
#suppress = new rxjs_1.Subject();
|
|
22
|
+
constructor(viewport) {
|
|
23
|
+
this.#viewport = viewport;
|
|
24
|
+
this.#alwaysDrawn = { cacheEntryObs: this.createCacheEntryObservable("always") };
|
|
25
|
+
this.#neverDrawn = { cacheEntryObs: this.createCacheEntryObservable("never") };
|
|
26
|
+
this.#suppressors = this.#suppress.pipe((0, rxjs_1.scan)((acc, suppress) => acc + (suppress ? 1 : -1), 0), (0, rxjs_1.startWith)(0), (0, rxjs_1.shareReplay)(1));
|
|
27
|
+
this.#subscriptions = [this.#alwaysDrawn.cacheEntryObs.subscribe(), this.#neverDrawn.cacheEntryObs.subscribe()];
|
|
42
28
|
}
|
|
43
29
|
suppressChangeEvents() {
|
|
44
|
-
this.
|
|
30
|
+
this.#suppress.next(true);
|
|
45
31
|
}
|
|
46
32
|
resumeChangeEvents() {
|
|
47
|
-
this.
|
|
33
|
+
this.#suppress.next(false);
|
|
48
34
|
}
|
|
49
35
|
getElements({ setType, modelId, categoryIds }) {
|
|
50
|
-
const cache = setType === "always" ? this
|
|
36
|
+
const cache = setType === "always" ? this.#alwaysDrawn : this.#neverDrawn;
|
|
51
37
|
const getElements = categoryIds
|
|
52
38
|
? (entry) => {
|
|
53
39
|
const result = new Set();
|
|
@@ -65,26 +51,30 @@ class AlwaysAndNeverDrawnElementInfo {
|
|
|
65
51
|
}
|
|
66
52
|
return elements;
|
|
67
53
|
};
|
|
68
|
-
return cache.
|
|
54
|
+
return !cache.latestCacheEntryValue
|
|
55
|
+
? cache.cacheEntryObs.pipe((0, rxjs_1.map)(getElements))
|
|
56
|
+
: this.#suppressors.pipe((0, rxjs_1.take)(1), (0, rxjs_1.mergeMap)((suppressionCount) => suppressionCount > 0 ? (0, rxjs_1.of)(cache.latestCacheEntryValue).pipe((0, rxjs_1.map)(getElements)) : cache.cacheEntryObs.pipe((0, rxjs_1.map)(getElements))));
|
|
69
57
|
}
|
|
70
|
-
createCacheEntryObservable(
|
|
71
|
-
const event =
|
|
58
|
+
createCacheEntryObservable(setType) {
|
|
59
|
+
const event = setType === "always" ? this.#viewport.onAlwaysDrawnChanged : this.#viewport.onNeverDrawnChanged;
|
|
60
|
+
const getIds = setType === "always" ? () => this.#viewport.alwaysDrawn : () => this.#viewport.neverDrawn;
|
|
72
61
|
const resultSubject = new rxjs_1.BehaviorSubject(undefined);
|
|
73
|
-
const obs = (0, rxjs_1.
|
|
62
|
+
const obs = (0, rxjs_1.fromEventPattern)((handler) => event.addListener(handler), (handler) => event.removeListener(handler)).pipe(
|
|
74
63
|
// Fire the observable once at the beginning
|
|
75
64
|
(0, rxjs_1.startWith)(undefined),
|
|
76
|
-
// Stop listening to events when dispose() is called
|
|
77
|
-
(0, rxjs_1.takeUntil)(this._disposeSubject),
|
|
78
65
|
// Reset result subject as soon as a new event is emitted.
|
|
79
66
|
// This will make newly subscribed observers wait for the debounce period to pass
|
|
80
67
|
// instead of consuming the cached value which at this point becomes invalid.
|
|
81
68
|
(0, rxjs_1.tap)(() => resultSubject.next(undefined)),
|
|
82
69
|
// Check if cache updates are not suppressed.
|
|
83
|
-
(0, rxjs_1.switchMap)(() => this.
|
|
70
|
+
(0, rxjs_1.switchMap)(() => this.#suppressors.pipe((0, rxjs_1.filter)((suppressors) => suppressors === 0), (0, rxjs_1.take)(1))), (0, rxjs_1.debounceTime)(exports.SET_CHANGE_DEBOUNCE_TIME),
|
|
84
71
|
// Cancel pending request if dispose() is called.
|
|
85
|
-
(0, rxjs_1.takeUntil)(this
|
|
72
|
+
(0, rxjs_1.takeUntil)(this.#disposeSubject),
|
|
86
73
|
// If multiple requests are sent at once, preserve only the result of the newest.
|
|
87
|
-
(0, rxjs_1.switchMap)(() => this.queryAlwaysOrNeverDrawnElementInfo(
|
|
74
|
+
(0, rxjs_1.switchMap)(() => this.queryAlwaysOrNeverDrawnElementInfo(getIds(), `${setType}Drawn`)), (0, rxjs_1.tap)((cacheEntry) => {
|
|
75
|
+
const value = setType === "always" ? this.#alwaysDrawn : this.#neverDrawn;
|
|
76
|
+
value.latestCacheEntryValue = cacheEntry;
|
|
77
|
+
}),
|
|
88
78
|
// Share the result by using a subject which always emits the saved result.
|
|
89
79
|
(0, rxjs_1.share)({
|
|
90
80
|
connector: () => resultSubject,
|
|
@@ -95,9 +85,9 @@ class AlwaysAndNeverDrawnElementInfo {
|
|
|
95
85
|
return obs;
|
|
96
86
|
}
|
|
97
87
|
[Symbol.dispose]() {
|
|
98
|
-
this.
|
|
99
|
-
this
|
|
100
|
-
this.
|
|
88
|
+
this.#subscriptions.forEach((x) => x.unsubscribe());
|
|
89
|
+
this.#subscriptions = [];
|
|
90
|
+
this.#disposeSubject.next();
|
|
101
91
|
}
|
|
102
92
|
queryAlwaysOrNeverDrawnElementInfo(set, requestId) {
|
|
103
93
|
const elementInfo = set?.size ? this.queryElementInfo([...set], requestId) : rxjs_1.EMPTY;
|
|
@@ -112,41 +102,42 @@ class AlwaysAndNeverDrawnElementInfo {
|
|
|
112
102
|
}, new Map()));
|
|
113
103
|
}
|
|
114
104
|
queryElementInfo(elementIds, requestId) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
105
|
+
return (0, rxjs_1.defer)(() => {
|
|
106
|
+
const executor = (0, presentation_core_interop_1.createECSqlQueryExecutor)(this.#viewport.iModel);
|
|
107
|
+
return executor.createQueryReader({
|
|
108
|
+
ctes: [
|
|
109
|
+
`
|
|
110
|
+
ElementInfo(elementId, modelId, categoryId, parentId) AS (
|
|
111
|
+
SELECT
|
|
112
|
+
ECInstanceId elementId,
|
|
113
|
+
Model.Id modelId,
|
|
114
|
+
Category.Id categoryId,
|
|
115
|
+
Parent.Id parentId
|
|
116
|
+
FROM bis.GeometricElement3d
|
|
117
|
+
WHERE InVirtualSet(?, ECInstanceId)
|
|
127
118
|
|
|
128
|
-
|
|
119
|
+
UNION ALL
|
|
129
120
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
121
|
+
SELECT
|
|
122
|
+
e.elementId,
|
|
123
|
+
e.modelId,
|
|
124
|
+
p.Category.Id categoryId,
|
|
125
|
+
p.Parent.Id parentId
|
|
126
|
+
FROM bis.GeometricElement3d p
|
|
127
|
+
JOIN ElementInfo e ON p.ECInstanceId = e.parentId
|
|
128
|
+
)
|
|
129
|
+
`,
|
|
130
|
+
],
|
|
131
|
+
ecsql: `
|
|
132
|
+
SELECT elementId, modelId, categoryId
|
|
133
|
+
FROM ElementInfo
|
|
134
|
+
WHERE parentId IS NULL
|
|
135
|
+
`,
|
|
136
|
+
bindings: [{ type: "idset", value: elementIds }],
|
|
137
|
+
}, {
|
|
138
|
+
restartToken: `ModelsTreeVisibilityHandler/${requestId}`,
|
|
139
|
+
});
|
|
140
|
+
}).pipe((0, rxjs_1.map)((row) => ({ elementId: row.elementId, modelId: row.modelId, categoryId: row.categoryId })));
|
|
150
141
|
}
|
|
151
142
|
}
|
|
152
143
|
exports.AlwaysAndNeverDrawnElementInfo = AlwaysAndNeverDrawnElementInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlwaysAndNeverDrawnElementInfo.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+BAoBc;AACd,sDAA2C;AAC3C,gFAA4E;AAC5E,oDAAkD;AAmBrC,QAAA,wBAAwB,GAAG,EAAE,CAAC;AAE3C,MAAa,8BAA8B;IAUZ;IATrB,cAAc,CAAiB;IAC/B,YAAY,CAAyB;IACrC,WAAW,CAAyB;IACpC,eAAe,GAAG,IAAI,cAAO,EAAQ,CAAC;IAEtC,YAAY,CAAqB;IACjC,SAAS,GAAG,IAAI,cAAO,EAAW,CAAC;IACnC,YAAY,GAAG,IAAI,cAAO,EAAQ,CAAC;IAE3C,YAA6B,SAAmB;QAAnB,cAAS,GAAT,SAAS,CAAU;QAC9C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,0BAA0B,CAAC;YAClD,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB;YAC1C,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW;YACxC,EAAE,EAAE,aAAa;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,0BAA0B,CAAC;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AM,CAAC,CAAC,IAAI,CAAC,IAAA,UAAG,EAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3H,CAAC;CACF;AA1KD,wEA0KC","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 BehaviorSubject,\n debounceTime,\n EMPTY,\n filter,\n first,\n from,\n fromEventPattern,\n map,\n merge,\n reduce,\n scan,\n share,\n shareReplay,\n startWith,\n Subject,\n switchMap,\n take,\n takeUntil,\n tap,\n} from \"rxjs\";\nimport { Id64 } from \"@itwin/core-bentley\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { pushToMap } from \"../../common/Utils.js\";\n\nimport type { BeEvent, Id64Arg, Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { Observable, Subscription } from \"rxjs\";\nimport type { Viewport } from \"@itwin/core-frontend\";\n\ninterface ElementInfo {\n elementId: Id64String;\n modelId: Id64String;\n categoryId: Id64String;\n}\n\ntype CacheEntry = Map<Id64String, Map<Id64String, Id64Set>>;\n\nexport interface AlwaysOrNeverDrawnElementsQueryProps {\n modelId: Id64String;\n categoryIds?: Id64Arg;\n}\n\nexport const SET_CHANGE_DEBOUNCE_TIME = 20;\n\nexport class AlwaysAndNeverDrawnElementInfo implements Disposable {\n private _subscriptions: Subscription[];\n private _alwaysDrawn: Observable<CacheEntry>;\n private _neverDrawn: Observable<CacheEntry>;\n private _disposeSubject = new Subject<void>();\n\n private _suppressors: Observable<number>;\n private _suppress = new Subject<boolean>();\n private _forceUpdate = new Subject<void>();\n\n constructor(private readonly _viewport: Viewport) {\n this._alwaysDrawn = this.createCacheEntryObservable({\n event: this._viewport.onAlwaysDrawnChanged,\n getSet: () => this._viewport.alwaysDrawn,\n id: \"alwaysDrawn\",\n });\n this._neverDrawn = this.createCacheEntryObservable({\n event: this._viewport.onNeverDrawnChanged,\n getSet: () => this._viewport.neverDrawn,\n id: \"neverDrawn\",\n });\n this._suppressors = this._suppress.pipe(\n scan((acc, suppress) => acc + (suppress ? 1 : -1), 0),\n startWith(0),\n shareReplay(1),\n );\n this._subscriptions = [\n this._alwaysDrawn.subscribe(),\n this._neverDrawn.subscribe(),\n this._suppressors.pipe(filter((suppressors) => suppressors === 0)).subscribe({\n next: () => this._forceUpdate.next(),\n }),\n ];\n }\n\n public suppressChangeEvents() {\n this._suppress.next(true);\n }\n\n public resumeChangeEvents() {\n this._suppress.next(false);\n }\n\n public getElements({ setType, modelId, categoryIds }: { setType: \"always\" | \"never\" } & AlwaysOrNeverDrawnElementsQueryProps): Observable<Id64Set> {\n const cache = setType === \"always\" ? this._alwaysDrawn : this._neverDrawn;\n const getElements = categoryIds\n ? (entry: CacheEntry | undefined) => {\n const result = new Set<Id64String>();\n for (const categoryId of Id64.iterable(categoryIds)) {\n const elements = entry?.get(modelId)?.get(categoryId);\n elements?.forEach((elementId) => result.add(elementId));\n }\n return result;\n }\n : (entry: CacheEntry | undefined) => {\n const modelEntry = entry?.get(modelId);\n const elements = new Set<Id64String>();\n for (const set of modelEntry?.values() ?? []) {\n set.forEach((id) => elements.add(id));\n }\n return elements;\n };\n\n return cache.pipe(map(getElements));\n }\n\n private createCacheEntryObservable(props: { event: BeEvent<() => void>; getSet(): Id64Set | undefined; id: string }) {\n const event = props.event;\n const resultSubject = new BehaviorSubject<CacheEntry | undefined>(undefined);\n\n const obs = merge(\n fromEventPattern(\n (handler) => event.addListener(handler),\n (handler) => event.removeListener(handler),\n ),\n this._forceUpdate,\n ).pipe(\n // Fire the observable once at the beginning\n startWith(undefined),\n // Stop listening to events when dispose() is called\n takeUntil(this._disposeSubject),\n // Reset result subject as soon as a new event is emitted.\n // This will make newly subscribed observers wait for the debounce period to pass\n // instead of consuming the cached value which at this point becomes invalid.\n tap(() => resultSubject.next(undefined)),\n // Check if cache updates are not suppressed.\n switchMap(() =>\n this._suppressors.pipe(\n filter((suppressors) => suppressors === 0),\n take(1),\n ),\n ),\n debounceTime(SET_CHANGE_DEBOUNCE_TIME),\n // Cancel pending request if dispose() is called.\n takeUntil(this._disposeSubject),\n // If multiple requests are sent at once, preserve only the result of the newest.\n switchMap(() => this.queryAlwaysOrNeverDrawnElementInfo(props.getSet(), props.id)),\n // Share the result by using a subject which always emits the saved result.\n share({\n connector: () => resultSubject,\n resetOnRefCountZero: false,\n }),\n // Wait until the result is available.\n first((x): x is CacheEntry => !!x),\n );\n return obs;\n }\n\n public [Symbol.dispose]() {\n this._subscriptions.forEach((x) => x.unsubscribe());\n this._subscriptions = [];\n this._disposeSubject.next();\n }\n\n private queryAlwaysOrNeverDrawnElementInfo(set: Id64Set | undefined, requestId: string): Observable<CacheEntry> {\n const elementInfo = set?.size ? this.queryElementInfo([...set], requestId) : EMPTY;\n return elementInfo.pipe(\n reduce((state, val) => {\n let entry = state.get(val.modelId);\n if (!entry) {\n entry = new Map();\n state.set(val.modelId, entry);\n }\n pushToMap(entry, val.categoryId, val.elementId);\n return state;\n }, new Map<Id64String, Map<Id64String, Id64Set>>()),\n );\n }\n\n private queryElementInfo(elementIds: Id64Array, requestId: string): Observable<ElementInfo> {\n const executor = createECSqlQueryExecutor(this._viewport.iModel);\n const reader = executor.createQueryReader(\n {\n ctes: [\n `\n ElementInfo(elementId, modelId, categoryId, parentId) AS (\n SELECT\n ECInstanceId elementId,\n Model.Id modelId,\n Category.Id categoryId,\n Parent.Id parentId\n FROM bis.GeometricElement3d\n WHERE InVirtualSet(?, ECInstanceId)\n\n UNION ALL\n\n SELECT\n e.elementId,\n e.modelId,\n p.Category.Id categoryId,\n p.Parent.Id parentId\n FROM bis.GeometricElement3d p\n JOIN ElementInfo e ON p.ECInstanceId = e.parentId\n )\n `,\n ],\n ecsql: `\n SELECT elementId, modelId, categoryId\n FROM ElementInfo\n WHERE parentId IS NULL\n `,\n bindings: [{ type: \"idset\", value: elementIds }],\n },\n {\n restartToken: `ModelsTreeVisibilityHandler/${requestId}`,\n },\n );\n\n return from(reader).pipe(map((row) => ({ elementId: row.elementId, modelId: row.modelId, categoryId: row.categoryId })));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AlwaysAndNeverDrawnElementInfo.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+BAqBc;AACd,sDAA2C;AAC3C,gFAA4E;AAC5E,oDAAkD;AAMlD,gBAAgB;AACH,QAAA,wBAAwB,GAAG,EAAE,CAAC;AAY3C,MAAa,8BAA8B;IACzC,cAAc,CAAiB;IAC/B,YAAY,CAAgF;IAC5F,WAAW,CAAgF;IAC3F,eAAe,GAAG,IAAI,cAAO,EAAQ,CAAC;IAC7B,SAAS,CAAW;IAE7B,YAAY,CAAqB;IACjC,SAAS,GAAG,IAAI,cAAO,EAAW,CAAC;IAEnC,YAAY,QAAkB;QAC5B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,YAAY,GAAG,EAAE,aAAa,EAAE,IAAI,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjF,IAAI,CAAC,WAAW,GAAG,EAAE,aAAa,EAAE,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/E,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACrC,IAAA,WAAI,EAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CA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AAiB,CAC/B;gBACE,IAAI,EAAE;oBACJ;;;;;;;;;;;;;;;;;;;;aAoBC;iBACF;gBACD,KAAK,EAAE;;;;WAIN;gBACD,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;aACjD,EACD;gBACE,YAAY,EAAE,+BAA+B,SAAS,EAAE;aACzD,CACF,CAAC;QACJ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,UAAG,EAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1G,CAAC;CACF;AA5KD,wEA4KC","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 BehaviorSubject,\n debounceTime,\n defer,\n EMPTY,\n filter,\n first,\n fromEventPattern,\n map,\n mergeMap,\n of,\n reduce,\n scan,\n share,\n shareReplay,\n startWith,\n Subject,\n switchMap,\n take,\n takeUntil,\n tap,\n} from \"rxjs\";\nimport { Id64 } from \"@itwin/core-bentley\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { pushToMap } from \"../../common/Utils.js\";\n\nimport type { Id64Arg, Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { Observable, Subscription } from \"rxjs\";\nimport type { Viewport } from \"@itwin/core-frontend\";\n\n/** @internal */\nexport const SET_CHANGE_DEBOUNCE_TIME = 20;\n\ntype SetType = \"always\" | \"never\";\n\n/** @internal */\nexport interface AlwaysOrNeverDrawnElementsQueryProps {\n modelId: Id64String;\n categoryIds?: Id64Arg;\n}\n\ntype CacheEntry = Map<Id64String, Map<Id64String, Id64Set>>;\n\nexport class AlwaysAndNeverDrawnElementInfo implements Disposable {\n #subscriptions: Subscription[];\n #alwaysDrawn: { cacheEntryObs: Observable<CacheEntry>; latestCacheEntryValue?: CacheEntry };\n #neverDrawn: { cacheEntryObs: Observable<CacheEntry>; latestCacheEntryValue?: CacheEntry };\n #disposeSubject = new Subject<void>();\n readonly #viewport: Viewport;\n\n #suppressors: Observable<number>;\n #suppress = new Subject<boolean>();\n\n constructor(viewport: Viewport) {\n this.#viewport = viewport;\n this.#alwaysDrawn = { cacheEntryObs: this.createCacheEntryObservable(\"always\") };\n this.#neverDrawn = { cacheEntryObs: this.createCacheEntryObservable(\"never\") };\n this.#suppressors = this.#suppress.pipe(\n scan((acc, suppress) => acc + (suppress ? 1 : -1), 0),\n startWith(0),\n shareReplay(1),\n );\n this.#subscriptions = [this.#alwaysDrawn.cacheEntryObs.subscribe(), this.#neverDrawn.cacheEntryObs.subscribe()];\n }\n\n public suppressChangeEvents() {\n this.#suppress.next(true);\n }\n\n public resumeChangeEvents() {\n this.#suppress.next(false);\n }\n\n public getElements({ setType, modelId, categoryIds }: { setType: SetType } & AlwaysOrNeverDrawnElementsQueryProps): Observable<Id64Set> {\n const cache = setType === \"always\" ? this.#alwaysDrawn : this.#neverDrawn;\n const getElements = categoryIds\n ? (entry: CacheEntry | undefined) => {\n const result = new Set<Id64String>();\n for (const categoryId of Id64.iterable(categoryIds)) {\n const elements = entry?.get(modelId)?.get(categoryId);\n elements?.forEach((elementId) => result.add(elementId));\n }\n return result;\n }\n : (entry: CacheEntry | undefined) => {\n const modelEntry = entry?.get(modelId);\n const elements = new Set<Id64String>();\n for (const set of modelEntry?.values() ?? []) {\n set.forEach((id) => elements.add(id));\n }\n return elements;\n };\n\n return !cache.latestCacheEntryValue\n ? cache.cacheEntryObs.pipe(map(getElements))\n : this.#suppressors.pipe(\n take(1),\n mergeMap((suppressionCount) =>\n suppressionCount > 0 ? of(cache.latestCacheEntryValue).pipe(map(getElements)) : cache.cacheEntryObs.pipe(map(getElements)),\n ),\n );\n }\n\n private createCacheEntryObservable(setType: SetType): Observable<CacheEntry> {\n const event = setType === \"always\" ? this.#viewport.onAlwaysDrawnChanged : this.#viewport.onNeverDrawnChanged;\n const getIds = setType === \"always\" ? () => this.#viewport.alwaysDrawn : () => this.#viewport.neverDrawn;\n\n const resultSubject = new BehaviorSubject<CacheEntry | undefined>(undefined);\n\n const obs = fromEventPattern(\n (handler) => event.addListener(handler),\n (handler) => event.removeListener(handler),\n ).pipe(\n // Fire the observable once at the beginning\n startWith(undefined),\n // Reset result subject as soon as a new event is emitted.\n // This will make newly subscribed observers wait for the debounce period to pass\n // instead of consuming the cached value which at this point becomes invalid.\n tap(() => resultSubject.next(undefined)),\n // Check if cache updates are not suppressed.\n switchMap(() =>\n this.#suppressors.pipe(\n filter((suppressors) => suppressors === 0),\n take(1),\n ),\n ),\n debounceTime(SET_CHANGE_DEBOUNCE_TIME),\n // Cancel pending request if dispose() is called.\n takeUntil(this.#disposeSubject),\n // If multiple requests are sent at once, preserve only the result of the newest.\n switchMap(() => this.queryAlwaysOrNeverDrawnElementInfo(getIds(), `${setType}Drawn`)),\n tap((cacheEntry) => {\n const value = setType === \"always\" ? this.#alwaysDrawn : this.#neverDrawn;\n value.latestCacheEntryValue = cacheEntry;\n }),\n // Share the result by using a subject which always emits the saved result.\n share({\n connector: () => resultSubject,\n resetOnRefCountZero: false,\n }),\n // Wait until the result is available.\n first((x): x is CacheEntry => !!x),\n );\n return obs;\n }\n\n public [Symbol.dispose]() {\n this.#subscriptions.forEach((x) => x.unsubscribe());\n this.#subscriptions = [];\n this.#disposeSubject.next();\n }\n\n private queryAlwaysOrNeverDrawnElementInfo(set: Id64Set | undefined, requestId: string): Observable<CacheEntry> {\n const elementInfo = set?.size ? this.queryElementInfo([...set], requestId) : EMPTY;\n return elementInfo.pipe(\n reduce((state, val) => {\n let entry = state.get(val.modelId);\n if (!entry) {\n entry = new Map();\n state.set(val.modelId, entry);\n }\n pushToMap(entry, val.categoryId, val.elementId);\n return state;\n }, new Map<Id64String, Map<Id64String, Id64Set>>()),\n );\n }\n\n private queryElementInfo(\n elementIds: Id64Array,\n requestId: string,\n ): Observable<{\n elementId: Id64String;\n modelId: Id64String;\n categoryId: Id64String;\n }> {\n return defer(() => {\n const executor = createECSqlQueryExecutor(this.#viewport.iModel);\n return executor.createQueryReader(\n {\n ctes: [\n `\n ElementInfo(elementId, modelId, categoryId, parentId) AS (\n SELECT\n ECInstanceId elementId,\n Model.Id modelId,\n Category.Id categoryId,\n Parent.Id parentId\n FROM bis.GeometricElement3d\n WHERE InVirtualSet(?, ECInstanceId)\n\n UNION ALL\n\n SELECT\n e.elementId,\n e.modelId,\n p.Category.Id categoryId,\n p.Parent.Id parentId\n FROM bis.GeometricElement3d p\n JOIN ElementInfo e ON p.ECInstanceId = e.parentId\n )\n `,\n ],\n ecsql: `\n SELECT elementId, modelId, categoryId\n FROM ElementInfo\n WHERE parentId IS NULL\n `,\n bindings: [{ type: \"idset\", value: elementIds }],\n },\n {\n restartToken: `ModelsTreeVisibilityHandler/${requestId}`,\n },\n );\n }).pipe(map((row) => ({ elementId: row.elementId, modelId: row.modelId, categoryId: row.categoryId })));\n }\n}\n"]}
|
package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Id64Arg, Id64Array, Id64String } from "@itwin/core-bentley";
|
|
|
3
3
|
import type { HierarchyNodeIdentifiersPath, LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
4
4
|
type ModelsTreeHierarchyConfiguration = ConstructorParameters<typeof ModelsTreeDefinition>[0]["hierarchyConfig"];
|
|
5
5
|
/** @internal */
|
|
6
|
-
export declare class ModelsTreeIdsCache {
|
|
6
|
+
export declare class ModelsTreeIdsCache implements Disposable {
|
|
7
7
|
private _queryExecutor;
|
|
8
8
|
private _hierarchyConfig;
|
|
9
9
|
private readonly _categoryElementCounts;
|
package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js
CHANGED
|
@@ -216,15 +216,18 @@ class ModelsTreeIdsCache {
|
|
|
216
216
|
return entry;
|
|
217
217
|
}
|
|
218
218
|
async *queryModelCategories() {
|
|
219
|
-
const query =
|
|
220
|
-
SELECT
|
|
219
|
+
const query = `
|
|
220
|
+
SELECT
|
|
221
|
+
this.Model.Id modelId,
|
|
222
|
+
this.Category.Id categoryId,
|
|
223
|
+
m.IsPrivate isModelPrivate,
|
|
224
|
+
MAX(IIF(this.Parent.Id IS NULL, 1, 0)) isRootElementCategory
|
|
221
225
|
FROM BisCore.Model m
|
|
222
226
|
JOIN ${this._hierarchyConfig.elementClassSpecification} this ON m.ECInstanceId = this.Model.Id
|
|
223
|
-
WHERE this.Parent.Id IS NULL
|
|
224
227
|
GROUP BY modelId, categoryId, isModelPrivate
|
|
225
228
|
`;
|
|
226
229
|
for await (const row of this._queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded" })) {
|
|
227
|
-
yield { modelId: row.modelId, categoryId: row.categoryId, isModelPrivate: !!row.isModelPrivate };
|
|
230
|
+
yield { modelId: row.modelId, categoryId: row.categoryId, isModelPrivate: !!row.isModelPrivate, isRootElementCategory: !!row.isRootElementCategory };
|
|
228
231
|
}
|
|
229
232
|
}
|
|
230
233
|
async *queryModeledElements() {
|
|
@@ -263,14 +266,14 @@ class ModelsTreeIdsCache {
|
|
|
263
266
|
async getModelInfos() {
|
|
264
267
|
this._modelInfos ??= (async () => {
|
|
265
268
|
const modelInfos = new Map();
|
|
266
|
-
for await (const { modelId, categoryId, isModelPrivate } of this.queryModelCategories()) {
|
|
269
|
+
for await (const { modelId, categoryId, isModelPrivate, isRootElementCategory } of this.queryModelCategories()) {
|
|
267
270
|
const entry = modelInfos.get(modelId);
|
|
268
271
|
if (entry) {
|
|
269
|
-
entry.categories.
|
|
272
|
+
entry.categories.set(categoryId, { isRootElementCategory });
|
|
270
273
|
entry.isModelPrivate = isModelPrivate;
|
|
271
274
|
}
|
|
272
275
|
else {
|
|
273
|
-
modelInfos.set(modelId, { categories: new
|
|
276
|
+
modelInfos.set(modelId, { categories: new Map([[categoryId, { isRootElementCategory }]]), isModelPrivate });
|
|
274
277
|
}
|
|
275
278
|
}
|
|
276
279
|
return modelInfos;
|
|
@@ -279,7 +282,7 @@ class ModelsTreeIdsCache {
|
|
|
279
282
|
}
|
|
280
283
|
async getModelCategories(modelId) {
|
|
281
284
|
const modelInfos = await this.getModelInfos();
|
|
282
|
-
const categories = modelInfos.get(modelId)?.categories;
|
|
285
|
+
const categories = modelInfos.get(modelId)?.categories.keys();
|
|
283
286
|
return categories ? [...categories] : [];
|
|
284
287
|
}
|
|
285
288
|
async hasSubModel(elementId) {
|
|
@@ -376,7 +379,8 @@ class ModelsTreeIdsCache {
|
|
|
376
379
|
const result = new Set();
|
|
377
380
|
const modelInfos = await this.getModelInfos();
|
|
378
381
|
modelInfos?.forEach((modelInfo, modelId) => {
|
|
379
|
-
|
|
382
|
+
const categoryEntry = modelInfo.categories.get(categoryId);
|
|
383
|
+
if (categoryEntry?.isRootElementCategory) {
|
|
380
384
|
result.add(modelId);
|
|
381
385
|
}
|
|
382
386
|
});
|