VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
ImageRenderer Class Reference

Graphic which displays a texture as an image. More...

Inheritance diagram for ImageRenderer:
Graphic RenderableInterface QQuickItem QObject QQmlParserStatus AnimatedImageRenderer MagneticHighlight

Signals

void visibleChanged ()
 Emitted when visible changes. More...
 
void sizeScaleChanged ()
 Emitted when sizeScale changes. More...
 
void aspectRatioChanged ()
 Emitted when aspectRatio changes. More...
 
void sourceChanged ()
 Emitted when source changes. More...
 
void cacheRenderParamsChanged ()
 Emitted when cacheRenderParams changes. More...
 
void cullingControlsBodyActiveChanged ()
 Emitted when cullingControlsBodyActive changes. More...
 

Public Member Functions

 ImageRenderer (QQuickItem *parent=nullptr)
 Construct an ImageRenderer. More...
 
bool isVisible () const
 Returns visible. More...
 
void setVisible (bool value)
 Sets visible. More...
 
float getSizeScale () const
 Returns sizeScale. More...
 
void setSizeScale (float value)
 Sets sizeScale. More...
 
float getAspectRatio () const
 Returns aspectRatio. More...
 
void setAspectRatio (float value)
 Sets aspectRatio. More...
 
const QStringgetSource () const
 Returns source. More...
 
void setSource (const QString &value)
 Sets source. More...
 
bool getCacheRenderParams () const
 Returns cacheRenderParams. More...
 
void setCacheRenderParams (bool value)
 Sets cacheRenderParams. More...
 
bool getCullingControlsBodyActive () const
 Returns cullingControlsBodyActive. More...
 
void setCullingControlsBodyActive (bool value)
 Sets cullingControlsBodyActive. More...
 
bool isCulled () const
 Returns whether or not this image has been culled because it is off screen. More...
 
- Public Member Functions inherited from Graphic
 Graphic (QQuickItem *parent=nullptr)
 Construct a Graphic. More...
 
- Public Member Functions inherited from QQuickItem
 QQuickItem (QQuickItem *parent)
 
QQuickWindowwindow () const
 
QQuickItemparentItem () const
 
void setParentItem (QQuickItem *parent)
 
void stackBefore (const QQuickItem *sibling)
 
void stackAfter (const QQuickItem *sibling)
 
QRectF childrenRect ()
 
QList< QQuickItem * > childItems () const
 
bool clip () const
 
void setClip (bool)
 
QString state () const
 
void setState (const QString &)
 
qreal baselineOffset () const
 
void setBaselineOffset (qreal)
 
qreal x () const
 
qreal y () const
 
void setX (qreal)
 
void setY (qreal)
 
qreal width () const
 
void setWidth (qreal)
 
void resetWidth ()
 
void setImplicitWidth (qreal)
 
qreal implicitWidth () const
 
qreal height () const
 
void setHeight (qreal)
 
void resetHeight ()
 
void setImplicitHeight (qreal)
 
qreal implicitHeight () const
 
TransformOrigin transformOrigin () const
 
void setTransformOrigin (TransformOrigin)
 
qreal z () const
 
void setZ (qreal)
 
qreal rotation () const
 
void setRotation (qreal)
 
qreal scale () const
 
void setScale (qreal)
 
qreal opacity () const
 
void setOpacity (qreal)
 
bool isVisible () const
 
void setVisible (bool)
 
bool isEnabled () const
 
void setEnabled (bool)
 
bool smooth () const
 
void setSmooth (bool)
 
bool activeFocusOnTab () const
 
void setActiveFocusOnTab (bool)
 
bool antialiasing () const
 
void setAntialiasing (bool)
 
void resetAntialiasing ()
 
Flags flags () const
 
void setFlag (Flag flag, bool enabled)
 
void setFlags (QFlags< QQuickItem::Flag > flags)
 
bool hasActiveFocus () const
 
bool hasFocus () const
 
void setFocus (bool)
 
void setFocus (bool focus, Qt::FocusReason reason)
 
bool isFocusScope () const
 
QQuickItemscopedFocusItem () const
 
Qt::MouseButtons acceptedMouseButtons () const
 
void setAcceptedMouseButtons (Qt::MouseButtons buttons)
 
bool acceptHoverEvents () const
 
void setAcceptHoverEvents (bool enabled)
 
QCursor cursor () const
 
void setCursor (const QCursor &cursor)
 
void unsetCursor ()
 
void grabMouse ()
 
void ungrabMouse ()
 
bool keepMouseGrab () const
 
void setKeepMouseGrab (bool keep)
 
bool filtersChildMouseEvents () const
 
void setFiltersChildMouseEvents (bool filter)
 
void grabTouchPoints (const QVector< int > &ids)
 
void ungrabTouchPoints ()
 
bool keepTouchGrab () const
 
void setKeepTouchGrab (bool keep)
 
virtual bool contains (const QPointF &point) const
 
QPointF mapToItem (const QQuickItem *item, const QPointF &point) const
 
QPointF mapToScene (const QPointF &point) const
 
QRectF mapRectToItem (const QQuickItem *item, const QRectF &rect) const
 
QRectF mapRectToScene (const QRectF &rect) const
 
QPointF mapFromItem (const QQuickItem *item, const QPointF &point) const
 
QPointF mapFromScene (const QPointF &point) const
 
QRectF mapRectFromItem (const QQuickItem *item, const QRectF &rect) const
 
QRectF mapRectFromScene (const QRectF &rect) const
 
void polish ()
 
void forceActiveFocus ()
 
void forceActiveFocus (Qt::FocusReason reason)
 
QQuickItemnextItemInFocusChain (bool forward)
 
QQuickItemchildAt (qreal x, qreal y) const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
virtual bool isTextureProvider () const
 
virtual QSGTextureProvidertextureProvider () const
 
void update ()
 
void windowChanged (QQuickWindow *window)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
virtual const QMetaObjectmetaObject () const
 
QString objectName () const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const
 
bool blockSignals (bool block)
 
QThreadthread () const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegExp &regExp, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegularExpression &re, QFlags< Qt::FindChildOption > options) const
 
const QObjectList & children () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const
 
bool disconnect (const QObject *receiver, const char *method) const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const
 
bool inherits (const char *className) const
 
void deleteLater ()
 
- Public Member Functions inherited from QQmlParserStatus
virtual void classBegin ()=0
 
virtual void componentComplete ()=0
 

Protected Member Functions

virtual void synchronizeForRendering (RenderList *renderList) override
 Synchronize this Graphic for rendering, adding any RenderNodes to renderList, and buffering any data that will be needed on the render thread for rendering. More...
 
virtual void render (RenderNode *node) override
 Renders the associated node. More...
 
virtual void componentComplete () override
 Post-initialization that checks for the existence of a parent Actor and the parent Actor's Body, caching the results for use in rendering. More...
 
virtual void computeDestTextureSize (QSizeF *textureSize) const
 Computes the size to treat the source Texture, for purposes of computing destination rectangle size. More...
 
virtual void computeSourceTextureRect (QRectF *textureSubRect) const
 Computes the subrectangle within the source Texture to render. More...
 
void markSourceTextureRectDirty ()
 Marks the texture rectangle as dirty, making ImageRenderer update. More...
 
- Protected Member Functions inherited from Graphic
void getFlattenedRenderParameters (RenderParameters *parameters)
 Compute the rendering parameters and transform of this Graphic by moving up the QQuickItem tree and accumulating results. More...
 
- Protected Member Functions inherited from QQuickItem
virtual bool event (QEvent *ev)
 
bool isComponentComplete () const
 
virtual void itemChange (ItemChange change, const ItemChangeData &value)
 
void updateInputMethod (Qt::InputMethodQueries queries)
 
bool widthValid () const
 
bool heightValid () const
 
virtual void classBegin ()
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual void focusInEvent (QFocusEvent *event)
 
virtual void focusOutEvent (QFocusEvent *event)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void mouseUngrabEvent ()
 
virtual void touchUngrabEvent ()
 
virtual void wheelEvent (QWheelEvent *event)
 
virtual void touchEvent (QTouchEvent *event)
 
virtual void hoverEnterEvent (QHoverEvent *event)
 
virtual void hoverMoveEvent (QHoverEvent *event)
 
virtual void hoverLeaveEvent (QHoverEvent *event)
 
virtual void dragEnterEvent (QDragEnterEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event)
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dropEvent (QDropEvent *event)
 
virtual bool childMouseEventFilter (QQuickItem *item, QEvent *event)
 
virtual void geometryChanged (const QRectF &newGeometry, const QRectF &oldGeometry)
 
virtual QSGNodeupdatePaintNode (QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData)
 
virtual void releaseResources ()
 
virtual void updatePolish ()
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Properties

bool visible
 Override of QQuickItem's visible property to set visibility. More...
 
float sizeScale
 Width of this image, in world coordinates. More...
 
float aspectRatio
 Height of this image, as a ratio of the width. More...
 
QString source
 Path to the source texture. More...
 
bool cacheRenderParams
 Controls whether or not the position, rotation, opacity, and z-depth are cached on first render, and cached copies are used subsequently. More...
 
bool cullingControlsBodyActive
 Controls whether or not the Actor's associated Body's Body::active property is linked to this image's visibility. More...
 
- Properties inherited from QQuickItem
 parent
 
 x
 
 y
 
 z
 
 width
 
 height
 
 opacity
 
 enabled
 
 visible
 
 state
 
 childrenRect
 
 baselineOffset
 
 clip
 
 focus
 
 activeFocus
 
 activeFocusOnTab
 
 rotation
 
 scale
 
 transformOrigin
 
 smooth
 
 antialiasing
 
 implicitWidth
 
 implicitHeight
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
- Public Attributes inherited from QQuickItem
typedef Flags
 

Detailed Description

Graphic which displays a texture as an image.

The texture is loaded and cached using TextureManager. This class also performs a crude scissor test to cull images from view, reducing the load on the geometry batch merger freeing up CPU time.

Constructor & Destructor Documentation

ImageRenderer::ImageRenderer ( QQuickItem parent = nullptr)
explicit

Construct an ImageRenderer.

Parameters
parentParent item

Member Function Documentation

void ImageRenderer::aspectRatioChanged ( )
signal

Emitted when aspectRatio changes.

void ImageRenderer::cacheRenderParamsChanged ( )
signal

Emitted when cacheRenderParams changes.

virtual void ImageRenderer::componentComplete ( )
overrideprotectedvirtual

Post-initialization that checks for the existence of a parent Actor and the parent Actor's Body, caching the results for use in rendering.

Reimplemented from QQuickItem.

virtual void ImageRenderer::computeDestTextureSize ( QSizeF textureSize) const
protectedvirtual

Computes the size to treat the source Texture, for purposes of computing destination rectangle size.

The actual texture size is passed in as textureSize. The desired texture size should be written back to textureSize.

Note
This can be used in conjunction with computeSourceTextureRect() to select a subrectangle of the source texture for rendering.
The default implementation leaves textureSize unmodified.
Parameters
textureSizeActual texture size, also receiving desired texture size

Reimplemented in AnimatedImageRenderer.

virtual void ImageRenderer::computeSourceTextureRect ( QRectF textureSubRect) const
protectedvirtual

Computes the subrectangle within the source Texture to render.

textureSubRect initially contains a unit rectangle from (0.0f, 0.0f) to (1.0f, 1.0f). The desired subrectangle should be written to textureSubRect by this function.

Note
This can be used in conjunction with computeDestTextureSize() to select a subrectangle of the source texture for rendering.
The default implementation leaves textureSubRect unmodified.
Parameters
textureSubRect

Reimplemented in AnimatedImageRenderer.

void ImageRenderer::cullingControlsBodyActiveChanged ( )
signal

Emitted when cullingControlsBodyActive changes.

float ImageRenderer::getAspectRatio ( ) const
inline

Returns aspectRatio.

bool ImageRenderer::getCacheRenderParams ( ) const
inline
bool ImageRenderer::getCullingControlsBodyActive ( ) const
inline
float ImageRenderer::getSizeScale ( ) const
inline

Returns sizeScale.

const QString& ImageRenderer::getSource ( ) const
inline

Returns source.

bool ImageRenderer::isCulled ( ) const
inline

Returns whether or not this image has been culled because it is off screen.

bool ImageRenderer::isVisible ( ) const
inline

Returns visible.

void ImageRenderer::markSourceTextureRectDirty ( )
protected

Marks the texture rectangle as dirty, making ImageRenderer update.

virtual void ImageRenderer::render ( RenderNode node)
overrideprotectedvirtual

Renders the associated node.

This method should be implemented to issue GL draw calls to render the visuals associated with the given RenderNode node. This can be done using the draw calls in Renderer, (i.e. Renderer::drawMesh()), direct GL calls, or some other mechanism. It is up to the user to ensure GL state is correctly preserved as necessary.

Note
The parameter node can be used to render multiple RenderNodes in a single implementer.
Parameters
nodeRenderNode that is being rendered

Implements RenderableInterface.

void ImageRenderer::setAspectRatio ( float  value)

Sets aspectRatio.

Parameters
valueFloat to set aspectRatio to
void ImageRenderer::setCacheRenderParams ( bool  value)

Sets cacheRenderParams.

Parameters
valueBoolean to set cacheRenderParams to
void ImageRenderer::setCullingControlsBodyActive ( bool  value)

Sets cullingControlsBodyActive.

Parameters
valueBoolean to set cullingControlsBodyActive to
void ImageRenderer::setSizeScale ( float  value)

Sets sizeScale.

Parameters
valueFloat to set sizeScale to
void ImageRenderer::setSource ( const QString value)

Sets source.

Parameters
valueQString to set source to
void ImageRenderer::setVisible ( bool  value)

Sets visible.

Parameters
valueBoolean to set visible to
void ImageRenderer::sizeScaleChanged ( )
signal

Emitted when sizeScale changes.

void ImageRenderer::sourceChanged ( )
signal

Emitted when source changes.

virtual void ImageRenderer::synchronizeForRendering ( RenderList renderList)
overrideprotectedvirtual

Synchronize this Graphic for rendering, adding any RenderNodes to renderList, and buffering any data that will be needed on the render thread for rendering.

Parameters
renderListRenderList to add RenderNodes to for rendering in sorted order

Reimplemented from Graphic.

Reimplemented in AnimatedImageRenderer.

void ImageRenderer::visibleChanged ( )
signal

Emitted when visible changes.

Property Documentation

float ImageRenderer::aspectRatio
readwrite

Height of this image, as a ratio of the width.

bool ImageRenderer::cacheRenderParams
readwrite

Controls whether or not the position, rotation, opacity, and z-depth are cached on first render, and cached copies are used subsequently.

This improves performance, but creates stale data if the Actor is moving or transforming.

See also
Graphic::RenderParameters
bool ImageRenderer::cullingControlsBodyActive
readwrite

Controls whether or not the Actor's associated Body's Body::active property is linked to this image's visibility.

If this property is true, when this image is culled or its visible is set to false, the associated Body will be deactivated. The Body is found through the Actor::body property.

float ImageRenderer::sizeScale
readwrite

Width of this image, in world coordinates.

QString ImageRenderer::source
readwrite

Path to the source texture.

bool ImageRenderer::visible
readwrite

Override of QQuickItem's visible property to set visibility.

Note
This is done to preserve the convention of using visible to control visibility. Internally we set QQuickItem's visible property, and visible is not virtual, so we cannot override it in the C++ sense. Instead we hide it.