📄 frame.cpp
字号:
m_tLastRoadTypeZoomingCheck = wxDateTime::Now(); m_cRecords.LoadRegion(pt, pt, OnlyRoadsVisibility(), false); } } adrGPS = FindCoordinates(pt, OnlyRoadsVisibility(), false, false, &m_cRecords); if (adrGPS.m_bValid) m_adrGPS = adrGPS; else m_adrGPS.m_ptCoordinates = pt; } m_ctlMap->SetMarker( MapMarker( wxT("GPS Position"), &m_adrGPS, fHeading, g_pConfig->Read(wxT("GPS Callout Box"), (long) false), g_pConfig->Read(wxT("GPS Small Label"), true), g_pConfig->Read(wxT("GPS Arrow"), true), g_pConfig->Read(wxT("GPS Icon"), wxT("")), false ), false); OnGPSUpdateIdleSpeedControlledZooming(event); if (bDoRoadTypeZoomingNow) OnGPSUpdateIdleRoadTypeZooming(event); if (m_bScreenTracksGPS && !bKeepGPSCentered) OnGPSUpdateIdleKeepGPSOnScreen(event); if (m_menuView->IsChecked(idView3DMode)) { m_ctlMap->SetCenterCoordinates(pt); m_ctlMap->SetAngle(fHeading); } else { if (!m_bNorthAlwaysUp) OnGPSUpdateIdlePointGPSHeadingUp(event); if (m_bScreenTracksGPS && bKeepGPSCentered) m_ctlMap->SetCenterCoordinates(pt); } if (m_menuView->IsChecked(idViewGPSHistory)) OnGPSUpdateIdleUpdateGPSTrack(event); m_SolarTimer.SetPosition(pt.m_fLong,pt.m_fLat); m_ptGPS = pt; m_fGPSSpeed = fSpeed; m_fGPSHeading = fHeading; } } if (m_pctlCompass) m_pctlCompass->SetDirection(fHeading); wxString strStreet = wxString::Format(wxT("%d "), m_adrGPS.m_iStreetNumber) + m_adrGPS.m_strStreetName + wxT(" ") + m_adrGPS.m_strStreetType; SetVariable(wxT("GPS Street"), strStreet); SetVariable(wxT("GPS City"), m_adrGPS.m_strCityName); SetVariable(wxT("GPS State"), m_adrGPS.m_strStateName); // if the home zip code is not set, then set it from the GPS coordinates if (m_adrGPS.m_iZipCode) { int iZipHome; g_pConfig->Read(wxT("HomeZipCode"), &iZipHome, 0); if (!iZipHome) { g_pConfig->Write(wxT("HomeZipCode"), m_adrGPS.m_iZipCode); g_pConfig->Flush(); } } if (!bEnabled) SetVariable(wxT("GPS Full Address"), wxT("GPS disabled")); else if (!bActive) SetVariable(wxT("GPS Full Address"), wxT("No GPS unit detected")); else if (!bLocked) SetVariable(wxT("GPS Full Address"), wxT("No GPS lock")); else SetVariable(wxT("GPS Full Address"), m_adrGPS.FormatAddress(false)); SetVariable(wxT("GPS Speed"), FormatSpeed(fSpeed)); if (fHeading >= 0) SetVariable(wxT("GPS Heading"), wxString::Format(wxT("%.0f ("), fHeading) + FormatHeading(fHeading) + wxT(")")); else SetVariable(wxT("GPS Heading"), wxT("?")); LibRoadnavDebug0(wxT("GPS"), wxT("Calling m_pfrmGPS->OnGPSUpdate")); m_pfrmGPS->OnGPSUpdate(event); LibRoadnavDebug0(wxT("GPS"), wxT("Calling m_pfrmDirections->OnGPSUpdate")); m_pfrmDirections->OnGPSUpdate(bEnabled, bActive, bLocked, pt, fSpeed, fHeading, strLockType, nSat, m_adrGPS); m_bOnGPSInProgress = false; LibRoadnavDebug0(wxT("GPS"), wxT("MapFrame::OnGPSUpdate done"));}//////////////////////////////////////////////////////////////////////////////////// \brief Save all markers to the registry./////////////////////////////////////////////////////////////////////////////////void MapFrame::SaveMarkers(){ int iMarker; for (iMarker = 0; iMarker < m_ctlMap->GetMarkerCount(); iMarker++) { wxString strMarker = m_ctlMap->GetMarker(iMarker).ToString(); g_pConfig->Write(wxString::Format(wxT("Marker%d"), iMarker), strMarker); } g_pConfig->Write(wxT("MarkerCount"), m_ctlMap->GetMarkerCount()); g_pConfig->Flush();}///////////////////////////////////////////////////////////////////////////////// /// \brief Handles the application being closed. Terminates worker threads, /// saves config settings/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnClose(wxCloseEvent& event){ wxRect rectWindow; int iDetailLevel; if (!g_pConfig->Read(wxT("CacheDownloads"), (long) 1)) ClearDownloadCache(); #ifdef USE_SCRIPTING delete m_ptmrScripting;#endif m_pfrmGPS->Hide(); m_pfrmDirections->Hide(); m_pfrmWhatsNearBy->Hide(); m_pfrmGPS->Destroy(); m_pfrmDirections->Destroy(); m_pfrmWhatsNearBy->Destroy(); Hide(); m_GPSMonitorThread->Delete(); delete m_GPSMonitorThread; m_DownloadThread->Delete(); delete m_DownloadThread; #ifdef USE_SCRIPTING delete m_pScripting;#endif LCDprocCleanup(); SaveMarkers(); Point ptCenter = m_ctlMap->GetCenterCoordinates(); g_pConfig->Write(wxT("CenterLong"), ptCenter.m_fLong); g_pConfig->Write(wxT("CenterLat"), ptCenter.m_fLat); g_pConfig->Write(wxT("MapAngle"), m_ctlMap->GetAngle()); g_pConfig->Write(wxT("DetailLevel"), m_ctlMap->GetDetailLevel() - m_iSpeedControlledDetailLevelOffset); m_ariRoadTypeZoomingDetailLevels[m_eRoadTypeZoomingCurrentType] = m_ctlMap->GetDetailLevel() - m_iSpeedControlledDetailLevelOffset; for (iDetailLevel = 0; iDetailLevel <= LAST_RECORD_TYPE; iDetailLevel++) g_pConfig->Write(wxString::Format(wxT("RoadTypeZoomingDetailLevels%d"), iDetailLevel), m_ariRoadTypeZoomingDetailLevels[iDetailLevel]); g_pConfig->Write(wxT("TrackGPSMarker"), m_bScreenTracksGPS); g_pConfig->Write(wxT("IsMaximized"), IsMaximized()); SaveWindowPosition(g_pConfig, this, wxT("Window")); SaveWindowPosition(g_pConfig, m_pfrmGPS, wxT("GPSWindow")); SaveWindowPosition(g_pConfig, m_pfrmDirections, wxT("DirectionsWindow")); SaveWindowPosition(g_pConfig, m_pfrmWhatsNearBy, wxT("WhatsNearByWindow")); delete m_pcTTS; m_ctlMap->PopEventHandler(true); g_pcStringTable->Save(); MapCleanup(); if (g_pConfig->Read(wxT("EnableExitCommand"), (long) 0)) wxExecute(g_pConfig->Read(wxT("ExitCommand"), GetDefaultShutdownCommand())); Destroy();}//////////////////////////////////////////////////////////////////////////////////// \brief Handles running a script/////////////////////////////////////////////////////////////////////////////////#ifdef USE_SCRIPTING void MapFrame::OnFileRunScript(wxCommandEvent & event){ wxFileDialog dlg(this, wxT("Run Script..."), wxT(""), wxT(""), wxT("*.rnv"),#if wxCHECK_VERSION(2, 8, 0) wxFD_OPEN | wxFD_FILE_MUST_EXIST#else wxOPEN | wxFILE_MUST_EXIST#endif ); if (dlg.ShowModal() == wxID_OK) { if (m_pScripting->RunFromFile(dlg.GetPath())) { wxMessageBox(wxT("Error running script"), wxT("Error"), wxOK | wxICON_ERROR, this); } else { wxMessageBox(wxT("Script run successfully"), wxT("Information"), wxOK | wxICON_INFORMATION, this); } }}#endif//////////////////////////////////////////////////////////////////////////////////// \brief Handles saving the shown map to a PNG file/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnFileSaveAs(wxCommandEvent & event){ wxFileDialog dlg(this, wxT("Save As..."), wxT(""), wxT(""), wxT("*.png"),#if wxCHECK_VERSION(2, 8, 0) wxFD_SAVE | wxFD_OVERWRITE_PROMPT#else wxSAVE | wxOVERWRITE_PROMPT#endif ); SaveAsSettingsDialog dlgSettings(this); if (dlgSettings.ShowModal() == wxID_OK) { if (dlg.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; sAddr = FindCoordinates(m_ctlMap->GetCenterCoordinates(), OnlyRoadsVisibility()); 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; sAddr = FindCoordinates(m_ctlMap->GetCenterCoordinates(), OnlyRoadsVisibility()); 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), g_pConfig->Read(wxT("AutoDownloadMaps"), (int) 1)); 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -