00001
00002 #ifndef QGSMARKERSYMBOLLAYERV2_H
00003 #define QGSMARKERSYMBOLLAYERV2_H
00004
00005 #include "qgssymbollayerv2.h"
00006
00007 #define DEFAULT_SIMPLEMARKER_NAME "circle"
00008 #define DEFAULT_SIMPLEMARKER_COLOR QColor(255,0,0)
00009 #define DEFAULT_SIMPLEMARKER_BORDERCOLOR QColor(0,0,0)
00010 #define DEFAULT_SIMPLEMARKER_SIZE DEFAULT_POINT_SIZE
00011 #define DEFAULT_SIMPLEMARKER_ANGLE 0
00012
00013 #include <QPen>
00014 #include <QBrush>
00015 #include <QPicture>
00016 #include <QPolygonF>
00017 #include <QFont>
00018
00019 class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
00020 {
00021 public:
00022 QgsSimpleMarkerSymbolLayerV2( QString name = DEFAULT_SIMPLEMARKER_NAME,
00023 QColor color = DEFAULT_SIMPLEMARKER_COLOR,
00024 QColor borderColor = DEFAULT_SIMPLEMARKER_BORDERCOLOR,
00025 double size = DEFAULT_SIMPLEMARKER_SIZE,
00026 double angle = DEFAULT_SIMPLEMARKER_ANGLE );
00027
00028
00029
00030 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
00031
00032
00033
00034 QString layerType() const;
00035
00036 void startRender( QgsSymbolV2RenderContext& context );
00037
00038 void stopRender( QgsSymbolV2RenderContext& context );
00039
00040 void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
00041
00042 QgsStringMap properties() const;
00043
00044 QgsSymbolLayerV2* clone() const;
00045
00046 QString name() const { return mName; }
00047 void setName( QString name ) { mName = name; }
00048
00049 QColor borderColor() const { return mBorderColor; }
00050 void setBorderColor( QColor color ) { mBorderColor = color; }
00051
00052 protected:
00053
00054 void drawMarker( QPainter* p, QgsSymbolV2RenderContext& context );
00055
00056 bool prepareShape();
00057 bool preparePath();
00058
00059 void prepareCache( QgsSymbolV2RenderContext& context );
00060
00061 QColor mBorderColor;
00062 QPen mPen;
00063 QBrush mBrush;
00064 QPolygonF mPolygon;
00065 QPainterPath mPath;
00066 QString mName;
00067 QImage mCache;
00068 QPen mSelPen;
00069 QBrush mSelBrush;
00070 QImage mSelCache;
00071 bool mUsingCache;
00072 };
00073
00075
00076 #define DEFAULT_SVGMARKER_NAME "/symbol/Star1.svg"
00077 #define DEFAULT_SVGMARKER_SIZE 2*DEFAULT_POINT_SIZE
00078 #define DEFAULT_SVGMARKER_ANGLE 0
00079
00080 class CORE_EXPORT QgsSvgMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
00081 {
00082 public:
00083 QgsSvgMarkerSymbolLayerV2( QString name = DEFAULT_SVGMARKER_NAME,
00084 double size = DEFAULT_SVGMARKER_SIZE,
00085 double angle = DEFAULT_SVGMARKER_ANGLE );
00086
00087
00088
00089 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
00090
00092 static QStringList listSvgFiles();
00093
00095 static QString symbolNameToPath( QString name );
00096
00098 static QString symbolPathToName( QString path );
00099
00100
00101
00102 QString layerType() const;
00103
00104 void startRender( QgsSymbolV2RenderContext& context );
00105
00106 void stopRender( QgsSymbolV2RenderContext& context );
00107
00108 void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
00109
00110 QgsStringMap properties() const;
00111
00112 QgsSymbolLayerV2* clone() const;
00113
00114 QString path() const { return mPath; }
00115 void setPath( QString path ) { mPath = path; }
00116
00117 protected:
00118
00119 void loadSvg();
00120
00121 QString mPath;
00122 QPicture mPicture;
00123 QPicture mSelPicture;
00124 double mOrigSize;
00125 };
00126
00127
00129
00130 #define POINT2MM(x) ( (x) * 25.4 / 72 ) // point is 1/72 of inch
00131 #define MM2POINT(x) ( (x) * 72 / 25.4 )
00132
00133 #define DEFAULT_FONTMARKER_FONT "Dingbats"
00134 #define DEFAULT_FONTMARKER_CHR QChar('A')
00135 #define DEFAULT_FONTMARKER_SIZE POINT2MM(12)
00136 #define DEFAULT_FONTMARKER_COLOR QColor(Qt::black)
00137 #define DEFAULT_FONTMARKER_ANGLE 0
00138
00139 class CORE_EXPORT QgsFontMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
00140 {
00141 public:
00142 QgsFontMarkerSymbolLayerV2( QString fontFamily = DEFAULT_FONTMARKER_FONT,
00143 QChar chr = DEFAULT_FONTMARKER_CHR,
00144 double pointSize = DEFAULT_FONTMARKER_SIZE,
00145 QColor color = DEFAULT_FONTMARKER_COLOR,
00146 double angle = DEFAULT_FONTMARKER_ANGLE );
00147
00148
00149
00150 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
00151
00152
00153
00154 QString layerType() const;
00155
00156 void startRender( QgsSymbolV2RenderContext& context );
00157
00158 void stopRender( QgsSymbolV2RenderContext& context );
00159
00160 void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
00161
00162 QgsStringMap properties() const;
00163
00164 QgsSymbolLayerV2* clone() const;
00165
00166
00167
00168 QString fontFamily() const { return mFontFamily; }
00169 void setFontFamily( QString family ) { mFontFamily = family; }
00170
00171 QChar character() const { return mChr; }
00172 void setCharacter( QChar ch ) { mChr = ch; }
00173
00174 protected:
00175
00176 QString mFontFamily;
00177 QChar mChr;
00178
00179 QPointF mChrOffset;
00180 QFont mFont;
00181 double mOrigSize;
00182 };
00183
00184
00185 #endif