@maqiuyao/dxf-viewer 0.2.22 → 0.2.23
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/README.md +1 -0
- package/dist/dxf-viewer.cjs +2 -2
- package/dist/dxf-viewer.js +34 -12
- package/dist/src/dxfViewer/core/compare/CompareDrawable.d.ts +7 -2
- package/dist/src/dxfViewer/core/helpers/TextSearchHelper.d.ts +4 -1
- package/dist/src/dxfViewer/core/viewers/Viewer2d.d.ts +9 -1
- package/package.json +1 -1
package/dist/dxf-viewer.js
CHANGED
|
@@ -14251,15 +14251,18 @@ const Nn = new p.Vector3();
|
|
|
14251
14251
|
class Ot extends ci {
|
|
14252
14252
|
/**
|
|
14253
14253
|
* @param id
|
|
14254
|
-
* @param boxes
|
|
14254
|
+
* @param boxes 需要绘制边框的包围盒集合
|
|
14255
14255
|
* @param lineColor 边框颜色 rgba 数组(0~1),默认红色
|
|
14256
14256
|
* @param fillColor 区域半透明填充色 rgba 数组(0~1),默认与边框同色、低透明度
|
|
14257
|
+
* @param useCloudBorder 边框样式,默认 false 普通圆角矩形边框;传 true 为云线(修订云线)花边
|
|
14257
14258
|
*/
|
|
14258
|
-
constructor(e, i, s = [1, 0, 0, 1], n) {
|
|
14259
|
+
constructor(e, i, s = [1, 0, 0, 1], n, r = !1) {
|
|
14259
14260
|
super(e);
|
|
14260
14261
|
g(this, "boxes");
|
|
14261
14262
|
g(this, "lineSegments");
|
|
14262
|
-
|
|
14263
|
+
/** 边框样式:true 云线(修订云线花边),false 普通圆角矩形边框 */
|
|
14264
|
+
g(this, "useCloudBorder");
|
|
14265
|
+
this.lineSegments = [], this.useCloudBorder = r, this.boxes = Ot.expandBoxesWithGap(i), this.lineColor = s, this.fillColor = n ?? [s[0], s[1], s[2], 0.12], this.lineWidth = 2, r && this.calculateCloudLineSegments(this.boxes);
|
|
14263
14266
|
}
|
|
14264
14267
|
/**
|
|
14265
14268
|
* 按包围盒尺寸比例向外扩张,使云线框与变动内容之间留出间隙,避免框线压住文字/图形。
|
|
@@ -14284,14 +14287,22 @@ class Ot extends ci {
|
|
|
14284
14287
|
}
|
|
14285
14288
|
draw(e, i) {
|
|
14286
14289
|
e.save(), e.lineWidth = this.lineWidth, e.strokeStyle = gs.rgba2Color(this.lineColor), e.fillStyle = gs.rgba2Color(this.fillColor);
|
|
14287
|
-
for (let s = 0; s < this.lineSegments.length; s++) {
|
|
14290
|
+
for (let s = 0; s < (this.useCloudBorder ? this.lineSegments.length : this.boxes.length); s++) {
|
|
14288
14291
|
const n = this.boxes[s];
|
|
14289
|
-
n && this.fillRect(e, i, n)
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
+
if (n && this.fillRect(e, i, n), this.useCloudBorder) {
|
|
14293
|
+
const r = this.lineSegments[s];
|
|
14294
|
+
this.drawBox(e, i, r);
|
|
14295
|
+
} else
|
|
14296
|
+
this.drawRoundedRect(e, i, n);
|
|
14292
14297
|
}
|
|
14293
14298
|
e.restore();
|
|
14294
14299
|
}
|
|
14300
|
+
/** 普通圆角矩形边框:屏幕空间绘制,圆角半径固定像素(不随缩放变化) */
|
|
14301
|
+
drawRoundedRect(e, i, s) {
|
|
14302
|
+
if (!s) return;
|
|
14303
|
+
const n = this.transToScreenCoord(new p.Vector3(s.min.x, s.min.y), i), r = this.transToScreenCoord(new p.Vector3(s.max.x, s.min.y), i), a = this.transToScreenCoord(new p.Vector3(s.max.x, s.max.y), i), o = this.transToScreenCoord(new p.Vector3(s.min.x, s.max.y), i), l = Math.hypot(r.x - n.x, r.y - n.y), h = Math.hypot(o.x - n.x, o.y - n.y), d = Math.max(0, Math.min(8, l / 2, h / 2));
|
|
14304
|
+
e.beginPath(), e.moveTo(n.x + d, n.y), e.arcTo(r.x, r.y, a.x, a.y, d), e.arcTo(a.x, a.y, o.x, o.y, d), e.arcTo(o.x, o.y, n.x, n.y, d), e.arcTo(n.x, n.y, r.x, r.y, d), e.closePath(), e.stroke();
|
|
14305
|
+
}
|
|
14295
14306
|
fillRect(e, i, s) {
|
|
14296
14307
|
const n = [new p.Vector3(s.min.x, s.min.y), new p.Vector3(s.max.x, s.min.y), new p.Vector3(s.max.x, s.max.y), new p.Vector3(s.min.x, s.max.y)];
|
|
14297
14308
|
e.beginPath();
|
|
@@ -32505,12 +32516,15 @@ class no {
|
|
|
32505
32516
|
}
|
|
32506
32517
|
/**
|
|
32507
32518
|
* 定位到一条搜索结果:切换到其所在布局、缩放至包围盒,并在叠加层高亮。
|
|
32519
|
+
* @param zoomScale 视野缩放比例:定位后的视野约为文字包围盒对角线的 zoomScale 倍,
|
|
32520
|
+
* 数值越大可视区域越大、文字占比越小(不要光看字);默认 8,
|
|
32521
|
+
* 传 2 约等于旧版视野(文字占满视野)。
|
|
32508
32522
|
*/
|
|
32509
|
-
focus(t) {
|
|
32523
|
+
focus(t, e = 8) {
|
|
32510
32524
|
if (!t) return;
|
|
32511
32525
|
this.viewer.activateLayout(t.layoutName), this.highlight(t);
|
|
32512
|
-
const
|
|
32513
|
-
this.viewer.zoomToBBox(
|
|
32526
|
+
const i = t.box.clone(), s = i.getSize(pu).length(), n = Math.max(s * e, s + 2);
|
|
32527
|
+
this.viewer.zoomToBBox(i.expandByScalar((n - s) / 2));
|
|
32514
32528
|
}
|
|
32515
32529
|
/**
|
|
32516
32530
|
* 在叠加层用云线框高亮指定结果(替换上一个高亮)。
|
|
@@ -34150,9 +34164,17 @@ class $o extends Pr {
|
|
|
34150
34164
|
/**
|
|
34151
34165
|
* @description {en} Zooms to a text search result and highlights it with a cloud border.
|
|
34152
34166
|
* @description {zh} 定位到一条文本搜索结果并高亮(云线框)。
|
|
34167
|
+
* @param zoomScale 视野缩放比例:定位后的视野约为文字包围盒对角线的 zoomScale 倍,
|
|
34168
|
+
* 数值越大可视区域越大、文字占比越小;默认 8,传 2 约等于旧版视野。
|
|
34169
|
+
* @example
|
|
34170
|
+
* ```typescript
|
|
34171
|
+
* const results = viewer.searchText("道岔");
|
|
34172
|
+
* results.length > 0 && viewer.focusText(results[0]); // 默认视野(可视区域较大)
|
|
34173
|
+
* results.length > 0 && viewer.focusText(results[0], 4); // 更贴近文字
|
|
34174
|
+
* ```
|
|
34153
34175
|
*/
|
|
34154
|
-
focusText(e) {
|
|
34155
|
-
!this.textSearchHelper && (this.textSearchHelper = new no(this)), this.textSearchHelper.focus(e);
|
|
34176
|
+
focusText(e, i) {
|
|
34177
|
+
!this.textSearchHelper && (this.textSearchHelper = new no(this)), this.textSearchHelper.focus(e, i);
|
|
34156
34178
|
}
|
|
34157
34179
|
/**
|
|
34158
34180
|
* @description {en} Clears the highlight of text search results.
|
|
@@ -6,13 +6,16 @@ import * as THREE from "three";
|
|
|
6
6
|
export declare class CompareDrawable extends Drawable {
|
|
7
7
|
boxes: THREE.Box3[];
|
|
8
8
|
lineSegments: THREE.Vector3[][];
|
|
9
|
+
/** 边框样式:true 云线(修订云线花边),false 普通圆角矩形边框 */
|
|
10
|
+
private useCloudBorder;
|
|
9
11
|
/**
|
|
10
12
|
* @param id
|
|
11
|
-
* @param boxes
|
|
13
|
+
* @param boxes 需要绘制边框的包围盒集合
|
|
12
14
|
* @param lineColor 边框颜色 rgba 数组(0~1),默认红色
|
|
13
15
|
* @param fillColor 区域半透明填充色 rgba 数组(0~1),默认与边框同色、低透明度
|
|
16
|
+
* @param useCloudBorder 边框样式,默认 false 普通圆角矩形边框;传 true 为云线(修订云线)花边
|
|
14
17
|
*/
|
|
15
|
-
constructor(id: string, boxes: THREE.Box3[], lineColor?: number[], fillColor?: number[]);
|
|
18
|
+
constructor(id: string, boxes: THREE.Box3[], lineColor?: number[], fillColor?: number[], useCloudBorder?: boolean);
|
|
16
19
|
/**
|
|
17
20
|
* 按包围盒尺寸比例向外扩张,使云线框与变动内容之间留出间隙,避免框线压住文字/图形。
|
|
18
21
|
* 间隙取盒最长边的 12%(退化盒给最小值兜底)。
|
|
@@ -20,6 +23,8 @@ export declare class CompareDrawable extends Drawable {
|
|
|
20
23
|
private static expandBoxesWithGap;
|
|
21
24
|
private calculateCloudLineSegments;
|
|
22
25
|
draw(ctx: CanvasRenderingContext2D, camera: THREE.Camera): void;
|
|
26
|
+
/** 普通圆角矩形边框:屏幕空间绘制,圆角半径固定像素(不随缩放变化) */
|
|
27
|
+
private drawRoundedRect;
|
|
23
28
|
private fillRect;
|
|
24
29
|
private drawBox;
|
|
25
30
|
static getControlPointByTwoPoints(p1: THREE.Vector2, p2: THREE.Vector2): THREE.Vector2;
|
|
@@ -68,8 +68,11 @@ export declare class TextSearchHelper {
|
|
|
68
68
|
}): TextSearchResult[];
|
|
69
69
|
/**
|
|
70
70
|
* 定位到一条搜索结果:切换到其所在布局、缩放至包围盒,并在叠加层高亮。
|
|
71
|
+
* @param zoomScale 视野缩放比例:定位后的视野约为文字包围盒对角线的 zoomScale 倍,
|
|
72
|
+
* 数值越大可视区域越大、文字占比越小(不要光看字);默认 8,
|
|
73
|
+
* 传 2 约等于旧版视野(文字占满视野)。
|
|
71
74
|
*/
|
|
72
|
-
focus(result: TextSearchResult): void;
|
|
75
|
+
focus(result: TextSearchResult, zoomScale?: number): void;
|
|
73
76
|
/**
|
|
74
77
|
* 在叠加层用云线框高亮指定结果(替换上一个高亮)。
|
|
75
78
|
*/
|
|
@@ -442,8 +442,16 @@ export declare class Viewer2d extends BaseViewer {
|
|
|
442
442
|
/**
|
|
443
443
|
* @description {en} Zooms to a text search result and highlights it with a cloud border.
|
|
444
444
|
* @description {zh} 定位到一条文本搜索结果并高亮(云线框)。
|
|
445
|
+
* @param zoomScale 视野缩放比例:定位后的视野约为文字包围盒对角线的 zoomScale 倍,
|
|
446
|
+
* 数值越大可视区域越大、文字占比越小;默认 8,传 2 约等于旧版视野。
|
|
447
|
+
* @example
|
|
448
|
+
* ```typescript
|
|
449
|
+
* const results = viewer.searchText("道岔");
|
|
450
|
+
* results.length > 0 && viewer.focusText(results[0]); // 默认视野(可视区域较大)
|
|
451
|
+
* results.length > 0 && viewer.focusText(results[0], 4); // 更贴近文字
|
|
452
|
+
* ```
|
|
445
453
|
*/
|
|
446
|
-
focusText(result: TextSearchResult): void;
|
|
454
|
+
focusText(result: TextSearchResult, zoomScale?: number): void;
|
|
447
455
|
/**
|
|
448
456
|
* @description {en} Clears the highlight of text search results.
|
|
449
457
|
* @description {zh} 清除文本搜索结果的高亮。
|