7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 14:41:42 +00:00

BOX2: Add a KiROUND specialisation for BOX2D -> BOX2I

This commit is contained in:
John Beard 2024-09-10 23:12:27 +01:00
parent 5e9aba5555
commit f6a693475f
3 changed files with 7 additions and 4 deletions
common/preview_items
libs/kimath/include/math

View File

@ -80,8 +80,7 @@ void ANCHOR_DEBUG::ViewDraw( int, VIEW* aView ) const
const COLOR4D textColor = settings.GetLayerColor( LAYER_AUX_ITEMS );
const BOX2D viewportD = aView->GetViewport();
const BOX2I viewport( KiROUND( viewportD.GetPosition() ), KiROUND( viewportD.GetSize() ) );
const BOX2I viewport = KiROUND( aView->GetViewport() );
gal.SetIsFill( false );
gal.SetIsStroke( true );

View File

@ -66,8 +66,7 @@ void CONSTRUCTION_GEOM::ViewDraw( int aLayer, VIEW* aView ) const
gal.SetIsStroke( true );
gal.SetLineWidth( 1 );
BOX2D viewportD = aView->GetViewport();
BOX2I viewport( VECTOR2I( viewportD.GetPosition() ), VECTOR2I( viewportD.GetSize() ) );
const BOX2I viewport = KiROUND( aView->GetViewport() );
const bool haveSnapLine = m_snapLine && m_snapLine->Length() != 0;

View File

@ -965,5 +965,10 @@ inline constexpr BOX2I BOX2ISafe( const VECTOR2I& aPos, const VECTOR2<S>& aSize
return BOX2I( aPos, VECTOR2L( right - aPos.x, bottom - aPos.y ) );
}
/* KiROUND specialization for double -> int boxes */
inline constexpr BOX2I KiROUND( const BOX2D& aBoxD )
{
return BOX2I( KiROUND( aBoxD.GetOrigin() ), KiROUND( aBoxD.GetSize() ) );
}
#endif