6259 lines
156 KiB
C++
6259 lines
156 KiB
C++
#include "stdafx.h"
|
||
//#include "TDbCableDim.h"
|
||
#include "dbproxy.h"
|
||
//#include "docreactor.h"
|
||
#include "Symdef.h"
|
||
#include "dbtext.h"
|
||
#include "TSysCoordinateTool.h"
|
||
#include "layerDefine.h"
|
||
|
||
//#define VERSION_TDBEEQUIPMENT 2 // 09.6.3号添加标注类型(LABLE_CABNO,LABLE_SPE,LABLE_CABANDSPE)版本由1升级到2
|
||
//#define VERSION_TDBEEQUIPMENT 3 // 10.10.18增加数据有效位数变量和备用变量版本由2升级到3
|
||
//#define VERSION_TDBEEQUIPMENT 4 // 2011.12.30 修改ID存放方式 版本由 3升级到4 (电气8.5)
|
||
#define VERSION_TDBEEQUIPMENT 5 // 增加 电缆标注夹点操作 (电气9.0) 2013
|
||
#define CABLELAY_XDATA_NAME _T("CableLay_XData_Name")//编号
|
||
#define CABLELAY_XDATA_SPE _T("CableLay_XData_Spe")//规格
|
||
#define LABLE_FILE_NAME _T("LableSet.dat")
|
||
#define LABLE_TYPE _T("类型") //lsd add 2013.7.17 添加桥架标注“类型”选项
|
||
#define LABLE_SYS_TYPE _T("系统分类") //lsd 2013-8-23 添加“系统分类”关键字
|
||
#define LABLE_NAME _T("编号")
|
||
#define LABLE_MODAL _T("型号")
|
||
#define LABLE_SPECS _T("规格")
|
||
#define LABLE_ELV _T("敷设高度")
|
||
#define LABLE_LEN _T("长度")
|
||
#define LABLE_CABNO _T("Lable_CabNo")//标注电缆编号
|
||
#define LABLE_SPE _T("Lable_Spe")//标注电缆规格
|
||
#define LABLE_CABANDSPE _T("Lable_Cab_Spe")//标注编号加规格
|
||
#define KEY_PIPE_FLOW_D _T("PipeFlowD") //穿管管径
|
||
//穿管扩展数据
|
||
#define CABLE_PIPE_FLOW _T("CablePipeFlow")
|
||
#define CABLE_PIPE_FLOW_IS_DIM _T("IsDimPipeFlow")
|
||
//多电缆敷设
|
||
#define MULTI_CABLE_LAY _T("MultiLay")
|
||
#define MULTI_CABLE_LAY_DIM _T("IsMultiCableLayDim")//是否多电缆敷设标注
|
||
#define SPEC_CHAR _T("*")
|
||
|
||
//引线扩展数据
|
||
#define DOWN_LEAD_XDATA _T("DownLeadXData")
|
||
#define DOWN_LEAD_COUNT _T("DownLeadCount")
|
||
|
||
//{{AFX_ARX_MACRO
|
||
ACRX_DXF_DEFINE_MEMBERS( TDbCableDim, TDbEntity,
|
||
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
||
AcDbProxyEntity::kAllAllowedBits,
|
||
ATS_CABLEDIM, "图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
||
//}}AFX_ARX_MACRO
|
||
|
||
IMPLEMENT_TENTBASE(TDbCableDim);
|
||
|
||
//处理数据
|
||
static void DisposeData(LPCTSTR lpKey,CString &sRowStr,CString &sData)
|
||
{
|
||
int idx = sRowStr.Find(lpKey);
|
||
sData = sRowStr.Left(idx);
|
||
sRowStr = sRowStr.Mid(idx + 1);
|
||
}
|
||
|
||
static CString GetName(BOOL bIsMultiLay)
|
||
{
|
||
CString sT = bIsMultiLay ? MULTI_CABLE_LAY : CABLELAY_XDATA_NAME;
|
||
return sT;
|
||
}
|
||
|
||
TDbCableDim::TDbCableDim()
|
||
{
|
||
m_nDimEntType = eCableTray;
|
||
m_dTextRowDis = 1.2;
|
||
m_nColorLine = 0;
|
||
m_nTextRotation = 0;
|
||
m_nColorText = 0;
|
||
m_sLableContent = _T("");
|
||
m_sLableType = LABLE_CABNO;
|
||
m_bPipeFlow = FALSE;
|
||
m_bIsMulitCableLayDim = FALSE;
|
||
m_nValidBit = 1;
|
||
m_sSign = _T("");
|
||
m_nCurDwgVer = VERSION_TDBEEQUIPMENT;
|
||
|
||
//added by lsd 2013-8-26
|
||
//初始化系统分类关键字
|
||
//m_sSysKeyForce = _T("E");
|
||
//m_sSysKeyFire = _T("F");
|
||
//m_sSysKeyWeak = _T("D");
|
||
//m_sSysKeyOther = _T("T");
|
||
//end
|
||
}
|
||
|
||
TDbCableDim::~TDbCableDim()
|
||
{
|
||
|
||
}
|
||
|
||
Acad::ErrorStatus TDbCableDim::dxfOutFields(AcDbDxfFiler* pFiler) const
|
||
{
|
||
assertReadEnabled();
|
||
Acad::ErrorStatus es;
|
||
|
||
if ((es = TDbEntity::dxfOutFields(pFiler)) != Acad::eOk)
|
||
return es;
|
||
|
||
es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbCableDim"));
|
||
assert(es == Acad::eOk);
|
||
|
||
return es;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbCableDim::dxfInFields(AcDbDxfFiler* pFiler)
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
if ((TDbEntity::dxfInFields(pFiler) != Acad::eOk))
|
||
return pFiler->filerStatus();
|
||
|
||
if (!pFiler->atSubclassData(_T("TDbCableDim")))
|
||
{
|
||
return Acad::eBadDxfSequence;
|
||
}
|
||
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDbCableDim::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||
{
|
||
assertReadEnabled();
|
||
Acad::ErrorStatus es;
|
||
|
||
if ((es = TDbEntity::dwgOutFields(pFiler)) != Acad::eOk)
|
||
{
|
||
return es;
|
||
}
|
||
|
||
pFiler->writeItem((Adesk::UInt16) VERSION_TDBEEQUIPMENT);
|
||
|
||
pFiler->writeItem(m_nTextHeight);
|
||
pFiler->writeItem(m_nTextRotation);
|
||
pFiler->writeHardPointerId(m_idTextLayer);
|
||
pFiler->writeHardPointerId(m_idTextStyle);
|
||
|
||
pFiler->writeItem(m_ptS);
|
||
pFiler->writeItem(m_ptTurn);
|
||
pFiler->writeItem(m_vtDir);
|
||
pFiler->writeItem(m_dLineBaseLen*GetPScale());
|
||
pFiler->writeItem(m_dTextRowDis);
|
||
pFiler->writeItem(m_nColorLine);
|
||
pFiler->writeItem(m_nColorText);
|
||
pFiler->writeItem(m_nLableStyle);
|
||
pFiler->writeItem(m_nStartStyle);
|
||
pFiler->writeItem(m_nDimEntType);
|
||
pFiler->writeString((LPCTSTR)m_sLableType);
|
||
|
||
|
||
/*
|
||
Adesk::UInt16 nCount = m_arIds.length();
|
||
pFiler->writeItem(nCount);
|
||
for (int i =0; i < m_arIds.length(); ++i)
|
||
{
|
||
// AcDbHandle dhl = m_arIds[i].handle();
|
||
// es = pFiler->writeAcDbHandle(dhl);
|
||
pFiler->writeSoftPointerId(m_arIds[i]);
|
||
}
|
||
*/
|
||
pFiler->writeString((LPCTSTR)m_sLableContent);
|
||
//pFiler->writeString(m_sLableFds);
|
||
pFiler->writeItem(m_nValidBit);
|
||
pFiler->writeItem(m_nSpare);
|
||
pFiler->writeItem(m_dSpare);
|
||
pFiler->writeString((LPCTSTR)m_sLableFds);
|
||
|
||
//行列
|
||
Adesk::UInt16 nCount = m_arRowWidth.length();
|
||
pFiler->writeItem(nCount);
|
||
AcGePoint3d ptTemp;
|
||
for (int i = 0;i < nCount;++i)
|
||
{
|
||
pFiler->writeItem(m_arRowWidth[i]);
|
||
}
|
||
//电缆分类标示
|
||
pFiler->writeItem(m_sSign);
|
||
|
||
//写入引线扩展数据
|
||
//WriteDownLeadData();
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDbCableDim::dwgInFields(AcDbDwgFiler* pFiler)
|
||
{
|
||
assertWriteEnabled();
|
||
Acad::ErrorStatus es;
|
||
|
||
if ((es = TDbEntity::dwgInFields(pFiler)) != Acad::eOk)
|
||
{
|
||
return es;
|
||
}
|
||
|
||
Adesk::UInt16 version;
|
||
pFiler->readItem(&version);
|
||
m_nCurDwgVer = version; // 记录当前导入图纸的版本号 2013/2/8 wzh add
|
||
if (version > VERSION_TDBEEQUIPMENT)//超过当前版本
|
||
{
|
||
return Acad::eMakeMeProxy;
|
||
}
|
||
|
||
pFiler->readItem(&m_nTextHeight);
|
||
pFiler->readItem(&m_nTextRotation);
|
||
pFiler->readHardPointerId(&m_idTextLayer);
|
||
pFiler->readHardPointerId(&m_idTextStyle);
|
||
pFiler->readItem(&m_ptS);
|
||
pFiler->readItem(&m_ptTurn);
|
||
pFiler->readItem(&m_vtDir);
|
||
pFiler->readItem(&m_dLineBaseLen);
|
||
m_dLineBaseLen /= GetPScale(); //tsj add2010.7.18解决更新比例时文字底线的长度不变的问题
|
||
pFiler->readItem(&m_dTextRowDis);
|
||
pFiler->readItem(&m_nColorLine);
|
||
pFiler->readItem(&m_nColorText);
|
||
pFiler->readItem(&m_nLableStyle);
|
||
pFiler->readItem(&m_nStartStyle);
|
||
pFiler->readItem(&m_nDimEntType);
|
||
|
||
if (version > 1)
|
||
{
|
||
//读取新添加的数据
|
||
TCHAR *pBuffer=NULL;
|
||
pFiler->readString(&pBuffer);
|
||
m_sLableType = pBuffer;
|
||
acutDelString(pBuffer);
|
||
}
|
||
|
||
|
||
if (version <= 4) // 解决8.5桥架标注,9.0打开崩溃问题 2013/2/8 alter
|
||
{
|
||
Adesk::UInt16 nCount;
|
||
AcDbSoftPointerId id;
|
||
AcDbHandle hdl;
|
||
pFiler->readItem(&nCount);
|
||
m_arIds.setLogicalLength(0);
|
||
AcDbDatabase* pDataBase = NULL;
|
||
for (int i =0; i < nCount; ++i)
|
||
{
|
||
//存放ID
|
||
if (version == 3)
|
||
{
|
||
//版本3存放的为句柄
|
||
pFiler->readAcDbHandle(&hdl);
|
||
pDataBase = acdbCurDwg();
|
||
if (GetCurDocData())
|
||
{
|
||
XString &sCmd = GetCurDocData()->m_sCurCommand;
|
||
if (_tcsicmp(sCmd,_T("T83_TBatSave")) == 0)
|
||
{
|
||
//bsl 2011.12.29 兼容 批转旧版 操作
|
||
pDataBase = database();
|
||
}
|
||
}
|
||
if (pDataBase)
|
||
{
|
||
pDataBase->getAcDbObjectId(id,true,hdl);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
es = pFiler->readSoftPointerId(&id);
|
||
}
|
||
|
||
m_arIds.append(id);
|
||
}
|
||
}
|
||
|
||
|
||
/*
|
||
Adesk::UInt16 nCount;
|
||
AcDbSoftPointerId id;
|
||
AcDbHandle hdl;
|
||
pFiler->readItem(&nCount);
|
||
m_arIds.setLogicalLength(0);
|
||
AcDbDatabase* pDataBase = NULL;
|
||
for (int i =0; i < nCount; ++i)
|
||
{
|
||
//存放ID
|
||
if (version == 3)
|
||
{
|
||
//版本3存放的为句柄
|
||
pFiler->readAcDbHandle(&hdl);
|
||
pDataBase = acdbCurDwg();
|
||
if (GetCurDocData())
|
||
{
|
||
XString &sCmd = GetCurDocData()->m_sCurCommand;
|
||
if (_tcsicmp(sCmd,_T("T83_TBatSave")) == 0)
|
||
{
|
||
//bsl 2011.12.29 兼容 批转旧版 操作
|
||
pDataBase = database();
|
||
}
|
||
}
|
||
if (pDataBase)
|
||
{
|
||
pDataBase->getAcDbObjectId(id,true,hdl);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
es = pFiler->readSoftPointerId(&id);
|
||
}
|
||
|
||
m_arIds.append(id);
|
||
}
|
||
*/
|
||
TCHAR *pBuffer=NULL;
|
||
es = pFiler->readString(&pBuffer);
|
||
assert(pBuffer);
|
||
m_sLableContent = pBuffer;
|
||
acutDelString(pBuffer);
|
||
|
||
// if (version >= 5) // 2013/1/31 wzh alter 9.0 新增
|
||
// {
|
||
// TCHAR* pBuf = NULL;
|
||
// es = pFiler->readString(&pBuf);
|
||
// assert(pBuf);
|
||
// m_sSpare = pBuf;
|
||
// m_sLableFds = m_sSpare;
|
||
// acutDelString(pBuf);
|
||
// }
|
||
|
||
|
||
if (version >= 3) //大于等于版本3
|
||
{
|
||
pFiler->readItem(&m_nValidBit);
|
||
pFiler->readItem(&m_nSpare);
|
||
pFiler->readItem(&m_dSpare);
|
||
TCHAR *pBuffer = NULL;
|
||
pFiler->readString(&pBuffer);
|
||
m_sSpare = pBuffer;
|
||
m_sLableFds = m_sSpare;
|
||
acutDelString(pBuffer);
|
||
}
|
||
|
||
if (version >= 5)
|
||
//if (version >= VERSION_TDBEEQUIPMENT)
|
||
{
|
||
//行列
|
||
m_arRowWidth.setLogicalLength(0);
|
||
Adesk::UInt16 nCount;
|
||
pFiler->readItem(&nCount);
|
||
double dTemp;
|
||
for (int i = 0;i < nCount;++i)
|
||
{
|
||
pFiler->readItem(&dTemp);
|
||
m_arRowWidth.append(dTemp);
|
||
}
|
||
|
||
//电缆高度
|
||
es = pFiler->readString(&pBuffer);
|
||
assert(pBuffer);
|
||
m_sSign = pBuffer;
|
||
acutDelString(pBuffer);
|
||
}
|
||
|
||
//读取引线扩展数据
|
||
ReadDownLeadData();
|
||
//读取是否标注穿管
|
||
ReadIsDimPipeFlow();
|
||
// SetGlobalContext(KEY_PIPE_FLOW_D,m_bPipeFlow);
|
||
ReadIsMulitCableLayDim();
|
||
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDbCableDim::subDeepClone(AcDbObject* pOwnerObject,
|
||
AcDbObject*& pClonedObject,
|
||
AcDbIdMapping& idMap,
|
||
Adesk::Boolean isPrimary) const
|
||
{
|
||
assertReadEnabled();
|
||
|
||
Acad::ErrorStatus es = TDbEntity::subDeepClone(pOwnerObject, pClonedObject, idMap, isPrimary);
|
||
|
||
return es;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbCableDim::subWblockClone( AcRxObject* pOwnerObject,
|
||
AcDbObject*& pClonedObject,
|
||
AcDbIdMapping& idMap,
|
||
Adesk::Boolean isPrimary) const
|
||
{
|
||
assertReadEnabled();
|
||
|
||
Acad::ErrorStatus es = TDbEntity::subWblockClone(pOwnerObject, pClonedObject, idMap, isPrimary);
|
||
|
||
return es;
|
||
}
|
||
|
||
//modify:bsl 2012.3.14 支持多列显示电缆标注
|
||
Acad::ErrorStatus TDbCableDim::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
||
AcDbIntArray& osnapModes,
|
||
AcDbIntArray& geomIds) const
|
||
{
|
||
assertReadEnabled();
|
||
gripPoints.append(m_ptS);
|
||
gripPoints.append(m_ptTurn);
|
||
|
||
//获得线的长度
|
||
double dTextLen = m_dLineBaseLen * GetPScale();
|
||
|
||
if (m_nDimEntType == eCableLay)
|
||
{
|
||
//电缆标注
|
||
AcGeVector3d vtDir = m_vtDir;
|
||
if (vtDir.isZeroLength())
|
||
vtDir = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
|
||
double dRowHeight = m_nTextHeight*GetPScale()*(1 + 0.5)*m_dTextRowDis;
|
||
AcGePoint3d ptTemp;
|
||
double dWidth = 0.0;
|
||
for (int i = 0;i < m_arRowWidth.length();++i)
|
||
{
|
||
dWidth += m_arRowWidth[i];
|
||
ptTemp = m_ptTurn + vtDir*dWidth;
|
||
gripPoints.append(ptTemp);
|
||
}
|
||
|
||
gripPoints.append(GetSizePt());
|
||
}
|
||
else
|
||
{
|
||
AcGePoint3d ptE = m_ptTurn + m_vtDir*dTextLen;
|
||
gripPoints.append(ptE);
|
||
}
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbCableDim::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
|
||
{
|
||
assertReadEnabled();
|
||
stretchPoints.append(m_ptTurn);
|
||
return Acad::eOk;
|
||
}
|
||
|
||
//modify:bsl 2012.3.14 支持多列显示电缆标注
|
||
Acad::ErrorStatus TDbCableDim::subMoveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset)
|
||
{
|
||
assertWriteEnabled();
|
||
ReadIsMulitCableLayDim();
|
||
if (indices.length() == 1)
|
||
{
|
||
AcGeVector3d vtOffsetT = offset;
|
||
vtOffsetT.z = 0.0;
|
||
|
||
// add by hh 2012-08-21 0向量在计算角度、距离等时出现-1.#IND000000000000值
|
||
// 导致ExplodeOrDraw2d时发生CAD2004下发生崩溃
|
||
if(EQUAL_ZERO(vtOffsetT[0]) && EQUAL_ZERO(vtOffsetT[1]))
|
||
return Acad::eOk;
|
||
|
||
AcGeVector3d vtDir = m_vtDir;
|
||
if (vtDir.isZeroLength())
|
||
vtDir = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
|
||
if (indices[0] == 0)
|
||
{
|
||
m_ptS += vtOffsetT;
|
||
m_ptTurn += vtOffsetT;
|
||
}
|
||
else if (indices[0] == 1)
|
||
{
|
||
AcGeVector3d vtTemp = m_ptTurn - m_ptS;
|
||
double dAngle = vtDir.angleTo(vtTemp);
|
||
double dDistOld = m_ptTurn.distanceTo(m_ptS);
|
||
dDistOld *= cos(dAngle);
|
||
m_ptTurn += vtOffsetT;
|
||
double dDist = vtOffsetT.length();
|
||
dAngle = vtDir.angleTo(vtOffsetT);
|
||
dDist *= cos(dAngle);
|
||
if (dDist + dDistOld < 1e-3)
|
||
{
|
||
m_vtDir *= -1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
int nCol = indices[0];
|
||
nCol -= 2;
|
||
double dLastDist = m_dLineBaseLen * GetPScale();
|
||
if (nCol < m_arRowWidth.length())
|
||
{
|
||
//处理行列夹点
|
||
double dAngle = vtDir.angleTo(vtOffsetT);
|
||
double dDist = vtOffsetT.length();
|
||
dDist *= cos(dAngle);
|
||
|
||
m_arRowWidth[nCol] += dDist;
|
||
if (m_arRowWidth[nCol] - dLastDist < 1e-3)
|
||
{
|
||
m_arRowWidth[nCol] = dLastDist;
|
||
}
|
||
}
|
||
else if (m_arRowWidth.length() > 0 && nCol == m_arRowWidth.length())
|
||
{
|
||
//动态调整夹点
|
||
AcGeVector3d vtLableDir = m_vtDir;
|
||
vtLableDir.normalize();
|
||
AcGePoint3d ptGe1 = m_ptTurn;
|
||
AcGePoint3d ptGe2 = m_ptS;
|
||
if (ptGe1.y > ptGe2.y)
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
else
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
double dH = GetDimHeight();
|
||
double dAngle = vtLableDir.angleTo(vtOffsetT);
|
||
dH += vtOffsetT.length() * cos(dAngle);
|
||
|
||
if (dH < 1e-3)
|
||
{
|
||
dH = 0.0;
|
||
}
|
||
|
||
CalcGripPntForLay(dH);
|
||
}
|
||
else
|
||
{
|
||
m_vtDir.normalize();
|
||
AcGePoint3d pt = m_ptTurn + m_dLineBaseLen * GetPScale() * m_vtDir;
|
||
AcDbLine line(m_ptTurn,pt);
|
||
|
||
AcGePoint3d ptOnLine;
|
||
line.getClosestPointTo(pt+vtOffsetT,ptOnLine,Adesk::kTrue);
|
||
|
||
m_vtDir = ptOnLine - m_ptTurn;
|
||
m_vtDir.normalize();
|
||
|
||
m_dLineBaseLen = m_ptTurn.distanceTo(ptOnLine) / GetPScale();
|
||
}
|
||
}
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbCableDim::subMoveStretchPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset)
|
||
{
|
||
assertWriteEnabled();
|
||
return moveGripPointsAt(indices,offset);
|
||
}
|
||
|
||
Acad::ErrorStatus TDbCableDim::subTransformBy(const AcGeMatrix3d& xform)
|
||
{
|
||
assertWriteEnabled();
|
||
TDbEntity::subTransformBy(xform);
|
||
|
||
m_ptS.transformBy(xform);
|
||
m_ptTurn.transformBy(xform);
|
||
m_vtDir.transformBy(xform);
|
||
|
||
//读取引线扩展数据
|
||
ReadDownLeadData();
|
||
for (int i = 0; i < m_arPtLead.length(); ++i)
|
||
{
|
||
m_arPtLead[i].transformBy(xform);
|
||
}
|
||
WriteDownLeadData();
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbCableDim::ExplodeOrDraw2d(XExplodeDraw &dc) const
|
||
{
|
||
ExplodeOrDraw2dStart(dc);
|
||
|
||
if (m_nDimEntType == eCableLay)
|
||
{
|
||
//电缆标注
|
||
ExplodeOrDraw2dLineForLay(dc);
|
||
ExplodeOrDraw2dTextForLay(dc);
|
||
}
|
||
else
|
||
{
|
||
//桥架标注
|
||
ExplodeOrDraw2dLine(dc);
|
||
ExplodeOrDraw2dText(dc);
|
||
}
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
//创建标注线
|
||
void TDbCableDim::ExplodeOrDraw2dLine(XExplodeDraw &dc) const
|
||
{
|
||
AcDbPolyline pline;
|
||
double dTextDistP = m_dTextRowDis;
|
||
pline.reset(Adesk::kFalse,0);
|
||
AcGePoint3d ptS,ptT,ptE,ptTmpE;
|
||
int nCount = 0;
|
||
if (m_nCurDwgVer >= 5)
|
||
{
|
||
AcDbObjectIdArray arTemp;
|
||
ReadReactorID(arTemp);
|
||
nCount = arTemp.length();
|
||
if (nCount == 0)
|
||
{
|
||
return;
|
||
}
|
||
if (m_nDimEntType == eCableLay)
|
||
{
|
||
CStringArray arNames;
|
||
//ReadXData(arTemp[0],CABLELAY_XDATA_NAME,arNames);
|
||
ReadXData(arTemp[0],GetName(m_bIsMulitCableLayDim),arNames);
|
||
nCount = arNames.GetSize();
|
||
}
|
||
}
|
||
else
|
||
nCount = m_arIds.length();
|
||
|
||
double dTextLen = m_dLineBaseLen * GetPScale(),dHeight = m_nTextHeight;
|
||
CString sText;
|
||
|
||
AcGeVector3d vtDir = m_vtDir;
|
||
if (vtDir.isZeroLength())
|
||
vtDir = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
|
||
// vtDir = Wcs2Ucs(vtDir);
|
||
vtDir.normalize();
|
||
|
||
ptS= m_ptS;
|
||
pline.addVertexAt(0,ptS.convert2d(AcGePlane::kXYPlane));
|
||
//是否需要扩展引线()
|
||
int nExtendCount = 0;
|
||
for (int i = 0; i < m_arPtLead.length(); ++i)
|
||
{
|
||
nExtendCount++;
|
||
pline.addVertexAt(nExtendCount,m_arPtLead[i].convert2d(AcGePlane::kXYPlane));
|
||
}
|
||
|
||
ptT = m_ptTurn;
|
||
pline.addVertexAt(nExtendCount + 1,ptT.convert2d(AcGePlane::kXYPlane));
|
||
|
||
|
||
ptE = ptT + vtDir*dTextLen;
|
||
pline.addVertexAt(nExtendCount + 2,ptE.convert2d(AcGePlane::kXYPlane));
|
||
|
||
ptTmpE = ptE;
|
||
int nStyle = m_nLableStyle;
|
||
if (nStyle == eLableStyle1)
|
||
nCount++;
|
||
|
||
//构建方格
|
||
AcGeVector3d vtLableDir = m_vtDir;
|
||
vtLableDir.normalize();
|
||
AcGePoint3d ptGe1 = m_ptTurn;
|
||
AcGePoint3d ptGe2 = m_ptS;
|
||
if (ptGe1.y > ptGe2.y)
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
else
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
|
||
|
||
// vtLableDir = Ucs2Wcs(vtLableDir);
|
||
//构成PLINE线
|
||
for (i = 1; i < nCount; ++i)
|
||
{
|
||
ptS = ptT;
|
||
pline.addVertexAt(nExtendCount + 3 * i,ptS.convert2d(AcGePlane::kXYPlane));
|
||
ptT = ptS;
|
||
ptT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
if (nStyle == eLableStyle3)
|
||
ptT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
|
||
pline.addVertexAt(nExtendCount + 1 + 3 * i,ptT.convert2d(AcGePlane::kXYPlane));
|
||
ptE = ptT + vtDir*dTextLen;
|
||
pline.addVertexAt(nExtendCount + 2 + 3 * i,ptE.convert2d(AcGePlane::kXYPlane));
|
||
}
|
||
|
||
if (nStyle == eLableStyle1)
|
||
{
|
||
pline.addVertexAt(nExtendCount + 3 * nCount,ptTmpE.convert2d(AcGePlane::kXYPlane));
|
||
}
|
||
|
||
|
||
pline.setColorIndex(m_nColorLine);
|
||
//add lsd 2013-8-28 将画好的表格挪到对应的高度
|
||
AcGeMatrix3d xform;
|
||
AcGeVector3d vec(0, 0, ptS.z);
|
||
xform.setToTranslation(vec);
|
||
pline.transformBy(xform);
|
||
//end
|
||
dc.Polyline(pline);
|
||
}
|
||
|
||
//bsl 2012.3.14 电缆标注线
|
||
void TDbCableDim::ExplodeOrDraw2dLineForLay(XExplodeDraw &dc) const
|
||
{
|
||
double dTextDistP = m_dTextRowDis,dHeight = m_nTextHeight;
|
||
|
||
double dRowHeight = dHeight*GetPScale()*(1 + 0.5)*dTextDistP;
|
||
|
||
AcDbObjectIdArray arTemp;
|
||
ReadReactorID(arTemp);
|
||
int nCount = arTemp.length();
|
||
if (nCount == 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
CStringArray arNames;
|
||
//modify liaoy 2016-8-12
|
||
//ReadXData(arTemp[0],CABLELAY_XDATA_NAME,arNames);
|
||
ReadXData(arTemp[0],GetName(m_bIsMulitCableLayDim),arNames);
|
||
//modify end
|
||
nCount = arNames.GetSize();
|
||
|
||
int nCol = m_arRowWidth.length();
|
||
if (nCol == 0)
|
||
{
|
||
//列数
|
||
return;
|
||
}
|
||
|
||
//行数
|
||
int nRow = (int)ceil((double)nCount / (double)nCol);
|
||
|
||
//横向量
|
||
AcGeVector3d vtDir = m_vtDir;
|
||
if (vtDir.isZeroLength())
|
||
vtDir = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
|
||
//纵向量
|
||
BOOL bUp = TRUE;
|
||
AcGeVector3d vtLableDir = m_vtDir;
|
||
vtLableDir.normalize();
|
||
AcGePoint3d ptGe1 = m_ptTurn;
|
||
AcGePoint3d ptGe2 = m_ptS;
|
||
if (ptGe1.y > ptGe2.y)
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
bUp = TRUE;
|
||
}
|
||
else
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
bUp = FALSE;
|
||
}
|
||
|
||
AcDbPolyline pline;
|
||
pline.reset(Adesk::kFalse,0);
|
||
AcGePoint3d ptS,ptT,ptE,ptTmpE;
|
||
|
||
//折线和引线
|
||
ptS= m_ptS;
|
||
pline.addVertexAt(0,ptS.convert2d(AcGePlane::kXYPlane));
|
||
//是否需要扩展引线()
|
||
int nExtendCount = 0;
|
||
for (int i = 0; i < m_arPtLead.length(); ++i)
|
||
{
|
||
nExtendCount++;
|
||
pline.addVertexAt(nExtendCount,m_arPtLead[i].convert2d(AcGePlane::kXYPlane));
|
||
}
|
||
|
||
//外框
|
||
double dWidth = 0.0;
|
||
for (i = 0;i < m_arRowWidth.length();++i)
|
||
{
|
||
dWidth += m_arRowWidth[i];
|
||
}
|
||
|
||
int nRowNum = nRow;
|
||
if (!m_sSign.IsEmpty())
|
||
{
|
||
//增加表头
|
||
++nRowNum;
|
||
}
|
||
AcGePoint3d ptLB,ptLT,ptRB,ptRT;
|
||
ptLB = m_ptTurn;
|
||
ptRB = m_ptTurn + vtDir * dWidth;
|
||
ptLT = ptLB + vtLableDir * nRowNum * dRowHeight;
|
||
ptRT = ptRB + vtLableDir * nRowNum * dRowHeight;
|
||
|
||
pline.addVertexAt(nExtendCount + 1,ptLB.convert2d(AcGePlane::kXYPlane));
|
||
pline.addVertexAt(nExtendCount + 2,ptRB.convert2d(AcGePlane::kXYPlane));
|
||
pline.addVertexAt(nExtendCount + 3,ptRT.convert2d(AcGePlane::kXYPlane));
|
||
pline.addVertexAt(nExtendCount + 4,ptLT.convert2d(AcGePlane::kXYPlane));
|
||
pline.addVertexAt(nExtendCount + 5,ptLB.convert2d(AcGePlane::kXYPlane));
|
||
|
||
pline.setColorIndex(m_nColorLine);
|
||
|
||
dc.Polyline(pline);
|
||
|
||
//行线
|
||
AcGePoint3d ptRowL,ptRowR;
|
||
for (i = 1;i < nRowNum;++i)
|
||
{
|
||
AcDbPolyline pRowLine;
|
||
ptRowL = ptLB + vtLableDir * i * dRowHeight;
|
||
ptRowR = ptRB + vtLableDir * i * dRowHeight;
|
||
pRowLine.addVertexAt(0,ptRowL.convert2d(AcGePlane::kXYPlane));
|
||
pRowLine.addVertexAt(1,ptRowR.convert2d(AcGePlane::kXYPlane));
|
||
pRowLine.setColorIndex(m_nColorLine);
|
||
dc.Polyline(pRowLine);
|
||
}
|
||
|
||
//列线
|
||
dWidth = 0.0;
|
||
int nStaRow = 0;
|
||
if (!m_sSign.IsEmpty() && !bUp)
|
||
{
|
||
nStaRow = 1;
|
||
}
|
||
for (i = 0;i < nCol - 1;++i)
|
||
{
|
||
//不画最后一列,和外框重合
|
||
dWidth += m_arRowWidth[i];
|
||
AcDbPolyline pColLine;
|
||
ptT = m_ptTurn + vtDir * dWidth + vtLableDir * nStaRow * dRowHeight;
|
||
pColLine.addVertexAt(0,ptT.convert2d(AcGePlane::kXYPlane));
|
||
ptT += vtLableDir * nRow * dRowHeight;
|
||
pColLine.addVertexAt(1,ptT.convert2d(AcGePlane::kXYPlane));
|
||
dc.Polyline(pColLine);
|
||
}
|
||
}
|
||
|
||
//创建起点
|
||
void TDbCableDim::ExplodeOrDraw2dStart(XExplodeDraw &dc) const
|
||
{
|
||
if (m_nStartStyle == 1)
|
||
{
|
||
AcGeVector3d vtDir = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
AcGePoint3d ptT1 = Wcs2Ucs(m_ptTurn);
|
||
AcGePoint3d ptT2 = Wcs2Ucs(m_ptS);
|
||
if ((ptT1.x >= ptT2.x && ptT1.y >= ptT2.y) ||
|
||
(ptT1.x <= ptT2.x && ptT1.y <= ptT2.y) )
|
||
{
|
||
vtDir.rotateBy(-PI/4,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
else
|
||
{
|
||
vtDir.rotateBy(PI/4,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
|
||
vtDir.normalize();
|
||
|
||
AcGePoint3d ptS,ptE;
|
||
//ptS = m_ptS + vtDir * m_dStaLineLen / 2 * GetPScale();
|
||
//ptE = m_ptS - vtDir * m_dStaLineLen / 2 * GetPScale();
|
||
//axc modify 2014-07-31 T20 电缆标注需要根据设置的符号大小进行更改起始线的长度
|
||
double dStartLineLen = GetStartLineLen();
|
||
ptS = m_ptS + vtDir * dStartLineLen / 2 * GetPScale();
|
||
ptE = m_ptS - vtDir * dStartLineLen / 2 * GetPScale();
|
||
XLine line;
|
||
line.SetPoints(ptS,ptE);
|
||
|
||
dc.DrawLine(line);
|
||
}
|
||
else if (m_nStartStyle == 0)
|
||
{
|
||
AcDbPolyline pline;
|
||
AcGePoint3d ptS,ptE,ptTmp;
|
||
ptTmp = m_ptS;
|
||
AcGeVector3d vtX = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
AcGeVector3d vtY = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
ptS = m_ptS + vtX*GetPScale()*0.2;
|
||
ptE = m_ptS - vtY*GetPScale()*0.2;
|
||
double dBulge = tan(0.25 * PI);
|
||
pline.addVertexAt(0,ptS.convert2d(AcGePlane::kXYPlane),dBulge);
|
||
pline.addVertexAt(1,ptE.convert2d(AcGePlane::kXYPlane),dBulge);
|
||
pline.setClosed(Adesk::kTrue);
|
||
pline.setConstantWidth(1*GetPScale());
|
||
pline.setColorIndex(m_nColorLine);
|
||
|
||
//add lsd 2013-8-28 将画好的起点挪到对应的高度
|
||
AcGeMatrix3d xform;
|
||
AcGeVector3d vec(0, 0, ptS.z);
|
||
xform.setToTranslation(vec);
|
||
pline.transformBy(xform);
|
||
//end
|
||
|
||
dc.Polyline(pline);
|
||
}
|
||
}
|
||
|
||
//创建标注文字
|
||
void TDbCableDim::ExplodeOrDraw2dText(XExplodeDraw &dc) const
|
||
{
|
||
double dTextDistP = m_dTextRowDis;
|
||
AcDbText *pText = NULL;
|
||
CString sText;
|
||
AcGePoint3d ptTextT = m_ptTurn;
|
||
AcGeVector3d vtDir = m_vtDir;
|
||
if (vtDir.isZeroLength())
|
||
vtDir = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
vtDir.normalize();
|
||
AcDbObjectId idStyle = m_idTextStyle;
|
||
|
||
int nType = m_nLableStyle;
|
||
double dTextLen = m_dLineBaseLen * GetPScale(),dHeight = m_nTextHeight;
|
||
|
||
if (vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) > PI/2)
|
||
{
|
||
ptTextT += (dTextLen - (dHeight / 2)*GetPScale())*vtDir;
|
||
}
|
||
else
|
||
{
|
||
ptTextT += vtDir*(dHeight / 2)*GetPScale();
|
||
}
|
||
|
||
AcGeVector3d vtLableDir = m_vtDir;
|
||
vtLableDir.normalize();
|
||
AcGePoint3d ptGe1 = m_ptTurn;
|
||
AcGePoint3d ptGe2 = m_ptS;
|
||
BOOL bChangeType3 = FALSE;
|
||
//绘制方格
|
||
if (ptGe1.y > ptGe2.y)
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
|
||
ptTextT.y += dHeight*GetPScale()*0.25;
|
||
}
|
||
else
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
|
||
ptTextT.y += dHeight*GetPScale()*0.25;
|
||
if (nType != eLableStyle2)
|
||
{
|
||
if (nType == eLableStyle1)
|
||
ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
else
|
||
ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
}
|
||
|
||
if (nType == eLableStyle3)
|
||
bChangeType3 = TRUE;
|
||
}
|
||
|
||
if (nType == eLableStyle1)
|
||
ptTextT.y += dHeight*GetPScale()*((1 + 0.5)*dTextDistP - 1) / 2 - dHeight*GetPScale()*0.25;
|
||
|
||
double dRotation = 0.0;
|
||
AcGeVector3d vtDirX = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
AcGeVector3d vtVerT = TSysCoordinateTool::GetCurrentViewWCSKYAxis();
|
||
if (vtDir.angleTo(vtVerT) < PI/2)
|
||
dRotation = vtDir.angleTo(vtDirX);
|
||
else
|
||
dRotation = 2*PI - vtDir.angleTo(vtDirX);
|
||
if (vtDir.angleTo(vtDirX) > PI/2)
|
||
dRotation -= PI;
|
||
|
||
int nIdIndex = 0;
|
||
AcDbObjectId idBefore;
|
||
idBefore.setNull();
|
||
//test
|
||
AcDbObjectIdArray arTemp;
|
||
CStringArray arTexts,arNames;
|
||
if (m_nCurDwgVer >= 5) // 2013/2/8 alter by wzh
|
||
{
|
||
ReadReactorID(arTemp);
|
||
if (arTemp.length() == 0)
|
||
{
|
||
return;
|
||
}
|
||
//for (int i = 0; i < m_arIds.length(); ++i)
|
||
if (m_nDimEntType == eCableTray)
|
||
{
|
||
//桥架标注
|
||
for (int i = 0; i < arTemp.length(); ++i)
|
||
{
|
||
GetTextString(arTemp[i],sText,0);
|
||
if (!sText.IsEmpty())
|
||
{
|
||
arTexts.Add(sText);
|
||
}
|
||
}
|
||
}
|
||
else if (m_nDimEntType == eCableLay)
|
||
{
|
||
//电缆标注
|
||
//modify liaoy 2016-8-12
|
||
//ReadXData(arTemp[0],CABLELAY_XDATA_NAME,arNames);
|
||
ReadXData(arTemp[0],GetName(m_bIsMulitCableLayDim),arNames);
|
||
//modify end
|
||
for (int j = 0;j < arNames.GetSize();++j)
|
||
{
|
||
GetTextString(arTemp[0],sText,j);
|
||
if (!sText.IsEmpty())
|
||
{
|
||
arTexts.Add(sText);
|
||
}
|
||
}
|
||
}
|
||
|
||
for(int i = 0;i < arTexts.GetSize();++i)
|
||
{
|
||
sText = arTexts[i];
|
||
|
||
dTextLen = GetTextLen(sText);
|
||
|
||
TDbText text;
|
||
text.setPropertiesFrom(this);
|
||
text.SetText((const TCHAR*)sText);
|
||
text.SetStyleId(idStyle);
|
||
text.SetLocation(ptTextT);
|
||
text.SetHeight(dHeight);
|
||
text.SetRotation(Ucs2Wcs(dRotation));
|
||
// text.setLayer(this->GetTextLayerId());
|
||
// text.SetAlignment(XExplodeDraw::kBottomRight);
|
||
if (nType != eLableStyle3)
|
||
{
|
||
text.setColorIndex(m_nColorText);
|
||
TPushProperty vProp1(&text, dc);
|
||
if(dc.IsFullExplode())
|
||
text.ExplodeOrDraw2d(dc);
|
||
else
|
||
dc.DrawEntity(text);
|
||
}
|
||
|
||
ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
|
||
//样式三则存在两行文字
|
||
if (nType == eLableStyle3)
|
||
{
|
||
CString sText1,sText2;
|
||
AcGePoint3d ptText1,ptText2;
|
||
int nFind = -1;
|
||
if (m_nCurDwgVer >= 5) // 2013/2/4 alter by wzh 桥架标注样式三调整
|
||
{
|
||
CString sFds = m_sLableFds;
|
||
int nFdsLen = sFds.GetLength();
|
||
char* pch = NULL;
|
||
pch= (char*)sFds.GetBuffer(1);
|
||
//pch= (char*)sFds.GetBuffer(m_sLableFds.GetLength());
|
||
nFind = sText.ReverseFind(*pch);
|
||
|
||
}
|
||
else
|
||
nFind = sText.ReverseFind(_T(','));
|
||
//int nFind = sText.ReverseFind(_T(',')); // 2013/2/4 comment by wzh
|
||
if (nFind != -1)
|
||
{
|
||
ptText2 = ptTextT;
|
||
ptText1 = ptTextT;
|
||
|
||
// 2013/2/4 alter by wzh
|
||
int nFdsLen = m_sLableFds.GetLength();
|
||
// sText1 = sText.Left(nFind - 1);
|
||
// sText2 = sText.Mid(nFind + nFdsLen - 1);
|
||
|
||
sText1 = sText.Left(nFind); // 2013/2/4 comment by wzh
|
||
sText2 = sText.Mid(nFind + 1);
|
||
text.SetText(sText1);
|
||
//判断是否需要调整位置
|
||
AcGeVector3d vtXT = m_vtDir;
|
||
//如果标注方向为向左
|
||
if (vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) > PI/2)
|
||
{
|
||
vtXT *= -1;
|
||
}
|
||
// vtXT = Wcs2Ucs(vtXT);
|
||
if (bChangeType3)
|
||
{
|
||
ptText2 -= dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
ptText1 = ptText2 - dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
ptText2 += vtXT*(GetTextLen(sText1)/2 - GetTextLen(sText2)/2);
|
||
}
|
||
else
|
||
{
|
||
ptText1 -= dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
ptText2 = ptText1 - dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
ptText2 += vtXT*(GetTextLen(sText1)/2 - GetTextLen(sText2)/2);
|
||
}
|
||
|
||
text.SetLocation(ptText1);
|
||
text.SetRotation(Ucs2Wcs(dRotation));
|
||
text.setColorIndex(m_nColorText);
|
||
TPushProperty vProp1(&text, dc);
|
||
if(dc.IsFullExplode())
|
||
text.ExplodeOrDraw2d(dc);
|
||
else
|
||
dc.DrawEntity(text);
|
||
|
||
TDbText text2;
|
||
text2.setPropertiesFrom(this);
|
||
text2.SetText((const TCHAR*)sText2);
|
||
text2.SetStyleId(idStyle);
|
||
text2.SetLocation(ptText2);
|
||
text2.SetHeight(dHeight);
|
||
text2.SetRotation(Ucs2Wcs(dRotation));
|
||
// text2.setLayer(this->GetTextLayerId());
|
||
text2.setColorIndex(m_nColorText);
|
||
TPushProperty vProp2(&text2, dc);
|
||
if(dc.IsFullExplode())
|
||
text2.ExplodeOrDraw2d(dc);
|
||
else
|
||
dc.DrawEntity(text2);
|
||
|
||
ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
for (int i = 0; i < m_arIds.length(); ++i)
|
||
{
|
||
if (!idBefore.isNull() && idBefore == m_arIds[i])
|
||
nIdIndex++;
|
||
else
|
||
nIdIndex = 0;
|
||
GetTextString(m_arIds[i],sText,nIdIndex);
|
||
|
||
idBefore = m_arIds[i];
|
||
dTextLen = GetTextLen(sText);
|
||
|
||
TDbText text;
|
||
text.setPropertiesFrom(this);
|
||
text.SetText((const TCHAR*)sText);
|
||
text.SetStyleId(idStyle);
|
||
text.SetLocation(ptTextT);
|
||
text.SetHeight(dHeight);
|
||
text.SetRotation(Ucs2Wcs(dRotation));
|
||
// text.setLayer(this->GetTextLayerId());
|
||
// text.SetAlignment(XExplodeDraw::kBottomRight);
|
||
if (nType != eLableStyle3)
|
||
{
|
||
text.setColorIndex(m_nColorText);
|
||
TPushProperty vProp1(&text, dc);
|
||
if(dc.IsFullExplode())
|
||
text.ExplodeOrDraw2d(dc);
|
||
else
|
||
dc.DrawEntity(text);
|
||
}
|
||
|
||
ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
|
||
//样式三则存在两行文字
|
||
if (nType == eLableStyle3)
|
||
{
|
||
CString sText1,sText2;
|
||
AcGePoint3d ptText1,ptText2;
|
||
int nFind = sText.ReverseFind(_T(','));
|
||
if (nFind != -1)
|
||
{
|
||
ptText2 = ptTextT;
|
||
ptText1 = ptTextT;
|
||
|
||
sText1 = sText.Left(nFind);
|
||
sText2 = sText.Mid(nFind + 1);
|
||
text.SetText(sText1);
|
||
//判断是否需要调整位置
|
||
AcGeVector3d vtXT = m_vtDir;
|
||
//如果标注方向为向左
|
||
if (vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) > PI/2)
|
||
{
|
||
vtXT *= -1;
|
||
}
|
||
// vtXT = Wcs2Ucs(vtXT);
|
||
if (bChangeType3)
|
||
{
|
||
ptText2 -= dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
ptText1 = ptText2 - dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
ptText2 += vtXT*(GetTextLen(sText1)/2 - GetTextLen(sText2)/2);
|
||
}
|
||
else
|
||
{
|
||
ptText1 -= dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
ptText2 = ptText1 - dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
ptText2 += vtXT*(GetTextLen(sText1)/2 - GetTextLen(sText2)/2);
|
||
}
|
||
|
||
text.SetLocation(ptText1);
|
||
text.SetRotation(Ucs2Wcs(dRotation));
|
||
text.setColorIndex(m_nColorText);
|
||
TPushProperty vProp1(&text, dc);
|
||
if(dc.IsFullExplode())
|
||
text.ExplodeOrDraw2d(dc);
|
||
else
|
||
dc.DrawEntity(text);
|
||
|
||
TDbText text2;
|
||
text2.setPropertiesFrom(this);
|
||
text2.SetText((const TCHAR*)sText2);
|
||
text2.SetStyleId(idStyle);
|
||
text2.SetLocation(ptText2);
|
||
text2.SetHeight(dHeight);
|
||
text2.SetRotation(Ucs2Wcs(dRotation));
|
||
// text2.setLayer(this->GetTextLayerId());
|
||
text2.setColorIndex(m_nColorText);
|
||
TPushProperty vProp2(&text2, dc);
|
||
if(dc.IsFullExplode())
|
||
text2.ExplodeOrDraw2d(dc);
|
||
else
|
||
dc.DrawEntity(text2);
|
||
|
||
ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
// for (int i = 0; i < arTemp.length(); ++i)
|
||
// {
|
||
// if (!idBefore.isNull() && idBefore == arTemp[i])
|
||
// nIdIndex++;
|
||
// else
|
||
// nIdIndex = 0;
|
||
// GetTextString(arTemp[i],sText,nIdIndex);
|
||
//
|
||
// idBefore = arTemp[i];
|
||
|
||
// 2013/2/8 comment by wzh
|
||
// for(int i = 0;i < arTexts.GetSize();++i)
|
||
// {
|
||
// sText = arTexts[i];
|
||
//
|
||
// dTextLen = GetTextLen(sText);
|
||
//
|
||
// TDbText text;
|
||
// text.setPropertiesFrom(this);
|
||
// text.SetText((const TCHAR*)sText);
|
||
// text.SetStyleId(idStyle);
|
||
// text.SetLocation(ptTextT);
|
||
// text.SetHeight(dHeight);
|
||
// text.SetRotation(Ucs2Wcs(dRotation));
|
||
// // text.setLayer(this->GetTextLayerId());
|
||
// // text.SetAlignment(XExplodeDraw::kBottomRight);
|
||
//
|
||
// if (nType != eLableStyle3)
|
||
// {
|
||
// text.setColorIndex(m_nColorText);
|
||
// TPushProperty vProp1(&text, dc);
|
||
// if(dc.IsFullExplode())
|
||
// text.ExplodeOrDraw2d(dc);
|
||
// else
|
||
// dc.DrawEntity(text);
|
||
// }
|
||
//
|
||
// ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
//
|
||
// //样式三则存在两行文字
|
||
// if (nType == eLableStyle3)
|
||
// {
|
||
// CString sText1,sText2;
|
||
// AcGePoint3d ptText1,ptText2;
|
||
// int nFind = -1;
|
||
// if (VERSION_TDBEEQUIPMENT > 4) // 2013/2/4 alter by wzh 桥架标注样式三调整
|
||
// {
|
||
// CString sFds = m_sLableFds;
|
||
// int nFdsLen = sFds.GetLength();
|
||
// char* pch = NULL;
|
||
// pch= (char*)sFds.GetBuffer(m_sLableFds.GetLength());
|
||
// nFind = sText.ReverseFind(*pch);
|
||
//
|
||
// }
|
||
// else
|
||
// nFind = sText.ReverseFind(_T(','));
|
||
// //int nFind = sText.ReverseFind(_T(',')); // 2013/2/4 comment by wzh
|
||
// if (nFind != -1)
|
||
// {
|
||
// ptText2 = ptTextT;
|
||
// ptText1 = ptTextT;
|
||
//
|
||
// // 2013/2/4 alter by wzh
|
||
// int nFdsLen = m_sLableFds.GetLength();
|
||
// sText1 = sText.Left(nFind - 1);
|
||
// sText2 = sText.Mid(nFind + nFdsLen - 1);
|
||
//
|
||
// // sText1 = sText.Left(nFind); // 2013/2/4 comment by wzh
|
||
// // sText2 = sText.Mid(nFind + 1);
|
||
// text.SetText(sText1);
|
||
// //判断是否需要调整位置
|
||
// AcGeVector3d vtXT = m_vtDir;
|
||
// //如果标注方向为向左
|
||
// if (vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) > PI/2)
|
||
// {
|
||
// vtXT *= -1;
|
||
// }
|
||
// // vtXT = Wcs2Ucs(vtXT);
|
||
// if (bChangeType3)
|
||
// {
|
||
// ptText2 -= dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
// ptText1 = ptText2 - dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
// ptText2 += vtXT*(GetTextLen(sText1)/2 - GetTextLen(sText2)/2);
|
||
// }
|
||
// else
|
||
// {
|
||
// ptText1 -= dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
// ptText2 = ptText1 - dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
// ptText2 += vtXT*(GetTextLen(sText1)/2 - GetTextLen(sText2)/2);
|
||
// }
|
||
//
|
||
// text.SetLocation(ptText1);
|
||
// text.SetRotation(Ucs2Wcs(dRotation));
|
||
// text.setColorIndex(m_nColorText);
|
||
// TPushProperty vProp1(&text, dc);
|
||
// if(dc.IsFullExplode())
|
||
// text.ExplodeOrDraw2d(dc);
|
||
// else
|
||
// dc.DrawEntity(text);
|
||
//
|
||
// TDbText text2;
|
||
// text2.setPropertiesFrom(this);
|
||
// text2.SetText((const TCHAR*)sText2);
|
||
// text2.SetStyleId(idStyle);
|
||
// text2.SetLocation(ptText2);
|
||
// text2.SetHeight(dHeight);
|
||
// text2.SetRotation(Ucs2Wcs(dRotation));
|
||
// // text2.setLayer(this->GetTextLayerId());
|
||
// text2.setColorIndex(m_nColorText);
|
||
// TPushProperty vProp2(&text2, dc);
|
||
// if(dc.IsFullExplode())
|
||
// text2.ExplodeOrDraw2d(dc);
|
||
// else
|
||
// dc.DrawEntity(text2);
|
||
//
|
||
// ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
// }
|
||
// }
|
||
// }
|
||
|
||
}
|
||
|
||
//bsl 2012.3.14 电缆标注文字
|
||
void TDbCableDim::ExplodeOrDraw2dTextForLay(XExplodeDraw &dc) const
|
||
{
|
||
double dTextDistP = m_dTextRowDis,dHeight = m_nTextHeight;
|
||
double dRowHeight = dHeight*GetPScale()*(1 + 0.5)*dTextDistP;
|
||
|
||
AcGePoint3d ptTextT,ptTemp;
|
||
|
||
AcGePoint3dArray arPts;
|
||
|
||
// AcDbObjectId idStyle = m_idTextStyle;
|
||
|
||
//横方向
|
||
AcGeVector3d vtDir = m_vtDir;
|
||
if (vtDir.isZeroLength())
|
||
vtDir = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
vtDir.normalize();
|
||
|
||
int nType = m_nLableStyle;
|
||
|
||
ptTextT += vtDir*(dHeight / 2)*GetPScale();
|
||
int nStaCol = 0;
|
||
if (vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) > PI/2)
|
||
{
|
||
double dWidth = 0.0;
|
||
for (int i = 0;i < m_arRowWidth.length();++i)
|
||
{
|
||
dWidth += m_arRowWidth[i];
|
||
ptTemp = m_ptTurn + vtDir * dWidth;
|
||
ptTemp -= vtDir*(dHeight / 2)*GetPScale();
|
||
arPts.append(ptTemp);
|
||
}
|
||
nStaCol = arPts.length() - 1;
|
||
}
|
||
else
|
||
{
|
||
double dWidth = 0.0;
|
||
for (int i = 0;i < m_arRowWidth.length();++i)
|
||
{
|
||
ptTemp = m_ptTurn + vtDir * dWidth;
|
||
ptTemp += vtDir*(dHeight / 2)*GetPScale();
|
||
arPts.append(ptTemp);
|
||
dWidth += m_arRowWidth[i];
|
||
}
|
||
}
|
||
|
||
//纵方向
|
||
AcGeVector3d vtLableDir = m_vtDir;
|
||
vtLableDir.normalize();
|
||
AcGePoint3d ptGe1 = m_ptTurn;
|
||
AcGePoint3d ptGe2 = m_ptS;
|
||
|
||
int nStatRow = 0;
|
||
if (ptGe1.y > ptGe2.y)
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
else
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
|
||
nStatRow = 1;
|
||
if (!m_sSign.IsEmpty())
|
||
{
|
||
nStatRow = 2;
|
||
}
|
||
}
|
||
|
||
if (nType == eLableStyle1)
|
||
ptTextT.y += dHeight*GetPScale()*((1 + 0.5)*dTextDistP - 1) / 2 - dHeight*GetPScale()*0.25;
|
||
|
||
double dRotation = 0.0;
|
||
AcGeVector3d vtDirX = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
AcGeVector3d vtVerT = TSysCoordinateTool::GetCurrentViewWCSKYAxis();
|
||
if (vtDir.angleTo(vtVerT) < PI/2)
|
||
dRotation = vtDir.angleTo(vtDirX);
|
||
else
|
||
dRotation = 2*PI - vtDir.angleTo(vtDirX);
|
||
if (vtDir.angleTo(vtDirX) > PI/2)
|
||
dRotation -= PI;
|
||
|
||
int nIdIndex = 0;
|
||
AcDbObjectId idBefore;
|
||
idBefore.setNull();
|
||
//test
|
||
AcDbObjectIdArray arTemp;
|
||
ReadReactorID(arTemp);
|
||
if (arTemp.length() == 0)
|
||
{
|
||
return;
|
||
}
|
||
CStringArray arTexts,arNames;
|
||
|
||
//电缆标注
|
||
CString sText;
|
||
//ReadXData(arTemp[0],CABLELAY_XDATA_NAME,arNames);
|
||
ReadXData(arTemp[0],GetName(m_bIsMulitCableLayDim),arNames);
|
||
//modify end
|
||
for (int j = 0;j < arNames.GetSize();++j)
|
||
{
|
||
GetTextString(arTemp[0],sText,j);
|
||
if (!sText.IsEmpty())
|
||
{
|
||
arTexts.Add(sText);
|
||
}
|
||
}
|
||
|
||
int nCol = m_arRowWidth.length();
|
||
if (nCol == 0)
|
||
{
|
||
//列数
|
||
return;
|
||
}
|
||
|
||
//行数
|
||
int nCount = arNames.GetSize();
|
||
int nRow = (int)ceil((double)nCount / (double)nCol);
|
||
|
||
int nCurCol = 0;
|
||
for(int i = 0;i < arTexts.GetSize();++i)
|
||
{
|
||
sText = arTexts[i];
|
||
|
||
nCurCol = i / nRow;
|
||
|
||
ptTextT = arPts[nCurCol];
|
||
|
||
ptTextT.y += dHeight*GetPScale()*0.25;
|
||
|
||
ptTextT += dRowHeight * vtLableDir * (i % nRow + nStatRow);
|
||
|
||
TDbText text;
|
||
text.setPropertiesFrom(this);
|
||
text.SetText((const TCHAR*)sText);
|
||
text.SetStyleId(m_idTextStyle);
|
||
text.SetLocation(ptTextT);
|
||
text.SetHeight(dHeight);
|
||
text.SetRotation(Ucs2Wcs(dRotation));
|
||
|
||
if (nType != eLableStyle3)
|
||
{
|
||
text.setColorIndex(m_nColorText);
|
||
TPushProperty vProp1(&text, dc);
|
||
if(dc.IsFullExplode())
|
||
text.ExplodeOrDraw2d(dc);
|
||
else
|
||
dc.DrawEntity(text);
|
||
}
|
||
}
|
||
|
||
if (!m_sSign.IsEmpty())
|
||
{
|
||
//加表头
|
||
ptTextT = arPts[nStaCol];
|
||
ptTextT.y += dHeight*GetPScale()*0.25;
|
||
|
||
if (nStatRow == 0)
|
||
ptTextT += dRowHeight * vtLableDir * nRow;
|
||
else
|
||
ptTextT += dRowHeight * vtLableDir;
|
||
|
||
TDbText text;
|
||
text.setPropertiesFrom(this);
|
||
text.SetText((const TCHAR*)m_sSign);
|
||
text.SetStyleId(m_idTextStyle);
|
||
text.SetLocation(ptTextT);
|
||
text.SetHeight(dHeight);
|
||
text.SetRotation(Ucs2Wcs(dRotation));
|
||
text.setColorIndex(m_nColorText);
|
||
TPushProperty vProp1(&text, dc);
|
||
if(dc.IsFullExplode())
|
||
text.ExplodeOrDraw2d(dc);
|
||
else
|
||
dc.DrawEntity(text);
|
||
}
|
||
}
|
||
//得到字长
|
||
double TDbCableDim::GetTextLen(LPCTSTR lpText) const
|
||
{
|
||
double dTextLen = 0.0;
|
||
|
||
if (lpText == NULL)
|
||
return dTextLen;
|
||
|
||
CString sText = lpText;
|
||
if (sText.IsEmpty())
|
||
return dTextLen;
|
||
double dHeight = m_nTextHeight;
|
||
AcDbObjectId idStyle = m_idTextStyle;
|
||
|
||
CString sStyleName = GetSymbolName(idStyle);
|
||
struct resbuf* pRb = acutBuildList(RTDXF0, _T("TEXT"),
|
||
1, lpText,
|
||
7, sStyleName,
|
||
40, dHeight,
|
||
41, GetPScale(),
|
||
0);
|
||
|
||
ads_point adsPt1, adsPt2;
|
||
int iRet = acedTextBox(pRb, adsPt1, adsPt2);
|
||
acutRelRb(pRb);
|
||
|
||
dTextLen = asPnt3d(adsPt1).distanceTo(asPnt3d(adsPt2));
|
||
// CString sText = lpText;
|
||
// dTextLen = sText.GetLength()*dHeight*GetPScale();
|
||
TDbText text;
|
||
text.setPropertiesFrom(this);
|
||
text.SetText((const TCHAR*)lpText);
|
||
AcDbObjectId id = m_idTextStyle;
|
||
text.SetStyleId(id);
|
||
text.SetLocation(m_ptTurn);
|
||
text.SetHeight(m_nTextHeight);
|
||
XPoint pt = text.GetExtents();
|
||
dTextLen = asPnt3d(adsPt1).distanceTo(pt) + dHeight*GetPScale();
|
||
return dTextLen;
|
||
}
|
||
|
||
//得到文字内容
|
||
void TDbCableDim::GetTextString(const AcDbObjectId &id,CString &sText,int nIndex) const
|
||
{
|
||
switch(m_nDimEntType)
|
||
{
|
||
case eCableTray:
|
||
GetCableTrayString(id,sText);
|
||
break;
|
||
case eCableLay:
|
||
GetCableLayString(id,sText,nIndex);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
//得到桥架文字内容
|
||
void TDbCableDim::GetCableTrayString(const AcDbObjectId &id,CString &sText) const
|
||
{
|
||
double dHeight = m_nTextHeight;
|
||
AcDbEntity *pEnt = NULL;
|
||
AcGePoint3d ptS,ptM,ptE;
|
||
double dB = 0.0,dH = 0.0,dElv = 0.0,dL = 0.0,dB1 = 0.0,dB2 = 0.0,dH1 = 0.0,dH2 = 0.0;
|
||
CString sType,sNumber,sClapData;
|
||
CString sSys;//系统分类 lsd 2013-8-26
|
||
int nRunTime = -1,nStyle = 0,nClap = 0;
|
||
double dElS = 0.0;
|
||
double dElE = 0.0;
|
||
|
||
BOOL bInClinePipe = FALSE;
|
||
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead) == Acad::eOk)
|
||
{
|
||
TDbPipeBase *pPipe = TDbPipeBase::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_TYPE,sType);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_START,ptS);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_END,ptE);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_B,dB);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_H,dH);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_RUNTIME,nRunTime);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_STYLE,nStyle);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_NO,sNumber);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_HAVE_CLAPBOARD,nClap);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_CLAPBOARD_DATA,sClapData);
|
||
pPipe->GetSpecialtyData()->GetAt(_T("Cabletray_Layer"), sSys);//lsd 2013-8-26 获取系统分类
|
||
dL = ptS.distanceTo(ptE) / 1000;
|
||
if (ptE.z > ptS.z)
|
||
dElv = ptE.z;
|
||
else
|
||
dElv = ptS.z;
|
||
dElv /= 1000;
|
||
|
||
dElS = ptS.z /= 1000;
|
||
dElE = ptE.z /= 1000;
|
||
if (fabs(ptE.z - ptS.z) > 1e-3)
|
||
bInClinePipe = TRUE;
|
||
}
|
||
TDbFittingBase *pFit = TDbFittingBase::cast(pEnt);
|
||
if (pFit != NULL)
|
||
{
|
||
pFit->GetSpecialtyData()->GetAt(KEY_TYPE,sType);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_MID,ptM);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_START,ptS);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_END,ptE);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_B,dB);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_H,dH);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_B1,dB1);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_H1,dH1);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_B2,dB2);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_H2,dH2);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_RUNTIME,nRunTime);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_STYLE,nStyle);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_HAVE_CLAPBOARD,nClap);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_CLAPBOARD_DATA,sClapData);
|
||
pFit->GetSpecialtyData()->GetAt(_T("Cabletray_Layer"), sSys);//lsd 2013-8-26 获取系统分类
|
||
if (nRunTime == TDb::eReduce || nRunTime == TDb::eOffset)
|
||
dElv = ptS.z / 1000;
|
||
else
|
||
dElv = ptM.z / 1000;
|
||
}
|
||
|
||
//解析得到需要的字符串
|
||
CStringArray arValues;
|
||
GetLableStrArray(m_sLableContent,arValues);
|
||
CString sTmp;
|
||
sText = _T("");
|
||
for (int j = 0; j < arValues.GetSize(); ++j)
|
||
{
|
||
if (arValues[j].CompareNoCase(LABLE_NAME) == 0)
|
||
{
|
||
sTmp = sNumber;
|
||
if (sNumber.IsEmpty())
|
||
continue;
|
||
}
|
||
else if (arValues[j].CompareNoCase(LABLE_MODAL) == 0)
|
||
{
|
||
sTmp = sType;
|
||
if (sType.IsEmpty())
|
||
continue;
|
||
}
|
||
else if (arValues[j].CompareNoCase(LABLE_ELV) == 0)
|
||
{
|
||
sTmp.Format(_T("H=%.*fm"),m_nValidBit,dElv);
|
||
if (bInClinePipe)
|
||
sTmp.Format(_T("H=%.*fm--%.*fm"),m_nValidBit,dElS,m_nValidBit,dElE);
|
||
}
|
||
else if (arValues[j].CompareNoCase(LABLE_LEN) == 0)
|
||
{
|
||
sTmp.Format(_T("L=%.*fm"),m_nValidBit,dL);
|
||
}
|
||
else if (arValues[j].CompareNoCase(LABLE_SPECS) == 0)
|
||
{
|
||
TCableTrayFittingTool tool(pEnt);
|
||
sTmp = tool.GetSpec(SPEC_CHAR);
|
||
/*mod end liaoy170609
|
||
//modify liaoy 2016-6-17 由GetCableTrayStringSpecs()代替
|
||
AcArray<double> arB;
|
||
AcArray<double> arH;
|
||
arB.append(dB);
|
||
arB.append(dB1);
|
||
arB.append(dB2);
|
||
arH.append(dH);
|
||
arH.append(dH1);
|
||
arH.append(dH2);
|
||
CString sClapData2;
|
||
if (pFit)
|
||
pFit->GetSpecialtyData()->GetAt(KEY_CLAPBOARD_DATA2,sClapData2);
|
||
sTmp = GetCableTrayStringSpecs(arB,arH,nClap,nRunTime,sClapData,sClapData2);
|
||
/*
|
||
sTmp.Format(_T("%.0f%s%.0f"),dB,SPEC_CHAR,dH);
|
||
if (nClap && !sClapData.IsEmpty() && nRunTime != TDb::eReduce)
|
||
{
|
||
CStringArray arTemp1,arTemp2;
|
||
CString sTemp = _T("(");
|
||
SplitValue(sClapData,KEY_CLP_MAIN_KEY,arTemp1);
|
||
for(int i = 0;i < arTemp1.GetSize();i++)
|
||
{
|
||
SplitValue(arTemp1[i],SPEC_CHAR,arTemp2);
|
||
for (int j = 0;j < arTemp2.GetSize();j++)
|
||
{
|
||
sTemp += arTemp2[0];
|
||
sTemp += _T("+");
|
||
break;
|
||
}
|
||
}
|
||
sTemp.TrimRight(_T("+"));
|
||
sTemp += _T(")");
|
||
sTmp.Format(_T("%s%s%g"),sTemp,SPEC_CHAR,dH);
|
||
}
|
||
if (nRunTime == TDb::eReduce)
|
||
{
|
||
|
||
sTmp.Format(_T("%.0f%s%.0f-%.0f%s%.0f"),dB1,SPEC_CHAR,dH1,dB2,SPEC_CHAR,dH2);
|
||
CString sClapData2 = _T("");
|
||
pFit->GetSpecialtyData()->GetAt(KEY_CLAPBOARD_DATA2,sClapData2);
|
||
CStringArray arTemp1,arTemp2;
|
||
CString sTmp1 = _T("(");
|
||
SplitValue(sClapData,KEY_CLP_MAIN_KEY,arTemp1);
|
||
for(int t = 0;t < arTemp1.GetSize();t++)
|
||
{
|
||
SplitValue(arTemp1[t],SPEC_CHAR,arTemp2);
|
||
for (int j = 0;j < arTemp2.GetSize();j++)
|
||
{
|
||
sTmp1 += arTemp2[0];
|
||
sTmp1 += _T("+");
|
||
break;
|
||
}
|
||
}
|
||
if (arTemp1.GetSize() != 0)
|
||
{
|
||
sTmp1.TrimRight(_T("+"));
|
||
sTmp1 += _T(")");
|
||
sTmp.Format(_T("%s%s%g"),sTmp1,SPEC_CHAR,dH1);
|
||
}
|
||
|
||
CString sTmp2 = _T("(");
|
||
SplitValue(sClapData2,KEY_CLP_MAIN_KEY,arTemp1);
|
||
for(int i = 0;i < arTemp1.GetSize();i++)
|
||
{
|
||
SplitValue(arTemp1[i],SPEC_CHAR,arTemp2);
|
||
for (int j = 0;j < arTemp2.GetSize();j++)
|
||
{
|
||
sTmp2 += arTemp2[0];
|
||
sTmp2 += _T("+");
|
||
break;
|
||
}
|
||
}
|
||
if (arTemp1.GetSize() != 0)
|
||
{
|
||
sTmp2.TrimRight(_T("+"));
|
||
sTmp2 += _T(")");
|
||
sTmp1.Format(_T("%s%s%g"),sTmp2,SPEC_CHAR,dH2);
|
||
|
||
sTmp += _T("-");
|
||
sTmp += sTmp1;
|
||
}
|
||
|
||
}
|
||
*/
|
||
//modify end
|
||
//modify end170609
|
||
}
|
||
//lsd add 2013.7.17 增加标注"类型"项
|
||
else if (arValues[j].CompareNoCase(LABLE_TYPE) == 0)
|
||
{
|
||
switch(nStyle)
|
||
{
|
||
case 0://槽式MR
|
||
sTmp = _T("MR");
|
||
break;
|
||
case 1://盘式CT
|
||
sTmp = _T("CT");
|
||
break;
|
||
case 2://梯式CL
|
||
sTmp = _T("CL");
|
||
break;
|
||
}
|
||
if (sTmp.IsEmpty())
|
||
continue;
|
||
}
|
||
//added by lsd 2013-8-26 系统分类关键字
|
||
else if(arValues[j].CompareNoCase(LABLE_SYS_TYPE) == 0)
|
||
{
|
||
//modify liaoy 2016-6-17 由GetCableTrayStringSysType()代替
|
||
sTmp = GetCableTrayStringSysType(sSys);
|
||
/*
|
||
if (sSys.CompareNoCase(LAY_CABLETRAY) == 0)
|
||
sTmp = m_sSysKeyForce;
|
||
else if (sSys.CompareNoCase(LAY_CABLETRAY_FIRE) == 0)
|
||
sTmp = m_sSysKeyFire;
|
||
else if (sSys.CompareNoCase(LAY_CABLETRAY_WEAK) == 0)
|
||
sTmp = m_sSysKeyWeak;
|
||
else if(sSys.CompareNoCase(LAY_CABLETRAY_OTHER) == 0)
|
||
sTmp = m_sSysKeyOther;
|
||
else if (sSys.CollateNoCase(LAY_CABLETRAY_LIGH) == 0)
|
||
sTmp = m_sSysKeyForce;
|
||
else if (sSys.CompareNoCase(LAY_CABLETRAY_SECU) == 0)
|
||
sTmp = m_sSysKeyWeak;
|
||
else if (sSys.CompareNoCase(LAY_CABLETRAY_RADIO) == 0)
|
||
sTmp = m_sSysKeyWeak;
|
||
else if (sSys.CompareNoCase(LAY_CABLETRAY_CATV) == 0)
|
||
sTmp = m_sSysKeyWeak;
|
||
else if (sSys.CompareNoCase(LAY_CABLETRAY_PDS) == 0)
|
||
sTmp = m_sSysKeyWeak;
|
||
*/
|
||
if(sTmp.IsEmpty())
|
||
continue;
|
||
//modify end
|
||
}
|
||
////////////////////////////////////////
|
||
//2012/6/14 桥架标注间隔符支持
|
||
if (j != arValues.GetSize() - 1)
|
||
{
|
||
if (m_nCurDwgVer >= 5) // wzh alter 2013/2/1
|
||
{
|
||
sTmp += m_sLableFds;
|
||
}
|
||
else
|
||
{
|
||
sTmp += _T(","); // 兼容9.0之前版本
|
||
}
|
||
}
|
||
|
||
//2012/6/14 注释
|
||
// if (j != arValues.GetSize() - 1)
|
||
// sTmp += _T(",");
|
||
|
||
sText += sTmp;
|
||
}
|
||
|
||
pEnt->close();
|
||
pEnt = NULL;
|
||
}
|
||
}
|
||
|
||
//得到电缆文字内容
|
||
void TDbCableDim::GetCableLayString(const AcDbObjectId &id,CString &sText,int nIndex) const
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
CStringArray arNameValues,arSpeValues;
|
||
CString sName,sSpe,sFlowD,sT;
|
||
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead) == Acad::eOk)
|
||
{
|
||
if (m_bIsMulitCableLayDim)
|
||
{
|
||
sName = MULTI_CABLE_LAY;
|
||
sSpe.Format(_T("%sdata"),MULTI_CABLE_LAY);
|
||
}
|
||
else
|
||
{
|
||
sName = CABLELAY_XDATA_NAME;
|
||
sSpe = CABLELAY_XDATA_SPE;
|
||
}
|
||
resbuf *pRb = pEnt->xData(sName);
|
||
if (pRb != NULL)
|
||
{
|
||
resbuf *pTemp = pRb;
|
||
while (pTemp->rbnext != NULL)
|
||
{
|
||
pTemp = pTemp->rbnext;
|
||
sT = pTemp->resval.rstring;
|
||
arNameValues.Add(sT);
|
||
}
|
||
ads_relrb(pRb);
|
||
}
|
||
resbuf *pRb2 = pEnt->xData(sSpe);
|
||
if (pRb2 != NULL)
|
||
{
|
||
resbuf *pTemp = pRb2;
|
||
while (pTemp->rbnext != NULL)
|
||
{
|
||
pTemp = pTemp->rbnext;
|
||
sT = pTemp->resval.rstring;
|
||
arSpeValues.Add(sT);
|
||
}
|
||
ads_relrb(pRb2);
|
||
}
|
||
if (arNameValues.GetSize() > nIndex)
|
||
sName = arNameValues[nIndex];
|
||
else
|
||
sName.Empty();
|
||
if (arSpeValues.GetSize() > nIndex)
|
||
sSpe = arSpeValues[nIndex];
|
||
else
|
||
sSpe.Empty();
|
||
if (m_bIsMulitCableLayDim)
|
||
{
|
||
CStringArray arSplit;
|
||
int nFind = sSpe.Find(SPEC_CHAR);
|
||
while(nFind >= 0)
|
||
{
|
||
arSplit.Add(sSpe.Left(nFind));
|
||
sSpe = sSpe.Mid(nFind + 1);
|
||
nFind = sSpe.Find(SPEC_CHAR);
|
||
}
|
||
arSplit.Add(sSpe);
|
||
if (arSplit.GetSize() >= 4)
|
||
{
|
||
sSpe = arSplit[0] + _T("-") + arSplit[1];
|
||
sFlowD = arSplit[2] + arSplit[3];
|
||
}
|
||
else
|
||
{
|
||
sSpe.Empty();
|
||
sFlowD.Empty();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
int nPos = sSpe.Find(SPEC_CHAR);
|
||
if (nPos >= 0 && sName.CompareNoCase(sSpe.Left(nPos)) == 0 )
|
||
{
|
||
sSpe = sSpe.Mid(nPos + 1);
|
||
sSpe.Replace(SPEC_CHAR,_T("-"));
|
||
if (sSpe.Right(1).CompareNoCase(_T("-")) == 0)
|
||
sSpe.Delete(sSpe.GetLength() - 1);
|
||
}
|
||
TDbXDataMap map;
|
||
if (map.Read(pEnt,CABLE_PIPE_FLOW))
|
||
{
|
||
map.GetAt(sName,sFlowD);
|
||
sFlowD.Replace(SPEC_CHAR,_T(""));
|
||
}
|
||
}
|
||
|
||
if (m_sLableType.CompareNoCase(LABLE_CABANDSPE) == 0)
|
||
{
|
||
sText = sName + _T("-") + sSpe;
|
||
if (sSpe.IsEmpty())
|
||
sText = sName;
|
||
else
|
||
sText = sName + _T("-") + sSpe;
|
||
}
|
||
else if (m_sLableType.CompareNoCase(LABLE_CABNO) == 0)// 标注电缆编号
|
||
{
|
||
sText = sName;
|
||
}
|
||
else if (m_sLableType.CompareNoCase(LABLE_SPE) == 0)// 标注电缆规格
|
||
{
|
||
sText=sSpe;
|
||
}
|
||
if (m_bPipeFlow)
|
||
{
|
||
if (sText.IsEmpty())
|
||
sText = sFlowD;
|
||
else if (!sFlowD.IsEmpty() && sFlowD.Left(1).CompareNoCase(_T("-")) != 0)
|
||
{
|
||
sFlowD.Insert(0,_T('-'));
|
||
sText += sFlowD;
|
||
}
|
||
}
|
||
pEnt->close();
|
||
}
|
||
/*
|
||
CString sXData;
|
||
AcDbEntity *pEnt = NULL;
|
||
CStringArray arValues;
|
||
|
||
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead) == Acad::eOk)
|
||
{
|
||
if (m_sLableType.CompareNoCase(LABLE_CABANDSPE) == 0)
|
||
{
|
||
//lsd 注释添加 7.12
|
||
//resbuf *pRb = pEnt->xData(CABLELAY_XDATA_SPE);
|
||
//if (pRb != NULL)
|
||
//{
|
||
// CString csRet = _T("");
|
||
//
|
||
// resbuf *pTemp = pRb;
|
||
// while (pTemp->rbnext != NULL)
|
||
// {
|
||
// pTemp = pTemp->rbnext;
|
||
// csRet = pTemp->resval.rstring;
|
||
// // 分解出电缆规格
|
||
// csRet.Replace(SPEC_CHAR,_T("-"));
|
||
// if (!csRet.IsEmpty())
|
||
// {
|
||
// arValues.Add(csRet);
|
||
// }
|
||
// }
|
||
//
|
||
// ads_relrb(pRb);
|
||
//}
|
||
//lsd 注释添加 7.12
|
||
|
||
//lsd 添加 start 7.12
|
||
resbuf *pRbNo = pEnt->xData(CABLELAY_XDATA_NAME);
|
||
resbuf *pRbSpe = pEnt->xData(CABLELAY_XDATA_SPE);
|
||
if (pRbNo != NULL)
|
||
{
|
||
CString csRet;
|
||
|
||
resbuf *pTempNo = pRbNo;
|
||
resbuf *pTempSpe = pRbSpe;
|
||
while (pTempNo->rbnext != NULL)
|
||
{
|
||
pTempNo = pTempNo->rbnext;
|
||
csRet = pTempNo->resval.rstring;
|
||
|
||
//添加编号后添加相应规格
|
||
if(pTempSpe != NULL)
|
||
{
|
||
CString temp;
|
||
pTempSpe = pTempSpe->rbnext;
|
||
temp = pTempSpe->resval.rstring;
|
||
|
||
// 分解出电缆规格
|
||
int loc = temp.Find(SPEC_CHAR,0);
|
||
if (loc >= 0)
|
||
{
|
||
temp = temp.Right(temp.GetLength()-loc-1);
|
||
if (!temp.IsEmpty())
|
||
{
|
||
temp.Replace(SPEC_CHAR,_T("-"));
|
||
}
|
||
}
|
||
//modify liaoy 2016-6-14
|
||
int nLen = temp.GetLength();
|
||
if (nLen > 0 && temp.ReverseFind(_T('-')) == nLen -1)
|
||
temp.Delete(nLen -1);//删掉最后的'-'
|
||
if (!temp.IsEmpty())//说明型号规格不为空,则添加'-'以区分开编号与型号规格
|
||
temp.Insert(0,_T('-'));//在首位增加'-'以和pTempNo->resval.rstring区分开
|
||
//modify end
|
||
csRet+=temp;
|
||
}
|
||
arValues.Add(csRet);
|
||
}
|
||
|
||
ads_relrb(pRbNo);
|
||
ads_relrb(pRbSpe);
|
||
}
|
||
//lsd 添加 end 7.12
|
||
}
|
||
else if (m_sLableType.CompareNoCase(LABLE_CABNO) == 0)// 标注电缆编号
|
||
{
|
||
resbuf *pRb = pEnt->xData(CABLELAY_XDATA_NAME);
|
||
if (pRb != NULL)
|
||
{
|
||
CString csRet;
|
||
|
||
resbuf *pTemp = pRb;
|
||
while (pTemp->rbnext != NULL)
|
||
{
|
||
pTemp = pTemp->rbnext;
|
||
csRet = pTemp->resval.rstring;
|
||
arValues.Add(csRet);
|
||
}
|
||
|
||
ads_relrb(pRb);
|
||
}
|
||
}
|
||
else if (m_sLableType.CompareNoCase(LABLE_SPE) == 0)// 标注电缆规格
|
||
{
|
||
resbuf *pRb = pEnt->xData(CABLELAY_XDATA_SPE);
|
||
if (pRb != NULL)
|
||
{
|
||
CString csRet = _T("");
|
||
int nIndex = -1;
|
||
|
||
resbuf *pTemp = pRb;
|
||
while (pTemp->rbnext != NULL)
|
||
{
|
||
pTemp = pTemp->rbnext;
|
||
csRet = pTemp->resval.rstring;
|
||
// 分解出电缆规格
|
||
nIndex = csRet.Find(SPEC_CHAR,0);
|
||
if (nIndex >= 0)
|
||
{
|
||
csRet = csRet.Right(csRet.GetLength()-nIndex-1);
|
||
if (!csRet.IsEmpty())
|
||
{
|
||
csRet.Replace(SPEC_CHAR,_T("-"));
|
||
//modify liaoy 2016-6-14
|
||
int nLen = csRet.GetLength();
|
||
if (nLen > 0 && csRet.ReverseFind(_T('-')) == nLen -1)
|
||
csRet.Delete(nLen -1);//删掉最后的'-'
|
||
//modify end
|
||
arValues.Add(csRet);
|
||
}
|
||
}
|
||
}
|
||
ads_relrb(pRb);
|
||
}
|
||
}
|
||
|
||
if (arValues.GetSize() > nIndex)
|
||
sText = arValues[nIndex];
|
||
else
|
||
sText.Empty();
|
||
|
||
//看是否需要标注穿管管径 需要的话需要加上
|
||
// BOOL bDimPipeD = FALSE;
|
||
// GetGlobalContext(KEY_PIPE_FLOW_D,bDimPipeD);
|
||
if (m_bPipeFlow)
|
||
{
|
||
arValues.RemoveAll();
|
||
TDbXDataMap map;
|
||
if (map.Read(pEnt,CABLE_PIPE_FLOW))
|
||
{
|
||
resbuf *pRb = pEnt->xData(CABLELAY_XDATA_NAME);
|
||
CString sFlowD;
|
||
if (pRb != NULL)
|
||
{
|
||
CString csRet;
|
||
resbuf *pTemp = pRb;
|
||
while (pTemp->rbnext != NULL)
|
||
{
|
||
pTemp = pTemp->rbnext;
|
||
csRet = pTemp->resval.rstring;
|
||
arValues.Add(csRet);
|
||
}
|
||
|
||
if (arValues.GetSize() > nIndex)
|
||
map.GetAt(arValues[nIndex],sFlowD);
|
||
sFlowD.Replace(SPEC_CHAR,_T(""));
|
||
if (!sFlowD.IsEmpty())
|
||
sText += _T("-");
|
||
sText += sFlowD;
|
||
|
||
ads_relrb(pRb);
|
||
}
|
||
}
|
||
}
|
||
pEnt->close();
|
||
}
|
||
*/
|
||
}
|
||
|
||
//得到需要标注的字符串
|
||
void TDbCableDim::GetLableStrArray(LPCTSTR lpStr,CStringArray &arValues) const
|
||
{
|
||
if (lpStr == NULL)
|
||
return;
|
||
|
||
CString sValue;
|
||
CString sLableName = lpStr;
|
||
int nFind = -1;
|
||
nFind = sLableName.Find(SPEC_CHAR,0);
|
||
while (nFind != -1)
|
||
{
|
||
sValue = sLableName.Left(nFind);
|
||
arValues.Add(sValue);
|
||
|
||
sLableName = sLableName.Mid(nFind+1);
|
||
nFind = sLableName.Find(SPEC_CHAR,0);
|
||
}
|
||
}
|
||
|
||
//设置起点
|
||
void TDbCableDim::SetStartPt(const AcGePoint3d &pt)
|
||
{
|
||
assertWriteEnabled();
|
||
m_ptS = pt;
|
||
}
|
||
|
||
//设置拐点
|
||
void TDbCableDim::SetTurnPt(const AcGePoint3d &pt)
|
||
{
|
||
assertWriteEnabled();
|
||
m_ptTurn = pt;
|
||
}
|
||
|
||
//设置标注方向
|
||
void TDbCableDim::SetVtDir(const AcGeVector3d &vt)
|
||
{
|
||
assertWriteEnabled();
|
||
m_vtDir = vt;
|
||
if (m_vtDir.isZeroLength())
|
||
m_vtDir = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
m_vtDir.normalize();
|
||
}
|
||
|
||
//设置标注的文字内容
|
||
void TDbCableDim::InitLableContent(int nRunTime)
|
||
{
|
||
assertWriteEnabled();
|
||
CStringArray arValues;
|
||
TCHAR strTmpPath[100] = _T("");
|
||
GetTempPath(100, strTmpPath);
|
||
_tcscat(strTmpPath, LABLE_FILE_NAME);
|
||
|
||
m_sLableContent.Empty();
|
||
CString sTmpRow,sTmp,sTmp2;
|
||
CStdioFile file;
|
||
int nRunIndex = -1;
|
||
switch(nRunTime)
|
||
{
|
||
case TDb::eCabletry:
|
||
nRunIndex = 0;
|
||
break;
|
||
case TDb::eElbow:
|
||
nRunIndex = 1;
|
||
break;
|
||
case TDb::eTee:
|
||
nRunIndex = 2;
|
||
break;
|
||
case TDb::eCross:
|
||
nRunIndex = 3;
|
||
break;
|
||
case TDb::eReduce:
|
||
case TDb::eOffset: //乙字弯使用变径类型 axc add 2015-08-04
|
||
nRunIndex = 4;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
if (file.Open(strTmpPath,CFile::modeRead))
|
||
{
|
||
int nRow = 0;
|
||
int nIndex = -1;
|
||
while (file.ReadString(sTmpRow))
|
||
{
|
||
//找到对应的行
|
||
if (nRow != nRunIndex)
|
||
{
|
||
nRow++;
|
||
continue;
|
||
}
|
||
|
||
nIndex = sTmpRow.Find(_T("@"));
|
||
while (nIndex != -1)
|
||
{
|
||
DisposeData(_T("@"),sTmpRow,sTmp);
|
||
DisposeData(_T("$"),sTmp,sTmp2);
|
||
|
||
if (_ttoi(sTmp))
|
||
arValues.Add(sTmp2);
|
||
|
||
nIndex = sTmpRow.Find(_T("@"));
|
||
}
|
||
DisposeData(_T("$"),sTmpRow,sTmp);
|
||
if (_ttoi(sTmpRow))
|
||
arValues.Add(sTmp);
|
||
|
||
break;
|
||
}
|
||
file.Close();
|
||
}
|
||
else
|
||
{
|
||
if (nRunTime == TDb::eCabletry)
|
||
{
|
||
arValues.Add(LABLE_MODAL);
|
||
arValues.Add(LABLE_LEN);
|
||
arValues.Add(LABLE_ELV);
|
||
}
|
||
else
|
||
{
|
||
arValues.Add(LABLE_MODAL);
|
||
arValues.Add(LABLE_SPECS);
|
||
arValues.Add(LABLE_ELV);
|
||
}
|
||
}
|
||
|
||
for (int i = 0; i < arValues.GetSize(); ++i)
|
||
{
|
||
m_sLableContent += arValues[i];
|
||
m_sLableContent += SPEC_CHAR;
|
||
}
|
||
|
||
}
|
||
|
||
//设置标注样式
|
||
void TDbCableDim::SetLableStyle(int nStyle)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nLableStyle = nStyle;
|
||
}
|
||
|
||
//设置标注起点样式
|
||
void TDbCableDim::SetLableStartStyle(int nStyle)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nStartStyle = nStyle;
|
||
}
|
||
|
||
//设置标注实体的类型
|
||
void TDbCableDim::SetLableEntsType(int nType)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nDimEntType = nType;
|
||
}
|
||
|
||
//设置要标注的实体的ID
|
||
void TDbCableDim::SetLableEntsIds(const AcDbObjectIdArray &arIds)
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
if (m_nCurDwgVer <= 4)
|
||
{
|
||
for (int i = 0; i < arIds.length(); ++i)
|
||
{
|
||
m_arIds.append(arIds[i]);
|
||
}
|
||
|
||
int nRunTime = 0;
|
||
if (arIds.length() > 0)
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
if (acdbOpenAcDbEntity(pEnt,arIds[0],AcDb::kForRead) == Acad::eOk)
|
||
{
|
||
TDbPipeBase *pPipe = TDbPipeBase::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_RUNTIME,nRunTime);
|
||
}
|
||
TDbFittingBase *pFit = TDbFittingBase::cast(pEnt);
|
||
if (pFit != NULL)
|
||
{
|
||
pFit->GetSpecialtyData()->GetAt(KEY_RUNTIME,nRunTime);
|
||
}
|
||
pEnt->close();
|
||
}
|
||
|
||
InitLableContent(nRunTime);
|
||
|
||
//m_dLineBaseLen = GetMaxTextLen() / GetPScale();
|
||
}
|
||
}
|
||
|
||
|
||
/*
|
||
for (int i = 0; i < arIds.length(); ++i)
|
||
{
|
||
m_arIds.append(arIds[i]);
|
||
}
|
||
|
||
int nRunTime = 0;
|
||
if (arIds.length() > 0)
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
if (acdbOpenAcDbEntity(pEnt,arIds[0],AcDb::kForRead) == Acad::eOk)
|
||
{
|
||
TDbPipeBase *pPipe = TDbPipeBase::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_RUNTIME,nRunTime);
|
||
}
|
||
TDbFittingBase *pFit = TDbFittingBase::cast(pEnt);
|
||
if (pFit != NULL)
|
||
{
|
||
pFit->GetSpecialtyData()->GetAt(KEY_RUNTIME,nRunTime);
|
||
}
|
||
pEnt->close();
|
||
}
|
||
|
||
InitLableContent(nRunTime);
|
||
|
||
//m_dLineBaseLen = GetMaxTextLen() / GetPScale();
|
||
}
|
||
*/
|
||
}
|
||
//得到最长的文字长度 8.5
|
||
double TDbCableDim::GetMaxTextLen()
|
||
{
|
||
double dMax = 0.0;
|
||
double dLen = 0.0;
|
||
int nIdIndex = 0;
|
||
AcDbObjectId idBefore;
|
||
idBefore.setNull();
|
||
for (int i = 0; i < m_arIds.length(); ++i)
|
||
{
|
||
if (!idBefore.isNull() && idBefore == m_arIds[i])
|
||
nIdIndex++;
|
||
else
|
||
nIdIndex = 0;
|
||
|
||
CString sText;
|
||
GetTextString(m_arIds[i],sText,nIdIndex);
|
||
|
||
idBefore = m_arIds[i];
|
||
dLen = GetTextLen(sText);
|
||
if (m_nLableStyle == eLableStyle3)
|
||
{
|
||
int nFind = sText.ReverseFind(_T(','));
|
||
if (nFind != -1)
|
||
{
|
||
CString sText2 = sText.Left(nFind);
|
||
dLen = GetTextLen(sText2);
|
||
}
|
||
}
|
||
if (dLen > dMax)
|
||
dMax = dLen;
|
||
}
|
||
|
||
return dMax;
|
||
}
|
||
|
||
//得到最长的文字长度 9.0
|
||
double TDbCableDim::GetMaxTextLen(const AcDbObjectIdArray& arIds)
|
||
{
|
||
double dMax = 0.0;
|
||
double dLen = 0.0;
|
||
int nIdIndex = 0;
|
||
AcDbObjectId idBefore;
|
||
idBefore.setNull();
|
||
CString sText;
|
||
if (m_nDimEntType == eCableTray)
|
||
{
|
||
//桥架标注
|
||
for (int i = 0; i < arIds.length(); ++i)
|
||
{
|
||
if (!idBefore.isNull() && idBefore == arIds[i])
|
||
nIdIndex++;
|
||
else
|
||
nIdIndex = 0;
|
||
|
||
GetTextString(arIds[i],sText,nIdIndex);
|
||
|
||
idBefore = arIds[i];
|
||
dLen = GetTextLen(sText);
|
||
if (m_nLableStyle == eLableStyle3)
|
||
{
|
||
int nFind = -1;
|
||
if (m_nCurDwgVer >= 5) // 2013/2/4 alter by wzh 桥架标注样式三调整
|
||
{
|
||
CString sFds = m_sLableFds;
|
||
int nFdsLen = sFds.GetLength();
|
||
char* pch = NULL;
|
||
pch= (char*)sFds.GetBuffer(1);
|
||
//pch= (char*)sFds.GetBuffer(m_sLableFds.GetLength());
|
||
nFind = sText.ReverseFind(*pch);
|
||
if (nFdsLen > 1)
|
||
{
|
||
nFind -= nFdsLen - 1;
|
||
}
|
||
}
|
||
else
|
||
nFind = sText.ReverseFind(_T(',')); // 待 del
|
||
//int nFind = sText.ReverseFind(_T(',')); // 2013/2/4 comment by wzh
|
||
if (nFind != -1)
|
||
{
|
||
CString sText2 = sText.Left(nFind);
|
||
dLen = GetTextLen(sText2);
|
||
}
|
||
}
|
||
if (dLen > dMax)
|
||
dMax = dLen;
|
||
}
|
||
}
|
||
else if (m_nDimEntType == eCableLay)
|
||
{
|
||
CStringArray arTemp;
|
||
|
||
//modify liaoy 2016-8-12
|
||
//ReadXData(arIds[0],CABLELAY_XDATA_NAME,arTemp);
|
||
ReadXData(arIds[0],GetName(m_bIsMulitCableLayDim),arTemp);
|
||
//modify end
|
||
for (int i = 0;i < arTemp.GetSize();++i)
|
||
{
|
||
GetTextString(arIds[0],sText,i);
|
||
dLen = GetTextLen(sText);
|
||
if (m_nLableStyle == eLableStyle3)
|
||
{
|
||
int nFind = -1;
|
||
if (m_nCurDwgVer >= 5) // 2013/2/4 alter by wzh 桥架标注样式三调整
|
||
{
|
||
CString sFds = m_sLableFds;
|
||
int nFdsLen = sFds.GetLength();
|
||
char* pch = NULL;
|
||
pch= (char*)sFds.GetBuffer(1);
|
||
//pch= (char*)sFds.GetBuffer(m_sLableFds.GetLength());
|
||
nFind = sText.ReverseFind(*pch);
|
||
if (nFdsLen > 1)
|
||
{
|
||
nFind -= nFdsLen - 1;
|
||
}
|
||
}
|
||
else
|
||
nFind = sText.ReverseFind(_T(',')); // 待 del
|
||
//int nFind = sText.ReverseFind(_T(',')); // 2013/2/4 comment by wzh
|
||
if (nFind != -1)
|
||
{
|
||
CString sText2 = sText.Left(nFind);
|
||
dLen = GetTextLen(sText2);
|
||
}
|
||
}
|
||
if (dLen > dMax)
|
||
dMax = dLen;
|
||
}
|
||
|
||
}
|
||
|
||
return dMax;
|
||
}
|
||
|
||
BOOL TDbCableDim::SplitValue(LPCTSTR pszSrc, LPCTSTR pszSplitCh, CStringArray& arValue) const
|
||
{
|
||
arValue.RemoveAll();
|
||
|
||
CString sValue;
|
||
CString sSrc = pszSrc;
|
||
while (SplitString(sSrc, pszSplitCh, sValue))
|
||
{
|
||
arValue.Add(sValue);
|
||
}
|
||
if (!sSrc.IsEmpty())
|
||
{
|
||
arValue.Add(sSrc);
|
||
}
|
||
return arValue.GetSize() > 0;
|
||
}
|
||
|
||
BOOL TDbCableDim::SplitString(CString& sSrc, LPCTSTR pszSplitCh, CString& sValue) const
|
||
{
|
||
if (!sSrc.IsEmpty())
|
||
{
|
||
int nIndex = sSrc.Find(pszSplitCh, 0);
|
||
if (nIndex > 0)
|
||
{
|
||
sValue = sSrc.Left(nIndex);
|
||
sSrc = sSrc.Right(sSrc.GetLength()-nIndex-1);
|
||
|
||
return TRUE;
|
||
}
|
||
}
|
||
|
||
return FALSE;
|
||
}
|
||
|
||
//设置行间距系数
|
||
void TDbCableDim::SetTextRowDisFact(double dDisFact)
|
||
{
|
||
assertWriteEnabled();
|
||
m_dTextRowDis = dDisFact;
|
||
}
|
||
|
||
//设置标注间隔符
|
||
void TDbCableDim::SetLableFds(CString& sLableFds)
|
||
{
|
||
assertWriteEnabled();
|
||
m_sLableFds = sLableFds;
|
||
}
|
||
|
||
//得到起点
|
||
AcGePoint3d TDbCableDim::GetStartPt()
|
||
{
|
||
return m_ptS;
|
||
}
|
||
|
||
//得到拐点
|
||
AcGePoint3d TDbCableDim::GetTurnPt()
|
||
{
|
||
return m_ptTurn;
|
||
}
|
||
|
||
//得到标注方向
|
||
AcGeVector3d TDbCableDim::GetVtDir()
|
||
{
|
||
return m_vtDir;
|
||
}
|
||
|
||
//得到标注样式
|
||
Adesk::UInt16 TDbCableDim::GetLableStyle()
|
||
{
|
||
return m_nLableStyle;
|
||
}
|
||
|
||
//得到标注起点样式
|
||
Adesk::UInt16 TDbCableDim::GetLableStartStyle()
|
||
{
|
||
return m_nStartStyle;
|
||
}
|
||
|
||
//得到标注实体类型
|
||
Adesk::UInt16 TDbCableDim::GetLableEntsType()
|
||
{
|
||
return m_nDimEntType;
|
||
}
|
||
|
||
//得到标注的实体的ID
|
||
void TDbCableDim::GetLableEntsIds(AcDbObjectIdArray &arIds)
|
||
{
|
||
// arIds.setLogicalLength(0);
|
||
// ReadReactorID(arIds);
|
||
|
||
//lsd del 2013-7-30
|
||
/* if (m_nCurDwgVer <= 4)
|
||
{
|
||
for (int i = 0; i < m_arIds.length(); ++i)
|
||
{
|
||
arIds.append(m_arIds[i]);
|
||
}
|
||
}*/
|
||
|
||
//lsd add 2013-7-30
|
||
for (int i = 0; i < m_arIds.length(); ++i)
|
||
{
|
||
arIds.append(m_arIds[i]);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
//得到文字行间距系数
|
||
double TDbCableDim::GetTextRowDisFact()
|
||
{
|
||
return m_dTextRowDis;
|
||
}
|
||
|
||
//得到标注分隔符
|
||
CString TDbCableDim::GetLableFds(CString& sLableFds)
|
||
{
|
||
return m_sLableFds;
|
||
}
|
||
|
||
//设置电缆标注类型
|
||
void TDbCableDim::SetCableLabelType(LPCTSTR pszType)
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
m_sLableType = pszType;
|
||
}
|
||
|
||
//设置标注颜色
|
||
void TDbCableDim::SetLableLineColor(Adesk::UInt16 nColor)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nColorLine = nColor;
|
||
}
|
||
|
||
//设置文字颜色
|
||
void TDbCableDim::SetLableTextColor(Adesk::UInt16 nColor)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nColorText = nColor;
|
||
}
|
||
|
||
//得到标注颜色
|
||
Adesk::UInt16 TDbCableDim::GetLableLineColor()
|
||
{
|
||
return m_nColorLine;
|
||
}
|
||
|
||
//得到文字颜色
|
||
Adesk::UInt16 TDbCableDim::GetLableTextColor()
|
||
{
|
||
return m_nColorText;
|
||
}
|
||
|
||
//获取出图比例
|
||
double TDbCableDim::GetPrintScale()
|
||
{
|
||
assertReadEnabled();
|
||
double dScale = GetPScale();
|
||
return dScale;
|
||
}
|
||
|
||
//布局转角
|
||
double TDbCableDim::GetLayoutRotationAngle()
|
||
{
|
||
assertReadEnabled();
|
||
double dAngle = GetLayoutRotation();
|
||
return dAngle;
|
||
}
|
||
|
||
//得到电缆标注类型
|
||
CString TDbCableDim::GetCableLabelType()
|
||
{
|
||
assertReadEnabled();
|
||
|
||
return m_sLableType;
|
||
}
|
||
|
||
//设置出图比例
|
||
void TDbCableDim::SetPrintScale(double dScale)
|
||
{
|
||
assertWriteEnabled();
|
||
SetPScale(dScale);
|
||
}
|
||
|
||
//设置布局转角
|
||
void TDbCableDim::SetLayoutRotationAngle(double dAngle)
|
||
{
|
||
assertWriteEnabled();
|
||
SetLayoutRotation(dAngle);
|
||
}
|
||
|
||
double TDbCableDim::GetTextHeight() const
|
||
{
|
||
return m_nTextHeight;
|
||
}
|
||
|
||
AcDbObjectId TDbCableDim::GetTextStyleId() const
|
||
{
|
||
return m_idTextStyle;
|
||
}
|
||
|
||
AcDbObjectId TDbCableDim::GetTextLayerId() const
|
||
{
|
||
return m_idTextLayer;
|
||
}
|
||
|
||
void TDbCableDim::SetTextHeight(double nHeight)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nTextHeight = nHeight;
|
||
}
|
||
|
||
void TDbCableDim::SetTextStyleId(AcDbObjectId id)
|
||
{
|
||
assertWriteEnabled();
|
||
m_idTextStyle = id;
|
||
}
|
||
|
||
void TDbCableDim::SetTextLayerId(AcDbObjectId id)
|
||
{
|
||
assertWriteEnabled();
|
||
m_idTextLayer = id;
|
||
}
|
||
|
||
void TDbCableDim::SetTextRotation(double nRot)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nTextRotation = nRot;
|
||
}
|
||
|
||
double TDbCableDim::GetTextRotation() const
|
||
{
|
||
return m_nTextRotation;
|
||
}
|
||
|
||
//更新桥架长度
|
||
void TDbCableDim::RenewCableLen()
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
if (m_nCurDwgVer >= 5)
|
||
{
|
||
AcDbObjectIdArray arTemp;
|
||
ReadReactorID(arTemp);
|
||
if (arTemp.length() == 0)
|
||
{
|
||
return;
|
||
}
|
||
m_dLineBaseLen = GetMaxTextLen(arTemp) / GetPScale();
|
||
}
|
||
else
|
||
m_dLineBaseLen = GetMaxTextLen() / GetPScale();
|
||
}
|
||
|
||
//更新桥架实体ID
|
||
void TDbCableDim::RenewCableEnts(const AcDbObjectIdArray &arIds)
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
//lsd del 2013-7-30
|
||
/* if (m_nCurDwgVer <= 4)
|
||
{
|
||
m_arIds.setLogicalLength(0);
|
||
for (int i = 0; i < arIds.length(); ++i)
|
||
{
|
||
m_arIds.append(arIds[i]);
|
||
}
|
||
}*/
|
||
|
||
|
||
//lsd add 2013-7-30
|
||
m_arIds.setLogicalLength(0);
|
||
for (int i = 0; i < arIds.length(); ++i)
|
||
{
|
||
m_arIds.append(arIds[i]);
|
||
}
|
||
|
||
}
|
||
|
||
//设置引线扩展数据点
|
||
void TDbCableDim::SetDownLeadXData(const AcGePoint3dArray &arPts)
|
||
{
|
||
m_arPtLead = arPts;
|
||
}
|
||
|
||
//得到引线点扩展数据
|
||
void TDbCableDim::GetDownLeadXData(AcGePoint3dArray &arPts)
|
||
{
|
||
arPts = m_arPtLead;
|
||
}
|
||
|
||
//写入引线扩展数据
|
||
void TDbCableDim::WriteDownLeadData()
|
||
{
|
||
//将多引线点写入扩展数据
|
||
TDbXDataMap map;
|
||
int nLen = m_arPtLead.length();
|
||
map.SetAt(DOWN_LEAD_COUNT,nLen);
|
||
CString sTmp;
|
||
for (int i = 0; i < nLen; ++i)
|
||
{
|
||
sTmp.Format(_T("%d"),i);
|
||
map.SetAt(sTmp,m_arPtLead[i]);
|
||
}
|
||
map.Write(this,DOWN_LEAD_XDATA);
|
||
}
|
||
|
||
//读取引线扩展数据
|
||
void TDbCableDim::ReadDownLeadData()
|
||
{
|
||
//读取引线扩展数据
|
||
m_arPtLead.setLogicalLength(0);
|
||
TDbXDataMap map;
|
||
int nCount = 0;
|
||
CString sTmp;
|
||
AcGePoint3d ptData;
|
||
if (map.Read(this,DOWN_LEAD_XDATA))
|
||
{
|
||
map.GetAt(DOWN_LEAD_COUNT,nCount);
|
||
for (int i = 0; i < nCount; ++i)
|
||
{
|
||
sTmp.Format(_T("%d"),i);
|
||
map.GetAt(sTmp,ptData);
|
||
m_arPtLead.append(ptData);
|
||
}
|
||
}
|
||
}
|
||
|
||
//读取是否标注穿管的扩展数据
|
||
void TDbCableDim::ReadIsDimPipeFlow()
|
||
{
|
||
resbuf *pRb = this->xData(CABLE_PIPE_FLOW_IS_DIM);
|
||
if (pRb != NULL)
|
||
{
|
||
resbuf *pTemp = pRb;
|
||
while (pTemp->rbnext != NULL)
|
||
{
|
||
pTemp = pTemp->rbnext;
|
||
m_bPipeFlow = _ttoi(pTemp->resval.rstring);
|
||
}
|
||
|
||
ads_relrb(pRb);
|
||
}
|
||
}
|
||
|
||
//读取是否多电缆敷设标注的扩展数据
|
||
void TDbCableDim::ReadIsMulitCableLayDim()
|
||
{
|
||
resbuf *pRb = this->xData(MULTI_CABLE_LAY_DIM);
|
||
if (pRb != NULL)
|
||
{
|
||
resbuf *pTemp = pRb;
|
||
while (pTemp->rbnext != NULL)
|
||
{
|
||
pTemp = pTemp->rbnext;
|
||
m_bIsMulitCableLayDim = _ttoi(pTemp->resval.rstring);
|
||
}
|
||
ads_relrb(pRb);
|
||
}
|
||
}
|
||
|
||
//设置是否标注穿管
|
||
void TDbCableDim::SetIsDimPipeFlow(BOOL bPipeFlow)
|
||
{
|
||
m_bPipeFlow = bPipeFlow;
|
||
}
|
||
|
||
//设置是否是否多电缆敷设标注
|
||
void TDbCableDim::SetIsMulitCableLayDim(BOOL bIsMulitCableLayDim)
|
||
{
|
||
m_bIsMulitCableLayDim = bIsMulitCableLayDim;
|
||
}
|
||
void TDbCableDim::CopyPropertiesFrom(AcDbEntity *pSrc,unsigned gMatchFlag)
|
||
{
|
||
assertWriteEnabled();
|
||
TDbEntity::CopyPropertiesFrom(pSrc,gMatchFlag);
|
||
}
|
||
|
||
//设置小数点位数
|
||
void TDbCableDim::SetDataValidPrecision(Adesk::UInt16 nBit)
|
||
{
|
||
m_nValidBit = nBit;
|
||
}
|
||
|
||
//得到小数点位数
|
||
Adesk::UInt16 TDbCableDim::GetDataValidPrecision()
|
||
{
|
||
return m_nValidBit;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbCableDim::subGetClassID(CLSID* pClsid) const
|
||
{
|
||
// #if (ADS < 16)
|
||
// CLSID CLSID_DimEntity = {0x5FA3482D, 0xBCC1, 0x4259, { 0x83, 0xAE, 0x37, 0x9F, 0x6F, 0xA7, 0x9D, 0xAE }};
|
||
// *pClsid = CLSID_DimEntity;
|
||
// #endif
|
||
//
|
||
// #if (ADS == 16)
|
||
// CLSID CLSID_DimEntity = {0x5FA3482D, 0xBCC1, 0x4259, { 0x83, 0xAE, 0x37, 0x9F, 0x6F, 0xA7, 0x9D, 0xAF }};
|
||
// *pClsid = CLSID_DimEntity;
|
||
// #endif
|
||
//
|
||
// #if (ADS == 17)
|
||
// CLSID CLSID_DimEntity = {0x5FA3482D, 0xBCC1, 0x4259, { 0x83, 0xAE, 0x37, 0x9F, 0x6F, 0xA7, 0x9D, 0xB0 }};
|
||
// *pClsid = CLSID_DimEntity;
|
||
// #endif
|
||
//
|
||
// #if (ADS == 18)
|
||
// CLSID CLSID_DimEntity = {0x5FA3482D, 0xBCC1, 0x4259, { 0x83, 0xAE, 0x37, 0x9F, 0x6F, 0xA7, 0x9D, 0xB1 }};
|
||
// *pClsid = CLSID_DimEntity;
|
||
// #endif
|
||
return Acad::eOk;
|
||
}
|
||
|
||
void TDbCableDim::ReadReactorID(AcDbObjectIdArray& arIds) const
|
||
{
|
||
const AcDbVoidPtrArray* parCabs = NULL;
|
||
void * pReactor = NULL;
|
||
AcDbObjectId oid;
|
||
int nRuntime = 0;
|
||
#if (ADS > 16)
|
||
parCabs = reactors();
|
||
#else
|
||
parCabs = const_cast<TDbCableDim*>(this)->reactors();
|
||
#endif
|
||
arIds.setLogicalLength(0);
|
||
if (parCabs == NULL)
|
||
{
|
||
return;
|
||
}
|
||
for (int i = 0;i < parCabs->length();++i)
|
||
{
|
||
pReactor = parCabs->at(i);
|
||
if (acdbIsPersistentReactor(pReactor))
|
||
{
|
||
oid = acdbPersistentReactorObjectId(pReactor);
|
||
OPENOBJ_BEGIN(oid,AcDb::kForRead,AcDbEntity,pCab);
|
||
if (pCab)
|
||
{
|
||
arIds.append(oid);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
}
|
||
|
||
void TDbCableDim::UpdateDimData()
|
||
{
|
||
AcDbObjectIdArray arTemp;
|
||
ReadReactorID(arTemp);
|
||
int nRunTime = 0;
|
||
if (arTemp.length() > 0)
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
if (acdbOpenAcDbEntity(pEnt,arTemp[0],AcDb::kForRead) == Acad::eOk)
|
||
{
|
||
TDbPipeBase *pPipe = TDbPipeBase::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_RUNTIME,nRunTime);
|
||
}
|
||
TDbFittingBase *pFit = TDbFittingBase::cast(pEnt);
|
||
if (pFit != NULL)
|
||
{
|
||
pFit->GetSpecialtyData()->GetAt(KEY_RUNTIME,nRunTime);
|
||
}
|
||
pEnt->close();
|
||
}
|
||
|
||
InitLableContent(nRunTime);
|
||
|
||
m_dLineBaseLen = GetMaxTextLen(arTemp) / GetPScale();
|
||
//axc add 2013-12-05 如果电缆标注显示电缆根数则求得电缆根数字符串的最大长度
|
||
double dCabNumTextLen = GetTextLen(m_sSign)/GetPScale();
|
||
if (m_dLineBaseLen < dCabNumTextLen)
|
||
m_dLineBaseLen = dCabNumTextLen;
|
||
|
||
if (m_nDimEntType == eCableLay)
|
||
{
|
||
//电缆标注,初始化夹点组
|
||
InitGripPntsForLay();
|
||
}
|
||
}
|
||
}
|
||
|
||
BOOL TDbCableDim::ReadXData(const AcDbObjectId& id,LPCTSTR pszAppName,CStringArray& arXData) const
|
||
{
|
||
arXData.RemoveAll();
|
||
if (pszAppName == NULL || !id.isValid())
|
||
{
|
||
return FALSE;
|
||
}
|
||
AcDbEntity* pEnt = NULL;
|
||
if (acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead) != Acad::eOk)
|
||
{
|
||
return FALSE;
|
||
}
|
||
BOOL bRet = ReadXData(pEnt,pszAppName,arXData);
|
||
pEnt->close();
|
||
|
||
return bRet;
|
||
}
|
||
|
||
BOOL TDbCableDim::ReadXData(AcDbEntity* pEnt,LPCTSTR pszAppName,CStringArray& arXData) const
|
||
{
|
||
arXData.RemoveAll();
|
||
if (pszAppName == NULL || pEnt == NULL)
|
||
{
|
||
return FALSE;
|
||
}
|
||
arXData.RemoveAll();
|
||
// 电缆编号,起点,终点
|
||
struct resbuf* pRb = NULL;
|
||
pRb = pEnt->xData(pszAppName);
|
||
struct resbuf* pTemp = NULL;
|
||
if (pRb == NULL)
|
||
{
|
||
return FALSE;
|
||
}
|
||
else
|
||
{
|
||
arXData.RemoveAll();
|
||
// 首先跳过程序名
|
||
for (pTemp = pRb->rbnext; pTemp != NULL;
|
||
pTemp = pTemp->rbnext)
|
||
{
|
||
if (pTemp->restype == AcDb::kDxfXdAsciiString)
|
||
{
|
||
arXData.Add(pTemp->resval.rstring);
|
||
}
|
||
}
|
||
}
|
||
|
||
acutRelRb(pRb);
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
//bsl 2012.3.14 初始化行列数据
|
||
void TDbCableDim::InitGripPntsForLay()
|
||
{
|
||
assertWriteEnabled();
|
||
//初始化夹点组
|
||
m_arRowWidth.setLogicalLength(0);
|
||
|
||
int nCount;
|
||
AcDbObjectIdArray arTemp;
|
||
ReadReactorID(arTemp);
|
||
if (arTemp.length() > 0)
|
||
{
|
||
CStringArray arNames;
|
||
//modify liaoy 2016-8-12
|
||
//ReadXData(arTemp[0],CABLELAY_XDATA_NAME,arNames);
|
||
ReadXData(arTemp[0],GetName(m_bIsMulitCableLayDim),arNames);
|
||
//modify end
|
||
nCount = arNames.GetSize();
|
||
|
||
double dRowWidth = m_dLineBaseLen * GetPScale();
|
||
double dRowHeight = m_nTextHeight*GetPScale()*(1 + 0.5)*m_dTextRowDis;
|
||
|
||
int nRow = 0,nCol = 0;
|
||
|
||
if (nCount > 10)
|
||
{
|
||
// nRow = 10;
|
||
nCol = (int)ceil((double)nCount/10.0);
|
||
nRow = (int)ceil((double)nCount/(double)nCol);
|
||
}
|
||
else
|
||
{
|
||
nRow = nCount;
|
||
nCol = 1;
|
||
}
|
||
|
||
AcGeVector3d vtDir = m_vtDir;
|
||
vtDir.normalize();
|
||
for (int i = 0;i < nCol;++i)
|
||
{
|
||
m_arRowWidth.append(dRowWidth);
|
||
}
|
||
|
||
//初始化控制行列夹点
|
||
AcGeVector3d vtLableDir = m_vtDir;
|
||
vtLableDir.normalize();
|
||
AcGePoint3d ptGe1 = m_ptTurn;
|
||
AcGePoint3d ptGe2 = m_ptS;
|
||
if (ptGe1.y > ptGe2.y)
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
else
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
}
|
||
}
|
||
|
||
//bsl 2012.3.14 根据高度计算重新计算列
|
||
void TDbCableDim::CalcGripPntForLay(double dH)
|
||
{
|
||
assertWriteEnabled();
|
||
//初始化夹点组
|
||
m_arRowWidth.setLogicalLength(0);
|
||
|
||
int nCount;
|
||
AcDbObjectIdArray arTemp;
|
||
ReadReactorID(arTemp);
|
||
if (arTemp.length() > 0)
|
||
{
|
||
CStringArray arNames;
|
||
//modify liaoy 2016-8-12
|
||
//ReadXData(arTemp[0],CABLELAY_XDATA_NAME,arNames);
|
||
ReadXData(arTemp[0],GetName(m_bIsMulitCableLayDim),arNames);
|
||
//modify end
|
||
nCount = arNames.GetSize();
|
||
|
||
double dRowHeight = m_nTextHeight*GetPScale()*(1 + 0.5)*m_dTextRowDis;
|
||
double dRowWidth = m_dLineBaseLen * GetPScale();
|
||
|
||
int nRow = (int)floor(fabs(dH)/dRowHeight);
|
||
if (nRow == 0)
|
||
{
|
||
nRow = 1;
|
||
}
|
||
int nCol = (int)ceil((double)nCount/(double)nRow);
|
||
|
||
AcGeVector3d vtDir = m_vtDir;
|
||
vtDir.normalize();
|
||
for (int i = 0;i < nCol;++i)
|
||
{
|
||
m_arRowWidth.append(dRowWidth);
|
||
}
|
||
|
||
//初始化控制行列夹点
|
||
AcGeVector3d vtLableDir = m_vtDir;
|
||
vtLableDir.normalize();
|
||
AcGePoint3d ptGe1 = m_ptTurn;
|
||
AcGePoint3d ptGe2 = m_ptS;
|
||
if (ptGe1.y > ptGe2.y)
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
else
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
}
|
||
}
|
||
|
||
//bsl 2012.3.14 获取控制行列夹点
|
||
AcGePoint3d TDbCableDim::GetSizePt() const
|
||
{
|
||
AcGePoint3d ptSize;
|
||
|
||
int nCol = m_arRowWidth.length();
|
||
if (nCol == 0)
|
||
{
|
||
//列数
|
||
return ptSize;
|
||
}
|
||
|
||
AcDbObjectIdArray arTemp;
|
||
ReadReactorID(arTemp);
|
||
int nCount = arTemp.length();
|
||
if (nCount == 0)
|
||
{
|
||
return ptSize;
|
||
}
|
||
|
||
CStringArray arNames;
|
||
//modify liaoy 2016-8-12
|
||
//ReadXData(arTemp[0],CABLELAY_XDATA_NAME,arNames);
|
||
ReadXData(arTemp[0],GetName(m_bIsMulitCableLayDim),arNames);
|
||
//modify end
|
||
nCount = arNames.GetSize();
|
||
|
||
//行数
|
||
int nRow = (int)ceil((double)nCount / (double)nCol);
|
||
|
||
double dRowHeight = m_nTextHeight*GetPScale()*(1 + 0.5)*m_dTextRowDis;
|
||
|
||
//纵方向
|
||
AcGeVector3d vtLableDir = m_vtDir;
|
||
vtLableDir.normalize();
|
||
AcGePoint3d ptGe1 = m_ptTurn;
|
||
AcGePoint3d ptGe2 = m_ptS;
|
||
if (ptGe1.y > ptGe2.y)
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
else
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
|
||
//横方向
|
||
AcGeVector3d vtDir = m_vtDir;
|
||
if (vtDir.isZeroLength())
|
||
vtDir = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
|
||
double dWidth = 0.0;
|
||
for (int i = 0;i < m_arRowWidth.length();++i)
|
||
{
|
||
dWidth += m_arRowWidth[i];
|
||
}
|
||
|
||
ptSize = m_ptTurn + vtDir * dWidth;
|
||
ptSize += vtLableDir*nRow*dRowHeight;
|
||
//增加表头支持
|
||
if (!m_sSign.IsEmpty())
|
||
ptSize += vtLableDir*dRowHeight;
|
||
return ptSize;
|
||
}
|
||
|
||
//bsl 2012.3.14 获取电缆标注的总高度
|
||
double TDbCableDim::GetDimHeight()
|
||
{
|
||
double dDimHeight = 0.0;
|
||
int nCol = m_arRowWidth.length();
|
||
if (nCol == 0)
|
||
{
|
||
//列数
|
||
return dDimHeight;
|
||
}
|
||
|
||
AcDbObjectIdArray arTemp;
|
||
ReadReactorID(arTemp);
|
||
int nCount = arTemp.length();
|
||
if (nCount == 0)
|
||
{
|
||
return dDimHeight;
|
||
}
|
||
|
||
CStringArray arNames;
|
||
//modify liaoy 2016-8-12
|
||
//ReadXData(arTemp[0],CABLELAY_XDATA_NAME,arNames);
|
||
ReadXData(arTemp[0],GetName(m_bIsMulitCableLayDim),arNames);
|
||
//modify end
|
||
nCount = arNames.GetSize();
|
||
|
||
//行数
|
||
int nRow = (int)ceil((double)nCount / (double)nCol);
|
||
|
||
double dRowHeight = m_nTextHeight*GetPScale()*(1 + 0.5)*m_dTextRowDis;
|
||
|
||
dDimHeight = nRow*dRowHeight;
|
||
|
||
return dDimHeight;
|
||
}
|
||
|
||
void TDbCableDim::SetCabSign(const TCHAR* pszSign)
|
||
{
|
||
if (pszSign == NULL)
|
||
{
|
||
m_sSign.Empty();
|
||
}
|
||
else
|
||
m_sSign = pszSign;
|
||
}
|
||
|
||
void TDbCableDim::SetStartLineLen(double dLen)
|
||
{
|
||
assertWriteEnabled();
|
||
TEntityFields& fields = Fields();
|
||
if (dLen == 0) dLen = 1;
|
||
fields.SFD(_T("STARTLINELEN"), dLen);
|
||
}
|
||
double TDbCableDim::GetStartLineLen() const
|
||
{
|
||
assertReadEnabled();
|
||
double dLen = 0.0;
|
||
const TEntityFields& fields = GetFields();
|
||
fields.GFD(_T("STARTLINELEN"), dLen);
|
||
if (dLen == 0) dLen = 1;
|
||
return dLen;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbCableDim::ExplodeOrDraw3d( XExplodeDraw &dc ) const
|
||
{
|
||
return ExplodeOrDraw2d(dc);
|
||
}
|
||
|
||
//设置系统分类关键字
|
||
//强电 lsd 2013-8-26
|
||
void TDbCableDim::SetSysKeyForce(CString& sSysKeyForce)
|
||
{
|
||
assertWriteEnabled();
|
||
//m_sSysKeyForce = sSysKeyForce;
|
||
TEntityFields& fields = Fields();
|
||
fields.SFD(_T("SysKeyForce"), sSysKeyForce);
|
||
}
|
||
CString TDbCableDim::GetSysKeyForce() const
|
||
{
|
||
assertReadEnabled();
|
||
CString sSysKey = _T("E");
|
||
const TEntityFields& fields = GetFields();
|
||
fields.GFD(_T("SysKeyForce"), sSysKey);
|
||
return sSysKey;
|
||
}
|
||
|
||
//弱电 lsd 2013-8-26
|
||
void TDbCableDim::SetSysKeyWeak(CString& sSysKeyWeak)
|
||
{
|
||
assertWriteEnabled();
|
||
//m_sSysKeyWeak = sSysKeyWeak;
|
||
TEntityFields& fields = Fields();
|
||
fields.SFD(_T("SysKeyWeak"), sSysKeyWeak);
|
||
}
|
||
CString TDbCableDim::GetSysKeyWeak() const
|
||
{
|
||
assertReadEnabled();
|
||
CString sSysKey = _T("D");
|
||
const TEntityFields& fields = GetFields();
|
||
fields.GFD(_T("SysKeyWeak"), sSysKey);
|
||
return sSysKey;
|
||
}
|
||
|
||
//消防 lsd 2013-8-26
|
||
void TDbCableDim::SetSysKeyFire(CString& sSysKeyFire)
|
||
{
|
||
assertWriteEnabled();
|
||
//m_sSysKeyFire = sSysKeyFire;
|
||
TEntityFields& fields = Fields();
|
||
fields.SFD(_T("SysKeyFire"), sSysKeyFire);
|
||
}
|
||
CString TDbCableDim::GetSysKeyFire() const
|
||
{
|
||
assertReadEnabled();
|
||
CString sSysKey = _T("F");
|
||
const TEntityFields& fields = GetFields();
|
||
fields.GFD(_T("SysKeyFire"), sSysKey);
|
||
return sSysKey;
|
||
}
|
||
|
||
//其他 lsd 2013-8-26
|
||
void TDbCableDim::SetSysKeyOther(CString& sSysKeyOther)
|
||
{
|
||
assertWriteEnabled();
|
||
//m_sSysKeyOther = sSysKeyOther;
|
||
TEntityFields& fields = Fields();
|
||
fields.SFD(_T("SysKeyOther"), sSysKeyOther);
|
||
}
|
||
CString TDbCableDim::GetSysKeyOther() const
|
||
{
|
||
assertReadEnabled();
|
||
CString sSysKey = _T("T");
|
||
const TEntityFields& fields = GetFields();
|
||
fields.GFD(_T("SysKeyOther"), sSysKey);
|
||
return sSysKey;
|
||
}
|
||
///////////////////////////////////////////////////////
|
||
TTextPosition TDbCableDim::FindSubText(const TCHAR *sSubText, TTextPosition &posStart,
|
||
TTextRange *pRange) const
|
||
{
|
||
TTextPosition pos;
|
||
if (!sSubText || !sSubText[0])
|
||
return pos;
|
||
|
||
TTextPosition posNext = posStart;
|
||
while(1)
|
||
{
|
||
TDbText text;
|
||
if (!GetText(posNext.m_nCookies,text))
|
||
break;
|
||
|
||
TTextPosition 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;
|
||
}
|
||
|
||
long TDbCableDim::GetSubTextNum() const
|
||
{
|
||
AcDbObjectIdArray arTemp;
|
||
CStringArray arNames;
|
||
CString sText;
|
||
long nSubTextNum = 0,nTmp = 0;
|
||
if (m_nDimEntType == eCableTray)
|
||
{
|
||
if (m_nCurDwgVer >= 5)
|
||
{
|
||
ReadReactorID(arTemp);
|
||
if (arTemp.length() == 0)
|
||
return 0;
|
||
for (int i = 0; i < arTemp.length(); ++i)
|
||
{
|
||
GetTextString(arTemp[i],sText,0);
|
||
if (!sText.IsEmpty())
|
||
nTmp++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
nTmp = m_arIds.length();
|
||
}
|
||
if (m_nLableStyle != eLableStyle3)
|
||
nSubTextNum = nTmp;
|
||
else
|
||
nSubTextNum = 2 * nTmp;
|
||
}
|
||
else if (m_nDimEntType == eCableLay)
|
||
{
|
||
ReadReactorID(arTemp);
|
||
if (arTemp.length() == 0)
|
||
return 0;
|
||
//ReadXData(arTemp[0],CABLELAY_XDATA_NAME,arNames);
|
||
ReadXData(arTemp[0],GetName(m_bIsMulitCableLayDim),arNames);
|
||
//modify end
|
||
for (int j = 0;j < arNames.GetSize();++j)
|
||
{
|
||
GetTextString(arTemp[0],sText,j);
|
||
if (!sText.IsEmpty())
|
||
nTmp++;
|
||
}
|
||
if (m_nLableStyle != eLableStyle3)
|
||
nSubTextNum = nTmp;
|
||
if (!m_sSign.IsEmpty())
|
||
nSubTextNum++;
|
||
}
|
||
return nSubTextNum;
|
||
}
|
||
|
||
TTextPosition TDbCableDim::ReplaceSubText(const TTextPosition &posRep, const TCHAR *sRepText, TTextRange *pRange)
|
||
{
|
||
TDbText text;
|
||
TTextPosition posNext;
|
||
if (!sRepText || !GetText(posRep.m_nCookies, text))
|
||
return posNext;
|
||
|
||
posNext = text.ReplaceSubText(posRep, sRepText, pRange);
|
||
if (!posNext)
|
||
{
|
||
posNext.m_nCookies = posRep.m_nCookies + 1;
|
||
posNext.m_nTextPos = 0;
|
||
}
|
||
AcArray<SCableDimTextInfo> arTextInfo;
|
||
if(m_nDimEntType == eCableTray)
|
||
GetTextAndPt(arTextInfo);
|
||
else if (m_nDimEntType == eCableLay)
|
||
GetTextAndPtForLay(arTextInfo);
|
||
int nLen = arTextInfo.length();
|
||
if (nLen <= 0 || (int)posRep.m_nCookies >= nLen)
|
||
//return posNext;
|
||
return TTextPosition();
|
||
SCableDimTextInfo textInfoTmp = arTextInfo[posRep.m_nCookies];
|
||
textInfoTmp.sText = text.GetText();
|
||
arTextInfo.setAt(posRep.m_nCookies,textInfoTmp);
|
||
if(m_nDimEntType == eCableTray)
|
||
{
|
||
if (SetText(arTextInfo))
|
||
{
|
||
RenewCableLen();
|
||
return posNext;
|
||
}
|
||
else
|
||
return TTextPosition();
|
||
}
|
||
//else if (m_nDimEntType == eCableLay)
|
||
//SetTextForLay(arTextInfo);
|
||
return posNext;
|
||
}
|
||
|
||
BOOL TDbCableDim::SetText(const AcArray<SCableDimTextInfo>& arTextInfo)
|
||
{
|
||
if (arTextInfo.length() == 0)
|
||
return FALSE;
|
||
BOOL bAllSuc = TRUE;
|
||
if (m_nCurDwgVer >= 5)
|
||
{
|
||
AcDbObjectIdArray arTemp;
|
||
ReadReactorID(arTemp);
|
||
if (m_nLableStyle == eLableStyle3)//样式三存在两行文字,且第二行有且只有一项
|
||
{
|
||
if (2 * arTemp.length() != arTextInfo.length())
|
||
return FALSE;
|
||
for (int i = 0; i < arTemp.length(); ++i)
|
||
{
|
||
CString sText = arTextInfo[2 * i].sText + m_sLableFds + arTextInfo[2 * i + 1].sText;
|
||
if (!SetCableTrayString(arTemp[i],sText,0))
|
||
bAllSuc = FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (arTemp.length() != arTextInfo.length())
|
||
return FALSE;
|
||
for (int i = 0; i < arTemp.length(); ++i)
|
||
{
|
||
if (!SetCableTrayString(arTemp[i],arTextInfo[i].sText,0))
|
||
bAllSuc = FALSE;
|
||
}
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
if (m_arIds.length() != arTextInfo.length())
|
||
return FALSE;
|
||
int nIdIndex = 0;
|
||
AcDbObjectId idBefore;
|
||
idBefore.setNull();
|
||
if (m_nLableStyle == eLableStyle3)//样式三存在两行文字,且第二行有且只有一项
|
||
{
|
||
if (2 * m_arIds.length() != arTextInfo.length())
|
||
return FALSE;
|
||
for (int i = 0; i < m_arIds.length(); ++i)
|
||
{
|
||
if (!idBefore.isNull() && idBefore == m_arIds[i])
|
||
nIdIndex++;
|
||
else
|
||
nIdIndex = 0;
|
||
CString sText = arTextInfo[2 * i].sText + m_sLableFds + arTextInfo[2 * i + 1].sText;
|
||
if(!SetCableTrayString(m_arIds[i],sText,nIdIndex))
|
||
bAllSuc = FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (m_arIds.length() != arTextInfo.length())
|
||
return FALSE;
|
||
for (int i = 0; i < m_arIds.length(); ++i)
|
||
{
|
||
if (!idBefore.isNull() && idBefore == m_arIds[i])
|
||
nIdIndex++;
|
||
else
|
||
nIdIndex = 0;
|
||
if(!SetCableTrayString(m_arIds[i],arTextInfo[i].sText,nIdIndex))
|
||
bAllSuc = FALSE;
|
||
}
|
||
}
|
||
}
|
||
return bAllSuc;
|
||
}
|
||
|
||
void TDbCableDim::SetSubText(long i,CString sText)
|
||
{
|
||
if (sText.IsEmpty())
|
||
return;
|
||
AcArray<SCableDimTextInfo> arTextInfo;
|
||
if(m_nDimEntType == eCableTray)
|
||
GetTextAndPt(arTextInfo);
|
||
else if (m_nDimEntType == eCableLay)
|
||
GetTextAndPtForLay(arTextInfo);
|
||
int nLen = arTextInfo.length();
|
||
if (nLen <= 0 || i >= nLen)
|
||
return;
|
||
SCableDimTextInfo textInfoTmp = arTextInfo[i];
|
||
textInfoTmp.sText = sText;
|
||
arTextInfo.setAt(i,textInfoTmp);
|
||
if(m_nDimEntType == eCableTray)
|
||
SetText(arTextInfo);
|
||
//else if (m_nDimEntType == eCableLay)
|
||
//SetTextForLay(arTextInfo);
|
||
}
|
||
|
||
BOOL TDbCableDim::GetText( Adesk::UInt32 cookies,TDbText &text) const
|
||
{
|
||
CString sText;
|
||
AcGePoint3d pt;
|
||
if (m_nDimEntType == eCableTray)
|
||
{
|
||
AcArray<SCableDimTextInfo> arTextInfo;
|
||
GetTextAndPt(arTextInfo);
|
||
int nLen = arTextInfo.length();
|
||
if (nLen <= 0 || (int)cookies >= nLen)
|
||
return FALSE;
|
||
sText = arTextInfo[cookies].sText;
|
||
pt = arTextInfo[cookies].pt;
|
||
}
|
||
else if (m_nDimEntType == eCableLay)
|
||
{
|
||
AcArray<SCableDimTextInfo> arTextInfoForLay;
|
||
GetTextAndPtForLay(arTextInfoForLay);
|
||
int nLen = arTextInfoForLay.length();
|
||
if (nLen <= 0 || (int)cookies >= nLen)
|
||
return FALSE;
|
||
sText = arTextInfoForLay[cookies].sText;
|
||
pt = arTextInfoForLay[cookies].pt;
|
||
}
|
||
text.setPropertiesFrom(this);
|
||
text.SetText((const TCHAR*)sText);
|
||
text.SetStyleId(m_idTextStyle);
|
||
text.SetHeight(m_nTextHeight);
|
||
text.SetRotation(m_nTextRotation);
|
||
text.SetLocation(pt);
|
||
return TRUE;
|
||
}
|
||
|
||
void TDbCableDim::GetTextAndPt(AcArray<SCableDimTextInfo>& arTextInfo) const
|
||
{
|
||
double dTextDistP = m_dTextRowDis;
|
||
AcDbText *pText = NULL;
|
||
CString sText;
|
||
AcGePoint3d ptTextT = m_ptTurn;
|
||
AcGeVector3d vtDir = m_vtDir;
|
||
if (vtDir.isZeroLength())
|
||
vtDir = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
vtDir.normalize();
|
||
AcDbObjectId idStyle = m_idTextStyle;
|
||
|
||
int nType = m_nLableStyle;
|
||
double dTextLen = m_dLineBaseLen * GetPScale(),dHeight = m_nTextHeight;
|
||
|
||
if (vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) > PI/2)
|
||
{
|
||
ptTextT += (dTextLen - (dHeight / 2)*GetPScale())*vtDir;
|
||
}
|
||
else
|
||
{
|
||
ptTextT += vtDir*(dHeight / 2)*GetPScale();
|
||
}
|
||
|
||
AcGeVector3d vtLableDir = m_vtDir;
|
||
vtLableDir.normalize();
|
||
AcGePoint3d ptGe1 = m_ptTurn;
|
||
AcGePoint3d ptGe2 = m_ptS;
|
||
BOOL bChangeType3 = FALSE;
|
||
//绘制方格
|
||
if (ptGe1.y > ptGe2.y)
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
|
||
ptTextT.y += dHeight*GetPScale()*0.25;
|
||
}
|
||
else
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
|
||
ptTextT.y += dHeight*GetPScale()*0.25;
|
||
if (nType != eLableStyle2)
|
||
{
|
||
if (nType == eLableStyle1)
|
||
ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
else
|
||
ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
}
|
||
|
||
if (nType == eLableStyle3)
|
||
bChangeType3 = TRUE;
|
||
}
|
||
|
||
if (nType == eLableStyle1)
|
||
ptTextT.y += dHeight*GetPScale()*((1 + 0.5)*dTextDistP - 1) / 2 - dHeight*GetPScale()*0.25;
|
||
|
||
int nIdIndex = 0;
|
||
AcDbObjectId idBefore;
|
||
idBefore.setNull();
|
||
AcDbObjectIdArray arTemp;
|
||
CStringArray arTexts,arNames;
|
||
arTextInfo.removeAll();
|
||
SCableDimTextInfo dimTextInfo;
|
||
if (m_nCurDwgVer >= 5)
|
||
{
|
||
ReadReactorID(arTemp);
|
||
if (arTemp.length() == 0)
|
||
{
|
||
return;
|
||
}
|
||
for (int i = 0; i < arTemp.length(); ++i)
|
||
{
|
||
GetTextString(arTemp[i],sText,0);
|
||
if (!sText.IsEmpty())
|
||
{
|
||
arTexts.Add(sText);
|
||
}
|
||
}
|
||
for(int i = 0;i < arTexts.GetSize();++i)
|
||
{
|
||
sText = arTexts[i];
|
||
dTextLen = GetTextLen(sText);
|
||
|
||
if (nType != eLableStyle3)
|
||
{
|
||
dimTextInfo.pt = ptTextT;
|
||
dimTextInfo.sText = sText;
|
||
arTextInfo.append(dimTextInfo);
|
||
}
|
||
|
||
ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
|
||
//样式三则存在两行文字
|
||
if (nType == eLableStyle3)
|
||
{
|
||
CString sText1,sText2;
|
||
AcGePoint3d ptText1,ptText2;
|
||
int nFind = -1;
|
||
if (m_nCurDwgVer >= 5) // 桥架标注样式三调整
|
||
{
|
||
CString sFds = m_sLableFds;
|
||
int nFdsLen = sFds.GetLength();
|
||
char* pch = NULL;
|
||
pch= (char*)sFds.GetBuffer(1);
|
||
nFind = sText.ReverseFind(*pch);
|
||
|
||
}
|
||
else
|
||
nFind = sText.ReverseFind(_T(','));
|
||
if (nFind != -1)
|
||
{
|
||
ptText2 = ptTextT;
|
||
ptText1 = ptTextT;
|
||
int nFdsLen = m_sLableFds.GetLength();
|
||
sText1 = sText.Left(nFind);
|
||
sText2 = sText.Mid(nFind + 1);
|
||
//判断是否需要调整位置
|
||
AcGeVector3d vtXT = m_vtDir;
|
||
//如果标注方向为向左
|
||
if (vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) > PI/2)
|
||
{
|
||
vtXT *= -1;
|
||
}
|
||
if (bChangeType3)
|
||
{
|
||
ptText2 -= dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
ptText1 = ptText2 - dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
ptText2 += vtXT*(GetTextLen(sText1)/2 - GetTextLen(sText2)/2);
|
||
}
|
||
else
|
||
{
|
||
ptText1 -= dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
ptText2 = ptText1 - dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
ptText2 += vtXT*(GetTextLen(sText1)/2 - GetTextLen(sText2)/2);
|
||
}
|
||
|
||
dimTextInfo.pt = ptText1;
|
||
dimTextInfo.sText = sText1;
|
||
arTextInfo.append(dimTextInfo);
|
||
dimTextInfo.pt = ptText2;
|
||
dimTextInfo.sText = sText2;
|
||
arTextInfo.append(dimTextInfo);
|
||
|
||
ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
for (int i = 0; i < m_arIds.length(); ++i)
|
||
{
|
||
if (!idBefore.isNull() && idBefore == m_arIds[i])
|
||
nIdIndex++;
|
||
else
|
||
nIdIndex = 0;
|
||
GetTextString(m_arIds[i],sText,nIdIndex);
|
||
|
||
idBefore = m_arIds[i];
|
||
dTextLen = GetTextLen(sText);
|
||
|
||
if (nType != eLableStyle3)
|
||
{
|
||
dimTextInfo.pt = ptTextT;
|
||
dimTextInfo.sText = sText;
|
||
arTextInfo.append(dimTextInfo);
|
||
}
|
||
|
||
ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
|
||
//样式三则存在两行文字
|
||
if (nType == eLableStyle3)
|
||
{
|
||
CString sText1,sText2;
|
||
AcGePoint3d ptText1,ptText2;
|
||
int nFind = sText.ReverseFind(_T(','));
|
||
if (nFind != -1)
|
||
{
|
||
ptText2 = ptTextT;
|
||
ptText1 = ptTextT;
|
||
|
||
sText1 = sText.Left(nFind);
|
||
sText2 = sText.Mid(nFind + 1);
|
||
//判断是否需要调整位置
|
||
AcGeVector3d vtXT = m_vtDir;
|
||
//如果标注方向为向左
|
||
if (vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) > PI/2)
|
||
{
|
||
vtXT *= -1;
|
||
}
|
||
// vtXT = Wcs2Ucs(vtXT);
|
||
if (bChangeType3)
|
||
{
|
||
ptText2 -= dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
ptText1 = ptText2 - dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
ptText2 += vtXT*(GetTextLen(sText1)/2 - GetTextLen(sText2)/2);
|
||
}
|
||
else
|
||
{
|
||
ptText1 -= dHeight*GetPScale()*(1 + 0.5)*vtLableDir*dTextDistP;
|
||
ptText2 = ptText1 - dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
ptText2 += vtXT*(GetTextLen(sText1)/2 - GetTextLen(sText2)/2);
|
||
}
|
||
dimTextInfo.pt = ptText1;
|
||
dimTextInfo.sText = sText1;
|
||
arTextInfo.append(dimTextInfo);
|
||
dimTextInfo.pt = ptText2;
|
||
dimTextInfo.sText = sText2;
|
||
arTextInfo.append(dimTextInfo);
|
||
|
||
ptTextT += dHeight*GetPScale()*(1 + 0.5)*vtLableDir;
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
void TDbCableDim::GetTextAndPtForLay(AcArray<SCableDimTextInfo>& arTextInfoForLay) const
|
||
{
|
||
double dTextDistP = m_dTextRowDis,dHeight = m_nTextHeight;
|
||
double dRowHeight = dHeight*GetPScale()*(1 + 0.5)*dTextDistP;
|
||
AcGePoint3d ptTextT,ptTemp;
|
||
AcGePoint3dArray arPts;
|
||
//横方向
|
||
AcGeVector3d vtDir = m_vtDir;
|
||
if (vtDir.isZeroLength())
|
||
vtDir = TSysCoordinateTool::GetCurrentViewWCSKXAxis();
|
||
vtDir.normalize();
|
||
int nType = m_nLableStyle;
|
||
ptTextT += vtDir*(dHeight / 2)*GetPScale();
|
||
int nStaCol = 0;
|
||
if (vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) > PI/2)
|
||
{
|
||
double dWidth = 0.0;
|
||
for (int i = 0;i < m_arRowWidth.length();++i)
|
||
{
|
||
dWidth += m_arRowWidth[i];
|
||
ptTemp = m_ptTurn + vtDir * dWidth;
|
||
ptTemp -= vtDir*(dHeight / 2)*GetPScale();
|
||
arPts.append(ptTemp);
|
||
}
|
||
nStaCol = arPts.length() - 1;
|
||
}
|
||
else
|
||
{
|
||
double dWidth = 0.0;
|
||
for (int i = 0;i < m_arRowWidth.length();++i)
|
||
{
|
||
ptTemp = m_ptTurn + vtDir * dWidth;
|
||
ptTemp += vtDir*(dHeight / 2)*GetPScale();
|
||
arPts.append(ptTemp);
|
||
dWidth += m_arRowWidth[i];
|
||
}
|
||
}
|
||
//纵方向
|
||
AcGeVector3d vtLableDir = m_vtDir;
|
||
vtLableDir.normalize();
|
||
AcGePoint3d ptGe1 = m_ptTurn;
|
||
AcGePoint3d ptGe2 = m_ptS;
|
||
|
||
int nStatRow = 0;
|
||
if (ptGe1.y > ptGe2.y)
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
}
|
||
else
|
||
{
|
||
if (m_vtDir.angleTo(TSysCoordinateTool::GetCurrentViewWCSKXAxis()) < PI/2)
|
||
vtLableDir.rotateBy(-PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
else
|
||
vtLableDir.rotateBy(PI/2,TSysCoordinateTool::GetCurrentViewWCSKZAxis());
|
||
|
||
nStatRow = 1;
|
||
if (!m_sSign.IsEmpty())
|
||
{
|
||
nStatRow = 2;
|
||
}
|
||
}
|
||
if (nType == eLableStyle1)
|
||
ptTextT.y += dHeight*GetPScale()*((1 + 0.5)*dTextDistP - 1) / 2 - dHeight*GetPScale()*0.25;
|
||
|
||
int nIdIndex = 0;
|
||
AcDbObjectId idBefore;
|
||
idBefore.setNull();
|
||
AcDbObjectIdArray arTemp;
|
||
ReadReactorID(arTemp);
|
||
if (arTemp.length() == 0)
|
||
return;
|
||
CStringArray arTexts,arNames;
|
||
//电缆标注
|
||
CString sText;
|
||
//ReadXData(arTemp[0],CABLELAY_XDATA_NAME,arNames);
|
||
ReadXData(arTemp[0],GetName(m_bIsMulitCableLayDim),arNames);
|
||
//modify end
|
||
for (int j = 0;j < arNames.GetSize();++j)
|
||
{
|
||
GetTextString(arTemp[0],sText,j);
|
||
if (!sText.IsEmpty())
|
||
{
|
||
arTexts.Add(sText);
|
||
}
|
||
}
|
||
int nCol = m_arRowWidth.length();
|
||
if (nCol == 0)
|
||
return;
|
||
int nCount = arNames.GetSize();
|
||
int nRow = (int)ceil((double)nCount / (double)nCol);
|
||
int nCurCol = 0;
|
||
arTextInfoForLay.removeAll();
|
||
SCableDimTextInfo dimTextInfo;
|
||
for(int i = 0;i < arTexts.GetSize();++i)
|
||
{
|
||
sText = arTexts[i];
|
||
nCurCol = i / nRow;
|
||
ptTextT = arPts[nCurCol];
|
||
ptTextT.y += dHeight*GetPScale()*0.25;
|
||
ptTextT += dRowHeight * vtLableDir * (i % nRow + nStatRow);
|
||
if (nType != eLableStyle3)
|
||
{
|
||
dimTextInfo.pt = ptTextT;
|
||
dimTextInfo.sText = sText;
|
||
arTextInfoForLay.append(dimTextInfo);
|
||
}
|
||
}
|
||
if (!m_sSign.IsEmpty())
|
||
{
|
||
//表头
|
||
ptTextT = arPts[nStaCol];
|
||
ptTextT.y += dHeight*GetPScale()*0.25;
|
||
|
||
if (nStatRow == 0)
|
||
ptTextT += dRowHeight * vtLableDir * nRow;
|
||
else
|
||
ptTextT += dRowHeight * vtLableDir;
|
||
dimTextInfo.pt = ptTextT;
|
||
dimTextInfo.sText = m_sSign;
|
||
arTextInfoForLay.append(dimTextInfo);
|
||
}
|
||
}
|
||
|
||
//得到s中double值,该double值的小数点位数以nValidBit为准
|
||
double TDbCableDim::HoldValidBit(const Adesk::UInt16& nValidBit,const CString& s)
|
||
{
|
||
CString sTmp = s;
|
||
double d = _ttof(sTmp);
|
||
sTmp.Format(_T("%.*f"),nValidBit,d);
|
||
d = _ttof(sTmp);
|
||
return d;
|
||
}
|
||
|
||
//得到sSrc基于0的位于nStartPos和nEndPos之间的字符串(包括nStartPos和nEndPos),
|
||
//若nEndPos >= sSrc.GetLength(),则返回nStartPos到sSrc末尾的字符串
|
||
//如sSrc = _T("abcde"),nStartPos = 1,nEndPos = 2,则返回_T("bc")
|
||
CString TDbCableDim::GetMidStr(const CString& sSrc,const int& nStartPos,const int& nEndPos)
|
||
{
|
||
if (nStartPos > nEndPos || nStartPos < 0 || nStartPos >= sSrc.GetLength())
|
||
return _T("");
|
||
int nEndPosCopy = nEndPos;
|
||
if (nEndPosCopy >= sSrc.GetLength())
|
||
nEndPosCopy = sSrc.GetLength() - 1;
|
||
return sSrc.Mid(nStartPos,nEndPosCopy - nStartPos + 1);
|
||
}
|
||
//sClapDataOld 是形如“200*A;100*B;”,sClapDataNew是形如"(300+200)*150";
|
||
//sClapDataGet是形如"300*A;200*B",dHGet是“150”
|
||
void TDbCableDim::GetClapDataStr(const CString& sClapDataOld,const CString& sClapDataNew,CString& sClapDataGet,double& dHGet,double& dBGet)
|
||
{
|
||
if(sClapDataOld.IsEmpty() || sClapDataNew.IsEmpty())
|
||
return;
|
||
CString sClapDataOldTmp = sClapDataOld,sClapDataNewTmp = sClapDataNew;
|
||
CString sTmp,sTmp2;
|
||
CStringArray arSTmp,arTemp1,arTemp2;
|
||
SplitValue(sClapDataOldTmp,KEY_CLP_MAIN_KEY,arTemp1);
|
||
for(int i = 0;i < arTemp1.GetSize();i++)
|
||
{
|
||
SplitValue(arTemp1[i],SPEC_CHAR,arTemp2);
|
||
for (int j = 0;j < arTemp2.GetSize();j++)
|
||
{
|
||
if (arTemp2.GetSize() >= 2)
|
||
{
|
||
arSTmp.Add(arTemp2[1]);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
//此时arSTmp[0]为“A”,arSTmp[1]为“B”
|
||
arTemp2.RemoveAll();
|
||
SplitValue(sClapDataNewTmp,_T("+"),arTemp1);
|
||
//arTemp1[0]为“(300”,arTemp1[2]为“200)*150”
|
||
int nLen = arTemp1.GetSize();
|
||
if (nLen >= 2)
|
||
{
|
||
sTmp = arTemp1[0];
|
||
if (sTmp.GetLength() > 1)
|
||
sTmp = sTmp.Right(sTmp.GetLength() - 1);//去掉“(300”中的“(”
|
||
arTemp2.Add(sTmp);//得到“300”
|
||
|
||
for(int i = 1;i < nLen-1;i++)
|
||
arTemp2.Add(arTemp2[i]);
|
||
sTmp = arTemp1[nLen - 1];
|
||
int nFind = sTmp.Find(_T(")*"));
|
||
if (nFind != -1)
|
||
{
|
||
arTemp2.Add(GetMidStr(sTmp,0,nFind -1));//得到“200”
|
||
dHGet = HoldValidBit(0,GetMidStr(sTmp,nFind + 2,sTmp.GetLength()));//得到“150”
|
||
}
|
||
}
|
||
|
||
sClapDataGet = _T("");
|
||
dBGet = 0;
|
||
if (arSTmp.GetSize() > 0 && arSTmp.GetSize() == arTemp2.GetSize())
|
||
{
|
||
for(int i = 0;i < arSTmp.GetSize();i++)
|
||
{
|
||
sTmp.Format(_T("%s%s%s%s"),arTemp2[i],SPEC_CHAR,arSTmp[i],KEY_CLP_MAIN_KEY);
|
||
sClapDataGet += sTmp;
|
||
dBGet += HoldValidBit(0,arTemp2[i]);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
//设置桥架文字内容
|
||
BOOL TDbCableDim::SetCableTrayString(const AcDbObjectId &id,const CString &sText,const int& nIndex)
|
||
{
|
||
BOOL bSuc = FALSE;
|
||
CString sTextOld;
|
||
GetCableTrayString(id,sTextOld);
|
||
if (sTextOld.CompareNoCase(sText) == 0)
|
||
return TRUE;
|
||
CString sTextCopy = sText;
|
||
CStringArray arTmp,arTmp1,arTmp2;
|
||
CString sTmp,sTmp1,sTmp2;
|
||
if (m_nCurDwgVer >= 5)
|
||
{
|
||
SplitValue(sTextCopy,m_sLableFds,arTmp1);
|
||
SplitValue(sTextOld,m_sLableFds,arTmp2);
|
||
}
|
||
else
|
||
{
|
||
SplitValue(sTextCopy,_T(","),arTmp1);
|
||
SplitValue(sTextOld,_T(","),arTmp2);
|
||
}
|
||
if(arTmp1.GetSize() != arTmp2.GetSize())
|
||
{
|
||
if (m_nCurDwgVer >= 5)
|
||
sTmp.Format(_T("请勿更改分隔符'%s'的数量!\n"),m_sLableFds);
|
||
else
|
||
sTmp.Format(_T("请勿更改分隔符','的数量!\n"));
|
||
ads_prompt(sTmp);
|
||
return bSuc;
|
||
}
|
||
double dHeight = m_nTextHeight;
|
||
AcDbEntity *pEnt = NULL;
|
||
AcGePoint3d ptS,ptM,ptE;
|
||
double dB = 0.0,dH = 0.0,dElv = 0.0,dL = 0.0,dB1 = 0.0,dB2 = 0.0,dH1 = 0.0,dH2 = 0.0;
|
||
CString sType,sNumber,sClapData,sClapData2;
|
||
CString sSys;//系统分类 lsd 2013-8-26
|
||
int nRunTime = -1,nStyle = 0,nClap = 0;
|
||
double dElS = 0.0;
|
||
double dElE = 0.0;
|
||
|
||
BOOL bInClinePipe = FALSE;
|
||
ads_command(RTSTR, _T(".UNDO"), RTSTR, _T("MARK"), RTNONE);
|
||
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForWrite) != Acad::eOk)
|
||
return bSuc;
|
||
TDbPipeBase *pPipe = TDbPipeBase::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_TYPE,sType);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_START,ptS);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_END,ptE);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_B,dB);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_H,dH);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_RUNTIME,nRunTime);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_STYLE,nStyle);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_NO,sNumber);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_HAVE_CLAPBOARD,nClap);
|
||
pPipe->GetSpecialtyData()->GetAt(KEY_CLAPBOARD_DATA,sClapData);
|
||
pPipe->GetSpecialtyData()->GetAt(_T("Cabletray_Layer"), sSys);
|
||
dL = ptS.distanceTo(ptE) / 1000;
|
||
if (ptE.z > ptS.z)
|
||
dElv = ptE.z;
|
||
else
|
||
dElv = ptS.z;
|
||
dElv /= 1000;
|
||
dElS = ptS.z / 1000;
|
||
dElE = ptE.z / 1000;
|
||
if (fabs(ptE.z - ptS.z) > 1e-3)
|
||
bInClinePipe = TRUE;
|
||
}
|
||
TDbFittingBase *pFit = TDbFittingBase::cast(pEnt);
|
||
if (pFit != NULL)
|
||
{
|
||
pFit->GetSpecialtyData()->GetAt(KEY_TYPE,sType);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_MID,ptM);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_START,ptS);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_END,ptE);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_B,dB);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_H,dH);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_B1,dB1);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_H1,dH1);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_B2,dB2);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_H2,dH2);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_RUNTIME,nRunTime);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_STYLE,nStyle);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_HAVE_CLAPBOARD,nClap);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_CLAPBOARD_DATA,sClapData);
|
||
pFit->GetSpecialtyData()->GetAt(_T("Cabletray_Layer"), sSys);
|
||
pFit->GetSpecialtyData()->GetAt(KEY_CLAPBOARD_DATA2,sClapData2);
|
||
if (nRunTime == TDb::eReduce || nRunTime == TDb::eOffset)
|
||
dElv = ptS.z / 1000;
|
||
else
|
||
dElv = ptM.z / 1000;
|
||
}
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//本段需与参照GetCableTrayString()方法保持一致,来获得分割后每个字符串所代表的意义
|
||
CString sLABLE_ELV,sLABLE_LEN,sLABLE_SPECS,sLABLE_TYPE,sLABLE_SYS_TYPE;
|
||
//LABLE_ELV
|
||
sLABLE_ELV.Format(_T("H=%.*fm"),m_nValidBit,dElv);
|
||
if (bInClinePipe)
|
||
sLABLE_ELV.Format(_T("H=%.*fm--%.*fm"),m_nValidBit,dElS,m_nValidBit,dElE);
|
||
//LABLE_LEN
|
||
sLABLE_LEN.Format(_T("L=%.*fm"),m_nValidBit,dL);
|
||
//LABLE_SPECS
|
||
//mod liaoy 170609
|
||
/*
|
||
AcArray<double> arB, arH;
|
||
arB.append(dB);
|
||
arB.append(dB1);
|
||
arB.append(dB2);
|
||
arH.append(dH);
|
||
arH.append(dH1);
|
||
arH.append(dH2);
|
||
sLABLE_SPECS = GetCableTrayStringSpecs(arB,arH,nClap,nRunTime,sClapData,sClapData2);
|
||
*/
|
||
TCableTrayFittingTool tool(pEnt);
|
||
sLABLE_SPECS = tool.GetSpec(SPEC_CHAR);
|
||
//mod end
|
||
//LABLE_TYPE
|
||
switch(nStyle)
|
||
{
|
||
case 0://槽式MR
|
||
sLABLE_TYPE = _T("MR");
|
||
break;
|
||
case 1://盘式CT
|
||
sLABLE_TYPE = _T("CT");
|
||
break;
|
||
case 2://梯式CL
|
||
sLABLE_TYPE = _T("CL");
|
||
break;
|
||
}
|
||
//LABLE_SYS_TYPE
|
||
sLABLE_SYS_TYPE = GetCableTrayStringSysType(sSys);
|
||
//////////////////////////////////////////////////////////////////////////
|
||
for (int j = 0; j < arTmp1.GetSize(); ++j)
|
||
{
|
||
sTmp1 = arTmp1[j];
|
||
sTmp2 = arTmp2[j];
|
||
if (sTmp1.CompareNoCase(sTmp2) == 0)
|
||
continue;
|
||
if (sTmp2.CompareNoCase(sNumber) == 0)//LABLE_NAME
|
||
{
|
||
MakeSureModify();
|
||
sNumber = sTmp1;
|
||
bSuc = TRUE;
|
||
}
|
||
else if (sTmp2.CompareNoCase(sType) == 0)//LABLE_MODAL
|
||
{
|
||
MakeSureModify();
|
||
sType = sTmp1;
|
||
bSuc = TRUE;
|
||
}
|
||
else if (sTmp2.CompareNoCase(sLABLE_ELV) == 0)//LABLE_ELV
|
||
{
|
||
if(!bInClinePipe)
|
||
{
|
||
if (sTmp1.GetLength() >= 3)
|
||
{
|
||
sTmp1.Delete(0,2);//删除最开始的“H=”
|
||
sTmp1.Delete(sTmp1.GetLength() - 1);//删除最后的“m”
|
||
dElv = HoldValidBit(m_nValidBit,sTmp1);
|
||
bSuc = TRUE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
int nPos1 = sTmp1.Find(_T("H="));
|
||
int nPos2 = sTmp1.Find(_T("m--"));
|
||
int nPos3 = sTmp1.ReverseFind(_T('m'));
|
||
dElS = HoldValidBit(m_nValidBit,GetMidStr(sTmp1,nPos1 + 2,nPos2 - 1));
|
||
dElE = HoldValidBit(m_nValidBit,GetMidStr(sTmp1,nPos2 + 3,nPos3 - 1));
|
||
bSuc = TRUE;
|
||
}
|
||
}
|
||
else if (sTmp2.CompareNoCase(sLABLE_LEN) == 0)//LABLE_LEN
|
||
{
|
||
if (sTmp1.GetLength() >= 3)
|
||
{
|
||
sTmp1.Delete(0,2);//删除最开始的“L=”
|
||
sTmp1.Delete(sTmp1.GetLength() - 1);//删除最后的“m”
|
||
dL = HoldValidBit(m_nValidBit,sTmp1);
|
||
bSuc = TRUE;
|
||
}
|
||
}
|
||
else if (sTmp2.CompareNoCase(sLABLE_SPECS) == 0)//LABLE_SPECS
|
||
{
|
||
MakeSureModify();
|
||
TCableTrayFittingTool tool(pEnt);
|
||
bSuc = tool.SetSpec(sTmp1,SPEC_CHAR);
|
||
/*
|
||
bSuc = TRUE;
|
||
int nPos = sTmp1.Find(SPEC_CHAR);
|
||
if (nPos != -1)
|
||
{
|
||
dB = HoldValidBit(0,GetMidStr(sTmp1,0,nPos - 1));
|
||
dH = HoldValidBit(0,GetMidStr(sTmp1,nPos+1,sTmp1.GetLength()));
|
||
}
|
||
if (nClap && !sClapData.IsEmpty() && nRunTime != TDb::eReduce)
|
||
{
|
||
GetClapDataStr(sClapData,sTmp1,sClapData,dH,dB);
|
||
}
|
||
if (nRunTime == TDb::eReduce)
|
||
{
|
||
CStringArray arSTmp,arTemp1,arTemp2;
|
||
AcArray<double> arDTmp;
|
||
if (sClapData.IsEmpty() && sClapData2.IsEmpty())
|
||
{
|
||
SplitValue(sTmp1,_T("-"),arTemp1);
|
||
for (int i = 0;i < arTemp1.GetSize();i++)
|
||
{
|
||
SplitValue(arTemp1[i],SPEC_CHAR,arTemp2);
|
||
for (int j = 0;j < arTemp1.GetSize();j++)
|
||
arSTmp.Add(arTemp2[j]);
|
||
}
|
||
for (int i = 0;i < arSTmp.GetSize();i++)
|
||
arDTmp.append(HoldValidBit(0,arSTmp[i]));
|
||
if (arDTmp.length() >= 4)
|
||
{
|
||
dB1 = arDTmp[0];
|
||
dH1 = arDTmp[1];
|
||
dB2 = arDTmp[2];
|
||
dH2 = arDTmp[3];
|
||
}
|
||
}
|
||
else
|
||
{
|
||
CString sClapDataTmp,sClapData2Tmp;
|
||
SplitValue(sTmp1,_T("-"),arTemp1);
|
||
if (!sClapData.IsEmpty() || !sClapData2.IsEmpty())
|
||
{
|
||
if (arTemp1.GetSize() == 2)
|
||
{
|
||
sClapDataTmp = arTemp1[0];
|
||
sClapData2Tmp = arTemp1[1];
|
||
}
|
||
}
|
||
if (!sClapData.IsEmpty() && sClapData2.IsEmpty())
|
||
{
|
||
if (arTemp1.GetSize() == 1)
|
||
sClapDataTmp = arTemp1[0];
|
||
}
|
||
else if (sClapData.IsEmpty() && !sClapData2.IsEmpty())
|
||
{
|
||
if (arTemp1.GetSize() == 1)
|
||
sClapData2Tmp = arTemp1[1];
|
||
}
|
||
GetClapDataStr(sClapData,sClapDataTmp,sClapData,dH1,dB1);
|
||
GetClapDataStr(sClapData2,sClapData2Tmp,sClapData2,dH2,dB2);
|
||
dB = 0;
|
||
dH = 0;
|
||
}
|
||
}
|
||
*/
|
||
}
|
||
else if (sTmp2.CompareNoCase(sLABLE_TYPE) == 0)//LABLE_TYPE
|
||
{
|
||
bSuc = TRUE;
|
||
if(sTmp1.CompareNoCase(_T("MR")) == 0)
|
||
nStyle = 0;
|
||
else if(sTmp1.CompareNoCase(_T("CT")) == 0)
|
||
nStyle = 1;
|
||
else if(sTmp1.CompareNoCase(_T("CL")) == 0)
|
||
nStyle = 2;
|
||
else
|
||
{
|
||
ads_prompt(_T("只允许修改为“MR”或“CT”或“CL”!\n"));
|
||
bSuc = FALSE;
|
||
}
|
||
}
|
||
else if(sTmp2.CompareNoCase(sLABLE_SYS_TYPE) == 0)//LABLE_SYS_TYPE
|
||
{
|
||
ads_prompt(_T("不允许修改系统分类关键字!\n"));
|
||
bSuc = FALSE;
|
||
}
|
||
}
|
||
if (bSuc)
|
||
{
|
||
if (pPipe != NULL)
|
||
{
|
||
AcGeVector3d vt = ptE - ptS;
|
||
vt.normalize();
|
||
ptE = ptS + vt * dL * 1000;
|
||
if(bInClinePipe)
|
||
{
|
||
ptS.z = dElS * 1000;
|
||
ptE.z = dElE * 1000;
|
||
}
|
||
else
|
||
{
|
||
ptS.z = dElv * 1000;
|
||
ptE.z = dElv * 1000;
|
||
}
|
||
pPipe->GetSpecialtyData()->SetAt(KEY_TYPE,sType);
|
||
pPipe->GetSpecialtyData()->SetAt(KEY_START,ptS);
|
||
pPipe->GetSpecialtyData()->SetAt(KEY_END,ptE);
|
||
pPipe->GetSpecialtyData()->SetAt(KEY_B,dB);
|
||
pPipe->GetSpecialtyData()->SetAt(KEY_H,dH);
|
||
pPipe->GetSpecialtyData()->SetAt(KEY_RUNTIME,nRunTime);
|
||
pPipe->GetSpecialtyData()->SetAt(KEY_STYLE,nStyle);
|
||
pPipe->GetSpecialtyData()->SetAt(KEY_NO,sNumber);
|
||
pPipe->GetSpecialtyData()->SetAt(KEY_HAVE_CLAPBOARD,nClap);
|
||
pPipe->GetSpecialtyData()->SetAt(KEY_CLAPBOARD_DATA,sClapData);
|
||
pPipe->GetSpecialtyData()->SetAt(_T("Cabletray_Layer"), sSys);//lsd 2013-8-26 获取系统分类
|
||
pPipe->ReCreateByXDataMap();
|
||
if (fabs(ptE.z - ptS.z) > 1e-3)
|
||
bInClinePipe = TRUE;
|
||
}
|
||
if (pFit != NULL)
|
||
{
|
||
if (nRunTime == TDb::eReduce || nRunTime == TDb::eOffset)
|
||
ptS.z = dElv * 1000;
|
||
else
|
||
ptM.z = dElv * 1000;
|
||
pFit->GetSpecialtyData()->SetAt(KEY_TYPE,sType);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_MID,ptM);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_START,ptS);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_END,ptE);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_B,dB);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_H,dH);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_B1,dB1);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_H1,dH1);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_B2,dB2);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_H2,dH2);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_RUNTIME,nRunTime);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_STYLE,nStyle);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_HAVE_CLAPBOARD,nClap);
|
||
pFit->GetSpecialtyData()->SetAt(KEY_CLAPBOARD_DATA,sClapData);
|
||
pFit->GetSpecialtyData()->SetAt(_T("Cabletray_Layer"), sSys);
|
||
pFit->ReCreateByXDataMap();
|
||
}
|
||
}
|
||
pEnt->close();
|
||
pEnt = NULL;
|
||
return bSuc;
|
||
}
|
||
|
||
BOOL TDbCableDim::MakeSureModify()
|
||
{
|
||
if (m_nDimEntType == eCableTray)
|
||
ads_prompt(_T(" 此标注文字来自于所标注实体固有属性,修改此标注可能导致实体不能正确显示,修改完成后请手动输入“REGEN”命令!\n"));
|
||
else
|
||
ads_prompt(_T(" 此标注文字来自于所标注实体拓展数据,修改此标注可能导致实体不能正确显示,修改完成后请手动输入“REGEN”命令!\n"));
|
||
return TRUE;
|
||
}
|
||
//mod liaoy 170609 弃用
|
||
/*
|
||
CString TDbCableDim::GetCableTrayStringSpecs(AcArray<double> arB,AcArray<double> arH,int nClap,int nRunTime,CString sClapData,CString sClapData2) const
|
||
{
|
||
CString sTmp;
|
||
if (arB.length() < 3 || arH.length() < 3)
|
||
return sTmp;
|
||
double dB = arB[0],dB1 = arB[1],dB2 = arB[2];
|
||
double dH = arH[0],dH1 = arH[1],dH2 = arH[2];
|
||
sTmp.Format(_T("%.0f%s%.0f"),dB,SPEC_CHAR,dH);
|
||
if (nClap && !sClapData.IsEmpty() && nRunTime != TDb::eReduce)
|
||
{
|
||
CStringArray arTemp1,arTemp2;
|
||
CString sTemp = _T("(");
|
||
SplitValue(sClapData,KEY_CLP_MAIN_KEY,arTemp1);
|
||
for(int i = 0;i < arTemp1.GetSize();i++)
|
||
{
|
||
SplitValue(arTemp1[i],SPEC_CHAR,arTemp2);
|
||
for (int j = 0;j < arTemp2.GetSize();j++)
|
||
{
|
||
sTemp += arTemp2[0];
|
||
sTemp += _T("+");
|
||
break;
|
||
}
|
||
}
|
||
sTemp.TrimRight(_T("+"));
|
||
sTemp += _T(")");
|
||
sTmp.Format(_T("%s%s%g"),sTemp,SPEC_CHAR,dH);
|
||
}
|
||
if (nRunTime == TDb::eReduce)
|
||
{
|
||
sTmp.Format(_T("%.0f%s%.0f-%.0f%s%.0f"),dB1,SPEC_CHAR,dH1,dB2,SPEC_CHAR,dH2);
|
||
//CString sClapData2 = _T("");
|
||
//if (pFit)
|
||
// pFit->GetSpecialtyData()->GetAt(KEY_CLAPBOARD_DATA2,sClapData2);
|
||
CStringArray arTemp1,arTemp2;
|
||
CString sTmp1 = _T("(");
|
||
SplitValue(sClapData,KEY_CLP_MAIN_KEY,arTemp1);
|
||
for(int t = 0;t < arTemp1.GetSize();t++)
|
||
{
|
||
SplitValue(arTemp1[t],SPEC_CHAR,arTemp2);
|
||
for (int j = 0;j < arTemp2.GetSize();j++)
|
||
{
|
||
sTmp1 += arTemp2[0];
|
||
sTmp1 += _T("+");
|
||
break;
|
||
}
|
||
}
|
||
if (arTemp1.GetSize() != 0)
|
||
{
|
||
sTmp1.TrimRight(_T("+"));
|
||
sTmp1 += _T(")");
|
||
sTmp.Format(_T("%s%s%g"),sTmp1,SPEC_CHAR,dH1);
|
||
}
|
||
CString sTmp2 = _T("(");
|
||
SplitValue(sClapData2,KEY_CLP_MAIN_KEY,arTemp1);
|
||
for(int i = 0;i < arTemp1.GetSize();i++)
|
||
{
|
||
SplitValue(arTemp1[i],SPEC_CHAR,arTemp2);
|
||
for (int j = 0;j < arTemp2.GetSize();j++)
|
||
{
|
||
sTmp2 += arTemp2[0];
|
||
sTmp2 += _T("+");
|
||
break;
|
||
}
|
||
}
|
||
if (arTemp1.GetSize() != 0)
|
||
{
|
||
sTmp2.TrimRight(_T("+"));
|
||
sTmp2 += _T(")");
|
||
sTmp1.Format(_T("%s%s%g"),sTmp2,SPEC_CHAR,dH2);
|
||
sTmp += _T("-");
|
||
sTmp += sTmp1;
|
||
}
|
||
}
|
||
return sTmp;
|
||
}
|
||
*/
|
||
CString TDbCableDim::GetCableTrayStringSysType(CString sSys) const
|
||
{
|
||
CString sTmp;
|
||
//if (sSys.CompareNoCase(LAY_CABLETRAY) == 0)
|
||
// sTmp = m_sSysKeyForce;
|
||
//else if (sSys.CompareNoCase(LAY_CABLETRAY_FIRE) == 0)
|
||
// sTmp = m_sSysKeyFire;
|
||
//else if (sSys.CompareNoCase(LAY_CABLETRAY_WEAK) == 0)
|
||
// sTmp = m_sSysKeyWeak;
|
||
//else if(sSys.CompareNoCase(LAY_CABLETRAY_OTHER) == 0)
|
||
// sTmp = m_sSysKeyOther;
|
||
//else if (sSys.CollateNoCase(LAY_CABLETRAY_LIGH) == 0)
|
||
// sTmp = m_sSysKeyForce;
|
||
//else if (sSys.CompareNoCase(LAY_CABLETRAY_SECU) == 0)
|
||
// sTmp = m_sSysKeyWeak;
|
||
//else if (sSys.CompareNoCase(LAY_CABLETRAY_RADIO) == 0)
|
||
// sTmp = m_sSysKeyWeak;
|
||
//else if (sSys.CompareNoCase(LAY_CABLETRAY_CATV) == 0)
|
||
// sTmp = m_sSysKeyWeak;
|
||
//else if (sSys.CompareNoCase(LAY_CABLETRAY_PDS) == 0)
|
||
// sTmp = m_sSysKeyWeak;
|
||
if (sSys.CompareNoCase(LAY_CABLETRAY) == 0)
|
||
sTmp = GetSysKeyForce();
|
||
else if (sSys.CompareNoCase(LAY_CABLETRAY_FIRE) == 0)
|
||
sTmp = GetSysKeyFire();
|
||
else if (sSys.CompareNoCase(LAY_CABLETRAY_WEAK) == 0)
|
||
sTmp = GetSysKeyWeak();
|
||
else if(sSys.CompareNoCase(LAY_CABLETRAY_OTHER) == 0)
|
||
sTmp = GetSysKeyOther();
|
||
else if (sSys.CollateNoCase(LAY_CABLETRAY_LIGH) == 0)
|
||
sTmp = GetSysKeyForce();
|
||
else if (sSys.CompareNoCase(LAY_CABLETRAY_SECU) == 0)
|
||
sTmp = GetSysKeyWeak();
|
||
else if (sSys.CompareNoCase(LAY_CABLETRAY_RADIO) == 0)
|
||
sTmp = GetSysKeyWeak();
|
||
else if (sSys.CompareNoCase(LAY_CABLETRAY_CATV) == 0)
|
||
sTmp = GetSysKeyWeak();
|
||
else if (sSys.CompareNoCase(LAY_CABLETRAY_PDS) == 0)
|
||
sTmp = GetSysKeyWeak();
|
||
return sTmp;
|
||
}
|
||
/*
|
||
void TDbCableDim::SetTextForLay(const AcArray<SCableDimTextInfo>& arTextInfo)
|
||
{
|
||
AcDbObjectIdArray arTemp;
|
||
CStringArray arNames;
|
||
ReadReactorID(arTemp);
|
||
if (arTemp.length() == 0)
|
||
return;
|
||
ReadXData(arTemp[0],CABLELAY_XDATA_NAME,arNames);
|
||
if (m_sSign.IsEmpty())
|
||
{
|
||
if (arNames.GetSize() != arTextInfo.length())
|
||
return;
|
||
for (int j = 0;j < arNames.GetSize();++j)
|
||
{
|
||
SetCableLayString(arTemp[0],arTextInfo[j].sText,j);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (arNames.GetSize() + 1 != arTextInfo.length())
|
||
return;
|
||
for (int j = 0;j < arNames.GetSize();++j)
|
||
{
|
||
SetCableLayString(arTemp[0],arTextInfo[j].sText,j);
|
||
}
|
||
CString sText = arTextInfo[arNames.GetSize()].sText;
|
||
if (m_sSign.CompareNoCase(sText) != 0)
|
||
m_sSign = sText;
|
||
}
|
||
|
||
}
|
||
|
||
void TDbCableDim::SetTextForLay(const AcArray<SCableDimTextInfo>& arTextInfo)
|
||
{
|
||
AcDbObjectIdArray arTemp;
|
||
CStringArray arNames;
|
||
ReadReactorID(arTemp);
|
||
if (arTemp.length() == 0)
|
||
return;
|
||
ReadXData(arTemp[0],CABLELAY_XDATA_NAME,arNames);
|
||
if (m_sSign.IsEmpty())
|
||
{
|
||
if (arNames.GetSize() != arTextInfo.length())
|
||
return;
|
||
for (int j = 0;j < arNames.GetSize();++j)
|
||
{
|
||
SetCableLayString(arTemp[0],arTextInfo[j].sText,j);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (arNames.GetSize() + 1 != arTextInfo.length())
|
||
return;
|
||
for (int j = 0;j < arNames.GetSize();++j)
|
||
{
|
||
SetCableLayString(arTemp[0],arTextInfo[j].sText,j);
|
||
}
|
||
CString sText = arTextInfo[arNames.GetSize()].sText;
|
||
if (m_sSign.CompareNoCase(sText) != 0)
|
||
m_sSign = sText;
|
||
}
|
||
|
||
}
|
||
|
||
BOOL TDbCableDim::ReadXData(const AcDbEntity*pEnt, const TCHAR*szName,CString& sValue) const
|
||
{
|
||
if(!pEnt)
|
||
return FALSE;
|
||
BOOL bRet = FALSE;
|
||
resbuf *pRb = pEnt->xData(szName);
|
||
if (pRb != NULL)
|
||
{
|
||
resbuf* pTemp = pRb;
|
||
if (pTemp->rbnext != NULL)
|
||
{
|
||
pTemp = pTemp->rbnext;
|
||
if (pTemp->restype == 1000)
|
||
{
|
||
sValue = pTemp->resval.rstring;
|
||
bRet = TRUE;
|
||
}
|
||
}
|
||
ads_relrb(pRb);
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
BOOL TDbCableDim::ReadXData(const AcDbEntity*pEnt, const TCHAR*szName,AcGePoint3dArray& arPts) const
|
||
{
|
||
arPts.removeAll();
|
||
if(!pEnt)
|
||
return FALSE;
|
||
BOOL bRet = FALSE;
|
||
resbuf *pRb = pEnt->xData(szName);
|
||
if (pRb != NULL)
|
||
{
|
||
resbuf* pTemp = pRb->rbnext;
|
||
for (;pTemp!= NULL;pTemp = pTemp->rbnext)
|
||
{
|
||
if (pTemp->restype == AcDb::kDxfXdWorldXCoord)
|
||
{
|
||
AcGePoint3d pt;
|
||
pt.x = (pTemp->resval.rpoint)[0];
|
||
pt.y = (pTemp->resval.rpoint)[1];
|
||
pt.z = (pTemp->resval.rpoint)[2];
|
||
arPts.append(pt);
|
||
bRet = TRUE;
|
||
}
|
||
}
|
||
ads_relrb(pRb);
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
BOOL TDbCableDim::WriteXData(AcDbEntity *pEnt, const TCHAR*szName, const TCHAR*szValue) const
|
||
{
|
||
if(!pEnt)
|
||
return FALSE;
|
||
if(!XSymbolTable(_T("APPID"), szName))
|
||
ads_regapp(szName);
|
||
resbuf *pXData = ads_buildlist(1001, szName, 1000, szValue, NULL);
|
||
BOOL bRet = FALSE;
|
||
if (pEnt->setXData(pXData) == Acad::eOk)
|
||
bRet = TRUE;
|
||
ads_relrb(pXData);
|
||
return bRet;
|
||
}
|
||
|
||
//写拓展数据,nIndex:0表示修改程序名,n(n>0):表示修改程序名拓展数据链表的第n个
|
||
BOOL TDbCableDim::WriteXData(AcDbEntity *pEnt, const CString& sName, const CString& sValue,const int& nIndex) const
|
||
{
|
||
if(!pEnt || nIndex < 0)
|
||
return FALSE;
|
||
BOOL bRet = FALSE;
|
||
if (nIndex > 0)
|
||
{
|
||
resbuf *pRb = pEnt->xData(sName);
|
||
if (pRb != NULL)
|
||
{
|
||
resbuf* pTemp = pRb;
|
||
int nPos = -1;
|
||
while(pTemp != NULL)
|
||
{
|
||
nPos++;
|
||
if (nPos == nIndex)
|
||
{
|
||
delete pTemp->resval.rstring;
|
||
pTemp->resval.rstring = new TCHAR[sValue.GetLength()+1];
|
||
memset(pTemp->resval.rstring,0,sValue.GetLength()+1);
|
||
_tcscpy(pTemp->resval.rstring,sValue);
|
||
if (pEnt->setXData(pRb) == Acad::eOk)
|
||
{
|
||
bRet = TRUE;
|
||
break;
|
||
}
|
||
}
|
||
pTemp = pTemp->rbnext;
|
||
}
|
||
acutRelRb(pRb);
|
||
}
|
||
}
|
||
else if (nIndex == 0)
|
||
{
|
||
CString sData;
|
||
if (ReadXData(pEnt,sName,sData))
|
||
{
|
||
if (RemoveXData(pEnt,sName))
|
||
WriteXData(pEnt,sValue,sData);
|
||
}
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
BOOL TDbCableDim::RemoveXData(AcDbEntity* pEnt, LPCTSTR pszAppName) const
|
||
{
|
||
if (pEnt == NULL || pszAppName == NULL)
|
||
{
|
||
return FALSE;
|
||
}
|
||
acdbRegApp(pszAppName);
|
||
struct resbuf* pRb = acutNewRb(AcDb::kDxfRegAppName);
|
||
if (Acad::eOk != acutNewString(pszAppName, pRb->resval.rstring))
|
||
{
|
||
acutRelRb(pRb);
|
||
return FALSE;
|
||
}
|
||
pRb->rbnext = NULL;
|
||
Acad::ErrorStatus es = pEnt->setXData(pRb);
|
||
acutRelRb(pRb);
|
||
return (es == Acad::eOk);
|
||
}
|
||
|
||
void TDbCableDim::UpdateOtherXData(AcDbEntity* pEnt,const CString& sNum,const CString& sSpe,const int& nIndex)
|
||
{
|
||
if ( pEnt == NULL || (sNum.IsEmpty() && sSpe.IsEmpty()) )
|
||
return;
|
||
CString sTmp,sNumCopy = sNum,sNumOld;
|
||
int nFind = -1;
|
||
if (!sNum.IsEmpty() && sSpe.IsEmpty())
|
||
{
|
||
if(ReadXData(pEnt,CABLELAY_XDATA_NAME,sNumOld))
|
||
WriteXData(pEnt,CABLELAY_XDATA_NAME,sNum,nIndex + 1);
|
||
if(ReadXData(pEnt,CABLELAY_XDATA_SPE,sTmp))
|
||
{
|
||
nFind = sTmp.Find(SPEC_CHAR);
|
||
if(nFind != -1)
|
||
WriteXData(pEnt,CABLELAY_XDATA_SPE,sNum + GetMidStr(sTmp,nFind,sTmp.GetLength()));
|
||
}
|
||
}
|
||
else if (sNum.IsEmpty() && !sSpe.IsEmpty())
|
||
{
|
||
if(ReadXData(pEnt,CABLELAY_XDATA_NAME,sNumOld))
|
||
{
|
||
nFind = sSpe.Find(SPEC_CHAR);
|
||
if(nFind != -1)
|
||
{
|
||
sNumCopy = GetMidStr(sSpe,0,nFind - 1);
|
||
WriteXData(pEnt,CABLELAY_XDATA_NAME,sNumCopy,nIndex + 1);
|
||
}
|
||
}
|
||
if(ReadXData(pEnt,CABLELAY_XDATA_SPE,sTmp))
|
||
WriteXData(pEnt,CABLELAY_XDATA_SPE,sSpe);
|
||
}
|
||
else if (!sNum.IsEmpty() && !sSpe.IsEmpty())
|
||
{
|
||
if(ReadXData(pEnt,CABLELAY_XDATA_NAME,sNumOld))
|
||
WriteXData(pEnt,CABLELAY_XDATA_NAME,sNum,nIndex + 1);
|
||
if(ReadXData(pEnt,CABLELAY_XDATA_SPE,sTmp))
|
||
WriteXData(pEnt,CABLELAY_XDATA_SPE,sSpe);
|
||
}
|
||
if (sNumCopy.IsEmpty())
|
||
return;
|
||
if(ReadXData(pEnt,XDATA_START_NO,sTmp))
|
||
{
|
||
nFind = sTmp.Find(SPEC_CHAR);
|
||
if(nFind != -1)
|
||
WriteXData(pEnt,XDATA_START_NO,sNumCopy + GetMidStr(sTmp,nFind,sTmp.GetLength()));
|
||
}
|
||
if(ReadXData(pEnt,XDATA_END_NO,sTmp))
|
||
{
|
||
nFind = sTmp.Find(SPEC_CHAR);
|
||
if(nFind != -1)
|
||
WriteXData(pEnt,XDATA_END_NO,sNumCopy + GetMidStr(sTmp,nFind,sTmp.GetLength()));
|
||
}
|
||
if(ReadXData(pEnt,XDATA_CABL_SIGN,sTmp))
|
||
{
|
||
nFind = sTmp.Find(SPEC_CHAR);
|
||
if(nFind != -1)
|
||
{
|
||
WriteXData(pEnt,XDATA_CABL_SIGN,sNumCopy + GetMidStr(sTmp,nFind,sTmp.GetLength()));
|
||
sTmp = GetMidStr(sTmp,nFind + 1,sTmp.GetLength());
|
||
if (sTmp.CompareNoCase(CABLELAY_END) == 0)//终点设备
|
||
{
|
||
if(ReadXData(pEnt,CABLE_CNT_EQU,sTmp))
|
||
{
|
||
nFind = sNumCopy.Find(_T("-"));
|
||
if(nFind != -1)
|
||
WriteXData(pEnt,CABLE_CNT_EQU,GetMidStr(sNumCopy,0,nFind-1));
|
||
}
|
||
CString sKeyOld,sKeyNew;
|
||
sKeyOld.Format(_T("%s%s"),sNumOld,CABLE_NUM_EX);
|
||
sKeyNew.Format(_T("%s%s"),sNumCopy,CABLE_NUM_EX);
|
||
if(ReadXData(pEnt,sKeyOld,sTmp))
|
||
WriteXData(pEnt,sKeyOld,sKeyNew,0);
|
||
}
|
||
}
|
||
}
|
||
if(ReadXData(pEnt,CABLE_PIPE_FLOW,sTmp))
|
||
WriteXData(pEnt,CABLE_PIPE_FLOW,sNumCopy,1);
|
||
}
|
||
|
||
// O1 M3
|
||
// \ | 4 2
|
||
// 5----+------+-------+------+---------6
|
||
// 1 3 | \
|
||
// M4 O2
|
||
//假设O1 M3 为起点电缆,O2 M4为终点电缆,O1余O2对应,M3与M4对应
|
||
//认为M3-3-4-M4为一体的,更改其中任何一段电缆的标注,其他2段的标注都做相应更改
|
||
//假设此函数中id为 M3与点3所表示的起点电缆,(也可以是M4与点4的那一段,道理是一样的,但不能是3-4的那一段)
|
||
//先得到arRelatedEntIds为点5到6的电缆,然后得到arRelatedEntIds为M4与点4所表示的终点点电缆,
|
||
//nPtIndex为点4在5-6的电缆上拓展数据的索引
|
||
void TDbCableDim::UpdateRelatedEntXData(const AcDbEntity* pSrcEnt,const CString& sNum,const int& nIndex)
|
||
{
|
||
if (pSrcEnt == NULL || sNum.IsEmpty() || nIndex < 0)
|
||
return;
|
||
CString sTmp;
|
||
if(ReadXData(pSrcEnt,PT_XDATA_NAME,sTmp))//sTmp只是凑参数,return的原因是不适用于id为3-4的那一段
|
||
{
|
||
UpdateRelatedEntXDataForPL(pSrcEnt,sNum,nIndex);
|
||
return;
|
||
}
|
||
AcDbObjectIdArray arRelatedEntIds,arStaOrEndEntIds;
|
||
int nPtIndex = -1;
|
||
AcGePoint3d ptS,ptE;
|
||
BOOL bSuc = FALSE;
|
||
AcDbPolyline* pLine = AcDbPolyline::cast(pSrcEnt);
|
||
if (pLine != NULL)
|
||
{
|
||
pLine->getStartPoint(ptS);
|
||
pLine->getEndPoint(ptE);
|
||
bSuc = TRUE;
|
||
}
|
||
if (!bSuc)
|
||
return;
|
||
RBList rbMask = acutBuildList(RTDXF0, _T("LWPOLYLINE"),8,LAY_CABLELAY_PL,NULL);
|
||
PickSet ss(SS_FREE);
|
||
ss.Get(_T("X"),NULL,NULL,rbMask);
|
||
AcGePoint3dArray arRelatedEntPts,arPts;
|
||
AcDbObjectId oid;
|
||
for (long i = 0;i < ss.Length();i++)
|
||
{
|
||
oid.setNull();
|
||
arRelatedEntPts.removeAll();
|
||
OPENOBJ_BEGIN(ss[i],AcDb::kForRead,AcDbPolyline,pLine);
|
||
if (ReadXData(pLine,PT_XDATA_NAME,arRelatedEntPts))
|
||
oid = pLine->objectId();
|
||
OPENOBJ_END();
|
||
if (!oid.isValid())
|
||
continue;
|
||
for (int j = 0;j < arRelatedEntPts.length();j++)
|
||
{
|
||
if ( arRelatedEntPts[j] == ptS)
|
||
{
|
||
arRelatedEntIds.append(oid);
|
||
arPts.append(ptS);
|
||
}
|
||
else if (arRelatedEntPts[j] == ptE)
|
||
{
|
||
arRelatedEntIds.append(oid);
|
||
arPts.append(ptE);
|
||
}
|
||
}
|
||
}
|
||
//得到了arRelatedEntIds,同时将点3【按顺序(与arRelatedEntIds一一对应)】存储到arPts中
|
||
//接下来根据arRelatedEntIds查找arStaOrEndEntIds
|
||
if(arPts.length() != arRelatedEntIds.length())
|
||
return;
|
||
rbMask.FreeGroups();
|
||
rbMask.Append(acutBuildList(RTDXF0, _T("LWPOLYLINE"),8,LAY_CABLELAY_CABLE,NULL));
|
||
for (int i = 0;i < arRelatedEntIds.length();i++)
|
||
{
|
||
oid = arRelatedEntIds[i];
|
||
arRelatedEntPts.removeAll();
|
||
AcGePoint3d pt;//在5-6所对应的电缆上且与3对应的点,即点4
|
||
OPENOBJ_BEGIN(oid,AcDb::kForWrite,AcDbPolyline,pLine);
|
||
if (ReadXData(pLine,PT_XDATA_NAME,arRelatedEntPts))
|
||
{
|
||
ss.Free();
|
||
ss.Get(_T("X"),NULL,NULL,rbMask);
|
||
//得到arPts[i]在arRelatedEntPts[i]中的位置
|
||
int j = 0;
|
||
bSuc = FALSE;
|
||
for(j = 0; j < arRelatedEntPts.length();j++)
|
||
{
|
||
if (arRelatedEntPts[j] == arPts[i])
|
||
{
|
||
bSuc = TRUE;
|
||
break;
|
||
}
|
||
}
|
||
if (bSuc)
|
||
{
|
||
if (j%2 == 0)//id为起点电缆
|
||
pt = arRelatedEntPts[j + 1];
|
||
else
|
||
pt = arRelatedEntPts[j - 1];
|
||
nPtIndex = j/2;
|
||
}
|
||
//得到了点4
|
||
}
|
||
else
|
||
continue;
|
||
OPENOBJ_END();
|
||
//得到arPts[i]在arRelatedEntPts[i]中的位置
|
||
for (long j = 0;j < ss.Length();j++)
|
||
{
|
||
OPENOBJ_BEGIN(ss[j],AcDb::kForRead,AcDbPolyline,pLine);
|
||
if (pLine != NULL)
|
||
{
|
||
pLine->getStartPoint(ptS);
|
||
pLine->getEndPoint(ptE);
|
||
if ( pt == ptS || pt == ptE)
|
||
arStaOrEndEntIds.append(pLine->objectId());//
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
//设置拓展数据
|
||
for (int i = 0;i < arRelatedEntIds.length();i++)
|
||
{
|
||
OPENOBJ_BEGIN(arRelatedEntIds[i],AcDb::kForWrite,AcDbEntity,pEnt);
|
||
if (pEnt != NULL)
|
||
WriteXData(pEnt,CABLELAY_XDATA_NAME,sNum,nPtIndex);
|
||
OPENOBJ_END();
|
||
}
|
||
for (int i = 0;i < arStaOrEndEntIds.length();i++)
|
||
{
|
||
OPENOBJ_BEGIN(arStaOrEndEntIds[i],AcDb::kForWrite,AcDbEntity,pEnt);
|
||
if (pEnt != NULL)
|
||
UpdateOtherXData(pEnt,sNum,_T(""),nIndex);
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
//与UpdateRelatedEntXData1示意图相同,仅适用于为3-4的那一段
|
||
void TDbCableDim::UpdateRelatedEntXDataForPL(const AcDbEntity* pSrcEnt,const CString& sNum,const int& nIndex)
|
||
{
|
||
if (pSrcEnt == NULL || sNum.IsEmpty() || nIndex < 0)
|
||
return;
|
||
AcDbObjectIdArray arStaEntIds,arEndEntIds;
|
||
AcGePoint3dArray arPts;
|
||
int nPtIndex = -1;
|
||
AcGePoint3d ptS,ptE;
|
||
AcGePoint3d ptStaEqu,ptEndEqu;
|
||
BOOL bSuc = FALSE;
|
||
if(!ReadXData(pSrcEnt,PT_XDATA_NAME,arPts) || arPts.length() <= 2 * nIndex + 3)
|
||
return;
|
||
ptStaEqu = arPts[2 * nIndex + 2];
|
||
ptEndEqu = arPts[2 * nIndex + 3];
|
||
RBList rbMask = acutBuildList(RTDXF0, _T("LWPOLYLINE"),8,LAY_CABLELAY_CABLE,NULL);
|
||
PickSet ss(SS_FREE);
|
||
ss.Get(_T("X"),NULL,NULL,rbMask);
|
||
AcDbObjectId oid;
|
||
for (long i = 0;i < ss.Length();i++)
|
||
{
|
||
oid.setNull();
|
||
bSuc = FALSE;
|
||
OPENOBJ_BEGIN(ss[i],AcDb::kForRead,AcDbPolyline,pLine);
|
||
if (pLine != NULL)
|
||
{
|
||
pLine->getStartPoint(ptS);
|
||
pLine->getEndPoint(ptE);
|
||
oid = pLine->objectId();
|
||
bSuc = TRUE;
|
||
}
|
||
OPENOBJ_END();
|
||
if (!bSuc || !oid.isValid())
|
||
continue;
|
||
if (ptStaEqu.isEqualTo(ptS) || ptStaEqu.isEqualTo(ptE))
|
||
arStaEntIds.append(oid);
|
||
else if (ptEndEqu.isEqualTo(ptS) || ptEndEqu.isEqualTo(ptE))
|
||
arEndEntIds.append(oid);
|
||
}
|
||
//
|
||
for (int i = 0;i < arStaEntIds.length();i++)
|
||
{
|
||
OPENOBJ_BEGIN(arStaEntIds[i],AcDb::kForWrite,AcDbEntity,pEnt);
|
||
if (pEnt != NULL)
|
||
UpdateOtherXData(pEnt,sNum,_T(""),0);
|
||
OPENOBJ_END();
|
||
}
|
||
for (int i = 0;i < arEndEntIds.length();i++)
|
||
{
|
||
OPENOBJ_BEGIN(arEndEntIds[i],AcDb::kForWrite,AcDbEntity,pEnt);
|
||
if (pEnt != NULL)
|
||
UpdateOtherXData(pEnt,sNum,_T(""),0);
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
//设置电缆文字内容
|
||
void TDbCableDim::SetCableLayString(const AcDbObjectId &id,const CString &sText,const int& nIndex)
|
||
{
|
||
CString sXData;
|
||
AcDbEntity *pEnt = NULL;
|
||
CStringArray arValues,arValues2;
|
||
BOOL bIsDimPipeFlow = FALSE;
|
||
TDbXDataMap map;
|
||
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForWrite) != Acad::eOk)
|
||
return;
|
||
resbuf *pRbNo = pEnt->xData(CABLELAY_XDATA_NAME);
|
||
resbuf *pRbSpe = pEnt->xData(CABLELAY_XDATA_SPE);
|
||
//读取
|
||
if (m_sLableType.CompareNoCase(LABLE_CABANDSPE) == 0)
|
||
{
|
||
if (pRbNo != NULL)
|
||
{
|
||
CString csRet;
|
||
resbuf *pTempNo = pRbNo;
|
||
resbuf *pTempSpe = pRbSpe;
|
||
while (pTempNo->rbnext != NULL)
|
||
{
|
||
pTempNo = pTempNo->rbnext;
|
||
csRet = pTempNo->resval.rstring;
|
||
//添加编号后添加相应规格
|
||
if(pTempSpe != NULL)
|
||
{
|
||
CString temp;
|
||
pTempSpe = pTempSpe->rbnext;
|
||
temp = pTempSpe->resval.rstring;
|
||
// 分解出电缆规格
|
||
int loc = temp.Find(SPEC_CHAR,0);
|
||
if (loc >= 0)
|
||
{
|
||
temp = temp.Right(temp.GetLength()-loc-1);
|
||
if (!temp.IsEmpty())
|
||
{
|
||
temp.Replace(SPEC_CHAR,_T("-"));
|
||
}
|
||
}
|
||
int nLen = temp.GetLength();
|
||
if (nLen > 0 && temp.ReverseFind(_T('-') == nLen -1))
|
||
temp.Delete(nLen -1);//删掉最后的'-'
|
||
temp.Insert(0,_T('-'));//在首位增加'-'以和pTempNo->resval.rstring区分开
|
||
csRet+=temp;
|
||
}
|
||
arValues.Add(csRet);
|
||
}
|
||
}
|
||
}
|
||
else if (m_sLableType.CompareNoCase(LABLE_CABNO) == 0)// 标注电缆编号
|
||
{
|
||
if (pRbNo != NULL)
|
||
{
|
||
CString csRet;
|
||
resbuf *pTemp = pRbNo;
|
||
while (pTemp->rbnext != NULL)
|
||
{
|
||
pTemp = pTemp->rbnext;
|
||
csRet = pTemp->resval.rstring;
|
||
arValues.Add(csRet);
|
||
}
|
||
}
|
||
}
|
||
else if (m_sLableType.CompareNoCase(LABLE_SPE) == 0)// 标注电缆规格
|
||
{
|
||
if (pRbSpe != NULL)
|
||
{
|
||
CString csRet = _T("");
|
||
int nIndex = -1;
|
||
resbuf *pTemp = pRbSpe;
|
||
while (pTemp->rbnext != NULL)
|
||
{
|
||
pTemp = pTemp->rbnext;
|
||
csRet = pTemp->resval.rstring;
|
||
// 分解出电缆规格
|
||
nIndex = csRet.Find(SPEC_CHAR,0);
|
||
if (nIndex >= 0)
|
||
{
|
||
csRet = csRet.Right(csRet.GetLength()-nIndex-1);
|
||
if (!csRet.IsEmpty())
|
||
{
|
||
csRet.Replace(SPEC_CHAR,_T("-"));
|
||
int nLen = csRet.GetLength();
|
||
if (nLen > 0 && csRet.ReverseFind(_T('-') == nLen -1))
|
||
csRet.Delete(nLen -1);//删掉最后的'-'
|
||
arValues.Add(csRet);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//看是否需要标注穿管管径 需要的话需要加上
|
||
if (m_bPipeFlow)
|
||
{
|
||
if (map.Read(pEnt,CABLE_PIPE_FLOW))
|
||
{
|
||
CString sFlowD;
|
||
if (pRbNo != NULL)
|
||
{
|
||
CString csRet;
|
||
resbuf *pTemp = pRbNo;
|
||
while (pTemp->rbnext != NULL)
|
||
{
|
||
pTemp = pTemp->rbnext;
|
||
csRet = pTemp->resval.rstring;
|
||
arValues2.Add(csRet);
|
||
}
|
||
|
||
if (arValues2.GetSize() > nIndex)
|
||
map.GetAt(arValues2[nIndex],sFlowD);
|
||
sFlowD.Replace(SPEC_CHAR,_T(""));
|
||
|
||
if (!m_sLableType.IsEmpty())
|
||
sFlowD.Insert(0,_T("-"));
|
||
arValues[nIndex] += sFlowD;
|
||
bIsDimPipeFlow = TRUE;
|
||
}
|
||
}
|
||
}
|
||
if(pRbNo != NULL)
|
||
ads_relrb(pRbNo);
|
||
if(pRbSpe != NULL)
|
||
ads_relrb(pRbSpe);
|
||
//读取完成,需要将原本为arValues[nIndex]修改为sText
|
||
if (arValues.GetSize() <= nIndex && sText.CompareNoCase(arValues[nIndex]) == 0)
|
||
return;
|
||
CString sTextCopy = sText,sTmp,sTmp1,sTmp2;
|
||
CStringArray arTmp,arTmp1,arTmp2;
|
||
SplitValue(sTextCopy,_T("-"),arTmp1);
|
||
SplitValue(arValues[nIndex],_T("-"),arTmp2);
|
||
int nLen1 = arTmp1.GetSize(),nLen2 = arTmp2.GetSize();
|
||
if (nLen1 == 0 || nLen2 == 0 || nLen1 != nLen2)
|
||
return;
|
||
int nSpeLen = nLen1;
|
||
if (bIsDimPipeFlow)
|
||
nSpeLen = nLen1 - 1;
|
||
// arTmp1分三部分,一:arTmp1[0]+arTmp1[1],二:arTmp1[2]到arTmp1[arTmp1.GetSize()-2],三:arTmp1[arTmp1.GetSize()-1]
|
||
//注:若bIsDimPipeFlow为真,
|
||
// {
|
||
// 若m_sLableType为LABLE_CABANDSPE,则一为编号数据,二为规格数据,三为穿管数据,
|
||
// 若m_sLableType为LABLE_CABNO, 则一+二为编号数据,三为穿管数据,
|
||
// 若m_sLableType为LABLE_SPE, 则一+二为规格数据,三为穿管数据,
|
||
// }
|
||
// 否则
|
||
// {
|
||
// 若m_sLableType为LABLE_CABANDSPE,则一为编号数据,二+三为规格数据
|
||
// 若m_sLableType为LABLE_CABNO, 则一+二+三为编号数据
|
||
// 若m_sLableType为LABLE_SPE, 则一+二+三为规格数据
|
||
// }
|
||
//写入
|
||
ads_command(RTSTR, _T(".UNDO"), RTSTR, _T("MARK"), RTNONE);
|
||
if (m_sLableType.CompareNoCase(LABLE_CABANDSPE) == 0)
|
||
{
|
||
CString csDeled;
|
||
if (!ReadXData(pEnt,CABLELAY_XDATA_SPE,csDeled))
|
||
{
|
||
sTmp = _T("");
|
||
for (int i = 0;i < nSpeLen;i++)
|
||
sTmp += (arTmp1[i] + _T("-"));
|
||
sTmp1 = sTmp.TrimRight(_T("-"));
|
||
sTmp = _T("");
|
||
for (int i = 0;i < nSpeLen;i++)
|
||
sTmp += (arTmp2[i] + _T("-"));
|
||
sTmp2 = sTmp.TrimRight(_T("-"));
|
||
if(sTmp1.CompareNoCase(sTmp2) != 0)
|
||
{
|
||
if(MakeSureModify())
|
||
{
|
||
UpdateOtherXData(pEnt,sTmp1,_T(""),nIndex);
|
||
UpdateRelatedEntXData(pEnt,sTmp1,nIndex);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (nLen1 >= 3)
|
||
{
|
||
sTmp1 = arTmp1[0] + _T("-") + arTmp1[1];
|
||
sTmp2 = arTmp2[0] + _T("-") + arTmp2[1];
|
||
if(sTmp1.CompareNoCase(sTmp2) != 0)
|
||
{
|
||
if(MakeSureModify())
|
||
{
|
||
UpdateOtherXData(pEnt,sTmp1,_T(""),nIndex);
|
||
UpdateRelatedEntXData(pEnt,sTmp1,nIndex);
|
||
}
|
||
}
|
||
sTmp = _T("");
|
||
for (int i = 2;i < nSpeLen;i++)
|
||
sTmp += (arTmp1[i] + _T("-"));
|
||
sTmp1 = sTmp.TrimRight(_T("-"));
|
||
sTmp = _T("");
|
||
for (int i = 2;i < nSpeLen;i++)
|
||
sTmp += (arTmp2[i] + _T("-"));
|
||
sTmp2 = sTmp.TrimRight(_T("-"));
|
||
if(sTmp1.CompareNoCase(sTmp2) != 0)
|
||
{
|
||
int nFind = csDeled.Find(SPEC_CHAR,0);
|
||
if (nFind != -1)
|
||
csDeled = GetMidStr(csDeled,0,nFind - 1);
|
||
sTmp.Format(_T("%s%s%s%s"),csDeled,SPEC_CHAR,sTmp1,SPEC_CHAR);
|
||
if(MakeSureModify())
|
||
{
|
||
UpdateOtherXData(pEnt,_T(""),sTmp,nIndex);
|
||
UpdateRelatedEntXData(pEnt,csDeled,nIndex);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (m_sLableType.CompareNoCase(LABLE_CABNO) == 0)// 标注电缆编号
|
||
{
|
||
sTmp = _T("");
|
||
for (int i = 0;i < nSpeLen;i++)
|
||
sTmp += (arTmp1[i] + _T("-"));
|
||
sTmp1 = sTmp.TrimRight(_T("-"));
|
||
sTmp = _T("");
|
||
for (int i = 0;i < nSpeLen;i++)
|
||
sTmp += (arTmp2[i] + _T("-"));
|
||
sTmp2 = sTmp.TrimRight(_T("-"));
|
||
if(sTmp1.CompareNoCase(sTmp2) != 0)
|
||
{
|
||
if(MakeSureModify())
|
||
{
|
||
UpdateOtherXData(pEnt,sTmp1,_T(""),nIndex);
|
||
UpdateRelatedEntXData(pEnt,sTmp1,nIndex);
|
||
}
|
||
}
|
||
}
|
||
else if (m_sLableType.CompareNoCase(LABLE_SPE) == 0)// 标注电缆规格
|
||
{
|
||
CString csDeled;
|
||
if (ReadXData(pEnt,CABLELAY_XDATA_SPE,csDeled))
|
||
{
|
||
sTmp = _T("");
|
||
for (int i = 0;i < nSpeLen;i++)
|
||
sTmp += (arTmp1[i] + _T("-"));
|
||
sTmp1 = sTmp.TrimRight(_T("-"));
|
||
sTmp = _T("");
|
||
for (int i = 0;i < nSpeLen;i++)
|
||
sTmp += (arTmp2[i] + _T("-"));
|
||
sTmp2 = sTmp.TrimRight(_T("-"));
|
||
if(sTmp1.CompareNoCase(sTmp2) != 0)
|
||
{
|
||
//得到被去掉的部分
|
||
int nFind = csDeled.Find(SPEC_CHAR,0);
|
||
if (nFind != -1)
|
||
csDeled = GetMidStr(csDeled,0,nFind -1);
|
||
//被去掉的部分存在了csToSet中
|
||
sTmp.Format(_T("%s%s%s%s"),csDeled,SPEC_CHAR,sTmp1,SPEC_CHAR);
|
||
if(MakeSureModify())
|
||
{
|
||
UpdateOtherXData(pEnt,_T(""),sTmp,nIndex);
|
||
UpdateRelatedEntXData(pEnt,csDeled,nIndex);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (bIsDimPipeFlow)
|
||
{
|
||
sTmp1 = arTmp1[nLen1 - 1];
|
||
sTmp2 = arTmp2[nLen1 - 1];
|
||
if ( nLen1 >= 1 && sTmp1.CompareNoCase(sTmp2) != 0)
|
||
{
|
||
//arTmp1是形如“PC20”“SC20”的形式,在“PC”或“SC”后添加删掉的“*”
|
||
int j = 0;
|
||
for(j = 0;j < sTmp1.GetLength();j++)
|
||
{
|
||
if (sTmp1[j] <= _T('9') && sTmp1[j] >= _T('0'))
|
||
break;
|
||
}
|
||
sTmp = GetMidStr(sTmp1,0,j-1);
|
||
CString sFlowD;
|
||
if(sTmp.CompareNoCase(_T("SC")) == 0 || sTmp.CompareNoCase(_T("PC")) == 0)
|
||
{
|
||
sTmp1.Insert(j,SPEC_CHAR);
|
||
if (map.Write(pEnt,CABLE_PIPE_FLOW))
|
||
{
|
||
if (arValues2.GetSize() > nIndex && map.SetAt(arValues2[nIndex],sTmp1))
|
||
{
|
||
resbuf* pRbTmp;
|
||
map.XDMap2Resbuf(CABLE_PIPE_FLOW,pRbTmp);
|
||
if (pRbTmp != NULL)
|
||
{
|
||
pEnt->setXData(pRbTmp);
|
||
ads_relrb(pRbTmp);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ads_prompt(_T("只允许修改为“SC+数字”或者“PC+数字”的形式!"));
|
||
}
|
||
}
|
||
}
|
||
pEnt->close();
|
||
}
|
||
*/
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
void TCableTrayFittingTool::StringSplit(const CString& sVal,const CString& sGap,CStringArray& arSplit,BOOL bIncludeEmptyString)
|
||
{
|
||
arSplit.RemoveAll();
|
||
int nGapLen = sGap.GetLength();
|
||
CString strSrc = sVal;
|
||
CString strLeft;
|
||
int nPos = strSrc.Find(sGap);
|
||
while(nPos >= 0)
|
||
{
|
||
strLeft = strSrc.Left(nPos);
|
||
if (bIncludeEmptyString || (!bIncludeEmptyString && !strLeft.IsEmpty()))
|
||
arSplit.Add(strLeft);
|
||
strSrc = strSrc.Mid(nPos+nGapLen);
|
||
nPos = strSrc.Find(sGap);
|
||
}
|
||
if (bIncludeEmptyString || (!bIncludeEmptyString && !strSrc.IsEmpty()))
|
||
arSplit.Add(strSrc);
|
||
}
|
||
CString TCableTrayFittingTool::StringJoin(const CStringArray& arValue,const CString& strGap,BOOL bLastAddGap)
|
||
{
|
||
CString strResult;
|
||
int nSize = (int)arValue.GetSize();
|
||
for (int i = 0;i < nSize;i++)
|
||
{
|
||
CString sTmp = arValue[i];
|
||
if( i != nSize - 1 || (i == nSize - 1 && bLastAddGap) )
|
||
{
|
||
sTmp += strGap;
|
||
}
|
||
strResult += sTmp;
|
||
}
|
||
return strResult;
|
||
}
|
||
|
||
void TCableTrayFittingTool::GetClapWidtdAisle(std::vector<std::pair<CString,CString>>& vecWidtdAisle,const CString& sKeyClap)
|
||
{
|
||
if (!m_pEnt)
|
||
return;
|
||
CString sClapData;
|
||
m_pEnt->GetSpecialtyData()->GetAt(sKeyClap,sClapData);
|
||
CStringArray arPair;
|
||
StringSplit(sClapData,KEY_CLP_MAIN_KEY,arPair,TRUE);
|
||
for (int i = 0;i < (int)arPair.GetSize();i++)
|
||
{
|
||
CStringArray arWidthAndAisle;
|
||
StringSplit(arPair[i],KEY_CLP_SUB_KEY,arWidthAndAisle,TRUE);
|
||
if (arWidthAndAisle.GetSize() >= 2)
|
||
{
|
||
vecWidtdAisle.push_back(std::make_pair(arWidthAndAisle[0],arWidthAndAisle[1]));
|
||
}
|
||
}
|
||
}
|
||
|
||
BOOL TCableTrayFittingTool::SetClapWidtdAisle(const CStringArray& arWidthNew,const CString& sKeyClap)
|
||
{
|
||
std::vector<std::pair<CString,CString>> vecWidtdAisle;
|
||
GetClapWidtdAisle(vecWidtdAisle,sKeyClap);
|
||
if (arWidthNew.GetSize() != vecWidtdAisle.size())
|
||
return FALSE;
|
||
for (int i = 0;i < (int)arWidthNew.GetSize();i++)
|
||
{
|
||
vecWidtdAisle[i].first = arWidthNew[i];
|
||
}
|
||
return SetClapWidtdAisle(vecWidtdAisle,sKeyClap);
|
||
}
|
||
|
||
BOOL TCableTrayFittingTool::SetClapWidtdAisle(const std::vector<std::pair<CString,CString>>& vecWidtdAisle,const CString& sKeyClap)
|
||
{
|
||
CString sRet,sT;
|
||
for (int i = 0;i < (int)vecWidtdAisle.size();i++)
|
||
{
|
||
sT.Format(_T("%s%s%s%s"),vecWidtdAisle[i].first,KEY_CLP_SUB_KEY,vecWidtdAisle[i].second,KEY_CLP_MAIN_KEY);
|
||
sRet += sT;
|
||
}
|
||
sRet.TrimRight(KEY_CLP_MAIN_KEY);
|
||
if (!sRet.IsEmpty())
|
||
return m_pEnt->GetSpecialtyData()->SetAt(sKeyClap,sRet);
|
||
return FALSE;
|
||
}
|
||
|
||
TCableTrayFittingTool::TCableTrayFittingTool(AcDbEntity* pEnt)
|
||
{
|
||
m_pEnt = TDbInterfacesObj::cast(pEnt);
|
||
}
|
||
CString TCableTrayFittingTool::GetRunTimeName()
|
||
{
|
||
CString sRet;
|
||
if (!m_pEnt)
|
||
return sRet;
|
||
int nFittingKind = 0;
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_RUNTIME,nFittingKind);
|
||
switch(nFittingKind)
|
||
{
|
||
case TDb::eCableTray:
|
||
sRet = _T("桥架");
|
||
break;
|
||
case TDb::eElbow:
|
||
sRet = _T("弯通");
|
||
break;
|
||
case TDb::eTee:
|
||
sRet = _T("三通");
|
||
break;
|
||
case TDb::eCross:
|
||
sRet = _T("四通");
|
||
break;
|
||
case TDb::eReduce:
|
||
sRet = _T("变径");
|
||
break;
|
||
case TDb::eOffset:
|
||
sRet = _T("乙字弯");
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
return sRet;
|
||
}
|
||
|
||
CString TCableTrayFittingTool::GetName()
|
||
{
|
||
CString sName;
|
||
if (!m_pEnt)
|
||
return sName;
|
||
int nFittingKind(-1),nStyle(-1),nType(-1),nHaveClap(-1);
|
||
BOOL bInclineFit = FALSE,bTransFit =FALSE;
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_RUNTIME,nFittingKind);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_STYLE,nStyle);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_INCLINE_FIT, bInclineFit); //
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_TRANS_FIT, bTransFit); //
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_HAVE_CLAPBOARD, nHaveClap);
|
||
switch (nStyle)
|
||
{
|
||
case TDb::eC:
|
||
{
|
||
sName = _T("槽式");
|
||
break;
|
||
}
|
||
case TDb::eP:
|
||
{
|
||
sName = _T("盘式");
|
||
break;
|
||
}
|
||
case TDb::eT:
|
||
{
|
||
sName = _T("梯式");
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
switch(nFittingKind)
|
||
{
|
||
case TDb::eCableTray:
|
||
{
|
||
int nBigSpan(-1);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_BIGSPAN,nBigSpan);
|
||
if (nBigSpan == TDb::eBigSpan)
|
||
sName += _T("大跨距直通桥架");
|
||
else
|
||
sName += _T("直通桥架");
|
||
//m_pEnt->GetSpecialtyData()->GetAt(KEY_CABLETRAY,nType);
|
||
break;
|
||
}
|
||
case TDb::eElbow:
|
||
{
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_ELBOW,nType);
|
||
switch (nType)
|
||
{
|
||
case TDb::eCHorEqualR:
|
||
{
|
||
if (bTransFit)
|
||
sName += _T("水平异径弯通");
|
||
else
|
||
sName += _T("水平等径弯通");
|
||
break;
|
||
}
|
||
case TDb::eCHorEqual135R:
|
||
{
|
||
if (bTransFit)
|
||
sName += _T("135度水平异径弯通");
|
||
else
|
||
sName += _T("135度水平等径弯通");
|
||
break;
|
||
}
|
||
case TDb::eCVerEqualTop:
|
||
{
|
||
sName += _T("垂直等径上弯通");
|
||
break;
|
||
}
|
||
case TDb::eCVerEqual135Top:
|
||
{
|
||
sName += _T("135度垂直等径上弯通");
|
||
break;
|
||
}
|
||
case TDb::eCVerEqualBottom:
|
||
{
|
||
sName += _T("垂直等径下弯通(右方向)");
|
||
break;
|
||
}
|
||
case TDb::eCVerEqual135Bottom:
|
||
{
|
||
sName += _T("135度垂直等径下弯通");
|
||
break;
|
||
}
|
||
case TDb::eCVerEqualLeftBottom:
|
||
{
|
||
sName += _T("垂直等径左下弯通");
|
||
break;
|
||
}
|
||
case TDb::eCVerEqualRightBottom:
|
||
{
|
||
sName += _T("垂直等径右下弯通");
|
||
break;
|
||
}
|
||
case TDb::eCVerEqualLeftTop:
|
||
{
|
||
sName += _T("垂直等径左上弯通");
|
||
break;
|
||
}
|
||
case TDb::eCVerEqualRightTop:
|
||
{
|
||
sName += _T("垂直等径右上弯通");
|
||
break;
|
||
}
|
||
case TDb::eCVerEqualTurn:
|
||
{
|
||
sName += _T("垂直等径转动弯通");
|
||
break;
|
||
}
|
||
case TDb::eCHorEqualZRight:
|
||
{
|
||
sName += _T("垂直等径Z字右偏弯通");
|
||
break;
|
||
}
|
||
case TDb::eCHorEqualZLeft:
|
||
{
|
||
sName += _T("垂直等径Z字左偏弯通");
|
||
break;
|
||
}
|
||
case TDb::eCVerEqualHightLow:
|
||
{
|
||
sName += _T("垂直高低等径弯通");
|
||
break;
|
||
}
|
||
case TDb::eCVerEqualBottom2:
|
||
{
|
||
sName += _T("垂直等径下弯通(左方向)");
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
}
|
||
case TDb::eTee:
|
||
{
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_TEE,nType);
|
||
switch (nType)
|
||
{
|
||
case TDb::eTHorEqualR:
|
||
{
|
||
if (bInclineFit && !bTransFit)
|
||
{
|
||
sName += _T("水平等径斜向三通");
|
||
}
|
||
else if (!bInclineFit && bTransFit)
|
||
{
|
||
sName += _T("水平异径三通");
|
||
}
|
||
else if (bInclineFit && bTransFit)
|
||
{
|
||
sName += _T("水平异径斜向三通");
|
||
}
|
||
else
|
||
sName += _T("水平等径三通");
|
||
break;
|
||
}
|
||
case TDb::eTVerEqualR: // 槽式上垂直等径三通
|
||
{
|
||
sName += _T("上垂直等径三通");
|
||
break;
|
||
}
|
||
case TDb::eTDVerEqualR: // 槽式下垂直等径三通
|
||
{
|
||
sName += _T("下垂直等径三通");
|
||
break;
|
||
}
|
||
case TDb::eTUpSideMidVerEqualR: // 槽式上边中间垂直等径三通
|
||
{
|
||
sName += _T("上边中间垂直等径三通");
|
||
break;
|
||
}
|
||
case TDb::eTDSideVerEqualR: // 槽式下边垂直等径三通
|
||
{
|
||
sName += _T("下边垂直等径三通");
|
||
break;
|
||
}
|
||
case TDb::eTUpAngleVerEqualR: // 槽式上角垂直等径三通
|
||
{
|
||
sName += _T("上角垂直等径三通");
|
||
break;
|
||
}
|
||
case TDb::eTDAngleVerEqualR: // 槽式下角垂直等径三通
|
||
{
|
||
sName += _T("下角垂直等径三通");
|
||
break;
|
||
}
|
||
case TDb::eTDSideMidVerEqualR: // 槽式下边中间垂直等径三通
|
||
{
|
||
sName += _T("下边中间垂直等径三通");
|
||
break;
|
||
}
|
||
case TDb::eTUpSideVerEqualR: // 槽式上边垂直等径三通
|
||
{
|
||
sName += _T("上边垂直等径三通");
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
}
|
||
case TDb::eCross:
|
||
{
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_CROSS,nType);
|
||
switch (nType)
|
||
{
|
||
case TDb::eOldCbotHorEqualCross:
|
||
case TDb::eCbotHorEqualCross: // 槽式水平等径四通
|
||
{
|
||
if (bInclineFit && !bTransFit)
|
||
{
|
||
sName += _T("水平等径斜向四通");
|
||
}
|
||
else if (!bInclineFit && bTransFit)
|
||
{
|
||
sName += _T("水平异径四通");
|
||
}
|
||
else if (bInclineFit && bTransFit)
|
||
{
|
||
sName += _T("水平异径斜向四通");
|
||
}
|
||
else
|
||
sName += _T("水平等径四通");
|
||
break;
|
||
}
|
||
case TDb::eCrossForSpace: // 槽式水平等径四通
|
||
{
|
||
sName += _T("垂直等径四通");
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
}
|
||
case TDb::eReduce:
|
||
{
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_REDUCER,nType);
|
||
switch (nType)
|
||
{
|
||
case TDb::eRbotHorDifR:
|
||
{
|
||
sName += _T("水平异径接头");
|
||
break;
|
||
}
|
||
case TDb::eRbotHorNormalDifR:
|
||
{
|
||
sName = _T("水平普通异径接头");
|
||
break;
|
||
}
|
||
case TDb::eRbotHorOffsetDifR: // 槽式水平偏移(左)异径接头
|
||
{
|
||
sName = _T("水平偏移(左)异径接头");
|
||
break;
|
||
}
|
||
case TDb::eRbotHorOffsetDifR2: // 槽式水平偏移(右)异径接头
|
||
{
|
||
sName = _T("水平偏移(右)异径接头");
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
}
|
||
case TDb::eOffset:
|
||
{
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_OFFSET,nType);
|
||
switch(nType)
|
||
{
|
||
case TDb::eHorLeftOffset:
|
||
{
|
||
sName += _T("水平左偏移等径乙字弯通");
|
||
break;
|
||
}
|
||
case TDb::eHorRightOffset:
|
||
{
|
||
sName += _T("水平右偏移等径乙字弯通");
|
||
break;
|
||
}
|
||
case TDb::eVerOffset:
|
||
{
|
||
sName += _T("垂直偏移等径乙字弯通");
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
if (nHaveClap == TDb::eBoard)
|
||
{
|
||
CString sNameBak(sName);
|
||
sName.Format(_T("隔板%s"),sNameBak);
|
||
}
|
||
return sName;
|
||
}
|
||
|
||
CString TCableTrayFittingTool::GetType()
|
||
{
|
||
CString sNO;
|
||
if (!m_pEnt)
|
||
return sNO;
|
||
int nFittingKind(-1),nStyle(-1);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_RUNTIME,nFittingKind);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_STYLE,nStyle);
|
||
|
||
switch(nFittingKind)
|
||
{
|
||
case TDb::eCableTray:
|
||
case TDb::eElbow:
|
||
case TDb::eTee:
|
||
case TDb::eCross:
|
||
case TDb::eReduce:
|
||
{
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_TYPE,sNO);
|
||
break;
|
||
}
|
||
case TDb::eOffset:
|
||
{
|
||
switch (nStyle)
|
||
{
|
||
case TDb::eC:
|
||
{
|
||
sNO = _T("C-20");
|
||
break;
|
||
}
|
||
case TDb::eP:
|
||
{
|
||
|
||
sNO = _T("P-20");
|
||
break;
|
||
}
|
||
case TDb::eT:
|
||
{
|
||
sNO = _T("T-20");
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
int nType(-1);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_OFFSET,nType);
|
||
switch(nType)
|
||
{
|
||
case TDb::eHorLeftOffset:
|
||
{
|
||
if (nStyle == TDb::eT)
|
||
sNO += _T("I");
|
||
else
|
||
sNO += _T("M");
|
||
break;
|
||
}
|
||
case TDb::eHorRightOffset:
|
||
{
|
||
if (nStyle == TDb::eT)
|
||
sNO += _T("H");
|
||
else
|
||
sNO += _T("L");
|
||
break;
|
||
}
|
||
case TDb::eVerOffset:
|
||
{
|
||
if (nStyle == TDb::eT)
|
||
sNO += _T("J");
|
||
else
|
||
sNO += _T("N");
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
return sNO;
|
||
}
|
||
|
||
CString TCableTrayFittingTool::GetSpec(const CString& sSpecChar,const CString& sLink)
|
||
{
|
||
CString sRet;
|
||
if (!m_pEnt)
|
||
return sRet;
|
||
int nRunTime(-1),nClapBoard(-1);
|
||
BOOL bTransFit(FALSE);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_RUNTIME, nRunTime);//运行时类型
|
||
m_pEnt ->GetSpecialtyData()->GetAt(KEY_HAVE_CLAPBOARD,nClapBoard);//隔板
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_TRANS_FIT, bTransFit);//异径
|
||
//隔板数据处理
|
||
std::vector<std::pair<CString,CString>> vecWidtdAisle,vecWidtdAisle2;
|
||
GetClapWidtdAisle(vecWidtdAisle,KEY_CLAPBOARD_DATA);
|
||
GetClapWidtdAisle(vecWidtdAisle2,KEY_CLAPBOARD_DATA2);
|
||
CString sWidth,sWidth2;
|
||
for (int i = 0;i < (int)vecWidtdAisle.size();i++)
|
||
{
|
||
sWidth += vecWidtdAisle[i].first + sLink;
|
||
}
|
||
sWidth.TrimRight(sLink);
|
||
for (int i = 0;i < (int)vecWidtdAisle2.size();i++)
|
||
{
|
||
sWidth2 += vecWidtdAisle2[i].first + sLink;
|
||
}
|
||
sWidth2.TrimRight(sLink);
|
||
//宽高数据处理
|
||
double dWidth = 0.0,dHeight = 0.0;
|
||
double dMajB = 0,dMinB = 0,dB1 = 0,dB2 = 0,dB3 = 0,dB4 = 0;
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_B, dWidth);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_H, dHeight);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_MAJBR_B, dMajB);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_MINBR_B, dMinB);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_DB1, dB1);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_DB2, dB2);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_DB3, dB3);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_DB4, dB4);
|
||
switch (nRunTime)
|
||
{
|
||
case TDb::eCabletry:
|
||
{
|
||
if (nClapBoard == TDb::eBoard)
|
||
sRet.Format(_T("(%s)%s%g"),sWidth,sSpecChar,dHeight);
|
||
else
|
||
sRet.Format(_T("%g%s%g"),dWidth,sSpecChar,dHeight);
|
||
break;
|
||
}
|
||
case TDb::eElbow:
|
||
{
|
||
if (nClapBoard == TDb::eBoard)
|
||
{
|
||
if (!sWidth.IsEmpty() && sWidth2.IsEmpty())
|
||
sRet.Format(_T("(%s)%s%g"),sWidth,sSpecChar,dHeight);
|
||
else if (!sWidth.IsEmpty() && !sWidth2.IsEmpty())
|
||
sRet.Format(_T("(%s)%s%g - (%s)%s%g"),sWidth,sSpecChar,dHeight,sWidth2,sSpecChar,dHeight);
|
||
else
|
||
sRet.Format(_T("%g%s%g"),dWidth,sSpecChar,dHeight);
|
||
}
|
||
else
|
||
{
|
||
if (bTransFit)
|
||
sRet.Format(_T("%g%s%g - %g%s%g"), dMajB,sSpecChar,dHeight,dMinB,sSpecChar,dHeight);
|
||
else
|
||
sRet.Format(_T("%g%s%g"),dWidth,sSpecChar,dHeight);
|
||
}
|
||
break;
|
||
}
|
||
case TDb::eTee:
|
||
{
|
||
if (bTransFit)
|
||
sRet.Format(_T("%g%s%g - %g%s%g - %g%s%g"), dMajB,sSpecChar,dHeight,dMinB,sSpecChar,dHeight,dB3,sSpecChar,dHeight);
|
||
else
|
||
sRet.Format(_T("%g%s%g"),dWidth,sSpecChar,dHeight);
|
||
break;
|
||
}
|
||
case TDb::eCross:
|
||
{
|
||
if (bTransFit)
|
||
{
|
||
const double dTol = 1e-4;
|
||
if (fabs(dB1 - dB3) <= dTol && fabs(dB2 - dB4) <= dTol )
|
||
sRet.Format(_T("%g%s%g - %g%s%g"), dB1,sSpecChar,dHeight,dB2,sSpecChar,dHeight);
|
||
else
|
||
sRet.Format(_T("%g%s%g - %g%s%g - %g%s%g - %g%s%g"), dB1,sSpecChar,dHeight,dB2,sSpecChar,dHeight,dB3,sSpecChar,dHeight,dB4,sSpecChar,dHeight);
|
||
}
|
||
else
|
||
sRet.Format(_T("%g%s%g"),dWidth,sSpecChar,dHeight);
|
||
break;
|
||
}
|
||
case TDb::eOffset:
|
||
{
|
||
if (nClapBoard == TDb::eBoard)
|
||
{
|
||
if (!sWidth.IsEmpty() && sWidth2.IsEmpty())
|
||
sRet.Format(_T("(%s)%s%g"),sWidth,sSpecChar,dHeight);
|
||
else if (!sWidth.IsEmpty() && !sWidth2.IsEmpty())
|
||
sRet.Format(_T("(%s)%s%g - (%s)%s%g"),sWidth,sSpecChar,dHeight,sWidth2,sSpecChar,dHeight);
|
||
else
|
||
sRet.Format(_T("%g%s%g"),dWidth,sSpecChar,dHeight);
|
||
}
|
||
else
|
||
sRet.Format(_T("%g%s%g"),dWidth,sSpecChar,dHeight);
|
||
break;
|
||
}
|
||
case TDb::eReduce:
|
||
{
|
||
double dW1 = 0.0, dH1 = 0.0;
|
||
double dW2 = 0.0, dH2 = 0.0;
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_B1, dW1);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_H1, dH1);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_B2, dW2);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_H2, dH2);
|
||
if (nClapBoard == TDb::eBoard)
|
||
{
|
||
if (!sWidth.IsEmpty() && sWidth2.IsEmpty())
|
||
sRet.Format(_T("(%s)%s%g - %g%s%g"),sWidth,sSpecChar,dH1,dW2,sSpecChar,dH2);
|
||
else if (!sWidth.IsEmpty() && !sWidth2.IsEmpty())
|
||
sRet.Format(_T("(%s)%s%g - (%s)%s%g"),sWidth,sSpecChar,dH1,sWidth2,sSpecChar,dH1);
|
||
else
|
||
sRet.Format(_T("%g%s%g - %g%s%g"), dW1,sSpecChar,dH1,dW2,sSpecChar,dH2);
|
||
}
|
||
else
|
||
sRet.Format(_T("%g%s%g - %g%s%g"), dW1,sSpecChar,dH1,dW2,sSpecChar,dH2);
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
return sRet;
|
||
}
|
||
|
||
BOOL UpdateClapWidtdAisle(std::vector<std::pair<CString,CString>>& vecWidtdAisle,const CStringArray& arWidthNew,const CString& sKeyClap)
|
||
{
|
||
if (arWidthNew.GetSize() != vecWidtdAisle.size())
|
||
return FALSE;
|
||
for (int i = 0;i < (int)arWidthNew.GetSize();i++)
|
||
{
|
||
vecWidtdAisle[i].first = arWidthNew[i];
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
double GetSumWidth(const CStringArray& arWidth)
|
||
{
|
||
double dSumWidth = 0;
|
||
for (int i = 0;i < (int)arWidth.GetSize();i++)
|
||
{
|
||
dSumWidth += _tstof(arWidth[i]);
|
||
}
|
||
return dSumWidth;
|
||
}
|
||
|
||
//sClapData是形如"100X150","(100+200)X200"
|
||
BOOL GetWidthsHeight(const CString& sSrc,CStringArray& arWidths,double& dHeight,const CString& sSpecChar = _T("X"),const CString& sLink = _T("+"))
|
||
{
|
||
int nFind = sSrc.Find(sSpecChar);
|
||
if (nFind < 0)
|
||
return FALSE;
|
||
CString sLeft = sSrc.Left(nFind);
|
||
CString sRight = sSrc.Mid(nFind + sSpecChar.GetLength());
|
||
sLeft.TrimLeft(_T("("));
|
||
sLeft.TrimLeft(_T(")"));
|
||
arWidths.RemoveAll();
|
||
TCableTrayFittingTool::StringSplit(sLeft,sLink,arWidths,TRUE);
|
||
dHeight = _tstof(sRight);
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL DefaultCableTrayFittingSpec(TDbInterfacesObj* pFitX,const CString& sSpecNew,const CString& sSpecChar = _T("X"),const CString& sLink = _T("+"))
|
||
{
|
||
if (!pFitX)
|
||
return FALSE;
|
||
CStringArray arWidthT;
|
||
double dHeightNew = 0;
|
||
if(!GetWidthsHeight(sSpecNew,arWidthT,dHeightNew,sLink,sSpecChar))
|
||
return FALSE;
|
||
if (arWidthT.GetSize() < 1)
|
||
return FALSE;
|
||
pFitX->GetSpecialtyData()->SetAt(KEY_H, dHeightNew);
|
||
pFitX->GetSpecialtyData()->SetAt(KEY_B, _tstof(arWidthT[0]));
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL TCableTrayFittingTool::SetSpec(const CString& sSpecNew,const CString& sSpecChar,const CString& sLink)
|
||
{
|
||
if (!m_pEnt || sSpecNew.IsEmpty())
|
||
return FALSE;
|
||
int nRunTime(-1),nClapBoard(-1);
|
||
BOOL bTransFit(FALSE);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_RUNTIME, nRunTime);//运行时类型
|
||
m_pEnt ->GetSpecialtyData()->GetAt(KEY_HAVE_CLAPBOARD,nClapBoard);//隔板
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_TRANS_FIT, bTransFit);//异径
|
||
//隔板数据处理
|
||
std::vector<std::pair<CString,CString>> vecWidtdAisle,vecWidtdAisle2;
|
||
GetClapWidtdAisle(vecWidtdAisle,KEY_CLAPBOARD_DATA);
|
||
GetClapWidtdAisle(vecWidtdAisle2,KEY_CLAPBOARD_DATA2);
|
||
CString sWidth,sWidth2;
|
||
for (int i = 0;i < (int)vecWidtdAisle.size();i++)
|
||
{
|
||
sWidth += vecWidtdAisle[i].first + sLink;
|
||
}
|
||
sWidth.TrimRight(sLink);
|
||
for (int i = 0;i < (int)vecWidtdAisle2.size();i++)
|
||
{
|
||
sWidth2 += vecWidtdAisle2[i].first + sLink;
|
||
}
|
||
sWidth2.TrimRight(sLink);
|
||
const CString sLink2 = _T(" - ");
|
||
CString sLeft,sRight,sT,sTmp;
|
||
CStringArray arWidthT,arPairT;
|
||
double dWidthNew = 0.0,dHeightNew = 0.0;
|
||
double dMajBNew = 0,dMinBNew = 0,dB1New = 0,dB2New = 0,dB3New = 0,dB4New = 0;
|
||
switch (nRunTime)
|
||
{
|
||
case TDb::eCabletry:
|
||
{
|
||
if (nClapBoard == TDb::eBoard)
|
||
{
|
||
if(!GetWidthsHeight(sSpecNew,arWidthT,dHeightNew,sLink,sSpecChar))
|
||
return FALSE;
|
||
if (SetClapWidtdAisle(arWidthT,KEY_CLAPBOARD_DATA))
|
||
{
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H, dHeightNew);
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B, GetSumWidth(arWidthT));
|
||
return TRUE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return DefaultCableTrayFittingSpec(m_pEnt,sSpecNew,sLink,sSpecChar);
|
||
}
|
||
break;
|
||
}
|
||
case TDb::eElbow:
|
||
{
|
||
if (nClapBoard == TDb::eBoard)
|
||
{
|
||
if (!sWidth.IsEmpty() && sWidth2.IsEmpty())
|
||
{
|
||
if(!GetWidthsHeight(sSpecNew,arWidthT,dHeightNew,sLink,sSpecChar))
|
||
return FALSE;
|
||
if (SetClapWidtdAisle(arWidthT,KEY_CLAPBOARD_DATA))
|
||
{
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H, dHeightNew);
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B, GetSumWidth(arWidthT));
|
||
return TRUE;
|
||
}
|
||
}
|
||
else if (!sWidth.IsEmpty() && !sWidth2.IsEmpty())
|
||
{
|
||
StringSplit(sSpecNew,sLink2,arPairT,TRUE);
|
||
if (arPairT.GetSize() < 2)
|
||
return FALSE;
|
||
CStringArray arWidth1,arWidth2;
|
||
if (!GetWidthsHeight(arPairT[0],arWidth1,dHeightNew,sLink,sSpecChar) ||
|
||
!GetWidthsHeight(arPairT[1],arWidth2,dHeightNew,sLink,sSpecChar))
|
||
return FALSE;
|
||
if (SetClapWidtdAisle(arWidth1,KEY_CLAPBOARD_DATA) &&
|
||
SetClapWidtdAisle(arWidth2,KEY_CLAPBOARD_DATA2) )
|
||
{
|
||
double dSumW1 = GetSumWidth(arWidth1),dSumW2 = GetSumWidth(arWidth2);
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H, dHeightNew);
|
||
if (fabs(dSumW1 - dSumW2) <= 1e-4)
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B,(dSumW1 + dSumW2) / 2);
|
||
else
|
||
{
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_MAJBR_B,dSumW1);
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_MINBR_B,dSumW2);
|
||
}
|
||
return TRUE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return DefaultCableTrayFittingSpec(m_pEnt,sSpecNew,sLink,sSpecChar);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (bTransFit)
|
||
{
|
||
StringSplit(sSpecNew,sLink2,arPairT,TRUE);
|
||
if (arPairT.GetSize() < 2)
|
||
return FALSE;
|
||
CStringArray arWidth1,arWidth2;
|
||
if (!GetWidthsHeight(arPairT[0],arWidth1,dHeightNew,sLink,sSpecChar) ||
|
||
!GetWidthsHeight(arPairT[1],arWidth2,dHeightNew,sLink,sSpecChar))
|
||
return FALSE;
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H, dHeightNew);
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_MAJBR_B,GetSumWidth(arWidth1));
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_MINBR_B,GetSumWidth(arWidth2));
|
||
return TRUE;
|
||
}
|
||
else
|
||
{
|
||
return DefaultCableTrayFittingSpec(m_pEnt,sSpecNew,sLink,sSpecChar);
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
case TDb::eTee:
|
||
case TDb::eCross:
|
||
{
|
||
if (bTransFit)
|
||
{
|
||
std::vector<std::pair<CString,double>> vecKey;
|
||
if (nRunTime == TDb::eTee)
|
||
{
|
||
vecKey.push_back(std::make_pair(KEY_MAJBR_B,0));
|
||
vecKey.push_back(std::make_pair(KEY_MINBR_B,0));
|
||
vecKey.push_back(std::make_pair(KEY_DB3,0));
|
||
}
|
||
else
|
||
{
|
||
vecKey.push_back(std::make_pair(KEY_DB1,0));
|
||
vecKey.push_back(std::make_pair(KEY_DB1,0));
|
||
vecKey.push_back(std::make_pair(KEY_DB3,0));
|
||
vecKey.push_back(std::make_pair(KEY_DB4,0));
|
||
}
|
||
int nKeyCount = (int)vecKey.size();
|
||
StringSplit(sSpecNew,sLink2,arPairT,TRUE);
|
||
if (arPairT.GetSize() < nKeyCount)
|
||
return FALSE;
|
||
BOOL bAllSuc = TRUE;
|
||
for (int i = 0;i < nKeyCount;i++)
|
||
{
|
||
CStringArray arT;
|
||
if(!GetWidthsHeight(arPairT[i],arT,dHeightNew,sLink,sSpecChar))
|
||
{
|
||
bAllSuc = FALSE;
|
||
}
|
||
vecKey[i].second = GetSumWidth(arT);
|
||
}
|
||
if (bAllSuc)
|
||
{
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H, dHeightNew);
|
||
for (int i = 0;i < nKeyCount;i++)
|
||
{
|
||
m_pEnt->GetSpecialtyData()->SetAt(vecKey[i].first,vecKey[i].second);
|
||
}
|
||
return TRUE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return DefaultCableTrayFittingSpec(m_pEnt,sSpecNew,sLink,sSpecChar);
|
||
}
|
||
break;
|
||
}
|
||
case TDb::eOffset:
|
||
{
|
||
if (nClapBoard == TDb::eBoard)
|
||
{
|
||
if (!sWidth.IsEmpty() && sWidth2.IsEmpty())
|
||
{
|
||
if(!GetWidthsHeight(sSpecNew,arWidthT,dHeightNew,sLink,sSpecChar))
|
||
return FALSE;
|
||
if (SetClapWidtdAisle(arWidthT,KEY_CLAPBOARD_DATA))
|
||
{
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H, dHeightNew);
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B, GetSumWidth(arWidthT));
|
||
return TRUE;
|
||
}
|
||
}
|
||
else if (!sWidth.IsEmpty() && !sWidth2.IsEmpty())
|
||
{
|
||
StringSplit(sSpecNew,sLink2,arPairT,TRUE);
|
||
if (arPairT.GetSize() < 2)
|
||
return FALSE;
|
||
CStringArray arWidth1,arWidth2;
|
||
if (!GetWidthsHeight(arPairT[0],arWidth1,dHeightNew,sLink,sSpecChar) ||
|
||
!GetWidthsHeight(arPairT[1],arWidth2,dHeightNew,sLink,sSpecChar))
|
||
return FALSE;
|
||
if (SetClapWidtdAisle(arWidth1,KEY_CLAPBOARD_DATA) &&
|
||
SetClapWidtdAisle(arWidth2,KEY_CLAPBOARD_DATA2) )
|
||
{
|
||
double dSumW1 = GetSumWidth(arWidth1),dSumW2 = GetSumWidth(arWidth2);
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H, dHeightNew);
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B,(dSumW1 + dSumW2) / 2);
|
||
return TRUE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return DefaultCableTrayFittingSpec(m_pEnt,sSpecNew,sLink,sSpecChar);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return DefaultCableTrayFittingSpec(m_pEnt,sSpecNew,sLink,sSpecChar);
|
||
}
|
||
break;
|
||
}
|
||
case TDb::eReduce:
|
||
{
|
||
double dW1New = 0.0, dH1New = 0.0;
|
||
double dW2New = 0.0, dH2New = 0.0;
|
||
StringSplit(sSpecNew,sLink2,arPairT,TRUE);
|
||
if (arPairT.GetSize() < 2)
|
||
return FALSE;
|
||
CStringArray arWidth1,arWidth2;
|
||
if (!GetWidthsHeight(arPairT[0],arWidth1,dH1New,sLink,sSpecChar) ||
|
||
!GetWidthsHeight(arPairT[1],arWidth2,dH2New,sLink,sSpecChar))
|
||
return FALSE;
|
||
if (nClapBoard == TDb::eBoard)
|
||
{
|
||
if (!sWidth.IsEmpty() && sWidth2.IsEmpty())
|
||
{
|
||
if (SetClapWidtdAisle(arWidthT,KEY_CLAPBOARD_DATA))
|
||
{
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B1, GetSumWidth(arWidth1));
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H1, dH1New);
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B2, GetSumWidth(arWidth2));
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H2, dH2New);
|
||
return TRUE;
|
||
}
|
||
}
|
||
else if (!sWidth.IsEmpty() && !sWidth2.IsEmpty())
|
||
{
|
||
if (SetClapWidtdAisle(arWidth1,KEY_CLAPBOARD_DATA) &&
|
||
SetClapWidtdAisle(arWidth2,KEY_CLAPBOARD_DATA2) )
|
||
{
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B1, GetSumWidth(arWidth1));
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H1, dH1New);
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B2, GetSumWidth(arWidth2));
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H2, dH2New);
|
||
return TRUE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (arWidth1.GetSize() < 1 || arWidth2.GetSize() < 1)
|
||
return FALSE;
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B1, _tstof(arWidth1[0]));
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H1, dH1New);
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B2, _tstof(arWidth2[0]));
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H2, dH2New);
|
||
return TRUE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (arWidth1.GetSize() < 1 || arWidth2.GetSize() < 1)
|
||
return FALSE;
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B1, _tstof(arWidth1[0]));
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H1, dH1New);
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_B2, _tstof(arWidth2[0]));
|
||
m_pEnt->GetSpecialtyData()->SetAt(KEY_H2, dH2New);
|
||
return TRUE;
|
||
}
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
return FALSE;
|
||
}
|
||
|
||
CString TCableTrayFittingTool::GetUnit()
|
||
{
|
||
CString sRet;
|
||
if (!m_pEnt)
|
||
return sRet;
|
||
int nFittingKind(-1);
|
||
m_pEnt->GetSpecialtyData()->GetAt(KEY_RUNTIME,nFittingKind);
|
||
switch(nFittingKind)
|
||
{
|
||
case TDb::eCableTray:
|
||
sRet = _T("米");
|
||
break;
|
||
case TDb::eElbow:
|
||
case TDb::eTee:
|
||
case TDb::eCross:
|
||
case TDb::eReduce:
|
||
case TDb::eOffset:
|
||
sRet = _T("件");
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
return sRet;
|
||
} |