geometry sip sync and some cosmetics

This commit is contained in:
Juergen E. Fischer 2016-01-28 10:30:06 +01:00
parent 7af58516bc
commit 4dd76da7f8
17 changed files with 346 additions and 88 deletions

View File

@ -70,46 +70,167 @@ class QgsAbstractGeometryV2
QgsAbstractGeometryV2( const QgsAbstractGeometryV2& geom );
//virtual QgsAbstractGeometryV2& operator=( const QgsAbstractGeometryV2& geom );
/** Clones the geometry by performing a deep copy
*/
virtual QgsAbstractGeometryV2* clone() const = 0;
/** Clears the geometry, ie reset it to a null geometry
*/
virtual void clear() = 0;
/** Returns the minimal bounding box for the geometry
*/
QgsRectangle boundingBox() const;
/** Calculates the minimal bounding box for the geometry. Derived classes should override this method
* to return the correct bounding box.
*/
virtual QgsRectangle calculateBoundingBox() const;
//mm-sql interface
/** Returns the inherent dimension of the geometry. For example, this is 0 for a point geometry,
* 1 for a linestring and 2 for a polygon.
*/
virtual int dimension() const = 0;
//virtual int coordDim() const { return mCoordDimension; }
/** Returns a unique string representing the geometry type.
* @see wkbType
* @see wktTypeStr
*/
virtual QString geometryType() const = 0;
/** Returns the WKB type of the geometry.
* @see geometryType
* @see wktTypeStr
*/
QgsWKBTypes::Type wkbType() const;
/** Returns the WKT type string of the geometry.
* @see geometryType
* @see wkbType
*/
QString wktTypeStr() const;
/** Returns true if the geometry is 3D and contains a z-value.
* @see isMeasure
*/
bool is3D() const;
/** Returns true if the geometry contains m values.
* @see is3D
*/
bool isMeasure() const;
//import
/** Sets the geometry from a WKB string.
* @see fromWkt
*/
virtual bool fromWkb( const unsigned char * wkb ) = 0;
/** Sets the geometry from a WKT string.
* @see fromWkb
*/
virtual bool fromWkt( const QString& wkt ) = 0;
//export
/** Returns the size of the WKB representation of the geometry.
* @see asWkb
*/
virtual int wkbSize() const = 0;
/** Returns a WKB representation of the geometry.
* @param binarySize will be set to the size of the returned WKB string
* @see wkbSize
* @see asWkt
* @see asGML2
* @see asGML3
* @see asJSON
*/
virtual unsigned char* asWkb( int& binarySize ) const = 0;
/** Returns a WKT representation of the geometry.
* @param precision number of decimal places for coordinates
* @see asWkb
* @see asGML2
* @see asGML3
* @see asJSON
*/
virtual QString asWkt( int precision = 17 ) const = 0;
/** Returns a GML2 representation of the geometry.
* @param doc DOM document
* @param precision number of decimal places for coordinates
* @param ns XML namespace
* @see asWkb
* @see asWkt
* @see asGML3
* @see asJSON
*/
virtual QDomElement asGML2( QDomDocument& doc, int precision = 17, const QString& ns = "gml" ) const = 0;
/** Returns a GML3 representation of the geometry.
* @param doc DOM document
* @param precision number of decimal places for coordinates
* @param ns XML namespace
* @see asWkb
* @see asWkt
* @see asGML2
* @see asJSON
*/
virtual QDomElement asGML3( QDomDocument& doc, int precision = 17, const QString& ns = "gml" ) const = 0;
/** Returns a GeoJSON representation of the geometry.
* @param precision number of decimal places for coordinates
* @see asWkb
* @see asWkt
* @see asGML2
* @see asGML3
*/
virtual QString asJSON( int precision = 17 ) const = 0;
virtual QgsRectangle calculateBoundingBox() const;
//render pipeline
/** Transforms the geometry using a coordinate transform
* @param ct coordinate transform
@param d transformation direction
*/
virtual void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform ) = 0;
/** Transforms the geometry using a QTransform object
* @param t QTransform transformation
*/
virtual void transform( const QTransform& t ) = 0;
//virtual void clip( const QgsRectangle& rect );
/** Draws the geometry using the specified QPainter.
* @param p destination QPainter
*/
virtual void draw( QPainter& p ) const = 0;
/** Returns next vertex id and coordinates
@return false if at end*/
* @param id initial value should be the starting vertex id. The next vertex id will be stored
* in this variable if found.
* @param vertex container for found node
* @return false if at end
*/
virtual bool nextVertex( QgsVertexId& id, QgsPointV2& vertex ) const = 0;
/** Retrieves the sequence of geometries, rings and nodes.
* @param coord destination for coordinate sequence.
*/
virtual void coordinateSequence( QList< QList< QList< QgsPointV2 > > >& coord /Out/ ) const = 0;
/** Returns the number of nodes contained in the geometry
*/
int nCoordinates() const;
/** Returns the point corresponding to a specified vertex id
*/
virtual QgsPointV2 vertexAt( const QgsVertexId& id ) const = 0;
/** Searches for the closest segment of the geometry to a given point.
@ -121,11 +242,34 @@ class QgsAbstractGeometryV2
* @param epsilon epsilon for segment snapping
* @returns squared distance to closest segment
*/
virtual double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const = 0;
virtual double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const = 0;
//low-level editing
/** Inserts a vertex into the geometry
* @param position vertex id for position of inserted vertex
* @param vertex vertex to insert
* @returns true if insert was successful
* @see moveVertex
* @see deleteVertex
*/
virtual bool insertVertex( const QgsVertexId& position, const QgsPointV2& vertex ) = 0;
/** Moves a vertex within the geometry
* @param position vertex id for vertex to move
* @param newPos new position of vertex
* @returns true if move was successful
* @see insertVertex
* @see deleteVertex
*/
virtual bool moveVertex( const QgsVertexId& position, const QgsPointV2& newPos ) = 0;
/** Deletes a vertex within the geometry
* @param position vertex id for vertex to delete
* @returns true if delete was successful
* @see insertVertex
* @see moveVertex
*/
virtual bool deleteVertex( const QgsVertexId& position ) = 0;
/** Returns the length of the geometry.
@ -146,15 +290,20 @@ class QgsAbstractGeometryV2
*/
virtual double area() const;
/** Returns the centroid of the geometry*/
/** Returns the centroid of the geometry */
virtual QgsPointV2 centroid() const;
/** Returns true if the geometry is empty
*/
bool isEmpty() const;
/** Returns true if the geometry contains curved segments
*/
virtual bool hasCurvedSegments() const;
/** Returns a geometry without curves. Caller takes ownership*/
/** Returns a version of the geometry without curves. Caller takes ownership of
* the returned geometry.
*/
virtual QgsAbstractGeometryV2* segmentize() const /Factory/;
/** Returns approximate angle at a vertex. This is usually the average angle between adjacent
@ -165,8 +314,8 @@ class QgsAbstractGeometryV2
*/
virtual double vertexAngle( const QgsVertexId& vertex ) const = 0;
virtual int vertexCount(int part = 0, int ring = 0) const = 0;
virtual int ringCount(int part = 0) const = 0;
virtual int vertexCount( int part = 0, int ring = 0 ) const = 0;
virtual int ringCount( int part = 0 ) const = 0;
/** Returns count of parts contained in the geometry.
* @see vertexCount
@ -178,7 +327,8 @@ class QgsAbstractGeometryV2
* @param zValue initial z-value for all nodes
* @returns true on success
* @note added in QGIS 2.12
* @see addMValue
* @see dropZValue()
* @see addMValue()
*/
virtual bool addZValue( double zValue = 0 ) = 0;
@ -186,7 +336,8 @@ class QgsAbstractGeometryV2
* @param mValue initial m-value for all nodes
* @returns true on success
* @note added in QGIS 2.12
* @see addZValue
* @see dropMValue()
* @see addZValue()
*/
virtual bool addMValue( double mValue = 0 ) = 0;

View File

@ -29,22 +29,51 @@ class QgsCircularStringV2: public QgsCurveV2
QString asJSON( int precision = 17 ) const;
int numPoints() const;
/** Returns the point at index i within the circular string.
*/
QgsPointV2 pointN( int i ) const;
/**
* @copydoc QgsCurveV2::points()
*/
void points( QList<QgsPointV2>& pts ) const;
/** Sets the circular string's points
*/
void setPoints( const QList<QgsPointV2>& points );
//curve interface
/**
* @copydoc QgsAbstractGeometryV2::length()
*/
virtual double length() const;
/**
* @copydoc QgsCurveV2::startPoint()
*/
virtual QgsPointV2 startPoint() const;
/**
* @copydoc QgsCurveV2::endPoint()
*/
virtual QgsPointV2 endPoint() const;
/**
* @copydoc QgsCurveV2::curveToLine()
*/
virtual QgsLineStringV2* curveToLine() const;
void draw( QPainter& p ) const;
/** Transforms the geometry using a coordinate transform
* @param ct coordinate transform
* @param d transformation direction
*/
void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform );
void transform( const QTransform& t );
//void clip( const QgsRectangle& rect );
void addToPainterPath( QPainterPath& path ) const;
/**
* @copydoc QgsCurveV2::drawAsPolygon()
*/
void drawAsPolygon( QPainter& p ) const;
virtual bool insertVertex( const QgsVertexId& position, const QgsPointV2& vertex );
@ -52,10 +81,19 @@ class QgsCircularStringV2: public QgsCurveV2
virtual bool deleteVertex( const QgsVertexId& position );
double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const;
/**
* @copydoc QgsCurveV2::pointAt()
*/
bool pointAt( int i, QgsPointV2& vertex, QgsVertexId::VertexType& type ) const;
/**
* @copydoc QgsCurveV2::sumUpArea()
*/
void sumUpArea( double& sum ) const;
/**
* @copydoc QgsAbstractGeometryV2::hasCurvedSegments()
*/
bool hasCurvedSegments() const;
/** Returns approximate rotation angle for a vertex. Usually average angle between adjacent segments.

View File

@ -37,17 +37,33 @@ class QgsCompoundCurveV2: public QgsCurveV2
virtual void points( QList<QgsPointV2>& pts ) const;
virtual int numPoints() const;
virtual QgsLineStringV2* curveToLine() const;
/** Returns the number of curves in the geometry.
*/
int nCurves() const;
/** Returns the curve at the specified index.
*/
const QgsCurveV2* curveAt( int i ) const;
/** Adds curve (takes ownership)*/
/** Adds a curve to the geometr (takes ownership)
*/
void addCurve( QgsCurveV2* c /Transfer/ );
/** Removes a curve from the geometry.
* @param i index of curve to remove
*/
void removeCurve( int i );
/** Adds a vertex to the end of the geometry.
*/
void addVertex( const QgsPointV2& pt );
/** Returns closed ring based on curve (connects to start point if not already done)*/
void close();
void draw( QPainter& p ) const;
/** Transforms the geometry using a coordinate transform
* @param ct coordinate transform
@param d transformation direction
*/
void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform );
void transform( const QTransform& t );
void addToPainterPath( QPainterPath& path ) const;
@ -58,10 +74,13 @@ class QgsCompoundCurveV2: public QgsCurveV2
virtual bool deleteVertex( const QgsVertexId& position );
virtual double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const;
bool pointAt( int i, QgsPointV2& vertex, QgsVertexId::VertexType& type ) const;
bool pointAt( int node, QgsPointV2& point, QgsVertexId::VertexType& type ) const;
void sumUpArea( double& sum ) const;
/** Appends first point if not already closed.*/
void close();
bool hasCurvedSegments() const;
/** Returns approximate rotation angle for a vertex. Usually average angle between adjacent segments.

View File

@ -47,13 +47,18 @@ class QgsCurvePolygonV2: public QgsSurfaceV2
*/
virtual void setExteriorRing( QgsCurveV2* ring /Transfer/ );
/** Sets interior rings (takes ownership)*/
/** Sets all interior rings (takes ownership)*/
void setInteriorRings( const QList<QgsCurveV2*>& rings );
/** Adds an interior ring to the geometry (takes ownership)*/
virtual void addInteriorRing( QgsCurveV2* ring /Transfer/ );
/** Removes ring. Exterior ring is 0, first interior ring 1, ...*/
bool removeInteriorRing( int nr );
virtual void draw( QPainter& p ) const;
/** Transforms the geometry using a coordinate transform
* @param ct coordinate transform
@param d transformation direction
*/
void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform );
void transform( const QTransform& t );
@ -73,9 +78,10 @@ class QgsCurvePolygonV2: public QgsSurfaceV2
@return rotation in radians, clockwise from north*/
double vertexAngle( const QgsVertexId& vertex ) const;
virtual int vertexCount(int part = 0, int ring = 0) const;
virtual int ringCount(int part = 0) const;
virtual int vertexCount( int /*part*/ = 0, int ring = 0) const;
virtual int ringCount( int /*part*/ = 0 ) const;
virtual int partCount() const;
virtual QgsPointV2 vertexAt( const QgsVertexId& id ) const;
virtual bool addZValue( double zValue = 0 );
virtual bool addMValue( double mValue = 0 );

View File

@ -87,6 +87,7 @@ class QgsGeometry
@note not available in python bindings
*/
// void fromGeos( GEOSGeometry* geos );
/**
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
This class will take ownership of the buffer.

View File

@ -12,8 +12,18 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
virtual QgsGeometryCollectionV2* clone() const;
/** Returns the number of geometries within the collection.
*/
int numGeometries() const;
/** Returns a const reference to a geometry from within the collection.
* @param n index of geometry to return
*/
//const QgsAbstractGeometryV2* geometryN( int n ) const;
/** Returns a geometry from within the collection.
* @param n index of geometry to return
*/
QgsAbstractGeometryV2* geometryN( int n );
//methods inherited from QgsAbstractGeometry
@ -21,7 +31,7 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
virtual QString geometryType() const;
virtual void clear();
/** Adds a geometry and takes ownership. Returns true in case of success*/
/** Adds a geometry and takes ownership. Returns true in case of success.*/
virtual bool addGeometry( QgsAbstractGeometryV2* g /Transfer/ );
/** Inserts a geometry before a specified index and takes ownership. Returns true in case of success.
@ -30,14 +40,25 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
*/
virtual bool insertGeometry( QgsAbstractGeometryV2* g /Transfer/, int index );
/** Removes a geometry from the collection.
* @param nr index of geometry to remove
* @returns true if removal was successful.
*/
virtual bool removeGeometry( int nr );
/** Transforms the geometry using a coordinate transform
* @param ct coordinate transform
* @param d transformation direction
*/
virtual void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform );
void transform( const QTransform& t );
//virtual void clip( const QgsRectangle& rect );
virtual void draw( QPainter& p ) const;
bool fromWkb( const unsigned char * wkb );
virtual bool fromWkt( const QString& wkt );
int wkbSize() const;
unsigned char* asWkb( int& binarySize ) const;
QString asWkt( int precision = 17 ) const;
@ -62,13 +83,16 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
bool hasCurvedSegments() const;
/** Returns a geometry without curves. Caller takes ownership*/
QgsAbstractGeometryV2* segmentize() const;
/** Returns approximate rotation angle for a vertex. Usually average angle between adjacent segments.
@param vertex the vertex id
@return rotation in radians, clockwise from north*/
double vertexAngle( const QgsVertexId& vertex ) const;
virtual int vertexCount(int part = 0, int ring = 0) const;
virtual int ringCount(int part = 0) const;
virtual int vertexCount( int part = 0, int ring = 0 ) const;
virtual int ringCount( int part = 0 ) const;
virtual int partCount() const;
virtual QgsPointV2 vertexAt( const QgsVertexId& id ) const;

View File

@ -3,7 +3,6 @@
* \brief Line string geometry type, with support for z-dimension and m-values.
* \note added in QGIS 2.10
*/
class QgsLineStringV2: public QgsCurveV2
{
%TypeHeaderCode
@ -84,7 +83,8 @@ class QgsLineStringV2: public QgsCurveV2
*/
void setMAt( int index, double m );
/** Resets the line string to match the specified list of points.
/** Resets the line string to match the specified list of points. The line string will
* inherit the dimensionality of the first point in the list.
* @param points new points for line string. If empty, line string will be cleared.
*/
void setPoints( const QList<QgsPointV2>& points );
@ -102,8 +102,6 @@ class QgsLineStringV2: public QgsCurveV2
/** Closes the line string by appending the first point to the end of the line, if it is not already closed.*/
void close();
virtual QgsLineStringV2* reversed() const /Factory/;
/** Returns a QPolygonF representing the line string.
*/
QPolygonF asQPolygonF() const;
@ -145,6 +143,8 @@ class QgsLineStringV2: public QgsCurveV2
virtual bool moveVertex( const QgsVertexId& position, const QgsPointV2& newPos );
virtual bool deleteVertex( const QgsVertexId& position );
virtual QgsLineStringV2* reversed() const /Factory/;
double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const;
bool pointAt( int i, QgsPointV2& vertex, QgsVertexId::VertexType& type ) const;

View File

@ -3,7 +3,6 @@
* \brief Point geometry type, with support for z-dimension and m-values.
* \note added in QGIS 2.10
*/
class QgsPointV2: public QgsAbstractGeometryV2
{
%TypeHeaderCode
@ -34,7 +33,7 @@ class QgsPointV2: public QgsAbstractGeometryV2
* @param m m-value of point, for PointM or PointZM types
*/
QgsPointV2( QgsWKBTypes::Type type, double x = 0.0, double y = 0.0, double z = 0.0, double m = 0.0 );
%MethodCode
%MethodCode
if ( QgsWKBTypes::flatType( a0 ) != QgsWKBTypes::Point )
{
PyErr_SetString(PyExc_ValueError,
@ -128,7 +127,7 @@ class QgsPointV2: public QgsAbstractGeometryV2
/** Sets the point's m-value.
* @note calling this will have no effect if the point does not contain a m-dimension. Use addMValue() to
* add an m value and force the point to have an m dimension.
* add a m value and force the point to have an m dimension.
* @see m()
* @see rm()
*/
@ -171,8 +170,8 @@ class QgsPointV2: public QgsAbstractGeometryV2
@return 0.0*/
double vertexAngle( const QgsVertexId& vertex ) const;
virtual int vertexCount(int part = 0, int ring = 0) const;
virtual int ringCount(int part = 0) const;
virtual int vertexCount( int /*part*/ = 0, int ring = 0 ) const;
virtual int ringCount( int /*part*/ = 0 ) const;
virtual int partCount() const;
virtual QgsPointV2 vertexAt( const QgsVertexId& id ) const;

View File

@ -14,6 +14,7 @@ class QgsPolygonV2: public QgsCurvePolygonV2
virtual QgsPolygonV2* clone() const;
virtual bool fromWkb( const unsigned char* wkb );
// inherited: bool fromWkt( const QString &wkt );
int wkbSize() const;
@ -28,4 +29,5 @@ class QgsPolygonV2: public QgsCurvePolygonV2
void addInteriorRing( QgsCurveV2* ring /Transfer/ );
//overridden to handle LineString25D rings
virtual void setExteriorRing( QgsCurveV2* ring /Transfer/ );
};

View File

@ -161,6 +161,7 @@ class QgsWKBTypes
* @param type original type
* @note added in QGIS 2.12
* @see addM()
* @see dropZ()
* @see hasZ()
*/
static Type addZ( Type type );
@ -169,6 +170,7 @@ class QgsWKBTypes
* @param type original type
* @note added in QGIS 2.12
* @see addZ()
* @see dropM()
* @see hasM()
*/
static Type addM( Type type );

View File

@ -33,20 +33,23 @@ class QgsClipper
static const double MIN_Y;
// A handy way to refer to the four boundaries
//! A handy way to refer to the four boundaries
enum Boundary {XMax, XMin, YMax, YMin};
%If (!ARM)
// Trims the given feature to a rectangular box. Returns the trimmed
// feature in x and y. The shapeOpen parameter determines whether
// the function treats the points as a closed shape (polygon), or as
// an open shape (linestring).
//
// @note not available in python bindings on android
/**
* Trims the given feature to a rectangular box. Returns the trimmed
* feature in x and y. The shapeOpen parameter determines whether
* the function treats the points as a closed shape (polygon), or as
* an open shape (linestring).
*
* @note not available in python bindings on android
*/
static void trimFeature( QVector<double>& x,
QVector<double>& y,
bool shapeOpen );
%End
static void trimPolygon( QPolygonF& pts, const QgsRectangle& clipRect );
/** Reads a polyline from WKB and clips it to clipExtent

View File

@ -17,7 +17,6 @@ class QgsSymbolV2LevelItem
int layer();
};
// every level has list of items: symbol + symbol layer num
// typedef QList< QgsSymbolV2LevelItem > QgsSymbolV2Level;
@ -62,8 +61,6 @@ class QgsFeatureRendererV2
QString type() const;
/** To be overridden
*
* Must be called between startRender() and stopRender() calls.
* @param feature feature
* @return returns pointer to symbol or 0 if symbol was not found
* @deprecated use symbolForFeature( QgsFeature& feature, QgsRenderContext& context ) instead
@ -71,8 +68,6 @@ class QgsFeatureRendererV2
virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature ) /Deprecated/;
/** To be overridden
*
* Must be called between startRender() and stopRender() calls.
* @param feature feature
* @param context render context
* @return returns pointer to symbol or 0 if symbol was not found
@ -103,19 +98,17 @@ class QgsFeatureRendererV2
virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature, QgsRenderContext& context ) /PyName=originalSymbolForFeature2/;
/**
* Return legend keys matching a specified feature.
* @note added in 2.14
* Needs to be called when a new render cycle is started
*
* @param context Additional information passed to the renderer about the job which will be rendered
* @param fields The fields available for rendering
* @return Information passed back from the renderer that can e.g. be used to reduce the amount of requested features
*/
virtual QSet< QString > legendKeysForFeature( QgsFeature& feature, QgsRenderContext& context );
virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) = 0;
//! @deprecated since 2.4 - not using QgsVectorLayer directly anymore
virtual void startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer ) /Deprecated/;
/**
* Needs to be called when a render cycle has finished to clean up.
*/
virtual void stopRender( QgsRenderContext& context ) = 0;
/**
@ -131,22 +124,17 @@ class QgsFeatureRendererV2
*/
virtual QString filter( const QgsFields& fields = QgsFields() );
/**
* Returns a set of attributes required for this renderer.
*
* TODO QGIS3: Change QList to QSet
*/
virtual QList<QString> usedAttributes() = 0;
virtual ~QgsFeatureRendererV2();
virtual QgsFeatureRendererV2* clone() const = 0 /Factory/;
/**
* Render a feature using this renderer in the given context.
* Must be called between startRender() and stopRender() calls.
* Default implementation renders a symbol as determined by symbolForFeature() call.
* Returns true if the feature has been returned (this is used for example
* to determine whether the feature may be labelled).
*
* If layer is not -1, the renderer should draw only a particula layer from symbols
* (in order to support symbol level rendering).
*/
virtual bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false );
//! for debugging
@ -247,8 +235,11 @@ class QgsFeatureRendererV2
void setVertexMarkerAppearance( int type, int size );
//! return rotation field name (or empty string if not set or not supported by renderer)
//! @deprecated use the symbol's methods instead
virtual QString rotationField() const /Deprecated/;
//! sets rotation field of renderer (if supported by the renderer)
//! @deprecated use the symbol's methods instead
virtual void setRotationField( const QString& fieldName ) /Deprecated/;
/** Returns whether the renderer will render a feature or not.
@ -290,7 +281,7 @@ class QgsFeatureRendererV2
*/
virtual QgsSymbolV2List originalSymbolsForFeature( QgsFeature& feat ) /Deprecated/;
/** Equivalent of originalSymbolsForFeature() call
/** Equivalent of originalSymbolsForFeature() call
* extended to support renderers that may use more symbols per feature - similar to symbolsForFeature()
* @note added in 2.12
* @note available in Python bindings as originalSymbolsForFeature2
@ -382,6 +373,7 @@ class QgsFeatureRendererV2
/** Copies paint effect of this renderer to another renderer
* @param destRenderer destination renderer for copied effect
* @deprecated use copyRendererData instead
*/
void copyPaintEffect( QgsFeatureRendererV2 *destRenderer ) const;
@ -389,7 +381,6 @@ class QgsFeatureRendererV2
* level DataDefined size
*/
static void convertSymbolSizeScale( QgsSymbolV2 * symbol, QgsSymbolV2::ScaleMethod method, const QString & field );
/** @note this function is used to convert old rotations expresssions to symbol
* level DataDefined angle
*/

View File

@ -93,16 +93,32 @@ class QgsSymbolV2
*/
int symbolLayerCount();
//! insert symbol layer to specified index
/**
* Insert symbol layer to specified index
* Ownership will be transferred.
* @param index The index at which the layer should be added
* @param layer The symbol layer to add
* @return True if the layer is added, False if the index or the layer is bad
*/
bool insertSymbolLayer( int index, QgsSymbolLayerV2* layer /Transfer/ );
//! append symbol layer at the end of the list
/**
* Append symbol layer at the end of the list
* Ownership will be transferred.
* @param layer The layer to add
* @return True if the layer is added, False if the layer is bad
*/
bool appendSymbolLayer( QgsSymbolLayerV2* layer /Transfer/ );
//! delete symbol layer at specified index
bool deleteSymbolLayer( int index );
//! remove symbol layer from the list and return pointer to it
/**
* Remove symbol layer from the list and return pointer to it.
* Ownership is handed to the caller.
* @param index The index of the layer to remove
* @return A pointer to the removed layer
*/
QgsSymbolLayerV2* takeSymbolLayer( int index ) /TransferBack/;
//! delete layer at specified index and set a new one
@ -183,6 +199,7 @@ class QgsSymbolV2
*/
bool hasDataDefinedProperties() const;
//! @note the layer will be NULL after stopRender
void setLayer( const QgsVectorLayer* layer );
const QgsVectorLayer* layer() const;
@ -202,7 +219,7 @@ class QgsSymbolV2
QgsSymbolV2( SymbolType type, const QgsSymbolLayerV2List& layers /Transfer/ ); // can't be instantiated
/**
Creates a point in screen coordinates from a QgsPointV2 in map coordinates
* Creates a point in screen coordinates from a QgsPointV2 in map coordinates
*/
static void _getPoint( QPointF& pt /Out/, QgsRenderContext& context, const QgsPointV2* point );
/**
@ -210,13 +227,19 @@ class QgsSymbolV2
* coordinates
*/
static const unsigned char* _getLineString( QPolygonF& pts, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent = true );
/**
* Creates a polygon in screen coordinates from a wkb string in map
* coordinates
*/
static const unsigned char* _getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent = true );
/**
* Retrieve a cloned list of all layers that make up this symbol.
* Ownership is transferred to the caller.
*/
QgsSymbolLayerV2List cloneLayers() const /Factory/;
/**
* Renders a context using a particular symbol layer without passing in a
* geometry. This is used as fallback, if the symbol being rendered is not
@ -230,7 +253,8 @@ class QgsSymbolV2
//! check whether a symbol layer type can be used within the symbol
//! (marker-marker, line-line, fill-fill/line)
bool isSymbolLayerCompatible( SymbolType t );
//! @deprecated since 2.14, use QgsSymbolLayerV2::isCompatibleWithSymbol instead
bool isSymbolLayerCompatible( SymbolType layerType );
private:
QgsSymbolV2( const QgsSymbolV2& );
@ -249,7 +273,7 @@ class QgsSymbolV2RenderContext
~QgsSymbolV2RenderContext();
QgsRenderContext& renderContext();
//void setRenderContext( QgsRenderContext& c );
// const QgsRenderContext& renderContext() const;
/** Sets the original value variable value for data defined symbology
* @param value value for original value variable. This usually represents the symbol property value
@ -262,7 +286,7 @@ class QgsSymbolV2RenderContext
void setOutputUnit( QgsSymbolV2::OutputUnit u );
QgsMapUnitScale mapUnitScale() const;
void setMapUnitScale( const QgsMapUnitScale& scale);
void setMapUnitScale( const QgsMapUnitScale& scale );
//! Get alpha transparency 1 for opaque, 0 for invisible
qreal alpha() const;
@ -308,7 +332,7 @@ class QgsSymbolV2RenderContext
private:
QgsSymbolV2RenderContext( const QgsSymbolV2RenderContext& rh );
QgsSymbolV2RenderContext( const QgsSymbolV2RenderContext& rh );
};

View File

@ -93,9 +93,6 @@ class CORE_EXPORT QgsCircularStringV2: public QgsCurveV2
*/
void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform ) override;
void transform( const QTransform& t ) override;
#if 0
void clip( const QgsRectangle& rect ) override;
#endif
void addToPainterPath( QPainterPath& path ) const override;
/**

View File

@ -72,7 +72,7 @@ class CORE_EXPORT QgsGeometryCollectionV2: public QgsAbstractGeometryV2
/** Transforms the geometry using a coordinate transform
* @param ct coordinate transform
@param d transformation direction
* @param d transformation direction
*/
virtual void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform ) override;
void transform( const QTransform& t ) override;

View File

@ -65,7 +65,7 @@ bool QgsTopologyPreservingSimplifier::simplifyGeometry( QgsGeometry* geometry )
if ( g )
{
int wkbSize = g->wkbSize();
unsigned char* wkb = reinterpret_cast< unsigned char* >( malloc( wkbSize ) );
unsigned char *wkb = new unsigned char[ wkbSize ];
memcpy( wkb, g->asWkb(), wkbSize );
geometry->fromWkb( wkb, wkbSize );
delete g;

View File

@ -693,27 +693,27 @@ void TestQgsGeometry::pointV2()
//dropZ
QgsPointV2 p25( QgsWKBTypes::PointZ, 1.0, 2.0, 3.0 );
QVERIFY( p25.dropZValue( ) );
QVERIFY( p25.dropZValue() );
QCOMPARE( p25, QgsPointV2( 1.0, 2.0 ) );
QVERIFY( !p25.dropZValue( ) );
QVERIFY( !p25.dropZValue() );
QgsPointV2 p26( QgsWKBTypes::PointZM, 1.0, 2.0, 3.0, 4.0 );
QVERIFY( p26.dropZValue( ) );
QVERIFY( p26.dropZValue() );
QCOMPARE( p26, QgsPointV2( QgsWKBTypes::PointM, 1.0, 2.0, 0.0, 4.0 ) );
QVERIFY( !p26.dropZValue( ) );
QVERIFY( !p26.dropZValue() );
QgsPointV2 p26a( QgsWKBTypes::Point25D, 1.0, 2.0, 3.0 );
QVERIFY( p26a.dropZValue( ) );
QVERIFY( p26a.dropZValue() );
QCOMPARE( p26a, QgsPointV2( QgsWKBTypes::Point, 1.0, 2.0 ) );
QVERIFY( !p26a.dropZValue( ) );
QVERIFY( !p26a.dropZValue() );
//dropM
QgsPointV2 p27( QgsWKBTypes::PointM, 1.0, 2.0, 0.0, 3.0 );
QVERIFY( p27.dropMValue( ) );
QVERIFY( p27.dropMValue() );
QCOMPARE( p27, QgsPointV2( 1.0, 2.0 ) );
QVERIFY( !p27.dropMValue( ) );
QVERIFY( !p27.dropMValue() );
QgsPointV2 p28( QgsWKBTypes::PointZM, 1.0, 2.0, 3.0, 4.0 );
QVERIFY( p28.dropMValue( ) );
QVERIFY( p28.dropMValue() );
QCOMPARE( p28, QgsPointV2( QgsWKBTypes::PointZ, 1.0, 2.0, 3.0, 0.0 ) );
QVERIFY( !p28.dropMValue( ) );
QVERIFY( !p28.dropMValue() );
//convertTo
QgsPointV2 p29( 1.0, 2.0 );
@ -3187,7 +3187,8 @@ void TestQgsGeometry::smoothCheck()
QgsMultiPolygon multipoly = result->asMultiPolygon();
delete result;
QgsMultiPolygon expectedMultiPoly;
expectedMultiPoly << ( QgsPolygon() << ( QgsPolyline() << QgsPoint( 1.0, 0 ) << QgsPoint( 9, 0 ) << QgsPoint( 10.0, 1 )
expectedMultiPoly
<< ( QgsPolygon() << ( QgsPolyline() << QgsPoint( 1.0, 0 ) << QgsPoint( 9, 0 ) << QgsPoint( 10.0, 1 )
<< QgsPoint( 10.0, 9 ) << QgsPoint( 9, 10.0 ) << QgsPoint( 1, 10.0 ) << QgsPoint( 0, 9 )
<< QgsPoint( 0, 1 ) << QgsPoint( 1, 0 ) ) )
<< ( QgsPolygon() << ( QgsPolyline() << QgsPoint( 2.2, 2.0 ) << QgsPoint( 3.8, 2.0 ) << QgsPoint( 4.0, 2.2 )
@ -3209,7 +3210,7 @@ void TestQgsGeometry::dataStream()
ds.device()->seek( 0 );
ds >> resultGeometry;
QCOMPARE( geom->geometry()->asWkt(), resultGeometry.geometry()->asWkt( ) );
QCOMPARE( geom->geometry()->asWkt(), resultGeometry.geometry()->asWkt() );
//also test with geometry without data
QScopedPointer<QgsGeometry> emptyGeom( new QgsGeometry() );