www.mxdraw.com
|
控件自定义实体
[ object, uuid(70C6F9BB-F9BD-4E8C-AB6B-2BC89358EACB), dual, nonextensible, helpstring("IMxDrawCustomEntity ӿ"), pointer_default(unique) ] interface IMxDrawCustomEntity : IMxDrawEntity;
MxDrawCustomEntity.idl
例如: JS 里绘制自定义实体
function InsertCustomEntity() { var mxOcx = document.all.item("MxDrawXCtrl"); var getPt = mxOcx.NewComObject("IMxDrawUiPrPoint"); getPt.message = "点取第一点"; if(getPt.go() != 1) return; var frstPt = getPt.value(); if(frstPt == null) return; var getSecondPt = mxOcx.NewComObject("IMxDrawUiPrPoint"); getSecondPt.message = "点取第二点"; getSecondPt.basePoint = frstPt; getSecondPt.setUseBasePt(true); if(getSecondPt.go() != 1) return; var secondPt = getSecondPt.value(); if(secondPt == null) return; var ent = mxOcx.DrawCustomEntity("TestMxCustomEntity",""); ent.SetPoint("spt",frstPt); ent.SetPoint("ept", secondPt); } function ExplodeFun(pCustomEntity, pWorldDraw) { var mxOcx = document.all.item("MxDrawXCtrl"); var sGuid = pCustomEntity.Guid; if(sGuid == "TestMxCustomEntity") { if (!pCustomEntity.IsHave("ept")) return; var stp = pCustomEntity.GetPoint("spt"); if(stp == null) return; var ept = pCustomEntity.GetPoint("ept"); if(ept == null) return; pWorldDraw.DrawLine(stp.x, stp.y, ept.x, ept.y); mxOcx.SetEventRet(1); } } function GetGripPointsFun(pCustomEntity) { var mxOcx = document.all.item("MxDrawXCtrl"); var sGuid = pCustomEntity.Guid; if(sGuid == "TestMxCustomEntity") { if(!pCustomEntity.IsHave("ept") ) return; var stp = pCustomEntity.GetPoint("spt"); if(stp == null) return; var ept = pCustomEntity.GetPoint("ept"); if(ept == null) return; var ret = mxOcx.NewResbuf(); ret.AddPoint(stp); ret.AddPoint(ept); mxOcx.SetEventRetEx(ret); } } function MoveGripPointsFun(pCustomEntity, lGridIndex, dOffsetX, dOffsetY) { var mxOcx = document.all.item("MxDrawXCtrl"); var sGuid = pCustomEntity.Guid; if (sGuid == "TestMxCustomEntity") { if (!pCustomEntity.IsHave("ept")) return; var stp = pCustomEntity.GetPoint("spt"); if (stp == null) return; var ept = pCustomEntity.GetPoint("ept"); if (ept == null) return; if(lGridIndex == 0) { stp.x=stp.x + dOffsetX; stp.y=stp.y + dOffsetY; pCustomEntity.SetPoint("spt",stp); } else { ept.x=ept.x + dOffsetX; ept.y=ept.y + dOffsetY; pCustomEntity.SetPoint("ept",ept); } mxOcx.SetEventRet(1); } } function TransformByFun(pCustomEntity, pMatXform) { var mxOcx = document.all.item("MxDrawXCtrl"); var sGuid = pCustomEntity.Guid; if (sGuid == "TestMxCustomEntity") { if (!pCustomEntity.IsHave("ept")) return; var stp = pCustomEntity.GetPoint("spt"); if (stp == null) return; var ept = pCustomEntity.GetPoint("ept"); if (ept == null) return; stp.TransformBy(pMatXform); ept.TransformBy(pMatXform); pCustomEntity.SetPoint("spt", stp); pCustomEntity.SetPoint("ept", ept); mxOcx.SetEventRet(1); } } function GetGeomExtentsFun(pCustomEntity) { var mxOcx = document.all.item("MxDrawXCtrl"); var sGuid = pCustomEntity.Guid; if (sGuid == "TestMxCustomEntity") { if (!pCustomEntity.IsHave("ept")) return; var stp = pCustomEntity.GetPoint("spt"); if (stp == null) return; var ept = pCustomEntity.GetPoint("ept"); if (ept == null) return; var ret = mxOcx.NewResbuf(); ret.AddPoint(stp); ret.AddPoint(ept); mxOcx.SetEventRetEx(ret); } } document.getElementById("MxDrawXCtrl").ImplementCommandEventFun = DoCommandEventFunc; document.getElementById("MxDrawXCtrl").ImpDynWorldDrawFun = DoDynWorldDrawFun; document.getElementById("MxDrawXCtrl").ImpExplodeFun = ExplodeFun; document.getElementById("MxDrawXCtrl").ImpGetGripPointsFun = GetGripPointsFun; document.getElementById("MxDrawXCtrl").ImpMoveGripPointsAtFun = MoveGripPointsFun; document.getElementById("MxDrawXCtrl").ImpTransformByFun = TransformByFun; document.getElementById("MxDrawXCtrl").ImpGetGeomExtentsFun = GetGeomExtentsFun;