/usr/include/qgis/qgsrubberband.h is in libqgis-dev 1.7.4+1.7.5~20120320-1.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | /***************************************************************************
qgsrubberband.h - Rubberband widget for drawing multilines and polygons
--------------------------------------
Date : 07-Jan-2006
Copyright : (C) 2006 by Tom Elwertowski
Email : telwertowski at users dot sourceforge dot net
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#ifndef QGSRUBBERBAND_H
#define QGSRUBBERBAND_H
#include "qgsmapcanvasitem.h"
#include "qgsgeometry.h"
#include <QBrush>
#include <QList>
#include <QPen>
#include <QPolygon>
class QgsVectorLayer;
class QPaintEvent;
/** \ingroup gui
* A class for drawing transient features (e.g. digitising lines) on the map.
*/
class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
{
public:
QgsRubberBand( QgsMapCanvas* mapCanvas, bool isPolygon = false );
~QgsRubberBand();
void setColor( const QColor & color );
void setWidth( int width );
void reset( bool isPolygon = false );
//! 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)
void addPoint( const QgsPoint & p, bool update = true, int geometryIndex = 0 );
//!Removes the last point. Most useful in connection with undo operations
void removeLastPoint( int geometryIndex = 0 );
void movePoint( const QgsPoint & p, int geometryIndex = 0 );
/**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*/
void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 );
/**Sets this rubber band to the geometry of an existing feature.
This is useful for 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.
*/
void setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
/**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 );
/**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 );
/**Adds translation to original coordinates (all in map coordinates)*/
void setTranslationOffset( double dx, double dy );
/**Returns number of geometries
* added in 1.5 */
int size() const;
/**Returns count of vertices in all lists of mPoint*/
int numberOfVertices() const;
/**Return vertex*/
const QgsPoint *getPoint( int i, int j = 0 ) const;
/**Returns the rubberband as a Geometry.
* added in 1.6 */
QgsGeometry* asGeometry();
protected:
virtual void paint( QPainter* p );
//! recalculates needed rectangle
void updateRect();
private:
QBrush mBrush;
QPen mPen;
/**Nested lists used for multitypes*/
QList< QList <QgsPoint> > mPoints;
bool mIsPolygon;
double mTranslationOffsetX;
double mTranslationOffsetY;
QgsRubberBand();
static QgsPolyline getPolyline( const QList<QgsPoint> & points );
};
#endif
|