##

JointMaker Class Reference
GUI

Handles the creation of joints in the model editor. More...

`#include <JointMaker.hh>`

Inherits QObject.

## Public Types

enum | JointType { JOINT_NONE, JOINT_FIXED, JOINT_SLIDER, JOINT_HINGE, JOINT_HINGE2, JOINT_SCREW, JOINT_UNIVERSAL, JOINT_BALL, JOINT_GEARBOX }

## Public Slots

void | OnType (const int _typeInt)
| A new type for the joint being created has been chosen. More...
void | SetAxis (const std::string &_axis, const ignition::math::Vector3d &_value)
| A new axis for the joint being created has been chosen. More...
void | ShowJoints (const bool _show)
| Qt Callback to show / hide joint visuals. More...

## Signals

void | EmitLinkInserted (const std::string &_linkId)
| Qt signal to notify that a link has been inserted. More...
void | EmitLinkRemoved (const std::string &_linkId)
| Qt signal to notify that a link has been removed. More...
void | JointAdded ()
| Qt signal when the joint creation process has ended. More...

## Public Member Functions

| JointMaker ()
| Constructor. More...
virtual | ~JointMaker ()
| Destructor. More...
void | AddJoint (const JointType _type)
| Add a joint. More...
void | AddJoint (const std::string &_type)
| Add a joint. More...
void | AddScopedLinkName (const std::string &_name)
| Add a scoped link name. More...
void | AlignLinks (const bool _childToParent, const std::string &_axis, const std::string &_mode, const bool _reverse)
| Align the parent and child links of the joint being created. More...
std::string | CreateHotSpot (JointData *_joint)
| Helper method to create hotspot visual for mouse interaction. More...
JointData * | CreateJoint (const rendering::VisualPtr &_parent, const rendering::VisualPtr &_child)
| Create a joint with parent and child. More...
void | CreateJointFromSDF (sdf::ElementPtr _jointElem, const std::string &_modelName="")
| Create a joint from SDF. More...
void | DisableEventHandlers ()
| Disable the mouse and key event handlers for the joint maker. More...
void | EnableEventHandlers ()
| Enable the mouse and key event handlers for the joint maker. More...
void | FinalizeCreation ()
| Finalize joint creation. More...
void | GenerateSDF ()
| Generate SDF for all joints. More...
unsigned int | JointCount ()
| Get the number of joints added. More...
std::vector< JointData * > | JointDataByLink (const std::string &_linkName) const
| Get a vector containing data for all joints connected to the given link. More...
std::map< std::string, std::string > | LinkList () const
| Get the list of links. More...
void | RemoveJoint (const std::string &_jointName)
| Remove joint by name. More...
void | RemoveJointByUser (const std::string &_jointName)
| Remove joint by name and register user command. More...
void | RemoveJointsByLink (const std::string &_linkName)
| Remove all joints connected to link. More...
void | Reset ()
| Reset the joint maker;. More...
sdf::ElementPtr | SDF () const
| Get model SDF element containing all joints. More...
void | SetChildLink (const std::string &_name)
| A new child link for the joint being created has been chosen. More...
void | SetJointPose (const ignition::math::Pose3d &_pose)
| A new joint pose for the joint being created has been chosen. More...
void | SetLinksRelativePose (const ignition::math::Pose3d &_pose, const bool _resetAll, const int _resetAxis=-1)
| A new relative pose for the child link of the joint being created hass been chosen. More...
void | SetParentLink (const std::string &_name)
| A new parent link for the joint being created has been chosen. More...
void | SetSelected (const rendering::VisualPtr &_jointVis, const bool selected)
| Set the select state of a joint visual. More...
void | SetSelected (const std::string &_name, const bool selected)
| Set the select state of a joint. More...
void | SetUserCmdManager (MEUserCmdManager *_manager)
| Set the user command manager variable. More...
JointMaker::JointType | State () const
| Get state. More...
void | Stop ()
| Stop the process of adding joint to the model. More...
void | Update ()
| Update callback on PreRender. More...

## Static Public Member Functions

static JointType | ConvertJointType (const std::string &_type)
| Convert a joint type string to enum. More...
static unsigned int | JointAxisCount (const JointMaker::JointType _type)
| Get the axis count for joint type. More...
static std::string | JointMaterial (const std::string &_type)
| Get the material for the joint type. More...
static std::string | TypeAsString (const JointMaker::JointType _type)
| Get the joint type in string. More...

## Static Public Attributes

static std::map< JointMaker::JointType, std::string > | jointMaterials
| A map of joint type to its corresponding material. More...
static std::map< JointMaker::JointType, std::string > | jointTypes
| A map of joint type to its string value. More...
static std::vector< ignition::math::Vector3d > | unitVectors
| Constant vector containing [UnitX, UnitY, UnitZ]. More...

## Detailed Description

Handles the creation of joints in the model editor.

## Member Enumeration Documentation

## JointType

enum JointType

Enumerator
JOINT_NONE | none
JOINT_FIXED | Fixed joint.
JOINT_SLIDER | Slider joint.
JOINT_HINGE | Hinge joint.
JOINT_HINGE2 | Hinge2 joint.
JOINT_SCREW | Screw joint.
JOINT_UNIVERSAL | Universal joint.
JOINT_BALL | Ball joint.
JOINT_GEARBOX | Gearbox joint.

## Constructor & Destructor Documentation

## JointMaker()

JointMaker | ( |  | ) |

Constructor.

## ~JointMaker()

virtual ~JointMaker | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## AddJoint() [1/2]

void AddJoint | ( | const JointType | _type | ) |

Add a joint.

Parameters

  [in] | _type | Type of joint to be added

## AddJoint() [2/2]

void AddJoint | ( | const std::string & | _type | ) |

Add a joint.

Parameters

  [in] | _type | Type of joint to be added in string.

## AddScopedLinkName()

void AddScopedLinkName | ( | const std::string & | _name | ) |

Add a scoped link name.

Nested model's link names are scoped but the parent and child field in the joint SDF element may not be. So keep track of scoped link names in order to generate the correct SDF before spawning the model.

Parameters

  [in] | _name | Scoped link name.

## AlignLinks()

void AlignLinks | ( | const bool | _childToParent,
|  | const std::string & | _axis,
|  | const std::string & | _mode,
|  | const bool | _reverse
| ) |  |

Align the parent and child links of the joint being created.

Parameters

  [in] | _childToParent | True to align the child to the parent, false to align the parent to the child.
  [in] | _axis | Axis of alignment (x/y/z)
  [in] | _mode | Alignment mode (min/center/max)
  [in] | _reverse | True to reverse alignment.

## ConvertJointType()

static JointType ConvertJointType | ( | const std::string & | _type | ) |

static

Convert a joint type string to enum.

Parameters

  [in] | _type | Joint type in string.

Returns
  Joint type enum.

## CreateHotSpot()

std::string CreateHotSpot | ( | JointData * | _joint | ) |

Helper method to create hotspot visual for mouse interaction.

Parameters

  [in] | _joint | Joint data used for creating the hotspot

Returns
  Joint id, empty if hotspot creation failed.

## CreateJoint()

JointData* CreateJoint | ( | const rendering::VisualPtr & | _parent,
|  | const rendering::VisualPtr & | _child
| ) |  |

Create a joint with parent and child.

Parameters

  [in] | _parent | Parent of the joint.
  [in] | _child | Child of the joint.

Returns
  Joint data.

## CreateJointFromSDF()

void CreateJointFromSDF | ( | sdf::ElementPtr | _jointElem,
|  | const std::string & | _modelName = `""`
| ) |  |

Create a joint from SDF.

This is mainly used when editing existing models.

Parameters

  [in] | _jointElement | SDF element to load.
  [in] | _modelName | Name of the model that contains this joint.

## DisableEventHandlers()

void DisableEventHandlers | ( |  | ) |

Disable the mouse and key event handlers for the joint maker.

## EmitLinkInserted

void EmitLinkInserted | ( | const std::string & | _linkId | ) |

signal

Qt signal to notify that a link has been inserted.

Parameters

  [in] | _linkId | Link's unique name.

## EmitLinkRemoved

void EmitLinkRemoved | ( | const std::string & | _linkId | ) |

signal

Qt signal to notify that a link has been removed.

Parameters

  [in] | _linkId | Link's unique name.

## EnableEventHandlers()

void EnableEventHandlers | ( |  | ) |

Enable the mouse and key event handlers for the joint maker.

## FinalizeCreation()

void FinalizeCreation | ( |  | ) |

Finalize joint creation.

## GenerateSDF()

void GenerateSDF | ( |  | ) |

Generate SDF for all joints.

## JointAdded

void JointAdded | ( |  | ) |

signal

Qt signal when the joint creation process has ended.

## JointAxisCount()

static unsigned int JointAxisCount | ( | const JointMaker::JointType | _type | ) |

static

Get the axis count for joint type.

Parameters

  [in] | _type | Type of joint.

Returns
  Axis count.

## JointCount()

unsigned int JointCount | ( |  | ) |

Get the number of joints added.

Returns
  Number of joints.

## JointDataByLink()

std::vector<JointData *> JointDataByLink | ( | const std::string & | _linkName | ) | const

Get a vector containing data for all joints connected to the given link.

Parameters

  [in] | _linkName | Name of the link.

Returns
  Vector with joint data.

## JointMaterial()

static std::string JointMaterial | ( | const std::string & | _type | ) |

static

Get the material for the joint type.

Parameters

  [in] | _type | Type of joint.

Returns
  Name of material.

## LinkList()

std::map<std::string, std::string> LinkList | ( |  | ) | const

Get the list of links.

Returns
  The list of links, with the link scoped name and leaf name.

## OnType

void OnType | ( | const int | _typeInt | ) |

slot

A new type for the joint being created has been chosen.

To be used by other classes.

Parameters

  [in] | _typeInt | Integer corresponding to joint type enum.

## RemoveJoint()

void RemoveJoint | ( | const std::string & | _jointName | ) |

Remove joint by name.

Parameters

  [in] | _jointName | Name of joint to be removed, or an empty string to remove the new joint under creation.

## RemoveJointByUser()

void RemoveJointByUser | ( | const std::string & | _jointName | ) |

Remove joint by name and register user command.

Parameters

  [in] | _jointName | Name of joint to be removed.

## RemoveJointsByLink()

void RemoveJointsByLink | ( | const std::string & | _linkName | ) |

Remove all joints connected to link.

Parameters

  [in] | _linkName | Name of the link.

## Reset()

void Reset | ( |  | ) |

Reset the joint maker;.

## SDF()

sdf::ElementPtr SDF | ( |  | ) | const

Get model SDF element containing all joints.

Returns
  Pointer to SDF element.

## SetAxis

void SetAxis | ( | const std::string & | _axis,
|  | const ignition::math::Vector3d & | _value
| ) |  |

slot

A new axis for the joint being created has been chosen.

To be used by other classes.

Parameters

  [in] | _axis | Axis which was changed, either "axis1" or "axis2".
  [in] | _value | New value for the axis

## SetChildLink()

void SetChildLink | ( | const std::string & | _name | ) |

A new child link for the joint being created has been chosen.

To be used by other classes.

See also
  SetChildLink(const rendering::VisualPtr &_childLink)

Parameters

  [in] | _name | Link name, either the leaf or scoped.

## SetJointPose()

void SetJointPose | ( | const ignition::math::Pose3d & | _pose | ) |

A new joint pose for the joint being created has been chosen.

To be used by other classes.

Parameters

  [in] | _pose | New joint pose.

## SetLinksRelativePose()

void SetLinksRelativePose | ( | const ignition::math::Pose3d & | _pose,
|  | const bool | _resetAll,
|  | const int | _resetAxis = `-1`
| ) |  |

A new relative pose for the child link of the joint being created hass been chosen.

The pose is expressed in the parent link frame. This has no effect if triggered before both links are chosen.

Parameters

  [in] | _pose | New pose.
  [in] | _resetAll | Set to true to reset the relative pose to the original one. \paran[in] _resetAxis Reset only the given axis 0 == x, 1 == y, 2 == z

## SetParentLink()

void SetParentLink | ( | const std::string & | _name | ) |

A new parent link for the joint being created has been chosen.

To be used by other classes.

See also
  SetParentLink(const rendering::VisualPtr &_parentLink)

Parameters

  [in] | _name | Link name, either the leaf or scoped.

## SetSelected() [1/2]

void SetSelected | ( | const rendering::VisualPtr & | _jointVis,
|  | const bool | selected
| ) |  |

Set the select state of a joint visual.

Parameters

  [in] | _jointVis | Pointer to the joint visual.
  [in] | _selected | True to select the joint.

## SetSelected() [2/2]

void SetSelected | ( | const std::string & | _name,
|  | const bool | selected
| ) |  |

Set the select state of a joint.

Parameters

  [in] | _name | Name of the joint.
  [in] | _selected | True to select the joint.

## SetUserCmdManager()

void SetUserCmdManager | ( | MEUserCmdManager * | _manager | ) |

Set the user command manager variable.

Parameters

  [in] | _manager | Pointer to the manager.

## ShowJoints

void ShowJoints | ( | const bool | _show | ) |

slot

Qt Callback to show / hide joint visuals.

Parameters

  [in] | _show | True to show joints, false to hide them.

## State()

JointMaker::JointType State | ( |  | ) | const

Get state.

Returns
  Current state of the joint maker. If mouse is enabled to create a new joint, it returns the type of joint. Otherwise, it returns JOINT_NONE.

## Stop()

void Stop | ( |  | ) |

Stop the process of adding joint to the model.

## TypeAsString()

static std::string TypeAsString | ( | const JointMaker::JointType | _type | ) |

static

Get the joint type in string.

Parameters

  [in] | _type | Type of joint.

Returns
  Joint type in string.

## Update()

void Update | ( |  | ) |

Update callback on PreRender.

## Member Data Documentation

## jointMaterials

std::map<JointMaker::JointType, std::string> jointMaterials

static

A map of joint type to its corresponding material.

## jointTypes

std::map<JointMaker::JointType, std::string> jointTypes

static

A map of joint type to its string value.

## unitVectors

std::vector<ignition::math::Vector3d> unitVectors

static

Constant vector containing [UnitX, UnitY, UnitZ].

The documentation for this class was generated from the following file:

- JointMaker.hh