UNPKG

@itwin/core-backend

Version:
518 lines • 26.5 kB
/** @packageDocumentation * @module ViewDefinitions */ import { Id64Array, Id64String } from "@itwin/core-bentley"; import { Angle, Point2d, Point3d, Range2d, Range3d, StandardViewIndex, Vector3d, YawPitchRollAngles } from "@itwin/core-geometry"; import { AuxCoordSystem2dProps, AuxCoordSystem3dProps, AuxCoordSystemProps, Camera, CategorySelectorProps, Code, CodeScopeProps, ConcreteEntityTypes, EntityReferenceSet, LightLocationProps, ModelSelectorProps, RelatedElement, SpatialViewDefinitionProps, ViewAttachmentProps, ViewDefinition2dProps, ViewDefinition3dProps, ViewDefinitionProps, ViewDetails, ViewDetails3d } from "@itwin/core-common"; import { DefinitionElement, GraphicalElement2d, SpatialLocationElement } from "./Element"; import { IModelDb } from "./IModelDb"; import { DisplayStyle, DisplayStyle2d, DisplayStyle3d } from "./DisplayStyle"; import { IModelElementCloneContext } from "./IModelElementCloneContext"; import { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from "./Entity"; /** Holds the list of Ids of GeometricModels displayed by a [[SpatialViewDefinition]]. Multiple SpatialViewDefinitions may point to the same ModelSelector. * @see [ModelSelectorState]($frontend) * See [how to create a ModelSelector]$(docs/learning/backend/CreateElements.md#ModelSelector). * @public @preview */ export declare class ModelSelector extends DefinitionElement { static get className(): string; /** The array of modelIds of the GeometricModels displayed by this ModelSelector */ models: Id64String[]; protected constructor(props: ModelSelectorProps, iModel: IModelDb); toJSON(): ModelSelectorProps; /** * ModelSelector custom HandledProps includes 'models'. * @inheritdoc * @beta */ protected static readonly _customHandledProps: CustomHandledProperty[]; /** * ModelSelector deserializes 'models'. * @inheritdoc * @beta */ static deserialize(props: DeserializeEntityArgs): ModelSelectorProps; protected collectReferenceIds(referenceIds: EntityReferenceSet): void; /** Create a Code for a ModelSelector given a name that is meant to be unique within the scope of the specified DefinitionModel. * @param iModel The IModelDb * @param scopeModelId The Id of the DefinitionModel that contains the ModelSelector and provides the scope for its name. * @param codeValue The ModelSelector name */ static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code; /** * Create a ModelSelector to select which Models are displayed by a ViewDefinition. * @param iModelDb The iModel * @param definitionModelId The [[DefinitionModel]] * @param name The name/CodeValue of the ModelSelector * @param models Array of models to select for display * @returns The newly constructed ModelSelector element. * @throws [[IModelError]] if unable to create the element. */ static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, models: Id64Array): ModelSelector; /** * Insert a ModelSelector to select which Models are displayed by a ViewDefinition. * @param iModelDb Insert into this iModel * @param definitionModelId Insert the new ModelSelector into this DefinitionModel * @param name The name/CodeValue of the ModelSelector * @param models Array of models to select for display * @returns The Id of the newly inserted ModelSelector element. * @throws [[IModelError]] if unable to insert the element. */ static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, models: Id64Array): Id64String; } /** Holds a list of Ids of Categories to be displayed in a view. * @see [CategorySelectorState]($frontend) * See [how to create a CategorySelector]$(docs/learning/backend/CreateElements.md#CategorySelector). * @public @preview */ export declare class CategorySelector extends DefinitionElement { static get className(): string; /** The array of element Ids of the Categories selected by this CategorySelector */ categories: Id64String[]; protected constructor(props: CategorySelectorProps, iModel: IModelDb); toJSON(): CategorySelectorProps; /** * CategorySelector custom HandledProps includes 'categories'. * @inheritdoc * @beta */ protected static readonly _customHandledProps: CustomHandledProperty[]; /** * CategorySelector deserializes 'categories'. * @inheritdoc * @beta */ static deserialize(props: DeserializeEntityArgs): CategorySelectorProps; protected collectReferenceIds(referenceIds: EntityReferenceSet): void; /** Create a Code for a CategorySelector given a name that is meant to be unique within the scope of the specified DefinitionModel. * @param iModel The IModelDb * @param scopeModelId The Id of the DefinitionModel that contains the CategorySelector and provides the scope for its name. * @param codeValue The CategorySelector name */ static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code; /** * Create a CategorySelector to select which categories are displayed by a ViewDefinition. * @param iModelDb The iModel * @param definitionModelId The [[DefinitionModel]] * @param name The name of the CategorySelector * @param categories Array of categories to select for display * @returns The newly constructed CategorySelector element. * @throws [[IModelError]] if unable to create the element. */ static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, categories: Id64Array): CategorySelector; /** * Insert a CategorySelector to select which categories are displayed by a ViewDefinition. * @param iModelDb Insert into this iModel * @param definitionModelId Insert the new CategorySelector into this DefinitionModel * @param name The name of the CategorySelector * @param categories Array of categories to select for display * @returns The Id of the newly inserted CategorySelector element. * @throws [[IModelError]] if unable to insert the element. */ static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, categories: Id64Array): Id64String; } /** * The definition element for a view. ViewDefinitions specify the area/volume that is viewed, the Ids of a DisplayStyle and a CategorySelector, * plus additional view-specific parameters in their [[Element.jsonProperties]]. * Subclasses of ViewDefinition determine which model(s) are viewed. * @note ViewDefinition is only available in the backend. See [ViewState]($frontend) for usage in the frontend. * @public @preview */ export declare abstract class ViewDefinition extends DefinitionElement { static get className(): string; /** The element Id of the [[CategorySelector]] for this ViewDefinition */ categorySelectorId: Id64String; /** The element Id of the [[DisplayStyle]] for this ViewDefinition */ displayStyleId: Id64String; protected constructor(props: ViewDefinitionProps, iModel: IModelDb); /** * ViewDefinition custom HandledProps includes 'categorySelector', and 'displayStyle'. * @inheritdoc * @beta */ protected static readonly _customHandledProps: CustomHandledProperty[]; /** * ViewDefinition deserializes 'categorySelector', and 'displayStyle'. * @inheritdoc * @beta */ static deserialize(props: DeserializeEntityArgs): ViewDefinitionProps; /** * ViewDefinition serializes 'categorySelector', and 'displayStyle'. * @inheritdoc * @beta */ static serialize(props: ViewDefinitionProps, _iModel: IModelDb): ECSqlRow; toJSON(): ViewDefinitionProps; protected collectReferenceIds(referenceIds: EntityReferenceSet): void; /** @beta */ static readonly requiredReferenceKeys: ReadonlyArray<string>; /** @alpha */ static readonly requiredReferenceKeyTypeMap: Record<string, ConcreteEntityTypes>; /** @beta */ protected static onCloned(context: IModelElementCloneContext, sourceElementProps: ViewDefinitionProps, targetElementProps: ViewDefinitionProps): void; /** Type guard for `instanceof ViewDefinition3d` */ isView3d(): this is ViewDefinition3d; /** Type guard for 'instanceof ViewDefinition2d` */ isView2d(): this is ViewDefinition2d; /** Type guard for `instanceof SpatialViewDefinition` */ isSpatialView(): this is SpatialViewDefinition; /** Type guard for 'instanceof DrawingViewDefinition' */ isDrawingView(): this is DrawingViewDefinition; /** Load this view's DisplayStyle from the IModelDb. */ loadDisplayStyle(): DisplayStyle; /** Load this view's CategorySelector from the IModelDb. */ loadCategorySelector(): CategorySelector; /** Provides access to optional detail settings for this view. */ abstract get details(): ViewDetails; /** The Id of the AuxiliaryCoordinateSystem for this ViewDefinition, or an invalid Id if no ACS is defined. */ getAuxiliaryCoordinateSystemId(): Id64String; /** Set or clear the AuxiliaryCoordinateSystem for this ViewDefinition. * @param acsId The Id of the new AuxiliaryCoordinateSystem. If `Id64.invalid` is passed, then no AuxiliaryCoordinateSystem will be used. */ setAuxiliaryCoordinateSystemId(acsId: Id64String): void; /** Create a Code for a ViewDefinition given a name that is meant to be unique within the scope of the specified DefinitionModel. * @param iModel The IModelDb * @param scopeModelId The Id of the DefinitionModel to contain the ViewDefinition and provides the scope for its name. * @param codeValue The ViewDefinition name */ static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code; } /** Defines a view of one or more 3d models. * @public @preview */ export declare abstract class ViewDefinition3d extends ViewDefinition { private readonly _details; static get className(): string; /** If true, camera is used. Otherwise, use an orthographic projection. */ cameraOn: boolean; /** The lower left back corner of the view frustum. */ origin: Point3d; /** The extent (size) of the view frustum, in meters, along its x,y,z axes. */ extents: Vector3d; /** Rotation from world coordinates to view coordinates. */ angles: YawPitchRollAngles; /** The camera used for this view, if `cameraOn` is true. */ camera: Camera; protected constructor(props: ViewDefinition3dProps, iModel: IModelDb); /** * ViewDefinition3d custom HandledProps includes 'eyePoint', 'focusDistance', 'lensAngle', 'yaw', 'pitch', 'roll', * 'origin', 'extents', and 'isCameraOn'. * @inheritdoc * @beta */ protected static readonly _customHandledProps: CustomHandledProperty[]; /** * ViewDefinition3d deserializes 'eyePoint', 'focusDistance', 'lensAngle', 'yaw', 'pitch', 'roll', * 'origin', 'extents', and 'isCameraOn'. * @inheritdoc * @beta */ static deserialize(props: DeserializeEntityArgs): ViewDefinition3dProps; /** * ViewDefinition3d serializes 'eyePoint', 'focusDistance', 'lensAngle', 'yaw', 'pitch', 'roll', * 'origin', 'extents', and 'isCameraOn'. * @inheritdoc * @beta */ static serialize(props: ViewDefinition3dProps, _iModel: IModelDb): ECSqlRow; toJSON(): ViewDefinition3dProps; /** Provides access to optional detail settings for this view. */ get details(): ViewDetails3d; /** Load this view's DisplayStyle3d from the IModelDb. */ loadDisplayStyle3d(): DisplayStyle3d; } /** Defines a view of one or more SpatialModels. * The list of viewed models is stored by the ModelSelector. * * This is how a SpatialViewDefinition selects the elements to display: * * SpatialViewDefinition * * ModelSelector * * ModelIds -------> SpatialModels <----------GeometricElement3d.Model * * CategorySelector * * CategoryIds -----> SpatialCategories <----------GeometricElement3d.Category * @public @preview */ export declare class SpatialViewDefinition extends ViewDefinition3d { static get className(): string; /** The Id of the [[ModelSelector]] for this SpatialViewDefinition. */ modelSelectorId: Id64String; protected constructor(props: SpatialViewDefinitionProps, iModel: IModelDb); /** Construct a SpatialViewDefinition from its JSON representation. */ static fromJSON(props: Omit<SpatialViewDefinitionProps, "classFullName">, iModel: IModelDb): SpatialViewDefinition; toJSON(): SpatialViewDefinitionProps; /** * SpatialViewDefinition custom HandledProps includes 'modelSelector'. * @inheritdoc * @beta */ protected static readonly _customHandledProps: CustomHandledProperty[]; /** * SpatialViewDefinition deserializes 'modelSelector'. * @inheritdoc * @beta */ static deserialize(props: DeserializeEntityArgs): SpatialViewDefinitionProps; /** * SpatialViewDefinition serializes 'modelSelector'. * @inheritdoc * @beta */ static serialize(props: SpatialViewDefinitionProps, _iModel: IModelDb): ECSqlRow; protected collectReferenceIds(referenceIds: EntityReferenceSet): void; /** @beta */ static readonly requiredReferenceKeys: ReadonlyArray<string>; /** @alpha */ static readonly requiredReferenceKeyTypeMap: Record<string, ConcreteEntityTypes>; /** Load this view's ModelSelector from the IModelDb. */ loadModelSelector(): ModelSelector; /** * Create a SpatialViewDefinition with the camera turned on. * @param iModelDb The iModel * @param definitionModelId The [[DefinitionModel]] * @param name The name/CodeValue of the view * @param modelSelectorId The [[ModelSelector]] that this view should use * @param categorySelectorId The [[CategorySelector]] that this view should use * @param displayStyleId The [[DisplayStyle3d]] that this view should use * @param range Defines the view origin and extents * @param standardView Optionally defines the view's rotation * @param cameraAngle Camera angle in radians. * @returns The newly constructed SpatialViewDefinition element * @throws [[IModelError]] if there is a problem creating the view */ static createWithCamera(iModelDb: IModelDb, definitionModelId: Id64String, name: string, modelSelectorId: Id64String, categorySelectorId: Id64String, displayStyleId: Id64String, range: Range3d, standardView?: StandardViewIndex, cameraAngle?: number): SpatialViewDefinition; /** * Insert an SpatialViewDefinition with the camera turned on. * @see [[createWithCamera]] for details. * @returns The Id of the newly inserted SpatialViewDefinition element * @throws [[IModelError]] if there is an insert problem. */ static insertWithCamera(iModelDb: IModelDb, definitionModelId: Id64String, name: string, modelSelectorId: Id64String, categorySelectorId: Id64String, displayStyleId: Id64String, range: Range3d, standardView?: StandardViewIndex, cameraAngle?: number): Id64String; } /** Defines a spatial view that displays geometry on the image plane using a parallel orthographic projection. * See [how to create a OrthographicViewDefinition]$(docs/learning/backend/CreateElements.md#OrthographicViewDefinition). * @public @preview */ export declare class OrthographicViewDefinition extends SpatialViewDefinition { static get className(): string; constructor(props: SpatialViewDefinitionProps, iModel: IModelDb); /** * Create an OrthographicViewDefinition * @param iModelDb The iModel * @param definitionModelId The [[DefinitionModel]] * @param name The name/CodeValue of the view * @param modelSelectorId The [[ModelSelector]] that this view should use * @param categorySelectorId The [[CategorySelector]] that this view should use * @param displayStyleId The [[DisplayStyle3d]] that this view should use * @param range Defines the view origin and extents * @param standardView Optionally defines the view's rotation * @returns The newly constructed OrthographicViewDefinition element * @throws [[IModelError]] if there is a problem creating the view */ static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, modelSelectorId: Id64String, categorySelectorId: Id64String, displayStyleId: Id64String, range: Range3d, standardView?: StandardViewIndex): OrthographicViewDefinition; /** * Insert an OrthographicViewDefinition * @param iModelDb Insert into this iModel * @param definitionModelId Insert the new OrthographicViewDefinition into this DefinitionModel * @param name The name/CodeValue of the view * @param modelSelectorId The [[ModelSelector]] that this view should use * @param categorySelectorId The [[CategorySelector]] that this view should use * @param displayStyleId The [[DisplayStyle3d]] that this view should use * @param range Defines the view origin and extents * @param standardView Optionally defines the view's rotation * @returns The Id of the newly inserted OrthographicViewDefinition element * @throws [[IModelError]] if there is an insert problem. */ static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, modelSelectorId: Id64String, categorySelectorId: Id64String, displayStyleId: Id64String, range: Range3d, standardView?: StandardViewIndex): Id64String; /** Set a new viewed range without changing the rotation or any other properties. */ setRange(range: Range3d): void; } /** Defines a view of a single 2d model. Each 2d model has its own coordinate system, so only one may appear per view. * @public @preview */ export declare class ViewDefinition2d extends ViewDefinition { private readonly _details; static get className(): string; /** The Id of the Model displayed by this view. */ baseModelId: Id64String; /** The lower-left corner of this view in Model coordinates. */ origin: Point2d; /** The delta (size) of this view, in meters, aligned with view x,y. */ delta: Point2d; /** The rotation of this view. */ angle: Angle; protected constructor(props: ViewDefinition2dProps, iModel: IModelDb); toJSON(): ViewDefinition2dProps; /** * ViewDefinition2d custom HandledProps includes 'baseModel', 'origin', 'extents', and 'rotationAngle'. * @inheritdoc * @beta */ protected static readonly _customHandledProps: CustomHandledProperty[]; /** * ViewDefinition2d deserializes 'baseModel', 'origin', 'extents', and 'rotationAngle'. * @inheritdoc * @beta */ static deserialize(props: DeserializeEntityArgs): ViewDefinition2dProps; /** * ViewDefinition2d serializes 'baseModel', 'origin', 'extents', and 'rotationAngle'. * @inheritdoc * @beta */ static serialize(props: ViewDefinition2dProps, _iModel: IModelDb): ECSqlRow; protected collectReferenceIds(referenceIds: EntityReferenceSet): void; /** Provides access to optional detail settings for this view. */ get details(): ViewDetails; /** Load this view's DisplayStyle2d from the IModelDb. */ loadDisplayStyle2d(): DisplayStyle2d; } /** Defines a view of a [[DrawingModel]]. * @public @preview */ export declare class DrawingViewDefinition extends ViewDefinition2d { static get className(): string; protected constructor(props: ViewDefinition2dProps, iModel: IModelDb); /** Create a DrawingViewDefinition * @param iModelDb The iModel * @param definitionModelId The [[DefinitionModel]] * @param name The name/CodeValue of the view * @param baseModelId The base [[DrawingModel]] * @param categorySelectorId The [[CategorySelector]] that this view should use * @param displayStyleId The [[DisplayStyle2d]] that this view should use * @param range Defines the view origin and extents * @throws [[IModelError]] if there is a problem creating the element. */ static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, baseModelId: Id64String, categorySelectorId: Id64String, displayStyleId: Id64String, range: Range2d): DrawingViewDefinition; /** Construct a DrawingViewDefinition from its JSON representation. */ static fromJSON(props: Omit<ViewDefinition2dProps, "classFullName">, iModel: IModelDb): DrawingViewDefinition; /** Insert a DrawingViewDefinition * @param iModelDb Insert into this iModel * @param definitionModelId Insert the new DrawingViewDefinition into this [[DefinitionModel]] * @param name The name/CodeValue of the view * @param baseModelId The base [[DrawingModel]] * @param categorySelectorId The [[CategorySelector]] that this view should use * @param displayStyleId The [[DisplayStyle2d]] that this view should use * @param range Defines the view origin and extents * @throws [[IModelError]] if there is an insert problem. */ static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, baseModelId: Id64String, categorySelectorId: Id64String, displayStyleId: Id64String, range: Range2d): Id64String; } /** Arguments to be passed in to [[SheetViewDefinition.create]] * @public */ export interface CreateSheetViewDefinitionArgs { /** The iModel in which the sheet view will be created. */ iModel: IModelDb; /** The Id of the [[DefinitionModel]] into which the sheet view will be inserted. */ definitionModelId: Id64String; /** The name to use as the view's Code value. */ name: string; /** The Id of the sheet model whose contents will be displayed by this view. */ baseModelId: Id64String; /** The [[CategorySelector]] that this view should use. */ categorySelectorId: Id64String; /** The [[DisplayStyle2d]] that this view should use. */ displayStyleId: Id64String; /** Defines the view origin and extents. */ range: Range2d; } /** Defines a view of a [[SheetModel]]. * @public @preview */ export declare class SheetViewDefinition extends ViewDefinition2d { static get className(): string; protected constructor(props: ViewDefinition2dProps, iModel: IModelDb); /** Create a SheetViewDefinition */ static create(args: CreateSheetViewDefinitionArgs): SheetViewDefinition; /** Insert a SheetViewDefinition into an IModelDb */ static insert(args: CreateSheetViewDefinitionArgs): Id64String; /** Create a SheetViewDefinition from JSON props */ static fromJSON(props: Omit<ViewDefinition2dProps, "classFullName">, iModel: IModelDb): SheetViewDefinition; } /** A ViewDefinition used to display a 2d template model. * @internal */ export declare class TemplateViewDefinition2d extends ViewDefinition2d { static get className(): string; } /** A ViewDefinition used to display a 3d template model. * @internal */ export declare class TemplateViewDefinition3d extends ViewDefinition3d { static get className(): string; } /** An auxiliary coordinate system element. Auxiliary coordinate systems can be used by views to show * coordinate information in different units and/or orientations. * @public @preview */ export declare abstract class AuxCoordSystem extends DefinitionElement { static get className(): string; type?: number; description?: string; constructor(props: AuxCoordSystemProps, iModel: IModelDb); } /** A 2d auxiliary coordinate system. * @public @preview */ export declare class AuxCoordSystem2d extends AuxCoordSystem { static get className(): string; origin?: Point2d; angle?: number; constructor(props: AuxCoordSystem2dProps, iModel: IModelDb); /** Create a Code for a AuxCoordSystem2d element given a name that is meant to be unique within the scope of the specified DefinitionModel. * @param iModel The IModelDb * @param scopeModelId The Id of the DefinitionModel that contains the AuxCoordSystem2d element and provides the scope for its name. * @param codeValue The AuxCoordSystem2d name */ static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code; } /** A 3d auxiliary coordinate system. * @public @preview */ export declare class AuxCoordSystem3d extends AuxCoordSystem { static get className(): string; origin?: Point3d; yaw?: number; pitch?: number; roll?: number; constructor(props: AuxCoordSystem3dProps, iModel: IModelDb); /** Create a Code for a AuxCoordSystem3d element given a name that is meant to be unique within the scope of the specified DefinitionModel. * @param iModel The IModelDb * @param scopeModelId The Id of the DefinitionModel that contains the AuxCoordSystem3d element and provides the scope for its name. * @param codeValue The AuxCoordSystem3d name */ static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code; } /** A spatial auxiliary coordinate system. * @public @preview */ export declare class AuxCoordSystemSpatial extends AuxCoordSystem3d { static get className(): string; /** Create a Code for a AuxCoordSystemSpatial element given a name that is meant to be unique within the scope of the specified DefinitionModel. * @param iModel The IModelDb * @param scopeModelId The Id of the DefinitionModel that contains the AuxCoordSystemSpatial element and provides the scope for its name. * @param codeValue The AuxCoordSystemSpatial name */ static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code; } /** Represents an *attachment* of a [[ViewDefinition]] to a [[Sheet]]. * @public @preview */ export declare class ViewAttachment extends GraphicalElement2d { static get className(): string; view: RelatedElement; constructor(props: ViewAttachmentProps, iModel: IModelDb); protected collectReferenceIds(referenceIds: EntityReferenceSet): void; } /** The position in space of a Light. * @internal */ export declare class LightLocation extends SpatialLocationElement { static get className(): string; /** Whether this light is currently turned on. */ enabled?: boolean; protected constructor(props: LightLocationProps, iModel: IModelDb); } //# sourceMappingURL=ViewDefinition.d.ts.map