QGIS API Documentation  master-3f58142
src/core/composer/qgscomposerarrow.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                          qgscomposerarrow.h
00003                          ----------------------
00004     begin                : November 2009
00005     copyright            : (C) 2009 by Marco Hugentobler
00006     email                : marco@hugis.net
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef QGSCOMPOSERARROW_H
00019 #define QGSCOMPOSERARROW_H
00020 
00021 #include "qgscomposeritem.h"
00022 #include <QBrush>
00023 #include <QPen>
00024 
00026 class CORE_EXPORT QgsComposerArrow: public QgsComposerItem
00027 {
00028   public:
00029 
00030     enum MarkerMode
00031     {
00032       DefaultMarker,
00033       NoMarker,
00034       SVGMarker
00035     };
00036 
00037     QgsComposerArrow( QgsComposition* c );
00038     QgsComposerArrow( const QPointF& startPoint, const QPointF& stopPoint, QgsComposition* c );
00039     ~QgsComposerArrow();
00040 
00042     virtual int type() const { return ComposerArrow; }
00043 
00045     void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
00046 
00048     void setSceneRect( const QRectF& rectangle );
00049 
00051     void setArrowHeadWidth( double width );
00052     double arrowHeadWidth() const {return mArrowHeadWidth;}
00053 
00054     void setOutlineWidth( double width );
00055     double outlineWidth() const {return mPen.widthF();}
00056 
00057     void setStartMarker( const QString& svgPath );
00058     QString startMarker() const {return mStartMarkerFile;}
00059     void setEndMarker( const QString& svgPath );
00060     QString endMarker() const {return mEndMarkerFile;}
00061 
00062     QColor arrowColor() const { return mArrowColor; }
00063     void setArrowColor( const QColor& c ) { mArrowColor = c; }
00064 
00065     MarkerMode markerMode() const { return mMarkerMode;}
00066     void setMarkerMode( MarkerMode mode ) {mMarkerMode = mode;}
00067 
00072     bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
00073 
00078     bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
00079 
00080   private:
00081 
00082     enum MarkerType
00083     {
00084       StartMarker,
00085       EndMarker
00086     };
00087 
00088     QPointF mStartPoint;
00089     QPointF mStopPoint;
00090 
00091     QPen mPen;
00092     QBrush mBrush;
00093 
00095     double mArrowHeadWidth;
00097     double mStartArrowHeadHeight;
00098     double mStopArrowHeadHeight;
00099 
00101     QString mStartMarkerFile;
00103     QString mEndMarkerFile;
00105     MarkerMode mMarkerMode;
00106     QColor mArrowColor;
00107 
00108 
00109 
00112     void adaptItemSceneRect();
00114     void drawHardcodedMarker( QPainter* p, MarkerType type );
00116     void drawSVGMarker( QPainter* p, MarkerType type, const QString& markerPath );
00118     void initGraphicsSettings();
00119 };
00120 
00121 #endif // QGSCOMPOSERARROW_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines