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 <string>
25
26#include <SimoxUtility/color/Color.h>
27
30
35
37{
38
39 const simox::Color visu::defaultColorHighlighted = simox::Color::orange();
40
42 VertexVisu::Pose::draw(const std::string& name,
43 const core::Pose& pose,
44 const VertexData& attribs) const
45 {
47 if (attribs.highlighted)
48 {
50 }
51 return p;
52 }
53
55 VertexVisu::ForwardArrow::draw(const std::string& name,
56 const core::Pose& pose,
57 const VertexData& attribs) const
58 {
59 viz::Arrow arrow =
61 if (attribs.highlighted)
62 {
64 arrow.width(width * 1.5f);
65 }
66 return arrow;
67 }
68
69 void
71 GuiGraph::ConstVertex vertex,
73 {
74 const auto p = core::resolveLocation(info.objects, info.info, vertex.attrib().getPose());
75 if (p.pose.has_value())
76 {
77 draw(layer, vertex.attrib().getLocationName(), p.pose.value(), vertex.attrib());
78 }
79 }
80
81 void
83 const std::string& name,
84 const core::Pose& pose,
85 const VertexData& attribs) const
86 {
87 if (this->pose.has_value())
88 {
89 layer.add(this->pose->draw(name, pose, attribs));
90 }
91 if (forwardArrow.has_value())
92 {
93 layer.add(forwardArrow->draw(name, pose, attribs));
94 }
95 }
96
99 const std::string& sourceName,
100 const std::string& targetName,
101 const core::Pose& source,
102 const core::Pose& target) const
103 {
105 navigation::graph::EdgeVisu::Arrow::draw(sourceName, targetName, source, target);
106 if (edge.highlighted)
107 {
108 arrow.color(colorHighlighted);
109 arrow.width(width * 1.5f);
110 }
111 return arrow;
112 }
113
114 void
116 GuiGraph::ConstEdge edge,
118 {
119 const auto src =
120 core::resolveLocation(info.objects, info.info, edge.source().attrib().getPose());
121 const auto tar =
122 core::resolveLocation(info.objects, info.info, edge.target().attrib().getPose());
123 if (src.pose.has_value() && tar.pose.has_value() && arrow.has_value())
124 {
125 layer.add(arrow->draw(edge.attrib(),
126 edge.source().attrib().getLocationName(),
127 edge.target().attrib().getLocationName(),
128 src.pose.value(),
129 tar.pose.value()));
130 }
131 }
132
133 void
135 const GuiGraph& graph,
137 {
138 if (vertex.has_value())
139 {
140 for (GuiGraph::ConstVertex v : graph.vertices())
141 {
142 vertex->draw(layer, v, info);
143 }
144 }
145 if (edge.has_value())
146 {
147 for (GuiGraph::ConstEdge e : graph.edges())
148 {
149 edge->draw(layer, e, info);
150 }
151 }
152 }
153
154
155} // namespace armarx::navigation::qt_plugins::location_graph_editor
DerivedT & color(Color color)
Definition ElementOps.h:218
DerivedT & scale(Eigen::Vector3f scale)
Definition ElementOps.h:254
void resolveLocation(Graph::Vertex &vertex, const aron::data::DictPtr &locationData)
Definition Graph.cpp:267
Eigen::Isometry3f Pose
Definition basic_types.h:31
This file is part of ArmarX.
Definition Visu.h:48
std::string getLocationName() const
Definition Graph.cpp:48
viz::Arrow draw(const std::string &sourceName, const std::string &targetName, const core::Pose &source, const core::Pose &target) const
Definition Visu.cpp:80
viz::Arrow draw(const std::string &name, const core::Pose &pose) const
Definition Visu.cpp:44
viz::Pose draw(const std::string &name, const core::Pose &pose) const
Definition Visu.cpp:38
const objpose::ObjectPoseMap & objects
Definition Visu.h:49
const std::vector< ObjectInfo > & info
Definition Visu.h:50
The EdgeData struct holds data required for the edge.
Definition GuiGraph.h:61
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:98
void draw(viz::Layer &layer, GuiGraph::ConstEdge edge, graph::visu::ObjectParserInfo info) const
Definition Visu.cpp:115
void draw(viz::Layer &layer, const GuiGraph &graph, graph::visu::ObjectParserInfo info) const
Definition Visu.cpp:134
The NodeData struct holds data required for the node.
Definition GuiGraph.h:45
viz::Arrow draw(const std::string &name, const core::Pose &pose, const VertexData &attribs) const
Definition Visu.cpp:55
viz::Pose draw(const std::string &name, const core::Pose &pose, const VertexData &attribs) const
Definition Visu.cpp:42
void draw(viz::Layer &layer, GuiGraph::ConstVertex vertex, graph::visu::ObjectParserInfo info) const
Definition Visu.cpp:70
Arrow & width(float w)
Definition Elements.h:211
void add(ElementT const &element)
Definition Layer.h:31