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 transform control and select entities GUI plugins #854

Merged
merged 41 commits into from
Aug 14, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3a7d09c
Add scene manager GUI plugin that works with ign-gui's Scene3D
chapulina May 12, 2021
80161fb
cleanup
chapulina May 12, 2021
22454e9
Added tranform control and select entities GUI plugins
ahcorde Jun 9, 2021
4465595
Used new plugin
ahcorde Jun 18, 2021
eda24b6
Fix Key event class name
ahcorde Jun 18, 2021
d0d7066
Merge branch 'main' into chapulina/6/scene_manager
chapulina Jun 19, 2021
5f94fe2
Update to latest
chapulina Jun 21, 2021
b7922fc
Some fixes to select entities plugin
ahcorde Jun 22, 2021
1e8ab03
Merge branch 'chapulina/6/scene_manager' into ahcorde/plugin/selectEn…
ahcorde Jun 22, 2021
3493fa0
Fixed transform control and linters
ahcorde Jun 22, 2021
44681d4
Merge branch 'ahcorde/plugin/selectEntities_transformControl' of http…
ahcorde Jun 22, 2021
c5b16d2
Merge branch 'main' into chapulina/6/scene_manager
chapulina Jun 24, 2021
27ee0d6
Merge remote-tracking branch 'origin/chapulina/6/scene_manager' into …
ahcorde Jul 1, 2021
6bb0bce
Added feedback
ahcorde Jul 1, 2021
e00ee2e
make linters happy
ahcorde Jul 1, 2021
c3095a2
Merge branch 'main' into chapulina/6/scene_manager
ahcorde Jul 2, 2021
c741662
Merge branch 'main' into chapulina/6/scene_manager
chapulina Aug 9, 2021
fbceade
Don't make it official yet
chapulina Aug 9, 2021
f27887a
Merge branch 'chapulina/6/scene_manager' of ssh://github.com/ignition…
chapulina Aug 9, 2021
21e1b7b
alphabetize
chapulina Aug 9, 2021
20c0e0b
merged from chapulina/6/scene_manager
chapulina Aug 9, 2021
8694ac4
Merge remote-tracking branch 'origin/main' into ahcorde/plugin/select…
ahcorde Aug 10, 2021
a74a4a6
clean up select entities
chapulina Aug 10, 2021
357f626
Start combining TransformControls
chapulina Aug 10, 2021
209cb68
improvements
ahcorde Aug 11, 2021
5a46411
Merge branch 'main' into ahcorde/plugin/selectEntities_transformControl
ahcorde Aug 11, 2021
cbf5c00
make linters happy
ahcorde Aug 11, 2021
5282927
Remove transform control logic plugin
ahcorde Aug 11, 2021
ee7784c
Fixed compilation error
ahcorde Aug 12, 2021
73b9e4e
Remove traces
ahcorde Aug 12, 2021
caf08a9
Documentation and style
chapulina Aug 13, 2021
e6e3e16
Fixed keyRelease event
ahcorde Aug 13, 2021
ae18bad
Fixed frozen scene
ahcorde Aug 13, 2021
0a754f4
Fix seg fault
ahcorde Aug 13, 2021
4cec6b2
Renamed TransformControlModeActive to TransformControlModeActive
ahcorde Aug 13, 2021
4279b67
make linters happy
ahcorde Aug 13, 2021
6ab0c3d
Fixed key event for legacy mode
ahcorde Aug 13, 2021
d9cb640
Merge branch 'main' into ahcorde/plugin/selectEntities_transformControl
chapulina Aug 13, 2021
b822910
Merge branch 'main' into ahcorde/plugin/selectEntities_transformControl
chapulina Aug 13, 2021
eb51a6c
revert unused blockUpdate
chapulina Aug 13, 2021
943679d
Merge branch 'ahcorde/plugin/selectEntities_transformControl' of ssh:…
chapulina Aug 13, 2021
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
21 changes: 21 additions & 0 deletions include/ignition/gazebo/gui/GuiEvents.hh
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,27 @@ namespace events
/// \brief The path of SDF file to be previewed.
std::string filePath;
};

class TransformControlMode : public QEvent
{
/// \brief Constructor
/// \param[in] _filePath The path to an SDF file.
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
public: explicit TransformControlMode(const bool _tranformModeActive)
: QEvent(kType), tranformModeActive(_tranformModeActive)
{
}

/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::User + 6);

public: bool TransformControl()
{
return this->tranformModeActive;
}

private: bool tranformModeActive;
};

} // namespace events
}
} // namespace gui
Expand Down
4 changes: 4 additions & 0 deletions include/ignition/gazebo/rendering/RenderUtil.hh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
/// \return Name of the rendering scene.
public: std::string SceneName() const;

/// \brief Set the scene to use.
/// \param[in] _scene Pointer to the scene.
public: void SetScene(const rendering::ScenePtr &_scene);

/// \brief Set background color of render window
/// \param[in] _color Color of render window background
public: void SetBackgroundColor(const math::Color &_color);
Expand Down
58 changes: 57 additions & 1 deletion src/gui/gui.config
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<!-- GUI plugins -->

<!-- 3D scene -->
<plugin filename="GzScene3D" name="3D View">
<plugin filename="MinimalScene" name="3D View">
<ignition-gui>
<title>3D View</title>
<property type="bool" key="showTitleBar">false</property>
Expand All @@ -40,6 +40,62 @@
<camera_pose>6 0 6 0 0.5 3.14</camera_pose>
</plugin>

<plugin filename="GzSceneManager" name="Scene Manager">
<ignition-gui>
<anchors target="3D View">
<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>

<plugin filename="TransformControlLogic" name="Transform Control Logic">
<ignition-gui>
<anchors target="3D View">
<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>

<plugin filename="SelectEntities" name="Select 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>

<plugin filename="ViewControl" name="View control">
<ignition-gui>
<anchors target="View Control">
<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>

<!-- Play / pause / step -->
<plugin filename="WorldControl" name="World control">
<ignition-gui>
Expand Down
3 changes: 3 additions & 0 deletions src/gui/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,12 @@ add_subdirectory(playback_scrubber)
add_subdirectory(plotting)
add_subdirectory(resource_spawner)
add_subdirectory(scene3d)
add_subdirectory(select_entities)
add_subdirectory(scene_manager)
add_subdirectory(shapes)
add_subdirectory(tape_measure)
add_subdirectory(transform_control)
add_subdirectory(transform_control_logic)
add_subdirectory(video_recorder)
add_subdirectory(view_angle)
add_subdirectory(visualize_lidar)
7 changes: 7 additions & 0 deletions src/gui/plugins/scene_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
gz_add_gui_plugin(GzSceneManager
SOURCES GzSceneManager.cc
QT_HEADERS GzSceneManager.hh
PRIVATE_LINK_LIBS
${PROJECT_LIBRARY_TARGET_NAME}-rendering
ignition-utils${IGN_UTILS_VER}::ignition-utils${IGN_UTILS_VER}
)
129 changes: 129 additions & 0 deletions src/gui/plugins/scene_manager/GzSceneManager.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include "GzSceneManager.hh"

#include <ignition/common/Profiler.hh>

#include <ignition/plugin/Register.hh>

#include <ignition/rendering/RenderingIface.hh>
#include <ignition/rendering/Scene.hh>

#include <ignition/gui/GuiEvents.hh>
#include <ignition/gui/Application.hh>
#include <ignition/gui/MainWindow.hh>

#include "ignition/gazebo/components/Name.hh"
#include "ignition/gazebo/components/World.hh"
#include "ignition/gazebo/EntityComponentManager.hh"
#include "ignition/gazebo/rendering/RenderUtil.hh"

namespace ignition
{
namespace gazebo
{
inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
/// \brief Private data class for GzSceneManager
class GzSceneManagerPrivate
{
/// \brief Update the 3D scene based on the latest state of the ECM.
public: void OnRender();

//// \brief Pointer to the rendering scene
public: rendering::ScenePtr scene;

/// \brief Rendering utility
public: RenderUtil renderUtil;

public: bool blockUpdate = false;
};
}
}
}

using namespace ignition;
using namespace gazebo;

/////////////////////////////////////////////////
GzSceneManager::GzSceneManager()
: GuiSystem(), dataPtr(std::make_unique<GzSceneManagerPrivate>())
{
}

/////////////////////////////////////////////////
GzSceneManager::~GzSceneManager() = default;

/////////////////////////////////////////////////
void GzSceneManager::LoadConfig(const tinyxml2::XMLElement *)
{
if (this->title.empty())
this->title = "Scene Manager";

ignition::gui::App()->findChild<
ignition::gui::MainWindow *>()->installEventFilter(this);
}

//////////////////////////////////////////////////
void GzSceneManager::Update(const UpdateInfo &_info,
EntityComponentManager &_ecm)
{
IGN_PROFILE("GzSceneManager::Update");

if (!this->dataPtr->blockUpdate)
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
{
this->dataPtr->renderUtil.UpdateECM(_info, _ecm);
this->dataPtr->renderUtil.UpdateFromECM(_info, _ecm);
}
}

/////////////////////////////////////////////////
bool GzSceneManager::eventFilter(QObject *_obj, QEvent *_event)
{
if (_event->type() == gui::events::Render::kType)
{
this->dataPtr->OnRender();
}
else if (_event->type() == ignition::gui::events::BlockOrbit::kType)
{
auto blockOrbit = reinterpret_cast<ignition::gui::events::BlockOrbit *>(
_event);
this->dataPtr->blockUpdate = blockOrbit->Block();
}

// Standard event processing
return QObject::eventFilter(_obj, _event);
}

/////////////////////////////////////////////////
void GzSceneManagerPrivate::OnRender()
{
if (nullptr == this->scene)
{
this->scene = rendering::sceneFromFirstRenderEngine();
if (nullptr == this->scene)
return;

this->renderUtil.SetScene(this->scene);
}

this->renderUtil.Update();
}

// Register this plugin
IGNITION_ADD_PLUGIN(ignition::gazebo::GzSceneManager,
ignition::gui::Plugin)
66 changes: 66 additions & 0 deletions src/gui/plugins/scene_manager/GzSceneManager.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#ifndef IGNITION_GAZEBO_GUI_GZSCENEMANAGER_HH_
#define IGNITION_GAZEBO_GUI_GZSCENEMANAGER_HH_

#include <memory>

#include <ignition/gazebo/gui/GuiSystem.hh>

namespace ignition
{
namespace gazebo
{
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
class GzSceneManagerPrivate;

/// \brief Updates a 3D scene based on information coming from the ECM.
/// This plugin doesn't instantiate a new 3D scene. Instead, it relies on
/// another plugin being loaded alongside it that will create and paint the
/// scene to the window, such as `ignition::gui::plugins::Scene3D`.
class GzSceneManager : public GuiSystem
{
Q_OBJECT

/// \brief Constructor
public: GzSceneManager();

/// \brief Destructor
public: ~GzSceneManager() override;

// Documentation inherited
public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem)
override;

// Documentation inherited
public: void Update(const UpdateInfo &_info,
EntityComponentManager &_ecm) override;

// Documentation inherited
private: bool eventFilter(QObject *_obj, QEvent *_event) override;

/// \internal
/// \brief Pointer to private data.
private: std::unique_ptr<GzSceneManagerPrivate> dataPtr;
};
}
}
}

#endif
28 changes: 28 additions & 0 deletions src/gui/plugins/scene_manager/GzSceneManager.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3

// TODO: remove invisible rectangle, see
// https://github.com/ignitionrobotics/ign-gui/issues/220
Rectangle {
visible: false
Layout.minimumWidth: 100
Layout.minimumHeight: 100
}
5 changes: 5 additions & 0 deletions src/gui/plugins/scene_manager/GzSceneManager.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="GzSceneManager/">
<file>GzSceneManager.qml</file>
</qresource>
</RCC>
11 changes: 11 additions & 0 deletions src/gui/plugins/select_entities/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
gz_add_gui_plugin(SelectEntities
SOURCES
SelectEntities.cc
QT_HEADERS
SelectEntities.hh
TEST_SOURCES
# CameraControllerManager_TEST.cc
PUBLIC_LINK_LIBS
ignition-rendering${IGN_RENDERING_VER}::ignition-rendering${IGN_RENDERING_VER}
${PROJECT_LIBRARY_TARGET_NAME}-rendering
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
)
Loading