37 #include <QDomElement>
38 #include <QDomDocument>
47 wkbPtr >> wkbType >> pt.
rx() >> pt.
ry();
50 wkbPtr +=
sizeof( double );
66 unsigned int wkbType, nPoints;
67 wkbPtr >> wkbType >> nPoints;
77 if ( clipToExtent && nPoints > 1 )
80 double cw = e.
width() / 10;
double ch = e.
height() / 10;
89 for (
unsigned int i = 0; i < nPoints; ++i, ++ptr )
93 wkbPtr +=
sizeof( double );
106 for (
int i = 0; i < pts.
size(); ++i, ++ptr )
118 unsigned int wkbType, numRings;
119 wkbPtr >> wkbType >> numRings;
132 double cw = e.
width() / 10;
double ch = e.
height() / 10;
135 for (
unsigned int idx = 0; idx < numRings; idx++ )
137 unsigned int nPoints;
144 for (
unsigned int jdx = 0; jdx < nPoints; ++jdx, ++ptr )
148 wkbPtr +=
sizeof( double );
168 for (
int i = 0; i < poly.
size(); ++i, ++ptr )
208 , mUsingSymbolLevels( false )
210 , mCurrentVertexMarkerSize( 3 )
235 if ( symbol == NULL )
279 QgsDebugMsg(
"point can be drawn only with marker symbol!" );
284 ((
QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );
294 QgsDebugMsg(
"linestring can be drawn only with line symbol!" );
299 ((
QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );
301 if ( drawVertexMarker )
309 QgsDebugMsg(
"polygon can be drawn only with fill symbol!" );
315 ((
QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.
count() ? &holes : NULL ), &feature, context, layer, selected );
317 if ( drawVertexMarker )
326 QgsDebugMsg(
"multi-point can be drawn only with marker symbol!" );
333 const unsigned char* ptr = wkbPtr;
336 for (
unsigned int i = 0; i < num; ++i )
339 ((
QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );
351 QgsDebugMsg(
"multi-linestring can be drawn only with line symbol!" );
358 const unsigned char* ptr = wkbPtr;
361 for (
unsigned int i = 0; i < num; ++i )
364 ((
QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );
366 if ( drawVertexMarker )
376 QgsDebugMsg(
"multi-polygon can be drawn only with fill symbol!" );
383 const unsigned char* ptr = wkbPtr;
387 for (
unsigned int i = 0; i < num; ++i )
390 ((
QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.
count() ? &holes : NULL ), &feature, context, layer, selected );
392 if ( drawVertexMarker )
404 return "UNKNOWN RENDERER\n";
429 if ( !effectElem.
isNull() )
456 if ( userStyleElem.
isNull() )
459 errorMessage =
"Info: UserStyle element not found.";
465 if ( featTypeStyleElem.
isNull() )
467 errorMessage =
"Info: FeatureTypeStyle element not found.";
474 bool needRuleRenderer =
false;
478 while ( !ruleElem.
isNull() )
485 QgsDebugMsg(
"more Rule elements found: need a RuleRenderer" );
486 needRuleRenderer =
true;
491 while ( !ruleChildElem.
isNull() )
494 if ( ruleChildElem.
localName() ==
"Filter" ||
495 ruleChildElem.
localName() ==
"MinScaleDenominator" ||
496 ruleChildElem.
localName() ==
"MaxScaleDenominator" )
498 QgsDebugMsg(
"Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" );
499 needRuleRenderer =
true;
506 if ( needRuleRenderer )
515 if ( needRuleRenderer )
517 rendererType =
"RuleRenderer";
521 rendererType =
"singleSymbol";
529 errorMessage =
QString(
"Error: Unable to get metadata for '%1' renderer." ).
arg( rendererType );
551 toSld( doc, featureTypeStyleElem );
554 return userStyleElem;
559 Q_UNUSED( iconSize );
583 Q_UNUSED( scaleDenominator );
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.
virtual QgsSymbolV2 * originalSymbolForFeature(QgsFeature &feature)
Return symbol for feature.
virtual void checkLegendSymbolItem(QString key, bool state=true)
item in symbology was checked
void setEnabled(const bool enabled)
Sets whether the effect is enabled.
const QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
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.
QgsRendererV2AbstractMetadata * rendererMetadata(QString rendererName)
get metadata for particular renderer. Returns NULL if not found in registry.
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
double yMaximum() const
Get the y maximum value (top side of rectangle)
void setDataDefinedSize(const QgsDataDefined &dd)
Set data defined size for whole symbol (including all symbol layers).
void transformInPlace(qreal &x, qreal &y) const
Transform device coordinates to map (world) coordinates.
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
VertexMarkerType
Editing vertex markers.
double clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent...
Base class for visual effects which can be applied to QPicture drawings.
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, QString rule="")
return a list of item text / symbol
QDomElement nextSiblingElement(const QString &tagName) const
Abstract base class for all geometries.
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
QgsPaintEffect * mPaintEffect
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
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 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 setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object.
QString number(int n, int base)
int count(const T &value) const
void append(const T &value)
QString localName() const
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)
static QgsPaintEffectRegistry * instance()
virtual bool legendSymbolItemChecked(QString key)
items of symbology items in legend is checked
int mCurrentVertexMarkerSize
The current size of editing marker.
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)
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.)
static QgsFeatureRendererV2 * defaultRenderer(QGis::GeometryType geomType)
return a new renderer - used by default in vector layers
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)
QgsFeatureRendererV2(QString type)
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 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 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.
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)
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
QDomElement createElement(const QString &tagName)
double width() const
Width of the rectangle.
static void trimPolygon(QPolygonF &pts, const QgsRectangle &clipRect)
Represents a vector layer which manages a vector based data sets.
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature)=0
to be overridden
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 renderVertexMarker(QPointF &pt, QgsRenderContext &context)
render editing vertex marker at specified point
double height() const
Height of the rectangle.
static void convertSymbolRotation(QgsSymbolV2 *symbol, const QString &field)