GuiGraph.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
* @package MemoryX::ArmarXObjects::GraphImportExport
17
* @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18
* @date 2021
19
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20
* GNU General Public License
21
*/
22
23
#include "
GuiGraph.h
"
24
25
#include <map>
26
#include <optional>
27
28
#include <SimoxUtility/math/convert/mat4f_to_rpy.h>
29
#include <SimoxUtility/math/convert/rad_to_deg.h>
30
31
#include <
armarx/navigation/core/Graph.h
>
32
#include <
armarx/navigation/core/basic_types.h
>
33
34
namespace
armarx::navigation::qt_plugins::location_graph_editor
35
{
36
37
bool
38
GuiGraph::hasChanged
()
const
39
{
40
if
(attrib().edgesChanged)
41
{
42
return
true
;
43
}
44
for
(
auto
vertex : vertices())
45
{
46
if
(vertex.attrib().changed)
47
{
48
return
true
;
49
}
50
}
51
return
false
;
52
}
53
54
std::optional<GuiGraph::Vertex>
55
GuiGraph::getVertexFromTableItem
(QTableWidgetItem* item)
56
{
57
for
(
auto
vertex : vertices())
58
{
59
if
(vertex.attrib().tableWidgetItem == item)
60
{
61
return
vertex;
62
}
63
}
64
return
std::nullopt;
65
}
66
67
std::map<QTableWidgetItem*, GuiGraph::Vertex>
68
GuiGraph::getTableItemToVertexMap
()
69
{
70
std::map<QTableWidgetItem*, GuiGraph::Vertex> map;
71
72
for
(
auto
vertex : vertices())
73
{
74
if
(vertex.attrib().tableWidgetItem !=
nullptr
)
75
{
76
map[vertex.attrib().tableWidgetItem] = vertex;
77
}
78
}
79
80
return
map;
81
}
82
83
std::map<QTableWidgetItem*, GuiGraph::Edge>
84
GuiGraph::getTableItemToEdgeMap
()
85
{
86
std::map<QTableWidgetItem*, GuiGraph::Edge> map;
87
88
for
(
auto
edge : edges())
89
{
90
if
(edge.attrib().tableWidgetItem !=
nullptr
)
91
{
92
map[edge.attrib().tableWidgetItem] = edge;
93
}
94
}
95
96
return
map;
97
}
98
99
float
100
getYawAngleDegree
(
const
core::Pose
& pose)
101
{
102
return
simox::math::rad_to_deg(simox::math::mat4f_to_rpy(pose.matrix())(2));
103
}
104
105
double
106
getYawAngleDegree
(
const
core::Pose_d
& pose)
107
{
108
return
simox::math::rad_to_deg(simox::math::mat4f_to_rpy(pose.matrix())(2));
109
}
110
111
auto
112
toGuiGraph
(
const
core::Graph
&
nav
) ->
GuiGraph
113
{
114
GuiGraph
gui
;
115
for
(
auto
v :
nav
.vertices())
116
{
117
gui
.addVertex(v.objectID(), {v.attrib()});
118
}
119
for
(
auto
e :
nav
.edges())
120
{
121
gui
.addEdge(e.sourceObjectID(), e.targetObjectID(), {e.attrib()});
122
}
123
return
gui
;
124
}
125
126
navigation::core::Graph
127
fromGuiGraph
(
const
GuiGraph
&
gui
)
128
{
129
core::Graph
nav
;
130
for
(
auto
v :
gui
.vertices())
131
{
132
nav
.addVertex(v.objectID(), {v.attrib()});
133
}
134
for
(
auto
e :
gui
.edges())
135
{
136
nav
.addEdge(e.sourceObjectID(), e.targetObjectID(), {e.attrib()});
137
}
138
return
nav
;
139
}
140
141
}
// namespace armarx::navigation::qt_plugins::location_graph_editor
Graph.h
GuiGraph.h
basic_types.h
armarx::navigation::core::Graph
Definition
Graph.h:94
armarx::navigation::qt_plugins::location_graph_editor::GuiGraph
Definition
GuiGraph.h:79
armarx::navigation::qt_plugins::location_graph_editor::GuiGraph::hasChanged
bool hasChanged() const
Definition
GuiGraph.cpp:38
armarx::navigation::qt_plugins::location_graph_editor::GuiGraph::getTableItemToEdgeMap
std::map< QTableWidgetItem *, Edge > getTableItemToEdgeMap()
Definition
GuiGraph.cpp:84
armarx::navigation::qt_plugins::location_graph_editor::GuiGraph::getVertexFromTableItem
std::optional< Vertex > getVertexFromTableItem(QTableWidgetItem *item)
Definition
GuiGraph.cpp:55
armarx::navigation::qt_plugins::location_graph_editor::GuiGraph::getTableItemToVertexMap
std::map< QTableWidgetItem *, Vertex > getTableItemToVertexMap()
Definition
GuiGraph.cpp:68
armarx::nav
Definition
client.h:7
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition
basic_types.h:31
armarx::navigation::core::Pose_d
Eigen::Isometry3d Pose_d
Definition
basic_types.h:32
armarx::navigation::qt_plugins::location_graph_editor
Definition
GuiGraph.cpp:35
armarx::navigation::qt_plugins::location_graph_editor::getYawAngleDegree
float getYawAngleDegree(const core::Pose &pose)
Definition
GuiGraph.cpp:100
armarx::navigation::qt_plugins::location_graph_editor::toGuiGraph
auto toGuiGraph(const core::Graph &nav) -> GuiGraph
Definition
GuiGraph.cpp:112
armarx::navigation::qt_plugins::location_graph_editor::fromGuiGraph
navigation::core::Graph fromGuiGraph(const GuiGraph &gui)
Definition
GuiGraph.cpp:127
gui
Definition
ClearableLineEdit.h:32
armarx
navigation
gui-plugins
LocationGraphEditor
GuiGraph.cpp
Generated by
1.13.2