Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef GRAPHVIEWER_H_
00029 #define GRAPHVIEWER_H_
00030
00031 #include <QGraphicsView>
00032 #include <QtCore/QMap>
00033 #include <QtCore/QSettings>
00034 #include <rtabmap/core/Link.h>
00035 #include <opencv2/opencv.hpp>
00036 #include <map>
00037
00038 class QGraphicsItem;
00039 class QGraphicsPixmapItem;
00040 class QGraphicsItemGroup;
00041
00042 namespace rtabmap {
00043
00044 class NodeItem;
00045 class LinkItem;
00046
00047 class GraphViewer : public QGraphicsView {
00048
00049 Q_OBJECT;
00050
00051 public:
00052 GraphViewer(QWidget * parent = 0);
00053 virtual ~GraphViewer();
00054
00055 void updateGraph(const std::map<int, Transform> & poses,
00056 const std::multimap<int, Link> & constraints);
00057 void updateReferentialPosition(const Transform & t);
00058 void updateMap(const cv::Mat & map8U, float resolution, float xMin, float yMin);
00059 void updatePosterior(const std::map<int, float> & posterior);
00060 void updateLocalPath(const std::vector<int> & localPath);
00061 void setGlobalPath(const std::vector<std::pair<int, Transform> > & globalPath);
00062 void setCurrentGoalID(int id);
00063 void setLocalRadius(float radius);
00064 void clearGraph();
00065 void clearMap();
00066 void clearPosterior();
00067 void clearAll();
00068
00069 void saveSettings(QSettings & settings, const QString & group = "") const;
00070 void loadSettings(QSettings & settings, const QString & group = "");
00071
00072
00073 const QString & getWorkingDirectory() const {return _workingDirectory;}
00074 float getNodeRadius() const {return _nodeRadius;}
00075 float getLinkWidth() const {return _linkWidth;}
00076 const QColor & getNodeColor() const {return _nodeColor;}
00077 const QColor & getCurrentGoalColor() const {return _currentGoalColor;}
00078 const QColor & getNeighborColor() const {return _neighborColor;}
00079 const QColor & getGlobalLoopClosureColor() const {return _loopClosureColor;}
00080 const QColor & getLocalLoopClosureColor() const {return _loopClosureLocalColor;}
00081 const QColor & getUserLoopClosureColor() const {return _loopClosureUserColor;}
00082 const QColor & getVirtualLoopClosureColor() const {return _loopClosureVirtualColor;}
00083 const QColor & getLocalPathColor() const {return _localPathColor;}
00084 const QColor & getGlobalPathColor() const {return _globalPathColor;}
00085 bool isGridMapVisible() const;
00086 bool isOriginVisible() const;
00087 bool isReferentialVisible() const;
00088 bool isLocalRadiusVisible() const;
00089
00090
00091 void setWorkingDirectory(const QString & path);
00092 void setNodeRadius(float radius);
00093 void setLinkWidth(float width);
00094 void setNodeColor(const QColor & color);
00095 void setCurrentGoalColor(const QColor & color);
00096 void setNeighborColor(const QColor & color);
00097 void setGlobalLoopClosureColor(const QColor & color);
00098 void setLocalLoopClosureColor(const QColor & color);
00099 void setUserLoopClosureColor(const QColor & color);
00100 void setVirtualLoopClosureColor(const QColor & color);
00101 void setLocalPathColor(const QColor & color);
00102 void setGlobalPathColor(const QColor & color);
00103 void setGridMapVisible(bool visible);
00104 void setOriginVisible(bool visible);
00105 void setReferentialVisible(bool visible);
00106 void setLocalRadiusVisible(bool visible);
00107
00108 signals:
00109 void configChanged();
00110
00111 public slots:
00112 void restoreDefaults();
00113
00114 protected:
00115 virtual void wheelEvent ( QWheelEvent * event );
00116 virtual void contextMenuEvent(QContextMenuEvent * event);
00117
00118 private:
00119 QString _workingDirectory;
00120 QColor _nodeColor;
00121 QColor _currentGoalColor;
00122 QColor _neighborColor;
00123 QColor _loopClosureColor;
00124 QColor _loopClosureLocalColor;
00125 QColor _loopClosureUserColor;
00126 QColor _loopClosureVirtualColor;
00127 QColor _localPathColor;
00128 QColor _globalPathColor;
00129 QGraphicsItem * _root;
00130 QMap<int, NodeItem*> _nodeItems;
00131 QMultiMap<int, LinkItem*> _linkItems;
00132 QMultiMap<int, LinkItem*> _localPathLinkItems;
00133 QMultiMap<int, LinkItem*> _globalPathLinkItems;
00134 float _nodeRadius;
00135 float _linkWidth;
00136 QGraphicsPixmapItem * _gridMap;
00137 QGraphicsItemGroup * _referential;
00138 QGraphicsItemGroup * _originReferential;
00139 float _gridCellSize;
00140 QGraphicsEllipseItem * _localRadius;
00141 };
00142
00143 }
00144 #endif