1313#include < QSettings>
1414#include < QRadioButton>
1515#include < unordered_map>
16+ #include < algorithm>
1617#include < QMessageBox>
1718#include < tf2_ros/qos.hpp>
1819#include < rosbag2_cpp/types.hpp>
@@ -51,7 +52,7 @@ void TopicPublisherROS2::updatePublishers()
5152 {
5253 return ;
5354 }
54- for (const auto & info : _topics_info)
55+ for (const auto & info : _topics_info)
5556 {
5657 auto to_publish = _topics_to_publish.find (info.topic_name );
5758 if (to_publish == _topics_to_publish.end () || to_publish->second == false )
@@ -62,7 +63,7 @@ void TopicPublisherROS2::updatePublishers()
6263 auto publisher_it = _publishers.find (info.topic_name );
6364 if (publisher_it == _publishers.end ())
6465 {
65- _publishers.insert ({ info.topic_name , GenericPublisher::create (*_node, info.topic_name , info.type ) });
66+ _publishers.insert ({info.topic_name , GenericPublisher::create (*_node, info.topic_name , info.type )});
6667 }
6768 }
6869
@@ -153,7 +154,9 @@ void TopicPublisherROS2::filterDialog()
153154
154155 std::map<std::string, QCheckBox*> checkbox;
155156
156- for (const TopicInfo& info : _topics_info)
157+ std::map<std::string, QCheckBox *> checkbox;
158+
159+ for (const TopicInfo &info : sorted_topics)
157160 {
158161 const std::string topic_name = info.topic_name ;
159162 auto cb = new QCheckBox (dialog);
@@ -169,18 +172,20 @@ void TopicPublisherROS2::filterDialog()
169172 cb->setFocusPolicy (Qt::NoFocus);
170173 dialog->ui ()->formLayout ->addRow (new QLabel (QString::fromStdString (topic_name)), cb);
171174 checkbox.insert (std::make_pair (topic_name, cb));
172- connect (dialog->ui ()->pushButtonSelect , &QPushButton::pressed, [cb]() { cb->setChecked (true ); });
173- connect (dialog->ui ()->pushButtonDeselect , &QPushButton::pressed, [cb]() { cb->setChecked (false ); });
175+ connect (dialog->ui ()->pushButtonSelect , &QPushButton::pressed, [cb]()
176+ { cb->setChecked (true ); });
177+ connect (dialog->ui ()->pushButtonDeselect , &QPushButton::pressed, [cb]()
178+ { cb->setChecked (false ); });
174179 }
175180
176181 dialog->exec ();
177182
178183 if (dialog->result () == QDialog::Accepted)
179184 {
180185 _topics_to_publish.clear ();
181- for (const auto & it : checkbox)
186+ for (const auto & it : checkbox)
182187 {
183- _topics_to_publish.insert ({ it.first , it.second ->isChecked () });
188+ _topics_to_publish.insert ({it.first , it.second ->isChecked ()});
184189 }
185190
186191 updatePublishers ();
@@ -189,12 +194,12 @@ void TopicPublisherROS2::filterDialog()
189194
190195constexpr long NSEC_PER_SEC = 1000000000 ;
191196
192- rcutils_time_point_value_t Convert (const builtin_interfaces::msg::Time& stamp)
197+ rcutils_time_point_value_t Convert (const builtin_interfaces::msg::Time & stamp)
193198{
194199 return stamp.nanosec + NSEC_PER_SEC * stamp.sec ;
195200}
196201
197- builtin_interfaces::msg::Time Convert (const rcutils_time_point_value_t & time_stamp)
202+ builtin_interfaces::msg::Time Convert (const rcutils_time_point_value_t & time_stamp)
198203{
199204 builtin_interfaces::msg::Time stamp;
200205 stamp.sec = static_cast <int32_t >(time_stamp / NSEC_PER_SEC );
@@ -316,14 +321,14 @@ void TopicPublisherROS2::updateState(double current_time)
316321 auto data_it = _datamap->user_defined .find (" plotjuggler::rosbag2_cpp::consecutive_messages" );
317322 if (data_it != _datamap->user_defined .end ())
318323 {
319- const PJ ::PlotDataAny& continuous_msgs = data_it->second ;
324+ const PJ ::PlotDataAny & continuous_msgs = data_it->second ;
320325 _previous_play_index = continuous_msgs.getIndexFromX (current_time);
321326 }
322327
323- for (const auto & data_it : _datamap->user_defined )
328+ for (const auto & data_it : _datamap->user_defined )
324329 {
325- const std::string& topic_name = data_it.first ;
326- const PJ ::PlotDataAny& plot_any = data_it.second ;
330+ const std::string & topic_name = data_it.first ;
331+ const PJ ::PlotDataAny & plot_any = data_it.second ;
327332
328333 if (topic_name == " /tf" || topic_name == " tf_static" )
329334 {
@@ -342,11 +347,11 @@ void TopicPublisherROS2::updateState(double current_time)
342347 continue ;
343348 }
344349
345- const auto & any_value = plot_any.at (last_index).y ;
350+ const auto & any_value = plot_any.at (last_index).y ;
346351
347352 if (any_value.type () == typeid (MessageRefPtr))
348353 {
349- const auto & msg_instance = std::any_cast<MessageRefPtr>(any_value);
354+ const auto & msg_instance = std::any_cast<MessageRefPtr>(any_value);
350355 publisher_it->second ->publish (msg_instance->serialized_data );
351356 }
352357 }
@@ -364,7 +369,7 @@ void TopicPublisherROS2::play(double current_time)
364369 {
365370 return ;
366371 }
367- const PJ ::PlotDataAny& continuous_msgs = data_it->second ;
372+ const PJ ::PlotDataAny & continuous_msgs = data_it->second ;
368373 int current_index = continuous_msgs.getIndexFromX (current_time);
369374
370375 if (_previous_play_index > current_index)
@@ -375,13 +380,13 @@ void TopicPublisherROS2::play(double current_time)
375380 }
376381 else
377382 {
378- const PJ ::PlotDataAny& consecutive_msg = data_it->second ;
383+ const PJ ::PlotDataAny & consecutive_msg = data_it->second ;
379384 for (int index = _previous_play_index + 1 ; index <= current_index; index++)
380385 {
381- const auto & any_value = consecutive_msg.at (index).y ;
386+ const auto & any_value = consecutive_msg.at (index).y ;
382387 if (any_value.type () == typeid (MessageRefPtr))
383388 {
384- const auto & msg_instance = std::any_cast<MessageRefPtr>(any_value);
389+ const auto & msg_instance = std::any_cast<MessageRefPtr>(any_value);
385390
386391 auto publisher_it = _publishers.find (msg_instance->topic_name );
387392 if (publisher_it == _publishers.end ())
0 commit comments