2233 lines
114 KiB
C++
2233 lines
114 KiB
C++
#include "stdafx.h"
|
|
#include "initools.h"
|
|
#include "EquipManaDlg.h"
|
|
#include "EquipManaOperator.h"
|
|
#include "AecDbEwEquipment.h"
|
|
#include "KTSetting.h"
|
|
#include "EquInsDirJig.h"
|
|
#include "SearchEquDlg.h"
|
|
#include "parseFamilyForRevit.h"
|
|
#include "KTCadUtility.h"
|
|
#include "KTCadUtilityEx.h"
|
|
#include "AecDbParamEquipment.h"
|
|
#include "AecDbXEquipment.h"
|
|
#include "YMJCDlg.h"
|
|
#include "aecdbweir.h"
|
|
#include "AecDbExtendedEntity.h"
|
|
#include "AecDbRiverGroove.h"
|
|
#include "AecDbTerrain.h"
|
|
#include <string>
|
|
#include "PipelineTools.h"
|
|
#include "coretools.h"
|
|
#include "aecdbxbg.h"
|
|
|
|
IMPLEMENT_DYNAMIC(CEquipManaDlg, CDialog)
|
|
|
|
#define IMG_FOLDER 0
|
|
#define IMG_CLASS 1
|
|
|
|
#ifndef DXF_EQUI
|
|
#define DXF_EQUI _T("AEC_DBWEQUIPMENT,AEC_DBPARAEQUI,AEC_DBXEQUIPMENT")
|
|
#endif
|
|
|
|
#ifndef FAN_FOLDER
|
|
#define FAN_FOLDER _T("风机")
|
|
#endif
|
|
|
|
extern AecEqui::VlvType g_vlvType[];
|
|
|
|
AcGePoint3d MidPoint(const AcGePoint3d& pt1, const AcGePoint3d& pt2)
|
|
{
|
|
return AcGePoint3d((pt1.x + pt2.x) / 2.0,
|
|
(pt1.y + pt2.y) / 2.0,
|
|
(pt1.z + pt2.z) / 2.0);
|
|
}
|
|
namespace
|
|
{
|
|
AcDbEntity* getEntity(CUIISQLiteServer *pDb
|
|
, const CEquipManaDlg::TYPE &type
|
|
, LPCTSTR prefix
|
|
, const CEquipManaDlg::STItem &item)
|
|
{
|
|
if (!pDb) return NULL;
|
|
if (type != CEquipManaDlg::eEntity) return NULL;
|
|
|
|
CString tmpFile(FilePath::getSystemTemporaryFolder() + _T("\\temp_$_$_.equ"));
|
|
if (CString(prefix) == _T("Aec_")) // 设备
|
|
{
|
|
CString sSql(_T(""));
|
|
sSql.Format(_T("select package from %spackage where ID=%s"), prefix, item.ID);
|
|
if (!pDb->GetSelBlob(sSql, tmpFile)) return NULL;
|
|
|
|
AecDbEwEquipment* pEqu = new AecDbEwEquipment;
|
|
if (pEqu->ReadFromFile(tmpFile))
|
|
{
|
|
pEqu->GetSpecialtyData()->SetAt(KEY_ID, item.ID);
|
|
pEqu->GetSpecialtyData()->SetAt(KEY_NAME, item.Name);
|
|
pEqu->GetSpecialtyData()->SetAt(KEY_CLASSID, item.IDClass);
|
|
|
|
pEqu->setLayer(KTSetting::InitLayer(LAY_PIPE_OUTSIDE));
|
|
pEqu->SetDashLayer(KTSetting::InitLayer(LAY_FITN_DASH));
|
|
pEqu->SetCenterLayer(KTSetting::InitLayer(LAY_FITN_CENTER));
|
|
|
|
//关闭箭头,通常入库的设备元件箭头是关闭的
|
|
AecEqui::XPrimData xdata;
|
|
pEqu->ModifyPrimData(0, xdata, 10);
|
|
}
|
|
else
|
|
{
|
|
DELETE_PTR(pEqu);
|
|
}
|
|
::DeleteFile(tmpFile);
|
|
|
|
return pEqu;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void insertEqu(AecDbEwEquipment *pEqu, CUIISQLiteServer *pDb)
|
|
{
|
|
if (!pEqu) return;
|
|
//设置osnap
|
|
AcDbObjectId idPipe;
|
|
double dEl = 0.0;
|
|
|
|
//选择插入点
|
|
ads_point ptRes;
|
|
while (TRUE)
|
|
{
|
|
acedInitGet(RSG_OTHER, _T("E R"));
|
|
int nRes = acedGetPoint(NULL, _T("\n选择插入位置点或[指定标高(E)/参考点(R)]:"), ptRes);
|
|
switch (nRes)
|
|
{
|
|
case RTNORM:
|
|
{
|
|
{
|
|
EQU_INSERT_POS:
|
|
acdbUcs2Wcs(ptRes, ptRes, false);
|
|
ptRes[Z] = dEl;
|
|
AcGeVector3d vtMove = asPnt3d(ptRes).asVector();
|
|
AcGeMatrix3d mat;
|
|
mat.setToTranslation(vtMove);
|
|
pEqu->transformBy(mat);
|
|
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"), &rb);
|
|
if (rb.resval.rint == AcDb::kUnitsMeters) //当前图是米制
|
|
{
|
|
AcGeMatrix3d scale;
|
|
scale.setToScaling(.001);
|
|
pEqu->AddTransform(scale);
|
|
}
|
|
|
|
//选择方向,插入
|
|
CEquInsDirJig jig;
|
|
jig.SetEqu(pEqu, asPnt3d(ptRes));
|
|
if (jig.DoIt())
|
|
{
|
|
AcGeVector3d vtDir = AcGeVector3d::kXAxis;
|
|
vtDir.rotateBy(jig.m_dAngle, AcGeVector3d::kZAxis);
|
|
pEqu->SetInsert(asPnt3d(ptRes), vtDir);
|
|
|
|
AcDbExtents ext;
|
|
pEqu->getGeomExtents(ext);
|
|
AcGePoint3d ptLB = ext.minPoint();
|
|
mat.setToTranslation(asPnt3d(ptRes) - ext.minPoint());
|
|
pEqu->transformBy(mat);
|
|
|
|
AcDbObjectId idLayE, idLayC, idLayD;
|
|
idLayE = KTSetting::InitLayer(LAY_EQU);
|
|
idLayC = KTSetting::InitLayer(LAY_EQU_CENTER);
|
|
idLayD = KTSetting::InitLayer(LAY_EQU_DASH);
|
|
|
|
pEqu->setLayer(idLayE);
|
|
pEqu->SetCenterLayer(idLayC);
|
|
pEqu->SetDashLayer(idLayD);
|
|
|
|
CString sID, sRem;
|
|
if (pDb && pEqu->GetSpecialtyData()->GetAt(KEY_ID, sID))
|
|
{
|
|
std::vector<std::vector<CString>> ar;
|
|
CString sSql(_T(""));
|
|
sSql.Format(_T("SELECT [name],[value] FROM aec_bims WHERE [equid]='%s'"), sID);
|
|
pDb->GetSelDataEx(sSql, ar);
|
|
if (!ar.empty())
|
|
{
|
|
SH_BIM_BLOCK bims;
|
|
for (size_t i = 0; i < ar.size(); ++i)
|
|
{
|
|
std::vector<CString> v(ar[i]);
|
|
if (v.size() < 2) continue;
|
|
bims.push_back(std::make_pair(v[0], v[1]));
|
|
}
|
|
CoreTools::setBimDatas(pEqu, bims);
|
|
}
|
|
}
|
|
//设备内部已经处理了单位
|
|
if (rb.resval.rint == AcDb::kUnitsMeters) //当前图是米制
|
|
{
|
|
pEqu->RemoveLastTransform();
|
|
}
|
|
|
|
CoreTools::AddToModelSpace(pEqu);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
DELETE_PTR(pEqu);
|
|
return;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case RTKWORD:
|
|
{
|
|
TCHAR szKey[3];
|
|
acedGetInput(szKey);
|
|
if (_tcsicmp(_T("E"), szKey) == 0)
|
|
{
|
|
CString sTip;
|
|
sTip.Format(_T("\n请输入标高<%.1f>:"), dEl);
|
|
|
|
nRes = acedGetReal(sTip, &dEl);
|
|
|
|
if (nRes == RTNORM || nRes == RTNONE)
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
else if (_tcsicmp(_T("R"), szKey) == 0)
|
|
{
|
|
//参考点<退出>:
|
|
ads_point ptBase,pt22;
|
|
int nRelt = acedGetPoint(NULL,_T("\n参考点<退出>:"),ptBase);
|
|
if (nRelt == RTNORM)
|
|
{
|
|
//起点<退出>:
|
|
nRelt = acedGetPoint(ptBase,_T("\n指定相对位置为插入点<退出>:"),pt22);
|
|
if (nRelt == RTNORM)
|
|
{
|
|
ads_point_set(pt22,ptRes);
|
|
|
|
goto EQU_INSERT_POS;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
void insertEqu(AecDbEwEquipment *pEqu,AcDbVoidPtrArray& arBaseStruPtrs, CUIISQLiteServer *pDb)
|
|
{
|
|
if (!pEqu) return;
|
|
//设置osnap
|
|
AcDbObjectId idPipe;
|
|
double dEl = 0.0;
|
|
|
|
//选择插入点
|
|
ads_point ptRes;
|
|
while (TRUE)
|
|
{
|
|
acedInitGet(RSG_OTHER, _T("E R"));
|
|
int nRes = acedGetPoint(NULL, _T("\n选择插入位置点或[指定标高(E)/参考点(R)]:"), ptRes);
|
|
switch (nRes)
|
|
{
|
|
case RTNORM:
|
|
{
|
|
{
|
|
EQU_INSERT_POS:
|
|
acdbUcs2Wcs(ptRes, ptRes, false);
|
|
ptRes[Z] = dEl;
|
|
AcGeVector3d vtMove = asPnt3d(ptRes).asVector();
|
|
AcGeMatrix3d mat;
|
|
mat.setToTranslation(vtMove);
|
|
pEqu->transformBy(mat);
|
|
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"), &rb);
|
|
if (rb.resval.rint == AcDb::kUnitsMeters) //当前图是米制
|
|
{
|
|
AcGeMatrix3d scale;
|
|
scale.setToScaling(.001);
|
|
pEqu->AddTransform(scale);
|
|
}
|
|
|
|
//选择方向,插入
|
|
CEquInsDirJig jig;
|
|
jig.SetEqu(pEqu, asPnt3d(ptRes));
|
|
if (jig.DoIt())
|
|
{
|
|
AcGeVector3d vtDir = AcGeVector3d::kXAxis;
|
|
vtDir.rotateBy(jig.m_dAngle, AcGeVector3d::kZAxis);
|
|
pEqu->SetInsert(asPnt3d(ptRes), vtDir);
|
|
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(asPnt3d(ptRes).asVector());
|
|
|
|
double dAngle = AcGeVector3d::kXAxis.angleTo(vtDir,AcGeVector3d::kZAxis);
|
|
AcGeMatrix3d xforR;
|
|
xforR.setToRotation(dAngle,AcGeVector3d::kZAxis);
|
|
|
|
AcDbExtents ext;
|
|
pEqu->getGeomExtents(ext);
|
|
AcGePoint3d ptLB = ext.minPoint();
|
|
mat.setToTranslation(asPnt3d(ptRes) - ext.minPoint());
|
|
pEqu->transformBy(mat);
|
|
|
|
AcDbObjectId idLayE, idLayC, idLayD;
|
|
idLayE = KTSetting::InitLayer(LAY_EQU);
|
|
idLayC = KTSetting::InitLayer(LAY_EQU_CENTER);
|
|
idLayD = KTSetting::InitLayer(LAY_EQU_DASH);
|
|
|
|
pEqu->setLayer(idLayE);
|
|
pEqu->SetCenterLayer(idLayC);
|
|
pEqu->SetDashLayer(idLayD);
|
|
|
|
CString sID, sRem;
|
|
if (pDb && pEqu->GetSpecialtyData()->GetAt(KEY_ID, sID))
|
|
{
|
|
std::vector<std::vector<CString>> ar;
|
|
CString sSql(_T(""));
|
|
sSql.Format(_T("SELECT [name],[value] FROM aec_bims WHERE [equid]='%s'"), sID);
|
|
pDb->GetSelDataEx(sSql, ar);
|
|
if (!ar.empty())
|
|
{
|
|
SH_BIM_BLOCK bims;
|
|
for (size_t i = 0; i < ar.size(); ++i)
|
|
{
|
|
std::vector<CString> v(ar[i]);
|
|
if (v.size() < 2) continue;
|
|
bims.push_back(std::make_pair(v[0], v[1]));
|
|
}
|
|
CoreTools::setBimDatas(pEqu, bims);
|
|
}
|
|
}
|
|
|
|
//设备内部已经处理了单位
|
|
if (rb.resval.rint == AcDb::kUnitsMeters) //当前图是米制
|
|
{
|
|
pEqu->RemoveLastTransform();
|
|
}
|
|
|
|
CoreTools::AddToModelSpace(pEqu,false);
|
|
|
|
AcDbExtents ext2;
|
|
pEqu->getGeomExtents(ext2);
|
|
pEqu->close();
|
|
|
|
AcGePoint3d ptBomMid0 = MidPoint(ext.minPoint(),ext.maxPoint());
|
|
ptBomMid0.z = ext.minPoint().z;
|
|
|
|
AcGePoint3d ptBomMid1 = MidPoint(ext2.minPoint(),ext2.maxPoint());
|
|
ptBomMid1.z = ext2.minPoint().z;
|
|
|
|
xformM.setToTranslation(ptBomMid1 - ptBomMid0);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arBaseStruPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arBaseStruPtrs.at(i);
|
|
pEnt->transformBy(xforR);
|
|
pEnt->transformBy(xformM);
|
|
}
|
|
|
|
for (int i = 0;i < arBaseStruPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arBaseStruPtrs.at(i);
|
|
CoreTools::AddToModelSpace(pEnt);
|
|
}
|
|
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
DELETE_PTR(pEqu);
|
|
return;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case RTKWORD:
|
|
{
|
|
TCHAR szKey[3];
|
|
acedGetInput(szKey);
|
|
if (_tcsicmp(_T("E"), szKey) == 0)
|
|
{
|
|
CString sTip;
|
|
sTip.Format(_T("\n请输入标高<%.1f>:"), dEl);
|
|
|
|
nRes = acedGetReal(sTip, &dEl);
|
|
|
|
if (nRes == RTNORM || nRes == RTNONE)
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
else if (_tcsicmp(_T("R"), szKey) == 0)
|
|
{
|
|
//参考点<退出>:
|
|
ads_point ptBase,pt22;
|
|
int nRelt = acedGetPoint(NULL,_T("\n参考点<退出>:"),ptBase);
|
|
if (nRelt == RTNORM)
|
|
{
|
|
//起点<退出>:
|
|
nRelt = acedGetPoint(ptBase,_T("\n指定相对位置为插入点<退出>:"),pt22);
|
|
if (nRelt == RTNORM)
|
|
{
|
|
ads_point_set(pt22,ptRes);
|
|
|
|
goto EQU_INSERT_POS;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool createDir(LPCTSTR pszFolder)
|
|
{
|
|
if (!pszFolder) return false;
|
|
|
|
if (_taccess(pszFolder, 0x0) == 0x0) return true;
|
|
|
|
if (::CreateDirectory(pszFolder, NULL)) return true;
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
CEquipManaDlg::CEquipManaDlg(const TYPE &type, const USE &use, LPCTSTR prefix, LPCTSTR title, CWnd* pParent /*=NULL*/)
|
|
: CAcUiDialog(CEquipManaDlg::IDD, pParent)
|
|
, m_b2DFlag(FALSE)
|
|
, m_bVolHasFlang(TRUE)
|
|
, m_sPrefix(prefix)
|
|
, m_sFolderShow(_T(""))
|
|
, m_sClassShow(_T(""))
|
|
, m_sOkButton(_T("确定"))
|
|
, m_bCheck2dFlag(FALSE)
|
|
, m_pDb(NULL)
|
|
, m_type(type)
|
|
, m_arItems(0)
|
|
, m_sTitle(title)
|
|
, m_use(use)
|
|
, m_iFmDN(-1)
|
|
, m_bHasBase(FALSE)
|
|
{
|
|
m_pDb = new CUIISQLiteServer;
|
|
m_bFZSB = FALSE;
|
|
m_hItemSel = NULL;
|
|
}
|
|
|
|
CEquipManaDlg::~CEquipManaDlg()
|
|
{
|
|
DELETE_PTR(m_pDb);
|
|
FreeBuffer();
|
|
m_font.DeleteObject();
|
|
}
|
|
|
|
CEquipManaDlg::STItem CEquipManaDlg::GetCurSelItemData()
|
|
{
|
|
int idx = m_wndPreview.GetCurSelIndex();
|
|
if (idx != -1 && idx < m_arItems.size())
|
|
return m_arItems[idx];
|
|
|
|
STItem ite = {_T(""), _T(""), _T("")};
|
|
return ite;
|
|
}
|
|
|
|
void CEquipManaDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_TREEEQUIP, m_wndEquipPrmTree);
|
|
DDX_Control(pDX, IDC_STATICVIEW, m_wndPreview);
|
|
DDX_Control(pDX, IDOK, m_wndBtOk);
|
|
DDX_Check(pDX, IDC_CHECK2DFLAG, m_b2DFlag);
|
|
DDX_Control(pDX, IDC_BTNEWFOLDER, m_wndBtNewFolder);
|
|
DDX_Control(pDX, IDC_BTNEWCLASS, m_wndBtNewClass);
|
|
DDX_Control(pDX, IDC_BTRENAME, m_wndBtRename);
|
|
DDX_Control(pDX, IDC_BTDELITEM, m_wndBtDelItem);
|
|
DDX_Check(pDX, IDC_CHECKVOLFLN, m_bVolHasFlang);
|
|
|
|
DDX_Control(pDX, IDC_BTN_BIM_ADD, m_btnBimAdd);
|
|
DDX_Control(pDX, IDC_BTN_BIM_MODIFY, m_btnBimMod);
|
|
DDX_Control(pDX, IDC_BTN_BIM_DEL, m_btnBimDel);
|
|
DDX_Control(pDX, IDC_BTN_BIM_IMP, m_btnBimImp);
|
|
DDX_Control(pDX, IDC_BTN_BIM_EXP, m_btnBimExp);
|
|
DDX_Control(pDX, IDC_LIST_BIM, m_wndBimLst);
|
|
DDX_Check(pDX, IDC_CHECK1, m_bHasBase);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CEquipManaDlg, CAcUiDialog)
|
|
ON_BN_CLICKED(IDOK, &CEquipManaDlg::OnBnClickedOk)
|
|
ON_NOTIFY(TVN_SELCHANGED, IDC_TREEEQUIP, &CEquipManaDlg::OnTvnSelchangedTreeequip)
|
|
ON_NOTIFY(NM_RCLICK, IDC_TREEEQUIP, &CEquipManaDlg::OnNMRclickTreeequip)
|
|
ON_COMMAND(ID_NEWFOLDER, &CEquipManaDlg::OnNewfolder)
|
|
ON_COMMAND(ID_NEWCLASS, &CEquipManaDlg::OnNewclass)
|
|
ON_COMMAND(ID_RENAME, &CEquipManaDlg::OnRename)
|
|
ON_COMMAND(ID_DELETE, &CEquipManaDlg::OnDelete)
|
|
ON_COMMAND(ID_ADDEQU, &CEquipManaDlg::OnAdd)
|
|
ON_COMMAND(ID_DELEQU, &CEquipManaDlg::OnDel)
|
|
ON_COMMAND(ID_PROPERTY, &CEquipManaDlg::OnProperty)
|
|
ON_BN_CLICKED(IDC_BTADD, &CEquipManaDlg::OnBnClickedBtadd)
|
|
ON_BN_CLICKED(IDC_BTDEL, &CEquipManaDlg::OnBnClickedBtdel)
|
|
ON_BN_CLICKED(IDC_BTOP, &CEquipManaDlg::OnBnClickedBtop)
|
|
ON_BN_CLICKED(IDC_BTNEWFOLDER, &CEquipManaDlg::OnBnClickedBtnewfolder)
|
|
ON_BN_CLICKED(IDC_BTNEWCLASS, &CEquipManaDlg::OnBnClickedBtnewclass)
|
|
ON_BN_CLICKED(IDC_BTRENAME, &CEquipManaDlg::OnBnClickedBtrename)
|
|
ON_BN_CLICKED(IDC_BTDELITEM, &CEquipManaDlg::OnBnClickedBtdelitem)
|
|
ON_BN_CLICKED(IDC_BTMODIREM, &CEquipManaDlg::OnBnClickedBtmodirem)
|
|
ON_BN_CLICKED(IDC_BTN_SEARCH, &CEquipManaDlg::OnBnClickedBtSearch)
|
|
ON_BN_CLICKED(IDC_BTN_BAND2D, &CEquipManaDlg::OnBnClickedBand2d)
|
|
ON_BN_CLICKED(IDC_BTN_BIM_ADD, &CEquipManaDlg::OnBnClickedBimAdd)
|
|
ON_BN_CLICKED(IDC_BTN_BIM_MODIFY, &CEquipManaDlg::OnBnClickedBimMod)
|
|
ON_BN_CLICKED(IDC_BTN_BIM_DEL, &CEquipManaDlg::OnBnClickedBimDel)
|
|
ON_BN_CLICKED(IDC_BTN_BIM_IMP, &CEquipManaDlg::OnBnClickedBimImp)
|
|
ON_BN_CLICKED(IDC_BTN_BIM_EXP, &CEquipManaDlg::OnBnClickedBimExp)
|
|
ON_MESSAGE(WM_CELL_SELECT_CHANGE, &CEquipManaDlg::OnCellSelectChange)
|
|
ON_BN_CLICKED(IDC_CHECK1, &CEquipManaDlg::OnBnClickedCheck1)
|
|
END_MESSAGE_MAP()
|
|
|
|
void CEquipManaDlg::Enable2DFlagCheck(BOOL bCheck2dFlag)
|
|
{
|
|
m_bCheck2dFlag = bCheck2dFlag;
|
|
m_b2DFlag = bCheck2dFlag;
|
|
}
|
|
|
|
BOOL CEquipManaDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
LOGFONT lf;
|
|
::GetObject((HFONT)GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf);
|
|
|
|
// for bim property
|
|
CClientDC dc(this);
|
|
_tcscpy(lf.lfFaceName, _T("Arial Unicode Ms"));
|
|
lf.lfHeight = -MulDiv(13, GetDeviceCaps(dc.m_hDC, LOGPIXELSY), 72);
|
|
m_font.CreateFontIndirect(&lf);
|
|
m_btnBimAdd.SetFont(&m_font);
|
|
m_btnBimMod.SetFont(&m_font);
|
|
m_btnBimDel.SetFont(&m_font);
|
|
m_btnBimImp.SetFont(&m_font);
|
|
m_btnBimExp.SetFont(&m_font);
|
|
m_btnBimAdd.SetWindowText(_T("✙"));
|
|
m_btnBimMod.SetWindowText(_T("✎"));
|
|
m_btnBimDel.SetWindowText(_T("✖"));
|
|
m_btnBimImp.SetWindowText(_T("➘"));
|
|
m_btnBimExp.SetWindowText(_T("➚"));
|
|
|
|
m_wndBimLst.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_SINGLEROW);
|
|
m_wndBimLst.EnableToolTips(TRUE);
|
|
m_wndBimLst.InsertColumn(0, _T("名称"), LVCFMT_LEFT, 100);
|
|
m_wndBimLst.InsertColumn(1, _T("数值"), LVCFMT_LEFT, 100);
|
|
m_wndBimLst.DeleteAllItems();
|
|
|
|
// end
|
|
|
|
if (!m_bCheck2dFlag)
|
|
{
|
|
GetDlgItem(IDC_CHECK2DFLAG)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CHECKVOLFLN)->ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
if (!m_bFZSB)
|
|
{
|
|
GetDlgItem(IDC_CHECK1)->ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
m_wndBtOk.SetWindowText(m_sOkButton);
|
|
|
|
if (m_use == eInsert)
|
|
{
|
|
GetDlgItem(IDC_BTDELITEM)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BTRENAME)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BTNEWCLASS)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BTNEWFOLDER)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BTADD)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BTDEL)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BTMODIREM)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BTOP)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BTN_BAND2D)->ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
if (m_type != eEntity)
|
|
{
|
|
GetDlgItem(IDC_BTMODIREM)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BTOP)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BTN_BAND2D)->ShowWindow(SW_HIDE);
|
|
|
|
m_btnBimAdd.EnableWindow(False);
|
|
m_btnBimMod.EnableWindow(False);
|
|
m_btnBimDel.EnableWindow(False);
|
|
m_wndBimLst.EnableWindow(False);
|
|
|
|
// 减去属性列表部分
|
|
CRect rcWnd;
|
|
GetWindowRect(rcWnd);
|
|
rcWnd.right -= 222;
|
|
MoveWindow(rcWnd);
|
|
}
|
|
|
|
SetWindowText(m_sTitle);
|
|
|
|
CRect rc;
|
|
GetDlgItem(IDC_STATICVIEW)->GetWindowRect(rc);
|
|
GetDlgItem(IDC_STATICVIEW)->ShowWindow(SW_HIDE);
|
|
ScreenToClient(rc);
|
|
|
|
m_wndPreview.Create(rc,this,IDC_STATICVIEW);
|
|
m_wndPreview.Init(3,3,-1,NULL);
|
|
|
|
CBitmap bmp;
|
|
if (!bmp.LoadBitmap (IDB_BITMAPDIR))
|
|
{
|
|
AfxMessageBox(_T ("Can't load bitmap: %x\n"), IDB_BITMAPPRIV);
|
|
ASSERT (FALSE);
|
|
return FALSE;
|
|
}
|
|
|
|
m_bmpCmd[0].LoadBitmap(IDB_BITMAPNEWDIR);
|
|
m_wndBtNewFolder.SetBitmap((HBITMAP)m_bmpCmd[0]);
|
|
|
|
m_bmpCmd[1].LoadBitmap(IDB_BITMAPNEWCLASS);
|
|
m_wndBtNewClass.SetBitmap((HBITMAP)m_bmpCmd[1]);
|
|
|
|
m_bmpCmd[2].LoadBitmap(IDB_BITMAPRENAME);
|
|
m_wndBtRename.SetBitmap((HBITMAP)m_bmpCmd[2]);
|
|
|
|
m_bmpCmd[3].LoadBitmap(IDB_BITMAPDELITEM);
|
|
m_wndBtDelItem.SetBitmap((HBITMAP)m_bmpCmd[3]);
|
|
|
|
BITMAP bmpObj;
|
|
bmp.GetBitmap (&bmpObj);
|
|
|
|
UINT nFlags = ILC_COLOR24 | ILC_MASK;
|
|
|
|
m_Imagelist.Create (16, bmpObj.bmHeight, nFlags, 0, 0);
|
|
m_Imagelist.Add (&bmp, RGB (255, 0, 0));
|
|
m_wndEquipPrmTree.SetImageList(&m_Imagelist,TVSIL_NORMAL);
|
|
|
|
CString dbPath = FilePath::GetSysDir();
|
|
dbPath += _T("\\Aec3DMep.db");
|
|
if (_taccess(dbPath, 0x00) != 0x00)
|
|
{
|
|
AfxMessageBox(_T("系统没有找到Aec3DMep.db文件!请检查软件是否正确安装!"));
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL bSuccess = FALSE;
|
|
if (m_pDb != NULL)
|
|
bSuccess = m_pDb->InitADOServer(dbPath);
|
|
|
|
if (!bSuccess)
|
|
{
|
|
AfxMessageBox(_T("数据库驱动加载数据库Aec3DMep.db失败!"));
|
|
return FALSE;
|
|
}
|
|
|
|
CFont* pFont = m_wndEquipPrmTree.GetFont();
|
|
|
|
memset(&lf,0,sizeof(LOGFONT));
|
|
if (pFont->GetLogFont(&lf))
|
|
{
|
|
m_wndPreview.SetLogFont(&lf);
|
|
}
|
|
|
|
//使用mdb 数据库
|
|
ShowEquipFolder();
|
|
|
|
//定位在第一个
|
|
WPARAM wp = 0;
|
|
LPARAM lp = 0;
|
|
OnCellSelectChange(wp,lp);
|
|
|
|
UpdateData(FALSE);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CEquipManaDlg::SetOkButtonText(LPCTSTR pszText)
|
|
{
|
|
m_sOkButton = pszText;
|
|
}
|
|
|
|
void CEquipManaDlg::ShowEquipFolder()
|
|
{
|
|
CString sSQL,sKey;
|
|
if (m_sFolderShow.IsEmpty())
|
|
{
|
|
//sSQL = _T("select id,folder from aec_folder");
|
|
sSQL.Format(_T("select id,folder from %sfolder"), m_sPrefix);
|
|
}
|
|
else
|
|
{
|
|
//sSQL.Format(_T("select id,folder from aec_folder where folder='%s'"),m_sFolderShow);
|
|
sSQL.Format(_T("select id,folder from %sfolder where folder='%s'"), m_sPrefix, m_sFolderShow);
|
|
}
|
|
|
|
CStringArray arFolders;
|
|
CUIIValueTable table;
|
|
|
|
m_pDb->GetSelData(sSQL,table);
|
|
for (int i = 0;i < table.GetTableLogicSize();i++)
|
|
{
|
|
arFolders.RemoveAll();
|
|
table.GetValueRecord(i,arFolders);
|
|
|
|
if (arFolders.GetSize() >= 2)
|
|
{
|
|
HTREEITEM hItem = m_wndEquipPrmTree.InsertItem(arFolders.GetAt(1),IMG_FOLDER,IMG_FOLDER);
|
|
ShowEquipClass(hItem,arFolders.GetAt(0));
|
|
m_wndEquipPrmTree.Expand(hItem,TVE_EXPAND);
|
|
|
|
sKey.Format(_T("%p"),hItem);
|
|
m_mapItem2FolderID.SetAt(sKey,arFolders.GetAt(0));
|
|
}
|
|
}
|
|
|
|
if (m_hItemSel != NULL)
|
|
{
|
|
m_wndEquipPrmTree.SelectItem(m_hItemSel);
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::ShowEquipClass(HTREEITEM hFolder,LPCTSTR pszFolderID)
|
|
{
|
|
CString sSQL,sKey;
|
|
|
|
if (m_sClassShow.IsEmpty())
|
|
{
|
|
//sSQL.Format(_T("select id,class from aec_class where idfolder='%s'"),pszFolderID);
|
|
sSQL.Format(_T("select id,class from %sclass where idfolder='%s'"), m_sPrefix,pszFolderID);
|
|
}
|
|
else
|
|
{
|
|
//sSQL.Format(_T("select id,class from aec_class where idfolder='%s' and class like '%%%s%%'"),pszFolderID,m_sClassShow);
|
|
sSQL.Format(_T("select id,class from %sclass where idfolder='%s' and class='%s'"), m_sPrefix,pszFolderID,m_sClassShow);
|
|
}
|
|
|
|
CStringArray arClass;
|
|
CUIIValueTable table;
|
|
|
|
m_pDb->GetSelData(sSQL,table);
|
|
|
|
if (table.GetTableLogicSize() == 0)
|
|
{
|
|
if (!m_sClassShow.IsEmpty())
|
|
{
|
|
sSQL.Format(_T("select id,class from %sclass where idfolder='%s' and class like '%s'"), m_sPrefix,pszFolderID,m_sClassShow);
|
|
m_pDb->GetSelData(sSQL,table);
|
|
}
|
|
}
|
|
|
|
for (int i = 0;i < table.GetTableLogicSize();i++)
|
|
{
|
|
arClass.RemoveAll();
|
|
table.GetValueRecord(i,arClass);
|
|
|
|
if (arClass.GetSize() >= 2)
|
|
{
|
|
HTREEITEM hItem = m_wndEquipPrmTree.InsertItem(arClass.GetAt(1),IMG_CLASS,IMG_CLASS,hFolder);
|
|
sKey.Format(_T("%p"),hItem);
|
|
|
|
if (m_hItemSel == NULL)
|
|
{
|
|
m_hItemSel = hItem;
|
|
}
|
|
m_mapItem2FolderID.SetAt(sKey,arClass.GetAt(0));
|
|
}
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::SetFolderShow(LPCTSTR pszFolder)
|
|
{
|
|
m_sFolderShow = pszFolder;
|
|
}
|
|
|
|
void CEquipManaDlg::SetClassShow(LPCTSTR pszClass, double dn)
|
|
{
|
|
m_sClassShow = pszClass;
|
|
double dDn = dn;
|
|
|
|
//如果是米单位,且公称直径小于 5
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"), &rb);
|
|
if (rb.resval.rint == AcDb::kUnitsMeters)
|
|
{
|
|
if (dDn <= 5.0)
|
|
{
|
|
dDn *= 1000;
|
|
}
|
|
}
|
|
m_iFmDN = (int)(dDn + 0.5);
|
|
}
|
|
|
|
//AecDbEwEquipment* CEquipManaDlg::GetSelectEqu()
|
|
//{
|
|
// return m_pEquSel;
|
|
//}
|
|
|
|
int CEquipManaDlg::GetSelectEquDBIdx()
|
|
{
|
|
return _ttoi(GetCurSelItemData().ID);
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedOk()
|
|
{
|
|
UpdateData();
|
|
EndDialog(IDOK);
|
|
}
|
|
|
|
static void AddToModelSpaceEx(AcDbEntity* pEnt,AcDbDatabase* pDb,bool bClose)
|
|
{
|
|
AcDbBlockTable* pTbl = NULL;
|
|
pDb->getBlockTable(pTbl,AcDb::kForRead);
|
|
|
|
if (pTbl != NULL)
|
|
{
|
|
AcDbBlockTableRecord* pRec = NULL;
|
|
pTbl->getAt(ACDB_MODEL_SPACE,pRec,AcDb::kForWrite);
|
|
|
|
if (pRec != NULL)
|
|
{
|
|
pRec->appendAcDbEntity(pEnt);
|
|
if (bClose) pEnt->close();
|
|
pRec->close();
|
|
}
|
|
pTbl->close();
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::OnTvnSelchangedTreeequip(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
|
|
|
|
int nImage = -1,nSelImg = -1;
|
|
m_wndEquipPrmTree.GetItemImage(pNMTreeView->itemNew.hItem,nImage,nSelImg);
|
|
|
|
if (nImage == IMG_CLASS)
|
|
{
|
|
CString sKey,sID;
|
|
sKey.Format(_T("%p"),pNMTreeView->itemNew.hItem);
|
|
if ( m_mapItem2FolderID.Lookup(sKey,sID) )
|
|
{
|
|
ShowClassEquips(sID);
|
|
}
|
|
}
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CEquipManaDlg::ShowClassEquips(CString& sID)
|
|
{
|
|
//解压到本地
|
|
CString sSQL,sClassid;
|
|
|
|
sClassid = sID;
|
|
//sSQL.Format(_T("select id from aec_package where idclass='%s'"),sClassid);
|
|
|
|
if (m_iFmDN >= 0)
|
|
sSQL.Format(_T("select id from %spackage where idclass='%s' and Name like '%%DN%d%%'"), m_sPrefix, sClassid, m_iFmDN);
|
|
else
|
|
sSQL.Format(_T("select id from %spackage where idclass='%s'"), m_sPrefix, sClassid);
|
|
|
|
CStringArray arIDs;
|
|
m_pDb->GetSelData(sSQL,arIDs);
|
|
|
|
m_wndPreview.Clear();
|
|
|
|
FreeBuffer();
|
|
|
|
CString str(_T(""));
|
|
for (int i = 0;i < arIDs.GetSize();i++)
|
|
{
|
|
sID = arIDs.GetAt(i);
|
|
|
|
STItem item;
|
|
item.ID = arIDs.GetAt(i);
|
|
|
|
sSQL.Format(_T("select Name from %spackage where ID=%d"), m_sPrefix, _ttoi(sID));
|
|
if (m_pDb->GetSelData(sSQL, str))
|
|
item.Name = str;
|
|
|
|
sSQL.Format(_T("select IDClass from %spackage where ID=%d"), m_sPrefix, _ttoi(sID));
|
|
if (m_pDb->GetSelData(sSQL, str))
|
|
item.IDClass = str;
|
|
|
|
m_arItems.push_back(item);
|
|
|
|
switch (m_type)
|
|
{
|
|
case CEquipManaDlg::eEntity:
|
|
{
|
|
AcDbEntity *pEnt = ::getEntity(m_pDb, m_type, m_sPrefix, item);
|
|
m_arEqusTmpPtr.append(pEnt);
|
|
//m_wndPreview.Add(pEnt,i,item.Name);
|
|
m_wndPreview.InitSingleCtrlFor3D(pEnt, item.Name);
|
|
}
|
|
break;
|
|
case CEquipManaDlg::eDWGFile:
|
|
{
|
|
str.Format(_T("%s\\tmp_dwg_$$%d.dwg"), FilePath::getSystemTemporaryFolder(), i);
|
|
if (_taccess(str, 0x0) == 0x0)
|
|
{
|
|
if (!::DeleteFile(str)) break;
|
|
}
|
|
|
|
sSQL.Format(_T("select package from %spackage where ID=%d"), m_sPrefix, _ttoi(sID));
|
|
if (!m_pDb->GetSelBlob(sSQL, str)) return;
|
|
m_wndPreview.InitDBCtrlFor2D(str, item.Name);
|
|
}
|
|
break;
|
|
case CEquipManaDlg::eNone:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
m_wndPreview.Redraw();
|
|
}
|
|
|
|
void CEquipManaDlg::FreeBuffer()
|
|
{
|
|
while(m_arEqusTmpPtr.length() > 0)
|
|
{
|
|
AecDbEwEquipment* pEqu = (AecDbEwEquipment*)m_arEqusTmpPtr.first();
|
|
m_arEqusTmpPtr.removeFirst();
|
|
DELETE_PTR(pEqu);
|
|
}
|
|
m_arItems.clear();
|
|
}
|
|
|
|
//目录操作
|
|
void CEquipManaDlg::OnNewfolder()
|
|
{
|
|
CEquipManaOperator equmOper(m_sPrefix);
|
|
equmOper.SetAdoDb(m_pDb);
|
|
equmOper.SetEquipTree(&m_wndEquipPrmTree);
|
|
equmOper.NewFolder(m_mapItem2FolderID);
|
|
}
|
|
|
|
void CEquipManaDlg::OnNewclass()
|
|
{
|
|
//确定当前的选择是目录下
|
|
HTREEITEM hItem = m_wndEquipPrmTree.GetSelectedItem();
|
|
if (hItem != NULL)
|
|
{
|
|
int nImage = 0,nImagSel = 0;
|
|
m_wndEquipPrmTree.GetItemImage(hItem,nImage,nImagSel);
|
|
if (nImage == IMG_FOLDER)
|
|
{
|
|
CEquipManaOperator equmOper(m_sPrefix);
|
|
equmOper.SetAdoDb(m_pDb);
|
|
equmOper.SetEquipTree(&m_wndEquipPrmTree);
|
|
equmOper.OnNewclass(hItem,m_mapItem2FolderID);
|
|
|
|
return;
|
|
}
|
|
}
|
|
AfxMessageBox(_T("请选择目录节点建立分类!"));
|
|
}
|
|
|
|
void CEquipManaDlg::OnRename()
|
|
{
|
|
//确定当前的选择是目录下
|
|
HTREEITEM hItem = m_wndEquipPrmTree.GetSelectedItem();
|
|
if (hItem != NULL)
|
|
{
|
|
int nImage = 0,nImagSel = 0;
|
|
m_wndEquipPrmTree.GetItemImage(hItem,nImage,nImagSel);
|
|
if (nImage == IMG_FOLDER || nImage == IMG_CLASS)
|
|
{
|
|
CEquipManaOperator equmOper(m_sPrefix);
|
|
equmOper.SetAdoDb(m_pDb);
|
|
equmOper.SetEquipTree(&m_wndEquipPrmTree);
|
|
|
|
CString sKey,sID;
|
|
sKey.Format(_T("%p"),hItem);
|
|
m_mapItem2FolderID.Lookup(sKey,sID);
|
|
equmOper.OnRename(hItem,sID);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::OnDelete()
|
|
{
|
|
//确定当前的选择是目录下
|
|
HTREEITEM hItem = m_wndEquipPrmTree.GetSelectedItem();
|
|
if (hItem != NULL)
|
|
{
|
|
int nImage = 0,nImagSel = 0;
|
|
m_wndEquipPrmTree.GetItemImage(hItem,nImage,nImagSel);
|
|
if (nImage == IMG_FOLDER || nImage == IMG_CLASS)
|
|
{
|
|
CEquipManaOperator equmOper(m_sPrefix);
|
|
equmOper.SetAdoDb(m_pDb);
|
|
equmOper.SetEquipTree(&m_wndEquipPrmTree);
|
|
|
|
CString sKey,sID;
|
|
sKey.Format(_T("%p"),hItem);
|
|
m_mapItem2FolderID.Lookup(sKey,sID);
|
|
equmOper.OnDelete(hItem,sID);
|
|
}
|
|
}
|
|
}
|
|
|
|
//设备元件操作
|
|
void CEquipManaDlg::OnAdd()
|
|
{
|
|
HTREEITEM hItem = m_wndEquipPrmTree.GetSelectedItem();
|
|
if (hItem != NULL)
|
|
{
|
|
int nImage = 0,nImagSel = 0;
|
|
m_wndEquipPrmTree.GetItemImage(hItem,nImage,nImagSel);
|
|
|
|
switch (m_type)
|
|
{
|
|
case CEquipManaDlg::eEntity:
|
|
{
|
|
if (nImage == IMG_CLASS)
|
|
{
|
|
CEquipManaOperator equmOper(m_sPrefix);
|
|
equmOper.SetAdoDb(m_pDb);
|
|
equmOper.SetEquipTree(&m_wndEquipPrmTree);
|
|
equmOper.OnAddequ(hItem);
|
|
|
|
CString sKey, sID;
|
|
sKey.Format(_T("%p"), hItem);
|
|
m_mapItem2FolderID.Lookup(sKey, sID);
|
|
|
|
ShowClassEquips(sID);
|
|
}
|
|
}
|
|
break;
|
|
case CEquipManaDlg::eDWGFile:
|
|
{
|
|
HideDialog(true);
|
|
CString sFolder(_T("")), sCLass(_T("")), tmpPath(_T(""));
|
|
sCLass = m_wndEquipPrmTree.GetItemText(hItem);
|
|
|
|
HTREEITEM hFolder = m_wndEquipPrmTree.GetParentItem(hItem);
|
|
sFolder = m_wndEquipPrmTree.GetItemText(hFolder);
|
|
|
|
if (!PipelineTools::makeBlockToDWG(tmpPath))
|
|
{
|
|
HideDialog(false);
|
|
break;
|
|
}
|
|
|
|
CString sName(_T(""));
|
|
if (!CoreTools::getNameByDialog(_T("请输入名称"), _T("名称:"), sName))
|
|
{
|
|
HideDialog(false);
|
|
break;
|
|
}
|
|
|
|
if (sName.IsEmpty())
|
|
{
|
|
AfxMessageBox(_T("名称不能为空!"));
|
|
HideDialog(false);
|
|
break;
|
|
}
|
|
|
|
CEquipManaOperator oper(m_sPrefix);
|
|
oper.SetAdoDb(m_pDb);
|
|
oper.SetEquipTree(&m_wndEquipPrmTree);
|
|
oper.PutPackageToDb(sFolder, sCLass, sName, CString(_T("")), tmpPath);
|
|
|
|
::DeleteFile(tmpPath);
|
|
|
|
CString sKey, sID;
|
|
sKey.Format(_T("%p"), hItem);
|
|
m_mapItem2FolderID.Lookup(sKey, sID);
|
|
HideDialog(false);
|
|
ShowClassEquips(sID);
|
|
}
|
|
break;
|
|
case CEquipManaDlg::eNone:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::OnDel()
|
|
{
|
|
CEquipManaOperator equmOper(m_sPrefix);
|
|
equmOper.SetAdoDb(m_pDb);
|
|
equmOper.SetEquipTree(&m_wndEquipPrmTree);
|
|
STItem ite = GetCurSelItemData();
|
|
equmOper.OnDelequ(ite.ID, ite.Name);
|
|
|
|
//重新刷新
|
|
ShowClassEquips(ite.IDClass);
|
|
}
|
|
|
|
void CEquipManaDlg::OnProperty()
|
|
{
|
|
if (m_type == eEntity && m_sPrefix == _T("Aec_"))
|
|
{
|
|
int nindex = m_wndPreview.GetCurSelIndex();
|
|
if (nindex != -1 && nindex < m_arEqusTmpPtr.length())
|
|
{
|
|
AecDbEwEquipment* pEquSel = (AecDbEwEquipment*)m_arEqusTmpPtr.at(nindex);
|
|
|
|
CAcModuleResourceOverride myResources;
|
|
CEquipManaOperator equmOper(m_sPrefix);
|
|
equmOper.SetAdoDb(m_pDb);
|
|
equmOper.OnProperty(pEquSel);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBtadd()
|
|
{
|
|
OnAdd();
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBtdel()
|
|
{
|
|
OnDel();
|
|
}
|
|
|
|
// 改为复制设备
|
|
void CEquipManaDlg::OnBnClickedBtop()
|
|
{
|
|
if (m_type != eEntity || m_sPrefix != _T("Aec_")) return;
|
|
|
|
|
|
CEquipManaOperator equmOper(m_sPrefix);
|
|
equmOper.SetAdoDb(m_pDb);
|
|
equmOper.SetEquipTree(&m_wndEquipPrmTree);
|
|
STItem ite = GetCurSelItemData();
|
|
|
|
CString sName(ite.Name + _T("_New"));
|
|
CoreTools::getNameByDialog(_T("输入新名称"), _T("名称"), sName);
|
|
|
|
equmOper.OnCloneEqu(ite.ID, sName);
|
|
|
|
//重新刷新
|
|
ShowClassEquips(ite.IDClass);
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBtmodirem()
|
|
{
|
|
if (m_type == eEntity && m_sPrefix == _T("Aec_"))
|
|
{
|
|
int nindex = m_wndPreview.GetCurSelIndex();
|
|
if (nindex != -1 && nindex < m_arEqusTmpPtr.length())
|
|
{
|
|
AecDbEwEquipment* pEquSel = (AecDbEwEquipment*)m_arEqusTmpPtr.at(nindex);
|
|
|
|
CAcModuleResourceOverride myResources;
|
|
CEquipManaOperator equmOper(m_sPrefix);
|
|
equmOper.SetAdoDb(m_pDb);
|
|
equmOper.OnModiRem(pEquSel);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBtSearch()
|
|
{
|
|
CSearchEquDlg dlg;
|
|
if (dlg.DoModal() != IDOK) return;
|
|
CEquipManaDlg::STItem item;
|
|
item.ID = TypeConvert::i2s(dlg.m_iSelEqu);
|
|
item.IDClass = TypeConvert::i2s(dlg.m_iIdClass);
|
|
item.Name = dlg.m_sEquName;
|
|
|
|
OnOK();
|
|
|
|
AecDbEwEquipment *pEnt = (AecDbEwEquipment*)CEquipManaDlg::getEntity(m_pDb, CEquipManaDlg::eEntity, _T("Aec_"), item);
|
|
|
|
insertEqu(pEnt, m_pDb);
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBand2d()
|
|
{
|
|
if (m_type == eEntity && m_sPrefix == _T("Aec_"))
|
|
{
|
|
int nindex = m_wndPreview.GetCurSelIndex();
|
|
if (nindex != -1 && nindex < m_arEqusTmpPtr.length())
|
|
{
|
|
AecDbEwEquipment* pEquSel = (AecDbEwEquipment*)m_arEqusTmpPtr.at(nindex);
|
|
CString sID, sRem;
|
|
if (pEquSel->GetSpecialtyData()->GetAt(KEY_ID, sID))
|
|
{
|
|
PipelineTools::updateEquSection(m_pDb, sID);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBimAdd()
|
|
{
|
|
CString name(_T("名称")), value(_T("数值"));
|
|
if (!CoreTools::getBimDataByDlg(true, name, value)) return;
|
|
|
|
STItem ite = GetCurSelItemData();
|
|
CEquipManaOperator equmOper(m_sPrefix, m_pDb);
|
|
int bimID = equmOper.AddBimForEqu(name, value, ite.ID);
|
|
|
|
if (bimID == -1) return;
|
|
|
|
int idx = m_wndBimLst.InsertItem(m_wndBimLst.GetItemCount(), name);
|
|
m_wndBimLst.SetItemText(idx, 1, value);
|
|
m_wndBimLst.SetItemData(idx, bimID);
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBimMod()
|
|
{
|
|
int idx = m_wndBimLst.GetSelectionMark();
|
|
if (idx == -1) return;
|
|
int bimID = m_wndBimLst.GetItemData(idx);
|
|
if (bimID == -1) return;
|
|
|
|
CString name = m_wndBimLst.GetItemText(idx, 0);
|
|
CString value = m_wndBimLst.GetItemText(idx, 1);
|
|
|
|
if (!CoreTools::getBimDataByDlg(false, name, value)) return;
|
|
|
|
CEquipManaOperator equmOper(m_sPrefix, m_pDb);
|
|
if (equmOper.ModBimForEqu(name, value, bimID))
|
|
{
|
|
m_wndBimLst.SetItemText(idx, 0, name);
|
|
m_wndBimLst.SetItemText(idx, 1, value);
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBimDel()
|
|
{
|
|
int idx = m_wndBimLst.GetSelectionMark();
|
|
if (idx == -1) return;
|
|
int bimID = m_wndBimLst.GetItemData(idx);
|
|
if (bimID == -1) return;
|
|
CEquipManaOperator equmOper(m_sPrefix, m_pDb);
|
|
if (equmOper.DelBimForEqu(bimID))
|
|
{
|
|
m_wndBimLst.DeleteItem(idx);
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBimImp()
|
|
{
|
|
STItem ite = GetCurSelItemData();
|
|
|
|
CFileDialog dlg(TRUE, _T("*.ini"), NULL, OFN_HIDEREADONLY, _T("bim导入数据 (*.ini)|*.ini||"), acedGetAcadFrame());
|
|
if (dlg.DoModal() != IDOK) return;
|
|
|
|
std::map<CString, CString> datas;
|
|
CoreTools::iniFile2BimData(dlg.GetPathName(), datas);
|
|
|
|
m_wndBimLst.DeleteAllItems();
|
|
|
|
int idx(0), bimID(-1);
|
|
CEquipManaOperator oper(m_sPrefix, m_pDb);
|
|
|
|
std::map<CString, CString>::iterator it(datas.begin());
|
|
for (; it != datas.end(); ++it)
|
|
{
|
|
bimID = oper.AddBimForEqu(it->first, it->second, ite.ID);
|
|
if (bimID == -1) continue;
|
|
idx = m_wndBimLst.InsertItem(m_wndBimLst.GetItemCount(), it->first);
|
|
m_wndBimLst.SetItemText(idx, 1, it->second);
|
|
m_wndBimLst.SetItemData(idx, bimID);
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBimExp()
|
|
{
|
|
CFileDialog dlg(FALSE, _T("*.ini"), NULL, OFN_HIDEREADONLY, _T("bim导出数据 (*.ini)|*.ini||"), acedGetAcadFrame());
|
|
if (dlg.DoModal() != IDOK) return;
|
|
|
|
std::map<CString, CString> datas;
|
|
CString name, value;
|
|
for (int i = 0; i < m_wndBimLst.GetItemCount(); ++i)
|
|
{
|
|
name = m_wndBimLst.GetItemText(i, 0);
|
|
value = m_wndBimLst.GetItemText(i, 1);
|
|
datas.insert(std::make_pair(name, value));
|
|
}
|
|
CoreTools::bimData2IniFile(dlg.GetPathName(), datas);
|
|
}
|
|
|
|
LRESULT CEquipManaDlg::OnCellSelectChange(WPARAM wp, LPARAM lp)
|
|
{
|
|
m_wndBimLst.DeleteAllItems();
|
|
LRESULT rel = 0L;
|
|
int idx = m_wndPreview.GetCurSelIndex();
|
|
if (idx == -1 || idx >= m_arEqusTmpPtr.length())
|
|
{
|
|
return rel;
|
|
}
|
|
bool bReadOnly(false);
|
|
std::vector<std::vector<CString>> bims;
|
|
CEquipManaOperator equmOper(m_sPrefix);
|
|
equmOper.SetAdoDb(m_pDb);
|
|
equmOper.SetEquipTree(&m_wndEquipPrmTree);
|
|
STItem ite = GetCurSelItemData();
|
|
equmOper.GetBimDatas(ite.ID, bims, bReadOnly);
|
|
|
|
if (bReadOnly)
|
|
{
|
|
m_btnBimAdd.EnableWindow(False);
|
|
m_btnBimDel.EnableWindow(False);
|
|
m_btnBimMod.EnableWindow(False);
|
|
m_btnBimImp.EnableWindow(False);
|
|
//m_btnBimExp.EnableWindow(False);
|
|
}
|
|
|
|
if (bims.empty()) return rel;
|
|
|
|
std::vector<std::vector<CString>>::const_iterator it(bims.begin());
|
|
for (int i = 0;it != bims.end(); ++it, ++i)
|
|
{
|
|
if (it->size() < 3) continue;
|
|
m_wndBimLst.InsertItem(i, it->at(1));
|
|
m_wndBimLst.SetItemText(i, 1, it->at(2));
|
|
m_wndBimLst.SetItemData(i, _ttoi(it->at(0)));
|
|
if (bReadOnly)
|
|
{
|
|
m_wndBimLst.SetItemColors(i, 0, RGB(0, 0, 0), RGB(240, 240, 240));
|
|
m_wndBimLst.SetItemColors(i, 1, RGB(0, 0, 0), RGB(240, 240, 240));
|
|
}
|
|
}
|
|
return 0L;
|
|
}
|
|
|
|
void CEquipManaDlg::OnNMRclickTreeequip(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
CPoint point,ptcursor;
|
|
::GetCursorPos(&point);
|
|
ptcursor = point;
|
|
m_wndEquipPrmTree.ScreenToClient(&point);
|
|
|
|
UINT uFlags;
|
|
HTREEITEM hItem = m_wndEquipPrmTree.HitTest(point,&uFlags);
|
|
if(hItem != NULL)
|
|
{
|
|
m_wndEquipPrmTree.SelectItem(hItem);
|
|
DoPopularMenu(hItem,ptcursor);
|
|
}
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CEquipManaDlg::DoPopularMenu(HTREEITEM hItem,CPoint point)
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CMenu menu;
|
|
menu.CreatePopupMenu();
|
|
|
|
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED,ID_NEWFOLDER, _T("新建目录(&F)"));
|
|
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED,ID_NEWCLASS, _T("新建分类(&C)"));
|
|
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED,ID_RENAME,_T("重命名(R)"));
|
|
|
|
menu.AppendMenu(MF_SEPARATOR);
|
|
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED,ID_DELETE,_T("删除(&D)"));
|
|
|
|
int nID = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, point.x, point.y,this);
|
|
switch(nID)
|
|
{
|
|
case ID_NEWFOLDER:
|
|
{
|
|
OnNewfolder();
|
|
break;
|
|
}
|
|
case ID_NEWCLASS:
|
|
{
|
|
OnNewclass();
|
|
break;
|
|
}
|
|
case ID_RENAME:
|
|
{
|
|
OnRename();
|
|
break;
|
|
}
|
|
case ID_DELETE:
|
|
{
|
|
OnDelete();
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
bool CEquipManaDlg::GetCurSelFile(LPCTSTR path)
|
|
{
|
|
// 如果文件存在,删除
|
|
if (_taccess(path, 0x0) == 0x0)
|
|
{
|
|
if (!::DeleteFile(path)) return false;
|
|
}
|
|
|
|
int idx = _ttoi(GetCurSelItemData().ID);
|
|
if (idx == -1) return false;
|
|
|
|
CString sSql(_T(""));
|
|
sSql.Format(_T("select package from %spackage where ID=%d"), m_sPrefix, idx);
|
|
|
|
if (!m_pDb->GetSelBlob(sSql, path)) return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
void CEquipManaDlg::HideDialog(bool Flag)
|
|
{
|
|
if (Flag)
|
|
{
|
|
GetParent()->EnableWindow(TRUE);
|
|
GetParent()->SetFocus();
|
|
GetParent()->SetActiveWindow();
|
|
ShowWindow(SW_HIDE);
|
|
}
|
|
else
|
|
{
|
|
GetParent()->EnableWindow(FALSE);
|
|
EnableWindow(TRUE);
|
|
SetActiveWindow();
|
|
ShowWindow(SW_SHOW);
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBtnewfolder()
|
|
{
|
|
OnNewfolder();
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBtnewclass()
|
|
{
|
|
OnNewclass();
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBtrename()
|
|
{
|
|
OnRename();
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedBtdelitem()
|
|
{
|
|
OnDelete();
|
|
}
|
|
|
|
void CEquipManaDlg::SBGL()
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CEquipManaDlg equManaDlg(CEquipManaDlg::eEntity, CEquipManaDlg::eMana, _T("Aec_"), _T("设备库"));
|
|
int nRes = equManaDlg.DoModal();
|
|
}
|
|
|
|
void CEquipManaDlg::CRSB()
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CEquipManaDlg equManaDlg(CEquipManaDlg::eEntity, CEquipManaDlg::eInsert, _T("Aec_"), _T("设备库"));
|
|
equManaDlg.m_bFZSB = TRUE;
|
|
if (equManaDlg.DoModal() != IDOK) return;
|
|
|
|
CUIISQLiteServer db;
|
|
CString dbPath = FilePath::GetSysDir();
|
|
dbPath += _T("\\Aec3DMep.db");
|
|
if (_taccess(dbPath, 0x00) != 0x00)
|
|
{
|
|
AfxMessageBox(_T("系统没有找到Aec3DMep.db文件!请检查软件是否正确安装!"));
|
|
return;
|
|
}
|
|
if (db.InitADOServer(dbPath))
|
|
{
|
|
AecDbEwEquipment* pEqu = (AecDbEwEquipment*)CEquipManaDlg::getEntity(&equManaDlg);
|
|
//CoreTools::AddToModelSpace(pEqu);
|
|
//insertEqu(pEqu, &db);
|
|
|
|
AcDbVoidPtrArray arBaseStruPtrs;
|
|
equManaDlg.GetBaseStruPart(arBaseStruPtrs);
|
|
|
|
insertEqu(pEqu,arBaseStruPtrs,&db);
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::GDFJ()
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CEquipManaDlg equManaDlg(CEquipManaDlg::eEntity, CEquipManaDlg::eInsert, _T("Aec_"), _T("设备库"));
|
|
equManaDlg.SetFolderShow(FAN_FOLDER);
|
|
|
|
int nRes = equManaDlg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
AecDbEwEquipment* pEqu = (AecDbEwEquipment*)CEquipManaDlg::getEntity(&equManaDlg);
|
|
if (pEqu != NULL)
|
|
{
|
|
CUIISQLiteServer db;
|
|
CString dbPath = FilePath::GetSysDir();
|
|
dbPath += _T("\\Aec3DMep.db");
|
|
if (_taccess(dbPath, 0x00) != 0x00)
|
|
{
|
|
AfxMessageBox(_T("系统没有找到Aec3DMep.db文件!请检查软件是否正确安装!"));
|
|
return;
|
|
}
|
|
if (db.InitADOServer(dbPath))
|
|
{
|
|
AecDbEwEquipment* pEqu = (AecDbEwEquipment*)CEquipManaDlg::getEntity(&equManaDlg);
|
|
|
|
AcDbVoidPtrArray arBaseStruPtrs;
|
|
equManaDlg.GetBaseStruPart(arBaseStruPtrs);
|
|
|
|
insertEqu(pEqu,arBaseStruPtrs,&db);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::SBJC()
|
|
{
|
|
ads_name ent1;
|
|
struct resbuf* pRb = acutBuildList(RTDXF0, DXF_EQUI, 0);
|
|
|
|
int nRes = CKTCadUtility::SelectEntity(_T("\n选择要加基础的设备:"), ent1, pRb);
|
|
acutRelRb(pRb);
|
|
if (nRes == RTNORM)
|
|
{
|
|
AcDbObjectId idEqu;
|
|
acdbGetObjectId(idEqu, ent1);
|
|
|
|
//选择要对齐的接口
|
|
AecInterface infRef;
|
|
AcDbObjectId id1;
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, idEqu, AcDb::kForRead))
|
|
{
|
|
double dL = 0.0,dW = 0.0;
|
|
AcDbExtents ext;
|
|
AcGePoint3d ptIns;
|
|
AcGeVector3d vtDir;
|
|
|
|
AecDbEwEquipment* pEquSel = AecDbEwEquipment::cast(pEnt);
|
|
if (pEquSel != NULL)
|
|
{
|
|
pEquSel->getGeomExtents(ext);
|
|
|
|
dL = ext.maxPoint().x - ext.minPoint().x;
|
|
dL += 60;
|
|
|
|
dW = ext.maxPoint().y - ext.minPoint().y;
|
|
dW += 60;
|
|
pEquSel->GetInsert(ptIns,vtDir);
|
|
}
|
|
|
|
AecDbParamEquipment* pPEquSel = AecDbParamEquipment::cast(pEnt);
|
|
if (pPEquSel != NULL)
|
|
{
|
|
pPEquSel->getGeomExtents(ext);
|
|
|
|
dL = ext.maxPoint().x - ext.minPoint().x;
|
|
dL += 60;
|
|
|
|
dW = ext.maxPoint().y - ext.minPoint().y;
|
|
dW += 60;
|
|
pPEquSel->GetInsert(ptIns,vtDir);
|
|
}
|
|
|
|
AecDbXEquipment* pXEqu = AecDbXEquipment::cast(pEnt);
|
|
if (pXEqu != NULL)
|
|
{
|
|
pXEqu->getGeomExtents(ext);
|
|
|
|
dL = ext.maxPoint().x - ext.minPoint().x;
|
|
dL += 60;
|
|
|
|
dW = ext.maxPoint().y - ext.minPoint().y;
|
|
dW += 60;
|
|
pXEqu->GetInsert(ptIns,vtDir);
|
|
}
|
|
|
|
CAcModuleResourceOverride myResources;
|
|
CYMJCDlg dlg;
|
|
dlg.m_dL = (int)(dL + 0.5);
|
|
dlg.m_dW = (int)(dW + 0.5);
|
|
dlg.m_dGL = (int)(dL + 0.5);
|
|
dlg.m_dGW = (int)(dW + 0.5);
|
|
dlg.m_dBomEl = ext.minPoint().z;
|
|
double dThick = _ttof(dlg.m_sMSize);
|
|
dlg.m_dXP = (dlg.m_dL - ((dThick * 2 + 5) + dlg.m_dSideSp * 2)) / (dlg.m_nCol - 1);
|
|
dlg.m_dYP = (dlg.m_dW - ((dThick * 2 + 5) + dlg.m_dSideSp * 2)) / (dlg.m_nRow - 1);
|
|
double dr = min(dlg.m_dL * .5 - (dThick * 2 + 5), dlg.m_dW * .5 - (dThick * 2 + 5));
|
|
dlg.m_dMR = dr;
|
|
|
|
if ( IDOK == dlg.DoModal() )
|
|
{
|
|
AcGePoint3d ptBomMid = MidPoint(ext.minPoint(), ext.maxPoint());
|
|
ptBomMid.z = dlg.m_dBomEl;
|
|
|
|
double dAngle = AcGeVector3d::kXAxis.angleTo(vtDir, AcGeVector3d::kZAxis);
|
|
AcGeMatrix3d xforR;
|
|
xforR.setToRotation(dAngle, AcGeVector3d::kZAxis, ptBomMid);
|
|
|
|
AecDbEwEquipment* pEqu = (AecDbEwEquipment*)dlg.GetBaseStruPart(ptBomMid);
|
|
if (pEqu)
|
|
{
|
|
pEqu->transformBy(xforR);
|
|
pEqu->GetSpecialtyData()->SetAt(KEY_DRAW2D, _T("AecDbEquBaseDraw2d"));
|
|
CoreTools::AddToModelSpace(pEqu);
|
|
}
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
}
|
|
|
|
void CEquipManaDlg::PLDR()
|
|
{
|
|
// 选择文件夹
|
|
CString strFolderPath(_T(""));
|
|
{
|
|
BROWSEINFO bInfo;
|
|
::ZeroMemory(&bInfo, sizeof(BROWSEINFO));
|
|
bInfo.pidlRoot = NULL;
|
|
bInfo.lpszTitle = _T("选择设备文件所在的总目录");
|
|
bInfo.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
|
|
bInfo.lpfn = NULL;
|
|
LPITEMIDLIST pidl = SHBrowseForFolder(&bInfo);
|
|
if (pidl == NULL) return;
|
|
SHGetPathFromIDList(pidl, strFolderPath.GetBuffer(MAX_PATH));
|
|
::CoTaskMemFree(pidl);
|
|
strFolderPath.ReleaseBuffer();
|
|
}
|
|
// end
|
|
|
|
// 选择BIM文件
|
|
CString strBimFile(_T(""));
|
|
{
|
|
CString szFilter = _T("ini文件 (*.ini)|*.ini||");
|
|
CFileDialog fileDlg(TRUE, _T("ini"), NULL, OFN_HIDEREADONLY, szFilter, acedGetAcadFrame());
|
|
if (fileDlg.DoModal() == IDOK)
|
|
{
|
|
strBimFile = fileDlg.GetPathName();
|
|
}
|
|
}
|
|
// end
|
|
|
|
// init database
|
|
CUIISQLiteServer db;
|
|
{
|
|
CString dbPath = FilePath::GetSysDir();
|
|
dbPath += _T("\\Aec3DMep.db");
|
|
if (_taccess(dbPath, 0x00) != 0x00)
|
|
{
|
|
AfxMessageBox(_T("系统没有找到Aec3DMep.db文件!请检查软件是否正确安装!"));
|
|
return;
|
|
}
|
|
|
|
if (!db.InitADOServer(dbPath))
|
|
{
|
|
AfxMessageBox(_T("Aec3DMep.db打开失败。"));
|
|
return;
|
|
}
|
|
}
|
|
// end
|
|
|
|
// 遍历文件夹
|
|
typedef std::map<CString, std::vector<CString>> SS;
|
|
SS folder2Class;
|
|
SS class2File;
|
|
{
|
|
std::vector<CString> folders, classes, files;
|
|
CoreTools::getSubFolderByPath(strFolderPath, folders, false);
|
|
|
|
for (size_t f = 0; f < folders.size(); ++f)
|
|
{
|
|
classes.clear();
|
|
CString &sFolder(folders[f]);
|
|
CoreTools::getSubFolderByPath(sFolder, classes, false);
|
|
|
|
for (size_t c = 0; c < classes.size(); ++c)
|
|
{
|
|
files.clear();
|
|
CString &sClass(classes[c]);
|
|
CoreTools::getFilesInFolder(sClass, _T("*.equ"), files, false, false);
|
|
CoreTools::getFilesInFolder(sClass, _T("*.json"), files, false, false);
|
|
class2File.insert(
|
|
std::make_pair(sClass.Right(sClass.GetLength() - sClass.ReverseFind(_T('\\')) - 1)
|
|
, files));
|
|
}
|
|
|
|
classes.clear();
|
|
CoreTools::getSubFolderByPath(sFolder, classes, true);
|
|
folder2Class.insert(
|
|
std::make_pair(
|
|
sFolder.Right(sFolder.GetLength() - sFolder.ReverseFind(_T('\\')) - 1)
|
|
, classes));
|
|
}
|
|
}
|
|
// end
|
|
|
|
// 操作数据库
|
|
{
|
|
CEquipManaOperator oper(_T("Aec_"), &db);
|
|
|
|
db.BeginTrans();
|
|
SS::const_iterator it(folder2Class.begin());
|
|
CString sExt(_T("")), sName(_T(""));
|
|
SH_BIM_BLOCK bims;
|
|
AcCmColor clr;
|
|
#if ARX < 24
|
|
clr.setColorMethod(AcCmEntityColor::kByLayer);
|
|
#endif
|
|
for (; it != folder2Class.end(); ++it)
|
|
{
|
|
const CString &folder(it->first);
|
|
|
|
const std::vector<CString> &classes(it->second);
|
|
for (size_t c = 0; c < classes.size(); ++c)
|
|
{
|
|
const CString &sClass(classes[c]);
|
|
|
|
SS::const_iterator itFiles = class2File.find(sClass);
|
|
if (itFiles == class2File.end()) continue;
|
|
|
|
const std::vector<CString> &files(itFiles->second);
|
|
for (size_t f = 0; f < files.size(); ++f)
|
|
{
|
|
const CString &file(files[f]);
|
|
sExt = file.Right(file.GetLength() - file.ReverseFind(_T('.')));
|
|
sName = file.Right(file.GetLength() - file.ReverseFind(_T('\\')) - 1);
|
|
sName = sName.Left(sName.ReverseFind(_T('.')));
|
|
if (sExt.CompareNoCase(_T(".equ")) == 0)
|
|
{
|
|
bims.clear();
|
|
IniTools::getSectionContent(strBimFile, sName, bims);
|
|
oper.PutPackageToDb(CString(folder)
|
|
, CString(sClass)
|
|
, CString(sName)
|
|
, CString(_T(""))
|
|
, CString(file)
|
|
, NULL
|
|
, &bims);
|
|
}
|
|
if (sExt.CompareNoCase(_T(".json")) == 0)
|
|
{
|
|
bims.clear();
|
|
|
|
std::wstring json;
|
|
ParseRevitFamily::parseFile2String(file, json);
|
|
if (json.empty()) continue;
|
|
ParseRevitFamily::parseBimDatas(json, bims);
|
|
|
|
AecDbEwEquipment* pWEquip = new AecDbEwEquipment;
|
|
AecDbObjXDataMap* pXDataMap = pWEquip->GetSpecialtyData();
|
|
pXDataMap->SetAt(KEY_NAME, sName);
|
|
pXDataMap->SetAt(KEY_FITSRV, KEY_FITWPIPE);
|
|
pXDataMap->SetAt(KEY_RUNTIME, eEquipment);
|
|
|
|
AecEqui::XPrimData data;
|
|
data.m_nSize = sizeof(wchar_t) * (json.size() + 1);
|
|
data.m_eType = AecEqui::kSubDMesh;
|
|
data.m_pData = new byte[data.m_nSize];
|
|
::memset(data.m_pData, 0, data.m_nSize);
|
|
::memcpy(data.m_pData, json.c_str(), data.m_nSize);
|
|
pWEquip->AddSubPrimObj(&data);
|
|
data.releaseData();
|
|
CString sTemp = FilePath::getSystemTemporaryFolder() + _T("\\$$^^newEqu&&$$.equ");
|
|
if (_taccess(sTemp, 0x0) == 0x0)
|
|
::DeleteFile(sTemp);
|
|
if (!pWEquip->WriteToFile(sTemp)) continue;
|
|
|
|
oper.PutPackageToDb(CString(folder)
|
|
, CString(sClass)
|
|
, CString(sName)
|
|
, CString(_T(""))
|
|
, CString(sTemp)
|
|
, NULL
|
|
, &bims);
|
|
|
|
DELETE_PTR(pWEquip);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
db.CommitTrans();
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
void CEquipManaDlg::SCGL()
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CEquipManaDlg equManaDlg(CEquipManaDlg::eDWGFile, CEquipManaDlg::eMana, _T("DWG_"), _T("水池库"));
|
|
if (equManaDlg.DoModal() != IDOK) return;
|
|
|
|
CEquipManaDlg::STItem item = equManaDlg.GetCurSelItemData();
|
|
|
|
CString blkName(_T(""));
|
|
blkName.Format(_T("%s-%s-%s"), item.ID, item.Name, item.IDClass);
|
|
|
|
CString path = FilePath::getSystemTemporaryFolder() + _T("\\_tmp_dwg_$_$.dwg");
|
|
|
|
if (!equManaDlg.GetCurSelFile(path)) return;
|
|
|
|
AcGePoint3d ptIns(AcGePoint3d::kOrigin);
|
|
AcDbObjectId blkId(AcDbObjectId::kNull);
|
|
if (!PipelineTools::generateBlockRecord(path, blkName, blkId, ptIns)) return;
|
|
|
|
ads_point adsPt;
|
|
if (acedGetPoint(NULL, _T("\n选择插入点:"), adsPt) != RTNORM) return;
|
|
|
|
acdbUcs2Wcs(adsPt, adsPt, false);
|
|
|
|
AcDbBlockReference * pBlock = new AcDbBlockReference();
|
|
pBlock->setBlockTableRecord(blkId);
|
|
pBlock->setNormal(AcGeVector3d::kZAxis);
|
|
pBlock->setPosition(asPnt3d(adsPt));
|
|
|
|
CoreTools::AddToModelSpace(pBlock);
|
|
}
|
|
|
|
void CEquipManaDlg::XGBG()
|
|
{
|
|
ads_name ent1;
|
|
struct resbuf* pRb = acutBuildList(RTDXF0, _T("AEC_DBXBG,AEC_DBTERRAIN,AEC_RIVERGROOVE,AEC_DBWEIR,AEC_DBEXTENDENT,AEC_DBWEQUIPMENT,AEC_DBPARAEQUI,AEC_DBXEQUIPMENT"), 0);
|
|
|
|
int nRes = CKTCadUtility::SelectEntity(_T("\n选择要修改标高的设备:"), ent1, pRb);
|
|
acutRelRb(pRb);
|
|
if (nRes != RTNORM) return;
|
|
|
|
AcDbObjectId idEqu;
|
|
acdbGetObjectId(idEqu, ent1);
|
|
|
|
OPENOBJ_BEGIN(idEqu, AcDb::kForRead, AcDbEntity, pEnt)
|
|
{
|
|
if (!pEnt) return;
|
|
double dElev(.0);
|
|
AcGePoint3d pt(AcGePoint3d::kOrigin);
|
|
AcGeVector3d dir(AcGeVector3d::kIdentity);
|
|
AecDbEwEquipment *pEqu1 = AecDbEwEquipment::cast(pEnt);
|
|
AecDbParamEquipment *pEqu2 = AecDbParamEquipment::cast(pEnt);
|
|
AecDbXEquipment *pXEqu = AecDbXEquipment::cast(pEnt);
|
|
AecDbWeir *pWeir = AecDbWeir::cast(pEnt);
|
|
AecDbExtendedEntity *pExt = AecDbExtendedEntity::cast(pEnt);
|
|
AecDbRiverGroove *pRiverG = AecDbRiverGroove::cast(pEnt);
|
|
AecDbXBG *pXBG = AecDbXBG::cast(pEnt);
|
|
|
|
if (pXBG)
|
|
{
|
|
dElev = pXBG->getElevation();
|
|
}
|
|
|
|
if (pEqu1)
|
|
{
|
|
pEqu1->GetInsert(pt, dir);
|
|
dElev = pt.z;
|
|
}
|
|
|
|
if (pEqu2)
|
|
dElev = pEqu2->GetElev();
|
|
|
|
if (pXEqu)
|
|
dElev = pXEqu->GetElev();
|
|
|
|
if (pWeir)
|
|
{
|
|
AcDbCurve *pCurve = pWeir->GetBaseCurve();
|
|
AcDbPolyline *pPoly = AcDbPolyline::cast(pCurve);
|
|
if (!pCurve)
|
|
acutPrintf(_T("\n获取标高失败!"));
|
|
dElev = pPoly->elevation();
|
|
DELETE_PTR(pCurve);
|
|
}
|
|
|
|
if (pRiverG)
|
|
{
|
|
AcDbCurve *pCurve = pRiverG->GetBaseCurve();
|
|
AcGePoint3d pt(AcGePoint3d::kOrigin);
|
|
if (pCurve->getStartPoint(pt) != Acad::eOk)
|
|
acutPrintf(_T("\n获取标高失败!"));
|
|
dElev = pt.z;
|
|
DELETE_PTR(pCurve);
|
|
}
|
|
|
|
if (pExt)
|
|
{
|
|
AcDbCurve *pCurve = pExt->GetBaseCurve();
|
|
AcDbPolyline *pPoly = AcDbPolyline::cast(pCurve);
|
|
if (!pCurve)
|
|
acutPrintf(_T("\n获取标高失败!"));
|
|
dElev = pPoly->elevation();
|
|
DELETE_PTR(pCurve);
|
|
}
|
|
|
|
|
|
// 设备和参数设备,可以选择参照点修改标高
|
|
AcGePoint3d ptRef(AcGePoint3d::kOrigin), ptEquIns(AcGePoint3d::kOrigin);
|
|
double dOldElev(.0);
|
|
if (pEqu1 || pXEqu)
|
|
{
|
|
AcGeVector3d vtDir;
|
|
if (pEqu1)
|
|
pEqu1->GetInsert(ptEquIns, vtDir);
|
|
if (pXEqu)
|
|
pXEqu->GetInsert(ptEquIns, vtDir);
|
|
ads_point adsPt;
|
|
ptRef = ptEquIns;
|
|
if (acedGetPoint(NULL, _T("\n选择一个参照点,并且修改这个点当前的标高<默认是设备插入点>:"), adsPt) == RTNORM)
|
|
{
|
|
ptRef = asPnt3d(adsPt);
|
|
CoreTools::UCS2WCS(ptRef, ptRef);
|
|
}
|
|
|
|
dElev = ptRef.z;
|
|
}
|
|
|
|
CString s(_T(""));
|
|
s.Format(_T("\n请输入新标高(mm)<%.2f>"), dElev);
|
|
if (acedGetReal(s, &dElev) != RTNORM) return;
|
|
|
|
if (pEqu1 || pXEqu)
|
|
{
|
|
ptEquIns.z += dElev - ptRef.z;
|
|
dElev = ptEquIns.z;
|
|
}
|
|
|
|
pEnt->upgradeOpen();
|
|
|
|
if (pXBG)
|
|
{
|
|
pXBG->setElevation(dElev);
|
|
}
|
|
|
|
if (pEqu1)
|
|
{
|
|
pt.z = dElev;
|
|
pEqu1->SetInsert(pt);
|
|
}
|
|
|
|
if (pEqu2)
|
|
pEqu2->SetElev(dElev);
|
|
|
|
if (pXEqu)
|
|
pXEqu->SetElev(dElev);
|
|
|
|
if (pWeir)
|
|
{
|
|
AcDbCurve *pCurve = pWeir->GetBaseCurve();
|
|
AcDbPolyline *pPoly = AcDbPolyline::cast(pCurve);
|
|
if (!pCurve)
|
|
acutPrintf(_T("\n获取标高失败!"));
|
|
pPoly->setElevation(dElev);
|
|
pWeir->SetBaseCurve(pPoly);
|
|
DELETE_PTR(pCurve);
|
|
}
|
|
|
|
if (pRiverG)
|
|
{
|
|
AcDbCurve *pCurve = pRiverG->GetBaseCurve();
|
|
AcGePoint3d ptS(AcGePoint3d::kOrigin), ptE(AcGePoint3d::kOrigin);
|
|
if (pCurve->getStartPoint(ptS) != Acad::eOk)
|
|
acutPrintf(_T("\n获取起点失败!"));
|
|
if (pCurve->getEndPoint(ptE) != Acad::eOk)
|
|
acutPrintf(_T("\n获取终点失败!"));
|
|
ptS.z = ptE.z = dElev;
|
|
pRiverG->SetBaseCurve(ptS, ptE);
|
|
}
|
|
|
|
if (pExt)
|
|
{
|
|
AcDbCurve *pCurve = pExt->GetBaseCurve();
|
|
AcDbPolyline *pPoly = AcDbPolyline::cast(pCurve);
|
|
if (!pCurve)
|
|
acutPrintf(_T("\n获取标高失败!"));
|
|
pPoly->setElevation(dElev);
|
|
pExt->SetBaseCurve(pPoly);
|
|
DELETE_PTR(pCurve);
|
|
}
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
|
|
void CEquipManaDlg::XGYS()
|
|
{
|
|
ads_name ent1;
|
|
struct resbuf* pRb = acutBuildList(RTDXF0, _T("AEC_DBWEQUIPMENT,AEC_DBPARAEQUI,AEC_DBXEQUIPMENT"), 0);
|
|
|
|
int nRes = CKTCadUtility::SelectEntity(_T("\n选择要修改颜色的设备:"), ent1, pRb);
|
|
acutRelRb(pRb);
|
|
if (nRes != RTNORM) return;
|
|
|
|
AcDbObjectId idEqu;
|
|
acdbGetObjectId(idEqu, ent1);
|
|
|
|
OPENOBJ_BEGIN(idEqu, AcDb::kForWrite, AcDbEntity, pEnt)
|
|
{
|
|
if (!pEnt) return;
|
|
AecDbEwEquipment *pEqu1 = AecDbEwEquipment::cast(pEnt);
|
|
AecDbParamEquipment *pEqu2 = AecDbParamEquipment::cast(pEnt);
|
|
AecDbXEquipment* pXEqu = AecDbXEquipment::cast(pEnt);
|
|
|
|
int iclr(256);
|
|
|
|
if (pEqu1)
|
|
pEqu1->GetSpecialtyData(AcDb::kForWrite)->GetAt(_T("COLOR"), iclr);
|
|
|
|
if (pEqu2)
|
|
pEqu2->GetSpecialtyData(AcDb::kForWrite)->GetAt(_T("COLOR"), iclr);
|
|
|
|
if (pXEqu)
|
|
pXEqu->GetSpecialtyData(AcDb::kForWrite)->GetAt(_T("COLOR"), iclr);
|
|
|
|
|
|
AcCmColor clr;
|
|
#if ARX < 24
|
|
clr.setColorMethod(AcCmEntityColor::kByACI);
|
|
#endif
|
|
clr.setColorIndex(iclr);
|
|
if (!acedSetColorDialogTrueColor(clr, Adesk::kFalse, clr, AcCm::kACITab)) return;
|
|
|
|
if (pEqu1)
|
|
pEqu1->GetSpecialtyData(AcDb::kForWrite)->SetAt(_T("COLOR"), clr.colorIndex());
|
|
if (pEqu2)
|
|
pEqu2->GetSpecialtyData(AcDb::kForWrite)->SetAt(_T("COLOR"), clr.colorIndex());
|
|
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
|
|
AcDbEntity * CEquipManaDlg::getEntity(CEquipManaDlg *pDlg)
|
|
{
|
|
CUIISQLiteServer *pDb(pDlg->getDbPtr());
|
|
TYPE type(pDlg->getType());
|
|
CString prefix(pDlg->getTblPrefix());
|
|
int idx(_ttoi(pDlg->GetCurSelItemData().ID));
|
|
|
|
if (!pDb) return NULL;
|
|
if (type != eEntity) return NULL;
|
|
|
|
AcDbEntity *pEnt = CEquipManaDlg::getEntity(pDb, type, prefix, pDlg->GetCurSelItemData());
|
|
return pEnt;
|
|
}
|
|
|
|
AcDbEntity * CEquipManaDlg::getEntity(CUIISQLiteServer *pDb, CEquipManaDlg::TYPE type, LPCTSTR prefix, CEquipManaDlg::STItem item)
|
|
{
|
|
if (!pDb) return NULL;
|
|
|
|
AcDbEntity *pEnt = ::getEntity(pDb, type, prefix, item);
|
|
if (!pEnt) return pEnt;
|
|
|
|
if (CString(prefix) == _T("Aec_")) // 设备
|
|
{
|
|
AecDbEwEquipment *pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (!pEqu) return pEqu;
|
|
|
|
//设置子类型,后续可增加类型
|
|
CString sText = item.Name;
|
|
if (sText.Find(_T("阀")) != -1)
|
|
{
|
|
pEqu->GetSpecialtyData()->SetAt(KEY_SUBRUNTIME, eValve);
|
|
pEqu->GetSpecialtyData()->SetAt(KEY_VLV2D, FALSE);
|
|
|
|
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;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void CEquipManaDlg::OnBnClickedCheck1()
|
|
{
|
|
UpdateData();
|
|
|
|
if (m_bHasBase)
|
|
{
|
|
CYMJCDlg dlg;
|
|
if ( IDOK == dlg.DoModal() )
|
|
{
|
|
int nindex = m_wndPreview.GetCurSelIndex();
|
|
if (nindex != -1 && nindex < m_arEqusTmpPtr.length())
|
|
{
|
|
double dL = 0.0, dW = 0.0;
|
|
AcDbExtents ext;
|
|
AcGePoint3d ptIns;
|
|
AcGeVector3d vtDir;
|
|
|
|
AecDbEwEquipment* pEquSel = (AecDbEwEquipment*)m_arEqusTmpPtr.at(nindex);
|
|
if (pEquSel != NULL)
|
|
{
|
|
pEquSel->getGeomExtents(ext);
|
|
|
|
dL = ext.maxPoint().x - ext.minPoint().x;
|
|
dL += 60;
|
|
|
|
dW = ext.maxPoint().y - ext.minPoint().y;
|
|
dW += 60;
|
|
pEquSel->GetInsert(ptIns, vtDir);
|
|
}
|
|
|
|
dlg.m_dL = (int)(dL + 0.5);
|
|
dlg.m_dW = (int)(dW + 0.5);
|
|
dlg.m_dGL = (int)(dL + 0.5);
|
|
dlg.m_dGW = (int)(dW + 0.5);
|
|
dlg.m_dBomEl = ext.minPoint().z;
|
|
double dThick = _ttof(dlg.m_sMSize);
|
|
dlg.m_dXP = (dlg.m_dL - ((dThick * 2 + 5) + dlg.m_dSideSp * 2)) / (dlg.m_nCol - 1);
|
|
dlg.m_dYP = (dlg.m_dW - ((dThick * 2 + 5) + dlg.m_dSideSp * 2)) / (dlg.m_nRow - 1);
|
|
|
|
AcGePoint3d ptBomMid = MidPoint(ext.minPoint(),ext.maxPoint());
|
|
ptBomMid.z = ext.minPoint().z;
|
|
|
|
double dAngle = AcGeVector3d::kXAxis.angleTo(vtDir, AcGeVector3d::kZAxis);
|
|
AcGeMatrix3d xforR;
|
|
xforR.setToRotation(dAngle, AcGeVector3d::kZAxis, ptBomMid);
|
|
|
|
AcDbVoidPtrArray arBaseStruParts;
|
|
AecDbEwEquipment * pEqu = dlg.GetBaseStruPart(ptBomMid);
|
|
if (pEqu)
|
|
{
|
|
pEqu->transformBy(xforR);
|
|
pEqu->GetSpecialtyData()->SetAt(KEY_DRAW2D, _T("AecDbEquBaseDraw2d"));
|
|
CoreTools::AddToModelSpace(pEqu);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool CEquipManaDlg::GetBaseStruPart(AcDbVoidPtrArray& arBaseStruParts)
|
|
{
|
|
if (!m_arBaseStruParts.isEmpty())
|
|
{
|
|
arBaseStruParts.append(m_arBaseStruParts);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void CEquipManaDlg::exportEquToDisk()
|
|
{
|
|
// 在 root 目录下新建 equipment
|
|
CString sDir = FilePath::GetRootDir() + _T("\\equipment");
|
|
if (!createDir(sDir)) return;
|
|
|
|
// 取目录
|
|
CString sSQL(_T("select id,folder from aec_folder"));
|
|
std::map<CString, CString> folders, classes;
|
|
std::map<CString, CString>::const_iterator itF, itC;
|
|
m_pDb->GetSelData(sSQL, folders);
|
|
if (folders.empty()) return;
|
|
|
|
// 新建文件夹
|
|
CStringArray arIDs;
|
|
std::vector<CString> ss;
|
|
std::vector<std::vector<CString>> bims;
|
|
static int _idx(0);
|
|
for (itF = folders.begin(); itF != folders.end(); ++itF)
|
|
{
|
|
if (!::createDir(sDir + _T("\\") + itF->second)) continue;
|
|
// 取类型
|
|
sSQL.Format(_T("select id,class from aec_class where idfolder='%s'"), itF->first);
|
|
classes.clear();
|
|
if (!m_pDb->GetSelData(sSQL, classes)) continue;
|
|
for (itC = classes.begin(); itC != classes.end(); ++itC)
|
|
{
|
|
if (!createDir(sDir + _T("\\") + itF->second + _T("\\") + itC->second)) continue;
|
|
arIDs.RemoveAll();
|
|
sSQL.Format(_T("select id from aec_package where idclass='%s'"), itC->first);
|
|
m_pDb->GetSelData(sSQL, arIDs);
|
|
for (int i = 0; i < arIDs.GetCount(); ++i)
|
|
{
|
|
_idx = 0;
|
|
ss.clear();
|
|
sSQL.Format(_T("select id,name,idclass,rem from aec_package where ID=%s"), arIDs[i]);
|
|
if (!m_pDb->GetSelData(sSQL, ss)) continue;
|
|
if (ss.size() < 4) continue;
|
|
|
|
CString tmpFile(FilePath::getSystemTemporaryFolder() + _T("\\temp_$_$_.equ"));
|
|
sSQL.Format(_T("select package from aec_package where ID=%s"), arIDs[i]);
|
|
if (!m_pDb->GetSelBlob(sSQL, tmpFile)) continue;
|
|
|
|
AecDbEwEquipment* pEqu = new AecDbEwEquipment;
|
|
|
|
if (!pEqu->ReadFromFile(tmpFile))
|
|
{
|
|
DELETE_PTR(pEqu);
|
|
::DeleteFile(tmpFile);
|
|
continue;
|
|
}
|
|
::DeleteFile(tmpFile);
|
|
|
|
pEqu->GetSpecialtyData()->SetAt(KEY_ID, ss[0]);
|
|
pEqu->GetSpecialtyData()->SetAt(KEY_NAME, ss[1]);
|
|
pEqu->GetSpecialtyData()->SetAt(KEY_CLASSID, ss[2]);
|
|
pEqu->GetSpecialtyData()->SetAt(_T("_KEY_REM_"), ss[3]);
|
|
|
|
pEqu->setLayer(KTSetting::InitLayer(LAY_PIPE_OUTSIDE));
|
|
pEqu->SetDashLayer(KTSetting::InitLayer(LAY_FITN_DASH));
|
|
pEqu->SetCenterLayer(KTSetting::InitLayer(LAY_FITN_CENTER));
|
|
|
|
//关闭箭头,通常入库的设备元件箭头是关闭的
|
|
AecEqui::XPrimData xdata;
|
|
pEqu->ModifyPrimData(0, xdata, 10);
|
|
|
|
// BIM数据
|
|
sSQL.Format(_T("select name,value from aec_bims where equid=%s"), arIDs[i]);
|
|
if (m_pDb->GetSelDataEx(sSQL, bims))
|
|
{
|
|
SH_BIM_BLOCK dm;
|
|
for (size_t b = 0; b < bims.size(); ++b)
|
|
{
|
|
std::vector<CString> &s(bims[b]);
|
|
if (s.size() >= 2)
|
|
dm.push_back(std::make_pair(s[0], s[1]));
|
|
}
|
|
CoreTools::setBimDatas(pEqu, dm);
|
|
}
|
|
|
|
// 保存
|
|
CString sPath = sDir
|
|
+ _T("\\")
|
|
+ itF->second
|
|
+ _T("\\")
|
|
+ itC->second
|
|
+ _T("\\")
|
|
+ ss[1];
|
|
while (_taccess(sPath + _T(".equ"), 0x0) == 0x0)
|
|
{ // 同名,改名
|
|
sPath += TypeConvert::convert<std::wstring, int>(++_idx).c_str();
|
|
}
|
|
|
|
_idx = 0;
|
|
|
|
CoreTools::equipment2File(pEqu, sPath + _T(".equ"), ss[1]);
|
|
|
|
DELETE_PTR(pEqu);
|
|
}
|
|
}
|
|
}
|
|
}
|