646 lines
15 KiB
C++
646 lines
15 KiB
C++
#include "stdafx.h"
|
||||
|
|
#include "DbFireExtinguisher.h"
|
|||
|
|
//#include "TelDef.h"
|
|||
|
|
|
|||
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSFireExtinguisher, ATSEntity, AcDb::kDHL_CURRENT,
|
|||
|
|
AcDb::kMReleaseCurrent, 1, ATS_FIRE_EXTINGUISHER,
|
|||
|
|
"ATS_FIRE_EXTINGUISHER图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|||
|
|
IMPLEMENT_TENTBASE(TDbFireExtinguisher);
|
|||
|
|
|
|||
|
|
// 图块大小
|
|||
|
|
void GetBlkSize(const AcDbObjectId &idBlk, const AcGeScale3d &scale, double &dWidth, double &dHeight)
|
|||
|
|
{
|
|||
|
|
AcGePoint3d ptIns = AcGePoint3d::kOrigin;
|
|||
|
|
AcDbBlockReference blkRef(ptIns, idBlk);
|
|||
|
|
blkRef.setScaleFactors(scale);
|
|||
|
|
AcDbExtents extent;
|
|||
|
|
blkRef.getGeomExtents(extent);
|
|||
|
|
AcGePoint3d ptMin = extent.minPoint();
|
|||
|
|
AcGePoint3d ptMax = extent.maxPoint();
|
|||
|
|
dWidth = ptMax.x - ptMin.x;
|
|||
|
|
dHeight = ptMax.y - ptMin.y;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool GetBlkSize(const CString &sBlkName, const AcGeScale3d &scale, double &dWidth, double &dHeight)
|
|||
|
|
{
|
|||
|
|
AcDbObjectId idBlk = GetBlockIdFromString(sBlkName);
|
|||
|
|
if (idBlk.isNull())
|
|||
|
|
{
|
|||
|
|
// 加载灭火器图块
|
|||
|
|
CString sDwbPath = g_sDwbPath;
|
|||
|
|
CString sDwb = sDwbPath + _T("TwtSys");
|
|||
|
|
CString sBlkNum;
|
|||
|
|
int nIndex = sBlkName.ReverseFind(_T('$'));
|
|||
|
|
if (nIndex != -1)
|
|||
|
|
{
|
|||
|
|
int nSize = sBlkName.GetLength();
|
|||
|
|
sBlkNum = sBlkName.Right(nSize - nIndex - 1);
|
|||
|
|
}
|
|||
|
|
XString xsTmp;
|
|||
|
|
if(LoadDwbBlock(sDwb, sBlkNum, xsTmp) != RTNORM)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 重新获取图块id
|
|||
|
|
idBlk = GetBlockIdFromString(sBlkName);
|
|||
|
|
if (idBlk.isNull())
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
GetBlkSize(idBlk, scale, dWidth, dHeight);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TDbFireExtinguisher::TDbFireExtinguisher()
|
|||
|
|
{
|
|||
|
|
m_bUp = true;
|
|||
|
|
m_nLayType = 0;
|
|||
|
|
m_dProtectRadius = 0.0;
|
|||
|
|
m_dScale = 1;
|
|||
|
|
m_nMirror = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus TDbFireExtinguisher::DownGradeSave(int nDrawMode, AcDbVoidPtrArray &entSet, BOOL *bErase)
|
|||
|
|
{
|
|||
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|||
|
|
if (g_nSaveTArchVer < 10)
|
|||
|
|
{
|
|||
|
|
AcDbVoidPtrArray arEnts;
|
|||
|
|
this->explode(arEnts);
|
|||
|
|
for (int j = 0; j < arEnts.length(); ++j)
|
|||
|
|
{
|
|||
|
|
entSet.append(arEnts[j]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(bErase)
|
|||
|
|
*bErase=TRUE;
|
|||
|
|
}
|
|||
|
|
return es;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus
|
|||
|
|
TDbFireExtinguisher::GetGripText(int idx, CString &cs) const
|
|||
|
|
{
|
|||
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|||
|
|
switch(idx) {
|
|||
|
|
case 0: cs=_T("移动灭火器"); break;
|
|||
|
|
case 1: cs=_T("移动标注"); break;
|
|||
|
|
default: es=Acad::eInvalidInput;
|
|||
|
|
}
|
|||
|
|
return es;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus
|
|||
|
|
TDbFireExtinguisher::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
|||
|
|
AcDbIntArray& osnapModes,
|
|||
|
|
AcDbIntArray& geomIds) const
|
|||
|
|
{
|
|||
|
|
assertReadEnabled();
|
|||
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|||
|
|
gripPoints.append((AcGePoint3d)m_ptLocation);
|
|||
|
|
gripPoints.append((AcGePoint3d)m_ptLabel);
|
|||
|
|
return es;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus
|
|||
|
|
TDbFireExtinguisher::subMoveGripPointsAt(const AcDbIntArray& indices,
|
|||
|
|
const AcGeVector3d& offset)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|||
|
|
AcGeMatrix3d mat;
|
|||
|
|
mat.setToTranslation(offset);
|
|||
|
|
for(int i=0; i<indices.length();i++)
|
|||
|
|
{
|
|||
|
|
int index=indices[i];
|
|||
|
|
if(index == 0)
|
|||
|
|
{
|
|||
|
|
m_ptLocation.TransformBy(mat);
|
|||
|
|
m_ptLabel.transformBy(mat);
|
|||
|
|
}
|
|||
|
|
else if (index == 1)
|
|||
|
|
{
|
|||
|
|
m_ptLabel.transformBy(mat);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return es;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus TDbFireExtinguisher::ExplodeOrDraw2d( TGGiExplodeDrawBase &dc ) const
|
|||
|
|
{
|
|||
|
|
// cet 2016.10.17 add 图层关闭时,实体不显示,不进行绘制(打印时,也不会绘制)
|
|||
|
|
AcDbLayerTableRecordPointer player(this->layerId(), AcDb::kForRead);
|
|||
|
|
if (player.openStatus() == Acad::eOk && player->isOff())
|
|||
|
|
{
|
|||
|
|
return Acad::eOk;
|
|||
|
|
}
|
|||
|
|
Acad::ErrorStatus st = Acad::eOk;
|
|||
|
|
// 灭火器数量
|
|||
|
|
if (m_nNum <= 0)
|
|||
|
|
{
|
|||
|
|
return st;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 灭火器大小
|
|||
|
|
double dScale = m_dScale;
|
|||
|
|
if (m_nScaleType == 0)
|
|||
|
|
{
|
|||
|
|
dScale *= (GetPScale() / 100);
|
|||
|
|
}
|
|||
|
|
AcGeScale3d scale(dScale);
|
|||
|
|
double dWidth = 0.0, dHeight = 0.0;
|
|||
|
|
GetBlkSize(m_idBlock2d, scale, dWidth, dHeight);
|
|||
|
|
AcGeVector3d vtDir = AcGeVector3d::kXAxis;
|
|||
|
|
//插入点
|
|||
|
|
AcGePoint3dArray arrPts;
|
|||
|
|
if (m_nLayType == 0) // 按数量进行布置并标注规格
|
|||
|
|
{
|
|||
|
|
// 图块出入点
|
|||
|
|
int nMod = m_nNum % 2;
|
|||
|
|
if (nMod == 1) // 奇数个灭火器
|
|||
|
|
{
|
|||
|
|
arrPts.append(m_ptLocation);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int nNum = m_nNum;
|
|||
|
|
nNum /= 2;
|
|||
|
|
vtDir.rotateBy(GetAngle(), AcGeVector3d::kZAxis);
|
|||
|
|
double dDist = 0.0;
|
|||
|
|
for (int i = 0; i < nNum; ++i)
|
|||
|
|
{
|
|||
|
|
if (i == 0 && nMod == 0)
|
|||
|
|
{
|
|||
|
|
dDist += dWidth * 0.5;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
dDist += dWidth;
|
|||
|
|
}
|
|||
|
|
arrPts.append(m_ptLocation + vtDir * dDist);
|
|||
|
|
arrPts.append(m_ptLocation - vtDir * dDist);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else // 单布标注数量与规格
|
|||
|
|
{
|
|||
|
|
arrPts.append(m_ptLocation);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int nLen = arrPts.length();
|
|||
|
|
for (int j = 0; j < nLen; ++j)
|
|||
|
|
{
|
|||
|
|
TDbEquipment pEquip;
|
|||
|
|
pEquip.SetBlock2d(m_idBlock2d);
|
|||
|
|
pEquip.SetLocation(arrPts[j]);
|
|||
|
|
pEquip.SetInsert(arrPts[j]);
|
|||
|
|
pEquip.SetAngle(GetAngle());
|
|||
|
|
pEquip.SetScale(dScale);
|
|||
|
|
pEquip.setPropertiesFrom(this);
|
|||
|
|
pEquip.SetAutoScale(false);
|
|||
|
|
pEquip.MirrorByX(IsMirrorByX());
|
|||
|
|
pEquip.MirrorByY(IsMirrorByY());
|
|||
|
|
if(dc.IsFullExplode())
|
|||
|
|
pEquip.ExplodeOrDraw2d(dc);
|
|||
|
|
else
|
|||
|
|
dc.DrawEntity(pEquip);
|
|||
|
|
|
|||
|
|
double dRadius = m_dProtectRadius;
|
|||
|
|
if (!DocGetCurMeterUnitDraw())
|
|||
|
|
{
|
|||
|
|
dRadius *= 1000;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (id() == NULL)
|
|||
|
|
{
|
|||
|
|
dc << XCircle(XPoint(arrPts[j]), dRadius);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 添加文字
|
|||
|
|
if (m_bDim)
|
|||
|
|
{
|
|||
|
|
CString sText, sSpec = m_sSpec.cs();
|
|||
|
|
// 剔除规格中的注视文字
|
|||
|
|
int nDel = sSpec.Find(_T("("));
|
|||
|
|
if (nDel != -1)
|
|||
|
|
{
|
|||
|
|
sSpec = sSpec.Left(nDel);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (m_nLayType == 0) // 按数量布置
|
|||
|
|
{
|
|||
|
|
sText = sSpec;
|
|||
|
|
}
|
|||
|
|
else // 单布
|
|||
|
|
{
|
|||
|
|
// cet 2014.7.23 modify 单布时根据文字格式类型确定标注文字
|
|||
|
|
// sText.Format(_T("%d-"), m_nNum);
|
|||
|
|
// sText += sSpec;
|
|||
|
|
sText = GetDimText();
|
|||
|
|
}
|
|||
|
|
TDbText text;
|
|||
|
|
text.setPropertiesFrom(this);
|
|||
|
|
text.setLayer(m_idTextLayer);
|
|||
|
|
text.SetStyleId(m_idTextStyle);
|
|||
|
|
text.SetText((const TCHAR*)sText);
|
|||
|
|
text.SetLocation(m_ptLabel);
|
|||
|
|
text.SetPScale(GetPScale());
|
|||
|
|
text.SetHeight(m_dTextHeight);
|
|||
|
|
|
|||
|
|
text.SetRotation(m_dTextAngle);
|
|||
|
|
text.SetAlignment(m_align);
|
|||
|
|
AcDbObjectId idLayerOld=dc.GetLayerId();
|
|||
|
|
if(m_idTextLayer.isValid())
|
|||
|
|
dc.SetLayer(m_idTextLayer);
|
|||
|
|
|
|||
|
|
TPushProperty vProp(&text, dc);
|
|||
|
|
if(dc.IsFullExplode())
|
|||
|
|
{
|
|||
|
|
text.ExplodeOrDraw2d(dc);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
dc.DrawEntity(text);
|
|||
|
|
}
|
|||
|
|
dc.SetLayer(idLayerOld);
|
|||
|
|
}
|
|||
|
|
return st;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbFireExtinguisher::SetLabelLoc(AcGePoint3d pt)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_ptLabel = pt;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbFireExtinguisher::SetTextLayer(AcDbObjectId id)
|
|||
|
|
{
|
|||
|
|
m_idTextLayer = id;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbFireExtinguisher::SetDimTextPos( bool bUp /*= true*/ )
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_bUp = bUp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbFireExtinguisher::SetLayType( int nLayType )
|
|||
|
|
{
|
|||
|
|
m_nLayType = nLayType;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbFireExtinguisher::SetProtectRadius( double dRadius )
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_dProtectRadius = dRadius;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbFireExtinguisher::SetTextHeight( double dHeight )
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_dTextHeight = dHeight;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 文字样式
|
|||
|
|
void TDbFireExtinguisher::SetTextStyleId(AcDbObjectId id)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_idTextStyle = id;
|
|||
|
|
}
|
|||
|
|
// 灭火器数量
|
|||
|
|
void TDbFireExtinguisher::SetNum(int nNum)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_nNum = nNum;
|
|||
|
|
}
|
|||
|
|
void TDbFireExtinguisher::SetIsDim(bool bDim)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_bDim = bDim;
|
|||
|
|
}
|
|||
|
|
// 规格
|
|||
|
|
void TDbFireExtinguisher::SetSpec(CString sSpec)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_sSpec = sSpec;
|
|||
|
|
}
|
|||
|
|
void TDbFireExtinguisher::SetGrade(CString sGrade)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_sGrade = sGrade;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbFireExtinguisher::SetScaleType(int nType)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_nScaleType = nType;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbFireExtinguisher::SetTextRotation(double dAngle)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_dTextAngle = dAngle;
|
|||
|
|
}
|
|||
|
|
void TDbFireExtinguisher::SetTextAlignment(XExplodeDraw::TextAlignment align)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
m_align = align;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbFireExtinguisher::CopyPropertiesFrom(AcDbEntity *pSrc,unsigned gMatchFlag)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
TDbFireExtinguisher *pSect = TDbFireExtinguisher::cast(pSrc);
|
|||
|
|
if(pSect != NULL)
|
|||
|
|
{
|
|||
|
|
m_bUp = pSect->m_bUp;
|
|||
|
|
m_dTextHeight = pSect->m_dTextHeight;
|
|||
|
|
m_idTextStyle = pSect->m_idTextStyle;
|
|||
|
|
m_nLayType = pSect->m_nLayType;
|
|||
|
|
m_dProtectRadius = pSect->m_dProtectRadius;
|
|||
|
|
m_nNum = pSect->m_nNum;
|
|||
|
|
m_bDim = pSect->m_bDim;
|
|||
|
|
m_sSpec = pSect->m_sSpec;
|
|||
|
|
m_sGrade = pSect->m_sGrade;
|
|||
|
|
m_nScaleType = pSect->m_nScaleType;
|
|||
|
|
}
|
|||
|
|
TDbEntity::CopyPropertiesFrom(pSrc, gMatchFlag);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 从DWG读入数据:
|
|||
|
|
Acad::ErrorStatus TDbFireExtinguisher::dwgInFields(AcDbDwgFiler* pFiler)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
Acad::ErrorStatus es = TDbEntity::dwgInFields(pFiler);
|
|||
|
|
if(es != Acad::eOk) return es;
|
|||
|
|
ReadString(pFiler, m_sSpec);
|
|||
|
|
ReadString(pFiler, m_sGrade);
|
|||
|
|
pFiler->readItem(&m_ptLabel);
|
|||
|
|
pFiler->readItem(&m_bUp);
|
|||
|
|
pFiler->readItem(&m_dTextHeight);
|
|||
|
|
pFiler->readItem(&m_nLayType);
|
|||
|
|
pFiler->readItem(&m_dProtectRadius);
|
|||
|
|
pFiler->readItem(&m_nNum);
|
|||
|
|
pFiler->readItem(&m_bDim);
|
|||
|
|
pFiler->readItem(&m_nScaleType);
|
|||
|
|
pFiler->readItem(&m_idTextLayer);
|
|||
|
|
pFiler->readItem(&m_idTextStyle);
|
|||
|
|
pFiler->readItem(&m_dTextAngle);
|
|||
|
|
Adesk::Int16 nAlign = 0;
|
|||
|
|
pFiler->readItem(&nAlign);
|
|||
|
|
m_align = (XExplodeDraw::TextAlignment)nAlign;
|
|||
|
|
pFiler->readItem((AcGePoint3d *)&m_ptLocation);
|
|||
|
|
pFiler->readItem(&m_dScale);
|
|||
|
|
pFiler->readItem(&m_idBlock2d);
|
|||
|
|
pFiler->readItem((AcGeVector3d *)&m_vtDirection);
|
|||
|
|
pFiler->readItem(&m_nMirror);
|
|||
|
|
return pFiler->filerStatus();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus TDbFireExtinguisher::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|||
|
|
{
|
|||
|
|
assertReadEnabled();
|
|||
|
|
Acad::ErrorStatus es = TDbEntity::dwgOutFields(pFiler);
|
|||
|
|
if(es != Acad::eOk) return es;
|
|||
|
|
pFiler->writeItem((const TCHAR *)m_sSpec);
|
|||
|
|
pFiler->writeItem((const TCHAR *)m_sGrade);
|
|||
|
|
pFiler->writeItem(m_ptLabel);
|
|||
|
|
pFiler->writeItem(m_bUp);
|
|||
|
|
pFiler->writeItem(m_dTextHeight);
|
|||
|
|
pFiler->writeItem(m_nLayType);
|
|||
|
|
pFiler->writeItem(m_dProtectRadius);
|
|||
|
|
pFiler->writeItem(m_nNum);
|
|||
|
|
pFiler->writeItem(m_bDim);
|
|||
|
|
pFiler->writeItem(m_nScaleType);
|
|||
|
|
pFiler->writeItem(m_idTextLayer);
|
|||
|
|
pFiler->writeItem(m_idTextStyle);
|
|||
|
|
pFiler->writeItem(m_dTextAngle);
|
|||
|
|
Adesk::Int16 nAlign = (int)m_align;
|
|||
|
|
pFiler->writeItem(nAlign);
|
|||
|
|
pFiler->writeItem((const AcGePoint3d &)m_ptLocation);
|
|||
|
|
pFiler->writeItem(m_dScale);
|
|||
|
|
pFiler->writeItem(m_idBlock2d);
|
|||
|
|
pFiler->writeItem((const AcGeVector3d &)m_vtDirection);
|
|||
|
|
pFiler->writeItem(m_nMirror);
|
|||
|
|
return pFiler->filerStatus();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus TDbFireExtinguisher::dxfInFields(AcDbDxfFiler* pFiler)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|||
|
|
es=TDbEntity::dxfInFields(pFiler);
|
|||
|
|
if(es!=Acad::eOk) return es;
|
|||
|
|
if (!pFiler->atSubclassData(_T("TDbFireExtinguisher")))
|
|||
|
|
{
|
|||
|
|
return Acad::eBadDxfSequence;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int fieldsFlags=0;
|
|||
|
|
resbuf rb;
|
|||
|
|
XPoint pt1, pt2;
|
|||
|
|
XString sText;
|
|||
|
|
while ((es == Acad::eOk)
|
|||
|
|
&& ((es = pFiler->readResBuf(&rb)) == Acad::eOk))
|
|||
|
|
{
|
|||
|
|
switch (rb.restype) {
|
|||
|
|
case AcDb::kDxfXCoord:
|
|||
|
|
pt1=rb.resval.rpoint;
|
|||
|
|
break;
|
|||
|
|
case AcDb::kDxfXCoord+1:
|
|||
|
|
pt2=rb.resval.rpoint;
|
|||
|
|
break;
|
|||
|
|
case AcDb::kDxfText:
|
|||
|
|
sText=rb.resval.rstring;
|
|||
|
|
free(rb.resval.rstring);
|
|||
|
|
break;
|
|||
|
|
case AcDb::kDxfXReal:
|
|||
|
|
m_dScale=rb.resval.rreal;
|
|||
|
|
default:
|
|||
|
|
pFiler->pushBackItem();
|
|||
|
|
es = Acad::eEndOfFile;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (es != Acad::eEndOfFile)
|
|||
|
|
return Acad::eInvalidResBuf;
|
|||
|
|
|
|||
|
|
m_ptLocation = pt1;
|
|||
|
|
m_ptLabel = pt2;
|
|||
|
|
m_sSpec = sText;
|
|||
|
|
return es;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus TDbFireExtinguisher::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|||
|
|
{
|
|||
|
|
assertReadEnabled();
|
|||
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|||
|
|
es=TDbEntity::dxfOutFields(pFiler);
|
|||
|
|
assert(es==Acad::eOk);
|
|||
|
|
es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbFireExtinguisher"));
|
|||
|
|
assert(es == Acad::eOk);
|
|||
|
|
pFiler->writePoint3d(AcDb::kDxfXCoord,m_ptLocation);
|
|||
|
|
pFiler->writePoint3d(AcDb::kDxfXCoord,m_ptLabel);
|
|||
|
|
pFiler->writeString(AcDb::kDxfXTextString,(const TCHAR*)m_sSpec);
|
|||
|
|
pFiler->writeDouble(AcDb::kDxfXReal,m_dScale);
|
|||
|
|
return es;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Acad::ErrorStatus TDbFireExtinguisher::subTransformBy(const AcGeMatrix3d& xform)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
((AcGeVector3d &)m_vtDirection).transformBy(xform);
|
|||
|
|
m_ptLocation.TransformBy(xform);
|
|||
|
|
m_ptLabel.transformBy(xform);
|
|||
|
|
if (IsMirrorMatrix(xform))
|
|||
|
|
{
|
|||
|
|
MirrorByX(!IsMirrorByX());
|
|||
|
|
}
|
|||
|
|
double dAngle = GetAngle();
|
|||
|
|
m_dTextAngle = dAngle;
|
|||
|
|
AcGeVector3d vtDir = AcGeVector3d::kXAxis;
|
|||
|
|
vtDir.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
|||
|
|
vtDir.normalize();
|
|||
|
|
AcGeVector3d vtLab = m_ptLabel - (AcGePoint3d)m_ptLocation;
|
|||
|
|
vtLab.normalize();
|
|||
|
|
// 旋转时调整文字角度
|
|||
|
|
if (Wcs2Ucs(dAngle) > 2 * PI / 3 && Wcs2Ucs(dAngle) < 5 * PI / 3)
|
|||
|
|
{
|
|||
|
|
m_dTextAngle += PI;
|
|||
|
|
if (m_nLayType == 1)
|
|||
|
|
{
|
|||
|
|
m_align = XExplodeDraw::kTopRight;
|
|||
|
|
if (vtLab != vtDir)
|
|||
|
|
{
|
|||
|
|
m_align = XExplodeDraw::kTopLeft;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_align = XExplodeDraw::kTopCenter;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (m_nLayType == 1)
|
|||
|
|
{
|
|||
|
|
m_align = XExplodeDraw::kBottomLeft;
|
|||
|
|
if (vtLab != vtDir)
|
|||
|
|
{
|
|||
|
|
m_align = XExplodeDraw::kBottomRight;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_align = XExplodeDraw::kBottomCenter;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// 镜像时调整文字角度
|
|||
|
|
if (IsMirrorByX())
|
|||
|
|
{
|
|||
|
|
if (m_nLayType == 0)
|
|||
|
|
{
|
|||
|
|
if (Wcs2Ucs(dAngle) > 2 * PI / 3 && Wcs2Ucs(dAngle) < 5 * PI / 3)
|
|||
|
|
{
|
|||
|
|
m_align = XExplodeDraw::kBottomCenter;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_align = XExplodeDraw::kTopCenter;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (Wcs2Ucs(dAngle) > 2 * PI / 3 && Wcs2Ucs(dAngle) < 5 * PI / 3)
|
|||
|
|
{
|
|||
|
|
m_align = XExplodeDraw::kBottomRight;
|
|||
|
|
if (vtLab != vtDir)
|
|||
|
|
{
|
|||
|
|
m_align = XExplodeDraw::kBottomLeft;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_align = XExplodeDraw::kTopLeft;
|
|||
|
|
if (vtLab != vtDir)
|
|||
|
|
{
|
|||
|
|
m_align = XExplodeDraw::kTopRight;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return Acad::eOk;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int TDbFireExtinguisher::GetTextFormatType() const
|
|||
|
|
{
|
|||
|
|
assertReadEnabled();
|
|||
|
|
const TEntityFields &fd = GetFields();
|
|||
|
|
Adesk::Int8 nType = 0;
|
|||
|
|
fd.GFD(_T("TEXT_FORMAT_TYPE"), nType);
|
|||
|
|
return static_cast<int>(nType);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbFireExtinguisher::SetTextFormatType(int nType)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
TEntityFields &fd = Fields();
|
|||
|
|
fd.SFD(_T("TEXT_FORMAT_TYPE"), static_cast<Adesk::Int8>(nType));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CString TDbFireExtinguisher::GetDimText() const
|
|||
|
|
{
|
|||
|
|
CString sSpec = m_sSpec.cs();
|
|||
|
|
// 剔除规格中的注释文字
|
|||
|
|
int nDel = sSpec.Find(_T("("));
|
|||
|
|
if (nDel != -1)
|
|||
|
|
{
|
|||
|
|
sSpec = sSpec.Left(nDel);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CString sText;
|
|||
|
|
switch(GetTextFormatType())
|
|||
|
|
{
|
|||
|
|
case 0:
|
|||
|
|
{
|
|||
|
|
sText.Format(_T("%d-%s"), m_nNum, sSpec);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 1:
|
|||
|
|
{
|
|||
|
|
sText.Format(_T("%s×%d"), sSpec, m_nNum);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return sText;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbFireExtinguisher::MirrorByX(BOOL bFlag)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
if(bFlag)
|
|||
|
|
m_nMirror |= MIRROR_XAXIS;
|
|||
|
|
else
|
|||
|
|
m_nMirror &= ~MIRROR_XAXIS;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void TDbFireExtinguisher::MirrorByY(BOOL bFlag)
|
|||
|
|
{
|
|||
|
|
assertWriteEnabled();
|
|||
|
|
if(bFlag)
|
|||
|
|
m_nMirror |= MIRROR_YAXIS;
|
|||
|
|
else
|
|||
|
|
m_nMirror &= ~MIRROR_YAXIS;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void InitDbFireExtinguisher(BOOL bTrue)
|
|||
|
|
{
|
|||
|
|
if(bTrue) {
|
|||
|
|
TDbFireExtinguisher::rxInit();
|
|||
|
|
TDbFireExtinguisher::InitMatchProtocol(TRUE);
|
|||
|
|
} else {
|
|||
|
|
TDbFireExtinguisher::InitMatchProtocol(FALSE);
|
|||
|
|
deleteAcRxClass(TDbFireExtinguisher::desc());
|
|||
|
|
}
|
|||
|
|
}
|