24 #include <QDomElement>
28 : placement( AroundPoint )
29 , placementFlags( OnLine )
108 if ( elem.
attribute(
"sizeType" ) ==
"MM" )
118 if ( elem.
attribute(
"labelPlacementMethod" ) ==
"Height" )
128 if ( elem.
attribute(
"diagramOrientation" ) ==
"Left" )
132 else if ( elem.
attribute(
"diagramOrientation" ) ==
"Right" )
136 else if ( elem.
attribute(
"diagramOrientation" ) ==
"Down" )
146 if ( elem.
attribute(
"scaleDependency" ) ==
"Diameter" )
165 if ( attributes.
length() > 0 )
167 for (
int i = 0; i < attributes.
size(); i++ )
187 for ( ; colorIt != colorList.
constEnd(); ++colorIt )
189 QColor newColor( *colorIt );
198 for ( ; catIt != catList.
constEnd(); ++catIt )
238 categoryElem.
setAttribute(
"labelPlacementMethod",
"Height" );
242 categoryElem.
setAttribute(
"labelPlacementMethod",
"XHeight" );
251 categoryElem.
setAttribute(
"scaleDependency",
"Diameter" );
258 categoryElem.
setAttribute(
"diagramOrientation",
"Left" );
262 categoryElem.
setAttribute(
"diagramOrientation",
"Right" );
266 categoryElem.
setAttribute(
"diagramOrientation",
"Down" );
270 categoryElem.
setAttribute(
"diagramOrientation",
"Up" );
274 categoryElem.
setAttribute(
"diagramOrientation",
"Up" );
284 for (
int i = 0; i < nCats; ++i )
314 : mDiagram( other.mDiagram ? other.mDiagram->clone() : 0 )
358 size.
rwidth() *= pixelToMap;
381 if ( diagramType ==
"Pie" )
385 else if ( diagramType ==
"Text" )
389 else if ( diagramType ==
"Histogram" )
445 if ( categoryElem.
isNull() )
450 mSettings.
readXML( categoryElem, layer );
457 mSettings.
writeXML( rendererElem, doc, layer );
519 if ( !settingsElem.
isNull() )
521 mSettings.
readXML( settingsElem, layer );
543 mSettings.
writeXML( rendererElem, doc, layer );
QDomNodeList elementsByTagName(const QString &tagname) const
double minimumSize
Scale diagrams smaller than mMinimumSize to mMinimumSize.
void writeXML(QDomElement &layerElem, QDomDocument &doc, const QgsVectorLayer *layer) const override
QgsDiagramRendererV2 * clone() const override
Returns new instance that is equivalent to this one.
double minScaleDenominator
QDomNode appendChild(const QDomNode &newChild)
void fill(const QColor &color)
void push_back(const T &value)
void _readXML(const QDomElement &elem, const QgsVectorLayer *layer)
virtual QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const
Returns list of legend nodes for the diagram.
~QgsDiagramLayerSettings()
QString attribute(const QString &name, const QString &defValue) const
QList< QString > categoryAttributes
bool classificationAttributeIsExpression
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
unsigned int placementFlags
const T & at(int i) const
bool scaleBasedVisibility
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer.
QgsSingleCategoryDiagramRenderer()
~QgsLinearlyInterpolatedDiagramRenderer()
static int dpiPaintDevice(const QPainter *)
Returns the paint device dpi (or -1 in case of error.
void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, const QPointF &pos)
double scaleFactor() const
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual Q_DECL_DEPRECATED void renderDiagram(const QgsAttributes &att, QgsRenderContext &c, const QgsDiagramSettings &s, const QPointF &position)
void setNamedColor(const QString &name)
double toDouble(bool *ok) const
void readXML(const QDomElement &elem, const QgsVectorLayer *layer)
QList< QgsDiagramSettings > diagramSettings() const override
Returns list with all diagram settings in the renderer.
Returns diagram settings for a feature.
virtual QSizeF diagramSize(const QgsFeature &features, const QgsRenderContext &c)=0
Returns size of the diagram (in painter units) or an invalid size in case of error.
QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const override
Returns list of legend nodes for the diagram.
QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const override
Returns list of legend nodes for the diagram.
void convertSizeToMapUnits(QSizeF &size, const QgsRenderContext &context) const
Converts size from mm to map units.
QDomElement toElement() const
DiagramOrientation diagramOrientation
QString number(int n, int base)
void readXML(const QDomElement &elem, const QgsVectorLayer *layer) override
void append(const T &value)
bool fromString(const QString &descrip)
bool hasAttribute(const QString &name) const
virtual QSizeF sizeMapUnits(const QgsFeature &feature, const QgsRenderContext &c)
Returns size of the diagram for a feature in map units.
QgsAttributes attributes() const
Returns the feature's attributes.
void readXML(const QDomElement &elem, const QgsVectorLayer *layer)
void setAttribute(const QString &name, const QString &value)
void setWidth(qreal width)
QString classificationAttributeExpression
int toInt(bool *ok, int base) const
QPaintDevice * device() const
QgsDiagramLayerSettings()
QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const
Returns list of legend nodes for the diagram.
static bool setFromXmlChildNode(QFont &font, const QDomElement &element, const QString &childNode)
Sets the properties of a font to match the properties stored in an XML child node.
double mapUnitsPerPixel() const
Return current map units per pixel.
QgsDiagramRendererV2 * renderer
~QgsSingleCategoryDiagramRenderer()
Implementation of legend node interface for displaying arbitrary label with icon. ...
virtual QSizeF diagramSize(const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s)=0
Returns the size in map units the diagram will use to render.
QgsLinearlyInterpolatedDiagramRenderer()
Base class for all diagram types.
virtual QString diagramName() const =0
void writeXML(QDomElement &layerElem, QDomDocument &doc, const QgsVectorLayer *layer) const override
void readXML(const QDomElement &elem, const QgsVectorLayer *layer) override
Contains information about the context of a rendering operation.
virtual ~QgsDiagramRendererV2()
QList< QString > diagramAttributes() const override
Returns attribute indices needed for diagram rendering.
double maxScaleDenominator
QDomElement firstChildElement(const QString &tagName) const
void writeXML(QDomElement &layerElem, QDomDocument &doc, const QgsVectorLayer *layer) const
QgsDiagramRendererV2 * clone() const override
Returns new instance that is equivalent to this one.
const QgsMapToPixel & mapToPixel() const
QList< QString > categoryLabels
int classificationAttribute
Index of the classification attribute.
static QDomElement toXmlElement(const QFont &font, QDomDocument &document, const QString &elementName)
Returns a DOM element containing the properties of the font.
const_iterator constEnd() const
QDomElement createElement(const QString &tagName)
const_iterator constBegin() const
void setDiagram(QgsDiagram *d)
QSizeF diagramSize(const QgsFeature &, const QgsRenderContext &c) override
Returns size of the diagram (in painter units) or an invalid size in case of error.
Represents a vector layer which manages a vector based data sets.
void setHeight(qreal height)
QList< QColor > categoryColors
void writeXML(QDomElement &rendererElem, QDomDocument &doc, const QgsVectorLayer *layer) const
QgsDiagram * mDiagram
Reference to the object that does the real diagram rendering.
QList< QgsDiagramSettings > diagramSettings() const override
Returns list with all diagram settings in the renderer.
void _writeXML(QDomElement &rendererElem, QDomDocument &doc, const QgsVectorLayer *layer) const
LabelPlacementMethod labelPlacementMethod
QSizeF diagramSize(const QgsFeature &, const QgsRenderContext &c) override
Returns size of the diagram (in painter units) or an invalid size in case of error.
Layer tree node points to a map layer.
QDomNode at(int index) const