-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path72610867-backport.diff
61 lines (55 loc) · 2.35 KB
/
72610867-backport.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
gendrill_file_writer_base: better algo to sort holes:
See https://gitlab.com/kicad/code/kicad/-/commit/7261086779c50658302bd4e3034bb99d74799c64
but backported to KiCad 5.1.8
--- a/pcbnew/exporters/gendrill_file_writer_base.cpp
+++ b/pcbnew/exporters/gendrill_file_writer_base.cpp
@@ -3,7 +3,7 @@
*
* Copyright (C) 2017 Jean_Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
- * Copyright (C) 1992-2017 KiCad Developers, see change_log.txt for contributors.
+ * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -34,7 +34,7 @@
/* Helper function for sorting hole list.
* Compare function used for sorting holes type type (plated then not plated)
- * then by increasing diameter value and X value
+ * then by increasing diameter value and X then Y position
*/
static bool CmpHoleSorting( const HOLE_INFO& a, const HOLE_INFO& b )
{
@@ -44,24 +44,9 @@
if( a.m_Hole_Diameter != b.m_Hole_Diameter )
return a.m_Hole_Diameter < b.m_Hole_Diameter;
- // group by components when possible
- const D_PAD* pada = dyn_cast<const D_PAD*>( a.m_ItemParent );
- const D_PAD* padb = dyn_cast<const D_PAD*>( b.m_ItemParent );
-
- if( pada && padb )
- {
- // cmp == 0 means the pads have the same parent, therfore the same reference
- int cmp = pada->GetParent() - padb->GetParent();
-
- if( cmp )
- return cmp < 0;
- }
- else if( pada || padb ) // in this case, other item is a via. Sort via first
- {
- return padb != nullptr;
- }
-
- // At this point, sort by position, as last sort criteria
+ // At this point (same diameter), sort by X then Y position.
+ // This is optimal for drilling and make the file reproducible as long as holes
+ // have not changed, even if the data order has changed.
if( a.m_Hole_Pos.x != b.m_Hole_Pos.x )
return a.m_Hole_Pos.x < b.m_Hole_Pos.x;
@@ -151,7 +136,7 @@
}
}
- // Sort holes per increasing diameter value
+ // Sort holes per increasing diameter value (and for each dimater, by position)
sort( m_holeListBuffer.begin(), m_holeListBuffer.end(), CmpHoleSorting );
// build the tool list