Use VECTOR2I::extended_type instead of long, and int for numeric limits.

This commit is contained in:
Alex 2022-07-16 22:33:33 +03:00 committed by Seth Hillbrand
parent 405be8d15f
commit 371f6d917f
4 changed files with 15 additions and 11 deletions

View File

@ -705,7 +705,9 @@ bool EDA_SHAPE::hitTest( const VECTOR2I& aPosition, int aAccuracy ) const
case SHAPE_T::CIRCLE:
{
int radius = GetRadius();
long dist = KiROUND<double, long>( EuclideanNorm( aPosition - getCenter() ) );
VECTOR2I::extended_type dist = KiROUND<double, VECTOR2I::extended_type>(
EuclideanNorm( aPosition - getCenter() ) );
if( IsFilled() )
return dist <= radius + maxdist; // Filled circle hit-test
@ -723,7 +725,9 @@ bool EDA_SHAPE::hitTest( const VECTOR2I& aPosition, int aAccuracy ) const
VECTOR2I relPos = aPosition - getCenter();
int radius = GetRadius();
long dist = KiROUND<double, long>( EuclideanNorm( relPos ) );
VECTOR2I::extended_type dist =
KiROUND<double, VECTOR2I::extended_type>( EuclideanNorm( relPos ) );
if( IsFilled() )
{

View File

@ -284,10 +284,10 @@ private:
typedef std::numeric_limits<int> coord_limits;
const int guardValue = 1;
long maxDiff = coord_limits::max() - guardValue;
VECTOR2I::extended_type maxDiff = coord_limits::max() - guardValue;
long xDiff = long( aEnd.x ) - aOrigin.x;
long yDiff = long( aEnd.y ) - aOrigin.y;
VECTOR2I::extended_type xDiff = VECTOR2I::extended_type( aEnd.x ) - aOrigin.x;
VECTOR2I::extended_type yDiff = VECTOR2I::extended_type( aEnd.y ) - aOrigin.y;
if( xDiff > maxDiff )
xDiff = maxDiff;
@ -314,8 +314,8 @@ private:
typedef std::numeric_limits<int> coord_limits;
const int guardValue = 10;
long xDiff = long( aEnd.x ) - aOrigin.x;
long yDiff = long( aEnd.y ) - aOrigin.y;
VECTOR2I::extended_type xDiff = VECTOR2I::extended_type( aEnd.x ) - aOrigin.x;
VECTOR2I::extended_type yDiff = VECTOR2I::extended_type( aEnd.y ) - aOrigin.y;
double maxRadius = coord_limits::max() / 2 - guardValue;
double radius = std::hypot( xDiff, yDiff );

View File

@ -1078,8 +1078,8 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
typedef std::numeric_limits<int> coord_limits;
long max = coord_limits::max() - COORDS_PADDING;
long min = -max;
int max = coord_limits::max() - COORDS_PADDING;
int min = -max;
bool outOfBounds = rotPos.x < min || rotPos.x > max || rotPos.y < min || rotPos.y > max
|| rotEnd.x < min || rotEnd.x > max || rotEnd.y < min || rotEnd.y > max;

View File

@ -299,8 +299,8 @@ VECTOR2I EDIT_TOOL::getSafeMovement( const VECTOR2I& aMovement, const BOX2I& aSo
{
typedef std::numeric_limits<int> coord_limits;
long max = coord_limits::max();
long min = -max;
int max = coord_limits::max();
int min = -max;
double left = aBBoxOffset.x + aSourceBBox.GetPosition().x;
double top = aBBoxOffset.y + aSourceBBox.GetPosition().y;