54 #include <QMessageBox> 55 #include <QInputDialog> 57 #include "ui_motion_planning_rviz_plugin_frame.h" 59 #include <boost/math/constants/constants.hpp> 72 std::unique_ptr<QMessageBox>
q;
74 q.reset(
new QMessageBox(QMessageBox::Question,
"Change Planning Scene Name",
75 QString(
"The name for the planning scene should not be empty. Would you like to rename " 76 "the planning scene?'"),
77 QMessageBox::Cancel,
this));
79 q.reset(
new QMessageBox(QMessageBox::Question,
"Confirm Planning Scene Overwrite",
80 QString(
"A planning scene named '")
82 .
append(
"' already exists. Do you wish to " 83 "overwrite that scene?"),
84 QMessageBox::Yes | QMessageBox::No,
this));
85 std::unique_ptr<QPushButton> rename(q->addButton(
"&Rename", QMessageBox::AcceptRole));
86 if (q->exec() != QMessageBox::Yes)
88 if (q->clickedButton() == rename.get())
91 QString new_name = QInputDialog::getText(
this,
"Rename Planning Scene",
"New name for the planning scene:",
92 QLineEdit::Normal, QString::fromStdString(name), &ok);
99 bool old = prop->blockSignals(
true);
101 prop->blockSignals(old);
125 QList<QTreeWidgetItem*> sel =
ui_->planning_scene_tree->selectedItems();
128 QTreeWidgetItem*
s = sel.front();
133 std::string scene = s->text(0).toStdString();
140 std::string scene = s->parent()->text(0).toStdString();
141 std::string query_name = s->text(0).toStdString();
145 std::unique_ptr<QMessageBox>
q;
146 if (query_name.empty())
147 q.reset(
new QMessageBox(QMessageBox::Question,
"Change Planning Query Name",
148 QString(
"The name for the planning query should not be empty. Would you like to " 149 "rename the planning query?'"),
150 QMessageBox::Cancel,
this));
152 q.reset(
new QMessageBox(QMessageBox::Question,
"Confirm Planning Query Overwrite",
153 QString(
"A planning query named '")
154 .
append(query_name.c_str())
155 .
append(
"' already exists. Do you wish " 156 "to overwrite that query?"),
157 QMessageBox::Yes | QMessageBox::No,
this));
158 std::unique_ptr<QPushButton> rename(q->addButton(
"&Rename", QMessageBox::AcceptRole));
159 if (q->exec() == QMessageBox::Yes)
163 if (q->clickedButton() == rename.get())
167 QInputDialog::getText(
this,
"Rename Planning Query",
"New name for the planning query:",
168 QLineEdit::Normal, QString::fromStdString(query_name), &ok);
170 query_name = new_name.toStdString();
211 if (item->text(column) == item->toolTip(column) || item->toolTip(column).length() == 0)
214 if (!planning_scene_storage)
219 std::string new_name = item->text(column).toStdString();
221 if (planning_scene_storage->hasPlanningScene(new_name))
224 QMessageBox::warning(
this,
"Scene not renamed",
225 QString(
"The scene name '").
append(item->text(column)).
append(
"' already exists"));
230 std::string old_name = item->toolTip(column).toStdString();
231 planning_scene_storage->renamePlanningScene(old_name, new_name);
232 item->setToolTip(column, item->text(column));
237 std::string scene = item->parent()->text(0).toStdString();
238 std::string new_name = item->text(column).toStdString();
239 if (planning_scene_storage->hasPlanningQuery(scene, new_name))
242 QMessageBox::warning(
this,
"Query not renamed", QString(
"The query name '")
243 .
append(item->text(column))
244 .
append(
"' already exists for scene ")
245 .append(item->parent()->text(0)));
250 std::string old_name = item->toolTip(column).toStdString();
251 planning_scene_storage->renamePlanningQuery(scene, old_name, new_name);
252 item->setToolTip(column, item->text(column));
260 if (!planning_scene_storage)
263 ui_->planning_scene_tree->setUpdatesEnabled(
false);
266 std::set<std::string> expanded;
267 for (
int i = 0; i <
ui_->planning_scene_tree->topLevelItemCount(); ++i)
269 QTreeWidgetItem* it =
ui_->planning_scene_tree->topLevelItem(i);
270 if (it->isExpanded())
271 expanded.insert(it->text(0).toStdString());
274 ui_->planning_scene_tree->clear();
275 std::vector<std::string> names;
276 planning_scene_storage->getPlanningSceneNames(names);
278 for (std::size_t i = 0; i < names.size(); ++i)
280 std::vector<std::string> query_names;
281 planning_scene_storage->getPlanningQueriesNames(query_names, names[i]);
282 QTreeWidgetItem* item =
283 new QTreeWidgetItem(
ui_->planning_scene_tree, QStringList(QString::fromStdString(names[i])),
ITEM_TYPE_SCENE);
284 item->setFlags(item->flags() | Qt::ItemIsEditable);
285 item->setToolTip(0, item->text(0));
286 for (std::size_t j = 0; j < query_names.size(); ++j)
288 QTreeWidgetItem* subitem =
289 new QTreeWidgetItem(item, QStringList(QString::fromStdString(query_names[j])),
ITEM_TYPE_QUERY);
290 subitem->setFlags(subitem->flags() | Qt::ItemIsEditable);
291 subitem->setToolTip(0, subitem->text(0));
292 item->addChild(subitem);
295 ui_->planning_scene_tree->insertTopLevelItem(
ui_->planning_scene_tree->topLevelItemCount(), item);
296 if (expanded.find(names[i]) != expanded.end())
297 ui_->planning_scene_tree->expandItem(item);
299 ui_->planning_scene_tree->sortItems(0, Qt::AscendingOrder);
300 ui_->planning_scene_tree->setUpdatesEnabled(
true);
static const int ITEM_TYPE_QUERY
planning_scene_monitor::LockedPlanningSceneRW getPlanningSceneRW()
get write access to planning scene
void saveQueryButtonClicked()
virtual bool setValue(const QVariant &new_value)
void saveSceneButtonClicked()
void computeSaveQueryButtonClicked(const std::string &scene, const std::string &query_name)
void checkPlanningSceneTreeEnabledButtons()
void populatePlanningSceneTreeView()
void loadSceneButtonClicked()
static const int ITEM_TYPE_SCENE
void computeSaveSceneButtonClicked()
void computeLoadSceneButtonClicked()
virtual Property * subProp(const QString &sub_name)
void addBackgroundJob(const boost::function< void()> &job, const std::string &name)
void computeDeleteQueryButtonClicked()
MotionPlanningDisplay * planning_display_
Ui::MotionPlanningUI * ui_
void computeLoadQueryButtonClicked()
void addMainLoopJob(const boost::function< void()> &job)
queue the execution of this function for the next time the main update() loop gets called ...
void warehouseItemNameChanged(QTreeWidgetItem *item, int column)
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
void deleteSceneButtonClicked()
void loadQueryButtonClicked()
void computeDeleteSceneButtonClicked()
moveit_warehouse::PlanningSceneStoragePtr planning_scene_storage_
void deleteQueryButtonClicked()
planning_scene_monitor::LockedPlanningSceneRO getPlanningSceneRO() const
get read-only access to planning scene
void planningSceneItemClicked()