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  // Use updateNodeColorByValue() instead with valueName="Posterior".
78  RTABMAP_DEPRECATED void updatePosterior(const std::map<int, float> & posterior, float fixedMax = 0.0f, int zValueOffset = 0);
79  void updateNodeColorByValue(const std::string & valueName, const std::map<int, float> & values, float fixedMax = 0.0f, bool invertedColorScale = false, int zValueOffset = 0);
80  void updateLocalPath(const std::vector<int> & localPath);
81  void setGlobalPath(const std::vector<std::pair<int, Transform> > & globalPath);
82  void setCurrentGoalID(int id, const Transform & pose = Transform());
83  void setLocalRadius(float radius);
84  void highlightNode(int nodeId, int highlightIndex);
85  void clearGraph();
86  void clearMap();
87  // Use clearNodeColorByValue() instead.
88  RTABMAP_DEPRECATED void clearPosterior();
89  void clearNodeColorByValue();
90  void clearAll();
91  void saveSettings(QSettings & settings, const QString & group = "") const;
92  void loadSettings(QSettings & settings, const QString & group = "");
93 
94  //getters
95  const QString & getWorkingDirectory() const {return _workingDirectory;}
96  float getNodeRadius() const {return _nodeRadius;}
97  float getLinkWidth() const {return _linkWidth;}
98  const QColor & getNodeColor() const {return _nodeColor;}
99  const QColor & getNodeOdomCacheColor() const {return _nodeOdomCacheColor;}
100  const QColor & getCurrentGoalColor() const {return _currentGoalColor;}
101  const QColor & getNeighborColor() const {return _neighborColor;}
102  const QColor & getGlobalLoopClosureColor() const {return _loopClosureColor;}
103  const QColor & getLocalLoopClosureColor() const {return _loopClosureLocalColor;}
104  const QColor & getUserLoopClosureColor() const {return _loopClosureUserColor;}
105  const QColor & getVirtualLoopClosureColor() const {return _loopClosureVirtualColor;}
106  const QColor & getNeighborMergedColor() const {return _neighborMergedColor;}
107  const QColor & getRejectedLoopClosureColor() const {return _loopClosureRejectedColor;}
108  const QColor & getLocalPathColor() const {return _localPathColor;}
109  const QColor & getGlobalPathColor() const {return _globalPathColor;}
110  const QColor & getGTColor() const {return _gtPathColor;}
111  const QColor & getGPSColor() const {return _gpsPathColor;}
112  const QColor & getIntraSessionLoopColor() const {return _loopIntraSessionColor;}
113  const QColor & getInterSessionLoopColor() const {return _loopInterSessionColor;}
114  bool isIntraInterSessionColorsEnabled() const {return _intraInterSessionColors;}
115  bool isGridMapVisible() const;
116  bool isOriginVisible() const;
117  bool isReferentialVisible() const;
118  bool isLocalRadiusVisible() const;
119  float getLoopClosureOutlierThr() const {return _loopClosureOutlierThr;}
120  float getMaxLinkLength() const {return _maxLinkLength;}
121  bool isGraphVisible() const;
122  bool isGlobalPathVisible() const;
123  bool isLocalPathVisible() const;
124  bool isGtGraphVisible() const;
125  bool isGPSGraphVisible() const;
126  bool isOdomCacheOverlayVisible() const;
127  bool isOrientationENU() const;
128  ViewPlane getViewPlane() const;
129  bool isEnsureFrameVisible() const;
130 
131  // setters
132  void setWorkingDirectory(const QString & path);
133  void setNodeVisible(bool visible);
134  void setNodeRadius(float radius);
135  void setLinkWidth(float width);
136  void setNodeColor(const QColor & color);
137  void setNodeOdomCacheColor(const QColor & color);
138  void setCurrentGoalColor(const QColor & color);
139  void setNeighborColor(const QColor & color);
140  void setGlobalLoopClosureColor(const QColor & color);
141  void setLocalLoopClosureColor(const QColor & color);
142  void setUserLoopClosureColor(const QColor & color);
143  void setVirtualLoopClosureColor(const QColor & color);
144  void setNeighborMergedColor(const QColor & color);
145  void setLandmarkColor(const QColor & color);
146  void setRejectedLoopClosureColor(const QColor & color);
147  void setLocalPathColor(const QColor & color);
148  void setGlobalPathColor(const QColor & color);
149  void setGTColor(const QColor & color);
150  void setGPSColor(const QColor & color);
151  void setHighlightColor(const QColor & color, int index);
152  void setIntraSessionLoopColor(const QColor & color);
153  void setInterSessionLoopColor(const QColor & color);
154  void setIntraInterSessionColorsEnabled(bool enabled);
155  void setGridMapVisible(bool visible);
156  void setOriginVisible(bool visible);
157  void setReferentialVisible(bool visible);
158  void setLocalRadiusVisible(bool visible);
159  void setLoopClosureOutlierThr(float value);
160  void setMaxLinkLength(float value);
161  void setGraphVisible(bool visible);
162  void setGlobalPathVisible(bool visible);
163  void setLocalPathVisible(bool visible);
164  void setGtGraphVisible(bool visible);
165  void setGPSGraphVisible(bool visible);
166  void setOdomCacheOverlayVisible(bool visible);
167  void setOrientationENU(bool enabled);
168  void setViewPlane(ViewPlane plane);
169  void setEnsureFrameVisible(bool visible);
170 
171 Q_SIGNALS:
172  void configChanged();
173  void mapShownRequested();
174  void nodeSelected(int);
175  void linkSelected(int, int);
176 
177 public Q_SLOTS:
178  void restoreDefaults();
179 
180 protected:
181  virtual void wheelEvent ( QWheelEvent * event );
182  virtual void mouseMoveEvent(QMouseEvent * event);
183  virtual void mousePressEvent(QMouseEvent * event);
184  virtual void contextMenuEvent(QContextMenuEvent * event);
185 
186 private:
188  QColor _nodeColor;
201  QColor _gtPathColor;
207  QGraphicsItem * _world;
208  QGraphicsItem * _root;
209  QGraphicsItem * _graphRoot;
210  QGraphicsItem * _globalPathRoot;
211  QGraphicsItem * _localPathRoot;
212  QGraphicsItem * _gtGraphRoot;
213  QGraphicsItem * _gpsGraphRoot;
214  QMap<int, NodeItem*> _nodeItems;
215  QMultiMap<int, LinkItem*> _linkItems;
216  QMap<int, NodeItem*> _gtNodeItems;
217  QMap<int, NodeItem*> _gpsNodeItems;
218  QMultiMap<int, LinkItem*> _gtLinkItems;
219  QMultiMap<int, LinkItem*> _gpsLinkItems;
220  QMultiMap<int, LinkItem*> _localPathLinkItems;
221  QMultiMap<int, LinkItem*> _globalPathLinkItems;
222  QVector<QPair<QColor, NodeItem*> > _highlightedNodes;
224  float _nodeRadius;
225  float _linkWidth;
226  QGraphicsPixmapItem * _gridMap;
227  QGraphicsItemGroup * _referential;
228  QGraphicsItemGroup * _referentialXY;
229  QGraphicsItemGroup * _referentialXZ;
230  QGraphicsItemGroup * _referentialYZ;
231  QGraphicsItemGroup * _originReferential;
232  QGraphicsItemGroup * _originReferentialXY;
233  QGraphicsItemGroup * _originReferentialXZ;
234  QGraphicsItemGroup * _originReferentialYZ;
236  QGraphicsEllipseItem * _localRadius;
237  QGraphicsRectItem * _odomCacheOverlay;
245 };
246 
247 } /* namespace rtabmap */
248 #endif /* GRAPHVIEWER_H_ */
rtabmap::GraphViewer::getMaxLinkLength
float getMaxLinkLength() const
Definition: GraphViewer.h:120
rtabmap::GraphViewer::_gridMap
QGraphicsPixmapItem * _gridMap
Definition: GraphViewer.h:226
rtabmap::GraphViewer::_worldMapRotation
float _worldMapRotation
Definition: GraphViewer.h:206
rtabmap::GraphViewer::_loopClosureUserColor
QColor _loopClosureUserColor
Definition: GraphViewer.h:194
rtabmap::GraphViewer::_loopInterSessionColor
QColor _loopInterSessionColor
Definition: GraphViewer.h:204
rtabmap::GraphViewer::_gpsLinkItems
QMultiMap< int, LinkItem * > _gpsLinkItems
Definition: GraphViewer.h:219
rtabmap::GraphViewer::getRejectedLoopClosureColor
const QColor & getRejectedLoopClosureColor() const
Definition: GraphViewer.h:107
rtabmap::GraphViewer::_gpsNodeItems
QMap< int, NodeItem * > _gpsNodeItems
Definition: GraphViewer.h:217
rtabmap::GraphViewer::_root
QGraphicsItem * _root
Definition: GraphViewer.h:208
rtabmap::GraphViewer::_graphRoot
QGraphicsItem * _graphRoot
Definition: GraphViewer.h:209
rtabmap::GraphViewer::_world
QGraphicsItem * _world
Definition: GraphViewer.h:207
rtabmap::GraphViewer::_loopIntraSessionColor
QColor _loopIntraSessionColor
Definition: GraphViewer.h:203
rtabmap::GraphViewer::getNodeOdomCacheColor
const QColor & getNodeOdomCacheColor() const
Definition: GraphViewer.h:99
rtabmap::GraphViewer::_workingDirectory
QString _workingDirectory
Definition: GraphViewer.h:187
rtabmap::GraphViewer::_nodeItems
QMap< int, NodeItem * > _nodeItems
Definition: GraphViewer.h:214
rtabmap::GraphViewer::_currentGoalColor
QColor _currentGoalColor
Definition: GraphViewer.h:190
rtabmap::GraphViewer::_originReferentialYZ
QGraphicsItemGroup * _originReferentialYZ
Definition: GraphViewer.h:234
rtabmap::GraphViewer::_orientationENU
bool _orientationENU
Definition: GraphViewer.h:240
rtabmap::GraphViewer::_landmarkColor
QColor _landmarkColor
Definition: GraphViewer.h:197
rtabmap::GraphViewer::_globalPathLinkItems
QMultiMap< int, LinkItem * > _globalPathLinkItems
Definition: GraphViewer.h:221
rtabmap::RTABMAP_DEPRECATED
RTABMAP_DEPRECATED(typedef SensorData Image, "rtabmap::Image class is renamed to rtabmap::SensorData, use the last one instead.")
rtabmap::GraphViewer::_originReferentialXY
QGraphicsItemGroup * _originReferentialXY
Definition: GraphViewer.h:232
rtabmap::GraphViewer::getWorkingDirectory
const QString & getWorkingDirectory() const
Definition: GraphViewer.h:95
rtabmap::GraphViewer::_globalPathColor
QColor _globalPathColor
Definition: GraphViewer.h:200
rtabmap::GraphViewer::isIntraInterSessionColorsEnabled
bool isIntraInterSessionColorsEnabled() const
Definition: GraphViewer.h:114
rtabmap::GraphViewer::_originReferentialXZ
QGraphicsItemGroup * _originReferentialXZ
Definition: GraphViewer.h:233
rtabmap::GraphViewer::getGTColor
const QColor & getGTColor() const
Definition: GraphViewer.h:110
rtabmap::GraphViewer::getVirtualLoopClosureColor
const QColor & getVirtualLoopClosureColor() const
Definition: GraphViewer.h:105
rtabmap::GraphViewer::_gtGraphRoot
QGraphicsItem * _gtGraphRoot
Definition: GraphViewer.h:212
rtabmap::GraphViewer::getWorldMapRotation
float getWorldMapRotation() const
Definition: GraphViewer.h:64
rtabmap::GraphViewer::_referentialYZ
QGraphicsItemGroup * _referentialYZ
Definition: GraphViewer.h:230
rtabmap::GraphViewer::_localPathLinkItems
QMultiMap< int, LinkItem * > _localPathLinkItems
Definition: GraphViewer.h:220
rtabmap::GraphViewer::_loopClosureOutlierThr
float _loopClosureOutlierThr
Definition: GraphViewer.h:238
rtabmap::GraphViewer::_gpsGraphRoot
QGraphicsItem * _gpsGraphRoot
Definition: GraphViewer.h:213
rtabmap::GraphViewer::_mouseTracking
bool _mouseTracking
Definition: GraphViewer.h:241
rtabmap::GraphViewer::_loopClosureLocalColor
QColor _loopClosureLocalColor
Definition: GraphViewer.h:193
rtabmap::GraphViewer::_linkWidth
float _linkWidth
Definition: GraphViewer.h:225
rtabmap::GraphViewer::_nodeVisible
bool _nodeVisible
Definition: GraphViewer.h:223
rtabmap::GraphViewer::_globalPathRoot
QGraphicsItem * _globalPathRoot
Definition: GraphViewer.h:210
rtabmap::GraphViewer
Definition: GraphViewer.h:52
rtabmap::GraphViewer::_linkItems
QMultiMap< int, LinkItem * > _linkItems
Definition: GraphViewer.h:215
rtabmap::GraphViewer::_localRadius
QGraphicsEllipseItem * _localRadius
Definition: GraphViewer.h:236
rtabmap::GraphViewer::_neighborColor
QColor _neighborColor
Definition: GraphViewer.h:191
rtabmap::GraphViewer::getGlobalLoopClosureColor
const QColor & getGlobalLoopClosureColor() const
Definition: GraphViewer.h:102
rtabmap::GraphViewer::_intraInterSessionColors
bool _intraInterSessionColors
Definition: GraphViewer.h:205
rtabmap::GraphViewer::_gridCellSize
float _gridCellSize
Definition: GraphViewer.h:235
rtabmap::GraphViewer::_referentialXZ
QGraphicsItemGroup * _referentialXZ
Definition: GraphViewer.h:229
rtabmap::GraphViewer::_previousMousePos
QPoint _previousMousePos
Definition: GraphViewer.h:244
GPS.h
rtabmap::GraphViewer::getCurrentGoalColor
const QColor & getCurrentGoalColor() const
Definition: GraphViewer.h:100
rtabmap::GraphViewer::getInterSessionLoopColor
const QColor & getInterSessionLoopColor() const
Definition: GraphViewer.h:113
rtabmap::GraphViewer::_referentialXY
QGraphicsItemGroup * _referentialXY
Definition: GraphViewer.h:228
rtabmap::GraphViewer::getNodeRadius
float getNodeRadius() const
Definition: GraphViewer.h:96
rtabmap::GraphViewer::_gtNodeItems
QMap< int, NodeItem * > _gtNodeItems
Definition: GraphViewer.h:216
rtabmap::GraphViewer::_odomCacheOverlay
QGraphicsRectItem * _odomCacheOverlay
Definition: GraphViewer.h:237
rtabmap::GraphViewer::_nodeRadius
float _nodeRadius
Definition: GraphViewer.h:224
rtabmap::GraphViewer::_loopClosureRejectedColor
QColor _loopClosureRejectedColor
Definition: GraphViewer.h:198
rtabmap::GraphViewer::_viewPlane
ViewPlane _viewPlane
Definition: GraphViewer.h:242
rtabmap::GraphViewer::_loopClosureColor
QColor _loopClosureColor
Definition: GraphViewer.h:192
rtabmap::GraphViewer::getLocalPathColor
const QColor & getLocalPathColor() const
Definition: GraphViewer.h:108
rtabmap::GraphViewer::getLoopClosureOutlierThr
float getLoopClosureOutlierThr() const
Definition: GraphViewer.h:119
rtabmap::Transform
Definition: Transform.h:41
rtabmap::GraphViewer::_loopClosureVirtualColor
QColor _loopClosureVirtualColor
Definition: GraphViewer.h:195
rtabmap::GraphViewer::ViewPlane
ViewPlane
Definition: GraphViewer.h:57
rtabmap::GraphViewer::getGlobalPathColor
const QColor & getGlobalPathColor() const
Definition: GraphViewer.h:109
rtabmap::GraphViewer::_ensureFrameVisible
bool _ensureFrameVisible
Definition: GraphViewer.h:243
rtabmap::GraphViewer::getLinkWidth
float getLinkWidth() const
Definition: GraphViewer.h:97
rtabmap::GraphViewer::_neighborMergedColor
QColor _neighborMergedColor
Definition: GraphViewer.h:196
rtabmap::GraphViewer::_originReferential
QGraphicsItemGroup * _originReferential
Definition: GraphViewer.h:231
rtabmap::GraphViewer::_maxLinkLength
float _maxLinkLength
Definition: GraphViewer.h:239
rtabmap::GraphViewer::getUserLoopClosureColor
const QColor & getUserLoopClosureColor() const
Definition: GraphViewer.h:104
rtabmap::GraphViewer::getNeighborMergedColor
const QColor & getNeighborMergedColor() const
Definition: GraphViewer.h:106
rtabmap::GraphViewer::_gtPathColor
QColor _gtPathColor
Definition: GraphViewer.h:201
rtabmap::GraphViewer::_highlightedNodes
QVector< QPair< QColor, NodeItem * > > _highlightedNodes
Definition: GraphViewer.h:222
rtabmap::GraphViewer::_localPathRoot
QGraphicsItem * _localPathRoot
Definition: GraphViewer.h:211
rtabmap::GraphViewer::getIntraSessionLoopColor
const QColor & getIntraSessionLoopColor() const
Definition: GraphViewer.h:112
rtabmap::GraphViewer::_gpsPathColor
QColor _gpsPathColor
Definition: GraphViewer.h:202
rtabmap::GraphViewer::_referential
QGraphicsItemGroup * _referential
Definition: GraphViewer.h:227
rtabmap::GraphViewer::_nodeColor
QColor _nodeColor
Definition: GraphViewer.h:188
rtabmap::GraphViewer::getNeighborColor
const QColor & getNeighborColor() const
Definition: GraphViewer.h:101
rtabmap::GraphViewer::getNodeColor
const QColor & getNodeColor() const
Definition: GraphViewer.h:98
rtabmap
Definition: CameraARCore.cpp:35
rtabmap::GraphViewer::_gtLinkItems
QMultiMap< int, LinkItem * > _gtLinkItems
Definition: GraphViewer.h:218
rtabmap::GraphViewer::_nodeOdomCacheColor
QColor _nodeOdomCacheColor
Definition: GraphViewer.h:189
rtabmap::GraphViewer::_localPathColor
QColor _localPathColor
Definition: GraphViewer.h:199
rtabmap::GraphViewer::getLocalLoopClosureColor
const QColor & getLocalLoopClosureColor() const
Definition: GraphViewer.h:103
rtabmap::GraphViewer::getGPSColor
const QColor & getGPSColor() const
Definition: GraphViewer.h:111


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Apr 28 2025 02:45:54