Skip to content

Commit

Permalink
Fixed spawn
Browse files Browse the repository at this point in the history
Signed-off-by: ahcorde <ahcorde@gmail.com>
  • Loading branch information
ahcorde committed Aug 26, 2021
1 parent 555d6ae commit f82ec2e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
20 changes: 19 additions & 1 deletion 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 Spawning from description active
public: bool isSpawnFromDescription{false};
};

using namespace ignition;
Expand Down Expand Up @@ -489,7 +492,14 @@ bool SelectEntities::eventFilter(QObject *_obj, QEvent *_event)
if (this->dataPtr->mouseEvent.Button() == common::MouseEvent::LEFT &&
this->dataPtr->mouseEvent.Type() == common::MouseEvent::PRESS)
{
this->dataPtr->mouseDirty = true;
if(this->dataPtr->isSpawnFromDescription)
{
this->dataPtr->isSpawnFromDescription = 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->isSpawnFromDescription = 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->isSpawnFromDescription = false;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/gui/plugins/spawn/Spawn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ bool Spawn::eventFilter(QObject *_obj, QEvent *_event)
ignition::gui::events::LeftClickOnScene *_e =
static_cast<ignition::gui::events::LeftClickOnScene*>(_event);
this->dataPtr->mouseEvent = _e->Mouse();
this->dataPtr->mouseDirty = true;
if (this->dataPtr->isSpawning || this->dataPtr->isPlacing)
this->dataPtr->mouseDirty = true;
}
else if (_event->type() == ignition::gui::events::HoverOnScene::kType)
{
Expand Down
10 changes: 5 additions & 5 deletions src/gui/plugins/spawn/Spawn.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
* Copyright (C) 2021 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,8 +15,8 @@
*
*/

#ifndef IGNITION_GAZEBO_GUI_Spawn_HH_
#define IGNITION_GAZEBO_GUI_Spawn_HH_
#ifndef IGNITION_GAZEBO_GUI_SPAWN_HH_
#define IGNITION_GAZEBO_GUI_SPAWN_HH_

#include <memory>

Expand All @@ -28,8 +28,8 @@ namespace gazebo
{
class SpawnPrivate;

/// \brief Provides buttons for adding a box, sphere, or cylinder
/// to the scene
/// \brief Allows to spawn models and lights using te gui event
/// SpawnFromDescription
class Spawn : public ignition::gui::Plugin
{
Q_OBJECT
Expand Down

0 comments on commit f82ec2e

Please sign in to comment.