2060 lines
50 KiB
C++
2060 lines
50 KiB
C++
#include "stdafx.h"
|
|
#include "DbVPipeDim.h"
|
|
#include "DbPipe.h"
|
|
#include "PipeWireMonitor.h"
|
|
#include "dbtext.h"
|
|
#include <algorithm>
|
|
|
|
#define LINK_SIGN _T('@')
|
|
#define VPIPE_DIM_TEXT _T("VPIPE_DIM_TEXT")
|
|
#define VPIPE_DIM_NUM _T("VPIPE_DIM_NUM")
|
|
#define VPIPE_DIM_FLOOR _T("VPIPE_DIM_FLOOR")
|
|
|
|
const Adesk::UInt8 TDbVPipeDim::g_nVersion = 1;
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSVPipeDim, ATSSymbWithText, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
1, ATS_VPIPEDIM, "ATS_VPIPEDIM图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
|
|
IMPLEMENT_TENTBASE(TDbVPipeDim);
|
|
|
|
extern BOOL WriteXdata(AcDbEntity *pEnt, const TCHAR*szName, const TCHAR*szValue);
|
|
void InitDbVPipeDim(BOOL bTrue)
|
|
{
|
|
if (bTrue)
|
|
{
|
|
TDbVPipeDim::rxInit();
|
|
TDbVPipeDim::InitMatchProtocol(TRUE);
|
|
}
|
|
else
|
|
{
|
|
TDbVPipeDim::InitMatchProtocol(FALSE);
|
|
deleteAcRxClass(TDbVPipeDim::desc());
|
|
}
|
|
}
|
|
|
|
static CString GetXDataByName(const AcDbObjectId &id,const TCHAR*szName)
|
|
{
|
|
CString sXData;
|
|
AcDbEntity *pEnt = NULL;
|
|
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead) == Acad::eOk)
|
|
{
|
|
resbuf *pRb = pEnt->xData(szName);
|
|
if (pRb != NULL)
|
|
{
|
|
CString csRet;
|
|
if (pRb != NULL)
|
|
{
|
|
resbuf *pTemp = pRb;
|
|
if (pTemp->rbnext != NULL)
|
|
{
|
|
pTemp = pTemp->rbnext;
|
|
if (pTemp->restype == 1000)
|
|
csRet = pTemp->resval.rstring;
|
|
}
|
|
}
|
|
ads_relrb(pRb);
|
|
sXData = csRet;
|
|
}
|
|
pEnt->close();
|
|
}
|
|
return sXData;
|
|
}
|
|
|
|
TDbVPipeDim::TDbVPipeDim()
|
|
{
|
|
m_nDimType = TVPipeDim::eDimType1;
|
|
m_nFloorType = TVPipeDim::eType1;
|
|
m_dDimLen = 0.0;
|
|
m_dRadius = 0.0;
|
|
m_dCurScale = -1;
|
|
}
|
|
|
|
TDbVPipeDim::~TDbVPipeDim()
|
|
{
|
|
|
|
}
|
|
|
|
void TDbVPipeDim::CopyPropertiesFrom(AcDbEntity *pSrc,unsigned gMatchFlag)
|
|
{
|
|
assertWriteEnabled();
|
|
TDbSymbWithText::CopyPropertiesFrom(pSrc, gMatchFlag);
|
|
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::subGetClassID(CLSID* pClsid) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::dwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbSymbWithText::dwgInFields(pFiler);
|
|
if(es != Acad::eOk)
|
|
return es;
|
|
|
|
Adesk::UInt8 nVer = 0;
|
|
pFiler->readItem(&nVer);
|
|
if(nVer>g_nVersion)
|
|
{// Version is too new
|
|
return Acad::eMakeMeProxy;
|
|
}
|
|
Adesk::UInt16 nDimType = 0;
|
|
pFiler->readItem(&nDimType);
|
|
m_nDimType = nDimType;
|
|
pFiler->readItem(&nDimType);
|
|
m_nFloorType = nDimType;
|
|
pFiler->readItem(&m_ptS);
|
|
pFiler->readItem(&m_ptTurn);
|
|
pFiler->readItem(&m_vtDir);
|
|
pFiler->readItem(&m_dDimLen);
|
|
|
|
pFiler->readItem(&m_dRadius);
|
|
pFiler->readSoftPointerId(&m_id);
|
|
XString sText;
|
|
ReadString(pFiler,sText);
|
|
m_sDimTypeText = sText;
|
|
|
|
//暂时解决BE1BUG
|
|
if (m_dDimLen > 10*GetTextLen())
|
|
m_dDimLen = GetTextLen();
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::dwgOutFields(AcDbDwgFiler *pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es = TDbSymbWithText::dwgOutFields(pFiler);
|
|
if(es != Acad::eOk)
|
|
return es;
|
|
|
|
pFiler->writeItem(g_nVersion);
|
|
pFiler->writeItem((Adesk::UInt16)m_nDimType);
|
|
pFiler->writeItem((Adesk::UInt16)m_nFloorType);
|
|
pFiler->writeItem(m_ptS);
|
|
pFiler->writeItem(m_ptTurn);
|
|
pFiler->writeItem(m_vtDir);
|
|
pFiler->writeItem(m_dDimLen);
|
|
pFiler->writeItem(m_dRadius);
|
|
pFiler->writeSoftPointerId(m_id);
|
|
pFiler->writeString((LPCTSTR)m_sDimTypeText);
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::dxfInFields (AcDbDxfFiler *pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbSymbWithText::dxfInFields(pFiler);
|
|
if(es!=Acad::eOk)
|
|
return pFiler->filerStatus();
|
|
if (!pFiler->atSubclassData(_T("TDbVPipeDim")))
|
|
{
|
|
return Acad::eBadDxfSequence;
|
|
}
|
|
|
|
resbuf rb;
|
|
while((es==Acad::eOk) && ((es=pFiler->readResBuf(&rb))==Acad::eOk)) {
|
|
switch (rb.restype) {
|
|
case AcDb::kDxfXTextString:
|
|
m_sFloorNum=rb.resval.rstring;
|
|
break;
|
|
default:
|
|
pFiler->pushBackItem();
|
|
es = Acad::eEndOfFile;
|
|
break;
|
|
}
|
|
}
|
|
if(es!=Acad::eEndOfFile)
|
|
return Acad::eInvalidResBuf;
|
|
|
|
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::dxfOutFields(AcDbDxfFiler *pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es=TDbSymbWithText::dxfOutFields(pFiler);
|
|
assert(es == Acad::eOk);
|
|
es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbVPipeDim"));
|
|
assert(es == Acad::eOk);
|
|
|
|
CString sFloorNum = GetXDataByName(m_id, _T("BUILDING-SERIAL"));
|
|
pFiler->writeString(AcDb::kDxfXTextString,(const TCHAR*)sFloorNum);//2011-9-30 sr 增加DXF 300 为楼号,方便过滤选择
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
|
|
if (m_nDimType != TVPipeDim::eDimType2)
|
|
{
|
|
// TDbSymbMultiLeader::getGripPoints(gripPoints,osnapModes,geomIds);
|
|
/*
|
|
gripPoints.append(m_ptS);
|
|
gripPoints.append(m_ptTurn);
|
|
double dLen = m_dDimLen*GetPScale();
|
|
AcGePoint3d ptE = m_ptTurn + m_vtDir*dLen;
|
|
gripPoints.append(ptE);
|
|
*/
|
|
CString sText;
|
|
GetDimText(m_id,sText);
|
|
double dTextLen = GetTextLen()*GetPScale();
|
|
|
|
AcGeVector3d vtY = AcGeVector3d::kYAxis;
|
|
AcGeVector3d vtX = AcGeVector3d::kXAxis;
|
|
//获取文字点
|
|
AcGePoint3d ptText;
|
|
if (m_nDimType == TVPipeDim::eDimType2)
|
|
{
|
|
ptText = m_ptTurn;
|
|
}
|
|
else
|
|
{
|
|
ptText = m_ptTurn + (m_dDimLen*GetPScale() - dTextLen/2)*m_vtDir;
|
|
}
|
|
|
|
double dLineLen = m_dDimLen;
|
|
//绘制文字
|
|
CString sText1,sText2;
|
|
int nFind = sText.Find(LINK_SIGN,0);
|
|
if (nFind != -1)
|
|
{
|
|
sText1 = sText.Left(nFind);
|
|
sText2 = sText.Mid(nFind + 1);
|
|
}
|
|
|
|
TDbSymbMultiLeader ent;
|
|
ent.SetText1(sText);
|
|
ent.SetLeaderPoint(m_ptTurn);
|
|
XPointList lst;
|
|
lst.Append(new XPoint(m_ptS));
|
|
|
|
ent.setPropertiesFrom(this);
|
|
ent.SetLayoutRotation(this->GetLayoutRotation());
|
|
ent.SetLeaderVertexes(lst);
|
|
ent.SetSideText(FALSE);
|
|
ent.SetArrow(TDbSymbMultiLeader::kNone);
|
|
ent.SetTextLayerId(this->GetTextLayerId());
|
|
ent.SetTextStyleId(this->GetTextStyleId());
|
|
ent.SetTextHeight(GetTextHeight());
|
|
ent.SetText2BaseRatio(0.2);
|
|
|
|
if (m_vtDir.angleTo(vtX) > PI/2)
|
|
ent.SetTextBaseLen(-dLineLen);
|
|
else
|
|
ent.SetTextBaseLen(dLineLen);
|
|
|
|
AcGePoint3dArray gripPointsT;
|
|
ent.subGetGripPoints(gripPointsT,osnapModes,geomIds);
|
|
|
|
if (gripPointsT.length() >= 3)
|
|
{
|
|
gripPoints.append(gripPointsT[2]);
|
|
gripPoints.append(gripPointsT[0]);
|
|
gripPoints.append(gripPointsT[1]);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
gripPoints.append(m_ptTurn);
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
|
|
{
|
|
if (m_nDimType != TVPipeDim::eDimType2)
|
|
{
|
|
// TDbSymbMultiLeader::getGripPoints(gripPoints,osnapModes,geomIds);
|
|
/*
|
|
gripPoints.append(m_ptS);
|
|
gripPoints.append(m_ptTurn);
|
|
double dLen = m_dDimLen*GetPScale();
|
|
AcGePoint3d ptE = m_ptTurn + m_vtDir*dLen;
|
|
gripPoints.append(ptE);
|
|
*/
|
|
CString sText;
|
|
GetDimText(m_id,sText);
|
|
double dTextLen = GetTextLen()*GetPScale();
|
|
|
|
AcGeVector3d vtY = AcGeVector3d::kYAxis;
|
|
AcGeVector3d vtX = AcGeVector3d::kXAxis;
|
|
//获取文字点
|
|
AcGePoint3d ptText;
|
|
if (m_nDimType == TVPipeDim::eDimType2)
|
|
{
|
|
ptText = m_ptTurn;
|
|
}
|
|
else
|
|
{
|
|
ptText = m_ptTurn + (m_dDimLen*GetPScale() - dTextLen/2)*m_vtDir;
|
|
}
|
|
|
|
double dLineLen = m_dDimLen;
|
|
//绘制文字
|
|
CString sText1,sText2;
|
|
int nFind = sText.Find(LINK_SIGN,0);
|
|
if (nFind != -1)
|
|
{
|
|
sText1 = sText.Left(nFind);
|
|
sText2 = sText.Mid(nFind + 1);
|
|
}
|
|
|
|
TDbSymbMultiLeader ent;
|
|
ent.SetText1(sText);
|
|
ent.SetLeaderPoint(m_ptTurn);
|
|
XPointList lst;
|
|
lst.Append(new XPoint(m_ptS));
|
|
|
|
ent.setPropertiesFrom(this);
|
|
ent.SetLayoutRotation(this->GetLayoutRotation());
|
|
ent.SetLeaderVertexes(lst);
|
|
ent.SetSideText(FALSE);
|
|
ent.SetArrow(TDbSymbMultiLeader::kNone);
|
|
ent.SetTextLayerId(this->GetTextLayerId());
|
|
ent.SetTextStyleId(this->GetTextStyleId());
|
|
ent.SetTextHeight(GetTextHeight());
|
|
ent.SetText2BaseRatio(0.2);
|
|
|
|
if (m_vtDir.angleTo(vtX) > PI/2)
|
|
ent.SetTextBaseLen(-dLineLen);
|
|
else
|
|
ent.SetTextBaseLen(dLineLen);
|
|
|
|
AcGePoint3dArray gripPointsT;
|
|
ent.subGetStretchPoints(gripPointsT);
|
|
|
|
if (gripPointsT.length() >= 3)
|
|
{
|
|
stretchPoints.append(gripPointsT[2]);
|
|
stretchPoints.append(gripPointsT[0]);
|
|
stretchPoints.append(gripPointsT[1]);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
stretchPoints.append(m_ptTurn);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::subMoveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset)
|
|
{
|
|
// cet 2016.12.9 add 移动起点时,更新标注与立管的关联关系
|
|
AcGePoint3dArray gripPoints;
|
|
AcDbIntArray osnapModes, geomIds;
|
|
subGetGripPoints(gripPoints, osnapModes, geomIds);
|
|
if (indices.length() == 1 && gripPoints.length() >= 1 && m_ptS.distanceTo(gripPoints[indices[0] ]) < 0.001)
|
|
{
|
|
TPipePerDocData *pData = GetCurPipeDocData();
|
|
if (pData != NULL)
|
|
{
|
|
pData->m_lstCloseEntity.Append(new AcDbObjectId(objectId()));
|
|
assertWriteEnabled();
|
|
}
|
|
}
|
|
|
|
if (indices.length() == 1)
|
|
{
|
|
assertWriteEnabled();
|
|
if (m_nDimType != TVPipeDim::eDimType2)
|
|
{
|
|
if (indices[0] == 2)
|
|
{
|
|
// zxl 2013.08.29 modify
|
|
m_vtDir.rotateBy(m_nLayoutRotation, AcGeVector3d::kZAxis);
|
|
AcGeVector3d vtX = m_vtDir;
|
|
vtX.rotateBy(PI/2,AcGeVector3d::kZAxis);
|
|
AcGeVector3d vtDir = offset.orthoProject(vtX);
|
|
|
|
AcGePoint3d ptE = m_ptTurn + m_dDimLen*GetPScale()*m_vtDir;
|
|
ptE += vtDir;
|
|
m_dDimLen = m_ptTurn.distanceTo(ptE)/GetPScale();
|
|
m_vtDir = ptE - m_ptTurn;
|
|
// zxl 2013.08.29 modify
|
|
m_vtDir.rotateBy(-m_nLayoutRotation, AcGeVector3d::kZAxis);
|
|
m_vtDir.normalize();
|
|
AcGeTol tol;
|
|
tol.setEqualVector(0.001);
|
|
if (m_vtDir.isZeroLength(tol))
|
|
{
|
|
m_dDimLen = GetTextLen();
|
|
m_vtDir = AcGeVector3d::kXAxis;
|
|
}
|
|
}
|
|
else if (indices[0] == 1)
|
|
{
|
|
// cet 2014.11.24 add m_vtDir的方向没有与布局角度所在方向上平行,重新设置m_vtDir(一般情况下m_vtDir方向与x轴正负方向相同(即文字方向平行于x轴))
|
|
AcGeVector3d vtTempX = Ucs2Wcs(AcGeVector3d::kXAxis, TRUE);
|
|
vtTempX.rotateBy(m_nLayoutRotation, AcGeVector3d::kZAxis);
|
|
AcGeTol tol;
|
|
tol.setEqualVector(0.001);
|
|
if (vtTempX.isCodirectionalTo(m_vtDir,tol) != Adesk::kTrue && vtTempX.isCodirectionalTo(-m_vtDir,tol) != Adesk::kTrue)
|
|
{
|
|
m_vtDir = Ucs2Wcs(m_ptS).x > Ucs2Wcs(m_ptTurn).x ? Ucs2Wcs(-AcGeVector3d::kXAxis) : Ucs2Wcs(AcGeVector3d::kXAxis);
|
|
m_vtDir.rotateBy(m_nLayoutRotation, AcGeVector3d::kZAxis);
|
|
}
|
|
|
|
m_ptTurn += offset;
|
|
|
|
// 拉伸时根据引线角度确定基线方向 zxl 2013.07.23 add
|
|
AcGeVector3d vtX = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtDir = m_ptTurn - m_ptS;
|
|
vtDir.rotateBy(-m_nLayoutRotation, AcGeVector3d::kZAxis);
|
|
double dAng = AcGeVector3d::kXAxis.angleTo(vtDir, AcGeVector3d::kZAxis);
|
|
if ((dAng > PI / 2 && dAng < PI * 3 / 2 && m_vtDir.angleTo(vtX) < PI/2) || ((dAng < PI / 2 || dAng > PI * 3 / 2) && m_vtDir.angleTo(vtX) > PI/2))
|
|
{
|
|
m_vtDir = - m_vtDir;
|
|
}
|
|
|
|
// cet 2014.4.28 add 正交情况下,且标注为直角时,可以轻微移动只改变基线方向
|
|
AcGeVector3d vtTemp = m_ptTurn - offset - m_ptS;
|
|
vtTemp.z = 0.0;
|
|
AcGeVector3d vtTemp2 = m_vtDir;
|
|
vtTemp2.rotateBy(m_nLayoutRotation, AcGeVector3d::kZAxis);
|
|
vtTemp2.z = 0.0;
|
|
int nOsMode = 0;
|
|
xg_getvar(_T("ORTHOMODE"), &nOsMode);
|
|
double dd = fabs(vtTemp.angleTo(vtTemp2) - PI * 0.5);
|
|
if (fabs(vtTemp.angleTo(vtTemp2) - PI * 0.5) < 0.001 && nOsMode == 1)
|
|
{
|
|
double dDist = 50;
|
|
if (DocGetMeterUnitDraw())
|
|
{
|
|
dDist = 0.5;
|
|
}
|
|
if (offset.length() < dDist)
|
|
{
|
|
m_ptTurn -= offset;
|
|
}
|
|
}
|
|
}
|
|
else if (indices[0] == 0)
|
|
{
|
|
m_ptS += offset;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (indices[0] == 0)
|
|
{
|
|
m_ptTurn += offset;
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::subMoveStretchPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
// cet 2016.12.9 add 拖拽起点时,更新标注与立管的关联关系
|
|
AcGePoint3dArray stretchPoints;
|
|
subGetStretchPoints(stretchPoints);
|
|
if (indices.length() == 1 && stretchPoints.length() >= 1 && m_ptS.distanceTo(stretchPoints[indices[0] ]) < 0.001)
|
|
{
|
|
TPipePerDocData *pData = GetCurPipeDocData();
|
|
if (pData != NULL)
|
|
{
|
|
pData->m_lstCloseEntity.Append(new AcDbObjectId(objectId()));
|
|
}
|
|
}
|
|
if (m_nDimType != TVPipeDim::eDimType2)
|
|
{
|
|
if (indices.length() <= 2)
|
|
{
|
|
if (indices[0] == 2)
|
|
{
|
|
AcGeVector3d vtX = m_vtDir;
|
|
vtX.rotateBy(PI/2,AcGeVector3d::kZAxis);
|
|
AcGeVector3d vtDir = offset.orthoProject(vtX);
|
|
|
|
AcGePoint3d ptE = m_ptTurn + m_dDimLen*GetPScale()*m_vtDir;
|
|
ptE += vtDir;
|
|
m_dDimLen = m_ptTurn.distanceTo(ptE)/GetPScale();
|
|
|
|
m_vtDir = ptE - m_ptTurn;
|
|
m_vtDir.normalize();
|
|
}
|
|
else if (indices[0] == 1)
|
|
{
|
|
// cet 2017.9.8 modify 拖拽时更新标注文字及基线位置
|
|
// m_ptTurn += offset;
|
|
AcDbIntArray indices;
|
|
indices.append(1);
|
|
subMoveGripPointsAt(indices, offset);
|
|
}
|
|
else if (indices[0] == 0)
|
|
{
|
|
m_ptS += offset;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_ptS += offset;
|
|
m_ptTurn += offset;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (indices[0] == 0)
|
|
{
|
|
m_ptTurn += offset;
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
assertWriteEnabled();
|
|
TDbEntity::subTransformBy(xform);
|
|
|
|
AcGePoint3d ptS = m_ptS;
|
|
m_ptS.transformBy(xform);
|
|
m_ptTurn.transformBy(xform);
|
|
m_vtDir.transformBy(xform);
|
|
|
|
XPoint ptUcs = Wcs2Ucs(ptS);
|
|
|
|
//SR 2009-7-21 修改以下: 如果立管标注位置发生变化,将ID写入m_lstCloseEntity,等命令反应器统一操作
|
|
if (m_ptS.distanceTo(ptS) > 1e-3 && objectId().isValid() && m_ptS != ptUcs)
|
|
{
|
|
TPipePerDocData *pData = GetCurPipeDocData();
|
|
ASSERT(pData);
|
|
if(pData) {
|
|
pData->m_lstCloseEntity.Append(new AcDbObjectId(objectId()));;
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::ExplodeOrDraw2d(XExplodeDraw &dc) const
|
|
{
|
|
// cet 2016.10.17 add 图层关闭时,实体不显示,不进行绘制(打印时,也不会绘制)
|
|
AcDbLayerTableRecordPointer player(this->layerId(), AcDb::kForRead);
|
|
if (player.openStatus() == Acad::eOk && player->isOff())
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
//绘制线
|
|
ExplodeOrDraw2dLine(dc);
|
|
|
|
//绘制文字
|
|
ExplodeOrDraw2dText(dc);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//设置起点
|
|
void TDbVPipeDim::SetStartPt(const AcGePoint3d& pt)
|
|
{
|
|
assertWriteEnabled();
|
|
m_ptS = pt;
|
|
}
|
|
|
|
//设置拐点
|
|
void TDbVPipeDim::SetTurnPt(const AcGePoint3d& pt)
|
|
{
|
|
assertWriteEnabled();
|
|
m_ptTurn = pt;
|
|
}
|
|
|
|
//设置立管标注类型文字
|
|
void TDbVPipeDim::SetDimTypeText(LPCTSTR lpText)
|
|
{
|
|
assertWriteEnabled();
|
|
if (lpText != NULL)
|
|
m_sDimTypeText = lpText;
|
|
|
|
SaveCurText();
|
|
}
|
|
|
|
//设置标注样式
|
|
void TDbVPipeDim::SetDimType(int nType)
|
|
{
|
|
assertWriteEnabled();
|
|
m_nDimType = nType;
|
|
|
|
SaveCurText();
|
|
}
|
|
|
|
int TDbVPipeDim::GetDimType()
|
|
{
|
|
return m_nDimType;
|
|
}
|
|
|
|
//绘制线
|
|
Acad::ErrorStatus TDbVPipeDim::ExplodeOrDraw2dLine(XExplodeDraw &dc) const
|
|
{
|
|
double dLen = m_dDimLen*GetPScale();
|
|
AcGeVector3d vtX = Ucs2Wcs(AcGeVector3d::kXAxis);
|
|
AcGeVector3d vtY = Ucs2Wcs(AcGeVector3d::kYAxis);
|
|
AcDbPolyline Polyline;
|
|
switch(m_nDimType)
|
|
{
|
|
case TVPipeDim::eDimType1:
|
|
case TVPipeDim::eDimType3:
|
|
case TVPipeDim::eDimType4:
|
|
{
|
|
/*
|
|
AcGePoint3d ptEnd = m_ptTurn + m_vtDir*dLen;
|
|
Polyline.addVertexAt(0,m_ptS.convert2d(AcGePlane::kXYPlane));
|
|
Polyline.addVertexAt(1,m_ptTurn.convert2d(AcGePlane::kXYPlane));
|
|
Polyline.addVertexAt(2,ptEnd.convert2d(AcGePlane::kXYPlane));
|
|
dc.DrawEntity(Polyline);
|
|
*/
|
|
}
|
|
break;
|
|
case TVPipeDim::eDimType2:
|
|
{
|
|
/*
|
|
AcGePoint3d ptS,ptE;
|
|
ptS = m_ptTurn + m_vtDir*m_dRadius*DocGetPScale();
|
|
ptE = m_ptTurn - m_vtDir*m_dRadius*DocGetPScale();
|
|
|
|
AcGeVector3d vt1(ptS-m_ptTurn);
|
|
AcGeVector3d vt2(ptE-m_ptTurn);
|
|
double dAngle1 = vt1.angleTo(vt2);
|
|
double dBulge1 = tan(0.25 * dAngle1);
|
|
double dAngle2 = vt2.angleTo(vt1);
|
|
double dBulge2 = tan(0.25 * dAngle2);
|
|
Polyline.addVertexAt(0,ptS.convert2d(AcGePlane::kXYPlane),dBulge1);
|
|
Polyline.addVertexAt(1,ptE.convert2d(AcGePlane::kXYPlane),dBulge2);
|
|
Polyline.addVertexAt(2,ptS.convert2d(AcGePlane::kXYPlane),dBulge1);
|
|
dc.DrawEntity(Polyline);
|
|
|
|
XLine line((XPoint)ptS,(XPoint)ptE);
|
|
dc.DrawLine(line);
|
|
*/
|
|
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//绘制文字
|
|
Acad::ErrorStatus TDbVPipeDim::ExplodeOrDraw2dText(XExplodeDraw &dc) const
|
|
{
|
|
if(_tcsicmp(dc.Desc(), XExplodeStream::Descriptor())!=0 && !objectId().isValid()) { //动态预览 2009-8-18 sr add (wyg 修改随块颜色打印崩溃)
|
|
XAcGiViewDraw &dcDraw = (XAcGiViewDraw&)dc;
|
|
dcDraw.GetCommonDraw()->subEntityTraits().setColor(3);
|
|
}
|
|
|
|
CString sText;
|
|
GetDimText(m_id,sText);
|
|
double dTextLen = GetTextLen()*GetPScale();
|
|
|
|
AcGeVector3d vtY = AcGeVector3d::kYAxis;
|
|
AcGeVector3d vtX = AcGeVector3d::kXAxis;
|
|
//获取文字点
|
|
AcGePoint3d ptText;
|
|
if (m_nDimType == TVPipeDim::eDimType2)
|
|
{
|
|
ptText = m_ptTurn;
|
|
}
|
|
else
|
|
{
|
|
// zxl 2013.08.29 modify
|
|
AcGeVector3d vt = m_vtDir;
|
|
vt.rotateBy(m_nLayoutRotation, AcGeVector3d::kZAxis);
|
|
vt.normalize();
|
|
ptText = m_ptTurn + (m_dDimLen*GetPScale() - dTextLen/2)*vt;
|
|
// ptText = m_ptTurn + (m_dDimLen*GetPScale() - dTextLen/2)*m_vtDir;
|
|
}
|
|
|
|
//绘制文字
|
|
CString sText1,sText2;
|
|
int nFind = sText.Find(LINK_SIGN,0);
|
|
if (nFind != -1)
|
|
{
|
|
sText1 = sText.Left(nFind);
|
|
sText2 = sText.Mid(nFind + 1);
|
|
}
|
|
|
|
double dLineLen = m_dDimLen;
|
|
if (m_nDimType == TVPipeDim::eDimType2)
|
|
{
|
|
TDbSymbDrawingIndex ent;
|
|
ent.setPropertiesFrom(this);
|
|
ent.SetCenter(m_ptTurn);
|
|
ent.SetRadius(m_dRadius);
|
|
ent.SetIndexLabel(sText1);
|
|
ent.SetDrawingLabel(sText2);
|
|
ent.SetLayoutRotation(this->GetLayoutRotation());
|
|
ent.SetTextLayerId(this->GetTextLayerId());
|
|
ent.SetTextStyleId(this->GetTextStyleId());
|
|
ent.SetTextHeight(GetTextHeight());
|
|
ent.SetLineWidth(0);
|
|
ent.setColorIndex(256);
|
|
ent.SetOldStyle(0); // cq 2016-09-01 设置默认风格为 标注在圈内
|
|
ent.ExplodeOrDraw2d(dc);
|
|
}
|
|
else if (m_nDimType == TVPipeDim::eDimType1 || m_nDimType == TVPipeDim::eDimType3 || m_nDimType == TVPipeDim::eDimType6) // cet 2014.6.17 modify 添加样式6 DN100的绘制
|
|
{
|
|
TDbSymbMultiLeader ent;
|
|
ent.SetText1(sText);
|
|
ent.SetLeaderPoint(m_ptTurn);
|
|
XPointList lst;
|
|
lst.Append(new XPoint(m_ptS));
|
|
|
|
ent.setPropertiesFrom(this);
|
|
ent.SetLayoutRotation(this->GetLayoutRotation());
|
|
ent.SetLeaderVertexes(lst);
|
|
ent.SetSideText(FALSE);
|
|
ent.SetArrow(TDbSymbMultiLeader::kNone);
|
|
ent.SetTextLayerId(this->GetTextLayerId());
|
|
ent.SetTextStyleId(this->GetTextStyleId());
|
|
ent.SetTextHeight(GetTextHeight());
|
|
ent.SetText2BaseRatio(m_dRadius/10.0);
|
|
|
|
if (m_vtDir.angleTo(vtX) > PI/2)
|
|
ent.SetTextBaseLen(-dLineLen);
|
|
else
|
|
ent.SetTextBaseLen(dLineLen);
|
|
|
|
ent.ExplodeOrDraw2d(dc);
|
|
}
|
|
else if (m_nDimType == TVPipeDim::eDimType4)
|
|
{
|
|
TDbSymbMultiLeader ent;
|
|
ent.SetText1(sText1);
|
|
//ent.SetText2(sText2); cet 2012.4.19 del
|
|
ent.SetLeaderPoint(m_ptTurn);
|
|
XPointList lst;
|
|
lst.Append(new XPoint(m_ptS));
|
|
|
|
ent.setPropertiesFrom(this);
|
|
ent.SetLeaderVertexes(lst);
|
|
double dR = GetPScale();
|
|
if (m_vtDir.angleTo(vtX) > PI/2)
|
|
ent.SetTextBaseLen(-dLineLen);
|
|
else
|
|
ent.SetTextBaseLen(dLineLen);
|
|
ent.SetSideText(FALSE);
|
|
ent.SetArrow(TDbSymbMultiLeader::kNone);
|
|
ent.SetLayoutRotation(this->GetLayoutRotation());
|
|
ent.SetTextLayerId(this->GetTextLayerId());
|
|
ent.SetTextStyleId(this->GetTextStyleId());
|
|
ent.SetTextHeight(GetTextHeight());
|
|
ent.SetText2BaseRatio(m_dRadius/10.0);
|
|
// cet 2012.10.17 add sText1对齐方式与sText2保持一致
|
|
switch(GetAlignTypeForDimType4())
|
|
{
|
|
case 0: // 左对齐
|
|
{
|
|
ent.SetTextAlign(TDbSymbMultiLeader::kAtStart);
|
|
break;
|
|
}
|
|
case 1: // 居中
|
|
{
|
|
ent.SetTextAlign(TDbSymbMultiLeader::kAtMiddle);
|
|
break;
|
|
}
|
|
case 2: // 右对齐
|
|
default:
|
|
{
|
|
ent.SetTextAlign(TDbSymbMultiLeader::kAtEnd);
|
|
break;
|
|
}
|
|
}
|
|
ent.ExplodeOrDraw2d(dc);
|
|
|
|
|
|
// cet 2012.4.19 add 绘制管径文字
|
|
if (GetShowDnForDimType4())
|
|
{
|
|
TDbText text;
|
|
text.setPropertiesFrom(this);
|
|
AcDbObjectId id = this->GetTextStyleId();
|
|
text.SetStyleId(id);
|
|
text.SetHeight(this->GetTextHeight());
|
|
//cet 2012.6.26 modify 图层颜色设置错误
|
|
//text.setLayer(this->GetTextLayerId());
|
|
text.setLayer(this->layerId());
|
|
text.setColorIndex(GetTextColor()); // cet 2018.1.11 modify 文字颜色可随文字颜色接口设置变化
|
|
|
|
text.SetText((const TCHAR*)sText2);
|
|
text.SetRotation(0.0);
|
|
AcGePoint3d ptLoc;
|
|
|
|
// zxl 2013.08.29 modify
|
|
//AcGeVector3d vt = ptText - m_ptTurn;
|
|
AcGeVector3d vt = m_vtDir;
|
|
vt.rotateBy(m_nLayoutRotation, AcGeVector3d::kZAxis);
|
|
|
|
vt.z = 0.0;
|
|
vt.normalize();
|
|
double dDistV = ent.GetText2BaseRatio() * GetPScale(); // 垂直间距
|
|
double dDistH = 0.0; // 水平间距
|
|
dDistH = DocGetMultiLeaderDistRatio()*m_nTextHeight*GetPScale();
|
|
switch(GetAlignTypeForDimType4())
|
|
{
|
|
case 0: // 左对齐
|
|
{
|
|
if (m_vtDir.angleTo(vtX) > PI/2)
|
|
{
|
|
AcGeVector3d vtTemp = vt;
|
|
vtTemp.rotateBy(PI/2, AcGeVector3d::kZAxis);
|
|
// zxl 2013.08.29 modify
|
|
ptLoc = m_ptTurn + vtTemp * dDistV;
|
|
text.SetAlignment(XExplodeDraw::kTopRight);
|
|
}
|
|
else
|
|
{
|
|
AcGeVector3d vtTemp = vt;
|
|
vtTemp.rotateBy(-PI/2, AcGeVector3d::kZAxis);
|
|
// zxl 2013.08.29 modify
|
|
ptLoc = m_ptTurn + vt * dDistH + vtTemp * dDistV;
|
|
text.SetAlignment(XExplodeDraw::kTopLeft);
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 1: // 居中
|
|
{
|
|
if (m_vtDir.angleTo(vtX) > PI/2)
|
|
{
|
|
AcGeVector3d vtTemp = vt;
|
|
vtTemp.rotateBy(PI/2, AcGeVector3d::kZAxis);
|
|
ptLoc = m_ptTurn + vt * (m_dDimLen*GetPScale() * 0.5) + vtTemp * dDistV;
|
|
}
|
|
else
|
|
{
|
|
AcGeVector3d vtTemp = vt;
|
|
vtTemp.rotateBy(-PI/2, AcGeVector3d::kZAxis);
|
|
ptLoc = m_ptTurn + vt * (m_dDimLen*GetPScale() * 0.5) + vtTemp * dDistV;
|
|
}
|
|
text.SetAlignment(XExplodeDraw::kTopCenter);
|
|
break;
|
|
}
|
|
case 2: // 右对齐
|
|
default:
|
|
{
|
|
if (m_vtDir.angleTo(vtX) > PI/2)
|
|
{
|
|
AcGeVector3d vtTemp = vt;
|
|
vtTemp.rotateBy(PI/2, AcGeVector3d::kZAxis);
|
|
// zxl 2013.08.29 modify
|
|
ptLoc = m_ptTurn + vt * (m_dDimLen*GetPScale()) + vtTemp * dDistV;
|
|
text.SetAlignment(XExplodeDraw::kTopLeft);
|
|
}
|
|
else
|
|
{
|
|
AcGeVector3d vtTemp = vt;
|
|
vtTemp.rotateBy(-PI/2, AcGeVector3d::kZAxis);
|
|
// zxl 2013.08.29 modify
|
|
ptLoc = m_ptTurn + vt * (m_dDimLen*GetPScale()) + vtTemp * dDistV;
|
|
text.SetAlignment(XExplodeDraw::kTopRight);
|
|
if (fabs(m_dDimLen) < 0.001)// 拐点与基线终点重合时
|
|
{
|
|
ptLoc += vt * dDistH;
|
|
text.SetAlignment(XExplodeDraw::kTopLeft);
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
text.SetLocation(ptLoc);
|
|
text.ExplodeOrDraw2d(dc);
|
|
}
|
|
}
|
|
else if (m_nDimType == TVPipeDim::eDimType5)// zxl 2013.08.23 add 添加新的立管标注样式
|
|
{
|
|
TDbSymbMultiLeader ent;
|
|
ent.SetText1(sText1);
|
|
ent.SetLeaderPoint(m_ptTurn);
|
|
XPointList lst;
|
|
lst.Append(new XPoint(m_ptS));
|
|
|
|
ent.setPropertiesFrom(this);
|
|
ent.SetLeaderVertexes(lst);
|
|
double dR = GetPScale();
|
|
if (m_vtDir.angleTo(vtX) > PI/2)
|
|
ent.SetTextBaseLen(-dLineLen);
|
|
else
|
|
ent.SetTextBaseLen(dLineLen);
|
|
ent.SetSideText(FALSE);
|
|
ent.SetArrow(TDbSymbMultiLeader::kNone);
|
|
ent.SetLayoutRotation(this->GetLayoutRotation());
|
|
ent.SetTextLayerId(this->GetTextLayerId());
|
|
ent.SetTextStyleId(this->GetTextStyleId());
|
|
ent.SetTextHeight(GetTextHeight());
|
|
ent.SetText2BaseRatio(m_dRadius/10.0);
|
|
if (m_vtDir.angleTo(vtX) > PI/2)
|
|
{
|
|
ent.SetTextAlign(TDbSymbMultiLeader::kAtEnd);
|
|
}
|
|
else
|
|
{
|
|
ent.SetTextAlign(TDbSymbMultiLeader::kAtStart);
|
|
}
|
|
ent.ExplodeOrDraw2d(dc);
|
|
|
|
// 绘制管径文字
|
|
TDbText text;
|
|
text.setPropertiesFrom(this);
|
|
AcDbObjectId id = this->GetTextStyleId();
|
|
text.SetStyleId(id);
|
|
text.SetHeight(this->GetTextHeight());
|
|
text.setLayer(this->layerId());
|
|
text.setColorIndex(GetTextColor()); // cet 2018.1.11 modify 文字颜色可随文字颜色接口设置变化
|
|
|
|
text.SetText((const TCHAR*)sText2);
|
|
text.SetRotation(0.0);
|
|
double dDistV = ent.GetText2BaseRatio() * GetPScale(); // 垂直间距
|
|
|
|
XPoint ptLoc;
|
|
vtY.rotateBy(this->GetLayoutRotation(), AcGeVector3d::kZAxis);
|
|
AcGeVector3d vt = m_vtDir;
|
|
vt.rotateBy(m_nLayoutRotation, AcGeVector3d::kZAxis);
|
|
vt.normalize();
|
|
if (m_vtDir.angleTo(vtX) > PI/2)
|
|
{
|
|
ptLoc = m_ptTurn + (m_dDimLen*GetPScale())*vt;
|
|
ptLoc -= vt * GetDnDistance2LabelLoc();
|
|
}
|
|
else
|
|
{
|
|
ptLoc = m_ptTurn;
|
|
ptLoc += vt * GetDnDistance2LabelLoc();
|
|
}
|
|
ptLoc += vtY * dDistV;
|
|
|
|
text.SetAlignment(XExplodeDraw::kBottomLeft);
|
|
text.SetLocation(ptLoc);
|
|
text.ExplodeOrDraw2d(dc);
|
|
}
|
|
/*
|
|
else
|
|
{
|
|
ptText += vtY*(DocGetText2Base() + 0.5)*DocGetPScale()*GetTextHeight();
|
|
ptText += m_vtDir*m_dDimLen;
|
|
//两行文字
|
|
TDbText text1;
|
|
text1.setPropertiesFrom(this);
|
|
text1.SetText((const TCHAR*)sText1);
|
|
AcDbObjectId id = this->GetTextStyleId();
|
|
text1.SetStyleId(id);
|
|
text1.SetLocation(ptText);
|
|
text1.SetHeight(this->GetTextHeight());
|
|
text1.SetRotation(Ucs2Wcs(0.0));
|
|
text1.setLayer(this->GetTextLayerId());
|
|
text1.SetAlignment(XExplodeDraw::kBottomRight);
|
|
|
|
TPushProperty vProp1(&text1, dc);
|
|
if(dc.IsFullExplode())
|
|
text1.ExplodeOrDraw2d(dc);
|
|
else
|
|
dc.DrawEntity(text1);
|
|
|
|
ptText -= vtY*(DocGetText2Base() + 0.5)*DocGetPScale()*GetTextHeight()*2;
|
|
TDbText text2;
|
|
text2.setPropertiesFrom(this);
|
|
text2.SetText((const TCHAR*)sText2);
|
|
text2.SetStyleId(id);
|
|
text2.SetLocation(ptText);
|
|
text2.SetHeight(this->GetTextHeight());
|
|
text2.SetRotation(Ucs2Wcs(0.0));
|
|
text2.setLayer(this->GetTextLayerId());
|
|
text2.SetAlignment(XExplodeDraw::kTopRight);
|
|
|
|
TPushProperty vProp2(&text2, dc);
|
|
if(dc.IsFullExplode())
|
|
text2.ExplodeOrDraw2d(dc);
|
|
else
|
|
dc.DrawEntity(text2);
|
|
}
|
|
*/
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//设置立管ID
|
|
void TDbVPipeDim::SetVPipeId(const AcDbObjectId &id)
|
|
{
|
|
assertWriteEnabled();
|
|
m_id = id;
|
|
|
|
if (m_dDimLen < GetTextLen())
|
|
m_dDimLen = GetTextLen();
|
|
|
|
if (m_id.isValid())
|
|
SaveCurText();
|
|
}
|
|
|
|
//得到文字长度
|
|
double TDbVPipeDim::GetTextLen() const
|
|
{
|
|
double dLen = 2000.0;
|
|
|
|
CString sText,sText1,sText2;
|
|
GetDimText(m_id,sText);
|
|
double dHeight = GetTextHeight();
|
|
int nFind = sText.Find(LINK_SIGN,0);
|
|
if (nFind != -1)
|
|
{
|
|
sText1 = sText.Left(nFind);
|
|
sText2 = sText.Mid(nFind + 1);
|
|
|
|
if (sText1.GetLength() > sText2.GetLength())
|
|
sText = sText1;
|
|
else
|
|
sText = sText2;
|
|
// zxl 2013.08.28 add
|
|
if (m_nDimType == TVPipeDim::eDimType5)
|
|
{
|
|
sText = sText2;
|
|
}
|
|
}
|
|
|
|
AcDbObjectId idStyle = this->GetTextStyleId();
|
|
CString sStyleName = GetSymbolName(idStyle).cs();
|
|
struct resbuf* pRb = acutBuildList(RTDXF0, _T("TEXT"),
|
|
1, sText,
|
|
7, sStyleName,
|
|
40, dHeight,
|
|
41, GetPScale(),
|
|
0);
|
|
|
|
ads_point adsPt1, adsPt2;
|
|
int iRet = acedTextBox(pRb, adsPt1, adsPt2);
|
|
dLen = asPnt3d(adsPt1).distanceTo(asPnt3d(adsPt2)) + dHeight*DocGetPScale();
|
|
acutRelRb(pRb);
|
|
|
|
TDbText text;
|
|
text.setPropertiesFrom(this);
|
|
text.SetText((const TCHAR*)sText);
|
|
AcDbObjectId id = this->GetTextStyleId();
|
|
text.SetStyleId(id);
|
|
text.SetLocation(m_ptTurn);
|
|
text.SetHeight(this->GetTextHeight());
|
|
text.SetAlignment(XExplodeDraw::kMiddleCenter);
|
|
XPoint pt = text.GetExtents();
|
|
dLen = asPnt3d(adsPt1).distanceTo(pt);
|
|
// zxl 2013.08.27 add 标注为空时,基线长度
|
|
if (sText.IsEmpty() || (nFind == -1 && m_nDimType == TVPipeDim::eDimType5))
|
|
{
|
|
dLen = 0.0;
|
|
}
|
|
/*
|
|
TDbSymbMultiLeader ent;
|
|
ent.SetText1(sText);
|
|
ent.SetLeaderPoint(m_ptTurn);
|
|
XPointList lst;
|
|
lst.Append(new XPoint(m_ptS));
|
|
|
|
ent.SetLeaderVertexes(lst);
|
|
ent.SetSideText(FALSE);
|
|
ent.SetArrow(TDbSymbMultiLeader::kNone);
|
|
ent.SetTextLayerId(this->GetTextLayerId());
|
|
ent.SetTextStyleId(this->GetTextStyleId());
|
|
dLen = ent.GetDefaultTextBaseLen();
|
|
*/
|
|
|
|
dLen /= GetPScale();
|
|
dLen *= 1.05;
|
|
// zxl 2013.08.28 add
|
|
if (m_nDimType == TVPipeDim::eDimType5)
|
|
{
|
|
// cet 2014.6.23 del 没弄明白为啥要分开处理,统一处理结果也没问题,分开倒有问题
|
|
// AcGeVector3d vtX = AcGeVector3d::kXAxis;
|
|
// if (m_vtDir.angleTo(vtX) > PI/2)
|
|
// {
|
|
// dLen = m_dDimLen;
|
|
// }
|
|
// else
|
|
{
|
|
dLen += GetDnDistance2LabelLoc()/GetPScale();
|
|
}
|
|
|
|
}
|
|
return dLen;
|
|
}
|
|
|
|
//设置方向向量
|
|
void TDbVPipeDim::SetVtDir(const AcGeVector3d& vtDir)
|
|
{
|
|
assertWriteEnabled();
|
|
m_vtDir = vtDir;
|
|
// zxl 2013.08.29 add
|
|
m_vtDir.rotateBy(-m_nLayoutRotation, AcGeVector3d::kZAxis);
|
|
m_vtDir.normalize();
|
|
}
|
|
|
|
//设置样式3的半径
|
|
void TDbVPipeDim::SetDimRadius(double dR)
|
|
{
|
|
assertWriteEnabled();
|
|
m_dRadius = dR;
|
|
}
|
|
|
|
|
|
|
|
//得到需要标注的文字
|
|
void TDbVPipeDim::GetDimText(const AcDbObjectId &id, CString& sText) const
|
|
{
|
|
double dRadius = 0.0,dDn =0.0;
|
|
int nPipeIndex = 0;
|
|
CString csDimHead;
|
|
AcDbEntity *pEnt = NULL;
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead))
|
|
{
|
|
TDbPipe *pPipe = TDbPipe::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
//cet 2012.7.13 modify 同一个字符串变量在下面格式化时调试状态下可能出错
|
|
//csDimHead = pPipe->GetLabel();
|
|
CString csLabel = pPipe->GetLabel();
|
|
dDn = pPipe->GetDnDiameter();
|
|
//cet 2012.7.13 modify
|
|
//csDimHead.Format(_T("%s%.0f"), csDimHead, dDn);
|
|
if(TPipeSys::kVRVMedia != pPipe->GetSysType())
|
|
csDimHead.Format(_T("%s%.0f"), csLabel, dDn);
|
|
else
|
|
{
|
|
CString sTmp = _T("%%C");
|
|
CString sGasDn = _T(""),sLiqDn = _T(""),sDGasDn = _T("");
|
|
CString sSplit = _T(",");
|
|
int nStr = csLabel.Find(sSplit);
|
|
if(0 > nStr)
|
|
{
|
|
sSplit = _T("/");
|
|
nStr = csLabel.Find(sSplit);
|
|
if(0 > nStr)
|
|
{
|
|
sSplit = _T(" ");
|
|
nStr = csLabel.Find(sSplit);
|
|
}
|
|
}
|
|
int nLength = csLabel.GetLength();
|
|
if (nStr < 0)
|
|
csDimHead = csLabel;
|
|
else
|
|
{
|
|
//液管
|
|
sLiqDn = csLabel.Left(nStr);
|
|
sGasDn = csLabel.Right(nLength - nStr - 1);
|
|
nStr = sGasDn.Find(sSplit);
|
|
nLength = sGasDn.GetLength();
|
|
//气管
|
|
if (nStr < 0)
|
|
{
|
|
csDimHead.Format(_T("%s%s%s%s%s"),sTmp,sLiqDn,sSplit,sTmp,sGasDn);
|
|
}
|
|
//低压气管
|
|
else
|
|
{
|
|
CString sGasTmp = sGasDn;
|
|
sGasDn = sGasTmp.Left(nStr);
|
|
sDGasDn = sGasTmp.Right(nLength - nStr - 1);
|
|
csDimHead.Format(_T("%s%s%s%s%s%s%s%s"),sTmp,sLiqDn,sSplit, sTmp,sGasDn,sSplit,sTmp,sDGasDn);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pEnt->close();
|
|
|
|
CString sPipeIndex = GetXDataByName(id, _T("PIPE-SERIAL"));
|
|
// if (sPipeIndex.CompareNoCase(_T("0")) == 0)
|
|
// sPipeIndex = _T("");
|
|
//得到立管楼号
|
|
CString sFloorNum = GetXDataByName(id, _T("BUILDING-SERIAL"));
|
|
|
|
switch(m_nDimType)
|
|
{
|
|
case TVPipeDim::eDimType1:
|
|
{
|
|
if (!sFloorNum.IsEmpty())
|
|
{
|
|
switch(m_nFloorType)
|
|
{
|
|
case TVPipeDim::eType1:
|
|
sText.Format(_T("%s-%s-%s"),sFloorNum,m_sDimTypeText,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType2:
|
|
sText.Format(_T("%s-%s-%s"),m_sDimTypeText,sFloorNum,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType3:
|
|
sText.Format(_T("%s-%s%s"),m_sDimTypeText,sFloorNum,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType4: // cet 2010.5.21 add
|
|
{
|
|
sText.Format(_T("%s%s-%s"), sFloorNum,m_sDimTypeText,sPipeIndex);
|
|
break;
|
|
}
|
|
case TVPipeDim::eType5: // cet 2010.11.18 add
|
|
sText.Format(_T("%s%s-%s"),m_sDimTypeText,sFloorNum,sPipeIndex);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sText.Format(_T("%s-%s"),m_sDimTypeText,sPipeIndex);
|
|
}
|
|
}
|
|
break;
|
|
case TVPipeDim::eDimType2:
|
|
sText.Format(_T("%s@%s"),sPipeIndex,m_sDimTypeText);
|
|
break;
|
|
case TVPipeDim::eDimType3:
|
|
sText.Format(_T("%s%s"),m_sDimTypeText,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eDimType4:
|
|
case TVPipeDim::eDimType5:// zxl 2013.08.22 add
|
|
if (!sFloorNum.IsEmpty())
|
|
{
|
|
switch(m_nFloorType)
|
|
{
|
|
case TVPipeDim::eType1:
|
|
sText.Format(_T("%s-%s-%s@%s"),sFloorNum,m_sDimTypeText,sPipeIndex,csDimHead);
|
|
break;
|
|
case TVPipeDim::eType2:
|
|
sText.Format(_T("%s-%s-%s@%s"),m_sDimTypeText,sFloorNum,sPipeIndex,csDimHead);
|
|
break;
|
|
case TVPipeDim::eType3:
|
|
sText.Format(_T("%s-%s%s@%s"),m_sDimTypeText,sFloorNum,sPipeIndex,csDimHead);
|
|
break;
|
|
case TVPipeDim::eType4: // cet 2010.5.21 add
|
|
{
|
|
sText.Format(_T("%s%s-%s@%s"), sFloorNum, m_sDimTypeText, sPipeIndex, csDimHead);
|
|
break;
|
|
}
|
|
case TVPipeDim::eType5: // cet 2010.11.18 add
|
|
sText.Format(_T("%s%s-%s@%s"),m_sDimTypeText,sFloorNum,sPipeIndex,csDimHead);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sText.Format(_T("%s-%s@%s"),m_sDimTypeText,sPipeIndex,csDimHead);
|
|
}
|
|
break;
|
|
case TVPipeDim::eDimType6: // DN100 cet 2014.6.17 add
|
|
sText = csDimHead;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
GetSheetRowHeight(sText,VPIPE_DIM_TEXT);
|
|
}
|
|
}
|
|
|
|
//得到立管半径
|
|
double TDbVPipeDim::GetDimRadius()
|
|
{
|
|
return m_dRadius;
|
|
}
|
|
|
|
//得到立管标注类型文字
|
|
void TDbVPipeDim::GetDimTypeText(CString &sText)
|
|
{
|
|
sText = m_sDimTypeText;
|
|
}
|
|
|
|
//更新标注长度
|
|
void TDbVPipeDim::RenewDimLen()
|
|
{
|
|
assertWriteEnabled();
|
|
// zxl 2013.08.26 add
|
|
if (m_nDimType == TVPipeDim::eDimType5)
|
|
{
|
|
CString sText,sText1;
|
|
GetDimText(m_id,sText);
|
|
double dHeight = GetTextHeight();
|
|
int nFind = sText.Find(LINK_SIGN,0);
|
|
if (nFind != -1)
|
|
{
|
|
sText1 = sText.Left(nFind);
|
|
}
|
|
|
|
AcDbObjectId idStyle = this->GetTextStyleId();
|
|
CString sStyleName = GetSymbolName(idStyle).cs();
|
|
struct resbuf* pRb = acutBuildList(RTDXF0, _T("TEXT"),
|
|
1, sText,
|
|
7, sStyleName,
|
|
40, dHeight,
|
|
41, GetPScale(),
|
|
0);
|
|
|
|
ads_point adsPt1, adsPt2;
|
|
int iRet = acedTextBox(pRb, adsPt1, adsPt2);
|
|
double dLenCur = asPnt3d(adsPt1).distanceTo(asPnt3d(adsPt2)) + dHeight*DocGetPScale();
|
|
acutRelRb(pRb);
|
|
|
|
TDbText text;
|
|
text.setPropertiesFrom(this);
|
|
text.SetText((const TCHAR*)sText1);
|
|
AcDbObjectId id = this->GetTextStyleId();
|
|
text.SetStyleId(id);
|
|
text.SetLocation(m_ptTurn);
|
|
text.SetHeight(this->GetTextHeight());
|
|
text.SetAlignment(XExplodeDraw::kMiddleCenter);
|
|
XPoint pt = text.GetExtents();
|
|
dLenCur = asPnt3d(adsPt1).distanceTo(pt);
|
|
|
|
dLenCur /= GetPScale();
|
|
dLenCur += GetDnDistBetweenLabel();
|
|
// cet 2017.10.11 del 应根据实际长度调整,而不是依据是否比原长度大
|
|
// if (dLenCur - (GetDnDistance2LabelLoc()/GetPScale()) > 0.001)
|
|
{
|
|
double dDst = dLenCur * GetPScale();
|
|
CString sDst;
|
|
sDst.Format(_T("%.1f"), dDst);
|
|
dDst = _tstof(sDst);
|
|
SetDnDistance2LabelLoc(dDst);
|
|
}
|
|
}
|
|
|
|
double dLen = GetTextLen();
|
|
// cet 2017.10.10 modify 更新基线长度
|
|
// if (m_dDimLen+1e-3 < dLen || m_dDimLen > dLen*10)
|
|
// m_dDimLen = dLen;
|
|
m_dDimLen = dLen;
|
|
}
|
|
|
|
//得到标注的立管的ID
|
|
AcDbObjectId TDbVPipeDim::GetVPipeId()
|
|
{
|
|
return m_id;
|
|
}
|
|
/*
|
|
void TDbVPipeDim::SetSubText(long i, CString sText)
|
|
{
|
|
if (i > 0)
|
|
return;
|
|
|
|
CString sVPipeNum;
|
|
int nFind = 0;
|
|
switch(m_nDimType)
|
|
{
|
|
case TVPipeDim::eDimType1:
|
|
nFind = sText.Find(m_sDimTypeText,0);
|
|
if (nFind < 0)
|
|
return;
|
|
nFind += m_sDimTypeText.GetLength();
|
|
sVPipeNum = sText.Mid(nFind+1);
|
|
break;
|
|
case TVPipeDim::eDimType2:
|
|
sVPipeNum = sText;
|
|
break;
|
|
case TVPipeDim::eDimType3:
|
|
nFind = sText.Find(m_sDimTypeText,0);
|
|
if (nFind < 0)
|
|
return;
|
|
nFind += m_sDimTypeText.GetLength();
|
|
sVPipeNum = sText.Mid(nFind);
|
|
break;
|
|
case TVPipeDim::eDimType4:
|
|
nFind = sText.Find(m_sDimTypeText,0);
|
|
if (nFind < 0)
|
|
return;
|
|
nFind += m_sDimTypeText.GetLength();
|
|
sVPipeNum = sText.Mid(nFind+1);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
AcDbEntity *pEnt = NULL;
|
|
resbuf *pBuf = acutNewRb(AcDb::kDxfRegAppName);
|
|
resbuf *pTemp = pBuf;
|
|
CString sTmp = _T("PIPE-SERIAL");
|
|
CString sNum = sVPipeNum;
|
|
if (acdbOpenAcDbEntity(pEnt,m_id,AcDb::kForWrite) == Acad::eOk)
|
|
{
|
|
pBuf->resval.rstring = (TCHAR*) malloc(strlen(sTmp) + 1);
|
|
_tcscpy(pBuf->resval.rstring,sTmp);
|
|
|
|
pBuf->rbnext = acutNewRb(AcDb::kDxfXdAsciiString);
|
|
pTemp = pBuf->rbnext;
|
|
pTemp->resval.rstring = (TCHAR*) malloc(strlen(sNum) + 1);
|
|
strcpy(pTemp->resval.rstring, sNum);
|
|
|
|
pEnt->setXData(pBuf);
|
|
pEnt->close();
|
|
}
|
|
acutRelRb(pBuf);
|
|
|
|
recordGraphicsModified();
|
|
}
|
|
|
|
*/
|
|
|
|
//设置标注序号
|
|
void TDbVPipeDim::SetDimVPipeNum(LPCTSTR lpNum)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
SetDimVPipeNum(lpNum,m_id);
|
|
}
|
|
|
|
//得到标注序号
|
|
void TDbVPipeDim::GetDimVPipeNum(CString &sNum)
|
|
{
|
|
if (m_id.isValid() && !m_id.isErased())
|
|
sNum = GetXDataByName(m_id, _T("PIPE-SERIAL"));
|
|
else
|
|
GetNullIdNum(sNum);
|
|
}
|
|
|
|
//设置立管楼号
|
|
void TDbVPipeDim::SetVPipeFloorType(int nNum)
|
|
{
|
|
assertWriteEnabled();
|
|
m_nFloorType = nNum;
|
|
SaveCurText(); // cet 2010.9.2 add 通过特性表修改楼号类型时,当标注没有依附立管时无法修改
|
|
}
|
|
|
|
//得到立管楼号
|
|
int TDbVPipeDim::GetVPipeFloorType()
|
|
{
|
|
return m_nFloorType;
|
|
}
|
|
|
|
//设置立管楼号
|
|
void TDbVPipeDim::SetVPipeFloorNum(LPCTSTR lpFloor)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
SetVPipeFloorNum(lpFloor,m_id);
|
|
}
|
|
|
|
//得到立管楼号
|
|
void TDbVPipeDim::GetVPipeFloorNum(CString &sFloor)
|
|
{
|
|
if (m_id.isValid())
|
|
sFloor = GetXDataByName(m_id,_T("BUILDING-SERIAL"));
|
|
else
|
|
GetNullIdFloorNum(sFloor);
|
|
}
|
|
|
|
//得到标注文字
|
|
void TDbVPipeDim::GetDimText(CString &sText)
|
|
{
|
|
double dRadius = 0.0,dDn =0.0;
|
|
int nPipeIndex = 0;
|
|
CString csDimHead;
|
|
AcDbEntity *pEnt = NULL;
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,m_id,AcDb::kForRead))
|
|
{
|
|
TDbPipe *pPipe = TDbPipe::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
// change by hh 2012-08-29 直接使用原字符串FORMAT容易崩溃
|
|
/*csDimHead = pPipe->GetLabel();
|
|
dDn = pPipe->GetDnDiameter();
|
|
csDimHead.Format(_T("%s%.0f"), csDimHead, dDn);*/
|
|
CString sLabel = pPipe->GetLabel();
|
|
dDn = pPipe->GetDnDiameter();
|
|
if(TPipeSys::kVRVMedia != pPipe->GetSysType())
|
|
csDimHead.Format(_T("%s%.0f"), sLabel, dDn);
|
|
else
|
|
{
|
|
CString sTmp = _T("%%C");
|
|
CString sGasDn = _T(""),sLiqDn = _T(""),sDGasDn = _T("");
|
|
CString sSplit = _T(",");
|
|
int nStr = sLabel.Find(sSplit);
|
|
if(0 > nStr)
|
|
{
|
|
sSplit = _T("/");
|
|
nStr = sLabel.Find(sSplit);
|
|
if(0 > nStr)
|
|
{
|
|
sSplit = _T(" ");
|
|
nStr = sLabel.Find(sSplit);
|
|
}
|
|
}
|
|
int nLength = sLabel.GetLength();
|
|
if (nStr < 0)
|
|
csDimHead = sLabel;
|
|
else
|
|
{
|
|
//液管
|
|
sLiqDn = sLabel.Left(nStr);
|
|
sGasDn = sLabel.Right(nLength - nStr - 1);
|
|
nStr = sGasDn.Find(sSplit);
|
|
nLength = sGasDn.GetLength();
|
|
//气管
|
|
if (nStr < 0)
|
|
{
|
|
csDimHead.Format(_T("%s%s%s%s%s"),sTmp,sLiqDn,sSplit,sTmp,sGasDn);
|
|
}
|
|
//低压气管
|
|
else
|
|
{
|
|
CString sGasTmp = sGasDn;
|
|
sGasDn = sGasTmp.Left(nStr);
|
|
sDGasDn = sGasTmp.Right(nLength - nStr - 1);
|
|
csDimHead.Format(_T("%s%s%s%s%s%s%s%s"),sTmp,sLiqDn,sSplit, sTmp,sGasDn,sSplit,sTmp,sDGasDn);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pEnt->close();
|
|
|
|
CString sPipeIndex = GetXDataByName(m_id, _T("PIPE-SERIAL"));
|
|
//得到立管楼号
|
|
CString sFloorNum = GetXDataByName(m_id, _T("BUILDING-SERIAL"));;
|
|
|
|
switch(m_nDimType)
|
|
{
|
|
case TVPipeDim::eDimType1:
|
|
{
|
|
if (!sFloorNum.IsEmpty())
|
|
{
|
|
switch(m_nFloorType)
|
|
{
|
|
case TVPipeDim::eType1:
|
|
sText.Format(_T("%s-%s-%s"),sFloorNum,m_sDimTypeText,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType2:
|
|
sText.Format(_T("%s-%s-%s"),m_sDimTypeText,sFloorNum,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType3:
|
|
sText.Format(_T("%s-%s%s"),m_sDimTypeText,sFloorNum,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType4: // cet 2010.5.24 add
|
|
{
|
|
sText.Format(_T("%s%s-%s"), sFloorNum,m_sDimTypeText,sPipeIndex);
|
|
break;
|
|
}
|
|
case TVPipeDim::eType5: // cet 2010.11.18 add
|
|
sText.Format(_T("%s%s-%s"),m_sDimTypeText,sFloorNum,sPipeIndex);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sText.Format(_T("%s-%s"),m_sDimTypeText,sPipeIndex);
|
|
}
|
|
}
|
|
break;
|
|
case TVPipeDim::eDimType2:
|
|
sText.Format(_T("%s-%s"),m_sDimTypeText,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eDimType3:
|
|
sText.Format(_T("%s%s"),m_sDimTypeText,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eDimType4:
|
|
case TVPipeDim::eDimType5:// zxl 2013.08.22 add
|
|
if (!sFloorNum.IsEmpty())
|
|
{
|
|
switch(m_nFloorType)
|
|
{
|
|
case TVPipeDim::eType1:
|
|
sText.Format(_T("%s-%s-%s"),sFloorNum,m_sDimTypeText,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType2:
|
|
sText.Format(_T("%s-%s-%s"),m_sDimTypeText,sFloorNum,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType3:
|
|
sText.Format(_T("%s-%s%s"),m_sDimTypeText,sFloorNum,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType4: // cet 2010.5.24 add
|
|
{
|
|
sText.Format(_T("%s%s-%s"), sFloorNum,m_sDimTypeText,sPipeIndex);
|
|
break;
|
|
}
|
|
case TVPipeDim::eType5: // cet 2010.11.18 add
|
|
sText.Format(_T("%s%s-%s"),m_sDimTypeText,sFloorNum,sPipeIndex);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sText.Format(_T("%s-%s"),m_sDimTypeText,sPipeIndex);
|
|
}
|
|
break;
|
|
case TVPipeDim::eDimType6: // DN100 cet 2014.6.17 add
|
|
sText = csDimHead;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
GetSheetRowHeight(sText,VPIPE_DIM_TEXT);
|
|
}
|
|
|
|
}
|
|
|
|
//得到起点位置
|
|
AcGePoint3d TDbVPipeDim::GetStartPt()
|
|
{
|
|
return m_ptS;
|
|
}
|
|
|
|
//得到拐点位置
|
|
AcGePoint3d TDbVPipeDim::GetTurnPt()
|
|
{
|
|
return m_ptTurn;
|
|
}
|
|
|
|
//得到方向向量 add by zh 2013-1-6 获得方向向量
|
|
AcGeVector3d TDbVPipeDim::GetVtDir()
|
|
{
|
|
// zxl 2013.08.29 modify
|
|
return m_vtDir.rotateBy(m_nLayoutRotation, AcGeVector3d::kZAxis);
|
|
}
|
|
|
|
//得到文字距引线距离
|
|
double TDbVPipeDim::GetText2BaseRatio()
|
|
{
|
|
return m_dRadius;
|
|
}
|
|
|
|
//设置立管文字距引线距离
|
|
void TDbVPipeDim::SetText2BaseRatio(double dDis)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (m_nDimType != TVPipeDim::eDimType2)
|
|
m_dRadius = dDis;
|
|
}
|
|
|
|
void TDbVPipeDim::GetSheetRowHeight(CString &sData,LPCTSTR lpLable) const
|
|
{
|
|
ASSERT(lpLable != NULL);
|
|
const TEntityFields &fd = GetFields();
|
|
|
|
fd.GFD(lpLable, sData);
|
|
}
|
|
|
|
void TDbVPipeDim::SetSheetRowHeight(const TCHAR* szSheetRowHeight,LPCTSTR lpLable)
|
|
{
|
|
assertWriteEnabled();
|
|
ASSERT(lpLable != NULL);
|
|
|
|
TEntityFields &fd = Fields();
|
|
fd.SFD(lpLable, szSheetRowHeight);
|
|
}
|
|
|
|
//存储文字
|
|
void TDbVPipeDim::SaveCurText()
|
|
{
|
|
CString sText,sNum,sFloor;
|
|
sText.Empty();
|
|
if (m_id.isValid())
|
|
GetDimText(m_id,sText);
|
|
else
|
|
GetNullIdText(sText);
|
|
|
|
if (!sText.IsEmpty())
|
|
{
|
|
SetSheetRowHeight(sText,VPIPE_DIM_TEXT);
|
|
|
|
GetDimVPipeNum(sNum);
|
|
GetVPipeFloorNum(sFloor);
|
|
|
|
SetSheetRowHeight(sNum,VPIPE_DIM_NUM);
|
|
SetSheetRowHeight(sFloor,VPIPE_DIM_FLOOR);
|
|
}
|
|
}
|
|
|
|
//得到没有绑定ID的立管标注文字
|
|
void TDbVPipeDim::GetNullIdText(CString& sText)
|
|
{
|
|
CString sPipeIndex,sFloorNum,sTempText,csDimHead;
|
|
|
|
// if (m_sPipeIndex.IsEmpty())
|
|
// return;
|
|
|
|
GetSheetRowHeight(sPipeIndex,VPIPE_DIM_NUM);
|
|
GetSheetRowHeight(sFloorNum,VPIPE_DIM_FLOOR);
|
|
// sPipeIndex = m_sPipeIndex;
|
|
// sFloorNum = m_sFloorNum;
|
|
|
|
//得到原来的文字
|
|
GetSheetRowHeight(sTempText,VPIPE_DIM_TEXT);
|
|
//得到半径
|
|
int nFind = sTempText.Find(_T("@"));
|
|
if (nFind != -1)
|
|
{
|
|
csDimHead = sTempText.Mid(nFind+1);
|
|
}
|
|
|
|
switch(m_nDimType)
|
|
{
|
|
case TVPipeDim::eDimType1:
|
|
{
|
|
if (!sFloorNum.IsEmpty())
|
|
{
|
|
switch(m_nFloorType)
|
|
{
|
|
case TVPipeDim::eType1:
|
|
sText.Format(_T("%s-%s-%s"),sFloorNum,m_sDimTypeText,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType2:
|
|
sText.Format(_T("%s-%s-%s"),m_sDimTypeText,sFloorNum,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType3:
|
|
sText.Format(_T("%s-%s%s"),m_sDimTypeText,sFloorNum,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType4: // cet 2010.8.31 add
|
|
sText.Format(_T("%s%s-%s"),sFloorNum,m_sDimTypeText,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eType5: // cet 2010.11.18 add
|
|
sText.Format(_T("%s%s-%s"),m_sDimTypeText,sFloorNum,sPipeIndex);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sText.Format(_T("%s-%s"),m_sDimTypeText,sPipeIndex);
|
|
}
|
|
}
|
|
break;
|
|
case TVPipeDim::eDimType2:
|
|
sText.Format(_T("%s@%s"),sPipeIndex,m_sDimTypeText);
|
|
break;
|
|
case TVPipeDim::eDimType3:
|
|
sText.Format(_T("%s%s"),m_sDimTypeText,sPipeIndex);
|
|
break;
|
|
case TVPipeDim::eDimType4:
|
|
case TVPipeDim::eDimType5:// zxl 2013.08.28 add
|
|
if (!sFloorNum.IsEmpty())
|
|
{
|
|
switch(m_nFloorType)
|
|
{
|
|
case TVPipeDim::eType1:
|
|
sText.Format(_T("%s-%s-%s@%s"),sFloorNum,m_sDimTypeText,sPipeIndex,csDimHead);
|
|
break;
|
|
case TVPipeDim::eType2:
|
|
sText.Format(_T("%s-%s-%s@%s"),m_sDimTypeText,sFloorNum,sPipeIndex,csDimHead);
|
|
break;
|
|
case TVPipeDim::eType3:
|
|
sText.Format(_T("%s-%s%s@%s"),m_sDimTypeText,sFloorNum,sPipeIndex,csDimHead);
|
|
break;
|
|
case TVPipeDim::eType4: // cet 2010.8.31 add
|
|
{
|
|
sText.Format(_T("%s%s-%s@%s"), sFloorNum, m_sDimTypeText, sPipeIndex, csDimHead);
|
|
break;
|
|
}
|
|
case TVPipeDim::eType5: // cet 2010.11.18 add
|
|
sText.Format(_T("%s%s-%s@%s"),m_sDimTypeText,sFloorNum,sPipeIndex,csDimHead);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sText.Format(_T("%s-%s@%s"),m_sDimTypeText,sPipeIndex,csDimHead);
|
|
}
|
|
break;
|
|
case TVPipeDim::eDimType6: // DN100 cet 2014.6.17 add
|
|
sText = csDimHead;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
//得到没有绑定ID的立管编号
|
|
void TDbVPipeDim::GetNullIdNum(CString &sNum)
|
|
{
|
|
GetSheetRowHeight(sNum,VPIPE_DIM_NUM);
|
|
/*
|
|
CString sDimText;
|
|
GetSheetRowHeight(sDimText);
|
|
int nFind = -1;
|
|
|
|
switch(m_nDimType)
|
|
{
|
|
case TVPipeDim::eDimType1:
|
|
case TVPipeDim::eDimType4:
|
|
{
|
|
switch(m_nFloorType)
|
|
{
|
|
case TVPipeDim::eType1:
|
|
case TVPipeDim::eType2:
|
|
nFind = sDimText.ReverseFind(_T('-'));
|
|
if (nFind != -1)
|
|
{
|
|
sNum = sDimText.Mid(nFind+1);
|
|
}
|
|
break;
|
|
|
|
case TVPipeDim::eType3:
|
|
nFind = sDimText.ReverseFind(_T('-'));
|
|
if (nFind != -1)
|
|
{
|
|
sNum = sDimText.Mid(nFind+1);
|
|
CString sNumT;
|
|
while (sNum.GetLength() > 0)
|
|
{
|
|
if (sNum[sNum.GetLength()-1] >= _T('0') && sNum[sNum.GetLength()-1] <= _T('9'))
|
|
{
|
|
sNumT = sNum[sNum.GetLength()-1] + sNumT;
|
|
sNum.Delete(sNum.GetLength()-1);
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
sNum = sNumT;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
case TVPipeDim::eDimType2:
|
|
nFind = sDimText.Find(_T("@"));
|
|
if (nFind != -1)
|
|
sNum = sDimText.Left(nFind);
|
|
break;
|
|
case TVPipeDim::eDimType3:
|
|
nFind = sDimText.Find(m_sDimTypeText);
|
|
if (nFind != -1)
|
|
sNum = sDimText.Mid(nFind);
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
*/
|
|
}
|
|
|
|
//得到没有绑定ID的立管楼号
|
|
void TDbVPipeDim::GetNullIdFloorNum(CString &sFloor)
|
|
{
|
|
GetSheetRowHeight(sFloor,VPIPE_DIM_FLOOR);
|
|
/*
|
|
CString sDimText;
|
|
GetSheetRowHeight(sDimText);
|
|
int nFind1 = -1,nFind2 = -1;
|
|
|
|
switch(m_nDimType)
|
|
{
|
|
case TVPipeDim::eDimType1:
|
|
case TVPipeDim::eDimType4:
|
|
{
|
|
switch(m_nFloorType)
|
|
{
|
|
case TVPipeDim::eType1:
|
|
nFind1 = sDimText.Find(_T("-"));
|
|
nFind2 = sDimText.ReverseFind(_T('-'));
|
|
if (nFind1 != -1 && nFind2 != -1 && nFind1 != nFind2)
|
|
{
|
|
sFloor = sDimText.Left(nFind1);
|
|
}
|
|
break;
|
|
case TVPipeDim::eType2:
|
|
nFind1 = sDimText.Find(_T("-"));
|
|
nFind2 = sDimText.ReverseFind(_T('-'));
|
|
if (nFind1 != -1 && nFind2 != -1 && nFind1 != nFind2)
|
|
{
|
|
sFloor = sDimText.Mid(nFind1+1,nFind2 - nFind1 -1);
|
|
}
|
|
break;
|
|
case TVPipeDim::eType3:
|
|
nFind1 = sDimText.Find(_T("-"));
|
|
if (nFind1 != -1)
|
|
{
|
|
CString sFloorT;
|
|
sFloor = sDimText.Mid(nFind1+1);
|
|
while (sFloor.GetLength() > 0)
|
|
{
|
|
if (sFloor[sFloor.GetLength()-1] >= _T('0') && sFloor[sFloor.GetLength()-1] <= _T('9'))
|
|
sFloor.Delete(sFloor.GetLength()-1);
|
|
else
|
|
break;
|
|
}
|
|
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
*/
|
|
}
|
|
|
|
//设置标注序号
|
|
void TDbVPipeDim::SetDimVPipeNum(LPCTSTR lpNum,const AcDbObjectId &id)
|
|
{
|
|
if (lpNum == NULL)
|
|
return;
|
|
|
|
AcDbEntity *pEnt = NULL;
|
|
resbuf *pBuf = acutNewRb(AcDb::kDxfRegAppName);
|
|
resbuf *pTemp = pBuf;
|
|
CString sTmp = _T("PIPE-SERIAL");
|
|
CString sNum = lpNum;
|
|
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForWrite) == Acad::eOk)
|
|
{
|
|
// pBuf->resval.rstring = (TCHAR*) malloc(_tcslen(sTmp) + 1);
|
|
// _tcscpy(pBuf->resval.rstring,sTmp);
|
|
acutNewString(sTmp,pBuf->resval.rstring);
|
|
|
|
pBuf->rbnext = acutNewRb(AcDb::kDxfXdAsciiString);
|
|
pTemp = pBuf->rbnext;
|
|
// pTemp->resval.rstring = (TCHAR*) malloc(_tcslen(sNum) + 1);
|
|
// _tcscpy(pTemp->resval.rstring, sNum);
|
|
acutNewString(sNum,pTemp->resval.rstring);
|
|
|
|
pEnt->setXData(pBuf);
|
|
pEnt->close();
|
|
}
|
|
acutRelRb(pBuf);
|
|
|
|
// m_sPipeIndex = lpNum;
|
|
SetSheetRowHeight(lpNum,VPIPE_DIM_NUM);
|
|
SaveCurText();
|
|
}
|
|
|
|
//设置立管楼号
|
|
void TDbVPipeDim::SetVPipeFloorNum(LPCTSTR lpFloor,const AcDbObjectId &id)
|
|
{
|
|
if (lpFloor == NULL)
|
|
return;
|
|
|
|
ads_regapp(_T("BUILDING-SERIAL"));
|
|
CString sVPipeNum;
|
|
AcDbEntity *pEnt = NULL;
|
|
resbuf *pBuf = acutNewRb(AcDb::kDxfRegAppName);
|
|
resbuf *pTemp = pBuf;
|
|
CString sTmp = _T("BUILDING-SERIAL");
|
|
CString sNum = lpFloor;
|
|
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForWrite) == Acad::eOk)
|
|
{
|
|
acutNewString(sTmp,pBuf->resval.rstring);
|
|
// pBuf->resval.rstring = (TCHAR*) malloc(_tcslen(sTmp) + 1);
|
|
// _tcscpy(pBuf->resval.rstring,sTmp);
|
|
|
|
pBuf->rbnext = acutNewRb(AcDb::kDxfXdAsciiString);
|
|
pTemp = pBuf->rbnext;
|
|
acutNewString(sNum,pTemp->resval.rstring);
|
|
// pTemp->resval.rstring = (TCHAR*) malloc(_tcslen(sNum) + 1);
|
|
// _tcscpy(pTemp->resval.rstring, sNum);
|
|
|
|
pEnt->setXData(pBuf);
|
|
pEnt->close();
|
|
}
|
|
acutRelRb(pBuf);
|
|
|
|
// m_sFloorNum = lpFloor;
|
|
SetSheetRowHeight(lpFloor,VPIPE_DIM_FLOOR);
|
|
SaveCurText();
|
|
}
|
|
|
|
void TDbVPipeDim::SetShowDnForDimType4( bool bShow )
|
|
{
|
|
assertWriteEnabled();
|
|
TEntityFields &fd = Fields();
|
|
fd.SFD(_T("SHOWDNDIM"), bShow);
|
|
}
|
|
|
|
bool TDbVPipeDim::GetShowDnForDimType4() const
|
|
{
|
|
const TEntityFields &fd = GetFields();
|
|
Adesk::Boolean bShow = Adesk::kTrue;
|
|
fd.GFD(_T("SHOWDNDIM"), bShow);
|
|
return bShow ? true : false;
|
|
}
|
|
|
|
void TDbVPipeDim::SetAlignTypeForDimType4( int nType )
|
|
{
|
|
assertWriteEnabled();
|
|
TEntityFields &fd = Fields();
|
|
fd.SFD(_T("ALIGNTYPE"), nType);
|
|
}
|
|
|
|
int TDbVPipeDim::GetAlignTypeForDimType4() const
|
|
{
|
|
const TEntityFields &fd = GetFields();
|
|
int nType = 2;
|
|
fd.GFD(_T("ALIGNTYPE"), nType);
|
|
return nType;
|
|
}
|
|
|
|
extern CString ReadXdata(const AcDbEntity *pEnt, const TCHAR*szName);
|
|
TSubText* TDbVPipeDim::HitTestText(XPoint pt) const
|
|
{
|
|
TSubText *pText = TDbSymbWithText::HitTestText(pt);
|
|
if (pText != NULL)
|
|
{
|
|
CString sPipeIndex;
|
|
if (m_id.isValid())
|
|
{
|
|
sPipeIndex = GetXDataByName(m_id, _T("PIPE-SERIAL"));
|
|
}
|
|
else
|
|
{
|
|
GetSheetRowHeight(sPipeIndex,VPIPE_DIM_NUM);
|
|
}
|
|
pText->SetText(sPipeIndex);
|
|
}
|
|
return pText;
|
|
}
|
|
|
|
void TDbVPipeDim::SetSubText(long i, CString sText)
|
|
{
|
|
SetDimVPipeNum(sText);
|
|
assertWriteEnabled();
|
|
// 文字长度超出基线长度时,自动更新长度 cet 2017.11.30 add
|
|
double dTextLen = GetTextLen();
|
|
double dBaseLineLen = m_dDimLen;
|
|
if (dTextLen > dBaseLineLen + 0.001)
|
|
{
|
|
RenewDimLen();
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::subOpen(AcDb::OpenMode mode)
|
|
{
|
|
Acad::ErrorStatus st = TDbSymbWithText::subOpen(mode);
|
|
m_dCurScale = GetPScale();
|
|
return st;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbVPipeDim::subClose()
|
|
{
|
|
Acad::ErrorStatus st = TDbSymbWithText::subClose();
|
|
double dScale = GetPScale();
|
|
// 比例发生变化,修改间距
|
|
if (m_dCurScale > 0.0 && fabs(dScale - m_dCurScale) > 1e-6 && m_nDimType == TVPipeDim::eDimType5)
|
|
{
|
|
double dDist = GetDnDistance2LabelLoc() * dScale / m_dCurScale;
|
|
SetDnDistance2LabelLoc(dDist);
|
|
RenewDimLen();
|
|
}
|
|
return st;
|
|
}
|
|
|