Skip to content

Commit d76bca0

Browse files
committedApr 2, 2017
Sipify QgsClipper
1 parent f4f45bf commit d76bca0

File tree

3 files changed

+81
-45
lines changed

3 files changed

+81
-45
lines changed
 

‎python/auto_sip.blacklist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ core/qgsattributetableconfig.sip
77
core/qgsattributeeditorelement.sip
88
core/qgsbearingutils.sip
99
core/qgsbrowsermodel.sip
10-
core/qgsclipper.sip
1110
core/qgscolorramp.sip
1211
core/qgscolorscheme.sip
1312
core/qgscolorschemeregistry.sip

‎python/core/qgsclipper.sip

Lines changed: 65 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,85 @@
1-
%Feature ARM
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgsclipper.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
13+
14+
%Feature ARM // Some parts are not available in sip bindings on ARM because of qreal double vs. float issues
215

316
class QgsClipper
417
{
5-
%TypeHeaderCode
6-
#include <qgsclipper.h>
18+
%Docstring
19+
A class to trim lines and polygons to within a rectangular region.
20+
The functions in this class are likely to be called from within a
21+
render loop and hence need to as CPU efficient as possible.
22+
The main purpose of the functions in this class are to trim lines
23+
and polygons to lie within a rectangular region. This is necessary
24+
for drawing items to an X11 display which have a limit on the
25+
magnitude of the screen coordinates (+/- 32768, i.e. 16 bit integer).
726
%End
827

28+
%TypeHeaderCode
29+
#include "qgsclipper.h"
30+
%End
931
public:
1032

11-
// Coordinates of the rectangular box that we trim to.
12-
//
13-
// These are the limits for X11 screen coordinates. The actual
14-
// values are +/-32767, but we allow a little bit of space for
15-
// rounding errors.
16-
17-
// You may wonder why the clipping is done to these coordindates
18-
// rather than the boundaries of the qgis canvas. Reasons include:
19-
// - making the boundaries static const allows the compiler to
20-
// optimise the code that uses these values more than if they changed
21-
// for every call to the trim code.
22-
// - clipping takes quite a bit of CPU effort, and the less that this is
23-
// done the better. More stuff would have to be clipped if the
24-
// boundaries were the qgis canvas (but this may be offset by
25-
// having less to draw).
26-
//
27-
// The limit is set to 30,000 instead of 32768 because that things
28-
// still go wrong.
33+
2934

3035
static const double MAX_X;
3136
static const double MIN_X;
3237
static const double MAX_Y;
3338
static const double MIN_Y;
3439

3540

36-
//! A handy way to refer to the four boundaries
37-
enum Boundary {XMax, XMin, YMax, YMin};
38-
39-
%If (!ARM)
40-
/**
41-
* Trims the given feature to a rectangular box. Returns the trimmed
42-
* feature in x and y. The shapeOpen parameter determines whether
43-
* the function treats the points as a closed shape (polygon), or as
44-
* an open shape (linestring).
45-
*
46-
* @note not available in python bindings on android
47-
*/
48-
static void trimFeature( QVector<double>& x,
49-
QVector<double>& y,
41+
enum Boundary
42+
{
43+
XMax,
44+
XMin,
45+
YMax,
46+
YMin
47+
};
48+
49+
%If (!ARM) // Not available on ARM sip bindings because of qreal issues
50+
static void trimFeature( QVector<double> &x,
51+
QVector<double> &y,
5052
bool shapeOpen );
53+
%Docstring
54+
Trims the given feature to a rectangular box. Returns the trimmed
55+
feature in x and y. The shapeOpen parameter determines whether
56+
the function treats the points as a closed shape (polygon), or as
57+
an open shape (linestring).
58+
59+
.. note::
60+
61+
not available in python bindings on android
5162
%End
5263

53-
static void trimPolygon( QPolygonF& pts, const QgsRectangle& clipRect );
64+
%End
65+
static void trimPolygon( QPolygonF &pts, const QgsRectangle &clipRect );
5466

55-
/** Takes a linestring and clips it to clipExtent
56-
* @param curve the linestring
57-
* @param clipExtent clipping bounds
58-
* @return clipped line coordinates
59-
*/
60-
static QPolygonF clippedLine( const QgsCurve& curve, const QgsRectangle& clipExtent );
67+
static QPolygonF clippedLine( const QgsCurve &curve, const QgsRectangle &clipExtent );
68+
%Docstring
69+
Takes a linestring and clips it to clipExtent
70+
@param curve the linestring
71+
@param clipExtent clipping bounds
72+
@return clipped line coordinates
73+
%End
6174

6275
};
76+
77+
78+
79+
/************************************************************************
80+
* This file has been generated automatically from *
81+
* *
82+
* src/core/qgsclipper.h *
83+
* *
84+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
85+
************************************************************************/

‎src/core/qgsclipper.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
class QgsCurve;
3131

32+
SIP_FEATURE( ARM ) // Some parts are not available in sip bindings on ARM because of qreal double vs. float issues
33+
34+
3235
/** \ingroup core
3336
* A class to trim lines and polygons to within a rectangular region.
3437
* The functions in this class are likely to be called from within a
@@ -38,7 +41,6 @@ class QgsCurve;
3841
* for drawing items to an X11 display which have a limit on the
3942
* magnitude of the screen coordinates (+/- 32768, i.e. 16 bit integer).
4043
*/
41-
4244
class CORE_EXPORT QgsClipper
4345
{
4446
public:
@@ -69,7 +71,15 @@ class CORE_EXPORT QgsClipper
6971

7072

7173
//! A handy way to refer to the four boundaries
72-
enum Boundary {XMax, XMin, YMax, YMin};
74+
enum Boundary
75+
{
76+
XMax,
77+
XMin,
78+
YMax,
79+
YMin
80+
};
81+
82+
SIP_IF_FEATURE( !ARM ) // Not available on ARM sip bindings because of qreal issues
7383

7484
/**
7585
* Trims the given feature to a rectangular box. Returns the trimmed
@@ -83,6 +93,8 @@ class CORE_EXPORT QgsClipper
8393
QVector<double> &y,
8494
bool shapeOpen );
8595

96+
SIP_END
97+
8698
static void trimPolygon( QPolygonF &pts, const QgsRectangle &clipRect );
8799

88100
/** Takes a linestring and clips it to clipExtent
@@ -148,6 +160,7 @@ class CORE_EXPORT QgsClipper
148160
static void clipEndLeft( double x0, double y0, double &x1, double &y1, double xMin );
149161
};
150162

163+
#ifndef SIP_RUN
151164
// The inline functions
152165

153166
// Trim the feature using Sutherland and Hodgman's
@@ -872,6 +885,7 @@ inline bool QgsClipper::clipLineSegment( double xLeft, double xRight, double yBo
872885
return false;
873886

874887
}
888+
#endif // SIP_RUN
875889

876890

877891
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.