void AISTargetQueryDialog::UpdateText() { wxString html; if( !m_pQueryTextCtl ) return; DimeControl( this ); wxColor bg = GetBackgroundColour(); m_pQueryTextCtl->SetBackgroundColour( bg ); SetBackgroundColour( bg ); // if( m_MMSI == 0 ) { // Faulty MMSI could be reported as 0 AIS_Target_Data *td = g_pAIS->Get_Target_Data_From_MMSI( m_MMSI ); if( td ) { if( td->b_PersistTrack ) { m_createTrkBtn->SetLabel(_("Stop Tracking")); } else { m_createTrkBtn->SetLabel(_("Record Track")); } wxFont *dFont = FontMgr::Get().GetFont( _("AISTargetQuery") ); wxString face = dFont->GetFaceName(); int sizes[7]; for( int i=-2; i<5; i++ ) { sizes[i+2] = dFont->GetPointSize() + i + (i>0?i:0); } html.Printf( _T("<html><body bgcolor=#%02x%02x%02x><center>"), bg.Red(), bg.Green(), bg.Blue() ); html << td->BuildQueryResult(); html << _T("</center></font></body></html>"); m_pQueryTextCtl->SetFonts( face, face, sizes ); m_pQueryTextCtl->SetPage( html ); // Try to create a min size that works across font sizes. wxSize sz; if( ! IsShown() ) { sz = m_pQueryTextCtl->GetVirtualSize(); sz.x = 300; m_pQueryTextCtl->SetSize( sz ); } m_pQueryTextCtl->Layout(); wxSize ir(m_pQueryTextCtl->GetInternalRepresentation()->GetWidth(), m_pQueryTextCtl->GetInternalRepresentation()->GetHeight() ); sz.x = wxMax( m_pQueryTextCtl->GetSize().x, ir.x ); sz.y = wxMax( m_pQueryTextCtl->GetSize().y, ir.y ); m_pQueryTextCtl->SetMinSize( sz ); Fit(); sz -= wxSize( 200, 200 ); m_pQueryTextCtl->SetMinSize( sz ); m_createWptBtn->Enable( td->b_positionOnceValid ); m_createTrkBtn->Enable( td->b_show_track ); } // } }
void AISTargetQueryDialog::OnIdTrkCreateClick( wxCommandEvent& event ) { if( m_MMSI != 0 ) { // Faulty MMSI could be reported as 0 AIS_Target_Data *td = g_pAIS->Get_Target_Data_From_MMSI( m_MMSI ); if( td ) { if ( td->b_PersistTrack ) //The target was tracked and the user wants to stop it { td->b_PersistTrack = false; g_pAIS->m_persistent_tracks.erase(td->MMSI); m_createTrkBtn->SetLabel(_("Record Track")); } else { RoutePoint *rp = NULL; RoutePoint *rp1 = NULL; Track *t = new Track(); t->m_RouteNameString = wxString::Format( _T("AIS %s (%u) %s %s"), td->GetFullName().c_str(), td->MMSI, wxDateTime::Now().FormatISODate().c_str(), wxDateTime::Now().FormatISOTime().c_str() ); wxAISTargetTrackListNode *node = td->m_ptrack->GetFirst(); while( node ) { AISTargetTrackPoint *ptrack_point = node->GetData(); vector2D point( ptrack_point->m_lon, ptrack_point->m_lat ); rp1 = t->AddNewPoint( point, wxDateTime(ptrack_point->m_time).ToUTC() ); if( rp ) { pSelect->AddSelectableTrackSegment( rp->m_lat, rp->m_lon, rp1->m_lat, rp1->m_lon, rp, rp1, t ); } rp = rp1; node = node->GetNext(); } pRouteList->Append( t ); pConfig->AddNewRoute( t, -1 ); t->RebuildGUIDList(); // ensure the GUID list is intact and good if( pRouteManagerDialog && pRouteManagerDialog->IsShown() ) pRouteManagerDialog->UpdateTrkListCtrl(); Refresh( false ); if( wxID_YES == OCPNMessageBox(NULL, _("The recently captured track of this target has been recorded.\nDo you want to continue recording until the end of the current OpenCPN session?"), _("OpenCPN Info"), wxYES_NO | wxCENTER, 60 ) ) { td->b_PersistTrack = true; g_pAIS->m_persistent_tracks[td->MMSI] = t; } } } } }
void AISTargetQueryDialog::UpdateText() { wxString html; if( !m_pQueryTextCtl ) return; int scroll_x, scroll_y; m_pQueryTextCtl->GetViewStart(&scroll_x, &scroll_y); DimeControl( this ); wxColor bg = GetBackgroundColour(); m_pQueryTextCtl->SetBackgroundColour( bg ); SetBackgroundColour( bg ); // if( m_MMSI == 0 ) { // Faulty MMSI could be reported as 0 AIS_Target_Data *td = g_pAIS->Get_Target_Data_From_MMSI( m_MMSI ); if( td ) { if( td->b_PersistTrack ) { m_createTrkBtn->SetLabel(_("Stop Tracking")); } else { m_createTrkBtn->SetLabel(_("Record Track")); } wxFont *dFont = FontMgr::Get().GetFont( _("AISTargetQuery") ); wxString face = dFont->GetFaceName(); int sizes[7]; for( int i=-2; i<5; i++ ) { sizes[i+2] = dFont->GetPointSize() + i + (i>0?i:0); } html.Printf( _T("<html><body bgcolor=#%02x%02x%02x><center>"), bg.Red(), bg.Green(), bg.Blue() ); html << td->BuildQueryResult(); html << _T("</center></font></body></html>"); m_pQueryTextCtl->SetFonts( face, face, sizes ); wxCharBuffer buf = html.ToUTF8(); if( buf.data() ) // string OK? m_pQueryTextCtl->SetPage( html ); if(!m_bsize_set){ SetBestSize(); m_bsize_set = true; } m_createWptBtn->Enable( td->b_positionOnceValid ); m_createTrkBtn->Enable( td->b_show_track ); } // } #ifdef __WXQT__ SetColorScheme( m_colorscheme ); #endif m_pQueryTextCtl->Scroll(scroll_x, scroll_y); }