758 lines
18 KiB
C++
758 lines
18 KiB
C++
#include "stdafx.h"
|
||
#include "EquLibDlg.h"
|
||
#include "coretools.h"
|
||
#include "AcGiViewDraw.h"
|
||
#include "AecDbEwEquipment.h"
|
||
|
||
namespace
|
||
{
|
||
CSize getControlWndTextSize(CWnd *pS, LPCTSTR psz = NULL)
|
||
{
|
||
CSize sz(0, 0);
|
||
if (!pS) return sz;
|
||
|
||
CDC *pDc = pS->GetDC();
|
||
pDc->SelectObject(pS->GetFont());
|
||
|
||
CString str;
|
||
if (psz)
|
||
str = psz;
|
||
else
|
||
pS->GetWindowText(str);
|
||
|
||
::GetTextExtentPoint32(pDc->m_hDC, str, str.GetLength(), &sz);
|
||
|
||
pS->ReleaseDC(pDc);
|
||
return sz;
|
||
}
|
||
|
||
}
|
||
|
||
BEGIN_MESSAGE_MAP(CEquLibDlg, CModelLibDlgBase)
|
||
ON_BN_CLICKED(IDC_CHECK_FANGLE, &CEquLibDlg::OnChkFlange)
|
||
ON_BN_CLICKED(IDC_CHECK2DFLAG, &CEquLibDlg::OnChk2dFlag)
|
||
ON_CBN_SELCHANGE(IDC_COMB_VALVE_TYPE, &CEquLibDlg::OnCbnSelchangeValveDriverType)
|
||
END_MESSAGE_MAP()
|
||
|
||
CEquLibDlg::CEquLibDlg(LPCTSTR pszDir , LPCTSTR pszFile)
|
||
: CModelLibDlgBase(_T("自定义设备"), pszDir, pszFile)
|
||
, m_sTablePrefix(_T("aec"))
|
||
, m_sFileSuffix(_T(".equ"))
|
||
, m_sRootName(_T("自定义设备"))
|
||
, m_bInsertMode(false)
|
||
, m_bValveMode(false)
|
||
, m_bUseFangle(false)
|
||
, m_bCheck2DFlag(false)
|
||
, m_nValveType(0)
|
||
, m_sEndF1(_T(""))
|
||
, m_sEndF2(_T(""))
|
||
, m_sGaskets(_T(""))
|
||
{
|
||
}
|
||
|
||
CRect CEquLibDlg::calcCtrlSize(CWnd * pWnd, const CPoint &ptLM)
|
||
{
|
||
if (!pWnd) return CRect();
|
||
|
||
CSize sz = getControlWndTextSize(pWnd);
|
||
|
||
// checkbox
|
||
CButton *pBtn = DYNAMIC_DOWNCAST(CButton, pWnd);
|
||
if (pBtn)
|
||
{
|
||
DWORD style = pBtn->GetButtonStyle() & 0x000F;
|
||
if (style == BS_CHECKBOX ||
|
||
style == BS_AUTOCHECKBOX ||
|
||
style == BS_3STATE ||
|
||
style == BS_AUTO3STATE)
|
||
{
|
||
// 判断是文字高还是复选框高
|
||
int boxH = ::GetSystemMetrics(SM_CYMENUCHECK);
|
||
if (boxH > sz.cy)
|
||
sz.cy = boxH;
|
||
sz.cx += ::GetSystemMetrics(SM_CXMENUCHECK) + 4;
|
||
}
|
||
}
|
||
CComboBox *pBox = DYNAMIC_DOWNCAST(CComboBox, pWnd);
|
||
if (pBox)
|
||
{
|
||
sz.cx += ::GetSystemMetrics(SM_CXBORDER) * 2;
|
||
sz.cx += ::GetSystemMetrics(SM_CXHSCROLL);
|
||
sz.cx += 8;
|
||
int height = pBox->GetItemHeight(-1) + 6;
|
||
sz.cy = height;
|
||
}
|
||
|
||
CPoint ptLT = ptLM;
|
||
ptLT.y -= sz.cy / 2;
|
||
|
||
CRect rc(ptLT, CSize(sz.cx, sz.cy));
|
||
|
||
pWnd->MoveWindow(rc);
|
||
return rc;
|
||
}
|
||
|
||
BOOL CEquLibDlg::OnInitDialog()
|
||
{
|
||
CModelLibDlgBase::OnInitDialog();
|
||
helper_ShowWindow(IDC_FILE_NEW, this, false);
|
||
|
||
if (m_bInsertMode)
|
||
{
|
||
CWnd *pWnd = GetDlgItem(IDOK);
|
||
if (pWnd) pWnd->SetWindowText(_T("插入"));
|
||
|
||
helper_ShowWindow(IDC_DIR_ADD, this, false);
|
||
helper_ShowWindow(IDC_DIR_MODI, this, false);
|
||
helper_ShowWindow(IDC_DIR_DEL, this, false);
|
||
helper_ShowWindow(IDC_DIR_OUT, this, false);
|
||
helper_ShowWindow(IDC_DIR_IN, this, false);
|
||
helper_ShowWindow(IDC_FILE_COPY, this, false);
|
||
helper_ShowWindow(IDC_FILE_IN, this, false);
|
||
helper_ShowWindow(IDC_FILE_RENAME, this, false);
|
||
helper_ShowWindow(IDC_FILE_DEL, this, false);
|
||
helper_ShowWindow(IDC_FILE_OUT, this, false);
|
||
helper_ShowWindow(IDC_BIM_ADD, this, false);
|
||
helper_ShowWindow(IDC_BIM_MODI, this, false);
|
||
helper_ShowWindow(IDC_BIM_DEL, this, false);
|
||
}
|
||
|
||
CWnd *pWnd = GetDlgItem(IDC_BTN_EXPAND_SERVER);
|
||
if (!pWnd) return TRUE;
|
||
CRect rc;
|
||
pWnd->GetWindowRect(rc);
|
||
ScreenToClient(rc);
|
||
|
||
int midY = (rc.top + rc.bottom) / 2;
|
||
|
||
m_ctrlCheckUseFangle.Create(_T("管线插入配对法兰")
|
||
, WS_CHILD | WS_VISIBLE | BS_CHECKBOX | BS_AUTOCHECKBOX
|
||
, CRect()
|
||
, this
|
||
, IDC_CHECK_FANGLE);
|
||
m_ctrlCheckUseFangle.SetFont(GetFont());
|
||
m_ctrlCheckUseFangle.SetCheck(m_bUseFangle);
|
||
rc = calcCtrlSize(&m_ctrlCheckUseFangle, CPoint(rc.right + 10, midY));
|
||
|
||
m_ctrlCheck2DFlag.Create(_T("二维显示为符号")
|
||
, WS_CHILD | WS_VISIBLE | BS_CHECKBOX | BS_AUTOCHECKBOX
|
||
, CRect()
|
||
, this
|
||
, IDC_CHECK2DFLAG);
|
||
m_ctrlCheck2DFlag.SetFont(GetFont());
|
||
m_ctrlCheck2DFlag.SetCheck(m_bCheck2DFlag);
|
||
rc = calcCtrlSize(&m_ctrlCheck2DFlag, CPoint(rc.right + 10, midY));
|
||
|
||
m_ctrlStaticValveDriverType.Create(_T("阀门驱动类型:")
|
||
, WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE
|
||
, CRect()
|
||
, this
|
||
, IDC_STATIC_VALUE_DRIVER);
|
||
m_ctrlStaticValveDriverType.SetFont(GetFont());
|
||
rc = calcCtrlSize(&m_ctrlStaticValveDriverType, CPoint(rc.right + 10, midY));
|
||
|
||
m_ctrlComboValveDriverType.Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST
|
||
, CRect()
|
||
, this
|
||
, IDC_COMB_VALVE_TYPE);
|
||
m_ctrlComboValveDriverType.SetFont(GetFont());
|
||
m_ctrlComboValveDriverType.AddString(_T("手动"));
|
||
m_ctrlComboValveDriverType.AddString(_T("电动"));
|
||
m_ctrlComboValveDriverType.AddString(_T("气动"));
|
||
m_ctrlComboValveDriverType.AddString(_T("液动"));
|
||
m_ctrlComboValveDriverType.SetCurSel(0);
|
||
rc = calcCtrlSize(&m_ctrlComboValveDriverType, CPoint(rc.right + 10, midY));
|
||
|
||
// 非插入阀门模式下,隐藏
|
||
if (!m_bValveMode)
|
||
{
|
||
m_ctrlCheckUseFangle.ShowWindow(SW_HIDE);
|
||
m_ctrlCheck2DFlag.ShowWindow(SW_HIDE);
|
||
m_ctrlComboValveDriverType.ShowWindow(SW_HIDE);
|
||
m_ctrlStaticValveDriverType.ShowWindow(SW_HIDE);
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
void CEquLibDlg::OnChkFlange()
|
||
{
|
||
m_bUseFangle = !m_bUseFangle;
|
||
}
|
||
|
||
void CEquLibDlg::OnChk2dFlag()
|
||
{
|
||
m_bCheck2DFlag = !m_bCheck2DFlag;
|
||
}
|
||
|
||
void CEquLibDlg::OnCbnSelchangeValveDriverType()
|
||
{
|
||
m_nValveType = m_ctrlComboValveDriverType.GetCurSel();
|
||
}
|
||
|
||
bool CEquLibDlg::initSqliteDB()
|
||
{
|
||
if (!m_sqlDB.InitADOServer(FilePath::GetSysDir() + _T("\\aec3dmep.db")))
|
||
{
|
||
AfxMessageBox(_T("打开数据库Aec3DMep.db失败!"));
|
||
EndDialog(-1);
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
void CEquLibDlg::refreshLocalFileList(HTREEITEM hItem)
|
||
{
|
||
helper_refreshLocalFileList(hItem, m_sTablePrefix);
|
||
}
|
||
|
||
void CEquLibDlg::refreshBimPropertyList(int idx)
|
||
{
|
||
if (idx == -1) return;
|
||
|
||
int fid = m_ctrlLocalFileList.GetItemData(idx);
|
||
m_ctrlBimPropertyList.DeleteAllItems();
|
||
int nRow(0);
|
||
|
||
std::vector<std::vector<CString>> bims;
|
||
CString Sql(_T(""));
|
||
Sql.Format(_T("select id, name, value from aec_bims where equid=%d"), fid);
|
||
m_sqlDB.GetSelDataEx(Sql, bims);
|
||
for (size_t i = 0; i < bims.size(); ++i)
|
||
{
|
||
std::vector<CString> &v(bims[i]);
|
||
if (v.size() < 3) continue;
|
||
nRow = m_ctrlBimPropertyList.InsertItem(nRow, v[1]);
|
||
m_ctrlBimPropertyList.SetItemText(nRow, 1, v[2]);
|
||
m_ctrlBimPropertyList.SetItemData(nRow, TypeConvert::convert<int, LPCTSTR>(v[0]));
|
||
nRow++;
|
||
}
|
||
}
|
||
|
||
void CEquLibDlg::LbnSelchangeFileList()
|
||
{
|
||
std::vector<int> v;
|
||
getSelectedFiles(v);
|
||
if (v.size() > 1)
|
||
return;
|
||
|
||
AcAxDocLock lock;
|
||
|
||
int idx = m_ctrlLocalFileList.GetCurSel();
|
||
refreshBimPropertyList(idx);
|
||
m_iSelectFileID = m_ctrlLocalFileList.GetItemData(idx);
|
||
|
||
|
||
m_wndPreviewCtrl.clearAll();
|
||
m_wndPreviewCtrl.init(true);
|
||
m_wndPreviewCtrl.SetOrbitFlag(OBF_PAN | OBF_ZOOM | OBF_COTE);
|
||
AcDbExtents exts;
|
||
AecDbEwEquipment *pEqu = getEquipment(m_iSelectFileID);
|
||
if (!pEqu) return;
|
||
|
||
// 预览
|
||
AcGiViewDraw dc;
|
||
pEqu->Draw3d(dc);
|
||
pEqu->getGeomExtents(exts);
|
||
m_wndPreviewCtrl.InitFromCurrentView3D(exts, true);
|
||
m_wndPreviewCtrl.Add(pEqu);
|
||
m_wndPreviewCtrl.view()->invalidate();
|
||
m_wndPreviewCtrl.Invalidate();
|
||
m_wndPreviewCtrl.RedrawWindow();
|
||
return;
|
||
}
|
||
|
||
void CEquLibDlg::LbnDblClkFileList()
|
||
{
|
||
if (m_bSearch)
|
||
{
|
||
helper_CurrentSelectFilePosition();
|
||
}
|
||
else
|
||
{
|
||
BnClickedInsert();
|
||
}
|
||
}
|
||
|
||
void CEquLibDlg::initPreviewCtrl()
|
||
{
|
||
m_wndPreviewCtrl.SubclassDlgItem(IDC_PREVIEW_PIC, this);
|
||
}
|
||
|
||
void CEquLibDlg::initLocalDirTree()
|
||
{
|
||
helper_initLocalDirTree(m_sRootName, m_sTablePrefix);
|
||
}
|
||
|
||
void CEquLibDlg::initServerDirTree()
|
||
{
|
||
helper_initServerDirTree(_T("未找到服务器配置"));
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedDirAdd()
|
||
{
|
||
helper_ClickedLocalDirAdd(m_sTablePrefix);
|
||
}
|
||
void CEquLibDlg::BnClickedDirRename()
|
||
{
|
||
helper_ClickedLocalDirRename(m_sTablePrefix);
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedDirDel()
|
||
{
|
||
helper_ClickedLocalDirDel(m_sTablePrefix);
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedDirOut()
|
||
{
|
||
helper_ClickedLocalDirOut(m_sTablePrefix, m_sFileSuffix);
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedDirIn()
|
||
{
|
||
std::vector<CString> filetypes(1, CString(_T("*")) + m_sFileSuffix);
|
||
filetypes.push_back(_T("*.r2p"));
|
||
helper_ClickedLocalDirIn(m_sTablePrefix, filetypes);
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedFileIn()
|
||
{
|
||
CString s(_T("上华设备文件(*.equ,*.r2p)|*.equ;*.r2p||"));
|
||
helper_ClickedFileIn(s);
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedFileNew()
|
||
{
|
||
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedFileCopy()
|
||
{
|
||
helper_ClickedFileCopy(m_sRootName, m_sTablePrefix);
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedFileRename()
|
||
{
|
||
helper_ClickedFileRename(m_sTablePrefix);
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedFileDel()
|
||
{
|
||
helper_ClickedFileDel(m_sTablePrefix);
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedFileOut()
|
||
{
|
||
|
||
HTREEITEM hRoot = m_ctrlLocalDirTree.GetSelectedItem();
|
||
if (!hRoot)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
|
||
std::vector<int> files;
|
||
getSelectedFiles(files);
|
||
if (files.empty())
|
||
{
|
||
AfxMessageBox(_T("请至少选择一个文件!"));
|
||
return;
|
||
}
|
||
|
||
CString sPath(_T(""));
|
||
if (!helper_selectPath(_T("请选择文件要保存的目录"), sPath))
|
||
return;
|
||
|
||
CString sName(_T("")), sFile(_T(""));
|
||
int fileId(-1);
|
||
for (size_t i = 0; i < files.size(); ++i)
|
||
{
|
||
fileId = m_ctrlLocalFileList.GetItemData(files[i]);
|
||
m_ctrlLocalFileList.GetText(files[i], sName);
|
||
|
||
sName = helper_checkFileName(sName);
|
||
sFile = sPath + sName;
|
||
|
||
AecDbEwEquipment *pEqu = getEquipment(fileId);
|
||
if (!pEqu) continue;
|
||
|
||
sFile += _T(".equ");
|
||
if (_taccess(sFile, 0x0) == 0x0)
|
||
{
|
||
if (IDYES != AfxMessageBox(CString(_T("文件:")) + sName + _T("已存在,是否覆盖?"), MB_YESNO))
|
||
{
|
||
DELETE_PTR(pEqu);
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
if (!::DeleteFile(sFile))
|
||
{
|
||
AfxMessageBox(helper_getLastErrorMsg());
|
||
DELETE_PTR(pEqu);
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
|
||
CoreTools::equipment2File(pEqu, sFile, sName);
|
||
|
||
DELETE_PTR(pEqu);
|
||
}
|
||
|
||
AfxMessageBox(_T("文件导出完毕。"));
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedBimAdd()
|
||
{
|
||
int idx = m_ctrlLocalFileList.GetCurSel();
|
||
if (idx == -1)
|
||
{
|
||
AfxMessageBox(_T("请选中一个文件!"));
|
||
return;
|
||
}
|
||
|
||
int equId = m_ctrlLocalFileList.GetItemData(idx);
|
||
|
||
CString sKey(_T("")), sValue(_T(""));
|
||
|
||
while (CoreTools::getBimDataByDlg(true, sKey, sValue))
|
||
{
|
||
|
||
LVFINDINFO info;
|
||
info.flags = LVFI_PARTIAL | LVFI_STRING;
|
||
info.psz = sKey;
|
||
int nIndex;
|
||
|
||
nIndex = m_ctrlBimPropertyList.FindItem(&info);
|
||
if (nIndex != -1)
|
||
{
|
||
AfxMessageBox(_T("已经存在相同的属性!"));
|
||
return;
|
||
}
|
||
|
||
CString sql(_T(""));
|
||
sql.Format(_T("insert into aec_bims (name, value, equid) values ('%s', '%s', '%d')")
|
||
, sKey
|
||
, sValue
|
||
, equId);
|
||
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
int id = helper_getLastInserId(m_sqlDB, _T("aec_bims"));
|
||
idx = m_ctrlBimPropertyList.InsertItem(m_ctrlBimPropertyList.GetItemCount() + 1, sKey);
|
||
m_ctrlBimPropertyList.SetItemText(idx, 1, sValue);
|
||
m_ctrlBimPropertyList.SetItemData(idx, id);
|
||
m_ctrlBimPropertyList.Invalidate();
|
||
}
|
||
}
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedBimModi()
|
||
{
|
||
int idx = m_ctrlLocalFileList.GetCurSel();
|
||
if (idx == -1)
|
||
{
|
||
AfxMessageBox(_T("请选中一个文件!"));
|
||
return;
|
||
}
|
||
|
||
int equId = m_ctrlLocalFileList.GetItemData(idx);
|
||
|
||
idx = m_ctrlBimPropertyList.GetSelectionMark();
|
||
if (idx == -1)
|
||
{
|
||
AfxMessageBox(_T("请选中一行数据!"));
|
||
return;
|
||
}
|
||
|
||
int bimId = m_ctrlBimPropertyList.GetItemData(idx);
|
||
|
||
if (AfxMessageBox(_T("是否修改?此操作不可逆!"), MB_YESNO) != IDYES)
|
||
return;
|
||
|
||
CString sKey(m_ctrlBimPropertyList.GetItemText(idx, 0)), sValue(m_ctrlBimPropertyList.GetItemText(idx, 1));
|
||
if (!CoreTools::getBimDataByDlg(false, sKey, sValue)) return;
|
||
|
||
CString sql(_T(""));
|
||
sql.Format(_T("update aec_bims set value='%s' where id='%d'"), sValue, bimId);
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
m_ctrlBimPropertyList.SetItemText(idx, 1, sValue);
|
||
m_ctrlBimPropertyList.Invalidate();
|
||
//refreshBimList(idx);
|
||
}
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedBimDel()
|
||
{
|
||
int fileIdx = m_ctrlLocalFileList.GetCurSel();
|
||
if (fileIdx == -1)
|
||
{
|
||
AfxMessageBox(_T("请选中一个文件!"));
|
||
return;
|
||
}
|
||
int equId = m_ctrlLocalFileList.GetItemData(fileIdx);
|
||
|
||
int bimIdx = m_ctrlBimPropertyList.GetSelectionMark();
|
||
if (bimIdx == -1)
|
||
{
|
||
AfxMessageBox(_T("请选中一行数据!"));
|
||
return;
|
||
}
|
||
int bimId = m_ctrlBimPropertyList.GetItemData(bimIdx);
|
||
|
||
if (AfxMessageBox(_T("是否删除?此操作不可逆!"), MB_YESNO) != IDYES)
|
||
return;
|
||
|
||
CString sql(_T(""));
|
||
sql.Format(_T("delete from aec_bims where id='%d'"), bimId);
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
m_ctrlBimPropertyList.DeleteItem(bimIdx);
|
||
m_ctrlBimPropertyList.Invalidate();
|
||
//refreshBimList(fileIdx);
|
||
}
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedOk()
|
||
{
|
||
CDialog::OnOK();
|
||
}
|
||
|
||
void CEquLibDlg::BnClickedInsert()
|
||
{
|
||
OnCancel();
|
||
}
|
||
|
||
void CEquLibDlg::TvnSelchangedLocalDirTree(NMHDR *pNMHDR, LRESULT *pResult)
|
||
{
|
||
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
|
||
if (!pNMTreeView->itemNew.hItem) return;
|
||
|
||
refreshLocalFileList(pNMTreeView->itemNew.hItem);
|
||
|
||
m_iSelectFileID = -1;
|
||
|
||
*pResult = 0;
|
||
}
|
||
|
||
void CEquLibDlg::EnChangeSearch()
|
||
{
|
||
helper_EnChangeSearch(m_sTablePrefix);
|
||
}
|
||
|
||
void CEquLibDlg::PopMenuForLocalDirTree(const CPoint &pt)
|
||
{
|
||
helper_PopMenuForLocalDirTree(pt);
|
||
}
|
||
|
||
void CEquLibDlg::PopMenuForServerDirTree(const CPoint &pt)
|
||
{
|
||
}
|
||
|
||
void CEquLibDlg::PopMenuForLocalFileList(const CPoint &pt)
|
||
{
|
||
CMenu menu;
|
||
menu.CreatePopupMenu();
|
||
|
||
std::vector<int> v;
|
||
getSelectedFiles(v);
|
||
|
||
if (m_bSearch)
|
||
{
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_ANCHOR, _T("定位文件(&W)"));
|
||
}
|
||
else
|
||
{
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_IN, _T("导入文件(&I)"));
|
||
if (!v.empty())
|
||
{
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_OUT, _T("导出文件(&O)"));
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_COPY, _T("复制文件(&C)"));
|
||
if (v.size() == 1)
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_RENAME, _T("文件改名(&M)"));
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_DEL, _T("删除文件(&D)"));
|
||
}
|
||
}
|
||
|
||
int nID = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD
|
||
, pt.x
|
||
, pt.y, &m_ctrlLocalFileList);
|
||
|
||
switch (nID)
|
||
{
|
||
case ID_EQU_LIB_FILE_NEW:
|
||
OnBnClickedFileNew();
|
||
break;
|
||
case ID_EQU_LIB_FILE_IN:
|
||
OnBnClickedFileIn();
|
||
break;
|
||
case ID_EQU_LIB_FILE_OUT:
|
||
return OnBnClickedFileOut();
|
||
case ID_EQU_LIB_FILE_DEL:
|
||
OnBnClickedFileDel();
|
||
break;
|
||
case ID_EQU_LIB_FILE_COPY:
|
||
OnBnClickedFileCopy();
|
||
break;
|
||
case ID_EQU_LIB_FILE_RENAME:
|
||
OnBnClickedFileRename();
|
||
break;
|
||
case ID_EQU_LIB_FILE_ANCHOR:
|
||
return helper_CurrentSelectFilePosition();
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void CEquLibDlg::ExpandServerDirTree(bool bExpand)
|
||
{
|
||
|
||
if (m_bValveMode)
|
||
{
|
||
CRect rect;
|
||
GetWindowRect(rect);
|
||
int nDelta(m_nDlgExpandedWidth - m_nDlgCollapsedWidth);
|
||
|
||
if (!bExpand)
|
||
nDelta *= -1;
|
||
|
||
moveCtrlX(IDC_CHECK_FANGLE, nDelta);
|
||
moveCtrlX(IDC_CHECK2DFLAG, nDelta);
|
||
moveCtrlX(IDC_STATIC_VALUE_DRIVER, nDelta);
|
||
moveCtrlX(IDC_COMB_VALVE_TYPE, nDelta);
|
||
}
|
||
|
||
CModelLibDlgBase::ExpandServerDirTree(bExpand);
|
||
}
|
||
|
||
void CEquLibDlg::sbgl()
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CEquLibDlg dlg;
|
||
dlg.DoModal();
|
||
}
|
||
|
||
void CEquLibDlg::crsb(LPCTSTR pszDir)
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CEquLibDlg dlg(pszDir);
|
||
dlg.m_bInsertMode = true;
|
||
if (dlg.DoModal() != IDOK) return;
|
||
|
||
AecDbEwEquipment *pEqu = dlg.getEquipment(dlg.m_iSelectFileID);
|
||
if (!pEqu)
|
||
{
|
||
AfxMessageBox(_T("生成设备失败!"));
|
||
return;
|
||
}
|
||
helper_insertEqu(pEqu);
|
||
}
|
||
|
||
AecDbEwEquipment * CEquLibDlg::selectCustomValve(LPCTSTR pszValueName
|
||
, double dDN
|
||
, bool &bUseFangle
|
||
, bool &b2DCheck)
|
||
{
|
||
struct resbuf rb;
|
||
acedGetVar(_T("INSUNITS"), &rb);
|
||
double dDn(dDN);
|
||
if (rb.resval.rint == AcDb::kUnitsMeters)
|
||
{
|
||
if (dDn <= 5.0) dDn *= 1000;
|
||
}
|
||
int iDN = (int)(dDn + 0.5);
|
||
CString pszDN = CString(_T("DN")) + TypeConvert::convert<std::wstring, int>(iDN).c_str();
|
||
|
||
return selectEqu(CString(pszValueName) + _T(" ") + pszDN, bUseFangle, b2DCheck);
|
||
|
||
/*CAcModuleResourceOverride myResources;
|
||
CEquLibDlg dlg(pszDN);
|
||
dlg.m_bValueMode = true;
|
||
dlg.m_bCheck2DFlag = bUseFangle;
|
||
dlg.m_bUseFangle = b2DCheck;
|
||
dlg.m_bSearch = TRUE;
|
||
dlg.m_sSearch = CString(pszValueName) + _T(" ") + pszDN;
|
||
if (dlg.DoModal() != IDOK) return NULL;
|
||
bUseFangle = dlg.m_bUseFangle;
|
||
b2DCheck = dlg.m_bCheck2DFlag;
|
||
|
||
AecDbEwEquipment *pEqu = dlg.getEquipment(dlg.m_iSelectFileID);
|
||
|
||
if (!pEqu) return NULL;
|
||
|
||
//设置子类型,后续可增加类型
|
||
extern AecEqui::VlvType g_vlvType[];
|
||
CString sText = pszValueName;
|
||
if (sText.Find(_T("阀")) != -1)
|
||
{
|
||
pEqu->SetAt(KEY_SUBRUNTIME, eValve);
|
||
pEqu->SetAt(KEY_VLV2D, FALSE);
|
||
pEqu->SetAt(_T("_VALVE_TYPE_"), dlg.m_nValveType);
|
||
|
||
pEqu->SetAt(PIPE_FLANGF1, dlg.m_sEndF1);
|
||
pEqu->SetAt(PIPE_FLANGF2, dlg.m_sEndF2);
|
||
pEqu->SetAt(PIPE_GASKET, dlg.m_sGaskets);
|
||
|
||
for (int i = 0; i < 14; i++)
|
||
{
|
||
if (sText.Find(g_vlvType[i].szNameCn) != -1)
|
||
{
|
||
pEqu->SetAt(PIPE_VALVE, (int)g_vlvType[i].eType);
|
||
pEqu->SetAt(KEY_VLV2D, TRUE);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
return pEqu;*/
|
||
}
|
||
|
||
AecDbEwEquipment * CEquLibDlg::selectEqu(LPCTSTR pszSearch
|
||
, bool &bUseFangle
|
||
, bool &b2DCheck)
|
||
{
|
||
if (!pszSearch) return NULL;
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
CEquLibDlg dlg;
|
||
dlg.m_bValveMode = true;
|
||
dlg.m_bCheck2DFlag = bUseFangle;
|
||
dlg.m_bUseFangle = b2DCheck;
|
||
dlg.m_bSearch = TRUE;
|
||
dlg.m_sSearch = pszSearch;
|
||
|
||
if (dlg.DoModal() != IDOK) return NULL;
|
||
bUseFangle = dlg.m_bUseFangle == 0 ? false : true;
|
||
b2DCheck = dlg.m_bCheck2DFlag == 0 ? false : true;
|
||
|
||
AecDbEwEquipment *pEqu = dlg.getEquipment(dlg.m_iSelectFileID);
|
||
|
||
if (!pEqu) return NULL;
|
||
|
||
//设置子类型,后续可增加类型
|
||
extern AecEqui::VlvType g_vlvType[];
|
||
CString sText(pszSearch);
|
||
if (sText.Find(_T("阀")) != -1)
|
||
{
|
||
pEqu->GetSpecialtyData()->SetAt(KEY_SUBRUNTIME, eValve);
|
||
pEqu->GetSpecialtyData()->SetAt(KEY_VLV2D, FALSE);
|
||
pEqu->GetSpecialtyData()->SetAt(_T("_VALVE_TYPE_"), dlg.m_nValveType);
|
||
|
||
pEqu->GetSpecialtyData()->SetAt(PIPE_FLANGF1, dlg.m_sEndF1);
|
||
pEqu->GetSpecialtyData()->SetAt(PIPE_FLANGF2, dlg.m_sEndF2);
|
||
pEqu->GetSpecialtyData()->SetAt(PIPE_GASKET, dlg.m_sGaskets);
|
||
|
||
for (int i = 0; i < 14; i++)
|
||
{
|
||
if (sText.Find(g_vlvType[i].szNameCn) != -1)
|
||
{
|
||
pEqu->GetSpecialtyData()->SetAt(PIPE_VALVE, (int)g_vlvType[i].eType);
|
||
pEqu->GetSpecialtyData()->SetAt(KEY_VLV2D, TRUE);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
return pEqu;
|
||
}
|