Files
envi-code/SourceCode/Code2026/EarthWormCmd/HZGLDlg.cpp
T
2026-09-28 15:28:50 +08:00

3228 lines
75 KiB
C++

#include "stdafx.h"
#include "HZGLDlg.h"
#include "AecDbEarthWorm.h"
#include "AecDbEarthWormFitting.h"
#include "UITools.h"
#include "GLTKDlg.h"
#include "GLBJDlg.h"
#include "AecDbX3dGroup.h"
#include "TJBZJCDlg.h"
#include "TJZJDlg.h"
#include "FZGWDlg.h"
#include "TJDJDlg.h"
#include "TJDHDlg.h"
#include "TJDUDlg.h"
#include "MHQDlg.h"
#include "JPSGDLG.h"
#include "FMHDlg.h"
#include "JKSBDlg.h"
#include "SDFJDlg.h"
#include "WSJCDlg.h"
#include "CSFCDlg.h"
#include "YWBJDlg.h"
#include "WDBJDlg.h"
#include "YYHTDlg.h"
#include "YQTCDlg.h"
#include "HZGL_SCFJDlg.h"
#include "BimInfoDlg.h"
#include "CGLFJDlg.h"
#include "PipeCableData.h"
#include "coreTools.h"
extern Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEnt,AcDbObjectId& id,AcDbDatabase* pDb,bool bClose);
extern void SplitStrintToArray(LPCTSTR pszDescr,CStringArray& arInfo,TCHAR tcSpace);
bool analySlabScript(LPCTSTR script
, int &idxRoom // 舱室
, int &type // 类型(横/竖)
, double &dist // 距舱室 底部/左侧 距离
, double &width // 板宽/板高
, double &x // ptOff-x
, double &y // ptOff-y
)
{
if (!script) return false;
CString str(script);
int idx = str.Find(_T(":"));
if (idx == -1) return false;
str = str.Left(str.GetLength() - 1);
str = str.Right(str.GetLength() - idx - 1);
std::vector<CString> vec(0);
idx = CoreTools::SplitString(str, _T("|"), vec);
if (idx != 8) return false;
idxRoom = _ttoi(vec[0]);
type = _ttoi(vec[1]);
dist= _ttof(vec[2]);
width = _ttof(vec[3]);
x = _ttof(vec[5]);
y = _ttof(vec[6]);
return true;
}
bool getSubRoomInfo(LPCTSTR key, int &idxRoom, double &x, double &y)
{
if (!key) return false;
std::vector<CString> vec(0);
if (!CoreTools::SplitString(key, _T("|"), vec)) return false;
if (vec.size() != 4) return false;
idxRoom = _ttoi(vec[0]);
// 缩小100
x = _ttof(vec[1]) * .01;
y = _ttof(vec[2]) * .01;
return true;
}
bool findKeysBySlab(CMapStringToString &mfcMap, ERoom &room, LPCTSTR slabScript, CString &key1, CString &key2)
{
if (mfcMap.IsEmpty() || !slabScript) return false;
AcGePoint2d ptOff(AcGePoint2d::kOrigin);
int idxRoom(0), type(0);
double dist(.0), width(.0);
if (!analySlabScript(slabScript, idxRoom, type, dist, width, ptOff.x, ptOff.y))return false;
// 根据room还原分舱中心点和板的位置
double condition(.0);
if (type == 0)
{
// 判断条件,水平分舱时,为x偏移量加上板长一半
condition = ptOff.x + room.ptGe[0].x + width * .5;
// 处理一下dist,得到真实位置
dist += room.ptGe[0].y;
}
else
{
// 判断条件,垂直分舱时,为y偏移量加上板高一半
condition = ptOff.y + room.ptGe[0].y + width * .5;
// 处理一下dist,得到真实位置
dist += room.ptGe[0].x;
}
// 遍历mfcMap,得到所有舱室索引为idxRoom,类型为ROOMNAME的key
std::map<double, CString> ss;
int idxSub(0);
double x(.0), y(.0);
CString sVal(_T("")), sKey(_T(""));
POSITION pos(mfcMap.GetStartPosition());
while (pos)
{
mfcMap.GetNextAssoc(pos, sKey, sVal);
if (sKey.Find(_T("ROOMNAME")) == -1) continue;
if (!getSubRoomInfo(sKey, idxSub, x, y)) continue;
if (idxSub != idxRoom) continue;
// 水平分舱以x来与condition判断
if (!EQUAL(condition, type == 0 ? x : y)) continue;
// 水平分舱 以 y 来排序
// 判断完 condition 之后,理论上不应该有与 y 相同的值出现
// 如果有,弹出一条报告
if (!ss.insert(std::make_pair(type == 0 ? y : x, sKey)).second)
acutPrintf(_T("\n%s-%s"), sKey, sVal);
}
std::pair<std::map<double, CString>::iterator, bool> pr(ss.insert(std::make_pair(dist, _T(""))));
// 理论上,dist不应该在 ss 内.
if (!pr.second) return false;
if (ss.size() < 2) return false;
if (ss.size() == 2) // pr.first旁边就是要得的key
{
if (pr.first == ss.begin())
key1 = (++pr.first)->second;
else
key1 = (--pr.first)->second;
key2 = _T("");
return true;
}
else // pr.first的左右两个位置就是要得到的key
{
// 如果pr.first是第一个或最后一个,逻辑不对
if (pr.first == ss.begin() || *pr.first == *ss.rbegin()) return false;
key1 = (--pr.first)->second;
++pr.first;
key2 = (++pr.first)->second;
return true;
}
return false;
}
// 很多截面的附件通过索引号进行删除
// ,但是m_mapAddtion中的key还包含了其它内容
// ,所以需要解析出key中的索引才可以进行添加和删除
// 注意,下面三个函数,只处理索引在附件类型前面的情况(例:x-x-x-idx-type)
bool hasAddin(const int &idx, LPCTSTR addinType, const CMapStringToString &mapAddtion)
{
CString sK(_T("")), sV(_T("")), sTrait(_T(""));
sTrait.Format(_T("%d-%s"), idx, addinType);
int nRes(-1);
POSITION pos = mapAddtion.GetStartPosition();
while (pos)
{
mapAddtion.GetNextAssoc(pos, sK, sV);
// 分析sK,看是否存在 索引-类型 的情况
nRes = sK.Find(sTrait);
if (nRes != -1)
return true;
}
return false;
}
void removeAddin(const int &idx, LPCTSTR addinType, CMapStringToString &mapAddtion)
{
std::vector<CString> delKeys(0);
CString sK(_T("")), sV(_T("")), sTrait(_T(""));
sTrait.Format(_T("%d-%s"), idx, addinType);
int nRes(-1);
POSITION pos = mapAddtion.GetStartPosition();
while (pos)
{
mapAddtion.GetNextAssoc(pos, sK, sV);
// 分析sK,看是否存在 索引-类型 的情况
nRes = sK.Find(sTrait);
if (nRes != -1)
delKeys.push_back(sK);
}
for (size_t i = 0; i < delKeys.size(); ++i)
mapAddtion.RemoveKey(delKeys[i]);
}
IMPLEMENT_DYNAMIC(CHZGLDlg, CBaseDialog)
CHZGLDlg::CHZGLDlg(bool bInsertLibrary, CWnd* pParent)
: CBaseDialog(CHZGLDlg::IDD, _T("HZGL"), IDC_STATIC_FRM, pParent)
, m_bIsInsertLibrary(bInsertLibrary)
, m_dInterH(3600)
, m_dOutT(400)
, m_dIntT(300)
, m_dRoomWAdd(3900)
, m_sCity(_T(""))
, m_sRoad(_T(""))
, m_dYXLen(80.0f)
, m_sRoomName(_T("电力舱"))
, m_dG(0.0)
, m_dt4(400)
, m_dt5(450)
, m_bTopNoCharm(FALSE)
, m_bBomNoCharm(FALSE)
, m_dh0(0)
, m_dh1(0)
, m_bIsLSGL(false)
, m_bIsYXGLJD(false)
, m_bHasGrade(false)
, m_pGroupBJ(NULL)
, m_pGroupRB(NULL)
, m_pGLBJXDataMap(NULL)
, m_pGLBZJCDataMap(NULL)
, m_nAlign(3)
, m_dLRAddThick(0)
, m_nLRAddThick(0)
{
m_sCrossSectionScr.Empty();
m_dChamferInter = 150.0f;
UIDataCache::Read(_T("%s"), m_sTag, &m_sCrossSectionScr);
if (m_sCrossSectionScr.IsEmpty())
SetCrossSectionScr(_T("RECT:2.6x3.0|4.2x3.0|2.4x3.0|0.4x0.3"));
return;
}
CHZGLDlg::~CHZGLDlg()
{
}
void CHZGLDlg::DoDataExchange(CDataExchange* pDX)
{
CBaseDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDITCHARM, m_dChamferInter);
DDX_Text(pDX, IDC_EDITH, m_dInterH);
DDX_Text(pDX, IDC_EDITT1, m_dOutT);
DDX_Text(pDX, IDC_EDITT2, m_dIntT);
DDX_Text(pDX, IDC_EDITROOMW, m_dRoomWAdd);
DDX_CBString(pDX, IDC_COMBO1, m_sCity);
DDX_CBString(pDX, IDC_COMBO2, m_sRoad);
DDX_Text(pDX, IDC_EDITYX, m_dYXLen);
DDX_Text(pDX, IDC_EDIT21, m_dG);
DDX_Control(pDX, IDC_STATICG, m_wndStaticG);
DDX_Control(pDX, IDC_EDIT21, m_wndEditG);
DDX_Control(pDX, IDC_STATICP, m_wndStaticP);
DDX_Control(pDX, IDC_BUTTON1, m_wndRoomReducerBt);
DDX_Control(pDX, IDC_BUTTON4, m_wndBTRainbow);
DDX_Control(pDX, IDC_COMBO4, m_wndCombo4);
DDX_Text(pDX, IDC_EDIT24, m_sRoomName);
DDX_Text(pDX, IDC_EDITT3, m_dt4);
DDX_Text(pDX, IDC_EDITT4, m_dt5);
DDX_Control(pDX, IDC_BTADDROOM2, m_wndButton2);
DDX_Control(pDX, IDC_BTADDROOM4, m_wndButton4);
DDX_Control(pDX, IDC_BTADDROOM3, m_wndButton3);
DDX_Control(pDX, IDC_BTADDROOM5, m_wndButton5);
DDX_Control(pDX, IDC_BTADDROOM6, m_wndButton6);
DDX_Control(pDX, IDC_BTADDROOM9, m_wndButton9);
DDX_Control(pDX, IDC_BTADDROOM8, m_wndButton8);
DDX_Control(pDX, IDC_BTADDROOM10, m_wndButton10);
DDX_Control(pDX, IDC_BTADDROOM7, m_wndButton7);
DDX_Control(pDX, IDC_BTADDROOM11, m_wndButton11);
DDX_Control(pDX, IDC_BUTTON6, m_wndButton12);
DDX_Control(pDX, IDC_BUTTON5, m_wndButton13);
DDX_Control(pDX, IDC_BUTTON3, m_wndButton14);
DDX_Control(pDX, IDC_BUTTON17, m_wndButton17);
DDX_Control(pDX, IDC_BUTTON56, m_wndButton56);
DDX_Control(pDX, IDC_BUTTON11, m_wndButtonCo11);
DDX_Control(pDX, IDC_BUTTON19, m_wndButtonO19);
DDX_Check(pDX, IDC_CHECK1, m_bTopNoCharm);
DDX_Check(pDX, IDC_CHECK3, m_bBomNoCharm);
DDX_Text(pDX, IDC_EDITH12, m_dh0);
DDX_Text(pDX, IDC_EDITH13, m_dh1);
DDX_Radio(pDX, IDC_RADIO1, m_nAlign);
DDX_Text(pDX, IDC_EDIT1, m_dLRAddThick);
DDX_Radio(pDX, IDC_RADIO5, m_nLRAddThick);
}
BEGIN_MESSAGE_MAP(CHZGLDlg, CBaseDialog)
ON_BN_CLICKED(IDOK, &CHZGLDlg::OnBnClickedOk)
ON_BN_CLICKED(IDC_BTADDROOM, &CHZGLDlg::OnBnClickedBtaddroom)
ON_BN_CLICKED(IDC_BTADDTODB, &CHZGLDlg::OnBnClickedBtaddtodb)
ON_BN_CLICKED(IDC_BTSELFROMDB, &CHZGLDlg::OnBnClickedBtselfromdb)
ON_BN_CLICKED(IDC_BTMODIROOM2, &CHZGLDlg::OnBnClickedBtmodiroom2)
ON_EN_KILLFOCUS(IDC_EDITH, &CHZGLDlg::OnEnChangeEdith)
ON_EN_KILLFOCUS(IDC_EDITT1, &CHZGLDlg::OnEnChangeEditt1)
ON_EN_KILLFOCUS(IDC_EDITT2, &CHZGLDlg::OnEnChangeEditt2)
ON_EN_KILLFOCUS(IDC_EDIT1, &CHZGLDlg::OnEnChangeEditt1)
ON_EN_KILLFOCUS(IDC_EDITCHARM, &CHZGLDlg::OnEnChangeEditcharm)
ON_CBN_SELCHANGE(IDC_COMBO4, &CHZGLDlg::OnCbnSelchangeCombo4)
ON_EN_KILLFOCUS(IDC_EDITROOMW, &CHZGLDlg::OnEnKillfocusEditroomw)
ON_BN_CLICKED(IDC_BUTTON1, &CHZGLDlg::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON4, &CHZGLDlg::OnBnClickedButton4)
ON_EN_CHANGE(IDC_EDIT24, &CHZGLDlg::OnEnChangeEdit24)
ON_BN_CLICKED(IDC_BUTTON2, &CHZGLDlg::OnBnClickedButton2)
ON_BN_CLICKED(IDC_BTADDROOM2, &CHZGLDlg::OnBnClickedBtaddroom2)
ON_BN_CLICKED(IDC_BTADDROOM3, &CHZGLDlg::OnBnClickedBtaddroom3)
ON_BN_CLICKED(IDC_BTADDROOM4, &CHZGLDlg::OnBnClickedBtaddroom4)
ON_BN_CLICKED(IDC_BTADDROOM5, &CHZGLDlg::OnBnClickedBtaddroom5)
ON_BN_CLICKED(IDC_BTADDROOM6, &CHZGLDlg::OnBnClickedBtaddroom6)
ON_BN_CLICKED(IDC_BTADDROOM7, &CHZGLDlg::OnBnClickedBtaddroom7)
ON_BN_CLICKED(IDC_BTADDROOM9, &CHZGLDlg::OnBnClickedBtaddroom9)
ON_BN_CLICKED(IDC_BTADDROOM8, &CHZGLDlg::OnBnClickedBtaddroom8)
ON_BN_CLICKED(IDC_BTADDROOM10, &CHZGLDlg::OnBnClickedBtaddroom10)
ON_BN_CLICKED(IDC_BTADDROOM11, &CHZGLDlg::OnBnClickedBtaddroom11)
ON_BN_CLICKED(IDC_BUTTON6, &CHZGLDlg::OnBnClickedButton6)
ON_BN_CLICKED(IDC_BUTTON5, &CHZGLDlg::OnBnClickedButton5)
ON_BN_CLICKED(IDC_BUTTON3, &CHZGLDlg::OnBnClickedButton3)
ON_EN_KILLFOCUS(IDC_EDITT4, &CHZGLDlg::OnEnKillfocusEditt4)
ON_EN_KILLFOCUS(IDC_EDITT3, &CHZGLDlg::OnEnKillfocusEditt3)
ON_BN_CLICKED(IDC_BUTTON17, &CHZGLDlg::OnBnClickedButton17)
ON_BN_CLICKED(IDC_BUTTON56, &CHZGLDlg::OnBnClickedButton56)
ON_BN_CLICKED(IDC_BUTTON11, &CHZGLDlg::OnBnClickedButton11)
ON_BN_CLICKED(IDC_BUTTON19, &CHZGLDlg::OnBnClickedButton19)
ON_BN_CLICKED(IDC_BTMODIROOM3, &CHZGLDlg::OnBnClickedBtmodiroom3)
ON_BN_CLICKED(IDC_CHECK1, &CHZGLDlg::OnBnClickedCheck1)
ON_BN_CLICKED(IDC_CHECK3, &CHZGLDlg::OnBnClickedCheck3)
ON_EN_KILLFOCUS(IDC_EDITH13, &CHZGLDlg::OnEnKillfocusEdith13)
ON_EN_KILLFOCUS(IDC_EDITH12, &CHZGLDlg::OnEnKillfocusEdith12)
END_MESSAGE_MAP()
BOOL CHZGLDlg::OnInitDialog()
{
m_data.fNodeDef[0] = AS_MUNITF(200);
m_data.fNodeDef[1] = AS_MUNITF(3000);
m_data.fNodeDef[2] = AS_MUNITF(400);
m_data.fNodeDef[3] = AS_MUNITF(300);
m_data.fNodeDef[4] = AS_MUNITF(3000);
m_data.fNodeDef[5] = .0;
m_data.fNodeDef[6] = 80.;
m_data.fNodeDef[7] = AS_MUNITF(400);
m_data.fNodeDef[8] = AS_MUNITF(450);
m_data.fNodeDef[9] = AS_MUNITF(3000);
m_data.fNodeDef[10] = AS_MUNITF(3000);
CBaseDialog::OnInitDialog();
if (IsInplaceEdit())
{
initByCrossSectionScr();
}
CBitmap bmp32;
if (!bmp32.LoadBitmap (IDB_BITMAP10))
{
AfxMessageBox(_T ("Can't load bitmap: %x\n"), IDB_BITMAP32);
ASSERT (FALSE);
return FALSE;
}
//附属物界面
BITMAP bmpObj32;
bmp32.GetBitmap (&bmpObj32);
UINT nFlags = ILC_COLOR24 | ILC_MASK;
m_Imagelist32.Create (32, bmpObj32.bmHeight, nFlags, 0, 0);
m_Imagelist32.Add (&bmp32, RGB (255, 0, 0));
m_wndButton2.SetIcon(m_Imagelist32.ExtractIcon(0));
m_wndButton3.SetIcon(m_Imagelist32.ExtractIcon(2));
m_wndButton4.SetIcon(m_Imagelist32.ExtractIcon(1));
m_wndButton5.SetIcon(m_Imagelist32.ExtractIcon(3));
m_wndButton6.SetIcon(m_Imagelist32.ExtractIcon(4));
m_wndButton9.SetIcon(m_Imagelist32.ExtractIcon(5));
m_wndButton8.SetIcon(m_Imagelist32.ExtractIcon(6));
m_wndButton10.SetIcon(m_Imagelist32.ExtractIcon(7));
m_wndButton7.SetIcon(m_Imagelist32.ExtractIcon(8));
m_wndButton11.SetIcon(m_Imagelist32.ExtractIcon(9));
m_wndButton12.SetIcon(m_Imagelist32.ExtractIcon(10));
m_wndButton13.SetIcon(m_Imagelist32.ExtractIcon(11));
m_wndButton14.SetIcon(m_Imagelist32.ExtractIcon(12));
m_wndButton17.SetIcon(m_Imagelist32.ExtractIcon(13));
m_wndButton56.SetIcon(m_Imagelist32.ExtractIcon(14));
m_wndButtonCo11.SetIcon(m_Imagelist32.ExtractIcon(15));
m_wndButtonO19.SetIcon(m_Imagelist32.ExtractIcon(16));
m_dChamferInter = AS_M2MM(m_data.fNodeDef[0]);
m_dInterH = AS_M2MM(m_data.fNodeDef[1]);
m_dOutT = AS_M2MM(m_data.fNodeDef[2]);
m_dIntT = AS_M2MM(m_data.fNodeDef[3]);
m_dRoomWAdd = AS_M2MM(m_data.fNodeDef[4]);
m_dG = m_data.fNodeDef[5];
// 在位编辑在外部已经设置好了m_dYXLen
if (!IsInplaceEdit())
m_dYXLen = m_data.fNodeDef[6];
m_dt4 = AS_M2MM(m_data.fNodeDef[7]);
//m_dt5 = (int)AS_M2MM(m_data.fNodeDef[8]);
m_dh0 = m_dInterH;
m_dh1 = m_dInterH;
// 获取脚本中的m_dt5
if (!m_sCrossSectionScr.IsEmpty())
{
AecDbEarthWorm dbEwTmp;
dbEwTmp.SetCrossSectionScr(m_sCrossSectionScr);
AcGePoint2dArray arrPnt2d;
dbEwTmp.ExtractEarthWormScr(arrPnt2d);
m_dh0 = AS_M2MM(dbEwTmp.GetLeftRoomHeight());
m_dh1 = AS_M2MM(dbEwTmp.GetRightRoomHeight());
int countOfRoom = dbEwTmp.GetRoomCount();
m_dOutT = AS_M2MM(arrPnt2d[countOfRoom].x);
m_dt5 = AS_M2MM(dbEwTmp.GetBomThickAdd()) + m_dOutT;
m_dt4 = AS_M2MM(dbEwTmp.GetTopThickAdd()) + m_dOutT;
m_dInterH = AS_M2MM(arrPnt2d.first().y);
}
if (m_dt4 < 1.e-3)
m_dt4 = m_dOutT;
if (m_dt5 < 1.e-3)
m_dt5 = m_dOutT;
//写入临时文件
CString sFullPath = FilePath::GetSysDir();
sFullPath.MakeLower();
sFullPath += _T("\\HZGLDlg.map");
if (!IsInplaceEdit())
{
CStdioFile file1;
if (file1.Open(sFullPath, CFile::modeRead))
{
CString sLast, sText;
int nPos = 0;
while (file1.ReadString(sText))
{
sText.TrimRight(_T('\n'));
if (nPos % 2 == 1)
{
m_mapIndexToName.SetAt(sLast, sText);
}
else
{
sLast = sText;
}
nPos += 1;
}
file1.Close();
}
else
{
CString str(_T(""));
GetCrossSectionScr(str);
AecDbEarthWorm ew;
ew.SetCrossSectionScr(m_sCrossSectionScr);
int roomCount = ew.GetRoomCount();
LPCTSTR ar[] = { _T("电力舱"), _T("综合舱"), _T("燃气舱") };
for (int i = 0; i < roomCount; ++i)
{
str.Format(_T("%d"), i);
m_mapIndexToName.SetAt(str, ar[i]);
}
}
}
else
{
;
}
std::vector<CString> vec(0);
CString type(_T("")),sTemp;
for (int i = 0; i < m_mapIndexToName.GetCount(); ++i)
{
sTemp.Format(_T("%d"), i);
if (!m_mapIndexToName.Lookup(sTemp, type))
type = _T("NONE");
vec.push_back(type);
}
if (!vec.empty())
m_sRoomName = vec[0];
SetRoomFeature(vec);
//解析EXT设置key
ESection eSecType = eRect;
AcGeLineSeg3d ln;
ExtractExtMap(eSecType,ln);
ShowEarthWorm();
std::vector<CString> strs;
CoreTools::SplitString(m_data.szNodeDefSpec, _T("|"), strs);
if (strs.size() == 2)
{
m_sCity = strs[0];
m_sRoad = strs[1];
}
m_wndRoomReducerBt.ShowWindow(SW_HIDE);
m_wndBTRainbow.ShowWindow(SW_HIDE);
if (!m_bIsYXGLJD)
{
GetDlgItem(IDC_STATIC_YX)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDITYX)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_YXM)->ShowWindow(SW_HIDE);
}
if (m_bIsLSGL)
{
GetDlgItem(IDC_STATIC_ALIGN)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_RADIO1)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_RADIO2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_RADIO21)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_RADIO22)->ShowWindow(SW_SHOW);
}
if (!m_bHasGrade)
{
m_wndStaticG.ShowWindow(SW_HIDE);
m_wndEditG.ShowWindow(SW_HIDE);
m_wndStaticP.ShowWindow(SW_HIDE);
}
else
{
m_wndRoomReducerBt.ShowWindow(SW_SHOW);
m_wndBTRainbow.ShowWindow(SW_SHOW);
}
m_idxRoom = -1;
AecDbEarthWorm ew;
ew.SetCrossSectionScr(m_sCrossSectionScr);
AcGePoint2dArray arPnt;
ew.ExtractEarthWormScr(arPnt);
if (!arPnt.isEmpty())
{
m_idxRoom = 0;
m_dRoomWAdd = AS_M2MM(arPnt[0].x);
}
UpdateData(FALSE);
CBimInfoDlg::ShowBimInfo(&m_mapSpecXData,_T("管廊"),FALSE);
return TRUE;
}
void CHZGLDlg::OnViewLButtonDownMsg()
{
if (m_idxRoom != -1 && m_pRectCell != NULL)
{
UpdateData(TRUE);
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);
ERoom room;
worm.GetRoom(m_idxRoom,room);
/*AcGePoint2d pt1,pt2,pt3;
m_pRectCell->getPointAt(0,pt1);
m_pRectCell->getPointAt(1,pt2);
m_pRectCell->getPointAt(2,pt3);
m_dRoomWAdd = pt1.distanceTo(pt2) * 1000;
m_dInterH = pt2.distanceTo(pt3) * 1000;
*/
m_dRoomWAdd = room.ptGe[1].distanceTo(room.ptGe[0]) * 1000.0;
m_dInterH = room.ptGe[3].distanceTo(room.ptGe[0]) * 1000.0;
CString sTemp;
sTemp.Format(_T("%d"),m_idxRoom);
m_mapIndexToName.Lookup(sTemp,m_sRoomName);
UpdateData(FALSE);
int nSel = m_wndCombo4.FindString(0,m_sRoomName);
if (nSel != -1)
{
m_wndCombo4.SetCurSel(nSel);
}
}
}
void CHZGLDlg::SetFeatureForEarthworm(AecDbEarthWorm *pEw)
{
if (!pEw) return;
CString sTemp, sName;
for (int ii = 0; ii < m_mapIndexToName.GetCount(); ii++)
{
sTemp.Format(_T("%d"), ii);
if (m_mapIndexToName.Lookup(sTemp, sName))
pEw->GetSpecialtyData()->SetAt(sTemp, sName);
}
return;
}
void CHZGLDlg::SetFeatureForEarthworm(AecDbEarthWormFitting *pEw)
{
if (!pEw) return;
CString sTemp, sName, sTemp2;
for (int ii = 0; ii < m_mapIndexToName.GetCount(); ii++)
{
sTemp.Format(_T("%d"), ii);
sTemp2.Format(_T("room-%d"), ii);
if (m_mapIndexToName.Lookup(sTemp, sName))
pEw->GetSpecialtyData()->SetAt(sTemp2, sName);
}
return;
}
void CHZGLDlg::InitRoomFeature(const AecDbEarthWorm *pEw)
{
if (!pEw) // 新建一段管廊时
{
std::vector<CString> vec(10, _T("NONE"));
SetRoomFeature(vec);
return;
}
CString str(_T("")), feature(_T(""));
for (int i = 0; i < pEw->GetRoomCount(); ++i)
{
str.Format(_T("%d"), i);
const AecDbObjXDataMap *pMap = pEw->GetSpecialtyData();
if (pMap)
{
pMap->GetAt(str, feature);
m_mapIndexToName.SetAt(str, feature);
m_roomTypes.push_back(feature);
}
}
}
void CHZGLDlg::OnBnClickedOk()
{
UpdateData();
if (m_bIsLSGL)
{
if (m_nAlign != 3) // 不是管廊中心线对齐
{
if (GetIdxOfRoom() == -1)
{
AfxMessageBox(_T("请选择一个舱室做为管廊对齐的参考。"));
return;
}
}
}
CString sText;
if (!m_bIsInsertLibrary)
{
if (m_dInterH < 100.0f)
{
sText = _T("舱室高度太小!");
AfxMessageBox(sText);
return;
}
if (m_dOutT < 10.0f || m_dIntT < 10.0f)
{
sText = _T("管廊外壁厚度或室间厚度太小!");
AfxMessageBox(sText);
return;
}
}
if (m_bIsYXGLJD)
{
if (m_dYXLen < 5.0f )
{
sText = _T("异型管廊节点长度太小,至少大于5米!");
AfxMessageBox(sText);
return;
}
}
m_data.fNodeDef[0] = AS_MUNITF(m_dChamferInter);
m_data.fNodeDef[1] = AS_MUNITF(m_dInterH);
m_data.fNodeDef[2] = AS_MUNITF(m_dOutT);
m_data.fNodeDef[3] = AS_MUNITF(m_dIntT);
m_data.fNodeDef[4] = AS_MUNITF(m_dRoomWAdd);
m_data.fNodeDef[5] = m_dG;
m_data.fNodeDef[6] = m_dYXLen;
m_data.fNodeDef[7] = AS_MUNITF(m_dt4);
m_data.fNodeDef[8] = AS_MUNITF(m_dt5);
m_data.fNodeDef[9] = AS_MUNITF(m_dh0);
m_data.fNodeDef[10] = AS_MUNITF(m_dh1);
std::vector<CString> strs;
strs.push_back(m_sCity);
strs.push_back(m_sRoad);
CString str = CoreTools::ConnectString(strs, _T("|"));
if (!str.IsEmpty())
_tcscpy(m_data.szNodeDefSpec, str);
AecDbEarthWorm ew;
ew.SetCrossSectionScr(m_sCrossSectionScr);
int roomCount = ew.GetRoomCount();
CString key(_T("")), value(_T(""));
bool bWrong(false);
//本地路径
CString sFullPath = FilePath::GetSysDir();
sFullPath.MakeLower();
sFullPath += _T("\\HZGLDlg.map");
//写入临时文件
CStdioFile file1;
if (file1.Open(sFullPath,CFile::modeWrite | CFile::modeCreate))
{
for (POSITION ps = m_mapIndexToName.GetStartPosition();ps != NULL;)
{
m_mapIndexToName.GetNextAssoc(ps,key,value);
key += _T("\n");
file1.WriteString(key);
value += _T("\n");
file1.WriteString(value);
}
file1.Close();
}
if (m_mapIndexToName.GetSize() >= roomCount)
{
for (int i = 0; i < roomCount; ++i)
{
key.Format(_T("%d"), i);
if (!m_mapIndexToName.Lookup(key, value))
{
bWrong = true;
break;
}
if (value.CompareNoCase(_T("NONE")) == 0)
{
bWrong = true;
break;
}
}
}
else
{
bWrong = true;
}
if (bWrong && !m_bIsInsertLibrary)
{
AfxMessageBox(_T("请确定为每个舱室设置了功能。"));
return;
}
UIDataCache::Write(_T("%s"), m_sTag, &m_sCrossSectionScr);
CBaseDialog::OnOK();
}
void CHZGLDlg::OnBnClickedBtaddroom()
{
UpdateData();
if (m_dRoomWAdd - 100.0 > 1.e-3)
{
//m_sCrossSectionScr = _T("RECT:3.900x3.600|2.900x3.600|0.400x0.300");
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);//last
worm.SetChamferInter(m_dChamferInter);
ESection eType = eRect;
AcGePoint2dArray arDatas;
eType = worm.ExtractEarthWormScr(arDatas);
AcGePoint2d ptLastRoom( AS_MUNITF(m_dRoomWAdd),AS_MUNITF(m_dInterH));
for (int i = 0;i < arDatas.length() - 1;i++)
{
AcGePoint2d& ptTemp = arDatas.at(i);
ptTemp.x = AS_MUNITF(m_dInterH);
}
arDatas.insertAt(arDatas.length() - 1,ptLastRoom);
//_T("RECT:3.900x3.600|2.900x3.600|0.400x0.300");
CString sCrossSectionScr = _T("RECT:");
CString sTemp;
for (int i = 0;i < arDatas.length();i++)
{
sTemp.Format(_T("%gx%g"),arDatas.at(i).x,arDatas.at(i).y);
sCrossSectionScr += sTemp;
if (i < arDatas.length() - 1) sCrossSectionScr += _T("|");
}
m_sCrossSectionScr = sCrossSectionScr;
ShowEarthWorm();
}
else
{
AfxMessageBox(_T("舱的宽度尺寸过小!"));
}
}
void CHZGLDlg::UpdateSplitRoomName(AecDbEarthWorm* pWorm)
{
int nRoomIndex = GetIdxOfRoom();
if (m_pRectCell != NULL && nRoomIndex != -1)
{
AcGePoint2d pt[4];
m_pRectCell->getPointAt(0,pt[0]);
m_pRectCell->getPointAt(1,pt[1]);
m_pRectCell->getPointAt(2,pt[2]);
m_pRectCell->getPointAt(3,pt[3]);
//判断是否分舱
double dCenX = (pt[0].x + pt[2].x) / 2.0;
double dCenY = (pt[0].y + pt[2].y) / 2.0;
AcGePoint2d ptCellCenter(dCenX, dCenY);
ERoom room;
pWorm->GetRoom(nRoomIndex,room);
AcGePoint2d ptRoomCenter((room.ptGe[0].x + room.ptGe[2].x) * .5, (room.ptGe[0].y + room.ptGe[2].y) * .5);
if (EQUAL_ZERO(ptRoomCenter.distanceTo(ptCellCenter)))
return;
CString sKey,sVal;
sKey.Format(_T("%d|%d|%d|ROOMNAME"), nRoomIndex, (int)( 100.0 * dCenX ),(int)(100.0 * dCenY) );//放大100倍
sVal.Format(_T("<ROOMNAME:%d|%d|%d|%s>"),nRoomIndex,(int)( 100.0 * dCenX ),(int)(100.0 * dCenY),m_sRoomName);
m_mapAddtion.SetAt(sKey,sVal);
//去除总分舱名称
dCenX = (room.ptGe[0].x + room.ptGe[2].x) / 2.0;
dCenY = (room.ptGe[0].y + room.ptGe[2].y) / 2.0;
sKey.Format(_T("%d|%d|%d|ROOMNAME"), nRoomIndex, (int)( 100.0 * dCenX ),(int)(100.0 * dCenY) );//放大100倍
m_mapAddtion.RemoveKey(sKey);
}
}
void CHZGLDlg::initByCrossSectionScr()
{
// 此函数根据m_sCrossSectionScr来解析
// m_dChamferInter 倒角 fNodeDef[0]
// m_dInterH 管廊高 fNodeDef[1]
// m_dOutT 外壁厚 fNodeDef[2]
// m_dIntT 内壁厚 fNodeDef[3]
// m_dt4 顶厚 fNodeDef[7]
// m_dt5 底厚 fNodeDef[8]
/*
例:RECT:3x4|4x4|3x4|0.36x0.35|EXT:<BOM2CHM:0.15|0.3|0.1>
3x4|4x4|3x4| 中的 4 为管廊高
|0.36x0.35| 中 前一个为 m_dOutT, 后一个为 m_dIntT
<BOM2CHM:0.15|0.3|0.1> 中 第一个为 m_dt5 - m_dOutT 第二个为m_dChamferInter 第三个为m_dt4 - m_dOutT
*/
std::vector<CString> arr(0);
CString sSrc(m_sCrossSectionScr);
CString str1(_T("")), str2(_T(""));
int idx1(-1), idx2(-1);
idx1 = sSrc.Find(_T(":"), 0);
if (idx1 == -1) return;
idx1 += 1;
if (idx1 >= sSrc.GetLength()) return;
idx2 = sSrc.Find(_T("|EXT:"), idx1);
if (idx2 == -1) return;
CString sRect(sSrc.Mid(idx1, idx2 - idx1));
CoreTools::SplitString(sRect, _T("|"), arr);
if (arr.size() < 2) return;// 必有一个舱,再加上内外壁厚
str1 = *arr.begin();
str2 = *arr.rbegin();
arr.clear();
CoreTools::SplitString(str1, _T("x"), arr);
if (arr.size() != 2) return;
m_data.fNodeDef[1] = _ttof(*arr.rbegin());
arr.clear();
CoreTools::SplitString(str2, _T("x"), arr);
if (arr.size() != 2) return;
m_data.fNodeDef[2] = _ttof(*arr.begin());
m_data.fNodeDef[3] = _ttof(*arr.rbegin());
double doutT = AS_M2MM(m_data.fNodeDef[2]);
arr.clear();
idx1 = sSrc.Find(_T("<BOM2CHM:"), 0);
if (idx1 == -1) return;
idx1 += 9;
if (idx1 >= sSrc.GetLength()) return;
idx2 = sSrc.Find(_T(">"), idx1);
if (idx2 == -1) return;
CString sBOM2CHM(sSrc.Mid(idx1, idx2 - idx1));
CoreTools::SplitString(sBOM2CHM, _T("|"), arr);
if (arr.size() != 3) return;
double dBomAdd = _ttof(arr[0]);
m_data.fNodeDef[0] = _ttof(arr[1]);
double dTopAdd = _ttof(arr[2]);
doutT += AS_M2MM(dBomAdd);
m_data.fNodeDef[8] = AS_MUNITF(doutT);
doutT = AS_M2MM(m_data.fNodeDef[2]);
doutT += AS_M2MM(dTopAdd);
m_data.fNodeDef[7] = AS_MUNITF(doutT);
}
void CHZGLDlg::OnBnClickedBtmodiroom()
{
UpdateData();
if (m_dRoomWAdd < AS_MUNIT(10.0) )
{
AfxMessageBox(_T("室宽度太小!请重新输入管廊截面内舱舱宽!"));
return;
}
if (m_dInterH < AS_MUNIT(10.0) )
{
AfxMessageBox(_T("室高度太小!请重新输入管廊截面内舱高度!"));
return;
}
if (GetIdxOfRoom() != -1)
{
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);//last
worm.SetChamferInter(m_dChamferInter);
ESection eType = eRect;
AcGePoint2dArray arDatas;
eType = worm.ExtractEarthWormScr(arDatas);
//修改 W
AcGePoint2d& pt = arDatas.at(GetIdxOfRoom());
pt.x = AS_MUNIT(m_dRoomWAdd);
//修改全部高度,合成文本
CString sCrossSectionScr = _T("RECT:");
CString sTemp;
for (int i = 0;i < arDatas.length();i++)
{
//W x H
if (i < arDatas.length() - 1)
sTemp.Format(_T("%gx%g"),arDatas.at(i).x,AS_MUNIT(m_dInterH));
else
sTemp.Format(_T("%gx%g"),AS_MUNIT(m_dOutT),AS_MUNIT(m_dIntT));
sCrossSectionScr += sTemp;
if (i < arDatas.length() - 1) sCrossSectionScr += _T("|");
}
CString sLRRoomH = _T("");
if (m_dh0 > 0.2 || m_dh1 > 0.2)
{
if (arDatas.length() - 1 >= 2)//必须大于两舱才有左右侧高度特定情况
{
if (m_dh0 > 0.2 || m_dh1 > 0.2)
{
sLRRoomH.Format(_T("<%s:%g|%g>"),EW_LRROOMH,AS_MUNIT(m_dh0),AS_MUNIT(m_dh1));
}
}
}
CString sExt = _T("|EXT:"),sKey,sExtVal;
//if (m_dt5 > m_dOutT)
//{
double dBomAdd = m_dt5 - m_dOutT;
if (dBomAdd < 0) dBomAdd = 0;
double dTopAdd = m_dt4 - m_dOutT;
if (dTopAdd < 0) dTopAdd = 0;
sExtVal.Format(_T("<%s:%g|%g|%g>"),EW_BOMANDCHM,AS_MUNIT(dBomAdd),AS_MUNIT(m_dChamferInter),AS_MUNIT(dTopAdd));
m_mapAddtion.SetAt(EW_BOMANDCHM,sExtVal);
//}
sTemp.Format(_T("%d"),GetIdxOfRoom());
m_mapIndexToName.SetAt(sTemp,m_sRoomName);
//EW_LRROOMADD
m_mapAddtion.RemoveKey(EW_LRROOMADD);
if (m_dLRAddThick > 1.e-2)
{
sExtVal.Format(_T("<%s:%g|%d>"),EW_LRROOMADD,AS_MUNIT(m_dLRAddThick),m_nLRAddThick);
m_mapAddtion.SetAt(EW_LRROOMADD,sExtVal);
}
//更新分舱的名称
UpdateSplitRoomName(&worm);
for (POSITION ps = m_mapAddtion.GetStartPosition();ps != NULL;)
{
m_mapAddtion.GetNextAssoc(ps,sKey,sExtVal);
sExt += sExtVal;
}
m_sCrossSectionScr = sCrossSectionScr;
if (sExt.CompareNoCase(_T("|EXT:")) != 0)
{
m_sCrossSectionScr += sExt;
}
worm.SetCrossSectionScr(m_sCrossSectionScr);//last
worm.SetChamferInter(m_dChamferInter);
int count = worm.GetRoomCount();
std::vector<CString> vec(0);
CString type(_T(""));
for (int i = 0; i < count; ++i)
{
sTemp.Format(_T("%d"), i);
if (!m_mapIndexToName.Lookup(sTemp, type))
type = _T("NONE");
vec.push_back(type);
}
SetRoomFeature(vec);
m_sCrossSectionScr += sLRRoomH;
ShowEarthWorm();
}
}
void CHZGLDlg::OnBnClickedBtaddtodb()
{
//_T("RECT:3900x3600|2900x3600|400x300|EXT:...");//EXT为扩充字段
OnBnClickedBtmodiroom();
CGLTKDlg dlg(CGLTKDlg::eInput);
dlg.SetCrossSectionScr(m_sCrossSectionScr);
dlg.DoModal();
}
void CHZGLDlg::ExtractTopAndBomAdd(AcGePoint2d& pt2d)
{
pt2d.set(0,0);
//_T("RECT:3900x3600|2900x3600|400x300|EXT:<F:*|*|*><><>...")
int nPos = m_sCrossSectionScr.Find(_T("EXT:"));
if (nPos != -1)
{
//EXT:
if (nPos + 4 < m_sCrossSectionScr.GetLength() )
{
CString sExt = m_sCrossSectionScr.Mid(nPos + 4);
//
int nPos1 = m_sCrossSectionScr.Find(EW_BOMANDCHM);
int nPos2 = m_sCrossSectionScr.Find(_T('>'),nPos1);
if (nPos1 != -1 && nPos2 != -1)
{
//BOMANDCHM:20|150>
CString sScript = m_sCrossSectionScr.Mid(nPos1,nPos2 - nPos1);//no >
sScript.TrimLeft(EW_BOMANDCHM);
sScript.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScript, arInf, _T('|'));
AcDbRegion* pAddReg = NULL;
if (arInf.GetSize() >= 3)
{
double dBomWAdd = _ttof(arInf.GetAt(0));
double dTopWAdd = _ttof(arInf.GetAt(2));
pt2d.set(1000.0 * dBomWAdd,1000.0 * dTopWAdd);//毫米
}
}
}
}
}
void CHZGLDlg::ExtractExtMap(ESection eSecType,AcGeLineSeg3d ln)
{
m_mapAddtion.RemoveAll();
int nPos = m_sCrossSectionScr.Find(_T("EXT:"));
if (nPos != -1)
{
//EXT:
if (nPos + 4 < m_sCrossSectionScr.GetLength() )
{
CString sExt = m_sCrossSectionScr.Mid(nPos + 4);
//<><><><><><>.....
CString sScript,sScriptT,sScript2,sScriptNewVer;
CString sKey,sOld;
int nSta = 0,nPos2 = 0,nRoomIndex = 0,nLRPos = 0,nNo = 1;
nPos = sExt.Find(_T('<'),nSta);
while(nPos != -1)
{
nPos2 = sExt.Find(_T('>'),nPos + 1);
if (nPos2 == -1)
break;
//..<***>...
sScript = sExt.Mid(nPos + 1,nPos2 - nPos - 1);
if (sScript.Find( EW_HOLDER ) != -1)
{
//HOLDER:房间|左右位置|层数|垂直间隙|水平间隙|距顶D|长度|宽度|厚度|材料|用途|偏移=(,,,)|编号
sScriptT = sScript;
sScriptT.TrimLeft(EW_HOLDER);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT,arInf,_T('|'));
if (arInf.GetSize() >= 12)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
nLRPos = _ttoi(arInf.GetAt(1));
if (arInf.GetSize() > 12)
{
nNo = _ttoi(arInf.GetAt(12));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"),nNo);
sScriptNewVer =sScript + sOld;
m_sCrossSectionScr.Replace(sScript,sScriptNewVer);
sScript = sScriptNewVer;
}
sKey.Format(_T("%d-%d-%d-HOLDER"),nRoomIndex,nLRPos,nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_BOSS) != -1)
{
//<BOSS:房间|左右位置|侧间隙|水平间隙|宽|高|长|直径|用途>
sScriptT = sScript;
sScriptT.TrimLeft(EW_BOSS);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT,arInf,_T('|'));
if (arInf.GetSize() >= 9)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
if (arInf.GetSize() > 16)
nLRPos = _ttoi(arInf.GetAt(16));
sKey.Format(_T("%d-%d-BOSS"),nRoomIndex,nLRPos);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find( EW_HANGER ) != -1)
{
//HANGER:房间|层数|垂直间隙|水平间隙|左侧距离|距顶D|长度|宽度|厚度|材料|用途|偏移(,,,)
sScriptT = sScript;
sScriptT.TrimLeft(EW_HANGER);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT,arInf,_T('|'));
if (arInf.GetSize() >= 13)
{
nNo = _ttoi(arInf.GetAt(12));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sCrossSectionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 11)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-HANGER"),nRoomIndex,0, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_RINGS) != -1)
{
//RINGS:房间|半径|长度|位置|材料|用途
sScriptT = sScript;
sScriptT.TrimLeft(EW_RINGS);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT,arInf,_T('|'));
if (arInf.GetSize() >= 9)
{
nNo = _ttoi(arInf.GetAt(8));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sCrossSectionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 7)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-RINGS"),nRoomIndex,0, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_LAMPS) != -1)
{
//LAMPS:房间|长度|宽度|厚度|左侧定位|纵向间距|瓦数|名称|型好|厂家
sScriptT = sScript;
sScriptT.TrimLeft(EW_LAMPS);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 12)
{
nNo = _ttoi(arInf.GetAt(11));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sCrossSectionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 10)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-LAMPS"), nRoomIndex, 0, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_FIREET) != -1)
{
//FIREET:房间|安装方式|安装位置|X直径L|Y直径H|上间隙TSP|下间隙DSP|填充量|工作温度|性能|型号|名称|类别|厂家
sScriptT = sScript;
sScriptT.TrimLeft(EW_FIREET);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 16)
{
nNo = _ttoi(arInf.GetAt(15));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sCrossSectionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 13)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
int nSetup = _ttoi(arInf.GetAt(1));
int nHSetup = _ttoi(arInf.GetAt(2));
CString sTemp;
sTemp.Format(_T("1%d%d"),nSetup,nHSetup);
sKey.Format(_T("%d-%s-%d-FIREET"), nRoomIndex, sTemp, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_GUTTERWAY) != -1)
{
sKey.Format(_T("%d-%d-GUTTERWAY"), 0, 0);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript);
}
else if (sScript.Find(EW_FIREDOOR) != -1)
{
//FIREDOOR:房间|宽|高|位置|型号|厂家
sScriptT = sScript;
sScriptT.TrimLeft(EW_FIREDOOR);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 8)
{
nNo = _ttoi(arInf.GetAt(7));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sCrossSectionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 5)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-FIREDOOR"), nRoomIndex, nPos, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_SECURITY) != -1)
{
//SECURITY:房间|大径|小径|高度|定位|间距|名称|型号|厂家
sScriptT = sScript;
sScriptT.TrimLeft(EW_SECURITY);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 11)
{
nNo = _ttoi(arInf.GetAt(10));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sCrossSectionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 9)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-SECURITY"), nRoomIndex, 0, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_DRAFAN) != -1)
{
//DRAFAN:房间|外径|长度|吊高|间距|风量|功率|机号|名称|型号|厂家
sScriptT = sScript;
sScriptT.TrimLeft(EW_DRAFAN);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 13)
{
nNo = _ttoi(arInf.GetAt(12));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sCrossSectionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 11)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-DRAFAN"), nRoomIndex, 0, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_GASALARM) != -1)
{
//GASALARM:房间|位置|高度|长|宽|厚|间距|名称|等级|型号|厂家
sScriptT = sScript;
sScriptT.TrimLeft(EW_GASALARM);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 13)
{
nNo = _ttoi(arInf.GetAt(12));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sCrossSectionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 11)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
nLRPos = _ttoi(arInf.GetAt(1));
sKey.Format(_T("%d-%d-%d-GASALARM"), nRoomIndex, nLRPos, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if(sScript.Find(EW_ROOMSLAB) != -1)
{
//ROOMSLAB: 房间|位置方向|距离|子舱宽|板厚度|偏移x|偏移y|编号
sScriptT = sScript;
sScriptT.TrimLeft(EW_ROOMSLAB);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 8)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
CString sNo = arInf.GetAt(7);
sKey.Format(_T("%d-%s-ROOMSLAB"), nRoomIndex, sNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_SMOKALARM) != -1)
{
//SMOKALARM:房间|位置|间距|外径|高度|名称|编号|规格|厂家|偏移
sScriptT = sScript;
sScriptT.TrimLeft(EW_SMOKALARM);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 11)
{
nNo = _ttoi(arInf.GetAt(10));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sCrossSectionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 10)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-SMOKALARM"), nRoomIndex, 0, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_TEMPALARM) != -1)
{
//TEMPALARM:房间|左右侧|位置|间距|宽度|高度|厚度|名称|编号|规格|厂家|偏移
sScriptT = sScript;
sScriptT.TrimLeft(EW_TEMPALARM);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 13)
{
nNo = _ttoi(arInf.GetAt(12));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sCrossSectionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 10)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
int nPos = _ttoi(arInf.GetAt(1));
sKey.Format(_T("%d-%d-%d-TEMPALARM"), nRoomIndex, nPos, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_COALARM) != -1)
{
//COALARM:房间|左右侧|位置|间距|宽度|高度|厚度|名称|浓度|偏移
sScriptT = sScript;
sScriptT.TrimLeft(EW_COALARM);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 12)
{
nNo = _ttoi(arInf.GetAt(11));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sCrossSectionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 10)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
int nPos = _ttoi(arInf.GetAt(1));
sKey.Format(_T("%d-%d-%d-COALARM"), nRoomIndex, nPos, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_OXALARM) != -1)
{
//OXALARM:房间|左右侧|位置|间距|宽度|高度|厚度|名称|采样方式|测量精度|厂家|偏移
sScriptT = sScript;
sScriptT.TrimLeft(EW_OXALARM);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 13)
{
nNo = _ttoi(arInf.GetAt(12));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sCrossSectionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 10)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
int nPos = _ttoi(arInf.GetAt(1));
sKey.Format(_T("%d-%d-%d-OXALARM"), nRoomIndex, nPos, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_ROOMNAME) != -1)
{
//ROOMNAME:房间|中心x|中心y|名称 -->x,y放大100倍
sScriptT = sScript;
sScriptT.TrimLeft(EW_ROOMNAME);
sScriptT.TrimLeft(_T(':'));
//判断是否分舱
//double dCenX = (pt[0].x + pt[2].x) / 2.0;
//double dCenY = (pt[0].y + pt[2].y) / 2.0;
//CString sKey,sVal;
//sKey.Format(_T("%d|%d|%d|ROOMNAME"), nRoomIndex, (int)( 100.0 * dCenX ),(int)(100.0 * dCenY) );//放大100倍
//sVal.Format(_T("<ROOMNAME:%d|%d|%d|%s>"),nRoomIndex,(int)( 100.0 * dCenX ),(int)(100.0 * dCenY),m_sRoomName);
//m_mapAddtion.SetAt(sKey,sVal);
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 4)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
int nCenX = _ttoi(arInf.GetAt(1));
int nCenY = _ttoi(arInf.GetAt(2));
sKey.Format(_T("%d|%d|%d|ROOMNAME"),nRoomIndex,nCenX,nCenY);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_CHARMNO) != -1)
{
sScriptT = sScript;
sScriptT.TrimLeft(EW_CHARMNO);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 2)
{
m_bTopNoCharm = _ttoi(arInf.GetAt(0));
m_bBomNoCharm = _ttoi(arInf.GetAt(1));
sKey = _T("CHMNO");
sScript2.Format(_T("<CHMNO:%d|%d>"),m_bTopNoCharm,m_bBomNoCharm);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if(sScript.Find(EW_LRROOMADD) != -1)
{
sScriptT = sScript;
sScriptT.TrimLeft(EW_LRROOMADD);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 2)
{
m_dLRAddThick = AS_M2MM(_ttof(arInf.GetAt(0)));
m_nLRAddThick = _ttoi(arInf.GetAt(1));
}
}
nSta += sScript.GetLength();
nPos = sExt.Find(_T('<'),nSta);
}
}
}
}
void CHZGLDlg::OnBnClickedBtselfromdb()
{
CGLTKDlg dlg(CGLTKDlg::eSelect);
if ( IDOK == dlg.DoModal() )
{
CString sScr;
if (dlg.GetCrossSectionScr(sScr))
{
if (sScr.Find(_T("RECT:")) == -1)
{
AfxMessageBox(_T("选择的是脚本不是标准舱室管廊截面!"));
return;
}
m_sCrossSectionScr = sScr;
AcGePoint2d pt2d;
ExtractTopAndBomAdd(pt2d);
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);
AcGePoint2dArray arDatas;
worm.ExtractEarthWormScr(arDatas);
if (arDatas.length() > 0)
{
m_dInterH = 1000.0 * arDatas.first().y;
m_dOutT = 1000.0 * arDatas.last().x;
m_dIntT = 1000.0 * arDatas.last().y;
m_dt5 = m_dOutT + pt2d.x;
m_dt4 = m_dOutT + pt2d.y;
m_dh0 = AS_M2MM(worm.GetLeftRoomHeight());
m_dh1 = AS_M2MM(worm.GetRightRoomHeight());
UpdateData(FALSE);
}
//解析EXT设置key
ESection eSecType = eRect;
AcGeLineSeg3d ln;
ExtractExtMap(eSecType,ln);
ShowEarthWorm();
UpdateWindow();
}
}
}
void CHZGLDlg::OnBnClickedBtmodiroom2()
{
UpdateData();
int nRoomIndex = GetIdxOfRoom();
if (nRoomIndex != -1)
{
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);//last
worm.SetChamferInter(m_dChamferInter);
ESection eType = eRect;
AcGePoint2dArray arDatas;
eType = worm.ExtractEarthWormScr(arDatas);
if (arDatas.length() == 2) return;
arDatas.removeAt( nRoomIndex );
//修改全部高度,合成文本
CString sCrossSectionScr = _T("RECT:");
CString sTemp;
for (int i = 0; i < arDatas.length(); i++)
{
if (i < arDatas.length() - 1)
sTemp.Format(_T("%gx%g"), arDatas.at(i).x, arDatas.at(i).y);
else
sTemp.Format(_T("%gx%g"),AS_MUNIT(m_dOutT),AS_MUNIT(m_dIntT));
sCrossSectionScr += sTemp;
if (i < arDatas.length() - 1)
sCrossSectionScr += _T("|");
}
CString sExt = _T("EXT:"),sKey,sExtVal;
if (m_dt5 > m_dOutT)
{
double dAdd = m_dt5 - m_dOutT;
if (dAdd > 1.e-2)
{
sExtVal.Format(_T("<%s:%g|%g>"),EW_BOMANDCHM,AS_MUNIT(dAdd),AS_MUNIT(m_dChamferInter));
m_mapAddtion.SetAt(EW_BOMANDCHM,sExtVal);
}
}
//EW_LRROOMADD
m_mapAddtion.RemoveKey(EW_LRROOMADD);
if (m_dLRAddThick > 1.e-2)
{
sExtVal.Format(_T("<%s:%g|%d>"),EW_LRROOMADD,m_dLRAddThick,m_nLRAddThick);
m_mapAddtion.SetAt(EW_LRROOMADD,sExtVal);
}
CString sValRem;
for (POSITION ps = m_mapAddtion.GetStartPosition();ps != NULL;)
{
m_mapAddtion.GetNextAssoc(ps,sKey,sExtVal);
//可能的删除舱室的附件也删除
//<HOLDER:房间|
sValRem.Format(_T("%s:%d"),EW_HOLDER,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<BOSS:房间
sValRem.Format(_T("%s:%d"),EW_BOSS,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<HANGER:房间
sValRem.Format(_T("%s:%d"),EW_HANGER,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<RINGS:房间
sValRem.Format(_T("%s:%d"),EW_RINGS,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<LAMPS:房间
sValRem.Format(_T("%s:%d"),EW_LAMPS,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<FIREET:房间
sValRem.Format(_T("%s:%d"),EW_FIREET,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<FIREDOOR:房间
sValRem.Format(_T("%s:%d"),EW_FIREDOOR,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<SECURITY:房间
sValRem.Format(_T("%s:%d"),EW_SECURITY,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<GASALARM:房间
sValRem.Format(_T("%s:%d"),EW_GASALARM,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<DRAFAN:房间
sValRem.Format(_T("%s:%d"),EW_DRAFAN,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<SMOKALARM:房间
sValRem.Format(_T("%s:%d"),EW_SMOKALARM,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<TEMPALARM:房间
sValRem.Format(_T("%s:%d"),EW_TEMPALARM,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<EW_COALARM:房间
sValRem.Format(_T("%s:%d"),EW_COALARM,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
//<EW_OXALARM:房间
sValRem.Format(_T("%s:%d"),EW_OXALARM,nRoomIndex);
if (sExtVal.Find(sValRem) != -1)
{
continue;
}
sExt += sExtVal;
}
m_sCrossSectionScr = sCrossSectionScr;
m_sCrossSectionScr.TrimLeft(_T('|'));
m_sCrossSectionScr += _T('|');
if (sExt.CompareNoCase(_T("EXT:")) != 0)
{
m_sCrossSectionScr += sExt;
}
ShowEarthWorm();
}
}
void CHZGLDlg::OnEnChangeEdith()
{
// 先更新一下 m_pRectCell
int idx(GetIdxOfRoom());
SelectRoom(idx < 0 ? 0 : idx);
OnBnClickedBtmodiroom();
}
void CHZGLDlg::OnEnChangeEditt1()
{
//m_dt4 = m_dOutT;
//UpdateData(FALSE);
// 先更新一下 m_pRectCell
int idx(GetIdxOfRoom());
SelectRoom(idx < 0 ? 0 : idx);
OnBnClickedBtmodiroom();
}
void CHZGLDlg::OnEnChangeEditt2()
{
// 先更新一下 m_pRectCell
int idx(GetIdxOfRoom());
SelectRoom(idx < 0 ? 0 : idx);
OnBnClickedBtmodiroom();
}
void CHZGLDlg::OnEnChangeEditcharm()
{
// 先更新一下 m_pRectCell
int idx(GetIdxOfRoom());
SelectRoom(idx < 0 ? 0 : idx);
OnBnClickedBtmodiroom();
}
void CHZGLDlg::OnEnKillfocusEditt4()
{
double dDt5 = m_dt5;
UpdateData();
if (m_dt5 - m_dt4 < -1.e-6 || m_dt5 - m_dOutT < -1.e-6)
{
AfxMessageBox(_T("底部壁厚不能小于顶部壁厚和两侧壁厚!"));
m_dt5 = dDt5;
UpdateData(FALSE);
return;
}
// 先更新一下 m_pRectCell
int idx(GetIdxOfRoom());
SelectRoom(idx < 0 ? 0 : idx);
OnBnClickedBtmodiroom();
}
void CHZGLDlg::OnEnKillfocusEditt3()
{
double dDt4 = m_dt4;
UpdateData();
if (m_dt5 - m_dt4 < -1.e-10)
{
AfxMessageBox(_T("顶部壁厚不能大于底部壁厚!"));
m_dt4 = dDt4;
UpdateData(FALSE);
return;
}
// 先更新一下 m_pRectCell
int idx(GetIdxOfRoom());
SelectRoom(idx < 0 ? 0 : idx);
OnBnClickedBtmodiroom();
}
void CHZGLDlg::OnCbnSelchangeCombo4()
{
int nSel = m_wndCombo4.GetCurSel();
if (nSel != -1)
{
m_wndCombo4.GetLBText(nSel,m_sRoomName);
UpdateData(FALSE);
}
OnBnClickedBtmodiroom();
}
void CHZGLDlg::OnEnKillfocusEditroomw()
{
// 先更新一下 m_pRectCell
SelectRoom(GetIdxOfRoom());
OnBnClickedBtmodiroom();
}
void CHZGLDlg::ReloadGLBJ(AecDbObjXDataMap* pXDataMap)
{
AecDbObjXDataMap rcXDataMap;
if (pXDataMap->GetAt(_T("CGLBJDlg"),0,rcXDataMap ))
{
m_pGLBJXDataMap = pXDataMap;
CGLBJDlg dlg;
dlg.m_bIsAddRec = true;
dlg.SetCrossSectionScr(m_sCrossSectionScr,m_dYXLen);
dlg.SetReloadGLBJ(m_pGLBJXDataMap);
dlg.ReloadFromXDataMap();
{
//合成AecX3DSolid 集合,加入FIT
DELETE_PTR(m_pGroupBJ);
AcGePoint3d ptOrg(0,0,0);
ptOrg.y += 0.5 * m_dYXLen;
dlg.GetX3dSolidRecs(m_pGroupBJ,ptOrg,-AcGeVector3d::kYAxis);
}
}
}
void CHZGLDlg::ReloadBZJC(AecDbObjXDataMap* pXDataMap)
{
AecDbObjXDataMap rcXDataMap;
if (pXDataMap->GetAt(_T("CTJBZJCDlg"),0,rcXDataMap) )
{
m_pGLBZJCDataMap = pXDataMap;
CTJBZJCDlg dlg;
dlg.SetCrossSectionScr(m_sCrossSectionScr,m_dYXLen);
dlg.SetReloadTJBZJC(m_pGLBZJCDataMap);
dlg.ReloadFromXDataMap();
{
//合成AecX3DSolid 集合,加入FIT
DELETE_PTR(m_pGroupRB);
dlg.GetX3dSolidRecsForYGL(m_pGroupRB);
}
}
}
//舱室变径
void CHZGLDlg::OnBnClickedButton1()
{
UpdateData();
CGLBJDlg dlg;
dlg.m_bIsAddRec = true;
dlg.SetCrossSectionScr(m_sCrossSectionScr,m_dYXLen);
dlg.SetReloadGLBJ(m_pGLBJXDataMap);
int nRes = dlg.DoModal();
if (nRes == IDOK)
{
//合成AecX3DSolid 集合,加入FIT
DELETE_PTR(m_pGroupBJ);
AcGePoint3d ptOrg(0,0,0);
ptOrg.y += 0.5 * m_dYXLen;
dlg.GetX3dSolidRecs(m_pGroupBJ,ptOrg,-AcGeVector3d::kYAxis);
}
}
void CHZGLDlg::OnBnClickedButton4()
{
UpdateData();
CTJBZJCDlg dlg;
dlg.SetCrossSectionScr(m_sCrossSectionScr,m_dYXLen);
int nRes = dlg.DoModal();
if (nRes == IDOK)
{
//合成AecX3DSolid 集合,加入FIT
DELETE_PTR(m_pGroupRB);
dlg.GetX3dSolidRecsForYGL(m_pGroupRB);
}
}
int CHZGLDlg::GetX3dSolidRecsRB(AecDbX3dGroup*& pGroup)
{
pGroup = m_pGroupRB;
return m_pGroupRB != NULL ? TRUE : FALSE;
}
int CHZGLDlg::GetX3dSolidRecs(AecDbX3dGroup*& pGroup)
{
if (pGroup != NULL)
{
AcArray<X3dSolidRec> arRecs;
if (m_pGroupBJ != NULL)
{
m_pGroupBJ->GetX3dSolidRecs(arRecs);
for (int i = 0;i < arRecs.length();i++)
{
X3dSolidRec& rc = arRecs.at(i);
pGroup->AddX3dSolidRec(rc);
}
//变径记录
for (int i = 0;i < 10;i++)
{
AecDbObjXDataMap rcXDataMap;
if (m_pGroupBJ->GetSpecialtyData()->GetAt(_T("CGLBJDlg"),i,rcXDataMap))
{
pGroup->GetSpecialtyData()->SetAt(_T("CGLBJDlg"),i,rcXDataMap);
}
else
{
pGroup->GetSpecialtyData()->RemoveAt(_T("CGLBJDlg"),i);
}
}
}
//倒虹
if (m_pGroupRB != NULL)
{
arRecs.removeAll();
m_pGroupRB->GetX3dSolidRecs(arRecs);
for (int i = 0;i < arRecs.length();i++)
{
X3dSolidRec& rc = arRecs.at(i);
pGroup->AddX3dSolidRec(rc);
}
AecDbObjXDataMap rcXDataMap;
if (m_pGroupRB->GetSpecialtyData()->GetAt(_T("CTJBZJCDlg"),0,rcXDataMap))
{
pGroup->GetSpecialtyData()->SetAt(_T("CTJBZJCDlg"),0,rcXDataMap);
}
}
if (pGroup != NULL || m_pGroupRB != NULL)
{
return TRUE;
}
}
return FALSE;
}
void CHZGLDlg::GetRoomNames(CStringArray& arRoomNames)
{
AecDbEarthWorm ew;
ew.SetCrossSectionScr(m_sCrossSectionScr);
CString sKey,sName;
for (int i = 0;i < ew.GetRoomCount();i++)
{
sKey.Format(_T("%d"),i);
if (m_mapIndexToName.Lookup(sKey,sName))
{
if ( !RoomHasSplitRoom(i))
{
arRoomNames.Add(sName);
}
}
else
{
break;
}
}
//ROOMNAME: 房间|中心x|中心y|名称 -->x,y放大100倍
//<ROOMNAME:%d|%d|%d|%s>
int nPos = -1;
CString sVal;
for (POSITION ps = m_mapAddtion.GetStartPosition();ps != NULL;)
{
m_mapAddtion.GetNextAssoc(ps,sKey,sVal);
if (sVal.Find(EW_ROOMNAME) != -1)
{
nPos = sVal.ReverseFind(_T('|'));
if (nPos != -1 && nPos < sVal.GetLength() - 1)
{
sName = sVal.Mid(nPos + 1);
arRoomNames.Add(sName);
}
}
}
}
void CHZGLDlg::OnEnChangeEdit24()
{
OnBnClickedBtmodiroom();
}
//自定义属性
void CHZGLDlg::OnBnClickedButton2()
{
CBimInfoDlg::ShowBimInfo(&m_mapSpecXData,_T("管廊"));
}
bool CHZGLDlg::GetOffsetRect(int nRoomIndex,CString& sOffsets)
{
if (nRoomIndex != -1)
{
ERoom room;
AecDbEarthWorm ew;
ew.SetCrossSectionScr(m_sCrossSectionScr);
ew.GetRoom(nRoomIndex,room);
if (m_pRectCell != NULL)
{
AcGePoint2d pt[4];
m_pRectCell->getPointAt(0,pt[0]);
m_pRectCell->getPointAt(1,pt[1]);
m_pRectCell->getPointAt(2,pt[2]);
m_pRectCell->getPointAt(3,pt[3]);
sOffsets = _T("(");
CString sText;
for(int i = 0;i < 4;i++)
{
sText.Format(_T("%.3f,%.3f,"),pt[i].x - room.ptGe[i].x,pt[i].y - room.ptGe[i].y);
sOffsets += sText;
}
sOffsets.TrimRight(_T(','));
sOffsets += _T(")");
return true;
}
}
return false;
}
//添加支架
void CHZGLDlg::OnBnClickedBtaddroom2()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
CString sKey, sName;
sKey.Format(_T("%d"), nIndex);
m_mapIndexToName.Lookup(sKey, sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex, sOffsets);
CStringArray arRooms;
GetRoomNames(arRooms);
CGLFJDlg dlg1(PIPECABLE::eHOLDER, nIndex, m_sCrossSectionScr, sOffsets, m_mapAddtion, arRooms);
dlg1.DoModal();
}
// 无论成功与否,都刷新
OnBnClickedBtmodiroom();
// CTJZJDlg dlg;
// dlg.m_data.m_sSpec = sName;
// if ( IDOK == dlg.DoModal() )
// {
// CString sHolder;
// int nPos = dlg.GetScript(sHolder,nIndex,sOffsets);
// CString sKey;
// sKey.Format(_T("%d-%d-%d-HOLDER"),nIndex,nPos,dlg.m_data.m_nNo);
// if (dlg.m_bRemove)
// {
// removeAddin(dlg.m_data.m_nNo, _T("HOLDER"), m_mapAddtion);
// }
// else
// {
// if (!hasAddin(dlg.m_data.m_nNo, _T("HOLDER"), m_mapAddtion))
// m_mapAddtion.SetAt(sKey,sHolder);
// else
// {
// CString str(_T(""));
// str.Format(_T("编号:%d已经存在!"), dlg.m_data.m_nNo);
// AfxMessageBox(str);
// }
// }
// OnBnClickedBtmodiroom();
// }
//}
//else
//{
// AfxMessageBox(_T("请选择管廊舱室添加支架!"));
//}
}
//添加吊架
void CHZGLDlg::OnBnClickedBtaddroom3()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
CString sKey, sName;
sKey.Format(_T("%d"), GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey, sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex, sOffsets);
CStringArray arRooms;
GetRoomNames(arRooms);
CGLFJDlg dlg1(PIPECABLE::eHANGER, nIndex, m_sCrossSectionScr, sOffsets, m_mapAddtion, arRooms);
dlg1.DoModal();
}
OnBnClickedBtmodiroom();
// CTJDJDlg dlg;
// dlg.m_data.m_sSpec = sName;
// if ( IDOK == dlg.DoModal() )
// {
// CString sHolder;
// int nPos = dlg.GetScript(sHolder,nIndex,sOffsets);
// CString sKey;
// sKey.Format(_T("%d-%d-%d-HANGER"),nIndex,nPos, dlg.m_data.m_nNo);
// if (dlg.m_bRemove)
// {
// removeAddin(dlg.m_data.m_nNo, _T("HANGER"), m_mapAddtion);
// }
// else
// {
// if (!hasAddin(dlg.m_data.m_nNo, _T("HANGER"), m_mapAddtion))
// m_mapAddtion.SetAt(sKey,sHolder);
// else
// {
// CString str(_T(""));
// str.Format(_T("编号:%d已经存在!"), dlg.m_data.m_nNo);
// AfxMessageBox(str);
// }
// }
// OnBnClickedBtmodiroom();
// }
//}
//else
//{
// AfxMessageBox(_T("请选择管廊舱室添加吊架!"));
//}
}
//预留管位
void CHZGLDlg::OnBnClickedBtaddroom4()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
CString sKey,sName;
sKey.Format(_T("%d"),GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey,sName);
//预留官位只能放在主舱!!!!
//计算可能分舱的四个方向的偏移量
CString sOffsets = _T("");
GetOffsetRect(nIndex,sOffsets);
CFZGWDlg dlg;
dlg.m_data.m_sSpec = sName;
if ( IDOK == dlg.DoModal() )
{
CString sBoss;
CString sPos = dlg.GetScript(sBoss,nIndex,sOffsets);
CString sKey;
sKey.Format(_T("%d-%s-BOSS"), nIndex, sPos);
if (dlg.m_bRemove)
{
m_mapAddtion.RemoveKey(sKey);
}
else
{
if (!m_mapAddtion.Lookup(sKey, sBoss))
m_mapAddtion.SetAt(sKey, sBoss);
else
{
CString str(_T(""));
str.Format(_T("管位编号:%s已经存在!"), sPos);
AfxMessageBox(str);
}
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室预留管位!"));
}
}
//添加吊环
void CHZGLDlg::OnBnClickedBtaddroom5()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
CString sKey,sName;
sKey.Format(_T("%d"),GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey,sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex,sOffsets);
CTJDHDlg dlg;
if ( IDOK == dlg.DoModal() )
{
CString sRings;
int nPos = dlg.GetScript(sRings,nIndex,sOffsets);
CString sKey;
sKey.Format(_T("%d-%d-%d-RINGS"),nIndex,nPos, dlg.m_nNo);
if (dlg.m_bRemove)
{
removeAddin(dlg.m_nNo, _T("RINGS"), m_mapAddtion);
}
else
{
if (!hasAddin(dlg.m_nNo, _T("RINGS"), m_mapAddtion))
m_mapAddtion.SetAt(sKey, sRings);
else
{
CString str(_T(""));
str.Format(_T("编号:%d已经存在!"), dlg.m_nNo);
AfxMessageBox(str);
}
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室添加吊环!"));
}
}
//添加灯具
void CHZGLDlg::OnBnClickedBtaddroom6()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
CString sKey,sName;
sKey.Format(_T("%d"),GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey,sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex,sOffsets);
CTJDUDlg dlg;
if ( IDOK == dlg.DoModal() )
{
CString sLamps;
int nPos = dlg.GetScript(sLamps, nIndex,sOffsets);
CString sKey;
sKey.Format(_T("%d-%d-%d-LAMPS"),nIndex,nPos, dlg.m_nNo);
if (dlg.m_bRemove)
{
removeAddin(dlg.m_nNo, _T("LAMPS"), m_mapAddtion);
}
else
{
if (!hasAddin(dlg.m_nNo, _T("LAMPS"), m_mapAddtion))
m_mapAddtion.SetAt(sKey, sLamps);
else
{
CString str(_T(""));
str.Format(_T("编号:%d已经存在!"), dlg.m_nNo);
AfxMessageBox(str);
}
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室添加灯具!"));
}
}
//添加排风
void CHZGLDlg::OnBnClickedBtaddroom7()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
//DRAFAN:房间|外径|长度|吊高|间距|风量|功率|机号|名称|型号|厂家
CString sKey, sName;
sKey.Format(_T("%d"), GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey, sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex,sOffsets);
CSDFJDlg dlg;
if (IDOK == dlg.DoModal())
{
CString sScript;
int nPos = dlg.GetScript(sScript, nIndex,sOffsets);
CString sKey;
sKey.Format(_T("%d-%d-%d-DRAFAN"), nIndex, nPos, dlg.m_nNo);
if (dlg.m_bRemove)
{
removeAddin(dlg.m_nNo, _T("DRAFAN"), m_mapAddtion);
}
else
{
if (!hasAddin(dlg.m_nNo, _T("DRAFAN"), m_mapAddtion))
m_mapAddtion.SetAt(sKey, sScript);
else
{
CString str(_T(""));
str.Format(_T("编号:%d已经存在!"), dlg.m_nNo);
AfxMessageBox(str);
}
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室添加风机!"));
}
}
//添加灭火器
void CHZGLDlg::OnBnClickedBtaddroom9()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
CString sKey, sName;
sKey.Format(_T("%d"), GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey, sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex,sOffsets);
CMHQDlg dlg;
if (IDOK == dlg.DoModal())
{
CString sFireet;
int nPos = dlg.GetScript(sFireet, nIndex,sOffsets);
CString sKey;
sKey.Format(_T("%d-1%d%d-%d-FIREET"), nIndex, dlg.m_nSetup, dlg.m_nHSetup, dlg.m_nNo);
if (dlg.m_bRemove)
{
removeAddin(dlg.m_nNo, _T("FIREET"), m_mapAddtion);
}
else
{
if (!hasAddin(dlg.m_nNo, _T("FIREET"), m_mapAddtion))
m_mapAddtion.SetAt(sKey, sFireet);
else
{
CString str(_T(""));
str.Format(_T("编号:%d已经存在!"), dlg.m_nNo);
AfxMessageBox(str);
}
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室添加灭火器!"));
}
}
//添加防火门
void CHZGLDlg::OnBnClickedBtaddroom8()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
//FIREDOOR:房间|宽|高|型号|厂家
CString sKey, sName;
sKey.Format(_T("%d"), GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey, sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex,sOffsets);
CFMHDlg dlg;
if (IDOK == dlg.DoModal())
{
CString sFireet;
int nPos = dlg.GetScript(sFireet, nIndex,sOffsets);
CString sKey;
sKey.Format(_T("%d-%d-%d-FIREDOOR"), nIndex, nPos, dlg.m_nNo);
if (dlg.m_bRemove)
{
removeAddin(dlg.m_nNo, _T("FIREDOOR"), m_mapAddtion);
}
else
{
if (!hasAddin(dlg.m_nNo, _T("FIREDOOR"), m_mapAddtion))
m_mapAddtion.SetAt(sKey, sFireet);
else
{
CString str(_T(""));
str.Format(_T("编号:%d已经存在!"), dlg.m_nNo);
AfxMessageBox(str);
}
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室添加防火门!"));
}
}
//添加监控
void CHZGLDlg::OnBnClickedBtaddroom10()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
//FIREDOOR:房间|宽|高|型号|厂家
CString sKey, sName;
sKey.Format(_T("%d"), GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey, sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex,sOffsets);
CJKSBDlg dlg;
if (IDOK == dlg.DoModal())
{
CString sSecurity;
int nPos = dlg.GetScript(sSecurity, nIndex,sOffsets);
CString sKey;
sKey.Format(_T("%d-%d-%d-SECURITY"), nIndex, nPos, dlg.m_nNo);
if (dlg.m_bRemove)
{
removeAddin(dlg.m_nNo, _T("SECURITY"), m_mapAddtion);
}
else
{
if (!hasAddin(dlg.m_nNo, _T("SECURITY"), m_mapAddtion))
m_mapAddtion.SetAt(sKey, sSecurity);
else
{
CString str(_T(""));
str.Format(_T("编号:%d已经存在!"), dlg.m_nNo);
AfxMessageBox(str);
}
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室添加监控!"));
}
}
//排水沟
void CHZGLDlg::OnBnClickedBtaddroom11()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
CString sKey, sName;
sKey.Format(_T("%d"), GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey, sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex, sOffsets);
//排水沟一律在底部
CJPSGDlg gDlg;
if (IDOK == gDlg.DoModal())
{
CString sWater;
int nPos = gDlg.GetScript(sWater, nIndex);
CString sKey;
sKey.Format(_T("%d-%d-GUTTERWAY"), 0, 0);
if (gDlg.m_bRemove)
{
m_mapAddtion.RemoveKey(sKey);
}
else
{
m_mapAddtion.SetAt(sKey, sWater);
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室添加排水沟!"));
}
}
//瓦斯报警器
void CHZGLDlg::OnBnClickedButton6()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
//GASALARM:房间|位置|高度|长|宽|厚|间距|名称|等级|型号|厂家
CString sKey, sName;
sKey.Format(_T("%d"), GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey, sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex,sOffsets);
CWSJCDlg dlg;
if (IDOK == dlg.DoModal())
{
CString sScript;
int nPos = dlg.GetScript(sScript, nIndex,sOffsets);
CString sKey;
sKey.Format(_T("%d-%d-%d-GASALARM"), nIndex, nPos, dlg.m_nNo);
if (dlg.m_bRemove)
{
removeAddin(dlg.m_nNo, _T("GASALARM"), m_mapAddtion);
}
else
{
if (!hasAddin(dlg.m_nNo, _T("GASALARM"), m_mapAddtion))
m_mapAddtion.SetAt(sKey, sScript);
else
{
CString str(_T(""));
str.Format(_T("编号:%d已经存在!"), dlg.m_nNo);
AfxMessageBox(str);
}
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室添加瓦斯报警器!"));
}
}
//烟雾报警器
void CHZGLDlg::OnBnClickedButton17()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
//SMOKALARM:房间|位置|高度|长|宽|厚|间距|名称|等级|型号|厂家
CString sKey, sName;
sKey.Format(_T("%d"), GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey, sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex,sOffsets);
CYWBJDlg dlg;
if (IDOK == dlg.DoModal())
{
CString sScript;
int nPos = dlg.GetScript(sScript, nIndex,sOffsets);
CString sKey;
sKey.Format(_T("%d-%d-%d-SMOKALARM"), nIndex, nPos, dlg.m_nNo);
if (dlg.m_bRemove)
{
removeAddin(dlg.m_nNo, _T("SMOKALARM"), m_mapAddtion);
}
else
{
if (!hasAddin(dlg.m_nNo, _T("SMOKALARM"), m_mapAddtion))
m_mapAddtion.SetAt(sKey, sScript);
else
{
CString str(_T(""));
str.Format(_T("编号:%d已经存在!"), dlg.m_nNo);
AfxMessageBox(str);
}
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室添加烟雾报警器!"));
}
}
//温度报警器
void CHZGLDlg::OnBnClickedButton56()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
//TEMPALARM:房间|左右侧|位置|间距|宽度|高度|厚度|名称|编号|规格|厂家|偏移
CString sKey, sName;
sKey.Format(_T("%d"), GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey, sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex,sOffsets);
CWDBJDlg dlg;
if (IDOK == dlg.DoModal())
{
CString sScript;
int nPos = dlg.GetScript(sScript, nIndex,sOffsets);
CString sKey;
sKey.Format(_T("%d-%d-%d-TEMPALARM"), nIndex, nPos, dlg.m_nNo);
if (dlg.m_bRemove)
{
removeAddin(dlg.m_nNo, _T("TEMPALARM"), m_mapAddtion);
}
else
{
if (!hasAddin(dlg.m_nNo, _T("TEMPALARM"), m_mapAddtion))
m_mapAddtion.SetAt(sKey, sScript);
else
{
CString str(_T(""));
str.Format(_T("编号:%d已经存在!"), dlg.m_nNo);
AfxMessageBox(str);
}
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室添加温度湿度报警器!"));
}
}
//CO探测器
void CHZGLDlg::OnBnClickedButton11()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
//COALARM:房间|左右侧|位置|间距|宽度|高度|厚度|名称|浓度|偏移
CString sKey, sName;
sKey.Format(_T("%d"), GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey, sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex,sOffsets);
CYYHTDlg dlg;
if (IDOK == dlg.DoModal())
{
CString sScript;
int nPos = dlg.GetScript(sScript, nIndex,sOffsets);
CString sKey;
sKey.Format(_T("%d-%d-%d-COALARM"), nIndex, nPos, dlg.m_nNo);
if (dlg.m_bRemove)
{
removeAddin(dlg.m_nNo, _T("COALARM"), m_mapAddtion);
}
else
{
if (!hasAddin(dlg.m_nNo, _T("COALARM"), m_mapAddtion))
m_mapAddtion.SetAt(sKey, sScript);
else
{
CString str(_T(""));
str.Format(_T("编号:%d已经存在!"), dlg.m_nNo);
AfxMessageBox(str);
}
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室添加温度湿度报警器!"));
}
}
//氧气探测器
void CHZGLDlg::OnBnClickedButton19()
{
int nIndex = GetIdxOfRoom();
if (nIndex != -1)
{
//OXALARM:房间|左右侧|位置|间距|宽度|高度|厚度|名称|采样方式|测量精度|厂家|偏移
CString sKey, sName;
sKey.Format(_T("%d"), GetIdxOfRoom());
m_mapIndexToName.Lookup(sKey, sName);
//计算可能分舱的四个方向的偏移量
CString sOffsets;
GetOffsetRect(nIndex,sOffsets);
CYQTCDlg dlg;
if (IDOK == dlg.DoModal())
{
CString sScript;
int nPos = dlg.GetScript(sScript, nIndex,sOffsets);
CString sKey;
sKey.Format(_T("%d-%d-%d-OXALARM"), nIndex, nPos, dlg.m_nNo);
if (dlg.m_bRemove)
{
removeAddin(dlg.m_nNo, _T("OXALARM"), m_mapAddtion);
}
else
{
if (!hasAddin(dlg.m_nNo, _T("OXALARM"), m_mapAddtion))
m_mapAddtion.SetAt(sKey, sScript);
else
{
CString str(_T(""));
str.Format(_T("编号:%d已经存在!"), dlg.m_nNo);
AfxMessageBox(str);
}
}
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("请选择管廊舱室添加温度湿度报警器!"));
}
}
//分舱
void CHZGLDlg::OnBnClickedButton5()
{
int nIndex = GetIdxOfRoom();
if (nIndex == -1)
{
AfxMessageBox(_T("请选择管廊舱室添加分舱!"));
return;
}
if (m_pRectCell != NULL)
{
AcDbExtents ext;
m_pRectCell->getGeomExtents(ext);
//主舱位置
int nRoomIndex = GetIdxOfRoom();
if (nRoomIndex != -1)
{
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);//last
worm.SetChamferInter(m_dChamferInter);
ERoom room;
worm.GetRoom(nRoomIndex, room);
double dW = ext.maxPoint().x - ext.minPoint().x;
double dH = ext.maxPoint().y - ext.minPoint().y;
AcGePoint2d ptOff;
ptOff.set(ext.minPoint().x - room.ptGe[0].x,ext.minPoint().y - room.ptGe[0].y);
CString sOffset;
GetOffsetRect(nRoomIndex,sOffset);
if (dW - 1.0 > 1.e-6 && dH - 1.0 > 1.e-6)
{
CCSFCDlg dlg;
dlg.SetRoomSize(dW,dH);
dlg.SetOffset(ptOff);
if (IDOK == dlg.DoModal() )
{
CString sKey,sVal;
CString sScript;
int nPos = dlg.GetScript(sScript, nRoomIndex);
sKey.Format(_T("%d-%d-ROOMSLAB"), nRoomIndex, nPos);
if (dlg.m_bRemove)
{
CString key1, key2;
if (findKeysBySlab(m_mapAddtion, room, m_mapAddtion[sKey], key1, key2))
{
m_mapAddtion.RemoveKey(key1);
m_mapAddtion.RemoveKey(key2);
}
m_mapAddtion.RemoveKey(sKey);
//SelectRoom(nRoomIndex);
}
else
{
CString sVal;
if (m_mapAddtion.Lookup(sKey,sVal))
{
CString sTip;
sTip.Format(_T("编号为 %d 的分舱已经存在!是否替换?"), nPos);
int nRes = AfxMessageBox(sTip,MB_YESNO);
if (nRes == IDYES)
{
m_mapAddtion.SetAt(sKey, sScript);
//分舱后原来的舱名称去掉
}
}
else
{
m_mapAddtion.SetAt(sKey, sScript);
//分舱后原来的舱名称去掉
}
}
SelectRoom(nRoomIndex);
OnBnClickedBtmodiroom();
}
}
else
{
AfxMessageBox(_T("选择的舱室单元空间太小!不能分舱!"));
}
}
}
}
//横断出图
extern BOOL OutDrawing(LPCTSTR pszDrawFileSub, AcDbVoidPtrArray& arEntPtrs, const AcGeVector3d& vtDir, bool bIsShowEntPtrs,bool bAddToModelSpace, bool hasDim = true);
void CHZGLDlg::OnBnClickedButton3()
{
EnableWindow(FALSE);
CWnd* pFrame = acedGetAcadFrame();
pFrame->EnableWindow(TRUE);
ShowWindow(SW_HIDE);
pFrame->SetFocus();
AcDbVoidPtrArray arDrawffer;
GetDrawBuffer(arDrawffer);
AcAxDocLock lock;
/*AcDbObjectId id;
AcDbEntity* pEnt = NULL;
for (int i = 0;i < arDrawffer.length();i++)
{
pEnt = (AcDbEntity*)arDrawffer.at(i);
AddToModelSpace(pEnt,id,NULL,true);
}*/
bool bAddToModelSpace = false;
int nRelt = 0;
int nRes = acedGetInt(_T("\n请选择断面出图空间[布局空间(0)/模型空间(1)]<布局空间>:"),&nRelt);
if (nRes == RTCAN )
{
pFrame->EnableWindow(FALSE);
EndDialog(IDCANCLE);
return;
}
if (nRelt == 1)
bAddToModelSpace = true;
OutDrawing(LAYOUTNAME_HD, arDrawffer, AcGeVector3d::kXAxis, true,bAddToModelSpace);
pFrame->EnableWindow(FALSE);
EndDialog(IDCANCLE);
}
namespace
{
void getAddinKeys(const CMapStringToString &addinMap
, std::vector<CString> &addins
, std::vector<CString> &slabs)
{
CString sKey(_T("")), sVal(_T(""));
POSITION pos(addinMap.GetStartPosition());
while (pos)
{
addinMap.GetNextAssoc(pos, sKey, sVal);
if (sKey.Find(EW_HOLDER) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_HANGER) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_BOSS) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_RINGS) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_LAMPS) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_FIREET) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_GUTTERWAY) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_FIREDOOR) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_SECURITY) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_DRAFAN) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_GASALARM) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_TEMPALARM) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_COALARM) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_OXALARM) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_SMOKALARM) != -1)
addins.push_back(sKey);
else if (sKey.Find(EW_ROOMSLAB) != -1)
slabs.push_back(sKey);
else if (sKey.Find(EW_ROOMNAME) != -1)
slabs.push_back(sKey);
else if (sKey.Find(EW_CHARMNO) != -1)
addins.push_back(sKey);
else
continue;
}
}
}
void CHZGLDlg::OnBnClickedBtmodiroom3()
{
CHZGL_SCFJDlg dlg;
if (dlg.DoModal() != IDOK) return;
CString str = m_sCrossSectionScr;
if (str.IsEmpty()) return;
std::vector<CString> addins(0), slabs(0);
getAddinKeys(m_mapAddtion, addins, slabs);
if (dlg.m_bDelAddin)
{
for (size_t i = 0; i < addins.size(); ++i)
m_mapAddtion.RemoveKey(addins[i]);
}
if (dlg.m_bDelSlab)
{
for (size_t i = 0; i < slabs.size(); ++i)
m_mapAddtion.RemoveKey(slabs[i]);
}
// 处理一下字符串
int idx = str.Find(_T("|EXT:"));
if (idx == -1) return;
m_sCrossSectionScr = str.Left(idx);
// 将m_mapAddtion的内容加入
CString sExt(_T("|EXT:")), sKey(_T("")), sExtVal(_T(""));
for (POSITION ps = m_mapAddtion.GetStartPosition(); ps != NULL;)
{
m_mapAddtion.GetNextAssoc(ps, sKey, sExtVal);
sExt += sExtVal;
}
if (sExt.CompareNoCase(_T("|EXT:")) != 0)
{
m_sCrossSectionScr += sExt;
}
ShowEarthWorm();
}
void CHZGLDlg::OnBnClickedCheck1()
{
UpdateData();
CString sKey,sScript;
sKey = _T("CHMNO");
sScript.Format(_T("<CHMNO:%d|%d>"),m_bTopNoCharm,m_bBomNoCharm);
if (!m_bBomNoCharm && !m_bTopNoCharm)
{
m_mapAddtion.RemoveKey(sKey);
}
else
{
m_mapAddtion.SetAt(sKey,sScript);
}
OnBnClickedBtmodiroom();
}
void CHZGLDlg::OnBnClickedCheck3()
{
UpdateData();
CString sKey,sScript;
sKey = _T("CHMNO");
sScript.Format(_T("<CHMNO:%d|%d>"),m_bTopNoCharm,m_bBomNoCharm);
if (!m_bBomNoCharm && !m_bTopNoCharm)
{
m_mapAddtion.RemoveKey(sKey);
}
else
{
m_mapAddtion.SetAt(sKey,sScript);
}
OnBnClickedBtmodiroom();
}
void CHZGLDlg::OnEnKillfocusEdith13()
{
OnEnChangeEditt1();
}
void CHZGLDlg::OnEnKillfocusEdith12()
{
OnEnChangeEditt1();
}