📄 tianwendlg.cpp
字号:
// tianwenDlg.cpp : implementation file
//
#include "stdafx.h"
#include "tianwen.h"
#include "tianwenDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTianwenDlg dialog
CTianwenDlg::CTianwenDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTianwenDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTianwenDlg)
m_Star_Longitude_Hour = 13;
m_Star_Longitude_Minute = 24;
m_Star_Longitude_Second = 59.19f;
m_Star_Latitude_Degree = -8;
m_Star_Latitude_Minute = -55;
m_Star_Latitude_Second = -46.7f;
m_Time_Year = 2004;
m_Time_Day = 16;
m_Time_Month = 10;
m_Time_Hour = 0;
m_Time_Minute = 0;
m_Time_Second = 0;
m_MyLongitude_Degree = 116;
m_MyLongitude_Minute = 23;
m_MyLongitude_Second = 3.6f;
m_MyLatitude_Degree = 39;
m_MyLatitude_Minute = 58;
m_MyLatitude_Second = 31.1f;
m_Star_Azimuth_Degree = 0;
m_Star_Azimuth_minute = 0;
m_Star_Azimuth_Second = 0;
m_Star_Height_Degree = 0;
m_Star_Height_Minute = 0;
m_Star_Height_Second = 0.0f;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CTianwenDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTianwenDlg)
DDX_Text(pDX, IDC_EDIT2, m_Star_Longitude_Hour);
DDV_MinMaxInt(pDX, m_Star_Longitude_Hour, 0, 24);
DDX_Text(pDX, IDC_EDIT4, m_Star_Longitude_Minute);
DDV_MinMaxInt(pDX, m_Star_Longitude_Minute, -60, 60);
DDX_Text(pDX, IDC_EDIT6, m_Star_Longitude_Second);
DDX_Text(pDX, IDC_EDIT3, m_Star_Latitude_Degree);
DDV_MinMaxInt(pDX, m_Star_Latitude_Degree, -90, 90);
DDX_Text(pDX, IDC_EDIT5, m_Star_Latitude_Minute);
DDV_MinMaxInt(pDX, m_Star_Latitude_Minute, -60, 60);
DDX_Text(pDX, IDC_EDIT7, m_Star_Latitude_Second);
DDX_Text(pDX, IDC_EDIT8, m_Time_Year);
DDV_MinMaxInt(pDX, m_Time_Year, 2000, 2008);
DDX_Text(pDX, IDC_EDIT10, m_Time_Day);
DDX_Text(pDX, IDC_EDIT9, m_Time_Month);
DDV_MinMaxInt(pDX, m_Time_Month, 1, 12);
DDX_Text(pDX, IDC_EDIT11, m_Time_Hour);
DDV_MinMaxInt(pDX, m_Time_Hour, 0, 24);
DDX_Text(pDX, IDC_EDIT12, m_Time_Minute);
DDV_MinMaxInt(pDX, m_Time_Minute, 0, 60);
DDX_Text(pDX, IDC_EDIT13, m_Time_Second);
DDX_Text(pDX, IDC_EDIT14, m_MyLongitude_Degree);
DDV_MinMaxInt(pDX, m_MyLongitude_Degree, -180, 180);
DDX_Text(pDX, IDC_EDIT16, m_MyLongitude_Minute);
DDV_MinMaxInt(pDX, m_MyLongitude_Minute, -60, 60);
DDX_Text(pDX, IDC_EDIT18, m_MyLongitude_Second);
DDX_Text(pDX, IDC_EDIT15, m_MyLatitude_Degree);
DDV_MinMaxInt(pDX, m_MyLatitude_Degree, -90, 90);
DDX_Text(pDX, IDC_EDIT17, m_MyLatitude_Minute);
DDV_MinMaxInt(pDX, m_MyLatitude_Minute, -60, 60);
DDX_Text(pDX, IDC_EDIT19, m_MyLatitude_Second);
DDX_Text(pDX, IDC_EDIT20, m_Star_Azimuth_Degree);
DDX_Text(pDX, IDC_EDIT21, m_Star_Azimuth_minute);
DDX_Text(pDX, IDC_EDIT22, m_Star_Azimuth_Second);
DDX_Text(pDX, IDC_EDIT23, m_Star_Height_Degree);
DDX_Text(pDX, IDC_EDIT24, m_Star_Height_Minute);
DDX_Text(pDX, IDC_EDIT25, m_Star_Height_Second);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTianwenDlg, CDialog)
//{{AFX_MSG_MAP(CTianwenDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTianwenDlg message handlers
BOOL CTianwenDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
CheckRadioButton(IDC_RADIO1,IDC_RADIO2,IDC_RADIO2);
GetCurrentTime();
return TRUE; // return TRUE unless you set the focus to a control
}
void CTianwenDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CTianwenDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CTianwenDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CTianwenDlg::OnOK()
{
// TODO: Add extra validation here
m_Star_Longitude=(m_Star_Longitude_Hour+m_Star_Longitude_Minute*60+m_Star_Longitude_Second*3600)*15;
m_Star_Longitude=m_Star_Longitude*PI/180; //得到赤经的弧度值
m_Star_Latitude=(m_Star_Latitude_Degree+m_Star_Latitude_Minute*60+m_Star_Latitude_Second*3600);
m_Star_Latitude=m_Star_Latitude*PI/180; //得到赤纬的弧度值
m_MyLongitude=(m_MyLongitude_Degree+m_MyLongitude_Minute*60+m_MyLongitude_Second*3600);
m_MyLongitude=m_MyLongitude*PI/180;
m_MyLatitude=(m_MyLatitude_Degree+m_MyLatitude_Minute*60+m_MyLatitude_Second*3600);
m_MyLatitude=m_MyLatitude*PI/180;
m_Longitude=m_Star_Longitude-m_MyLongitude; //暂时代替
// m_Latitude=m_MyLongitude-m_MyLatitude;
m_Star_Azimuth=atan(cos(m_MyLatitude)*sin(m_Longitude)/(sin(m_MyLatitude)*sin(m_Star_Longitude)-cos(m_Latitude)*sin(m_Star_Latitude)));
m_Star_Azimuth=m_Star_Azimuth*180/PI;
m_Star_Azimuth_Degree=fix(m_Star_Azimuth);
m_Star_Azimuth_minute=fix((m_Star_Azimuth-m_Star_Azimuth_Degree)*60);
m_Star_Azimuth_Second=float(fix(((m_Star_Azimuth-m_Star_Azimuth_Degree)*60-m_Star_Azimuth_minute)*6000))/100;
m_Star_Height=asin(sin(m_MyLatitude)*sin(m_Star_Latitude)+cos(m_MyLatitude)*cos(m_MyLatitude)*cos(m_Star_Longitude));
m_Star_Height=m_Star_Height*180/PI;
m_Star_Height_Degree=fix(m_Star_Height);
m_Star_Height_Minute=fix((m_Star_Height-m_Star_Height_Degree)*60);
m_Star_Height_Second=float(fix(((m_Star_Height-m_Star_Height_Degree)*60-m_Star_Height_Minute)*6000))/100;
//CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -