448 lines
9.4 KiB
C++
448 lines
9.4 KiB
C++
#include "stdafx.h"
|
|
#include "shs_outdoor.h"
|
|
#include "WaterBucketDlg.h"
|
|
#include "SelectBlkDlg.h"
|
|
#include "WaterBucketParameterDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
#include"TGAs.h"
|
|
|
|
CString CWaterBucketDlg::m_strWndCmbDia = _T("DN75");
|
|
CString CWaterBucketDlg::m_strWndEdtNumber = _T("R1");
|
|
double CWaterBucketDlg::m_dWndEdtSize = 6;
|
|
double CWaterBucketDlg::m_dWndEdtEle = 0;
|
|
CString CWaterBucketDlg::m_csBlkName = _T("$TwtSys$00000522");
|
|
IMPLEMENT_DYNAMIC(CWaterBucketDlg, CModelessDialog)
|
|
CWaterBucketDlg::CWaterBucketDlg(CWnd* pParent /*=NULL*/)
|
|
: CModelessDialog(CWaterBucketDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CWaterBucketDlg)
|
|
m_nWndRadioSel = 0;
|
|
m_dWndEdtDist = 4.2;
|
|
m_dWndEdtDeep = 0.045;
|
|
m_dWndEdtFlux = 0.0;
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
|
|
void CWaterBucketDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CWaterBucketDlg)
|
|
DDX_Radio(pDX, IDC_RADIO_SEL, m_nWndRadioSel);
|
|
DDX_Text(pDX, IDC_EDIT_DISTANCE, m_dWndEdtDist);
|
|
DDX_Text(pDX, IDC_EDIT_SIZE, m_dWndEdtSize);
|
|
DDX_Text(pDX, IDC_EDIT_NUMBER, m_strWndEdtNumber);
|
|
DDX_Text(pDX, IDC_EDIT_DEEP, m_dWndEdtDeep);
|
|
DDX_CBString(pDX, IDC_COMBO_PIPEDIA, m_strWndCmbDia);
|
|
DDX_Text(pDX, IDC_EDIT_ELE, m_dWndEdtEle);
|
|
DDX_Text(pDX, IDC_EDIT_FLUX, m_dWndEdtFlux);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CWaterBucketDlg, CModelessDialog)
|
|
//{{AFX_MSG_MAP(CWaterBucketDlg)
|
|
ON_MESSAGE(WM_ACAD_KEEPFOCUS, onAcadKeepFocus)
|
|
ON_BN_CLICKED(IDC_STATIC_PICTURE, OnStaticPicture)
|
|
ON_WM_PAINT()
|
|
ON_BN_CLICKED(IDC_BUTTON_PARAMETER, OnButtonParameter)
|
|
ON_BN_CLICKED(IDC_RADIO_SEL, OnRadioSel)
|
|
ON_WM_CLOSE()
|
|
ON_BN_CLICKED(IDC_RADIO2, OnRadioSel)
|
|
ON_BN_CLICKED(IDC_RADIO3, OnRadioSel)
|
|
ON_BN_CLICKED(IDC_RADIO11, OnRadioSel)
|
|
ON_CBN_SELCHANGE(IDC_COMBO_PIPEDIA, OnSelchangeComboPipedia)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
LONG_PTR CWaterBucketDlg::onAcadKeepFocus(UINT_PTR, LONG_PTR)
|
|
{
|
|
CPoint pt;
|
|
GetCursorPos(&pt);
|
|
CRect rc;
|
|
GetWindowRect(&rc);
|
|
return (rc.PtInRect(pt) ? TRUE : FALSE);
|
|
}
|
|
|
|
void CWaterBucketDlg::OnStaticPicture()
|
|
{
|
|
CString csSldName;
|
|
CString csTK, csRecord;
|
|
SplitBlkStr(m_csBlkName, csTK, csRecord);
|
|
csSldName.Format(_T("TWTSYS(%s)"), csRecord);
|
|
|
|
CTemporaryResourceOverride vTemp;
|
|
CSelectBlkDlg dlg;
|
|
dlg.m_csTkName = _T("TWTSYS");
|
|
dlg.m_csType = _T("虹吸雨水斗");
|
|
CWnd *pWnd = GetDlgItem(IDC_STATIC_PICTURE);
|
|
CRect rect;
|
|
dlg.m_staticSlide.m_csCurRecord = csSldName;
|
|
pWnd->GetWindowRect(&rect);
|
|
dlg.m_ptBase = rect.TopLeft();
|
|
if(dlg.DoModal() == IDOK)
|
|
{
|
|
CString csRet = dlg.m_staticSlide.m_csCurRecord;
|
|
XString xsTKName, xsRocord, xsTmp;
|
|
SplitSlbName(csRet, xsTKName, xsRocord);
|
|
AcDbDatabase *dwg=acdbCurDwg();
|
|
AcAxDocLock docLock(dwg);
|
|
VERIFY(docLock.lockStatus() == Acad::eOk);
|
|
|
|
if(LoadDwbBlock((const TCHAR*)xsTKName, (const TCHAR*)xsRocord, xsTmp) != RTNORM)
|
|
return;
|
|
m_csBlkName = (const TCHAR*)xsTmp;
|
|
OpenSlide();
|
|
}
|
|
}
|
|
|
|
void CWaterBucketDlg::OpenSlide()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pImageBox1 = GetDlgItem(IDC_STATIC_PICTURE);
|
|
CString csSldName;
|
|
CString csTK, csRecord;
|
|
SplitBlkStr(m_csBlkName, csTK, csRecord);
|
|
csSldName.Format(_T("TWTSYS(%s)"), csRecord);
|
|
DrawSlide((const TCHAR*)csSldName, pImageBox1);
|
|
}
|
|
|
|
void CWaterBucketDlg::OnPaint()
|
|
{
|
|
CPaintDC dc(this);
|
|
OpenSlide();
|
|
}
|
|
|
|
BOOL CWaterBucketDlg::OnInitDialog()
|
|
{
|
|
CModelessDialog::OnInitDialog();
|
|
CString strDia = m_strWndCmbDia;
|
|
OnRadioSel();
|
|
m_strWndCmbDia = strDia;
|
|
UpdateData(FALSE);
|
|
InitCmb();
|
|
OnSelchangeComboPipedia();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CWaterBucketDlg::InitCmb()
|
|
{
|
|
XString fullFile;
|
|
if(!FindFile(_T("datastore.dbf"), fullFile))
|
|
{
|
|
MessageBox(_T("对不起,没有发现datastore.dbf文件!"));
|
|
return;
|
|
}
|
|
|
|
CodeBase db;
|
|
db.read_only = 1;
|
|
XDbfTable *pTable = db.Open(fullFile);
|
|
if(!pTable)
|
|
return;
|
|
|
|
CString strDia, strFlux, strDeep,strNum;
|
|
std::set<double> setDia;
|
|
for(pTable->MoveFirst(); !pTable->IsEOF(); pTable->MoveNext())
|
|
{
|
|
GET_FIELD(pTable, _T("Typenumber"), strNum);
|
|
if (strNum.Compare(_T("45")) != 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
GET_FIELD(pTable, _T("Typename"), strDia);
|
|
GET_FIELD(pTable, _T("Typevalue"), strFlux);
|
|
GET_FIELD(pTable, _T("Remark"), strDeep);
|
|
|
|
WaterBucketInfo info = {_tstof(strDia), _tstof(strFlux), _tstof(strDeep)};
|
|
m_vecData.push_back(info);
|
|
setDia.insert(_tstof(strDia));
|
|
}
|
|
|
|
pTable->Close();
|
|
|
|
CComboBox *pWnd = (CComboBox*)GetDlgItem(IDC_COMBO_PIPEDIA);
|
|
if (pWnd != NULL)
|
|
{
|
|
pWnd->Clear();
|
|
|
|
int i = 0;
|
|
std::set<double>::iterator it;
|
|
for(it = setDia.begin(); it != setDia.end(); it++)
|
|
{
|
|
CString strTemp;
|
|
strTemp.Format(_T("%.0f"), *it);
|
|
strTemp = _T("DN") + strTemp;
|
|
pWnd->InsertString(i, strTemp);
|
|
++i;
|
|
}
|
|
|
|
InitDia();
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CWaterBucketDlg::OnButtonParameter()
|
|
{
|
|
CTemporaryResourceOverride vTemp;
|
|
CWaterBucketParameterDlg dlg;
|
|
dlg.DoModal();
|
|
|
|
CString strDia;
|
|
dlg.GetData(m_vecData, strDia);
|
|
|
|
if (strDia != _T(""))
|
|
{
|
|
m_strWndCmbDia = _T("DN") + strDia;
|
|
}
|
|
|
|
CComboBox *pBox = (CComboBox *)GetDlgItem(IDC_COMBO_PIPEDIA);
|
|
if (pBox != NULL)
|
|
{
|
|
pBox->ResetContent();
|
|
|
|
std::vector<WATERBUCKETINFO>::iterator it;
|
|
std::set<double> data;
|
|
for(it = m_vecData.begin(); it != m_vecData.end(); it++)
|
|
{
|
|
data.insert((*it).dPipeDia);
|
|
}
|
|
|
|
int i = 0;
|
|
std::set<double>::iterator it1;
|
|
for(it1 = data.begin(); it1 != data.end(); it1++)
|
|
{
|
|
CString str;
|
|
str.Format(_T("%.0f"), (*it1));
|
|
str = _T("DN") + str;
|
|
pBox->InsertString(i, str);
|
|
i++;
|
|
}
|
|
}
|
|
|
|
InitDia();
|
|
UpdateData(FALSE);
|
|
OnSelchangeComboPipedia();
|
|
}
|
|
|
|
void CWaterBucketDlg::OnRadioSel()
|
|
{
|
|
UpdateData(TRUE);
|
|
CEdit *pWnd = (CEdit*)GetDlgItem(IDC_EDIT_DISTANCE);
|
|
if (pWnd != NULL)
|
|
{
|
|
if (m_nWndRadioSel == 0)
|
|
{
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
else
|
|
{
|
|
pWnd->EnableWindow(TRUE);
|
|
}
|
|
}
|
|
|
|
PostCommand(_T("R "), false);
|
|
}
|
|
|
|
int CWaterBucketDlg::GetMode()
|
|
{
|
|
return m_nWndRadioSel;
|
|
}
|
|
|
|
CString CWaterBucketDlg::GetBlkName()
|
|
{
|
|
return m_csBlkName;
|
|
}
|
|
|
|
double CWaterBucketDlg::GetDistance()
|
|
{
|
|
return m_dWndEdtDist;
|
|
}
|
|
|
|
void CWaterBucketDlg::SetDistance(double dDist)
|
|
{
|
|
m_dWndEdtDist = dDist;
|
|
}
|
|
|
|
double CWaterBucketDlg::GetSize()
|
|
{
|
|
return m_dWndEdtSize;
|
|
}
|
|
|
|
void CWaterBucketDlg::SetSize(double dSize)
|
|
{
|
|
m_dWndEdtSize = dSize;
|
|
}
|
|
|
|
double CWaterBucketDlg::GetEle()
|
|
{
|
|
return m_dWndEdtEle;
|
|
}
|
|
|
|
void CWaterBucketDlg::SetEle(double dEle)
|
|
{
|
|
m_dWndEdtEle = dEle;
|
|
}
|
|
|
|
CString CWaterBucketDlg::GetNumber()
|
|
{
|
|
return m_strWndEdtNumber;
|
|
}
|
|
|
|
void CWaterBucketDlg::SetNumber(const CString& strNumber)
|
|
{
|
|
m_strWndEdtNumber = strNumber;
|
|
}
|
|
|
|
double CWaterBucketDlg::GetDeep()
|
|
{
|
|
return m_dWndEdtDeep;
|
|
}
|
|
|
|
void CWaterBucketDlg::SetDeep(double dDeep)
|
|
{
|
|
m_dWndEdtDeep = dDeep;
|
|
}
|
|
|
|
double CWaterBucketDlg::GetFlux()
|
|
{
|
|
return m_dWndEdtFlux;
|
|
}
|
|
|
|
void CWaterBucketDlg::SetFlux(double dFlux)
|
|
{
|
|
m_dWndEdtFlux = dFlux;
|
|
}
|
|
|
|
double CWaterBucketDlg::GetPipeDia()
|
|
{
|
|
CString strDia = m_strWndCmbDia;
|
|
strDia.TrimLeft(_T("DN"));
|
|
return _tstof(strDia);
|
|
}
|
|
|
|
void CWaterBucketDlg::SetPipeDia(double dDia)
|
|
{
|
|
m_strWndCmbDia.Format(_T("%.0f"), dDia);
|
|
m_strWndCmbDia = _T("DN") + m_strWndCmbDia;
|
|
}
|
|
|
|
void CWaterBucketDlg::OnClose()
|
|
{
|
|
CModelessDialog::OnClose();
|
|
PostCommand(_T("\33\33"));
|
|
}
|
|
|
|
void CWaterBucketDlg::OnSelchangeComboPipedia()
|
|
{
|
|
UpdateData(TRUE);
|
|
CString strDia = m_strWndCmbDia;
|
|
strDia.TrimLeft(_T("DN"));
|
|
double dDia = _tstof(strDia);
|
|
std::vector<WATERBUCKETINFO>::iterator it;
|
|
for(it = m_vecData.begin(); it != m_vecData.end(); it++)
|
|
{
|
|
if (fabs((*it).dPipeDia - dDia) < 1e-3)
|
|
{
|
|
m_dWndEdtFlux = (*it).dFlux;
|
|
m_dWndEdtDeep = (*it).dDeep;
|
|
break;
|
|
}
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CWaterBucketDlg::AddNumber()
|
|
{
|
|
// 提取数字
|
|
int i = m_strWndEdtNumber.GetLength() - 1;
|
|
for(; i >= 0 ; i--)
|
|
{
|
|
TCHAR ch = m_strWndEdtNumber.GetAt(i);
|
|
if (ch >= _T('0') && ch <= _T('9'))
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
|
|
CString strNum, strCh;
|
|
strNum = m_strWndEdtNumber.Right(m_strWndEdtNumber.GetLength() - i - 1);
|
|
strCh = m_strWndEdtNumber.Left(i + 1);
|
|
strNum = _T("1") + strNum; // 支持005样式数值递增
|
|
|
|
int nNum = static_cast<int>(_tstof(strNum));
|
|
++nNum;
|
|
|
|
strNum.Format(_T("%d"), nNum);
|
|
|
|
if (strNum.GetAt(0) == _T('1'))
|
|
{
|
|
strNum.Delete(0);
|
|
}
|
|
else
|
|
{
|
|
strNum.SetAt(0, _T('1'));
|
|
}
|
|
|
|
m_strWndEdtNumber = strCh + strNum;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CWaterBucketDlg::InitDia()
|
|
{
|
|
XString fullFile;
|
|
if(!FindFile(_T("datastore.dbf"), fullFile))
|
|
{
|
|
MessageBox(_T("对不起,没有发现datastore.dbf文件!"));
|
|
return;
|
|
}
|
|
|
|
CodeBase db;
|
|
db.read_only = 1;
|
|
XDbfTable *pTable = db.Open(fullFile);
|
|
if(!pTable)
|
|
return;
|
|
|
|
CString strDia, strFlux, strDeep,strNum;
|
|
std::set<double> setDia;
|
|
for(pTable->MoveFirst(); !pTable->IsEOF(); pTable->MoveNext())
|
|
{
|
|
GET_FIELD(pTable, _T("Typenumber"), strNum);
|
|
if (strNum.Compare(_T("45")) != 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
GET_FIELD(pTable, _T("Typename"), strDia);
|
|
GET_FIELD(pTable, _T("Typevalue"), strFlux);
|
|
GET_FIELD(pTable, _T("Remark"), strDeep);
|
|
|
|
WaterBucketInfo info = {_tstof(strDia), _tstof(strFlux), _tstof(strDeep)};
|
|
m_vecData.push_back(info);
|
|
setDia.insert(_tstof(strDia));
|
|
}
|
|
|
|
pTable->Close();
|
|
|
|
|
|
//当m_strWndCmbDia当前值不存在时,重新赋值
|
|
CString strTemp = m_strWndCmbDia;
|
|
strTemp.TrimLeft(_T("DN"));
|
|
std::set<double>::iterator it;
|
|
it = setDia.find(_tstof(strTemp));
|
|
if (it == setDia.end() && setDia.size() > 0)
|
|
{
|
|
strTemp.Format(_T("%.0f"), *setDia.begin());
|
|
m_strWndCmbDia = _T("DN") + strTemp;
|
|
}
|
|
} |