59 mGeometry = geom ?
new QgsGeometry( *geom ) :
nullptr;
69 mGeometry = geom ?
new QgsGeometry( *geom ) :
nullptr;
75 , mGeometry( nullptr )
84 void QgsHighlight::init()
119 mBrush.
setStyle( Qt::SolidPattern );
125 mBrush.
setStyle( Qt::SolidPattern );
140 if ( !symbol )
continue;
141 setSymbol( symbol, context, color, fillColor );
149 if ( !symbol )
return;
155 if ( !symbolLayer )
continue;
159 setSymbol( symbolLayer->
subSymbol(), context, color, fillColor );
197 width = qMax( width + 2 * mBuffer * scale, mMinWidth * scale );
227 for (
int i = 0; i < line.
size(); i++ )
243 for (
int i = 0; i < polygon.
size(); i++ )
245 if ( polygon[i].empty() )
continue;
248 ring.
reserve( polygon[i].size() + 1 );
250 for (
int j = 0; j < polygon[i].
size(); j++ )
254 if ( 0 == j || std::abs( ring.
back().x() - cur.
x() ) > 1 || std::abs( ring.
back().y() - cur.
y() ) > 1 )
283 switch ( mGeometry->
type() )
289 paintPoint( p, mGeometry->
asPoint() );
294 for (
int i = 0; i < m.
size(); i++ )
296 paintPoint( p, m[i] );
312 for (
int i = 0; i < m.
size(); i++ )
314 paintLine( p, m[i] );
324 paintPolygon( p, mGeometry->
asPolygon() );
329 for (
int i = 0; i < m.
size(); i++ )
331 paintPolygon( p, m[i] );
353 QColor tmpColor( 255, 0, 0, 255 );
354 QColor tmpFillColor( 0, 255, 0, 255 );
357 if ( layer && renderer )
361 QImage image =
QImage( imageSize.width(), imageSize.height(), QImage::Format_ARGB32 );
376 double k = ( 255. - mBrush.
color().
alpha() ) / 255.;
377 for (
int r = 0; r < image.height(); r++ )
379 for (
int c = 0; c < image.width(); c++ )
381 QRgb rgba = image.
pixel( c, r );
382 int alpha = qAlpha( rgba );
385 int green = qGreen( rgba );
386 color.
setAlpha( qBound<int>( 0, alpha - ( green * k ), 255 ) );
388 image.setPixel( c, r, color.
rgba() );
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
QgsMultiPolyline asMultiPolyline() const
Return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list.
A rectangle specified with double values.
Base class for all map layer types.
virtual void updatePosition() override
called on changed extent or resize event to update position of the item
OutputUnit
The unit of the output.
QgsPoint asPoint() const
Return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
QgsRectangle rect() const
returns canvas item rectangle in map units
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
void setRenderHint(RenderHint hint, bool on)
virtual void setOutlineColor(const QColor &color)
Set outline color.
void setXMaximum(double x)
Set the maximum x value.
QgsHighlight(QgsMapCanvas *mapCanvas, const QgsGeometry *geom, QgsMapLayer *layer)
void drawPolyline(const QPointF *points, int pointCount)
void setFillColor(const QColor &fillColor)
Set polygons fill color.
An abstract class for items that can be placed on the map canvas.
void setOutlineWidth(double w)
Sets the width of the marker's outline.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
QgsPoint toMapPoint(double x, double y) const
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule)
A geometry is the spatial representation of a feature.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void setStyle(Qt::BrushStyle style)
virtual void removeDataDefinedProperty(const QString &property)
Removes a data defined property from the layer.
Map canvas is a class for displaying all GIS data types on a canvas.
uint pixel(int screen) const
void update(const QRectF &rect)
QgsPolyline asPolyline() const
Return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list...
double y() const
Get the y value of the point.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
QgsFields fields() const
Returns the list of fields of this layer.
The QgsMapSettings class contains configuration for rendering of the map.
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
const QColor & color() const
QPointF toCanvasCoordinates(const QgsPoint &point) const
transformation from map coordinates to screen coordinates
QgsMultiPoint asMultiPoint() const
Return contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty list...
Perform transforms between map coordinates and device coordinates.
virtual bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
Render a feature using this renderer in the given context.
virtual double width() const
virtual QgsFeatureRendererV2 * clone() const =0
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
The output shall be in millimeters.
void addPolygon(const QPolygonF &polygon)
void fill(uint pixelValue)
bool isEmpty() const
test if rectangle is empty.
void setPen(const QColor &color)
QgsSymbolV2::OutputUnit outputUnit() const override
double width() const
Width of the rectangle.
void setYMinimum(double y)
Set the minimum y value.
virtual void setWidth(double width)
void updateRect()
recalculates needed rectangle
QgsRectangle extent() const
Returns the current zoom exent of the map canvas.
void setRect(const QgsRectangle &r, bool resetRotation=true)
sets canvas item rectangle in map units
The output shall be in map unitx.
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
void setBrush(const QBrush &brush)
void setPainter(QPainter *p)
const QgsCoordinateTransform * layerTransform(QgsMapLayer *layer) const
Return coordinate transform from layer's CRS to destination CRS.
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
void setColor(const QColor &color)
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
double mapUnitsPerPixel() const
Return current map units per pixel.
A class to represent a point.
const QgsMapToPixel & mapToPixel() const
virtual void setFillColor(const QColor &color)
Set fill color.
A class to represent a vector.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
QgsGeometry * geometry()
Get the geometry object associated with this feature.
double xMaximum() const
Get the x maximum value (right side of rectangle)
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
virtual QgsSymbolV2 * subSymbol()
Contains information about the context of a rendering operation.
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
void drawPath(const QPainterPath &path)
static double lineWidthScaleFactor(const QgsRenderContext &c, QgsSymbolV2::OutputUnit u, const QgsMapUnitScale &scale=QgsMapUnitScale())
Returns the line width scale factor depending on the unit and the paint device.
void setColor(const QColor &color)
Set line/outline to color, polygon fill to color with alpha = 63.
void setYMaximum(double y)
Set the maximum y value.
QgsMultiPolygon asMultiPolygon() const
Return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
QgsMapCanvas * mMapCanvas
pointer to map canvas
double borderWidth() const
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
virtual void paint(QPainter *p) override
double outlineWidth() const
Returns the width of the marker's outline.
double xMinimum() const
Get the x minimum value (left side of rectangle)
int transform(const QgsCoordinateTransform &ct)
Transform this geometry as described by CoordinateTransform ct.
void push_back(const T &value)
void setVisible(bool visible)
virtual void setColor(const QColor &color)
The fill color.
double yMaximum() const
Get the y maximum value (top side of rectangle)
const QgsMapLayer * layer() const
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
QgsSymbolV2::OutputUnit outlineWidthUnit() const
Returns the unit for the width of the marker's outline.
Represents a vector layer which manages a vector based data sets.
void setColor(const QColor &color)
void setBorderWidth(double borderWidth)
QSize outputSize() const
Return the size of the resulting map image.
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an outline...
double x() const
Get the x value of the point.
void setXMinimum(double x)
Set the minimum x value.
QgsSymbolV2::OutputUnit widthUnit() const
void setWidth(int width)
Set width.