QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Static Private Attributes | List of all members
QgsClipper Class Reference

A class to trim lines and polygons to within a rectangular region. More...

#include <qgsclipper.h>

Public Types

enum  Boundary { XMax, XMin, YMax, YMin }

Static Public Member Functions

static void trimFeature (QVector< double > &x, QVector< double > &y, bool shapeOpen)
static void trimPolygon (QPolygonF &pts, const QgsRectangle &clipRect)
static const unsigned char * clippedLineWKB (const unsigned char *wkb, const QgsRectangle &clipExtent, QPolygonF &line)
 Reads a polyline from WKB and clips it to clipExtent.

Static Public Attributes

static const double MAX_X = 16000
static const double MIN_X = -16000
static const double MAX_Y = 16000
static const double MIN_Y = -16000

Static Private Member Functions

static void trimFeatureToBoundary (const QVector< double > &inX, const QVector< double > &inY, QVector< double > &outX, QVector< double > &outY, Boundary b, bool shapeOpen)
static void trimPolygonToBoundary (const QPolygonF &inPts, QPolygonF &outPts, const QgsRectangle &rect, Boundary b, double boundaryValue)
static bool inside (const double x, const double y, Boundary b)
static bool inside (const QPointF &pt, Boundary b, double val)
static QgsPoint intersect (const double x1, const double y1, const double x2, const double y2, Boundary b)
static QPointF intersectRect (const QPointF &pt1, const QPointF &pt2, Boundary b, const QgsRectangle &rect)
static bool clipLineSegment (double xLeft, double xRight, double yBottom, double yTop, double &x0, double &y0, double &x1, double &y1)
static void connectSeparatedLines (double x0, double y0, double x1, double y1, const QgsRectangle &clipRect, QPolygonF &pts)
 Connects two lines split by the clip (by inserting points on the clip border)
static void clipStartTop (double &x0, double &y0, const double &x1, const double &y1, double yMax)
static void clipStartBottom (double &x0, double &y0, const double &x1, const double &y1, double yMin)
static void clipStartRight (double &x0, double &y0, const double &x1, const double &y1, double xMax)
static void clipStartLeft (double &x0, double &y0, const double &x1, const double &y1, double xMin)
static void clipEndTop (const double &x0, const double &y0, double &x1, double &y1, double yMax)
static void clipEndBottom (const double &x0, const double &y0, double &x1, double &y1, double yMin)
static void clipEndRight (const double &x0, const double &y0, double &x1, double &y1, double xMax)
static void clipEndLeft (const double &x0, const double &y0, double &x1, double &y1, double xMin)

Static Private Attributes

static const double SMALL_NUM = 1e-12

Detailed Description

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).

Definition at line 39 of file qgsclipper.h.

Member Enumeration Documentation

Enumerator:
XMax 
XMin 
YMax 
YMin 

Definition at line 69 of file qgsclipper.h.

Member Function Documentation

void QgsClipper::clipEndBottom ( const double &  x0,
const double &  y0,
double &  x1,
double &  y1,
double  yMin 
)
inlinestaticprivate

Definition at line 459 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::clipEndLeft ( const double &  x0,
const double &  y0,
double &  x1,
double &  y1,
double  xMin 
)
inlinestaticprivate

Definition at line 471 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::clipEndRight ( const double &  x0,
const double &  y0,
double &  x1,
double &  y1,
double  xMax 
)
inlinestaticprivate

Definition at line 465 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::clipEndTop ( const double &  x0,
const double &  y0,
double &  x1,
double &  y1,
double  yMax 
)
inlinestaticprivate

Definition at line 453 of file qgsclipper.h.

Referenced by clipLineSegment().

bool QgsClipper::clipLineSegment ( double  xLeft,
double  xRight,
double  yBottom,
double  yTop,
double &  x0,
double &  y0,
double &  x1,
double &  y1 
)
inlinestaticprivate
const unsigned char * QgsClipper::clippedLineWKB ( const unsigned char *  wkb,
const QgsRectangle clipExtent,
QPolygonF &  line 
)
static

Reads a polyline from WKB and clips it to clipExtent.

Parameters
wkbpointer to the start of the line wkb
clipExtentclipping bounds
lineout: clipped line coordinates

Definition at line 38 of file qgsclipper.cpp.

References clipLineSegment(), connectSeparatedLines(), QGis::WKBLineString25D, QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().

Referenced by QgsFeatureRendererV2::_getLineString().

void QgsClipper::clipStartBottom ( double &  x0,
double &  y0,
const double &  x1,
const double &  y1,
double  yMin 
)
inlinestaticprivate

Definition at line 435 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::clipStartLeft ( double &  x0,
double &  y0,
const double &  x1,
const double &  y1,
double  xMin 
)
inlinestaticprivate

Definition at line 447 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::clipStartRight ( double &  x0,
double &  y0,
const double &  x1,
const double &  y1,
double  xMax 
)
inlinestaticprivate

Definition at line 441 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::clipStartTop ( double &  x0,
double &  y0,
const double &  x1,
const double &  y1,
double  yMax 
)
inlinestaticprivate

Definition at line 429 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::connectSeparatedLines ( double  x0,
double  y0,
double  x1,
double  y1,
const QgsRectangle clipRect,
QPolygonF &  pts 
)
staticprivate

Connects two lines split by the clip (by inserting points on the clip border)

Parameters
x0x-coordinate of the first line end
y0y-coordinate of the first line end
x1x-coordinate of the second line start
y1y-coordinate of the second line start
clipRectclip rectangle
pts,:in/out array of clipped points

Definition at line 108 of file qgsclipper.cpp.

References qgsDoubleNear(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().

Referenced by clippedLineWKB().

bool QgsClipper::inside ( const double  x,
const double  y,
Boundary  b 
)
inlinestaticprivate

Definition at line 297 of file qgsclipper.h.

References MAX_X, MAX_Y, MIN_X, MIN_Y, XMax, XMin, YMax, and YMin.

Referenced by trimFeatureToBoundary(), and trimPolygonToBoundary().

bool QgsClipper::inside ( const QPointF &  pt,
Boundary  b,
double  val 
)
inlinestaticprivate

Definition at line 321 of file qgsclipper.h.

References XMax, XMin, YMax, and YMin.

QgsPoint QgsClipper::intersect ( const double  x1,
const double  y1,
const double  x2,
const double  y2,
Boundary  b 
)
inlinestaticprivate

Definition at line 342 of file qgsclipper.h.

References MAX_X, MAX_Y, MIN_X, MIN_Y, QgsPoint::set(), SMALL_NUM, XMax, XMin, YMax, and YMin.

Referenced by trimFeatureToBoundary().

QPointF QgsClipper::intersectRect ( const QPointF &  pt1,
const QPointF &  pt2,
Boundary  b,
const QgsRectangle rect 
)
inlinestaticprivate
void QgsClipper::trimFeature ( QVector< double > &  x,
QVector< double > &  y,
bool  shapeOpen 
)
inlinestatic

Definition at line 155 of file qgsclipper.h.

References trimFeatureToBoundary(), XMax, XMin, YMax, and YMin.

void QgsClipper::trimFeatureToBoundary ( const QVector< double > &  inX,
const QVector< double > &  inY,
QVector< double > &  outX,
QVector< double > &  outY,
Boundary  b,
bool  shapeOpen 
)
inlinestaticprivate

Definition at line 195 of file qgsclipper.h.

References inside(), intersect(), QgsPoint::x(), and QgsPoint::y().

Referenced by trimFeature().

void QgsClipper::trimPolygon ( QPolygonF &  pts,
const QgsRectangle clipRect 
)
inlinestatic
void QgsClipper::trimPolygonToBoundary ( const QPolygonF &  inPts,
QPolygonF &  outPts,
const QgsRectangle rect,
Boundary  b,
double  boundaryValue 
)
inlinestaticprivate

Definition at line 261 of file qgsclipper.h.

References inside(), and intersectRect().

Referenced by trimPolygon().

Member Data Documentation

const double QgsClipper::MAX_X = 16000
static

Definition at line 62 of file qgsclipper.h.

Referenced by inside(), and intersect().

const double QgsClipper::MAX_Y = 16000
static

Definition at line 64 of file qgsclipper.h.

Referenced by inside(), and intersect().

const double QgsClipper::MIN_X = -16000
static

Definition at line 63 of file qgsclipper.h.

Referenced by inside(), and intersect().

const double QgsClipper::MIN_Y = -16000
static

Definition at line 65 of file qgsclipper.h.

Referenced by inside(), and intersect().

const double QgsClipper::SMALL_NUM = 1e-12
staticprivate

Definition at line 90 of file qgsclipper.h.

Referenced by intersect(), and intersectRect().


The documentation for this class was generated from the following files: