@mlightcad/cad-simple-viewer 1.6.1 → 1.6.2
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/cad-simple-viewer.js +5714 -4936
- package/dist/cad-simple-viewer.umd.cjs +180 -29
- package/lib/app/AcApSettingManager.d.ts.map +1 -1
- package/lib/app/AcApSettingManager.js +1 -0
- package/lib/app/AcApSettingManager.js.map +1 -1
- package/lib/command/draw/AcApArcCmd.d.ts.map +1 -1
- package/lib/command/draw/AcApArcCmd.js +28 -312
- package/lib/command/draw/AcApArcCmd.js.map +1 -1
- package/lib/command/draw/AcApCircleCmd.d.ts.map +1 -1
- package/lib/command/draw/AcApCircleCmd.js +10 -42
- package/lib/command/draw/AcApCircleCmd.js.map +1 -1
- package/lib/command/markup/AcApMarkupTextCmd.d.ts.map +1 -1
- package/lib/command/markup/AcApMarkupTextCmd.js +8 -2
- package/lib/command/markup/AcApMarkupTextCmd.js.map +1 -1
- package/lib/command/markup/AcApMarkupTextEdit.d.ts.map +1 -1
- package/lib/command/markup/AcApMarkupTextEdit.js +3 -1
- package/lib/command/markup/AcApMarkupTextEdit.js.map +1 -1
- package/lib/command/markup/AcApMarkupUtil.d.ts.map +1 -1
- package/lib/command/markup/AcApMarkupUtil.js +3 -2
- package/lib/command/markup/AcApMarkupUtil.js.map +1 -1
- package/lib/command/measure/AcApMeasureArcCmd.d.ts +22 -25
- package/lib/command/measure/AcApMeasureArcCmd.d.ts.map +1 -1
- package/lib/command/measure/AcApMeasureArcCmd.js +480 -256
- package/lib/command/measure/AcApMeasureArcCmd.js.map +1 -1
- package/lib/command/measure/AcApMeasureArcLock.d.ts +40 -0
- package/lib/command/measure/AcApMeasureArcLock.d.ts.map +1 -0
- package/lib/command/measure/AcApMeasureArcLock.js +226 -0
- package/lib/command/measure/AcApMeasureArcLock.js.map +1 -0
- package/lib/command/measure/AcApMeasurementGeometry.d.ts.map +1 -1
- package/lib/command/measure/AcApMeasurementGeometry.js +9 -9
- package/lib/command/measure/AcApMeasurementGeometry.js.map +1 -1
- package/lib/command/measure/AcApMeasurementSidecar.d.ts.map +1 -1
- package/lib/command/measure/AcApMeasurementSidecar.js +12 -7
- package/lib/command/measure/AcApMeasurementSidecar.js.map +1 -1
- package/lib/command/measure/AcApMeasurementStore.d.ts +2 -0
- package/lib/command/measure/AcApMeasurementStore.d.ts.map +1 -1
- package/lib/command/measure/AcApMeasurementStore.js +4 -0
- package/lib/command/measure/AcApMeasurementStore.js.map +1 -1
- package/lib/command/measure/AcApMeasurementTypes.d.ts +6 -0
- package/lib/command/measure/AcApMeasurementTypes.d.ts.map +1 -1
- package/lib/command/measure/entity/AcApMeasureArcEntity.d.ts +24 -22
- package/lib/command/measure/entity/AcApMeasureArcEntity.d.ts.map +1 -1
- package/lib/command/measure/entity/AcApMeasureArcEntity.js +104 -41
- package/lib/command/measure/entity/AcApMeasureArcEntity.js.map +1 -1
- package/lib/command/measure/entity/AcApMeasureDrawUtil.d.ts +35 -38
- package/lib/command/measure/entity/AcApMeasureDrawUtil.d.ts.map +1 -1
- package/lib/command/measure/entity/AcApMeasureDrawUtil.js +42 -53
- package/lib/command/measure/entity/AcApMeasureDrawUtil.js.map +1 -1
- package/lib/command/measure/entity/AcApMeasureEntityFactory.d.ts.map +1 -1
- package/lib/command/measure/entity/AcApMeasureEntityFactory.js +1 -1
- package/lib/command/measure/entity/AcApMeasureEntityFactory.js.map +1 -1
- package/lib/command/modify/AcApEraseCmd.d.ts +1 -0
- package/lib/command/modify/AcApEraseCmd.d.ts.map +1 -1
- package/lib/command/modify/AcApEraseCmd.js +4 -2
- package/lib/command/modify/AcApEraseCmd.js.map +1 -1
- package/lib/editor/grip/AcEdGripEditSession.d.ts.map +1 -1
- package/lib/editor/grip/AcEdGripEditSession.js +2 -0
- package/lib/editor/grip/AcEdGripEditSession.js.map +1 -1
- package/lib/editor/input/AcEdOsnapCenterMarks.d.ts +23 -0
- package/lib/editor/input/AcEdOsnapCenterMarks.d.ts.map +1 -0
- package/lib/editor/input/AcEdOsnapCenterMarks.js +240 -0
- package/lib/editor/input/AcEdOsnapCenterMarks.js.map +1 -0
- package/lib/editor/input/AcEdOsnapResolver.d.ts +18 -0
- package/lib/editor/input/AcEdOsnapResolver.d.ts.map +1 -1
- package/lib/editor/input/AcEdOsnapResolver.js +159 -10
- package/lib/editor/input/AcEdOsnapResolver.js.map +1 -1
- package/lib/editor/input/marker/AcEdMarker.d.ts +1 -1
- package/lib/editor/input/marker/AcEdMarker.d.ts.map +1 -1
- package/lib/editor/input/marker/AcEdMarker.js +11 -1
- package/lib/editor/input/marker/AcEdMarker.js.map +1 -1
- package/lib/editor/input/marker/AcEdOSnapMarkerManager.d.ts +17 -1
- package/lib/editor/input/marker/AcEdOSnapMarkerManager.d.ts.map +1 -1
- package/lib/editor/input/marker/AcEdOSnapMarkerManager.js +71 -10
- package/lib/editor/input/marker/AcEdOSnapMarkerManager.js.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInput.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInput.js +4 -0
- package/lib/editor/input/ui/AcEdFloatingInput.js.map +1 -1
- package/lib/i18n/cs/jig.d.ts +3 -0
- package/lib/i18n/cs/jig.d.ts.map +1 -1
- package/lib/i18n/cs/jig.js +6 -3
- package/lib/i18n/cs/jig.js.map +1 -1
- package/lib/i18n/en/jig.d.ts +3 -0
- package/lib/i18n/en/jig.d.ts.map +1 -1
- package/lib/i18n/en/jig.js +6 -3
- package/lib/i18n/en/jig.js.map +1 -1
- package/lib/i18n/tr/jig.d.ts +3 -0
- package/lib/i18n/tr/jig.d.ts.map +1 -1
- package/lib/i18n/tr/jig.js +6 -3
- package/lib/i18n/tr/jig.js.map +1 -1
- package/lib/i18n/zh/jig.d.ts +3 -0
- package/lib/i18n/zh/jig.d.ts.map +1 -1
- package/lib/i18n/zh/jig.js +6 -3
- package/lib/i18n/zh/jig.js.map +1 -1
- package/lib/service/AcApEntityService.d.ts +4 -2
- package/lib/service/AcApEntityService.d.ts.map +1 -1
- package/lib/service/AcApEntityService.js +14 -10
- package/lib/service/AcApEntityService.js.map +1 -1
- package/lib/ui/AcApDrawStyle.d.ts +19 -1
- package/lib/ui/AcApDrawStyle.d.ts.map +1 -1
- package/lib/ui/AcApDrawStyle.js +22 -1
- package/lib/ui/AcApDrawStyle.js.map +1 -1
- package/lib/ui/AcApDrawStyleToolbar.d.ts +12 -7
- package/lib/ui/AcApDrawStyleToolbar.d.ts.map +1 -1
- package/lib/ui/AcApDrawStyleToolbar.js +173 -52
- package/lib/ui/AcApDrawStyleToolbar.js.map +1 -1
- package/lib/util/AcApCssColor.d.ts +8 -0
- package/lib/util/AcApCssColor.d.ts.map +1 -0
- package/lib/util/AcApCssColor.js +20 -0
- package/lib/util/AcApCssColor.js.map +1 -0
- package/lib/util/AcApMeasurementUtil.d.ts.map +1 -1
- package/lib/util/AcApMeasurementUtil.js +3 -2
- package/lib/util/AcApMeasurementUtil.js.map +1 -1
- package/lib/util/AcApScreenHitTest.d.ts +5 -1
- package/lib/util/AcApScreenHitTest.d.ts.map +1 -1
- package/lib/util/AcApScreenHitTest.js +9 -3
- package/lib/util/AcApScreenHitTest.js.map +1 -1
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/lib/view/AcTrView2d.d.ts +6 -1
- package/lib/view/AcTrView2d.d.ts.map +1 -1
- package/lib/view/AcTrView2d.js +62 -34
- package/lib/view/AcTrView2d.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AcDbDatabase } from '@mlightcad/data-model';
|
|
2
2
|
import { type AcApMeasurementStyle } from '../../../util';
|
|
3
3
|
import type { AcTrView2d } from '../../../view';
|
|
4
4
|
import type { AcApMeasurementRecord } from '../AcApMeasurementTypes';
|
|
5
5
|
import { type AcApMeasureCircleGeom } from './AcApMeasureDrawUtil';
|
|
6
6
|
import { AcApMeasureEntity, type AcApMeasureEntityOptions, type AcApMeasureWorldDrawResult } from './AcApMeasureEntity';
|
|
7
|
+
type Point2 = {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
7
11
|
/**
|
|
8
12
|
* Arc-length measurement overlay entity.
|
|
9
13
|
*
|
|
10
|
-
* Renders a canvas stroke of the
|
|
11
|
-
*
|
|
14
|
+
* Renders a canvas stroke of the measured arc (the sweep that contains
|
|
15
|
+
* {@link through} when present, otherwise the shorter arc), HTML dots at
|
|
16
|
+
* the control points, and a length badge at the arc midpoint.
|
|
12
17
|
* Redraws the arc on view changes.
|
|
13
18
|
*/
|
|
14
19
|
export declare class AcApMeasureArcEntity extends AcApMeasureEntity {
|
|
@@ -16,6 +21,8 @@ export declare class AcApMeasureArcEntity extends AcApMeasureEntity {
|
|
|
16
21
|
private readonly geom;
|
|
17
22
|
/** Arc start point in world XY. */
|
|
18
23
|
private readonly start;
|
|
24
|
+
/** Optional point on the measured sweep (distinguishes major vs minor arc). */
|
|
25
|
+
private readonly through;
|
|
19
26
|
/** Arc end point in world XY. */
|
|
20
27
|
private readonly end;
|
|
21
28
|
/**
|
|
@@ -25,14 +32,13 @@ export declare class AcApMeasureArcEntity extends AcApMeasureEntity {
|
|
|
25
32
|
* @param start - Arc start point in world XY
|
|
26
33
|
* @param end - Arc end point in world XY
|
|
27
34
|
* @param options - Shared id, layout, and style options
|
|
35
|
+
* @param through - Point on the measured sweep; omit for legacy short-arc records
|
|
28
36
|
*/
|
|
29
|
-
constructor(geom: AcApMeasureCircleGeom, start:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
y: number;
|
|
35
|
-
}, options: AcApMeasureEntityOptions);
|
|
37
|
+
constructor(geom: AcApMeasureCircleGeom, start: Point2, end: Point2, options: AcApMeasureEntityOptions, through?: Point2);
|
|
38
|
+
/**
|
|
39
|
+
* Reconstructs the measured sweep from stored control points.
|
|
40
|
+
*/
|
|
41
|
+
private resolveMeasuredArc;
|
|
36
42
|
/**
|
|
37
43
|
* Factory that builds an arc entity from circle geometry, endpoints, and style.
|
|
38
44
|
*
|
|
@@ -40,23 +46,18 @@ export declare class AcApMeasureArcEntity extends AcApMeasureEntity {
|
|
|
40
46
|
* @param start - Arc start point in world XY
|
|
41
47
|
* @param end - Arc end point in world XY
|
|
42
48
|
* @param style - Measurement visual style
|
|
43
|
-
* @param options - Optional id and
|
|
49
|
+
* @param options - Optional id, layout, and through-point overrides
|
|
44
50
|
* @returns New {@link AcApMeasureArcEntity}
|
|
45
51
|
*/
|
|
46
|
-
static create(geom: AcApMeasureCircleGeom, start: {
|
|
47
|
-
x: number;
|
|
48
|
-
y: number;
|
|
49
|
-
}, end: {
|
|
50
|
-
x: number;
|
|
51
|
-
y: number;
|
|
52
|
-
}, style: AcApMeasurementStyle, options?: {
|
|
52
|
+
static create(geom: AcApMeasureCircleGeom, start: Point2, end: Point2, style: AcApMeasurementStyle, options?: {
|
|
53
53
|
id?: string;
|
|
54
54
|
layoutId?: string;
|
|
55
|
+
through?: Point2;
|
|
55
56
|
}): AcApMeasureArcEntity;
|
|
56
57
|
/**
|
|
57
|
-
* Primary anchor for the measurement (midpoint of the
|
|
58
|
+
* Primary anchor for the measurement (midpoint of the measured sweep).
|
|
58
59
|
*
|
|
59
|
-
* @returns World point on the
|
|
60
|
+
* @returns World point on the arc between {@link start} and {@link end}
|
|
60
61
|
*/
|
|
61
62
|
primaryPoint(): {
|
|
62
63
|
x: number;
|
|
@@ -67,11 +68,11 @@ export declare class AcApMeasureArcEntity extends AcApMeasureEntity {
|
|
|
67
68
|
* Serializes this arc measurement to a store/sidecar record.
|
|
68
69
|
*
|
|
69
70
|
* @param layoutId - Optional layout BTR id written onto the record
|
|
70
|
-
* @returns Record with `type: 'arc'` and center/radius/start/end geometry
|
|
71
|
+
* @returns Record with `type: 'arc'` and center/radius/start/through/end geometry
|
|
71
72
|
*/
|
|
72
73
|
toRecord(layoutId?: string): AcApMeasurementRecord;
|
|
73
74
|
/**
|
|
74
|
-
* Draws the arc canvas stroke,
|
|
75
|
+
* Draws the arc canvas stroke, control-point dots, length badge, and extras.
|
|
75
76
|
*
|
|
76
77
|
* Registers a `viewChanged` listener to repaint the arc; dispose extras
|
|
77
78
|
* remove the listener.
|
|
@@ -82,4 +83,5 @@ export declare class AcApMeasureArcEntity extends AcApMeasureEntity {
|
|
|
82
83
|
*/
|
|
83
84
|
protected subWorldDrawWithDb(view: AcTrView2d, db: AcDbDatabase): AcApMeasureWorldDrawResult;
|
|
84
85
|
}
|
|
86
|
+
export {};
|
|
85
87
|
//# sourceMappingURL=AcApMeasureArcEntity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcApMeasureArcEntity.d.ts","sourceRoot":"","sources":["../../../../src/command/measure/entity/AcApMeasureArcEntity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"AcApMeasureArcEntity.d.ts","sourceRoot":"","sources":["../../../../src/command/measure/entity/AcApMeasureArcEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAiB,MAAM,uBAAuB,CAAA;AAOxE,OAAO,EAEL,KAAK,oBAAoB,EAE1B,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAChC,MAAM,qBAAqB,CAAA;AAE5B,KAAK,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEtC;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB;IACzD,0DAA0D;IAC1D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAuB;IAC5C,mCAAmC;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,+EAA+E;IAC/E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,iCAAiC;IACjC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAE5B;;;;;;;;OAQG;gBAED,IAAI,EAAE,qBAAqB,EAC3B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,wBAAwB,EACjC,OAAO,CAAC,EAAE,MAAM;IASlB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAc1B;;;;;;;;;OASG;IACH,MAAM,CAAC,MAAM,CACX,IAAI,EAAE,qBAAqB,EAC3B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,oBAAoB,EAC3B,OAAO,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7D,oBAAoB;IAcvB;;;;OAIG;IACM,YAAY;;;;;IAOrB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,qBAAqB;IAmBlD;;;;;;;;;OASG;IACH,SAAS,CAAC,kBAAkB,CAC1B,IAAI,EAAE,UAAU,EAChB,EAAE,EAAE,YAAY,GACf,0BAA0B;CA6E9B"}
|
|
@@ -13,17 +13,55 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
+
var __assign = (this && this.__assign) || function () {
|
|
17
|
+
__assign = Object.assign || function(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
return __assign.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
28
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
29
|
+
if (!m) return o;
|
|
30
|
+
var i = m.call(o), r, ar = [], e;
|
|
31
|
+
try {
|
|
32
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
33
|
+
}
|
|
34
|
+
catch (error) { e = { error: error }; }
|
|
35
|
+
finally {
|
|
36
|
+
try {
|
|
37
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
38
|
+
}
|
|
39
|
+
finally { if (e) throw e.error; }
|
|
40
|
+
}
|
|
41
|
+
return ar;
|
|
42
|
+
};
|
|
43
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
44
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
45
|
+
if (ar || !(i in from)) {
|
|
46
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
47
|
+
ar[i] = from[i];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
51
|
+
};
|
|
52
|
+
import { AcGeCircArc2d } from '@mlightcad/data-model';
|
|
16
53
|
import { AcTrHtmlBadge, AcTrHtmlCanvasOverlay, AcTrHtmlDot } from '@mlightcad/three-renderer';
|
|
17
54
|
import { acapMeasurementCanvasLineWidth, formatMeasurementLength } from '../../../util';
|
|
18
55
|
import { serializeMeasurementStyle } from '../AcApMeasurementSidecar';
|
|
19
56
|
import { getMeasurementStyle, MEASUREMENT_LAYER } from '../AcApMeasurementStore';
|
|
20
|
-
import { drawMeasureArcOnCanvas
|
|
57
|
+
import { drawMeasureArcOnCanvas } from './AcApMeasureDrawUtil';
|
|
21
58
|
import { AcApMeasureEntity } from './AcApMeasureEntity';
|
|
22
59
|
/**
|
|
23
60
|
* Arc-length measurement overlay entity.
|
|
24
61
|
*
|
|
25
|
-
* Renders a canvas stroke of the
|
|
26
|
-
*
|
|
62
|
+
* Renders a canvas stroke of the measured arc (the sweep that contains
|
|
63
|
+
* {@link through} when present, otherwise the shorter arc), HTML dots at
|
|
64
|
+
* the control points, and a length badge at the arc midpoint.
|
|
27
65
|
* Redraws the arc on view changes.
|
|
28
66
|
*/
|
|
29
67
|
var AcApMeasureArcEntity = /** @class */ (function (_super) {
|
|
@@ -35,15 +73,29 @@ var AcApMeasureArcEntity = /** @class */ (function (_super) {
|
|
|
35
73
|
* @param start - Arc start point in world XY
|
|
36
74
|
* @param end - Arc end point in world XY
|
|
37
75
|
* @param options - Shared id, layout, and style options
|
|
76
|
+
* @param through - Point on the measured sweep; omit for legacy short-arc records
|
|
38
77
|
*/
|
|
39
|
-
function AcApMeasureArcEntity(geom, start, end, options) {
|
|
78
|
+
function AcApMeasureArcEntity(geom, start, end, options, through) {
|
|
40
79
|
var _a;
|
|
41
80
|
var _this = _super.call(this, (_a = options.id) !== null && _a !== void 0 ? _a : "arc-".concat(Date.now()), options.layoutId, options.style) || this;
|
|
42
81
|
_this.geom = geom;
|
|
43
82
|
_this.start = start;
|
|
44
83
|
_this.end = end;
|
|
84
|
+
_this.through = through;
|
|
45
85
|
return _this;
|
|
46
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Reconstructs the measured sweep from stored control points.
|
|
89
|
+
*/
|
|
90
|
+
AcApMeasureArcEntity.prototype.resolveMeasuredArc = function () {
|
|
91
|
+
if (this.through) {
|
|
92
|
+
return AcGeCircArc2d.tryCreateByThreePoints(this.start, this.through, this.end);
|
|
93
|
+
}
|
|
94
|
+
return AcGeCircArc2d.tryCreateShorterArc(this.start, this.end, {
|
|
95
|
+
x: this.geom.cx,
|
|
96
|
+
y: this.geom.cy
|
|
97
|
+
});
|
|
98
|
+
};
|
|
47
99
|
/**
|
|
48
100
|
* Factory that builds an arc entity from circle geometry, endpoints, and style.
|
|
49
101
|
*
|
|
@@ -51,7 +103,7 @@ var AcApMeasureArcEntity = /** @class */ (function (_super) {
|
|
|
51
103
|
* @param start - Arc start point in world XY
|
|
52
104
|
* @param end - Arc end point in world XY
|
|
53
105
|
* @param style - Measurement visual style
|
|
54
|
-
* @param options - Optional id and
|
|
106
|
+
* @param options - Optional id, layout, and through-point overrides
|
|
55
107
|
* @returns New {@link AcApMeasureArcEntity}
|
|
56
108
|
*/
|
|
57
109
|
AcApMeasureArcEntity.create = function (geom, start, end, style, options) {
|
|
@@ -59,21 +111,25 @@ var AcApMeasureArcEntity = /** @class */ (function (_super) {
|
|
|
59
111
|
style: style,
|
|
60
112
|
id: options === null || options === void 0 ? void 0 : options.id,
|
|
61
113
|
layoutId: options === null || options === void 0 ? void 0 : options.layoutId
|
|
62
|
-
});
|
|
114
|
+
}, options === null || options === void 0 ? void 0 : options.through);
|
|
63
115
|
};
|
|
64
116
|
/**
|
|
65
|
-
* Primary anchor for the measurement (midpoint of the
|
|
117
|
+
* Primary anchor for the measurement (midpoint of the measured sweep).
|
|
66
118
|
*
|
|
67
|
-
* @returns World point on the
|
|
119
|
+
* @returns World point on the arc between {@link start} and {@link end}
|
|
68
120
|
*/
|
|
69
121
|
AcApMeasureArcEntity.prototype.primaryPoint = function () {
|
|
70
|
-
|
|
122
|
+
var _a;
|
|
123
|
+
var mid = (_a = this.resolveMeasuredArc()) === null || _a === void 0 ? void 0 : _a.midPoint;
|
|
124
|
+
return mid
|
|
125
|
+
? { x: mid.x, y: mid.y, z: 0 }
|
|
126
|
+
: { x: this.start.x, y: this.start.y, z: 0 };
|
|
71
127
|
};
|
|
72
128
|
/**
|
|
73
129
|
* Serializes this arc measurement to a store/sidecar record.
|
|
74
130
|
*
|
|
75
131
|
* @param layoutId - Optional layout BTR id written onto the record
|
|
76
|
-
* @returns Record with `type: 'arc'` and center/radius/start/end geometry
|
|
132
|
+
* @returns Record with `type: 'arc'` and center/radius/start/through/end geometry
|
|
77
133
|
*/
|
|
78
134
|
AcApMeasureArcEntity.prototype.toRecord = function (layoutId) {
|
|
79
135
|
return {
|
|
@@ -81,17 +137,13 @@ var AcApMeasureArcEntity = /** @class */ (function (_super) {
|
|
|
81
137
|
type: 'arc',
|
|
82
138
|
layoutId: layoutId,
|
|
83
139
|
style: serializeMeasurementStyle(this.style),
|
|
84
|
-
geometry: {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
radius: this.geom.r,
|
|
88
|
-
start: { x: this.start.x, y: this.start.y },
|
|
89
|
-
end: { x: this.end.x, y: this.end.y }
|
|
90
|
-
}
|
|
140
|
+
geometry: __assign({ type: 'arc', center: { x: this.geom.cx, y: this.geom.cy }, radius: this.geom.r, start: { x: this.start.x, y: this.start.y }, end: { x: this.end.x, y: this.end.y } }, (this.through
|
|
141
|
+
? { through: { x: this.through.x, y: this.through.y } }
|
|
142
|
+
: {}))
|
|
91
143
|
};
|
|
92
144
|
};
|
|
93
145
|
/**
|
|
94
|
-
* Draws the arc canvas stroke,
|
|
146
|
+
* Draws the arc canvas stroke, control-point dots, length badge, and extras.
|
|
95
147
|
*
|
|
96
148
|
* Registers a `viewChanged` listener to repaint the arc; dispose extras
|
|
97
149
|
* remove the listener.
|
|
@@ -101,10 +153,12 @@ var AcApMeasureArcEntity = /** @class */ (function (_super) {
|
|
|
101
153
|
* @returns World-draw result including redraw/dispose hooks
|
|
102
154
|
*/
|
|
103
155
|
AcApMeasureArcEntity.prototype.subWorldDrawWithDb = function (view, db) {
|
|
156
|
+
var _a;
|
|
104
157
|
var _this = this;
|
|
158
|
+
var _b, _c;
|
|
105
159
|
var color = this.style.color;
|
|
106
|
-
var arcLen =
|
|
107
|
-
var mid =
|
|
160
|
+
var arcLen = (_c = (_b = this.resolveMeasuredArc()) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
|
|
161
|
+
var mid = this.primaryPoint();
|
|
108
162
|
var layoutId = this.resolveLayoutId(view);
|
|
109
163
|
var persistOverlay = new AcTrHtmlCanvasOverlay({
|
|
110
164
|
id: "arc-canvas-".concat(this.entityId),
|
|
@@ -114,31 +168,40 @@ var AcApMeasureArcEntity = /** @class */ (function (_super) {
|
|
|
114
168
|
});
|
|
115
169
|
var paintArc = function (paintStyle) {
|
|
116
170
|
if (paintStyle === void 0) { paintStyle = _this.style; }
|
|
117
|
-
return drawMeasureArcOnCanvas(persistOverlay.canvas, view, _this.geom, _this.start, _this.end, paintStyle.color, acapMeasurementCanvasLineWidth(paintStyle.lineWeight));
|
|
171
|
+
return drawMeasureArcOnCanvas(persistOverlay.canvas, view, _this.geom, _this.start, _this.end, paintStyle.color, acapMeasurementCanvasLineWidth(paintStyle.lineWeight), _this.through);
|
|
118
172
|
};
|
|
119
173
|
paintArc();
|
|
120
174
|
var redrawPersist = function () { var _a; return paintArc((_a = getMeasurementStyle(_this.entityId)) !== null && _a !== void 0 ? _a : _this.style); };
|
|
121
175
|
view.events.viewChanged.addEventListener(redrawPersist);
|
|
122
|
-
var group = this.createGroup(view)
|
|
123
|
-
.add(new AcTrHtmlDot({
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
176
|
+
var group = (_a = this.createGroup(view))
|
|
177
|
+
.add.apply(_a, __spreadArray(__spreadArray([new AcTrHtmlDot({
|
|
178
|
+
id: "".concat(this.entityId, "-dot1"),
|
|
179
|
+
color: color,
|
|
180
|
+
worldPosition: this.start,
|
|
181
|
+
layer: MEASUREMENT_LAYER
|
|
182
|
+
})], __read((this.through
|
|
183
|
+
? [
|
|
184
|
+
new AcTrHtmlDot({
|
|
185
|
+
id: "".concat(this.entityId, "-dot-through"),
|
|
186
|
+
color: color,
|
|
187
|
+
worldPosition: this.through,
|
|
188
|
+
layer: MEASUREMENT_LAYER
|
|
189
|
+
})
|
|
190
|
+
]
|
|
191
|
+
: [])), false), [new AcTrHtmlDot({
|
|
192
|
+
id: "".concat(this.entityId, "-dot2"),
|
|
193
|
+
color: color,
|
|
194
|
+
worldPosition: this.end,
|
|
195
|
+
layer: MEASUREMENT_LAYER
|
|
196
|
+
}),
|
|
197
|
+
new AcTrHtmlBadge({
|
|
198
|
+
id: "".concat(this.entityId, "-badge"),
|
|
199
|
+
color: color,
|
|
200
|
+
text: formatMeasurementLength(db, arcLen),
|
|
201
|
+
worldPosition: mid,
|
|
202
|
+
layer: MEASUREMENT_LAYER,
|
|
203
|
+
fontSize: this.style.fontSize
|
|
204
|
+
})], false)).addCanvas(persistOverlay);
|
|
142
205
|
return {
|
|
143
206
|
group: group,
|
|
144
207
|
entityIds: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcApMeasureArcEntity.js","sourceRoot":"","sources":["../../../../src/command/measure/entity/AcApMeasureArcEntity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AcApMeasureArcEntity.js","sourceRoot":"","sources":["../../../../src/command/measure/entity/AcApMeasureArcEntity.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACxE,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,WAAW,EACZ,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,8BAA8B,EAE9B,uBAAuB,EACxB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,y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D,CAAC;YACD,MAAM,EAAE;gBACN,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE;gBACxC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACjC,MAAM,EAAE,QAAQ;aACjB;SACF,CAAA;IACH,CAAC;IACH,2BAAC;AAAD,CAAC,AA/MD,CAA0C,iBAAiB,GA+M1D"}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AcCmColor } from '@mlightcad/data-model';
|
|
2
2
|
import type { AcEdBaseView } from '../../../editor';
|
|
3
|
+
/**
|
|
4
|
+
* Circle geometry in world XY used by arc-length measurement overlays.
|
|
5
|
+
*/
|
|
6
|
+
export interface AcApMeasureCircleGeom {
|
|
7
|
+
/** Circle center X in world coordinates. */
|
|
8
|
+
cx: number;
|
|
9
|
+
/** Circle center Y in world coordinates. */
|
|
10
|
+
cy: number;
|
|
11
|
+
/** Circle radius in world units. */
|
|
12
|
+
r: number;
|
|
13
|
+
}
|
|
3
14
|
/**
|
|
4
15
|
* Two-dimensional point in world or screen space (XY only).
|
|
5
16
|
*/
|
|
@@ -50,53 +61,39 @@ export declare function drawMeasureAngleArcOnCanvas(canvas: HTMLCanvasElement, v
|
|
|
50
61
|
*/
|
|
51
62
|
export declare function drawMeasureAreaOnCanvas(canvas: HTMLCanvasElement, view: AcEdBaseView, points: Point2[], color: AcCmColor, lineWidth?: number): void;
|
|
52
63
|
/**
|
|
53
|
-
*
|
|
64
|
+
* Strokes a circular arc onto an already-prepared measure overlay context.
|
|
65
|
+
*
|
|
66
|
+
* When `through` is given, the sweep that contains it is drawn (including
|
|
67
|
+
* major arcs over 180 degrees). Otherwise the shorter screen-space arc is
|
|
68
|
+
* used so legacy sidecar records without a through point keep their previous
|
|
69
|
+
* look.
|
|
70
|
+
*
|
|
71
|
+
* @param ctx - Overlay context in CSS pixels
|
|
72
|
+
* @param view - View for world-to-screen conversion
|
|
73
|
+
* @param g - Circle center and radius in world coordinates
|
|
74
|
+
* @param start - Arc start in world coordinates
|
|
75
|
+
* @param end - Arc end in world coordinates
|
|
76
|
+
* @param color - Stroke color
|
|
77
|
+
* @param lineWidth - Stroke width in CSS pixels
|
|
78
|
+
* @param through - Optional point on the measured sweep
|
|
54
79
|
*/
|
|
55
|
-
export
|
|
56
|
-
/** Circle center X in world coordinates. */
|
|
57
|
-
cx: number;
|
|
58
|
-
/** Circle center Y in world coordinates. */
|
|
59
|
-
cy: number;
|
|
60
|
-
/** Circle radius in world units. */
|
|
61
|
-
r: number;
|
|
62
|
-
}
|
|
80
|
+
export declare function strokeMeasureArcOnContext(ctx: CanvasRenderingContext2D, view: AcEdBaseView, g: AcApMeasureCircleGeom, start: Point2, end: Point2, color: AcCmColor, lineWidth: number, through?: Point2): void;
|
|
63
81
|
/**
|
|
64
|
-
* Strokes
|
|
82
|
+
* Strokes an arc between two points on a circle onto a measure canvas.
|
|
65
83
|
*
|
|
66
|
-
* Screen radius is taken from the distance of `
|
|
67
|
-
* the stroke tracks the circle under the current view transform.
|
|
84
|
+
* Screen radius is taken from the distance of `start` to the projected center
|
|
85
|
+
* so the stroke tracks the circle under the current view transform.
|
|
68
86
|
*
|
|
69
87
|
* @param canvas - Overlay canvas to paint
|
|
70
88
|
* @param view - View for world-to-screen conversion and canvas sizing
|
|
71
89
|
* @param g - Circle center and radius in world coordinates
|
|
72
|
-
* @param
|
|
73
|
-
* @param
|
|
90
|
+
* @param start - Arc start point in world coordinates (on or near the circle)
|
|
91
|
+
* @param end - Arc end point in world coordinates (on or near the circle)
|
|
74
92
|
* @param color - Stroke color
|
|
75
93
|
* @param lineWidth - Stroke width in CSS pixels (default `4`)
|
|
94
|
+
* @param through - Optional point on the measured sweep (major vs minor arc)
|
|
76
95
|
*/
|
|
77
|
-
export declare function drawMeasureArcOnCanvas(canvas: HTMLCanvasElement, view: AcEdBaseView, g: AcApMeasureCircleGeom,
|
|
78
|
-
/**
|
|
79
|
-
* Computes the shorter arc length between two points on a circle.
|
|
80
|
-
*
|
|
81
|
-
* @param p1 - First point in world coordinates
|
|
82
|
-
* @param p2 - Second point in world coordinates
|
|
83
|
-
* @param g - Circle center and radius
|
|
84
|
-
* @returns Arc length along the shorter sector (`min(span, 2π − span) × r`)
|
|
85
|
-
*/
|
|
86
|
-
export declare function measureShortArcLength(p1: Point2, p2: Point2, g: AcApMeasureCircleGeom): number;
|
|
87
|
-
/**
|
|
88
|
-
* Finds the midpoint of the shorter arc between two points on a circle.
|
|
89
|
-
*
|
|
90
|
-
* @param p1 - Arc start in world coordinates
|
|
91
|
-
* @param p2 - Arc end in world coordinates
|
|
92
|
-
* @param g - Circle center and radius
|
|
93
|
-
* @returns Midpoint on the shorter arc with `z: 0`
|
|
94
|
-
*/
|
|
95
|
-
export declare function measureShortArcMid(p1: Point2, p2: Point2, g: AcApMeasureCircleGeom): {
|
|
96
|
-
x: number;
|
|
97
|
-
y: number;
|
|
98
|
-
z: number;
|
|
99
|
-
};
|
|
96
|
+
export declare function drawMeasureArcOnCanvas(canvas: HTMLCanvasElement, view: AcEdBaseView, g: AcApMeasureCircleGeom, start: Point2, end: Point2, color: AcCmColor, lineWidth?: number, through?: Point2): void;
|
|
100
97
|
/**
|
|
101
98
|
* Computes polygon area using the shoelace formula.
|
|
102
99
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcApMeasureDrawUtil.d.ts","sourceRoot":"","sources":["../../../../src/command/measure/entity/AcApMeasureDrawUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"AcApMeasureDrawUtil.d.ts","sourceRoot":"","sources":["../../../../src/command/measure/entity/AcApMeasureDrawUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,i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;GAcG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAE,YAAY,EAClB,CAAC,EAAE,qBAAqB,EACxB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,EAChB,SAAS,SAAI,EACb,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAcN;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,CASzD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAIvE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,MAAM,CASR"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AcGeCircArc2d, AcGeMathUtil } from '@mlightcad/data-model';
|
|
1
2
|
import { acapColorToCssAlpha, acapCssColor } from '../../../util';
|
|
2
3
|
/**
|
|
3
4
|
* Sizes and clears a measure overlay canvas to match the view viewport.
|
|
@@ -32,15 +33,6 @@ function prepareMeasureCanvas(canvas, view) {
|
|
|
32
33
|
ctx.scale(dpr, dpr);
|
|
33
34
|
return { ctx: ctx, dpr: dpr };
|
|
34
35
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Normalizes an angle in radians to the half-open interval `[0, 2π)`.
|
|
37
|
-
*
|
|
38
|
-
* @param a - Angle in radians (any real value)
|
|
39
|
-
* @returns Equivalent angle in `[0, 2π)`
|
|
40
|
-
*/
|
|
41
|
-
var normaliseAngle = function (a) {
|
|
42
|
-
return ((a % (2 * Math.PI)) + 2 * Math.PI) % (2 * Math.PI);
|
|
43
|
-
};
|
|
44
36
|
/**
|
|
45
37
|
* Strokes a single world-space segment onto a measure overlay canvas.
|
|
46
38
|
*
|
|
@@ -104,7 +96,7 @@ export function drawMeasureAngleArcOnCanvas(canvas, view, vertex, arm1, arm2, co
|
|
|
104
96
|
var arcR = Math.max(Math.min(len1, len2) * 0.3, 15);
|
|
105
97
|
var startAngle = Math.atan2(sa1.y - sv.y, sa1.x - sv.x);
|
|
106
98
|
var endAngle = Math.atan2(sa2.y - sv.y, sa2.x - sv.x);
|
|
107
|
-
var antiClockwise =
|
|
99
|
+
var antiClockwise = AcGeMathUtil.normalizeAngle(endAngle - startAngle) > Math.PI;
|
|
108
100
|
ctx.beginPath();
|
|
109
101
|
ctx.arc(sv.x, sv.y, arcR, startAngle, endAngle, antiClockwise);
|
|
110
102
|
ctx.stroke();
|
|
@@ -144,68 +136,65 @@ export function drawMeasureAreaOnCanvas(canvas, view, points, color, lineWidth)
|
|
|
144
136
|
ctx.restore();
|
|
145
137
|
}
|
|
146
138
|
/**
|
|
147
|
-
* Strokes
|
|
139
|
+
* Strokes a circular arc onto an already-prepared measure overlay context.
|
|
148
140
|
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
141
|
+
* When `through` is given, the sweep that contains it is drawn (including
|
|
142
|
+
* major arcs over 180 degrees). Otherwise the shorter screen-space arc is
|
|
143
|
+
* used so legacy sidecar records without a through point keep their previous
|
|
144
|
+
* look.
|
|
151
145
|
*
|
|
152
|
-
* @param
|
|
153
|
-
* @param view - View for world-to-screen conversion
|
|
146
|
+
* @param ctx - Overlay context in CSS pixels
|
|
147
|
+
* @param view - View for world-to-screen conversion
|
|
154
148
|
* @param g - Circle center and radius in world coordinates
|
|
155
|
-
* @param
|
|
156
|
-
* @param
|
|
149
|
+
* @param start - Arc start in world coordinates
|
|
150
|
+
* @param end - Arc end in world coordinates
|
|
157
151
|
* @param color - Stroke color
|
|
158
|
-
* @param lineWidth - Stroke width in CSS pixels
|
|
152
|
+
* @param lineWidth - Stroke width in CSS pixels
|
|
153
|
+
* @param through - Optional point on the measured sweep
|
|
159
154
|
*/
|
|
160
|
-
export function
|
|
161
|
-
if (lineWidth === void 0) { lineWidth = 4; }
|
|
162
|
-
var prepared = prepareMeasureCanvas(canvas, view);
|
|
163
|
-
if (!prepared)
|
|
164
|
-
return;
|
|
165
|
-
var ctx = prepared.ctx;
|
|
155
|
+
export function strokeMeasureArcOnContext(ctx, view, g, start, end, color, lineWidth, through) {
|
|
166
156
|
var sc = view.worldToScreen({ x: g.cx, y: g.cy });
|
|
167
|
-
var ss = view.worldToScreen(
|
|
168
|
-
var se = view.worldToScreen(
|
|
157
|
+
var ss = view.worldToScreen(start);
|
|
158
|
+
var se = view.worldToScreen(end);
|
|
169
159
|
var screenR = Math.hypot(ss.x - sc.x, ss.y - sc.y);
|
|
160
|
+
if (!(screenR > 0))
|
|
161
|
+
return;
|
|
170
162
|
var sa = Math.atan2(ss.y - sc.y, ss.x - sc.x);
|
|
171
163
|
var ea = Math.atan2(se.y - sc.y, se.x - sc.x);
|
|
172
|
-
var
|
|
173
|
-
|
|
164
|
+
var measured = through
|
|
165
|
+
? AcGeCircArc2d.tryCreateByThreePoints(start, through, end)
|
|
166
|
+
: undefined;
|
|
167
|
+
var antiClockwise = measured
|
|
168
|
+
? !measured.clockwise
|
|
169
|
+
: AcGeMathUtil.normalizeAngle(ea - sa) > Math.PI;
|
|
174
170
|
ctx.beginPath();
|
|
175
171
|
ctx.arc(sc.x, sc.y, screenR, sa, ea, antiClockwise);
|
|
176
172
|
ctx.strokeStyle = acapCssColor(color);
|
|
177
173
|
ctx.lineWidth = lineWidth;
|
|
178
174
|
ctx.stroke();
|
|
179
|
-
ctx.restore();
|
|
180
175
|
}
|
|
181
176
|
/**
|
|
182
|
-
*
|
|
177
|
+
* Strokes an arc between two points on a circle onto a measure canvas.
|
|
183
178
|
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* @param g - Circle center and radius
|
|
187
|
-
* @returns Arc length along the shorter sector (`min(span, 2π − span) × r`)
|
|
188
|
-
*/
|
|
189
|
-
export function measureShortArcLength(p1, p2, g) {
|
|
190
|
-
var a1 = Math.atan2(p1.y - g.cy, p1.x - g.cx);
|
|
191
|
-
var a2 = Math.atan2(p2.y - g.cy, p2.x - g.cx);
|
|
192
|
-
var span = normaliseAngle(a2 - a1);
|
|
193
|
-
return Math.min(span, 2 * Math.PI - span) * g.r;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Finds the midpoint of the shorter arc between two points on a circle.
|
|
179
|
+
* Screen radius is taken from the distance of `start` to the projected center
|
|
180
|
+
* so the stroke tracks the circle under the current view transform.
|
|
197
181
|
*
|
|
198
|
-
* @param
|
|
199
|
-
* @param
|
|
200
|
-
* @param g - Circle center and radius
|
|
201
|
-
* @
|
|
182
|
+
* @param canvas - Overlay canvas to paint
|
|
183
|
+
* @param view - View for world-to-screen conversion and canvas sizing
|
|
184
|
+
* @param g - Circle center and radius in world coordinates
|
|
185
|
+
* @param start - Arc start point in world coordinates (on or near the circle)
|
|
186
|
+
* @param end - Arc end point in world coordinates (on or near the circle)
|
|
187
|
+
* @param color - Stroke color
|
|
188
|
+
* @param lineWidth - Stroke width in CSS pixels (default `4`)
|
|
189
|
+
* @param through - Optional point on the measured sweep (major vs minor arc)
|
|
202
190
|
*/
|
|
203
|
-
export function
|
|
204
|
-
|
|
205
|
-
var
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
191
|
+
export function drawMeasureArcOnCanvas(canvas, view, g, start, end, color, lineWidth, through) {
|
|
192
|
+
if (lineWidth === void 0) { lineWidth = 4; }
|
|
193
|
+
var prepared = prepareMeasureCanvas(canvas, view);
|
|
194
|
+
if (!prepared)
|
|
195
|
+
return;
|
|
196
|
+
strokeMeasureArcOnContext(prepared.ctx, view, g, start, end, color, lineWidth, through);
|
|
197
|
+
prepared.ctx.restore();
|
|
209
198
|
}
|
|
210
199
|
/**
|
|
211
200
|
* Computes polygon area using the shoelace formula.
|