@itwin/core-backend
Version:
iTwin.js backend components
411 lines • 18.3 kB
TypeScript
/** @packageDocumentation
* @module Models
*/
import { GuidString, Id64String } from "@itwin/core-bentley";
import { Point2d } from "@itwin/core-geometry";
import { AxisAlignedBox3d, ElementProps, EntityReferenceSet, GeometricModel2dProps, GeometricModel3dProps, GeometricModelProps, ModelProps, RelatedElement } from "@itwin/core-common";
import { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow, Entity } from "./Entity";
import { IModelDb } from "./IModelDb";
/** Argument for the `Model.onXxx` static methods
* @beta
*/
export interface OnModelArg {
/** The iModel for the Model affected. */
iModel: IModelDb;
}
/** Argument for the `Model.onXxx` static methods that supply the properties of a Model to be inserted or updated.
* @beta
*/
export interface OnModelPropsArg extends OnModelArg {
/** The new properties of the Model affected. */
props: Readonly<ModelProps>;
}
/** Argument for the `Model.onXxx` static methods that only supply the Id of the affected Model.
* @beta
*/
export interface OnModelIdArg extends OnModelArg {
/** The Id of the Model affected */
id: Id64String;
}
/** Argument for the `Model.onXxxElement` static methods that supply the properties of an Element for a Model.
* @beta
*/
export interface OnElementInModelPropsArg extends OnModelIdArg {
/** The new properties of an Element for the affected Model */
elementProps: Readonly<ElementProps>;
}
/** Argument for the `Model.onXxxElement` static methods that supply the Id of an Element for a Model.
* @beta
*/
export interface OnElementInModelIdArg extends OnModelIdArg {
/** The Id of the Element for the affected Model */
elementId: Id64String;
}
/** A Model is a container for persisting a collection of related elements within an iModel.
* See [[IModelDb.Models]] for how to query and manage the Models in an IModelDb.
* See [Creating models]($docs/learning/backend/CreateModels.md)
* @public @preview
*/
export declare class Model extends Entity {
static get className(): string;
/** @internal */
static get protectedOperations(): string[];
readonly modeledElement: RelatedElement;
readonly name: string;
readonly parentModel?: Id64String;
readonly jsonProperties: {
[key: string]: any;
};
isPrivate: boolean;
isTemplate: boolean;
protected constructor(props: ModelProps, iModel: IModelDb);
/**
* Model custom HandledProps includes 'isPrivate', 'isTemplate', and 'lastMod'.
* @inheritdoc
* @beta
*/
protected static readonly _customHandledProps: CustomHandledProperty[];
/**
* Model deserializes 'isPrivate', and 'isTemplate', and sets the proper parentModel.
* @inheritdoc
* @beta
*/
static deserialize(props: DeserializeEntityArgs): ModelProps;
/**
* Model serializes 'isPrivate', and 'isTemplate'.
* @inheritdoc
* @beta
*/
static serialize(props: ModelProps, _iModel: IModelDb): ECSqlRow;
toJSON(): ModelProps;
/** Called before a new Model is inserted.
* @note throw an exception to disallow the insert
* @note If you override this method, you must call super.
* @note `this` is the class of the Model to be inserted
* @beta
*/
protected static onInsert(arg: OnModelPropsArg): void;
/** Called after a new Model is inserted.
* @note If you override this method, you must call super.
* @note `this` is the class of the Model that was inserted
* @beta
*/
protected static onInserted(_arg: OnModelIdArg): void;
/** Called before a Model is updated.
* @note throw an exception to disallow the update
* @note If you override this method, you must call super.
* @note `this` is the class of the Model to be updated
* @beta
*/
protected static onUpdate(arg: OnModelPropsArg): void;
/** Called after a Model is updated.
* @note If you override this method, you must call super.
* @note `this` is the class of the Model that was updated.
* @beta
*/
protected static onUpdated(arg: OnModelIdArg): void;
/** Called before a Model is deleted.
* @note throw an exception to disallow the delete
* @note If you override this method, you must call super.
* @note `this` is the class of the Model to be deleted
* @beta
*/
protected static onDelete(arg: OnModelIdArg): void;
/** Called after a Model was deleted.
* @note If you override this method, you must call super.
* @note `this` is the class of the Model that was deleted
* @beta
*/
protected static onDeleted(arg: OnModelIdArg): void;
/** Called before a prospective Element is to be inserted into an instance of a Model of this class.
* @note throw an exception to disallow the insert
* @note If you override this method, you must call super.
* @note `this` is the class of the Model to hold the element
* @beta
*/
protected static onInsertElement(_arg: OnElementInModelPropsArg): void;
/** Called after an Element has been inserted into an instance of a Model of this class.
* @note If you override this method, you must call super.
* @note `this` is the class of the Model holding the element
* @beta
*/
protected static onInsertedElement(arg: OnElementInModelIdArg): void;
/** Called when an Element in an instance of a Model of this class is about to be updated.
* @note throw an exception to disallow the update
* @note If you override this method, you must call super.
* @note `this` is the class of the Model holding the element
* @beta
*/
protected static onUpdateElement(_arg: OnElementInModelPropsArg): void;
/** Called after an Element in an instance of a Model of this class has been updated.
* @note If you override this method, you must call super.
* @note `this` is the class of the Model holding the element
* @beta
*/
protected static onUpdatedElement(arg: OnElementInModelIdArg): void;
/** Called when an Element in an instance of a Model of this class is about to be deleted.
* @note throw an exception to disallow the delete
* @note If you override this method, you must call super.
* @note `this` is the class of the Model holding the element
* @beta
*/
protected static onDeleteElement(_arg: OnElementInModelIdArg): void;
/** Called after an Element in an instance of a Model of this class has been deleted.
* @note If you override this method, you must call super.
* @note `this` is the class of the Model that held the element
* @beta
*/
protected static onDeletedElement(arg: OnElementInModelIdArg): void;
private getAllUserProperties;
/** Get a set of JSON user properties by namespace */
getUserProperties(namespace: string): any;
/** Change a set of user JSON properties of this Element by namespace. */
setUserProperties(nameSpace: string, value: any): void;
/** Remove a set of JSON user properties, specified by namespace, from this Element */
removeUserProperties(nameSpace: string): void;
getJsonProperty(name: string): any;
setJsonProperty(name: string, value: any): void;
/** Insert this Model in the iModel */
insert(): string;
/** Update this Model in the iModel. */
update(): void;
/** Delete this Model from the iModel. */
delete(): void;
protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
}
/** A container for persisting geometric elements.
* @public @preview
*/
export declare class GeometricModel extends Model {
geometryGuid?: GuidString;
static get className(): string;
protected constructor(props: GeometricModelProps, iModel: IModelDb);
/** Query for the union of the extents of the elements contained by this model.
* @note This function blocks the JavaScript event loop. Consider using [[queryRange]] instead.
*/
queryExtents(): AxisAlignedBox3d;
/** Query for the union of the extents of all elements contained within this model. */
queryRange(): Promise<AxisAlignedBox3d>;
}
/** A container for persisting 3d geometric elements.
* @public @preview
*/
export declare abstract class GeometricModel3d extends GeometricModel {
/** If true, then the elements in this GeometricModel3d are expected to be in an XY plane.
* @note The associated ECProperty was added to the BisCore schema in version 1.0.8
*/
readonly isPlanProjection: boolean;
/** If true, then the elements in this GeometricModel3d are not in real-world coordinates and will not be in the spatial index.
* @note The associated ECProperty was added to the BisCore schema in version 1.0.8
*/
readonly isNotSpatiallyLocated: boolean;
/** If true, then the elements in this GeometricModel3d are in real-world coordinates and will be in the spatial index. */
get isSpatiallyLocated(): boolean;
static get className(): string;
protected constructor(props: GeometricModel3dProps, iModel: IModelDb);
/**
* GeometricModel3d custom HandledProps includes 'isPlanProjection', and 'isNotSpatiallyLocated'.
* @inheritdoc
* @beta
*/
protected static readonly _customHandledProps: CustomHandledProperty[];
/**
* GeometricModel3d deserializes 'isPlanProjection', and 'isNotSpatiallyLocated'.
* @inheritdoc
* @beta
*/
static deserialize(props: DeserializeEntityArgs): GeometricModel3dProps;
/**
* GeometricModel3d serializes 'isPlanProjection', and 'isNotSpatiallyLocated'.
* @inheritdoc
* @beta
*/
static serialize(props: GeometricModel3dProps, _iModel: IModelDb): ECSqlRow;
toJSON(): GeometricModel3dProps;
}
/** A container for persisting 2d geometric elements.
* @public @preview
*/
export declare abstract class GeometricModel2d extends GeometricModel {
/** The actual coordinates of (0,0) in modeling coordinates. An offset applied to all modeling coordinates. */
globalOrigin?: Point2d;
static get className(): string;
protected constructor(props: GeometricModel2dProps, iModel: IModelDb);
toJSON(): GeometricModel2dProps;
}
/** A container for persisting 2d graphical elements.
* @public @preview
*/
export declare abstract class GraphicalModel2d extends GeometricModel2d {
static get className(): string;
}
/** A container for persisting GraphicalElement3d instances.
* @note The associated ECClass was added to the BisCore schema in version 1.0.8
* @see [[GraphicalPartition3d]]
* @public @preview
*/
export declare abstract class GraphicalModel3d extends GeometricModel3d {
static get className(): string;
}
/** A container for persisting 3d geometric elements that are spatially located.
* @public @preview
*/
export declare abstract class SpatialModel extends GeometricModel3d {
static get className(): string;
}
/** A container for persisting physical elements that model physical space.
* @see [[PhysicalPartition]]
* @public @preview
*/
export declare class PhysicalModel extends SpatialModel {
static get className(): string;
/** Insert a PhysicalPartition and a PhysicalModel that sub-models it.
* @param iModelDb Insert into this iModel
* @param parentSubjectId The PhysicalPartition will be inserted as a child of this Subject element.
* @param name The name of the PhysicalPartition that the new PhysicalModel will sub-model.
* @param isPlanProjection Optional value (default is false) that indicates if the contents of this model are expected to be in an XY plane.
* @returns The Id of the newly inserted PhysicalPartition and PhysicalModel (same value).
* @throws [[IModelError]] if there is an insert problem.
*/
static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String;
}
/** A container for persisting spatial location elements.
* @see [[SpatialLocationPartition]]
* @public @preview
*/
export declare class SpatialLocationModel extends SpatialModel {
static get className(): string;
/** Insert a SpatialLocationPartition and a SpatialLocationModel that sub-models it.
* @param iModelDb Insert into this iModel
* @param parentSubjectId The SpatialLocationPartition will be inserted as a child of this Subject element.
* @param name The name of the SpatialLocationPartition that the new SpatialLocationModel will sub-model.
* @param isPlanProjection Optional value (default is false) that indicates if the contents of this model are expected to be in an XY plane.
* @returns The Id of the newly inserted SpatialLocationPartition and SpatialLocationModel (same value).
* @throws [[IModelError]] if there is an insert problem.
*/
static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String;
}
/** A 2d model that holds [[DrawingGraphic]]s. DrawingModels may be dimensional or non-dimensional.
* @public @preview
*/
export declare class DrawingModel extends GraphicalModel2d {
static get className(): string;
}
/** A container for persisting section [[DrawingGraphic]]s.
* @public @preview
*/
export declare class SectionDrawingModel extends DrawingModel {
static get className(): string;
}
/** A container for persisting [[ViewAttachment]]s and [[DrawingGraphic]]s.
* A SheetModel is a digital representation of a *sheet of paper*. SheetModels are 2d models in bounded paper coordinates.
* SheetModels may contain annotation Elements as well as references to 2d or 3d Views.
* @public @preview
*/
export declare class SheetModel extends GraphicalModel2d {
static get className(): string;
}
/** A container for persisting role elements.
* @public @preview
*/
export declare class RoleModel extends Model {
static get className(): string;
}
/** A container for persisting information elements.
* @public @preview
*/
export declare abstract class InformationModel extends Model {
static get className(): string;
}
/** A container for persisting group information elements.
* @see [[GroupInformationPartition]]
* @public @preview
*/
export declare abstract class GroupInformationModel extends InformationModel {
static get className(): string;
}
/** A sub-model of a [[SheetIndexPartition]] serving as a container for persisting [[SheetIndexEntry]] and [[SheetIndex]] elements.
* @beta
*/
export declare class SheetIndexModel extends InformationModel {
static get className(): string;
/** Insert a SheetIndex and a SheetIndexModel that sub-models it.
* @param iModelDb Insert into this iModel
* @param parentSubjectId The SheetIndex will be inserted as a child of this Subject element.
* @param name The name of the SheetIndex that the new SheetIndexModel will sub-model.
* @returns The Id of the newly inserted SheetIndexModel.
* @throws [[IModelError]] if there is an insert problem.
*/
static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String;
}
/** A container for persisting Information Record Elements
* @see [[InformationRecordPartition]]
* @public @preview
*/
export declare class InformationRecordModel extends InformationModel {
static get className(): string;
/** Insert a InformationRecordPartition and a InformationRecordModel that sub-models it.
* @param iModelDb Insert into this iModel
* @param parentSubjectId The InformationRecordPartition will be inserted as a child of this Subject element.
* @param name The name of the InformationRecordPartition that the new InformationRecordModel will sub-model.
* @returns The Id of the newly inserted InformationRecordModel.
* @throws [[IModelError]] if there is an insert problem.
*/
static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String;
}
/** A container for persisting definition elements.
* @see [[DefinitionPartition]]
* @public @preview
*/
export declare class DefinitionModel extends InformationModel {
static get className(): string;
/** Insert a DefinitionPartition and a DefinitionModel that sub-models it.
* @param iModelDb Insert into this iModel
* @param parentSubjectId The DefinitionPartition will be inserted as a child of this Subject element.
* @param name The name of the DefinitionPartition that the new DefinitionModel will sub-model.
* @returns The Id of the newly inserted DefinitionModel.
* @throws [[IModelError]] if there is an insert problem.
*/
static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String;
}
/** The singleton container of repository-related information elements.
* @public @preview
*/
export declare class RepositoryModel extends DefinitionModel {
static get className(): string;
}
/** Contains a list of document elements.
* @see [[DocumentPartition]]
* @public @preview
*/
export declare class DocumentListModel extends InformationModel {
static get className(): string;
/** Insert a DocumentPartition and a DocumentListModel that sub-models it.
* @param iModelDb Insert into this iModel
* @param parentSubjectId The DocumentPartition will be inserted as a child of this Subject element.
* @param name The name of the DocumentPartition that the new DocumentListModel will sub-model.
* @returns The Id of the newly inserted DocumentPartition and DocumentListModel (same value)
* @throws [[IModelError]] if there is an insert problem.
*/
static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String;
}
/** A container for persisting link elements.
* @see [[LinkPartition]]
* @public @preview
*/
export declare class LinkModel extends InformationModel {
static get className(): string;
}
/** The singleton container for repository-specific definition elements.
* @public @preview
*/
export declare class DictionaryModel extends DefinitionModel {
static get className(): string;
}
/** Obtains and displays multi-resolution tiled raster organized according to the WebMercator tiling system.
* @public @preview
*/
export declare class WebMercatorModel extends SpatialModel {
static get className(): string;
}
//# sourceMappingURL=Model.d.ts.map