@itwin/core-backend
Version:
iTwin.js backend components
90 lines • 5.46 kB
TypeScript
/** @packageDocumentation
* @module Elements
*/
import { RelatedElement, RelationshipProps, TextBlock } from "@itwin/core-common";
import { ElementDrivesElement } from "../Relationship";
import { IModelDb } from "../IModelDb";
import { Element } from "../Element";
import { Id64String } from "@itwin/core-bentley";
import { IModelElementCloneContext } from "../IModelElementCloneContext";
/** Describes one of potentially many [TextBlock]($common)s hosted by an [[ITextAnnotation]].
* For example, a [[TextAnnotation2d]] hosts only a single text block, but an element representing a table may
* host one text block for each cell in the table, in which case it might use the combination of row and column
* as the [[id]] for each text block.
* @beta
*/
export interface TextBlockAndId {
/** The text block. */
readonly textBlock: TextBlock;
/** An opaque identifier that allows the [[ITextAnnotation]] to discern which of its hosted text blocks is being referred to. */
readonly id: unknown;
}
/** Interface implemented by [[GeometricElement]] subclasses whose schemas declare them to implement the mix-in `BisCore:ITextAnnotation`.
* Such elements may host any number of [TextBlock]($common)s. `ITextAnnotation` provides a uniform way to interact with text regardless of
* the type of element to which it belongs.
* @beta
*/
export interface ITextAnnotation {
/** The default [[AnnotationTextStyle]] used by the text annotation. */
defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;
/** Obtain a collection of all of the [TextBlock]($common)s hosted by this element. */
getTextBlocks(): Iterable<TextBlockAndId>;
/** Update the element in-memory to replace the contents of the specified [TextBlock]($common)s. */
updateTextBlocks(textBlocks: TextBlockAndId[]): void;
}
/** Returns `true` if the specified `element` implements [[ITextAnnotation]].
* @beta
*/
export declare function isITextAnnotation(element: Element): element is ITextAnnotation & Element;
/** Arguments supplied to [[ElementDrivesTextAnnotation.evaluateFields]].
* @beta
*/
export interface EvaluateFieldsArgs {
/** The text block whose fields are to be evaluated. */
block: TextBlock;
/** The iModel containing the elements supplying the display strings for the fields in [[block]]. */
iModel: IModelDb;
}
/** A relationship in which the source element hosts one or more properties that are displayed by a target [[ITextAnnotation]] element.
* This relationship is used to automatically update the [FieldRun]($common)s contained in the target element when the source element is modified.
* An [[ITextAnnotation]] element should invoke [[updateFieldDependencies]] from its [[Element.onInserted]] and [[Element.onUpdated]] functions to
* establish or update the relationships required for the [FieldRun]($common)s it contains.
* @note This relationship was introduced in version 01.00.22 of the BisCore schema. [FieldRun]($common)s created in iModels that have not been upgraded to
* that version or newer will not automatically update. Use [[isSupportedForIModel]] to check.
* @beta
*/
export declare class ElementDrivesTextAnnotation extends ElementDrivesElement {
static get className(): string;
/** @internal */
static onRootChanged(props: RelationshipProps, iModel: IModelDb): void;
/** @internal */
static onDeletedDependency(props: RelationshipProps, iModel: IModelDb): void;
/** Returns true if `iModel` contains a version of the BisCore schema new enough to support this relationship.
* If not, the schema should be updated before inserting any [FieldRun]($common)s, or those runs will not
* update when the source element changes.
*/
static isSupportedForIModel(iModel: IModelDb): boolean;
/** Examines all of the [FieldRun]($common)s within the specified [[ITextAnnotation]] and ensures that the appropriate
* `ElementDrivesTextAnnotation` relationships exist between the fields' source elements and this target element.
* It also deletes any stale relationships left over from fields that were deleted or whose source elements changed.
*/
static updateFieldDependencies(annotationElementId: Id64String, iModel: IModelDb): void;
/** Recompute the display strings of all [FieldRun]($common)s in a [TextBlock]($common).
* @returns the number of fields whose display strings were modified.
* @throws Error if evaluation of any field fails.
*/
static evaluateFields(args: EvaluateFieldsArgs): number;
/** When copying an [[ITextAnnotation]] from one iModel into another, remaps the element Ids in any [FieldPropertyHost]($common) within the cloned element
* so that they refer to elements in the `context`'s target iModel, and sets any Ids that cannot be remapped to [Id64.invalid]($bentley).
* Implementations of `ITextAnnotation` should invoke this function from their implementations of [[Element.onCloned]].
*/
static remapFields(clone: ITextAnnotation, context: IModelElementCloneContext): void;
}
/** Relationship indicating that the [[AnnotationTextStyle]] is being used as the default style for the [[ITextAnnotation]].
* @beta
*/
export declare class TextAnnotationUsesTextStyleByDefault extends RelatedElement {
static classFullName: string;
constructor(annotationTextStyleId: Id64String, relClassName?: string);
}
//# sourceMappingURL=ElementDrivesTextAnnotation.d.ts.map