@mlightcad/cad-pdf-plugin 1.8.0-preview.3 → 1.8.0-preview.4
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/LICENSE +21 -21
- package/README.md +280 -186
- package/dist/cad-pdf-plugin-register.js +29 -11
- package/dist/cad-pdf-plugin-register.umd.cjs +1 -1
- package/dist/cad-pdf-plugin.js +17568 -8428
- package/dist/cad-pdf-plugin.umd.cjs +847 -13
- package/lib/AcApConvertToPdfCmd.d.ts.map +1 -1
- package/lib/AcApConvertToPdfCmd.js +14 -3
- package/lib/AcApConvertToPdfCmd.js.map +1 -1
- package/lib/AcApImportPdfCmd.d.ts +5 -3
- package/lib/AcApImportPdfCmd.d.ts.map +1 -1
- package/lib/AcApImportPdfCmd.js +5 -3
- package/lib/AcApImportPdfCmd.js.map +1 -1
- package/lib/AcApImportPdfPromptCmd.d.ts +16 -0
- package/lib/AcApImportPdfPromptCmd.d.ts.map +1 -0
- package/lib/AcApImportPdfPromptCmd.js +89 -0
- package/lib/AcApImportPdfPromptCmd.js.map +1 -0
- package/lib/AcApPdfBlockCmd.d.ts +15 -0
- package/lib/AcApPdfBlockCmd.d.ts.map +1 -0
- package/lib/AcApPdfBlockCmd.js +75 -0
- package/lib/AcApPdfBlockCmd.js.map +1 -0
- package/lib/AcApPdfDimCmd.d.ts +20 -0
- package/lib/AcApPdfDimCmd.d.ts.map +1 -0
- package/lib/AcApPdfDimCmd.js +413 -0
- package/lib/AcApPdfDimCmd.js.map +1 -0
- package/lib/AcApPdfDimSession.d.ts +82 -0
- package/lib/AcApPdfDimSession.d.ts.map +1 -0
- package/lib/AcApPdfDimSession.js +252 -0
- package/lib/AcApPdfDimSession.js.map +1 -0
- package/lib/AcApPdfFontResolver.d.ts.map +1 -1
- package/lib/AcApPdfFontResolver.js +2 -5
- package/lib/AcApPdfFontResolver.js.map +1 -1
- package/lib/AcApPdfHatchCmd.d.ts +33 -0
- package/lib/AcApPdfHatchCmd.d.ts.map +1 -0
- package/lib/AcApPdfHatchCmd.js +411 -0
- package/lib/AcApPdfHatchCmd.js.map +1 -0
- package/lib/AcApPdfHatchSession.d.ts +122 -0
- package/lib/AcApPdfHatchSession.d.ts.map +1 -0
- package/lib/AcApPdfHatchSession.js +357 -0
- package/lib/AcApPdfHatchSession.js.map +1 -0
- package/lib/AcApPdfImportConvertor.d.ts +47 -5
- package/lib/AcApPdfImportConvertor.d.ts.map +1 -1
- package/lib/AcApPdfImportConvertor.js +999 -108
- package/lib/AcApPdfImportConvertor.js.map +1 -1
- package/lib/AcApPdfImportOptions.d.ts +116 -0
- package/lib/AcApPdfImportOptions.d.ts.map +1 -0
- package/lib/AcApPdfImportOptions.js +31 -0
- package/lib/AcApPdfImportOptions.js.map +1 -0
- package/lib/AcApPdfImportResources.d.ts +41 -0
- package/lib/AcApPdfImportResources.d.ts.map +1 -0
- package/lib/AcApPdfImportResources.js +52 -0
- package/lib/AcApPdfImportResources.js.map +1 -0
- package/lib/AcApPdfPlugin.d.ts +3 -3
- package/lib/AcApPdfPlugin.d.ts.map +1 -1
- package/lib/AcApPdfPlugin.js +23 -5
- package/lib/AcApPdfPlugin.js.map +1 -1
- package/lib/AcApPdfScaleCmd.d.ts +22 -0
- package/lib/AcApPdfScaleCmd.d.ts.map +1 -0
- package/lib/AcApPdfScaleCmd.js +185 -0
- package/lib/AcApPdfScaleCmd.js.map +1 -0
- package/lib/AcApPdfTextCmd.d.ts +73 -0
- package/lib/AcApPdfTextCmd.d.ts.map +1 -0
- package/lib/AcApPdfTextCmd.js +777 -0
- package/lib/AcApPdfTextCmd.js.map +1 -0
- package/lib/AcApPdfTextSession.d.ts +232 -0
- package/lib/AcApPdfTextSession.d.ts.map +1 -0
- package/lib/AcApPdfTextSession.js +826 -0
- package/lib/AcApPdfTextSession.js.map +1 -0
- package/lib/acapPdfI18n.d.ts +11 -0
- package/lib/acapPdfI18n.d.ts.map +1 -0
- package/lib/acapPdfI18n.js +57 -0
- package/lib/acapPdfI18n.js.map +1 -0
- package/lib/acapPdfPrompts.d.ts +12 -0
- package/lib/acapPdfPrompts.d.ts.map +1 -0
- package/lib/acapPdfPrompts.js +100 -0
- package/lib/acapPdfPrompts.js.map +1 -0
- package/lib/index.d.ts +28 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +28 -0
- package/lib/index.js.map +1 -1
- package/lib/pdfDeprecatedMatching.d.ts +27 -0
- package/lib/pdfDeprecatedMatching.d.ts.map +1 -0
- package/lib/pdfDeprecatedMatching.js +20 -0
- package/lib/pdfDeprecatedMatching.js.map +1 -0
- package/lib/pdfDimStrokeTexts.d.ts +55 -0
- package/lib/pdfDimStrokeTexts.d.ts.map +1 -0
- package/lib/pdfDimStrokeTexts.js +274 -0
- package/lib/pdfDimStrokeTexts.js.map +1 -0
- package/lib/pdfDimensionConvert.d.ts +80 -0
- package/lib/pdfDimensionConvert.d.ts.map +1 -0
- package/lib/pdfDimensionConvert.js +566 -0
- package/lib/pdfDimensionConvert.js.map +1 -0
- package/lib/pdfEntityStrokes.d.ts +13 -0
- package/lib/pdfEntityStrokes.d.ts.map +1 -0
- package/lib/pdfEntityStrokes.js +86 -0
- package/lib/pdfEntityStrokes.js.map +1 -0
- package/lib/pdfHatchRecover.d.ts +57 -0
- package/lib/pdfHatchRecover.d.ts.map +1 -0
- package/lib/pdfHatchRecover.js +315 -0
- package/lib/pdfHatchRecover.js.map +1 -0
- package/lib/pdfImportAppend.d.ts +24 -0
- package/lib/pdfImportAppend.d.ts.map +1 -0
- package/lib/pdfImportAppend.js +35 -0
- package/lib/pdfImportAppend.js.map +1 -0
- package/lib/pdfImportEntities.d.ts +63 -0
- package/lib/pdfImportEntities.d.ts.map +1 -0
- package/lib/pdfImportEntities.js +307 -0
- package/lib/pdfImportEntities.js.map +1 -0
- package/lib/pdfImportImages.d.ts +90 -0
- package/lib/pdfImportImages.d.ts.map +1 -0
- package/lib/pdfImportImages.js +294 -0
- package/lib/pdfImportImages.js.map +1 -0
- package/lib/pdfImportShapes.d.ts +63 -0
- package/lib/pdfImportShapes.d.ts.map +1 -0
- package/lib/pdfImportShapes.js +248 -0
- package/lib/pdfImportShapes.js.map +1 -0
- package/lib/pdfVectorImport.d.ts +218 -5
- package/lib/pdfVectorImport.d.ts.map +1 -1
- package/lib/pdfVectorImport.js +566 -98
- package/lib/pdfVectorImport.js.map +1 -1
- package/lib/recognition/pdfCurveRecognition.d.ts +91 -0
- package/lib/recognition/pdfCurveRecognition.d.ts.map +1 -0
- package/lib/recognition/pdfCurveRecognition.js +506 -0
- package/lib/recognition/pdfCurveRecognition.js.map +1 -0
- package/lib/recognition/pdfDimDigitRecognition.d.ts +18 -0
- package/lib/recognition/pdfDimDigitRecognition.d.ts.map +1 -0
- package/lib/recognition/pdfDimDigitRecognition.js +520 -0
- package/lib/recognition/pdfDimDigitRecognition.js.map +1 -0
- package/lib/recognition/pdfDimensionPattern.d.ts +173 -0
- package/lib/recognition/pdfDimensionPattern.d.ts.map +1 -0
- package/lib/recognition/pdfDimensionPattern.js +1023 -0
- package/lib/recognition/pdfDimensionPattern.js.map +1 -0
- package/lib/recognition/pdfFormBlocks.d.ts +58 -0
- package/lib/recognition/pdfFormBlocks.d.ts.map +1 -0
- package/lib/recognition/pdfFormBlocks.js +260 -0
- package/lib/recognition/pdfFormBlocks.js.map +1 -0
- package/lib/recognition/pdfGlyphClustering.d.ts +81 -0
- package/lib/recognition/pdfGlyphClustering.d.ts.map +1 -0
- package/lib/recognition/pdfGlyphClustering.js +1005 -0
- package/lib/recognition/pdfGlyphClustering.js.map +1 -0
- package/lib/recognition/pdfGlyphDictionary.d.ts +49 -0
- package/lib/recognition/pdfGlyphDictionary.d.ts.map +1 -0
- package/lib/recognition/pdfGlyphDictionary.js +188 -0
- package/lib/recognition/pdfGlyphDictionary.js.map +1 -0
- package/lib/recognition/pdfHatchFaces.d.ts +84 -0
- package/lib/recognition/pdfHatchFaces.d.ts.map +1 -0
- package/lib/recognition/pdfHatchFaces.js +1285 -0
- package/lib/recognition/pdfHatchFaces.js.map +1 -0
- package/lib/recognition/pdfHatchRecognition.d.ts +222 -0
- package/lib/recognition/pdfHatchRecognition.d.ts.map +1 -0
- package/lib/recognition/pdfHatchRecognition.js +3781 -0
- package/lib/recognition/pdfHatchRecognition.js.map +1 -0
- package/lib/recognition/pdfRecGeometry.d.ts +67 -0
- package/lib/recognition/pdfRecGeometry.d.ts.map +1 -0
- package/lib/recognition/pdfRecGeometry.js +365 -0
- package/lib/recognition/pdfRecGeometry.js.map +1 -0
- package/lib/recognition/pdfTextFontKind.d.ts +16 -0
- package/lib/recognition/pdfTextFontKind.d.ts.map +1 -0
- package/lib/recognition/pdfTextFontKind.js +51 -0
- package/lib/recognition/pdfTextFontKind.js.map +1 -0
- package/lib/recognition/pdfTextMerge.d.ts +71 -0
- package/lib/recognition/pdfTextMerge.d.ts.map +1 -0
- package/lib/recognition/pdfTextMerge.js +382 -0
- package/lib/recognition/pdfTextMerge.js.map +1 -0
- package/lib/recognition/pdfTextRunMerge.d.ts +28 -0
- package/lib/recognition/pdfTextRunMerge.d.ts.map +1 -0
- package/lib/recognition/pdfTextRunMerge.js +90 -0
- package/lib/recognition/pdfTextRunMerge.js.map +1 -0
- package/lib/register.d.ts +8 -2
- package/lib/register.d.ts.map +1 -1
- package/lib/register.js +29 -4
- package/lib/register.js.map +1 -1
- package/lib/ui/AcUiPdfDimPanel.d.ts +55 -0
- package/lib/ui/AcUiPdfDimPanel.d.ts.map +1 -0
- package/lib/ui/AcUiPdfDimPanel.js +347 -0
- package/lib/ui/AcUiPdfDimPanel.js.map +1 -0
- package/lib/ui/AcUiPdfHatchPanel.d.ts +57 -0
- package/lib/ui/AcUiPdfHatchPanel.d.ts.map +1 -0
- package/lib/ui/AcUiPdfHatchPanel.js +420 -0
- package/lib/ui/AcUiPdfHatchPanel.js.map +1 -0
- package/lib/ui/AcUiPdfImportDialog.d.ts +120 -0
- package/lib/ui/AcUiPdfImportDialog.d.ts.map +1 -0
- package/lib/ui/AcUiPdfImportDialog.js +673 -0
- package/lib/ui/AcUiPdfImportDialog.js.map +1 -0
- package/lib/ui/AcUiPdfTextPanel.d.ts +95 -0
- package/lib/ui/AcUiPdfTextPanel.d.ts.map +1 -0
- package/lib/ui/AcUiPdfTextPanel.js +775 -0
- package/lib/ui/AcUiPdfTextPanel.js.map +1 -0
- package/package.json +11 -11
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __values = (this && this.__values) || function(o) {
|
|
13
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
14
|
+
if (m) return m.call(o);
|
|
15
|
+
if (o && typeof o.length === "number") return {
|
|
16
|
+
next: function () {
|
|
17
|
+
if (o && i >= o.length) o = void 0;
|
|
18
|
+
return { value: o && o[i++], done: !o };
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
22
|
+
};
|
|
23
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
24
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
25
|
+
if (!m) return o;
|
|
26
|
+
var i = m.call(o), r, ar = [], e;
|
|
27
|
+
try {
|
|
28
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
29
|
+
}
|
|
30
|
+
catch (error) { e = { error: error }; }
|
|
31
|
+
finally {
|
|
32
|
+
try {
|
|
33
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
34
|
+
}
|
|
35
|
+
finally { if (e) throw e.error; }
|
|
36
|
+
}
|
|
37
|
+
return ar;
|
|
38
|
+
};
|
|
39
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
40
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
41
|
+
if (ar || !(i in from)) {
|
|
42
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
43
|
+
ar[i] = from[i];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
47
|
+
};
|
|
48
|
+
import { AcDbPredefinedAcadIsoPat } from '@mlightcad/data-model';
|
|
49
|
+
import { acapPdfBoundaryAt, acapPdfFitHatch, acapPdfMatchHatch } from './recognition/pdfHatchRecognition';
|
|
50
|
+
/** Lowest precision of a hatch shown as a good match. */
|
|
51
|
+
export var PDF_HATCH_GOOD_PRECISION = 0.95;
|
|
52
|
+
/** Lowest recall of a hatch shown as a good match. */
|
|
53
|
+
export var PDF_HATCH_GOOD_RECALL = 0.9;
|
|
54
|
+
/** Key of single user-defined lines. */
|
|
55
|
+
export var PDF_HATCH_USER_KEY = 'user';
|
|
56
|
+
/** Key of crossed user-defined lines. */
|
|
57
|
+
export var PDF_HATCH_USER_DOUBLE_KEY = 'user2';
|
|
58
|
+
/** Key of the measured custom pattern. */
|
|
59
|
+
export var PDF_HATCH_CUSTOM_KEY = 'custom';
|
|
60
|
+
var DEG = Math.PI / 180;
|
|
61
|
+
/**
|
|
62
|
+
* State of a `pdfhatch` review: the recovered hatches, which of them to
|
|
63
|
+
* create, and their patterns. UI-free, so the panel stays a thin view.
|
|
64
|
+
*
|
|
65
|
+
* Every change of pattern or size refits the hatch to the strokes and
|
|
66
|
+
* scores it again; a hatch only replaces the entities it re-draws
|
|
67
|
+
* completely, so a poor choice leaves strokes in place instead of losing
|
|
68
|
+
* them.
|
|
69
|
+
*/
|
|
70
|
+
var AcApPdfHatchSession = /** @class */ (function () {
|
|
71
|
+
function AcApPdfHatchSession(options) {
|
|
72
|
+
var e_1, _a, e_2, _b;
|
|
73
|
+
var _c;
|
|
74
|
+
this.rows = [];
|
|
75
|
+
/** Items per entity, to tell whether a hatch re-draws all of one. */
|
|
76
|
+
this.itemCount = new Map();
|
|
77
|
+
this.nextKey = 0;
|
|
78
|
+
this.input = options.input;
|
|
79
|
+
this.tolerance = options.tolerance;
|
|
80
|
+
try {
|
|
81
|
+
for (var _d = __values(this.input.owners), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
82
|
+
var owner = _e.value;
|
|
83
|
+
this.itemCount.set(owner, ((_c = this.itemCount.get(owner)) !== null && _c !== void 0 ? _c : 0) + 1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
87
|
+
finally {
|
|
88
|
+
try {
|
|
89
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
90
|
+
}
|
|
91
|
+
finally { if (e_1) throw e_1.error; }
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
for (var _f = __values(options.hatches), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
95
|
+
var hatch = _g.value;
|
|
96
|
+
var consumed = this.consumedBy(hatch.items);
|
|
97
|
+
if (consumed.length === 0)
|
|
98
|
+
continue;
|
|
99
|
+
// The recognition proved its items; the score is for display.
|
|
100
|
+
var match = __assign(__assign({}, acapPdfMatchHatch(this.input.items, hatch, this.tolerance)), { items: hatch.items });
|
|
101
|
+
this.rows.push({
|
|
102
|
+
key: this.nextKey++,
|
|
103
|
+
hatch: hatch,
|
|
104
|
+
match: match,
|
|
105
|
+
included: true,
|
|
106
|
+
consumed: consumed,
|
|
107
|
+
guessed: false,
|
|
108
|
+
original: hatch,
|
|
109
|
+
added: false
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
114
|
+
finally {
|
|
115
|
+
try {
|
|
116
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
117
|
+
}
|
|
118
|
+
finally { if (e_2) throw e_2.error; }
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
Object.defineProperty(AcApPdfHatchSession.prototype, "readyRows", {
|
|
122
|
+
/** Rows created on Apply. */
|
|
123
|
+
get: function () {
|
|
124
|
+
return this.rows.filter(function (row) { return row.included && row.consumed.length > 0; });
|
|
125
|
+
},
|
|
126
|
+
enumerable: false,
|
|
127
|
+
configurable: true
|
|
128
|
+
});
|
|
129
|
+
Object.defineProperty(AcApPdfHatchSession.prototype, "erasedIds", {
|
|
130
|
+
/** Entities erased on Apply, each once. */
|
|
131
|
+
get: function () {
|
|
132
|
+
return __spreadArray([], __read(new Set(this.readyRows.flatMap(function (row) { return row.consumed; }))), false);
|
|
133
|
+
},
|
|
134
|
+
enumerable: false,
|
|
135
|
+
configurable: true
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(AcApPdfHatchSession.prototype, "strokeIds", {
|
|
138
|
+
/** Every entity some row may replace (hidden while previewing). */
|
|
139
|
+
get: function () {
|
|
140
|
+
return __spreadArray([], __read(new Set(this.rows.flatMap(function (row) { return row.consumed; }))), false);
|
|
141
|
+
},
|
|
142
|
+
enumerable: false,
|
|
143
|
+
configurable: true
|
|
144
|
+
});
|
|
145
|
+
/** Whether a row re-draws its strokes well enough to trust it. */
|
|
146
|
+
AcApPdfHatchSession.prototype.isGood = function (row) {
|
|
147
|
+
return (!row.guessed &&
|
|
148
|
+
row.match.precision >= PDF_HATCH_GOOD_PRECISION &&
|
|
149
|
+
row.match.recall >= PDF_HATCH_GOOD_RECALL);
|
|
150
|
+
};
|
|
151
|
+
/** Entity whose layer and colour the hatch of `row` takes. */
|
|
152
|
+
AcApPdfHatchSession.prototype.sourceOf = function (row) {
|
|
153
|
+
var first = row.hatch.items[0];
|
|
154
|
+
return first === undefined ? undefined : this.input.owners[first];
|
|
155
|
+
};
|
|
156
|
+
AcApPdfHatchSession.prototype.setIncluded = function (row, included) {
|
|
157
|
+
row.included = included;
|
|
158
|
+
};
|
|
159
|
+
/** Pattern choices for `row`, in display order. */
|
|
160
|
+
AcApPdfHatchSession.prototype.patternKeys = function (row) {
|
|
161
|
+
var e_3, _a;
|
|
162
|
+
var keys = [];
|
|
163
|
+
if (row.original.pattern.type === 'custom')
|
|
164
|
+
keys.push(PDF_HATCH_CUSTOM_KEY);
|
|
165
|
+
keys.push(PDF_HATCH_USER_KEY, PDF_HATCH_USER_DOUBLE_KEY);
|
|
166
|
+
try {
|
|
167
|
+
for (var _b = __values(AcDbPredefinedAcadIsoPat.patterns), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
168
|
+
var pattern = _c.value;
|
|
169
|
+
keys.push("predefined:".concat(pattern.name));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
173
|
+
finally {
|
|
174
|
+
try {
|
|
175
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
176
|
+
}
|
|
177
|
+
finally { if (e_3) throw e_3.error; }
|
|
178
|
+
}
|
|
179
|
+
return keys;
|
|
180
|
+
};
|
|
181
|
+
/** Current pattern choice of `row`. */
|
|
182
|
+
AcApPdfHatchSession.prototype.patternKey = function (row) {
|
|
183
|
+
var pattern = row.hatch.pattern;
|
|
184
|
+
if (pattern.type === 'predefined')
|
|
185
|
+
return "predefined:".concat(pattern.name);
|
|
186
|
+
if (pattern.type === 'userDefined') {
|
|
187
|
+
return pattern.double ? PDF_HATCH_USER_DOUBLE_KEY : PDF_HATCH_USER_KEY;
|
|
188
|
+
}
|
|
189
|
+
return PDF_HATCH_CUSTOM_KEY;
|
|
190
|
+
};
|
|
191
|
+
/** Size and angle, or `undefined` for a measured custom pattern. */
|
|
192
|
+
AcApPdfHatchSession.prototype.params = function (row) {
|
|
193
|
+
var pattern = row.hatch.pattern;
|
|
194
|
+
if (pattern.type === 'custom')
|
|
195
|
+
return undefined;
|
|
196
|
+
return {
|
|
197
|
+
size: pattern.type === 'predefined' ? pattern.scale : pattern.spacing,
|
|
198
|
+
angle: normalizeDegrees(pattern.angle / DEG)
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Switches `row` to another pattern and measures its size and angle on
|
|
203
|
+
* the strokes.
|
|
204
|
+
*
|
|
205
|
+
* @returns Whether the row changed.
|
|
206
|
+
*/
|
|
207
|
+
AcApPdfHatchSession.prototype.setPattern = function (row, key) {
|
|
208
|
+
if (key === PDF_HATCH_CUSTOM_KEY) {
|
|
209
|
+
if (row.original.pattern.type !== 'custom')
|
|
210
|
+
return false;
|
|
211
|
+
this.restore(row);
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
var request = requestOf(key);
|
|
215
|
+
return request ? this.refit(row, request) : false;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Places the row's pattern at the given size and angle (only the origin
|
|
219
|
+
* is searched).
|
|
220
|
+
*
|
|
221
|
+
* @returns Whether the row changed.
|
|
222
|
+
*/
|
|
223
|
+
AcApPdfHatchSession.prototype.setParams = function (row, params) {
|
|
224
|
+
if (!(params.size > 0) || !Number.isFinite(params.angle))
|
|
225
|
+
return false;
|
|
226
|
+
var pattern = row.hatch.pattern;
|
|
227
|
+
var angle = params.angle * DEG;
|
|
228
|
+
if (pattern.type === 'predefined') {
|
|
229
|
+
return this.refit(row, {
|
|
230
|
+
type: 'predefined',
|
|
231
|
+
name: pattern.name,
|
|
232
|
+
scale: params.size,
|
|
233
|
+
angle: angle
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
if (pattern.type === 'userDefined') {
|
|
237
|
+
return this.refit(row, {
|
|
238
|
+
type: 'userDefined',
|
|
239
|
+
double: pattern.double,
|
|
240
|
+
spacing: params.size,
|
|
241
|
+
angle: angle
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Measures size and angle of the row's pattern again (after manual
|
|
248
|
+
* edits); a custom pattern returns to what the recognition measured.
|
|
249
|
+
*/
|
|
250
|
+
AcApPdfHatchSession.prototype.autoFit = function (row) {
|
|
251
|
+
var key = this.patternKey(row);
|
|
252
|
+
return this.setPattern(row, key);
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Adds a hatch for the closed area around `point`: the best fitting
|
|
256
|
+
* pattern for the strokes inside it.
|
|
257
|
+
*
|
|
258
|
+
* @returns The new row, `'noBoundary'` when no closed area holds the
|
|
259
|
+
* point, or `'noStrokes'` when no pattern explains strokes inside it.
|
|
260
|
+
*/
|
|
261
|
+
AcApPdfHatchSession.prototype.addRegion = function (point) {
|
|
262
|
+
var boundary = acapPdfBoundaryAt(this.input.items, point, this.tolerance);
|
|
263
|
+
if (!boundary)
|
|
264
|
+
return 'noBoundary';
|
|
265
|
+
var fit = acapPdfFitHatch(this.input.items, boundary, undefined, {
|
|
266
|
+
tolerance: this.tolerance
|
|
267
|
+
});
|
|
268
|
+
if (!fit || fit.match.items.length === 0)
|
|
269
|
+
return 'noStrokes';
|
|
270
|
+
var consumed = this.consumedBy(fit.match.items);
|
|
271
|
+
if (consumed.length === 0)
|
|
272
|
+
return 'noStrokes';
|
|
273
|
+
var row = {
|
|
274
|
+
key: this.nextKey++,
|
|
275
|
+
hatch: fit.hatch,
|
|
276
|
+
match: fit.match,
|
|
277
|
+
included: true,
|
|
278
|
+
consumed: consumed,
|
|
279
|
+
guessed: !fit.fitted,
|
|
280
|
+
original: fit.hatch,
|
|
281
|
+
added: true
|
|
282
|
+
};
|
|
283
|
+
this.rows.push(row);
|
|
284
|
+
return row;
|
|
285
|
+
};
|
|
286
|
+
/** Boundary shapes of `row` (for framing it in the drawing). */
|
|
287
|
+
AcApPdfHatchSession.prototype.boundaryOf = function (row) {
|
|
288
|
+
return row.hatch.boundary;
|
|
289
|
+
};
|
|
290
|
+
AcApPdfHatchSession.prototype.refit = function (row, request) {
|
|
291
|
+
var fit = acapPdfFitHatch(this.input.items, row.hatch.boundary, request, {
|
|
292
|
+
tolerance: this.tolerance
|
|
293
|
+
});
|
|
294
|
+
if (!fit)
|
|
295
|
+
return false;
|
|
296
|
+
row.hatch = fit.hatch;
|
|
297
|
+
row.match = fit.match;
|
|
298
|
+
row.guessed = !fit.fitted;
|
|
299
|
+
row.consumed = this.consumedBy(fit.match.items);
|
|
300
|
+
return true;
|
|
301
|
+
};
|
|
302
|
+
AcApPdfHatchSession.prototype.restore = function (row) {
|
|
303
|
+
row.hatch = row.original;
|
|
304
|
+
row.match = __assign(__assign({}, acapPdfMatchHatch(this.input.items, row.original, this.tolerance)), { items: row.original.items });
|
|
305
|
+
row.guessed = false;
|
|
306
|
+
row.consumed = this.consumedBy(row.original.items);
|
|
307
|
+
};
|
|
308
|
+
/** Entities all of whose items are among `items`. */
|
|
309
|
+
AcApPdfHatchSession.prototype.consumedBy = function (items) {
|
|
310
|
+
var e_4, _a;
|
|
311
|
+
var _this = this;
|
|
312
|
+
var _b;
|
|
313
|
+
var taken = new Map();
|
|
314
|
+
try {
|
|
315
|
+
for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
|
|
316
|
+
var index = items_1_1.value;
|
|
317
|
+
var owner = this.input.owners[index];
|
|
318
|
+
taken.set(owner, ((_b = taken.get(owner)) !== null && _b !== void 0 ? _b : 0) + 1);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
322
|
+
finally {
|
|
323
|
+
try {
|
|
324
|
+
if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
|
|
325
|
+
}
|
|
326
|
+
finally { if (e_4) throw e_4.error; }
|
|
327
|
+
}
|
|
328
|
+
// A polyline whose other segments are line work stays as it is.
|
|
329
|
+
return __spreadArray([], __read(taken.entries()), false).filter(function (_a) {
|
|
330
|
+
var _b = __read(_a, 2), owner = _b[0], count = _b[1];
|
|
331
|
+
return count === _this.itemCount.get(owner);
|
|
332
|
+
})
|
|
333
|
+
.map(function (_a) {
|
|
334
|
+
var _b = __read(_a, 1), owner = _b[0];
|
|
335
|
+
return owner;
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
return AcApPdfHatchSession;
|
|
339
|
+
}());
|
|
340
|
+
export { AcApPdfHatchSession };
|
|
341
|
+
function requestOf(key) {
|
|
342
|
+
if (key === PDF_HATCH_USER_KEY)
|
|
343
|
+
return { type: 'userDefined', double: false };
|
|
344
|
+
if (key === PDF_HATCH_USER_DOUBLE_KEY) {
|
|
345
|
+
return { type: 'userDefined', double: true };
|
|
346
|
+
}
|
|
347
|
+
var prefix = 'predefined:';
|
|
348
|
+
if (key.startsWith(prefix)) {
|
|
349
|
+
return { type: 'predefined', name: key.slice(prefix.length) };
|
|
350
|
+
}
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
function normalizeDegrees(angle) {
|
|
354
|
+
var a = ((angle % 360) + 360) % 360;
|
|
355
|
+
return Number(a.toFixed(4)) % 360;
|
|
356
|
+
}
|
|
357
|
+
//# sourceMappingURL=AcApPdfHatchSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApPdfHatchSession.js","sourceRoot":"","sources":["../src/AcApPdfHatchSession.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAIhE,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EAIlB,MAAM,mCAAmC,CAAA;AAG1C,yDAAyD;AACzD,MAAM,CAAC,IAAM,wBAAwB,GAAG,IAAI,CAAA;AAC5C,sDAAsD;AACtD,MAAM,CAAC,IAAM,qBAAqB,GAAG,GAAG,CAAA;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OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;IAC7E,IAAI,GAAG,KAAK,yBAAyB,EAAE,CAAC;QACtC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;IAC9C,CAAC;IACD,IAAM,MAAM,GAAG,aAAa,CAAA;IAC5B,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAA;IAC/D,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,IAAM,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;IACrC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;AACnC,CAAC"}
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { type AcApContext } from '@mlightcad/cad-simple-viewer';
|
|
2
|
+
import { type AcApPdfImportOptions } from './AcApPdfImportOptions';
|
|
2
3
|
/**
|
|
3
4
|
* Converts a PDF file into CAD entities appended to the current document's
|
|
4
5
|
* model space.
|
|
5
6
|
*/
|
|
6
7
|
export declare class AcApPdfImportConvertor {
|
|
7
8
|
/**
|
|
8
|
-
* Prompts the user to pick a PDF file
|
|
9
|
+
* Prompts the user to pick a PDF file, shows the Import PDF dialog (page,
|
|
10
|
+
* insertion point, scale, import mode) and imports vector geometry
|
|
11
|
+
* (`pdfimport`).
|
|
12
|
+
*
|
|
13
|
+
* Returns without database edits when the picker or the dialog is
|
|
14
|
+
* dismissed. The command undo mark then has no committed changes, so
|
|
15
|
+
* nothing is pushed onto the undo stack.
|
|
16
|
+
*
|
|
17
|
+
* @param context - Application context for the target document
|
|
18
|
+
*/
|
|
19
|
+
importFromFilePicker(context: AcApContext): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Prompts the user to pick a PDF file, asks for page / insertion point /
|
|
22
|
+
* scale / mode on the command line, and imports vector geometry
|
|
23
|
+
* (`-pdfimport`).
|
|
9
24
|
*
|
|
10
25
|
* Returns without database edits when the picker is dismissed. The command
|
|
11
26
|
* undo mark then has no committed changes, so nothing is pushed onto the
|
|
@@ -13,19 +28,46 @@ export declare class AcApPdfImportConvertor {
|
|
|
13
28
|
*
|
|
14
29
|
* @param context - Application context for the target document
|
|
15
30
|
*/
|
|
16
|
-
|
|
31
|
+
importFromCommandLine(context: AcApContext): Promise<void>;
|
|
17
32
|
/**
|
|
18
33
|
* Opens the browser file picker.
|
|
19
34
|
*
|
|
20
35
|
* Resolves `undefined` when the user cancels the picker. `cancel` does not
|
|
21
36
|
* fire for every dismiss path, so closing the dialog (window focus with no
|
|
22
|
-
* selected file) also settles the promise. Otherwise `
|
|
37
|
+
* selected file) also settles the promise. Otherwise `pdfimport` would stay
|
|
23
38
|
* inside its write transaction.
|
|
24
39
|
*/
|
|
25
40
|
private pickPdfFile;
|
|
26
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Imports one PDF page into model space.
|
|
43
|
+
*
|
|
44
|
+
* @param context - Application context for the target document
|
|
45
|
+
* @param data - PDF file bytes
|
|
46
|
+
* @param pageNumberOrOptions - 1-based page number, or full import options
|
|
47
|
+
*/
|
|
48
|
+
convert(context: AcApContext, data: ArrayBuffer, pageNumberOrOptions?: number | AcApPdfImportOptions): Promise<void>;
|
|
49
|
+
private importDocument;
|
|
50
|
+
/**
|
|
51
|
+
* Command-line prompts: page (multi-page files only), then insertion point
|
|
52
|
+
* with `Scale` and `Mode` (recover the drawing / keep the PDF look)
|
|
53
|
+
* options.
|
|
54
|
+
*
|
|
55
|
+
* @returns Options to import with, or `undefined` when the user cancels.
|
|
56
|
+
*/
|
|
57
|
+
private promptImportOptions;
|
|
58
|
+
/**
|
|
59
|
+
* Asks for the import mode; Enter keeps `current`.
|
|
60
|
+
*
|
|
61
|
+
* @returns The chosen mode, or `undefined` when the user cancels.
|
|
62
|
+
*/
|
|
63
|
+
private promptImportMode;
|
|
64
|
+
/**
|
|
65
|
+
* Asks for the insertion point in the drawing. Enter takes the origin.
|
|
66
|
+
*
|
|
67
|
+
* @returns The point, or `undefined` when the user cancels.
|
|
68
|
+
*/
|
|
69
|
+
private promptInsertionPoint;
|
|
27
70
|
private importPage;
|
|
28
|
-
private subpathToEntity;
|
|
29
71
|
private textToEntity;
|
|
30
72
|
}
|
|
31
73
|
//# sourceMappingURL=AcApPdfImportConvertor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcApPdfImportConvertor.d.ts","sourceRoot":"","sources":["../src/AcApPdfImportConvertor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"AcApPdfImportConvertor.d.ts","sourceRoot":"","sources":["../src/AcApPdfImportConvertor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAYjB,MAAM,8BAA8B,CAAA;AA0BrC,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,wBAAwB,CAAA;AA6H/B;;;GAGG;AACH,qBAAa,sBAAsB;IACjC;;;;;;;;;;OAUG;IACG,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAiE/D;;;;;;;;;;OAUG;IACG,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBhE;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;IA8CnB;;;;;;OAMG;IACG,OAAO,CACX,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,WAAW,EACjB,mBAAmB,GAAE,MAAM,GAAG,oBAAwB;YAe1C,cAAc;IAW5B;;;;;;OAMG;YACW,mBAAmB;IAwEjC;;;;OAIG;YACW,gBAAgB;IAuB9B;;;;OAIG;YACW,oBAAoB;YAepB,UAAU;IAiRxB,OAAO,CAAC,YAAY;CAyBrB"}
|