QgsSymbol Class Reference

#include <qgssymbol.h>

List of all members.


Detailed Description

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

Definition at line 35 of file qgssymbol.h.

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

Protected Member Functions

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

Protected Attributes

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

Private Member Functions

int readFieldName (QDomNode &synode, QString name, const QgsVectorLayer &vl)
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


Constructor & Destructor Documentation

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

Constructor.

Definition at line 39 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 57 of file qgssymbol.cpp.

References DEFAULT_LINE_WIDTH, and mPen.

QgsSymbol::QgsSymbol ( const QgsSymbol  ) 

Definition at line 105 of file qgssymbol.cpp.

References mBrush, mCacheUpToDate, mCacheUpToDate2, mLabel, mLowerValue, mPen, mPointSize, mPointSymbolImage, mPointSymbolImage2, mPointSymbolImageSelected, mPointSymbolImageSelected2, mPointSymbolName, mRotationClassificationField, mScaleClassificationField, mSelectionColor, mSelectionColor2, mTextureFilePath, mType, mUpperValue, and mWidthScale.

QgsSymbol::QgsSymbol (  ) 

old constructors

Definition at line 76 of file qgssymbol.cpp.

References DEFAULT_LINE_WIDTH, and mPen.

QgsSymbol::QgsSymbol ( QColor  c  ) 

Definition at line 90 of file qgssymbol.cpp.

References DEFAULT_LINE_WIDTH, and mPen.

QgsSymbol::~QgsSymbol (  )  [virtual]

Destructor.

Definition at line 132 of file qgssymbol.cpp.


Member Function Documentation

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

Sets the brush.

Definition at line 208 of file qgssymbol.h.

References mBrush.

const QBrush & QgsSymbol::brush (  )  const [inline, virtual]

Gets a reference to m_brush, Don't use the brush to change color/style.

Definition at line 213 of file qgssymbol.h.

References mBrush.

Referenced by cache(), cache2(), QgsComposerLegend::drawPolygonSymbol(), getPointSymbolAsImage(), QgsUniqueValueRenderer::renderFeature(), QgsSingleSymbolRenderer::renderFeature(), QgsGraduatedSymbolRenderer::renderFeature(), and QgsContinuousColorRenderer::renderFeature().

void QgsSymbol::setColor ( QColor  c  )  [virtual]

Set the color.

Definition at line 142 of file qgssymbol.cpp.

References mCacheUpToDate, mCacheUpToDate2, and mPen.

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

QColor QgsSymbol::color (  )  const [virtual]

Get the current color.

Definition at line 137 of file qgssymbol.cpp.

References mPen.

QColor QgsSymbol::fillColor (  )  const [virtual]

Get the fill color.

Definition at line 148 of file qgssymbol.cpp.

References mBrush.

Referenced by QgsContinuousColorRenderer::renderFeature().

void QgsSymbol::setFillColor ( QColor  c  )  [virtual]

Sets the fill color.

Definition at line 153 of file qgssymbol.cpp.

References mBrush, mCacheUpToDate, and mCacheUpToDate2.

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

double QgsSymbol::lineWidth (  )  const [virtual]

Get the line width.

Definition at line 159 of file qgssymbol.cpp.

References mPen.

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

Sets the line width.

Definition at line 164 of file qgssymbol.cpp.

References mCacheUpToDate, mCacheUpToDate2, and mPen.

Referenced by readXML().

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

Sets the pen.

Definition at line 218 of file qgssymbol.h.

References mPen.

const QPen & QgsSymbol::pen (  )  const [inline, virtual]

Gets a reference to m_pen.

Don't use the pen to change color/style

Definition at line 223 of file qgssymbol.h.

References mPen.

Referenced by cache(), cache2(), QgsComposerLegend::drawLineSymbol(), QgsComposerLegend::drawPolygonSymbol(), getPointSymbolAsImage(), QgsUniqueValueRenderer::renderFeature(), QgsSingleSymbolRenderer::renderFeature(), QgsGraduatedSymbolRenderer::renderFeature(), and QgsContinuousColorRenderer::renderFeature().

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

Set the line (pen) style.

Definition at line 170 of file qgssymbol.cpp.

References mCacheUpToDate, mCacheUpToDate2, and mPen.

Referenced by readXML().

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

Set the fill (brush) style.

Definition at line 176 of file qgssymbol.cpp.

References mBrush, mCacheUpToDate, and mCacheUpToDate2.

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

QString QgsSymbol::customTexture (  )  const [virtual]

Gets the path to the customs texture image.

Definition at line 182 of file qgssymbol.cpp.

References mTextureFilePath.

void QgsSymbol::setCustomTexture ( QString  path  )  [virtual]

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

Definition at line 187 of file qgssymbol.cpp.

References mBrush, mCacheUpToDate, mCacheUpToDate2, and mTextureFilePath.

Referenced by readXML().

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

Definition at line 228 of file qgssymbol.h.

References mLowerValue.

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

Definition at line 233 of file qgssymbol.h.

References mLowerValue.

Referenced by QgsLegendModel::itemFromSymbol(), QgsContinuousColorRenderer::renderFeature(), and QgsLegendModel::updateVectorClassificationItem().

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

Definition at line 238 of file qgssymbol.h.

References mUpperValue.

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

Definition at line 243 of file qgssymbol.h.

References mUpperValue.

Referenced by QgsLegendModel::itemFromSymbol(), and QgsLegendModel::updateVectorClassificationItem().

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

Definition at line 248 of file qgssymbol.h.

References mLabel.

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

Definition at line 253 of file qgssymbol.h.

References mLabel.

Referenced by QgsLegendModel::itemFromSymbol(), and QgsLegendModel::updateVectorClassificationItem().

void QgsSymbol::setNamedPointSymbol ( QString  name  )  [virtual]

Set point symbol from name.

Definition at line 196 of file qgssymbol.cpp.

References mCacheUpToDate, mCacheUpToDate2, mPointSymbolName, QgsDebugMsg, and QgsApplication::svgPath().

Referenced by readXML().

QString QgsSymbol::pointSymbolName (  )  const [virtual]

Get point symbol.

Definition at line 234 of file qgssymbol.cpp.

References mPointSymbolName.

Referenced by QgsContinuousColorRenderer::renderFeature(), and writeXML().

void QgsSymbol::setPointSize ( double  s  )  [virtual]

Set size.

Definition at line 239 of file qgssymbol.cpp.

References mCacheUpToDate, mCacheUpToDate2, MINIMUM_POINT_SIZE, and mPointSize.

Referenced by readXML().

double QgsSymbol::pointSize (  )  const [virtual]

Get size.

Definition at line 249 of file qgssymbol.cpp.

References mPointSize.

Referenced by QgsComposerLegend::drawPointSymbol(), QgsContinuousColorRenderer::renderFeature(), and writeXML().

QImage QgsSymbol::getLineSymbolAsImage (  )  [virtual]

Get a little icon for the legend.

Definition at line 255 of file qgssymbol.cpp.

References mPen.

Referenced by QgsLegendModel::itemFromSymbol().

QImage QgsSymbol::getPolygonSymbolAsImage (  )  [virtual]

Get a little icon for the legend.

Definition at line 275 of file qgssymbol.cpp.

References mBrush, and mPen.

Referenced by QgsLegendModel::itemFromSymbol().

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

Get QImage representation of point symbol with current settings.

Definition at line 315 of file qgssymbol.cpp.

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

Referenced by getPointSymbolAsImage().

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

Definition at line 341 of file qgssymbol.cpp.

References brush(), getCachedPointSymbolAsImage(), QgsMarkerCatalogue::imageMarker(), QgsMarkerCatalogue::instance(), mBrush, mPen, mPointSize, mPointSymbolName, mWidthScale, and pen().

Referenced by QgsComposerLegend::drawPointSymbol(), QgsLegendModel::itemFromSymbol(), QgsUniqueValueRenderer::renderFeature(), QgsSingleSymbolRenderer::renderFeature(), and QgsGraduatedSymbolRenderer::renderFeature().

bool QgsSymbol::writeXML ( QDomNode &  item,
QDomDocument &  document,
const QgsVectorLayer vl 
) const [virtual]

Writes the contents of the symbol to a configuration file @ return true in case of success.

Definition at line 438 of file qgssymbol.cpp.

References appendField(), appendText(), QgsSymbologyUtils::brushStyle2QString(), mBrush, mLabel, mLowerValue, mPen, mRotationClassificationField, mScaleClassificationField, mTextureFilePath, mUpperValue, QgsSymbologyUtils::penStyle2QString(), pointSize(), and pointSymbolName().

Referenced by QgsSingleSymbolRenderer::writeXML(), QgsContinuousColorRenderer::writeXML(), and QgsLegendModel::writeXML().

bool QgsSymbol::readXML ( QDomNode &  symbol,
const QgsVectorLayer vl 
) [virtual]

Reads the contents of the symbol from a configuration file @ return true in case of success.

Definition at line 499 of file qgssymbol.cpp.

References mLabel, mLowerValue, mRotationClassificationField, mScaleClassificationField, mUpperValue, QgsSymbologyUtils::qString2BrushStyle(), QgsSymbologyUtils::qString2PenStyle(), readFieldName(), setColor(), setCustomTexture(), setFillColor(), setFillStyle(), setLineStyle(), setLineWidth(), setNamedPointSymbol(), and setPointSize().

Referenced by QgsSingleSymbolRenderer::readXML().

QGis::GeometryType QgsSymbol::type (  )  const [inline]

Returns if this symbol is point/ line or polygon.

Definition at line 124 of file qgssymbol.h.

Referenced by QgsComposerLegend::drawSymbol(), and QgsLegendModel::itemFromSymbol().

int QgsSymbol::rotationClassificationField (  )  const

Returns the number of the rotation classification field.

Definition at line 587 of file qgssymbol.cpp.

References mRotationClassificationField.

Referenced by QgsUniqueValueRenderer::renderFeature(), QgsSingleSymbolRenderer::renderFeature(), QgsGraduatedSymbolRenderer::renderFeature(), and QgsSingleSymbolRenderer::updateSymbolAttributes().

void QgsSymbol::setRotationClassificationField ( int  field  ) 

Sets the number of the rotation classicifation field.

Parameters:
field the number of the field to classify for rotation

Definition at line 592 of file qgssymbol.cpp.

References mRotationClassificationField.

int QgsSymbol::scaleClassificationField (  )  const

Returns the number of the scale classification field.

Definition at line 597 of file qgssymbol.cpp.

References mScaleClassificationField.

Referenced by QgsUniqueValueRenderer::renderFeature(), QgsSingleSymbolRenderer::renderFeature(), QgsGraduatedSymbolRenderer::renderFeature(), and QgsSingleSymbolRenderer::updateSymbolAttributes().

void QgsSymbol::setScaleClassificationField ( int  field  ) 

Sets the number of the scale classicifation field.

Parameters:
field the number of the field to classify for scale

Definition at line 602 of file qgssymbol.cpp.

References mScaleClassificationField.

void QgsSymbol::cache ( QColor  selectionColor  )  [protected]

Definition at line 382 of file qgssymbol.cpp.

References brush(), QgsMarkerCatalogue::imageMarker(), QgsMarkerCatalogue::instance(), mBrush, mCacheUpToDate, mPen, mPointSize, mPointSymbolImage, mPointSymbolImageSelected, mPointSymbolName, mSelectionColor, and pen().

void QgsSymbol::cache2 ( double  widthScale,
QColor  selectionColor 
) [protected]

Definition at line 402 of file qgssymbol.cpp.

References brush(), QgsMarkerCatalogue::imageMarker(), QgsMarkerCatalogue::instance(), mBrush, mCacheUpToDate2, mPen, mPointSize, mPointSymbolImage2, mPointSymbolImageSelected2, mPointSymbolName, mSelectionColor2, mWidthScale, and pen().

Referenced by getCachedPointSymbolAsImage().

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

Definition at line 478 of file qgssymbol.cpp.

References QgsVectorLayer::pendingFields().

Referenced by readXML().

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

Definition at line 425 of file qgssymbol.cpp.

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

Referenced by writeXML().

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

Definition at line 430 of file qgssymbol.cpp.

Referenced by appendField(), and writeXML().


Member Data Documentation

QString QgsSymbol::mLowerValue [protected]

Lower value for classification.

Definition at line 141 of file qgssymbol.h.

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

QString QgsSymbol::mUpperValue [protected]

Upper value for classification.

Definition at line 143 of file qgssymbol.h.

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

QString QgsSymbol::mLabel [protected]

Definition at line 144 of file qgssymbol.h.

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

QGis::GeometryType QgsSymbol::mType [protected]

Vector type (point, line, polygon).

Definition at line 146 of file qgssymbol.h.

Referenced by QgsSymbol().

QPen QgsSymbol::mPen [protected]

Definition at line 148 of file qgssymbol.h.

Referenced by cache(), cache2(), color(), getLineSymbolAsImage(), getPointSymbolAsImage(), getPolygonSymbolAsImage(), lineWidth(), pen(), QgsSymbol(), setColor(), setLineStyle(), setLineWidth(), setPen(), and writeXML().

QBrush QgsSymbol::mBrush [protected]

Definition at line 149 of file qgssymbol.h.

Referenced by brush(), cache(), cache2(), fillColor(), getPointSymbolAsImage(), getPolygonSymbolAsImage(), QgsSymbol(), setBrush(), setCustomTexture(), setFillColor(), setFillStyle(), and writeXML().

QString QgsSymbol::mTextureFilePath [protected]

Definition at line 150 of file qgssymbol.h.

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

QString QgsSymbol::mPointSymbolName [protected]

Definition at line 152 of file qgssymbol.h.

Referenced by cache(), cache2(), getPointSymbolAsImage(), pointSymbolName(), QgsSymbol(), and setNamedPointSymbol().

double QgsSymbol::mPointSize [protected]

Definition at line 154 of file qgssymbol.h.

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

QImage QgsSymbol::mPointSymbolImage [protected]

Definition at line 169 of file qgssymbol.h.

Referenced by cache(), and QgsSymbol().

QImage QgsSymbol::mPointSymbolImageSelected [protected]

Definition at line 172 of file qgssymbol.h.

Referenced by cache(), and QgsSymbol().

double QgsSymbol::mWidthScale [protected]

Definition at line 175 of file qgssymbol.h.

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

QImage QgsSymbol::mPointSymbolImage2 [protected]

Definition at line 178 of file qgssymbol.h.

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

QImage QgsSymbol::mPointSymbolImageSelected2 [protected]

Definition at line 179 of file qgssymbol.h.

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

bool QgsSymbol::mCacheUpToDate [protected]

Definition at line 188 of file qgssymbol.h.

Referenced by cache(), QgsSymbol(), setColor(), setCustomTexture(), setFillColor(), setFillStyle(), setLineStyle(), setLineWidth(), setNamedPointSymbol(), and setPointSize().

bool QgsSymbol::mCacheUpToDate2 [protected]

Definition at line 191 of file qgssymbol.h.

Referenced by cache2(), getCachedPointSymbolAsImage(), QgsSymbol(), setColor(), setCustomTexture(), setFillColor(), setFillStyle(), setLineStyle(), setLineWidth(), setNamedPointSymbol(), and setPointSize().

QColor QgsSymbol::mSelectionColor [protected]

Definition at line 194 of file qgssymbol.h.

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

QColor QgsSymbol::mSelectionColor2 [protected]

Definition at line 195 of file qgssymbol.h.

Referenced by cache2(), and QgsSymbol().

int QgsSymbol::mRotationClassificationField [protected]

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

Definition at line 198 of file qgssymbol.h.

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

int QgsSymbol::mScaleClassificationField [protected]

Definition at line 199 of file qgssymbol.h.

Referenced by QgsSymbol(), readXML(), scaleClassificationField(), setScaleClassificationField(), and writeXML().


The documentation for this class was generated from the following files:
Generated on Tue Jan 6 16:51:23 2009 for Quantum GIS API Documentation by  doxygen 1.5.1