#include "StdAfx.h" #include "AecDbSymbCoord.h" #include "AecDbText.h" const Adesk::UInt8 AecXDbSymbCoord::g_nVersion = 5; ACRX_DXF_DEFINE_MEMBERS(AecXDbSymbCoord, AecXDbSymbWithText, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent, 1, AEC_ZUOBIAOBIAOZHU, "AEC_ZUOBIAOBIAOZHU|缺乏上华解释器, 请下载上华软件|网址: www.shanghuasoft.com"); AecXDbSymbCoord::AecXDbSymbCoord() { m_nFlag = 0; m_nQuadrant = 0; // if (g_Option::instance().g_bCoordPrec2) // modified by whl on 04/06/15 // m_nFlag |= SCF_PREC2; if (g_Option::instance().g_bCoordPrec2) SetPrecNum(2); else SetPrecNum(3); m_nStyle = AecXDbSymbMultiLeader::kNone; m_dText2BaseRatio = -1000; // 使用GlobalFunc::DocGetText2BaseRatio,sg add 081113 m_dTextBaseLen = 100000; // lxb add 120104,文字基线长度,用100000表示使用默认长度 } AecXDbSymbCoord::~AecXDbSymbCoord() { } const TCHAR* AecXDbSymbCoord::GetDefaultLayer()const { extern TCHAR* LAY_COORD_DIM; return LAY_COORD_DIM; } //Acad::ErrorStatus //AecXDbSymbCoord::subGetClassID(CLSID* pClsid) const //{ // *pClsid = CLSID_ComSymbCoord; // return Acad::eOk; //} // 提供对格式刷的支持 void AecXDbSymbCoord::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag) { AssertWriteEnabled(); AecXDbSymbWithText::CopyPropertiesFrom(pSrcEntity, gMatchFlag); AecXDbSymbCoord *pSrc = AecXDbSymbCoord::cast(pSrcEntity); if (pSrc != NULL) { m_nFlag = pSrc->m_nFlag; // 控制标记 m_nStyle = pSrc->m_nStyle; m_dText2BaseRatio = pSrc->m_dText2BaseRatio; // 文字距基线系数,sg add 081113 m_dTextBaseLen = pSrc->m_dTextBaseLen; // 文字基线长度,add by lxb on 120104 } } // 从DWG读入数据: Acad::ErrorStatus AecXDbSymbCoord::dwgInFields(AcDbDwgFiler* pFiler) { AssertWriteEnabled(); Acad::ErrorStatus es = AecXDbSymbWithText::dwgInFields(pFiler); if (es != Acad::eOk) return es; Adesk::UInt8 nVer; pFiler->readItem(&nVer); if (nVer > g_nVersion) { // Version is too new return Acad::eMakeMeProxy; } pFiler->readItem(&m_nFlag); pFiler->readItem(&m_nQuadrant); pFiler->readItem((AcGePoint2d *)&m_ptLocation); pFiler->readItem((AcGePoint2d *)&m_ptValue); if (nVer < 2) { m_ptTurn = _GetTurnPoint(); } else { pFiler->readItem((AcGePoint2d *)&m_ptTurn); } if (nVer > 2) { Adesk::UInt8 nTemp; pFiler->readItem(&nTemp); m_nStyle = (AecXDbSymbMultiLeader::TArrowStyle)nTemp; } if (nVer > 3) // sg add 081113,8.0版本为4 pFiler->readItem(&m_dText2BaseRatio); else m_dText2BaseRatio = -1000; // 文字基线长度,add by lxb on 120104 if (nVer > 4) // TArch9为5 pFiler->readItem(&m_dTextBaseLen); else m_dTextBaseLen = 100000; return pFiler->filerStatus(); } Acad::ErrorStatus AecXDbSymbCoord::dwgOutFields(AcDbDwgFiler* pFiler) const { assertReadEnabled(); Acad::ErrorStatus es = AecXDbSymbWithText::dwgOutFields(pFiler); if (es != Acad::eOk) return es; pFiler->writeItem(g_nVersion); pFiler->writeItem(m_nFlag); pFiler->writeItem(m_nQuadrant); pFiler->writeItem((const AcGePoint2d &)m_ptLocation); pFiler->writeItem((const AcGePoint2d &)m_ptValue); pFiler->writeItem((const AcGePoint2d &)m_ptTurn); pFiler->writeItem((Adesk::UInt8)m_nStyle); pFiler->writeItem(m_dText2BaseRatio); pFiler->writeItem(m_dTextBaseLen); return pFiler->filerStatus(); } Acad::ErrorStatus AecXDbSymbCoord::dxfInFields(AcDbDxfFiler* pFiler) { return AecXDbSymbWithText::dxfInFields(pFiler); } Acad::ErrorStatus AecXDbSymbCoord::dxfOutFields(AcDbDxfFiler* pFiler) const { return AecXDbSymbWithText::dxfOutFields(pFiler); } // ----------------------------------------------------------------------- // Active when being rotated, scaled, moved, etc. // Scale is disabled here // Modified on 2002/2/5 by ZJQ // 原先没有按米制单位进行标注 Acad::ErrorStatus AecXDbSymbCoord::subTransformBy(const AcGeMatrix3d& xform) { AssertWriteEnabled(); AecXDbSymbWithText::subTransformBy(xform); ads_matrix mat; GlobalFunc::AsAdsMatrix(xform, mat); m_ptLocation.TransformBy(mat); m_ptLocation.z = 0; m_ptTurn.TransformBy(mat); m_ptTurn.z = 0; if (g_Option::instance().g_bDynamicCoord) { m_ptValue = m_ptLocation; // sg add 120413,转换坐标的时候,需要考虑当前坐标系,转换为当前坐标系下的点,进行标注 GlobalFunc::WCS2UCS(m_ptValue); if (!GlobalFunc::DocGetMeterUnitDraw()) m_ptValue /= 1000.0; } { //Vector3D vt=m_ptTurn-m_ptLocation; double nAngle = ads_angle(m_ptLocation, m_ptTurn); nAngle = Wcs2Layout(nAngle); if (nAngle >= 0.0 && nAngle < PI / 2) m_nQuadrant = 0; else if (nAngle >= PI / 2 && nAngle < PI) m_nQuadrant = 1; else if (nAngle >= PI && nAngle < PI * 1.5) m_nQuadrant = 2; else m_nQuadrant = 3; } return Acad::eOk; } // Overriden functions for edit // to do: // 允许通过夹点改变边界 Acad::ErrorStatus AecXDbSymbCoord::subGetGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const { assertReadEnabled(); gripPoints.append(m_ptLocation); gripPoints.append((AcGePoint3d &)GetTurnPoint()); // lxb add 120104,文字基线长度夹点 ADSGePoint3d ptTextBaseLen; ads_polar(m_ptTurn, m_nLayoutRotation, GetTrueTextBaseLen(FALSE), ptTextBaseLen); gripPoints.append(ptTextBaseLen); return Acad::eOk; } Acad::ErrorStatus AecXDbSymbCoord::subGetGripPoints(AcDbGripDataPtrArray & grips, const double curViewUnitSize, const int gripSize, const AcGeVector3d & curViewDir, const int bitflags) const { return Acad::eNotImplementedYet; } // stretch points is diffrent from grep points, with no midpoint included Acad::ErrorStatus AecXDbSymbCoord::subGetStretchPoints(AcGePoint3dArray & gripPoints) const { AcDbIntArray ar; return subGetGripPoints(gripPoints, ar, ar); } // 功能: 夹点操作 Acad::ErrorStatus AecXDbSymbCoord::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset) { // sg modify 120104,修改判断条件,当同时选中前2个夹点的时候,认为是整体MOVE // if(indices.length()>1) { if (indices.contains(0) && indices.contains(1)) { AcGeMatrix3d mat; mat.setToTranslation(offset); return subTransformBy(mat); } // sg add 120104,同时选中文字基线的2个夹点时,不修改文字基线长度 BOOL bSkipTextBaseLen = FALSE; if (indices.contains(1) && indices.contains(2)) bSkipTextBaseLen = TRUE; AssertWriteEnabled(); ADSGePoint3d vtOffset(offset[0], offset[1]); for (int i = 0; i < indices.length(); i++) { int idx = indices[i]; if (idx == 0) { //整体移动 m_ptLocation += vtOffset; if (g_Option::instance().g_bDynamicCoord) { m_ptValue = m_ptLocation; // sg add 120413,转换坐标的时候,需要考虑当前坐标系,转换为当前坐标系下的点,进行标注 GlobalFunc::WCS2UCS(m_ptValue); if (!GlobalFunc::DocGetMeterUnitDraw()) m_ptValue /= 1000.0; } } else if (idx == 1) { //改方向 ADSGePoint3d ptTurn = GetTurnPoint(); ptTurn += vtOffset; Vector3D vt = ptTurn - m_ptLocation; double nAngle = ads_angle(ADSGePoint3d(), vt); nAngle = GlobalFunc::AngleRangeTo2PI(nAngle - m_nLayoutRotation); if (nAngle >= 0.0 && nAngle < PI / 2) m_nQuadrant = 0; else if (nAngle >= PI / 2 && nAngle < PI) m_nQuadrant = 1; else if (nAngle >= PI && nAngle < PI * 1.5) m_nQuadrant = 2; else m_nQuadrant = 3; SetTurnPoint(ptTurn); } // end if else if (idx == 2) // 移动文字基线 add by lxb on 120104 { if (bSkipTextBaseLen) // 同时选中文字基线的2个夹点时,不修改文字基线长度 continue; ADSGePoint3d vtOffset1 = vtOffset; vtOffset1.Rotate(-GetLayoutRotation()); double dLen = GetTrueTextBaseLen(FALSE); dLen += vtOffset1.x; double nFactor = (m_nQuadrant == 0 || m_nQuadrant == 3) ? 1 : -1; SetTextBaseLen(nFactor * dLen, FALSE); } } return Acad::eOk; } // 功能: 夹点操作 Acad::ErrorStatus AecXDbSymbCoord::subMoveStretchPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset) { return subMoveGripPointsAt(indices, offset); } // 取得夹点说明 Acad::ErrorStatus AecXDbSymbCoord::GetGripText(int idx, CString &cs) const { Acad::ErrorStatus es = Acad::eOk; if (idx == 0) { cs = _T("移动位置"); //cs += IsDynamic()? _T("-更新坐标") : _T("不更新坐标"); } else if (idx == 1) cs = _T("翻转、移动文字"); else if (idx == 2) // 移动文字基线 add by lxb on 120104 { cs = _T("移动文字基线"); } return es; } ADSGePoint3d AecXDbSymbCoord::GetTurnPoint() const { return m_ptTurn; } // 只用于TArch5->TArch6的升级 ADSGePoint3d AecXDbSymbCoord::_GetTurnPoint() const { double nDir = PI / 4; switch (m_nQuadrant) { case 0: nDir = PI / 4; break; case 1: nDir = PI * 0.75; break; case 2: nDir = PI * 1.25; break; default: nDir = PI * 1.75; } double nDist = 10.0 * GetPScale(); ADSGePoint3d ptTurn; ads_polar(m_ptLocation, nDir, nDist, ptTurn); return ptTurn; } BOOL AecXDbSymbCoord::IsPrec2() const { //modified by whl on 04/06/15 //return ((m_nFlag&SCF_PREC2)!=0); return GetPrecNum() == 2; } void AecXDbSymbCoord::SetPrec2(BOOL bTrue) { AssertWriteEnabled(); //modified by whl on 04/06/15 //if(bTrue) // m_nFlag |= SCF_PREC2; //else // m_nFlag &= ~SCF_PREC2; if (bTrue) SetPrecNum(2); else SetPrecNum(3); } // sg add 090629,解决需求平台问题613,支持查找替换操作 BOOL AecXDbSymbCoord::GetText(Adesk::UInt32 cookies, AecXDbText &text) const { if (cookies > 1) return FALSE; TCString szFormat1, szFormat2; int iPrec = GetPrecNum(); szFormat1 << _T("%.") << iPrec << _T("f"); // 查找替换格式 szFormat2 << _T("%s=%.") << iPrec << _T("f"); // 绘制格式 AecXDbSymbMultiLeader leader; leader.SetPScale(GetPScale()); leader.setPropertiesFrom(this); leader.SetSymbMultiLeader(FALSE); // sg add 090723,设置是否为引出标注 leader.SetTextStyleId(GetTextStyleId()); // sg add 120106,增加文字字高的设置 leader.SetTextHeight(GetTextHeight()); leader.SetArrow(GetStyle()); leader.SetArrowSize(2.0); leader.SetText2BaseRatio(GetText2BaseRatio(TRUE, FALSE), TRUE); ADSGePointList vertexes; vertexes.Append(new ADSGePoint3d(m_ptLocation)); leader.SetLeaderVertexes(vertexes); leader.SetLeaderPoint(GetTurnPoint()); leader.SetText1(TCString(szFormat2, (IsAB() ? _T("A") : _T("X")), m_ptValue.y)); leader.SetText2(TCString(szFormat2, (IsAB() ? _T("B") : _T("Y")), m_ptValue.x)); double nFactor = (m_nQuadrant == 0 || m_nQuadrant == 3) ? 1.1 : -1.1, // lxb modify 120104,文字基线长度全部由GetTrueTextBaseLen函数返回 // dBaseLen = leader.GetDefaultTextBaseLen()*nFactor; dBaseLen = GetTrueTextBaseLen(); leader.SetText1(TCString(szFormat1, m_ptValue.y)); leader.SetText2(TCString(szFormat1, m_ptValue.x)); leader.SetTextBaseLen(dBaseLen); if (nFactor < 0) leader.SetTextAlign(AecXDbSymbMultiLeader::kAtStart); leader.GetText(cookies, text); return TRUE; } TextPosition AecXDbSymbCoord::FindSubText(const TCHAR *sSubText, TextPosition &posStart, TextRange *pRange) const { assertReadEnabled(); TextPosition pos; if (!sSubText || !sSubText[0]) return pos; TextPosition posNext = posStart; while (1) { AecXDbText text; text.SetPScale(GetPScale()); if (!GetText(posNext.m_nCookies, text)) break; TextPosition posFind = text.FindSubText(sSubText, posNext, pRange); if (!posFind) { posNext.m_nCookies++; posNext.m_nTextPos = 0; } else { posStart = posNext; if (!posStart) { posStart.m_nCookies++; posStart.m_nTextPos = 0; } posFind.m_nCookies = posNext.m_nCookies; pos = posFind; break; } } return pos; } TextPosition AecXDbSymbCoord::ReplaceSubText(const TextPosition &posRep, const TCHAR *sRepText, TextRange *pRange) { AssertWriteEnabled(); AecXDbText text; text.SetPScale(GetPScale()); TextPosition posNext; if (!sRepText || !GetText(posRep.m_nCookies, text)) return posNext; posNext = text.ReplaceSubText(posRep, sRepText, pRange); int cookies = posRep.m_nCookies; if (cookies == 0) { m_ptValue.y = _tstof(text.GetText()); } else { m_ptValue.x = _tstof(text.GetText()); } if (!posNext) { posNext.m_nCookies = posRep.m_nCookies + 1; posNext.m_nTextPos = 0; } return posNext; } void AecXDbSymbCoord::SetSubText(long i, CString sText) { AssertWriteEnabled(); if (i == 0) m_ptValue.y = _tstof(sText); else m_ptValue.x = _tstof(sText); } SubText* AecXDbSymbCoord::HitTestText(ADSGePoint3d pt)const { int iPrec = GetPrecNum(); TCString szFormat; szFormat << _T("%s=%.") << iPrec << _T("f"); //const TCHAR *szFormat=IsPrec2()? _T("%s=%.2f") : _T("%s=%.3f"); AecXDbSymbMultiLeader leader; leader.SetPScale(GetPScale()); leader.setPropertiesFrom(this); leader.SetSymbMultiLeader(FALSE); // sg add 090723,设置是否为引出标注 leader.SetTextStyleId(GetTextStyleId()); // sg add 120106,增加文字字高的设置 leader.SetTextHeight(GetTextHeight()); ADSGePointList vertexes; vertexes.Append(new ADSGePoint3d(m_ptLocation)); leader.SetLeaderVertexes(vertexes); leader.SetLeaderPoint(GetTurnPoint()); leader.SetText1(TCString(szFormat, (IsAB() ? _T("A") : _T("X")), m_ptValue.y)); leader.SetText2(TCString(szFormat, (IsAB() ? _T("B") : _T("Y")), m_ptValue.x)); //leader.SetArrow(AecXDbSymbMultiLeader::kCrossing); leader.SetArrow(AecXDbSymbMultiLeader::kNone);//modified by whl leader.SetArrowSize(2.0); double nFactor = (m_nQuadrant == 0 || m_nQuadrant == 3) ? 1.1 : -1.1; // lxb modify 120104,文字基线长度全部由GetTrueTextBaseLen函数返回 //leader.SetTextBaseLen(leader.GetDefaultTextBaseLen()*nFactor); leader.SetTextBaseLen(GetTrueTextBaseLen()); leader.SetText2BaseRatio(GetText2BaseRatio(TRUE, FALSE), TRUE); // sg add 081113 AcGiViewDraw dc; leader.DrawBaseEx(dc, leader); SubText* pSubText = leader.HitTestText(pt); if (pSubText != NULL) { pSubText->SetObjectId(objectId()); CString sText = pSubText->GetText(); long s = sText.Find(_T('=')); pSubText->SetText(sText.Right(sText.GetLength() - s - 1)); } return pSubText; } SubText* AecXDbSymbCoord::GetSubText(long iText)const { int iPrec = GetPrecNum(); TCString szFormat; szFormat << _T("%s=%.") << iPrec << _T("f"); //const TCHAR *szFormat=IsPrec2()? _T("%s=%.2f") : _T("%s=%.3f"); AecXDbSymbMultiLeader leader; leader.SetPScale(GetPScale()); leader.setPropertiesFrom(this); leader.SetSymbMultiLeader(FALSE); // sg add 090723,设置是否为引出标注 leader.SetTextStyleId(GetTextStyleId()); // sg add 120106,增加文字字高的设置 leader.SetTextHeight(GetTextHeight()); ADSGePointList vertexes; vertexes.Append(new ADSGePoint3d(m_ptLocation)); leader.SetLeaderVertexes(vertexes); leader.SetLeaderPoint(GetTurnPoint()); leader.SetText1(TCString(szFormat, (IsAB() ? _T("A") : _T("X")), m_ptValue.y)); leader.SetText2(TCString(szFormat, (IsAB() ? _T("B") : _T("Y")), m_ptValue.x)); //leader.SetArrow(AecXDbSymbMultiLeader::kCrossing); leader.SetArrow(AecXDbSymbMultiLeader::kNone);//modified by whl leader.SetArrowSize(2.0); double nFactor = (m_nQuadrant == 0 || m_nQuadrant == 3) ? 1.1 : -1.1; // lxb modify 120104,文字基线长度全部由GetTrueTextBaseLen函数返回 // leader.SetTextBaseLen(leader.GetDefaultTextBaseLen()*nFactor); leader.SetTextBaseLen(GetTrueTextBaseLen()); leader.SetText2BaseRatio(GetText2BaseRatio(TRUE, FALSE), TRUE); // sg add 081113 SubText* pSubText = leader.GetSubText(iText); if (pSubText != NULL) { pSubText->SetObjectId(objectId()); CString sText = pSubText->GetText(); long s = sText.Find(_T('=')); pSubText->SetText(sText.Right(sText.GetLength() - s - 1)); } return pSubText; } // sg add 110301,支持统一标高 bool AecXDbSymbCoord::UnifyElevation(double dElevation) { AssertWriteEnabled(); m_ptLocation.z = dElevation; m_ptValue.z = dElevation; m_ptTurn.z = dElevation; return true; } Acad::ErrorStatus AecXDbSymbCoord::Draw2d(AcGiDraw &dc) const { assertReadEnabled(); //if (!IsValid()) // return Acad::eInvalidInput; GlobalFunc::_LoadConfig(); if (Has2DBuffer() && !m_bInJig) { dc.SetColor(colorIndex()); dc.SetLayer(layerId()); BaseEx::_Draw2DBuffers(dc, true); return Acad::eOk; } if (!m_bInJig) int a = 0; BOOL bDynamic = FALSE; if (g_Option::instance().g_bDynamicCoord/* && _tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor()) == 0*/) { AcGiCommonDraw *pDraw = dc.GetCommonDraw(); pDraw->context()->disableFastMoveDrag(); bDynamic = TRUE; } int iPrec = GetPrecNum(); TCString szFormat; szFormat << _T("%s=%.") << iPrec << _T("f"); // const TCHAR *szFormat=IsPrec2()? _T("%s=%.2f") : _T("%s=%.3f"); AecXDbSymbMultiLeader leader; //leader.m_bInJig = m_bInJig; leader.SetPScale(GetPScale()); leader.setPropertiesFrom(this); leader.SetSymbMultiLeader(FALSE); // sg add 090723,设置是否为引出标注 if (bDynamic && !objectId().isValid()) { leader.setColorIndex(1); leader.SetTextColor(1); // sg add 090608,设置文字颜色为红色 } else { leader.SetTextColor(m_colorText); // sg add 090608,设置文字颜色 } leader.SetTextStyleId(GetTextStyleId()); // sg add 120106,增加文字字高的设置 leader.SetTextHeight(GetTextHeight()); ADSGePointList vertexes; vertexes.Append(new ADSGePoint3d(m_ptLocation)); leader.SetLeaderVertexes(vertexes); leader.SetLeaderPoint(GetTurnPoint()); leader.SetText1(TCString(szFormat, (IsAB() ? _T("A") : _T("X")), m_ptValue.y)); leader.SetText2(TCString(szFormat, (IsAB() ? _T("B") : _T("Y")), m_ptValue.x)); // leader.SetArrow(AecXDbSymbMultiLeader::kCrossing); leader.SetArrow(GetStyle()); // modified by whl leader.SetArrowSize(2.0); double nFactor = (m_nQuadrant == 0 || m_nQuadrant == 3) ? 1.1 : -1.1; // lxb modify 120104,文字基线长度全部由GetTrueTextBaseLen函数返回 // leader.SetTextBaseLen(leader.GetDefaultTextBaseLen()*nFactor); leader.SetTextBaseLen(GetTrueTextBaseLen()); leader.SetText2BaseRatio(GetText2BaseRatio(TRUE, FALSE), TRUE); // sg add 081113 //leader.ExplodeOrDraw2d(dc); DrawBaseEx(dc, leader); return Acad::eOk; } /* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */ void AecXDbSymbCoord::GetTips(PtrList &lstInfo) const { lstInfo.Append(new ObjInfoUnit(_T("对象类型"), _T("坐标标注"))); TCString sTextStyle = GlobalFunc::GetSymbolName(m_idTextStyle); lstInfo.Append(new ObjInfoUnit(_T("文字样式"), sTextStyle)); TCString sHeight; GlobalFunc::ftoa(m_nTextHeight, 1, sHeight); sHeight << _T("P"); lstInfo.Append(new ObjInfoUnit(_T("文字高度"), sHeight)); //lstInfo.Append(new ObjInfoUnit(_T("文字转角"), Angle2Str(m_nTextRotation*180/PI))); lstInfo.Append(new ObjInfoUnit(TCString(_T("坐标%s"), IsAB() ? _T("A") : _T("X")), TCString(_T("%.3f"), m_ptValue.y))); lstInfo.Append(new ObjInfoUnit(TCString(_T("坐标%s"), IsAB() ? _T("B") : _T("Y")), TCString(_T("%.3f"), m_ptValue.x))); TCString sLocation(256); sLocation << _T("(") << GlobalFunc::Dist2Str(m_ptLocation.x) << _T(", ") << GlobalFunc::Dist2Str(m_ptLocation.y) << _T(")"); lstInfo.Append(new ObjInfoUnit(_T("位置"), sLocation)); } BOOL AecXDbSymbCoord::IsAB() const { return ((m_nFlag & SCF_AB) != 0); } ADSGePoint3d AecXDbSymbCoord::GetLocation() const { return m_ptLocation; } ADSGePoint3d AecXDbSymbCoord::GetValue() const { return m_ptValue; } Adesk::UInt8 AecXDbSymbCoord::GetQuadrant() const { return m_nQuadrant; } Adesk::UInt8 AecXDbSymbCoord::GetPrecNum() const { Adesk::UInt8 num = (m_nFlag >> 4); //removed by whl on 04/06/15 //if(num==01111) { // num=IsPrec2()? 2 : 3; //} return num; } void AecXDbSymbCoord::SetPrecNum(Adesk::UInt8 iNum) { AssertWriteEnabled(); //removed by whl on 04/06/15 // if(iNum==2) // SetPrec2(TRUE); //else if(iNum==3) // SetPrec2(FALSE); Adesk::UInt8 iHi4 = (iNum << 4); Adesk::UInt8 iTemp = (m_nFlag << 4); Adesk::UInt8 iLo4 = (iTemp >> 4); m_nFlag = (iHi4 | iLo4); } void AecXDbSymbCoord::SetQuadrant(Adesk::UInt8 nQuadrant) { AssertWriteEnabled(); m_nQuadrant = nQuadrant; } void AecXDbSymbCoord::SetValue(ADSGePoint3d ptValue) { AssertWriteEnabled(); m_ptValue = ptValue; } void AecXDbSymbCoord::SetAB(BOOL bTrue) { AssertWriteEnabled(); if (bTrue) { m_nFlag |= SCF_AB; } else m_nFlag &= ~SCF_AB; } void AecXDbSymbCoord::SetTurnPoint(ADSGePoint3d pt) { AssertWriteEnabled(); m_ptTurn = ADSGePoint3d(pt.x, pt.y); } void AecXDbSymbCoord::SetLocation(ADSGePoint3d pt) { AssertWriteEnabled(); m_ptLocation = pt; } double AecXDbSymbCoord::GetText2BaseRatio(BOOL bAsPaperUnit, BOOL bRealDist) const { double dVal = m_dText2BaseRatio; // 系数 if (fabs(dVal + 1000) < 1.0E-5) { dVal = GlobalFunc::DocGetText2BaseRatio(); // 使用全局变量GlobalFunc::DocGetText2BaseRatio的值 } if (bRealDist) { dVal *= m_nTextHeight; // 将“系数”转为“实际值” } if (!bAsPaperUnit) // 处理出图比例 { dVal *= GetPScale(); } return dVal; } void AecXDbSymbCoord::SetText2BaseRatio(double dVal, BOOL bAsPaperUnit) { AssertWriteEnabled(); m_dText2BaseRatio = dVal; // 系数 if (!bAsPaperUnit) { m_dText2BaseRatio /= GetPScale(); } } // lxb add 120104,文字基线长度 void AecXDbSymbCoord::SetTextBaseLen(double dVal, BOOL bAsPaperUnit) { AssertWriteEnabled(); if (fabs(dVal) < 1E-6) { return; } m_dTextBaseLen = dVal; if (!bAsPaperUnit) { m_dTextBaseLen /= GetPScale(); } } double AecXDbSymbCoord::GetTextBaseLen(BOOL bAsPaperUnit) const { double val = m_dTextBaseLen; if (!bAsPaperUnit) { val *= GetPScale(); } return val; } // lxb add 120104,文字基线默认长度 double AecXDbSymbCoord::GetDefaultTextBaseLen(BOOL bAsPaperUnit) const { double dVal = 0; AecXDbSymbMultiLeader leader;; leader.SetPScale(GetPScale()); leader.setPropertiesFrom(this); leader.SetSymbMultiLeader(FALSE); leader.SetTextStyleId(GetTextStyleId()); // sg add 120106,增加文字字高的设置 leader.SetTextHeight(GetTextHeight()); TCString szFormat; int iPrec = GetPrecNum(); szFormat << _T("%s=%.") << iPrec << _T("f"); leader.SetText1(TCString(szFormat, (IsAB() ? _T("A") : _T("X")), m_ptValue.y)); leader.SetText2(TCString(szFormat, (IsAB() ? _T("B") : _T("Y")), m_ptValue.x)); dVal = leader.GetDefaultTextBaseLen(bAsPaperUnit); double dFactor = (m_nQuadrant == 0 || m_nQuadrant == 3) ? 1.1 : -1.1; dVal *= dFactor; return dVal; } // lxb add 120104,文字基线的真实长度 double AecXDbSymbCoord::GetTrueTextBaseLen(BOOL bAsPaperUnit) const { double dVal = 10.0; if (fabs(m_dTextBaseLen - 100000) < 1.0E-6) { dVal = GetDefaultTextBaseLen(bAsPaperUnit); // 已经考虑了1.1问题以及m_nQuadrant问题 } else { dVal = GetTextBaseLen(bAsPaperUnit); // 考虑象限对坐标的引线正负的影响 double dFactor = (m_nQuadrant == 0 || m_nQuadrant == 3) ? 1.0 : -1.0; dVal *= dFactor; } return dVal; }