97 lines
1.8 KiB
C++
97 lines
1.8 KiB
C++
#include "stdafx.h"
|
|
#include "SpereDlg.h"
|
|
#include "EarThwormDef.h"
|
|
|
|
IMPLEMENT_DYNAMIC(CSpereDlg, CDialog)
|
|
|
|
CSpereDlg::CSpereDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CSpereDlg::IDD, pParent)
|
|
, m_dR(100)
|
|
, m_pData(NULL)
|
|
, m_clr(256)
|
|
, m_bSub(FALSE)
|
|
{
|
|
GET_CACHE(CSpereDlg, %f%d, &m_dR, &m_clr);
|
|
}
|
|
|
|
CSpereDlg::~CSpereDlg()
|
|
{
|
|
}
|
|
|
|
void CSpereDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Text(pDX, IDC_EDITR, m_dR);
|
|
DDX_Check(pDX, IDC_CHECK_SUB, m_bSub);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CSpereDlg, CDialog)
|
|
ON_BN_CLICKED(IDOK, &CSpereDlg::OnBnClickedOk)
|
|
ON_BN_CLICKED(IDC_STATIC_COLOR, OnStaticColor)
|
|
ON_WM_CTLCOLOR()
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
void CSpereDlg::OnBnClickedOk()
|
|
{
|
|
UpdateData();
|
|
|
|
if (m_dR < 1.e-3)
|
|
{
|
|
AfxMessageBox(_T("球的半径必须大于0!请重新输入数据!"));
|
|
return;
|
|
}
|
|
|
|
if (m_pData != NULL)
|
|
{
|
|
AecEqui::XSphere* pSphe = (AecEqui::XSphere*)m_pData;
|
|
pSphe->dr = m_dR;
|
|
}
|
|
|
|
SET_CACHE(CSpereDlg, %f%d, m_dR, m_clr);
|
|
|
|
OnOK();
|
|
}
|
|
|
|
BOOL CSpereDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
if (m_pData != NULL)
|
|
{
|
|
AecEqui::XSphere* pShere = (AecEqui::XSphere*)m_pData;
|
|
m_dR = pShere->dr;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CSpereDlg::OnStaticColor()
|
|
{
|
|
AcCmColor clr;
|
|
#if ARX < 24
|
|
clr.setColorMethod(AcCmEntityColor::kByACI);
|
|
#endif
|
|
clr.setColorIndex(256);
|
|
if (acedSetColorDialogTrueColor(clr, Adesk::kTrue, clr, (AcCm::DialogTabs)(AcCm::kACITab)) == Adesk::kFalse) return;
|
|
m_clr = clr.colorIndex();
|
|
Invalidate();
|
|
}
|
|
|
|
HBRUSH CSpereDlg::OnCtlColor(CDC * pDC, CWnd * pWnd, UINT nCtlColor)
|
|
{
|
|
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
if (nCtlColor == CTLCOLOR_STATIC)
|
|
{
|
|
if (pWnd != NULL && pWnd->GetDlgCtrlID() == IDC_STATIC_COLOR)
|
|
{
|
|
CRect rc;
|
|
pWnd->GetClientRect(rc);
|
|
pDC->FillSolidRect(rc, acedGetRGB(m_clr));
|
|
}
|
|
}
|
|
return hbr;
|
|
}
|
|
|