237 lines
5.7 KiB
C++
237 lines
5.7 KiB
C++
#include "StdAfx.h"
|
|
#include "StdArx.h"
|
|
#include "dbproxy.h"
|
|
#include "geassign.h"
|
|
#include "acgi.h"
|
|
#include "TDbEFitting.h"
|
|
|
|
#define VERSION_TDBEFITTING 1
|
|
|
|
//{{AFX_ARX_MACRO
|
|
ACRX_DXF_DEFINE_MEMBERS( TDbEFitting, TDbFittingBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kAllAllowedBits,
|
|
ATS_EFITTING, "图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
//}}AFX_ARX_MACRO
|
|
IMPLEMENT_TENTBASE(TDbEFitting);
|
|
|
|
TDbEFitting::TDbEFitting()
|
|
{
|
|
//{{AFX_ARX_DATA_INIT(TDbEFitting)
|
|
//}}AFX_ARX_DATA_INIT
|
|
}
|
|
|
|
TDbEFitting::~TDbEFitting()
|
|
{
|
|
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEFitting::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es;
|
|
|
|
if ((es = TDbFittingBase::dxfOutFields(pFiler)) != Acad::eOk)
|
|
return es;
|
|
|
|
// Write subclass marker.
|
|
pFiler->writeItem(AcDb::kDxfSubclass, _T("TDbEFitting"));
|
|
|
|
// Write version number.
|
|
pFiler->writeItem(AcDb::kDxfInt16, (Adesk::UInt16) VERSION_TDBEFITTING);
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEFitting::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
struct resbuf rb;
|
|
|
|
if ((TDbFittingBase::dxfInFields(pFiler) != Acad::eOk) ||
|
|
!pFiler->atSubclassData(_T("TDbEFitting")))
|
|
return pFiler->filerStatus();
|
|
|
|
// Read version number.
|
|
pFiler->readItem(&rb);
|
|
if (rb.restype != AcDb::kDxfInt16)
|
|
{
|
|
pFiler->pushBackItem();
|
|
pFiler->setError(Acad::eInvalidDxfCode,
|
|
_T("Error: expected object version group code %d"),
|
|
AcDb::kDxfInt16);
|
|
return pFiler->filerStatus();
|
|
}
|
|
else
|
|
{
|
|
Adesk::UInt16 version = rb.resval.rint;
|
|
if (version > VERSION_TDBEFITTING)
|
|
return Acad::eMakeMeProxy;
|
|
}
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEFitting::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es;
|
|
|
|
// Call dwgOutFields from TDbInterfacesObj
|
|
if ((es = TDbFittingBase::dwgOutFields(pFiler)) != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
|
|
// Write version number.
|
|
pFiler->writeItem((Adesk::UInt16) VERSION_TDBEFITTING);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEFitting::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es;
|
|
|
|
// Call dwgInFields from TDbInterfacesObj
|
|
if ((es = TDbFittingBase::dwgInFields(pFiler)) != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
|
|
// Read version number.
|
|
Adesk::UInt16 version;
|
|
pFiler->readItem(&version);
|
|
if (version > VERSION_TDBEFITTING)
|
|
return Acad::eMakeMeProxy;
|
|
|
|
switch (version)
|
|
{
|
|
case (1):
|
|
{
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEFitting::subGetTransformedCopy( const AcGeMatrix3d& xform,AcDbEntity*& pEnt) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
pEnt = new TDbEFitting;
|
|
(TDbEFitting*)pEnt->copyFrom(this);
|
|
pEnt->transformBy(xform);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
BOOL TDbEFitting::SetLatestVersion()
|
|
{
|
|
TDbEFittingVersion ver(GetSpecialtyData());
|
|
int nLatestVer(0);
|
|
if (ver.GetLatestVersion(nLatestVer))
|
|
return SetVersion(nLatestVer);
|
|
return FALSE;
|
|
}
|
|
BOOL TDbEFitting::GetVersion(int& nVer)
|
|
{
|
|
TDbEFittingVersion ver(GetSpecialtyData());
|
|
return ver.GetVersion(nVer);
|
|
}
|
|
BOOL TDbEFitting::GetLatestVersion(const TDb::ObjectKind& kind,int& nVer)
|
|
{
|
|
return TDbEFittingVersion::GetLatestVersion(kind,nVer);
|
|
}
|
|
|
|
BOOL TDbEFitting::SetVersion(const int& nVer)
|
|
{
|
|
TDbEFittingVersion ver(GetSpecialtyData());
|
|
return ver.SetVersion(nVer);
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//170626:三通升级到版本1
|
|
/*升级修正了
|
|
1、水平三通KEY_L2长的计算方式
|
|
2、水平斜向异径三通(三个宽度都不同时)的KEY_DB3可正常显示
|
|
3、水平三通若颠倒KEY_DB3和KEY_MAJBR_B,三通应该对称
|
|
*/
|
|
#define KEY_EFittingVer _T("EFittingVer")
|
|
std::map<TDb::ObjectKind,int> TDbEFittingVersion::m_kVer;
|
|
TDbEFittingVersion::TDbEFittingVersion(TDbXDataMap* pXDataMap)
|
|
{
|
|
m_pXDataMap = pXDataMap;
|
|
if (m_kVer.size() <= 0)
|
|
{
|
|
//m_kVer的first类型应该与TDbEImpFittingCreatorService::CreateSpecialFitting()中相同,second为版本号,初始为0
|
|
m_kVer.insert(std::make_pair(TDb::eElbow,0));
|
|
m_kVer.insert(std::make_pair(TDb::eTee,1));//三通的最新版本是1
|
|
m_kVer.insert(std::make_pair(TDb::eCross,0));
|
|
m_kVer.insert(std::make_pair(TDb::eReduce,0));
|
|
m_kVer.insert(std::make_pair(TDb::eOffset,0));
|
|
m_kVer.insert(std::make_pair(TDb::eEnclosure,0));
|
|
//升级版本后需在TDbEFitting::SetLatestVersion()中做相应处理
|
|
}
|
|
}
|
|
BOOL TDbEFittingVersion::GetKind(TDb::ObjectKind& kind)
|
|
{
|
|
if (!m_pXDataMap)
|
|
return FALSE;
|
|
int nRunTime(-1);
|
|
m_pXDataMap->GetAt(KEY_RUNTIME,nRunTime);
|
|
kind = (TDb::ObjectKind)nRunTime;
|
|
return TRUE;
|
|
}
|
|
BOOL TDbEFittingVersion::GetVersion(int& nVer)
|
|
{
|
|
TDb::ObjectKind kind = (TDb::ObjectKind)-1;
|
|
if(GetKind(kind))
|
|
{
|
|
std::map<TDb::ObjectKind,int>::iterator it = m_kVer.find(kind);
|
|
if(it != m_kVer.end())
|
|
{
|
|
return m_pXDataMap->GetAt(KEY_EFittingVer,nVer);
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TDbEFittingVersion::SetVersion(const int& nVer)
|
|
{
|
|
TDb::ObjectKind kind = (TDb::ObjectKind)-1;
|
|
if(GetKind(kind))
|
|
{
|
|
std::map<TDb::ObjectKind,int>::iterator it = m_kVer.find(kind);
|
|
if(it != m_kVer.end())
|
|
{
|
|
return m_pXDataMap->SetAt(KEY_EFittingVer,nVer);
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
BOOL TDbEFittingVersion::GetLatestVersion(int& nVer)
|
|
{
|
|
TDb::ObjectKind kind = (TDb::ObjectKind)-1;
|
|
if(GetKind(kind) && GetLatestVersion(kind,nVer))
|
|
return TRUE;
|
|
return FALSE;
|
|
}
|
|
BOOL TDbEFittingVersion::SetLatestVersion()
|
|
{
|
|
int nLatestVersion(0);
|
|
if (GetLatestVersion(nLatestVersion))
|
|
return m_pXDataMap->SetAt(KEY_EFittingVer,nLatestVersion);
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TDbEFittingVersion::GetLatestVersion(const TDb::ObjectKind& kind,int& nVer)
|
|
{
|
|
std::map<TDb::ObjectKind,int>::iterator it = m_kVer.find(kind);
|
|
if(it != m_kVer.end())
|
|
{
|
|
nVer = it->second;
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
} |