452 lines
13 KiB
C++
452 lines
13 KiB
C++
// DoorWinDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "resource.h"
|
|
#include "DoorWinDlg.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);
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDoorWinDlg dialog
|
|
|
|
|
|
CDoorWinDlg::CDoorWinDlg(CWnd* pParent /*=NULL*/)
|
|
: CInsertOpeningDlg(CDoorWinDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CDoorWinDlg)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
m_sWin3DStyle=SYS_DWIN3D;
|
|
m_sDoor3DStyle = SYS_WDOOR3D;
|
|
|
|
m_nDWidth = 750.0; //门宽
|
|
m_nWidth=1800; //总宽
|
|
m_nHeight=2400; //总高 modified by fxj 090323
|
|
m_nWHeight=1500; //窗高; modified by fxj 090323
|
|
m_nSill=0;
|
|
}
|
|
|
|
|
|
//根据给定的门窗 设置二,三维样式
|
|
void CDoorWinDlg::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; \
|
|
int __nWindowHei = (int)m_nWHeight; \
|
|
CString __strDoorStyle3d = m_sDoor3DStyle; \
|
|
CString __strWinStyle3d = m_sWin3DStyle;
|
|
|
|
#define CHECK_LABEL_PROP_CHANGE \
|
|
{ \
|
|
bool bSame = (__nWid == (int)m_nWidth) && \
|
|
(__nHei == (int)m_nHeight) && \
|
|
(__nDoorWid == (int)m_nDWidth) && \
|
|
(__nWindowHei == (int)m_nWHeight) && \
|
|
(__strDoorStyle3d.CompareNoCase(m_sDoor3DStyle) == 0) && \
|
|
(__strWinStyle3d.CompareNoCase(m_sWin3DStyle) == 0); \
|
|
if (!bSame) InvalidateOldLabel(); \
|
|
}
|
|
|
|
void CDoorWinDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
KEEP_LABEL_PROP;
|
|
CInsertOpeningDlg::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CDoorWinDlg)
|
|
DDX_Control(pDX, IDC_DOORWIDTH, m_doorwCtl);
|
|
DDX_Control(pDX, IDC_WINHEIGHT, m_winhCtl);
|
|
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);
|
|
double nVal=_tstof(csText);
|
|
if (nVal<_DIST_SNAP || nVal>m_nWidth) {
|
|
pDX->Fail();
|
|
return;
|
|
}
|
|
m_nDWidth = nVal;
|
|
GetDlgItem(IDC_WINHEIGHT)->GetWindowText(csText);
|
|
nVal=_tstof(csText);
|
|
if (nVal<_DIST_SNAP || nVal>m_nHeight) {
|
|
pDX->Fail();
|
|
return;
|
|
}
|
|
m_nWHeight = nVal;
|
|
} else {
|
|
CString csText;
|
|
csText.Format(_T("%.f"),m_nDWidth);
|
|
GetDlgItem(IDC_DOORWIDTH)->SetWindowText(csText);
|
|
csText.Format(_T("%.f"),m_nWHeight);
|
|
GetDlgItem(IDC_WINHEIGHT)->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(CDoorWinDlg, CInsertOpeningDlg)
|
|
//{{AFX_MSG_MAP(CDoorWinDlg)
|
|
ON_WM_PAINT()
|
|
ON_WM_SETCURSOR()
|
|
ON_BN_CLICKED(IDC_DOORSTYLE, OnPicDoor)
|
|
ON_BN_CLICKED(IDC_WINSTYLE, OnPicWin)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDoorWinDlg message handlers
|
|
|
|
BOOL CDoorWinDlg::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);
|
|
|
|
// add by xly on 110113 已有洞口插入灰显
|
|
m_toolbar.EnableButton(ID_HASHOLE_INSERT, FALSE);
|
|
m_toolbar.EnableButton(ID_UPLEVEL_INSERT, TRUE);
|
|
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 CDoorWinDlg::InitCombox()
|
|
{
|
|
double width[] = {1500,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 CDoorWinDlg::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 CDoorWinDlg::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 CDoorWinDlg::OnPicDoor()
|
|
{
|
|
KEEP_LABEL_PROP;
|
|
|
|
XString sLibFile, sBlockName, sTkw;
|
|
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 CDoorWinDlg::OnPicWin()
|
|
{
|
|
KEEP_LABEL_PROP;
|
|
|
|
XString sLibFile, sBlockName, sTkw;
|
|
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;
|
|
}
|
|
|
|
CHECK_LABEL_PROP_CHANGE;
|
|
}
|
|
|
|
BOOL CDoorWinDlg::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 CDoorWinDlg::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 CDoorWinDlg::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_WINHEIGHT, _T("窗高")));
|
|
lstParam.Append(new XOpeningParam(IDC_DOORSTYLE, _T("三维门式")));
|
|
lstParam.Append(new XOpeningParam(IDC_WINSTYLE, _T("三维窗式")));
|
|
return TRUE;
|
|
}
|
|
|
|
//add by lgy 20120119 拾取数据时需要不同的对话框初始化
|
|
int CDoorWinDlg::ObjToDlg(TDbOpening* pOpening)
|
|
{
|
|
CInsertOpeningDlg::ObjToDlg(pOpening);
|
|
m_nDWidth = pOpening->m_nDoorWidth;
|
|
m_nWHeight = pOpening->m_nWinHeight;
|
|
|
|
//设置门窗样式幻灯片
|
|
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 CDoorWinDlg::SetDlgParamFrom(const TDbOpening &opening)
|
|
{
|
|
if (!CInsertOpeningDlg::SetDlgParamFrom(opening))
|
|
return FALSE;
|
|
|
|
// Modify on 2002/4/2, 修复对象编辑,未能获取门宽和窗高的参数
|
|
m_nDWidth=opening.m_nDoorWidth;
|
|
m_nWHeight=opening.m_nWinHeight;
|
|
|
|
// 设置门或者窗的样式, 包括2D & 3D
|
|
SetStyle(opening);
|
|
return TRUE;
|
|
}
|
|
|
|
void
|
|
CDoorWinDlg::UpdateOpening(TDbOpening &op, BOOL bLoadStyle)
|
|
{
|
|
CInsertOpeningDlg::UpdateOpening(op, bLoadStyle);
|
|
op.m_nDoorWidth=m_nDWidth;
|
|
op.m_nWinHeight=m_nWHeight;
|
|
op.SetLabel(GetAutoLabel(&op));
|
|
}
|
|
|
|
BOOL CDoorWinDlg::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 CDoorWinDlg::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 (nUsageFlag==USE_EDIT || GetParamCheck(IDC_WINHEIGHT))
|
|
op.m_nWinHeight=m_nWHeight;
|
|
|
|
if (!CInsertOpeningDlg::ModifyOpeningWithDlgParam(op))
|
|
return FALSE;
|
|
|
|
op.SetSill(0.0); //门联窗的底标高一定为0
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDoorWinDlg::GetTitleKeyString(XString &sKeyTitle) const
|
|
{
|
|
sKeyTitle=_T("门连窗参数");//门联窗-》门连窗 090622 by fxj
|
|
return TRUE;
|
|
}
|
|
|
|
//关键注册位置, 子类需要重载本方法
|
|
BOOL CDoorWinDlg::GetRegLocation(XString &sRegLoc) const
|
|
{
|
|
sRegLoc = _T("DoorWin");
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// 从注册表读入参数
|
|
BOOL CDoorWinDlg::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("DoorWidth"), m_nDWidth) ||
|
|
!regProp.GetValue(_T("WinHeight"), m_nWHeight) )
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// 把最近的参数写入注册表
|
|
BOOL CDoorWinDlg::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("DoorWidth"), m_nDWidth) ||
|
|
!regProp.SetValue(_T("WinHeight"), m_nWHeight) )
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|