Skip to content

Commit

Permalink
Added Spawn plugin (#983)
Browse files Browse the repository at this point in the history
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: Louise Poubel <[email protected]>

Co-authored-by: Louise Poubel <[email protected]>
  • Loading branch information
ahcorde and chapulina authored Sep 8, 2021
1 parent f48085b commit 1fb3207
Show file tree
Hide file tree
Showing 8 changed files with 645 additions and 4 deletions.
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

0 comments on commit 1fb3207

Please sign in to comment.