Swiftray  1.0
Shape Class Reference

A base class for shape objects that contains transform and parent information. More...

#include <shape.h>

Inheritance diagram for Shape:
BitmapShape GroupShape PathShape TextShape

Public Types

enum class  Type {
  None , Path , Bitmap , Text ,
  Group
}
 

Public Member Functions

 Shape () noexcept
 
virtual ~Shape ()
 
void applyTransform (const QTransform &transform)
 
QRectF boundingRect () const
 
virtual shared_ptr< Shapeclone () const
 
void flushCache ()
 
QTransform globalTransform () const
 
bool hasLayer () const
 
virtual bool hitTest (QPointF global_coord, qreal tolerance) const
 
virtual bool hitTest (QRectF global_coord_rect) const
 
bool isLayerLocked () const
 
bool isParentSelected () const
 
Layerlayer () const
 
virtual operator QString ()
 
virtual void paint (QPainter *painter) const
 
Shapeparent () const
 
QPointF pos () const
 
QPolygonF rotatedBBox () const
 
qreal rotation () const
 
bool selected () const
 
void setLayer (Layer *layer)
 
void setParent (Shape *parent)
 
void setRotation (qreal r)
 
void setSelected (bool selected)
 
void setTempTransform (const QTransform &transform)
 
void setTransform (const QTransform &transform)
 
const QTransform & tempTransform () const
 
const QTransform & transform () const
 
virtual Type type () const
 
qreal x () const
 
qreal y () const
 

Protected Member Functions

virtual void calcBoundingBox () const
 

Protected Attributes

QRectF bbox_
 
QPolygonF rotated_bbox_
 
bool selected_
 
QTransform temp_transform_
 
QTransform transform_
 

Friends

class DocumentSerializer
 

Detailed Description

A base class for shape objects that contains transform and parent information.

Member Enumeration Documentation

◆ Type

enum Shape::Type
strong
Enumerator
None 
Path 
Bitmap 
Text 
Group 

Constructor & Destructor Documentation

◆ Shape()

Shape::Shape ( )
noexcept

◆ ~Shape()

Shape::~Shape ( )
virtual

Member Function Documentation

◆ applyTransform()

void Shape::applyTransform ( const QTransform &  transform)

Combine current transform with a new transform.

Parameters
transformThe new transform

◆ boundingRect()

QRectF Shape::boundingRect ( ) const

◆ calcBoundingBox()

void Shape::calcBoundingBox ( ) const
protectedvirtual

Calculate bounding box of the shape if the cache is invalid

◆ clone()

shared_ptr< Shape > Shape::clone ( ) const
virtual

Reimplemented in TextShape, PathShape, GroupShape, and BitmapShape.

◆ flushCache()

void Shape::flushCache ( )

◆ globalTransform()

QTransform Shape::globalTransform ( ) const
Returns
The transform combines with group parents' transform (if any)

◆ hasLayer()

bool Shape::hasLayer ( ) const

◆ hitTest() [1/2]

bool Shape::hitTest ( QPointF  global_coord,
qreal  tolerance 
) const
virtual

Reimplemented in PathShape, GroupShape, and BitmapShape.

◆ hitTest() [2/2]

bool Shape::hitTest ( QRectF  global_coord_rect) const
virtual

Reimplemented in PathShape, GroupShape, and BitmapShape.

◆ isLayerLocked()

bool Shape::isLayerLocked ( ) const

Whether the layer of the object is locked

◆ isParentSelected()

bool Shape::isParentSelected ( ) const

◆ layer()

Layer * Shape::layer ( ) const

◆ operator QString()

Shape::operator QString ( )
virtual

◆ paint()

void Shape::paint ( QPainter *  painter) const
virtual

Reimplemented in TextShape, PathShape, GroupShape, and BitmapShape.

◆ parent()

Shape * Shape::parent ( ) const

◆ pos()

QPointF Shape::pos ( ) const

◆ rotatedBBox()

QPolygonF Shape::rotatedBBox ( ) const

◆ rotation()

qreal Shape::rotation ( ) const

◆ selected()

bool Shape::selected ( ) const

◆ setLayer()

void Shape::setLayer ( Layer layer)

◆ setParent()

void Shape::setParent ( Shape parent)

◆ setRotation()

void Shape::setRotation ( qreal  r)

◆ setSelected()

void Shape::setSelected ( bool  selected)

◆ setTempTransform()

void Shape::setTempTransform ( const QTransform &  transform)

Set temporarily transform that hasn't been commited during moving / rotating / scaling stage for displaying objects.

Parameters
transformThe new transform

◆ setTransform()

void Shape::setTransform ( const QTransform &  transform)

Set current transform to a new transform.

Parameters
transformThe new transform

◆ tempTransform()

const QTransform & Shape::tempTransform ( ) const

◆ transform()

const QTransform & Shape::transform ( ) const
Returns
Raw transform

◆ type()

Shape::Type Shape::type ( ) const
virtual

Returns shape type in Shape::Type

Reimplemented in TextShape, PathShape, GroupShape, and BitmapShape.

◆ x()

qreal Shape::x ( ) const

◆ y()

qreal Shape::y ( ) const

Friends And Related Function Documentation

◆ DocumentSerializer

friend class DocumentSerializer
friend

Member Data Documentation

◆ bbox_

QRectF Shape::bbox_
mutableprotected

Cached bounding box

◆ rotated_bbox_

QPolygonF Shape::rotated_bbox_
mutableprotected

Cached bounding box with rotation

◆ selected_

bool Shape::selected_
protected

Whether the object is selected by user

◆ temp_transform_

QTransform Shape::temp_transform_
protected

Temporarily transform that hasn't been commited during moving / rotating / scaling stage for displaying objects.

◆ transform_

QTransform Shape::transform_
protected

Shape transform including offset, scale, rotate and kew


The documentation for this class was generated from the following files: