LuciadCPillar 2023.1.04
luciad::IIconPainter Class Referenceabstract

An icon painter can paint an icon as an Image. More...

#include <luciad/drawing/IIcon.h>

Public Member Functions

virtual ~IIconPainter ()=default
 
virtual double getAnchorX () const =0
 Returns the x coordinate of the anchor point in pixels. More...
 
virtual double getAnchorY () const =0
 Returns the y coordinate of the anchor point in pixels. More...
 
virtual double getDisplayScale () const =0
 Returns the display scale for which this painter is optimized. More...
 
virtual size_t getHeight () const =0
 Returns the height of this icon. More...
 
virtual size_t getWidth () const =0
 Returns the width of this icon. More...
 
virtual std::shared_ptr< Imagepaint ()=0
 Paints the IIcon as an image. More...
 

Detailed Description

An icon painter can paint an icon as an Image.

This class can be used on any thread, so its implementation must be thread-safe.

Performance considerations: to make sure the rendering backend can avoid as much work as possible

  • IIconPainter::paint must be as performant as possible. This can for example be done by implementing this function lazily, i.e. avoid generating the image in the constructor of the IIconPainter implementation.
  • The same goes for the getWidth/getHeight, getAnchorX/getAnchorY methods. If possible, make these as performant as possible. If there is a more performant way to calculate these without painting the image, that is preferred. The reason is that the rendering backend might need these properties to determine if an icon should effectively be visible or not on the Map.
Since
2022.0

Constructor & Destructor Documentation

◆ ~IIconPainter()

virtual luciad::IIconPainter::~IIconPainter ( )
virtualdefault

Member Function Documentation

◆ getAnchorX()

virtual double luciad::IIconPainter::getAnchorX ( ) const
pure virtual

Returns the x coordinate of the anchor point in pixels.

The anchor point is the location of the icon that (by default) is attached to an other object, e.g. a location on the map. This must be a value in the [0, getWidth()] range. A good default implementation is to return getWidth() / 2.0.

Remarks
This method may be invoked from different threads.
Returns
the x coordinate of the anchor point in pixels.

◆ getAnchorY()

virtual double luciad::IIconPainter::getAnchorY ( ) const
pure virtual

Returns the y coordinate of the anchor point in pixels.

The anchor point is the location of the icon that (by default) is attached to an other object, e.g. a location on the map. This must be a value in the [0, getHeight()] range. A good default implementation is to return getHeight() / 2.0.

Remarks
This method may be invoked from different threads.
Returns
the y coordinate of the anchor point in pixels.

◆ getDisplayScale()

virtual double luciad::IIconPainter::getDisplayScale ( ) const
pure virtual

Returns the display scale for which this painter is optimized.

This is not necessarily the same display as the one that was used to create this painter. Some icons may only have a limited number scaled versions of their icon available. This method can then be used by the rendering backend to discover this, and to paint it at the intended size.

Remarks
This method may be invoked from different threads.
Returns
the display scale for which this painter is optimized.

◆ getHeight()

virtual size_t luciad::IIconPainter::getHeight ( ) const
pure virtual

Returns the height of this icon.

I.e. the height of the Image that is returned by IIconPainter::paint

Remarks
This method may be invoked from different threads.
Returns
the height of this icon.

◆ getWidth()

virtual size_t luciad::IIconPainter::getWidth ( ) const
pure virtual

Returns the width of this icon.

I.e. the width of the Image that is returned by IIconPainter::paint.

Remarks
This method may be invoked from different threads.
  • Returns
    the width of this icon.

◆ paint()

virtual std::shared_ptr< Image > luciad::IIconPainter::paint ( )
pure virtual

Paints the IIcon as an image.

Returns
the image of this icon, never nullptr.
Remarks
This method may be invoked from different threads.