47  if ( mRatio.width() > 0 && mRatio.height() > 0 )
 
   49    const double width = std::fabs( p.
x() - mStartPoint.
x() );
 
   50    double height = width * ( mRatio.width() / mRatio.height() );
 
   51    if ( p.
y() - mStartPoint.
y() < 0 )
 
   53    p.
setY( mStartPoint.
y() + height );
 
   57  calculateEndPoint( mEndPoint );
 
   64  mEndPoint = mStartPoint;
 
   76  calculateEndPoint( mEndPoint );
 
   86  if ( mStartPoint.
x() != mEndPoint.
x() && mStartPoint.
y() != mEndPoint.
y() )
 
   98  mRubberBand->
reset( Qgis::GeometryType::Polygon );
 
  101void QgsMapToolExtent::calculateEndPoint( 
QgsPointXY &point )
 
  103  if ( mRatio.width() > 0 && mRatio.height() > 0 )
 
  105    const double width = std::fabs( point.
x() - mStartPoint.
x() );
 
  106    double height = width * mRatio.height() / mRatio.width();
 
  107    if ( point.
y() - mStartPoint.
y() < 0 )
 
  109    point.
setY( mStartPoint.
y() + height );
 
  113void QgsMapToolExtent::drawExtent()
 
  120  mRubberBand->
reset( Qgis::GeometryType::Polygon );
 
void reset(T *p=nullptr)
Will reset the managed pointer to p.
 
Map canvas is a class for displaying all GIS data types on a canvas.
 
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
 
A class to represent a 2D point.
 
void setY(double y) SIP_HOLDGIL
Sets the y value of the point.
 
A rectangle specified with double values.
 
A class for drawing transient features (e.g.
 
void reset(Qgis::GeometryType geometryType=Qgis::GeometryType::Line)
Clears all the geometries in this rubberband.
 
void addPoint(const QgsPointXY &p, bool doUpdate=true, int geometryIndex=0, int ringIndex=0)
Adds a vertex to the rubberband and update canvas.
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)