www.mxdraw.com
|
动态绘制接口
[ object, uuid(4124B02B-047D-4691-8395-2A01C872F918), dual, nonextensible, helpstring("IMxDrawWorldDraw interface"), pointer_default(unique) ]
interface IMxDrawWorldDraw : IDispatch;
MxDrawWorldDraw.idl
例如: VC COM接口
void CTestVc2005Dlg::CustomEntity_ExplodeMxdrawxctrl1(LPDISPATCH pCustomEntity, LPDISPATCH pDraw, long* pRet) { // TODO: 在此处添加消息处理程序代码 *pRet = 1; IMxDrawCustomEntityPtr spDrawData; pCustomEntity->QueryInterface(&spDrawData); IMxDrawWorldDrawPtr spWordDraw; pDraw->QueryInterface(&spWordDraw); CString sGuid = spDrawData->Guid; if(sGuid == MX_CUSTOM_ENTITY_ID) { if(spDrawData->IsHave(_T("ept") ) != VARIANT_TRUE) return; IMxDrawPointPtr stp = spDrawData->GetPoint(_T("spt")); if(stp == NULL) return; IMxDrawPointPtr ept = spDrawData->GetPoint(_T("ept")); if(ept == NULL) return; MxDrawXLib::IMxDrawUtilityPtr mxUtility; mxUtility.CreateInstance(__uuidof( MxDrawXLib::MxDrawUtility )); IMxDrawVector3dPtr vec = ept->SumVector(stp); vec->Mult(0.5); MxDrawXLib::IMxDrawPointPtr midPt; midPt.CreateInstance(__uuidof( MxDrawXLib::MxDrawPoint )); midPt->x = stp->x; midPt->y = stp->y; midPt->Add(vec); double dAng = vec->Angle(); dAng = mxUtility->GetDimAngle(dAng); double dDis = 0.0; dDis = stp->DistanceTo(ept); CString sTxt; sTxt.Format(_T("L=%.3lf"),dDis); dAng = dAng * 180.0 / 3.14159265; vec->RotateByXyPlan(3.14159265 / 2.0); vec->Normalize(); vec->Mult(10); stp->Add(vec); ept->Add(vec); spWordDraw->DrawLine(stp->x,stp->y,ept->x,ept->y); vec->Mult(2); stp->Sum(vec); ept->Sum(vec); spWordDraw->DrawLine(stp->x,stp->y,ept->x,ept->y); spWordDraw->SetColorIndex(1); spWordDraw->MxDrawText(midPt->x,midPt->y,sTxt.AllocSysString(),5,dAng, mcHorizontalAlignmentCenter,mcVerticalAlignmentMiddle); } }