#include "stdafx.h" #include "DJPGDlg.h" #include "UITools.h" #include "AecDbShEarthWorm.h" #include "AecDb3dRoadAxisLine.h" #include "CoreTools.h" extern void SplitStrintToArray(LPCTSTR pszDescr,CStringArray& arInfo,TCHAR tcSpace); static const Adesk::UInt16 kColorByBlock = 0; static const Adesk::UInt16 kRed = 1; static const Adesk::UInt16 kYellow = 2; static const Adesk::UInt16 kGreen = 3; static const Adesk::UInt16 kCyan = 4; static const Adesk::UInt16 kBlue = 5; static const Adesk::UInt16 kMagenta = 6; static const Adesk::UInt16 kWhite = 7; static const Adesk::UInt16 kColorByLayer = 256; IMPLEMENT_DYNAMIC(CDJPGDlg, CDialog) CDJPGDlg::CDJPGDlg(CWnd* pParent /*=NULL*/) : CDialog(CDJPGDlg::IDD, pParent) , m_nFloor(1) , m_nCableCount(1) , m_dSpace(10) , m_bDJ(FALSE) , m_iNo(1) { m_nPipeColor = kRed; m_sCurrSys = _T(""); m_sMertial = _T(""); m_dDn = 300.0; m_dt = 14; m_sPipeNo = _T("PIPE-001"); m_dOD = 328.0; m_curSection.pReg = NULL; m_curSection.pt.set(0,0,0); m_sCrossSectionScr = _T(""); m_sAddtionScr = _T(""); m_idxRoom = 0; m_pRegionRoom = NULL; } CDJPGDlg::~CDJPGDlg() { } void CDJPGDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_LIST1, m_wndPipeList); DDX_Control(pDX, IDC_LIST2, m_wndListBoxMaters); DDX_LBString(pDX, IDC_LIST2, m_sMertial); DDX_Control(pDX, IDC_LIST3, m_wndSysListBox); DDX_Text(pDX, IDC_EDIT6, m_sPipeNo); DDX_Text(pDX, IDC_EDIT1, m_nFloor); DDV_MinMaxInt(pDX, m_nFloor, 1, 99); DDX_Text(pDX, IDC_EDIT3, m_nCableCount); DDV_MinMaxInt(pDX, m_nCableCount, 1, 99); DDX_Text(pDX, IDC_EDIT4, m_dSpace); DDV_MinMaxDouble(pDX, m_dSpace, 0, 9999); DDX_Radio(pDX, IDC_RADIO1, m_bDJ); DDX_Text(pDX, IDC_EDIT5, m_iNo); DDV_MinMaxInt(pDX, m_dSpace, 0, 999); } BEGIN_MESSAGE_MAP(CDJPGDlg, CDialog) ON_STN_CLICKED(IDC_STATIC_COLOR, &CDJPGDlg::OnStnClickedStaticColor) ON_WM_CTLCOLOR() ON_MESSAGE(WM_VIEW_LBUTTONDOWN, &CDJPGDlg::OnViewLButtonDown) ON_BN_CLICKED(IDOK, &CDJPGDlg::OnBnClickedOk) END_MESSAGE_MAP() BOOL CDJPGDlg::OnInitDialog() { CDialog::OnInitDialog(); // 子类化控件对象 if (!m_wndViewCtrl.SubclassDlgItem(IDC_STATIC_FRM, this)) { return FALSE; } m_wndPipeList.SetExtendedStyle(LVS_EX_FULLROWSELECT); m_wndPipeList.InsertColumn(0,_T("公称直径"),LVCFMT_LEFT,60); m_wndPipeList.InsertColumn(1,_T("外径"),LVCFMT_LEFT,60); m_wndPipeList.InsertColumn(2,_T("壁厚"),LVCFMT_LEFT,60); m_wndPipeList.InsertColumn(3,_T("线比重"),LVCFMT_LEFT,100); CString path = FilePath::GetSysDir() + Plumbing_DB; if (!m_dbSQLite.InitADOServer(path)) { AfxMessageBox(CString(_T("数据库初始化失败,请检查 sys")) + Plumbing_DB + _T("文件是否存在.")); return FALSE; } InitPipeList(); ShowLastSection(); UpdateData(FALSE); return TRUE; } void CDJPGDlg::ShowLastSection() { //1.截面 CString sFullPath = FilePath::GetSysDir(); sFullPath.MakeLower(); sFullPath += _T("\\DGJM.sat"); AcDbVoidPtrArray arBodyPtrs; if ( Acad::eOk == AcDbBody::acisIn(sFullPath,arBodyPtrs) ) { if (arBodyPtrs.length() > 0) { AcDbEntity* pEnt = (AcDbEntity*)arBodyPtrs.first(); AcDbRegion* pRegion = AcDbRegion::cast(pEnt); if (pRegion != NULL) { m_curSection.pReg = pRegion; } if (m_curSection.pReg != NULL) { ExtractRegionRooms(); ShowEwSection(); } } } //2.壁厚 sFullPath = FilePath::GetSysDir(); sFullPath.MakeLower(); sFullPath += _T("\\DGJM.ext"); CString sLine; CStdioFile file; if (file.Open(sFullPath,CFile::modeRead | CFile::typeText)) { file.ReadString(sLine); file.Close(); sLine.TrimRight(_T('\n')); CStringArray arInf; SplitStrintToArray(sLine,arInf,_T(',')); if (arInf.GetSize() >= 6) { m_curSection.pt.set(_ttof(arInf.GetAt(0)),_ttof(arInf.GetAt(1)),0.0); m_curSection.dThick[0] = _ttof(arInf.GetAt(2)); m_curSection.dThick[1] = _ttof(arInf.GetAt(3)); m_curSection.dThick[2] = _ttof(arInf.GetAt(4)); m_curSection.dThick[3] = _ttof(arInf.GetAt(5)); } } //3.名称 sFullPath = FilePath::GetSysDir(); sFullPath.MakeLower(); sFullPath += _T("\\DGJM.nam"); CString sIndex,sName; AcDbText* pText = NULL; AcGePoint3d ptIns; CStringArray arInf; if (file.Open(sFullPath,CFile::modeRead | CFile::typeText)) { sLine = _T(""); while(file.ReadString(sLine)) { sLine.TrimRight(_T('\n')); arInf.RemoveAll(); SplitStrintToArray(sLine,arInf,_T(',')); if (arInf.GetSize() >= 4) { sIndex = arInf.GetAt(0); sName = arInf.GetAt(1); m_mapIndexToName.SetAt(sIndex,sName); } } file.Close(); } ExtractRegionRooms(); //4.显示附件 sFullPath = FilePath::GetSysDir(); sFullPath.MakeLower(); sFullPath += _T("\\DGJM.adt"); if (file.Open(sFullPath,CFile::modeRead | CFile::typeText)) { sLine = _T(""); file.ReadString(sLine); sLine.TrimRight(_T('\n')); m_sAddtionScr = sLine; m_mapAddtion.RemoveAll(); ExtrAddtionToMap(); file.Close(); } ShowAddtion(); ShowRoomName(); UpdateData(FALSE); UpdateWindow(); } void CDJPGDlg::ExtrAddtionToMap( ) { m_mapAddtion.RemoveAll(); int nPos = m_sAddtionScr.Find(_T("EXT:")); if (nPos != -1) { //EXT: if (nPos + 4 < m_sAddtionScr.GetLength() ) { CString sName; CString sExt = m_sAddtionScr.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_sAddtionScr.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) { // 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_sAddtionScr.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_sAddtionScr.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_sAddtionScr.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_sAddtionScr.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_sAddtionScr.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_sAddtionScr.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_sAddtionScr.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_sAddtionScr.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_sAddtionScr.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_sAddtionScr.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_sAddtionScr.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_sAddtionScr.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(""),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)); sName = arInf.GetAt(3); sKey.Format(_T("%d|%d|%d|ROOMNAME"),nRoomIndex,nCenX,nCenY); sScript2.Format(_T("<%s>"),sScript); m_mapAddtion.SetAt(sKey,sScript2); m_mapIndexToName.SetAt(arInf.GetAt(0),sName); } } else if (sScript.Find(EW_CHARMNO) != -1) { //盾构没有倒角 } nSta += sScript.GetLength(); nPos = sExt.Find(_T('<'),nSta); } } } } LRESULT CDJPGDlg::OnViewLButtonDown(WPARAM wp, LPARAM lp) { //鼠标点击的点 AcGePoint3d* pPt = (AcGePoint3d*)lp; pPt->z = 0.0; if (m_curSection.pReg != NULL) { AcGsView* pView = m_wndViewCtrl.view(); AcGsModel* pModel = m_wndViewCtrl.model(); //判断点落在region内 AcDbExtents ext; AcDbCurve* pPl = NULL; AcDbRegion* pRegion = NULL; AcDbRay rayx1,rayx2; AcDbCurve* pCurve = NULL; AcGePoint3dArray arPts1,arPts2; rayx1.setBasePoint(*pPt); rayx1.setUnitDir(AcGeVector3d::kXAxis); rayx2.setBasePoint(*pPt); rayx2.setUnitDir(-AcGeVector3d::kXAxis); AcDbVoidPtrArray arCurPtrs,arSubEntPtrs; for (int i = 0;i < m_arRegionRooms.length();i++) { pRegion = (AcDbRegion*)m_arRegionRooms.at(i); arCurPtrs.removeAll(); pRegion->explode(arCurPtrs); arSubEntPtrs.removeAll(); pCurve = KTCADUtilityEx::ConvertBoundCurve(arCurPtrs,arSubEntPtrs); pPl = AcDbCurve::cast(pCurve); if (pPl != NULL) { pPl->intersectWith(&rayx1,AcDb::kOnBothOperands,arPts1); pPl->intersectWith(&rayx2,AcDb::kOnBothOperands,arPts2); if (!arPts1.isEmpty() && !arPts2.isEmpty()) { if (pView != NULL && m_pRegionRoom != NULL) { pView->erase(m_pRegionRoom); } m_pRegionRoom = pRegion; m_pRegionRoom->setColorIndex(6); if (pView != NULL) { pView->add(m_pRegionRoom, pModel); } delete pPl; m_wndViewCtrl.view()->invalidate(); m_wndViewCtrl.RedrawWindow(); break; } delete pPl; } } } return 0L; } int CDJPGDlg::GetIdxOfRoom() { if (m_pRegionRoom == NULL) return -1; AcDbRegion* pRegion = NULL; for (int i = 0;i < m_arRegionRooms.length();i++) { pRegion = (AcDbRegion*)m_arRegionRooms.at(i); if (pRegion == m_pRegionRoom) { return i; } } return -1; } void CDJPGDlg::ShowRoomName() { CString sKey,sName; AcDbRegion* pRegion = NULL; AcDbText* pText = NULL; //延着整体圆排序 double perimeter; double area; AcGePoint2d centroid; double momInertia[2]; double prodInertia; double prinMoments[2]; AcGeVector2d prinAxes[2]; double radiiGyration[2]; AcGePoint2d extentsLow; AcGePoint2d extentsHigh; AcGePoint3d ptIns; for (int i = 0;i < m_arRegionRooms.length();i++) { pRegion = (AcDbRegion*)m_arRegionRooms.at(i); pRegion->getAreaProp(AcGePoint3d::kOrigin,AcGeVector3d::kXAxis,AcGeVector3d::kYAxis, perimeter, area, centroid, momInertia, prodInertia, prinMoments, prinAxes, radiiGyration, extentsLow, extentsHigh); sKey.Format(_T("%d"),i); ptIns.set(centroid.x,centroid.y,0.0); if (m_mapIndexToName.Lookup(sKey,sName)) { pText = NULL; if (m_mapIndexToDbText.Lookup(sKey,(void*&)pText)) { pText->setPosition(ptIns); pText->setTextString(sName); } else { ptIns.set(centroid.x,centroid.y,0.0); pText = new AcDbText(ptIns,sName,acdbCurDwg()->textstyle(),0.15,0.0); pText->setHeight(.15); pText->setColorIndex(1); pText->setTextStyle(acdbCurDwg()->textstyle()); pText->setHorizontalMode(AcDb::kTextLeft); m_mapIndexToDbText.SetAt(sKey,pText); } if (pText != NULL) { m_wndViewCtrl.view()->erase(pText); m_wndViewCtrl.Add(pText); if (m_arDrawBuffer.find(pText) == -1) m_arDrawBuffer.append(pText); } } } m_wndViewCtrl.view()->invalidate(); m_wndViewCtrl.Invalidate(); m_wndViewCtrl.RedrawWindow(); } void CDJPGDlg::ExtractRegionRooms() { if (m_curSection.pReg != NULL) { AecDbShEarthWorm::ExtractRegionRooms(m_arRegionRooms,m_curSection.pReg); } } void CDJPGDlg::ShowEwSection() { if (m_curSection.pReg != NULL) { m_arDrawBuffer.removeAll(); m_wndViewCtrl.clearAll(); m_wndViewCtrl.init(true); m_wndViewCtrl.SetOrbitFlag(OBF_PAN | OBF_ZOOM | OBF_COTE); AcDbExtents exts; m_curSection.pReg->getGeomExtents(exts); m_wndViewCtrl.InitFromCurrentView2D(exts,true); m_wndViewCtrl.Add(m_curSection.pReg); m_arDrawBuffer.append(m_curSection.pReg); m_wndViewCtrl.view()->invalidate(); m_wndViewCtrl.Invalidate(); m_wndViewCtrl.RedrawWindow(); } } void CDJPGDlg::FormatAddtionScr() { m_sAddtionScr = _T(""); CString sExt = _T("EXT:"),sKey,sExtVal; for (POSITION ps = m_mapAddtion.GetStartPosition();ps != NULL;) { m_mapAddtion.GetNextAssoc(ps,sKey,sExtVal); sExt += sExtVal; } if (sExt.CompareNoCase(_T("EXT:")) != 0) { m_sAddtionScr += sExt; } } STSection* CDJPGDlg::GetShEwSection() const { if (m_sCrossSectionScr.Find(_T("RECT")) != -1) { return NULL; } AcGePoint3d pt(0,0,0); CString sFullPath = FilePath::GetSysDir(); sFullPath.MakeLower(); sFullPath += _T("\\DGJM.sat"); STSection* pSection = new STSection; pSection->pt = pt; CStdioFile file; if (file.Open(sFullPath,CFile::modeCreate |CFile::modeWrite )) { CString sScr = m_sCrossSectionScr; int nPos = m_sCrossSectionScr.Find(_T("")); nPos = sPt.Find(_T(',')); if (nPos != -1) { CStringArray arInfo; CoreTools::SplitStrintToArray(sPt,arInfo,_T(',')); if (arInfo.GetSize() >= 2) { sX = arInfo.GetAt(0); sY = arInfo.GetAt(1); pSection->pt.set(_ttof(sX),_ttof(sY),0.0); if (arInfo.GetSize() >= 6) { pSection->dThick[0] = _ttof(arInfo.GetAt(2)); pSection->dThick[1] = _ttof(arInfo.GetAt(3)); pSection->dThick[2] = _ttof(arInfo.GetAt(4)); pSection->dThick[3] = _ttof(arInfo.GetAt(5)); } } } } pSection->pReg = NULL; AcDbVoidPtrArray arBodyPtrs; if ( Acad::eOk == AcDbBody::acisIn(sFullPath,arBodyPtrs) ) { if (arBodyPtrs.length() > 0) { AcDbEntity* pEnt = (AcDbEntity*)arBodyPtrs.first(); AcDbRegion* pRegion = AcDbRegion::cast(pEnt); if (pRegion != NULL) { pSection->pReg = pRegion; } } } return pSection; } void CDJPGDlg::ShowAddtion() { //合成脚本 FormatAddtionScr(); if (!m_sAddtionScr.IsEmpty()) { STSection* pSection = GetShEwSection(); if (pSection != NULL) { AecDbShEarthWorm dbEW; AcGePoint3d ptSta(0,0,0); AcGePoint3d ptEnd(10,0,0); AcDbLine ln(ptSta,ptEnd); AecDb3dRoadAxisLine* pRoadLn = new AecDb3dRoadAxisLine; pRoadLn->AppendCurveSeg(&ln); dbEW.GetSpecialtyData()->SetAt(KEY_2DSTYLE, 2); dbEW.SetSection(pSection->pReg, pSection->pt); dbEW.SetBaseCurve(pRoadLn); dbEW.GetSpecialtyData()->SetAt(KEY_ADDTIONSCR,pSection->sAddtionScr); dbEW.GetSpecialtyData()->SetAt(KEY_THICKT1,AS_MUNIT(pSection->dThick[0])); dbEW.GetSpecialtyData()->SetAt(KEY_THICKT2,AS_MUNIT(pSection->dThick[1])); dbEW.GetSpecialtyData()->SetAt(KEY_THICKT4,AS_MUNIT(pSection->dThick[2])); dbEW.GetSpecialtyData()->SetAt(KEY_THICKT5,AS_MUNIT(pSection->dThick[3])); AcDbVoidPtrArray arCurPtrs; dbEW.GetAddtionSection(arCurPtrs); AcGsView* pView = m_wndViewCtrl.view(); AcGsModel* pModel = m_wndViewCtrl.model(); AcDbEntity* pEnt = NULL; for (int i = 0;i < arCurPtrs.length();i++) { pEnt = (AcDbEntity*)arCurPtrs.at(i); pView->add(pEnt, pModel); m_arDrawBuffer.append(pEnt); } m_wndViewCtrl.view()->invalidate(); m_wndViewCtrl.RedrawWindow(); } } } void CDJPGDlg::InitPipeList() { CString sSQL,sText; sSQL = _T("select [公称直径],[外径],[壁厚],[重量] from AecOD order by [公称直径]"); CUIIValueTable table; m_dbSQLite.GetSelData(sSQL,table); table.ShowToListCtrl(&m_wndPipeList); double dT = 0.0; CString sDnold; sDnold.Format(_T("%d"),(int)m_dDn); bool bFind = false; for (int i = 0;i < m_wndPipeList.GetItemCount();i++) { sText = m_wndPipeList.GetItemText(i,0); dT = _ttof(m_wndPipeList.GetItemText(i,2)); if (sText.CompareNoCase(sDnold) == 0 && fabs(m_dt - dT) < 1.e-2) { m_wndPipeList.SetItemState(i,LVIS_SELECTED,LVIS_SELECTED); m_wndPipeList.EnsureVisible(i,TRUE); bFind = true; break; } } if (!bFind) { if (m_wndPipeList.GetItemCount() > 0) m_wndPipeList.SetItemState(0,LVIS_SELECTED,LVIS_SELECTED); } //材质 CStringArray arVals; sSQL = _T("select [材质] from AecMaterial where [类型]='管道'"); m_dbSQLite.GetSelData(sSQL,arVals); int nCursel = 0; for (i = 0;i < arVals.GetSize();i++) { m_wndListBoxMaters.AddString(arVals.GetAt(i)); if (m_sMertial.CompareNoCase(arVals.GetAt(i)) == 0) { nCursel = i; } } m_wndListBoxMaters.SetCurSel(nCursel); //系统 CString sStd,sTemp; sSQL = _T("select tablename from wpipecfg where currstd=1"); m_dbSQLite.GetSelData(sSQL,sStd); sSQL.Format(_T("select distinct system from %s"),sStd); CStringArray arSyses; m_dbSQLite.GetSelData(sSQL,arSyses); nCursel = 0; for (int i = 0;i < arSyses.GetSize();i++) { sTemp = arSyses.GetAt(i); m_wndSysListBox.AddString(sTemp); if (m_sCurrSys.CompareNoCase(sTemp) == 0) { nCursel = i; } } m_wndSysListBox.SetCurSel(nCursel); } void CDJPGDlg::OnStnClickedStaticColor() { acedSetColorDialog(m_nPipeColor, Adesk::kFalse, m_nPipeColor); Invalidate(); } HBRUSH CDJPGDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (nCtlColor == CTLCOLOR_STATIC) { if (pWnd != NULL && pWnd->GetDlgCtrlID() == IDC_STATIC_COLOR) { COLORREF crColor = RGB(255,255,255); if (m_nPipeColor == kColorByLayer) { crColor = RGB(255,255,255); } else { crColor = acedGetRGB(m_nPipeColor); } CRect rc; pWnd->GetClientRect(rc); pDC->FillSolidRect(rc,crColor); } } return hbr; } int CDJPGDlg::GetPipe(AecDbEwPipe*& pPipe) { bool bIsModify = false; if (pPipe == NULL) { pPipe = new AecDbEwPipe; } else { bIsModify = true; } AcGeVector3d vtZ = AcGeVector3d::kXAxis; vtZ.normalize(); AcGePoint3d ptOrg(0,0,0); ptOrg += 40.0 * vtZ; //设置半径和厚度 pPipe->SetSection(AS_MUNIT(m_dDn),0.0);//AS_MUNIT(m_dt) //设置起始点,可以通过官位得到,后期改动 AcGePoint3d ptSta,ptEnd; ptSta = ptOrg - vtZ * 40.0; ptEnd = ptOrg + vtZ * 40.0; if (!bIsModify) { pPipe->SetBaseCurve(ptSta,ptEnd); } //不需要BOOL并到Fit中的标志 pPipe->GetSpecialtyData()->SetAt(_T("COLOR"),m_nPipeColor);//系统默认KEY COLOR //序列化BIM数据 pPipe->GetSpecialtyData()->SetAt(_T("m_dX"),0.0); pPipe->GetSpecialtyData()->SetAt(_T("m_dZ"),0.0); pPipe->GetSpecialtyData()->SetAt(_T("m_nN"),1); pPipe->GetSpecialtyData()->SetAt(_T("m_dLen"),80.0); pPipe->GetSpecialtyData()->SetAt(_T("m_bRight"),FALSE); pPipe->GetSpecialtyData()->SetAt(_T("m_vtDir"),AcGeVector3d::kXAxis); pPipe->GetSpecialtyData()->SetAt(_T("m_sCurrSys"),m_sCurrSys); pPipe->GetSpecialtyData()->SetAt(_T("m_sMertial"),m_sMertial); pPipe->GetSpecialtyData()->SetAt(_T("m_dDn"),m_dDn); pPipe->GetSpecialtyData()->SetAt(_T("m_dt"),m_dt); pPipe->GetSpecialtyData()->SetAt(_T("m_dOD"),m_dOD); pPipe->GetSpecialtyData()->SetAt(_T("m_idxRoom"),0); pPipe->GetSpecialtyData()->SetAt(_T("m_sPipeNo"),m_sPipeNo); //统一管线接口 pPipe->GetSpecialtyData()->SetAt(KEY_2DSTYLE, 1); pPipe->GetSpecialtyData()->SetAt(PIPE_DN, AS_MUNIT(m_dDn)); pPipe->GetSpecialtyData()->SetAt(PIPE_OD, AS_MUNIT(m_dOD)); pPipe->GetSpecialtyData()->SetAt(PIPE_THICK, AS_MUNIT(m_dt)); pPipe->GetSpecialtyData()->SetAt(PIPE_MATERIAL, m_sMertial); pPipe->GetSpecialtyData()->SetAt(PIPE_SYS, m_sCurrSys); return TRUE; } void CDJPGDlg::OnBnClickedOk() { UpdateData(); int nItem = -1; POSITION ps = m_wndPipeList.GetFirstSelectedItemPosition(); if (ps != NULL) { nItem = m_wndPipeList.GetNextSelectedItem(ps); } if (nItem == -1) { AfxMessageBox(_T("请选择管道规格!")); return; } m_dDn = _ttof( m_wndPipeList.GetItemText(nItem,0) ); m_dOD = _ttof(m_wndPipeList.GetItemText(nItem,1)); m_dt = _ttof(m_wndPipeList.GetItemText(nItem,2)); int nSel = m_wndListBoxMaters.GetCurSel(); if (nSel == -1) { AfxMessageBox(_T("请选择管道材质!")); return; } m_wndListBoxMaters.GetText(nSel,m_sMertial); int nSys = m_wndSysListBox.GetCurSel(); if (nSys == -1) { AfxMessageBox(_T("请选择管道用途系统!")); return; } m_wndSysListBox.GetText(nSys,m_sCurrSys); OnOK(); }