Go to the documentation of this file.
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;
136 const ignition::math::Vector3d &_size = ignition::math::Vector3d::One,
137 const ignition::math::Pose3d &_pose = ignition::math::Pose3d::Zero,
138 const std::string &_uri =
"",
const unsigned int _samples = 5);
148 const ignition::math::Vector3d &_size = ignition::math::Vector3d::One,
149 const ignition::math::Pose3d &_pose = ignition::math::Pose3d::Zero,
150 const std::string &_uri =
"",
const unsigned int _samples = 5);
170 const bool _newCmd =
true);
193 public:
void SetSelected(
const std::string &_name,
const bool selected);
199 const bool selected);
203 public:
enum SaveState CurrentSaveState()
const;
220 const std::string &_filename,
const std::string &_innerxml,
221 const bool _newCmd =
true);
252 const ignition::math::Pose3d &_world)
const;
257 private: sdf::ElementPtr GenerateLinkSDF(
LinkData *_link);
260 private:
void OnNew();
264 private:
bool OnSave();
268 private:
bool OnSaveAs();
273 private:
void OnNameChanged(
const std::string &_modelName);
278 private:
void OnPropertiesChanged(
const bool _static,
279 const bool _autoDisable);
282 private:
void OnExit();
287 private:
void RemoveNestedModelImpl(
const std::string &_nestedModelName);
292 private:
void RemoveLinkImpl(
const std::string &_linkName);
296 private slots:
void OnEdit(
const bool _checked);
300 private slots:
void OnEditModel(
const std::string &_modelName);
303 private slots:
void OnCopy();
306 private slots:
void OnPaste();
335 private:
void OnManipMode(
const std::string &_mode);
340 private:
void OnDeselectAll(
const std::string &_name,
341 const std::string &_mode);
347 private:
void OnSetSelectedEntity(
const std::string &_name,
348 const bool _selected);
354 private:
void OnSetSelectedModelPlugin(
const std::string &_name,
355 const bool _selected);
367 private:
void InsertLinkFromSDF(sdf::ElementPtr _sdf);
371 private:
void InsertNestedModelFromSDF(sdf::ElementPtr _sdf);
376 private:
NestedModelData *CloneNestedModel(
const std::string &_modelName);
381 private:
LinkData *CloneLink(
const std::string &_linkName);
388 private:
LinkData *CreateLinkFromSDF(
const sdf::ElementPtr &_linkElem,
393 private:
void OpenInspector(
const std::string &_name);
397 private:
void OpenModelPluginInspector(
const std::string &_name);
400 private:
virtual void CreateTheEntity();
403 private:
bool Init();
407 private: std::string CreateModel();
417 private:
NestedModelData *CreateModelFromSDF(
const sdf::ElementPtr &_sdf,
419 const bool _emit =
true);
428 private:
void OnAlignMode(
const std::string &_axis,
429 const std::string &_config,
const std::string &_target,
430 const bool _preview,
const bool _inverted =
false);
435 private:
void OnEntityScaleChanged(
const std::string &_name,
436 const ignition::math::Vector3d &_scale);
443 private:
void OnEntityMoved(
const std::string &_name,
444 const ignition::math::Pose3d &_pose,
const bool _isFinal);
448 private:
void DeselectAll();
451 private:
void DeselectAllEntities();
454 private:
void DeselectAllModelPlugins();
459 private:
void OnRequestLinkScale(
const std::string &_name,
460 const std::map<std::string, ignition::math::Vector3d> &_scales);
465 private:
void OnRequestLinkMove(
const std::string &_name,
466 const ignition::math::Pose3d &_pose);
471 private:
void OnRequestNestedModelMove(
const std::string &_name,
472 const ignition::math::Pose3d &_pose);
478 private:
void SetModelVisible(
const std::string &_name,
479 const bool _visible);
486 const bool _visible);
490 private:
void ShowContextMenu(
const std::string &_link);
494 private:
void ShowModelPluginContextMenu(
const std::string &_name);
498 private:
void EmitNestedModelInsertedEvent(
503 private slots:
void OnDelete();
507 private slots:
void OnDelete(
const std::string &_name);
510 private slots:
void OnOpenInspector();
514 private slots:
void OnOpenModelPluginInspector(
const QString &_name);
518 private slots:
void OnRemoveModelPlugin(
const QString &_name);
525 private: std::unique_ptr<ModelCreatorPrivate> dataPtr;
ModelCreator(QObject *_parent=NULL)
Constructor.
EntityType
Definition: ModelCreator.hh:67
bool SaveModelFiles()
Helper function to manage writing files to disk.
void SetModelName(const std::string &_modelName)
Set the name of 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.
void DisableEventHandlers()
Disable the mouse and key event handlers.
@ ENTITY_MODEL
Nested model.
Definition: ModelCreator.hh:81
@ UNSAVED_CHANGES
Has been saved before, but has unsaved changes.
Definition: ModelCreator.hh:95
std::string ModelName() const
Get the name of the model.
Forward declarations for the common classes.
Definition: Animation.hh:27
Handles the creation of joints in the model editor.
Definition: JointMaker.hh:77
@ ENTITY_MESH
Imported 3D mesh.
Definition: ModelCreator.hh:77
Create and manage 3D visuals of a model with links, nested models and joints.
Definition: ModelCreator.hh:61
void AddJoint(const std::string &_type)
Add a joint to the model.
ModelPluginData * ModelPlugin(const std::string &_name)
Get a model plugin data by its name.
#define NULL
Definition: CommonTypes.hh:31
void ShowCollisions(const bool _show)
Show or hide collision visuals.
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.
@ ENTITY_NONE
none
Definition: ModelCreator.hh:69
common
Definition: FuelModelDatabase.hh:37
void ShowLinkFrames(const bool _show)
Show or hide link frame visuals.
void FinishModel()
Finish the model and create the entity on the gzserver.
void SetSelected(const std::string &_name, const bool selected)
Set the select state of an entity.
void SetSelected(const rendering::VisualPtr &_entityVis, const bool selected)
Set the select state of a entity visual.
void GenerateSDF()
Generate the SDF from model link and joint visuals.
virtual ~ModelCreator()
Destructor.
NestedModelData * AddModel(const sdf::ElementPtr &_sdf)
Add a nested model to the model.
@ NEVER_SAVED
The model has never been saved.
Definition: ModelCreator.hh:89
void LinkAdded()
Qt signal when the a link has been added.
void AddModelPlugin(const sdf::ElementPtr &_pluginElem)
Add a model plugin to the model.
void Stop()
Stop the process of adding a link or joint to the model.
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 SetAutoDisable(const bool _auto)
Set the model to allow auto disable at rest.
void ShowVisuals(const bool _show)
Show or hide visual visuals.
Helper class to store nested models data.
Definition: ModelData.hh:58
void AddLink(const EntityType _type)
Add a link to the model.
enum SaveState CurrentSaveState() const
Get current save state.
Generic description of a keyboard event.
Definition: KeyEvent.hh:33
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.
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gui
Definition: KeyEventHandler.hh:29
void SetStatic(const bool _static)
Set the model to be static.
void AddEntity(const sdf::ElementPtr &_sdf)
Add an entity to the model.
SaveState
Save states for the model editor.
Definition: ModelCreator.hh:87
Helper class to store model plugin data.
Definition: ModelData.hh:313
void RemoveModelPlugin(const std::string &_pluginName, const bool _newCmd=true)
Remove a model plugin from the model.
@ ENTITY_SPHERE
Sphere.
Definition: ModelCreator.hh:73
@ ALL_SAVED
All changes have been saved.
Definition: ModelCreator.hh:92
gui::JointMaker * JointMaker() const
Get joint maker.
Helper class to store link data.
Definition: ModelData.hh:95
void Reset()
Reset the model creator and the SDF.
@ ENTITY_POLYLINE
Extruded polyline.
Definition: ModelCreator.hh:79
void EnableEventHandlers()
Enable the mouse and key event handlers.
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:114
void ModelChanged()
Set save state upon a change to the model.
@ ENTITY_BOX
Box.
Definition: ModelCreator.hh:71
@ ENTITY_CYLINDER
Cylinder.
Definition: ModelCreator.hh:75
Generic description of a mouse event.
Definition: MouseEvent.hh:36
void RemoveEntity(const std::string &_entityName)
Remove an entity from the model.