@mlightcad/graphic-interface 3.11.2 → 3.12.0
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.
- package/LICENSE +21 -21
- package/README.md +213 -213
- package/dist/graphic-interface.umd.cjs +1 -1
- package/lib/AcGiTextStyle.d.ts +5 -0
- package/lib/AcGiTextStyle.d.ts.map +1 -1
- package/lib/AcGiViewport.d.ts +25 -1
- package/lib/AcGiViewport.d.ts.map +1 -1
- package/lib/AcGiViewport.js +63 -2
- package/lib/AcGiViewport.js.map +1 -1
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 mlightcad
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mlightcad
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,214 +1,214 @@
|
|
|
1
|
-
# @mlightcad/graphic-interface
|
|
2
|
-
|
|
3
|
-
[](https://opensource.org/licenses/MIT)
|
|
4
|
-
[](https://www.npmjs.com/package/@mlightcad/graphic-interface)
|
|
5
|
-
|
|
6
|
-
The graphic-interface package provides the graphics interface for controlling how AutoCAD entities are displayed on screen. This package offers a simplified API compared to AutoCAD ObjectARX's AcGi classes, making it more developer-friendly while maintaining the core functionality needed for rendering CAD entities.
|
|
7
|
-
|
|
8
|
-
## Overview
|
|
9
|
-
|
|
10
|
-
This package provides the graphics interface layer that bridges the gap between the data model and the rendering system. It handles the conversion of AutoCAD entities into drawable objects and provides customization options for how objects are displayed, including colors, layers, visibility, and various rendering styles.
|
|
11
|
-
|
|
12
|
-
## Key Features
|
|
13
|
-
|
|
14
|
-
- **Entity Rendering**: Convert AutoCAD entities to drawable objects
|
|
15
|
-
- **Style Customization**: Control colors, line styles, text styles, and point styles
|
|
16
|
-
- **View Management**: Handle different views and viewports
|
|
17
|
-
- **Arrow and Hatch Support**: Custom arrow types and hatch pattern rendering
|
|
18
|
-
- **Image Rendering**: Support for raster image display
|
|
19
|
-
- **Flexible Rendering**: Extensible rendering system for different output formats
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm install @mlightcad/graphic-interface
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Key Classes
|
|
28
|
-
|
|
29
|
-
### Core Rendering Classes
|
|
30
|
-
- **AcGiRenderer**: Main interface for rendering entities to drawable objects
|
|
31
|
-
- **AcGiEntity**: Base class for drawable objects that can be rendered
|
|
32
|
-
- **AcGiView**: Represents a view with camera and projection settings
|
|
33
|
-
- **AcGiViewport**: Manages viewport settings and clipping
|
|
34
|
-
|
|
35
|
-
### Style Classes
|
|
36
|
-
- **AcGiArrowType**: Defines different arrow types for dimensions and leaders
|
|
37
|
-
- **AcGiHatchStyle**: Controls hatch pattern rendering and appearance
|
|
38
|
-
- **AcGiImageStyle**: Manages raster image display properties
|
|
39
|
-
- **AcGiLineStyle**: Defines line styles including dash patterns and widths
|
|
40
|
-
- **AcGiPointStyle**: Controls point entity display appearance
|
|
41
|
-
- **AcGiTextStyle**: Manages text rendering properties and formatting
|
|
42
|
-
|
|
43
|
-
## Usage Examples
|
|
44
|
-
|
|
45
|
-
### Basic Entity Rendering
|
|
46
|
-
```typescript
|
|
47
|
-
import { AcGiRenderer, AcGiEntity } from '@mlightcad/graphic-interface';
|
|
48
|
-
import { AcDbLine, AcGePoint3d } from '@mlightcad/data-model';
|
|
49
|
-
|
|
50
|
-
// Create a renderer
|
|
51
|
-
const renderer = new AcGiRenderer();
|
|
52
|
-
|
|
53
|
-
// Create an entity
|
|
54
|
-
const startPoint = new AcGePoint3d(0, 0, 0);
|
|
55
|
-
const endPoint = new AcGePoint3d(10, 10, 0);
|
|
56
|
-
const line = new AcDbLine(startPoint, endPoint);
|
|
57
|
-
|
|
58
|
-
// Render the entity
|
|
59
|
-
const drawableEntity = renderer.renderEntity(line);
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### Style Configuration
|
|
63
|
-
```typescript
|
|
64
|
-
import {
|
|
65
|
-
AcGiLineStyle,
|
|
66
|
-
AcGiTextStyle,
|
|
67
|
-
AcGiPointStyle,
|
|
68
|
-
AcGiArrowType
|
|
69
|
-
} from '@mlightcad/graphic-interface';
|
|
70
|
-
|
|
71
|
-
// Configure line style
|
|
72
|
-
const lineStyle = new AcGiLineStyle();
|
|
73
|
-
lineStyle.setColor(1); // Red
|
|
74
|
-
lineStyle.setWidth(2.0);
|
|
75
|
-
lineStyle.setDashPattern([10, 5, 5, 5]); // Dashed line
|
|
76
|
-
|
|
77
|
-
// Configure text style
|
|
78
|
-
const textStyle = new AcGiTextStyle();
|
|
79
|
-
textStyle.setFont('Arial');
|
|
80
|
-
textStyle.setHeight(12);
|
|
81
|
-
textStyle.setColor(2); // Yellow
|
|
82
|
-
textStyle.setBold(true);
|
|
83
|
-
|
|
84
|
-
// Configure point style
|
|
85
|
-
const pointStyle = new AcGiPointStyle();
|
|
86
|
-
pointStyle.setSize(5);
|
|
87
|
-
pointStyle.setShape('Circle');
|
|
88
|
-
pointStyle.setColor(3); // Green
|
|
89
|
-
|
|
90
|
-
// Configure arrow style
|
|
91
|
-
const arrowStyle = new AcGiArrowType();
|
|
92
|
-
arrowStyle.setType('ClosedFilled');
|
|
93
|
-
arrowStyle.setSize(3);
|
|
94
|
-
arrowStyle.setColor(1); // Red
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### View and Viewport Management
|
|
98
|
-
```typescript
|
|
99
|
-
import { AcGiView, AcGiViewport, AcGePoint3d } from '@mlightcad/graphic-interface';
|
|
100
|
-
|
|
101
|
-
// Create a view
|
|
102
|
-
const view = new AcGiView();
|
|
103
|
-
view.setEyePoint(new AcGePoint3d(0, 0, 100));
|
|
104
|
-
view.setTargetPoint(new AcGePoint3d(0, 0, 0));
|
|
105
|
-
view.setUpVector(new AcGeVector3d(0, 1, 0));
|
|
106
|
-
|
|
107
|
-
// Create a viewport
|
|
108
|
-
const viewport = new AcGiViewport();
|
|
109
|
-
viewport.setView(view);
|
|
110
|
-
viewport.setWidth(800);
|
|
111
|
-
viewport.setHeight(600);
|
|
112
|
-
viewport.setZoom(1.0);
|
|
113
|
-
|
|
114
|
-
// Set viewport properties
|
|
115
|
-
viewport.setClippingEnabled(true);
|
|
116
|
-
viewport.setClippingBounds(0, 0, 100, 100);
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Hatch Pattern Rendering
|
|
120
|
-
```typescript
|
|
121
|
-
import { AcGiHatchStyle } from '@mlightcad/graphic-interface';
|
|
122
|
-
|
|
123
|
-
// Configure hatch style
|
|
124
|
-
const hatchStyle = new AcGiHatchStyle();
|
|
125
|
-
hatchStyle.setPattern('ANSI31'); // Standard AutoCAD pattern
|
|
126
|
-
hatchStyle.setScale(1.0);
|
|
127
|
-
hatchStyle.setAngle(0);
|
|
128
|
-
hatchStyle.setColor(4); // Cyan
|
|
129
|
-
hatchStyle.setTransparency(0.5);
|
|
130
|
-
|
|
131
|
-
// Apply hatch to an entity
|
|
132
|
-
const hatchedEntity = renderer.renderEntityWithHatch(entity, hatchStyle);
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Image Rendering
|
|
136
|
-
```typescript
|
|
137
|
-
import { AcGiImageStyle } from '@mlightcad/graphic-interface';
|
|
138
|
-
|
|
139
|
-
// Configure image style
|
|
140
|
-
const imageStyle = new AcGiImageStyle();
|
|
141
|
-
imageStyle.setBrightness(1.0);
|
|
142
|
-
imageStyle.setContrast(1.0);
|
|
143
|
-
imageStyle.setFade(0.0);
|
|
144
|
-
imageStyle.setTransparency(0.0);
|
|
145
|
-
imageStyle.setClippingEnabled(false);
|
|
146
|
-
|
|
147
|
-
// Render image with style
|
|
148
|
-
const imageEntity = renderer.renderImage(imagePath, imageStyle);
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Custom Rendering Pipeline
|
|
152
|
-
```typescript
|
|
153
|
-
import { AcGiRenderer, AcGiEntity } from '@mlightcad/graphic-interface';
|
|
154
|
-
|
|
155
|
-
// Create a custom renderer
|
|
156
|
-
class CustomRenderer extends AcGiRenderer {
|
|
157
|
-
renderEntity(entity: AcDbEntity): AcGiEntity {
|
|
158
|
-
// Custom rendering logic
|
|
159
|
-
const drawable = super.renderEntity(entity);
|
|
160
|
-
|
|
161
|
-
// Apply custom styling
|
|
162
|
-
if (entity.getLayer() === 'HIGHLIGHT') {
|
|
163
|
-
drawable.setHighlighted(true);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return drawable;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
renderToCanvas(canvas: HTMLCanvasElement, entities: AcGiEntity[]) {
|
|
170
|
-
const ctx = canvas.getContext('2d');
|
|
171
|
-
|
|
172
|
-
entities.forEach(entity => {
|
|
173
|
-
// Custom canvas rendering
|
|
174
|
-
this.renderEntityToCanvas(ctx, entity);
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Use custom renderer
|
|
180
|
-
const customRenderer = new CustomRenderer();
|
|
181
|
-
const drawableEntities = entities.map(entity => customRenderer.renderEntity(entity));
|
|
182
|
-
customRenderer.renderToCanvas(canvas, drawableEntities);
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### Batch Rendering
|
|
186
|
-
```typescript
|
|
187
|
-
import { AcGiRenderer } from '@mlightcad/graphic-interface';
|
|
188
|
-
|
|
189
|
-
// Batch render multiple entities
|
|
190
|
-
const renderer = new AcGiRenderer();
|
|
191
|
-
const entities = [line1, circle1, polyline1, text1];
|
|
192
|
-
|
|
193
|
-
// Render all entities with consistent styling
|
|
194
|
-
const drawableEntities = renderer.renderEntities(entities, {
|
|
195
|
-
defaultColor: 7, // White
|
|
196
|
-
defaultLayer: '0',
|
|
197
|
-
defaultLinetype: 'CONTINUOUS'
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// Apply viewport transformations
|
|
201
|
-
viewport.applyTransformations(drawableEntities);
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
## Dependencies
|
|
205
|
-
|
|
206
|
-
- **@mlightcad/geometry-engine**: For geometric operations (peer dependency)
|
|
207
|
-
|
|
208
|
-
## API Documentation
|
|
209
|
-
|
|
210
|
-
For detailed API documentation, visit the [RealDWG-Web documentation](https://mlight-lee.github.io/realdwg-web/).
|
|
211
|
-
|
|
212
|
-
## Contributing
|
|
213
|
-
|
|
1
|
+
# @mlightcad/graphic-interface
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://www.npmjs.com/package/@mlightcad/graphic-interface)
|
|
5
|
+
|
|
6
|
+
The graphic-interface package provides the graphics interface for controlling how AutoCAD entities are displayed on screen. This package offers a simplified API compared to AutoCAD ObjectARX's AcGi classes, making it more developer-friendly while maintaining the core functionality needed for rendering CAD entities.
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
This package provides the graphics interface layer that bridges the gap between the data model and the rendering system. It handles the conversion of AutoCAD entities into drawable objects and provides customization options for how objects are displayed, including colors, layers, visibility, and various rendering styles.
|
|
11
|
+
|
|
12
|
+
## Key Features
|
|
13
|
+
|
|
14
|
+
- **Entity Rendering**: Convert AutoCAD entities to drawable objects
|
|
15
|
+
- **Style Customization**: Control colors, line styles, text styles, and point styles
|
|
16
|
+
- **View Management**: Handle different views and viewports
|
|
17
|
+
- **Arrow and Hatch Support**: Custom arrow types and hatch pattern rendering
|
|
18
|
+
- **Image Rendering**: Support for raster image display
|
|
19
|
+
- **Flexible Rendering**: Extensible rendering system for different output formats
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @mlightcad/graphic-interface
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Key Classes
|
|
28
|
+
|
|
29
|
+
### Core Rendering Classes
|
|
30
|
+
- **AcGiRenderer**: Main interface for rendering entities to drawable objects
|
|
31
|
+
- **AcGiEntity**: Base class for drawable objects that can be rendered
|
|
32
|
+
- **AcGiView**: Represents a view with camera and projection settings
|
|
33
|
+
- **AcGiViewport**: Manages viewport settings and clipping
|
|
34
|
+
|
|
35
|
+
### Style Classes
|
|
36
|
+
- **AcGiArrowType**: Defines different arrow types for dimensions and leaders
|
|
37
|
+
- **AcGiHatchStyle**: Controls hatch pattern rendering and appearance
|
|
38
|
+
- **AcGiImageStyle**: Manages raster image display properties
|
|
39
|
+
- **AcGiLineStyle**: Defines line styles including dash patterns and widths
|
|
40
|
+
- **AcGiPointStyle**: Controls point entity display appearance
|
|
41
|
+
- **AcGiTextStyle**: Manages text rendering properties and formatting
|
|
42
|
+
|
|
43
|
+
## Usage Examples
|
|
44
|
+
|
|
45
|
+
### Basic Entity Rendering
|
|
46
|
+
```typescript
|
|
47
|
+
import { AcGiRenderer, AcGiEntity } from '@mlightcad/graphic-interface';
|
|
48
|
+
import { AcDbLine, AcGePoint3d } from '@mlightcad/data-model';
|
|
49
|
+
|
|
50
|
+
// Create a renderer
|
|
51
|
+
const renderer = new AcGiRenderer();
|
|
52
|
+
|
|
53
|
+
// Create an entity
|
|
54
|
+
const startPoint = new AcGePoint3d(0, 0, 0);
|
|
55
|
+
const endPoint = new AcGePoint3d(10, 10, 0);
|
|
56
|
+
const line = new AcDbLine(startPoint, endPoint);
|
|
57
|
+
|
|
58
|
+
// Render the entity
|
|
59
|
+
const drawableEntity = renderer.renderEntity(line);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Style Configuration
|
|
63
|
+
```typescript
|
|
64
|
+
import {
|
|
65
|
+
AcGiLineStyle,
|
|
66
|
+
AcGiTextStyle,
|
|
67
|
+
AcGiPointStyle,
|
|
68
|
+
AcGiArrowType
|
|
69
|
+
} from '@mlightcad/graphic-interface';
|
|
70
|
+
|
|
71
|
+
// Configure line style
|
|
72
|
+
const lineStyle = new AcGiLineStyle();
|
|
73
|
+
lineStyle.setColor(1); // Red
|
|
74
|
+
lineStyle.setWidth(2.0);
|
|
75
|
+
lineStyle.setDashPattern([10, 5, 5, 5]); // Dashed line
|
|
76
|
+
|
|
77
|
+
// Configure text style
|
|
78
|
+
const textStyle = new AcGiTextStyle();
|
|
79
|
+
textStyle.setFont('Arial');
|
|
80
|
+
textStyle.setHeight(12);
|
|
81
|
+
textStyle.setColor(2); // Yellow
|
|
82
|
+
textStyle.setBold(true);
|
|
83
|
+
|
|
84
|
+
// Configure point style
|
|
85
|
+
const pointStyle = new AcGiPointStyle();
|
|
86
|
+
pointStyle.setSize(5);
|
|
87
|
+
pointStyle.setShape('Circle');
|
|
88
|
+
pointStyle.setColor(3); // Green
|
|
89
|
+
|
|
90
|
+
// Configure arrow style
|
|
91
|
+
const arrowStyle = new AcGiArrowType();
|
|
92
|
+
arrowStyle.setType('ClosedFilled');
|
|
93
|
+
arrowStyle.setSize(3);
|
|
94
|
+
arrowStyle.setColor(1); // Red
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### View and Viewport Management
|
|
98
|
+
```typescript
|
|
99
|
+
import { AcGiView, AcGiViewport, AcGePoint3d } from '@mlightcad/graphic-interface';
|
|
100
|
+
|
|
101
|
+
// Create a view
|
|
102
|
+
const view = new AcGiView();
|
|
103
|
+
view.setEyePoint(new AcGePoint3d(0, 0, 100));
|
|
104
|
+
view.setTargetPoint(new AcGePoint3d(0, 0, 0));
|
|
105
|
+
view.setUpVector(new AcGeVector3d(0, 1, 0));
|
|
106
|
+
|
|
107
|
+
// Create a viewport
|
|
108
|
+
const viewport = new AcGiViewport();
|
|
109
|
+
viewport.setView(view);
|
|
110
|
+
viewport.setWidth(800);
|
|
111
|
+
viewport.setHeight(600);
|
|
112
|
+
viewport.setZoom(1.0);
|
|
113
|
+
|
|
114
|
+
// Set viewport properties
|
|
115
|
+
viewport.setClippingEnabled(true);
|
|
116
|
+
viewport.setClippingBounds(0, 0, 100, 100);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Hatch Pattern Rendering
|
|
120
|
+
```typescript
|
|
121
|
+
import { AcGiHatchStyle } from '@mlightcad/graphic-interface';
|
|
122
|
+
|
|
123
|
+
// Configure hatch style
|
|
124
|
+
const hatchStyle = new AcGiHatchStyle();
|
|
125
|
+
hatchStyle.setPattern('ANSI31'); // Standard AutoCAD pattern
|
|
126
|
+
hatchStyle.setScale(1.0);
|
|
127
|
+
hatchStyle.setAngle(0);
|
|
128
|
+
hatchStyle.setColor(4); // Cyan
|
|
129
|
+
hatchStyle.setTransparency(0.5);
|
|
130
|
+
|
|
131
|
+
// Apply hatch to an entity
|
|
132
|
+
const hatchedEntity = renderer.renderEntityWithHatch(entity, hatchStyle);
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Image Rendering
|
|
136
|
+
```typescript
|
|
137
|
+
import { AcGiImageStyle } from '@mlightcad/graphic-interface';
|
|
138
|
+
|
|
139
|
+
// Configure image style
|
|
140
|
+
const imageStyle = new AcGiImageStyle();
|
|
141
|
+
imageStyle.setBrightness(1.0);
|
|
142
|
+
imageStyle.setContrast(1.0);
|
|
143
|
+
imageStyle.setFade(0.0);
|
|
144
|
+
imageStyle.setTransparency(0.0);
|
|
145
|
+
imageStyle.setClippingEnabled(false);
|
|
146
|
+
|
|
147
|
+
// Render image with style
|
|
148
|
+
const imageEntity = renderer.renderImage(imagePath, imageStyle);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Custom Rendering Pipeline
|
|
152
|
+
```typescript
|
|
153
|
+
import { AcGiRenderer, AcGiEntity } from '@mlightcad/graphic-interface';
|
|
154
|
+
|
|
155
|
+
// Create a custom renderer
|
|
156
|
+
class CustomRenderer extends AcGiRenderer {
|
|
157
|
+
renderEntity(entity: AcDbEntity): AcGiEntity {
|
|
158
|
+
// Custom rendering logic
|
|
159
|
+
const drawable = super.renderEntity(entity);
|
|
160
|
+
|
|
161
|
+
// Apply custom styling
|
|
162
|
+
if (entity.getLayer() === 'HIGHLIGHT') {
|
|
163
|
+
drawable.setHighlighted(true);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return drawable;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
renderToCanvas(canvas: HTMLCanvasElement, entities: AcGiEntity[]) {
|
|
170
|
+
const ctx = canvas.getContext('2d');
|
|
171
|
+
|
|
172
|
+
entities.forEach(entity => {
|
|
173
|
+
// Custom canvas rendering
|
|
174
|
+
this.renderEntityToCanvas(ctx, entity);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Use custom renderer
|
|
180
|
+
const customRenderer = new CustomRenderer();
|
|
181
|
+
const drawableEntities = entities.map(entity => customRenderer.renderEntity(entity));
|
|
182
|
+
customRenderer.renderToCanvas(canvas, drawableEntities);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Batch Rendering
|
|
186
|
+
```typescript
|
|
187
|
+
import { AcGiRenderer } from '@mlightcad/graphic-interface';
|
|
188
|
+
|
|
189
|
+
// Batch render multiple entities
|
|
190
|
+
const renderer = new AcGiRenderer();
|
|
191
|
+
const entities = [line1, circle1, polyline1, text1];
|
|
192
|
+
|
|
193
|
+
// Render all entities with consistent styling
|
|
194
|
+
const drawableEntities = renderer.renderEntities(entities, {
|
|
195
|
+
defaultColor: 7, // White
|
|
196
|
+
defaultLayer: '0',
|
|
197
|
+
defaultLinetype: 'CONTINUOUS'
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// Apply viewport transformations
|
|
201
|
+
viewport.applyTransformations(drawableEntities);
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Dependencies
|
|
205
|
+
|
|
206
|
+
- **@mlightcad/geometry-engine**: For geometric operations (peer dependency)
|
|
207
|
+
|
|
208
|
+
## API Documentation
|
|
209
|
+
|
|
210
|
+
For detailed API documentation, visit the [RealDWG-Web documentation](https://mlight-lee.github.io/realdwg-web/).
|
|
211
|
+
|
|
212
|
+
## Contributing
|
|
213
|
+
|
|
214
214
|
This package is part of the RealDWG-Web monorepo. Please refer to the main project README for contribution guidelines.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(s,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@mlightcad/geometry-engine")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/geometry-engine"],r):(s=typeof globalThis<"u"?globalThis:s||self,r(s["graphic-interface"]={},s.geometryEngine))})(this,(function(s,r){"use strict";var i=(e=>(e.ClosedFilled="",e.Dot="_DOT",e.DotSmall="_DOTSMALL",e.DotBlank="_DOTBLANK",e.Origin="_ORIGIN",e.Origin2="_ORIGIN2",e.Open="_OPEN",e.Open90="_OPEN90",e.Open30="_OPEN30",e.Closed="_CLOSED",e.Small="_SMALL",e.None="_NONE",e.Oblique="_OBLIQUE",e.BoxFilled="_BOXFILLED",e.Box="_BOXBLANK",e.ClosedBlank="_CLOSEDBLANK",e.DatumBlank="_DATUMBLANK",e.DatumFilled="_DATUMFILLED",e.Integral="_INTEGRAL",e.ArchTick="_ARCHTICK",e))(i||{}),I=(e=>(e[e.ByBlock=-2]="ByBlock",e[e.ByDIPs=-4]="ByDIPs",e[e.ByLayer=-1]="ByLayer",e[e.ByLineWeightDefault=-3]="ByLineWeightDefault",e[e.LineWeight000=0]="LineWeight000",e[e.LineWeight005=5]="LineWeight005",e[e.LineWeight009=9]="LineWeight009",e[e.LineWeight013=13]="LineWeight013",e[e.LineWeight015=15]="LineWeight015",e[e.LineWeight018=18]="LineWeight018",e[e.LineWeight020=20]="LineWeight020",e[e.LineWeight025=25]="LineWeight025",e[e.LineWeight030=30]="LineWeight030",e[e.LineWeight035=35]="LineWeight035",e[e.LineWeight040=40]="LineWeight040",e[e.LineWeight050=50]="LineWeight050",e[e.LineWeight053=53]="LineWeight053",e[e.LineWeight060=60]="LineWeight060",e[e.LineWeight070=70]="LineWeight070",e[e.LineWeight080=80]="LineWeight080",e[e.LineWeight090=90]="LineWeight090",e[e.LineWeight100=100]="LineWeight100",e[e.LineWeight106=106]="LineWeight106",e[e.LineWeight120=120]="LineWeight120",e[e.LineWeight140=140]="LineWeight140",e[e.LineWeight158=158]="LineWeight158",e[e.LineWeight200=200]="LineWeight200",e[e.LineWeight211=211]="LineWeight211",e))(I||{});class _{constructor(t={}){this.database=t.database,this.foregroundOnDark=t.foregroundOnDark??u,this.foregroundOnLight=t.foregroundOnLight??h,this.backgroundIsDark=t.backgroundIsDark??!0,this.fallbackRgb=t.fallbackRgb??16777215}resolveSubEntityTraitsRgb(t){const n=t.color;return n.isForeground?this.backgroundIsDark?this.foregroundOnDark:this.foregroundOnLight:n.isByLayer||n.isByBlock?this.fallbackRgb??16777215:n.RGB??this.fallbackRgb??16777215}static fromBackgroundColor(t=a,n){return new _({database:n,foregroundOnDark:u,foregroundOnLight:h,backgroundIsDark:!l(t),fallbackRgb:16777215})}}const a=0,u=16777215,h=0,b=16777215,f=128,v=new _({database:void 0,foregroundOnDark:u,foregroundOnLight:h,backgroundIsDark:!0,fallbackRgb:16777215});function l(e){const t=e>>16&255,n=e>>8&255,g=e&255;return .299*t+.587*n+.114*g>f}function H(e){const t=_.fromBackgroundColor(e);return t.backgroundIsDark?t.foregroundOnDark:t.foregroundOnLight}function N(e){return e?h:u}function k(e,t){return _.fromBackgroundColor(t).resolveSubEntityTraitsRgb(e)}var E=(e=>(e[e.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",e[e.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",e[e.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",e[e.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",e[e.BY_STYLE=5]="BY_STYLE",e))(E||{}),C=(e=>(e[e.TopLeft=1]="TopLeft",e[e.TopCenter=2]="TopCenter",e[e.TopRight=3]="TopRight",e[e.MiddleLeft=4]="MiddleLeft",e[e.MiddleCenter=5]="MiddleCenter",e[e.MiddleRight=6]="MiddleRight",e[e.BottomLeft=7]="BottomLeft",e[e.BottomCenter=8]="BottomCenter",e[e.BottomRight=9]="BottomRight",e[e.BaselineLeft=10]="BaselineLeft",e[e.BaselineCenter=11]="BaselineCenter",e[e.BaselineRight=12]="BaselineRight",e))(C||{}),D=(e=>(e[e.OPTIMIZED_2D=0]="OPTIMIZED_2D",e[e.WIREFRAME=1]="WIREFRAME",e[e.HIDDEN_LINE=2]="HIDDEN_LINE",e[e.FLAT_SHADED=3]="FLAT_SHADED",e[e.GOURAUD_SHADED=4]="GOURAUD_SHADED",e[e.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",e[e.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",e))(D||{}),B=(e=>(e[e.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",e[e.TOP=1]="TOP",e[e.BOTTOM=2]="BOTTOM",e[e.FRONT=3]="FRONT",e[e.BACK=4]="BACK",e[e.LEFT=5]="LEFT",e[e.RIGHT=6]="RIGHT",e))(B||{}),T=(e=>(e[e.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",e[e.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",e))(T||{});class d{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new r.AcGePoint3d,this._height=0,this._width=0,this._viewCenter=new r.AcGePoint3d,this._viewTarget=new r.AcGePoint3d,this._viewTwistAngle=0,this._viewHeight=0}get number(){return this._number}set number(t){this._number=t}get id(){return this._id}set id(t){this._id=t}get groupId(){return this._groupId}set groupId(t){this._groupId=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get box(){const t=new r.AcGeBox2d;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewTarget(){return this._viewTarget}set viewTarget(t){this._viewTarget.copy(t)}get viewTwistAngle(){return this._viewTwistAngle}set viewTwistAngle(t){this._viewTwistAngle=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=d.dcsCenterToWcs(this.viewCenter,this.viewTarget,this.viewTwistAngle),n=new r.AcGeBox2d;return n.setFromCenterAndSize(t,{x:this.viewWidth,y:this.viewHeight}),n}static dcsCenterToWcs(t,n,g){let O=t.x,o=t.y;if(Number.isFinite(g)&&g!==0){const R=Math.cos(g),L=Math.sin(g);O=t.x*R-t.y*L,o=t.x*L+t.y*R}return n&&Number.isFinite(n.x)&&Number.isFinite(n.y)&&(O+=n.x,o+=n.y),new r.AcGePoint3d(O,o,0)}clone(){const t=new d;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewTarget.copy(this.viewTarget),t.viewTwistAngle=this.viewTwistAngle,t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewTarget.copy(t.viewTarget),this.viewTwistAngle=t.viewTwistAngle,this.viewHeight=t.viewHeight,this}}s.ACGI_DARK_THEME_FOREGROUND=u,s.ACGI_LIGHT_THEME_FOREGROUND=h,s.ACGI_MODEL_SPACE_BACKGROUND=a,s.ACGI_PAPER_SPACE_BACKGROUND=b,s.AcGiArrowType=i,s.AcGiContext=_,s.AcGiDefaultLightingType=T,s.AcGiLineWeight=I,s.AcGiMTextAttachmentPoint=C,s.AcGiMTextFlowDirection=E,s.AcGiOrthographicType=B,s.AcGiRenderMode=D,s.AcGiViewport=d,s.DEFAULT_ACGI_CONTEXT=v,s.acgiContrastingForegroundColor=N,s.acgiForegroundColorForBackground=H,s.acgiIsLightBackground=l,s.acgiResolveSubEntityTraitsRgbFromBackground=k,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
|
package/lib/AcGiTextStyle.d.ts
CHANGED
|
@@ -43,6 +43,11 @@ export interface AcGiMTextData {
|
|
|
43
43
|
directionVector?: AcGeVector3dLike;
|
|
44
44
|
attachmentPoint?: AcGiMTextAttachmentPoint;
|
|
45
45
|
drawingDirection?: AcGiMTextFlowDirection;
|
|
46
|
+
/**
|
|
47
|
+
* AutoCAD DXF group-44 line spacing factor.
|
|
48
|
+
* Ratio of actual baseline spacing to single spacing (`5/3` of text height).
|
|
49
|
+
* Default is `1.0`.
|
|
50
|
+
*/
|
|
46
51
|
lineSpaceFactor?: number;
|
|
47
52
|
widthFactor?: number;
|
|
48
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcGiTextStyle.d.ts","sourceRoot":"","sources":["../src/AcGiTextStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAE9E,oBAAY,sBAAsB;IAChC,aAAa,IAAI;IACjB,aAAa,IAAI;IACjB,aAAa,IAAI;IACjB,aAAa,IAAI;IACjB,QAAQ,IAAI;CACb;AAED;;;;;;;;;;GAUG;AACH,oBAAY,wBAAwB;IAClC,OAAO,IAAI;IACX,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,UAAU,IAAI;IACd,YAAY,IAAI;IAChB,WAAW,IAAI;IACf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AQ,IAAI;IACZ,UAAU,IAAI;IACd,YAAY,IAAI;IAChB,WAAW,IAAI;IACf,UAAU,IAAI;IACd,YAAY,IAAI;IAChB,WAAW,IAAI;IACf,sEAAsE;IACtE,YAAY,KAAK;IACjB,6BAA6B;IAC7B,cAAc,KAAK;IACnB,4BAA4B;IAC5B,aAAa,KAAK;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,eAAe,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,gBAAgB,CAAA;IAClC,eAAe,CAAC,EAAE,wBAAwB,CAAA;IAC1C,gBAAgB,CAAC,EAAE,sBAAsB,CAAA;IACzC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB"}
|
package/lib/AcGiViewport.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export declare class AcGiViewport {
|
|
|
8
8
|
private _height;
|
|
9
9
|
private _width;
|
|
10
10
|
private _viewCenter;
|
|
11
|
+
private _viewTarget;
|
|
12
|
+
private _viewTwistAngle;
|
|
11
13
|
private _viewHeight;
|
|
12
14
|
private _number;
|
|
13
15
|
private _id;
|
|
@@ -53,6 +55,19 @@ export declare class AcGiViewport {
|
|
|
53
55
|
*/
|
|
54
56
|
get viewCenter(): AcGePoint3d;
|
|
55
57
|
set viewCenter(value: AcGePoint3d);
|
|
58
|
+
/**
|
|
59
|
+
* The view target in WCS coordinates (DXF group 17).
|
|
60
|
+
*
|
|
61
|
+
* Paper-space viewports store the model view center in DCS (`viewCenter`);
|
|
62
|
+
* the WCS center is `viewTarget + rotate(viewCenter, viewTwistAngle)`.
|
|
63
|
+
*/
|
|
64
|
+
get viewTarget(): AcGePoint3d;
|
|
65
|
+
set viewTarget(value: AcGePoint3d);
|
|
66
|
+
/**
|
|
67
|
+
* The view twist angle in radians (DXF group 51).
|
|
68
|
+
*/
|
|
69
|
+
get viewTwistAngle(): number;
|
|
70
|
+
set viewTwistAngle(value: number);
|
|
56
71
|
/**
|
|
57
72
|
* The height (in display coordinate system coordinates) of the Model Space view within the viewport.
|
|
58
73
|
* Zooming the view out within the viewport increases this value and zooming in decreases this value.
|
|
@@ -65,9 +80,18 @@ export declare class AcGiViewport {
|
|
|
65
80
|
*/
|
|
66
81
|
get viewWidth(): number;
|
|
67
82
|
/**
|
|
68
|
-
* The bounding box
|
|
83
|
+
* The bounding box of the Model Space view shown through this viewport,
|
|
84
|
+
* expressed in WCS coordinates.
|
|
85
|
+
*
|
|
86
|
+
* `viewCenter` is stored in DCS; AutoCAD maps it to WCS by rotating by
|
|
87
|
+
* `viewTwistAngle` and translating by `viewTarget` (same rule as
|
|
88
|
+
* `AcDbViewportTableRecord.modelViewBox` for the *ACTIVE VPORT).
|
|
69
89
|
*/
|
|
70
90
|
get viewBox(): AcGeBox2d;
|
|
91
|
+
/**
|
|
92
|
+
* Maps a DCS view center to WCS using the viewport target and twist.
|
|
93
|
+
*/
|
|
94
|
+
static dcsCenterToWcs(center: AcGePoint3d, target: AcGePoint3d, twistAngle: number): AcGePoint3d;
|
|
71
95
|
/**
|
|
72
96
|
* Clone this viewport
|
|
73
97
|
* @returns Return the cloned instance of this viewport
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcGiViewport.d.ts","sourceRoot":"","sources":["../src/AcGiViewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAEnE;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,GAAG,CAAQ;IACnB,OAAO,CAAC,QAAQ,CAAQ;;
|
|
1
|
+
{"version":3,"file":"AcGiViewport.d.ts","sourceRoot":"","sources":["../src/AcGiViewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAEnE;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,GAAG,CAAQ;IACnB,OAAO,CAAC,QAAQ,CAAQ;;IAexB;;OAEG;IACH,IAAI,MAAM,IAGQ,MAAM,CADvB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAEvB;IAED;;OAEG;IACH,IAAI,EAAE,IAGQ,MAAM,CADnB;IACD,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAEnB;IAED;;OAEG;IACH,IAAI,OAAO,IAGQ,MAAM,CADxB;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,MAAM,EAExB;IAED;;OAEG;IACH,IAAI,WAAW,IAGQ,WAAW,CADjC;IACD,IAAI,WAAW,CAAC,KAAK,EAAE,WAAW,EAEjC;IAED;;OAEG;IACH,IAAI,MAAM,IAGQ,MAAM,CADvB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAEvB;IAED;;;OAGG;IACH,IAAI,KAAK,IAGQ,MAAM,CADtB;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAEtB;IAED;;OAEG;IACH,IAAI,GAAG,cAON;IAED;;OAEG;IACH,IAAI,UAAU,IAGQ,WAAW,CADhC;IACD,IAAI,UAAU,CAAC,KAAK,EAAE,WAAW,EAEhC;IAED;;;;;OAKG;IACH,IAAI,UAAU,IAGQ,WAAW,CADhC;IACD,IAAI,UAAU,CAAC,KAAK,EAAE,WAAW,EAEhC;IAED;;OAEG;IACH,IAAI,cAAc,IAGQ,MAAM,CAD/B;IACD,IAAI,cAAc,CAAC,KAAK,EAAE,MAAM,EAE/B;IAED;;;OAGG;IACH,IAAI,UAAU,IAGQ,MAAM,CAD3B;IACD,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,EAE3B;IAED;;;OAGG;IACH,IAAI,SAAS,WAEZ;IAED;;;;;;;OAOG;IACH,IAAI,OAAO,cAYV;IAED;;OAEG;IACH,MAAM,CAAC,cAAc,CACnB,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,EACnB,UAAU,EAAE,MAAM,GACjB,WAAW;IAoBd;;;OAGG;IACH,KAAK;IAeL;;;;OAIG;IACH,IAAI,CAAC,QAAQ,EAAE,YAAY;CAa5B"}
|
package/lib/AcGiViewport.js
CHANGED
|
@@ -12,6 +12,8 @@ var AcGiViewport = /** @class */ (function () {
|
|
|
12
12
|
this._height = 0;
|
|
13
13
|
this._width = 0;
|
|
14
14
|
this._viewCenter = new AcGePoint3d();
|
|
15
|
+
this._viewTarget = new AcGePoint3d();
|
|
16
|
+
this._viewTwistAngle = 0;
|
|
15
17
|
this._viewHeight = 0;
|
|
16
18
|
}
|
|
17
19
|
Object.defineProperty(AcGiViewport.prototype, "number", {
|
|
@@ -121,6 +123,35 @@ var AcGiViewport = /** @class */ (function () {
|
|
|
121
123
|
enumerable: false,
|
|
122
124
|
configurable: true
|
|
123
125
|
});
|
|
126
|
+
Object.defineProperty(AcGiViewport.prototype, "viewTarget", {
|
|
127
|
+
/**
|
|
128
|
+
* The view target in WCS coordinates (DXF group 17).
|
|
129
|
+
*
|
|
130
|
+
* Paper-space viewports store the model view center in DCS (`viewCenter`);
|
|
131
|
+
* the WCS center is `viewTarget + rotate(viewCenter, viewTwistAngle)`.
|
|
132
|
+
*/
|
|
133
|
+
get: function () {
|
|
134
|
+
return this._viewTarget;
|
|
135
|
+
},
|
|
136
|
+
set: function (value) {
|
|
137
|
+
this._viewTarget.copy(value);
|
|
138
|
+
},
|
|
139
|
+
enumerable: false,
|
|
140
|
+
configurable: true
|
|
141
|
+
});
|
|
142
|
+
Object.defineProperty(AcGiViewport.prototype, "viewTwistAngle", {
|
|
143
|
+
/**
|
|
144
|
+
* The view twist angle in radians (DXF group 51).
|
|
145
|
+
*/
|
|
146
|
+
get: function () {
|
|
147
|
+
return this._viewTwistAngle;
|
|
148
|
+
},
|
|
149
|
+
set: function (value) {
|
|
150
|
+
this._viewTwistAngle = value;
|
|
151
|
+
},
|
|
152
|
+
enumerable: false,
|
|
153
|
+
configurable: true
|
|
154
|
+
});
|
|
124
155
|
Object.defineProperty(AcGiViewport.prototype, "viewHeight", {
|
|
125
156
|
/**
|
|
126
157
|
* The height (in display coordinate system coordinates) of the Model Space view within the viewport.
|
|
@@ -148,11 +179,17 @@ var AcGiViewport = /** @class */ (function () {
|
|
|
148
179
|
});
|
|
149
180
|
Object.defineProperty(AcGiViewport.prototype, "viewBox", {
|
|
150
181
|
/**
|
|
151
|
-
* The bounding box
|
|
182
|
+
* The bounding box of the Model Space view shown through this viewport,
|
|
183
|
+
* expressed in WCS coordinates.
|
|
184
|
+
*
|
|
185
|
+
* `viewCenter` is stored in DCS; AutoCAD maps it to WCS by rotating by
|
|
186
|
+
* `viewTwistAngle` and translating by `viewTarget` (same rule as
|
|
187
|
+
* `AcDbViewportTableRecord.modelViewBox` for the *ACTIVE VPORT).
|
|
152
188
|
*/
|
|
153
189
|
get: function () {
|
|
190
|
+
var wcsCenter = AcGiViewport.dcsCenterToWcs(this.viewCenter, this.viewTarget, this.viewTwistAngle);
|
|
154
191
|
var box = new AcGeBox2d();
|
|
155
|
-
box.setFromCenterAndSize(
|
|
192
|
+
box.setFromCenterAndSize(wcsCenter, {
|
|
156
193
|
x: this.viewWidth,
|
|
157
194
|
y: this.viewHeight
|
|
158
195
|
});
|
|
@@ -161,6 +198,26 @@ var AcGiViewport = /** @class */ (function () {
|
|
|
161
198
|
enumerable: false,
|
|
162
199
|
configurable: true
|
|
163
200
|
});
|
|
201
|
+
/**
|
|
202
|
+
* Maps a DCS view center to WCS using the viewport target and twist.
|
|
203
|
+
*/
|
|
204
|
+
AcGiViewport.dcsCenterToWcs = function (center, target, twistAngle) {
|
|
205
|
+
var wcsCenterX = center.x;
|
|
206
|
+
var wcsCenterY = center.y;
|
|
207
|
+
if (Number.isFinite(twistAngle) && twistAngle !== 0) {
|
|
208
|
+
var cos = Math.cos(twistAngle);
|
|
209
|
+
var sin = Math.sin(twistAngle);
|
|
210
|
+
wcsCenterX = center.x * cos - center.y * sin;
|
|
211
|
+
wcsCenterY = center.x * sin + center.y * cos;
|
|
212
|
+
}
|
|
213
|
+
if (target &&
|
|
214
|
+
Number.isFinite(target.x) &&
|
|
215
|
+
Number.isFinite(target.y)) {
|
|
216
|
+
wcsCenterX += target.x;
|
|
217
|
+
wcsCenterY += target.y;
|
|
218
|
+
}
|
|
219
|
+
return new AcGePoint3d(wcsCenterX, wcsCenterY, 0);
|
|
220
|
+
};
|
|
164
221
|
/**
|
|
165
222
|
* Clone this viewport
|
|
166
223
|
* @returns Return the cloned instance of this viewport
|
|
@@ -174,6 +231,8 @@ var AcGiViewport = /** @class */ (function () {
|
|
|
174
231
|
viewport.height = this.height;
|
|
175
232
|
viewport.width = this.width;
|
|
176
233
|
viewport.viewCenter.copy(this.viewCenter);
|
|
234
|
+
viewport.viewTarget.copy(this.viewTarget);
|
|
235
|
+
viewport.viewTwistAngle = this.viewTwistAngle;
|
|
177
236
|
viewport.viewHeight = this.viewHeight;
|
|
178
237
|
return viewport;
|
|
179
238
|
};
|
|
@@ -190,6 +249,8 @@ var AcGiViewport = /** @class */ (function () {
|
|
|
190
249
|
this.height = viewport.height;
|
|
191
250
|
this.width = viewport.width;
|
|
192
251
|
this.viewCenter.copy(viewport.viewCenter);
|
|
252
|
+
this.viewTarget.copy(viewport.viewTarget);
|
|
253
|
+
this.viewTwistAngle = viewport.viewTwistAngle;
|
|
193
254
|
this.viewHeight = viewport.viewHeight;
|
|
194
255
|
return this;
|
|
195
256
|
};
|
package/lib/AcGiViewport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcGiViewport.js","sourceRoot":"","sources":["../src/AcGiViewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAEnE;;;GAGG;AACH;
|
|
1
|
+
{"version":3,"file":"AcGiViewport.js","sourceRoot":"","sources":["../src/AcGiViewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAEnE;;;GAGG;AACH;IAYE;QACE,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAA;QACjB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;QACb,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;QAClB,IAAI,CAAC,YAAY,GAAG,IAAI,WAAW,EAAE,CAAA;QACrC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;QACf,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,EAA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C,cAAc,CAAA;QAC7C,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAA;QACrC,OAAO,IAAI,CAAA;IACb,CAAC;IACH,mBAAC;AAAD,CAAC,AA5OD,IA4OC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlightcad/graphic-interface",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"require": "./dist/graphic-interface.umd.cjs"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@mlightcad/common": "1.
|
|
37
|
-
"@mlightcad/geometry-engine": "3.
|
|
36
|
+
"@mlightcad/common": "1.12.0",
|
|
37
|
+
"@mlightcad/geometry-engine": "3.12.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"clean": "rimraf dist lib tsconfig.tsbuildinfo",
|