@mlightcad/cad-simple-viewer 1.2.2 → 1.2.3

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.
Files changed (202) hide show
  1. package/dist/__vite-browser-external-l0sNRNKZ-l0sNRNKZ.js +1 -0
  2. package/dist/index.js +40205 -0
  3. package/dist/index.umd.cjs +333 -0
  4. package/dist/libredwg-parser-worker.js +15458 -0
  5. package/dist/mtext-renderer-worker.js +29930 -0
  6. package/lib/app/AcApContext.d.ts +57 -0
  7. package/lib/app/AcApContext.d.ts.map +1 -0
  8. package/lib/app/AcApContext.js +106 -0
  9. package/lib/app/AcApContext.js.map +1 -0
  10. package/lib/app/AcApDocManager.d.ts +291 -0
  11. package/lib/app/AcApDocManager.d.ts.map +1 -0
  12. package/lib/app/AcApDocManager.js +498 -0
  13. package/lib/app/AcApDocManager.js.map +1 -0
  14. package/lib/app/AcApDocument.d.ts +101 -0
  15. package/lib/app/AcApDocument.d.ts.map +1 -0
  16. package/lib/app/AcApDocument.js +237 -0
  17. package/lib/app/AcApDocument.js.map +1 -0
  18. package/lib/app/AcApFontLoader.d.ts +54 -0
  19. package/lib/app/AcApFontLoader.d.ts.map +1 -0
  20. package/lib/app/AcApFontLoader.js +151 -0
  21. package/lib/app/AcApFontLoader.js.map +1 -0
  22. package/lib/app/AcApGlobalFunc.d.ts +26 -0
  23. package/lib/app/AcApGlobalFunc.d.ts.map +1 -0
  24. package/lib/app/AcApGlobalFunc.js +66 -0
  25. package/lib/app/AcApGlobalFunc.js.map +1 -0
  26. package/lib/app/AcApSettingManager.d.ts +232 -0
  27. package/lib/app/AcApSettingManager.d.ts.map +1 -0
  28. package/lib/app/AcApSettingManager.js +283 -0
  29. package/lib/app/AcApSettingManager.js.map +1 -0
  30. package/lib/app/index.d.ts +6 -0
  31. package/lib/app/index.d.ts.map +1 -0
  32. package/lib/app/index.js +6 -0
  33. package/lib/app/index.js.map +1 -0
  34. package/lib/command/AcApConvertToSvgCmd.d.ts +32 -0
  35. package/lib/command/AcApConvertToSvgCmd.d.ts.map +1 -0
  36. package/lib/command/AcApConvertToSvgCmd.js +56 -0
  37. package/lib/command/AcApConvertToSvgCmd.js.map +1 -0
  38. package/lib/command/AcApOpenCmd.d.ts +37 -0
  39. package/lib/command/AcApOpenCmd.d.ts.map +1 -0
  40. package/lib/command/AcApOpenCmd.js +60 -0
  41. package/lib/command/AcApOpenCmd.js.map +1 -0
  42. package/lib/command/AcApPanCmd.d.ts +31 -0
  43. package/lib/command/AcApPanCmd.d.ts.map +1 -0
  44. package/lib/command/AcApPanCmd.js +55 -0
  45. package/lib/command/AcApPanCmd.js.map +1 -0
  46. package/lib/command/AcApQNewCmd.d.ts +32 -0
  47. package/lib/command/AcApQNewCmd.d.ts.map +1 -0
  48. package/lib/command/AcApQNewCmd.js +56 -0
  49. package/lib/command/AcApQNewCmd.js.map +1 -0
  50. package/lib/command/AcApRegenCmd.d.ts +21 -0
  51. package/lib/command/AcApRegenCmd.d.ts.map +1 -0
  52. package/lib/command/AcApRegenCmd.js +45 -0
  53. package/lib/command/AcApRegenCmd.js.map +1 -0
  54. package/lib/command/AcApSelectCmd.d.ts +32 -0
  55. package/lib/command/AcApSelectCmd.d.ts.map +1 -0
  56. package/lib/command/AcApSelectCmd.js +56 -0
  57. package/lib/command/AcApSelectCmd.js.map +1 -0
  58. package/lib/command/AcApSvgConvertor.d.ts +53 -0
  59. package/lib/command/AcApSvgConvertor.d.ts.map +1 -0
  60. package/lib/command/AcApSvgConvertor.js +103 -0
  61. package/lib/command/AcApSvgConvertor.js.map +1 -0
  62. package/lib/command/AcApZoomCmd.d.ts +35 -0
  63. package/lib/command/AcApZoomCmd.d.ts.map +1 -0
  64. package/lib/command/AcApZoomCmd.js +57 -0
  65. package/lib/command/AcApZoomCmd.js.map +1 -0
  66. package/lib/command/AcApZoomToBoxCmd.d.ts +68 -0
  67. package/lib/command/AcApZoomToBoxCmd.d.ts.map +1 -0
  68. package/lib/command/AcApZoomToBoxCmd.js +158 -0
  69. package/lib/command/AcApZoomToBoxCmd.js.map +1 -0
  70. package/lib/command/index.d.ts +11 -0
  71. package/lib/command/index.d.ts.map +1 -0
  72. package/lib/command/index.js +11 -0
  73. package/lib/command/index.js.map +1 -0
  74. package/lib/editor/command/AcEdCommand.d.ts +151 -0
  75. package/lib/editor/command/AcEdCommand.d.ts.map +1 -0
  76. package/lib/editor/command/AcEdCommand.js +164 -0
  77. package/lib/editor/command/AcEdCommand.js.map +1 -0
  78. package/lib/editor/command/AcEdCommandIterator.d.ts +36 -0
  79. package/lib/editor/command/AcEdCommandIterator.d.ts.map +1 -0
  80. package/lib/editor/command/AcEdCommandIterator.js +65 -0
  81. package/lib/editor/command/AcEdCommandIterator.js.map +1 -0
  82. package/lib/editor/command/AcEdCommandStack.d.ts +120 -0
  83. package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -0
  84. package/lib/editor/command/AcEdCommandStack.js +235 -0
  85. package/lib/editor/command/AcEdCommandStack.js.map +1 -0
  86. package/lib/editor/command/index.d.ts +3 -0
  87. package/lib/editor/command/index.d.ts.map +1 -0
  88. package/lib/editor/command/index.js +3 -0
  89. package/lib/editor/command/index.js.map +1 -0
  90. package/lib/editor/global/AcEdConditionWaiter.d.ts +51 -0
  91. package/lib/editor/global/AcEdConditionWaiter.d.ts.map +1 -0
  92. package/lib/editor/global/AcEdConditionWaiter.js +87 -0
  93. package/lib/editor/global/AcEdConditionWaiter.js.map +1 -0
  94. package/lib/editor/global/AcEdGlobalFunc.d.ts +8 -0
  95. package/lib/editor/global/AcEdGlobalFunc.d.ts.map +1 -0
  96. package/lib/editor/global/AcEdGlobalFunc.js +14 -0
  97. package/lib/editor/global/AcEdGlobalFunc.js.map +1 -0
  98. package/lib/editor/global/AcEdMessage.d.ts +5 -0
  99. package/lib/editor/global/AcEdMessage.d.ts.map +1 -0
  100. package/lib/editor/global/AcEdMessage.js +6 -0
  101. package/lib/editor/global/AcEdMessage.js.map +1 -0
  102. package/lib/editor/global/eventBus.d.ts +103 -0
  103. package/lib/editor/global/eventBus.d.ts.map +1 -0
  104. package/lib/editor/global/eventBus.js +41 -0
  105. package/lib/editor/global/eventBus.js.map +1 -0
  106. package/lib/editor/global/index.d.ts +4 -0
  107. package/lib/editor/global/index.d.ts.map +1 -0
  108. package/lib/editor/global/index.js +4 -0
  109. package/lib/editor/global/index.js.map +1 -0
  110. package/lib/editor/index.d.ts +5 -0
  111. package/lib/editor/index.d.ts.map +1 -0
  112. package/lib/editor/index.js +5 -0
  113. package/lib/editor/index.js.map +1 -0
  114. package/lib/editor/input/AcEdBaseInput.d.ts +89 -0
  115. package/lib/editor/input/AcEdBaseInput.d.ts.map +1 -0
  116. package/lib/editor/input/AcEdBaseInput.js +166 -0
  117. package/lib/editor/input/AcEdBaseInput.js.map +1 -0
  118. package/lib/editor/input/AcEdBoxSelector.d.ts +108 -0
  119. package/lib/editor/input/AcEdBoxSelector.d.ts.map +1 -0
  120. package/lib/editor/input/AcEdBoxSelector.js +220 -0
  121. package/lib/editor/input/AcEdBoxSelector.js.map +1 -0
  122. package/lib/editor/input/AcEdCursorManager.d.ts +130 -0
  123. package/lib/editor/input/AcEdCursorManager.d.ts.map +1 -0
  124. package/lib/editor/input/AcEdCursorManager.js +155 -0
  125. package/lib/editor/input/AcEdCursorManager.js.map +1 -0
  126. package/lib/editor/input/AcEdInputPoint.d.ts +51 -0
  127. package/lib/editor/input/AcEdInputPoint.d.ts.map +1 -0
  128. package/lib/editor/input/AcEdInputPoint.js +78 -0
  129. package/lib/editor/input/AcEdInputPoint.js.map +1 -0
  130. package/lib/editor/input/AcEdJig.d.ts +180 -0
  131. package/lib/editor/input/AcEdJig.d.ts.map +1 -0
  132. package/lib/editor/input/AcEdJig.js +256 -0
  133. package/lib/editor/input/AcEdJig.js.map +1 -0
  134. package/lib/editor/input/AcEdJigLoop.d.ts +63 -0
  135. package/lib/editor/input/AcEdJigLoop.d.ts.map +1 -0
  136. package/lib/editor/input/AcEdJigLoop.js +91 -0
  137. package/lib/editor/input/AcEdJigLoop.js.map +1 -0
  138. package/lib/editor/input/AcEdSelectionSet.d.ts +146 -0
  139. package/lib/editor/input/AcEdSelectionSet.d.ts.map +1 -0
  140. package/lib/editor/input/AcEdSelectionSet.js +179 -0
  141. package/lib/editor/input/AcEdSelectionSet.js.map +1 -0
  142. package/lib/editor/input/AcEditor.d.ts +111 -0
  143. package/lib/editor/input/AcEditor.d.ts.map +1 -0
  144. package/lib/editor/input/AcEditor.js +183 -0
  145. package/lib/editor/input/AcEditor.js.map +1 -0
  146. package/lib/editor/input/index.d.ts +5 -0
  147. package/lib/editor/input/index.d.ts.map +1 -0
  148. package/lib/editor/input/index.js +5 -0
  149. package/lib/editor/input/index.js.map +1 -0
  150. package/lib/editor/view/AcEdBaseView.d.ts +457 -0
  151. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -0
  152. package/lib/editor/view/AcEdBaseView.js +349 -0
  153. package/lib/editor/view/AcEdBaseView.js.map +1 -0
  154. package/lib/editor/view/AcEdLayerInfo.d.ts +21 -0
  155. package/lib/editor/view/AcEdLayerInfo.d.ts.map +1 -0
  156. package/lib/editor/view/AcEdLayerInfo.js +2 -0
  157. package/lib/editor/view/AcEdLayerInfo.js.map +1 -0
  158. package/lib/editor/view/index.d.ts +3 -0
  159. package/lib/editor/view/index.d.ts.map +1 -0
  160. package/lib/editor/view/index.js +3 -0
  161. package/lib/editor/view/index.js.map +1 -0
  162. package/lib/index.d.ts +5 -0
  163. package/lib/index.d.ts.map +1 -0
  164. package/lib/index.js +5 -0
  165. package/lib/index.js.map +1 -0
  166. package/lib/util/AcTrGeometryUtil.d.ts +92 -0
  167. package/lib/util/AcTrGeometryUtil.d.ts.map +1 -0
  168. package/lib/util/AcTrGeometryUtil.js +109 -0
  169. package/lib/util/AcTrGeometryUtil.js.map +1 -0
  170. package/lib/util/index.d.ts +2 -0
  171. package/lib/util/index.d.ts.map +1 -0
  172. package/lib/util/index.js +2 -0
  173. package/lib/util/index.js.map +1 -0
  174. package/lib/view/AcTrLayer.d.ts +132 -0
  175. package/lib/view/AcTrLayer.d.ts.map +1 -0
  176. package/lib/view/AcTrLayer.js +199 -0
  177. package/lib/view/AcTrLayer.js.map +1 -0
  178. package/lib/view/AcTrLayout.d.ts +218 -0
  179. package/lib/view/AcTrLayout.d.ts.map +1 -0
  180. package/lib/view/AcTrLayout.js +437 -0
  181. package/lib/view/AcTrLayout.js.map +1 -0
  182. package/lib/view/AcTrLayoutView.d.ts +115 -0
  183. package/lib/view/AcTrLayoutView.d.ts.map +1 -0
  184. package/lib/view/AcTrLayoutView.js +200 -0
  185. package/lib/view/AcTrLayoutView.js.map +1 -0
  186. package/lib/view/AcTrLayoutViewManager.d.ts +89 -0
  187. package/lib/view/AcTrLayoutViewManager.d.ts.map +1 -0
  188. package/lib/view/AcTrLayoutViewManager.js +118 -0
  189. package/lib/view/AcTrLayoutViewManager.js.map +1 -0
  190. package/lib/view/AcTrScene.d.ts +162 -0
  191. package/lib/view/AcTrScene.d.ts.map +1 -0
  192. package/lib/view/AcTrScene.js +370 -0
  193. package/lib/view/AcTrScene.js.map +1 -0
  194. package/lib/view/AcTrView2d.d.ts +262 -0
  195. package/lib/view/AcTrView2d.d.ts.map +1 -0
  196. package/lib/view/AcTrView2d.js +772 -0
  197. package/lib/view/AcTrView2d.js.map +1 -0
  198. package/lib/view/index.d.ts +2 -0
  199. package/lib/view/index.d.ts.map +1 -0
  200. package/lib/view/index.js +2 -0
  201. package/lib/view/index.js.map +1 -0
  202. package/package.json +3 -3
@@ -0,0 +1,457 @@
1
+ import { AcCmEventManager, AcDbEntity, AcDbLayerTableRecord, AcDbLayout, AcDbObjectId, AcGeBox2d, AcGeBox3d, AcGePoint2d, AcGePoint2dLike } from '@mlightcad/data-model';
2
+ import { AcEdCorsorType, AcEdSelectionSet } from '../input';
3
+ import { AcEditor } from '../input/AcEditor';
4
+ /**
5
+ * Item returned by spatial query
6
+ */
7
+ export interface AcEdSpatialQueryResultItem {
8
+ minX: number;
9
+ minY: number;
10
+ maxX: number;
11
+ maxY: number;
12
+ id: AcDbObjectId;
13
+ }
14
+ /**
15
+ * Interface to define arguments of mouse event events.
16
+ */
17
+ export interface AcEdMouseEventArgs {
18
+ /**
19
+ * X coordinate value of current mouse in the world coordinate system
20
+ */
21
+ x: number;
22
+ /**
23
+ * Y coordinate value of current mouse in the world coordinate system
24
+ */
25
+ y: number;
26
+ }
27
+ /**
28
+ * Interface to define arguments of view resized events.
29
+ */
30
+ export interface AcEdViewResizedEventArgs {
31
+ /**
32
+ * New width of the resized view.
33
+ */
34
+ width: number;
35
+ /**
36
+ * New height of the resized view.
37
+ */
38
+ height: number;
39
+ }
40
+ /**
41
+ * Interface to define arguments of hover events.
42
+ */
43
+ export interface AcEdViewHoverEventArgs {
44
+ /**
45
+ * X coordinate value of current mouse in the screen coordinate system
46
+ */
47
+ x: number;
48
+ /**
49
+ * Y coordinate value of current mouse in the screen coordinate system
50
+ */
51
+ y: number;
52
+ /**
53
+ * Object id of the hovered entity
54
+ */
55
+ id: AcDbObjectId;
56
+ }
57
+ /**
58
+ * Enumeration of view interaction modes.
59
+ *
60
+ * The view mode determines how the view responds to user mouse interactions:
61
+ * - In SELECTION mode, clicks select entities
62
+ * - In PAN mode, clicks and drags pan the view
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * // Set to selection mode for entity picking
67
+ * view.mode = AcEdViewMode.SELECTION;
68
+ *
69
+ * // Set to pan mode for view navigation
70
+ * view.mode = AcEdViewMode.PAN;
71
+ * ```
72
+ */
73
+ export declare enum AcEdViewMode {
74
+ /**
75
+ * Selection mode - mouse clicks select entities.
76
+ *
77
+ * In this mode:
78
+ * - Single clicks select individual entities
79
+ * - Drag operations can create selection boxes
80
+ * - Selected entities are highlighted with grip points
81
+ */
82
+ SELECTION = 0,
83
+ /**
84
+ * Pan mode - mouse interactions pan the view.
85
+ *
86
+ * In this mode:
87
+ * - Click and drag operations move the view
88
+ * - The cursor typically changes to indicate pan mode
89
+ * - Entity selection is disabled
90
+ */
91
+ PAN = 1
92
+ }
93
+ /**
94
+ * Represents missed data when rendering entities in the drawing
95
+ */
96
+ export interface AcEdMissedData {
97
+ fonts: Record<string, number>;
98
+ images: Map<string, string>;
99
+ }
100
+ /**
101
+ * Type of callback function used to calculate size of canvas when window resized
102
+ */
103
+ export type AcEdCalculateSizeCallback = () => {
104
+ width: number;
105
+ height: number;
106
+ };
107
+ /**
108
+ * Abstract base class for all CAD view implementations.
109
+ *
110
+ * This class provides the foundation for rendering and interacting with CAD drawings.
111
+ * It manages:
112
+ * - Canvas and viewport dimensions
113
+ * - Mouse event handling and coordinate conversion
114
+ * - Entity selection and highlighting
115
+ * - View modes (selection, pan, etc.)
116
+ * - Spatial queries for entity picking
117
+ * - Hover/unhover detection with timing
118
+ *
119
+ * Concrete implementations must provide specific rendering logic and coordinate
120
+ * transformations appropriate for their rendering technology (e.g., Three.js, SVG).
121
+ *
122
+ * ## Key Responsibilities
123
+ * - **Input Management**: Handles mouse events and user interactions
124
+ * - **Selection**: Manages selected entities and visual feedback
125
+ * - **Coordinate Systems**: Converts between screen and world coordinates
126
+ * - **Spatial Queries**: Finds entities at specific locations
127
+ * - **View State**: Tracks current position, zoom, and view mode
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * class MyView extends AcEdBaseView {
132
+ * // Implement required abstract methods
133
+ * get missedData() { return { fonts: {}, images: new Map() }; }
134
+ * get mode() { return this._mode; }
135
+ * set mode(value) { this._mode = value; }
136
+ * // ... other abstract methods
137
+ * }
138
+ *
139
+ * const view = new MyView(canvasElement);
140
+ * view.events.mouseMove.addEventListener(args => {
141
+ * console.log('Mouse at world coords:', args.x, args.y);
142
+ * });
143
+ * ```
144
+ */
145
+ export declare abstract class AcEdBaseView {
146
+ /** Current viewport width in pixels */
147
+ private _width;
148
+ /** Current viewport height in pixels */
149
+ private _height;
150
+ /** Optional callback to calculate canvas size on resize */
151
+ private _calculateSizeCallback?;
152
+ /** Bounding box of all entities in the view */
153
+ private _bbox;
154
+ /** Current mouse position in world coordinates */
155
+ private _curPos;
156
+ /** Current mouse position in screen coordinates */
157
+ private _curScreenPos;
158
+ /** Set of currently selected entities */
159
+ private _selectionSet;
160
+ /** Input manager for handling user interactions */
161
+ private _editor;
162
+ /** Size of selection box in pixels for entity picking */
163
+ private _selectionBoxSize;
164
+ /** Timer for hover detection delay */
165
+ private _hoverTimer;
166
+ /** Timer for hover pause detection */
167
+ private _pauseTimer;
168
+ /** ID of currently hovered entity */
169
+ private _hoveredObjectId;
170
+ /** The HTML canvas element for rendering */
171
+ protected _canvas: HTMLCanvasElement;
172
+ /** Events fired by the view for various interactions */
173
+ readonly events: {
174
+ /** Fired when mouse moves over the view */
175
+ mouseMove: AcCmEventManager<AcEdMouseEventArgs>;
176
+ /** Fired when the view is resized */
177
+ viewResize: AcCmEventManager<AcEdViewResizedEventArgs>;
178
+ /** Fired when mouse hovers over an entity */
179
+ hover: AcCmEventManager<AcEdViewHoverEventArgs>;
180
+ /** Fired when mouse stops hovering over an entity */
181
+ unhover: AcCmEventManager<AcEdViewHoverEventArgs>;
182
+ };
183
+ /**
184
+ * Creates a new base view instance.
185
+ *
186
+ * Sets up the canvas, initializes internal state, and registers event listeners
187
+ * for mouse interactions and window resize events.
188
+ *
189
+ * @param canvas - The HTML canvas element to render into
190
+ */
191
+ constructor(canvas: HTMLCanvasElement);
192
+ /**
193
+ * Gets the input manager for handling user interactions.
194
+ *
195
+ * The editor provides high-level methods for getting user input like
196
+ * point selection, entity selection, and cursor management.
197
+ *
198
+ * @returns The editor instance
199
+ */
200
+ get editor(): AcEditor;
201
+ /**
202
+ * Gets the size of the selection box used for entity picking.
203
+ *
204
+ * This determines how close the mouse needs to be to an entity
205
+ * to select it, measured in screen pixels.
206
+ *
207
+ * @returns Selection box size in pixels
208
+ */
209
+ get selectionBoxSize(): number;
210
+ /**
211
+ * Sets the size of the selection box used for entity picking.
212
+ *
213
+ * @param value - Selection box size in pixels
214
+ */
215
+ set selectionBoxSize(value: number);
216
+ /**
217
+ * Gets information about missing data during rendering.
218
+ *
219
+ * This includes fonts that couldn't be loaded and images that are
220
+ * missing or inaccessible. Implementations should track and report
221
+ * this information to help users understand rendering issues.
222
+ *
223
+ * @returns Object containing missing fonts and images
224
+ */
225
+ abstract get missedData(): AcEdMissedData;
226
+ /**
227
+ * Gets the current view mode.
228
+ *
229
+ * The view mode determines how the view responds to user interactions:
230
+ * - SELECTION: Click to select entities
231
+ * - PAN: Click and drag to pan the view
232
+ *
233
+ * @returns The current view mode
234
+ */
235
+ abstract get mode(): AcEdViewMode;
236
+ /**
237
+ * Sets the current view mode.
238
+ *
239
+ * @param value - The view mode to set
240
+ */
241
+ abstract set mode(value: AcEdViewMode);
242
+ /**
243
+ * Gets the center point of the current view in world coordinates.
244
+ *
245
+ * @returns The view center point
246
+ */
247
+ abstract get center(): AcGePoint2d;
248
+ /**
249
+ * Sets the center point of the current view in world coordinates.
250
+ *
251
+ * @param value - The new center point
252
+ */
253
+ abstract set center(value: AcGePoint2d);
254
+ /**
255
+ * Converts a point from client window coordinates to world coordinates.
256
+ *
257
+ * The client window coordinate system has its origin at the top-left corner
258
+ * of the canvas, with Y increasing downward. World coordinates use the
259
+ * CAD coordinate system with Y typically increasing upward.
260
+ *
261
+ * @param point - Point in client window coordinates
262
+ * @returns Point in world coordinates
263
+ *
264
+ * @example
265
+ * ```typescript
266
+ * const screenPoint = { x: 100, y: 200 }; // 100px right, 200px down
267
+ * const worldPoint = view.cwcs2Wcs(screenPoint);
268
+ * console.log('World coordinates:', worldPoint.x, worldPoint.y);
269
+ * ```
270
+ */
271
+ abstract cwcs2Wcs(point: AcGePoint2dLike): AcGePoint2d;
272
+ /**
273
+ * Converts a point from world coordinates to client window coordinates.
274
+ *
275
+ * This is the inverse of `cwcs2Wcs()`, converting from the CAD world
276
+ * coordinate system to screen pixel coordinates.
277
+ *
278
+ * @param point - Point in world coordinates
279
+ * @returns Point in client window coordinates
280
+ *
281
+ * @example
282
+ * ```typescript
283
+ * const worldPoint = new AcGePoint2d(10, 20); // CAD coordinates
284
+ * const screenPoint = view.wcs2Cwcs(worldPoint);
285
+ * console.log('Screen position:', screenPoint.x, screenPoint.y);
286
+ * ```
287
+ */
288
+ abstract wcs2Cwcs(point: AcGePoint2dLike): AcGePoint2d;
289
+ /**
290
+ * Zooms the view to fit the specified bounding box with optional margin.
291
+ *
292
+ * This method adjusts the view's center and zoom level so that the entire
293
+ * specified bounding box is visible within the viewport. The margin parameter
294
+ * adds extra space around the bounding box to provide visual padding.
295
+ *
296
+ * @param box - The bounding box to zoom to, in world coordinates
297
+ * @param margin - Additional margin around the bounding box (in world units)
298
+ */
299
+ abstract zoomTo(box: AcGeBox2d, margin: number): void;
300
+ /**
301
+ * Zooms the view to fit all visible entities in the current scene.
302
+ *
303
+ * This method automatically calculates the bounding box of all entities
304
+ * currently displayed in the view and adjusts the view's center and zoom
305
+ * level to show the entire scene. This is useful for getting an overview
306
+ * of the entire drawing or after loading new content.
307
+ *
308
+ * This function takes effect only if the current view has finished rendering
309
+ * all entities. When opening a file, progressive Rendering is used to render
310
+ * entities incrementally. So this function will wait until all of entities
311
+ * rendered or a timeout occurs.
312
+ *
313
+ * @param timeout - Maximum time (ms) to wait before executing zoom to fit
314
+ * action. Default: 0 (no timeout).
315
+ */
316
+ abstract zoomToFit(timeout?: number): void;
317
+ /**
318
+ * Gets the background color of the view.
319
+ *
320
+ * The color is represented as a 24-bit hexadecimal RGB number, for example
321
+ * `0x000000` for black or `0xffffff` for white.
322
+ */
323
+ abstract get backgroundColor(): number;
324
+ /**
325
+ * Sets the background color of the view.
326
+ *
327
+ * @param value - The background color as a 24-bit hexadecimal RGB number
328
+ */
329
+ abstract set backgroundColor(value: number);
330
+ /**
331
+ * Search entities intersected or contained in the specified bounding box.
332
+ * @param box Input the query bounding box
333
+ * @returns Return query results
334
+ */
335
+ abstract search(box: AcGeBox2d | AcGeBox3d): AcEdSpatialQueryResultItem[];
336
+ /**
337
+ * Pick entities intersected with the specified point in the world coordinate
338
+ * system.
339
+ * @param point Input the point to pick objects. If not provided, the position
340
+ * of current cursor is used.
341
+ * @returns Return ids of entities intersected with the specified point
342
+ */
343
+ abstract pick(point?: AcGePoint2dLike): AcDbObjectId[];
344
+ /**
345
+ * Select entities intersected with the specified bounding box in the world
346
+ * coordinate system, add them to the current selection set, and highlight
347
+ * them.
348
+ * @param box Input one bounding box in the world coordinate system.
349
+ */
350
+ abstract selectByBox(box: AcGeBox2d): void;
351
+ /**
352
+ * Select entities intersected with the specified point in the world coordinate
353
+ * system, add them to the current selection set, and highlight them.
354
+ * @param box Input one point in the world coordinate system.
355
+ */
356
+ abstract select(point?: AcGePoint2dLike): void;
357
+ /**
358
+ * Clear the scene
359
+ */
360
+ abstract clear(): void;
361
+ /**
362
+ * Add the specified layer in drawing database into the current scene
363
+ * @param layer Input the layer to add into the current scene
364
+ */
365
+ abstract addLayer(layer: AcDbLayerTableRecord): void;
366
+ /**
367
+ * Update the specified layer in the current scene
368
+ * @param layer Input the layer to update
369
+ */
370
+ abstract updateLayer(layer: AcDbLayerTableRecord): void;
371
+ /**
372
+ * Add the specified entity or entities in drawing database into the current scene
373
+ * and draw it or them
374
+ * @param entity Input the entity to add into the current scene
375
+ */
376
+ abstract addEntity(entity: AcDbEntity | AcDbEntity[]): void;
377
+ /**
378
+ * Update the specified entity or entities
379
+ * @param entity Input the entity or entities to update
380
+ */
381
+ abstract updateEntity(entity: AcDbEntity | AcDbEntity[]): void;
382
+ /**
383
+ * Add the specified layout in drawing database into the current scene
384
+ * @param layout Input the layout to add into the current scene
385
+ */
386
+ abstract addLayout(layout: AcDbLayout): void;
387
+ /**
388
+ * Select the specified entities
389
+ */
390
+ abstract highlight(ids: AcDbObjectId[]): void;
391
+ /**
392
+ * Unhighlight the specified entities
393
+ */
394
+ abstract unhighlight(ids: AcDbObjectId[]): void;
395
+ /**
396
+ * Called when hovering the specified entity
397
+ */
398
+ protected abstract onHover(id: AcDbObjectId): void;
399
+ /**
400
+ * Called when unhovering the specified entity
401
+ */
402
+ protected abstract onUnhover(id: AcDbObjectId): void;
403
+ /**
404
+ * Set cursor type of this view
405
+ * @param cursorType Input cursor type
406
+ */
407
+ setCursor(cursorType: AcEdCorsorType): void;
408
+ /**
409
+ * Set callback function used to calculate size of canvas when window resized
410
+ * @param value Input callback function
411
+ */
412
+ setCalculateSizeCallback(value: AcEdCalculateSizeCallback): void;
413
+ /**
414
+ * Width of canvas (not width of window) in pixel
415
+ */
416
+ get width(): number;
417
+ set width(value: number);
418
+ /**
419
+ * Height of canvas (not height of window) in pixel
420
+ */
421
+ get height(): number;
422
+ set height(value: number);
423
+ /**
424
+ * The bounding box to include all entities in this viewer
425
+ */
426
+ get bbox(): AcGeBox3d;
427
+ /**
428
+ * The canvas HTML element used by this view
429
+ */
430
+ get canvas(): HTMLCanvasElement;
431
+ get aspect(): number;
432
+ /**
433
+ * Postion of current mouse in world coordinate system
434
+ */
435
+ get curPos(): AcGePoint2d;
436
+ /**
437
+ * Postion of current mouse in screen coordinate system
438
+ */
439
+ get curScreenPos(): AcGePoint2d;
440
+ /**
441
+ * The selection set in current view.
442
+ */
443
+ get selectionSet(): AcEdSelectionSet;
444
+ protected onWindowResize(): void;
445
+ /**
446
+ * Mouse move event handler.
447
+ * @param event Input mouse event argument
448
+ */
449
+ private onMouseMove;
450
+ private setHoveredObjectId;
451
+ private hoverAt;
452
+ private clearHoverTimer;
453
+ private clearPauseTimer;
454
+ private startHoverTimer;
455
+ private startPauseTimer;
456
+ }
457
+ //# sourceMappingURL=AcEdBaseView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcEdBaseView.d.ts","sourceRoot":"","sources":["../../../src/editor/view/AcEdBaseView.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,oBAAoB,EACpB,UAAU,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,WAAW,EACX,eAAe,EAChB,MAAM,uBAAuB,CAAA;AAE9B,O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