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 RTABMAP_IMAGEVIEW_H_
00029 #define RTABMAP_IMAGEVIEW_H_
00030
00031 #include "rtabmap/gui/RtabmapGuiExp.h"
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 int getFeaturesSize() const {return _featuresSize;}
00065 bool isGraphicsViewMode() const;
00066 bool isGraphicsViewScaled() const;
00067 bool isGraphicsViewScaledToHeight() const;
00068 const QColor & getDefaultBackgroundColor() const;
00069 const QColor & getBackgroundColor() const;
00070
00071 float viewScale() const;
00072
00073 void setFeaturesShown(bool shown);
00074 void setImageShown(bool shown);
00075 void setImageDepthShown(bool shown);
00076 void setLinesShown(bool shown);
00077 void setGraphicsViewMode(bool on);
00078 void setGraphicsViewScaled(bool scaled);
00079 void setGraphicsViewScaledToHeight(bool scaled);
00080 void setDefaultBackgroundColor(const QColor & color);
00081 void setBackgroundColor(const QColor & color);
00082
00083 void setFeatures(const std::multimap<int, cv::KeyPoint> & refWords, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
00084 void setFeatures(const std::vector<cv::KeyPoint> & features, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
00085 void addFeature(int id, const cv::KeyPoint & kpt, float depth, QColor color);
00086 void addLine(float x1, float y1, float x2, float y2, QColor color, const QString & text = QString());
00087 void setImage(const QImage & image);
00088 void setImageDepth(const cv::Mat & imageDepth);
00089 void setImageDepth(const QImage & image);
00090 void setFeatureColor(int id, QColor color);
00091 void setFeaturesColor(QColor color);
00092 void setAlpha(int alpha);
00093 void setFeaturesSize(int size);
00094 void setSceneRect(const QRectF & rect);
00095
00096 const QMultiMap<int, rtabmap::KeypointItem *> & getFeatures() const {return _features;}
00097
00098 void clearLines();
00099 void clearFeatures();
00100 void clear();
00101
00102 virtual QSize sizeHint() const;
00103
00104 Q_SIGNALS:
00105 void configChanged();
00106
00107 protected:
00108 virtual void paintEvent(QPaintEvent *event);
00109 virtual void resizeEvent(QResizeEvent* event);
00110 virtual void contextMenuEvent(QContextMenuEvent * e);
00111
00112 private Q_SLOTS:
00113 void sceneRectChanged(const QRectF &rect);
00114
00115 private:
00116 void updateOpacity();
00117 void computeScaleOffsets(const QRect & targetRect, float & scale, float & offsetX, float & offsetY) const;
00118
00119 private:
00120 QString _savedFileName;
00121 int _alpha;
00122 int _featuresSize;
00123 QColor _defaultBgColor;
00124
00125 QMenu * _menu;
00126 QAction * _showImage;
00127 QAction * _showImageDepth;
00128 QAction * _showFeatures;
00129 QAction * _showLines;
00130 QAction * _saveImage;
00131 QAction * _setAlpha;
00132 QAction * _setFeaturesSize;
00133 QAction * _graphicsViewMode;
00134 QAction * _graphicsViewScaled;
00135 QAction * _graphicsViewScaledToHeight;
00136 QAction * _graphicsViewNoScaling;
00137 QAction * _colorMapWhiteToBlack;
00138 QAction * _colorMapBlackToWhite;
00139 QAction * _colorMapRedToBlue;
00140 QAction * _colorMapBlueToRed;
00141 QMenu * _scaleMenu;
00142
00143 QGraphicsView * _graphicsView;
00144 QMultiMap<int, rtabmap::KeypointItem *> _features;
00145 QList<QGraphicsLineItem*> _lines;
00146 QGraphicsPixmapItem * _imageItem;
00147 QGraphicsPixmapItem * _imageDepthItem;
00148 QPixmap _image;
00149 QPixmap _imageDepth;
00150 cv::Mat _imageDepthCv;
00151 };
00152
00153 }
00154
00155 #endif