mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			448 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			448 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/gui/qgsrubberband.h                                              *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 | 
						|
 ************************************************************************/
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
%ModuleHeaderCode
 | 
						|
// For ConvertToSubClassCode.
 | 
						|
#include <qgsrubberband.h>
 | 
						|
%End
 | 
						|
 | 
						|
class QgsRubberBand : QgsMapCanvasItem
 | 
						|
{
 | 
						|
%Docstring(signature="appended")
 | 
						|
Responsible for drawing transient features (e.g. digitizing lines) on
 | 
						|
the map.
 | 
						|
 | 
						|
The :py:class:`QgsRubberBand` class provides a transparent overlay
 | 
						|
widget for tracking the mouse while drawing polylines or polygons.
 | 
						|
%End
 | 
						|
 | 
						|
%TypeHeaderCode
 | 
						|
#include "qgsrubberband.h"
 | 
						|
%End
 | 
						|
%ConvertToSubClassCode
 | 
						|
    if ( dynamic_cast<QgsRubberBand *>( sipCpp ) )
 | 
						|
    {
 | 
						|
      sipType = sipType_QgsRubberBand;
 | 
						|
      // We need to tweak the pointer as sip believes it is single inheritance
 | 
						|
      // from QgsMapCanvasItem, but the raw address of QgsRubberBand (sipCpp)
 | 
						|
      // is actually a QObject
 | 
						|
      *sipCppRet = dynamic_cast<QgsRubberBand *>( sipCpp );
 | 
						|
    }
 | 
						|
    else
 | 
						|
      sipType = nullptr;
 | 
						|
%End
 | 
						|
  public:
 | 
						|
 | 
						|
    enum IconType
 | 
						|
    {
 | 
						|
 | 
						|
      ICON_NONE,
 | 
						|
 | 
						|
      ICON_CROSS,
 | 
						|
 | 
						|
      ICON_X,
 | 
						|
 | 
						|
      ICON_BOX,
 | 
						|
 | 
						|
      ICON_CIRCLE,
 | 
						|
 | 
						|
      ICON_FULL_BOX,
 | 
						|
 | 
						|
      ICON_DIAMOND,
 | 
						|
 | 
						|
      ICON_FULL_DIAMOND,
 | 
						|
 | 
						|
      ICON_SVG
 | 
						|
    };
 | 
						|
 | 
						|
    QgsRubberBand( QgsMapCanvas *mapCanvas /TransferThis/, Qgis::GeometryType geometryType = Qgis::GeometryType::Line );
 | 
						|
%Docstring
 | 
						|
Creates a new RubberBand.
 | 
						|
 | 
						|
:param mapCanvas: The map canvas to draw onto. Its CRS will be used to
 | 
						|
                  map points onto screen coordinates. The ownership is
 | 
						|
                  transferred to this canvas.
 | 
						|
:param geometryType: Defines how the data should be drawn onto the
 | 
						|
                     screen. :py:class:`Qgis`.GeometryType.Line,
 | 
						|
                     :py:class:`Qgis`.GeometryType.Polygon or
 | 
						|
                     :py:class:`Qgis`.GeometryType.Point
 | 
						|
%End
 | 
						|
    ~QgsRubberBand();
 | 
						|
 | 
						|
    void setColor( const QColor &color );
 | 
						|
%Docstring
 | 
						|
Sets the color for the rubberband. Shorthand method to set fill and
 | 
						|
stroke color with a single call.
 | 
						|
 | 
						|
:param color: The color used to render this rubberband
 | 
						|
%End
 | 
						|
 | 
						|
    void setFillColor( const QColor &color );
 | 
						|
%Docstring
 | 
						|
Sets the fill color for the rubberband
 | 
						|
 | 
						|
:param color: The color used to render this rubberband
 | 
						|
%End
 | 
						|
 | 
						|
    QColor fillColor() const;
 | 
						|
%Docstring
 | 
						|
Returns the current fill color.
 | 
						|
%End
 | 
						|
 | 
						|
    void setStrokeColor( const QColor &color );
 | 
						|
%Docstring
 | 
						|
Sets the stroke color for the rubberband
 | 
						|
 | 
						|
:param color: The color used to render this rubberband
 | 
						|
%End
 | 
						|
 | 
						|
    QColor strokeColor() const;
 | 
						|
%Docstring
 | 
						|
Returns the current stroke color.
 | 
						|
%End
 | 
						|
 | 
						|
    void setSecondaryStrokeColor( const QColor &color );
 | 
						|
%Docstring
 | 
						|
Sets a secondary stroke color for the rubberband which will be drawn
 | 
						|
under the main stroke color. Set to an invalid color to avoid drawing
 | 
						|
the secondary stroke.
 | 
						|
 | 
						|
:param color: The color used to render a secondary stroke color to this
 | 
						|
              rubberband
 | 
						|
%End
 | 
						|
 | 
						|
    QColor secondaryStrokeColor() const;
 | 
						|
%Docstring
 | 
						|
Returns the current secondary stroke color.
 | 
						|
%End
 | 
						|
 | 
						|
    void setWidth( double width );
 | 
						|
%Docstring
 | 
						|
Sets the width of the line. Stroke width for polygon.
 | 
						|
 | 
						|
:param width: The width for any lines painted for this rubberband
 | 
						|
%End
 | 
						|
 | 
						|
    int width() const;
 | 
						|
%Docstring
 | 
						|
Returns the current width of the line or stroke width for polygon.
 | 
						|
%End
 | 
						|
 | 
						|
    void setIcon( IconType icon );
 | 
						|
%Docstring
 | 
						|
Sets the icon type to highlight point geometries.
 | 
						|
 | 
						|
:param icon: The icon to visualize point geometries
 | 
						|
%End
 | 
						|
 | 
						|
    void setSvgIcon( const QString &path, QPoint drawOffset );
 | 
						|
%Docstring
 | 
						|
Set the path to the svg file to use to draw points. Calling this
 | 
						|
function automatically calls setIcon(ICON_SVG)
 | 
						|
 | 
						|
:param path: The path to the svg
 | 
						|
:param drawOffset: The offset where to draw the image origin
 | 
						|
 | 
						|
.. versionadded:: 3.10
 | 
						|
%End
 | 
						|
 | 
						|
 | 
						|
    IconType icon() const;
 | 
						|
%Docstring
 | 
						|
Returns the current icon type to highlight point geometries.
 | 
						|
%End
 | 
						|
 | 
						|
    void setIconSize( double iconSize );
 | 
						|
%Docstring
 | 
						|
Sets the size of the point icons
 | 
						|
%End
 | 
						|
 | 
						|
    double iconSize() const;
 | 
						|
%Docstring
 | 
						|
Returns the current icon size of the point icons.
 | 
						|
%End
 | 
						|
 | 
						|
    void setLineStyle( Qt::PenStyle penStyle );
 | 
						|
%Docstring
 | 
						|
Sets the style of the line
 | 
						|
%End
 | 
						|
 | 
						|
    void setBrushStyle( Qt::BrushStyle brushStyle );
 | 
						|
%Docstring
 | 
						|
Sets the style of the brush
 | 
						|
%End
 | 
						|
 | 
						|
    void reset( Qgis::GeometryType geometryType = Qgis::GeometryType::Line );
 | 
						|
%Docstring
 | 
						|
Clears all the geometries in this rubberband. Sets the representation
 | 
						|
type according to geometryType.
 | 
						|
 | 
						|
:param geometryType: Defines how the data should be drawn onto the
 | 
						|
                     screen. (Use :py:class:`Qgis`.Line,
 | 
						|
                     :py:class:`Qgis`.Polygon or :py:class:`Qgis`.Point)
 | 
						|
%End
 | 
						|
 | 
						|
    void addPoint( const QgsPointXY &p, bool doUpdate = true, int geometryIndex = 0, int ringIndex = 0 );
 | 
						|
%Docstring
 | 
						|
Adds a vertex to the rubberband and update canvas. The rendering of the
 | 
						|
vertex depends on the current GeometryType and icon. If adding more
 | 
						|
points consider using update=``False`` for better performance
 | 
						|
 | 
						|
:param p: The vertex/point to add
 | 
						|
:param doUpdate: Should the map canvas be updated immediately?
 | 
						|
:param geometryIndex: The index of the feature part (in case of
 | 
						|
                      multipart geometries)
 | 
						|
:param ringIndex: The index of the polygon ring (in case of polygons
 | 
						|
                  with holes)
 | 
						|
%End
 | 
						|
 | 
						|
    void closePoints( bool doUpdate = true, int geometryIndex = 0, int ringIndex = 0 );
 | 
						|
%Docstring
 | 
						|
Ensures that a polygon geometry is closed and that the last vertex
 | 
						|
equals the first vertex.
 | 
						|
 | 
						|
:param doUpdate: set to ``True`` to update the map canvas immediately
 | 
						|
:param geometryIndex: The index of the feature part (in case of
 | 
						|
                      multipart geometries)
 | 
						|
:param ringIndex: The index of the polygon ring (in case of polygons
 | 
						|
                  with holes)
 | 
						|
%End
 | 
						|
 | 
						|
    void removePoint( int index = 0, bool doUpdate = true, int geometryIndex = 0, int ringIndex = 0 );
 | 
						|
%Docstring
 | 
						|
Removes a vertex from the rubberband and (optionally) updates canvas.
 | 
						|
 | 
						|
:param index: The index of the vertex/point to remove, negative indexes
 | 
						|
              start at end
 | 
						|
:param doUpdate: Should the map canvas be updated immediately?
 | 
						|
:param geometryIndex: The index of the feature part (in case of
 | 
						|
                      multipart geometries)
 | 
						|
:param ringIndex: The index of the polygon ring (in case of polygons
 | 
						|
                  with holes)
 | 
						|
%End
 | 
						|
 | 
						|
    void removeLastPoint( int geometryIndex = 0, bool doUpdate = true, int ringIndex = 0 );
 | 
						|
%Docstring
 | 
						|
Removes the last point. Most useful in connection with undo operations
 | 
						|
%End
 | 
						|
 | 
						|
    void movePoint( const QgsPointXY &p, int geometryIndex = 0, int ringIndex = 0 );
 | 
						|
%Docstring
 | 
						|
Moves the rubber band point specified by index. Note that if the rubber
 | 
						|
band is not used to track the last mouse position, the first point of
 | 
						|
the rubber band has two vertices
 | 
						|
%End
 | 
						|
 | 
						|
    void movePoint( int index, const QgsPointXY &p, int geometryIndex = 0, int ringIndex = 0 );
 | 
						|
%Docstring
 | 
						|
Moves the rubber band point specified by index. Note that if the rubber
 | 
						|
band is not used to track the last mouse position, the first point of
 | 
						|
the rubber band has two vertices
 | 
						|
%End
 | 
						|
 | 
						|
    int partSize( int geometryIndex ) const;
 | 
						|
%Docstring
 | 
						|
Returns number of vertices in feature part
 | 
						|
 | 
						|
:param geometryIndex: The index of the feature part (in case of
 | 
						|
                      multipart geometries)
 | 
						|
 | 
						|
:return: number of vertices
 | 
						|
%End
 | 
						|
 | 
						|
    void setToGeometry( const QgsGeometry &geom, QgsVectorLayer *layer );
 | 
						|
%Docstring
 | 
						|
Sets this rubber band to ``geom``. This is useful for feature
 | 
						|
highlighting. In contrast to :py:func:`~QgsRubberBand.addGeometry`, this
 | 
						|
method does also change the geometry type of the rubberband.
 | 
						|
 | 
						|
:param geom: the geometry object
 | 
						|
:param layer: the layer containing the feature, used for coord
 | 
						|
              transformation to map crs. If ``layer`` is ``None``, the
 | 
						|
              coordinates are not going to be transformed.
 | 
						|
%End
 | 
						|
 | 
						|
    void setToGeometry( const QgsGeometry &geometry, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
 | 
						|
%Docstring
 | 
						|
Sets this rubber band to ``geometry``. In contrast to
 | 
						|
:py:func:`~QgsRubberBand.addGeometry`, this method does also change the
 | 
						|
geometry type of the rubberband. The coordinate reference system of the
 | 
						|
geometry can be specified with ``crs``. If an invalid ``crs`` is passed,
 | 
						|
the geometry will not be reprojected and needs to be in canvas crs
 | 
						|
already. By default, no reprojection is done.
 | 
						|
 | 
						|
.. versionadded:: 3.4
 | 
						|
%End
 | 
						|
 | 
						|
    void setToCanvasRectangle( QRect rect );
 | 
						|
%Docstring
 | 
						|
Sets this rubber band to a map canvas rectangle
 | 
						|
 | 
						|
:param rect: rectangle in canvas coordinates
 | 
						|
%End
 | 
						|
 | 
						|
    void copyPointsFrom( const QgsRubberBand *other );
 | 
						|
%Docstring
 | 
						|
Copies the points from another rubber band.
 | 
						|
 | 
						|
.. versionadded:: 3.22
 | 
						|
%End
 | 
						|
 | 
						|
    void addGeometry( const QgsGeometry &geometry, QgsMapLayer *layer, bool doUpdate = true );
 | 
						|
%Docstring
 | 
						|
Adds the geometry of an existing feature to a rubberband This is useful
 | 
						|
for multi feature highlighting. As of 2.0, this method does not change
 | 
						|
the GeometryType any more. You need to set the GeometryType of the
 | 
						|
rubberband explicitly by calling :py:func:`~QgsRubberBand.reset` or
 | 
						|
:py:func:`~QgsRubberBand.setToGeometry` with appropriate arguments.
 | 
						|
:py:func:`~QgsRubberBand.setToGeometry` is also to be preferred for
 | 
						|
backwards-compatibility.
 | 
						|
 | 
						|
If additional geometries are to be added then set ``doUpdate`` to
 | 
						|
``False`` to defer costly repaint and bounding rectangle calculations
 | 
						|
for better performance. After adding the final geometry
 | 
						|
:py:func:`~QgsRubberBand.updatePosition` should be called.
 | 
						|
 | 
						|
:param geometry: the geometry object. Will be treated as a collection of
 | 
						|
                 vertices.
 | 
						|
:param layer: the layer associated with the geometry. This is used for
 | 
						|
              transforming the geometry from the layer's CRS to the map
 | 
						|
              crs. If ``layer`` is ``None`` no coordinate transformation
 | 
						|
              will occur.
 | 
						|
:param doUpdate: set to ``False`` to defer updates of the rubber band.
 | 
						|
%End
 | 
						|
 | 
						|
    void addGeometry( const QgsGeometry &geometry, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem(), bool doUpdate = true );
 | 
						|
%Docstring
 | 
						|
Adds a ``geometry`` to the rubberband.
 | 
						|
 | 
						|
If ``crs`` is specified, the geometry will be automatically reprojected
 | 
						|
from ``crs`` to the canvas CRS.
 | 
						|
 | 
						|
If additional geometries are to be added then set ``doUpdate`` to
 | 
						|
``False`` to defer costly repaint and bounding rectangle calculations
 | 
						|
for better performance. After adding the final geometry
 | 
						|
:py:func:`~QgsRubberBand.updatePosition` should be called.
 | 
						|
%End
 | 
						|
 | 
						|
    void setTranslationOffset( double dx, double dy );
 | 
						|
%Docstring
 | 
						|
Adds translation to original coordinates (all in map coordinates)
 | 
						|
 | 
						|
:param dx: x translation
 | 
						|
:param dy: y translation
 | 
						|
%End
 | 
						|
 | 
						|
    int size() const;
 | 
						|
%Docstring
 | 
						|
Returns number of geometries
 | 
						|
 | 
						|
:return: number of geometries
 | 
						|
%End
 | 
						|
 | 
						|
    int numberOfVertices() const;
 | 
						|
%Docstring
 | 
						|
Returns count of vertices in all lists of mPoint
 | 
						|
 | 
						|
:return: The total number of vertices
 | 
						|
%End
 | 
						|
 | 
						|
 | 
						|
    const QgsPointXY *getPoint( int i, int j = 0, int ringIndex = 0 ) const;
 | 
						|
%Docstring
 | 
						|
Returns a vertex
 | 
						|
 | 
						|
:param i: The geometry index
 | 
						|
:param j: The vertex index within ring ringIndex
 | 
						|
:param ringIndex: The ring index within geometry i
 | 
						|
%End
 | 
						|
 | 
						|
    QgsGeometry asGeometry() const;
 | 
						|
%Docstring
 | 
						|
Returns the rubberband as a Geometry
 | 
						|
 | 
						|
:return: A geometry object which reflects the current state of the
 | 
						|
         rubberband.
 | 
						|
%End
 | 
						|
 | 
						|
    virtual void updatePosition();
 | 
						|
 | 
						|
 | 
						|
    QgsSymbol *symbol() const;
 | 
						|
%Docstring
 | 
						|
Returns the symbol used for rendering the rubberband, if set.
 | 
						|
 | 
						|
.. seealso:: :py:func:`setSymbol`
 | 
						|
 | 
						|
.. versionadded:: 3.20
 | 
						|
%End
 | 
						|
 | 
						|
    void setSymbol( QgsSymbol *symbol /Transfer/ );
 | 
						|
%Docstring
 | 
						|
Sets the ``symbol`` used for rendering the rubberband.
 | 
						|
 | 
						|
Ownership of ``symbol`` is transferred to the rubberband.
 | 
						|
 | 
						|
.. warning::
 | 
						|
 | 
						|
   Only line and fill symbols are currently supported.
 | 
						|
 | 
						|
.. note::
 | 
						|
 | 
						|
   Setting a symbol for the rubberband overrides any other appearance setting,
 | 
						|
   such as the :py:func:`~QgsRubberBand.strokeColor` or :py:func:`~QgsRubberBand.width`.
 | 
						|
 | 
						|
.. seealso:: :py:func:`setSymbol`
 | 
						|
 | 
						|
.. versionadded:: 3.20
 | 
						|
%End
 | 
						|
 | 
						|
  protected:
 | 
						|
    virtual void paint( QPainter *p );
 | 
						|
 | 
						|
%Docstring
 | 
						|
Paints the rubber band in response to an update event.
 | 
						|
 | 
						|
:param p: The QPainter object
 | 
						|
%End
 | 
						|
 | 
						|
    void drawShape( QPainter *p, const QVector<QPointF> &pts );
 | 
						|
%Docstring
 | 
						|
Draws shape of the rubber band.
 | 
						|
 | 
						|
:param p: The QPainter object
 | 
						|
:param pts: A list of points used to draw the shape
 | 
						|
%End
 | 
						|
 | 
						|
    void drawShape( QPainter *p, const QVector<QPolygonF> &rings );
 | 
						|
%Docstring
 | 
						|
Draws shape of the rubber band.
 | 
						|
 | 
						|
:param p: The QPainter object
 | 
						|
:param rings: A list of points used to draw the shape
 | 
						|
%End
 | 
						|
 | 
						|
    void updateRect();
 | 
						|
%Docstring
 | 
						|
Recalculates needed rectangle
 | 
						|
%End
 | 
						|
 | 
						|
};
 | 
						|
 | 
						|
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/gui/qgsrubberband.h                                              *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 | 
						|
 ************************************************************************/
 |