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.

397 lines 12.9 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 { AcCmColor, defaults } from '@mlightcad/common'; import { AcDbSymbolTableRecord } from './AcDbSymbolTableRecord'; /** * Represents a record in the layer table. * * This class contains information about a layer in the drawing database, * including color, visibility settings, linetype, and other layer properties. * Layers are used to organize and control the display of entities in the drawing. * * @example * ```typescript * const layer = new AcDbLayerTableRecord({ * name: 'MyLayer', * color: new AcCmColor(255, 0, 0), // Red * isOff: false, * isPlottable: true * }); * ``` */ var AcDbLayerTableRecord = /** @class */ (function (_super) { __extends(AcDbLayerTableRecord, _super); /** * Creates a new AcDbLayerTableRecord instance. * * @param attrs - Input attribute values for this layer table record * @param defaultAttrs - Default values for attributes of this layer table record * * @example * ```typescript * const layer = new AcDbLayerTableRecord({ * name: 'MyLayer', * color: new AcCmColor(255, 0, 0) * }); * ``` */ function AcDbLayerTableRecord(attrs, defaultAttrs) { var _this = this; attrs = attrs || {}; defaults(attrs, { color: new AcCmColor(), description: '', standardFlags: 0, isHidden: false, isInUse: true, isOff: false, isPlottable: true, transparency: 0, linetype: '', lineWeight: 1, materialId: -1 }); _this = _super.call(this, attrs, defaultAttrs) || this; _this.attrs.events.attrChanged.addEventListener(function (args) { _this.database.events.layerModified.dispatch({ database: _this.database, layer: _this, changes: args.object.changedAttributes() }); }); return _this; } Object.defineProperty(AcDbLayerTableRecord.prototype, "color", { /** * Gets or sets the color value of this layer. * * @returns The color of the layer * * @example * ```typescript * const color = layer.color; * layer.color = new AcCmColor(255, 0, 0); // Red * ``` */ get: function () { return this.getAttr('color'); }, set: function (value) { this.setAttr('color', value.clone()); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbLayerTableRecord.prototype, "description", { /** * Gets or sets the description of this layer. * * @returns The description of the layer * * @example * ```typescript * const description = layer.description; * layer.description = 'My custom layer'; * ``` */ get: function () { return this.getAttr('description'); }, set: function (value) { this.setAttr('description', value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbLayerTableRecord.prototype, "standardFlags", { /** * Gets or sets the standard flags for this layer. * * Standard flags are bit-coded values: * - 1 = Layer is frozen; otherwise layer is thawed * - 2 = Layer is frozen by default in new viewports * - 4 = Layer is locked * - 16 = If set, table entry is externally dependent on an xref * - 32 = If both this bit and bit 16 are set, the externally dependent xref has been successfully resolved * - 64 = If set, the table entry was referenced by at least one entity in the drawing the last time the drawing was edited * * @returns The standard flags value * * @example * ```typescript * const flags = layer.standardFlags; * layer.standardFlags = 1; // Freeze the layer * ``` */ get: function () { return this.getAttr('standardFlags'); }, set: function (value) { this.setAttr('standardFlags', value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbLayerTableRecord.prototype, "isFrozen", { /** * Gets or sets whether this layer is frozen. * * When a layer is frozen, its entities are not displayed and cannot be modified. * * @returns True if the layer is frozen, false otherwise * * @example * ```typescript * if (layer.isFrozen) { * console.log('Layer is frozen'); * } * layer.isFrozen = true; * ``` */ get: function () { return (this.standardFlags & 0x01) == 1; }, set: function (value) { var flag = value ? 1 : 0; this.standardFlags = this.standardFlags | flag; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbLayerTableRecord.prototype, "isHidden", { /** * Gets or sets whether this layer is hidden. * * When a layer is hidden, it isn't shown in the user interface of * the host application, but entities on the layer are still displayed. * * @returns True if the layer is hidden, false otherwise * * @example * ```typescript * if (layer.isHidden) { * console.log('Layer is hidden from UI'); * } * layer.isHidden = true; * ``` */ get: function () { return this.getAttr('isHidden'); }, set: function (value) { this.setAttr('isHidden', value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbLayerTableRecord.prototype, "isInUse", { /** * Gets or sets whether this layer is in use. * * A layer is considered in use if it contains entities or is referenced * by other objects in the drawing. * * @returns True if the layer is in use, false otherwise * * @example * ```typescript * if (layer.isInUse) { * console.log('Layer contains entities'); * } * ``` */ get: function () { return this.getAttr('isInUse'); }, set: function (value) { this.setAttr('isInUse', value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbLayerTableRecord.prototype, "isLocked", { /** * Gets or sets whether this layer is locked. * * When a layer is locked, its entities cannot be modified but are still visible. * * @returns True if the layer is locked, false otherwise * * @example * ```typescript * if (layer.isLocked) { * console.log('Layer is locked'); * } * layer.isLocked = true; * ``` */ get: function () { return (this.standardFlags & 0x04) == 4; }, set: function (value) { var flag = value ? 4 : 0; this.standardFlags = this.standardFlags | flag; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbLayerTableRecord.prototype, "isOff", { /** * Gets or sets whether this layer is turned off. * * When a layer is turned off, its entities are not displayed but can still be modified. * * @returns True if the layer is turned off, false otherwise * * @example * ```typescript * if (layer.isOff) { * console.log('Layer is turned off'); * } * layer.isOff = true; * ``` */ get: function () { return this.getAttr('isOff'); }, set: function (value) { this.setAttr('isOff', value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbLayerTableRecord.prototype, "isPlottable", { /** * Gets or sets whether this layer is plottable. * * When a layer is plottable, its entities will be included when the drawing is plotted or printed. * * @returns True if the layer is plottable, false otherwise * * @example * ```typescript * if (layer.isPlottable) { * console.log('Layer will be included in plots'); * } * layer.isPlottable = false; * ``` */ get: function () { return this.getAttr('isPlottable'); }, set: function (value) { this.setAttr('isPlottable', value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbLayerTableRecord.prototype, "transparency", { /** * Gets or sets the transparency level of this layer. * * Transparency values range from 0 (opaque) to 1 (fully transparent). * * @returns The transparency level (0-1) * * @example * ```typescript * const transparency = layer.transparency; * layer.transparency = 0.5; // 50% transparent * ``` */ get: function () { return this.getAttr('transparency'); }, set: function (value) { this.setAttr('transparency', value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbLayerTableRecord.prototype, "linetype", { /** * Gets or sets the linetype name for this layer. * * The linetype defines the pattern of dashes, dots, and spaces used * to display lines and curves on this layer. * * @returns The linetype name * * @example * ```typescript * const linetype = layer.linetype; * layer.linetype = 'DASHED'; * ``` */ get: function () { return this.getAttr('linetype'); }, set: function (value) { this.setAttr('linetype', value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbLayerTableRecord.prototype, "lineWeight", { /** * Gets or sets the line weight for this layer. * * Line weight determines the thickness of lines and curves on this layer. * * @returns The line weight value * * @example * ```typescript * const weight = layer.lineWeight; * layer.lineWeight = 2.0; // 2.0mm line weight * ``` */ get: function () { return this.getAttr('lineWeight'); }, set: function (value) { this.setAttr('lineWeight', value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbLayerTableRecord.prototype, "materialId", { /** * Gets or sets the material ID associated with this layer. * * Material IDs are used for rendering and visualization purposes. * * @returns The material ID * * @example * ```typescript * const materialId = layer.materialId; * layer.materialId = 'concrete'; * ``` */ get: function () { return this.getAttr('materialId'); }, set: function (value) { this.setAttr('materialId', value); }, enumerable: false, configurable: true }); return AcDbLayerTableRecord; }(AcDbSymbolTableRecord)); export { AcDbLayerTableRecord }; //# sourceMappingURL=AcDbLayerTableRecord.js.map