roviz  0.7
Code Documentation of roviz
image_widget.h
1 #ifndef IMAGEWIDGET_H
2 #define IMAGEWIDGET_H
3 
4 #include <QRectF>
5 #include <QImage>
6 #include <QLabel>
7 #include "core/export_handling.h"
8 #include "streams/image.h"
9 #include "streams/stream_object.h"
10 #include "gui/stream_widget.h"
11 
12 class QWidget;
13 class QPaintEvent;
14 class QResizeEvent;
15 
16 // TODO Use native OpenGL (maybe that? https://github.com/Myzhar/QtOpenCVViewerGl),
17 // implement BGR display for OpenCV, just switching to QOpenGLWidget doesn't seem to work,
18 // don't know why.
29 class ROVIZ_EXPORT ImageWidget : public QLabel, public StreamWidget
30 {
31 Q_OBJECT
32 
33 public:
35 
40  void newObject(StreamObject obj) override;
41 
45  void reset(void) override;
46 
51  QWidget *qwidget(void) override;
52 
53 protected:
60  virtual void paintEvent(QPaintEvent *event) override;
61 
68  void resizeEvent(QResizeEvent *event) override;
69 
70 protected:
71  QImage image_qt;
72  Image image; // To keep a reference, prevents deletion
73  QRectF image_rect;
74 
80  void recalcImageRect(double w, double h);
81 };
82 
83 #endif // IMAGEWIDGET_H
Base class of all objects that can be transported with a stream.
Definition: stream_object.h:39
Base class for all widgets representing a StreamObject.
Definition: stream_widget.h:14
virtual void newObject(StreamObject obj)=0
Called when a new image arrived.
Private part of the Ouput class.
Definition: output_p.h:16
A widget to show images.
Definition: image_widget.h:29
virtual void reset(void)=0
Reset the widget to make it show the default image again.
A portable image class with smart memory management.
Definition: image.h:35
virtual QWidget * qwidget(void)=0
Convert this widget to a QWidget.