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


rtabmap
Author(s): Mathieu Labbe
autogenerated on Sun Dec 1 2024 03:42:46