MIRA
QtUtils.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
47 #ifndef _MIRA_QTUTILS_H_
48 #define _MIRA_QTUTILS_H_
49 
50 #include <image/Img.h>
52 
53 #include <QString>
54 #include <QFileDialog>
55 
56 class QImage;
57 class QGraphicsItem;
58 class QFileDialog;
59 class QWidget;
60 
61 namespace mira { namespace QtUtils {
62 
64 
66 QImage makeQImage(const Img8U1& img);
67 
69 QImage makeQImage(const Img<int8, 1>& img);
70 
72 QImage makeQImage(const Img8U3& img);
73 
75 QImage makeQImage(const Img8U4& img);
76 
82 QImage makeQImage(const Img16U1& img, uint16_t minVal, uint16_t maxVal);
83 
89 QImage makeQImage(const Img16S1& img, int16_t minVal, int16_t maxVal);
90 
96 QImage makeQImage(const Img32F1& img, float minVal, float maxVal);
97 
103 QImage makeQImage(const Img64F1& img, double minVal, double maxVal);
104 
111 QImage makeQImage(const Img<>& img);
112 
121 QImage makeQImage(const Img<>& img, double minVal, double maxVal);
122 
128 QImage asQImage(Img8U1& img);
129 
140 QImage asQImage(const Img8U1& img);
141 
143 QImage asQImage(Img8U4& img);
144 
150 QImage asQImage(const Img8U4& img);
151 
155 void fromQImage(const QImage& qimage, Img<>& oImg);
156 
160 void setTransform(QGraphicsItem* item, const RigidTransform2f& t);
161 
165 QString getOpenFileName(QWidget* parent = NULL,
166  const QString& caption = QString(),
167  const QString& dir = QString(),
168  const QString& filter = QString(),
169  QString* selectedFilter = NULL,
170  QFileDialog::Options options = QFileDialog::DontUseNativeDialog);
171 
178 QString getSaveFileName(QWidget* parent = NULL,
179  const QString& caption = QString(),
180  const QString& dir = QString(),
181  const QString& filter = QString(),
182  QString* selectedFilter = NULL,
183  QFileDialog::Options options = QFileDialog::DontUseNativeDialog,
184  const QStringList& enforceExtension = QStringList());
188 QString getExistingDirectory(QWidget* parent = NULL,
189  const QString& caption = QString(),
190  const QString& dir = QString(),
191  QFileDialog::Options options = QFileDialog::DontUseNativeDialog | QFileDialog::ShowDirsOnly);
192 
196 void initPainterFrom(QPainter& painter, const QWidget& widget);
197 
199 
200 }}
201 
202 #endif
QString getExistingDirectory(QWidget *parent=NULL, const QString &caption=QString(), const QString &dir=QString(), QFileDialog::Options options=QFileDialog::DontUseNativeDialog|QFileDialog::ShowDirsOnly)
Enforce the use of non-native FileDialog-methods to prevent platform depending behavior differences...
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
void fromQImage(const QImage &qimage, Img<> &oImg)
Convert a QImage to an image.
QString getSaveFileName(QWidget *parent=NULL, const QString &caption=QString(), const QString &dir=QString(), const QString &filter=QString(), QString *selectedFilter=NULL, QFileDialog::Options options=QFileDialog::DontUseNativeDialog, const QStringList &enforceExtension=QStringList())
Enforce the use of non-native FileDialog-methods to prevent platform depending behavior differences...
QString getOpenFileName(QWidget *parent=NULL, const QString &caption=QString(), const QString &dir=QString(), const QString &filter=QString(), QString *selectedFilter=NULL, QFileDialog::Options options=QFileDialog::DontUseNativeDialog)
Enforce the use of non-native FileDialog-methods to prevent platform depending behavior differences...
class for typed images.
Definition: Img.h:797
Rigid transformation class.
QImage asQImage(Img8U1 &img)
Create QImage wrapper for 8bit unsigned image (sharing img&#39;s memory).
Header file containing Img classes that wrap cv::Mat.
void initPainterFrom(QPainter &painter, const QWidget &widget)
Init painter&#39;s pen, background and font from widget.
QImage makeQImage(const Img8U1 &img)
Create QImage from 8bit unsigned image.
void setTransform(QGraphicsItem *item, const RigidTransform2f &t)
Applies a transform (translation and rotation) to a graphics scene item.