GuiGraph.h
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 #pragma once
23 
24 #include <map>
25 #include <optional>
26 
28 
29 #include <SemanticObjectRelations/RelationGraph/RelationGraph.h>
30 
31 
32 class QGraphicsEllipseItem;
33 class QGraphicsLineItem;
34 class QTableWidgetItem;
35 
37 {
38 
39  /**
40  * @brief The NodeData struct holds data required for the node.
41  * The name is stored in the key used in the map vertices.
42  */
44  {
45  /// The item in the table tableWidgetVertices.
46  QTableWidgetItem* tableWidgetItem = nullptr;
47 
48  /// Whether the node is highlighted.
49  bool highlighted = false;
50 
51  /// Whether the vertex was changed since loading or committing.
52  bool changed = false;
53  };
54 
55  /**
56  * @brief The EdgeData struct holds data required for the edge.
57  * The name is stored in the key used in the map edges.
58  */
60  {
61  /// The line in the scene.
62  QGraphicsLineItem* graphicsItem = nullptr;
63 
64  /// The item in the table tableWidgetEdges.
65  QTableWidgetItem* tableWidgetItem = nullptr;
66 
67  /// Whether the edge is highlighted.
68  bool highlighted = false;
69  };
70 
72  {
73  /// Whether the graph structure was changed since loading or committing.
74  bool edgesChanged = false;
75  };
76 
77  class GuiGraph : public semrel::RelationGraph<VertexData, EdgeData, GraphData>
78  {
79  public:
80  using RelationGraph::RelationGraph;
81 
82 
83  bool hasChanged() const;
84 
85  std::optional<Vertex> getVertexFromTableItem(QTableWidgetItem* item);
86 
87  std::map<QTableWidgetItem*, Vertex> getTableItemToVertexMap();
88  std::map<QTableWidgetItem*, Edge> getTableItemToEdgeMap();
89  };
90 
91  GuiGraph toGuiGraph(const core::Graph& graph);
92  core::Graph fromGuiGraph(const GuiGraph& graph);
93 
94 
95  float getYawAngleDegree(const core::Pose& pose);
96  double getYawAngleDegree(const core::Pose_d& pose);
97 
98 } // namespace armarx::navigation::qt_plugins::location_graph_editor
armarx::navigation::qt_plugins::location_graph_editor::GuiGraph::getVertexFromTableItem
std::optional< Vertex > getVertexFromTableItem(QTableWidgetItem *item)
Definition: GuiGraph.cpp:50
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
armarx::navigation::qt_plugins::location_graph_editor::VertexData::tableWidgetItem
QTableWidgetItem * tableWidgetItem
The item in the table tableWidgetVertices.
Definition: GuiGraph.h:46
armarx::navigation::core::GraphAttribs
Definition: Graph.h:84
semrel::RelationGraph
Definition: forward_declarations.h:28
armarx::navigation::qt_plugins::location_graph_editor::EdgeData
The EdgeData struct holds data required for the edge.
Definition: GuiGraph.h:59
armarx::navigation::core::Pose_d
Eigen::Isometry3d Pose_d
Definition: basic_types.h:32
armarx::navigation::qt_plugins::location_graph_editor::fromGuiGraph
navigation::core::Graph fromGuiGraph(const GuiGraph &gui)
Definition: GuiGraph.cpp:127
armarx::navigation::qt_plugins::location_graph_editor::getYawAngleDegree
float getYawAngleDegree(const core::Pose &pose)
Definition: GuiGraph.cpp:97
armarx::navigation::qt_plugins::location_graph_editor::GraphData
Definition: GuiGraph.h:71
armarx::navigation::qt_plugins::location_graph_editor::EdgeData::tableWidgetItem
QTableWidgetItem * tableWidgetItem
The item in the table tableWidgetEdges.
Definition: GuiGraph.h:65
armarx::navigation::qt_plugins::location_graph_editor::VertexData
The NodeData struct holds data required for the node.
Definition: GuiGraph.h:43
armarx::navigation::qt_plugins::location_graph_editor::GuiGraph::hasChanged
bool hasChanged() const
Definition: GuiGraph.cpp:33
armarx::navigation::qt_plugins::location_graph_editor::VertexData::changed
bool changed
Whether the vertex was changed since loading or committing.
Definition: GuiGraph.h:52
armarx::navigation::qt_plugins::location_graph_editor::toGuiGraph
auto toGuiGraph(const core::Graph &nav) -> GuiGraph
Definition: GuiGraph.cpp:111
armarx::navigation::core::Graph
Definition: Graph.h:88
armarx::navigation::qt_plugins::location_graph_editor::GraphData::edgesChanged
bool edgesChanged
Whether the graph structure was changed since loading or committing.
Definition: GuiGraph.h:74
armarx::navigation::qt_plugins::location_graph_editor::EdgeData::graphicsItem
QGraphicsLineItem * graphicsItem
The line in the scene.
Definition: GuiGraph.h:62
armarx::navigation::qt_plugins::location_graph_editor
Definition: GuiGraph.cpp:29
armarx::navigation::qt_plugins::location_graph_editor::GuiGraph::getTableItemToEdgeMap
std::map< QTableWidgetItem *, Edge > getTableItemToEdgeMap()
Definition: GuiGraph.cpp:81
armarx::navigation::core::EdgeAttribs
Definition: Graph.h:60
armarx::navigation::qt_plugins::location_graph_editor::EdgeData::highlighted
bool highlighted
Whether the edge is highlighted.
Definition: GuiGraph.h:68
Graph.h
armarx::navigation::core::VertexAttribs
Definition: Graph.h:43
armarx::navigation::qt_plugins::location_graph_editor::GuiGraph
Definition: GuiGraph.h:77
armarx::navigation::qt_plugins::location_graph_editor::GuiGraph::getTableItemToVertexMap
std::map< QTableWidgetItem *, Vertex > getTableItemToVertexMap()
Definition: GuiGraph.cpp:64
armarx::navigation::qt_plugins::location_graph_editor::VertexData::highlighted
bool highlighted
Whether the node is highlighted.
Definition: GuiGraph.h:49