Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

274 lines
6.8 KiB
C++

// TkcsDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TkcsDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTkcsDlg dialog
CTkcsDlg::CTkcsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTkcsDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTkcsDlg)
m_strLengthX = _T("1");
m_strLengthY = _T("1");
m_strLengthZ = _T("1");
m_strScaleX = _T("1.0");
m_strScaleY = _T("1.0");
m_strScaleZ = _T("1.0");
m_bTybl = TRUE;
m_strAngle = _T("0");
//}}AFX_DATA_INIT
m_nType=1;
}
void CTkcsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTkcsDlg)
DDX_Text(pDX, IDC_LENGTHX, m_strLengthX);
DDX_Text(pDX, IDC_LENGTHY, m_strLengthY);
DDX_Text(pDX, IDC_LENGTHZ, m_strLengthZ);
DDX_Text(pDX, IDC_SCALEX, m_strScaleX);
DDX_Text(pDX, IDC_SCALEY, m_strScaleY);
DDX_Text(pDX, IDC_SCALEZ, m_strScaleZ);
DDX_Check(pDX, IDC_TYBL, m_bTybl);
DDX_CBString(pDX, IDC_CMB_ANGLE, m_strAngle);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTkcsDlg, CDialog)
//{{AFX_MSG_MAP(CTkcsDlg)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_EN_KILLFOCUS(IDC_SCALEX, OnKillfocusScalex)
ON_EN_KILLFOCUS(IDC_SCALEY, OnKillfocusScaley)
ON_EN_KILLFOCUS(IDC_SCALEZ, OnKillfocusScalez)
ON_CBN_KILLFOCUS(IDC_CMB_ANGLE, OnKillfocusCmbAngle)
ON_BN_CLICKED(IDC_TYBL, OnTybl)
ON_EN_KILLFOCUS(IDC_LENGTHX, OnKillfocusLengthx)
ON_EN_KILLFOCUS(IDC_LENGTHY, OnKillfocusLengthy)
ON_EN_KILLFOCUS(IDC_LENGTHZ, OnKillfocusLengthz)
ON_MESSAGE(WM_ACAD_KEEPFOCUS, OnAcadKeepFocus)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTkcsDlg message handlers
void CTkcsDlg::SetRadioChk()
{
if(m_nType==0)
{
((CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(1);
((CButton*)GetDlgItem(IDC_RADIO2))->SetCheck(0);
GetDlgItem(IDC_LENGTHX)->EnableWindow(TRUE);
GetDlgItem(IDC_LENGTHY)->EnableWindow(TRUE);
GetDlgItem(IDC_LENGTHZ)->EnableWindow(TRUE);
GetDlgItem(IDC_SCALEX)->EnableWindow(FALSE);
GetDlgItem(IDC_SCALEY)->EnableWindow(FALSE);
GetDlgItem(IDC_SCALEZ)->EnableWindow(FALSE);
}
else
{
((CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(0);
((CButton*)GetDlgItem(IDC_RADIO2))->SetCheck(1);
GetDlgItem(IDC_LENGTHX)->EnableWindow(FALSE);
GetDlgItem(IDC_LENGTHY)->EnableWindow(FALSE);
GetDlgItem(IDC_LENGTHZ)->EnableWindow(FALSE);
GetDlgItem(IDC_SCALEX)->EnableWindow(TRUE);
GetDlgItem(IDC_SCALEY)->EnableWindow(TRUE);
GetDlgItem(IDC_SCALEZ)->EnableWindow(TRUE);
}
}
BOOL CTkcsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CRect rect;
GetWindowRect(&rect);
CString strFormat;
strFormat.Format(_T("lef=%d,top=%d"),rect.left,rect.top);
// AfxMessageBox(strFormat);
rect.MoveToXY(CPoint(0,0));
MoveWindow(rect);
SetRadioChk();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CTkcsDlg::OnRadio1()
{
UpdateData(TRUE);
m_nType=0;
SetRadioChk();
}
void CTkcsDlg::OnRadio2()
{
UpdateData(TRUE);
m_nType=1;
SetRadioChk(); // TODO: Add your control notification handler code here
}
void CTkcsDlg::setUnitLength(double dX,double dY, double dZ)
{
m_dUnitLengthX=dX;
m_dUnitLengthY=dY;
m_dUnitLengthZ=dZ;
m_strLengthX.Format(_T("%0.3f"),m_dUnitLengthX*_ttof(m_strScaleX));
m_strLengthY.Format(_T("%0.3f"),m_dUnitLengthY*_ttof(m_strScaleY));
m_strLengthZ.Format(_T("%0.3f"),m_dUnitLengthZ*_ttof(m_strScaleZ));
/* m_strScaleX="1.0";
m_strScaleY="1.0";
m_strScaleZ="1.0";
m_strAngle="0.0";*/
UpdateData(FALSE);
}
void CTkcsDlg::UpdateDataAll()
{
if(m_nType==0)
{
m_strScaleX.Format(_T("%0.1f"),_ttof(m_strLengthX)/m_dUnitLengthX);
m_strScaleY.Format(_T("%0.1f"),_ttof(m_strLengthY)/m_dUnitLengthY);
m_strScaleZ.Format(_T("%0.1f"),_ttof(m_strLengthZ)/m_dUnitLengthZ);
if(fabs(m_dUnitLengthX)<0.001)
m_strScaleX=_T("1.0");
if(fabs(m_dUnitLengthY)<0.001)
m_strScaleY=_T("1.0");
if(fabs(m_dUnitLengthZ)<0.001)
m_strScaleZ=_T("1.0");
}
else
{
m_strLengthX.Format(_T("%0.3f"),_ttof(m_strScaleX)*m_dUnitLengthX);
m_strLengthY.Format(_T("%0.3f"),_ttof(m_strScaleY)*m_dUnitLengthY);
m_strLengthZ.Format(_T("%0.3f"),_ttof(m_strScaleZ)*m_dUnitLengthZ);
if(fabs(m_dUnitLengthX)<0.001)
m_strLengthX=_T("0.000");
if(fabs(m_dUnitLengthY)<0.001)
m_strLengthY=_T("0.000");
if(fabs(m_dUnitLengthZ)<0.001)
m_strLengthZ=_T("0.000");
}
UpdateData(FALSE);
}
void CTkcsDlg::OnKillfocusScalex()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bTybl)
m_strScaleY=m_strScaleZ=m_strScaleX;
UpdateDataAll();
}
void CTkcsDlg::OnKillfocusScaley()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bTybl)
m_strScaleX=m_strScaleZ=m_strScaleY;
UpdateDataAll();
}
void CTkcsDlg::OnKillfocusScalez()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_bTybl)
m_strScaleX=m_strScaleY=m_strScaleZ;
UpdateDataAll();
}
void CTkcsDlg::OnKillfocusCmbAngle()
{
UpdateData(TRUE);
}
void CTkcsDlg::OnTybl()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
}
void CTkcsDlg::OnKillfocusLengthx()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(fabs(m_dUnitLengthX)>0.001)
m_strScaleX.Format(_T("%0.5f"),_ttof(m_strLengthX)/m_dUnitLengthX);
if(m_bTybl)
{
m_strScaleY=m_strScaleZ=m_strScaleX;
m_strLengthY.Format(_T("%0.3f"),_ttof(m_strScaleY)*m_dUnitLengthY);
m_strLengthZ.Format(_T("%0.3f"),_ttof(m_strScaleZ)*m_dUnitLengthZ);
}
UpdateData(FALSE);
}
void CTkcsDlg::OnKillfocusLengthy()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(fabs(m_dUnitLengthY)>0.001)
m_strScaleY.Format(_T("%0.5f"),_ttof(m_strLengthY)/m_dUnitLengthY);
if(m_bTybl)
{
m_strScaleX=m_strScaleZ=m_strScaleY;
m_strLengthX.Format(_T("%0.3f"),_ttof(m_strScaleX)*m_dUnitLengthX);
m_strLengthZ.Format(_T("%0.3f"),_ttof(m_strScaleZ)*m_dUnitLengthZ);
}
UpdateData(FALSE);
}
void CTkcsDlg::OnKillfocusLengthz()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(fabs(m_dUnitLengthZ)>0.001)
{
m_strScaleZ.Format(_T("%0.5f"),_ttof(m_strLengthZ)/m_dUnitLengthZ);
if(m_bTybl)
{
m_strScaleX=m_strScaleY=m_strScaleZ;
m_strLengthX.Format(_T("%0.3f"),_ttof(m_strScaleX)*m_dUnitLengthX);
m_strLengthY.Format(_T("%0.3f"),_ttof(m_strScaleY)*m_dUnitLengthY);
}
}
UpdateData(FALSE);
}
LRESULT CTkcsDlg::OnAcadKeepFocus (WPARAM wParam, LPARAM lParam)
{
CPoint point;
GetCursorPos(&point);
// 鼠标已在窗体内时,判断什么时候鼠标离开
CRect rcWindow;
GetWindowRect(&rcWindow);
// 表示鼠标已离开窗体
if(!rcWindow.PtInRect(point))
return FALSE;
return TRUE;
}