@mlightcad/cad-simple-viewer 1.4.11 → 1.4.12
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/dist/index.js +10751 -8434
- package/dist/index.umd.cjs +78 -77
- package/dist/libredwg-parser-worker.js +6603 -12203
- package/lib/app/AcApAnnotation.d.ts.map +1 -1
- package/lib/app/AcApAnnotation.js +3 -3
- package/lib/app/AcApAnnotation.js.map +1 -1
- package/lib/app/AcApDocManager.d.ts +1 -0
- package/lib/app/AcApDocManager.d.ts.map +1 -1
- package/lib/app/AcApDocManager.js +7 -1
- package/lib/app/AcApDocManager.js.map +1 -1
- package/lib/app/AcApDocument.d.ts +6 -0
- package/lib/app/AcApDocument.d.ts.map +1 -1
- package/lib/app/AcApDocument.js +12 -0
- package/lib/app/AcApDocument.js.map +1 -1
- package/lib/app/AcApProgress.d.ts.map +1 -1
- package/lib/app/AcApProgress.js +3 -3
- package/lib/app/AcApProgress.js.map +1 -1
- package/lib/app/AcApSettingManager.d.ts.map +1 -1
- package/lib/app/AcApSettingManager.js +3 -1
- package/lib/app/AcApSettingManager.js.map +1 -1
- package/lib/app/AcDbOpenDatabaseOptions.d.ts.map +1 -1
- package/lib/command/AcApArcCmd.d.ts +140 -0
- package/lib/command/AcApArcCmd.d.ts.map +1 -0
- package/lib/command/AcApArcCmd.js +1009 -0
- package/lib/command/AcApArcCmd.js.map +1 -0
- package/lib/command/AcApCircleCmd.d.ts.map +1 -1
- package/lib/command/AcApCircleCmd.js +10 -4
- package/lib/command/AcApCircleCmd.js.map +1 -1
- package/lib/command/AcApClearMeasurementsCmd.d.ts +1 -1
- package/lib/command/AcApClearMeasurementsCmd.d.ts.map +1 -1
- package/lib/command/AcApClearMeasurementsCmd.js +2 -4
- package/lib/command/AcApClearMeasurementsCmd.js.map +1 -1
- package/lib/command/AcApConvertToDxfCmd.d.ts +9 -0
- package/lib/command/AcApConvertToDxfCmd.d.ts.map +1 -0
- package/lib/command/AcApConvertToDxfCmd.js +75 -0
- package/lib/command/AcApConvertToDxfCmd.js.map +1 -0
- package/lib/command/AcApDimLinearCmd.d.ts.map +1 -1
- package/lib/command/AcApDimLinearCmd.js +14 -5
- package/lib/command/AcApDimLinearCmd.js.map +1 -1
- package/lib/command/AcApDxfConvertor.d.ts +12 -0
- package/lib/command/AcApDxfConvertor.d.ts.map +1 -0
- package/lib/command/AcApDxfConvertor.js +37 -0
- package/lib/command/AcApDxfConvertor.js.map +1 -0
- package/lib/command/AcApEraseCmd.d.ts.map +1 -1
- package/lib/command/AcApEraseCmd.js +10 -6
- package/lib/command/AcApEraseCmd.js.map +1 -1
- package/lib/command/AcApLineCmd.d.ts.map +1 -1
- package/lib/command/AcApLineCmd.js +10 -4
- package/lib/command/AcApLineCmd.js.map +1 -1
- package/lib/command/AcApMTextCmd.d.ts.map +1 -1
- package/lib/command/AcApMTextCmd.js +6 -3
- package/lib/command/AcApMTextCmd.js.map +1 -1
- package/lib/command/AcApMeasureAngleCmd.d.ts.map +1 -1
- package/lib/command/AcApMeasureAngleCmd.js +134 -123
- package/lib/command/AcApMeasureAngleCmd.js.map +1 -1
- package/lib/command/AcApMeasureArcCmd.d.ts.map +1 -1
- package/lib/command/AcApMeasureArcCmd.js +165 -147
- package/lib/command/AcApMeasureArcCmd.js.map +1 -1
- package/lib/command/AcApMeasureAreaCmd.d.ts.map +1 -1
- package/lib/command/AcApMeasureAreaCmd.js +183 -175
- package/lib/command/AcApMeasureAreaCmd.js.map +1 -1
- package/lib/command/AcApMeasureDistanceCmd.d.ts.map +1 -1
- package/lib/command/AcApMeasureDistanceCmd.js +51 -39
- package/lib/command/AcApMeasureDistanceCmd.js.map +1 -1
- package/lib/command/AcApPolylineCmd.d.ts +71 -0
- package/lib/command/AcApPolylineCmd.d.ts.map +1 -0
- package/lib/command/AcApPolylineCmd.js +569 -0
- package/lib/command/AcApPolylineCmd.js.map +1 -0
- package/lib/command/AcApRectCmd.d.ts.map +1 -1
- package/lib/command/AcApRectCmd.js +10 -4
- package/lib/command/AcApRectCmd.js.map +1 -1
- package/lib/command/AcApRevCloudCmd.d.ts.map +1 -1
- package/lib/command/AcApRevCloudCmd.js +10 -4
- package/lib/command/AcApRevCloudCmd.js.map +1 -1
- package/lib/command/AcApSketchCmd.d.ts.map +1 -1
- package/lib/command/AcApSketchCmd.js +11 -7
- package/lib/command/AcApSketchCmd.js.map +1 -1
- package/lib/command/AcApSplineCmd.d.ts +20 -0
- package/lib/command/AcApSplineCmd.d.ts.map +1 -0
- package/lib/command/AcApSplineCmd.js +213 -0
- package/lib/command/AcApSplineCmd.js.map +1 -0
- package/lib/command/AcApSysVarCmd.d.ts.map +1 -1
- package/lib/command/AcApSysVarCmd.js +6 -3
- package/lib/command/AcApSysVarCmd.js.map +1 -1
- package/lib/command/AcApZoomToBoxCmd.d.ts.map +1 -1
- package/lib/command/AcApZoomToBoxCmd.js +6 -4
- package/lib/command/AcApZoomToBoxCmd.js.map +1 -1
- package/lib/command/index.d.ts +5 -0
- package/lib/command/index.d.ts.map +1 -1
- package/lib/command/index.js +5 -0
- package/lib/command/index.js.map +1 -1
- package/lib/editor/command/AcEdCommandIterator.d.ts.map +1 -1
- package/lib/editor/command/AcEdCommandIterator.js.map +1 -1
- package/lib/editor/global/AcEdUiTheme.d.ts +4 -0
- package/lib/editor/global/AcEdUiTheme.d.ts.map +1 -0
- package/lib/editor/global/AcEdUiTheme.js +44 -0
- package/lib/editor/global/AcEdUiTheme.js.map +1 -0
- package/lib/editor/global/index.d.ts +1 -0
- package/lib/editor/global/index.d.ts.map +1 -1
- package/lib/editor/global/index.js +1 -0
- package/lib/editor/global/index.js.map +1 -1
- package/lib/editor/input/AcEdCursorManager.d.ts +10 -0
- package/lib/editor/input/AcEdCursorManager.d.ts.map +1 -1
- package/lib/editor/input/AcEdCursorManager.js +24 -4
- package/lib/editor/input/AcEdCursorManager.js.map +1 -1
- package/lib/editor/input/AcEdInputModifiers.d.ts +39 -0
- package/lib/editor/input/AcEdInputModifiers.d.ts.map +1 -0
- package/lib/editor/input/AcEdInputModifiers.js +2 -0
- package/lib/editor/input/AcEdInputModifiers.js.map +1 -0
- package/lib/editor/input/AcEdInputToggles.d.ts +24 -0
- package/lib/editor/input/AcEdInputToggles.d.ts.map +1 -0
- package/lib/editor/input/AcEdInputToggles.js +2 -0
- package/lib/editor/input/AcEdInputToggles.js.map +1 -0
- package/lib/editor/input/AcEdPromptStateMachine.d.ts +110 -0
- package/lib/editor/input/AcEdPromptStateMachine.d.ts.map +1 -0
- package/lib/editor/input/AcEdPromptStateMachine.js +147 -0
- package/lib/editor/input/AcEdPromptStateMachine.js.map +1 -0
- package/lib/editor/input/AcEditor.d.ts +58 -9
- package/lib/editor/input/AcEditor.d.ts.map +1 -1
- package/lib/editor/input/AcEditor.js +96 -1
- package/lib/editor/input/AcEditor.js.map +1 -1
- package/lib/editor/input/index.d.ts +3 -0
- package/lib/editor/input/index.d.ts.map +1 -1
- package/lib/editor/input/index.js +3 -0
- package/lib/editor/input/index.js.map +1 -1
- package/lib/editor/input/marker/AcEdMarker.d.ts.map +1 -1
- package/lib/editor/input/marker/AcEdMarker.js +3 -3
- package/lib/editor/input/marker/AcEdMarker.js.map +1 -1
- package/lib/editor/input/prompt/AcEdKeywordCollection.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdKeywordCollection.js +11 -4
- package/lib/editor/input/prompt/AcEdKeywordCollection.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts +1 -1
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.js +2 -2
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptBoxResult.d.ts +12 -0
- package/lib/editor/input/prompt/AcEdPromptBoxResult.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptBoxResult.js +30 -0
- package/lib/editor/input/prompt/AcEdPromptBoxResult.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptDoubleResult.d.ts +9 -0
- package/lib/editor/input/prompt/AcEdPromptDoubleResult.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptDoubleResult.js +28 -0
- package/lib/editor/input/prompt/AcEdPromptDoubleResult.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptEntityOptions.d.ts +1 -1
- package/lib/editor/input/prompt/AcEdPromptEntityOptions.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptEntityOptions.js +2 -2
- package/lib/editor/input/prompt/AcEdPromptEntityOptions.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptEntityResult.d.ts +14 -0
- package/lib/editor/input/prompt/AcEdPromptEntityResult.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptEntityResult.js +31 -0
- package/lib/editor/input/prompt/AcEdPromptEntityResult.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptIntegerResult.d.ts +9 -0
- package/lib/editor/input/prompt/AcEdPromptIntegerResult.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptIntegerResult.js +28 -0
- package/lib/editor/input/prompt/AcEdPromptIntegerResult.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptKeywordOptions.d.ts +1 -1
- package/lib/editor/input/prompt/AcEdPromptKeywordOptions.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptKeywordOptions.js +2 -2
- package/lib/editor/input/prompt/AcEdPromptKeywordOptions.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptNumericalOptions.d.ts +1 -1
- package/lib/editor/input/prompt/AcEdPromptNumericalOptions.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptNumericalOptions.js +2 -2
- package/lib/editor/input/prompt/AcEdPromptNumericalOptions.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptOptions.d.ts +3 -2
- package/lib/editor/input/prompt/AcEdPromptOptions.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptOptions.js +15 -4
- package/lib/editor/input/prompt/AcEdPromptOptions.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptPointOptions.d.ts +1 -1
- package/lib/editor/input/prompt/AcEdPromptPointOptions.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptPointOptions.js +2 -2
- package/lib/editor/input/prompt/AcEdPromptPointOptions.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptPointResult.d.ts +3 -3
- package/lib/editor/input/prompt/AcEdPromptSelectionOptions.d.ts +1 -1
- package/lib/editor/input/prompt/AcEdPromptSelectionOptions.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptSelectionOptions.js +2 -2
- package/lib/editor/input/prompt/AcEdPromptSelectionOptions.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptSelectionResult.d.ts +12 -0
- package/lib/editor/input/prompt/AcEdPromptSelectionResult.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptSelectionResult.js +30 -0
- package/lib/editor/input/prompt/AcEdPromptSelectionResult.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptStringOptions.d.ts +1 -1
- package/lib/editor/input/prompt/AcEdPromptStringOptions.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptStringOptions.js +2 -2
- package/lib/editor/input/prompt/AcEdPromptStringOptions.js.map +1 -1
- package/lib/editor/input/prompt/index.d.ts +9 -0
- package/lib/editor/input/prompt/index.d.ts.map +1 -1
- package/lib/editor/input/prompt/index.js +9 -0
- package/lib/editor/input/prompt/index.js.map +1 -1
- package/lib/editor/input/session/AcEdKeywordSession.d.ts +2 -1
- package/lib/editor/input/session/AcEdKeywordSession.d.ts.map +1 -1
- package/lib/editor/input/session/AcEdKeywordSession.js +7 -1
- package/lib/editor/input/session/AcEdKeywordSession.js.map +1 -1
- package/lib/editor/input/ui/AcEdCommandLine.d.ts +4 -1
- package/lib/editor/input/ui/AcEdCommandLine.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdCommandLine.js +34 -5
- package/lib/editor/input/ui/AcEdCommandLine.js.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInput.d.ts +23 -1
- package/lib/editor/input/ui/AcEdFloatingInput.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInput.js +140 -26
- package/lib/editor/input/ui/AcEdFloatingInput.js.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInputBox.d.ts +2 -0
- package/lib/editor/input/ui/AcEdFloatingInputBox.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInputBox.js +4 -0
- package/lib/editor/input/ui/AcEdFloatingInputBox.js.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.d.ts +7 -0
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.js +14 -6
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.js.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInputTypes.d.ts +5 -0
- package/lib/editor/input/ui/AcEdFloatingInputTypes.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingMessage.d.ts +12 -0
- package/lib/editor/input/ui/AcEdFloatingMessage.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingMessage.js +61 -2
- package/lib/editor/input/ui/AcEdFloatingMessage.js.map +1 -1
- package/lib/editor/input/ui/AcEdInputManager.d.ts +47 -13
- package/lib/editor/input/ui/AcEdInputManager.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdInputManager.js +847 -383
- package/lib/editor/input/ui/AcEdInputManager.js.map +1 -1
- package/lib/editor/input/ui/AcEdRubberBand.js +1 -1
- package/lib/editor/input/ui/AcEdRubberBand.js.map +1 -1
- package/lib/editor/view/AcEdBaseView.d.ts +66 -0
- package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
- package/lib/editor/view/AcEdBaseView.js +170 -0
- package/lib/editor/view/AcEdBaseView.js.map +1 -1
- package/lib/editor/view/AcEdSpatialQueryResult.d.ts.map +1 -1
- package/lib/i18n/en/command.d.ts +15 -0
- package/lib/i18n/en/command.d.ts.map +1 -1
- package/lib/i18n/en/command.js +15 -0
- package/lib/i18n/en/command.js.map +1 -1
- package/lib/i18n/en/jig.d.ts +110 -0
- package/lib/i18n/en/jig.d.ts.map +1 -1
- package/lib/i18n/en/jig.js +110 -0
- package/lib/i18n/en/jig.js.map +1 -1
- package/lib/i18n/zh/command.d.ts +15 -0
- package/lib/i18n/zh/command.d.ts.map +1 -1
- package/lib/i18n/zh/command.js +15 -0
- package/lib/i18n/zh/command.js.map +1 -1
- package/lib/i18n/zh/jig.d.ts +110 -0
- package/lib/i18n/zh/jig.d.ts.map +1 -1
- package/lib/i18n/zh/jig.js +110 -0
- package/lib/i18n/zh/jig.js.map +1 -1
- package/lib/util/AcApMeasurementElementGenerator.d.ts +36 -0
- package/lib/util/AcApMeasurementElementGenerator.d.ts.map +1 -0
- package/lib/util/AcApMeasurementElementGenerator.js +92 -0
- package/lib/util/AcApMeasurementElementGenerator.js.map +1 -0
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/view/AcTrLayoutView.d.ts +6 -0
- package/lib/view/AcTrLayoutView.d.ts.map +1 -1
- package/lib/view/AcTrLayoutView.js +20 -0
- package/lib/view/AcTrLayoutView.js.map +1 -1
- package/lib/view/AcTrView2d.d.ts.map +1 -1
- package/lib/view/AcTrView2d.js +86 -46
- package/lib/view/AcTrView2d.js.map +1 -1
- package/package.json +10 -10
- package/lib/util/AcApMeasurementUtils.d.ts +0 -12
- package/lib/util/AcApMeasurementUtils.d.ts.map +0 -1
- package/lib/util/AcApMeasurementUtils.js +0 -36
- package/lib/util/AcApMeasurementUtils.js.map +0 -1
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
1
16
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
17
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
18
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -73,12 +88,22 @@ var __values = (this && this.__values) || function(o) {
|
|
|
73
88
|
import { AcGeBox2d } from '@mlightcad/data-model';
|
|
74
89
|
import { AcApSettingManager } from '../../../app';
|
|
75
90
|
import { AcApI18n } from '../../../i18n';
|
|
91
|
+
import { AcEdSelectionSet } from '../AcEdSelectionSet';
|
|
76
92
|
import { AcEdAngleHandler, AcEdDistanceHandler, AcEdDoubleHandler, AcEdIntegerHandler, AcEdPointHandler, AcEdStringHandler } from '../handler';
|
|
77
93
|
import { AcEdKeywordHandler } from '../handler/AcEdKeywordHandler';
|
|
78
|
-
import { AcEdPromptPointOptions } from '../prompt';
|
|
94
|
+
import { AcEdPromptBoxResult, AcEdPromptDoubleResult, AcEdPromptEntityResult, AcEdPromptIntegerResult, AcEdPromptKeywordOptions, AcEdPromptPointOptions, AcEdPromptPointResult, AcEdPromptResult, AcEdPromptSelectionResult, AcEdPromptStatus } from '../prompt';
|
|
79
95
|
import { AcEdCommandLine } from './AcEdCommandLine';
|
|
80
96
|
import { AcEdFloatingInput } from './AcEdFloatingInput';
|
|
81
97
|
import { AcEdFloatingMessage } from './AcEdFloatingMessage';
|
|
98
|
+
var AcEdKeywordInputError = /** @class */ (function (_super) {
|
|
99
|
+
__extends(AcEdKeywordInputError, _super);
|
|
100
|
+
function AcEdKeywordInputError(keyword) {
|
|
101
|
+
var _this = _super.call(this, 'keyword') || this;
|
|
102
|
+
_this.keyword = keyword;
|
|
103
|
+
return _this;
|
|
104
|
+
}
|
|
105
|
+
return AcEdKeywordInputError;
|
|
106
|
+
}(Error));
|
|
82
107
|
/**
|
|
83
108
|
* A fully type-safe TypeScript class providing CAD-style interactive user input
|
|
84
109
|
* using floating HTML input boxes and mouse events. Supports collecting points,
|
|
@@ -98,11 +123,25 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
98
123
|
this.lastPoint = null;
|
|
99
124
|
/** Buffered command-line style inputs (each item is one Enter-confirmed value). */
|
|
100
125
|
this._scriptInputs = [];
|
|
126
|
+
/** Current modifier key state during input sessions. */
|
|
127
|
+
this._modifierState = {
|
|
128
|
+
ctrlKey: false,
|
|
129
|
+
shiftKey: false,
|
|
130
|
+
altKey: false,
|
|
131
|
+
metaKey: false
|
|
132
|
+
};
|
|
133
|
+
/** Toggle-style Ctrl flip state (press Ctrl once to flip arc direction). */
|
|
134
|
+
this._ctrlArcFlip = false;
|
|
101
135
|
/**
|
|
102
136
|
* The flag to indicate whether it is currently in an “input acquisition” mode (e.g., point
|
|
103
137
|
* selection, distance/angle prompt, string prompt, etc.),
|
|
104
138
|
*/
|
|
105
139
|
this.active = false;
|
|
140
|
+
/**
|
|
141
|
+
* True only when the current input session explicitly expects entity selection
|
|
142
|
+
* (getEntity/getSelection). Used to gate view-level selection behavior.
|
|
143
|
+
*/
|
|
144
|
+
this.entitySelectionActive = false;
|
|
106
145
|
this.view = view;
|
|
107
146
|
this.injectCSS();
|
|
108
147
|
// Newly added UI overlays (command line, previews) are container-local.
|
|
@@ -129,6 +168,40 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
129
168
|
enumerable: false,
|
|
130
169
|
configurable: true
|
|
131
170
|
});
|
|
171
|
+
Object.defineProperty(AcEdInputManager.prototype, "isEntitySelectionActive", {
|
|
172
|
+
/**
|
|
173
|
+
* Whether current input session allows entity selection in the view.
|
|
174
|
+
*/
|
|
175
|
+
get: function () {
|
|
176
|
+
return this.entitySelectionActive;
|
|
177
|
+
},
|
|
178
|
+
enumerable: false,
|
|
179
|
+
configurable: true
|
|
180
|
+
});
|
|
181
|
+
Object.defineProperty(AcEdInputManager.prototype, "modifiers", {
|
|
182
|
+
/**
|
|
183
|
+
* Current modifier key state (Ctrl/Shift/Alt/Meta) during input sessions.
|
|
184
|
+
*/
|
|
185
|
+
get: function () {
|
|
186
|
+
return this._modifierState;
|
|
187
|
+
},
|
|
188
|
+
enumerable: false,
|
|
189
|
+
configurable: true
|
|
190
|
+
});
|
|
191
|
+
Object.defineProperty(AcEdInputManager.prototype, "toggles", {
|
|
192
|
+
/**
|
|
193
|
+
* Toggle-style input states (press once to flip, persists after keyup).
|
|
194
|
+
*/
|
|
195
|
+
get: function () {
|
|
196
|
+
return { ctrlArcFlip: this._ctrlArcFlip };
|
|
197
|
+
},
|
|
198
|
+
enumerable: false,
|
|
199
|
+
configurable: true
|
|
200
|
+
});
|
|
201
|
+
/** Reset toggle-style inputs to their default state. */
|
|
202
|
+
AcEdInputManager.prototype.resetToggles = function () {
|
|
203
|
+
this._ctrlArcFlip = false;
|
|
204
|
+
};
|
|
132
205
|
/**
|
|
133
206
|
* Queue scripted inputs for subsequent getXXX calls.
|
|
134
207
|
* One array item equals one Enter-confirmed value.
|
|
@@ -152,7 +225,7 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
152
225
|
return;
|
|
153
226
|
AcEdInputManager.stylesInjected = true;
|
|
154
227
|
var style = document.createElement('style');
|
|
155
|
-
style.textContent = "\n .ml-jig-preview-rect {\n position: absolute;\n border: 1px dashed var(--line-color, #0f0);\n background: rgba(
|
|
228
|
+
style.textContent = "\n .ml-jig-preview-rect {\n position: absolute;\n border: 1px dashed var(--line-color, var(--ml-ui-canvas-line, #0f0));\n background: var(--ml-ui-canvas-fill-mix, var(--ml-ui-canvas-fill, rgba(64, 158, 255, 0.12)));\n pointer-events: none;\n z-index: 9999;\n }\n .ml-jig-preview-line {\n position: absolute;\n height: 1px;\n background: var(--line-color, var(--ml-ui-canvas-line, #0f0));\n transform-origin: 0 0;\n pointer-events: none;\n z-index: 9999;\n }\n ";
|
|
156
229
|
document.head.appendChild(style);
|
|
157
230
|
};
|
|
158
231
|
/**
|
|
@@ -171,15 +244,77 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
171
244
|
return value.toFixed(3);
|
|
172
245
|
}
|
|
173
246
|
};
|
|
247
|
+
AcEdInputManager.prototype.hasKeywords = function (options) {
|
|
248
|
+
var _a, _b;
|
|
249
|
+
var keywords = (_b = (_a = options.keywords) === null || _a === void 0 ? void 0 : _a.toArray()) !== null && _b !== void 0 ? _b : [];
|
|
250
|
+
return keywords.length > 0;
|
|
251
|
+
};
|
|
252
|
+
AcEdInputManager.prototype.buildKeywordOptions = function (options) {
|
|
253
|
+
var _a, _b;
|
|
254
|
+
var keywordOptions = new AcEdPromptKeywordOptions(options.message);
|
|
255
|
+
keywordOptions.appendKeywordsToMessage = options.appendKeywordsToMessage;
|
|
256
|
+
var keywords = (_b = (_a = options.keywords) === null || _a === void 0 ? void 0 : _a.toArray()) !== null && _b !== void 0 ? _b : [];
|
|
257
|
+
keywords.forEach(function (kw) {
|
|
258
|
+
var added = keywordOptions.keywords.add(kw.displayName, kw.globalName, kw.localName, kw.enabled, kw.visible);
|
|
259
|
+
if (options.keywords.default === kw) {
|
|
260
|
+
keywordOptions.keywords.default = added;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
return keywordOptions;
|
|
264
|
+
};
|
|
265
|
+
AcEdInputManager.prototype.copyKeywords = function (source, target) {
|
|
266
|
+
var _a, _b;
|
|
267
|
+
target.appendKeywordsToMessage = source.appendKeywordsToMessage;
|
|
268
|
+
var keywords = (_b = (_a = source.keywords) === null || _a === void 0 ? void 0 : _a.toArray()) !== null && _b !== void 0 ? _b : [];
|
|
269
|
+
keywords.forEach(function (kw) {
|
|
270
|
+
var added = target.keywords.add(kw.displayName, kw.globalName, kw.localName, kw.enabled, kw.visible);
|
|
271
|
+
if (source.keywords.default === kw) {
|
|
272
|
+
target.keywords.default = added;
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
AcEdInputManager.prototype.startKeywordSession = function (options, allowTyping) {
|
|
277
|
+
var _this = this;
|
|
278
|
+
if (!this.hasKeywords(options))
|
|
279
|
+
return undefined;
|
|
280
|
+
var keywordOptions = this.buildKeywordOptions(options);
|
|
281
|
+
return {
|
|
282
|
+
promise: this._commandLine.getKeywords(keywordOptions, allowTyping),
|
|
283
|
+
cancel: function () { return _this._commandLine.cancelActiveSession(); }
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
AcEdInputManager.prototype.isPromptKeyword = function (error) {
|
|
287
|
+
return error instanceof AcEdKeywordInputError;
|
|
288
|
+
};
|
|
174
289
|
/**
|
|
175
290
|
* Public point input API.
|
|
176
291
|
*/
|
|
177
292
|
AcEdInputManager.prototype.getPoint = function (options) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return
|
|
181
|
-
|
|
182
|
-
|
|
293
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
294
|
+
var value, error_1, result;
|
|
295
|
+
return __generator(this, function (_a) {
|
|
296
|
+
switch (_a.label) {
|
|
297
|
+
case 0:
|
|
298
|
+
_a.trys.push([0, 2, , 3]);
|
|
299
|
+
return [4 /*yield*/, this.getPointInternal(options)];
|
|
300
|
+
case 1:
|
|
301
|
+
value = _a.sent();
|
|
302
|
+
return [2 /*return*/, new AcEdPromptPointResult(AcEdPromptStatus.OK, value)];
|
|
303
|
+
case 2:
|
|
304
|
+
error_1 = _a.sent();
|
|
305
|
+
if (this.isPromptCancelled(error_1)) {
|
|
306
|
+
return [2 /*return*/, new AcEdPromptPointResult(AcEdPromptStatus.Cancel)];
|
|
307
|
+
}
|
|
308
|
+
if (this.isPromptKeyword(error_1)) {
|
|
309
|
+
result = new AcEdPromptPointResult(AcEdPromptStatus.Keyword);
|
|
310
|
+
result.stringResult = error_1.keyword;
|
|
311
|
+
return [2 /*return*/, result];
|
|
312
|
+
}
|
|
313
|
+
throw error_1;
|
|
314
|
+
case 3: return [2 /*return*/];
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
});
|
|
183
318
|
};
|
|
184
319
|
/**
|
|
185
320
|
* Prompt the user to type a numeric value. If integerOnly is true, integers
|
|
@@ -194,141 +329,256 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
194
329
|
};
|
|
195
330
|
};
|
|
196
331
|
return this.makeFloatingInputPromise({
|
|
197
|
-
message: options.message,
|
|
198
332
|
inputCount: 1,
|
|
199
|
-
|
|
200
|
-
showBaseLineOnly: false,
|
|
201
|
-
useBasePoint: false,
|
|
333
|
+
promptOptions: options,
|
|
202
334
|
handler: handler,
|
|
203
335
|
getDynamicValue: getDynamicValue
|
|
204
336
|
});
|
|
205
337
|
};
|
|
206
338
|
/** Request a distance (number) from the user. */
|
|
207
339
|
AcEdInputManager.prototype.getDistance = function (options) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
340
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
341
|
+
var handler, scriptedValue, value_1, getDynamicValue, value, error_2, result;
|
|
342
|
+
var _this = this;
|
|
343
|
+
return __generator(this, function (_a) {
|
|
344
|
+
switch (_a.label) {
|
|
345
|
+
case 0:
|
|
346
|
+
handler = new AcEdDistanceHandler(options);
|
|
347
|
+
scriptedValue = this.tryGetScriptedNumber(handler);
|
|
348
|
+
if (scriptedValue != null) {
|
|
349
|
+
return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, scriptedValue)];
|
|
350
|
+
}
|
|
351
|
+
_a.label = 1;
|
|
352
|
+
case 1:
|
|
353
|
+
_a.trys.push([1, 5, , 6]);
|
|
354
|
+
if (!!this.lastPoint) return [3 /*break*/, 3];
|
|
355
|
+
return [4 /*yield*/, this.getNumberTyped(options, handler)];
|
|
356
|
+
case 2:
|
|
357
|
+
value_1 = _a.sent();
|
|
358
|
+
return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, value_1)];
|
|
359
|
+
case 3:
|
|
360
|
+
getDynamicValue = function (pos) {
|
|
361
|
+
var dx = pos.x - _this.lastPoint.x;
|
|
362
|
+
var dy = pos.y - _this.lastPoint.y;
|
|
363
|
+
var dist = Math.sqrt(dx * dx + dy * dy);
|
|
364
|
+
return {
|
|
365
|
+
value: dist,
|
|
366
|
+
raw: { x: _this.formatNumber(dist, 'distance') }
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
return [4 /*yield*/, this.makeFloatingInputPromise({
|
|
370
|
+
inputCount: 1,
|
|
371
|
+
promptOptions: options,
|
|
372
|
+
handler: handler,
|
|
373
|
+
getDynamicValue: getDynamicValue
|
|
374
|
+
})];
|
|
375
|
+
case 4:
|
|
376
|
+
value = _a.sent();
|
|
377
|
+
return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, value)];
|
|
378
|
+
case 5:
|
|
379
|
+
error_2 = _a.sent();
|
|
380
|
+
if (this.isPromptCancelled(error_2)) {
|
|
381
|
+
return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.Cancel)];
|
|
382
|
+
}
|
|
383
|
+
if (this.isPromptKeyword(error_2)) {
|
|
384
|
+
result = new AcEdPromptDoubleResult(AcEdPromptStatus.Keyword);
|
|
385
|
+
result.stringResult = error_2.keyword;
|
|
386
|
+
return [2 /*return*/, result];
|
|
387
|
+
}
|
|
388
|
+
throw error_2;
|
|
389
|
+
case 6: return [2 /*return*/];
|
|
390
|
+
}
|
|
391
|
+
});
|
|
237
392
|
});
|
|
238
393
|
};
|
|
239
394
|
/** Request an angle in degrees from the user. */
|
|
240
395
|
AcEdInputManager.prototype.getAngle = function (options) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
396
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
397
|
+
var handler, scriptedValue, getDynamicValue, value, error_3, result;
|
|
398
|
+
var _this = this;
|
|
399
|
+
return __generator(this, function (_a) {
|
|
400
|
+
switch (_a.label) {
|
|
401
|
+
case 0:
|
|
402
|
+
handler = new AcEdAngleHandler(options);
|
|
403
|
+
scriptedValue = this.tryGetScriptedNumber(handler);
|
|
404
|
+
if (scriptedValue != null) {
|
|
405
|
+
return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, scriptedValue)];
|
|
406
|
+
}
|
|
407
|
+
getDynamicValue = function (pos) {
|
|
408
|
+
var dx = pos.x - _this.lastPoint.x;
|
|
409
|
+
var dy = pos.y - _this.lastPoint.y;
|
|
410
|
+
var angleRad = Math.atan2(dy, dx);
|
|
411
|
+
var angleDeg = (angleRad * 180) / Math.PI;
|
|
412
|
+
return {
|
|
413
|
+
value: angleDeg,
|
|
414
|
+
raw: { x: _this.formatNumber(angleDeg, 'angle') }
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
_a.label = 1;
|
|
418
|
+
case 1:
|
|
419
|
+
_a.trys.push([1, 3, , 4]);
|
|
420
|
+
return [4 /*yield*/, this.makeFloatingInputPromise({
|
|
421
|
+
inputCount: 1,
|
|
422
|
+
promptOptions: options,
|
|
423
|
+
handler: handler,
|
|
424
|
+
getDynamicValue: getDynamicValue
|
|
425
|
+
})];
|
|
426
|
+
case 2:
|
|
427
|
+
value = _a.sent();
|
|
428
|
+
return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, value)];
|
|
429
|
+
case 3:
|
|
430
|
+
error_3 = _a.sent();
|
|
431
|
+
if (this.isPromptCancelled(error_3)) {
|
|
432
|
+
return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.Cancel)];
|
|
433
|
+
}
|
|
434
|
+
if (this.isPromptKeyword(error_3)) {
|
|
435
|
+
result = new AcEdPromptDoubleResult(AcEdPromptStatus.Keyword);
|
|
436
|
+
result.stringResult = error_3.keyword;
|
|
437
|
+
return [2 /*return*/, result];
|
|
438
|
+
}
|
|
439
|
+
throw error_3;
|
|
440
|
+
case 4: return [2 /*return*/];
|
|
441
|
+
}
|
|
442
|
+
});
|
|
266
443
|
});
|
|
267
444
|
};
|
|
268
445
|
/** Request a double/float from the user. */
|
|
269
446
|
AcEdInputManager.prototype.getDouble = function (options) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return
|
|
273
|
-
|
|
274
|
-
|
|
447
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
448
|
+
var handler, scriptedValue, value, error_4, result;
|
|
449
|
+
return __generator(this, function (_a) {
|
|
450
|
+
switch (_a.label) {
|
|
451
|
+
case 0:
|
|
452
|
+
handler = new AcEdDoubleHandler(options);
|
|
453
|
+
scriptedValue = this.tryGetScriptedNumber(handler);
|
|
454
|
+
if (scriptedValue != null) {
|
|
455
|
+
return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, scriptedValue)];
|
|
456
|
+
}
|
|
457
|
+
_a.label = 1;
|
|
458
|
+
case 1:
|
|
459
|
+
_a.trys.push([1, 3, , 4]);
|
|
460
|
+
return [4 /*yield*/, this.getNumberTyped(options, handler)];
|
|
461
|
+
case 2:
|
|
462
|
+
value = _a.sent();
|
|
463
|
+
return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, value)];
|
|
464
|
+
case 3:
|
|
465
|
+
error_4 = _a.sent();
|
|
466
|
+
if (this.isPromptCancelled(error_4)) {
|
|
467
|
+
return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.Cancel)];
|
|
468
|
+
}
|
|
469
|
+
if (this.isPromptKeyword(error_4)) {
|
|
470
|
+
result = new AcEdPromptDoubleResult(AcEdPromptStatus.Keyword);
|
|
471
|
+
result.stringResult = error_4.keyword;
|
|
472
|
+
return [2 /*return*/, result];
|
|
473
|
+
}
|
|
474
|
+
throw error_4;
|
|
475
|
+
case 4: return [2 /*return*/];
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
});
|
|
275
479
|
};
|
|
276
480
|
/** Request an integer from the user. */
|
|
277
481
|
AcEdInputManager.prototype.getInteger = function (options) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
return
|
|
281
|
-
|
|
282
|
-
|
|
482
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
483
|
+
var scriptedValue, value, error_5, result;
|
|
484
|
+
return __generator(this, function (_a) {
|
|
485
|
+
switch (_a.label) {
|
|
486
|
+
case 0:
|
|
487
|
+
scriptedValue = this.tryGetScriptedNumber(new AcEdIntegerHandler(options));
|
|
488
|
+
if (scriptedValue != null) {
|
|
489
|
+
return [2 /*return*/, new AcEdPromptIntegerResult(AcEdPromptStatus.OK, scriptedValue)];
|
|
490
|
+
}
|
|
491
|
+
_a.label = 1;
|
|
492
|
+
case 1:
|
|
493
|
+
_a.trys.push([1, 3, , 4]);
|
|
494
|
+
return [4 /*yield*/, this.getNumberTyped(options, new AcEdIntegerHandler(options))];
|
|
495
|
+
case 2:
|
|
496
|
+
value = _a.sent();
|
|
497
|
+
return [2 /*return*/, new AcEdPromptIntegerResult(AcEdPromptStatus.OK, value)];
|
|
498
|
+
case 3:
|
|
499
|
+
error_5 = _a.sent();
|
|
500
|
+
if (this.isPromptCancelled(error_5)) {
|
|
501
|
+
return [2 /*return*/, new AcEdPromptIntegerResult(AcEdPromptStatus.Cancel)];
|
|
502
|
+
}
|
|
503
|
+
if (this.isPromptKeyword(error_5)) {
|
|
504
|
+
result = new AcEdPromptIntegerResult(AcEdPromptStatus.Keyword);
|
|
505
|
+
result.stringResult = error_5.keyword;
|
|
506
|
+
return [2 /*return*/, result];
|
|
507
|
+
}
|
|
508
|
+
throw error_5;
|
|
509
|
+
case 4: return [2 /*return*/];
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
});
|
|
283
513
|
};
|
|
284
514
|
/**
|
|
285
515
|
* Prompt the user to type an arbitrary string. Resolved when Enter is pressed.
|
|
286
516
|
*/
|
|
287
517
|
AcEdInputManager.prototype.getString = function (options) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
return
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
518
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
519
|
+
var scriptedValue, getDynamicValue, handler, value, error_6;
|
|
520
|
+
return __generator(this, function (_a) {
|
|
521
|
+
switch (_a.label) {
|
|
522
|
+
case 0:
|
|
523
|
+
scriptedValue = this.tryGetScriptedValue(new AcEdStringHandler(options));
|
|
524
|
+
if (scriptedValue != null) {
|
|
525
|
+
return [2 /*return*/, new AcEdPromptResult(AcEdPromptStatus.OK, scriptedValue)];
|
|
526
|
+
}
|
|
527
|
+
_a.label = 1;
|
|
528
|
+
case 1:
|
|
529
|
+
_a.trys.push([1, 3, , 4]);
|
|
530
|
+
getDynamicValue = function () {
|
|
531
|
+
return {
|
|
532
|
+
value: '',
|
|
533
|
+
raw: { x: '' }
|
|
534
|
+
};
|
|
535
|
+
};
|
|
536
|
+
handler = new AcEdStringHandler(options);
|
|
537
|
+
return [4 /*yield*/, this.makeFloatingInputPromise({
|
|
538
|
+
inputCount: 1,
|
|
539
|
+
promptOptions: options,
|
|
540
|
+
handler: handler,
|
|
541
|
+
getDynamicValue: getDynamicValue
|
|
542
|
+
})];
|
|
543
|
+
case 2:
|
|
544
|
+
value = _a.sent();
|
|
545
|
+
return [2 /*return*/, new AcEdPromptResult(AcEdPromptStatus.OK, value)];
|
|
546
|
+
case 3:
|
|
547
|
+
error_6 = _a.sent();
|
|
548
|
+
if (this.isPromptCancelled(error_6)) {
|
|
549
|
+
return [2 /*return*/, new AcEdPromptResult(AcEdPromptStatus.Cancel)];
|
|
550
|
+
}
|
|
551
|
+
if (this.isPromptKeyword(error_6)) {
|
|
552
|
+
return [2 /*return*/, new AcEdPromptResult(AcEdPromptStatus.Keyword, error_6.keyword)];
|
|
553
|
+
}
|
|
554
|
+
throw error_6;
|
|
555
|
+
case 4: return [2 /*return*/];
|
|
556
|
+
}
|
|
557
|
+
});
|
|
307
558
|
});
|
|
308
559
|
};
|
|
309
560
|
/**
|
|
310
561
|
* Prompt the user to type a keyword. Resolved when Enter is pressed.
|
|
311
562
|
*/
|
|
312
563
|
AcEdInputManager.prototype.getKeywords = function (options) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
return
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
getDynamicValue: getDynamicValue
|
|
564
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
565
|
+
var scriptedValue, result;
|
|
566
|
+
return __generator(this, function (_a) {
|
|
567
|
+
switch (_a.label) {
|
|
568
|
+
case 0:
|
|
569
|
+
scriptedValue = this.tryGetScriptedValue(new AcEdKeywordHandler(options));
|
|
570
|
+
if (scriptedValue != null) {
|
|
571
|
+
return [2 /*return*/, Promise.resolve(scriptedValue)];
|
|
572
|
+
}
|
|
573
|
+
return [4 /*yield*/, this._commandLine.getKeywords(options, true)];
|
|
574
|
+
case 1:
|
|
575
|
+
result = _a.sent();
|
|
576
|
+
if (!result) {
|
|
577
|
+
throw new Error('cancelled');
|
|
578
|
+
}
|
|
579
|
+
return [2 /*return*/, result];
|
|
580
|
+
}
|
|
581
|
+
});
|
|
332
582
|
});
|
|
333
583
|
};
|
|
334
584
|
/**
|
|
@@ -337,8 +587,9 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
337
587
|
* This method supports two selection modes:
|
|
338
588
|
*
|
|
339
589
|
* - **Click selection**: Clicking on an entity selects the entity under the cursor.
|
|
340
|
-
* - **Box selection**:
|
|
341
|
-
*
|
|
590
|
+
* - **Box selection**:
|
|
591
|
+
* - left-to-right drag: window selection (entities fully inside the box)
|
|
592
|
+
* - right-to-left drag: crossing selection (entities intersecting the box)
|
|
342
593
|
*
|
|
343
594
|
* The selection operation behaves similarly to AutoCAD's
|
|
344
595
|
* `Editor.GetSelection()` API:
|
|
@@ -360,113 +611,176 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
360
611
|
*/
|
|
361
612
|
AcEdInputManager.prototype.getSelection = function (options) {
|
|
362
613
|
return __awaiter(this, void 0, void 0, function () {
|
|
614
|
+
var value, error_7;
|
|
363
615
|
var _this = this;
|
|
364
616
|
return __generator(this, function (_a) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
height: "".concat(height, "px")
|
|
419
|
-
});
|
|
420
|
-
};
|
|
421
|
-
var mouseUp = function (e) {
|
|
422
|
-
var e_1, _a;
|
|
423
|
-
if (!startWcs)
|
|
424
|
-
return;
|
|
425
|
-
var endWcs = _this.view.screenToWorld(_this.view.viewportToCanvas({ x: e.clientX, y: e.clientY }));
|
|
426
|
-
previewEl === null || previewEl === void 0 ? void 0 : previewEl.remove();
|
|
427
|
-
previewEl = null;
|
|
428
|
-
// Click selection
|
|
429
|
-
var dist = Math.hypot(endWcs.x - startWcs.x, endWcs.y - startWcs.y);
|
|
430
|
-
if (dist < 2) {
|
|
431
|
-
var picked = _this.view.pick(endWcs);
|
|
432
|
-
if (picked.length > 0) {
|
|
433
|
-
selected.add(picked[0].id);
|
|
434
|
-
if (options.singleOnly) {
|
|
617
|
+
switch (_a.label) {
|
|
618
|
+
case 0:
|
|
619
|
+
_a.trys.push([0, 2, , 3]);
|
|
620
|
+
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
621
|
+
_this.active = true;
|
|
622
|
+
_this.entitySelectionActive = true;
|
|
623
|
+
var keywordSession = _this.startKeywordSession(options, true);
|
|
624
|
+
if (!keywordSession) {
|
|
625
|
+
_this._commandLine.setPrompt(options.message);
|
|
626
|
+
}
|
|
627
|
+
var floatingMessage = new AcEdFloatingMessage(_this.view, {
|
|
628
|
+
parent: _this.view.canvas,
|
|
629
|
+
message: options.message
|
|
630
|
+
});
|
|
631
|
+
var selected = new Set();
|
|
632
|
+
var startWcs = null;
|
|
633
|
+
var startCanvas = null;
|
|
634
|
+
var previewEl = null;
|
|
635
|
+
var settled = false;
|
|
636
|
+
var cleanup = function () {
|
|
637
|
+
if (settled)
|
|
638
|
+
return;
|
|
639
|
+
settled = true;
|
|
640
|
+
_this.active = false;
|
|
641
|
+
_this.entitySelectionActive = false;
|
|
642
|
+
floatingMessage === null || floatingMessage === void 0 ? void 0 : floatingMessage.dispose();
|
|
643
|
+
previewEl === null || previewEl === void 0 ? void 0 : previewEl.remove();
|
|
644
|
+
keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.cancel();
|
|
645
|
+
_this._commandLine.clear();
|
|
646
|
+
document.removeEventListener('keydown', keyHandler);
|
|
647
|
+
_this.view.canvas.removeEventListener('mousedown', mouseDown);
|
|
648
|
+
_this.view.canvas.removeEventListener('mousemove', mouseMove);
|
|
649
|
+
_this.view.canvas.removeEventListener('mouseup', mouseUp);
|
|
650
|
+
};
|
|
651
|
+
keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.promise.then(function (keyword) {
|
|
652
|
+
if (settled)
|
|
653
|
+
return;
|
|
654
|
+
if (!keyword) {
|
|
655
|
+
cleanup();
|
|
656
|
+
reject(new Error('cancelled'));
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
cleanup();
|
|
660
|
+
reject(new AcEdKeywordInputError(keyword));
|
|
661
|
+
});
|
|
662
|
+
/** ---------- Keyboard ---------- */
|
|
663
|
+
var keyHandler = function (e) {
|
|
664
|
+
if (e.key === 'Escape') {
|
|
665
|
+
cleanup();
|
|
666
|
+
reject(new Error('cancelled'));
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
if (e.key === 'Enter') {
|
|
435
670
|
cleanup();
|
|
436
671
|
resolve(__spreadArray([], __read(selected), false));
|
|
437
672
|
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
673
|
+
};
|
|
674
|
+
/** ---------- Mouse ---------- */
|
|
675
|
+
var mouseDown = function (e) {
|
|
676
|
+
startCanvas = _this.view.viewportToCanvas({
|
|
677
|
+
x: e.clientX,
|
|
678
|
+
y: e.clientY
|
|
679
|
+
});
|
|
680
|
+
startWcs = _this.view.screenToWorld(startCanvas);
|
|
681
|
+
previewEl = document.createElement('div');
|
|
682
|
+
previewEl.className = 'ml-jig-preview-rect';
|
|
683
|
+
_this.view.container.appendChild(previewEl);
|
|
684
|
+
};
|
|
685
|
+
var mouseMove = function (e) {
|
|
686
|
+
if (!startWcs || !previewEl || !startCanvas)
|
|
687
|
+
return;
|
|
688
|
+
var curWcs = _this.view.screenToWorld(_this.view.viewportToCanvas({ x: e.clientX, y: e.clientY }));
|
|
689
|
+
var curCanvas = _this.view.viewportToCanvas({
|
|
690
|
+
x: e.clientX,
|
|
691
|
+
y: e.clientY
|
|
692
|
+
});
|
|
693
|
+
var p1 = _this.view.worldToScreen(startWcs);
|
|
694
|
+
var p2 = _this.view.worldToScreen(curWcs);
|
|
695
|
+
var left = Math.min(p1.x, p2.x);
|
|
696
|
+
var top = Math.min(p1.y, p2.y);
|
|
697
|
+
var width = Math.abs(p1.x - p2.x);
|
|
698
|
+
var height = Math.abs(p1.y - p2.y);
|
|
699
|
+
var mode = _this.view.getSelectionMode(startCanvas, curCanvas);
|
|
700
|
+
var action = _this.view.getSelectionActionFromEvent(e, 'add');
|
|
701
|
+
var style = _this.view.getSelectionPreviewStyle(mode, action);
|
|
702
|
+
Object.assign(previewEl.style, {
|
|
703
|
+
left: "".concat(left, "px"),
|
|
704
|
+
top: "".concat(top, "px"),
|
|
705
|
+
width: "".concat(width, "px"),
|
|
706
|
+
height: "".concat(height, "px"),
|
|
707
|
+
borderStyle: style.borderStyle,
|
|
708
|
+
background: style.background
|
|
709
|
+
});
|
|
710
|
+
previewEl.style.setProperty('--line-color', style.lineColor);
|
|
711
|
+
};
|
|
712
|
+
var mouseUp = function (e) {
|
|
713
|
+
var e_1, _a;
|
|
714
|
+
if (!startWcs || !startCanvas)
|
|
715
|
+
return;
|
|
716
|
+
var endWcs = _this.view.screenToWorld(_this.view.viewportToCanvas({ x: e.clientX, y: e.clientY }));
|
|
717
|
+
var endCanvas = _this.view.viewportToCanvas({
|
|
718
|
+
x: e.clientX,
|
|
719
|
+
y: e.clientY
|
|
720
|
+
});
|
|
721
|
+
previewEl === null || previewEl === void 0 ? void 0 : previewEl.remove();
|
|
722
|
+
previewEl = null;
|
|
723
|
+
// Click selection
|
|
724
|
+
var action = _this.view.getSelectionActionFromEvent(e, 'add');
|
|
725
|
+
if (_this.view.isSelectionClick(startCanvas, endCanvas)) {
|
|
726
|
+
var picked = _this.view.pick(endWcs);
|
|
727
|
+
if (picked.length > 0) {
|
|
728
|
+
_this.view.applySelection([picked[0].id], action);
|
|
729
|
+
}
|
|
730
|
+
else if (action === 'replace') {
|
|
731
|
+
_this.view.selectionSet.clear();
|
|
732
|
+
}
|
|
452
733
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
734
|
+
else {
|
|
735
|
+
// Box selection
|
|
736
|
+
var box = new AcGeBox2d()
|
|
737
|
+
.expandByPoint(startWcs)
|
|
738
|
+
.expandByPoint(endWcs);
|
|
739
|
+
var mode = _this.view.getSelectionMode(startCanvas, endCanvas);
|
|
740
|
+
_this.view.selectByBoxWithMode(box, mode, action);
|
|
741
|
+
}
|
|
742
|
+
selected.clear();
|
|
456
743
|
try {
|
|
457
|
-
|
|
744
|
+
for (var _b = __values(_this.view.selectionSet.ids), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
745
|
+
var id = _c.value;
|
|
746
|
+
selected.add(id);
|
|
747
|
+
}
|
|
458
748
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
749
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
750
|
+
finally {
|
|
751
|
+
try {
|
|
752
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
753
|
+
}
|
|
754
|
+
finally { if (e_1) throw e_1.error; }
|
|
755
|
+
}
|
|
756
|
+
if (options.singleOnly && action !== 'remove') {
|
|
757
|
+
if (selected.size > 0) {
|
|
758
|
+
cleanup();
|
|
759
|
+
resolve(__spreadArray([], __read(selected), false));
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
startWcs = null;
|
|
763
|
+
startCanvas = null;
|
|
764
|
+
};
|
|
765
|
+
document.addEventListener('keydown', keyHandler);
|
|
766
|
+
_this.view.canvas.addEventListener('mousedown', mouseDown);
|
|
767
|
+
_this.view.canvas.addEventListener('mousemove', mouseMove);
|
|
768
|
+
_this.view.canvas.addEventListener('mouseup', mouseUp);
|
|
769
|
+
})];
|
|
770
|
+
case 1:
|
|
771
|
+
value = _a.sent();
|
|
772
|
+
return [2 /*return*/, new AcEdPromptSelectionResult(AcEdPromptStatus.OK, new AcEdSelectionSet(value))];
|
|
773
|
+
case 2:
|
|
774
|
+
error_7 = _a.sent();
|
|
775
|
+
if (this.isPromptCancelled(error_7)) {
|
|
776
|
+
return [2 /*return*/, new AcEdPromptSelectionResult(AcEdPromptStatus.Cancel)];
|
|
777
|
+
}
|
|
778
|
+
if (this.isPromptKeyword(error_7)) {
|
|
779
|
+
return [2 /*return*/, new AcEdPromptSelectionResult(AcEdPromptStatus.Keyword, undefined, error_7.keyword)];
|
|
780
|
+
}
|
|
781
|
+
throw error_7;
|
|
782
|
+
case 3: return [2 /*return*/];
|
|
783
|
+
}
|
|
470
784
|
});
|
|
471
785
|
});
|
|
472
786
|
};
|
|
@@ -475,59 +789,104 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
475
789
|
* Similar to Editor.GetEntity() in AutoCAD.
|
|
476
790
|
*/
|
|
477
791
|
AcEdInputManager.prototype.getEntity = function (options) {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
_this
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
792
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
793
|
+
var value, error_8, result;
|
|
794
|
+
var _this = this;
|
|
795
|
+
return __generator(this, function (_a) {
|
|
796
|
+
switch (_a.label) {
|
|
797
|
+
case 0:
|
|
798
|
+
_a.trys.push([0, 2, , 3]);
|
|
799
|
+
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
800
|
+
_this.active = true;
|
|
801
|
+
_this.entitySelectionActive = true;
|
|
802
|
+
var keywordSession = _this.startKeywordSession(options, true);
|
|
803
|
+
var floatingMessage = new AcEdFloatingMessage(_this.view, {
|
|
804
|
+
parent: _this.view.canvas,
|
|
805
|
+
message: options.message
|
|
806
|
+
});
|
|
807
|
+
if (!keywordSession) {
|
|
808
|
+
_this._commandLine.setPrompt(options.message);
|
|
809
|
+
}
|
|
810
|
+
var settled = false;
|
|
811
|
+
var cleanup = function () {
|
|
812
|
+
var _a;
|
|
813
|
+
if (settled)
|
|
814
|
+
return;
|
|
815
|
+
settled = true;
|
|
816
|
+
_this.active = false;
|
|
817
|
+
_this.entitySelectionActive = false;
|
|
818
|
+
(_a = options.jig) === null || _a === void 0 ? void 0 : _a.end();
|
|
819
|
+
document.removeEventListener('keydown', keyHandler);
|
|
820
|
+
_this.view.canvas.removeEventListener('mousedown', clickHandler);
|
|
821
|
+
floatingMessage === null || floatingMessage === void 0 ? void 0 : floatingMessage.dispose();
|
|
822
|
+
keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.cancel();
|
|
823
|
+
_this._commandLine.clear();
|
|
824
|
+
};
|
|
825
|
+
keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.promise.then(function (keyword) {
|
|
826
|
+
if (settled)
|
|
827
|
+
return;
|
|
828
|
+
if (!keyword) {
|
|
829
|
+
cleanup();
|
|
830
|
+
reject(new Error('cancelled'));
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
cleanup();
|
|
834
|
+
reject(new AcEdKeywordInputError(keyword));
|
|
835
|
+
});
|
|
836
|
+
/** Mouse click → try select entity */
|
|
837
|
+
var clickHandler = function (e) {
|
|
838
|
+
var pos = _this.view.screenToWorld(_this.view.viewportToCanvas({ x: e.clientX, y: e.clientY }));
|
|
839
|
+
var picked = _this.view.pick(pos);
|
|
840
|
+
// Clicked empty space
|
|
841
|
+
if (picked.length == 0) {
|
|
842
|
+
// this.view.showMessage(options.rejectMessage)
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
// Locked layer
|
|
846
|
+
// if (picked.locked && !options.allowObjectOnLockedLayer) {
|
|
847
|
+
// this.view.showMessage(options.rejectMessage)
|
|
848
|
+
// return
|
|
849
|
+
// }
|
|
850
|
+
// Class filter
|
|
851
|
+
// if (!options.isClassAllowed(picked.className)) {
|
|
852
|
+
// this.view.showMessage(options.rejectMessage)
|
|
853
|
+
// return
|
|
854
|
+
// }
|
|
855
|
+
cleanup();
|
|
856
|
+
resolve(picked[0].id);
|
|
857
|
+
};
|
|
858
|
+
/** Keyboard handling */
|
|
859
|
+
var keyHandler = function (e) {
|
|
860
|
+
if (e.key === 'Escape') {
|
|
861
|
+
cleanup();
|
|
862
|
+
reject(new Error('cancelled'));
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
if (e.key === 'Enter' && options.allowNone) {
|
|
866
|
+
cleanup();
|
|
867
|
+
resolve(null);
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
document.addEventListener('keydown', keyHandler);
|
|
871
|
+
_this.view.canvas.addEventListener('mousedown', clickHandler);
|
|
872
|
+
})];
|
|
873
|
+
case 1:
|
|
874
|
+
value = _a.sent();
|
|
875
|
+
return [2 /*return*/, new AcEdPromptEntityResult(AcEdPromptStatus.OK, value || undefined)];
|
|
876
|
+
case 2:
|
|
877
|
+
error_8 = _a.sent();
|
|
878
|
+
if (this.isPromptCancelled(error_8)) {
|
|
879
|
+
return [2 /*return*/, new AcEdPromptEntityResult(AcEdPromptStatus.Cancel)];
|
|
880
|
+
}
|
|
881
|
+
if (this.isPromptKeyword(error_8)) {
|
|
882
|
+
result = new AcEdPromptEntityResult(AcEdPromptStatus.Keyword);
|
|
883
|
+
result.stringResult = error_8.keyword;
|
|
884
|
+
return [2 /*return*/, result];
|
|
885
|
+
}
|
|
886
|
+
throw error_8;
|
|
887
|
+
case 3: return [2 /*return*/];
|
|
527
888
|
}
|
|
528
|
-
};
|
|
529
|
-
document.addEventListener('keydown', keyHandler);
|
|
530
|
-
_this.view.canvas.addEventListener('mousedown', clickHandler);
|
|
889
|
+
});
|
|
531
890
|
});
|
|
532
891
|
};
|
|
533
892
|
/**
|
|
@@ -537,32 +896,39 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
537
896
|
*/
|
|
538
897
|
AcEdInputManager.prototype.getBox = function (options) {
|
|
539
898
|
return __awaiter(this, void 0, void 0, function () {
|
|
540
|
-
var message1, options1, p1,
|
|
899
|
+
var message1, options1, p1Result, p1, cwcsP1_1, previewEl_1, cleanup, drawPreview, message2, options2, p2, box, error_9;
|
|
541
900
|
var _this = this;
|
|
542
901
|
return __generator(this, function (_a) {
|
|
543
902
|
switch (_a.label) {
|
|
544
903
|
case 0:
|
|
545
|
-
|
|
904
|
+
_a.trys.push([0, 3, , 4]);
|
|
905
|
+
message1 = options.firstCornerMessage ||
|
|
906
|
+
AcApI18n.t('main.inputManager.firstCorner');
|
|
546
907
|
options1 = new AcEdPromptPointOptions(message1);
|
|
908
|
+
this.copyKeywords(options, options1);
|
|
547
909
|
options1.useDashedLine = options.useDashedLine;
|
|
548
910
|
options1.useBasePoint = options.useBasePoint;
|
|
549
911
|
return [4 /*yield*/, this.getPoint(options1)];
|
|
550
912
|
case 1:
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
913
|
+
p1Result = _a.sent();
|
|
914
|
+
if (p1Result.status !== AcEdPromptStatus.OK) {
|
|
915
|
+
return [2 /*return*/, new AcEdPromptBoxResult(p1Result.status, undefined, p1Result.stringResult)];
|
|
916
|
+
}
|
|
917
|
+
p1 = p1Result.value;
|
|
918
|
+
cwcsP1_1 = this.view.worldToScreen(p1);
|
|
919
|
+
previewEl_1 = document.createElement('div');
|
|
920
|
+
previewEl_1.className = 'ml-jig-preview-rect';
|
|
921
|
+
this.view.container.appendChild(previewEl_1);
|
|
556
922
|
cleanup = function () {
|
|
557
|
-
|
|
923
|
+
previewEl_1.remove();
|
|
558
924
|
};
|
|
559
925
|
drawPreview = function (pos) {
|
|
560
926
|
var cwcsP2 = _this.view.worldToScreen(pos);
|
|
561
|
-
var left = Math.min(cwcsP2.x,
|
|
562
|
-
var top = Math.min(cwcsP2.y,
|
|
563
|
-
var width = Math.abs(cwcsP2.x -
|
|
564
|
-
var height = Math.abs(cwcsP2.y -
|
|
565
|
-
Object.assign(
|
|
927
|
+
var left = Math.min(cwcsP2.x, cwcsP1_1.x);
|
|
928
|
+
var top = Math.min(cwcsP2.y, cwcsP1_1.y);
|
|
929
|
+
var width = Math.abs(cwcsP2.x - cwcsP1_1.x);
|
|
930
|
+
var height = Math.abs(cwcsP2.y - cwcsP1_1.y);
|
|
931
|
+
Object.assign(previewEl_1.style, {
|
|
566
932
|
left: "".concat(left, "px"),
|
|
567
933
|
top: "".concat(top, "px"),
|
|
568
934
|
width: "".concat(width, "px"),
|
|
@@ -572,12 +938,24 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
572
938
|
message2 = options.secondCornerMessage ||
|
|
573
939
|
AcApI18n.t('main.inputManager.secondCorner');
|
|
574
940
|
options2 = new AcEdPromptPointOptions(message2);
|
|
941
|
+
this.copyKeywords(options, options2);
|
|
575
942
|
options2.useDashedLine = options.useDashedLine;
|
|
576
943
|
options2.useBasePoint = options.useBasePoint;
|
|
577
944
|
return [4 /*yield*/, this.getPointInternal(options2, cleanup, drawPreview)];
|
|
578
945
|
case 2:
|
|
579
946
|
p2 = _a.sent();
|
|
580
|
-
|
|
947
|
+
box = new AcGeBox2d().expandByPoint(p1).expandByPoint(p2);
|
|
948
|
+
return [2 /*return*/, new AcEdPromptBoxResult(AcEdPromptStatus.OK, box)];
|
|
949
|
+
case 3:
|
|
950
|
+
error_9 = _a.sent();
|
|
951
|
+
if (this.isPromptCancelled(error_9)) {
|
|
952
|
+
return [2 /*return*/, new AcEdPromptBoxResult(AcEdPromptStatus.Cancel)];
|
|
953
|
+
}
|
|
954
|
+
if (this.isPromptKeyword(error_9)) {
|
|
955
|
+
return [2 /*return*/, new AcEdPromptBoxResult(AcEdPromptStatus.Keyword, undefined, error_9.keyword)];
|
|
956
|
+
}
|
|
957
|
+
throw error_9;
|
|
958
|
+
case 4: return [2 /*return*/];
|
|
581
959
|
}
|
|
582
960
|
});
|
|
583
961
|
});
|
|
@@ -587,33 +965,34 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
587
965
|
* typed input OR mouse click.
|
|
588
966
|
*/
|
|
589
967
|
AcEdInputManager.prototype.getPointInternal = function (options, cleanup, drawPreview) {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
value: { x: pos.x, y: pos.y, z: 0 },
|
|
599
|
-
raw: {
|
|
600
|
-
x: _this.formatNumber(pos.x, 'point'),
|
|
601
|
-
y: _this.formatNumber(pos.y, 'point')
|
|
968
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
969
|
+
var scriptedValue, getDynamicValue, handler;
|
|
970
|
+
var _this = this;
|
|
971
|
+
return __generator(this, function (_a) {
|
|
972
|
+
scriptedValue = this.tryGetScriptedPoint(options);
|
|
973
|
+
if (scriptedValue != null) {
|
|
974
|
+
cleanup === null || cleanup === void 0 ? void 0 : cleanup();
|
|
975
|
+
return [2 /*return*/, Promise.resolve(scriptedValue)];
|
|
602
976
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
977
|
+
getDynamicValue = function (pos) {
|
|
978
|
+
return {
|
|
979
|
+
value: { x: pos.x, y: pos.y, z: 0 },
|
|
980
|
+
raw: {
|
|
981
|
+
x: _this.formatNumber(pos.x, 'point'),
|
|
982
|
+
y: _this.formatNumber(pos.y, 'point')
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
};
|
|
986
|
+
handler = new AcEdPointHandler(options);
|
|
987
|
+
return [2 /*return*/, this.makeFloatingInputPromise({
|
|
988
|
+
inputCount: 2,
|
|
989
|
+
promptOptions: options,
|
|
990
|
+
cleanup: cleanup,
|
|
991
|
+
handler: handler,
|
|
992
|
+
getDynamicValue: getDynamicValue,
|
|
993
|
+
drawPreview: drawPreview
|
|
994
|
+
})];
|
|
995
|
+
});
|
|
617
996
|
});
|
|
618
997
|
};
|
|
619
998
|
/**
|
|
@@ -673,6 +1052,34 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
673
1052
|
return undefined;
|
|
674
1053
|
return { x: parts[0], y: parts[1] };
|
|
675
1054
|
};
|
|
1055
|
+
AcEdInputManager.prototype.isPromptCancelled = function (error) {
|
|
1056
|
+
return error instanceof Error && error.message === 'cancelled';
|
|
1057
|
+
};
|
|
1058
|
+
AcEdInputManager.prototype.updateModifierStateFromEvent = function (e) {
|
|
1059
|
+
var next = {
|
|
1060
|
+
ctrlKey: !!e.ctrlKey,
|
|
1061
|
+
shiftKey: !!e.shiftKey,
|
|
1062
|
+
altKey: !!e.altKey,
|
|
1063
|
+
metaKey: !!e.metaKey
|
|
1064
|
+
};
|
|
1065
|
+
var prev = this._modifierState;
|
|
1066
|
+
var changed = prev.ctrlKey !== next.ctrlKey ||
|
|
1067
|
+
prev.shiftKey !== next.shiftKey ||
|
|
1068
|
+
prev.altKey !== next.altKey ||
|
|
1069
|
+
prev.metaKey !== next.metaKey;
|
|
1070
|
+
if (changed) {
|
|
1071
|
+
this._modifierState = next;
|
|
1072
|
+
}
|
|
1073
|
+
return changed;
|
|
1074
|
+
};
|
|
1075
|
+
AcEdInputManager.prototype.handleCtrlToggleKey = function (e) {
|
|
1076
|
+
if (e.key !== 'Control' || e.repeat)
|
|
1077
|
+
return false;
|
|
1078
|
+
if (e.type !== 'keydown')
|
|
1079
|
+
return false;
|
|
1080
|
+
this._ctrlArcFlip = !this._ctrlArcFlip;
|
|
1081
|
+
return true;
|
|
1082
|
+
};
|
|
676
1083
|
/**
|
|
677
1084
|
* Creates a promise for floating input that will be resolved or rejected by user input.
|
|
678
1085
|
*
|
|
@@ -680,86 +1087,143 @@ var AcEdInputManager = /** @class */ (function () {
|
|
|
680
1087
|
* including handling the Escape key to cancel, resolving with user-provided
|
|
681
1088
|
* values, and guaranteeing cleanup of UI elements and event handlers.
|
|
682
1089
|
*/
|
|
1090
|
+
AcEdInputManager.prototype.resolvePromptDefaults = function (options) {
|
|
1091
|
+
var hasBasePoint = 'basePoint' in options;
|
|
1092
|
+
var hasUseBasePoint = 'useBasePoint' in options;
|
|
1093
|
+
var hasUseDashedLine = 'useDashedLine' in options;
|
|
1094
|
+
var basePoint = hasBasePoint && options.basePoint
|
|
1095
|
+
? options.basePoint
|
|
1096
|
+
: undefined;
|
|
1097
|
+
var useBasePoint = hasUseBasePoint ? options.useBasePoint : false;
|
|
1098
|
+
var showBaseLineOnly = hasUseDashedLine ? !options.useDashedLine : false;
|
|
1099
|
+
return {
|
|
1100
|
+
message: options.message,
|
|
1101
|
+
jig: options.jig,
|
|
1102
|
+
basePoint: basePoint,
|
|
1103
|
+
useBasePoint: useBasePoint,
|
|
1104
|
+
showBaseLineOnly: showBaseLineOnly
|
|
1105
|
+
};
|
|
1106
|
+
};
|
|
683
1107
|
AcEdInputManager.prototype.makeFloatingInputPromise = function (options) {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
1108
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1109
|
+
var _this = this;
|
|
1110
|
+
return __generator(this, function (_a) {
|
|
1111
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
1112
|
+
_this.active = true;
|
|
1113
|
+
_this.entitySelectionActive = false;
|
|
1114
|
+
var settled = false;
|
|
1115
|
+
var validate = function (raw) {
|
|
1116
|
+
var value = options.handler.parse(raw.x, raw.y);
|
|
1117
|
+
return {
|
|
1118
|
+
isValid: value != null,
|
|
1119
|
+
value: value !== null && value !== void 0 ? value : undefined
|
|
1120
|
+
};
|
|
1121
|
+
};
|
|
1122
|
+
var promptDefaults = _this.resolvePromptDefaults(options.promptOptions);
|
|
1123
|
+
var keywordSession = _this.startKeywordSession(options.promptOptions, true);
|
|
1124
|
+
var basePoint = undefined;
|
|
1125
|
+
if (promptDefaults.useBasePoint) {
|
|
1126
|
+
if (promptDefaults.basePoint) {
|
|
1127
|
+
basePoint = promptDefaults.basePoint;
|
|
1128
|
+
}
|
|
1129
|
+
else if (_this.lastPoint) {
|
|
1130
|
+
basePoint = { x: _this.lastPoint.x, y: _this.lastPoint.y };
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
var commandLineMessage = promptDefaults.message;
|
|
1134
|
+
if (!keywordSession) {
|
|
1135
|
+
_this._commandLine.setPrompt(commandLineMessage);
|
|
1136
|
+
}
|
|
1137
|
+
var floatingInput = new AcEdFloatingInput(_this.view, {
|
|
1138
|
+
parent: _this.view.canvas,
|
|
1139
|
+
inputCount: options.inputCount,
|
|
1140
|
+
message: promptDefaults.message,
|
|
1141
|
+
disableOSnap: options.disableOSnap,
|
|
1142
|
+
showBaseLineOnly: promptDefaults.showBaseLineOnly,
|
|
1143
|
+
basePoint: basePoint,
|
|
1144
|
+
allowPrompt: options.allowPrompt !== false,
|
|
1145
|
+
validate: validate,
|
|
1146
|
+
getDynamicValue: options.getDynamicValue,
|
|
1147
|
+
drawPreview: function (pos) {
|
|
1148
|
+
var _a;
|
|
1149
|
+
if (promptDefaults.jig) {
|
|
1150
|
+
var defaults = options.getDynamicValue(pos);
|
|
1151
|
+
promptDefaults.jig.update(defaults.value);
|
|
1152
|
+
promptDefaults.jig.render();
|
|
1153
|
+
}
|
|
1154
|
+
(_a = options.drawPreview) === null || _a === void 0 ? void 0 : _a.call(options, pos);
|
|
1155
|
+
},
|
|
1156
|
+
onCommit: function (val) {
|
|
1157
|
+
var result = false;
|
|
1158
|
+
if (!options.onCommit || options.onCommit(val)) {
|
|
1159
|
+
resolver(val);
|
|
1160
|
+
result = true;
|
|
1161
|
+
}
|
|
1162
|
+
if (floatingInput.lastPoint) {
|
|
1163
|
+
_this.lastPoint = {
|
|
1164
|
+
x: floatingInput.lastPoint.x,
|
|
1165
|
+
y: floatingInput.lastPoint.y
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
return result;
|
|
1169
|
+
},
|
|
1170
|
+
onCancel: function () { return rejector(); }
|
|
1171
|
+
});
|
|
1172
|
+
var cleanup = function () {
|
|
1173
|
+
var _a, _b;
|
|
1174
|
+
if (settled)
|
|
1175
|
+
return;
|
|
1176
|
+
settled = true;
|
|
1177
|
+
_this.active = false;
|
|
1178
|
+
_this.entitySelectionActive = false;
|
|
1179
|
+
(_a = options.cleanup) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
1180
|
+
(_b = promptDefaults.jig) === null || _b === void 0 ? void 0 : _b.end();
|
|
1181
|
+
document.removeEventListener('keydown', escHandler);
|
|
1182
|
+
document.removeEventListener('keydown', modifierHandler);
|
|
1183
|
+
document.removeEventListener('keyup', modifierHandler);
|
|
1184
|
+
floatingInput.dispose();
|
|
1185
|
+
keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.cancel();
|
|
1186
|
+
_this._commandLine.clear();
|
|
1187
|
+
};
|
|
1188
|
+
var resolver = function (value) {
|
|
1189
|
+
cleanup();
|
|
1190
|
+
resolve(value);
|
|
732
1191
|
};
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
1192
|
+
var rejector = function (err) {
|
|
1193
|
+
cleanup();
|
|
1194
|
+
reject(err !== null && err !== void 0 ? err : new Error('cancelled'));
|
|
1195
|
+
};
|
|
1196
|
+
var keywordRejector = function (keyword) {
|
|
1197
|
+
rejector(new AcEdKeywordInputError(keyword));
|
|
1198
|
+
};
|
|
1199
|
+
var escHandler = function (e) {
|
|
1200
|
+
if (e.key === 'Escape') {
|
|
1201
|
+
rejector();
|
|
1202
|
+
}
|
|
1203
|
+
};
|
|
1204
|
+
var modifierHandler = function (e) {
|
|
1205
|
+
var toggled = _this.handleCtrlToggleKey(e);
|
|
1206
|
+
var changed = _this.updateModifierStateFromEvent(e);
|
|
1207
|
+
if (toggled || changed) {
|
|
1208
|
+
floatingInput.requestPreviewRefresh();
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
document.addEventListener('keydown', escHandler);
|
|
1212
|
+
document.addEventListener('keydown', modifierHandler);
|
|
1213
|
+
document.addEventListener('keyup', modifierHandler);
|
|
1214
|
+
// showAt() expects viewport coordinates; curMousePos is canvas-local.
|
|
1215
|
+
floatingInput.showAt(_this.view.canvasToViewport(_this.view.curMousePos));
|
|
1216
|
+
keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.promise.then(function (keyword) {
|
|
1217
|
+
if (settled)
|
|
1218
|
+
return;
|
|
1219
|
+
if (!keyword) {
|
|
1220
|
+
rejector();
|
|
1221
|
+
return;
|
|
1222
|
+
}
|
|
1223
|
+
keywordRejector(keyword);
|
|
1224
|
+
});
|
|
1225
|
+
})];
|
|
737
1226
|
});
|
|
738
|
-
var cleanup = function () {
|
|
739
|
-
var _a, _b;
|
|
740
|
-
_this.active = false;
|
|
741
|
-
(_a = options.cleanup) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
742
|
-
(_b = options.jig) === null || _b === void 0 ? void 0 : _b.end();
|
|
743
|
-
document.removeEventListener('keydown', escHandler);
|
|
744
|
-
floatingInput.dispose();
|
|
745
|
-
_this._commandLine.clear();
|
|
746
|
-
};
|
|
747
|
-
var resolver = function (value) {
|
|
748
|
-
cleanup();
|
|
749
|
-
resolve(value);
|
|
750
|
-
};
|
|
751
|
-
var rejector = function () {
|
|
752
|
-
cleanup();
|
|
753
|
-
reject(new Error('cancelled'));
|
|
754
|
-
};
|
|
755
|
-
var escHandler = function (e) {
|
|
756
|
-
if (e.key === 'Escape') {
|
|
757
|
-
rejector();
|
|
758
|
-
}
|
|
759
|
-
};
|
|
760
|
-
document.addEventListener('keydown', escHandler);
|
|
761
|
-
// showAt() expects viewport coordinates; curMousePos is canvas-local.
|
|
762
|
-
floatingInput.showAt(_this.view.canvasToViewport(_this.view.curMousePos));
|
|
763
1227
|
});
|
|
764
1228
|
};
|
|
765
1229
|
/** Inject styles only once */
|