1096 lines
26 KiB
C++
1096 lines
26 KiB
C++
// SPSheet.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "CurtainWallSet.h"
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSPSheet
|
|
IMPLEMENT_DYNAMIC(CSPSheet, CPropertySheet)
|
|
int CSPSheet::cur=0;
|
|
CSPSheet::CSPSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
|
|
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
|
|
{
|
|
CSPSheet::cur=0;
|
|
}
|
|
|
|
CSPSheet::CSPSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
|
|
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
|
|
{
|
|
CSPSheet::cur=0;
|
|
}
|
|
|
|
CSPSheet::~CSPSheet()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CSPSheet, CPropertySheet)
|
|
ON_BN_CLICKED(IDOK, OnOK)
|
|
ON_WM_DESTROY()
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSPSheet message handlers
|
|
|
|
void CSPSheet::OnOK()
|
|
{
|
|
BOOL bOK=true;
|
|
for(long i=0;i<pageList.GetLength()&&bOK;i++)
|
|
{
|
|
if (pageList[i]->GetSafeHwnd()!=NULL)
|
|
bOK=pageList[i]->UpdateData();
|
|
}
|
|
if (bOK)
|
|
{
|
|
cur=pageList.Find(GetActivePage());
|
|
EndDialog(IDOK);
|
|
}
|
|
}
|
|
|
|
void CSPSheet::AddPage(CPropertyPage*pPage)
|
|
{
|
|
pageList.AddTail(pPage);
|
|
CPropertySheet::AddPage(pPage);
|
|
}
|
|
|
|
BOOL CSPSheet::OnInitDialog()
|
|
{
|
|
BOOL bResult = CPropertySheet::OnInitDialog();
|
|
HWND hWnd = ::GetDlgItem(m_hWnd, ID_APPLY_NOW);
|
|
if (hWnd != NULL)
|
|
{
|
|
::ShowWindow(hWnd, SW_HIDE);
|
|
::EnableWindow(hWnd, FALSE);
|
|
}
|
|
hWnd = ::GetDlgItem(m_hWnd, IDHELP);
|
|
if (hWnd != NULL)
|
|
{
|
|
::ShowWindow(hWnd, SW_HIDE);
|
|
::EnableWindow(hWnd, FALSE);
|
|
}
|
|
if (pageList.IsValidIndex(cur))
|
|
SetActivePage(pageList[cur]);
|
|
return bResult;
|
|
}
|
|
|
|
void CSPSheet::OnDestroy()
|
|
{
|
|
while(GetPageCount() > 0)
|
|
{
|
|
RemovePage(0);
|
|
}
|
|
for(long i=0;i<pageList.GetLength();i++)
|
|
{
|
|
if (pageList[i]->GetSafeHwnd()!=NULL)
|
|
{
|
|
pageList[i]->DestroyWindow();
|
|
}
|
|
}
|
|
CPropertySheet::OnDestroy();
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CCurtainWallSet property page
|
|
extern bool SelectString(CComboBox&cb,CString s);
|
|
BOOL CCurtainWallSet::bHAverage = TRUE;
|
|
BOOL CCurtainWallSet::bVAverage = TRUE;
|
|
BOOL CCurtainWallSet::bBotFrame = FALSE;
|
|
BOOL CCurtainWallSet::bTopFrame = FALSE;
|
|
int CCurtainWallSet::hNum = 6;
|
|
int CCurtainWallSet::vNum = 6;
|
|
CString CCurtainWallSet::layer =LAY_3DGLASS;
|
|
IMPLEMENT_DYNCREATE(CCurtainWallSet, CPropertyPage)
|
|
CCurtainWallSet::CCurtainWallSet() : CPropertyPage(CCurtainWallSet::IDD),hListBox(false,30),vListBox(false,30)//modified
|
|
{
|
|
|
|
sHeight = (const TCHAR *)Dist2Str(DocGetLHeight());
|
|
|
|
vListBox.SetRowSel(false);
|
|
hListBox.SetRowSel(false);
|
|
vListBox.SetColFixLength();
|
|
vListBox.SetRowFixLength();
|
|
hListBox.SetColFixLength();
|
|
hListBox.SetRowFixLength();
|
|
hListBox.SetColPosFix();
|
|
vListBox.SetColPosFix();
|
|
hListBox.SetSortEnable(false);
|
|
vListBox.SetSortEnable(false);
|
|
hListBox.SetColNum(2);
|
|
vListBox.SetColNum(2);
|
|
hListBox.SetRowNum(hNum);
|
|
vListBox.SetRowNum(vNum);
|
|
hListBox.GetCol(0).SetReadOnly();
|
|
hListBox.GetCol(0).SetName(_T("行号"));
|
|
hListBox.GetCol(1).SetName(_T("行高"));
|
|
vListBox.GetCol(0).SetReadOnly();
|
|
vListBox.GetCol(0).SetName(_T("列号"));
|
|
vListBox.GetCol(1).SetName(_T("列宽"));
|
|
InitLayer(LAY_3DGLASS, FALSE);
|
|
bCreate=true;
|
|
}
|
|
CCurtainWallSet::~CCurtainWallSet()
|
|
{
|
|
}
|
|
void CCurtainWallSet::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CPropertyPage::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_LAYER, layerCombo);
|
|
DDX_Control(pDX, IDC_VSPIN, vSpin);
|
|
DDX_Control(pDX, IDC_HSPIN, hSpin);
|
|
DDX_Check(pDX, IDC_HCHECK, bHAverage);
|
|
// DDX_Text(pDX, IDC_HNUM, hNum);//del by fxj 090409
|
|
// DDV_MinMaxInt(pDX, hNum, 1, 10000);//del by fxj 090331
|
|
DDX_Text(pDX, IDC_HEIGHT, sHeight);
|
|
DDX_Text(pDX, IDC_LENGTH, sLength);
|
|
DDX_Check(pDX, IDC_VCHECK, bVAverage);
|
|
// DDX_Text(pDX, IDC_VNUM, vNum);//del by fxj 090409
|
|
// DDV_MinMaxInt(pDX, vNum, 1, 10000);//del by fxj 090331
|
|
DDX_Check(pDX, IDC_BOTFRAME, bBotFrame);
|
|
DDX_Check(pDX, IDC_TOPFRAME, bTopFrame);
|
|
DDX_CBString(pDX, IDC_LAYER, layer);
|
|
if (pDX->m_bSaveAndValidate)
|
|
{
|
|
//---------add by fxj 090409---
|
|
CString sHnum,sVnum;
|
|
int iHnum,iVnum;
|
|
DDX_Text(pDX, IDC_HNUM, sHnum);
|
|
DDX_Text(pDX, IDC_VNUM, sVnum);
|
|
|
|
#ifdef UNICODE
|
|
iHnum=_wtoi(sHnum);
|
|
|
|
iVnum=_wtoi(sVnum);
|
|
#else
|
|
iHnum=atoi(sHnum);
|
|
|
|
iVnum=atoi(sVnum);
|
|
#endif
|
|
|
|
if (iHnum>0&&iHnum<10000)
|
|
hNum=iHnum;
|
|
if (iVnum>0&&iVnum<10000)
|
|
vNum=iVnum;
|
|
//---------------------------
|
|
|
|
CString text;
|
|
for(long i=0;i<hNum;i++)
|
|
{
|
|
double temp=hListBox.GetRow(i)[1];
|
|
if (temp<=0.5)
|
|
{
|
|
text.Format(_T("横向第%d分格高度太小!"),i+1);
|
|
AfxMessageBox(text);
|
|
pDX->Fail();
|
|
}
|
|
}
|
|
for(i=0;i<vNum;i++)
|
|
{
|
|
double temp=vListBox.GetRow(i)[1];
|
|
if (temp<=0.5)
|
|
{
|
|
text.Format(_T("竖向第%d分格宽度太小!"),i+1);
|
|
AfxMessageBox(text);
|
|
pDX->Fail();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{//add by fxj 090409
|
|
CString sHnum,sVnum;
|
|
sHnum.Format(_T("%d"),hNum);
|
|
sVnum.Format(_T("%d"),vNum);
|
|
DDX_Text(pDX, IDC_HNUM, sHnum);
|
|
DDX_Text(pDX, IDC_VNUM, sVnum);
|
|
}
|
|
|
|
}
|
|
void CCurtainWallSet::Init(TDbCurtainWall&cWall,bool bOut)
|
|
{
|
|
if (bOut)
|
|
{
|
|
cWall.SetHeight(_tstof(sHeight));
|
|
cWall.SetRowAverage(bHAverage);
|
|
cWall.SetColAverage(bVAverage);
|
|
cWall.SetRowNum(hNum);
|
|
cWall.SetColNum(vNum);
|
|
cWall.SetBotRow(bBotFrame);
|
|
cWall.SetTopRow(bTopFrame);
|
|
CString l0=_T("0");
|
|
cWall.SetLayerGlass3d(layer==l0?NULL:InitLayer(layer, FALSE));
|
|
cWall.m_rowSpaces.Reset();
|
|
cWall.m_colSpaces.Reset();
|
|
if (!bHAverage)
|
|
for(int i=0;i<hNum;i++)
|
|
{
|
|
double *p=new double(hListBox.GetCell(i,1));
|
|
cWall.m_rowSpaces.Append(p);
|
|
}
|
|
if (!bVAverage)
|
|
for(int i=0;i<vNum;i++)
|
|
{
|
|
double *p=new double(vListBox.GetCell(i,1));
|
|
cWall.m_colSpaces.Append(p);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
bCreate=false;
|
|
sHeight=Dist2Str(cWall.GetHeight());//modified
|
|
sLength=Dist2Str(cWall.GetLength());//modified
|
|
bHAverage=cWall.IsRowAverage();
|
|
bVAverage=cWall.IsColAverage();
|
|
hNum=cWall.GetRowNum();hListBox.SetRowNum(hNum);
|
|
hListBox.GetRow(hNum-1).SetReadOnly();
|
|
vNum=cWall.GetColNum();vListBox.SetRowNum(vNum);
|
|
vListBox.GetRow(vNum-1).SetReadOnly();
|
|
bBotFrame=cWall.HasBotRow();
|
|
bTopFrame=cWall.HasTopRow();
|
|
layer=cWall.GetLayerCol3d()?GetSymbolName(cWall.GetLayerGlass3d()):_T("0");
|
|
CString sNum,sSpace;
|
|
if (!bHAverage)
|
|
{
|
|
for(long i=0;i<hNum;i++)
|
|
{
|
|
sNum.Format(_T("%d"),i+1);
|
|
sSpace=Dist2Str(*cWall.m_rowSpaces[i]);//modified
|
|
hListBox.GetRow(i)[0].SetText(sNum);
|
|
hListBox.GetRow(i)[1].SetText(sSpace);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sSpace=Dist2Str(cWall.GetHeight()/hNum);//modified
|
|
for(long i=0;i<hNum;i++)
|
|
{
|
|
sNum.Format(_T("%d"),i+1);
|
|
hListBox.GetRow(i)[0].SetText(sNum);
|
|
hListBox.GetRow(i)[1].SetText(sSpace);
|
|
}
|
|
}
|
|
if (!bVAverage)
|
|
{
|
|
for(long i=0;i<vNum;i++)
|
|
{
|
|
sNum.Format(_T("%d"),i+1);
|
|
sSpace=Dist2Str(*cWall.m_colSpaces[i]);//modified
|
|
vListBox.GetRow(i)[0].SetText(sNum);
|
|
vListBox.GetRow(i)[1].SetText(sSpace);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sSpace=Dist2Str(cWall.GetLength()/vNum);//modified
|
|
for(long i=0;i<vNum;i++)
|
|
{
|
|
sNum.Format(_T("%d"),i+1);
|
|
vListBox.GetRow(i)[0].SetText(sNum);
|
|
vListBox.GetRow(i)[1].SetText(sSpace);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
BOOL CCurtainWallSet::OnInitDialog()
|
|
{
|
|
BOOL result=CPropertyPage::OnInitDialog();
|
|
|
|
hListBox.UnSelect();
|
|
vListBox.UnSelect();
|
|
XSymbolList lstLayer(_T("LAYER"));
|
|
lstLayer.QuickSort(_tcsicmp);
|
|
for(int i=0;i<lstLayer.Length();i++)
|
|
layerCombo.AddString(lstLayer[i]);
|
|
if (!SelectString(layerCombo,layer))
|
|
{
|
|
layerCombo.InsertString(0,layer);
|
|
layerCombo.SetCurSel(0);
|
|
}
|
|
|
|
hSpin.SetRange(1,1000);
|
|
vSpin.SetRange(1,1000);
|
|
BOOL bSuccess1 = vListBox.Create(this,IDC_VLIST);
|
|
BOOL bSuccess2 = hListBox.Create(this,IDC_HLIST);
|
|
if (bCreate)
|
|
{
|
|
OnChangeHnum();
|
|
OnChangeVnum();
|
|
}
|
|
vListBox.FitLastCol();
|
|
hListBox.FitLastCol();
|
|
vListBox.SetReadOnly(bVAverage==TRUE);
|
|
hListBox.SetReadOnly(bHAverage==TRUE);
|
|
return result;
|
|
}
|
|
BEGIN_MESSAGE_MAP(CCurtainWallSet, CPropertyPage)
|
|
//{{AFX_MSG_MAP(CCurtainWallSet)
|
|
ON_EN_CHANGE(IDC_HLIST,OnChangeRowHeight)
|
|
ON_EN_CHANGE(IDC_VLIST,OnChangeColWidth)
|
|
ON_EN_CHANGE(IDC_HNUM, OnChangeHnum)
|
|
ON_EN_CHANGE(IDC_VNUM, OnChangeVnum)
|
|
ON_BN_CLICKED(IDC_VCHECK, OnVcheck)
|
|
ON_BN_CLICKED(IDC_HCHECK, OnHcheck)
|
|
ON_EN_CHANGE(IDC_HEIGHT, OnChangeHeight)
|
|
ON_EN_KILLFOCUS(IDC_HNUM, OnKillFocusHnum)//add by fxj 090423
|
|
ON_EN_KILLFOCUS(IDC_VNUM, OnKillFocusVnum)//add by fxj 090423
|
|
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
void CCurtainWallSet::OnKillFocusHnum()//add by fxj 090423
|
|
{
|
|
|
|
CString str;
|
|
int num;
|
|
GetDlgItem(IDC_HNUM)->GetWindowText(str);
|
|
#ifdef UNICODE
|
|
num=_wtoi(str);
|
|
#else
|
|
num=atoi(str);
|
|
#endif
|
|
|
|
if (num<1||num>10000)
|
|
{
|
|
// AfxMessageBox(_T("请输入一个整数"));
|
|
CDataExchange dxOut(this,false);
|
|
DDX_Text(&dxOut, IDC_HNUM, hNum);
|
|
GetDlgItem(IDC_HNUM)->SetFocus();
|
|
}
|
|
|
|
}
|
|
void CCurtainWallSet::OnKillFocusVnum()//add by fxj 090423
|
|
{
|
|
CString str;
|
|
int num;
|
|
GetDlgItem(IDC_VNUM)->GetWindowText(str);
|
|
#ifdef UNICODE
|
|
num=_wtoi(str);
|
|
#else
|
|
num=atoi(str);
|
|
#endif
|
|
if (num<1||num>10000)
|
|
{
|
|
// AfxMessageBox(_T("请输入一个整数"));
|
|
CDataExchange dxOut(this,false);
|
|
DDX_Text(&dxOut, IDC_VNUM, vNum);
|
|
GetDlgItem(IDC_VNUM)->SetFocus();
|
|
}
|
|
|
|
}
|
|
void CCurtainWallSet::OnChangeHnum()//modified
|
|
{
|
|
//---------modified by fxj 090409---------
|
|
int num;
|
|
CString snum;
|
|
|
|
CDataExchange dx(this,true);
|
|
DDX_Text(&dx,IDC_HNUM,snum);
|
|
#ifdef UNICODE
|
|
num=_wtoi(snum);
|
|
#else
|
|
num=atoi(snum);
|
|
#endif
|
|
//----------------------------------
|
|
|
|
|
|
if (num>0&&num<1000)
|
|
{
|
|
if (hListBox.IsValidRow(hNum-1))
|
|
hListBox.GetRow(hNum-1).SetReadOnly(false);
|
|
hNum=num;
|
|
hListBox.SetRowNum(num);
|
|
hListBox.GetRow(hNum-1).SetReadOnly();
|
|
CString sNum,sSpace;
|
|
sSpace=Dist2Str(_tstof(sHeight)/num);
|
|
for(long i=0;i<num;i++)
|
|
{
|
|
sNum.Format(_T("%d"),i+1);
|
|
hListBox.GetRow(i)[0].SetText(sNum);
|
|
hListBox.GetRow(i)[1].SetText(sSpace);
|
|
}
|
|
}
|
|
}
|
|
void CCurtainWallSet::OnChangeVnum()
|
|
{
|
|
//-------------//modified by fxj 090409-------------
|
|
int num;
|
|
CString snum;
|
|
CDataExchange dx(this,true);
|
|
DDX_Text(&dx,IDC_VNUM,snum);
|
|
#ifdef UNICODE
|
|
num=_wtoi(snum);
|
|
#else
|
|
num=atoi(snum);
|
|
#endif
|
|
//----------------------------------------------
|
|
if (num>0&&num<1000)
|
|
{
|
|
if (vListBox.IsValidRow(vNum-1))
|
|
vListBox.GetRow(vNum-1).SetReadOnly(false);
|
|
vNum=num;
|
|
vListBox.SetRowNum(vNum);
|
|
vListBox.GetRow(vNum-1).SetReadOnly();
|
|
CString sNum,sWidth;
|
|
sWidth=Dist2Str(_tstof(sLength)/vNum);//modified
|
|
for(long i=0;i<vNum;i++)
|
|
{
|
|
sNum.Format(_T("%d"),i+1);
|
|
vListBox.GetRow(i)[0].SetText(sNum);
|
|
vListBox.GetRow(i)[1].SetText(sWidth);
|
|
}
|
|
}
|
|
}
|
|
void CCurtainWallSet::OnVcheck()
|
|
{
|
|
bVAverage=!bVAverage;
|
|
if (bVAverage)
|
|
{
|
|
vListBox.SetRowNum(vNum);
|
|
double space=(_tstof(sLength))/vNum;
|
|
CString sNum,sWidth;
|
|
sWidth=Dist2Str(space);//modified
|
|
for(long i=0;i<vNum;i++)
|
|
{
|
|
sNum.Format(_T("%d"),i+1);
|
|
vListBox.GetRow(i)[0].SetText(sNum);
|
|
vListBox.GetRow(i)[1].SetText(sWidth);
|
|
}
|
|
vListBox.Invalidate();
|
|
}
|
|
vListBox.SetReadOnly(bVAverage==TRUE);
|
|
}
|
|
void CCurtainWallSet::OnHcheck()
|
|
{
|
|
bHAverage=!bHAverage;
|
|
if (bHAverage)
|
|
{
|
|
hListBox.SetRowNum(hNum);
|
|
double space=(_tstof(sHeight))/hNum;
|
|
CString sNum,sWidth;
|
|
sWidth=Dist2Str(space);//modidied
|
|
for(long i=0;i<hNum;i++)
|
|
{
|
|
sNum.Format(_T("%d"),i+1);
|
|
hListBox.GetRow(i)[0].SetText(sNum);
|
|
hListBox.GetRow(i)[1].SetText(sWidth);
|
|
}
|
|
hListBox.Invalidate();
|
|
}
|
|
hListBox.SetReadOnly(bHAverage==TRUE);
|
|
}
|
|
void CCurtainWallSet::OnChangeHeight() //modidied
|
|
{
|
|
double oldHeight=_tstof(sHeight);
|
|
CDataExchange dx(this,true);
|
|
DDX_Text(&dx,IDC_HEIGHT,sHeight);
|
|
if (bHAverage)
|
|
{
|
|
double space=_tstof(sHeight)/hNum;
|
|
CString sNum,sWidth;
|
|
sWidth=Dist2Str(space);
|
|
for(long i=0;i<hNum;i++)
|
|
{
|
|
sNum.Format(_T("%d"),i+1);
|
|
hListBox.GetRow(i)[0].SetText(sNum);
|
|
hListBox.GetRow(i)[1].SetText(sWidth);
|
|
}
|
|
hListBox.Invalidate();
|
|
}
|
|
else if (fabs(_tstof(sHeight)-oldHeight)>1E-9)
|
|
{
|
|
double temp=(double)hListBox.GetCell(hNum-1,1);
|
|
hListBox.GetCell(hNum-1,1).SetText(Dist2Str(temp+_tstof(sHeight)-oldHeight));
|
|
hListBox.GetCell(hNum-1,1).Refresh();
|
|
}
|
|
}
|
|
void CCurtainWallSet::OnChangeRowHeight()//modidied
|
|
{
|
|
bHAverage=false;
|
|
double height=0;
|
|
for(long i=0;i<hNum-1;i++)
|
|
height+=(double)hListBox.GetCell(i,1);
|
|
CString text;
|
|
text=Dist2Str(_tstof(sHeight)-height);
|
|
hListBox.GetCell(hNum-1,1).SetText(text);
|
|
hListBox.GetCell(hNum-1,1).Refresh();
|
|
UpdateData(false);
|
|
}
|
|
void CCurtainWallSet::OnChangeColWidth()//modified
|
|
{
|
|
bVAverage=false;
|
|
double length=0;
|
|
for(long i=0;i<vNum-1;i++)
|
|
length+=(double)vListBox.GetCell(i,1);
|
|
CString text;
|
|
text=Dist2Str(_tstof(sLength)-length);
|
|
vListBox.GetCell(vNum-1,1).SetText(text);
|
|
vListBox.GetCell(vNum-1,1).Refresh();
|
|
UpdateData(false);
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CGlassFrameSet property page
|
|
int FindString(CComboBox &cb,CString s)
|
|
{
|
|
CString temp;
|
|
for(int i=0;i<cb.GetCount();i++)
|
|
{
|
|
cb.GetLBText(i,temp);
|
|
if (temp==s)
|
|
return i;
|
|
}
|
|
return -1;
|
|
}
|
|
bool SelectString(CComboBox &cb,CString s)
|
|
{
|
|
int pos=FindString(cb,s);
|
|
if (pos==-1)
|
|
return false;
|
|
else
|
|
cb.SetCurSel(pos);
|
|
return true;
|
|
}
|
|
int FindString(CListBox &lb,CString s)
|
|
{
|
|
CString temp;
|
|
for(int i=0;i<lb.GetCount();i++)
|
|
{
|
|
lb.GetText(i,temp);
|
|
if (temp==s)
|
|
return i;
|
|
}
|
|
return -1;
|
|
}
|
|
bool SelectString(CListBox &lb,CString s)
|
|
{
|
|
int pos=FindString(lb,s);
|
|
if (pos==-1)
|
|
return false;
|
|
else
|
|
lb.SetCurSel(pos);
|
|
return true;
|
|
}
|
|
IMPLEMENT_DYNCREATE(CGlassFrameSet, CPropertyPage)
|
|
//共用基线类型
|
|
int CGlassFrameSet::baseType=1;
|
|
//竖挺参数备份
|
|
CString CGlassFrameSet::sVLength = _T("100");
|
|
CString CGlassFrameSet::sVWidth = _T("50");
|
|
CString CGlassFrameSet::vFrameLayer =LAY_3DFRAME;//modified
|
|
BOOL CGlassFrameSet::bVHide = FALSE;
|
|
int CGlassFrameSet::glassOffset=0;
|
|
int CGlassFrameSet::oldGlassOffset=0;
|
|
//横框参数备份
|
|
CString CGlassFrameSet::sHLength = _T("100");
|
|
CString CGlassFrameSet::sHWidth = _T("50");
|
|
CString CGlassFrameSet::hFrameLayer =LAY_3DFRAME;//modified
|
|
BOOL CGlassFrameSet::bHHide = FALSE;
|
|
int CGlassFrameSet::frameOffset = 0;
|
|
|
|
CGlassFrameSet::CGlassFrameSet() : CPropertyPage(CGlassFrameSet::IDD)
|
|
{
|
|
bValidWnd=false;
|
|
pBuddy=NULL;
|
|
bVFrame=true;
|
|
|
|
bHide=bVHide;
|
|
sLength=sVLength;
|
|
sWidth=sVWidth;
|
|
layer=vFrameLayer;
|
|
offset=glassOffset;
|
|
InitLayer(LAY_3DFRAME, FALSE);
|
|
}
|
|
CGlassFrameSet::CGlassFrameSet(UINT resourceID):CPropertyPage(resourceID)
|
|
{
|
|
bValidWnd=false;
|
|
pBuddy=NULL;
|
|
bVFrame=false;
|
|
|
|
bHide=bHHide;
|
|
sLength=sHLength;
|
|
sWidth=sHWidth;
|
|
layer=hFrameLayer;
|
|
offset=frameOffset;
|
|
|
|
preViewWnd.SetHFrame();
|
|
InitLayer(LAY_3DFRAME, FALSE);
|
|
}
|
|
CGlassFrameSet::~CGlassFrameSet()
|
|
{
|
|
if (bVFrame)
|
|
{
|
|
bVHide=bHide;
|
|
sVLength=sLength;
|
|
sVWidth=sWidth;
|
|
vFrameLayer=layer;
|
|
glassOffset=offset;
|
|
}
|
|
else
|
|
{
|
|
bHHide=bHide;
|
|
sHLength=sLength;
|
|
sHWidth=sWidth;
|
|
hFrameLayer=layer;
|
|
frameOffset=offset;
|
|
}
|
|
}
|
|
void CGlassFrameSet::Init(TDbCurtainWall&cWall,bool bOut)
|
|
{
|
|
if (bOut)
|
|
{
|
|
CString l0=_T("0");
|
|
if (bVFrame)
|
|
{
|
|
cWall.SetColHide(bHide);
|
|
cWall.SetColAlignment((enum TDbCurtainWall::ColAlignment)baseType);
|
|
if (!bHide)
|
|
cWall.SetGlazeDist(offset);
|
|
cWall.SetColU(_tstof(sWidth));
|
|
cWall.SetColV(_tstof(sLength));
|
|
cWall.SetLayerCol3d(layer==l0?NULL:InitLayer(layer, FALSE));
|
|
}
|
|
else
|
|
{
|
|
cWall.SetRowHide(bHide);
|
|
cWall.SetRowU(_tstof(sWidth));
|
|
cWall.SetRowV(_tstof(sLength));
|
|
if (!bHide)
|
|
cWall.SetRowDist(offset);
|
|
cWall.SetLayerRow3d(layer==l0?NULL:InitLayer(layer, FALSE));
|
|
}
|
|
}
|
|
else//modified
|
|
{
|
|
if (bVFrame)
|
|
{
|
|
bHide=cWall.IsColHide();
|
|
baseType=cWall.GetColAlignment();
|
|
if (!bHide)
|
|
{
|
|
offset=(int)cWall.GetGlazeDist();
|
|
glassOffset=offset;
|
|
oldGlassOffset=offset;
|
|
}
|
|
//if (cWall.GetColU()-(int)cWall.m_uCol>0)
|
|
sWidth=Dist2Str(cWall.GetColU());
|
|
//else
|
|
// sWidth.Format(_T("%d"),(int)cWall.m_uCol);
|
|
//if (cWall.m_vCol-(int)cWall.m_vCol>0)
|
|
|
|
// modify by xly on 101101 设置竖挺截面长=左宽+右宽
|
|
//sLength=Dist2Str(cWall.GetColV());
|
|
double dWith = cWall.GetColV();
|
|
sLength=Dist2Str(dWith);
|
|
//else
|
|
// sLength.Format(_T("%d"),(int)cWall.m_vCol);
|
|
layer=cWall.GetLayerCol3d()?GetSymbolName(cWall.GetLayerCol3d()):_T("0");
|
|
}
|
|
else
|
|
{
|
|
bHide=cWall.IsRowHide();
|
|
//if (cWall.m_uRow-(int)cWall.m_uRow>0)
|
|
sWidth=Dist2Str(cWall.GetRowU());
|
|
//else
|
|
// sWidth.Format(_T("%d"),(int)cWall.m_uRow);
|
|
//if (cWall.m_vRow-(int)cWall.m_vRow>0)
|
|
sLength=Dist2Str(cWall.GetRowV());
|
|
//else
|
|
// sLength.Format(_T("%d"),(int)cWall.m_vRow);
|
|
if (!bHide)
|
|
offset=(int)cWall.GetRowDist();
|
|
layer=cWall.GetLayerRow3d()?GetSymbolName(cWall.GetLayerRow3d()):_T("0");
|
|
}
|
|
}
|
|
}
|
|
void CGlassFrameSet::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CPropertyPage::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_LAYER, layCombo);
|
|
DDX_Control(pDX, IDC_LENGTH, lengthCombo);
|
|
DDX_Control(pDX, IDC_WIDTH, widthCombo);
|
|
DDX_Control(pDX, IDC_BASELINE,baseCombo);
|
|
DDX_Control(pDX, IDC_OFFSET_SPIN, offsetSpin);
|
|
DDX_Control(pDX, IDC_PREVIEW, preViewWnd);
|
|
DDX_Check(pDX, IDC_HIDE, bHide);
|
|
DDX_CBString(pDX, IDC_LENGTH, sLength);
|
|
DDX_Text(pDX, IDC_OFFSET, offset);
|
|
DDX_CBString(pDX, IDC_WIDTH, sWidth);
|
|
DDX_CBString(pDX, IDC_LAYER, layer);
|
|
}
|
|
BEGIN_MESSAGE_MAP(CGlassFrameSet, CPropertyPage)
|
|
//{{AFX_MSG_MAP(CGlassFrameSet)
|
|
ON_EN_CHANGE(IDC_OFFSET, OnChangeOffset)
|
|
ON_CBN_EDITCHANGE(IDC_LENGTH, OnEditchangeLength)
|
|
ON_CBN_SELCHANGE(IDC_LENGTH, OnSelchangeLength)
|
|
ON_CBN_SELCHANGE(IDC_BASELINE, OnSelchangeBase)
|
|
ON_BN_CLICKED(IDC_HIDE, OnHide)
|
|
ON_WM_DESTROY()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
void CGlassFrameSet::OnDestroy()
|
|
{
|
|
CPropertyPage::OnDestroy();
|
|
bValidWnd=false;
|
|
}
|
|
void CGlassFrameSet::SetBaseType(int t,int pos)
|
|
{
|
|
baseType=t;
|
|
baseCombo.SetCurSel(baseType);
|
|
if (bVFrame)
|
|
{
|
|
preViewWnd.SetBaseLine(pos);
|
|
if (pBuddy != NULL && ::IsWindow(pBuddy->m_hWnd)) pBuddy->SetBaseType(t,pos);
|
|
}
|
|
}
|
|
void CGlassFrameSet::SetGlassOffset(int of)
|
|
{//处理玻璃偏移值变化,以及由此发生的所有相关变化
|
|
if (bVFrame)
|
|
{
|
|
SetOffset(of);//更新玻璃偏移记录
|
|
if (bHide)//调整演示窗中的玻璃偏移。
|
|
preViewWnd.SetFrameHide();
|
|
else
|
|
preViewWnd.SetGlassOffset(of);
|
|
preViewWnd.Invalidate();//显示刷新
|
|
if (pBuddy != NULL && ::IsWindow(pBuddy->m_hWnd)) pBuddy->SetGlassOffset(of);//更新横框设置
|
|
}
|
|
else
|
|
{
|
|
offsetSpin.SetRange(-_ttoi(sLength)/2+of,_ttoi(sLength)/2+of);//调整横框偏移区间
|
|
int newOf=offset+of-oldGlassOffset;//,oldGlassOffset必须始终有效。
|
|
if (newOf>=(-_ttoi(sLength)/2+of)&&newOf<=(_ttoi(sLength)/2+of))
|
|
SetOffset(newOf);//横框与玻璃相对位置不变,更新横框偏移记录
|
|
//否则已经无法保持原相对位置,则取最近点.
|
|
else if (newOf<-_ttoi(sLength)/2+of)
|
|
SetOffset(-_ttoi(sLength)/2+of);
|
|
else
|
|
SetOffset(_ttoi(sLength)/2+of);
|
|
oldGlassOffset=of;
|
|
preViewWnd.SetGlassOffset(of);//更新演示窗中的玻璃位置
|
|
if (bHide)//调整演示窗中的横框偏移。
|
|
preViewWnd.SetFrameHide();
|
|
else
|
|
preViewWnd.SetFrameOffset(offset);
|
|
}
|
|
}
|
|
BOOL CGlassFrameSet::OnInitDialog()
|
|
{
|
|
CPropertyPage::OnInitDialog();
|
|
bValidWnd=true;
|
|
XSymbolList lstLayer(_T("LAYER"));
|
|
lstLayer.QuickSort(_tcsicmp);
|
|
for(int i=0;i<lstLayer.Length();i++)
|
|
layCombo.AddString(lstLayer[i]);
|
|
if (!SelectString(layCombo,layer))
|
|
{
|
|
layCombo.InsertString(0,layer);
|
|
layCombo.SetCurSel(0);
|
|
}
|
|
|
|
lengthCombo.AddString(_T("30"));
|
|
lengthCombo.AddString(_T("50"));
|
|
lengthCombo.AddString(_T("100"));
|
|
lengthCombo.AddString(_T("200"));
|
|
lengthCombo.AddString(_T("300"));
|
|
lengthCombo.AddString(_T("400"));
|
|
lengthCombo.AddString(_T("500"));
|
|
if (!SelectString(lengthCombo,sLength))
|
|
{
|
|
lengthCombo.InsertString(0,sLength);
|
|
lengthCombo.SetCurSel(0);
|
|
}
|
|
|
|
widthCombo.AddString(_T("30"));
|
|
widthCombo.AddString(_T("50"));
|
|
widthCombo.AddString(_T("100"));
|
|
widthCombo.AddString(_T("200"));
|
|
widthCombo.AddString(_T("300"));
|
|
widthCombo.AddString(_T("400"));
|
|
widthCombo.AddString(_T("500"));
|
|
if (!SelectString(widthCombo,sWidth))
|
|
{
|
|
widthCombo.InsertString(0,sWidth);
|
|
widthCombo.SetCurSel(0);
|
|
}
|
|
baseCombo.AddString(_T("竖挺内侧"));
|
|
baseCombo.AddString(_T("竖挺中心"));
|
|
baseCombo.AddString(_T("竖挺外侧"));
|
|
baseCombo.SetCurSel(GetBaseType());
|
|
|
|
preViewWnd.SetLength(_tstof(sLength));
|
|
preViewWnd.SetGlassOffset(glassOffset);
|
|
if (bVFrame)
|
|
{
|
|
if (baseCombo.GetCurSel()==0)
|
|
{
|
|
SetBaseType(baseCombo.GetCurSel(),-_ttoi(sLength)/2);
|
|
offsetSpin.SetRange(0,_ttoi(sLength));
|
|
}
|
|
else if (baseCombo.GetCurSel()==2)
|
|
{
|
|
SetBaseType(baseCombo.GetCurSel(),_ttoi(sLength)/2);
|
|
offsetSpin.SetRange(-_ttoi(sLength),0);
|
|
}
|
|
else
|
|
{
|
|
SetBaseType(baseCombo.GetCurSel(),0);
|
|
offsetSpin.SetRange(-_ttoi(sLength)/2,_ttoi(sLength)/2);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SetGlassOffset(GetGlassOffset());
|
|
baseCombo.EnableWindow(FALSE);
|
|
}
|
|
if (bHide)
|
|
{
|
|
bHide=false;
|
|
OnHide();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void CGlassFrameSet::SetOffset(int of)
|
|
{
|
|
offset=of;
|
|
if (bVFrame)
|
|
{
|
|
oldGlassOffset=glassOffset;
|
|
glassOffset=offset;
|
|
}
|
|
if (bValidWnd)
|
|
{
|
|
CDataExchange dx(this,false);
|
|
DDX_Text(&dx, IDC_OFFSET, offset);
|
|
}
|
|
}
|
|
void CGlassFrameSet::OnChangeOffset()
|
|
{
|
|
if (!bValidWnd)
|
|
return;
|
|
CString temp;
|
|
this->GetDlgItemText(IDC_OFFSET,temp);
|
|
|
|
if (temp!="-" && temp!="")// [11/16/2007 nsh]
|
|
{
|
|
CDataExchange dx(this,true);
|
|
DDX_Text(&dx, IDC_OFFSET, offset);
|
|
if (bVFrame)
|
|
SetGlassOffset(offset);
|
|
else
|
|
{
|
|
preViewWnd.SetFrameOffset(offset);
|
|
preViewWnd.Invalidate();
|
|
}
|
|
}// [11/16/2007 nsh]
|
|
|
|
}
|
|
void CGlassFrameSet::OnEditchangeLength()
|
|
{
|
|
CDataExchange dx(this,true);
|
|
DDX_CBString(&dx, IDC_LENGTH, sLength);
|
|
if (_tstof(sLength)<=0)
|
|
return;
|
|
preViewWnd.SetLength(_ttoi(sLength));
|
|
if (bVFrame)
|
|
OnSelchangeBase();
|
|
else
|
|
{
|
|
offsetSpin.SetRange(-_ttoi(sLength)/2+GetGlassOffset(),_ttoi(sLength)/2+GetGlassOffset());
|
|
if (bHide)
|
|
{
|
|
bHide=false;
|
|
OnHide();
|
|
}
|
|
else
|
|
{
|
|
SetOffset(GetGlassOffset());//玻璃居中
|
|
preViewWnd.SetFrameOffset(offset);
|
|
}
|
|
preViewWnd.Invalidate();
|
|
}
|
|
}
|
|
|
|
void CGlassFrameSet::OnSelchangeLength()
|
|
{
|
|
if (lengthCombo.GetCurSel()>=0)
|
|
lengthCombo.GetLBText(lengthCombo.GetCurSel(),sLength);
|
|
if (_tstof(sLength)<=0)
|
|
return;
|
|
preViewWnd.SetLength(_ttoi(sLength));
|
|
if (bVFrame)
|
|
OnSelchangeBase();
|
|
else
|
|
{
|
|
offsetSpin.SetRange(-_ttoi(sLength)/2+GetGlassOffset(),_ttoi(sLength)/2+GetGlassOffset());
|
|
if (bHide)
|
|
{
|
|
bHide=false;
|
|
OnHide();
|
|
}
|
|
else
|
|
{
|
|
SetOffset(GetGlassOffset());//玻璃居中
|
|
preViewWnd.SetFrameOffset(offset);
|
|
}
|
|
preViewWnd.Invalidate();
|
|
}
|
|
}
|
|
|
|
void CGlassFrameSet::OnSelchangeBase()
|
|
{//处理基线位置变化而引起的所有相关变化
|
|
if (!bVFrame)
|
|
return;
|
|
if (baseCombo.GetCurSel()==0)
|
|
{
|
|
SetBaseType(baseCombo.GetCurSel(),-_ttoi(sLength)/2);
|
|
offsetSpin.SetRange(0,_ttoi(sLength));
|
|
}
|
|
else if (baseCombo.GetCurSel()==2)
|
|
{
|
|
SetBaseType(baseCombo.GetCurSel(),_ttoi(sLength)/2);
|
|
offsetSpin.SetRange(-_ttoi(sLength),0);
|
|
}
|
|
else
|
|
{
|
|
SetBaseType(baseCombo.GetCurSel(),0);
|
|
offsetSpin.SetRange(-_ttoi(sLength)/2,_ttoi(sLength)/2);
|
|
}
|
|
if (bHide)//维持隐框状态
|
|
{
|
|
bHide=false;
|
|
OnHide();
|
|
}
|
|
else//偏移回零
|
|
SetGlassOffset(0);
|
|
}
|
|
|
|
void CGlassFrameSet::OnHide()
|
|
{//处理隐框动作,也可用来初始化隐框状态。
|
|
bHide=!bHide;
|
|
if (bHide)
|
|
{
|
|
if (bVFrame)
|
|
{
|
|
//对话框中的偏移数据保持真实偏移,不计玻璃厚度
|
|
if (baseType==0)
|
|
SetGlassOffset(_ttoi(sLength));
|
|
else if (baseType==2)
|
|
SetGlassOffset(0);
|
|
else
|
|
SetGlassOffset(_ttoi(sLength)/2);
|
|
}
|
|
else
|
|
{
|
|
//对话框中的偏移数据保持真实偏移,不计玻璃厚度
|
|
SetOffset(GetGlassOffset()-_ttoi(sLength)/2);
|
|
preViewWnd.SetFrameHide();
|
|
preViewWnd.Invalidate();
|
|
}
|
|
GetDlgItem(IDC_OFFSET)->EnableWindow(false);
|
|
GetDlgItem(IDC_OFFSET_SPIN)->EnableWindow(false);
|
|
}
|
|
else
|
|
{
|
|
//显示真实值
|
|
if (bVFrame)
|
|
preViewWnd.SetGlassOffset(offset);
|
|
else
|
|
preViewWnd.SetFrameOffset(offset);
|
|
preViewWnd.Invalidate();
|
|
GetDlgItem(IDC_OFFSET)->EnableWindow(true);
|
|
GetDlgItem(IDC_OFFSET_SPIN)->EnableWindow(true);
|
|
}
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CWndPreView
|
|
CWndPreView::CWndPreView()
|
|
{
|
|
glassBrush.CreateSolidBrush(RGB(0,255,255));
|
|
frameBrush.CreateSolidBrush(RGB(170,150,50));
|
|
glassOffset=frameOffset=0;
|
|
basePos=0;
|
|
SetLength(100);
|
|
bVFrame=true;
|
|
}
|
|
|
|
CWndPreView::~CWndPreView()
|
|
{
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CWndPreView, CWnd)
|
|
//{{AFX_MSG_MAP(CWndPreView)
|
|
ON_WM_PAINT()
|
|
ON_WM_ERASEBKGND()
|
|
ON_WM_CREATE()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CWndPreView message handlers
|
|
|
|
void CWndPreView::OnPaint()
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
CRect rect;
|
|
GetClientRect(&rect);
|
|
dc.IntersectClipRect(rect);
|
|
double cy=rect.bottom/extent,cx=rect.right/extent;
|
|
if (bVFrame)
|
|
dc.SetViewportOrg(rect.right/2,rect.bottom/2);
|
|
else
|
|
dc.SetViewportOrg((int)(rect.right/2-glassOffset*cx),rect.bottom/2);
|
|
dc.SelectObject(&glassBrush);
|
|
dc.Rectangle(int(cx*(-thick/2+glassOffset+basePos)),rect.bottom/2,int(cx*(thick/2+glassOffset+basePos)),-rect.bottom/2);
|
|
dc.SelectObject(&frameBrush);
|
|
if (bVFrame)
|
|
dc.Rectangle(int(-cx*length/2),int(cy*width/2),int(cx*length/2),int(-cy*width/2));
|
|
else
|
|
dc.Rectangle(int(cx*(-length/2+frameOffset)),int(cy*width/2),int(cx*(length/2+frameOffset)),int(-cy*width/2));
|
|
CFont font1,font2;
|
|
font1.CreateFont(15,7,0,0,FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
|
|
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,18,_T("Arial"));
|
|
font2.CreateFont(15,7,0,0,FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
|
|
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,18,_T("Arial"));
|
|
dc.SetBkMode(TRANSPARENT);
|
|
dc.SetTextColor(RGB(255,255,255));
|
|
dc.SelectObject(&font1);
|
|
dc.SetTextAlign(TA_LEFT|TA_BOTTOM);
|
|
dc.TextOut(int(cx*(-length/2+frameOffset)),int(-cy*width/2),_T("长"));
|
|
dc.SetTextColor(RGB(255,255,255));
|
|
dc.SelectObject(&font2);
|
|
dc.TextOut(int(cx*(length/2+frameOffset)),int(cy*width/2),_T("宽"));
|
|
CPen pen(2,1,RGB(255,0,0));
|
|
dc.SelectObject(&pen);
|
|
dc.MoveTo(int(basePos*cx),rect.bottom/2);
|
|
dc.LineTo(int(basePos*cx),-rect.bottom/2);
|
|
}
|
|
|
|
BOOL CWndPreView::OnEraseBkgnd(CDC* pDC)
|
|
{
|
|
CBrush brush;
|
|
brush.CreateSolidBrush(RGB(0,0,0));
|
|
pDC->SelectObject(&brush);
|
|
CRect rect;
|
|
GetClientRect(&rect);
|
|
pDC->Rectangle(rect);
|
|
return true;
|
|
}
|
|
|
|
int CWndPreView::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
|
{
|
|
if (CWnd::OnCreate(lpCreateStruct) == -1)
|
|
return -1;
|
|
return 0;
|
|
}
|