主要用到函数说明:
_DMxDrawX::DrawLine
绘制一个直线。详细说明如下:
参数 | 说明 |
---|---|
DOUBLE dX1 |
直线的开始点x坐标 |
DOUBLE dY1 |
直线的开始点y坐标 |
DOUBLE dX2 |
直线的结束点x坐标 |
DOUBLE dY2 |
直线的结束点y坐标 |
IMxDrawCustomEntity::Draw
把实体绘制到图上。一般用于动态拖放时,在拖放结束时,绘制到图上。
c#中实现代码说明:
动态拖放时的绘制事件:
private void DrawPathToPolyline() { // 创建一个与用户交互取点的对象。 MxDrawPoint point1 = (MxDrawPoint)axMxDrawX1.GetPoint(false, 0, 0, "\n 点取开始点:"); if (point1 == null) { return; } MxDrawUiPrPoint getSecondPt = new MxDrawUiPrPoint(); getSecondPt.message = "第二点"; getSecondPt.basePoint = point1; //不开启皮筋效果 getSecondPt.setUseBasePt(false); //调用 var spDrawData = getSecondPt.InitUserDraw("TestDynDrawMatrix1"); // 设置动态绘制参数. spDrawData.SetPoint("BasePoint", point1); // 开始取第二个点。 if (getSecondPt.go() != MCAD_McUiPrStatus.mcOk) return; var ret = spDrawData.Draw(); }
动态绘制矩形框:
private void axMxDrawX1_DynWorldDraw(object sender, AxMxDrawXLib._DMxDrawXEvents_DynWorldDrawEvent e) { MxDrawCustomEntity pCustomEntity = (MxDrawCustomEntity)e.pData; MxDrawWorldDraw pWorldDraw = (MxDrawWorldDraw)e.pWorldDraw; string sGuid = pCustomEntity.Guid; MxDrawPoint curPoint = new MxDrawPoint(); curPoint.x = e.dX; curPoint.y = e.dY; if(sGuid == "TestDynDrawMatrix1") { //与用户交互在图面上提取一个点 var vBasePt = pCustomEntity.GetPoint("BasePoint"); //绘制一个直线 //参数一直线的开始点x坐标,参数二直线的开始点y坐标,参数三直线的结束点x坐标,参数四直线的结束点y坐标 pWorldDraw.DrawLine(vBasePt.x, vBasePt.y, vBasePt.x, curPoint.y); pWorldDraw.DrawLine(vBasePt.x, curPoint.y, curPoint.x, curPoint.y); pWorldDraw.DrawLine(curPoint.x, curPoint.y, curPoint.x, vBasePt.y); pWorldDraw.DrawLine(curPoint.x, vBasePt.y, vBasePt.x, vBasePt.y); } }
原文地址:https://www.cnblogs.com/yzy0224/p/11064812.html
时间: 2024-11-05 20:34:12