ImageView.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2016, 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 IMAGEVIEW_H_
00029 #define IMAGEVIEW_H_
00030 
00031 #include "rtabmap/gui/RtabmapGuiExp.h" // DLL export/import defines
00032 
00033 #include <QGraphicsView>
00034 #include <QtCore/QRectF>
00035 #include <QtCore/QMultiMap>
00036 #include <QtCore/QSettings>
00037 #include <opencv2/features2d/features2d.hpp>
00038 #include <map>
00039 
00040 class QAction;
00041 class QMenu;
00042 
00043 namespace rtabmap {
00044 
00045 class KeypointItem;
00046 
00047 class RTABMAPGUI_EXP ImageView : public QWidget {
00048 
00049         Q_OBJECT
00050 
00051 public:
00052         ImageView(QWidget * parent = 0);
00053         virtual ~ImageView();
00054 
00055         void saveSettings(QSettings & settings, const QString & group = "") const;
00056         void loadSettings(QSettings & settings, const QString & group = "");
00057 
00058         QRectF sceneRect() const;
00059         bool isImageShown() const;
00060         bool isImageDepthShown() const;
00061         bool isFeaturesShown() const;
00062         bool isLinesShown() const;
00063         int getAlpha() const {return _alpha;}
00064         bool isGraphicsViewMode() const;
00065         bool isGraphicsViewScaled() const;
00066         const QColor & getBackgroundColor() const;
00067 
00068         float viewScale() const;
00069 
00070         void setFeaturesShown(bool shown);
00071         void setImageShown(bool shown);
00072         void setImageDepthShown(bool shown);
00073         void setLinesShown(bool shown);
00074         void setGraphicsViewMode(bool on);
00075         void setGraphicsViewScaled(bool scaled);
00076         void setBackgroundColor(const QColor & color);
00077 
00078         void setFeatures(const std::multimap<int, cv::KeyPoint> & refWords, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
00079         void setFeatures(const std::vector<cv::KeyPoint> & features, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
00080         void addFeature(int id, const cv::KeyPoint & kpt, float depth, QColor color);
00081         void addLine(float x1, float y1, float x2, float y2, QColor color, const QString & text = QString());
00082         void setImage(const QImage & image);
00083         void setImageDepth(const QImage & image);
00084         void setFeatureColor(int id, QColor color);
00085         void setFeaturesColor(QColor color);
00086         void setAlpha(int alpha);
00087         void setSceneRect(const QRectF & rect);
00088 
00089         const QMultiMap<int, rtabmap::KeypointItem *> & getFeatures() const {return _features;}
00090 
00091         void clearLines();
00092         void clear();
00093 
00094         virtual QSize sizeHint() const;
00095 
00096 signals:
00097         void configChanged();
00098 
00099 protected:
00100         virtual void paintEvent(QPaintEvent *event);
00101         virtual void resizeEvent(QResizeEvent* event);
00102         virtual void contextMenuEvent(QContextMenuEvent * e);
00103 
00104 private slots:
00105         void sceneRectChanged(const QRectF &rect);
00106 
00107 private:
00108         void updateOpacity();
00109         void computeScaleOffsets(const QRect & targetRect, float & scale, float & offsetX, float & offsetY) const;
00110 
00111 private:
00112         QString _savedFileName;
00113         int _alpha;
00114 
00115         QMenu * _menu;
00116         QAction * _showImage;
00117         QAction * _showImageDepth;
00118         QAction * _showFeatures;
00119         QAction * _showLines;
00120         QAction * _saveImage;
00121         QAction * _setAlpha;
00122         QAction * _graphicsViewMode;
00123         QAction * _graphicsViewScaled;
00124 
00125         QGraphicsView * _graphicsView;
00126         QMultiMap<int, rtabmap::KeypointItem *> _features;
00127         QList<QGraphicsLineItem*> _lines;
00128         QGraphicsPixmapItem * _imageItem;
00129         QGraphicsPixmapItem * _imageDepthItem;
00130         QPixmap _image;
00131         QPixmap _imageDepth;
00132 };
00133 
00134 }
00135 
00136 #endif /* IMAGEVIEW_H_ */


rtabmap
Author(s): Mathieu Labbe
autogenerated on Sat Jul 23 2016 11:44:16