24 #include <QDomElement>
28 : placement( AroundPoint )
29 , placementFlags( OnLine )
109 if ( elem.
attribute(
"sizeType" ) ==
"MM" )
119 if ( elem.
attribute(
"labelPlacementMethod" ) ==
"Height" )
129 if ( elem.
attribute(
"diagramOrientation" ) ==
"Left" )
133 else if ( elem.
attribute(
"diagramOrientation" ) ==
"Right" )
137 else if ( elem.
attribute(
"diagramOrientation" ) ==
"Down" )
147 if ( elem.
attribute(
"scaleDependency" ) ==
"Diameter" )
166 if ( attributes.
length() > 0 )
168 for ( uint i = 0; i < attributes.
length(); i++ )
188 for ( ; colorIt != colorList.
constEnd(); ++colorIt )
190 QColor newColor( *colorIt );
199 for ( ; catIt != catList.
constEnd(); ++catIt )
239 categoryElem.
setAttribute(
"labelPlacementMethod",
"Height" );
243 categoryElem.
setAttribute(
"labelPlacementMethod",
"XHeight" );
252 categoryElem.
setAttribute(
"scaleDependency",
"Diameter" );
259 categoryElem.
setAttribute(
"diagramOrientation",
"Left" );
263 categoryElem.
setAttribute(
"diagramOrientation",
"Right" );
267 categoryElem.
setAttribute(
"diagramOrientation",
"Down" );
271 categoryElem.
setAttribute(
"diagramOrientation",
"Up" );
275 categoryElem.
setAttribute(
"diagramOrientation",
"Up" );
285 for (
int i = 0; i < nCats; ++i )
315 : mDiagram( other.mDiagram ? other.mDiagram->clone() : 0 )
359 size.
rwidth() *= pixelToMap;
382 if ( diagramType ==
"Pie" )
386 else if ( diagramType ==
"Text" )
390 else if ( diagramType ==
"Histogram" )
446 if ( categoryElem.
isNull() )
451 mSettings.
readXML( categoryElem, layer );
458 mSettings.
writeXML( rendererElem, doc, layer );
520 if ( !settingsElem.
isNull() )
522 mSettings.
readXML( settingsElem, layer );
544 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