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 
143 QImage asQImage(const Img8U1& img);
144 
146 QImage asQImage(Img8U4& img);
147 
153 QImage asQImage(const Img8U4& img);
154 
158 void fromQImage(const QImage& qimage, Img<>& oImg);
159 
163 void setTransform(QGraphicsItem* item, const RigidTransform2f& t);
164 
168 QString getOpenFileName(QWidget* parent = NULL,
169  const QString& caption = QString(),
170  const QString& dir = QString(),
171  const QString& filter = QString(),
172  QString* selectedFilter = NULL,
173  QFileDialog::Options options = QFileDialog::DontUseNativeDialog);
174 
181 QString getSaveFileName(QWidget* parent = NULL,
182  const QString& caption = QString(),
183  const QString& dir = QString(),
184  const QString& filter = QString(),
185  QString* selectedFilter = NULL,
186  QFileDialog::Options options = QFileDialog::DontUseNativeDialog,
187  const QStringList& enforceExtension = QStringList());
191 QString getExistingDirectory(QWidget* parent = NULL,
192  const QString& caption = QString(),
193  const QString& dir = QString(),
194  QFileDialog::Options options = QFileDialog::DontUseNativeDialog | QFileDialog::ShowDirsOnly);
195 
199 void initPainterFrom(QPainter& painter, const QWidget& widget);
200 
209 void configureQtForRunningOgreOnWayland(bool useStdOutForMsgs = true);
210 
212 
213 }}
214 
215 #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 configureQtForRunningOgreOnWayland(bool useStdOutForMsgs=true)
This function checks if the system is running on Wayland.
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.