789 lines
19 KiB
C++
789 lines
19 KiB
C++
#include "stdafx.h"
|
|
#include "GLTKDlg.h"
|
|
#include "AecDbEarthWorm.h"
|
|
#include "coreTools.h"
|
|
|
|
#define STANDARD_DB _T("\\cityStandard.db")
|
|
#define STANDARD_TABLE _T("standard")
|
|
|
|
namespace
|
|
{
|
|
void initTree(CUIISQLiteServer &server, CTreeCtrl &tree)
|
|
{
|
|
tree.DeleteAllItems();
|
|
CStringArray arrCity, arrStand;
|
|
CString sCity(_T("")), sSql(_T("")), sStand;
|
|
server.GetSelData(_T("select distinct city from standard"), arrCity);
|
|
|
|
HTREEITEM parent, sub;
|
|
for (int cty = 0; cty < arrCity.GetCount(); ++cty)
|
|
{
|
|
arrStand.RemoveAll();
|
|
sCity = arrCity[cty];
|
|
sSql.Format(_T("select distinct standard from standard where city='%s'"), sCity);
|
|
parent = tree.InsertItem(sCity, 0, 0, TVI_ROOT, TVI_LAST);
|
|
server.GetSelData(sSql, arrStand);
|
|
for (int sta = 0; sta < arrStand.GetCount(); ++sta)
|
|
{
|
|
sStand = arrStand[sta];
|
|
if (!sStand.IsEmpty())
|
|
sub = tree.InsertItem(sStand, 0, 0, parent, TVI_LAST);
|
|
}
|
|
}
|
|
HTREEITEM item = tree.GetFirstVisibleItem();
|
|
while (item)
|
|
{
|
|
tree.Expand(item, TVE_EXPAND);
|
|
item = tree.GetNextSiblingItem(item);
|
|
}
|
|
}
|
|
|
|
bool hasSameCity(CTreeCtrl &tree, LPCTSTR name)
|
|
{
|
|
if (!name) return true;
|
|
if (!tree.GetCount()) return false;
|
|
|
|
HTREEITEM item = tree.GetFirstVisibleItem();
|
|
if (!item) return true;
|
|
|
|
CString str(_T(""));
|
|
while (item)
|
|
{
|
|
str = tree.GetItemText(item);
|
|
if (str == name) return true;
|
|
item = tree.GetNextSiblingItem(item);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool hasSameStandard(CTreeCtrl &tree, HTREEITEM parent, LPCTSTR name)
|
|
{
|
|
if (!name || !parent) return true;
|
|
|
|
HTREEITEM sub = tree.GetChildItem(parent);
|
|
if (!sub) return false;
|
|
|
|
CString str(_T(""));
|
|
while (sub)
|
|
{
|
|
str = tree.GetItemText(sub);
|
|
if (str == name) return true;
|
|
sub = tree.GetNextSiblingItem(sub);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool IsCityItem(CTreeCtrl &tree, HTREEITEM item)
|
|
{
|
|
if (!item) return false;
|
|
|
|
HTREEITEM parent = tree.GetParentItem(item);
|
|
if (!parent) return true;
|
|
return false;
|
|
}
|
|
|
|
bool IsStandardItem(CTreeCtrl &tree, HTREEITEM item)
|
|
{
|
|
if (!item) return false;
|
|
return !IsCityItem(tree, item);
|
|
}
|
|
|
|
void _delete(CUIISQLiteServer &server, CTreeCtrl &tree, HTREEITEM item)
|
|
{
|
|
if (!item) return;
|
|
|
|
// 删除数据库
|
|
CString city(_T("")), standard(_T("")), sql(_T(""));
|
|
if (IsCityItem(tree, item))
|
|
{
|
|
HTREEITEM sub = tree.GetChildItem(item);
|
|
city = tree.GetItemText(item);
|
|
sql.Format(_T("delete from %s where city='%s'"), STANDARD_TABLE, city);
|
|
server.ExecuteSQL(sql);
|
|
}
|
|
else
|
|
{
|
|
HTREEITEM parent = tree.GetParentItem(item);
|
|
city = tree.GetItemText(parent);
|
|
standard = tree.GetItemText(item);
|
|
sql.Format(_T("delete from %s where city='%s' and standard='%s'")
|
|
, STANDARD_TABLE
|
|
, city
|
|
, standard);
|
|
server.ExecuteSQL(sql);
|
|
}
|
|
// 删除界面
|
|
tree.DeleteItem(item);
|
|
}
|
|
|
|
void deleteCurrentItem(CUIISQLiteServer &server, CTreeCtrl &tree)
|
|
{
|
|
HTREEITEM item = tree.GetSelectedItem();
|
|
if (!item) return;
|
|
_delete(server, tree, item);
|
|
}
|
|
|
|
void RefreshLst(CUIISQLiteServer &server, CListCtrl &lst, CTreeCtrl &tree, HTREEITEM item)
|
|
{
|
|
if (!item) return;
|
|
lst.DeleteAllItems();
|
|
|
|
bool bSelCity(false);
|
|
|
|
HTREEITEM city, standard;
|
|
if (IsCityItem(tree, item))
|
|
{
|
|
city = item;
|
|
bSelCity = true;
|
|
}
|
|
else
|
|
{
|
|
standard = item;
|
|
city = tree.GetParentItem(standard);
|
|
}
|
|
|
|
int nRow(0);
|
|
CStringArray arrStand, arrSection,arAddtion;
|
|
CString sSql(_T("")), sCity(_T("")), sStandard(_T("")), sSection(_T("")), sAddtion(_T(""));
|
|
sCity = tree.GetItemText(city);
|
|
|
|
if (bSelCity)
|
|
{
|
|
sSql.Format(_T("select distinct standard from standard where city='%s'"), sCity);
|
|
server.GetSelData(sSql, arrStand);
|
|
for (int sta = 0; sta < arrStand.GetCount(); ++sta)
|
|
{
|
|
sStandard = arrStand[sta];
|
|
if (sStandard.IsEmpty()) continue;
|
|
sSql.Format(_T("select section from standard where city='%s' and standard='%s'"),
|
|
sCity, sStandard);
|
|
arrSection.RemoveAll();
|
|
server.GetSelData(sSql, arrSection);
|
|
for (int sec = 0; sec < arrSection.GetCount(); sec++)
|
|
{
|
|
sSection = arrSection[sec];
|
|
if (sSection.IsEmpty()) continue;
|
|
nRow = lst.InsertItem(0, sStandard);
|
|
lst.SetItemText(nRow, 1, sSection);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sStandard = tree.GetItemText(standard);
|
|
if (sStandard.IsEmpty()) return;
|
|
sSql.Format(_T("select section,addtion from standard where city='%s' and standard='%s'"),
|
|
sCity, sStandard);
|
|
|
|
CUIIValueTable table;
|
|
arrSection.RemoveAll();
|
|
server.GetSelData(sSql, table);
|
|
|
|
CUIIValueRecord rec;
|
|
for (int i = 0;i < table.GetTableLogicSize();i++)
|
|
{
|
|
rec.RemoveAll();
|
|
table.GetValueRecord(i,rec);
|
|
|
|
rec.GetValue(0,sSection);
|
|
rec.GetValue(1,sAddtion);
|
|
|
|
if (sSection.IsEmpty()) continue;
|
|
nRow = lst.InsertItem(lst.GetItemCount(), sStandard);
|
|
lst.SetItemText(nRow, 1, sSection);
|
|
lst.SetItemText(nRow, 2, sAddtion);
|
|
}
|
|
}
|
|
}
|
|
|
|
void InsertData(CUIISQLiteServer &server, LPCTSTR city, LPCTSTR standard, LPCTSTR section)
|
|
{
|
|
CStringList lstField;
|
|
server.GetTableStru(STANDARD_TABLE,lstField);
|
|
|
|
CString sql(_T(""));
|
|
if (lstField.GetCount() == 3)
|
|
{
|
|
sql.Format(_T("insert into %s values('%s', '%s', '%s')")
|
|
, STANDARD_TABLE
|
|
, city
|
|
, standard
|
|
, section);
|
|
}
|
|
else
|
|
{
|
|
sql.Format(_T("insert into %s values('%s', '%s', '%s','%s')")
|
|
, STANDARD_TABLE
|
|
, city
|
|
, standard
|
|
, section
|
|
,_T(""));
|
|
}
|
|
server.ExecuteSQL(sql);
|
|
}
|
|
void InsertData(CUIISQLiteServer &server, LPCTSTR city, LPCTSTR standard, LPCTSTR section,LPCTSTR pszAddtion)
|
|
{
|
|
CString sql(_T(""));
|
|
sql.Format(_T("insert into %s values('%s', '%s', '%s', '%s')")
|
|
, STANDARD_TABLE
|
|
, city
|
|
, standard
|
|
, section
|
|
, pszAddtion);
|
|
|
|
server.ExecuteSQL(sql);
|
|
}
|
|
}
|
|
|
|
IMPLEMENT_DYNAMIC(CGLTKDlg, CDialog)
|
|
|
|
CGLTKDlg::CGLTKDlg(OPERA opera, CWnd* pParent /*=NULL*/)
|
|
: CDialog(CGLTKDlg::IDD, pParent)
|
|
, m_eOpera(opera)
|
|
{
|
|
m_nItemSel = -1;
|
|
m_bScrForAddToDb = false;
|
|
m_sCrossSectionScr = _T("RECT:3.900x3.600|2.900x3.600|0.400x0.300");
|
|
m_sAddtionScr = _T("");
|
|
}
|
|
|
|
CGLTKDlg::~CGLTKDlg() { }
|
|
|
|
void CGLTKDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Text(pDX, IDC_EDIT1, m_sCrossSectionScr);
|
|
DDX_Control(pDX, IDC_EDIT1, m_wndScrEdit);
|
|
DDX_Control(pDX, IDC_LIST1, m_wndList);
|
|
DDX_Control(pDX, IDC_TREE1, m_wndTree);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CGLTKDlg, CDialog)
|
|
ON_BN_CLICKED(IDC_BUTTON1, &CGLTKDlg::OnBnClickedAddCity)
|
|
ON_BN_CLICKED(IDC_BUTTON2, &CGLTKDlg::OnBnClickedAddStandard)
|
|
ON_BN_CLICKED(IDC_BUTTON3, &CGLTKDlg::OnBnClickedInput)
|
|
ON_BN_CLICKED(IDOK, &CGLTKDlg::OnBnClickedOk)
|
|
ON_WM_CTLCOLOR()
|
|
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, &CGLTKDlg::OnTvnSelchangedTree1)
|
|
ON_NOTIFY(NM_RCLICK, IDC_TREE1, &CGLTKDlg::OnNMRClickTree1)
|
|
ON_COMMAND(IDM_ADD_CITY, &CGLTKDlg::OnAddCity)
|
|
ON_COMMAND(IDM_ADD_STANDARD, &CGLTKDlg::OnAddStandard)
|
|
ON_COMMAND(IDM_DEL_CITY, &CGLTKDlg::OnDelItem)
|
|
ON_COMMAND(IDM_DEL_STANDARD, &CGLTKDlg::OnDelItem)
|
|
ON_COMMAND(IDM_DEL_SECTION, &CGLTKDlg::OnDelSection)
|
|
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, &CGLTKDlg::OnLvnItemchangedList1)
|
|
ON_NOTIFY(NM_RCLICK, IDC_LIST1, &CGLTKDlg::OnNMRClickList1)
|
|
ON_BN_CLICKED(IDC_BUTTON4, &CGLTKDlg::OnBnClickedButton4)
|
|
ON_BN_CLICKED(IDC_BUTTON5, &CGLTKDlg::OnBnClickedButton5)
|
|
END_MESSAGE_MAP()
|
|
|
|
void CGLTKDlg::SetCrossSectionScr(const CString& sCrossSectionScr)
|
|
{
|
|
m_sCrossSectionScr = sCrossSectionScr;
|
|
m_bScrForAddToDb = true;
|
|
}
|
|
|
|
BOOL CGLTKDlg::GetCrossSectionScr(CString& sCrossSectionScr) const
|
|
{
|
|
sCrossSectionScr = m_sCrossSectionScr;
|
|
//return m_nItemSel == -1 ? FALSE : TRUE;
|
|
return TRUE;
|
|
}
|
|
|
|
void CGLTKDlg::SetAddtionScr(const CString& sScr)
|
|
{
|
|
m_sAddtionScr = sScr;
|
|
}
|
|
|
|
BOOL CGLTKDlg::GetAddtionScr(CString& sScr) const
|
|
{
|
|
sScr = m_sAddtionScr;
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CGLTKDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// 如是选择模式
|
|
if (m_eOpera == eSelect)
|
|
{
|
|
if (GetDlgItem(IDC_BUTTON1))
|
|
GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
|
|
if (GetDlgItem(IDC_BUTTON2))
|
|
GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);
|
|
if (GetDlgItem(IDC_BUTTON3))
|
|
GetDlgItem(IDC_BUTTON3)->EnableWindow(FALSE);
|
|
}
|
|
else
|
|
m_wndList.EnableWindow(FALSE);
|
|
|
|
m_ImageList.Create(IDB_BITMAP4,16,1,RGB(0, 255, 255));
|
|
m_wndList.SetImageList(&m_ImageList,LVSIL_SMALL);
|
|
m_wndTree.SetImageList(&m_ImageList,TVSIL_NORMAL);
|
|
|
|
m_wndList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
|
|
m_wndList.InsertColumn(0,_T("标准名称"),LVCFMT_LEFT,80);
|
|
m_wndList.InsertColumn(1,_T("管廊截面描述"),LVCFMT_LEFT,200);
|
|
m_wndList.InsertColumn(2,_T("附属描述"),LVCFMT_LEFT,200);
|
|
|
|
// 子类化控件对象
|
|
if (!m_wndViewCtrl.SubclassDlgItem(IDC_STATIC_FRM, this))
|
|
{
|
|
// 错误时,结束对话框
|
|
EndDialog(IDCANCEL);
|
|
return FALSE;
|
|
}
|
|
|
|
ShowEarthWorm();
|
|
|
|
// 数据库
|
|
CString path = FilePath::GetSysDir() + STANDARD_DB;
|
|
if (!m_server.InitADOServer(path))
|
|
{
|
|
AfxMessageBox(CString(_T("数据库初始化失败,请检查 sys")) + STANDARD_DB + _T("文件是否存在."));
|
|
return false;
|
|
}
|
|
|
|
ShowCityEwStdTree();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CGLTKDlg::ShowCityEwStdTree()
|
|
{
|
|
initTree(m_server, m_wndTree);
|
|
}
|
|
|
|
void CGLTKDlg::ShowEarthWorm()
|
|
{
|
|
m_wndViewCtrl.clearAll();
|
|
m_wndViewCtrl.init(true);
|
|
m_wndViewCtrl.SetOrbitFlag(OBF_PAN | OBF_ZOOM | OBF_COTE);
|
|
|
|
if (m_sCrossSectionScr.Find(_T("RECT:")) == -1 )
|
|
{
|
|
//是盾构
|
|
ShowDGEarthworm();
|
|
return;
|
|
}
|
|
|
|
AecDbEarthWorm worm;
|
|
worm.SetCrossSectionScr(m_sCrossSectionScr);
|
|
worm.SetChamferInter(100.0f);
|
|
|
|
ESection eType = eRect;
|
|
AcGePoint2dArray arDatas;
|
|
eType = worm.ExtractEarthWormScr(arDatas);
|
|
|
|
AcGeLineSeg3d ln;
|
|
AcGePoint3d pt2(1000.0,0,0);
|
|
ln.set(AcGePoint3d::kOrigin,pt2);
|
|
|
|
AcDbRegion* pEWRegion = worm.CreateSectionRegion(ln,eType,arDatas);
|
|
if (pEWRegion != NULL)
|
|
{
|
|
AcDbExtents exts;
|
|
pEWRegion->getGeomExtents(exts);
|
|
|
|
// AcGeMatrix3d xform;
|
|
// xform.setToScaling(0.95);
|
|
// pEWRegion->transformBy(xform);
|
|
|
|
m_wndViewCtrl.InitFromCurrentView2D(exts,true);
|
|
|
|
AcDbVoidPtrArray arr;
|
|
int rooms = worm.CreateSectionRoomRegion(ln, eType, arDatas, arr);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbVoidPtrArray arr2;
|
|
worm.CreateSectionRoomAddition(ln,eType,arr2);
|
|
for (int i = 0; i < arr2.length(); i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arr2.at(i);
|
|
m_wndViewCtrl.Add(pEnt);
|
|
}
|
|
|
|
m_wndViewCtrl.Add(pEWRegion);
|
|
m_wndViewCtrl.view()->invalidate();
|
|
|
|
m_wndViewCtrl.Invalidate();
|
|
m_wndViewCtrl.RedrawWindow();
|
|
}
|
|
}
|
|
|
|
void CGLTKDlg::ShowDGEarthworm()
|
|
{
|
|
CString sFullPath = FilePath::GetSysDir();
|
|
sFullPath.MakeLower();
|
|
sFullPath += _T("\\DGJM.sat");
|
|
|
|
CStdioFile file;
|
|
if (file.Open(sFullPath,CFile::modeCreate |CFile::modeWrite ))
|
|
{
|
|
CString sScr = m_sCrossSectionScr;
|
|
int nPos = m_sCrossSectionScr.Find(_T("<ELAGN:") );
|
|
if (nPos != -1)
|
|
{
|
|
sScr = m_sCrossSectionScr.Mid(0,nPos);
|
|
}
|
|
file.WriteString(sScr);
|
|
file.Close();
|
|
}
|
|
|
|
AcDbVoidPtrArray arBodyPtrs;
|
|
if ( Acad::eOk == AcDbBody::acisIn(sFullPath,arBodyPtrs) )
|
|
{
|
|
AcDbRegion* pRegSect = NULL;
|
|
if (arBodyPtrs.length() > 0)
|
|
{
|
|
AcDbEntity* pEnt = (AcDbEntity*)arBodyPtrs.first();
|
|
|
|
AcDbRegion* pRegion = AcDbRegion::cast(pEnt);
|
|
if (pRegion != NULL)
|
|
{
|
|
pRegSect = pRegion;
|
|
}
|
|
|
|
AcDbExtents exts;
|
|
pRegion->getGeomExtents(exts);
|
|
|
|
m_wndViewCtrl.InitFromCurrentView2D(exts,true);
|
|
|
|
m_wndViewCtrl.Add(pRegion);
|
|
m_wndViewCtrl.view()->invalidate();
|
|
|
|
m_wndViewCtrl.Invalidate();
|
|
m_wndViewCtrl.RedrawWindow();
|
|
}
|
|
}
|
|
}
|
|
|
|
void CGLTKDlg::OnBnClickedAddCity()
|
|
{
|
|
//新建城市节点,并入库
|
|
CString name;
|
|
if (!CoreTools::getNameByDialog(_T("请输入城市名称"), _T("城市名称:"), name)) return;
|
|
if (name.IsEmpty()) return;
|
|
if (hasSameCity(m_wndTree, name))
|
|
{
|
|
AfxMessageBox(_T("输入的城市名已存在。"));
|
|
return;
|
|
}
|
|
HTREEITEM item = m_wndTree.InsertItem(name, 0, 0, TVI_ROOT, TVI_LAST);
|
|
m_wndTree.Invalidate();
|
|
m_wndTree.SelectItem(item);
|
|
|
|
InsertData(m_server, name, _T(""), _T(""));
|
|
}
|
|
|
|
void CGLTKDlg::OnBnClickedAddStandard()
|
|
{
|
|
//新建标准,弹出一个对话框,
|
|
|
|
HTREEITEM item = m_wndTree.GetSelectedItem();
|
|
if (!IsCityItem(m_wndTree, item))
|
|
{
|
|
AfxMessageBox(_T("请选中一个城市!"));
|
|
return;
|
|
}
|
|
CString name;
|
|
if (!CoreTools::getNameByDialog(_T("请输入标准名称"), _T("标准名称:"), name)) return;
|
|
if (name.IsEmpty()) return;
|
|
if (hasSameStandard(m_wndTree, item, name))
|
|
{
|
|
AfxMessageBox(_T("输入的标准名已存在。"));
|
|
return;
|
|
}
|
|
|
|
HTREEITEM sub = m_wndTree.InsertItem(name, 0, 0, item, TVI_LAST);
|
|
m_wndTree.Expand(item, TVE_EXPAND);
|
|
m_wndTree.Invalidate();
|
|
m_wndTree.SelectItem(sub);
|
|
|
|
CString city = m_wndTree.GetItemText(item);
|
|
InsertData(m_server, city, name, _T(""));
|
|
}
|
|
|
|
void CGLTKDlg::OnBnClickedInput()
|
|
{
|
|
HTREEITEM item = m_wndTree.GetSelectedItem();
|
|
if (!IsStandardItem(m_wndTree, item))
|
|
{
|
|
AfxMessageBox(_T("请选中一个标准"));
|
|
return;
|
|
}
|
|
|
|
CString city = m_wndTree.GetItemText(m_wndTree.GetParentItem(item));
|
|
CString standard = m_wndTree.GetItemText(item);
|
|
CString section;
|
|
m_wndScrEdit.GetWindowText(section);
|
|
|
|
if (m_sAddtionScr.IsEmpty())
|
|
{
|
|
InsertData(m_server, city, standard, section);
|
|
}
|
|
else
|
|
{
|
|
InsertData(m_server, city, standard, section,m_sAddtionScr);
|
|
}
|
|
|
|
m_bScrForAddToDb = false;//入库完毕,控件为灰色
|
|
|
|
RefreshLst(m_server, m_wndList, m_wndTree, item);
|
|
|
|
// 入库成功,三个按钮无效
|
|
m_sAddtionScr = _T("");
|
|
if (GetDlgItem(IDC_BUTTON1))
|
|
GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
|
|
if (GetDlgItem(IDC_BUTTON2))
|
|
GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);
|
|
if (GetDlgItem(IDC_BUTTON3))
|
|
GetDlgItem(IDC_BUTTON3)->EnableWindow(FALSE);
|
|
m_wndList.EnableWindow(TRUE);
|
|
|
|
UpdateWindow();
|
|
RedrawWindow();
|
|
}
|
|
|
|
void CGLTKDlg::OnBnClickedOk()
|
|
{
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
HBRUSH CGLTKDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
|
{
|
|
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
if (pWnd == GetDlgItem(IDC_EDIT1))
|
|
{
|
|
if (m_bScrForAddToDb)
|
|
{
|
|
COLORREF crColor = RGB(255, 0, 0);
|
|
pDC->SetTextColor(crColor);
|
|
}
|
|
}
|
|
return hbr;
|
|
}
|
|
|
|
void CGLTKDlg::OnTvnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
*pResult = 0;
|
|
|
|
|
|
// 只有点中城市节点时,list才会更新,点中标准节点时,先取父节点,更新list,然后gsview更新
|
|
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
|
|
HTREEITEM hSelect = pNMTreeView->itemNew.hItem;
|
|
if (!hSelect) return;
|
|
|
|
// 城市
|
|
if (IsCityItem(m_wndTree, hSelect))
|
|
{
|
|
RefreshLst(m_server, m_wndList, m_wndTree, hSelect);
|
|
}
|
|
else // 标准
|
|
{
|
|
RefreshLst(m_server, m_wndList, m_wndTree, hSelect);
|
|
}
|
|
}
|
|
|
|
void CGLTKDlg::OnAddCity()
|
|
{
|
|
OnBnClickedAddCity();
|
|
}
|
|
|
|
void CGLTKDlg::OnDelItem()
|
|
{
|
|
if (AfxMessageBox(_T("是否删除这个节点?这个操作不能够恢复!"), MB_YESNO) != IDYES) return;
|
|
deleteCurrentItem(m_server, m_wndTree);
|
|
m_wndTree.Invalidate();
|
|
HTREEITEM item = m_wndTree.GetFirstVisibleItem();
|
|
if (item)
|
|
m_wndTree.SelectItem(item);
|
|
else
|
|
m_wndList.DeleteAllItems();
|
|
}
|
|
|
|
void CGLTKDlg::OnDelSection()
|
|
{
|
|
if (AfxMessageBox(_T("是否进行删除,此操作不能恢复!"), MB_YESNO) != IDYES) return;
|
|
int nCurSel = m_wndList.GetSelectionMark();
|
|
HTREEITEM item = m_wndTree.GetSelectedItem();
|
|
CString city(_T(""));
|
|
if (IsCityItem(m_wndTree, item))
|
|
city = m_wndTree.GetItemText(item);
|
|
else
|
|
city = m_wndTree.GetItemText(m_wndTree.GetParentItem(item));
|
|
|
|
CString standard = m_wndList.GetItemText(nCurSel, 0);
|
|
CString section = m_wndList.GetItemText(nCurSel, 1);
|
|
CString sql(_T(""));
|
|
sql.Format(_T("delete from %s where city='%s' and standard='%s' and section='%s'"),
|
|
STANDARD_TABLE, city, standard, section);
|
|
m_server.ExecuteSQL(sql);
|
|
RefreshLst(m_server, m_wndList, m_wndTree, item);
|
|
}
|
|
|
|
void CGLTKDlg::OnAddStandard()
|
|
{
|
|
OnBnClickedAddStandard();
|
|
}
|
|
|
|
void CGLTKDlg::OnNMRClickTree1(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
CPoint pt;
|
|
::GetCursorPos(&pt);
|
|
|
|
CPoint pointInTree = pt;
|
|
m_wndTree.ScreenToClient(&pointInTree);
|
|
UINT nFlag = TVHT_ONITEM; // 当在 Item 上右击时
|
|
HTREEITEM item = m_wndTree.HitTest(pointInTree, &nFlag);
|
|
|
|
CMenu menu;
|
|
menu.CreatePopupMenu();
|
|
|
|
if (!item) // 空,则新建城市
|
|
{
|
|
menu.AppendMenu(MF_STRING, IDM_ADD_CITY, _T("添加城市"));
|
|
}
|
|
else if (m_wndTree.GetParentItem(item) == NULL) // 选中城市节点
|
|
{
|
|
m_wndTree.SelectItem(item);
|
|
menu.AppendMenu(MF_STRING, IDM_ADD_STANDARD, _T("添加标准"));
|
|
menu.AppendMenu(MF_STRING, IDM_DEL_CITY, _T("删除城市"));
|
|
}
|
|
else // 选中标准节点
|
|
{
|
|
m_wndTree.SelectItem(item);
|
|
menu.AppendMenu(MF_STRING, IDM_DEL_STANDARD, _T("删除标准"));
|
|
}
|
|
menu.TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this);
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
|
|
void CGLTKDlg::OnLvnItemchangedList1(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
*pResult = 0;
|
|
|
|
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
|
|
int nCurSel = pNMLV->iItem;
|
|
|
|
if (m_nItemSel == nCurSel) return;
|
|
|
|
m_sCrossSectionScr = m_wndList.GetItemText(nCurSel, 1);
|
|
m_sAddtionScr = m_wndList.GetItemText(nCurSel,2);
|
|
|
|
if (!m_sCrossSectionScr.IsEmpty())
|
|
{
|
|
UpdateData(FALSE);
|
|
ShowEarthWorm();
|
|
m_nItemSel = nCurSel;
|
|
}
|
|
}
|
|
|
|
|
|
void CGLTKDlg::OnNMRClickList1(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
|
// TODO: Add your control notification handler code here
|
|
*pResult = 0;
|
|
|
|
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
|
|
int nCurSel = pNMLV->iItem;
|
|
|
|
CPoint pt;
|
|
::GetCursorPos(&pt);
|
|
CMenu menu;
|
|
menu.CreatePopupMenu();
|
|
menu.AppendMenu(MF_STRING, IDM_DEL_SECTION, _T("删除"));
|
|
menu.TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this);
|
|
}
|
|
|
|
void CGLTKDlg::OnBnClickedButton4()
|
|
{
|
|
UpdateData();
|
|
if (!m_sCrossSectionScr.IsEmpty())
|
|
{
|
|
CString sFullPath = FilePath::GetSysDir();
|
|
sFullPath.MakeLower();
|
|
sFullPath.Replace(_T("\\sys"),_T("\\temp\\efedemo.ews"));
|
|
|
|
CString szFilter = _T("管廊截面脚本文件 (*.ews)|*.ews;*.ews||");
|
|
CFileDialog fileDlg(FALSE,_T("ews"),sFullPath,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter,acedGetAcadFrame());
|
|
int nRes = fileDlg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
//efeTemplete.db
|
|
sFullPath = fileDlg.GetPathName();
|
|
|
|
AecDbObjXDataMap xDataMap;
|
|
xDataMap.SetAt(_T("FILEFLAG"),_T("EARTHWORMSECTIONFILE 1.0"));
|
|
xDataMap.SetAt(_T("EarthWormSect"),m_sCrossSectionScr);
|
|
|
|
CFile file;
|
|
if (file.Open(sFullPath,CFile::modeCreate | CFile::modeWrite))
|
|
{
|
|
xDataMap.Write(&file,FALSE);
|
|
file.Close();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void CGLTKDlg::OnBnClickedButton5()
|
|
{
|
|
UpdateData();
|
|
|
|
CString szFilter = _T("管廊截面脚本文件 (*.ews)|*.ews;*.ews||");
|
|
CFileDialog fileDlg(TRUE, _T("ews"), NULL, OFN_HIDEREADONLY,szFilter,this);
|
|
|
|
TCHAR szFileName[16001] = _T("");
|
|
LPCTSTR szDlgTitle = _T("管廊截面脚本文件");
|
|
int maxChar = 16000;
|
|
fileDlg.m_ofn.lpstrFile = szFileName;
|
|
fileDlg.m_ofn.nMaxFile = maxChar;
|
|
fileDlg.m_ofn.lpstrTitle = szDlgTitle;
|
|
fileDlg.m_ofn.lpstrInitialDir = _T("");
|
|
|
|
CString sEfeFile = _T("");
|
|
if (IDOK == fileDlg.DoModal())
|
|
{
|
|
sEfeFile = fileDlg.GetPathName();
|
|
|
|
CFile file;
|
|
if (file.Open(sEfeFile,CFile::modeRead ))
|
|
{
|
|
AecDbObjXDataMap xDataMap;
|
|
xDataMap.Read(&file,FALSE);
|
|
|
|
CString sFlag,sSect;
|
|
xDataMap.GetAt(_T("FILEFLAG"),sFlag);
|
|
xDataMap.GetAt(_T("EarthWormSect"),sSect);
|
|
|
|
if (sFlag.CompareNoCase(_T("EARTHWORMSECTIONFILE 1.0")) == 0)
|
|
{
|
|
if (!sSect.IsEmpty())
|
|
{
|
|
m_sCrossSectionScr = sSect;
|
|
m_bScrForAddToDb = true;
|
|
|
|
if (GetDlgItem(IDC_BUTTON1))
|
|
GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
|
|
if (GetDlgItem(IDC_BUTTON2))
|
|
GetDlgItem(IDC_BUTTON2)->EnableWindow(TRUE);
|
|
if (GetDlgItem(IDC_BUTTON3))
|
|
GetDlgItem(IDC_BUTTON3)->EnableWindow(TRUE);
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox(_T("管廊截面脚本文件!读入失败!"));
|
|
}
|
|
file.Close();
|
|
}
|
|
}
|
|
}
|