352 lines
7.4 KiB
C++
352 lines
7.4 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TDbProtectEntity.h
|
|
// = Version : ver2.0
|
|
// = Author : xlc
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: 受保护对象类的声明
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "TDbProtectEntity.h"
|
|
//#include "TchGlobalDef.h"
|
|
#include "DbCornerWin.h"
|
|
#include "TGGiWorldViewportDraw.h"
|
|
|
|
const Adesk::UInt8 TDbProtectEntity::g_nVersion = 1;//7.0
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSProtectEntity, ATSEntity, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
1, ATS_PROTECT_ENTITY, "ATS_PROTECT_ENTITY图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
|
|
IMPLEMENT_TENTBASE(TDbProtectEntity);
|
|
|
|
TDbProtectEntity::TDbProtectEntity()
|
|
{
|
|
|
|
}
|
|
|
|
TDbProtectEntity::~TDbProtectEntity()
|
|
{
|
|
|
|
}
|
|
|
|
void TDbProtectEntity::SetName(const TCHAR* sName)
|
|
{
|
|
assertWriteEnabled();
|
|
m_sName = sName;
|
|
}
|
|
|
|
const TCHAR* TDbProtectEntity::GetName()const
|
|
{
|
|
return m_sName;
|
|
}
|
|
|
|
void TDbProtectEntity::SetCode(const TCHAR* sCode)
|
|
{
|
|
assertWriteEnabled();
|
|
m_sCode = sCode;
|
|
}
|
|
|
|
const TCHAR* TDbProtectEntity::GetCode()const
|
|
{
|
|
return m_sCode;
|
|
}
|
|
|
|
void TDbProtectEntity::SetCode1(const TCHAR* sCode)
|
|
{
|
|
assertWriteEnabled();
|
|
m_sCode1 = sCode;
|
|
}
|
|
|
|
const TCHAR* TDbProtectEntity::GetCode1()const
|
|
{
|
|
return m_sCode1;
|
|
}
|
|
|
|
bool TDbProtectEntity::IsProtectPrint()const
|
|
{
|
|
return (m_iFlag & PROTECT_PRINT) != 0;
|
|
}
|
|
|
|
int TDbProtectEntity::GetFirstVersion()const
|
|
{
|
|
return 7;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbProtectEntity::subDeepClone(AcDbObject* pOwner,
|
|
AcDbObject*& pClonedObject,
|
|
AcDbIdMapping& idMap,
|
|
Adesk::Boolean isPrimary) const
|
|
{
|
|
pClonedObject = NULL;
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbProtectEntity::subWblockClone(AcRxObject* pOwner,
|
|
AcDbObject*& pClonedObject,
|
|
AcDbIdMapping& idMap,
|
|
Adesk::Boolean isPrimary) const
|
|
{
|
|
pClonedObject = NULL;
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbProtectEntity::dwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbEntity::dwgInFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
|
|
Adesk::UInt8 nVer;
|
|
pFiler->readItem(&nVer);
|
|
if (nVer > g_nVersion)//版本太新
|
|
{
|
|
return Acad::eMakeMeProxy;
|
|
}
|
|
|
|
ReadString(pFiler,m_sName);
|
|
ReadString(pFiler, m_sCode);
|
|
|
|
if (nVer > 0)
|
|
{
|
|
pFiler->readInt32(&m_iFlag);
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbProtectEntity::dwgOutFields (AcDbDwgFiler* pFiler)const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbEntity::dwgOutFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
|
|
pFiler->writeItem(g_nVersion);
|
|
pFiler->writeString(m_sName);
|
|
pFiler->writeString(m_sCode);
|
|
pFiler->writeInt32(m_iFlag);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbProtectEntity::dxfInFields (AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbEntity::dxfInFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
|
|
if (!pFiler->atSubclassData(_T("TDbProtectEntity")))
|
|
{
|
|
return Acad::eBadDxfSequence;
|
|
}
|
|
|
|
Adesk::UInt32 fieldsFlags = 0;
|
|
resbuf rb;
|
|
while ((es == Acad::eOk)
|
|
&& ((es = pFiler->readResBuf(&rb)) == Acad::eOk))
|
|
{
|
|
switch (rb.restype)
|
|
{
|
|
case AcDb::kDxfText:
|
|
m_sName = rb.resval.rstring;
|
|
fieldsFlags |= 0x01;
|
|
free(rb.resval.rstring);
|
|
break;
|
|
default:
|
|
pFiler->pushBackItem();
|
|
es = Acad::eEndOfFile;
|
|
break;
|
|
}
|
|
}
|
|
if (es != Acad::eEndOfFile)
|
|
{
|
|
return Acad::eInvalidResBuf;
|
|
}
|
|
|
|
if (!(fieldsFlags & 0x01))
|
|
{
|
|
return Acad::eMissingDxfField;
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbProtectEntity::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbEntity::dxfOutFields(pFiler);
|
|
assert(es == Acad::eOk);
|
|
|
|
es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbProtectEntity"));
|
|
pFiler->writeString(AcDb::kDxfText, (const TCHAR *)m_sName);
|
|
return es;
|
|
}
|
|
|
|
AcDbObjectId TDbProtectEntity::GetBlockRecordId()const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbObjectId id = extensionDictionary();
|
|
AcDbDictionary *pDict = NULL;
|
|
acdbOpenObject(pDict,id,AcDb::kForRead);
|
|
|
|
if (pDict == NULL)
|
|
{
|
|
return AcDbObjectId::kNull;
|
|
}
|
|
|
|
Acad::ErrorStatus es;
|
|
AcDbObject *pObj = NULL;
|
|
AcDbObjectId idRecord = AcDbObjectId::kNull;
|
|
es = pDict->getAt(DICT_ENTRY_NAME,idRecord);
|
|
pDict->close();
|
|
|
|
return idRecord;
|
|
}
|
|
|
|
bool TDbProtectEntity::CanExplode()const
|
|
{
|
|
return m_sCode == _T("") || m_sCode == m_sCode1;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbProtectEntity::subExplode(AcDbVoidPtrArray&ent)const
|
|
{
|
|
if (CanExplode())
|
|
{
|
|
AcDbObjectId idRecord = GetBlockRecordId();
|
|
|
|
if (!idRecord.isNull() && idRecord.isValid())
|
|
{
|
|
AcDbBlockReference block(AcGePoint3d(),idRecord);
|
|
block.setPropertiesFrom(this);
|
|
|
|
Acad::ErrorStatus es = block.explode(ent);
|
|
|
|
//add by w on 060216
|
|
if (es == Acad::eOk)
|
|
{
|
|
for(long i = 0;i < ent.length(); i++)
|
|
{
|
|
AcDbEntity *pEnt = (AcDbEntity*)ent[i];
|
|
|
|
TDbWall* pWall = TDbWall::cast(pEnt);
|
|
if (pWall != NULL)
|
|
{
|
|
pWall->ResetOpeningId();
|
|
|
|
//排在最前,使反应器正常工作
|
|
ent.removeAt(i);
|
|
ent.insertAt(0,pEnt);
|
|
}
|
|
else
|
|
{
|
|
TDbOpening* pOpening = TDbOpening::cast(pEnt);
|
|
if (pOpening != NULL)
|
|
{
|
|
pOpening->SetWallId(AcDbObjectId::kNull);
|
|
}
|
|
else
|
|
{
|
|
TDbCornerWin *pWin = TDbCornerWin::cast(pEnt);
|
|
if (pWin != NULL)
|
|
{
|
|
for (long i = 0; i < pWin->GetWallNum(); i++)
|
|
{
|
|
pWin->SetWallId(i,AcDbObjectId::kNull);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return es;
|
|
}
|
|
}
|
|
return Acad::eCannotExplodeEntity;
|
|
}
|
|
|
|
Adesk::Boolean TDbProtectEntity::subWorldDraw(AcGiWorldDraw*pWd)
|
|
{
|
|
AcGiRegenType nRegenType = pWd->regenType();
|
|
if (nRegenType == kAcGiSaveWorldDrawForProxy) //不保存代理
|
|
{
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
void TDbProtectEntity::subViewportDraw(AcGiViewportDraw*pVd)
|
|
{
|
|
if (IsProtectPrint())
|
|
{
|
|
AcGiContext *pContext = pVd->context();
|
|
if (pContext != NULL && pContext->isPlotGeneration())
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
AcDbObjectId idRecord = GetBlockRecordId();
|
|
|
|
AcDbBlockTableRecord* pRecord = NULL;
|
|
acdbOpenObject(pRecord,idRecord,AcDb::kForRead);
|
|
if (pRecord != NULL)
|
|
{
|
|
TGGiWorldViewportDraw dc(NULL,pVd);
|
|
if (OnExplodeOrDraw(dc))
|
|
{
|
|
// // sg add 120507,解决关闭图层后的打印问题,打印时对象不能显示出来
|
|
// BOOL bMakeBlock = g_bMakeBlock;
|
|
// if (_tcsicmp(dc.Desc(), XAcGiViewDraw::Descriptor()) == 0)
|
|
// {
|
|
// if (dc.IsPlotGeneration()) // 强制打印时,不使用新方法
|
|
// bMakeBlock = FALSE;
|
|
// else
|
|
// bMakeBlock=(g_nAcadVer>15.0001);
|
|
// }
|
|
|
|
//wlw mod 121009将sg 120507改的注释掉,因为影响了打印时标注显示问题
|
|
dc.SetColorLayer(colorIndex(),layerId());
|
|
dc.DrawBlock(*pRecord,TADSGePoint3d(),AcGeScale3d(1,1,1),0,TRUE);
|
|
// sg add 120507,解决关闭图层后的打印问题,打印时对象不能显示出来
|
|
//dc.DrawBlock(*pRecord,TADSGePoint3d(),AcGeScale3d(1,1,1),0,bMakeBlock);
|
|
pRecord->close();
|
|
}
|
|
}
|
|
}
|
|
|
|
void TDbProtectEntity::GetTips(TDPtrList<TObjInfoUnit> &lstInfo) const
|
|
{
|
|
lstInfo.Append(new TObjInfoUnit(_T("类型"),_T("只读")));
|
|
lstInfo.Append(new TObjInfoUnit(_T("名称"),m_sName));
|
|
}
|
|
|
|
void TDbProtectEntity::SetProtectPrint(bool bFix)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (bFix)
|
|
{
|
|
m_iFlag |= PROTECT_PRINT;
|
|
}
|
|
else
|
|
{
|
|
m_iFlag &= ~PROTECT_PRINT;
|
|
}
|
|
} |