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

📄 frame.cpp

📁 roadnav 内含一个基于wxWindows库的车载导航系统。编译后
💻 CPP
📖 第 1 页 / 共 5 页
字号:
					wxSAVE | wxOVERWRITE_PROMPT					);	if (dlg.ShowModal() == wxID_OK)	{		SaveAsSettingsDialog dlgSettings(this);		if (dlgSettings.ShowModal() == wxID_OK)		{			wxMemoryDC dc;			wxBitmap bmpOut(dlgSettings.m_iWidth, dlgSettings.m_iHeight);						dc.SelectObject(bmpOut);			m_ctlMap->DrawAll(&dc, wxSize(dlgSettings.m_iWidth, dlgSettings.m_iHeight));					bmpOut.SaveFile(dlg.GetPath(), wxBITMAP_TYPE_PNG);			}	}}//////////////////////////////////////////////////////////////////////////////////// \brief Prints the map/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnFilePrint(wxCommandEvent & event){	wxString strTitle;	Address sAddr;	vector<bool> bVisibility;	int iRT;	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);	if (sAddr.m_bValid)	{		strTitle = sAddr.FormatAddress(false, false, true);	}	else	{		strTitle = m_ctlMap->GetCenterCoordinates().FormatPoint();	}	wxPrintDialogData printDialogData(m_pdData);	wxPrinter printer(&printDialogData);	Printout printout(strTitle, m_ctlMap);	if (!printer.Print(this, &printout, TRUE))	{		if (wxPrinter::GetLastError() == wxPRINTER_ERROR)			wxMessageBox(wxT("There was a problem printing.\nPerhaps your current printer is not set correctly?"), wxT("Printing"), wxOK, this);		else		{			// user hit cancel		}	}	else	{		m_pdData = printer.GetPrintDialogData().GetPrintData();	}}//////////////////////////////////////////////////////////////////////////////////// \brief Brings up a print preview dialog box/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnFilePrintPreview(wxCommandEvent & event){	wxString strTitle;	Address sAddr;	vector<bool> bVisibility;	int iRT;	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);	if (sAddr.m_bValid)	{		strTitle = sAddr.FormatAddress(false, false, true);	}	else	{		strTitle = m_ctlMap->GetCenterCoordinates().FormatPoint();	}    wxPrintDialogData printDialogData(m_pdData);    wxPrintPreview * preview = new wxPrintPreview(	new Printout(strTitle, m_ctlMap), 													new Printout(strTitle, m_ctlMap), 													&printDialogData);    if (!preview->Ok())    {        delete preview;        wxMessageBox(wxT("There was a problem previewing.\nPerhaps your current printer is not set correctly?"), _T("Previewing"), wxOK, this);        return;    }        wxPreviewFrame *pfrmPreview = new wxPreviewFrame(preview, this, wxT("Print Preview"), wxPoint(100, 100), wxSize(600, 650));    pfrmPreview->Centre(wxBOTH);    pfrmPreview->Initialize();    pfrmPreview->Show(TRUE);}//////////////////////////////////////////////////////////////////////////////////// \brief File->Exit selected, close the application/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnFileExit(wxCommandEvent & event){	Close(TRUE);}//////////////////////////////////////////////////////////////////////////////////// \brief View->Compass selected, show/hide the compass/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnViewCompass(wxCommandEvent & event){	m_ctlMap->ShowCompass(m_menuView->IsChecked(idViewCompass));}//////////////////////////////////////////////////////////////////////////////////// \brief View->Aerial Photos selected, show/hide the photographic background/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnViewAerialPhotos(wxCommandEvent & event){	g_pConfig->Write(wxT("AerialPhotosVisible"), m_menuView->IsChecked(idViewAerialPhotos));	g_pConfig->Flush();	UpdateTheme();	m_ctlMap->ShowAerialPhotos(m_menuView->IsChecked(idViewAerialPhotos));	if (m_menuView->IsChecked(idViewAerialPhotos) && m_menuView->IsChecked(idView3DMode))	{		wxCommandEvent ev;		// both aerial photos and 3D mode may not be on at the same time		m_menuView->Check(idView3DMode, false);		OnView3DMode(ev);	}}//////////////////////////////////////////////////////////////////////////////////// \brief View->3D Mode selected, enable/disable 3D mode/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnView3DMode(wxCommandEvent & event){	g_pConfig->Write(wxT("3DMode"), m_menuView->IsChecked(idView3DMode));	g_pConfig->Flush();	m_ctlMap->Enable3DMode(m_menuView->IsChecked(idView3DMode));	if (m_menuView->IsChecked(idViewAerialPhotos) && m_menuView->IsChecked(idView3DMode))	{		wxCommandEvent ev;		// both aerial photos and 3D mode may not be on at the same time		m_menuView->Check(idViewAerialPhotos, false);		OnViewAerialPhotos(ev);	}}//////////////////////////////////////////////////////////////////////////////////// \brief View->Scale selected, show/hide the scale key/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnViewScale(wxCommandEvent & event){	m_ctlMap->ShowScale(m_menuView->IsChecked(idViewScale));}//////////////////////////////////////////////////////////////////////////////////// \brief View->GPS History toggled/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnViewGPSHistory(wxCommandEvent & event){	if (!m_menuView->IsChecked(idViewGPSHistory))		m_ctlMap->ClearTrack(wxT("GPSHistory"));	g_pConfig->Write(wxT("GPSHistory"), m_menuView->IsChecked(idViewGPSHistory));	g_pConfig->Flush();}//////////////////////////////////////////////////////////////////////////////////// \brief View->Zoom In selected, increase the detail level/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnViewZoomIn(wxCommandEvent& event){	m_ctlMap->MoreDetail();}//////////////////////////////////////////////////////////////////////////////////// \brief View->Zoom Out selected, decrease the detail level/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnViewZoomOut(wxCommandEvent& event){	m_ctlMap->LessDetail();}//////////////////////////////////////////////////////////////////////////////////// \brief View->Zoom All selected/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnViewZoomMax(wxCommandEvent& event){   m_ctlMap->SetDetailLevel(m_MapAppearanceSettings.GetDetailLevelCount());}//////////////////////////////////////////////////////////////////////////////////// \brief View->Zoom None selected/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnViewZoomMin(wxCommandEvent& event){   m_ctlMap->SetDetailLevel(0);}//////////////////////////////////////////////////////////////////////////////////// \brief Show/hide the marker indicating the current GPS coordinates/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnViewGPSMarker(wxCommandEvent& event){	m_bScreenTracksGPS = m_menuView->IsChecked(idViewGPSMarker);}//////////////////////////////////////////////////////////////////////////////////// \brief Show/hides the GPS status window/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnViewGPSWindow(wxCommandEvent& event){	if (m_menuView->IsChecked(idViewGPSWindow))		m_pfrmGPS->Show();	else		m_pfrmGPS->Hide();		g_pConfig->Write(wxT("GPSWindowVisible"), m_menuView->IsChecked(idViewGPSWindow));	g_pConfig->Flush();}//////////////////////////////////////////////////////////////////////////////////// \brief Show/hides the What's Nearby window/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnViewWhatsNearByWindow(wxCommandEvent& event){	if (m_menuView->IsChecked(idViewWhatsNearByWindow))	{		m_pfrmWhatsNearBy->SetCenter(m_ctlMap->GetCenterCoordinates());		m_pfrmWhatsNearBy->Show();	}	else	{		m_pfrmWhatsNearBy->Hide();	}		g_pConfig->Write(wxT("WhatsNearByWindowVisible"), m_menuView->IsChecked(idViewWhatsNearByWindow));	g_pConfig->Flush();}//////////////////////////////////////////////////////////////////////////////////// \brief Enters/exits full screen mode/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnViewFullScreen(wxCommandEvent& event){	ShowFullScreen(!IsFullScreen());	m_menuView->Check(idViewFullScreen, IsFullScreen());}///////////////////////////////////////////////////////////////////////////////// /// \brief Map->Set Address selected.////// Bring up a dialog box asking the user for an address. Center the map on/// that address./////////////////////////////////////////////////////////////////////////////////void MapFrame::OnMapSetAddress(wxCommandEvent & event){	wxFont fntThis = GetFont();	LocationDialog dlgAddress(this, m_ctlMap, ADFLAG_CANCELBUTTON, &fntThis);	if (dlgAddress.ShowModal() == wxID_OK)	{		Address sAddr;		wxString strMarkerName;		wxString strErrorMsg;		sAddr = dlgAddress.GetAddress(&strErrorMsg);		strMarkerName = dlgAddress.m_strName;		if (strMarkerName == wxT(""))			strMarkerName = wxT("Selected Address");					if (!sAddr.m_bValid)		{			wxMessageDialog dlgError(this, strErrorMsg, wxT("Error"), wxOK | wxICON_ERROR);			dlgError.ShowModal();			return;		}				m_ctlMap->SetMarker(MapMarker(strMarkerName, &sAddr, -1, dlgAddress.m_bShowCalloutBox, dlgAddress.m_bShowSmallLabel, false, dlgAddress.m_strIconFilename));	}}///////////////////////////////////////////////////////////////////////////////// /// \brief Map->Set Angle selected.////// Bring up a dialog box asking the user to enter the orientation of the map./////////////////////////////////////////////////////////////////////////////////void MapFrame::OnMapSetAngle(wxCommandEvent & event){	wxTextEntryDialog dlg(this, wxT("Enter desired orientation in degrees"), wxT("Set Map Orientation"), wxString::Format(wxT("%.1f"), m_ctlMap->GetAngle()));	dlg.SetValue(wxString::Format(wxT("%.1f"), m_ctlMap->GetAngle()));	if (dlg.ShowModal() == wxID_OK)	{		double fAngle;		fAngle = 0;		dlg.GetValue().ToDouble(&fAngle);		m_ctlMap->SetAngle(fAngle);	}}//////////////////////////////////////////////////////////////////////////////////// \brief Map->Waypoints selected.////// Bring up the LocationDialog box, allowing the user to add/update/delete/// waypoints./////////////////////////////////////////////////////////////////////////////////void MapFrame::OnMapWaypoints(wxCommandEvent & event){	wxFont fntThis = GetFont();	LocationDialog dlgAddress(this, m_ctlMap, ADFLAG_MARKERMANAGEMENTBUTTONS, &fntThis);	dlgAddress.m_strTitle = wxT("Waypoints");	dlgAddress.ShowModal();		SaveMarkers();}//////////////////////////////////////////////////////////////////////////////////// \brief Map->Get Directions selected./// Ask the user for two addresses and figure out the best way to get from/// the first address to the second. Results are shown in the directions/// miniframe./////////////////////////////////////////////////////////////////////////////////void MapFrame::OnMapGetDirections(wxCommandEvent & event){	if (m_menuMap->IsChecked(idMapGetDirections))	{		if (!m_pfrmDirections->Setup())			m_pfrmDirections->Show();		else			m_menuMap->Check(idMapGetDirections, false);	}	else	{		m_pfrmDirections->Close();	}}//////////////////////////////////////////////////////////////////////////////////// \brief One of the get directions accelerators has been pressed./// Toggle the map directions off, then on/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnMapGetDirectionsAccel(wxCommandEvent & event){	if (m_menuMap->IsChecked(idMapGetDirections))	{		// first uncheck		m_menuMap->Check(idMapGetDirections, 0);		OnMapGetDirections(event);	}	// now check	m_menuMap->Check(idMapGetDirections, 1);	OnMapGetDirections(event);}//////////////////////////////////////////////////////////////////////////////////// \brief User pressed left arrow key - move map to the left/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnMapMoveCenterLeft(wxCommandEvent & event){	m_ctlMap->MoveCenterLeft();}

⌨️ 快捷键说明

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