void CelestialNavigationDialog::UpdateSight(int idx, bool warnings) { Sight *s = (Sight*)wxUIntToPtr(m_lSights->GetItemData(idx)); // then add sights to the listctrl m_lSights->SetItem(idx, rmTYPE, SightType[s->m_Type]); m_lSights->SetItem(idx, rmBODY, s->m_Body); wxDateTime dt = s->m_DateTime; m_lSights->SetItem(idx, rmTIME, dt.FormatISODate() + _T(" ") + dt.FormatISOTime()); m_lSights->SetItem(idx, rmMEASUREMENT, wxString::Format(_T("%.4f"), s->m_Measurement)); if(s->m_Type == Sight::LUNAR) m_lSights->SetItem(idx, rmCOLOR, _("Time Correction") + wxString::Format(_T(": %.4f"), s->m_TimeCorrection)); else m_lSights->SetItem(idx, rmCOLOR, s->m_ColourName); m_lSights->SetColumnWidth(rmTYPE, wxLIST_AUTOSIZE); m_lSights->SetColumnWidth(rmBODY, wxLIST_AUTOSIZE); m_lSights->SetColumnWidth(rmTIME, wxLIST_AUTOSIZE); m_lSights->SetColumnWidth(rmCOLOR, wxLIST_AUTOSIZE); if(m_lSights->GetColumnWidth(1) < 20) m_lSights->SetColumnWidth(1, 50); if(m_lSights->GetColumnWidth(2) < 20) m_lSights->SetColumnWidth(2, 50); m_lSights->SortItems(SortSights, (long)m_lSights); UpdateButtons(); UpdateFix(warnings); }
void CelestialNavigationDialog::UpdateSights() { // if an item was selected, make it selected again if it still exist long selected_index = m_lSights->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); long selected_id = -1; if (selected_index > -1) selected_id = m_lSights->GetItemData(selected_index); // Delete existing items m_lSights->DeleteAllItems(); // then add sights to the listctrl SightList::iterator it; wxListItem item; int index = 0; for (it = m_SightList.begin(); it != m_SightList.end(); ++it, ++index) { item.SetId(index); item.SetImage((*it)->IsVisible() ? 0 : -1); item.SetData(index); long idx = m_lSights->InsertItem(item); m_lSights->SetItemImage(index, (*it)->IsVisible() ? 0 : -1); m_lSights->SetItem(idx, rmTYPE, (*it)->m_Type ? _("Azimuth") : _("Altitude")); m_lSights->SetItem(idx, rmBODY, (*it)->m_Body); m_lSights->SetItem(idx, rmTIME, (*it)->m_DateTime.Format()); m_lSights->SetItem(idx, rmMEASUREMENT, wxString::Format(_T("%.4f"), (*it)->m_Measurement)); m_lSights->SetItem(idx, rmCOLOR, wxString::Format(_T("0x%hhx%hhx%hhx"), (*it)->m_Colour.Red(), (*it)->m_Colour.Green(), (*it)->m_Colour.Blue())); } m_lSights->SetColumnWidth(1, wxLIST_AUTOSIZE); m_lSights->SetColumnWidth(2, wxLIST_AUTOSIZE); if(m_lSights->GetColumnWidth(1) < 20) m_lSights->SetColumnWidth(1, 50); if(m_lSights->GetColumnWidth(2) < 20) m_lSights->SetColumnWidth(2, 50); m_lSights->SortItems(SortSights, (long)m_lSights); // restore selection if possible // NOTE this will select a different item, if one is deleted // (the next sight will get that index). if (selected_id > -1) { selected_index = m_lSights->FindItem(-1, selected_id); m_lSights->SetItemState(selected_index, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); } UpdateButtons(); UpdateFix(); }
void Gps::BeforePhysicsStep(const Timekeeper &timekeeper) { // keep the update rate if (!update_timer_.CheckUpdate(timekeeper)) { return; } // only compute and publish when the number of subscribers is not zero if (fix_publisher_.getNumSubscribers() > 0) { UpdateFix(); gps_fix_.header.stamp = timekeeper.GetSimTime(); fix_publisher_.publish(gps_fix_); } if (broadcast_tf_) { gps_tf_.header.stamp = timekeeper.GetSimTime(); tf_broadcaster_.sendTransform(gps_tf_); } }