QGIS API Documentation  2.2.0-Valmiera
 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 : 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 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
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc)=0
sets state from Dom document
An item that draws an arrow between to points.
A item that forms part of a map composition.
QString mStartMarkerFile
Path to the start marker file.
double outlineWidth() const
MarkerMode markerMode() const
QColor arrowColor() const
MarkerMode mMarkerMode
Default marker, no marker or svg marker.
void setMarkerMode(MarkerMode mode)
void setArrowColor(const QColor &c)
virtual int type() const
return correct graphics item type.
QString endMarker() const
Graphics scene for map printing.
QString startMarker() const
double mArrowHeadWidth
Width of the arrow marker in mm.
QString mEndMarkerFile
Path to the end marker file.
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
double mStartArrowHeadHeight
Height of the arrow marker in mm.
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const =0
stores state in Dom element
double arrowHeadWidth() const