// TestGISCtrlDlgDlg.cpp : implementation file // #include "stdafx.h" #include "TestGISCtrlDlg.h" #include "TestGISCtrlDlgDlg.h" #include "GuidePointDataStruct.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About double g_uavLon = 117; double g_uavLat = 39; double g_yaw = 0; bool m_bHaveLoadMap = false; // 发送导引点数据的消息 const UINT WM_SEND_GUIDEPOINT_INFO = WM_USER + 1000; 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() ///////////////////////////////////////////////////////////////////////////// // CTestGISCtrlDlgDlg dialog CTestGISCtrlDlgDlg::CTestGISCtrlDlgDlg(CWnd* pParent /*=NULL*/) : CDialog(CTestGISCtrlDlgDlg::IDD, pParent) { //{{AFX_DATA_INIT(CTestGISCtrlDlgDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CTestGISCtrlDlgDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CTestGISCtrlDlgDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CTestGISCtrlDlgDlg, CDialog) //{{AFX_MSG_MAP(CTestGISCtrlDlgDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTTON4, OnButton4) ON_BN_CLICKED(IDC_BUTTON5, OnButton5) ON_BN_CLICKED(IDC_BUTTON6, OnDrawTrack) ON_BN_CLICKED(IDC_BUTTON7, OnCallBack1) ON_BN_CLICKED(IDC_BUTTON8, OnCallBack2) ON_WM_TIMER() //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2) ON_BN_CLICKED(IDC_BUTTON3, CTestGISCtrlDlgDlg::OnBnClickedButton3) // 导引方式消息 ON_MESSAGE(WM_SEND_GUIDEPOINT_INFO, OnReceiveGuidePoint) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CTestGISCtrlDlgDlg message handlers BOOL CTestGISCtrlDlgDlg::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 ShowWindow(SW_MAXIMIZE); // TODO: Add extra initialization here SetTimer(1, 80, NULL); return TRUE; // return TRUE unless you set the focus to a control } void CTestGISCtrlDlgDlg::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 CTestGISCtrlDlgDlg::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 CTestGISCtrlDlgDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CTestGISCtrlDlgDlg::OnButton1() { CRect rcGISArea; GetClientRect(&rcGISArea); rcGISArea.top = 0; rcGISArea.left = 0; rcGISArea.right = rcGISArea.left + 900; rcGISArea.bottom = rcGISArea.top + 700; //客户区转windows区域 // ClientToScreen(&rcGISArea); m_exportGIS.ShowGISDlg(rcGISArea, this); m_exportGIS.SetMsgInfo(this->GetSafeHwnd(), WM_SEND_GUIDEPOINT_INFO); } void CTestGISCtrlDlgDlg::OnBnClickedButton2() { m_exportGIS.DeleteGISDlg(); } void CTestGISCtrlDlgDlg::OnBnClickedButton3() { CString str = "E:\\13-CH96无人机系统\\GISControlDlg20140114\\bin\\route1.txt"; m_exportGIS.DisplayFlyLine(str); } //接收到导引点数据后,装订注入 LRESULT CTestGISCtrlDlgDlg::OnReceiveGuidePoint(WPARAM wParam, LPARAM lParam) { GuidePointData *pGuidePt = (GuidePointData *)(wParam); //软件界面进行标注 m_exportGIS.DrawGuidePoint(pGuidePt->guideMode, pGuidePt->guidePtLon, pGuidePt->guidePtLat); return 0; } int g_pointID = 1; double g_targetLon = 116.41; double g_targetLat = 39.798797; void CTestGISCtrlDlgDlg::OnButton4() { m_exportGIS.AddTarget(g_pointID, g_targetLon, g_targetLat); // g_pointID++; g_targetLon += 0.005; g_targetLat += 0.005; m_exportGIS.AddTarget(g_pointID, g_targetLon, g_targetLat); } void CTestGISCtrlDlgDlg::OnButton5() { m_exportGIS.DeleteTarget(g_pointID); } void CTestGISCtrlDlgDlg::OnDrawTrack() { m_bHaveLoadMap = true; m_exportGIS.SetUAVFlyCoordinate(g_uavLon, g_uavLat, g_yaw); } void CTestGISCtrlDlgDlg::OnCallBack1() { g_uavLon += 3; g_uavLat += 3; m_exportGIS.DrawCallBackPoint(1, g_uavLon, g_uavLat); } void CTestGISCtrlDlgDlg::OnCallBack2() { g_uavLon += 3; g_uavLat += 3; m_exportGIS.DrawCallBackPoint(2, g_uavLon, g_uavLat); } void CTestGISCtrlDlgDlg::OnTimer(UINT nIDEvent) { if (m_bHaveLoadMap) { g_uavLon += 0.01; g_uavLat += 0.01; g_yaw += 1; if (g_yaw > 360) { g_yaw = 360; } m_exportGIS.SetUAVFlyCoordinate(g_uavLon, g_uavLat, g_yaw); } CDialog::OnTimer(nIDEvent); }