334 lines
10 KiB
C++
334 lines
10 KiB
C++
// CalcDirtWellDataDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include <DbWell.h>
|
|
#include <DbSpace.h>
|
|
#include <tapi.h>
|
|
#include <ssearchPipeList.h>
|
|
#include <twtdef.h>
|
|
|
|
#include "CalcDirtWellDataDlg.h"
|
|
#include "WaterRationDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//***************************************************************************************************
|
|
// 服务面积
|
|
//***************************************************************************************************
|
|
|
|
void DirtParameter()
|
|
{
|
|
// CString csAreaLayer = _T("TWT_汇流面积"); // 8.0发行之前要修改过来
|
|
|
|
RBList rbMask(RTDXF0, _T("ATS_WELL"), 8, LAY_WELL_DIRT, NULL);
|
|
RBList rbMask2(RTDXF0, _T("ATS_SPACE"), 8, LAY_CALC_AREA, NULL); // 服务面积
|
|
PickSet ssAll(SS_FREE);
|
|
ssAll.Get(_T("X"), NULL, NULL, rbMask2);
|
|
PickSet ssWell(SS_FREE);
|
|
if (SelectEntities(_T("\n请选择污水井:<退出>"), ssWell, rbMask) != RTNORM)
|
|
return;
|
|
Entity entSel(ssWell[0L]); // 无论单、选多选只要第一个实体样板
|
|
|
|
// 读取扩展数据
|
|
CString csWellName = GetWellName(entSel);
|
|
CString csArea = ReadXdata(entSel, _T("TG-WELLAREA"));
|
|
CString csRation = ReadXdata(entSel, _T("TG-DIRTRATION"));
|
|
CString csPeople = ReadXdata(entSel, _T("TG-DIRTPEOPLE"));
|
|
CString csQ = ReadXdata(entSel, _T("TG-DIRTFOCUSQ"));
|
|
CString csWaterRation = ReadXdata(entSel, _T("TG-WATERRATION")); // 给水指标
|
|
CString csDirtCoef = ReadXdata(entSel, _T("TG-DIRTCOEF")); // 污水折减系数
|
|
double nArea(0);
|
|
for(long j=0;j<ssAll.Length();j++){
|
|
Entity ent = ssAll[j];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbSpace, pSpace);
|
|
if(pSpace){
|
|
pSpace->SetHighlight(TRUE);
|
|
CString csName = pSpace->GetName();
|
|
int iCharLen = (int)_tcslen(_T("服务面积"));
|
|
csName = csName.Left(csName.GetLength() - iCharLen);
|
|
if(csName == csWellName){
|
|
nArea = pSpace->m_nUseArea;
|
|
if(nArea < 1 && DocGetMeterUnitDraw())
|
|
nArea = nArea * 1000000;
|
|
csArea.Format(_T("%.2f"), nArea);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
// 显示所选井的数据信息
|
|
CTemporaryResourceOverride vTemp2;
|
|
CCalcDirtWellDataDlg dlg;
|
|
long len = ssWell.Length();
|
|
if (1 != len)
|
|
dlg.EnableSelArea(FALSE); // 选中多个实体情况下禁止用户手动绘制用水区域
|
|
dlg.m_ent = entSel;
|
|
if (!(csArea == _T("") && csPeople == _T("") && csRation == _T("") && csDirtCoef == _T("") && csWaterRation == _T("")))
|
|
{ // 有定义过 (如果没有定义过则有自己的初始值)
|
|
if (csRation == _T("") && csPeople == _T(""))
|
|
{ // 工业
|
|
dlg.m_bLife = FALSE;
|
|
dlg.m_bIndustry = TRUE;
|
|
double nArea = _tstof(csArea) / 10000;
|
|
dlg.m_csAreaIndustry.Format(_T("%.2f"), nArea);
|
|
dlg.m_dWasteCoef = _tstof(csDirtCoef);
|
|
dlg.m_dWaterRation = _tstof(csWaterRation);
|
|
}
|
|
else if (csWaterRation == _T("") && csDirtCoef == _T(""))
|
|
{ // 生活
|
|
dlg.m_bLife = TRUE;
|
|
dlg.m_bIndustry = FALSE;
|
|
double nArea = _tstof(csArea) / 10000;
|
|
dlg.m_csArea.Format(_T("%.2f"), nArea);
|
|
dlg.m_iPeople = _ttoi(csPeople);
|
|
dlg.m_nRation = _tstof(csRation);
|
|
}
|
|
}
|
|
if(csQ == _T(""))
|
|
dlg.m_bOther = FALSE;
|
|
else{
|
|
dlg.m_bOther = TRUE;
|
|
dlg.m_nQ = _tstof(csQ);
|
|
}
|
|
|
|
if(dlg.DoModal() != IDOK)
|
|
return;
|
|
|
|
long idx(0);
|
|
for (idx; idx < len; idx++)
|
|
{
|
|
Entity ent = ssWell[idx];
|
|
// 写扩展数据
|
|
if(dlg.m_bLife)
|
|
{ // 生活
|
|
double nArea = _tstof(dlg.m_csArea) * 10000;
|
|
WriteXdata(ent, _T("TG-WELLAREA"), XString(_T("%.2f"), nArea));
|
|
WriteXdata(ent, _T("TG-DIRTRATION"), XString(_T("%.2f"), dlg.m_nRation));
|
|
WriteXdata(ent, _T("TG-DIRTPEOPLE"), XString(_T("%d"), dlg.m_iPeople));
|
|
WriteXdata(ent, _T("TG-WATERRATION"), _T("")); // 给水指标
|
|
WriteXdata(ent, _T("TG-DIRTCOEF"), _T("")); // 污水折减系数
|
|
}
|
|
else if (dlg.m_bIndustry)
|
|
{ // 工业 add 2008-6-13
|
|
double nArea = _tstof(dlg.m_csAreaIndustry) * 10000;
|
|
WriteXdata(ent, _T("TG-WELLAREA"), XString(_T("%.2f"), nArea));
|
|
WriteXdata(ent, _T("TG-WATERRATION"), XString(_T("%.2f"), dlg.m_dWaterRation)); // 给水指标
|
|
WriteXdata(ent, _T("TG-DIRTCOEF"), XString(_T("%.2f"),dlg.m_dWasteCoef)); // 污水折减系数
|
|
WriteXdata(ent, _T("TG-DIRTRATION"), _T(""));
|
|
WriteXdata(ent, _T("TG-DIRTPEOPLE"), _T(""));
|
|
}
|
|
else{
|
|
WriteXdata(ent, _T("TG-WELLAREA"), _T(""));
|
|
WriteXdata(ent, _T("TG-DIRTRATION"), _T(""));
|
|
WriteXdata(ent, _T("TG-DIRTPEOPLE"), _T(""));
|
|
WriteXdata(ent, _T("TG-WATERRATION"), _T("")); // 给水指标
|
|
WriteXdata(ent, _T("TG-DIRTCOEF"), _T("")); // 污水折减系数
|
|
}
|
|
if(dlg.m_bOther)
|
|
WriteXdata(ent, _T("TG-DIRTFOCUSQ"), XString(_T("%.2f"), dlg.m_nQ));
|
|
else
|
|
WriteXdata(ent, _T("TG-DIRTFOCUSQ"), _T(""));
|
|
}
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CCalcDirtWellDataDlg dialog
|
|
|
|
|
|
CCalcDirtWellDataDlg::CCalcDirtWellDataDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CCalcDirtWellDataDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CCalcDirtWellDataDlg)
|
|
m_bLife = FALSE;
|
|
m_bOther = FALSE;
|
|
m_csArea = _T("5");
|
|
m_iPeople = 350;
|
|
m_nQ = 0.0;
|
|
m_nRation = 120;
|
|
m_bIndustry = TRUE;
|
|
m_csAreaIndustry = _T("5");
|
|
m_dWasteCoef = 0.80;
|
|
m_bSelArea = TRUE;
|
|
m_dWaterRation = 1.5;
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
|
|
void CCalcDirtWellDataDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CCalcDirtWellDataDlg)
|
|
DDX_Check(pDX, IDC_CHECK_LIFE, m_bLife);
|
|
DDX_Check(pDX, IDC_CHECK_OTHER, m_bOther);
|
|
DDX_Text(pDX, IDC_EDIT_AREA, m_csArea);
|
|
DDX_Text(pDX, IDC_EDIT_PEOPLE, m_iPeople);
|
|
DDX_Text(pDX, IDC_EDIT_Q, m_nQ);
|
|
DDX_Text(pDX, IDC_EDIT_RATION, m_nRation);
|
|
DDX_Check(pDX, IDC_CHECK_INDUSTRY, m_bIndustry);
|
|
DDX_Text(pDX, IDC_EDIT_AREA_OTHER, m_csAreaIndustry);
|
|
DDX_Text(pDX, IDC_EDIT_COEF, m_dWasteCoef);
|
|
DDX_Text(pDX, IDC_EDIT_WATER_RATION, m_dWaterRation);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CCalcDirtWellDataDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CCalcDirtWellDataDlg)
|
|
ON_BN_CLICKED(IDC_BUTTON_AREA, OnButtonArea)
|
|
ON_BN_CLICKED(IDC_CHECK_LIFE, OnCheckLife)
|
|
ON_BN_CLICKED(IDC_CHECK_OTHER, OnCheckOther)
|
|
ON_BN_CLICKED(IDC_BUTTON_WATER_RATION, OnButtonWaterRation)
|
|
ON_BN_CLICKED(IDC_BUTTON_AREA_OTHER, OnButtonAreaOther)
|
|
ON_BN_CLICKED(IDC_CHECK_INDUSTRY, OnCheckIndustry)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CCalcDirtWellDataDlg message handlers
|
|
|
|
void CCalcDirtWellDataDlg::OnButtonArea()
|
|
{
|
|
UpdateData(TRUE);
|
|
HideDialog(this, TRUE);
|
|
XPoly2D poly2d;
|
|
if(GetOpenPoly2D(_T("\n请勾绘封闭汇流面积:"), poly2d)!=RTNORM) {
|
|
HideDialog(this, FALSE);
|
|
return;
|
|
}
|
|
if(!poly2d.IsClosed())
|
|
poly2d.SetFlag(1);
|
|
XPoint ptLoc;
|
|
CString csName;
|
|
OPENOBJ_BEGIN(m_ent, AcDb::kForWrite, TDbWell, pEquip);
|
|
if(pEquip){
|
|
ptLoc = pEquip->GetLocation();
|
|
csName = pEquip->GetWellName();
|
|
double nScale = pEquip->GetScale();
|
|
ads_polar(ptLoc, -PI/2, nScale*2, ptLoc);
|
|
}
|
|
OPENOBJ_END();
|
|
double nArea = _AS_SQMETER(poly2d.Area());
|
|
if(!DocGetMeterUnitDraw())
|
|
nArea = _AS_SQMETER(poly2d.Area());
|
|
else
|
|
nArea = poly2d.Area();
|
|
|
|
adsout << _T("服务面积=") << nArea << _T("(平方米)\n");
|
|
TDbSpace *pDbSpace = new TDbSpace();
|
|
pDbSpace->m_sName = csName + _T("服务面积");
|
|
pDbSpace->m_ptLocation = ptLoc;
|
|
pDbSpace->SetHas3D(FALSE);
|
|
pDbSpace->SetHighlight(TRUE);
|
|
pDbSpace->m_outline = poly2d;
|
|
pDbSpace->m_nUseArea = nArea;
|
|
pDbSpace->m_nOccuArea = 0;
|
|
pDbSpace->m_nCeilArea = 0;
|
|
pDbSpace->m_nWallSurfArea = 0;
|
|
pDbSpace->m_nExtWallArea = 0;
|
|
pDbSpace->m_nExtWinArea = 0;
|
|
pDbSpace->m_nExtDoorArea = 0;
|
|
pDbSpace->m_nPerimeter = 0;
|
|
pDbSpace->m_nKickboardLength = 0;
|
|
pDbSpace->SetShowOutline(TRUE);
|
|
|
|
pDbSpace->SetTextStyleId(InitTextStyle(g_csDimWellStyle));
|
|
pDbSpace->AddToCSpace(Adesk::kFalse);
|
|
pDbSpace->setLayer(InitLayer(LAY_CALC_AREA));
|
|
pDbSpace->close();
|
|
m_csArea.Format(_T("%.2f"), nArea/10000);
|
|
HideDialog(this, FALSE);
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CCalcDirtWellDataDlg::OnCheckLife()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd1 = GetDlgItem(IDC_EDIT_AREA);
|
|
CWnd *pWnd2 = GetDlgItem(IDC_EDIT_PEOPLE);
|
|
CWnd *pWnd3 = GetDlgItem(IDC_EDIT_RATION);
|
|
CWnd *pWnd4 = GetDlgItem(IDC_BUTTON_AREA);
|
|
if(m_bLife){
|
|
pWnd1->EnableWindow(TRUE);
|
|
pWnd2->EnableWindow(TRUE);
|
|
pWnd3->EnableWindow(TRUE);
|
|
pWnd4->EnableWindow(TRUE && m_bSelArea); // 选中多个实体情况下禁止用户手动绘制用水区域
|
|
}
|
|
else{
|
|
pWnd1->EnableWindow(FALSE);
|
|
pWnd2->EnableWindow(FALSE);
|
|
pWnd3->EnableWindow(FALSE);
|
|
pWnd4->EnableWindow(FALSE && m_bSelArea);
|
|
}
|
|
GetDlgItem(IDC_CHECK_INDUSTRY)->EnableWindow(!m_bLife);
|
|
}
|
|
|
|
void CCalcDirtWellDataDlg::OnCheckOther()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd1 = GetDlgItem(IDC_EDIT_Q);
|
|
if(m_bOther)
|
|
pWnd1->EnableWindow(TRUE);
|
|
else
|
|
pWnd1->EnableWindow(FALSE);
|
|
}
|
|
|
|
BOOL CCalcDirtWellDataDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// m_bLife = FALSE;
|
|
// m_bOther = FALSE;
|
|
// m_bIndustry = TRUE;
|
|
OnCheckLife();
|
|
OnCheckOther();
|
|
OnCheckIndustry();
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CCalcDirtWellDataDlg::OnButtonWaterRation()
|
|
{
|
|
UpdateData();
|
|
CTemporaryResourceOverride vTemp;
|
|
CWaterRationDlg dlg;
|
|
if (IDOK == dlg.DoModal())
|
|
m_dWaterRation = _tstof(dlg.m_csWaterRation);
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CCalcDirtWellDataDlg::OnButtonAreaOther()
|
|
{
|
|
// 1公顷 == 100 * 100 平方米
|
|
OnButtonArea();
|
|
m_csAreaIndustry = m_csArea;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CCalcDirtWellDataDlg::OnCheckIndustry()
|
|
{
|
|
UpdateData();
|
|
CWnd* pWnd1 = GetDlgItem(IDC_EDIT_AREA_OTHER);
|
|
CWnd* pWnd2 = GetDlgItem(IDC_EDIT_WATER_RATION);
|
|
CWnd* pWnd3 = GetDlgItem(IDC_EDIT_COEF);
|
|
CWnd* pWnd4 = GetDlgItem(IDC_BUTTON_AREA_OTHER);
|
|
CWnd* pWnd5 = GetDlgItem(IDC_BUTTON_WATER_RATION);
|
|
|
|
pWnd1->EnableWindow(m_bIndustry);
|
|
pWnd2->EnableWindow(m_bIndustry);
|
|
pWnd3->EnableWindow(m_bIndustry);
|
|
pWnd4->EnableWindow(m_bIndustry && m_bSelArea);
|
|
pWnd5->EnableWindow(m_bIndustry);
|
|
|
|
GetDlgItem(IDC_CHECK_LIFE)->EnableWindow(!m_bIndustry);
|
|
}
|