mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
clean
This commit is contained in:
parent
fbdf77d305
commit
6036fa6a7c
@ -0,0 +1,327 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/geometry/qgsrectangle.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsRectangle
|
||||
{
|
||||
%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
|
||||
.. seealso:: QgsBox3d
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsrectangle.h"
|
||||
%End
|
||||
public:
|
||||
QgsRectangle( double xMin = 0, double yMin = 0, double xMax = 0, double yMax = 0 );
|
||||
%Docstring
|
||||
Constructor
|
||||
%End
|
||||
QgsRectangle( const QgsPointXY &p1, const QgsPointXY &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 );
|
||||
%Docstring
|
||||
Copy constructor
|
||||
%End
|
||||
|
||||
void set( const QgsPointXY &p1, const QgsPointXY &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 );
|
||||
%Docstring
|
||||
Set the minimum x value.
|
||||
%End
|
||||
|
||||
void setXMaximum( double x );
|
||||
%Docstring
|
||||
Set the maximum x value.
|
||||
%End
|
||||
|
||||
void setYMinimum( double y );
|
||||
%Docstring
|
||||
Set the minimum y value.
|
||||
%End
|
||||
|
||||
void setYMaximum( double y );
|
||||
%Docstring
|
||||
Set the maximum y value.
|
||||
%End
|
||||
|
||||
void setMinimal();
|
||||
%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;
|
||||
%Docstring
|
||||
Returns the x maximum value (right side of rectangle).
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
double xMinimum() const;
|
||||
%Docstring
|
||||
Returns the x minimum value (left side of rectangle).
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
double yMaximum() const;
|
||||
%Docstring
|
||||
Returns the y maximum value (top side of rectangle).
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
double yMinimum() const;
|
||||
%Docstring
|
||||
Returns the y minimum value (bottom side of rectangle).
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
void normalize();
|
||||
%Docstring
|
||||
Normalize the rectangle so it has non-negative width/height.
|
||||
%End
|
||||
|
||||
double width() const;
|
||||
%Docstring
|
||||
Returns the width of the rectangle.
|
||||
.. seealso:: height()
|
||||
.. seealso:: area()
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
double height() const;
|
||||
%Docstring
|
||||
Returns the height of the rectangle.
|
||||
.. seealso:: width()
|
||||
.. seealso:: area()
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
double area() const;
|
||||
%Docstring
|
||||
Returns the area of the rectangle.
|
||||
.. versionadded:: 3.0
|
||||
.. seealso:: width()
|
||||
.. seealso:: height()
|
||||
.. seealso:: perimeter()
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
double perimeter() const;
|
||||
%Docstring
|
||||
Returns the perimeter of the rectangle.
|
||||
.. versionadded:: 3.0
|
||||
.. seealso:: area()
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
QgsPointXY center() const;
|
||||
%Docstring
|
||||
Returns the center point of the rectangle.
|
||||
:rtype: QgsPointXY
|
||||
%End
|
||||
|
||||
void scale( double scaleFactor, const QgsPointXY *c = 0 );
|
||||
%Docstring
|
||||
Scale the rectangle around its center point.
|
||||
%End
|
||||
|
||||
void scale( double scaleFactor, double centerX, double centerY );
|
||||
%Docstring
|
||||
Scale the rectangle around its center point.
|
||||
%End
|
||||
|
||||
void grow( double delta );
|
||||
%Docstring
|
||||
Grows the rectangle by the specified amount.
|
||||
%End
|
||||
|
||||
void include( const QgsPointXY &p );
|
||||
%Docstring
|
||||
Updates the rectangle to include the specified point.
|
||||
%End
|
||||
|
||||
QgsRectangle buffer( double width );
|
||||
%Docstring
|
||||
Get rectangle enlarged by buffer.
|
||||
.. versionadded:: 2.1
|
||||
:rtype: QgsRectangle
|
||||
%End
|
||||
|
||||
QgsRectangle intersect( const QgsRectangle *rect ) const;
|
||||
%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 QgsPointXY &p ) const;
|
||||
%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 );
|
||||
%Docstring
|
||||
Expand the rectangle so that covers both the original rectangle and the given point.
|
||||
%End
|
||||
|
||||
QgsRectangle operator-( const QgsVector v ) const;
|
||||
%Docstring
|
||||
Returns a rectangle offset from this one in the direction of the reversed vector.
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsRectangle
|
||||
%End
|
||||
|
||||
QgsRectangle operator+( const QgsVector v ) const;
|
||||
%Docstring
|
||||
Returns a rectangle offset from this one in the direction of the vector.
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsRectangle
|
||||
%End
|
||||
|
||||
QgsRectangle &operator-=( const QgsVector v );
|
||||
%Docstring
|
||||
Moves this rectangle in the direction of the reversed vector.
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsRectangle
|
||||
%End
|
||||
|
||||
QgsRectangle &operator+=( const QgsVector v );
|
||||
%Docstring
|
||||
Moves this rectangle in the direction of the vector.
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsRectangle
|
||||
%End
|
||||
|
||||
bool isEmpty() const;
|
||||
%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;
|
||||
%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;
|
||||
%Docstring
|
||||
Returns a string representation of the rectangle in WKT format.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
QString asWktPolygon() const;
|
||||
%Docstring
|
||||
Returns a string representation of the rectangle as a WKT Polygon.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
QRectF toRectF() const;
|
||||
%Docstring
|
||||
Returns a QRectF with same coordinates as the rectangle.
|
||||
:rtype: QRectF
|
||||
%End
|
||||
|
||||
QString toString( int precision = 16 ) const;
|
||||
%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;
|
||||
%Docstring
|
||||
Returns the rectangle as a polygon.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
bool operator==( const QgsRectangle &r1 ) const;
|
||||
|
||||
bool operator!=( const QgsRectangle &r1 ) const;
|
||||
%Docstring
|
||||
Comparison operator
|
||||
:return: False if rectangles are equal
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
|
||||
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
|
||||
|
||||
void invert();
|
||||
%Docstring
|
||||
Swap x/y coordinates in the rectangle.
|
||||
%End
|
||||
|
||||
QgsBox3d toBox3d( double zMin, double zMax ) const;
|
||||
%Docstring
|
||||
Converts the rectangle to a 3D box, with the specified
|
||||
``zMin`` and ``zMax`` z values.
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsBox3d
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/geometry/qgsrectangle.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -34,6 +34,13 @@ Adds a whole curve (e.g. circularstring) to the captured geometry. Curve must be
|
||||
:rtype: int
|
||||
%End
|
||||
|
||||
void clearCurve( );
|
||||
%Docstring
|
||||
Clear capture curve.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
const QgsCompoundCurve *captureCurve() const;
|
||||
%Docstring
|
||||
Get the capture curve
|
||||
|
@ -29,6 +29,7 @@ QgsMapToolAddCircle::QgsMapToolAddCircle( QgsMapToolCapture *parentTool, QgsMapC
|
||||
, mTempRubberBand( nullptr )
|
||||
, mCircle( QgsCircle() )
|
||||
{
|
||||
clean();
|
||||
if ( mCanvas )
|
||||
{
|
||||
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddCircle::setParentTool );
|
||||
@ -41,6 +42,7 @@ QgsMapToolAddCircle::QgsMapToolAddCircle( QgsMapCanvas *canvas )
|
||||
, mTempRubberBand( nullptr )
|
||||
, mCircle( QgsCircle() )
|
||||
{
|
||||
clean();
|
||||
if ( mCanvas )
|
||||
{
|
||||
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddCircle::setParentTool );
|
||||
@ -49,18 +51,11 @@ QgsMapToolAddCircle::QgsMapToolAddCircle( QgsMapCanvas *canvas )
|
||||
|
||||
QgsMapToolAddCircle::~QgsMapToolAddCircle()
|
||||
{
|
||||
delete mTempRubberBand;
|
||||
mPoints.clear();
|
||||
clean();
|
||||
}
|
||||
|
||||
void QgsMapToolAddCircle::setParentTool( QgsMapTool *newTool, QgsMapTool *oldTool )
|
||||
{
|
||||
if ( mTempRubberBand )
|
||||
{
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
}
|
||||
mPoints.clear();
|
||||
QgsMapToolCapture *tool = dynamic_cast<QgsMapToolCapture *>( oldTool );
|
||||
QgsMapToolAddCircle *csTool = dynamic_cast<QgsMapToolAddCircle *>( oldTool );
|
||||
if ( csTool && newTool == this )
|
||||
@ -82,9 +77,7 @@ void QgsMapToolAddCircle::keyPressEvent( QKeyEvent *e )
|
||||
|
||||
if ( e && e->key() == Qt::Key_Escape )
|
||||
{
|
||||
mPoints.clear();
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
clean();
|
||||
if ( mParentTool )
|
||||
mParentTool->keyPressEvent( e );
|
||||
}
|
||||
@ -105,22 +98,29 @@ void QgsMapToolAddCircle::deactivate()
|
||||
return;
|
||||
}
|
||||
|
||||
mParentTool->clearCurve();
|
||||
mParentTool->addCurve( mCircle.toCircularString() );
|
||||
clean();
|
||||
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
mPoints.clear();
|
||||
mCircle = QgsCircle();
|
||||
QgsMapToolCapture::deactivate();
|
||||
}
|
||||
|
||||
void QgsMapToolAddCircle::activate()
|
||||
{
|
||||
mPoints.clear();
|
||||
clean();
|
||||
QgsMapToolCapture::activate();
|
||||
}
|
||||
|
||||
void QgsMapToolAddCircle::clean()
|
||||
{
|
||||
if ( mTempRubberBand )
|
||||
{
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
}
|
||||
mPoints.clear();
|
||||
if ( mParentTool )
|
||||
{
|
||||
mParentTool->deleteTempRubberBand();
|
||||
}
|
||||
QgsMapToolCapture::activate();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ class QgsGeometryRubberBand;
|
||||
class QgsMapToolAddCircle: public QgsMapToolCapture
|
||||
{
|
||||
Q_OBJECT
|
||||
void clean();
|
||||
public:
|
||||
QgsMapToolAddCircle( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode = CaptureLine );
|
||||
~QgsMapToolAddCircle();
|
||||
|
@ -29,6 +29,7 @@ QgsMapToolAddEllipse::QgsMapToolAddEllipse( QgsMapToolCapture *parentTool, QgsMa
|
||||
, mTempRubberBand( nullptr )
|
||||
, mEllipse( QgsEllipse() )
|
||||
{
|
||||
clean();
|
||||
if ( mCanvas )
|
||||
{
|
||||
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddEllipse::setParentTool );
|
||||
@ -41,6 +42,7 @@ QgsMapToolAddEllipse::QgsMapToolAddEllipse( QgsMapCanvas *canvas )
|
||||
, mTempRubberBand( nullptr )
|
||||
, mEllipse( QgsEllipse() )
|
||||
{
|
||||
clean();
|
||||
if ( mCanvas )
|
||||
{
|
||||
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddEllipse::setParentTool );
|
||||
@ -49,8 +51,7 @@ QgsMapToolAddEllipse::QgsMapToolAddEllipse( QgsMapCanvas *canvas )
|
||||
|
||||
QgsMapToolAddEllipse::~QgsMapToolAddEllipse()
|
||||
{
|
||||
delete mTempRubberBand;
|
||||
mPoints.clear();
|
||||
clean();
|
||||
}
|
||||
|
||||
void QgsMapToolAddEllipse::setParentTool( QgsMapTool *newTool, QgsMapTool *oldTool )
|
||||
@ -76,9 +77,7 @@ void QgsMapToolAddEllipse::keyPressEvent( QKeyEvent *e )
|
||||
|
||||
if ( e && e->key() == Qt::Key_Escape )
|
||||
{
|
||||
mPoints.clear();
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
clean();
|
||||
if ( mParentTool )
|
||||
mParentTool->keyPressEvent( e );
|
||||
}
|
||||
@ -99,20 +98,30 @@ void QgsMapToolAddEllipse::deactivate()
|
||||
return;
|
||||
}
|
||||
|
||||
mParentTool->clearCurve();
|
||||
mParentTool->addCurve( mEllipse.toLineString() );
|
||||
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
mPoints.clear();
|
||||
mEllipse = QgsEllipse();
|
||||
clean();
|
||||
QgsMapToolCapture::deactivate();
|
||||
}
|
||||
|
||||
void QgsMapToolAddEllipse::activate()
|
||||
{
|
||||
|
||||
clean();
|
||||
QgsMapToolCapture::activate();
|
||||
}
|
||||
|
||||
void QgsMapToolAddEllipse::clean()
|
||||
{
|
||||
if ( mTempRubberBand )
|
||||
{
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
}
|
||||
mPoints.clear();
|
||||
if ( mParentTool )
|
||||
{
|
||||
mParentTool->deleteTempRubberBand();
|
||||
}
|
||||
QgsMapToolCapture::activate();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ class QgsGeometryRubberBand;
|
||||
class QgsMapToolAddEllipse: public QgsMapToolCapture
|
||||
{
|
||||
Q_OBJECT
|
||||
void clean();
|
||||
public:
|
||||
QgsMapToolAddEllipse( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode = CaptureLine );
|
||||
~QgsMapToolAddEllipse();
|
||||
|
@ -30,6 +30,7 @@ QgsMapToolAddRectangle::QgsMapToolAddRectangle( QgsMapToolCapture *parentTool, Q
|
||||
, mTempRubberBand( nullptr )
|
||||
, mRectangle( QgsRectangle() )
|
||||
{
|
||||
clean();
|
||||
if ( mCanvas )
|
||||
{
|
||||
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddRectangle::setParentTool );
|
||||
@ -42,6 +43,7 @@ QgsMapToolAddRectangle::QgsMapToolAddRectangle( QgsMapCanvas *canvas )
|
||||
, mTempRubberBand( nullptr )
|
||||
, mRectangle( QgsRectangle() )
|
||||
{
|
||||
clean();
|
||||
if ( mCanvas )
|
||||
{
|
||||
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddRectangle::setParentTool );
|
||||
@ -50,18 +52,12 @@ QgsMapToolAddRectangle::QgsMapToolAddRectangle( QgsMapCanvas *canvas )
|
||||
|
||||
QgsMapToolAddRectangle::~QgsMapToolAddRectangle()
|
||||
{
|
||||
delete mTempRubberBand;
|
||||
mPoints.clear();
|
||||
clean();
|
||||
}
|
||||
|
||||
void QgsMapToolAddRectangle::setParentTool( QgsMapTool *newTool, QgsMapTool *oldTool )
|
||||
{
|
||||
if ( mTempRubberBand )
|
||||
{
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
}
|
||||
mPoints.clear();
|
||||
|
||||
QgsMapToolCapture *tool = dynamic_cast<QgsMapToolCapture *>( oldTool );
|
||||
QgsMapToolAddRectangle *csTool = dynamic_cast<QgsMapToolAddRectangle *>( oldTool );
|
||||
if ( csTool && newTool == this )
|
||||
@ -83,9 +79,7 @@ void QgsMapToolAddRectangle::keyPressEvent( QKeyEvent *e )
|
||||
|
||||
if ( e && e->key() == Qt::Key_Escape )
|
||||
{
|
||||
mPoints.clear();
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
clean();
|
||||
if ( mParentTool )
|
||||
mParentTool->keyPressEvent( e );
|
||||
}
|
||||
@ -136,6 +130,7 @@ void QgsMapToolAddRectangle::deactivate()
|
||||
return;
|
||||
}
|
||||
|
||||
mParentTool->clearCurve( );
|
||||
mParentTool->addCurve( rectangleToLinestring() );
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
@ -146,10 +141,20 @@ void QgsMapToolAddRectangle::deactivate()
|
||||
|
||||
void QgsMapToolAddRectangle::activate()
|
||||
{
|
||||
if ( mParentTool )
|
||||
{
|
||||
mPoints.clear();
|
||||
mParentTool->deleteTempRubberBand();
|
||||
}
|
||||
clean();
|
||||
QgsMapToolCapture::activate();
|
||||
}
|
||||
|
||||
void QgsMapToolAddRectangle::clean()
|
||||
{
|
||||
if ( mTempRubberBand )
|
||||
{
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
}
|
||||
mPoints.clear();
|
||||
if ( mParentTool )
|
||||
{
|
||||
mParentTool->deleteTempRubberBand();
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ class QgsPolygonV2;
|
||||
class QgsMapToolAddRectangle: public QgsMapToolCapture
|
||||
{
|
||||
Q_OBJECT
|
||||
//! convenient method to clean members
|
||||
void clean();
|
||||
public:
|
||||
QgsMapToolAddRectangle( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode = CaptureLine );
|
||||
~QgsMapToolAddRectangle();
|
||||
|
@ -29,6 +29,7 @@ QgsMapToolAddRegularPolygon::QgsMapToolAddRegularPolygon( QgsMapToolCapture *par
|
||||
, mTempRubberBand( nullptr )
|
||||
, mRegularPolygon( QgsRegularPolygon() )
|
||||
{
|
||||
clean();
|
||||
if ( mCanvas )
|
||||
{
|
||||
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddRegularPolygon::setParentTool );
|
||||
@ -41,6 +42,7 @@ QgsMapToolAddRegularPolygon::QgsMapToolAddRegularPolygon( QgsMapCanvas *canvas )
|
||||
, mTempRubberBand( nullptr )
|
||||
, mRegularPolygon( QgsRegularPolygon() )
|
||||
{
|
||||
clean();
|
||||
if ( mCanvas )
|
||||
{
|
||||
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddRegularPolygon::setParentTool );
|
||||
@ -49,19 +51,12 @@ QgsMapToolAddRegularPolygon::QgsMapToolAddRegularPolygon( QgsMapCanvas *canvas )
|
||||
|
||||
QgsMapToolAddRegularPolygon::~QgsMapToolAddRegularPolygon()
|
||||
{
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
mPoints.clear();
|
||||
clean();
|
||||
}
|
||||
|
||||
void QgsMapToolAddRegularPolygon::setParentTool( QgsMapTool *newTool, QgsMapTool *oldTool )
|
||||
{
|
||||
if ( mTempRubberBand )
|
||||
{
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
}
|
||||
mPoints.clear();
|
||||
clean();
|
||||
QgsMapToolCapture *tool = dynamic_cast<QgsMapToolCapture *>( oldTool );
|
||||
QgsMapToolAddRegularPolygon *csTool = dynamic_cast<QgsMapToolAddRegularPolygon *>( oldTool );
|
||||
if ( csTool && newTool == this )
|
||||
@ -105,13 +100,7 @@ void QgsMapToolAddRegularPolygon::keyPressEvent( QKeyEvent *e )
|
||||
|
||||
if ( e && e->key() == Qt::Key_Escape )
|
||||
{
|
||||
if ( mNumberSidesSpinBox )
|
||||
{
|
||||
deleteNumberSidesSpinBox();
|
||||
}
|
||||
mPoints.clear();
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
clean();
|
||||
if ( mParentTool )
|
||||
mParentTool->keyPressEvent( e );
|
||||
}
|
||||
@ -131,25 +120,33 @@ void QgsMapToolAddRegularPolygon::deactivate()
|
||||
{
|
||||
return;
|
||||
}
|
||||
mParentTool->clearCurve( );
|
||||
mParentTool->addCurve( mRegularPolygon.toLineString() );
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
mPoints.clear();
|
||||
mRegularPolygon = QgsRegularPolygon();
|
||||
if ( mNumberSidesSpinBox )
|
||||
{
|
||||
deleteNumberSidesSpinBox();
|
||||
}
|
||||
clean();
|
||||
|
||||
QgsMapToolCapture::deactivate();
|
||||
}
|
||||
|
||||
void QgsMapToolAddRegularPolygon::activate()
|
||||
{
|
||||
clean();
|
||||
QgsMapToolCapture::activate();
|
||||
}
|
||||
|
||||
void QgsMapToolAddRegularPolygon::clean()
|
||||
{
|
||||
if ( mTempRubberBand )
|
||||
{
|
||||
delete mTempRubberBand;
|
||||
mTempRubberBand = nullptr;
|
||||
}
|
||||
mPoints.clear();
|
||||
if ( mParentTool )
|
||||
{
|
||||
mParentTool->deleteTempRubberBand();
|
||||
}
|
||||
QgsMapToolCapture::activate();
|
||||
if ( mNumberSidesSpinBox )
|
||||
{
|
||||
deleteNumberSidesSpinBox();
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ class QSpinBox;
|
||||
class QgsMapToolAddRegularPolygon: public QgsMapToolCapture
|
||||
{
|
||||
Q_OBJECT
|
||||
void clean();
|
||||
public:
|
||||
QgsMapToolAddRegularPolygon( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode = CaptureLine );
|
||||
~QgsMapToolAddRegularPolygon();
|
||||
|
@ -50,10 +50,7 @@ void QgsMapToolRegularPolygon2Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e
|
||||
mTempRubberBand->show();
|
||||
|
||||
createNumberSidesSpinBox();
|
||||
/*if ( mNumberSidesSpinBox )
|
||||
{
|
||||
mNumberSidesSpinBox->setMinimum( 3 );
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -502,6 +502,11 @@ int QgsMapToolCapture::addCurve( QgsCurve *c )
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QgsMapToolCapture::clearCurve()
|
||||
{
|
||||
mCaptureCurve.clear();
|
||||
}
|
||||
|
||||
QList<QgsPointLocator::Match> QgsMapToolCapture::snappingMatches() const
|
||||
{
|
||||
return mSnappingMatches;
|
||||
|
@ -49,6 +49,13 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
|
||||
//! Adds a whole curve (e.g. circularstring) to the captured geometry. Curve must be in map CRS
|
||||
int addCurve( QgsCurve *c );
|
||||
|
||||
/**
|
||||
* Clear capture curve.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
void clearCurve( );
|
||||
|
||||
/**
|
||||
* Get the capture curve
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user