Cylinder.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <mc_rtc/gui/Visual.h>
4 #include <mc_rtc/visual_utils.h>
5 
6 namespace mc_rtc::gui
7 {
8 
11 {
12  double radius;
13  double length;
14 };
15 
26 template<typename GetPos, typename GetParams = const CylinderParameters &, typename GetColor = const mc_rtc::gui::Color &>
27 auto Cylinder(const std::string & name,
28  GetParams params_fn,
29  GetPos get_pos_fn,
30  GetColor color_fn = mc_rtc::gui::Color::Red)
31 {
33  auto visual = mc_rtc::makeVisualCylinder(params.radius, params.length, details::GetValueOrCallbackValue(color_fn));
34  auto get_visual_fn = [=]() mutable -> const rbd::parsers::Visual &
35  {
36  if constexpr(std::is_invocable_v<GetParams>)
37  {
38  auto & cylinder = mc_rtc::getVisualCylinder(visual);
39  auto params = params_fn();
40  cylinder.radius = params.radius;
41  cylinder.length = params.length;
42  }
43  if constexpr(std::is_invocable_v<GetColor>) { mc_rtc::details::setVisualColor(visual, color_fn()); }
44  return visual;
45  };
46  return Visual(name, get_visual_fn, get_pos_fn);
47 }
48 
49 } // namespace mc_rtc::gui
Visual.h
mc_rtc::gui::Color::Red
static const Color Red
Definition: types.h:102
mc_rtc::gui::details::GetValueOrCallbackValue
auto GetValueOrCallbackValue(const T &value_or_cb)
Definition: traits.h:231
visual_utils.h
mc_rtc::details::setVisualColor
void setVisualColor(rbd::parsers::Visual &visual, const mc_rtc::gui::Color &color)
Definition: visual_utils.h:20
mc_rtc::gui::Cylinder
auto Cylinder(const std::string &name, GetParams params_fn, GetPos get_pos_fn, GetColor color_fn=mc_rtc::gui::Color::Red)
Definition: Cylinder.h:27
mc_rtc::gui::Visual
auto Visual(const std::string &name, GetVisual get_visual_fn, GetPos get_pos_fn)
Definition: Visual.h:64
mc_rtc::gui::CylinderParameters::radius
double radius
Definition: Cylinder.h:12
mc_rtc::getVisualCylinder
constexpr auto getVisualCylinder
Definition: visual_utils.h:92
mc_rtc::makeVisualCylinder
rbd::parsers::Visual makeVisualCylinder(double radius, double length, const mc_rtc::gui::Color &color)
Definition: visual_utils.h:83
mc_rtc::gui::CylinderParameters
Definition: Cylinder.h:10
mc_rtc::gui::CylinderParameters::length
double length
Definition: Cylinder.h:13
MC_RTC_GUI_DLLAPI
#define MC_RTC_GUI_DLLAPI
Definition: api.h:50
mc_rtc::gui
Definition: Observer.h:15