@itwin/presentation-frontend
Version:
Frontend of iModel.js Presentation library
181 lines • 9.79 kB
TypeScript
/** @packageDocumentation
* @module UnifiedSelection
*/
import { Id64Arg } from "@itwin/core-bentley";
import { IModelConnection } from "@itwin/core-frontend";
import { Keys, KeySet, SelectionScope, SelectionScopeProps } from "@itwin/presentation-common";
import { SelectionStorage } from "@itwin/unified-selection";
import { HiliteSet } from "./HiliteSetProvider.js";
import { ISelectionProvider } from "./ISelectionProvider.js";
import { SelectionChangeEvent } from "./SelectionChangeEvent.js";
import { SelectionScopesManager } from "./SelectionScopesManager.js";
/**
* Properties for creating [[SelectionManager]].
* @public
* @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
*/
export interface SelectionManagerProps {
/** A manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */
scopes: SelectionScopesManager;
/**
* Custom unified selection storage to be used by [[SelectionManager]]. If not provided [[SelectionManager]] creates
* and maintains storage.
*/
selectionStorage?: SelectionStorage;
/**
* An optional function that returns a key for the given iModel. The key is what "glues" iModel selection
* changes made in `selectionStorage`, where iModels are identified by key, and `SelectionManager`, where
* iModels are specified as `IModelConnection`.
*
* If not provided, [IModelConnection.key]($core-frontend) or [IModelConnection.name]($core-frontend) is used.
*/
imodelKeyFactory?: (imodel: IModelConnection) => string;
}
/**
* The selection manager which stores the overall selection.
* @public
* @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
*/
export declare class SelectionManager implements ISelectionProvider, Disposable {
private _imodelKeyFactory;
private _imodelToolSelectionSyncHandlers;
private _hiliteSetProviders;
private _ownsStorage;
private _knownIModels;
private _currentSelection;
private _selectionChanges;
private _selectionEventsSubscription;
private _listeners;
/**
* Underlying selection storage used by this selection manager. Ideally, consumers should use
* the storage directly instead of using this manager to manipulate selection.
*/
readonly selectionStorage: SelectionStorage;
/** An event which gets broadcasted on selection changes */
readonly selectionChange: SelectionChangeEvent;
/** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */
readonly scopes: SelectionScopesManager;
/**
* Creates an instance of SelectionManager.
*/
constructor(props: SelectionManagerProps);
[Symbol.dispose](): void;
/** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */
dispose(): void;
private onConnectionClose;
/**
* Request the manager to sync with imodel's tool selection (see `IModelConnection.selectionSet`).
*/
setSyncWithIModelToolSelection(imodel: IModelConnection, sync?: boolean): void;
/**
* Temporarily suspends tool selection synchronization until the returned `Disposable`
* is disposed.
*/
suspendIModelToolSelectionSync(imodel: IModelConnection): {
[Symbol.dispose]: () => void;
dispose: () => void;
};
/** Get the selection levels currently stored in this manager for the specified imodel */
getSelectionLevels(imodel: IModelConnection): number[];
/**
* Get the selection currently stored in this manager
*
* @note Calling immediately after `add*`|`replace*`|`remove*`|`clear*` method call does not guarantee
* that returned `KeySet` will include latest changes. Listen for `selectionChange` event to get the
* latest selection after changes.
*/
getSelection(imodel: IModelConnection, level?: number): Readonly<KeySet>;
private handleEvent;
/**
* Add keys to the selection
* @param source Name of the selection source
* @param imodel iModel associated with the selection
* @param keys Keys to add
* @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))
* @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control
*/
addToSelection(source: string, imodel: IModelConnection, keys: Keys, level?: number, rulesetId?: string): void;
/**
* Remove keys from current selection
* @param source Name of the selection source
* @param imodel iModel associated with the selection
* @param keys Keys to remove
* @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))
* @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control
*/
removeFromSelection(source: string, imodel: IModelConnection, keys: Keys, level?: number, rulesetId?: string): void;
/**
* Replace current selection
* @param source Name of the selection source
* @param imodel iModel associated with the selection
* @param keys Keys to add
* @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))
* @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control
*/
replaceSelection(source: string, imodel: IModelConnection, keys: Keys, level?: number, rulesetId?: string): void;
/**
* Clear current selection
* @param source Name of the selection source
* @param imodel iModel associated with the selection
* @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))
* @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control
*/
clearSelection(source: string, imodel: IModelConnection, level?: number, rulesetId?: string): void;
/**
* Add keys to selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.
* @param source Name of the selection source
* @param imodel iModel associated with the selection
* @param ids Element IDs to add
* @param scope Selection scope to apply
* @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))
* @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control
*/
addToSelectionWithScope(source: string, imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string, level?: number, rulesetId?: string): Promise<void>;
/**
* Remove keys from current selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.
* @param source Name of the selection source
* @param imodel iModel associated with the selection
* @param ids Element IDs to remove
* @param scope Selection scope to apply
* @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))
* @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control
*/
removeFromSelectionWithScope(source: string, imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string, level?: number, rulesetId?: string): Promise<void>;
/**
* Replace current selection with keys after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.
* @param source Name of the selection source
* @param imodel iModel associated with the selection
* @param ids Element IDs to replace with
* @param scope Selection scope to apply
* @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))
* @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control
*/
replaceSelectionWithScope(source: string, imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string, level?: number, rulesetId?: string): Promise<void>;
/**
* Get the current hilite set for the specified imodel
* @public
*/
getHiliteSet(imodel: IModelConnection): Promise<HiliteSet>;
/**
* Get the current hilite set iterator for the specified imodel.
* @public
*/
getHiliteSetIterator(imodel: IModelConnection): AsyncIterableIterator<HiliteSet>;
private getHiliteSetProvider;
private streamSelectionEvents;
}
/** @internal */
export declare class ToolSelectionSyncHandler implements Disposable {
private _selectionSourceName;
private _logicalSelection;
private _imodel;
private _imodelToolSelectionListenerDisposeFunc;
private _asyncsTracker;
isSuspended?: boolean;
constructor(imodel: IModelConnection, logicalSelection: SelectionManager);
[Symbol.dispose](): void;
/** note: used only it tests */
get pendingAsyncs(): Set<string>;
private onToolSelectionChanged;
}
//# sourceMappingURL=SelectionManager.d.ts.map