Files
envi-code/SourceCode/Code2026/Dimension/AecDbSymbModi.cpp
T
2026-09-28 15:28:50 +08:00

852 lines
19 KiB
C++

#include "StdAfx.h"
#include "AecDbSymbModi.h"
#include "globalFunc.h"
#include "PushProperty.h"
#include "AecDbText.h"
const Adesk::UInt8 AecXDbSymbModi::g_nVersion = 1;
ACRX_DXF_DEFINE_MEMBERS(AecXDbSymbModi, AecXDbSymbWithText, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
1, AEC_YUNXIAN, "AEC_YUNXIAN|缺乏上华解释器, 请下载上华软件|网址: www.shanghuasoft.com");
AecXDbSymbModi::AecXDbSymbModi()
{
m_dEndWidth = 1.5;
m_nTextHeight = 5.0;
m_bShowEdition = FALSE;
m_sEdition = _T("1");
}
AecXDbSymbModi::~AecXDbSymbModi()
{
}
BOOL AecXDbSymbModi::IsValid() const
{
//BOOL bRet = TDbEntity::IsValid();
//if (!bRet)
// return bRet;
return TRUE;
}
//Acad::ErrorStatus AecXDbSymbModi::subGetClassID(CLSID* pClsid) const
//{
// *pClsid = CLSID_ComSymbModi;
// return Acad::eOk;
//}
void AecXDbSymbModi::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag)
{
AssertWriteEnabled();
AecXDbSymbWithText::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
AecXDbSymbModi *pSrc = AecXDbSymbModi::cast(pSrcEntity);
if (pSrc != NULL)
{
m_dEndWidth = pSrc->m_dEndWidth;
m_nTextHeight = pSrc->m_nTextHeight;
m_bShowEdition = pSrc->m_bShowEdition;
}
}
Acad::ErrorStatus AecXDbSymbModi::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)
return Acad::eMakeMeProxy;
GlobalFunc::ReadPoly2D(pFiler, m_poly);
pFiler->readItem(&m_dEndWidth);
pFiler->readItem(&m_dAngle);
pFiler->readItem(&m_bShowEdition);
GlobalFunc::ReadString(pFiler, m_sEdition);
pFiler->readItem((AcGePoint3d *)&m_ptEditLoc);
return pFiler->filerStatus();
}
Acad::ErrorStatus AecXDbSymbModi::dwgOutFields(AcDbDwgFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es = AecXDbSymbWithText::dwgOutFields(pFiler);
if (es != Acad::eOk)
return es;
pFiler->writeItem(g_nVersion);
GlobalFunc::WritePoly2D(pFiler, m_poly);
pFiler->writeItem(m_dEndWidth);
pFiler->writeItem(m_dAngle);
pFiler->writeItem(m_bShowEdition);
pFiler->writeString(m_sEdition);
pFiler->writeItem((const AcGePoint3d &)m_ptEditLoc);
return pFiler->filerStatus();
}
Acad::ErrorStatus AecXDbSymbModi::dxfInFields(AcDbDxfFiler* pFiler)
{
AssertWriteEnabled();
Acad::ErrorStatus es = AecXDbSymbWithText::dxfInFields(pFiler);
if (es != Acad::eOk)
return es;
if (!pFiler->atSubclassData(_T("AecXDbSymbModi")))
return Acad::eBadDxfSequence;
int nFlag(0);
double dAngle(0),
dEndWidth(0);
ADSGePoint3d ptText;
TCHAR *pEdition = NULL;
PtrList<double> bulges;
PtrList<ADSGePoint3d> pts;
Adesk::UInt32 fieldsFlags = 0;
resbuf rb;
while ((es == Acad::eOk) && ((es = pFiler->readResBuf(&rb)) == Acad::eOk))
{
switch (rb.restype)
{
case AcDb::kDxfXCoord:
pts.Append(new ADSGePoint3d(rb.resval.rpoint));
break;
case AcDb::kDxfAngle:
bulges.Append(new double(rb.resval.rreal));
break;
case AcDb::kDxfAngle + 1:
dEndWidth = rb.resval.rreal;
break;
case AcDb::kDxfAngle + 2:
dAngle = rb.resval.rreal;
break;
case AcDb::kDxfInt16:
fieldsFlags |= 0x1;
nFlag = rb.resval.rint;
break;
case AcDb::kDxfText:
acutUpdString(rb.resval.rstring, pEdition);
fieldsFlags |= 0x04;
free(rb.resval.rstring);
break;
case AcDb::kDxfXCoord + 1:
ptText = rb.resval.rpoint;
break;
default:
pFiler->pushBackItem();
es = Acad::eEndOfFile;
break;
}
}
if (pts.Length() < 2 || pts.Length() != bulges.Length())
{
pFiler->setError(_T("\nError DXF group code: 10, 50"));
return Acad::eMissingDxfField;
}
m_poly.Reset();
for (int i = 0; i < pts.Length(); i++)
{
m_poly.AppendNode(*pts[i], *bulges[i]);
}
m_dEndWidth = dEndWidth;
m_dAngle = dAngle;
if (fieldsFlags & 0x01)
m_bShowEdition = nFlag;
m_ptEditLoc = ptText;
if (fieldsFlags & 0x04)
{
m_sEdition = pEdition;
acutDelString(pEdition);
}
return pFiler->filerStatus();
}
Acad::ErrorStatus AecXDbSymbModi::dxfOutFields(AcDbDxfFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es = AecXDbSymbWithText::dxfOutFields(pFiler);
assert(es == Acad::eOk);
es = pFiler->writeItem(AcDb::kDxfSubclass, _T("AecXDbSymbModi"));
assert(es == Acad::eOk);
for (int i = 0; i < m_poly.Length(); i++)
{
pFiler->writePoint3d(AcDb::kDxfXCoord, m_poly[i]);
pFiler->writeDouble(AcDb::kDxfAngle, m_poly.GetBulge(i));
}
pFiler->writeDouble(AcDb::kDxfAngle + 1, m_dEndWidth);
pFiler->writeDouble(AcDb::kDxfAngle + 2, m_dAngle);
pFiler->writeInt16(AcDb::kDxfInt16, (Adesk::UInt16)m_bShowEdition);
pFiler->writeString(AcDb::kDxfText, m_sEdition);
pFiler->writePoint3d(AcDb::kDxfXCoord, m_ptEditLoc.AsAcGePoint3d());
return es;
}
Acad::ErrorStatus AecXDbSymbModi::subGetGripPoints(AcGePoint3dArray& gripPoints,
AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const
{
assertReadEnabled();
ADSGePoint3d ptUp, ptLow;
m_poly.GetExtend(ptUp, ptLow);
AcGeVector3d vector3d(0, 0, 1);
AcGeMatrix3d mat, mat1; //mat保存从wcs转换到ucs, mat1保存从ucs转换到wcs
ADSGePoint3d ptCenter;
Midpoint(ptUp, ptLow, ptCenter); //求得中心点
mat.setToRotation(GlobalFunc::Ucs2Wcs(0.0), vector3d, ptCenter);//获得旋转矩阵
mat1.setToRotation(-GlobalFunc::Ucs2Wcs(0.0), vector3d, ptCenter);
GePoly2D polyTemp = m_poly;
polyTemp.TransformBy(mat1); //临时将ucs坐标系下的图形旋转会在wcs下的状态
polyTemp.GetExtend(ptUp, ptLow); //求恢复的多段线的外包围盒
ptLow.TransformBy(mat); //将点旋转到ucs状态
ptUp.TransformBy(mat);
ADSGePoint3d pt1 = GlobalFunc::Wcs2Ucs(ptUp), pt3 = GlobalFunc::Wcs2Ucs(ptLow);
ADSGePoint3d pt2(pt3.x, pt1.y, 0), pt4(pt1.x, pt3.y, 0); //四个顶点
gripPoints.append(GlobalFunc::Ucs2Wcs(pt1));
gripPoints.append(GlobalFunc::Ucs2Wcs(pt2));
gripPoints.append(GlobalFunc::Ucs2Wcs(pt3));
gripPoints.append(GlobalFunc::Ucs2Wcs(pt4));
ADSGePoint3d ptTemp;
Midpoint(pt1, pt2, ptTemp);
gripPoints.append(GlobalFunc::Ucs2Wcs(ptTemp));
Midpoint(pt3, pt2, ptTemp);
gripPoints.append(GlobalFunc::Ucs2Wcs(ptTemp));
Midpoint(pt3, pt4, ptTemp);
gripPoints.append(GlobalFunc::Ucs2Wcs(ptTemp));
Midpoint(pt1, pt4, ptTemp);
gripPoints.append(GlobalFunc::Ucs2Wcs(ptTemp));
Midpoint(pt1, pt3, ptTemp);
gripPoints.append(GlobalFunc::Ucs2Wcs(ptTemp));
if (m_bShowEdition) //是否显示版次标志
{
gripPoints.append(m_ptEditLoc);
}
return Acad::eOk;
}
Acad::ErrorStatus AecXDbSymbModi::subMoveGripPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
AssertWriteEnabled();
// pt1,pt2,pt3,pt4是保存m_poly的外包装盒的四个顶点
ADSGePoint3d pt1, pt2;
m_poly.GetExtend(pt1, pt2);
ADSGePoint3d pt3(pt2.x, pt1.y, 0), pt4(pt1.x, pt2.y, 0);
// 以下算法是通过修改云线的缩放比例,如果拉伸一个点,
// 固定其对角点,通过缩放之后再将其对角点平移回原来位置实现拉伸效果
for (int i = 0; i < indices.length(); i++)
{
int idx = indices[i];
if (idx == 0 || idx == 2) // 拉伸时0,2夹点是对角夹点如果拉伸其中一个,选择另外一个为基点做变换
{
ADSGePoint3d ptOld = pt2; // ptOld保存拉伸夹点前夹点位置
if (idx == 2)
{
ptOld = pt1;
}
double dX = fabs(pt2.x - pt1.x);
double dY = fabs(pt2.y - pt1.y);
if (idx == 0)
{
pt1 += offset;
}
else
{
pt2 += offset;
}
double dNewX = fabs(pt2.x - pt1.x);
double dNewY = fabs(pt2.y - pt1.y);
AcGeScale3d scale(dNewX / dX, dNewY / dY, 1); // 缩放比例
AcGeMatrix3d mat;
scale.getMatrix(mat); // 得到缩放矩阵
subTransformBy(mat);
m_poly.GetExtend(pt1, pt2); // 获得缩放转换后的m_poly的外包围盒
AcGeVector3d vt;
if (idx == 0) // 该判断是为了求出如果要再将基点位置返回到ptOld位置需要做的平移向量
{
vt = ptOld - pt2;
}
else
{
vt = ptOld - pt1;
}
mat.setToTranslation(vt); // 求出平移回去的矩阵
subTransformBy(mat);
}
else if (idx == 1 || idx == 3) // 拉伸时1,3夹点是对角夹点如果拉伸其中一个,选择另外一个为基点做变换
{
ADSGePoint3d ptOld = pt4; // ptOld保存拉伸夹点前夹点位置
if (idx == 3)
{
ptOld = pt3;
}
double dX = fabs(pt4.x - pt3.x);
double dY = fabs(pt4.y - pt3.y);
if (idx == 1)
{
pt3 += offset;
}
else
{
pt4 += offset;
}
double dNewX = fabs(pt4.x - pt3.x);
double dNewY = fabs(pt4.y - pt3.y);
AcGeScale3d scale(dNewX / dX, dNewY / dY, 1); // 获得缩放比例
AcGeMatrix3d mat;
scale.getMatrix(mat); // 获得缩放矩阵
subTransformBy(mat);
m_poly.GetExtend(pt1, pt2);
pt3 = ADSGePoint3d(pt2.x, pt1.y, 0);
pt4 = ADSGePoint3d(pt1.x, pt2.y, 0);
AcGeVector3d vt;
if (idx == 1) // if判断是为了获得再平移回去时的向量
{
vt = ptOld - pt4;
}
else
{
vt = ptOld - pt3;
}
mat.setToTranslation(vt); // 获得平移回去的矩阵
subTransformBy(mat);
}
else if (idx == 4 || idx == 6) // 拉伸时4,6夹点是对角夹点如果拉伸其中一个,选择另外一个为基点做变换
{
ADSGePoint3d pt5 = ADSGePoint3d((pt1.x + pt2.x) / 2, pt1.y, 0);
ADSGePoint3d pt6 = ADSGePoint3d((pt1.x + pt2.x) / 2, pt2.y, 0);
ADSGePoint3d ptOld = pt6; // 保存原来位置以备平移回去
if (idx == 6)
{
ptOld = pt5;
}
double dX = fabs(pt6.x - pt5.x);
double dY = fabs(pt6.y - pt5.y);
if (idx == 4)
{
pt5 += offset;
}
else
{
pt6 += offset;
}
double dNewX = fabs(pt6.x - pt5.x);
double dNewY = fabs(pt6.y - pt5.y);
AcGeScale3d scale(1, dNewY / dY, 1); // 缩放比例
AcGeMatrix3d mat;
scale.getMatrix(mat); // 获得缩放矩阵
subTransformBy(mat);
m_poly.GetExtend(pt1, pt2);
pt5 = ADSGePoint3d((pt1.x + pt2.x) / 2, pt1.y, 0);
pt6 = ADSGePoint3d((pt1.x + pt2.x) / 2, pt2.y, 0);
AcGeVector3d vt;
if (idx == 4)
{
vt = ptOld - pt6;
}
else
{
vt = ptOld - pt5;
}
mat.setToTranslation(vt); // 平移回去的矩阵
subTransformBy(mat);
}
else if (idx == 5 || idx == 7)
{
ADSGePoint3d pt5 = ADSGePoint3d(pt2.x, (pt2.y + pt1.y) / 2, 0);
ADSGePoint3d pt6 = ADSGePoint3d(pt1.x, (pt2.y + pt1.y) / 2, 0);
ADSGePoint3d ptOld = pt6;
if (idx == 7)
{
ptOld = pt5;
}
double dX = fabs(pt6.x - pt5.x);
double dY = fabs(pt6.y - pt5.y);
if (idx == 5)
{
pt5 += offset;
}
else
{
pt6 += offset;
}
double dNewX = fabs(pt6.x - pt5.x);
double dNewY = fabs(pt6.y - pt5.y);
AcGeScale3d scale(dNewX / dX, 1, 1);
AcGeMatrix3d mat;
scale.getMatrix(mat);
subTransformBy(mat);
m_poly.GetExtend(pt1, pt2);
pt5 = ADSGePoint3d(pt2.x, (pt2.y + pt1.y) / 2, 0);
pt6 = ADSGePoint3d(pt1.x, (pt2.y + pt1.y) / 2, 0);
AcGeVector3d vt;
if (idx == 5)
{
vt = ptOld - pt6;
}
else
{
vt = ptOld - pt5;
}
mat.setToTranslation(vt);
subTransformBy(mat);
}
else if (idx == 8) // 平移中心点时
{
AcGeMatrix3d mat;
mat.setToTranslation(offset);
m_poly.TransformBy(mat);
m_ptEditLoc += offset;
}
if (idx == 9) // 移动文字位置
{
m_ptEditLoc += offset;
}
}
return Acad::eOk;
}
Acad::ErrorStatus AecXDbSymbModi::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
{
assertReadEnabled();
AcDbIntArray geomIds;
AcDbIntArray osnapModes;
return subGetGripPoints(stretchPoints, osnapModes, geomIds);
}
Acad::ErrorStatus AecXDbSymbModi::subMoveStretchPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
AssertWriteEnabled();
int idx = indices[0];
if (indices.length() == 1 && idx == 9)
{
m_ptEditLoc += offset;
}
else // 如果选中的夹点个数>1或者选中的不是版次位置点,则认为是整体移动
{
AcGeMatrix3d mat;
mat.setToTranslation(offset);
m_poly.TransformBy(mat);
m_ptEditLoc += offset;
}
return Acad::eOk;
}
Acad::ErrorStatus AecXDbSymbModi::subTransformBy(const AcGeMatrix3d& xform)
{
AssertWriteEnabled();
AecXDbSymbWithText::subTransformBy(xform);
m_poly.TransformBy(xform);
m_ptEditLoc.TransformBy(xform);
return Acad::eOk;
}
Acad::ErrorStatus AecXDbSymbModi::GetGripText(int i, CString &cs) const
{
Acad::ErrorStatus es = Acad::eOk;
if (i < 4)
{
cs.Format(_T("对角拉伸"));
}
else if (i < 8)
{
cs.Format(_T("移动第%d条边"), i - 3);
}
else if (i == 8)
{
cs.Format(_T("移动云线"));
}
if (i == 9)
{
cs.Format(_T("移动文字"));
}
return es;
}
Acad::ErrorStatus AecXDbSymbModi::Draw2d(AcGiDraw &dc) const
{
assertReadEnabled();
GlobalFunc::_LoadConfig();
if (Has2DBuffer() && !dc.IsDragging())
{
dc.SetColor(colorIndex());
dc.SetLayer(layerId());
BaseEx::_Draw2DBuffers(dc, true);
return Acad::eOk;
}
Acad::ErrorStatus es = Acad::eOk;
if (m_poly.Length() < 2)
{
return es;
}
AcDbPolyline pLine;
GlobalFunc::PolyConvert(m_poly, pLine);
for (int i = 0; i < m_poly.Length(); i++) // 循环为多段线设置弧度值和首尾宽度值
{
pLine.setBulgeAt(i, m_dAngle);
pLine.setWidthsAt(i, 0, m_dEndWidth * GetPScale());
}
pLine.setPropertiesFrom(this);
//dc.Polyline(pLine);
DrawPline(dc, pLine);
if (m_bShowEdition) // 显示文字版次
{
AcGePoint3dArray ptArray; // 保存文字版次的三角形的三个顶点
ADSGePoint3d ptTemp;
double dLength = m_nTextHeight * 1.2 * GetPScale();
ads_polar(m_ptEditLoc, m_nLayoutRotation + PI / 2, dLength, ptTemp);
ptArray.append(ptTemp);
ads_polar(m_ptEditLoc, m_nLayoutRotation + 7 * PI / 6, dLength, ptTemp);
ptArray.append(ptTemp);
ads_polar(m_ptEditLoc, m_nLayoutRotation + 11 * PI / 6, dLength, ptTemp);
ptArray.append(ptTemp);
GeLine lineTemp; // 绘制三角形
lineTemp.SetStartPoint(ptArray[0]);
lineTemp.SetEndPoint(ptArray[1]);
//dc << lineTemp;
DrawLine(dc, lineTemp);
lineTemp.SetEndPoint(ptArray[2]);
//dc << lineTemp;
DrawLine(dc, lineTemp);
lineTemp.SetStartPoint(ptArray[1]);
//dc << lineTemp;
DrawLine(dc, lineTemp);
double dDistance = m_poly[0].Distance2d(m_ptEditLoc);
int iNum = 0; // 保存多段线第几个顶点到版次点最近
int iLength = m_poly.Length();
for (int i = 1; i < m_poly.Length(); i++) // 循环求出多段线上的顶点到版次位置点的最近距离点
{
double dTemp = m_poly[i].Distance2d(m_ptEditLoc);
if (dTemp < dDistance)
{
dDistance = dTemp;
iNum = i;
}
}
//add by lgy 20120523 版次三边形中三个顶点中的一个与云线连接
ADSGePoint3d ptNear = m_poly[iNum];
double dDist = ptNear.Distance2d(ptArray[0]);
iNum = 0;
for (int j = 1; j < 3; j++)
{
if (ptNear.Distance2d(ptArray[j]) < dDist)
{
iNum = j;
dDist = ptNear.Distance2d(ptArray[j]);
}
}
lineTemp.SetStartPoint(ptNear);
lineTemp.SetEndPoint(ptArray[iNum]);
//dc << lineTemp;
DrawLine(dc, lineTemp);
AecXDbText text;
text.setPropertiesFrom(this);
//if (dc.IsExportTch4())
//{
// // 分解出来的文字的图层和颜色要随“高级选项”中的设置来处理
// if (g_nSymbTextT3Layer == 1 && !!m_idTextLayer)
// text.setLayer(m_idTextLayer); // 文字层
// else
// text.setColorIndex(m_colorText); // 文字和标注放在同一层,文字的颜色为白色
//}
//else
{
// sg modify 120713,临时加到此处,后续还是应该加到导出函数中
text.setColorIndex(m_colorText); // 文字和标注放在同一层,文字的颜色为白色
//else // 导出
//{
// if (g_nSymbTextT3Layer == 1 && !!m_idTextLayer)
// text.setLayer(m_idTextLayer); // 文字层
// else
// text.setColorIndex(m_colorText); // 文字和标注放在同一层,文字的颜色为白色
//}
}
text.SetHeight(m_nTextHeight);
text.SetLocation(m_ptEditLoc);
text.SetStyleId(m_idTextStyle);
text.SetText(m_sEdition);
text.SetAlignment(AcGiDraw::kMiddleCenter);
text.SetRotation(GlobalFunc::ChangeAngleTo1_4(Wcs2Layout(m_nLayoutRotation))); // 考虑ucs坐标系下布局转角
PushProperty vProp(&text, dc);
//if (dc.IsFullExplode())
// text.ExplodeOrDraw2d(dc);
//else
// dc.DrawEntity(text);
DrawBaseEx(dc, text);
}
return es;
}
void AecXDbSymbModi::GetTips(PtrList<ObjInfoUnit> &lstInfo) const
{
lstInfo.Append(new ObjInfoUnit(_T("对象类型"), _T("云线标注")));
if (m_bShowEdition)
{
lstInfo.Append(new ObjInfoUnit(_T("修改版次"), m_sEdition));
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));
}
}
const TCHAR* AecXDbSymbModi::GetDefaultLayer()const
{
extern TCHAR* LAY_MODI_DIM;
return LAY_MODI_DIM;
}
int AecXDbSymbModi::ConvertText(TConvertTextPtr ptr, void *pData)
{
AssertWriteEnabled();
TCString sText;
int nRet = ptr(m_sEdition, sText, pData);
if (nRet == RTNORM)
{
m_sEdition = sText;
}
return nRet;
}
BOOL AecXDbSymbModi::GetText(Adesk::UInt32 cookies, AecXDbText &text) const
{
if (cookies != 0)
return FALSE;
text.setPropertiesFrom(this);
text.SetAlignment(AcGiDraw::kMiddleCenter);
text.SetStyleId(m_idTextStyle);
text.SetHeight(m_nTextHeight);
text.SetText(m_sEdition);
text.SetLocation(m_ptEditLoc);
return TRUE;
}
TextPosition AecXDbSymbModi::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 AecXDbSymbModi::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);
SetEditionText(text.GetText());
if (!posNext)
{
posNext.m_nCookies = posRep.m_nCookies + 1;
posNext.m_nTextPos = 0;
}
return posNext;
}
bool AecXDbSymbModi::UnifyElevation(double dElevation)
{
m_poly.SetElevation(dElevation);
m_ptEditLoc.z = dElevation;
return true;
}
void AecXDbSymbModi::SetModiPoly(GePoly2D poly)
{
AssertWriteEnabled();
m_poly = poly;
}
void AecXDbSymbModi::GetModiPoly(GePoly2D &poly) const
{
poly = m_poly;
}
double AecXDbSymbModi::GetEndWidth() const
{
return m_dEndWidth;
}
void AecXDbSymbModi::SetEndWidth(double dWidth)
{
AssertWriteEnabled();
m_dEndWidth = dWidth;
}
BOOL AecXDbSymbModi::GetIsShowEdition() const
{
return m_bShowEdition;
}
void AecXDbSymbModi::SetIsShowEdition(BOOL bShow)
{
AssertWriteEnabled();
m_bShowEdition = bShow;
}
ADSGePoint3d AecXDbSymbModi::GetEditLocal() const
{
return m_ptEditLoc;
}
ADSGePoint3d AecXDbSymbModi::GetDefaultTextLocation()
{
ADSGePoint3d ptUp, ptLow;
m_poly.GetExtend(ptLow, ptUp);
double dDistance = ptUp.Distance2d(ptLow);
double dAng = ads_angle(ptLow, ptUp);
ADSGePoint3d ptCenter((ptUp.x + ptLow.x) / 2, (ptLow.y + ptUp.y) / 2, 0);
ADSGePoint3d ptLocal;
ads_polar(ptCenter, dAng - PI / 2, 3 * dDistance / 5, ptLocal);
return ptLocal;
}
void AecXDbSymbModi::SetEditLocal(ADSGePoint3d pt)
{
AssertWriteEnabled();
m_ptEditLoc = pt;
}
void AecXDbSymbModi::SetEditionText(CString strText)
{
AssertWriteEnabled();
m_sEdition = strText;
}
CString AecXDbSymbModi::GetEditionText() const
{
return (const TCHAR *)m_sEdition;
}
void AecXDbSymbModi::SetArcAngle(double dAngle)
{
AssertWriteEnabled();
m_dAngle = dAngle;
}
double AecXDbSymbModi::GetArcAngle() const
{
return m_dAngle;
}