yanchengPowerSupply/node_modules/mxdraw/dist/lib/MxModule/MxDbEntity/index.d.ts

377 lines
10 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import McGiWorldDraw from '../McGiWorldDraw';
import MxDrawObject from '../MxDrawObject';
import MxType, { MxColorType, UnstableColor } from '../MxType';
export declare enum DataType {
Default = 0,
Color = 1,
Vector2 = 2,
Vector3 = 3,
Vector4 = 4,
Matrix3 = 5,
Matrix4 = 6
}
export declare const MXDBDATATYPE = "datatype";
/**
* MxDbEntity 用于构建一个自定义对象的抽象类(该类无法实例化 请通过继承的方式对其抽象方法进行实现)
* @description MxDbEntity 属于 abstract class(抽象类) 主要用途是通过继承这个类实现一个用于动态绘制的图形对象
* 继承实现这个类必须实现的抽象方法:(方法名称前有'Abstract'标签就是必须实现的方法)
* @example ```typescript
* import THREE from "three"
* import { McGiWorldDraw, MxDbEntity } from "mxdraw"
* class MxLineEntity extends MxDbEntity {
* constructor() {
* super(); // 在派生类的构造函数中必须调用 super()
* }
* private pt1: THREE.Vector3 = new THREE.Vector3();
* private pt2: THREE.Vector3 = new THREE.Vector3();
* worldDraw(pWorldDraw: McGiWorldDraw) {
* pWorldDraw.drawLine(this.pt1,this.pt2);
* }
* ...
* }
* ```
*/
export default abstract class MxDbEntity {
constructor();
/** 该类注册的cmd命令名称 */
static cmd: string;
/** 该类注册的cmd命令绘制函数 */
static draw: Function;
/** 该类是否已注册 */
static isRegister: boolean;
/** 注册该类的cmd命令和初始化 (引入该类时自动注册 当该类的isRegister为ture时表示已经注册) */
static register(): void;
/** 使用该类的cmd命令 执行默认的绘制功能 */
static use(): Promise<void>;
/**
* 颜色值
* */
color: UnstableColor;
/**
* 显示顺序
* */
renderOrder: number;
/**
* 设置透明度 0 ~ 1,1表示完全不透明0表示全透明.
* */
opacity: number;
/**
* 该矩形对象是否可见
* */
visible: boolean;
/**
* 用户自定义数据.
* */
userData: {
[key: string]: any;
};
sGuid: string;
dLineWidth: number;
lineWidthByPixels: boolean;
dDashArray: number;
dDashRatio: number;
layer: string;
private _event;
abstract getTypeName(): string;
initGuid(guid: string): void;
/**
* 自定义对象的绘制函数。在方法中定义如何绘制图形
* @param pWorldDraw 绘制对象{@link McGiWorldDraw }
* @returns void
*/
abstract worldDraw(pWorldDraw: McGiWorldDraw): void;
/**
* 返回自定义对象的夹点.
* @param
* @returns Array<THREE.Vector3>
*/
abstract getGripPoints(): Array<THREE.Vector3>;
/**
* 移动自定义对象的夹点.
* @param
* @returns boolean
*/
abstract moveGripPointsAt(index: number, offset: THREE.Vector3): boolean;
/**
* 自定义对象数据输入,辅助函数.
* @param obj 数据对象
* @param aryProp 属性名称列表
* @param hooks.getVal 交互数据输入钩子函数 return null | undefined 默认深拷贝 ; return Value 返回数据
* @param hooks.getCacheVal 归档数据构子函数 return null | undefined 默认深拷贝 ; return Value 返回数据
* @returns boolean
* @example
* ``` typescript
* class MxLine extends MxDbEntity {
* dwgIn(obj) {
* // 必须调用 同步自定义数据对象输入
* this.dwgInHelp(obj,["xxx"])
* }
* }
* ```
*/
protected dwgInHelp<T extends (string | {
key: string;
default: any;
})[]>(obj: any, aryProp: T, hooks?: {
getVal?: (v: any) => any;
getCacheVal?: (v: any) => any;
}): boolean;
/**
* 自定义对象数据输出 辅助函数.
* @param
* @returns object
* @example
* ``` typescript
* class MxLine extends MxDbEntity {
* dwgOut(obj) {
* // 必须调用 同步自定义数据对象输出
* this.dwgOutHelp(obj,["xxx"])
* }
* }
* ```
*/
protected dwgOutHelp(obj: any, aryProp: (string | {
key: string;
default: any;
})[]): any;
protected callEvent(sEventName: string, param?: any): any;
/**
* 新创建一个自定义对象 (默认调用该对象的构造函数来创建新的对象)
* @param { T } options
* @returns MxDbEntity
*/
create(options?: {}): any;
/**
* 自定义对象数据输入,必须要实现该函数
* @param
* @returns boolean
* @example
* ``` typescript
* class MxLine extends MxDbEntity {
* dwgIn(obj) {
* // 必须调用 同步自定义数据对象输入
* this.onDwgIn(obj)
* }
* }
* ```
*/
abstract dwgIn(obj: {
type: MxType.MxCloneType;
[x: string]: any;
}): boolean;
/**
* 自定义对象数据输出,必须要实现该函数
* @param
* @returns object
* @example
* ``` typescript
* class MxLine extends MxDbEntity {
* dwgOut(obj) {
* // 必须调用 同步自定义数据对象输出
* this.onDwgOut(obj)
* }
* }
* ```
*/
abstract dwgOut(obj: {
type: MxType.MxCloneType;
[x: string]: any;
}): object;
/**
* 自定义实体的矩阵 坐标变换 (需要重写该方法实现如果通过矩阵对自定义实体进行操作 默认不会进行任何操作)
* @param _mat THREE.Matrix4 变化矩阵
* @returns void
*/
transformBy(_mat: THREE.Matrix4): void;
/**
* 返回对象最小外包.
* @param
* @returns void
*/
getGeomExtents(): THREE.Box3 | null;
/**
* 对一个点到这个对象的最近点 。
* iOperationType == 0正常操作求值最近点.
* iOperationType == 1点选择操作求值最近点.
* @param
* @returns void
*/
getClosestPointTo(pt: THREE.Vector3, iOperationType?: number): THREE.Vector3 | null;
private getImp;
/**
* 更新显示
* @param 为true 重绘时立即更新显示,默认值false
* @returns boolean
*/
setNeedUpdateDisplay(isImmediate?: boolean): boolean;
/**
* 返回对象所在的控件对象。
* @returns {@link MxDrawObject}
*/
getMxObject(): MxDrawObject | null;
/**
* 视区显示比较发生成变化,继承类可以向应该事件,更新显示大小。
* @returns boolean
*/
protected onViewChange(): boolean;
/**
* 得到对象的id.
* @returns number
*/
objectId(): number;
/**
* 删除对象
* @returns boolean
*/
erase(): boolean;
/**
* 设置图层
* @returns boolean
*/
setLayer(layer: string): void;
/**
* 得到图层
* @returns boolean
*/
getLayer(): string;
/**
* 设置颜色
* @param color 颜色值
* @returns boolean
*/
setColor(color: MxColorType): this;
/**
* 得到颜色
* @returns boolean
*/
getColor(): MxColorType;
/**
* 复制克隆对象。
* @param type {@link MxType.MxCloneType} 传入参数区分是正常拷贝还是动态拷贝
* @returns MxDbEntity
*/
clone(type?: number): any;
/**
* 自定义对象内部数据输入同步重写实现dwgIn抽象方法时 必须在实现中调用 this.onDwgIn(obj)
* @param obj dwgIn抽象方法的回调数据
*/
protected onDwgIn(obj: any): void;
/**
* 自定义对象内部数据输出同步重写实现dwgIn抽象方法 必须在实现中调用 this.onDwgIn(obj)
* @param obj dwgOut抽象方法的回调数据
*/
protected onDwgOut(obj: any): void;
/**
* 初始自定义对象的类型信息.(如果需要实现该图形对象的保存数据和恢复数据的功能, 需要在项目中初始化一次该图形对象的类)
* @returns
*/
rxInit(): void;
/**
* 设置显示顺序 (通过显示顺序控制图层)
* @param renderOrder 显示顺序
*/
setRenderOrder(renderOrder: number): void;
/**
* 得到显示顺序
* @returns number
*/
getRenderOrder(): number;
/**
* 设置线宽是否随像素
* @returns number
*/
setLineWidthByPixels(isPixels: boolean): this;
/**
* 线宽是否随像素
* @returns number
*/
getLineWidthByPixels(): boolean;
/**
* 设置线宽
* @returns number
*/
setLineWidth(dLineWidth: number): this;
/**
* 得到线宽
* @returns number
*/
getLineWidth(): number;
/**
* 返回曲线长度
* @returns number
*/
getGetLength(): number;
/**
* 设置虚线 +实线的长度.
* dDashRatio确定虚线与实线的比率.
* @returns number
*/
setDashLen(dashLen: number): this;
/**
* 设置虚线,与实线的比率
* @returns number
*/
setDashRatio(dDashRatio: number): this;
/**
* 设置实线虚线总段数 = 1 / dashArray
* @returns number
*/
setDashArray(dDashArray: number): this;
/**
* 设置虚线数据
* @returns number
*/
setDash(dDashArray: number, dDashRatio: number): this;
/**
* 得到虚线数据
* @returns number
*/
getDash(): any;
/**
* 设置虚线显示。并初始化一个默认值。
* @returns number
*/
setDashLineDisplay(isDashLine: boolean): this;
/**
* 是否虚线显示
* @returns number
*/
isDashLineDisplay(): boolean;
/**
* 返回唯一标识guid
* @returns string
*/
guid(): string;
/**
* 对象结束开始编辑
* @returns string
*/
onEndGripEidt(): void;
/**
* 对象开始开始编辑
* @returns string
*/
onStartGripEidt(): any;
/**
* 添加一个事件处理
* @returns void
*/
addEvent(name: string, fun: object): void;
/**
* 删除一个事件处理
* @returns void
*/
removeEvent(name: string): void;
/**
* 把一个对象变成一个json字体串.
* @returns void
*/
toJsonString(type?: MxType.MxCloneType): string;
/**
* 从一个josn字符串加载数据.
* @returns void
*/
fromJsonString(str: string): boolean;
}