Files
envi-code/SourceCode/Code2026/tg_shs/shs_TwtKernal/SprinklerCalcDlg.cpp
T

1398 lines
43 KiB
C++
Raw Normal View History

2026-09-28 15:28:50 +08:00
// SprinklerCalcDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SprinklerCalcDlg.h"
#include <MSWORD8.h>
#include <dbgridsheet.h>
#include "TWordFormulasTemplet.h"
#include "TwtDef.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern SSearchPipeList *GetNextExportNode(SSearchPipeList *pListAll, SSearchPipeList *pDisadvantage);
extern void DoSprinklerCalc(SSearchPipeList *pListAll, double nPress, double nK, int iStart);
extern double DoSprinklerCalc2(SSearchPipeList *pListAll, double nPress, double nK, int iStart);
TGridSprinklerCalc::TGridSprinklerCalc()
{
AppendCol(_T("管段名称"), 55);
AppendCol(_T("起点压力"), 55);
AppendCol(_T("流量L/s"), 50);
AppendCol(_T("管长(m)"), 55);
AppendCol(_T("当量"), 50);
AppendCol(_T("管径(mm)"), 55);
AppendCol(_T("特性K"), 35);
AppendCol(_T("水力坡降"), 55);
AppendCol(_T("流速m/s"), 55);
AppendCol(_T("损失mH2O"), 55);
AppendCol(_T("终点压力"), 55);
SetColPosFix();
SetColFixLength();
SetNoPaste();
// FitLastCol();
GetCol(5).SetComboEdit();
GetCol(4).SetRightButton();
COLORREF color = RGB(255,0,0);
GetCol(5).SetTextColor(color);
GetCol(6).SetTextColor(color);
COLORREF color2 = RGB(0,0,255);;
GetCol(7).SetTextColor(color2);
GetCol(8).SetTextColor(color2);
GetCol(9).SetTextColor(color2);
GetCol(10).SetTextColor(color2);
}
void TGridSprinklerCalc::OnBeforeRefresh(WDGridCell&cell)
{
if(cell.GetColIndex()==8)
{
double dV = _tstof(cell.GetText());
if(dV > 4.9999){
CDC&dc=GetDC();
COLORREF color=acedGetRGB(6);
// dc.SetBkColor(TRANSPARENT);
dc.SetTextColor(color);
dc.SetBkMode(TRANSPARENT);
}
else
WDGrid::OnBeforeRefresh(cell);
}
else
WDGrid::OnBeforeRefresh(cell);
}
void TGridSprinklerCalc::OnCellComboString(WDGridCell&cell,CComboBox&combo)
{
if(cell.GetColIndex()==5){
combo.AddString(_T("25"));
combo.AddString(_T("32"));
combo.AddString(_T("40"));
combo.AddString(_T("50"));
combo.AddString(_T("65"));
combo.AddString(_T("80"));
combo.AddString(_T("100"));
combo.AddString(_T("125"));
combo.AddString(_T("150"));
combo.AddString(_T("200"));
}
}
bool TGridSprinklerCalc::OnCellButtonDown(WDGridCell &cell, CString &res)
{
if(cell.GetColIndex() == 4)
{
WDGridRow &row = cell.GetRow();
TGridSprinklerData *pNewData = (TGridSprinklerData *)row.GetExtendData();
AfxMessageBox(pNewData->m_csNg);
return true;
}
return false;
}
CSprinklerCalcDlg::CSprinklerCalcDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSprinklerCalcDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSprinklerCalcDlg)
m_nPress = 7;
m_nK = 80;
m_iMode = 1;
m_nPressIn = 20;
m_csRetArea = _T("");
m_csRetEven = _T("");
m_csRetPress = _T("");
m_csRetQ = _T("");
m_bNg = TRUE;
//}}AFX_DATA_INIT
m_nProtectArea=0;
m_nProtectQ =0;
m_dElePress = 0;
}
void CSprinklerCalcDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSprinklerCalcDlg)
DDX_Text(pDX, IDC_EDIT_PRESS, m_nPress);
DDV_MinMaxDouble(pDX, m_nPress, 1., 100.);
DDX_Text(pDX, IDC_EDIT_K, m_nK);
DDX_Radio(pDX, IDC_RADIO_MODE1, m_iMode);
DDX_Text(pDX, IDC_EDIT_PRESS2, m_nPressIn);
DDX_Text(pDX, IDC_EDIT_RET_AREA, m_csRetArea);
DDX_Text(pDX, IDC_EDIT_RET_EVEN, m_csRetEven);
DDX_Text(pDX, IDC_EDIT_RET_PRESS, m_csRetPress);
DDX_Text(pDX, IDC_EDIT_RET_Q, m_csRetQ);
DDX_Check(pDX, IDC_CHECK_NG, m_bNg);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSprinklerCalcDlg, CDialog)
//{{AFX_MSG_MAP(CSprinklerCalcDlg)
ON_BN_CLICKED(IDC_BUTTON_WORD, OnButtonWord)
ON_BN_CLICKED(IDC_BUTTON_SHEET, OnButtonSheet)
ON_BN_CLICKED(IDC_RADIO_MODE1, OnRadioMode1)
ON_BN_CLICKED(IDC_RADIO_MODE2, OnRadioMode2)
ON_BN_CLICKED(IDC_BUTTON_HIDE, OnButtonHide)
ON_BN_CLICKED(IDC_BUTTON_DN, OnButtonDn)
ON_BN_CLICKED(IDC_BUTTON_HELP, OnButtonHelp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSprinklerCalcDlg message handlers
BOOL CSprinklerCalcDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_grid.Clear();
m_grid.Create(this, IDC_LIST_PIPE);
//m_grid.FitLastCol();
m_grid.SetNoAppendButton(TRUE);
m_grid.SetNoDefaultMenu(true);
m_nRetK = 0.42 / 80 * m_nK;
DoCalcNg(m_pListAll);
DoSprinklerCalc(m_pListAll, m_nPress, m_nRetK, m_iStart);
UpdateGrid();
CWnd *pWnd = GetDlgItem(IDC_EDIT_PRESS2);
pWnd->EnableWindow(FALSE);
m_csRetArea.Format(_T("%.2f"), m_nUserArea);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSprinklerCalcDlg::OnRadioMode1()
{
CWnd *pWnd1 = GetDlgItem(IDC_EDIT_PRESS);
CWnd *pWnd2 = GetDlgItem(IDC_EDIT_PRESS2);
pWnd1->EnableWindow(FALSE);
pWnd2->EnableWindow(TRUE);
}
void CSprinklerCalcDlg::OnRadioMode2()
{
CWnd *pWnd1 = GetDlgItem(IDC_EDIT_PRESS);
CWnd *pWnd2 = GetDlgItem(IDC_EDIT_PRESS2);
pWnd1->EnableWindow(TRUE);
pWnd2->EnableWindow(FALSE);
}
void CSprinklerCalcDlg::UpdateGrid()
{
long iCurRow = m_grid.GetCurRowIndex();
m_grid.Clear();
m_lstNode.Reset();
SSearchPipeList *pNode = GetNextExportNode(m_pListAll, NULL);
while(pNode){
SSearchPipeList *pNodeNew = new SSearchPipeList();
pNodeNew->m_iDn = pNode->m_iDn;
pNodeNew->m_ID = pNode->m_ID;
if(pNode->m_lstNode[0] != NULL){
if(pNode->m_lstNode[0]->m_iType == 2)
pNodeNew->m_iSpare = pNode->m_lstNode[0]->m_iSpare;
else
pNodeNew->m_iSpare = 0;
}
CString csNg = GetPipeNg(pNode);
CString csName = pNode->m_csName + _T(" 管 当量 = ") + csNg;
pNodeNew->m_csName = csName;
pNodeNew->m_nLength = pNode->m_nLength;
pNodeNew->m_nPipeQ = pNode->m_nPipeQ;
pNodeNew->m_nDang = pNode->m_nDang;
pNodeNew->m_nStartPress = pNode->m_nStartPress;
pNodeNew->m_nI = pNode->m_nI;
pNodeNew->m_nV = pNode->m_nV;
pNodeNew->m_nLost = pNode->m_nLost;
m_lstNode.Append(pNodeNew);
pNode->m_iNum = 0;
pNode = GetNextExportNode(m_pListAll, NULL);
}
int len = m_lstNode.Length();
for(int i=0; i<len; i++){
m_grid.AppendRow();
TGridSprinklerData *pNewData = new TGridSprinklerData();
CString csName = m_lstNode[i]->m_csName;
int idx = csName.Find(_T(" "));
csName = csName.Left(idx);
pNewData->m_csNg = m_lstNode[i]->m_csName;
WDGridRow &row = m_grid.GetRow(i);
row.SetExtendData(pNewData);
m_grid.GetCell(i, 0).SetText(csName);
m_grid.GetCell(i, 1).SetText(XString(_T("%.2f"), m_lstNode[i]->m_nStartPress));
m_grid.GetCell(i, 2).SetText(XString(_T("%.2f"), m_lstNode[i]->m_nPipeQ));
m_grid.GetCell(i, 3).SetText(XString(_T("%.2f"), m_lstNode[i]->m_nLength));
m_grid.GetCell(i, 4).SetText(XString(_T("%.2f"), m_lstNode[i]->m_nDang));
m_grid.GetCell(i, 5).SetText(XString(_T("%d"), m_lstNode[i]->m_iDn));
m_grid.GetCell(i, 7).SetText(XString(_T("%.2f"), m_lstNode[i]->m_nI));
m_grid.GetCell(i, 8).SetText(XString(_T("%.2f"), m_lstNode[i]->m_nV));
m_grid.GetCell(i, 9).SetText(XString(_T("%.2f"), m_lstNode[i]->m_nLost));
m_grid.GetCell(i, 10).SetText(XString(_T("%.2f"), m_lstNode[i]->m_nLost + m_lstNode[i]->m_nStartPress));
if(m_lstNode[i]->m_iSpare < 1)
m_grid.GetCell(i, 6).SetText(_T("默认"));
else
m_grid.GetCell(i, 6).SetText(XString(_T("%d"), m_lstNode[i]->m_iSpare));
}
if(len < 1)
return;
m_grid.SelectRow(iCurRow, TRUE);
m_csRetQ.Format(_T("%.2f"), m_lstNode[len-1]->m_nPipeQ);
m_csRetPress.Format(_T("%.2f"), m_lstNode[len-1]->m_nLost + m_lstNode[len-1]->m_nStartPress + m_dElePress);
m_csRetEven.Format(_T("%.2f"), m_lstNode[len-1]->m_nPipeQ/m_nUserArea*60);
UpdateData(FALSE);
}
/*
void CSprinklerCalcDlg::OnSelchangeComboLevel()
{
UpdateData(TRUE);
if(m_iLevel == 0){ //轻危险级
m_nIntension = 4;
m_nArea = 160;
}
else if(m_iLevel == 1){//中危险级1级
m_nIntension = 6;
m_nArea = 160;
}
else if(m_iLevel == 2){//中危险级2级
m_nIntension = 8;
m_nArea = 160;
}
else if(m_iLevel == 3){//严重危险级1级
m_nIntension = 12;
m_nArea = 260;
}
else if(m_iLevel == 4){//严重危险级2级
m_nIntension = 16;
m_nArea = 260;
}
else if(m_iLevel == 5){//仓库危险级1级
m_nIntension = 12;
m_nArea = 200;
}
else if(m_iLevel == 6){//仓库危险级2级
m_nIntension = 16;
m_nArea = 300;
}
else if(m_iLevel == 7){//仓库危险级3级
m_nIntension = 20;
m_nArea = 260;
}
UpdateData(FALSE);
}
*/
void CSprinklerCalcDlg::ResetList(SSearchPipeList *pListAll)
{
// if(pListAll->m_lstNode.Length() != 0)
pListAll->m_nStartPress = 0;
pListAll->m_nPipeQ = 0;
long len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
ResetList(pList);
}
}
void CSprinklerCalcDlg::OnOK()
{
UpdateData(TRUE);
m_nRetK = 0.42 / 80 * m_nK;
// CMapStringToString map;
for(m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext()){
WDGridRow *pRow = m_grid.CurRow();
CString csName = (*pRow)[0].GetText().cs();
CString csDn = (*pRow)[5].GetText().cs();
CString csStart = (*pRow)[1].GetText().cs();
if(csName == _T(""))
break;
SSearchPipeList *pList = GetPipeNodeByName(m_pListAll, csName, NULL);
if(pList != NULL){
// if(pList->m_lstNode.Length() == 1){
// SSearchPipeList *pList2 = pList->m_lstNode[0];
// if(pList2->m_lstNode.Length() == 0){//末端
// map.SetAt(csName, csStart);
// }
// }
if(pList->m_iDn != _ttoi(csDn)){
pList->m_iDn = _ttoi(csDn);
OPENOBJ_BEGIN(pList->m_ID, AcDb::kForWrite, TDbPipe, pPipe);
if(pPipe){
pPipe->SetDnDiameter(_ttoi(csDn));
}
OPENOBJ_END();
}
// cet 2010.11.25 add 支持修改K值更新计算
CString strK = (*pRow)[6].GetText().cs();
if (strK.CompareNoCase(_T("默认")) != 0 && pList->m_lstNode[0] != NULL && pList->m_lstNode[0]->m_iType == 2)
{
pList->m_lstNode[0]->m_iSpare = _tstof(strK);
ads_name name;
acdbGetAdsName(name, pList->m_lstNode[0]->m_ID);
WriteXdata(name, _T("SPRINKLER_K"), strK); // 修改喷头k值
}
}
}
ResetList(m_pListAll);
DoCalcNg(m_pListAll);
if(m_iMode == 1)
DoSprinklerCalc(m_pListAll, m_nPress, m_nRetK, m_iStart);
else
DoSprinklerCalc2(m_pListAll, (m_nPressIn - m_dElePress), m_nRetK, m_iStart);
UpdateGrid();
}
//判断本管线是否需要计算(只要后面有1个计算喷头)
BOOL CSprinklerCalcDlg::IsNeedCalc(SSearchPipeList *pListAll)
{
BOOL bRet = FALSE;
long len = pListAll->m_lstNode.Length();
CString csName = pListAll->m_csName;
if(pListAll->m_bNeedCale)
return TRUE;
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
bRet = IsNeedCalc(pList);
if(bRet)
return TRUE;
}
return bRet;
}
//自动喷水灭火系统设计规范 附录C 当量长度表
double GetDangLenByElbow90(int iDn1) //90度弯头当量长度
{
if(iDn1 == 25)
return 0.6;
else if(iDn1 == 32)
return 0.9;
else if(iDn1 == 40)
return 1.2;
else if(iDn1 == 50)
return 1.5;
else if(iDn1 == 65)
return 1.8;
else if(iDn1 == 80)
return 2.1;
else if(iDn1 == 100)
return 3.1;
else if(iDn1 == 125)
return 3.7;
else if(iDn1 == 150)
return 4.3;
else
return 0;
}
extern double GetDangLenByTaiIn(int iDn1, int iDn2); //接头当量长度
extern double GetDangLenByCorner(int iDn); //3通4通当量长度
//计算得到每段管线的当量
void CSprinklerCalcDlg::DoCalcNg(SSearchPipeList *pListAll)
{
if(pListAll->m_iType == 0){
AcDbObjectId id = NULL;
id = pListAll->m_ID;
int iDn1(0), iDn2(0), iDn0(0);
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipe, pPipe);
if(pPipe){
iDn1 = (int)pPipe->GetDnDiameter();
}
OPENOBJ_END();
double dNg(0);
DList<AcDbObjectId> lstPipe;
if(pListAll->m_lstNode.Length() == 1){
SSearchPipeList *pList = pListAll->m_lstNode[0]; //得到后节点
if(IsNeedCalc(pList)){
BOOL bIsSprinkler = FALSE;
if(pList->m_iType == 2)
bIsSprinkler = TRUE;
//第一步, 得到后节点管件的当量
int iLen = pList->m_lstNode.Length();
int iNoCalc(0);
if(m_bNg){//当量统计仅考虑水流情况
for(int j=0;j<iLen;j++){
SSearchPipeList *pListTmp = pList->m_lstNode[j];
if(!IsNeedCalc(pListTmp))
iNoCalc++;
}
iLen-=iNoCalc;
}
if(bIsSprinkler)
iLen++;
iLen++;
if(iLen > 2){ //三通 四通
dNg = GetDangLenByCorner(iDn1);
}
else if(iLen == 2){
if(bIsSprinkler){ //接喷淋立管弯头
dNg = GetDangLenByElbow90(iDn1);
}
else if(iNoCalc==0){//iNoCalc==0 表示不考虑水流情况下,实际情况就是2跟管。
SSearchPipeList *pListTmp = pList->m_lstNode[0];
OPENOBJ_BEGIN(pListTmp->m_ID, AcDb::kForRead, TDbPipe, pPipe2);
if(pPipe2){
iDn2 = (int)pPipe2->GetDnDiameter();
}
OPENOBJ_END();
if(Is2PipeParallel(pListTmp->m_ID, id)) //前后管是否平行
dNg = GetDangLenByTaiIn(iDn1, iDn2); //根据接头查当量长度
else
dNg = GetDangLenByElbow90(iDn1); //根据弯头查当量长度
}
}
//第二步, 看看和前节点是否存在变径
if(pListAll->m_pPrevious != NULL){
SSearchPipeList *pList2 = pListAll->m_pPrevious;
int iLen2 = pList2->m_lstNode.Length();
if(iLen2 > 1 || pList2->m_iType == 2){//肯定是个三通
if(pList2->m_pPrevious != NULL){
SSearchPipeList *pList3 = pList2->m_pPrevious;//得到前管
OPENOBJ_BEGIN(pList3->m_ID, AcDb::kForRead, TDbPipe, pPipe2);
if(pPipe2){
iDn0 = (int)pPipe2->GetDnDiameter();
}
OPENOBJ_END();
double dNg2 = GetDangLenByTaiIn(iDn0, iDn1); //异径接头
dNg += dNg2;
}
}
}
}
}
pListAll->m_nDang = dNg;
}
long len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
DoCalcNg(pList);
}
}
/*
void CSprinklerCalcDlg::DoCalcNg(SSearchPipeList *pListAll)
{
if(pListAll->m_iType == 0){
AcDbObjectId id = NULL;
id = pListAll->m_ID;
int iDn1(0), iDn2(0), iDn0(0);
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipe, pPipe);
if(pPipe){
iDn1 = (int)pPipe->GetDnDiameter();
}
OPENOBJ_END();
double dNg(0);
DList<AcDbObjectId> lstPipe;
if(pListAll->m_lstNode.Length() == 1){
SSearchPipeList *pList = pListAll->m_lstNode[0]; //得到后节点
if(IsNeedCalc(pList)){
BOOL bIsSprinkler = FALSE;
if(pList->m_iType == 2)
bIsSprinkler = TRUE;
//第一步, 得到后节点管件的当量
int iLen = pList->m_lstNode.Length();
if(bIsSprinkler)
iLen++;
iLen++;
if(iLen > 2){ //三通 四通
dNg = GetDangLenByCorner(iDn1);
}
else if(iLen == 2){
if(bIsSprinkler){ //接喷淋立管弯头
dNg = GetDangLenByElbow90(iDn1);
}
else{
SSearchPipeList *pListTmp = pList->m_lstNode[0];
OPENOBJ_BEGIN(pListTmp->m_ID, AcDb::kForRead, TDbPipe, pPipe2);
if(pPipe2){
iDn2 = (int)pPipe2->GetDnDiameter();
}
OPENOBJ_END();
if(Is2PipeParallel(pListTmp->m_ID, id)) //前后管是否平行
dNg = GetDangLenByTaiIn(iDn1, iDn2); //根据接头查当量长度
else
dNg = GetDangLenByElbow90(iDn1); //根据弯头查当量长度
}
}
//第二步, 看看和前节点是否存在变径
if(pListAll->m_pPrevious != NULL){
SSearchPipeList *pList2 = pListAll->m_pPrevious;
int iLen2 = pList2->m_lstNode.Length();
if(iLen2 > 1 || pList2->m_iType == 2){//肯定是个三通
if(pList2->m_pPrevious != NULL){
SSearchPipeList *pList3 = pList2->m_pPrevious;//得到前管
OPENOBJ_BEGIN(pList3->m_ID, AcDb::kForRead, TDbPipe, pPipe2);
if(pPipe2){
iDn0 = (int)pPipe2->GetDnDiameter();
}
OPENOBJ_END();
double dNg2 = GetDangLenByTaiIn(iDn0, iDn1); //异径接头
dNg += dNg2;
}
}
}
}
}
pListAll->m_nDang = dNg;
}
long len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
DoCalcNg(pList);
}
}
*/
//计算得到每段管线的当量
CString CSprinklerCalcDlg::GetPipeNg(SSearchPipeList *pListAll)
{
CString csRet;
double dNg(0);
if(pListAll->m_iType == 0){
AcDbObjectId id = NULL;
id = pListAll->m_ID;
int iDn1(0), iDn2(0), iDn0(0);
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipe, pPipe);
if(pPipe){
iDn1 = (int)pPipe->GetDnDiameter();
}
OPENOBJ_END();
DList<AcDbObjectId> lstPipe;
if(pListAll->m_lstNode.Length() == 1){
SSearchPipeList *pList = pListAll->m_lstNode[0]; //得到后节点
if(IsNeedCalc(pList)){
BOOL bIsSprinkler = FALSE;
if(pList->m_iType == 2)
bIsSprinkler = TRUE;
//第一步, 得到后节点管件的当量
int iLen = pList->m_lstNode.Length();
int iNoCalc(0);
if(m_bNg){//当量统计仅考虑水流情况
for(int j=0;j<iLen;j++){
SSearchPipeList *pListTmp = pList->m_lstNode[j];
if(!IsNeedCalc(pListTmp))
iNoCalc++;
}
iLen-=iNoCalc;
}
if(bIsSprinkler)
iLen++;
iLen++;
if(iLen > 2){ //三通 四通
double dNg1 = GetDangLenByCorner(iDn1);
csRet.Format(_T("三通四通 %.2f "), dNg1);
}
else if(iLen == 2){
if(bIsSprinkler){ //接喷淋立管弯头
double dNg1 = GetDangLenByElbow90(iDn1);
csRet.Format(_T("90度弯头 %.2f "), dNg1);
}
else if(iNoCalc==0){
SSearchPipeList *pListTmp = pList->m_lstNode[0];
OPENOBJ_BEGIN(pListTmp->m_ID, AcDb::kForRead, TDbPipe, pPipe2);
if(pPipe2){
iDn2 = (int)pPipe2->GetDnDiameter();
}
OPENOBJ_END();
if(Is2PipeParallel(pListTmp->m_ID, id)){ //前后管是否平行
double dNg1 = GetDangLenByTaiIn(iDn1, iDn2); //根据接头查当量长度
csRet.Format(_T("异径接头 %.2f "), dNg1);
}
else{
double dNg1 = GetDangLenByElbow90(iDn1); //根据弯头查当量长度
csRet.Format(_T("90度弯头 %.2f "), dNg1);
}
}
}
//第二步, 看看和前节点是否存在变径
if(pListAll->m_pPrevious != NULL){
SSearchPipeList *pList2 = pListAll->m_pPrevious;
int iLen2 = pList2->m_lstNode.Length();
if(iLen2 > 1 || pList2->m_iType == 2){//肯定是个三通
if(pList2->m_pPrevious != NULL){
SSearchPipeList *pList3 = pList2->m_pPrevious;//得到前管
OPENOBJ_BEGIN(pList3->m_ID, AcDb::kForRead, TDbPipe, pPipe2);
if(pPipe2){
iDn0 = (int)pPipe2->GetDnDiameter();
}
OPENOBJ_END();
double dNg2 = GetDangLenByTaiIn(iDn0, iDn1); //异径接头
csRet.Format(_T("%s 异径接头 %.2f "), csRet, dNg2);
dNg += dNg2;
}
}
}
}
}
}
// csRet.Format("%.2f", dNg);
return csRet;
}
void CSprinklerCalcDlg::OnButtonWord()
{
UpdateData(TRUE);
ImportWord(m_lstNode, m_nUserArea, m_nK);
}
void CSprinklerCalcDlg::OnButtonSheet()
{
HideDialog(this, TRUE);
UpdateData(TRUE);
if(m_lstNode.Length() > 0){
ImportSheet(m_lstNode, m_nUserArea, m_nK);
actrTransactionManager->flushGraphics(); //acad 刷新
}
HideDialog(this, FALSE);
}
//输出计算书函数
void CSprinklerCalcDlg::ImportWord(DList<SSearchPipeList> &lstNode, double nArea, double nK)
{
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.7.9 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);
// CString csK; // cet 2010.7.14 del
// csK.Format(_T("自喷计算书 K = %.0f \n"), nK); // cet 2010.7.14 del
//写一行字
wordSelection = wordApplication.GetSelection();
wordParagraphs = wordSelection.GetParagraphs();
wordParagraphs.SetAlignment(0); // 0: 居左 1:居中 2:居右
// wordSelection.TypeText(csK); // cet 2010.7.14 del
// wordSelection.TypeText(szLevel);
// cet 2010.7.9 del
// wordSelection.TypeText(_T("\n计算原理参照《自动喷水灭火系统设计规范GB 50084-2001》(2005年版) \n"));
// wordSelection.TypeText(_T("基本计算公式 \n"));
// wordSelection.TypeText(_T("1. 喷头流量 \n"));
// wordSelection.TypeText(_T("q = K * SQRT(10P) \n"));
// wordSelection.TypeText(_T("式中:\n"));
// wordSelection.TypeText(_T("q-喷头处节点流量,L/min \n"));
// wordSelection.TypeText(_T("P-喷头处水压,MPa\n"));
// wordSelection.TypeText(_T("K-喷头流量系数\n"));
// wordSelection.TypeText(_T("2. 流速V \n"));
// wordSelection.TypeText(_T("V = (4 * Q) / (π * Dj * Dj)\n"));
// wordSelection.TypeText(_T("式中:\n"));
// wordSelection.TypeText(_T("Q-管段流量L/s\n"));
// wordSelection.TypeText(_T("Dj-管道的计算内径(m)\n"));
// wordSelection.TypeText(_T("3. 水力坡降 \n"));
// wordSelection.TypeText(_T("i = 0.00107 * V * V / (pow(Dj, 1.3) \n"));
// wordSelection.TypeText(_T("式中:\n"));
// wordSelection.TypeText(_T("i-每米管道的水头损失(m H20/m)\n"));
// wordSelection.TypeText(_T("V-管道内水的平均流速(m/s)\n"));
// wordSelection.TypeText(_T("Dj-管道的计算内径(m)\n"));
// wordSelection.TypeText(_T("4. 沿程水头损失 \n"));
// wordSelection.TypeText(_T("h = i * L \n"));
// wordSelection.TypeText(_T("式中:\n"));
// wordSelection.TypeText(_T("L-管段长度m\n"));
// wordSelection.TypeText(_T("5. 局部损失(采用当量长度法) \n"));
// wordSelection.TypeText(_T("h = i * L(当量) \n"));
// wordSelection.TypeText(_T("式中:\n"));
// wordSelection.TypeText(_T("L(当量) 管段当量长度,单位m(《自动喷水灭火系统设计规范》附录C)\n"));
// wordSelection.TypeText(_T("6. 总损失 \n"));
// wordSelection.TypeText(_T("h = h(局) + h(沿) \n"));
// wordSelection.TypeText(_T("7. 终点压力 \n"));
// wordSelection.TypeText(_T("Hn = Hn-1 + h \n\n"));
// cet 2010.7.9 add
_Font font;
font = wordSelection.GetFont();
wordSelection.TypeText(_T("计算原理参照《自动喷水灭火系统设计规范GB 50084-2001》(2005年版) \n"));
wordSelection.TypeText(_T("基本计算公式: \n"));
wordSelection.TypeText(_T("1、喷头流量: \n"));
wordSelection.TypeText(_T(" "));
wdFormula.InsertFormula(WORD_FORMULA18, wordSelection);
wordSelection.TypeText(_T("\n 式中:"));
wordSelection.TypeText(_T("q -- 喷头处节点流量,L/min \n"));
wordSelection.TypeText(_T(" P -- 喷头处水压(喷头工作压力)MPa\n"));
wordSelection.TypeText(_T(" K -- 喷头流量系数\n"));
wordSelection.TypeText(_T("2、流速V: \n"));
wordSelection.TypeText(_T(" "));
wdFormula.InsertFormula(WORD_FORMULA14, wordSelection);
wordSelection.TypeText(_T("\n 式中:"));
wordSelection.TypeText(_T("Q -- 管段流量L/s\n"));
wordSelection.TypeText(_T(" D"));
font.SetSubscript(2); //处理下标
wordSelection.TypeText(_T("j"));
font.SetSubscript(0);
wordSelection.TypeText(_T(" --管道的计算内径(m)\n"));
wordSelection.TypeText(_T("3、水力坡降: \n"));
wordSelection.TypeText(_T(" "));
wdFormula.InsertFormula(WORD_FORMULA15, wordSelection);
wordSelection.TypeText(_T("\n 式中:"));
wordSelection.TypeText(_T("i -- 每米管道的水头损失(mH"));
font.SetSubscript(2); //处理下标
wordSelection.TypeText(_T("2"));
font.SetSubscript(0);
wordSelection.TypeText(_T("0/m)\n"));
wordSelection.TypeText(_T(" V -- 管道内水的平均流速(m/s)\n"));
wordSelection.TypeText(_T(" d"));
font.SetSubscript(2); //处理下标
wordSelection.TypeText(_T("j"));
font.SetSubscript(0);
wordSelection.TypeText(_T(" -- 管道的计算内径(m),取值应按管道的内径减1mm确定\n"));
wordSelection.TypeText(_T("4、沿程水头损失: \n"));
wordSelection.TypeText(_T(" "));
wdFormula.InsertFormula(WORD_FORMULA16, wordSelection);
wordSelection.TypeText(_T("\n 式中:"));
wordSelection.TypeText(_T("L -- 管段长度m\n"));
wordSelection.TypeText(_T("5、局部损失(采用当量长度法): \n"));
wordSelection.TypeText(_T(" "));
wdFormula.InsertFormula(WORD_FORMULA17, wordSelection);
wordSelection.TypeText(_T("(当量)"));
wordSelection.TypeText(_T("\n 式中:"));
wordSelection.TypeText(_T("L(当量) -- 管段当量长度,单位m(《自动喷水灭火系统设计规范》附录C)\n"));
wordSelection.TypeText(_T("6、总损失: \n"));
wordSelection.TypeText(_T(" "));
wdFormula.InsertFormula(WORD_FORMULA19, wordSelection);
wordSelection.TypeText(_T("\n7、终点压力: \n"));
wordSelection.TypeText(_T(" "));
wdFormula.InsertFormula(WORD_FORMULA20, wordSelection);
wordSelection.TypeText(_T("\n"));
wdFormula.CloseFile();
Selection wSelection2 = wordApplication.GetSelection();
wSelection2.TypeParagraph();
//画表格
int rows(len+1), columns(11);
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(38, 0); // 0 = wdAdjustNone
oColumn = oColumns.Item(2);
oColumn.SetWidth(52, 0);
oColumn = oColumns.Item(3);
oColumn.SetWidth(45, 0);
oColumn = oColumns.Item(4);
oColumn.SetWidth(35, 0);
oColumn = oColumns.Item(5);
oColumn.SetWidth(35, 0);
oColumn = oColumns.Item(6);
oColumn.SetWidth(35, 0);
oColumn = oColumns.Item(7);
oColumn.SetWidth(30, 0);
oColumn = oColumns.Item(8);
oColumn.SetWidth(60, 0);
oColumn = oColumns.Item(9);
oColumn.SetWidth(40, 0);
oColumn = oColumns.Item(10);
oColumn.SetWidth(45, 0);
oColumn = oColumns.Item(11);
oColumn.SetWidth(55, 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("起点压力mH2O"));
oCell = oTable.Cell(1, 3);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("管道流量L/s"));
oCell = oTable.Cell(1, 4);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("管长m"));
oCell = oTable.Cell(1, 5);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("当量长度"));
oCell = oTable.Cell(1, 6);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("管径mm"));
oCell = oTable.Cell(1, 7);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("K"));
oCell = oTable.Cell(1, 8);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("水力坡降mH2O/m"));
oCell = oTable.Cell(1, 9);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("流速m/s"));
oCell = oTable.Cell(1, 10);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("损失mH2O"));
oCell = oTable.Cell(1, 11);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("终点压力mH2O"));
for(int i=0; i<len; i++){
CString csTmp;
oCell = oTable.Cell(i+2, 1); //管段名称
oRange = oCell.GetRange();
CString csName = lstNode[i]->m_csName;
int idx = csName.Find(_T(" "));
csName = csName.Left(idx);
oRange.InsertAfter(csName);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nStartPress);
oCell = oTable.Cell(i+2, 2); //起点压力mH2O
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nPipeQ);
oCell = oTable.Cell(i+2, 3); //管道流量L/s
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nLength);
oCell = oTable.Cell(i+2, 4); //管长m
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nDang);
oCell = oTable.Cell(i+2, 5); //当量长度m
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%d"), lstNode[i]->m_iDn);
oCell = oTable.Cell(i+2, 6); //管径mm
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
int iK = lstNode[i]->m_iSpare;
if(iK < 1)
iK = (int)m_nK;
csTmp.Format(_T("%d"), iK);
oCell = oTable.Cell(i+2, 7); //K
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.3f"), lstNode[i]->m_nI);
oCell = oTable.Cell(i+2, 8); //水力坡降mH2O/m
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nV);
oCell = oTable.Cell(i+2, 9); //流速m/s
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nLost);
oCell = oTable.Cell(i+2, 10); //损失mH2O
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nLost + lstNode[i]->m_nStartPress);
oCell = oTable.Cell(i+2, 11); //终点压力mH2O
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
}
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();
wordSelection.TypeText(_T("计算结果:\n"));
CString csRet;
csRet.Format(_T("所选作用面积:%.1f平方米\n"), nArea);
wordSelection.TypeText(csRet);
csRet.Format(_T("总流量:%.2f L/s\n"), lstNode[len-1]->m_nPipeQ);
wordSelection.TypeText(csRet);
csRet.Format(_T("平均喷水强度:%.2f L/min.平方米\n"), lstNode[len-1]->m_nPipeQ/nArea*60);
wordSelection.TypeText(csRet);
csRet.Format(_T("入口压力:%.2f 米水柱\n"), lstNode[len-1]->m_nLost + lstNode[len-1]->m_nStartPress + m_dElePress);
wordSelection.TypeText(csRet);
if(fabs(m_dElePress) > 0.001)
{
csRet.Format(_T("其中高差压力:%.2f 米水柱\n"), m_dElePress);
wordSelection.TypeText(csRet);
}
if(m_nProtectArea > 0 && m_nProtectQ > 0){
wordSelection.TypeText(_T("4喷头校核结果:\n"));
csRet.Format(_T("4喷头保护面积:%.1f平方米\n"), m_nProtectArea);
wordSelection.TypeText(csRet);
csRet.Format(_T("4喷头总流量:%.2f L/s\n"), m_nProtectQ);
wordSelection.TypeText(csRet);
csRet.Format(_T("4喷头喷水强度:%.2f L/min.平方米\n"), m_nProtectQ/m_nProtectArea*60);
wordSelection.TypeText(csRet);
}
}
//输出计算表函数
void CSprinklerCalcDlg::ImportSheet(DList<SSearchPipeList> &lstNode, double nArea, double nK)
{
XPoint pt;
int ret = XGetPoint(NULL, _T("点取计算结果表位置\n"), pt);
if(ret != RTNORM) {
return;
}
int nColNum(11);
int len = lstNode.Length();
if(len < 0)
return;
AcDbObjectId idTextStyle = InitTwtTextStyle(g_csSheetStyle);
if(!idTextStyle)
idTextStyle = GetTextStyleId(_T("Standard"));
TDbSheet *pSheet = new TDbSheet;
pSheet->SetRotation(Ucs2Wcs(0.0));//add by sr
InitLayer(LAY_TEXT);
pSheet->setLayer(LAY_TEXT);
TGridStyle gridStyle;
gridStyle.SetOverrideAll(TRUE);
gridStyle.SetTextHeight(g_nSheetHeight);
gridStyle.SetTextStyleId(idTextStyle);
TSheetTitle &title=pSheet->GetTitle();
title.SetHeight(7.0);
title.SetVisible(TRUE);
TDividerStyle &style=title.GetDividerStyle();
style.SetDividerFlag(TDividerStyle::kNone);
gridStyle.SetHorMode(AcDb::kTextCenter);
gridStyle.SetVerMode(AcDb::kTextVertMid);
pSheet->SetGridStyle(gridStyle);
pSheet->SetRowHeight(g_nSheetHeight+3);
pSheet->InitSheet(len+2, 11, g_nSheetHeight+3, 50);
CString csTitle;
// csTitle.Format(_T("采用作用面积法计算 K = %.0f"), nK); // cet 2010.7.14 del
csTitle = _T("采用作用面积法计算"); // cet 2010.7.14 add
pSheet->SetTitleText(csTitle);
TSheetColumn column;
column.SetWidth(15);
pSheet->SetColumnAt(0, column);
TGridCell &cell=*(*pSheet)(0, 0);
cell.SetText(_T("管段名称"));
column.SetWidth(30);
pSheet->SetColumnAt(1, column);
TGridCell &cell2=*(*pSheet)(0, 1);
cell2.SetText(_T("起点压力(mH2O)"));
column.SetWidth(25);
pSheet->SetColumnAt(2, column);
TGridCell &cell3=*(*pSheet)(0, 2);
cell3.SetText(_T("管道流量(L/s)"));
column.SetWidth(20);
pSheet->SetColumnAt(3, column);
TGridCell &cell4=*(*pSheet)(0, 3);
cell4.SetText(_T("管长(m)"));
column.SetWidth(20);
pSheet->SetColumnAt(4, column);
TGridCell &cell5=*(*pSheet)(0, 4);
cell5.SetText(_T("当量长度"));
column.SetWidth(20);
pSheet->SetColumnAt(5, column);
TGridCell &cell6=*(*pSheet)(0, 5);
cell6.SetText(_T("管径(mm)"));
column.SetWidth(20);
pSheet->SetColumnAt(6, column);
TGridCell &cell11=*(*pSheet)(0, 6);
cell11.SetText(_T("特性系数K"));
column.SetWidth(35);
pSheet->SetColumnAt(7, column);
TGridCell &cell7=*(*pSheet)(0, 7);
cell7.SetText(_T("水力坡降(mH2O/m)"));
column.SetWidth(20);
pSheet->SetColumnAt(8, column);
TGridCell &cell8=*(*pSheet)(0, 8);
cell8.SetText(_T("流速(m/s)"));
column.SetWidth(30);
pSheet->SetColumnAt(9, column);
TGridCell &cell9=*(*pSheet)(0, 9);
cell9.SetText(_T("损失(mH2O)"));
column.SetWidth(30);
pSheet->SetColumnAt(10, column);
TGridCell &cell10=*(*pSheet)(0, 10);
cell10.SetText(_T("终点压力(mH2O)"));
for(int i=1; i<=len; i++){
CString csTmp;
TGridCell &Cell11=*(*pSheet)(i, 0);
csTmp = lstNode[i-1]->m_csName;
csTmp.Replace(_T("-"), _T("~"));
int idx = csTmp.Find(_T(" "));
csTmp = csTmp.Left(idx);
Cell11.SetText(csTmp); //管段名称
csTmp.Format(_T("%.2f"), lstNode[i-1]->m_nStartPress);
TGridCell &Cell12=*(*pSheet)(i, 1);
Cell12.SetText(csTmp); //起点压力mH2O
csTmp.Format(_T("%.2f"), lstNode[i-1]->m_nPipeQ);
TGridCell &Cell13=*(*pSheet)(i, 2);
Cell13.SetText(csTmp); //管道流量L/s
csTmp.Format(_T("%.2f"), lstNode[i-1]->m_nLength);
TGridCell &Cell14=*(*pSheet)(i, 3);
Cell14.SetText(csTmp); //管长m
csTmp.Format(_T("%.2f"), lstNode[i-1]->m_nDang);
TGridCell &Cell15=*(*pSheet)(i, 4);
Cell15.SetText(csTmp); //当量长度m
csTmp.Format(_T("%d"), lstNode[i-1]->m_iDn);
TGridCell &Cell16=*(*pSheet)(i, 5);
Cell16.SetText(csTmp); //管径mm
int iK(0);
iK = lstNode[i-1]->m_iSpare;
if(iK < 1)
iK = (int)m_nK;
csTmp.Format(_T("%d"), iK);
TGridCell &Cell21=*(*pSheet)(i, 6);
Cell21.SetText(csTmp); //特性系数K
csTmp.Format(_T("%.3f"), lstNode[i-1]->m_nI);
TGridCell &Cell17=*(*pSheet)(i, 7);
Cell17.SetText(csTmp); //水力坡降mH2O/m
csTmp.Format(_T("%.2f"), lstNode[i-1]->m_nV);
TGridCell &Cell18=*(*pSheet)(i, 8);
Cell18.SetText(csTmp); //流速m/s
csTmp.Format(_T("%.2f"), lstNode[i-1]->m_nLost);
TGridCell &Cell19=*(*pSheet)(i, 9);
Cell19.SetText(csTmp); //损失mH2O
csTmp.Format(_T("%.2f"), lstNode[i-1]->m_nLost + lstNode[i-1]->m_nStartPress);
TGridCell &Cell20=*(*pSheet)(i, 10);
Cell20.SetText(csTmp); //终点压力mH2O
}
CString csRet;
csRet.Format(_T("%.2f"), lstNode[len-1]->m_nPipeQ);
TGridCell &Cell20=*(*pSheet)(len+1, 0);
Cell20.SetText(_T("计算结果"));
TGridCell &Cell21=*(*pSheet)(len+1, 1);
Cell21.SetText(_T("总流量(L/s):"));
TGridCell &Cell22=*(*pSheet)(len+1, 2);
Cell22.SetText(csRet);
TGridCell &Cell23=*(*pSheet)(len+1, 6);
Cell23.SetText(_T("入口压力:"));
csRet.Format(_T("%.2f"), lstNode[len-1]->m_nLost + lstNode[len-1]->m_nStartPress + m_dElePress);
TGridCell &Cell24=*(*pSheet)(len+1, 7);
Cell24.SetText(csRet);
TGridCell &Cell25=*(*pSheet)(len+1, 3);
Cell25.SetText(_T("作用面积"));
TGridCell &Cell26=*(*pSheet)(len+1, 4);
csRet.Format(_T("%.1f平方米"), nArea);
Cell26.SetText(csRet);
TGridCell &Cell27=*(*pSheet)(len+1, 8);
Cell27.SetText(_T("平均喷水强度"));
TGridCell &Cell28=*(*pSheet)(len+1, 9);
csRet.Format(_T("%.1fL/min.平方米"), lstNode[len-1]->m_nPipeQ/nArea*60);
Cell28.SetText(csRet);
pSheet->SetLocation(Ucs2Wcs(pt));
pSheet->AddToCSpace(TRUE);
}
BOOL CSprinklerCalcDlg::GetIdByNode(SSearchPipeList *pListAll, CString csName, AcDbObjectId &idRet)
{
BOOL bRet=FALSE;
AcDbObjectId id = pListAll->m_ID;
CString csName2 = pListAll->m_csName;
if(csName2 == csName){
idRet = id;
return TRUE;
}
long len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
bRet = GetIdByNode(pList, csName, idRet);
}
return bRet;
}
SSearchPipeList *CSprinklerCalcDlg::GetNodeById(SSearchPipeList *pListAll, AcDbObjectId idSprinkler, SSearchPipeList *pNode)
{
AcDbObjectId id = NULL;
id = pListAll->m_ID;
if(idSprinkler == id)
return pListAll;
long len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
pNode = GetNodeById(pList, idSprinkler, pNode);
}
return pNode;
}
/*
void CSprinklerCalcDlg::OnButtonCheck()
{
HideDialog(this, TRUE);
Entity entPoly;
RBList rbMask(RTDXF0, _T("LWPOLYLINE"), 8, _T("*"), NULL);
if(SelectEntity(_T("\n请选择表示4个相邻喷头所组成保护面积的闭合PLINE:<退出>"), entPoly, rbMask) != RTNORM){
UpdateData(FALSE);
HideDialog(this, FALSE);
return;
}
PickSet ss(SS_FREE);
XPoly2D poly(entPoly);
RBList rbMask2(RTDXF0, _T("ATS_EQUIPMENT"), 8, LAY_EQUIP_SPRINKLE, NULL);
poly.TransUCS(Groups(0), Groups(1));//Groups(0) wcs, Groups(1) ucs
RBList rbFence = poly.Fence();
ss.Get(_T("CP"), rbFence, NULL, rbMask2);
if(ss.Length() != 4){
MessageBox(_T("必须框住4个喷头!"));
UpdateData(FALSE);
HideDialog(this, FALSE);
return;
}
m_nProtectQ = 0;
m_nProtectArea = AS_SQMETER(poly.Area());
int len = m_lstNode.Length();
for(long i=0;i<4;i++){
Entity ent = ss[i];
AcDbObjectId id = NULL;
acdbGetObjectId(id, ent);
SSearchPipeList *pNode = GetNodeById(m_pListAll, id, NULL);
if(pNode){
double nStartPress = pNode->m_nStartPress;
double nQ = m_nRetK * sqrt(nStartPress);
m_nProtectQ += nQ;
}
}
UpdateData(FALSE);
HideDialog(this, FALSE);
CString csRet;
csRet.Format(_T("4喷头喷水强度:%.2f L/min.平方米\n"), m_nProtectQ/m_nProtectArea*60);
MessageBox(csRet);
}
*/
void CSprinklerCalcDlg::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("")){
AcDbObjectId id = NULL;
GetIdByNode(m_pListAll, csName1, id);
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipe, pPipe);
if(pPipe){
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);
}
OPENOBJ_END();
}
HideDialog(this, TRUE);
TCHAR szTmp[256];
ads_getstring(NULL, _T("\n按任意键返回对话框:<返回>"), szTmp);
HideDialog(this, FALSE);
}
//校正管径,让流速控制在5之内
void CSprinklerCalcDlg::OnButtonDn()
{
BOOL bFind = FALSE;
for(m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext()){
WDGridRow *pRow = m_grid.CurRow();
CString csName = (*pRow)[0].GetText().cs();
CString csV = (*pRow)[8].GetText().cs();
CString csDn = (*pRow)[5].GetText().cs();
if(csName == _T(""))
break;
if(_tstof(csV) > 5.0){
bFind = TRUE;
break;
}
}
if(bFind == FALSE){
MessageBox(_T("没有流速超过5米的管线(紫色流速值),如果需要调整可以手工修改管径值"));
return;
}
else{
int nRes = AfxMessageBox(_T("发现有流速超过5米的管线(紫色流速值),是否统一将管径调整大一号?"),MB_YESNO | MB_ICONWARNING);
if (nRes == IDNO)
return;
}
for(m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext()){
WDGridRow *pRow = m_grid.CurRow();
CString csName = (*pRow)[0].GetText().cs();
CString csV = (*pRow)[8].GetText().cs();
CString csDn = (*pRow)[5].GetText().cs();
if(csName == _T(""))
break;
if(_tstof(csV) > 5.0){
int iDn = _ttoi(csDn);
if(iDn <= 25)
iDn = 32;
else if(iDn == 32)
iDn = 40;
else if(iDn == 40)
iDn = 50;
else if(iDn == 50)
iDn = 65;
else if(iDn == 65)
iDn = 80;
else if(iDn == 80)
iDn = 100;
else if(iDn == 100)
iDn = 125;
else if(iDn == 125)
iDn = 150;
else if(iDn >= 150)
iDn = 200;
csDn.Format(_T("%d"), iDn);
(*pRow)[5].SetText(csDn);
SSearchPipeList *pList = GetPipeNodeByName(m_pListAll, csName, NULL);
if(pList != NULL){
pList->m_iDn = iDn;
OPENOBJ_BEGIN(pList->m_ID, AcDb::kForWrite, TDbPipe, pPipe);
if(pPipe){
pPipe->SetDnDiameter(iDn);
}
OPENOBJ_END();
}
}
}
OnOK();
}
void CSprinklerCalcDlg::OnButtonHelp()
{
AfxMessageBox(_T("《自动喷水灭火系统设计规范》5.0.1:\n\n轻危险级,中危险级,严重危险级:系统最不利点喷头出的工作压力不应低于0.05MPa。"));
}