00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef QGSSYMBOL_H
00020 #define QGSSYMBOL_H
00021
00022 #include "qgis.h"
00023 #include <QBrush>
00024 #include <QPen>
00025 #include <QImage>
00026
00027 class QDomNode;
00028 class QDomDocument;
00029 class QDomElement;
00030
00031 class QgsVectorLayer;
00032
00035 class CORE_EXPORT QgsSymbol
00036 {
00037
00038 public:
00040 QgsSymbol( QGis::GeometryType t, QString lvalue = "", QString uvalue = "", QString label = "" );
00042 QgsSymbol( QGis::GeometryType t, QString lvalue, QString uvalue, QString label, QColor c );
00043 QgsSymbol( const QgsSymbol& );
00045 QgsSymbol();
00046 QgsSymbol( QColor c );
00048 virtual void setBrush( QBrush b );
00050 virtual const QBrush& brush() const;
00052 virtual void setColor( QColor c );
00054 virtual QColor color() const;
00056 virtual QColor fillColor() const;
00058 virtual void setFillColor( QColor c );
00060 virtual double lineWidth() const;
00062 virtual void setLineWidth( double w );
00064 virtual void setPen( QPen p );
00066 virtual const QPen& pen() const;
00067
00069 virtual void setLineStyle( Qt::PenStyle s );
00071 virtual void setFillStyle( Qt::BrushStyle s );
00072
00074 virtual QString customTexture() const;
00076 virtual void setCustomTexture( QString path );
00077
00078 virtual void setLowerValue( QString value );
00079 virtual QString lowerValue() const;
00080 virtual void setUpperValue( QString value );
00081 virtual QString upperValue() const;
00082 virtual void setLabel( QString label );
00083 virtual QString label() const;
00084
00086 virtual void setNamedPointSymbol( QString name );
00088 virtual QString pointSymbolName() const;
00090 virtual void setPointSize( double s );
00092 virtual double pointSize() const;
00094 virtual ~QgsSymbol();
00095
00097 virtual QImage getLineSymbolAsImage();
00098
00100 virtual QImage getPolygonSymbolAsImage();
00101
00104 virtual QImage getCachedPointSymbolAsImage( double widthScale = 1.,
00105 bool selected = false, QColor selectionColor = Qt::yellow );
00106
00107
00108
00109
00110 virtual QImage getPointSymbolAsImage( double widthScale = 1.,
00111 bool selected = false,
00112 QColor selectionColor = Qt::yellow,
00113 double scale = 1.0,
00114 double rotation = 0.0,
00115 double rasterScaleFactor = 1.0 );
00116
00119 virtual bool writeXML( QDomNode & item, QDomDocument & document, const QgsVectorLayer *vl ) const;
00122 virtual bool readXML( QDomNode & symbol, const QgsVectorLayer *vl );
00124 QGis::GeometryType type() const {return mType;}
00125
00127 int rotationClassificationField() const;
00130 void setRotationClassificationField( int field );
00131
00133 int scaleClassificationField() const;
00136 void setScaleClassificationField( int field );
00137
00138 protected:
00139
00141 QString mLowerValue;
00143 QString mUpperValue;
00144 QString mLabel;
00146 QGis::GeometryType mType;
00147
00148 QPen mPen;
00149 QBrush mBrush;
00150 QString mTextureFilePath;
00151
00152 QString mPointSymbolName;
00153
00154 double mPointSize;
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 QImage mPointSymbolImage;
00170
00171
00172 QImage mPointSymbolImageSelected;
00173
00174
00175 double mWidthScale;
00176
00177
00178 QImage mPointSymbolImage2;
00179 QImage mPointSymbolImageSelected2;
00180
00181
00182 void cache( QColor selectionColor );
00183
00184
00185 void cache2( double widthScale, QColor selectionColor );
00186
00187
00188 bool mCacheUpToDate;
00189
00190
00191 bool mCacheUpToDate2;
00192
00193
00194 QColor mSelectionColor;
00195 QColor mSelectionColor2;
00196
00198 int mRotationClassificationField;
00199 int mScaleClassificationField;
00200
00201 private:
00202 int readFieldName( QDomNode &synode, QString name, const QgsVectorLayer &vl );
00203 void appendField( QDomElement &symbol, QDomDocument &document, const QgsVectorLayer &vl, QString name, int idx ) const;
00204 void appendText( QDomElement &symbol, QDomDocument &document, QString name, QString value ) const;
00205
00206 };
00207
00208 inline void QgsSymbol::setBrush( QBrush b )
00209 {
00210 mBrush = b;
00211 }
00212
00213 inline const QBrush& QgsSymbol::brush() const
00214 {
00215 return mBrush;
00216 }
00217
00218 inline void QgsSymbol::setPen( QPen p )
00219 {
00220 mPen = p;
00221 }
00222
00223 inline const QPen& QgsSymbol::pen() const
00224 {
00225 return mPen;
00226 }
00227
00228 inline void QgsSymbol::setLowerValue( QString value )
00229 {
00230 mLowerValue = value;
00231 }
00232
00233 inline QString QgsSymbol::lowerValue() const
00234 {
00235 return mLowerValue;
00236 }
00237
00238 inline void QgsSymbol::setUpperValue( QString value )
00239 {
00240 mUpperValue = value;
00241 }
00242
00243 inline QString QgsSymbol::upperValue() const
00244 {
00245 return mUpperValue;
00246 }
00247
00248 inline void QgsSymbol::setLabel( QString label )
00249 {
00250 mLabel = label;
00251 }
00252
00253 inline QString QgsSymbol::label() const
00254 {
00255 return mLabel;
00256 }
00257
00258 #endif // QGSSYMBOL_H
00259
00260