@itwin/core-frontend
Version:
iTwin.js frontend components
47 lines • 3.39 kB
TypeScript
/** @packageDocumentation
* @module QuantityFormatting
*/
import { FormatProps, UnitSystemKey } from "@itwin/core-quantity";
import { IModelConnection } from "../IModelConnection";
import { FormattingUnitSystemChangedArgs, OverrideFormatEntry, QuantityFormatOverridesChangedArgs, QuantityFormatter, QuantityTypeKey, UnitFormattingSettingsProvider } from "./QuantityFormatter";
/** This abstract class reacts to changes in the "active" iModel and updates the [[QuantityFormatter]] overrides and active
* presentation unit system based on stored preferences. In addition, monitors the [[QuantityFormatter]] for changes to format overrides and the active
* unit system and stores these changes. The "active" iModel is determined by listening to the `IModelApp.viewManager.onSelectedViewportChanged` event
* and gets the iModel from the selected viewport.
* @beta
*/
export declare abstract class BaseUnitFormattingSettingsProvider implements UnitFormattingSettingsProvider {
private _quantityFormatter;
private _maintainOverridesPerIModel?;
protected _imodelConnection: IModelConnection | undefined;
/**
* @param maintainOverridesPerIModel If maintainOverridesPerIModel is true the base class will set up listeners
* to monitor "active" iModel changes so the overrides for the QuantityFormatter properly match the overrides set
* up by the user. If false then the overrides are maintained only per user.
* @beta
*/
constructor(_quantityFormatter: QuantityFormatter, _maintainOverridesPerIModel?: boolean | undefined);
get maintainOverridesPerIModel(): boolean;
storeFormatOverrides: ({ typeKey, overrideEntry, unitSystem }: QuantityFormatOverridesChangedArgs) => Promise<void>;
/** save UnitSystem for active iModel */
storeUnitSystemSetting: ({ system }: FormattingUnitSystemChangedArgs) => Promise<void>;
loadOverrides(imodel?: IModelConnection): Promise<void>;
protected applyQuantityFormattingSettingsForIModel: (imodel?: IModelConnection) => Promise<void>;
private handleIModelOpen;
private handleViewportChanged;
private handleIModelClose;
protected get imodelConnection(): IModelConnection | undefined;
/** function to convert from serialized JSON format for Quantity Type overrides to build a map compatible with QuantityManager */
protected buildQuantityFormatOverridesMap(): Promise<Map<UnitSystemKey, Map<string, FormatProps>>>;
/** Serializes JSON object containing format overrides for a specific quantity type. */
abstract store(quantityTypeKey: QuantityTypeKey, overrideProps: OverrideFormatEntry): Promise<boolean>;
/** Retrieves serialized JSON object containing format overrides for a specific quantity type. */
abstract retrieve(quantityTypeKey: QuantityTypeKey): Promise<OverrideFormatEntry | undefined>;
/** Removes the override formats for a specific quantity type. */
abstract remove(quantityTypeKey: QuantityTypeKey): Promise<boolean>;
/** Retrieves the active unit system typically based on the "active" iModelConnection. */
abstract retrieveUnitSystem(defaultKey: UnitSystemKey): Promise<UnitSystemKey>;
/** Store the active unit system typically for the "active" iModelConnection. */
abstract storeUnitSystemKey(unitSystemKey: UnitSystemKey): Promise<boolean>;
}
//# sourceMappingURL=BaseUnitFormattingSettingsProvider.d.ts.map