Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

1334 lines
37 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// CalcDirtDlg.cpp : implementation file
//
#include "stdafx.h"
#include <DbEquipment.h>
#include <MSWORD8.h>
#include "CalcDirtDlg.h"
#include "TWordFormulasTemplet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define FORMULA1(nNum, dVal) (nNum < 15 ? dVal : dVal * 0.9) // cet 2010.7.7 add
#define FORMULA2(nNum, dVal) (nNum < 15 ? (dVal + 0.01) : (dVal * 0.9 + 0.01)) // cet 2010.7.7 add
/////////////////////////////////////////////////////////////////////////////
// 污水计算
/////////////////////////////////////////////////////////////////////////////
extern SSearchPipeList *GetNextExportNode2(SSearchPipeList *pListAll, SSearchPipeList *pDisadvantage);
void CalcDirtPipeDn()
{
Entity entMainPipe;
ads_name entMain;
RBList rbMask(RTDXF0, _T("ATS_EQUIPMENT"), 8, _T("*"), NULL);
// RBList rbMaskPipe(RTDXF0, _T("ATS_PIPE"), 8, LAY_PIPE_DIRT, NULL);
RBList rbMaskPipe = ads_buildlist( -4, _T("<or"),
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, LAY_PIPE_DIRT, -4, _T("and>"),
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, LAY_PIPE_USELESS, -4, _T("and>"),
-4, _T("or>"), NULL);
if(SelectEntity(_T("\n请选择排水出口管<退出>"), entMainPipe, rbMaskPipe) != RTNORM)
return;
//第一步,选择总干管,并找到它之前的堵头
AcDbObjectId idMain = NULL;
OPENOBJ_BEGIN(entMainPipe, AcDb::kForRead, TDbPipe, pPipe);
if(pPipe){
AcDbObjectId nodeId1(NULL), nodeId2(NULL);
nodeId1 = pPipe->GetNode(0);
nodeId2 = pPipe->GetNode(1);
OPENOBJ_BEGIN(nodeId1, AcDb::kForRead, TDbPipeNode, pNode);
if(pNode){
int num = pNode->GetInterfaceNum();
if(num == 1)
idMain = nodeId1;
}
OPENOBJ_END();
OPENOBJ_BEGIN(nodeId2, AcDb::kForRead, TDbPipeNode, pNode);
if(pNode){
int num = pNode->GetInterfaceNum();
if(num == 1)
idMain = nodeId2;
}
OPENOBJ_END();
}
OPENOBJ_END();
if(!idMain){
AfxMessageBox(_T("没有正确选择起点干管!"));
return;
}
acdbGetAdsName(entMain, idMain);
SSearchPipeList *pListAll = new SSearchPipeList();
PickSet ssAll(SS_FREE);
ssAll += idMain;
pListAll->m_iType = 1;
if(!SearchSprinkPipeSys(entMain, NULL, pListAll, ssAll)){
AfxMessageBox(_T("系统有回路!"));
delete pListAll;
return;
}
//第二步,搜索整个系统,计算管长,建立双向链表
CalcPipeLength2(pListAll, NULL);
int idx = 1;
SSearchPipeList *pNode = GetNextDimNode2(pListAll, NULL);
while(pNode){
idx = DoSerialNumber2(pNode, idx); //标注节点编号
pNode = GetNextDimNode2(pListAll, NULL); //得到下一支路起点节点
}
DoDimPipeSerialNumber(pListAll); //标注管段编号
CalcPipeLength(pListAll);
// cet 2010.7.6 add 获得扩张数据
Entity ent;
CString strAterateType, strConnType, strFloorNum;
for(long i = 0; i < ssAll.Length(); i++)
{
ent = ssAll[i];
strAterateType = ReadXdata(ent, _T("AterateType"));
if (strAterateType.Compare(_T("")) != 0)
{
strConnType = ReadXdata(ent, _T("ConnectType"));
strFloorNum = ReadXdata(ent, _T("FloorNum"));
break;
}
}
//第三步,计算管径
CTemporaryResourceOverride over;
CCalcDirtDlg dlg;
dlg.SetData(strAterateType, strConnType, _ttoi(strFloorNum)); // cet 2010.7.6 add
dlg.m_pListAll = pListAll;
dlg.m_ssAll += ssAll;
if(dlg.DoModal() != IDOK){
delete pListAll;
return;
}
delete pListAll;
return;
}
/////////////////////////////////////////////////////////////////////////////
// CCalcDirtDlg dialog
TGridDirt::TGridDirt()
{
AppendCol(_T("编号"), 50);
AppendCol(_T("管类型"), 50);
AppendCol(_T("管径mm"), 50);
AppendCol(_T("当量"), 50);
AppendCol(_T("最大流量"), 55);
AppendCol(_T("额定流量"), 55);
AppendCol(_T("计算流量"), 55);
AppendCol(_T("坡度‰"), 50);
AppendCol(_T("流速m/s"), 50);
AppendCol(_T("充满度%"), 50);
SetColPosFix();
SetColFixLength();
SetNoPaste();
GetCol(2).SetComboEdit();
COLORREF color2 = RGB(0,0,255);;
GetCol(6).SetTextColor(color2);
GetCol(7).SetTextColor(color2);
GetCol(8).SetTextColor(color2);
GetCol(9).SetTextColor(color2);
}
void TGridDirt::OnCellComboString(WDGridCell&cell,CComboBox&combo)
{
if(cell.GetColIndex()==2){
combo.AddString(_T("50"));
combo.AddString(_T("75"));
combo.AddString(_T("100"));
combo.AddString(_T("125"));
combo.AddString(_T("150"));
combo.AddString(_T("200"));
}
}
CCalcDirtDlg::CCalcDirtDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCalcDirtDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCalcDirtDlg)
m_csA = _T("1.5");
m_nFloorNum = 0;
//}}AFX_DATA_INIT
}
void CCalcDirtDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCalcDirtDlg)
DDX_CBString(pDX, IDC_COMBO_A, m_csA);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCalcDirtDlg, CDialog)
//{{AFX_MSG_MAP(CCalcDirtDlg)
ON_BN_CLICKED(IDC_BUTTON_HELP, OnButtonHelp)
ON_BN_CLICKED(IDC_BUTTON_DIM, OnButtonDim)
ON_BN_CLICKED(IDC_BUTTON_WORD, OnButtonWord)
ON_CBN_SELCHANGE(IDC_COMBO_TYPE2, OnSelchangeComboType2)
ON_CBN_SELCHANGE(IDC_COMBO_ATERATETYPE, OnSelchangeComboAteratetype)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCalcDirtDlg message handlers
BOOL CCalcDirtDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// cet 2010.7.6 add
InitData();
m_grid.Clear();
m_grid.Create(this, IDC_LIST_PIPE);
m_grid.SetNoAppendButton(TRUE);
m_grid.SetNoDefaultMenu(true);
CalcNg(m_pListAll);
CalcBigQ(m_pListAll);
DoCalcQ(m_pListAll);
OnOK();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
SSearchPipeList *CCalcDirtDlg::GetNextExportNode(XStringList &lstNodeName, SSearchPipeList *pListAll, SSearchPipeList *pDisadvantage)
{
CString csName = pListAll->m_csName;
int idx = csName.Find(_T("-"));
if(lstNodeName.Index(csName) > -1)
idx = -1;
CString csFront;
if(idx > -1){
csFront = csName.Left(idx);
int iFront = _ttoi(csFront);
if(!pDisadvantage)
pDisadvantage = pListAll;
else{
csName = pDisadvantage->m_csName;
idx = csName.Find(_T("-"));
csFront = csName.Left(idx);
if(iFront < _ttoi(csFront))
pDisadvantage = pListAll;
}
}
int len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
pDisadvantage = GetNextExportNode(lstNodeName, pList, pDisadvantage);
}
return pDisadvantage;
}
void CCalcDirtDlg::DoCalcQ(SSearchPipeList *pListAll)
{
if(pListAll->m_iType != 0){
double nQ = 0.12 * _tstof(m_csA) * sqrt(pListAll->m_nDang) + pListAll->m_nSpare;
pListAll->m_nPipeQ = nQ;
pListAll->m_iDn = 0;
//《给排水规范》P59 如果计算流量大于该管道额定流量累加值,应按额定流量累加值
if(pListAll->m_nPipeQ > pListAll->m_nStartPress)
pListAll->m_nPipeQ = pListAll->m_nStartPress;
if(pListAll->m_pPrevious != NULL)
pListAll->m_pPrevious->m_nPipeQ = pListAll->m_nPipeQ;
}
long len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
DoCalcQ(pList);
}
return;
}
//管径查表获得 《技术措施》PAGE 73
int CCalcDirtDlg::GetVPipeDnByQ(double nQ, BOOL bIsPlastic)
{
int nRet = 0;
UpdateData(TRUE);
// cet 2010.7.6 del
// if(m_iType == 0){ //仅有伸顶通气管
// if(bIsPlastic){ //塑料管
// if(nQ < 1.21)
// nRet = 50;
// else if(nQ > 1.2 && nQ < 3.01)
// nRet = 75;
// else if(nQ > 3.0 && nQ < 3.81)
// nRet = 90;
// else if(nQ > 3.8 && nQ < 5.41)
// nRet = 110;
// else if(nQ > 5.4 && nQ < 7.51)
// nRet = 125;
// else if(nQ > 7.5)
// nRet = 160;
// }
// else{
// if(nQ < 1.01)
// nRet = 50;
// else if(nQ > 1.0 && nQ < 2.51)
// nRet = 75;
// else if(nQ > 2.5 && nQ < 4.51)
// nRet = 100;
// else if(nQ > 4.5 && nQ < 7.01)
// nRet = 125;
// else if(nQ > 7.0)
// nRet = 150;
// }
// }
// else{ //有专有通气立管
// if(bIsPlastic){ //塑料管
// if(nQ < 10.01)
// nRet = 110;
// else if(nQ > 10 && nQ < 16.01)
// nRet = 125;
// else if(nQ > 16)
// nRet = 160;
// }
// else{
// if(nQ < 5.01)
// nRet = 75;
// else if(nQ > 5 && nQ < 9.01)
// nRet = 100;
// else if(nQ > 9 && nQ < 14.01)
// nRet = 125;
// else if(nQ > 14)
// nRet = 150;
// }
// }
// cet 2010.7.6 add
if (m_strAterateType.Compare(_T("伸顶通气")) == 0)
{
CComboBox *pBox = NULL;
pBox = (CComboBox *)GetDlgItem(IDC_COMBO_TYPE);
if(pBox != NULL)
{
CString strType;
pBox->GetLBText(pBox->GetCurSel(), strType);
if (strType.Compare(_T("立管与横支管90°顺水三通连接")) == 0)
{
if (bIsPlastic) //塑料管
{
if (nQ < FORMULA2(m_nFloorNum, 0.8))
{
nRet = 50;
}
else if (nQ > FORMULA1(m_nFloorNum, 0.8) && nQ < FORMULA2(m_nFloorNum, 1.3))
{
nRet = 75;
}
else if (nQ > FORMULA1(m_nFloorNum, 1.3) && nQ < FORMULA2(m_nFloorNum, 3.2))
{
nRet = 110;
}
else if (nQ > FORMULA1(m_nFloorNum, 3.2) && nQ < FORMULA2(m_nFloorNum, 4.0))
{
nRet = 125;
}
else if (nQ > FORMULA1(m_nFloorNum, 4.0))
{
nRet = 160;
}
}
else
{
if (nQ < FORMULA2(m_nFloorNum, 0.8))
{
nRet = 50;
}
else if (nQ > FORMULA1(m_nFloorNum, 0.8) && nQ < FORMULA2(m_nFloorNum, 1.3))
{
nRet = 75;
}
else if (nQ > FORMULA1(m_nFloorNum, 1.3) && nQ < FORMULA2(m_nFloorNum, 3.2))
{
nRet = 100;
}
else if (nQ > FORMULA1(m_nFloorNum, 3.2) && nQ < FORMULA2(m_nFloorNum, 4.0))
{
nRet = 125;
}
else if (nQ > FORMULA1(m_nFloorNum, 4.0))
{
nRet = 150;
}
}
}
else if (strType.Compare(_T("立管与横支管45°斜三通连接")) == 0)
{
if (bIsPlastic) //塑料管
{
if (nQ < FORMULA2(m_nFloorNum, 1.0))
{
nRet = 50;
}
else if (nQ > FORMULA1(m_nFloorNum, 1.0) && nQ < FORMULA2(m_nFloorNum, 1.7))
{
nRet = 75;
}
else if (nQ > FORMULA1(m_nFloorNum, 1.7) && nQ < FORMULA2(m_nFloorNum, 4.0))
{
nRet = 110;
}
else if (nQ > FORMULA1(m_nFloorNum, 4.0) && nQ < FORMULA2(m_nFloorNum, 5.2))
{
nRet = 125;
}
else if (nQ > FORMULA1(m_nFloorNum, 5.2))
{
nRet = 160;
}
}
else
{
if (nQ < FORMULA2(m_nFloorNum, 1.0))
{
nRet = 50;
}
else if (nQ > FORMULA1(m_nFloorNum, 1.0) && nQ < FORMULA2(m_nFloorNum, 1.7))
{
nRet = 75;
}
else if (nQ > FORMULA1(m_nFloorNum, 1.7) && nQ < FORMULA2(m_nFloorNum, 4.0))
{
nRet = 100;
}
else if (nQ > FORMULA1(m_nFloorNum, 4.0) && nQ < FORMULA2(m_nFloorNum, 5.2))
{
nRet = 125;
}
else if (nQ > FORMULA1(m_nFloorNum, 5.2))
{
nRet = 150;
}
}
}
}
}
else if (m_strAterateType.Compare(_T("专用通气")) == 0)
{
CComboBox *pBox = NULL;
pBox = (CComboBox *)GetDlgItem(IDC_COMBO_TYPE);
if(pBox != NULL)
{
CString strType;
pBox->GetLBText(pBox->GetCurSel(), strType);
if (strType.Compare(_T("专用通气75mm")) == 0 &&
m_strConnectType.Compare(_T("结合通气管每层连接")) == 0)
{
if (bIsPlastic)
{
if (nQ < FORMULA2(m_nFloorNum, 5.5))
{
nRet = 110;
}
else if (nQ > FORMULA1(m_nFloorNum, 5.5))
{
nRet = 160;
}
}
else
{
if (nQ < FORMULA2(m_nFloorNum, 5.5))
{
nRet = 100;
}
else if (nQ > FORMULA1(m_nFloorNum, 5.5))
{
nRet = 150;
}
}
}
else if (strType.Compare(_T("专用通气75mm")) == 0 &&
m_strConnectType.Compare(_T("结合通气管隔层连接")) == 0)
{
if (bIsPlastic)
{
if (nQ < FORMULA2(m_nFloorNum, 3.0))
{
nRet = 75;
}
else if (nQ > FORMULA1(m_nFloorNum, 3.0) && nQ < FORMULA2(m_nFloorNum, 4.4))
{
nRet = 110;
}
else if (nQ > FORMULA1(m_nFloorNum, 4.4))
{
nRet = 160;
}
}
else
{
if (nQ < FORMULA2(m_nFloorNum, 3.0))
{
nRet = 75;
}
else if (nQ > FORMULA1(m_nFloorNum, 3.0) && nQ < FORMULA2(m_nFloorNum, 4.4))
{
nRet = 100;
}
else if (nQ > FORMULA1(m_nFloorNum, 4.4))
{
nRet = 150;
}
}
}
else if (strType.Compare(_T("专用通气100mm")) == 0 &&
m_strConnectType.Compare(_T("结合通气管每层连接")) == 0)
{
if (bIsPlastic)
{
if (nQ < FORMULA2(m_nFloorNum, 8.8))
{
nRet = 110;
}
else if (nQ > FORMULA1(m_nFloorNum, 8.8))
{
nRet = 160;
}
}
else
{
if (nQ < FORMULA2(m_nFloorNum, 8.8))
{
nRet = 100;
}
else if (nQ > FORMULA1(m_nFloorNum, 8.8))
{
nRet = 150;
}
}
}
else if (strType.Compare(_T("专用通气100mm")) == 0 &&
m_strConnectType.Compare(_T("结合通气管隔层连接")) == 0)
{
if (bIsPlastic)
{
if (nQ < FORMULA2(m_nFloorNum, 4.8))
{
nRet = 110;
}
else if (nQ > FORMULA1(m_nFloorNum, 4.8))
{
nRet = 160;
}
}
else
{
if (nQ < FORMULA2(m_nFloorNum, 4.8))
{
nRet = 100;
}
else if (nQ > FORMULA1(m_nFloorNum, 4.8))
{
nRet = 150;
}
}
}
}
}
else if (m_strAterateType.Compare(_T("自循环通气")) == 0)
{
if (m_strConnectType.Compare(_T("专用通气形式")) == 0)
{
if (bIsPlastic)
{
if (nQ < FORMULA2(m_nFloorNum, 4.4))
{
nRet = 110;
}
else if (nQ > FORMULA1(m_nFloorNum, 4.4))
{
nRet = 160;
}
}
else
{
if (nQ < FORMULA2(m_nFloorNum, 4.4))
{
nRet = 100;
}
else if (nQ > FORMULA1(m_nFloorNum, 4.4))
{
nRet = 150;
}
}
}
else if (m_strConnectType.Compare(_T("环形通气形式")) == 0)
{
if (bIsPlastic)
{
if (nQ < FORMULA2(m_nFloorNum, 5.9))
{
nRet = 110;
}
else if (nQ > FORMULA1(m_nFloorNum, 5.9))
{
nRet = 160;
}
}
else
{
if (nQ < FORMULA2(m_nFloorNum, 5.9))
{
nRet = 100;
}
else if (nQ > FORMULA1(m_nFloorNum, 5.9))
{
nRet = 150;
}
}
}
}
return nRet;
}
void CCalcDirtDlg::DoCalcDirt(SSearchPipeList *pListAll)
{
if(pListAll->m_iType == 0 && pListAll->m_bNeedCale == FALSE){//横管
BOOL bIsPlastic = FALSE;
OPENOBJ_BEGIN(pListAll->m_ID, AcDb::kForRead, TDbPipe, pPipe);
if(pPipe){
CString csMat = GetPipeMaterialByIdx(pPipe->GetMaterial());
if(csMat.Find(_T("PVC")) > -1 || csMat.Find(_T("塑料")) > -1)
bIsPlastic = TRUE;
}
OPENOBJ_END();
double nN(0.009), nTmpQ(0);
double nD = pListAll->m_iDn;
double nI = 0.026;
if(bIsPlastic){
nN = 0.009;
if(nD == 110)
nD = 100;
else if(nD == 160)
nD = 150;
}
else{
nN = 0.013;
if(nD == 50)
nI = 0.035;
else if(nD == 75)
nI = 0.025;
else if(nD == 100)
nI = 0.02;
else if(nD == 125)
nI = 0.015;
else if(nD == 150)
nI = 0.01;
else if(nD > 150)
nI = 0.008;
}
//计算坡度,充满度,流速 《技术措施》 PAGE71
//第一步, 计算坡度 表:4.4.5 按通用坡度
//第二步, 根据坡度,粗糙系数,流量,半径,计算q/q0 《给水排水管网系统》 PAGE54
//第三步, 根据q/q0 查表得到充满度
//第四步, 计算流速
nD = nD/1000;
double nQ = pListAll->m_nPipeQ / 1000;
nTmpQ = 3.208*nN*nQ/(pow(nD, 2.667) * pow(nI, 0.5));
double nFull = GetFullByPercentQ(nTmpQ);
double nV = 1 / nN * pow(nD/4, 0.667)*pow(nI, 0.5);
pListAll->m_nLost = nFull;
pListAll->m_nI = nI;
pListAll->m_nV = nV;
}
long len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
DoCalcDirt(pList);
}
return;
}
void CCalcDirtDlg::DoCalcPipeDn(SSearchPipeList *pListAll)
{
if(pListAll->m_iType == 0){
BOOL bIsPlastic = FALSE;
OPENOBJ_BEGIN(pListAll->m_ID, AcDb::kForRead, TDbPipe, pPipe);
if(pPipe){
CString csMat = GetPipeMaterialByIdx(pPipe->GetMaterial());
if(csMat.Find(_T("PVC")) > -1 || csMat.Find(_T("塑料")) > -1)
bIsPlastic = TRUE;
}
OPENOBJ_END();
if(pListAll->m_bNeedCale == FALSE){ //横管
if(pListAll->m_nSpare < 1)
pListAll->m_iDn = 50;
else if(pListAll->m_nSpare < 1.5)
pListAll->m_iDn = 75;
else if(pListAll->m_nSpare < 3){
if(bIsPlastic)
pListAll->m_iDn = 110;
else
pListAll->m_iDn = 100;
}
else{
if(bIsPlastic)
pListAll->m_iDn = 160;
else
pListAll->m_iDn = 150;
}
}
else{ //立管
pListAll->m_iDn = GetVPipeDnByQ(pListAll->m_nPipeQ, bIsPlastic);
}
}
long len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
DoCalcPipeDn(pList);
if(pList->m_iDn > pListAll->m_iDn)
pListAll->m_iDn = pList->m_iDn;
}
return;
}
void CCalcDirtDlg::CalcBigQ(SSearchPipeList *pListAll)
{
long len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
CalcBigQ(pList);
if(pList->m_nSpare > pListAll->m_nSpare)
pListAll->m_nSpare = pList->m_nSpare;
}
return;
}
void CCalcDirtDlg::CalcNg(SSearchPipeList *pListAll)
{
if(pListAll->m_iType == -1){
OPENOBJ_BEGIN(pListAll->m_ID, AcDb::kForRead, TDbEquipment, pEquip);
if(pEquip){
AcDbObjectId id2d = pEquip->GetBlock2d();
CString csBlkName = GetBlkNameById(id2d);
pListAll->m_nDang = pEquip->GetDang(); //排水当量
pListAll->m_nStartPress = pEquip->GetSpare(); //累计流量
if(_tcsicmp(csBlkName, _T("$TwtSys$00000132")) == 0)//排水原理图
pListAll->m_nSpare = pEquip->GetPipeLength(); //最大流量
else
pListAll->m_nSpare = pEquip->GetSpare(); //最大流量
}
OPENOBJ_END();
}
else if(pListAll->m_iType == 0){
OPENOBJ_BEGIN(pListAll->m_ID, AcDb::kForRead, TDbPipe, pPipe);
if(pPipe){
XPoint ps, pe;
ps = pPipe->StartPoint();
pe = pPipe->EndPoint();
if(fabs(ps.x - pe.x) < 0.01 && pPipe->GetModelType() == TPipeSys::kSystem)
pListAll->m_bNeedCale = TRUE; //立管
else
pListAll->m_bNeedCale = FALSE; //横管
}
OPENOBJ_END();
}
long len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
pList->m_pPrevious = pListAll;
CalcNg(pList);
pListAll->m_nDang += pList->m_nDang;
pListAll->m_nStartPress += pList->m_nStartPress;
}
return;
}
void CCalcDirtDlg::UpdateGrid()
{
m_grid.Clear();
DList<SSearchPipeList> lstNode;
XStringList lstNodeName;
SSearchPipeList *pNode = GetNextExportNode(lstNodeName, m_pListAll, NULL);
while(pNode){
SSearchPipeList *pNodeNew = new SSearchPipeList();
pNodeNew->m_csName = pNode->m_csName;
pNodeNew->m_nLength = pNode->m_nLength;
pNodeNew->m_nDang = pNode->m_nDang;
pNodeNew->m_nSpare = pNode->m_nSpare;
pNodeNew->m_bNeedCale = pNode->m_bNeedCale;
pNodeNew->m_iDn = pNode->m_iDn;
pNodeNew->m_nPipeQ = pNode->m_nPipeQ;
pNodeNew->m_nI = pNode->m_nI;
pNodeNew->m_nV = pNode->m_nV;
pNodeNew->m_nLost = pNode->m_nLost;
pNodeNew->m_nStartPress = pNode->m_nStartPress;
lstNode.Append(pNodeNew);
lstNodeName.Append(tstrnew(pNodeNew->m_csName));
pNode = GetNextExportNode(lstNodeName, m_pListAll, NULL);
}
for(int i=0;i<lstNode.Length();i++){
m_grid.AppendRow();
CString csNg, csBigQ, csDn,csQ, csI, csV, csFull, csAllQ;
csNg.Format(_T("%.2f"), lstNode[i]->m_nDang);
csBigQ.Format(_T("%.2f"), lstNode[i]->m_nSpare);
csDn.Format(_T("%d"), lstNode[i]->m_iDn);
csQ.Format(_T("%.2f"), lstNode[i]->m_nPipeQ);
csI.Format(_T("%.4f"), lstNode[i]->m_nI);
csV.Format(_T("%.3f"), lstNode[i]->m_nV);
csFull.Format(_T("%.2f"), lstNode[i]->m_nLost);
csAllQ.Format(_T("%.2f"), lstNode[i]->m_nStartPress);
m_grid.GetCell(i, 0).SetText(lstNode[i]->m_csName);
m_grid.GetCell(i, 2).SetText(csDn);
m_grid.GetCell(i, 3).SetText(csNg);
m_grid.GetCell(i, 4).SetText(csBigQ);
m_grid.GetCell(i, 5).SetText(csAllQ);
m_grid.GetCell(i, 6).SetText(csQ);
m_grid.GetCell(i, 7).SetText(csI);
m_grid.GetCell(i, 8).SetText(csV);
m_grid.GetCell(i, 9).SetText(csFull);
if(lstNode[i]->m_bNeedCale)
m_grid.GetCell(i, 1).SetText(_T("立管"));
else
m_grid.GetCell(i, 1).SetText(_T("横管"));
}
}
void CCalcDirtDlg::OnButtonHelp()
{
// AfxMessageBox(_T("住宅、宾馆、医院、疗养院、幼儿园、养老院的卫生间 1.5 \n\n集体宿舍、旅馆和其它公共建筑的公共盥洗室和厕所间 2.0 ~ 2.5\n"));
AfxMessageBox(_T("宿舍(Ⅰ、Ⅱ类)、住宅、宾馆、酒店式公寓、医院、疗养院、幼儿园、养老院的卫生间 1.5 \n\n旅馆和其它公共建筑的公共盥洗室和厕所间 2.0 ~ 2.5\n"));
}
void CCalcDirtDlg::OnOK()
{
UpdateData(TRUE);
DoCalcQ(m_pListAll);
DoCalcPipeDn(m_pListAll);
DoCalcDirt(m_pListAll);
UpdateGrid();
}
//将初算结果标注在图中 管径 & 坡度
void CCalcDirtDlg::DimCalcResult(SSearchPipeList *pListAll)
{
AcDbObjectId id = NULL;
id = pListAll->m_ID;
if(pListAll->m_iType == 0){
ads_name ent;
acdbGetAdsName(ent, id);
XPoint ptStart, ptEnd;
GetPipePoint(ent, ptStart, ptEnd);
DoDimPipeDn(ent, pListAll->m_iDn, _T("自动"), g_nPipeDnHeight, FALSE, FALSE);
}
long len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
DimCalcResult(pList);
}
}
void CCalcDirtDlg::OnButtonDim()
{
UpdateData(TRUE);
HideDialog(this, TRUE);
XPoint ptLow, ptUp;
m_ssAll.GetExtend(ptLow, ptUp);
AssureInCurrentView(ptLow, ptUp);
DimCalcResult(m_pListAll);
UpdateMultDim();
actrTransactionManager->flushGraphics(); //acad 刷新
TCHAR szTmp[32];
ads_getstring(NULL, _T("\n按任意键返回对话框:<返回>"), szTmp);
HideDialog(this, FALSE);
}
void CCalcDirtDlg::OnButtonWord()
{
DList<SSearchPipeList> lstNode;
XStringList lstNodeName;
SSearchPipeList *pNode = GetNextExportNode(lstNodeName, m_pListAll, NULL);
while(pNode){
SSearchPipeList *pNodeNew = new SSearchPipeList();
pNodeNew->m_csName = pNode->m_csName;
pNodeNew->m_ID = pNode->m_ID;
pNodeNew->m_nLength = pNode->m_nLength;
pNodeNew->m_nDang = pNode->m_nDang;
pNodeNew->m_nSpare = pNode->m_nSpare;
pNodeNew->m_bNeedCale = pNode->m_bNeedCale;
pNodeNew->m_iDn = pNode->m_iDn;
pNodeNew->m_nPipeQ = pNode->m_nPipeQ;
pNodeNew->m_nI = pNode->m_nI;
pNodeNew->m_nV = pNode->m_nV;
pNodeNew->m_nLost = pNode->m_nLost;
lstNode.Append(pNodeNew);
lstNodeName.Append(tstrnew(pNodeNew->m_csName));
pNode = GetNextExportNode(lstNodeName, m_pListAll, NULL);
}
ImportCalcWord(lstNode, _tstof(m_csA));
}
//输出计算书函数
void CCalcDirtDlg::ImportCalcWord(DList<SSearchPipeList> &lstNode, double nA)
{
int len = lstNode.Length();
if(len < 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;
}
// cet 2010.6.28 add 打开公式模板
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();
wordParagraphs.SetAlignment(0); // 0: 居左 1:居中 2:居右
wordSelection.TypeText(_T("采用当量法计算\n"));
// cet 2010.6.28 del
// wordSelection.TypeText(_T("计算原理参照《建筑给水排水设计规范GB50015-2003》,采用公共建筑采用当量法 \n"));
// wordSelection.TypeText(_T("基本计算公式 \n"));
// wordSelection.TypeText(_T("Q = 0.12 × SQRT(Ng) × α + Qmax\n"));
// wordSelection.TypeText(_T("式中:\n"));
// wordSelection.TypeText(_T("Q-计算管段的排水设计秒流量(L/s) \n"));
// wordSelection.TypeText(_T("Ng-计算管段的卫生器具排水当量总数 \n"));
// wordSelection.TypeText(_T("Qmax-最大排水器具的流量 \n"));
// wordSelection.TypeText(XString(_T("α-根据建筑物用途而定的系数:%.1f \n"), nA));
// cet 2010.6.28 add
_Font font;
font = wordSelection.GetFont();
wordSelection.TypeText(_T("计算原理参照《建筑给水排水设计规范GB50015-2003》(2009年版),采用公共建筑采用当量法 \n"));
wordSelection.TypeText(_T("基本计算公式 \n "));
wdFormula.InsertFormula(6, wordSelection);
font.SetColorIndex(1);
wordSelection.TypeText(_T("\n式中:"));
wordSelection.TypeText(_T(" q"));
font.SetSubscript(2); //处理下标
wordSelection.TypeText(_T("p"));
font.SetSubscript(0);
wordSelection.TypeText(_T("-计算管段的排水设计秒流量(L/s) \n"));
wordSelection.TypeText(_T(" N"));
font.SetSubscript(2); //处理下标
wordSelection.TypeText(_T("p"));
font.SetSubscript(0);
wordSelection.TypeText(_T("-计算管段的卫生器具排水当量总数 \n"));
wordSelection.TypeText(_T(" q"));
font.SetSubscript(2); //处理下标
wordSelection.TypeText(_T("max"));
font.SetSubscript(0);
wordSelection.TypeText(_T("-计算管段上最大一个卫生器具的排水流量(L/s) \n"));
wordSelection.TypeText(XString(_T(" α-根据建筑物用途而定的系数:%.1f \n"), nA));
wordSelection.TypeText(_T("计算结果:\n"));
Selection wSelection2 = wordApplication.GetSelection();
wSelection2.TypeParagraph();
//画表格
int rows(len+1), columns(9);
Selection wSelection = wordApplication.GetSelection();
Range oRange = wSelection.GetRange();
Tables oTables = activeDocument.GetTables();
_Table oTable = oTables.Add(oRange, rows, columns);
// cet 2010.3.25 add
Borders oBorders = oTable.GetBorders();
oBorders.SetInsideLineStyle(1); // 设置表格线型
oBorders.SetOutsideLineStyle(1);
Columns oColumns;
Column oColumn;
oColumns = oTable.GetColumns();
oColumn = oColumns.Item(1);
oColumn.SetWidth(40, 0); // 0 = wdAdjustNone
oColumn = oColumns.Item(2);
oColumn.SetWidth(45, 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(60, 0);
oColumn = oColumns.Item(7);
oColumn.SetWidth(50, 0);
oColumn = oColumns.Item(8);
oColumn.SetWidth(55, 0);
oColumn = oColumns.Item(9);
oColumn.SetWidth(60, 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("管道类型"));
oCell = oTable.Cell(1, 4);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("累计当量"));
oCell = oTable.Cell(1, 5);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("公称直径"));
oCell = oTable.Cell(1, 6);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("水力坡降mH2O/m"));
oCell = oTable.Cell(1, 7);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("流速m/s"));
oCell = oTable.Cell(1, 8);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("充满度"));
oCell = oTable.Cell(1, 9);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("管材"));
for(int i=0; i<len; i++){
CString csTmp;
oCell = oTable.Cell(i+2, 1); //管段名称
oRange = oCell.GetRange();
oRange.InsertAfter(lstNode[i]->m_csName);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nPipeQ);
oCell = oTable.Cell(i+2, 2); //管道流量L/s
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
if(lstNode[i]->m_bNeedCale)
csTmp = _T("立管");
else
csTmp = _T("横管");
oCell = oTable.Cell(i+2, 3); //管长m
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nDang);
oCell = oTable.Cell(i+2, 4); //当量长度m
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%d"), lstNode[i]->m_iDn);
oCell = oTable.Cell(i+2, 5); //管径mm
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.3f"), lstNode[i]->m_nI);
oCell = oTable.Cell(i+2, 6); //水力坡降mH2O/m
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nV);
oCell = oTable.Cell(i+2, 7); //流速m/s
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nLost);
oCell = oTable.Cell(i+2, 8); //损失mH2O
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
int iMat(0);
OPENOBJ_BEGIN(lstNode[i]->m_ID, AcDb::kForRead, TDbPipe, pPipe);
if(pPipe){
iMat = pPipe->GetMaterial();
}
OPENOBJ_END();
CString csMat = GetPipeMaterialByIdx(iMat);
oCell = oTable.Cell(i+2, 9); //管材
oRange = oCell.GetRange();
oRange.InsertAfter(csMat);
}
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();
wdFormula.CloseFile(); // cet 2010.6.28 add
}
void CCalcDirtDlg::OnSelchangeComboType2()
{
CComboBox *pBox1 = NULL, *pBox2 = NULL, *pBox3 = NULL;
pBox1 = (CComboBox *)GetDlgItem(IDC_COMBO_ATERATETYPE);
pBox2 = (CComboBox *)GetDlgItem(IDC_COMBO_TYPE);
pBox3 = (CComboBox *)GetDlgItem(IDC_COMBO_TYPE2);
if (pBox1 != NULL)
{
pBox1->GetLBText(pBox1->GetCurSel(), m_strAterateType);
if (m_strAterateType.Compare(_T("伸顶通气")) == 0)
{
pBox1->SetCurSel(0);
ClearCombox(pBox2);
pBox2->InsertString(0, _T("立管与横支管90°顺水三通连接"));
pBox2->InsertString(1, _T("立管与横支管45°斜三通连接"));
pBox2->SetCurSel(0);
pBox2->EnableWindow(TRUE);
}
else if (m_strAterateType.Compare(_T("专用通气")) == 0)
{
pBox1->SetCurSel(1);
ClearCombox(pBox2);
pBox2->InsertString(0, _T("专用通气75mm"));
pBox2->InsertString(1, _T("专用通气100mm"));
pBox2->SetCurSel(0);
pBox2->EnableWindow(TRUE);
}
else if (m_strAterateType.Compare(_T("自循环通气")) == 0)
{
pBox1->SetCurSel(2);
ClearCombox(pBox2);
pBox2->EnableWindow(FALSE);
}
}
if (pBox3 != NULL)
{
int nIndex = pBox3->GetCurSel();
if (m_strAterateType.Compare(_T("伸顶通气")) == 0)
{
m_strConnectType = _T("");
}
else if (m_strAterateType.Compare(_T("专用通气")) == 0)
{
if (nIndex == 0)
{
m_strConnectType = _T("结合通气管每层连接");
}
else if (nIndex == 1)
{
m_strConnectType = _T("结合通气管隔层连接");
}
}
else if (m_strAterateType.Compare(_T("自循环通气")) == 0)
{
if (nIndex == 0)
{
m_strConnectType = _T("专用通气形式");
}
else if (nIndex == 1)
{
m_strConnectType = _T("环形通气形式");
}
}
}
}
void CCalcDirtDlg::OnSelchangeComboAteratetype()
{
CComboBox *pBox = NULL, *pBox2 = NULL;
pBox = (CComboBox *)GetDlgItem(IDC_COMBO_ATERATETYPE);
pBox2 = (CComboBox *)GetDlgItem(IDC_COMBO_TYPE2);
if (pBox != NULL)
{
int nIndex = 0;
nIndex = pBox->GetCurSel();
ClearCombox(pBox2);
if (nIndex == 0) // 伸顶通气
{
pBox2->EnableWindow(FALSE);
m_strAterateType = _T("伸顶通气");
}
else if (nIndex == 1) // 专用通气
{
pBox2->InsertString(0, _T("结合通气管每层连接"));
pBox2->InsertString(1, _T("结合通气管隔层连接"));
pBox2->SetCurSel(0);
pBox2->EnableWindow(TRUE);
m_strAterateType = _T("专用通气");
m_strConnectType = _T("结合通气管每层连接");
}
else if (nIndex == 2) // 自循环通气
{
pBox2->InsertString(0, _T("专用通气形式"));
pBox2->InsertString(1, _T("环形通气形式"));
pBox2->SetCurSel(0);
pBox2->EnableWindow(TRUE);
m_strAterateType = _T("自循环通气");
m_strConnectType = _T("专用通气形式");
}
}
OnSelchangeComboType2();
}
void CCalcDirtDlg::InitData()
{
CComboBox *pBox1 = NULL, *pBox2 = NULL, *pBox3 = NULL;
pBox1 = (CComboBox *)GetDlgItem(IDC_COMBO_ATERATETYPE);
pBox2 = (CComboBox *)GetDlgItem(IDC_COMBO_TYPE);
pBox3 = (CComboBox *)GetDlgItem(IDC_COMBO_TYPE2);
CWnd *pWnd = NULL;
pWnd = GetDlgItem(IDC_STATIC_TYPE);
if (m_strAterateType.IsEmpty()) // 没有扩展数据
{
if (pBox1 != NULL)
{
pBox1->SetCurSel(0);
pBox3->EnableWindow(FALSE);
}
if(pBox2 != NULL)
{
pBox2->InsertString(0, _T("立管与横支管90°顺水三通连接"));
pBox2->InsertString(1, _T("立管与横支管45°斜三通连接"));
pBox2->SetCurSel(0);
}
m_strAterateType = _T("伸顶通气");
}
else
{
if (pBox1 != NULL)
{
if (m_strAterateType.Compare(_T("伸顶通气")) == 0)
{
pBox1->SetCurSel(0);
}
else if (m_strAterateType.Compare(_T("专用通气")) == 0)
{
pBox1->SetCurSel(1);
}
else if (m_strAterateType.Compare(_T("自循环通气")) == 0)
{
pBox1->SetCurSel(2);
}
pBox1->EnableWindow(FALSE);
}
if(pBox2 != NULL)
{
if (m_strAterateType.Compare(_T("伸顶通气")) == 0)
{
pBox2->InsertString(0, _T("立管与横支管90°顺水三通连接"));
pBox2->InsertString(1, _T("立管与横支管45°斜三通连接"));
pBox2->SetCurSel(0);
}
else if (m_strAterateType.Compare(_T("专用通气")) == 0)
{
pBox2->InsertString(0, _T("专用通气75mm"));
pBox2->InsertString(1, _T("专用通气100mm"));
pBox2->SetCurSel(0);
}
else if (m_strAterateType.Compare(_T("自循环通气")) == 0)
{
pBox2->EnableWindow(FALSE);
}
}
if (pBox3 != NULL)
{
pBox3->ShowWindow(HIDE_WINDOW);
}
if (pWnd != NULL)
{
pWnd->ShowWindow(HIDE_WINDOW);
}
}
}
void CCalcDirtDlg::ClearCombox(CComboBox *pBox)
{
if (pBox != NULL)
{
int nNum = pBox->GetCount();
for (int i = nNum - 1; i > -1; i--)
{
pBox->DeleteString(i);
}
}
}