计算文字的外包框
ARXDLL int mcedTextBox(const struct resbuf * args, mds_point pt1, mds_point pt2);
ArxFun.h
参数 |
说明 |
const struct resbuf * args |
文字相关信息的输入参数,链表数据的第一项是字符串类型,是需要计算文字的字符串 第二项是REAL类型是文字的高度,第三项是REAL类型是文字的宽度缩放比例 |
成功返回RTNORM
该函数计算文字的外包框,函数计算时取当前数据库的当前文字样式 例如:函数实现代码如下:
int Mx::mcedTextBox (const struct resbuf *args, mds_point pt1,mds_point pt2) { if(args == NULL || args->rbnext == NULL || args->rbnext->rbnext == NULL) return RTREJ; int iType1 = Mx::DXFToType(args->restype); int iType2 = Mx::DXFToType(args->rbnext->restype); int iType3 = Mx::DXFToType(args->rbnext->rbnext->restype); if(iType1 != RTSTR || iType2 != RTREAL || iType3 != RTREAL) return RTREJ; CString sText = args->resval.rstring; double dTextHeight = args->rbnext->resval.rreal; double dWidthFactor = args->rbnext->rbnext->resval.rreal; if(mcdbHostApplicationServices()->workingDatabase() == NULL) return RTERROR; McDbText tmpText; tmpText.setTextStyle(mcdbHostApplicationServices()->workingDatabase()->m_pImp->SysVar().GetCurTextStyleId()); tmpText.setHeight(dTextHeight); tmpText.setWidthFactor(dWidthFactor); tmpText.setTextString(sText); McDbExtents extents; if(tmpText.getGeomExtents(extents) != Mcad::eOk) return RTERROR; pt1[X] = pt1[Y] = pt1[Z] = 0.0; pt2[X] = extents.maxPoint().x - extents.minPoint().x; pt2[Y] = extents.maxPoint().y - extents.minPoint().y; pt2[Z] = 0.0; return RTNORM; }
调用该函数的例程代码:
MrxDbgRbList spTextData = Mx::mcutBuildList(RTSTR,_T("测试计算文字的宽度"),RTREAL,20.0,RTREAL,1.0,0); ads_point pt1,pt2; if(Mx::mcedTextBox(spTextData.data(),pt1,pt2) == RTNORM) { CString sT; sT.Format(_T("pt1:%lf,%lf,pt2:%lf,%lf"),pt1[X],pt1[Y],pt2[X],pt2[Y]); AfxMessageBox(sT); } else { AfxMessageBox(_T("计算失败")); }