@itwin/tree-widget-react 4.0.0-alpha.21 → 4.0.0-alpha.22
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/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.js +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/TreeWidgetViewport.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/TreeWidgetViewport.js.map +1 -1
- package/package.json +1 -1
|
@@ -38,6 +38,7 @@ export function useClassificationsTreeDefinition(props) {
|
|
|
38
38
|
}),
|
|
39
39
|
imodelAccess,
|
|
40
40
|
abortSignal,
|
|
41
|
+
limit: typeof searchTerm !== "string" ? "unbounded" : undefined,
|
|
41
42
|
...(typeof searchTerm === "string" ? { label: searchTerm } : { targetItems: searchTerm }),
|
|
42
43
|
})));
|
|
43
44
|
return first.concat(...rest);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseClassificationsTreeDefinition.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AAgDxF,aAAa;AACb,MAAM,UAAU,gCAAgC,CAAC,KAA4C;IAC3F,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAEnD,MAAM,SAAS,GAAG,MAAM,CAA2C,IAAI,GAAG,EAAE,CAAC,CAAC;IAE9E,MAAM,UAAU,GA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AC;YAEF,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC;IAE3C,OAAO;QACL,UAAU;QACV,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,EAC3B,SAAS,EACT,OAAO,EACP,eAAe,EACf,SAAS,GAQV;IACC,IAAI,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAChD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;QAC7F,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACjB,QAAQ,GAAG,IAAI,2BAA2B,CAAC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;QACjF,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,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 { useMemo, useRef } from \"react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { ClassificationsTreeDefinition } from \"./ClassificationsTreeDefinition.js\";\nimport { ClassificationsTreeIdsCache } from \"./internal/ClassificationsTreeIdsCache.js\";\n\nimport type { MutableRefObject } from \"react\";\nimport type { HierarchyDefinition } from \"@itwin/presentation-hierarchies\";\nimport type { useIModelTree, useTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { FunctionProps } from \"../common/Utils.js\";\nimport type { ClassificationsTreeHierarchyConfiguration } from \"./ClassificationsTreeDefinition.js\";\n\n/** @alpha */\ninterface UseClassificationsTreeDefinitionProps {\n /**\n * A list of iModels to create merged hierarchy for.\n *\n * **Warning:** These **must** all be different versions of the same iModel, ordered from the earliest to the\n * latest version. Not obeying this rule may result in undefined behavior.\n */\n imodels: Array<{\n /**\n * An object that provides access to iModel's data and metadata.\n */\n imodelAccess: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n }>;\n hierarchyConfig: ClassificationsTreeHierarchyConfiguration;\n /**\n * Optional search parameters to filter tree nodes.\n */\n search?:\n | {\n /**\n * Text used to filter tree nodes by label.\n */\n searchText: string;\n }\n | {\n /**\n * List of instance keys to filter tree nodes by.\n */\n targetItems: Array<InstanceKey>;\n };\n}\n\n/** @alpha */\ninterface UseClassificationsTreeDefinitionResult {\n definition: HierarchyDefinition;\n getFilteredPaths?: FunctionProps<typeof useTree>[\"getFilteredPaths\"];\n}\n\n/** @alpha */\nexport function useClassificationsTreeDefinition(props: UseClassificationsTreeDefinitionProps): UseClassificationsTreeDefinitionResult {\n const { imodels, hierarchyConfig, search } = props;\n\n const idsCaches = useRef<Map<string, ClassificationsTreeIdsCache>>(new Map());\n\n const definition = useMemo(() => {\n return new ClassificationsTreeDefinition({\n imodelAccess: imodels[imodels.length - 1].imodelAccess,\n getIdsCache: (imodelKey: string) =>\n getOrCreateIdsCache({\n imodelKey,\n imodels,\n idsCaches,\n hierarchyConfig,\n }),\n hierarchyConfig,\n });\n }, [imodels, hierarchyConfig]);\n\n const searchTerm = search ? (\"searchText\" in search ? search.searchText : search.targetItems) : undefined;\n const getFilteredPaths = useMemo<FunctionProps<typeof useTree>[\"getFilteredPaths\"]>(() => {\n if (!searchTerm) {\n return undefined;\n }\n\n return async ({ abortSignal }) => {\n const [first, ...rest] = await Promise.all(\n imodels.map(async ({ imodelAccess }) =>\n ClassificationsTreeDefinition.createInstanceKeyPaths({\n hierarchyConfig,\n idsCache: getOrCreateIdsCache({\n imodelKey: imodelAccess.imodelKey,\n imodels,\n idsCaches,\n hierarchyConfig,\n }),\n imodelAccess,\n abortSignal,\n ...(typeof searchTerm === \"string\" ? { label: searchTerm } : { targetItems: searchTerm }),\n }),\n ),\n );\n\n return first.concat(...rest);\n };\n }, [imodels, hierarchyConfig, searchTerm]);\n\n return {\n definition,\n getFilteredPaths,\n };\n}\n\nfunction getOrCreateIdsCache({\n imodelKey,\n imodels,\n hierarchyConfig,\n idsCaches,\n}: {\n imodelKey: string;\n imodels: Array<{\n imodelAccess: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n }>;\n hierarchyConfig: ClassificationsTreeHierarchyConfiguration;\n idsCaches: MutableRefObject<Map<string, ClassificationsTreeIdsCache>>;\n}) {\n let idsCache = idsCaches.current.get(imodelKey);\n if (!idsCache) {\n const imodel = imodels.find((currImodel) => currImodel.imodelAccess.imodelKey === imodelKey);\n assert(!!imodel);\n idsCache = new ClassificationsTreeIdsCache(imodel.imodelAccess, hierarchyConfig);\n idsCaches.current.set(imodelKey, idsCache);\n }\n return idsCache;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseClassificationsTreeDefinition.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AAgDxF,aAAa;AACb,MAAM,UAAU,gCAAgC,CAAC,KAA4C;IAC3F,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAEnD,MAAM,SAAS,GAAG,MAAM,CA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AO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;aAC1F,CAAC,CACH,CACF,CAAC;YAEF,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC;IAE3C,OAAO;QACL,UAAU;QACV,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,EAC3B,SAAS,EACT,OAAO,EACP,eAAe,EACf,SAAS,GAQV;IACC,IAAI,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAChD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;QAC7F,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACjB,QAAQ,GAAG,IAAI,2BAA2B,CAAC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;QACjF,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,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 { useMemo, useRef } from \"react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { ClassificationsTreeDefinition } from \"./ClassificationsTreeDefinition.js\";\nimport { ClassificationsTreeIdsCache } from \"./internal/ClassificationsTreeIdsCache.js\";\n\nimport type { MutableRefObject } from \"react\";\nimport type { HierarchyDefinition } from \"@itwin/presentation-hierarchies\";\nimport type { useIModelTree, useTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { FunctionProps } from \"../common/Utils.js\";\nimport type { ClassificationsTreeHierarchyConfiguration } from \"./ClassificationsTreeDefinition.js\";\n\n/** @alpha */\ninterface UseClassificationsTreeDefinitionProps {\n /**\n * A list of iModels to create merged hierarchy for.\n *\n * **Warning:** These **must** all be different versions of the same iModel, ordered from the earliest to the\n * latest version. Not obeying this rule may result in undefined behavior.\n */\n imodels: Array<{\n /**\n * An object that provides access to iModel's data and metadata.\n */\n imodelAccess: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n }>;\n hierarchyConfig: ClassificationsTreeHierarchyConfiguration;\n /**\n * Optional search parameters to filter tree nodes.\n */\n search?:\n | {\n /**\n * Text used to filter tree nodes by label.\n */\n searchText: string;\n }\n | {\n /**\n * List of instance keys to filter tree nodes by.\n */\n targetItems: Array<InstanceKey>;\n };\n}\n\n/** @alpha */\ninterface UseClassificationsTreeDefinitionResult {\n definition: HierarchyDefinition;\n getFilteredPaths?: FunctionProps<typeof useTree>[\"getFilteredPaths\"];\n}\n\n/** @alpha */\nexport function useClassificationsTreeDefinition(props: UseClassificationsTreeDefinitionProps): UseClassificationsTreeDefinitionResult {\n const { imodels, hierarchyConfig, search } = props;\n\n const idsCaches = useRef<Map<string, ClassificationsTreeIdsCache>>(new Map());\n\n const definition = useMemo(() => {\n return new ClassificationsTreeDefinition({\n imodelAccess: imodels[imodels.length - 1].imodelAccess,\n getIdsCache: (imodelKey: string) =>\n getOrCreateIdsCache({\n imodelKey,\n imodels,\n idsCaches,\n hierarchyConfig,\n }),\n hierarchyConfig,\n });\n }, [imodels, hierarchyConfig]);\n\n const searchTerm = search ? (\"searchText\" in search ? search.searchText : search.targetItems) : undefined;\n const getFilteredPaths = useMemo<FunctionProps<typeof useTree>[\"getFilteredPaths\"]>(() => {\n if (!searchTerm) {\n return undefined;\n }\n\n return async ({ abortSignal }) => {\n const [first, ...rest] = await Promise.all(\n imodels.map(async ({ imodelAccess }) =>\n ClassificationsTreeDefinition.createInstanceKeyPaths({\n hierarchyConfig,\n idsCache: getOrCreateIdsCache({\n imodelKey: imodelAccess.imodelKey,\n imodels,\n idsCaches,\n hierarchyConfig,\n }),\n imodelAccess,\n abortSignal,\n limit: typeof searchTerm !== \"string\" ? \"unbounded\" : undefined,\n ...(typeof searchTerm === \"string\" ? { label: searchTerm } : { targetItems: searchTerm }),\n }),\n ),\n );\n\n return first.concat(...rest);\n };\n }, [imodels, hierarchyConfig, searchTerm]);\n\n return {\n definition,\n getFilteredPaths,\n };\n}\n\nfunction getOrCreateIdsCache({\n imodelKey,\n imodels,\n hierarchyConfig,\n idsCaches,\n}: {\n imodelKey: string;\n imodels: Array<{\n imodelAccess: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n }>;\n hierarchyConfig: ClassificationsTreeHierarchyConfiguration;\n idsCaches: MutableRefObject<Map<string, ClassificationsTreeIdsCache>>;\n}) {\n let idsCache = idsCaches.current.get(imodelKey);\n if (!idsCache) {\n const imodel = imodels.find((currImodel) => currImodel.imodelAccess.imodelKey === imodelKey);\n assert(!!imodel);\n idsCache = new ClassificationsTreeIdsCache(imodel.imodelAccess, hierarchyConfig);\n idsCaches.current.set(imodelKey, idsCache);\n }\n return idsCache;\n}\n"]}
|
|
@@ -63,7 +63,7 @@ export function createTreeWidgetViewport(viewport) {
|
|
|
63
63
|
return viewport.onNeverDrawnChanged;
|
|
64
64
|
},
|
|
65
65
|
get onDisplayStyleChanged() {
|
|
66
|
-
return viewport.
|
|
66
|
+
return viewport.onDisplayStyleChanged;
|
|
67
67
|
},
|
|
68
68
|
get onDisplayedModelsChanged() {
|
|
69
69
|
return viewport.onViewedModelsChanged;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeWidgetViewport.js","sourceRoot":"","s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,KAAK,CAAC,UAAU,CAAC;QAClE,eAAe,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,eAAe,EAAE;QACjD,IAAI,WAAW;YACb,OAAO,QAAQ,CAAC,WAAW,CAAC;QAC9B,CAAC;QACD,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;QACrF,gBAAgB,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,gBAAgB,EAAE;QACnD,IAAI,sBAAsB;YACxB,OAAO,QAAQ,CAAC,sBAAsB,CAAC;QACzC,CAAC;QACD,IAAI,oBAAoB;YACtB,OAAO,QAAQ,CAAC,oBAAoB,CAAC;QACvC,CAAC;QACD,IAAI,mBAAmB;YACrB,OAAO,QAAQ,CAAC,mBAAmB,CAAC;QACtC,CAAC;QACD,IAAI,qBAAqB;YACvB,OAAO,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC;QAC7C,CAAC;QACD,IAAI,wBAAwB;YAC1B,OAAO,QAAQ,CAAC,qBAAqB,CAAC;QACxC,CAAC;QACD,IAAI,4BAA4B;YAC9B,OAAO,QAAQ,CAAC,yBAAyB,CAAC;QAC5C,CAAC;QACD,IAAI,oCAAoC;YACtC,OAAO,QAAQ,CAAC,iCAAiC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,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 { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { BeEvent, Id64Arg, Id64String } from \"@itwin/core-bentley\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\n\n/** @public */\nexport type PerModelCategoryOverride = \"show\" | \"hide\" | \"none\";\n\n/**\n * Creates a `TreeWidgetViewport`.\n * @beta\n */\nexport function createTreeWidgetViewport(viewport: Viewport): TreeWidgetViewport {\n return {\n get viewType() {\n return viewport.view.is2d() ? \"2d\" : viewport.view.isSpatialView() ? \"3d\" : \"other\";\n },\n get iModel() {\n return viewport.iModel;\n },\n viewsModel: (modelId) => viewport.view.viewsModel(modelId),\n changeModelDisplay: (props) => {\n if (props.display) {\n void viewport.addViewedModels(props.modelIds);\n return;\n }\n viewport.changeModelDisplay(props.modelIds, false);\n },\n viewsCategory: (categoryId) => viewport.view.viewsCategory(categoryId),\n changeCategoryDisplay: (props) => viewport.changeCategoryDisplay(props.categoryIds, props.display, props.enableAllSubCategories),\n viewsSubCategory: (subCategoryId) => viewport.isSubCategoryVisible(subCategoryId),\n changeSubCategoryDisplay: (props) => viewport.changeSubCategoryDisplay(props.subCategoryId, props.display),\n get perModelCategoryOverrides() {\n return viewport.perModelCategoryVisibility;\n },\n setPerModelCategoryOverride: (props) => {\n const override =\n props.override === \"show\"\n ? PerModelCategoryVisibility.Override.Show\n : props.override === \"hide\"\n ? PerModelCategoryVisibility.Override.Hide\n : PerModelCategoryVisibility.Override.None;\n viewport.perModelCategoryVisibility.setOverride(props.modelIds, props.categoryIds, override);\n },\n getPerModelCategoryOverride: (props) => {\n const override = viewport.perModelCategoryVisibility.getOverride(props.modelId, props.categoryId);\n return override === PerModelCategoryVisibility.Override.Show ? \"show\" : override === PerModelCategoryVisibility.Override.Hide ? \"hide\" : \"none\";\n },\n clearPerModelCategoryOverrides: (props) => viewport.perModelCategoryVisibility.clearOverrides(props?.modelIds),\n get neverDrawn() {\n return viewport.neverDrawn;\n },\n setNeverDrawn: (props) => viewport.setNeverDrawn(props.elementIds),\n clearNeverDrawn: () => viewport.clearNeverDrawn(),\n get alwaysDrawn() {\n return viewport.alwaysDrawn;\n },\n setAlwaysDrawn: (props) => viewport.setAlwaysDrawn(props.elementIds, props.exclusive),\n clearAlwaysDrawn: () => viewport.clearAlwaysDrawn(),\n get isAlwaysDrawnExclusive() {\n return viewport.isAlwaysDrawnExclusive;\n },\n get onAlwaysDrawnChanged() {\n return viewport.onAlwaysDrawnChanged;\n },\n get onNeverDrawnChanged() {\n return viewport.onNeverDrawnChanged;\n },\n get onDisplayStyleChanged() {\n return viewport.view.onDisplayStyleChanged;\n },\n get onDisplayedModelsChanged() {\n return viewport.onViewedModelsChanged;\n },\n get onDisplayedCategoriesChanged() {\n return viewport.onViewedCategoriesChanged;\n },\n get onPerModelCategoriesOverridesChanged() {\n return viewport.onViewedCategoriesPerModelChanged;\n },\n };\n}\n\n/**\n * A simplified interface for a Viewport that is used by the Tree Widget to control and determine visibility.\n *\n * Viewport should only display elements. Since elements have model, category and sub-category assigned to them, each of these can affect element visibility.\n *\n * The order of precedence for visibility is:\n * 1. Model visibility - if model is not visible, elements from that model should never be displayed.\n * 2. `neverDrawn` set - elements in that set should never be displayed.\n * 3. `alwaysDrawn` set - elements in that set should always be displayed.\n * 4. Per-model category visibility overrides:\n * - if a per-model-category has `Hide` override, elements which have that category and model should not be displayed.\n * - if a per-model-category has `Show` override, elements which have that category and model should be displayed.\n * 5. Category and sub-category visibility - if element's category or sub-category is turned off, it should not be displayed.\n *\n * Based on this order of precedence, element can only be displayed in these scenarios:\n * - Model is visible *AND* element is in `alwaysDrawn` set.\n * - Model is visible *AND* element is not in `neverDrawn` set *AND* per-model category override is set to show `Show`.\n * - Model is visible *AND* element is not in `neverDrawn` set *AND* per-model category override is not set to `Hide` *AND* category and sub-category are visible.\n * @public\n */\nexport interface TreeWidgetViewport {\n /**\n * The type of the view. Generally it should be either `3d` or `2d`.\n *\n * The `other` value is reserved for edge cases when viewport doesn't show any elements, e.g. a blank viewport.\n */\n viewType: \"2d\" | \"3d\" | \"other\";\n /** The iModel of this Viewport. */\n iModel: IModelConnection;\n /**\n * Should return true if model specified by `modelId` is visible in the viewport.\n *\n * Model display should not take into account its' child elements display.\n *\n * When model is not displayed, all elements that have that model should not be shown in the viewport.\n */\n viewsModel: (modelId: Id64String) => boolean;\n /**\n * Should add or remove a set of models from those models currently displayed in this viewport.\n *\n * **NOTE** When turning model display to:\n * - `true`, model display should be turned on. This does not mean that any elements should be turned on, it only means that\n * model visibility should not interfere with elements visibility.\n * - `false`, model display should be turned off. All elements which have that model should not be displayed in the viewport.\n */\n changeModelDisplay: (props: { modelIds: Id64Arg; display: boolean }) => void;\n /**\n * Should return true if category specified by `categoryId` is visible in the viewport.\n *\n * Category display should not take into account its' child elements or sub-categories display.\n *\n * When category is not displayed, all elements and sub-categories which have that category should not be shown in the viewport.\n *\n * **NOTE** Elements might still be visible if per-model category `Show` override or `alwaysDrawn` set makes them visible.\n */\n viewsCategory: (categoryId: Id64String) => boolean;\n /**\n * Should enable or disable display of elements belonging to a set of categories specified by Id.\n *\n * Visibility of individual sub-categories belonging to a category can be controlled separately through the use of `changeSubCategoryDisplay`.\n *\n * By default, enabling display of a category does not affect display of sub-categories thereof which have been set to be invisible.\n *\n * Changing category visibility should not change per-model category overrides.\n *\n * **NOTE** When turning category display to:\n * - `true`, category display should be turned on. All elements which have specified category should be turned on if model is visible,\n * category does not have per-model `hide` override and element is not in the `neverDrawn` set.\n * - `false`, category and its' sub-categories display should be turned off. All elements which have that category should not be displayed in the viewport,\n * unless element has per-model category `Show` override, or is in the `alwaysDrawn` set.\n */\n changeCategoryDisplay: (props: { categoryIds: Id64Arg; display: boolean; enableAllSubCategories?: boolean }) => void;\n /**\n * Should return true if sub-category specified by `subCategoryId` is visible in the viewport.\n *\n * Sub-category display should not take into account its' child elements.\n *\n * When sub-category is not displayed, all elements that have that sub-category should not be shown in the viewport, unless they have per-model category `Show` override or are in the `alwaysDrawn` list.\n */\n viewsSubCategory: (subCategoryId: Id64String) => boolean;\n /**\n * Should enable or disable display of elements belonging to sub-category specified by Id.\n *\n * Changing sub-category display should not change category display.\n *\n * **NOTE** When turning sub-category display to:\n * - `true`, sub-category display should be turned on. All elements which have specified sub-category should be turned on if model and category are visible,\n * category does not have per-model `hide` override and element is not in the `neverDrawn` set.\n * - `false`, sub-category display should be turned off. All elements that have that sub-category should not be displayed in the viewport,\n * unless element has per-model category `Show` override, or is in the `alwaysDrawn` set.\n */\n changeSubCategoryDisplay: (props: { subCategoryId: Id64String; display: boolean }) => void;\n /** Returns an iterable of per-model-category overrides. */\n perModelCategoryOverrides: Readonly<Iterable<{ modelId: Id64String; categoryId: Id64String; visible: boolean }>>;\n /** Should change the override state of one or more categories for one or more models. */\n setPerModelCategoryOverride: (props: { modelIds: Id64Arg; categoryIds: Id64Arg; override: PerModelCategoryOverride }) => void;\n /** Should return the per-model category override. */\n getPerModelCategoryOverride: (props: { modelId: Id64String; categoryId: Id64String }) => PerModelCategoryOverride;\n /** Should remove per-model category override for the specified models. */\n clearPerModelCategoryOverrides: (props?: { modelIds?: Id64Arg }) => void;\n /**\n * Ids of elements which should not be displayed.\n *\n * This set takes precedence over category and sub-category display, per-model category overrides, and the `alwaysDrawn` set.\n */\n neverDrawn: ReadonlySet<Id64String> | undefined;\n /** Ids of elements which should not be displayed in the viewport, regardless of category and sub-category visibility. */\n setNeverDrawn: (props: { elementIds: Set<Id64String> }) => void;\n /** Should clear the set of never-drawn elements. */\n clearNeverDrawn: () => void;\n /**\n * Ids of elements which should be displayed.\n *\n * Elements in this set should be displayed only when model is displayed as well.\n *\n * This set takes precedence over category and sub-category display and per-model category override.\n */\n alwaysDrawn: ReadonlySet<Id64String> | undefined;\n /**\n * Ids of elements which should be displayed in the viewport, regardless of category and sub-category visibility.\n *\n * These elements should be displayed only when their models are displayed as well.\n *\n * When the `exclusive` prop is set to `true`, only the specified elements should be drawn.\n */\n setAlwaysDrawn: (props: { elementIds: Set<Id64String>; exclusive?: boolean }) => void;\n /** Should clear the set of always-drawn elements. */\n clearAlwaysDrawn: () => void;\n /**\n * Should return true if elements in the [[alwaysDrawn]] set are the *only* elements that are displayed when their models are visible.\n *\n * Should be set to true when `setAlwaysDrawn` is called with `exclusive` flag. Should be set to false\n * when `setAlwaysDrawn` is called with `exclusive` set to `false` or `undefined`, or when `clearAlwaysDrawn` is called.\n */\n readonly isAlwaysDrawnExclusive: boolean;\n /** Event that should be raised when set of always-drawn elements changes. */\n onAlwaysDrawnChanged: BeEvent<() => void>;\n /** Event that should be raised when set of never-drawn elements changes. */\n onNeverDrawnChanged: BeEvent<() => void>;\n /** Event that should be raised when per-model category overrides changes. */\n onPerModelCategoriesOverridesChanged: BeEvent<() => void>;\n /** Event that should be raised when category display changes. */\n onDisplayedCategoriesChanged: BeEvent<() => void>;\n /** Event that should be raised when model display changes. */\n onDisplayedModelsChanged: BeEvent<() => void>;\n /** Event that should be raised when view changes between `2d`, `3d` or `other`. */\n onDisplayStyleChanged: BeEvent<() => void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TreeWidgetViewport.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/TreeWidgetViewport.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAQlE;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAAkB;IACzD,OAAO;QACL,IAAI,QAAQ;YACV,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;QACtF,CAAC;QACD,IAAI,MAAM;YACR,OAAO,QAAQ,CAAC,MAAM,CAAC;QACzB,CAAC;QACD,UAAU,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAC1D,kBAAkB,EAAE,CAAC,KAAK,EAAE,EAAE;YAC5B,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBAClB,KAAK,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAC9C,OAAO;YACT,CAAC;YACD,QAAQ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AAC;QACD,IAAI,oCAAoC;YACtC,OAAO,QAAQ,CAAC,iCAAiC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,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 { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { BeEvent, Id64Arg, Id64String } from \"@itwin/core-bentley\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\n\n/** @public */\nexport type PerModelCategoryOverride = \"show\" | \"hide\" | \"none\";\n\n/**\n * Creates a `TreeWidgetViewport`.\n * @beta\n */\nexport function createTreeWidgetViewport(viewport: Viewport): TreeWidgetViewport {\n return {\n get viewType() {\n return viewport.view.is2d() ? \"2d\" : viewport.view.isSpatialView() ? \"3d\" : \"other\";\n },\n get iModel() {\n return viewport.iModel;\n },\n viewsModel: (modelId) => viewport.view.viewsModel(modelId),\n changeModelDisplay: (props) => {\n if (props.display) {\n void viewport.addViewedModels(props.modelIds);\n return;\n }\n viewport.changeModelDisplay(props.modelIds, false);\n },\n viewsCategory: (categoryId) => viewport.view.viewsCategory(categoryId),\n changeCategoryDisplay: (props) => viewport.changeCategoryDisplay(props.categoryIds, props.display, props.enableAllSubCategories),\n viewsSubCategory: (subCategoryId) => viewport.isSubCategoryVisible(subCategoryId),\n changeSubCategoryDisplay: (props) => viewport.changeSubCategoryDisplay(props.subCategoryId, props.display),\n get perModelCategoryOverrides() {\n return viewport.perModelCategoryVisibility;\n },\n setPerModelCategoryOverride: (props) => {\n const override =\n props.override === \"show\"\n ? PerModelCategoryVisibility.Override.Show\n : props.override === \"hide\"\n ? PerModelCategoryVisibility.Override.Hide\n : PerModelCategoryVisibility.Override.None;\n viewport.perModelCategoryVisibility.setOverride(props.modelIds, props.categoryIds, override);\n },\n getPerModelCategoryOverride: (props) => {\n const override = viewport.perModelCategoryVisibility.getOverride(props.modelId, props.categoryId);\n return override === PerModelCategoryVisibility.Override.Show ? \"show\" : override === PerModelCategoryVisibility.Override.Hide ? \"hide\" : \"none\";\n },\n clearPerModelCategoryOverrides: (props) => viewport.perModelCategoryVisibility.clearOverrides(props?.modelIds),\n get neverDrawn() {\n return viewport.neverDrawn;\n },\n setNeverDrawn: (props) => viewport.setNeverDrawn(props.elementIds),\n clearNeverDrawn: () => viewport.clearNeverDrawn(),\n get alwaysDrawn() {\n return viewport.alwaysDrawn;\n },\n setAlwaysDrawn: (props) => viewport.setAlwaysDrawn(props.elementIds, props.exclusive),\n clearAlwaysDrawn: () => viewport.clearAlwaysDrawn(),\n get isAlwaysDrawnExclusive() {\n return viewport.isAlwaysDrawnExclusive;\n },\n get onAlwaysDrawnChanged() {\n return viewport.onAlwaysDrawnChanged;\n },\n get onNeverDrawnChanged() {\n return viewport.onNeverDrawnChanged;\n },\n get onDisplayStyleChanged() {\n return viewport.onDisplayStyleChanged;\n },\n get onDisplayedModelsChanged() {\n return viewport.onViewedModelsChanged;\n },\n get onDisplayedCategoriesChanged() {\n return viewport.onViewedCategoriesChanged;\n },\n get onPerModelCategoriesOverridesChanged() {\n return viewport.onViewedCategoriesPerModelChanged;\n },\n };\n}\n\n/**\n * A simplified interface for a Viewport that is used by the Tree Widget to control and determine visibility.\n *\n * Viewport should only display elements. Since elements have model, category and sub-category assigned to them, each of these can affect element visibility.\n *\n * The order of precedence for visibility is:\n * 1. Model visibility - if model is not visible, elements from that model should never be displayed.\n * 2. `neverDrawn` set - elements in that set should never be displayed.\n * 3. `alwaysDrawn` set - elements in that set should always be displayed.\n * 4. Per-model category visibility overrides:\n * - if a per-model-category has `Hide` override, elements which have that category and model should not be displayed.\n * - if a per-model-category has `Show` override, elements which have that category and model should be displayed.\n * 5. Category and sub-category visibility - if element's category or sub-category is turned off, it should not be displayed.\n *\n * Based on this order of precedence, element can only be displayed in these scenarios:\n * - Model is visible *AND* element is in `alwaysDrawn` set.\n * - Model is visible *AND* element is not in `neverDrawn` set *AND* per-model category override is set to show `Show`.\n * - Model is visible *AND* element is not in `neverDrawn` set *AND* per-model category override is not set to `Hide` *AND* category and sub-category are visible.\n * @public\n */\nexport interface TreeWidgetViewport {\n /**\n * The type of the view. Generally it should be either `3d` or `2d`.\n *\n * The `other` value is reserved for edge cases when viewport doesn't show any elements, e.g. a blank viewport.\n */\n viewType: \"2d\" | \"3d\" | \"other\";\n /** The iModel of this Viewport. */\n iModel: IModelConnection;\n /**\n * Should return true if model specified by `modelId` is visible in the viewport.\n *\n * Model display should not take into account its' child elements display.\n *\n * When model is not displayed, all elements that have that model should not be shown in the viewport.\n */\n viewsModel: (modelId: Id64String) => boolean;\n /**\n * Should add or remove a set of models from those models currently displayed in this viewport.\n *\n * **NOTE** When turning model display to:\n * - `true`, model display should be turned on. This does not mean that any elements should be turned on, it only means that\n * model visibility should not interfere with elements visibility.\n * - `false`, model display should be turned off. All elements which have that model should not be displayed in the viewport.\n */\n changeModelDisplay: (props: { modelIds: Id64Arg; display: boolean }) => void;\n /**\n * Should return true if category specified by `categoryId` is visible in the viewport.\n *\n * Category display should not take into account its' child elements or sub-categories display.\n *\n * When category is not displayed, all elements and sub-categories which have that category should not be shown in the viewport.\n *\n * **NOTE** Elements might still be visible if per-model category `Show` override or `alwaysDrawn` set makes them visible.\n */\n viewsCategory: (categoryId: Id64String) => boolean;\n /**\n * Should enable or disable display of elements belonging to a set of categories specified by Id.\n *\n * Visibility of individual sub-categories belonging to a category can be controlled separately through the use of `changeSubCategoryDisplay`.\n *\n * By default, enabling display of a category does not affect display of sub-categories thereof which have been set to be invisible.\n *\n * Changing category visibility should not change per-model category overrides.\n *\n * **NOTE** When turning category display to:\n * - `true`, category display should be turned on. All elements which have specified category should be turned on if model is visible,\n * category does not have per-model `hide` override and element is not in the `neverDrawn` set.\n * - `false`, category and its' sub-categories display should be turned off. All elements which have that category should not be displayed in the viewport,\n * unless element has per-model category `Show` override, or is in the `alwaysDrawn` set.\n */\n changeCategoryDisplay: (props: { categoryIds: Id64Arg; display: boolean; enableAllSubCategories?: boolean }) => void;\n /**\n * Should return true if sub-category specified by `subCategoryId` is visible in the viewport.\n *\n * Sub-category display should not take into account its' child elements.\n *\n * When sub-category is not displayed, all elements that have that sub-category should not be shown in the viewport, unless they have per-model category `Show` override or are in the `alwaysDrawn` list.\n */\n viewsSubCategory: (subCategoryId: Id64String) => boolean;\n /**\n * Should enable or disable display of elements belonging to sub-category specified by Id.\n *\n * Changing sub-category display should not change category display.\n *\n * **NOTE** When turning sub-category display to:\n * - `true`, sub-category display should be turned on. All elements which have specified sub-category should be turned on if model and category are visible,\n * category does not have per-model `hide` override and element is not in the `neverDrawn` set.\n * - `false`, sub-category display should be turned off. All elements that have that sub-category should not be displayed in the viewport,\n * unless element has per-model category `Show` override, or is in the `alwaysDrawn` set.\n */\n changeSubCategoryDisplay: (props: { subCategoryId: Id64String; display: boolean }) => void;\n /** Returns an iterable of per-model-category overrides. */\n perModelCategoryOverrides: Readonly<Iterable<{ modelId: Id64String; categoryId: Id64String; visible: boolean }>>;\n /** Should change the override state of one or more categories for one or more models. */\n setPerModelCategoryOverride: (props: { modelIds: Id64Arg; categoryIds: Id64Arg; override: PerModelCategoryOverride }) => void;\n /** Should return the per-model category override. */\n getPerModelCategoryOverride: (props: { modelId: Id64String; categoryId: Id64String }) => PerModelCategoryOverride;\n /** Should remove per-model category override for the specified models. */\n clearPerModelCategoryOverrides: (props?: { modelIds?: Id64Arg }) => void;\n /**\n * Ids of elements which should not be displayed.\n *\n * This set takes precedence over category and sub-category display, per-model category overrides, and the `alwaysDrawn` set.\n */\n neverDrawn: ReadonlySet<Id64String> | undefined;\n /** Ids of elements which should not be displayed in the viewport, regardless of category and sub-category visibility. */\n setNeverDrawn: (props: { elementIds: Set<Id64String> }) => void;\n /** Should clear the set of never-drawn elements. */\n clearNeverDrawn: () => void;\n /**\n * Ids of elements which should be displayed.\n *\n * Elements in this set should be displayed only when model is displayed as well.\n *\n * This set takes precedence over category and sub-category display and per-model category override.\n */\n alwaysDrawn: ReadonlySet<Id64String> | undefined;\n /**\n * Ids of elements which should be displayed in the viewport, regardless of category and sub-category visibility.\n *\n * These elements should be displayed only when their models are displayed as well.\n *\n * When the `exclusive` prop is set to `true`, only the specified elements should be drawn.\n */\n setAlwaysDrawn: (props: { elementIds: Set<Id64String>; exclusive?: boolean }) => void;\n /** Should clear the set of always-drawn elements. */\n clearAlwaysDrawn: () => void;\n /**\n * Should return true if elements in the [[alwaysDrawn]] set are the *only* elements that are displayed when their models are visible.\n *\n * Should be set to true when `setAlwaysDrawn` is called with `exclusive` flag. Should be set to false\n * when `setAlwaysDrawn` is called with `exclusive` set to `false` or `undefined`, or when `clearAlwaysDrawn` is called.\n */\n readonly isAlwaysDrawnExclusive: boolean;\n /** Event that should be raised when set of always-drawn elements changes. */\n onAlwaysDrawnChanged: BeEvent<() => void>;\n /** Event that should be raised when set of never-drawn elements changes. */\n onNeverDrawnChanged: BeEvent<() => void>;\n /** Event that should be raised when per-model category overrides changes. */\n onPerModelCategoriesOverridesChanged: BeEvent<() => void>;\n /** Event that should be raised when category display changes. */\n onDisplayedCategoriesChanged: BeEvent<() => void>;\n /** Event that should be raised when model display changes. */\n onDisplayedModelsChanged: BeEvent<() => void>;\n /** Event that should be raised when view changes between `2d`, `3d` or `other`. */\n onDisplayStyleChanged: BeEvent<() => void>;\n}\n"]}
|