void WeatherRouting::OnRemovePosition( wxCommandEvent& event ) { long index = m_lPositions->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if(index < 0) return; wxListItem it; it.SetId(index); it.SetColumn(0); m_lPositions->GetItem(it); wxString name = it.GetText(); for(std::list<RouteMapPosition>::iterator it = RouteMap::Positions.begin(); it != RouteMap::Positions.end(); it++) if((*it).Name == name) { RouteMap::Positions.erase(it); break; } m_ConfigurationDialog.RemoveSource(name); m_ConfigurationBatchDialog.RemoveSource(name); m_lPositions->DeleteItem(index); UpdateConfigurations(); }
to edit the first column, so this doesn't work */ void WeatherRouting::OnListLabelEdit( wxListEvent& event ) { long index = event.GetIndex(); int col = event.GetColumn(); long i = 0; for(std::list<RouteMapPosition>::iterator it = RouteMap::Positions.begin(); it != RouteMap::Positions.end(); it++, i++) if(i == index) { if(col == POSITION_NAME) { (*it).Name = event.GetText(); } else { double value; event.GetText().ToDouble(&value); if(col == POSITION_LAT) (*it).lat = value; else if(col == POSITION_LON) (*it).lon = value; m_lPositions->SetItem(index, col, wxString::Format(_T("%.5f"), value)); UpdateConfigurations(); } } }
void WeatherRouting::AddPosition(double lat, double lon) { wxTextEntryDialog pd( this, _("Enter Name"), _("New Position") ); if(pd.ShowModal() == wxID_OK) { wxString name = pd.GetValue(); for(std::list<RouteMapPosition>::iterator it = RouteMap::Positions.begin(); it != RouteMap::Positions.end(); it++) { if((*it).Name == name) { wxMessageDialog mdlg(this, _("This name already exists, replace?\n"), _("Weather Routing"), wxYES | wxNO | wxICON_ERROR); if(mdlg.ShowModal() == wxID_YES) { long index = m_lPositions->FindItem(0, name); (*it).lat = lat; (*it).lon = lon; m_lPositions->SetItem(index, POSITION_LAT, wxString::Format(_T("%.5f"), lat)); m_lPositions->SetItem(index, POSITION_LON, wxString::Format(_T("%.5f"), lon)); } UpdateConfigurations(); return; } } // for AddPosition(lat, lon, name); } }
void WeatherRouting::AddPosition(double lat, double lon, wxString name) { RouteMap::Positions.push_back(RouteMapPosition(name, lat, lon)); UpdateConfigurations(); // Test WXOSX Assert InsertItem wxListItem item; long index = m_lPositions->InsertItem(m_lPositions->GetItemCount(), item); m_lPositions->SetItem(index, POSITION_NAME, name); m_lPositions->SetColumnWidth(POSITION_NAME, wxLIST_AUTOSIZE); m_lPositions->SetItem(index, POSITION_LAT, wxString::Format(_T("%.5f"), lat)); m_lPositions->SetItem(index, POSITION_LON, wxString::Format(_T("%.5f"), lon)); m_ConfigurationDialog.AddSource(name); m_ConfigurationBatchDialog.AddSource(name); }
void WeatherRouting::OnUpdateBoat( wxCommandEvent& event ) { double lat = m_weather_routing_pi.m_boat_lat; double lon = m_weather_routing_pi.m_boat_lon; long index = 0; for(std::list<RouteMapPosition>::iterator it = RouteMap::Positions.begin(); it != RouteMap::Positions.end(); it++, index++) if((*it).Name == _("Boat")) { m_lPositions->SetItem(index, POSITION_LAT, wxString::Format(_T("%.5f"), lat)); m_lPositions->SetItem(index, POSITION_LON, wxString::Format(_T("%.5f"), lon)); (*it).lat = lat, (*it).lon = lon; UpdateConfigurations(); return; } AddPosition(lat, lon, _("Boat")); }
int Session::UpdateConfigurations(UpdateProxy<Configuration>* proxy) { return UpdateConfigurations(proxy, ""); }