Skip to content
Permalink
Browse files
Cleanup QgsRectangle header and sipify
Also add methods for returning area and perimeter of rectangle
  • Loading branch information
nyalldawson committed Apr 12, 2017
1 parent e3dfe17 commit 6632fd68498502c51b232c9b8604b9fc110b4d09
Showing with 464 additions and 215 deletions.
  1. +0 −1 python/auto_sip.blacklist
  2. +261 −78 python/core/qgsrectangle.sip
  3. +7 −18 src/core/qgsrectangle.cpp
  4. +191 −118 src/core/qgsrectangle.h
  5. +5 −0 tests/src/python/test_qgsrectangle.py
@@ -95,7 +95,6 @@ core/qgspropertycollection.sip
core/qgsprovidermetadata.sip
core/qgsproviderregistry.sip
core/qgspythonrunner.sip
core/qgsrectangle.sip
core/qgsrelation.sip
core/qgsrelationmanager.sip
core/qgsrenderchecker.sip
@@ -1,119 +1,302 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsrectangle.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






/** \ingroup core
* A rectangle specified with double values.
*
* QgsRectangle is used to store a rectangle when double values are required.
* Examples are storing a layer extent or the current view extent of a map
*/
class QgsRectangle
{
%TypeHeaderCode
#include <qgsrectangle.h>
%Docstring
A rectangle specified with double values.

QgsRectangle is used to store a rectangle when double values are required.
Examples are storing a layer extent or the current view extent of a map
\see QgsBox3d
%End

%TypeHeaderCode
#include "qgsrectangle.h"
%End
public:
//! Constructor
QgsRectangle( double xmin = 0, double ymin = 0, double xmax = 0, double ymax = 0 );
//! Construct a rectangle from two points. The rectangle is normalized after construction.
QgsRectangle( const QgsPoint & p1, const QgsPoint & p2 );
//! Construct a rectangle from a QRectF. The rectangle is normalized after construction.
QgsRectangle( const QRectF & qRectF );
//! Copy constructor
QgsRectangle( double xMin = 0, double yMin = 0, double xMax = 0, double yMax = 0 );
%Docstring
Constructor
%End
QgsRectangle( const QgsPoint &p1, const QgsPoint &p2 );
%Docstring
Construct a rectangle from two points. The rectangle is normalized after construction.
%End
QgsRectangle( const QRectF &qRectF );
%Docstring
Construct a rectangle from a QRectF. The rectangle is normalized after construction.
%End
QgsRectangle( const QgsRectangle &other );
//! Destructor
~QgsRectangle();
//! Set the rectangle from two QgsPoints. The rectangle is
//! normalised after construction.
void set( const QgsPoint& p1, const QgsPoint& p2 );
//! Set the rectangle from four points. The rectangle is
//! normalised after construction.
void set( double xmin, double ymin, double xmax, double ymax );
//! Set the minimum x value
%Docstring
Copy constructor
%End

void set( const QgsPoint &p1, const QgsPoint &p2 );
%Docstring
Sets the rectangle from two QgsPoints. The rectangle is
normalised after construction.
%End

void set( double mXmin, double mYmin, double mXmax, double mYmax );
%Docstring
Sets the rectangle from four points. The rectangle is
normalised after construction.
%End

void setXMinimum( double x );
//! Set the maximum x value
%Docstring
Set the minimum x value.
%End

void setXMaximum( double x );
//! Set the minimum y value
%Docstring
Set the maximum x value.
%End

void setYMinimum( double y );
//! Set the maximum y value
%Docstring
Set the minimum y value.
%End

void setYMaximum( double y );
//! Set a rectangle so that min corner is at max
//! and max corner is at min. It is NOT normalized.
%Docstring
Set the maximum y value.
%End

void setMinimal();
//! Get the x maximum value (right side of rectangle)
%Docstring
Set a rectangle so that min corner is at max
and max corner is at min. It is NOT normalized.
%End

double xMaximum() const;
//! Get the x minimum value (left side of rectangle)
%Docstring
Returns the x maximum value (right side of rectangle).
:rtype: float
%End

double xMinimum() const;
//! Get the y maximum value (top side of rectangle)
%Docstring
Returns the x minimum value (left side of rectangle).
:rtype: float
%End

double yMaximum() const;
//! Get the y minimum value (bottom side of rectangle)
%Docstring
Returns the y maximum value (top side of rectangle).
:rtype: float
%End

double yMinimum() const;
//! Normalize the rectangle so it has non-negative width/height
%Docstring
Returns the y minimum value (bottom side of rectangle).
:rtype: float
%End

void normalize();
//! Width of the rectangle
%Docstring
Normalize the rectangle so it has non-negative width/height.
%End

double width() const;
//! Height of the rectangle
%Docstring
Returns the width of the rectangle.
\see height()
\see area()
:rtype: float
%End

double height() const;
//! Center point of the rectangle
%Docstring
Returns the height of the rectangle.
\see width()
\see area()
:rtype: float
%End

double area() const;
%Docstring
Returns the area of the rectangle.
.. versionadded:: 3.0
\see width()
\see height()
\see perimeter()
:rtype: float
%End

double perimeter() const;
%Docstring
Returns the perimeter of the rectangle.
.. versionadded:: 3.0
\see area()
:rtype: float
%End

QgsPoint center() const;
//! Scale the rectangle around its center point
%Docstring
Returns the center point of the rectangle.
:rtype: QgsPoint
%End

void scale( double scaleFactor, const QgsPoint *c = 0 );
%Docstring
Scale the rectangle around its center point.
%End

void scale( double scaleFactor, double centerX, double centerY );
//! Grow the rectangle by the specified amount
%Docstring
Scale the rectangle around its center point.
%End

void grow( double delta );
/** Updates the rectangle to include the specified point */
void include( const QgsPoint& p );
/** Get rectangle enlarged by buffer.
* @note added in 2.1 */
%Docstring
Grows the rectangle by the specified amount.
%End

void include( const QgsPoint &p );
%Docstring
Updates the rectangle to include the specified point.
%End

QgsRectangle buffer( double width );
//! return the intersection with the given rectangle
%Docstring
Get rectangle enlarged by buffer.
.. versionadded:: 2.1
:rtype: QgsRectangle
%End

QgsRectangle intersect( const QgsRectangle *rect ) const;
//! returns true when rectangle intersects with other rectangle
bool intersects( const QgsRectangle& rect ) const;
//! return true when rectangle contains other rectangle
bool contains( const QgsRectangle& rect ) const;
//! return true when rectangle contains a point
%Docstring
Return the intersection with the given rectangle.
:rtype: QgsRectangle
%End

bool intersects( const QgsRectangle &rect ) const;
%Docstring
Returns true when rectangle intersects with other rectangle.
:rtype: bool
%End

bool contains( const QgsRectangle &rect ) const;
%Docstring
Return true when rectangle contains other rectangle.
:rtype: bool
%End

bool contains( const QgsPoint &p ) const;
//! expand the rectangle so that covers both the original rectangle and the given rectangle
void combineExtentWith( const QgsRectangle& rect );
//! expand the rectangle so that covers both the original rectangle and the given point
%Docstring
Return true when rectangle contains a point.
:rtype: bool
%End

void combineExtentWith( const QgsRectangle &rect );
%Docstring
Expand the rectangle so that covers both the original rectangle and the given rectangle.
%End

void combineExtentWith( double x, double y );
//! test if rectangle is empty.
//! Empty rectangle may still be non-null if it contains valid information (e.g. bounding box of a point)
%Docstring
Expand the rectangle so that covers both the original rectangle and the given point.
%End

bool isEmpty() const;
//! test if the rectangle is null (all coordinates zero or after call to setMinimal()).
//! Null rectangle is also an empty rectangle.
//! @note added in 2.4
%Docstring
Returns true if the rectangle is empty.
An empty rectangle may still be non-null if it contains valid information (e.g. bounding box of a point).
:rtype: bool
%End

bool isNull() const;
//! returns string representation in Wkt form
%Docstring
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
A null rectangle is also an empty rectangle.
.. versionadded:: 2.4
:rtype: bool
%End

QString asWktCoordinates() const;
//! returns string representation as WKT Polygon
%Docstring
Returns a string representation of the rectangle in WKT format.
:rtype: str
%End

QString asWktPolygon() const;
//! returns a QRectF with same coordinates.
%Docstring
Returns a string representation of the rectangle as a WKT Polygon.
:rtype: str
%End

QRectF toRectF() const;
/**
* returns a string representation of form xmin,ymin : xmax,ymax
* Coordinates will be truncated to the specified precision.
* If the specified precision is less than 0, a suitable minimum precision is used.
*/
%Docstring
Returns a QRectF with same coordinates as the rectangle.
:rtype: QRectF
%End

QString toString( int precision = 16 ) const;
//! returns rectangle as a polygon
%Docstring
Returns a string representation of form xmin,ymin : xmax,ymax
Coordinates will be truncated to the specified precision.
If the specified precision is less than 0, a suitable minimum precision is used.
:rtype: str
%End

QString asPolygon() const;
/** Comparison operator
* @return True if rectangles are equal
*/
%Docstring
Returns the rectangle as a polygon.
:rtype: str
%End

bool operator==( const QgsRectangle &r1 ) const;
/** Comparison operator
* @return False if rectangles are equal
*/
%Docstring
Comparison operator
:return: True if rectangles are equal
:rtype: bool
%End

bool operator!=( const QgsRectangle &r1 ) const;
/** Updates rectangle to include passed argument */
void unionRect( const QgsRectangle& rect );
%Docstring
Comparison operator
:return: False if rectangles are equal
:rtype: bool
%End

// QgsRectangle &operator=( const QgsRectangle &r1 );

void unionRect( const QgsRectangle &rect );
%Docstring
Updates the rectangle to include another rectangle.
%End

/** Returns true if the rectangle has finite boundaries. Will
* return false if any of the rectangle boundaries are NaN or Inf.
*/
bool isFinite() const;
%Docstring
Returns true if the rectangle has finite boundaries. Will
return false if any of the rectangle boundaries are NaN or Inf.
:rtype: bool
%End

//! swap x/y
void invert();
%Docstring
Swap x/y coordinates in the rectangle.
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsrectangle.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
Loading

0 comments on commit 6632fd6

Please sign in to comment.