1224 lines
28 KiB
C++
1224 lines
28 KiB
C++
// EquipmentOpeningDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "EquipmentOpeningDlg.h"
|
|
#include <bitset>
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
CString CEquipmentOpeningDlg::m_strLength = _T("700"); //设备箱长度
|
|
CString CEquipmentOpeningDlg::m_strWidth = _T("200"); //设备箱宽度
|
|
CString CEquipmentOpeningDlg::m_strHeight = _T("1000"); //设备箱高度
|
|
CString CEquipmentOpeningDlg::m_strLayerName = _T("0");//图层
|
|
CString CEquipmentOpeningDlg::m_strDistance = _T("0"); //垛宽距离
|
|
CString CEquipmentOpeningDlg::m_strDeep = _T("0"); //嵌入深度
|
|
CString CEquipmentOpeningDlg::m_strDistToFloor = _T("85"); //距地面高度
|
|
BOOL CEquipmentOpeningDlg::m_bBreakWall = TRUE; //打断墙体
|
|
int CEquipmentOpeningDlg::m_nInsertType = 0; //插入方式,默认自由插入
|
|
CString CEquipmentOpeningDlg::m_csEquipStyle = _T("设备平面(00000002)");
|
|
|
|
extern BOOL InvokeTkwMan(const TCHAR *pszLib, BOOL bSelOnly, XString &sBlockName);
|
|
|
|
IMPLEMENT_DYNAMIC(CEquipmentOpeningDlg, CModelessDialog)
|
|
CEquipmentOpeningDlg::CEquipmentOpeningDlg(CWnd* pParent /*=NULL*/)
|
|
: CModelessDialog(CEquipmentOpeningDlg::IDD, pParent)
|
|
{
|
|
m_bIsEdit = FALSE;
|
|
m_bIsDeep = FALSE;
|
|
}
|
|
|
|
CEquipmentOpeningDlg::~CEquipmentOpeningDlg()
|
|
{
|
|
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::SetIsEditDlg(BOOL bIs)
|
|
{
|
|
m_bIsEdit = bIs;
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
|
|
DDX_CBString(pDX, IDC_CMB_EQUIPMENTLEN, m_strLength);
|
|
DDX_CBString(pDX, IDC_CMB_EQUIPMENTWIDTH, m_strWidth);
|
|
DDX_CBString(pDX, IDC_CMB_EQUIPMENTHEIGHT, m_strHeight);
|
|
|
|
DDX_CBString(pDX, IDC_CMB_EQUIPMENTDISTANCE, m_strDistance);
|
|
DDX_CBString(pDX, IDC_CMB_DEEPVALUE, m_strDeep);
|
|
DDX_CBString(pDX, IDC_CMB_HEIHGTTOFLOOR, m_strDistToFloor);
|
|
DDX_CBString(pDX, IDC_CMB_EQUIPMENTLAYERS, m_strLayerName);
|
|
|
|
DDX_Check(pDX, IDC_CHK_BREAKWALL, m_bBreakWall);
|
|
|
|
DDX_Control(pDX, IDC_STATIC_EQUIPSTYLE, m_pic2d);
|
|
DDX_Control(pDX, IDC_CMB_EQUIPMENTLAYERS, m_cmbLayer);
|
|
|
|
DDX_Check(pDX, IDC_CHK_INOUTTURN, m_bInOutTurn);
|
|
DDX_Check(pDX, IDC_CHK_LEFTRTURN, m_bLeftRTurn);
|
|
}
|
|
|
|
BOOL CEquipmentOpeningDlg::OnInitDialog()
|
|
{
|
|
CModelessDialog::OnInitDialog();
|
|
|
|
if (!m_bIsEdit)
|
|
{
|
|
GetDlgItem(IDC_EQUIPOK)->ShowWindow(FALSE);
|
|
GetDlgItem(IDC_EQUIPCANCEL)->ShowWindow(FALSE);
|
|
GetDlgItem(IDC_CHK_LEFTRTURN)->ShowWindow(FALSE);
|
|
GetDlgItem(IDC_CHK_INOUTTURN)->ShowWindow(FALSE);
|
|
createToolBar();
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_CMB_EQUIPMENTLAYERS)->ShowWindow(FALSE);
|
|
GetDlgItem(IDC_CMB_EQUIPMENTDISTANCE)->ShowWindow(FALSE);
|
|
GetDlgItem(IDC_STATIC_LAYERNAME)->ShowWindow(FALSE);
|
|
GetDlgItem(IDC_STATIC_DISTANCE)->ShowWindow(FALSE);
|
|
//add by lgy 20120605 是否置灰嵌入深度
|
|
if (m_bIsDeep)
|
|
{
|
|
GetDlgItem(IDC_STATIC_DEEP)->EnableWindow(TRUE);
|
|
GetDlgItem(IDC_CMB_DEEPVALUE)->EnableWindow(TRUE);
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_STATIC_DEEP)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_CMB_DEEPVALUE)->EnableWindow(FALSE);
|
|
}
|
|
|
|
}
|
|
AddTip(IDC_CHK_BREAKWALL, _T("暗装、半暗装设备箱通过此项控制其是否打断墙线"));
|
|
if (m_nInsertType != 2) //如果不是定居插入,则垛宽距离应置灰色
|
|
{
|
|
GetDlgItem(IDC_CMB_EQUIPMENTDISTANCE)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_STATIC_DISTANCE)->EnableWindow(FALSE);
|
|
}
|
|
|
|
XSymbolList lstLayer(_T("LAYER"));
|
|
for (int i = 0; i < lstLayer.Length(); i++)//初始化图层组合框
|
|
{
|
|
CString strLayer = lstLayer[i];
|
|
m_cmbLayer.AddString(strLayer);
|
|
}
|
|
|
|
//add by lgy 20120522 设置工具条按钮状态
|
|
CheckTypeButton();
|
|
//add by lgy 20120522 显示幻灯片
|
|
XString sBlockName = m_csEquipStyle;
|
|
ShowSlide(m_pic2d, m_PicSlide1, sBlockName);
|
|
|
|
//add by lgy 20120528 初始化幻灯片id
|
|
XString sBlockEquipment(_T("%s%s"), g_sDwbPath, (const TCHAR *)m_csEquipStyle);
|
|
XString szBlockDoor;
|
|
BOOL bLoadEquip = (LoadDwbBlock(sBlockEquipment, szBlockDoor)==RTNORM);
|
|
m_idSlide = InitBlock(szBlockDoor);
|
|
|
|
UpdateData(TRUE);
|
|
return TRUE;
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CEquipmentOpeningDlg, CModelessDialog)
|
|
|
|
ON_WM_PAINT()
|
|
ON_WM_SETCURSOR()
|
|
ON_CBN_KILLFOCUS(IDC_CMB_EQUIPMENTLEN, OnCbnKillCmbLen)
|
|
ON_CBN_KILLFOCUS(IDC_CMB_EQUIPMENTWIDTH, OnCbnKillCmbWidth)
|
|
ON_CBN_KILLFOCUS(IDC_CMB_EQUIPMENTHEIGHT, OnCbnKillCmbHeight)
|
|
ON_CBN_KILLFOCUS(IDC_CMB_EQUIPMENTDISTANCE, OnCbnKillCmbDistance)
|
|
ON_CBN_KILLFOCUS(IDC_CMB_DEEPVALUE, OnCbnKillCmbDeepvalue)
|
|
ON_CBN_KILLFOCUS(IDC_CMB_HEIHGTTOFLOOR, OnCbnKillCmbToFloor)
|
|
|
|
ON_BN_CLICKED(ID_FREEADD, OnClkFreeAdd)
|
|
ON_BN_CLICKED(ID_WALLSIDEADD, OnClkWallSideAdd)
|
|
ON_BN_CLICKED(ID_DISTANCEADD, OnClkDistanceAdd)
|
|
|
|
ON_STN_CLICKED(IDC_STATIC_EQUIPSTYLE, OnClkEquimentStyle)
|
|
|
|
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
|
|
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
|
|
|
|
ON_WM_DESTROY()
|
|
ON_BN_CLICKED(IDC_EQUIPOK, OnBnClickedEquipok)
|
|
ON_BN_CLICKED(IDC_EQUIPCANCEL, OnBnClickedEquipcancel)
|
|
END_MESSAGE_MAP()
|
|
|
|
void CEquipmentOpeningDlg::createToolBar()
|
|
{
|
|
UINT buttonID[]={ID_FREEADD, ID_WALLSIDEADD, ID_DISTANCEADD};
|
|
CAcModuleResourceOverride vTmp;
|
|
m_toolbar.Create( WS_VISIBLE | WS_CHILD | CCS_BOTTOM | TBSTYLE_TOOLTIPS
|
|
| CCS_ADJUSTABLE ,CRect(0,0,0,0),this, IDR_EQUIPMENTOPEN);
|
|
TBBUTTON *pIndex, *pRTF_Button = new TBBUTTON[3];
|
|
|
|
pIndex = pRTF_Button;
|
|
for(long lIndex = 0; lIndex < 3; lIndex++) //创建3个按钮控件
|
|
{
|
|
memset(pIndex ,NULL, sizeof(TBBUTTON));
|
|
pIndex->iBitmap = lIndex;
|
|
pIndex->idCommand = buttonID[lIndex];
|
|
pIndex->fsStyle = TBSTYLE_CHECKGROUP;
|
|
pIndex->fsState = TBSTATE_ENABLED;
|
|
pIndex++;
|
|
}
|
|
CSize size(16, 15);
|
|
m_toolbar.SetButtonSize(size);
|
|
m_toolbar.AddButtons(3, pRTF_Button);
|
|
|
|
//LH 2012.9.3 修改该指针不能删除因为它与pRTF_Button指向同一地址
|
|
//delete pIndex;
|
|
delete[] pRTF_Button;
|
|
|
|
m_toolbar.SetBitmapSize(size);
|
|
m_toolbar.ModifyStyle(0,TBSTYLE_FLAT);
|
|
m_toolbar.AddBitmap(3, IDR_EQUIPMENTOPEN);
|
|
|
|
}
|
|
|
|
BOOL CEquipmentOpeningDlg::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW);
|
|
if (GetRoutingFrame() != NULL) return FALSE;
|
|
|
|
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
|
|
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
|
|
|
|
CString strTipText;
|
|
UINT nID = (UINT)pNMHDR->idFrom;
|
|
|
|
if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
|
|
pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
if (nID != 0)
|
|
{
|
|
{
|
|
CAcModuleResourceOverride vTmp;
|
|
strTipText.LoadString(nID);
|
|
}
|
|
|
|
#ifndef _UNICODE
|
|
if (pNMHDR->code == TTN_NEEDTEXTA) {
|
|
lstrcpyn(pTTTA->szText, strTipText, sizeof(pTTTA->szText));
|
|
} else {
|
|
_mbstowcsz(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
|
|
}
|
|
#else
|
|
if (pNMHDR->code == TTN_NEEDTEXTA) {
|
|
_wcstombsz(pTTTA->szText, strTipText,sizeof(pTTTA->szText));
|
|
} else {
|
|
lstrcpyn(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
|
|
}
|
|
#endif
|
|
|
|
*pResult = 0;
|
|
|
|
::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0,SWP_NOACTIVATE|
|
|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); return TRUE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CEquipmentOpeningDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
|
|
{
|
|
if (pWnd && pWnd->m_hWnd==m_pic2d.m_hWnd)
|
|
{
|
|
CAcModuleResourceOverride vTemp;
|
|
HCURSOR hIcon = AfxGetApp()->LoadCursor( IDC_CUR_PICK );
|
|
SetCursor(hIcon);
|
|
return TRUE;
|
|
}
|
|
return CModelessDialog::OnSetCursor(pWnd, nHitTest, message);
|
|
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnPaint()
|
|
{
|
|
CDC* pDC;
|
|
CRect cR1;
|
|
CPaintDC dc(this);
|
|
|
|
pDC = m_pic2d.GetDC();
|
|
m_pic2d.GetClientRect(&cR1);
|
|
m_PicSlide1.InitDC(pDC,cR1,GetAcadBackColor());
|
|
m_PicSlide1.Redraw();
|
|
m_pic2d.ReleaseDC(pDC);
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnClkEquimentStyle()
|
|
{
|
|
XPushAutoHide noAutoHide(this);
|
|
|
|
XString sLibFile, sBlockName;//DorLib2D
|
|
sLibFile << g_sDwbPath << _T("设备平面.TKW");
|
|
sBlockName = m_csEquipStyle;
|
|
if (InvokeTkwMan(sLibFile, TRUE, sBlockName));
|
|
{
|
|
ShowSlide(m_pic2d, m_PicSlide1, sBlockName);
|
|
m_csEquipStyle = XPathParser(sBlockName).m_sFileName;
|
|
}
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::CheckTypeButton()
|
|
{
|
|
m_toolbar.CheckButton(ID_FREEADD, m_nInsertType == 0);
|
|
m_toolbar.CheckButton(ID_WALLSIDEADD, m_nInsertType == 1);
|
|
m_toolbar.CheckButton(ID_DISTANCEADD, m_nInsertType == 2);
|
|
}
|
|
|
|
//add by lgy 20120522 判断当前字符串中是否有字符
|
|
//返回TRUE说明该字符串中含有字母
|
|
BOOL StrHasChar(CString str)
|
|
{
|
|
for (int i = 0; i < str.GetLength(); i++)
|
|
{
|
|
char c = str.GetAt(i);
|
|
if (i == 0) //第一个字母
|
|
{
|
|
if ((c >= '0'&&c <= '9') || c == '-')
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
return TRUE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ((c >= '0' && c<= '9') || c == '.')
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnCbnKillCmbLen()
|
|
{
|
|
CString strValue = m_strLength;
|
|
UpdateData(TRUE);
|
|
|
|
if (StrHasChar(m_strLength) || m_strLength.GetLength() == 0)
|
|
{
|
|
AfxMessageBox(_T("请输入数值!"));
|
|
m_strLength = strValue;
|
|
}
|
|
else
|
|
{
|
|
if (_tstof(m_strLength) <= 0)
|
|
{
|
|
AfxMessageBox(_T("请输入大于0的数!"));
|
|
m_strLength = strValue;
|
|
}
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnCbnKillCmbWidth()
|
|
{
|
|
CString strValue = m_strWidth;
|
|
UpdateData(TRUE);
|
|
|
|
if (StrHasChar(m_strWidth) || m_strWidth.GetLength() == 0)
|
|
{
|
|
AfxMessageBox(_T("请输入数值!"));
|
|
m_strWidth = strValue;
|
|
}
|
|
else
|
|
{
|
|
if (_tstof(m_strWidth) <= 0)
|
|
{
|
|
AfxMessageBox(_T("请输入大于0的数!"));
|
|
m_strWidth = strValue;
|
|
}
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnCbnKillCmbHeight()
|
|
{
|
|
CString strValue = m_strHeight;
|
|
UpdateData(TRUE);
|
|
|
|
if (StrHasChar(m_strHeight) || m_strHeight.GetLength() == 0)
|
|
{
|
|
AfxMessageBox(_T("请输入数值!"));
|
|
m_strHeight = strValue;
|
|
}
|
|
else
|
|
{
|
|
if (_tstof(m_strHeight) <= 0)
|
|
{
|
|
AfxMessageBox(_T("请输入大于0的数!"));
|
|
m_strHeight = strValue;
|
|
}
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnDestroy()
|
|
{
|
|
UpdateData(TRUE);
|
|
CModelessDialog::OnDestroy();
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnCbnKillCmbDistance()
|
|
{
|
|
CString strValue = m_strDistance;
|
|
UpdateData(TRUE);
|
|
|
|
if (StrHasChar(m_strDistance) || m_strDistance.GetLength() == 0)
|
|
{
|
|
AfxMessageBox(_T("请输入数值!"));
|
|
m_strDistance = strValue;
|
|
}
|
|
else
|
|
{
|
|
if (_tstof(m_strDistance) <0)
|
|
{
|
|
AfxMessageBox(_T("请输入大于等于0的数!"));
|
|
m_strDistance = strValue;
|
|
}
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnCbnKillCmbDeepvalue()
|
|
{
|
|
CString strTemp = m_strDeep;
|
|
UpdateData(TRUE);
|
|
|
|
if (StrHasChar(m_strDeep) || m_strDeep.GetLength() == 0)
|
|
{
|
|
AfxMessageBox(_T("请输入数值!"));
|
|
m_strDeep = strTemp;
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnClkFreeAdd()
|
|
{
|
|
GetDlgItem(IDC_CMB_EQUIPMENTDISTANCE)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_STATIC_DISTANCE)->EnableWindow(FALSE);
|
|
m_nInsertType = 0;
|
|
|
|
//add by lgy 20120522 设置工具条按钮状态
|
|
CheckTypeButton();
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnClkWallSideAdd()
|
|
{
|
|
GetDlgItem(IDC_CMB_EQUIPMENTDISTANCE)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_STATIC_DISTANCE)->EnableWindow(FALSE);
|
|
m_nInsertType = 1;
|
|
|
|
//add by lgy 20120522 设置工具条按钮状态
|
|
CheckTypeButton();
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnClkDistanceAdd()
|
|
{
|
|
GetDlgItem(IDC_CMB_EQUIPMENTDISTANCE)->EnableWindow(TRUE);
|
|
GetDlgItem(IDC_STATIC_DISTANCE)->EnableWindow(TRUE);
|
|
m_nInsertType = 2;
|
|
|
|
//add by lgy 20120522 设置工具条按钮状态
|
|
CheckTypeButton();
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnCbnKillCmbToFloor()
|
|
{
|
|
CString strValue = m_strDistToFloor;//先保存未更新的值,如果输入的值不符合条件,方便恢复
|
|
UpdateData(TRUE);
|
|
|
|
if (StrHasChar(m_strDistToFloor) || m_strDistToFloor.GetLength() == 0)
|
|
{
|
|
AfxMessageBox(_T("请输入数值!"));
|
|
m_strDistToFloor = strValue;
|
|
}
|
|
else
|
|
{
|
|
if (_tstof(m_strDistToFloor) <= 0)
|
|
{
|
|
AfxMessageBox(_T("请输入大于0的数!"));
|
|
m_strDistToFloor = strValue;
|
|
}
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
double CEquipmentOpeningDlg::GetEquipLength()
|
|
{
|
|
UpdateData(TRUE);
|
|
return _tstof(m_strLength);
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::SetEquipLength(double dLength)
|
|
{
|
|
CString strTemp;
|
|
strTemp.Format(_T("%.2f"), dLength);
|
|
m_strLength = strTemp;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
double CEquipmentOpeningDlg::GetEquipWidth()
|
|
{
|
|
UpdateData(TRUE);
|
|
return _tstof(m_strWidth);
|
|
}
|
|
void CEquipmentOpeningDlg::SetEquipWidth(double dWidth)
|
|
{
|
|
CString strTemp;
|
|
strTemp.Format(_T("%.2f"), dWidth);
|
|
m_strWidth = strTemp;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
double CEquipmentOpeningDlg::GetEquipHeight()
|
|
{
|
|
UpdateData(TRUE);
|
|
return _tstof(m_strHeight);
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::SetEquipHeight(double dHeight)
|
|
{
|
|
CString strTemp;
|
|
strTemp.Format(_T("%.2f"), dHeight);
|
|
m_strHeight = strTemp;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
bool CEquipmentOpeningDlg::GetEquipLayerName(CString &strLayer)
|
|
{
|
|
UpdateData(TRUE);
|
|
strLayer = m_strLayerName;
|
|
if (m_cmbLayer.FindString(-1, strLayer) == -1)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
double CEquipmentOpeningDlg::GetEquipDistance()
|
|
{
|
|
UpdateData(TRUE);
|
|
return _tstof(m_strDistance);
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::SetEquipDistance(double dDistance)
|
|
{
|
|
CString strTemp;
|
|
strTemp.Format(_T("%.2f"), dDistance);
|
|
m_strDistance = strTemp;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
double CEquipmentOpeningDlg::GetEquipDeep()
|
|
{
|
|
UpdateData(TRUE);
|
|
return _tstof(m_strDeep);
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::SetEquipDeep(double dDeep)
|
|
{
|
|
CString strTemp;
|
|
strTemp.Format(_T("%.2f"), dDeep);
|
|
m_strDeep = strTemp;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
double CEquipmentOpeningDlg::GetDistToFloor()
|
|
{
|
|
UpdateData(TRUE);
|
|
return _tstof(m_strDistToFloor);
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::SetDistToFloor(double dDist)
|
|
{
|
|
CString strTemp;
|
|
strTemp.Format(_T("%.2f"), dDist);
|
|
m_strDistToFloor = strTemp;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
int CEquipmentOpeningDlg::GetInsertType()
|
|
{
|
|
return m_nInsertType;
|
|
}
|
|
|
|
BOOL CEquipmentOpeningDlg::GetIsBreakWall()
|
|
{
|
|
UpdateData(TRUE);
|
|
return m_bBreakWall;
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::SetBreakWall(BOOL bIs)
|
|
{
|
|
m_bBreakWall = bIs;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
BOOL CEquipmentOpeningDlg::GetIsLeftRTurn()
|
|
{
|
|
UpdateData(TRUE);
|
|
return m_bLeftRTurn;
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::SetLeftRTurn(BOOL bLeft)
|
|
{
|
|
m_bLeftRTurn = bLeft;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
BOOL CEquipmentOpeningDlg::GetIsInOutTurn()
|
|
{
|
|
UpdateData(TRUE);
|
|
return m_bInOutTurn;
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::SetInOutTurn(BOOL bIn)
|
|
{
|
|
m_bInOutTurn = bIn;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::SetEquipStyle(CString strStyle)
|
|
{
|
|
m_csEquipStyle = strStyle;
|
|
}
|
|
|
|
CString CEquipmentOpeningDlg::GetEquipStyle()
|
|
{
|
|
return m_csEquipStyle;
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::ShowSlide(CStatic& st, CImageDC& imgdc, const TCHAR* sldName)
|
|
{
|
|
XString sFullSld(256);
|
|
if (sldName && sldName[0])
|
|
{
|
|
sFullSld << g_sDwbPath << sldName;
|
|
}
|
|
|
|
CRect cR;
|
|
CDC* pDC = st.GetDC();
|
|
st.GetClientRect(&cR);
|
|
|
|
imgdc.InitDC(pDC,cR, GetAcadBackColor());
|
|
imgdc.PaintSlide(sFullSld);
|
|
|
|
st.ReleaseDC(pDC);
|
|
}
|
|
|
|
AcDbObjectId CEquipmentOpeningDlg::GetSlideId()
|
|
{
|
|
XString sBlockEquipment(_T("%s%s"), g_sDwbPath, (const TCHAR *)m_csEquipStyle);
|
|
XString szBlockDoor;
|
|
if (LoadDwbBlock(sBlockEquipment, szBlockDoor)!=RTNORM)
|
|
{
|
|
return 0;
|
|
}
|
|
m_idSlide = InitBlock(szBlockDoor);
|
|
return m_idSlide;
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::Obj2Dlg(TDbEquipmentBox *pBox)
|
|
{
|
|
m_strWidth.Format(_T("%.1f"), pBox->GetBreadth());
|
|
m_strLength.Format(_T("%.1f"), pBox->GetWidth());
|
|
m_strHeight.Format(_T("%.1f"), pBox->GetHeight());
|
|
|
|
m_bBreakWall = pBox->GetBreakWall();
|
|
m_strDistToFloor.Format(_T("%.1f"), pBox->m_ptLocation.z);
|
|
|
|
|
|
//设置门窗样式幻灯片
|
|
XString sDwb2D, sDwg2D;
|
|
if (pBox->GetStyle2dName(sDwb2D, sDwg2D)==Acad::eOk)
|
|
{
|
|
m_csEquipStyle = XString(_T("%s(%s)"), (TCHAR *)sDwb2D, (TCHAR *)sDwg2D);
|
|
}
|
|
|
|
OPENOBJ_BEGIN(pBox->m_nIdOfWall, AcDb::kForRead, TDbWall, pWall);
|
|
if (pWall == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
m_bIsDeep = TRUE;
|
|
XCurveSegment seg = pWall->OffsetGeomCenter();
|
|
XPoint ptLocal = pBox->m_ptLocation;
|
|
double dDeep = seg.GetDist2Me(ptLocal);
|
|
if (seg.OnWhichSide(ptLocal) == OFFSET_LEFT)
|
|
{
|
|
dDeep = _tstof(m_strWidth) -dDeep +pWall->GetWidth(0);
|
|
}
|
|
else
|
|
{
|
|
dDeep = _tstof(m_strWidth) -dDeep +pWall->GetWidth(1);
|
|
}
|
|
|
|
m_strDeep.Format(_T("%.1f"), dDeep);
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::Dlg2Obj(TDbEquipmentBox *pBox)
|
|
{
|
|
pBox->SetWidth(_tstof(m_strLength));
|
|
pBox->SetBreadth(_tstof(m_strWidth));
|
|
pBox->SetHeight(_tstof(m_strHeight));
|
|
pBox->m_nIdStyle2d = GetSlideId();
|
|
pBox->m_ptLocation.z = _tstof(m_strDistToFloor);
|
|
|
|
if (m_bInOutTurn)
|
|
{
|
|
pBox->m_nQuadrant = abs(pBox->m_nQuadrant - 3);
|
|
}
|
|
|
|
if (m_bLeftRTurn)
|
|
{
|
|
std::bitset<2> bitValue(pBox->m_nQuadrant);
|
|
bitValue[0].flip();//第一位反转
|
|
pBox->m_nQuadrant = bitValue.to_ulong();
|
|
}
|
|
|
|
OPENOBJ_BEGIN(pBox->m_nIdOfWall, AcDb::kForRead, TDbWall, pWall);
|
|
if (pWall == NULL)
|
|
{
|
|
return;
|
|
}
|
|
XCurveSegment cvSeg = pWall->OffsetGeomCenter();
|
|
XPoint ptLocal = pBox->m_ptLocation;
|
|
|
|
XPoint ptOff;
|
|
cvSeg.ProjectToMe(ptLocal, ptOff);
|
|
XPoint ptLineSide;
|
|
|
|
int nSide = cvSeg.OnWhichSide(ptLocal);
|
|
if (nSide == OFFSET_LEFT)
|
|
{
|
|
double dDist = pWall->GetWidth(0) + _tstof(m_strWidth)/2 - _tstof(m_strDeep);
|
|
ads_polar(ptOff, cvSeg.Direction(ptOff)+PI/2, dDist, ptLineSide);
|
|
}
|
|
else
|
|
{
|
|
double dDist = pWall->GetWidth(1) + _tstof(m_strWidth)/2 - _tstof(m_strDeep);
|
|
ads_polar(ptOff, cvSeg.Direction(ptOff)-PI/2, dDist, ptLineSide);
|
|
}
|
|
|
|
pBox->m_ptLocation = ptLineSide;
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnBnClickedEquipok()
|
|
{
|
|
UpdateData(TRUE);
|
|
CModelessDialog::OnOK();
|
|
}
|
|
|
|
void CEquipmentOpeningDlg::OnBnClickedEquipcancel()
|
|
{
|
|
CModelessDialog::OnCancel();
|
|
}
|
|
|
|
//add by lgy 20120524 设备箱JIG类
|
|
class DrawEquipmentJig : public TEdJig
|
|
{
|
|
public:
|
|
DrawEquipmentJig(CEquipmentOpeningDlg *pDlg);
|
|
virtual ~DrawEquipmentJig();
|
|
int doIt();
|
|
virtual DragStatus sampler();
|
|
virtual Adesk::Boolean Update();
|
|
virtual AcDbEntity* entity() const;
|
|
|
|
void SetEquipmentBox(TDbEquipmentBox *pBox);
|
|
void SetLocalPoint(XPoint ptLocal);
|
|
|
|
int GetRetCode(int *kwordId = NULL) const;
|
|
int m_nRetCode; //返回码
|
|
Entity m_ent;
|
|
protected:
|
|
TDbEquipmentBox *m_pEquipBox;//设备箱
|
|
CEquipmentOpeningDlg *m_pDlg;
|
|
XPoint m_ptLocal; //设备箱位置点
|
|
XPoint m_ptNew; //jig时保存实时位置点
|
|
};
|
|
|
|
DrawEquipmentJig::DrawEquipmentJig(CEquipmentOpeningDlg *pDlg)
|
|
{
|
|
m_pDlg = pDlg;
|
|
m_pEquipBox = NULL;
|
|
}
|
|
|
|
DrawEquipmentJig::~DrawEquipmentJig()
|
|
{
|
|
|
|
}
|
|
|
|
// 转换成ADS代码
|
|
int DrawEquipmentJig::GetRetCode(int *kwordId) const
|
|
{
|
|
int ret = m_nRetCode;
|
|
if (ret == AcEdJig::kCancel)
|
|
{
|
|
ret = RTCAN;
|
|
}
|
|
else if (ret == AcEdJig::kNull)
|
|
{
|
|
ret = RTNONE;
|
|
}
|
|
else if (ret <= 0)
|
|
{
|
|
ret = RTNORM;
|
|
}
|
|
else
|
|
{
|
|
if (kwordId) *kwordId = ret;
|
|
ret = RTKWORD;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
void DrawEquipmentJig::SetEquipmentBox(TDbEquipmentBox *pBox)
|
|
{
|
|
m_pEquipBox = pBox;
|
|
}
|
|
|
|
void DrawEquipmentJig::SetLocalPoint(XPoint ptLocal)
|
|
{
|
|
m_ptLocal = ptLocal;
|
|
}
|
|
|
|
int DrawEquipmentJig::doIt()
|
|
{
|
|
try
|
|
{
|
|
drag();
|
|
}
|
|
catch(...)
|
|
{
|
|
return RTCAN;
|
|
}
|
|
|
|
return m_nRetCode;
|
|
}
|
|
|
|
AcEdJig::DragStatus DrawEquipmentJig::sampler()
|
|
{
|
|
DragStatus stat;
|
|
setUserInputControls((UserInputControls)
|
|
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted
|
|
| AcEdJig::kNoNegativeResponseAccepted
|
|
| AcEdJig::kNoZeroResponseAccepted));
|
|
|
|
XPoint ptTemp;
|
|
stat = acquirePoint(ptTemp);
|
|
if (stat == AcEdJig::kNormal)
|
|
{
|
|
if (ads_distance(ptTemp, m_ptNew) > _DIST_SNAP)
|
|
{
|
|
m_ptNew = ptTemp;
|
|
}
|
|
else
|
|
{
|
|
return AcEdJig::kNoChange;
|
|
}
|
|
m_nRetCode = RTNORM;
|
|
}
|
|
else
|
|
{
|
|
m_nRetCode = RTCAN;
|
|
}
|
|
|
|
return stat;
|
|
}
|
|
|
|
Adesk::Boolean DrawEquipmentJig::Update()
|
|
{
|
|
m_pEquipBox->SetWidth(m_pDlg->GetEquipLength());
|
|
m_pEquipBox->SetHeight(m_pDlg->GetEquipHeight());
|
|
m_pEquipBox->SetBreadth(m_pDlg->GetEquipWidth());
|
|
m_pEquipBox->m_nIdStyle2d = m_pDlg->GetSlideId();
|
|
m_pEquipBox->m_nRotation = 0;
|
|
XPoint ptOff = m_ptLocal;
|
|
XCurveSegment cvSeg;
|
|
XPoint ptLineSide;
|
|
|
|
double dAng = ads_angle(m_ptLocal, m_ptNew);
|
|
|
|
int nInsertType = m_pDlg->GetInsertType(); //获得插入方式
|
|
OPENOBJ_BEGIN(m_ent, AcDb::kForRead, AcDbEntity, pEnt);
|
|
if (pEnt == NULL)
|
|
{
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
if (pEnt->isKindOf(TDbWall::desc()))
|
|
{
|
|
TDbWall *pWall = TDbWall::cast(pEnt);
|
|
cvSeg = pWall->OffsetGeomCenter();
|
|
cvSeg.ProjectToMe(m_ptLocal, ptOff);
|
|
|
|
if (fabs(m_pDlg->GetEquipDeep()) < _DIST_SNAP)
|
|
{
|
|
m_pEquipBox->m_nIdOfWall = NULL;
|
|
m_pEquipBox->SetBreakWall(FALSE);
|
|
}
|
|
else
|
|
{
|
|
m_pEquipBox->SetBreakWall(m_pDlg->GetIsBreakWall());
|
|
m_pEquipBox->m_nIdOfWall = pWall->id();
|
|
}
|
|
|
|
if (nInsertType == 1) //居中插入
|
|
{
|
|
ptOff = cvSeg.MidPoint();
|
|
dAng = ads_angle(ptOff, m_ptNew);
|
|
}
|
|
else if (nInsertType == 2)//定居插入
|
|
{
|
|
pWall->GetSubSegmentByPierAt(m_ptLocal, cvSeg);
|
|
if (cvSeg.GetStartPoint().Distance2d(m_ptLocal) < cvSeg.GetEndPoint().Distance2d(m_ptLocal))
|
|
{
|
|
TADSGePointDir2d ptDir2d;
|
|
cvSeg.Polar(m_pDlg->GetEquipDistance()+m_pDlg->GetEquipLength()/2, ptDir2d);
|
|
ptOff = ptDir2d.AsAcGePoint3d();
|
|
}
|
|
else
|
|
{
|
|
TADSGePointDir2d ptDir2d;
|
|
cvSeg.Polar(cvSeg.GetLength()-m_pDlg->GetEquipDistance()-m_pDlg->GetEquipLength()/2, ptDir2d);
|
|
ptOff = ptDir2d;
|
|
}
|
|
dAng = ads_angle(ptOff, m_ptNew);
|
|
}
|
|
|
|
int nSide = cvSeg.OnWhichSide(m_ptLocal);
|
|
//LH 2012.9.3 修改当嵌入深度等于0时,按照不断墙处理
|
|
if (!m_pDlg->GetIsBreakWall() || m_pDlg->GetEquipDeep() == 0)
|
|
{
|
|
if (nSide == OFFSET_LEFT)
|
|
{
|
|
double dDist = pWall->GetWidth(0) + m_pDlg->GetEquipWidth()/2 - m_pDlg->GetEquipDeep();
|
|
ads_polar(ptOff, cvSeg.Direction(ptOff)+PI/2, dDist, ptLineSide);
|
|
}
|
|
else
|
|
{
|
|
double dDist = pWall->GetWidth(1) + m_pDlg->GetEquipWidth()/2 - m_pDlg->GetEquipDeep();
|
|
ads_polar(ptOff, cvSeg.Direction(ptOff)-PI/2, dDist, ptLineSide);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pWall->GetWidth(4) > m_pDlg->GetEquipDeep())
|
|
{
|
|
m_pEquipBox->m_nOpStyle &= OPS_NOT_BORE;
|
|
}
|
|
if (nSide == OFFSET_LEFT)
|
|
{
|
|
m_pEquipBox->m_nThickness = m_pDlg->GetEquipDeep();
|
|
m_pEquipBox->m_nRotation = cvSeg.Direction(ptOff);
|
|
}
|
|
else
|
|
{
|
|
m_pEquipBox->m_nThickness = m_pDlg->GetEquipDeep();
|
|
m_pEquipBox->m_nRotation = cvSeg.Direction(ptOff)- PI;
|
|
}
|
|
ptLineSide = ptOff;
|
|
|
|
}
|
|
}
|
|
else if (pEnt->isKindOf(AcDbLine::desc()) || pEnt->isKindOf(AcDbArc::desc()))
|
|
{
|
|
XCurveSegment cvTemp(m_ent);
|
|
int nSide = cvTemp.OnWhichSide(m_ptNew);
|
|
|
|
if (nInsertType == 1) //居中插入
|
|
{
|
|
ptOff = cvTemp.MidPoint();
|
|
dAng = ads_angle(ptOff, m_ptNew);
|
|
}
|
|
else if (nInsertType == 2)
|
|
{
|
|
if (cvTemp.GetStartPoint().Distance2d(m_ptLocal) < cvTemp.GetEndPoint().Distance2d(m_ptLocal))
|
|
{
|
|
TADSGePointDir2d ptDir2d;
|
|
cvTemp.Polar(m_pDlg->GetEquipDistance()+m_pDlg->GetEquipLength()/2, ptDir2d);
|
|
ptOff = ptDir2d.AsAcGePoint3d();
|
|
}
|
|
else
|
|
{
|
|
TADSGePointDir2d ptDir2d;
|
|
cvTemp.Polar(cvSeg.GetLength()-m_pDlg->GetEquipDistance()-m_pDlg->GetEquipLength()/2, ptDir2d);
|
|
ptOff = ptDir2d;
|
|
}
|
|
|
|
dAng = ads_angle(ptOff, m_ptNew);
|
|
}
|
|
|
|
double dDist = m_pDlg->GetEquipWidth()/2 - m_pDlg->GetEquipDeep();
|
|
if (nSide == OFFSET_LEFT)
|
|
{
|
|
ads_polar(ptOff, cvTemp.Direction(ptOff)+PI/2, dDist, ptLineSide);
|
|
}
|
|
else
|
|
{
|
|
ads_polar(ptOff, cvTemp.Direction(ptOff)-PI/2, dDist, ptLineSide);
|
|
}
|
|
|
|
m_pEquipBox->m_nRotation = cvTemp.Direction(ptOff);
|
|
}
|
|
else if (pEnt->isKindOf(TDbColumn::desc()))
|
|
{
|
|
XPoly2D poly(m_ent);
|
|
|
|
XCurveSegment cvTemp;
|
|
for (int i = 0; i < poly.TotalSegments(); i++)
|
|
{
|
|
XCurveSegment seg;
|
|
poly.Nth(i, seg);
|
|
if (fabs(seg.GetDist2Me(m_ptLocal)) < _DIST_SNAP)
|
|
{
|
|
cvTemp = seg;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (nInsertType == 1) //居中插入
|
|
{
|
|
ptOff = cvTemp.MidPoint();
|
|
|
|
dAng = ads_angle(ptOff, m_ptNew);
|
|
}
|
|
else if (nInsertType == 2)
|
|
{
|
|
if (cvTemp.GetStartPoint().Distance2d(m_ptLocal) < cvTemp.GetEndPoint().Distance2d(m_ptLocal))
|
|
{
|
|
TADSGePointDir2d ptDir2d;
|
|
cvTemp.Polar(m_pDlg->GetEquipDistance()+m_pDlg->GetEquipLength()/2, ptDir2d);
|
|
ptOff = ptDir2d.AsAcGePoint3d();
|
|
}
|
|
else
|
|
{
|
|
TADSGePointDir2d ptDir2d;
|
|
cvTemp.Polar(cvSeg.GetLength()-m_pDlg->GetEquipDistance()-m_pDlg->GetEquipLength()/2, ptDir2d);
|
|
ptOff = ptDir2d;
|
|
}
|
|
|
|
dAng = ads_angle(ptOff, m_ptNew);
|
|
}
|
|
|
|
int nSide = cvTemp.OnWhichSide(m_ptNew);
|
|
double dDist = m_pDlg->GetEquipWidth()/2 - m_pDlg->GetEquipDeep();
|
|
if (nSide == OFFSET_LEFT)
|
|
{
|
|
ads_polar(ptOff, cvTemp.Direction(ptOff)+PI/2, dDist, ptLineSide);
|
|
}
|
|
else
|
|
{
|
|
ads_polar(ptOff, cvTemp.Direction(ptOff)-PI/2, dDist, ptLineSide);
|
|
}
|
|
|
|
m_pEquipBox->m_nRotation = cvTemp.Direction(ptOff);
|
|
}
|
|
|
|
OPENOBJ_END();
|
|
|
|
m_pEquipBox->SetLocation(ptLineSide);
|
|
m_pEquipBox->m_ptLocation.z = m_pDlg->GetDistToFloor();
|
|
|
|
double dRotation = m_pEquipBox->m_nRotation;
|
|
|
|
dAng = CT_std_angle(dAng - dRotation);
|
|
if (dAng < PI/2 && dAng >0)
|
|
{
|
|
m_pEquipBox->m_nQuadrant = 0;
|
|
}
|
|
else if(dAng >= PI/2 && dAng < PI)
|
|
{
|
|
m_pEquipBox->m_nQuadrant = 1;
|
|
}
|
|
else if (dAng >= PI && dAng < 3*PI/2)
|
|
{
|
|
m_pEquipBox->m_nQuadrant = 2;
|
|
}
|
|
else
|
|
{
|
|
m_pEquipBox->m_nQuadrant = 3;
|
|
}
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
AcDbEntity* DrawEquipmentJig::entity() const
|
|
{
|
|
return m_pEquipBox;
|
|
}
|
|
|
|
void EquipmentOpeningCmd() // 设备箱
|
|
{
|
|
CAcModuleResourceOverride vTemp;
|
|
|
|
CEquipmentOpeningDlg dlg;
|
|
dlg.SetIsEditDlg(FALSE);
|
|
BOOL bOk = dlg.Create(CEquipmentOpeningDlg::IDD, acedGetAcadFrame());
|
|
if (!bOk)
|
|
{
|
|
acutPrintf(_T("\n创建设备布置箱对话框失败!"));
|
|
return;
|
|
}
|
|
dlg.ShowWindow(TRUE);
|
|
|
|
XPoint ptPick;
|
|
Entity ent;
|
|
RBList rbMask(RTDXF0, _T("TCH_WALL,TCH_COLUMN,ARC,LINE,INSERT"),NULL);
|
|
while(TRUE)
|
|
{
|
|
if (RTNORM != SelectEntity1(_T("\n请拾取需布置设备箱的外部参照、块参照、墙线、柱子、直线、弧线 <退出>:"),ent, ptPick, rbMask))
|
|
{
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
|
|
if (ent.Is(_T("INSERT"))) //判断拾取的实体是否是块参照或者外部参照
|
|
{
|
|
BOOL bIsExt = FALSE; //保存是否是外部参照
|
|
AcDbObjectId idBlock;
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbBlockReference, pReference);
|
|
if (pReference == NULL)
|
|
{
|
|
continue;
|
|
}
|
|
idBlock = pReference->blockTableRecord();
|
|
OPENOBJ_END();
|
|
|
|
OPENOBJ_BEGIN(idBlock, AcDb::kForRead, AcDbBlockTableRecord, pBlockRecord);
|
|
if (pBlockRecord == NULL)
|
|
{
|
|
continue;
|
|
}
|
|
bIsExt = pBlockRecord->isFromExternalReference();
|
|
OPENOBJ_END();
|
|
|
|
CString strNote;
|
|
if (!bIsExt)
|
|
{
|
|
strNote = _T("\n块参照!请继续选择块参照中的墙线、柱子、直线、弧线<退出>:");
|
|
}
|
|
else
|
|
{
|
|
strNote = _T("\n外部参照!请继续选择外部参照中的墙线、柱子、直线、弧线<退出>:");
|
|
}
|
|
|
|
resbuf *refstkres = ads_buildlist(RTDXF0,_T("TCH_WALL,TCH_COLUMN,ARC,LINE"),NULL);
|
|
ads_matrix xformres;
|
|
//直接选择子实体
|
|
int result = acedNEntSelP(strNote, ent, ptPick, 0, xformres, &refstkres);//拾取块参照中的实体
|
|
if (refstkres != NULL)
|
|
{
|
|
acutRelRb(refstkres);
|
|
}
|
|
if (result != RTNORM)
|
|
{
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbEntity, pEnt);
|
|
if (pEnt == NULL)
|
|
{
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
|
|
if (!pEnt->isKindOf(TDbWall::desc()) && !pEnt->isKindOf(TDbColumn::desc())
|
|
&& !pEnt->isKindOf(AcDbArc::desc()) && !pEnt->isKindOf(AcDbLine::desc()))
|
|
{
|
|
acutPrintf(_T("\n选择无效,请重新选择!"));
|
|
continue;
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
ptPick = Ucs2Wcs(ptPick);
|
|
|
|
TDbEquipmentBox *pEquipBox = new TDbEquipmentBox;
|
|
//LH 2012.9.3 修改设备布置支持设置相关图层
|
|
CString sLayerName =_T("");
|
|
dlg.GetEquipLayerName(sLayerName);
|
|
if (!sLayerName.IsEmpty())
|
|
{
|
|
pEquipBox->setLayer(sLayerName);
|
|
}
|
|
|
|
DrawEquipmentJig jig(&dlg);
|
|
jig.SetEquipmentBox(pEquipBox);
|
|
jig.SetLocalPoint(ptPick);
|
|
jig.m_ent = ent;
|
|
acutPrintf(_T("\n请指定设备箱的插入方向:"));
|
|
int nRet = jig.doIt();
|
|
if (nRet == RTNORM)
|
|
{
|
|
AddToModelSpace(pEquipBox);
|
|
}
|
|
else
|
|
{
|
|
delete pEquipBox;
|
|
}
|
|
}
|
|
}
|
|
|
|
//add by lgy 020605 编辑不设备箱
|
|
int EditEquipment(AcDbObjectId id)
|
|
{
|
|
if (!id)
|
|
{
|
|
return RTERROR;
|
|
}
|
|
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbEquipmentBox, pBox);
|
|
if (pBox == NULL)
|
|
{
|
|
return RTERROR;
|
|
}
|
|
|
|
CTemporaryResourceOverride vTemp;
|
|
CEquipmentOpeningDlg dlg(acedGetAcadFrame());
|
|
dlg.SetIsEditDlg(TRUE);
|
|
dlg.Obj2Dlg(pBox);
|
|
INT_PTR nResult = dlg.DoModal();
|
|
|
|
if (nResult == IDOK)
|
|
{
|
|
if (pBox->upgradeOpen() == Acad::eOk)
|
|
{
|
|
dlg.Dlg2Obj(pBox);
|
|
pBox->downgradeOpen();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pBox->close();
|
|
return RTCAN;
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
return RTNORM;
|
|
}
|
|
|