2026-10-04 00:04:20 +08:00
|
|
|
#include "stdafx.h"
|
2026-09-28 15:28:50 +08:00
|
|
|
#include "LXSGDlg.h"
|
|
|
|
|
#include "UITools.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const Adesk::UInt16 kColorByBlock = 0;
|
|
|
|
|
static const Adesk::UInt16 kRed = 1;
|
|
|
|
|
static const Adesk::UInt16 kYellow = 2;
|
|
|
|
|
static const Adesk::UInt16 kGreen = 3;
|
|
|
|
|
static const Adesk::UInt16 kCyan = 4;
|
|
|
|
|
static const Adesk::UInt16 kBlue = 5;
|
|
|
|
|
static const Adesk::UInt16 kMagenta = 6;
|
|
|
|
|
static const Adesk::UInt16 kWhite = 7;
|
|
|
|
|
static const Adesk::UInt16 kColorByLayer = 256;
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC(CLXSGDlg, CDialog)
|
|
|
|
|
|
|
|
|
|
CLXSGDlg::CLXSGDlg(CWnd* pParent /*=NULL*/)
|
|
|
|
|
: CDialog(CLXSGDlg::IDD, pParent)
|
|
|
|
|
, m_nConnectType(0)
|
|
|
|
|
, m_bIsMUnit(FALSE)
|
|
|
|
|
{
|
|
|
|
|
m_sPipeNo = _T("P-001");
|
|
|
|
|
m_sZoneNo = _T("Z-001");
|
|
|
|
|
m_sMertial = _T("");
|
|
|
|
|
m_sCurrSys = _T("");
|
|
|
|
|
m_dRRato = 1.5;
|
|
|
|
|
m_dDn = 500.0;
|
|
|
|
|
m_dOD = 530.0;
|
|
|
|
|
m_dt = 9.5;
|
|
|
|
|
m_nPipeColor = kRed;
|
|
|
|
|
m_sMertial = _T("25#");
|
2026-10-04 00:04:20 +08:00
|
|
|
m_sCurrSys = _T("燃气");
|
2026-09-28 15:28:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CLXSGDlg::~CLXSGDlg()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLXSGDlg::DoDataExchange(CDataExchange* pDX)
|
|
|
|
|
{
|
|
|
|
|
CDialog::DoDataExchange(pDX);
|
|
|
|
|
DDX_Control(pDX, IDC_LIST1, m_wndPipeList);
|
|
|
|
|
DDX_Control(pDX, IDC_LIST2, m_wndListBoxMaters);
|
|
|
|
|
DDX_LBString(pDX, IDC_LIST2, m_sMertial);
|
|
|
|
|
DDX_Control(pDX, IDC_LIST3, m_wndSysListBox);
|
|
|
|
|
DDX_Text(pDX, IDC_EDITPIPECODE, m_sPipeNo);
|
|
|
|
|
DDX_Text(pDX, IDC_EDITZONE, m_sZoneNo);
|
|
|
|
|
DDX_Control(pDX, IDC_LIST4, m_wndListBox);
|
|
|
|
|
DDX_Radio(pDX, IDC_RADIOWELD, m_nConnectType);
|
|
|
|
|
DDX_Check(pDX, IDC_CHECK1, m_bIsMUnit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CLXSGDlg, CDialog)
|
|
|
|
|
ON_BN_CLICKED(IDOK, &CLXSGDlg::OnBnClickedOk)
|
|
|
|
|
ON_WM_CTLCOLOR()
|
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL CLXSGDlg::OnInitDialog()
|
|
|
|
|
{
|
|
|
|
|
CDialog::OnInitDialog();
|
|
|
|
|
|
|
|
|
|
m_wndPipeList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
|
2026-10-04 00:04:20 +08:00
|
|
|
m_wndPipeList.InsertColumn(0,_T("公称直径"),LVCFMT_LEFT,60);
|
|
|
|
|
m_wndPipeList.InsertColumn(1,_T("外径"),LVCFMT_LEFT,60);
|
|
|
|
|
m_wndPipeList.InsertColumn(2,_T("壁厚"),LVCFMT_LEFT,60);
|
|
|
|
|
m_wndPipeList.InsertColumn(3,_T("线比重"),LVCFMT_LEFT,100);
|
2026-09-28 15:28:50 +08:00
|
|
|
|
|
|
|
|
CString path = FilePath::GetSysDir() + Plumbing_DB;
|
|
|
|
|
if (!m_dbSQLite.InitADOServer(path))
|
|
|
|
|
{
|
2026-10-04 00:04:20 +08:00
|
|
|
AfxMessageBox(CString(_T("数据库初始化失败,请检查 sys")) + Plumbing_DB + _T("文件是否存在."));
|
2026-09-28 15:28:50 +08:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InitPipeList();
|
|
|
|
|
InitElbowCrt();
|
|
|
|
|
|
|
|
|
|
struct resbuf rb;
|
|
|
|
|
acedGetVar(_T("INSUNITS"),&rb);
|
|
|
|
|
|
2026-10-04 00:04:20 +08:00
|
|
|
//提示,如果当前地形图单位不是米,分米,厘米,毫米,无单位,给与提示
|
2026-09-28 15:28:50 +08:00
|
|
|
if (rb.resval.rint == AcDb::kUnitsMeters)
|
|
|
|
|
{
|
|
|
|
|
m_bIsMUnit = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateData(FALSE);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLXSGDlg::InitPipeList()
|
|
|
|
|
{
|
|
|
|
|
CString sSQL,sText;
|
2026-10-04 00:04:20 +08:00
|
|
|
sSQL = _T("select [公称直径],[外径],[壁厚],[重量] from AecOD order by [公称直径]");
|
2026-09-28 15:28:50 +08:00
|
|
|
|
|
|
|
|
CUIIValueTable table;
|
|
|
|
|
m_dbSQLite.GetSelData(sSQL,table);
|
|
|
|
|
table.ShowToListCtrl(&m_wndPipeList);
|
|
|
|
|
|
|
|
|
|
double dT = 0.0;
|
|
|
|
|
CString sDnold;
|
|
|
|
|
sDnold.Format(_T("%d"),(int)m_dDn);
|
|
|
|
|
|
|
|
|
|
bool bFind = false;
|
|
|
|
|
for (int i = 0;i < m_wndPipeList.GetItemCount();i++)
|
|
|
|
|
{
|
|
|
|
|
sText = m_wndPipeList.GetItemText(i,0);
|
|
|
|
|
dT = _ttof(m_wndPipeList.GetItemText(i,2));
|
|
|
|
|
if (sText.CompareNoCase(sDnold) == 0 && fabs(m_dt - dT) < 1.e-2)
|
|
|
|
|
{
|
|
|
|
|
m_wndPipeList.SetItemState(i,LVIS_SELECTED,LVIS_SELECTED);
|
|
|
|
|
m_wndPipeList.EnsureVisible(i,TRUE);
|
|
|
|
|
bFind = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bFind)
|
|
|
|
|
{
|
|
|
|
|
if (m_wndPipeList.GetItemCount() > 0)
|
|
|
|
|
m_wndPipeList.SetItemState(0,LVIS_SELECTED,LVIS_SELECTED);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-04 00:04:20 +08:00
|
|
|
//材质
|
2026-09-28 15:28:50 +08:00
|
|
|
CStringArray arVals;
|
2026-10-04 00:04:20 +08:00
|
|
|
sSQL = _T("select [材质] from AecMaterial where [类型]='管道'");
|
2026-09-28 15:28:50 +08:00
|
|
|
m_dbSQLite.GetSelData(sSQL,arVals);
|
|
|
|
|
int nCursel = 0;
|
|
|
|
|
|
|
|
|
|
for (i = 0;i < arVals.GetSize();i++)
|
|
|
|
|
{
|
|
|
|
|
m_wndListBoxMaters.AddString(arVals.GetAt(i));
|
|
|
|
|
if (m_sMertial.CompareNoCase(arVals.GetAt(i)) == 0)
|
|
|
|
|
{
|
|
|
|
|
nCursel = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_wndListBoxMaters.SetCurSel(nCursel);
|
|
|
|
|
|
2026-10-04 00:04:20 +08:00
|
|
|
//系统
|
2026-09-28 15:28:50 +08:00
|
|
|
CString sStd,sTemp;
|
|
|
|
|
sSQL = _T("select tablename from wpipecfg where currstd=1");
|
|
|
|
|
m_dbSQLite.GetSelData(sSQL,sStd);
|
|
|
|
|
|
|
|
|
|
sSQL.Format(_T("select distinct system from %s"),sStd);
|
|
|
|
|
CStringArray arSyses;
|
|
|
|
|
m_dbSQLite.GetSelData(sSQL,arSyses);
|
|
|
|
|
|
|
|
|
|
nCursel = 0;
|
|
|
|
|
if (arSyses.GetSize() > 0)
|
|
|
|
|
m_sCurrSys = arSyses.GetAt(0);
|
|
|
|
|
|
|
|
|
|
for (int i = 0;i < arSyses.GetSize();i++)
|
|
|
|
|
{
|
|
|
|
|
sTemp = arSyses.GetAt(i);
|
|
|
|
|
m_wndSysListBox.AddString(sTemp);
|
|
|
|
|
if (m_sCurrSys.CompareNoCase(sTemp) == 0)
|
|
|
|
|
{
|
|
|
|
|
nCursel = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_wndSysListBox.SetCurSel(nCursel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLXSGDlg::InitElbowCrt()
|
|
|
|
|
{
|
|
|
|
|
CString sSQL;
|
2026-10-04 00:04:20 +08:00
|
|
|
sSQL = _T("select [曲率半径] from AecElbowradius order by [曲率半径]");
|
2026-09-28 15:28:50 +08:00
|
|
|
|
|
|
|
|
bool bSet = false;
|
|
|
|
|
CStringArray arVals;
|
|
|
|
|
m_dbSQLite.GetSelData(sSQL,arVals);
|
|
|
|
|
|
|
|
|
|
for (int i = 0;i < arVals.GetSize();i++)
|
|
|
|
|
{
|
|
|
|
|
m_wndListBox.AddString(arVals.GetAt(i));
|
|
|
|
|
|
|
|
|
|
if ( fabs( m_dRRato - _ttof(arVals.GetAt(i) ) ) < 1.e-2)
|
|
|
|
|
{
|
|
|
|
|
m_wndListBox.SetCurSel(i);
|
|
|
|
|
bSet = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bSet)
|
|
|
|
|
m_wndListBox.SetCurSel(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLXSGDlg::OnBnClickedOk()
|
|
|
|
|
{
|
|
|
|
|
int nItem = -1;
|
|
|
|
|
POSITION ps = m_wndPipeList.GetFirstSelectedItemPosition();
|
|
|
|
|
if (ps != NULL)
|
|
|
|
|
{
|
|
|
|
|
nItem = m_wndPipeList.GetNextSelectedItem(ps);
|
|
|
|
|
}
|
|
|
|
|
if (nItem == -1)
|
|
|
|
|
{
|
2026-10-04 00:04:20 +08:00
|
|
|
AfxMessageBox(_T("请选择管道规格!"));
|
2026-09-28 15:28:50 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int nCurSel = m_wndListBox.GetCurSel();
|
|
|
|
|
if (nCurSel < 0)
|
|
|
|
|
{
|
2026-10-04 00:04:20 +08:00
|
|
|
AfxMessageBox(_T("没有选择弯头曲率半径,请选择曲率半径!"));
|
2026-09-28 15:28:50 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CString sRato;
|
|
|
|
|
m_wndListBox.GetText(nCurSel,sRato);
|
|
|
|
|
m_dRRato = _ttof(sRato);
|
|
|
|
|
|
|
|
|
|
m_dDn = _ttof( m_wndPipeList.GetItemText(nItem,0) );
|
|
|
|
|
m_dOD = _ttof(m_wndPipeList.GetItemText(nItem,1));
|
|
|
|
|
m_dt = _ttof(m_wndPipeList.GetItemText(nItem,2));
|
|
|
|
|
|
|
|
|
|
int nSel = m_wndListBoxMaters.GetCurSel();
|
|
|
|
|
if (nSel == -1)
|
|
|
|
|
{
|
2026-10-04 00:04:20 +08:00
|
|
|
AfxMessageBox(_T("请选择管道材质!"));
|
2026-09-28 15:28:50 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
m_wndListBoxMaters.GetText(nSel,m_sMertial);
|
|
|
|
|
|
|
|
|
|
int nSys = m_wndSysListBox.GetCurSel();
|
|
|
|
|
if (nSys == -1)
|
|
|
|
|
{
|
2026-10-04 00:04:20 +08:00
|
|
|
AfxMessageBox(_T("请选择管道用途系统!"));
|
2026-09-28 15:28:50 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
m_wndSysListBox.GetText(nSys,m_sCurrSys);
|
|
|
|
|
|
|
|
|
|
OnOK();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLXSGDlg::GetPipeParam( AecDbObjXDataMap* pXDataMap)
|
|
|
|
|
{
|
|
|
|
|
pXDataMap->SetAt(_T("COLOR"),m_nPipeColor);
|
|
|
|
|
pXDataMap->SetAt(KEY_2DSTYLE,0);
|
|
|
|
|
pXDataMap->SetAt(KEY_SINGLEW,0);
|
|
|
|
|
pXDataMap->SetAt(KEY_DRAWGRAD,1);
|
|
|
|
|
if (m_bIsMUnit)
|
|
|
|
|
{
|
|
|
|
|
pXDataMap->SetAt(PIPE_DN,AS_MUNIT(m_dDn));
|
|
|
|
|
pXDataMap->SetAt(PIPE_D,AS_MUNIT(m_dOD));
|
|
|
|
|
pXDataMap->SetAt(PIPE_OD,AS_MUNIT(m_dOD));
|
|
|
|
|
pXDataMap->SetAt(PIPE_THICK,AS_MUNIT(m_dt));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pXDataMap->SetAt(PIPE_DN,m_dDn);
|
|
|
|
|
pXDataMap->SetAt(PIPE_D,m_dOD);
|
|
|
|
|
pXDataMap->SetAt(PIPE_OD,m_dOD);
|
|
|
|
|
pXDataMap->SetAt(PIPE_THICK,m_dt);
|
|
|
|
|
}
|
|
|
|
|
pXDataMap->SetAt(PIPE_MATERIAL,m_sCurrSys);
|
|
|
|
|
pXDataMap->SetAt(PIPE_SYS,m_sCurrSys);
|
|
|
|
|
pXDataMap->SetAt(PIPE_RATIO,m_dRRato);
|
2026-10-04 00:04:20 +08:00
|
|
|
pXDataMap->SetAt(PIPE_EAPP,_T("市政"));
|
2026-09-28 15:28:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HBRUSH CLXSGDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
|
|
|
|
{
|
|
|
|
|
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
|
|
|
if (nCtlColor == CTLCOLOR_STATIC)
|
|
|
|
|
{
|
|
|
|
|
if (pWnd != NULL && pWnd->GetDlgCtrlID() == IDC_STATIC_COLOR)
|
|
|
|
|
{
|
|
|
|
|
COLORREF crColor = RGB(255,255,255);
|
|
|
|
|
if (m_nPipeColor == kColorByLayer)
|
|
|
|
|
{
|
|
|
|
|
crColor = RGB(255,255,255);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
crColor = acedGetRGB(m_nPipeColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CRect rc;
|
|
|
|
|
pWnd->GetClientRect(rc);
|
|
|
|
|
pDC->FillSolidRect(rc,crColor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return hbr;
|
|
|
|
|
}
|