Files
envi-code/SourceCode/Code2026/Dimension/AecDbSymbSection.cpp
T

1915 lines
47 KiB
C++
Raw Normal View History

2026-10-04 00:04:20 +08:00
#include "StdAfx.h"
2026-09-28 15:28:50 +08:00
#include "AecDbSymbSection.h"
#include "AecDbText.h"
#include "PushProperty.h"
#include "dbgrip.h"
#include "DimOptionData.h"
AcDbObjectId InitTextStyle(TTextStyle ts, AcDbDatabase *pDb);
const static Adesk::UInt8 g_nVersion;
ACRX_DXF_DEFINE_MEMBERS(AecXDbSymbSection, AecXDbSymbWithText, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
2026-10-04 00:04:20 +08:00
1, AEC_POQIE, "AEC_POQIE|缺乏上华解释器, 请下载上华软件|网址: www.shanghuasoft.com");
2026-09-28 15:28:50 +08:00
const Adesk::UInt8 AecXDbSymbSection::g_nVersion = 2;
double AecXDbSymbSection::g_nLineWidth = 0.5;
double AecXDbSymbSection::g_nSegLength = 10.0;
AecXDbSymbSection::AecXDbSymbSection()
{
m_nTextHeight = 5.0;
m_nViewDir = 0.0;
m_bViewLine = TRUE;
2026-10-04 00:04:20 +08:00
// add by lgy 20120319,剖面图号文字
2026-09-28 15:28:50 +08:00
m_sDrawingIndex = _T("");
m_dIndexHeight = 3.5;
m_nFlag = 0;
2026-10-04 00:04:20 +08:00
m_dText2BaseRatio = -1000; // 默认-1000时说明受天正选项距基线系数控制
2026-09-28 15:28:50 +08:00
m_nViewDir2 = 0;
}
AecXDbSymbSection::~AecXDbSymbSection()
{
}
BOOL AecXDbSymbSection::IsValid() const
{
//BOOL bRet = AecXDbSymbWithText::IsValid();
//if (!bRet)
// return bRet;
BOOL bRet = (m_poly.Length() > 1 && !m_poly.IsClosed());
return bRet;
}
//Acad::ErrorStatus
//AecXDbSymbSection::subGetClassID(CLSID* pClsid) const
//{
// *pClsid = CLSID_ComSymbSection;
// return Acad::eOk;
//}
2026-10-04 00:04:20 +08:00
// 提供对格式刷的支持
2026-09-28 15:28:50 +08:00
void AecXDbSymbSection::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag)
{
AssertWriteEnabled();
AecXDbSymbWithText::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
AecXDbSymbSection *pSrc = AecXDbSymbSection::cast(pSrcEntity);
if (pSrc)
{
m_bViewLine = pSrc->m_bViewLine;
}
}
Acad::ErrorStatus
AecXDbSymbSection::dwgInFields(AcDbDwgFiler* filer)
{
AssertWriteEnabled();
Acad::ErrorStatus es = AecXDbSymbWithText::dwgInFields(filer);
if (es != Acad::eOk)
return es;
Adesk::Int8 version;
filer->readItem(&version);
if (version > g_nVersion)
return Acad::eMakeMeProxy;
filer->readItem(&m_bViewLine);
filer->readItem(&m_nViewDir);
Adesk::UInt8 nVertNum;
filer->readItem(&nVertNum);
m_poly.Reset();
for (Adesk::UInt8 i = 0; i < nVertNum; i++)
{
ADSGePoint3d pnt;
filer->readItem(&(AcGePoint2d &)pnt);
m_poly.AppendNode(pnt);
}
GlobalFunc::ReadString(filer, m_sText);
2026-10-04 00:04:20 +08:00
// sg modify 120426,根据9.0需求,将文字夹点转换为ECS坐标
2026-09-28 15:28:50 +08:00
//filer->readItem(&(AcGePoint2d &)m_ptText1);
//filer->readItem(&(AcGePoint2d &)m_ptText2);
ADSGePoint3d ptText1, ptText2;
filer->readItem(&(AcGePoint2d &)ptText1);
filer->readItem(&(AcGePoint2d &)ptText2);
2026-10-04 00:04:20 +08:00
// add by lgy 20120319,9.0为剖面图号添加一些新的属性
if (version > 1) // 9.0版本
2026-09-28 15:28:50 +08:00
{
m_ptText1 = ptText1;
m_ptText2 = ptText2;
GlobalFunc::ReadString(filer, m_sDrawingIndex);
filer->readItem(&(AcGePoint2d &)m_ptSIndex);
filer->readItem(&(AcGePoint2d &)m_ptEIndex);
filer->readItem(&m_dIndexHeight);
filer->readItem(&m_nFlag);
filer->readItem(&m_idIndexStyle);
filer->readItem(&m_dText2BaseRatio);
filer->readItem(&m_nViewDir2);
}
2026-10-04 00:04:20 +08:00
else // 9.0以前版本
2026-09-28 15:28:50 +08:00
{
m_nFlag = 0;
m_dIndexHeight = 3.5;
m_sDrawingIndex = _T("");
m_idIndexStyle = InitTextStyle(TS_INDEXSCALE, database());
m_dText2BaseRatio = -1000;
m_nViewDir2 = m_nViewDir;
2026-10-04 00:04:20 +08:00
SetTextLocation(0, ptText1); // 将起点、终点处的文字位置点转换为ECS坐标
2026-09-28 15:28:50 +08:00
SetTextLocation(1, ptText2);
}
return filer->filerStatus();
}
Acad::ErrorStatus
AecXDbSymbSection::dwgOutFields(AcDbDwgFiler* filer) const
{
assertReadEnabled();
VERIFY(AecXDbSymbWithText::dwgOutFields(filer) == Acad::eOk);
2026-10-04 00:04:20 +08:00
// modify by lgy 20120319,9.0中新添加些属性
2026-09-28 15:28:50 +08:00
// filer->writeItem(g_nVersion);
filer->writeItem(g_nVersion);
filer->writeItem(m_bViewLine);
filer->writeItem(m_nViewDir);
Adesk::UInt8 vexLen = m_poly.Length();
filer->writeItem(vexLen);
for (Adesk::UInt8 i = 0; i < vexLen; i++)
{
filer->writeItem((const AcGePoint2d &)m_poly[i]);
}
filer->writeItem((const TCHAR *)m_sText);
2026-10-04 00:04:20 +08:00
// sg modify 120426,根据9.0需求,将文字夹点转换为ECS坐标
2026-09-28 15:28:50 +08:00
//filer->writeItem((const AcGePoint2d &)m_ptText1);
//filer->writeItem((const AcGePoint2d &)m_ptText2);
2026-10-04 00:04:20 +08:00
// add by lgy 20120319,9.0为剖面符号添加了新的属性
//if (g_nSaveTArchVer > 8) // 9.0版本
2026-09-28 15:28:50 +08:00
//{
filer->writeItem((const AcGePoint2d &)m_ptText1);
filer->writeItem((const AcGePoint2d &)m_ptText2);
filer->writeItem((const TCHAR *)m_sDrawingIndex);
filer->writeItem((const AcGePoint2d &)m_ptSIndex);
filer->writeItem((const AcGePoint2d &)m_ptEIndex);
filer->writeItem(m_dIndexHeight);
filer->writeItem(m_nFlag);
filer->writeItem(m_idIndexStyle);
filer->writeItem(m_dText2BaseRatio);
filer->writeItem(m_nViewDir2);
//}
2026-10-04 00:04:20 +08:00
//else // 9.0以前版本
2026-09-28 15:28:50 +08:00
//{
// ADSGePoint3d pt = GetTextLocation(0);
// filer->writeItem((const AcGePoint2d &)pt);
// pt = GetTextLocation(1);
// filer->writeItem((const AcGePoint2d &)pt);
//}
return filer->filerStatus();
}
Acad::ErrorStatus
AecXDbSymbSection::dxfInFields(AcDbDxfFiler* filer)
{
return AecXDbSymbWithText::dxfInFields(filer);
}
Acad::ErrorStatus
AecXDbSymbSection::dxfOutFields(AcDbDxfFiler* filer) const
{
return AecXDbSymbWithText::dxfOutFields(filer);
}
Acad::ErrorStatus AecXDbSymbSection::Draw2d(AcGiDraw &dc) const
{
assertReadEnabled();
2026-10-04 00:04:20 +08:00
if (!IsValid()) // 判断是否符合绘制条件
2026-09-28 15:28:50 +08:00
{
return Acad::eInvalidInput;
}
if (Has2DBuffer() && !dc.IsDragging())
{
dc.SetColor(colorIndex());
dc.SetLayer(layerId());
BaseEx::_Draw2DBuffers(dc, true);
return Acad::eOk;
}
if (!m_bInJig)
int a = 0;
double tempLineWidth = g_nLineWidth * GetPScale();
2026-10-04 00:04:20 +08:00
// sg modify 110408,剖线方向、位置长度,都改成支持在高级选项中进行设置
2026-09-28 15:28:50 +08:00
// double tempSegLen = g_nSegLength*GetPScale();
double tempSegLen = g_DimOption::instance().g_dSectionSegLocLength * GetPScale(),
tempSegDirLen = g_DimOption::instance().g_dSectionSegDirLength * GetPScale();
int vexNum = m_poly.Length();
for (int i = 0; i < vexNum; i++)
{
ADSGePoint3d ptVert = m_poly[i];
ADSGePoint3d ptPrev, ptNext;
BOOL bPrev = FALSE,
bNext = FALSE;
if (i == 0 && m_bViewLine)
{
2026-10-04 00:04:20 +08:00
// sg modify 110408,剖线方向、位置长度,都改成支持在高级选项中进行设置
2026-09-28 15:28:50 +08:00
// ads_polar(ptVert, m_nViewDir, 0.6*tempSegLen, ptPrev);
ads_polar(ptVert, m_nViewDir, tempSegDirLen, ptPrev);
bPrev = TRUE;
}
else if (i > 0)
{
double nSegLen = min(tempSegLen, ptVert.Distance2d(m_poly[i - 1]) / 2);
ads_polar(ptVert, ads_angle(ptVert, m_poly[i - 1]), nSegLen, ptPrev);
bPrev = TRUE;
}
if (i == vexNum - 1 && m_bViewLine)
{
2026-10-04 00:04:20 +08:00
// sg modify 110408,剖线方向、位置长度,都改成支持在高级选项中进行设置
2026-09-28 15:28:50 +08:00
// ads_polar(ptVert, m_nViewDir, 0.6*tempSegLen, ptNext);
2026-10-04 00:04:20 +08:00
// sg modify 120524,终点处有可能使用另外一个剖视方向
2026-09-28 15:28:50 +08:00
// ads_polar(ptVert, m_nViewDir, tempSegDirLen, ptNext);
ads_polar(ptVert, GetEndViewLineDir(), tempSegDirLen, ptNext);
bNext = TRUE;
}
else if (i < vexNum - 1)
{
double nSegLen = min(tempSegLen, ptVert.Distance2d(m_poly[i + 1]) / 2);
ads_polar(ptVert, ads_angle(ptVert, m_poly[i + 1]), nSegLen, ptNext);
bNext = TRUE;
}
AcDbPolyline pline;
pline.setPropertiesFrom(this);
int nVert = 0;
if (bPrev)
{
pline.addVertexAt(nVert, ptPrev);
nVert++;
}
pline.addVertexAt(nVert, ptVert);
nVert++;
if (bNext)
{
pline.addVertexAt(nVert, ptNext);
nVert++;
}
pline.setConstantWidth(tempLineWidth);
//dc.Polyline(pline);
DrawPline(dc, pline);
}
if (!!m_sText || g_Option::instance().g_bExplodeSubText)
{
AecXDbText text;
text.setPropertiesFrom(this);
text.SetPScale(GetPScale());
// text.SetRotation(m_nTextRotation);
text.SetAlignment(AcGiDraw::kMiddleCenter);
text.SetStyleId(m_idTextStyle);
//if (dc.IsExportTch4()) // sg modify 090608
//{
2026-10-04 00:04:20 +08:00
// // sg add 120313,分解出来的文字的图层和颜色要随“高级选项”中的设置来处理
2026-09-28 15:28:50 +08:00
// // if (!!m_idTextLayer)
// if (g_nSymbTextT3Layer == 1 && !!m_idTextLayer)
2026-10-04 00:04:20 +08:00
// text.setLayer(m_idTextLayer); // 文字层
2026-09-28 15:28:50 +08:00
// else
2026-10-04 00:04:20 +08:00
// text.setColorIndex(m_colorText); // 文字和标注放在同一层,文字的颜色为白色
2026-09-28 15:28:50 +08:00
//}
//else
2026-10-04 00:04:20 +08:00
text.setColorIndex(m_colorText); // sg add 090608,将文字和标注放在同一层,文字的颜色为白色
2026-09-28 15:28:50 +08:00
PushProperty vProp(&text, dc);
text.SetHeight(m_nTextHeight);
text.SetText(m_sText);
2026-10-04 00:04:20 +08:00
// modify by lgy 20120322,9.0中各个文字位置点保存的是ecs坐标,故需要转换成为wcs
2026-09-28 15:28:50 +08:00
// text.SetLocation(m_ptText1);
ADSGePoint3d pt = GetTextLocation(0);
text.SetLocation(pt);
//if (dc.IsFullExplode())
// text.ExplodeOrDraw2d(dc);
//else
// dc.DrawEntity(text);
DrawBaseEx(dc, text);
2026-10-04 00:04:20 +08:00
// modify by lgy 20120322,9.0中各个文字位置点保存的是ecs坐标,故需要转换成为wcs
2026-09-28 15:28:50 +08:00
// text.SetLocation(m_ptText2);
2026-10-04 00:04:20 +08:00
pt = GetTextLocation(1);//获得剖切编号末端位置点
2026-09-28 15:28:50 +08:00
text.SetLocation(pt);
//if (dc.IsFullExplode())
// text.ExplodeOrDraw2d(dc);
//else
// dc.DrawEntity(text);
DrawBaseEx(dc, text);
}
2026-10-04 00:04:20 +08:00
// add by lgy 20120319,9.0中有添加了剖面图号文字
2026-09-28 15:28:50 +08:00
if ((GetIsHasIndexS() || GetIsHasIndexE()) && (!!m_sDrawingIndex || g_Option::instance().g_bExplodeSubText))
{
AecXDbText text;
text.setPropertiesFrom(this);
text.SetPScale(GetPScale());
text.SetStyleId(m_idIndexStyle);
//if (dc.IsExportTch4())
//{
// if (g_nSymbTextT3Layer == 1 && !!m_idTextLayer)
2026-10-04 00:04:20 +08:00
// text.setLayer(m_idTextLayer); // 为文字设置图层
2026-09-28 15:28:50 +08:00
// else
2026-10-04 00:04:20 +08:00
// text.setColorIndex(m_colorText); // 为文字设置颜色
2026-09-28 15:28:50 +08:00
//}
//else
text.setColorIndex(m_colorText);
PushProperty vProp(&text, dc);
2026-10-04 00:04:20 +08:00
text.SetHeight(m_dIndexHeight); // 为文字设置高度
2026-09-28 15:28:50 +08:00
text.SetText(m_sDrawingIndex);
2026-10-04 00:04:20 +08:00
if (GetIsHasIndexS()) // 图号始端有文字
2026-09-28 15:28:50 +08:00
{
double dRotation = GetIndexTextRotation(0);
text.SetRotation(dRotation);
AcGiDraw::TextAlignment nAlign = GetIndexTextAlignment(0);
text.SetAlignment(nAlign);
ADSGePoint3d pt = GetIndexLocation(0);
text.SetLocation(pt);
//if (dc.IsFullExplode())
// text.ExplodeOrDraw2d(dc);
//else
// dc.DrawEntity(text);
DrawBaseEx(dc, text);
}
2026-10-04 00:04:20 +08:00
if (GetIsHasIndexE()) // 图号末端有文字
2026-09-28 15:28:50 +08:00
{
double dRotation = GetIndexTextRotation(1);
text.SetRotation(dRotation);
AcGiDraw::TextAlignment nAlign = GetIndexTextAlignment(1);
text.SetAlignment(nAlign);
ADSGePoint3d pt = GetIndexLocation(1);
text.SetLocation(pt);
//if (dc.IsFullExplode())
// text.ExplodeOrDraw2d(dc);
//else
// dc.DrawEntity(text);
DrawBaseEx(dc, text);
}
}
return Acad::eOk;
}
SubText* AecXDbSymbSection::HitTestText(ADSGePoint3d pt)const
{
//SubText *pSub = TDbEntity::HitTestText(pt);
//if (pSub != NULL)
// pSub->SetIndex(0);
//return pSub;
return AecXDbSymbWithText::HitTestText(pt);
}
void AecXDbSymbSection::SetSubText(long i, CString sText)
{
AssertWriteEnabled();
// m_sText = sText;
if (i == 0 || i == 1)
{
m_sText = sText;
}
2026-10-04 00:04:20 +08:00
else // 2或者3
2026-09-28 15:28:50 +08:00
{
m_sDrawingIndex = sText;
}
}
2026-10-04 00:04:20 +08:00
// sg add 110301,支持统一标高
2026-09-28 15:28:50 +08:00
bool AecXDbSymbSection::UnifyElevation(double dElevation)
{
AssertWriteEnabled();
m_poly.SetElevation(dElevation);
m_ptText1.z = dElevation;
m_ptText2.z = dElevation;
m_ptSIndex.z = dElevation;
m_ptEIndex.z = dElevation;
return true;
}
void AecXDbSymbSection::getGripPoints(AcGePoint3dArray &gripPoints) const
{
assertReadEnabled();
2026-10-04 00:04:20 +08:00
// modify by lgy 20120322,9.0中文字位置点保存为ecs坐标
2026-09-28 15:28:50 +08:00
// gripPoints.append(m_ptText1); //0
// gripPoints.append(m_ptText2); //1
ADSGePoint3d ptTemp = GetTextLocation(0);
gripPoints.append(ptTemp);
ptTemp = GetTextLocation(1);
gripPoints.append(ptTemp);
int nEdgeNum = m_poly.TotalSegments();
gripPoints.append(*m_poly.Head()); //2
gripPoints.append(*m_poly.Tail()); //3
2026-10-04 00:04:20 +08:00
// add by lgy 20120321,为剖切符号添加剖面图号夹点
2026-09-28 15:28:50 +08:00
if (GetIsHasIndexS())
{
ptTemp = GetIndexLocation(0);
gripPoints.append(ptTemp); //4
}
if (GetIsHasIndexE())
{
ptTemp = GetIndexLocation(1);
gripPoints.append(ptTemp); //5
}
for (int i = 0; i < nEdgeNum; i++)
{
GeCurveSegment seg;
m_poly.Nth(i, seg);
ADSGePoint3d ptMid = seg.MidPoint();
gripPoints.append(ptMid);
}
}
Acad::ErrorStatus AecXDbSymbSection::subGetGripPoints(AcGePoint3dArray& gripPoints,
AcDbIntArray& osnapMasks,
AcDbIntArray& geomIds) const
{
getGripPoints(gripPoints);
return Acad::eOk;
}
namespace
{
double PixelToWcs(int nPixel)
{
ads_point ptScreenSize;
double nViewSize;
struct resbuf rb1, rb2;
acedGetVar(_T("ScreenSize"), &rb1);
acedGetVar(_T("ViewSize"), &rb2);
nViewSize = rb2.resval.rreal;
ads_point_set(rb1.resval.rpoint, ptScreenSize);
if (ptScreenSize[1] < 1.0e-6 || nViewSize < 1.0e-6)
return 0.0;
double hight = (nViewSize / ptScreenSize[Y]) * nPixel;
return hight;
}
bool Grip_WorldDrawfunc(AcDbGripData *pThis,
AcGiWorldDraw *pWd,
const AcDbObjectId &entId,
AcDbGripOperations::DrawType type,
AcGePoint3d *cursor,
double dGripSize)
{
AcGiFillType eOldFill = pWd->subEntityTraits().fillType();
int nOldColor = pWd->subEntityTraits().color();
AecXDbSymbSection::GripData* pGrip = (AecXDbSymbSection::GripData*)pThis->appData();
AcGePoint3d ptGe[5], ptBox[5];
AcGePoint3d ptGrip = pThis->gripPoint();
double dOne = PixelToWcs(1);
ptGe[0] = ptGrip;
ptGe[0].x -= 4 * dOne;
ptGe[1] = ptGrip;
ptGe[1].x += 4 * dOne;
ptBox[0] = ptGe[0];
ptBox[0].y -= 4 * dOne;
ptBox[1] = ptGe[0];
ptBox[1].y += 4 * dOne;
ptBox[2] = ptGe[1];
ptBox[2].y += 4 * dOne;
ptBox[3] = ptGe[1];
ptBox[3].y -= 4 * dOne;
pWd->subEntityTraits().setFillType(kAcGiFillAlways);
pWd->geometry().polygon(4, ptBox);
pWd->subEntityTraits().setFillType(eOldFill);
if (pGrip->m_bDrawFrame)
{
AcGePoint3d arFrame1[] = {pGrip->m_pt0, pGrip->m_pt1, pGrip->m_pt2, pGrip->m_pt3,};
pWd->subEntityTraits().setColor(9);
pWd->geometry().polyline(4, arFrame1);
pWd->subEntityTraits().setColor(nOldColor);
}
return true;
}
}
bool AecXDbSymbSection::hasLastPoint() const
{
assertReadEnabled();
int v;
return GetSpecialtyData()->HasKey(_T("_SECTION_LAST_POINT_"), v) == FALSE ? false : true;
}
void AecXDbSymbSection::setLastPoint(const AcGePoint3d &pt)
{
AssertWriteEnabled();
GetSpecialtyData(AcDb::kForWrite)->SetAt(_T("_SECTION_LAST_POINT_"), pt);
}
AcGePoint3d AecXDbSymbSection::getLastPoint() const
{
assertReadEnabled();
AcGePoint3d pt(AcGePoint3d::kOrigin);
GetSpecialtyData()->GetAt(_T("_SECTION_LAST_POINT_"), pt);
return pt;
}
Acad::ErrorStatus AecXDbSymbSection::subGetGripPoints(AcDbGripDataPtrArray &grips
, const double curViewUnitSize
, const int gripSize
, const AcGeVector3d &curViewDir
, const int bitflags) const
{
AcGePoint3dArray gripPoints;
getGripPoints(gripPoints);
if (gripPoints.length() < 3) return Acad::eBufferTooSmall;
m_GripDatas.clear();
2026-10-04 00:04:20 +08:00
// 先把 grippoints 里的点都绘制出来
2026-09-28 15:28:50 +08:00
for (int i(0); i < gripPoints.length(); ++i)
{
GripData gpd;
gpd.m_idx = i;
AcDbGripData *pGripData = new AcDbGripData;
pGripData->setGripPoint(gripPoints.at(i));
pGripData->setWorldDraw(Grip_WorldDrawfunc);
m_GripDatas.push_back(gpd);
void *p = &*m_GripDatas.rbegin();
pGripData->setAppData(p);
grips.append(pGripData);
}
if (!hasLastPoint()) return Acad::eOk;
AcGePoint3d ptLast = getLastPoint();
int nEdges = m_poly.TotalSegments();
AcGeVector3d vt1((gripPoints[0] - gripPoints[2]).normalize())
, vt2((gripPoints[1] - gripPoints[3]).normalize());
2026-10-04 00:04:20 +08:00
// 同向且平行
2026-09-28 15:28:50 +08:00
if (vt1.isCodirectionalTo(vt2) && vt1.isParallelTo(vt2))
{
AcGeRay3d ray1(gripPoints[2], vt1);
AcGeRay3d ray2(gripPoints[3], vt2);
AcGePoint3d pt1 = ray1.closestPointTo(ptLast);
AcGePoint3d pt2 = ray2.closestPointTo(ptLast);
2026-10-04 00:04:20 +08:00
GripData &lastGrip = *m_GripDatas.rbegin(); // 最后的夹点
2026-09-28 15:28:50 +08:00
lastGrip.m_bDrawFrame = true;
lastGrip.m_pt0 = gripPoints[2];
lastGrip.m_pt1 = pt1;
lastGrip.m_pt2 = pt2;
lastGrip.m_pt3 = gripPoints[3];
}
return Acad::eOk;
}
Acad::ErrorStatus AecXDbSymbSection::subMoveGripPointsAt(const AcDbVoidPtrArray &appData
, const AcGeVector3d &offset
, const int bitflags)
{
AssertWriteEnabled();
AcDbIntArray indices;
if (!appData.isEmpty())
{
GripData *pAppData = (GripData *)appData.first();
indices.append(pAppData->m_idx);
return subMoveGripPointsAt(indices, offset);
}
else
{
return Acad::eOk;
}
return Acad::eOk;
}
Acad::ErrorStatus AecXDbSymbSection::subMoveGripPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& vtOffset)
{
using namespace GlobalFunc;
AssertWriteEnabled();
2026-10-04 00:04:20 +08:00
if (!IsValid()) // 判断是否符合绘制条件
2026-09-28 15:28:50 +08:00
{
return Acad::eOk;
}
ADSGePoint3d offset(vtOffset[0], vtOffset[1]);
2026-10-04 00:04:20 +08:00
// modify by lgy 20120322, 9.0文字位置点为相对于线的ECS坐标系下的点,
// 故不需要再判断移动的点是不是在默认位置
2026-09-28 15:28:50 +08:00
// ADSGePoint3d ptDef1=GetDefaultTextLocation(0);
// ADSGePoint3d ptDef2=GetDefaultTextLocation(1);
// BOOL bAtDefault1=(m_ptText1.Distance2d(ptDef1)<g_Option::instance()._DIST_SNAP);
// BOOL bAtDefault2=(m_ptText2.Distance2d(ptDef2)<g_Option::instance()._DIST_SNAP);
// BOOL bMoveText1 = FALSE;
// BOOL bMoveText2 = FALSE;
BOOL bMT1 = FALSE;
BOOL bMT2 = FALSE;
ADSGePoint3d offsetSViewLine(offset),
offsetEViewLine(offset);
int nSeg = m_poly.TotalSegments();
for (int i = 0; i < indices.length(); i++)
{
int idx = indices[i];
if (idx == 0) // GetTextLocation(0)
{
//if (!bMT1)
//{
2026-10-04 00:04:20 +08:00
// modify by lgy 20120322,移动夹点时需要将移动的夹点从ecs坐标系转换成为wcs坐标系
2026-09-28 15:28:50 +08:00
// m_ptText1 +=offset;
// bMoveText1 = TRUE;
ADSGePoint3d ptTemp = GetTextLocation(0),
ptOther = GetTextLocation(1),
ptSIndex = GetIndexLocation(0),
ptEIndex = GetIndexLocation(1);
ptTemp += offsetSViewLine;
GeCurveSegment segFirst;
m_poly.Nth(0, segFirst);
GeCurveSegment segLast;
m_poly.Nth(m_poly.TotalSegments() - 1, segLast);
ADSGePoint3d ptView;
ads_polar(segFirst.StartPoint(), m_nViewDir, 100.0, ptView);
2026-10-04 00:04:20 +08:00
if (segFirst.OnWhichSide(ptView) != segFirst.OnWhichSide(ptTemp)) // 反向
2026-09-28 15:28:50 +08:00
{
m_nViewDir = GlobalFunc::AngleRangeTo2PI(m_nViewDir + PI);
2026-10-04 00:04:20 +08:00
if (GetNonPerpendicularitySection()) // 不平行
2026-09-28 15:28:50 +08:00
m_nViewDir2 = GlobalFunc::AngleRangeTo2PI(m_nViewDir2 + PI);
2026-10-04 00:04:20 +08:00
// 将另外的点都进行镜像操作
2026-09-28 15:28:50 +08:00
{
ADSGePoint3d ptMid, ptMirror;
segLast.ProjectToMe(ptOther, ptMid);
ptMid.Mirror(ptOther, ptMirror);
SetTextLocation(1, ptMirror);
segFirst.ProjectToMe(ptSIndex, ptMid);
ptMid.Mirror(ptSIndex, ptMirror);
SetIndexLocation(0, ptMirror);
segLast.ProjectToMe(ptEIndex, ptMid);
ptMid.Mirror(ptEIndex, ptMirror);
SetIndexLocation(1, ptMirror);
}
}
SetTextLocation(0, ptTemp);
//bMT1 = TRUE;
//}
}
else if (idx == 1) // GetTextLocation(1)
{
//if (!bMT2)
//{
2026-10-04 00:04:20 +08:00
// modify by lgy 20120322,移动夹点时需要将移动的夹点从ecs坐标系转换成为wcs坐标系
2026-09-28 15:28:50 +08:00
// m_ptText2 +=offset;
// bMoveText2 = TRUE;
ADSGePoint3d ptTemp = GetTextLocation(1),
ptOther = GetTextLocation(0),
ptSIndex = GetIndexLocation(0),
ptEIndex = GetIndexLocation(1);
ptTemp += offsetEViewLine;
GeCurveSegment segFirst;
m_poly.Nth(0, segFirst);
GeCurveSegment segLast;
m_poly.Nth(m_poly.TotalSegments() - 1, segLast);
ADSGePoint3d ptView;
ads_polar(segLast.EndPoint(), GetEndViewLineDir(), 100.0, ptView);
2026-10-04 00:04:20 +08:00
if (segLast.OnWhichSide(ptView) != segLast.OnWhichSide(ptTemp)) // 反向
2026-09-28 15:28:50 +08:00
{
m_nViewDir = GlobalFunc::AngleRangeTo2PI(m_nViewDir + PI);
2026-10-04 00:04:20 +08:00
if (GetNonPerpendicularitySection()) // 不平行
2026-09-28 15:28:50 +08:00
m_nViewDir2 = GlobalFunc::AngleRangeTo2PI(m_nViewDir2 + PI);
2026-10-04 00:04:20 +08:00
// 将另外一个点镜像
2026-09-28 15:28:50 +08:00
{
ADSGePoint3d ptMid, ptMirror;
segFirst.ProjectToMe(ptOther, ptMid);
ptMid.Mirror(ptOther, ptMirror);
SetTextLocation(0, ptMirror);
segFirst.ProjectToMe(ptSIndex, ptMid);
ptMid.Mirror(ptSIndex, ptMirror);
SetIndexLocation(0, ptMirror);
segLast.ProjectToMe(ptEIndex, ptMid);
ptMid.Mirror(ptEIndex, ptMirror);
SetIndexLocation(1, ptMirror);
}
}
SetTextLocation(1, ptTemp);
// bMT2 = TRUE;
//}
}
else if (idx == 2) // *m_poly.Head()
{
GeLine ln;
GeArc arc;
m_poly.Nth(0, ln, arc);
Vector3D vt = ln.StartPoint() - ln.EndPoint();
((AcGeVector3d &)vt).normalize();
double nInc = (offset & vt);
ads_polar(ADSGePoint3d(ln.StartPoint()), ln.Direction() - PI, nInc, *m_poly.Head());
vt.Scale(nInc);
if (!bMT1)
{
2026-10-04 00:04:20 +08:00
// delete by lgy 20120322,该点已经保存为ECS坐标,故不需要再转换偏移
2026-09-28 15:28:50 +08:00
// m_ptText1 += vt;
bMT1 = TRUE;
Vector3D vtViewLine = Vector3D(cos(m_nViewDir), sin(m_nViewDir));
((AcGeVector3d &)vtViewLine).normalize();
nInc = (offset & vtViewLine);
vtViewLine.Scale(nInc);
offsetSViewLine = ADSGePoint3d(vtViewLine.x, vtViewLine.y, vtViewLine.z);
}
}
else if (idx == 3) // *m_poly.Tail()
{
GeLine ln;
GeArc arc;
m_poly.Nth(nSeg - 1, ln, arc);
Vector3D vt = ln.EndPoint() - ln.StartPoint();
((AcGeVector3d &)vt).normalize();
double nInc = (offset & vt);
ads_polar(ADSGePoint3d(ln.EndPoint()), ln.Direction(), nInc, *m_poly.Tail());
vt.Scale(nInc);
if (!bMT2)
{
2026-10-04 00:04:20 +08:00
// delete by lgy 20120322,该点已经保存为ECS坐标,故不需要再转换偏移
2026-09-28 15:28:50 +08:00
// m_ptText2 += vt;
bMT2 = TRUE;
Vector3D vtViewLine = Vector3D(cos(GetEndViewLineDir()), sin(GetEndViewLineDir()));
((AcGeVector3d &)vtViewLine).normalize();
nInc = (offset & vtViewLine);
vtViewLine.Scale(nInc);
offsetEViewLine = ADSGePoint3d(vtViewLine.x, vtViewLine.y, vtViewLine.z);
}
}
else
{
2026-10-04 00:04:20 +08:00
// add by lgy 201203,为剖面剖切添加了两个剖面图号夹点
2026-09-28 15:28:50 +08:00
if (idx == 4)
{
if (GetIsHasIndexS()) // GetIndexLocation(0)
{
ADSGePoint3d pt = GetIndexLocation(0);
pt += offset;
SetIndexLocation(0, pt);
continue;
}
else if (GetIsHasIndexE()) // GetIndexLocation(1)
{
ADSGePoint3d pt = GetIndexLocation(1);
pt += offset;
SetIndexLocation(1, pt);
continue;
}
}
else if (idx == 5)
{
if (GetIsHasIndexS() && GetIsHasIndexE()) // GetIndexLocation(1)
{
ADSGePoint3d pt = GetIndexLocation(1);
pt += offset;
SetIndexLocation(1, pt);
continue;
}
}
if (GetIsHasIndexS())
{
idx--;
}
if (GetIsHasIndexE())
{
idx--;
}
// Move Edge
int nEdgeIndex = idx - 4;
int nTotalEdge = m_poly.TotalSegments();
GeLine ln;
GeArc arc;
m_poly.Nth(nEdgeIndex, ln, arc);
ln.StartPoint() += offset;
ln.EndPoint() += offset;
ln.SetLineFlag(LS_INFINITE);
GeDirectionCurve prevSeg,
nextSeg;
int nPrev = nEdgeIndex - 1,
nNext = nEdgeIndex + 1;
ADSGePoint3d ptStart,
ptEnd;
BOOL bUpdateIt = TRUE;
2026-10-04 00:04:20 +08:00
if (nPrev >= 0 && nPrev < nTotalEdge) // 更新起点
2026-09-28 15:28:50 +08:00
{
m_poly.Nth(nPrev, prevSeg);
prevSeg.SetLineFlag(LS_INFINITE);
ADSGePoint3d ptInt[2];
int nIntNum = prevSeg.Intersection(ln, ptInt[0], ptInt[1]);
if (nIntNum == 1)
ptStart = ptInt[0];
else if (nIntNum == 2)
{
ptStart = GeLine(ptInt[0], ptInt[1]).NearPoint(ln.StartPoint());
}
else
bUpdateIt = FALSE;
}
else
{
Vector3D vtView(cos(m_nViewDir), sin(m_nViewDir));
double nDot = (offset & vtView);
vtView *= nDot;
ptStart = *m_poly[nEdgeIndex] + vtView;
if (!bMT1)
{
2026-10-04 00:04:20 +08:00
// delete by lgy 20120322,移动夹点时需要将移动的夹点从ecs坐标系转换成为wcs坐标系
2026-09-28 15:28:50 +08:00
// m_ptText1 +=vtView;
bMT1 = TRUE;
offsetSViewLine = ADSGePoint3d(vtView.x, vtView.y, vtView.z);
}
}
2026-10-04 00:04:20 +08:00
// 更新下一点
2026-09-28 15:28:50 +08:00
if (nNext >= 0 && nNext < nTotalEdge)
{
m_poly.Nth(nNext, nextSeg);
nextSeg.SetLineFlag(LS_INFINITE);
ADSGePoint3d ptInt[2];
int nIntNum = nextSeg.Intersection(ln, ptInt[0], ptInt[1]);
if (nIntNum == 1)
ptEnd = ptInt[0];
else if (nIntNum == 2)
{
ptEnd = GeLine(ptInt[0], ptInt[1]).NearPoint(ln.EndPoint());
}
else
bUpdateIt = FALSE;
}
else
{
// Vector3D vtView(cos(m_nViewDir), sin(m_nViewDir));
Vector3D vtView(cos(GetEndViewLineDir()), sin(GetEndViewLineDir()));
double nDot = (offset & vtView);
vtView *= nDot;
ptEnd = *m_poly[nEdgeIndex + 1] + vtView;
if (!bMT2)
{
2026-10-04 00:04:20 +08:00
// delete by lgy 20120322,移动夹点时需要将移动的夹点从ecs坐标系转换成为wcs坐标系
2026-09-28 15:28:50 +08:00
// m_ptText1 +=vtView;
bMT2 = TRUE;
offsetEViewLine = ADSGePoint3d(vtView.x, vtView.y, vtView.z);
}
}
if (bUpdateIt)
{
*m_poly[nEdgeIndex] = ptStart;
if (nNext >= 0 && nNext < m_poly.Length())
{
*m_poly[nNext] = ptEnd;
}
}
}
}
2026-10-04 00:04:20 +08:00
// modify by lgy 20120322,9.0文字位置点全部保存为ECS坐标系下的点
2026-09-28 15:28:50 +08:00
// if(bAtDefault1 && !bMoveText1)
// m_ptText1=GetDefaultTextLocation(0);
// if(bAtDefault2 && !bMoveText2)
// m_ptText2=GetDefaultTextLocation(1);
//if (bMoveText1)
//{
// GeCurveSegment segFirst;
// m_poly.Nth(0, segFirst);
// ADSGePoint3d ptView;
// ads_polar(segFirst.StartPoint(), m_nViewDir, 100.0, ptView);
// if(segFirst.OnWhichSide(ptView)!=segFirst.OnWhichSide(m_ptText1))
// {
// m_nViewDir=GlobalFunc::AngleRangeTo2PI(m_nViewDir+PI);
// m_ptText2=GetDefaultTextLocation(1);
// }
//}
//else if (bMoveText2)
//{
// GeCurveSegment segLast;
// m_poly.Nth(m_poly.TotalSegments()-1, segLast);
// ADSGePoint3d ptView;
// ads_polar(segLast.EndPoint(), m_nViewDir, 100.0, ptView);
// if(segLast.OnWhichSide(ptView)!=segLast.OnWhichSide(m_ptText2))
// {
// m_nViewDir=GlobalFunc::AngleRangeTo2PI(m_nViewDir+PI);
// }
//}
return Acad::eOk;
}
Acad::ErrorStatus
AecXDbSymbSection::subGetStretchPoints(AcGePoint3dArray& stretchPoints) const
{
assertReadEnabled();
AcDbIntArray osnapModes;
AcDbIntArray geomIds;
return subGetGripPoints(stretchPoints, osnapModes, geomIds);
}
Acad::ErrorStatus
AecXDbSymbSection::subMoveStretchPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
AssertWriteEnabled();
DualPtrList<int> lstIndices;
for (long i = 0; i < indices.length(); i++)
lstIndices.FindOrAddTail(indices[i]);
int nAllLength = m_poly.TotalSegments() + 4,
nFirstSeg = 4,
nLastSeg = 4 + m_poly.TotalSegments() - 1;
if (GetIsHasIndexS())
{
nAllLength++;
nFirstSeg++;
nLastSeg++;
}
if (GetIsHasIndexE())
{
nAllLength++;
nFirstSeg++;
nLastSeg++;
}
bool bHasSPt(false),
bHasEPt(false),
bAllSel(false),
bHasStartText(false),
bHasEndText(false);
AcDbIntArray indices2;
if (lstIndices.Find(2) > -1)
{
indices2.append(2);
bHasSPt = true;
}
if (lstIndices.Find(3) > -1)
{
indices2.append(3);
bHasEPt = true;
}
if (lstIndices.Find(nFirstSeg) > -1)
{
indices2.append(nFirstSeg);
bHasStartText = bHasSPt;
bHasSPt = true;
}
if (lstIndices.Find(nLastSeg) > -1)
{
if (nFirstSeg != nLastSeg)
indices2.append(nLastSeg);
bHasEndText = bHasEPt;
bHasEPt = true;
}
int nSel = lstIndices.GetLength();
bAllSel = nAllLength == nSel;
for (i = 0; i < nSel; i++)
{
int nIndex = lstIndices[i];
if (bHasSPt && (nIndex == 2 || nIndex == nFirstSeg || (GetIsHasIndexS() && nIndex == 4)))
continue;
if (bHasEPt && (nIndex == 3 || nIndex == nLastSeg || (GetIsHasIndexS() && GetIsHasIndexE() && nIndex == 5) || (!GetIsHasIndexS() && GetIsHasIndexE() && nIndex == 4)))
continue;
if (bAllSel && (nIndex == 0 || nIndex == 1))
continue;
if (bHasStartText && nIndex == 0)
continue;
if (bHasEndText && nIndex == 1)
continue;
indices2.append(nIndex);
}
return subMoveGripPointsAt(indices2, offset);
}
Acad::ErrorStatus AecXDbSymbSection::subTransformBy(const AcGeMatrix3d& xform)
{
AssertWriteEnabled();
AecXDbSymbWithText::subTransformBy(xform);
ads_matrix mat;
memcpy(mat, &xform, sizeof(AcGeMatrix3d));
int i(0),
len = m_poly.Length();
for (i = 0; i < len; i++)
{
m_poly[i]->TransformBy(mat);
}
ADSGePoint3d ptTemp1, ptTemp2;
ads_polar(ptTemp1, m_nViewDir, 1000.0, ptTemp2);
ptTemp1.TransformBy(mat);
ptTemp2.TransformBy(mat);
m_nViewDir = ads_angle(ptTemp1, ptTemp2);
2026-10-04 00:04:20 +08:00
// modify by lgy 20120322,9.0中新添加图号文字,并且各位置点保存为ecs坐标
2026-09-28 15:28:50 +08:00
// m_ptText1.TransformBy(mat);
// m_ptText2.TransformBy(mat);
2026-10-04 00:04:20 +08:00
if (GetNonPerpendicularitySection()) // 不平行,可能有2个剖视方向
2026-09-28 15:28:50 +08:00
{
ADSGePoint3d ptTemp3, ptTemp4;
ads_polar(ptTemp3, m_nViewDir2, 1000.0, ptTemp4);
ptTemp3.TransformBy(mat);
ptTemp4.TransformBy(mat);
m_nViewDir2 = ads_angle(ptTemp3, ptTemp4);
}
return Acad::eOk;
}
int AecXDbSymbSection::ConvertText(TConvertTextPtr ptr, void *pData)
{
AssertWriteEnabled();
TCString sText;
int nRet = ptr(m_sText, sText, pData);
if (nRet == RTNORM)
{
m_sText = sText;
}
int nRet1 = ptr(m_sDrawingIndex, sText, pData);
if (nRet1 == RTNORM)
{
m_sDrawingIndex = sText;
}
else if (nRet1 == RTERROR)
nRet = nRet1;
return nRet;
}
2026-10-04 00:04:20 +08:00
// sg add 090626,解决需求平台问题1416,支持查找替换操作
2026-09-28 15:28:50 +08:00
BOOL AecXDbSymbSection::GetText(Adesk::UInt32 cookies, AecXDbText &text) const
{
2026-10-04 00:04:20 +08:00
// modify by lgy 20120322,9.0添加图号文字,要支持查找替换操作
2026-09-28 15:28:50 +08:00
//if (cookies != 0)
// return FALSE;
//text.setPropertiesFrom(this);
//text.SetAlignment(AcGiDraw::kMiddleCenter);
//text.SetStyleId(m_idTextStyle);
//text.SetHeight(m_nTextHeight);
//text.SetText(m_sText);
//text.SetLocation(m_ptText1);
if (((GetIsHasIndexS() || GetIsHasIndexE()) && (cookies > 1)) || (cookies > 0))
{
return FALSE;
}
text.setPropertiesFrom(this);
text.SetAlignment(AcGiDraw::kMiddleCenter);
2026-10-04 00:04:20 +08:00
if (cookies == 0) // 剖切编号
2026-09-28 15:28:50 +08:00
{
text.SetStyleId(m_idTextStyle);
text.SetHeight(m_nTextHeight);
ADSGePoint3d ptText = GetTextLocation(0);
text.SetLocation(ptText);
text.SetText(m_sText);
}
2026-10-04 00:04:20 +08:00
else // 剖切图号
2026-09-28 15:28:50 +08:00
{
text.SetStyleId(m_idIndexStyle);
text.SetHeight(m_dIndexHeight);
2026-10-04 00:04:20 +08:00
if (GetIsHasIndexS()) // 图号始端有文字
2026-09-28 15:28:50 +08:00
{
text.SetRotation(GetIndexTextRotation(0));
text.SetAlignment(GetIndexTextAlignment(0));
ADSGePoint3d pt = GetIndexLocation(0);
text.SetLocation(pt);
}
2026-10-04 00:04:20 +08:00
else if (GetIsHasIndexE()) // 图号末端有文字
2026-09-28 15:28:50 +08:00
{
text.SetRotation(GetIndexTextRotation(1));
text.SetAlignment(GetIndexTextAlignment(1));
ADSGePoint3d pt = GetIndexLocation(1);
text.SetLocation(pt);
}
text.SetText(m_sDrawingIndex);
}
return TRUE;
}
TextPosition AecXDbSymbSection::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 AecXDbSymbSection::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);
2026-10-04 00:04:20 +08:00
// modify by lgy 20120419,9.0为增加剖面图号,故需要支持查找替换
2026-09-28 15:28:50 +08:00
// SetText(text.GetText());
if (posRep.m_nCookies == 0)
{
SetText(text.GetText());
}
else if (posRep.m_nCookies == 1)
{
SetDrawingIndex(text.GetText());
}
if (!posNext)
{
posNext.m_nCookies = posRep.m_nCookies + 1;
posNext.m_nTextPos = 0;
}
return posNext;
}
void AecXDbSymbSection::GetTips(PtrList<ObjInfoUnit> &lstInfo) const
{
2026-10-04 00:04:20 +08:00
lstInfo.Append(new ObjInfoUnit(_T("对象类型"), _T("剖切符号")));
lstInfo.Append(new ObjInfoUnit(_T("剖切号"), m_sText));
2026-09-28 15:28:50 +08:00
if (!!m_sDrawingIndex)
2026-10-04 00:04:20 +08:00
lstInfo.Append(new ObjInfoUnit(_T("剖面图号"), m_sDrawingIndex));
lstInfo.Append(new ObjInfoUnit(_T("字高"), TCString(_T("%.1fP"), (double)m_nTextHeight)));
//lstInfo.Append(new ObjInfoUnit(_T("线宽"), TCString(_T("%.1f"), (double)m_rLineWidth)));
2026-09-28 15:28:50 +08:00
return;
}
Acad::ErrorStatus AecXDbSymbSection::GetGripText(int idx, CString &cs) const
{
int vexLen;
vexLen = m_poly.Length();
if (idx <= 1) // 0\1
{
2026-10-04 00:04:20 +08:00
cs = _T("移动文字和改变方向");
2026-09-28 15:28:50 +08:00
}
else if (idx == 4)
{
if (GetIsHasIndexS() || GetIsHasIndexE())
{
2026-10-04 00:04:20 +08:00
cs = _T("移动文字");
2026-09-28 15:28:50 +08:00
}
else
{
2026-10-04 00:04:20 +08:00
cs = _T("改变剖切位置");
2026-09-28 15:28:50 +08:00
}
}
else if (idx == 5)
{
if (GetIsHasIndexS() || GetIsHasIndexE())
{
2026-10-04 00:04:20 +08:00
cs = _T("移动文字");
2026-09-28 15:28:50 +08:00
}
else
{
2026-10-04 00:04:20 +08:00
cs = _T("改变剖切位置");
2026-09-28 15:28:50 +08:00
}
}
else
{
2026-10-04 00:04:20 +08:00
cs = _T("改变剖切位置");
2026-09-28 15:28:50 +08:00
}
return Acad::eOk;
}
///////////////////////////////////////////////////////////
// Properties
ADSGePoint3d AecXDbSymbSection::GetDefaultTextLocation(int nPos) const
{
double nGap = m_nTextHeight * GetPScale() / 2.0,
nGap1 = g_DimOption::instance().g_dSectionSegDirLength * GetPScale();
if (!m_bViewLine)
nGap1 = 0.0;
ADSGePoint3d ptRet;
//ads_polar(nPos==0? *m_poly.Head():*m_poly.Tail(), m_nViewDir, nGap1+nGap*2, ptRet);
if (nPos == 0)
{
ads_polar(*m_poly.Head(), m_nViewDir, nGap1 + nGap * 2, ptRet);
}
else
{
ads_polar(*m_poly.Tail(), GetEndViewLineDir(), nGap1 + nGap * 2, ptRet);
}
return ptRet;
}
ADSGePoint3d AecXDbSymbSection::GetTextLocation(int nPos, BOOL bEcsPoint) const
{
//return (nPos==0? m_ptText1 : m_ptText2);
2026-10-04 00:04:20 +08:00
ADSGePoint3d pt = (nPos == 0) ? m_ptText1 : m_ptText2; // ECS点
if (!bEcsPoint) // WCS点
2026-09-28 15:28:50 +08:00
{
pt = GetWcsTextPt(nPos);
}
return pt;
}
void AecXDbSymbSection::GetPoly2D(GePoly2D &poly) const
{
poly = m_poly;
}
double AecXDbSymbSection::GetViewDirection() const
{
return m_nViewDir;
}
const TCHAR * AecXDbSymbSection::GetText() const
{
return (const TCHAR *)m_sText;
}
BOOL AecXDbSymbSection::HasViewLine() const
{
return (m_bViewLine != 0);
}
void AecXDbSymbSection::SetTextLocation(int nPos, ADSGePoint3d pt)
{
AssertWriteEnabled();
2026-10-04 00:04:20 +08:00
// modify by lgy 20120319,修改该部分是为了满足9.0中求的剖面图号位置点
2026-09-28 15:28:50 +08:00
// if(nPos==0)
//m_ptText1=pt;
// else
//m_ptText2=pt;
2026-10-04 00:04:20 +08:00
AcGePoint2d ptOrigin = GetEcsOriginPt(nPos); // 获得ECS原点
2026-09-28 15:28:50 +08:00
AcGeVector2d xAxis, yAxis;
2026-10-04 00:04:20 +08:00
GetEcsAxisVector(xAxis, yAxis, nPos); // 获得ECS坐标轴方向
2026-09-28 15:28:50 +08:00
AcGeMatrix2d mat2d;
mat2d = mat2d.alignCoordSys(ptOrigin, xAxis, yAxis,
AcGePoint2d(0, 0), AcGeVector2d(1, 0), AcGeVector2d(0, 1));
AcGePoint2d ptResult(pt.x, pt.y);
ptResult.transformBy(mat2d); //WCS2ECS
2026-10-04 00:04:20 +08:00
if (nPos == 0) // 剖切编号始端位置点
2026-09-28 15:28:50 +08:00
{
m_ptText1.x = ptResult.x / GetPScale();
2026-10-04 00:04:20 +08:00
m_ptText1.y = ptResult.y / GetPScale(); // 用图纸比例保存
2026-09-28 15:28:50 +08:00
}
2026-10-04 00:04:20 +08:00
else if (nPos == 1) // 剖切编号末端位置点
2026-09-28 15:28:50 +08:00
{
m_ptText2.x = ptResult.x / GetPScale();
2026-10-04 00:04:20 +08:00
m_ptText2.y = ptResult.y / GetPScale(); // 用图纸比例保存
2026-09-28 15:28:50 +08:00
}
}
void AecXDbSymbSection::SetPoly2D(const GePoly2D &poly)
{
AssertWriteEnabled();
m_poly = poly;
}
void AecXDbSymbSection::SetText(const TCHAR * pStr)
{
AssertWriteEnabled();
m_sText = pStr;
}
void AecXDbSymbSection::SetViewDirection(double vec)
{
AssertWriteEnabled();
m_nViewDir = vec;
}
void AecXDbSymbSection::SetViewLine(BOOL bTrue)
{
AssertWriteEnabled();
m_bViewLine = bTrue;
}
2026-10-04 00:04:20 +08:00
AcGePoint2d AecXDbSymbSection::GetEcsOriginPt(int nPos) const //获取ECS原点,文字位置参考点
2026-09-28 15:28:50 +08:00
{
ADSGePoint3d ptOrigin;
2026-10-04 00:04:20 +08:00
if (nPos == 0) // 剖切编号文字始端位置点
2026-09-28 15:28:50 +08:00
{
ptOrigin = GetDefaultTextLocation(0);
}
2026-10-04 00:04:20 +08:00
else if (nPos == 1) // 剖切编号文字末端位置点
2026-09-28 15:28:50 +08:00
{
ptOrigin = GetDefaultTextLocation(1);
}
2026-10-04 00:04:20 +08:00
else if (nPos == 2) // 剖切图号文字始端位置点
2026-09-28 15:28:50 +08:00
{
ptOrigin = GetDefaultIndexLocation(0);
}
2026-10-04 00:04:20 +08:00
else if (nPos == 3) // 剖切图号文字末端位置点
2026-09-28 15:28:50 +08:00
{
ptOrigin = GetDefaultIndexLocation(1);
}
return ptOrigin.AsAcGePoint2d();
}
void AecXDbSymbSection::GetEcsAxisVector(AcGeVector2d &xAxis, AcGeVector2d &yAxis, int nPos) const
{
if (m_poly.TotalSegments() < 1)
{
return;
}
switch (nPos)
{
case 0:
xAxis = m_poly[0] - m_poly[1];
break;
case 1:
xAxis = m_poly[m_poly.Length() - 2] - m_poly[m_poly.Length() - 1];
break;
case 2:
2026-10-04 00:04:20 +08:00
if (GetDimDirection() == 1) // 沿剖视方向
2026-09-28 15:28:50 +08:00
xAxis = AcGeVector2d(cos(m_nViewDir), sin(m_nViewDir));
else
xAxis = m_poly[0] - m_poly[1];
break;
case 3:
2026-10-04 00:04:20 +08:00
if (GetDimDirection() == 1) // 沿剖视方向
2026-09-28 15:28:50 +08:00
xAxis = AcGeVector2d(cos(GetEndViewLineDir()), sin(GetEndViewLineDir()));
else
xAxis = m_poly[m_poly.Length() - 2] - m_poly[m_poly.Length() - 1];
yAxis = xAxis.perpVector();
break;
}
yAxis = xAxis.perpVector();
xAxis.normalize();
yAxis.normalize();
}
2026-10-04 00:04:20 +08:00
//将文字位置由ECS转换为WCS
2026-09-28 15:28:50 +08:00
ADSGePoint3d AecXDbSymbSection::GetWcsTextPt(int nPos) const
{
2026-10-04 00:04:20 +08:00
AcGePoint2d ptOrigin = GetEcsOriginPt(nPos); // 获得ECS原点
2026-09-28 15:28:50 +08:00
AcGePoint2d ptResult;
2026-10-04 00:04:20 +08:00
if (nPos == 0) // 剖切编号文字始端位置
2026-09-28 15:28:50 +08:00
{
ptResult.x = m_ptText1.x * GetPScale();
ptResult.y = m_ptText1.y * GetPScale();
}
2026-10-04 00:04:20 +08:00
else if (nPos == 1) // 剖切编号文字末端位置
2026-09-28 15:28:50 +08:00
{
ptResult.x = m_ptText2.x * GetPScale();
ptResult.y = m_ptText2.y * GetPScale();
}
2026-10-04 00:04:20 +08:00
else if (nPos == 2) // 剖切图号文字始端位置
2026-09-28 15:28:50 +08:00
{
ptResult.x = m_ptSIndex.x * GetPScale();
ptResult.y = m_ptSIndex.y * GetPScale();
}
2026-10-04 00:04:20 +08:00
else if (nPos == 3) // 剖切图号文字末端位置
2026-09-28 15:28:50 +08:00
{
ptResult.x = m_ptEIndex.x * GetPScale();
ptResult.y = m_ptEIndex.y * GetPScale();
}
AcGeVector2d xAxis, yAxis;
2026-10-04 00:04:20 +08:00
GetEcsAxisVector(xAxis, yAxis, nPos); // 获得ECS坐标轴方向
2026-09-28 15:28:50 +08:00
AcGeMatrix2d mat2d;
mat2d = mat2d.alignCoordSys(AcGePoint2d(0, 0), AcGeVector2d(1, 0),
2026-10-04 00:04:20 +08:00
AcGeVector2d(0, 1), ptOrigin, xAxis, yAxis); // 构造转换矩阵
2026-09-28 15:28:50 +08:00
ptResult.transformBy(mat2d); // ECS2WCS
return ADSGePoint3d(ptResult.x, ptResult.y);
}
2026-10-04 00:04:20 +08:00
TCString AecXDbSymbSection::GetDrawingIndex() const // 剖面图号的文字内容
2026-09-28 15:28:50 +08:00
{
return m_sDrawingIndex;
}
void AecXDbSymbSection::SetDrawingIndex(CString strDrawingIndex)
{
AssertWriteEnabled();
m_sDrawingIndex = strDrawingIndex;
}
AcDbObjectId AecXDbSymbSection::GetIndexStyleId() const
{
return m_idIndexStyle;
}
void AecXDbSymbSection::SetIndexStyleId(AcDbObjectId id)
{
AssertWriteEnabled();
m_idIndexStyle = id;
}
2026-10-04 00:04:20 +08:00
double AecXDbSymbSection::GetIndexHeight() const // 文字字高
2026-09-28 15:28:50 +08:00
{
return m_dIndexHeight;
}
2026-10-04 00:04:20 +08:00
void AecXDbSymbSection::SetIndexHeight(double dHeight) // 设置剖面图号文字字高
2026-09-28 15:28:50 +08:00
{
AssertWriteEnabled();
m_dIndexHeight = dHeight;
}
ADSGePoint3d AecXDbSymbSection::GetDefaultIndexLocation(int nPos) const
{
ADSGePoint3d ptView, ptRet;
double dDistance(0.0),
dDrawAngle(0.0),
dText2BaseRatio = GetText2BaseRatios() * m_dIndexHeight * GetPScale();
2026-10-04 00:04:20 +08:00
if (GetDimDirection() == 1) // 沿剖视方向
2026-09-28 15:28:50 +08:00
{
2026-10-04 00:04:20 +08:00
if (m_bViewLine) // 剖面剖切
2026-09-28 15:28:50 +08:00
{
dDistance = g_DimOption::instance().g_dSectionSegDirLength * GetPScale();
2026-10-04 00:04:20 +08:00
if (nPos == 0) // 始端剖切图号位置点
2026-09-28 15:28:50 +08:00
{
ads_polar(m_poly[0], m_nViewDir, g_DimOption::instance().g_dSectionSegDirLength * GetPScale(), ptView);
dDrawAngle = ads_angle(m_poly[1], m_poly[0]);
ads_polar(ptView, dDrawAngle, dText2BaseRatio, ptRet);
}
2026-10-04 00:04:20 +08:00
else // 终点剖切图号位置点
2026-09-28 15:28:50 +08:00
{
ads_polar(*m_poly.Tail(), GetEndViewLineDir(), g_DimOption::instance().g_dSectionSegDirLength * GetPScale(), ptView);
dDrawAngle = ads_angle(m_poly[m_poly.Length() - 2], m_poly[m_poly.Length() - 1]);
ads_polar(ptView, dDrawAngle, dText2BaseRatio, ptRet);
}
}
2026-10-04 00:04:20 +08:00
else // 断面剖切
2026-09-28 15:28:50 +08:00
{
2026-10-04 00:04:20 +08:00
if (nPos == 0) // 始端剖切图号位置点
2026-09-28 15:28:50 +08:00
{
ads_polar(m_poly[0], m_nViewDir, -dText2BaseRatio, ptRet);
}
2026-10-04 00:04:20 +08:00
else // 终点剖切图号位置点
2026-09-28 15:28:50 +08:00
{
ads_polar(*m_poly.Tail(), m_nViewDir, -dText2BaseRatio, ptRet);
}
}
}
2026-10-04 00:04:20 +08:00
else // 沿剖切方向
2026-09-28 15:28:50 +08:00
{
dDistance = g_DimOption::instance().g_dSectionSegLocLength * GetPScale();
2026-10-04 00:04:20 +08:00
if (nPos == 0) // 始端端剖切图号位置点
2026-09-28 15:28:50 +08:00
{
double dSegLen = min(dDistance, m_poly[0].Distance2d(m_poly[1]) / 2);
dDrawAngle = ads_angle(m_poly[0], m_poly[1]);
ads_polar(m_poly[0], dDrawAngle, dSegLen, ptView);
ads_polar(ptView, m_nViewDir, -dText2BaseRatio, ptRet);
}
2026-10-04 00:04:20 +08:00
else // 终点剖切图号位置点
2026-09-28 15:28:50 +08:00
{
int nLength = m_poly.Length();
double dSegLen = min(dDistance, m_poly[nLength - 2].Distance2d(m_poly[nLength - 1]) / 2);
dDrawAngle = ads_angle(m_poly[nLength - 2], m_poly[nLength - 1]);
ads_polar(m_poly[nLength - 1], dDrawAngle, -dSegLen, ptView);
ads_polar(ptView, GetEndViewLineDir(), -dText2BaseRatio, ptRet);
}
}
return ptRet;
}
2026-10-04 00:04:20 +08:00
// 获得图号标注方向,0为剖切方向,1为剖视方向
2026-09-28 15:28:50 +08:00
int AecXDbSymbSection::GetDimDirection() const
{
2026-10-04 00:04:20 +08:00
int nDir = 0; // 默认是剖切方向
2026-09-28 15:28:50 +08:00
if (m_nFlag & SYMB_SECTION_DIM_DIR)
{
nDir = 0;
}
else
{
2026-10-04 00:04:20 +08:00
nDir = 1; // 剖视方向
2026-09-28 15:28:50 +08:00
}
return nDir;
}
2026-10-04 00:04:20 +08:00
//设置图号标注方向, 0为剖切方向,1为剖视方向
2026-09-28 15:28:50 +08:00
void AecXDbSymbSection::SetDimDirection(int nDir)
{
AssertWriteEnabled();
2026-10-04 00:04:20 +08:00
if (nDir == 0) //剖切方向
2026-09-28 15:28:50 +08:00
{
m_nFlag |= SYMB_SECTION_DIM_DIR;
}
2026-10-04 00:04:20 +08:00
else if (nDir == 1) //剖视方向
2026-09-28 15:28:50 +08:00
{
m_nFlag &= ~SYMB_SECTION_DIM_DIR;
}
}
2026-10-04 00:04:20 +08:00
//始端是否有文字
2026-09-28 15:28:50 +08:00
BOOL AecXDbSymbSection::GetIsHasIndexS() const
{
BOOL bHas = (m_nFlag & SYMB_SECTION_START_INDEX);
return bHas;
}
2026-10-04 00:04:20 +08:00
// 设置始端是否有文字
2026-09-28 15:28:50 +08:00
void AecXDbSymbSection::SetIsHasIndexS(BOOL bHas)
{
AssertWriteEnabled();
if (bHas)
{
m_nFlag |= SYMB_SECTION_START_INDEX;
}
else
{
m_nFlag &= ~SYMB_SECTION_START_INDEX;
}
}
2026-10-04 00:04:20 +08:00
// 终端是否有文字
2026-09-28 15:28:50 +08:00
BOOL AecXDbSymbSection::GetIsHasIndexE() const
{
BOOL bHas = (m_nFlag & SYMB_SECTION_END_INDEX);
return bHas;
}
2026-10-04 00:04:20 +08:00
// 设置终端是否有文字
2026-09-28 15:28:50 +08:00
void AecXDbSymbSection::SetIsHasIndexE(BOOL bHas)
{
AssertWriteEnabled();
if (bHas)
{
m_nFlag |= SYMB_SECTION_END_INDEX;
}
else
{
m_nFlag &= ~SYMB_SECTION_END_INDEX;
}
}
2026-10-04 00:04:20 +08:00
// 返回图号文字距基线系数
2026-09-28 15:28:50 +08:00
double AecXDbSymbSection::GetText2BaseRatios() const
{
double dText2BaseRatio = m_dText2BaseRatio;
if (fabs(m_dText2BaseRatio + 1000) < 1.0E-2)
{
dText2BaseRatio = GlobalFunc::DocGetText2BaseRatio();
}
return dText2BaseRatio;
}
2026-10-04 00:04:20 +08:00
// 设置图号文字距基线系数
2026-09-28 15:28:50 +08:00
void AecXDbSymbSection::SetText2BaseRatios(double dText2BaseRatio)
{
AssertWriteEnabled();
m_dText2BaseRatio = dText2BaseRatio;
}
ADSGePoint3d AecXDbSymbSection::GetIndexLocation(int nPos, BOOL bEcsPoint) const
{
2026-10-04 00:04:20 +08:00
ADSGePoint3d pt = (nPos == 0) ? m_ptSIndex : m_ptEIndex; // ECS点
if (!bEcsPoint) // WCS点
2026-09-28 15:28:50 +08:00
{
pt = GetWcsTextPt(nPos + 2);
}
return pt;
}
void AecXDbSymbSection::SetIndexLocation(int nPos, ADSGePoint3d pt)
{
AssertWriteEnabled();
2026-10-04 00:04:20 +08:00
AcGePoint2d ptOrigin = GetEcsOriginPt(nPos + 2); // 获得ECS原点
2026-09-28 15:28:50 +08:00
AcGeVector2d xAxis, yAxis;
2026-10-04 00:04:20 +08:00
GetEcsAxisVector(xAxis, yAxis, nPos + 2); // 获得ECS坐标轴方向
2026-09-28 15:28:50 +08:00
AcGeMatrix2d mat2d;
mat2d = mat2d.alignCoordSys(ptOrigin, xAxis, yAxis,
AcGePoint2d(0, 0), AcGeVector2d(1, 0), AcGeVector2d(0, 1));
AcGePoint2d ptResult(pt.x, pt.y);
ptResult.transformBy(mat2d); // WCS2ECS
2026-10-04 00:04:20 +08:00
if (nPos == 0) // 剖切图号始端位置点
2026-09-28 15:28:50 +08:00
{
m_ptSIndex.x = ptResult.x / GetPScale();
2026-10-04 00:04:20 +08:00
m_ptSIndex.y = ptResult.y / GetPScale(); // 用图纸比例保存
2026-09-28 15:28:50 +08:00
}
2026-10-04 00:04:20 +08:00
else if (nPos == 1) // 剖切图号末端位置点
2026-09-28 15:28:50 +08:00
{
m_ptEIndex.x = ptResult.x / GetPScale();
2026-10-04 00:04:20 +08:00
m_ptEIndex.y = ptResult.y / GetPScale(); // 用图纸比例保存
2026-09-28 15:28:50 +08:00
}
}
2026-10-04 00:04:20 +08:00
// 是否为非正交(非垂直)的剖切符号
2026-09-28 15:28:50 +08:00
BOOL AecXDbSymbSection::GetNonPerpendicularitySection() const
{
assertReadEnabled();
BOOL bNoPerpendicularity = ((m_nFlag & SYMB_SECTION_VIEW_DIR2) != 0);
return bNoPerpendicularity;
}
void AecXDbSymbSection::SetNonPerpendicularitySection(BOOL bYes)
{
AssertWriteEnabled();
if (bYes)
{
m_nFlag |= SYMB_SECTION_VIEW_DIR2;
}
else
{
m_nFlag &= ~SYMB_SECTION_VIEW_DIR2;
}
}
double AecXDbSymbSection::GetViewDirection2() const
{
return m_nViewDir2;
}
void AecXDbSymbSection::SetViewDirection2(double vec)
{
AssertWriteEnabled();
m_nViewDir2 = vec;
}
double AecXDbSymbSection::GetEndViewLineDir() const
{
2026-10-04 00:04:20 +08:00
if (GetNonPerpendicularitySection()) // 不平行
2026-09-28 15:28:50 +08:00
return m_nViewDir2;
return m_nViewDir;
}
AcGiDraw::TextAlignment AecXDbSymbSection::GetIndexTextAlignment(int nPos) const
{
2026-10-04 00:04:20 +08:00
double dTextRotation = GetIndexTextRotation(nPos); // 获得文字标注方向
double dLineDir(0), // 线的方向
2026-09-28 15:28:50 +08:00
dViewDir(0),
dTempAngle1(0),
dTempAngle2(0);
AcGiDraw::TextAlignment nAlign;
2026-10-04 00:04:20 +08:00
if (nPos == 0) // 起点
2026-09-28 15:28:50 +08:00
{
dLineDir = Wcs2Layout(ads_angle(m_poly[0], m_poly[1]));
dViewDir = Wcs2Layout(m_nViewDir);
dTempAngle1 = GlobalFunc::AngleRangeTo2PI(dViewDir + PI);
dTempAngle2 = GlobalFunc::AngleRangeTo2PI(dLineDir + PI / 2);
2026-10-04 00:04:20 +08:00
if (GetDimDirection() == 1) // 剖视方向
2026-09-28 15:28:50 +08:00
{
2026-10-04 00:04:20 +08:00
if (m_bViewLine) // 剖面剖切
2026-09-28 15:28:50 +08:00
{
if (IsExactSameDrt(dTextRotation, dTempAngle1, g_DimOption::instance()._angSnap))
{
if (fabs(dTempAngle2 - dViewDir) < 1.0E-5)
nAlign = AcGiDraw::kTopLeft;
else
nAlign = AcGiDraw::kBottomLeft;
}
else
{
if (fabs(dTempAngle2 - dViewDir) < 1.0E-5)
nAlign = AcGiDraw::kBottomRight;
else
nAlign = AcGiDraw::kTopRight;
}
}
2026-10-04 00:04:20 +08:00
else // 断面剖切
2026-09-28 15:28:50 +08:00
{
if (IsExactSameDrt(dTextRotation, dTempAngle1, g_DimOption::instance()._angSnap))
{
if (fabs(dTempAngle2 - dViewDir) < 1.0E-5)
nAlign = AcGiDraw::kBottomLeft;
else
nAlign = AcGiDraw::kTopLeft;
}
else
{
if (fabs(dTempAngle2 - dViewDir) < 1.0E-5)
nAlign = AcGiDraw::kTopRight;
else
nAlign = AcGiDraw::kBottomRight;
}
}
}
2026-10-04 00:04:20 +08:00
else // 剖切方向
2026-09-28 15:28:50 +08:00
{
if (IsExactSameDrt(dTextRotation, dLineDir, g_DimOption::instance()._angSnap))
{
if (fabs(dTempAngle2 - dViewDir) < 1.0E-5)
nAlign = AcGiDraw::kTopRight;
else
nAlign = AcGiDraw::kBottomRight;
}
else
{
if (fabs(dTempAngle2 - dViewDir) < 1.0E-5)
nAlign = AcGiDraw::kBottomLeft;
else
nAlign = AcGiDraw::kTopLeft;
}
}
}
2026-10-04 00:04:20 +08:00
else // 终点
2026-09-28 15:28:50 +08:00
{
dLineDir = Wcs2Layout(ads_angle(m_poly[m_poly.Length() - 2], m_poly[m_poly.Length() - 1]));
dViewDir = Wcs2Layout(GetEndViewLineDir());
dTempAngle1 = GlobalFunc::AngleRangeTo2PI(dViewDir + PI);
dTempAngle2 = GlobalFunc::AngleRangeTo2PI(dLineDir + PI / 2);
2026-10-04 00:04:20 +08:00
if (GetDimDirection() == 1) // 剖视方向
2026-09-28 15:28:50 +08:00
{
2026-10-04 00:04:20 +08:00
if (m_bViewLine) // 剖面剖切
2026-09-28 15:28:50 +08:00
{
if (IsExactSameDrt(dTextRotation, dTempAngle1, g_DimOption::instance()._angSnap))
{
if (fabs(dTempAngle2 - dViewDir) < 1.0E-5)
nAlign = AcGiDraw::kBottomLeft;
else
nAlign = AcGiDraw::kTopLeft;
}
else
{
if (fabs(dTempAngle2 - dViewDir) < 1.0E-5)
nAlign = AcGiDraw::kTopRight;
else
nAlign = AcGiDraw::kBottomRight;
}
}
2026-10-04 00:04:20 +08:00
else // 断面剖切
2026-09-28 15:28:50 +08:00
{
if (IsExactSameDrt(dTextRotation, dTempAngle1, g_DimOption::instance()._angSnap))
{
if (fabs(dTempAngle2 - dViewDir) < 1.0E-5)
nAlign = AcGiDraw::kTopLeft;
else
nAlign = AcGiDraw::kBottomLeft;
}
else
{
if (fabs(dTempAngle2 - dViewDir) < 1.0E-5)
nAlign = AcGiDraw::kBottomRight;
else
nAlign = AcGiDraw::kTopRight;
}
}
}
2026-10-04 00:04:20 +08:00
else // 剖切方向
2026-09-28 15:28:50 +08:00
{
if (IsExactSameDrt(dTextRotation, dLineDir, g_DimOption::instance()._angSnap))
{
if (fabs(dTempAngle2 - dViewDir) < 1.0E-5)
nAlign = AcGiDraw::kTopLeft;
else
nAlign = AcGiDraw::kBottomLeft;
}
else
{
if (fabs(dTempAngle2 - dViewDir) < 1.0E-5)
nAlign = AcGiDraw::kBottomRight;
else
nAlign = AcGiDraw::kTopRight;
}
}
}
return nAlign;
}
double AecXDbSymbSection::GetIndexTextRotation(int nPos) const
{
double dTextRotation(0.0);
2026-10-04 00:04:20 +08:00
if (nPos == 0) // 起点
2026-09-28 15:28:50 +08:00
{
dTextRotation = ads_angle(m_poly[0], m_poly[1]);
2026-10-04 00:04:20 +08:00
if (GetDimDirection() == 1) // 剖视方向
2026-09-28 15:28:50 +08:00
dTextRotation = m_nViewDir;
}
2026-10-04 00:04:20 +08:00
else // 终点
2026-09-28 15:28:50 +08:00
{
dTextRotation = ads_angle(m_poly[m_poly.Length() - 2], m_poly[m_poly.Length() - 1]);
2026-10-04 00:04:20 +08:00
if (GetDimDirection() == 1) // 剖视方向
2026-09-28 15:28:50 +08:00
dTextRotation = GetEndViewLineDir();
}
dTextRotation = GlobalFunc::ChangeAngleTo1_4(Wcs2Layout(dTextRotation));
return dTextRotation;
}