Files
envi-code/SourceCode/Code2026/tg_shs/shs_pipewire/DbEquipDimNew.cpp
T
2026-09-28 15:28:50 +08:00

846 lines
21 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "stdafx.h"
#include "DbEquipDimNew.h"
#include "dbtext.h"
#include "TSysCoordinateTool.h"
EquipDimTextInfo g_TextInfo;
const Adesk::UInt8 TDbEquipDimNew::g_nVersion = 1;
ACRX_DXF_DEFINE_MEMBERS(ATSEquipDimNew, ATSSymbWithText, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
1, ATS_EQUIPDIM2, "ATS_EQUIPDIM2图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
IMPLEMENT_TENTBASE(TDbEquipDimNew);
void InitDbEquipDimNew(BOOL bTrue)
{
if (bTrue)
{
TDbEquipDimNew::rxInit();
TDbEquipDimNew::InitMatchProtocol(TRUE);
}
else
{
TDbEquipDimNew::InitMatchProtocol(FALSE);
deleteAcRxClass(TDbEquipDimNew::desc());
}
}
TDbEquipDimNew::TDbEquipDimNew()
{
m_nType = -1;
m_nNum = 0;
m_csX = _T("x"); // x X ×
m_bHasW = true;
m_ptIns.x = 0;
m_ptIns.y = 0;
m_nDimLen = -1;
}
TDbEquipDimNew::TDbEquipDimNew( AcGePoint3d ptIns, bool bHasW, int nNum, CString csX,
CString csBulbNum, CString csSpec, CString csBulbPower,
CString csSetupHeight, CString csSetupMode, CString csLightType)
{
m_nType = 0;
m_ptIns = ptIns;
m_bHasW = bHasW;
m_csX = csX;
m_nNum = nNum;
m_csBulbNum = csBulbNum;
m_csSpec = csSpec;
m_csBulbPower = csBulbPower;
m_csSetupHeight = csSetupHeight;
m_csSetupMode = csSetupMode;
m_csLightType = csLightType;
m_nDimLen = -1;
InitData();
}
TDbEquipDimNew::TDbEquipDimNew(AcGePoint3d ptIns, CString csBulbNum, CString csSetupHeight)
{
m_nType = 1;
m_nNum = 0;
m_ptIns = ptIns;
m_csBulbNum = csBulbNum;
m_csSetupHeight = csSetupHeight;
m_nDimLen = -1;
InitData();
}
TDbEquipDimNew::TDbEquipDimNew(AcGePoint3d ptIns, CString csBulbNum)
{
m_nType = 2;
m_nNum = 0;
m_ptIns = ptIns;
m_csSpec = csBulbNum;
m_nDimLen = -1;
InitData();
}
TDbEquipDimNew::~TDbEquipDimNew()
{
}
// ***************************************
// csTitle2
// csTitle1 ------------ csTitle4
// csTitle3
//****************************************
void TDbEquipDimNew::InitData()
{
m_csTitle1.Format(_T("%d"), m_nNum);
if(m_csTitle1 != _T("") && m_csSpec != _T("") && m_nType == 0)
m_csTitle1 += _T("-");
else if(m_nType != 0)
m_csTitle1 = _T("");
m_csTitle1 += m_csSpec;
if(m_csBulbNum == _T(""))
m_csBulbNum = _T("1");
if(m_csBulbNum == _T("1"))
m_csTitle2 = _T("");
else
m_csTitle2 = m_csBulbNum;
if(m_csBulbNum != _T("1") && (m_csBulbPower != _T("") || m_csLightType!=_T("")))
m_csTitle2 += m_csX;
if(m_csBulbPower != _T("")){
m_csTitle2 += m_csBulbPower;
// if(m_bHasW && m_csX == _T("x"))
// m_csTitle2 += _T("w");
// else if(m_bHasW && m_csX == _T("X")) //delete by wx 2015-1-14
if(m_bHasW) //add by wx
m_csTitle2 += _T("W");//add end
if(m_csLightType!=_T(""))
m_csTitle2 += m_csX;
}
m_csTitle2 += m_csLightType;
m_csTitle3 = m_csSetupHeight;
if(m_csTitle3 == _T("") && m_nType == 0)
m_csTitle3 = _T("-");
m_csTitle4 = m_csSetupMode;
}
double TDbEquipDimNew::GetDimLength() const
{
double nLen4(0), nLenRet(0);
double nLen(0), nLen2(0), nLen3(0);
AcGePoint3d pMax, pMin;
AcDbObjectId id = GetTextStyleId();
if(m_csTitle1 != _T("")){
TDbText text1;
text1.setPropertiesFrom(this);
text1.SetLocation(m_ptIns);
text1.SetHeight(GetTextHeight());//*GetPScale()
text1.SetText(m_csTitle1);
text1.SetStyleId(id);
// text1.setWidthFactor(m_nWidthFactor);
// text1.SetRotation(this->GetTextRotation());
AcDbExtents extents;
text1.getGeomExtents(extents);
pMax = extents.maxPoint();
pMin = extents.minPoint();
nLen = pMax.distanceTo(pMin) + GetTextHeight()*GetPScale();//*GetPScale()
nLenRet += nLen;
}
XPoint ptTmp, ptTmp2;
if(m_csTitle2 != _T("") || m_csTitle3 != _T("-")){
ptTmp.x = m_ptIns.x + nLen;
ptTmp.y = m_ptIns.y + GetTextHeight()*GetPScale();//*GetPScale()
TDbText text2, text3;
text2.setPropertiesFrom(this);
text2.SetLocation(m_ptIns);
text2.SetHeight(GetTextHeight());//*GetPScale()
text2.SetText(m_csTitle2);
text2.SetStyleId(id);
// text2.setWidthFactor(m_nWidthFactor);
// text2.SetRotation(this->GetTextRotation());
AcDbExtents extents1;
text2.getGeomExtents(extents1);
pMax = extents1.maxPoint();
pMin = extents1.minPoint();
nLen2 = pMax.distanceTo(pMin);
text3.SetLocation(m_ptIns);
text3.setPropertiesFrom(this);
text3.SetHeight(GetTextHeight());//*GetPScale()
text3.SetText(m_csTitle3);
text3.SetStyleId(id);
// text3.setWidthFactor(m_nWidthFactor);
// text3.SetRotation(this->GetTextRotation());
AcDbExtents extents2;
text3.getGeomExtents(extents2);
pMax = extents2.maxPoint();
pMin = extents2.minPoint();
nLen3 = pMax.distanceTo(pMin);
if(nLen3 > nLen2)
// nLenRet += (nLen3 + GetTextHeight()*GetPScale());//*GetPScale()
nLenRet += (nLen3 + GetTextHeight()*GetPScale()/2);//bsl 2011.6.27
else
//nLenRet += (nLen2 + GetTextHeight()*GetPScale());//*GetPScale()
nLenRet += (nLen2 + GetTextHeight()*GetPScale()/2);//bsl 2011.6.27
}
if(m_csTitle4 != _T("")){
ptTmp.x = m_ptIns.x + nLen + nLen2 + GetTextHeight()*GetPScale();//*GetPScale()
ptTmp.y = m_ptIns.y;
TDbText text4;
text4.setPropertiesFrom(this);
text4.SetLocation(ptTmp);
text4.SetHeight(GetTextHeight());//*GetPScale()
text4.SetText(m_csTitle4);
text4.SetStyleId(id);
// text4.setWidthFactor(m_nWidthFactor);
// text4.SetRotation(this->GetTextRotation());
AcDbExtents extents4;
text4.getGeomExtents(extents4);
pMax = extents4.maxPoint();
pMin = extents4.minPoint();
nLen4 = pMax.distanceTo(pMin);
nLenRet += (nLen4 + GetTextHeight()*GetPScale());//*GetPScale()
}
// m_nDimLen = nLenRet;
return nLenRet;
}
// ***********************************************************************
// BulbNum X Power X LightType
// LightNum - EquipType ------------------------------SetupMode
// SetupHeight
//************************************************************************
Acad::ErrorStatus
TDbEquipDimNew::subGetGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const
{
assertReadEnabled();
gripPoints.append(m_ptIns);
gripPoints.append(m_ptStart);
//添加夹点 axc add 2015-05-05
if (eLine == GetDimEquipType())
{
AcGePoint3d ptThird(m_ptIns + GetLineDir() * GetBaseLineLen());
gripPoints.append(ptThird);
}
return Acad::eOk;
}
Acad::ErrorStatus
TDbEquipDimNew::subMoveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset)
{
if (indices.length()== 0 || offset.isZeroLength())
return Acad::eOk; //that's easy :-)
assertWriteEnabled();
if (indices.length() > 1){
return Acad::eOk;
}
if (indices[0] == 0) {
if (eLine == GetDimEquipType())
{
//axc add 2015-05-05
AcGeVector3d vtDir = GetLineDir();
if (Wcs2Ucs(m_ptIns).x > Wcs2Ucs(m_ptStart).x)
{
if (Wcs2Ucs(m_ptIns + offset).x < Wcs2Ucs(m_ptStart).x)
{
vtDir *= -1;
}
}
else
{
if (Wcs2Ucs(m_ptIns + offset).x > Wcs2Ucs(m_ptStart).x)
{
vtDir *= -1;
}
}
SetLineDir(vtDir);
}
m_ptIns += offset;
return Acad::eOk;
}
else if (indices[0] == 1) {
m_ptStart += offset;
return Acad::eOk;
}
else if (indices[0] == 2)
{
if (eLine == GetDimEquipType())
{
//新增夹点操作 axc add 2015-05-05
AcGePoint3d ptE = m_ptIns + GetBaseLineLen() * GetLineDir();
AcDbLine line(m_ptIns,ptE);
AcGeVector3d vtDir = Ucs2Wcs(AcGeVector3d::kXAxis);
AcGePoint3d ptOnLine;
ptE += offset;
line.getClosestPointTo(ptE,ptOnLine,Adesk::kTrue);
vtDir = ptOnLine - m_ptIns;
double dBaseLine = vtDir.length();
vtDir.normalize();
SetLineDir(vtDir);
SetBaseLineLen(dBaseLine);
}
}
return Acad::eOk;
}
Acad::ErrorStatus
TDbEquipDimNew::subTransformBy(const AcGeMatrix3d& xform)
{
assertWriteEnabled();
m_ptIns.transformBy(xform);
// if(m_ptStart != AcGePoint3d(0,0,0))
m_ptStart.transformBy(xform);
return Acad::eOk;
}
Acad::ErrorStatus TDbEquipDimNew::subGetClassID(CLSID* pClsid) const
{
return Acad::eOk;
}
Acad::ErrorStatus
TDbEquipDimNew::dwgOutFields(AcDbDwgFiler* filer) const
{
assertReadEnabled();
Acad::ErrorStatus es = TDbSymbWithText::dwgOutFields(filer);
if(es != Acad::eOk)
return es;
Adesk::Int16 val = m_nNum;
Adesk::Int16 type = m_nType;
filer->writeItem(g_nVersion);
filer->writePoint3d(m_ptStart);
filer->writePoint3d(m_ptIns);
filer->writeBool(m_bHasW);
// filer->writeDouble(m_nDimLen);
filer->writeInt16(val);
filer->writeInt16(type);
filer->writeString((LPCTSTR)m_csSpec);
filer->writeString((LPCTSTR)m_csBulbNum);
filer->writeString((LPCTSTR)m_csBulbPower);
filer->writeString((LPCTSTR)m_csSetupHeight);
filer->writeString((LPCTSTR)m_csSetupMode);
filer->writeString((LPCTSTR)m_csLightType);
filer->writeString((LPCTSTR)m_csX);
return filer->filerStatus();
}
Acad::ErrorStatus
TDbEquipDimNew::dwgInFields(AcDbDwgFiler* filer)
{
assertWriteEnabled();
Acad::ErrorStatus es = TDbSymbWithText::dwgInFields(filer);
if(es != Acad::eOk)
return es;
// Object Version - must always be the first item.
//
Adesk::Int8 version;
AcGePoint3d ptTmp;
Adesk::Int16 val;
filer->readItem(&version);
if (version > g_nVersion)
return Acad::eMakeMeProxy;
switch (version)
{
case 1:
{
filer->readPoint3d(&m_ptStart);
filer->readPoint3d(&m_ptIns);
filer->readBool(&m_bHasW);
// filer->readDouble(&m_nDimLen);
filer->readInt16(&val);
m_nNum = val;
filer->readInt16(&val);
m_nType = val;
XString xsContent;
ReadString(filer, xsContent);
m_csSpec = (const TCHAR*)xsContent;
ReadString(filer, xsContent);
m_csBulbNum = (const TCHAR*)xsContent;
ReadString(filer, xsContent);
m_csBulbPower = (const TCHAR*)xsContent;
ReadString(filer, xsContent);
m_csSetupHeight = (const TCHAR*)xsContent;
ReadString(filer, xsContent);
m_csSetupMode = (const TCHAR*)xsContent;
ReadString(filer, xsContent);
m_csLightType = (const TCHAR*)xsContent;
ReadString(filer, xsContent);
m_csX = (const TCHAR*)xsContent;
break;
}
default:
assert(false);
}
// if(GetTextHeight()*GetPScale() > GetPScale())
// GetTextHeight()*GetPScale() = GetTextHeight()*GetPScale()/GetPScale();
// if(GetTextHeight()*GetPScale() < 10)
// GetTextHeight()*GetPScale() = GetTextHeight()*GetPScale() * 100;
InitData();
return filer->filerStatus();
}
void TDbEquipDimNew::SetLineDir(const AcGeVector3d& vtDir)
{
assertWriteEnabled();
TEntityFields& fields = Fields();
fields.SFD(_T("EQUIPDIMLINEDIR"), vtDir);
}
AcGeVector3d TDbEquipDimNew::GetLineDir() const
{
assertReadEnabled();
AcGeVector3d vtDir = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
const TEntityFields& fields = GetFields();
fields.GFD(_T("EQUIPDIMLINEDIR"), vtDir);
return vtDir;
}
void TDbEquipDimNew::SetDimEquipType(const int type)
{
assertWriteEnabled();
TEntityFields& fields = Fields();
fields.SFD(_T("EQUIPDIMLINETYPE"), type);
}
int TDbEquipDimNew::GetDimEquipType() const
{
assertReadEnabled();
int nType = 0;
const TEntityFields& fields = GetFields();
fields.GFD(_T("EQUIPDIMLINETYPE"), nType);
return nType;
}
void TDbEquipDimNew::SetBaseLineLen(const double dBaseLineLen)
{
assertWriteEnabled();
TEntityFields& fields = Fields();
fields.SFD(_T("EQUIPBASELINELEN"), dBaseLineLen);
}
double TDbEquipDimNew::GetBaseLineLen() const
{
assertReadEnabled();
double dLen = 0.0;
const TEntityFields& fields = GetFields();
fields.GFD(_T("EQUIPBASELINELEN"), dLen);
return dLen;
}
Acad::ErrorStatus TDbEquipDimNew::ExplodeOrDraw2d(XExplodeDraw &dc) const
{
// cet 2016.10.17 add 图层关闭时,实体不显示,不进行绘制(打印时,也不会绘制)
AcDbLayerTableRecordPointer player(this->layerId(), AcDb::kForRead);
if (player.openStatus() == Acad::eOk && player->isOff())
{
return Acad::eOk;
}
AcGeVector3d vtDirTT = Ucs2Wcs(AcGeVector3d::kXAxis);
AcGeVector3d vtVerTT = Ucs2Wcs(AcGeVector3d::kYAxis);
AcGeVector3d vtDirT = AcGeVector3d::kXAxis;
AcGeVector3d vtVerT = AcGeVector3d::kYAxis;
vtDirT.rotateBy(GetLayoutRotation(),AcGeVector3d::kZAxis);
vtVerT.rotateBy(GetLayoutRotation(),AcGeVector3d::kZAxis);
if(m_ptIns.x == 0 && m_ptIns.y == 0)
return Acad::eOk;
XPoint ptTmp, ptTmp2, ptInsTmp;
AcGePoint3d pMax, pMin;
ptInsTmp = m_ptIns;
if(m_ptStart != AcGePoint3d(0,0,0)){
AcGePoint3d ptArray2[2] = {m_ptStart, m_ptIns,};
XLine line;
line.SetPoints(m_ptStart,m_ptIns);
dc.DrawLine(line);
double dimlen = GetDimLength();
//axc add 2015-05-05
if (eLine == GetDimEquipType())
{
double dScale = GetPScale();
ptInsTmp += GetTextHeight()*GetPScale()*vtVerT;//*GetPScale()
ptInsTmp += GetTextHeight()*GetPScale()/2*vtDirT;//*GetPScale()
line.SetPoints(m_ptIns,m_ptIns+GetLineDir()*GetBaseLineLen());
dc.DrawLine(line);
}
else
{
ptInsTmp -= GetTextHeight()*GetPScale()/2*vtVerT;//*GetPScale()
ptInsTmp += GetTextHeight()*GetPScale()/2*vtDirT;//*GetPScale()
}
double dS = Wcs2Ucs(m_ptIns).x;
double dT = Wcs2Ucs(m_ptStart).x;
if(dS < dT)
{
if (m_nType == 2)
ptInsTmp += GetTextHeight()*GetPScale()*vtDirT;//*GetPScale()
ptInsTmp -= dimlen*vtDirT;
}
}
ptTmp = ptInsTmp;
TPushProperty* pVProp = NULL;
double nLen(0), nLen2(0), nLen3(0);
AcDbObjectId id = this->GetTextStyleId();;
if(m_csTitle1 != _T("")){
TDbText text1;
text1.setPropertiesFrom(this);
text1.SetLocation(ptInsTmp);
text1.SetHeight(GetTextHeight());//*GetPScale()
text1.SetText(m_csTitle1);
text1.SetStyleId(id);
text1.SetAlignment(XExplodeDraw::kBottomLeft);
text1.setColorIndex(GetTextColor());
g_TextInfo.ptTitle1 = ptInsTmp;
// text1.setLayer(GetTextLayerId());
// text1.set(m_nWidthFactor);
// text1.SetRotation(this->GetTextRotation());
pVProp = new TPushProperty(&text1, dc);
if(dc.IsFullExplode())
text1.ExplodeOrDraw2d(dc);
else
dc.DrawEntity(text1);
delete pVProp;
pVProp = NULL;
XPoint ptTempLen = text1.GetExtents();
AcDbExtents extents;
text1.getGeomExtents(extents);
pMax = extents.maxPoint();
pMin = extents.minPoint();
nLen = pMax.distanceTo(pMin) + GetTextHeight()*GetPScale()*0.9;//*GetPScale()
nLen = ptTempLen.x + GetTextHeight()*GetPScale();
ptTmp = ptInsTmp + nLen*vtDirT;
}
if(m_csTitle2 == _T("") && m_csTitle3 == _T("") && m_csTitle4 == _T(""))
return Acad::eOk;
if(m_csTitle2 != _T("") || m_csTitle3 != _T("-")){
TDbText text2, text3;
text2.setPropertiesFrom(this);
text2.SetLocation(ptInsTmp);
text2.SetHeight(GetTextHeight());//*GetPScale()
text2.SetText(m_csTitle2);
text2.SetStyleId(id);
text2.SetAlignment(XExplodeDraw::kBottomLeft);
text2.setColorIndex(GetTextColor());
g_TextInfo.ptTitle2 = ptInsTmp;
// text2.setLayer(GetTextLayerId());
// text2.setWidthFactor(m_nWidthFactor);
// text2.SetRotation(this->GetTextRotation());
AcDbExtents extents1;
double dTextH = GetTextHeight();
text2.getGeomExtents(extents1);
pMax = extents1.maxPoint();
pMin = extents1.minPoint();
nLen2 = pMax.distanceTo(pMin);
text3.setPropertiesFrom(this);
AcGeVector3d vtTemp = vtDirT;
if (m_csTitle3.Find(_T("|")) > -1 ||
m_csTitle3.Find(_T("\\")) > -1||
m_csTitle3.Find(_T("/")) > -1)
{
vtTemp.rotateBy(PI/2,AcGeVector3d::kZAxis);
vtTemp.normalize();
vtTemp *= 250;
}
else
vtTemp *= 0;
text3.SetHeight(dTextH);//*GetPScale()
text3.SetText(m_csTitle3);
text3.SetStyleId(id);
text3.SetAlignment(XExplodeDraw::kBottomLeft);
text3.setColorIndex(GetTextColor());
AcDbExtents extents2;
text3.getGeomExtents(extents2);
pMax = extents2.maxPoint();
pMin = extents2.minPoint();
nLen3 = pMax.distanceTo(pMin);
if(nLen3 > nLen2)
{
ptTmp -= 0.7*GetTextHeight()*GetPScale()*vtVerT + vtTemp;//*GetPScale()
text3.SetLocation(ptTmp);
g_TextInfo.ptTitle3 = ptTmp;
pVProp = new TPushProperty(&text3, dc);
if(dc.IsFullExplode())
text3.ExplodeOrDraw2d(dc);
else
dc.DrawEntity(text3);
delete pVProp;
pVProp = NULL;
//ptTmp = ptInsTmp + (nLen + nLen2 / 2 - nLen3 / 2)*vtDirT;
ptTmp = ptInsTmp + (nLen + nLen3 / 2 - nLen2 / 2)*vtDirT; // bsl 2011.6.28
ptTmp += 0.7*(GetTextHeight()*GetPScale())*vtVerT;//*GetPScale()
text2.SetLocation(ptTmp);
g_TextInfo.ptTitle2 = ptTmp;
pVProp = new TPushProperty(&text2, dc);
if(dc.IsFullExplode())
text2.ExplodeOrDraw2d(dc);
else
dc.DrawEntity(text2);
delete pVProp;
pVProp = NULL;
nLen2 = nLen3; // bsl 2011.6.28
}
else{
ptTmp += 0.7*GetTextHeight()*GetPScale()*vtVerT;//*GetPScale()
text2.SetLocation(ptTmp);
g_TextInfo.ptTitle2 = ptTmp;
pVProp = new TPushProperty(&text2, dc);
if(dc.IsFullExplode())
text2.ExplodeOrDraw2d(dc);
else
dc.DrawEntity(text2);
delete pVProp;
pVProp = NULL;
ptTmp = ptInsTmp + (nLen + nLen2 / 2 - nLen3 / 2)*vtDirT;
ptTmp -= 0.7*GetTextHeight()*GetPScale()*vtVerT + vtTemp;//*GetPScale()
text3.SetLocation(ptTmp);
g_TextInfo.ptTitle3 = ptTmp;
pVProp = new TPushProperty(&text3, dc);
if(dc.IsFullExplode())
text3.ExplodeOrDraw2d(dc);
else
dc.DrawEntity(text3);
delete pVProp;
pVProp = NULL;
}
if(m_csTitle3 != _T("") || (m_ptStart != AcGePoint3d(0,0,0))){
ptTmp = ptInsTmp + (nLen - GetTextHeight()*GetPScale()/2)*vtDirT;//*GetPScale()
ptTmp += GetTextHeight()*GetPScale()/2*vtVerT; //*GetPScale()
double dimlen = GetDimLength();
if (m_nType == 0)
ptTmp2 = ptTmp + (nLen2 + GetTextHeight()*GetPScale())*vtDirT; //*GetPScale()
else
ptTmp2 = ptTmp + dimlen*vtDirT; //*GetPScale()
// ptTmp2.y = ptTmp.y;
AcGePoint3d ptArray[2] = {ptTmp, ptTmp2,};
XLine line;
line.SetPoints(ptTmp,ptTmp2);
dc.DrawLine(line);
}
}
if(m_csTitle4 != _T("")){
ptTmp = ptInsTmp + (nLen + nLen2 + GetTextHeight()*GetPScale())*vtDirT;//*GetPScale()
// ptTmp.y = ptInsTmp.y;
TDbText text4;
text4.setPropertiesFrom(this);
text4.SetLocation(ptTmp);
g_TextInfo.ptTitle4 = ptTmp;
text4.SetHeight(GetTextHeight());//*GetPScale()
text4.SetText(m_csTitle4);
text4.SetStyleId(id);
// text4.setLayer(GetTextLayerId());
text4.SetAlignment(XExplodeDraw::kBottomLeft);
text4.setColorIndex(GetTextColor());
// text4.setWidthFactor(m_nWidthFactor);
// text4.SetRotation(this->GetTextRotation());
TPushProperty vProp(&text4, dc);
if(dc.IsFullExplode())
text4.ExplodeOrDraw2d(dc);
else
dc.DrawEntity(text4);
}
return Acad::eOk;
}
//axc add 2015-05-15 设备标准支持查找替换命令
// 返回发现的位置,同时posStart往前移动(以便继续找下一个使用)
TTextPosition TDbEquipDimNew::FindSubText(const TCHAR *sSubText, TTextPosition &posStart, TTextRange *pRange) const
{
TTextPosition pos;
if (!sSubText || !sSubText[0])
return pos;
TTextPosition posNext = posStart;
while (1)
{
TTextPosition posFind; //查找到的文本位置
int nCookies = posNext.m_nCookies;
TDbText text; //待查找的子文本内容
if (!GetText(nCookies, text))
break;
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;
}
BOOL TDbEquipDimNew::GetText(Adesk::UInt32 cookies, TDbText &text) const
{
if ((UINT)cookies > 4) return FALSE;
text.setPropertiesFrom(this);
text.SetRotation(0);
text.SetHeight(m_nTextHeight);
text.SetStyleId(m_idTextStyle);
XPoint ptLoc;
switch (cookies)
{
case 0:
{
ptLoc = g_TextInfo.ptTitle1;
text.SetText(m_csTitle1);
}
break;
case 1:
{
ptLoc = g_TextInfo.ptTitle2;
text.SetText(m_csTitle2);
}
break;
case 2:
{
ptLoc = g_TextInfo.ptTitle3;
text.SetText(m_csTitle3);
}
break;
case 3:
{
ptLoc = g_TextInfo.ptTitle4;
text.SetText(m_csTitle4);
}
break;
default:
break;
}
text.SetLocation(ptLoc);
return TRUE;
}
TTextPosition TDbEquipDimNew::ReplaceSubText(const TTextPosition &posRep, const TCHAR *sRepText, TTextRange *pRange)
{
assertWriteEnabled();
TTextPosition posNext;
int cookies = posRep.m_nCookies;
if (cookies > 4)
{
posNext.m_nCookies = posRep.m_nCookies + 1;
posNext.m_nTextPos = 0;
return posNext;
}
TDbText text; //即将被替换内容的子文本内容
if (!sRepText || !GetText(cookies, text))
return posNext;
posNext = text.ReplaceSubText(posRep, sRepText, pRange);
switch (cookies)
{
case 0:
m_csTitle1 = text.GetText();
break;
case 1:
m_csTitle2 = text.GetText();
break;
case 2:
m_csTitle3 = text.GetText();
break;
case 3:
m_csTitle4 = text.GetText();
break;
default:
break;
}
if (!posNext)
{
posNext.m_nCookies = posRep.m_nCookies+1;
posNext.m_nTextPos = 0;
}
return posNext;
}
void TDbEquipDimNew::SetSubText(long i,CString sText)
{
switch (i)
{
case 0:
m_csTitle1 = sText;
break;
case 1:
m_csTitle2 = sText;
break;
case 2:
m_csTitle3 = sText;
break;
case 3:
m_csTitle4 = sText;
break;
default:
break;
}
}
//add end
AcGePoint3d TDbEquipDimNew::GetStartPt()
{
return m_ptStart;
}
AcGePoint3d TDbEquipDimNew::GetTurnPt()
{
return m_ptIns;
}
void TDbEquipDimNew::SetStartPt(const AcGePoint3d& ptS)
{
m_ptStart = ptS;
}
void TDbEquipDimNew::SetTurnPt(const AcGePoint3d& ptT)
{
m_ptIns = ptT;
}