136 lines
3.6 KiB
C++
136 lines
3.6 KiB
C++
#include "StdAfx.h"
|
|
#include "PipeSystemProcessor.h"
|
|
#include "DbPipe.h"
|
|
#include "DbDoubleLinePipe.h"
|
|
|
|
std::map<CString, int> PipeSystemProcessor::m_mapSysIndex;
|
|
std::map<CString, int> PipeSystemProcessor::m_mapDbSysIndex;
|
|
std::map<AcDbObjectId, int> PipeSystemProcessor::m_mapPipeSysIndex;
|
|
std::map<AcDbObjectId, int> PipeSystemProcessor::m_mapDbPipeSysIndex;
|
|
int PipeSystemProcessor::m_nSysIndex = 0;
|
|
|
|
void PipeSystemProcessor::InitSysInedex()
|
|
{
|
|
m_nSysIndex = 1000;
|
|
m_mapSysIndex.clear();
|
|
m_mapDbSysIndex.clear();
|
|
m_mapPipeSysIndex.clear();
|
|
m_mapDbPipeSysIndex.clear();
|
|
}
|
|
|
|
int PipeSystemProcessor::GetSysIndex(const CString &sSysName)
|
|
{
|
|
std::map<CString, int>::iterator itFind = m_mapSysIndex.find(sSysName);
|
|
if (itFind != m_mapSysIndex.end())
|
|
{
|
|
return itFind->second;
|
|
}
|
|
++m_nSysIndex;
|
|
m_mapSysIndex.insert(std::make_pair(sSysName, m_nSysIndex));
|
|
return m_nSysIndex;
|
|
}
|
|
|
|
int PipeSystemProcessor::GetDbSysIndex(const CString &sSysName)
|
|
{
|
|
std::map<CString, int>::iterator itFind = m_mapDbSysIndex.find(sSysName);
|
|
if (itFind != m_mapDbSysIndex.end())
|
|
{
|
|
return itFind->second;
|
|
}
|
|
++m_nSysIndex;
|
|
m_mapDbSysIndex.insert(std::make_pair(sSysName, m_nSysIndex));
|
|
return m_nSysIndex;
|
|
}
|
|
|
|
int PipeSystemProcessor::GetSysIndex(const AcDbObjectId &idPipe)
|
|
{
|
|
std::map<AcDbObjectId, int>::iterator itFind = m_mapPipeSysIndex.find(idPipe);
|
|
if (itFind != m_mapPipeSysIndex.end())
|
|
{
|
|
return itFind->second;
|
|
}
|
|
itFind = m_mapDbPipeSysIndex.find(idPipe);
|
|
if (itFind != m_mapDbPipeSysIndex.end())
|
|
{
|
|
return itFind->second;
|
|
}
|
|
// 获得管线图层
|
|
int nIndex = -1;
|
|
TDbPipe *pPipe = NULL;
|
|
acdbOpenObject(pPipe, idPipe, AcDb::kForRead);
|
|
if (pPipe != NULL)
|
|
{
|
|
nIndex = GetSysIndex(pPipe);
|
|
pPipe->close();
|
|
}
|
|
return nIndex;
|
|
}
|
|
|
|
int PipeSystemProcessor::GetSysIndex(const TDbPipePrototype *pPipe)
|
|
{
|
|
if (pPipe->isKindOf(TDbDoubleLinePipe::desc())) // 双线水管
|
|
{
|
|
AcDbObjectId idPipe = pPipe->id();
|
|
std::map<AcDbObjectId, int>::iterator itFind = m_mapDbPipeSysIndex.find(idPipe);
|
|
if (itFind != m_mapDbPipeSysIndex.end())
|
|
{
|
|
return itFind->second;
|
|
}
|
|
// cet 2018.6.7 modify 双线水管支持按系统分类
|
|
// int nIndex = -1;
|
|
// if (m_mapDbPipeSysIndex.empty())
|
|
// {
|
|
// ++m_nSysIndex;
|
|
// nIndex = m_nSysIndex;
|
|
// }
|
|
// else // 索引双线水管属于同一系统
|
|
// {
|
|
// nIndex = m_mapDbPipeSysIndex.begin()->second;
|
|
// }
|
|
// m_mapDbPipeSysIndex.insert(std::make_pair(idPipe, nIndex));
|
|
// return m_nSysIndex;
|
|
// 设置系统索引
|
|
CString sPipeSysName = pPipe->GetPipeSystemName();
|
|
int nIndex = GetDbSysIndex(sPipeSysName);
|
|
m_mapDbPipeSysIndex.insert(std::make_pair(idPipe, nIndex));
|
|
return nIndex;
|
|
}
|
|
else if (pPipe->isKindOf(TDbPipe::desc())) // 单线管
|
|
{
|
|
AcDbObjectId idPipe = pPipe->id();
|
|
std::map<AcDbObjectId, int>::iterator itFind = m_mapPipeSysIndex.find(idPipe);
|
|
if (itFind != m_mapPipeSysIndex.end())
|
|
{
|
|
return itFind->second;
|
|
}
|
|
// 设置系统索引
|
|
TDbPipe *pTempPipe = (TDbPipe*)pPipe;
|
|
TPipeSys::SysType sysType = pTempPipe->GetSysType();
|
|
CString sPipeSysName;
|
|
if (pTempPipe->HavePipeSystemName()) // 有管线系统名
|
|
{
|
|
sPipeSysName = pTempPipe->GetPipeSystemName();
|
|
}
|
|
else
|
|
{
|
|
sPipeSysName = SysTypeToSysName(sysType);
|
|
}
|
|
int nIndex = GetSysIndex(sPipeSysName);
|
|
m_mapPipeSysIndex.insert(std::make_pair(idPipe, nIndex));
|
|
return nIndex;
|
|
}
|
|
// 不应该到达这里
|
|
return -1;
|
|
}
|
|
|
|
inline CString PipeSystemProcessor::SysTypeToSysName(TPipeSys::SysType sysType)
|
|
{
|
|
// // 系统类型转换为字符串名
|
|
// int nType = sysType;
|
|
// CString sTemp;
|
|
// sTemp.Format(_T("@-@-%d"), nType);
|
|
// return sTemp;
|
|
return GetSystypeName(sysType); // 旧系统类型转换为类型名
|
|
}
|
|
|