#include "stdafx.h" #include "shs_outdoor.h" #include "SiphonRainwaterCalcDlg.h" #include "TWordFormulasTemplet.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #include"TGAs.h" CSiphonRainwaterCalcGrid::CSiphonRainwaterCalcGrid() { m_pWnd = NULL; } void CSiphonRainwaterCalcGrid::OnCellComboString(WDGridCell&cell,CComboBox&combo) { if(cell.GetColIndex()==3) { XString fullFile; if(!FindFile(_T("pipe.dbf"), fullFile)) { acutPrintf(_T("对不起,没有发现pipe.dbf文件!")); return; } CodeBase db; db.read_only = 1; XDbfTable *pTable = db.Open(fullFile); if(!pTable) return; CString strMaterial, strDn; std::set data; for(pTable->MoveFirst(); !pTable->IsEOF(); pTable->MoveNext()) { GET_FIELD(pTable, _T("Gc"), strMaterial); if (strMaterial.Compare(m_strPipeMaterial) != 0) { continue; } GET_FIELD(pTable, _T("Dn"), strDn); data.insert(_tstof(strDn)); } pTable->Close(); std::set::iterator it; for(it = data.begin(); it != data.end(); it++) { double dVal = *it; if (dVal >= 50 && dVal <= 300) { CString str; str.Format(_T("%.0f"), dVal); combo.AddString(str); } } } } void CSiphonRainwaterCalcGrid::SetPipeMaterial(const CString& strMaterial) { m_strPipeMaterial = strMaterial; } void CSiphonRainwaterCalcGrid::SetWnd(CSiphonRainwaterCalcDlg* pWnd) { m_pWnd = pWnd; } void CSiphonRainwaterCalcGrid::OnDblClick(WDGridRow&row) { if (m_pWnd != NULL) { m_pWnd->DblClickLst(); } } bool CSiphonRainwaterCalcGrid::OnModified(WDGridCell&cell,CString &text) { long i = cell.GetColIndex(); if (i == 3 && m_pWnd != NULL) { m_pWnd->UpDatePipeDia(cell.GetRowIndex(), text); } else if (i == 6 && m_pWnd != NULL) { m_pWnd->UpDateT(cell.GetRowIndex(), text); } return true; } void CSiphonRainwaterCalcGrid::SetData(std::set &data) { m_setRow = data; } std::set& CSiphonRainwaterCalcGrid::GetData() { return m_setRow; } void CSiphonRainwaterCalcGrid::OnBeforeRefresh(WDGridCell &cell) { if(cell.GetColIndex() == 4) { std::set::iterator it; it = m_setRow.find(cell.GetRowIndex()); if(it != m_setRow.end()) { CDC&dc=GetDC(); COLORREF color=acedGetRGB(6); dc.SetTextColor(color); dc.SetBkMode(TRANSPARENT); } else WDGrid::OnBeforeRefresh(cell); } else WDGrid::OnBeforeRefresh(cell); } extern int GetPipeMaterialType(const CString &strMaterial); CString CSiphonRainwaterCalcDlg::m_strWndCmbT = _T("10"); CSiphonRainwaterCalcDlg::CSiphonRainwaterCalcDlg(CWnd* pParent /*=NULL*/) : CDialog(CSiphonRainwaterCalcDlg::IDD, pParent) { //{{AFX_DATA_INIT(CSiphonRainwaterCalcDlg) m_dWndEdtDelta = 0.0; //}}AFX_DATA_INIT m_bExistPlan2Sys = FALSE; } void CSiphonRainwaterCalcDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSiphonRainwaterCalcDlg) DDX_Control(pDX, IDC_LIST1, m_listCtrl); DDX_CBString(pDX, IDC_COMBOTEMPERATURE, m_strWndCmbT); DDX_Text(pDX, IDC_EDT_ROUGHNESS, m_dWndEdtDelta); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSiphonRainwaterCalcDlg, CDialog) //{{AFX_MSG_MAP(CSiphonRainwaterCalcDlg) ON_BN_CLICKED(IDC_BUTTON_TABALE, OnButtonTabale) ON_BN_CLICKED(IDC_BUTTON_HIDE, OnButtonHide) ON_BN_CLICKED(IDC_BUTTON_CALC, OnButtonCalc) ON_BN_CLICKED(IDC_BUTTON_CHECK, OnButtonCheck) ON_BN_CLICKED(IDC_BUTTON_WORD, OnButtonWord) //}}AFX_MSG_MAP END_MESSAGE_MAP() void CSiphonRainwaterCalcDlg::SetSiphonInfo(std::vector &data) { m_vecData = data; } BOOL CSiphonRainwaterCalcDlg::OnInitDialog() { CDialog::OnInitDialog(); CRect rect; m_listCtrl.GetWindowRect(&rect); ScreenToClient(&rect); m_listCtrl.Clear(); m_listCtrl.Create(this, IDC_LIST1); m_listCtrl.SetPipeMaterial(m_strPipeMaterial); m_listCtrl.SetNoDefaultMenu(); m_listCtrl.SetNoAppendButton(); long nWidth = rect.Width() / 20; COLORREF color = RGB(255,0,0); m_listCtrl.AppendCol(_T("管段"), nWidth); m_listCtrl.AppendCol(_T("流量L/s"), 1.5 * nWidth); m_listCtrl.AppendCol(_T("管长(m)"), 1.5 * nWidth); m_listCtrl.AppendCol(_T("管径(mm)"), 1.5 * nWidth); m_listCtrl.AppendCol(_T("流速m/s"), 1.5 * nWidth); m_listCtrl.AppendCol(_T("沿损kPa"), 1.5 * nWidth); m_listCtrl.AppendCol(_T("局阻系数"), 1.5 * nWidth); m_listCtrl.AppendCol(_T("局损(kPa)"), 2.0 * nWidth); m_listCtrl.AppendCol(_T("总损失(kPa)"), 2 * nWidth); m_listCtrl.AppendCol(_T("∑总损失(kPa)"), 2.5 * nWidth); m_listCtrl.AppendCol(_T("高差(m)"), 1.5 * nWidth); m_listCtrl.AppendCol(_T("压力(kPa)"), 1.5 * nWidth); m_listCtrl.GetCol(0).SetCenterAlign(true); m_listCtrl.GetCol(1).SetCenterAlign(true); m_listCtrl.GetCol(2).SetCenterAlign(true); m_listCtrl.GetCol(3).SetCenterAlign(true); m_listCtrl.GetCol(4).SetCenterAlign(true); m_listCtrl.GetCol(5).SetCenterAlign(true); m_listCtrl.GetCol(6).SetCenterAlign(true); m_listCtrl.GetCol(7).SetCenterAlign(true); m_listCtrl.GetCol(8).SetCenterAlign(true); m_listCtrl.GetCol(9).SetCenterAlign(true); m_listCtrl.GetCol(10).SetCenterAlign(true); m_listCtrl.GetCol(11).SetCenterAlign(true); m_listCtrl.GetCol(3).SetComboEdit(); m_listCtrl.GetCol(0).SetReadOnly(true); m_listCtrl.GetCol(1).SetReadOnly(true); m_listCtrl.GetCol(2).SetReadOnly(true); m_listCtrl.GetCol(4).SetReadOnly(true); m_listCtrl.GetCol(5).SetReadOnly(true); m_listCtrl.GetCol(7).SetReadOnly(true); m_listCtrl.GetCol(8).SetReadOnly(true); m_listCtrl.GetCol(9).SetReadOnly(true); m_listCtrl.GetCol(10).SetReadOnly(true); m_listCtrl.GetCol(11).SetReadOnly(true); m_listCtrl.GetCol(3).SetTextColor(RGB(255,0,0)); m_listCtrl.GetCol(6).SetTextColor(RGB(255,0,0)); m_listCtrl.GetCol(4).SetTextColor(RGB(0,0,255)); m_listCtrl.GetCol(5).SetTextColor(RGB(0,0,255)); m_listCtrl.GetCol(7).SetTextColor(RGB(0,0,255)); m_listCtrl.GetCol(8).SetTextColor(RGB(0,0,255)); m_listCtrl.GetCol(9).SetTextColor(RGB(0,0,255)); m_listCtrl.GetCol(10).SetTextColor(RGB(0,0,255)); m_listCtrl.GetCol(11).SetTextColor(RGB(0,0,255)); m_listCtrl.FitLastCol(); m_listCtrl.SetWnd(this); std::vector::iterator it; int nIdex = 0; for(it = m_vecData.begin(); it != m_vecData.end(); it++) { if ((*it).nType == 1) { continue; } m_listCtrl.AppendRow(); } int nType = GetPipeMaterialType(m_strPipeMaterial); if (nType == 0) { m_dWndEdtDelta = 0.007; } else if (nType == 1) { m_dWndEdtDelta = 0.015; } else if (nType == 2) { m_dWndEdtDelta = 0.15; } UpdateData(FALSE); ResetList(); UpdateData(FALSE); return TRUE; } void CSiphonRainwaterCalcDlg::CleanUseless0(CString &strText) { int nIndex = -1; nIndex = strText.Find(_T(".")); if (nIndex != -1) { strText.TrimRight(_T("0")); strText.TrimRight(_T(".")); } } void CSiphonRainwaterCalcDlg::ResetList() { UpdataInfo(); std::vector::iterator it; int nIdex = 0; for(it = m_vecData.begin(); it != m_vecData.end(); it++) { if ((*it).nType == 1) { continue; } CString strDia, strLen, strEle, strQ, strT; strDia.Format(_T("%f"), (*it).dPipeDia); strLen.Format(_T("%.2f"), (*it).dLen); strEle.Format(_T("%f"), (*it).dEle); strQ.Format(_T("%f"), (*it).dQ); strT.Format(_T("%f"), (*it).dT); CleanUseless0(strDia); CleanUseless0(strEle); CleanUseless0(strQ); CleanUseless0(strT); m_listCtrl.GetCell(nIdex, 0).SetText((*it).strName); //名称 m_listCtrl.GetCell(nIdex, 3).SetText(strDia); //管径 m_listCtrl.GetCell(nIdex, 2).SetText(strLen); //管长 m_listCtrl.GetCell(nIdex, 10).SetText(strEle); //高差 m_listCtrl.GetCell(nIdex, 1).SetText(strQ); //流量 m_listCtrl.GetCell(nIdex, 6).SetText(strT); //局部阻力系数 //流速 CString strV; strV.Format(_T("%.3f"), (*it).dv); m_listCtrl.GetCell(nIdex, 4).SetText(strV); //沿程阻力损失 CString strHf; strHf.Format(_T("%.3f"), (*it).dhf); m_listCtrl.GetCell(nIdex, 5).SetText(strHf); //局部阻力损失 CString strHj; strHj.Format(_T("%.3f"), (*it).dhj); m_listCtrl.GetCell(nIdex, 7).SetText(strHj); //总阻力损失 CString strH; strH.Format(_T("%.3f"), (*it).dH); m_listCtrl.GetCell(nIdex, 8).SetText(strH); //∑总阻力损失 CString strH2; strH2.Format(_T("%.3f"), (*it).dH2); m_listCtrl.GetCell(nIdex, 9).SetText(strH2); //压力 CString strP; strP.Format(_T("%.3f"), (*it).dP); m_listCtrl.GetCell(nIdex, 11).SetText(strP); ++nIdex; } m_listCtrl.Invalidate(); } void CSiphonRainwaterCalcDlg::SetPipeMaterial(const CString& strMaterial) { m_strPipeMaterial = strMaterial; } double CSiphonRainwaterCalcDlg::GetU() { UpdateData(TRUE); double dU = 0.0; double dT = _tstof(m_strWndCmbT); if (dT < 0) { dU = 1.785*1e-6; } else if (dT >= 0 && dT <= 5) { dU = 1.785*1e-6 - (dT - 0) * (1.785*1e-6 - 1.519*1e-6)/(5 - 0); } else if (dT >= 5 && dT <= 10) { dU = 1.519*1e-6 - (dT - 5) * (1.519*1e-6 - 1.306*1e-6)/(10 - 5); } else if (dT >= 10 && dT <= 15) { dU = 1.306*1e-6 - (dT - 10) * (1.306*1e-6 - 1.139*1e-6)/(15 - 10); } else if (dT >= 15 && dT <= 20) { dU = 1.139*1e-6 - (dT - 15) * (1.139*1e-6 - 1.003*1e-6)/(20 - 15); } else if (dT >= 20 && dT <= 25) { dU = 1.003*1e-6 - (dT - 20) * (1.003*1e-6 - 0.893*1e-6)/(25 - 20); } else if (dT >= 25 && dT <= 30) { dU = 0.893*1e-6 - (dT - 25) * (0.893*1e-6 - 0.800*1e-6)/(30 - 25); } else if (dT >= 30 && dT <= 40) { dU = 0.800*1e-6 - (dT - 30) * (0.800*1e-6 - 0.658*1e-6)/(40 - 30); } else if (dT >= 40 && dT <= 50) { dU = 0.658*1e-6 - (dT - 40) * (0.658*1e-6 - 0.553*1e-6)/(50 - 40); } else if (dT >= 50 && dT <= 60) { dU = 0.553*1e-6 - (dT - 50) * (0.553*1e-6 - 0.474*1e-6)/(60 - 50); } else if (dT >= 60 && dT <= 70) { dU = 0.474*1e-6 - (dT - 60) * (0.474*1e-6 - 0.413*1e-6)/(70 - 60); } else if (dT >= 70 && dT <= 80) { dU = 0.413*1e-6 - (dT - 70) * (0.413*1e-6 - 0.364*1e-6)/(80 - 70); } else if (dT >= 80 && dT <= 90) { dU = 0.364*1e-6 - (dT - 80) * (0.364*1e-6 - 0.326*1e-6)/(90 - 80); } else if (dT >= 90 && dT <= 100) { dU = 0.326*1e-6 - (dT - 90) * (0.326*1e-6 - 0.294*1e-6)/(100 - 90); } else { dU = 0.294 * 1e-6; } return dU; } void CSiphonRainwaterCalcDlg::OnButtonTabale() { UpdateData(TRUE); HideDialog(this, TRUE); XPoint pt; if(acedGetPoint(NULL, _T("\n点取表格左上角位置"), pt) != RTNORM) { HideDialog(this, FALSE); return; } double CSiphonRainwaterCalcGrid = g_nSheetHeight; //字高 double nTableHeight = g_nSheetHeight+2; AcDbObjectId idTextStyle=InitTwtTextStyle(g_csSheetStyle); TDbSheet *pSheet = new TDbSheet; TGridStyle gridStyle; gridStyle.SetOverrideAll(TRUE); gridStyle.SetTextHeight(CSiphonRainwaterCalcGrid); gridStyle.SetTextStyleId(idTextStyle); TSheetTitle &title=pSheet->GetTitle(); title.SetHeight(7.0); title.SetText(_T("虹吸雨水计算表")); TGridStyle &gridStyle2=title.GetGridStyle(); gridStyle2.SetTextHeight(CSiphonRainwaterCalcGrid); gridStyle2.SetTextStyleId(idTextStyle); TDividerStyle &style=title.GetDividerStyle(); style.SetDividerFlag(TDividerStyle::kNone); gridStyle.SetHorMode(AcDb::kTextCenter); gridStyle.SetVerMode(AcDb::kTextVertMid); gridStyle.SetLineSpaceFactor(0.2); gridStyle.SetTextWrap(FALSE); pSheet->SetGridStyle(gridStyle); pSheet->SetRowHeight(nTableHeight); pSheet->SetLayoutRotation(Ucs2Wcs(0.0)); pSheet->SetLocation(Ucs2Wcs(pt)); int nAllRow = (int)m_listCtrl.GetRowNum(); pSheet->InitSheet(nAllRow + 1, 12, nTableHeight, 50); TSheetColumn column; column.SetWidth(15); //管段名称 pSheet->SetColumnAt(0, column); column.SetWidth(20); //流量 pSheet->SetColumnAt(1, column); column.SetWidth(15); //管长 pSheet->SetColumnAt(2, column); column.SetWidth(20); //管径 pSheet->SetColumnAt(3, column); column.SetWidth(20); //流速 pSheet->SetColumnAt(4, column); column.SetWidth(30); //沿程阻力损失 pSheet->SetColumnAt(5, column); column.SetWidth(20); //局部阻力系数 pSheet->SetColumnAt(6, column); column.SetWidth(30); //局部阻力损失 pSheet->SetColumnAt(7, column); column.SetWidth(30); //总阻力损失 pSheet->SetColumnAt(8, column); column.SetWidth(30); //Σ总阻力损失 pSheet->SetColumnAt(9, column); column.SetWidth(30); //高差 pSheet->SetColumnAt(10, column); column.SetWidth(20); //压力 pSheet->SetColumnAt(11, column); TGridCell &cell=*(*pSheet)(0, 0); cell.SetText(_T("管段名称")); TGridCell &cell2=*(*pSheet)(0, 1); cell2.SetText(_T("流量(L/s)")); TGridCell &cell3=*(*pSheet)(0, 2); cell3.SetText(_T("管长(m)")); TGridCell &cell4=*(*pSheet)(0, 3); cell4.SetText(_T("管径(mm)")); TGridCell &cell5=*(*pSheet)(0, 4); cell5.SetText(_T("流速(m/s)")); TGridCell &cell6=*(*pSheet)(0, 5); cell6.SetText(_T("沿程阻力损失(kPa)")); TGridCell &cell7=*(*pSheet)(0, 6); cell7.SetText(_T("局部阻力系数")); TGridCell &cell8=*(*pSheet)(0, 7); cell8.SetText(_T("局部阻力损失(kPa)")); TGridCell &cell9=*(*pSheet)(0, 8); cell9.SetText(_T("总阻力损失(kPa)")); TGridCell &cell10=*(*pSheet)(0, 9); cell10.SetText(_T("Σ总阻力损失(kPa)")); TGridCell &cell11=*(*pSheet)(0, 10); cell11.SetText(_T("高差(m)")); TGridCell &cell12=*(*pSheet)(0, 11); cell12.SetText(_T("压力(kPa)")); for(int i = 0; i < nAllRow; i++) { TGridCell &Cell11=*(*pSheet)(i+1, 0); Cell11.SetText(m_listCtrl.GetCell(i, 0).GetText()); TGridCell &Cell12=*(*pSheet)(i+1, 1); Cell12.SetText(m_listCtrl.GetCell(i, 1).GetText()); TGridCell &Cell13=*(*pSheet)(i+1, 2); Cell13.SetText(m_listCtrl.GetCell(i, 2).GetText()); TGridCell &Cell14=*(*pSheet)(i+1, 3); Cell14.SetText(m_listCtrl.GetCell(i, 3).GetText()); TGridCell &Cell15=*(*pSheet)(i+1, 4); Cell15.SetText(m_listCtrl.GetCell(i, 4).GetText()); TGridCell &Cell16=*(*pSheet)(i+1, 5); Cell16.SetText(m_listCtrl.GetCell(i, 5).GetText()); TGridCell &Cell17=*(*pSheet)(i+1, 6); Cell17.SetText(m_listCtrl.GetCell(i, 6).GetText()); TGridCell &Cell18=*(*pSheet)(i+1, 7); Cell18.SetText(m_listCtrl.GetCell(i, 7).GetText()); TGridCell &Cell19=*(*pSheet)(i+1, 8); Cell19.SetText(m_listCtrl.GetCell(i, 8).GetText()); TGridCell &Cell110=*(*pSheet)(i+1, 9); Cell110.SetText(m_listCtrl.GetCell(i, 9).GetText()); TGridCell &Cell111=*(*pSheet)(i+1, 10); Cell111.SetText(m_listCtrl.GetCell(i, 10).GetText()); TGridCell &Cell112=*(*pSheet)(i+1, 11); Cell112.SetText(m_listCtrl.GetCell(i, 11).GetText()); } pSheet->AddToCSpace(TRUE); TCHAR szTmp[32]; ads_getstring(NULL, _T("\n按任意键返回对话框:<返回>"), szTmp); HideDialog(this,FALSE); } void CSiphonRainwaterCalcDlg::UpdataInfo() { UpdateData(TRUE); std::vector::iterator it; double dU = GetU(); int nNum = -1; //记录上一管段号 double dTotal = 0.0; //记录前一管段总损失 for(it = m_vecData.begin(); it != m_vecData.end(); it++) { if ((*it).nType == 1) { continue; } //流速 double dDia = GetPipeDjByDn(m_strPipeMaterial, (int)(*it).dPipeDia); double dv = 4 * (*it).dQ / (PI * dDia * dDia * 1000); (*it).dv = dv; //沿程阻力损失 double dRes1 = 0.0, dRes2 = 0.0; double dRe = dv * dDia / dU; double dA = 0.0; //管道沿程阻力损失系数λ for(double i = 0; i <= 1; i += 5 * 1e-6) { dRes1 = 1.0 / sqrt(i); dRes2 = -2 * log10(m_dWndEdtDelta / (3.7 * dDia * 1000) + 2.51 / (dRe * sqrt(i))); if (fabs(dRes1 - dRes2) < 1e-3) { dA = i; break; } } double dhf = dA * ((*it).dLen / dDia) * (dv * dv / (2 * 9.81)) * 10; (*it).dhf = dhf; (*it).dA = dA; //局部阻力损失 double dhj = (*it).dT * 5 * dv * dv * 0.1; (*it).dhj = dhj; //总阻力损失 double dH = dhf + dhj; (*it).dH = dH; //∑总阻力损失 double dH2 = 0.0; int nCurNum = (int)_tstof((*it).strName); if (nNum == -1) { dH2 = dH; nNum = nCurNum; dTotal = dH2; } else if (nCurNum - nNum == 1) //与前段管道号码相差1,加上前段管段的∑总阻力损失 { dH2 = dH + dTotal; nNum = nCurNum; dTotal = dH2; } else { dH2 = dH; nNum = nCurNum; dTotal = dH2; } (*it).dH2 = dH2; //压力 double dP = 98.1 * (*it).dEle - 5 * dv * dv - dH2 * 10; dP *= 0.1; (*it).dP = dP; } } void CSiphonRainwaterCalcDlg::SetMapInfo(std::map &mapPipe, std::map &mapDim, std::map &map2PipeId) { m_mapPipe = mapPipe; m_mapDim = mapDim; m_map2PipeId = map2PipeId; } void CSiphonRainwaterCalcDlg::OnButtonHide() { UpdateData(TRUE); int nIndex = m_listCtrl.GetCurRowIndex(); if (nIndex == -1 || !m_bExistPlan2Sys) { return; } HideDialog(this, TRUE); AcDbObjectId idPipe = GetPipeId(nIndex); ShowPipe(idPipe); TCHAR szTmp[32]; ads_getstring(NULL, _T("\n按任意键返回对话框:<返回>"), szTmp); HideDialog(this, FALSE); } void CSiphonRainwaterCalcDlg::SetPlan2Sys(BOOL bExist) { m_bExistPlan2Sys = bExist; } AcDbObjectId CSiphonRainwaterCalcDlg::GetPipeId(int nIndex) { AcDbObjectId idPipe; std::vector::iterator it; int i = 0; //第几行管段 for (it = m_vecData.begin(); it != m_vecData.end(); it++) { if ((*it).nType == 1) { continue; } if (i == nIndex) { idPipe = (*it).id; break; } ++i; } std::map::iterator it2; it2 = m_mapPipe.find(idPipe); if (it2 != m_mapPipe.end()) { idPipe = (*it2).second; } else { idPipe.setNull(); } return idPipe; } void CSiphonRainwaterCalcDlg::ShowPipe(AcDbObjectId &idPipe) { TDbPipe *pPipe = NULL; acdbOpenObject(pPipe, idPipe, AcDb::kForRead); if (pPipe != NULL) { XPoint ptCen, p1, p2, p3, p4; ptCen = pPipe->MidPoint(); double nDist = pPipe->Length()*2000; arxZoomTo(ptCen, nDist, nDist); ads_polar(ptCen, 0, nDist/5, p1); ads_polar(p1, PI/2, nDist/5, p1); ads_polar(ptCen, PI, nDist/5, p2); ads_polar(p2, PI/2, -nDist/5, p2); ads_grdraw(p1, p2, 2, 0); ads_polar(ptCen, PI/2, nDist/5, p3); ads_polar(p3, PI, nDist/5, p3); ads_polar(ptCen, PI/2, -nDist/5, p4); ads_polar(p4, 0, nDist/5, p4); ads_grdraw(p3, p4, 2, 0); pPipe->close(); } } void CSiphonRainwaterCalcDlg::DblClickLst() { OnButtonHide(); } extern CString GetDimInfo(std::vector &data, const AcDbObjectId &id); void CSiphonRainwaterCalcDlg::UpDatePipeDia(long nIndex, CString &strText) { UpdateData(TRUE); //更新管段管径 AcDbObjectId idPipe1, idPipe2; std::vector::iterator it; int i = 0; //表格第几行管段 for (it = m_vecData.begin(); it != m_vecData.end(); it++) { if ((*it).nType == 1) { continue; } if (i == nIndex) { idPipe1 = (*it).id; //原图管段 break; } ++i; } if (it == m_vecData.end()) { return; } std::map::iterator it2; it2 = m_mapPipe.find(idPipe1); if (it2 == m_mapPipe.end()) { return; } idPipe2 = (*it2).second; //系统图管段 double dDia = _tstof(strText); UpDatePipeDia(idPipe1, dDia); UpDatePipeDia(idPipe2, dDia); // cet 2011.7.6 add 更新倒角管径 it2 = m_mapChamferPipe.find(idPipe1); if (it2 != m_mapChamferPipe.end()) { AcDbObjectId id1 = (*it2).second; UpDatePipeDia(id1, dDia); it2 = m_mapPipe.find(id1); // 系统图对应的倒角管段 if (it2 != m_mapPipe.end()) { UpDatePipeDia((*it2).second, dDia); } } it2 = m_mapDim.find(idPipe1); if (it2 != m_mapDim.end()) //更新管道标注 { CString strContext; std::vector::iterator it3; for (it3 = m_vecData.begin(); it3 != m_vecData.end(); it3++) { if ((*it3).id == idPipe1) { (*it3).dPipeDia = dDia; //更新管径 strContext = GetDimInfo(m_vecData, idPipe1); break; } } AcDbMText *pText = NULL; acdbOpenObject(pText, (*it2).second, AcDb::kForWrite); if (pText != NULL) { pText->setContents(strContext); pText->close(); } } //管径改变时,更新计算局部阻力系数时需要考虑变径的管段的局部阻力系数 AcDbObjectId id2 = (*it).id2; if (id2.isValid()) { if (ComparePipeDia(idPipe1, id2) != 0 && !(*it).bDia) { (*it).bDia = true; (*it).dT += 0.4; } else if (ComparePipeDia((*it).id, id2) == 0 && (*it).bDia) { (*it).bDia = false; (*it).dT -= 0.4; } } for (it = m_vecData.begin(); it != m_vecData.end(); it++) { AcDbObjectId id3 = (*it).id2; if (id3 == idPipe1) { if (ComparePipeDia((*it).id, id3) != 0 && !(*it).bDia) { (*it).bDia = true; (*it).dT += 0.4; } else if (ComparePipeDia((*it).id, id3) == 0 && (*it).bDia) { (*it).bDia = false; (*it).dT -= 0.4; } } } m_listCtrl.GetCell(nIndex, 3).SetText(strText); UpdateData(FALSE); ResetList(); UpdateData(FALSE); } void CSiphonRainwaterCalcDlg::UpDatePipeDia(AcDbObjectId &id, double dDia) { TDbPipe *pPipe = NULL; acdbOpenObject(pPipe, id, AcDb::kForWrite); if (pPipe != NULL) { pPipe->SetDnDiameter(dDia); pPipe->close(); } } int CSiphonRainwaterCalcDlg::ComparePipeDia(const AcDbObjectId &id1, const AcDbObjectId &id2) { int nRet = 0; double dDia1 = 0, dDia2 = 0; TDbPipe *pPipe1 = NULL, *pPipe2 = NULL; acdbOpenObject(pPipe1, id1, AcDb::kForRead); if (pPipe1 != NULL) { dDia1 = pPipe1->GetDnDiameter(); pPipe1->close(); } acdbOpenObject(pPipe2, id2, AcDb::kForRead); if (pPipe2 != NULL) { dDia2 = pPipe2->GetDnDiameter(); pPipe2->close(); } if (dDia1 > dDia2) { return 1; } else if (dDia2 > dDia1) { return -1; } else { return 0; } } void CSiphonRainwaterCalcDlg::UpDateT(long nIndex, CString &strText) { std::vector::iterator it; int i = 0; //表格第几行管段 for (it = m_vecData.begin(); it != m_vecData.end(); it++) { if ((*it).nType == 1) { continue; } if (i == nIndex) { (*it).dT = _tstof(strText); break; } ++i; } } void CSiphonRainwaterCalcDlg::OnButtonCalc() { UpdateData(TRUE); m_listCtrl.GetData().clear(); ResetList(); UpdateData(FALSE); } /* cet 2011.10.13 modify 校核规则发生变化 void CSiphonRainwaterCalcDlg::OnButtonCheck() { //流速 压力余量 最大负压管段 CString strP, strMaxNP, strVP; BOOL bLess1 = FALSE; //流速是否小于1 m/s BOOL bEqual1 = FALSE; //流速是否等于1 m/s std::vector::iterator it; int nRow = -1; //表格行号 std::set setRow; for(it = m_vecData.begin(); it != m_vecData.end(); it++) { SIPHONINFO info = *it; if (info.nType == 1) { continue; } double dv = info.dv; ++nRow; ads_name name; acdbGetAdsName(name, info.id); Entity ent(name); CString strOutPipe = ReadXdata(ent, _T("OutPipe")); if (strOutPipe == _T("1")) //出流端管段 { double dEle = info.dEle, dH2 = info.dH2; double dP = 98.1 * info.dEle - 5 * dv * dv - info.dH2 * 10; //压力余量 dP *= 0.1; if (dP > 10) { strP.Format(_T("压力余量:%.1f kPa, 大于10 kPa, 符合要求!"), dP); } else { strP.Format(_T("压力余量:%.1f kPa, 小于10 kPa, 不符合要求!"), dP); } } CString strTemp; strTemp = ReadXdata(ent, _T("MaxNP")); if (strTemp == _T("1")) //最大负压管段 { int nType = GetPipeMaterialType(m_strPipeMaterial); double dMaxP = info.dP; if (nType == 0 || nType == 2) //0表示内壁涂塑离心排水铸铁管 1表示排水塑料管 2表示钢管 { if (fabs(dMaxP) < 90) { strMaxNP.Format(_T("最大负压值:%.2f kPa,其绝对值小于90 kPa,符合要求!"), dMaxP); } else { strMaxNP.Format(_T("最大负压值:%.2f kPa,其绝对值大于90 kPa,不符合要求!"), dMaxP); } } else if (nType == 1) { if (info.dPipeDia >= 50 && info.dPipeDia <= 160 && fabs(dMaxP) < 80) { strMaxNP.Format(_T("最大负压值:%.2f kPa,其绝对值小于80 kPa,符合要求!"), dMaxP); } else if (info.dPipeDia >= 200 && fabs(dMaxP) < 70) { strMaxNP.Format(_T("最大负压值:%.2f kPa,其绝对值小于70 kPa,符合要求!"), dMaxP); } else if (info.dPipeDia >= 50 && info.dPipeDia <= 160) { strMaxNP.Format(_T("最大负压值:%.2f kPa,其绝对值大于80 kPa,不符合要求!"), dMaxP); } else if (info.dPipeDia >= 200) { strMaxNP.Format(_T("最大负压值:%.2f kPa,其绝对值大于70 kPa,不符合要求!"), dMaxP); } } } if (!bLess1 && dv < 1) { bLess1 = TRUE; setRow.insert(nRow); } if (!bEqual1 && fabs(dv - 1) < 1e-3) { bEqual1 = TRUE; } if (info.bVertical && !info.bLinkWaterBucket) { CString strTemp; if (dv < 2.2) { strTemp.Format(_T("立管流速:%.2f m/s,小于2.2 m/s,不符合要求!"), dv); setRow.insert(nRow); } else if (fabs(dv - 2.2) < 1e-3) { strTemp.Format(_T("立管流速:%.2f m/s,等于2.2 m/s,符合要求!"), dv); } else if (dv < 6) { strTemp.Format(_T("立管流速:%.2f m/s,数值大于2.2 m/s且小于6 m/s,符合要求!"), dv); } else if (fabs(dv - 6.0) < 1e-3) { strTemp.Format(_T("立管流速:%.2f m/s,等于6 m/s,在最大允许值内!"), dv); } else if (dv <= 10) { strTemp.Format(_T("立管流速:%.2f m/s,数值大于6 m/s且小于10 m/s,在最大允许值内!"), dv); } else if (fabs(dv-10) < 1e-3) { strTemp.Format(_T("立管流速:%.2f m/s,等于10 m/s,在最大允许值内!"), dv); } else { strTemp.Format(_T("立管流速:%.2f m/s,大于10 m/s,不符合要求!"), dv); setRow.insert(nRow); } if (strVP.IsEmpty()) { strVP += strTemp; } else { strVP += _T("\n") + strTemp; } } } m_listCtrl.SetData(setRow); m_listCtrl.Invalidate(); CString strV; if (bLess1) { strV = _T("存在小于1m/s的管段流速,不符合要求!"); } else if (bEqual1) { strV = _T("存在等于1m/s的管段流速,符合要求!"); } else { strV = _T("全部管段流速大于1 m/s,符合要求!"); } //各节点由不同支路计算得到的压力差 CString strNO; std::map::iterator it2; for (it2 = m_map2PipeId.begin(); it2 != m_map2PipeId.end(); it2++) { CString strNO1, strNO2; double dP = 0.0; if (GetPressure((*it2).first, (*it2) .second, dP, strNO1, strNO2)) { if (dP > 15) { if (strNO.IsEmpty()) { strNO += _T("(NO.") + strNO1 + _T(", NO.") + strNO2 + _T(")"); } else { strNO += _T("、(NO.") + strNO1 + _T(", NO.") + strNO2 + _T(")"); } } } } if (strNO.IsEmpty()) { strNO = _T("由不同支路计算得到的压力差数值的绝对值均小于15kPa,符合要求!"); } else { strNO += _T("节点处的压力差数值绝对值大于15kPa,不符合要求!"); } CString strContext; strContext = strV + _T("\n\n") + strVP + _T("\n\n") + strP + _T("\n\n") + strMaxNP + _T("\n\n") + strNO; AfxMessageBox(strContext); } */ void CSiphonRainwaterCalcDlg::OnButtonCheck() { //流速 压力余量 最大负压管段 CString strP, strMaxNP, strVP; //悬吊管中心线与雨水斗出口的高差 CString sHangers; //排出端 CString sDischargePipe; BOOL bLess1 = FALSE; //流速是否小于1 m/s BOOL bEqual1 = FALSE; //流速是否等于1 m/s std::vector::iterator it; int nRow = -1; //表格行号 std::set setRow; for(it = m_vecData.begin(); it != m_vecData.end(); it++) { SIPHONINFO info = *it; if (info.nType == 1) { continue; } double dv = info.dv; ++nRow; //检查悬吊管中心线与雨水斗出口的高差 if (info.bVertical && info.bLinkWaterBucket) { if (info.dEle < 1.0) { if (sHangers.IsEmpty()) { sHangers += _T("NO.") + info.strName; } else { sHangers += _T("、NO.") + info.strName; } } } ads_name name; acdbGetAdsName(name, info.id); Entity ent(name); CString strOutPipe = ReadXdata(ent, _T("OutPipe")); if (strOutPipe == _T("1")) //出流端管段 { double dEle = info.dEle, dH2 = info.dH2; double dP = 98.1 * info.dEle - 5 * dv * dv - info.dH2 * 10; //压力余量 dP *= 0.1; if (dP > 10) { strP.Format(_T("压力余量:%.1f kPa, 大于10 kPa, 符合要求!"), dP); } else { strP.Format(_T("压力余量:%.1f kPa, 小于10 kPa, 不符合要求!"), dP); } // 排出端流速 CString sV; sV.Format(_T("%.2f"), dv); if (fabs(dv - 1.8) < 0.001) { sDischargePipe = _T("排出端流速:") + sV + _T("m/s,等于1.8m/s,符合要求!"); } else if (dv < 1.8) { sDischargePipe = _T("排出端流速:") + sV + _T("m/s,小于1.8m/s,符合要求!"); } else { sDischargePipe = _T("排出端流速:") + sV + _T("m/s,大于1.8m/s,不符合要求!"); } } CString strTemp; strTemp = ReadXdata(ent, _T("MaxNP")); if (strTemp == _T("1")) //最大负压管段 { int nType = GetPipeMaterialType(m_strPipeMaterial); double dMaxP = info.dP; if (nType == 0 || nType == 2) //0表示内壁涂塑离心排水铸铁管 1表示排水塑料管 2表示钢管 { if (fabs(dMaxP) < 90) { strMaxNP.Format(_T("最大负压值:%.2f kPa,其绝对值小于90 kPa,符合要求!"), dMaxP); } else { strMaxNP.Format(_T("最大负压值:%.2f kPa,其绝对值大于90 kPa,不符合要求!"), dMaxP); } } else if (nType == 1) { if (info.dPipeDia >= 50 && info.dPipeDia <= 160 && fabs(dMaxP) < 80) { strMaxNP.Format(_T("最大负压值:%.2f kPa,其绝对值小于80 kPa,符合要求!"), dMaxP); } else if (info.dPipeDia >= 200 && fabs(dMaxP) < 70) { strMaxNP.Format(_T("最大负压值:%.2f kPa,其绝对值小于70 kPa,符合要求!"), dMaxP); } else if (info.dPipeDia >= 50 && info.dPipeDia <= 160) { strMaxNP.Format(_T("最大负压值:%.2f kPa,其绝对值大于80 kPa,不符合要求!"), dMaxP); } else if (info.dPipeDia >= 200) { strMaxNP.Format(_T("最大负压值:%.2f kPa,其绝对值大于70 kPa,不符合要求!"), dMaxP); } } } if (!bLess1 && dv < 1) { bLess1 = TRUE; setRow.insert(nRow); } if (!bEqual1 && fabs(dv - 1) < 1e-3) { bEqual1 = TRUE; } // 立管流速 if (info.bVertical && !info.bLinkWaterBucket) { CString strTemp; if (dv < 2.2) { strTemp.Format(_T("立管流速:%.2f m/s,小于2.2 m/s,不符合要求!"), dv); setRow.insert(nRow); } else if (fabs(dv - 2.2) < 1e-3) { strTemp.Format(_T("立管流速:%.2f m/s,等于2.2 m/s,符合要求!"), dv); } else if (dv < 6) { strTemp.Format(_T("立管流速:%.2f m/s,数值大于2.2 m/s且小于6 m/s,符合要求!"), dv); } else if (fabs(dv - 6.0) < 1e-3) { strTemp.Format(_T("立管流速:%.2f m/s,等于6 m/s,在最大允许值内!"), dv); } else if (dv <= 10) { strTemp.Format(_T("立管流速:%.2f m/s,数值大于6 m/s且小于10 m/s,在最大允许值内!"), dv); } else if (fabs(dv-10) < 1e-3) { strTemp.Format(_T("立管流速:%.2f m/s,等于10 m/s,在最大允许值内!"), dv); } else { strTemp.Format(_T("立管流速:%.2f m/s,大于10 m/s,不符合要求!"), dv); setRow.insert(nRow); } if (strVP.IsEmpty()) { strVP += strTemp; } else { strVP += _T("\n") + strTemp; } } } m_listCtrl.SetData(setRow); m_listCtrl.Invalidate(); CString strV; if (bLess1) { strV = _T("存在小于1m/s的管段流速,不符合要求!"); } else if (bEqual1) { strV = _T("存在等于1m/s的管段流速,符合要求!"); } else { strV = _T("全部管段流速大于1 m/s,符合要求!"); } //各节点由不同支路计算得到的压力差 CString strNO, sDn75, sDn100; std::map::iterator it2; for (it2 = m_map2PipeId.begin(); it2 != m_map2PipeId.end(); it2++) { CString strNO1, strNO2; double dP = 0.0, dDn1 = 0.0, dDn2 = 0.0; if (GetPressure((*it2).first, (*it2).second, dP, strNO1, strNO2) && GetPipeDn((*it2).first, dDn1) && GetPipeDn((*it2).second, dDn2)) { if (dDn1 < 100 && dDn2 < 100) //管径均小于100; { if (dP > 10) //节点压力差大于10 { if (sDn75.IsEmpty()) { sDn75 += _T("(NO.") + strNO1 + _T(", NO.") + strNO2 + _T(")"); } else { sDn75 += _T("、(NO.") + strNO1 + _T(", NO.") + strNO2 + _T(")"); } } } else //存在管径不小于100的管 { if (dP > 5) //节点压力差大于5 { if (sDn100.IsEmpty()) { sDn100 += _T("(NO.") + strNO1 + _T(", NO.") + strNO2 + _T(")"); } else { sDn100 += _T("、(NO.") + strNO1 + _T(", NO.") + strNO2 + _T(")"); } } } } } if (!sDn75.IsEmpty()) { strNO = sDn75 + _T("节点上游不同支路的管径均小于等于DN75,但其计算水头损失之差绝对值大于10kPa,不符合要求!\n"); } if (!sDn100.IsEmpty()) { strNO += sDn100 + _T("节点上游不同支路存在大于等于DN100管径,且其计算水头损失之差大于5 kPa,不符合要求!\n"); } if (sDn75.IsEmpty() && sDn100.IsEmpty()) { strNO = _T("各节点上游不同支路的计算水头损失之差,在管径小于等于DN75时,均小于10 kPa;在管径大于等于DN100时,均小于5 kPa,符合要求!"); } // 悬吊管信息 if (sHangers.IsEmpty()) { sHangers = _T("悬吊管中心线与雨水斗出口高差均大于1.0m,符合要求!"); } else { sHangers = _T("悬吊管中心线与雨水口高差存在小于1.0m现象,其管段编号为") + sHangers + _T(",不符合要求!"); } CString strContext; strContext = sHangers +_T("\n\n") + strV + _T("\n\n") + strVP + _T("\n\n") + sDischargePipe + _T("\n\n") + strP + _T("\n\n") + strMaxNP + _T("\n\n") + strNO; AfxMessageBox(strContext); } BOOL CSiphonRainwaterCalcDlg::GetPressure(const AcDbObjectId &id1, const AcDbObjectId &id2, double &dPressure, CString &strNO1, CString &strNO2) { std::vector::iterator it1, it2; it1 = Find(id1); it2 = Find(id2); if (it1 == m_vecData.end() || it2 == m_vecData.end()) { return FALSE; } dPressure = fabs((*it1).dP - (*it2).dP); strNO1 = (*it1).strName; strNO2 = (*it2).strName; return TRUE; } BOOL CSiphonRainwaterCalcDlg::GetPipeDn(const AcDbObjectId &id, double &dDn) { std::vector::iterator it; it = Find(id); if (it == m_vecData.end()) { return FALSE; } dDn = (*it).dPipeDia; return TRUE; } std::vector::iterator CSiphonRainwaterCalcDlg::Find(const AcDbObjectId &id) { std::vector::iterator it; for (it = m_vecData.begin(); it != m_vecData.end(); it++) { if ((*it).id == id) { return it; } } return m_vecData.end(); } void CSiphonRainwaterCalcDlg::OnButtonWord() { int nLen = m_listCtrl.GetRowNum(); if(nLen < 1) { return; } //初始化 COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR), vtTrue((short)TRUE), vtFalse((short)FALSE); _Application wordApplication; Documents wordDocuments; _Document activeDocument; Paragraphs wordParagraphs; Selection wordSelection; if (!wordApplication.CreateDispatch(_T("Word.Application"))) { AfxMessageBox(_T("不能执行Microsoft Word 8.0!")); return; } // 打开公式模板 TWordFormulasTemplet wdFormula; CString sPathName = g_csSysPath; sPathName += _T("formula.doc"); if (!wdFormula.OpenWordFormulasTempletFile(sPathName)) { return; } wordApplication.SetVisible(TRUE); wordDocuments = wordApplication.GetDocuments(); activeDocument = wordDocuments.Add(vtOptional,vtOptional); //写一行字 wordSelection = wordApplication.GetSelection(); wordParagraphs = wordSelection.GetParagraphs(); _Font font; font = wordSelection.GetFont(); float dSize = font.GetSize(); float dBold = font.GetBold(); wordParagraphs.SetAlignment(1); // 0: 居左 1:居中 2:居右 font.SetSize(dSize + 2); font.SetBold(dBold + 1); wordSelection.TypeText(_T("虹吸雨水计算书\n")); font.SetBold(dBold); font.SetSize(dSize); wordParagraphs.SetAlignment(0); wordSelection.TypeText(_T("计算原理参考《建筑与小区雨水利用工程技术规范》(GB50400-2006)\n")); font.SetSize(dSize + 1); font.SetBold(dBold + 1); wordSelection.TypeText(_T("一、基本参数:\n")); font.SetBold(dBold); font.SetSize(dSize); CString strMatrial; AcDbObjectId id; std::vector::iterator it; for (it = m_vecData.begin(); it != m_vecData.end(); it++) { if ((*it).nType == 0) { id = (*it).id; break; } } TDbPipe *pPipe = NULL; acdbOpenObject(pPipe, id, AcDb::kForRead); if (pPipe != NULL) { strMatrial = GetPipeMaterialByIdx(pPipe->GetMaterial()); pPipe->close(); } wordSelection.TypeText(_T("管材:") + strMatrial + _T("\n")); wordSelection.TypeText(_T("温度:") + m_strWndCmbT + _T("℃ \n")); font.SetSize(dSize + 1); font.SetBold(dBold + 1); wordSelection.TypeText(_T("\n二、基本计算公式:\n")); font.SetBold(dBold); font.SetSize(dSize); wordSelection.TypeText(_T("1、 暴雨强度公式:\n")); wordSelection.TypeText(_T(" ")); wdFormula.InsertFormula(WORD_FORMULA21, wordSelection); wordSelection.TypeText(_T("\n 式中:")); wordSelection.TypeText(_T("q -- 降雨强度,(L/s·ha、L/s·hm")); font.SetSuperscript(2); //处理上标 wordSelection.TypeText(_T("2")); font.SetSuperscript(0); wordSelection.TypeText(_T("、L/s·10")); font.SetSuperscript(2); //处理上标 wordSelection.TypeText(_T("4")); font.SetSuperscript(0); wordSelection.TypeText(_T("m")); font.SetSuperscript(2); //处理上标 wordSelection.TypeText(_T("2")); font.SetSuperscript(0); wordSelection.TypeText(_T(")\n")); wordSelection.TypeText(_T(" t -- 降雨历时(min)\n")); wordSelection.TypeText(_T(" P -- 设计重现期(年)\n")); wordSelection.TypeText(_T(" A、b、C、n -- 当地降雨参数\n")); wordSelection.TypeText(_T("\n2、 雨水设计流量公式:\n")); wordSelection.TypeText(_T(" ")); wdFormula.InsertFormula(WORD_FORMULA22, wordSelection); wordSelection.TypeText(_T("\n 式中:Q -- 雨水设计流量(L/s)\n")); wordSelection.TypeText(_T(" q -- 降雨强度,(L/s·ha、L/s·hm")); font.SetSuperscript(2); //处理上标 wordSelection.TypeText(_T("2")); font.SetSuperscript(0); wordSelection.TypeText(_T("、L/s·10")); font.SetSuperscript(2); //处理上标 wordSelection.TypeText(_T("4")); font.SetSuperscript(0); wordSelection.TypeText(_T("m")); font.SetSuperscript(2); //处理上标 wordSelection.TypeText(_T("2")); font.SetSuperscript(0); wordSelection.TypeText(_T(")\n")); wordSelection.TypeText(_T(" ψ-- 径流系数。\n")); wordSelection.TypeText(_T(" F -- 汇水面积(hm")); font.SetSuperscript(2); //处理上标 wordSelection.TypeText(_T("2")); font.SetSuperscript(0); wordSelection.TypeText(_T(")1 hm")); font.SetSuperscript(2); //处理上标 wordSelection.TypeText(_T("2")); font.SetSuperscript(0); wordSelection.TypeText(_T(" = 10000平方米")); wordSelection.TypeText(_T("\n\n3、 流速\n")); wordSelection.TypeText(_T(" ")); wdFormula.InsertFormula(WORD_FORMULA23, wordSelection); wordSelection.TypeText(_T("\n 式中:V -- 流速(m/s)\n")); wordSelection.TypeText(_T(" Q -- 管段流量(L/s)\n ")); wordSelection.TypeText(_T(" d -- 管道的计算内径(m)\n")); wordSelection.TypeText(_T("\n4、 沿程阻力损失:\n")); wordSelection.TypeText(_T(" ")); wdFormula.InsertFormula(WORD_FORMULA24, wordSelection); wordSelection.TypeText(_T("\n 式中:h")); font.SetSubscript(2); //处理下标 wordSelection.TypeText(_T("f")); font.SetSubscript(0); wordSelection.TypeText(_T("-- 管道沿程阻力损失(m);1米=10kPa\n")); wordSelection.TypeText(_T(" λ-- 管道沿程阻力损失系数,按下式计算\n")); wordSelection.TypeText(_T(" l -- 管道长度(m)\n")); wordSelection.TypeText(_T(" d -- 管道计算内径(m)\n")); wordSelection.TypeText(_T(" v -- 管内流速(m/s)\n")); wordSelection.TypeText(_T(" g -- 重力加速度(m/s")); font.SetSuperscript(2); //处理上标 wordSelection.TypeText(_T("2")); font.SetSuperscript(0); wordSelection.TypeText(_T(") 取 9.81\n")); wordSelection.TypeText(_T(" ")); wdFormula.InsertFormula(WORD_FORMULA25, wordSelection); wordSelection.TypeText(_T("\n 式中:△ -- 管壁绝对粗糙度(mm),由管材生产厂提供\n")); wordSelection.TypeText(_T(" Re -- 雷诺数\n")); wordSelection.TypeText(_T("\n5、 局部阻力损失:\n")); wordSelection.TypeText(_T(" ")); wdFormula.InsertFormula(WORD_FORMULA26, wordSelection); wordSelection.TypeText(_T("\n 式中:h")); font.SetSubscript(2); //处理下标 wordSelection.TypeText(_T("j")); font.SetSubscript(0); wordSelection.TypeText(_T("--局部阻力损失(mbar)1mbar=100pa=0.1kPa\n")); wordSelection.TypeText(_T(" T -- 局部阻力系数\n")); wordSelection.TypeText(_T(" V")); font.SetSubscript(2); //处理下标 wordSelection.TypeText(_T("x")); font.SetSubscript(0); wordSelection.TypeText(_T(" -- 管道某一x断面处流速(m/s)\n")); wordSelection.TypeText(_T("\n6、 总阻力损失\n")); wordSelection.TypeText(_T(" ")); wdFormula.InsertFormula(WORD_FORMULA27, wordSelection); wordSelection.TypeText(_T("\n\n7、管道某一x断面处的压力:\n")); wordSelection.TypeText(_T(" ")); wdFormula.InsertFormula(WORD_FORMULA28, wordSelection); wordSelection.TypeText(_T("\n 式中: P")); font.SetSubscript(2); //处理下标 wordSelection.TypeText(_T("x")); font.SetSubscript(0); wordSelection.TypeText(_T(" -- 管道某一x断面处的压力(mbar)1mbar=100pa=0.1kPa\n")); wordSelection.TypeText(_T(" h")); font.SetSubscript(2); //处理下标 wordSelection.TypeText(_T("x")); font.SetSubscript(0); wordSelection.TypeText(_T(" -- 雨水斗顶面至计算断面的高度差(m)\n")); wordSelection.TypeText(_T(" v")); font.SetSubscript(2); //处理下标 wordSelection.TypeText(_T("x")); font.SetSubscript(0); wordSelection.TypeText(_T(" -- 管道某一x断面处流速(m/s)\n")); wordSelection.TypeText(_T(" ∑Z")); font.SetSubscript(2); //处理下标 wordSelection.TypeText(_T("x-2")); font.SetSubscript(0); wordSelection.TypeText(_T(" -- 断面处对应最远雨水斗至计算断面的总阻力损失之和(mbar)\n")); wordSelection.TypeText(_T("\n8、压力余量计算公式:\n")); wordSelection.TypeText(_T(" ")); wdFormula.InsertFormula(WORD_FORMULA29, wordSelection); wordSelection.TypeText(_T("\n 式中:△P")); font.SetSubscript(2); //处理下标 wordSelection.TypeText(_T("r")); font.SetSubscript(0); wordSelection.TypeText(_T(" -- 压力余量(mbar)1mbar=100pa=0.1kPa\n")); wordSelection.TypeText(_T(" H--雨水斗顶面与排水管出口的几何高差(m)\n")); wordSelection.TypeText(_T(" V")); font.SetSubscript(2); //处理下标 wordSelection.TypeText(_T("1")); font.SetSubscript(0); wordSelection.TypeText(_T(" -- 排水管出口的管道流速(m/s)\n")); wordSelection.TypeText(_T(" ∑Z -- 最远雨水斗至排水口处的总阻力损失之和(mbar)\n")); wdFormula.CloseFile(); font.SetSize(dSize + 1); font.SetBold(dBold + 1); wordSelection.TypeText(_T("\n三、虹吸雨水水力计算表:\n")); font.SetBold(dBold); font.SetSize(dSize); Selection wSelection2 = wordApplication.GetSelection(); wSelection2.TypeParagraph(); //画表格 int rows(nLen+1), columns(12); Selection wSelection = wordApplication.GetSelection(); Range oRange = wSelection.GetRange(); Tables oTables = activeDocument.GetTables(); _Table oTable = oTables.Add(oRange, rows, columns); Borders oBorders = oTable.GetBorders(); oBorders.SetInsideLineStyle(1); // 设置表格线型 oBorders.SetOutsideLineStyle(1); Columns oColumns; Column oColumn; oColumns = oTable.GetColumns(); oColumn = oColumns.Item(1); oColumn.SetWidth(30, 0); // 0 = wdAdjustNone oColumn = oColumns.Item(2); oColumn.SetWidth(30, 0); oColumn = oColumns.Item(3); oColumn.SetWidth(40, 0); oColumn = oColumns.Item(4); oColumn.SetWidth(40, 0); oColumn = oColumns.Item(5); oColumn.SetWidth(40, 0); oColumn = oColumns.Item(6); oColumn.SetWidth(40, 0); oColumn = oColumns.Item(7); oColumn.SetWidth(40, 0); oColumn = oColumns.Item(8); oColumn.SetWidth(40, 0); oColumn = oColumns.Item(9); oColumn.SetWidth(40, 0); oColumn = oColumns.Item(10); oColumn.SetWidth(50, 0); oColumn = oColumns.Item(11); oColumn.SetWidth(40, 0); oColumn = oColumns.Item(12); oColumn.SetWidth(50, 0); Cell oCell; oCell = oTable.Cell(1, 1); oRange = oCell.GetRange(); oRange.InsertAfter(_T("管段名称")); oCell = oTable.Cell(1, 2); oRange = oCell.GetRange(); oRange.InsertAfter(_T("流量(L/s)")); oCell = oTable.Cell(1, 3); oRange = oCell.GetRange(); oRange.InsertAfter(_T("管长(m)")); oCell = oTable.Cell(1, 4); oRange = oCell.GetRange(); oRange.InsertAfter(_T("管径(mm)")); oCell = oTable.Cell(1, 5); oRange = oCell.GetRange(); oRange.InsertAfter(_T("流速(m/s)")); oCell = oTable.Cell(1, 6); oRange = oCell.GetRange(); oRange.InsertAfter(_T("沿程阻力损失(kPa)")); oCell = oTable.Cell(1, 7); oRange = oCell.GetRange(); oRange.InsertAfter(_T("局部阻力系数")); oCell = oTable.Cell(1, 8); oRange = oCell.GetRange(); oRange.InsertAfter(_T("局部阻力损失(kPa)")); oCell = oTable.Cell(1, 9); oRange = oCell.GetRange(); oRange.InsertAfter(_T("总阻力损失(kPa)")); oCell = oTable.Cell(1, 10); oRange = oCell.GetRange(); oRange.InsertAfter(_T("Σ总阻力损失(kPa)")); oCell = oTable.Cell(1, 11); oRange = oCell.GetRange(); oRange.InsertAfter(_T("高差(m)")); oCell = oTable.Cell(1, 12); oRange = oCell.GetRange(); oRange.InsertAfter(_T("压力(kPa)")); for(int i = 0; i < nLen; i++) { oCell = oTable.Cell(i+2, 1); //管段名称 oRange = oCell.GetRange(); oRange.InsertAfter(m_listCtrl.GetCell(i, 0).GetText()); oCell = oTable.Cell(i+2, 2); //流量(L/s) oRange = oCell.GetRange(); oRange.InsertAfter(m_listCtrl.GetCell(i, 1).GetText()); oCell = oTable.Cell(i+2, 3); //管长(m) oRange = oCell.GetRange(); oRange.InsertAfter(m_listCtrl.GetCell(i, 2).GetText()); oCell = oTable.Cell(i+2, 4); //管径(mm) oRange = oCell.GetRange(); oRange.InsertAfter(m_listCtrl.GetCell(i, 3).GetText()); oCell = oTable.Cell(i+2, 5); //流速(m/s) oRange = oCell.GetRange(); oRange.InsertAfter(m_listCtrl.GetCell(i, 4).GetText()); oCell = oTable.Cell(i+2, 6); //沿程阻力损失(kPa) oRange = oCell.GetRange(); oRange.InsertAfter(m_listCtrl.GetCell(i, 5).GetText()); oCell = oTable.Cell(i+2, 7); //局部阻力系数 oRange = oCell.GetRange(); oRange.InsertAfter(m_listCtrl.GetCell(i, 6).GetText()); oCell = oTable.Cell(i+2, 8); //局部阻力损失(kPa) oRange = oCell.GetRange(); oRange.InsertAfter(m_listCtrl.GetCell(i, 7).GetText()); oCell = oTable.Cell(i+2, 9); //总阻力损失(kPa) oRange = oCell.GetRange(); oRange.InsertAfter(m_listCtrl.GetCell(i, 8).GetText()); oCell = oTable.Cell(i+2, 10); //Σ总阻力损失(kPa) oRange = oCell.GetRange(); oRange.InsertAfter(m_listCtrl.GetCell(i, 9).GetText()); oCell = oTable.Cell(i+2, 11); //高差(m) oRange = oCell.GetRange(); oRange.InsertAfter(m_listCtrl.GetCell(i, 10).GetText()); oCell = oTable.Cell(i+2, 12); //压力(kPa) oRange = oCell.GetRange(); oRange.InsertAfter(m_listCtrl.GetCell(i, 11).GetText()); } COleVariant vtOptional2((long)DISP_E_PARAMNOTFOUND,VT_ERROR); wordSelection = wordApplication.GetSelection(); wordSelection.GoTo(COleVariant((short)3), // 3 = wdGoToLine COleVariant((short)-1),vtOptional2,vtOptional2); // -1 = wdGoToLast wSelection = wordApplication.GetSelection(); wSelection.TypeParagraph(); font.SetSize(dSize + 1); font.SetBold(dBold + 1); wordSelection.TypeText(_T("四、计算结果:\n")); font.SetBold(dBold); font.SetSize(dSize); CString strMaxP, strP; for(it = m_vecData.begin(); it != m_vecData.end(); it++) { SIPHONINFO info = *it; if (info.nType == 1) { continue; } ads_name name; acdbGetAdsName(name, info.id); Entity ent(name); CString strTemp; strTemp = ReadXdata(ent, _T("MaxNP")); if (strTemp == _T("1")) //最大负压管段 { double dMaxP = info.dP; strMaxP.Format(_T("%.2f kPa\n"), dMaxP); } CString strOutPipe = ReadXdata(ent, _T("OutPipe")); if (strOutPipe == _T("1")) //出流端管段 { double dv = info.dv; double dEle = info.dEle, dH2 = info.dH2; double dP = 98.1 * info.dEle - 5 * dv * dv - info.dH2 * 10; //压力余量 dP *= 0.1; strP.Format(_T("%.1f kPa\n"), dP); } } wordSelection.TypeText(_T("管道最大负压值: ") + strMaxP); wordSelection.TypeText(_T("压力余量:") + strP); } void CSiphonRainwaterCalcDlg::SetChamferPipe(std::map &mapPipe) { m_mapChamferPipe.clear(); m_mapChamferPipe = mapPipe; }