Frapper  1.0a
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
PainterPanel::BaseShapeItem Class Referenceabstract

BaseShapeItem class. More...

#include <PainterGraphicsItems.h>

Inheritance diagram for PainterPanel::BaseShapeItem:
Inheritance graph
[legend]
Collaboration diagram for PainterPanel::BaseShapeItem:
Collaboration graph
[legend]

Classes

class  PointHandle
 The PointHandle class provides handles to update its parents bounding points. More...
 
class  RotationHandle
 The RotationHandle class provides handles to update its parents orientation. More...
 
class  TranslationHandle
 The TranslationHandle class provides handles to update its parents position. More...
 

Public Types

enum  ItemType {
  BASE =0, PAINT, LINE, RECT,
  CIRCLE, ELLIPSE, POLYGON, POLYLINE,
  CURVE, CLOSEDCURVE, NUM_ITEMTYPES
}
 
enum  { Type = UserType + 1 }
 

Public Member Functions

 BaseShapeItem (QPen pen=QPen(), QBrush brush=QBrush())
 Constructor of the BaseShapeItem class.
 
virtual ~BaseShapeItem ()
 Destructor of the PainterPanel class.
 
virtual int type () const
 Enable the use of qgraphicsitem_cast with this item.
 
virtual ItemType GetItemType ()
 The item type is used to distinguish between the different types of items.
 
virtual void addPosition (QPointF pos)=0
 Add a new position to this item.
 
virtual void updatePosition (QPointF pos)=0
 Update the current position of this item.
 
virtual void skipLastPosition (bool &emptyItem)
 Forget the last position provided by add-/updatePosition()
 
virtual QRectF boundingRect () const
 Get the bounding-rect of the shape.
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 Paint the item with the specified pen and brush Use a yellow pen when the item is selected.
 
QString getDescriptionText ()
 

Protected Member Functions

virtual void updateShape ()
 Call this function to update the shape of the item. This function updates the position of the translation and rotation handle.
 
virtual QVariant itemChange (GraphicsItemChange change, const QVariant &value)
 React on changes of the item.
 

Protected Attributes

QPainterPath m_shape
 The shape of the item to draw.
 
QList< PointHandle * > m_points
 The list of point handles.
 
RotationHandlem_rotateHandle
 The handle to rotate this shape item.
 
TranslationHandlem_translateHandle
 The handle to translate this shape item.
 

Private Member Functions

void showHandles (bool show=true)
 Show/Hide handles of the item.
 

Detailed Description

BaseShapeItem class.

This class provides objects handles for bounding points, translation and rotation Implement functions addPosition( QPointF pos ) and updatePosition( QPointF pos ) for custom items

If you override updateShape() for complex shapes, don't forget to call prepareGeometryChange() at the beginning and BaseShapeItem::updateShape() at the end. This file also contains some examples.

Member Enumeration Documentation

Enumerator:
BASE 
PAINT 
LINE 
RECT 
CIRCLE 
ELLIPSE 
POLYGON 
POLYLINE 
CURVE 
CLOSEDCURVE 
NUM_ITEMTYPES 
anonymous enum
Enumerator:
Type 

Constructor & Destructor Documentation

PainterPanel::BaseShapeItem::BaseShapeItem ( QPen  pen = QPen(),
QBrush  brush = QBrush() 
)
inline

Constructor of the BaseShapeItem class.

Parameters
penColorThe parent widget the created instance will be a child of.
penWidthExtra widget options.
virtual PainterPanel::BaseShapeItem::~BaseShapeItem ( )
inlinevirtual

Destructor of the PainterPanel class.

Defined virtual to guarantee that the destructor of a derived class will be called if the instance of the derived class is saved in a variable of its parent class type.

Member Function Documentation

virtual int PainterPanel::BaseShapeItem::type ( ) const
inlinevirtual

Enable the use of qgraphicsitem_cast with this item.

virtual ItemType PainterPanel::BaseShapeItem::GetItemType ( )
inlinevirtual
virtual void PainterPanel::BaseShapeItem::addPosition ( QPointF  pos)
pure virtual
virtual void PainterPanel::BaseShapeItem::updatePosition ( QPointF  pos)
pure virtual
virtual void PainterPanel::BaseShapeItem::skipLastPosition ( bool &  emptyItem)
inlinevirtual

Forget the last position provided by add-/updatePosition()

Parameters
emptyItemSet to true, if this operation creates an empty item, otherwise false

Reimplemented in PainterPanel::ClosedCurveItem, PainterPanel::CurveItem, and PainterPanel::PolyLineItem.

virtual QRectF PainterPanel::BaseShapeItem::boundingRect ( ) const
inlinevirtual

Get the bounding-rect of the shape.

virtual void PainterPanel::BaseShapeItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget 
)
inlinevirtual

Paint the item with the specified pen and brush Use a yellow pen when the item is selected.

Reimplemented in PainterPanel::CurveItem.

QString PainterPanel::BaseShapeItem::getDescriptionText ( )
inline
virtual void PainterPanel::BaseShapeItem::updateShape ( )
inlineprotectedvirtual

Call this function to update the shape of the item. This function updates the position of the translation and rotation handle.

Reimplemented in PainterPanel::ClosedCurveItem, PainterPanel::CurveItem, PainterPanel::PolygonItem, PainterPanel::PolyLineItem, PainterPanel::EllipseItem, PainterPanel::CircleItem, PainterPanel::RectItem, and PainterPanel::LineItem.

virtual QVariant PainterPanel::BaseShapeItem::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
)
inlineprotectedvirtual

React on changes of the item.

Reimplemented in PainterPanel::CurveItem.

void PainterPanel::BaseShapeItem::showHandles ( bool  show = true)
inlineprivate

Show/Hide handles of the item.

Member Data Documentation

QPainterPath PainterPanel::BaseShapeItem::m_shape
protected

The shape of the item to draw.

QList<PointHandle*> PainterPanel::BaseShapeItem::m_points
protected

The list of point handles.

RotationHandle* PainterPanel::BaseShapeItem::m_rotateHandle
protected

The handle to rotate this shape item.

TranslationHandle* PainterPanel::BaseShapeItem::m_translateHandle
protected

The handle to translate this shape item.


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