Visu.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
17  * @date 2021
18  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19  * GNU General Public License
20  */
21 
22 #include "Visu.h"
23 
24 #include <SimoxUtility/color/Color.h>
25 #include <SimoxUtility/math/pose.h>
26 #include <VirtualRobot/VirtualRobot.h>
27 
29 
31 
33 {
34 
36 
37  viz::Pose
38  VertexVisu::Pose::draw(const std::string& name,
39  const core::Pose& pose,
40  const VertexData& attribs) const
41  {
43  if (attribs.highlighted)
44  {
46  }
47  return p;
48  }
49 
51  VertexVisu::ForwardArrow::draw(const std::string& name,
52  const core::Pose& pose,
53  const VertexData& attribs) const
54  {
55  viz::Arrow arrow =
57  if (attribs.highlighted)
58  {
59  arrow.color(colorHighlighted);
60  arrow.width(width * 1.5f);
61  }
62  return arrow;
63  }
64 
65  void
67  GuiGraph::ConstVertex vertex,
69  {
70  const auto p = core::resolveLocation(info.objects, info.info, vertex.attrib().getPose());
71  if (p.pose.has_value())
72  {
73  draw(layer, vertex.attrib().getName(), p.pose.value(), vertex.attrib());
74  }
75  }
76 
77  void
79  const std::string& name,
80  const core::Pose& pose,
81  const VertexData& attribs) const
82  {
83  if (this->pose.has_value())
84  {
85  layer.add(this->pose->draw(name, pose, attribs));
86  }
87  if (forwardArrow.has_value())
88  {
89  layer.add(forwardArrow->draw(name, pose, attribs));
90  }
91  }
92 
95  const std::string& sourceName,
96  const std::string& targetName,
97  const core::Pose& source,
98  const core::Pose& target) const
99  {
100  viz::Arrow arrow =
101  navigation::graph::EdgeVisu::Arrow::draw(sourceName, targetName, source, target);
102  if (edge.highlighted)
103  {
104  arrow.color(colorHighlighted);
105  arrow.width(width * 1.5f);
106  }
107  return arrow;
108  }
109 
110  void
112  GuiGraph::ConstEdge edge,
114  {
115  const auto src =
116  core::resolveLocation(info.objects, info.info, edge.source().attrib().getPose());
117  const auto tar =
118  core::resolveLocation(info.objects, info.info, edge.target().attrib().getPose());
119  if (src.pose.has_value() && tar.pose.has_value() && arrow.has_value())
120  {
121  layer.add(arrow->draw(edge.attrib(),
122  edge.source().attrib().getName(),
123  edge.target().attrib().getName(),
124  src.pose.value(),
125  tar.pose.value()));
126  }
127  }
128 
129  void
131  const GuiGraph& graph,
133  {
134  if (vertex.has_value())
135  {
136  for (GuiGraph::ConstVertex v : graph.vertices())
137  {
138  vertex->draw(layer, v, info);
139  }
140  }
141  if (edge.has_value())
142  {
143  for (GuiGraph::ConstEdge e : graph.edges())
144  {
145  edge->draw(layer, e, info);
146  }
147  }
148  }
149 
150 
151 } // namespace armarx::navigation::qt_plugins::location_graph_editor
Client.h
armarx::navigation::qt_plugins::location_graph_editor::EdgeVisu::Arrow::draw
viz::Arrow draw(const EdgeData &edge, const std::string &sourceName, const std::string &targetName, const core::Pose &source, const core::Pose &target) const
Definition: Visu.cpp:94
armarx::navigation::qt_plugins::location_graph_editor::GraphVisu::draw
void draw(viz::Layer &layer, const GuiGraph &graph, graph::visu::ObjectParserInfo info) const
Definition: Visu.cpp:130
armarx::navigation::graph::visu::ObjectParserInfo::info
const std::vector< ObjectInfo > & info
Definition: Visu.h:47
armarx::navigation::qt_plugins::location_graph_editor::VertexVisu::forwardArrow
std::optional< ForwardArrow > forwardArrow
Definition: Visu.h:62
armarx::navigation::core::resolveLocation
void resolveLocation(Graph::Vertex &vertex, const aron::data::DictPtr &locationData)
Definition: Graph.cpp:244
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
armarx::navigation::core::VertexAttribs::getName
std::string getName() const
Definition: Graph.cpp:41
boost::target
Vertex target(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:688
armarx::viz::Arrow
Definition: Elements.h:198
armarx::navigation::qt_plugins::location_graph_editor::EdgeData
The EdgeData struct holds data required for the edge.
Definition: GuiGraph.h:59
armarx::navigation::graph::EdgeVisu::Arrow::draw
viz::Arrow draw(const std::string &sourceName, const std::string &targetName, const core::Pose &source, const core::Pose &target) const
Definition: Visu.cpp:78
armarx::navigation::qt_plugins::location_graph_editor::VertexVisu::Pose::draw
viz::Pose draw(const std::string &name, const core::Pose &pose, const VertexData &attribs) const
Definition: Visu.cpp:38
armarx::viz::Layer::add
void add(ElementT const &element)
Definition: Layer.h:29
armarx::navigation::graph::VertexVisu::ForwardArrow::draw
viz::Arrow draw(const std::string &name, const core::Pose &pose) const
Definition: Visu.cpp:42
armarx::navigation::qt_plugins::location_graph_editor::VertexVisu::Pose::scaleFactorHighlighted
float scaleFactorHighlighted
Definition: Visu.h:46
armarx::navigation::qt_plugins::location_graph_editor::VertexData
The NodeData struct holds data required for the node.
Definition: GuiGraph.h:43
Color
uint32_t Color
RGBA color.
Definition: color.h:8
LocationUtils.h
armarx::viz::Arrow::width
Arrow & width(float w)
Definition: Elements.h:211
armarx::viz::Pose
Definition: Elements.h:179
armarx::navigation::qt_plugins::location_graph_editor
Definition: GuiGraph.cpp:29
armarx::navigation::qt_plugins::location_graph_editor::VertexVisu::draw
void draw(viz::Layer &layer, GuiGraph::ConstVertex vertex, graph::visu::ObjectParserInfo info) const
Definition: Visu.cpp:66
Visu.h
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:681
armarx::navigation::graph::VertexVisu::Pose::scale
float scale
Definition: Visu.h:56
armarx::navigation::qt_plugins::location_graph_editor::EdgeData::highlighted
bool highlighted
Whether the edge is highlighted.
Definition: GuiGraph.h:68
armarx::navigation::graph::VertexVisu::Pose::draw
viz::Pose draw(const std::string &name, const core::Pose &pose) const
Definition: Visu.cpp:36
armarx::navigation::qt_plugins::location_graph_editor::EdgeVisu::draw
void draw(viz::Layer &layer, GuiGraph::ConstEdge edge, graph::visu::ObjectParserInfo info) const
Definition: Visu.cpp:111
armarx::navigation::qt_plugins::location_graph_editor::VertexVisu::pose
std::optional< Pose > pose
Definition: Visu.h:52
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
armarx::navigation::qt_plugins::location_graph_editor::VertexVisu::ForwardArrow::draw
viz::Arrow draw(const std::string &name, const core::Pose &pose, const VertexData &attribs) const
Definition: Visu.cpp:51
armarx::navigation::qt_plugins::location_graph_editor::visu::defaultColorHighlighted
const simox::Color defaultColorHighlighted
Definition: Visu.cpp:35
armarx::viz::ElementOps::scale
DerivedT & scale(Eigen::Vector3f scale)
Definition: ElementOps.h:227
armarx::navigation::graph::visu::ObjectParserInfo::objects
const objpose::ObjectPoseMap & objects
Definition: Visu.h:46
armarx::viz::ElementOps::color
DerivedT & color(Color color)
Definition: ElementOps.h:195
armarx::navigation::qt_plugins::location_graph_editor::GuiGraph
Definition: GuiGraph.h:77
armarx::navigation::graph::visu::ObjectParserInfo
Definition: Visu.h:44
armarx::viz::Layer
Definition: Layer.h:12
armarx::orange
QColor orange()
Definition: StyleSheets.h:80
armarx::navigation::qt_plugins::location_graph_editor::VertexData::highlighted
bool highlighted
Whether the node is highlighted.
Definition: GuiGraph.h:49