You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
3.8 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//////////////////////////////////////////////////////////////////////////////
//Îļþ: CScaleViewPage.cpp
//Ö÷Òª¹¦ÄÜ:
//
//³ÌÐò±àд: 2006-12-07
//
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
//#include "DFDrawPro.h"
#include "ScaleViewPage.h"
#include <math.h>
//#include "ScaleSelectPage.h"
//#include "ScaleUnitPage.h"
#include ".\PublicParam.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CScaleViewPage dialog
IMPLEMENT_DYNCREATE(CScaleViewPage, CPropertyPage)
CScaleViewPage::CScaleViewPage(CWnd* pParent /*=NULL*/)
: CPropertyPage(CScaleViewPage::IDD)
{
//{{AFX_DATA_INIT(CScaleViewPage)
m_bNotSame = FALSE;
m_strPrintX = _T("");
m_strPrintY = _T("");
m_strRealX = _T("");
m_strRealY = _T("");
//}}AFX_DATA_INIT
m_unit.SetSize(CUnit::UNIT_M, CUnit::UNIT_M);
}
void CScaleViewPage::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CScaleViewPage)
DDX_Check(pDX, IDC_CHECK_SCALE_VIEW_XY, m_bNotSame);
DDX_Text(pDX, IDC_EDIT_SCALE_VIEW_DX1, m_strRealX);
DDX_Text(pDX, IDC_EDIT_SCALE_VIEW_DX2, m_strPrintX);
DDX_Text(pDX, IDC_EDIT_SCALE_VIEW_DY1, m_strRealY);
DDX_Text(pDX, IDC_EDIT_SCALE_VIEW_DY2, m_strPrintY);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CScaleViewPage, CPropertyPage)
//{{AFX_MSG_MAP(CScaleViewPage)
ON_EN_CHANGE(IDC_EDIT_SCALE_VIEW_DX1, OnChangeEDITRealX)
ON_EN_CHANGE(IDC_EDIT_SCALE_VIEW_DX2, OnChangeEDITPrintX)
ON_EN_CHANGE(IDC_EDIT_SCALE_VIEW_DY1, OnChangeEDITRealY)
ON_EN_CHANGE(IDC_EDIT_SCALE_VIEW_DY2, OnChangeEDITPrintY)
ON_BN_CLICKED(IDC_CHECK_SCALE_VIEW_XY, OnCheck1)
ON_BN_CLICKED(IDC_BUTTON_SCALE_VIEW_WIZARD, OnBUTTONWizard)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CScaleViewPage message handlers
void CScaleViewPage::OnChangeEDITRealX()
{
double k;
if(fabs(atof(m_strRealX))<1e-100)return;
k=atof(m_strRealY)/atof(m_strRealX);
UpdateData( );
if(m_bNotSame)return;
AfxGetPublicFunction()->FloatToString(m_strRealY,k*atof(m_strRealX), 10);
UpdateData(FALSE);
}
void CScaleViewPage::OnChangeEDITRealY()
{
double k;
if(fabs(atof(m_strRealX))<1e-100)return;
k=atof(m_strRealY)/atof(m_strRealX);
UpdateData( );
if(m_bNotSame)return;
AfxGetPublicFunction()->FloatToString(m_strRealX,atof(m_strRealY)/k, 10);
UpdateData(FALSE);
}
void CScaleViewPage::OnChangeEDITPrintX()
{
double k;
if(fabs(atof(m_strPrintX))<1e-100)return;
k=atof(m_strPrintY)/atof(m_strPrintX);
UpdateData( );
if(m_bNotSame)return;
AfxGetPublicFunction()->FloatToString(m_strPrintY,k*atof(m_strPrintX), 10);
UpdateData(FALSE);
}
void CScaleViewPage::OnChangeEDITPrintY()
{
double k;
if(fabs(atof(m_strPrintX))<1e-100)return;
k=atof(m_strPrintY)/atof(m_strPrintX);
UpdateData( );
if(m_bNotSame)return;
AfxGetPublicFunction()->FloatToString(m_strPrintX,atof(m_strPrintY)/k, 10);
UpdateData(FALSE);
}
BOOL CScaleViewPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CScaleViewPage::OnCancel()
{
CPropertyPage::OnCancel();
}
void CScaleViewPage::OnCheck1() //X¡¢Y±ÈÀýÒò×Ó²»Í¬
{
UpdateData();
}
void CScaleViewPage::OnBUTTONWizard()
{
UpdateData();
CSize unit = m_unit;
///< 1ºÁÃ×´ú±íµÄʵ¼Ê³¤¶È
CSize8 scale;
scale.cx = atof(m_strRealX)/atof(m_strPrintX);
scale.cy = atof(m_strRealY)/atof(m_strPrintY);
if(!PARAM().DoScaleSetDialog(scale, unit, !m_bNotSame, this))
return;
m_unit = unit;
AfxGetPublicFunction()->FloatToString(m_strRealX, scale.cx, 10);
AfxGetPublicFunction()->FloatToString(m_strRealY, scale.cy, 10);
m_strPrintX = "1";
m_strPrintY = "1";
UpdateData(FALSE);
}