Quantum GIS API Documentation
1.7.4
|
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 00024 class CORE_EXPORT QgsComposerArrow: public QgsComposerItem 00025 { 00026 public: 00027 00028 enum MarkerMode 00029 { 00030 DefaultMarker, 00031 NoMarker, 00032 SVGMarker 00033 }; 00034 00035 QgsComposerArrow( QgsComposition* c ); 00036 QgsComposerArrow( const QPointF& startPoint, const QPointF& stopPoint, QgsComposition* c ); 00037 ~QgsComposerArrow(); 00038 00040 virtual int type() const { return ComposerArrow; } 00041 00043 void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ); 00044 00046 void setSceneRect( const QRectF& rectangle ); 00047 00049 void setArrowHeadWidth( double width ); 00050 double arrowHeadWidth() const {return mArrowHeadWidth;} 00051 00052 void setOutlineWidth( double width ); 00053 double outlineWidth() const {return mPen.widthF();} 00054 00055 void setStartMarker( const QString& svgPath ); 00056 QString startMarker() const {return mStartMarkerFile;} 00057 void setEndMarker( const QString& svgPath ); 00058 QString endMarker() const {return mEndMarkerFile;} 00059 00060 QColor arrowColor() const { return mArrowColor; } 00061 void setArrowColor( const QColor& c ) { mArrowColor = c; } 00062 00063 MarkerMode markerMode() const { return mMarkerMode;} 00064 void setMarkerMode( MarkerMode mode ) {mMarkerMode = mode;} 00065 00070 bool writeXML( QDomElement& elem, QDomDocument & doc ) const; 00071 00076 bool readXML( const QDomElement& itemElem, const QDomDocument& doc ); 00077 00078 private: 00079 00080 enum MarkerType 00081 { 00082 StartMarker, 00083 EndMarker 00084 }; 00085 00086 QPointF mStartPoint; 00087 QPointF mStopPoint; 00088 00089 QPen mPen; 00090 QBrush mBrush; 00091 00093 double mArrowHeadWidth; 00095 double mStartArrowHeadHeight; 00096 double mStopArrowHeadHeight; 00097 00099 QString mStartMarkerFile; 00101 QString mEndMarkerFile; 00103 MarkerMode mMarkerMode; 00104 QColor mArrowColor; 00105 00106 00107 00110 void adaptItemSceneRect(); 00112 void drawHardcodedMarker( QPainter* p, MarkerType type ); 00114 void drawSVGMarker( QPainter* p, MarkerType type, const QString& markerPath ); 00116 void initGraphicsSettings(); 00117 }; 00118 00119 #endif // QGSCOMPOSERARROW_H