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.

92 lines 3.32 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 } from '@mlightcad/common'; import { DEFAULT_LINE_TYPE } from '../misc'; import { AcDbLayerTableRecord } from './AcDbLayerTableRecord'; import { AcDbSymbolTable } from './AcDbSymbolTable'; /** * Symbol table for layer table records. * * This class manages layer table records which represent layers within a * drawing database. Layers are used to organize and control the display * of entities in the drawing. Each layer can have its own color, linetype, * visibility settings, and other properties. * * @example * ```typescript * const layerTable = new AcDbLayerTable(database); * const layer = layerTable.getAt('0'); * const newLayer = new AcDbLayerTableRecord({ name: 'MyLayer' }); * layerTable.add(newLayer); * ``` */ var AcDbLayerTable = /** @class */ (function (_super) { __extends(AcDbLayerTable, _super); /** * Creates a new AcDbLayerTable instance. * * This constructor automatically creates a default layer named '0' with * white color and continuous linetype. * * @param db - The database this layer table belongs to * * @example * ```typescript * const layerTable = new AcDbLayerTable(database); * ``` */ function AcDbLayerTable(db) { var _this = _super.call(this, db) || this; // The empty database should have one layer named '0' var defaultColor = new AcCmColor(); defaultColor.color = 0xffffff; var layer0 = new AcDbLayerTableRecord({ name: '0', standardFlags: 0, linetype: DEFAULT_LINE_TYPE, lineWeight: 1, isOff: false, color: defaultColor, isPlottable: true }); _this.add(layer0); return _this; } /** * Adds a layer table record to this layer table. * * This method overrides the base class method to dispatch a layerAppended * event when a new layer is added to the table. * * @param record - The layer table record to add * * @example * ```typescript * const newLayer = new AcDbLayerTableRecord({ name: 'MyLayer' }); * layerTable.add(newLayer); * ``` */ AcDbLayerTable.prototype.add = function (record) { _super.prototype.add.call(this, record); this.database.events.layerAppended.dispatch({ database: this.database, layer: record }); }; return AcDbLayerTable; }(AcDbSymbolTable)); export { AcDbLayerTable }; //# sourceMappingURL=AcDbLayerTable.js.map