QGIS API Documentation  2.99.0-Master (7d4f81d)
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 "qgis_core.h"
22 #include "qgis.h"
23 #include "qgscomposeritem.h"
24 #include <QBrush>
25 #include <QPen>
26 
27 class QgsLineSymbol;
28 
32 class CORE_EXPORT QgsComposerArrow: public QgsComposerItem
33 {
34  Q_OBJECT
35 
36  public:
37 
39  {
42  SVGMarker
43  };
44 
49 
55  QgsComposerArrow( QPointF startPoint, QPointF stopPoint, QgsComposition *c SIP_TRANSFERTHIS );
56 
58 
60  virtual int type() const override { return ComposerArrow; }
61 
63  void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
64 
67  void setSceneRect( const QRectF &rectangle ) override;
68 
73  void setArrowHeadWidth( double width );
74 
79  double arrowHeadWidth() const { return mArrowHeadWidth; }
80 
86  void setStartMarker( const QString &svgPath );
87 
93  QString startMarker() const { return mStartMarkerFile; }
94 
100  void setEndMarker( const QString &svgPath );
101 
107  QString endMarker() const { return mEndMarkerFile; }
108 
115  QColor arrowHeadStrokeColor() const { return mArrowHeadStrokeColor; }
116 
123  void setArrowHeadStrokeColor( const QColor &color );
124 
131  QColor arrowHeadFillColor() const { return mArrowHeadFillColor; }
132 
139  void setArrowHeadFillColor( const QColor &color );
140 
147  void setArrowHeadStrokeWidth( const double width );
148 
155  double arrowHeadStrokeWidth() const { return mArrowHeadStrokeWidth; }
156 
162  void setLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
163 
169  QgsLineSymbol *lineSymbol() { return mLineSymbol; }
170 
175  MarkerMode markerMode() const { return mMarkerMode; }
176 
181  void setMarkerMode( MarkerMode mode );
182 
187  bool writeXml( QDomElement &elem, QDomDocument &doc ) const override;
188 
193  bool readXml( const QDomElement &itemElem, const QDomDocument &doc ) override;
194 
195  private:
196 
197  enum MarkerType
198  {
199  StartMarker,
200  EndMarker
201  };
202 
203  QPointF mStartPoint;
204  QPointF mStopPoint;
205 
209  int mStartXIdx;
210  int mStartYIdx;
211 
212  QPen mPen;
213  QBrush mBrush;
214 
216  double mArrowHeadWidth;
218  double mStartArrowHeadHeight;
219  double mStopArrowHeadHeight;
220 
222  QString mStartMarkerFile;
224  QString mEndMarkerFile;
226  MarkerMode mMarkerMode;
227 
228  double mArrowHeadStrokeWidth;
229  QColor mArrowHeadStrokeColor;
230  QColor mArrowHeadFillColor;
231 
235  int mBoundsBehavior;
236 
237  QgsLineSymbol *mLineSymbol = nullptr;
238 
242  void adaptItemSceneRect();
244  double computeMarkerMargin() const;
246  void drawHardcodedMarker( QPainter *p, MarkerType type );
248  void drawSVGMarker( QPainter *p, MarkerType type, const QString &markerPath );
250  void init();
251 
255  void createDefaultLineSymbol();
256 
260  void drawLine( QPainter *painter );
261 };
262 
263 #endif // QGSCOMPOSERARROW_H
264 
265 
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
QColor arrowHeadFillColor() const
Returns the color used to fill the arrow head.
An item that draws an arrow between two points.
virtual int type() const override
Return composer item type.
QColor arrowHeadStrokeColor() const
Returns the color used to draw stroke around the the arrow head.
A item that forms part of a map composition.
double arrowHeadWidth() const
Returns the width of the arrow head in mm.
QgsLineSymbol * lineSymbol()
Returns the line symbol used for drawing the line portion of the arrow.
QString startMarker() const
Returns the marker drawn at the start of the line.
virtual bool readXml(const QDomElement &itemElem, const QDomDocument &doc)
Sets item state from DOM element.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Graphics scene for map printing.
MarkerMode markerMode() const
Returns marker mode, which controls how the arrow endpoints are drawn.
double arrowHeadStrokeWidth() const
Returns the pen width for the stroke 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...
QString endMarker() const
Returns the marker drawn at the end of the line.
virtual bool writeXml(QDomElement &elem, QDomDocument &doc) const
Stores item state in DOM element.