MIRA
Functions
mira::QtUtils Namespace Reference

Functions

MIRA_GUI_WIDGETS_EXPORT QImage makeQImage (const Img8U1 &img)
 Create QImage from 8bit unsigned image. More...
 
MIRA_GUI_WIDGETS_EXPORT QImage makeQImage (const Img< int8, 1 > &img)
 Create QImage from 8bit signed image. More...
 
MIRA_GUI_WIDGETS_EXPORT QImage makeQImage (const Img8U3 &img)
 Create QImage from 3-channel 8bit unsigned image. More...
 
MIRA_GUI_WIDGETS_EXPORT QImage makeQImage (const Img8U4 &img)
 Create QImage from 4-channel 8bit unsigned image. More...
 
MIRA_GUI_WIDGETS_EXPORT QImage makeQImage (const Img16U1 &img, uint16_t minVal, uint16_t maxVal)
 Create QImage from 16bit unsigned image. More...
 
MIRA_GUI_WIDGETS_EXPORT QImage makeQImage (const Img16S1 &img, int16_t minVal, int16_t maxVal)
 Create QImage from 16bit signed image. More...
 
MIRA_GUI_WIDGETS_EXPORT QImage makeQImage (const Img32F1 &img, float minVal, float maxVal)
 Create QImage from float image. More...
 
MIRA_GUI_WIDGETS_EXPORT QImage makeQImage (const Img64F1 &img, double minVal, double maxVal)
 Create QImage from double image. More...
 
MIRA_GUI_WIDGETS_EXPORT QImage makeQImage (const Img<> &img)
 Create QImage from generic image, checks actual format and calls the respective specific overload for handling. More...
 
MIRA_GUI_WIDGETS_EXPORT QImage makeQImage (const Img<> &img, double minVal, double maxVal)
 Create QImage from generic image, checks actual format and calls the respective specific overload for handling. More...
 
MIRA_GUI_WIDGETS_EXPORT QImage asQImage (Img8U1 &img)
 Create QImage wrapper for 8bit unsigned image (sharing img's memory). More...
 
MIRA_GUI_WIDGETS_EXPORT QImage asQImage (const Img8U1 &img)
 Create QImage from 8bit unsigned image. More...
 
MIRA_GUI_WIDGETS_EXPORT QImage asQImage (Img8U4 &img)
 Create QImage wrapper for 4-channel 8bit unsigned image (sharing img's memory) More...
 
MIRA_GUI_WIDGETS_EXPORT QImage asQImage (const Img8U4 &img)
 Create (const) QImage wrapper for 4-channel 8bit unsigned image. More...
 
MIRA_GUI_WIDGETS_EXPORT void fromQImage (const QImage &qimage, Img<> &oImg)
 Convert a QImage to an image. More...
 
MIRA_GUI_WIDGETS_EXPORT void setTransform (QGraphicsItem *item, const RigidTransform2f &t)
 Applies a transform (translation and rotation) to a graphics scene item. More...
 
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. More...
 
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. More...
 
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. More...
 
MIRA_GUI_WIDGETS_EXPORT void initPainterFrom (QPainter &painter, const QWidget &widget)
 Init painter's pen, background and font from widget. More...
 

Function Documentation

◆ makeQImage() [1/10]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::makeQImage ( const Img8U1 img)

Create QImage from 8bit unsigned image.

◆ makeQImage() [2/10]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::makeQImage ( const Img< int8, 1 > &  img)

Create QImage from 8bit signed image.

◆ makeQImage() [3/10]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::makeQImage ( const Img8U3 img)

Create QImage from 3-channel 8bit unsigned image.

◆ makeQImage() [4/10]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::makeQImage ( const Img8U4 img)

Create QImage from 4-channel 8bit unsigned image.

◆ makeQImage() [5/10]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::makeQImage ( const Img16U1 img,
uint16_t  minVal,
uint16_t  maxVal 
)

Create QImage from 16bit unsigned image.

Pixel values are mapped from (minVal,maxVal) interval to (0,255) (and saturated).

Exceptions
XInvalidParameterif maxVal <= minVal.

◆ makeQImage() [6/10]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::makeQImage ( const Img16S1 img,
int16_t  minVal,
int16_t  maxVal 
)

Create QImage from 16bit signed image.

Pixel values are mapped from (minVal,maxVal) interval to (0,255) (and saturated).

Exceptions
XInvalidParameterif maxVal <= minVal.

◆ makeQImage() [7/10]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::makeQImage ( const Img32F1 img,
float  minVal,
float  maxVal 
)

Create QImage from float image.

Pixel values are mapped from (minVal,maxVal) interval to (0,255) (and saturated).

Exceptions
XInvalidParameterif maxVal <= minVal.

◆ makeQImage() [8/10]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::makeQImage ( const Img64F1 img,
double  minVal,
double  maxVal 
)

Create QImage from double image.

Pixel values are mapped from (minVal,maxVal) interval to (0,255) (and saturated).

Exceptions
XInvalidParameterif maxVal <= minVal.

◆ makeQImage() [9/10]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::makeQImage ( const Img<> &  img)

Create QImage from generic image, checks actual format and calls the respective specific overload for handling.

Exceptions
XNotImplementedif conversion is not implemented for image pixel format.
XInvalidParameterif image pixel format is other than 8bit (single or multi channel).

◆ makeQImage() [10/10]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::makeQImage ( const Img<> &  img,
double  minVal,
double  maxVal 
)

Create QImage from generic image, checks actual format and calls the respective specific overload for handling.

Pixel values are mapped from (minVal,maxVal) interval to (0,255) (and saturated).

Exceptions
XNotImplementedif conversion is not implemented for image pixel format.
XInvalidParameterif image pixel format is 8bit (single or multi channel).
XInvalidParameterif maxVal <= minVal.

◆ asQImage() [1/4]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::asQImage ( Img8U1 img)

Create QImage wrapper for 8bit unsigned image (sharing img's memory).

QImage requires all image data to be 32bit-aligned, so this throws XInvalidParameter if img.step() does not return a multiple of 4.

◆ asQImage() [2/4]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::asQImage ( const Img8U1 img)

Create QImage from 8bit unsigned image.

QImage requires all image data to be 32bit-aligned, so this throws XInvalidParameter if img.step() does not return a multiple of 4.

The required setColorTable() will trigger a deep-copy internally (as originally shared image data is read-only in the const& case), so the resulting QImage will NOT share memory of the input img and there is no real advantage over makeQImage().

Note
This limitation may change in Qt 6.4 or later. See #882 comment 2.

◆ asQImage() [3/4]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::asQImage ( Img8U4 img)

Create QImage wrapper for 4-channel 8bit unsigned image (sharing img's memory)

◆ asQImage() [4/4]

MIRA_GUI_WIDGETS_EXPORT QImage mira::QtUtils::asQImage ( const Img8U4 img)

Create (const) QImage wrapper for 4-channel 8bit unsigned image.

This will share img's memory, but mark it read-only. Non-const access to the QImage will result in automatic deep-copying.

◆ fromQImage()

MIRA_GUI_WIDGETS_EXPORT void mira::QtUtils::fromQImage ( const QImage &  qimage,
Img<> &  oImg 
)

Convert a QImage to an image.

◆ setTransform()

MIRA_GUI_WIDGETS_EXPORT void mira::QtUtils::setTransform ( QGraphicsItem *  item,
const RigidTransform2f t 
)

Applies a transform (translation and rotation) to a graphics scene item.

Examples:
tutorials/Point2Visualization.C.

◆ getOpenFileName()

MIRA_GUI_WIDGETS_EXPORT QString mira::QtUtils::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.

◆ getSaveFileName()

MIRA_GUI_WIDGETS_EXPORT QString mira::QtUtils::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.

Parameters
[in]enforceExtensionIf a non-empty list is provided as argument, the method will make sure one of these extensions is selected, replacing the extension entered by the user with the first element in the list if necessary.

◆ getExistingDirectory()

MIRA_GUI_WIDGETS_EXPORT QString mira::QtUtils::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.

◆ initPainterFrom()

MIRA_GUI_WIDGETS_EXPORT void mira::QtUtils::initPainterFrom ( QPainter &  painter,
const QWidget &  widget 
)

Init painter's pen, background and font from widget.

Replaces QPainter::initFrom(QPaintDevice*) deprecated in Qt5.15.