692 lines
17 KiB
C++
692 lines
17 KiB
C++
// DormerDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "resource.h"
|
|
#include "DormerDlg.h"
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static TCHAR THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
|
|
int FindStringInArray(CStringArray &arLabel, CString s);
|
|
void SortString(CStringArray &arString);
|
|
bool CheckDoorWinLabel(CString strName);
|
|
int GetSequenceNum(CString strlabel);
|
|
|
|
void GetDormerIdList(DList<AcDbDatabase> &dbList, DList<AcDbObjectId> &idList)
|
|
{
|
|
XStringList lstFiles;
|
|
::GetFloorFiles(lstFiles);
|
|
CString sCurDwg=curDoc()->fileName();
|
|
for(int i=0; i<lstFiles.Length(); i++)
|
|
{
|
|
CString sDwgDump = lstFiles[i];
|
|
if (_tcsicmp(sCurDwg, sDwgDump)==0)
|
|
continue; // Disalbe CurDwg
|
|
AcDbDatabase *dwgDb=new AcDbDatabase(false, true);
|
|
dbList.Append(dwgDb);
|
|
#if ADS < 21
|
|
if (dwgDb->readDwgFile(sDwgDump, _SH_DENYNO, false)==Acad::eOk)
|
|
#else
|
|
if (dwgDb->readDwgFile(sDwgDump, AcDbDatabase::kForReadAndAllShare, false)==Acad::eOk)
|
|
#endif
|
|
{
|
|
GetEntityFromDatabase(idList, *dwgDb, _T("TCH_DORMER"), 0, ACDB_MODEL_SPACE);
|
|
}
|
|
}
|
|
GetEntFromBlockByDxf(idList, _T("TCH_DORMER"));
|
|
}
|
|
|
|
void GetLabelAry(DList<AcDbObjectId> &idList, CStringArray &arDormerData)
|
|
{
|
|
arDormerData.RemoveAll();
|
|
|
|
for (int i = 0; i < idList.Length(); i++)
|
|
{
|
|
AcDbObjectId &id = *idList[i];
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbDormer, pDormer);
|
|
if (pDormer != NULL)
|
|
{
|
|
CString sDormer = pDormer->GetLabel();
|
|
sDormer.TrimLeft();
|
|
sDormer.TrimRight();
|
|
if (sDormer.IsEmpty())
|
|
continue;
|
|
if (FindStringInArray(arDormerData, sDormer) == -1)
|
|
{
|
|
arDormerData.Add(sDormer);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
#define S_DORMER_AUTOLABEL (_T("自动编号"))
|
|
|
|
CDormerDlg::CDormerDlg(CString sTitle,CWnd* pParent /*=NULL*/)
|
|
: GlwCAcUiDialog(CDormerDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CDormerDlg)
|
|
m_nDormerType = -1;
|
|
m_sEaves = _T("");
|
|
m_sFloor = _T("");
|
|
m_sGlass = _T("");
|
|
m_sRoof = _T("");
|
|
m_sWall = _T("");
|
|
m_sWindow = _T("");
|
|
m_bShowWindow = TRUE;
|
|
m_sExtendEaves = _T("");
|
|
m_sExtendHill = _T("");
|
|
m_sSlopeGrade = _T("");
|
|
m_sSlopeHeight = _T("");
|
|
m_sSlopeThickness = _T("");
|
|
m_sWallHeight = _T("");
|
|
m_sWallThickness = _T("");
|
|
m_sWallWidth = _T("");
|
|
m_sWindowWidth = _T("");
|
|
m_sWindowHeight = _T("");
|
|
//}}AFX_DATA_INIT
|
|
m_sTitle = sTitle;
|
|
|
|
SetDefaultLabel();
|
|
}
|
|
|
|
|
|
void CDormerDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CDormerDlg)
|
|
DDX_CBIndex(pDX, IDC_DORMERTYPE, m_nDormerType);
|
|
DDX_CBString(pDX, IDC_COMBO_EAVES, m_sEaves);
|
|
DDX_CBString(pDX, IDC_COMBO_FLOOR, m_sFloor);
|
|
DDX_CBString(pDX, IDC_COMBO_GLASS, m_sGlass);
|
|
DDX_CBString(pDX, IDC_COMBO_ROOF, m_sRoof);
|
|
DDX_CBString(pDX, IDC_COMBO_WALL, m_sWall);
|
|
DDX_CBString(pDX, IDC_COMBO_WINDOW, m_sWindow);
|
|
DDX_Check(pDX, IDC_CHECK_SHOWWINDOW, m_bShowWindow);
|
|
DDX_Control(pDX, IDC_COMBO_WINDOW, m_comboWindow);
|
|
DDX_Control(pDX, IDC_COMBO_WALL, m_comboWall);
|
|
DDX_Control(pDX, IDC_COMBO_ROOF, m_comboRoof);
|
|
DDX_Control(pDX, IDC_COMBO_GLASS, m_comboGlass);
|
|
DDX_Control(pDX, IDC_COMBO_FLOOR, m_comboFloor);
|
|
DDX_Control(pDX, IDC_COMBO_EAVES, m_comboEaves);
|
|
DDX_Control(pDX, IDC_EDIT1_WINDOWHEIGHT, m_ctrlWindowHeight);
|
|
DDX_Control(pDX, IDC_EDIT_WINDOWWIDTH, m_ctrlWindowWidth);
|
|
DDX_Control(pDX, IDC_EDIT_WALLWIDTH, m_ctrlWallWidth);
|
|
DDX_Control(pDX, IDC_EDIT_WALLTHICKNESS, m_ctrlWallThickness);
|
|
DDX_Control(pDX, IDC_EDIT_WALLHEIGHT, m_ctrlWallHeight);
|
|
DDX_Control(pDX, IDC_EDIT_SLOPETHICKNESS, m_ctrlSlopeThickness);
|
|
DDX_Control(pDX, IDC_EDIT_SLOPEHEIGHT, m_ctrlSlopeHeight);
|
|
DDX_Control(pDX, IDC_EDIT_SLOPEGRADE, m_ctrlSlopeGrade);
|
|
DDX_Control(pDX, IDC_EDIT_EXTENDHILL, m_ctrlExtendHill);
|
|
DDX_Control(pDX, IDC_EDIT_EXTENDEAVES, m_ctrlExtendEaves);
|
|
DDX_Control(pDX, IDC_LABEL, m_cmbLabel);
|
|
DDX_Text(pDX, IDC_EDIT_EXTENDEAVES, m_sExtendEaves);
|
|
DDX_Text(pDX, IDC_EDIT_EXTENDHILL, m_sExtendHill);
|
|
DDX_Text(pDX, IDC_EDIT_SLOPEGRADE, m_sSlopeGrade);
|
|
DDX_Text(pDX, IDC_EDIT_SLOPEHEIGHT, m_sSlopeHeight);
|
|
DDX_Text(pDX, IDC_EDIT_SLOPETHICKNESS, m_sSlopeThickness);
|
|
DDX_Text(pDX, IDC_EDIT_WALLHEIGHT, m_sWallHeight);
|
|
DDX_Text(pDX, IDC_EDIT_WALLTHICKNESS, m_sWallThickness);
|
|
DDX_Text(pDX, IDC_EDIT_WALLWIDTH, m_sWallWidth);
|
|
DDX_Text(pDX, IDC_EDIT_WINDOWWIDTH, m_sWindowWidth);
|
|
DDX_Text(pDX, IDC_EDIT1_WINDOWHEIGHT, m_sWindowHeight);
|
|
//}}AFX_DATA_MAP
|
|
DDX_CBString(pDX, IDC_LABEL, m_csLabel);
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDormerDlg, GlwCAcUiDialog)
|
|
//{{AFX_MSG_MAP(CDormerDlg)
|
|
ON_CBN_SELCHANGE(IDC_DORMERTYPE, OnSelchangeDormerType)
|
|
ON_WM_PAINT()
|
|
ON_BN_CLICKED(IDC_CHECK_SHOWWINDOW, OnCheckShowWindow)
|
|
ON_EN_CHANGE(IDC_EDIT_SLOPEGRADE, OnChangeEditSlopeGrade)
|
|
ON_EN_CHANGE(IDC_EDIT_WALLWIDTH, OnChangeEditWallWidth)
|
|
ON_EN_CHANGE(IDC_EDIT_WINDOWWIDTH, OnChangeEditWindowWidth)
|
|
ON_CBN_SELCHANGE(IDC_LABEL, OnSelChangeLabel)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
BOOL CDormerDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
SetWindowText(m_sTitle);
|
|
XSymbolList lstLayer(_T("LAYER"));
|
|
lstLayer.QuickSort(_tcsicmp);
|
|
for(int i=0;i<lstLayer.Length();i++) {
|
|
m_comboWindow.AddString(lstLayer[i]);
|
|
m_comboWall.AddString(lstLayer[i]);
|
|
m_comboRoof.AddString(lstLayer[i]);
|
|
m_comboGlass.AddString(lstLayer[i]);
|
|
m_comboFloor.AddString(lstLayer[i]);
|
|
m_comboEaves.AddString(lstLayer[i]);
|
|
}
|
|
ResetLabelCombox();
|
|
|
|
if (m_bUseDefaultLabel)
|
|
{
|
|
m_csLabel = m_strDefaultlabel;
|
|
}
|
|
else
|
|
{
|
|
m_cmbLabel.GetLBText(0, m_csLabel);
|
|
ReadParamFromRegistry();
|
|
}
|
|
|
|
UpdateWindow();
|
|
UpdateData(FALSE);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
//类型
|
|
void CDormerDlg::SetDormerType(TDormerPar::DormerType dormerType)
|
|
{
|
|
switch (dormerType) {
|
|
case TDormerPar::SLOPE_TRIANGLE:
|
|
m_nDormerType = 0;
|
|
break;
|
|
case TDormerPar::SLOPE_TWO:
|
|
m_nDormerType = 1;
|
|
break;
|
|
case TDormerPar::SLOPE_THREE:
|
|
m_nDormerType = 2;
|
|
break;
|
|
case TDormerPar::SLOPE_TRAPEZIA:
|
|
m_nDormerType = 3;
|
|
break;
|
|
case TDormerPar::SLOPE_FLAT:
|
|
m_nDormerType = 4;
|
|
break;
|
|
default:
|
|
m_nDormerType = 1;
|
|
}
|
|
}
|
|
|
|
TDormerPar::DormerType CDormerDlg::GetDormerType() const
|
|
{
|
|
TDormerPar::DormerType dormerType=TDormerPar::SLOPE_TWO;
|
|
|
|
switch(m_nDormerType) {
|
|
case 0:
|
|
dormerType = TDormerPar::SLOPE_TRIANGLE;
|
|
break;
|
|
case 1:
|
|
dormerType = TDormerPar::SLOPE_TWO;
|
|
break;
|
|
case 2:
|
|
dormerType = TDormerPar::SLOPE_THREE;
|
|
break;
|
|
case 3:
|
|
dormerType = TDormerPar::SLOPE_TRAPEZIA;
|
|
break;
|
|
case 4:
|
|
dormerType = TDormerPar::SLOPE_FLAT;
|
|
break;
|
|
default:
|
|
dormerType = TDormerPar::SLOPE_TWO;
|
|
}
|
|
|
|
return dormerType;
|
|
}
|
|
|
|
void CDormerDlg::GetDormerPar(TDormerPar& dormerPar) const
|
|
{
|
|
//类型
|
|
dormerPar.SetDormerType(GetDormerType());
|
|
|
|
//墙
|
|
dormerPar.SetWallHeight(_tstof(m_sWallHeight)-_tstof(m_sSlopeThickness));
|
|
dormerPar.SetWallWidth(_tstof(m_sWallWidth));
|
|
dormerPar.SetWallThickness(_tstof(m_sWallThickness));
|
|
|
|
//窗
|
|
dormerPar.SetWindowHeight(_tstof(m_sWindowHeight));
|
|
dormerPar.SetWindowWidth(_tstof(m_sWindowWidth));
|
|
|
|
//坡
|
|
dormerPar.SetSlopeGrade(_tstof(m_sSlopeGrade));
|
|
dormerPar.SetSlopeHeight(_tstof(m_sSlopeHeight));
|
|
dormerPar.SetSlopeThickness(_tstof(m_sSlopeThickness));
|
|
|
|
//伸出长度
|
|
dormerPar.SetExtendEaves(_tstof(m_sExtendEaves));
|
|
dormerPar.SetExtendHill(_tstof(m_sExtendHill));
|
|
}
|
|
|
|
void CDormerDlg::SetDormerPar(const TDormerPar& dormerPar)
|
|
{
|
|
//类型
|
|
SetDormerType(dormerPar.GetDormerType());
|
|
|
|
//墙
|
|
m_sWallHeight = (const TCHAR *)
|
|
Dist2Str(dormerPar.GetWallHeight()+dormerPar.GetSlopeThickness());
|
|
m_sWallWidth = (const TCHAR *)
|
|
Dist2Str(dormerPar.GetWallWidth());
|
|
m_sWallThickness = (const TCHAR *)
|
|
Dist2Str(dormerPar.GetWallThickness());
|
|
|
|
//窗
|
|
m_sWindowHeight = (const TCHAR *)
|
|
Dist2Str(dormerPar.GetWindowHeight());
|
|
m_sWindowWidth = (const TCHAR *)
|
|
Dist2Str(dormerPar.GetWindowWidth());
|
|
|
|
//坡
|
|
m_sSlopeGrade.Format(_T("%.2f"),dormerPar.GetSlopeGrade());
|
|
m_sSlopeHeight = (const TCHAR *)
|
|
Dist2Str(dormerPar.GetSlopeHeight());
|
|
m_sSlopeThickness = (const TCHAR *)
|
|
Dist2Str(dormerPar.GetSlopeThickness());
|
|
|
|
//伸出长度
|
|
m_sExtendEaves = (const TCHAR *)
|
|
Dist2Str(dormerPar.GetExtendEaves());
|
|
m_sExtendHill = (const TCHAR *)
|
|
Dist2Str(dormerPar.GetExtendHill());
|
|
}
|
|
|
|
void CDormerDlg::SetDormerLayer(const TDormerLayer& dormerLayer)
|
|
{
|
|
m_sEaves = dormerLayer.GetEavesName();
|
|
m_sFloor = dormerLayer.GetFloorName();
|
|
m_sGlass = dormerLayer.GetGlassName();
|
|
m_sRoof = dormerLayer.GetRoofName();
|
|
m_sWall = dormerLayer.GetWallName();
|
|
m_sWindow = dormerLayer.GetWindowName();
|
|
/*
|
|
if (m_sEaves.IsEmpty()) {
|
|
m_sEaves = _T("3D_EAVES");
|
|
InitLayer(m_sEaves,FALSE);
|
|
}
|
|
if (m_sFloor.IsEmpty()) {
|
|
m_sFloor = "3D_CEILING";
|
|
InitLayer(m_sFloor,FALSE);
|
|
}
|
|
if (m_sGlass.IsEmpty()) {
|
|
m_sGlass = LAY_3DGLASS;
|
|
InitLayer(m_sGlass,FALSE);
|
|
}
|
|
if (m_sRoof.IsEmpty()) {
|
|
m_sRoof = LAY_ROOF;
|
|
InitLayer(m_sRoof,FALSE);
|
|
}
|
|
if (m_sWindow.IsEmpty()) {
|
|
m_sWindow = LAY_3DFRAME;
|
|
InitLayer(LAY_3DFRAME);
|
|
}
|
|
if (m_sWall.IsEmpty()) {
|
|
m_sWall = LAY_WALL;
|
|
InitLayer(m_sWall,FALSE);
|
|
}*/
|
|
}
|
|
|
|
void CDormerDlg::GetDormerLayer(TDormerLayer& dormerLayer) const
|
|
{
|
|
dormerLayer.SetEaves((const TCHAR *)m_sEaves);
|
|
dormerLayer.SetFloor((const TCHAR *)m_sFloor);
|
|
dormerLayer.SetGlass((const TCHAR *)m_sGlass);
|
|
dormerLayer.SetRoof((const TCHAR *)m_sRoof);
|
|
dormerLayer.SetWall((const TCHAR *)m_sWall);
|
|
dormerLayer.SetWindow((const TCHAR *)m_sWindow);
|
|
}
|
|
|
|
void CDormerDlg::SetShowWindow(BOOL bShow)
|
|
{
|
|
m_bShowWindow = bShow;
|
|
}
|
|
|
|
BOOL CDormerDlg::IsShowWindow() const
|
|
{
|
|
return m_bShowWindow;
|
|
}
|
|
|
|
void CDormerDlg::UpdateWindow()
|
|
{
|
|
switch(m_nDormerType) {
|
|
case 0:
|
|
m_ctrlSlopeGrade.EnableWindow(TRUE);
|
|
m_ctrlSlopeHeight.EnableWindow(FALSE);
|
|
m_ctrlWallHeight.EnableWindow(FALSE);
|
|
m_ctrlWindowHeight.EnableWindow(FALSE);
|
|
m_ctrlWindowWidth.EnableWindow(FALSE);
|
|
m_ctrlExtendEaves.EnableWindow(FALSE);
|
|
OpenSlide(_T("TArch(DMTRIANGLE)"));
|
|
break;
|
|
case 1:
|
|
m_ctrlSlopeGrade.EnableWindow(TRUE);
|
|
m_ctrlSlopeHeight.EnableWindow(FALSE);
|
|
m_ctrlWallHeight.EnableWindow(TRUE);
|
|
m_ctrlWindowHeight.EnableWindow(TRUE);
|
|
m_ctrlWindowWidth.EnableWindow(TRUE);
|
|
m_ctrlExtendEaves.EnableWindow(TRUE);
|
|
OpenSlide(_T("TArch(DMDOUBLE)"));
|
|
break;
|
|
case 2:
|
|
m_ctrlSlopeGrade.EnableWindow(TRUE);
|
|
m_ctrlSlopeHeight.EnableWindow(FALSE);
|
|
m_ctrlWallHeight.EnableWindow(TRUE);
|
|
m_ctrlWindowHeight.EnableWindow(TRUE);
|
|
m_ctrlWindowWidth.EnableWindow(TRUE);
|
|
m_ctrlExtendEaves.EnableWindow(TRUE);
|
|
OpenSlide(_T("TArch(DMTRISLOPE)"));
|
|
break;
|
|
case 3:
|
|
m_ctrlSlopeGrade.EnableWindow(TRUE);
|
|
m_ctrlSlopeHeight.EnableWindow(TRUE);
|
|
m_ctrlWallHeight.EnableWindow(TRUE);
|
|
m_ctrlWindowHeight.EnableWindow(TRUE);
|
|
m_ctrlWindowWidth.EnableWindow(TRUE);
|
|
m_ctrlExtendEaves.EnableWindow(TRUE);
|
|
OpenSlide(_T("TArch(DMTRAP)"));
|
|
break;
|
|
case 4:
|
|
m_ctrlSlopeGrade.EnableWindow(FALSE);
|
|
m_ctrlSlopeHeight.EnableWindow(FALSE);
|
|
m_ctrlWallHeight.EnableWindow(TRUE);
|
|
m_ctrlWindowHeight.EnableWindow(TRUE);
|
|
m_ctrlWindowWidth.EnableWindow(TRUE);
|
|
m_ctrlExtendEaves.EnableWindow(TRUE);
|
|
OpenSlide(_T("TArch(DMFLATWIN)"));
|
|
break;
|
|
default:
|
|
m_ctrlSlopeGrade.EnableWindow(TRUE);
|
|
m_ctrlSlopeHeight.EnableWindow(FALSE);
|
|
m_ctrlWallHeight.EnableWindow(TRUE);
|
|
m_ctrlWindowHeight.EnableWindow(TRUE);
|
|
m_ctrlWindowWidth.EnableWindow(TRUE);
|
|
m_ctrlExtendEaves.EnableWindow(TRUE);
|
|
OpenSlide(_T("TArch(DMDOUBLE)"));
|
|
}
|
|
if (!m_bShowWindow) {
|
|
m_ctrlWindowHeight.EnableWindow(FALSE);
|
|
m_ctrlWindowWidth.EnableWindow(FALSE);
|
|
}
|
|
}
|
|
|
|
void CDormerDlg::OnSelchangeDormerType()
|
|
{
|
|
UpdateData(TRUE);
|
|
UpdateWindow();
|
|
}
|
|
void CDormerDlg::OnPaint()
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
CRect rcClip, rcImage;
|
|
dc.GetClipBox(&rcClip);
|
|
CWnd *pImageBox=GetDlgItem(IDC_IMAGE);
|
|
if (pImageBox) {
|
|
pImageBox->GetWindowRect(&rcImage);
|
|
ScreenToClient(&rcImage);
|
|
if (!rcImage.IntersectRect(&rcImage, &rcClip))
|
|
return;
|
|
CDC *pDC=pImageBox->GetDC();
|
|
m_slideDc.SetDC(pDC);
|
|
m_slideDc.Redraw();
|
|
m_slideDc.SetDC(NULL);
|
|
pImageBox->ReleaseDC(pDC);
|
|
}
|
|
}
|
|
|
|
void CDormerDlg::OpenSlide(XString sFilePath)
|
|
{
|
|
CWnd *pImageBox=GetDlgItem(IDC_IMAGE);
|
|
if (pImageBox) {
|
|
CDC *pDC=pImageBox->GetDC();
|
|
CRect rc;
|
|
pImageBox->GetClientRect(&rc);
|
|
m_slideDc.InitDC(pDC, rc, GetAcadBackColor());
|
|
m_slideDc.PaintSlide(sFilePath);
|
|
m_slideDc.SetDC(NULL);
|
|
pImageBox->ReleaseDC(pDC);
|
|
}
|
|
}
|
|
|
|
void CDormerDlg::OnOK()
|
|
{
|
|
UpdateData(TRUE);
|
|
if (_tstof(m_sWindowHeight) > _tstof(m_sWallHeight)) {
|
|
AfxMessageBox(_T("窗的高度不能大于墙的高度!"));
|
|
return;
|
|
}
|
|
if (_tstof(m_sWindowWidth) > _tstof(m_sWallWidth)-_tstof(m_sWallThickness)*2) {
|
|
AfxMessageBox(_T("窗的宽度不能大于内墙的宽度!"));
|
|
return;
|
|
}
|
|
if (m_nDormerType==0 && _tstof(m_sSlopeGrade)<=0) {
|
|
AfxMessageBox(_T("坡度必须大于零!"));
|
|
return;
|
|
}
|
|
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
|
|
void CDormerDlg::OnCheckShowWindow()
|
|
{
|
|
UpdateData(TRUE);
|
|
UpdateWindow();
|
|
}
|
|
|
|
void CDormerDlg::UpdateParameter()
|
|
{
|
|
UpdateData(TRUE);
|
|
if (m_nDormerType==0) {
|
|
m_sSlopeHeight = (const TCHAR *)
|
|
Dist2Str(_tstof(m_sWallWidth)*_tstof(m_sSlopeGrade)/2);
|
|
m_sWallHeight = m_sSlopeHeight;
|
|
m_sWindowHeight = (const TCHAR *)
|
|
Dist2Str(_tstof(m_sWindowWidth)*_tstof(m_sSlopeGrade)/2);
|
|
}
|
|
else if (m_nDormerType==1 || m_nDormerType==2 ){
|
|
m_sSlopeHeight = (const TCHAR *)
|
|
Dist2Str(_tstof(m_sWallWidth)*_tstof(m_sSlopeGrade)/2);
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CDormerDlg::OnChangeEditSlopeGrade()
|
|
{
|
|
UpdateParameter();
|
|
}
|
|
|
|
void CDormerDlg::OnChangeEditWallWidth()
|
|
{
|
|
UpdateParameter();
|
|
}
|
|
|
|
void CDormerDlg::OnChangeEditWindowWidth()
|
|
{
|
|
UpdateParameter();
|
|
}
|
|
|
|
void CDormerDlg::ResetLabelCombox()
|
|
{
|
|
DList<AcDbDatabase> databaseLst;
|
|
DList<AcDbObjectId> idLst;
|
|
GetDormerIdList(databaseLst, idLst);
|
|
|
|
CStringArray arDormerData;
|
|
GetLabelAry(idLst, arDormerData);
|
|
|
|
m_cmbLabel.ResetContent();
|
|
m_cmbLabel.AddString(_T("自动编号"));
|
|
SortString(arDormerData);
|
|
for (int i = 0; i < arDormerData.GetSize(); i++)
|
|
{
|
|
m_cmbLabel.AddString(arDormerData[i]);
|
|
}
|
|
}
|
|
|
|
// 每种类型都需要有一个函数来判断是否应该采用同名的编号
|
|
bool TestCanSameLabel(TDbDormer *pDormer, double dWid, double dHei)
|
|
{
|
|
if (pDormer == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const TDormerPar &dorPar = pDormer->GetDormerPar();
|
|
|
|
double dWidOld = dorPar.GetWindowWidth();
|
|
double dHeiOld = dorPar.GetWindowHeight();
|
|
|
|
if (fabs(dWidOld - dWid) < 1e-6 && fabs(dHeiOld - dHei) < 1e-6)
|
|
return true;
|
|
else return false;
|
|
}
|
|
|
|
|
|
CString CDormerDlg::GetDormerLabel(TDbDormer &dormer)
|
|
{
|
|
if (m_csLabel.Compare(_T("自动编号")) == 0)
|
|
{ // 自动编号
|
|
bool bReLabel = false;
|
|
TDormerPar dorPar;
|
|
TDormerLayer layer;
|
|
this->GetDormerPar(dorPar);
|
|
this->GetDormerLayer(layer);
|
|
dormer.SetDormerPar(dorPar);
|
|
dormer.SetDormerLayer(layer);
|
|
CString szLabel = dormer.GetAutoLabel(bReLabel);
|
|
if (!bReLabel)
|
|
return szLabel;
|
|
else
|
|
{ // 根据顺序重新编号。
|
|
DList<AcDbDatabase> lstDataBase;
|
|
DList<AcDbObjectId> lstId;
|
|
GetDormerIdList(lstDataBase, lstId);
|
|
|
|
TDormerPar dorPar;
|
|
this->GetDormerPar(dorPar);
|
|
|
|
double dWidOld = dorPar.GetWindowWidth();
|
|
double dHeiOld = dorPar.GetWindowHeight();
|
|
int nBigNum = 1;
|
|
for (int i = 0; i < (int)lstId.Length(); i++)
|
|
{
|
|
AcDbObjectId *pId = lstId[i];
|
|
OPENOBJ_BEGIN(*pId, AcDb::kForRead, TDbDormer, pEnt)
|
|
{
|
|
if (pEnt == NULL)
|
|
continue;
|
|
|
|
CString strLabel = pEnt->GetLabel();
|
|
if (CheckDoorWinLabel(strLabel))
|
|
{
|
|
if (TestCanSameLabel(pEnt, dWidOld, dHeiOld))
|
|
{
|
|
return strLabel;
|
|
}
|
|
else
|
|
{
|
|
int nNum = GetSequenceNum(strLabel) + 1;
|
|
nBigNum = Maximum(int(2), nNum, nBigNum);
|
|
}
|
|
}
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
|
|
szLabel.Format(_T("%s%d"), szLabel, nBigNum);
|
|
return szLabel;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return m_csLabel;
|
|
}
|
|
}
|
|
|
|
|
|
void CDormerDlg::SetDefaultLabel(bool bUseDefaultLabel, CString strDefaultLabel)
|
|
{
|
|
m_strDefaultlabel = strDefaultLabel;
|
|
m_bUseDefaultLabel = bUseDefaultLabel;
|
|
}
|
|
|
|
void CDormerDlg::AfterModelAdded(TDbDormer *pDormer)
|
|
{
|
|
WriteParamToRegistry();
|
|
}
|
|
|
|
|
|
CString CDormerDlg::GetRegLocation() const
|
|
{
|
|
return _T("Dormer");
|
|
}
|
|
|
|
|
|
// 从注册表读入参数
|
|
BOOL CDormerDlg::ReadParamFromRegistry()
|
|
{
|
|
XString sRegSubLoc = this->GetRegLocation(), sRegLoc(1024);
|
|
sRegLoc << ::GetRegLocation() << _T("\\Settings") ;
|
|
CRegProperty regProp(sRegLoc, sRegSubLoc);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
|
|
CString csLab;
|
|
if (!regProp.GetValue(_T("Label"), csLab))
|
|
return FALSE;
|
|
|
|
m_csLabel = csLab;
|
|
return TRUE;
|
|
}
|
|
//把最近的参数写入注册表
|
|
BOOL CDormerDlg::WriteParamToRegistry() const
|
|
{
|
|
XString sRegSubLoc = GetRegLocation(), sRegLoc(1024);
|
|
|
|
sRegLoc << ::GetRegLocation() << _T("\\Settings");
|
|
CRegProperty regProp(sRegLoc, sRegSubLoc);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
|
|
regProp.SetValue(_T("Label"), m_csLabel);
|
|
return TRUE;
|
|
}
|
|
|
|
void CDormerDlg::OnSelChangeLabel()
|
|
{
|
|
int nCurrSel = m_cmbLabel.GetCurSel();
|
|
if (nCurrSel >= 0 )
|
|
{
|
|
// 打开相关文档,然后从中读取数据
|
|
DList<AcDbDatabase> databaseLst;
|
|
DList<AcDbObjectId> idLst;
|
|
GetDormerIdList(databaseLst, idLst);
|
|
|
|
CString sSelLabel;
|
|
m_cmbLabel.GetLBText(nCurrSel, sSelLabel);
|
|
m_cmbLabel.SetWindowText(sSelLabel);
|
|
m_csLabel = sSelLabel;
|
|
if (sSelLabel.Compare(S_DORMER_AUTOLABEL) == 0)
|
|
return;
|
|
|
|
for (int i = 0; i < idLst.Length(); i++)
|
|
{
|
|
AcDbObjectId &id = *(idLst[i]);
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbDormer, pDormer);
|
|
if (pDormer != NULL && sSelLabel.CompareNoCase(pDormer->GetLabel()) == 0 )
|
|
{
|
|
const TDormerPar &dp = pDormer->GetDormerPar();
|
|
m_sWindowHeight.Format(_T("%lg"), dp.GetWindowHeight());
|
|
m_sWindowWidth.Format(_T("%lg"), dp.GetWindowWidth());
|
|
break;
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
}
|