@mlightcad/cad-simple-viewer 1.4.12 → 1.4.13
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 +15901 -10590
- package/dist/index.umd.cjs +55 -48
- package/dist/libredwg-parser-worker.js +4724 -4762
- package/lib/app/AcApDocManager.d.ts +60 -4
- package/lib/app/AcApDocManager.d.ts.map +1 -1
- package/lib/app/AcApDocManager.js +160 -33
- package/lib/app/AcApDocManager.js.map +1 -1
- package/lib/command/AcApArcCmd.d.ts.map +1 -1
- package/lib/command/AcApArcCmd.js +1 -1
- package/lib/command/AcApArcCmd.js.map +1 -1
- package/lib/command/AcApCircleCmd.d.ts +59 -0
- package/lib/command/AcApCircleCmd.d.ts.map +1 -1
- package/lib/command/AcApCircleCmd.js +489 -18
- package/lib/command/AcApCircleCmd.js.map +1 -1
- package/lib/command/AcApConvertToPngCmd.d.ts +35 -0
- package/lib/command/AcApConvertToPngCmd.d.ts.map +1 -0
- package/lib/command/{AcApZoomToBoxCmd.js → AcApConvertToPngCmd.js} +50 -26
- package/lib/command/AcApConvertToPngCmd.js.map +1 -0
- package/lib/command/AcApEllipseCmd.d.ts +87 -0
- package/lib/command/AcApEllipseCmd.d.ts.map +1 -0
- package/lib/command/AcApEllipseCmd.js +583 -0
- package/lib/command/AcApEllipseCmd.js.map +1 -0
- package/lib/command/AcApHatchCmd.d.ts +210 -0
- package/lib/command/AcApHatchCmd.d.ts.map +1 -0
- package/lib/command/AcApHatchCmd.js +808 -0
- package/lib/command/AcApHatchCmd.js.map +1 -0
- package/lib/command/AcApLayerCmd.d.ts +217 -0
- package/lib/command/AcApLayerCmd.d.ts.map +1 -0
- package/lib/command/AcApLayerCmd.js +768 -0
- package/lib/command/AcApLayerCmd.js.map +1 -0
- package/lib/command/AcApLineCmd.d.ts +36 -1
- package/lib/command/AcApLineCmd.d.ts.map +1 -1
- package/lib/command/AcApLineCmd.js +157 -20
- package/lib/command/AcApLineCmd.js.map +1 -1
- package/lib/command/AcApMeasureAreaCmd.d.ts.map +1 -1
- package/lib/command/AcApMeasureAreaCmd.js +3 -0
- package/lib/command/AcApMeasureAreaCmd.js.map +1 -1
- package/lib/command/AcApMoveCmd.d.ts +16 -0
- package/lib/command/AcApMoveCmd.d.ts.map +1 -0
- package/lib/command/AcApMoveCmd.js +278 -0
- package/lib/command/AcApMoveCmd.js.map +1 -0
- package/lib/command/AcApPngConvertor.d.ts +95 -0
- package/lib/command/AcApPngConvertor.d.ts.map +1 -0
- package/lib/command/AcApPngConvertor.js +205 -0
- package/lib/command/AcApPngConvertor.js.map +1 -0
- package/lib/command/AcApPolygonCmd.d.ts +69 -0
- package/lib/command/AcApPolygonCmd.d.ts.map +1 -0
- package/lib/command/AcApPolygonCmd.js +422 -0
- package/lib/command/AcApPolygonCmd.js.map +1 -0
- package/lib/command/AcApRectCmd.d.ts +149 -4
- package/lib/command/AcApRectCmd.d.ts.map +1 -1
- package/lib/command/AcApRectCmd.js +716 -34
- package/lib/command/AcApRectCmd.js.map +1 -1
- package/lib/command/AcApRevCircleCmd.d.ts +8 -0
- package/lib/command/AcApRevCircleCmd.d.ts.map +1 -1
- package/lib/command/AcApRevCircleCmd.js +30 -6
- package/lib/command/AcApRevCircleCmd.js.map +1 -1
- package/lib/command/AcApRevRectCmd.d.ts +8 -0
- package/lib/command/AcApRevRectCmd.d.ts.map +1 -1
- package/lib/command/AcApRevRectCmd.js +78 -6
- package/lib/command/AcApRevRectCmd.js.map +1 -1
- package/lib/command/AcApSplineCmd.d.ts +66 -1
- package/lib/command/AcApSplineCmd.d.ts.map +1 -1
- package/lib/command/AcApSplineCmd.js +466 -59
- package/lib/command/AcApSplineCmd.js.map +1 -1
- package/lib/command/AcApZoomCmd.d.ts +91 -20
- package/lib/command/AcApZoomCmd.d.ts.map +1 -1
- package/lib/command/AcApZoomCmd.js +288 -23
- package/lib/command/AcApZoomCmd.js.map +1 -1
- package/lib/command/index.d.ts +7 -1
- package/lib/command/index.d.ts.map +1 -1
- package/lib/command/index.js +7 -1
- package/lib/command/index.js.map +1 -1
- package/lib/editor/command/AcEdCommandStack.d.ts +54 -1
- package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -1
- package/lib/editor/command/AcEdCommandStack.js +207 -25
- package/lib/editor/command/AcEdCommandStack.js.map +1 -1
- package/lib/editor/input/AcEdSelectionFilter.d.ts +79 -0
- package/lib/editor/input/AcEdSelectionFilter.d.ts.map +1 -0
- package/lib/editor/input/AcEdSelectionFilter.js +231 -0
- package/lib/editor/input/AcEdSelectionFilter.js.map +1 -0
- package/lib/editor/input/AcEditor.d.ts +20 -2
- package/lib/editor/input/AcEditor.d.ts.map +1 -1
- package/lib/editor/input/AcEditor.js +66 -0
- package/lib/editor/input/AcEditor.js.map +1 -1
- package/lib/editor/input/index.d.ts +1 -0
- package/lib/editor/input/index.d.ts.map +1 -1
- package/lib/editor/input/index.js +1 -0
- package/lib/editor/input/index.js.map +1 -1
- package/lib/editor/input/prompt/AcEdKeywordCollection.d.ts +47 -0
- package/lib/editor/input/prompt/AcEdKeywordCollection.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdKeywordCollection.js +19 -0
- package/lib/editor/input/prompt/AcEdKeywordCollection.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts +7 -0
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.js +17 -0
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptEntityOptions.d.ts +17 -0
- package/lib/editor/input/prompt/AcEdPromptEntityOptions.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptEntityOptions.js +30 -3
- package/lib/editor/input/prompt/AcEdPromptEntityOptions.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptOptions.d.ts +6 -1
- package/lib/editor/input/prompt/AcEdPromptOptions.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptOptions.js +7 -0
- package/lib/editor/input/prompt/AcEdPromptOptions.js.map +1 -1
- package/lib/editor/input/session/AcEdKeywordSession.d.ts +65 -0
- package/lib/editor/input/session/AcEdKeywordSession.d.ts.map +1 -1
- package/lib/editor/input/session/AcEdKeywordSession.js +71 -0
- package/lib/editor/input/session/AcEdKeywordSession.js.map +1 -1
- package/lib/editor/input/ui/AcEdCommandLine.d.ts +23 -0
- package/lib/editor/input/ui/AcEdCommandLine.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdCommandLine.js +42 -6
- package/lib/editor/input/ui/AcEdCommandLine.js.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInput.d.ts +1 -0
- package/lib/editor/input/ui/AcEdFloatingInput.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInput.js +8 -2
- package/lib/editor/input/ui/AcEdFloatingInput.js.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.d.ts +23 -1
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.js +32 -9
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.js.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInputTypes.d.ts +28 -0
- package/lib/editor/input/ui/AcEdFloatingInputTypes.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdInputManager.d.ts +356 -16
- package/lib/editor/input/ui/AcEdInputManager.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdInputManager.js +964 -529
- package/lib/editor/input/ui/AcEdInputManager.js.map +1 -1
- package/lib/editor/input/ui/AcEdRubberBand.d.ts +15 -1
- package/lib/editor/input/ui/AcEdRubberBand.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdRubberBand.js +42 -10
- package/lib/editor/input/ui/AcEdRubberBand.js.map +1 -1
- package/lib/i18n/en/command.d.ts +21 -3
- package/lib/i18n/en/command.d.ts.map +1 -1
- package/lib/i18n/en/command.js +21 -3
- package/lib/i18n/en/command.js.map +1 -1
- package/lib/i18n/en/jig.d.ts +443 -0
- package/lib/i18n/en/jig.d.ts.map +1 -1
- package/lib/i18n/en/jig.js +452 -9
- package/lib/i18n/en/jig.js.map +1 -1
- package/lib/i18n/zh/command.d.ts +21 -3
- package/lib/i18n/zh/command.d.ts.map +1 -1
- package/lib/i18n/zh/command.js +21 -3
- package/lib/i18n/zh/command.js.map +1 -1
- package/lib/i18n/zh/jig.d.ts +443 -0
- package/lib/i18n/zh/jig.d.ts.map +1 -1
- package/lib/i18n/zh/jig.js +452 -9
- package/lib/i18n/zh/jig.js.map +1 -1
- package/lib/plugin/AcApPluginManager.d.ts.map +1 -1
- package/lib/plugin/AcApPluginManager.js.map +1 -1
- package/lib/view/AcTrLayer.d.ts.map +1 -1
- package/lib/view/AcTrLayer.js +5 -3
- package/lib/view/AcTrLayer.js.map +1 -1
- package/lib/view/AcTrView2d.d.ts +0 -1
- package/lib/view/AcTrView2d.d.ts.map +1 -1
- package/lib/view/AcTrView2d.js +17 -4
- package/lib/view/AcTrView2d.js.map +1 -1
- package/package.json +11 -9
- package/lib/command/AcApZoomToBoxCmd.d.ts +0 -29
- package/lib/command/AcApZoomToBoxCmd.d.ts.map +0 -1
- package/lib/command/AcApZoomToBoxCmd.js.map +0 -1
|
@@ -49,91 +49,773 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
import { AcDbPolyline, AcGePoint2d } from '@mlightcad/data-model';
|
|
52
|
+
import { AcDbPolyline, AcGePoint2d, AcGePoint3d } from '@mlightcad/data-model';
|
|
53
53
|
import { AcApDocManager } from '../app';
|
|
54
|
-
import { AcEdCommand, AcEdOpenMode, AcEdPreviewJig, AcEdPromptPointOptions, AcEdPromptStatus } from '../editor';
|
|
54
|
+
import { AcEdCommand, AcEdOpenMode, AcEdPreviewJig, AcEdPromptAngleOptions, AcEdPromptDoubleOptions, AcEdPromptPointOptions, AcEdPromptStateMachine, AcEdPromptStatus, eventBus } from '../editor';
|
|
55
55
|
import { AcApI18n } from '../i18n';
|
|
56
|
-
|
|
56
|
+
var EPSILON = 1e-9;
|
|
57
|
+
var FILLET_BULGE_BASE = Math.tan(Math.PI / 8);
|
|
58
|
+
var DEFAULT_RECT_SETTINGS = {
|
|
59
|
+
chamferDist1: 0,
|
|
60
|
+
chamferDist2: 0,
|
|
61
|
+
filletRadius: 0,
|
|
62
|
+
width: 0,
|
|
63
|
+
elevation: 0,
|
|
64
|
+
thickness: 0,
|
|
65
|
+
rotation: 0
|
|
66
|
+
};
|
|
67
|
+
function addKeyword(prompt, key) {
|
|
68
|
+
prompt.keywords.add(AcApI18n.t("jig.rect.keywords.".concat(key, ".display")), AcApI18n.t("jig.rect.keywords.".concat(key, ".global")), AcApI18n.t("jig.rect.keywords.".concat(key, ".local")));
|
|
69
|
+
}
|
|
70
|
+
function addDoubleKeyword(prompt, key) {
|
|
71
|
+
prompt.keywords.add(AcApI18n.t("jig.rect.keywords.".concat(key, ".display")), AcApI18n.t("jig.rect.keywords.".concat(key, ".global")), AcApI18n.t("jig.rect.keywords.".concat(key, ".local")));
|
|
72
|
+
}
|
|
73
|
+
function warnRectMessage(key) {
|
|
74
|
+
eventBus.emit('message', {
|
|
75
|
+
message: AcApI18n.t("jig.rect.".concat(key)),
|
|
76
|
+
type: 'warning'
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function toWorldPoint(origin, local, rotation) {
|
|
80
|
+
var cos = Math.cos(rotation);
|
|
81
|
+
var sin = Math.sin(rotation);
|
|
82
|
+
return new AcGePoint2d(origin.x + local.x * cos - local.y * sin, origin.y + local.x * sin + local.y * cos);
|
|
83
|
+
}
|
|
84
|
+
function toLocalVector(origin, point, rotation) {
|
|
85
|
+
var dx = point.x - origin.x;
|
|
86
|
+
var dy = point.y - origin.y;
|
|
87
|
+
var cos = Math.cos(rotation);
|
|
88
|
+
var sin = Math.sin(rotation);
|
|
89
|
+
return new AcGePoint2d(dx * cos + dy * sin, -dx * sin + dy * cos);
|
|
90
|
+
}
|
|
91
|
+
function normalizeNonNegative(value) {
|
|
92
|
+
if (!Number.isFinite(value !== null && value !== void 0 ? value : NaN))
|
|
93
|
+
return 0;
|
|
94
|
+
return Math.max(0, value !== null && value !== void 0 ? value : 0);
|
|
95
|
+
}
|
|
96
|
+
function buildSquareVertices(lx, ly) {
|
|
97
|
+
return [
|
|
98
|
+
{ point: new AcGePoint2d(0, 0) },
|
|
99
|
+
{ point: new AcGePoint2d(lx, 0) },
|
|
100
|
+
{ point: new AcGePoint2d(lx, ly) },
|
|
101
|
+
{ point: new AcGePoint2d(0, ly) }
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
function buildChamferVertices(lx, ly, distance1, distance2) {
|
|
105
|
+
var sx = lx >= 0 ? 1 : -1;
|
|
106
|
+
var sy = ly >= 0 ? 1 : -1;
|
|
107
|
+
var absX = Math.abs(lx);
|
|
108
|
+
var absY = Math.abs(ly);
|
|
109
|
+
var d1 = Math.min(normalizeNonNegative(distance1), absX / 2);
|
|
110
|
+
var d2 = Math.min(normalizeNonNegative(distance2), absY / 2);
|
|
111
|
+
if (d1 <= EPSILON && d2 <= EPSILON) {
|
|
112
|
+
return buildSquareVertices(lx, ly);
|
|
113
|
+
}
|
|
114
|
+
var c1Out = new AcGePoint2d(sx * d1, 0);
|
|
115
|
+
var c1In = new AcGePoint2d(0, sy * d2);
|
|
116
|
+
var c2In = new AcGePoint2d(lx - sx * d1, 0);
|
|
117
|
+
var c2Out = new AcGePoint2d(lx, sy * d2);
|
|
118
|
+
var c3In = new AcGePoint2d(lx, ly - sy * d2);
|
|
119
|
+
var c3Out = new AcGePoint2d(lx - sx * d1, ly);
|
|
120
|
+
var c4In = new AcGePoint2d(sx * d1, ly);
|
|
121
|
+
var c4Out = new AcGePoint2d(0, ly - sy * d2);
|
|
122
|
+
return [
|
|
123
|
+
{ point: c1Out },
|
|
124
|
+
{ point: c2In },
|
|
125
|
+
{ point: c2Out },
|
|
126
|
+
{ point: c3In },
|
|
127
|
+
{ point: c3Out },
|
|
128
|
+
{ point: c4In },
|
|
129
|
+
{ point: c4Out },
|
|
130
|
+
{ point: c1In }
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
function buildFilletVertices(lx, ly, radius) {
|
|
134
|
+
var absX = Math.abs(lx);
|
|
135
|
+
var absY = Math.abs(ly);
|
|
136
|
+
var r = Math.min(normalizeNonNegative(radius), absX / 2, absY / 2);
|
|
137
|
+
if (r <= EPSILON)
|
|
138
|
+
return buildSquareVertices(lx, ly);
|
|
139
|
+
var chamferLike = buildChamferVertices(lx, ly, r, r);
|
|
140
|
+
var orientation = lx * ly >= 0 ? 1 : -1;
|
|
141
|
+
var bulge = orientation * FILLET_BULGE_BASE;
|
|
142
|
+
// Arc segments are: c2In->c2Out, c3In->c3Out, c4In->c4Out, c1In->c1Out(closed).
|
|
143
|
+
// These are represented by bulge on vertices 1, 3, 5, 7 respectively.
|
|
144
|
+
return chamferLike.map(function (vertex, index) { return ({
|
|
145
|
+
point: vertex.point,
|
|
146
|
+
bulge: index % 2 === 1 ? bulge : undefined
|
|
147
|
+
}); });
|
|
148
|
+
}
|
|
149
|
+
function resolveRectVertices(lx, ly, settings) {
|
|
150
|
+
if (settings.filletRadius > EPSILON) {
|
|
151
|
+
return buildFilletVertices(lx, ly, settings.filletRadius);
|
|
152
|
+
}
|
|
153
|
+
if (settings.chamferDist1 > EPSILON || settings.chamferDist2 > EPSILON) {
|
|
154
|
+
return buildChamferVertices(lx, ly, settings.chamferDist1, settings.chamferDist2);
|
|
155
|
+
}
|
|
156
|
+
return buildSquareVertices(lx, ly);
|
|
157
|
+
}
|
|
158
|
+
function updateRect(rect, firstPoint, input, settings) {
|
|
159
|
+
var lx = 0;
|
|
160
|
+
var ly = 0;
|
|
161
|
+
if (input.mode === 'corner') {
|
|
162
|
+
var local = toLocalVector(firstPoint, input.secondPoint, settings.rotation);
|
|
163
|
+
lx = local.x;
|
|
164
|
+
ly = local.y;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
lx = input.length;
|
|
168
|
+
ly = input.width;
|
|
169
|
+
}
|
|
170
|
+
if (Math.abs(lx) <= EPSILON || Math.abs(ly) <= EPSILON)
|
|
171
|
+
return false;
|
|
57
172
|
rect.reset(false);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
173
|
+
var vertices = resolveRectVertices(lx, ly, settings);
|
|
174
|
+
var segWidth = normalizeNonNegative(settings.width);
|
|
175
|
+
vertices.forEach(function (vertex, index) {
|
|
176
|
+
var worldPoint = toWorldPoint(firstPoint, vertex.point, settings.rotation);
|
|
177
|
+
if (segWidth > EPSILON) {
|
|
178
|
+
rect.addVertexAt(index, worldPoint, vertex.bulge, segWidth, segWidth);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
rect.addVertexAt(index, worldPoint, vertex.bulge);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
rect.elevation = settings.elevation;
|
|
67
185
|
rect.closed = true;
|
|
186
|
+
return true;
|
|
68
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Dynamic preview jig for RECT command.
|
|
190
|
+
*/
|
|
69
191
|
var AcApRectJig = /** @class */ (function (_super) {
|
|
70
192
|
__extends(AcApRectJig, _super);
|
|
71
193
|
/**
|
|
72
|
-
* Creates a
|
|
194
|
+
* Creates a dynamic rectangle preview jig.
|
|
73
195
|
*
|
|
74
|
-
* @param view -
|
|
196
|
+
* @param view - Active editor view used to render transient geometry.
|
|
197
|
+
* @param start - First corner point of the rectangle.
|
|
198
|
+
* @param settingsProvider - Callback that returns current command settings.
|
|
75
199
|
*/
|
|
76
|
-
function AcApRectJig(view, start) {
|
|
200
|
+
function AcApRectJig(view, start, settingsProvider) {
|
|
77
201
|
var _this = _super.call(this, view) || this;
|
|
78
202
|
_this._rect = new AcDbPolyline();
|
|
79
203
|
_this._firstPoint = new AcGePoint2d(start);
|
|
204
|
+
_this._settingsProvider = settingsProvider;
|
|
80
205
|
return _this;
|
|
81
206
|
}
|
|
82
207
|
Object.defineProperty(AcApRectJig.prototype, "entity", {
|
|
208
|
+
/**
|
|
209
|
+
* Gets the transient polyline entity displayed by the jig.
|
|
210
|
+
*/
|
|
83
211
|
get: function () {
|
|
84
212
|
return this._rect;
|
|
85
213
|
},
|
|
86
214
|
enumerable: false,
|
|
87
215
|
configurable: true
|
|
88
216
|
});
|
|
217
|
+
/**
|
|
218
|
+
* Rebuilds preview geometry from the current cursor point.
|
|
219
|
+
*
|
|
220
|
+
* @param secondPoint - Dynamic opposite corner point under the cursor.
|
|
221
|
+
*/
|
|
89
222
|
AcApRectJig.prototype.update = function (secondPoint) {
|
|
90
|
-
updateRect(this._rect, this._firstPoint, secondPoint);
|
|
223
|
+
updateRect(this._rect, this._firstPoint, { mode: 'corner', secondPoint: secondPoint }, this._settingsProvider());
|
|
91
224
|
};
|
|
92
225
|
return AcApRectJig;
|
|
93
226
|
}(AcEdPreviewJig));
|
|
94
227
|
export { AcApRectJig };
|
|
95
228
|
/**
|
|
96
|
-
*
|
|
229
|
+
* Static rectangle preview jig used for non-point prompts (angle/number input).
|
|
230
|
+
*
|
|
231
|
+
* The geometry is built once in the constructor and then kept unchanged.
|
|
232
|
+
*
|
|
233
|
+
* @typeParam T - Prompt value type that drives this jig instance.
|
|
234
|
+
*/
|
|
235
|
+
var AcApRectStaticJig = /** @class */ (function (_super) {
|
|
236
|
+
__extends(AcApRectStaticJig, _super);
|
|
237
|
+
/**
|
|
238
|
+
* Creates a static preview jig with precomputed rectangle geometry.
|
|
239
|
+
*
|
|
240
|
+
* @param view - Active editor view.
|
|
241
|
+
* @param firstPoint - Rectangle base corner.
|
|
242
|
+
* @param input - Rectangle construction input (corner or dimensions).
|
|
243
|
+
* @param settings - Rectangle style/transform settings.
|
|
244
|
+
*/
|
|
245
|
+
function AcApRectStaticJig(view, firstPoint, input, settings) {
|
|
246
|
+
var _this = _super.call(this, view) || this;
|
|
247
|
+
_this._rect = new AcDbPolyline();
|
|
248
|
+
updateRect(_this._rect, firstPoint, input, settings);
|
|
249
|
+
return _this;
|
|
250
|
+
}
|
|
251
|
+
Object.defineProperty(AcApRectStaticJig.prototype, "entity", {
|
|
252
|
+
/**
|
|
253
|
+
* Gets the transient static rectangle entity.
|
|
254
|
+
*/
|
|
255
|
+
get: function () {
|
|
256
|
+
return this._rect;
|
|
257
|
+
},
|
|
258
|
+
enumerable: false,
|
|
259
|
+
configurable: true
|
|
260
|
+
});
|
|
261
|
+
/**
|
|
262
|
+
* No-op update hook required by preview jig interface.
|
|
263
|
+
*
|
|
264
|
+
* @param _value - Prompt value (unused for static preview).
|
|
265
|
+
*/
|
|
266
|
+
AcApRectStaticJig.prototype.update = function (_value) {
|
|
267
|
+
// No-op. Static preview.
|
|
268
|
+
};
|
|
269
|
+
return AcApRectStaticJig;
|
|
270
|
+
}(AcEdPreviewJig));
|
|
271
|
+
function cloneRectSettings(settings) {
|
|
272
|
+
return {
|
|
273
|
+
chamferDist1: settings.chamferDist1,
|
|
274
|
+
chamferDist2: settings.chamferDist2,
|
|
275
|
+
filletRadius: settings.filletRadius,
|
|
276
|
+
width: settings.width,
|
|
277
|
+
elevation: settings.elevation,
|
|
278
|
+
thickness: settings.thickness,
|
|
279
|
+
rotation: settings.rotation
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function isPositive(value) {
|
|
283
|
+
return Number.isFinite(value !== null && value !== void 0 ? value : NaN) && (value !== null && value !== void 0 ? value : 0) > EPSILON;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Command to create one rectangle with AutoCAD-like branching options.
|
|
97
287
|
*/
|
|
98
288
|
var AcApRectCmd = /** @class */ (function (_super) {
|
|
99
289
|
__extends(AcApRectCmd, _super);
|
|
290
|
+
/**
|
|
291
|
+
* Creates RECT command instance.
|
|
292
|
+
*/
|
|
100
293
|
function AcApRectCmd() {
|
|
101
294
|
var _this = _super.call(this) || this;
|
|
102
295
|
_this.mode = AcEdOpenMode.Write;
|
|
103
296
|
return _this;
|
|
104
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* Command entry point.
|
|
300
|
+
*
|
|
301
|
+
* Flow:
|
|
302
|
+
* 1. Prompt first corner and first-stage options.
|
|
303
|
+
* 2. Prompt second-corner input, dimensions, or area workflow.
|
|
304
|
+
* 3. Build final polyline and append it to model space.
|
|
305
|
+
*
|
|
306
|
+
* @param context - Current application/document context.
|
|
307
|
+
*/
|
|
105
308
|
AcApRectCmd.prototype.execute = function (context) {
|
|
106
309
|
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
-
var
|
|
310
|
+
var settings, firstPoint, secondInput, rect, isValid;
|
|
108
311
|
return __generator(this, function (_a) {
|
|
109
312
|
switch (_a.label) {
|
|
110
313
|
case 0:
|
|
111
|
-
|
|
112
|
-
return [4 /*yield*/,
|
|
314
|
+
settings = cloneRectSettings(AcApRectCmd._settings);
|
|
315
|
+
return [4 /*yield*/, this.promptFirstCorner(settings)];
|
|
113
316
|
case 1:
|
|
114
|
-
|
|
115
|
-
if (
|
|
317
|
+
firstPoint = _a.sent();
|
|
318
|
+
if (!firstPoint)
|
|
116
319
|
return [2 /*return*/];
|
|
117
|
-
|
|
118
|
-
secondPointPrompt = new AcEdPromptPointOptions(AcApI18n.t('jig.rect.nextPoint'));
|
|
119
|
-
secondPointPrompt.jig = new AcApRectJig(context.view, firstPoint);
|
|
120
|
-
secondPointPrompt.useDashedLine = false;
|
|
121
|
-
secondPointPrompt.useBasePoint = true;
|
|
122
|
-
return [4 /*yield*/, AcApDocManager.instance.editor.getPoint(secondPointPrompt)];
|
|
320
|
+
return [4 /*yield*/, this.promptSecondInput(context, firstPoint, settings)];
|
|
123
321
|
case 2:
|
|
124
|
-
|
|
125
|
-
if (
|
|
322
|
+
secondInput = _a.sent();
|
|
323
|
+
if (!secondInput)
|
|
126
324
|
return [2 /*return*/];
|
|
127
|
-
secondPoint = secondPointResult.value;
|
|
128
|
-
db = context.doc.database;
|
|
129
325
|
rect = new AcDbPolyline();
|
|
130
|
-
updateRect(rect, firstPoint,
|
|
131
|
-
|
|
326
|
+
isValid = updateRect(rect, firstPoint, secondInput, settings);
|
|
327
|
+
if (!isValid) {
|
|
328
|
+
warnRectMessage('invalidRect');
|
|
329
|
+
return [2 /*return*/];
|
|
330
|
+
}
|
|
331
|
+
if (settings.thickness > EPSILON) {
|
|
332
|
+
warnRectMessage('thicknessNotSupported');
|
|
333
|
+
}
|
|
334
|
+
context.doc.database.tables.blockTable.modelSpace.appendEntity(rect);
|
|
335
|
+
AcApRectCmd._settings = cloneRectSettings(settings);
|
|
132
336
|
return [2 /*return*/];
|
|
133
337
|
}
|
|
134
338
|
});
|
|
135
339
|
});
|
|
136
340
|
};
|
|
341
|
+
/**
|
|
342
|
+
* Prompts for the first rectangle corner while handling setup keywords.
|
|
343
|
+
*
|
|
344
|
+
* Supported options at this step: Chamfer, Elevation, Fillet, Thickness, Width.
|
|
345
|
+
*
|
|
346
|
+
* @param settings - Mutable settings object updated in-place by options.
|
|
347
|
+
* @returns First corner point, or `undefined` when user cancels.
|
|
348
|
+
*/
|
|
349
|
+
AcApRectCmd.prototype.promptFirstCorner = function (settings) {
|
|
350
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
351
|
+
var prompt_1, result, keyword, ok, ok, ok, ok, ok;
|
|
352
|
+
var _a;
|
|
353
|
+
return __generator(this, function (_b) {
|
|
354
|
+
switch (_b.label) {
|
|
355
|
+
case 0:
|
|
356
|
+
if (!true) return [3 /*break*/, 12];
|
|
357
|
+
prompt_1 = new AcEdPromptPointOptions(AcApI18n.t('jig.rect.firstPointWithOptions'));
|
|
358
|
+
addKeyword(prompt_1, 'chamfer');
|
|
359
|
+
addKeyword(prompt_1, 'elevation');
|
|
360
|
+
addKeyword(prompt_1, 'fillet');
|
|
361
|
+
addKeyword(prompt_1, 'thickness');
|
|
362
|
+
addKeyword(prompt_1, 'width');
|
|
363
|
+
return [4 /*yield*/, AcApDocManager.instance.editor.getPoint(prompt_1)];
|
|
364
|
+
case 1:
|
|
365
|
+
result = _b.sent();
|
|
366
|
+
if (result.status === AcEdPromptStatus.OK) {
|
|
367
|
+
return [2 /*return*/, result.value];
|
|
368
|
+
}
|
|
369
|
+
if (result.status !== AcEdPromptStatus.Keyword)
|
|
370
|
+
return [2 /*return*/, undefined];
|
|
371
|
+
keyword = (_a = result.stringResult) !== null && _a !== void 0 ? _a : '';
|
|
372
|
+
if (!(keyword === 'Chamfer')) return [3 /*break*/, 3];
|
|
373
|
+
return [4 /*yield*/, this.promptChamfer(settings)];
|
|
374
|
+
case 2:
|
|
375
|
+
ok = _b.sent();
|
|
376
|
+
if (!ok)
|
|
377
|
+
return [2 /*return*/, undefined];
|
|
378
|
+
return [3 /*break*/, 11];
|
|
379
|
+
case 3:
|
|
380
|
+
if (!(keyword === 'Elevation')) return [3 /*break*/, 5];
|
|
381
|
+
return [4 /*yield*/, this.promptElevation(settings)];
|
|
382
|
+
case 4:
|
|
383
|
+
ok = _b.sent();
|
|
384
|
+
if (!ok)
|
|
385
|
+
return [2 /*return*/, undefined];
|
|
386
|
+
return [3 /*break*/, 11];
|
|
387
|
+
case 5:
|
|
388
|
+
if (!(keyword === 'Fillet')) return [3 /*break*/, 7];
|
|
389
|
+
return [4 /*yield*/, this.promptFillet(settings)];
|
|
390
|
+
case 6:
|
|
391
|
+
ok = _b.sent();
|
|
392
|
+
if (!ok)
|
|
393
|
+
return [2 /*return*/, undefined];
|
|
394
|
+
return [3 /*break*/, 11];
|
|
395
|
+
case 7:
|
|
396
|
+
if (!(keyword === 'Thickness')) return [3 /*break*/, 9];
|
|
397
|
+
return [4 /*yield*/, this.promptThickness(settings)];
|
|
398
|
+
case 8:
|
|
399
|
+
ok = _b.sent();
|
|
400
|
+
if (!ok)
|
|
401
|
+
return [2 /*return*/, undefined];
|
|
402
|
+
return [3 /*break*/, 11];
|
|
403
|
+
case 9:
|
|
404
|
+
if (!(keyword === 'Width')) return [3 /*break*/, 11];
|
|
405
|
+
return [4 /*yield*/, this.promptWidth(settings)];
|
|
406
|
+
case 10:
|
|
407
|
+
ok = _b.sent();
|
|
408
|
+
if (!ok)
|
|
409
|
+
return [2 /*return*/, undefined];
|
|
410
|
+
_b.label = 11;
|
|
411
|
+
case 11: return [3 /*break*/, 0];
|
|
412
|
+
case 12: return [2 /*return*/];
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
};
|
|
417
|
+
/**
|
|
418
|
+
* Prompts for rectangle completion input after first corner is known.
|
|
419
|
+
*
|
|
420
|
+
* Supports direct opposite corner pick or switching to Area/Dimensions/Rotation
|
|
421
|
+
* branches through a point-prompt state machine.
|
|
422
|
+
*
|
|
423
|
+
* @param context - Current application/document context.
|
|
424
|
+
* @param firstPoint - First corner point.
|
|
425
|
+
* @param settings - Mutable rectangle settings used by preview/build.
|
|
426
|
+
* @returns Final rectangle build input, or `undefined` on cancel.
|
|
427
|
+
*/
|
|
428
|
+
AcApRectCmd.prototype.promptSecondInput = function (context, firstPoint, settings) {
|
|
429
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
430
|
+
var finalInput, CornerState, machine;
|
|
431
|
+
return __generator(this, function (_a) {
|
|
432
|
+
switch (_a.label) {
|
|
433
|
+
case 0:
|
|
434
|
+
CornerState = /** @class */ (function () {
|
|
435
|
+
/**
|
|
436
|
+
* Creates corner state handler.
|
|
437
|
+
*
|
|
438
|
+
* @param cmd - Owning RECT command instance.
|
|
439
|
+
*/
|
|
440
|
+
function CornerState(cmd) {
|
|
441
|
+
this.cmd = cmd;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Builds the point prompt for second-corner input.
|
|
445
|
+
*
|
|
446
|
+
* @returns Configured point prompt with keywords and preview jig.
|
|
447
|
+
*/
|
|
448
|
+
CornerState.prototype.buildPrompt = function () {
|
|
449
|
+
var prompt = new AcEdPromptPointOptions(AcApI18n.t('jig.rect.otherCornerWithOptions'));
|
|
450
|
+
addKeyword(prompt, 'area');
|
|
451
|
+
addKeyword(prompt, 'dimensions');
|
|
452
|
+
addKeyword(prompt, 'rotation');
|
|
453
|
+
prompt.useDashedLine = false;
|
|
454
|
+
prompt.useBasePoint = true;
|
|
455
|
+
prompt.basePoint = new AcGePoint3d(firstPoint);
|
|
456
|
+
prompt.jig = new AcApRectJig(context.view, firstPoint, function () { return settings; });
|
|
457
|
+
return prompt;
|
|
458
|
+
};
|
|
459
|
+
/**
|
|
460
|
+
* Handles point/keyword result and drives state transitions.
|
|
461
|
+
*
|
|
462
|
+
* @param result - User input result from point prompt.
|
|
463
|
+
* @returns State-machine step result.
|
|
464
|
+
*/
|
|
465
|
+
CornerState.prototype.handleResult = function (result) {
|
|
466
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
467
|
+
var keyword, ok, dims, dims;
|
|
468
|
+
var _a;
|
|
469
|
+
return __generator(this, function (_b) {
|
|
470
|
+
switch (_b.label) {
|
|
471
|
+
case 0:
|
|
472
|
+
if (result.status === AcEdPromptStatus.OK) {
|
|
473
|
+
finalInput = { mode: 'corner', secondPoint: result.value };
|
|
474
|
+
return [2 /*return*/, 'finish'];
|
|
475
|
+
}
|
|
476
|
+
if (result.status !== AcEdPromptStatus.Keyword)
|
|
477
|
+
return [2 /*return*/, 'finish'];
|
|
478
|
+
keyword = (_a = result.stringResult) !== null && _a !== void 0 ? _a : '';
|
|
479
|
+
if (!(keyword === 'Rotation')) return [3 /*break*/, 2];
|
|
480
|
+
return [4 /*yield*/, this.cmd.promptRotation(context, firstPoint, settings)];
|
|
481
|
+
case 1:
|
|
482
|
+
ok = _b.sent();
|
|
483
|
+
if (!ok)
|
|
484
|
+
return [2 /*return*/, 'finish'];
|
|
485
|
+
return [2 /*return*/, 'continue'];
|
|
486
|
+
case 2:
|
|
487
|
+
if (!(keyword === 'Dimensions')) return [3 /*break*/, 4];
|
|
488
|
+
return [4 /*yield*/, this.cmd.promptDimensions(context, firstPoint, settings)];
|
|
489
|
+
case 3:
|
|
490
|
+
dims = _b.sent();
|
|
491
|
+
if (!dims)
|
|
492
|
+
return [2 /*return*/, 'finish'];
|
|
493
|
+
finalInput = dims;
|
|
494
|
+
return [2 /*return*/, 'finish'];
|
|
495
|
+
case 4:
|
|
496
|
+
if (!(keyword === 'Area')) return [3 /*break*/, 6];
|
|
497
|
+
return [4 /*yield*/, this.cmd.promptArea(context, firstPoint, settings)];
|
|
498
|
+
case 5:
|
|
499
|
+
dims = _b.sent();
|
|
500
|
+
if (!dims)
|
|
501
|
+
return [2 /*return*/, 'finish'];
|
|
502
|
+
finalInput = dims;
|
|
503
|
+
return [2 /*return*/, 'finish'];
|
|
504
|
+
case 6: return [2 /*return*/, 'continue'];
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
};
|
|
509
|
+
return CornerState;
|
|
510
|
+
}());
|
|
511
|
+
machine = new AcEdPromptStateMachine();
|
|
512
|
+
machine.setState(new CornerState(this));
|
|
513
|
+
return [4 /*yield*/, machine.run(function (prompt) { return AcApDocManager.instance.editor.getPoint(prompt); })];
|
|
514
|
+
case 1:
|
|
515
|
+
_a.sent();
|
|
516
|
+
return [2 /*return*/, finalInput];
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* Prompts for a strictly positive numeric value.
|
|
523
|
+
*
|
|
524
|
+
* @param message - Prompt message text.
|
|
525
|
+
* @param jig - Optional preview jig displayed during input.
|
|
526
|
+
* @returns Positive number, or `undefined` when canceled.
|
|
527
|
+
*/
|
|
528
|
+
AcApRectCmd.prototype.promptPositiveDouble = function (message, jig) {
|
|
529
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
530
|
+
var prompt_2, result;
|
|
531
|
+
return __generator(this, function (_a) {
|
|
532
|
+
switch (_a.label) {
|
|
533
|
+
case 0:
|
|
534
|
+
if (!true) return [3 /*break*/, 2];
|
|
535
|
+
prompt_2 = new AcEdPromptDoubleOptions(message);
|
|
536
|
+
prompt_2.allowNegative = false;
|
|
537
|
+
prompt_2.allowZero = false;
|
|
538
|
+
if (jig)
|
|
539
|
+
prompt_2.jig = jig;
|
|
540
|
+
return [4 /*yield*/, AcApDocManager.instance.editor.getDouble(prompt_2)];
|
|
541
|
+
case 1:
|
|
542
|
+
result = _a.sent();
|
|
543
|
+
if (result.status !== AcEdPromptStatus.OK)
|
|
544
|
+
return [2 /*return*/, undefined];
|
|
545
|
+
if (isPositive(result.value))
|
|
546
|
+
return [2 /*return*/, result.value];
|
|
547
|
+
warnRectMessage('invalidPositive');
|
|
548
|
+
return [3 /*break*/, 0];
|
|
549
|
+
case 2: return [2 /*return*/];
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
});
|
|
553
|
+
};
|
|
554
|
+
/**
|
|
555
|
+
* Prompts chamfer distances and updates settings.
|
|
556
|
+
*
|
|
557
|
+
* Also clears fillet mode, because chamfer and fillet are mutually exclusive.
|
|
558
|
+
*
|
|
559
|
+
* @param settings - Mutable rectangle settings.
|
|
560
|
+
* @returns `true` when values are accepted, otherwise `false`.
|
|
561
|
+
*/
|
|
562
|
+
AcApRectCmd.prototype.promptChamfer = function (settings) {
|
|
563
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
564
|
+
var d1, d2;
|
|
565
|
+
return __generator(this, function (_a) {
|
|
566
|
+
switch (_a.label) {
|
|
567
|
+
case 0: return [4 /*yield*/, this.promptPositiveDouble(AcApI18n.t('jig.rect.chamferFirst'))];
|
|
568
|
+
case 1:
|
|
569
|
+
d1 = _a.sent();
|
|
570
|
+
if (!isPositive(d1))
|
|
571
|
+
return [2 /*return*/, false];
|
|
572
|
+
return [4 /*yield*/, this.promptPositiveDouble(AcApI18n.t('jig.rect.chamferSecond'))];
|
|
573
|
+
case 2:
|
|
574
|
+
d2 = _a.sent();
|
|
575
|
+
if (!isPositive(d2))
|
|
576
|
+
return [2 /*return*/, false];
|
|
577
|
+
settings.chamferDist1 = d1;
|
|
578
|
+
settings.chamferDist2 = d2;
|
|
579
|
+
settings.filletRadius = 0;
|
|
580
|
+
return [2 /*return*/, true];
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
};
|
|
585
|
+
/**
|
|
586
|
+
* Prompts fillet radius and updates settings.
|
|
587
|
+
*
|
|
588
|
+
* Also clears chamfer values, because fillet and chamfer are mutually exclusive.
|
|
589
|
+
*
|
|
590
|
+
* @param settings - Mutable rectangle settings.
|
|
591
|
+
* @returns `true` when value is accepted, otherwise `false`.
|
|
592
|
+
*/
|
|
593
|
+
AcApRectCmd.prototype.promptFillet = function (settings) {
|
|
594
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
595
|
+
var radius;
|
|
596
|
+
return __generator(this, function (_a) {
|
|
597
|
+
switch (_a.label) {
|
|
598
|
+
case 0: return [4 /*yield*/, this.promptPositiveDouble(AcApI18n.t('jig.rect.filletRadius'))];
|
|
599
|
+
case 1:
|
|
600
|
+
radius = _a.sent();
|
|
601
|
+
if (!isPositive(radius))
|
|
602
|
+
return [2 /*return*/, false];
|
|
603
|
+
settings.filletRadius = radius;
|
|
604
|
+
settings.chamferDist1 = 0;
|
|
605
|
+
settings.chamferDist2 = 0;
|
|
606
|
+
return [2 /*return*/, true];
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
});
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Prompts segment width and updates settings.
|
|
613
|
+
*
|
|
614
|
+
* @param settings - Mutable rectangle settings.
|
|
615
|
+
* @returns `true` when value is accepted, otherwise `false`.
|
|
616
|
+
*/
|
|
617
|
+
AcApRectCmd.prototype.promptWidth = function (settings) {
|
|
618
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
619
|
+
var prompt, result;
|
|
620
|
+
return __generator(this, function (_a) {
|
|
621
|
+
switch (_a.label) {
|
|
622
|
+
case 0:
|
|
623
|
+
prompt = new AcEdPromptDoubleOptions(AcApI18n.t('jig.rect.segmentWidth'));
|
|
624
|
+
prompt.allowNegative = false;
|
|
625
|
+
prompt.allowZero = true;
|
|
626
|
+
return [4 /*yield*/, AcApDocManager.instance.editor.getDouble(prompt)];
|
|
627
|
+
case 1:
|
|
628
|
+
result = _a.sent();
|
|
629
|
+
if (result.status !== AcEdPromptStatus.OK)
|
|
630
|
+
return [2 /*return*/, false];
|
|
631
|
+
settings.width = normalizeNonNegative(result.value);
|
|
632
|
+
return [2 /*return*/, true];
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
};
|
|
637
|
+
/**
|
|
638
|
+
* Prompts elevation and updates settings.
|
|
639
|
+
*
|
|
640
|
+
* @param settings - Mutable rectangle settings.
|
|
641
|
+
* @returns `true` when value is accepted, otherwise `false`.
|
|
642
|
+
*/
|
|
643
|
+
AcApRectCmd.prototype.promptElevation = function (settings) {
|
|
644
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
645
|
+
var prompt, result;
|
|
646
|
+
var _a;
|
|
647
|
+
return __generator(this, function (_b) {
|
|
648
|
+
switch (_b.label) {
|
|
649
|
+
case 0:
|
|
650
|
+
prompt = new AcEdPromptDoubleOptions(AcApI18n.t('jig.rect.elevationValue'));
|
|
651
|
+
prompt.allowNegative = true;
|
|
652
|
+
prompt.allowZero = true;
|
|
653
|
+
return [4 /*yield*/, AcApDocManager.instance.editor.getDouble(prompt)];
|
|
654
|
+
case 1:
|
|
655
|
+
result = _b.sent();
|
|
656
|
+
if (result.status !== AcEdPromptStatus.OK)
|
|
657
|
+
return [2 /*return*/, false];
|
|
658
|
+
settings.elevation = (_a = result.value) !== null && _a !== void 0 ? _a : 0;
|
|
659
|
+
return [2 /*return*/, true];
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
};
|
|
664
|
+
/**
|
|
665
|
+
* Prompts thickness and updates settings.
|
|
666
|
+
*
|
|
667
|
+
* @param settings - Mutable rectangle settings.
|
|
668
|
+
* @returns `true` when value is accepted, otherwise `false`.
|
|
669
|
+
*/
|
|
670
|
+
AcApRectCmd.prototype.promptThickness = function (settings) {
|
|
671
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
672
|
+
var prompt, result;
|
|
673
|
+
return __generator(this, function (_a) {
|
|
674
|
+
switch (_a.label) {
|
|
675
|
+
case 0:
|
|
676
|
+
prompt = new AcEdPromptDoubleOptions(AcApI18n.t('jig.rect.thicknessValue'));
|
|
677
|
+
prompt.allowNegative = false;
|
|
678
|
+
prompt.allowZero = true;
|
|
679
|
+
return [4 /*yield*/, AcApDocManager.instance.editor.getDouble(prompt)];
|
|
680
|
+
case 1:
|
|
681
|
+
result = _a.sent();
|
|
682
|
+
if (result.status !== AcEdPromptStatus.OK)
|
|
683
|
+
return [2 /*return*/, false];
|
|
684
|
+
settings.thickness = normalizeNonNegative(result.value);
|
|
685
|
+
return [2 /*return*/, true];
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
};
|
|
690
|
+
/**
|
|
691
|
+
* Prompts rectangle rotation angle and updates settings.
|
|
692
|
+
*
|
|
693
|
+
* @param context - Current application/document context.
|
|
694
|
+
* @param firstPoint - First corner used as angle base point.
|
|
695
|
+
* @param settings - Mutable rectangle settings.
|
|
696
|
+
* @returns `true` when value is accepted, otherwise `false`.
|
|
697
|
+
*/
|
|
698
|
+
AcApRectCmd.prototype.promptRotation = function (context, firstPoint, settings) {
|
|
699
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
700
|
+
var prompt, result;
|
|
701
|
+
var _a;
|
|
702
|
+
return __generator(this, function (_b) {
|
|
703
|
+
switch (_b.label) {
|
|
704
|
+
case 0:
|
|
705
|
+
prompt = new AcEdPromptAngleOptions(AcApI18n.t('jig.rect.rotationAngle'));
|
|
706
|
+
prompt.useBasePoint = true;
|
|
707
|
+
prompt.useDashedLine = true;
|
|
708
|
+
prompt.basePoint = new AcGePoint3d(firstPoint);
|
|
709
|
+
prompt.allowNegative = true;
|
|
710
|
+
prompt.allowZero = true;
|
|
711
|
+
prompt.jig = new AcApRectStaticJig(context.view, firstPoint, { mode: 'dimensions', length: 1, width: 1 }, settings);
|
|
712
|
+
return [4 /*yield*/, AcApDocManager.instance.editor.getAngle(prompt)];
|
|
713
|
+
case 1:
|
|
714
|
+
result = _b.sent();
|
|
715
|
+
if (result.status !== AcEdPromptStatus.OK)
|
|
716
|
+
return [2 /*return*/, false];
|
|
717
|
+
settings.rotation = (((_a = result.value) !== null && _a !== void 0 ? _a : 0) * Math.PI) / 180;
|
|
718
|
+
return [2 /*return*/, true];
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
});
|
|
722
|
+
};
|
|
723
|
+
/**
|
|
724
|
+
* Prompts rectangle length and width explicitly.
|
|
725
|
+
*
|
|
726
|
+
* @param context - Current application/document context.
|
|
727
|
+
* @param firstPoint - First corner point.
|
|
728
|
+
* @param settings - Mutable rectangle settings.
|
|
729
|
+
* @returns Dimension-based build input, or `undefined` on cancel.
|
|
730
|
+
*/
|
|
731
|
+
AcApRectCmd.prototype.promptDimensions = function (context, firstPoint, settings) {
|
|
732
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
733
|
+
var seedInput, length, width;
|
|
734
|
+
return __generator(this, function (_a) {
|
|
735
|
+
switch (_a.label) {
|
|
736
|
+
case 0:
|
|
737
|
+
seedInput = {
|
|
738
|
+
mode: 'dimensions',
|
|
739
|
+
length: 1,
|
|
740
|
+
width: 1
|
|
741
|
+
};
|
|
742
|
+
return [4 /*yield*/, this.promptPositiveDouble(AcApI18n.t('jig.rect.dimensionLength'), new AcApRectStaticJig(context.view, firstPoint, seedInput, settings))];
|
|
743
|
+
case 1:
|
|
744
|
+
length = _a.sent();
|
|
745
|
+
if (!isPositive(length))
|
|
746
|
+
return [2 /*return*/, undefined];
|
|
747
|
+
return [4 /*yield*/, this.promptPositiveDouble(AcApI18n.t('jig.rect.dimensionWidth'), new AcApRectStaticJig(context.view, firstPoint, { mode: 'dimensions', length: length, width: 1 }, settings))];
|
|
748
|
+
case 2:
|
|
749
|
+
width = _a.sent();
|
|
750
|
+
if (!isPositive(width))
|
|
751
|
+
return [2 /*return*/, undefined];
|
|
752
|
+
return [2 /*return*/, {
|
|
753
|
+
mode: 'dimensions',
|
|
754
|
+
length: length,
|
|
755
|
+
width: width
|
|
756
|
+
}];
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
});
|
|
760
|
+
};
|
|
761
|
+
/**
|
|
762
|
+
* Prompts rectangle area, then asks for either known length or known width.
|
|
763
|
+
*
|
|
764
|
+
* @param context - Current application/document context.
|
|
765
|
+
* @param firstPoint - First corner point.
|
|
766
|
+
* @param settings - Mutable rectangle settings.
|
|
767
|
+
* @returns Dimension-based build input derived from area, or `undefined`.
|
|
768
|
+
*/
|
|
769
|
+
AcApRectCmd.prototype.promptArea = function (context, firstPoint, settings) {
|
|
770
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
771
|
+
var area, knownPrompt, knownResult, width, length;
|
|
772
|
+
return __generator(this, function (_a) {
|
|
773
|
+
switch (_a.label) {
|
|
774
|
+
case 0: return [4 /*yield*/, this.promptPositiveDouble(AcApI18n.t('jig.rect.areaValue'), new AcApRectStaticJig(context.view, firstPoint, { mode: 'dimensions', length: 1, width: 1 }, settings))];
|
|
775
|
+
case 1:
|
|
776
|
+
area = _a.sent();
|
|
777
|
+
if (!isPositive(area))
|
|
778
|
+
return [2 /*return*/, undefined];
|
|
779
|
+
knownPrompt = new AcEdPromptDoubleOptions(AcApI18n.t('jig.rect.areaLengthOrWidth'));
|
|
780
|
+
addDoubleKeyword(knownPrompt, 'rectWidth');
|
|
781
|
+
knownPrompt.allowNegative = false;
|
|
782
|
+
knownPrompt.allowZero = false;
|
|
783
|
+
knownPrompt.jig = new AcApRectStaticJig(context.view, firstPoint, { mode: 'dimensions', length: 1, width: 1 }, settings);
|
|
784
|
+
return [4 /*yield*/, AcApDocManager.instance.editor.getDouble(knownPrompt)];
|
|
785
|
+
case 2:
|
|
786
|
+
knownResult = _a.sent();
|
|
787
|
+
if (!(knownResult.status === AcEdPromptStatus.Keyword)) return [3 /*break*/, 4];
|
|
788
|
+
if (knownResult.stringResult !== 'Width')
|
|
789
|
+
return [2 /*return*/, undefined];
|
|
790
|
+
return [4 /*yield*/, this.promptPositiveDouble(AcApI18n.t('jig.rect.areaSpecifyWidth'), new AcApRectStaticJig(context.view, firstPoint, { mode: 'dimensions', length: 1, width: 1 }, settings))];
|
|
791
|
+
case 3:
|
|
792
|
+
width = _a.sent();
|
|
793
|
+
if (!isPositive(width))
|
|
794
|
+
return [2 /*return*/, undefined];
|
|
795
|
+
return [2 /*return*/, {
|
|
796
|
+
mode: 'dimensions',
|
|
797
|
+
length: (area !== null && area !== void 0 ? area : 0) / (width !== null && width !== void 0 ? width : 1),
|
|
798
|
+
width: width
|
|
799
|
+
}];
|
|
800
|
+
case 4:
|
|
801
|
+
if (knownResult.status !== AcEdPromptStatus.OK)
|
|
802
|
+
return [2 /*return*/, undefined];
|
|
803
|
+
if (!isPositive(knownResult.value))
|
|
804
|
+
return [2 /*return*/, undefined];
|
|
805
|
+
length = knownResult.value;
|
|
806
|
+
return [2 /*return*/, {
|
|
807
|
+
mode: 'dimensions',
|
|
808
|
+
length: length,
|
|
809
|
+
width: (area !== null && area !== void 0 ? area : 0) / length
|
|
810
|
+
}];
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
});
|
|
814
|
+
};
|
|
815
|
+
/**
|
|
816
|
+
* Last-used rectangle settings persisted between command invocations.
|
|
817
|
+
*/
|
|
818
|
+
AcApRectCmd._settings = cloneRectSettings(DEFAULT_RECT_SETTINGS);
|
|
137
819
|
return AcApRectCmd;
|
|
138
820
|
}(AcEdCommand));
|
|
139
821
|
export { AcApRectCmd };
|