25 #include "OCPNListCtrl.h"
27 #include "model/ais_target_data.h"
28 #include "model/navutil_base.h"
29 #include "model/own_ship.h"
32 const wxPoint& pos,
const wxSize& size,
long style)
33 : wxListCtrl(parent, id, pos, size, style) {
37 OCPNListCtrl::~OCPNListCtrl() {
38 g_AisTargetList_column_spec.Clear();
39 for (
int i = 0; i < tlSOG + 1; i++) {
43 sitem.Printf(_T(
"%d;"), item.m_width);
44 g_AisTargetList_column_spec += sitem;
47 #ifdef wxHAS_LISTCTRL_COLUMN_ORDER
48 int i_columns = GetColumnCount();
49 wxArrayInt a_order(i_columns);
50 a_order = GetColumnsOrder();
51 g_AisTargetList_column_order.Clear();
52 for (
int i = 0; i < i_columns; i++) {
54 sitem.Printf(_T(
"%d;"), a_order[i]);
55 g_AisTargetList_column_order += sitem;
60 wxString OCPNListCtrl::OnGetItemText(
long item,
long column)
const {
63 if (m_parent->m_pListCtrlAISTargets) {
64 auto pAISTarget = m_parent->GetpTarget(item);
65 if (pAISTarget) ret = GetTargetColumnData(pAISTarget.get(), column);
71 int OCPNListCtrl::OnGetItemColumnImage(
long item,
long column)
const {
75 wxString OCPNListCtrl::GetTargetColumnData(
AisTargetData* pAISTarget,
82 if ((pAISTarget->Class == AIS_ATON) ||
83 (pAISTarget->Class == AIS_BASE) || (pAISTarget->Class == AIS_METEO))
85 else if (pAISTarget->b_show_track && !pAISTarget->b_NoTrack)
92 if ((!pAISTarget->b_nameValid && (pAISTarget->Class == AIS_BASE)) ||
93 (pAISTarget->Class == AIS_SART))
96 wxString uret = trimAISField(pAISTarget->ShipName);
97 if (uret == _T(
"Unknown"))
98 ret = wxGetTranslation(uret);
102 if (strlen(pAISTarget->ShipNameExtension))
103 ret.Append(wxString(pAISTarget->ShipNameExtension, wxConvUTF8));
108 ret = trimAISField(pAISTarget->CallSign);
112 if (pAISTarget->Class != AIS_GPSG_BUDDY)
113 ret.Printf(_T(
"%09d"), abs(pAISTarget->MMSI));
115 ret.Printf(_T(
" nil "));
119 if (pAISTarget->b_SarAircraftPosnReport) {
120 int airtype = (pAISTarget->MMSI % 1000) / 100;
121 ret = airtype == 5 ? _(
"SAR Helicopter") : _(
"SAR Aircraft");
123 ret = wxGetTranslation(pAISTarget->Get_class_string(
true));
127 if ((pAISTarget->Class == AIS_BASE) ||
128 (pAISTarget->Class == AIS_SART) ||
129 (pAISTarget->Class == AIS_METEO) ||
130 pAISTarget->b_SarAircraftPosnReport)
133 ret = wxGetTranslation(pAISTarget->Get_vessel_type_string(
false));
137 if (pAISTarget->Class == AIS_SART) {
138 if (pAISTarget->NavStatus == RESERVED_14)
140 else if (pAISTarget->NavStatus == UNDEFINED)
143 if ((pAISTarget->NavStatus <= 20) && (pAISTarget->NavStatus >= 0))
144 ret = wxGetTranslation(ais_get_status(pAISTarget->NavStatus));
149 if ((pAISTarget->Class == AIS_ATON) ||
150 (pAISTarget->Class == AIS_BASE) ||
151 (pAISTarget->Class == AIS_CLASS_B) ||
152 (pAISTarget->Class == AIS_METEO) ||
153 pAISTarget->b_SarAircraftPosnReport)
159 if (pAISTarget->b_positionOnceValid && bGPSValid &&
160 (pAISTarget->Brg >= 0.) && (fabs(pAISTarget->Lat) < 85.)) {
161 int brg = (int)wxRound(pAISTarget->Brg);
162 if (pAISTarget->Brg > 359.5) brg = 0;
164 ret.Printf(_T(
"%03d"), brg);
171 if ((pAISTarget->COG >= 360.0) || (pAISTarget->Class == AIS_ATON) ||
172 (pAISTarget->Class == AIS_BASE) || (pAISTarget->Class == AIS_METEO))
175 int crs = wxRound(pAISTarget->COG);
177 ret.Printf(_T(
" 000"));
179 ret.Printf(_T(
" %03d"), crs);
185 if (((pAISTarget->SOG > 100.) && !pAISTarget->b_SarAircraftPosnReport) ||
186 (pAISTarget->Class == AIS_ATON) || (pAISTarget->Class == AIS_BASE) ||
187 (pAISTarget->Class == AIS_METEO))
190 ret.Printf(_T(
"%5.1f"), toUsrSpeed(pAISTarget->SOG));
194 if ((!pAISTarget->bCPA_Valid) || (pAISTarget->Class == AIS_ATON) ||
195 (pAISTarget->Class == AIS_BASE) || (pAISTarget->Class == AIS_METEO))
198 ret.Printf(_T(
"%5.2f"), toUsrDistance(pAISTarget->CPA));
202 if ((!pAISTarget->bCPA_Valid) || (pAISTarget->Class == AIS_ATON) ||
203 (pAISTarget->Class == AIS_BASE) || (pAISTarget->Class == AIS_METEO))
206 ret.Printf(_T(
"%5.0f"), pAISTarget->TCPA);
210 if (pAISTarget->b_positionOnceValid && bGPSValid &&
211 (pAISTarget->Range_NM >= 0.))
212 ret.Printf(_T(
"%5.2f"), toUsrDistance(pAISTarget->Range_NM));
Global state for AIS decoder.