@mlightcad/cad-simple-viewer 1.0.20 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,205 +0,0 @@
1
- import { AcCmColor, AcDbArc, AcDbHatch, AcDbLine, AcDbMText, AcDbTextStyleTableRecord, AcGeCircArc2d, AcGeLine2d, AcGeLine3d, AcGeLoop2d, AcGeMathUtil, AcGePoint3d, AcGePolyline2d, AcGiMTextAttachmentPoint } from '@mlightcad/data-model';
2
- var DEFAULT_FONT = 'simsun';
3
- /**
4
- * Factory class for creating example CAD documents with predefined content.
5
- *
6
- * This utility class provides methods to generate sample CAD drawings for
7
- * testing, demonstration, or initial document templates. It creates various
8
- * types of CAD entities including:
9
- * - Geometric shapes (arcs, lines, hatches)
10
- * - Text elements (MText with formatting)
11
- * - Text styles and formatting
12
- *
13
- * The class follows a singleton pattern to ensure consistent example
14
- * data generation across the application.
15
- *
16
- * @internal This class is for internal use by the framework
17
- *
18
- * @example
19
- * ```typescript
20
- * const creator = AcApDocCreator.instance;
21
- * const database = new AcDbDatabase();
22
- *
23
- * // Create example document with various entities
24
- * creator.createExampleDoc2(database);
25
- *
26
- * // The database now contains sample lines, arcs, hatches, and text
27
- * ```
28
- */
29
- var AcApDocCreator = /** @class */ (function () {
30
- function AcApDocCreator() {
31
- }
32
- Object.defineProperty(AcApDocCreator, "instance", {
33
- /**
34
- * Gets the singleton instance of the document creator.
35
- *
36
- * @returns The singleton AcApDocCreator instance
37
- */
38
- get: function () {
39
- if (!AcApDocCreator._instance) {
40
- AcApDocCreator._instance = new AcApDocCreator();
41
- }
42
- return AcApDocCreator._instance;
43
- },
44
- enumerable: false,
45
- configurable: true
46
- });
47
- /**
48
- * Creates a simple example document with circular hatches.
49
- *
50
- * This method generates a 2x2 grid of circular hatched areas,
51
- * useful for testing hatch rendering and basic geometry display.
52
- *
53
- * @param db - The database to add the example entities to
54
- *
55
- * @example
56
- * ```typescript
57
- * const creator = AcApDocCreator.instance;
58
- * const database = new AcDbDatabase();
59
- * creator.createExampleDoc1(database);
60
- * // Database now contains 4 circular hatches in a grid
61
- * ```
62
- */
63
- AcApDocCreator.prototype.createExampleDoc1 = function (db) {
64
- var rowCount = 2;
65
- var colCount = 2;
66
- for (var i = 0; i < rowCount; ++i) {
67
- for (var j = 0; j < colCount; ++j) {
68
- var hatch = new AcDbHatch();
69
- var circle = new AcGePolyline2d();
70
- circle.addVertexAt(0, { x: j * 100, y: i * 100, bulge: 1 });
71
- circle.addVertexAt(1, { x: j * 100 + 100, y: i * 100, bulge: 1 });
72
- circle.closed = true;
73
- hatch.add(circle);
74
- db.tables.blockTable.modelSpace.appendEntity(hatch);
75
- }
76
- }
77
- };
78
- /**
79
- * Creates a comprehensive example document with various CAD entities.
80
- *
81
- * This method generates a more complex document containing:
82
- * - Arcs and lines forming geometric shapes
83
- * - Complex hatches with boundary loops
84
- * - Formatted text (MText) with Chinese characters
85
- * - Custom text styles
86
- *
87
- * This example is useful for testing complex rendering scenarios,
88
- * text handling, and international character support.
89
- *
90
- * @param db - The database to add the example entities to
91
- *
92
- * @example
93
- * ```typescript
94
- * const creator = AcApDocCreator.instance;
95
- * const database = new AcDbDatabase();
96
- * creator.createExampleDoc2(database);
97
- * // Database now contains arcs, lines, hatches, and formatted text
98
- * ```
99
- */
100
- AcApDocCreator.prototype.createExampleDoc2 = function (db) {
101
- var modelSpace = db.tables.blockTable.modelSpace;
102
- modelSpace.appendEntity(this.createArc());
103
- var lines = this.createLines();
104
- lines.forEach(function (line) {
105
- db.tables.blockTable.modelSpace.appendEntity(new AcDbLine(line.startPoint, line.endPoint));
106
- });
107
- modelSpace.appendEntity(this.createHatch());
108
- db.tables.textStyleTable.add(this.createTextStyle());
109
- modelSpace.appendEntity(this.createMText());
110
- };
111
- AcApDocCreator.prototype.createTextStyle = function () {
112
- var textStyle = {
113
- bigFont: '',
114
- color: 0xffffff,
115
- extendedFont: DEFAULT_FONT,
116
- fixedTextHeight: 0,
117
- font: DEFAULT_FONT,
118
- lastHeight: 0.2,
119
- name: 'Standard',
120
- obliqueAngle: 0,
121
- standardFlag: 0,
122
- textGenerationFlag: 0,
123
- widthFactor: 0.667
124
- };
125
- return new AcDbTextStyleTableRecord(textStyle);
126
- };
127
- AcApDocCreator.prototype.createMText = function () {
128
- var mtext = new AcDbMText();
129
- mtext.attachmentPoint = AcGiMTextAttachmentPoint.MiddleLeft;
130
- mtext.color = new AcCmColor().setColorName('red');
131
- mtext.layer = '0';
132
- mtext.location = new AcGePoint3d(9850, 86773, 0);
133
- mtext.contents = '{\\W0.667;\\T1.1;智慧8081}';
134
- mtext.height = 200;
135
- mtext.width = 1000;
136
- mtext.styleName = 'Standard';
137
- return mtext;
138
- };
139
- AcApDocCreator.prototype.createHatch = function () {
140
- var lines = this.createLines();
141
- var hatch = new AcDbHatch();
142
- var loops = new AcGeLoop2d();
143
- loops.add(new AcGeCircArc2d({ x: 20241.23355899991, y: 174118.6312674369 }, 89258.30757455899, AcGeMathUtil.degToRad(262.2471115358437), AcGeMathUtil.degToRad(264.444541053754), false));
144
- lines.forEach(function (line) {
145
- loops.add(new AcGeLine2d(line.startPoint, line.endPoint));
146
- });
147
- hatch.add(loops);
148
- return hatch;
149
- };
150
- AcApDocCreator.prototype.createArc = function () {
151
- return new AcDbArc({ x: 20241.23355899991, y: 174118.6312674369, z: 0 }, 89258.30757455899, AcGeMathUtil.degToRad(262.2471115358437), AcGeMathUtil.degToRad(264.444541053754));
152
- };
153
- AcApDocCreator.prototype.createLines = function () {
154
- var lines = [];
155
- lines.push(new AcGeLine3d({
156
- x: 11600.20888122753,
157
- y: 85279.57362051727,
158
- z: 0
159
- }, {
160
- x: 11600.20890652924,
161
- y: 86546.03982284805,
162
- z: 0
163
- }));
164
- lines.push(new AcGeLine3d({
165
- x: 11600.20890652924,
166
- y: 86546.03982284805,
167
- z: 0
168
- }, {
169
- x: 10850.20885583921,
170
- y: 86546.03980174381,
171
- z: 0
172
- }));
173
- lines.push(new AcGeLine3d({
174
- x: 10850.2088602169,
175
- y: 86546.03967292747,
176
- z: 0
177
- }, {
178
- x: 9050.208860216895,
179
- y: 86546.039672927,
180
- z: 0
181
- }));
182
- lines.push(new AcGeLine3d({
183
- x: 9050.208855839213,
184
- y: 86546.0397510943,
185
- z: 0
186
- }, {
187
- x: 8200.209067034302,
188
- y: 86546.039727177,
189
- z: 0
190
- }));
191
- lines.push(new AcGeLine3d({
192
- x: 8200.209067034302,
193
- y: 86546.039727177,
194
- z: 0
195
- }, {
196
- x: 8200.209067033837,
197
- y: 85676.22514764359,
198
- z: 0
199
- }));
200
- return lines;
201
- };
202
- return AcApDocCreator;
203
- }());
204
- export { AcApDocCreator };
205
- //# sourceMappingURL=AcApDocCreator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AcApDocCreator.js","sourceRoot":"","sources":["../../src/app/AcApDocCreator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EAEP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,cAAc,EACd,wBAAwB,EAEzB,MAAM,uBAAuB,CAAA;AAE9B,IAAM,YAAY,GAAG,QAAQ,CAAA;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH;IAAA;IA0NA,CAAC;IAjNC,sBAAW,0BAAQ;QALnB;;;;WAIG;aACH;YACE,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;gBAC9B,cAAc,CAAC,SAAS,GAAG,IAAI,cAAc,EAAE,CAAA;YACjD,CAAC;YACD,OAAO,cAAc,CAAC,SAAS,CAAA;QACjC,CAAC;;;OAAA;IAED;;;;;;;;;;;;;;;OAeG;IACH,0CAAiB,GAAjB,UAAkB,EAAgB;QAChC,IAAM,QAAQ,GAAG,CAAC,CAAA;QAClB,IAAM,QAAQ,GAAG,CAAC,CAAA;QAClB,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