ratio_layouted_frame.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, Dirk Thomas, TU Darmstadt
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
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following
13  * disclaimer in the documentation and/or other materials provided
14  * with the distribution.
15  * * Neither the name of the TU Darmstadt nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef rqt_image_view__RatioLayoutedFrame_H
34 #define rqt_image_view__RatioLayoutedFrame_H
35 
36 #include <QFrame>
37 #include <QImage>
38 #include <QLayout>
39 #include <QLayoutItem>
40 #include <QMutex>
41 #include <QPainter>
42 #include <QRect>
43 #include <QSize>
44 
45 namespace rqt_image_view {
46 
52  : public QFrame
53 {
54 
55  Q_OBJECT
56 
57 public:
58 
59  RatioLayoutedFrame(QWidget* parent, Qt::WindowFlags flags = 0);
60 
61  virtual ~RatioLayoutedFrame();
62 
63  const QImage& getImage() const;
64 
65  QImage getImageCopy() const;
66 
67  void setImage(const QImage& image);
68 
70 
72 
73  void setOuterLayout(QHBoxLayout* outer_layout);
74 
75  void setInnerFrameMinimumSize(const QSize& size);
76 
77  void setInnerFrameMaximumSize(const QSize& size);
78 
79  void setInnerFrameFixedSize(const QSize& size);
80 
81 signals:
82 
83  void delayed_update();
84 
85  void mouseLeft(int x, int y);
86 
87 protected slots:
88 
89  void onSmoothImageChanged(bool checked);
90 
91 protected:
92 
93  void setAspectRatio(unsigned short width, unsigned short height);
94 
95  void paintEvent(QPaintEvent* event);
96 
97 private:
98 
99  static int greatestCommonDivisor(int a, int b);
100 
101  void mousePressEvent(QMouseEvent * mouseEvent);
102 
103  QHBoxLayout* outer_layout_;
104 
106 
107  QImage qimage_;
108  mutable QMutex qimage_mutex_;
109 
111 };
112 
113 }
114 
115 #endif // rqt_image_view__RatioLayoutedFrame_H
void setOuterLayout(QHBoxLayout *outer_layout)
RatioLayoutedFrame(QWidget *parent, Qt::WindowFlags flags=0)
void setInnerFrameMinimumSize(const QSize &size)
static int greatestCommonDivisor(int a, int b)
void mousePressEvent(QMouseEvent *mouseEvent)
void setInnerFrameMaximumSize(const QSize &size)
void setInnerFrameFixedSize(const QSize &size)
void setAspectRatio(unsigned short width, unsigned short height)


rqt_image_view
Author(s): Dirk Thomas
autogenerated on Mon Mar 18 2019 02:53:45