From 2dc63005011eadccc86e7cfab50dd9c9e2d4b2fe Mon Sep 17 00:00:00 2001
From: Jeff Young <jeff@rokeby.ie>
Date: Wed, 31 Aug 2022 10:15:42 +0100
Subject: [PATCH] Move EDA_ITEM bounding boxes to BOX2I.

---
 common/bitmap_base.cpp                        | 23 +++++------
 common/drawing_sheet/ds_draw_item.cpp         | 39 ++++++++----------
 common/eda_item.cpp                           |  8 ++--
 eeschema/autoplace_fields.cpp                 | 40 +++++++++----------
 eeschema/bus-wire-junction.cpp                | 14 +++----
 eeschema/cross-probing.cpp                    |  2 +-
 eeschema/lib_field.cpp                        | 20 +++++-----
 eeschema/lib_field.h                          |  2 +-
 eeschema/lib_item.h                           |  2 +-
 eeschema/lib_pin.cpp                          |  8 ++--
 eeschema/lib_pin.h                            |  6 +--
 eeschema/lib_shape.cpp                        |  8 ++--
 eeschema/lib_shape.h                          |  2 +-
 eeschema/lib_symbol.cpp                       | 15 ++-----
 eeschema/lib_symbol.h                         |  4 +-
 eeschema/lib_text.cpp                         | 27 ++++++-------
 eeschema/lib_text.h                           |  2 +-
 eeschema/lib_textbox.cpp                      |  2 +-
 eeschema/sch_bitmap.cpp                       | 12 +++---
 eeschema/sch_bitmap.h                         |  4 +-
 eeschema/sch_bus_entry.cpp                    | 14 +++----
 eeschema/sch_bus_entry.h                      |  2 +-
 eeschema/sch_field.cpp                        | 20 +++++-----
 eeschema/sch_field.h                          |  2 +-
 eeschema/sch_junction.cpp                     | 10 ++---
 eeschema/sch_junction.h                       |  2 +-
 eeschema/sch_label.cpp                        |  8 ++--
 eeschema/sch_label.h                          |  2 +-
 eeschema/sch_line.cpp                         | 16 ++++----
 eeschema/sch_line.h                           |  2 +-
 eeschema/sch_marker.cpp                       |  2 +-
 eeschema/sch_marker.h                         |  2 +-
 eeschema/sch_no_connect.cpp                   | 11 +++--
 eeschema/sch_no_connect.h                     |  2 +-
 eeschema/sch_painter.cpp                      | 12 +++---
 eeschema/sch_pin.cpp                          | 12 +++---
 eeschema/sch_pin.h                            |  6 +--
 .../sch_plugins/altium/sch_altium_plugin.cpp  |  6 +--
 .../cadstar/cadstar_sch_archive_loader.cpp    |  6 +--
 .../sch_plugins/eagle/sch_eagle_plugin.cpp    | 12 +++---
 eeschema/sch_rtree.h                          |  6 +--
 eeschema/sch_shape.h                          |  2 +-
 eeschema/sch_sheet.cpp                        | 14 +++----
 eeschema/sch_sheet.h                          |  2 +-
 eeschema/sch_sheet_pin.cpp                    |  2 +-
 eeschema/sch_symbol.cpp                       |  6 +--
 eeschema/sch_symbol.h                         |  4 +-
 eeschema/sch_text.cpp                         | 18 ++++-----
 eeschema/sch_text.h                           |  2 +-
 gerbview/gbr_layout.h                         |  2 +-
 gerbview/gerber_draw_item.cpp                 | 23 ++++-------
 gerbview/gerber_draw_item.h                   |  2 +-
 gerbview/tools/gerbview_selection.cpp         | 22 ++++------
 include/bitmap_base.h                         |  4 +-
 include/drawing_sheet/ds_draw_item.h          | 14 +++----
 include/eda_item.h                            |  2 +-
 include/pcb_group.h                           |  2 +-
 pagelayout_editor/pl_editor_layout.h          |  2 +-
 pcbnew/autorouter/ar_autoplacer.cpp           | 10 ++---
 pcbnew/board.cpp                              | 14 +++----
 pcbnew/board.h                                |  4 +-
 pcbnew/board_commit.cpp                       |  6 +--
 pcbnew/connectivity/connectivity_items.h      |  5 +--
 pcbnew/cross-probing.cpp                      | 17 +++-----
 pcbnew/drc/drc_rtree.h                        |  2 +-
 .../drc_test_provider_copper_clearance.cpp    |  4 +-
 .../drc_test_provider_courtyard_clearance.cpp |  4 +-
 .../drc_test_provider_physical_clearance.cpp  |  4 +-
 pcbnew/drc/drc_test_provider_solder_mask.cpp  |  4 +-
 .../drc_test_provider_zone_connections.cpp    |  2 +-
 pcbnew/footprint.cpp                          | 35 ++++++++--------
 pcbnew/footprint.h                            |  2 +-
 pcbnew/fp_text.cpp                            |  8 ++--
 pcbnew/fp_text.h                              |  2 +-
 pcbnew/netinfo.h                              |  2 +-
 pcbnew/netinfo_item.cpp                       |  4 +-
 pcbnew/pad.cpp                                |  8 ++--
 pcbnew/pad.h                                  |  4 +-
 pcbnew/pcb_bitmap.cpp                         |  6 +--
 pcbnew/pcb_bitmap.h                           |  2 +-
 pcbnew/pcb_dimension.cpp                      |  8 ++--
 pcbnew/pcb_dimension.h                        |  4 +-
 pcbnew/pcb_expr_evaluator.cpp                 |  4 +-
 pcbnew/pcb_group.cpp                          | 10 ++---
 pcbnew/pcb_marker.cpp                         |  2 +-
 pcbnew/pcb_marker.h                           |  2 +-
 pcbnew/pcb_painter.cpp                        |  8 ++--
 pcbnew/pcb_shape.h                            |  2 +-
 pcbnew/pcb_target.cpp                         |  2 +-
 pcbnew/pcb_target.h                           |  2 +-
 pcbnew/pcb_text.cpp                           |  2 +-
 pcbnew/pcb_text.h                             |  2 +-
 pcbnew/pcb_track.cpp                          |  6 +--
 pcbnew/pcb_track.h                            |  2 +-
 pcbnew/zone.cpp                               |  6 +--
 pcbnew/zone.h                                 |  4 +-
 qa/unittests/common/test_bitmap_base.cpp      |  2 +-
 97 files changed, 338 insertions(+), 397 deletions(-)

diff --git a/common/bitmap_base.cpp b/common/bitmap_base.cpp
index 0c03af5fb9..1025095d6d 100644
--- a/common/bitmap_base.cpp
+++ b/common/bitmap_base.cpp
@@ -1,7 +1,3 @@
-/**
- * @file class_bitmap_base.cpp
- */
-
 /*
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
@@ -215,15 +211,14 @@ bool BITMAP_BASE::LoadData( LINE_READER& aLine, wxString& aErrorMsg )
 }
 
 
-const EDA_RECT BITMAP_BASE::GetBoundingBox() const
+const BOX2I BITMAP_BASE::GetBoundingBox() const
 {
-    EDA_RECT rect;
+    BOX2I    bbox;
+    VECTOR2I size = GetSize();
 
-    wxSize   size = GetSize();
+    bbox.Inflate( size.x / 2, size.y / 2 );
 
-    rect.Inflate( size.x / 2, size.y / 2 );
-
-    return rect;
+    return bbox;
 }
 
 
@@ -233,7 +228,7 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const VECTOR2I& aPos )
         return;
 
     VECTOR2I pos = aPos;
-    wxSize  size = GetSize();
+    VECTOR2I size = GetSize();
 
     // This fixes a bug in OSX that should be fixed in the 3.0.3 version or later.
     if( ( size.x == 0 ) || ( size.y == 0 ) )
@@ -292,7 +287,7 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const VECTOR2I& aPos )
     }
 
     aDC->DestroyClippingRegion();
-    aDC->SetClippingRegion( clipAreaPos, size );
+    aDC->SetClippingRegion( clipAreaPos, wxSize( size.x, size.y ) );
 
     if( GetGRForceBlackPenState() )
     {
@@ -316,9 +311,9 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const VECTOR2I& aPos )
 }
 
 
-wxSize BITMAP_BASE::GetSize() const
+VECTOR2I BITMAP_BASE::GetSize() const
 {
-    wxSize size;
+    VECTOR2I size;
 
     if( m_bitmap )
     {
diff --git a/common/drawing_sheet/ds_draw_item.cpp b/common/drawing_sheet/ds_draw_item.cpp
index ad07150fee..9244f2bc97 100644
--- a/common/drawing_sheet/ds_draw_item.cpp
+++ b/common/drawing_sheet/ds_draw_item.cpp
@@ -169,7 +169,7 @@ void DS_DRAW_ITEM_TEXT::PrintWsItem( const RENDER_SETTINGS* aSettings, const VEC
 }
 
 
-const EDA_RECT DS_DRAW_ITEM_TEXT::GetBoundingBox() const
+const BOX2I DS_DRAW_ITEM_TEXT::GetBoundingBox() const
 {
     return EDA_TEXT::GetTextBox();
 }
@@ -231,17 +231,9 @@ void DS_DRAW_ITEM_POLYPOLYGONS::SetPosition( const VECTOR2I& aPos )
 }
 
 
-const EDA_RECT DS_DRAW_ITEM_POLYPOLYGONS::GetBoundingBox() const
+const BOX2I DS_DRAW_ITEM_POLYPOLYGONS::GetBoundingBox() const
 {
-    EDA_RECT rect;
-    BOX2I box = m_Polygons.BBox();
-
-    rect.SetX( box.GetX() );
-    rect.SetY( box.GetY() );
-    rect.SetWidth( box.GetWidth() );
-    rect.SetHeight( box.GetHeight() );
-
-    return rect;
+    return m_Polygons.BBox();
 }
 
 
@@ -309,9 +301,9 @@ void DS_DRAW_ITEM_RECT::PrintWsItem( const RENDER_SETTINGS* aSettings, const VEC
 }
 
 
-const EDA_RECT DS_DRAW_ITEM_RECT::GetBoundingBox() const
+const BOX2I DS_DRAW_ITEM_RECT::GetBoundingBox() const
 {
-    return EDA_RECT( GetStart(), wxSize( GetEnd().x - GetStart().x, GetEnd().y - GetStart().y ) );
+    return BOX2I( GetStart(), GetEnd() - GetStart() );
 }
 
 
@@ -407,9 +399,9 @@ void DS_DRAW_ITEM_LINE::PrintWsItem( const RENDER_SETTINGS* aSettings, const VEC
 }
 
 
-const EDA_RECT DS_DRAW_ITEM_LINE::GetBoundingBox() const
+const BOX2I DS_DRAW_ITEM_LINE::GetBoundingBox() const
 {
-    return EDA_RECT( GetStart(), wxSize( GetEnd().x - GetStart().x, GetEnd().y - GetStart().y ) );
+    return BOX2I( GetStart(), GetEnd() - GetStart() );
 }
 
 
@@ -440,14 +432,14 @@ void DS_DRAW_ITEM_BITMAP::PrintWsItem( const RENDER_SETTINGS* aSettings, const V
 }
 
 
-const EDA_RECT DS_DRAW_ITEM_BITMAP::GetBoundingBox() const
+const BOX2I DS_DRAW_ITEM_BITMAP::GetBoundingBox() const
 {
-    auto*    bitmap = static_cast<const DS_DATA_ITEM_BITMAP*>( m_peer );
-    wxSize bm_size = bitmap->m_ImageBitmap->GetSize();
+    const DS_DATA_ITEM_BITMAP* bitmap = static_cast<const DS_DATA_ITEM_BITMAP*>( m_peer );
+    VECTOR2I                   bm_size = bitmap->m_ImageBitmap->GetSize();
+    BOX2I                      bbox;
 
-    EDA_RECT bbox;
     bbox.SetSize( bm_size );
-    bbox.SetOrigin( m_pos.x - bm_size.x/2, m_pos.y - bm_size.y/2 );
+    bbox.SetOrigin( m_pos.x - bm_size.x / 2, m_pos.y - bm_size.y / 2 );
 
     return bbox;
 }
@@ -480,13 +472,14 @@ wxString DS_DRAW_ITEM_PAGE::GetSelectMenuText( EDA_UNITS aUnits ) const
 }
 
 
-const EDA_RECT DS_DRAW_ITEM_PAGE::GetBoundingBox() const
+const BOX2I DS_DRAW_ITEM_PAGE::GetBoundingBox() const
 {
-    EDA_RECT dummy;
+    BOX2I dummy;
 
     // We want this graphic item always visible. So gives the max size to the
     // bounding box to avoid any clamping:
-    dummy.SetSize( wxSize( std::numeric_limits<int>::max(), std::numeric_limits<int>::max() ) );
+    dummy.SetMaximum();
+
     return dummy;
 }
 
diff --git a/common/eda_item.cpp b/common/eda_item.cpp
index a089f65ca2..c0e5bc5d66 100644
--- a/common/eda_item.cpp
+++ b/common/eda_item.cpp
@@ -72,11 +72,11 @@ void EDA_ITEM::SetModified()
 }
 
 
-const EDA_RECT EDA_ITEM::GetBoundingBox() const
+const BOX2I EDA_ITEM::GetBoundingBox() const
 {
     // return a zero-sized box per default. derived classes should override
     // this
-    return EDA_RECT( VECTOR2I( 0, 0 ), VECTOR2I( 0, 0 ) );
+    return BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( 0, 0 ) );
 }
 
 
@@ -255,9 +255,7 @@ EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem )
 const BOX2I EDA_ITEM::ViewBBox() const
 {
     // Basic fallback
-    EDA_RECT bbox = GetBoundingBox();
-
-    return BOX2I( bbox.GetOrigin(), bbox.GetSize() );
+    return GetBoundingBox();
 }
 
 
diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp
index d9354d8542..c0ae74bc1a 100644
--- a/eeschema/autoplace_fields.cpp
+++ b/eeschema/autoplace_fields.cpp
@@ -139,7 +139,7 @@ public:
         SIDE_AND_NPINS  sideandpins = chooseSideForFields( aManual );
         SIDE            field_side = sideandpins.side;
         VECTOR2I        fbox_pos = fieldBoxPlacement( sideandpins );
-        EDA_RECT        field_box( fbox_pos, m_fbox_size );
+        BOX2I           field_box( fbox_pos, m_fbox_size );
 
         if( aManual )
             forceWireSpacing = fitFieldsBetweenWires( &field_box, field_side );
@@ -190,7 +190,7 @@ protected:
      * Compute and return the size of the fields' bounding box.
      * @param aDynamic - if true, use dynamic spacing
      */
-    wxSize computeFBoxSize( bool aDynamic )
+    VECTOR2I computeFBoxSize( bool aDynamic )
     {
         int max_field_width = 0;
         int total_height = 0;
@@ -210,9 +210,9 @@ protected:
             else
                 field->SetTextAngle( ANGLE_HORIZONTAL );
 
-            EDA_RECT bbox = field->GetBoundingBox();
-            int      field_width = bbox.GetWidth();
-            int      field_height = bbox.GetHeight();
+            BOX2I bbox = field->GetBoundingBox();
+            int   field_width = bbox.GetWidth();
+            int   field_height = bbox.GetHeight();
 
             max_field_width = std::max( max_field_width, field_width );
 
@@ -228,7 +228,7 @@ protected:
                 total_height += field_height + FIELD_PADDING;
         }
 
-        return wxSize( max_field_width, total_height );
+        return VECTOR2I( max_field_width, total_height );
     }
 
     /**
@@ -277,12 +277,12 @@ protected:
     {
         wxCHECK_RET( m_screen, "getPossibleCollisions() with null m_screen" );
 
-        EDA_RECT symbolBox = m_symbol->GetBodyAndPinsBoundingBox();
+        BOX2I symbolBox = m_symbol->GetBodyAndPinsBoundingBox();
         std::vector<SIDE_AND_NPINS> sides = getPreferredSides();
 
         for( SIDE_AND_NPINS& side : sides )
         {
-            EDA_RECT box( fieldBoxPlacement( side ), m_fbox_size );
+            BOX2I box( fieldBoxPlacement( side ), m_fbox_size );
             box.Merge( symbolBox );
 
             for( SCH_ITEM* item : m_screen->Items().Overlapping( box ) )
@@ -308,13 +308,13 @@ protected:
      * Filter a list of possible colliders to include only those that actually collide
      * with a given rectangle. Returns the new vector.
      */
-    std::vector<SCH_ITEM*> filterCollisions( const EDA_RECT& aRect )
+    std::vector<SCH_ITEM*> filterCollisions( const BOX2I& aRect )
     {
         std::vector<SCH_ITEM*> filtered;
 
         for( SCH_ITEM* item : m_colliders )
         {
-            EDA_RECT item_box;
+            BOX2I item_box;
 
             if( SCH_SYMBOL* item_comp = dynamic_cast<SCH_SYMBOL*>( item ) )
                 item_box = item_comp->GetBodyAndPinsBoundingBox();
@@ -412,7 +412,7 @@ protected:
             sideandpins.side = side;
             sideandpins.pins = pinsOnSide( side );
 
-            EDA_RECT box( fieldBoxPlacement( sideandpins ), m_fbox_size );
+            BOX2I box( fieldBoxPlacement( sideandpins ), m_fbox_size );
 
             COLLISION collision = COLLIDE_NONE;
 
@@ -540,8 +540,8 @@ protected:
     VECTOR2I fieldBoxPlacement( SIDE_AND_NPINS aFieldSideAndPins )
     {
         VECTOR2I fbox_center = m_symbol_bbox.Centre();
-        int      offs_x = ( m_symbol_bbox.GetWidth() + m_fbox_size.GetWidth() ) / 2;
-        int      offs_y = ( m_symbol_bbox.GetHeight() + m_fbox_size.GetHeight() ) / 2;
+        int      offs_x = ( m_symbol_bbox.GetWidth() + m_fbox_size.x ) / 2;
+        int      offs_y = ( m_symbol_bbox.GetHeight() + m_fbox_size.y ) / 2;
 
         if( aFieldSideAndPins.side.x != 0 )
             offs_x += HPADDING;
@@ -551,13 +551,13 @@ protected:
         fbox_center.x += aFieldSideAndPins.side.x * offs_x;
         fbox_center.y += aFieldSideAndPins.side.y * offs_y;
 
-        int     x = fbox_center.x - ( m_fbox_size.GetWidth() / 2 );
-        int     y = fbox_center.y - ( m_fbox_size.GetHeight() / 2 );
+        int     x = fbox_center.x - ( m_fbox_size.x / 2 );
+        int     y = fbox_center.y - ( m_fbox_size.y / 2 );
 
         auto getPinsBox =
                 [&]( const VECTOR2I& aSide )
                 {
-                    EDA_RECT pinsBox;
+                    BOX2I pinsBox;
 
                     for( SCH_PIN* each_pin : m_symbol->GetPins() )
                     {
@@ -581,7 +581,7 @@ protected:
             }
             else if( aFieldSideAndPins.side == SIDE_RIGHT || aFieldSideAndPins.side == SIDE_LEFT )
             {
-                y = pinsBox.GetTop() - ( m_fbox_size.GetHeight() + ( VPADDING * 2 ) );
+                y = pinsBox.GetTop() - ( m_fbox_size.y + ( VPADDING * 2 ) );
             }
         }
 
@@ -592,7 +592,7 @@ protected:
      * Shift a field box up or down a bit to make the fields fit between some wires.
      * Returns true if a shift was made.
      */
-    bool fitFieldsBetweenWires( EDA_RECT* aBox, SIDE aSide )
+    bool fitFieldsBetweenWires( BOX2I* aBox, SIDE aSide )
     {
         if( aSide != SIDE_TOP && aSide != SIDE_BOTTOM )
             return false;
@@ -719,8 +719,8 @@ private:
     SCH_SYMBOL*             m_symbol;
     std::vector<SCH_FIELD*> m_fields;
     std::vector<SCH_ITEM*>  m_colliders;
-    EDA_RECT                m_symbol_bbox;
-    wxSize                  m_fbox_size;
+    BOX2I                   m_symbol_bbox;
+    VECTOR2I                m_fbox_size;
     bool                    m_allow_rejustify;
     bool                    m_align_to_grid;
     bool                    m_is_power_symbol;
diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp
index 9369d1fca4..0f474cd0d3 100644
--- a/eeschema/bus-wire-junction.cpp
+++ b/eeschema/bus-wire-junction.cpp
@@ -80,17 +80,15 @@ void SCH_EDIT_FRAME::TestDanglingEnds()
 
 bool SCH_EDIT_FRAME::TrimWire( const VECTOR2I& aStart, const VECTOR2I& aEnd )
 {
-    SCH_SCREEN* screen = GetScreen();
-    bool        retval = false;
+    if( aStart == aEnd )
+        return false;
 
+    SCH_SCREEN*            screen = GetScreen();
     std::vector<SCH_LINE*> wires;
-    EDA_RECT    bb( aStart, wxSize( 1, 1 ) );
+    BOX2I                  bb( aStart );
 
     bb.Merge( aEnd );
 
-    if( aStart == aEnd )
-        return retval;
-
     // We cannot modify the RTree while iterating, so push the possible
     // wires into a separate structure.
     for( EDA_ITEM* item : screen->Items().Overlapping( bb ) )
@@ -138,10 +136,10 @@ bool SCH_EDIT_FRAME::TrimWire( const VECTOR2I& aStart, const VECTOR2I& aEnd )
         SaveCopyInUndoList( screen, line, UNDO_REDO::DELETED, true );
         RemoveFromScreen( line, screen );
 
-        retval = true;
+        return true;
     }
 
-    return retval;
+    return false;
 }
 
 
diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp
index 621858bb40..531c56cd63 100644
--- a/eeschema/cross-probing.cpp
+++ b/eeschema/cross-probing.cpp
@@ -135,7 +135,7 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString* aPath, const wx
         {
             if( crossProbingSettings.zoom_to_fit )
             {
-                EDA_RECT bbox = symbol->GetBoundingBox();
+                BOX2I bbox = symbol->GetBoundingBox();
 
                 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->ZoomFitCrossProbeBBox( bbox );
             }
diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp
index 5fe79aa603..94ca608e00 100644
--- a/eeschema/lib_field.cpp
+++ b/eeschema/lib_field.cpp
@@ -323,7 +323,7 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffs
             orient = ANGLE_HORIZONTAL;
     }
 
-    EDA_RECT bbox = GetBoundingBox();
+    BOX2I bbox = GetBoundingBox();
     bbox.RevertYAxis();
 
     GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_CENTER;
@@ -368,28 +368,28 @@ wxString LIB_FIELD::GetFullText( int unit ) const
 }
 
 
-const EDA_RECT LIB_FIELD::GetBoundingBox() const
+const BOX2I LIB_FIELD::GetBoundingBox() const
 {
     /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
      * calling GetTextBox() that works using top to bottom Y axis orientation.
      */
-    BOX2I rect = GetTextBox( -1, true );
-    rect.RevertYAxis();
+    BOX2I bbox = GetTextBox( -1, true );
+    bbox.RevertYAxis();
 
     // We are using now a bottom to top Y axis.
-    VECTOR2I orig = rect.GetOrigin();
-    VECTOR2I end = rect.GetEnd();
+    VECTOR2I orig = bbox.GetOrigin();
+    VECTOR2I end = bbox.GetEnd();
 
     RotatePoint( orig, GetTextPos(), -GetTextAngle() );
     RotatePoint( end, GetTextPos(), -GetTextAngle() );
 
-    rect.SetOrigin( orig );
-    rect.SetEnd( end );
+    bbox.SetOrigin( orig );
+    bbox.SetEnd( end );
 
     // We are using now a top to bottom Y axis:
-    rect.RevertYAxis();
+    bbox.RevertYAxis();
 
-    return rect;
+    return bbox;
 }
 
 
diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h
index 3c1971dfec..0c1071608f 100644
--- a/eeschema/lib_field.h
+++ b/eeschema/lib_field.h
@@ -128,7 +128,7 @@ public:
 
     void ViewGetLayers( int aLayers[], int& aCount ) const override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
 
diff --git a/eeschema/lib_item.h b/eeschema/lib_item.h
index c89aec3323..018dacc8b3 100644
--- a/eeschema/lib_item.h
+++ b/eeschema/lib_item.h
@@ -184,7 +184,7 @@ public:
     /**
      * @return the boundary box for this, in library coordinates
      */
-    const EDA_RECT GetBoundingBox() const override { return EDA_ITEM::GetBoundingBox(); }
+    const BOX2I GetBoundingBox() const override { return EDA_ITEM::GetBoundingBox(); }
 
     /**
      * Display basic info (type, part and convert) about the current item in message panel.
diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index ffb8cad1ef..742ad413f6 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -141,7 +141,7 @@ LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aN
 
 bool LIB_PIN::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
 {
-    EDA_RECT rect = GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE );
+    BOX2I rect = GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE );
 
     return rect.Inflate( aAccuracy ).Contains( aPosition );
 }
@@ -1124,12 +1124,12 @@ void LIB_PIN::ViewGetLayers( int aLayers[], int& aCount ) const
 }
 
 
-const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber,
-                                        bool aIncludeElectricalType ) const
+const BOX2I LIB_PIN::GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber,
+                                     bool aIncludeElectricalType ) const
 {
     KIFONT::FONT* font = KIFONT::FONT::GetFont( Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>()->m_Appearance.default_font );
 
-    EDA_RECT       bbox;
+    BOX2I          bbox;
     VECTOR2I       begin;
     VECTOR2I       end;
     int            nameTextOffset = 0;
diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h
index 3bb16dc8c1..eeb7f1e65b 100644
--- a/eeschema/lib_pin.h
+++ b/eeschema/lib_pin.h
@@ -182,14 +182,14 @@ public:
     void ViewGetLayers( int aLayers[], int& aCount ) const override;
 
     /* Cannot use a default parameter here as it will not be compatible with the virtual. */
-    const EDA_RECT GetBoundingBox() const override { return GetBoundingBox( false, true, false ); }
+    const BOX2I GetBoundingBox() const override { return GetBoundingBox( false, true, false ); }
 
     /**
      * @param aIncludeInvisibles - if false, do not include labels for invisible pins
      *      in the calculation.
      */
-    const EDA_RECT GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber,
-                                   bool aIncludeElectricalType ) const;
+    const BOX2I GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber,
+                                bool aIncludeElectricalType ) const;
 
     /**
      * Return whether this pin forms an implicit power connection: i.e., is hidden
diff --git a/eeschema/lib_shape.cpp b/eeschema/lib_shape.cpp
index ee97eefbb5..ab2ef3227e 100644
--- a/eeschema/lib_shape.cpp
+++ b/eeschema/lib_shape.cpp
@@ -413,13 +413,13 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
 }
 
 
-const EDA_RECT LIB_SHAPE::GetBoundingBox() const
+const BOX2I LIB_SHAPE::GetBoundingBox() const
 {
-    BOX2I rect = getBoundingBox();
+    BOX2I bbox = getBoundingBox();
 
-    rect.RevertYAxis();
+    bbox.RevertYAxis();
 
-    return rect;
+    return bbox;
 }
 
 
diff --git a/eeschema/lib_shape.h b/eeschema/lib_shape.h
index 1475c757b9..50bd94f25f 100644
--- a/eeschema/lib_shape.h
+++ b/eeschema/lib_shape.h
@@ -65,7 +65,7 @@ public:
             return m_stroke.GetPlotStyle();
     }
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
 
diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp
index cc9f4e1e50..270cc464dc 100644
--- a/eeschema/lib_symbol.cpp
+++ b/eeschema/lib_symbol.cpp
@@ -863,10 +863,9 @@ bool LIB_SYMBOL::PinsConflictWith( const LIB_SYMBOL& aOtherPart, bool aTestNums,
 }
 
 
-const EDA_RECT LIB_SYMBOL::GetUnitBoundingBox( int aUnit, int aConvert ) const
+const BOX2I LIB_SYMBOL::GetUnitBoundingBox( int aUnit, int aConvert ) const
 {
-    EDA_RECT bBox;
-    bool initialized = false;
+    BOX2I bBox;     // Start with a fresh BOX2I so the Merge algorithm works
 
     for( const LIB_ITEM& item : m_drawings )
     {
@@ -884,15 +883,7 @@ const EDA_RECT LIB_SYMBOL::GetUnitBoundingBox( int aUnit, int aConvert ) const
         if ( ( item.Type() == LIB_FIELD_T ) && !( ( LIB_FIELD& ) item ).IsVisible() )
             continue;
 
-        if( initialized )
-        {
-            bBox.Merge( item.GetBoundingBox() );
-        }
-        else
-        {
-            bBox = item.GetBoundingBox();
-            initialized = true;
-        }
+        bBox.Merge( item.GetBoundingBox() );
     }
 
     return bBox;
diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h
index 0251579010..9a909200b2 100644
--- a/eeschema/lib_symbol.h
+++ b/eeschema/lib_symbol.h
@@ -213,7 +213,7 @@ public:
      *  if aConvert == 0 Convert is non used
      *  Invisible fields are not taken in account
      **/
-    const EDA_RECT GetUnitBoundingBox( int aUnit, int aConvert ) const;
+    const BOX2I GetUnitBoundingBox( int aUnit, int aConvert ) const;
 
     /**
      * Get the symbol bounding box excluding fields.
@@ -228,7 +228,7 @@ public:
     const BOX2I GetBodyBoundingBox( int aUnit, int aConvert, bool aIncludePins,
                                     bool aIncludePrivateItems ) const;
 
-    const EDA_RECT GetBoundingBox() const override
+    const BOX2I GetBoundingBox() const override
     {
         return GetUnitBoundingBox( 0, 0 );
     }
diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp
index 01ff926237..6891b4fb24 100644
--- a/eeschema/lib_text.cpp
+++ b/eeschema/lib_text.cpp
@@ -270,17 +270,16 @@ void LIB_TEXT::Plot( PLOTTER* plotter, bool aBackground, const VECTOR2I& offset,
     if( aBackground )
         return;
 
-    EDA_RECT bBox = GetBoundingBox();
+    BOX2I bBox = GetBoundingBox();
     // convert coordinates from draw Y axis to symbol_editor Y axis
     bBox.RevertYAxis();
     VECTOR2I txtpos = bBox.Centre();
 
     // The text orientation may need to be flipped if the transformation matrix causes xy
     // axes to be flipped.
-    int t1  = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL );
+    int      t1  = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL );
     VECTOR2I pos = aTransform.TransformCoordinate( txtpos ) + offset;
-
-    COLOR4D color = GetTextColor();
+    COLOR4D  color = GetTextColor();
 
     if( !plotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
         color = plotter->RenderSettings()->GetLayerColor( LAYER_DEVICE );
@@ -345,7 +344,7 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
      *   to calculate so the more easily way is to use no justifications (centered text) and
      *   use GetBoundingBox to know the text coordinate considered as centered
     */
-    EDA_RECT bBox = GetBoundingBox();
+    BOX2I bBox = GetBoundingBox();
 
     // convert coordinates from draw Y axis to symbol_editor Y axis:
     bBox.RevertYAxis();
@@ -395,28 +394,28 @@ void LIB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
 }
 
 
-const EDA_RECT LIB_TEXT::GetBoundingBox() const
+const BOX2I LIB_TEXT::GetBoundingBox() const
 {
     /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
      * calling GetTextBox() that works using top to bottom Y axis orientation.
      */
-    BOX2I rect = GetTextBox( -1, true );
-    rect.RevertYAxis();
+    BOX2I bbox = GetTextBox( -1, true );
+    bbox.RevertYAxis();
 
     // We are using now a bottom to top Y axis.
-    VECTOR2I orig = rect.GetOrigin();
-    VECTOR2I end = rect.GetEnd();
+    VECTOR2I orig = bbox.GetOrigin();
+    VECTOR2I end = bbox.GetEnd();
 
     RotatePoint( orig, GetTextPos(), -GetTextAngle() );
     RotatePoint( end, GetTextPos(), -GetTextAngle() );
 
-    rect.SetOrigin( orig );
-    rect.SetEnd( end );
+    bbox.SetOrigin( orig );
+    bbox.SetEnd( end );
 
     // We are using now a top to bottom Y axis:
-    rect.RevertYAxis();
+    bbox.RevertYAxis();
 
-    return rect;
+    return bbox;
 }
 
 
diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h
index aa13f87152..497b393ae6 100644
--- a/eeschema/lib_text.h
+++ b/eeschema/lib_text.h
@@ -81,7 +81,7 @@ public:
 
     KIFONT::FONT* GetDrawFont() const override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     void BeginEdit( const VECTOR2I& aStartPoint ) override;
     void CalcEdit( const VECTOR2I& aPosition ) override;
diff --git a/eeschema/lib_textbox.cpp b/eeschema/lib_textbox.cpp
index 751405c463..76dc8d7453 100644
--- a/eeschema/lib_textbox.cpp
+++ b/eeschema/lib_textbox.cpp
@@ -286,7 +286,7 @@ bool LIB_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
     if( aAccuracy < Mils2iu( MINIMUM_SELECTION_DISTANCE ) )
         aAccuracy = Mils2iu( MINIMUM_SELECTION_DISTANCE );
 
-    EDA_RECT rect = GetBoundingBox();
+    BOX2I rect = GetBoundingBox();
 
     rect.Inflate( aAccuracy );
 
diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp
index d1b9b8a149..775a300c28 100644
--- a/eeschema/sch_bitmap.cpp
+++ b/eeschema/sch_bitmap.cpp
@@ -104,13 +104,13 @@ void SCH_BITMAP::SwapData( SCH_ITEM* aItem )
 }
 
 
-const EDA_RECT SCH_BITMAP::GetBoundingBox() const
+const BOX2I SCH_BITMAP::GetBoundingBox() const
 {
-    EDA_RECT rect = m_image->GetBoundingBox();
+    BOX2I bbox = m_image->GetBoundingBox();
 
-    rect.Move( m_pos );
+    bbox.Move( m_pos );
 
-    return rect;
+    return bbox;
 }
 
 
@@ -122,7 +122,7 @@ void SCH_BITMAP::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffse
 }
 
 
-wxSize SCH_BITMAP::GetSize() const
+VECTOR2I SCH_BITMAP::GetSize() const
 {
     return m_image->GetSize();
 }
@@ -162,7 +162,7 @@ void SCH_BITMAP::Show( int nestLevel, std::ostream& os ) const
 
 bool SCH_BITMAP::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
 {
-    EDA_RECT rect = GetBoundingBox();
+    BOX2I rect = GetBoundingBox();
 
     rect.Inflate( aAccuracy );
 
diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h
index d512876ab5..5f17527fe6 100644
--- a/eeschema/sch_bitmap.h
+++ b/eeschema/sch_bitmap.h
@@ -86,9 +86,9 @@ public:
     /**
      * @return the actual size (in user units, not in pixels) of the image.
      */
-    wxSize GetSize() const;
+    VECTOR2I GetSize() const;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     void SwapData( SCH_ITEM* aItem ) override;
 
diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp
index fabe3881f3..de59f6b9c2 100644
--- a/eeschema/sch_bus_entry.cpp
+++ b/eeschema/sch_bus_entry.cpp
@@ -159,17 +159,15 @@ void SCH_BUS_ENTRY_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
 }
 
 
-const EDA_RECT SCH_BUS_ENTRY_BASE::GetBoundingBox() const
+const BOX2I SCH_BUS_ENTRY_BASE::GetBoundingBox() const
 {
-    EDA_RECT box;
+    BOX2I bbox( m_pos );
+    bbox.SetEnd( GetEnd() );
 
-    box.SetOrigin( m_pos );
-    box.SetEnd( GetEnd() );
+    bbox.Normalize();
+    bbox.Inflate( ( GetPenWidth() / 2 ) + 1 );
 
-    box.Normalize();
-    box.Inflate( ( GetPenWidth() / 2 ) + 1 );
-
-    return box;
+    return bbox;
 }
 
 
diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h
index 215036526a..3269a3e518 100644
--- a/eeschema/sch_bus_entry.h
+++ b/eeschema/sch_bus_entry.h
@@ -89,7 +89,7 @@ public:
 
     void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     void Move( const VECTOR2I& aMoveVector ) override
     {
diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp
index b89ad63134..a9fb575735 100644
--- a/eeschema/sch_field.cpp
+++ b/eeschema/sch_field.cpp
@@ -399,16 +399,16 @@ EDA_ANGLE SCH_FIELD::GetDrawRotation() const
 }
 
 
-const EDA_RECT SCH_FIELD::GetBoundingBox() const
+const BOX2I SCH_FIELD::GetBoundingBox() const
 {
     // Calculate the text bounding box:
-    BOX2I rect = GetTextBox();
+    BOX2I bbox = GetTextBox();
 
     // Calculate the bounding box position relative to the parent:
     VECTOR2I origin = GetParentPosition();
     VECTOR2I pos = GetTextPos() - origin;
-    VECTOR2I begin = rect.GetOrigin() - origin;
-    VECTOR2I end = rect.GetEnd() - origin;
+    VECTOR2I begin = bbox.GetOrigin() - origin;
+    VECTOR2I end = bbox.GetEnd() - origin;
     RotatePoint( begin, pos, GetTextAngle() );
     RotatePoint( end, pos, GetTextAngle() );
 
@@ -431,13 +431,13 @@ const EDA_RECT SCH_FIELD::GetBoundingBox() const
         transform = TRANSFORM( 1, 0, 0, 1 );  // identity transform
     }
 
-    rect.SetOrigin( transform.TransformCoordinate( begin ) );
-    rect.SetEnd( transform.TransformCoordinate( end ) );
+    bbox.SetOrigin( transform.TransformCoordinate( begin ) );
+    bbox.SetEnd( transform.TransformCoordinate( end ) );
 
-    rect.Move( origin );
-    rect.Normalize();
+    bbox.Move( origin );
+    bbox.Normalize();
 
-    return rect;
+    return bbox;
 }
 
 
@@ -874,7 +874,7 @@ bool SCH_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
     if( !IsVisible() || IsVoid() )
         return false;
 
-    EDA_RECT rect = GetBoundingBox();
+    BOX2I rect = GetBoundingBox();
 
     rect.Inflate( aAccuracy );
 
diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h
index 25d85205ae..9e9a0554f6 100644
--- a/eeschema/sch_field.h
+++ b/eeschema/sch_field.h
@@ -124,7 +124,7 @@ public:
      */
     EDA_ANGLE         GetDrawRotation() const override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     /**
      * Return whether the field will be rendered with the horizontal justification
diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp
index 44af91e3da..9d33b2a47e 100644
--- a/eeschema/sch_junction.cpp
+++ b/eeschema/sch_junction.cpp
@@ -100,14 +100,12 @@ SHAPE_CIRCLE SCH_JUNCTION::getEffectiveShape() const
 }
 
 
-const EDA_RECT SCH_JUNCTION::GetBoundingBox() const
+const BOX2I SCH_JUNCTION::GetBoundingBox() const
 {
-    EDA_RECT rect;
+    BOX2I bbox( m_pos );
+    bbox.Inflate( getEffectiveShape().GetRadius() );
 
-    rect.SetOrigin( m_pos );
-    rect.Inflate( getEffectiveShape().GetRadius() );
-
-    return rect;
+    return bbox;
 }
 
 
diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h
index de1022cd2a..742251caed 100644
--- a/eeschema/sch_junction.h
+++ b/eeschema/sch_junction.h
@@ -67,7 +67,7 @@ public:
 
     void ViewGetLayers( int aLayers[], int& aCount ) const override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
 
diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp
index 67c1772dd6..bb44ebccc9 100644
--- a/eeschema/sch_label.cpp
+++ b/eeschema/sch_label.cpp
@@ -657,7 +657,7 @@ const BOX2I SCH_LABEL_BASE::GetBodyBoundingBox() const
 }
 
 
-const EDA_RECT SCH_LABEL_BASE::GetBoundingBox() const
+const BOX2I SCH_LABEL_BASE::GetBoundingBox() const
 {
     // build the bounding box of the entire label, including its fields
 
@@ -667,7 +667,7 @@ const EDA_RECT SCH_LABEL_BASE::GetBoundingBox() const
     {
         if( field.IsVisible() )
         {
-            EDA_RECT fieldBBox = field.GetBoundingBox();
+            BOX2I fieldBBox = field.GetBoundingBox();
 
             if( Type() == SCH_LABEL_T || Type() == SCH_GLOBAL_LABEL_T )
                 fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
@@ -694,7 +694,7 @@ bool SCH_LABEL_BASE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
     {
         if( field.IsVisible() )
         {
-            EDA_RECT fieldBBox = field.GetBoundingBox();
+            BOX2I fieldBBox = field.GetBoundingBox();
             fieldBBox.Inflate( aAccuracy );
 
             if( Type() == SCH_LABEL_T || Type() == SCH_GLOBAL_LABEL_T )
@@ -728,7 +728,7 @@ bool SCH_LABEL_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccur
         {
             if( field.IsVisible() )
             {
-                EDA_RECT fieldBBox = field.GetBoundingBox();
+                BOX2I fieldBBox = field.GetBoundingBox();
 
                 if( Type() == SCH_LABEL_T || Type() == SCH_GLOBAL_LABEL_T )
                     fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
diff --git a/eeschema/sch_label.h b/eeschema/sch_label.h
index 1899332656..3de3ac7ed8 100644
--- a/eeschema/sch_label.h
+++ b/eeschema/sch_label.h
@@ -152,7 +152,7 @@ public:
     /**
      * Return the bounding box of the label including its fields.
      */
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
     bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp
index 748b95719c..f4582ebf82 100644
--- a/eeschema/sch_line.cpp
+++ b/eeschema/sch_line.cpp
@@ -188,18 +188,18 @@ void SCH_LINE::ViewGetLayers( int aLayers[], int& aCount ) const
 }
 
 
-const EDA_RECT SCH_LINE::GetBoundingBox() const
+const BOX2I SCH_LINE::GetBoundingBox() const
 {
-    int      width = m_stroke.GetWidth() / 2;
-    int      extra = m_stroke.GetWidth() & 0x1;
+    int   width = m_stroke.GetWidth() / 2;
+    int   extra = m_stroke.GetWidth() & 0x1;
 
-    int      xmin = std::min( m_start.x, m_end.x ) - width;
-    int      ymin = std::min( m_start.y, m_end.y ) - width;
+    int   xmin = std::min( m_start.x, m_end.x ) - width;
+    int   ymin = std::min( m_start.y, m_end.y ) - width;
 
-    int      xmax = std::max( m_start.x, m_end.x ) + width + extra;
-    int      ymax = std::max( m_start.y, m_end.y ) + width + extra;
+    int   xmax = std::max( m_start.x, m_end.x ) + width + extra;
+    int   ymax = std::max( m_start.y, m_end.y ) + width + extra;
 
-    EDA_RECT ret( VECTOR2I( xmin, ymin ), VECTOR2I( xmax - xmin, ymax - ymin ) );
+    BOX2I ret( VECTOR2I( xmin, ymin ), VECTOR2I( xmax - xmin, ymax - ymin ) );
 
     return ret;
 }
diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h
index cb18d078bb..39fef48062 100644
--- a/eeschema/sch_line.h
+++ b/eeschema/sch_line.h
@@ -188,7 +188,7 @@ public:
 
     void ViewGetLayers( int aLayers[], int& aCount ) const override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     /**
      * @return The length of the line segment.
diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp
index 3531227507..3e3c545d82 100644
--- a/eeschema/sch_marker.cpp
+++ b/eeschema/sch_marker.cpp
@@ -179,7 +179,7 @@ bool SCH_MARKER::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) c
 }
 
 
-const EDA_RECT SCH_MARKER::GetBoundingBox() const
+const BOX2I SCH_MARKER::GetBoundingBox() const
 {
     return GetBoundingBoxMarker();
 }
diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h
index 558e522d13..1367974bca 100644
--- a/eeschema/sch_marker.h
+++ b/eeschema/sch_marker.h
@@ -70,7 +70,7 @@ public:
         // do not confirm this by locally implementing a no-op Plot().
     }
 
-    EDA_RECT const GetBoundingBox() const override;
+    BOX2I const GetBoundingBox() const override;
 
     // Geometric transforms (used in block operations):
 
diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp
index a65d4bfa22..0fa908fdb8 100644
--- a/eeschema/sch_no_connect.cpp
+++ b/eeschema/sch_no_connect.cpp
@@ -65,15 +65,14 @@ void SCH_NO_CONNECT::SwapData( SCH_ITEM* aItem )
 }
 
 
-const EDA_RECT SCH_NO_CONNECT::GetBoundingBox() const
+const BOX2I SCH_NO_CONNECT::GetBoundingBox() const
 {
-    int      delta = ( GetPenWidth() + GetSize() ) / 2;
-    EDA_RECT box;
+    int   delta = ( GetPenWidth() + GetSize() ) / 2;
+    BOX2I bbox( m_pos );
 
-    box.SetOrigin( m_pos );
-    box.Inflate( delta );
+    bbox.Inflate( delta );
 
-    return box;
+    return bbox;
 }
 
 
diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h
index 0708d7def5..e823b1a7fd 100644
--- a/eeschema/sch_no_connect.h
+++ b/eeschema/sch_no_connect.h
@@ -69,7 +69,7 @@ public:
 
     void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     // Geometric transforms (used in block operations):
 
diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp
index 5e50e0a823..39ccf3e7fd 100644
--- a/eeschema/sch_painter.cpp
+++ b/eeschema/sch_painter.cpp
@@ -549,7 +549,7 @@ void SCH_PAINTER::boxText( const wxString& aText, const VECTOR2D& aPosition,
 
     VECTOR2I extents = font->StringBoundaryLimits( aText, aAttrs.m_Size, aAttrs.m_StrokeWidth,
                                                    aAttrs.m_Bold, aAttrs.m_Italic );
-    EDA_RECT box( (VECTOR2I) aPosition, wxSize( extents.x, aAttrs.m_Size.y ) );
+    BOX2I box( aPosition, VECTOR2I( extents.x, aAttrs.m_Size.y ) );
 
     switch( aAttrs.m_Halign )
     {
@@ -874,7 +874,7 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer )
     m_gal->SetStrokeColor( color );
     m_gal->SetFillColor( color );
 
-    EDA_RECT bbox = aField->GetBoundingBox();
+    BOX2I bbox = aField->GetBoundingBox();
 
     if( drawingShadows )
     {
@@ -929,7 +929,7 @@ void SCH_PAINTER::draw( const LIB_TEXT* aText, int aLayer )
             return;
     }
 
-    EDA_RECT bBox = aText->GetBoundingBox();
+    BOX2I bBox = aText->GetBoundingBox();
 
     m_gal->SetFillColor( color );
     m_gal->SetStrokeColor( color );
@@ -1838,7 +1838,7 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer )
 
     if( drawingShadows )
     {
-        EDA_RECT bBox = aText->GetBoundingBox();
+        BOX2I bBox = aText->GetBoundingBox();
         bBox.Inflate( getTextThickness( aText ) * 2 );
         bBox.RevertYAxis();
 
@@ -2198,7 +2198,7 @@ void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer )
      *   to calculate so the easier way is to use no justifications (centered text) and use
      *   GetBoundingBox to know the text coordinate considered as centered
      */
-    EDA_RECT bbox = aField->GetBoundingBox();
+    BOX2I bbox = aField->GetBoundingBox();
 
     if( aField->GetParent() && aField->GetParent()->Type() == SCH_GLOBAL_LABEL_T )
     {
@@ -2211,7 +2211,7 @@ void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer )
 
     if( drawingShadows )
     {
-        EDA_RECT shadow_box = bbox;
+        BOX2I shadow_box = bbox;
         shadow_box.Inflate( getTextThickness( aField ) * 2 );
         shadow_box.RevertYAxis();
 
diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp
index 4ff5df1be0..9433f0310c 100644
--- a/eeschema/sch_pin.cpp
+++ b/eeschema/sch_pin.cpp
@@ -146,9 +146,7 @@ int SCH_PIN::GetLength() const
 
 const BOX2I SCH_PIN::ViewBBox() const
 {
-    EDA_RECT bbox = GetBoundingBox( false, true, true );
-
-    return BOX2I( bbox.GetOrigin(), bbox.GetSize() );
+    return GetBoundingBox( false, true, true );
 }
 
 
@@ -317,11 +315,11 @@ VECTOR2I SCH_PIN::GetTransformedPosition() const
 }
 
 
-const EDA_RECT SCH_PIN::GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber,
-                                        bool aIncludeElectricalType ) const
+const BOX2I SCH_PIN::GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber,
+                                     bool aIncludeElectricalType ) const
 {
     TRANSFORM t = GetParentSymbol()->GetTransform();
-    EDA_RECT  r = m_libPin->GetBoundingBox( aIncludeInvisiblePins, aIncludeNameAndNumber,
+    BOX2I     r = m_libPin->GetBoundingBox( aIncludeInvisiblePins, aIncludeNameAndNumber,
                                             aIncludeElectricalType );
 
     r.RevertYAxis();
@@ -340,7 +338,7 @@ bool SCH_PIN::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
     if( Schematic() )
         aAccuracy = std::max( aAccuracy, Schematic()->Settings().m_PinSymbolSize / 4 );
 
-    EDA_RECT rect = GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE );
+    BOX2I rect = GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE );
     return rect.Inflate( aAccuracy ).Contains( aPosition );
 }
 
diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h
index 636281421c..de2e8ae922 100644
--- a/eeschema/sch_pin.h
+++ b/eeschema/sch_pin.h
@@ -84,14 +84,14 @@ public:
     void           SetPosition( const VECTOR2I& aPosition ) override { m_position = aPosition; }
 
     /* Cannot use a default parameter here as it will not be compatible with the virtual. */
-    const EDA_RECT GetBoundingBox() const override { return GetBoundingBox( false, true, false ); }
+    const BOX2I GetBoundingBox() const override { return GetBoundingBox( false, true, false ); }
 
     /**
      * @param aIncludeInvisibles - if false, do not include labels for invisible pins
      *      in the calculation.
      */
-    const EDA_RECT GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber,
-                                   bool aIncludeElectricalType ) const;
+    const BOX2I GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber,
+                                bool aIncludeElectricalType ) const;
 
     bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
     bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp
index 8855c3b188..a9a50c7df1 100644
--- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp
+++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp
@@ -2385,10 +2385,10 @@ void SCH_ALTIUM_PLUGIN::ParseImage( const std::map<wxString, wxString>& aPropert
     }
 
     // we only support one scale, thus we need to select one in case it does not keep aspect ratio
-    wxSize  currentImageSize = bitmap->GetSize();
+    VECTOR2I currentImageSize = bitmap->GetSize();
     VECTOR2I expectedImageSize = elem.location - elem.corner;
-    double  scaleX = std::abs( static_cast<double>( expectedImageSize.x ) / currentImageSize.x );
-    double  scaleY = std::abs( static_cast<double>( expectedImageSize.y ) / currentImageSize.y );
+    double   scaleX = std::abs( static_cast<double>( expectedImageSize.x ) / currentImageSize.x );
+    double   scaleY = std::abs( static_cast<double>( expectedImageSize.y ) / currentImageSize.y );
     bitmap->SetImageScale( std::min( scaleX, scaleY ) );
 
     bitmap->SetFlags( IS_NEW );
diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp
index 31759f1550..77baa0996f 100644
--- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp
+++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp
@@ -158,9 +158,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSh
         // Calculate the new sheet size.
         EDA_RECT sheetBoundingBox;
 
-        for( auto item : sheet->GetScreen()->Items() )
+        for( SCH_ITEM* item : sheet->GetScreen()->Items() )
         {
-            EDA_RECT bbox;
+            BOX2I bbox;
 
             // Only use the visible fields of the symbols to calculate their bounding box
             // (hidden fields could be very long and artificially enlarge the sheet bounding box)
@@ -2769,7 +2769,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT*            aKiCadT
         // so need to adjust the location of the text element based on Cadstar's original text
         // alignment (anchor position).
         setAlignment( aKiCadTextItem, textAlignment );
-        EDA_RECT bb = textEdaItem->GetBoundingBox();
+        BOX2I    bb = textEdaItem->GetBoundingBox();
         int      off = static_cast<SCH_TEXT*>( aKiCadTextItem )->GetTextOffset();
         wxPoint  pos;
 
diff --git a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp
index 375be5f32c..5fc402a834 100644
--- a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp
+++ b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp
@@ -111,9 +111,9 @@ static int countChildren( wxXmlNode* aCurrentNode, const wxString& aName )
 
 
 ///< Compute a bounding box for all items in a schematic sheet
-static EDA_RECT getSheetBbox( SCH_SHEET* aSheet )
+static BOX2I getSheetBbox( SCH_SHEET* aSheet )
 {
-    EDA_RECT bbox;
+    BOX2I bbox;
 
     for( SCH_ITEM* item : aSheet->GetScreen()->Items() )
         bbox.Merge( item->GetBoundingBox() );
@@ -756,7 +756,7 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
     // Calculate the already placed items bounding box and the page size to determine
     // placement for the new symbols
     wxSize   pageSizeIU = m_rootSheet->GetScreen()->GetPageSettings().GetSizeIU( IU_PER_MILS );
-    EDA_RECT sheetBbox  = getSheetBbox( m_rootSheet );
+    BOX2I    sheetBbox  = getSheetBbox( m_rootSheet );
     VECTOR2I newCmpPosition( sheetBbox.GetLeft(), sheetBbox.GetBottom() );
     int      maxY = sheetBbox.GetY();
 
@@ -783,8 +783,8 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
             symbol->AddHierarchicalReference( sheetpath.Path(), reference, unit );
 
             // Calculate the placement position
-            EDA_RECT cmpBbox = symbol->GetBoundingBox();
-            int      posY    = newCmpPosition.y + cmpBbox.GetHeight();
+            BOX2I cmpBbox = symbol->GetBoundingBox();
+            int   posY    = newCmpPosition.y + cmpBbox.GetHeight();
             symbol->SetPosition( VECTOR2I( newCmpPosition.x, posY ) );
             newCmpPosition.x += cmpBbox.GetWidth();
             maxY = std::max( maxY, posY );
@@ -935,7 +935,7 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
     }
 
     // Calculate the new sheet size.
-    EDA_RECT sheetBoundingBox = getSheetBbox( m_currentSheet );
+    BOX2I    sheetBoundingBox = getSheetBbox( m_currentSheet );
     VECTOR2I targetSheetSize = sheetBoundingBox.GetSize();
     targetSheetSize += VECTOR2I( Mils2iu( 1500 ), Mils2iu( 1500 ) );
 
diff --git a/eeschema/sch_rtree.h b/eeschema/sch_rtree.h
index dfcdc99ac6..48a0999198 100644
--- a/eeschema/sch_rtree.h
+++ b/eeschema/sch_rtree.h
@@ -59,7 +59,7 @@ public:
      */
     void insert( SCH_ITEM* aItem )
     {
-        EDA_RECT bbox = aItem->GetBoundingBox();
+        BOX2I bbox = aItem->GetBoundingBox();
 
         // Inflate a bit for safety, selection shadows, etc.
         bbox.Inflate( aItem->GetPenWidth() );
@@ -79,7 +79,7 @@ public:
     bool remove( SCH_ITEM* aItem )
     {
         // First, attempt to remove the item using its given BBox
-        EDA_RECT bbox    = aItem->GetBoundingBox();
+        BOX2I bbox = aItem->GetBoundingBox();
 
         // Inflate a bit for safety, selection shadows, etc.
         bbox.Inflate( aItem->GetPenWidth() );
@@ -125,7 +125,7 @@ public:
      */
     bool contains( const SCH_ITEM* aItem, bool aRobust = false ) const
     {
-        EDA_RECT bbox    = aItem->GetBoundingBox();
+        BOX2I bbox = aItem->GetBoundingBox();
 
         // Inflate a bit for safety, selection shadows, etc.
         bbox.Inflate( aItem->GetPenWidth() );
diff --git a/eeschema/sch_shape.h b/eeschema/sch_shape.h
index 42c2794aec..2fc0a3a414 100644
--- a/eeschema/sch_shape.h
+++ b/eeschema/sch_shape.h
@@ -72,7 +72,7 @@ public:
             return m_stroke.GetPlotStyle();
     }
 
-    const EDA_RECT GetBoundingBox() const override    { return getBoundingBox(); }
+    const BOX2I GetBoundingBox() const override    { return getBoundingBox(); }
 
     VECTOR2I GetPosition() const override { return getPosition(); }
     void     SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); }
diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp
index e2bb59892e..88115758cd 100644
--- a/eeschema/sch_sheet.cpp
+++ b/eeschema/sch_sheet.cpp
@@ -454,7 +454,7 @@ int SCH_SHEET::GetMinWidth( bool aFromLeft ) const
 
         if( edge == SHEET_SIDE::TOP || edge == SHEET_SIDE::BOTTOM )
         {
-            EDA_RECT pinRect = m_pins[i]->GetBoundingBox();
+            BOX2I pinRect = m_pins[i]->GetBoundingBox();
 
             pinsLeft = std::min( pinsLeft, pinRect.GetLeft() );
             pinsRight = std::max( pinsRight, pinRect.GetRight() );
@@ -488,7 +488,7 @@ int SCH_SHEET::GetMinHeight( bool aFromTop ) const
 
         if( edge == SHEET_SIDE::RIGHT || edge == SHEET_SIDE::LEFT )
         {
-            EDA_RECT pinRect = m_pins[i]->GetBoundingBox();
+            BOX2I pinRect = m_pins[i]->GetBoundingBox();
 
             pinsTop = std::min( pinsTop, pinRect.GetTop() );
             pinsBottom = std::max( pinsBottom, pinRect.GetBottom() );
@@ -638,20 +638,20 @@ const BOX2I SCH_SHEET::GetBodyBoundingBox() const
 }
 
 
-const EDA_RECT SCH_SHEET::GetBoundingBox() const
+const BOX2I SCH_SHEET::GetBoundingBox() const
 {
-    BOX2I box = GetBodyBoundingBox();
+    BOX2I bbox = GetBodyBoundingBox();
 
     for( const SCH_FIELD& field : m_fields )
-        box.Merge( field.GetBoundingBox() );
+        bbox.Merge( field.GetBoundingBox() );
 
-    return box;
+    return bbox;
 }
 
 
 VECTOR2I SCH_SHEET::GetRotationCenter() const
 {
-    EDA_RECT box( m_pos, m_size );
+    BOX2I box( m_pos, m_size );
     return box.GetCenter();
 }
 
diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h
index 3d7ca577c9..e3900aefb8 100644
--- a/eeschema/sch_sheet.h
+++ b/eeschema/sch_sheet.h
@@ -250,7 +250,7 @@ public:
      */
     const BOX2I GetBodyBoundingBox() const;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     /**
      * Rotating around the boundingBox's center can cause walking when the sheetname or
diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp
index af11f3b032..9bb2c25370 100644
--- a/eeschema/sch_sheet_pin.cpp
+++ b/eeschema/sch_sheet_pin.cpp
@@ -340,7 +340,7 @@ BITMAPS SCH_SHEET_PIN::GetMenuImage() const
 
 bool SCH_SHEET_PIN::HitTest( const VECTOR2I& aPoint, int aAccuracy ) const
 {
-    EDA_RECT rect = GetBoundingBox();
+    BOX2I rect = GetBoundingBox();
 
     rect.Inflate( aAccuracy );
 
diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp
index 2dab0bb2d9..24f302b7a1 100644
--- a/eeschema/sch_symbol.cpp
+++ b/eeschema/sch_symbol.cpp
@@ -1447,13 +1447,13 @@ BOX2I SCH_SYMBOL::GetBodyBoundingBox() const
 }
 
 
-EDA_RECT SCH_SYMBOL::GetBodyAndPinsBoundingBox() const
+BOX2I SCH_SYMBOL::GetBodyAndPinsBoundingBox() const
 {
     return doGetBoundingBox( true, false );
 }
 
 
-const EDA_RECT SCH_SYMBOL::GetBoundingBox() const
+const BOX2I SCH_SYMBOL::GetBoundingBox() const
 {
     return doGetBoundingBox( true, true );
 }
@@ -1807,7 +1807,7 @@ bool SCH_SYMBOL::operator <( const SCH_ITEM& aItem ) const
 
     auto symbol = static_cast<const SCH_SYMBOL*>( &aItem );
 
-    EDA_RECT rect = GetBodyAndPinsBoundingBox();
+    BOX2I rect = GetBodyAndPinsBoundingBox();
 
     if( rect.GetArea() != symbol->GetBodyAndPinsBoundingBox().GetArea() )
         return rect.GetArea() < symbol->GetBodyAndPinsBoundingBox().GetArea();
diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h
index 785d7a96b7..7aead19a66 100644
--- a/eeschema/sch_symbol.h
+++ b/eeschema/sch_symbol.h
@@ -325,7 +325,7 @@ public:
      */
     bool ReplaceInstanceSheetPath( const KIID_PATH& aOldSheetPath, const KIID_PATH& aNewSheetPath );
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     /**
      * Return a bounding box for the symbol body but not the pins or fields.
@@ -335,7 +335,7 @@ public:
     /**
      * Return a bounding box for the symbol body and pins but not the fields.
      */
-    EDA_RECT GetBodyAndPinsBoundingBox() const;
+    BOX2I GetBodyAndPinsBoundingBox() const;
 
 
     //-----<Fields>-----------------------------------------------------------
diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp
index 9073ffb1de..52f3969909 100644
--- a/eeschema/sch_text.cpp
+++ b/eeschema/sch_text.cpp
@@ -313,24 +313,24 @@ void SCH_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
 }
 
 
-const EDA_RECT SCH_TEXT::GetBoundingBox() const
+const BOX2I SCH_TEXT::GetBoundingBox() const
 {
-    BOX2I rect = GetTextBox();
+    BOX2I bbox = GetTextBox();
 
-    if( !GetTextAngle().IsZero() ) // Rotate rect.
+    if( !GetTextAngle().IsZero() ) // Rotate bbox.
     {
-        VECTOR2I pos = rect.GetOrigin();
-        VECTOR2I end = rect.GetEnd();
+        VECTOR2I pos = bbox.GetOrigin();
+        VECTOR2I end = bbox.GetEnd();
 
         RotatePoint( pos, GetTextPos(), GetTextAngle() );
         RotatePoint( end, GetTextPos(), GetTextAngle() );
 
-        rect.SetOrigin( pos );
-        rect.SetEnd( end );
+        bbox.SetOrigin( pos );
+        bbox.SetEnd( end );
     }
 
-    rect.Normalize();
-    return rect;
+    bbox.Normalize();
+    return bbox;
 }
 
 
diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h
index 3d523eb784..c9e40a344e 100644
--- a/eeschema/sch_text.h
+++ b/eeschema/sch_text.h
@@ -165,7 +165,7 @@ public:
 
     void SwapData( SCH_ITEM* aItem ) override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     bool operator<( const SCH_ITEM& aItem ) const override;
 
diff --git a/gerbview/gbr_layout.h b/gerbview/gbr_layout.h
index 15546a3d1a..aa8da5c872 100644
--- a/gerbview/gbr_layout.h
+++ b/gerbview/gbr_layout.h
@@ -70,7 +70,7 @@ public:
      */
     BOX2I ComputeBoundingBox() const;
 
-    const EDA_RECT GetBoundingBox() const override
+    const BOX2I GetBoundingBox() const override
     {
         return ComputeBoundingBox();
     }
diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp
index 98b4292bec..70831d947a 100644
--- a/gerbview/gerber_draw_item.cpp
+++ b/gerbview/gerber_draw_item.cpp
@@ -246,10 +246,10 @@ D_CODE* GERBER_DRAW_ITEM::GetDcodeDescr() const
 }
 
 
-const EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const
+const BOX2I GERBER_DRAW_ITEM::GetBoundingBox() const
 {
     // return a rectangle which is (pos,dim) in nature.  therefore the +1
-    EDA_RECT bbox( m_Start, wxSize( 1, 1 ) );
+    BOX2I   bbox( m_Start, VECTOR2I( 1, 1 ) );
     D_CODE* code = GetDcodeDescr();
 
     // TODO(JE) GERBER_DRAW_ITEM maybe should actually be a number of subclasses.
@@ -260,9 +260,9 @@ const EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const
     {
     case GBR_POLYGON:
     {
-        auto bb = m_Polygon.BBox();
+        BOX2I bb = m_Polygon.BBox();
         bbox.Inflate( bb.GetWidth() / 2, bb.GetHeight() / 2 );
-        bbox.SetOrigin( bb.GetOrigin().x, bb.GetOrigin().y );
+        bbox.SetOrigin( bb.GetOrigin() );
         break;
     }
 
@@ -287,10 +287,7 @@ const EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const
             angle.Normalize();
 
         SHAPE_ARC arc( m_ArcCentre, m_Start, angle );
-        BOX2I arc_bbox = arc.BBox( m_Size.x / 2 );  // m_Size.x is the line thickness
-        bbox.SetOrigin( arc_bbox.GetX(), arc_bbox.GetY() );
-        bbox.SetWidth( arc_bbox.GetWidth() );
-        bbox.SetHeight( arc_bbox.GetHeight() );
+        bbox = arc.BBox( m_Size.x / 2 );  // m_Size.x is the line thickness
         break;
     }
 
@@ -358,16 +355,12 @@ const EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const
                 // So use a temporary polygon
                 SHAPE_POLY_SET poly_shape;
                 ConvertSegmentToPolygon( &poly_shape );
-                BOX2I bb = poly_shape.BBox();
-                bbox.SetSize( bb.GetWidth(), bb.GetHeight() );
-                bbox.SetOrigin( bb.GetOrigin().x, bb.GetOrigin().y );
+                bbox = poly_shape.BBox();
             }
 
             else
             {
-                BOX2I bb = m_Polygon.BBox();
-                bbox.SetSize( bb.GetWidth(), bb.GetHeight() );
-                bbox.SetOrigin( bb.GetOrigin().x, bb.GetOrigin().y );
+                bbox = m_Polygon.BBox();
             }
         }
         else
@@ -380,7 +373,7 @@ const EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const
             int ymin = std::min( m_Start.y, m_End.y ) - radius;
             int xmin = std::min( m_Start.x, m_End.x ) - radius;
 
-            bbox = EDA_RECT( VECTOR2I( xmin, ymin ), VECTOR2I( xmax - xmin + 1, ymax - ymin + 1 ) );
+            bbox = BOX2I( VECTOR2I( xmin, ymin ), VECTOR2I( xmax - xmin + 1, ymax - ymin + 1 ) );
         }
 
         break;
diff --git a/gerbview/gerber_draw_item.h b/gerbview/gerber_draw_item.h
index 0ac492c7d5..6565bfde9d 100644
--- a/gerbview/gerber_draw_item.h
+++ b/gerbview/gerber_draw_item.h
@@ -151,7 +151,7 @@ public:
      */
     D_CODE* GetDcodeDescr() const;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     void Print( wxDC* aDC, const VECTOR2I& aOffset, GBR_DISPLAY_OPTIONS* aOptions );
 
diff --git a/gerbview/tools/gerbview_selection.cpp b/gerbview/tools/gerbview_selection.cpp
index b4180fbbe7..78afc43539 100644
--- a/gerbview/tools/gerbview_selection.cpp
+++ b/gerbview/tools/gerbview_selection.cpp
@@ -33,12 +33,10 @@ VECTOR2I GERBVIEW_SELECTION::GetCenter() const
     }
     else
     {
-        EDA_RECT bbox = Front()->GetBoundingBox();
-        auto i = m_items.begin();
-        ++i;
+        BOX2I bbox;
 
-        for( ; i != m_items.end(); ++i )
-            bbox.Merge( (*i)->GetBoundingBox() );
+        for( EDA_ITEM* item : m_items )
+            bbox.Merge( item->GetBoundingBox() );
 
         centre = bbox.Centre();
     }
@@ -49,23 +47,19 @@ VECTOR2I GERBVIEW_SELECTION::GetCenter() const
 
 const BOX2I GERBVIEW_SELECTION::ViewBBox() const
 {
-    EDA_RECT eda_bbox;
+    BOX2I bbox;
 
     if( Size() == 1 )
     {
-        eda_bbox = Front()->GetBoundingBox();
+        bbox = Front()->GetBoundingBox();
     }
     else if( Size() > 1 )
     {
-        eda_bbox = Front()->GetBoundingBox();
-        auto i = m_items.begin();
-        ++i;
-
-        for( ; i != m_items.end(); ++i )
-            eda_bbox.Merge( (*i)->GetBoundingBox() );
+        for( EDA_ITEM* item : m_items )
+            bbox.Merge( item->GetBoundingBox() );
     }
 
-    return BOX2I( eda_bbox.GetOrigin(), eda_bbox.GetSize() );
+    return bbox;
 }
 
 
diff --git a/include/bitmap_base.h b/include/bitmap_base.h
index 852425ef18..3c18dcf969 100644
--- a/include/bitmap_base.h
+++ b/include/bitmap_base.h
@@ -116,7 +116,7 @@ public:
     /**
      * @return the actual size (in user units, not in pixels) of the image
      */
-    wxSize GetSize() const;
+    VECTOR2I GetSize() const;
 
     /**
      * @return the size in pixels of the image
@@ -144,7 +144,7 @@ public:
      * and the units should be in the pcb or schematic coordinate system.  It is OK to
      * overestimate the size by a few counts.
      */
-    const EDA_RECT GetBoundingBox() const;
+    const BOX2I GetBoundingBox() const;
 
     void DrawBitmap( wxDC* aDC, const VECTOR2I& aPos );
 
diff --git a/include/drawing_sheet/ds_draw_item.h b/include/drawing_sheet/ds_draw_item.h
index 81d21f979d..8e9700bc16 100644
--- a/include/drawing_sheet/ds_draw_item.h
+++ b/include/drawing_sheet/ds_draw_item.h
@@ -86,7 +86,7 @@ public:
 
     // Derived types must define GetBoundingBox() as a minimum, and can then override the
     // two HitTest() functions if they need something more specific.
-    const EDA_RECT GetBoundingBox() const override = 0;
+    const BOX2I GetBoundingBox() const override = 0;
 
     bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
     {
@@ -138,7 +138,7 @@ public:
     VECTOR2I GetPosition() const override { return GetStart(); }
     void     SetPosition( const VECTOR2I& aPos ) override { SetStart( aPos ); }
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
     bool           HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
 
     void PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
@@ -171,7 +171,7 @@ public:
     VECTOR2I        GetPosition() const override { return m_pos; }
     void            SetPosition( const VECTOR2I& aPos ) override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
     bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
@@ -227,7 +227,7 @@ public:
 
     void PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
     bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
@@ -276,7 +276,7 @@ public:
 
     void PrintWsItem( const RENDER_SETTINGS* , const VECTOR2I& ) override { /* do nothing */ }
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
     bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override { return false; }
 
     wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
@@ -324,7 +324,7 @@ public:
     VECTOR2I GetPosition() const override { return GetTextPos(); }
     void     SetPosition( const VECTOR2I& aPos ) override { SetTextPos( aPos ); }
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
     bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
@@ -360,7 +360,7 @@ public:
 
     bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
     bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
 
diff --git a/include/eda_item.h b/include/eda_item.h
index 262a63554e..11f7556407 100644
--- a/include/eda_item.h
+++ b/include/eda_item.h
@@ -259,7 +259,7 @@ public:
      * object, and the units should be in the pcb or schematic coordinate
      * system.  It is OK to overestimate the size by a few counts.
      */
-    virtual const EDA_RECT GetBoundingBox() const;
+    virtual const BOX2I GetBoundingBox() const;
 
     virtual VECTOR2I GetPosition() const { return VECTOR2I(); }
     virtual void     SetPosition( const VECTOR2I& aPos ){};
diff --git a/include/pcb_group.h b/include/pcb_group.h
index 011d585d7c..d581c155fb 100644
--- a/include/pcb_group.h
+++ b/include/pcb_group.h
@@ -158,7 +158,7 @@ public:
     bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
 
     ///< @copydoc EDA_ITEM::GetBoundingBox
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     ///< @copydoc EDA_ITEM::Visit
     INSPECT_RESULT Visit( INSPECTOR aInspector, void* aTestData,
diff --git a/pagelayout_editor/pl_editor_layout.h b/pagelayout_editor/pl_editor_layout.h
index 8a8f114c40..8bce30cd76 100644
--- a/pagelayout_editor/pl_editor_layout.h
+++ b/pagelayout_editor/pl_editor_layout.h
@@ -70,7 +70,7 @@ public:
      * Called soon after ComputeBoundingBox() to return the same EDA_RECT,
      * as long as the CLASS_PL_EDITOR_LAYOUT has not changed.
      */
-    const EDA_RECT GetBoundingBox() const { return m_boundingBox; }
+    const BOX2I GetBoundingBox() const { return m_boundingBox; }
 
     void SetBoundingBox( const EDA_RECT& aBox ) { m_boundingBox = aBox; }
 
diff --git a/pcbnew/autorouter/ar_autoplacer.cpp b/pcbnew/autorouter/ar_autoplacer.cpp
index 9f2f69c33a..abcd6283b3 100644
--- a/pcbnew/autorouter/ar_autoplacer.cpp
+++ b/pcbnew/autorouter/ar_autoplacer.cpp
@@ -277,7 +277,7 @@ void AR_AUTOPLACER::addFpBody( const VECTOR2I& aStart, const VECTOR2I& aEnd, LSE
 void AR_AUTOPLACER::addPad( PAD* aPad, int aClearance )
 {
     // Add a polygonal shape (rectangle) to m_fpAreaFront and/or m_fpAreaBack
-    EDA_RECT bbox = aPad->GetBoundingBox();
+    BOX2I bbox = aPad->GetBoundingBox();
     bbox.Inflate( aClearance );
 
     if( aPad->IsOnLayer( F_Cu ) )
@@ -317,7 +317,7 @@ void AR_AUTOPLACER::buildFpAreas( FOOTPRINT* aFootprint, int aFpClearance )
     if( aFootprint->GetLayer() == B_Cu )
         layerMask.set( B_Cu );
 
-    EDA_RECT fpBBox = aFootprint->GetBoundingBox();
+    BOX2I fpBBox = aFootprint->GetBoundingBox();
 
     fpBBox.Inflate( ( m_matrix.m_GridRouting / 2 ) + aFpClearance );
 
@@ -335,9 +335,9 @@ void AR_AUTOPLACER::buildFpAreas( FOOTPRINT* aFootprint, int aFpClearance )
 
 void AR_AUTOPLACER::genModuleOnRoutingMatrix( FOOTPRINT* Module )
 {
-    int         ox, oy, fx, fy;
-    LSET        layerMask;
-    EDA_RECT    fpBBox = Module->GetBoundingBox();
+    int   ox, oy, fx, fy;
+    LSET  layerMask;
+    BOX2I fpBBox = Module->GetBoundingBox();
 
     fpBBox.Inflate( m_matrix.m_GridRouting / 2 );
     ox  = fpBBox.GetX();
diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp
index d8d78d8f22..b2db121305 100644
--- a/pcbnew/board.cpp
+++ b/pcbnew/board.cpp
@@ -1153,7 +1153,7 @@ unsigned BOARD::GetUnconnectedNetCount() const
 
 BOX2I BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
 {
-    BOX2I area;
+    BOX2I bbox;
     LSET  visible = GetVisibleLayers();
     bool  showInvisibleText = IsElementVisible( LAYER_MOD_TEXT_INVISIBLE )
                                       && PgmOrNull() && !PgmOrNull()->m_Printing;
@@ -1168,7 +1168,7 @@ BOX2I BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
             continue;
 
         if( ( item->GetLayerSet() & visible ).any() )
-            area.Merge( item->GetBoundingBox() );
+            bbox.Merge( item->GetBoundingBox() );
     }
 
     // Check footprints
@@ -1182,12 +1182,12 @@ BOX2I BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
             for( const BOARD_ITEM* edge : footprint->GraphicalItems() )
             {
                 if( edge->GetLayer() == Edge_Cuts  && edge->Type() == PCB_FP_SHAPE_T )
-                    area.Merge( edge->GetBoundingBox() );
+                    bbox.Merge( edge->GetBoundingBox() );
             }
         }
         else
         {
-            area.Merge( footprint->GetBoundingBox( true, showInvisibleText ) );
+            bbox.Merge( footprint->GetBoundingBox( true, showInvisibleText ) );
         }
     }
 
@@ -1197,18 +1197,18 @@ BOX2I BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
         for( PCB_TRACK* track : m_tracks )
         {
             if( ( track->GetLayerSet() & visible ).any() )
-                area.Merge( track->GetBoundingBox() );
+                bbox.Merge( track->GetBoundingBox() );
         }
 
         // Check zones
         for( ZONE* aZone : m_zones )
         {
             if( ( aZone->GetLayerSet() & visible ).any() )
-                area.Merge( aZone->GetBoundingBox() );
+                bbox.Merge( aZone->GetBoundingBox() );
         }
     }
 
-    return area;
+    return bbox;
 }
 
 
diff --git a/pcbnew/board.h b/pcbnew/board.h
index b3dec6daf4..b728d5099a 100644
--- a/pcbnew/board.h
+++ b/pcbnew/board.h
@@ -803,7 +803,7 @@ public:
      */
     BOX2I ComputeBoundingBox( bool aBoardEdgesOnly = false ) const;
 
-    const EDA_RECT GetBoundingBox() const override
+    const BOX2I GetBoundingBox() const override
     {
         return ComputeBoundingBox( false );
     }
@@ -817,7 +817,7 @@ public:
      *
      * @return bounding box calculated using exclusively the board edges.
      */
-    const EDA_RECT GetBoardEdgesBoundingBox() const
+    const BOX2I GetBoardEdgesBoundingBox() const
     {
         return ComputeBoundingBox( true );
     }
diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp
index a277f084b3..22aafa1b0b 100644
--- a/pcbnew/board_commit.cpp
+++ b/pcbnew/board_commit.cpp
@@ -133,9 +133,9 @@ void BOARD_COMMIT::dirtyIntersectingZones( BOARD_ITEM* item )
     }
     else
     {
-        BOARD*   board = static_cast<BOARD*>( m_toolMgr->GetModel() );
-        EDA_RECT bbox = item->GetBoundingBox();
-        LSET     layers = item->GetLayerSet();
+        BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
+        BOX2I  bbox = item->GetBoundingBox();
+        LSET   layers = item->GetLayerSet();
 
         if( layers.test( Edge_Cuts ) || layers.test( Margin ) )
             layers = LSET::PhysicalLayersMask();
diff --git a/pcbnew/connectivity/connectivity_items.h b/pcbnew/connectivity/connectivity_items.h
index b9638d2e05..7f92f6e13e 100644
--- a/pcbnew/connectivity/connectivity_items.h
+++ b/pcbnew/connectivity/connectivity_items.h
@@ -218,10 +218,7 @@ public:
     const BOX2I& BBox()
     {
         if( m_dirty && m_valid )
-        {
-            EDA_RECT box = m_parent->GetBoundingBox();
-            m_bbox = BOX2I( box.GetPosition(), box.GetSize() );
-        }
+            m_bbox = m_parent->GetBoundingBox();
 
         return m_bbox;
     }
diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp
index 8962110ca0..912a1926c9 100644
--- a/pcbnew/cross-probing.cpp
+++ b/pcbnew/cross-probing.cpp
@@ -164,7 +164,7 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
         return;
     }
 
-    BOX2I bbox = { { 0, 0 }, { 0, 0 } };
+    BOX2I bbox;
 
     if( footprint )
     {
@@ -191,16 +191,11 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
         pcb->HighLightON();
 
         auto merge_area =
-            [netcode, &bbox]( BOARD_CONNECTED_ITEM* aItem )
-            {
-            if( aItem->GetNetCode() == netcode )
-            {
-                if( bbox.GetWidth() == 0 )
-                    bbox = aItem->GetBoundingBox();
-                else
-                    bbox.Merge( aItem->GetBoundingBox() );
-            }
-        };
+                [netcode, &bbox]( BOARD_CONNECTED_ITEM* aItem )
+                {
+                    if( aItem->GetNetCode() == netcode )
+                        bbox.Merge( aItem->GetBoundingBox() );
+                };
 
         if( crossProbingSettings.center_on_items )
         {
diff --git a/pcbnew/drc/drc_rtree.h b/pcbnew/drc/drc_rtree.h
index bed37ed94e..264f56dcd2 100644
--- a/pcbnew/drc/drc_rtree.h
+++ b/pcbnew/drc/drc_rtree.h
@@ -223,7 +223,7 @@ public:
         // shapes
         std::unordered_map<BOARD_ITEM*, bool> filterResults;
 
-        EDA_RECT box = aRefItem->GetBoundingBox();
+        BOX2I box = aRefItem->GetBoundingBox();
         box.Inflate( aClearance );
 
         int min[2] = { box.GetX(),     box.GetY() };
diff --git a/pcbnew/drc/drc_test_provider_copper_clearance.cpp b/pcbnew/drc/drc_test_provider_copper_clearance.cpp
index 5ca6d0cf5f..881849e0f3 100644
--- a/pcbnew/drc/drc_test_provider_copper_clearance.cpp
+++ b/pcbnew/drc/drc_test_provider_copper_clearance.cpp
@@ -298,8 +298,8 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone( BOARD_ITEM* aItem,
             return;
     }
 
-    EDA_RECT itemBBox = aItem->GetBoundingBox();
-    EDA_RECT worstCaseBBox = itemBBox;
+    BOX2I itemBBox = aItem->GetBoundingBox();
+    BOX2I worstCaseBBox = itemBBox;
 
     worstCaseBBox.Inflate( m_board->m_DRCMaxClearance );
 
diff --git a/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp b/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp
index 9250ea1b00..811b75fa1e 100644
--- a/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp
+++ b/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp
@@ -183,7 +183,7 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances()
         frontA_worstCaseBBox.Inflate( m_largestCourtyardClearance );
         backA_worstCaseBBox.Inflate( m_largestCourtyardClearance );
 
-        EDA_RECT fpA_bbox = fpA->GetBoundingBox();
+        BOX2I fpA_bbox = fpA->GetBoundingBox();
 
         for( auto itB = itA + 1; itB != m_board->Footprints().end(); itB++ )
         {
@@ -205,7 +205,7 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances()
             frontB_worstCaseBBox.Inflate( m_largestCourtyardClearance );
             backB_worstCaseBBox.Inflate( m_largestCourtyardClearance );
 
-            EDA_RECT       fpB_bbox = fpB->GetBoundingBox();
+            BOX2I          fpB_bbox = fpB->GetBoundingBox();
             DRC_CONSTRAINT constraint;
             int            clearance;
             int            actual;
diff --git a/pcbnew/drc/drc_test_provider_physical_clearance.cpp b/pcbnew/drc/drc_test_provider_physical_clearance.cpp
index e5121b5fae..14c6c5341c 100644
--- a/pcbnew/drc/drc_test_provider_physical_clearance.cpp
+++ b/pcbnew/drc/drc_test_provider_physical_clearance.cpp
@@ -701,8 +701,8 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aIt
         if( !zone->GetLayerSet().test( aLayer ) )
             continue;
 
-        EDA_RECT itemBBox = aItem->GetBoundingBox();
-        EDA_RECT worstCaseBBox = itemBBox;
+        BOX2I itemBBox = aItem->GetBoundingBox();
+        BOX2I worstCaseBBox = itemBBox;
 
         worstCaseBBox.Inflate( m_board->m_DRCMaxClearance );
 
diff --git a/pcbnew/drc/drc_test_provider_solder_mask.cpp b/pcbnew/drc/drc_test_provider_solder_mask.cpp
index cf6696036e..1e427a65ca 100644
--- a/pcbnew/drc/drc_test_provider_solder_mask.cpp
+++ b/pcbnew/drc/drc_test_provider_solder_mask.cpp
@@ -260,7 +260,7 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance()
                     if( !item->IsOnLayer( layer ) )
                         continue;
 
-                    EDA_RECT       itemBBox = item->GetBoundingBox();
+                    BOX2I          itemBBox = item->GetBoundingBox();
                     DRC_CONSTRAINT constraint = m_drcEngine->EvalRules( SILK_CLEARANCE_CONSTRAINT,
                                                                         item, nullptr, layer );
                     int            clearance = constraint.GetValue().Min();
@@ -662,7 +662,7 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::testMaskBridges()
                 if( !reportProgress( ii++, count, progressDelta ) )
                     return false;
 
-                EDA_RECT itemBBox = item->GetBoundingBox();
+                BOX2I itemBBox = item->GetBoundingBox();
 
                 if( item->IsOnLayer( F_Mask ) && !isNullAperture( item ) )
                 {
diff --git a/pcbnew/drc/drc_test_provider_zone_connections.cpp b/pcbnew/drc/drc_test_provider_zone_connections.cpp
index f9b2603561..fbaed9865f 100644
--- a/pcbnew/drc/drc_test_provider_zone_connections.cpp
+++ b/pcbnew/drc/drc_test_provider_zone_connections.cpp
@@ -99,7 +99,7 @@ void DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer( ZONE* aZone, PCB_LAYER_I
             if( pad->GetNetCode() != aZone->GetNetCode() || pad->GetNetCode() <= 0 )
                 continue;
 
-            EDA_RECT item_bbox = pad->GetBoundingBox();
+            BOX2I item_bbox = pad->GetBoundingBox();
 
             if( !item_bbox.Intersects( aZone->GetCachedBoundingBox() ) )
                 continue;
diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp
index e793a98ea3..8f95f19e92 100644
--- a/pcbnew/footprint.cpp
+++ b/pcbnew/footprint.cpp
@@ -734,7 +734,7 @@ wxString FOOTPRINT::GetTypeName() const
 
 BOX2I FOOTPRINT::GetFpPadsLocalBbox() const
 {
-    BOX2I area;
+    BOX2I bbox;
 
     // We want the bounding box of the footprint pads at rot 0, not flipped
     // Create such a image:
@@ -747,13 +747,13 @@ BOX2I FOOTPRINT::GetFpPadsLocalBbox() const
         dummy.Flip( VECTOR2I( 0, 0 ), false );
 
     for( PAD* pad : dummy.Pads() )
-        area.Merge( pad->GetBoundingBox() );
+        bbox.Merge( pad->GetBoundingBox() );
 
-    return area;
+    return bbox;
 }
 
 
-const EDA_RECT FOOTPRINT::GetBoundingBox() const
+const BOX2I FOOTPRINT::GetBoundingBox() const
 {
     return GetBoundingBox( true, true );
 }
@@ -783,11 +783,8 @@ const EDA_RECT FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisi
         }
     }
 
-    EDA_RECT area;
-
-    area.SetOrigin( m_pos );
-    area.SetEnd( m_pos );
-    area.Inflate( Millimeter2iu( 0.25 ) );   // Give a min size to the area
+    BOX2I bbox( m_pos );
+    bbox.Inflate( Millimeter2iu( 0.25 ) );   // Give a min size to the bbox
 
     for( BOARD_ITEM* item : m_drawings )
     {
@@ -803,14 +800,14 @@ const EDA_RECT FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisi
         if( item->Type() == PCB_FP_TEXT_T )
             continue;
 
-        area.Merge( item->GetBoundingBox() );
+        bbox.Merge( item->GetBoundingBox() );
     }
 
     for( PAD* pad : m_pads )
-        area.Merge( pad->GetBoundingBox() );
+        bbox.Merge( pad->GetBoundingBox() );
 
     for( FP_ZONE* zone : m_fp_zones )
-        area.Merge( zone->GetBoundingBox() );
+        bbox.Merge( zone->GetBoundingBox() );
 
     bool noDrawItems = ( m_drawings.empty() && m_pads.empty() && m_fp_zones.empty() );
 
@@ -825,7 +822,7 @@ const EDA_RECT FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisi
             // Only FP_TEXT items are independently selectable; FP_TEXTBOX items go in with
             // other graphic items above.
             if( item->Type() == PCB_FP_TEXT_T )
-                area.Merge( item->GetBoundingBox() );
+                bbox.Merge( item->GetBoundingBox() );
         }
 
         // This can be further optimized when aIncludeInvisibleText is true, but currently
@@ -853,14 +850,14 @@ const EDA_RECT FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisi
                 || aIncludeInvisibleText
                 || noDrawItems )
         {
-            area.Merge( m_value->GetBoundingBox() );
+            bbox.Merge( m_value->GetBoundingBox() );
         }
 
         if( ( m_reference->IsVisible() && refLayerIsVisible )
                 || aIncludeInvisibleText
                 || noDrawItems )
         {
-            area.Merge( m_reference->GetBoundingBox() );
+            bbox.Merge( m_reference->GetBoundingBox() );
         }
     }
 
@@ -869,21 +866,21 @@ const EDA_RECT FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisi
         if( ( aIncludeText && aIncludeInvisibleText ) || noDrawItems )
         {
             m_boundingBoxCacheTimeStamp = board->GetTimeStamp();
-            m_cachedBoundingBox = area;
+            m_cachedBoundingBox = bbox;
         }
         else if( aIncludeText )
         {
             m_visibleBBoxCacheTimeStamp = board->GetTimeStamp();
-            m_cachedVisibleBBox = area;
+            m_cachedVisibleBBox = bbox;
         }
         else
         {
             m_textExcludedBBoxCacheTimeStamp = board->GetTimeStamp();
-            m_cachedTextExcludedBBox = area;
+            m_cachedTextExcludedBBox = bbox;
         }
     }
 
-    return area;
+    return bbox;
 }
 
 
diff --git a/pcbnew/footprint.h b/pcbnew/footprint.h
index d1f884c5b9..f4d8a15817 100644
--- a/pcbnew/footprint.h
+++ b/pcbnew/footprint.h
@@ -169,7 +169,7 @@ public:
     SHAPE_POLY_SET GetBoundingHull() const;
 
     // Virtual function
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
     const EDA_RECT GetBoundingBox( bool aIncludeText, bool aIncludeInvisibleText ) const;
 
     PADS& Pads()             { return m_pads; }
diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp
index 789c552367..f358b7765b 100644
--- a/pcbnew/fp_text.cpp
+++ b/pcbnew/fp_text.cpp
@@ -219,15 +219,15 @@ void FP_TEXT::SetLocalCoord()
     }
 }
 
-const EDA_RECT FP_TEXT::GetBoundingBox() const
+const BOX2I FP_TEXT::GetBoundingBox() const
 {
     EDA_ANGLE angle = GetDrawRotation();
-    BOX2I     text_area = GetTextBox();
+    BOX2I     bbox = GetTextBox();
 
     if( !angle.IsZero() )
-        text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle );
+        bbox = bbox.GetBoundingBoxRotated( GetTextPos(), angle );
 
-    return text_area;
+    return bbox;
 }
 
 
diff --git a/pcbnew/fp_text.h b/pcbnew/fp_text.h
index e024b25c3c..d4d2cc8e12 100644
--- a/pcbnew/fp_text.h
+++ b/pcbnew/fp_text.h
@@ -137,7 +137,7 @@ public:
     virtual EDA_ANGLE GetDrawRotation() const override;
 
     // Virtual function
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     ///< Set absolute coordinates.
     void SetDrawCoord();
diff --git a/pcbnew/netinfo.h b/pcbnew/netinfo.h
index 639d1f5f12..61efbc91f8 100644
--- a/pcbnew/netinfo.h
+++ b/pcbnew/netinfo.h
@@ -85,7 +85,7 @@ public:
     }
 #endif
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     VECTOR2I GetPosition() const override
     {
diff --git a/pcbnew/netinfo_item.cpp b/pcbnew/netinfo_item.cpp
index a3b0d96143..cfb46a3022 100644
--- a/pcbnew/netinfo_item.cpp
+++ b/pcbnew/netinfo_item.cpp
@@ -149,10 +149,10 @@ bool NETINFO_ITEM::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
 }
 
 
-const EDA_RECT NETINFO_ITEM::GetBoundingBox() const
+const BOX2I NETINFO_ITEM::GetBoundingBox() const
 {
     std::shared_ptr<CONNECTIVITY_DATA> conn = GetBoard()->GetConnectivity();
-    EDA_RECT                           bbox;
+    BOX2I                              bbox;
 
     for( BOARD_ITEM* item : conn->GetNetItems( m_netCode, { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T,
                                                             PCB_ZONE_T, PCB_PAD_T } ) )
diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp
index a043c015a7..71dc4f0f70 100644
--- a/pcbnew/pad.cpp
+++ b/pcbnew/pad.cpp
@@ -539,8 +539,7 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const
         }
     }
 
-    BOX2I bbox = m_effectiveShape->BBox();
-    m_effectiveBoundingBox = EDA_RECT( bbox );
+    m_effectiveBoundingBox = m_effectiveShape->BBox();
 
     // Hole shape
     VECTOR2I half_size = m_drill / 2;
@@ -551,8 +550,7 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const
 
     m_effectiveHoleShape = std::make_shared<SHAPE_SEGMENT>( m_pos - half_len, m_pos + half_len,
                                                             half_width * 2 );
-    bbox = m_effectiveHoleShape->BBox();
-    m_effectiveBoundingBox.Merge( EDA_RECT( bbox ) );
+    m_effectiveBoundingBox.Merge( m_effectiveHoleShape->BBox() );
 
     // All done
     m_shapesDirty = false;
@@ -598,7 +596,7 @@ void PAD::BuildEffectivePolygon() const
 }
 
 
-const EDA_RECT PAD::GetBoundingBox() const
+const BOX2I PAD::GetBoundingBox() const
 {
     if( m_shapesDirty )
         BuildEffectiveShapes( UNDEFINED_LAYER );
diff --git a/pcbnew/pad.h b/pcbnew/pad.h
index d28acc01ca..907b6b6c8b 100644
--- a/pcbnew/pad.h
+++ b/pcbnew/pad.h
@@ -621,7 +621,7 @@ public:
     /**
      * The bounding box is cached, so this will be efficient most of the time.
      */
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     ///< Set absolute coordinates.
     void SetDrawCoord();
@@ -716,7 +716,7 @@ private:
     // Must be set to true to force rebuild shapes to draw (after geometry change for instance)
     mutable bool                              m_shapesDirty;
     mutable std::mutex                        m_shapesBuildingLock;
-    mutable EDA_RECT                          m_effectiveBoundingBox;
+    mutable BOX2I                             m_effectiveBoundingBox;
     mutable std::shared_ptr<SHAPE_COMPOUND>   m_effectiveShape;
     mutable std::shared_ptr<SHAPE_SEGMENT>    m_effectiveHoleShape;
 
diff --git a/pcbnew/pcb_bitmap.cpp b/pcbnew/pcb_bitmap.cpp
index c014cd103e..9501139901 100644
--- a/pcbnew/pcb_bitmap.cpp
+++ b/pcbnew/pcb_bitmap.cpp
@@ -120,13 +120,13 @@ double PCB_BITMAP::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
 }
 
 
-const EDA_RECT PCB_BITMAP::GetBoundingBox() const
+const BOX2I PCB_BITMAP::GetBoundingBox() const
 {
-    // Bitmaps are center origin, EDA_RECTs need top-left origin
+    // Bitmaps are center origin, BOX2Is need top-left origin
     VECTOR2I size = m_image->GetSize();
     VECTOR2I topLeft = { m_pos.x - size.x / 2, m_pos.y - size.y / 2 };
 
-    return EDA_RECT( topLeft, size );
+    return BOX2I( topLeft, size );
 }
 
 
diff --git a/pcbnew/pcb_bitmap.h b/pcbnew/pcb_bitmap.h
index 7e1857e96d..a3cf8728cd 100644
--- a/pcbnew/pcb_bitmap.h
+++ b/pcbnew/pcb_bitmap.h
@@ -80,7 +80,7 @@ public:
 
     double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
                                               FLASHING aFlash = FLASHING::DEFAULT ) const override;
diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp
index eeba1f2c71..94e34def5d 100644
--- a/pcbnew/pcb_dimension.cpp
+++ b/pcbnew/pcb_dimension.cpp
@@ -422,10 +422,10 @@ bool PCB_DIMENSION_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aA
 }
 
 
-const EDA_RECT PCB_DIMENSION_BASE::GetBoundingBox() const
+const BOX2I PCB_DIMENSION_BASE::GetBoundingBox() const
 {
-    EDA_RECT    bBox;
-    int         xmin, xmax, ymin, ymax;
+    BOX2I bBox;
+    int   xmin, xmax, ymin, ymax;
 
     bBox    = m_text.GetTextBox();
     xmin    = bBox.GetX();
@@ -1260,7 +1260,7 @@ BITMAPS PCB_DIM_CENTER::GetMenuImage() const
 }
 
 
-const EDA_RECT PCB_DIM_CENTER::GetBoundingBox() const
+const BOX2I PCB_DIM_CENTER::GetBoundingBox() const
 {
     int halfWidth = VECTOR2I( m_end - m_start ).x + ( m_lineThickness / 2.0 );
 
diff --git a/pcbnew/pcb_dimension.h b/pcbnew/pcb_dimension.h
index ffa2b6268b..199aef5253 100644
--- a/pcbnew/pcb_dimension.h
+++ b/pcbnew/pcb_dimension.h
@@ -240,7 +240,7 @@ public:
     bool HitTest( const VECTOR2I& aPosition, int aAccuracy ) const override;
     bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer,
             FLASHING aFlash = FLASHING::DEFAULT ) const override;
@@ -609,7 +609,7 @@ public:
         return wxT( "PCB_DIM_CENTER" );
     }
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     const BOX2I ViewBBox() const override;
 
diff --git a/pcbnew/pcb_expr_evaluator.cpp b/pcbnew/pcb_expr_evaluator.cpp
index 5a909444ef..4a051f4cf1 100644
--- a/pcbnew/pcb_expr_evaluator.cpp
+++ b/pcbnew/pcb_expr_evaluator.cpp
@@ -621,7 +621,7 @@ static void intersectsAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
             {
                 BOARD*       board = item->GetBoard();
                 PCB_LAYER_ID layer = context->GetLayer();
-                EDA_RECT     itemBBox;
+                BOX2I        itemBBox;
 
                 if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
                     itemBBox = static_cast<ZONE*>( item )->GetCachedBoundingBox();
@@ -689,7 +689,7 @@ static void enclosedByAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
                 BOARD*       board = item->GetBoard();
                 int          maxError = board->GetDesignSettings().m_MaxError;
                 PCB_LAYER_ID layer = context->GetLayer();
-                EDA_RECT     itemBBox;
+                BOX2I        itemBBox;
 
                 if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
                     itemBBox = static_cast<ZONE*>( item )->GetCachedBoundingBox();
diff --git a/pcbnew/pcb_group.cpp b/pcbnew/pcb_group.cpp
index 32735f8fe9..1cb2a117d5 100644
--- a/pcbnew/pcb_group.cpp
+++ b/pcbnew/pcb_group.cpp
@@ -220,16 +220,16 @@ bool PCB_GROUP::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
 }
 
 
-const EDA_RECT PCB_GROUP::GetBoundingBox() const
+const BOX2I PCB_GROUP::GetBoundingBox() const
 {
-    EDA_RECT area;
+    BOX2I bbox;
 
     for( BOARD_ITEM* item : m_items )
-        area.Merge( item->GetBoundingBox() );
+        bbox.Merge( item->GetBoundingBox() );
 
-    area.Inflate( Millimeter2iu( 0.25 ) ); // Give a min size to the area
+    bbox.Inflate( Millimeter2iu( 0.25 ) ); // Give a min size to the bbox
 
-    return area;
+    return bbox;
 }
 
 
diff --git a/pcbnew/pcb_marker.cpp b/pcbnew/pcb_marker.cpp
index 0cad95879b..807c7edb42 100644
--- a/pcbnew/pcb_marker.cpp
+++ b/pcbnew/pcb_marker.cpp
@@ -299,7 +299,7 @@ void PCB_MARKER::SetZoom( double aZoomFactor )
 }
 
 
-const EDA_RECT PCB_MARKER::GetBoundingBox() const
+const BOX2I PCB_MARKER::GetBoundingBox() const
 {
     return GetBoundingBoxMarker();
 }
diff --git a/pcbnew/pcb_marker.h b/pcbnew/pcb_marker.h
index 681c7f4e9e..7fdc12b4d3 100644
--- a/pcbnew/pcb_marker.h
+++ b/pcbnew/pcb_marker.h
@@ -106,7 +106,7 @@ public:
 
     const BOX2I ViewBBox() const override;
 
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     void ViewGetLayers( int aLayers[], int& aCount ) const override;
 
diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp
index 817e716187..8bb7717304 100644
--- a/pcbnew/pcb_painter.cpp
+++ b/pcbnew/pcb_painter.cpp
@@ -568,7 +568,8 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
     if( m_pcbSettings.GetDrawBoundingBoxes() )
     {
         // Show bounding boxes of painted objects for debugging.
-        EDA_RECT box = item->GetBoundingBox();
+        BOX2I box = item->GetBoundingBox();
+
         m_gal->SetIsFill( false );
         m_gal->SetIsStroke( true );
 
@@ -1017,7 +1018,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
         if( netname.IsEmpty() && padNumber.IsEmpty() )
             return;
 
-        EDA_RECT padBBox = aPad->GetBoundingBox();
+        BOX2I    padBBox = aPad->GetBoundingBox();
         VECTOR2D position = padBBox.Centre();
         VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
 
@@ -2142,9 +2143,10 @@ void PCB_PAINTER::draw( const PCB_GROUP* aGroup, int aLayer )
 
         const COLOR4D color = m_pcbSettings.GetColor( aGroup, LAYER_ANCHOR );
 
-        EDA_RECT bbox = aGroup->GetBoundingBox();
         m_gal->SetStrokeColor( color );
         m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth * 2.0f );
+
+        BOX2I    bbox = aGroup->GetBoundingBox();
         VECTOR2I topLeft = bbox.GetPosition();
         VECTOR2I width = VECTOR2I( bbox.GetWidth(), 0 );
         VECTOR2I height = VECTOR2I( 0, bbox.GetHeight() );
diff --git a/pcbnew/pcb_shape.h b/pcbnew/pcb_shape.h
index 3c72266aa4..a06d47dc56 100644
--- a/pcbnew/pcb_shape.h
+++ b/pcbnew/pcb_shape.h
@@ -120,7 +120,7 @@ public:
 
     void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
 
-    const EDA_RECT GetBoundingBox() const override { return getBoundingBox(); }
+    const BOX2I GetBoundingBox() const override { return getBoundingBox(); }
 
     bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
     {
diff --git a/pcbnew/pcb_target.cpp b/pcbnew/pcb_target.cpp
index 1b1e164a4c..9605537f0a 100644
--- a/pcbnew/pcb_target.cpp
+++ b/pcbnew/pcb_target.cpp
@@ -101,7 +101,7 @@ void PCB_TARGET::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
 }
 
 
-const EDA_RECT PCB_TARGET::GetBoundingBox() const
+const BOX2I PCB_TARGET::GetBoundingBox() const
 {
     EDA_RECT bBox;
     bBox.SetX( m_pos.x - m_size / 2 );
diff --git a/pcbnew/pcb_target.h b/pcbnew/pcb_target.h
index 9190c2407e..ac27a5e964 100644
--- a/pcbnew/pcb_target.h
+++ b/pcbnew/pcb_target.h
@@ -82,7 +82,7 @@ public:
     bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
 
     // Virtual function
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer,
             FLASHING aFlash = FLASHING::DEFAULT ) const override;
diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp
index 1f3e3c72b0..f6c4628ddc 100644
--- a/pcbnew/pcb_text.cpp
+++ b/pcbnew/pcb_text.cpp
@@ -157,7 +157,7 @@ int PCB_TEXT::getKnockoutMargin() const
 }
 
 
-const EDA_RECT PCB_TEXT::GetBoundingBox() const
+const BOX2I PCB_TEXT::GetBoundingBox() const
 {
     BOX2I rect = GetTextBox();
 
diff --git a/pcbnew/pcb_text.h b/pcbnew/pcb_text.h
index 7f6f3ff275..6ad608076a 100644
--- a/pcbnew/pcb_text.h
+++ b/pcbnew/pcb_text.h
@@ -144,7 +144,7 @@ public:
     double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
 
     // Virtual function
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     EDA_ITEM* Clone() const override;
 
diff --git a/pcbnew/pcb_track.cpp b/pcbnew/pcb_track.cpp
index 4298bc8b17..686dfc9798 100644
--- a/pcbnew/pcb_track.cpp
+++ b/pcbnew/pcb_track.cpp
@@ -228,7 +228,7 @@ EDA_ITEM_FLAGS PCB_TRACK::IsPointOnEnds( const VECTOR2I& point, int min_dist ) c
 }
 
 
-const EDA_RECT PCB_TRACK::GetBoundingBox() const
+const BOX2I PCB_TRACK::GetBoundingBox() const
 {
     // end of track is round, this is its radius, rounded up
     int radius = ( m_Width + 1 ) / 2;
@@ -245,7 +245,7 @@ const EDA_RECT PCB_TRACK::GetBoundingBox() const
     else if( Type() == PCB_ARC_T )
     {
         std::shared_ptr<SHAPE> arc = GetEffectiveShape();
-        auto bbox = arc->BBox();
+        BOX2I bbox = arc->BBox();
 
         xmin = bbox.GetLeft();
         xmax = bbox.GetRight();
@@ -268,7 +268,7 @@ const EDA_RECT PCB_TRACK::GetBoundingBox() const
     xmin -= radius;
 
     // return a rectangle which is [pos,dim) in nature.  therefore the +1
-    EDA_RECT ret( VECTOR2I( xmin, ymin ), VECTOR2I( xmax - xmin + 1, ymax - ymin + 1 ) );
+    BOX2I ret( VECTOR2I( xmin, ymin ), VECTOR2I( xmax - xmin + 1, ymax - ymin + 1 ) );
 
     return ret;
 }
diff --git a/pcbnew/pcb_track.h b/pcbnew/pcb_track.h
index 56526347e5..3a8fce47f0 100644
--- a/pcbnew/pcb_track.h
+++ b/pcbnew/pcb_track.h
@@ -124,7 +124,7 @@ public:
     }
 
     // Virtual function
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     /**
      * Function GetLength
diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp
index 1a72a61aab..742b9d02ec 100644
--- a/pcbnew/zone.cpp
+++ b/pcbnew/zone.cpp
@@ -318,11 +318,9 @@ bool ZONE::IsOnLayer( PCB_LAYER_ID aLayer ) const
 }
 
 
-const EDA_RECT ZONE::GetBoundingBox() const
+const BOX2I ZONE::GetBoundingBox() const
 {
-    BOX2I bb = m_Poly->BBox();
-
-    return bb;
+    return m_Poly->BBox();
 }
 
 
diff --git a/pcbnew/zone.h b/pcbnew/zone.h
index 79ee7122da..126e85ef36 100644
--- a/pcbnew/zone.h
+++ b/pcbnew/zone.h
@@ -124,9 +124,9 @@ public:
     }
 
     /**
-     * @return an EDA_RECT that is the bounding box of the zone outline.
+     * @return the bounding box of the zone outline.
      */
-    const EDA_RECT GetBoundingBox() const override;
+    const BOX2I GetBoundingBox() const override;
 
     /**
      * ONLY TO BE USED BY CLIENTS WHICH SET UP THE CACHE!
diff --git a/qa/unittests/common/test_bitmap_base.cpp b/qa/unittests/common/test_bitmap_base.cpp
index c39f126231..bd84dca361 100644
--- a/qa/unittests/common/test_bitmap_base.cpp
+++ b/qa/unittests/common/test_bitmap_base.cpp
@@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE( BasicProps )
     BOOST_CHECK( img.GetSizePixels() == size_4tile );
     BOOST_CHECK( img.GetSize() == size_4tile * 10 );
 
-    const EDA_RECT bb = img.GetBoundingBox();
+    const BOX2I bb = img.GetBoundingBox();
     BOOST_CHECK( bb.GetPosition() == wxPoint( -40, -40 ) );
     BOOST_CHECK( bb.GetEnd() == wxPoint( 40, 40 ) );
 }