如何选择圆形范围比较?
MxDraw网页开发|黄洪辉|2018-05-07 10:06
-
回答:
通过圆形范围把两个控件里面不同的内容标记出来,首先需要动态画一个圆,具体实现js代码如下:
function DoDynWorldDrawFun(dX, dY, pWorldDraw, pData) { var sGuid = pData.Guid; var ocx1 = document.getElementById("MxDrawXCtrl1"); ocx1.SetEventRet(0); if (sGuid == "DrawCircle") { var pt1 = pData.GetPoint("pt1"); if (pt1 == null) return; var pt2 = ocx1.NewPoint(); pt2.x = dX; pt2.y = dY; var dR = pt1.DistanceTo(pt2); pWorldDraw.DrawCircle(pt1.x, pt1.y, dR); } }
用户可以选取圆形范围内的图纸作比较,具体实现js代码如下:
function CircleCompare() { var mxOcx = document.getElementById("MxDrawXCtrl1"); var getPt1 = mxOcx.NewComObject("IMxDrawUiPrPoint"); getPt1.message = "指定圆心"; if (getPt1.go() != 1) { return; } var getPt2 = mxOcx.NewComObject("IMxDrawUiPrPoint"); getPt2.message = "指定圆上一点"; getPt2.basePoint = getPt1.value(); var spDrawData = getPt2.InitUserDraw("DrawCircle"); spDrawData.SetPoint("pt1", getPt1.value()); getPt2.setUseBasePt(true); if (getPt2.go() != 1) { return; } var cen = getPt1.value(); var pt2 = getPt2.value(); var dR = cen.DistanceTo(pt2); var circle = mxOcx.NewEntity("IMxDrawCircle"); circle.Center = cen; circle.Radius = dR; var points = circle.GetSamplePoints(0.1); if (points.Count < 3) { alert("圆太小"); } var filter = mxOcx.NewResbuf(); DoImpCompare(points, filter); }