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

Added Spawn plugin #983

Merged
merged 8 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion examples/worlds/minimal_scene.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ Features:
* Grid config
* Select entities
* Transform controls
* Spawn entities through GUI

Missing for parity with GzScene3D:

* Spawn entities through GUI
* Context menu
* Record video
* View angles
* View collisions, wireframe, transparent, CoM, etc
* Drag and drop from Fuel / meshes
* ...

-->
Expand Down Expand Up @@ -160,6 +161,20 @@ Missing for parity with GzScene3D:
<topic>/world/buoyancy/stats</topic>
</plugin>

<plugin filename="Spawn" name="Spawn Entities">
<ignition-gui>
<anchors target="Select entities">
<line own="right" target="right"/>
<line own="top" target="top"/>
</anchors>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</plugin>

<!-- Insert simple shapes -->
<plugin filename="Shapes" name="Shapes">
<ignition-gui>
Expand Down
1 change: 1 addition & 0 deletions src/gui/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ add_subdirectory(scene3d)
add_subdirectory(select_entities)
add_subdirectory(scene_manager)
add_subdirectory(shapes)
add_subdirectory(spawn)
add_subdirectory(transform_control)
add_subdirectory(video_recorder)
add_subdirectory(view_angle)
Expand Down
24 changes: 21 additions & 3 deletions src/gui/plugins/select_entities/SelectEntities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ class ignition::gazebo::gui::SelectEntitiesPrivate

/// \brief is transform control active ?
public: bool transformControlActive = false;

/// \brief Is an entity being spawned
public: bool isSpawning{false};
};

using namespace ignition;
Expand Down Expand Up @@ -485,11 +488,18 @@ bool SelectEntities::eventFilter(QObject *_obj, QEvent *_event)
ignition::gui::events::LeftClickOnScene *_e =
static_cast<ignition::gui::events::LeftClickOnScene*>(_event);
this->dataPtr->mouseEvent = _e->Mouse();
// handle transform control

if (this->dataPtr->mouseEvent.Button() == common::MouseEvent::LEFT &&
this->dataPtr->mouseEvent.Type() == common::MouseEvent::PRESS)
this->dataPtr->mouseEvent.Type() == common::MouseEvent::RELEASE)
{
this->dataPtr->mouseDirty = true;
if (this->dataPtr->isSpawning)
{
this->dataPtr->isSpawning = false;
}
else
{
this->dataPtr->mouseDirty = true;
}
}
}
else if (_event->type() == ignition::gui::events::Render::kType)
Expand Down Expand Up @@ -545,6 +555,13 @@ bool SelectEntities::eventFilter(QObject *_obj, QEvent *_event)
this->dataPtr->selectedEntitiesID.clear();
this->dataPtr->selectedEntities.clear();
}
else if (_event->type() ==
ignition::gui::events::SpawnFromDescription::kType ||
_event->type() == ignition::gui::events::SpawnFromPath::kType)
{
this->dataPtr->isSpawning = true;
this->dataPtr->mouseDirty = true;
}
else if (_event->type() == ignition::gui::events::KeyReleaseOnScene::kType)
{
ignition::gui::events::KeyReleaseOnScene *_e =
Expand All @@ -553,6 +570,7 @@ bool SelectEntities::eventFilter(QObject *_obj, QEvent *_event)
{
this->dataPtr->mouseDirty = true;
this->dataPtr->selectionHelper.deselectAll = true;
this->dataPtr->isSpawning = false;
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/gui/plugins/spawn/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
gz_add_gui_plugin(Spawn
SOURCES
Spawn.cc
QT_HEADERS
Spawn.hh
PUBLIC_LINK_LIBS
${PROJECT_LIBRARY_TARGET_NAME}-rendering
)
Loading