类型定义汇总
大约 3 分钟
类型定义汇总
本页汇总 vjmapext 所有公开导出的类型和接口定义。
核心类型
MapCadLayerMode
type MapCadLayerMode = 'edit' | 'browse';MapCadLayerOptions
interface MapCadLayerOptions {
locale?: Locale; // 语言,默认 'zh'
defaultColor?: number; // 默认颜色,默认 0x00ff00
nudgePixels?: number; // 键盘微移像素,默认 1
nudgeRotateDeg?: number; // 键盘微旋角度,默认 1
nudgeScaleFactor?: number; // 键盘微缩比例,默认 1.02
drawingDefaults?: Partial<DrawingDefaultsData>;
mode?: MapCadLayerMode; // 初始模式,默认 'edit'
modeToggleShortcut?: string | null; // 模式切换快捷键,默认 'ctrl+shift+e'
shortcuts?: Partial<ShortcutMap>; // 自定义快捷键
}Locale
type Locale = 'zh' | 'en';MessageKey
翻译键的字符串字面量联合类型,用于 t() 函数的类型安全。
DrawingDefaultsData
interface DrawingDefaultsData {
color: number;
lineType: string;
lineWidth: number;
ltScale: number;
layer: string;
textHeight: number;
}几何类型
Point2D
class Point2D {
x: number;
y: number;
constructor(x: number, y: number);
}Point2DLike
type Point2DLike = Point2D | [number, number] | { x: number; y: number };BBox
type BBox = [minX: number, minY: number, maxX: number, maxY: number];实体类型
GripPointDef
interface GripPointDef {
point: Point2D;
type: GripType;
onMove(newPoint: Point2D): void;
}GripType / GripShape
type GripType = 'vertex' | 'edge' | 'center' | 'quadrant' | 'control' | 'custom';
type GripShape = 'square' | 'circle' | 'diamond' | 'triangle';PropertyInfo
实体属性元数据,供属性面板使用。
VertexListData
顶点列表数据结构,用于多段线等实体的顶点管理。
CustomPropertyType / CustomPropertyValue
type CustomPropertyType = 'string' | 'number' | 'boolean';
type CustomPropertyValue = string | number | boolean;HatchLoop
interface HatchLoop {
points: Point2DLike[];
}标注类型
OwnerRef
标注关联引用,将标注的控制点绑定到源实体。
interface OwnerRef {
entityId: string;
pointType: string;
}ArrowStyleType
type ArrowStyleType = 'OPEN' | 'CLOSED' | 'FILLED' | 'DOT' | 'NONE'
| 'TICK' | 'INTEGRAL' | 'ARCHITECTURAL' | string;TextAlignment / MTextAttachment
type TextAlignment = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
// 1=Left, 2=Center, 3=Right, 4=MidLeft, 5=MidCenter, 6=MidRight,
// 7=TopLeft, 8=TopCenter, 9=TopRight
type MTextAttachment = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;命令类型
CommandContext
interface CommandContext {
store: EntityStore;
inputManager: InputManager;
eventBus: EventBus;
coordMapper: CoordMapper;
renderPipeline: RenderPipeline;
previewManager: PreviewManager;
gripManager: GripManager;
drawingDefaults: DrawingDefaults;
undoManager: UndoManager;
blocks: Blocks;
map: any;
dimReactorManager: DimReactorManager;
}CommandClass
interface CommandClass {
main(ctx: CommandContext, opts?: any): Promise<void>;
}EntityTypeDefinition
interface EntityTypeDefinition {
type: string;
entityClass: typeof EntityBase;
}GripProvider
interface GripProvider {
getGrips(entity: EntityBase): GripPointDef[];
}输入类型
InputResult
interface InputResult {
status: InputStatusEnum;
point?: Point2D;
value?: number;
keyword?: string;
entities?: EntityBase[];
}InputStatusEnum
enum InputStatusEnum {
OK = 0,
Cancel = 1,
Keyword = 2,
}输入选项类型
interface PointInputOptions {
prompt?: string;
keywords?: string[];
basePoint?: Point2DLike;
rubberBand?: boolean;
}
interface SelectionInputOptions {
prompt?: string;
singleSelect?: boolean;
filter?(entity: EntityBase): boolean;
}
interface RealInputOptions {
prompt?: string;
defaultValue?: number;
min?: number;
max?: number;
}
interface IntegerInputOptions {
prompt?: string;
defaultValue?: number;
min?: number;
max?: number;
}
interface KeywordInputOptions {
prompt?: string;
keywords: string[];
defaultKeyword?: string;
}
interface StringInputOptions {
prompt?: string;
defaultValue?: string;
}
interface EntityInputOptions {
prompt?: string;
filter?(entity: EntityBase): boolean;
}ShortcutMap
快捷键映射对象,键为操作名,值为快捷键字符串。
序列化类型
SerializedDocument
interface SerializedDocument {
version: number;
entities: SerializedEntity[];
blocks?: any;
drawingDefaults?: DrawingDefaultsData;
}捕捉类型
SnapPoint
interface SnapPoint {
point: Point2D;
type: SnapType;
}SnapType
type SnapType = 'endpoint' | 'midpoint' | 'center' | 'quadrant'
| 'intersection' | 'perpendicular' | 'tangent' | 'nearest' | 'node';线型类型
interface LinetypeDefinition {
name: string;
description: string;
elements: (SimpleLinetypeElement | ShapeLinetypeElement)[];
}
interface SimpleLinetypeElement {
type: LinetypeElementType.Simple;
length: number;
}
interface ShapeLinetypeElement {
type: LinetypeElementType.Shape;
shapeName: string;
shapeScale: number;
shapeRotation: number;
rotationMode: RotationMode;
}
enum LinetypeElementType { Simple, Shape }
enum RotationMode { Absolute, Relative }动画类型
type AnimationCallback = (deltaTime: number) => void;
interface AnimationItemOptions { maxFps?: number; }
type EasingFunction = (t: number) => number;
interface TweenOptions {
from: number;
to: number;
duration: number;
easing?: EasingFunction;
onUpdate(value: number): void;
onComplete?(): void;
}
interface PathAnimatorOptions {
entity: EntityBase;
path: Point2D[];
duration: number;
loop?: boolean;
easing?: EasingFunction;
onUpdate?(progress: number): void;
onComplete?(): void;
}
interface TrailEffectOptions {
entity: EntityBase;
maxPoints?: number;
fadeColor?: number;
trailWidth?: number;
}
interface SpringOptions {
stiffness?: number;
damping?: number;
mass?: number;
onUpdate(value: number): void;
onComplete?(): void;
}
interface Keyframe {
time: number;
value: number;
easing?: EasingFunction;
}
interface KeyframeOptions {
keyframes: Keyframe[];
duration: number;
loop?: boolean;
onUpdate(value: number): void;
}
interface LineRevealOptions {
entity: EntityBase;
duration: number;
easing?: EasingFunction;
}
interface BlinkEffectOptions {
entity: EntityBase;
onColor: number;
offColor: number;
interval: number;
mode?: BlinkMode;
}
type BlinkMode = 'toggle' | 'breath';UI 类型
interface ToolbarManagerOptions {
theme?: 'light' | 'dark';
showProperty?: boolean;
showCommandInput?: boolean;
showToolbar?: boolean;
toolbarOptions?: ToolbarOptions;
}
interface ToolbarOptions {
groups?: ToolbarGroup[];
position?: string;
orientation?: string;
}
interface ToolbarGroup {
name: string;
items: ToolbarItem[];
}
interface ToolbarItem {
name: string;
icon?: string;
command?: string;
onClick?(): void;
tooltip?: string;
}
interface PropertyPanelOptions {
// 属性面板配置
}
interface CommandInputOptions {
// 命令行配置
}SVG 类型
interface SvgParseOptions {
scale?: number;
basePoint?: Point2DLike;
flipY?: boolean;
strokeWidth?: number;
}
interface SvgParseResult {
entities: EntityBase[];
bounds: BBox;
}填充图案类型
interface PatternDefinition {
name: string;
lines: PatternLine[];
}
interface PatternLine {
angle: number;
baseX: number;
baseY: number;
offsetX: number;
offsetY: number;
dashes: number[];
}插件类型
interface Plugin {
manifest: PluginManifest;
install(ctx: PluginContext): void | Promise<void>;
activate?(): void;
deactivate?(): void;
}
interface PluginManifest {
name: string;
version: string;
description?: string;
}
interface PluginContext {
commandRegistry: CommandRegistry;
entityRegistry: EntityRegistry;
eventBus: EventBus;
store: EntityStore;
on(event: string, handler: Function): void;
off(event: string, handler: Function): void;
}