From 7c46cb0a05a0f71fe1d11b6272616c00eff44963 Mon Sep 17 00:00:00 2001
From: Jeff Young <jeff@rokeby.ie>
Date: Tue, 6 Oct 2020 17:38:24 +0100
Subject: [PATCH] Make GetCenter() return the boundingbox center by default.

Leaves pads and markers returning the position.

Fixes https://gitlab.com/kicad/code/kicad/issues/1924
---
 include/class_board_item.h | 8 +++++---
 pcbnew/class_marker_pcb.h  | 5 +++++
 pcbnew/class_pad.h         | 2 ++
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/class_board_item.h b/include/class_board_item.h
index c910b597be..6d0be2d11e 100644
--- a/include/class_board_item.h
+++ b/include/class_board_item.h
@@ -120,12 +120,14 @@ public:
     /**
      * Function GetCenter()
      *
-     * This defaults to the same point as returned by GetPosition(), unless
-     * overridden
+     * This defaults to the center of the bounding box if not overridden.
      *
      * @return centre point of the item
      */
-    virtual wxPoint GetCenter() const { return GetPosition(); }
+    virtual wxPoint GetCenter() const
+    {
+        return GetBoundingBox().GetCenter();
+    }
 
     void SetX( int aX )
     {
diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h
index c596675de7..2f451becfc 100644
--- a/pcbnew/class_marker_pcb.h
+++ b/pcbnew/class_marker_pcb.h
@@ -72,6 +72,11 @@ public:
     wxPoint GetPosition() const override { return m_Pos; }
     void SetPosition( const wxPoint& aPos ) override { m_Pos = aPos; }
 
+    wxPoint GetCenter() const override
+    {
+        return GetPosition();
+    }
+
     bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override
     {
         return HitTestMarker( aPosition, aAccuracy );
diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h
index feb8194996..195e73f1e8 100644
--- a/pcbnew/class_pad.h
+++ b/pcbnew/class_pad.h
@@ -239,6 +239,8 @@ public:
     void SetOffset( const wxPoint& aOffset )    { m_offset = aOffset; m_shapesDirty = true; }
     const wxPoint& GetOffset() const            { return m_offset; }
 
+    wxPoint GetCenter() const override          { return GetPosition(); }
+
     /**
      * Has meaning only for custom shape pads.
      * add a free shape to the shape list.