QGIS API Documentation 3.99.0-Master (752b475928d)
Loading...
Searching...
No Matches
QgsHighlight Class Reference

Highlights features on the map. More...

#include <qgshighlight.h>

Inheritance diagram for QgsHighlight:

Public Member Functions

 QgsHighlight (QgsMapCanvas *mapCanvas, const QgsFeature &feature, QgsVectorLayer *layer)
 Constructor for highlighting true feature shape using feature attributes and renderer.
 QgsHighlight (QgsMapCanvas *mapCanvas, const QgsGeometry &geom, QgsMapLayer *layer)
 Constructor for QgsHighlight.
 ~QgsHighlight () override
void applyDefaultStyle ()
 Applies the default style from the user settings to the highlight.
double buffer () const
 Returns the line/stroke buffer size (in millimeters).
QColor color () const
 Returns the line/stroke color.
QColor fillColor () const
 Returns the fill color.
QgsMapLayerlayer () const
 Returns the layer for which this highlight has been created.
void setBuffer (double buffer)
 Sets the line/stroke buffer size (in millimeters).
void setColor (const QColor &color)
 Set line/stroke to color, polygon fill to color with alpha = 63.
void setFillColor (const QColor &fillColor)
 Fill color for the highlight.
void setMinWidth (double width)
 Sets the minimum line/stroke width (in millimeters).
void setWidth (int width)
 Set stroke width.
void updatePosition () override
 called on changed extent or resize event to update position of the item
int width () const
 Returns the stroke width.
Public Member Functions inherited from QgsMapCanvasItem
QRectF boundingRect () const override
QgsRectangle rect () const
 returns canvas item rectangle in map units
void setRect (const QgsRectangle &r, bool resetRotation=true)
 sets canvas item rectangle in map units
QPointF toCanvasCoordinates (const QgsPointXY &point) const
 transformation from map coordinates to screen coordinates
QgsPointXY toMapCoordinates (QPoint point) const
 transformation from screen coordinates to map coordinates

Protected Member Functions

void paint (QPainter *p) override
 function to be implemented by derived classes
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override
void updateRect ()
 recalculates needed rectangle
Protected Member Functions inherited from QgsMapCanvasItem
 QgsMapCanvasItem (QgsMapCanvas *mapCanvas)
 protected constructor: cannot be constructed directly
 ~QgsMapCanvasItem () override
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override
bool setRenderContextVariables (QPainter *p, QgsRenderContext &context) const
 Sets render context parameters.
void updateCanvas ()
 schedules map canvas for repaint

Properties

int buffer
QColor color
QColor fillColor
int width

Friends

class QgsMapToolAddFeature
class QgsUpdateGpsDetailsAction

Additional Inherited Members

Protected Attributes inherited from QgsMapCanvasItem
QSizeF mItemSize
 cached size of the item (to return in boundingRect())
QgsMapCanvasmMapCanvas = nullptr
 pointer to map canvas
QgsRectangle mRect
 cached canvas item rectangle in map coordinates encodes position (xmin,ymax) and size (width/height) used to re-position and re-size the item on zoom/pan while waiting for the renderer to complete.
double mRectRotation = 0.0

Detailed Description

Highlights features on the map.

The QgsHighlight class provides a transparent overlay canvas item for highlighting features or geometries on a map canvas.

color = QColor(Qt.red)
highlight = QgsHighlight(mapCanvas, feature, layer)
highlight.setColor(color)
color.setAlpha(50)
highlight.setFillColor(color)
highlight.show()
Highlights features on the map.

Definition at line 62 of file qgshighlight.h.

Constructor & Destructor Documentation

◆ QgsHighlight() [1/2]

QgsHighlight::QgsHighlight ( QgsMapCanvas * mapCanvas,
const QgsGeometry & geom,
QgsMapLayer * layer )

Constructor for QgsHighlight.

Parameters
mapCanvasassociated map canvas
geominitial geometry of highlight
layerassociated map layer

Definition at line 54 of file qgshighlight.cpp.

◆ QgsHighlight() [2/2]

QgsHighlight::QgsHighlight ( QgsMapCanvas * mapCanvas,
const QgsFeature & feature,
QgsVectorLayer * layer )

Constructor for highlighting true feature shape using feature attributes and renderer.

Parameters
mapCanvasmap canvas
feature
layervector layer

Definition at line 63 of file qgshighlight.cpp.

◆ ~QgsHighlight()

QgsHighlight::~QgsHighlight ( )
overridedefault

Member Function Documentation

◆ applyDefaultStyle()

void QgsHighlight::applyDefaultStyle ( )

Applies the default style from the user settings to the highlight.

Since
QGIS 3.30

Definition at line 303 of file qgshighlight.cpp.

◆ buffer()

double QgsHighlight::buffer ( ) const
inline

Returns the line/stroke buffer size (in millimeters).

See also
setBuffer()
Since
QGIS 3.4

Definition at line 154 of file qgshighlight.h.

◆ color()

QColor QgsHighlight::color ( ) const
inline

Returns the line/stroke color.

Since
QGIS 3.4

Definition at line 113 of file qgshighlight.h.

◆ fillColor()

QColor QgsHighlight::fillColor ( ) const
inline

Returns the fill color.

Since
QGIS 3.4

Definition at line 125 of file qgshighlight.h.

◆ layer()

QgsMapLayer * QgsHighlight::layer ( ) const
inline

Returns the layer for which this highlight has been created.

Definition at line 171 of file qgshighlight.h.

◆ paint() [1/2]

void QgsHighlight::paint ( QPainter * painter)
overrideprotectedvirtual

function to be implemented by derived classes

Implements QgsMapCanvasItem.

Definition at line 318 of file qgshighlight.cpp.

◆ paint() [2/2]

void QgsMapCanvasItem::paint ( QPainter * painter,
const QStyleOptionGraphicsItem * option,
QWidget * widget = nullptr )
overrideprotected

Definition at line 45 of file qgsmapcanvasitem.cpp.

◆ setBuffer()

void QgsHighlight::setBuffer ( double buffer)
inline

Sets the line/stroke buffer size (in millimeters).

See also
buffer()

Definition at line 161 of file qgshighlight.h.

◆ setColor()

void QgsHighlight::setColor ( const QColor & color)

Set line/stroke to color, polygon fill to color with alpha = 63.

This is legacy function, use setFillColor() after setColor() if different fill color is required.

Definition at line 110 of file qgshighlight.cpp.

◆ setFillColor()

void QgsHighlight::setFillColor ( const QColor & fillColor)

Fill color for the highlight.

Will be used for polygons and points.

Definition at line 119 of file qgshighlight.cpp.

◆ setMinWidth()

void QgsHighlight::setMinWidth ( double width)
inline

Sets the minimum line/stroke width (in millimeters).

Definition at line 166 of file qgshighlight.h.

◆ setWidth()

void QgsHighlight::setWidth ( int width)

Set stroke width.

Note
Ignored in feature mode.

Definition at line 200 of file qgshighlight.cpp.

◆ updatePosition()

void QgsHighlight::updatePosition ( )
overridevirtual

called on changed extent or resize event to update position of the item

Reimplemented from QgsMapCanvasItem.

Definition at line 290 of file qgshighlight.cpp.

◆ updateRect()

void QgsHighlight::updateRect ( )
protected

recalculates needed rectangle

Definition at line 482 of file qgshighlight.cpp.

◆ width()

int QgsHighlight::width ( ) const
inline

Returns the stroke width.

Since
QGIS 3.4

Definition at line 138 of file qgshighlight.h.

◆ QgsMapToolAddFeature

friend class QgsMapToolAddFeature
friend

Definition at line 223 of file qgshighlight.h.

◆ QgsUpdateGpsDetailsAction

friend class QgsUpdateGpsDetailsAction
friend

Definition at line 224 of file qgshighlight.h.

Property Documentation

◆ buffer

int QgsHighlight::buffer
readwrite

Definition at line 89 of file qgshighlight.h.

◆ color

QColor QgsHighlight::color
readwrite

Definition at line 86 of file qgshighlight.h.

◆ fillColor

QColor QgsHighlight::fillColor
readwrite

Definition at line 87 of file qgshighlight.h.

◆ width

int QgsHighlight::width
readwrite

Definition at line 88 of file qgshighlight.h.


The documentation for this class was generated from the following files: