2015-07-29 11:52:14 +02:00
|
|
|
/** A composer items that draws common shapes (ellipse, triangle, rectangle)*/
|
2010-02-09 14:34:17 +00:00
|
|
|
class QgsComposerShape: QgsComposerItem
|
2009-11-19 09:04:33 +00:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgscomposershape.h"
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum Shape
|
|
|
|
{
|
|
|
|
Ellipse,
|
|
|
|
Rectangle,
|
|
|
|
Triangle
|
|
|
|
};
|
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
QgsComposerShape( QgsComposition *composition /TransferThis/ );
|
|
|
|
QgsComposerShape( qreal x, qreal y, qreal width, qreal height, QgsComposition *composition /TransferThis/);
|
2009-11-19 09:04:33 +00:00
|
|
|
~QgsComposerShape();
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return correct graphics item type. Added in v1.7 */
|
2010-11-25 21:45:52 +00:00
|
|
|
virtual int type() const;
|
|
|
|
|
2009-11-19 09:04:33 +00:00
|
|
|
/** \brief Reimplementation of QCanvasItem::paint - draw on canvas */
|
2017-05-01 18:13:15 +02:00
|
|
|
void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget );
|
2009-11-19 09:04:33 +00:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Stores state in Dom element
|
2012-09-24 02:28:15 +02:00
|
|
|
* @param elem is Dom element corresponding to 'Composer' tag
|
|
|
|
* @param doc write template file
|
2009-11-19 09:04:33 +00:00
|
|
|
*/
|
2017-05-03 07:45:22 +02:00
|
|
|
bool writeXml( QDomElement &elem, QDomDocument &doc ) const;
|
2009-11-19 09:04:33 +00:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Sets state from Dom document
|
2009-11-19 09:04:33 +00:00
|
|
|
* @param itemElem is Dom node corresponding to item tag
|
2012-09-24 02:28:15 +02:00
|
|
|
* @param doc is Dom document
|
2009-11-19 09:04:33 +00:00
|
|
|
*/
|
2017-05-01 18:13:15 +02:00
|
|
|
bool readXml( const QDomElement &itemElem, const QDomDocument &doc );
|
2009-11-19 09:04:33 +00:00
|
|
|
|
|
|
|
//setters and getters
|
|
|
|
QgsComposerShape::Shape shapeType() const;
|
|
|
|
void setShapeType( QgsComposerShape::Shape s );
|
2012-03-02 08:14:26 +02:00
|
|
|
|
2016-08-06 17:52:06 +02:00
|
|
|
/** Sets radius for rounded rectangle corners. Added in 2.1 */
|
2013-09-16 22:03:46 +10:00
|
|
|
void setCornerRadius( double radius );
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns the radius for rounded rectangle corners*/
|
2013-09-17 12:33:57 +02:00
|
|
|
double cornerRadius() const;
|
2014-01-26 18:35:21 +01:00
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
/** Sets the QgsFillSymbol used to draw the shape. Must also call setUseSymbol( true ) to
|
2013-01-12 16:21:00 +11:00
|
|
|
* enable drawing with a symbol.
|
|
|
|
* Note: added in version 2.1*/
|
2017-05-01 18:13:15 +02:00
|
|
|
void setShapeStyleSymbol( QgsFillSymbol *symbol );
|
2016-08-06 11:01:42 +02:00
|
|
|
/** Returns the QgsFillSymbol used to draw the shape.
|
2013-01-12 16:21:00 +11:00
|
|
|
* Note: added in version 2.1*/
|
2017-05-01 18:13:15 +02:00
|
|
|
QgsFillSymbol *shapeStyleSymbol();
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
/** Controls whether the shape should be drawn using a QgsFillSymbol.
|
2016-08-06 17:52:06 +02:00
|
|
|
* Note: Added in 2.1 */
|
|
|
|
void setUseSymbol( bool useSymbol );
|
2014-05-27 23:22:50 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Depending on the symbol style, the bounding rectangle can be larger than the shape
|
2014-05-27 23:22:50 +02:00
|
|
|
@note this function was added in version 2.3*/
|
|
|
|
QRectF boundingRect() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Sets new scene rectangle bounds and recalculates hight and extent. Reimplemented from
|
2014-04-11 13:04:39 +10:00
|
|
|
* QgsComposerItem as it needs to call updateBoundingRect after the shape's size changes
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2017-05-01 18:13:15 +02:00
|
|
|
void setSceneRect( const QRectF &rectangle );
|
2014-08-17 13:37:26 +02:00
|
|
|
|
2015-10-04 23:54:21 +02:00
|
|
|
//Overridden to return shape type
|
2014-07-28 19:44:43 +10:00
|
|
|
virtual QString displayName() const;
|
2013-06-23 16:00:16 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/* reimplement drawFrame, since it's not a rect, but a custom shape */
|
2017-05-01 18:13:15 +02:00
|
|
|
virtual void drawFrame( QPainter *p );
|
2013-06-23 16:00:16 +02:00
|
|
|
/* reimplement drawBackground, since it's not a rect, but a custom shape */
|
2017-05-01 18:13:15 +02:00
|
|
|
virtual void drawBackground( QPainter *p );
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Reimplement estimatedFrameBleed, since frames on shapes are drawn using symbology
|
2014-02-04 18:34:47 +11:00
|
|
|
* rather than the item's pen */
|
|
|
|
virtual double estimatedFrameBleed() const;
|
2014-05-27 23:22:50 +02:00
|
|
|
|
2014-02-04 18:34:47 +11:00
|
|
|
public slots:
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Should be called after the shape's symbol is changed. Redraws the shape and recalculates
|
2014-02-04 18:34:47 +11:00
|
|
|
* its selection bounds.
|
|
|
|
* Note: added in version 2.1*/
|
|
|
|
void refreshSymbol();
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|