ImageView.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_IMAGEVIEW_H_
29 #define RTABMAP_IMAGEVIEW_H_
30 
31 #include "rtabmap/gui/RtabmapGuiExp.h" // DLL export/import defines
32 
33 #include <QGraphicsView>
34 #include <QtCore/QRectF>
35 #include <QtCore/QMultiMap>
36 #include <QtCore/QSettings>
37 #include <opencv2/features2d/features2d.hpp>
38 #include <map>
39 
40 class QAction;
41 class QMenu;
42 
43 namespace rtabmap {
44 
45 class KeypointItem;
46 
47 class RTABMAPGUI_EXP ImageView : public QWidget {
48 
49  Q_OBJECT
50 
51 public:
52  ImageView(QWidget * parent = 0);
53  virtual ~ImageView();
54 
55  void saveSettings(QSettings & settings, const QString & group = "") const;
56  void loadSettings(QSettings & settings, const QString & group = "");
57 
58  QRectF sceneRect() const;
59  bool isImageShown() const;
60  bool isImageDepthShown() const;
61  bool isFeaturesShown() const;
62  bool isLinesShown() const;
63  int getAlpha() const {return _alpha;}
64  int getFeaturesSize() const {return _featuresSize;}
65  bool isGraphicsViewMode() const;
66  bool isGraphicsViewScaled() const;
67  bool isGraphicsViewScaledToHeight() const;
68  const QColor & getDefaultBackgroundColor() const;
69  const QColor & getBackgroundColor() const;
70 
71  float viewScale() const;
72 
73  void setFeaturesShown(bool shown);
74  void setImageShown(bool shown);
75  void setImageDepthShown(bool shown);
76  void setLinesShown(bool shown);
77  void setGraphicsViewMode(bool on);
78  void setGraphicsViewScaled(bool scaled);
79  void setGraphicsViewScaledToHeight(bool scaled);
80  void setDefaultBackgroundColor(const QColor & color);
81  void setBackgroundColor(const QColor & color);
82 
83  void setFeatures(const std::multimap<int, cv::KeyPoint> & refWords, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
84  void setFeatures(const std::vector<cv::KeyPoint> & features, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
85  void addFeature(int id, const cv::KeyPoint & kpt, float depth, QColor color);
86  void addLine(float x1, float y1, float x2, float y2, QColor color, const QString & text = QString());
87  void setImage(const QImage & image);
88  void setImageDepth(const cv::Mat & imageDepth);
89  void setImageDepth(const QImage & image);
90  void setFeatureColor(int id, QColor color);
91  void setFeaturesColor(QColor color);
92  void setAlpha(int alpha);
93  void setFeaturesSize(int size);
94  void setSceneRect(const QRectF & rect);
95 
96  const QMultiMap<int, rtabmap::KeypointItem *> & getFeatures() const {return _features;}
97 
98  void clearLines();
99  void clearFeatures();
100  void clear();
101 
102  virtual QSize sizeHint() const;
103 
104 Q_SIGNALS:
105  void configChanged();
106 
107 protected:
108  virtual void paintEvent(QPaintEvent *event);
109  virtual void resizeEvent(QResizeEvent* event);
110  virtual void contextMenuEvent(QContextMenuEvent * e);
111 
112 private Q_SLOTS:
113  void sceneRectChanged(const QRectF &rect);
114 
115 private:
116  void updateOpacity();
117  void computeScaleOffsets(const QRect & targetRect, float & scale, float & offsetX, float & offsetY) const;
118 
119 private:
120  QString _savedFileName;
121  int _alpha;
124 
125  QMenu * _menu;
126  QAction * _showImage;
127  QAction * _showImageDepth;
128  QAction * _showFeatures;
129  QAction * _showLines;
130  QAction * _saveImage;
131  QAction * _setAlpha;
132  QAction * _setFeaturesSize;
133  QAction * _graphicsViewMode;
141  QMenu * _scaleMenu;
142 
143  QGraphicsView * _graphicsView;
144  QMultiMap<int, rtabmap::KeypointItem *> _features;
145  QList<QGraphicsLineItem*> _lines;
146  QGraphicsPixmapItem * _imageItem;
147  QGraphicsPixmapItem * _imageDepthItem;
148  QPixmap _image;
149  QPixmap _imageDepth;
150  cv::Mat _imageDepthCv;
151 };
152 
153 }
154 
155 #endif /* IMAGEVIEW_H_ */
#define RTABMAPGUI_EXP
Definition: RtabmapGuiExp.h:38
QMultiMap< int, rtabmap::KeypointItem * > _features
Definition: ImageView.h:144
QAction * _showImageDepth
Definition: ImageView.h:127
QAction * _showLines
Definition: ImageView.h:129
QAction * _setFeaturesSize
Definition: ImageView.h:132
const QMultiMap< int, rtabmap::KeypointItem * > & getFeatures() const
Definition: ImageView.h:96
QList< QGraphicsLineItem * > _lines
Definition: ImageView.h:145
GLM_FUNC_DECL genType e()
GLM_FUNC_DECL detail::tmat4x4< T, P > scale(detail::tmat4x4< T, P > const &m, detail::tvec3< T, P > const &v)
QColor _defaultBgColor
Definition: ImageView.h:123
QAction * _showImage
Definition: ImageView.h:126
QAction * _graphicsViewScaledToHeight
Definition: ImageView.h:135
QAction * _colorMapRedToBlue
Definition: ImageView.h:139
QGraphicsView * _graphicsView
Definition: ImageView.h:143
QAction * _graphicsViewMode
Definition: ImageView.h:133
QGraphicsPixmapItem * _imageItem
Definition: ImageView.h:146
QAction * _saveImage
Definition: ImageView.h:130
QAction * _colorMapWhiteToBlack
Definition: ImageView.h:137
QMenu * _scaleMenu
Definition: ImageView.h:141
QPixmap _imageDepth
Definition: ImageView.h:149
QAction * _setAlpha
Definition: ImageView.h:131
QAction * _colorMapBlueToRed
Definition: ImageView.h:140
QAction * _showFeatures
Definition: ImageView.h:128
int getAlpha() const
Definition: ImageView.h:63
QAction * _colorMapBlackToWhite
Definition: ImageView.h:138
QString _savedFileName
Definition: ImageView.h:120
QAction * _graphicsViewNoScaling
Definition: ImageView.h:136
int getFeaturesSize() const
Definition: ImageView.h:64
cv::Mat _imageDepthCv
Definition: ImageView.h:150
QAction * _graphicsViewScaled
Definition: ImageView.h:134
QGraphicsPixmapItem * _imageDepthItem
Definition: ImageView.h:147


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