37 #include <QVBoxLayout>
38 #include <QHBoxLayout>
40 #include <QPushButton>
41 #include <QGridLayout>
43 #include <QMessageBox>
45 #include <QTreeWidget>
56 : QWidget(parent), rviz_panel_(rviz_panel)
59 QVBoxLayout* layout =
new QVBoxLayout();
62 title_ =
new QLabel(
"",
this);
63 QFont group_title_font(QFont().defaultFamily(), 12, QFont::Bold);
64 title_->setFont(group_title_font);
70 connect(
link_tree_, SIGNAL(itemSelectionChanged()),
this, SLOT(itemSelected()));
74 QGridLayout* form_grid =
new QGridLayout();
75 form_grid->setContentsMargins(20, 20, 20, 20);
78 QLabel* base_link_label =
new QLabel(
"Base Link",
this);
79 form_grid->addWidget(base_link_label, 0, 0, Qt::AlignRight);
85 QPushButton* btn_base_link =
new QPushButton(
"Choose Selected",
this);
86 connect(btn_base_link, SIGNAL(clicked()),
this, SLOT(baseLinkTreeClick()));
87 form_grid->addWidget(btn_base_link, 0, 2, Qt::AlignLeft);
90 QLabel* tip_link_label =
new QLabel(
"Tip Link",
this);
91 form_grid->addWidget(tip_link_label, 1, 0, Qt::AlignRight);
97 QPushButton* btn_tip_link =
new QPushButton(
"Choose Selected",
this);
98 connect(btn_tip_link, SIGNAL(clicked()),
this, SLOT(tipLinkTreeClick()));
99 form_grid->addWidget(btn_tip_link, 1, 2, Qt::AlignLeft);
102 layout->addLayout(form_grid);
105 QHBoxLayout* controls_layout =
new QHBoxLayout();
108 QLabel* expand_controls =
new QLabel(
this);
109 expand_controls->setText(
"<a href='expand'>Expand All</a> <a href='contract'>Collapse All</a>");
110 connect(expand_controls, SIGNAL(linkActivated(
const QString)),
this, SLOT(alterTree(
const QString)));
111 controls_layout->addWidget(expand_controls);
114 controls_layout->addItem(
new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
117 QPushButton* btn_save =
new QPushButton(
"&Save",
this);
118 btn_save->setMaximumWidth(200);
119 connect(btn_save, SIGNAL(clicked()),
this, SIGNAL(
doneEditing()));
120 controls_layout->addWidget(btn_save);
121 controls_layout->setAlignment(btn_save, Qt::AlignRight);
124 QPushButton* btn_cancel =
new QPushButton(
"&Cancel",
this);
125 btn_cancel->setMaximumWidth(200);
126 connect(btn_cancel, SIGNAL(clicked()),
this, SIGNAL(
cancelEditing()));
127 controls_layout->addWidget(btn_cancel);
128 controls_layout->setAlignment(btn_cancel, Qt::AlignRight);
131 layout->addLayout(controls_layout);
134 this->setLayout(layout);
137 kinematic_chain_loaded_ =
false;
146 if (kinematic_chain_loaded_)
153 kinematic_chain_loaded_ =
true;
161 QTreeWidgetItem* new_item =
new QTreeWidgetItem(parent);
162 new_item->setText(0, link.
data.c_str());
167 new_item->addChild(new_child);
184 void KinematicChainWidget::baseLinkTreeClick()
186 QTreeWidgetItem* item =
link_tree_->currentItem();
196 void KinematicChainWidget::tipLinkTreeClick()
198 QTreeWidgetItem* item =
link_tree_->currentItem();
208 void KinematicChainWidget::alterTree(
const QString& link)
210 if (link.contains(
"expand"))
219 void KinematicChainWidget::itemSelected()
221 QTreeWidgetItem* item =
link_tree_->currentItem();
226 std::string
name = item->text(0).toStdString();
233 rviz_panel_->
highlightLink(item->text(0).toStdString(), QColor(255, 0, 0));
void highlightLink(const std::string &link_name, const QColor &color)
std::vector< LinkNameTree > children