首页 技术 正文
技术 2022年11月9日
0 收藏 427 点赞 2,351 浏览 3806 个字

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);
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,488
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,903
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,736
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,487
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,127
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,289