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

Added a method to show the head on arrows and axis #95

Merged
merged 6 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

### Ignition Rendering 4.0.0

1. Added a method to show the head on arrows and axis
* [Pull request #95](https://github.com/ignitionrobotics/ign-rendering/pull/95)

1. Scale BaseAxis properly
* [Pull request #88](https://github.com/ignitionrobotics/ign-rendering/pull/88)

Expand Down
4 changes: 4 additions & 0 deletions include/ignition/rendering/ArrowVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ namespace ignition
/// \brief Get arrow-shaft visual
/// \return The arrow-shaft visual
public: virtual VisualPtr Shaft() const = 0;

/// \brief set true to show the arrow head, false otherwise
/// \param[in] _b true to show the arrow head, false otherwise
public: virtual void ShowArrowHead(bool _b) = 0;
};
}
}
Expand Down
4 changes: 4 additions & 0 deletions include/ignition/rendering/AxisVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ namespace ignition
{
/// \brief Deconstructor
public: virtual ~AxisVisual() { }

/// \brief set true to show the axis heads, false otherwise
/// \param[in] _b true to show the axis heads, false otherwise
public: virtual void ShowAxisHead(bool _b) = 0;
};
}
}
Expand Down
15 changes: 15 additions & 0 deletions include/ignition/rendering/base/BaseArrowVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ namespace ignition

public: virtual VisualPtr Shaft() const;

// Documentation inherited
public: virtual void ShowArrowHead(bool _b) override;

protected: virtual void Init();
};

Expand Down Expand Up @@ -68,6 +71,18 @@ namespace ignition
return nullptr;
}

//////////////////////////////////////////////////
template <class T>
void BaseArrowVisual<T>::ShowArrowHead(bool _b)
{
NodePtr child = this->ChildByIndex(1);
VisualPtr visual = std::dynamic_pointer_cast<Visual>(child);
if (visual)
{
visual->SetVisible(_b);
}
}

//////////////////////////////////////////////////
template <class T>
void BaseArrowVisual<T>::Init()
Expand Down
15 changes: 15 additions & 0 deletions include/ignition/rendering/base/BaseAxisVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ namespace ignition

// Documentation inherited.
public: virtual math::Vector3d LocalScale() const override;

// Documentation inherited.
public: void ShowAxisHead(bool _b) override;
};

//////////////////////////////////////////////////
Expand Down Expand Up @@ -78,6 +81,18 @@ namespace ignition
_scale.Z());
}

//////////////////////////////////////////////////
template <class T>
void BaseAxisVisual<T>::ShowAxisHead(bool _b)
{
for (unsigned int i = 0; i < this->ChildCount(); ++i)
{
auto arrow = std::dynamic_pointer_cast<rendering::ArrowVisual>(
this->ChildByIndex(i));
arrow->ShowArrowHead(_b);
}
}

//////////////////////////////////////////////////
template <class T>
void BaseAxisVisual<T>::Init()
Expand Down