Sipify QgsClipper

This commit is contained in:
Matthias Kuhn 2017-04-02 11:27:08 +02:00
parent f4f45bf6c6
commit d76bca0ade
3 changed files with 79 additions and 43 deletions

View File

@ -7,7 +7,6 @@ core/qgsattributetableconfig.sip
core/qgsattributeeditorelement.sip core/qgsattributeeditorelement.sip
core/qgsbearingutils.sip core/qgsbearingutils.sip
core/qgsbrowsermodel.sip core/qgsbrowsermodel.sip
core/qgsclipper.sip
core/qgscolorramp.sip core/qgscolorramp.sip
core/qgscolorscheme.sip core/qgscolorscheme.sip
core/qgscolorschemeregistry.sip core/qgscolorschemeregistry.sip

View File

@ -1,31 +1,36 @@
%Feature ARM /************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsclipper.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
%Feature ARM // Some parts are not available in sip bindings on ARM because of qreal double vs. float issues
class QgsClipper class QgsClipper
{ {
%TypeHeaderCode %Docstring
#include <qgsclipper.h> A class to trim lines and polygons to within a rectangular region.
The functions in this class are likely to be called from within a
render loop and hence need to as CPU efficient as possible.
The main purpose of the functions in this class are to trim lines
and polygons to lie within a rectangular region. This is necessary
for drawing items to an X11 display which have a limit on the
magnitude of the screen coordinates (+/- 32768, i.e. 16 bit integer).
%End %End
%TypeHeaderCode
#include "qgsclipper.h"
%End
public: public:
// Coordinates of the rectangular box that we trim to.
//
// These are the limits for X11 screen coordinates. The actual
// values are +/-32767, but we allow a little bit of space for
// rounding errors.
// You may wonder why the clipping is done to these coordindates
// rather than the boundaries of the qgis canvas. Reasons include:
// - making the boundaries static const allows the compiler to
// optimise the code that uses these values more than if they changed
// for every call to the trim code.
// - clipping takes quite a bit of CPU effort, and the less that this is
// done the better. More stuff would have to be clipped if the
// boundaries were the qgis canvas (but this may be offset by
// having less to draw).
//
// The limit is set to 30,000 instead of 32768 because that things
// still go wrong.
static const double MAX_X; static const double MAX_X;
static const double MIN_X; static const double MIN_X;
@ -33,30 +38,48 @@ class QgsClipper
static const double MIN_Y; static const double MIN_Y;
//! A handy way to refer to the four boundaries enum Boundary
enum Boundary {XMax, XMin, YMax, YMin}; {
XMax,
XMin,
YMax,
YMin
};
%If (!ARM) %If (!ARM) // Not available on ARM sip bindings because of qreal issues
/** static void trimFeature( QVector<double> &x,
* Trims the given feature to a rectangular box. Returns the trimmed QVector<double> &y,
* 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 ); bool shapeOpen );
%Docstring
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
%End %End
static void trimPolygon( QPolygonF& pts, const QgsRectangle& clipRect ); %End
static void trimPolygon( QPolygonF &pts, const QgsRectangle &clipRect );
/** Takes a linestring and clips it to clipExtent static QPolygonF clippedLine( const QgsCurve &curve, const QgsRectangle &clipExtent );
* @param curve the linestring %Docstring
* @param clipExtent clipping bounds Takes a linestring and clips it to clipExtent
* @return clipped line coordinates @param curve the linestring
*/ @param clipExtent clipping bounds
static QPolygonF clippedLine( const QgsCurve& curve, const QgsRectangle& clipExtent ); @return clipped line coordinates
%End
}; };
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsclipper.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

View File

@ -29,6 +29,9 @@
class QgsCurve; class QgsCurve;
SIP_FEATURE( ARM ) // Some parts are not available in sip bindings on ARM because of qreal double vs. float issues
/** \ingroup core /** \ingroup core
* A class to trim lines and polygons to within a rectangular region. * A class to trim lines and polygons to within a rectangular region.
* The functions in this class are likely to be called from within a * The functions in this class are likely to be called from within a
@ -38,7 +41,6 @@ class QgsCurve;
* for drawing items to an X11 display which have a limit on the * for drawing items to an X11 display which have a limit on the
* magnitude of the screen coordinates (+/- 32768, i.e. 16 bit integer). * magnitude of the screen coordinates (+/- 32768, i.e. 16 bit integer).
*/ */
class CORE_EXPORT QgsClipper class CORE_EXPORT QgsClipper
{ {
public: public:
@ -69,7 +71,15 @@ class CORE_EXPORT QgsClipper
//! A handy way to refer to the four boundaries //! A handy way to refer to the four boundaries
enum Boundary {XMax, XMin, YMax, YMin}; enum Boundary
{
XMax,
XMin,
YMax,
YMin
};
SIP_IF_FEATURE( !ARM ) // Not available on ARM sip bindings because of qreal issues
/** /**
* Trims the given feature to a rectangular box. Returns the trimmed * Trims the given feature to a rectangular box. Returns the trimmed
@ -83,6 +93,8 @@ class CORE_EXPORT QgsClipper
QVector<double> &y, QVector<double> &y,
bool shapeOpen ); bool shapeOpen );
SIP_END
static void trimPolygon( QPolygonF &pts, const QgsRectangle &clipRect ); static void trimPolygon( QPolygonF &pts, const QgsRectangle &clipRect );
/** Takes a linestring and clips it to clipExtent /** Takes a linestring and clips it to clipExtent
@ -148,6 +160,7 @@ class CORE_EXPORT QgsClipper
static void clipEndLeft( double x0, double y0, double &x1, double &y1, double xMin ); static void clipEndLeft( double x0, double y0, double &x1, double &y1, double xMin );
}; };
#ifndef SIP_RUN
// The inline functions // The inline functions
// Trim the feature using Sutherland and Hodgman's // Trim the feature using Sutherland and Hodgman's
@ -872,6 +885,7 @@ inline bool QgsClipper::clipLineSegment( double xLeft, double xRight, double yBo
return false; return false;
} }
#endif // SIP_RUN
#endif #endif