@itwin/core-backend
Version:
iTwin.js backend components
333 lines • 15.1 kB
TypeScript
/** @packageDocumentation
* @module Elements
*/
import { AnnotationTextStyleProps, Code, CodeProps, CodeScopeProps, EntityReferenceSet, Placement2dProps, Placement3dProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps, VersionedJSON } from "@itwin/core-common";
import { IModelDb } from "../IModelDb";
import { AnnotationElement2d, DefinitionElement, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from "../Element";
import { Id64String } from "@itwin/core-bentley";
import { TextAnnotationUsesTextStyleByDefault, TextBlockAndId } from "./ElementDrivesTextAnnotation";
import { IModelElementCloneContext } from "../IModelElementCloneContext";
import { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from "../Entity";
/** The version of the JSON stored in `TextAnnotation2d/3dProps.textAnnotationData` used by the code.
* Uses the same semantics as [ECVersion]($ecschema-metadata).
* @internal
*/
export declare const TEXT_ANNOTATION_JSON_VERSION = "1.0.0";
/** Parses, validates, and potentially migrates the text annotation data from a JSON string.
* @internal
*/
export declare function parseTextAnnotationData(json: string | undefined): VersionedJSON<TextAnnotationProps> | undefined;
/** Arguments supplied when creating a [[TextAnnotation2d]].
* @beta
*/
export interface TextAnnotation2dCreateArgs {
/** The category ID for the annotation. */
category: Id64String;
/** The model ID where the annotation will be placed. */
model: Id64String;
/** The placement properties for the annotation. */
placement: Placement2dProps;
/** The default text style ID for the annotation. */
defaultTextStyleId?: Id64String;
/** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided. */
textAnnotationProps?: TextAnnotationProps;
/** Optional code for the element. */
code?: CodeProps;
}
/** Arguments supplied when creating a [[TextAnnotation3d]].
* @beta
*/
export interface TextAnnotation3dCreateArgs {
/** The category ID for the annotation. */
category: Id64String;
/** The model ID where the annotation will be placed. */
model: Id64String;
/** The placement properties for the annotation. */
placement: Placement3dProps;
/** The default text style ID for the annotation. */
defaultTextStyleId?: Id64String;
/** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided. */
textAnnotationProps?: TextAnnotationProps;
/** Optional code for the element. */
code?: CodeProps;
}
/** An element that displays textual content within a 2d model.
* The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
* @see [[setAnnotation]] to change the textual content.
* @public @preview
*/
export declare class TextAnnotation2d extends AnnotationElement2d {
/** @internal */
static get className(): string;
/**
* The default [[AnnotationTextStyle]] used by the TextAnnotation2d.
* @beta
*/
defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;
/** The data associated with the text annotation. */
private _textAnnotationProps?;
/** Extract the textual content, if present.
* @see [[setAnnotation]] to change it.
*/
getAnnotation(): TextAnnotation | undefined;
/** Change the textual content of the `TextAnnotation2d`.
* @see [[getAnnotation]] to extract the current annotation.
* @param annotation The new annotation
*/
setAnnotation(annotation: TextAnnotation): void;
protected constructor(props: TextAnnotation2dProps, iModel: IModelDb);
/** Creates a new instance of `TextAnnotation2d` from its JSON representation. */
static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d;
/**
* Converts the current `TextAnnotation2d` instance to its JSON representation.
* It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.
* @inheritdoc
*/
toJSON(): TextAnnotation2dProps;
/** Creates a new `TextAnnotation2d` instance with the specified properties.
* @param iModelDb The iModel.
* @param arg The arguments for creating the TextAnnotation2d.
* @beta
*/
static create(iModelDb: IModelDb, arg: TextAnnotation2dCreateArgs): TextAnnotation2d;
/**
* Updates the geometry of the TextAnnotation2d on insert and validates version.
* @inheritdoc
* @beta
*/
protected static onInsert(arg: OnElementPropsArg): void;
/**
* Updates the geometry of the TextAnnotation2d on update and validates version.
* @inheritdoc
* @beta
*/
protected static onUpdate(arg: OnElementPropsArg): void;
/**
* Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).
* Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.
* Also, validates the version of the text annotation data and migrates it if necessary.
* @beta
*/
protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void;
/**
* TextAnnotation2d custom HandledProps include 'textAnnotationData'.
* @inheritdoc
* @internal
*/
protected static readonly _customHandledProps: CustomHandledProperty[];
/**
* TextAnnotation2d deserializes 'textAnnotationData'.
* @inheritdoc
* @beta
*/
static deserialize(props: DeserializeEntityArgs): TextAnnotation2dProps;
/**
* TextAnnotation2d serializes 'textAnnotationData'.
* @inheritdoc
* @beta
*/
static serialize(props: TextAnnotation2dProps, iModel: IModelDb): ECSqlRow;
/** @internal */
getTextBlocks(): Iterable<TextBlockAndId>;
/** @internal */
updateTextBlocks(textBlocks: TextBlockAndId[]): void;
/** @internal */
static onInserted(arg: OnElementIdArg): void;
/** @internal */
static onUpdated(arg: OnElementIdArg): void;
protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
/** @internal */
protected static onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation2dProps, dstProps: TextAnnotation2dProps): Promise<void>;
}
/** An element that displays textual content within a 3d model.
* The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
* @see [[setAnnotation]] to change the textual content.
* @public @preview
*/
export declare class TextAnnotation3d extends GraphicalElement3d {
/** @internal */
static get className(): string;
/**
* The default [[AnnotationTextStyle]] used by the TextAnnotation3d.
* @beta
*/
defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;
/** The data associated with the text annotation. */
private _textAnnotationProps?;
/** Extract the textual content, if present.
* @see [[setAnnotation]] to change it.
*/
getAnnotation(): TextAnnotation | undefined;
/** Change the textual content of the `TextAnnotation3d`.
* @see [[getAnnotation]] to extract the current annotation.
* @param annotation The new annotation
*/
setAnnotation(annotation: TextAnnotation): void;
protected constructor(props: TextAnnotation3dProps, iModel: IModelDb);
/** Creates a new instance of `TextAnnotation3d` from its JSON representation. */
static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d;
/**
* Converts the current `TextAnnotation3d` instance to its JSON representation.
* It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.
* @inheritdoc
*/
toJSON(): TextAnnotation3dProps;
/** Creates a new `TextAnnotation3d` instance with the specified properties.
* @param iModelDb The iModel.
* @param arg The arguments for creating the TextAnnotation3d.
* @beta
*/
static create(iModelDb: IModelDb, arg: TextAnnotation3dCreateArgs): TextAnnotation3d;
/**
* Updates the geometry of the TextAnnotation3d on insert and validates version..
* @inheritdoc
* @beta
*/
protected static onInsert(arg: OnElementPropsArg): void;
/**
* Updates the geometry of the TextAnnotation3d on update and validates version..
* @inheritdoc
* @beta
*/
protected static onUpdate(arg: OnElementPropsArg): void;
/**
* Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).
* Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.
* Also, validates the version of the text annotation data and migrates it if necessary.
* @beta
*/
protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void;
/**
* TextAnnotation3d custom HandledProps include 'textAnnotationData'.
* @inheritdoc
* @internal
*/
protected static readonly _customHandledProps: CustomHandledProperty[];
/**
* TextAnnotation3d deserializes 'textAnnotationData'.
* @inheritdoc
* @beta
*/
static deserialize(props: DeserializeEntityArgs): TextAnnotation3dProps;
/**
* TextAnnotation3d serializes 'textAnnotationData'.
* @inheritdoc
* @beta
*/
static serialize(props: TextAnnotation3dProps, iModel: IModelDb): ECSqlRow;
/** @internal */
getTextBlocks(): Iterable<TextBlockAndId>;
/** @internal */
updateTextBlocks(textBlocks: TextBlockAndId[]): void;
/** @internal */
static onInserted(arg: OnElementIdArg): void;
/** @internal */
static onUpdated(arg: OnElementIdArg): void;
protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
/** @internal */
protected static onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation3dProps, dstProps: TextAnnotation3dProps): Promise<void>;
}
/** The version of the JSON stored in `AnnotationTextStyleProps.settings` used by the code.
* Uses the same semantics as [ECVersion]($ecschema-metadata).
* @internal
*/
export declare const TEXT_STYLE_SETTINGS_JSON_VERSION = "1.0.1";
/** Arguments supplied when creating an [[AnnotationTextStyle]].
* @beta
*/
export interface TextStyleCreateArgs {
/** The ID of the [[DefinitionModel]]. */
definitionModelId: Id64String;
/** The name to assign to the [[AnnotationTextStyle]]. */
name: string;
/** Optional text style settings used to create the [[AnnotationTextStyle]]. Default settings will be used if not provided. */
settings?: TextStyleSettingsProps;
/** Optional description for the [[AnnotationTextStyle]]. */
description?: string;
}
/**
* The definition element that holds text style information.
* The style is stored as a [TextStyleSettings]($common).
* @beta
*/
export declare class AnnotationTextStyle extends DefinitionElement {
/** @internal */
static get className(): string;
/**
* Optional text describing the `AnnotationTextStyle`.
*/
description?: string;
/**
* The text style settings for the `AnnotationTextStyle`.
* @see [[TextStyleSettings]] for more information.
*/
settings: TextStyleSettings;
protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb);
/**
* Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.
*
* @param iModel - The IModelDb.
* @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.
* @param name - The AnnotationTextStyle name.
* @beta
*/
static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code;
/**
* Creates a new instance of `AnnotationTextStyle` with the specified properties.
*
* @param iModelDb - The iModelDb.
* @param arg - The arguments for creating the AnnotationTextStyle.
* @beta
*/
static create(iModelDb: IModelDb, arg: TextStyleCreateArgs): AnnotationTextStyle;
/**
* Converts the current `AnnotationTextStyle` instance to its JSON representation.
* @inheritdoc
*/
toJSON(): AnnotationTextStyleProps;
/** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */
static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle;
/**
* Validates that the AnnotationTextStyle's settings are valid before insert.
* @inheritdoc
* @beta
*/
protected static onInsert(arg: OnElementPropsArg): void;
/**
* Validates that the AnnotationTextStyle's settings are valid before update.
* @inheritdoc
* @beta
*/
protected static onUpdate(arg: OnElementPropsArg): void;
private static validateSettings;
/**
* AnnotationTextStyle custom HandledProps include 'settings'.
* @inheritdoc
* @beta
*/
protected static readonly _customHandledProps: CustomHandledProperty[];
/**
* AnnotationTextStyle deserializes 'settings'.
* @inheritdoc
* @beta
*/
static deserialize(props: DeserializeEntityArgs): AnnotationTextStyleProps;
/**
* AnnotationTextStyle serializes 'settings'.
* @inheritdoc
* @beta
*/
static serialize(props: AnnotationTextStyleProps, iModel: IModelDb): ECSqlRow;
/** Parses, validates, and potentially migrates the text style settings data from a JSON string. */
private static parseTextStyleSettings;
/** When copying an element from one iModel to another, returns the Id of the AnnotationTextStyle in the `context`'s target iModel
* corresponding to `sourceTextStyleId`, or [Id64.invalid]($bentley) if no corresponding text style exists.
* If a text style with the same [Code]($common) exists in the target iModel, the style Id will be remapped to refer to that style.
* Otherwise, a copy of the style will be imported into the target iModel and its element Id returned.
* Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element.onCloned]] method.
* @throws Error if an attempt to import the text style failed.
*/
static remapTextStyleId(sourceTextStyleId: Id64String, context: IModelElementCloneContext): Promise<Id64String>;
protected static onCloned(context: IModelElementCloneContext, srcProps: AnnotationTextStyleProps, dstProps: AnnotationTextStyleProps): Promise<void>;
}
//# sourceMappingURL=TextAnnotationElement.d.ts.map