Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgscomposershape.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposershape.h
3  ----------------------
4  begin : November 2009
5  copyright : (C) 2009 by Marco Hugentobler
6  email : marco@hugis.net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSCOMPOSERSHAPE_H
19 #define QGSCOMPOSERSHAPE_H
20 
21 #include "qgscomposeritem.h"
22 
24 class CORE_EXPORT QgsComposerShape: public QgsComposerItem
25 {
26  Q_OBJECT
27  public:
28 
29  enum Shape
30  {
33  Triangle
34  };
35 
36  QgsComposerShape( QgsComposition* composition );
37  QgsComposerShape( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition );
39 
41  virtual int type() const { return ComposerShape; }
42 
44  void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
45 
50  bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
51 
56  bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
57 
58  //setters and getters
59  void setLineWidth( double width );
60  double lineWidth() const;
61  void setOutlineColor( const QColor& color );
62  QColor outlineColor() const;
63  void setFillColor( const QColor& color );
64  QColor fillColor() const;
65  QgsComposerShape::Shape shapeType() const {return mShape;}
66  void setShapeType( QgsComposerShape::Shape s ) {mShape = s;}
67  bool transparentFill() const;
68  void setTransparentFill( bool transparent );
69 
72  void setSceneRect( const QRectF& rectangle );
73 
74  public slots:
76  virtual void setRotation( double r );
77 
78 
79  private:
83  QPen mPen;
85  QBrush mBrush;
86  double mShapeWidth;
87  double mShapeHeight;
88 
90  void initGraphicsSettings();
91 
93  QPointF pointOnLineWithDistance( const QPointF& startPoint, const QPointF& directionPoint, double distance ) const;
94 };
95 
96 #endif // QGSCOMPOSERSHAPEITEM_H