Quantum GIS API Documentation  1.8
Public Types | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Static Private Attributes
QgsClipper Class Reference

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

#include <qgsclipper.h>

List of all members.

Public Types

enum  Boundary { XMax, XMin, YMax, YMin }

Static Public Member Functions

static void trimFeature (std::vector< double > &x, std::vector< double > &y, bool shapeOpen)
static void trimPolygon (QPolygonF &pts, const QgsRectangle &clipRect)
static unsigned char * clippedLineWKB (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 std::vector< double > &inX, const std::vector< double > &inY, std::vector< double > &outX, std::vector< 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 41 of file qgsclipper.h.


Member Enumeration Documentation

Enumerator:
XMax 
XMin 
YMax 
YMin 

Definition at line 71 of file qgsclipper.h.


Member Function Documentation

void QgsClipper::clipEndBottom ( const double &  x0,
const double &  y0,
double &  x1,
double &  y1,
double  yMin 
) [inline, static, private]

Definition at line 461 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::clipEndLeft ( const double &  x0,
const double &  y0,
double &  x1,
double &  y1,
double  xMin 
) [inline, static, private]

Definition at line 473 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::clipEndRight ( const double &  x0,
const double &  y0,
double &  x1,
double &  y1,
double  xMax 
) [inline, static, private]

Definition at line 467 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::clipEndTop ( const double &  x0,
const double &  y0,
double &  x1,
double &  y1,
double  yMax 
) [inline, static, private]

Definition at line 455 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 
) [inline, static, private]
unsigned char * QgsClipper::clippedLineWKB ( 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 
) [inline, static, private]

Definition at line 437 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::clipStartLeft ( double &  x0,
double &  y0,
const double &  x1,
const double &  y1,
double  xMin 
) [inline, static, private]

Definition at line 449 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::clipStartRight ( double &  x0,
double &  y0,
const double &  x1,
const double &  y1,
double  xMax 
) [inline, static, private]

Definition at line 443 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::clipStartTop ( double &  x0,
double &  y0,
const double &  x1,
const double &  y1,
double  yMax 
) [inline, static, private]

Definition at line 431 of file qgsclipper.h.

Referenced by clipLineSegment().

void QgsClipper::connectSeparatedLines ( double  x0,
double  y0,
double  x1,
double  y1,
const QgsRectangle clipRect,
QPolygonF &  pts 
) [static, private]

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 doubleNear(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().

Referenced by clippedLineWKB().

bool QgsClipper::inside ( const double  x,
const double  y,
Boundary  b 
) [inline, static, private]

Definition at line 299 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 
) [inline, static, private]

Definition at line 323 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 
) [inline, static, private]

Definition at line 344 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 
) [inline, static, private]
void QgsClipper::trimFeature ( std::vector< double > &  x,
std::vector< double > &  y,
bool  shapeOpen 
) [inline, static]

Definition at line 157 of file qgsclipper.h.

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

Referenced by QgsVectorLayer::drawLineString(), and QgsVectorLayer::drawPolygon().

void QgsClipper::trimFeatureToBoundary ( const std::vector< double > &  inX,
const std::vector< double > &  inY,
std::vector< double > &  outX,
std::vector< double > &  outY,
Boundary  b,
bool  shapeOpen 
) [inline, static, private]

Definition at line 197 of file qgsclipper.h.

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

Referenced by trimFeature().

void QgsClipper::trimPolygon ( QPolygonF &  pts,
const QgsRectangle clipRect 
) [inline, static]
void QgsClipper::trimPolygonToBoundary ( const QPolygonF &  inPts,
QPolygonF &  outPts,
const QgsRectangle rect,
Boundary  b,
double  boundaryValue 
) [inline, static, private]

Definition at line 263 of file qgsclipper.h.

References inside(), and intersectRect().

Referenced by trimPolygon().


Member Data Documentation

const double QgsClipper::MAX_X = 16000 [static]
const double QgsClipper::MAX_Y = 16000 [static]
const double QgsClipper::MIN_X = -16000 [static]

Definition at line 65 of file qgsclipper.h.

Referenced by inside(), and intersect().

const double QgsClipper::MIN_Y = -16000 [static]

Definition at line 67 of file qgsclipper.h.

Referenced by inside(), and intersect().

const double QgsClipper::SMALL_NUM = 1e-12 [static, private]

Definition at line 92 of file qgsclipper.h.

Referenced by intersect(), and intersectRect().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines