QGIS API Documentation  2.8.2-Wien
 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 
25 class QgsLineSymbolV2;
26 
28 class CORE_EXPORT QgsComposerArrow: public QgsComposerItem
29 {
30  public:
31 
33  {
36  SVGMarker
37  };
38 
43 
49  QgsComposerArrow( const QPointF& startPoint, const QPointF& stopPoint, QgsComposition* c );
50 
52 
54  virtual int type() const override { return ComposerArrow; }
55 
57  void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) override;
58 
61  void setSceneRect( const QRectF& rectangle ) override;
62 
67  void setArrowHeadWidth( double width );
68 
73  double arrowHeadWidth() const { return mArrowHeadWidth; }
74 
78  Q_DECL_DEPRECATED void setOutlineWidth( double width );
79 
83  Q_DECL_DEPRECATED double outlineWidth() const;
84 
90  void setStartMarker( const QString& svgPath );
91 
97  QString startMarker() const { return mStartMarkerFile; }
98 
104  void setEndMarker( const QString& svgPath );
105 
111  QString endMarker() const { return mEndMarkerFile; }
112 
116  Q_DECL_DEPRECATED QColor arrowColor() const;
117 
121  Q_DECL_DEPRECATED void setArrowColor( const QColor& c );
122 
129  QColor arrowHeadOutlineColor() const { return mArrowHeadOutlineColor; }
130 
137  void setArrowHeadOutlineColor( const QColor& color );
138 
145  QColor arrowHeadFillColor() const { return mArrowHeadFillColor; }
146 
153  void setArrowHeadFillColor( const QColor& color );
154 
161  void setArrowHeadOutlineWidth( const double width );
162 
169  double arrowHeadOutlineWidth() const { return mArrowHeadOutlineWidth; }
170 
176  void setLineSymbol( QgsLineSymbolV2* symbol );
177 
183  QgsLineSymbolV2* lineSymbol() { return mLineSymbol; }
184 
189  MarkerMode markerMode() const { return mMarkerMode; }
190 
195  void setMarkerMode( MarkerMode mode );
196 
201  bool writeXML( QDomElement& elem, QDomDocument & doc ) const override;
202 
207  bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) override;
208 
209  private:
210 
211  enum MarkerType
212  {
213  StartMarker,
214  EndMarker
215  };
216 
217  QPointF mStartPoint;
218  QPointF mStopPoint;
219 
223  int mStartXIdx;
224  int mStartYIdx;
225 
226  QPen mPen;
227  QBrush mBrush;
228 
230  double mArrowHeadWidth;
232  double mStartArrowHeadHeight;
233  double mStopArrowHeadHeight;
234 
236  QString mStartMarkerFile;
238  QString mEndMarkerFile;
240  MarkerMode mMarkerMode;
241 
242  double mArrowHeadOutlineWidth;
243  QColor mArrowHeadOutlineColor;
244  QColor mArrowHeadFillColor;
248  int mBoundsBehaviour;
249 
250  QgsLineSymbolV2* mLineSymbol;
251 
254  void adaptItemSceneRect();
256  double computeMarkerMargin() const;
258  void drawHardcodedMarker( QPainter* p, MarkerType type );
260  void drawSVGMarker( QPainter* p, MarkerType type, const QString& markerPath );
262  void init();
266  void createDefaultLineSymbol();
270  void drawLine( QPainter *painter );
271 };
272 
273 #endif // QGSCOMPOSERARROW_H
274 
275