// CalcSheetDlg.cpp : implementation file // #include "stdafx.h" //#include #include #include "CalcSheetDlg.h" #include "RainNewCityDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //#ifdef _WIN64 #include"TGAs.h" //#endif extern SSearchPipeList *GetNextCalcWell(SSearchPipeList *pListAll, SSearchPipeList *pDisadvantage); extern int GetFirstPipeDnByQ(double nQ, double nN, double &nRetI, double &nRetV); extern void ImportRainCalcWord(DList &lstNode, DList &lstWell, CCalcRainWellDlg &dlg); extern void DimRainCalcResult(SSearchPipeList *pListAll); extern void GetOtherWellNode(SSearchPipeList *pListAll, DList &lstWell); extern int GetFirstPipeDnByQ2(double nQ, double nN, double nI, double &nRetV); ///////////////////////////////////////////////////////////////////////////// // CCalcRainWellDlg dialog TGridRainCalc::TGridRainCalc() { AppendCol(_T("起始井"), 40); AppendCol(_T("终止井"), 40); AppendCol(_T("管径mm"), 50); AppendCol(_T("坡度‰"), 55); AppendCol(_T("管长m"), 50); AppendCol(_T("汇水面积m2"), 65); AppendCol(_T("总面积"), 55); AppendCol(_T("径流"), 40); AppendCol(_T("重现期"), 38); AppendCol(_T("汇水时间"), 55); AppendCol(_T("流速m/s"), 55); AppendCol(_T("流量L/s"), 55); AppendCol(_T("暴雨强度"), 60); // SetColPosFix(); // SetColFixLength(); SetNoPaste(); // FitLastCol(); GetCol(2).SetComboEdit(); GetCol(3).SetComboEdit(); COLORREF color = RGB(255,0,0); GetCol(2).SetTextColor(color); GetCol(3).SetTextColor(color); COLORREF color2 = RGB(0,0,255);; GetCol(9).SetTextColor(color2); GetCol(10).SetTextColor(color2); GetCol(11).SetTextColor(color2); GetCol(12).SetTextColor(color2); } void TGridRainCalc::OnCellComboString(WDGridCell&cell,CComboBox&combo) { if(cell.GetColIndex()==2){ combo.AddString(_T("200")); // combo.AddString(_T("250")); combo.AddString(_T("300")); // combo.AddString(_T("350")); combo.AddString(_T("400")); // combo.AddString(_T("450")); combo.AddString(_T("500")); combo.AddString(_T("600")); combo.AddString(_T("700")); combo.AddString(_T("800")); combo.AddString(_T("900")); combo.AddString(_T("1000")); combo.AddString(_T("1100")); combo.AddString(_T("1200")); } else if(cell.GetColIndex()==3){ combo.AddString(_T("1")); combo.AddString(_T("2")); combo.AddString(_T("3")); combo.AddString(_T("4")); combo.AddString(_T("5")); combo.AddString(_T("6")); } } void TGridRainCalc::OnBeforeRefresh(WDGridCell&cell) { if(cell.GetColIndex()==10) { double dV = _tstof(cell.GetText()); if(dV > 4.9999){ CDC&dc=GetDC(); COLORREF color=acedGetRGB(6); dc.SetTextColor(color); dc.SetBkMode(TRANSPARENT); } else WDGrid::OnBeforeRefresh(cell); } else if(cell.GetColIndex()==12){ CString csQ = cell.GetText().cs(); if(csQ.Find(_T("错误")) > -1) { CDC&dc=GetDC(); COLORREF color=acedGetRGB(6); dc.SetTextColor(color); dc.SetBkMode(TRANSPARENT); } else WDGrid::OnBeforeRefresh(cell); // CString csColName = cell.GetCol().GetName(); // if(csColName == _T("泄流量")){ // int iRow = cell.GetRowIndex(); // // WDGrid &grid = cell.GetGrid(); // if(this->IsValidRow(iRow)){ // WDGridRow *pRow =this->rowList.GetAt(iRow); // WDGridRow row = *pRow; // CString csQ = row[11].GetText(); // // pRow-> // // (*pRow)[11]; // // // WDGridRow &row = this->GetRow(iRow); // // CString csQ = (*pRow)[11].GetText(); // //// if(_tstof(csQ) < dQ){ //// CDC&dc=GetDC(); //// COLORREF color=acedGetRGB(6); //// dc.SetTextColor(color); //// dc.SetBkMode(TRANSPARENT); //// } // // // } // WDGridRow &row = grid.GetRow(iRow); // CString csQ = row[11].GetText(); // if(_tstof(csQ) < dQ){ // CDC&dc=GetDC(); // COLORREF color=acedGetRGB(6); // dc.SetTextColor(color); // dc.SetBkMode(TRANSPARENT); // } // } // else // WDGrid::OnBeforeRefresh(cell); } else WDGrid::OnBeforeRefresh(cell); } // zxl 2013.12.31 add TGridMaterialN::TGridMaterialN() { AppendCol(_T("管材"), 73); AppendCol(_T("粗糙系数"), 47); SetNoPaste(); GetCol(0).SetReadOnly(true); SetColPosFix(); SetColFixLength(); SetNoPaste(); FitLastCol(); GetCol(0).SetComboSel(); } bool IsStrAllNum(CString csText) { CString sText = csText.SpanIncluding(_T("0123456789.-e")); if ((sText.Find(_T("."), 0) == 0 || sText.Find(_T("-"), 0) == 0) && _tstof(csText) == 0) { return false; } // 小数点可以出现在中间,但只能出现一次 int nIndex = sText.Find(_T("."), 0); if (nIndex > 0) { nIndex = sText.Find(_T("."), ++nIndex); } // 负号可以出现在起始处,但只能出现一次 int nIndex2 = sText.Find(_T("-")); if (nIndex2 == 0) { nIndex2 = sText.Find(_T("-"), 1); } if (csText == sText && nIndex < 0 && nIndex2 <= 0)// 全是数字 { return true; } else { return false; } } bool TGridMaterialN::OnModified(WDGridCell&cell, CString &text) { if (cell.GetCol().GetIndex() == 1) { double dVal = _tstof(text); if (dVal <= 0.0 || !IsStrAllNum(text)) { return false; } } return true; } void TGridMaterialN::OnBeforeRefresh(WDGridCell&cell) { WDGrid::OnBeforeRefresh(cell); } BOOL GetAllCityByProvince(const TCHAR* szProvince, XStringList &lstCity) { CodeBase db; db.read_only = 1; XString fullFile; if(!FindFile(_T("raincity.dbf"), fullFile)) { AfxMessageBox(_T("对不起,没有发现raincity.dbf文件!")); return TRUE; } XDbfTable *pTable = db.Open(fullFile); if(!pTable) return TRUE; CString csTmp, csCity; XStringList lstProvince; for(pTable->MoveFirst();!pTable->IsEOF();pTable->MoveNext()){ GET_FIELD(pTable, _T("province"), csTmp); GET_FIELD(pTable, _T("city"), csCity); if(_tcsicmp(csTmp, szProvince) == 0 && lstCity.Index(csCity) < 0) lstCity.Append(tstrnew(csCity)); } return TRUE; } // zxl 2013.12.27 add double CCalcRainWellDlg::m_nFactor = 0.6; double CCalcRainWellDlg::m_nP = 1; double CCalcRainWellDlg::m_dM = 2; double CCalcRainWellDlg::m_dTime = 15; CCalcRainWellDlg::CCalcRainWellDlg(CWnd* pParent /*=NULL*/) : CAcUiDialog(CCalcRainWellDlg::IDD, pParent), m_ssAll(SS_FREE) { //{{AFX_DATA_INIT(CCalcRainWellDlg) m_csA = _T(""); m_csB = _T(""); m_csC = _T(""); m_csN = _T(""); m_csCity = _T(""); m_csProvince = _T(""); m_csN2 = _T(""); //}}AFX_DATA_INIT m_bCalc = FALSE; m_bReCalc = FALSE; } void CCalcRainWellDlg::DoDataExchange(CDataExchange* pDX) { CAcUiDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CCalcRainWellDlg) DDX_Control(pDX, IDC_LIST_PROVINCE, m_listProvince); DDX_Control(pDX, IDC_LIST_CITY, m_listCity); DDX_Text(pDX, IDC_STATIC_A, m_csA); DDX_Text(pDX, IDC_STATIC_B, m_csB); DDX_Text(pDX, IDC_STATIC_C, m_csC); DDX_Text(pDX, IDC_STATIC_N, m_csN); DDX_Text(pDX, IDC_EDIT_FACTOR, m_nFactor); DDX_Text(pDX, IDC_EDIT_P, m_nP); DDX_LBString(pDX, IDC_LIST_CITY, m_csCity); DDX_LBString(pDX, IDC_LIST_PROVINCE, m_csProvince); DDX_Text(pDX, IDC_EDIT_M, m_dM); DDX_Text(pDX, IDC_EDIT_TIME, m_dTime); DDX_Text(pDX, IDC_STATIC_N2, m_csN2); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CCalcRainWellDlg, CAcUiDialog) //{{AFX_MSG_MAP(CCalcRainWellDlg) ON_BN_CLICKED(IDC_BUTTON_CALC, OnButtonCalc) ON_BN_CLICKED(IDC_BUTTON_WORD, OnButtonWord) ON_BN_CLICKED(IDC_BUTTON_DIM, OnButtonDim) ON_BN_CLICKED(IDC_BUTTON_P, OnButtonP) ON_LBN_SELCHANGE(IDC_LIST_PROVINCE, OnSelchangeListProvince) ON_LBN_SELCHANGE(IDC_LIST_CITY, OnSelchangeListCity) ON_BN_CLICKED(IDC_BUTTON_FACTOR, OnButtonFactor) ON_BN_CLICKED(IDC_BUTTON_NEWCITY, OnButtonNewCity) ON_BN_CLICKED(IDC_BUTTON_HIDE, OnButtonHide) ON_BN_CLICKED(IDC_BUTTON_CALC2, OnButtonCalc2) ON_WM_DESTROY() ON_WM_PAINT() ON_BN_CLICKED(IDC_BTN_CALC_TABLE, OnBtnCalcTable) ON_EN_KILLFOCUS(IDC_EDIT_TIME, OnKillfocusEdtTime) ON_EN_KILLFOCUS(IDC_EDIT_P, OnKillfocusEdtP) ON_EN_KILLFOCUS(IDC_EDIT_M, OnKillfocusEdtM) ON_EN_KILLFOCUS(IDC_EDIT_FACTOR, OnKillfocusEdtFactor) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CCalcRainWellDlg message handlers BOOL CCalcRainWellDlg::OnInitDialog() { CAcUiDialog::OnInitDialog(); XString fullFile; if(!FindFile(_T("raincity.dbf"), fullFile)) { MessageBox(_T("对不起,没有发现raincity.dbf文件!")); return TRUE; } CodeBase db; db.read_only = 1; XDbfTable *pTable = db.Open(fullFile); if(!pTable) return TRUE; CString csTmp; XStringList lstProvince; for(pTable->MoveFirst();!pTable->IsEOF();pTable->MoveNext()){ GET_FIELD(pTable, _T("province"), csTmp); if(lstProvince.Index(csTmp) < 0 && csTmp != _T("")) lstProvince.Append(tstrnew(csTmp)); } for(int i=0;i::iterator it = m_mapMeratialN.begin(); int idx = 0; m_gridN.Clear(); for (; it != m_mapMeratialN.end(); it++) { m_gridN.AppendRow(); m_gridN.GetCell(idx, 0).SetText(it->first); CString csN; csN.Format(_T("%.4f"), it->second); m_gridN.GetCell(idx, 1).SetText(csN); idx++; } m_wndToolTip.Create(this); m_wndToolTip.Activate(true); m_wndToolTip.SetDelayTime(TTDT_INITIAL, 500); CWnd *pWnd1 = GetDlgItem(IDOK); CWnd *pWnd2 = GetDlgItem(IDC_BUTTON_CALC); CWnd *pWnd3 = GetDlgItem(IDC_BUTTON_CALC2); CWnd *pWnd4 = GetDlgItem(IDC_BUTTON_HIDE); m_wndToolTip.AddTool(pWnd1, _T("初算,未知管径,未知坡度")); m_wndToolTip.AddTool(pWnd2, _T("复算,已知管径,已知坡度")); m_wndToolTip.AddTool(pWnd3, _T("复算,已知坡度,计算管径")); m_wndToolTip.AddTool(pWnd4, _T("隐藏对话框")); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CCalcRainWellDlg::OnKillfocusEdtM() { CWnd *pWnd = GetDlgItem(IDC_EDIT_M); if (pWnd != NULL) { CString csText; pWnd->GetWindowText(csText); double dDouble = _tstof(csText); if (dDouble <= 0.0 || !IsStrAllNum(csText)) { UpdateData(FALSE); } else { UpdateData(TRUE); } } } void CCalcRainWellDlg::OnKillfocusEdtP() { CWnd *pWnd = GetDlgItem(IDC_EDIT_P); if (pWnd != NULL) { CString csText; pWnd->GetWindowText(csText); double dDouble = _tstof(csText); if (dDouble <= 0.0 || !IsStrAllNum(csText)) { UpdateData(FALSE); } else { UpdateData(TRUE); } } } void CCalcRainWellDlg::OnKillfocusEdtFactor() { CWnd *pWnd = GetDlgItem(IDC_EDIT_FACTOR); if (pWnd != NULL) { CString csText; pWnd->GetWindowText(csText); double dDouble = _tstof(csText); if (dDouble <= 0.0 || !IsStrAllNum(csText)) { UpdateData(FALSE); } else { UpdateData(TRUE); } } } void CCalcRainWellDlg::OnKillfocusEdtTime() { CEdit *pWnd = (CEdit *)GetDlgItem(IDC_EDIT_TIME); if (pWnd != NULL) { CString csText; pWnd->GetWindowText(csText); double dDouble = _tstof(csText); if (dDouble <= 0.0 || !IsStrAllNum(csText)) { pWnd->SetSel(0, -1); UpdateData(FALSE); } else { UpdateData(TRUE); } } } void CCalcRainWellDlg::OnPaint() { CAcUiDialog::OnPaint(); if (m_gridN.IsWindowVisible()) { m_gridN.SetRedraw(TRUE); } } //把树结构的数据转化为DLIST链表结构 void CCalcRainWellDlg::TransWellListData(SSearchPipeList *pListAll, DList &lstWellSys) { SRainCalcData *pList = new SRainCalcData(); pList->m_iDn = pListAll->m_iDn; if(pListAll->m_iType == 0) pList->m_bIsWell = FALSE; else pList->m_bIsWell = TRUE; pList->m_csName = pListAll->m_csName; pList->m_nI = pListAll->m_nI; pList->m_ID = pListAll->m_ID; pList->m_nLength = pListAll->m_nLength; pList->m_nArea = pListAll->m_nDang; pList->m_nAllArea = pListAll->m_nStartPress; lstWellSys.Append(pList); long len = pListAll->m_lstNode.Length(); for(long i=0;im_lstNode[i]; TransWellListData(pList, lstWellSys); } } //得到下一个计算支路的起点节点 根据流量是否为0且最远 SSearchPipeList *CCalcRainWellDlg::GetNextWell(SSearchPipeList *pListAll, SSearchPipeList *pDisadvantage, DList &lstData) { AcDbObjectId id = NULL; id = pListAll->m_ID; BOOL bFind = FALSE; for(int j=0;jm_ID == id){ bFind = TRUE; break; } } double nCurPipeLength(0); if(!bFind && pListAll->m_iType == 3){ nCurPipeLength = pListAll->m_nLength; if(pDisadvantage){ if(nCurPipeLength > pDisadvantage->m_nLength) pDisadvantage = pListAll; } else pDisadvantage = pListAll; //条件3: 临时节点为空 } int len = pListAll->m_lstNode.Length(); for(long i=0;im_lstNode[i]; pDisadvantage = GetNextWell(pList, pDisadvantage, lstData); } return pDisadvantage; } void CCalcRainWellDlg::UpdateGrid() { long iCurRow = m_grid.GetCurRowIndex(); m_grid.Clear(); DList lstData; SSearchPipeList *pNodeLong = m_pNodeLong; while(pNodeLong){//主干网 if(pNodeLong->m_iType == 0 || pNodeLong->m_iType == 3 || pNodeLong->m_iType == 1){ SRainCalcData *pList = new SRainCalcData(); pList->m_iDn = pNodeLong->m_iDn; if(pNodeLong->m_iType == 0) pList->m_bIsWell = FALSE; else if(pNodeLong->m_iType == 3 || pNodeLong->m_iType == 1) pList->m_bIsWell = TRUE; pList->m_csName = pNodeLong->m_csName; pList->m_nI = pNodeLong->m_nI; pList->m_nTime = pNodeLong->m_nLost; pList->m_nV = pNodeLong->m_nV; pList->m_nQ = pNodeLong->m_nPipeQ; pList->m_ID = pNodeLong->m_ID; pList->m_nFactor = (double)(pNodeLong->m_iNum) / 1000; pList->m_iP = pNodeLong->m_iSpare; if(pList->m_nFactor < 0.0001) //没有输入,就按默认走 pList->m_nFactor = m_nFactor; if(pList->m_iP < 0.0001) pList->m_iP = (int)m_nP; pList->m_nLength = pNodeLong->m_nLength; pList->m_nArea = pNodeLong->m_nDang; pList->m_nAllArea = pNodeLong->m_nStartPress; pList->m_dI = pNodeLong->m_nSpare; lstData.Append(pList); } if(pNodeLong->m_pPrevious) pNodeLong = pNodeLong->m_pPrevious; else break; } SSearchPipeList *pNodeNext = GetNextWell(m_pListAll, NULL, lstData); while(pNodeNext){ SSearchPipeList *pNodeLong = pNodeNext; while(pNodeLong){ BOOL bFind = FALSE; for(int j=0;jm_ID == pNodeLong->m_ID){ bFind = TRUE; break; } } if(pNodeLong->m_iType == 0 || pNodeLong->m_iType == 3 || pNodeLong->m_iType == 1){ SRainCalcData *pList = new SRainCalcData(); pList->m_iDn = pNodeLong->m_iDn; if(pNodeLong->m_iType == 0) pList->m_bIsWell = FALSE; else pList->m_bIsWell = TRUE; pList->m_csName = pNodeLong->m_csName; pList->m_nI = pNodeLong->m_nI; pList->m_nTime = pNodeLong->m_nLost; pList->m_nV = pNodeLong->m_nV; pList->m_nQ = pNodeLong->m_nPipeQ; pList->m_ID = pNodeLong->m_ID; pList->m_nFactor = (double)(pNodeLong->m_iNum) / 1000; if(pList->m_nFactor < 0.0001) //没有输入,就按默认走 pList->m_nFactor = m_nFactor; pList->m_iP = pNodeLong->m_iSpare; if(pList->m_iP < 0.0001) pList->m_iP = (int)m_nP; pList->m_nLength = pNodeLong->m_nLength; pList->m_nArea = pNodeLong->m_nDang; pList->m_nAllArea = pNodeLong->m_nStartPress; pList->m_dI = pNodeLong->m_nSpare; lstData.Append(pList); } if(bFind) break; if(pNodeLong->m_pPrevious) pNodeLong = pNodeLong->m_pPrevious; else break; } pNodeNext = GetNextWell(m_pListAll, NULL, lstData); } m_arRainStom.RemoveAll(); int idx = 0; bool bInitMap = true; if (!m_mapMeratialN.empty()) { bInitMap = false; } for(int i=0;im_bIsWell){ //井 if(i == lstData.Length()-2) break; m_grid.AppendRow(); CString csName1 = lstData[i]->m_csName; CString csName2 = lstData[i+2]->m_csName; if(csName1 == _T("") && csName2 == _T("")) continue; CString csArea, csAllArea, csFactor, csQ, csTime, csP, csI; m_grid.GetCell(idx, 0).SetText(csName1); m_grid.GetCell(idx, 1).SetText(csName2); csArea.Format(_T("%.1f"), lstData[i]->m_nArea); csTime.Format(_T("%.2f"), lstData[i]->m_nTime); csQ.Format(_T("%.2f"), lstData[i]->m_nQ); csAllArea.Format(_T("%.1f"), lstData[i]->m_nAllArea); csFactor.Format(_T("%.2f"), lstData[i]->m_nFactor); csP.Format(_T("%d"), lstData[i]->m_iP); csI.Format(_T("%.2f"), lstData[i]->m_dI); //暴雨强度 m_grid.GetCell(idx, 5).SetText(csArea); m_grid.GetCell(idx, 6).SetText(csAllArea); m_grid.GetCell(idx, 9).SetText(csTime); m_grid.GetCell(idx, 7).SetText(csFactor); m_grid.GetCell(idx, 8).SetText(csP); m_grid.GetCell(idx, 11).SetText(csQ); // m_grid.GetCell(idx, 11).SetText(csQ); if(!m_bReCalc) m_grid.GetCell(idx, 12).SetText(csI); else m_arRainStom.Add(csI); } else{ //管 int iDn = lstData[i]->m_iDn; CString csDn, csPipeLen, csI, csV; csDn.Format(_T("%d"), iDn); csV.Format(_T("%.2f"), lstData[i]->m_nV); csI.Format(_T("%.3f"), lstData[i]->m_nI); csPipeLen.Format(_T("%.2f"), lstData[i]->m_nLength); m_grid.GetCell(idx, 2).SetText(csDn); m_grid.GetCell(idx, 3).SetText(csI); m_grid.GetCell(idx, 4).SetText(csPipeLen); m_grid.GetCell(idx, 10).SetText(csV); double dTmpv = lstData[i]->m_nV; double nTempQ = (0.25*iDn*iDn*PI)*lstData[i]->m_nV/1000; double nQ = lstData[i]->m_nQ; csI.Format(_T("%.2f"), nTempQ); if(m_bReCalc){ if(nTempQ < lstData[i]->m_nQ){ csI = csI + _T("错误"); } m_grid.GetCell(idx, 12).SetText(csI); } idx++; //zxl 2013.12.30 add if (bInitMap) { double nN(0.009); CString csMat; OPENOBJ_BEGIN(lstData[i]->m_ID, AcDb::kForRead, TDbPipe, pPipe); if(pPipe) { csMat = GetPipeMaterialByIdx(pPipe->GetMaterial()); if(csMat.Find(_T("混凝土管")) > -1 || csMat.Find(_T("铸铁")) > -1) nN = 0.013; else if(csMat.Find(_T("钢")) > -1) nN = 0.012; m_mapMeratialN.insert(std::make_pair(csMat, nN)); } OPENOBJ_END(); } // if(nTempQ < lstData[i]->m_nQ || lstData[i]->m_nV > 5){ // CString csTmp; // csTmp.Format(_T("%s管径过小,泄流量不满足计算流量要求!"), lstData[i]->m_csName); // // // m_grid.GetCell(idx, 2) // // MessageBox(csTmp); // } } } m_grid.SelectRow(iCurRow, TRUE); } void CCalcRainWellDlg::OnCancel() { UpdateData(TRUE); CRegProperty regProp(GetRegLocation(), _T("TWTConfig")); regProp.SetTopRootKey(HKEY_CURRENT_USER); regProp.SetValue(_T("CurProvince"), m_csProvince); regProp.SetValue(_T("CurCity"), m_csCity); CAcUiDialog::OnCancel(); } //初算 void CCalcRainWellDlg::OnOK() { UpdateData(TRUE); // if(m_csCity == _T("重庆")){ 2010-6-2 sr 删除,因为09技术措施有新公式 // double nB = m_nP; // nB = pow(nB, 0.076)* 12.8; // m_csB.Format(_T("%.3f"), nB); // UpdateData(FALSE); // } if(m_csCity == _T("南充")){ double nB = m_nP; nB = pow(nB, 0.0167)* 7.8786; m_csB.Format(_T("%.3f"), nB); UpdateData(FALSE); } if(m_csCity == _T("")){ MessageBox(_T("没有选择城市!")); return; } m_grid.GetCol(12).SetName(_T("暴雨强度")); m_bCalc = TRUE; m_bReCalc = FALSE; // zxl 2013.12.31 add m_mapMeratialN.clear(); for(m_gridN.MoveToFirst(); !m_gridN.IsOut(); m_gridN.MoveToNext()) { WDGridRow *pRow = m_gridN.CurRow(); CString csName = (*pRow)[0].GetText().cs(); CString csN = (*pRow)[1].GetText().cs(); m_mapMeratialN.insert(std::make_pair(csName, _tstof(csN))); } ResetList(m_pListAll); m_pNodeLong->m_nLost = m_dTime; CalcRainNode(m_pNodeLong, 0); //主干线计算 SSearchPipeList *pNodeNext = GetNextCalcWell(m_pListAll, NULL); while(pNodeNext){ CalcRainNode(pNodeNext, 0);//支路计算 pNodeNext = GetNextCalcWell(m_pListAll, NULL); } UpdateGrid(); } //返回用户选择的最远井所在链表的位置 // SSearchPipeList *GetPipeNodeByName(SSearchPipeList *pListAll, CString csName, SSearchPipeList *pNode) // { // AcDbObjectId id = NULL; // id = pListAll->m_ID; // if(pListAll->m_iType == 0){ // if(pListAll->m_csName == csName) // return pListAll; // } // long len = pListAll->m_lstNode.Length(); // for(long i=0;im_lstNode[i]; // pNode = GetPipeNodeByName(pList, csName, pNode); // } // return pNode; // } void CCalcRainWellDlg::ResetList(SSearchPipeList *pListAll) { pListAll->m_nPipeQ = 0; pListAll->m_nLost = 0; //汇水时间,每次计算都根据对话框重新计算 long len = pListAll->m_lstNode.Length(); for(long i=0;im_lstNode[i]; ResetList(pList); } } //复算2 已知坡度计算管径 void CCalcRainWellDlg::OnButtonCalc2() { UpdateData(TRUE); // if(m_csCity == _T("重庆")){ // double nB = m_nP; // nB = pow(nB, 0.076)* 12.8; // m_csB.Format(_T("%.3f"), nB); // UpdateData(FALSE); // } // else if(m_csCity == _T("南充")){ double nB = m_nP; nB = pow(nB, 0.0167)* 7.8786; m_csB.Format(_T("%.3f"), nB); UpdateData(FALSE); } if(m_csCity == _T("")){ MessageBox(_T("没有选择城市!")); return; } m_grid.GetCol(12).SetName(_T("暴雨强度")); for(m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext()){ WDGridRow *pRow = m_grid.CurRow(); CString csName1 = (*pRow)[0].GetText().cs(); CString csName2 = (*pRow)[1].GetText().cs(); CString csI = (*pRow)[3].GetText().cs(); if(csName1 == _T("")) break; csName1 = csName1 + _T("-") + csName2; if(fabs(_tstof(csI)) < 1e-9){ MessageBox(_T("雨水计算,坡度不能为0!")); return; } SSearchPipeList *pList = GetPipeNodeByName(m_pListAll, csName1, NULL); if(pList != NULL){ pList->m_nI = _tstof(csI); } } // zxl 2013.12.31 add m_mapMeratialN.clear(); for(m_gridN.MoveToFirst(); !m_gridN.IsOut(); m_gridN.MoveToNext()) { WDGridRow *pRow = m_gridN.CurRow(); CString csName = (*pRow)[0].GetText().cs(); CString csN = (*pRow)[1].GetText().cs(); m_mapMeratialN.insert(std::make_pair(csName, _tstof(csN))); } ResetList(m_pListAll); CalcRainNode(m_pNodeLong, 2); //主干线计算 m_bCalc = TRUE; m_bReCalc = FALSE; SSearchPipeList *pNodeNext = GetNextCalcWell(m_pListAll, NULL); while(pNodeNext){ CalcRainNode(pNodeNext, 2);//支路计算 pNodeNext = GetNextCalcWell(m_pListAll, NULL); } UpdateGrid(); } //复算 void CCalcRainWellDlg::OnButtonCalc() { UpdateData(TRUE); if(m_csCity == _T("重庆")){ double nB = m_nP; nB = pow(nB, 0.076)* 12.8; m_csB.Format(_T("%.3f"), nB); UpdateData(FALSE); } else if(m_csCity == _T("南充")){ double nB = m_nP; nB = pow(nB, 0.0167)* 7.8786; m_csB.Format(_T("%.3f"), nB); UpdateData(FALSE); } if(m_csCity == _T("")){ MessageBox(_T("没有选择城市!")); return; } m_grid.GetCol(12).SetName(_T("泄流量")); for(m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext()){ WDGridRow *pRow = m_grid.CurRow(); CString csName1 = (*pRow)[0].GetText().cs(); CString csName2 = (*pRow)[1].GetText().cs(); CString csDn = (*pRow)[2].GetText().cs(); CString csI = (*pRow)[3].GetText().cs(); if(csName1 == _T("")) break; csName1 = csName1 + _T("-") + csName2; if(fabs(_tstof(csI)) < 1e-9){ MessageBox(_T("雨水计算,坡度不能为0!")); return; } SSearchPipeList *pList = GetPipeNodeByName(m_pListAll, csName1, NULL); if(pList != NULL){ pList->m_iDn = _ttoi(csDn); pList->m_nI = _tstof(csI); } } // zxl 2013.12.31 add m_mapMeratialN.clear(); for(m_gridN.MoveToFirst(); !m_gridN.IsOut(); m_gridN.MoveToNext()) { WDGridRow *pRow = m_gridN.CurRow(); CString csName = (*pRow)[0].GetText().cs(); CString csN = (*pRow)[1].GetText().cs(); m_mapMeratialN.insert(std::make_pair(csName, _tstof(csN))); } ResetList(m_pListAll); CalcRainNode(m_pNodeLong, 1); //主干线计算 m_bCalc = TRUE; m_bReCalc = TRUE; SSearchPipeList *pNodeNext = GetNextCalcWell(m_pListAll, NULL); while(pNodeNext){ CalcRainNode(pNodeNext, 1);//支路计算 pNodeNext = GetNextCalcWell(m_pListAll, NULL); } UpdateGrid(); } //《给水排水设计手册》红皮 P436 满流 double CalcPipeV(double nDn, double nI, double n) { double nTemp = 1 / n; nI = pow(nI, 0.5); double nR = pow(0.25*nDn, 2.0/3.0); return nTemp*nI*nR; } //《给水排水设计手册》红皮 P436 满流 double CalcPipeVByQ(double nPipeQ, double nDn) { double nRet(-1); double nRadius = nDn / 1000 / 2; double dArea = PI * nRadius * nRadius; nRet = nPipeQ / dArea / 1000; return nRet; } //计算管道泄流量 double CalcDesignPipeQ(double nDn, double nI, double n) { double nRet(-1); double dV = CalcPipeV(nDn/ 1000, nI/ 1000, n); double nRadius = nDn / 1000 / 2; double dArea = PI * nRadius * nRadius; nRet = dArea*dV*1000; return nRet; } //《给水排水设计手册》红皮 P436 满流 double CalcPipeV(double nQ, double nDn, double nI, double n) { double nRet(-1); double nTemp = 1 / n; nI = pow(nI, 0.5); double nR = pow(0.25*nDn, 2.0/3.0); nRet = nTemp*nI*nR; double nTempQ = (0.25*nDn*nDn*PI)*nRet; if(nTempQ < nQ && nDn < 2.750) return -1; return nRet; // double nRet(-1); // double nArea(0); // nArea = PI/4.0 * nDn * nDn; // nRet = nQ / nArea; // return nRet; } //主计算模块 // mode == 0 初算 计算管径 // mode == 1 复算 不计算管径, 从图上读管径 void CCalcRainWellDlg::CalcRainNode(SSearchPipeList *pListLast, int mode) { double A = _tstof(m_csA); double B = _tstof(m_csB); double C = _tstof(m_csC); double D = _tstof(m_csN); double P = m_nP; if(m_csCity == _T("成都")) { B = pow(m_nP, 0.231) * 12.8; } else if(m_csCity == _T("贵阳")) { B = pow(m_nP, 0.031) * 9.35; } double nM = m_dM; //折减系数,暗管折减系数m=2,明渠折减系数m=l.2; 这里都认为是2 AcDbObjectId id = NULL; id = pListLast->m_ID; if(pListLast->m_iType == 3 || pListLast->m_iType == 1){ double nTime = pListLast->m_nLost; double nFactor = (double)(pListLast->m_iNum) / 1000; if(nFactor < 0.0001) nFactor = m_nFactor; if(nTime < 0.001){ //不是起始井 int len = pListLast->m_lstNode.Length(); for(int i=0;im_lstNode[i]; if(pList->m_nLost > 0){ nTime = pList->m_nLost; pListLast->m_nLost = nTime; break; } } } if(nTime < 0.001){ //是起始井, 但不是最远,默认随最远井 nTime = m_dTime; if(pListLast->m_nLost < 1) pListLast->m_nLost = nTime; } double nArea = pListLast->m_nStartPress; double i = (log10(P) * C + 1) * A; i = i / pow((nTime + B), D); double q = i * 10000 / 60; //把mm/min -> 升/秒/公顷 double nQ = q * nFactor * nArea / 10000; if(nArea < 0.001) nQ = -1; pListLast->m_nPipeQ = nQ; pListLast->m_nSpare = q; //暴雨强度 2007-12-13 应蒋工要求加入 } else if(pListLast->m_iType == 0){ double nRadius(0), nPipeLen(0), nI(0); int iDn(0); double nN(0.009);//粗糙系数 OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipe, pPipe); if(pPipe){ nPipeLen = pPipe->Length(); // if(!DocGetMeterUnitDraw()) // nPipeLen = nPipeLen/1000; CString csMat = GetPipeMaterialByIdx(pPipe->GetMaterial()); // zxl 2013.12.30 modify // if(csMat.Find(_T("混凝土管")) > -1) //《给排水设计手册》 P764 满流 // nN = 0.013; // else if(csMat.Find(_T("铸铁")) > -1) // nN = 0.013; // else if(csMat.Find(_T("钢")) > -1) // nN = 0.012; // else if(csMat.Find(_T("PVC")) > -1 || csMat.Find(_T("塑料")) > -1) // nN = 0.009; std::map::iterator it = m_mapMeratialN.find(csMat); if (it != m_mapMeratialN.end()) { nN = it->second; } } OPENOBJ_END(); if(pListLast->m_lstNode.Length() == 1){ SSearchPipeList *pList = pListLast->m_lstNode[0]; //得到后节点 double nPipeQ = pList->m_nPipeQ; double nV(0), nI(0); if(mode == 0){ //初算 iDn = GetFirstPipeDnByQ(nPipeQ, nN, nI, nV); nI = nI * 1000; int iDnBig(iDn); //检查前管的管径是否大于本管,如果大于则本管也按大的管径 2010-5-11 sr 增加这个考虑 王峻提 if(pList->m_lstNode.Length() > 0){ for(int mm=0;mm< pList->m_lstNode.Length();mm++){ SSearchPipeList *pList4 = pList->m_lstNode[mm]; if(pList4->m_iDn > iDnBig) iDnBig = pList4->m_iDn; } if(iDnBig > iDn){ iDn = iDnBig; nRadius = (double)iDn / 1000; nV = CalcPipeV(nRadius, nI/ 1000, nN); } } } else if(mode == 1){ //复算1 //以下是7.5的程序 // iDn = pListLast->m_iDn; // nI = pListLast->m_nI; // double nRadius = (double)iDn / 1000; // nV = CalcPipeV(nRadius, nI/ 1000, nN); //以下是7.0的程序,蒋工认为管径增加后,流速复算不能变大 // iDn = pListLast->m_iDn; // nI = pListLast->m_nI; // double nV2(0); // int iDnTmp = GetFirstPipeDnByQ2(nPipeQ, nN, nI, nV2); // if(iDnTmp == iDn){ // nRadius = (double)iDn / 1000; // nV = CalcPipeV(nRadius, nI/ 1000, nN); // } // else{ // //计算流量的公式2:《给排水设计手册》P766 Q = V*A (A = PI/4*d*d) // //假定复算2得到的管径是满流管径,nV2也就是满流流速 // //满流情况比非满流情况,计算得出非满流的流速V // nV = ((double)iDnTmp/(double)iDn)*((double)iDnTmp/(double)iDn)*nV2; // } //2008-1-10 蒋工推荐方法:V=Q/A A仍然是满流 iDn = pListLast->m_iDn; nI = pListLast->m_nI; nV = CalcPipeVByQ(nPipeQ, (double)iDn); // double dCalcQ = CalcDesignPipeQ((double)iDn, nI, nN); // double dTmp = fabs(dCalcQ - nPipeQ); // if(dTmp > nPipeQ*0.2){ // // nV = CalcPipeV((double)iDn/ 1000, nI/ 1000, nN); // } double nV2(0); int iDnTmp = GetFirstPipeDnByQ2(nPipeQ, nN, nI, nV2); // if(iDnTmp == iDn){ nRadius = (double)iDn / 1000; nV = CalcPipeV(nRadius, nI/ 1000, nN); // } } else if(mode == 2){ //复算2 nI = pListLast->m_nI; iDn = GetFirstPipeDnByQ2(nPipeQ, nN, nI, nV); int iDnBig(iDn); //检查前管的管径是否大于本管,如果大于则本管也按大的管径 if(pList->m_lstNode.Length() > 0){ for(int mm=0;mm< pList->m_lstNode.Length();mm++){ SSearchPipeList *pList4 = pList->m_lstNode[mm]; if(pList4->m_iDn > iDnBig) iDnBig = pList4->m_iDn; } if(iDnBig > iDn){ iDn = iDnBig; nRadius = (double)iDn / 1000; nV = CalcPipeV(nRadius, nI/ 1000, nN); } } } pListLast->m_nPipeQ = nPipeQ; pListLast->m_iDn = iDn; pListLast->m_nI = nI; pListLast->m_nV = nV; double nTime = nPipeLen / nV / 60 * nM + pList->m_nLost; pListLast->m_nLost = nTime; pListLast->m_nDang = pList->m_nDang; } } if(pListLast->m_pPrevious){ CalcRainNode(pListLast->m_pPrevious, mode); } } void CCalcRainWellDlg::OnButtonWord() { SSearchPipeList *pNodeLong = m_pNodeLong; DList lstNode, lstWell; while(pNodeLong){ if(pNodeLong->m_iType == 0 || pNodeLong->m_iType == 3){ SSearchPipeList *pNodeNew = new SSearchPipeList(); pNodeNew->m_iDn = pNodeLong->m_iDn; pNodeNew->m_ID = pNodeLong->m_ID; pNodeNew->m_csName = pNodeLong->m_csName; pNodeNew->m_nLength = pNodeLong->m_nLength; pNodeNew->m_nPipeQ = pNodeLong->m_nPipeQ; pNodeNew->m_nDang = pNodeLong->m_nDang; pNodeNew->m_nStartPress = pNodeLong->m_nStartPress; pNodeNew->m_nI = pNodeLong->m_nI; pNodeNew->m_nV = pNodeLong->m_nV; pNodeNew->m_nLost = pNodeLong->m_nLost; pNodeNew->m_nSpare = pNodeLong->m_nSpare; if(pNodeLong->m_iType == 3) lstWell.Append(pNodeNew); else lstNode.Append(pNodeNew); } if(pNodeLong->m_pPrevious) pNodeLong = pNodeLong->m_pPrevious; else break; } GetOtherWellNode(m_pListAll, lstWell); ImportRainCalcWord(lstNode, lstWell, *this); } //void CCalcRainWellDlg::OnButtonDim() //{ // UpdateData(TRUE); // BeginEditorCommand(); // // XPoint ptLow, ptUp; // m_ssAll.GetExtend(ptLow, ptUp); // AssureInCurrentView(ptLow, ptUp); // // TCHAR szTmp[32]; // DimRainCalcResult(m_pListAll); // actrTransactionManager->flushGraphics(); //acad 刷新 // // ads_getstring(NULL, _T("\n数据已经赋回图面,n按任意键返回对话框:<返回>"), szTmp); // // CompleteEditorCommand(); // //} //extern void UpdateMultDim(); extern bool g_bPipeShow; // cet 2012.1.9 add 图面赋值控制变量 extern int g_nSelType; // cet 2012.1.9 add 图面赋值控制变量 void CCalcRainWellDlg::OnButtonDim() { if(!m_bCalc) return; UpdateData(TRUE); BeginEditorCommand(); XPoint ptLow, ptUp; m_ssAll.GetExtend(ptLow, ptUp); AssureInCurrentView(ptLow, ptUp); TCHAR szTmp[32]; // cet 2012.1.9 add g_bPipeShow = false; g_nSelType = -1; DimRainCalcResult(m_pListAll); acedRedraw(0,0); // cet 2012.1.9 add 刷新清除显示管线时的X UpdateMultDim(); actrTransactionManager->flushGraphics(); //acad 刷新 ads_getstring(NULL, _T("\n数据已经赋回图面,按任意键返回对话框:<返回>"), szTmp); CompleteEditorCommand(); } void CCalcRainWellDlg::OnButtonNewCity() { CTemporaryResourceOverride vTemp; CRainNewCityDlg dlg; dlg.m_csProvince = m_csProvince; if(dlg.DoModal() != IDOK || dlg.m_csCity == _T("") || dlg.m_csA == _T("") || dlg.m_csB == _T("") || dlg.m_csC == _T("") || dlg.m_csN == _T("")) return; XStringList lstCity; GetAllCityByProvince(m_csProvince, lstCity); for(int i=0;iAppendBegin(); SET_FIELD(pTable, _T("province"), (const TCHAR*)m_csProvince); SET_FIELD(pTable, _T("city"), (const TCHAR*)dlg.m_csCity); SET_FIELD(pTable, _T("A"), (const TCHAR*)dlg.m_csA); SET_FIELD(pTable, _T("B"), (const TCHAR*)dlg.m_csB); SET_FIELD(pTable, _T("C"), (const TCHAR*)dlg.m_csC); SET_FIELD(pTable, _T("D"), (const TCHAR*)dlg.m_csN); pTable->AppendEnd(); OnSelchangeListProvince(); } void CCalcRainWellDlg::OnButtonP() { // zxl 2011.08.16 modify 更改显示方式 // UpdateData(TRUE); // CString csTmp; // if(m_csCity == _T("北京")) // csTmp = _T("一般地形居住区或城市区间道路:0.33~0.5\n 不利地形的居住区域或一般城市道路:0.5~1\n城市干道、中心区1~2\n特殊重要地区或盆地3~10\n立交路口1~3"); // else if(m_csCity == _T("上海")) // csTmp = _T("市区:0.5~1\n 工业区的生活区:1\n厂区一般车间:2\n大型重要车间:5"); // else if(m_csCity == _T("无锡")) // csTmp = _T("小巷:0.33\n 一般:0.5\n新建区:1"); // else if(m_csCity == _T("常州")) // csTmp = _T("常州:1"); // else if(m_csCity == _T("南京")) // csTmp = _T("南京:0.5~1"); // else if(m_csCity == _T("杭州")) // csTmp = _T("杭州:0.33~1"); // else if(m_csCity == _T("宁波")) // csTmp = _T("宁波:0.5~1"); // else if(m_csCity == _T("广州")) // csTmp = _T("1~2,主要地区2~20"); // else if(m_csCity == _T("长沙")) // csTmp = _T("长沙:0.5~1"); // else if(m_csCity == _T("成都")) // csTmp = _T("成都:1"); // else if(m_csCity == _T("重庆")) // csTmp = _T("小面积小区:1~2\n面积(30~50)×100平方米小区:5\n大面积或重要地区:5~10"); // else if(m_csCity == _T("天津")) // csTmp = _T("天津:1"); // else if(m_csCity == _T("贵阳")) // csTmp = _T("贵阳:3"); // else if(m_csCity == _T("哈尔滨")) // csTmp = _T("哈尔滨:0.5~1"); // else if(m_csCity == _T("吉林")) // csTmp = _T("吉林:1"); // else if(m_csCity == _T("营口")) // csTmp = _T("郊区:0.5, 市区:1"); // else if(m_csCity == _T("白城")) // csTmp = _T("白城:1"); // else if(m_csCity == _T("兰州")) // csTmp = _T("兰州:0.5~1"); // else if(m_csCity == _T("西宁")) // csTmp = _T("西宁:0.33~0.5"); // else if(m_csCity == _T("西安")) // csTmp = _T("西安:1~3"); // else if(m_csCity == _T("唐山")) // csTmp = _T("唐山:1"); // else if(m_csCity == _T("保定")) // csTmp = _T("保定:1~2"); // else if(m_csCity == _T("昆明")) // csTmp = _T("昆明:0.5"); // else // return; // AfxMessageBox(csTmp); RBList rbCmd=ads_buildlist(RTSTR, _T("IShowRecurCyle"), NULL); resbuf *rbRes=NULL; if(ads_invoke(rbCmd, &rbRes)==RTNORM && rbRes) { ads_relrb(rbRes); return; } return; } void CCalcRainWellDlg::OnSelchangeListProvince() { UpdateData(TRUE); XStringList lstCity; GetAllCityByProvince(m_csProvince, lstCity); m_listCity.ResetContent(); for(int i=0;iMoveFirst();!pTable->IsEOF();pTable->MoveNext()){ GET_FIELD(pTable, _T("province"), csTmp); GET_FIELD(pTable, _T("city"), csCity); if(_tcsicmp(csTmp, m_csProvince) == 0 && _tcsicmp(csCity, m_csCity) == 0){ GET_FIELD(pTable, _T("A"), m_csA); GET_FIELD(pTable, _T("B"), m_csB); GET_FIELD(pTable, _T("C"), m_csC); GET_FIELD(pTable, _T("D"), m_csN); if(m_csCity == _T("成都")) { m_csB = _T("12.8P"); m_csN2 = _T("0.231"); } else if(m_csCity == _T("贵阳")) { m_csB = _T("9.35P"); m_csN2 = _T("0.031"); } else m_csN2 = _T(""); UpdateData(FALSE); return; } } } void CCalcRainWellDlg::OnButtonFactor() { // cet 2010.9.25 modify // CString csTmp; // csTmp = _T("径 流 系 数\n\n"); // csTmp += _T("地面种类 ψ\n"); // csTmp += _T("各种屋面、混凝土和沥青路面 0.9\n"); // csTmp += _T("大块石铺砌路面和沥青表面处理的碎石路面 0.6\n"); // csTmp += _T("级配碎石路面 0.45\n"); // csTmp += _T("非铺砌土地面 0.3\n"); // csTmp += _T("公园或绿地 0.15\n\n"); // csTmp += _T("综 合 径 流 系 数\n"); // csTmp += _T("市区 0.5 ~ 0.8\n"); // csTmp += _T("郊区 0.4 ~ 0.6\n"); // AfxMessageBox(csTmp); RBList rbCmd=ads_buildlist(RTSTR, _T("IShowRunoffQuotie"), NULL); resbuf *rbRes=NULL; if(ads_invoke(rbCmd, &rbRes)==RTNORM && rbRes) { ads_relrb(rbRes); return; } return; } void CCalcRainWellDlg::OnButtonHide() { long idx = m_grid.GetCurRowIndex(); CString csName1; if(idx > -1){ WDGridRow *pRow = &m_grid.GetRow(idx); if(pRow) csName1 = (*pRow)[0].GetText(); } if(csName1 != _T("")){ RBList rbMask(RTDXF0, _T("ATS_WELL"), NULL); PickSet ss(SS_FREE); ss.Get(_T("X"), NULL, NULL, rbMask); long len = ss.Length(); for(long i=0;iGetWellName(); if(_tcsicmp(csName, csName1) == 0){ XPoint ptCen = pEquip->GetLocation(); arxZoomTo(ptCen, 10*pEquip->GetPScale(), 10*pEquip->GetPScale()); double nDist = pEquip->GetPScale(); XPoint p1, p2, p3, p4; ads_polar(ptCen, 0, nDist, p1); ads_polar(p1, PI/2, nDist, p1); ads_polar(ptCen, PI, nDist, p2); ads_polar(p2, PI/2, -nDist, p2); ads_grdraw(p1, p2, 2, 0); ads_polar(ptCen, PI/2, nDist, p3); ads_polar(p3, PI, nDist, p3); ads_polar(ptCen, PI/2, -nDist, p4); ads_polar(p4, 0, nDist, p4); ads_grdraw(p3, p4, 2, 0); break; } } OPENOBJ_END(); } } HideDialog(this, TRUE); TCHAR szTmp[256]; ads_getstring(NULL, _T("\n按任意键返回对话框:<返回>"), szTmp); HideDialog(this, FALSE); } void CCalcRainWellDlg::OnDestroy() { CAcUiDialog::OnDestroy(); m_wndToolTip.DestroyWindow(); } BOOL CCalcRainWellDlg::PreTranslateMessage(MSG* pMsg) { if (pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST) { MSG msg; ::CopyMemory(&msg, pMsg, sizeof(MSG)); HWND hWndParent = ::GetParent(msg.hwnd); if (msg.hwnd) { m_wndToolTip.RelayEvent(&msg); } } return CAcUiDialog::PreTranslateMessage(pMsg); } void CCalcRainWellDlg::OnBtnCalcTable() { //前期数据准备 SSearchPipeList *pNodeLong = m_pNodeLong; DList lstNode, lstWell; while(pNodeLong){ if(pNodeLong->m_iType == 0 || pNodeLong->m_iType == 3){ SSearchPipeList *pNodeNew = new SSearchPipeList(); pNodeNew->m_iDn = pNodeLong->m_iDn; pNodeNew->m_ID = pNodeLong->m_ID; pNodeNew->m_csName = pNodeLong->m_csName; pNodeNew->m_nLength = pNodeLong->m_nLength; pNodeNew->m_nPipeQ = pNodeLong->m_nPipeQ; pNodeNew->m_nDang = pNodeLong->m_nDang; pNodeNew->m_nStartPress = pNodeLong->m_nStartPress; pNodeNew->m_nI = pNodeLong->m_nI; pNodeNew->m_nV = pNodeLong->m_nV; pNodeNew->m_nLost = pNodeLong->m_nLost; pNodeNew->m_nSpare = pNodeLong->m_nSpare; if(pNodeLong->m_iType == 3) lstWell.Append(pNodeNew); else lstNode.Append(pNodeNew); } if(pNodeLong->m_pPrevious) pNodeLong = pNodeLong->m_pPrevious; else break; } GetOtherWellNode(m_pListAll, lstWell); //绘制计算表 DrawCalcTable(lstNode,lstWell); } //绘制计算表 void CCalcRainWellDlg::DrawCalcTable(DList &lstNode, DList &lstWell) { HideDialog(this,TRUE); XPoint pt; int ret = XGetPoint(NULL, _T("点取位置\n"), pt); if(ret != RTNORM) { HideDialog(this,FALSE); return; } pt = Ucs2Wcs(pt); int nColNum = 16; int nRow = m_grid.GetRowNum(); if (nRow < 1) { HideDialog(this,FALSE); return; } //删除空行 int nCount = m_grid.GetRowNum() - 1; CString sEndText = m_grid.GetCell(nCount,0).GetText().cs(); while (sEndText.IsEmpty() && nCount >= 0) { nRow--; nCount--; if (nCount < 0) break; sEndText = m_grid.GetCell(nCount,0); } int nTitleLen = 3; nRow += nTitleLen; //加上3行标题 double nTextSize(4), nTableHeight(7),dTitleHeight(15); //字高,表高,字宽高比 CString csDimStyle = _T("_TCH_DIM");//字型 InitTextStyle(csDimStyle); AcDbObjectId idTextStyle = NULL; idTextStyle = GetTextStyleId(csDimStyle); if (!idTextStyle) { HideDialog(this,FALSE); return; } TDbSheet *pSheet = new TDbSheet; ASSERT(pSheet != NULL); InitLayer(LAY_TEXT); pSheet->setLayer(LAY_TEXT); //初始化表格属性 TGridStyle gridStyle; gridStyle.SetOverrideAll(TRUE); gridStyle.SetTextHeight(nTextSize); gridStyle.SetTextStyleId(idTextStyle); gridStyle.SetHorMode(AcDb::kTextCenter); gridStyle.SetVerMode(AcDb::kTextVertMid); pSheet->SetRotation(Ucs2Wcs(0.0)); pSheet->SetGridStyle(gridStyle); pSheet->SetRowHeight(nTableHeight); pSheet->SetTitleHeight(dTitleHeight); gridStyle.SetTextHeight(nTextSize+3); pSheet->SetTitleGridStyle(gridStyle); pSheet->SetTitleText(_T("雨水计算表")); TSheetTitle &title=pSheet->GetTitle(); TDividerStyle &dStyle=title.GetDividerStyle(); dStyle.SetDividerFlag(TDividerStyle::kNone); pSheet->InitSheet(nRow, nColNum, nTableHeight, 50); //初始化列 TSheetColumn column; column.SetWidth(17); for (int i = 0; i < nColNum; ++i) { pSheet->SetColumnAt(i, column); } column.SetWidth(10); pSheet->SetColumnAt(0, column); pSheet->SetColumnAt(1, column); column.SetWidth(13); pSheet->SetColumnAt(5, column); pSheet->SetColumnAt(6, column); pSheet->SetColumnAt(2, column); column.SetWidth(23); pSheet->SetColumnAt(3, column); pSheet->SetColumnAt(4, column); column.SetWidth(26); pSheet->SetColumnAt(7, column); pSheet->SetColumnAt(8, column); pSheet->MergeCells(0,0,0,5); pSheet->MergeCells(0,6,0,11); pSheet->MergeCells(0,12,0,15); pSheet->MergeCells(1,0,1,1); pSheet->MergeCells(1,0,1,1); pSheet->MergeCells(1,2,2,2); pSheet->MergeCells(1,3,1,4); pSheet->MergeCells(1,5,2,5); pSheet->MergeCells(1,6,2,6); pSheet->MergeCells(1,7,1,9); for (int j = 10; j < nColNum; ++j) { pSheet->MergeCells(1,j,2,j); } //标题文字 TGridCell &cell00=*(*pSheet)(0, 0); cell00.SetText(_T("线路")); TGridCell &cell01=*(*pSheet)(0, 6); cell01.SetText(_T("设计降雨")); TGridCell &cell02=*(*pSheet)(0, 12); cell02.SetText(_T("设计管渠")); TGridCell &cell10=*(*pSheet)(1, 0); cell10.SetText(_T("管段")); TGridCell &cell20=*(*pSheet)(2, 0); cell20.SetText(_T("起点")); TGridCell &cell21=*(*pSheet)(2, 1); cell21.SetText(_T("终点")); TGridCell &cell12=*(*pSheet)(1, 2); cell12.SetText(_T("长度L(m)")); TGridCell &cell13=*(*pSheet)(1, 3); cell13.SetText(_T("面积F")); TGridCell &cell23=*(*pSheet)(2, 3); cell23.SetText(_T("汇水面积(m2)")); TGridCell &cell24=*(*pSheet)(2, 4); cell24.SetText(_T("总面积(m2)")); TGridCell &cell15=*(*pSheet)(1, 5); cell15.SetText(_T("径流系数ψ")); TGridCell &cell16=*(*pSheet)(1, 6); cell16.SetText(_T("重现期P(年)")); TGridCell &cell17=*(*pSheet)(1, 7); cell17.SetText(_T("历时t")); TGridCell &cell27=*(*pSheet)(2, 7); cell27.SetText(_T("汇水时间t(min)")); TGridCell &cell28=*(*pSheet)(2, 8); cell28.SetText(_T("管内时间t(min)")); TGridCell &cell29=*(*pSheet)(2, 9); cell29.SetText(_T("折减系数m")); TGridCell &cell110=*(*pSheet)(1, 10); cell110.SetText(_T("暴雨强度q(L/s.ha)")); TGridCell &cell111=*(*pSheet)(1, 11); cell111.SetText(_T("设计流量Q(L/s)")); TGridCell &cell112=*(*pSheet)(1, 12); cell112.SetText(_T("直径D(mm)")); TGridCell &cell113=*(*pSheet)(1, 13); cell113.SetText(_T("坡度i(‰)")); TGridCell &cell114=*(*pSheet)(1, 14); cell114.SetText(_T("流速v(m/s)")); TGridCell &cell115=*(*pSheet)(1, 15); cell115.SetText(_T("泄流量Qs(L/s)")); //表格内容 CString sTmpText; for (int k = nTitleLen; k < nRow; ++k) { sTmpText = m_grid.GetCell(k - nTitleLen,0).GetText(); TGridCell &cell0=*(*pSheet)(k, 0); cell0.SetText(sTmpText); sTmpText = m_grid.GetCell(k - nTitleLen,1).GetText(); TGridCell &cell1=*(*pSheet)(k, 1); cell1.SetText(sTmpText); sTmpText = m_grid.GetCell(k - nTitleLen,4).GetText(); TGridCell &cell2=*(*pSheet)(k, 2); cell2.SetText(sTmpText); sTmpText = m_grid.GetCell(k - nTitleLen,5).GetText(); TGridCell &cell3=*(*pSheet)(k, 3); cell3.SetText(sTmpText); sTmpText = m_grid.GetCell(k - nTitleLen,6).GetText(); TGridCell &cell4=*(*pSheet)(k, 4); cell4.SetText(sTmpText); sTmpText = m_grid.GetCell(k - nTitleLen,7).GetText(); TGridCell &cell5=*(*pSheet)(k, 5); cell5.SetText(sTmpText); sTmpText = m_grid.GetCell(k - nTitleLen,8).GetText(); TGridCell &cell6=*(*pSheet)(k, 6); cell6.SetText(sTmpText); sTmpText = m_grid.GetCell(k - nTitleLen,9).GetText(); TGridCell &cell7=*(*pSheet)(k, 7); cell7.SetText(sTmpText); TGridCell &cell8=*(*pSheet)(k, 8); CString sLen = m_grid.GetCell(k - nTitleLen,4).GetText().cs(); CString sV = m_grid.GetCell(k - nTitleLen,10).GetText().cs(); sTmpText.Format(_T("%.2f"),_tstof(sLen)/_tstof(sV)/60); cell8.SetText(sTmpText); TGridCell &cell9=*(*pSheet)(k, 9); sTmpText.Format(_T("%.2f"),m_dM); cell9.SetText(sTmpText); sTmpText = m_grid.GetCell(k - nTitleLen,12).GetText(); TGridCell &cell10=*(*pSheet)(k, 10); if (m_bReCalc) sTmpText = m_arRainStom[k - nTitleLen]; cell10.SetText(sTmpText); sTmpText = m_grid.GetCell(k - nTitleLen,11).GetText(); TGridCell &cell11=*(*pSheet)(k, 11); cell11.SetText(sTmpText); sTmpText = m_grid.GetCell(k - nTitleLen,2).GetText(); TGridCell &cell12=*(*pSheet)(k, 12); cell12.SetText(sTmpText); sTmpText = m_grid.GetCell(k - nTitleLen,3).GetText(); TGridCell &cell13=*(*pSheet)(k, 13); cell13.SetText(sTmpText); sTmpText = m_grid.GetCell(k - nTitleLen,10).GetText(); TGridCell &cell14=*(*pSheet)(k, 14); cell14.SetText(sTmpText); TGridCell &cell15=*(*pSheet)(k, 15); sV = m_grid.GetCell(k - nTitleLen,10).GetText(); CString sD = m_grid.GetCell(k - nTitleLen,2).GetText().cs(); sTmpText.Format(_T("%.2f"),PI/4*pow(_tstof(sD),2)*_tstof(sV)/1000.0); cell15.SetText(sTmpText); } pSheet->SetLocation(pt); pSheet->AddToCSpace(TRUE); actrTransactionManager->flushGraphics(); //acad 刷新 acedUpdateDisplay(); HideDialog(this,FALSE); }