UNPKG

@itwin/core-frontend

Version:
110 lines 4 kB
/** @packageDocumentation * @module Views */ import { Id64String } from "@itwin/core-bentley"; import { ColorDef } from "@itwin/core-common"; import { IModelConnection } from "./IModelConnection"; import { ViewState } from "./ViewState"; /** Options for creating a [[ViewState2d]] via [[ViewCreator2d]]. * @public * @extensions */ export interface ViewCreator2dOptions { /** Aspect ratio of [[Viewport]]. Required to fit contents of the model in the initial state of the view. */ vpAspect?: number; /** Background color of the view (default is white). */ bgColor?: ColorDef; /** Checks to see if there already is a [[ViewDefinition2d]] for the given modelId. If so, use it as the seed view, and merge its props into the final view created. */ useSeedView?: boolean; } /** * API for creating a [[ViewState2d]] for a 2D model ([[GeometricModel2dState]]). @see [[ViewCreator3d]] to create a view for a 3d model. * Example usage: * ```ts * const viewCreator = new ViewCreator2d(imodel); * const models = await imodel.models.queryProps({ from: "BisCore.GeometricModel2d" }); * if (models.length > 0) * const view = await viewCreator.createViewForModel(models[0].id!); * ``` * @public * @extensions */ export declare class ViewCreator2d { private _imodel; private static _drawingModelClasses; private static _sheetModelClasses; /** * Constructs a ViewCreator2d using an [[IModelConnection]]. * @param _imodel [[IModelConnection]] to query for categories and/or models. */ constructor(_imodel: IModelConnection); /** * Creates and returns view for the 2D model id passed in. * @param modelId Id of the 2D model for the view. * @param [options] Options for creating the view. * @throws [IModelError]($common) If modelType is not supported. */ createViewForModel(modelId: Id64String, options?: ViewCreator2dOptions): Promise<ViewState>; /** * Gets model base class name from id. * @param modelId of target model. * @throws [IModelError]($common) if modelId is invalid. */ private _getModelBaseClassName; /** * Creates view from any 2D model type (Drawing/SectionDrawing/Sheet) * @param modelId of target model. * @param modelType classFullName of target 2D model. * @param options for view creation. * @throws [IModelError]($common) if modelType is not supported. */ private _createViewState2d; /** * Checks to see if given model is of [[DrawingModelState]]. * @param modelType classFullName of model. */ private _isDrawingModelClass; /** * Checks to see if given model is of [[SheetModelState]]. * @param modelType classFullName of model. */ private _isSheetModelClass; /** * Creates ViewStateProps for the model. ViewStateProps are composed of the 4 sets of Props below. * @param modelId of target model. * @param options for view creation. */ private _createViewStateProps; /** * Adds Sheet view props to given view props. * @param modelId of target model. * @param props input ViewStateProps. */ private _addSheetViewProps; /** * Merges a seed view in the iModel with the passed view state props. It will be a no-op if there are no 2D views for target model. * @param modelId of target model. * @param props Input view props to be merged */ private _mergeSeedView; /** * Get all view definitions for a given model. * @param modelId of target model. */ private _getViewDefinitionsIdForModel; /** * Get all drawing categories */ private _getAllCategories; /** * Get all sheet attachments * @param modelId of target model. */ private _getSheetAttachments; /** * Helper function to execute ECSql queries. * @param query statement to execute. */ private _executeQuery; } //# sourceMappingURL=ViewCreator2d.d.ts.map