Skip to content

Commit

Permalink
Merge branch 'ign-gazebo3' into sensors_background_color
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Koenig committed Oct 28, 2021
2 parents 5ca8a7a + 63decda commit 280383d
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 16 deletions.
78 changes: 76 additions & 2 deletions src/gui/plugins/component_inspector/ComponentInspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@
#include "ignition/gazebo/components/Actor.hh"
#include "ignition/gazebo/components/AngularAcceleration.hh"
#include "ignition/gazebo/components/AngularVelocity.hh"
#include "ignition/gazebo/components/BatterySoC.hh"
#include "ignition/gazebo/components/CastShadows.hh"
#include "ignition/gazebo/components/CenterOfVolume.hh"
#include "ignition/gazebo/components/ChildLinkName.hh"
#include "ignition/gazebo/components/Collision.hh"
#include "ignition/gazebo/components/Factory.hh"
#include "ignition/gazebo/components/Gravity.hh"
#include "ignition/gazebo/components/Joint.hh"
#include "ignition/gazebo/components/LaserRetro.hh"
#include "ignition/gazebo/components/Level.hh"
#include "ignition/gazebo/components/Light.hh"
#include "ignition/gazebo/components/LinearAcceleration.hh"
Expand All @@ -53,7 +56,10 @@
#include "ignition/gazebo/components/Sensor.hh"
#include "ignition/gazebo/components/SourceFilePath.hh"
#include "ignition/gazebo/components/Static.hh"
#include "ignition/gazebo/components/ThreadPitch.hh"
#include "ignition/gazebo/components/Transparency.hh"
#include "ignition/gazebo/components/Visual.hh"
#include "ignition/gazebo/components/Volume.hh"
#include "ignition/gazebo/components/WindMode.hh"
#include "ignition/gazebo/components/World.hh"
#include "ignition/gazebo/EntityComponentManager.hh"
Expand Down Expand Up @@ -184,6 +190,13 @@ void ignition::gazebo::setData(QStandardItem *_item, const int &_data)
_item->setData(_data, ComponentsModel::RoleNames().key("data"));
}

//////////////////////////////////////////////////
template<>
void ignition::gazebo::setData(QStandardItem *_item, const Entity &_data)
{
setData(_item, static_cast<int>(_data));
}

//////////////////////////////////////////////////
template<>
void ignition::gazebo::setData(QStandardItem *_item, const double &_data)
Expand Down Expand Up @@ -309,6 +322,7 @@ ComponentInspector::ComponentInspector()
: GuiSystem(), dataPtr(std::make_unique<ComponentInspectorPrivate>())
{
qRegisterMetaType<ignition::gazebo::ComponentTypeId>();
qRegisterMetaType<Entity>("Entity");
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -462,13 +476,30 @@ void ComponentInspector::Update(const UpdateInfo &,
setUnit(item, "rad/s");
}
}
else if (typeId == components::BatterySoC::typeId)
{
auto comp = _ecm.Component<components::BatterySoC>(
this->dataPtr->entity);
if (comp)
setData(item, comp->Data());
}
else if (typeId == components::CastShadows::typeId)
{
auto comp = _ecm.Component<components::CastShadows>(
this->dataPtr->entity);
if (comp)
setData(item, comp->Data());
}
else if (typeId == components::CenterOfVolume::typeId)
{
auto comp = _ecm.Component<components::CenterOfVolume>(
this->dataPtr->entity);
if (comp)
{
setData(item, comp->Data());
setUnit(item, "m");
}
}
else if (typeId == components::ChildLinkName::typeId)
{
auto comp = _ecm.Component<components::ChildLinkName>(
Expand All @@ -485,6 +516,12 @@ void ComponentInspector::Update(const UpdateInfo &,
setUnit(item, "m/s\u00B2");
}
}
else if (typeId == components::LaserRetro::typeId)
{
auto comp = _ecm.Component<components::LaserRetro>(this->dataPtr->entity);
if (comp)
setData(item, comp->Data());
}
else if (typeId == components::LinearAcceleration::typeId)
{
auto comp = _ecm.Component<components::LinearAcceleration>(
Expand Down Expand Up @@ -584,6 +621,33 @@ void ComponentInspector::Update(const UpdateInfo &,
if (comp)
setData(item, comp->Data());
}
else if (typeId == components::ThreadPitch::typeId)
{
auto comp = _ecm.Component<components::ThreadPitch>(
this->dataPtr->entity);
if (comp)
{
setData(item, comp->Data());
setUnit(item, "m");
}
}
else if (typeId == components::Transparency::typeId)
{
auto comp = _ecm.Component<components::Transparency>(
this->dataPtr->entity);
if (comp)
setData(item, comp->Data());
}
else if (typeId == components::Volume::typeId)
{
auto comp = _ecm.Component<components::Volume>(
this->dataPtr->entity);
if (comp)
{
setData(item, comp->Data());
setUnit(item, "m\u00B3");
}
}
else if (typeId == components::WindMode::typeId)
{
auto comp = _ecm.Component<components::WindMode>(this->dataPtr->entity);
Expand All @@ -600,6 +664,16 @@ void ComponentInspector::Update(const UpdateInfo &,
setUnit(item, "rad/s\u00B2");
}
}
else if (typeId == components::WorldAngularVelocity::typeId)
{
auto comp = _ecm.Component<components::WorldAngularVelocity>(
this->dataPtr->entity);
if (comp)
{
setData(item, comp->Data());
setUnit(item, "rad/s");
}
}
else if (typeId == components::WorldLinearVelocity::typeId)
{
auto comp = _ecm.Component<components::WorldLinearVelocity>(
Expand Down Expand Up @@ -679,13 +753,13 @@ bool ComponentInspector::eventFilter(QObject *_obj, QEvent *_event)
}

/////////////////////////////////////////////////
int ComponentInspector::Entity() const
Entity ComponentInspector::GetEntity() const
{
return this->dataPtr->entity;
}

/////////////////////////////////////////////////
void ComponentInspector::SetEntity(const int &_entity)
void ComponentInspector::SetEntity(const Entity &_entity)
{
// If nothing is selected, display world properties
if (_entity == kNullEntity)
Expand Down
8 changes: 4 additions & 4 deletions src/gui/plugins/component_inspector/ComponentInspector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ namespace gazebo

/// \brief Entity
Q_PROPERTY(
int entity
READ Entity
Entity entity
READ GetEntity
WRITE SetEntity
NOTIFY EntityChanged
)
Expand Down Expand Up @@ -233,11 +233,11 @@ namespace gazebo

/// \brief Get the entity currently inspected.
/// \return Entity ID.
public: Q_INVOKABLE int Entity() const;
public: Q_INVOKABLE Entity GetEntity() const;

/// \brief Set the entity currently inspected.
/// \param[in] _entity Entity ID.
public: Q_INVOKABLE void SetEntity(const int &_entity);
public: Q_INVOKABLE void SetEntity(const Entity &_entity);

/// \brief Notify that entity has changed.
signals: void EntityChanged();
Expand Down
2 changes: 2 additions & 0 deletions src/gui/plugins/component_inspector/ComponentInspector.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<qresource prefix="ComponentInspector/">
<file>Boolean.qml</file>
<file>ComponentInspector.qml</file>
<file>Float.qml</file>
<file>Integer.qml</file>
<file>NoData.qml</file>
<file>Physics.qml</file>
<file>Pose3d.qml</file>
Expand Down
20 changes: 15 additions & 5 deletions src/gui/plugins/component_inspector/Float.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Rectangle {
// Maximum spinbox value
property double spinMax: 1000000

// Unit
property string unit: model && model.unit != undefined ? model.unit : ''

RowLayout {
anchors.fill: parent

Expand All @@ -55,13 +58,20 @@ Rectangle {
id: typeHeader
}

IgnSpinBox {
// TODO(anyone) Support write mode
Text {
id: content
value: model.data
minimumValue: -spinMax
maximumValue: spinMax
decimals: xSpin.width < 100 ? 2 : 6
Layout.fillWidth: true
horizontalAlignment: Text.AlignRight
color: Material.theme == Material.Light ? "black" : "white"
font.pointSize: 12
text: {
var decimals = getDecimals(content.width)
var valueText = model.data.toFixed(decimals)
if (unit !== '')
valueText += ' ' + unit
return valueText
}
}

Item {
Expand Down
20 changes: 15 additions & 5 deletions src/gui/plugins/component_inspector/Integer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ Rectangle {
// Maximum spinbox value
property double spinMax: 1000000

Row {
// Unit
property string unit: model && model.unit != undefined ? model.unit : ''

RowLayout {
anchors.fill: parent

Item {
Expand All @@ -55,12 +58,19 @@ Rectangle {
id: typeHeader
}

IgnSpinBox {
// TODO(anyone) Support write mode
Text {
id: content
value: model.data
minimumValue: -spinMax
maximumValue: spinMax
Layout.fillWidth: true
horizontalAlignment: Text.AlignRight
color: Material.theme == Material.Light ? "black" : "white"
font.pointSize: 12
text: {
var valueText = model.data
if (unit !== '')
valueText += ' ' + unit
return valueText
}
}

Item {
Expand Down

0 comments on commit 280383d

Please sign in to comment.