Kuesa Runtime

PlaceholderTracker Class

class Kuesa::PlaceholderTracker

PlaceholderTracker allows watching a placeholder for changes and computing a screen position changes given a window size and a camera. More...

Header: #include <PlaceholderTracker>
Since: Kuesa 1.3
Instantiated By: PlaceholderTracker
Inherits: Kuesa::KuesaNode

This class was introduced in Kuesa 1.3.

Properties

Public Functions

Qt3DCore::QEntity *camera() const
int height() const
QString name() const
QPointF screenPosition() const
QSize screenSize() const
QObject *target() const
QRectF viewportRect() const
int width() const
int x() const
int y() const

Public Slots

void setCamera(Qt3DCore::QEntity *camera)
void setName(const QString &name)
void setScreenSize(const QSize &screenSize)
void setTarget(QObject *target)
void setViewportRect(qreal x, qreal y, qreal width, qreal height)
void setViewportRect(const QRectF &viewportRect)

Signals

void cameraChanged(Qt3DCore::QEntity *camera)
void heightChanged(int height)
void nameChanged(const QString &name)
void screenPositionChanged(const QPointF &screenPosition)
void screenSizeChanged(const QSize &screenSize)
void targetChanged(QObject *target)
void viewportRectChanged(QRectF viewportRect)
void widthChanged(int width)
void xChanged(int x)
void yChanged(int y)

Detailed Description

PlaceholderTracker allows watching a placeholder for changes and computing a screen position changes given a window size and a camera.

This is especially useful to easily map 2D content based on a 3D placeholder. It does so by projecting a plane defined by the Kuesa::Placeholder facing the camera to screen space. setting the x, y, width and height properties of a target QObject to match the projected rectangle

 Kuesa::SceneEntity *sceneEntity = new Kuesa::SceneEntity();
 Kuesa::PlaceholderTracker *tracker = new Kuesa::PlaceholderTracker();
 Qt3DRender::QCamera *camera = new Qt3DRender::Camera();
 QObject *target = new QObject(); // Our UI target

 tracker->setSceneEntity(sceneEntity);
 tracker->setName(QStringLiteral("MyPlaceholder");
 tracker->setCamera(camera);
 tracker->setScreenSize({512, 512});
 tracker->setTarget(target);

Read more about Kuesa Placeholders.

See also Kuesa::Placeholder.

Property Documentation

camera : Qt3DCore::QEntity*

Holds the camera the placeholder is facing and which is used to project the plane to screen space.

 QQuickItem *target = view->rootItem();
 Kuesa::PlaceholderTracker *placeholderTracker = new Kuesa::PlaceholderTracker();
 placeholderTracker->setName(QStringliteral("placeholder"));
 Qt3DRender::QCamera *camera = sceneEntity->camera(QStringliteral("Camera_Orientation"));
 placeholderTracker->setSceneSize({view.width(), view.height()});
 placeholderTracker->setTarget(target);
 placeholderTracker->setCamera(camera);

Note: using a Qt3DRender::QCamera for the placeholderTracker different than the one being used for the render might give unexpected results.

Access functions:

Qt3DCore::QEntity *camera() const
void setCamera(Qt3DCore::QEntity *camera)

Notifier signal:

void cameraChanged(Qt3DCore::QEntity *camera)

height : const int

Holds the height in screen coordinates computed from the placeholder.

Access functions:

int height() const

Notifier signal:

void heightChanged(int height)

name : QString

Holds the name of the Placeholder instance to retrieve from the Kuesa::SceneEntity.

Access functions:

QString name() const
void setName(const QString &name)

Notifier signal:

void nameChanged(const QString &name)

screenPosition : const QPointF

Holds the screenPosition computed from the placeholder.

Access functions:

QPointF screenPosition() const

Notifier signal:

void screenPositionChanged(const QPointF &screenPosition)

screenSize : QSize

Holds the size of the area within which we should compute screen positions. This would usually be the size of the window or the size of the sub view within the window.

Access functions:

QSize screenSize() const
void setScreenSize(const QSize &screenSize)

Notifier signal:

void screenSizeChanged(const QSize &screenSize)

target : QObject*

Holds the target object on which to set x, y, width and height properties computed from the Placeholder and Camera transformations.

Commonly it would be a QtQuick element and should be used as

 QQuickItem *target = view->rootItem();
 Kuesa::PlaceholderTracker *placeholderTracker = new Kuesa::PlaceholderTracker();
 placeholder->setName(QStringliteral("placeholder"));
 placeholder->setScreenSize({view.width(), view.height()});
 placeholder->setTarget(target);

Access functions:

QObject *target() const
void setTarget(QObject *target)

Notifier signal:

void targetChanged(QObject *target)

viewportRect : QRectF

Holds the normalized viewport rectangle defining the area into which screen positions should be computed. If unspecified QRectF(0.0f, 0.0f, 1.0f, 1.0f) will be used.

Access functions:

QRectF viewportRect() const
void setViewportRect(const QRectF &viewportRect)
void setViewportRect(qreal x, qreal y, qreal width, qreal height)

Notifier signal:

void viewportRectChanged(QRectF viewportRect)

width : const int

Holds the width in screen coordinates computed from the placeholder.

Access functions:

int width() const

Notifier signal:

void widthChanged(int width)

x : const int

Holds the top left x screen position coordinate computed from the placeholder.

Access functions:

int x() const

Notifier signal:

void xChanged(int x)

y : const int

Holds the top left y screen position coordinate computed from the placeholder.

Access functions:

int y() const

Notifier signal:

void yChanged(int y)