QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposerarrow.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerarrow.h
3  ----------------------
4  begin : November 2009
5  copyright : (C) 2009 by Marco Hugentobler
6  email : [email protected]
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 QGSCOMPOSERARROW_H
19 #define QGSCOMPOSERARROW_H
20 
21 #include "qgscomposeritem.h"
22 #include <QBrush>
23 #include <QPen>
24 
26 class CORE_EXPORT QgsComposerArrow: public QgsComposerItem
27 {
28  public:
29 
31  {
34  SVGMarker
35  };
36 
38  QgsComposerArrow( const QPointF& startPoint, const QPointF& stopPoint, QgsComposition* c );
40 
42  virtual int type() const { return ComposerArrow; }
43 
45  void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
46 
48  void setSceneRect( const QRectF& rectangle );
49 
51  void setArrowHeadWidth( double width );
52  double arrowHeadWidth() const {return mArrowHeadWidth;}
53 
54  void setOutlineWidth( double width );
55  double outlineWidth() const {return mPen.widthF();}
56 
57  void setStartMarker( const QString& svgPath );
58  QString startMarker() const {return mStartMarkerFile;}
59  void setEndMarker( const QString& svgPath );
60  QString endMarker() const {return mEndMarkerFile;}
61 
62  QColor arrowColor() const { return mArrowColor; }
63  void setArrowColor( const QColor& c ) { mArrowColor = c; }
64 
65  MarkerMode markerMode() const { return mMarkerMode;}
66  void setMarkerMode( MarkerMode mode ) {mMarkerMode = mode;}
67 
72  bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
73 
78  bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
79 
80  private:
81 
83  {
85  EndMarker
86  };
87 
88  QPointF mStartPoint;
89  QPointF mStopPoint;
90 
91  QPen mPen;
92  QBrush mBrush;
93 
99 
103  QString mEndMarkerFile;
106  QColor mArrowColor;
107 
108 
109 
112  void adaptItemSceneRect();
114  void drawHardcodedMarker( QPainter* p, MarkerType type );
116  void drawSVGMarker( QPainter* p, MarkerType type, const QString& markerPath );
118  void initGraphicsSettings();
119 };
120 
121 #endif // QGSCOMPOSERARROW_H