24 #include <QDomElement>
28 : placement( AroundPoint )
29 , placementFlags( OnLine )
44 : placement( rh.placement )
45 , placementFlags( rh.placementFlags )
46 , priority( rh.priority )
48 , obstacle( rh.obstacle )
50 , renderer( rh.renderer ? rh.renderer->clone() : nullptr )
54 , xPosColumn( rh.xPosColumn )
55 , yPosColumn( rh.yPosColumn )
56 , showAll( rh.showAll )
146 if ( elem.
attribute(
"sizeType" ) ==
"MM" )
156 if ( elem.
attribute(
"labelPlacementMethod" ) ==
"Height" )
166 if ( elem.
attribute(
"diagramOrientation" ) ==
"Left" )
170 else if ( elem.
attribute(
"diagramOrientation" ) ==
"Right" )
174 else if ( elem.
attribute(
"diagramOrientation" ) ==
"Down" )
184 if ( elem.
attribute(
"scaleDependency" ) ==
"Diameter" )
203 if ( attributes.
length() > 0 )
205 for (
int i = 0; i < attributes.
size(); i++ )
225 for ( ; colorIt != colorList.
constEnd(); ++colorIt )
227 QColor newColor( *colorIt );
236 for ( ; catIt != catList.
constEnd(); ++catIt )
276 categoryElem.
setAttribute(
"labelPlacementMethod",
"Height" );
280 categoryElem.
setAttribute(
"labelPlacementMethod",
"XHeight" );
289 categoryElem.
setAttribute(
"scaleDependency",
"Diameter" );
296 categoryElem.
setAttribute(
"diagramOrientation",
"Left" );
300 categoryElem.
setAttribute(
"diagramOrientation",
"Right" );
304 categoryElem.
setAttribute(
"diagramOrientation",
"Down" );
308 categoryElem.
setAttribute(
"diagramOrientation",
"Up" );
312 categoryElem.
setAttribute(
"diagramOrientation",
"Up" );
322 for (
int i = 0; i < nCats; ++i )
336 : mDiagram( nullptr )
352 : mDiagram( other.mDiagram ? other.mDiagram->clone() : nullptr )
396 size.
rwidth() *= pixelToMap;
419 if ( diagramType ==
"Pie" )
423 else if ( diagramType ==
"Text" )
427 else if ( diagramType ==
"Histogram" )
483 if ( categoryElem.
isNull() )
488 mSettings.
readXML( categoryElem, layer );
495 mSettings.
writeXML( rendererElem, doc, layer );
557 if ( !settingsElem.
isNull() )
559 mSettings.
readXML( settingsElem, layer );
581 mSettings.
writeXML( rendererElem, doc, layer );
double zIndex
Z-index of diagrams, where diagrams with a higher z-index are drawn on top of diagrams with a lower z...
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
double minScaleDenominator
QgsSingleCategoryDiagramRenderer * clone() const override
Returns new instance that is equivalent to this one.
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.
Renders the diagrams for all features with the same settings.
~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, QPointF pos)
double scaleFactor() const
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
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)
const QgsMapToPixel * xform
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.
QgsLinearlyInterpolatedDiagramRenderer * clone() const override
Returns new instance that is equivalent to this one.
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 Q_DECL_DEPRECATED void renderDiagram(const QgsAttributes &att, QgsRenderContext &c, const QgsDiagramSettings &s, QPointF position)
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
virtual QgsDiagramRendererV2 * clone() const =0
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.
const QgsCoordinateTransform * ct
QList< QgsDiagramSettings > diagramSettings() const override
Returns list with all diagram settings in the renderer.
QgsDiagramLayerSettings & operator=(const QgsDiagramLayerSettings &rh)
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