Skip to content

Commit

Permalink
merge model_editor into component_inspector
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Nov 9, 2021
1 parent 1c4f59c commit 0ecc731
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 73 deletions.
1 change: 0 additions & 1 deletion src/gui/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ add_subdirectory(modules)
add_subdirectory(align_tool)
add_subdirectory(banana_for_scale)
add_subdirectory(component_inspector)
add_subdirectory(model_editor)
add_subdirectory(entity_context_menu)
add_subdirectory(entity_tree)
add_subdirectory(joint_position_controller)
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
)
11 changes: 10 additions & 1 deletion src/gui/plugins/component_inspector/ComponentInspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "ignition/gazebo/gui/GuiEvents.hh"

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

namespace ignition::gazebo
{
Expand Down Expand Up @@ -101,6 +102,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 +409,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 @@ -782,6 +788,9 @@ void ComponentInspector::Update(const UpdateInfo &,
Q_ARG(ignition::gazebo::ComponentTypeId, typeId));
}
}


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

/////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <ignition/gui/Application.hh>
#include <ignition/gui/GuiEvents.hh>
#include <ignition/gui/MainWindow.hh>
#include <ignition/plugin/Register.hh>

#include <sdf/Link.hh>
#include <sdf/parser.hh>
Expand Down Expand Up @@ -102,19 +101,16 @@ using namespace gazebo;

/////////////////////////////////////////////////
ModelEditor::ModelEditor()
: GuiSystem(), dataPtr(std::make_unique<ModelEditorPrivate>())
: dataPtr(std::make_unique<ModelEditorPrivate>())
{
}

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

/////////////////////////////////////////////////
void ModelEditor::LoadConfig(const tinyxml2::XMLElement *)
void ModelEditor::Load()
{
if (this->title.empty())
this->title = "Model editor";

ignition::gui::App()->findChild<
ignition::gui::MainWindow *>()->installEventFilter(this);
}
Expand Down Expand Up @@ -408,7 +404,3 @@ void ModelEditorPrivate::HandleAddEntity(const std::string &_geomOrLightType,
eta.uri = _uri;
this->entitiesToAdd.push_back(eta);
}

// Register this plugin
IGNITION_ADD_PLUGIN(ignition::gazebo::ModelEditor,
ignition::gui::Plugin)
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@
#ifndef IGNITION_GAZEBO_GUI_MODELEDITOR_HH_
#define IGNITION_GAZEBO_GUI_MODELEDITOR_HH_

#include <map>
#include <memory>
#include <string>

#include <ignition/math/Pose3.hh>
#include <ignition/math/Vector3.hh>
#include <QtCore>

#include <ignition/gazebo/components/Component.hh>
#include <ignition/gazebo/gui/GuiSystem.hh>
#include <ignition/gazebo/Types.hh>

namespace ignition
Expand All @@ -35,24 +30,24 @@ namespace gazebo
{
class ModelEditorPrivate;

/// \brief
///
/// Model Editor gui plugin
class ModelEditor : public gazebo::GuiSystem
/// \brief Model Editor
class ModelEditor : public QObject
{
Q_OBJECT

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

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

// Documentation inherited
public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
/// \brief Load the model editor
public: void Load();

// Documentation inherited
public: void Update(const UpdateInfo &, EntityComponentManager &) override;
/// \brief Update the model editor with data from ECM
/// \param[in] _info Simulator update info
/// \param[in] _ecm Reference to Entity Component Manager
public: void Update(const UpdateInfo &_info, EntityComponentManager &_ecm);

// Documentation inherited
protected: bool eventFilter(QObject *_obj, QEvent *_event) override;
Expand Down
13 changes: 6 additions & 7 deletions src/gui/plugins/entity_tree/EntityTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ void TreeModel::AddEntity(Entity _entity, const QString &_entityName,
IGN_PROFILE("TreeModel::AddEntity");
QStandardItem *parentItem{nullptr};

// check if entity has already been added or not.
// This could happen because we get new and removed entity updates from both
// the ECM and GUI events.
if (this->entityItems.find(_entity) != this->entityItems.end())
return;

// Root
if (_parentEntity == kNullEntity)
{
Expand All @@ -151,13 +157,6 @@ void TreeModel::AddEntity(Entity _entity, const QString &_entityName,
return;
}

if (this->entityItems.find(_entity) != this->entityItems.end())
{
ignwarn << "Internal error: Trying to create item for entity [" << _entity
<< "], but entity already has an item." << std::endl;
return;
}

// New entity item
auto entityItem = new QStandardItem(_entityName);
entityItem->setData(_entityName, this->roleNames().key("entityName"));
Expand Down
4 changes: 0 additions & 4 deletions src/gui/plugins/model_editor/CMakeLists.txt

This file was deleted.

28 changes: 0 additions & 28 deletions src/gui/plugins/model_editor/ModelEditor.qml

This file was deleted.

5 changes: 0 additions & 5 deletions src/gui/plugins/model_editor/ModelEditor.qrc

This file was deleted.

0 comments on commit 0ecc731

Please sign in to comment.