@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
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { AcDbCircle, AcGePoint3dLike } from '@mlightcad/data-model';
|
|
2
2
|
import { AcApContext } from '../app';
|
|
3
3
|
import { AcEdBaseView, AcEdCommand, AcEdPreviewJig } from '../editor';
|
|
4
|
+
/**
|
|
5
|
+
* Dynamic radius preview jig used by center-based circle workflows.
|
|
6
|
+
*/
|
|
4
7
|
export declare class AcApCircleJig extends AcEdPreviewJig<number> {
|
|
8
|
+
/**
|
|
9
|
+
* Transient circle entity reused during radius preview.
|
|
10
|
+
*/
|
|
5
11
|
private _circle;
|
|
6
12
|
/**
|
|
7
13
|
* Creates a circle jig.
|
|
@@ -9,14 +15,67 @@ export declare class AcApCircleJig extends AcEdPreviewJig<number> {
|
|
|
9
15
|
* @param view - The associated view
|
|
10
16
|
*/
|
|
11
17
|
constructor(view: AcEdBaseView, center: AcGePoint3dLike);
|
|
18
|
+
/**
|
|
19
|
+
* Gets transient circle entity displayed by the jig.
|
|
20
|
+
*/
|
|
12
21
|
get entity(): AcDbCircle;
|
|
22
|
+
/**
|
|
23
|
+
* Updates preview radius.
|
|
24
|
+
*
|
|
25
|
+
* @param radius - Dynamic radius value from prompt input.
|
|
26
|
+
*/
|
|
13
27
|
update(radius: number): void;
|
|
14
28
|
}
|
|
15
29
|
/**
|
|
16
30
|
* Command to create one circle.
|
|
17
31
|
*/
|
|
18
32
|
export declare class AcApCircleCmd extends AcEdCommand {
|
|
33
|
+
/**
|
|
34
|
+
* Creates CIRCLE command instance.
|
|
35
|
+
*/
|
|
19
36
|
constructor();
|
|
37
|
+
/**
|
|
38
|
+
* Command entry point.
|
|
39
|
+
*
|
|
40
|
+
* Supports center/radius, center/diameter, two-point and three-point
|
|
41
|
+
* circle creation through a prompt state machine.
|
|
42
|
+
*
|
|
43
|
+
* @param context - Current application/document context.
|
|
44
|
+
*/
|
|
20
45
|
execute(context: AcApContext): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Runs center-based workflow:
|
|
48
|
+
* center -> radius OR center -> diameter.
|
|
49
|
+
*
|
|
50
|
+
* @param context - Current application/document context.
|
|
51
|
+
* @param center - Picked center point.
|
|
52
|
+
* @returns Resolved circle definition, or `undefined` on cancel/invalid input.
|
|
53
|
+
*/
|
|
54
|
+
private runCenterFlow;
|
|
55
|
+
/**
|
|
56
|
+
* Prompts diameter input in center-based workflow.
|
|
57
|
+
*
|
|
58
|
+
* @param context - Current application/document context.
|
|
59
|
+
* @param center - Circle center point.
|
|
60
|
+
* @returns Circle definition, or `undefined` when canceled/invalid.
|
|
61
|
+
*/
|
|
62
|
+
private promptDiameterCircle;
|
|
63
|
+
/**
|
|
64
|
+
* Creates circle definition from two points.
|
|
65
|
+
*
|
|
66
|
+
* @param first - First point of diameter.
|
|
67
|
+
* @param second - Second point of diameter.
|
|
68
|
+
* @returns Circle definition, or `undefined` when points are invalid.
|
|
69
|
+
*/
|
|
70
|
+
private createFromTwoPoints;
|
|
71
|
+
/**
|
|
72
|
+
* Creates circle definition from three points.
|
|
73
|
+
*
|
|
74
|
+
* @param p1 - First point on circle.
|
|
75
|
+
* @param p2 - Second point on circle.
|
|
76
|
+
* @param p3 - Third point on circle.
|
|
77
|
+
* @returns Circle definition, or `undefined` when points are degenerate.
|
|
78
|
+
*/
|
|
79
|
+
private createFromThreePoints;
|
|
21
80
|
}
|
|
22
81
|
//# sourceMappingURL=AcApCircleCmd.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcApCircleCmd.d.ts","sourceRoot":"","sources":["../../src/command/AcApCircleCmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"AcApCircleCmd.d.ts","sourceRoot":"","sources":["../../src/command/AcApCircleCmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAe,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEhF,OAAO,EAAE,WAAW,EAAkB,MAAM,QAAQ,CAAA;AACpD,OAAO,EACL,YAAY,EACZ,WAAW,EAEX,cAAc,EAQf,MAAM,WAAW,CAAA;AAqGlB;;GAEG;AACH,qBAAa,aAAc,SAAQ,cAAc,CAAC,MAAM,CAAC;IACvD;;OAEG;IACH,OAAO,CAAC,OAAO,CAAY;IAE3B;;;;OAIG;gBACS,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe;IAKvD;;OAEG;IACH,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM;CAGtB;AAmDD;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C;;OAEG;;IAMH;;;;;;;OAOG;IACG,OAAO,CAAC,OAAO,EAAE,WAAW;IAwUlC;;;;;;;OAOG;YACW,aAAa;IAwB3B;;;;;;OAMG;YACW,oBAAoB;IAmBlC;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAI3B;;;;;;;OAOG;IACH,OAAO,CAAC,qBAAqB;CAO9B"}
|
|
@@ -49,10 +49,76 @@ 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 { AcDbCircle } from '@mlightcad/data-model';
|
|
52
|
+
import { AcDbCircle, AcGePoint3d } from '@mlightcad/data-model';
|
|
53
53
|
import { AcApDocManager } from '../app';
|
|
54
|
-
import { AcEdCommand, AcEdOpenMode, AcEdPreviewJig, AcEdPromptDistanceOptions, AcEdPromptPointOptions, AcEdPromptStatus } from '../editor';
|
|
54
|
+
import { AcEdCommand, AcEdOpenMode, AcEdPreviewJig, AcEdPromptDistanceOptions, AcEdPromptPointOptions, AcEdPromptStateMachine, AcEdPromptStatus } from '../editor';
|
|
55
55
|
import { AcApI18n } from '../i18n';
|
|
56
|
+
var EPSILON = 1e-9;
|
|
57
|
+
function createFallbackCircle(point) {
|
|
58
|
+
return {
|
|
59
|
+
center: { x: point.x, y: point.y, z: 0 },
|
|
60
|
+
radius: 1e-6
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function addKeyword(prompt, key) {
|
|
64
|
+
prompt.keywords.add(AcApI18n.t("jig.circle.keywords.".concat(key, ".display")), AcApI18n.t("jig.circle.keywords.".concat(key, ".global")), AcApI18n.t("jig.circle.keywords.".concat(key, ".local")));
|
|
65
|
+
}
|
|
66
|
+
function applyCircleDefinition(entity, definition) {
|
|
67
|
+
entity.center = definition.center;
|
|
68
|
+
entity.radius = definition.radius;
|
|
69
|
+
}
|
|
70
|
+
function createCircleFromCenterRadius(center, radius) {
|
|
71
|
+
if (!Number.isFinite(radius) || radius <= EPSILON)
|
|
72
|
+
return undefined;
|
|
73
|
+
return {
|
|
74
|
+
center: { x: center.x, y: center.y, z: 0 },
|
|
75
|
+
radius: radius
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function createCircleFromTwoPoints(first, second) {
|
|
79
|
+
var dx = second.x - first.x;
|
|
80
|
+
var dy = second.y - first.y;
|
|
81
|
+
var diameter = Math.hypot(dx, dy);
|
|
82
|
+
if (diameter <= EPSILON)
|
|
83
|
+
return undefined;
|
|
84
|
+
return {
|
|
85
|
+
center: {
|
|
86
|
+
x: (first.x + second.x) / 2,
|
|
87
|
+
y: (first.y + second.y) / 2,
|
|
88
|
+
z: 0
|
|
89
|
+
},
|
|
90
|
+
radius: diameter / 2
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function createCircleFromThreePoints(p1, p2, p3) {
|
|
94
|
+
var x1 = p1.x;
|
|
95
|
+
var y1 = p1.y;
|
|
96
|
+
var x2 = p2.x;
|
|
97
|
+
var y2 = p2.y;
|
|
98
|
+
var x3 = p3.x;
|
|
99
|
+
var y3 = p3.y;
|
|
100
|
+
var d = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2));
|
|
101
|
+
if (Math.abs(d) <= EPSILON)
|
|
102
|
+
return undefined;
|
|
103
|
+
var ux = ((x1 * x1 + y1 * y1) * (y2 - y3) +
|
|
104
|
+
(x2 * x2 + y2 * y2) * (y3 - y1) +
|
|
105
|
+
(x3 * x3 + y3 * y3) * (y1 - y2)) /
|
|
106
|
+
d;
|
|
107
|
+
var uy = ((x1 * x1 + y1 * y1) * (x3 - x2) +
|
|
108
|
+
(x2 * x2 + y2 * y2) * (x1 - x3) +
|
|
109
|
+
(x3 * x3 + y3 * y3) * (x2 - x1)) /
|
|
110
|
+
d;
|
|
111
|
+
var radius = Math.hypot(ux - x1, uy - y1);
|
|
112
|
+
if (!Number.isFinite(radius) || radius <= EPSILON)
|
|
113
|
+
return undefined;
|
|
114
|
+
return {
|
|
115
|
+
center: { x: ux, y: uy, z: 0 },
|
|
116
|
+
radius: radius
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Dynamic radius preview jig used by center-based circle workflows.
|
|
121
|
+
*/
|
|
56
122
|
var AcApCircleJig = /** @class */ (function (_super) {
|
|
57
123
|
__extends(AcApCircleJig, _super);
|
|
58
124
|
/**
|
|
@@ -66,57 +132,462 @@ var AcApCircleJig = /** @class */ (function (_super) {
|
|
|
66
132
|
return _this;
|
|
67
133
|
}
|
|
68
134
|
Object.defineProperty(AcApCircleJig.prototype, "entity", {
|
|
135
|
+
/**
|
|
136
|
+
* Gets transient circle entity displayed by the jig.
|
|
137
|
+
*/
|
|
69
138
|
get: function () {
|
|
70
139
|
return this._circle;
|
|
71
140
|
},
|
|
72
141
|
enumerable: false,
|
|
73
142
|
configurable: true
|
|
74
143
|
});
|
|
144
|
+
/**
|
|
145
|
+
* Updates preview radius.
|
|
146
|
+
*
|
|
147
|
+
* @param radius - Dynamic radius value from prompt input.
|
|
148
|
+
*/
|
|
75
149
|
AcApCircleJig.prototype.update = function (radius) {
|
|
76
150
|
this._circle.radius = radius;
|
|
77
151
|
};
|
|
78
152
|
return AcApCircleJig;
|
|
79
153
|
}(AcEdPreviewJig));
|
|
80
154
|
export { AcApCircleJig };
|
|
155
|
+
/**
|
|
156
|
+
* Dynamic point-based circle preview jig used by 2P/3P workflows.
|
|
157
|
+
*/
|
|
158
|
+
var AcApCircleDynamicJig = /** @class */ (function (_super) {
|
|
159
|
+
__extends(AcApCircleDynamicJig, _super);
|
|
160
|
+
/**
|
|
161
|
+
* Creates dynamic circle preview jig.
|
|
162
|
+
*
|
|
163
|
+
* @param view - Active editor view.
|
|
164
|
+
* @param builder - Cursor point to circle definition resolver.
|
|
165
|
+
* @param fallback - Initial valid fallback circle.
|
|
166
|
+
*/
|
|
167
|
+
function AcApCircleDynamicJig(view, builder, fallback) {
|
|
168
|
+
var _this = _super.call(this, view) || this;
|
|
169
|
+
_this._circle = new AcDbCircle(fallback.center, fallback.radius);
|
|
170
|
+
_this._builder = builder;
|
|
171
|
+
return _this;
|
|
172
|
+
}
|
|
173
|
+
Object.defineProperty(AcApCircleDynamicJig.prototype, "entity", {
|
|
174
|
+
/**
|
|
175
|
+
* Gets transient circle entity displayed by the jig.
|
|
176
|
+
*/
|
|
177
|
+
get: function () {
|
|
178
|
+
return this._circle;
|
|
179
|
+
},
|
|
180
|
+
enumerable: false,
|
|
181
|
+
configurable: true
|
|
182
|
+
});
|
|
183
|
+
/**
|
|
184
|
+
* Recomputes preview circle from current cursor point.
|
|
185
|
+
*
|
|
186
|
+
* @param point - Current cursor/input point.
|
|
187
|
+
*/
|
|
188
|
+
AcApCircleDynamicJig.prototype.update = function (point) {
|
|
189
|
+
var definition = this._builder(point);
|
|
190
|
+
if (!definition)
|
|
191
|
+
return;
|
|
192
|
+
applyCircleDefinition(this._circle, definition);
|
|
193
|
+
};
|
|
194
|
+
return AcApCircleDynamicJig;
|
|
195
|
+
}(AcEdPreviewJig));
|
|
81
196
|
/**
|
|
82
197
|
* Command to create one circle.
|
|
83
198
|
*/
|
|
84
199
|
var AcApCircleCmd = /** @class */ (function (_super) {
|
|
85
200
|
__extends(AcApCircleCmd, _super);
|
|
201
|
+
/**
|
|
202
|
+
* Creates CIRCLE command instance.
|
|
203
|
+
*/
|
|
86
204
|
function AcApCircleCmd() {
|
|
87
205
|
var _this = _super.call(this) || this;
|
|
88
206
|
_this.mode = AcEdOpenMode.Write;
|
|
89
207
|
return _this;
|
|
90
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Command entry point.
|
|
211
|
+
*
|
|
212
|
+
* Supports center/radius, center/diameter, two-point and three-point
|
|
213
|
+
* circle creation through a prompt state machine.
|
|
214
|
+
*
|
|
215
|
+
* @param context - Current application/document context.
|
|
216
|
+
*/
|
|
91
217
|
AcApCircleCmd.prototype.execute = function (context) {
|
|
92
218
|
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
-
var
|
|
219
|
+
var circle, EntryState, TwoPointFirstState, TwoPointSecondState, ThreePointFirstState, ThreePointSecondState, ThreePointThirdState, machine;
|
|
94
220
|
return __generator(this, function (_a) {
|
|
95
221
|
switch (_a.label) {
|
|
96
222
|
case 0:
|
|
97
|
-
|
|
98
|
-
|
|
223
|
+
EntryState = /** @class */ (function () {
|
|
224
|
+
/**
|
|
225
|
+
* Creates entry state handler.
|
|
226
|
+
*
|
|
227
|
+
* @param cmd - Owning CIRCLE command instance.
|
|
228
|
+
* @param machine - Prompt state machine used for state transitions.
|
|
229
|
+
*/
|
|
230
|
+
function EntryState(cmd, machine) {
|
|
231
|
+
this.cmd = cmd;
|
|
232
|
+
this.machine = machine;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Builds first prompt for center-or-options input.
|
|
236
|
+
*
|
|
237
|
+
* @returns Configured point prompt with `3P` and `2P` keywords.
|
|
238
|
+
*/
|
|
239
|
+
EntryState.prototype.buildPrompt = function () {
|
|
240
|
+
var prompt = new AcEdPromptPointOptions(AcApI18n.t('jig.circle.centerOrOptions'));
|
|
241
|
+
addKeyword(prompt, 'threeP');
|
|
242
|
+
addKeyword(prompt, 'twoP');
|
|
243
|
+
return prompt;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Handles entry step result and dispatches to selected branch.
|
|
247
|
+
*
|
|
248
|
+
* @param result - Point prompt result.
|
|
249
|
+
* @returns State-machine step result.
|
|
250
|
+
*/
|
|
251
|
+
EntryState.prototype.handleResult = function (result) {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
253
|
+
var keyword;
|
|
254
|
+
var _a;
|
|
255
|
+
return __generator(this, function (_b) {
|
|
256
|
+
switch (_b.label) {
|
|
257
|
+
case 0:
|
|
258
|
+
if (!(result.status === AcEdPromptStatus.OK)) return [3 /*break*/, 2];
|
|
259
|
+
return [4 /*yield*/, this.cmd.runCenterFlow(context, result.value)];
|
|
260
|
+
case 1:
|
|
261
|
+
circle = _b.sent();
|
|
262
|
+
return [2 /*return*/, 'finish'];
|
|
263
|
+
case 2:
|
|
264
|
+
if (result.status !== AcEdPromptStatus.Keyword)
|
|
265
|
+
return [2 /*return*/, 'finish'];
|
|
266
|
+
keyword = (_a = result.stringResult) !== null && _a !== void 0 ? _a : '';
|
|
267
|
+
if (keyword === '3P') {
|
|
268
|
+
this.machine.setState(new ThreePointFirstState(this.cmd, this.machine));
|
|
269
|
+
return [2 /*return*/, 'continue'];
|
|
270
|
+
}
|
|
271
|
+
if (keyword === '2P') {
|
|
272
|
+
this.machine.setState(new TwoPointFirstState(this.cmd, this.machine));
|
|
273
|
+
return [2 /*return*/, 'continue'];
|
|
274
|
+
}
|
|
275
|
+
return [2 /*return*/, 'finish'];
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
return EntryState;
|
|
281
|
+
}());
|
|
282
|
+
TwoPointFirstState = /** @class */ (function () {
|
|
283
|
+
/**
|
|
284
|
+
* Creates 2P first-point state handler.
|
|
285
|
+
*
|
|
286
|
+
* @param cmd - Owning CIRCLE command instance.
|
|
287
|
+
* @param machine - Prompt state machine used for state transitions.
|
|
288
|
+
*/
|
|
289
|
+
function TwoPointFirstState(cmd, machine) {
|
|
290
|
+
this.cmd = cmd;
|
|
291
|
+
this.machine = machine;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Builds prompt for first 2P endpoint.
|
|
295
|
+
*
|
|
296
|
+
* @returns Configured point prompt.
|
|
297
|
+
*/
|
|
298
|
+
TwoPointFirstState.prototype.buildPrompt = function () {
|
|
299
|
+
return new AcEdPromptPointOptions(AcApI18n.t('jig.circle.twoPointFirst'));
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Handles first 2P point and moves to second-point state.
|
|
303
|
+
*
|
|
304
|
+
* @param result - Point prompt result.
|
|
305
|
+
* @returns State-machine step result.
|
|
306
|
+
*/
|
|
307
|
+
TwoPointFirstState.prototype.handleResult = function (result) {
|
|
308
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
309
|
+
return __generator(this, function (_a) {
|
|
310
|
+
if (result.status !== AcEdPromptStatus.OK)
|
|
311
|
+
return [2 /*return*/, 'finish'];
|
|
312
|
+
this.machine.setState(new TwoPointSecondState(this.cmd, result.value));
|
|
313
|
+
return [2 /*return*/, 'continue'];
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
return TwoPointFirstState;
|
|
318
|
+
}());
|
|
319
|
+
TwoPointSecondState = /** @class */ (function () {
|
|
320
|
+
/**
|
|
321
|
+
* Creates 2P second-point state handler.
|
|
322
|
+
*
|
|
323
|
+
* @param cmd - Owning CIRCLE command instance.
|
|
324
|
+
* @param firstPoint - First 2P endpoint captured in previous step.
|
|
325
|
+
*/
|
|
326
|
+
function TwoPointSecondState(cmd, firstPoint) {
|
|
327
|
+
this.cmd = cmd;
|
|
328
|
+
this.firstPoint = firstPoint;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Builds prompt for second 2P endpoint with dynamic preview.
|
|
332
|
+
*
|
|
333
|
+
* @returns Configured point prompt.
|
|
334
|
+
*/
|
|
335
|
+
TwoPointSecondState.prototype.buildPrompt = function () {
|
|
336
|
+
var _this = this;
|
|
337
|
+
var prompt = new AcEdPromptPointOptions(AcApI18n.t('jig.circle.twoPointSecond'));
|
|
338
|
+
prompt.useBasePoint = true;
|
|
339
|
+
prompt.useDashedLine = true;
|
|
340
|
+
prompt.basePoint = new AcGePoint3d(this.firstPoint);
|
|
341
|
+
prompt.jig = new AcApCircleDynamicJig(context.view, function (point) { return createCircleFromTwoPoints(_this.firstPoint, point); }, createFallbackCircle(this.firstPoint));
|
|
342
|
+
return prompt;
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* Handles second 2P point and finalizes circle output.
|
|
346
|
+
*
|
|
347
|
+
* @param result - Point prompt result.
|
|
348
|
+
* @returns State-machine step result.
|
|
349
|
+
*/
|
|
350
|
+
TwoPointSecondState.prototype.handleResult = function (result) {
|
|
351
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
352
|
+
return __generator(this, function (_a) {
|
|
353
|
+
if (result.status === AcEdPromptStatus.OK) {
|
|
354
|
+
circle = this.cmd.createFromTwoPoints(this.firstPoint, result.value);
|
|
355
|
+
}
|
|
356
|
+
return [2 /*return*/, 'finish'];
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
return TwoPointSecondState;
|
|
361
|
+
}());
|
|
362
|
+
ThreePointFirstState = /** @class */ (function () {
|
|
363
|
+
/**
|
|
364
|
+
* Creates 3P first-point state handler.
|
|
365
|
+
*
|
|
366
|
+
* @param cmd - Owning CIRCLE command instance.
|
|
367
|
+
* @param machine - Prompt state machine used for state transitions.
|
|
368
|
+
*/
|
|
369
|
+
function ThreePointFirstState(cmd, machine) {
|
|
370
|
+
this.cmd = cmd;
|
|
371
|
+
this.machine = machine;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Builds prompt for first 3P point.
|
|
375
|
+
*
|
|
376
|
+
* @returns Configured point prompt.
|
|
377
|
+
*/
|
|
378
|
+
ThreePointFirstState.prototype.buildPrompt = function () {
|
|
379
|
+
return new AcEdPromptPointOptions(AcApI18n.t('jig.circle.threePointFirst'));
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* Handles first 3P point and advances to second-point state.
|
|
383
|
+
*
|
|
384
|
+
* @param result - Point prompt result.
|
|
385
|
+
* @returns State-machine step result.
|
|
386
|
+
*/
|
|
387
|
+
ThreePointFirstState.prototype.handleResult = function (result) {
|
|
388
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
389
|
+
return __generator(this, function (_a) {
|
|
390
|
+
if (result.status !== AcEdPromptStatus.OK)
|
|
391
|
+
return [2 /*return*/, 'finish'];
|
|
392
|
+
this.machine.setState(new ThreePointSecondState(this.cmd, this.machine, result.value));
|
|
393
|
+
return [2 /*return*/, 'continue'];
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
};
|
|
397
|
+
return ThreePointFirstState;
|
|
398
|
+
}());
|
|
399
|
+
ThreePointSecondState = /** @class */ (function () {
|
|
400
|
+
/**
|
|
401
|
+
* Creates 3P second-point state handler.
|
|
402
|
+
*
|
|
403
|
+
* @param cmd - Owning CIRCLE command instance.
|
|
404
|
+
* @param machine - Prompt state machine used for state transitions.
|
|
405
|
+
* @param firstPoint - First 3P point captured in previous step.
|
|
406
|
+
*/
|
|
407
|
+
function ThreePointSecondState(cmd, machine, firstPoint) {
|
|
408
|
+
this.cmd = cmd;
|
|
409
|
+
this.machine = machine;
|
|
410
|
+
this.firstPoint = firstPoint;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Builds prompt for second 3P point.
|
|
414
|
+
*
|
|
415
|
+
* @returns Configured point prompt.
|
|
416
|
+
*/
|
|
417
|
+
ThreePointSecondState.prototype.buildPrompt = function () {
|
|
418
|
+
var prompt = new AcEdPromptPointOptions(AcApI18n.t('jig.circle.threePointSecond'));
|
|
419
|
+
prompt.useBasePoint = true;
|
|
420
|
+
prompt.useDashedLine = true;
|
|
421
|
+
prompt.basePoint = new AcGePoint3d(this.firstPoint);
|
|
422
|
+
return prompt;
|
|
423
|
+
};
|
|
424
|
+
/**
|
|
425
|
+
* Handles second 3P point and advances to third-point state.
|
|
426
|
+
*
|
|
427
|
+
* @param result - Point prompt result.
|
|
428
|
+
* @returns State-machine step result.
|
|
429
|
+
*/
|
|
430
|
+
ThreePointSecondState.prototype.handleResult = function (result) {
|
|
431
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
432
|
+
return __generator(this, function (_a) {
|
|
433
|
+
if (result.status !== AcEdPromptStatus.OK)
|
|
434
|
+
return [2 /*return*/, 'finish'];
|
|
435
|
+
this.machine.setState(new ThreePointThirdState(this.cmd, this.firstPoint, result.value));
|
|
436
|
+
return [2 /*return*/, 'continue'];
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
};
|
|
440
|
+
return ThreePointSecondState;
|
|
441
|
+
}());
|
|
442
|
+
ThreePointThirdState = /** @class */ (function () {
|
|
443
|
+
/**
|
|
444
|
+
* Creates 3P third-point state handler.
|
|
445
|
+
*
|
|
446
|
+
* @param cmd - Owning CIRCLE command instance.
|
|
447
|
+
* @param firstPoint - First 3P point.
|
|
448
|
+
* @param secondPoint - Second 3P point.
|
|
449
|
+
*/
|
|
450
|
+
function ThreePointThirdState(cmd, firstPoint, secondPoint) {
|
|
451
|
+
this.cmd = cmd;
|
|
452
|
+
this.firstPoint = firstPoint;
|
|
453
|
+
this.secondPoint = secondPoint;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Builds prompt for final 3P point with dynamic preview.
|
|
457
|
+
*
|
|
458
|
+
* @returns Configured point prompt.
|
|
459
|
+
*/
|
|
460
|
+
ThreePointThirdState.prototype.buildPrompt = function () {
|
|
461
|
+
var _this = this;
|
|
462
|
+
var prompt = new AcEdPromptPointOptions(AcApI18n.t('jig.circle.threePointThird'));
|
|
463
|
+
prompt.useBasePoint = true;
|
|
464
|
+
prompt.useDashedLine = true;
|
|
465
|
+
prompt.basePoint = new AcGePoint3d(this.secondPoint);
|
|
466
|
+
prompt.jig = new AcApCircleDynamicJig(context.view, function (point) {
|
|
467
|
+
return createCircleFromThreePoints(_this.firstPoint, _this.secondPoint, point);
|
|
468
|
+
}, createFallbackCircle(this.firstPoint));
|
|
469
|
+
return prompt;
|
|
470
|
+
};
|
|
471
|
+
/**
|
|
472
|
+
* Handles final 3P point and finalizes circle output.
|
|
473
|
+
*
|
|
474
|
+
* @param result - Point prompt result.
|
|
475
|
+
* @returns State-machine step result.
|
|
476
|
+
*/
|
|
477
|
+
ThreePointThirdState.prototype.handleResult = function (result) {
|
|
478
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
479
|
+
return __generator(this, function (_a) {
|
|
480
|
+
if (result.status === AcEdPromptStatus.OK) {
|
|
481
|
+
circle = this.cmd.createFromThreePoints(this.firstPoint, this.secondPoint, result.value);
|
|
482
|
+
}
|
|
483
|
+
return [2 /*return*/, 'finish'];
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
};
|
|
487
|
+
return ThreePointThirdState;
|
|
488
|
+
}());
|
|
489
|
+
machine = new AcEdPromptStateMachine();
|
|
490
|
+
machine.setState(new EntryState(this, machine));
|
|
491
|
+
return [4 /*yield*/, machine.run(function (prompt) { return AcApDocManager.instance.editor.getPoint(prompt); })];
|
|
99
492
|
case 1:
|
|
100
|
-
|
|
101
|
-
if (
|
|
493
|
+
_a.sent();
|
|
494
|
+
if (!circle)
|
|
102
495
|
return [2 /*return*/];
|
|
103
|
-
center
|
|
104
|
-
|
|
496
|
+
context.doc.database.tables.blockTable.modelSpace.appendEntity(new AcDbCircle(circle.center, circle.radius));
|
|
497
|
+
return [2 /*return*/];
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* Runs center-based workflow:
|
|
504
|
+
* center -> radius OR center -> diameter.
|
|
505
|
+
*
|
|
506
|
+
* @param context - Current application/document context.
|
|
507
|
+
* @param center - Picked center point.
|
|
508
|
+
* @returns Resolved circle definition, or `undefined` on cancel/invalid input.
|
|
509
|
+
*/
|
|
510
|
+
AcApCircleCmd.prototype.runCenterFlow = function (context, center) {
|
|
511
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
512
|
+
var radiusPrompt, radiusResult;
|
|
513
|
+
var _a;
|
|
514
|
+
return __generator(this, function (_b) {
|
|
515
|
+
switch (_b.label) {
|
|
516
|
+
case 0:
|
|
517
|
+
radiusPrompt = new AcEdPromptDistanceOptions(AcApI18n.t('jig.circle.radiusOrDiameter'));
|
|
518
|
+
addKeyword(radiusPrompt, 'diameter');
|
|
519
|
+
radiusPrompt.allowZero = false;
|
|
520
|
+
radiusPrompt.useBasePoint = true;
|
|
521
|
+
radiusPrompt.useDashedLine = true;
|
|
522
|
+
radiusPrompt.basePoint = new AcGePoint3d(center);
|
|
105
523
|
radiusPrompt.jig = new AcApCircleJig(context.view, center);
|
|
106
524
|
return [4 /*yield*/, AcApDocManager.instance.editor.getDistance(radiusPrompt)];
|
|
107
|
-
case
|
|
108
|
-
radiusResult =
|
|
109
|
-
if (radiusResult.status
|
|
110
|
-
return [2 /*return
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
525
|
+
case 1:
|
|
526
|
+
radiusResult = _b.sent();
|
|
527
|
+
if (radiusResult.status === AcEdPromptStatus.OK) {
|
|
528
|
+
return [2 /*return*/, createCircleFromCenterRadius(center, (_a = radiusResult.value) !== null && _a !== void 0 ? _a : 0)];
|
|
529
|
+
}
|
|
530
|
+
if (!(radiusResult.status === AcEdPromptStatus.Keyword &&
|
|
531
|
+
radiusResult.stringResult === 'Diameter')) return [3 /*break*/, 3];
|
|
532
|
+
return [4 /*yield*/, this.promptDiameterCircle(context, center)];
|
|
533
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
534
|
+
case 3: return [2 /*return*/, undefined];
|
|
116
535
|
}
|
|
117
536
|
});
|
|
118
537
|
});
|
|
119
538
|
};
|
|
539
|
+
/**
|
|
540
|
+
* Prompts diameter input in center-based workflow.
|
|
541
|
+
*
|
|
542
|
+
* @param context - Current application/document context.
|
|
543
|
+
* @param center - Circle center point.
|
|
544
|
+
* @returns Circle definition, or `undefined` when canceled/invalid.
|
|
545
|
+
*/
|
|
546
|
+
AcApCircleCmd.prototype.promptDiameterCircle = function (context, center) {
|
|
547
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
548
|
+
var diameterPrompt, diameterResult, radius;
|
|
549
|
+
var _a;
|
|
550
|
+
return __generator(this, function (_b) {
|
|
551
|
+
switch (_b.label) {
|
|
552
|
+
case 0:
|
|
553
|
+
diameterPrompt = new AcEdPromptDistanceOptions(AcApI18n.t('jig.circle.diameter'));
|
|
554
|
+
diameterPrompt.allowZero = false;
|
|
555
|
+
diameterPrompt.useBasePoint = true;
|
|
556
|
+
diameterPrompt.useDashedLine = true;
|
|
557
|
+
diameterPrompt.basePoint = new AcGePoint3d(center);
|
|
558
|
+
diameterPrompt.jig = new AcApCircleJig(context.view, center);
|
|
559
|
+
return [4 /*yield*/, AcApDocManager.instance.editor.getDistance(diameterPrompt)];
|
|
560
|
+
case 1:
|
|
561
|
+
diameterResult = _b.sent();
|
|
562
|
+
if (diameterResult.status !== AcEdPromptStatus.OK)
|
|
563
|
+
return [2 /*return*/, undefined];
|
|
564
|
+
radius = ((_a = diameterResult.value) !== null && _a !== void 0 ? _a : 0) / 2;
|
|
565
|
+
return [2 /*return*/, createCircleFromCenterRadius(center, radius)];
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
571
|
+
* Creates circle definition from two points.
|
|
572
|
+
*
|
|
573
|
+
* @param first - First point of diameter.
|
|
574
|
+
* @param second - Second point of diameter.
|
|
575
|
+
* @returns Circle definition, or `undefined` when points are invalid.
|
|
576
|
+
*/
|
|
577
|
+
AcApCircleCmd.prototype.createFromTwoPoints = function (first, second) {
|
|
578
|
+
return createCircleFromTwoPoints(first, second);
|
|
579
|
+
};
|
|
580
|
+
/**
|
|
581
|
+
* Creates circle definition from three points.
|
|
582
|
+
*
|
|
583
|
+
* @param p1 - First point on circle.
|
|
584
|
+
* @param p2 - Second point on circle.
|
|
585
|
+
* @param p3 - Third point on circle.
|
|
586
|
+
* @returns Circle definition, or `undefined` when points are degenerate.
|
|
587
|
+
*/
|
|
588
|
+
AcApCircleCmd.prototype.createFromThreePoints = function (p1, p2, p3) {
|
|
589
|
+
return createCircleFromThreePoints(p1, p2, p3);
|
|
590
|
+
};
|
|
120
591
|
return AcApCircleCmd;
|
|
121
592
|
}(AcEdCommand));
|
|
122
593
|
export { AcApCircleCmd };
|