00001
00002 #ifndef QGSSYMBOLV2_H
00003 #define QGSSYMBOLV2_H
00004
00005 #include "qgis.h"
00006 #include <QList>
00007
00008 class QColor;
00009 class QImage;
00010 class QPainter;
00011 class QSize;
00012 class QPointF;
00013 class QPolygonF;
00014
00015
00016 class QgsSymbolLayerV2;
00017 class QgsRenderContext;
00018
00019 typedef QList<QgsSymbolLayerV2*> QgsSymbolLayerV2List;
00020
00021 class CORE_EXPORT QgsSymbolV2
00022 {
00023 public:
00024
00025 enum OutputUnit
00026 {
00027 MM,
00028 MapUnit
00029 };
00030
00031 enum SymbolType
00032 {
00033 Marker,
00034 Line,
00035 Fill
00036 };
00037
00039 enum RenderHint
00040 {
00041 DataDefinedSizeScale = 1,
00042 DataDefinedRotation = 2
00043 };
00044
00045 virtual ~QgsSymbolV2();
00046
00048 static QgsSymbolV2* defaultSymbol( QGis::GeometryType geomType );
00049
00050 SymbolType type() const { return mType; }
00051
00052
00053
00054 QgsSymbolLayerV2* symbolLayer( int layer );
00055
00056 int symbolLayerCount() { return mLayers.count(); }
00057
00059 bool insertSymbolLayer( int index, QgsSymbolLayerV2* layer );
00060
00062 bool appendSymbolLayer( QgsSymbolLayerV2* layer );
00063
00065 bool deleteSymbolLayer( int index );
00066
00068 QgsSymbolLayerV2* takeSymbolLayer( int index );
00069
00071 bool changeSymbolLayer( int index, QgsSymbolLayerV2* layer );
00072
00073
00074 void startRender( QgsRenderContext& context );
00075 void stopRender( QgsRenderContext& context );
00076
00077 void setColor( const QColor& color );
00078 QColor color();
00079
00080 void drawPreviewIcon( QPainter* painter, QSize size );
00081
00082 QImage bigSymbolPreviewImage();
00083
00084 QString dump();
00085
00086 virtual QgsSymbolV2* clone() const = 0;
00087
00088 OutputUnit outputUnit() const { return mOutputUnit; }
00089 void setOutputUnit( OutputUnit u ) { mOutputUnit = u; }
00090
00091 qreal alpha() const { return mAlpha; }
00092 void setAlpha( qreal alpha ) { mAlpha = alpha; }
00093
00095 void setRenderHints( int hints ) { mRenderHints = hints; }
00097 int renderHints() { return mRenderHints; }
00098
00099 protected:
00100 QgsSymbolV2( SymbolType type, QgsSymbolLayerV2List layers );
00101
00102 QgsSymbolLayerV2List cloneLayers() const;
00103
00104 SymbolType mType;
00105 QgsSymbolLayerV2List mLayers;
00106
00107 OutputUnit mOutputUnit;
00108
00110 qreal mAlpha;
00111
00112 int mRenderHints;
00113 };
00114
00116
00117 class CORE_EXPORT QgsSymbolV2RenderContext
00118 {
00119 public:
00120 QgsSymbolV2RenderContext( QgsRenderContext& c, QgsSymbolV2::OutputUnit u , qreal alpha = 1.0, bool selected = false, int renderHints = 0 );
00121 ~QgsSymbolV2RenderContext();
00122
00123 QgsRenderContext& renderContext() { return mRenderContext; }
00124
00125
00126 QgsSymbolV2::OutputUnit outputUnit() const { return mOutputUnit; }
00127 void setOutputUnit( QgsSymbolV2::OutputUnit u ) { mOutputUnit = u; }
00128
00129 qreal alpha() const { return mAlpha; }
00130 void setAlpha( qreal alpha ) { mAlpha = alpha; }
00131
00132 bool selected() const { return mSelected; }
00133 void setSelected( bool selected ) { mSelected = selected; }
00134
00136 int renderHints() const { return mRenderHints; }
00138 void setRenderHints( int hints ) { mRenderHints = hints; }
00139
00140
00141 static QColor selectionColor();
00142
00143 double outputLineWidth( double width ) const;
00144 double outputPixelSize( double size ) const;
00145
00146
00147 QgsSymbolV2RenderContext& operator=( const QgsSymbolV2RenderContext& );
00148
00149 private:
00150 QgsRenderContext& mRenderContext;
00151 QgsSymbolV2::OutputUnit mOutputUnit;
00152 qreal mAlpha;
00153 bool mSelected;
00154 int mRenderHints;
00155 };
00156
00157
00158
00160
00161
00162
00163 class CORE_EXPORT QgsMarkerSymbolV2 : public QgsSymbolV2
00164 {
00165 public:
00166 QgsMarkerSymbolV2( QgsSymbolLayerV2List layers = QgsSymbolLayerV2List() );
00167
00168 void setAngle( double angle );
00169 double angle();
00170
00171 void setSize( double size );
00172 double size();
00173
00174 void renderPoint( const QPointF& point, QgsRenderContext& context, int layer = -1, bool selected = false );
00175
00176 virtual QgsSymbolV2* clone() const;
00177 };
00178
00179
00180
00181 class CORE_EXPORT QgsLineSymbolV2 : public QgsSymbolV2
00182 {
00183 public:
00184 QgsLineSymbolV2( QgsSymbolLayerV2List layers = QgsSymbolLayerV2List() );
00185
00186 void setWidth( double width );
00187 double width();
00188
00189 void renderPolyline( const QPolygonF& points, QgsRenderContext& context, int layer = -1, bool selected = false );
00190
00191 virtual QgsSymbolV2* clone() const;
00192 };
00193
00194
00195
00196 class CORE_EXPORT QgsFillSymbolV2 : public QgsSymbolV2
00197 {
00198 public:
00199 QgsFillSymbolV2( QgsSymbolLayerV2List layers = QgsSymbolLayerV2List() );
00200
00201 void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context, int layer = -1, bool selected = false );
00202
00203 virtual QgsSymbolV2* clone() const;
00204 };
00205
00206 #endif
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229