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->
wkbType() )
288 paintPoint( p, mGeometry->
asPoint() );
296 for (
int i = 0; i < m.
size(); i++ )
298 paintPoint( p, m[i] );
315 for (
int i = 0; i < m.
size(); i++ )
317 paintLine( p, m[i] );
325 paintPolygon( p, mGeometry->
asPolygon() );
333 for (
int i = 0; i < m.
size(); i++ )
335 paintPolygon( p, m[i] );
356 QColor tmpColor( 255, 0, 0, 255 );
357 QColor tmpFillColor( 0, 255, 0, 255 );
360 if ( layer && renderer )
364 QImage image =
QImage( imageSize.width(), imageSize.height(), QImage::Format_ARGB32 );
379 double k = ( 255. - mBrush.
color().
alpha() ) / 255.;
380 for (
int r = 0; r < image.height(); r++ )
382 for (
int c = 0; c < image.width(); c++ )
384 QRgb rgba = image.
pixel( c, r );
385 int alpha = qAlpha( rgba );
388 int green = qGreen( rgba );
389 color.
setAlpha( qBound<int>( 0, alpha - ( green * k ), 255 ) );
391 image.setPixel( c, r, color.
rgba() );
double borderWidth() const
A rectangle specified with double values.
Base class for all map layer types.
bool isEmpty() const
test if rectangle is empty.
virtual void updatePosition() override
called on changed extent or resize event to update position of the item
OutputUnit
The unit of the output.
virtual double width() const
void setRenderHint(RenderHint hint, bool on)
virtual void setOutlineColor(const QColor &color)
Set outline color.
void setXMaximum(double x)
Set the maximum x value.
QPointF toCanvasCoordinates(const QgsPoint &point) const
transformation from map coordinates to screen coordinates
const QgsCoordinateTransform * layerTransform(QgsMapLayer *layer) const
Return coordinate transform from layer's CRS to destination CRS.
double yMaximum() const
Get the y maximum value (top side of rectangle)
QgsFields fields() const
Returns the list of fields of this layer.
QgsMultiPolyline asMultiPolyline() const
Return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list.
QgsHighlight(QgsMapCanvas *mapCanvas, const QgsGeometry *geom, QgsMapLayer *layer)
void drawPolyline(const QPointF *points, int pointCount)
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
void setFillColor(const QColor &fillColor)
Set polygons fill color.
An abstract class for items that can be placed on the map canvas.
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
void setOutlineWidth(double w)
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule)
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
A geometry is the spatial representation of a feature.
const QgsMapToPixel & mapToPixel() const
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsRectangle rect() const
returns canvas item rectangle in map units
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)
double x() const
Get the x value of the point.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
QgsMultiPolygon asMultiPolygon() const
Return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
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
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 QgsFeatureRendererV2 * clone() const =0
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
The output shall be in millimeters.
void addPolygon(const QPolygonF &polygon)
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
void fill(uint pixelValue)
QSize outputSize() const
Return the size of the resulting map image.
double xMaximum() const
Get the x maximum value (right side of rectangle)
void setPen(const QColor &color)
QgsSymbolV2::OutputUnit outputUnit() const override
void setYMinimum(double y)
Set the minimum y value.
virtual void setWidth(double width)
void updateRect()
recalculates needed rectangle
double outlineWidth() const
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)
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
double mapUnitsPerPixel() const
Return current map units per pixel.
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
void setColor(const QColor &color)
const QgsMapLayer * layer() const
A class to represent a point.
virtual void setFillColor(const QColor &color)
Set fill color.
A class to represent a vector.
QgsGeometry * geometry()
Get the geometry object associated with this feature.
virtual QgsSymbolV2 * subSymbol()
QgsPolyline asPolyline() const
Return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list...
QgsSymbolV2::OutputUnit outlineWidthUnit() const
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.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
QgsMultiPoint asMultiPoint() const
Return contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty list...
QgsMapCanvas * mMapCanvas
pointer to map canvas
virtual void paint(QPainter *p) override
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
int transform(const QgsCoordinateTransform &ct)
Transform this geometry as described by CoordinateTransform ct.
void push_back(const T &value)
void setVisible(bool visible)
double y() const
Get the y value of the point.
virtual void setColor(const QColor &color)
The fill color.
QgsRectangle extent() const
Returns the current zoom exent of the map canvas.
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
double width() const
Width of the rectangle.
QgsPoint asPoint() const
Return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
Represents a vector layer which manages a vector based data sets.
void setColor(const QColor &color)
void setBorderWidth(double borderWidth)
double xMinimum() const
Get the x minimum value (left side of rectangle)
QgsSymbolV2::OutputUnit widthUnit() const
void setXMinimum(double x)
Set the minimum x value.
QgsPoint toMapPoint(double x, double y) const
void setWidth(int width)
Set width.