NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
layout.hpp
1 //This package is based on rqt_image_view package. (for copyright notes, please read the ReadMe.txt)
2 // Author: Hafez Farazi <farazi@ais.uni-bonn.de>
3 #pragma once
4 #include <opencv2/opencv.hpp>
5 #include <rqt_vision_module/mouseevent.hpp>
6 #include <QLayout>
7 #include <QFrame>
8 #include <QLayoutItem>
9 #include <QSize>
10 #include <QMutex>
11 #include <QRect>
12 #include <QImage>
13 #include <QPainter>
14 #include <QMouseEvent>
15 #include <QDebug>
16 
17 
18 using namespace cv;
19 
20 namespace rqt_vision_module
21 {
22 
23 class RatioLayoutedFrame: public QFrame
24 {
25 
26 Q_OBJECT
27 
28 public:
29 
30  mutable QMutex output_mutex_;
31 
32  Point2d ClickedPoint;
33 
34  QList<QString> listText;
35 
36  RatioLayoutedFrame(QWidget* parent, Qt::WFlags flags = 0);
37 
38  virtual ~RatioLayoutedFrame();
39 
40  const QImage& getImage() const;
41 
42  QImage getImageCopy() const;
43 
44  void setImage(const QImage& image);
45 
46  QRect getAspectRatioCorrectPaintArea();
47 
48  void resizeToFitAspectRatio();
49 
50  void setInnerFrameMinimumSize(const QSize& size);
51 
52  void setInnerFrameMaximumSize(const QSize& size);
53 
54  void setInnerFrameFixedSize(const QSize& size);
55 
56  signals:
57 
58  void delayed_update();
59  void mouseEvent(MouseEvent event, float x, float y);
60 
61 protected:
62 
63  void setAspectRatio(unsigned short width, unsigned short height);
64 
65  virtual void mousePressEvent(QMouseEvent * event);
66  virtual void mouseReleaseEvent(QMouseEvent * event);
67  virtual void wheelEvent(QWheelEvent* event);
68 
69  virtual void paintEvent(QPaintEvent* event);
70  virtual bool eventFilter(QObject *obj, QEvent *event);
71 
72 private:
73  static int greatestCommonDivisor(int a, int b);
74  Point2f getMousePos(QMouseEvent *event);
75 
76 private:
77  QSize aspect_ratio_;
78 
79  mutable QMutex qimage_mutex_;
80  QImage qimage_;
81 };
82 
83 }