135 lines
3.0 KiB
C++
135 lines
3.0 KiB
C++
#include "stdafx.h"
|
|
#include "RecttorDlg.h"
|
|
#include "EarThwormDef.h"
|
|
|
|
IMPLEMENT_DYNAMIC(CRecttorDlg, CDialog)
|
|
|
|
CRecttorDlg::CRecttorDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CRecttorDlg::IDD, pParent)
|
|
, m_dSAngle(0)
|
|
, m_dEAngle(90)
|
|
, m_dR1(300)
|
|
, m_dR2(500)
|
|
, m_dH(400)
|
|
, m_pData(NULL)
|
|
, m_clr(256)
|
|
, m_bSub(FALSE)
|
|
{
|
|
GET_CACHE(CRecttorDlg, %f%f%f%f%f%d, &m_dSAngle, &m_dEAngle, &m_dR1, &m_dR2, &m_dH, &m_clr);
|
|
}
|
|
|
|
CRecttorDlg::~CRecttorDlg()
|
|
{
|
|
}
|
|
|
|
void CRecttorDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Text(pDX, IDC_EDITRSA, m_dSAngle);
|
|
DDX_Text(pDX, IDC_EDITREA, m_dEAngle);
|
|
DDX_Text(pDX, IDC_EDITR1, m_dR1);
|
|
DDX_Text(pDX, IDC_EDITR2, m_dR2);
|
|
DDX_Text(pDX, IDC_EDITRH, m_dH);
|
|
DDX_Check(pDX, IDC_CHECK_SUB, m_bSub);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CRecttorDlg, CDialog)
|
|
ON_BN_CLICKED(IDOK, &CRecttorDlg::OnBnClickedOk)
|
|
ON_BN_CLICKED(IDC_STATIC_COLOR, OnStaticColor)
|
|
ON_WM_CTLCOLOR()
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL CRecttorDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
if (m_pData != NULL)
|
|
{
|
|
AecEqui::XRecttorus* pRctor = (AecEqui::XRecttorus*)m_pData;
|
|
m_dR1 = pRctor->dInr;
|
|
m_dR2 = pRctor->dOutR;
|
|
m_dH = pRctor->dH;
|
|
m_dSAngle = pRctor->dStaAngle * 180.0 / PI;
|
|
m_dEAngle = pRctor->dEndAngle * 180.0 / PI;
|
|
}
|
|
UpdateData(FALSE);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CRecttorDlg::OnBnClickedOk()
|
|
{
|
|
UpdateData();
|
|
|
|
if (m_dR1 < 1.e-3 || m_dR2 < 1.e-3)
|
|
{
|
|
AfxMessageBox(_T("圆环内外半径必须大于0!请重新输入数据!"));
|
|
return;
|
|
}
|
|
|
|
if (m_dR2 - m_dR1 < 1.e-3)
|
|
{
|
|
AfxMessageBox(_T("圆环的外半径必须大于内半径!请重新输入数据!"));
|
|
return;
|
|
}
|
|
|
|
if (m_dSAngle - m_dEAngle > 1.e-3)
|
|
{
|
|
AfxMessageBox(_T("起始角度必须小于终止角度!请重新输入角度"));
|
|
return;
|
|
}
|
|
|
|
double dA = m_dEAngle - m_dSAngle;
|
|
if (dA - 360.0 > -1.e-6)
|
|
{
|
|
AfxMessageBox(_T("圆环的圆心角度必须小于360度,请重新输入角度!"));
|
|
return;
|
|
}
|
|
|
|
if (m_dH < 1.e-3)
|
|
{
|
|
AfxMessageBox(_T(" 圆环的矩形截面高度必须大于0!,请重新输入截面高度!"));
|
|
return;
|
|
}
|
|
|
|
if (m_pData != NULL)
|
|
{
|
|
AecEqui::XRecttorus* pRctor = (AecEqui::XRecttorus*)m_pData;
|
|
pRctor->dInr = m_dR1;
|
|
pRctor->dOutR = m_dR2;
|
|
pRctor->dH = m_dH;
|
|
pRctor->dStaAngle = m_dSAngle * PI / 180.0;
|
|
pRctor->dEndAngle = m_dEAngle * PI / 180.0;
|
|
}
|
|
|
|
SET_CACHE(CRecttorDlg, %f%f%f%f%f%d, m_dSAngle, m_dEAngle, m_dR1, m_dR2, m_dH, m_clr);
|
|
OnOK();
|
|
}
|
|
|
|
void CRecttorDlg::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 CRecttorDlg::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;
|
|
}
|