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>
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 updateGraph(const std::map<int, Transform> & poses,
60  const std::multimap<int, Link> & constraints,
61  const std::map<int, int> & mapIds);
62  void updateGTGraph(const std::map<int, Transform> & poses);
63  void updateGPSGraph(
64  const std::map<int, Transform> & gpsMapPoses,
65  const std::map<int, GPS> & gpsValues);
66  void updateReferentialPosition(const Transform & t);
67  void updateMap(const cv::Mat & map8U, float resolution, float xMin, float yMin);
68  void updatePosterior(const std::map<int, float> & posterior, float fixedMax = 0.0f);
69  void updateLocalPath(const std::vector<int> & localPath);
70  void setGlobalPath(const std::vector<std::pair<int, Transform> > & globalPath);
71  void setCurrentGoalID(int id, const Transform & pose = Transform());
72  void setLocalRadius(float radius);
73  void clearGraph();
74  void clearMap();
75  void clearPosterior();
76  void clearAll();
77 
78  void saveSettings(QSettings & settings, const QString & group = "") const;
79  void loadSettings(QSettings & settings, const QString & group = "");
80 
81  //getters
82  const QString & getWorkingDirectory() const {return _workingDirectory;}
83  float getNodeRadius() const {return _nodeRadius;}
84  float getLinkWidth() const {return _linkWidth;}
85  const QColor & getNodeColor() const {return _nodeColor;}
86  const QColor & getCurrentGoalColor() const {return _currentGoalColor;}
87  const QColor & getNeighborColor() const {return _neighborColor;}
88  const QColor & getGlobalLoopClosureColor() const {return _loopClosureColor;}
89  const QColor & getLocalLoopClosureColor() const {return _loopClosureLocalColor;}
90  const QColor & getUserLoopClosureColor() const {return _loopClosureUserColor;}
91  const QColor & getVirtualLoopClosureColor() const {return _loopClosureVirtualColor;}
92  const QColor & getNeighborMergedColor() const {return _neighborMergedColor;}
93  const QColor & getRejectedLoopClosureColor() const {return _loopClosureRejectedColor;}
94  const QColor & getLocalPathColor() const {return _localPathColor;}
95  const QColor & getGlobalPathColor() const {return _globalPathColor;}
96  const QColor & getGTColor() const {return _gtPathColor;}
97  const QColor & getGPSColor() const {return _gpsPathColor;}
98  const QColor & getIntraSessionLoopColor() const {return _loopIntraSessionColor;}
99  const QColor & getInterSessionLoopColor() const {return _loopInterSessionColor;}
100  bool isIntraInterSessionColorsEnabled() const {return _intraInterSessionColors;}
101  bool isGridMapVisible() const;
102  bool isOriginVisible() const;
103  bool isReferentialVisible() const;
104  bool isLocalRadiusVisible() const;
105  float getLoopClosureOutlierThr() const {return _loopClosureOutlierThr;}
106  float getMaxLinkLength() const {return _maxLinkLength;}
107  bool isGraphVisible() const;
108  bool isGlobalPathVisible() const;
109  bool isLocalPathVisible() const;
110  bool isGtGraphVisible() const;
111  bool isGPSGraphVisible() const;
112  bool isOrientationENU() const;
113 
114  // setters
115  void setWorkingDirectory(const QString & path);
116  void setNodeVisible(bool visible);
117  void setNodeRadius(float radius);
118  void setLinkWidth(float width);
119  void setNodeColor(const QColor & color);
120  void setCurrentGoalColor(const QColor & color);
121  void setNeighborColor(const QColor & color);
122  void setGlobalLoopClosureColor(const QColor & color);
123  void setLocalLoopClosureColor(const QColor & color);
124  void setUserLoopClosureColor(const QColor & color);
125  void setVirtualLoopClosureColor(const QColor & color);
126  void setNeighborMergedColor(const QColor & color);
127  void setRejectedLoopClosureColor(const QColor & color);
128  void setLocalPathColor(const QColor & color);
129  void setGlobalPathColor(const QColor & color);
130  void setGTColor(const QColor & color);
131  void setGPSColor(const QColor & color);
132  void setIntraSessionLoopColor(const QColor & color);
133  void setInterSessionLoopColor(const QColor & color);
134  void setIntraInterSessionColorsEnabled(bool enabled);
135  void setGridMapVisible(bool visible);
136  void setOriginVisible(bool visible);
137  void setReferentialVisible(bool visible);
138  void setLocalRadiusVisible(bool visible);
139  void setLoopClosureOutlierThr(float value);
140  void setMaxLinkLength(float value);
141  void setGraphVisible(bool visible);
142  void setGlobalPathVisible(bool visible);
143  void setLocalPathVisible(bool visible);
144  void setGtGraphVisible(bool visible);
145  void setGPSGraphVisible(bool visible);
146  void setOrientationENU(bool enabled);
147 
148 Q_SIGNALS:
149  void configChanged();
150  void mapShownRequested();
151 
152 public Q_SLOTS:
153  void restoreDefaults();
154 
155 protected:
156  virtual void wheelEvent ( QWheelEvent * event );
157  virtual void contextMenuEvent(QContextMenuEvent * event);
158 
159 private:
161  QColor _nodeColor;
172  QColor _gtPathColor;
177  QGraphicsItem * _root;
178  QGraphicsItem * _graphRoot;
179  QGraphicsItem * _globalPathRoot;
180  QGraphicsItem * _localPathRoot;
181  QGraphicsItem * _gtGraphRoot;
182  QGraphicsItem * _gpsGraphRoot;
183  QMap<int, NodeItem*> _nodeItems;
184  QMultiMap<int, LinkItem*> _linkItems;
185  QMap<int, NodeItem*> _gtNodeItems;
186  QMap<int, NodeItem*> _gpsNodeItems;
187  QMultiMap<int, LinkItem*> _gtLinkItems;
188  QMultiMap<int, LinkItem*> _gpsLinkItems;
189  QMultiMap<int, LinkItem*> _localPathLinkItems;
190  QMultiMap<int, LinkItem*> _globalPathLinkItems;
192  float _nodeRadius;
193  float _linkWidth;
194  QGraphicsPixmapItem * _gridMap;
195  QGraphicsItemGroup * _referential;
196  QGraphicsItemGroup * _originReferential;
198  QGraphicsEllipseItem * _localRadius;
202 };
203 
204 } /* namespace rtabmap */
205 #endif /* GRAPHVIEWER_H_ */
#define RTABMAPGUI_EXP
Definition: RtabmapGuiExp.h:38
QGraphicsItem * _gpsGraphRoot
Definition: GraphViewer.h:182
QColor _loopClosureLocalColor
Definition: GraphViewer.h:165
QColor _loopClosureVirtualColor
Definition: GraphViewer.h:167
const QColor & getVirtualLoopClosureColor() const
Definition: GraphViewer.h:91
float getLinkWidth() const
Definition: GraphViewer.h:84
QGraphicsItem * _localPathRoot
Definition: GraphViewer.h:180
const QColor & getInterSessionLoopColor() const
Definition: GraphViewer.h:99
QGraphicsEllipseItem * _localRadius
Definition: GraphViewer.h:198
QGraphicsItemGroup * _referential
Definition: GraphViewer.h:195
f
const QString & getWorkingDirectory() const
Definition: GraphViewer.h:82
const QColor & getGPSColor() const
Definition: GraphViewer.h:97
const QColor & getRejectedLoopClosureColor() const
Definition: GraphViewer.h:93
float getNodeRadius() const
Definition: GraphViewer.h:83
QGraphicsPixmapItem * _gridMap
Definition: GraphViewer.h:194
QMultiMap< int, LinkItem * > _gpsLinkItems
Definition: GraphViewer.h:188
QGraphicsItem * _graphRoot
Definition: GraphViewer.h:178
QGraphicsItem * _root
Definition: GraphViewer.h:177
const QColor & getGlobalLoopClosureColor() const
Definition: GraphViewer.h:88
QColor _loopInterSessionColor
Definition: GraphViewer.h:175
const QColor & getGlobalPathColor() const
Definition: GraphViewer.h:95
const QColor & getLocalPathColor() const
Definition: GraphViewer.h:94
QColor _loopClosureRejectedColor
Definition: GraphViewer.h:169
float getLoopClosureOutlierThr() const
Definition: GraphViewer.h:105
QColor _loopIntraSessionColor
Definition: GraphViewer.h:174
QMultiMap< int, LinkItem * > _globalPathLinkItems
Definition: GraphViewer.h:190
QGraphicsItemGroup * _originReferential
Definition: GraphViewer.h:196
const QColor & getNodeColor() const
Definition: GraphViewer.h:85
float getMaxLinkLength() const
Definition: GraphViewer.h:106
QMultiMap< int, LinkItem * > _gtLinkItems
Definition: GraphViewer.h:187
const QColor & getIntraSessionLoopColor() const
Definition: GraphViewer.h:98
QGraphicsItem * _gtGraphRoot
Definition: GraphViewer.h:181
const QColor & getLocalLoopClosureColor() const
Definition: GraphViewer.h:89
const QColor & getCurrentGoalColor() const
Definition: GraphViewer.h:86
QMultiMap< int, LinkItem * > _localPathLinkItems
Definition: GraphViewer.h:189
bool isIntraInterSessionColorsEnabled() const
Definition: GraphViewer.h:100
QGraphicsItem * _globalPathRoot
Definition: GraphViewer.h:179
QMap< int, NodeItem * > _gpsNodeItems
Definition: GraphViewer.h:186
QColor _loopClosureUserColor
Definition: GraphViewer.h:166
const QColor & getUserLoopClosureColor() const
Definition: GraphViewer.h:90
QMultiMap< int, LinkItem * > _linkItems
Definition: GraphViewer.h:184
const QColor & getNeighborMergedColor() const
Definition: GraphViewer.h:92
const QColor & getGTColor() const
Definition: GraphViewer.h:96
QMap< int, NodeItem * > _nodeItems
Definition: GraphViewer.h:183
QMap< int, NodeItem * > _gtNodeItems
Definition: GraphViewer.h:185
const QColor & getNeighborColor() const
Definition: GraphViewer.h:87


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:41:31