2007-01-09 02:39:15 +00:00
|
|
|
class QgsRubberBand: QgsMapCanvasItem
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsrubberband.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
2012-11-14 12:58:33 +01:00
|
|
|
QgsRubberBand( QgsMapCanvas* mapCanvas /TransferThis/, QGis::GeometryType geometryType = QGis::Line );
|
|
|
|
QgsRubberBand( QgsMapCanvas* mapCanvas /TransferThis/, bool isPolygon );
|
2007-01-09 02:39:15 +00:00
|
|
|
~QgsRubberBand();
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
void setColor( const QColor & color );
|
|
|
|
void setWidth( int width );
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2012-11-14 12:58:33 +01:00
|
|
|
void reset( QGis::GeometryType geometryType = QGis::Line );
|
|
|
|
void reset( bool isPolygon );
|
2008-01-09 16:54:55 +00:00
|
|
|
|
2008-01-24 14:34:05 +00:00
|
|
|
//! Add point to rubberband and update canvas
|
|
|
|
//! If adding more points consider using update=false for better performance
|
|
|
|
//! geometryIndex is the index of the feature part (in case of multipart geometries)
|
2012-09-24 02:28:15 +02:00
|
|
|
void addPoint( const QgsPoint & p, bool update = true, int geometryIndex = 0 );
|
2008-01-09 16:54:55 +00:00
|
|
|
|
2009-12-20 12:29:07 +00:00
|
|
|
//!Removes the last point. Most useful in connection with undo operations
|
2012-09-24 02:28:15 +02:00
|
|
|
void removeLastPoint( int geometryIndex = 0 );
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
void movePoint( const QgsPoint & p, int geometryIndex = 0 );
|
|
|
|
/**Moves the rubber band point specified by index. Note that if the rubber band is
|
2008-01-24 14:34:05 +00:00
|
|
|
not used to track the last mouse position, the first point of the rubber band has two vertices*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 );
|
2008-01-24 14:34:05 +00:00
|
|
|
|
|
|
|
/**Sets this rubber band to the geometry of an existing feature.
|
2009-12-20 12:29:07 +00:00
|
|
|
This is useful for feature highlighting.
|
2008-01-09 16:54:55 +00:00
|
|
|
@param geom the geometry object
|
2012-09-24 02:28:15 +02:00
|
|
|
@param layer the layer containing the feature, used for coord transformation to map
|
2008-11-11 14:47:48 +00:00
|
|
|
crs. In case of 0 pointer, the coordinates are not going to be transformed.
|
2010-05-16 18:36:20 +00:00
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
|
2010-05-16 18:36:20 +00:00
|
|
|
|
2011-04-28 08:31:01 +00:00
|
|
|
/**Sets this rubber band to a map canvas rectangle
|
|
|
|
@param rect rectangle in canvas coordinates
|
|
|
|
@note added in version 1.7*/
|
|
|
|
void setToCanvasRectangle( const QRect& rect );
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/**Add the geometry of an existing feature to a rubberband
|
|
|
|
This is useful for multi feature highlighting.
|
|
|
|
@param geom the geometry object
|
|
|
|
@param layer the layer containing the feature, used for coord transformation to map
|
|
|
|
crs. In case of 0 pointer, the coordinates are not going to be transformed.
|
|
|
|
@note added in 1.5
|
|
|
|
*/
|
|
|
|
void addGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
|
|
|
|
|
2008-01-24 14:34:05 +00:00
|
|
|
/**Adds translation to original coordinates (all in map coordinates)*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void setTranslationOffset( double dx, double dy );
|
2008-01-09 16:54:55 +00:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/**Returns number of geometries
|
|
|
|
* added in 1.5 */
|
|
|
|
int size() const;
|
2010-05-16 18:36:20 +00:00
|
|
|
|
2008-01-24 14:34:05 +00:00
|
|
|
/**Returns count of vertices in all lists of mPoint*/
|
2008-01-09 16:54:55 +00:00
|
|
|
int numberOfVertices() const;
|
2007-09-30 23:45:36 +00:00
|
|
|
|
2008-03-13 13:11:53 +00:00
|
|
|
/**Return vertex*/
|
2012-09-24 02:28:15 +02:00
|
|
|
const QgsPoint *getPoint( int i, int j = 0 ) const;
|
|
|
|
|
2010-08-12 16:59:57 +00:00
|
|
|
/**Returns the rubberband as a Geometry.
|
|
|
|
* added in 1.6 */
|
|
|
|
QgsGeometry* asGeometry();
|
2008-03-13 13:11:53 +00:00
|
|
|
|
2007-01-09 02:39:15 +00:00
|
|
|
protected:
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual void paint( QPainter* p );
|
|
|
|
|
2007-01-09 02:39:15 +00:00
|
|
|
//! recalculates needed rectangle
|
|
|
|
void updateRect();
|
|
|
|
|
|
|
|
};
|