444 lines
12 KiB
C++
444 lines
12 KiB
C++
// DoorWinDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "resource.h"
|
|
#include "TwoDoorDlg.h"
|
|
|
|
// 门联窗
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
extern BOOL InvokeTkwMan(const TCHAR *pszLib, BOOL bSelOnly, XString &sBlockName);
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CTwoDoorDlg dialog
|
|
|
|
|
|
CTwoDoorDlg::CTwoDoorDlg(CWnd* pParent /*=NULL*/)
|
|
: CInsertOpeningDlg(CTwoDoorDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CTwoDoorDlg)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
m_sWin3DStyle=SYS_TWODOOR;
|
|
m_sDoor3DStyle = SYS_TWODOOR;
|
|
m_nDWidth = 1200; //大门宽
|
|
m_nWidth=1800; //总宽
|
|
m_nHeight=2100; //总高 modified by fxj 090323
|
|
m_nSill=0;
|
|
}
|
|
|
|
|
|
//根据给定的门窗 设置二,三维样式
|
|
void CTwoDoorDlg::SetStyle(const TDbOpening& opening)
|
|
{
|
|
XString sDwb2D, sDwg2D, sDwb3D, sDwg3D;
|
|
if (opening.GetStyle2dName(sDwb2D, sDwg2D)==Acad::eOk) {
|
|
m_sDoor3DStyle = XString(_T("%s(%s)"), (TCHAR *)sDwb2D, (TCHAR *)sDwg2D);
|
|
}
|
|
if (opening.GetStyle3dName(sDwb3D, sDwg3D)==Acad::eOk) {
|
|
m_sWin3DStyle = XString(_T("%s(%s)"), (TCHAR *)sDwb3D, (TCHAR *)sDwg3D);
|
|
}
|
|
}
|
|
|
|
// 保存编号相关属性:如果变动并且当前是自动编号的时候,则需要更新编号:
|
|
#define KEEP_LABEL_PROP \
|
|
int __nWid = (int)m_nWidth; \
|
|
int __nHei = (int)m_nHeight; \
|
|
int __nDoorWid = (int)m_nDWidth; \
|
|
CString __strBDoorStyle = m_sDoor3DStyle; \
|
|
CString __strSDoorStyle = m_sWin3DStyle
|
|
|
|
|
|
#define CHECK_LABEL_PROP_CHANGE \
|
|
{ \
|
|
bool bSame = (__nWid == (int)m_nWidth) && \
|
|
(__nHei == (int)m_nHeight) && \
|
|
(__nDoorWid == (int)m_nDWidth) && \
|
|
(__strBDoorStyle.CompareNoCase(m_sDoor3DStyle) == 0) && \
|
|
(__strSDoorStyle.CompareNoCase(m_sWin3DStyle) == 0); \
|
|
if (!bSame) InvalidateOldLabel(); \
|
|
}
|
|
|
|
|
|
void CTwoDoorDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
KEEP_LABEL_PROP;
|
|
CInsertOpeningDlg::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CTwoDoorDlg)
|
|
DDX_Control(pDX, IDC_DOORWIDTH, m_doorwCtl);
|
|
DDX_Control(pDX, IDC_DOORSTYLE, m_picDoor);
|
|
DDX_Control(pDX, IDC_WINSTYLE, m_picWin);
|
|
//}}AFX_DATA_MAP
|
|
if (pDX->m_bSaveAndValidate) {
|
|
CString csText;
|
|
GetDlgItem(IDC_DOORWIDTH)->GetWindowText(csText);
|
|
if (_tstof(csText)<_DIST_SNAP)
|
|
pDX->Fail();
|
|
m_nDWidth = _tstof(csText);
|
|
if (m_nDWidth>m_nWidth)
|
|
pDX->Fail();
|
|
} else {
|
|
CString csText;
|
|
csText.Format(_T("%.f"),m_nDWidth);
|
|
GetDlgItem(IDC_DOORWIDTH)->SetWindowText(csText);
|
|
|
|
// 显示幻灯
|
|
XString sSlidePath(256);
|
|
sSlidePath << m_sWin3DStyle;
|
|
ShowSlide(m_picWin, m_dcWin, sSlidePath);
|
|
|
|
_tcscpy(sSlidePath, _T(""));
|
|
sSlidePath << m_sDoor3DStyle;
|
|
ShowSlide(m_picDoor, m_dcDoor, sSlidePath);
|
|
}
|
|
|
|
CHECK_LABEL_PROP_CHANGE;
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CTwoDoorDlg, CInsertOpeningDlg)
|
|
//{{AFX_MSG_MAP(CTwoDoorDlg)
|
|
ON_WM_PAINT()
|
|
ON_WM_SETCURSOR()
|
|
ON_BN_CLICKED(IDC_DOORSTYLE, OnPicDoor)
|
|
ON_BN_CLICKED(IDC_WINSTYLE, OnPicWin)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CTwoDoorDlg message handlers
|
|
|
|
BOOL CTwoDoorDlg::OnInitDialog()
|
|
{
|
|
CInsertOpeningDlg::OnInitDialog();
|
|
|
|
// TODO: Add extra initialization here
|
|
if (!CInsertOpeningDlg::bRefreshDlg)//add by whl
|
|
if (GetInsertMode()==ID_UPLEVEL_INSERT)
|
|
g_nInsertMode=0;
|
|
//GetDlgItem(ID_UPLEVEL_INSERT)->EnableWindow(FALSE);
|
|
m_toolbar.EnableButton(ID_UPLEVEL_INSERT, TRUE);
|
|
|
|
// add by xly on 110113 已有洞口插入灰显
|
|
m_toolbar.EnableButton(ID_HASHOLE_INSERT, FALSE);
|
|
|
|
InitCombox();
|
|
m_bInitMe=TRUE;
|
|
UpdateData(FALSE);
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
//初始化组合框
|
|
void CTwoDoorDlg::InitCombox()
|
|
{
|
|
// sg add 101221,根据8.5需求,增加1600的默认门宽
|
|
// double width[] = {1500,1800,2100,2400};
|
|
double width[] = {1500,1600,1800,2100,2400};
|
|
double height[] = {2000,2100,2400,2500,2700,3000};
|
|
double high[] = {1200,1500,1800,2100};
|
|
double dwidth[] = {900};
|
|
|
|
DList<double> lstWidth(width, ELEMENTS(width)),
|
|
lstHeight(height, ELEMENTS(height)),
|
|
lstSill(high, ELEMENTS(high)), lstDWidth(dwidth, ELEMENTS(dwidth));
|
|
|
|
InitCombox(m_lstWidthBox, lstWidth);
|
|
InitCombox(m_doorwCtl, lstDWidth);
|
|
InitCombox(m_lstHeightBox,lstHeight);
|
|
//InitCombox(m_winhCtl,lstSill);
|
|
|
|
// sg add 110530,取得门槛的高度模数系列
|
|
double sill[] = {0, 50, 60, 100, 150, 200, 300, 600};
|
|
DList<double> lstDoorSill(sill, ELEMENTS(sill));
|
|
InitCombox(m_lstSillBox, lstDoorSill);
|
|
}
|
|
|
|
|
|
//初始化组合框
|
|
void CTwoDoorDlg::InitCombox(CComboBox& combox, DList<double> &lstModelNum)
|
|
{
|
|
CString szItem;
|
|
combox.ResetContent();
|
|
for (int i = 0 ; i < lstModelNum.Length(); i++) {
|
|
szItem.Format(_T("%d"), AS_INT(*lstModelNum[i]));
|
|
combox.AddString(szItem);
|
|
}
|
|
}
|
|
|
|
//显示幻灯
|
|
void CTwoDoorDlg::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);
|
|
}
|
|
|
|
// 清除幻灯
|
|
void CTwoDoorDlg::ShowSlide(CStatic& st)
|
|
{
|
|
CRect cR;
|
|
CDC* pDC = st.GetDC();
|
|
CBrush Brush;
|
|
st.GetClientRect(&cR);
|
|
Brush.CreateSolidBrush(RGB(0,0,0));
|
|
pDC->FillRect(cR,&Brush);
|
|
st.ReleaseDC(pDC);
|
|
}
|
|
|
|
|
|
// 点取三维样式
|
|
void CTwoDoorDlg::OnPicDoor()
|
|
{
|
|
KEEP_LABEL_PROP;
|
|
XPushAutoHide noAutoHide(this);
|
|
|
|
// const TCHAR *pszPrompt = _T("选择大门式");
|
|
XString sLibFile, sBlockName;
|
|
sLibFile << g_sDwbPath << _T("WDLib3D.TKW");
|
|
sBlockName=m_sDoor3DStyle;
|
|
if (InvokeTkwMan(sLibFile, TRUE, sBlockName)) {
|
|
ShowSlide(m_picDoor, m_dcDoor, sBlockName);
|
|
m_sDoor3DStyle=XPathParser(sBlockName).m_sFileName;
|
|
}
|
|
|
|
CHECK_LABEL_PROP_CHANGE;
|
|
}
|
|
|
|
|
|
void CTwoDoorDlg::OnPicWin()
|
|
{
|
|
// sg add 110803,仿照选择大门样式,增加修改小门样式后的自动编号
|
|
KEEP_LABEL_PROP;
|
|
XPushAutoHide noAutoHide(this);
|
|
|
|
// const TCHAR *pszPrompt = _T("选择小门样式");
|
|
XString sLibFile, sBlockName;
|
|
sLibFile << g_sDwbPath << _T("WDLib3D.TKW");
|
|
sBlockName=m_sWin3DStyle;
|
|
if (InvokeTkwMan(sLibFile, TRUE, sBlockName)) {
|
|
ShowSlide(m_picWin, m_dcWin, sBlockName);
|
|
m_sWin3DStyle=XPathParser(sBlockName).m_sFileName;
|
|
}
|
|
|
|
// sg add 110803,仿照选择大门样式,增加修改小门样式后的自动编号
|
|
CHECK_LABEL_PROP_CHANGE;
|
|
}
|
|
|
|
BOOL CTwoDoorDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
|
|
{
|
|
if (pWnd && (pWnd->m_hWnd==m_picDoor.m_hWnd || pWnd->m_hWnd==m_picWin.m_hWnd)) {
|
|
CAcModuleResourceOverride vTemp;
|
|
HCURSOR hIcon = AfxGetApp()->LoadCursor( IDC_CUR_PICK );
|
|
SetCursor( hIcon );
|
|
return TRUE;
|
|
}
|
|
return CInsertOpeningDlg::OnSetCursor(pWnd, nHitTest, message);
|
|
|
|
}
|
|
|
|
void CTwoDoorDlg::OnPaint()
|
|
{
|
|
CDC* pDC;
|
|
CRect cR,cR1;
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
pDC = m_picDoor.GetDC();
|
|
m_picDoor.GetClientRect(&cR);
|
|
m_dcDoor.InitDC(pDC, cR,GetAcadBackColor());
|
|
m_dcDoor.Redraw();
|
|
m_picDoor.ReleaseDC(pDC);
|
|
|
|
pDC = m_picWin.GetDC();
|
|
m_picWin.GetClientRect(&cR1);
|
|
m_dcWin.InitDC(pDC,cR1,GetAcadBackColor());
|
|
m_dcWin.Redraw();
|
|
m_picWin.ReleaseDC(pDC);
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
// override memeber
|
|
BOOL CTwoDoorDlg::InitParamList(DList<XOpeningParam> &lstParam) const
|
|
{
|
|
lstParam.Append(new XOpeningParam(IDC_LABEL, _T("编号")));
|
|
lstParam.Append(new XOpeningParam(IDC_WIDTH, _T("总宽")));
|
|
lstParam.Append(new XOpeningParam(IDC_DOORWIDTH, _T("大门宽")));
|
|
lstParam.Append(new XOpeningParam(IDC_HEIGHT, _T("门高")));
|
|
lstParam.Append(new XOpeningParam(IDC_DOORSTYLE, _T("三维门式")));
|
|
lstParam.Append(new XOpeningParam(IDC_WINSTYLE, _T("三维窗式")));
|
|
return TRUE;
|
|
}
|
|
|
|
//add by lgy 20120119 拾取参数时分别为对话框初始化
|
|
int CTwoDoorDlg::ObjToDlg(TDbOpening* pOpening)
|
|
{
|
|
CInsertOpeningDlg::ObjToDlg(pOpening);
|
|
m_nDWidth=pOpening->m_nDoorWidth;
|
|
|
|
//显示幻灯片
|
|
XString sDwb2D, sDwg2D, sDwb3D, sDwg3D;
|
|
if (pOpening->GetStyle2dName(sDwb2D, sDwg2D)==Acad::eOk)
|
|
{
|
|
m_sDoor3DStyle = XString(_T("%s(%s)"), (TCHAR *)sDwb2D, (TCHAR *)sDwg2D);
|
|
}
|
|
|
|
if (pOpening->GetStyle3dName(sDwb3D, sDwg3D)==Acad::eOk)
|
|
{
|
|
m_sWin3DStyle = XString(_T("%s(%s)"), (TCHAR *)sDwb3D, (TCHAR *)sDwg3D);
|
|
}
|
|
|
|
XString sSlidePath(256);
|
|
sSlidePath << m_sWin3DStyle;
|
|
ShowSlide(m_picWin, m_dcWin, sSlidePath);
|
|
|
|
_tcscpy(sSlidePath, _T(""));
|
|
sSlidePath << m_sDoor3DStyle;
|
|
ShowSlide(m_picDoor, m_dcDoor, sSlidePath);
|
|
UpdateData(FALSE);
|
|
return 1;
|
|
}
|
|
|
|
// 用于编辑以及改选编号时
|
|
BOOL CTwoDoorDlg::SetDlgParamFrom(const TDbOpening &opening)
|
|
{
|
|
if (!CInsertOpeningDlg::SetDlgParamFrom(opening))
|
|
return FALSE;
|
|
m_nDWidth=opening.m_nDoorWidth;
|
|
// 设置门或者窗的样式, 包括2D & 3D
|
|
SetStyle(opening);
|
|
return TRUE;
|
|
}
|
|
|
|
void
|
|
CTwoDoorDlg::UpdateOpening(TDbOpening &op, BOOL bLoadStyle)
|
|
{
|
|
CInsertOpeningDlg::UpdateOpening(op, bLoadStyle);
|
|
op.m_nDoorWidth=m_nDWidth;
|
|
op.SetLabel(GetAutoLabel(&op));
|
|
}
|
|
|
|
BOOL CTwoDoorDlg::GetStyles(AcDbObjectId &idDoor, AcDbObjectId &idWin)
|
|
{
|
|
extern TARCH_IMPEXP void CheckOp3dStyle(AcDbObjectId idStyle3d);
|
|
|
|
XString sBlockDoor(_T("%s%s"), g_sDwbPath, (const TCHAR *)m_sDoor3DStyle);
|
|
XString sBlockWin(_T("%s%s"), g_sDwbPath, (const TCHAR *)m_sWin3DStyle);
|
|
XString szBlockDoor;
|
|
XString szBlockWin;
|
|
BOOL bLoadWin=(LoadDwbBlock(sBlockDoor, szBlockDoor)==RTNORM);
|
|
BOOL bLoadDoor=(LoadDwbBlock(sBlockWin, szBlockWin)==RTNORM);
|
|
if (!bLoadWin || !bLoadDoor)
|
|
return FALSE;
|
|
|
|
idDoor=InitBlock(szBlockDoor);
|
|
idWin=InitBlock(szBlockWin);
|
|
|
|
if (!!idDoor)
|
|
CheckOp3dStyle(idDoor);
|
|
if (!!idWin)
|
|
CheckOp3dStyle(idWin);
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////
|
|
// 用对话框上的参数更新实体数据
|
|
// op--门/窗/门联窗-门/门联窗-窗
|
|
BOOL CTwoDoorDlg::ModifyOpeningWithDlgParam(TDbOpening &op)
|
|
{
|
|
AcDbObjectId id2d, id3d;
|
|
GetStyles(id2d, id3d);
|
|
int nUsageFlag=GetUsage();
|
|
|
|
// sg add 110804,将下面两行代码从CInsertOpeningDlg::ModifyOpeningWithDlgParam函数之后,提前到这里,主要是解决自动编号问题
|
|
// 在CInsertOpeningDlg::ModifyOpeningWithDlgParam函数中,进行了自动编号,而编号规则需要考虑是否2D、3D图块样式等
|
|
if (nUsageFlag==USE_EDIT || GetParamCheck(IDC_WINSTYLE))
|
|
op.m_nIdStyle3d=id3d;
|
|
if (nUsageFlag==USE_EDIT || GetParamCheck(IDC_DOORSTYLE))
|
|
op.m_nIdStyle2d=id2d;
|
|
if (nUsageFlag==USE_EDIT || GetParamCheck(IDC_DOORWIDTH))
|
|
op.m_nDoorWidth=m_nDWidth;
|
|
|
|
if (!CInsertOpeningDlg::ModifyOpeningWithDlgParam(op))
|
|
return FALSE;
|
|
op.SetSill(0.0); //子母门的底标高一定为0
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CTwoDoorDlg::GetTitleKeyString(XString &sKeyTitle) const
|
|
{
|
|
sKeyTitle=_T("子母门参数");
|
|
return TRUE;
|
|
}
|
|
|
|
//关键注册位置, 子类需要重载本方法
|
|
BOOL CTwoDoorDlg::GetRegLocation(XString &sRegLoc) const
|
|
{
|
|
sRegLoc = _T("TwoDoor");
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// 从注册表读入参数
|
|
BOOL CTwoDoorDlg::ReadParamFromRegistry()
|
|
{
|
|
if (!CInsertOpeningDlg::ReadParamFromRegistry())
|
|
return FALSE;
|
|
XString sRegSubLoc, sRegLoc(1024);
|
|
BOOL bOk=GetRegLocation(sRegSubLoc);
|
|
if (!bOk)
|
|
return FALSE;
|
|
sRegLoc << ::GetRegLocation() << _T("\\Settings");
|
|
CRegProperty regProp(sRegLoc, sRegSubLoc);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
|
|
if (!regProp.GetValue(_T("Door3DStyle"), m_sDoor3DStyle) ||
|
|
!regProp.GetValue(_T("Win3DStyle"), m_sWin3DStyle) ||
|
|
!regProp.GetValue(_T("BigDoorWidth"), m_nDWidth)
|
|
)
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// 把最近的参数写入注册表
|
|
BOOL CTwoDoorDlg::WriteParamToRegistry() const
|
|
{
|
|
if (!CInsertOpeningDlg::WriteParamToRegistry())
|
|
return FALSE;
|
|
|
|
XString sRegSubLoc, sRegLoc(1024);
|
|
BOOL bOk=GetRegLocation(sRegSubLoc);
|
|
if (!bOk)
|
|
return FALSE;
|
|
sRegLoc << ::GetRegLocation() << _T("\\Settings");
|
|
CRegProperty regProp(sRegLoc, sRegSubLoc);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
if (!regProp.SetValue(_T("Door3DStyle"), m_sDoor3DStyle) ||
|
|
!regProp.SetValue(_T("Win3DStyle"), m_sWin3DStyle) ||
|
|
!regProp.SetValue(_T("BigDoorWidth"), m_nDWidth) )
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|