39 #include <QDomElement>
40 #include <QDomDocument>
49 wkbPtr >> wkbType >> pt.
rx() >> pt.
ry();
52 wkbPtr +=
sizeof( double );
68 unsigned int wkbType, nPoints;
69 wkbPtr >> wkbType >> nPoints;
80 if ( clipToExtent && nPoints > 1 )
83 double cw = e.
width() / 10;
double ch = e.
height() / 10;
92 for (
unsigned int i = 0; i < nPoints; ++i, ++ptr )
96 wkbPtr +=
sizeof( double );
98 wkbPtr +=
sizeof( double );
111 for (
int i = 0; i < pts.
size(); ++i, ++ptr )
123 unsigned int wkbType, numRings;
124 wkbPtr >> wkbType >> numRings;
138 double cw = e.
width() / 10;
double ch = e.
height() / 10;
141 for (
unsigned int idx = 0; idx < numRings; idx++ )
143 unsigned int nPoints;
150 for (
unsigned int jdx = 0; jdx < nPoints; ++jdx, ++ptr )
154 wkbPtr +=
sizeof( double );
156 wkbPtr +=
sizeof( double );
176 for (
int i = 0; i < poly.
size(); ++i, ++ptr )
216 , mUsingSymbolLevels( false )
218 , mCurrentVertexMarkerSize( 3 )
220 , mForceRaster( false )
272 if ( symbol == NULL )
291 bool deleteSegmentizedGeometry =
false;
309 deleteSegmentizedGeometry =
true;
321 QgsDebugMsg(
"point can be drawn only with marker symbol!" );
326 ((
QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );
333 QgsDebugMsg(
"linestring can be drawn only with line symbol!" );
338 ((
QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );
345 QgsDebugMsg(
"polygon can be drawn only with fill symbol!" );
351 ((
QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.
count() ? &holes : NULL ), &feature, context, layer, selected );
359 QgsDebugMsg(
"multi-point can be drawn only with marker symbol!" );
366 const unsigned char* ptr = wkbPtr;
369 for (
unsigned int i = 0; i < num; ++i )
372 ((
QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );
382 QgsDebugMsg(
"multi-linestring can be drawn only with line symbol!" );
389 const unsigned char* ptr = wkbPtr;
394 for (
unsigned int i = 0; i < num; ++i )
396 if ( geomCollection )
401 ((
QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );
411 QgsDebugMsg(
"multi-polygon can be drawn only with fill symbol!" );
418 const unsigned char* ptr = wkbPtr;
424 for (
unsigned int i = 0; i < num; ++i )
426 if ( geomCollection )
431 ((
QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.
count() ? &holes : NULL ), &feature, context, layer, selected );
439 if ( drawVertexMarker )
451 x = vertexPoint.
x(); y = vertexPoint.
y(); z = vertexPoint.
z();
456 mapPoint.
setX( x ); mapPoint.
setY( y );
462 if ( deleteSegmentizedGeometry )
464 delete segmentizedGeometry;
470 return "UNKNOWN RENDERER\n";
512 if ( !effectElem.
isNull() )
540 if ( userStyleElem.
isNull() )
543 errorMessage =
"Info: UserStyle element not found.";
549 if ( featTypeStyleElem.
isNull() )
551 errorMessage =
"Info: FeatureTypeStyle element not found.";
558 bool needRuleRenderer =
false;
562 while ( !ruleElem.
isNull() )
569 QgsDebugMsg(
"more Rule elements found: need a RuleRenderer" );
570 needRuleRenderer =
true;
575 while ( !ruleChildElem.
isNull() )
578 if ( ruleChildElem.
localName() ==
"Filter" ||
579 ruleChildElem.
localName() ==
"MinScaleDenominator" ||
580 ruleChildElem.
localName() ==
"MaxScaleDenominator" )
582 QgsDebugMsg(
"Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" );
583 needRuleRenderer =
true;
590 if ( needRuleRenderer )
599 if ( needRuleRenderer )
601 rendererType =
"RuleRenderer";
605 rendererType =
"singleSymbol";
613 errorMessage =
QString(
"Error: Unable to get metadata for '%1' renderer." ).
arg( rendererType );
635 toSld( doc, featureTypeStyleElem );
638 return userStyleElem;
643 Q_UNUSED( iconSize );
667 Q_UNUSED( scaleDenominator );
711 Q_FOREACH (
const QPointF& pt, pts )
717 Q_FOREACH (
const QPointF& pt, pts )
722 Q_FOREACH (
const QPolygonF& ring, *rings )
724 Q_FOREACH (
const QPointF& pt, ring )
QgsFeatureId id() const
Get the feature ID for this feature.
static QgsRendererV2Registry * instance()
#define RENDERER_TAG_NAME
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
A rectangle specified with double values.
void setEnabled(const bool enabled)
Sets whether the effect is enabled.
void setDataDefinedAngle(const QgsDataDefined &dd)
Set data defined angle for whole symbol (including all symbol layers).
A container class for data source field mapping or expression.
QgsFeatureRendererV2(const QString &type)
QDomNode appendChild(const QDomNode &newChild)
static QgsFeatureRendererV2 * loadSld(const QDomNode &node, QGis::GeometryType geomType, QString &errorMessage)
Create a new renderer according to the information contained in the UserStyle element of a SLD style ...
static const unsigned char * _getPoint(QPointF &pt, QgsRenderContext &context, const unsigned char *wkb)
QString attribute(const QString &name, const QString &defValue) const
virtual QString dump() const
for debugging
void setForceRasterRender(bool forceRaster)
Sets whether the renderer should be rendered to a raster destination.
double yMaximum() const
Get the y maximum value (top side of rectangle)
QgsFields fields() const
Returns the list of fields of this layer.
void setDataDefinedSize(const QgsDataDefined &dd)
Set data defined size for whole symbol (including all symbol layers).
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
virtual Q_DECL_DEPRECATED QgsSymbolV2 * originalSymbolForFeature(QgsFeature &feature)
Return symbol for feature.
static QgsExpressionContext createFeatureBasedContext(const QgsFeature &feature, const QgsFields &fields)
Helper function for creating an expression context which contains just a feature and fields collectio...
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
static const unsigned char * clippedLineWKB(const unsigned char *wkb, const QgsRectangle &clipExtent, QPolygonF &line)
Reads a polyline from WKB and clips it to clipExtent.
bool contains(const QgsRectangle &rect) const
return true when rectangle contains other rectangle
Calculate scale by the diameter.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
#define Q_NOWARN_DEPRECATED_PUSH
Base class for visual effects which can be applied to QPicture drawings.
QDomElement nextSiblingElement(const QString &tagName) const
Abstract base class for all geometries.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
virtual ~QgsFeatureRendererV2()
const QgsRectangle & extent() const
void renderVertexMarkerPolyline(QPolygonF &pts, QgsRenderContext &context)
render editing vertex marker for a polyline
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
const QgsCoordinateTransform * coordinateTransform() const
virtual Q_DECL_DEPRECATED bool willRenderFeature(QgsFeature &feat)
return whether the renderer will render a feature or not.
virtual bool legendSymbolItemChecked(const QString &key)
items of symbology items in legend is checked
QgsRendererV2AbstractMetadata * rendererMetadata(const QString &rendererName)
get metadata for particular renderer. Returns NULL if not found in registry.
QgsPaintEffect * mPaintEffect
virtual void checkLegendSymbolItem(const QString &key, bool state=true)
item in symbology was checked
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize)
return a list of symbology items for the legend
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
void renderFeatureWithSymbol(QgsFeature &feature, QgsSymbolV2 *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker)
QDomElement toElement() const
const QString & name() const
Get the display name of the layer.
virtual Q_DECL_DEPRECATED QgsSymbolV2List originalSymbolsForFeature(QgsFeature &feat)
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
Perform transforms between map coordinates and device coordinates.
virtual bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
static Type flatType(Type type)
void transformInPlace(double &x, double &y) const
Transform device coordinates to map (world) coordinates.
QString number(int n, int base)
int count(const T &value) const
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden.
void append(const T &value)
QString localName() const
static bool hasM(Type type)
Tests whether a WKB type contains m values.
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects. ...
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
Utility class for identifying a unique vertex within a geometry.
static QgsPaintEffectRegistry * instance()
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, const QString &rule="")
return a list of item text / symbol
int mCurrentVertexMarkerSize
The current size of editing marker.
void setAttribute(const QString &name, const QString &value)
VertexMarkerType
Editing vertex markers.
int toInt(bool *ok, int base) const
int mCurrentVertexMarkerType
The current type of editing marker.
static const unsigned char * _getPolygon(QPolygonF &pts, QList< QPolygonF > &holes, QgsRenderContext &context, const unsigned char *wkb, bool clipToExtent=true)
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the renderer.
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
virtual bool nextVertex(QgsVertexId &id, QgsPointV2 &vertex) const =0
Returns next vertex id and coordinates.
static QgsFeatureRendererV2 * defaultRenderer(QGis::GeometryType geomType)
return a new renderer - used by default in vector layers
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
for symbol levels
static void drawVertexMarker(double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize)
Draws a vertex symbol at (screen) coordinates x, y.
static void convertSymbolSizeScale(QgsSymbolV2 *symbol, QgsSymbolV2::ScaleMethod method, const QString &field)
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
QDomText createTextNode(const QString &value)
virtual void toSld(QDomDocument &doc, QDomElement &element) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
virtual QgsAbstractGeometryV2 * segmentize() const
Returns a version of the geometry without curves.
void renderVertexMarker(const QPointF &pt, QgsRenderContext &context)
render editing vertex marker at specified point
SymbolType
Type of the symbol.
#define Q_NOWARN_DEPRECATED_POP
void setDataDefinedWidth(const QgsDataDefined &dd)
Set data defined width for whole symbol (including all symbol layers).
void setUsingSymbolLevels(bool usingSymbolLevels)
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
Contains information about the context of a rendering operation.
QRectF boundingRect() const
void copyPaintEffect(QgsFeatureRendererV2 *destRenderer) const
Copies paint effect of this renderer to another renderer.
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
return list of symbols used for rendering the feature.
static QgsFeatureRendererV2 * load(QDomElement &symbologyElem)
create a renderer from XML element
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const
Return a list of symbology items for the legend.
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
void setVertexMarkerAppearance(int type, int size)
set type and size of editing vertex markers for subsequent rendering
QDomElement firstChildElement(const QString &tagName) const
void setScaleMethodToSymbol(QgsSymbolV2 *symbol, int scaleMethod)
virtual Q_DECL_DEPRECATED QDomElement writeSld(QDomDocument &doc, const QgsVectorLayer &layer) const
create the SLD UserStyle element following the SLD v1.1 specs
void renderVertexMarkerPolygon(QPolygonF &pts, QList< QPolygonF > *rings, QgsRenderContext &context)
render editing vertex marker for a polygon
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
const QgsAbstractGeometryV2 * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
const QgsMapToPixel & mapToPixel() const
static const unsigned char * _getLineString(QPolygonF &pts, QgsRenderContext &context, const unsigned char *wkb, bool clipToExtent=true)
Calculate scale by the area.
QDomElement createElement(const QString &tagName)
double width() const
Width of the rectangle.
static void trimPolygon(QPolygonF &pts, const QgsRectangle &clipRect)
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent...
Represents a vector layer which manages a vector based data sets.
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
const unsigned char * asWkb() const
Returns the buffer containing this geometry in WKB format.
double xMinimum() const
Get the x minimum value (left side of rectangle)
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
void setGeometry(const QgsAbstractGeometryV2 *geometry)
Sets pointer to original (unsegmentized) geometry.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
double height() const
Height of the rectangle.
static void convertSymbolRotation(QgsSymbolV2 *symbol, const QString &field)