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

Model editor: Add links to model #1165

Merged
merged 36 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fc9ee3c
add an add entity button to component inspector. Currently only enabl…
iche033 Oct 7, 2021
12fa0da
add model editor gui plugin that inserts visuals to the scene in the …
iche033 Oct 11, 2021
5364f51
write to ECM
iche033 Oct 12, 2021
cdd9e50
support adding light links
iche033 Oct 15, 2021
4e7cec8
Merge branch 'ign-gazebo6' into model_editor_add_link
iche033 Oct 20, 2021
8f7714c
notify other GUI plugins of added/removed entities via GUI events
adlarkin Oct 22, 2021
c2055ca
Merge remote-tracking branch 'origin/adlarkin/added_removed_entities_…
iche033 Oct 22, 2021
3b967a3
use const ref for constructor input params
adlarkin Oct 25, 2021
afd5b8c
guarantee 64 bit entity IDs with gazebo::Entity instead of unsigned int
adlarkin Oct 25, 2021
3031b3c
testing makr as new entity func
iche033 Oct 25, 2021
399416c
rm printouts
iche033 Oct 25, 2021
d634a4a
Merge branch 'adlarkin/added_removed_entities_event' into model_edito…
iche033 Oct 25, 2021
79518bf
register type
iche033 Oct 25, 2021
413a075
refactor render util
iche033 Oct 26, 2021
4c81d38
workaround for avoiding crash on exit
iche033 Nov 2, 2021
44f7859
refactor, comment out unused menu items
iche033 Nov 4, 2021
fbe09f1
remove commented out code, add CreateLight function
iche033 Nov 4, 2021
2f4aa41
merge
iche033 Nov 4, 2021
b7957c8
add model editor src files
iche033 Nov 4, 2021
493d155
remove more commented out code
iche033 Nov 4, 2021
9d3b499
Merge branch 'ign-gazebo6' into model_editor_add_link
Nov 8, 2021
ac5791d
Merge branch 'ign-gazebo6' into model_editor_add_link
Nov 8, 2021
26965e3
use entity instead of entity name (#1176)
nkoenig Nov 8, 2021
539295c
Add link menu updates (#1177)
nkoenig Nov 9, 2021
1c4f59c
fix adding ellipsoid
iche033 Nov 9, 2021
7ad8ad1
Merge branch 'ign-gazebo6' into model_editor_add_link
iche033 Nov 9, 2021
0ecc731
merge model_editor into component_inspector
iche033 Nov 9, 2021
ca1a11a
merge
iche033 Nov 9, 2021
5aba7b8
fixing warnings
iche033 Nov 9, 2021
cf2d651
Merge branch 'ign-gazebo6' into model_editor_add_link
iche033 Nov 9, 2021
1a6c5b6
Merge branch 'ign-gazebo6' into model_editor_add_link
Nov 9, 2021
7dc2eae
Adjust tool tips
Nov 9, 2021
abb667d
fix adding light
iche033 Nov 9, 2021
91190cc
Merge branch 'model_editor_add_link' of github.com:ignitionrobotics/i…
Nov 9, 2021
4460933
Fix codecheck
Nov 9, 2021
a5f2c5a
Fixed documentation
Nov 10, 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
47 changes: 47 additions & 0 deletions include/ignition/gazebo/gui/GuiEvents.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#define IGNITION_GAZEBO_GUI_GUIEVENTS_HH_

#include <QEvent>
#include <QString>

#include <set>
#include <string>
#include <utility>
Expand Down Expand Up @@ -158,6 +160,51 @@ namespace events
/// \brief True if a transform mode is active.
private: bool tranformModeActive;
};

/// \brief Event that notifies an entity is to be added to the model editor
class ModelEditorAddEntity : public QEvent
{
/// \brief Constructor
/// \param[in] _tranformModeActive is the transform control mode active
public: explicit ModelEditorAddEntity(QString _entity, QString _type,
ignition::gazebo::Entity _parent, QString _uri) :
QEvent(kType), entity(_entity), type(_type), parent(_parent), uri(_uri)
{
}

/// \brief Get the entity to add
public: QString Entity() const
{
return this->entity;
}

/// \brief Get the URI, if any, associated with the entity to add
public: QString Uri() const
{
return this->uri;
}

/// \brief Get the entity type
public: QString EntityType() const
{
return this->type;
}

/// \brief Get the parent entity to add the entity to
public: ignition::gazebo::Entity ParentEntity() const
{
return this->parent;
}

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

private: QString entity;
private: QString type;
private: ignition::gazebo::Entity parent;
private: QString uri;
};

} // namespace events
}
} // namespace gui
Expand Down
9 changes: 9 additions & 0 deletions include/ignition/gazebo/rendering/RenderUtil.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define IGNITION_GAZEBO_RENDERUTIL_HH_

#include <memory>
#include <set>
#include <string>
#include <vector>

Expand Down Expand Up @@ -76,6 +77,14 @@ inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
public: void UpdateFromECM(const UpdateInfo &_info,
const EntityComponentManager &_ecm);

/// \brief Helper function to create visuals for new entities created in
/// ECM. This function is intended to be used by other GUI plugins when
/// new entities are created on the GUI side.
/// \param[in] _ecm Const reference to the entity component manager
/// \param[in] _entities Entities to create visuals for.
public: void CreateVisualsForEntities(const EntityComponentManager &_ecm,
const std::set<Entity> &_entities);

/// \brief Set the rendering engine to use
/// \param[in] _engineName Name of the rendering engine.
public: void SetEngineName(const std::string &_engineName);
Expand Down
4 changes: 2 additions & 2 deletions src/gui/plugins/component_inspector/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
gz_add_gui_plugin(ComponentInspector
SOURCES ComponentInspector.cc
QT_HEADERS ComponentInspector.hh
SOURCES ComponentInspector.cc ModelEditor.cc
QT_HEADERS ComponentInspector.hh ModelEditor.hh
)
50 changes: 49 additions & 1 deletion src/gui/plugins/component_inspector/ComponentInspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <list>
#include <regex>
#include <ignition/common/Console.hh>
#include <ignition/common/MeshManager.hh>
#include <ignition/common/Profiler.hh>
#include <ignition/gui/Application.hh>
#include <ignition/gui/MainWindow.hh>
Expand Down Expand Up @@ -67,6 +68,7 @@
#include "ignition/gazebo/gui/GuiEvents.hh"

#include "ComponentInspector.hh"
#include "ModelEditor.hh"

namespace ignition::gazebo
{
Expand Down Expand Up @@ -101,6 +103,9 @@ namespace ignition::gazebo

/// \brief Transport node for making command requests
public: transport::Node node;

/// \brief Transport node for making command requests
public: ModelEditor modelEditor;
};
}

Expand Down Expand Up @@ -405,10 +410,12 @@ void ComponentInspector::LoadConfig(const tinyxml2::XMLElement *)
// Connect model
this->Context()->setContextProperty(
"ComponentsModel", &this->dataPtr->componentsModel);

this->dataPtr->modelEditor.Load();
}

//////////////////////////////////////////////////
void ComponentInspector::Update(const UpdateInfo &,
void ComponentInspector::Update(const UpdateInfo &_info,
EntityComponentManager &_ecm)
{
IGN_PROFILE("ComponentInspector::Update");
Expand Down Expand Up @@ -789,6 +796,8 @@ void ComponentInspector::Update(const UpdateInfo &,
Qt::QueuedConnection,
Q_ARG(ignition::gazebo::ComponentTypeId, typeId));
}

this->dataPtr->modelEditor.Update(_info, _ecm);
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -1029,6 +1038,45 @@ bool ComponentInspector::NestedModel() const
return this->dataPtr->nestedModel;
}

/////////////////////////////////////////////////
void ComponentInspector::OnAddEntity(const QString &_entity,
const QString &_type)
{
// currently just assumes parent is the model
// todo(anyone) support adding visuals / collisions / sensors to links
ignition::gazebo::gui::events::ModelEditorAddEntity addEntityEvent(
_entity, _type, this->dataPtr->entity, QString(""));

ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
&addEntityEvent);
}

/////////////////////////////////////////////////
void ComponentInspector::OnLoadMesh(const QString &_entity,
const QString &_type, const QString &_mesh)
{
std::string meshStr = _mesh.toStdString();
if (QUrl(_mesh).isLocalFile())
{
// mesh to sdf model
common::rtrim(meshStr);

if (!common::MeshManager::Instance()->IsValidFilename(meshStr))
{
QString errTxt = QString::fromStdString("Invalid URI: " + meshStr +
"\nOnly mesh file types DAE, OBJ, and STL are supported.");
return;
}

ignition::gazebo::gui::events::ModelEditorAddEntity addEntityEvent(
_entity, _type, this->dataPtr->entity, QString(meshStr.c_str()));
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
&addEntityEvent);
}
}

// Register this plugin
IGNITION_ADD_PLUGIN(ignition::gazebo::ComponentInspector,
ignition::gui::Plugin)
13 changes: 13 additions & 0 deletions src/gui/plugins/component_inspector/ComponentInspector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,19 @@ namespace gazebo
/// \brief Notify that paused has changed.
signals: void PausedChanged();

/// \brief Callback in Qt thread when an entity is to be added
/// \param[in] _entity Entity to add, e.g. box, sphere, cylinder, etc
/// \param[in] _type Entity type, e.g. link, visual, collision, etc
public: Q_INVOKABLE void OnAddEntity(const QString &_entity,
const QString &_type);

/// \brief Callback to insert a new entity
/// \param[in] _entity Entity to add, e.g. box, sphere, cylinder, etc
/// \param[in] _type Entity type, e.g. link, visual, collision, etc
/// \param[in] _mesh Mesh file to load.
public: Q_INVOKABLE void OnLoadMesh(const QString &_entity,
const QString &_type, const QString &_mesh);

/// \internal
/// \brief Pointer to private data.
private: std::unique_ptr<ComponentInspectorPrivate> dataPtr;
Expand Down
Loading