Skip to content

mxcad_2d API 文档 / 2d / MxCADUiPrPointTransform

Class: MxCADUiPrPointTransform ​

2d.MxCADUiPrPointTransform

MxCADUiPrPointTransform 是在 MxCADUiPrPoint 基础上增加坐标系变换能力的交互取点类。

Description

该类适用于在特定坐标系中进行交互取点,例如局部坐标系、工作坐标系或自定义视图坐标系。 它可以在用户选点时自动应用矩阵转换,便于在变换后的空间中完成交互输入。 使用方法:

  1. new MxCADUiPrPointTransform(mat) 创建带坐标变换的取点器;
  2. 传入用于映射的 McGeMatrix3d;
  3. 调用 go() 获取用户点击点;
  4. 取回的点会按矩阵约定转换到目标坐标系中。

Example

ts
   import { MxCpp, McGePoint3d, MxCADUiPrPointTransform, McGeMatrix3d, McGeVector3d, McDbPolyline } from "mxcad";

   async function Mx_Test_Rect() {
   const mxcad = MxCpp.getCurrentMxCAD();
   let mat = new McGeMatrix3d;
   mat.setToRotation(-mxcad.mxdraw.getViewAngle(), McGeVector3d.kZAxis, McGePoint3d.kOrigin);

   const getPoint = new MxCADUiPrPointTransform(mat);
   getPoint.clearLastInputPoint();
   getPoint.setDisableDynInput(true);
   getPoint.setMessage("请选择第一个点");
   const pt1 = await getPoint.go();
   if (!pt1) return;

   const getNextPt = new MxCADUiPrPointTransform(mat);
   getNextPt.setMessage("请选择第二个点");
   getNextPt.setUserDraw((pt2, pWorldDraw) => {
       let pl = new McDbPolyline();
       pl.addVertexAt(pt1);
       pl.addVertexAt(new McGePoint3d(pt1.x, pt2.y, pt1.z));
       pl.addVertexAt(pt2);
       pl.addVertexAt(new McGePoint3d(pt2.x, pt1.y, pt1.z));
       pl.isClosed = true;
       pWorldDraw.drawMcDbEntity(pl);
   });

   if (!await getNextPt.go()) return;

   getNextPt.drawReserve();
   }

Hierarchy ​

Table of contents ​

Constructors ​

Properties ​

Methods ​

Constructors ​

constructor ​

• new MxCADUiPrPointTransform(mat)

Parameters ​

NameType
matMcGeMatrix3d

Overrides ​

MxCADUiPrPoint.constructor

Properties ​

mat ​

• mat: McGeMatrix3d = McGeMatrix3d.kIdentity


mat_three ​

• mat_three: Matrix4


rmat ​

• rmat: McGeMatrix3d = McGeMatrix3d.kIdentity


rmat_three ​

• rmat_three: Matrix4

Methods ​

abort ​

▸ abort(cause?): void

停止当前动态拖动

Parameters ​

NameTypeDefault value
causeDetailedResultDetailedResult.kCodeAbort

Returns ​

void

void

Inherited from ​

MxCADUiPrPoint.abort


basePt ​

▸ basePt(retcad_val?): McGePoint3d

得到动态拖动的基点

Parameters ​

NameTypeDefault value
retcad_valbooleanfalse

Returns ​

McGePoint3d

基点 McGePoint3d

Overrides ​

MxCADUiPrPoint.basePt


clearLastInputPoint ​

▸ clearLastInputPoint(): void

清除上一次的输入点数据。

Returns ​

void

Inherited from ​

MxCADUiPrPoint.clearLastInputPoint


disableAllTrace ​

▸ disableAllTrace(isDisable?): void

禁用所有跟踪

Parameters ​

NameTypeDefault valueDescription
isDisablebooleantrue是否禁用

Returns ​

void

Inherited from ​

MxCADUiPrPoint.disableAllTrace


drawReserve ​

▸ drawReserve(callAddEntity?): void

把动态绘制的对象,保留到图上。

Parameters ​

NameTypeDescription
callAddEntity?(ent: Object3D) => void回调参数ent 类型:THREE.THREE.Object3D

Returns ​

void

Example

ts
//以 MxCADUiPrPoint 类示例
 import { MxCADUiPrPoint } from 'mxcad';

 async function test(){
   const getPoint = new MxCADUiPrPoint();
   const basePt = new McGePoint3d(0, 0, 0);
   getPoint.setBasePt(basePt);
   getPoint.setUserDraw((pt,pw)=>{
   const line = new McDbLine(basePt, pt);
   pw.drawMcDbEntity(line)
   })
   const val = await getPoint.go();
   if (!val) return;
   getPoint.drawReserve()
 }

Inherited from ​

MxCADUiPrPoint.drawReserve


getCursorType ​

▸ getCursorType(): MxCursorType

返回光标类型

Returns ​

MxCursorType

Inherited from ​

MxCADUiPrPoint.getCursorType


getDetailedResult ​

▸ getDetailedResult(): DetailedResult

返回交互操作退出的详细原因

Returns ​

DetailedResult

当前交互操作返回值类型

Example

ts
//以 MxCADUiPrDist 类示例
  import { MxCADUiPrDist } from 'mxcad';
  import { DetailedResult } from "mxdraw";

  async function test(){
    const getDist = new MxCADUiPrDist();
    const val = await getDist.go();
    if (!val) return;
    if (getDist.getDetailedResult() === DetailedResult.kCoordIn) {
        console.log('提示输入', val)
    }
  }

Inherited from ​

MxCADUiPrPoint.getDetailedResult


getDocValue ​

▸ getDocValue(): McGePoint3d

得到文档坐标.

Returns ​

McGePoint3d

点对象 MdGePoint3d

Example

ts
import { MxCADUiPrPoint } from "mxcad"

const getPoint = new MxCADUiPrPoint();
await getPoint.go();
const pt = getPoint.getDocValue();
console.log(pt)

Inherited from ​

MxCADUiPrPoint.getDocValue


getDynamicInputType ​

▸ getDynamicInputType(): DynamicInputType

返回动态输入类型

Returns ​

DynamicInputType

动态输入显示类型

Inherited from ​

MxCADUiPrPoint.getDynamicInputType


getInputToucheType ​

▸ getInputToucheType(): number

返回需要的Touche输入类型

Returns ​

number

Touche输入类型

Inherited from ​

MxCADUiPrPoint.getInputToucheType


getLastInputPoint ​

▸ getLastInputPoint(): undefined | McGePoint3d

返回上一次的输入点。

Returns ​

undefined | McGePoint3d

选择的关键字

Inherited from ​

MxCADUiPrPoint.getLastInputPoint


getResultPointOsnapMode ​

▸ getResultPointOsnapMode(): AcquirePointOsnapMode

返回交互取点操作得到的点的捕捉类型

Returns ​

AcquirePointOsnapMode

Inherited from ​

MxCADUiPrPoint.getResultPointOsnapMode


getResultPointType ​

▸ getResultPointType(): AcquirePointType

返回交互取点操作得到的点类型

Returns ​

AcquirePointType

Inherited from ​

MxCADUiPrPoint.getResultPointType


getStatus ​

▸ getStatus(): MrxDbgUiPrBaseReturn

获取操作状态

Returns ​

MrxDbgUiPrBaseReturn

操作状态值

Example

ts
//以 MxCADUiPrDist 类示例
 import { MxCADUiPrDist } from 'mxcad';
 import { MrxDbgUiPrBaseReturn } from "mxdraw";

 const getDist = new MxCADUiPrDist();
 const val = await getDist.go();
 if (!val) return;
 if(getPoint.getStatus() === MrxDbgUiPrBaseReturn.kNone) {
   // 空输入
 }

Inherited from ​

MxCADUiPrPoint.getStatus


go ​

▸ go(): Promise<null | McGePoint3d>

运行go方法, 将返回用户交互的Promise任务

Returns ​

Promise<null | McGePoint3d>

返回一个promise对象,包含了用户点击页面得到的坐标点

Overrides ​

MxCADUiPrPoint.go


isDisableDynInput ​

▸ isDisableDynInput(): boolean

是否禁用动态输入框

Returns ​

boolean

Inherited from ​

MxCADUiPrPoint.isDisableDynInput


isDisableDynamicTrace ​

▸ isDisableDynamicTrace(): boolean

是否禁用动态跟踪

Returns ​

boolean

Inherited from ​

MxCADUiPrPoint.isDisableDynamicTrace


isDisableGridTrace ​

▸ isDisableGridTrace(): boolean

是否禁用格网追踪

Returns ​

boolean

Inherited from ​

MxCADUiPrPoint.isDisableGridTrace


isDisableOrthoTrace ​

▸ isDisableOrthoTrace(): boolean

是否禁用正射追踪

Returns ​

boolean

Inherited from ​

MxCADUiPrPoint.isDisableOrthoTrace


isDisableOsnap ​

▸ isDisableOsnap(): boolean

是否禁用捕捉

Returns ​

boolean

Inherited from ​

MxCADUiPrPoint.isDisableOsnap


isDisablePolarAxisTrace ​

▸ isDisablePolarAxisTrace(): boolean

是否禁用极轴跟踪

Returns ​

boolean

Inherited from ​

MxCADUiPrPoint.isDisablePolarAxisTrace


isKeyWordPicked ​

▸ isKeyWordPicked(matchKeyWord): boolean

测试某一个关键字是否被用户选择

Parameters ​

NameTypeDescription
matchKeyWordstring要检测的关键字

Returns ​

boolean

true为真

Example

ts
  //以 MxCADUiPrPoint 类示例
  import { MxCADUiPrPoint } from 'mxcad';

 async function test(){
   const getPoint = new MxCADUiPrPoint();
   getPoint.setKeyWords("[选项1(A)/选项2(B)]");
   const pt = await getPoint.go();
   if(getPoint.isKeyWordPicked('A')){
       console.log('选项1')
   }else if(getPoint.isKeyWordPicked('B')){
       console.log('选项2')
   }
 }

Inherited from ​

MxCADUiPrPoint.isKeyWordPicked


isOffsetInputPostion ​

▸ isOffsetInputPostion(): boolean

输入点是否偏移显示/处理

Returns ​

boolean

Inherited from ​

MxCADUiPrPoint.isOffsetInputPostion


keyWordPicked ​

▸ keyWordPicked(): string

返回用户选择的关键字

Returns ​

string

选择的关键字

Example

ts
  //以 MxCADUiPrPoint 类示例
  import { MxCADUiPrPoint } from 'mxcad';

  async function test(){
   const getPoint = new MxCADUiPrPoint();
   getPoint.setKeyWords("[选项1(A)/选项2(B)]");
   const pt = await getPoint.go();
   const key = getPoint.keyWordPicked();
   console.log(key)
  }

Inherited from ​

MxCADUiPrPoint.keyWordPicked


keyWords ​

▸ keyWords(): string

返回关键字列表

Returns ​

string

关键词列表

Example

ts
//以 MxCADUiPrPoint 类示例,其他MxCADUiPr* 系列的类同理
  import { MxCADUiPrPoint } from 'mxcad'
  const getPoint = new MxCADUiPrPoint();
  getPoint.setKeyWords("[选项1(A)/选项2(B)]");
  const keyList = getPoint.keyWords();
  console.log("关键词列表", keyList)// 关键词列表 [选项1(A)/选项2(B)]

Inherited from ​

MxCADUiPrPoint.keyWords


message ​

▸ message(): string

提示字符串

Returns ​

string

提示消息

Inherited from ​

MxCADUiPrPoint.message


setBasePt ​

▸ setBasePt(basePt, cad_val?): void

设置动态拖动的基点

Parameters ​

NameTypeDefault valueDescription
basePtMcGePoint3dundefined基点 McGePoint3d
cad_valbooleanfalse-

Returns ​

void

Overrides ​

MxCADUiPrPoint.setBasePt


setCursorType ​

▸ setCursorType(type): void

设置光标类型

Parameters ​

NameTypeDescription
typeMxCursorType鼠标样式类型

Returns ​

void

Example

ts
//以 MxCADUiPrPoint 类示例
  import { MxCADUiPrPoint } from 'mxcad';
  import { MxCursorType } from "mxdraw";

  async function test(){
   const getPoint = new MxCADUiPrPoint()
   getPoint.setMessage("指定文字起点:")
   getPoint.setCursorType(MxCursorType.kCross);
   const pt = await getPoint.go();
  }

Inherited from ​

MxCADUiPrPoint.setCursorType


setDisableDynInput ​

▸ setDisableDynInput(isDisable): void

设置是否禁用动态输入框

Parameters ​

NameTypeDescription
isDisableboolean是否禁用

Returns ​

void

Inherited from ​

MxCADUiPrPoint.setDisableDynInput


setDisableDynamicTrace ​

▸ setDisableDynamicTrace(isDisable): void

设置是否禁用动态跟踪

Parameters ​

NameTypeDescription
isDisableboolean是否禁用

Returns ​

void

Inherited from ​

MxCADUiPrPoint.setDisableDynamicTrace


setDisableGridTrace ​

▸ setDisableGridTrace(isDisable): void

设置是否禁用格网追踪

Parameters ​

NameTypeDescription
isDisableboolean是否禁用

Returns ​

void

Inherited from ​

MxCADUiPrPoint.setDisableGridTrace


setDisableOrthoTrace ​

▸ setDisableOrthoTrace(isDisable): void

设置是否禁用正射追踪

Parameters ​

NameTypeDescription
isDisableboolean是否禁用

Returns ​

void

Inherited from ​

MxCADUiPrPoint.setDisableOrthoTrace


setDisableOsnap ​

▸ setDisableOsnap(isDisable): void

设置是否禁用捕捉

Parameters ​

NameTypeDescription
isDisableboolean是否禁用

Returns ​

void

Inherited from ​

MxCADUiPrPoint.setDisableOsnap


setDisablePolarAxisTrace ​

▸ setDisablePolarAxisTrace(isDisable): void

设置是否禁用极轴跟踪

Parameters ​

NameTypeDescription
isDisableboolean是否禁用

Returns ​

void

Inherited from ​

MxCADUiPrPoint.setDisablePolarAxisTrace


setDynamicInputType ​

▸ setDynamicInputType(type): void

设置动态输入类型

Parameters ​

NameTypeDescription
typeDynamicInputType动态输入显示类型

Returns ​

void

Example

ts
//以 MxCADUiPrPoint 类示例
  import { MxCADUiPrPoint } from 'mxcad';
  import { DynamicInputType } from "mxdraw";

  async function Mx_WindowZoom() {
    let getPoint = new MxCADUiPrPointTransform(MxInsidePublicFuns.getMxCADViewSpinMatrix(MxCpp.getCurrentMxCAD()));
    getPoint.disableAllTrace();
    getPoint.setMessage("\n点取缩放区域");
    getPoint.setDynamicInputType(DynamicInputType.kDynTip);
    let pt1 = await getPoint.go();
    if (pt1 == null) return;
    let mxcad = MxCpp.getCurrentMxCAD();
    getPoint.setUserDraw((p1, worldDraw) => {
        worldDraw.drawRect(MxCoordConvert.cad2doc1((pt1 as any)), MxCoordConvert.cad2doc1((p1 as any)));
    });

    let pt2 = await getPoint.go();
    if (pt2 == null) return;

    pt1.transformBy(getPoint.rmat);
    pt2.transformBy(getPoint.rmat);
    mxcad.zoomW(pt1, pt2);
 }

Inherited from ​

MxCADUiPrPoint.setDynamicInputType


setInputToucheType ​

▸ setInputToucheType(toucheType): void

设置需要的Touche输入类型,默认值是 MxType.InputToucheType.kGetBegan

Parameters ​

NameTypeDescription
toucheTypenumbertoucheType类型

Returns ​

void

Example

ts
//以 MxCADUiPrPoint 类示例
  import { MxCADUiPrPoint, MxCpp } from "mxcad";
  import { MxType } from "mxdraw";

   // 手机触模屏画直线
   async function Mx_Test_Touch_DrawLine() {
       const getPoint = new MxCADUiPrPoint();
       getPoint.setOffsetInputPostion(true);
       getPoint.setMessage("\n指定第一点:");
       // 接收 kGetBegan,触摸屏手指按下.
       getPoint.setInputToucheType(MxType.InputToucheType.kGetEnd);
       let pt1 = await getPoint.go();
       if (!pt1) return;
       getPoint.setMessage("\n指定第二点:");
       getPoint.setBasePt(pt1);

       console.log(getPoint.getResultPointOsnapMode());
       console.log(getPoint.getResultPointType());

       // 接收kGetEnd,触摸屏手指放开.
       getPoint.setInputToucheType(MxType.InputToucheType.kGetEnd);
       let pt2 = await getPoint.go();
       if (!pt2) return;
       let mxcad = MxCpp.getCurrentMxCAD();
       let ent = mxcad.drawLine(pt1.x, pt1.y, pt2.x, pt2.y).getMcDbEntity();
       if (ent) {
           ent.lineweight = 20;
       }
   }

Inherited from ​

MxCADUiPrPoint.setInputToucheType


setKeyWords ​

▸ setKeyWords(keyWordList): void

设置关键字列表

Parameters ​

NameTypeDescription
keyWordListstring关键词列表

Returns ​

void

void

Example

ts
  //以 MxCADUiPrPoint 类示例, 其他MxCADUiPr* 系列的类同理
  import { MxCADUiPrPoint } from 'mxcad'
  const getPoint = new MxCADUiPrPoint();
  getPoint.setKeyWords("[选项1(A)/选项2(B)]")

Inherited from ​

MxCADUiPrPoint.setKeyWords


setLastInputPoint ​

▸ setLastInputPoint(pt): void

设置上一次的输入点。

Parameters ​

NameTypeDescription
ptundefined | McGePoint3d点对象

Returns ​

void

Inherited from ​

MxCADUiPrPoint.setLastInputPoint


setMessage ​

▸ setMessage(message): void

设置提示字符串

Parameters ​

NameTypeDescription
messagestring提示消息

Returns ​

void

提示消息

Inherited from ​

MxCADUiPrPoint.setMessage


setOffsetInputPostion ​

▸ setOffsetInputPostion(isOffset): void

设置输入点遍移,常用于移动端取点

Parameters ​

NameType
isOffsetboolean

Returns ​

void

Example

ts
import { MxCADUiPrPoint } from "mxcad";
import { MxFun } from "mxdraw";

// 移动端 绘制临时标注圆
async function test(){
   const getPoint = new MxCADUiPrPoint();
   getPoint.setMessage("\n指定一点:");
   getPoint.setOffsetInputPostion(true);
   getPoint.clearLastInputPoint();
   let pt1 = (await getPoint.go());
   if (!pt1) return;

   let mxdraw = MxFun.getCurrentDraw();

   mxdraw.getTempMarkDraw().drawCircleMark(pt1.toVector3(), mxdraw.viewCoordLong2Cad(50), 0xFF0000);
   mxdraw.updateDisplay();
}

Inherited from ​

MxCADUiPrPoint.setOffsetInputPostion


setOsModeExParam ​

▸ setOsModeExParam(lVal): void

设置捕捉时的扩展捕捉参数。

Parameters ​

NameTypeDescription
lValOsModeExParam扩展对象捕捉参数

Returns ​

void

Example

ts
import { MxCADUiPrPoint } from "mxcad";
import { OsModeExParam } from "mxdraw";

    async function Mx_Test_Rect2() {
        const getPoint = new MxCADUiPrPoint();
        getPoint.clearLastInputPoint();
        getPoint.setMessage("请选择第一个点");
        const pt1 = await getPoint.go();
        if (!pt1) return;

        const getNextPt = new MxCADUiPrPoint();
        getNextPt.setMessage("请选择第二个角点");
        getNextPt.setOsModeExParam(OsModeExParam.kCircleTangentOsmode);
        getNextPt.setUserDraw((pt2, pWorldDraw) => {
            let pl = new McDbPolyline();
            pl.addVertexAt(pt1);
            pl.addVertexAt(new McGePoint3d(pt1.x, pt2.y, pt1.z));
            pl.addVertexAt(pt2);
            pl.addVertexAt(new McGePoint3d(pt2.x, pt1.y, pt1.z));
            pl.isClosed = true;
            pWorldDraw.drawMcDbEntity(pl);
        });

        if (!await getNextPt.go()) return;

        getNextPt.drawReserve();
    }

Inherited from ​

MxCADUiPrPoint.setOsModeExParam


setUseBasePt ​

▸ setUseBasePt(useIt): void

设置动态拖动的基点用于动态绘制。

Parameters ​

NameTypeDescription
useItboolean是否设置,setBasePt会自设置true.

Returns ​

void

void

Inherited from ​

MxCADUiPrPoint.setUseBasePt


setUserDraw ​

▸ setUserDraw(pDraw): void

设置动态绘制

Parameters ​

NameType
pDraw(currentPoint: McGePoint3d, pWorldDraw: McEdGetPointWorldDrawObject) => void

Returns ​

void

Overrides ​

MxCADUiPrPoint.setUserDraw


setUserInputControls ​

▸ setUserInputControls(contros): void

设置输入控制设置

Parameters ​

NameType
controsnumber

Returns ​

void

Example

ts
// 以 MxCADUiPrInt 类示例
  import { MxCADUiPrInt } from 'mxcad';
  import { UserInputControls } from "mxdraw"

  let getInt = new MxCADUiPrInt();
  getInt.setMessage("输入整数:");
  getInt.setUserInputControls(UserInputControls.kNoZeroResponseAccepted);
  let iRowNum = await getInt.go();
  if (iRowNum == null) return;

Inherited from ​

MxCADUiPrPoint.setUserInputControls


userInputControls ​

▸ userInputControls(): number

返回输入控制设置

Returns ​

number

Inherited from ​

MxCADUiPrPoint.userInputControls


value ​

▸ value(retcad_val?): McGePoint3d

得以获取的点

Parameters ​

NameTypeDefault value
retcad_valbooleanfalse

Returns ​

McGePoint3d

点坐标

Overrides ​

MxCADUiPrPoint.value