Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgsmarkersymbollayerv2.h
Go to the documentation of this file.
1 
2 #ifndef QGSMARKERSYMBOLLAYERV2_H
3 #define QGSMARKERSYMBOLLAYERV2_H
4 
5 #include "qgssymbollayerv2.h"
6 
7 #define DEFAULT_SIMPLEMARKER_NAME "circle"
8 #define DEFAULT_SIMPLEMARKER_COLOR QColor(255,0,0)
9 #define DEFAULT_SIMPLEMARKER_BORDERCOLOR QColor(0,0,0)
10 #define DEFAULT_SIMPLEMARKER_SIZE DEFAULT_POINT_SIZE
11 #define DEFAULT_SIMPLEMARKER_ANGLE 0
12 
13 #include <QPen>
14 #include <QBrush>
15 #include <QPicture>
16 #include <QPolygonF>
17 #include <QFont>
18 
20 {
21  public:
23  QColor color = DEFAULT_SIMPLEMARKER_COLOR,
24  QColor borderColor = DEFAULT_SIMPLEMARKER_BORDERCOLOR,
25  double size = DEFAULT_SIMPLEMARKER_SIZE,
27 
28  // static stuff
29 
30  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
31 
32  // implemented from base classes
33 
34  QString layerType() const;
35 
36  void startRender( QgsSymbolV2RenderContext& context );
37 
38  void stopRender( QgsSymbolV2RenderContext& context );
39 
40  void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
41 
42  QgsStringMap properties() const;
43 
44  QgsSymbolLayerV2* clone() const;
45 
46  QString name() const { return mName; }
47  void setName( QString name ) { mName = name; }
48 
49  QColor borderColor() const { return mBorderColor; }
50  void setBorderColor( QColor color ) { mBorderColor = color; }
51 
52  protected:
53 
54  void drawMarker( QPainter* p, QgsSymbolV2RenderContext& context );
55 
56  bool prepareShape();
57  bool preparePath();
58 
59  void prepareCache( QgsSymbolV2RenderContext& context );
60 
61  QColor mBorderColor;
62  QPen mPen;
63  QBrush mBrush;
64  QPolygonF mPolygon;
65  QPainterPath mPath;
66  QString mName;
67  QImage mCache;
68  QPen mSelPen;
69  QBrush mSelBrush;
70  QImage mSelCache;
72 };
73 
75 
76 #define DEFAULT_SVGMARKER_NAME "/symbol/Star1.svg"
77 #define DEFAULT_SVGMARKER_SIZE 2*DEFAULT_POINT_SIZE
78 #define DEFAULT_SVGMARKER_ANGLE 0
79 
81 {
82  public:
84  double size = DEFAULT_SVGMARKER_SIZE,
85  double angle = DEFAULT_SVGMARKER_ANGLE );
86 
87  // static stuff
88 
89  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
90 
92  static QStringList listSvgFiles();
93 
95  static QString symbolNameToPath( QString name );
96 
98  static QString symbolPathToName( QString path );
99 
100  // implemented from base classes
101 
102  QString layerType() const;
103 
104  void startRender( QgsSymbolV2RenderContext& context );
105 
106  void stopRender( QgsSymbolV2RenderContext& context );
107 
108  void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
109 
110  QgsStringMap properties() const;
111 
112  QgsSymbolLayerV2* clone() const;
113 
114  QString path() const { return mPath; }
115  void setPath( QString path ) { mPath = path; }
116 
117  protected:
118 
119  void loadSvg();
120 
121  QString mPath;
122  QPicture mPicture;
123  QPicture mSelPicture;
124  double mOrigSize;
125 };
126 
127 
129 
130 #define POINT2MM(x) ( (x) * 25.4 / 72 ) // point is 1/72 of inch
131 #define MM2POINT(x) ( (x) * 72 / 25.4 )
132 
133 #define DEFAULT_FONTMARKER_FONT "Dingbats"
134 #define DEFAULT_FONTMARKER_CHR QChar('A')
135 #define DEFAULT_FONTMARKER_SIZE POINT2MM(12)
136 #define DEFAULT_FONTMARKER_COLOR QColor(Qt::black)
137 #define DEFAULT_FONTMARKER_ANGLE 0
138 
140 {
141  public:
143  QChar chr = DEFAULT_FONTMARKER_CHR,
144  double pointSize = DEFAULT_FONTMARKER_SIZE,
145  QColor color = DEFAULT_FONTMARKER_COLOR,
146  double angle = DEFAULT_FONTMARKER_ANGLE );
147 
148  // static stuff
149 
150  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
151 
152  // implemented from base classes
153 
154  QString layerType() const;
155 
156  void startRender( QgsSymbolV2RenderContext& context );
157 
158  void stopRender( QgsSymbolV2RenderContext& context );
159 
160  void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
161 
162  QgsStringMap properties() const;
163 
164  QgsSymbolLayerV2* clone() const;
165 
166  // new methods
167 
168  QString fontFamily() const { return mFontFamily; }
169  void setFontFamily( QString family ) { mFontFamily = family; }
170 
171  QChar character() const { return mChr; }
172  void setCharacter( QChar ch ) { mChr = ch; }
173 
174  protected:
175 
176  QString mFontFamily;
177  QChar mChr;
178 
179  QPointF mChrOffset;
180  QFont mFont;
181  double mOrigSize;
182 };
183 
184 
185 #endif