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

📄 frame.cpp

📁 roadnav 内含一个基于wxWindows库的车载导航系统。编译后
💻 CPP
📖 第 1 页 / 共 5 页
字号:
//////////////////////////////////////////////////////////////////////////////////// \brief User pressed right arrow key - move map to the right/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnMapMoveCenterRight(wxCommandEvent & event){	m_ctlMap->MoveCenterRight();}//////////////////////////////////////////////////////////////////////////////////// \brief User pressed up arrow key - move map to the up/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnMapMoveCenterUp(wxCommandEvent & event){	m_ctlMap->MoveCenterUp();}//////////////////////////////////////////////////////////////////////////////////// \brief User pressed down arrow key - move map to the down/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnMapMoveCenterDown(wxCommandEvent & event){	m_ctlMap->MoveCenterDown();}//////////////////////////////////////////////////////////////////////////////////// \brief Tools->Measure selected. Enables/Disables Measure mode/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnToolsMeasure(wxCommandEvent& event){   if ( m_ToolMode == toolMeasure )   {      m_ToolMode = toolNone;      return;   }   m_ToolMode = toolMeasure;}//////////////////////////////////////////////////////////////////////////////////// \brief Updates the check mark next to Tools->Measure/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnUpdateToolsMeasure(wxUpdateUIEvent& event){	event.Check( m_ToolMode == toolMeasure );}//////////////////////////////////////////////////////////////////////////////////// \brief Tools->Zoom selected. Enables/disables zoom mode./////////////////////////////////////////////////////////////////////////////////void MapFrame::OnToolsZoom(wxCommandEvent& event){	if ( m_ToolMode == toolZoom )	{		m_ToolMode = toolNone;		return;	}	m_ToolMode = toolZoom;}//////////////////////////////////////////////////////////////////////////////////// \brief Updates the check mark next to Tools->Zoom/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnUpdateToolsZoom(wxUpdateUIEvent& event){	event.Check( m_ToolMode == toolZoom );}//////////////////////////////////////////////////////////////////////////////////// \brief Tools->Download Maps selected////// Bring up a dialog box listing the counties, and download the Tiger/Line/// files for the counties the user selects. Files are pulled directly from/// the Census Bureau web site./////////////////////////////////////////////////////////////////////////////////void MapFrame::OnToolsDownloadTIGERLineMaps(wxCommandEvent & event){	wxFont fntThis = GetFont();	vector<wxString> vCounties;	vector<wxString>::iterator i;	vector<wxString> vDownloaded;	MapControlDataImporter_GNISDECI diGNIS;	MapControlDataImporter_TigerLine diTigerLine;		vCounties = GetCountyNames();		for (i = vCounties.begin(); i != vCounties.end(); i++)	{		int iCountyCode;		iCountyCode = CountyCodeByName(*i);					if (diTigerLine.IsCountyLoaded(iCountyCode))			vDownloaded.push_back(*i);	}	CountyDialog dlgCounty(this, &fntThis, vDownloaded);		if (dlgCounty.ShowModal() == wxID_OK)	{		vector<wxInt32> viStateCountyCodes;		unsigned int i;		map<wxString, bool> mapDownloading;		int iCount;		int iProgressPosition;		iCount = 0;		for (i = 0; i < dlgCounty.m_strSelCounties.size(); i++)		{			int iCountyCode;			wxString strStateAbbrev;						iCountyCode = CountyCodeByName(dlgCounty.m_strSelCounties[i]);			strStateAbbrev = StateAbbreviationByCode(iCountyCode / 1000);						if (!diTigerLine.IsCountyLoaded(iCountyCode))				iCount++;			if (!diGNIS.IsGNISStateLoaded(strStateAbbrev) && !mapDownloading[strStateAbbrev])			{				mapDownloading[strStateAbbrev] = true;				iCount++;			}		}				ProgressDialog dlgProgress(NULL, wxT("Downloading..."), iCount * 100);		dlgProgress.Show();		iProgressPosition = 0;		for (i = 0; i < dlgCounty.m_strSelCounties.size(); i++)		{			int iCountyCode;			wxString strStateAbbrev;			MapControlDataImporter_GNISDECI diGNIS;			MapControlDataImporter_TigerLine diTigerLine;						iCountyCode = CountyCodeByName(dlgCounty.m_strSelCounties[i]);			strStateAbbrev = StateAbbreviationByCode(iCountyCode / 1000);						if (!diTigerLine.IsCountyLoaded(iCountyCode))			{				viStateCountyCodes.push_back(iCountyCode);			}			if (!diGNIS.IsGNISStateLoaded(strStateAbbrev))			{				diGNIS.DownloadGNISState(&m_cRecords, strStateAbbrev, &dlgProgress, iProgressPosition, 99);				iProgressPosition += 100;			}		}		MapControlDataImporter_TigerLine diTigerLine;		diTigerLine.DownloadCounties(&m_cRecords, viStateCountyCodes, &dlgProgress, iProgressPosition, viStateCountyCodes.size() * 100);		iProgressPosition += viStateCountyCodes.size() * 100;		m_ctlMap->MapUpdated();	}}#ifdef USE_OPENSTREETMAPvoid MapFrame::OnToolsDownloadOSMMaps(wxCommandEvent & event){	wxString strRtn;	wxStringTokenizer tkz;	Point ptTL;	Point ptBR;	MapControlDataImporter_OSM osm;		if (g_pConfig->Read(wxT("OSMUsername")) == wxT(""))	{		::wxMessageBox(wxT("You must enter your OpenStreetMap username and password in Preferences before you can download any maps."),						wxT("Error"),						wxOK | wxICON_ERROR,						this);		return;	}		strRtn = wxGetTextFromUser(wxT("Please enter the coordinate range you wish to download."),								wxT("Specify Coordinates"),								wxT("0 N, 0 W : 0 N, 0 W"),								this);		if (strRtn.Find(wxT(":")) < 0)		return;			tkz.SetString(strRtn, wxT(":"), wxTOKEN_STRTOK);		ptTL.ParsePoint(tkz.GetNextToken());	ptBR.ParsePoint(tkz.GetNextToken());		ProgressDialog dlgProgress(NULL, wxT("Downloading..."), 1000);	dlgProgress.Show();	if (!osm.DownloadRegion(&m_cRecords, ptTL, ptBR, g_pConfig->Read(wxT("OSMUsername")), g_pConfig->Read(wxT("OSMPassword")), &dlgProgress, 0, 1000))		m_ctlMap->SetCenterCoordinates((ptTL + ptBR) / 2);}void MapFrame::OnToolsImportOSMMaps(wxCommandEvent & event){	wxString strFilename;		strFilename = wxFileSelector(wxT("Select OpenStreetMaps XML File"), 										wxT(""),										wxT(""),										wxT("osm"),										wxT("*.osm"),										wxOPEN | wxFILE_MUST_EXIST);		if (strFilename != wxT(""))	{		MapControlDataImporter_OSM osm;		ProgressDialog dlgProgress(NULL, wxT("Importing..."), 100);		dlgProgress.Show();		osm.LoadDirect(strFilename, &m_cRecords, &dlgProgress, 0, 100);	}}#endif//////////////////////////////////////////////////////////////////////////////////// \brief Open the preferences dialog box.////// This function also restarts the GPS monitor thread, and reloads the map/// settings if the user clicks Ok in the preferences dialog./////////////////////////////////////////////////////////////////////////////////void MapFrame::OnToolsPreferences(wxCommandEvent & event){	wxFont fntThis = GetFont();	PreferencesDialog dlgPref(this, &fntThis);		if (dlgPref.ShowModal() == wxID_OK)	{		m_GPSMonitorThread->Delete();		m_GPSMonitorThread = new GPSMonitorThread(this);		m_GPSMonitorThread->Create();		m_GPSMonitorThread->Run();		ApplyPreferences();	}}///////////////////////////////////////////////////////////////////////////////// /// \brief Help->About selected.////// Show the about box./////////////////////////////////////////////////////////////////////////////////void MapFrame::OnHelpAbout(wxCommandEvent & event){	wxDialog dlg(this, -1, wxString(wxT("About Roadnav")));	wxBoxSizer * sizerWnd = new wxBoxSizer(wxHORIZONTAL);	wxBoxSizer * sizerOutside = new wxBoxSizer(wxHORIZONTAL);	wxBoxSizer * sizerInside = new wxBoxSizer(wxVERTICAL);		//////////////////////////////////////////////////////////////////////////////	// Inside box	//////////////////////////////////////////////////////////////////////////////	sizerInside->Add( 		new wxStaticText(&dlg, -1, wxT("Roadnav ") wxT(VERSION), wxDefaultPosition),		0,		wxALIGN_LEFT | wxALL,		3);	sizerInside->Add( 		new wxStaticText(&dlg, -1, wxT("Copyright (c) 2004 - 2006 Richard L. Lynch <rllynch@users.sourceforge.net>"), wxDefaultPosition),		0,		wxALIGN_LEFT | wxALL,		3);		sizerInside->Add( 		new wxStaticText(&dlg, -1, wxT("http://roadnav.sourceforge.net/"), wxDefaultPosition),		0,		wxALIGN_LEFT | wxALL,		3);	//////////////////////////////////////////////////////////////////////////////	// Outside box	//////////////////////////////////////////////////////////////////////////////	wxBitmap bmpAppIcon(appicon64_xpm);	sizerOutside->Add(		new wxStaticBitmap(&dlg, -1, bmpAppIcon),		0,		wxALIGN_CENTER | wxALL,		5);	sizerOutside->Add(		sizerInside,		0,		wxALL,		5);		//////////////////////////////////////////////////////////////////////////////	// Edge box	//////////////////////////////////////////////////////////////////////////////	sizerWnd->Add(		sizerOutside,		0,		wxALL,		8);	    dlg.SetSizer(sizerWnd);    sizerWnd->Fit(&dlg);	dlg.Center();	dlg.Layout();	dlg.ShowModal();}//////////////////////////////////////////////////////////////////////////////////// \brief Used to test the solar timer (ctrl-t to activate)/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnSolarTimerTest(wxCommandEvent& event){   wxDateTime sunrise = m_SolarTimer.GetSunrise();   wxDateTime sunset  = m_SolarTimer.GetSunset();   double lat,lon;   m_SolarTimer.GetPosition(lon,lat);   wxString msg = wxString::Format(wxT("Lat %.1f, Long %.1f\nSunrise %s\nSunset %s"),									lat,lon,									sunrise.FormatTime().c_str(),									sunset.FormatTime().c_str());   wxMessageBox(msg);}//////////////////////////////////////////////////////////////////////////////////// \brief Users wants to close the GPS window - uncheck the View->GPS Window menu/// item and set registry entry GPSWindowVisible to 0./////////////////////////////////////////////////////////////////////////////////void MapFrame::OnGPSWindowHiding(){	m_menuView->Check(idViewGPSWindow, false);	g_pConfig->Write(wxT("GPSWindowVisible"), 0);	g_pConfig->Flush();}//////////////////////////////////////////////////////////////////////////////////// \brief Users wants to close the directions window - uncheck the /// Map->Get Directions menu item/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnDirectionsWindowHiding(){	m_menuMap->Check(idMapGetDirections, false);}//////////////////////////////////////////////////////////////////////////////////// \brief Users wants to close the what's nearby window - uncheck the /// View->What's Nearby Window menu item/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnWhatsNearByWindowHiding(){	m_menuView->Check(idViewWhatsNearByWindow, false);	g_pConfig->Write(wxT("WhatsNearByWindowVisible"), 0);	g_pConfig->Flush();}//////////////////////////////////////////////////////////////////////////////////// \brief The center of the map has been changed somehow. Update the Whats /// Nearby window, if it's visible./// //////////////////////////////////////////////////////////////////////////////void MapFrame::OnMapRecentered(wxCommandEvent & event){	Address sAddr;	int iRT;	vector<bool> bVisibility;	wxString strAddress;	if (m_menuView->IsChecked(idViewWhatsNearByWindow))		m_pfrmWhatsNearBy->SetCenter(m_ctlMap->GetCenterCoordinates());	for (iRT = FIRST_RECORD_TYPE; iRT <= LAST_RECORD_TYPE; iRT++)	{		bVisibility.push_back(iRT >= FIRST_RECORD_TYPE_ROAD && iRT <= LAST_RECORD_TYPE_ROAD);	}	sAddr = FindCoordinates(m_ctlMap->GetCenterCoordinates(), bVisibility, false, false, &m_cRecords);	if (sAddr.m_bValid)	{		strAddress = sAddr.FormatAddress();		strAddress.Replace(wxT("\r"), wxT(""));		strAddress.Replace(wxT("\n"), wxT(" "));		SetTitle(wxT("Roadnav - ") + strAddress);	}}//////////////////////////////////////////////////////////////////////////////////// \brief Handle the list in the Whats Nearby miniframe being double clicked by/// centering the map on those coordinates///////////

⌨️ 快捷键说明

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