7 std::deque<std::shared_ptr<TopicData>> already_displayed_topics,
8 const std::vector<std::string> allowed_types,
9 const bool single_choice,
12 already_displayed_topics_(already_displayed_topics),
13 allowed_types_(allowed_types),
14 single_choice_(single_choice)
16 setWindowTitle(
"Topics selection");
17 QVBoxLayout *main_layout =
new QVBoxLayout;
18 setLayout(main_layout);
19 QVBoxLayout *scroll_widget_layout =
new QVBoxLayout;
20 QWidget *scroll_widget =
new QWidget;
21 scroll_widget->setLayout(scroll_widget_layout);
22 QScrollArea *scroll_area =
new QScrollArea;
23 scroll_area->setWidget(scroll_widget);
24 scroll_area->setWidgetResizable(
true);
25 scroll_area->setFrameShape(QFrame::NoFrame);
29 return a.
name < b.name;
34 QAbstractButton *button;
36 button =
new QRadioButton;
38 button =
new QCheckBox;
41 button->setText(QString::fromStdString(topic.name));
42 button->setObjectName(QString::fromStdString(topic.name));
43 button->setToolTip(QString::fromStdString(topic.datatype));
51 button->setChecked(
true);
54 scroll_widget_layout->addWidget(button);
57 main_layout->addWidget(scroll_area);
58 QDialogButtonBox *button_box =
new QDialogButtonBox(QDialogButtonBox::Ok
59 | QDialogButtonBox::Cancel);
60 main_layout->addWidget(button_box);
63 connect(button_box, &QDialogButtonBox::rejected,
this, &QDialog::reject);
77 Q_EMIT
displayMessageBox(
"Error getting topics",
"Could not retrieve the topics names.",
"",
78 QMessageBox::Icon::Critical);
82 for (
auto topic : topics)
86 if (topic.datatype == type)
98 const QMessageBox::Icon icon)
100 const bool old_state(isEnabled());
103 msg_box.setWindowTitle(title);
104 msg_box.setText(text);
105 msg_box.setInformativeText(info);
106 msg_box.setIcon(icon);
107 msg_box.setStandardButtons(QMessageBox::Ok);
109 setEnabled(old_state);
117 if (!button->isChecked())
120 std::shared_ptr<TopicData> topic_data =
121 std::make_shared<TopicData>(button->objectName().toStdString(), button->toolTip().toStdString(),
nh_);
const bool single_choice_
std::deque< std::shared_ptr< TopicData > > displayed_topics_
ROSCPP_DECL bool getTopics(V_TopicInfo &topics)
std::vector< TopicInfo > V_TopicInfo
std::deque< std::shared_ptr< TopicData > > already_displayed_topics_
std::vector< QAbstractButton * > topic_buttons_
const std::vector< std::string > allowed_types_
void displayMessageBoxHandler(const QString title, const QString text, const QString info="", const QMessageBox::Icon icon=QMessageBox::Icon::Information)
SelectionTopics(std::shared_ptr< ros::NodeHandle > nh, std::deque< std::shared_ptr< TopicData >> already_displayed_topics, const std::vector< std::string > allowed_types, const bool single_choice, QDialog *parent=0)
ros::master::V_TopicInfo supported_topics_
void displayMessageBox(const QString, const QString, const QString, const QMessageBox::Icon)
std::shared_ptr< ros::NodeHandle > nh_