QGIS API Documentation  2.99.0-Master (c558d51)
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 QgsLineSymbol;
26 
30 class CORE_EXPORT QgsComposerArrow: public QgsComposerItem
31 {
32  Q_OBJECT
33 
34  public:
35 
37  {
40  SVGMarker
41  };
42 
47 
53  QgsComposerArrow( QPointF startPoint, QPointF stopPoint, QgsComposition* c );
54 
56 
58  virtual int type() const override { return ComposerArrow; }
59 
61  void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) override;
62 
65  void setSceneRect( const QRectF& rectangle ) override;
66 
71  void setArrowHeadWidth( double width );
72 
77  double arrowHeadWidth() const { return mArrowHeadWidth; }
78 
84  void setStartMarker( const QString& svgPath );
85 
91  QString startMarker() const { return mStartMarkerFile; }
92 
98  void setEndMarker( const QString& svgPath );
99 
105  QString endMarker() const { return mEndMarkerFile; }
106 
113  QColor arrowHeadOutlineColor() const { return mArrowHeadOutlineColor; }
114 
121  void setArrowHeadOutlineColor( const QColor& color );
122 
129  QColor arrowHeadFillColor() const { return mArrowHeadFillColor; }
130 
137  void setArrowHeadFillColor( const QColor& color );
138 
145  void setArrowHeadOutlineWidth( const double width );
146 
153  double arrowHeadOutlineWidth() const { return mArrowHeadOutlineWidth; }
154 
160  void setLineSymbol( QgsLineSymbol* symbol );
161 
167  QgsLineSymbol* lineSymbol() { return mLineSymbol; }
168 
173  MarkerMode markerMode() const { return mMarkerMode; }
174 
179  void setMarkerMode( MarkerMode mode );
180 
185  bool writeXml( QDomElement& elem, QDomDocument & doc ) const override;
186 
191  bool readXml( const QDomElement& itemElem, const QDomDocument& doc ) override;
192 
193  private:
194 
195  enum MarkerType
196  {
197  StartMarker,
198  EndMarker
199  };
200 
201  QPointF mStartPoint;
202  QPointF mStopPoint;
203 
207  int mStartXIdx;
208  int mStartYIdx;
209 
210  QPen mPen;
211  QBrush mBrush;
212 
214  double mArrowHeadWidth;
216  double mStartArrowHeadHeight;
217  double mStopArrowHeadHeight;
218 
220  QString mStartMarkerFile;
222  QString mEndMarkerFile;
224  MarkerMode mMarkerMode;
225 
226  double mArrowHeadOutlineWidth;
227  QColor mArrowHeadOutlineColor;
228  QColor mArrowHeadFillColor;
229 
233  int mBoundsBehaviour;
234 
235  QgsLineSymbol* mLineSymbol;
236 
240  void adaptItemSceneRect();
242  double computeMarkerMargin() const;
244  void drawHardcodedMarker( QPainter* p, MarkerType type );
246  void drawSVGMarker( QPainter* p, MarkerType type, const QString& markerPath );
248  void init();
249 
253  void createDefaultLineSymbol();
254 
258  void drawLine( QPainter *painter );
259 };
260 
261 #endif // QGSCOMPOSERARROW_H
262 
263 
An item that draws an arrow between two points.
virtual int type() const override
Return composer item type.
A item that forms part of a map composition.
QColor arrowHeadFillColor() const
Returns the color used to fill the arrow head.
MarkerMode markerMode() const
Returns marker mode, which controls how the arrow endpoints are drawn.
QgsLineSymbol * lineSymbol()
Returns the line symbol used for drawing the line portion of the arrow.
virtual bool readXml(const QDomElement &itemElem, const QDomDocument &doc)
Sets item state from DOM element.
QColor arrowHeadOutlineColor() const
Returns the color used to draw outline around the the arrow head.
QString endMarker() const
Returns the marker drawn at the end of the line.
Graphics scene for map printing.
QString startMarker() const
Returns the marker drawn at the start of the line.
double arrowHeadOutlineWidth() const
Returns the pen width for the outline of the arrow head.
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...
virtual bool writeXml(QDomElement &elem, QDomDocument &doc) const
Stores item state in DOM element.
double arrowHeadWidth() const
Returns the width of the arrow head in mm.