@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.
- package/README.md +296 -2
- package/dist/index.js +1347 -122
- package/dist/index.umd.cjs +2 -2
- package/lib/app/AcApContext.d.ts +45 -3
- package/lib/app/AcApContext.d.ts.map +1 -1
- package/lib/app/AcApContext.js +43 -3
- package/lib/app/AcApContext.js.map +1 -1
- package/lib/app/AcApDocCreator.d.ts +68 -2
- package/lib/app/AcApDocCreator.d.ts.map +1 -1
- package/lib/app/AcApDocCreator.js +67 -2
- package/lib/app/AcApDocCreator.js.map +1 -1
- package/lib/app/AcApDocManager.d.ts +227 -12
- package/lib/app/AcApDocManager.d.ts.map +1 -1
- package/lib/app/AcApDocManager.js +228 -17
- package/lib/app/AcApDocManager.js.map +1 -1
- package/lib/app/AcApDocument.d.ts +77 -3
- package/lib/app/AcApDocument.d.ts.map +1 -1
- package/lib/app/AcApDocument.js +75 -3
- package/lib/app/AcApDocument.js.map +1 -1
- package/lib/app/AcApFontLoader.d.ts +32 -0
- package/lib/app/AcApFontLoader.d.ts.map +1 -1
- package/lib/app/AcApFontLoader.js +30 -0
- package/lib/app/AcApFontLoader.js.map +1 -1
- package/lib/app/AcApSettingManager.d.ts +191 -3
- package/lib/app/AcApSettingManager.d.ts.map +1 -1
- package/lib/app/AcApSettingManager.js +161 -0
- package/lib/app/AcApSettingManager.js.map +1 -1
- package/lib/command/AcApConvertToSvgCmd.d.ts +26 -0
- package/lib/command/AcApConvertToSvgCmd.d.ts.map +1 -1
- package/lib/command/AcApConvertToSvgCmd.js +26 -0
- package/lib/command/AcApConvertToSvgCmd.js.map +1 -1
- package/lib/command/AcApOpenCmd.d.ts +31 -0
- package/lib/command/AcApOpenCmd.d.ts.map +1 -1
- package/lib/command/AcApOpenCmd.js +31 -0
- package/lib/command/AcApOpenCmd.js.map +1 -1
- package/lib/command/AcApPanCmd.d.ts +25 -0
- package/lib/command/AcApPanCmd.d.ts.map +1 -1
- package/lib/command/AcApPanCmd.js +25 -0
- package/lib/command/AcApPanCmd.js.map +1 -1
- package/lib/command/AcApQNewCmd.d.ts +26 -0
- package/lib/command/AcApQNewCmd.d.ts.map +1 -1
- package/lib/command/AcApQNewCmd.js +26 -0
- package/lib/command/AcApQNewCmd.js.map +1 -1
- package/lib/command/AcApSelectCmd.d.ts +26 -0
- package/lib/command/AcApSelectCmd.d.ts.map +1 -1
- package/lib/command/AcApSelectCmd.js +26 -0
- package/lib/command/AcApSelectCmd.js.map +1 -1
- package/lib/command/AcApSvgConvertor.d.ts +48 -0
- package/lib/command/AcApSvgConvertor.d.ts.map +1 -1
- package/lib/command/AcApSvgConvertor.js +48 -0
- package/lib/command/AcApSvgConvertor.js.map +1 -1
- package/lib/command/AcApZoomCmd.d.ts +29 -0
- package/lib/command/AcApZoomCmd.d.ts.map +1 -1
- package/lib/command/AcApZoomCmd.js +29 -0
- package/lib/command/AcApZoomCmd.js.map +1 -1
- package/lib/command/AcApZoomToBoxCmd.d.ts +57 -0
- package/lib/command/AcApZoomToBoxCmd.d.ts.map +1 -1
- package/lib/command/AcApZoomToBoxCmd.js +57 -0
- package/lib/command/AcApZoomToBoxCmd.js.map +1 -1
- package/lib/editor/command/AcEdCommand.d.ts +118 -9
- package/lib/editor/command/AcEdCommand.d.ts.map +1 -1
- package/lib/editor/command/AcEdCommand.js +113 -9
- package/lib/editor/command/AcEdCommand.js.map +1 -1
- package/lib/editor/command/AcEdCommandStack.d.ts +59 -5
- package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -1
- package/lib/editor/command/AcEdCommandStack.js +48 -5
- package/lib/editor/command/AcEdCommandStack.js.map +1 -1
- package/lib/editor/global/eventBus.d.ts +69 -1
- package/lib/editor/global/eventBus.d.ts.map +1 -1
- package/lib/editor/global/eventBus.js +37 -0
- package/lib/editor/global/eventBus.js.map +1 -1
- package/lib/editor/input/AcEdBaseInput.d.ts +65 -1
- package/lib/editor/input/AcEdBaseInput.d.ts.map +1 -1
- package/lib/editor/input/AcEdBaseInput.js +62 -1
- package/lib/editor/input/AcEdBaseInput.js.map +1 -1
- package/lib/editor/input/AcEdBoxSelector.d.ts +81 -0
- package/lib/editor/input/AcEdBoxSelector.d.ts.map +1 -1
- package/lib/editor/input/AcEdBoxSelector.js +80 -0
- package/lib/editor/input/AcEdBoxSelector.js.map +1 -1
- package/lib/editor/input/AcEdCursorManager.d.ts +95 -8
- package/lib/editor/input/AcEdCursorManager.d.ts.map +1 -1
- package/lib/editor/input/AcEdCursorManager.js +95 -11
- package/lib/editor/input/AcEdCursorManager.js.map +1 -1
- package/lib/editor/input/AcEdInputPoint.d.ts +38 -1
- package/lib/editor/input/AcEdInputPoint.d.ts.map +1 -1
- package/lib/editor/input/AcEdInputPoint.js +38 -1
- package/lib/editor/input/AcEdInputPoint.js.map +1 -1
- package/lib/editor/input/AcEdJig.d.ts +166 -0
- package/lib/editor/input/AcEdJig.d.ts.map +1 -1
- package/lib/editor/input/AcEdJig.js +164 -0
- package/lib/editor/input/AcEdJig.js.map +1 -1
- package/lib/editor/input/AcEdJigLoop.d.ts +49 -0
- package/lib/editor/input/AcEdJigLoop.d.ts.map +1 -1
- package/lib/editor/input/AcEdJigLoop.js +48 -0
- package/lib/editor/input/AcEdJigLoop.js.map +1 -1
- package/lib/editor/input/AcEdSelectionSet.d.ts +122 -2
- package/lib/editor/input/AcEdSelectionSet.d.ts.map +1 -1
- package/lib/editor/input/AcEdSelectionSet.js +117 -1
- package/lib/editor/input/AcEdSelectionSet.js.map +1 -1
- package/lib/editor/input/AcEditor.d.ts +90 -6
- package/lib/editor/input/AcEditor.d.ts.map +1 -1
- package/lib/editor/input/AcEditor.js +86 -6
- package/lib/editor/input/AcEditor.js.map +1 -1
- package/lib/editor/view/AcEdBaseView.d.ts +163 -16
- package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
- package/lib/editor/view/AcEdBaseView.js +94 -5
- package/lib/editor/view/AcEdBaseView.js.map +1 -1
- package/lib/util/AcTrGeometryUtil.d.ts +65 -0
- package/lib/util/AcTrGeometryUtil.d.ts.map +1 -1
- package/lib/util/AcTrGeometryUtil.js +65 -0
- package/lib/util/AcTrGeometryUtil.js.map +1 -1
- package/lib/view/AcTrLayer.d.ts +40 -5
- package/lib/view/AcTrLayer.d.ts.map +1 -1
- package/lib/view/AcTrLayer.js +34 -5
- package/lib/view/AcTrLayer.js.map +1 -1
- package/lib/view/AcTrLayout.d.ts +122 -23
- package/lib/view/AcTrLayout.d.ts.map +1 -1
- package/lib/view/AcTrLayout.js +103 -23
- package/lib/view/AcTrLayout.js.map +1 -1
- package/lib/view/AcTrLayoutView.d.ts +74 -16
- package/lib/view/AcTrLayoutView.d.ts.map +1 -1
- package/lib/view/AcTrLayoutView.js +65 -16
- package/lib/view/AcTrLayoutView.js.map +1 -1
- package/lib/view/AcTrLayoutViewManager.d.ts +58 -12
- package/lib/view/AcTrLayoutViewManager.d.ts.map +1 -1
- package/lib/view/AcTrLayoutViewManager.js +56 -12
- package/lib/view/AcTrLayoutViewManager.js.map +1 -1
- package/lib/view/AcTrScene.d.ts +48 -4
- package/lib/view/AcTrScene.d.ts.map +1 -1
- package/lib/view/AcTrScene.js +44 -4
- package/lib/view/AcTrScene.js.map +1 -1
- package/lib/view/AcTrView2d.d.ts +71 -0
- package/lib/view/AcTrView2d.d.ts.map +1 -1
- package/lib/view/AcTrView2d.js +65 -0
- package/lib/view/AcTrView2d.js.map +1 -1
- package/package.json +8 -4
|
@@ -2,23 +2,87 @@ import { AcEdBaseView } from '../view/AcEdBaseView';
|
|
|
2
2
|
/**
|
|
3
3
|
* The base class for all of classes to get user inputs such as string, angle, number, point, selection,
|
|
4
4
|
* and so on.
|
|
5
|
+
*
|
|
6
|
+
* This abstract class provides a common framework for handling user input operations in the CAD editor.
|
|
7
|
+
* It manages the input lifecycle including activation, deactivation, and promise-based resolution.
|
|
8
|
+
* Subclasses must implement specific input behaviors while this base class handles common functionality
|
|
9
|
+
* like keyboard event handling and promise management.
|
|
10
|
+
*
|
|
11
|
+
* @template TResult - The type of result that this input operation will return
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* class MyInput extends AcEdBaseInput<string> {
|
|
16
|
+
* // Implement specific input behavior
|
|
17
|
+
* }
|
|
18
|
+
* const input = new MyInput(view);
|
|
19
|
+
* const result = await input.start();
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
5
22
|
* @internal
|
|
6
23
|
*/
|
|
7
24
|
export declare abstract class AcEdBaseInput<TResult> {
|
|
25
|
+
/** The view associated with this input operation */
|
|
8
26
|
protected view: AcEdBaseView;
|
|
27
|
+
/** Whether this input is currently active */
|
|
9
28
|
protected active: boolean;
|
|
29
|
+
/** Flag to prevent multiple resolutions of the same promise */
|
|
10
30
|
protected isResolvedOrRejected: boolean;
|
|
31
|
+
/** Promise resolve function for completing the input operation */
|
|
11
32
|
private _resolve?;
|
|
33
|
+
/** Promise reject function for canceling the input operation */
|
|
12
34
|
private _reject?;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new base input instance.
|
|
37
|
+
*
|
|
38
|
+
* @param view - The view that will handle this input operation
|
|
39
|
+
*/
|
|
13
40
|
constructor(view: AcEdBaseView);
|
|
41
|
+
/**
|
|
42
|
+
* Gets whether this input is currently active.
|
|
43
|
+
*
|
|
44
|
+
* @returns True if the input is active, false otherwise
|
|
45
|
+
*/
|
|
14
46
|
get isActive(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Activates this input operation.
|
|
49
|
+
* Sets up event listeners and marks the input as active.
|
|
50
|
+
* Subclasses should call super.activate() when overriding.
|
|
51
|
+
*/
|
|
15
52
|
activate(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Deactivates this input operation.
|
|
55
|
+
* Removes event listeners and marks the input as inactive.
|
|
56
|
+
* Subclasses should call super.deactivate() when overriding.
|
|
57
|
+
*/
|
|
16
58
|
deactivate(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Resolves the input operation with the specified result.
|
|
61
|
+
* Automatically deactivates the input and prevents multiple resolutions.
|
|
62
|
+
*
|
|
63
|
+
* @param result - The result to resolve the promise with
|
|
64
|
+
*/
|
|
17
65
|
resolve(result: TResult): void;
|
|
66
|
+
/**
|
|
67
|
+
* Rejects the input operation with the specified reason.
|
|
68
|
+
* Automatically deactivates the input and prevents multiple rejections.
|
|
69
|
+
*
|
|
70
|
+
* @param reason - The reason for rejecting the input operation
|
|
71
|
+
*/
|
|
18
72
|
reject(reason: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Handles keyboard events for the input operation.
|
|
75
|
+
* By default, cancels the operation when Escape is pressed.
|
|
76
|
+
*
|
|
77
|
+
* @param e - The keyboard event
|
|
78
|
+
*/
|
|
19
79
|
private onKeyDown;
|
|
20
80
|
/**
|
|
21
|
-
*
|
|
81
|
+
* Starts the input operation and returns a promise that resolves with the result.
|
|
82
|
+
* This method activates the input and returns a promise that will be resolved
|
|
83
|
+
* when the user completes the input operation.
|
|
84
|
+
*
|
|
85
|
+
* @returns A promise that resolves with the input result
|
|
22
86
|
*/
|
|
23
87
|
start(): Promise<TResult>;
|
|
24
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcEdBaseInput.d.ts","sourceRoot":"","sources":["../../../src/editor/input/AcEdBaseInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD
|
|
1
|
+
{"version":3,"file":"AcEdBaseInput.d.ts","sourceRoot":"","sources":["../../../src/editor/input/AcEdBaseInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,8BAAsB,aAAa,CAAC,OAAO;IACzC,oDAAoD;IACpD,SAAS,CAAC,IAAI,EAAE,YAAY,CAAA;IAC5B,6CAA6C;IAC7C,SAAS,CAAC,MAAM,UAAQ;IACxB,+DAA+D;IAC/D,SAAS,CAAC,oBAAoB,UAAQ;IAEtC,kEAAkE;IAClE,OAAO,CAAC,QAAQ,CAAC,CAA0B;IAC3C,gEAAgE;IAChE,OAAO,CAAC,OAAO,CAAC,CAA0B;IAE1C;;;;OAIG;gBACS,IAAI,EAAE,YAAY;IAI9B;;;;OAIG;IACH,IAAI,QAAQ,YAEX;IAED;;;;OAIG;IACH,QAAQ;IAQR;;;;OAIG;IACH,UAAU;IAKV;;;;;OAKG;IACH,OAAO,CAAC,MAAM,EAAE,OAAO;IAQvB;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM;IAQrB;;;;;OAKG;IACH,OAAO,CAAC,SAAS,CAIhB;IAED;;;;;;OAMG;IACG,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;CAQhC"}
|
|
@@ -37,13 +37,43 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
/**
|
|
38
38
|
* The base class for all of classes to get user inputs such as string, angle, number, point, selection,
|
|
39
39
|
* and so on.
|
|
40
|
+
*
|
|
41
|
+
* This abstract class provides a common framework for handling user input operations in the CAD editor.
|
|
42
|
+
* It manages the input lifecycle including activation, deactivation, and promise-based resolution.
|
|
43
|
+
* Subclasses must implement specific input behaviors while this base class handles common functionality
|
|
44
|
+
* like keyboard event handling and promise management.
|
|
45
|
+
*
|
|
46
|
+
* @template TResult - The type of result that this input operation will return
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* class MyInput extends AcEdBaseInput<string> {
|
|
51
|
+
* // Implement specific input behavior
|
|
52
|
+
* }
|
|
53
|
+
* const input = new MyInput(view);
|
|
54
|
+
* const result = await input.start();
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
40
57
|
* @internal
|
|
41
58
|
*/
|
|
42
59
|
var AcEdBaseInput = /** @class */ (function () {
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new base input instance.
|
|
62
|
+
*
|
|
63
|
+
* @param view - The view that will handle this input operation
|
|
64
|
+
*/
|
|
43
65
|
function AcEdBaseInput(view) {
|
|
44
66
|
var _this = this;
|
|
67
|
+
/** Whether this input is currently active */
|
|
45
68
|
this.active = false;
|
|
69
|
+
/** Flag to prevent multiple resolutions of the same promise */
|
|
46
70
|
this.isResolvedOrRejected = false;
|
|
71
|
+
/**
|
|
72
|
+
* Handles keyboard events for the input operation.
|
|
73
|
+
* By default, cancels the operation when Escape is pressed.
|
|
74
|
+
*
|
|
75
|
+
* @param e - The keyboard event
|
|
76
|
+
*/
|
|
47
77
|
this.onKeyDown = function (e) {
|
|
48
78
|
if (e.code === 'Escape') {
|
|
49
79
|
_this.reject('Canceled by user!');
|
|
@@ -52,12 +82,22 @@ var AcEdBaseInput = /** @class */ (function () {
|
|
|
52
82
|
this.view = view;
|
|
53
83
|
}
|
|
54
84
|
Object.defineProperty(AcEdBaseInput.prototype, "isActive", {
|
|
85
|
+
/**
|
|
86
|
+
* Gets whether this input is currently active.
|
|
87
|
+
*
|
|
88
|
+
* @returns True if the input is active, false otherwise
|
|
89
|
+
*/
|
|
55
90
|
get: function () {
|
|
56
91
|
return this.active;
|
|
57
92
|
},
|
|
58
93
|
enumerable: false,
|
|
59
94
|
configurable: true
|
|
60
95
|
});
|
|
96
|
+
/**
|
|
97
|
+
* Activates this input operation.
|
|
98
|
+
* Sets up event listeners and marks the input as active.
|
|
99
|
+
* Subclasses should call super.activate() when overriding.
|
|
100
|
+
*/
|
|
61
101
|
AcEdBaseInput.prototype.activate = function () {
|
|
62
102
|
if (this.isActive) {
|
|
63
103
|
console.warn('Something wrong here!');
|
|
@@ -65,10 +105,21 @@ var AcEdBaseInput = /** @class */ (function () {
|
|
|
65
105
|
this.active = true;
|
|
66
106
|
this.view.canvas.addEventListener('keydown', this.onKeyDown);
|
|
67
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Deactivates this input operation.
|
|
110
|
+
* Removes event listeners and marks the input as inactive.
|
|
111
|
+
* Subclasses should call super.deactivate() when overriding.
|
|
112
|
+
*/
|
|
68
113
|
AcEdBaseInput.prototype.deactivate = function () {
|
|
69
114
|
this.active = false;
|
|
70
115
|
this.view.canvas.removeEventListener('keydown', this.onKeyDown);
|
|
71
116
|
};
|
|
117
|
+
/**
|
|
118
|
+
* Resolves the input operation with the specified result.
|
|
119
|
+
* Automatically deactivates the input and prevents multiple resolutions.
|
|
120
|
+
*
|
|
121
|
+
* @param result - The result to resolve the promise with
|
|
122
|
+
*/
|
|
72
123
|
AcEdBaseInput.prototype.resolve = function (result) {
|
|
73
124
|
this.deactivate();
|
|
74
125
|
if (this._resolve && !this.isResolvedOrRejected) {
|
|
@@ -76,6 +127,12 @@ var AcEdBaseInput = /** @class */ (function () {
|
|
|
76
127
|
this.isResolvedOrRejected = true;
|
|
77
128
|
}
|
|
78
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* Rejects the input operation with the specified reason.
|
|
132
|
+
* Automatically deactivates the input and prevents multiple rejections.
|
|
133
|
+
*
|
|
134
|
+
* @param reason - The reason for rejecting the input operation
|
|
135
|
+
*/
|
|
79
136
|
AcEdBaseInput.prototype.reject = function (reason) {
|
|
80
137
|
this.deactivate();
|
|
81
138
|
if (this._reject && !this.isResolvedOrRejected) {
|
|
@@ -84,7 +141,11 @@ var AcEdBaseInput = /** @class */ (function () {
|
|
|
84
141
|
}
|
|
85
142
|
};
|
|
86
143
|
/**
|
|
87
|
-
*
|
|
144
|
+
* Starts the input operation and returns a promise that resolves with the result.
|
|
145
|
+
* This method activates the input and returns a promise that will be resolved
|
|
146
|
+
* when the user completes the input operation.
|
|
147
|
+
*
|
|
148
|
+
* @returns A promise that resolves with the input result
|
|
88
149
|
*/
|
|
89
150
|
AcEdBaseInput.prototype.start = function () {
|
|
90
151
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcEdBaseInput.js","sourceRoot":"","sources":["../../../src/editor/input/AcEdBaseInput.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA
|
|
1
|
+
{"version":3,"file":"AcEdBaseInput.js","sourceRoot":"","sources":["../../../src/editor/input/AcEdBaseInput.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IAaE;;;;OAIG;IACH,uBAAY,IAAkB;QAA9B,iBAEC;QAjBD,6CAA6C;QACnC,WAAM,GAAG,KAAK,CAAA;QACxB,+DAA+D;QACrD,yBAAoB,GAAG,KAAK,CAAA;QA4EtC;;;;;WAKG;QACK,cAAS,GAAG,UAAC,CAAgB;YACnC,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACxB,KAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAA;YAClC,CAAC;QACH,CAAC,CAAA;QAzEC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAOD,sBAAI,mCAAQ;QALZ;;;;WAIG;aACH;YACE,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;;;OAAA;IAED;;;;OAIG;IACH,gCAAQ,GAAR;QACE,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;QACvC,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAClB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IAC9D,CAAC;IAED;;;;OAIG;IACH,kCAAU,GAAV;QACE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IACjE,CAAC;IAED;;;;;OAKG;IACH,+BAAO,GAAP,UAAQ,MAAe;QACrB,IAAI,CAAC,UAAU,EAAE,CAAA;QACjB,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAChD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;YACrB,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAA;QAClC,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,8BAAM,GAAN,UAAO,MAAc;QACnB,IAAI,CAAC,UAAU,EAAE,CAAA;QACjB,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC/C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACpB,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAA;QAClC,CAAC;IACH,CAAC;IAcD;;;;;;OAMG;IACG,6BAAK,GAAX;;;;gBACE,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAA;gBACjC,sBAAO,IAAI,OAAO,CAAU,UAAC,OAAO,EAAE,MAAM;wBAC1C,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;wBACvB,KAAI,CAAC,OAAO,GAAG,MAAM,CAAA;wBACrB,KAAI,CAAC,QAAQ,EAAE,CAAA;oBACjB,CAAC,CAAC,EAAA;;;KACH;IACH,oBAAC;AAAD,CAAC,AA7GD,IA6GC"}
|
|
@@ -3,25 +3,106 @@ import { AcEdBaseView } from '../view';
|
|
|
3
3
|
import { AcEdBaseInput } from './AcEdBaseInput';
|
|
4
4
|
/**
|
|
5
5
|
* Selector used to select entities by a box.
|
|
6
|
+
*
|
|
7
|
+
* This class provides interactive box selection functionality for the CAD editor.
|
|
8
|
+
* Users can click and drag to create a selection rectangle, which is then converted
|
|
9
|
+
* to world coordinates for entity selection operations.
|
|
10
|
+
*
|
|
11
|
+
* The selector handles mouse events to track the selection area and provides visual
|
|
12
|
+
* feedback through a DOM overlay showing the selection bounds.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const boxSelector = new AcEdBoxSelector(view);
|
|
17
|
+
* const selectionBox = await boxSelector.start();
|
|
18
|
+
* // Use selectionBox to select entities
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
6
21
|
* @internal
|
|
7
22
|
*/
|
|
8
23
|
export declare class AcEdBoxSelector extends AcEdBaseInput<AcGeBox2d> {
|
|
24
|
+
/** Whether the mouse button is currently pressed */
|
|
9
25
|
private mouseDown;
|
|
26
|
+
/** Whether the mouse has moved since being pressed */
|
|
10
27
|
private mouseMove;
|
|
28
|
+
/** X coordinate where mouse was initially pressed (-1 indicates invalid) */
|
|
11
29
|
private mouseDownPositionX;
|
|
30
|
+
/** Y coordinate where mouse was initially pressed (-1 indicates invalid) */
|
|
12
31
|
private mouseDownPositionY;
|
|
32
|
+
/** DOM element used to draw the selection box */
|
|
13
33
|
private boxDom?;
|
|
34
|
+
/** Selection box border color */
|
|
14
35
|
color: number;
|
|
36
|
+
/** The container element for the selection box */
|
|
15
37
|
private container;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new box selector instance.
|
|
40
|
+
*
|
|
41
|
+
* @param view - The view that will handle this box selection operation
|
|
42
|
+
*/
|
|
16
43
|
constructor(view: AcEdBaseView);
|
|
44
|
+
/**
|
|
45
|
+
* Activates the box selector.
|
|
46
|
+
* Sets up mouse event listeners for tracking selection area.
|
|
47
|
+
* Overrides the base class to add mouse event handling.
|
|
48
|
+
*/
|
|
17
49
|
activate(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Deactivates the box selector.
|
|
52
|
+
* Removes mouse event listeners and hides the selection box.
|
|
53
|
+
* Overrides the base class to clean up mouse event handling.
|
|
54
|
+
*/
|
|
18
55
|
deactivate(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Rejects the box selection operation.
|
|
58
|
+
* Cleans up the selection box DOM element.
|
|
59
|
+
*
|
|
60
|
+
* @param reason - The reason for rejecting the selection operation
|
|
61
|
+
*/
|
|
19
62
|
reject(reason: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* Handles mouse down events to start box selection.
|
|
65
|
+
* Records the initial mouse position for the selection area.
|
|
66
|
+
*
|
|
67
|
+
* @param e - The mouse event
|
|
68
|
+
*/
|
|
20
69
|
private mousedown;
|
|
70
|
+
/**
|
|
71
|
+
* Handles mouse move events to update the selection box.
|
|
72
|
+
* Creates and updates the visual selection rectangle as the user drags.
|
|
73
|
+
*
|
|
74
|
+
* @param e - The mouse event
|
|
75
|
+
*/
|
|
21
76
|
private mousemove;
|
|
77
|
+
/**
|
|
78
|
+
* Handles mouse up events to complete box selection.
|
|
79
|
+
* Calculates the final selection area and resolves the promise with the result.
|
|
80
|
+
*
|
|
81
|
+
* @param e - The mouse event
|
|
82
|
+
*/
|
|
22
83
|
private mouseup;
|
|
84
|
+
/**
|
|
85
|
+
* Draws the selection rectangle on screen.
|
|
86
|
+
* Creates or updates the DOM element representing the selection box.
|
|
87
|
+
*
|
|
88
|
+
* @param leftTop - The top-left corner of the selection rectangle
|
|
89
|
+
* @param rightBottom - The bottom-right corner of the selection rectangle
|
|
90
|
+
*/
|
|
23
91
|
private drawRect;
|
|
92
|
+
/**
|
|
93
|
+
* Sets the visibility of the selection rectangle DOM element.
|
|
94
|
+
*
|
|
95
|
+
* @param visible - Whether the selection rectangle should be visible
|
|
96
|
+
*/
|
|
24
97
|
private setRectDomVisible;
|
|
98
|
+
/**
|
|
99
|
+
* Converts a screen coordinate box to world coordinate system.
|
|
100
|
+
* Transforms the selection box from screen coordinates to world coordinates
|
|
101
|
+
* for use in entity selection operations.
|
|
102
|
+
*
|
|
103
|
+
* @param box - The selection box in screen coordinates
|
|
104
|
+
* @returns The selection box in world coordinates
|
|
105
|
+
*/
|
|
25
106
|
private toWcs;
|
|
26
107
|
}
|
|
27
108
|
//# sourceMappingURL=AcEdBoxSelector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcEdBoxSelector.d.ts","sourceRoot":"","sources":["../../../src/editor/input/AcEdBoxSelector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAe,MAAM,uBAAuB,CAAA;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"AcEdBoxSelector.d.ts","sourceRoot":"","sources":["../../../src/editor/input/AcEdBoxSelector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAe,MAAM,uBAAuB,CAAA;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAO/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,eAAgB,SAAQ,aAAa,CAAC,SAAS,CAAC;IAC3D,oDAAoD;IACpD,OAAO,CAAC,SAAS,CAAQ;IACzB,sDAAsD;IACtD,OAAO,CAAC,SAAS,CAAQ;IACzB,4EAA4E;IAC5E,OAAO,CAAC,kBAAkB,CAAK;IAC/B,4EAA4E;IAC5E,OAAO,CAAC,kBAAkB,CAAK;IAE/B,iDAAiD;IACjD,OAAO,CAAC,MAAM,CAAC,CAAgB;IAC/B,iCAAiC;IAC1B,KAAK,EAAE,MAAM,CAAA;IACpB,kDAAkD;IAClD,OAAO,CAAC,SAAS,CAAa;IAE9B;;;;OAIG;gBACS,IAAI,EAAE,YAAY;IAM9B;;;;OAIG;IACH,QAAQ;IAQR;;;;OAIG;IACH,UAAU;IAQV;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM;IAMrB;;;;;OAKG;IACH,OAAO,CAAC,SAAS,CAOhB;IAED;;;;;OAKG;IACH,OAAO,CAAC,SAAS,CAuBhB;IAED;;;;;OAKG;IACH,OAAO,CAAC,OAAO,CAmBd;IAED;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IAiChB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAMzB;;;;;;;OAOG;IACH,OAAO,CAAC,KAAK;CAQd"}
|
|
@@ -15,20 +15,52 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
})();
|
|
16
16
|
import { AcCmColor, AcGeBox2d, AcGePoint2d } from '@mlightcad/data-model';
|
|
17
17
|
import { AcEdBaseInput } from './AcEdBaseInput';
|
|
18
|
+
/** Default border color for the selection box */
|
|
18
19
|
var BORDER_COLOR = 0xffffff;
|
|
20
|
+
/** Default border width for the selection box */
|
|
19
21
|
var BORDER_WIDTH = '1px';
|
|
20
22
|
/**
|
|
21
23
|
* Selector used to select entities by a box.
|
|
24
|
+
*
|
|
25
|
+
* This class provides interactive box selection functionality for the CAD editor.
|
|
26
|
+
* Users can click and drag to create a selection rectangle, which is then converted
|
|
27
|
+
* to world coordinates for entity selection operations.
|
|
28
|
+
*
|
|
29
|
+
* The selector handles mouse events to track the selection area and provides visual
|
|
30
|
+
* feedback through a DOM overlay showing the selection bounds.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const boxSelector = new AcEdBoxSelector(view);
|
|
35
|
+
* const selectionBox = await boxSelector.start();
|
|
36
|
+
* // Use selectionBox to select entities
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
22
39
|
* @internal
|
|
23
40
|
*/
|
|
24
41
|
var AcEdBoxSelector = /** @class */ (function (_super) {
|
|
25
42
|
__extends(AcEdBoxSelector, _super);
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new box selector instance.
|
|
45
|
+
*
|
|
46
|
+
* @param view - The view that will handle this box selection operation
|
|
47
|
+
*/
|
|
26
48
|
function AcEdBoxSelector(view) {
|
|
27
49
|
var _this = _super.call(this, view) || this;
|
|
50
|
+
/** Whether the mouse button is currently pressed */
|
|
28
51
|
_this.mouseDown = false;
|
|
52
|
+
/** Whether the mouse has moved since being pressed */
|
|
29
53
|
_this.mouseMove = false;
|
|
54
|
+
/** X coordinate where mouse was initially pressed (-1 indicates invalid) */
|
|
30
55
|
_this.mouseDownPositionX = -1; // -1 means invalid point
|
|
56
|
+
/** Y coordinate where mouse was initially pressed (-1 indicates invalid) */
|
|
31
57
|
_this.mouseDownPositionY = -1;
|
|
58
|
+
/**
|
|
59
|
+
* Handles mouse down events to start box selection.
|
|
60
|
+
* Records the initial mouse position for the selection area.
|
|
61
|
+
*
|
|
62
|
+
* @param e - The mouse event
|
|
63
|
+
*/
|
|
32
64
|
_this.mousedown = function (e) {
|
|
33
65
|
if (e.button === 0) {
|
|
34
66
|
_this.mouseDown = true;
|
|
@@ -37,6 +69,12 @@ var AcEdBoxSelector = /** @class */ (function (_super) {
|
|
|
37
69
|
_this.mouseDownPositionY = point.y;
|
|
38
70
|
}
|
|
39
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Handles mouse move events to update the selection box.
|
|
74
|
+
* Creates and updates the visual selection rectangle as the user drags.
|
|
75
|
+
*
|
|
76
|
+
* @param e - The mouse event
|
|
77
|
+
*/
|
|
40
78
|
_this.mousemove = function (e) {
|
|
41
79
|
if (!_this.mouseDown) {
|
|
42
80
|
return;
|
|
@@ -53,6 +91,12 @@ var AcEdBoxSelector = /** @class */ (function (_super) {
|
|
|
53
91
|
}
|
|
54
92
|
}
|
|
55
93
|
};
|
|
94
|
+
/**
|
|
95
|
+
* Handles mouse up events to complete box selection.
|
|
96
|
+
* Calculates the final selection area and resolves the promise with the result.
|
|
97
|
+
*
|
|
98
|
+
* @param e - The mouse event
|
|
99
|
+
*/
|
|
56
100
|
_this.mouseup = function (e) {
|
|
57
101
|
if (_this.mouseDown && _this.mouseMove) {
|
|
58
102
|
var point = new AcGePoint2d(e.x, e.y);
|
|
@@ -71,6 +115,11 @@ var AcEdBoxSelector = /** @class */ (function (_super) {
|
|
|
71
115
|
_this.color = BORDER_COLOR;
|
|
72
116
|
return _this;
|
|
73
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Activates the box selector.
|
|
120
|
+
* Sets up mouse event listeners for tracking selection area.
|
|
121
|
+
* Overrides the base class to add mouse event handling.
|
|
122
|
+
*/
|
|
74
123
|
AcEdBoxSelector.prototype.activate = function () {
|
|
75
124
|
_super.prototype.activate.call(this);
|
|
76
125
|
this.active = true;
|
|
@@ -78,6 +127,11 @@ var AcEdBoxSelector = /** @class */ (function (_super) {
|
|
|
78
127
|
this.container.addEventListener('pointermove', this.mousemove);
|
|
79
128
|
this.container.addEventListener('pointerup', this.mouseup);
|
|
80
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* Deactivates the box selector.
|
|
132
|
+
* Removes mouse event listeners and hides the selection box.
|
|
133
|
+
* Overrides the base class to clean up mouse event handling.
|
|
134
|
+
*/
|
|
81
135
|
AcEdBoxSelector.prototype.deactivate = function () {
|
|
82
136
|
_super.prototype.deactivate.call(this);
|
|
83
137
|
this.container.removeEventListener('pointerdown', this.mousedown);
|
|
@@ -85,12 +139,25 @@ var AcEdBoxSelector = /** @class */ (function (_super) {
|
|
|
85
139
|
this.container.removeEventListener('pointerup', this.mouseup);
|
|
86
140
|
this.setRectDomVisible(false);
|
|
87
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* Rejects the box selection operation.
|
|
144
|
+
* Cleans up the selection box DOM element.
|
|
145
|
+
*
|
|
146
|
+
* @param reason - The reason for rejecting the selection operation
|
|
147
|
+
*/
|
|
88
148
|
AcEdBoxSelector.prototype.reject = function (reason) {
|
|
89
149
|
var _a;
|
|
90
150
|
_super.prototype.reject.call(this, reason);
|
|
91
151
|
(_a = this.boxDom) === null || _a === void 0 ? void 0 : _a.remove();
|
|
92
152
|
this.boxDom = undefined;
|
|
93
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* Draws the selection rectangle on screen.
|
|
156
|
+
* Creates or updates the DOM element representing the selection box.
|
|
157
|
+
*
|
|
158
|
+
* @param leftTop - The top-left corner of the selection rectangle
|
|
159
|
+
* @param rightBottom - The bottom-right corner of the selection rectangle
|
|
160
|
+
*/
|
|
94
161
|
AcEdBoxSelector.prototype.drawRect = function (leftTop, rightBottom) {
|
|
95
162
|
if (!this.boxDom) {
|
|
96
163
|
var color = new AcCmColor();
|
|
@@ -121,11 +188,24 @@ var AcEdBoxSelector = /** @class */ (function (_super) {
|
|
|
121
188
|
this.boxDom.style.width = "".concat(width, "px");
|
|
122
189
|
this.boxDom.style.height = "".concat(height, "px");
|
|
123
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* Sets the visibility of the selection rectangle DOM element.
|
|
193
|
+
*
|
|
194
|
+
* @param visible - Whether the selection rectangle should be visible
|
|
195
|
+
*/
|
|
124
196
|
AcEdBoxSelector.prototype.setRectDomVisible = function (visible) {
|
|
125
197
|
if (this.boxDom) {
|
|
126
198
|
this.boxDom.style.display = visible ? 'inline-block' : 'none';
|
|
127
199
|
}
|
|
128
200
|
};
|
|
201
|
+
/**
|
|
202
|
+
* Converts a screen coordinate box to world coordinate system.
|
|
203
|
+
* Transforms the selection box from screen coordinates to world coordinates
|
|
204
|
+
* for use in entity selection operations.
|
|
205
|
+
*
|
|
206
|
+
* @param box - The selection box in screen coordinates
|
|
207
|
+
* @returns The selection box in world coordinates
|
|
208
|
+
*/
|
|
129
209
|
AcEdBoxSelector.prototype.toWcs = function (box) {
|
|
130
210
|
var wcsBox = new AcGeBox2d();
|
|
131
211
|
var p1 = new AcGePoint2d(box.min.x, box.min.y);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcEdBoxSelector.js","sourceRoot":"","sources":["../../../src/editor/input/AcEdBoxSelector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGzE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,IAAM,YAAY,GAAG,QAAQ,CAAA;AAC7B,IAAM,YAAY,GAAG,KAAK,CAAA;AAE1B
|
|
1
|
+
{"version":3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cAAc,CAAC,CAAC,CAAC,MAAM,CAAA;QAC/D,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACK,+BAAK,GAAb,UAAc,GAAc;QAC1B,IAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAA;QAC9B,IAAM,EAAE,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QAChD,IAAM,EAAE,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QAChD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAA;QAC5C,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAA;QAC5C,OAAO,MAAM,CAAA;IACf,CAAC;IACH,sBAAC;AAAD,CAAC,AA9MD,CAAqC,aAAa,GA8MjD"}
|
|
@@ -1,36 +1,123 @@
|
|
|
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 declare enum AcEdCorsorType {
|
|
21
|
+
/** No special cursor - uses browser default */
|
|
2
22
|
NoSpecialCursor = -1,
|
|
23
|
+
/** Crosshair cursor for precise point selection */
|
|
3
24
|
Crosshair = 0,
|
|
25
|
+
/** Rectangle cursor for area selection */
|
|
4
26
|
RectCursor = 1,
|
|
27
|
+
/** Rubber band cursor for dynamic drawing */
|
|
5
28
|
RubberBand = 2,
|
|
29
|
+
/** Non-rotated cursor */
|
|
6
30
|
NotRotated = 3,
|
|
31
|
+
/** Target box cursor for object snapping */
|
|
7
32
|
TargetBox = 4,
|
|
33
|
+
/** Rotated crosshair cursor */
|
|
8
34
|
RotatedCrosshair = 5,
|
|
35
|
+
/** Crosshair that doesn't rotate with view */
|
|
9
36
|
CrosshairNoRotate = 6,
|
|
37
|
+
/** Invisible cursor for hiding cursor */
|
|
10
38
|
Invisible = 7,
|
|
39
|
+
/** Entity selection cursor */
|
|
11
40
|
EntitySelect = 8,
|
|
41
|
+
/** Parallelogram cursor for skewed operations */
|
|
12
42
|
Parallelogram = 9,
|
|
43
|
+
/** Entity select cursor without perspective */
|
|
13
44
|
EntitySelectNoPersp = 10,
|
|
45
|
+
/** Cursor for pick-first or grips operations */
|
|
14
46
|
PkfirstOrGrips = 11,
|
|
47
|
+
/** Dashed crosshair cursor */
|
|
15
48
|
CrosshairDashed = 12,
|
|
49
|
+
/** Grab/hand cursor for panning */
|
|
16
50
|
Grab = 13
|
|
17
51
|
}
|
|
18
52
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
53
|
+
* Manages cursor appearance and behavior for the CAD editor.
|
|
54
|
+
*
|
|
55
|
+
* This class creates and applies custom cursors to HTML elements,
|
|
56
|
+
* providing visual feedback for different CAD operations. It supports
|
|
57
|
+
* both built-in browser cursors and custom SVG-based cursors.
|
|
58
|
+
*
|
|
59
|
+
* The cursor manager maintains a cache of cursor definitions to avoid
|
|
60
|
+
* recreating them repeatedly, improving performance.
|
|
61
|
+
*
|
|
62
|
+
* @internal This class is for internal use by the editor system
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const cursorManager = new AcEdCursorManager();
|
|
67
|
+
* const canvas = document.getElementById('canvas') as HTMLCanvasElement;
|
|
68
|
+
*
|
|
69
|
+
* // Set crosshair cursor
|
|
70
|
+
* cursorManager.setCursor(AcEdCorsorType.Crosshair, canvas);
|
|
71
|
+
*
|
|
72
|
+
* // Set grab cursor for panning
|
|
73
|
+
* cursorManager.setCursor(AcEdCorsorType.Grab, canvas);
|
|
74
|
+
* ```
|
|
21
75
|
*/
|
|
22
76
|
export declare class AcEdCursorManager {
|
|
77
|
+
/** Cache of cursor definitions mapped by cursor type */
|
|
23
78
|
private _cursorMap;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a new cursor manager instance.
|
|
81
|
+
*
|
|
82
|
+
* Initializes the cursor cache and creates default cursor definitions.
|
|
83
|
+
*/
|
|
24
84
|
constructor();
|
|
85
|
+
/**
|
|
86
|
+
* Sets the cursor for the specified HTML element.
|
|
87
|
+
*
|
|
88
|
+
* Applies the appropriate cursor style based on the cursor type.
|
|
89
|
+
* For built-in cursor types, uses CSS cursor values. For custom
|
|
90
|
+
* cursor types, uses cached SVG-based cursor definitions.
|
|
91
|
+
*
|
|
92
|
+
* @param cursorType - The type of cursor to set
|
|
93
|
+
* @param element - The HTML element to apply the cursor to
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const canvas = document.getElementById('canvas') as HTMLCanvasElement;
|
|
98
|
+
* cursorManager.setCursor(AcEdCorsorType.Crosshair, canvas);
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
25
101
|
setCursor(cursorType: AcEdCorsorType, element: HTMLElement): void;
|
|
26
102
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
103
|
+
* Encodes an SVG string into a CSS cursor URL.
|
|
104
|
+
*
|
|
105
|
+
* This method converts SVG markup into a data URI that can be used
|
|
106
|
+
* as a CSS cursor value, with specified hotspot coordinates.
|
|
107
|
+
*
|
|
108
|
+
* @param svgString - The SVG markup as a string
|
|
109
|
+
* @param xOffset - X coordinate of the cursor hotspot
|
|
110
|
+
* @param yOffset - Y coordinate of the cursor hotspot
|
|
111
|
+
* @returns CSS cursor string in url() format
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const svgCursor = '<svg width="20" height="20">...</svg>';
|
|
116
|
+
* const cursorUrl = cursorManager.encodeSvgToCursor(svgCursor, 10, 10);
|
|
117
|
+
* element.style.cursor = cursorUrl;
|
|
118
|
+
* ```
|
|
32
119
|
*/
|
|
33
|
-
|
|
120
|
+
encodeSvgToCursor(svgString: string, xOffset: number, yOffset: number): string;
|
|
34
121
|
/**
|
|
35
122
|
* Create one svg icon with one rectangle plus two cross lines
|
|
36
123
|
* @param rectSize Input the width and height of rectangle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcEdCursorManager.d.ts","sourceRoot":"","sources":["../../../src/editor/input/AcEdCursorManager.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,eAAe,KAAK;IACpB,SAAS,IAAI;IACb,UAAU,IAAA;IACV,UAAU,IAAA;IACV,UAAU,IAAA;IACV,SAAS,IAAA;IACT,gBAAgB,IAAA;IAChB,iBAAiB,IAAA;IACjB,SAAS,IAAA;IACT,YAAY,IAAA;IACZ,aAAa,IAAA;IACb,mBAAmB,KAAA;IACnB,cAAc,KAAA;IACd,eAAe,KAAA;IACf,IAAI,KAAA;CACL;AAED
|
|
1
|
+
{"version":3,"file":"AcEdCursorManager.d.ts","sourceRoot":"","sources":["../../../src/editor/input/AcEdCursorManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,oBAAY,cAAc;IACxB,+CAA+C;IAC/C,eAAe,KAAK;IACpB,mDAAmD;IACnD,SAAS,IAAI;IACb,0CAA0C;IAC1C,UAAU,IAAA;IACV,6CAA6C;IAC7C,UAAU,IAAA;IACV,yBAAyB;IACzB,UAAU,IAAA;IACV,4CAA4C;IAC5C,SAAS,IAAA;IACT,+BAA+B;IAC/B,gBAAgB,IAAA;IAChB,8CAA8C;IAC9C,iBAAiB,IAAA;IACjB,yCAAyC;IACzC,SAAS,IAAA;IACT,8BAA8B;IAC9B,YAAY,IAAA;IACZ,iDAAiD;IACjD,aAAa,IAAA;IACb,+CAA+C;IAC/C,mBAAmB,KAAA;IACnB,gDAAgD;IAChD,cAAc,KAAA;IACd,8BAA8B;IAC9B,eAAe,KAAA;IACf,mCAAmC;IACnC,IAAI,KAAA;CACL;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,iBAAiB;IAC5B,wDAAwD;IACxD,OAAO,CAAC,UAAU,CAA6B;IAE/C;;;;OAIG;;IASH;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW;IAa1D;;;;;;;;;;;;;;;;;OAiBG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAIrE;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;CAkB5B"}
|