-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue27 configure link #84
base: indigo-devel
Are you sure you want to change the base?
Changes from 3 commits
90ec936
8916efb
53c8271
e91fbeb
8f0b4cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,6 +240,32 @@ namespace urdf_editor | |
QMenu *menu = new QMenu(tree_widget_); | ||
menu->addAction("Add"); | ||
menu->addAction("Remove"); | ||
|
||
// Add menu for converting the link to base/tool0 if there are no base/tool0 before | ||
if (sel->parent() == link_root_) | ||
{ | ||
bool base_exist = link_names_.contains("base", Qt::CaseSensitive); | ||
bool tool0_exist = link_names_.contains("tool0", Qt::CaseSensitive); | ||
bool TCP_exist = link_names_.contains("TCP", Qt::CaseSensitive); | ||
if (!base_exist || !tool0_exist || !TCP_exist) | ||
{ | ||
menu->addSeparator(); | ||
QMenu *convertMenu = menu->addMenu("Convert to"); | ||
if (!base_exist) | ||
{ | ||
convertMenu->addAction("base"); | ||
} | ||
if (!tool0_exist) | ||
{ | ||
convertMenu->addAction("tool0"); | ||
} | ||
if (!TCP_exist) | ||
{ | ||
convertMenu->addAction("TCP"); | ||
} | ||
} | ||
} | ||
|
||
QAction *selected_item = menu->exec(tree_widget_->mapToGlobal(pos)); | ||
if (selected_item) | ||
{ | ||
|
@@ -254,6 +280,41 @@ namespace urdf_editor | |
addJoint(sel); | ||
} | ||
} | ||
else if (selected_item->text() == "tool0") | ||
{ | ||
// Firstly remove the link, then add new link named "tool0" | ||
// on_propertyWidget_linkNameChanged(ltree_to_link_property_[sel].get(), "tool0"); | ||
link_names_.removeOne(sel->text(0)); | ||
link_root_->removeChild(sel); | ||
boost::shared_ptr<urdf::Link> new_link(new urdf::Link()); | ||
new_link->name = "tool0"; | ||
model_->links_.insert(std::make_pair("tool0", new_link)); | ||
addLinkProperty(new_link); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does create a new |
||
} | ||
else if (selected_item->text() == "base") | ||
{ | ||
link_names_.removeOne(sel->text(0)); | ||
link_root_->removeChild(sel); | ||
boost::shared_ptr<urdf::Link> new_link(new urdf::Link()); | ||
new_link->name = "base"; | ||
model_->links_.insert(std::make_pair("base", new_link)); | ||
addLinkProperty(new_link); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See earlier comment about dangling link. |
||
} | ||
else if (selected_item->text() == "TCP") | ||
{ | ||
// Add TCP link | ||
link_names_.removeOne(sel->text(0)); | ||
link_root_->removeChild(sel); | ||
boost::shared_ptr<urdf::Link> new_link(new urdf::Link()); | ||
new_link->name = "TCP"; | ||
model_->links_.insert(std::make_pair("TCP", new_link)); | ||
addLinkProperty(new_link); | ||
// Add Joint which has TCP as a child and has origin property | ||
addJoint(joint_root_); | ||
JointPropertyPtr targetJoint = ctree_to_joint_property_[joint_root_->child(0)]; | ||
targetJoint->createOriginProperty(); | ||
targetJoint->loadProperty(property_editor_); | ||
} | ||
else | ||
{ | ||
if (sel->parent() == link_root_) | ||
|
@@ -302,7 +363,7 @@ namespace urdf_editor | |
if (ctree_to_joint_property_.contains(selt)) | ||
{ | ||
qDebug() << QString("The member ctree_to_joint_property_ contains the link %1").arg(selt->text(0)); | ||
|
||
JointPropertyPtr activeJoint = ctree_to_joint_property_[selt]; | ||
QMenu menu(property_editor_.get()); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this leak the
QTreeItemWidget
?