@mlightcad/cad-simple-viewer 1.0.0 → 1.0.1

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 (136) hide show
  1. package/README.md +296 -2
  2. package/dist/index.js +1347 -122
  3. package/dist/index.umd.cjs +2 -2
  4. package/lib/app/AcApContext.d.ts +45 -3
  5. package/lib/app/AcApContext.d.ts.map +1 -1
  6. package/lib/app/AcApContext.js +43 -3
  7. package/lib/app/AcApContext.js.map +1 -1
  8. package/lib/app/AcApDocCreator.d.ts +68 -2
  9. package/lib/app/AcApDocCreator.d.ts.map +1 -1
  10. package/lib/app/AcApDocCreator.js +67 -2
  11. package/lib/app/AcApDocCreator.js.map +1 -1
  12. package/lib/app/AcApDocManager.d.ts +227 -12
  13. package/lib/app/AcApDocManager.d.ts.map +1 -1
  14. package/lib/app/AcApDocManager.js +228 -17
  15. package/lib/app/AcApDocManager.js.map +1 -1
  16. package/lib/app/AcApDocument.d.ts +77 -3
  17. package/lib/app/AcApDocument.d.ts.map +1 -1
  18. package/lib/app/AcApDocument.js +75 -3
  19. package/lib/app/AcApDocument.js.map +1 -1
  20. package/lib/app/AcApFontLoader.d.ts +32 -0
  21. package/lib/app/AcApFontLoader.d.ts.map +1 -1
  22. package/lib/app/AcApFontLoader.js +30 -0
  23. package/lib/app/AcApFontLoader.js.map +1 -1
  24. package/lib/app/AcApSettingManager.d.ts +191 -3
  25. package/lib/app/AcApSettingManager.d.ts.map +1 -1
  26. package/lib/app/AcApSettingManager.js +161 -0
  27. package/lib/app/AcApSettingManager.js.map +1 -1
  28. package/lib/command/AcApConvertToSvgCmd.d.ts +26 -0
  29. package/lib/command/AcApConvertToSvgCmd.d.ts.map +1 -1
  30. package/lib/command/AcApConvertToSvgCmd.js +26 -0
  31. package/lib/command/AcApConvertToSvgCmd.js.map +1 -1
  32. package/lib/command/AcApOpenCmd.d.ts +31 -0
  33. package/lib/command/AcApOpenCmd.d.ts.map +1 -1
  34. package/lib/command/AcApOpenCmd.js +31 -0
  35. package/lib/command/AcApOpenCmd.js.map +1 -1
  36. package/lib/command/AcApPanCmd.d.ts +25 -0
  37. package/lib/command/AcApPanCmd.d.ts.map +1 -1
  38. package/lib/command/AcApPanCmd.js +25 -0
  39. package/lib/command/AcApPanCmd.js.map +1 -1
  40. package/lib/command/AcApQNewCmd.d.ts +26 -0
  41. package/lib/command/AcApQNewCmd.d.ts.map +1 -1
  42. package/lib/command/AcApQNewCmd.js +26 -0
  43. package/lib/command/AcApQNewCmd.js.map +1 -1
  44. package/lib/command/AcApSelectCmd.d.ts +26 -0
  45. package/lib/command/AcApSelectCmd.d.ts.map +1 -1
  46. package/lib/command/AcApSelectCmd.js +26 -0
  47. package/lib/command/AcApSelectCmd.js.map +1 -1
  48. package/lib/command/AcApSvgConvertor.d.ts +48 -0
  49. package/lib/command/AcApSvgConvertor.d.ts.map +1 -1
  50. package/lib/command/AcApSvgConvertor.js +48 -0
  51. package/lib/command/AcApSvgConvertor.js.map +1 -1
  52. package/lib/command/AcApZoomCmd.d.ts +29 -0
  53. package/lib/command/AcApZoomCmd.d.ts.map +1 -1
  54. package/lib/command/AcApZoomCmd.js +29 -0
  55. package/lib/command/AcApZoomCmd.js.map +1 -1
  56. package/lib/command/AcApZoomToBoxCmd.d.ts +57 -0
  57. package/lib/command/AcApZoomToBoxCmd.d.ts.map +1 -1
  58. package/lib/command/AcApZoomToBoxCmd.js +57 -0
  59. package/lib/command/AcApZoomToBoxCmd.js.map +1 -1
  60. package/lib/editor/command/AcEdCommand.d.ts +118 -9
  61. package/lib/editor/command/AcEdCommand.d.ts.map +1 -1
  62. package/lib/editor/command/AcEdCommand.js +113 -9
  63. package/lib/editor/command/AcEdCommand.js.map +1 -1
  64. package/lib/editor/command/AcEdCommandStack.d.ts +59 -5
  65. package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -1
  66. package/lib/editor/command/AcEdCommandStack.js +48 -5
  67. package/lib/editor/command/AcEdCommandStack.js.map +1 -1
  68. package/lib/editor/global/eventBus.d.ts +69 -1
  69. package/lib/editor/global/eventBus.d.ts.map +1 -1
  70. package/lib/editor/global/eventBus.js +37 -0
  71. package/lib/editor/global/eventBus.js.map +1 -1
  72. package/lib/editor/input/AcEdBaseInput.d.ts +65 -1
  73. package/lib/editor/input/AcEdBaseInput.d.ts.map +1 -1
  74. package/lib/editor/input/AcEdBaseInput.js +62 -1
  75. package/lib/editor/input/AcEdBaseInput.js.map +1 -1
  76. package/lib/editor/input/AcEdBoxSelector.d.ts +81 -0
  77. package/lib/editor/input/AcEdBoxSelector.d.ts.map +1 -1
  78. package/lib/editor/input/AcEdBoxSelector.js +80 -0
  79. package/lib/editor/input/AcEdBoxSelector.js.map +1 -1
  80. package/lib/editor/input/AcEdCursorManager.d.ts +95 -8
  81. package/lib/editor/input/AcEdCursorManager.d.ts.map +1 -1
  82. package/lib/editor/input/AcEdCursorManager.js +95 -11
  83. package/lib/editor/input/AcEdCursorManager.js.map +1 -1
  84. package/lib/editor/input/AcEdInputPoint.d.ts +38 -1
  85. package/lib/editor/input/AcEdInputPoint.d.ts.map +1 -1
  86. package/lib/editor/input/AcEdInputPoint.js +38 -1
  87. package/lib/editor/input/AcEdInputPoint.js.map +1 -1
  88. package/lib/editor/input/AcEdJig.d.ts +166 -0
  89. package/lib/editor/input/AcEdJig.d.ts.map +1 -1
  90. package/lib/editor/input/AcEdJig.js +164 -0
  91. package/lib/editor/input/AcEdJig.js.map +1 -1
  92. package/lib/editor/input/AcEdJigLoop.d.ts +49 -0
  93. package/lib/editor/input/AcEdJigLoop.d.ts.map +1 -1
  94. package/lib/editor/input/AcEdJigLoop.js +48 -0
  95. package/lib/editor/input/AcEdJigLoop.js.map +1 -1
  96. package/lib/editor/input/AcEdSelectionSet.d.ts +122 -2
  97. package/lib/editor/input/AcEdSelectionSet.d.ts.map +1 -1
  98. package/lib/editor/input/AcEdSelectionSet.js +117 -1
  99. package/lib/editor/input/AcEdSelectionSet.js.map +1 -1
  100. package/lib/editor/input/AcEditor.d.ts +90 -6
  101. package/lib/editor/input/AcEditor.d.ts.map +1 -1
  102. package/lib/editor/input/AcEditor.js +86 -6
  103. package/lib/editor/input/AcEditor.js.map +1 -1
  104. package/lib/editor/view/AcEdBaseView.d.ts +163 -16
  105. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
  106. package/lib/editor/view/AcEdBaseView.js +94 -5
  107. package/lib/editor/view/AcEdBaseView.js.map +1 -1
  108. package/lib/util/AcTrGeometryUtil.d.ts +65 -0
  109. package/lib/util/AcTrGeometryUtil.d.ts.map +1 -1
  110. package/lib/util/AcTrGeometryUtil.js +65 -0
  111. package/lib/util/AcTrGeometryUtil.js.map +1 -1
  112. package/lib/view/AcTrLayer.d.ts +40 -5
  113. package/lib/view/AcTrLayer.d.ts.map +1 -1
  114. package/lib/view/AcTrLayer.js +34 -5
  115. package/lib/view/AcTrLayer.js.map +1 -1
  116. package/lib/view/AcTrLayout.d.ts +122 -23
  117. package/lib/view/AcTrLayout.d.ts.map +1 -1
  118. package/lib/view/AcTrLayout.js +103 -23
  119. package/lib/view/AcTrLayout.js.map +1 -1
  120. package/lib/view/AcTrLayoutView.d.ts +74 -16
  121. package/lib/view/AcTrLayoutView.d.ts.map +1 -1
  122. package/lib/view/AcTrLayoutView.js +65 -16
  123. package/lib/view/AcTrLayoutView.js.map +1 -1
  124. package/lib/view/AcTrLayoutViewManager.d.ts +58 -12
  125. package/lib/view/AcTrLayoutViewManager.d.ts.map +1 -1
  126. package/lib/view/AcTrLayoutViewManager.js +56 -12
  127. package/lib/view/AcTrLayoutViewManager.js.map +1 -1
  128. package/lib/view/AcTrScene.d.ts +48 -4
  129. package/lib/view/AcTrScene.d.ts.map +1 -1
  130. package/lib/view/AcTrScene.js +44 -4
  131. package/lib/view/AcTrScene.js.map +1 -1
  132. package/lib/view/AcTrView2d.d.ts +71 -0
  133. package/lib/view/AcTrView2d.d.ts.map +1 -1
  134. package/lib/view/AcTrView2d.js +65 -0
  135. package/lib/view/AcTrView2d.js.map +1 -1
  136. package/package.json +8 -4
@@ -1,30 +1,105 @@
1
+ /**
2
+ * Enumeration of cursor types available in the CAD editor.
3
+ *
4
+ * These cursor types provide visual feedback to users about the current
5
+ * operation mode or expected input type. Each cursor has a specific
6
+ * appearance and is used in different contexts.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Set crosshair cursor for precise point input
11
+ * editor.setCursor(AcEdCorsorType.Crosshair);
12
+ *
13
+ * // Set grab cursor for pan operations
14
+ * editor.setCursor(AcEdCorsorType.Grab);
15
+ *
16
+ * // Restore default cursor
17
+ * editor.setCursor(AcEdCorsorType.NoSpecialCursor);
18
+ * ```
19
+ */
1
20
  export var AcEdCorsorType;
2
21
  (function (AcEdCorsorType) {
22
+ /** No special cursor - uses browser default */
3
23
  AcEdCorsorType[AcEdCorsorType["NoSpecialCursor"] = -1] = "NoSpecialCursor";
24
+ /** Crosshair cursor for precise point selection */
4
25
  AcEdCorsorType[AcEdCorsorType["Crosshair"] = 0] = "Crosshair";
26
+ /** Rectangle cursor for area selection */
5
27
  AcEdCorsorType[AcEdCorsorType["RectCursor"] = 1] = "RectCursor";
28
+ /** Rubber band cursor for dynamic drawing */
6
29
  AcEdCorsorType[AcEdCorsorType["RubberBand"] = 2] = "RubberBand";
30
+ /** Non-rotated cursor */
7
31
  AcEdCorsorType[AcEdCorsorType["NotRotated"] = 3] = "NotRotated";
32
+ /** Target box cursor for object snapping */
8
33
  AcEdCorsorType[AcEdCorsorType["TargetBox"] = 4] = "TargetBox";
34
+ /** Rotated crosshair cursor */
9
35
  AcEdCorsorType[AcEdCorsorType["RotatedCrosshair"] = 5] = "RotatedCrosshair";
36
+ /** Crosshair that doesn't rotate with view */
10
37
  AcEdCorsorType[AcEdCorsorType["CrosshairNoRotate"] = 6] = "CrosshairNoRotate";
38
+ /** Invisible cursor for hiding cursor */
11
39
  AcEdCorsorType[AcEdCorsorType["Invisible"] = 7] = "Invisible";
40
+ /** Entity selection cursor */
12
41
  AcEdCorsorType[AcEdCorsorType["EntitySelect"] = 8] = "EntitySelect";
42
+ /** Parallelogram cursor for skewed operations */
13
43
  AcEdCorsorType[AcEdCorsorType["Parallelogram"] = 9] = "Parallelogram";
44
+ /** Entity select cursor without perspective */
14
45
  AcEdCorsorType[AcEdCorsorType["EntitySelectNoPersp"] = 10] = "EntitySelectNoPersp";
46
+ /** Cursor for pick-first or grips operations */
15
47
  AcEdCorsorType[AcEdCorsorType["PkfirstOrGrips"] = 11] = "PkfirstOrGrips";
48
+ /** Dashed crosshair cursor */
16
49
  AcEdCorsorType[AcEdCorsorType["CrosshairDashed"] = 12] = "CrosshairDashed";
50
+ /** Grab/hand cursor for panning */
17
51
  AcEdCorsorType[AcEdCorsorType["Grab"] = 13] = "Grab";
18
52
  })(AcEdCorsorType || (AcEdCorsorType = {}));
19
53
  /**
20
- * The class to create and manage cursor
21
- * @internal
54
+ * Manages cursor appearance and behavior for the CAD editor.
55
+ *
56
+ * This class creates and applies custom cursors to HTML elements,
57
+ * providing visual feedback for different CAD operations. It supports
58
+ * both built-in browser cursors and custom SVG-based cursors.
59
+ *
60
+ * The cursor manager maintains a cache of cursor definitions to avoid
61
+ * recreating them repeatedly, improving performance.
62
+ *
63
+ * @internal This class is for internal use by the editor system
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const cursorManager = new AcEdCursorManager();
68
+ * const canvas = document.getElementById('canvas') as HTMLCanvasElement;
69
+ *
70
+ * // Set crosshair cursor
71
+ * cursorManager.setCursor(AcEdCorsorType.Crosshair, canvas);
72
+ *
73
+ * // Set grab cursor for panning
74
+ * cursorManager.setCursor(AcEdCorsorType.Grab, canvas);
75
+ * ```
22
76
  */
23
77
  var AcEdCursorManager = /** @class */ (function () {
78
+ /**
79
+ * Creates a new cursor manager instance.
80
+ *
81
+ * Initializes the cursor cache and creates default cursor definitions.
82
+ */
24
83
  function AcEdCursorManager() {
25
84
  this._cursorMap = new Map();
26
85
  this._cursorMap.set(AcEdCorsorType.Crosshair, this.createRectCrossIcon(10, 10));
27
86
  }
87
+ /**
88
+ * Sets the cursor for the specified HTML element.
89
+ *
90
+ * Applies the appropriate cursor style based on the cursor type.
91
+ * For built-in cursor types, uses CSS cursor values. For custom
92
+ * cursor types, uses cached SVG-based cursor definitions.
93
+ *
94
+ * @param cursorType - The type of cursor to set
95
+ * @param element - The HTML element to apply the cursor to
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * const canvas = document.getElementById('canvas') as HTMLCanvasElement;
100
+ * cursorManager.setCursor(AcEdCorsorType.Crosshair, canvas);
101
+ * ```
102
+ */
28
103
  AcEdCursorManager.prototype.setCursor = function (cursorType, element) {
29
104
  if (cursorType <= AcEdCorsorType.NoSpecialCursor) {
30
105
  element.style.cursor = 'default';
@@ -40,15 +115,24 @@ var AcEdCursorManager = /** @class */ (function () {
40
115
  }
41
116
  };
42
117
  /**
43
- * Encode SVG string to one cursor defined using url() in CSS
44
- * @param svgString Input svg string
45
- * @param xOffset Input x offset for cursor hotspot
46
- * @param yOffset Input y offset for cursor hotspot
47
- * @returns
118
+ * Encodes an SVG string into a CSS cursor URL.
119
+ *
120
+ * This method converts SVG markup into a data URI that can be used
121
+ * as a CSS cursor value, with specified hotspot coordinates.
122
+ *
123
+ * @param svgString - The SVG markup as a string
124
+ * @param xOffset - X coordinate of the cursor hotspot
125
+ * @param yOffset - Y coordinate of the cursor hotspot
126
+ * @returns CSS cursor string in url() format
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * const svgCursor = '<svg width="20" height="20">...</svg>';
131
+ * const cursorUrl = cursorManager.encodeSvgToCursor(svgCursor, 10, 10);
132
+ * element.style.cursor = cursorUrl;
133
+ * ```
48
134
  */
49
- AcEdCursorManager.prototype.encodeSvg = function (svgString, xOffset, yOffset) {
50
- if (xOffset === void 0) { xOffset = 0; }
51
- if (yOffset === void 0) { yOffset = 0; }
135
+ AcEdCursorManager.prototype.encodeSvgToCursor = function (svgString, xOffset, yOffset) {
52
136
  return "url('data:image/svg+xml;base64,".concat(btoa(svgString), "') ").concat(xOffset, " ").concat(yOffset, ", auto");
53
137
  };
54
138
  /**
@@ -63,7 +147,7 @@ var AcEdCursorManager = /** @class */ (function () {
63
147
  var halfSize = rectSize / 2;
64
148
  var svgSize = rectSize + 2 * lineLength;
65
149
  var svg = "\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(svgSize, "\" height=\"").concat(svgSize, "\" viewBox=\"0 0 ").concat(svgSize, " ").concat(svgSize, "\">\n <rect x=\"").concat(lineLength, "\" y=\"").concat(lineLength, "\" width=\"").concat(rectSize, "\" height=\"").concat(rectSize, "\" fill=\"none\" stroke=\"").concat(lineColor, "\" />\n <line x1=\"").concat(halfSize + lineLength, "\" y1=\"0\" x2=\"").concat(halfSize + lineLength, "\" y2=\"").concat(lineLength, "\" stroke=\"").concat(lineColor, "\" />\n <line x1=\"").concat(rectSize + lineLength, "\" y1=\"").concat(halfSize + lineLength, "\" x2=\"").concat(rectSize + 2 * lineLength, "\" y2=\"").concat(halfSize + lineLength, "\" stroke=\"").concat(lineColor, "\" />\n <line x1=\"").concat(halfSize + lineLength, "\" y1=\"").concat(rectSize + lineLength, "\" x2=\"").concat(halfSize + lineLength, "\" y2=\"").concat(rectSize + 2 * lineLength, "\" stroke=\"").concat(lineColor, "\" />\n <line x1=\"0\" y1=\"").concat(halfSize + lineLength, "\" x2=\"").concat(lineLength, "\" y2=\"").concat(halfSize + lineLength, "\" stroke=\"").concat(lineColor, "\" />\n </svg>\n ");
66
- return this.encodeSvg(svg, halfSize + lineLength, halfSize + lineLength);
150
+ return this.encodeSvgToCursor(svg, halfSize + lineLength, halfSize + lineLength);
67
151
  };
68
152
  return AcEdCursorManager;
69
153
  }());
@@ -1 +1 @@
1
- {"version":3,"file":"AcEdCursorManager.js","sourceRoot":"","sources":["../../../src/editor/input/AcEdCursorManager.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,cAgBX;AAhBD,WAAY,cAAc;IACxB,0EAAoB,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cEdBaseView } from '../view/AcEdBaseView';
3
3
  import { AcEdBaseInput } from './AcEdBaseInput';
4
4
  /**
5
- * Class used to input one point
5
+ * Class used to input one point from user interaction.
6
+ *
7
+ * This class provides functionality for capturing a single point input from the user
8
+ * by handling mouse click events. When the user clicks on the canvas, the click
9
+ * coordinates are converted from screen coordinates to world coordinates and
10
+ * returned as the result.
11
+ *
12
+ * The input operation can be canceled by pressing the Escape key (handled by the base class).
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const pointInput = new AcEdInputPoint(view);
17
+ * const point = await pointInput.start();
18
+ * console.log(`User clicked at: ${point.x}, ${point.y}`);
19
+ * ```
20
+ *
6
21
  * @internal
7
22
  */
8
23
  export declare class AcEdInputPoint extends AcEdBaseInput<AcGePoint2d> {
24
+ /**
25
+ * Creates a new point input instance.
26
+ *
27
+ * @param view - The view that will handle this point input operation
28
+ */
9
29
  constructor(view: AcEdBaseView);
30
+ /**
31
+ * Activates the point input operation.
32
+ * Sets up the click event listener to capture user point selection.
33
+ * Overrides the base class to add click event handling.
34
+ */
10
35
  activate(): void;
36
+ /**
37
+ * Deactivates the point input operation.
38
+ * Removes the click event listener.
39
+ * Overrides the base class to clean up click event handling.
40
+ */
11
41
  deactivate(): void;
42
+ /**
43
+ * Handles mouse click events to capture the selected point.
44
+ * Converts the click coordinates from screen space to world coordinates
45
+ * and resolves the input operation with the resulting point.
46
+ *
47
+ * @param event - The mouse click event containing the screen coordinates
48
+ */
12
49
  private onClick;
13
50
  }
14
51
  //# sourceMappingURL=AcEdInputPoint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AcEdInputPoint.d.ts","sourceRoot":"","sources":["../../../src/editor/input/AcEdInputPoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;;GAGG;AACH,qBAAa,cAAe,SAAQ,aAAa,CAAC,WAAW,CAAC;gBAChD,IAAI,EAAE,YAAY;IAI9B,QAAQ;IAKR,UAAU;IAKV,OAAO,CAAC,OAAO,CAEd;CACF"}
1
+ {"version":3,"file":"AcEdInputPoint.d.ts","sourceRoot":"","sources":["../../../src/editor/input/AcEdInputPoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,cAAe,SAAQ,aAAa,CAAC,WAAW,CAAC;IAC5D;;;;OAIG;gBACS,IAAI,EAAE,YAAY;IAI9B;;;;OAIG;IACH,QAAQ;IAKR;;;;OAIG;IACH,UAAU;IAKV;;;;;;OAMG;IACH,OAAO,CAAC,OAAO,CAEd;CACF"}
@@ -15,22 +15,59 @@ var __extends = (this && this.__extends) || (function () {
15
15
  })();
16
16
  import { AcEdBaseInput } from './AcEdBaseInput';
17
17
  /**
18
- * Class used to input one point
18
+ * Class used to input one point from user interaction.
19
+ *
20
+ * This class provides functionality for capturing a single point input from the user
21
+ * by handling mouse click events. When the user clicks on the canvas, the click
22
+ * coordinates are converted from screen coordinates to world coordinates and
23
+ * returned as the result.
24
+ *
25
+ * The input operation can be canceled by pressing the Escape key (handled by the base class).
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const pointInput = new AcEdInputPoint(view);
30
+ * const point = await pointInput.start();
31
+ * console.log(`User clicked at: ${point.x}, ${point.y}`);
32
+ * ```
33
+ *
19
34
  * @internal
20
35
  */
21
36
  var AcEdInputPoint = /** @class */ (function (_super) {
22
37
  __extends(AcEdInputPoint, _super);
38
+ /**
39
+ * Creates a new point input instance.
40
+ *
41
+ * @param view - The view that will handle this point input operation
42
+ */
23
43
  function AcEdInputPoint(view) {
24
44
  var _this = _super.call(this, view) || this;
45
+ /**
46
+ * Handles mouse click events to capture the selected point.
47
+ * Converts the click coordinates from screen space to world coordinates
48
+ * and resolves the input operation with the resulting point.
49
+ *
50
+ * @param event - The mouse click event containing the screen coordinates
51
+ */
25
52
  _this.onClick = function (event) {
26
53
  _this.resolve(_this.view.cwcs2Wcs({ x: event.clientX, y: event.clientY }));
27
54
  };
28
55
  return _this;
29
56
  }
57
+ /**
58
+ * Activates the point input operation.
59
+ * Sets up the click event listener to capture user point selection.
60
+ * Overrides the base class to add click event handling.
61
+ */
30
62
  AcEdInputPoint.prototype.activate = function () {
31
63
  _super.prototype.activate.call(this);
32
64
  this.view.canvas.addEventListener('click', this.onClick);
33
65
  };
66
+ /**
67
+ * Deactivates the point input operation.
68
+ * Removes the click event listener.
69
+ * Overrides the base class to clean up click event handling.
70
+ */
34
71
  AcEdInputPoint.prototype.deactivate = function () {
35
72
  _super.prototype.deactivate.call(this);
36
73
  this.view.canvas.removeEventListener('click', this.onClick);
@@ -1 +1 @@
1
- {"version":3,"file":"AcEdInputPoint.js","sourceRoot":"","sources":["../../../src/editor/input/AcEdInputPoint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;;GAGG;AACH;IAAoC,kCAA0B;IAC5D,wBAAY,IAAkB;QAC5B,YAAA,MAAK,YAAC,IAAI,CAAC,SAAA;QAaL,aAAO,GAAG,UAAC,KAAiB;YAClC,KAAI,CAAC,OAAO,CAAC,KAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;QAC1E,CAAC,CAAA;;IAdD,CAAC;IAED,iCAAQ,GAAR;QACE,gBAAK,CAAC,QAAQ,WAAE,CAAA;QAChB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gBA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Aa,GAwChD"}
@@ -1,14 +1,180 @@
1
1
  import { AcEdBaseView } from '../view';
2
+ /**
3
+ * Base class for interactive drawing operations (jigs) in the CAD editor.
4
+ *
5
+ * A jig is an interactive operation that allows users to dynamically preview
6
+ * and modify geometric elements during creation. Common examples include:
7
+ * - Drawing lines with real-time preview as the mouse moves
8
+ * - Selecting rectangular areas with visual feedback
9
+ * - Dynamic entity placement with instant visual updates
10
+ *
11
+ * The jig system provides:
12
+ * - Real-time visual feedback during user interaction
13
+ * - Event-driven updates based on mouse movement
14
+ * - Asynchronous completion handling
15
+ * - Cancellation and error handling
16
+ *
17
+ * @template TResult - The type of result returned when the jig completes
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * class RectangleSelectionJig extends AcEdJig<Rectangle> {
22
+ * private startPoint?: Point;
23
+ * private currentPoint?: Point;
24
+ *
25
+ * async sampler() {
26
+ * // Get start point
27
+ * this.startPoint = await this.view.editor.getPoint();
28
+ *
29
+ * // Continue updating until complete
30
+ * this.view.events.mouseMove.addEventListener(this.onMouseMove);
31
+ * }
32
+ *
33
+ * update() {
34
+ * if (this.startPoint && this.currentPoint) {
35
+ * // Update preview rectangle
36
+ * this.drawPreviewRectangle(this.startPoint, this.currentPoint);
37
+ * }
38
+ * }
39
+ *
40
+ * private onMouseMove = (args) => {
41
+ * this.currentPoint = args;
42
+ * // Jig loop will call update() automatically
43
+ * }
44
+ * }
45
+ *
46
+ * // Usage
47
+ * const jig = new RectangleSelectionJig(view);
48
+ * const rectangle = await jig.drag();
49
+ * ```
50
+ */
2
51
  export declare class AcEdJig<TResult> {
52
+ /** Internal jig loop that handles the interactive operation */
3
53
  private _jigLoop;
54
+ /** The view associated with this jig */
4
55
  private _view;
56
+ /**
57
+ * Creates a new jig instance for the specified view.
58
+ *
59
+ * Sets up the jig loop and connects update event handling.
60
+ *
61
+ * @param view - The view this jig will operate in
62
+ */
5
63
  constructor(view: AcEdBaseView);
64
+ /**
65
+ * Gets the view associated with this jig.
66
+ *
67
+ * @returns The view instance
68
+ */
6
69
  get view(): AcEdBaseView;
70
+ /**
71
+ * Resolves the jig operation with the specified result.
72
+ *
73
+ * This method should be called when the jig operation completes successfully.
74
+ * It cleans up event listeners and resolves the underlying promise.
75
+ *
76
+ * @param result - The result to return from the jig operation
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * // In a line drawing jig, when user completes the line
81
+ * if (this.hasValidEndPoint()) {
82
+ * const line = new Line(this.startPoint, this.endPoint);
83
+ * this.resolve(line);
84
+ * }
85
+ * ```
86
+ */
7
87
  resolve(result: TResult): void;
88
+ /**
89
+ * Rejects the jig operation with an error.
90
+ *
91
+ * This method should be called when the jig operation fails or is cancelled.
92
+ * It cleans up event listeners and rejects the underlying promise.
93
+ *
94
+ * @param reason - The reason for the rejection
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * // If user cancels or invalid input is detected
99
+ * if (userPressedEscape) {
100
+ * this.reject('Operation cancelled by user');
101
+ * }
102
+ * ```
103
+ */
8
104
  reject(reason: string): void;
105
+ /**
106
+ * Starts the interactive jig operation.
107
+ *
108
+ * This method initiates both the jig loop and the sampling process.
109
+ * It returns a promise that resolves when the jig operation completes
110
+ * or rejects if an error occurs.
111
+ *
112
+ * @returns Promise that resolves when the jig operation completes
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const jig = new MyCustomJig(view);
117
+ * try {
118
+ * const result = await jig.drag();
119
+ * console.log('Jig completed with result:', result);
120
+ * } catch (error) {
121
+ * console.log('Jig was cancelled or failed:', error);
122
+ * }
123
+ * ```
124
+ */
9
125
  drag(): Promise<void>;
126
+ /**
127
+ * Abstract method for handling jig input sampling.
128
+ *
129
+ * This method should be overridden by subclasses to implement
130
+ * the specific input handling logic for the jig. It typically:
131
+ * - Gets initial user input (like a start point)
132
+ * - Sets up event listeners for dynamic updates
133
+ * - Handles user interaction until completion
134
+ *
135
+ * The sampler runs concurrently with the jig loop and should
136
+ * call `resolve()` or `reject()` when the operation completes.
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * async sampler() {
141
+ * // Get initial point
142
+ * const startPoint = await this.view.editor.getPoint();
143
+ *
144
+ * // Set up mouse tracking for dynamic preview
145
+ * this.view.events.mouseMove.addEventListener(this.onMouseMove);
146
+ * this.view.events.mouseClick.addEventListener(this.onMouseClick);
147
+ * }
148
+ * ```
149
+ */
10
150
  sampler(): Promise<void>;
151
+ /**
152
+ * Called during each update cycle to refresh the jig display.
153
+ *
154
+ * This method should be overridden by subclasses to implement
155
+ * the visual update logic. It's called automatically by the jig loop
156
+ * whenever the display needs to be refreshed (typically on mouse movement).
157
+ *
158
+ * Common update operations include:
159
+ * - Redrawing preview geometry
160
+ * - Updating dimension displays
161
+ * - Refreshing visual feedback elements
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * update() {
166
+ * if (this.startPoint && this.currentMousePoint) {
167
+ * // Clear previous preview
168
+ * this.clearPreview();
169
+ *
170
+ * // Draw new preview line
171
+ * this.drawPreviewLine(this.startPoint, this.currentMousePoint);
172
+ * }
173
+ * }
174
+ * ```
175
+ */
11
176
  update(): void;
177
+ /** Internal event handler for jig loop updates */
12
178
  private onUpdate;
13
179
  }
14
180
  //# sourceMappingURL=AcEdJig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AcEdJig.d.ts","sourceRoot":"","sources":["../../../src/editor/input/AcEdJig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAGtC,qBAAa,OAAO,CAAC,OAAO;IAC1B,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,KAAK,CAAc;gBAEf,IAAI,EAAE,YAAY;IAM9B,IAAI,IAAI,iBAEP;IAED,OAAO,CAAC,MAAM,EAAE,OAAO;IAKvB,MAAM,CAAC,MAAM,EAAE,MAAM;IAKf,IAAI;IAMJ,OAAO;IAIb,MAAM;IAIN,OAAO,CAAC,QAAQ,CAEf;CACF"}
1
+ {"version":3,"file":"AcEdJig.d.ts","sourceRoot":"","sources":["../../../src/editor/input/AcEdJig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,qBAAa,OAAO,CAAC,OAAO;IAC1B,+DAA+D;IAC/D,OAAO,CAAC,QAAQ,CAAsB;IACtC,wCAAwC;IACxC,OAAO,CAAC,KAAK,CAAc;IAE3B;;;;;;OAMG;gBACS,IAAI,EAAE,YAAY;IAM9B;;;;OAIG;IACH,IAAI,IAAI,iBAEP;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,MAAM,EAAE,OAAO;IAKvB;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM;IAKrB;;;;;;;;;;;;;;;;;;;OAmBG;IACG,IAAI;IAMV;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,OAAO;IAIb;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,MAAM;IAIN,kDAAkD;IAClD,OAAO,CAAC,QAAQ,CAEf;CACF"}