GraphViewer.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the Universite de Sherbrooke nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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         //getters
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         // setters
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 } /* namespace rtabmap */
00144 #endif /* GRAPHVIEWER_H_ */


rtabmap
Author(s): Mathieu Labbe
autogenerated on Fri Aug 28 2015 12:51:31