www.mxdraw.com
|
自定义实体,打碎事件
[id(6)] void CustomEntity_Explode(IDispatch* pCustomEntity, IDispatch* pDraw, LONG* pRet);
参数 |
说明 |
IDispatch* pCustomEntity |
IMxDrawCustomEntity对象 |
IDispatch* pDraw |
IMxDrawWorldDraw,自绘对象 |
LONG* pRet |
返回值,成功回 1. |
例如: 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); } }