← Back to team overview

kicad-developers team mailing list archive

[PATCH] Fix arc selection over-enthusiastic bounding boxes

 

Hi,

Here is a patch to fix https://bugs.launchpad.net/kicad/+bug/1492734,
where a small-angle arc has an unexpectedly large bounding box,
causing odd selection behaviour.

The code was actually already there with a TODO on it - this patch
basically just uses that and replaces the TODO with a comment (one
more TODO down!)

Cheers,

John
From 42a706a236276f88a06a1202ab01326614c3e2e9 Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@xxxxxxxxx>
Date: Sat, 4 Feb 2017 09:42:37 +0800
Subject: [PATCH] Do not include arc centre in bounding box

Arc centres don't land in the bounding box when the arc angle is small.
Currently, there are added to the BB, which leads to surprising
selection beheviour of arc segments (the BB can be much larger than
expected).

This commit omits the arc centre from the calculation.

Fixes: lp:1492734
* https://bugs.launchpad.net/kicad/+bug/1492734
---
 pcbnew/class_drawsegment.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp
index 37d776a0b..50ddf984a 100644
--- a/pcbnew/class_drawsegment.cpp
+++ b/pcbnew/class_drawsegment.cpp
@@ -608,9 +608,10 @@ const BOX2I DRAWSEGMENT::ViewBBox() const
 
 void DRAWSEGMENT::computeArcBBox( EDA_RECT& aBBox ) const
 {
-    aBBox.Merge( m_End );
-    // TODO perhaps the above line can be replaced with this one, so we do not include the center
-    //aBBox.SetOrigin( m_End );
+    // Do not include the center, which is not necessarily
+    // inside the BB of a arc with a small angle
+    aBBox.SetOrigin( m_End );
+
     wxPoint end = m_End;
     RotatePoint( &end, m_Start, -m_Angle );
     aBBox.Merge( end );
-- 
2.11.0


Follow ups