27 #include <QDomDocument>
28 #include <QDomElement>
32 , mPreprocessingEnabled( false )
91 QRect e( context.
painter()->viewport() );
93 e.adjust( -e.width()*5, -e.height()*5, e.width()*5, e.height()*5 );
96 exteriorRing << mtp.toMapCoordinates( e.topRight() );
97 exteriorRing << mtp.toMapCoordinates( e.bottomRight() );
98 exteriorRing << mtp.toMapCoordinates( e.bottomLeft() );
99 exteriorRing << mtp.toMapCoordinates( e.topLeft() );
114 QRect v( context.
painter()->viewport() );
131 if ( selected || drawVertexMarker )
157 catId.append( reinterpret_cast<const char*>( &sym ),
sizeof( sym ) );
165 catId.append( reinterpret_cast<const char*>( &sym ),
sizeof( sym ) );
169 if ( catId.isEmpty() )
200 if ( ! geom->isGeosValid() )
202 geom.reset( geom->buffer( 0, 0 ) );
266 for (
int i = 0; i < multi.size(); i++ )
272 if ( exterior.count() < 4 || exterior[0] != exterior[exterior.count() - 1] )
274 finalMulti[0].append( exterior );
277 for (
int j = 1; j < multi[i].size(); j++ )
280 new_poly.append( multi[i][j] );
281 finalMulti.append( new_poly );
323 return "INVERTED: NULL";
347 QDomElement embeddedRendererElem = element.firstChildElement(
"renderer-v2" );
348 if ( !embeddedRendererElem.isNull() )
359 rendererElem.setAttribute(
"type",
"invertedPolygonRenderer" );
364 QDomElement embeddedRendererElem =
mSubRenderer->save( doc );
365 rendererElem.appendChild( embeddedRendererElem );
411 return QList<QString>();
431 return mSubRenderer->legendSymbolItems( scaleDenominator, rule );
virtual ~QgsInvertedPolygonRenderer()
#define RENDERER_TAG_NAME
A rectangle specified with double values.
virtual QgsFeatureRendererV2 * clone()
Used to clone this feature renderer.
QList< QgsSymbolV2 * > QgsSymbolV2List
QVector< QgsPoint > QgsPolyline
polyline is represented as a vector of points
QgsPolygon mExtentPolygon
the polygon used as exterior ring that covers the current extent
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, QString rule="")
Proxy that will call this method on the embedded renderer.
QgsPolygon asPolygon() const
return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list ...
bool mPreprocessingEnabled
whether to preprocess (merge) geometries before rendering
Container of fields for a vector layer.
QgsInvertedPolygonRenderer(const QgsFeatureRendererV2 *embeddedRenderer=0)
Constructor.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual int capabilities()
Proxy that will call this method on the embedded renderer.
const QgsCoordinateTransform * coordinateTransform() const
QgsGeometry * difference(QgsGeometry *geometry)
Returns a geometry representing the points making up this geometry that do not make up other...
void setExtent(const QgsRectangle &extent)
virtual QgsSymbolV2List symbols()
Proxy that will call this method on the embedded renderer.
QgsMultiPolygon asMultiPolygon() const
return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
void setCoordinateTransform(const QgsCoordinateTransform *t)
Sets coordinate transformation.
void setEmbeddedRenderer(const QgsFeatureRendererV2 *subRenderer)
sets the embedded renderer
Perform transforms between map coordinates and device coordinates.
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object (deep copy)
virtual void stopRender(QgsRenderContext &context)
The actual rendering will take place here.
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted...
void setPreprocessingEnabled(bool enabled)
bool preprocessingEnabled() const
QgsFields mFields
fields of each feature
QVector< QgsPolygon > QgsMultiPolygon
a collection of QgsPolygons that share a common collection of attributes
QGis::WkbType wkbType() const
Returns type of wkb (point / linestring / polygon etc.)
QVector< QgsPolyline > QgsPolygon
polygon: first item of the list is outer ring, inner rings (if any) start from second item ...
static QgsFeatureRendererV2 * defaultRenderer(QGis::GeometryType geomType)
return a new renderer - used by default in vector layers
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
virtual QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
Proxy that will call this method on the embedded renderer.
Class used to represent features that must be rendered with decorations (selection, vertex markers)
virtual bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
Renders a given feature.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
virtual QList< QString > usedAttributes()
Proxy that will call this method on the embedded renderer.
QgsPoint toMapCoordinates(int x, int y) const
Contains information about the context of a rendering operation.
const QgsFeatureRendererV2 * embeddedRenderer() const
QMap< QByteArray, int > mSymbolCategories
maps a category to an index
FeatureCategoryVector mFeaturesCategories
where features are stored, based on the index of their symbol category
static QgsFeatureRendererV2 * load(QDomElement &symbologyElem)
create a renderer from XML element
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
Proxy that will call this method on the embedded renderer.
const QgsMapToPixel & mapToPixel() const
static QgsGeometry * unaryUnion(const QList< QgsGeometry * > &geometryList)
compute the unary union on a list of geometries.
static QgsGeometry * fromMultiPolygon(const QgsMultiPolygon &multipoly)
construct geometry from a multipolygon
QgsRenderContext mContext
the context used for rendering
static QgsGeometry * fromPolygon(const QgsPolygon &polygon)
construct geometry from a polygon
virtual QDomElement save(QDomDocument &doc)
Creates an XML representation of the renderer.
virtual QString dump() const
static QgsFeatureRendererV2 * create(QDomElement &element)
Creates a renderer out of an XML, for loading.
QScopedPointer< QgsFeatureRendererV2 > mSubRenderer
Embedded renderer.
QList< QgsGeometry * > geometries
virtual bool willRenderFeature(QgsFeature &feat)
Proxy that will call this method on the embedded renderer.
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
QList< FeatureDecoration > mFeatureDecorations
Structure where the reversed geometry is built during renderFeature.
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize)
Proxy that will call this method on the embedded renderer.