453 lines
13 KiB
C++
453 lines
13 KiB
C++
// BayWindowDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "resource.h"
|
|
#include "BayWindowDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
GEOAPI int DisplaySlide(CWnd *pWnd, const TCHAR *pszSlide);
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CBayWindowDlg dialog
|
|
|
|
//IMPLEMENT_DYNAMIC(CBayWindowDlg, CInsertOpeningDlg)
|
|
|
|
|
|
BOOL CBayWindowDlg::s_bLeftSlab=FALSE;
|
|
BOOL CBayWindowDlg::s_bRightSlab=FALSE;
|
|
double CBayWindowDlg::s_fSlabThick=100;//add by fxj 090505
|
|
CBayWindowDlg::CBayWindowDlg(CWnd* pParent /*=NULL*/)
|
|
: CInsertOpeningDlg(CBayWindowDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CBayWindowDlg)
|
|
//}}AFX_DATA_INIT
|
|
m_nWidth=2400.0;
|
|
m_nHeight=1500.0;
|
|
m_nSill = 600;// modified by fxj 090323
|
|
}
|
|
|
|
|
|
#define KEEP_LABEL_PROP \
|
|
int __nWid = (int)m_nWidth; \
|
|
int __nHei = (int)m_nHeight; \
|
|
XBayWinStyle __nStyle = m_nStyle; \
|
|
int __nProWid = (int)m_nProtrude; \
|
|
int __nInEnt = (int)m_nTrapezia
|
|
|
|
#define CHECK_LABEL_PROP_CHANGE \
|
|
{ \
|
|
bool bSame = (__nWid == (int)m_nWidth) && \
|
|
(__nHei == (int)m_nHeight) && \
|
|
(__nStyle == m_nStyle) && \
|
|
(__nProWid == (int)m_nProtrude) && \
|
|
(__nInEnt == (int)m_nTrapezia); \
|
|
if (!bSame) InvalidateOldLabel(); \
|
|
}
|
|
|
|
|
|
void CBayWindowDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
KEEP_LABEL_PROP;
|
|
CInsertOpeningDlg::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CBayWindowDlg)
|
|
DDX_Control(pDX, IDC_STYLE, m_lstStyleBox);
|
|
DDX_Control(pDX, IDC_PROTRUDE, m_lstProtrudeBox);
|
|
DDX_Control(pDX, IDC_IDENT, m_lstIndentBox);
|
|
DDX_Check(pDX,IDC_LEFT_SLAB,s_bLeftSlab);
|
|
DDX_Check(pDX,IDC_RIGHT_SLAB,s_bRightSlab);
|
|
|
|
//}}AFX_DATA_MAP
|
|
if (pDX->m_bSaveAndValidate) {
|
|
|
|
//---------add by fxj 090505
|
|
CString sSlabThick;
|
|
DDX_Text(pDX, IDC_SLAB_THICK, sSlabThick);
|
|
s_fSlabThick=_tstof(sSlabThick);
|
|
//------------------------------
|
|
|
|
m_nStyle = (XBayWinStyle)(m_lstStyleBox.GetCurSel()+1);
|
|
CString csTemp;
|
|
m_lstProtrudeBox.GetWindowText(csTemp); m_nProtrude = _tstof(csTemp);
|
|
m_lstIndentBox.GetWindowText(csTemp); m_nTrapezia = _tstof(csTemp);
|
|
if (m_nProtrude<=0) {
|
|
pDX->Fail();
|
|
}
|
|
} else {
|
|
//---------add by fxj 090505
|
|
CString sSlabThick;
|
|
sSlabThick.Format(_T("%lg"),s_fSlabThick);
|
|
DDX_Text(pDX, IDC_SLAB_THICK, sSlabThick);
|
|
//----------------------------
|
|
|
|
m_lstStyleBox.SetCurSel(m_nStyle-1);
|
|
m_lstProtrudeBox.SetWindowText(XString(_T("%.f"), m_nProtrude));
|
|
m_lstIndentBox.SetWindowText(XString(_T("%.f"), m_nTrapezia));
|
|
OnSelchangeStyle();
|
|
}
|
|
GetDlgItem(IDC_SLAB_THICK)->EnableWindow(s_bLeftSlab||s_bRightSlab);//add by fxj 090505
|
|
CHECK_LABEL_PROP_CHANGE;
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CBayWindowDlg, CInsertOpeningDlg)
|
|
//{{AFX_MSG_MAP(CBayWindowDlg)
|
|
ON_CBN_SELCHANGE(IDC_STYLE, OnSelchangeStyle)
|
|
ON_BN_CLICKED(IDC_LEFT_SLAB, OnLeftSlab)//add by fxj 090505
|
|
ON_BN_CLICKED(IDC_RIGHT_SLAB, OnRightSlab)//add by fxj 090505
|
|
ON_WM_PAINT()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CBayWindowDlg message handlers
|
|
void CBayWindowDlg::InitComboxes()
|
|
{
|
|
//窗户类型
|
|
m_lstStyleBox.AddString(_T("梯形凸窗"));
|
|
m_lstStyleBox.AddString(_T("三角凸窗"));
|
|
m_lstStyleBox.AddString(_T("圆弧凸窗"));
|
|
m_lstStyleBox.AddString(_T("矩形凸窗"));
|
|
// sg modify 101126,根据8.5需求,默认为矩形凸窗
|
|
// m_lstStyleBox.SetCurSel(0);
|
|
m_lstStyleBox.SetCurSel(3);
|
|
|
|
|
|
// 宽度系列 2400
|
|
CString csItem;
|
|
int widthArray[]={1500, 1800, 2100, 2400, 2700, 3000, 3300, 3600};
|
|
for(int i=0; i<ELEMENTS(widthArray); i++) {
|
|
csItem.Format(_T("%d"), widthArray[i]);
|
|
m_lstWidthBox.AddString(csItem);
|
|
}
|
|
//m_lstWidthBox.SetCurSel(3);
|
|
|
|
// 高度系列 1500
|
|
int heightArray[]={1200, 1400, 1500, 1800, 2100, 2400, 2700, 3000};
|
|
for(i=0; i<ELEMENTS(heightArray); i++) {
|
|
csItem.Format(_T("%d"), heightArray[i]);
|
|
m_lstHeightBox.AddString(csItem);
|
|
}
|
|
//m_lstHeightBox.SetCurSel(2);
|
|
|
|
// 窗台高度系列 900
|
|
int sillArray[]={0, 300, 400, 500, 600, 700, 800, 900, 1000, 1200};
|
|
for(i=0; i<ELEMENTS(sillArray); i++) {
|
|
csItem.Format(_T("%d"), sillArray[i]);
|
|
m_lstSillBox.AddString(csItem);
|
|
}
|
|
//m_lstSillBox.SetCurSel(7);
|
|
|
|
// 凸出宽系列 600
|
|
int protrudeArray[]={400, 500, 600, 700, 800, 900, 1000, 1200, 1500};
|
|
for(i=0; i<ELEMENTS(protrudeArray); i++) {
|
|
csItem.Format(_T("%d"), protrudeArray[i]);
|
|
m_lstProtrudeBox.AddString(csItem);
|
|
}
|
|
//m_lstProtrudeBox.SetCurSel(2);
|
|
|
|
// 缩进宽度系列 300
|
|
int identArray[]={0, 300, 400, 500, 600, 700, 800, 900};
|
|
for(i=0; i<ELEMENTS(identArray); i++) {
|
|
csItem.Format(_T("%d"), identArray[i]);
|
|
m_lstIndentBox.AddString(csItem);
|
|
}
|
|
}
|
|
|
|
BOOL CBayWindowDlg::OnInitDialog()
|
|
{
|
|
CInsertOpeningDlg::OnInitDialog();
|
|
|
|
InitComboxes();
|
|
|
|
// sg modify 101222,根据8.5需求,增加“出挑长”、“挡板厚”控件提示语
|
|
AddTip(IDC_STATIC_PROTRUDE_LEN, _T("墙体结构层到窗台板外侧(或挡板结构层)距离"));
|
|
AddTip(IDC_STATIC_BAFFLE_LEN, _T("无论挡板是否加保温,此厚度仅为挡板结构层的厚度"));
|
|
|
|
// add by xly on 110113 已有洞口插入灰显
|
|
m_toolbar.EnableButton(ID_HASHOLE_INSERT, FALSE);
|
|
|
|
UpdateData(FALSE); //显示幻灯
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
|
|
// 改变类型时显示幻灯
|
|
void CBayWindowDlg::OnSelchangeStyle()
|
|
{
|
|
CWnd *pImageBox=GetDlgItem(IDC_SLIDE);
|
|
const TCHAR *pBayWinSlide[4]={_T("trapezia"), _T("triangle"), _T("proarc"), _T("prorect")};
|
|
int nIdx=m_lstStyleBox.GetCurSel();
|
|
if (pImageBox && (nIdx>=0 && nIdx<=3)) {
|
|
CDC *pDC=pImageBox->GetDC();
|
|
CRect rc;
|
|
pImageBox->GetClientRect(&rc);
|
|
m_slide.InitDC(pDC, rc, GetAcadBackColor());
|
|
|
|
m_slide.PaintSlide(XString(_T("TArch(%s)"), pBayWinSlide[nIdx]));
|
|
m_slide.SetDC(NULL);
|
|
pImageBox->ReleaseDC(pDC);
|
|
//DisplaySlide(pImageBox, XString(_T("AEC(%s)"), pBayWinSlide[nIdx]));
|
|
|
|
BOOL bEnable=(nIdx==0);
|
|
m_lstIndentBox.EnableWindow(bEnable);
|
|
}
|
|
GetDlgItem(IDC_LEFT_SLAB)->EnableWindow(nIdx==3);
|
|
GetDlgItem(IDC_RIGHT_SLAB)->EnableWindow(nIdx==3);
|
|
}
|
|
|
|
|
|
|
|
void CBayWindowDlg::OnPaint()
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
CRect rcClip, rcImage;
|
|
dc.GetClipBox(&rcClip);
|
|
CWnd *pImageBox=GetDlgItem(IDC_SLIDE);
|
|
if (pImageBox) {
|
|
pImageBox->GetWindowRect(&rcImage);
|
|
ScreenToClient(&rcImage);
|
|
if (!rcImage.IntersectRect(&rcImage, &rcClip))
|
|
return;
|
|
CDC *pDC=pImageBox->GetDC();
|
|
m_slide.SetDC(pDC);
|
|
m_slide.Redraw();
|
|
m_slide.SetDC(NULL);
|
|
pImageBox->ReleaseDC(pDC);
|
|
}
|
|
|
|
// Do not call CInsertOpeningDlg::OnPaint() for painting messages
|
|
}
|
|
void CBayWindowDlg::OnLeftSlab()//add by fxj 09505
|
|
{
|
|
s_bLeftSlab=!s_bLeftSlab;
|
|
GetDlgItem(IDC_SLAB_THICK)->EnableWindow(s_bLeftSlab||s_bRightSlab);
|
|
|
|
|
|
}
|
|
void CBayWindowDlg::OnRightSlab()//add by fxj 09505
|
|
{
|
|
s_bRightSlab=!s_bRightSlab;
|
|
GetDlgItem(IDC_SLAB_THICK)->EnableWindow(s_bLeftSlab||s_bRightSlab);
|
|
}
|
|
///////////////////////////////////////////////////////////
|
|
// 根据给定的门窗, 设置对话框参数
|
|
BOOL CBayWindowDlg::SetDlgParamFrom(const TDbOpening &op)
|
|
{
|
|
if (!CInsertOpeningDlg::SetDlgParamFrom(op) || !op.m_pBayWin)
|
|
return FALSE;
|
|
|
|
// 更新凸窗特有的参数
|
|
*(XBayWindow *)this = *op.m_pBayWin;
|
|
s_bLeftSlab=op.HasLeftSlab();
|
|
s_bRightSlab=op.HasRightSlab();
|
|
s_fSlabThick=op.GetProWinSlabWidth(0);//add by fxj 090505
|
|
return TRUE;
|
|
}
|
|
|
|
// 用对话框上的参数更新实体数据
|
|
BOOL CBayWindowDlg::ModifyOpeningWithDlgParam(TDbOpening &op)
|
|
{
|
|
if (CInsertOpeningDlg::ModifyOpeningWithDlgParam(op))
|
|
{
|
|
if (op.GetKind()==TOpeningData::OP_PROWIN && !op.m_pBayWin)
|
|
op.m_pBayWin=AllocBayWinData();
|
|
|
|
XBayWinStyle nOldStyle = op.m_pBayWin->m_nStyle; // 保留旧的凸窗样式
|
|
|
|
if (op.m_pBayWin) {
|
|
int nUsageFlag=GetUsage();
|
|
if (nUsageFlag==USE_EDIT || GetParamCheck(IDC_STYLE))
|
|
op.m_pBayWin->m_nStyle=m_nStyle;
|
|
if (nUsageFlag==USE_EDIT || GetParamCheck(IDC_IDENT))
|
|
op.m_pBayWin->m_nTrapezia=m_nTrapezia;
|
|
if (nUsageFlag==USE_EDIT || GetParamCheck(IDC_PROTRUDE))
|
|
op.m_pBayWin->m_nProtrude = m_nProtrude;
|
|
}
|
|
|
|
if (m_nStyle==4)//add by whl on 051227
|
|
{
|
|
BOOL bOldHasSlab = op.HasLeftSlab() || op.HasRightSlab(); // 保留旧的挡板情况
|
|
|
|
if (!s_bLeftSlab&&!s_bRightSlab)
|
|
op.SetSideSlab(0);
|
|
else if (s_bLeftSlab&&s_bRightSlab)
|
|
op.SetSideSlab(1);
|
|
else if (s_bLeftSlab&&!s_bRightSlab)
|
|
op.SetSideSlab(2);
|
|
else
|
|
op.SetSideSlab(3);
|
|
|
|
//add by fxj 090505
|
|
if (s_bLeftSlab||s_bRightSlab)
|
|
{
|
|
op.SetProWinSlabWidth(s_fSlabThick);
|
|
|
|
// sg add 110223,当由其他样式改成矩形凸窗,新给矩形凸窗增加挡板后,设置默认挡板保温厚
|
|
if ((nOldStyle!=BWS_RECT) || (!bOldHasSlab))
|
|
{
|
|
extern TARCH_IMPEXP double g_dProWinSlabInsuThick;
|
|
op.SetProWinSlabInsuThick(g_dProWinSlabInsuThick); // 设置凸窗默认保温厚
|
|
}
|
|
}
|
|
}
|
|
else
|
|
op.SetSideSlab(0);
|
|
|
|
// sg add 110804,增加下面的代码,主要是为了解决凸窗对象编辑的时候,需要根据型式、出挑长和梯形宽等,确定是否要更新编号
|
|
// CInsertOpeningDlg::ModifyOpeningWithDlgParam函数中,其实有这些代码,但是更新的数据不全,只有宽度和高度会考虑
|
|
if (GetUsage()==USE_EDIT || GetParamCheck(IDC_LABEL))
|
|
{
|
|
if (_tcscmp(_T("自动编号"),GetOpeningLabel())==0)
|
|
{
|
|
op.SetLabel(CalcAutoLabel(&op));
|
|
}
|
|
else
|
|
op.SetLabel(GetOpeningLabel());
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
XBayWindow *CBayWindowDlg::AllocBayWinData()
|
|
{
|
|
return new XBayWindow(*this);
|
|
}
|
|
void CBayWindowDlg::UpdateOpening(TDbOpening &op, BOOL bLoadStyle)
|
|
{
|
|
CInsertOpeningDlg::UpdateOpening(op,bLoadStyle);
|
|
|
|
if (m_nStyle==4)//add by whl on 051227
|
|
{
|
|
if (!s_bLeftSlab&&!s_bRightSlab)
|
|
op.SetSideSlab(0);
|
|
else if (s_bLeftSlab&&s_bRightSlab)
|
|
op.SetSideSlab(1);
|
|
else if (s_bLeftSlab&&!s_bRightSlab)
|
|
op.SetSideSlab(2);
|
|
else
|
|
op.SetSideSlab(3);
|
|
|
|
//add by fxj 090505
|
|
if (s_bLeftSlab||s_bRightSlab)
|
|
{
|
|
op.SetProWinSlabWidth(s_fSlabThick);
|
|
|
|
// sg add 110223,给矩形凸窗设置默认挡板保温厚
|
|
extern TARCH_IMPEXP double g_dProWinSlabInsuThick;
|
|
op.SetProWinSlabInsuThick(g_dProWinSlabInsuThick); // 设置凸窗默认保温厚
|
|
}
|
|
}
|
|
else
|
|
op.SetSideSlab(0);
|
|
|
|
op.SetLabel(GetAutoLabel(&op));
|
|
|
|
}
|
|
int CBayWindowDlg::GetOpeningKind() const
|
|
{
|
|
return TOpeningData::OP_PROWIN;
|
|
}
|
|
|
|
int CBayWindowDlg::ObjToDlg(TDbOpening* pOpening)
|
|
{
|
|
CInsertOpeningDlg::ObjToDlg(pOpening);
|
|
m_csWinDoorType = pOpening->GetSubKind();
|
|
m_nStyle = pOpening->m_pBayWin->m_nStyle;
|
|
m_nProtrude = pOpening->m_pBayWin->m_nProtrude;
|
|
m_nTrapezia = pOpening->m_pBayWin->m_nTrapezia;
|
|
|
|
s_bLeftSlab=pOpening->HasLeftSlab();
|
|
s_bRightSlab=pOpening->HasRightSlab();
|
|
s_fSlabThick=pOpening->GetProWinSlabWidth(0);
|
|
UpdateData(FALSE);
|
|
return 1;
|
|
}
|
|
|
|
// 关键注册位置, 子类需要重载本方法
|
|
BOOL CBayWindowDlg::GetRegLocation(XString &sRegLoc) const
|
|
{
|
|
sRegLoc=_T("BayWindow");
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CBayWindowDlg::InitParamList(DList<XOpeningParam> &lstParam) const
|
|
{
|
|
lstParam.Append(new XOpeningParam(IDC_STYLE, _T("型式")));
|
|
CInsertOpeningDlg::InitParamList(lstParam);
|
|
lstParam.Append(new XOpeningParam(IDC_PROTRUDE, _T("凸出宽")));
|
|
lstParam.Append(new XOpeningParam(IDC_IDENT, _T("梯形宽")));
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// 从注册表读入参数
|
|
BOOL CBayWindowDlg::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);
|
|
|
|
int ns=3;
|
|
if (!regProp.GetValue(_T("BayWinStyle"), ns) ||
|
|
!regProp.GetValue(_T("Protrude"), m_nProtrude) ||
|
|
!regProp.GetValue(_T("Trapezia"), m_nTrapezia) )
|
|
return FALSE;
|
|
m_nStyle = (XBayWinStyle)ns;
|
|
return TRUE;
|
|
}
|
|
|
|
// 把最近的参数写入注册表
|
|
BOOL CBayWindowDlg::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);
|
|
regProp.SetValue(_T("BayWinStyle"), (int)m_nStyle);
|
|
regProp.SetValue(_T("Protrude"), m_nProtrude);
|
|
regProp.SetValue(_T("Trapezia"), m_nTrapezia);
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void TestBayWin()
|
|
{
|
|
CAcModuleResourceOverride vTemp;
|
|
CBayWindowDlg dlg(acedGetAcadFrame());
|
|
dlg.DoModal();
|
|
}
|
|
|
|
|
|
|
|
// Command: 插入凸窗
|
|
void InsBayWin()
|
|
{
|
|
}
|
|
|
|
|
|
|
|
|
|
|