GraphViewer.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef RTABMAP_GRAPHVIEWER_H_
29 #define RTABMAP_GRAPHVIEWER_H_
30 
31 #include "rtabmap/gui/RtabmapGuiExp.h" // DLL export/import defines
32 
33 #include <QGraphicsView>
34 #include <QtCore/QMap>
35 #include <QtCore/QSettings>
36 #include <rtabmap/core/Link.h>
37 #include <rtabmap/core/GPS.h>
38 #include <opencv2/opencv.hpp>
39 #include <map>
40 #include <vector>
41 
42 class QGraphicsItem;
43 class QGraphicsPixmapItem;
44 class QGraphicsItemGroup;
45 
46 namespace rtabmap {
47 
48 class NodeItem;
49 class LinkItem;
50 
51 class RTABMAPGUI_EXP GraphViewer : public QGraphicsView {
52 
53  Q_OBJECT;
54 
55 public:
56  GraphViewer(QWidget * parent = 0);
57  virtual ~GraphViewer();
58 
59  void setWorldMapRotation(const float & theta);
60  float getWorldMapRotation() const {return _worldMapRotation;}
61 
62  void updateGraph(const std::map<int, Transform> & poses,
63  const std::multimap<int, Link> & constraints,
64  const std::map<int, int> & mapIds,
65  const std::map<int, int> & weights = std::map<int, int>());
66  void updateGTGraph(const std::map<int, Transform> & poses);
67  void updateGPSGraph(
68  const std::map<int, Transform> & gpsMapPoses,
69  const std::map<int, GPS> & gpsValues);
70  void updateReferentialPosition(const Transform & t);
71  void updateMap(const cv::Mat & map8U, float resolution, float xMin, float yMin);
72  void updatePosterior(const std::map<int, float> & posterior, float fixedMax = 0.0f, int zValueOffset = 0);
73  void updateLocalPath(const std::vector<int> & localPath);
74  void setGlobalPath(const std::vector<std::pair<int, Transform> > & globalPath);
75  void setCurrentGoalID(int id, const Transform & pose = Transform());
76  void setLocalRadius(float radius);
77  void clearGraph();
78  void clearMap();
79  void clearPosterior();
80  void clearAll();
81 
82  void saveSettings(QSettings & settings, const QString & group = "") const;
83  void loadSettings(QSettings & settings, const QString & group = "");
84 
85  //getters
86  const QString & getWorkingDirectory() const {return _workingDirectory;}
87  float getNodeRadius() const {return _nodeRadius;}
88  float getLinkWidth() const {return _linkWidth;}
89  const QColor & getNodeColor() const {return _nodeColor;}
90  const QColor & getCurrentGoalColor() const {return _currentGoalColor;}
91  const QColor & getNeighborColor() const {return _neighborColor;}
92  const QColor & getGlobalLoopClosureColor() const {return _loopClosureColor;}
93  const QColor & getLocalLoopClosureColor() const {return _loopClosureLocalColor;}
94  const QColor & getUserLoopClosureColor() const {return _loopClosureUserColor;}
95  const QColor & getVirtualLoopClosureColor() const {return _loopClosureVirtualColor;}
96  const QColor & getNeighborMergedColor() const {return _neighborMergedColor;}
97  const QColor & getRejectedLoopClosureColor() const {return _loopClosureRejectedColor;}
98  const QColor & getLocalPathColor() const {return _localPathColor;}
99  const QColor & getGlobalPathColor() const {return _globalPathColor;}
100  const QColor & getGTColor() const {return _gtPathColor;}
101  const QColor & getGPSColor() const {return _gpsPathColor;}
102  const QColor & getIntraSessionLoopColor() const {return _loopIntraSessionColor;}
103  const QColor & getInterSessionLoopColor() const {return _loopInterSessionColor;}
104  bool isIntraInterSessionColorsEnabled() const {return _intraInterSessionColors;}
105  bool isGridMapVisible() const;
106  bool isOriginVisible() const;
107  bool isReferentialVisible() const;
108  bool isLocalRadiusVisible() const;
109  float getLoopClosureOutlierThr() const {return _loopClosureOutlierThr;}
110  float getMaxLinkLength() const {return _maxLinkLength;}
111  bool isGraphVisible() const;
112  bool isGlobalPathVisible() const;
113  bool isLocalPathVisible() const;
114  bool isGtGraphVisible() const;
115  bool isGPSGraphVisible() const;
116  bool isOrientationENU() const;
117 
118  // setters
119  void setWorkingDirectory(const QString & path);
120  void setNodeVisible(bool visible);
121  void setNodeRadius(float radius);
122  void setLinkWidth(float width);
123  void setNodeColor(const QColor & color);
124  void setCurrentGoalColor(const QColor & color);
125  void setNeighborColor(const QColor & color);
126  void setGlobalLoopClosureColor(const QColor & color);
127  void setLocalLoopClosureColor(const QColor & color);
128  void setUserLoopClosureColor(const QColor & color);
129  void setVirtualLoopClosureColor(const QColor & color);
130  void setNeighborMergedColor(const QColor & color);
131  void setLandmarkColor(const QColor & color);
132  void setRejectedLoopClosureColor(const QColor & color);
133  void setLocalPathColor(const QColor & color);
134  void setGlobalPathColor(const QColor & color);
135  void setGTColor(const QColor & color);
136  void setGPSColor(const QColor & color);
137  void setIntraSessionLoopColor(const QColor & color);
138  void setInterSessionLoopColor(const QColor & color);
139  void setIntraInterSessionColorsEnabled(bool enabled);
140  void setGridMapVisible(bool visible);
141  void setOriginVisible(bool visible);
142  void setReferentialVisible(bool visible);
143  void setLocalRadiusVisible(bool visible);
144  void setLoopClosureOutlierThr(float value);
145  void setMaxLinkLength(float value);
146  void setGraphVisible(bool visible);
147  void setGlobalPathVisible(bool visible);
148  void setLocalPathVisible(bool visible);
149  void setGtGraphVisible(bool visible);
150  void setGPSGraphVisible(bool visible);
151  void setOrientationENU(bool enabled);
152 
153 Q_SIGNALS:
154  void configChanged();
155  void mapShownRequested();
156 
157 public Q_SLOTS:
158  void restoreDefaults();
159 
160 protected:
161  virtual void wheelEvent ( QWheelEvent * event );
162  virtual void contextMenuEvent(QContextMenuEvent * event);
163 
164 private:
166  QColor _nodeColor;
178  QColor _gtPathColor;
184  QGraphicsItem * _world;
185  QGraphicsItem * _root;
186  QGraphicsItem * _graphRoot;
187  QGraphicsItem * _globalPathRoot;
188  QGraphicsItem * _localPathRoot;
189  QGraphicsItem * _gtGraphRoot;
190  QGraphicsItem * _gpsGraphRoot;
191  QMap<int, NodeItem*> _nodeItems;
192  QMultiMap<int, LinkItem*> _linkItems;
193  QMap<int, NodeItem*> _gtNodeItems;
194  QMap<int, NodeItem*> _gpsNodeItems;
195  QMultiMap<int, LinkItem*> _gtLinkItems;
196  QMultiMap<int, LinkItem*> _gpsLinkItems;
197  QMultiMap<int, LinkItem*> _localPathLinkItems;
198  QMultiMap<int, LinkItem*> _globalPathLinkItems;
200  float _nodeRadius;
201  float _linkWidth;
202  QGraphicsPixmapItem * _gridMap;
203  QGraphicsItemGroup * _referential;
204  QGraphicsItemGroup * _originReferential;
206  QGraphicsEllipseItem * _localRadius;
210 };
211 
212 } /* namespace rtabmap */
213 #endif /* GRAPHVIEWER_H_ */
#define RTABMAPGUI_EXP
Definition: RtabmapGuiExp.h:38
QGraphicsItem * _gpsGraphRoot
Definition: GraphViewer.h:190
QColor _loopClosureLocalColor
Definition: GraphViewer.h:170
QColor _loopClosureVirtualColor
Definition: GraphViewer.h:172
const QColor & getVirtualLoopClosureColor() const
Definition: GraphViewer.h:95
float getLinkWidth() const
Definition: GraphViewer.h:88
QGraphicsItem * _localPathRoot
Definition: GraphViewer.h:188
const QColor & getInterSessionLoopColor() const
Definition: GraphViewer.h:103
QGraphicsEllipseItem * _localRadius
Definition: GraphViewer.h:206
QGraphicsItemGroup * _referential
Definition: GraphViewer.h:203
f
const QString & getWorkingDirectory() const
Definition: GraphViewer.h:86
const QColor & getGPSColor() const
Definition: GraphViewer.h:101
const QColor & getRejectedLoopClosureColor() const
Definition: GraphViewer.h:97
float getNodeRadius() const
Definition: GraphViewer.h:87
QGraphicsPixmapItem * _gridMap
Definition: GraphViewer.h:202
QMultiMap< int, LinkItem * > _gpsLinkItems
Definition: GraphViewer.h:196
QGraphicsItem * _graphRoot
Definition: GraphViewer.h:186
QGraphicsItem * _root
Definition: GraphViewer.h:185
const QColor & getGlobalLoopClosureColor() const
Definition: GraphViewer.h:92
QColor _loopInterSessionColor
Definition: GraphViewer.h:181
const QColor & getGlobalPathColor() const
Definition: GraphViewer.h:99
const QColor & getLocalPathColor() const
Definition: GraphViewer.h:98
QColor _loopClosureRejectedColor
Definition: GraphViewer.h:175
float getLoopClosureOutlierThr() const
Definition: GraphViewer.h:109
QColor _loopIntraSessionColor
Definition: GraphViewer.h:180
QMultiMap< int, LinkItem * > _globalPathLinkItems
Definition: GraphViewer.h:198
QGraphicsItemGroup * _originReferential
Definition: GraphViewer.h:204
const QColor & getNodeColor() const
Definition: GraphViewer.h:89
float getMaxLinkLength() const
Definition: GraphViewer.h:110
QMultiMap< int, LinkItem * > _gtLinkItems
Definition: GraphViewer.h:195
const QColor & getIntraSessionLoopColor() const
Definition: GraphViewer.h:102
QGraphicsItem * _gtGraphRoot
Definition: GraphViewer.h:189
const QColor & getLocalLoopClosureColor() const
Definition: GraphViewer.h:93
const QColor & getCurrentGoalColor() const
Definition: GraphViewer.h:90
QMultiMap< int, LinkItem * > _localPathLinkItems
Definition: GraphViewer.h:197
bool isIntraInterSessionColorsEnabled() const
Definition: GraphViewer.h:104
QGraphicsItem * _globalPathRoot
Definition: GraphViewer.h:187
QMap< int, NodeItem * > _gpsNodeItems
Definition: GraphViewer.h:194
QColor _loopClosureUserColor
Definition: GraphViewer.h:171
const QColor & getUserLoopClosureColor() const
Definition: GraphViewer.h:94
QMultiMap< int, LinkItem * > _linkItems
Definition: GraphViewer.h:192
QGraphicsItem * _world
Definition: GraphViewer.h:184
const QColor & getNeighborMergedColor() const
Definition: GraphViewer.h:96
float getWorldMapRotation() const
Definition: GraphViewer.h:60
const QColor & getGTColor() const
Definition: GraphViewer.h:100
QMap< int, NodeItem * > _nodeItems
Definition: GraphViewer.h:191
QMap< int, NodeItem * > _gtNodeItems
Definition: GraphViewer.h:193
const QColor & getNeighborColor() const
Definition: GraphViewer.h:91


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:34:59