@xtctwins/tctwins-pdf-core 0.1.0
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 +0 -0
- package/dist/PdfViewer.d.ts +81 -0
- package/dist/PdfViewer.d.ts.map +1 -0
- package/dist/annotations/index.d.ts +3 -0
- package/dist/annotations/index.d.ts.map +1 -0
- package/dist/annotations/types.d.ts +3 -0
- package/dist/annotations/types.d.ts.map +1 -0
- package/dist/annotations/utils.d.ts +11 -0
- package/dist/annotations/utils.d.ts.map +1 -0
- package/dist/components/PdfViewer.d.ts +65 -0
- package/dist/components/PdfViewer.d.ts.map +1 -0
- package/dist/components/PdfViewer.vue.d.ts +44 -0
- package/dist/components/PdfViewer.vue.d.ts.map +1 -0
- package/dist/components/interaction.d.ts +15 -0
- package/dist/components/interaction.d.ts.map +1 -0
- package/dist/components/types.d.ts +3 -0
- package/dist/components/types.d.ts.map +1 -0
- package/dist/components/useAnnotationCanvas.d.ts +49 -0
- package/dist/components/useAnnotationCanvas.d.ts.map +1 -0
- package/dist/components/usePointerInteraction.d.ts +51 -0
- package/dist/components/usePointerInteraction.d.ts.map +1 -0
- package/dist/components/useViewerLayout.d.ts +46 -0
- package/dist/components/useViewerLayout.d.ts.map +1 -0
- package/dist/components/useViewerManager.d.ts +46 -0
- package/dist/components/useViewerManager.d.ts.map +1 -0
- package/dist/core/PDFLoader.d.ts +15 -0
- package/dist/core/PDFLoader.d.ts.map +1 -0
- package/dist/core/TileCache.d.ts +18 -0
- package/dist/core/TileCache.d.ts.map +1 -0
- package/dist/core/TileRenderer.d.ts +29 -0
- package/dist/core/TileRenderer.d.ts.map +1 -0
- package/dist/core/coords/CoordTransformer.d.ts +19 -0
- package/dist/core/coords/CoordTransformer.d.ts.map +1 -0
- package/dist/core/coords/Types.d.ts +3 -0
- package/dist/core/coords/Types.d.ts.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/pdf-core.js +1308 -0
- package/dist/style.css +2 -0
- package/dist/tools/MeasureTool.d.ts +59 -0
- package/dist/tools/MeasureTool.d.ts.map +1 -0
- package/dist/tools/ToolManager.d.ts +42 -0
- package/dist/tools/ToolManager.d.ts.map +1 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/measure/AngleMeasure.d.ts +23 -0
- package/dist/tools/measure/AngleMeasure.d.ts.map +1 -0
- package/dist/tools/measure/AreaMeasure.d.ts +22 -0
- package/dist/tools/measure/AreaMeasure.d.ts.map +1 -0
- package/dist/tools/measure/DistanceMeasure.d.ts +22 -0
- package/dist/tools/measure/DistanceMeasure.d.ts.map +1 -0
- package/dist/tools/measure/MeasureBase.d.ts +87 -0
- package/dist/tools/measure/MeasureBase.d.ts.map +1 -0
- package/dist/tools/measure/index.d.ts +5 -0
- package/dist/tools/measure/index.d.ts.map +1 -0
- package/dist/tools/types.d.ts +4 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/types/annotations.d.ts +29 -0
- package/dist/types/annotations.d.ts.map +1 -0
- package/dist/types/components.d.ts +28 -0
- package/dist/types/components.d.ts.map +1 -0
- package/dist/types/coords.d.ts +28 -0
- package/dist/types/coords.d.ts.map +1 -0
- package/dist/types/core.d.ts +44 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/tools.d.ts +113 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/utils/EventTrigger.d.ts +45 -0
- package/dist/utils/EventTrigger.d.ts.map +1 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/plugin.d.ts +5 -0
- package/dist/vue/plugin.d.ts.map +1 -0
- package/dist/vue/useAnnotations.d.ts +12 -0
- package/dist/vue/useAnnotations.d.ts.map +1 -0
- package/dist/vue/useInteraction.d.ts +13 -0
- package/dist/vue/useInteraction.d.ts.map +1 -0
- package/dist/vue/useMeasurement.d.ts +10 -0
- package/dist/vue/useMeasurement.d.ts.map +1 -0
- package/dist/vue/usePdfCore.d.ts +28 -0
- package/dist/vue/usePdfCore.d.ts.map +1 -0
- package/package.json +61 -0
package/dist/style.css
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.pdf-core-viewer[data-v-0e4941dc]{border:1px solid #e5e7eb;width:100%;position:relative}.pdf-core-toolbar[data-v-0e4941dc]{z-index:10;background:#ffffffe6;border-radius:6px;gap:8px;padding:6px;display:flex;position:absolute;top:8px;left:8px;box-shadow:0 2px 8px #00000014}.pdf-core-toolbar button[data-v-0e4941dc]{cursor:pointer;background:#fff;border:1px solid #cbd5e1;border-radius:4px;padding:4px 8px}.pdf-core-canvas-wrapper[data-v-0e4941dc]{justify-content:center;align-items:center;margin:auto;display:flex;position:relative}.pdf-core-pdf-layer[data-v-0e4941dc]{z-index:0;position:relative}.pdf-core-annotation-canvas[data-v-0e4941dc]{z-index:1;pointer-events:none;position:absolute;inset:0}.pdf-core-overlay[data-v-0e4941dc]{z-index:2;position:absolute;inset:0}
|
|
2
|
+
/*$vite$:1*/
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 测量工具门面
|
|
3
|
+
* 参考 dxf-viewer/src/Toolbar/MeasureTool.js
|
|
4
|
+
*
|
|
5
|
+
* 职责:
|
|
6
|
+
* - 管理所有测量子工具(distance / angle / area)
|
|
7
|
+
* - 根据当前子类型激活对应子工具
|
|
8
|
+
* - 持有 EventTrigger,子工具通过它发射事件
|
|
9
|
+
* - 作为统一入口向外部暴露 onPointerDown / onPointerMove / onPointerUp
|
|
10
|
+
*/
|
|
11
|
+
import type { MeasureSubType, MeasureResult, ITool, ToolEventMap } from "../types/tools";
|
|
12
|
+
import type { MeasureCoordProvider } from "./measure/MeasureBase";
|
|
13
|
+
import { EventTrigger } from "../utils/EventTrigger";
|
|
14
|
+
export interface MeasureToolOptions {
|
|
15
|
+
coordProvider: MeasureCoordProvider;
|
|
16
|
+
calibration?: {
|
|
17
|
+
scale: number;
|
|
18
|
+
unit: string;
|
|
19
|
+
precision: number;
|
|
20
|
+
};
|
|
21
|
+
/** 可选:外部注入 EventTrigger(通常由 ToolManager 传入) */
|
|
22
|
+
eventTrigger?: EventTrigger<ToolEventMap>;
|
|
23
|
+
}
|
|
24
|
+
export declare class MeasureTool implements ITool {
|
|
25
|
+
readonly TOOLNAME: "measure";
|
|
26
|
+
get currentType(): string;
|
|
27
|
+
private _currentSubType;
|
|
28
|
+
private _active;
|
|
29
|
+
private _isCreating;
|
|
30
|
+
private distanceMeasure;
|
|
31
|
+
private angleMeasure;
|
|
32
|
+
private areaMeasure;
|
|
33
|
+
private _subTools;
|
|
34
|
+
private _resultList;
|
|
35
|
+
/** 公开的事件触发器 */
|
|
36
|
+
readonly events: EventTrigger<ToolEventMap>;
|
|
37
|
+
constructor(options: MeasureToolOptions);
|
|
38
|
+
private _onMeasureStart;
|
|
39
|
+
private _onMeasureCreated;
|
|
40
|
+
get subType(): MeasureSubType;
|
|
41
|
+
setSubType(type: MeasureSubType): void;
|
|
42
|
+
getActive(): boolean;
|
|
43
|
+
get isCreating(): boolean;
|
|
44
|
+
setActive(active: boolean): void;
|
|
45
|
+
onPointerDown(event: PointerEvent): void;
|
|
46
|
+
onPointerMove(event: PointerEvent): void;
|
|
47
|
+
onPointerUp(event: PointerEvent): void;
|
|
48
|
+
getResults(): MeasureResult[];
|
|
49
|
+
getResult(id: string): MeasureResult | undefined;
|
|
50
|
+
removeResult(id: string): boolean;
|
|
51
|
+
clearResults(): void;
|
|
52
|
+
/** 距离测量的预览终点 */
|
|
53
|
+
get previewDistanceEnd(): import(".").Point2D | null;
|
|
54
|
+
/** 当前子工具的测量点 */
|
|
55
|
+
get currentPoints(): any;
|
|
56
|
+
interrupt(): void;
|
|
57
|
+
destroy(): void;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=MeasureTool.d.ts.map
|
|
@@ -0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B,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAwBhC,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAMxC,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAMxC,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAQtC,UAAU,IAAI,aAAa,EAAE;IAI7B,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIhD,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIjC,YAAY,IAAI,IAAI;IAMpB,gBAAgB;IAChB,IAAI,kBAAkB,+BAErB;IAED,gBAAgB;IAChB,IAAI,aAAa,QAGhB;IAID,SAAS,IAAI,IAAI;IAKjB,OAAO,IAAI,IAAI;CAUf"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 工具管理器
|
|
3
|
+
* 参考 dxf-viewer/src/ToolManager.js
|
|
4
|
+
*
|
|
5
|
+
* 职责:
|
|
6
|
+
* - 管理所有工具的创建/激活/销毁生命周期
|
|
7
|
+
* - 提供统一的事件分发接口
|
|
8
|
+
* - 维护当前激活工具状态
|
|
9
|
+
* - 持有全局 EventTrigger
|
|
10
|
+
*/
|
|
11
|
+
import type { ToolMode, ITool, ToolEventMap } from "../types/tools";
|
|
12
|
+
import { EventTrigger } from "../utils/EventTrigger";
|
|
13
|
+
import { MeasureTool, type MeasureToolOptions } from "./MeasureTool";
|
|
14
|
+
export interface ToolManagerOptions {
|
|
15
|
+
/** 坐标转换注入(所有工具共用) */
|
|
16
|
+
coordProvider: MeasureToolOptions["coordProvider"];
|
|
17
|
+
/** 比例校准 */
|
|
18
|
+
calibration?: MeasureToolOptions["calibration"];
|
|
19
|
+
}
|
|
20
|
+
export declare class ToolManager {
|
|
21
|
+
private _activeTool;
|
|
22
|
+
private _activeMode;
|
|
23
|
+
private _tools;
|
|
24
|
+
/** 全局事件触发器 */
|
|
25
|
+
readonly events: EventTrigger<ToolEventMap>;
|
|
26
|
+
readonly measureTool: MeasureTool;
|
|
27
|
+
constructor(options: ToolManagerOptions);
|
|
28
|
+
get activeMode(): ToolMode;
|
|
29
|
+
/** 切换到指定工具 */
|
|
30
|
+
setMode(mode: ToolMode): void;
|
|
31
|
+
/** 获取当前激活的工具 */
|
|
32
|
+
getActiveTool(): ITool | null;
|
|
33
|
+
registerTool(mode: ToolMode, tool: ITool): void;
|
|
34
|
+
onPointerDown(event: PointerEvent): void;
|
|
35
|
+
onPointerMove(event: PointerEvent): void;
|
|
36
|
+
onPointerUp(event: PointerEvent): void;
|
|
37
|
+
/** 中断当前工具操作 */
|
|
38
|
+
interrupt(): void;
|
|
39
|
+
/** 销毁所有工具 */
|
|
40
|
+
destroy(): void;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=ToolManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolManager.d.ts","sourceRoot":"","sources":["../../src/tools/ToolManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAwB,MAAM,gBAAgB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAErE,MAAM,WAAW,kBAAkB;IAClC,qBAAqB;IACrB,aAAa,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACnD,WAAW;IACX,WAAW,CAAC,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;CAChD;AAED,qBAAa,WAAW;IACvB,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,MAAM,CAA8B;IAE5C,cAAc;IACd,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;IAG5C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;gBAEtB,OAAO,EAAE,kBAAkB;IAcvC,IAAI,UAAU,IAAI,QAAQ,CAEzB;IAED,cAAc;IACd,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAkC7B,gBAAgB;IAChB,aAAa,IAAI,KAAK,GAAG,IAAI;IAM7B,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI;IAM/C,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAIxC,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAIxC,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAMtC,eAAe;IACf,SAAS,IAAI,IAAI;IAIjB,aAAa;IACb,OAAO,IAAI,IAAI;CASf"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { ToolMode, MeasureSubType, ToolState, Point2D, MeasureResult, UnitType, PrecisionType, ScaleCalibration, MeasureStartEvent, MeasureCreatedEvent, MeasureCancelEvent, ToolActiveEvent, ToolModeChangedEvent, ITool } from "../types/tools";
|
|
2
|
+
export { DEFAULT_TOOL_STATE } from "../types/tools";
|
|
3
|
+
export { EventTrigger } from "../utils/EventTrigger";
|
|
4
|
+
export type { ToolEventMap } from "../types/tools";
|
|
5
|
+
export { ToolManager, type ToolManagerOptions } from "./ToolManager";
|
|
6
|
+
export { MeasureTool, type MeasureToolOptions } from "./MeasureTool";
|
|
7
|
+
export { MeasureBase, DistanceMeasure, AngleMeasure, AreaMeasure, type MeasureBaseOptions, type MeasureCoordProvider } from "./measure";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,eAAe,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvP,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGrE,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 角度测量工具(骨架)
|
|
3
|
+
* 参考 dxf-viewer/src/Toolbar/MeasureTools/MeasureAngleTool.js
|
|
4
|
+
*
|
|
5
|
+
* 交互流程:
|
|
6
|
+
* 1. 第一次点击 → 角的顶点
|
|
7
|
+
* 2. 第二次点击 → 第一条边的终点
|
|
8
|
+
* 3. 第三次点击 → 第二条边的终点,计算角度
|
|
9
|
+
*/
|
|
10
|
+
import type { MeasureSubType } from "../../types/tools";
|
|
11
|
+
import { MeasureBase, type MeasureBaseOptions } from "./MeasureBase";
|
|
12
|
+
export declare class AngleMeasure extends MeasureBase {
|
|
13
|
+
readonly currentType: MeasureSubType;
|
|
14
|
+
private _secondPoint;
|
|
15
|
+
private _thirdPoint;
|
|
16
|
+
constructor(options: MeasureBaseOptions);
|
|
17
|
+
onPointerDown(event: PointerEvent): void;
|
|
18
|
+
onPointerMove(_event: PointerEvent): void;
|
|
19
|
+
onPointerUp(_event: PointerEvent): void;
|
|
20
|
+
/** 三点计算角度(度) */
|
|
21
|
+
private calcAngle;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=AngleMeasure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AngleMeasure.d.ts","sourceRoot":"","sources":["../../../src/tools/measure/AngleMeasure.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAW,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAErE,qBAAa,YAAa,SAAQ,WAAW;IAC5C,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAW;IAE/C,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,WAAW,CAAwB;gBAE/B,OAAO,EAAE,kBAAkB;IAIvC,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IA6BxC,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAIzC,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAcvC,gBAAgB;IAChB,OAAO,CAAC,SAAS;CAgBjB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 面积测量工具(骨架)
|
|
3
|
+
* 参考 dxf-viewer/src/Toolbar/MeasureTools/MeasureAreaTool.js
|
|
4
|
+
*
|
|
5
|
+
* 交互流程:
|
|
6
|
+
* - 连续点击多边形的各个顶点
|
|
7
|
+
* - 双击或右键完成 → 计算闭合多边形面积
|
|
8
|
+
*/
|
|
9
|
+
import type { MeasureSubType } from "../../types/tools";
|
|
10
|
+
import { MeasureBase, type MeasureBaseOptions } from "./MeasureBase";
|
|
11
|
+
export declare class AreaMeasure extends MeasureBase {
|
|
12
|
+
readonly currentType: MeasureSubType;
|
|
13
|
+
constructor(options: MeasureBaseOptions);
|
|
14
|
+
onPointerDown(event: PointerEvent): void;
|
|
15
|
+
onPointerMove(_event: PointerEvent): void;
|
|
16
|
+
onPointerUp(_event: PointerEvent): void;
|
|
17
|
+
/** 手动完成面积测量 */
|
|
18
|
+
finish(): void;
|
|
19
|
+
/** Shoelace 公式计算多边形面积 */
|
|
20
|
+
private calcPolygonArea;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=AreaMeasure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AreaMeasure.d.ts","sourceRoot":"","sources":["../../../src/tools/measure/AreaMeasure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAW,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAErE,qBAAa,WAAY,SAAQ,WAAW;IAC3C,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAU;gBAElC,OAAO,EAAE,kBAAkB;IAIvC,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAgBxC,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAIzC,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAIvC,eAAe;IACf,MAAM,IAAI,IAAI;IAOd,yBAAyB;IACzB,OAAO,CAAC,eAAe;CAUvB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 距离测量工具
|
|
3
|
+
* 参考 dxf-viewer/src/Toolbar/MeasureTools/MeasureDistanceTool.js
|
|
4
|
+
*
|
|
5
|
+
* 交互流程:
|
|
6
|
+
* 1. 第一次点击 → 设置起点,开始拖拽预览
|
|
7
|
+
* 2. 鼠标移动 → 实时更新终点预览
|
|
8
|
+
* 3. 第二次点击 → 确认终点,完成测量
|
|
9
|
+
*/
|
|
10
|
+
import type { Point2D, MeasureSubType } from "../../types/tools";
|
|
11
|
+
import { MeasureBase, type MeasureBaseOptions } from "./MeasureBase";
|
|
12
|
+
export declare class DistanceMeasure extends MeasureBase {
|
|
13
|
+
readonly currentType: MeasureSubType;
|
|
14
|
+
private _previewEnd;
|
|
15
|
+
constructor(options: MeasureBaseOptions);
|
|
16
|
+
get previewEnd(): Point2D | null;
|
|
17
|
+
onPointerDown(event: PointerEvent): void;
|
|
18
|
+
onPointerMove(event: PointerEvent): void;
|
|
19
|
+
onPointerUp(event: PointerEvent): void;
|
|
20
|
+
interrupt(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=DistanceMeasure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DistanceMeasure.d.ts","sourceRoot":"","sources":["../../../src/tools/measure/DistanceMeasure.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAErE,qBAAa,eAAgB,SAAQ,WAAW;IAC/C,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAc;IAGlD,OAAO,CAAC,WAAW,CAAwB;gBAE/B,OAAO,EAAE,kBAAkB;IAIvC,IAAI,UAAU,IAAI,OAAO,GAAG,IAAI,CAE/B;IAID,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IA2BxC,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAsBxC,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAgCtC,SAAS,IAAI,IAAI;CAIjB"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 测量工具基类
|
|
3
|
+
* 参考 dxf-viewer/src/Toolbar/MeasureTools/MeasureBase.js
|
|
4
|
+
*
|
|
5
|
+
* 提供所有测量子工具共用的:
|
|
6
|
+
* - 生命周期状态管理(isStart / isEnd / isMeasuring)
|
|
7
|
+
* - 点集管理(_points)
|
|
8
|
+
* - 中断/重置逻辑
|
|
9
|
+
* - 屏幕坐标 ↔ scene 坐标转换(由外部注入)
|
|
10
|
+
*/
|
|
11
|
+
import type { Point2D, ITool, ToolMode, MeasureSubType, MeasureResult, ToolEventMap } from "../../types/tools";
|
|
12
|
+
import type { EventTrigger } from "../../utils/EventTrigger";
|
|
13
|
+
export interface MeasureCoordProvider {
|
|
14
|
+
/** 屏幕坐标 → 场景坐标(PDF 逻辑坐标) */
|
|
15
|
+
screenToScene(event: PointerEvent): Point2D;
|
|
16
|
+
/** 场景坐标 → 屏幕坐标 */
|
|
17
|
+
sceneToScreen(point: Point2D): Point2D;
|
|
18
|
+
}
|
|
19
|
+
export interface MeasureBaseOptions {
|
|
20
|
+
/** 坐标转换提供者 */
|
|
21
|
+
coordProvider: MeasureCoordProvider;
|
|
22
|
+
/** 比例校准(可选,用于 mm/cm/m/km 换算) */
|
|
23
|
+
calibration?: {
|
|
24
|
+
scale: number;
|
|
25
|
+
unit: string;
|
|
26
|
+
precision: number;
|
|
27
|
+
};
|
|
28
|
+
/** 事件触发器(由 MeasureTool 注入,子工具通过它发送事件) */
|
|
29
|
+
eventTrigger: EventTrigger<ToolEventMap>;
|
|
30
|
+
}
|
|
31
|
+
export declare abstract class MeasureBase implements ITool {
|
|
32
|
+
readonly TOOLNAME: ToolMode;
|
|
33
|
+
abstract readonly currentType: MeasureSubType;
|
|
34
|
+
protected _active: boolean;
|
|
35
|
+
protected _isStart: boolean;
|
|
36
|
+
protected _isEnd: boolean;
|
|
37
|
+
protected _isMeasuring: boolean;
|
|
38
|
+
protected _isDragging: boolean;
|
|
39
|
+
protected _startPoint: Point2D | null;
|
|
40
|
+
protected _endPoint: Point2D | null;
|
|
41
|
+
protected _points: Point2D[];
|
|
42
|
+
protected _measureList: Map<string, {
|
|
43
|
+
points: Point2D[];
|
|
44
|
+
result: MeasureResult | null;
|
|
45
|
+
}>;
|
|
46
|
+
protected coordProvider: MeasureCoordProvider;
|
|
47
|
+
protected calibration: {
|
|
48
|
+
scale: number;
|
|
49
|
+
unit: string;
|
|
50
|
+
precision: number;
|
|
51
|
+
};
|
|
52
|
+
protected eventTrigger: EventTrigger<ToolEventMap>;
|
|
53
|
+
protected _dragStart: Point2D | null;
|
|
54
|
+
protected _dragThreshold: number;
|
|
55
|
+
constructor(options: MeasureBaseOptions);
|
|
56
|
+
getActive(): boolean;
|
|
57
|
+
setActive(active: boolean): void;
|
|
58
|
+
protected getScenePoint(event: PointerEvent): Point2D;
|
|
59
|
+
/** 两点距离(场景坐标) */
|
|
60
|
+
protected distance(a: Point2D, b: Point2D): number;
|
|
61
|
+
/** 应用比例校准 */
|
|
62
|
+
protected calibrate(rawValue: number): {
|
|
63
|
+
value: number;
|
|
64
|
+
label: string;
|
|
65
|
+
};
|
|
66
|
+
protected generateId(): string;
|
|
67
|
+
protected buildResult(points: Point2D[], rawValue: number): MeasureResult;
|
|
68
|
+
protected isDrag(event: PointerEvent): boolean;
|
|
69
|
+
abstract onPointerDown(event: PointerEvent): void;
|
|
70
|
+
abstract onPointerMove(event: PointerEvent): void;
|
|
71
|
+
abstract onPointerUp(event: PointerEvent): void;
|
|
72
|
+
/** 发射测量开始事件 */
|
|
73
|
+
protected emitMeasureStart(): void;
|
|
74
|
+
/** 发射测量创建事件 */
|
|
75
|
+
protected emitMeasureCreated(result: MeasureResult): void;
|
|
76
|
+
/** 发射测量取消事件 */
|
|
77
|
+
protected emitMeasureCancel(): void;
|
|
78
|
+
/** 中断当前测量 */
|
|
79
|
+
interrupt(): void;
|
|
80
|
+
/** 完成当前测量 */
|
|
81
|
+
protected finalize(rawValue: number): MeasureResult | null;
|
|
82
|
+
/** 重置内部状态 */
|
|
83
|
+
protected resetState(): void;
|
|
84
|
+
/** 销毁清理 */
|
|
85
|
+
destroy(): void;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=MeasureBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Meas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,IAAI;IAazD,eAAe;IACf,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAOnC,aAAa;IACb,SAAS,IAAI,IAAI;IAQjB,aAAa;IACb,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;IAU1D,aAAa;IACb,SAAS,CAAC,UAAU,IAAI,IAAI;IAW5B,WAAW;IACX,OAAO,IAAI,IAAI;CAKf"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { MeasureBase, type MeasureBaseOptions, type MeasureCoordProvider } from "./MeasureBase";
|
|
2
|
+
export { DistanceMeasure } from "./DistanceMeasure";
|
|
3
|
+
export { AngleMeasure } from "./AngleMeasure";
|
|
4
|
+
export { AreaMeasure } from "./AreaMeasure";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/measure/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** @deprecated 请改用 src/types/tools */
|
|
2
|
+
export type { ToolMode, MeasureSubType, ToolState, Point2D, MeasureResult, UnitType, PrecisionType, ScaleCalibration, ToolEventMap, ITool } from "../types/tools";
|
|
3
|
+
export { DEFAULT_TOOL_STATE } from "../types/tools";
|
|
4
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAClK,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 标注系统类型定义
|
|
3
|
+
* 从 src/annotations/types.ts 集中迁移至 src/types/
|
|
4
|
+
*/
|
|
5
|
+
export type AnnotationKind = "measure" | "shape";
|
|
6
|
+
export interface PointLike {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}
|
|
10
|
+
export interface AnnotationBase {
|
|
11
|
+
id: string;
|
|
12
|
+
kind: AnnotationKind;
|
|
13
|
+
points: PointLike[];
|
|
14
|
+
color?: string;
|
|
15
|
+
strokeWidth?: number;
|
|
16
|
+
label?: string;
|
|
17
|
+
createdAt?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface MeasureAnnotation extends AnnotationBase {
|
|
20
|
+
kind: "measure";
|
|
21
|
+
value?: number;
|
|
22
|
+
unit?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ShapeAnnotation extends AnnotationBase {
|
|
25
|
+
kind: "shape";
|
|
26
|
+
shapeType?: "rectangle" | "circle" | "polygon" | "freehand";
|
|
27
|
+
}
|
|
28
|
+
export type AnnotationItem = MeasureAnnotation | ShapeAnnotation;
|
|
29
|
+
//# sourceMappingURL=annotations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/types/annotations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC;AAEjD,MAAM,WAAW,SAAS;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED,MAAM,WAAW,cAAc;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAkB,SAAQ,cAAc;IACxD,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACtD,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;CAC5D;AAED,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 组件 Props/Emits 类型定义
|
|
3
|
+
* 从 src/components/types.ts 集中迁移至 src/types/
|
|
4
|
+
*/
|
|
5
|
+
export interface PdfViewerProps {
|
|
6
|
+
modelValue?: ArrayBuffer | null;
|
|
7
|
+
scale?: number;
|
|
8
|
+
width?: string | number;
|
|
9
|
+
height?: string | number;
|
|
10
|
+
theme?: "light" | "dark";
|
|
11
|
+
toolbar?: boolean;
|
|
12
|
+
/** 缩放速率:滚轮每格跳动几个 ZOOM_LEVELS 档位,默认 1 */
|
|
13
|
+
zoomSpeed?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface PdfViewerEmits {
|
|
16
|
+
(e: "loaded", payload: {
|
|
17
|
+
pageCount: number;
|
|
18
|
+
currentPage: number;
|
|
19
|
+
}): void;
|
|
20
|
+
(e: "error", payload: {
|
|
21
|
+
message: string;
|
|
22
|
+
}): void;
|
|
23
|
+
(e: "annotation-added", payload: {
|
|
24
|
+
id: string;
|
|
25
|
+
kind: "measure" | "shape";
|
|
26
|
+
}): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/types/components.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC9B,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC9B,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACzE,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD,CAAC,CAAC,EAAE,kBAAkB,EAAE,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CAClF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 坐标系统类型定义
|
|
3
|
+
* 从 src/core/coords/Types.ts 集中迁移至 src/types/
|
|
4
|
+
*/
|
|
5
|
+
/** 屏幕像素坐标(左上角原点,Y 轴朝下) */
|
|
6
|
+
export interface ScreenPoint {
|
|
7
|
+
readonly x: number;
|
|
8
|
+
readonly y: number;
|
|
9
|
+
}
|
|
10
|
+
/** PDF 逻辑坐标,即 PDF.js 内部点坐标(左下角原点,Y 轴朝上) */
|
|
11
|
+
export interface PagePoint {
|
|
12
|
+
readonly x: number;
|
|
13
|
+
readonly y: number;
|
|
14
|
+
}
|
|
15
|
+
/** pdf-lib 写入坐标 */
|
|
16
|
+
export interface PdfLibPoint {
|
|
17
|
+
readonly x: number;
|
|
18
|
+
readonly y: number;
|
|
19
|
+
}
|
|
20
|
+
export interface PageSizePt {
|
|
21
|
+
readonly width: number;
|
|
22
|
+
readonly height: number;
|
|
23
|
+
}
|
|
24
|
+
export interface ViewportLike {
|
|
25
|
+
convertToViewportPoint(x: number, y: number): [number, number];
|
|
26
|
+
convertToPdfPoint(x: number, y: number): [number, number];
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=coords.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coords.d.ts","sourceRoot":"","sources":["../../src/types/coords.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0BAA0B;AAC1B,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,2CAA2C;AAC3C,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,mBAAmB;AACnB,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC5B,sBAAsB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/D,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF 核心事件类型
|
|
3
|
+
* 参考 DxfViewer 的 "loaded" / "cleared" / "viewChanged" 等事件
|
|
4
|
+
*/
|
|
5
|
+
/** PDF 文件加载完成 */
|
|
6
|
+
export interface PdfLoadedEvent {
|
|
7
|
+
pageCount: number;
|
|
8
|
+
currentPage: number;
|
|
9
|
+
}
|
|
10
|
+
/** PDF 渲染完成 */
|
|
11
|
+
export interface PdfRenderCompleteEvent {
|
|
12
|
+
pageNum: number;
|
|
13
|
+
scale: number;
|
|
14
|
+
}
|
|
15
|
+
/** 缩放变化 */
|
|
16
|
+
export interface PdfScaleChangedEvent {
|
|
17
|
+
scale: number;
|
|
18
|
+
previousScale: number;
|
|
19
|
+
}
|
|
20
|
+
/** 错误发生 */
|
|
21
|
+
export interface PdfErrorEvent {
|
|
22
|
+
message: string;
|
|
23
|
+
}
|
|
24
|
+
/** 页面切换 */
|
|
25
|
+
export interface PdfPageChangedEvent {
|
|
26
|
+
pageNum: number;
|
|
27
|
+
previousPageNum: number;
|
|
28
|
+
}
|
|
29
|
+
/** 核心事件映射表 */
|
|
30
|
+
export type PdfCoreEventMap = {
|
|
31
|
+
/** PDF 文件加载完成(含首帧渲染) */
|
|
32
|
+
loaded: (payload: PdfLoadedEvent) => void;
|
|
33
|
+
/** 页面渲染完成(每次缩放/翻页后) */
|
|
34
|
+
render_complete: (payload: PdfRenderCompleteEvent) => void;
|
|
35
|
+
/** 缩放比例变化 */
|
|
36
|
+
scale_changed: (payload: PdfScaleChangedEvent) => void;
|
|
37
|
+
/** 错误发生 */
|
|
38
|
+
error_occurred: (payload: PdfErrorEvent) => void;
|
|
39
|
+
/** 页面切换 */
|
|
40
|
+
page_changed: (payload: PdfPageChangedEvent) => void;
|
|
41
|
+
/** 清空/重置 */
|
|
42
|
+
cleared: () => void;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/types/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,iBAAiB;AACjB,MAAM,WAAW,cAAc;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,eAAe;AACf,MAAM,WAAW,sBAAsB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACd;AAED,WAAW;AACX,MAAM,WAAW,oBAAoB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;CACtB;AAED,WAAW;AACX,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,WAAW;AACX,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;CACxB;AAED,cAAc;AACd,MAAM,MAAM,eAAe,GAAG;IAC7B,wBAAwB;IACxB,MAAM,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,uBAAuB;IACvB,eAAe,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC3D,aAAa;IACb,aAAa,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACvD,WAAW;IACX,cAAc,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IACjD,WAAW;IACX,YAAY,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACrD,YAAY;IACZ,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 集中类型定义 — 统一的类型入口
|
|
3
|
+
*
|
|
4
|
+
* 所有模块的类型均从此处导出,不再散落各地。
|
|
5
|
+
*
|
|
6
|
+
* 使用方式:
|
|
7
|
+
* import type { AnnotationItem, PointLike } from "../types";
|
|
8
|
+
* import type { ScreenPoint, PagePoint } from "../types";
|
|
9
|
+
* import type { PdfViewerProps, PdfViewerEmits } from "../types";
|
|
10
|
+
* import type { ToolMode, MeasureResult, ITool } from "../types";
|
|
11
|
+
*/
|
|
12
|
+
export type { AnnotationKind, AnnotationBase, MeasureAnnotation, ShapeAnnotation, AnnotationItem, PointLike } from "./annotations";
|
|
13
|
+
export type { ScreenPoint, PagePoint, PdfLibPoint, PageSizePt, ViewportLike } from "./coords";
|
|
14
|
+
export type { PdfViewerProps, PdfViewerEmits } from "./components";
|
|
15
|
+
export type { ToolMode, MeasureSubType, ToolState, Point2D, MeasureResult, UnitType, PrecisionType, ScaleCalibration, ToolEventMap, MeasureStartEvent, MeasureCreatedEvent, MeasureCancelEvent, ToolActiveEvent, ToolModeChangedEvent, ITool } from "./tools";
|
|
16
|
+
export { DEFAULT_TOOL_STATE } from "./tools";
|
|
17
|
+
export type { PdfCoreEventMap, PdfLoadedEvent, PdfRenderCompleteEvent, PdfScaleChangedEvent, PdfErrorEvent, PdfPageChangedEvent } from "./core";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGnI,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG9F,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,eAAe,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9P,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG7C,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 工具系统公共类型定义
|
|
3
|
+
* 从 src/tools/types.ts 集中迁移至 src/types/
|
|
4
|
+
* 参考 dxf-viewer/src/Toolbar 架构
|
|
5
|
+
*/
|
|
6
|
+
/** 当前激活的工具标识 */
|
|
7
|
+
export type ToolMode = "measure" | "rectangle" | "circle" | "polygon" | "freehand" | "line" | "none";
|
|
8
|
+
/** 测量子类型 */
|
|
9
|
+
export type MeasureSubType = "distance" | "angle" | "area" | "continuousDistance" | "rectArea" | "areaCurve";
|
|
10
|
+
export interface ToolState {
|
|
11
|
+
/** 当前激活模式 */
|
|
12
|
+
mode: ToolMode;
|
|
13
|
+
/** 激活的测量子类型 */
|
|
14
|
+
measureSubType: MeasureSubType;
|
|
15
|
+
}
|
|
16
|
+
export declare const DEFAULT_TOOL_STATE: ToolState;
|
|
17
|
+
export interface Point2D {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
}
|
|
21
|
+
export interface MeasureResult {
|
|
22
|
+
/** 唯一 ID */
|
|
23
|
+
id: string;
|
|
24
|
+
/** 测量类型 */
|
|
25
|
+
type: MeasureSubType;
|
|
26
|
+
/** 测量点集 */
|
|
27
|
+
points: Point2D[];
|
|
28
|
+
/** 计算值 */
|
|
29
|
+
value: number;
|
|
30
|
+
/** 单位 */
|
|
31
|
+
unit: string;
|
|
32
|
+
/** 显示标签 */
|
|
33
|
+
label: string;
|
|
34
|
+
/** 所属图层 */
|
|
35
|
+
layer?: string;
|
|
36
|
+
/** 创建时间 */
|
|
37
|
+
createdAt: number;
|
|
38
|
+
}
|
|
39
|
+
export type UnitType = "none" | "mm" | "cm" | "m" | "km";
|
|
40
|
+
export type PrecisionType = 1 | 0.1 | 0.01 | 0.001 | 0.0001;
|
|
41
|
+
export interface ScaleCalibration {
|
|
42
|
+
scale: number;
|
|
43
|
+
unit: UnitType;
|
|
44
|
+
precision: PrecisionType;
|
|
45
|
+
}
|
|
46
|
+
/** 测量开始事件(参数为空) */
|
|
47
|
+
export interface MeasureStartEvent {
|
|
48
|
+
type: MeasureSubType;
|
|
49
|
+
}
|
|
50
|
+
/** 测量创建完成事件 */
|
|
51
|
+
export interface MeasureCreatedEvent {
|
|
52
|
+
id: string;
|
|
53
|
+
type: MeasureSubType;
|
|
54
|
+
points: Point2D[];
|
|
55
|
+
value: number;
|
|
56
|
+
unit: string;
|
|
57
|
+
label: string;
|
|
58
|
+
result: MeasureResult;
|
|
59
|
+
}
|
|
60
|
+
/** 测量取消事件 */
|
|
61
|
+
export interface MeasureCancelEvent {
|
|
62
|
+
type: MeasureSubType;
|
|
63
|
+
}
|
|
64
|
+
/** 工具激活状态变化事件 */
|
|
65
|
+
export interface ToolActiveEvent {
|
|
66
|
+
active: boolean;
|
|
67
|
+
toolName: ToolMode;
|
|
68
|
+
}
|
|
69
|
+
/** 工具模式切换事件 */
|
|
70
|
+
export interface ToolModeChangedEvent {
|
|
71
|
+
previous: ToolMode;
|
|
72
|
+
current: ToolMode;
|
|
73
|
+
subType?: MeasureSubType;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 工具事件映射表 — 供 EventTrigger 泛型使用
|
|
77
|
+
*/
|
|
78
|
+
export type ToolEventMap = {
|
|
79
|
+
measure_start: (payload: MeasureStartEvent) => void;
|
|
80
|
+
measure_created: (payload: MeasureCreatedEvent) => void;
|
|
81
|
+
measure_cancel: (payload: MeasureCancelEvent) => void;
|
|
82
|
+
measure_preview: (payload: {
|
|
83
|
+
type: MeasureSubType;
|
|
84
|
+
previewPoint?: Point2D;
|
|
85
|
+
}) => void;
|
|
86
|
+
tool_active: (payload: ToolActiveEvent) => void;
|
|
87
|
+
tool_mode_changed: (payload: ToolModeChangedEvent) => void;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* 所有工具的基类接口
|
|
91
|
+
* 参考 dxf-viewer 的 Controller 模式
|
|
92
|
+
*/
|
|
93
|
+
export interface ITool {
|
|
94
|
+
/** 工具名称 */
|
|
95
|
+
readonly TOOLNAME: ToolMode;
|
|
96
|
+
/** 当前子类型 */
|
|
97
|
+
readonly currentType: string;
|
|
98
|
+
/** 获取工具是否激活 */
|
|
99
|
+
getActive(): boolean;
|
|
100
|
+
/** 设置工具激活状态 */
|
|
101
|
+
setActive(active: boolean): void;
|
|
102
|
+
/** 鼠标按下 */
|
|
103
|
+
onPointerDown(event: PointerEvent): void;
|
|
104
|
+
/** 鼠标移动 */
|
|
105
|
+
onPointerMove(event: PointerEvent): void;
|
|
106
|
+
/** 鼠标抬起 */
|
|
107
|
+
onPointerUp(event: PointerEvent): void;
|
|
108
|
+
/** 中断当前操作 */
|
|
109
|
+
interrupt(): void;
|
|
110
|
+
/** 销毁清理 */
|
|
111
|
+
destroy(): void;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,gBAAgB;AAChB,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SA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