Quantum GIS API Documentation
1.7.4
|
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 (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 |
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 42 of file qgsclipper.h.
enum QgsClipper::Boundary |
Definition at line 72 of file qgsclipper.h.
void QgsClipper::clipEndBottom | ( | const double & | x0, |
const double & | y0, | ||
double & | x1, | ||
double & | y1, | ||
double | yMin | ||
) | [inline, static, private] |
Definition at line 462 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 474 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 468 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 456 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] |
Definition at line 481 of file qgsclipper.h.
References clipEndBottom(), clipEndLeft(), clipEndRight(), clipEndTop(), clipStartBottom(), clipStartLeft(), clipStartRight(), and clipStartTop().
Referenced by clippedLineWKB().
unsigned char * QgsClipper::clippedLineWKB | ( | unsigned char * | wkb, |
const QgsRectangle & | clipExtent, | ||
QPolygonF & | line | ||
) | [static] |
Reads a polyline from WKB and clips it to clipExtent.
wkb | pointer to the start of the line wkb |
clipExtent | clipping bounds |
line | out: clipped line coordinates |
Definition at line 39 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 438 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 450 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 444 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 432 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)
x0 | x-coordinate of the first line end |
y0 | y-coordinate of the first line end |
x1 | x-coordinate of the second line start |
y1 | y-coordinate of the second line start |
clipRect | clip rectangle |
pts,: | in/out array of clipped points |
Definition at line 109 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 300 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] |
QgsPoint QgsClipper::intersect | ( | const double | x1, |
const double | y1, | ||
const double | x2, | ||
const double | y2, | ||
Boundary | b | ||
) | [inline, static, private] |
Definition at line 345 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] |
Definition at line 392 of file qgsclipper.h.
References doubleNear(), SMALL_NUM, XMax, QgsRectangle::xMaximum(), XMin, QgsRectangle::xMinimum(), YMax, QgsRectangle::yMaximum(), YMin, and QgsRectangle::yMinimum().
Referenced by trimPolygonToBoundary().
void QgsClipper::trimFeature | ( | std::vector< double > & | x, |
std::vector< double > & | y, | ||
bool | shapeOpen | ||
) | [inline, static] |
Definition at line 158 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 198 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] |
Definition at line 179 of file qgsclipper.h.
References trimPolygonToBoundary(), XMax, QgsRectangle::xMaximum(), XMin, QgsRectangle::xMinimum(), YMax, QgsRectangle::yMaximum(), YMin, and QgsRectangle::yMinimum().
Referenced by QgsFeatureRendererV2::_getPolygon().
void QgsClipper::trimPolygonToBoundary | ( | const QPolygonF & | inPts, |
QPolygonF & | outPts, | ||
const QgsRectangle & | rect, | ||
Boundary | b, | ||
double | boundaryValue | ||
) | [inline, static, private] |
Definition at line 264 of file qgsclipper.h.
References inside(), and intersectRect().
Referenced by trimPolygon().
const double QgsClipper::MAX_X = 16000 [static] |
Definition at line 65 of file qgsclipper.h.
Referenced by QgsVectorLayer::drawFeature(), QgsVectorLayer::drawLineString(), QgsVectorLayer::drawPolygon(), inside(), and intersect().
const double QgsClipper::MAX_Y = 16000 [static] |
Definition at line 67 of file qgsclipper.h.
Referenced by QgsVectorLayer::drawFeature(), QgsVectorLayer::drawLineString(), QgsVectorLayer::drawPolygon(), inside(), and intersect().
const double QgsClipper::MIN_X = -16000 [static] |
Definition at line 66 of file qgsclipper.h.
Referenced by inside(), and intersect().
const double QgsClipper::MIN_Y = -16000 [static] |
Definition at line 68 of file qgsclipper.h.
Referenced by inside(), and intersect().
const double QgsClipper::SMALL_NUM = 1e-12 [static, private] |
Definition at line 93 of file qgsclipper.h.
Referenced by intersect(), and intersectRect().