#include "stdafx.h" #include "PushMemVar.h" #include "AcDbObjectPtr.h" #include "AecDbText.h" #include "AecDbSymbDrawingIndex.h" #include "ObjInfoUnit.h" #include "globalDefine.h" #include "globalFunc.h" #include "GeRectAngle.h" #include "GeCurveInline.h" #include "PushProperty.h" #include "DimOptionData.h" AcDbObjectId InitTextStyle(const TCHAR *pszStyle, AcDbDatabase *pDb = NULL); AcDbObjectId InitTextStyle(TTextStyle ts, AcDbDatabase *pDb = NULL); int GetTextColorByTs(TTextStyle ts); const Adesk::UInt8 AecXDbSymbDrawingIndex::g_nVersion = 2; // sg modify 081210 ACRX_DXF_DEFINE_MEMBERS(AecXDbSymbDrawingIndex, AecXDbSymbWithText, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent, 1, AEC_SUOYINTUMING, "AEC_SUOYINTUMING|缺乏上华解释器, 请下载上华软件|网址: www.shanghuasoft.com"); AecXDbSymbDrawingIndex::AecXDbSymbDrawingIndex() { // m_nRadius = 7.0; // m_dScaleXDist = 9.0; // 仿照TArch3.8,设置为定值 m_nRadius = g_DimOption::instance().g_dSymbDrawingIndexDia * 0.5; // 从高级选项中读取默认值 m_dScaleXDist = (9.0 * m_nRadius) / 7.0; m_nLineWidth = 0.5; // sg modify 120106,给“TS_INDEXSCALE”独立出来一个文字样式 // m_idScaleStyle = InitTextStyle(TS_LABEL); // sg add 081210 m_idScaleStyle = InitTextStyle(TS_INDEXSCALE); // sg add 081210 m_szScaleText = _T("1:100"); m_dScaleTextHeight = 3.5; m_bDrawScale = FALSE; // sg add 090108,sg add 090115从TDbConfig中读取,但不随TDbConfig // sg modify 090723,根据HX提出的需求,默认的索引图名,不但要从TDbConfig中读取默认值,还要随TDbConfig变化 // m_bOldStyle = DocGetOldDrawingIndex(); // m_dTextRatio = DocGetDITextRatio(); m_bOldStyle = 2; m_dTextRatio = 0.0; m_bSymbText = TRUE; // sg add 120110,比例文字距圆心的Y方向距离 m_dScaleYDist = -m_nRadius; m_colorText = GetTextColorByTs(TS_INDEXSCALE); } AecXDbSymbDrawingIndex::~AecXDbSymbDrawingIndex() { } BOOL AecXDbSymbDrawingIndex::IsValid() const { //BOOL bRet = AecXDbSymbWithText::IsValid(); //if (!bRet) // return bRet; BOOL bRet = (m_nRadius > 0); return bRet; } // //Acad::ErrorStatus //AecXDbSymbDrawingIndex::subGetClassID(CLSID* pClsid) const //{ // *pClsid = CLSID_ComSymbDrawingIndex; // return Acad::eOk; //} const TCHAR* AecXDbSymbDrawingIndex::GetDefaultLayer()const { extern TCHAR* LAY_INDEX_DIM; return LAY_INDEX_DIM; } // 提供对格式刷的支持 void AecXDbSymbDrawingIndex::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag) { AssertWriteEnabled(); AecXDbSymbWithText::CopyPropertiesFrom(pSrcEntity, gMatchFlag); AecXDbSymbDrawingIndex *pSrc = AecXDbSymbDrawingIndex::cast(pSrcEntity); if (pSrc != NULL) { m_nRadius = pSrc->m_nRadius; m_nLineWidth = pSrc->m_nLineWidth; } } // 从DWG读入数据: Acad::ErrorStatus AecXDbSymbDrawingIndex::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((AcGePoint2d *)&m_ptCenter); pFiler->readItem(&m_nRadius); pFiler->readItem(&m_nLineWidth); GlobalFunc::ReadString(pFiler, m_sIndexLabel); GlobalFunc::ReadString(pFiler, m_sDrawingLabel); if (nVer > 1) // sg add 081210,8.0中的nVer为2,以前版本为1 { GlobalFunc::ReadString(pFiler, m_szScaleText); pFiler->readItem(&m_idScaleStyle); pFiler->readItem(&m_dScaleTextHeight); pFiler->readItem(&m_dScaleXDist); pFiler->readItem(&m_bDrawScale); pFiler->readItem(&m_bOldStyle); pFiler->readItem(&m_dTextRatio); } else // 8.0以前版本 { m_szScaleText = _T("1:100"); // m_dScaleXDist = 9.0; m_dScaleXDist = (9.0 * m_nRadius) / 7.0; // 考虑号圈新增默认值,改变默认位置,变成系数 m_dScaleTextHeight = 3.5; m_bDrawScale = FALSE; // sg modify 120106,给“TS_INDEXSCALE”独立出来一个文字样式 // m_idScaleStyle = InitTextStyle(TS_LABEL, database()); m_idScaleStyle = InitTextStyle(TS_INDEXSCALE, database()); m_bOldStyle = 2; // 随TDbConfig m_dTextRatio = 0.0; } return pFiler->filerStatus(); } Acad::ErrorStatus AecXDbSymbDrawingIndex::dwgOutFields(AcDbDwgFiler* pFiler) const { assertReadEnabled(); Acad::ErrorStatus es = AecXDbSymbWithText::dwgOutFields(pFiler); if (es != Acad::eOk) return es; pFiler->writeItem(g_nVersion); pFiler->writeItem((const AcGePoint2d &)m_ptCenter); pFiler->writeItem(m_nRadius); pFiler->writeItem(m_nLineWidth); pFiler->writeString(m_sIndexLabel); pFiler->writeString(m_sDrawingLabel); pFiler->writeItem(m_szScaleText); pFiler->writeItem(m_idScaleStyle); pFiler->writeItem(m_dScaleTextHeight); pFiler->writeItem(m_dScaleXDist); pFiler->writeItem(m_bDrawScale); pFiler->writeItem(m_bOldStyle); pFiler->writeItem(m_dTextRatio); return pFiler->filerStatus(); } Acad::ErrorStatus AecXDbSymbDrawingIndex::dxfInFields(AcDbDxfFiler* pFiler) { return AecXDbSymbWithText::dxfInFields(pFiler); } Acad::ErrorStatus AecXDbSymbDrawingIndex::dxfOutFields(AcDbDxfFiler* pFiler) const { return AecXDbSymbWithText::dxfOutFields(pFiler); } // ----------------------------------------------------------------------- // Active when being rotated, scaled, moved, etc. // Scale is disabled here Acad::ErrorStatus AecXDbSymbDrawingIndex::subTransformBy(const AcGeMatrix3d& xform) { AssertWriteEnabled(); AecXDbSymbWithText::subTransformBy(xform); ads_matrix mat; GlobalFunc::AsAdsMatrix(xform, mat); m_ptCenter.TransformBy(mat); if (xform.isUniScaledOrtho()) { m_nRadius *= xform.scale(); } return Acad::eOk; } // Overriden functions for edit Acad::ErrorStatus AecXDbSymbDrawingIndex::subGetGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const { assertReadEnabled(); return subGetStretchPoints(gripPoints); } Acad::ErrorStatus AecXDbSymbDrawingIndex::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 AecXDbSymbDrawingIndex::subGetStretchPoints(AcGePoint3dArray & gripPoints) const { assertReadEnabled(); gripPoints.append(m_ptCenter); // sg add 120110,比例文字提供一个夹点 if (m_bDrawScale) { ADSGePoint3d ptScale = GetScaleTextPt(); gripPoints.append(ptScale); } return Acad::eOk; } // 取得夹点说明 Acad::ErrorStatus AecXDbSymbDrawingIndex::GetGripText(int idx, CString &cs) const { Acad::ErrorStatus es = Acad::eOk; if (idx == 0) cs = _T("移动索引图名"); else if (idx == 1) cs = _T("移动比例位置"); return es; } // sg add 120110,根据9.0需求,增加了一个夹点,需要重载这2个函数 Acad::ErrorStatus AecXDbSymbDrawingIndex::subMoveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset) { AssertWriteEnabled(); if (indices.contains(0) && indices.contains(1)) { AcGeMatrix3d mat; mat.setToTranslation(offset); return subTransformBy(mat); } ADSGePoint3d vtOffset(offset[0], offset[1]); for (int i = 0; i < indices.length(); i++) { int idx = indices[i]; if (idx == 0) // 移动索引图名 { m_ptCenter += vtOffset; } else if (idx == 1) // 移动比例位置 { ADSGePoint3d pt = GetScaleTextPt(); pt += vtOffset; SetScaleTextPt(pt); } } return Acad::eOk; } Acad::ErrorStatus AecXDbSymbDrawingIndex::subMoveStretchPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset) { AssertWriteEnabled(); return subMoveGripPointsAt(indices, offset); } BOOL g_bDrawAxisLabel = FALSE; // 国际分轴号 // sg add 081222,计算最大的文字宽度、高度 void AecXDbSymbDrawingIndex::GetTextExtends(const TCHAR *sText, double &dX, double &dY, BOOL bDrawingLabel) const { double dWidthFactor(1.0); // 中文字体宽高比 OPENOBJ_BEGIN(m_idTextStyle, AcDb::kForRead, AcDbTextStyleTableRecord, pStyle); if (pStyle != NULL) { dWidthFactor = pStyle->xScale(); } OPENOBJ_END(); CString csTmpText = sText; csTmpText.TrimLeft(); csTmpText.TrimRight(); if (csTmpText.IsEmpty() || _tcscmp(sText, _T("-")) == 0) { csTmpText = _T("2"); } // sg add 110209,获得文字高度 double dHeigh = m_nTextHeight * GetPScale(), dRadius = GetRadius(FALSE) * GetTextRatio(); int nTrueStyle = GetTrueTextStyle(); if (nTrueStyle != 0) // 出圈样式 { dHeigh = dRadius * 2.0; if (g_bDrawAxisLabel || bDrawingLabel) { dHeigh *= 0.5; } } AcDbText text; text.setPosition(ADSGePoint3d(0, 0)); text.setTextStyle(m_idTextStyle); text.setTextString(csTmpText); // text.setHeight(m_nTextHeight*GetPScale()); text.setHeight(dHeigh); text.setRotation(0); text.setWidthFactor(dWidthFactor); AcDbExtents extents; ADSGePoint3d ptMax, ptMin; if (text.getGeomExtents(extents) == Acad::eOk) // 外包矩形,一般情况下都是eOk { ptMax = extents.maxPoint(); ptMin = extents.minPoint(); } else // sg add 110802,批量转旧时候,获得外包围盒有时候会不成功 { AcGiTextStyle style; fromAcDbTextStyle(style, m_idTextStyle); style.extentsBox(csTmpText, FALSE, csTmpText.GetLength(), FALSE, ptMin, ptMax); } if (nTrueStyle != 0) // sg add 110209,出圈样式 { dX = ptMax.x - ptMin.x; dY = dHeigh; if (!g_bDrawAxisLabel && !bDrawingLabel) { dX *= 0.5; dY *= 0.5; } return; } // 8.0起,文字最大不超过圆的比例可设置 double dFactor = (ptMax.x - ptMin.x) / (ptMax.y - ptMin.y); // 宽高比例 dY = dRadius / sqrt(1 + dFactor * dFactor); // 调整大小,圈内只有一行文字时 if (g_bDrawAxisLabel && bDrawingLabel) { dY = dRadius / sqrt(1.0431 + 0.9656 * dFactor + dFactor * dFactor); // 国际分轴号 } else if (bDrawingLabel) { dY = dRadius / sqrt(1.21 + 0.25 * dFactor * dFactor); // 圈内有两行文字时 } dX = dY * dFactor; } Acad::ErrorStatus AecXDbSymbDrawingIndex::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; // 绘制圆圈 double radius = GetRadius(FALSE); double nThick = m_nLineWidth * GetPScale(); GeCurveSegment seg; seg = GeCircle(m_ptCenter, radius); if (nThick > g_Option::instance()._DIST_SNAP && !!objectId()) // 加粗 { AcDbPolyline pline; pline.addVertexAt(0, seg.StartPoint(), 1.0); pline.addVertexAt(1, seg.EndPoint(), 1.0); pline.setConstantWidth(nThick); pline.setClosed(Adesk::kTrue); //dc.Polyline(pline); DrawPline(dc, pline); } else // 不加粗 { //dc << GeCircle(m_ptCenter, radius); DrawCircle(dc, GeCircle(m_ptCenter, radius)); } ads_matrix matRot; m_ptCenter.GetRotationMatrix(m_nLayoutRotation, matRot); dc.SetTextStyle(m_idTextStyle); //dc.SetRotation(m_nLayoutRotation); // sg modify 110209,支持圆圈文字出圈样式 // BOOL bOldStyle = IsOldStyle(); int nTrueStyle = GetTrueTextStyle(); if (!m_sDrawingLabel && !g_Option::instance().g_bOsnapExpl) // 圆圈文字内只有一个单行文字的情况 { ADSGePoint3d pt1, pt2; double nTextHeight(0); // if (bOldStyle) if (nTrueStyle == 1) // 8.0以前样式 { nTextHeight = radius / sin(PI / 4.0); pt1 = m_ptCenter - ADSGePoint3d(0.8 * nTextHeight / 2.0, 0.8 * nTextHeight / 2.0); pt2 = m_ptCenter + ADSGePoint3d(0.8 * nTextHeight / 2.0, -0.8 * nTextHeight / 2.0); } else // 8.0新样式,8.5出圈文字样式 { double dX(0); GetTextExtends(m_sIndexLabel, dX, nTextHeight, FALSE); // 获取指定文字的最大尺寸 pt1 = m_ptCenter - ADSGePoint3d(dX, nTextHeight); pt2 = m_ptCenter + ADSGePoint3d(dX, -nTextHeight); } if (!!m_sIndexLabel || g_Option::instance().g_bExplodeSubText) { AcDbObjectId idOld = dc.GetLayerId(); int nColorOld = dc.GetColor(); // sg modify 090608,将文字和标注放在同一层,文字的颜色为白色 if (!m_bSymbText && !m_idTextLayer.isNull()) // 轴号 dc.SetColorLayer(colorIndex(), m_idTextLayer); else if (m_bSymbText) // 索引图名、索引符号 { //if (dc.IsExportTch4()) // 炸开 //{ // if (g_nSymbTextT3Layer == 1 && !m_idTextLayer.isNull()) // dc.SetColorLayer(colorIndex(), m_idTextLayer); // else // dc.SetColor(m_colorText); //} //else // 绘制 dc.SetColor(m_colorText); } if (IsLayoutRotated()) { pt1.TransformBy(matRot); pt2.TransformBy(matRot); } if (nTrueStyle == 1) // 旧样式 //dc.DrawTextFit(m_sIndexLabel, pt1, pt2, nTextHeight * 0.8, GlobalFunc::GetSymbolName(dc.GetTextStyle())); DrawTextFit(dc, m_sIndexLabel, pt1, pt2, nTextHeight * 0.8, dc.GetTextStyle(), m_colorText); else // 新样式,出圈文字样式样式 //dc.DrawTextFit(m_sIndexLabel, pt1, pt2, nTextHeight * 2, GlobalFunc::GetSymbolName(dc.GetTextStyle())); // 字高为dY的2倍 DrawTextFit(dc, m_sIndexLabel, pt1, pt2, nTextHeight * 2, dc.GetTextStyle(), m_colorText); if (m_bDrawScale) // sg add 081217,增加比例文字 { // pt1 = m_ptCenter + ADSGePoint3d(GetScaleXDist(FALSE), -7*GetPScale()); // sg modify 120110,修改比例文字的位置点,增加了Y方向的距离 // pt1 = m_ptCenter + ADSGePoint3d(GetScaleXDist(FALSE), -m_nRadius*GetPScale()); // if (IsLayoutRotated()) // { // pt1.TransformBy(matRot); // } pt1 = GetScaleTextPt(); // 上面的矩阵变化过程,已经封装在了函数内部 AecXDbText text; text.SetPScale(GetPScale()); text.setPropertiesFrom(this); text.SetHeight(m_dScaleTextHeight); text.SetStyleId(m_idScaleStyle); text.SetText(m_szScaleText); text.SetLocation(pt1); text.SetAlignment(AcGiDraw::kBottomLeft); // sg add 090608,将文字和标注放在同一层,文字的颜色为白色 //if (dc.IsExportTch4()) //{ // // sg add 120313,分解出来的文字的图层和颜色要随“高级选项”中的设置来处理 // // if (!!m_idTextLayer) // if (g_nSymbTextT3Layer == 1 && !!m_idTextLayer) // text.setLayer(m_idTextLayer); // 文字层 // else // text.setColorIndex(m_colorText); // 文字和标注放在同一层,文字的颜色为白色 //} //else text.setColorIndex(m_colorText); PushProperty vProp(&text, dc); //if (dc.IsFullExplode()) // text.ExplodeOrDraw2d(dc); //else // dc.DrawEntity(text); DrawBaseEx(dc, text); } dc.SetLayer(idOld); dc.SetColor(nColorOld); } } else if (g_bDrawAxisLabel && !g_Option::instance().g_bOsnapExpl) // 国标分轴号,轴号专用,sg modify 090610 { GeLine lnSep; ads_polar(m_ptCenter, PI + PI / 4, radius, lnSep.StartPoint()); ads_polar(m_ptCenter, PI / 4, radius, lnSep.EndPoint()); if (IsLayoutRotated()) lnSep.TransformBy(matRot); //dc << lnSep; DrawLine(dc, lnSep); double nTextHeight(0), dY(0); if (nTrueStyle == 1) // 旧样式 { double nAng = atan(2.0); nTextHeight = radius * sin(nAng); } else // 新样式 GetTextExtends(m_sIndexLabel, nTextHeight, dY, TRUE); ADSGePoint3d pt1 = m_ptCenter, pt2 = m_ptCenter; double nSpacer = nTextHeight / 10.0; if (nTrueStyle == 1) // 旧样式 { pt1.x -= radius * 0.7; pt2.x -= radius * 0.2; } else // 新样式 { nSpacer = dY / 5.0; pt1.x -= (0.4828 * dY + nTextHeight); pt2.x -= 0.4828 * dY; } pt1.y -= nSpacer; pt2.y -= nSpacer; AcDbObjectId idOld = dc.GetLayerId(); int nColorOld = dc.GetColor(); // sg modify 090608,将文字和标注放在同一层,文字的颜色为白色 if (!m_bSymbText && !m_idTextLayer.isNull()) // 轴号 dc.SetColorLayer(colorIndex(), m_idTextLayer); else if (m_bSymbText) // 索引图名、索引符号 { //if (dc.IsExportTch4()) // 炸开 //{ // if (g_nSymbTextT3Layer == 1 && !m_idTextLayer.isNull()) // dc.SetColorLayer(colorIndex(), m_idTextLayer); // else // dc.SetColor(m_colorText); //} //else // 绘制 dc.SetColor(m_colorText); } if (!!m_sIndexLabel || g_Option::instance().g_bExplodeSubText) { if (nTrueStyle == 1) // 旧样式 //dc.DrawTextFit(m_sIndexLabel, pt1.TransformAs(matRot), pt2.TransformAs(matRot), nTextHeight * 0.8, GlobalFunc::GetSymbolName(dc.GetTextStyle())); DrawTextFit(dc, m_sIndexLabel, pt1.TransformAs(matRot), pt2.TransformAs(matRot), nTextHeight * 0.8, dc.GetTextStyle(), m_colorText); else // 新样式 //dc.DrawTextFit(m_sIndexLabel, pt1.TransformAs(matRot), pt2.TransformAs(matRot), dY, GlobalFunc::GetSymbolName(dc.GetTextStyle())); DrawTextFit(dc, m_sIndexLabel, pt1.TransformAs(matRot), pt2.TransformAs(matRot), dY, dc.GetTextStyle(), m_colorText); } if (nTrueStyle == 1) // 旧样式 { pt1.x += radius * 0.9; pt2.x += radius * 0.9; pt1.y -= nTextHeight * 0.4 + 2 * nSpacer; pt2.y -= nTextHeight * 0.4 + 2 * nSpacer; } else // 新样式 { GetTextExtends(m_sDrawingLabel, nTextHeight, dY, TRUE); pt1 = m_ptCenter + ADSGePoint3d(0.4828 * dY, -dY * 0.8); pt2 = m_ptCenter + ADSGePoint3d(0.4828 * dY + nTextHeight, -dY * 0.8); } if (IsLayoutRotated()) { pt1.TransformBy(matRot); pt2.TransformBy(matRot); } if (nTrueStyle == 1) // 旧样式 //dc.DrawTextFit(m_sDrawingLabel, pt1, pt2, nTextHeight * 0.8, GlobalFunc::GetSymbolName(dc.GetTextStyle())); DrawTextFit(dc, m_sDrawingLabel, pt1, pt2, nTextHeight * 0.8, dc.GetTextStyle(), m_colorText); else // 新样式 //dc.DrawTextFit(m_sDrawingLabel, pt1, pt2, dY, GlobalFunc::GetSymbolName(dc.GetTextStyle())); DrawTextFit(dc, m_sDrawingLabel, pt1, pt2, dY, dc.GetTextStyle(), m_colorText); dc.SetLayer(idOld); dc.SetColor(nColorOld); } else if (!g_Option::instance().g_bOsnapExpl) // 上、下都有文字的情况 { GeLine lnSep(seg.StartPoint(), seg.EndPoint()); if (IsLayoutRotated()) lnSep.TransformBy(matRot); //dc << lnSep; DrawLine(dc, lnSep); double nTextHeight(0), dY(0); if (nTrueStyle == 1) // 旧样式 { double nAng = atan(2.0); nTextHeight = radius * sin(nAng) * 0.9; } else // 新样式,出圈样式 { GetTextExtends(m_sIndexLabel, nTextHeight, dY, TRUE); } ADSGePoint3d pt1 = m_ptCenter, pt2 = m_ptCenter; pt1.x -= nTextHeight / 2; pt2.x += nTextHeight / 2; double nSpacer(0); if (nTrueStyle == 1) // 旧样式 nSpacer = nTextHeight / 10.0; else // 新样式,出圈样式 { if (GetTextRatio() > 1.0 + 1E-2) // 圆圈文字的系数大于1时 { nSpacer = dY / 5.0; } else if (nTrueStyle == 0) // 新样式 { // sg modify 101119,根据8.5需求,修改新样式,将文字远离基线 nSpacer = (sqrt(radius * radius - 0.25 * nTextHeight * nTextHeight) - dY) * 0.4; } else // ==3,出圈样式 { nSpacer = (radius - dY) * 0.4; } } pt1.y += nSpacer; pt2.y += nSpacer; AcDbObjectId idOld = dc.GetLayerId(); int nColorOld = dc.GetColor(); // sg modify 090608,将文字和标注放在同一层,文字的颜色为白色 if (!m_bSymbText && !m_idTextLayer.isNull()) // 轴号 dc.SetColorLayer(colorIndex(), m_idTextLayer); else if (m_bSymbText) // 索引图名、索引符号 { //if (dc.IsExportTch4()) // 炸开 //{ // if (g_nSymbTextT3Layer == 1 && !m_idTextLayer.isNull()) // dc.SetColorLayer(colorIndex(), m_idTextLayer); // else // dc.SetColor(m_colorText); //} //else // 绘制 dc.SetColor(m_colorText); } if (!!m_sIndexLabel || g_Option::instance().g_bExplodeSubText) { if (nTrueStyle == 1) // 旧样式 //dc.DrawTextFit(m_sIndexLabel, pt1.TransformAs(matRot), pt2.TransformAs(matRot), nTextHeight * 0.8, GlobalFunc::GetSymbolName(dc.GetTextStyle())); DrawTextFit(dc, m_sIndexLabel, pt1.TransformAs(matRot), pt2.TransformAs(matRot), nTextHeight * 0.8, dc.GetTextStyle(), m_colorText); else // 新样式,出圈样式,设置字高为dY //dc.DrawTextFit(m_sIndexLabel, pt1.TransformAs(matRot), pt2.TransformAs(matRot), dY, GlobalFunc::GetSymbolName(dc.GetTextStyle())); DrawTextFit(dc, m_sIndexLabel, pt1.TransformAs(matRot), pt2.TransformAs(matRot), dY, dc.GetTextStyle(), m_colorText); } if (nTrueStyle == 1) // 旧样式 { pt1.y -= nTextHeight * 0.8 + 2 * nSpacer; pt2.y -= nTextHeight * 0.8 + 2 * nSpacer; } else // 新样式,出圈样式 { GetTextExtends(m_sDrawingLabel, nTextHeight, dY, TRUE); // sg modify 101119,根据8.5需求,修改新样式,将文字远离基线 double dTmpNum = dY * 1.2; if (GetTextRatio() < 1.0 + 1E-2) { if (nTrueStyle == 0) // 新样式 { dTmpNum = (sqrt(radius * radius - 0.25 * nTextHeight * nTextHeight) - dY) * 0.4 + dY; } else // ==3,出圈样式 { dTmpNum = (radius - dY) * 0.4 + dY; } } // pt1 = m_ptCenter - ADSGePoint3d(nTextHeight/2, dY*1.2); // pt2 = m_ptCenter + ADSGePoint3d(nTextHeight/2, -dY*1.2); pt1 = m_ptCenter - ADSGePoint3d(nTextHeight / 2, dTmpNum); pt2 = m_ptCenter + ADSGePoint3d(nTextHeight / 2, -dTmpNum); } if (IsLayoutRotated()) { pt1.TransformBy(matRot); pt2.TransformBy(matRot); } if (nTrueStyle == 1) // 旧样式 //dc.DrawTextFit(m_sDrawingLabel, pt1, pt2, nTextHeight * 0.8, GlobalFunc::GetSymbolName(dc.GetTextStyle())); DrawTextFit(dc, m_sDrawingLabel, pt1, pt2, nTextHeight * 0.8, dc.GetTextStyle(), m_colorText); else // 新样式,出圈样式 //dc.DrawTextFit(m_sDrawingLabel, pt1, pt2, dY, GlobalFunc::GetSymbolName(dc.GetTextStyle())); DrawTextFit(dc, m_sDrawingLabel, pt1, pt2, dY, dc.GetTextStyle(), m_colorText); if (m_bDrawScale) // sg add 081217,增加比例文字 { // pt1 = m_ptCenter + ADSGePoint3d(GetScaleXDist(FALSE), -7*GetPScale()); // sg modify 120110,修改比例文字的位置点,增加了Y方向的距离 // pt1 = m_ptCenter + ADSGePoint3d(GetScaleXDist(FALSE), -m_nRadius*GetPScale()); // if (IsLayoutRotated()) // { // pt1.TransformBy(matRot); // } pt1 = GetScaleTextPt(); // 上面的矩阵变化过程,已经封装在了函数内部 AecXDbText text; text.SetPScale(GetPScale()); text.setPropertiesFrom(this); text.SetHeight(m_dScaleTextHeight); text.SetStyleId(m_idScaleStyle); text.SetText(m_szScaleText); text.SetLocation(pt1); text.SetAlignment(AcGiDraw::kBottomLeft); // sg add 090608,将文字和标注放在同一层,文字的颜色为白色 //if (dc.IsExportTch4()) //{ // // sg add 120313,分解出来的文字的图层和颜色要随“高级选项”中的设置来处理 // // if (!!m_idTextLayer) // if (g_nSymbTextT3Layer == 1 && !!m_idTextLayer) // text.setLayer(m_idTextLayer); // 文字层 // else // text.setColorIndex(m_colorText); // 文字和标注放在同一层,文字的颜色为白色 //} //else text.setColorIndex(m_colorText); PushProperty vProp(&text, dc); //if (dc.IsFullExplode()) // text.ExplodeOrDraw2d(dc); //else // dc.DrawEntity(text); DrawBaseEx(dc, text); } dc.SetLayer(idOld); dc.SetColor(nColorOld); } // dc.SetColor(nColorOld); return Acad::eOk; } //Acad::ErrorStatus AecXDbSymbDrawingIndex::DownGradeSave(int nDrawMode, // AcDbVoidPtrArray &entSet, // BOOL *bErase) //{ // // sg add 110621,如果是出圈样式,导出为T3-T8时,全部分解 // BOOL bExplode = GetTrueTextStyle() == 3; // Acad::ErrorStatus es = Acad::eOk; // int nnn = g_nSaveTArchVer; // if (bExplode && g_nSaveTArchVer < 9) // sg add 110621,出圈样式,需要分解 //wlw mod t9 不分解140728 // { // //XPushMemVar vTemp(XExplodeStream::m_bFullExplode, TRUE); // 完全分解 // XPushMemVar vTemp2(XExplodeStream::m_bExportTch4, TRUE); // XExplodeStream dc(entSet); // if (!OnExplodeOrDraw(dc)) // return es; // // // dc.SetPropertiesFrom(this); // if (nDrawMode == DRAW_2D) // es = ExplodeOrDraw2d(dc); // else // es = ExplodeOrDraw3d(dc); // // if (bErase) // *bErase = TRUE; // return es; // } // // // sg add 120110,如果导出到T8,比例文字不在默认位置,也需要分解成一个独立对象 // ADSGePoint3d ptScale = GetScaleTextPt(), // ptDefault = GetDefaultScaleTextLocation(); // bExplode = ptScale.Distance2d(ptDefault) > g_Option::instance()._DIST_SNAP; // // // // 绘制了“比例”,导出为T5/T7/T6时,单独把“比例”部分NEW一个“单行文字” // // sg modify 120110,如果导出到T8,比例文字不在默认位置,也需要分解成一个独立对象 // // if (m_bDrawScale && g_nSaveTArchVer>3 && g_nSaveTArchVer<8) // if ((m_bDrawScale && g_nSaveTArchVer > 3 && g_nSaveTArchVer < 8) || // (m_bDrawScale && g_nSaveTArchVer == 8 && bExplode)) // { // AecXDbSymbDrawingIndex *pIndex = NULL; // sg modify 090325,防止导出T7崩溃 // { // XPushMemVar vTemp(g_nSaveTArchVer, _TCH_VERSION); // pIndex = (AecXDbSymbDrawingIndex*)clone(); // } // // if (m_bDrawScale && g_nSaveTArchVer == 8 && bExplode) // { // pIndex->SetDrawScale(FALSE); // } // entSet.append(pIndex); // nVer=1版的索引图名 // // AcDbObjectId idLayer = pIndex->layerId(); // // ADSGePoint3d ptCen = GetCenter(), // // pt = ptCen + ADSGePoint3d(GetScaleXDist(FALSE), -7*GetPScale()); // 文字位置 // // sg modify 120110,修改比例文字的位置点,增加了Y方向的距离 // // pt = ptCen + ADSGePoint3d(GetScaleXDist(FALSE), -m_nRadius*GetPScale()); // 文字位置 // pt = ptScale; // 下面的矩阵变化过程,已经封装在了GetScaleTextPt函数内部 // // //ads_matrix matRot; // //ptCen.GetRotationMatrix(m_nLayoutRotation, matRot); // //if (IsLayoutRotated()) // //{ // // pt.TransformBy(matRot); // //} // // AecXDbText *pText = new AecXDbText; // pText->CopyPropertiesFrom(this, 0); // pText->SetHeight(m_dScaleTextHeight); // pText->SetStyleId(m_idScaleStyle); // pText->SetAlignment(XExplodeDraw::kBottomLeft); // if (g_nSymbTextT3Layer == 1 && !!m_idTextLayer) // 文字层 // { // pText->setLayer(m_idTextLayer); // pText->setColorIndex(colorIndex()); // } // else // 符号层 // { // pText->setLayer(idLayer); // pText->setColorIndex(m_colorText); // } // pText->SetText(m_szScaleText); // pText->SetLocation(pt); // entSet.append(pText); // // if (bErase) // { // *bErase = TRUE; // } // return es; // } // // return AecXDbSymbWithText::DownGradeSave(nDrawMode, entSet, bErase); // 其他情况,基类处理 //} // sg add 110211,支持统一标高 bool AecXDbSymbDrawingIndex::UnifyElevation(double dElevation) { AssertWriteEnabled(); m_ptCenter.z = dElevation; return true; } int AecXDbSymbDrawingIndex::ConvertText(TConvertTextPtr ptr, void *pData) { AssertWriteEnabled(); TCString sText; int nRet = ptr(m_sIndexLabel, sText, pData); if (nRet == RTNORM) { m_sIndexLabel = sText; } int nRet1 = ptr(m_sDrawingLabel, sText, pData); if (nRet1 == RTNORM) { m_sDrawingLabel = sText; } else if (nRet1 == RTERROR) nRet = nRet1; return nRet; } /* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */ void AecXDbSymbDrawingIndex::GetTips(PtrList &lstInfo) const { lstInfo.Append(new ObjInfoUnit(_T("对象类型"), _T("索引图名"))); lstInfo.Append(new ObjInfoUnit(_T("被索引图编号"), m_sDrawingLabel)); lstInfo.Append(new ObjInfoUnit(_T("索引编号"), m_sIndexLabel)); TCString sTextStyle = GlobalFunc::GetSymbolName(m_idTextStyle); lstInfo.Append(new ObjInfoUnit(_T("文字样式"), sTextStyle)); if (m_bDrawScale) // 绘制比例文字,sg add 081230 { TCString sScaleStyle = GlobalFunc::GetSymbolName(m_idScaleStyle); lstInfo.Append(new ObjInfoUnit(_T("比例样式"), sScaleStyle)); lstInfo.Append(new ObjInfoUnit(_T("比例文字"), m_szScaleText)); } } // Properties double AecXDbSymbDrawingIndex::GetTextParam1(ADSGePoint3d &pt1, ADSGePoint3d &pt2) const { // sg modify 110209,支持圆圈文字出圈样式 // BOOL bOldStyle = IsOldStyle(); int nTrueStyle = GetTrueTextStyle(); // sg add 090729,特殊对新样式的国际分轴号的导出做处理 BOOL bAxisLable = !!m_sDrawingLabel && g_bDrawAxisLabel; double nTextHeight(0); // if (bOldStyle || bAxisLable) // sg modify 110209,支持圆圈文字出圈样式 if (nTrueStyle == 1 || bAxisLable) { double radius = GetRadius(FALSE); nTextHeight = radius / sin(PI / 4.0) * 0.8; pt1 = m_ptCenter - ADSGePoint3d(nTextHeight / 2.0, nTextHeight / 2.0); pt2 = m_ptCenter + ADSGePoint3d(nTextHeight / 2.0, -nTextHeight / 2.0); } else { double dX(0); GetTextExtends(m_sIndexLabel, dX, nTextHeight, FALSE); pt1 = m_ptCenter - ADSGePoint3d(dX, nTextHeight); pt2 = m_ptCenter + ADSGePoint3d(dX, -nTextHeight); } if (IsLayoutRotated()) // add by whl on 060218 { ads_matrix matRot; m_ptCenter.GetRotationMatrix(m_nLayoutRotation, matRot); pt1.TransformBy(matRot); pt2.TransformBy(matRot); } // sg modify 110209,支持圆圈文字出圈样式 // double dRet = (bOldStyle || bAxisLable)?nTextHeight:(2*nTextHeight); double dRet = (nTrueStyle == 1 || bAxisLable) ? nTextHeight : (2 * nTextHeight); return dRet; } const TCHAR * AecXDbSymbDrawingIndex::GetIndexLabel() const { return (const TCHAR *)m_sIndexLabel; } const TCHAR * AecXDbSymbDrawingIndex::GetDrawingLabel() const { return (const TCHAR *)m_sDrawingLabel; } ADSGePoint3d AecXDbSymbDrawingIndex::GetCenter() const { return m_ptCenter; } double AecXDbSymbDrawingIndex::GetRadius(BOOL bAsPaperUnit) const { double val = m_nRadius; if (!bAsPaperUnit) val *= GetPScale(); return val; } double AecXDbSymbDrawingIndex::GetLineWidth() const { return m_nLineWidth; } void AecXDbSymbDrawingIndex::SetDrawingLabel(const TCHAR *pszText) { AssertWriteEnabled(); m_sDrawingLabel = pszText; } void AecXDbSymbDrawingIndex::SetIndexLabel(const TCHAR *pszText) { AssertWriteEnabled(); m_sIndexLabel = pszText; } void AecXDbSymbDrawingIndex::SetCenter(ADSGePoint3d pt) { AssertWriteEnabled(); m_ptCenter = pt; } void AecXDbSymbDrawingIndex::SetRadius(double val, BOOL bAsPaperUnit) { AssertWriteEnabled(); m_nRadius = val; if (!bAsPaperUnit) m_nRadius /= GetPScale(); } void AecXDbSymbDrawingIndex::SetLineWidth(double val) { AssertWriteEnabled(); m_nLineWidth = val; } SubText* AecXDbSymbDrawingIndex::HitTestText(ADSGePoint3d pt)const { // sg modify 110209,支持圆圈文字出圈样式 // BOOL bOldStyle = IsOldStyle(); // double dScale = bOldStyle?0.75:(GetTextRatio()-0.05); int nTrueStyle = GetTrueTextStyle(); double dScale = (nTrueStyle == 1) ? 0.75 : (GetTextRatio() - 0.05); // if (pt.Distance2d(GetCenter()) < GetRadius(FALSE)*0.75) if (pt.Distance2d(GetCenter()) < GetRadius(FALSE) * dScale) // sg modify 081223,字的大小占圆圈的% { if (GetSubTextNum() == 1) return GetSubText(0); GeLine line; ads_polar(m_ptCenter, m_nLayoutRotation, GetRadius(FALSE), line.EndPoint()); ads_polar(m_ptCenter, PI + m_nLayoutRotation, GetRadius(FALSE), line.StartPoint()); if (line.HitTest2d(pt) == 2) return GetSubText(1); else return GetSubText(0); } else // sg add 081217,适应在位编辑比例,圈外部分 { ADSGePoint3d ptScale, ptTmp; // sg modify 120110,修改比例文字的位置点,增加了Y方向的距离 /* ads_polar(m_ptCenter, m_nLayoutRotation, GetScaleXDist(FALSE), ptScale); // ads_polar(ptScale, m_nLayoutRotation+PI/2, -7*GetPScale(), ptScale); ads_polar(ptScale, m_nLayoutRotation+PI/2, -m_nRadius*GetPScale(), ptScale);*/ ptScale = GetScaleTextPt(); AecXDbText text; text.setPropertiesFrom(this); text.SetHeight(m_dScaleTextHeight); text.SetStyleId(m_idScaleStyle); text.SetText(m_szScaleText); text.SetLocation(ptScale); text.SetAlignment(AcGiDraw::kBottomLeft); Vector3D vt = text.GetExtents(); // 得到文字外包框 // ADSGePoint3d ptTmp = ptScale + ADSGePoint3d(vt.x, vt.y); // sg modify 090508,解决带布局转角后,不支持在位编辑的BUG ads_polar(ptScale, m_nLayoutRotation, vt.x, ptTmp); ads_polar(ptTmp, m_nLayoutRotation + PI / 2, vt.y, ptTmp); GePoly2D poly(1); GeRectAngle rect(ptScale, ptTmp); rect.AsPoly2D(poly); ptTmp = pt; ptTmp.z = 0; if ((ptTmp & poly) == PR_INSIDE) // 当前点必须在文字外包框内 { if (GetSubTextNum() == 1) return GetSubText(1); else return GetSubText(2); } } return NULL; } // sg add 081218,AOL中有同名函数的实现,因此在暂时将该函数定义为内联 void AecXDbSymbDrawingIndex::SetSubText(long i, CString sText) { AssertWriteEnabled(); if (i == 0) { SetIndexLabel(sText); } // else // sg modify 081218 // SetDrawingLabel(sText); else if (i == 1) { if (!m_sDrawingLabel) { SetScaleText(sText); } else { SetDrawingLabel(sText); } } else // == 2 { SetScaleText(sText); } } // sg add 081210 TCString AecXDbSymbDrawingIndex::GetScaleText() const { return m_szScaleText; } AcDbObjectId AecXDbSymbDrawingIndex::GetScaleStyleId() const { return m_idScaleStyle; } double AecXDbSymbDrawingIndex::GetScaleTextHeight() const { return m_dScaleTextHeight; } double AecXDbSymbDrawingIndex::GetScaleXDist(BOOL bAsPaperUnit) const { double dVal = m_dScaleXDist; if (!bAsPaperUnit) { dVal *= GetPScale(); } return dVal; } void AecXDbSymbDrawingIndex::SetScaleText(const TCString &szScaleText) { AssertWriteEnabled(); m_szScaleText = szScaleText; } void AecXDbSymbDrawingIndex::SetScaleStyleId(const AcDbObjectId &idScaleStyle) { AssertWriteEnabled(); m_idScaleStyle = idScaleStyle; } void AecXDbSymbDrawingIndex::SetScaleTextHeight(double dVal) { AssertWriteEnabled(); m_dScaleTextHeight = dVal; } // sg modify 120110,修改接口,增加出图比例的设置 // void AecXDbSymbDrawingIndex::SetScaleXDist(double dVal) void AecXDbSymbDrawingIndex::SetScaleXDist(double dVal, BOOL bAsPaperUnit) { AssertWriteEnabled(); m_dScaleXDist = dVal; if (!bAsPaperUnit) m_dScaleXDist /= GetPScale(); } // sg add 081217 BOOL AecXDbSymbDrawingIndex::IsDrawScale() const { return m_bDrawScale; } void AecXDbSymbDrawingIndex::SetDrawScale(BOOL bDraw) { AssertWriteEnabled(); m_bDrawScale = bDraw; } // sg add 090723,单纯的Set\Get函数 void AecXDbSymbDrawingIndex::SetOldStyle(int nDraw) { AssertWriteEnabled(); m_bOldStyle = nDraw; } int AecXDbSymbDrawingIndex::GetOldStyle() const { return m_bOldStyle; } // sg add 090116,是否是旧样式,考虑了随基本设定的情况 BOOL AecXDbSymbDrawingIndex::IsOldStyle() const { int nOldStyle = m_bOldStyle; if (nOldStyle == 2) // 随基本设定 { nOldStyle = GlobalFunc::DocGetDrawingIndexStyle(); } return (nOldStyle == 0); } // sg add 110209,获得圆圈文字样式,考虑了随基本设定的情况 int AecXDbSymbDrawingIndex::GetTrueTextStyle() const { int nOldStyle = m_bOldStyle; if (nOldStyle == 2) // 随基本设定 { nOldStyle = GlobalFunc::DocGetDrawingIndexStyle(); } return nOldStyle; } double AecXDbSymbDrawingIndex::GetTextRatio() const { double dRatio = m_dTextRatio; if (fabs(dRatio) < 1.0E-3) { dRatio = GlobalFunc::DocGetDITextRatio(); } return dRatio; } void AecXDbSymbDrawingIndex::SetTextRatio(double dVal) { AssertWriteEnabled(); m_dTextRatio = dVal; } // sg add 090203,支持查找替换 BOOL AecXDbSymbDrawingIndex::GetText(Adesk::UInt32 cookies, AecXDbText &text) const { if ((!!m_sDrawingLabel && m_bDrawScale && cookies > 2) || (!!m_sDrawingLabel && !m_bDrawScale && cookies > 1) || (!m_sDrawingLabel && m_bDrawScale && cookies > 1) || (!m_sDrawingLabel && !m_bDrawScale && cookies != 0)) { return FALSE; } text.setPropertiesFrom(this); text.SetStyleId(m_idTextStyle); text.SetRotation(m_nLayoutRotation); ads_matrix matRot; ADSGePoint3d pt1(m_ptCenter), pt2(m_ptCenter), ptText; m_ptCenter.GetRotationMatrix(m_nLayoutRotation, matRot); // sg modify 110209,支持圆圈文字出圈样式 // BOOL bOldStyle = IsOldStyle(); int nTrueStyle = GetTrueTextStyle(); double dHeight = m_nTextHeight; // sg add 090609,字高 if (cookies == 0) // m_sIndexLabel { if (!m_sDrawingLabel) { if (nTrueStyle == 1) // 8.0以前样式 { double dTextHeight = GetRadius(FALSE) / sin(PI / 4.0); pt1 -= ADSGePoint3d(0.4 * dTextHeight, 0.4 * dTextHeight); pt2 += ADSGePoint3d(0.4 * dTextHeight, -0.4 * dTextHeight); dHeight = dTextHeight * 0.8; } else // 8.0新样式,出圈样式 { double dX(0), dY(0); GetTextExtends(m_sIndexLabel, dX, dY, FALSE); // 获取指定文字的最大尺寸 pt1 -= ADSGePoint3d(dX, dY); pt2 += ADSGePoint3d(dX, -dY); dHeight = dY * 2; } } else { double dTextHeight(0), dY(0), dSpacer(0); if (nTrueStyle == 1) // 旧样式 { double dAng = atan(2.0); // dTextHeight = GetRadius(FALSE)*sin(dAng)*0.9; // sg modify 090610,支持国际分轴号 dTextHeight = GetRadius(FALSE) * sin(dAng); if (!g_bDrawAxisLabel) dTextHeight *= 0.9; dSpacer = dTextHeight / 10.0; dHeight = 0.8 * dTextHeight; } else // 新样式,出圈样式 { GetTextExtends(m_sIndexLabel, dTextHeight, dY, TRUE); // sg modify 101119,根据8.5需求,修改新样式,将文字远离基线 double radius = GetRadius(FALSE); if (GetTextRatio() > 1.0 + 1E-2) // 圆圈文字的系数大于1时 { dSpacer = dY / 5.0; } else if (nTrueStyle == 0) // 新样式 { dSpacer = (sqrt(radius * radius - 0.25 * dTextHeight * dTextHeight) - dY) * 0.4; } else // ==3,出圈样式 { dSpacer = (radius - dY) * 0.4; } dHeight = dY; } if (g_bDrawAxisLabel) // sg add 090610,支持国际分轴号 { pt1.x -= (0.4828 * dY + dTextHeight); pt2.x -= 0.4828 * dY; pt1.y -= dSpacer; pt2.y -= dSpacer; } else { pt1.x -= dTextHeight / 2; pt2.x += dTextHeight / 2; pt1.y += dSpacer; pt2.y += dSpacer; } } Midpoint(pt1, pt2, ptText); text.SetText(m_sIndexLabel); text.SetAlignment(AcGiDraw::kBottomCenter); } else if (cookies == 1) { if (!m_sDrawingLabel) // m_szScaleText { dHeight = m_dScaleTextHeight * GetPScale(); // sg modify 120110,修改比例文字的位置点,增加了Y方向的距离 // ptText = m_ptCenter + ADSGePoint3d(GetScaleXDist(FALSE), -7*GetPScale()); // ptText = m_ptCenter + ADSGePoint3d(GetScaleXDist(FALSE), -m_nRadius*GetPScale()); ptText = GetScaleTextPt(); text.SetText(m_szScaleText); text.SetStyleId(m_idScaleStyle); text.SetAlignment(AcGiDraw::kBottomLeft); } else // m_sDrawingLabel { double dTextHeight(0), dY(0); if (nTrueStyle == 1) // 旧样式 { double dAng = atan(2.0); dTextHeight = GetRadius(FALSE) * sin(dAng) * 0.9; pt1 -= ADSGePoint3d(0.5 * dTextHeight, 0.5 * dTextHeight); pt2 -= ADSGePoint3d(-0.5 * dTextHeight, 0.5 * dTextHeight); dHeight = 0.8 * dTextHeight; } else // 新样式,出圈样式 { GetTextExtends(m_sDrawingLabel, dTextHeight, dY, TRUE); // sg modify 101119,根据8.5需求,修改新样式,将文字远离基线 double dTmpNum = dY * 1.2; double radius = GetRadius(FALSE); if (GetTextRatio() < 1.0 + 1E-2) { if (nTrueStyle == 0) // 新样式 { dTmpNum = (sqrt(radius * radius - 0.25 * dTextHeight * dTextHeight) - dY) * 0.4 + dY; } else // ==3,出圈样式 { dTmpNum = (radius - dY) * 0.4 + dY; } } // pt1 -= ADSGePoint3d(dTextHeight/2, dY*1.2); // pt2 += ADSGePoint3d(dTextHeight/2, -dY*1.2); pt1 -= ADSGePoint3d(dTextHeight / 2, dTmpNum); pt2 += ADSGePoint3d(dTextHeight / 2, -dTmpNum); dHeight = dY; } Midpoint(pt1, pt2, ptText); text.SetText(m_sDrawingLabel); text.SetAlignment(AcGiDraw::kBottomCenter); } } else if (cookies == 2) // m_szScaleText { dHeight = m_dScaleTextHeight * GetPScale(); // sg modify 120110,修改比例文字的位置点,增加了Y方向的距离 // ptText = m_ptCenter + ADSGePoint3d(GetScaleXDist(FALSE), -7*GetPScale()); // ptText = m_ptCenter + ADSGePoint3d(GetScaleXDist(FALSE), -m_nRadius*GetPScale()); ptText = GetScaleTextPt(); text.SetText(m_szScaleText); text.SetStyleId(m_idScaleStyle); text.SetAlignment(AcGiDraw::kBottomLeft); } // 下面的矩阵变化过程,已经封装在了GetScaleTextPt函数内部 //if (IsLayoutRotated()) //{ // ptText.TransformBy(matRot); //} text.SetLocation(ptText); text.SetHeight(dHeight, FALSE); return TRUE; } // 返回发现的位置,同时posStart往前移动(以便继续找下一个使用), TextPosition AecXDbSymbDrawingIndex::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; 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 AecXDbSymbDrawingIndex::ReplaceSubText(const TextPosition &posRep, const TCHAR *sRepText, TextRange *pRange) { AssertWriteEnabled(); AecXDbText text; 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) { SetIndexLabel(text.GetText()); } else if (cookies == 1) { if (!m_sDrawingLabel) { SetScaleText(text.GetText()); } else { SetDrawingLabel(text.GetText()); } } else if (cookies == 2) { SetScaleText(text.GetText()); } if (!posNext) { posNext.m_nCookies = posRep.m_nCookies + 1; posNext.m_nTextPos = 0; } return posNext; } // sg add 090720,8.0正式版增加的临时变量,不保存,处理轴网标注的轴号绘制问题 void AecXDbSymbDrawingIndex::SetSymbText(BOOL bSymbText) { AssertWriteEnabled(); m_bSymbText = bSymbText; } // sg add 120110,比例文字距圆心的Y方向距离 double AecXDbSymbDrawingIndex::GetScaleYDist(BOOL bAsPaperUnit) const { assertReadEnabled(); double dVal = -m_nRadius; const EntityFields &fd = GetFields(); fd.GFD(_T("Y方向距离"), dVal); if (!bAsPaperUnit) { dVal *= GetPScale(); } return dVal; } void AecXDbSymbDrawingIndex::SetScaleYDist(double dVal, BOOL bAsPaperUnit) { AssertWriteEnabled(); if (!bAsPaperUnit) dVal /= GetPScale(); EntityFields &fd = Fields(); fd.SFD(_T("Y方向距离"), dVal); } // sg add 120110,直接提供接口,设置比例文字位置,但是内部保存的还是m_dScaleXDist和m_dScaleYDist ADSGePoint3d AecXDbSymbDrawingIndex::GetScaleTextPt() const { ADSGePoint3d ptScaleText; ads_polar(m_ptCenter, m_nLayoutRotation, GetScaleXDist(FALSE), ptScaleText); ads_polar(ptScaleText, m_nLayoutRotation + PI / 2, GetScaleYDist(FALSE), ptScaleText); return ptScaleText; } void AecXDbSymbDrawingIndex::SetScaleTextPt(ADSGePoint3d pt) { Vector3D vtDist = pt - m_ptCenter; vtDist.Rotate(-GetLayoutRotation()); double dX = vtDist.x, dY = vtDist.y; SetScaleXDist(dX, FALSE); SetScaleYDist(dY, FALSE); } // sg add 120110,获得比例文字默认的文字位置 ADSGePoint3d AecXDbSymbDrawingIndex::GetDefaultScaleTextLocation() const { double dX = (9.0 * m_nRadius) / 7.0, dY = -m_nRadius; ADSGePoint3d ptScaleText; ads_polar(m_ptCenter, m_nLayoutRotation, dX * GetPScale(), ptScaleText); ads_polar(ptScaleText, m_nLayoutRotation + PI / 2, dY * GetPScale(), ptScaleText); return ptScaleText; }