Files
envi-code/SourceCode/Code2026/Dimension/CalcFeedPublickDlg.cpp
T

1376 lines
42 KiB
C++
Raw Normal View History

2026-09-28 15:28:50 +08:00
#include "stdafx.h"
#include "CalcFeedPublickDlg.h"
#include "CalcFeedSettingDlg.h"
#include "AcDbObjectPtr.h"
#include "DbPipe.h"
#include "PickEntSet.h"
#include "DbEquipment.h"
#include "msword8.h"
#include "dbGridSheet.h"
#include "CalcRoomDlg.h"
#include"TGAs.h"
#include "TWordFormulasTemplet.h"
#include "XText.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern AcDbObjectId InitLayer(const TCHAR *szLayer, AcDbDatabase *pDb = NULL);
void CalcPipeLength(SSearchPipeList *pListAll)
{
if (pListAll->m_iType == 0) {
OPENOBJ_BEGIN(pListAll->m_ID, AcDb::kForRead, CDbPipe, pPipe);
if (pPipe) {
pListAll->m_nLength = pPipe->Length();
}
OPENOBJ_END();
}
long len = pListAll->m_lstNode.Length();
for (long i = 0; i < len; i++) {
SSearchPipeList *pList = pListAll->m_lstNode[i];
CalcPipeLength(pList);
}
return;
}
void CalcPipeLength2(SSearchPipeList *pListAll, SSearchPipeList *pListFront)
{
if (pListAll->m_iType == 0) {
OPENOBJ_BEGIN(pListAll->m_ID, AcDb::kForRead, CDbPipe, pPipe);
if (pPipe) {
pListAll->m_nLength = pPipe->Length();
}
OPENOBJ_END();
}
if (pListFront)
pListAll->m_nLength += pListFront->m_nLength;
long len = pListAll->m_lstNode.Length();
for (long i = 0; i < len; i++) {
SSearchPipeList *pList = pListAll->m_lstNode[i];
pList->m_pPrevious = pListAll;
CalcPipeLength2(pList, pListAll);
}
return;
}
BOOL DoDimSerialNumber(AcDbObjectId id, int idx)
{
extern TCHAR *LAY_CALC_TEXT;
InitLayer(LAY_CALC_TEXT);
GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csTwtDimStyle);
OPENOBJ_BEGIN(id, AcDb::kForRead, CDbPipeNode, pNode);
if (pNode) {
CString csText;
csText.Format(_T("%d"), idx);
XPoint pt = pNode->GetLocation();
XPoint ptText;
double nDist = GlobalFunc::DocGetPScale();
if (GlobalFunc::IsWell(id))
nDist = nDist * g_Option::instance().g_nWellRadius / 2; //如果标注井,距离就大些
ads_polar(pt, PI/2, nDist, ptText);
ads_polar(ptText, 0, nDist, ptText);
XText text(csText, ptText, g_Option::instance().g_nTwtDimHeight * GlobalFunc::DocGetPScale(), g_Option::instance().g_nDimScale, g_Option::instance().g_csTwtDimStyle, LAY_CALC_TEXT);
text.Draw();
return TRUE;
}
OPENOBJ_END();
return FALSE;
}
void DoDimPipeSerialNumber(SSearchPipeList *pListAll)
{
if (pListAll->m_iType == 0) {
CString csNum1 = pListAll->m_pPrevious->m_csName;
if (!pListAll->m_pPrevious->m_pPrevious && csNum1 == _T(""))
csNum1 = _T("末端");
int len2 = pListAll->m_lstNode.Length();
CString csNum2;
if (len2 > 0)
csNum2 = pListAll->m_lstNode[0]->m_csName;
if (csNum1 != _T("") && csNum2 != _T(""))
pListAll->m_csName = csNum2 + _T("-") + csNum1;
}
long len = pListAll->m_lstNode.Length();
for (long i = 0; i < len; i++) {
SSearchPipeList *pList = pListAll->m_lstNode[i];
DoDimPipeSerialNumber(pList);
}
}
int DoSerialNumber2(SSearchPipeList *pListLast, int idx)
{
AcDbObjectId id = NULL;
id = pListLast->m_ID;
if (pListLast->m_iType == 2 || pListLast->m_iType == 1 || pListLast->m_iType == -1) {
if (pListLast->m_csName != _T(""))
return idx;
pListLast->m_csName.Format(_T("%d"), idx);
if (DoDimSerialNumber(id, idx))
idx++;
else
return idx;
}
if (pListLast->m_pPrevious)
idx = DoSerialNumber2(pListLast->m_pPrevious, idx);
return idx;
}
BOOL GetRelationFromDnToV(DList<CTempStruct> &lstDn)
{
XString fullFile;
if (!GlobalFunc::FindFile(_T("datastore.dbf"), fullFile)) {
AfxMessageBox(_T("对不起,没有发现datastore.dbf文件!"));
return 0;
}
CodeBase db;
db.read_only = 1;
DbfTable *pTable = db.Open(fullFile);
if (!pTable)
return 0;
int nType = 0, nRowCount = 0;
CString strName = _T(""), strValue = _T("");
for (pTable->MoveFirst(); !pTable->IsEOF(); pTable->MoveNext())
{
GET_FIELD(pTable, _T("typenumber"), nType);
if (nType == 42)
{
GET_FIELD(pTable, _T("typename"), strName);
GET_FIELD(pTable, _T("typevalue"), strValue);
int iDn = _ttoi(strName);
double dValue = _tstof(strValue);
CTempStruct *pData = new CTempStruct;
pData->m_iTmp = iDn;
pData->m_dTmp = dValue;
lstDn.Append(pData);
}
}
return TRUE;
}
int GetPipeDnByQ(double nQ, AcDbObjectId id, double &nLost, double &nI, double &nSpeed, BOOL bIsReCalc = FALSE)
{
double nLength(-1);
int nRet(-1);
int iMat(-1);
OPENOBJ_BEGIN(id, AcDb::kForRead, CDbPipe, pPipe);
if (pPipe) {
iMat = pPipe->GetMaterial();
nLength = pPipe->Length();
if (bIsReCalc)
nRet = (int)pPipe->GetDnDiameter();
}
OPENOBJ_END();
CString csMat = GlobalFunc::GetPipeMaterialByIdx(iMat);
double nCh(0); // 海澄-威廉系数
if (csMat == _T("镀锌钢管") || csMat == _T("给水铸铁管") || csMat == _T("排水铸铁管") || csMat == _T("焊接钢管") || csMat == _T("无缝钢管"))
nCh = 100;
else
nCh = 140;
DList<int> lstSpec;
GlobalFunc::GetPipeSpecList(lstSpec, csMat);
// Q = 1/4 * PI * Dj * Dj * V
nQ = nQ / 1000;
if (bIsReCalc) //复算
{
double nRetDj = GlobalFunc::GetPipeDjByDn(csMat, nRet);
nSpeed = nQ / (0.25*PI*nRetDj*nRetDj);
if (nRetDj < 0)
return nRet;
nI = 105 * (pow(nRetDj, -4.87)) * (pow(nQ, 1.85)) * (pow(nCh, -1.85)) / 10;
nLost = nI * nLength;
}
else
{
DList<CTempStruct> lstDn;
GetRelationFromDnToV(lstDn);
lstDn.QuickSort(CTempStruct::SortByInt);
// <<建筑给排水规范》2003,P35 表3.6.9
for (int j = 0; j<lstSpec.Length(); j++) {
int iDnTmp = *lstSpec[j];
double nRetDj = GlobalFunc::GetPipeDjByDn(csMat, iDnTmp);
nSpeed = nQ / (0.25*PI*nRetDj*nRetDj);
if (nRetDj < 0)
continue;
nI = 105 * (pow(nRetDj, -4.87)) * (pow(nQ, 1.85)) * (pow(nCh, -1.85)) / 10;
nLost = nI * nLength;
int len = lstDn.Length();
for (int i = 0; i<len; i++)
{
int iTmp = lstDn[i]->m_iTmp;
double dTmp = lstDn[i]->m_dTmp;
dTmp += 0.001;
if (iTmp >= iDnTmp || (iTmp == 80 && iDnTmp > 80))//if(iTmp >= iDnTmp) 2009-12-17 sr 修改。王峻发现bug,管线超过80系统就无法处理了
{
if (nSpeed < dTmp)
return iDnTmp;
break;
}
}
// if(iDnTmp <= 20 && nSpeed <= 1)
// return iDnTmp;
// else if(iDnTmp <= 40 && iDnTmp > 20 && nSpeed <= 1.2)
// return iDnTmp;
// else if(iDnTmp < 80 && iDnTmp > 40 && nSpeed <= 1.5)
// return iDnTmp;
// else if(iDnTmp >= 80 && nSpeed <= 1.8)
// return iDnTmp;
}
}
return nRet;
}
CFeedPublickGrid::CFeedPublickGrid()
{
SetNoAppendButton();
SetNoDefaultMenu();
SetNoPaste();
}
void CFeedPublickGrid::OnCellComboString(WDGridCell&cell,CComboBox&combo)
{
int idx = 4;
CDialog *pDlg =(CDialog*)GetParent();
if(!pDlg->IsKindOf(RUNTIME_CLASS(CCalcFeedPublickDlg)))
idx = 3;
if(cell.GetColIndex()==idx)
{
combo.AddString(_T("15"));
combo.AddString(_T("20"));
combo.AddString(_T("25"));
combo.AddString(_T("32"));
combo.AddString(_T("40"));
combo.AddString(_T("50"));
combo.AddString(_T("70"));
combo.AddString(_T("80"));
combo.AddString(_T("100"));
combo.AddString(_T("125"));
combo.AddString(_T("150"));
combo.AddString(_T("300"));
combo.AddString(_T("350"));
combo.AddString(_T("400"));
combo.AddString(_T("500"));
combo.AddString(_T("600"));
combo.AddString(_T("700"));
}
}
//单元内容将改变为text,返回值代表是否确定
bool CFeedPublickGrid::OnModified(WDGridCell&cell,CString &text)
{
return true;
}
IMPLEMENT_DYNAMIC(CCalcFeedPublickDlg, CDialog)
CCalcFeedPublickDlg::CCalcFeedPublickDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCalcFeedPublickDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCalcFeedPublickDlg)
m_dAlpha = 1.5;
m_iArch = 2;
m_csDn = _T("自动");
m_csLost = _T("");
//}}AFX_DATA_INIT
}
CCalcFeedPublickDlg::~CCalcFeedPublickDlg()
{
}
void CCalcFeedPublickDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCalcFeedPublickDlg)
DDX_Control(pDX, IDC_SEARCHBTN, m_searchPipe);
DDX_Control(pDX, IDC_LIST_CACLARCH, m_publicGrid);
DDX_Text(pDX, IDC_EDIT_ALPH, m_dAlpha);
DDX_CBIndex(pDX, IDC_COMBO_ARCHTYPE, m_iArch);
DDX_CBString(pDX, IDC_COMBO_DN, m_csDn);
DDX_Text(pDX, IDC_EDIT_ALLLOST, m_csLost);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCalcFeedPublickDlg, CDialog)
//{{AFX_MSG_MAP(CCalcFeedPublickDlg)
ON_CBN_SELCHANGE(IDC_COMBO_ARCHTYPE, OnSelchangeComboArchtype)
ON_BN_CLICKED(IDC_BOOKBTN, OnBookbtn)
ON_BN_CLICKED(IDC_RECACULATE, OnRecaculate)
ON_BN_CLICKED(IDC_SEARCHBTN, OnSearchbtn)
ON_BN_CLICKED(IDC_BUTTON_SETTING, OnButtonSetting)
ON_BN_CLICKED(IDC_BUTTON_SHEET, OnButtonSheet)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//公共建筑给水计算 主函数
extern TCHAR *LAY_PIPE_FEED;
extern TCHAR *LAY_VPIPE_FEED;
extern TCHAR *LAY_PIPE_FEED2;
extern TCHAR *LAY_VPIPE_FEED2;
extern TCHAR *LAY_PIPE_FEED3;
extern TCHAR *LAY_VPIPE_FEED3;
void CalcFeedPipeDn()
{
Entity entMainPipe;
RBList rbMask(RTDXF0, _T("ATS_EQUIPMENT"), 8, _T("*"), NULL);
RBList rbMaskPipe = ads_buildlist( -4, _T("<or"),
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, LAY_PIPE_FEED, -4, _T("and>"),
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, LAY_VPIPE_FEED, -4, _T("and>"),
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, LAY_PIPE_FEED2, -4, _T("and>"),
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, LAY_VPIPE_FEED2, -4, _T("and>"),
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, LAY_PIPE_FEED3, -4, _T("and>"),
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, LAY_VPIPE_FEED3, -4, _T("and>"),
-4, _T("or>"), NULL);
if(GlobalFunc::SelectEntity(_T("\n请选择给水总干管<退出>"), entMainPipe, rbMaskPipe) != RTNORM)
return;
//第一步,选择总干管,并找到它之前的堵头
AcDbObjectId idMain = NULL;
OPENOBJ_BEGIN(entMainPipe, AcDb::kForRead, CDbPipe, pPipe);
if(pPipe)
{
AcDbObjectId nodeId1(NULL), nodeId2(NULL);
nodeId1 = pPipe->GetNode(0);
nodeId2 = pPipe->GetNode(1);
OPENOBJ_BEGIN(nodeId1, AcDb::kForRead, CDbPipeNode, pNode);
if(pNode)
{
int num = pNode->GetInterfaceNum();
if(num == 1)
idMain = nodeId1;
}
OPENOBJ_END();
OPENOBJ_BEGIN(nodeId2, AcDb::kForRead, CDbPipeNode, pNode);
if(pNode)
{
int num = pNode->GetInterfaceNum();
if(num == 1)
idMain = nodeId2;
}
OPENOBJ_END();
}
OPENOBJ_END();
if(!idMain)
{
AfxMessageBox(_T("没有正确选择起点干管!"));
return;
}
ads_name entMain;
acdbGetAdsName(entMain, idMain);
SSearchPipeList *pListAll = new SSearchPipeList();
PickSet ssAll(SS_FREE);
ssAll += idMain;
pListAll->m_iType = 1;
if(!GlobalFunc::SearchSprinkPipeSys(entMain, NULL, pListAll, ssAll))
{
AfxMessageBox(_T("系统有回路!"));
delete pListAll;
return;
}
//第二步,搜索整个系统,计算管长,建立双向链表
CalcPipeLength2(pListAll, NULL);
//第三步,标注节点
int idx = 1;
SSearchPipeList *pNode = GlobalFunc::GetNextDimNode2(pListAll, NULL);
while(pNode)
{
idx = DoSerialNumber2(pNode, idx); //标注节点编号
pNode = GlobalFunc::GetNextDimNode2(pListAll, NULL); //得到下一支路起点节点
}
DoDimPipeSerialNumber(pListAll); //标注管段编号
CTemporaryResourceOverride over;
CCalcFeedPublickDlg dlg;
dlg.SetListAll(pListAll);
if(dlg.DoModal() != IDOK)
{
delete pListAll;
return;
}
delete pListAll;
return;
}
void CCalcFeedPublickDlg::OnOK()
{
UpdateData(TRUE);
//第三步,计算管径
CacluatePipe(0);
UpdatePublicGrid(m_listNode);
}
void CCalcFeedPublickDlg::OnSelchangeComboArchtype()
{
UpdateData(TRUE);
// cet 2010.6.25 del
// if(m_iArch == 0)
// m_dAlpha = 1.2;
// else if(m_iArch == 1)
// m_dAlpha = 1.4;
// else if(m_iArch == 2)
// m_dAlpha = 1.5;
// else if(m_iArch == 3)
// m_dAlpha = 1.8;
// else if(m_iArch == 4)
// m_dAlpha = 2.0;
// else if(m_iArch == 5)
// m_dAlpha = 2.5;
// else if(m_iArch == 6)
// m_dAlpha = 3.0;
// cet 2010.6.25 add
if(m_iArch == 0)
m_dAlpha = 1.2;
else if(m_iArch == 1)
m_dAlpha = 1.4;
else if(m_iArch == 2)
m_dAlpha = 1.5;
else if(m_iArch == 3)
m_dAlpha = 1.6;
else if(m_iArch == 4)
m_dAlpha = 1.7;
else if(m_iArch == 5)
m_dAlpha = 1.8;
else if(m_iArch == 6)
m_dAlpha = 2.0;
else if(m_iArch == 7)
m_dAlpha = 2.2;
else if(m_iArch == 8)
m_dAlpha = 2.5;
else if(m_iArch == 9)
m_dAlpha = 3.0;
UpdateData(FALSE);
}
BOOL CCalcFeedPublickDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_publicGrid.Create(this,IDC_LIST_CACLARCH);
m_publicGrid.Refresh();
m_publicGrid.AppendCol(_T("管段名称"),60);
m_publicGrid.AppendCol(_T("管道流量L/s"),72);
m_publicGrid.AppendCol(_T("管长m"),50);
m_publicGrid.AppendCol(_T("累计当量"),60);
m_publicGrid.AppendCol(_T("标注管径"),60);
m_publicGrid.AppendCol(_T("水力坡降mH2O/m"),88);
m_publicGrid.AppendCol(_T("流速m/s"),50);
m_publicGrid.AppendCol(_T("沿程损失mH2O"),80);
m_publicGrid.GetCol(0).SetReadOnly();
m_publicGrid.GetCol(1).SetReadOnly();
m_publicGrid.GetCol(2).SetReadOnly();
m_publicGrid.GetCol(3).SetReadOnly();
m_publicGrid.GetCol(4).SetComboSel();
m_publicGrid.GetCol(5).SetReadOnly();
m_publicGrid.GetCol(6).SetReadOnly();
m_publicGrid.GetCol(7).SetReadOnly();
m_publicGrid.GetCol(4).SetTextColor(RGB(255,0,0));
m_publicGrid.GetCol(5).SetTextColor(RGB(0,0,255));
m_publicGrid.GetCol(6).SetTextColor(RGB(0,0,255));
m_publicGrid.GetCol(7).SetTextColor(RGB(0,0,255));
m_bitSearchPipe.LoadBitmap(IDB_SEARCHPIPE);
m_searchPipe.SetBitmap((HBITMAP)m_bitSearchPipe);
CacluatePipe(1);
UpdatePublicGrid(m_listNode,FALSE);
return TRUE;
}
void CCalcFeedPublickDlg::SetObjectID(AcDbObjectId id)
{
m_id = id;
}
void CCalcFeedPublickDlg::DoDimFeedPipeDn(SSearchPipeList *pListAll, double nA, int iMode)
{
AcDbObjectId id = NULL;
id = pListAll->m_ID;
pListAll->m_iNum = 0;
double nDang(0), dRateQ(0);
if(pListAll->m_iType == -1)
{
AcDbObjectId id = pListAll->m_ID;
OPENOBJ_BEGIN(id, AcDb::kForRead, CDbEquipment, pEquip);
if(pEquip){
nDang = pEquip->GetDang();
dRateQ = pEquip->GetSpare();
AcDbObjectId idBlk = pEquip->GetBlock2d();
CString csBlkName = GlobalFunc::GetBlkNameById(idBlk);
CString csSysName = pEquip->GetSysBlock();
if(_tcsicmp(_T("$TWTSYS$00000290"), csBlkName) == 0 || //大便器自闭式冲洗阀
_tcsicmp(_T("$TWTSYS$00000291"), csBlkName) == 0 ||
_tcsicmp(_T("$TWTSYS$00000292"), csBlkName) == 0 ||
_tcsicmp(_T("$TWTSYS$00000293"), csBlkName) == 0 ||
_tcsicmp(_T("$TWTSYS$00000502"), csBlkName) == 0 || //大便器感应式冲洗阀
_tcsicmp(_T("$TWTSYS$00000503"), csBlkName) == 0 ||
_tcsicmp(_T("$TWTSYS$00000504"), csBlkName) == 0 ||
_tcsicmp(_T("$TWTSYS$00000505"), csBlkName) == 0 ||
_tcsicmp(_T("$TWTSYS$00000430"), csBlkName) == 0 || //脚踏式大便器 sr 2009-8-22 add
_tcsicmp(_T("$TWTSYS$00000431"), csBlkName) == 0 ||
_tcsicmp(_T("$TWTSYS$00000432"), csBlkName) == 0 ||
_tcsicmp(_T("$TWTSYS$00000433"), csBlkName) == 0 ||
_tcsicmp(_T("$ATTACHMENT$00000132"), csBlkName) == 0 || // cet 2010.11.26 add 延时自闭冲洗阀
_tcsicmp(_T("$ATTACHMENT$00000131"), csBlkName) == 0 || // cet 2010.11.26 add 延时自闭冲洗阀
_tcsicmp(_T("TWTSYS(00000502)"), csSysName) == 0 ||
_tcsicmp(_T("TWTSYS(00000503)"), csSysName) == 0 ||
_tcsicmp(_T("TWTSYS(00000504)"), csSysName) == 0 ||
_tcsicmp(_T("TWTSYS(00000505)"), csSysName) == 0 ||
_tcsicmp(_T("TWTSYS(00000430)"), csSysName) == 0 ||
_tcsicmp(_T("TWTSYS(00000431)"), csSysName) == 0 ||
_tcsicmp(_T("TWTSYS(00000432)"), csSysName) == 0 ||
_tcsicmp(_T("TWTSYS(00000433)"), csSysName) == 0 ||
_tcsicmp(_T("TWTSYS(00000290)"), csSysName) == 0 ||
_tcsicmp(_T("TWTSYS(00000291)"), csSysName) == 0 ||
_tcsicmp(_T("TWTSYS(00000292)"), csSysName) == 0 ||
_tcsicmp(_T("TWTSYS(00000293)"), csSysName) == 0 )
{ //大便器自闭式冲洗阀
if(nDang > 5)
{
pListAll->m_bNeedCale = TRUE; //临时存一下
nDang = 0.5; //大便器自闭式冲洗阀,当量按0.5
}
}
else if(_tcsicmp(_T("$TWTSYS$00000132"), csBlkName) == 0 && pEquip->GetPipeLength() < 0)
pListAll->m_bNeedCale = TRUE; //给水原理图,【修改当量】设置有自闭式冲洗阀
}
OPENOBJ_END();
pListAll->m_nDang = nDang;
pListAll->m_nSpare = dRateQ;
pListAll->m_nStartPress = dRateQ;
}
ads_name ent;
acdbGetAdsName(ent, id);
long len = pListAll->m_lstNode.Length();
// double dSumDang = pListAll->m_nDang;
for(long i=0;i<len;i++)
{
SSearchPipeList *pList = pListAll->m_lstNode[i];
pList->m_pPrevious = pListAll;
DoDimFeedPipeDn(pList, nA, iMode);
pListAll->m_nDang += pList->m_nDang;
if(pList->m_nStartPress > pListAll->m_nStartPress) //记录本管段最大额定流量
pListAll->m_nStartPress = pList->m_nStartPress;
pListAll->m_nSpare += pList->m_nSpare; //记录本管道总额定流量
if(pList->m_bNeedCale)//如果下面节点有大便器自闭式冲洗阀,则本节点流量也加1.1
pListAll->m_bNeedCale = TRUE;
}
// pListAll->m_nDang = dSumDang;
double nQ = 0.2 * nA * sqrt(pListAll->m_nDang);
//《建筑给水排水设计规范》2003 3.6.5 2006,10,30 sr 改为规范计算
if(pListAll->m_bNeedCale)
// nQ += 1.1; // cet 2010.6.28 del
nQ += 1.2; // cet 2010.6.28 add
// 大便器延时自闭冲洗阀的给水管段,大便器延时自闭冲洗阀的给水当量均以0.5计,计算得到的 附加1.10L/s的流量后,为该管段的给水设计秒流量。
if(nQ > pListAll->m_nSpare)
nQ = pListAll->m_nSpare;
//如计算值大于该管段上按卫生器具给水额定流量累加所得流量值时,应按卫生器具给水额定流量累加所得流量值采用。
if(nQ < pListAll->m_nStartPress)
nQ = pListAll->m_nStartPress;
//如计算值小于该管段上一个最大卫生器具给水额定流量时,应采用一个最大的卫生器具给水额定流量作为设计秒流量。
pListAll->m_nPipeQ = nQ;
if(pListAll->m_iType != 0 || pListAll->m_nPipeQ < 0.001)
return;
double nLost(-1), nI(-1), nSpeed(0);
int iDn(0);
if(iMode == 0){
iDn = GetPipeDnByQ(nQ, pListAll->m_ID, nLost, nI, nSpeed);
//2009-4-1 末端管径究竟是50(按及时)还是给一个小管径,这个用户有分歧,做成可以设置的。
if(m_csDn != _T("自动"))
{
double dDn = _tstof(m_csDn);
if(len == 1 && pListAll->m_bNeedCale){
SSearchPipeList *pList = pListAll->m_lstNode[0];
if(pList->m_lstNode.Length() == 0)
iDn = (int)dDn;
if(iDn != 50)
GetPipeVIByDn(nQ, pListAll->m_ID, iDn, nLost, nI, nSpeed);
}
}
//大便器延时自闭冲洗阀 末端尽管流量很大,也不能用50的管径,一般末端用25, 倒数第二段用32 sr modify 2006-5-16 出自天津院
// if(len == 1 && iDn == 50 && pListAll->m_bNeedCale){
// SSearchPipeList *pList = pListAll->m_lstNode[0];
// if(pList->m_lstNode.Length() == 0)
// iDn = 25;
// else if(pList->m_lstNode.Length() == 1){
// SSearchPipeList *pList2 = pList->m_lstNode[0];
// if(pList2->m_lstNode.Length() == 1){
// SSearchPipeList *pList3 = pList2->m_lstNode[0];
// if(pList3->m_lstNode.Length() == 0)
// iDn = 32;
// }
// }
// if(iDn != 50)
// GetPipeVIByDn(nQ, pListAll->m_ID, iDn, nLost, nI, nSpeed);
// }
}
else{
CString csMat;
double nLength(1);
OPENOBJ_BEGIN(pListAll->m_ID, AcDb::kForRead, CDbPipe, pPipe);
if(pPipe){
iDn = (int)pPipe->GetDnDiameter();
csMat = GlobalFunc::GetPipeMaterialByIdx(pPipe->GetMaterial());
// nLength = pPipe->Length() / 1000;
nLength = pPipe->Length();
}
OPENOBJ_END();
double nCh(140); // 海澄-威廉系数
if(csMat == _T("镀锌钢管") || csMat == _T("给水铸铁管") || csMat == _T("排水铸铁管") || csMat == _T("焊接钢管") || csMat == _T("无缝钢管"))
nCh = 100;
else
nCh = 140;
double nRetDj = GlobalFunc::GetPipeDjByDn(csMat, iDn);
nQ = nQ /1000;
nSpeed = nQ / (0.25*PI*nRetDj*nRetDj);
nI = 105 * (pow(nRetDj, -4.87)) * (pow(nQ, 1.85)) * (pow(nCh, -1.85)) / 10;
nLost = nI * nLength;
}
pListAll->m_nLost = nLost;
pListAll->m_nI = nI;
pListAll->m_iDn = iDn;
pListAll->m_nV = nSpeed;
GlobalFunc::DoDimPipeDn(ent, iDn, _T("自动"), g_Option::instance().g_nPipeDnHeight, FALSE, FALSE);
}
//得到最不利节点
SSearchPipeList* CCalcFeedPublickDlg::GetFeedDisadvantageNode(SSearchPipeList *pListAll, SSearchPipeList *pDisadvantage)
{
AcDbObjectId id = NULL;
id = pListAll->m_ID;
double nCurPipeLength(0);
nCurPipeLength = pListAll->m_nLength;
if(GlobalFunc::IsEquipment(id)){
if(!pDisadvantage || (pDisadvantage && nCurPipeLength > pDisadvantage->m_nLength))
pDisadvantage = pListAll;
}
int len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++){
SSearchPipeList *pList = pListAll->m_lstNode[i];
pDisadvantage = GetFeedDisadvantageNode(pList, pDisadvantage);
}
return pDisadvantage;
}
//计算总的沿程水头损失
void CCalcFeedPublickDlg::DoCalcFeedWaterLost(SSearchPipeList *pDisadvantage, double &dAllLostRet)
{
double nAllLost(-1);
nAllLost = pDisadvantage->m_nLost;
if(pDisadvantage->m_pPrevious)
{
// pDisadvantage->m_pPrevious->m_nLost += nAllLost;
if(pDisadvantage->m_iType == 0)
dAllLostRet += nAllLost;
DoCalcFeedWaterLost(pDisadvantage->m_pPrevious, dAllLostRet);
}
}
void CCalcFeedPublickDlg::OnBookbtn()
{
//出计算书
ImportFeedCalcWord(m_listNode, m_csArch, m_dAlpha);
}
//输出计算书函数
void CCalcFeedPublickDlg::ImportFeedCalcWord(DList<SSearchPipeList> &lstNode,
const TCHAR* szArch, double nA)
{
if (m_pListAll == NULL)
return;
int len = lstNode.Length();
if(len < 1)
{
MessageBox(_T("请先计算!"));
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 = GlobalFunc::GetSysDir();
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 add
_Font font;
font = wordSelection.GetFont();
// wordSelection.TypeText(_T("计算原理参照《建筑给水排水设计规范GB50015-2003》,采用公共建筑采用当量法 \n")); // cet 2010.6.28 del
wordSelection.TypeText(_T("计算原理参照《建筑给水排水设计规范GB50015-2003》(2009年版),采用公共建筑采用当量法 \n")); // cet 2010.6.28 add
wordSelection.TypeText(_T("基本计算公式 \n"));
// wordSelection.TypeText(_T("Q = 0.2 × SQRT(Ng) × α\n")); // cet 2010.6.28 del
// cet 2010.6.28 add
wordSelection.TypeText(_T(" "));
wdFormula.InsertFormula(4, wordSelection);
wordSelection.TypeText(_T("\n式中:\n"));
// cet 2010.6.28 del
// wordSelection.TypeText(_T("Q-计算管段的给水设计秒流量(L/s) \n"));
// wordSelection.TypeText(_T("Ng-计算管段的卫生器具给水当量总数 \n"));
// cet 2010.6.28 add
wordSelection.TypeText(_T(" q"));
font.SetSubscript(2); //处理下标
wordSelection.TypeText(_T("g"));
font.SetSubscript(0);
wordSelection.TypeText(_T("-计算管段的给水设计秒流量(L/s) \n"));
wordSelection.TypeText(_T(" N"));
font.SetSubscript(2); //处理下标
wordSelection.TypeText(_T("g"));
font.SetSubscript(0);
wordSelection.TypeText(_T("-计算管段的卫生器具给水当量总数 \n"));
wordSelection.TypeText(XString(_T(" α-根据建筑物用途而定的系数:%.1f \n"), nA));
wordSelection.TypeText(XString(_T(" 建筑类型:%s\n"), szArch));
// wordSelection.TypeText(XString(_T("末端压力:%.3f MPa\n"), nPress));
// wordSelection.TypeText(XString(_T("局部损失系数:%.0f %\n"), nFactor));
wordSelection.TypeText(_T("计算结果:\n"));
// wordSelection.TypeText(XString(_T("沿程损失:%.3f MPa\n"), nLost));
// wordSelection.TypeText(XString(_T("起点压力:%.3f MPa\n"), nStartPress));
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(50, 0);
oColumn = oColumns.Item(3);
oColumn.SetWidth(40, 0);
oColumn = oColumns.Item(4);
oColumn.SetWidth(55, 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("管长m"));
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("沿程损失mH2O"));
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);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nLength);
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, CDbPipe, pPipe);
if(pPipe){
iMat = pPipe->GetMaterial();
}
OPENOBJ_END();
CString csMat = GlobalFunc::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 CCalcFeedPublickDlg::GetPipeVIByDn(double nQ, AcDbObjectId id, int iDn, double &nLost, double &nI, double &nSpeed)
{
double nLength(-1);
int nRet(-1);
int iMat(-1);
OPENOBJ_BEGIN(id, AcDb::kForRead, CDbPipe, pPipe);
if(pPipe){
iMat = pPipe->GetMaterial();
// nLength = pPipe->Length() / 1000;
nLength = pPipe->Length();
}
OPENOBJ_END();
CString csMat = GlobalFunc::GetPipeMaterialByIdx(iMat);
double nCh(0); // 海澄-威廉系数
if(csMat == _T("镀锌钢管") || csMat == _T("给水铸铁管") || csMat == _T("排水铸铁管") || csMat == _T("焊接钢管") || csMat == _T("无缝钢管"))
nCh = 100;
else
nCh = 140;
// Q = 1/4 * PI * Dj * Dj * V
nQ = nQ / 1000;
double nRetDj = GlobalFunc::GetPipeDjByDn(csMat, iDn);
nSpeed = nQ / (0.25*PI*nRetDj*nRetDj);
nI = 105 * (pow(nRetDj, -4.87)) * (pow(nQ, 1.85)) * (pow(nCh, -1.85)) / 10;
nLost = nI * nLength;
}
//得到下一个导出WORD节点 根据节点计算顺序排序
SSearchPipeList *CCalcFeedPublickDlg::GetNextExportNode2(SSearchPipeList *pListAll, SSearchPipeList *pDisadvantage,std::map<CString,int> mapLable)
{
if (mapLable.find(pListAll->m_csName) == mapLable.end())
{
CString csName = pListAll->m_csName;
int idx = csName.Find(_T("-"));
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 = GetNextExportNode2(pList, pDisadvantage,mapLable);
}
return pDisadvantage;
}
//计算 nMode = 0 初算 1 复算
void CCalcFeedPublickDlg::CacluatePipe(int nMode)
{
UpdateData();
//更新管径
UpdatePipeRadius();
// cet 2010.6.25 del
// if(m_iArch == 0)
// m_csArch = _T("幼儿园、托儿所、养老院");
// else if(m_iArch == 1)
// m_csArch = _T("门诊部、诊疗所");
// else if(m_iArch == 2)
// m_csArch = _T("办公楼、商场");
// else if(m_iArch == 3)
// m_csArch = _T("学校");
// else if(m_iArch == 4)
// m_csArch = _T("医院、疗养院、休养所");
// else if(m_iArch == 5)
// m_csArch = _T("集体宿舍、旅馆、招待所、宾馆");
// else if(m_iArch == 6)
// m_csArch = _T("客运站、会展中心、公共厕所");
// cet 2010.6.25 add
if(m_iArch == 0)
m_csArch = _T("幼儿园、托儿所、养老院");
else if(m_iArch == 1)
m_csArch = _T("门诊部、诊疗所");
else if(m_iArch == 2)
m_csArch = _T("办公楼、商场");
else if(m_iArch == 3)
m_csArch = _T("图书馆");
else if(m_iArch == 4)
m_csArch = _T("书店");
else if(m_iArch == 5)
m_csArch = _T("学校");
else if(m_iArch == 6)
m_csArch = _T("医院、疗养院、休养所");
else if(m_iArch == 7)
m_csArch = _T("酒店式公寓");
else if(m_iArch == 8)
m_csArch = _T("宿舍(Ⅰ、Ⅱ类)、旅馆、招待所、宾馆");
else if(m_iArch == 9)
m_csArch = _T("客运站、航站楼、会展中心、公共厕所");;
//计算
ResetList(m_pListAll);
m_listNode.Reset();
DoDimFeedPipeDn(m_pListAll, m_dAlpha, nMode);
GlobalFunc::UpdateMultDim();
double dAllLost(0);
CalcPipeLength2(m_pListAll, NULL);
SSearchPipeList *pDisadvantage = NULL;
pDisadvantage = GetFeedDisadvantageNode(m_pListAll, NULL);
if(pDisadvantage != NULL)
DoCalcFeedWaterLost(pDisadvantage, dAllLost);
CalcPipeLength(m_pListAll);
m_csLost.Format(_T("%.2f"), dAllLost);
UpdateData(FALSE);
std::map<CString,int> mapLable;
SSearchPipeList *pNode = GetNextExportNode2(m_pListAll, NULL,mapLable);
int i = 0;
CString sText;
while(pNode)
{
SSearchPipeList *pNodeNew = new SSearchPipeList();
pNodeNew->m_ID = pNode->m_ID;
pNodeNew->m_iDn = pNode->m_iDn;
pNodeNew->m_csName = pNode->m_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;
//更新数据结构管径的值
if (m_publicGrid.GetRowNum() > 0)
{
OPENOBJ_BEGIN(pNodeNew->m_ID, AcDb::kForWrite, CDbPipe, pPipe);
if(pPipe)
{
sText = m_publicGrid.GetCell(i,4).GetText();
if (nMode == 1)
pNodeNew->m_iDn = _ttoi(sText);
}
OPENOBJ_END();
i++;
}
m_listNode.Append(pNodeNew);
mapLable[pNode->m_csName] = 0;
pNode = GetNextExportNode2(m_pListAll, NULL,mapLable);
}
}
//显示表中的类容 bshowre = TRUE 显示计算结果 否则不显示计算结果
void CCalcFeedPublickDlg::UpdatePublicGrid(DList<SSearchPipeList> &lstNode,BOOL bShowRe)
{
m_publicGrid.Clear();
CString csTmp;
int nLen = lstNode.Length();
while (m_arId.length() > 0)
{
m_arId.removeAt(0);
}
for (int i = 0; i < nLen; ++i)
{
m_publicGrid.AppendRow();
m_publicGrid.GetCell(i,0).SetText(lstNode[i]->m_csName);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nPipeQ);
m_publicGrid.GetCell(i,1).SetText(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nLength);
m_publicGrid.GetCell(i,2).SetText(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nDang);
m_publicGrid.GetCell(i,3).SetText(csTmp);
csTmp.Format(_T("%d"), lstNode[i]->m_iDn);
m_publicGrid.GetCell(i,4).SetText(csTmp);
if (bShowRe)
{
csTmp.Format(_T("%.3f"), lstNode[i]->m_nI);
m_publicGrid.GetCell(i,5).SetText(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nV);
m_publicGrid.GetCell(i,6).SetText(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nLost);
m_publicGrid.GetCell(i,7).SetText(csTmp);
}
m_arId.append(lstNode[i]->m_ID);
}
}
//更新管径
void CCalcFeedPublickDlg::UpdatePipeRadius()
{
CString sText;
int nLen = m_arId.length();
for (int i = 0; i < nLen; ++i)
{
OPENOBJ_BEGIN(m_arId.at(i), AcDb::kForWrite, CDbPipe, pPipe);
if(pPipe)
{
sText = m_publicGrid.GetCell(i,4).GetText();
pPipe->SetDnDiameter(_ttoi(sText));
}
OPENOBJ_END();
}
}
void CCalcFeedPublickDlg::SetListAll(SSearchPipeList *pListAll)
{
m_pListAll = pListAll;
}
void CCalcFeedPublickDlg::ResetList(SSearchPipeList *pListAll)
{
pListAll->m_nDang = 0;
pListAll->m_nLost = 0;
pListAll->m_nLength = 0;
pListAll->m_nI = 0;
pListAll->m_nPipeQ = 0;
pListAll->m_nStartPress = 0;
pListAll->m_nV = 0;
pListAll->m_nSpare = 0;
long len = pListAll->m_lstNode.Length();
for(long i=0;i<len;i++)
{
SSearchPipeList *pList = pListAll->m_lstNode[i];
ResetList(pList);
}
}
//复算
void CCalcFeedPublickDlg::OnRecaculate()
{
CacluatePipe(1);
UpdatePublicGrid(m_listNode);
}
//找到所选择的管子
void CCalcFeedPublickDlg::OnSearchbtn()
{
if (m_pListAll == NULL)
return;
std::map<CString,int> mapLable;
SSearchPipeList *pNode = GetNextExportNode2(m_pListAll, NULL,mapLable);
int i = 0;
int nSelR = m_publicGrid.GetCurRowIndex();
if (nSelR < 0)
{
AfxMessageBox(_T("请选择一行!"));
return;
}
CString sText;
AcDbObjectId id;
while(pNode)
{
id = pNode->m_ID;
if (i == nSelR)
{
OPENOBJ_BEGIN(id, AcDb::kForRead, CDbPipe, pPipe);
if(pPipe)
{
XPoint ptCen, p1, p2, p3, p4;
ptCen = pPipe->MidPoint();
double nDist = pPipe->Length()*2000;
GlobalFunc::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();
}
mapLable[pNode->m_csName] = 0;//防止循环退不出去
pNode = GetNextExportNode2(m_pListAll, NULL,mapLable);
i++;
}
GlobalFunc::HideDialog(this, TRUE);
TCHAR szTmp[256];
ads_getstring(NULL, _T("\n按任意键返回对话框:<返回>"), szTmp);
GlobalFunc::HideDialog(this, FALSE);
}
void CCalcFeedPublickDlg::OnButtonSetting()
{
CTemporaryResourceOverride vTemp;
CCalcFeedSettingDlg dlg;
dlg.DoModal();
}
void CCalcFeedPublickDlg::OnButtonSheet()
{
UpdateData(TRUE);
GlobalFunc::HideDialog(this, TRUE);
XPoint pt;
if(acedGetPoint(NULL, _T("\n点取表格左上角位置:<返回>"), pt) != RTNORM)
{
GlobalFunc::HideDialog(this, FALSE);
return;
}
double nTextSize = g_Option::instance().g_nSheetHeight;
double nTableHeight = g_Option::instance().g_nSheetHeight+2;
AcDbObjectId idTextStyle=GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csSheetStyle);
CDbSheet *pSheet = new CDbSheet;
GridStyle gridStyle;
gridStyle.SetOverrideAll(TRUE);
gridStyle.SetTextHeight(nTextSize);
gridStyle.SetTextStyleId(idTextStyle);
SheetTitle &title=pSheet->GetTitle();
title.SetHeight(nTextSize);
title.SetText(_T("公共建筑给水计算表"));
GridStyle &gridStyle2=title.GetGridStyle();
gridStyle2.SetTextHeight(nTextSize);
gridStyle2.SetTextStyleId(idTextStyle);
DividerStyle &style=title.GetDividerStyle();
style.SetDividerFlag(DividerStyle::kNone);
gridStyle.SetHorMode(AcDb::kTextCenter);
gridStyle.SetVerMode(AcDb::kTextVertMid);
gridStyle.SetLineSpaceFactor(0.2);
gridStyle.SetTextWrap(FALSE);
pSheet->SetGridStyle(gridStyle);
pSheet->SetRowHeight(nTableHeight);
pSheet->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0));
pSheet->SetLocation(GlobalFunc::Ucs2Wcs(pt));
int nAllRow = (int)m_publicGrid.GetRowNum();
pSheet->InitSheet(nAllRow + 1, 8, nTableHeight, 50);
DividerStyle &styleBorder = pSheet->GetBorderStyle();
styleBorder.SetLineWidth(0.2);
SheetRow *pRow = pSheet->GetRow(0);
if (pRow != NULL)
{
DividerStyle &styleRow = pRow->GetDividerStyle();
styleRow.SetLineWidth(0.2);
styleRow.SetDividerFlag(DividerStyle::kLocal);
}
pSheet->SetLocation(GlobalFunc::Ucs2Wcs(pt));
XPoint ptex = pSheet->GetExtents(FALSE);
SheetColumn column;
column.SetWidth(15);
pSheet->SetColumnAt(0, column);
column.SetWidth(20);
pSheet->SetColumnAt(1, column);
column.SetWidth(15);
pSheet->SetColumnAt(2, column);
column.SetWidth(20);
pSheet->SetColumnAt(3, column);
column.SetWidth(20);
pSheet->SetColumnAt(4, column);
column.SetWidth(30);
pSheet->SetColumnAt(5, column);
column.SetWidth(20);
pSheet->SetColumnAt(6, column);
column.SetWidth(25);
pSheet->SetColumnAt(7, column);
GridCell &cell01=*(*pSheet)(0, 0);
cell01.SetText(_T("管段名称"));
GridCell &cell02=*(*pSheet)(0, 1);
cell02.SetText(_T("管道流量L/s"));
GridCell &cell03=*(*pSheet)(0, 2);
cell03.SetText(_T("管长m"));
GridCell &cell08=*(*pSheet)(0, 3);
cell08.SetText(_T("累计当量"));
GridCell &cell04=*(*pSheet)(0, 4);
cell04.SetText(_T("标注管径"));
GridCell &cell05=*(*pSheet)(0, 5);
cell05.SetText(_T("水力坡降mH2O/m"));
GridCell &cell06=*(*pSheet)(0, 6);
cell06.SetText(_T("流速m/s"));
GridCell &cell07=*(*pSheet)(0, 7);
cell07.SetText(_T("沿程损失mH2O"));
for(int j = 1; j < m_publicGrid.GetRowNum() + 1; j++)
{
for (int i = 0; i < m_publicGrid.GetColNum(); i++)
{
GridCell &Cell=*(*pSheet)(j, i);
CString sText = (LPCTSTR)m_publicGrid.GetCell(j-1,i).GetText();
Cell.SetText(sText);
}
}
GlobalFunc::AddToModelSpace(pSheet);
//pSheet->AddToCSpace(TRUE);
TCHAR szTmp[32];
ads_getstring(NULL, _T("\n按任意键返回对话框:<返回>"), szTmp);
GlobalFunc::HideDialog(this, FALSE);
}