Skip to content
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

Support copy/paste #1013

Merged
merged 30 commits into from
Nov 9, 2021
Merged

Support copy/paste #1013

merged 30 commits into from
Nov 9, 2021

Conversation

adlarkin
Copy link
Contributor

@adlarkin adlarkin commented Sep 8, 2021

Signed-off-by: Ashton Larkin [email protected]

🎉 New feature

Closes #102

Requires:

Summary

This PR builds on top of #959 to provide GUI support for copy/paste. Copy/paste is available via the GUI plugin buttons, right click, and ctrl-c + ctrl-v.

Test it

  1. Run the following command to start a gazebo world with a model: ign gazebo pendulum_links.sdf
  2. Load the GUI plugin, and select entities to copy/paste. This can be done while simulation is running or paused:

copy_paste_demo

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge

@adlarkin adlarkin requested a review from iche033 September 8, 2021 00:34
@adlarkin adlarkin requested a review from chapulina as a code owner September 8, 2021 00:34
@adlarkin adlarkin added needs upstream release Blocked by a release of an upstream library editor Tools to edit entities in simulation labels Sep 8, 2021
@chapulina chapulina added the 🏯 fortress Ignition Fortress label Sep 8, 2021
src/gui/plugins/copy_paste/CopyPaste.hh Outdated Show resolved Hide resolved
src/gui/plugins/copy_paste/CopyPaste.qml Outdated Show resolved Hide resolved
src/gui/plugins/scene3d/Scene3D.cc Outdated Show resolved Hide resolved
@chapulina chapulina added the beta Targeting beta release of upcoming collection label Sep 8, 2021
Signed-off-by: Ashton Larkin <[email protected]>
@adlarkin
Copy link
Contributor Author

adlarkin commented Sep 9, 2021

I'm currently facing an issue where an extra object is spawned at the origin after pasting occurs. I have tried to debug this, but cannot figure out what the issue is. The extra entity does not seem to appear in the entity tree, so perhaps there's an issue with cleaning up the preview once pasting occurs? Here's an example of what I am seeing:

copy_paste_simple_shapes

cc @iche033 @chapulina

src/gui/plugins/copy_paste/CopyPaste.hh Show resolved Hide resolved
src/gui/plugins/copy_paste/CopyPaste.hh Show resolved Hide resolved
src/gui/plugins/copy_paste/CopyPaste.hh Show resolved Hide resolved
src/rendering/SceneManager.cc Outdated Show resolved Hide resolved
src/rendering/SceneManager.cc Show resolved Hide resolved
src/gui/plugins/scene3d/Scene3D.cc Outdated Show resolved Hide resolved
src/gui/plugins/scene3d/Scene3D.cc Outdated Show resolved Hide resolved
src/gui/plugins/copy_paste/CopyPaste.cc Outdated Show resolved Hide resolved
src/gui/plugins/copy_paste/CopyPaste.cc Outdated Show resolved Hide resolved
Signed-off-by: Ashton Larkin <[email protected]>
Signed-off-by: Ashton Larkin <[email protected]>
@adlarkin
Copy link
Contributor Author

adlarkin commented Sep 14, 2021

Another issue I'm trying to troubleshoot is that if I copy/paste an entity, I'll sometimes see the following error message (this is from gazebosim/gz-rendering#397):

[GUI] [Err] [BaseGeometry.hh:110] Cloning a geometry failed because the name of the mesh is missing.

I usually see this when I try to copy/paste an entity that has already been moved with the transform tool, or copy/paste an entity via the plugin buttons. I don't see it happen as much when I copy/paste via the right click menu. I've tried debugging, but I'm not sure why the mesh information doesn't seem to be attached to an entity at times.

@iche033
Copy link
Contributor

iche033 commented Sep 14, 2021

I'm currently facing an issue where an extra object is spawned at the origin after pasting occurs.

this could be because the preview visual is not removed properly. I noticed that it's calling SceneManager::RemoveEntity(_id) on the model entity Id. That function does not recursively delete all child visuals so you'll likely need to remove other visuals in the model as well.

Another issue I'm trying to troubleshoot is that if I copy/paste an entity, I'll sometimes see the following error message (this is from gazebosim/gz-rendering#397):

That turns out to be the WireBox that is attached to the model when it is selected. We'll need to be careful about other visualizations such as joint, CoM, inertia visuals that can be attached to the model visual. So maybe instead of recursively copying all the child visuals, we may need to figure out a way to omit these gui-only visuals. One idea is to tag these gui-only visuals using user-data and in the SceneManager::CopyVisual function, you can selectively clone visuals that do not have this tag.

@adlarkin adlarkin changed the base branch from main to ign-gazebo6 October 4, 2021 20:45
@adlarkin
Copy link
Contributor Author

adlarkin commented Oct 5, 2021

This is ready for another round of review. I have added some details to the PR description that show a demo and instructions for testing. I have a few questions/notes for my reviewers (@chapulina @iche033):

  1. I've added copy/paste options to the right click menu (EntityContextMenu). However, these buttons won't work unless the copy/paste plugin has been loaded. Because of this, should I remove the copy/paste options from the right click menu, and only allow users to copy/paste via the plugin buttons themselves?
  2. I have added the corresponding server functionality in Scene3d, but not to the Spawn yet (the Spawn/MinimalScene changes were made after I started working on this PR). Since there are already quite a few changes here, I will copy the Scene3d functionality over to Spawn either in a separate PR or once everything else in this PR has been reviewed.

@adlarkin adlarkin requested a review from chapulina October 5, 2021 21:45
src/rendering/RenderUtil.cc Outdated Show resolved Hide resolved
@adlarkin
Copy link
Contributor Author

I just merged #1103 into this PR, which means that this PR no longer depends on gazebosim/gz-rendering#442.

@adlarkin adlarkin removed the needs upstream release Blocked by a release of an upstream library label Oct 13, 2021
@nkoenig nkoenig self-requested a review November 1, 2021 20:06
@adlarkin
Copy link
Contributor Author

adlarkin commented Nov 3, 2021

I've updated this PR to support copy/paste via ctrl-c and ctrl-v. The plugin is also automatically loaded with the default gazebo gui config (see the demo in the PR description). This should be ready for final review!

@adlarkin adlarkin dismissed ahcorde’s stale review November 9, 2021 16:18

Comments have been addressed

@adlarkin adlarkin merged commit 3944134 into ign-gazebo6 Nov 9, 2021
@adlarkin adlarkin deleted the adlarkin/copy_paste_usingClone branch November 9, 2021 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Tools to edit entities in simulation 🏯 fortress Ignition Fortress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy / paste entities from the GUI
5 participants