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 <set>
41 #include <vector>
42 
43 class QGraphicsItem;
44 class QGraphicsPixmapItem;
45 class QGraphicsItemGroup;
46 
47 namespace rtabmap {
48 
49 class NodeItem;
50 class LinkItem;
51 
52 class RTABMAPGUI_EXP GraphViewer : public QGraphicsView {
53 
54  Q_OBJECT;
55 
56 public:
57  enum ViewPlane {XY, XZ, YZ};
58 
59 public:
60  GraphViewer(QWidget * parent = 0);
61  virtual ~GraphViewer();
62 
63  void setWorldMapRotation(const float & theta);
64  float getWorldMapRotation() const {return _worldMapRotation;}
65 
66  void updateGraph(const std::map<int, Transform> & poses,
67  const std::multimap<int, Link> & constraints,
68  const std::map<int, int> & mapIds,
69  const std::map<int, int> & weights = std::map<int, int>(),
70  const std::set<int> & odomCacheIds = std::set<int>());
71  void updateGTGraph(const std::map<int, Transform> & poses);
72  void updateGPSGraph(
73  const std::map<int, Transform> & gpsMapPoses,
74  const std::map<int, GPS> & gpsValues);
75  void updateReferentialPosition(const Transform & t);
76  void updateMap(const cv::Mat & map8U, float resolution, float xMin, float yMin);
77  void updatePosterior(const std::map<int, float> & posterior, float fixedMax = 0.0f, int zValueOffset = 0);
78  void updateLocalPath(const std::vector<int> & localPath);
79  void setGlobalPath(const std::vector<std::pair<int, Transform> > & globalPath);
80  void setCurrentGoalID(int id, const Transform & pose = Transform());
81  void setLocalRadius(float radius);
82  void clearGraph();
83  void clearMap();
84  void clearPosterior();
85  void clearAll();
86 
87  void saveSettings(QSettings & settings, const QString & group = "") const;
88  void loadSettings(QSettings & settings, const QString & group = "");
89 
90  //getters
91  const QString & getWorkingDirectory() const {return _workingDirectory;}
92  float getNodeRadius() const {return _nodeRadius;}
93  float getLinkWidth() const {return _linkWidth;}
94  const QColor & getNodeColor() const {return _nodeColor;}
95  const QColor & getNodeOdomCacheColor() const {return _nodeOdomCacheColor;}
96  const QColor & getCurrentGoalColor() const {return _currentGoalColor;}
97  const QColor & getNeighborColor() const {return _neighborColor;}
98  const QColor & getGlobalLoopClosureColor() const {return _loopClosureColor;}
99  const QColor & getLocalLoopClosureColor() const {return _loopClosureLocalColor;}
100  const QColor & getUserLoopClosureColor() const {return _loopClosureUserColor;}
101  const QColor & getVirtualLoopClosureColor() const {return _loopClosureVirtualColor;}
102  const QColor & getNeighborMergedColor() const {return _neighborMergedColor;}
103  const QColor & getRejectedLoopClosureColor() const {return _loopClosureRejectedColor;}
104  const QColor & getLocalPathColor() const {return _localPathColor;}
105  const QColor & getGlobalPathColor() const {return _globalPathColor;}
106  const QColor & getGTColor() const {return _gtPathColor;}
107  const QColor & getGPSColor() const {return _gpsPathColor;}
108  const QColor & getIntraSessionLoopColor() const {return _loopIntraSessionColor;}
109  const QColor & getInterSessionLoopColor() const {return _loopInterSessionColor;}
110  bool isIntraInterSessionColorsEnabled() const {return _intraInterSessionColors;}
111  bool isGridMapVisible() const;
112  bool isOriginVisible() const;
113  bool isReferentialVisible() const;
114  bool isLocalRadiusVisible() const;
115  float getLoopClosureOutlierThr() const {return _loopClosureOutlierThr;}
116  float getMaxLinkLength() const {return _maxLinkLength;}
117  bool isGraphVisible() const;
118  bool isGlobalPathVisible() const;
119  bool isLocalPathVisible() const;
120  bool isGtGraphVisible() const;
121  bool isGPSGraphVisible() const;
122  bool isOdomCacheOverlayVisible() const;
123  bool isOrientationENU() const;
124  ViewPlane getViewPlane() const;
125  bool isEnsureFrameVisible() const;
126 
127  // setters
128  void setWorkingDirectory(const QString & path);
129  void setNodeVisible(bool visible);
130  void setNodeRadius(float radius);
131  void setLinkWidth(float width);
132  void setNodeColor(const QColor & color);
133  void setNodeOdomCacheColor(const QColor & color);
134  void setCurrentGoalColor(const QColor & color);
135  void setNeighborColor(const QColor & color);
136  void setGlobalLoopClosureColor(const QColor & color);
137  void setLocalLoopClosureColor(const QColor & color);
138  void setUserLoopClosureColor(const QColor & color);
139  void setVirtualLoopClosureColor(const QColor & color);
140  void setNeighborMergedColor(const QColor & color);
141  void setLandmarkColor(const QColor & color);
142  void setRejectedLoopClosureColor(const QColor & color);
143  void setLocalPathColor(const QColor & color);
144  void setGlobalPathColor(const QColor & color);
145  void setGTColor(const QColor & color);
146  void setGPSColor(const QColor & color);
147  void setIntraSessionLoopColor(const QColor & color);
148  void setInterSessionLoopColor(const QColor & color);
149  void setIntraInterSessionColorsEnabled(bool enabled);
150  void setGridMapVisible(bool visible);
151  void setOriginVisible(bool visible);
152  void setReferentialVisible(bool visible);
153  void setLocalRadiusVisible(bool visible);
154  void setLoopClosureOutlierThr(float value);
155  void setMaxLinkLength(float value);
156  void setGraphVisible(bool visible);
157  void setGlobalPathVisible(bool visible);
158  void setLocalPathVisible(bool visible);
159  void setGtGraphVisible(bool visible);
160  void setGPSGraphVisible(bool visible);
161  void setOdomCacheOverlayVisible(bool visible);
162  void setOrientationENU(bool enabled);
163  void setViewPlane(ViewPlane plane);
164  void setEnsureFrameVisible(bool visible);
165 
166 Q_SIGNALS:
167  void configChanged();
168  void mapShownRequested();
169 
170 public Q_SLOTS:
171  void restoreDefaults();
172 
173 protected:
174  virtual void wheelEvent ( QWheelEvent * event );
175  virtual void contextMenuEvent(QContextMenuEvent * event);
176 
177 private:
179  QColor _nodeColor;
192  QColor _gtPathColor;
198  QGraphicsItem * _world;
199  QGraphicsItem * _root;
200  QGraphicsItem * _graphRoot;
201  QGraphicsItem * _globalPathRoot;
202  QGraphicsItem * _localPathRoot;
203  QGraphicsItem * _gtGraphRoot;
204  QGraphicsItem * _gpsGraphRoot;
205  QMap<int, NodeItem*> _nodeItems;
206  QMultiMap<int, LinkItem*> _linkItems;
207  QMap<int, NodeItem*> _gtNodeItems;
208  QMap<int, NodeItem*> _gpsNodeItems;
209  QMultiMap<int, LinkItem*> _gtLinkItems;
210  QMultiMap<int, LinkItem*> _gpsLinkItems;
211  QMultiMap<int, LinkItem*> _localPathLinkItems;
212  QMultiMap<int, LinkItem*> _globalPathLinkItems;
214  float _nodeRadius;
215  float _linkWidth;
216  QGraphicsPixmapItem * _gridMap;
217  QGraphicsItemGroup * _referential;
218  QGraphicsItemGroup * _referentialXY;
219  QGraphicsItemGroup * _referentialXZ;
220  QGraphicsItemGroup * _referentialYZ;
221  QGraphicsItemGroup * _originReferential;
222  QGraphicsItemGroup * _originReferentialXY;
223  QGraphicsItemGroup * _originReferentialXZ;
224  QGraphicsItemGroup * _originReferentialYZ;
226  QGraphicsEllipseItem * _localRadius;
227  QGraphicsRectItem * _odomCacheOverlay;
233 };
234 
235 } /* namespace rtabmap */
236 #endif /* GRAPHVIEWER_H_ */
#define RTABMAPGUI_EXP
Definition: RtabmapGuiExp.h:38
QGraphicsItem * _gpsGraphRoot
Definition: GraphViewer.h:204
QColor _loopClosureLocalColor
Definition: GraphViewer.h:184
const QColor & getLocalPathColor() const
Definition: GraphViewer.h:104
QColor _loopClosureVirtualColor
Definition: GraphViewer.h:186
QGraphicsItem * _localPathRoot
Definition: GraphViewer.h:202
const QColor & getIntraSessionLoopColor() const
Definition: GraphViewer.h:108
QGraphicsEllipseItem * _localRadius
Definition: GraphViewer.h:226
QGraphicsItemGroup * _referential
Definition: GraphViewer.h:217
f
const QColor & getLocalLoopClosureColor() const
Definition: GraphViewer.h:99
const QColor & getCurrentGoalColor() const
Definition: GraphViewer.h:96
float getMaxLinkLength() const
Definition: GraphViewer.h:116
QGraphicsPixmapItem * _gridMap
Definition: GraphViewer.h:216
QMultiMap< int, LinkItem * > _gpsLinkItems
Definition: GraphViewer.h:210
QGraphicsItem * _graphRoot
Definition: GraphViewer.h:200
QGraphicsItem * _root
Definition: GraphViewer.h:199
const QColor & getGlobalPathColor() const
Definition: GraphViewer.h:105
const QColor & getGPSColor() const
Definition: GraphViewer.h:107
QGraphicsItemGroup * _referentialXY
Definition: GraphViewer.h:218
const QColor & getInterSessionLoopColor() const
Definition: GraphViewer.h:109
float getNodeRadius() const
Definition: GraphViewer.h:92
QColor _loopInterSessionColor
Definition: GraphViewer.h:195
const QColor & getRejectedLoopClosureColor() const
Definition: GraphViewer.h:103
QColor _loopClosureRejectedColor
Definition: GraphViewer.h:189
QColor _loopIntraSessionColor
Definition: GraphViewer.h:194
const QColor & getNodeOdomCacheColor() const
Definition: GraphViewer.h:95
QMultiMap< int, LinkItem * > _globalPathLinkItems
Definition: GraphViewer.h:212
float getLinkWidth() const
Definition: GraphViewer.h:93
QGraphicsItemGroup * _originReferential
Definition: GraphViewer.h:221
const QColor & getUserLoopClosureColor() const
Definition: GraphViewer.h:100
const QColor & getNeighborMergedColor() const
Definition: GraphViewer.h:102
const QColor & getNodeColor() const
Definition: GraphViewer.h:94
QMultiMap< int, LinkItem * > _gtLinkItems
Definition: GraphViewer.h:209
QGraphicsItem * _gtGraphRoot
Definition: GraphViewer.h:203
const QString & getWorkingDirectory() const
Definition: GraphViewer.h:91
QGraphicsItemGroup * _originReferentialXZ
Definition: GraphViewer.h:223
const QColor & getNeighborColor() const
Definition: GraphViewer.h:97
float getWorldMapRotation() const
Definition: GraphViewer.h:64
QMultiMap< int, LinkItem * > _localPathLinkItems
Definition: GraphViewer.h:211
QGraphicsItem * _globalPathRoot
Definition: GraphViewer.h:201
QMap< int, NodeItem * > _gpsNodeItems
Definition: GraphViewer.h:208
QColor _loopClosureUserColor
Definition: GraphViewer.h:185
const QColor & getGlobalLoopClosureColor() const
Definition: GraphViewer.h:98
QMultiMap< int, LinkItem * > _linkItems
Definition: GraphViewer.h:206
QGraphicsItemGroup * _referentialXZ
Definition: GraphViewer.h:219
QGraphicsItem * _world
Definition: GraphViewer.h:198
bool isIntraInterSessionColorsEnabled() const
Definition: GraphViewer.h:110
QMap< int, NodeItem * > _nodeItems
Definition: GraphViewer.h:205
QMap< int, NodeItem * > _gtNodeItems
Definition: GraphViewer.h:207
const QColor & getVirtualLoopClosureColor() const
Definition: GraphViewer.h:101
QGraphicsItemGroup * _originReferentialYZ
Definition: GraphViewer.h:224
QGraphicsRectItem * _odomCacheOverlay
Definition: GraphViewer.h:227
QGraphicsItemGroup * _originReferentialXY
Definition: GraphViewer.h:222
float getLoopClosureOutlierThr() const
Definition: GraphViewer.h:115
QGraphicsItemGroup * _referentialYZ
Definition: GraphViewer.h:220
const QColor & getGTColor() const
Definition: GraphViewer.h:106


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:28