VisualizationArrow.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ElementVisualizer.h"
4 
5 #include <RobotAPI/interface/ArViz/Elements.h>
6 #include <Inventor/nodes/SoCone.h>
7 #include <Inventor/nodes/SoCylinder.h>
8 #include <Inventor/nodes/SoSphere.h>
9 #include <Inventor/nodes/SoTranslation.h>
10 
11 namespace armarx::viz::coin
12 {
14  {
15  using ElementType = data::ElementArrow;
16 
18  {
19  tr = new SoTranslation;
20  c = new SoCylinder();
21  transl = new SoTranslation;
22  cone = new SoCone();
23 
24  node->addChild(tr);
25  node->addChild(c);
26  node->addChild(transl);
27  node->addChild(cone);
28  }
29 
30  bool update(ElementType const& element)
31  {
32  float coneHeight = element.width * 6.0f;
33  float coneBottomRadius = element.width * 2.5f;
34  float baseLength = element.length - coneHeight;
35  baseLength = std::max(0.0f, baseLength);
36 
37  tr->translation.setValue(0, baseLength * 0.5f, 0);
38 
39  c->radius = element.width;
40  c->height = baseLength;
41 
42  transl->translation.setValue(0, element.length * 0.5f, 0);
43 
44  cone->bottomRadius.setValue(coneBottomRadius);
45  cone->height.setValue(coneHeight);
46 
47  return true;
48  }
49 
50  SoTranslation* tr;
51  SoCylinder* c;
52  SoTranslation* transl;
53  SoCone* cone;
54  };
55 }
ElementVisualizer.h
armarx::viz::coin::VisualizationArrow
Definition: VisualizationArrow.h:13
armarx::viz::coin::TypedElementVisualization
Definition: ElementVisualizer.h:53
armarx::viz::coin::VisualizationArrow::ElementType
data::ElementArrow ElementType
Definition: VisualizationArrow.h:15
armarx::viz::coin::VisualizationArrow::VisualizationArrow
VisualizationArrow()
Definition: VisualizationArrow.h:17
armarx::viz::coin::TypedElementVisualization< SoSeparator >::node
NodeType * node
Definition: ElementVisualizer.h:68
armarx::viz::coin::VisualizationArrow::update
bool update(ElementType const &element)
Definition: VisualizationArrow.h:30
armarx::viz::coin::VisualizationArrow::cone
SoCone * cone
Definition: VisualizationArrow.h:53
max
T max(T t1, T t2)
Definition: gdiam.h:48
armarx::viz::coin::VisualizationArrow::c
SoCylinder * c
Definition: VisualizationArrow.h:51
armarx::viz::coin::VisualizationArrow::transl
SoTranslation * transl
Definition: VisualizationArrow.h:52
armarx::viz::coin
Definition: ElementVisualizer.cpp:11
armarx::viz::coin::VisualizationArrow::tr
SoTranslation * tr
Definition: VisualizationArrow.h:50