replace round() with KiROUND(), our function that is used almost everywhere for rounding, and detects int overflows in debug mode.
This commit is contained in:
parent
3372b77b43
commit
40ccc0bedf
|
@ -125,8 +125,8 @@ void GAL::DrawGrid()
|
|||
VECTOR2D worldStartPoint = screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
|
||||
VECTOR2D worldEndPoint = screenWorldMatrix * VECTOR2D( screenSize );
|
||||
|
||||
int gridScreenSizeDense = round( gridSize.x * worldScale );
|
||||
int gridScreenSizeCoarse = round( gridSize.x * static_cast<double>( gridTick ) * worldScale );
|
||||
int gridScreenSizeDense = KiROUND( gridSize.x * worldScale );
|
||||
int gridScreenSizeCoarse = KiROUND( gridSize.x * static_cast<double>( gridTick ) * worldScale );
|
||||
|
||||
// Compute the line marker or point radius of the grid
|
||||
double marker = 2.0 * gridLineWidth / worldScale;
|
||||
|
@ -136,10 +136,10 @@ void GAL::DrawGrid()
|
|||
if( std::max( gridScreenSizeDense, gridScreenSizeCoarse ) > gridDrawThreshold )
|
||||
{
|
||||
// Compute grid variables
|
||||
int gridStartX = round( worldStartPoint.x / gridSize.x );
|
||||
int gridEndX = round( worldEndPoint.x / gridSize.x );
|
||||
int gridStartY = round( worldStartPoint.y / gridSize.y );
|
||||
int gridEndY = round( worldEndPoint.y / gridSize.y );
|
||||
int gridStartX = KiROUND( worldStartPoint.x / gridSize.x );
|
||||
int gridEndX = KiROUND( worldEndPoint.x / gridSize.x );
|
||||
int gridStartY = KiROUND( worldStartPoint.y / gridSize.y );
|
||||
int gridEndY = KiROUND( worldEndPoint.y / gridSize.y );
|
||||
|
||||
assert( gridEndX >= gridStartX );
|
||||
assert( gridEndY >= gridStartY );
|
||||
|
@ -231,8 +231,8 @@ void GAL::DrawGrid()
|
|||
|
||||
VECTOR2D GAL::GetGridPoint( const VECTOR2D& aPoint ) const
|
||||
{
|
||||
return VECTOR2D( round( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
|
||||
round( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
|
||||
return VECTOR2D( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
|
||||
KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
|
||||
}
|
||||
|
||||
const int GAL::MIN_DEPTH = -1024;
|
||||
|
|
|
@ -112,7 +112,7 @@ void DIALOG_MOVE_EXACT::OnPolarChanged( wxCommandEvent& event )
|
|||
double r, q;
|
||||
ToPolarDeg( val.x, val.y, r, q );
|
||||
|
||||
PutValueInLocalUnits( *m_xEntry, round( r / 10.0) * 10 );
|
||||
PutValueInLocalUnits( *m_xEntry, KiROUND( r / 10.0) * 10 );
|
||||
m_yEntry->SetValue( wxString::FromDouble( q ) );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#include <geometry/seg.h>
|
||||
|
||||
#include <common.h>
|
||||
|
||||
void EC_VERTICAL::Apply( EDIT_POINT& aHandle )
|
||||
{
|
||||
VECTOR2I point = aHandle.GetPosition();
|
||||
|
@ -50,7 +52,7 @@ void EC_45DEGREE::Apply( EDIT_POINT& aHandle )
|
|||
double angle = lineVector.Angle();
|
||||
|
||||
// Find the closest angle, which is a multiple of 45 degrees
|
||||
double newAngle = round( angle / ( M_PI / 4.0 ) ) * M_PI / 4.0;
|
||||
double newAngle = KiROUND( angle / ( M_PI / 4.0 ) ) * M_PI / 4.0;
|
||||
VECTOR2I newLineVector = lineVector.Rotate( newAngle - angle );
|
||||
|
||||
aHandle.SetPosition( m_constrainer.GetPosition() + newLineVector );
|
||||
|
|
|
@ -96,8 +96,8 @@ VECTOR2I GRID_HELPER::Align( const VECTOR2I& aPoint ) const
|
|||
const VECTOR2D gridOffset( GetOrigin() );
|
||||
const VECTOR2D gridSize( GetGrid() );
|
||||
|
||||
VECTOR2I nearest( round( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
|
||||
round( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
|
||||
VECTOR2I nearest( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
|
||||
KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
|
||||
|
||||
if( !m_auxAxis )
|
||||
return nearest;
|
||||
|
|
|
@ -503,8 +503,8 @@ int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent )
|
|||
// Handler cursor movement
|
||||
KIGFX::VIEW* view = getView();
|
||||
newCursor = view->ToScreen( newCursor );
|
||||
newCursor.x = round( newCursor.x );
|
||||
newCursor.y = round( newCursor.y );
|
||||
newCursor.x = KiROUND( newCursor.x );
|
||||
newCursor.y = KiROUND( newCursor.y );
|
||||
|
||||
// Pan the screen if required
|
||||
const VECTOR2I& screenSize = view->GetGAL()->GetScreenPixelSize();
|
||||
|
|
Loading…
Reference in New Issue