40 #include <QFormLayout> 41 #include <QMessageBox> 42 #include <QApplication> 53 QVBoxLayout* layout =
new QVBoxLayout();
58 new HeaderWidget(
"Define Virtual Joints",
"Create a virtual joint between a robot link and an external frame of " 59 "reference (considered fixed with respect to the robot).",
61 layout->addWidget(header);
74 QWidget* stacked_layout_widget =
new QWidget(
this);
77 layout->addWidget(stacked_layout_widget);
80 this->setLayout(layout);
89 QWidget* content_widget =
new QWidget(
this);
92 QVBoxLayout* layout =
new QVBoxLayout(
this);
99 data_table_->setSelectionBehavior(QAbstractItemView::SelectRows);
105 QStringList header_list;
106 header_list.append(
"Virtual Joint Name");
107 header_list.append(
"Child Link");
108 header_list.append(
"Parent Frame");
109 header_list.append(
"Type");
110 data_table_->setHorizontalHeaderLabels(header_list);
114 QHBoxLayout* controls_layout =
new QHBoxLayout();
117 QWidget* spacer =
new QWidget(
this);
118 spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
119 controls_layout->addWidget(spacer);
122 btn_edit_ =
new QPushButton(
"&Edit Selected",
this);
123 btn_edit_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
128 controls_layout->setAlignment(
btn_edit_, Qt::AlignRight);
131 btn_delete_ =
new QPushButton(
"&Delete Selected",
this);
134 controls_layout->setAlignment(
btn_delete_, Qt::AlignRight);
137 QPushButton* btn_add =
new QPushButton(
"&Add Virtual Joint",
this);
138 btn_add->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
139 btn_add->setMaximumWidth(300);
140 connect(btn_add, SIGNAL(clicked()),
this, SLOT(
showNewScreen()));
141 controls_layout->addWidget(btn_add);
142 controls_layout->setAlignment(btn_add, Qt::AlignRight);
145 layout->addLayout(controls_layout);
148 content_widget->setLayout(layout);
150 return content_widget;
159 QWidget* edit_widget =
new QWidget(
this);
161 QVBoxLayout* layout =
new QVBoxLayout();
164 QFormLayout* form_layout =
new QFormLayout();
166 form_layout->setRowWrapPolicy(QFormLayout::WrapAllRows);
189 layout->addLayout(form_layout);
193 QHBoxLayout* controls_layout =
new QHBoxLayout();
194 controls_layout->setContentsMargins(0, 25, 0, 15);
197 QWidget* spacer =
new QWidget(
this);
198 spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
199 controls_layout->addWidget(spacer);
202 QPushButton*
btn_save_ =
new QPushButton(
"&Save",
this);
203 btn_save_->setMaximumWidth(200);
204 connect(btn_save_, SIGNAL(clicked()),
this, SLOT(
doneEditing()));
205 controls_layout->addWidget(btn_save_);
206 controls_layout->setAlignment(btn_save_, Qt::AlignRight);
209 QPushButton*
btn_cancel_ =
new QPushButton(
"&Cancel",
this);
210 btn_cancel_->setMaximumWidth(200);
211 connect(btn_cancel_, SIGNAL(clicked()),
this, SLOT(
cancelEditing()));
212 controls_layout->addWidget(btn_cancel_);
213 controls_layout->setAlignment(btn_cancel_, Qt::AlignRight);
216 layout->addLayout(controls_layout);
219 edit_widget->setLayout(layout);
289 QList<QTableWidgetItem*> selected =
data_table_->selectedItems();
292 if (!selected.size())
296 edit(selected[0]->
text().toStdString());
318 QMessageBox::critical(
this,
"Error Loading",
"Unable to find child link in drop down box");
327 QMessageBox::critical(
this,
"Error Loading",
"Unable to find joint type in drop down box");
362 std::vector<const robot_model::LinkModel*> link_models =
config_data_->getRobotModel()->getLinkModels();
365 for (std::vector<const robot_model::LinkModel*>::const_iterator link_it = link_models.begin();
366 link_it < link_models.end(); ++link_it)
380 for (std::vector<srdf::Model::VirtualJoint>::iterator vjoint_it =
config_data_->srdf_->virtual_joints_.begin();
381 vjoint_it !=
config_data_->srdf_->virtual_joints_.end(); ++vjoint_it)
383 if (vjoint_it->name_ == name)
385 searched_group = &(*vjoint_it);
391 if (searched_group ==
NULL)
393 QMessageBox::critical(
this,
"Error Saving",
"An internal error has occured while saving. Quitting.");
394 QApplication::quit();
397 return searched_group;
406 QList<QTableWidgetItem*> selected =
data_table_->selectedItems();
409 if (!selected.size())
416 if (QMessageBox::question(
this,
"Confirm Virtual Joint Deletion",
417 QString(
"Are you sure you want to delete the virtual joint '")
420 QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel)
426 for (std::vector<srdf::Model::VirtualJoint>::iterator vjoint_it =
config_data_->srdf_->virtual_joints_.begin();
427 vjoint_it !=
config_data_->srdf_->virtual_joints_.end(); ++vjoint_it)
455 if (vjoint_name.empty())
457 QMessageBox::warning(
this,
"Error Saving",
"A name must be given for the virtual joint!");
462 if (parent_name.empty())
464 QMessageBox::warning(
this,
"Error Saving",
"A name must be given for the parent frame");
476 for (std::vector<srdf::Model::VirtualJoint>::const_iterator data_it =
config_data_->srdf_->virtual_joints_.begin();
477 data_it !=
config_data_->srdf_->virtual_joints_.end(); ++data_it)
479 if (data_it->name_.compare(vjoint_name) == 0)
482 if (&(*data_it) != searched_data)
484 QMessageBox::warning(
this,
"Error Saving",
"A virtual joint already exists with that name!");
493 QMessageBox::warning(
this,
"Error Saving",
"A joint type must be chosen!");
500 QMessageBox::warning(
this,
"Error Saving",
"A child link must be chosen!");
509 if (searched_data ==
NULL)
517 searched_data->
name_ = vjoint_name;
522 bool emit_frame_notice =
false;
528 emit_frame_notice =
true;
529 config_data_->srdf_->virtual_joints_.push_back(*searched_data);
545 if (emit_frame_notice)
578 for (std::vector<srdf::Model::VirtualJoint>::const_iterator data_it =
config_data_->srdf_->virtual_joints_.begin();
579 data_it !=
config_data_->srdf_->virtual_joints_.end(); ++data_it)
582 QTableWidgetItem* data_name =
new QTableWidgetItem(data_it->name_.c_str());
583 data_name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
584 QTableWidgetItem* child_link_name =
new QTableWidgetItem(data_it->child_link_.c_str());
585 child_link_name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
586 QTableWidgetItem* parent_frame_name =
new QTableWidgetItem(data_it->parent_frame_.c_str());
587 parent_frame_name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
588 QTableWidgetItem* type_name =
new QTableWidgetItem(data_it->type_.c_str());
589 type_name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
std::string parent_frame_
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)