624 lines
16 KiB
C++
624 lines
16 KiB
C++
#include "stdafx.h"
|
||
#include "globalDefine.h"
|
||
#include "globalFunc.h"
|
||
#include "AecDbText.h"
|
||
#include "AecDbSymbNorthThumb.h"
|
||
#include "PushProperty.h"
|
||
#include "DimOptionData.h"
|
||
|
||
//////////////////////////////////////////////////////////////
|
||
// 指北针
|
||
// 1-TArch8及以前版本;2-TArch9
|
||
// lxb add 111227,根据9.0需求,增加文字部分的内容
|
||
// const Adesk::UInt8 AecXDbSymbNorthThumb::g_nVersion = 1;
|
||
|
||
extern AcDbObjectId GetValidTextStyle(AcDbDatabase *pDb, const TCHAR *pStyle);
|
||
extern AcDbObjectId InitTextStyle(TTextStyle ts, AcDbDatabase *pDb = NULL);
|
||
extern AcDbObjectId InitLayer(const TCHAR *szLayer, AcDbDatabase *pDb = NULL);
|
||
|
||
const Adesk::UInt8 AecXDbSymbNorthThumb::g_nVersion = 2;
|
||
|
||
ACRX_DXF_DEFINE_MEMBERS(AecXDbSymbNorthThumb, AecXDbEntityBaseEx, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
||
1, AEC_ZHIBEIZHEN, "AEC_ZHIBEIZHEN|缺乏上华解释器, 请下载上华软件|网址: www.shanghuasoft.com");
|
||
|
||
AecXDbSymbNorthThumb::AecXDbSymbNorthThumb()
|
||
{
|
||
m_nRadius = 12.0;
|
||
m_nRotation = PI / 2.0;
|
||
|
||
// lxb add 111227,根据9.0需求,增加文字部分的内容
|
||
m_idTextStyle = InitTextStyle(TS_NORTHTHUMB);
|
||
m_dTextHeight = 5.0;
|
||
m_colorText = 7;
|
||
m_szText = _T("北");
|
||
m_ptText = ADSGePoint3d(0, 0);
|
||
}
|
||
|
||
AecXDbSymbNorthThumb::~AecXDbSymbNorthThumb()
|
||
{
|
||
}
|
||
|
||
BOOL AecXDbSymbNorthThumb::IsValid() const
|
||
{
|
||
//BOOL bRet = TDbEntity::IsValid();
|
||
//if (!bRet)
|
||
// return bRet;
|
||
BOOL bRet = (m_nRadius > 0.0);
|
||
return bRet;
|
||
}
|
||
|
||
// 提供对格式刷的支持
|
||
void AecXDbSymbNorthThumb::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag)
|
||
{
|
||
AssertWriteEnabled();
|
||
AecXDbEntityBaseEx::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
|
||
|
||
AecXDbSymbNorthThumb *pSrc = AecXDbSymbNorthThumb::cast(pSrcEntity);
|
||
if (pSrc)
|
||
{
|
||
m_nRadius = pSrc->m_nRadius;
|
||
m_nRotation = pSrc->m_nRotation;
|
||
|
||
// lxb add 111227,根据9.0需求,增加文字部分的内容
|
||
m_idTextStyle = pSrc->m_idTextStyle;
|
||
m_colorText = pSrc->m_colorText;
|
||
m_dTextHeight = pSrc->m_dTextHeight;
|
||
}
|
||
}
|
||
|
||
// 从DWG读入数据:
|
||
Acad::ErrorStatus AecXDbSymbNorthThumb::dwgInFields(AcDbDwgFiler* pFiler)
|
||
{
|
||
AssertWriteEnabled();
|
||
Acad::ErrorStatus es = AecXDbEntityBaseEx::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_nRotation);
|
||
|
||
// lxb add 111227,根据9.0需求,增加文字部分的内容
|
||
if (nVer > 1) // 2,TArch9版本
|
||
{
|
||
pFiler->readItem(&m_idTextStyle);
|
||
pFiler->readItem(&m_dTextHeight);
|
||
pFiler->readItem(&m_colorText);
|
||
GlobalFunc::ReadString(pFiler, m_szText);
|
||
pFiler->readItem((AcGePoint2d *)&m_ptText);
|
||
}
|
||
else // 1,TArch8及以前版本
|
||
{
|
||
if (database() == acdbCurDwg())
|
||
{
|
||
m_idTextStyle = InitTextStyle(TS_NORTHTHUMB);
|
||
}
|
||
else
|
||
{
|
||
m_idTextStyle = GetValidTextStyle(database(), _T("_TCH_NORTHTHUMB"));
|
||
}
|
||
|
||
m_dTextHeight = 5.0;
|
||
m_colorText = 7;
|
||
m_szText = _T("");
|
||
}
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus AecXDbSymbNorthThumb::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||
{
|
||
assertReadEnabled();
|
||
Acad::ErrorStatus es = AecXDbEntityBaseEx::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_nRotation);
|
||
|
||
pFiler->writeItem(m_idTextStyle);
|
||
pFiler->writeItem(m_dTextHeight);
|
||
pFiler->writeItem(m_colorText);
|
||
pFiler->writeItem((const TCHAR *)m_szText);
|
||
pFiler->writeItem((const AcGePoint2d &)m_ptText);
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus AecXDbSymbNorthThumb::dxfInFields(AcDbDxfFiler* pFiler)
|
||
{
|
||
return AecXDbEntityBaseEx::dxfInFields(pFiler);
|
||
}
|
||
|
||
Acad::ErrorStatus AecXDbSymbNorthThumb::dxfOutFields(AcDbDxfFiler* pFiler) const
|
||
{
|
||
return AecXDbEntityBaseEx::dxfOutFields(pFiler);
|
||
}
|
||
|
||
// -----------------------------------------------------------------------
|
||
// Overriden functions for edit
|
||
// to do:
|
||
// 允许通过夹点改变边界
|
||
Acad::ErrorStatus AecXDbSymbNorthThumb::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
||
AcDbIntArray& osnapModes,
|
||
AcDbIntArray& geomIds) const
|
||
{
|
||
assertReadEnabled();
|
||
ADSGePoint3d ptTemp;
|
||
// sg modify 111228,夹点位置也应该考虑布局转角,保持和绘制的代码一致
|
||
// ads_polar(m_ptCenter, m_nRotation, GetRadius(FALSE), ptTemp);
|
||
ads_polar(m_ptCenter, m_nLayoutRotation + m_nRotation, GetRadius(FALSE), ptTemp);
|
||
gripPoints.append(m_ptCenter); //0
|
||
gripPoints.append(ptTemp); //1
|
||
|
||
// lxb add 111227,根据9.0需求,增加文字位置夹点
|
||
ptTemp = GetWcsTextPt();
|
||
gripPoints.append(ptTemp);//2
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus AecXDbSymbNorthThumb::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
|
||
AecXDbSymbNorthThumb::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
|
||
{
|
||
assertReadEnabled();
|
||
stretchPoints.append(m_ptCenter);
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// Active when being rotated, scaled, moved, etc.
|
||
// Scale is disabled here
|
||
Acad::ErrorStatus AecXDbSymbNorthThumb::subTransformBy(const AcGeMatrix3d& xform)
|
||
{
|
||
AssertWriteEnabled();
|
||
AecXDbEntityBaseEx::subTransformBy(xform);
|
||
|
||
ads_matrix mat;
|
||
GlobalFunc::AsAdsMatrix(xform, mat);
|
||
|
||
ADSGePoint3d ptTemp;
|
||
// sg modify 111228,夹点位置也应该考虑布局转角,保持和绘制的代码一致
|
||
// ads_polar(m_ptCenter, m_nRotation, GetRadius(FALSE), ptTemp);
|
||
ads_polar(m_ptCenter, m_nLayoutRotation + m_nRotation, GetRadius(FALSE), ptTemp);
|
||
|
||
m_ptCenter.TransformBy(mat);
|
||
ptTemp.TransformBy(mat);
|
||
|
||
if (!g_Option::instance().g_bLayoutRotate)
|
||
{
|
||
//m_nRotation = ads_angle(m_ptCenter, ptTemp);
|
||
m_nRotation = ads_angle(m_ptCenter, ptTemp) - m_nLayoutRotation;
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// 功能: 夹点操作
|
||
Acad::ErrorStatus AecXDbSymbNorthThumb::subMoveGripPointsAt(
|
||
const AcDbIntArray& indices,
|
||
const AcGeVector3d& offset)
|
||
{
|
||
AssertWriteEnabled();
|
||
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 ptTemp;
|
||
// sg modify 111228,夹点位置也应该考虑布局转角,保持和绘制的代码一致
|
||
// ads_polar(m_ptCenter, m_nRotation, GetRadius(FALSE), ptTemp);
|
||
ads_polar(m_ptCenter, m_nLayoutRotation + m_nRotation, GetRadius(FALSE), ptTemp);
|
||
ptTemp += vtOffset;
|
||
// m_nRotation = ads_angle(m_ptCenter, ptTemp);
|
||
m_nRotation = ads_angle(m_ptCenter, ptTemp) - m_nLayoutRotation;
|
||
}
|
||
// lxb add 111227,根据9.0需求,增加文字位置夹点
|
||
else if (idx == 2) // 移动文字
|
||
{
|
||
ADSGePoint3d pt = GetTextPoint(FALSE);
|
||
pt += vtOffset;
|
||
SetTextPoint(pt);
|
||
}
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// 功能: 夹点操作
|
||
Acad::ErrorStatus AecXDbSymbNorthThumb::subMoveStretchPointsAt(
|
||
const AcDbIntArray& indices,
|
||
const AcGeVector3d& offset)
|
||
{
|
||
AssertWriteEnabled();
|
||
m_ptCenter += offset;
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// 取得夹点说明
|
||
Acad::ErrorStatus AecXDbSymbNorthThumb::GetGripText(int i, CString &cs) const
|
||
{
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
if (i == 0)
|
||
cs = _T("移动指北针");
|
||
else if (i == 1)
|
||
cs = _T("更改方向");
|
||
else if (i == 2) // lxb add 111227,根据9.0需求,增加文字位置夹点
|
||
cs = _T("移动文字");
|
||
return es;
|
||
}
|
||
|
||
//Acad::ErrorStatus AecXDbSymbNorthThumb::DownGradeSave(int nDrawMode, AcDbVoidPtrArray &entSet, BOOL *bErase)
|
||
//{
|
||
// Acad::ErrorStatus es = Acad::eOk;
|
||
// if (g_nSaveTArchVer < 7) // 7.0开始才有圆圈文字
|
||
// {
|
||
// BOOL bHasCircle = FALSE; // 是否存在圆圈文字
|
||
// long num = GetSubTextNum();
|
||
// if (num == 1)
|
||
// {
|
||
// SubText* pSubText = GetSubText(0);
|
||
// if (pSubText != NULL)
|
||
// {
|
||
// CString sText = pSubText->GetText();
|
||
// delete pSubText;
|
||
// if (sText.Find(_T("^C")) != -1)
|
||
// bHasCircle = TRUE; // 有圆圈文字,此时还要求完全炸开
|
||
// }
|
||
// }
|
||
//
|
||
// if (bHasCircle)
|
||
// {
|
||
// GlobalFunc::PushMemVar<BOOL> vTemp(XExplodeStream::m_bFullExplode, TRUE); // 完全分解
|
||
// GlobalFunc::PushMemVar<BOOL> vTemp2(XExplodeStream::m_bExportTch4, TRUE); // 保证炸开的图层正确,临时设置为全部炸开
|
||
// XExplodeStream dc(entSet);
|
||
// if (!OnExplodeOrDraw(dc)) // 解决导出后,无遮挡关系的BUG,必须有
|
||
// return Acad::eOk;
|
||
//
|
||
// dc.SetPropertiesFrom(this);
|
||
// if (nDrawMode == DRAW_2D)
|
||
// es = ExplodeOrDraw2d(dc);
|
||
// else
|
||
// es = ExplodeOrDraw3d(dc);
|
||
//
|
||
// if (bErase)
|
||
// *bErase = TRUE;
|
||
// return es;
|
||
// }
|
||
// }
|
||
//
|
||
// if (g_nSaveTArchVer < 9 && g_nSaveTArchVer > 3) // TArch9以前版本,需要分离文字
|
||
// {
|
||
// AecXDbSymbNorthThumb *pNorthThumb = NULL;
|
||
// {
|
||
// GlobalFunc::PushMemVar<int> vTemp(g_nSaveTArchVer, _TCH_VERSION);
|
||
// pNorthThumb = (AecXDbSymbNorthThumb*)clone();
|
||
// }
|
||
// entSet.append(pNorthThumb);
|
||
//
|
||
// AcDbObjectId idLayer = pNorthThumb->layerId();
|
||
//
|
||
// AecXDbText *pdbText = new AecXDbText;
|
||
// pdbText->CopyPropertiesFrom(this, 0);
|
||
// pdbText->SetPScale(GetPScale());
|
||
// pdbText->SetLocation(GetWcsTextPt());
|
||
// pdbText->SetText(m_szText);
|
||
// pdbText->SetHeight(m_dTextHeight);
|
||
// pdbText->SetStyleId(m_idTextStyle);
|
||
//
|
||
// // sg add 120313,分解出来的文字的图层和颜色要随“高级选项”中的设置来处理
|
||
// if (g_nSymbTextT3Layer == 1) // 文字层
|
||
// pdbText->setLayer(::InitLayer(LAY_TEXT, database()));
|
||
// else // 符号层,白色
|
||
// {
|
||
// pdbText->setLayer(idLayer);
|
||
// pdbText->setColorIndex(m_colorText);
|
||
// }
|
||
//
|
||
// pdbText->SetAlignment(XExplodeDraw::kMiddleCenter);
|
||
// if (g_Option::instance().g_bNorthThumbTextDir == 0) // 半径方向
|
||
// {
|
||
// pdbText->SetRotation(m_nRotation - 0.5 * PI);
|
||
// }
|
||
// entSet.append(pdbText);
|
||
//
|
||
// if (bErase)
|
||
// {
|
||
// *bErase = TRUE;
|
||
// }
|
||
// return es;
|
||
// }
|
||
//
|
||
// return TDbEntity::DownGradeSave(nDrawMode, entSet, bErase);
|
||
//}
|
||
|
||
Acad::ErrorStatus
|
||
AecXDbSymbNorthThumb::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;
|
||
|
||
//dc << GeCircle(m_ptCenter, GetRadius(FALSE));
|
||
DrawCircle(dc, GeCircle(m_ptCenter, GetRadius(FALSE)));
|
||
|
||
ADSGePoint3d pt1, pt2;
|
||
ads_polar(m_ptCenter, m_nLayoutRotation + m_nRotation - PI, GetRadius(FALSE), pt1);
|
||
ads_polar(m_ptCenter, m_nLayoutRotation + m_nRotation, GetRadius(FALSE), pt2); // 文字近点
|
||
|
||
AcDbPolyline pline;
|
||
pline.setPropertiesFrom(this);
|
||
pline.addVertexAt(0, pt1);
|
||
pline.addVertexAt(1, pt2);
|
||
pline.setWidthsAt(0, GetRadius(FALSE) / 4.0, 0.0);
|
||
//dc.Polyline(pline);
|
||
DrawPline(dc, pline);
|
||
|
||
// lxb add 111227,根据9.0需求,增加文字
|
||
AecXDbText dbText;
|
||
dbText.setPropertiesFrom(this);
|
||
dbText.SetHeight(m_dTextHeight);
|
||
dbText.SetStyleId(m_idTextStyle);
|
||
// sg add 120313,分解出来的文字的图层和颜色要随“高级选项”中的设置来处理
|
||
//if (dc.IsExportTch4() && g_nSymbTextT3Layer == 1)
|
||
//{
|
||
// dbText.setLayer(::InitLayer(LAY_TEXT, database()));
|
||
//}
|
||
//else
|
||
dbText.setColorIndex(m_colorText); // sg add 090608,文字和标注放在同一层,文字的颜色为白色
|
||
dbText.SetText(m_szText);
|
||
|
||
if (g_DimOption::instance().g_bNorthThumbTextDir == 0) // 半径方向
|
||
{
|
||
dbText.SetRotation(m_nRotation - 0.5 * PI);
|
||
}
|
||
dbText.SetLayoutRotation(m_nLayoutRotation);
|
||
dbText.SetAlignment(AcGiDraw::kMiddleCenter);
|
||
|
||
ADSGePoint3d ptText = GetWcsTextPt(); // 文字夹点位置,WCS
|
||
dbText.SetLocation(ptText);
|
||
|
||
PushProperty vProp(&dbText, dc);
|
||
//if (dc.IsFullExplode())
|
||
// dbText.ExplodeOrDraw2d(dc);
|
||
//else
|
||
//dc.DrawEntity(dbText);
|
||
DrawBaseEx(dc, dbText);
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// sg add 110301,支持统一标高
|
||
bool AecXDbSymbNorthThumb::UnifyElevation(double dElevation)
|
||
{
|
||
AssertWriteEnabled();
|
||
m_ptCenter.z = dElevation;
|
||
return true;
|
||
}
|
||
|
||
const TCHAR *AecXDbSymbNorthThumb::GetDefaultLayer() const
|
||
{
|
||
extern TCHAR* LAY_NORTHTHUMB_DIM;
|
||
return LAY_NORTHTHUMB_DIM;
|
||
}
|
||
|
||
DrawModeType
|
||
AecXDbSymbNorthThumb::GetDrawType() const
|
||
{
|
||
return k2DOnly;
|
||
}
|
||
|
||
/* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */
|
||
void AecXDbSymbNorthThumb::GetTips(PtrList<ObjInfoUnit> &lstInfo) const
|
||
{
|
||
lstInfo.Append(new ObjInfoUnit(_T("对象类型"), _T("指北针")));
|
||
lstInfo.Append(new ObjInfoUnit(_T("北向角度:"), GlobalFunc::Angle2Str(GetRotation() * 180.0 / PI)));
|
||
lstInfo.Append(new ObjInfoUnit(_T("半径"), TCString(_T("%.1fP"), m_nRadius)));
|
||
|
||
// lxb add 111227,根据9.0需求,增加文字
|
||
lstInfo.Append(new ObjInfoUnit(_T("指北针文字"), m_szText));
|
||
}
|
||
|
||
ADSGePoint3d AecXDbSymbNorthThumb::GetNorthPoint() const
|
||
{
|
||
ADSGePoint3d ptTemp;
|
||
ads_polar(m_ptCenter, m_nLayoutRotation + m_nRotation, GetRadius(FALSE), ptTemp);
|
||
return ptTemp;
|
||
}
|
||
|
||
double AecXDbSymbNorthThumb::GetRotation() const
|
||
{
|
||
return m_nRotation;
|
||
}
|
||
|
||
double AecXDbSymbNorthThumb::GetRadius(BOOL bAsPaperUnit) const
|
||
{
|
||
double val = m_nRadius;
|
||
if (!bAsPaperUnit)
|
||
val *= GetPScale();
|
||
return val;
|
||
}
|
||
|
||
ADSGePoint3d AecXDbSymbNorthThumb::GetCenter() const
|
||
{
|
||
return m_ptCenter;
|
||
}
|
||
|
||
void AecXDbSymbNorthThumb::SetRotation(double val)
|
||
{
|
||
AssertWriteEnabled();
|
||
m_nRotation = val;
|
||
}
|
||
|
||
void AecXDbSymbNorthThumb::SetRadius(double nLen, BOOL bAsPaperUnit)
|
||
{
|
||
AssertWriteEnabled();
|
||
m_nRadius = nLen;
|
||
if (!bAsPaperUnit)
|
||
m_nRadius /= GetPScale();
|
||
}
|
||
|
||
void AecXDbSymbNorthThumb::SetCenter(ADSGePoint3d pt)
|
||
{
|
||
AssertWriteEnabled();
|
||
m_ptCenter = pt;
|
||
}
|
||
|
||
// lxb add 111227,根据9.0需求,增加文字
|
||
AcDbObjectId AecXDbSymbNorthThumb::GetTextStyleId() const
|
||
{
|
||
return m_idTextStyle;
|
||
}
|
||
|
||
void AecXDbSymbNorthThumb::SetTextStyleId(AcDbObjectId id)
|
||
{
|
||
AssertWriteEnabled();
|
||
m_idTextStyle = id;
|
||
}
|
||
|
||
double AecXDbSymbNorthThumb::GetTextHeight(BOOL bAsPaperUnit) const
|
||
{
|
||
double dHeight = m_dTextHeight;
|
||
if (!bAsPaperUnit)
|
||
{
|
||
dHeight *= GetPScale();
|
||
}
|
||
return dHeight;
|
||
}
|
||
|
||
void AecXDbSymbNorthThumb::SetTextHeight(double nHeight, BOOL bAsPaperUnit)
|
||
{
|
||
AssertWriteEnabled();
|
||
m_dTextHeight = nHeight;
|
||
if (!bAsPaperUnit)
|
||
{
|
||
m_dTextHeight /= GetPScale();
|
||
}
|
||
}
|
||
|
||
void AecXDbSymbNorthThumb::SetTextColor(Adesk::UInt16 color)
|
||
{
|
||
AssertWriteEnabled();
|
||
m_colorText = color;
|
||
}
|
||
|
||
Adesk::UInt16 AecXDbSymbNorthThumb::GetTextColor() const
|
||
{
|
||
return m_colorText;
|
||
}
|
||
|
||
void AecXDbSymbNorthThumb::SetText(const TCHAR *pszText)
|
||
{
|
||
AssertWriteEnabled();
|
||
m_szText = pszText;
|
||
}
|
||
|
||
const TCHAR* AecXDbSymbNorthThumb::GetText() const
|
||
{
|
||
return (const TCHAR *)m_szText;
|
||
}
|
||
|
||
ADSGePoint3d AecXDbSymbNorthThumb::GetTextPoint(BOOL bEcsPoint) const
|
||
{
|
||
if (bEcsPoint)
|
||
return m_ptText;
|
||
|
||
return GetWcsTextPt();
|
||
}
|
||
|
||
void AecXDbSymbNorthThumb::SetTextPoint(ADSGePoint3d pt)
|
||
{
|
||
AssertWriteEnabled();
|
||
AcGePoint2d ptOrigin = GetEcsOriginPt();
|
||
AcGeVector2d xAxis, yAxis;
|
||
GetEcsAxisVector(xAxis, yAxis);
|
||
|
||
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);
|
||
m_ptText.x = ptResult.x / GetPScale();
|
||
m_ptText.y = ptResult.y / GetPScale();
|
||
}
|
||
|
||
AcGePoint2d AecXDbSymbNorthThumb::GetEcsOriginPt() const
|
||
{
|
||
ADSGePoint3d ptOrg; // ECS原点
|
||
GeLine line(m_ptCenter, GetNorthPoint());
|
||
|
||
ads_real rAngle = line.Direction();
|
||
acutPolar(m_ptCenter, rAngle, (GetRadius(FALSE) + m_dTextHeight * GetPScale()), ptOrg);
|
||
|
||
return (ptOrg.AsAcGePoint2d());
|
||
}
|
||
|
||
void AecXDbSymbNorthThumb::GetEcsAxisVector(AcGeVector2d &xAxis, AcGeVector2d &yAxis) const
|
||
{
|
||
yAxis = GetEcsOriginPt() - m_ptCenter.AsAcGePoint2d();
|
||
|
||
xAxis = yAxis;
|
||
xAxis.rotateBy(-0.5 * PI);
|
||
|
||
xAxis.normalize();
|
||
yAxis.normalize();
|
||
}
|
||
|
||
ADSGePoint3d AecXDbSymbNorthThumb::GetWcsTextPt() const
|
||
{
|
||
AcGePoint2d ptOrigin = GetEcsOriginPt();
|
||
AcGePoint2d ptResult(m_ptText.x * GetPScale(), m_ptText.y * GetPScale());
|
||
|
||
AcGeVector2d xAxis, yAxis;
|
||
GetEcsAxisVector(xAxis, yAxis);
|
||
|
||
AcGeMatrix2d mat2d;
|
||
mat2d = mat2d.alignCoordSys(
|
||
AcGePoint2d(0, 0),
|
||
AcGeVector2d(1, 0),
|
||
AcGeVector2d(0, 1),
|
||
ptOrigin,
|
||
xAxis,
|
||
yAxis);
|
||
ptResult.transformBy(mat2d);
|
||
return ADSGePoint3d(ptResult.x, ptResult.y);
|
||
}
|
||
|
||
ADSGePoint3d AecXDbSymbNorthThumb::GetDefaultTextLocation() const
|
||
{
|
||
ADSGePoint3d ptText = GetEcsOriginPt();
|
||
return ptText; // WCS点
|
||
}
|
||
|