CVB++ 14.0
ImageViewItem Class Reference

Image view item for QML. More...

#include <cvb/ui/image_view_item.hpp>

Inherits QQuickPaintedItem.

Public Slots

void Refresh ()
 Refresh the currently shared image. More...
 

Public Member Functions

Q_INVOKABLE bool TryZoomIn ()
 Tries to zoom in. More...
 
Q_INVOKABLE bool TryZoomOut ()
 Tries to zoom out. More...
 
Q_INVOKABLE bool TryTranslate (const QPointF &translation)
 Tries to translate the target rectangle to a give point. More...
 
Q_INVOKABLE QPointF MapViewToTarget (const QPointF &viewPoint) const
 Maps a point from the view rectangle to the target rect. More...
 
Q_INVOKABLE QPointF MapTargetToSource (const QPointF &targetPoint) const
 Maps a point from the target rectangle to the source rect. More...
 
Q_INVOKABLE QPointF MapSourceToImage (const QPointF &sourcePoint) const
 Maps a point from the source rectangle to the image rect. More...
 
Q_INVOKABLE QPointF MapTargetToView (const QPointF &targetPoint) const
 Maps a point from the target rectangle to the view rectangle. More...
 
Q_INVOKABLE QPointF MapSourceToTarget (const QPointF &sourcePoint) const
 Maps a point from the source rectangle to the target rectangle. More...
 
Q_INVOKABLE QPointF MapImageToSource (const QPointF &imagePoint) const
 Maps a point from the image rectangle to the source rectangle. More...
 
Q_INVOKABLE QPointF MapViewToImage (const QPointF &viewPoint) const
 Maps a point from the view rectangle to the image rectangle. More...
 
QRectF ImageRect () const noexcept
 Get the rectangle described by the image buffer associated with the view. More...
 
QRectF ViewRect () const noexcept
 Get the rectangle this items covers. More...
 
QRectF TargetRect () const noexcept
 Get the rectangle inside the view rectangle the image is actually rendered to. More...
 
QRectF SourceRect () const noexcept
 Get the rectangle inside the image rectangle that is actually rendered. More...
 
int ZoomID () const
 Get the zoom identifier for special zoom steps (as integer, see Cvb::UI::ZoomID). More...
 
void SetZoomID (int id)
 Set the zoom identifier for special zoom steps (as integer, see Cvb::UI::ZoomID). More...
 
double ZoomFactor () const
 Get the view's zoom factor. More...
 
void SetZoomFactor (double factor)
 Set the view's zoom factor. More...
 
void SetImage (QObject *image)
 Set the image controller for this view item. More...
 
QPointF ViewAnchor () const noexcept
 Get the reference point for mouse operations in view coordinates. More...
 
void SetViewAnchor (const QPointF &viewAnchor)
 Set the reference point for mouse operations in view coordinates. More...
 
QPointF ImageAnchor () const noexcept
 Get the reference point for mouse operations in image coordinates. More...
 
void SetImageAnchor (const QPointF &imageAnchor)
 Set the reference point for mouse operations in image coordinates. More...
 
QVector< double > HoverPixel () const
 The image pixel value the mouse is currently hovered over. More...
 
QPointF HoverPosition () const noexcept
 Get the point the mouse is hovering over. More...
 
int UploadMode () const noexcept
 Get the current upload mode (as integer, see Cvb::UI::UploadMode). More...
 
void SetUploadMode (int uploadMode)
 Set the current upload mode (as integer). More...
 

Static Public Member Functions

template<class T >
static void Register (const char *uri, int versionMajor, int versionMinor, const char *qmlName)
 Convenience method to register this type or a derived type in QML. More...
 
static void Register ()
 Convenience method to register this type in QML. More...
 

Detailed Description

Image view item for QML.

This class (or an extended subclass) should be registered in QML. The item provides an image display. Instances should only be created from QML.

For convenience see ImageViewItem::Register

Member Function Documentation

◆ HoverPixel()

QVector< double > HoverPixel ( ) const
inline

The image pixel value the mouse is currently hovered over.

Returns
A list containing a the pixel value for each plane.
Exceptions
Doesnot throw any exception.

If the value is undefined an empty vector is returned.

Use in QML as property: hoverPixel.

◆ HoverPosition()

QPointF HoverPosition ( ) const
inlinenoexcept

Get the point the mouse is hovering over.

Returns
The point in image coordinates
Exceptions
Doesnot throw any exception.

Use in QML as property: hoverPos.

◆ ImageAnchor()

QPointF ImageAnchor ( ) const
inlinenoexcept

Get the reference point for mouse operations in image coordinates.

Returns
The reference point.
Exceptions
Doesnot throw any exception.

Use in QML as property: imageAnchor.

◆ ImageRect()

QRectF ImageRect ( ) const
inlinenoexcept

Get the rectangle described by the image buffer associated with the view.

Returns
The image rectangle
Exceptions
Doesnot throw any exception.

Use in QML as property: imageRect.

◆ MapImageToSource()

Q_INVOKABLE QPointF MapImageToSource ( const QPointF imagePoint) const
inline

Maps a point from the image rectangle to the source rectangle.

Parameters
[in]imagePointPoint to map.
Returns
Mapped point.
Exceptions
Doesnot throw any exception.

◆ MapSourceToImage()

Q_INVOKABLE QPointF MapSourceToImage ( const QPointF sourcePoint) const
inline

Maps a point from the source rectangle to the image rect.

Parameters
[in]sourcePointPoint to map.
Returns
Mapped point.
Exceptions
Doesnot throw any exception.

◆ MapSourceToTarget()

Q_INVOKABLE QPointF MapSourceToTarget ( const QPointF sourcePoint) const
inline

Maps a point from the source rectangle to the target rectangle.

Parameters
[in]sourcePointPoint to map.
Returns
Mapped point.
Exceptions
Doesnot throw any exception.

◆ MapTargetToSource()

Q_INVOKABLE QPointF MapTargetToSource ( const QPointF targetPoint) const
inline

Maps a point from the target rectangle to the source rect.

Parameters
[in]targetPointPoint to map.
Returns
Mapped point.
Exceptions
Doesnot throw any exception.

◆ MapTargetToView()

Q_INVOKABLE QPointF MapTargetToView ( const QPointF targetPoint) const
inline

Maps a point from the target rectangle to the view rectangle.

Parameters
[in]targetPointPoint to map.
Returns
Mapped point.
Exceptions
Doesnot throw any exception.

◆ MapViewToImage()

Q_INVOKABLE QPointF MapViewToImage ( const QPointF viewPoint) const
inline

Maps a point from the view rectangle to the image rectangle.

Parameters
[in]viewPointPoint to map.
Returns
Mapped point.
Exceptions
Doesnot throw any exception.

◆ MapViewToTarget()

Q_INVOKABLE QPointF MapViewToTarget ( const QPointF viewPoint) const
inline

Maps a point from the view rectangle to the target rect.

Parameters
[in]viewPointPoint to map.
Returns
Mapped point.
Exceptions
Doesnot throw any exception.

◆ Refresh

void Refresh ( )
inlineslot

Refresh the currently shared image.

Exceptions
Doesnot throw any exception.

This slot may be called from QML.

◆ Register() [1/2]

static void Register ( )
inlinestatic

Convenience method to register this type in QML.

Exceptions
Doesnot throw any exception.

This type is registered as ImageView in CvbQuick. In addition also the required enums are registered.

Examples
Cvb/QmlImageDisplay, Cvb/QmlStreamDisplay, Foundation/QmlBlobSearch, GevServer/QmlGevServer, Minos/QmlMinos, and Polimago/QmlCookieClassification.

◆ Register() [2/2]

static void Register ( const char *  uri,
int  versionMajor,
int  versionMinor,
const char *  qmlName 
)
inlinestatic

Convenience method to register this type or a derived type in QML.

Parameters
[in]uriURI forwarded to Qt.
[in]versionMajorMajor version forwarded to Qt.
[in]versionMinorMinor version forwarded to Qt.
[in]qmlNameName in QML forwarded to Qt.
Exceptions
Doesnot throw any exception.

Basically just calls qmlRegisterType. In addition also the required enums are registered.

◆ SetImage()

void SetImage ( QObject image)
inline

Set the image controller for this view item.

Parameters
[in]imageThe image controller.
Exceptions
Doesnot throw any exception.

Use in QML as property: image.

Usually you set an image controller object as context property and assign it to the view's image property.

◆ SetImageAnchor()

void SetImageAnchor ( const QPointF imageAnchor)
inline

Set the reference point for mouse operations in image coordinates.

Parameters
[in]imageAnchorThe reference point.
Exceptions
Doesnot throw any exception.

Use in QML as property: imageAnchor.

◆ SetUploadMode()

void SetUploadMode ( int  uploadMode)
inline

Set the current upload mode (as integer).

Parameters
[in]uploadModeThe new upload mode (as integer, see CVb::UI::UploadMode).
Exceptions
Anyexception derived from std::exception including CvbException.

Use in QML as property: uploadMode.

The related enum is automatically registered in QML using ImageViewItem::Register.

◆ SetViewAnchor()

void SetViewAnchor ( const QPointF viewAnchor)
inline

Set the reference point for mouse operations in view coordinates.

Parameters
[in]viewAnchorThe reference point.
Exceptions
Doesnot throw any exception.

Use in QML as property: viewAnchor.

◆ SetZoomFactor()

void SetZoomFactor ( double  factor)
inline

Set the view's zoom factor.

Parameters
[in]factorThe zoom factor
Exceptions
Doesnot throw any exception.

Use in QML as property: zoomFactor.

◆ SetZoomID()

void SetZoomID ( int  id)
inline

Set the zoom identifier for special zoom steps (as integer, see Cvb::UI::ZoomID).

Parameters
[in]idThe zoom ID.
Exceptions
Doesnot throw any exception.

Use in QML as property: zoomID.

The related enum is automatically registered in QML using ImageViewItem::Register.

◆ SourceRect()

QRectF SourceRect ( ) const
inlinenoexcept

Get the rectangle inside the image rectangle that is actually rendered.

Returns
The target rectangle
Exceptions
Doesnot throw any exception.

Use in QML as property: sourceRect.

◆ TargetRect()

QRectF TargetRect ( ) const
inlinenoexcept

Get the rectangle inside the view rectangle the image is actually rendered to.

Returns
The target rectangle
Exceptions
Doesnot throw any exception.

Use in QML as property: targetRect.

◆ TryTranslate()

Q_INVOKABLE bool TryTranslate ( const QPointF translation)
inline

Tries to translate the target rectangle to a give point.

Parameters
[in]translationPoint interpreted as vector to translate.
Returns
bool True if successful, false otherwise.
Exceptions
Doesnot throw any exception.

◆ TryZoomIn()

Q_INVOKABLE bool TryZoomIn ( )
inline

Tries to zoom in.

Returns
True if successful, false otherwise.
Exceptions
Doesnot throw any exception.

◆ TryZoomOut()

Q_INVOKABLE bool TryZoomOut ( )
inline

Tries to zoom out.

Returns
bool True if successful, false otherwise.
Exceptions
Doesnot throw any exception.

◆ UploadMode()

int UploadMode ( ) const
inlinenoexcept

Get the current upload mode (as integer, see Cvb::UI::UploadMode).

Returns
UploadMode The current upload mode (as integer).
Exceptions
Doesnot throw any exception.

Use in QML as property: uploadMode.

The related enum is automatically registered in QML using ImageViewItem::Register.

◆ ViewAnchor()

QPointF ViewAnchor ( ) const
inlinenoexcept

Get the reference point for mouse operations in view coordinates.

Returns
The reference point.
Exceptions
Doesnot throw any exception.

Use in QML as property: viewAnchor.

◆ ViewRect()

QRectF ViewRect ( ) const
inlinenoexcept

Get the rectangle this items covers.

Returns
The view rectangle
Exceptions
Doesnot throw any exception.

Use in QML as property: viewRect.

◆ ZoomFactor()

double ZoomFactor ( ) const
inline

Get the view's zoom factor.

Returns
The zoom factor.
Exceptions
Doesnot throw any exception.

Use in QML as property: zoomFactor.

◆ ZoomID()

int ZoomID ( ) const
inline

Get the zoom identifier for special zoom steps (as integer, see Cvb::UI::ZoomID).

Returns
The zoom ID.
Exceptions
Doesnot throw any exception.

Use in QML as property: zoomID.

The related enum is automatically registered in QML using ImageViewItem::Register.