@mlightcad/cad-simple-viewer 1.4.9 → 1.4.11
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 +17930 -12377
- package/dist/index.umd.cjs +158 -30
- package/dist/libredwg-parser-worker.js +78 -31
- package/dist/mtext-renderer-worker.js +28725 -28097
- package/lib/app/AcApAnnotation.d.ts +2 -1
- package/lib/app/AcApAnnotation.d.ts.map +1 -1
- package/lib/app/AcApAnnotation.js +2 -1
- package/lib/app/AcApAnnotation.js.map +1 -1
- package/lib/app/AcApContext.d.ts.map +1 -1
- package/lib/app/AcApContext.js +14 -3
- package/lib/app/AcApContext.js.map +1 -1
- package/lib/app/AcApDocManager.d.ts +28 -1
- package/lib/app/AcApDocManager.d.ts.map +1 -1
- package/lib/app/AcApDocManager.js +117 -16
- package/lib/app/AcApDocManager.js.map +1 -1
- package/lib/app/AcApDocument.d.ts.map +1 -1
- package/lib/app/AcApDocument.js +2 -2
- package/lib/app/AcApDocument.js.map +1 -1
- package/lib/command/AcApClearMeasurementsCmd.d.ts +13 -0
- package/lib/command/AcApClearMeasurementsCmd.d.ts.map +1 -0
- package/lib/command/AcApClearMeasurementsCmd.js +86 -0
- package/lib/command/AcApClearMeasurementsCmd.js.map +1 -0
- package/lib/command/AcApLogCmd.d.ts.map +1 -1
- package/lib/command/AcApLogCmd.js +40 -6
- package/lib/command/AcApLogCmd.js.map +1 -1
- package/lib/command/AcApMTextCmd.d.ts +12 -0
- package/lib/command/AcApMTextCmd.d.ts.map +1 -0
- package/lib/command/AcApMTextCmd.js +120 -0
- package/lib/command/AcApMTextCmd.js.map +1 -0
- package/lib/command/AcApMeasureAngleCmd.d.ts +15 -0
- package/lib/command/AcApMeasureAngleCmd.d.ts.map +1 -0
- package/lib/command/AcApMeasureAngleCmd.js +358 -0
- package/lib/command/AcApMeasureAngleCmd.js.map +1 -0
- package/lib/command/AcApMeasureArcCmd.d.ts +25 -0
- package/lib/command/AcApMeasureArcCmd.d.ts.map +1 -0
- package/lib/command/AcApMeasureArcCmd.js +411 -0
- package/lib/command/AcApMeasureArcCmd.js.map +1 -0
- package/lib/command/AcApMeasureAreaCmd.d.ts +21 -0
- package/lib/command/AcApMeasureAreaCmd.d.ts.map +1 -0
- package/lib/command/AcApMeasureAreaCmd.js +379 -0
- package/lib/command/AcApMeasureAreaCmd.js.map +1 -0
- package/lib/command/AcApMeasureDistanceCmd.d.ts +34 -0
- package/lib/command/AcApMeasureDistanceCmd.d.ts.map +1 -0
- package/lib/command/AcApMeasureDistanceCmd.js +179 -0
- package/lib/command/AcApMeasureDistanceCmd.js.map +1 -0
- package/lib/command/AcApSwitchBgCmd.js +2 -2
- package/lib/command/AcApSwitchBgCmd.js.map +1 -1
- package/lib/command/AcApSysVarCmd.d.ts.map +1 -1
- package/lib/command/AcApSysVarCmd.js +16 -6
- package/lib/command/AcApSysVarCmd.js.map +1 -1
- package/lib/command/AcApZoomToBoxCmd.d.ts +1 -1
- package/lib/command/AcApZoomToBoxCmd.d.ts.map +1 -1
- package/lib/command/AcApZoomToBoxCmd.js +6 -3
- package/lib/command/AcApZoomToBoxCmd.js.map +1 -1
- package/lib/command/index.d.ts +6 -0
- package/lib/command/index.d.ts.map +1 -1
- package/lib/command/index.js +6 -0
- package/lib/command/index.js.map +1 -1
- package/lib/editor/global/AcEdConditionWaiter.d.ts +1 -1
- package/lib/editor/global/AcEdConditionWaiter.d.ts.map +1 -1
- package/lib/editor/global/AcEdConditionWaiter.js +3 -2
- package/lib/editor/global/AcEdConditionWaiter.js.map +1 -1
- package/lib/editor/input/AcEdCursorManager.js +2 -2
- package/lib/editor/input/AcEdCursorManager.js.map +1 -1
- package/lib/editor/input/AcEditor.d.ts +9 -2
- package/lib/editor/input/AcEditor.d.ts.map +1 -1
- package/lib/editor/input/AcEditor.js +13 -2
- package/lib/editor/input/AcEditor.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptBoxOptions.d.ts +20 -0
- package/lib/editor/input/prompt/AcEdPromptBoxOptions.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptBoxOptions.js +80 -0
- package/lib/editor/input/prompt/AcEdPromptBoxOptions.js.map +1 -0
- package/lib/editor/input/prompt/index.d.ts +1 -0
- package/lib/editor/input/prompt/index.d.ts.map +1 -1
- package/lib/editor/input/prompt/index.js +1 -0
- package/lib/editor/input/prompt/index.js.map +1 -1
- package/lib/editor/input/ui/AcEdInputManager.d.ts +23 -2
- package/lib/editor/input/ui/AcEdInputManager.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdInputManager.js +114 -7
- package/lib/editor/input/ui/AcEdInputManager.js.map +1 -1
- package/lib/editor/input/ui/AcEdMTextEditor.d.ts +79 -0
- package/lib/editor/input/ui/AcEdMTextEditor.d.ts.map +1 -0
- package/lib/editor/input/ui/AcEdMTextEditor.js +157 -0
- package/lib/editor/input/ui/AcEdMTextEditor.js.map +1 -0
- package/lib/editor/input/ui/index.d.ts +2 -0
- package/lib/editor/input/ui/index.d.ts.map +1 -1
- package/lib/editor/input/ui/index.js +1 -0
- package/lib/editor/input/ui/index.js.map +1 -1
- package/lib/editor/view/AcEdBaseView.d.ts +15 -0
- package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
- package/lib/editor/view/AcEdBaseView.js +3 -1
- package/lib/editor/view/AcEdBaseView.js.map +1 -1
- package/lib/i18n/en/command.d.ts +12 -0
- package/lib/i18n/en/command.d.ts.map +1 -1
- package/lib/i18n/en/command.js +12 -0
- package/lib/i18n/en/command.js.map +1 -1
- package/lib/i18n/en/jig.d.ts +21 -0
- package/lib/i18n/en/jig.d.ts.map +1 -1
- package/lib/i18n/en/jig.js +21 -0
- package/lib/i18n/en/jig.js.map +1 -1
- package/lib/i18n/zh/command.d.ts +12 -0
- package/lib/i18n/zh/command.d.ts.map +1 -1
- package/lib/i18n/zh/command.js +12 -0
- package/lib/i18n/zh/command.js.map +1 -1
- package/lib/i18n/zh/jig.d.ts +21 -0
- package/lib/i18n/zh/jig.d.ts.map +1 -1
- package/lib/i18n/zh/jig.js +21 -0
- package/lib/i18n/zh/jig.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/plugin/AcApPluginExample.d.ts.map +1 -1
- package/lib/plugin/AcApPluginExample.js +7 -6
- package/lib/plugin/AcApPluginExample.js.map +1 -1
- package/lib/plugin/AcApPluginManager.d.ts +4 -4
- package/lib/plugin/AcApPluginManager.d.ts.map +1 -1
- package/lib/plugin/AcApPluginManager.js +7 -6
- package/lib/plugin/AcApPluginManager.js.map +1 -1
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.d.ts.map +1 -1
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js +1 -0
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js.map +1 -1
- package/lib/util/AcApMeasurementUtils.d.ts +12 -0
- package/lib/util/AcApMeasurementUtils.d.ts.map +1 -0
- package/lib/util/AcApMeasurementUtils.js +36 -0
- package/lib/util/AcApMeasurementUtils.js.map +1 -0
- 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/AcTrLayer.d.ts +15 -0
- package/lib/view/AcTrLayer.d.ts.map +1 -1
- package/lib/view/AcTrLayer.js +13 -2
- package/lib/view/AcTrLayer.js.map +1 -1
- package/lib/view/AcTrLayout.d.ts +25 -0
- package/lib/view/AcTrLayout.d.ts.map +1 -1
- package/lib/view/AcTrLayout.js +40 -3
- package/lib/view/AcTrLayout.js.map +1 -1
- package/lib/view/AcTrLayoutView.d.ts +5 -0
- package/lib/view/AcTrLayoutView.d.ts.map +1 -1
- package/lib/view/AcTrLayoutView.js +10 -0
- package/lib/view/AcTrLayoutView.js.map +1 -1
- package/lib/view/AcTrScene.d.ts +30 -4
- package/lib/view/AcTrScene.d.ts.map +1 -1
- package/lib/view/AcTrScene.js +59 -3
- package/lib/view/AcTrScene.js.map +1 -1
- package/lib/view/AcTrView2d.d.ts +17 -4
- package/lib/view/AcTrView2d.d.ts.map +1 -1
- package/lib/view/AcTrView2d.js +64 -15
- package/lib/view/AcTrView2d.js.map +1 -1
- package/package.json +7 -6
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
27
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
53
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
54
|
+
if (!m) return o;
|
|
55
|
+
var i = m.call(o), r, ar = [], e;
|
|
56
|
+
try {
|
|
57
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
58
|
+
}
|
|
59
|
+
catch (error) { e = { error: error }; }
|
|
60
|
+
finally {
|
|
61
|
+
try {
|
|
62
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
63
|
+
}
|
|
64
|
+
finally { if (e) throw e.error; }
|
|
65
|
+
}
|
|
66
|
+
return ar;
|
|
67
|
+
};
|
|
68
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
69
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
70
|
+
if (ar || !(i in from)) {
|
|
71
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
72
|
+
ar[i] = from[i];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
76
|
+
};
|
|
77
|
+
import { AcDbLine, AcGiLineWeight } from '@mlightcad/data-model';
|
|
78
|
+
import { AcApDocManager } from '../app';
|
|
79
|
+
import { AcEdCommand, AcEdOpenMode, AcEdPreviewJig, AcEdPromptPointOptions } from '../editor';
|
|
80
|
+
import { AcApI18n } from '../i18n';
|
|
81
|
+
import { colorToCss, colorToCssAlpha, makeBadge, makeDot, measurementColor } from '../util';
|
|
82
|
+
import { registerMeasurementCleanup } from './AcApClearMeasurementsCmd';
|
|
83
|
+
/**
|
|
84
|
+
* Rubber-band jig: shows a preview line from the last confirmed
|
|
85
|
+
* vertex to the current cursor position and fires onMove on each update.
|
|
86
|
+
*/
|
|
87
|
+
var AcApMeasureAreaJig = /** @class */ (function (_super) {
|
|
88
|
+
__extends(AcApMeasureAreaJig, _super);
|
|
89
|
+
function AcApMeasureAreaJig(view, from, color, onMove) {
|
|
90
|
+
var _this = _super.call(this, view) || this;
|
|
91
|
+
_this._line = new AcDbLine(from, from);
|
|
92
|
+
_this._line.color = color;
|
|
93
|
+
_this._line.lineWeight = AcGiLineWeight.LineWeight070;
|
|
94
|
+
_this._onMove = onMove;
|
|
95
|
+
return _this;
|
|
96
|
+
}
|
|
97
|
+
Object.defineProperty(AcApMeasureAreaJig.prototype, "entity", {
|
|
98
|
+
get: function () {
|
|
99
|
+
return this._line;
|
|
100
|
+
},
|
|
101
|
+
enumerable: false,
|
|
102
|
+
configurable: true
|
|
103
|
+
});
|
|
104
|
+
AcApMeasureAreaJig.prototype.update = function (p) {
|
|
105
|
+
this._line.endPoint = p;
|
|
106
|
+
this._onMove(p);
|
|
107
|
+
};
|
|
108
|
+
return AcApMeasureAreaJig;
|
|
109
|
+
}(AcEdPreviewJig));
|
|
110
|
+
/**
|
|
111
|
+
* Returns true when segment (p1→p2) properly crosses segment (p3→p4).
|
|
112
|
+
* Endpoint-touches are intentionally excluded so adjacent edges never trigger.
|
|
113
|
+
*/
|
|
114
|
+
function segmentsIntersect(p1, p2, p3, p4) {
|
|
115
|
+
var d1x = p2.x - p1.x, d1y = p2.y - p1.y;
|
|
116
|
+
var d2x = p4.x - p3.x, d2y = p4.y - p3.y;
|
|
117
|
+
var denom = d1x * d2y - d1y * d2x;
|
|
118
|
+
if (Math.abs(denom) < 1e-10)
|
|
119
|
+
return false; // parallel
|
|
120
|
+
var dx = p3.x - p1.x, dy = p3.y - p1.y;
|
|
121
|
+
var t = (dx * d2y - dy * d2x) / denom;
|
|
122
|
+
var u = (dx * d1y - dy * d1x) / denom;
|
|
123
|
+
return t > 0 && t < 1 && u > 0 && u < 1;
|
|
124
|
+
}
|
|
125
|
+
/** Computes the area of a polygon using the shoelace (Gauss) formula. */
|
|
126
|
+
function shoelaceArea(pts) {
|
|
127
|
+
var area = 0;
|
|
128
|
+
var n = pts.length;
|
|
129
|
+
for (var i = 0; i < n; i++) {
|
|
130
|
+
var j = (i + 1) % n;
|
|
131
|
+
area += pts[i].x * pts[j].y;
|
|
132
|
+
area -= pts[j].x * pts[i].y;
|
|
133
|
+
}
|
|
134
|
+
return Math.abs(area) / 2;
|
|
135
|
+
}
|
|
136
|
+
/** Returns the arithmetic centroid of a set of world points. */
|
|
137
|
+
function centroid(pts) {
|
|
138
|
+
var x = pts.reduce(function (s, p) { return s + p.x; }, 0) / pts.length;
|
|
139
|
+
var y = pts.reduce(function (s, p) { return s + p.y; }, 0) / pts.length;
|
|
140
|
+
return { x: x, y: y };
|
|
141
|
+
}
|
|
142
|
+
/** Draws a filled polygon on a full-viewport canvas overlay. */
|
|
143
|
+
function drawAreaOnCanvas(canvas, view, points, color) {
|
|
144
|
+
var rect = view.canvas.getBoundingClientRect();
|
|
145
|
+
var dpr = window.devicePixelRatio || 1;
|
|
146
|
+
var w = Math.round(rect.width);
|
|
147
|
+
var h = Math.round(rect.height);
|
|
148
|
+
canvas.style.left = "".concat(rect.left, "px");
|
|
149
|
+
canvas.style.top = "".concat(rect.top, "px");
|
|
150
|
+
canvas.style.width = "".concat(w, "px");
|
|
151
|
+
canvas.style.height = "".concat(h, "px");
|
|
152
|
+
if (canvas.width !== w * dpr || canvas.height !== h * dpr) {
|
|
153
|
+
canvas.width = w * dpr;
|
|
154
|
+
canvas.height = h * dpr;
|
|
155
|
+
}
|
|
156
|
+
var ctx = canvas.getContext('2d');
|
|
157
|
+
if (!ctx || points.length < 3)
|
|
158
|
+
return;
|
|
159
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
160
|
+
ctx.save();
|
|
161
|
+
ctx.scale(dpr, dpr);
|
|
162
|
+
var spts = points.map(function (p) { return view.worldToScreen(p); });
|
|
163
|
+
ctx.beginPath();
|
|
164
|
+
ctx.moveTo(spts[0].x, spts[0].y);
|
|
165
|
+
for (var i = 1; i < spts.length; i++)
|
|
166
|
+
ctx.lineTo(spts[i].x, spts[i].y);
|
|
167
|
+
ctx.closePath();
|
|
168
|
+
ctx.fillStyle = colorToCssAlpha(color, 0.2);
|
|
169
|
+
ctx.fill();
|
|
170
|
+
ctx.strokeStyle = colorToCss(color);
|
|
171
|
+
ctx.lineWidth = 2.5;
|
|
172
|
+
ctx.stroke();
|
|
173
|
+
ctx.restore();
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Command that measures the area of a polygon drawn by the user.
|
|
177
|
+
*
|
|
178
|
+
* The user clicks successive vertices; after each click the canvas overlay
|
|
179
|
+
* updates with a semi-transparent blue fill and a dashed outline. The polygon
|
|
180
|
+
* auto-closes when the user clicks near the first vertex (14 px threshold),
|
|
181
|
+
* clicks near the last vertex, or draws a segment that crosses an existing
|
|
182
|
+
* edge — matching AutoCAD's area measurement behaviour. Pressing ESC/Enter
|
|
183
|
+
* also finalises the polygon.
|
|
184
|
+
*
|
|
185
|
+
* Persistent overlays are placed via {@link AcTrHtmlTransientManager} for dots
|
|
186
|
+
* and badge. The filled area canvas is managed with a viewChanged listener
|
|
187
|
+
* cleaned up via {@link registerMeasurementCleanup}.
|
|
188
|
+
*/
|
|
189
|
+
var AcApMeasureAreaCmd = /** @class */ (function (_super) {
|
|
190
|
+
__extends(AcApMeasureAreaCmd, _super);
|
|
191
|
+
function AcApMeasureAreaCmd() {
|
|
192
|
+
var _this = _super.call(this) || this;
|
|
193
|
+
_this.mode = AcEdOpenMode.Read;
|
|
194
|
+
return _this;
|
|
195
|
+
}
|
|
196
|
+
AcApMeasureAreaCmd.prototype.execute = function (context) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
+
var editor, color, points, fillCanvas, liveBadge, drawPolygon, redrawOnViewChange, p1, _loop_1, state_1, _a, area, persistCanvas, redrawPersist, htManager, id, mid;
|
|
199
|
+
return __generator(this, function (_b) {
|
|
200
|
+
switch (_b.label) {
|
|
201
|
+
case 0:
|
|
202
|
+
editor = AcApDocManager.instance.editor;
|
|
203
|
+
color = measurementColor(context.doc.database);
|
|
204
|
+
points = [];
|
|
205
|
+
fillCanvas = document.createElement('canvas');
|
|
206
|
+
fillCanvas.style.cssText =
|
|
207
|
+
'position:fixed;pointer-events:none;z-index:99997;';
|
|
208
|
+
document.body.appendChild(fillCanvas);
|
|
209
|
+
liveBadge = document.createElement('div');
|
|
210
|
+
liveBadge.style.cssText =
|
|
211
|
+
"position:fixed;background:rgba(255,255,255,0.95);color:".concat(colorToCss(color), ";") +
|
|
212
|
+
'font-size:13px;font-family:sans-serif;font-weight:500;' +
|
|
213
|
+
'padding:3px 14px;border-radius:20px;pointer-events:none;' +
|
|
214
|
+
'transform:translate(-50%,-50%);white-space:nowrap;' +
|
|
215
|
+
'box-shadow:0 1px 4px rgba(0,0,0,0.2);z-index:99999;display:none;';
|
|
216
|
+
document.body.appendChild(liveBadge);
|
|
217
|
+
drawPolygon = function (cursor) {
|
|
218
|
+
var rect = context.view.canvas.getBoundingClientRect();
|
|
219
|
+
var dpr = window.devicePixelRatio || 1;
|
|
220
|
+
var w = Math.round(rect.width);
|
|
221
|
+
var h = Math.round(rect.height);
|
|
222
|
+
fillCanvas.style.left = "".concat(rect.left, "px");
|
|
223
|
+
fillCanvas.style.top = "".concat(rect.top, "px");
|
|
224
|
+
fillCanvas.style.width = "".concat(w, "px");
|
|
225
|
+
fillCanvas.style.height = "".concat(h, "px");
|
|
226
|
+
if (fillCanvas.width !== w * dpr || fillCanvas.height !== h * dpr) {
|
|
227
|
+
fillCanvas.width = w * dpr;
|
|
228
|
+
fillCanvas.height = h * dpr;
|
|
229
|
+
}
|
|
230
|
+
var ctx = fillCanvas.getContext('2d');
|
|
231
|
+
if (!ctx || points.length < 1)
|
|
232
|
+
return;
|
|
233
|
+
ctx.clearRect(0, 0, fillCanvas.width, fillCanvas.height);
|
|
234
|
+
ctx.save();
|
|
235
|
+
ctx.scale(dpr, dpr);
|
|
236
|
+
var confirmedSpts = points.map(function (p) { return context.view.worldToScreen(p); });
|
|
237
|
+
var fillSpts = cursor
|
|
238
|
+
? __spreadArray(__spreadArray([], __read(confirmedSpts), false), [context.view.worldToScreen(cursor)], false) : confirmedSpts;
|
|
239
|
+
if (fillSpts.length >= 3) {
|
|
240
|
+
ctx.beginPath();
|
|
241
|
+
ctx.moveTo(fillSpts[0].x, fillSpts[0].y);
|
|
242
|
+
for (var i = 1; i < fillSpts.length; i++)
|
|
243
|
+
ctx.lineTo(fillSpts[i].x, fillSpts[i].y);
|
|
244
|
+
ctx.closePath();
|
|
245
|
+
ctx.fillStyle = colorToCssAlpha(color, 0.2);
|
|
246
|
+
ctx.fill();
|
|
247
|
+
}
|
|
248
|
+
if (confirmedSpts.length >= 2) {
|
|
249
|
+
ctx.beginPath();
|
|
250
|
+
ctx.moveTo(confirmedSpts[0].x, confirmedSpts[0].y);
|
|
251
|
+
for (var i = 1; i < confirmedSpts.length; i++)
|
|
252
|
+
ctx.lineTo(confirmedSpts[i].x, confirmedSpts[i].y);
|
|
253
|
+
ctx.strokeStyle = colorToCss(color);
|
|
254
|
+
ctx.lineWidth = 2.5;
|
|
255
|
+
ctx.setLineDash([8, 5]);
|
|
256
|
+
ctx.stroke();
|
|
257
|
+
ctx.setLineDash([]);
|
|
258
|
+
}
|
|
259
|
+
ctx.restore();
|
|
260
|
+
};
|
|
261
|
+
redrawOnViewChange = function () { return drawPolygon(); };
|
|
262
|
+
context.view.events.viewChanged.addEventListener(redrawOnViewChange);
|
|
263
|
+
return [4 /*yield*/, editor.getPoint(new AcEdPromptPointOptions(AcApI18n.t('jig.measureArea.firstPoint')))];
|
|
264
|
+
case 1:
|
|
265
|
+
p1 = _b.sent();
|
|
266
|
+
points.push(p1);
|
|
267
|
+
drawPolygon();
|
|
268
|
+
_b.label = 2;
|
|
269
|
+
case 2:
|
|
270
|
+
_b.trys.push([2, 6, , 7]);
|
|
271
|
+
_loop_1 = function () {
|
|
272
|
+
var prompt_1, onMove, p, sp_1, snap, last, crosses, i;
|
|
273
|
+
return __generator(this, function (_c) {
|
|
274
|
+
switch (_c.label) {
|
|
275
|
+
case 0:
|
|
276
|
+
prompt_1 = new AcEdPromptPointOptions(AcApI18n.t('jig.measureArea.nextPoint'));
|
|
277
|
+
prompt_1.useBasePoint = true;
|
|
278
|
+
onMove = function (cursor) {
|
|
279
|
+
if (points.length < 2)
|
|
280
|
+
return;
|
|
281
|
+
var tempPts = __spreadArray(__spreadArray([], __read(points), false), [cursor], false);
|
|
282
|
+
var area = shoelaceArea(tempPts);
|
|
283
|
+
liveBadge.textContent = "~ ".concat(area.toFixed(3), " m\u00B2");
|
|
284
|
+
liveBadge.style.display = '';
|
|
285
|
+
var mid = centroid(tempPts);
|
|
286
|
+
var rect = context.view.canvas.getBoundingClientRect();
|
|
287
|
+
var sc = context.view.worldToScreen(mid);
|
|
288
|
+
liveBadge.style.left = "".concat(sc.x + rect.left, "px");
|
|
289
|
+
liveBadge.style.top = "".concat(sc.y + rect.top, "px");
|
|
290
|
+
drawPolygon(cursor);
|
|
291
|
+
};
|
|
292
|
+
prompt_1.jig = new AcApMeasureAreaJig(context.view, points[points.length - 1], color, onMove);
|
|
293
|
+
return [4 /*yield*/, editor.getPoint(prompt_1)];
|
|
294
|
+
case 1:
|
|
295
|
+
p = _c.sent();
|
|
296
|
+
liveBadge.style.display = 'none';
|
|
297
|
+
if (points.length >= 3) {
|
|
298
|
+
sp_1 = context.view.worldToScreen(p);
|
|
299
|
+
snap = function (anchor) {
|
|
300
|
+
var sa = context.view.worldToScreen(anchor);
|
|
301
|
+
var dx = sp_1.x - sa.x;
|
|
302
|
+
var dy = sp_1.y - sa.y;
|
|
303
|
+
return dx * dx + dy * dy <= 14 * 14;
|
|
304
|
+
};
|
|
305
|
+
if (snap(points[0]) || snap(points[points.length - 1]))
|
|
306
|
+
return [2 /*return*/, "break"];
|
|
307
|
+
}
|
|
308
|
+
if (points.length >= 3) {
|
|
309
|
+
last = points[points.length - 1];
|
|
310
|
+
crosses = false;
|
|
311
|
+
for (i = 0; i < points.length - 2; i++) {
|
|
312
|
+
if (segmentsIntersect(last, p, points[i], points[i + 1])) {
|
|
313
|
+
crosses = true;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (crosses)
|
|
318
|
+
return [2 /*return*/, "break"];
|
|
319
|
+
}
|
|
320
|
+
points.push(p);
|
|
321
|
+
drawPolygon();
|
|
322
|
+
return [2 /*return*/];
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
_b.label = 3;
|
|
327
|
+
case 3:
|
|
328
|
+
if (!(points.length < 50)) return [3 /*break*/, 5];
|
|
329
|
+
return [5 /*yield**/, _loop_1()];
|
|
330
|
+
case 4:
|
|
331
|
+
state_1 = _b.sent();
|
|
332
|
+
if (state_1 === "break")
|
|
333
|
+
return [3 /*break*/, 5];
|
|
334
|
+
return [3 /*break*/, 3];
|
|
335
|
+
case 5: return [3 /*break*/, 7];
|
|
336
|
+
case 6:
|
|
337
|
+
_a = _b.sent();
|
|
338
|
+
return [3 /*break*/, 7];
|
|
339
|
+
case 7:
|
|
340
|
+
// Clean up construction-phase elements
|
|
341
|
+
liveBadge.remove();
|
|
342
|
+
context.view.events.viewChanged.removeEventListener(redrawOnViewChange);
|
|
343
|
+
fillCanvas.remove();
|
|
344
|
+
if (points.length < 3)
|
|
345
|
+
return [2 /*return*/];
|
|
346
|
+
area = shoelaceArea(points);
|
|
347
|
+
persistCanvas = document.createElement('canvas');
|
|
348
|
+
persistCanvas.style.cssText =
|
|
349
|
+
'position:fixed;pointer-events:none;z-index:99997;';
|
|
350
|
+
document.body.appendChild(persistCanvas);
|
|
351
|
+
drawAreaOnCanvas(persistCanvas, context.view, points, color);
|
|
352
|
+
redrawPersist = function () {
|
|
353
|
+
return drawAreaOnCanvas(persistCanvas, context.view, points, color);
|
|
354
|
+
};
|
|
355
|
+
context.view.events.viewChanged.addEventListener(redrawPersist);
|
|
356
|
+
htManager = AcApDocManager.instance.curView.htmlTransientManager;
|
|
357
|
+
id = "area-".concat(Date.now());
|
|
358
|
+
mid = centroid(points);
|
|
359
|
+
htManager.add("".concat(id, "-badge"), makeBadge(color, "~ ".concat(area.toFixed(3), " m\u00B2")), mid, 'measurement');
|
|
360
|
+
points.forEach(function (p, i) {
|
|
361
|
+
htManager.add("".concat(id, "-dot").concat(i), makeDot(color), p, 'measurement');
|
|
362
|
+
});
|
|
363
|
+
registerMeasurementCleanup(function () {
|
|
364
|
+
persistCanvas.remove();
|
|
365
|
+
context.view.events.viewChanged.removeEventListener(redrawPersist);
|
|
366
|
+
htManager.remove("".concat(id, "-badge"));
|
|
367
|
+
points.forEach(function (_, i) {
|
|
368
|
+
htManager.remove("".concat(id, "-dot").concat(i));
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
return [2 /*return*/];
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
return AcApMeasureAreaCmd;
|
|
377
|
+
}(AcEdCommand));
|
|
378
|
+
export { AcApMeasureAreaCmd };
|
|
379
|
+
//# sourceMappingURL=AcApMeasureAreaCmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApMeasureAreaCmd.js","sourceRoot":"","sources":["../../src/command/AcApMeasureAreaCmd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAEL,QAAQ,EAER,cAAc,EACf,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAe,cAAc,EAAE,MAAM,QAAQ,CAAA;AACpD,OAAO,EAEL,WAAW,EACX,YAAY,EACZ,cAAc,EACd,sBAAsB,EACvB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EACL,UAAU,EACV,eAAe,EACf,SAAS,EACT,OAAO,EACP,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AAEvE;;;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GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;wBAE5B,SAAS,CAAC,GAAG,CACX,UAAG,EAAE,WAAQ,EACb,SAAS,CAAC,KAAK,EAAE,YAAK,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,aAAK,CAAC,EAC3C,GAAG,EACH,aAAa,CACd,CAAA;wBACD,MAAM,CAAC,OAAO,CAAC,UAAC,CAAC,EAAE,CAAC;4BAClB,SAAS,CAAC,GAAG,CAAC,UAAG,EAAE,iBAAO,CAAC,CAAE,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,CAAA;wBAClE,CAAC,CAAC,CAAA;wBAEF,0BAA0B,CAAC;4BACzB,aAAa,CAAC,MAAM,EAAE,CAAA;4BACtB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAA;4BAClE,SAAS,CAAC,MAAM,CAAC,UAAG,EAAE,WAAQ,CAAC,CAAA;4BAC/B,MAAM,CAAC,OAAO,CAAC,UAAC,CAAC,EAAE,CAAC;gCAClB,SAAS,CAAC,MAAM,CAAC,UAAG,EAAE,iBAAO,CAAC,CAAE,CAAC,CAAA;4BACnC,CAAC,CAAC,CAAA;wBACJ,CAAC,CAAC,CAAA;;;;;KACH;IACH,yBAAC;AAAD,CAAC,AAlMD,CAAwC,WAAW,GAkMlD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AcCmColor, AcDbLine, AcGePoint3dLike } from '@mlightcad/data-model';
|
|
2
|
+
import { AcApContext } from '../app';
|
|
3
|
+
import { AcEdBaseView, AcEdCommand, AcEdPreviewJig } from '../editor';
|
|
4
|
+
/**
|
|
5
|
+
* Preview jig for the distance measurement command.
|
|
6
|
+
*
|
|
7
|
+
* Renders a live rubber-band line from the fixed first point to the current
|
|
8
|
+
* cursor position. The badge showing the live distance is rendered by the
|
|
9
|
+
* jig itself and is removed when the jig ends — it is intentionally short-lived
|
|
10
|
+
* and intrinsic to the interactive input UX.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AcApMeasureDistanceJig extends AcEdPreviewJig<AcGePoint3dLike> {
|
|
13
|
+
private _line;
|
|
14
|
+
private _p1;
|
|
15
|
+
private _view;
|
|
16
|
+
private _badge;
|
|
17
|
+
constructor(view: AcEdBaseView, p1: AcGePoint3dLike, color: AcCmColor);
|
|
18
|
+
get entity(): AcDbLine;
|
|
19
|
+
update(p2: AcGePoint3dLike): void;
|
|
20
|
+
end(): void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Command that measures the straight-line distance between two points.
|
|
24
|
+
*
|
|
25
|
+
* Prompts the user to pick two world points, then registers a transient CAD
|
|
26
|
+
* line between them. Persistent DOM overlays (dots + badge) are placed via
|
|
27
|
+
* {@link AcTrHtmlTransientManager} using CSS2DObject, so they track zoom/pan
|
|
28
|
+
* automatically without manual viewChanged listeners.
|
|
29
|
+
*/
|
|
30
|
+
export declare class AcApMeasureDistanceCmd extends AcEdCommand {
|
|
31
|
+
constructor();
|
|
32
|
+
execute(context: AcApContext): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=AcApMeasureDistanceCmd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApMeasureDistanceCmd.d.ts","sourceRoot":"","sources":["../../src/command/AcApMeasureDistanceCmd.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,eAAe,EAEhB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,WAAW,EAAkB,MAAM,QAAQ,CAAA;AACpD,OAAO,EACL,YAAY,EACZ,WAAW,EAEX,cAAc,EAEf,MAAM,WAAW,CAAA;AAYlB;;;;;;;GAOG;AACH,qBAAa,sBAAuB,SAAQ,cAAc,CAAC,eAAe,CAAC;IACzE,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,MAAM,CAAgB;gBAElB,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,SAAS;IAmBrE,IAAI,MAAM,IAAI,QAAQ,CAErB;IAED,MAAM,CAAC,EAAE,EAAE,eAAe;IAmB1B,GAAG;CAIJ;AAED;;;;;;;GAOG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;;IAM/C,OAAO,CAAC,OAAO,EAAE,WAAW;CA6CnC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
27
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
import { AcDbLine, AcGiLineWeight } from '@mlightcad/data-model';
|
|
53
|
+
import { AcApDocManager } from '../app';
|
|
54
|
+
import { AcEdCommand, AcEdOpenMode, AcEdPreviewJig, AcEdPromptPointOptions } from '../editor';
|
|
55
|
+
import { AcApI18n } from '../i18n';
|
|
56
|
+
import { colorToCss, makeBadge, makeDot, measurementColor } from '../util';
|
|
57
|
+
import { registerMeasurementCleanup } from './AcApClearMeasurementsCmd';
|
|
58
|
+
/** Returns the 2D Euclidean distance between two world points. */
|
|
59
|
+
function calcDist(p1, p2) {
|
|
60
|
+
var dx = p2.x - p1.x;
|
|
61
|
+
var dy = p2.y - p1.y;
|
|
62
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Preview jig for the distance measurement command.
|
|
66
|
+
*
|
|
67
|
+
* Renders a live rubber-band line from the fixed first point to the current
|
|
68
|
+
* cursor position. The badge showing the live distance is rendered by the
|
|
69
|
+
* jig itself and is removed when the jig ends — it is intentionally short-lived
|
|
70
|
+
* and intrinsic to the interactive input UX.
|
|
71
|
+
*/
|
|
72
|
+
var AcApMeasureDistanceJig = /** @class */ (function (_super) {
|
|
73
|
+
__extends(AcApMeasureDistanceJig, _super);
|
|
74
|
+
function AcApMeasureDistanceJig(view, p1, color) {
|
|
75
|
+
var _this = _super.call(this, view) || this;
|
|
76
|
+
_this._p1 = p1;
|
|
77
|
+
_this._view = view;
|
|
78
|
+
_this._line = new AcDbLine(p1, p1);
|
|
79
|
+
_this._line.color = color;
|
|
80
|
+
_this._line.lineWeight = AcGiLineWeight.LineWeight070;
|
|
81
|
+
// Live badge — short-lived, cleaned up in end()
|
|
82
|
+
_this._badge = document.createElement('div');
|
|
83
|
+
_this._badge.style.cssText =
|
|
84
|
+
"position:fixed;background:rgba(255,255,255,0.95);color:".concat(colorToCss(color), ";") +
|
|
85
|
+
'font-size:13px;font-family:sans-serif;font-weight:500;' +
|
|
86
|
+
'padding:3px 14px;border-radius:20px;pointer-events:none;' +
|
|
87
|
+
'transform:translate(-50%,-50%);white-space:nowrap;' +
|
|
88
|
+
'box-shadow:0 1px 4px rgba(0,0,0,0.2);z-index:99999;display:none;';
|
|
89
|
+
document.body.appendChild(_this._badge);
|
|
90
|
+
return _this;
|
|
91
|
+
}
|
|
92
|
+
Object.defineProperty(AcApMeasureDistanceJig.prototype, "entity", {
|
|
93
|
+
get: function () {
|
|
94
|
+
return this._line;
|
|
95
|
+
},
|
|
96
|
+
enumerable: false,
|
|
97
|
+
configurable: true
|
|
98
|
+
});
|
|
99
|
+
AcApMeasureDistanceJig.prototype.update = function (p2) {
|
|
100
|
+
this._line.endPoint = p2;
|
|
101
|
+
var dist = calcDist(this._p1, p2);
|
|
102
|
+
if (dist < 0.0001) {
|
|
103
|
+
this._badge.style.display = 'none';
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this._badge.textContent = "~ ".concat(dist.toFixed(3), " m");
|
|
107
|
+
this._badge.style.display = 'block';
|
|
108
|
+
var mid = { x: (this._p1.x + p2.x) / 2, y: (this._p1.y + p2.y) / 2 };
|
|
109
|
+
var rect = this._view.canvas.getBoundingClientRect();
|
|
110
|
+
var s = this._view.worldToScreen(mid);
|
|
111
|
+
this._badge.style.left = "".concat(s.x + rect.left, "px");
|
|
112
|
+
this._badge.style.top = "".concat(s.y + rect.top, "px");
|
|
113
|
+
};
|
|
114
|
+
AcApMeasureDistanceJig.prototype.end = function () {
|
|
115
|
+
_super.prototype.end.call(this);
|
|
116
|
+
this._badge.remove();
|
|
117
|
+
};
|
|
118
|
+
return AcApMeasureDistanceJig;
|
|
119
|
+
}(AcEdPreviewJig));
|
|
120
|
+
export { AcApMeasureDistanceJig };
|
|
121
|
+
/**
|
|
122
|
+
* Command that measures the straight-line distance between two points.
|
|
123
|
+
*
|
|
124
|
+
* Prompts the user to pick two world points, then registers a transient CAD
|
|
125
|
+
* line between them. Persistent DOM overlays (dots + badge) are placed via
|
|
126
|
+
* {@link AcTrHtmlTransientManager} using CSS2DObject, so they track zoom/pan
|
|
127
|
+
* automatically without manual viewChanged listeners.
|
|
128
|
+
*/
|
|
129
|
+
var AcApMeasureDistanceCmd = /** @class */ (function (_super) {
|
|
130
|
+
__extends(AcApMeasureDistanceCmd, _super);
|
|
131
|
+
function AcApMeasureDistanceCmd() {
|
|
132
|
+
var _this = _super.call(this) || this;
|
|
133
|
+
_this.mode = AcEdOpenMode.Read;
|
|
134
|
+
return _this;
|
|
135
|
+
}
|
|
136
|
+
AcApMeasureDistanceCmd.prototype.execute = function (context) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
138
|
+
var editor, color, p1Prompt, p1, p2Prompt, p2, dist, line, htManager, id, mid;
|
|
139
|
+
return __generator(this, function (_a) {
|
|
140
|
+
switch (_a.label) {
|
|
141
|
+
case 0:
|
|
142
|
+
editor = AcApDocManager.instance.editor;
|
|
143
|
+
color = measurementColor(context.doc.database);
|
|
144
|
+
p1Prompt = new AcEdPromptPointOptions(AcApI18n.t('jig.measureDistance.firstPoint'));
|
|
145
|
+
return [4 /*yield*/, editor.getPoint(p1Prompt)];
|
|
146
|
+
case 1:
|
|
147
|
+
p1 = _a.sent();
|
|
148
|
+
p2Prompt = new AcEdPromptPointOptions(AcApI18n.t('jig.measureDistance.secondPoint'));
|
|
149
|
+
p2Prompt.useBasePoint = true;
|
|
150
|
+
p2Prompt.jig = new AcApMeasureDistanceJig(context.view, p1, color);
|
|
151
|
+
return [4 /*yield*/, editor.getPoint(p2Prompt)];
|
|
152
|
+
case 2:
|
|
153
|
+
p2 = _a.sent();
|
|
154
|
+
dist = calcDist(p1, p2);
|
|
155
|
+
line = new AcDbLine(p1, p2);
|
|
156
|
+
line.color = color;
|
|
157
|
+
line.lineWeight = AcGiLineWeight.LineWeight070;
|
|
158
|
+
context.view.addTransientEntity(line);
|
|
159
|
+
htManager = AcApDocManager.instance.curView.htmlTransientManager;
|
|
160
|
+
id = "dist-".concat(Date.now());
|
|
161
|
+
mid = { x: (p1.x + p2.x) / 2, y: (p1.y + p2.y) / 2 };
|
|
162
|
+
htManager.add("".concat(id, "-dot1"), makeDot(color), p1, 'measurement');
|
|
163
|
+
htManager.add("".concat(id, "-dot2"), makeDot(color), p2, 'measurement');
|
|
164
|
+
htManager.add("".concat(id, "-badge"), makeBadge(color, "~ ".concat(dist.toFixed(3), " m")), mid, 'measurement');
|
|
165
|
+
registerMeasurementCleanup(function () {
|
|
166
|
+
context.view.removeTransientEntity(line.objectId);
|
|
167
|
+
htManager.remove("".concat(id, "-dot1"));
|
|
168
|
+
htManager.remove("".concat(id, "-dot2"));
|
|
169
|
+
htManager.remove("".concat(id, "-badge"));
|
|
170
|
+
});
|
|
171
|
+
return [2 /*return*/];
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
return AcApMeasureDistanceCmd;
|
|
177
|
+
}(AcEdCommand));
|
|
178
|
+
export { AcApMeasureDistanceCmd };
|
|
179
|
+
//# sourceMappingURL=AcApMeasureDistanceCmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApMeasureDistanceCmd.js","sourceRoot":"","sources":["../../src/command/AcApMeasureDistanceCmd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAEL,QAAQ,EAER,cAAc,EACf,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAe,cAAc,EAAE,MAAM,QAAQ,CAAA;AACpD,OAAO,EAEL,WAAW,EACX,YAAY,EACZ,cAAc,EACd,sBAAsB,EACvB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,SAAS,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wBAChE,EAAE,GAAG,eAAQ,IAAI,CAAC,GAAG,EAAE,CAAE,CAAA;wBACzB,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAA;wBAE1D,SAAS,CAAC,GAAG,CAAC,UAAG,EAAE,UAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,aAAa,CAAC,CAAA;wBAC9D,SAAS,CAAC,GAAG,CAAC,UAAG,EAAE,UAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,aAAa,CAAC,CAAA;wBAC9D,SAAS,CAAC,GAAG,CACX,UAAG,EAAE,WAAQ,EACb,SAAS,CAAC,KAAK,EAAE,YAAK,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAI,CAAC,EAC1C,GAAG,EACH,aAAa,CACd,CAAA;wBAED,0BAA0B,CAAC;4BACzB,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;4BACjD,SAAS,CAAC,MAAM,CAAC,UAAG,EAAE,UAAO,CAAC,CAAA;4BAC9B,SAAS,CAAC,MAAM,CAAC,UAAG,EAAE,UAAO,CAAC,CAAA;4BAC9B,SAAS,CAAC,MAAM,CAAC,UAAG,EAAE,WAAQ,CAAC,CAAA;wBACjC,CAAC,CAAC,CAAA;;;;;KACH;IACH,6BAAC;AAAD,CAAC,AAnDD,CAA4C,WAAW,GAmDtD"}
|
|
@@ -49,7 +49,7 @@ 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 { AcDbSysVarManager } from '@mlightcad/data-model';
|
|
52
|
+
import { AcDbSystemVariables, AcDbSysVarManager } from '@mlightcad/data-model';
|
|
53
53
|
import { AcEdCommand } from '../editor';
|
|
54
54
|
/**
|
|
55
55
|
* Command for switching the drawing background between white and black.
|
|
@@ -68,7 +68,7 @@ var AcApSwitchBgCmd = /** @class */ (function (_super) {
|
|
|
68
68
|
return __awaiter(this, void 0, void 0, function () {
|
|
69
69
|
var variableName, sysVarManager, sysVar, db, useWhiteBackgroundColor;
|
|
70
70
|
return __generator(this, function (_a) {
|
|
71
|
-
variableName =
|
|
71
|
+
variableName = AcDbSystemVariables.WHITEBKCOLOR;
|
|
72
72
|
sysVarManager = AcDbSysVarManager.instance();
|
|
73
73
|
sysVar = sysVarManager.getDescriptor(variableName);
|
|
74
74
|
if (sysVar) {
|