js中实现代码说明:

动态拖放时的绘制事件:

function DoDynWorldDrawFun(dX,dY,pWorldDraw,pData) {
//自定义实体的GUID标识符
var sGuid = pData.Guid;
//设置自定义事件的返回值
mxOcx.SetEventRet(0); var curPt = mxOcx.NewPoint();
curPt.x = dX;
curPt.y = dY;
if (sGuid == "DrawCircle") {
var pt1 = pData.GetPoint("pt1");
var dR = curPt.DistanceTo(pt1) * 0.5;
var vec = curPt.SumVector(pt1);
vec.Mult(0.5);
pt1.Add(vec);
pWorldDraw.DrawCircle(pt1.x, pt1.y, dR);
} }

动态拖放时的绘制事件:

function  DynWorldDrawComment2( pCustomEntity,pWorldDraw,  curPt) {
// 得到绘制参数. var sText = pCustomEntity.GetString("Text");
var dTextHeight = pCustomEntity.GetDouble("TextHeight");
var iEdgeNumber = pCustomEntity.GetLong("EdgeNumber");
var dShapRadius = pCustomEntity.GetDouble("ShapRadius");
var basePoint = pCustomEntity.GetPoint("BasePoint");
// 创建一个批注对象.
var comment = mxOcx.NewEntity("IMxDrawComment");
comment.Text = sText;
comment.TextHeight = dTextHeight;
comment.EdgeNumber = iEdgeNumber;
comment.ShapRadius = dShapRadius;
comment.basePoint = basePoint;
comment.Position = curPt;
// 设置文字样式。
pWorldDraw.TextStyle = "MyCommentFont";
// 动态绘制.
pWorldDraw.DrawEntity(comment);
}

动态绘制文字:

function ExplodeFun(pCustomEntity, pWorldDraw, txt) {
var sGuid = pCustomEntity.Guid;
if (sGuid == "TestMxCustomEntity1") {
if (!pCustomEntity.IsHave("First"))
return;
var stp = pCustomEntity.GetPoint("First");
var ept = pCustomEntity.GetPoint("BasePoint");
var dimpt = pCustomEntity.GetPoint("DimPoint");
var txt = pCustomEntity.GetString("Text");
var textH = pCustomEntity.GetDouble("TextHeight");
var edgeNum = pCustomEntity.GetLong("EdgeNumber");
var shapRadius = pCustomEntity.GetDouble("ShapRadius");
var isCircle = pCustomEntity.GetLong("isCircle");
var comment = mxOcx.NewEntity("IMxDrawComment");
comment.Text = txt;
comment.TextHeight = textH;
comment.EdgeNumber = edgeNum;
comment.ShapRadius = shapRadius;
comment.basePoint = ept;
comment.Position = dimpt;
pWorldDraw.TextStyle = "MyCommentFont";
// 动态绘制.
pWorldDraw.DrawEntity(comment);
// 绘制矩形框.
if (isCircle) {
var dR = stp.DistanceTo(ept) * 0.5;
var vec = stp.SumVector(ept);
vec.Mult(0.5);
ept.Add(vec);
pWorldDraw.DrawCircle(ept.x, ept.y, dR);
}
else {
pWorldDraw.DrawLine(stp.x, stp.y, stp.x, ept.y);
pWorldDraw.DrawLine(stp.x, ept.y, ept.x, ept.y);
pWorldDraw.DrawLine(ept.x, ept.y, ept.x, stp.y);
pWorldDraw.DrawLine(ept.x, stp.y, stp.x, stp.y);
}
mxOcx.SetEventRet(1);
}
}

动态绘制文字:

function DoCircleComment() {
var getPt = mxOcx.NewComObject("IMxDrawUiPrPoint");
getPt.message = "点取第一点";
if (getPt.go() != 1) {
return;
}
var frstPt = getPt.value();
if (frstPt == null)
return;
var getPt2 = mxOcx.NewComObject("IMxDrawUiPrPoint");
getPt2.message = "指定第二个点";
var spDrawData = getPt2.InitUserDraw("DrawCircle");
spDrawData.SetPoint("pt1", frstPt);
if (getPt2.go() != 1) {
return;
}
var secondPt = getPt2.value();
// 出来一个对象,让用户输入文字.
var winWidth = 440;
var winHeight = 140;
var winLeft = (screen.width - winWidth) / 2;
var winTop = (screen.height - winHeight) / 2 - 20;
var str = 'dialogHeight:' + winHeight + 'px;dialogWidth:' + winWidth + 'px;dialogTop:' + winTop + 'px;dialogLeft:' + winLeft + 'px;resizable:yes;center:yes;status:no;'
var rt = window.showModalDialog("Gettext.htm?tmp=" + Math.random(), "输入文字", str);
var txt;
if (typeof (rt) == "undefined") {
return;
} else {
var arr = rt.split(",");
txt = arr[0];
}
// 加入换行操作符\\P
//txt = txt + "\\PTEST";
// 创建一个文字样式,用于批注文字字体.
mxOcx.AddTextStyle2("MyCommentFont", "黑体", 0.7);
// 创建一个与用户交互取点的对象。
var getSecondPt = mxOcx.NewComObject("IMxDrawUiPrPoint");
getSecondPt.message = "输入标注位置点";
getSecondPt.basePoint = secondPt;
getSecondPt.setUseBasePt(false);
spDrawData = getSecondPt.InitUserDraw("DrawComment2");
// 设置动态绘制参数.
spDrawData.SetPoint("BasePoint", secondPt);
spDrawData.SetString("Text", txt);
spDrawData.SetDouble("TextHeight", 100);
spDrawData.SetLong("EdgeNumber", 2);
spDrawData.SetDouble("ShapRadius", 1);
// 开始取第二个点。
if (getSecondPt.go() != 1)
return;
var ent = mxOcx.DrawCustomEntity("TestMxCustomEntity1", "");
ent.SetPoint("BasePoint", secondPt);
ent.SetString("Text", txt);
ent.SetDouble("TextHeight", 100);
ent.SetLong("EdgeNumber", 2);
ent.SetDouble("ShapRadius", 1);
ent.SetPoint("DimPoint", getSecondPt.value());
ent.SetPoint("First", frstPt);
ent.SetLong("isCircle", 1);
}

CAD交互绘制圆形批注(网页版)的更多相关文章

  1. CAD交互绘制文字(网页版)

    在CAD设计时,需要绘制文字,用户可以设置设置绘制文字的高度等属性. 主要用到函数说明: _DMxDrawX::DrawText 绘制一个单行文字.详细说明如下: 参数 说明 DOUBLE dPosX ...

  2. CAD交互绘制圆(网页版)

    CAD绘制图像的过程中,画圆的情况是非常常见的,用户可以在控件视区点取任意一点做为圆心,再动态点取半径绘制圆. 主要用到函数说明: _DMxDrawX::DrawCircle 绘制一个圆.详细说明如下 ...

  3. CAD交互绘制圆弧(网页版)

    在CAD设计时,需要绘制圆弧,用户可以在图面点圆弧起点,圆弧上的一点和圆弧的终点,这样就绘制出圆弧. 主要用到函数说明: _DMxDrawX::DrawArc2 由圆弧上的三点绘制一个圆弧.详细说明如 ...

  4. CAD交互绘制虚线(网页版)

    用户可以在CAD控件视区任意位置绘制直线. 主要用到函数说明: _DMxDrawX::DrawLine 绘制一个直线.详细说明如下: 参数 说明 DOUBLE dX1 直线的开始点x坐标 DOUBLE ...

  5. CAD交互绘制直线(网页版)

    用户可以在CAD控件视区任意位置绘制直线. 主要用到函数说明: _DMxDrawX::DrawLine 绘制一个直线.详细说明如下: 参数 说明 DOUBLE dX1 直线的开始点x坐标 DOUBLE ...

  6. CAD交互绘制圆形云线批注(网页版)

    js中实现代码说明: 动态拖放时的绘制事件: function DoDynWorldDrawFun(dX,dY,pWorldDraw,pData) { //自定义实体的GUID标识符 var sGui ...

  7. CAD交互绘制矩形批注(网页版)

    js中实现代码说明: 动态拖放时的绘制事件: function DynWorldDrawComment2( pCustomEntity,pWorldDraw, curPt) { // 得到绘制参数. ...

  8. CAD参数绘制文字(网页版)

    在CAD设计时,需要绘制文字,用户可以设置设置绘制文字的高度等属性. 主要用到函数说明: _DMxDrawX::DrawText 绘制一个单行文字.详细说明如下: 参数 说明 DOUBLE dPosX ...

  9. CAD参数绘制椭圆(网页版)

    在CAD设计时,需要绘制椭圆,用户可以设置椭圆的基本属性. 主要用到函数说明: _DMxDrawX::DrawEllipse 绘制椭圆.详细说明如下: 参数 说明 DOUBLE dCenterX 椭圆 ...

随机推荐

  1. LeetCode:104 Maximum Depth of Binary Tree(easy)

    题目: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the ...

  2. lightoj1145 【DP优化求方案】

    题意: 有一个k面的骰子,然后问你n个骰子朝上的面数字之和=s的方案: 思路: dp[i][j] 代表 前 i 个骰子组成 j 有多少种方案: 显然 dp[i][j] = dp[i - 1][j - ...

  3. Android NDK开发指南(二)Android.mk文件

    http://www.cnblogs.com/yaozhongxiao/archive/2012/03/06/2382225.html 1.  概述 Android.mk文件是用来描述build sy ...

  4. Label-Free Proteomic Analysis of Exosomes Secreted from THP-1- Derived Macrophages Treated with IFN‑α Identifies Antiviral Proteins Enriched in Exosomes (文献分享一组-张霞)

    文献名:Label-Free Proteomic Analysis of Exosomes Secreted from THP-1- Derived Macrophages Treated with ...

  5. 理解:return、break、continue区别

    1.return:结束该方法的执行 2.continue:结束当前流程中的continue一下的代码,如果是for循环会再次执行下一个条件 3.break:完全终止当前执行流程,如果是for循环,那么 ...

  6. MyBatist庖丁解牛(三)

    从MyBatis代码实现的角度来看,MyBatis的主要的核心部件有以下几个: SqlSession:作为MyBatis工作的主要顶层API,表示和数据库交互的会话,完成必要数据库增删改查功能: Ex ...

  7. DBUtils学习一 增删该查

    package com.mozq.jdbc.test; import java.sql.SQLException; import java.util.List; import java.util.Ma ...

  8. [BZOJ3128]a+b Problem

    题解 最小割+主席树优化建图 首先看到每个点只有\(0/1\)两种状态就想到最小割 然后由于有一个限制是点\(i\)是黑点且有符合条件的白点就会减去\(p_i\) 所以我们将\(S\)集合设为黑点集合 ...

  9. 牛客寒假6-E.海啸

    链接:https://ac.nowcoder.com/acm/contest/332/E 题意: 有一个沿海地区,可以看作有n行m列的城市,第i行第j列的城市海拔为h[i][j]. 由于沿海,所以这个 ...

  10. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) B

    Description Kostya likes Codeforces contests very much. However, he is very disappointed that his so ...