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/rtabmap_gui_export.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 RTABMAP_GUI_EXPORT 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  void nodeSelected(int);
170  void linkSelected(int, int);
171 
172 public Q_SLOTS:
173  void restoreDefaults();
174 
175 protected:
176  virtual void wheelEvent ( QWheelEvent * event );
177  virtual void mouseMoveEvent(QMouseEvent * event);
178  virtual void mouseDoubleClickEvent(QMouseEvent * event);
179  virtual void contextMenuEvent(QContextMenuEvent * event);
180 
181 private:
183  QColor _nodeColor;
196  QColor _gtPathColor;
202  QGraphicsItem * _world;
203  QGraphicsItem * _root;
204  QGraphicsItem * _graphRoot;
205  QGraphicsItem * _globalPathRoot;
206  QGraphicsItem * _localPathRoot;
207  QGraphicsItem * _gtGraphRoot;
208  QGraphicsItem * _gpsGraphRoot;
209  QMap<int, NodeItem*> _nodeItems;
210  QMultiMap<int, LinkItem*> _linkItems;
211  QMap<int, NodeItem*> _gtNodeItems;
212  QMap<int, NodeItem*> _gpsNodeItems;
213  QMultiMap<int, LinkItem*> _gtLinkItems;
214  QMultiMap<int, LinkItem*> _gpsLinkItems;
215  QMultiMap<int, LinkItem*> _localPathLinkItems;
216  QMultiMap<int, LinkItem*> _globalPathLinkItems;
218  float _nodeRadius;
219  float _linkWidth;
220  QGraphicsPixmapItem * _gridMap;
221  QGraphicsItemGroup * _referential;
222  QGraphicsItemGroup * _referentialXY;
223  QGraphicsItemGroup * _referentialXZ;
224  QGraphicsItemGroup * _referentialYZ;
225  QGraphicsItemGroup * _originReferential;
226  QGraphicsItemGroup * _originReferentialXY;
227  QGraphicsItemGroup * _originReferentialXZ;
228  QGraphicsItemGroup * _originReferentialYZ;
230  QGraphicsEllipseItem * _localRadius;
231  QGraphicsRectItem * _odomCacheOverlay;
238 };
239 
240 } /* namespace rtabmap */
241 #endif /* GRAPHVIEWER_H_ */
rtabmap::GraphViewer::getMaxLinkLength
float getMaxLinkLength() const
Definition: GraphViewer.h:116
rtabmap::GraphViewer::_gridMap
QGraphicsPixmapItem * _gridMap
Definition: GraphViewer.h:220
rtabmap::GraphViewer::_worldMapRotation
float _worldMapRotation
Definition: GraphViewer.h:201
rtabmap::GraphViewer::_loopClosureUserColor
QColor _loopClosureUserColor
Definition: GraphViewer.h:189
rtabmap::GraphViewer::_loopInterSessionColor
QColor _loopInterSessionColor
Definition: GraphViewer.h:199
rtabmap::GraphViewer::_gpsLinkItems
QMultiMap< int, LinkItem * > _gpsLinkItems
Definition: GraphViewer.h:214
rtabmap::GraphViewer::getRejectedLoopClosureColor
const QColor & getRejectedLoopClosureColor() const
Definition: GraphViewer.h:103
rtabmap::GraphViewer::_gpsNodeItems
QMap< int, NodeItem * > _gpsNodeItems
Definition: GraphViewer.h:212
rtabmap::GraphViewer::_root
QGraphicsItem * _root
Definition: GraphViewer.h:203
rtabmap::GraphViewer::_graphRoot
QGraphicsItem * _graphRoot
Definition: GraphViewer.h:204
rtabmap::GraphViewer::_world
QGraphicsItem * _world
Definition: GraphViewer.h:202
rtabmap::GraphViewer::_loopIntraSessionColor
QColor _loopIntraSessionColor
Definition: GraphViewer.h:198
rtabmap::GraphViewer::getNodeOdomCacheColor
const QColor & getNodeOdomCacheColor() const
Definition: GraphViewer.h:95
rtabmap::GraphViewer::_workingDirectory
QString _workingDirectory
Definition: GraphViewer.h:182
rtabmap::GraphViewer::_nodeItems
QMap< int, NodeItem * > _nodeItems
Definition: GraphViewer.h:209
rtabmap::GraphViewer::_currentGoalColor
QColor _currentGoalColor
Definition: GraphViewer.h:185
rtabmap::GraphViewer::_originReferentialYZ
QGraphicsItemGroup * _originReferentialYZ
Definition: GraphViewer.h:228
rtabmap::GraphViewer::_orientationENU
bool _orientationENU
Definition: GraphViewer.h:234
rtabmap::GraphViewer::_landmarkColor
QColor _landmarkColor
Definition: GraphViewer.h:192
rtabmap::GraphViewer::_globalPathLinkItems
QMultiMap< int, LinkItem * > _globalPathLinkItems
Definition: GraphViewer.h:216
rtabmap::GraphViewer::_originReferentialXY
QGraphicsItemGroup * _originReferentialXY
Definition: GraphViewer.h:226
rtabmap::GraphViewer::getWorkingDirectory
const QString & getWorkingDirectory() const
Definition: GraphViewer.h:91
rtabmap::GraphViewer::_globalPathColor
QColor _globalPathColor
Definition: GraphViewer.h:195
rtabmap::GraphViewer::isIntraInterSessionColorsEnabled
bool isIntraInterSessionColorsEnabled() const
Definition: GraphViewer.h:110
rtabmap::GraphViewer::_originReferentialXZ
QGraphicsItemGroup * _originReferentialXZ
Definition: GraphViewer.h:227
rtabmap::GraphViewer::getGTColor
const QColor & getGTColor() const
Definition: GraphViewer.h:106
rtabmap::GraphViewer::getVirtualLoopClosureColor
const QColor & getVirtualLoopClosureColor() const
Definition: GraphViewer.h:101
rtabmap::GraphViewer::_gtGraphRoot
QGraphicsItem * _gtGraphRoot
Definition: GraphViewer.h:207
rtabmap::GraphViewer::getWorldMapRotation
float getWorldMapRotation() const
Definition: GraphViewer.h:64
rtabmap::GraphViewer::_referentialYZ
QGraphicsItemGroup * _referentialYZ
Definition: GraphViewer.h:224
rtabmap::GraphViewer::_localPathLinkItems
QMultiMap< int, LinkItem * > _localPathLinkItems
Definition: GraphViewer.h:215
rtabmap::GraphViewer::_loopClosureOutlierThr
float _loopClosureOutlierThr
Definition: GraphViewer.h:232
rtabmap::GraphViewer::_gpsGraphRoot
QGraphicsItem * _gpsGraphRoot
Definition: GraphViewer.h:208
rtabmap::GraphViewer::_mouseTracking
bool _mouseTracking
Definition: GraphViewer.h:235
rtabmap::GraphViewer::_loopClosureLocalColor
QColor _loopClosureLocalColor
Definition: GraphViewer.h:188
rtabmap::GraphViewer::_linkWidth
float _linkWidth
Definition: GraphViewer.h:219
rtabmap::GraphViewer::_nodeVisible
bool _nodeVisible
Definition: GraphViewer.h:217
rtabmap::GraphViewer::_globalPathRoot
QGraphicsItem * _globalPathRoot
Definition: GraphViewer.h:205
rtabmap::GraphViewer
Definition: GraphViewer.h:52
rtabmap::GraphViewer::_linkItems
QMultiMap< int, LinkItem * > _linkItems
Definition: GraphViewer.h:210
rtabmap::GraphViewer::_localRadius
QGraphicsEllipseItem * _localRadius
Definition: GraphViewer.h:230
rtabmap::GraphViewer::_neighborColor
QColor _neighborColor
Definition: GraphViewer.h:186
rtabmap::GraphViewer::getGlobalLoopClosureColor
const QColor & getGlobalLoopClosureColor() const
Definition: GraphViewer.h:98
rtabmap::GraphViewer::_intraInterSessionColors
bool _intraInterSessionColors
Definition: GraphViewer.h:200
rtabmap::GraphViewer::_gridCellSize
float _gridCellSize
Definition: GraphViewer.h:229
rtabmap::GraphViewer::_referentialXZ
QGraphicsItemGroup * _referentialXZ
Definition: GraphViewer.h:223
GPS.h
rtabmap::GraphViewer::getCurrentGoalColor
const QColor & getCurrentGoalColor() const
Definition: GraphViewer.h:96
rtabmap::GraphViewer::getInterSessionLoopColor
const QColor & getInterSessionLoopColor() const
Definition: GraphViewer.h:109
rtabmap::GraphViewer::_referentialXY
QGraphicsItemGroup * _referentialXY
Definition: GraphViewer.h:222
rtabmap::GraphViewer::getNodeRadius
float getNodeRadius() const
Definition: GraphViewer.h:92
rtabmap::GraphViewer::_gtNodeItems
QMap< int, NodeItem * > _gtNodeItems
Definition: GraphViewer.h:211
rtabmap::GraphViewer::_odomCacheOverlay
QGraphicsRectItem * _odomCacheOverlay
Definition: GraphViewer.h:231
rtabmap::GraphViewer::_nodeRadius
float _nodeRadius
Definition: GraphViewer.h:218
rtabmap::GraphViewer::_loopClosureRejectedColor
QColor _loopClosureRejectedColor
Definition: GraphViewer.h:193
rtabmap::GraphViewer::_viewPlane
ViewPlane _viewPlane
Definition: GraphViewer.h:236
rtabmap::GraphViewer::_loopClosureColor
QColor _loopClosureColor
Definition: GraphViewer.h:187
rtabmap::GraphViewer::getLocalPathColor
const QColor & getLocalPathColor() const
Definition: GraphViewer.h:104
rtabmap::GraphViewer::getLoopClosureOutlierThr
float getLoopClosureOutlierThr() const
Definition: GraphViewer.h:115
rtabmap::Transform
Definition: Transform.h:41
rtabmap::GraphViewer::_loopClosureVirtualColor
QColor _loopClosureVirtualColor
Definition: GraphViewer.h:190
rtabmap::GraphViewer::ViewPlane
ViewPlane
Definition: GraphViewer.h:57
rtabmap::GraphViewer::getGlobalPathColor
const QColor & getGlobalPathColor() const
Definition: GraphViewer.h:105
rtabmap::GraphViewer::_ensureFrameVisible
bool _ensureFrameVisible
Definition: GraphViewer.h:237
rtabmap::GraphViewer::getLinkWidth
float getLinkWidth() const
Definition: GraphViewer.h:93
rtabmap::GraphViewer::_neighborMergedColor
QColor _neighborMergedColor
Definition: GraphViewer.h:191
rtabmap::GraphViewer::_originReferential
QGraphicsItemGroup * _originReferential
Definition: GraphViewer.h:225
rtabmap::GraphViewer::_maxLinkLength
float _maxLinkLength
Definition: GraphViewer.h:233
rtabmap::GraphViewer::getUserLoopClosureColor
const QColor & getUserLoopClosureColor() const
Definition: GraphViewer.h:100
rtabmap::GraphViewer::getNeighborMergedColor
const QColor & getNeighborMergedColor() const
Definition: GraphViewer.h:102
rtabmap::GraphViewer::_gtPathColor
QColor _gtPathColor
Definition: GraphViewer.h:196
rtabmap::GraphViewer::_localPathRoot
QGraphicsItem * _localPathRoot
Definition: GraphViewer.h:206
rtabmap::GraphViewer::getIntraSessionLoopColor
const QColor & getIntraSessionLoopColor() const
Definition: GraphViewer.h:108
rtabmap::GraphViewer::_gpsPathColor
QColor _gpsPathColor
Definition: GraphViewer.h:197
rtabmap::GraphViewer::_referential
QGraphicsItemGroup * _referential
Definition: GraphViewer.h:221
rtabmap::GraphViewer::_nodeColor
QColor _nodeColor
Definition: GraphViewer.h:183
rtabmap::GraphViewer::getNeighborColor
const QColor & getNeighborColor() const
Definition: GraphViewer.h:97
rtabmap::GraphViewer::getNodeColor
const QColor & getNodeColor() const
Definition: GraphViewer.h:94
rtabmap
Definition: CameraARCore.cpp:35
rtabmap::GraphViewer::_gtLinkItems
QMultiMap< int, LinkItem * > _gtLinkItems
Definition: GraphViewer.h:213
rtabmap::GraphViewer::_nodeOdomCacheColor
QColor _nodeOdomCacheColor
Definition: GraphViewer.h:184
rtabmap::GraphViewer::_localPathColor
QColor _localPathColor
Definition: GraphViewer.h:194
rtabmap::GraphViewer::getLocalLoopClosureColor
const QColor & getLocalLoopClosureColor() const
Definition: GraphViewer.h:99
rtabmap::GraphViewer::getGPSColor
const QColor & getGPSColor() const
Definition: GraphViewer.h:107


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:10