Quantum GIS API Documentation  master-693a1fe
QgsComposerShape Class Reference

A composer items that draws common shapes (ellipse, triangle, rectangle) More...

#include <qgscomposershape.h>

+ Inheritance diagram for QgsComposerShape:
+ Collaboration diagram for QgsComposerShape:

List of all members.

Public Types

enum  Shape { Ellipse, Rectangle, Triangle }

Public Slots

virtual void setRotation (double r)
 Sets item rotation and resizes item bounds such that the shape always has the same size.

Public Member Functions

 QgsComposerShape (QgsComposition *composition)
 QgsComposerShape (qreal x, qreal y, qreal width, qreal height, QgsComposition *composition)
 ~QgsComposerShape ()
void paint (QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget)
 Reimplementation of QCanvasItem::paint - draw on canvas.
bool readXML (const QDomElement &itemElem, const QDomDocument &doc)
 sets state from Dom document
void setSceneRect (const QRectF &rectangle)
 Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size unit.
void setShapeType (QgsComposerShape::Shape s)
QgsComposerShape::Shape shapeType () const
virtual int type () const
 return correct graphics item type.
bool writeXML (QDomElement &elem, QDomDocument &doc) const
 stores state in Dom element

Protected Member Functions

virtual void drawBackground (QPainter *p)
 Draw background.
virtual void drawFrame (QPainter *p)
 Draw black frame around item.

Private Member Functions

void drawShape (QPainter *p)
QPointF pointOnLineWithDistance (const QPointF &startPoint, const QPointF &directionPoint, double distance) const
 Returns a point on the line from startPoint to directionPoint that is a certain distance away from the starting point.

Private Attributes

Shape mShape
 Ellipse, rectangle or triangle.

Detailed Description

A composer items that draws common shapes (ellipse, triangle, rectangle)

Definition at line 26 of file qgscomposershape.h.


Member Enumeration Documentation

Enumerator:
Ellipse 
Rectangle 
Triangle 

Definition at line 31 of file qgscomposershape.h.


Constructor & Destructor Documentation

QgsComposerShape::QgsComposerShape ( qreal  x,
qreal  y,
qreal  width,
qreal  height,
QgsComposition composition 
)

Definition at line 26 of file qgscomposershape.cpp.

References QgsComposerItem::setFrameEnabled(), and setSceneRect().


Member Function Documentation

void QgsComposerShape::drawBackground ( QPainter *  p) [protected, virtual]

Draw background.

Reimplemented from QgsComposerItem.

Definition at line 97 of file qgscomposershape.cpp.

References drawShape(), and QgsComposerItem::mBackground.

Referenced by paint().

void QgsComposerShape::drawFrame ( QPainter *  p) [protected, virtual]

Draw black frame around item.

Reimplemented from QgsComposerItem.

Definition at line 86 of file qgscomposershape.cpp.

References drawShape(), and QgsComposerItem::mFrame.

Referenced by paint().

void QgsComposerShape::drawShape ( QPainter *  p) [private]

Definition at line 55 of file qgscomposershape.cpp.

References Ellipse, QgsComposerItem::mRotation, mShape, Rectangle, and Triangle.

Referenced by drawBackground(), and drawFrame().

void QgsComposerShape::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  itemStyle,
QWidget *  pWidget 
)

Reimplementation of QCanvasItem::paint - draw on canvas.

Definition at line 37 of file qgscomposershape.cpp.

References drawBackground(), drawFrame(), and QgsComposerItem::drawSelectionBoxes().

QPointF QgsComposerShape::pointOnLineWithDistance ( const QPointF &  startPoint,
const QPointF &  directionPoint,
double  distance 
) const [private]

Returns a point on the line from startPoint to directionPoint that is a certain distance away from the starting point.

bool QgsComposerShape::readXML ( const QDomElement &  itemElem,
const QDomDocument &  doc 
) [virtual]

sets state from Dom document

Parameters:
itemElemis Dom node corresponding to item tag
docis Dom document

Implements QgsComposerItem.

Definition at line 117 of file qgscomposershape.cpp.

References QgsComposerItem::_readXML(), QgsComposerItem::itemChanged(), and mShape.

Referenced by QgsComposition::addItemsFromXML().

void QgsComposerShape::setRotation ( double  r) [virtual, slot]

Sets item rotation and resizes item bounds such that the shape always has the same size.

Reimplemented from QgsComposerItem.

Definition at line 133 of file qgscomposershape.cpp.

References setSceneRect(), and QgsComposerItem::sizeChangedByRotation().

void QgsComposerShape::setSceneRect ( const QRectF &  rectangle) [virtual]

Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size unit.

Also, the shape is scaled

Reimplemented from QgsComposerItem.

Definition at line 148 of file qgscomposershape.cpp.

References QgsComposerItem::imageSizeConsideringRotation().

Referenced by QgsComposerShape(), and setRotation().

Definition at line 62 of file qgscomposershape.h.

Referenced by QgsComposerView::addShape().

Definition at line 61 of file qgscomposershape.h.

virtual int QgsComposerShape::type ( ) const [inline, virtual]

return correct graphics item type.

Added in v1.7

Reimplemented from QgsComposerItem.

Definition at line 43 of file qgscomposershape.h.

References QgsComposerItem::ComposerShape.

bool QgsComposerShape::writeXML ( QDomElement &  elem,
QDomDocument &  doc 
) const [virtual]

stores state in Dom element

Parameters:
elemis Dom element corresponding to 'Composer' tag
docwrite template file

Implements QgsComposerItem.

Definition at line 109 of file qgscomposershape.cpp.

References QgsComposerItem::_writeXML(), and mShape.


Member Data Documentation

Ellipse, rectangle or triangle.

Definition at line 82 of file qgscomposershape.h.

Referenced by drawShape(), readXML(), and writeXML().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines