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 
54 
55 #include <QString>
56 #include <QFileDialog>
57 
58 class QImage;
59 class QGraphicsItem;
60 class QFileDialog;
61 class QWidget;
62 
63 namespace mira { namespace QtUtils {
64 
66 
68 MIRA_GUI_WIDGETS_EXPORT QImage makeQImage(const Img8U1& img);
69 
72 
74 MIRA_GUI_WIDGETS_EXPORT QImage makeQImage(const Img8U3& img);
75 
77 MIRA_GUI_WIDGETS_EXPORT QImage makeQImage(const Img8U4& img);
78 
84 MIRA_GUI_WIDGETS_EXPORT QImage makeQImage(const Img16U1& img, uint16_t minVal, uint16_t maxVal);
85 
91 MIRA_GUI_WIDGETS_EXPORT QImage makeQImage(const Img16S1& img, int16_t minVal, int16_t maxVal);
92 
98 MIRA_GUI_WIDGETS_EXPORT QImage makeQImage(const Img32F1& img, float minVal, float maxVal);
99 
105 MIRA_GUI_WIDGETS_EXPORT QImage makeQImage(const Img64F1& img, double minVal, double maxVal);
106 
113 MIRA_GUI_WIDGETS_EXPORT QImage makeQImage(const Img<>& img);
114 
123 MIRA_GUI_WIDGETS_EXPORT QImage makeQImage(const Img<>& img, double minVal, double maxVal);
124 
131 
142 MIRA_GUI_WIDGETS_EXPORT QImage asQImage(const Img8U1& img);
143 
146 
152 MIRA_GUI_WIDGETS_EXPORT QImage asQImage(const Img8U4& img);
153 
157 MIRA_GUI_WIDGETS_EXPORT void fromQImage(const QImage& qimage, Img<>& oImg);
158 
162 MIRA_GUI_WIDGETS_EXPORT void setTransform(QGraphicsItem* item, const RigidTransform2f& t);
163 
167 MIRA_GUI_WIDGETS_EXPORT QString getOpenFileName(QWidget* parent = NULL,
168  const QString& caption = QString(),
169  const QString& dir = QString(),
170  const QString& filter = QString(),
171  QString* selectedFilter = NULL,
172  QFileDialog::Options options = QFileDialog::DontUseNativeDialog);
173 
180 MIRA_GUI_WIDGETS_EXPORT QString getSaveFileName(QWidget* parent = NULL,
181  const QString& caption = QString(),
182  const QString& dir = QString(),
183  const QString& filter = QString(),
184  QString* selectedFilter = NULL,
185  QFileDialog::Options options = QFileDialog::DontUseNativeDialog,
186  const QStringList& enforceExtension = QStringList());
190 MIRA_GUI_WIDGETS_EXPORT QString getExistingDirectory(QWidget* parent = NULL,
191  const QString& caption = QString(),
192  const QString& dir = QString(),
193  QFileDialog::Options options = QFileDialog::DontUseNativeDialog | QFileDialog::ShowDirsOnly);
194 
198 MIRA_GUI_WIDGETS_EXPORT void initPainterFrom(QPainter& painter, const QWidget& widget);
199 
201 
202 }}
203 
204 #endif
#define MIRA_GUI_WIDGETS_EXPORT
Definition: GuiWidgetsExports.h:61
MIRA_GUI_WIDGETS_EXPORT 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...
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
MIRA_GUI_WIDGETS_EXPORT void fromQImage(const QImage &qimage, Img<> &oImg)
Convert a QImage to an image.
GUI export macro declaration.
MIRA_GUI_WIDGETS_EXPORT 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...
class for typed images.
Definition: Img.h:797
Rigid transformation class.
Header file containing Img classes that wrap cv::Mat.
MIRA_GUI_WIDGETS_EXPORT QImage asQImage(Img8U1 &img)
Create QImage wrapper for 8bit unsigned image (sharing img&#39;s memory).
MIRA_GUI_WIDGETS_EXPORT QImage makeQImage(const Img8U1 &img)
Create QImage from 8bit unsigned image.
MIRA_GUI_WIDGETS_EXPORT void setTransform(QGraphicsItem *item, const RigidTransform2f &t)
Applies a transform (translation and rotation) to a graphics scene item.
MIRA_GUI_WIDGETS_EXPORT 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...
MIRA_GUI_WIDGETS_EXPORT void initPainterFrom(QPainter &painter, const QWidget &widget)
Init painter&#39;s pen, background and font from widget.