?? track.cpp
字號:
// Track.cpp : implementation file
//
#include "stdafx.h"
#include "ydpd.h"
#include "Track.h"
#include "ydgj.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Track dialog
Track::Track(CWnd* pParent /*=NULL*/)
: CDialog(Track::IDD, pParent)
{
//{{AFX_DATA_INIT(Track)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
this->m_YDGJ.m_Len = 0;
}
void Track::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Track)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Track, CDialog)
//{{AFX_MSG_MAP(Track)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Track message handlers
//下面的代碼實現物體軌跡的繪制
void Track::OnPaint()
{
CPaintDC dc(this); // device context for painting
int i;
CPen Pen;
//創建畫筆
Pen.CreatePen(PS_SOLID, 1, RGB(0, 255, 0));
//選中畫筆
dc.SelectObject(&Pen);
CWnd *Chart;
CRect m_ChartRect;
//得到窗口指針
Chart = GetDlgItem(IDC_STATIC_GUIJI);
//得到窗口的矩形大小
Chart->GetWindowRect(&m_ChartRect);
//更改屏幕坐標,使之與客戶區相對應
ScreenToClient(&m_ChartRect);
//畫物體中心點
for(i =0 ;i<this->m_YDGJ.m_Len;i++)
{
CPoint po;
//得到物體中心點的橫坐標、縱坐標
po.x = m_YDGJ.m_Guiji[i].x+40;
po.y = m_mapheight - m_YDGJ.m_Guiji[i].y+50;
//畫點
dc.SetPixel(po,RGB(255,0,0));
}
//畫物體的運動軌跡曲線
for( i=0;i<this->m_YDGJ.m_Len-1;i++)
{ //移動到起始點
dc.MoveTo(m_YDGJ.m_Guiji[i].x+40,m_mapheight - m_YDGJ.m_Guiji[i].y+50);
//畫線
dc.LineTo(m_YDGJ.m_Guiji[i+1].x+40,m_mapheight - m_YDGJ.m_Guiji[i+1].y+50);
}
Pen.DeleteObject();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -