UNPKG

@mlightcad/data-model

Version:

The data-model package provides the core classes for interacting with AutoCAD's database and entities. This package mimics AutoCAD ObjectARX's AcDb (Database) classes and implements the drawing database structure that AutoCAD developers are familiar with.

318 lines 12.2 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { AcGePoint2d, AcGePoint3d } from '@mlightcad/geometry-engine'; import { AcGiDefaultLightingType, AcGiOrthographicType, AcGiRenderMode } from '@mlightcad/graphic-interface'; import { AcDbSymbolTableRecord } from './AcDbSymbolTableRecord'; /** * Default view configuration for viewport table records. */ var DEFAULT_VIEW = { center: new AcGePoint2d(), viewDirectionFromTarget: new AcGePoint3d(0, 0, 1), viewTarget: new AcGePoint3d(0, 0, 0), lensLength: 500, frontClippingPlane: 0, backClippingPlane: 0, viewHeight: 1000, viewTwistAngle: 0, frozenLayers: [], styleSheet: '', renderMode: AcGiRenderMode.OPTIMIZED_2D, viewMode: 0, ucsIconSetting: 0, ucsOrigin: new AcGePoint3d(0, 0, 0), ucsXAxis: new AcGePoint3d(1, 0, 0), ucsYAxis: new AcGePoint3d(0, 1, 0), orthographicType: AcGiOrthographicType.TOP, shadePlotSetting: 0, shadePlotObjectId: undefined, visualStyleObjectId: undefined, isDefaultLightingOn: false, defaultLightingType: AcGiDefaultLightingType.ONE_DISTANT_LIGHT, brightness: 0, contrast: 0, ambientColor: undefined }; /** * Represents a viewport table record in AutoCAD. * * This class represents viewport arrangements in AutoCAD, which define how * the drawing is displayed in different areas of the screen or paper space. * Viewports can have their own zoom levels, pan positions, grid settings, * and other display properties. * * @example * ```typescript * const viewportRecord = new AcDbViewportTableRecord(); * viewportRecord.name = '*Active'; * viewportRecord.circleSides = 100; * viewportRecord.lowerLeftCorner = new AcGePoint2d(0, 0); * viewportRecord.upperRightCorner = new AcGePoint2d(1, 1); * ``` */ var AcDbViewportTableRecord = /** @class */ (function (_super) { __extends(AcDbViewportTableRecord, _super); /** * Creates a new AcDbViewportTableRecord instance. * * @example * ```typescript * const viewportRecord = new AcDbViewportTableRecord(); * ``` */ function AcDbViewportTableRecord() { var _this = _super.call(this) || this; _this._circleSides = 100; _this._center = new AcGePoint2d(); _this._lowerLeftCorner = new AcGePoint2d(0, 0); _this._upperRightCorner = new AcGePoint2d(1, 1); _this._snapBase = new AcGePoint2d(0, 0); _this._snapAngle = 0; _this._snapSpacing = new AcGePoint2d(0, 0); _this._standardFlag = 0; _this._gridSpacing = new AcGePoint2d(); // TODO: Not sure what's the correct default value _this._gridMajor = 10; _this._gsView = DEFAULT_VIEW; return _this; } Object.defineProperty(AcDbViewportTableRecord.prototype, "circleSides", { /** * Gets or sets the circle zoom percent. * * This controls the number of sides to the tessellation used when displaying * curves. The value can be between 1 and 20000, with higher settings using * more sides in the curve tessellation. * * @returns The number of sides used for circle tessellation * * @example * ```typescript * const sides = viewportRecord.circleSides; * viewportRecord.circleSides = 200; // Higher quality circles * ``` */ get: function () { return this._circleSides; }, set: function (value) { this._circleSides = value; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbViewportTableRecord.prototype, "center", { /** * Gets the center point of the viewport. * * @returns The center point of the viewport * * @example * ```typescript * const center = viewportRecord.center; * ``` */ get: function () { return this._center; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbViewportTableRecord.prototype, "lowerLeftCorner", { /** * Gets or sets the lower left corner of the viewport window. * * The X and Y values of this point are expressed as a value between (0.0, 0.0) * for the lower left corner of the AutoCAD graphics area and (1.0, 1.0) for * the upper right corner of the AutoCAD graphics area. For example, a lower * left corner value of (0.5, 0.0) indicates that the viewport's lower left * corner is along the bottom of the AutoCAD graphics area, midway between * the left and right edges of the graphics area. * * @returns The lower left corner point * * @example * ```typescript * const corner = viewportRecord.lowerLeftCorner; * viewportRecord.lowerLeftCorner = new AcGePoint2d(0.25, 0.25); * ``` */ get: function () { return this._lowerLeftCorner; }, set: function (value) { this._lowerLeftCorner.copy(value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbViewportTableRecord.prototype, "upperRightCorner", { /** * The upper right corner of the viewport window. The X and Y values of this point are expressed as * a value between (0.0, 0.0) for the lower left corner of the AutoCAD graphics area and (1.0, 1.0) * for upper right corner of the AutoCAD graphics area. For example, an upper right corner value of * (0.5, 1.0) indicates that the viewport's upper right corner is along the top of the AutoCAD * graphics area, midway between the left and right edges of the graphics area. */ get: function () { return this._upperRightCorner; }, set: function (value) { this._upperRightCorner.copy(value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbViewportTableRecord.prototype, "snapBase", { /** * The snap basepoint (in UCS coordinates) for the viewport table record. */ get: function () { return this._snapBase; }, set: function (value) { this._snapBase.copy(value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbViewportTableRecord.prototype, "snapAngle", { /** * The snap angle setting (in radians) for the viewport table record. The snap angle is measured * within the UCS XY plane, with zero being the UCS X axis and positive angles going counterclockwise * when looking down the UCS Z axis towards the UCS origin. */ get: function () { return this._snapAngle; }, set: function (value) { this._snapAngle = value; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbViewportTableRecord.prototype, "snapIncrements", { /** * An AcGePoint2d in which the X value represents the X spacing of the snap grid and the Y value * represents the Y spacing of the snap grid. Both values are in drawing units. */ get: function () { return this._snapSpacing; }, set: function (value) { this._snapSpacing.copy(value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbViewportTableRecord.prototype, "gridMajor", { /** * The number of minor grid lines between each major grid line in the viewport. */ get: function () { return this._gridMajor; }, set: function (value) { this._gridMajor = value; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbViewportTableRecord.prototype, "gridIncrements", { /** * An AcGePoint2d in which the X value represents the X spacing (in drawing units) of the grid and * the Y value represents the Y spacing of the grid. */ get: function () { return this._gridSpacing; }, set: function (value) { this._gridSpacing.copy(value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbViewportTableRecord.prototype, "standardFlag", { /* * Viewport status bit-coded flags: * - 1 (0x1) = Enables perspective mode * - 2 (0x2) = Enables front clipping * - 4 (0x4) = Enables back clipping * - 8 (0x8) = Enables UCS follow * - 16 (0x10) = Enables front clip not at eye * - 32 (0x20) = Enables UCS icon visibility * - 64 (0x40) = Enables UCS icon at origin * - 128 (0x80) = Enables fast zoom * - 256 (0x100) = Enables snap mode * - 512 (0x200) = Enables grid mode * - 1024 (0x400) = Enables isometric snap style * - 2048 (0x800) = Enables hide plot mode * - 4096 (0x1000) = kIsoPairTop. If set and kIsoPairRight is not set, then isopair top is enabled. If both kIsoPairTop and kIsoPairRight are set, then isopair left is enabled * - 8192 (0x2000) = kIsoPairRight. If set and kIsoPairTop is not set, then isopair right is enabled * - 16384 (0x4000) = Enables viewport zoom locking * - 32768 (0x8000) = Currently always enabled * - 65536 (0x10000) = Enables non-rectangular clipping * - 131072 (0x20000) = Turns the viewport off * - 262144 (0x40000) = Enables the display of the grid beyond the drawing limits * - 524288 (0x80000) = Enable adaptive grid display * - 1048576 (0x100000) = Enables subdivision of the grid below the set grid spacing when the grid display is adaptive * - 2097152 (0x200000) = Enables grid follows workplane switching * * @internal */ get: function () { return this._standardFlag; }, set: function (value) { this._standardFlag = value; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbViewportTableRecord.prototype, "snapEnabled", { get: function () { return !!(this._standardFlag & 0x100); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbViewportTableRecord.prototype, "backgroundObjectId", { /** * The object dD of the new background for the view. */ get: function () { return this._backgroundObjectId; }, set: function (value) { this._backgroundObjectId = value; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbViewportTableRecord.prototype, "gsView", { /** * The AcGiView associated with this viewport table record */ get: function () { return this._gsView; }, enumerable: false, configurable: true }); return AcDbViewportTableRecord; }(AcDbSymbolTableRecord)); export { AcDbViewportTableRecord }; //# sourceMappingURL=AcDbViewportTableRecord.js.map