#include "StdAfx.h" #include "AecDbSymbMultiLeader.h" #include "AecDbMText.h" #include "globalFunc.h" #include "PushProperty.h" #define SMLF_PARALLEL 0x01 // 引线平行 const Adesk::UInt8 AecXDbSymbMultiLeader::g_nVersion = 5; ACRX_DXF_DEFINE_MEMBERS(AecXDbSymbMultiLeader, AecXDbSymbWithText, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent, 1, AEC_YINCHUBIAOZU, "AEC_YINCHUBIAOZHU|缺乏上华解释器, 请下载上华软件|网址: www.shanghuasoft.com"); AecXDbSymbMultiLeader::AecXDbSymbMultiLeader() { m_nTextBaseLen = 10.0; m_arrow = AecXDbSymbMultiLeader::kNone; m_bSideText = FALSE; m_nArrowSize = g_Option::instance().g_nArrowLen; m_dText2BaseRatio = -1000; // 使用GlobalFunc::DocGetText2BaseRatio,sg add 081111 m_nTextAlign = kAtEnd; // sg add 090216,8.0的Beta2起使用 m_dPageWidth = 0; // 线上文字页宽控制,默认为单行文字 SetPageWidth2(0.0); // sg add 090410,线下文字页宽控制,默认为单行文字 m_bSymbMultiLeader = TRUE; // sg add 090723,默认为引出标注 // lxb add 111230,增加引线平行数据 m_nLeaderFlag = 0; } AecXDbSymbMultiLeader::~AecXDbSymbMultiLeader() { } BOOL AecXDbSymbMultiLeader::IsValid() const { //BOOL bRet = AecXDbSymbWithText::IsValid(); //if (!bRet) // return bRet; BOOL bRet = (m_lstVertexes.Length() > 0); return bRet; } const TCHAR * AecXDbSymbMultiLeader::GetDefaultLayer()const { extern TCHAR* LAY_LEADER_DIM; return LAY_LEADER_DIM; } //Acad::ErrorStatus //AecXDbSymbMultiLeader::subGetClassID(CLSID* pClsid) const //{ // *pClsid = CLSID_ComSymbMultiLeader; // return Acad::eOk; //} // 提供对格式刷的支持 void AecXDbSymbMultiLeader::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag) { AssertWriteEnabled(); AecXDbSymbWithText::CopyPropertiesFrom(pSrcEntity, gMatchFlag); AecXDbSymbMultiLeader *pSrc = AecXDbSymbMultiLeader::cast(pSrcEntity); if (pSrc != NULL) { m_arrow = pSrc->m_arrow; m_nArrowSize = pSrc->m_nArrowSize; m_bSideText = pSrc->m_bSideText; m_dText2BaseRatio = pSrc->m_dText2BaseRatio; // 文字距基线系数,sg add 081111 m_nTextAlign = pSrc->m_nTextAlign; // sg add 090401,文字相对于基线的对齐方式 //axc add 2015-12-17 电气短斜线在格式刷时重新计算第一个短斜线的两点 AcGeVector3d vtDir = pSrc->m_ptSortLineEnd - pSrc->m_ptSortLineStart; if (m_lstVertexes.Length() > 0) { ADSGePoint3d ptLoca = *m_lstVertexes[0]; m_ptSortLineEnd = ptLoca + vtDir / 2; m_ptSortLineStart = ptLoca - vtDir / 2; } //m_ptSortLineEnd = pSrc->m_ptSortLineEnd; //m_ptSortLineStart = pSrc->m_ptSortLineStart; } } // 从DWG读入数据: Acad::ErrorStatus AecXDbSymbMultiLeader::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; } Adesk::UInt8 nFlag; pFiler->readItem(&nFlag); m_arrow = (AecXDbSymbMultiLeader::TArrowStyle)nFlag; pFiler->readItem((AcGePoint2d *)&m_ptLeader); pFiler->readItem(&m_nTextBaseLen); pFiler->readItem(&m_bSideText); GlobalFunc::ReadString(pFiler, m_sText1); GlobalFunc::ReadString(pFiler, m_sText2); Adesk::UInt8 nNum = 0; pFiler->readItem(&nNum); m_lstVertexes.Reset(); for (Adesk::UInt8 i = 0; i < nNum; i++) { ADSGePoint3d ptVert; pFiler->readItem((AcGePoint2d *)&ptVert); m_lstVertexes.Append(new ADSGePoint3d(ptVert)); } if (nVer > 1) pFiler->readItem(&m_nArrowSize); if (nVer > 2) // sg add 081111,sg modify 090216,8.0版本为3 { pFiler->readItem(&m_dText2BaseRatio); Adesk::UInt8 nTemp; pFiler->readItem(&nTemp); m_nTextAlign = (TSymbMLTextAlign)nTemp; pFiler->readItem(&m_dPageWidth); } else { m_dText2BaseRatio = -1000; m_nTextAlign = kAtEnd; m_dPageWidth = 0; // 线上文字,默认为单行 } // lxb add 111230,增加引线平行数据 if (nVer > 3) // 9.0版本 { pFiler->readItem(&m_nLeaderFlag); pFiler->readItem((AcGePoint2d*)&m_ptLeaderDirection); } else // 8.0及以前版本 { m_nLeaderFlag = 0; if (m_lstVertexes.Length() > 0) { m_ptLeaderDirection = m_lstVertexes[0]->AsAcGePoint3d(); } } if (nVer >= 5) { pFiler->readItem(&m_ptSortLineStart); pFiler->readItem(&m_ptSortLineEnd); } return pFiler->filerStatus(); } Acad::ErrorStatus AecXDbSymbMultiLeader::dwgOutFields(AcDbDwgFiler* pFiler) const { assertReadEnabled(); Acad::ErrorStatus es = AecXDbSymbWithText::dwgOutFields(pFiler); if (es != Acad::eOk) return es; // pFiler->writeItem(g_nVersion); // sg modify 081111 pFiler->writeItem(g_nVersion); pFiler->writeItem((Adesk::UInt8)m_arrow); pFiler->writeItem((const AcGePoint2d &)m_ptLeader); pFiler->writeItem(m_nTextBaseLen); pFiler->writeItem(m_bSideText); pFiler->writeString(m_sText1); pFiler->writeString(m_sText2); Adesk::UInt8 nNum = m_lstVertexes.Length(); pFiler->writeItem(nNum); for (Adesk::UInt8 i = 0; i < nNum; i++) { pFiler->writeItem((const AcGePoint2d &)m_lstVertexes[i]); } pFiler->writeItem(m_nArrowSize); pFiler->writeItem(m_dText2BaseRatio); pFiler->writeItem((Adesk::UInt8)m_nTextAlign); pFiler->writeItem(m_dPageWidth); pFiler->writeItem(m_nLeaderFlag); pFiler->writeItem((const AcGePoint2d &)m_ptLeaderDirection); pFiler->writeItem(m_ptSortLineStart); pFiler->writeItem(m_ptSortLineEnd); return pFiler->filerStatus(); } Acad::ErrorStatus AecXDbSymbMultiLeader::dxfInFields(AcDbDxfFiler* pFiler) { return AecXDbSymbWithText::dxfInFields(pFiler); } Acad::ErrorStatus AecXDbSymbMultiLeader::dxfOutFields(AcDbDxfFiler* pFiler) const { return AecXDbSymbWithText::dxfOutFields(pFiler); } // ----------------------------------------------------------------------- // Active when being rotated, scaled, moved, etc. // Scale is disabled here Acad::ErrorStatus AecXDbSymbMultiLeader::subTransformBy(const AcGeMatrix3d& xform) { AssertWriteEnabled(); // double nOldHeight = GetTextHeight(); // ADSGePoint3d ptTextBase = GetTextBasePoint(); ADSGePoint3d ptTextBase; // sg modify 090305,解决需求平台问题1866,GetTextBasePoint函数角度错误 ads_polar(m_ptLeader, m_nLayoutRotation, GetTextBaseLen(FALSE), ptTextBase); AecXDbSymbWithText::subTransformBy(xform); // 当支持图纸旋转时,调用 ptTextBase.TransformBy(xform); // double nScale = GetTextHeight()/nOldHeight; ads_matrix mat; GlobalFunc::AsAdsMatrix(xform, mat); m_ptLeader.TransformBy(mat); m_ptLeader.z = 0; //lsd 2014-4-30 短斜线不跟着走的问题 ADSGePoint3d ptS(m_ptSortLineStart), ptE(m_ptSortLineEnd); ptS.TransformBy(mat); ptS.z = 0; ptE.TransformBy(mat); ptE.z = 0; m_ptSortLineStart = ptS.AsAcGePoint3d(); m_ptSortLineEnd = ptE.AsAcGePoint3d(); //end using namespace GlobalFunc; Vector3D vt = ptTextBase - m_ptLeader, vtBase(cos(m_nLayoutRotation), sin(m_nLayoutRotation)); // m_nTextBaseLen = (vt&vtBase)/GetPScale(); // sg modify 090317,只取符号,不改变大小 double dTmp = (vt & vtBase); int nSign = (dTmp > -1.0E-5) ? 1 : (-1); m_nTextBaseLen = nSign * fabs(m_nTextBaseLen); if (xform.isUniScaledOrtho()) // sg add 090317,解决SCALE操作的问题 m_nTextBaseLen *= fabs(xform.scale()); // 只改大小,不考虑符号 // m_nTextBaseLen *= nScale; for (int i = 0; i < m_lstVertexes.Length(); i++) m_lstVertexes[i]->TransformBy(mat); // add by lxb on 120104,维护不绘制的代表平行的引线方向点的变化 m_ptLeaderDirection.TransformBy(mat); m_ptLeaderDirection.z = 0; return Acad::eOk; } // Overriden functions for edit Acad::ErrorStatus AecXDbSymbMultiLeader::subGetGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const { assertReadEnabled(); // return getStretchPoints(gripPoints); // sg modify 090427,页宽夹点不支持stretch操作 Acad::ErrorStatus es = subGetStretchPoints(gripPoints); // sg add 090413,文字内容不为空时,增加文字页宽拖拽夹点 ADSGePoint3d ptTemp; if (!!m_sText1) // 线上文字 { ADSGePoint3d ptTextLoc = GetTextPt(); double dPageWidth = GetPageWidth(FALSE); if (IsUpText()) // 单行文字 { ads_polar(ptTextLoc, GetLayoutRotation() + PI / 2, m_nTextHeight * GetPScale(), ptTextLoc); if (m_nTextAlign == AecXDbSymbMultiLeader::kAtMiddle) dPageWidth *= 0.5; else if ((m_nTextBaseLen < 0.0 && m_nTextAlign == kAtStart) || (m_nTextBaseLen > 0.0 && m_nTextAlign == kAtEnd)) dPageWidth = 0; } ads_polar(ptTextLoc, GetLayoutRotation(), dPageWidth, ptTemp); gripPoints.append(ptTemp); } if (!!m_sText2) // 线下文字 { ADSGePoint3d ptTextLoc = GetText2Pt(); double dPageWidth = GetPageWidth2(FALSE); if (IsDownText()) // 单行文字 { if (m_nTextAlign == AecXDbSymbMultiLeader::kAtMiddle) dPageWidth *= 0.5; else if ((m_nTextBaseLen < 0.0 && m_nTextAlign == kAtStart) || (m_nTextBaseLen > 0.0 && m_nTextAlign == kAtEnd)) dPageWidth = 0; } ads_polar(ptTextLoc, GetLayoutRotation(), dPageWidth, ptTemp); gripPoints.append(ptTemp); } return es; } // stretch points is diffrent from grep points, with no midpoint included Acad::ErrorStatus AecXDbSymbMultiLeader::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const { assertReadEnabled(); stretchPoints.append(m_ptLeader); ADSGePoint3d ptTemp; ads_polar(m_ptLeader, GetLayoutRotation(), GetTextBaseLen(FALSE), ptTemp); stretchPoints.append(ptTemp); for (int i = 0; i < m_lstVertexes.Length(); i++) stretchPoints.append(m_lstVertexes[i]); return Acad::eOk; } // 功能: 夹点操作 Acad::ErrorStatus AecXDbSymbMultiLeader::subMoveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset) { AssertWriteEnabled(); // 判断是否是所有的引注点都被选择为夹点,第2个标记用来标记,是否有引注点,被选中 bool bAllVertexes = true, bHasVertexes = false; for (int i = 0; i < m_lstVertexes.Length(); i++) { if (!indices.contains(i + 2)) bAllVertexes = false; else bHasVertexes = true; } // add by lxb on 2012/01/04,引注点和引线端点如果同时被选为夹点,则MOVE操作 if (indices.contains(0) && bAllVertexes) { AcGeMatrix3d mat; mat.setToTranslation(offset); return subTransformBy(mat); } ADSGePoint3d vtOffset(offset[0], offset[1]); if (bAllVertexes) // 如果所有的标注点都被选中,并且没有选中引线端点,则需要修改对象内部点的位置,来改变引注方向 { m_ptLeaderDirection += vtOffset; } BOOL bSkip1 = FALSE; // sg add 090514,当引线端点和文字基线点同时选中时,忽略文字基线点 if (indices.contains(0) && indices.contains(1)) bSkip1 = TRUE; for (i = 0; i < indices.length(); i++) { int idx = indices[i]; if (idx == 0) // 移动引线端点 { if (!bHasVertexes) // 如果选中某一个或几个引注点和引线端点,则认为是只改变引线长度,不改变引线方向 { m_ptLeader += vtOffset; // sg modify 090216/090514,解决需求平台问题496,此时,文字基线长不应该改变 int nLen1 = indices.length(), nLen2 = m_lstVertexes.Length() + 2; if (nLen1 > 1 && nLen1 < nLen2 && !indices.contains(1)) { // m_nTextBaseLen -= vtOffset.x/GetPScale(); ADSGePoint3d vtOffset1 = vtOffset; vtOffset1.Rotate(-GetLayoutRotation()); m_nTextBaseLen -= vtOffset1.x / GetPScale(); } //lsd 2013-11-14 拖动转向 double dLen = GetTextBaseLen(FALSE); ADSGePoint3d vtOffset2 = m_ptLeader - *m_lstVertexes[0]; if ((vtOffset2.x) * dLen < 0) dLen *= -1; SetTextBaseLen(dLen, FALSE); //end } } else if (idx == 1) // 移动文字基线 { if (!bSkip1) // sg add 090514 { // modified by whl on 070306 // m_nTextBaseLen += vtOffset.x/GetPScale(); ADSGePoint3d vtOffset1 = vtOffset; vtOffset1.Rotate(-GetLayoutRotation()); // modify by lxb on 2012/01/05,防止基线长度夹点和引线端点夹点重合 // m_nTextBaseLen += vtOffset1.x/GetPScale(); double dLen = GetTextBaseLen(FALSE); dLen += vtOffset1.x; SetTextBaseLen(dLen, FALSE); } } else // 移动(删除)引注点 { //lsd 2014-4-30 移动短线 if (0 == i && idx == 2) { //保證每次只移動一次 m_ptSortLineStart += vtOffset; m_ptSortLineEnd += vtOffset; } //end int iVert = idx - 2; if (iVert < m_lstVertexes.Length()) { *m_lstVertexes[iVert] += vtOffset; if (m_ptLeader.Distance2d(*m_lstVertexes[iVert]) < g_Option::instance()._DIST_SNAP) { if (indices.length() == 1 && m_lstVertexes.Length() > 1) m_lstVertexes.Remove(iVert); } } else // sg add 090413,增加文字页宽拖拽夹点 { iVert = m_lstVertexes.Length() + 2; if (!!m_sText1) // 线上文字 { if (idx == iVert) { ADSGePoint3d vtOffset1 = vtOffset; vtOffset1.Rotate(-GetLayoutRotation()); double dPageWidth = GetPageWidth(TRUE); dPageWidth += vtOffset1.x / GetPScale(); if (dPageWidth > 1.0E-5) // sg add 090427,页宽不支持小于0 SetPageWidth(dPageWidth, TRUE); } iVert++; } if (!!m_sText2) // 线下文字 { if (idx == iVert) { ADSGePoint3d vtOffset1 = vtOffset; vtOffset1.Rotate(-GetLayoutRotation()); double dPageWidth = GetPageWidth2(TRUE); dPageWidth += vtOffset1.x / GetPScale(); if (dPageWidth > 1.0E-5) // sg add 090427,页宽不支持小于0 SetPageWidth2(dPageWidth, TRUE); } iVert++; } } } } return Acad::eOk; } // 功能: 夹点操作 Acad::ErrorStatus AecXDbSymbMultiLeader::subMoveStretchPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset) { AssertWriteEnabled(); return subMoveGripPointsAt(indices, offset); } // 取得夹点说明 Acad::ErrorStatus AecXDbSymbMultiLeader::GetGripText(int idx, CString &cs) const { Acad::ErrorStatus es = Acad::eOk; if (idx == 0) cs = _T("移动引线端点"); else if (idx == 1) cs = _T("移动文字基线"); else { // cs = _T("移动(删除)引注点"); // sg modify 090413,增加文字页宽拖拽夹点 int iVert = idx - 2; if (iVert < m_lstVertexes.Length()) cs = _T("移动(删除)引注点"); else { iVert = m_lstVertexes.Length() + 2; if (!!m_sText1) // 线上文字 { if (iVert == idx) cs = _T("修改文字1页宽"); iVert++; } if (!!m_sText2) // 线下文字 { if (iVert == idx) cs = _T("修改文字2页宽"); iVert++; } } } return es; } Acad::ErrorStatus AecXDbSymbMultiLeader::Draw2d(AcGiDraw &dc) const { assertReadEnabled(); GlobalFunc::_LoadConfig(); if (Has2DBuffer() && !dc.IsDragging()) { dc.SetColor(colorIndex()); dc.SetLayer(layerId()); BaseEx::_Draw2DBuffers(dc, true); return Acad::eOk; } if (!IsValid()) return Acad::eInvalidInput; int i = 0; PtrList lnSet; PtrList lnTmpSet; // sg add 120104,存放补充的平行线延长线 // lxb add 111230,增加引线平行的绘制 if (IsLeaderParall()) { if (m_lstVertexes.Length() > 0) { double dTextBaseLen = GetTextBaseLen(FALSE); if (fabs(dTextBaseLen) < 1.0E-6) dTextBaseLen = GetDefaultTextBaseLen(FALSE); ADSGePoint3d ptTemp, ptInter; ads_polar(m_ptLeader, m_nLayoutRotation, dTextBaseLen, ptTemp); GeLine textbaseline(m_ptLeader, ptTemp, LS_INFINITE); // 延长,直线 GeLine textbaseline1(m_ptLeader, ptTemp, LS_FINITE); // 不延长,线段 AcGeVector3d vec = m_ptLeader - m_ptLeaderDirection; // 平行引线方向 for (i = 0; i < m_lstVertexes.Length(); i++) { if (m_lstVertexes[i].Distance2d(m_ptLeader) < g_Option::instance()._DIST_SNAP) continue; GeLine line(m_lstVertexes[i], m_lstVertexes[i] + vec); if (textbaseline1.Intersection(&line, ptInter) == 0) // 交点在线段外,需要延长文字基线 { textbaseline.Intersection(&line, ptInter); if (ptInter.Distance(m_ptLeader) < ptInter.Distance(ptTemp)) { lnTmpSet.Append(new GeLine(m_ptLeader, ptInter, LS_FINITE)); } else { lnTmpSet.Append(new GeLine(ptTemp, ptInter, LS_FINITE)); } } lnSet.Append(new GeLine(m_lstVertexes[i], ptInter, LS_FINITE)); } for (i = 0; i < lnTmpSet.Length(); i++) { //dc << *lnTmpSet[i]; // 补充的平行线延长线 DrawLine(dc, *lnTmpSet[i]); } } } else // 引线不平行的情况 { //for (int i=0; iStartPoint().GetRotationMatrix(m_nLayoutRotation, mat); if (m_arrow == AecXDbSymbMultiLeader::kArrow) // 箭头 { if (ln->GetLength() < nArLen) continue; ADSGePoint3d ptTemp; ads_polar(ln->StartPoint(), ln->Direction(), nArLen, ptTemp); pline.addVertexAt(0, ln->StartPoint()); pline.addVertexAt(1, ptTemp); pline.setWidthsAt(0, 0.0, nArWidth); // pline.transformBy(GlobalFunc::AsAcGeMatrix3d(mat)); //dc.Polyline(pline); DrawPline(dc, pline); } else if (m_arrow == AecXDbSymbMultiLeader::kCrossing) // 十字 { GeLine ln1, ln2; ln1.StartPoint() = ln->StartPoint() - ADSGePoint3d(nArLen / 2, 0); ln1.EndPoint() = ln->StartPoint() + ADSGePoint3d(nArLen / 2, 0); ln2.StartPoint() = ln->StartPoint() - ADSGePoint3d(0, nArLen / 2); ln2.EndPoint() = ln->StartPoint() + ADSGePoint3d(0, nArLen / 2); ln1.TransformBy(mat); ln2.TransformBy(mat); //dc << ln1 << ln2; DrawLine(dc, ln1); DrawLine(dc, ln2); } else if (m_arrow == AecXDbSymbMultiLeader::kDote) // 圆点 { if (ln->GetLength() < nArWidth) continue; double nW = nArWidth / 4.0; ADSGePoint3d pt1, pt2; ads_polar(ln->StartPoint(), ln->Direction() + PI, nW, pt1); ads_polar(ln->StartPoint(), ln->Direction(), nW, pt2); pline.addVertexAt(0, pt1, 1.0); pline.addVertexAt(1, pt2, 1.0); //if (_tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor()) == 0 && !objectId()) // ; //else // pline.setConstantWidth(nW * 2); pline.setClosed(Adesk::kTrue); pline.transformBy(GlobalFunc::AsAcGeMatrix3d(mat)); //dc.Polyline(pline); DrawPline(dc, pline); } else if (m_arrow == AecXDbSymbMultiLeader::kSortLine) // 电气短线 { //dc.DrawLine(GeLine(asDblArray(m_ptSortLineStart), asDblArray(m_ptSortLineEnd), LS_FINITE)); //axc add 2015-01-14 样式为短斜线时支持3种标准样式 //i=0时第一根短斜线始终保持与要标注的线呈45度,其余短斜线一律按照与引出直线呈45度 if (0 == i) { ptFirstS = ln->StartPoint().AsAcGePoint3d(); ptFirstE = ln->EndPoint().AsAcGePoint3d(); //dc.DrawLine(GeLine(asDblArray((const AcGePoint2d &)m_ptSortLineStart), asDblArray((const AcGePoint2d &)m_ptSortLineEnd), LS_FINITE)); DrawLine(dc, GeLine(asDblArray((const AcGePoint2d &)m_ptSortLineStart), asDblArray((const AcGePoint2d &)m_ptSortLineEnd), LS_FINITE)); } else { //T20 v2.0以前版本的引出标注m_lstVertexes[0]与m_lstVertexes[1]相同 //究其原因是因为以前在往m_lstVertexes添加点时会事先执行lstVertexes.Remove(); //此操作没有被正确执行,后来改用lstVertexes.Reset(); //为了兼容以前的版本此处做个特殊处理,即判断i=0和i=1时两条线是否相同如果相同 if (ln->StartPoint().AsAcGePoint3d().isEqualTo(ptFirstS) && ln->EndPoint().AsAcGePoint3d().isEqualTo(ptFirstE)) { continue; } GeLine lnSortLine; AcGeVector3d vtSortLine = ln->EndPoint() - ln->StartPoint(); vtSortLine = vtSortLine.rotateBy(PI / 2, AcGeVector3d::kZAxis); vtSortLine.normalize(); lnSortLine.StartPoint() = ln->StartPoint() - vtSortLine * nArLen / 2; lnSortLine.EndPoint() = ln->StartPoint() + vtSortLine * nArLen / 2; lnSortLine.TransformBy(mat); //dc << lnSortLine; DrawLine(dc, lnSortLine); } } } } ADSGePoint3d ptTemp; ads_polar(m_ptLeader, m_nLayoutRotation, GetTextBaseLen(FALSE), ptTemp); //dc << GeLine(m_ptLeader, ptTemp); // 绘制文字基线 DrawLine(dc, m_ptLeader, ptTemp); // sg modify 090409,将文字分为单行文字和多行文字 // double nText2Base = DocGetText2Base()*GetPScale(); double nText2Base = GetText2BaseRatio(FALSE, TRUE); // sg modify 081111,距基线系数 if (!!m_sText1 || g_Option::instance().g_bExplodeSubText) // 绘制线上文字 { AecXDbText *pText = IsUpText() ? (new AecXDbText) : (new AecXDbMText); AecXDbText &text = *pText; text.SetPScale(GetPScale()); text.setPropertiesFrom(this); // text.SetRotation(m_nTextRotation); // 文字一律使用布局转角 text.SetHeight(m_nTextHeight); text.SetStyleId(m_idTextStyle); text.SetText(m_sText1); //if (dc.IsExportTch4()) // sg modify 090608 //{ // // sg add 120313,分解出来的文字的图层和颜色要随“高级选项”中的设置来处理 // // if (!!m_idTextLayer) // if (g_nSymbTextT3Layer == 1 && !!m_idTextLayer) // { // text.setLayer(m_idTextLayer); // 文字层 // text.setColorIndex(256); // sg add 110616,解决坐标文字图形导出T3时候颜色错误 // } // else // text.setColorIndex(m_colorText); // 文字和标注放在同一层,文字的颜色为白色 //} //else text.setColorIndex(m_colorText); // sg add 090608,将文字和标注放在同一层,文字的颜色为白色 ADSGePoint3d ptLoc = GetTextPt(FALSE); // 文字位置点 text.SetLocation(ptLoc); if (IsUpText()) // m_sText1为单行文字 { if (m_bSideText) // 注:本段代码实际上未使用 text.SetAlignment((m_nTextBaseLen < 0.0) ? AcGiDraw::kMiddleLeft : AcGiDraw::kMiddleRight); else { // sg modify 090401,处理对齐方式的问题 // text.SetAlignment(m_nTextBaseLen<0.0?AcGiDraw::kBottomLeft:AcGiDraw::kBottomRight); AcGiDraw::TextAlignment nAlign = AcGiDraw::kBottomLeft; if (m_nTextAlign == kAtMiddle) // 居中对齐 nAlign = AcGiDraw::kBottomCenter; else if (m_nTextAlign == kAtStart) // 起端对齐 nAlign = (m_nTextBaseLen < 0.0 ? AcGiDraw::kBottomRight : nAlign); else // 末端对齐 nAlign = (m_nTextBaseLen < 0.0 ? nAlign : AcGiDraw::kBottomRight); text.SetAlignment(nAlign); } // sg add 090724,率先解决坐标文字,线上、下文字距离文字基线距离相等的问题 if (!m_bSymbMultiLeader) { ADSGePoint3d ptMin, ptMax; text.SetLayoutRotation(0.0); // 获得外包框的时候,一定要不考虑布局转角、文字转角 text.GetExtents2d(ptMin, ptMax); double dTmp = 0; // sg add 090819,防止批量转旧时,无法得到文字外包围框 if (ptMin != ADSGePoint3d() || ptMax != ADSGePoint3d()) { dTmp = ptLoc.y - ptMin.y; } text.SetLayoutRotation(m_nLayoutRotation); ptLoc = GetTextPt(); ADSGePoint3d ptDraw = ptLoc; ads_polar(ptLoc, m_nLayoutRotation + PI / 2, dTmp, ptDraw); text.SetLocation(ptDraw); } } else // m_sText1为多行文字 { ((AecXDbMText &)text).SetLineSpace(nText2Base, FALSE); // 行间距 ((AecXDbMText &)text).SetPageWidth(GetPageWidth(FALSE), FALSE); // 页宽 text.SetAlignment(AcGiDraw::kLeft); // 对齐方式 } PushProperty vProp(&text, dc); //if (dc.IsFullExplode()) // text.ExplodeOrDraw2d(dc); //else // dc.DrawEntity(text); DrawBaseEx(dc, text); delete pText; } if (!!m_sText2 || g_Option::instance().g_bExplodeSubText) // 绘制线下文字 { BOOL bText = IsDownText(); AecXDbText *pText = bText ? (new AecXDbText) : (new AecXDbMText); AecXDbText &text = *pText; text.SetPScale(GetPScale()); text.setPropertiesFrom(this); text.SetHeight(m_nTextHeight); text.SetStyleId(m_idTextStyle); text.SetText(m_sText2); //if (dc.IsExportTch4()) // sg modify 090608 //{ // // sg add 120313,分解出来的文字的图层和颜色要随“高级选项”中的设置来处理 // // if (!!m_idTextLayer) // if (g_nSymbTextT3Layer == 1 && !!m_idTextLayer) // { // text.setLayer(m_idTextLayer); // 文字层 // text.setColorIndex(256); // sg add 110616,解决坐标文字图形导出T3时候颜色错误 // } // else // text.setColorIndex(m_colorText); // 文字和标注放在同一层,文字的颜色为白色 //} //else text.setColorIndex(m_colorText); // sg add 090608,将文字和标注放在同一层,文字的颜色为白色 ADSGePoint3d ptLoc = GetText2Pt(FALSE); // 文字位置点 text.SetLocation(ptLoc); if (bText) // m_sText2为单行文字 { // sg modify 090401,处理对齐方式的问题 // text.SetAlignment(m_nTextBaseLen<0.0?AcGiDraw::kTopLeft:AcGiDraw::kTopRight); AcGiDraw::TextAlignment nAlign = AcGiDraw::kTopLeft; if (m_nTextAlign == kAtMiddle) // 居中对齐 nAlign = AcGiDraw::kTopCenter; else if (m_nTextAlign == kAtStart) // 起端对齐 nAlign = (m_nTextBaseLen < 0.0 ? AcGiDraw::kTopRight : nAlign); else // 末端对齐 nAlign = (m_nTextBaseLen < 0.0 ? nAlign : AcGiDraw::kTopRight); text.SetAlignment(nAlign); // sg add 090724,率先解决坐标文字,线上、下文字距离文字基线距离相等的问题 if (!m_bSymbMultiLeader) { ADSGePoint3d ptMin, ptMax; text.SetLayoutRotation(0.0); // 获得外包框的时候,一定要不考虑布局转角、文字转角 text.GetExtents2d(ptMin, ptMax); double dTmp = 0; // sg add 090819,防止批量转旧时,无法得到文字外包围框 if (ptMin != ADSGePoint3d() || ptMax != ADSGePoint3d()) { dTmp = ptLoc.y - ptMax.y; } text.SetLayoutRotation(m_nLayoutRotation); ptLoc = GetText2Pt(); ADSGePoint3d ptDraw = ptLoc; ads_polar(ptLoc, m_nLayoutRotation + PI / 2, dTmp, ptDraw); text.SetLocation(ptDraw); } } else // m_sText2为多行文字 { ((AecXDbMText &)text).SetPageWidth(GetPageWidth2(FALSE), FALSE); // 页宽 ((AecXDbMText &)text).SetLineSpace(nText2Base, FALSE); // 行间距 text.SetAlignment(AcGiDraw::kLeft); // 对齐方式 } PushProperty vProp(&text, dc); //if (dc.IsFullExplode()) // text.ExplodeOrDraw2d(dc); //else // dc.DrawEntity(text); DrawBaseEx(dc, text); delete pText; } return Acad::eOk; } // sg add 110301,支持统一标高 bool AecXDbSymbMultiLeader::UnifyElevation(double dElevation) { AssertWriteEnabled(); m_lstVertexes.SetElevation(dElevation); m_ptLeader.z = dElevation; m_ptLeaderDirection.z = dElevation; return true; } int AecXDbSymbMultiLeader::ConvertText(TConvertTextPtr ptr, void *pData) { AssertWriteEnabled(); TCString sText; int nRet = ptr(m_sText1, sText, pData); if (nRet == RTNORM) { m_sText1 = sText; } int nRet1 = ptr(m_sText2, sText, pData); if (nRet1 == RTNORM) { m_sText2 = sText; } else if (nRet1 == RTERROR) nRet = nRet1; return nRet; } BOOL AecXDbSymbMultiLeader::GetText(Adesk::UInt32 cookies, AecXDbText &text) const { if (cookies > 1) return FALSE; text.setPropertiesFrom(this); text.SetRotation(0); text.SetHeight(m_nTextHeight); text.SetStyleId(m_idTextStyle); ADSGePoint3d ptLoc; if (cookies == 0) // 线上文字 { ptLoc = GetTextPt(); text.SetText(m_sText1); if (IsUpText()) // 单行文字 { if (m_bSideText) // 注:该变量未使用 text.SetAlignment(m_nTextBaseLen < 0.0 ? AcGiDraw::kMiddleLeft : AcGiDraw::kMiddleRight); else { AcGiDraw::TextAlignment nAlign = AcGiDraw::kBottomLeft; if (m_nTextAlign == kAtMiddle) // 居中对齐 nAlign = AcGiDraw::kBottomCenter; else if (m_nTextAlign == kAtStart) // 起端对齐 nAlign = (m_nTextBaseLen < 0.0 ? AcGiDraw::kBottomRight : nAlign); else // 末端对齐 nAlign = (m_nTextBaseLen < 0.0 ? nAlign : AcGiDraw::kBottomRight); text.SetAlignment(nAlign); } } else // 多行文字 text.SetAlignment(AcGiDraw::kLeft); } else // 线下文字 { ptLoc = GetText2Pt(); text.SetText(m_sText2); if (IsDownText()) // 单行文字 { AcGiDraw::TextAlignment nAlign = AcGiDraw::kTopLeft; if (m_nTextAlign == kAtMiddle) // 居中对齐 nAlign = AcGiDraw::kTopCenter; else if (m_nTextAlign == kAtStart) // 起端对齐 nAlign = (m_nTextBaseLen < 0.0 ? AcGiDraw::kTopRight : nAlign); else // 末端对齐 nAlign = (m_nTextBaseLen < 0.0 ? nAlign : AcGiDraw::kTopRight); text.SetAlignment(nAlign); } else // 多行文字 text.SetAlignment(AcGiDraw::kLeft); } text.SetLocation(ptLoc); return TRUE; } // 返回发现的位置,同时posStart往前移动(以便继续找下一个使用), TextPosition AecXDbSymbMultiLeader::FindSubText(const TCHAR *sSubText, TextPosition &posStart, TextRange *pRange) const { TextPosition pos; if (!sSubText || !sSubText[0]) return pos; TextPosition posNext = posStart; double dRatio = GetText2BaseRatio(FALSE, TRUE); while (1) { TextPosition posFind; int nCookies = posNext.m_nCookies; // sg modify 090409,兼顾单行、多行文字 if (nCookies == 0) // 线上文字 { if (IsUpText()) // 单行文字 { AecXDbText text; text.SetPScale(GetPScale()); if (!GetText(nCookies, text)) break; posFind = text.FindSubText(sSubText, posNext, pRange); } else // 多行文字 { AecXDbMText mText; ((AecXDbMText &)mText).SetLineSpace(dRatio, FALSE); ((AecXDbMText &)mText).SetPageWidth(GetPageWidth(FALSE), FALSE); if (!GetText(nCookies, mText)) break; posFind = mText.FindSubText(sSubText, posNext, pRange); } } else // 线下文字 { if (IsDownText()) // 单行文字 { AecXDbText text; text.SetPScale(GetPScale()); if (!GetText(nCookies, text)) break; posFind = text.FindSubText(sSubText, posNext, pRange); } else // 多行文字 { AecXDbMText mText; double dPageWidth = GetPageWidth2(FALSE); ((AecXDbMText &)mText).SetPageWidth(dPageWidth, FALSE); ((AecXDbMText &)mText).SetLineSpace(dRatio, FALSE); if (!GetText(nCookies, mText)) break; posFind = mText.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 AecXDbSymbMultiLeader::ReplaceSubText(const TextPosition &posRep, const TCHAR *sRepText, TextRange *pRange) { AssertWriteEnabled(); TextPosition posNext; double dRatio = GetText2BaseRatio(FALSE, TRUE); int cookies = posRep.m_nCookies; // sg modify 090409,兼顾单行、多行文字 if (cookies == 0) // 线上文字 { if (IsUpText()) // 单行文字 { AecXDbText text; text.SetPScale(GetPScale()); if (!sRepText || !GetText(cookies, text)) return posNext; posNext = text.ReplaceSubText(posRep, sRepText, pRange); SetText1(text.GetText()); } else // 多行文字 { AecXDbMText mText; ((AecXDbMText &)mText).SetLineSpace(dRatio, FALSE); ((AecXDbMText &)mText).SetPageWidth(GetPageWidth(FALSE), FALSE); if (!sRepText || !GetText(cookies, mText)) return posNext; posNext = mText.ReplaceSubText(posRep, sRepText, pRange); SetText1(mText.GetText()); } } else // 线下文字 { if (IsDownText()) // 单行文字 { AecXDbText text; text.SetPScale(GetPScale()); if (!sRepText || !GetText(cookies, text)) return posNext; posNext = text.ReplaceSubText(posRep, sRepText, pRange); SetText2(text.GetText()); } else // 多行文字 { AecXDbMText mText; double dPageWidth = GetPageWidth2(FALSE); ((AecXDbMText &)mText).SetPageWidth(dPageWidth, FALSE); ((AecXDbMText &)mText).SetLineSpace(dRatio, FALSE); if (!sRepText || !GetText(cookies, mText)) return posNext; posNext = mText.ReplaceSubText(posRep, sRepText, pRange); SetText2(mText.GetText()); } } if (!posNext) { posNext.m_nCookies = posRep.m_nCookies + 1; posNext.m_nTextPos = 0; } return posNext; } /* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */ void AecXDbSymbMultiLeader::GetTips(PtrList &lstInfo) const { lstInfo.Append(new ObjInfoUnit(_T("对象类型"), _T("引出标注"))); lstInfo.Append(new ObjInfoUnit(_T("文字1"), m_sText1)); lstInfo.Append(new ObjInfoUnit(_T("文字2"), m_sText2)); 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)); } double AecXDbSymbMultiLeader::GetMinTextBaseLen(BOOL bAsPaperUnit) const { if (!m_sText1 && !m_sText2) return 0.0; AecXDbText text; text.SetPScale(GetPScale()); text.setPropertiesFrom(this); text.SetHeight(m_nTextHeight); text.SetStyleId(m_idTextStyle); double nVal = 0.0; if (!!m_sText1) { text.SetText(m_sText1); ADSGePoint3d ptExt = text.GetExtents(); nVal = max(nVal, ptExt.x); } if (!!m_sText2) { text.SetText(m_sText2); ADSGePoint3d ptExt = text.GetExtents(); nVal = max(nVal, ptExt.x); } if (bAsPaperUnit) nVal /= GetPScale(); return nVal; } double AecXDbSymbMultiLeader::GetDefaultTextBaseLen(BOOL bAsPaperUnit) const { double nVal = 10.0; if (!bAsPaperUnit) nVal *= GetPScale(); return max(nVal, GetMinTextBaseLen(bAsPaperUnit)); } ADSGePoint3d AecXDbSymbMultiLeader::GetLeaderPoint() const { return m_ptLeader; } const TCHAR * AecXDbSymbMultiLeader::GetText1() const { return (const TCHAR *)m_sText1; } const TCHAR * AecXDbSymbMultiLeader::GetText2() const { return (const TCHAR *)m_sText2; } BOOL AecXDbSymbMultiLeader::IsSideText() const { return m_bSideText; } double AecXDbSymbMultiLeader::GetTextBaseLen(BOOL bAsPaperUnit) const { double val = m_nTextBaseLen; if (!bAsPaperUnit) val *= GetPScale(); return val; } ADSGePoint3d AecXDbSymbMultiLeader::GetTextBasePoint() const { ADSGePoint3d pt; ads_polar(m_ptLeader, 0.0, GetTextBaseLen(FALSE), pt); return pt; } void AecXDbSymbMultiLeader::GetLeaderVertexes(ADSGePointList &pts) const { pts = m_lstVertexes; } AecXDbSymbMultiLeader::TArrowStyle AecXDbSymbMultiLeader::GetArrow() const { return m_arrow; } double AecXDbSymbMultiLeader::GetArrowSize(BOOL bAsPaperUnit) const { double nSize = m_nArrowSize; if (!bAsPaperUnit) nSize *= GetPScale(); return nSize; } // sg modify 120104,新增加的参数用于判断是否要给m_ptLeaderDirection赋值,内部数据用于引线平行样式 //void AecXDbSymbMultiLeader::SetLeaderVertexes(const ADSGePointList &pts, BOOL bUpdateLeaderDirection) void AecXDbSymbMultiLeader::SetLeaderVertexes(const ADSGePointList &pts, BOOL bUpdateLeaderDirection) { AssertWriteEnabled(); m_lstVertexes = pts; // sg add 120104,更新m_ptLeaderDirection if (bUpdateLeaderDirection) { if (m_lstVertexes.Length() > 0) { m_ptLeaderDirection = m_lstVertexes[0]->AsAcGePoint3d(); } } } void AecXDbSymbMultiLeader::SetSideText(BOOL bTrue) { AssertWriteEnabled(); m_bSideText = (bTrue != 0); } void AecXDbSymbMultiLeader::SetTextBaseLen(double val, BOOL bAsPaperUnit) { AssertWriteEnabled(); // add by lxb on 2012/01/05,防止基线长度夹点和引线端点夹点重合 if (fabs(val) < 1E-6) { return; } m_nTextBaseLen = val; if (!bAsPaperUnit) m_nTextBaseLen /= GetPScale(); } void AecXDbSymbMultiLeader::SetArrow(AecXDbSymbMultiLeader::TArrowStyle ar) { AssertWriteEnabled(); m_arrow = ar; } void AecXDbSymbMultiLeader::SetLeaderPoint(ADSGePoint3d pt) { AssertWriteEnabled(); m_ptLeader = pt; } void AecXDbSymbMultiLeader::SetText2(const TCHAR *pszText) { AssertWriteEnabled(); m_sText2 = pszText; } void AecXDbSymbMultiLeader::SetText1(const TCHAR *pszText) { AssertWriteEnabled(); m_sText1 = pszText; } void AecXDbSymbMultiLeader::SetArrowSize(double nSize, BOOL bAsPaperUnit) { AssertWriteEnabled(); m_nArrowSize = nSize; if (!bAsPaperUnit) m_nArrowSize /= GetPScale(); } double AecXDbSymbMultiLeader::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 AecXDbSymbMultiLeader::SetText2BaseRatio(double dVal, BOOL bAsPaperUnit) { AssertWriteEnabled(); m_dText2BaseRatio = dVal; // 系数 if (!bAsPaperUnit) { m_dText2BaseRatio /= GetPScale(); } } AecXDbSymbMultiLeader::TSymbMLTextAlign AecXDbSymbMultiLeader::GetTextAlign() const { return m_nTextAlign; } void AecXDbSymbMultiLeader::SetTextAlign(TSymbMLTextAlign align) { AssertWriteEnabled(); m_nTextAlign = align; } void AecXDbSymbMultiLeader::SetPageWidth(double dVal, BOOL bAsPaperUnit) { AssertWriteEnabled(); m_dPageWidth = dVal; if (!bAsPaperUnit) { m_dPageWidth /= GetPScale(); } } double AecXDbSymbMultiLeader::GetPageWidth(BOOL bAsPaperUnit) const { double dVal = m_dPageWidth; if (fabs(dVal) < 1.0E-5) { AecXDbText text; text.SetPScale(GetPScale()); text.setPropertiesFrom(this); text.SetHeight(m_nTextHeight); text.SetStyleId(m_idTextStyle); text.SetText(m_sText1); ADSGePoint3d ptExt = text.GetExtents(); dVal = ptExt.x; if (bAsPaperUnit) dVal /= GetPScale(); return dVal; } if (!bAsPaperUnit) dVal *= GetPScale(); return dVal; } void AecXDbSymbMultiLeader::SetPageWidth2(double dVal, BOOL bAsPaperUnit) { AssertWriteEnabled(); double dPageWidth = dVal; if (!bAsPaperUnit) dPageWidth /= GetPScale(); EntityFields &fd = Fields(); fd.SFD(_T("线下文字页宽"), dPageWidth); } // sg add 090410,线下文字页宽,动态数据 double AecXDbSymbMultiLeader::GetPageWidth2(BOOL bAsPaperUnit) const { assertReadEnabled(); double dPageWidth(0.0); const EntityFields &fd = GetFields(); fd.GFD(_T("线下文字页宽"), dPageWidth); if (fabs(dPageWidth) < 1.0E-5) { AecXDbText text; text.SetPScale(GetPScale()); text.setPropertiesFrom(this); text.SetHeight(m_nTextHeight); text.SetStyleId(m_idTextStyle); text.SetText(m_sText2); ADSGePoint3d ptExt = text.GetExtents(); dPageWidth = ptExt.x; if (bAsPaperUnit) dPageWidth /= GetPScale(); return dPageWidth; } if (!bAsPaperUnit) dPageWidth *= GetPScale(); return dPageWidth; } // sg add 090413 BOOL AecXDbSymbMultiLeader::IsUpText() const // 线上文字,是否是单行文字 { return fabs(m_dPageWidth) < 1.0E-5; } BOOL AecXDbSymbMultiLeader::IsDownText() const // 线下文字,是否是单行文字 { double dPageWidth(0.0); const EntityFields &fd = GetFields(); fd.GFD(_T("线下文字页宽"), dPageWidth); return fabs(dPageWidth) < 1.0E-5; } // sg add 090413,分别计算两段文字位置点 ADSGePoint3d AecXDbSymbMultiLeader::GetTextPt(BOOL bUseLayout) const { // sg add 090724,如果是坐标标注,忽略引线距离末端距离 double dDistRatio = GlobalFunc::DocGetMultiLeaderDistRatio(); if (!m_bSymbMultiLeader) dDistRatio = 0; double dDist = dDistRatio * m_nTextHeight * GetPScale(), dSign = 1.0; if (fabs(m_nTextBaseLen) > 1.0E-5) dSign = m_nTextBaseLen / (fabs(m_nTextBaseLen)); dDist *= dSign; // sg add 090724,调整坐标上下文字距离基线距离 double dLayoutRotation = m_nLayoutRotation; if (!m_bSymbMultiLeader) { if (!bUseLayout) dLayoutRotation = 0; } ADSGePoint3d ptEnd, ptTemp; ads_polar(m_ptLeader, dLayoutRotation, GetTextBaseLen(FALSE), ptEnd); // 文字基线 if (m_nTextAlign == kAtMiddle) // 居中对齐 { Midpoint(m_ptLeader, ptEnd, ptTemp); } else if (m_nTextAlign == kAtStart) // 起端对齐 ads_polar(m_ptLeader, dLayoutRotation, dDist, ptTemp); else // 末端对齐 ads_polar(ptEnd, dLayoutRotation, -dDist, ptTemp); ADSGePoint3d ptRet = ptTemp; double nText2Base = GetText2BaseRatio(FALSE, TRUE); // 距基线距离 if (!m_sText1 && g_Option::instance().g_bExplodeSubText) // 不绘制线上文字 { ads_polar(ptRet, dLayoutRotation + PI / 2, nText2Base, ptRet); return ptRet; } if (IsUpText()) // m_sText1为单行文字 { if (m_bSideText) // 注:本段代码实际上未使用 { if (m_nTextBaseLen < 0.0) ads_polar(ptRet, PI + dLayoutRotation, nText2Base, ptRet); else ads_polar(ptRet, dLayoutRotation, nText2Base, ptRet); } else ads_polar(ptRet, dLayoutRotation + PI / 2, nText2Base, ptRet); } else // m_sText1为多行文字 { AecXDbMText text; text.setPropertiesFrom(this); text.SetHeight(m_nTextHeight); text.SetStyleId(m_idTextStyle); text.SetText(m_sText1); text.SetAlignment(AcGiDraw::kLeft); double dPageWidth = GetPageWidth(FALSE); ((AecXDbMText &)text).SetLineSpace(nText2Base, FALSE); // 行间距 ((AecXDbMText &)text).SetPageWidth(dPageWidth, FALSE); // 页宽 Vector3D vtExt = text.GetExtents(); ads_polar(ptRet, m_nLayoutRotation + PI / 2, nText2Base + vtExt.y, ptRet); if (m_nTextAlign == kAtMiddle) // 居中对齐 ads_polar(ptRet, m_nLayoutRotation, -dPageWidth * 0.5, ptRet); else if ((m_nTextBaseLen < 0.0 && m_nTextAlign == kAtStart) || (m_nTextBaseLen > 0.0 && m_nTextAlign == kAtEnd)) ads_polar(ptRet, m_nLayoutRotation, -dPageWidth, ptRet); } return ptRet; } ADSGePoint3d AecXDbSymbMultiLeader::GetText2Pt(BOOL bUseLayout) const { // sg add 090724,如果是坐标标注,忽略引线距离末端距离 double dDistRatio = GlobalFunc::DocGetMultiLeaderDistRatio(); if (!m_bSymbMultiLeader) dDistRatio = 0; double dDist = dDistRatio * m_nTextHeight * GetPScale(), dSign = 1.0; if (fabs(m_nTextBaseLen) > 1.0E-5) dSign = m_nTextBaseLen / (fabs(m_nTextBaseLen)); dDist *= dSign; // sg add 090724,调整坐标上下文字距离基线距离 double dLayoutRotation = m_nLayoutRotation; if (!m_bSymbMultiLeader) { if (!bUseLayout) dLayoutRotation = 0; } ADSGePoint3d ptEnd, ptTemp; ads_polar(m_ptLeader, dLayoutRotation, GetTextBaseLen(FALSE), ptEnd); // 文字基线 if (m_nTextAlign == kAtMiddle) // 居中对齐 { Midpoint(m_ptLeader, ptEnd, ptTemp); } else if (m_nTextAlign == kAtStart) // 起端对齐 ads_polar(m_ptLeader, dLayoutRotation, dDist, ptTemp); else // 末端对齐 ads_polar(ptEnd, dLayoutRotation, -dDist, ptTemp); ADSGePoint3d ptRet = ptTemp; double nText2Base = GetText2BaseRatio(FALSE, TRUE); // 距基线距离 ads_polar(ptRet, dLayoutRotation - PI / 2, nText2Base, ptRet); if (!m_sText2 && g_Option::instance().g_bExplodeSubText) // 不绘制线下文字 return ptRet; if (!IsDownText()) // m_sText2为多行文字 { double dPageWidth = GetPageWidth2(FALSE); if (m_nTextAlign == kAtMiddle) // 居中对齐 ads_polar(ptRet, dLayoutRotation, -dPageWidth * 0.5, ptRet); else if ((m_nTextBaseLen < 0.0 && m_nTextAlign == kAtStart) || (m_nTextBaseLen > 0.0 && m_nTextAlign == kAtEnd)) ads_polar(ptRet, dLayoutRotation, -dPageWidth, ptRet); } return ptRet; } // sg add 090720,8.0正式版增加的临时变量,不保存,处理坐标标注的绘制问题 void AecXDbSymbMultiLeader::SetSymbMultiLeader(BOOL bSymbMultiLeader) { AssertWriteEnabled(); m_bSymbMultiLeader = bSymbMultiLeader; } // add by lxb on 111229,引线是否平行接口 void AecXDbSymbMultiLeader::SetLeaderParalle(BOOL bParallel) { AssertWriteEnabled(); if (bParallel) { m_nLeaderFlag |= SMLF_PARALLEL; } else { m_nLeaderFlag &= ~SMLF_PARALLEL; } } BOOL AecXDbSymbMultiLeader::IsLeaderParall() const { return((m_nLeaderFlag & SMLF_PARALLEL) != 0); } // 获得引线平行时的平行方向点 void AecXDbSymbMultiLeader::SetLeaderDirection(ADSGePoint3d &pt) { AssertWriteEnabled(); m_ptLeaderDirection = pt; } ADSGePoint3d AecXDbSymbMultiLeader::GetLeaderDirection() const { return m_ptLeaderDirection; }