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
rqt_image_view
Definition: image_view.h:58
rqt_image_view::RatioLayoutedFrame::getImage
const QImage & getImage() const
Definition: ratio_layouted_frame.cpp:53
rqt_image_view::RatioLayoutedFrame::resizeToFitAspectRatio
void resizeToFitAspectRatio()
Definition: ratio_layouted_frame.cpp:76
rqt_image_view::RatioLayoutedFrame::getImageCopy
QImage getImageCopy() const
Definition: ratio_layouted_frame.cpp:58
rqt_image_view::RatioLayoutedFrame::onSmoothImageChanged
void onSmoothImageChanged(bool checked)
Definition: ratio_layouted_frame.cpp:206
rqt_image_view::RatioLayoutedFrame::paintEvent
void paintEvent(QPaintEvent *event)
Definition: ratio_layouted_frame.cpp:156
rqt_image_view::RatioLayoutedFrame::getAspectRatioCorrectPaintArea
QRect getAspectRatioCorrectPaintArea()
rqt_image_view::RatioLayoutedFrame::smoothImage_
bool smoothImage_
Definition: ratio_layouted_frame.h:110
rqt_image_view::RatioLayoutedFrame::mouseLeft
void mouseLeft(int x, int y)
rqt_image_view::RatioLayoutedFrame::setInnerFrameFixedSize
void setInnerFrameFixedSize(const QSize &size)
Definition: ratio_layouted_frame.cpp:141
rqt_image_view::RatioLayoutedFrame::qimage_mutex_
QMutex qimage_mutex_
Definition: ratio_layouted_frame.h:108
rqt_image_view::RatioLayoutedFrame
Definition: ratio_layouted_frame.h:51
rqt_image_view::RatioLayoutedFrame::qimage_
QImage qimage_
Definition: ratio_layouted_frame.h:107
rqt_image_view::RatioLayoutedFrame::setAspectRatio
void setAspectRatio(unsigned short width, unsigned short height)
Definition: ratio_layouted_frame.cpp:147
rqt_image_view::RatioLayoutedFrame::mousePressEvent
void mousePressEvent(QMouseEvent *mouseEvent)
Definition: ratio_layouted_frame.cpp:197
rqt_image_view::RatioLayoutedFrame::aspect_ratio_
QSize aspect_ratio_
Definition: ratio_layouted_frame.h:105
rqt_image_view::RatioLayoutedFrame::setInnerFrameMaximumSize
void setInnerFrameMaximumSize(const QSize &size)
Definition: ratio_layouted_frame.cpp:132
rqt_image_view::RatioLayoutedFrame::outer_layout_
QHBoxLayout * outer_layout_
Definition: ratio_layouted_frame.h:103
rqt_image_view::RatioLayoutedFrame::setInnerFrameMinimumSize
void setInnerFrameMinimumSize(const QSize &size)
Definition: ratio_layouted_frame.cpp:123
rqt_image_view::RatioLayoutedFrame::~RatioLayoutedFrame
virtual ~RatioLayoutedFrame()
Definition: ratio_layouted_frame.cpp:49
rqt_image_view::RatioLayoutedFrame::delayed_update
void delayed_update()
rqt_image_view::RatioLayoutedFrame::setOuterLayout
void setOuterLayout(QHBoxLayout *outer_layout)
Definition: ratio_layouted_frame.cpp:118
rqt_image_view::RatioLayoutedFrame::RatioLayoutedFrame
RatioLayoutedFrame(QWidget *parent, Qt::WindowFlags flags=0)
Definition: ratio_layouted_frame.cpp:40
rqt_image_view::RatioLayoutedFrame::greatestCommonDivisor
static int greatestCommonDivisor(int a, int b)
Definition: ratio_layouted_frame.cpp:188
rqt_image_view::RatioLayoutedFrame::setImage
void setImage(const QImage &image)
Definition: ratio_layouted_frame.cpp:67


rqt_image_view
Author(s): Dirk Thomas , Mabel Zhang
autogenerated on Fri May 26 2023 02:31:55