18#ifndef GAZEBO_GUI_MODEL_MODELCREATOR_HH_
19#define GAZEBO_GUI_MODEL_MODELCREATOR_HH_
26#include <ignition/math/Pose3.hh>
27#include <ignition/math/Vector3.hh>
48 class ModelPluginData;
49 class NestedModelData;
52 class ModelCreatorPrivate;
135 const ignition::math::Vector3d &_size = ignition::math::Vector3d::One,
136 const ignition::math::Pose3d &_pose = ignition::math::Pose3d::Zero,
137 const std::string &_uri =
"",
const unsigned int _samples = 5);
147 const ignition::math::Vector3d &_size = ignition::math::Vector3d::One,
148 const ignition::math::Pose3d &_pose = ignition::math::Pose3d::Zero,
149 const std::string &_uri =
"",
const unsigned int _samples = 5);
169 const bool _newCmd =
true);
192 public:
void SetSelected(
const std::string &_name,
const bool selected);
198 const bool selected);
219 const std::string &_filename,
const std::string &_innerxml,
220 const bool _newCmd =
true);
251 const ignition::math::Pose3d &_world)
const;
256 private: sdf::ElementPtr GenerateLinkSDF(
LinkData *_link);
259 private:
void OnNew();
263 private:
bool OnSave();
267 private:
bool OnSaveAs();
272 private:
void OnNameChanged(
const std::string &_modelName);
277 private:
void OnPropertiesChanged(
const bool _static,
278 const bool _autoDisable);
281 private:
void OnExit();
286 private:
void RemoveNestedModelImpl(
const std::string &_nestedModelName);
291 private:
void RemoveLinkImpl(
const std::string &_linkName);
295 private slots:
void OnEdit(
const bool _checked);
299 private slots:
void OnEditModel(
const std::string &_modelName);
302 private slots:
void OnCopy();
305 private slots:
void OnPaste();
334 private:
void OnManipMode(
const std::string &_mode);
339 private:
void OnDeselectAll(
const std::string &_name,
340 const std::string &_mode);
346 private:
void OnSetSelectedEntity(
const std::string &_name,
347 const bool _selected);
353 private:
void OnSetSelectedModelPlugin(
const std::string &_name,
354 const bool _selected);
366 private:
void InsertLinkFromSDF(sdf::ElementPtr _sdf);
370 private:
void InsertNestedModelFromSDF(sdf::ElementPtr _sdf);
375 private:
NestedModelData *CloneNestedModel(
const std::string &_modelName);
380 private:
LinkData *CloneLink(
const std::string &_linkName);
387 private:
LinkData *CreateLinkFromSDF(
const sdf::ElementPtr &_linkElem,
392 private:
void OpenInspector(
const std::string &_name);
396 private:
void OpenModelPluginInspector(
const std::string &_name);
399 private:
virtual void CreateTheEntity();
402 private:
bool Init();
406 private: std::string CreateModel();
416 private:
NestedModelData *CreateModelFromSDF(
const sdf::ElementPtr &_sdf,
418 const bool _emit =
true);
427 private:
void OnAlignMode(
const std::string &_axis,
428 const std::string &_config,
const std::string &_target,
429 const bool _preview,
const bool _inverted =
false);
434 private:
void OnEntityScaleChanged(
const std::string &_name,
435 const ignition::math::Vector3d &_scale);
442 private:
void OnEntityMoved(
const std::string &_name,
443 const ignition::math::Pose3d &_pose,
const bool _isFinal);
447 private:
void DeselectAll();
450 private:
void DeselectAllEntities();
453 private:
void DeselectAllModelPlugins();
458 private:
void OnRequestLinkScale(
const std::string &_name,
459 const std::map<std::string, ignition::math::Vector3d> &_scales);
464 private:
void OnRequestLinkMove(
const std::string &_name,
465 const ignition::math::Pose3d &_pose);
470 private:
void OnRequestNestedModelMove(
const std::string &_name,
471 const ignition::math::Pose3d &_pose);
477 private:
void SetModelVisible(
const std::string &_name,
478 const bool _visible);
485 const bool _visible);
489 private:
void ShowContextMenu(
const std::string &_link);
493 private:
void ShowModelPluginContextMenu(
const std::string &_name);
497 private:
void EmitNestedModelInsertedEvent(
502 private slots:
void OnDelete();
506 private slots:
void OnDelete(
const std::string &_name);
509 private slots:
void OnOpenInspector();
513 private slots:
void OnOpenModelPluginInspector(
const QString &_name);
517 private slots:
void OnRemoveModelPlugin(
const QString &_name);
524 private: std::unique_ptr<ModelCreatorPrivate> dataPtr;
#define NULL
Definition CommonTypes.hh:31
common
Definition FuelModelDatabase.hh:37
gui
Definition KeyEventHandler.hh:29
Generic description of a keyboard event.
Definition KeyEvent.hh:33
Generic description of a mouse event.
Definition MouseEvent.hh:36
Handles the creation of joints in the model editor.
Definition JointMaker.hh:77
Helper class to store link data.
Definition ModelData.hh:95
Create and manage 3D visuals of a model with links, nested models and joints.
Definition ModelCreator.hh:61
ignition::math::Pose3d WorldToLocal(const ignition::math::Pose3d &_world) const
Convert a given pose from the world frame to the local frame of the model being edited.
void SaveModelFiles()
Helper function to manage writing files to disk.
void AddJoint(const std::string &_type)
Add a joint to the model.
void Stop()
Stop the process of adding a link or joint to the model.
void AddCustomLink(const EntityType _type, const ignition::math::Vector3d &_size=ignition::math::Vector3d::One, const ignition::math::Pose3d &_pose=ignition::math::Pose3d::Zero, const std::string &_uri="", const unsigned int _samples=5)
Begin the process of inserting a custom link using the mouse.
LinkData * AddShape(const EntityType _type, const ignition::math::Vector3d &_size=ignition::math::Vector3d::One, const ignition::math::Pose3d &_pose=ignition::math::Pose3d::Zero, const std::string &_uri="", const unsigned int _samples=5)
Add a link to the model.
void SetSelected(const std::string &_name, const bool selected)
Set the select state of an entity.
void AddLink(const EntityType _type)
Add a link to the model.
void AddModelPlugin(const sdf::ElementPtr &_pluginElem)
Add a model plugin to the model.
gui::JointMaker * JointMaker() const
Get joint maker.
void Reset()
Reset the model creator and the SDF.
void DisableEventHandlers()
Disable the mouse and key event handlers.
void FinishModel()
Finish the model and create the entity on the gzserver.
ModelCreator(QObject *_parent=NULL)
Constructor.
void OnAddModelPlugin(const std::string &_name, const std::string &_filename, const std::string &_innerxml, const bool _newCmd=true)
Add a model plugin to the model.
void ShowCollisions(const bool _show)
Show or hide collision visuals.
SaveState
Save states for the model editor.
Definition ModelCreator.hh:87
@ ALL_SAVED
All changes have been saved.
Definition ModelCreator.hh:92
@ NEVER_SAVED
The model has never been saved.
Definition ModelCreator.hh:89
@ UNSAVED_CHANGES
Has been saved before, but has unsaved changes.
Definition ModelCreator.hh:95
ModelPluginData * ModelPlugin(const std::string &_name)
Get a model plugin data by its name.
void SetStatic(const bool _static)
Set the model to be static.
void ModelChanged()
Set save state upon a change to the model.
void ShowVisuals(const bool _show)
Show or hide visual visuals.
void LinkAdded()
Qt signal when the a link has been added.
std::string ModelName() const
Get the name of the model.
void RemoveEntity(const std::string &_entityName)
Remove an entity from the model.
void SetModelName(const std::string &_modelName)
Set the name of the model.
void RemoveModelPlugin(const std::string &_pluginName, const bool _newCmd=true)
Remove a model plugin from the model.
virtual ~ModelCreator()
Destructor.
void AddEntity(const sdf::ElementPtr &_sdf)
Add an entity to the model.
void GenerateSDF()
Generate the SDF from model link and joint visuals.
enum SaveState CurrentSaveState() const
Get current save state.
void SetAutoDisable(const bool _auto)
Set the model to allow auto disable at rest.
NestedModelData * AddModel(const sdf::ElementPtr &_sdf)
Add a nested model to the model.
void EnableEventHandlers()
Enable the mouse and key event handlers.
EntityType
Definition ModelCreator.hh:67
@ ENTITY_POLYLINE
Extruded polyline.
Definition ModelCreator.hh:79
@ ENTITY_MESH
Imported 3D mesh.
Definition ModelCreator.hh:77
@ ENTITY_BOX
Box.
Definition ModelCreator.hh:71
@ ENTITY_CYLINDER
Cylinder.
Definition ModelCreator.hh:75
@ ENTITY_SPHERE
Sphere.
Definition ModelCreator.hh:73
@ ENTITY_NONE
none
Definition ModelCreator.hh:69
@ ENTITY_MODEL
Nested model.
Definition ModelCreator.hh:81
void SetSelected(const rendering::VisualPtr &_entityVis, const bool selected)
Set the select state of a entity visual.
void ShowLinkFrames(const bool _show)
Show or hide link frame visuals.
Helper class to store model plugin data.
Definition ModelData.hh:313
Helper class to store nested models data.
Definition ModelData.hh:58
std::shared_ptr< Visual > VisualPtr
Definition RenderTypes.hh:114
Forward declarations for the common classes.
Definition Animation.hh:27