209 lines
4.8 KiB
C++
209 lines
4.8 KiB
C++
#include "stdafx.h"
|
|||
|
|
#include "TViewPortThunders.h"
|
||
|
|
#include "ThunderXData.h"
|
||
|
|
#include "ThunderCaculate.h"
|
||
|
|
#include "LightningRodData.h"
|
||
|
|
#include "ktsetting.h"
|
||
|
|
|
||
|
|
#ifdef _DEBUG
|
||
|
|
#undef THIS_FILE
|
||
|
|
static char THIS_FILE[]=__FILE__;
|
||
|
|
#define new DEBUG_NEW
|
||
|
|
#endif
|
||
|
|
|
||
|
|
TViewPortThunders::TViewPortThunders(CDrawThunderTools* pDraw)
|
||
|
|
{
|
||
|
|
m_pDrawTool = pDraw;
|
||
|
|
if (m_pDrawTool == NULL)
|
||
|
|
return;
|
||
|
|
|
||
|
|
PickSet ssAll(SS_FREE);
|
||
|
|
RBList rbMask = ads_buildlist( -4, _T("<or"),
|
||
|
|
-4, _T("<and"), RTDXF0, _T("CIRCLE"), 8, LAY_EL_THUNDER_2D, -4, _T("and>"),
|
||
|
|
-4, _T("<and"), RTDXF0, _T("INSERT"), 8, LAY_EL_THUNDER, -4, _T("and>"),
|
||
|
|
-4, _T("<and"), RTDXF0, _T("LWPOLYLINE"), 8, LAY_EL_LIGHTNING_LINE, -4, _T("and>"),
|
||
|
|
-4, _T("or>"), NULL);
|
||
|
|
|
||
|
|
int nRet;
|
||
|
|
if ((nRet = SelectEntities(_T("\n 请选择需要查看三维显示的避雷针<全部>:"), ssAll, rbMask)) == RTCAN)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
MapThunder mapID;
|
||
|
|
MapThunderLine mapLine;
|
||
|
|
if (nRet != RTNORM)
|
||
|
|
{
|
||
|
|
AcDbObjectIdArray arID;
|
||
|
|
TContainerSingleton::LstGroupIDMap mapThun;
|
||
|
|
TContainerSingleton::LstGroupIDMap mapThunLine;
|
||
|
|
TContainerSingleton::LstGroupIDMap::iterator it;
|
||
|
|
TContainerSingleton::LstIDData::iterator itLst;
|
||
|
|
|
||
|
|
// 避雷针
|
||
|
|
ThunderContainer->GetThunderMap(mapThun);
|
||
|
|
for (it = mapThun.begin();it != mapThun.end();++it)
|
||
|
|
{
|
||
|
|
for (itLst = it->second.begin();itLst != it->second.end();++itLst)
|
||
|
|
{
|
||
|
|
arID.append(*itLst);
|
||
|
|
}
|
||
|
|
|
||
|
|
mapID.insert(std::make_pair(it->first,arID));
|
||
|
|
arID.setLogicalLength(0);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 避雷线
|
||
|
|
ThunderContainer->GetThunderLineMap(mapThunLine);
|
||
|
|
for (it = mapThunLine.begin();it != mapThunLine.end();++it)
|
||
|
|
{
|
||
|
|
for (itLst = it->second.begin();itLst != it->second.end();++itLst)
|
||
|
|
{
|
||
|
|
arID.append(*itLst);
|
||
|
|
}
|
||
|
|
|
||
|
|
mapLine.insert(std::make_pair(it->first,arID));
|
||
|
|
arID.setLogicalLength(0);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
PartitionGroup(ssAll, mapID, mapLine);
|
||
|
|
}
|
||
|
|
|
||
|
|
View3dThunders(mapID, mapLine);
|
||
|
|
}
|
||
|
|
|
||
|
|
TViewPortThunders::~TViewPortThunders()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void TViewPortThunders::View3dThunders(MapThunder& mapID, MapThunderLine& mapLine)
|
||
|
|
{
|
||
|
|
if (m_pDrawTool == NULL)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
KTSetting::InitLayer(LAY_EL_THUNDER_2D);
|
||
|
|
KTSetting::InitLayer(LAY_EL_THUNDER_3D);
|
||
|
|
KTSetting::InitLayer(LAY_EL_TEXT);
|
||
|
|
KTSetting::InitLayer(LAY_EL_THUNDER);
|
||
|
|
KTSetting::InitLayer(LAY_PREVIEW_THUNDER);
|
||
|
|
|
||
|
|
MapThunder::iterator it;
|
||
|
|
for (it = mapID.begin();it != mapID.end();++it)
|
||
|
|
{
|
||
|
|
m_pDrawTool->DrawThunder2DArea(it->first,it->second);
|
||
|
|
}
|
||
|
|
|
||
|
|
MapThunderLine::iterator itLine;
|
||
|
|
for (itLine = mapLine.begin();itLine != mapLine.end();++itLine)
|
||
|
|
{
|
||
|
|
m_pDrawTool->DrawThunderLine(itLine->first,itLine->second);
|
||
|
|
}
|
||
|
|
|
||
|
|
m_pDrawTool->ShowLayer(LAY_EL_TEXT,FALSE);
|
||
|
|
m_pDrawTool->ShowLayer(LAY_EL_THUNDER,FALSE);
|
||
|
|
m_pDrawTool->ShowLayer(LAY_EL_THUNDER_2D,FALSE);
|
||
|
|
m_pDrawTool->ShowLayer(LAY_EL_LIGHTNING_LINE,FALSE);
|
||
|
|
m_pDrawTool->ShowLayer(LAY_EL_THUNDER_3D,FALSE);
|
||
|
|
m_pDrawTool->ShowLayer(LAY_PREVIEW_THUNDER,TRUE);
|
||
|
|
|
||
|
|
SHads_command(RTSTR, _T("_view"), RTSTR, _T("_swiso"), RTNONE);
|
||
|
|
SHads_command(RTSTR, _T("_shademode"), RTSTR, _T("g"), RTNONE);
|
||
|
|
}
|
||
|
|
|
||
|
|
void TViewPortThunders::PartitionGroup(PickSet& ssEnt, MapThunder& mapID, MapThunderLine& mapLine)
|
||
|
|
{
|
||
|
|
CString sGNo;
|
||
|
|
AcDbObjectId id,idThund;
|
||
|
|
MapThunder::iterator it;
|
||
|
|
CThunderXData thunderXData;
|
||
|
|
AcDbObjectIdArray arID;
|
||
|
|
mapID.clear();
|
||
|
|
mapLine.clear();
|
||
|
|
|
||
|
|
for (long i = 0;i < ssEnt.Length();++i)
|
||
|
|
{
|
||
|
|
if (ssEnt[i].Is(_T("INSERT")))
|
||
|
|
{
|
||
|
|
Entity _ent(ssEnt[i]);
|
||
|
|
id = GetIDFromEntity(_ent);
|
||
|
|
ThunderContainer->GetThunderGroupNo(id, sGNo);
|
||
|
|
if ((it = mapID.find(sGNo)) != mapID.end())
|
||
|
|
{
|
||
|
|
it->second.append(id);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
arID.setLogicalLength(0);
|
||
|
|
arID.append(id);
|
||
|
|
mapID.insert(std::make_pair(sGNo,arID));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (ssEnt[i].Is(_T("CIRCLE")))
|
||
|
|
{
|
||
|
|
Entity _ent(ssEnt[i]);
|
||
|
|
id = GetIDFromEntity(_ent);
|
||
|
|
thunderXData.GetEntityIdFromExData(id, idThund, TEL_THUNDER_ID);
|
||
|
|
if (idThund.isValid())
|
||
|
|
{
|
||
|
|
ThunderContainer->GetThunderGroupNo(idThund, sGNo);
|
||
|
|
if ((it = mapID.find(sGNo)) != mapID.end())
|
||
|
|
{
|
||
|
|
if (!HasExist(idThund, it->second))
|
||
|
|
{
|
||
|
|
it->second.append(idThund);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
arID.setLogicalLength(0);
|
||
|
|
arID.append(idThund);
|
||
|
|
mapID.insert(std::make_pair(sGNo,arID));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (ssEnt[i].Is(_T("LWPOLYLINE"))) // 避雷线
|
||
|
|
{
|
||
|
|
Entity _ent(ssEnt[i]);
|
||
|
|
id = GetIDFromEntity(_ent);
|
||
|
|
thunderXData.GetXData(id, KEY_LINE_GROUP_NO, sGNo);
|
||
|
|
if ((it = mapLine.find(sGNo)) != mapLine.end())
|
||
|
|
{
|
||
|
|
it->second.append(id);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
arID.setLogicalLength(0);
|
||
|
|
arID.append(id);
|
||
|
|
mapLine.insert(std::make_pair(sGNo,arID));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
BOOL TViewPortThunders::HasExist(const AcDbObjectId& id, const AcDbObjectIdArray& arID)
|
||
|
|
{
|
||
|
|
int nIndex = -1;
|
||
|
|
if (arID.find(id, nIndex))
|
||
|
|
{
|
||
|
|
return TRUE;
|
||
|
|
}
|
||
|
|
return FALSE;
|
||
|
|
}
|
||
|
|
|
||
|
|
AcDbObjectId TViewPortThunders::GetIDFromEntity(Entity& ent)
|
||
|
|
{
|
||
|
|
AcDbObjectId id;
|
||
|
|
id.setNull();
|
||
|
|
|
||
|
|
if (!!ent)
|
||
|
|
{
|
||
|
|
acdbGetObjectId(id, ent);
|
||
|
|
}
|
||
|
|
|
||
|
|
return id;
|
||
|
|
}
|