touchgfx::AbstractShape is only used within TouchGFX.
 
Symbols
loading...
Files
loading...

touchgfx::AbstractShape class

@class AbstractShape AbstractShape.hpp touchgfx/widgets/canvas/AbstractShape.hpp Simple widget capable of drawing a abstractShape. Simple widget capable of drawing a abstractShape. The abstractShape can be scaled and rotated around 0,0. Note that the y axis goes down, so a abstractShape that goes up must be given negative coordinates. @see CanvasWidget ### tparam T The type of the points used for the abstractShape. Must be int or float.

Syntax

class AbstractShape : public CanvasWidget { public:     template <typename T>     struct ShapePoint     {         T x;          T y;      };     AbstractShape();     virtual ~AbstractShape();     virtual int getNumPoints() const = 0;     virtual void setCorner(int i, CWRUtil::Q5 x, CWRUtil::Q5 y) = 0;     virtual CWRUtil::Q5 getCornerX(int i) const = 0;     virtual CWRUtil::Q5 getCornerY(int i) const = 0;     template <typename T>     void setShape(ShapePoint<T>* points)     {         int numPoints = getNumPoints();         for (int i = 0; i < numPoints; i++)         {             setCorner(i, CWRUtil::toQ5<T>(points[i].x), CWRUtil::toQ5<T>(points[i].y));         }         updateAbstractShapeCache();     }     template <typename T>     void setOrigin(T x, T y)     {         CWRUtil::Q5 dxNew = CWRUtil::toQ5<T>(x);         CWRUtil::Q5 dyNew = CWRUtil::toQ5<T>(y);         if (dx == dxNew && dy == dyNew)         {             return;         }         dx = dxNew;         dy = dyNew;         updateAbstractShapeCache();     }     template <typename T>     void moveOrigin(T x, T y)     {         CWRUtil::Q5 xNew = CWRUtil::toQ5<T>(x);         CWRUtil::Q5 yNew = CWRUtil::toQ5<T>(y);         if (dx == xNew && dy == yNew)         {             return;         }         Rect rect = getMinimalRect();         dx = xNew;         dy = yNew;         updateAbstractShapeCache();         rect.expandToFit(getMinimalRect());         invalidateRect(rect);     }     template <typename T>     void getOrigin(T& dx, T& dy) const     {         dx = this->dx.to<T>();         dy = this->dy.to<T>();     }     template <typename T>     void setAngle(T angle)     {         CWRUtil::Q5 angleQ5 = CWRUtil::toQ5<T>(angle);         if (shapeAngle != angleQ5)         {             shapeAngle = angleQ5;             updateAbstractShapeCache();         }     }     template <typename T>     void updateAngle(T angle)     {         CWRUtil::Q5 angleQ5 = CWRUtil::toQ5<T>(angle);         if (shapeAngle != angleQ5)         {             Rect rectBefore = getMinimalRect();             shapeAngle = angleQ5;             updateAbstractShapeCache();             Rect rectAfter = getMinimalRect();             rectBefore.expandToFit(rectAfter);             invalidateRect(rectBefore);         }     }     int getAngle() const     {         return shapeAngle.to<int>();     }     template <typename T>     void setScale(T newXScale, T newYScale)     {         xScale = CWRUtil::toQ5<T>(newXScale);         yScale = CWRUtil::toQ5<T>(newYScale);         updateAbstractShapeCache();     }     template <typename T>     void setScale(T scale)     {         setScale(scale, scale);     }     template <typename T>     void getScale(T& x, T& y) const     {         x = xScale.to<T>();         y = yScale.to<T>();     }     virtual bool drawCanvasWidget(const Rect& invalidatedArea) const;     void updateAbstractShapeCache(); protected:     virtual void setCache(int i, CWRUtil::Q5 x, CWRUtil::Q5 y) = 0;     virtual CWRUtil::Q5 getCacheX(int i) const = 0;     virtual CWRUtil::Q5 getCacheY(int i) const = 0;     virtual Rect getMinimalRect() const; private:     CWRUtil::Q5 dx, dy;     CWRUtil::Q5 shapeAngle;     CWRUtil::Q5 xScale, yScale;     Rect minimalRect; };

Fields

dx

No summary provided. Read more...

dy

No summary provided. Read more...

shapeAngle

No summary provided. Read more...

xScale

No summary provided. Read more...

yScale

No summary provided. Read more...

minimalRect

No summary provided. Read more...

Methods

moveOrigin()

No summary provided. Read more...

getOrigin() const

No summary provided. Read more...

setAngle()

No summary provided. Read more...

updateAngle()

No summary provided. Read more...

getAngle() const

@fn template T AbstractShape::getAngle() const Gets the current angle of the abstractShape. Gets the current angle of the abstractShape. Read more...

setScale()

No summary provided. Read more...

setScale()

No summary provided. Read more...

getScale() const

No summary provided. Read more...

drawCanvasWidget() const

@fn virtual bool AbstractShape::drawCanvasWidget(const Rect& invalidatedArea) const; Draws the AbstractShape. Draws the AbstractShape. This class supports partial drawing, so only the area described by the rectangle will be drawn. Read more...

updateAbstractShapeCache()

@fn void AbstractShape::updateAbstractShapeCache(); Updates the abstractShape cache. Updates the abstractShape cache. The cache is used to be able to quickly redraw the AbstractShape without calculating the points that make up the abstractShape (with regards to scaling and rotation). Read more...

setCache()

@fn virtual void AbstractShape::setCache(int i, CWRUtil::Q5 x, CWRUtil::Q5 y) = 0; Sets the cached coordinates of a given corner. Sets the cached coordinates of a given corner. The coordinates in the cache are the coordinates from the corners after rotating and scaling the coordinate. Read more...

getCacheX() const

@fn virtual CWRUtil::Q5 AbstractShape::getCacheX(int i) const = 0; Gets cached x coordinate of a corner. Gets cached x coordinate of a corner. Read more...

getCacheY() const

@fn virtual CWRUtil::Q5 AbstractShape::getCacheY(int i) const = 0; Gets cached y coordinate of a corner. Gets cached y coordinate of a corner. Read more...

getMinimalRect() const

@fn virtual Rect AbstractShape::getMinimalRect() const; Gets minimal rectangle containing the abstractShape. Gets minimal rectangle containing the abstractShape. Used for invalidating only the required part of the screen. Read more...

getNumPoints() const

@fn virtual int AbstractShape::getNumPoints() const = 0; Gets number points used to make up the shape. Gets number points used to make up the shape. Read more...

setCorner()

@fn virtual void AbstractShape::setCorner(int i, CWRUtil::Q5 x, CWRUtil::Q5 y) = 0; Sets a corner of the shape. Sets a corner of the shape in Q5 format. Read more...

getCornerX() const

@fn virtual CWRUtil::Q5 AbstractShape::getCornerX(int i) const = 0; Gets the x coordinate of a corner. Gets the x coordinate of a corner. Read more...

getCornerY() const

@fn virtual CWRUtil::Q5 AbstractShape::getCornerY(int i) const = 0; Gets the y coordinate of a corner. Gets the y coordinate of a corner. Read more...

setShape()

No summary provided. Read more...

setOrigin()

No summary provided. Read more...

References

LocationText
AbstractShape.hpp:39
class AbstractShape : public CanvasWidget
Shape.hpp:47
class Shape : public AbstractShape

Class Tree

Child classes
touchgfx::AbstractShape
all items filtered out