⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frame.cpp

📁 Powerful and Portable GPS application -- support Linux, Windows, Windows CE GPS navigation and Map m
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* *  Roadnav *  Frame.cpp    * *  Copyright (c) 2004 - 2007 Richard L. Lynch <rllynch@users.sourceforge.net> * *  This program is free software; you can redistribute it and/or *  modify it under the terms of version 2 of the GNU General Public License *  as published by the Free Software Foundation. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */ ///////////////////////////////////////////////////////////////////////////////// \file////// Contains the frame class for the application, and the associated/// event handlers./////////////////////////////////////////////////////////////////////////////////#ifdef HAVE_CONFIG_H#  include <config.h>#endif#ifdef _MSC_VER#pragma warning(disable: 4786)#pragma warning(disable: 4800)#endif#include <wx/wx.h>#include <wx/minifram.h>#include <wx/string.h>#include <wx/print.h>#include <wx/printdlg.h>#include <wx/filename.h>#include <wx/tokenzr.h>#if defined _WINDOWS#include <windows.h> // for WM_TIMECHANGE#endif#ifdef HAVE_MATH_H#include <math.h>#endif#include "libroadnav/Map.h"#include "libroadnav/MapLookup.h"#include "libroadnav/MapSupport.h"#include "libroadnav/MapRepresentations.h"#include "libroadnav/Debug.h"#include "App.h"#include "Frame.h"#include "MapEventExtender.h"#include "GPSMonitorThread.h"#include "LocationDialog.h"#include "CountyDialog.h"#include "libroadnav/MapCounty.h"#include "libroadnav/MapState.h"#include "Printout.h"#include "PreferencesDialog.h"#include "SaveAsSettingsDialog.h"#include "libroadnav/MapControlDataImporter_GNISDECI.h"#include "libroadnav/MapControlDataImporter_TigerLine.h"#include "TTSFactory.h"#include "Support.h"#include "KeyboardDialog.h"#include "libroadnav/StringTable.h"#ifdef USE_OPENSTREETMAP#include "libroadnav/MapControlDataImporter_OSM.h"#endif#include "libroadnav/MapZip.h"#include "libroadnav/URLs.h"#include "libroadnav/DownloadFiles.h"#include "LCDprocInterface.h"#include "appicon16.xpm"#include "appicon32.xpm"#include "appicon64.xpm"#include <vector>using namespace std;///////////////////////////////////////////////////////////////////////////////// /// Menu item IDs/////////////////////////////////////////////////////////////////////////////////enum{	idMapControl = 0,	idWhatsNearBy,#ifdef USE_SCRIPTING		idFileRunScript,#endif	idFileSaveAs,	idFilePrint,	idFilePrintPreview,		idViewCompass,	idViewAerialPhotos,	idView3DMode,	idViewScale,	idViewGPSHistory,	idViewZoomIn,	idViewZoomOut,	idViewZoomMax,	idViewZoomMin,	idViewGPSMarker,	idViewGPSWindow,	idViewWhatsNearByWindow,	idViewFullScreen,		idMapSetAddress,	idMapWaypoints,	idMapSetAngle,	idMapGetDirections,	idMapGetDirectionsAccel,	idMapMoveCenterLeft,	idMapMoveCenterRight,	idMapMoveCenterUp,	idMapMoveCenterDown,	idToolsMeasure,	idToolsZoom,	idToolsDownloadMaps,#ifdef USE_OPENSTREETMAP	idToolsDownloadOSMMaps,	idToolsImportOSMMaps,#endif		idSolarTimerTest,	idRefreshMapControl,	idEscape,	idViewZoom0,	idViewZoom1,	idViewZoom2,	idViewZoom3,	idViewZoom4,	idViewZoom5,	idViewZoom6,	idViewZoom7,	idViewZoom8,	idViewZoom9,	idViewZoom10,	idViewZoom11,	idViewZoom12,	idViewZoom13,	idViewZoom14,};#define TIMER_INIT		4#ifdef USE_SCRIPTING#define TIMER_SCRIPTING	5#endif#define TIMER_CONFIGFLUSH	6//////////////////////////////////////////////////////////////////////////////////// MapFrame event table/////////////////////////////////////////////////////////////////////////////////BEGIN_EVENT_TABLE(MapFrame, wxFrame)#ifdef USE_SCRIPTING		EVT_MENU  (idFileRunScript, MapFrame::OnFileRunScript)#endif	EVT_MENU  (idFileSaveAs, MapFrame::OnFileSaveAs)	EVT_BUTTON(idFileSaveAs, MapFrame::OnFileSaveAs)	EVT_MENU  (idFilePrint, MapFrame::OnFilePrint)	EVT_BUTTON(idFilePrint, MapFrame::OnFilePrint)	EVT_MENU  (idFilePrintPreview, MapFrame::OnFilePrintPreview)	EVT_MENU  (wxID_EXIT, MapFrame::OnFileExit)	EVT_BUTTON(wxID_EXIT, MapFrame::OnFileExit)	EVT_MENU  (idViewCompass, MapFrame::OnViewCompass)	EVT_MENU  (idViewAerialPhotos, MapFrame::OnViewAerialPhotos)	EVT_MENU  (idView3DMode, MapFrame::OnView3DMode)	EVT_MENU  (idViewScale, MapFrame::OnViewScale)	EVT_MENU  (idViewGPSHistory, MapFrame::OnViewGPSHistory)	EVT_MENU  (idViewZoomIn, MapFrame::OnViewZoomIn)	EVT_BUTTON(idViewZoomIn, MapFrame::OnViewZoomIn)	EVT_MENU  (idViewZoomOut, MapFrame::OnViewZoomOut)	EVT_BUTTON(idViewZoomOut, MapFrame::OnViewZoomOut)	EVT_MENU  (idViewZoomMax, MapFrame::OnViewZoomMax)	EVT_MENU  (idViewZoomMin, MapFrame::OnViewZoomMin)	EVT_MENU  (idViewGPSMarker, MapFrame::OnViewGPSMarker)	EVT_BUTTON(idViewGPSMarker, MapFrame::OnViewGPSMarkerToggle)	EVT_MENU  (idViewGPSWindow, MapFrame::OnViewGPSWindow)	EVT_MENU  (idViewWhatsNearByWindow, MapFrame::OnViewWhatsNearByWindow)	EVT_MENU  (idViewFullScreen, MapFrame::OnViewFullScreen)	EVT_MENU  (idMapSetAddress, MapFrame::OnMapSetAddress)	EVT_BUTTON(idMapSetAddress, MapFrame::OnMapSetAddress)	EVT_MENU  (idMapWaypoints, MapFrame::OnMapWaypoints)	EVT_MENU  (idMapSetAngle, MapFrame::OnMapSetAngle)	EVT_MENU  (idMapGetDirections, MapFrame::OnMapGetDirections)	EVT_BUTTON(idMapGetDirections, MapFrame::OnMapGetDirectionsAccel)	EVT_MENU  (idMapGetDirectionsAccel, MapFrame::OnMapGetDirectionsAccel)	EVT_MENU  (idMapMoveCenterLeft, MapFrame::OnMapMoveCenterLeft)	EVT_BUTTON(idMapMoveCenterLeft, MapFrame::OnMapMoveCenterLeft)	EVT_MENU  (idMapMoveCenterRight, MapFrame::OnMapMoveCenterRight)	EVT_BUTTON(idMapMoveCenterRight, MapFrame::OnMapMoveCenterRight)	EVT_MENU  (idMapMoveCenterUp, MapFrame::OnMapMoveCenterUp)	EVT_BUTTON(idMapMoveCenterUp, MapFrame::OnMapMoveCenterUp)	EVT_MENU  (idMapMoveCenterDown, MapFrame::OnMapMoveCenterDown)	EVT_BUTTON(idMapMoveCenterDown, MapFrame::OnMapMoveCenterDown)	EVT_MENU  (idToolsMeasure, MapFrame::OnToolsMeasure)	EVT_UPDATE_UI(idToolsMeasure, MapFrame::OnUpdateToolsMeasure)	EVT_MENU  (idToolsZoom, MapFrame::OnToolsZoom)	EVT_UPDATE_UI(idToolsZoom, MapFrame::OnUpdateToolsZoom)	EVT_BUTTON(idToolsDownloadMaps, MapFrame::OnToolsDownloadTIGERLineMaps)	EVT_MENU  (idToolsDownloadMaps, MapFrame::OnToolsDownloadTIGERLineMaps)#ifdef USE_OPENSTREETMAP	EVT_MENU  (idToolsDownloadOSMMaps, MapFrame::OnToolsDownloadOSMMaps)	EVT_MENU  (idToolsImportOSMMaps, MapFrame::OnToolsImportOSMMaps)#endif		EVT_BUTTON(wxID_PREFERENCES, MapFrame::OnToolsPreferences)	EVT_MENU  (wxID_PREFERENCES, MapFrame::OnToolsPreferences)	EVT_MENU  (wxID_ABOUT, MapFrame::OnHelpAbout)	EVT_MENU  (idSolarTimerTest, MapFrame::OnSolarTimerTest)	EVT_MENU  (idRefreshMapControl, MapFrame::RedrawMap)	EVT_MENU  (idEscape, MapFrame::OnEscapeKey)	EVT_BUTTON(idWhatsNearBy, MapFrame::OnWhatsNearbyDoubleClick)	EVT_BUTTON(idMapControl, MapFrame::OnMapRecentered)	EVT_COMMAND_RIGHT_CLICK(idMapControl, MapFrame::OnDownloadCounty)	EVT_SOLAR(MapFrame::OnSolarEvent)	EVT_IDLE(MapFrame::OnIdle)	EVT_SIZE(wxSkinnableFrame::OnSize)	EVT_TIMER(TIMER_REFRESH, wxSkinnableFrame::OnTimerRefresh)		EVT_TIMER(TIMER_INIT, MapFrame::OnTimerInit)	EVT_TIMER(TIMER_CONFIGFLUSH, MapFrame::OnTimerConfigFlush)#ifdef USE_SCRIPTING	EVT_TIMER(TIMER_SCRIPTING, MapFrame::OnTimerScripting)#endif	EVT_GPS(MapFrame::OnGPSUpdate)		EVT_CLOSE(MapFrame::OnClose)	EVT_MENU  (idViewZoom0, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom0, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom1, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom1, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom2, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom2, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom3, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom3, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom4, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom4, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom5, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom5, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom6, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom6, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom7, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom7, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom8, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom8, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom9, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom9, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom10, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom10, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom11, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom11, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom12, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom12, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom13, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom13, MapFrame::OnViewZoomLevel)	EVT_MENU  (idViewZoom14, MapFrame::OnViewZoomLevel)	EVT_BUTTON(idViewZoom14, MapFrame::OnViewZoomLevel)END_EVENT_TABLE()//////////////////////////////////////////////////////////////////////////////////// \brief MapFrame constructor - create controls and initialize them/////////////////////////////////////////////////////////////////////////////////MapFrame::MapFrame(wxString title) : wxSkinnableFrame((wxFrame *) NULL, -1, title), m_tLastRoadTypeZoomingCheck((time_t) 0){	//////////////////////////////////////////////////////////////////////////////	// Icon	//////////////////////////////////////////////////////////////////////////////	wxIconBundle icbApp;	wxIcon icoApp16;	wxBitmap bmpAppIcon16(appicon16_xpm);	icoApp16.CopyFromBitmap(bmpAppIcon16);	icbApp.AddIcon(icoApp16);	wxIcon icoApp32;	wxBitmap bmpAppIcon32(appicon32_xpm);	icoApp32.CopyFromBitmap(bmpAppIcon32);	icbApp.AddIcon(icoApp32);	wxIcon icoApp64;	wxBitmap bmpAppIcon64(appicon64_xpm);	icoApp64.CopyFromBitmap(bmpAppIcon64);	icbApp.AddIcon(icoApp64);	SetIcons(icbApp);	//////////////////////////////////////////////////////////////////////////////	// Initialize variables	//////////////////////////////////////////////////////////////////////////////	m_ptGPS.Set(0, 0);	m_fGPSHeading = 0;	m_fGPSSpeed = 0;	m_bOnGPSInProgress = false;	m_bNewGPSData = false;	m_bGPSJustRun = false;	m_iRoadTypeZoomingCountdown = -1;	m_eRoadTypeZoomingCurrentType = RecordTypeDefault;	m_eRoadTypeZoomingNextType = RecordTypeDefault;	m_bScreenTracksGPS = g_pConfig->Read(wxT("TrackGPSMarker"), true);		m_iSpeedControlledDetailLevelOffset = 0;	m_ToolMode = toolNone;		m_pcTTS = ConstructTTS(TTSTypeNone);	InitializeThemes();	//////////////////////////////////////////////////////////////////////////	// Create the "What's Nearby" miniframe	//////////////////////////////////////////////////////////////////////////	m_pfrmWhatsNearBy = new WhatsNearByFrame(this, idWhatsNearBy, new MapControlData_Tiles());		//////////////////////////////////////////////////////////////////////////////	// Create controls	//////////////////////////////////////////////////////////////////////////////	m_ctlMap = new MapControl(&m_cRecords, &m_MapAppearanceSettings, this, idMapControl, wxDefaultPosition, wxDefaultSize);	m_ctlMap->Hide();	//////////////////////////////////////////////////////////////////////////////	// Extend map control event handling	//////////////////////////////////////////////////////////////////////////////	m_ctlMap->PushEventHandler(new MapEventExtender(this, m_ctlMap));	//////////////////////////////////////////////////////////////////////////////	// Add map control to skin	//////////////////////////////////////////////////////////////////////////////	AddNamedControl(m_ctlMap, wxT("map"));	m_pctlCompass = NULL;	//////////////////////////////////////////////////////////////////////////////	// File Menu	//////////////////////////////////////////////////////////////////////////////	wxMenu * menuFile = new wxMenu;#ifdef USE_SCRIPTING	menuFile->Append(idFileRunScript, wxT("Run S&cript..."));#endif	menuFile->Append(idFileSaveAs, wxT("Save &as...\tCtrl-s"));	menuFile->Append(idFilePrint, wxT("&Print...\tCtrl-p"));	menuFile->Append(idFilePrintPreview, wxT("P&rint Preview..."));	menuFile->AppendSeparator();	menuFile->Append(wxID_EXIT, wxT("E&xit"));	//////////////////////////////////////////////////////////////////////////////	// View Menu	//////////////////////////////////////////////////////////////////////////////	m_menuView = new wxMenu;		m_menuView->AppendCheckItem(idViewCompass, wxT("&Compass"));	m_menuView->Check(idViewCompass, TRUE);		m_menuView->AppendCheckItem(idViewAerialPhotos, wxT("Aerial &Photos"));	m_menuView->Check(idViewAerialPhotos, g_pConfig->Read(wxT("AerialPhotosVisible"), (long int) 0));		m_menuView->AppendCheckItem(idView3DMode, wxT("&3D Mode"));	m_menuView->Check(idView3DMode, g_pConfig->Read(wxT("3DMode"), (long int) 0));		m_menuView->AppendCheckItem(idViewScale, wxT("&Scale"));	m_menuView->Check(idViewScale, TRUE);	m_menuView->AppendCheckItem(idViewGPSHistory, wxT("GPS &History"));	m_menuView->Check(idViewGPSHistory, g_pConfig->Read(wxT("GPSHistory"), (long int) 1));	m_menuView->AppendCheckItem(idViewGPSMarker, wxT("Map Tracks &GPS"));	m_menuView->Check(idViewGPSMarker, m_bScreenTracksGPS);	m_menuView->AppendCheckItem(idViewGPSWindow, wxT("G&PS Window"));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -