Skip to content

Commit

Permalink
Merge f2dff76 into 8f415f3
Browse files Browse the repository at this point in the history
  • Loading branch information
scpeters authored Mar 23, 2023
2 parents 8f415f3 + f2dff76 commit 73e9daf
Show file tree
Hide file tree
Showing 15 changed files with 739 additions and 177 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,11 @@

## Gazebo GUI 3

### Gazebo GUI 3.11.2 (2022-08-17)

1. Fix mistaken dialog error message
* [Pull request #472](https://github.com/gazebosim/gz-gui/pull/472)

### Gazebo GUI 3.11.1 (2022-08-15)

1. Replace pose in Grid3d with GzPose
Expand Down
19 changes: 11 additions & 8 deletions conf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
set(ign_library_path "${CMAKE_BINARY_DIR}/src/cmd/cmdgui${PROJECT_VERSION_MAJOR}")
# Used only for internal testing.
set(ign_library_path "${CMAKE_BINARY_DIR}/test/lib/ruby/ignition/cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}")

# Generate a configuration file for internal testing.
# Note that the major version of the library is included in the name.
# Ex: gui0.yaml
configure_file(
"gui.yaml.in"
"${CMAKE_BINARY_DIR}/test/conf/gui${PROJECT_VERSION_MAJOR}.yaml" @ONLY)
"${GZ_DESIGNATION}.yaml.in"
"${CMAKE_BINARY_DIR}/test/conf/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml" @ONLY)

set(ign_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/ignition/cmdgui${PROJECT_VERSION_MAJOR}")
# Used for the installed version.
set(ign_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/ignition/cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}")

# Generate a configuration file.
# Generate the configuration file that is installed.
# Note that the major version of the library is included in the name.
# Ex: gui0.yaml
configure_file(
"gui.yaml.in"
"${CMAKE_CURRENT_BINARY_DIR}/gui${PROJECT_VERSION_MAJOR}.yaml" @ONLY)
"${GZ_DESIGNATION}.yaml.in"
"${CMAKE_CURRENT_BINARY_DIR}/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml" @ONLY)

# Install the yaml configuration files in an unversioned location.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gui${PROJECT_VERSION_MAJOR}.yaml DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/ignition/)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/ignition/)
10 changes: 7 additions & 3 deletions include/ignition/gui/qml/GzPose.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import QtQuick.Controls.Styles 1.4
* GzPose {
* id: gzPose
* readOnly: false
* useRadian: true
* xValue: xValueFromCPP
* yValue: yValueFromCPP
* zValue: zValueFromCPP
Expand All @@ -59,6 +60,9 @@ Item {
// Read-only / write
property bool readOnly: false

// Radian / Degree as the unit for Rotation
property bool useRadian: true

// User input value.
property double xValue
property double yValue
Expand Down Expand Up @@ -222,7 +226,7 @@ Item {

Text {
id: rollText
text: 'Roll (rad)'
text: 'Roll ' + (useRadian ? '(rad)' : '(deg)')
leftPadding: 5
color: Material.theme == Material.Light ? "#444444" : "#bbbbbb"
font.pointSize: 12
Expand Down Expand Up @@ -292,7 +296,7 @@ Item {

Text {
id: pitchText
text: 'Pitch (rad)'
text: 'Pitch ' + (useRadian ? '(rad)' : '(deg)')
leftPadding: 5
color: Material.theme == Material.Light ? "#444444" : "#bbbbbb"
font.pointSize: 12
Expand Down Expand Up @@ -362,7 +366,7 @@ Item {

Text {
id: yawText
text: 'Yaw (rad)'
text: 'Yaw ' + (useRadian ? '(rad)' : '(deg)')
leftPadding: 5
color: Material.theme == Material.Light ? "#444444" : "#bbbbbb"
font.pointSize: 12
Expand Down
2 changes: 1 addition & 1 deletion src/Application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ bool Application::RemovePlugin(const std::string &_pluginName)
// Remove split on QML
auto bgItem = this->dataPtr->mainWin->QuickWindow()
->findChild<QQuickItem *>("background");
if (bgItem)
if (bgItem && cardItem->parentItem())
{
QMetaObject::invokeMethod(bgItem, "removeSplitItem",
Q_ARG(QVariant, cardItem->parentItem()->objectName()));
Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,7 @@ if(TARGET UNIT_ign_TEST)
ENVIRONMENT "${_env_vars}")
endif()

add_subdirectory(cmd)
if(NOT WIN32)
add_subdirectory(cmd)
endif()
add_subdirectory(plugins)
49 changes: 40 additions & 9 deletions src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
# Generate the ruby script.
#===============================================================================
# Generate the ruby script for internal testing.
# Note that the major version of the library is included in the name.
if (APPLE)
set(IGN_LIBRARY_NAME lib${PROJECT_NAME_LOWER}.dylib)
else()
set(IGN_LIBRARY_NAME lib${PROJECT_NAME_LOWER}.so)
endif()
# Ex: cmdgui3.rb
set(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/lib/ruby/ignition/cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured_test "${cmd_script_generated_test}.configured")

# Set the library_location variable to the full path of the library file within
# the build directory.
set(library_location "$<TARGET_FILE:${PROJECT_LIBRARY_TARGET_NAME}>")

configure_file(
"cmd${GZ_DESIGNATION}.rb.in"
"${cmd_script_configured_test}"
@ONLY)

file(GENERATE
OUTPUT "${cmd_script_generated_test}"
INPUT "${cmd_script_configured_test}")


#===============================================================================
# Used for the installed version.
# Generate the ruby script that gets installed.
# Note that the major version of the library is included in the name.
# Ex: cmdgui3.rb
set(cmd_script_generated "${CMAKE_CURRENT_BINARY_DIR}/cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured "${cmd_script_generated}.configured")

# Set the library_location variable to the relative path to the library file
# within the install directory structure.
set(library_location "../../../${CMAKE_INSTALL_LIBDIR}/$<TARGET_FILE_NAME:${PROJECT_LIBRARY_TARGET_NAME}>")

configure_file(
"cmdgui.rb.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmdgui${PROJECT_VERSION_MAJOR}.rb" @ONLY)
"cmd${GZ_DESIGNATION}.rb.in"
"${cmd_script_configured}"
@ONLY)

file(GENERATE
OUTPUT "${cmd_script_generated}"
INPUT "${cmd_script_configured}")

# Install the ruby command line library in an unversioned location.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmdgui${PROJECT_VERSION_MAJOR}.rb DESTINATION lib/ruby/ignition)
install(FILES ${cmd_script_generated} DESTINATION lib/ruby/ignition)

# Tack version onto and install the bash completion script
configure_file(
Expand Down
12 changes: 10 additions & 2 deletions src/cmd/cmdgui.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ end
require 'optparse'

# Constants.
LIBRARY_NAME = '@IGN_LIBRARY_NAME@'
LIBRARY_NAME = '@library_location@'
LIBRARY_VERSION = '@PROJECT_VERSION_FULL@'
COMMON_OPTIONS =
" -h [ --help ] Print this help message.\n"\
Expand Down Expand Up @@ -134,7 +134,15 @@ class Cmd
# puts options

# Read the plugin that handles the command.
plugin = LIBRARY_NAME
if LIBRARY_NAME[0] == '/'
# If the first character is a slash, we'll assume that we've been given an
# absolute path to the library. This is only used during test mode.
plugin = LIBRARY_NAME
else
# We're assuming that the library path is relative to the current
# location of this script.
plugin = File.expand_path(File.join(File.dirname(__FILE__), LIBRARY_NAME))
end
conf_version = LIBRARY_VERSION

begin
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/image_display/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ ign_gui_add_plugin(ImageDisplay
QT_HEADERS
ImageDisplay.hh
TEST_SOURCES
# ImageDisplay_TEST.cc
ImageDisplay_TEST.cc
)

40 changes: 6 additions & 34 deletions src/plugins/image_display/ImageDisplay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

#include "ImageDisplay.hh"

#include <QQuickImageProvider>

#include <algorithm>
#include <iostream>
#include <limits>
#include <string>
Expand All @@ -39,37 +36,6 @@ namespace gui
{
namespace plugins
{
class ImageProvider : public QQuickImageProvider
{
public: ImageProvider()
: QQuickImageProvider(QQuickImageProvider::Image)
{
}

public: QImage requestImage(const QString &, QSize *,
const QSize &) override
{
if (!this->img.isNull())
{
// Must return a copy
QImage copy(this->img);
return copy;
}

// Placeholder in case we have no image yet
QImage i(400, 400, QImage::Format_RGB888);
i.fill(QColor(128, 128, 128, 100));
return i;
}

public: void SetImage(const QImage &_image)
{
this->img = _image;
}

private: QImage img;
};

class ImageDisplayPrivate
{
/// \brief List of topics publishing image messages.
Expand Down Expand Up @@ -236,7 +202,11 @@ void ImageDisplay::OnTopic(const QString _topic)
{
auto topic = _topic.toStdString();
if (topic.empty())
{
// LCOV_EXCL_START
return;
// LCOV_EXCL_STOP
}

// Unsubscribe
auto subs = this->dataPtr->node.SubscribedTopics();
Expand All @@ -247,8 +217,10 @@ void ImageDisplay::OnTopic(const QString _topic)
if (!this->dataPtr->node.Subscribe(topic, &ImageDisplay::OnImageMsg,
this))
{
// LCOV_EXCL_START
ignerr << "Unable to subscribe to topic [" << topic << "]" << std::endl;
return;
// LCOV_EXCL_STOP
}
App()->findChild<MainWindow *>()->notifyWithDuration(
QString::fromStdString("Subscribed to: <b>" + topic + "</b>"), 4000);
Expand Down
46 changes: 45 additions & 1 deletion src/plugins/image_display/ImageDisplay.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
#ifndef IGNITION_GUI_PLUGINS_IMAGEDISPLAY_HH_
#define IGNITION_GUI_PLUGINS_IMAGEDISPLAY_HH_

#include <algorithm>
#include <memory>
#include <QQuickImageProvider>

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
Expand All @@ -27,6 +30,16 @@
#pragma warning(pop)
#endif

#ifndef _WIN32
# define ImageDisplay_EXPORTS_API
#else
# if (defined(ImageDisplay_EXPORTS))
# define ImageDisplay_EXPORTS_API __declspec(dllexport)
# else
# define ImageDisplay_EXPORTS_API __declspec(dllimport)
# endif
#endif

#include "ignition/gui/Plugin.hh"

namespace ignition
Expand All @@ -37,14 +50,45 @@ namespace plugins
{
class ImageDisplayPrivate;

class ImageProvider : public QQuickImageProvider
{
public: ImageProvider()
: QQuickImageProvider(QQuickImageProvider::Image)
{
}

public: QImage requestImage(const QString &, QSize *,
const QSize &) override
{
if (!this->img.isNull())
{
// Must return a copy
QImage copy(this->img);
return copy;
}

// Placeholder in case we have no image yet
QImage i(400, 400, QImage::Format_RGB888);
i.fill(QColor(128, 128, 128, 100));
return i;
}

public: void SetImage(const QImage &_image)
{
this->img = _image;
}

private: QImage img;
};

/// \brief Display images coming through an Ignition transport topic.
///
/// ## Configuration
///
/// \<topic\> : Set the topic to receive image messages.
/// \<topic_picker\> : Whether to show the topic picker, true by default. If
/// this is false, a \<topic\> must be specified.
class ImageDisplay : public Plugin
class ImageDisplay_EXPORTS_API ImageDisplay : public Plugin
{
Q_OBJECT

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/image_display/ImageDisplay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Rectangle {
RowLayout {
visible: showPicker
RoundButton {
objectName: "refreshButton"
text: "\u21bb"
Material.background: Material.primary
onClicked: {
Expand All @@ -72,6 +73,7 @@ Rectangle {
}
ComboBox {
id: combo
objectName: "topicsCombo"
Layout.fillWidth: true
model: ImageDisplay.topicList
onCurrentIndexChanged: {
Expand Down
Loading

0 comments on commit 73e9daf

Please sign in to comment.