Quantum GIS API Documentation  master-2bfffaa
QgsSymbol Class Reference

Encapsulates settings for drawing (QPen, QBrush, Point symbol) and classification (lower value, upper value) More...

#include <qgssymbol.h>

List of all members.

Public Member Functions

 QgsSymbol (QGis::GeometryType t, QString lvalue="", QString uvalue="", QString label="")
 Constructor.
 QgsSymbol (QGis::GeometryType t, QString lvalue, QString uvalue, QString label, QColor c)
 Constructor.
 QgsSymbol (const QgsSymbol &)
 QgsSymbol ()
 old constructors
 QgsSymbol (QColor c)
virtual ~QgsSymbol ()
 Destructor.
virtual const QBrush & brush () const
 Gets a reference to m_brush, Don't use the brush to change color/style.
virtual QColor color () const
 Get the current color.
virtual QString customTexture () const
 Gets the path to the customs texture image.
virtual QColor fillColor () const
 Get the fill color.
virtual QImage getCachedPointSymbolAsImage (double widthScale=1.0, bool selected=false, QColor selectionColor=Qt::yellow, double opacity=1.0)
 Get QImage representation of point symbol with current settings.
virtual QImage getLineSymbolAsImage ()
 Get a little icon for the legend.
virtual QImage getPointSymbolAsImage (double widthScale=1.0, bool selected=false, QColor selectionColor=Qt::yellow, double scale=1.0, double rotation=0.0, double rasterScaleFactor=1.0, double opacity=1.0)
 Get QImage representation of point symbol with current settings and scaled (can be slow when scale != 1.0)
virtual QImage getPolygonSymbolAsImage ()
 Get a little icon for the legend.
virtual QString label () const
virtual double lineWidth () const
 Get the line width.
virtual QString lowerValue () const
virtual const QPen & pen () const
 Gets a reference to m_pen.
virtual double pointSize () const
 Get size.
virtual bool pointSizeUnits () const
 get point size units
virtual QString pointSymbolName () const
 Get point symbol.
virtual bool readXML (QDomNode &symbol, const QgsVectorLayer *vl)
 Reads the contents of the symbol from a configuration file @ return true in case of success.
int rotationClassificationField () const
 Returns the number of the rotation classification field.
int scaleClassificationField () const
 Returns the number of the scale classification field.
virtual void setBrush (QBrush b)
 Sets the brush.
virtual void setColor (QColor c)
 Set the color.
virtual void setCustomTexture (QString path)
 Sets the path to the custom texture, and sets the brush to use TexturePattern.
virtual void setFillColor (QColor c)
 Sets the fill color.
virtual void setFillStyle (Qt::BrushStyle s)
 Set the fill (brush) style.
virtual void setLabel (QString label)
virtual void setLineStyle (Qt::PenStyle s)
 Set the line (pen) style.
virtual void setLineWidth (double w)
 Sets the line width.
virtual void setLowerValue (QString value)
virtual void setNamedPointSymbol (QString name)
 Set point symbol from name.
virtual void setPen (QPen p)
 Sets the pen.
virtual void setPointSize (double s)
 Set point size.
virtual void setPointSizeUnits (bool sizeInMapUnits)
 Set point size units.
void setRotationClassificationField (int field)
 Sets the number of the rotation classicifation field.
void setScaleClassificationField (int field)
 Sets the number of the scale classicifation field.
void setSymbolField (int field)
 Sets the number of the symbol field.
virtual void setUpperValue (QString value)
int symbolField () const
 Returns the number of the symbol field.
QGis::GeometryType type () const
 Returns if this symbol is point/ line or polygon.
virtual QString upperValue () const
virtual bool writeXML (QDomNode &item, QDomDocument &document, const QgsVectorLayer *vl) const
 Writes the contents of the symbol to a configuration file @ return true in case of success.

Protected Member Functions

void cache (QColor selectionColor)
void cache2 (double widthScale, QColor selectionColor, double opacity)

Protected Attributes

QBrush mBrush
bool mCacheUpToDate
bool mCacheUpToDate2
QString mLabel
QString mLowerValue
 Lower value for classification.
double mOpacity
QPen mPen
QImage mPointSymbolImage
QImage mPointSymbolImage2
QImage mPointSymbolImageSelected
QImage mPointSymbolImageSelected2
QString mPointSymbolName
int mRotationClassificationField
 Index of the classification fields (it must be a numerical field index)
int mScaleClassificationField
QColor mSelectionColor
QColor mSelectionColor2
double mSize
bool mSizeInMapUnits
int mSymbolField
QString mTextureFilePath
QGis::GeometryType mType
 Vector type (point, line, polygon)
QString mUpperValue
 Upper value for classification.
double mWidthScale

Private Member Functions

void appendField (QDomElement &symbol, QDomDocument &document, const QgsVectorLayer &vl, QString name, int idx) const
void appendText (QDomElement &symbol, QDomDocument &document, QString name, QString value) const
int readFieldName (QDomNode &synode, QString name, const QgsVectorLayer &vl)

Detailed Description

Encapsulates settings for drawing (QPen, QBrush, Point symbol) and classification (lower value, upper value)

Definition at line 34 of file qgssymbol.h.


Constructor & Destructor Documentation

QgsSymbol::QgsSymbol ( QGis::GeometryType  t,
QString  lvalue = "",
QString  uvalue = "",
QString  label = "" 
)

Constructor.

Definition at line 38 of file qgssymbol.cpp.

References DEFAULT_LINE_WIDTH, and mPen.

QgsSymbol::QgsSymbol ( QGis::GeometryType  t,
QString  lvalue,
QString  uvalue,
QString  label,
QColor  c 
)

Constructor.

Definition at line 58 of file qgssymbol.cpp.

References DEFAULT_LINE_WIDTH, and mPen.

old constructors

Definition at line 79 of file qgssymbol.cpp.

References DEFAULT_LINE_WIDTH, and mPen.

QgsSymbol::QgsSymbol ( QColor  c)

Definition at line 95 of file qgssymbol.cpp.

References DEFAULT_LINE_WIDTH, and mPen.

QgsSymbol::~QgsSymbol ( ) [virtual]

Destructor.

Definition at line 141 of file qgssymbol.cpp.


Member Function Documentation

void QgsSymbol::appendField ( QDomElement &  symbol,
QDomDocument &  document,
const QgsVectorLayer vl,
QString  name,
int  idx 
) const [private]

Definition at line 476 of file qgssymbol.cpp.

References appendText(), QgsFields::count(), and QgsVectorLayer::pendingFields().

Referenced by writeXML().

void QgsSymbol::appendText ( QDomElement &  symbol,
QDomDocument &  document,
QString  name,
QString  value 
) const [private]

Definition at line 483 of file qgssymbol.cpp.

Referenced by appendField(), and writeXML().

void QgsSymbol::cache2 ( double  widthScale,
QColor  selectionColor,
double  opacity 
) [protected]
QColor QgsSymbol::color ( void  ) const [virtual]

Get the current color.

Definition at line 146 of file qgssymbol.cpp.

References mPen.

Referenced by QgsSymbologyV2Conversion::symbolV1toV2().

QString QgsSymbol::customTexture ( ) const [virtual]

Gets the path to the customs texture image.

Definition at line 191 of file qgssymbol.cpp.

References mTextureFilePath.

QColor QgsSymbol::fillColor ( ) const [virtual]

Get the fill color.

Definition at line 157 of file qgssymbol.cpp.

References mBrush.

Referenced by QgsContinuousColorRenderer::renderFeature(), and QgsSymbologyV2Conversion::symbolV1toV2().

QImage QgsSymbol::getCachedPointSymbolAsImage ( double  widthScale = 1.0,
bool  selected = false,
QColor  selectionColor = Qt::yellow,
double  opacity = 1.0 
) [virtual]

Get QImage representation of point symbol with current settings.

Definition at line 355 of file qgssymbol.cpp.

References cache2(), mCacheUpToDate2, mOpacity, mPointSymbolImage2, mPointSymbolImageSelected2, and mSelectionColor.

Referenced by getPointSymbolAsImage().

QImage QgsSymbol::getLineSymbolAsImage ( ) [virtual]

Get a little icon for the legend.

Definition at line 295 of file qgssymbol.cpp.

References mPen.

Referenced by QgsLegendModel::itemFromSymbol(), and QgsComposerSymbolItem::readXML().

QImage QgsSymbol::getPointSymbolAsImage ( double  widthScale = 1.0,
bool  selected = false,
QColor  selectionColor = Qt::yellow,
double  scale = 1.0,
double  rotation = 0.0,
double  rasterScaleFactor = 1.0,
double  opacity = 1.0 
) [virtual]
QImage QgsSymbol::getPolygonSymbolAsImage ( ) [virtual]

Get a little icon for the legend.

Definition at line 315 of file qgssymbol.cpp.

References mBrush, and mPen.

Referenced by QgsLegendModel::itemFromSymbol(), and QgsComposerSymbolItem::readXML().

QString QgsSymbol::label ( ) const [inline, virtual]
double QgsSymbol::lineWidth ( ) const [virtual]

Get the line width.

Definition at line 168 of file qgssymbol.cpp.

References mPen.

Referenced by QgsSymbologyV2Conversion::symbolV1toV2().

int QgsSymbol::readFieldName ( QDomNode &  synode,
QString  name,
const QgsVectorLayer vl 
) [private]

Definition at line 565 of file qgssymbol.cpp.

References QgsFields::count(), and QgsVectorLayer::pendingFields().

Referenced by readXML().

void QgsSymbol::setBrush ( QBrush  b) [inline, virtual]

Sets the brush.

Definition at line 229 of file qgssymbol.h.

References mBrush.

void QgsSymbol::setColor ( QColor  c) [virtual]
void QgsSymbol::setCustomTexture ( QString  path) [virtual]

Sets the path to the custom texture, and sets the brush to use TexturePattern.

Definition at line 196 of file qgssymbol.cpp.

References mBrush, mCacheUpToDate, mCacheUpToDate2, and mTextureFilePath.

Referenced by readXML().

void QgsSymbol::setFillColor ( QColor  c) [virtual]
void QgsSymbol::setFillStyle ( Qt::BrushStyle  s) [virtual]

Set the fill (brush) style.

Definition at line 185 of file qgssymbol.cpp.

References mBrush, mCacheUpToDate, and mCacheUpToDate2.

Referenced by QgsSingleSymbolRenderer::QgsSingleSymbolRenderer(), readXML(), and QgsSymbologyV2Conversion::symbolV2toV1().

void QgsSymbol::setLabel ( QString  label) [inline, virtual]

Definition at line 269 of file qgssymbol.h.

References label(), and mLabel.

Referenced by QgsSymbologyV2Conversion::rendererV2toV1().

void QgsSymbol::setLineStyle ( Qt::PenStyle  s) [virtual]

Set the line (pen) style.

Definition at line 179 of file qgssymbol.cpp.

References mCacheUpToDate, mCacheUpToDate2, and mPen.

Referenced by readXML(), and QgsSymbologyV2Conversion::symbolV2toV1().

void QgsSymbol::setLineWidth ( double  w) [virtual]

Sets the line width.

Definition at line 173 of file qgssymbol.cpp.

References mCacheUpToDate, mCacheUpToDate2, and mPen.

Referenced by readXML(), and QgsSymbologyV2Conversion::symbolV2toV1().

void QgsSymbol::setLowerValue ( QString  value) [inline, virtual]

Definition at line 249 of file qgssymbol.h.

References mLowerValue.

Referenced by QgsSymbologyV2Conversion::rendererV2toV1().

void QgsSymbol::setPen ( QPen  p) [inline, virtual]

Sets the pen.

Definition at line 239 of file qgssymbol.h.

References mPen.

Referenced by QgsQuickPrint::printMap().

void QgsSymbol::setPointSizeUnits ( bool  sizeInMapUnits) [virtual]

Set point size units.

Definition at line 266 of file qgssymbol.cpp.

References mSizeInMapUnits.

Referenced by readXML(), and QgsSingleSymbolRenderer::renderFeature().

Sets the number of the rotation classicifation field.

Parameters:
fieldthe number of the field to classify for rotation

Definition at line 695 of file qgssymbol.cpp.

References mRotationClassificationField.

Sets the number of the scale classicifation field.

Parameters:
fieldthe number of the field to classify for scale

Definition at line 705 of file qgssymbol.cpp.

References mScaleClassificationField.

void QgsSymbol::setSymbolField ( int  field)

Sets the number of the symbol field.

Parameters:
fieldthe number of the field to select the symbol

Definition at line 715 of file qgssymbol.cpp.

References mSymbolField.

void QgsSymbol::setUpperValue ( QString  value) [inline, virtual]

Definition at line 259 of file qgssymbol.h.

References mUpperValue.

Referenced by QgsSymbologyV2Conversion::rendererV2toV1().

QString QgsSymbol::upperValue ( ) const [inline, virtual]

Member Data Documentation

QString QgsSymbol::mLabel [protected]

Definition at line 158 of file qgssymbol.h.

Referenced by label(), QgsSymbol(), readXML(), setLabel(), and writeXML().

QString QgsSymbol::mLowerValue [protected]

Lower value for classification.

Definition at line 155 of file qgssymbol.h.

Referenced by lowerValue(), QgsSymbol(), readXML(), setLowerValue(), and writeXML().

double QgsSymbol::mOpacity [protected]

Definition at line 199 of file qgssymbol.h.

Referenced by cache2(), and getCachedPointSymbolAsImage().

QImage QgsSymbol::mPointSymbolImage [protected]

Definition at line 186 of file qgssymbol.h.

Referenced by cache(), and QgsSymbol().

QImage QgsSymbol::mPointSymbolImage2 [protected]

Definition at line 195 of file qgssymbol.h.

Referenced by cache2(), getCachedPointSymbolAsImage(), and QgsSymbol().

Definition at line 189 of file qgssymbol.h.

Referenced by cache(), and QgsSymbol().

Definition at line 196 of file qgssymbol.h.

Referenced by cache2(), getCachedPointSymbolAsImage(), and QgsSymbol().

Index of the classification fields (it must be a numerical field index)

Definition at line 218 of file qgssymbol.h.

Referenced by QgsSymbol(), readXML(), rotationClassificationField(), setRotationClassificationField(), and writeXML().

QColor QgsSymbol::mSelectionColor [protected]

Definition at line 214 of file qgssymbol.h.

Referenced by cache(), getCachedPointSymbolAsImage(), and QgsSymbol().

QColor QgsSymbol::mSelectionColor2 [protected]

Definition at line 215 of file qgssymbol.h.

Referenced by cache2(), and QgsSymbol().

double QgsSymbol::mSize [protected]

Definition at line 168 of file qgssymbol.h.

Referenced by cache(), cache2(), getPointSymbolAsImage(), pointSize(), QgsSymbol(), and setPointSize().

int QgsSymbol::mSymbolField [protected]

Definition at line 220 of file qgssymbol.h.

Referenced by QgsSymbol(), readXML(), setSymbolField(), symbolField(), and writeXML().

QString QgsSymbol::mTextureFilePath [protected]

Definition at line 164 of file qgssymbol.h.

Referenced by customTexture(), QgsSymbol(), setCustomTexture(), and writeXML().

Vector type (point, line, polygon)

Definition at line 160 of file qgssymbol.h.

Referenced by QgsSymbol().

QString QgsSymbol::mUpperValue [protected]

Upper value for classification.

Definition at line 157 of file qgssymbol.h.

Referenced by QgsSymbol(), readXML(), setUpperValue(), upperValue(), and writeXML().

double QgsSymbol::mWidthScale [protected]

Definition at line 192 of file qgssymbol.h.

Referenced by cache2(), getPointSymbolAsImage(), and QgsSymbol().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines