KiCad PCB EDA Suite
gendrill_file_writer_base.cpp File Reference
#include <fctsys.h>
#include <class_board.h>
#include <class_module.h>
#include <class_track.h>
#include <collectors.h>
#include <reporter.h>
#include <gendrill_file_writer_base.h>

Go to the source code of this file.

Functions

static bool CmpHoleSorting (const HOLE_INFO &a, const HOLE_INFO &b)
 

Function Documentation

◆ CmpHoleSorting()

static bool CmpHoleSorting ( const HOLE_INFO a,
const HOLE_INFO b 
)
static

Definition at line 40 of file gendrill_file_writer_base.cpp.

41 {
43  return b.m_Hole_NotPlated;
44 
45  if( a.m_Hole_Diameter != b.m_Hole_Diameter )
46  return a.m_Hole_Diameter < b.m_Hole_Diameter;
47 
48  // group by components when possible
49  const D_PAD* pada = dyn_cast<const D_PAD*>( a.m_ItemParent );
50  const D_PAD* padb = dyn_cast<const D_PAD*>( b.m_ItemParent );
51 
52  if( pada && padb )
53  {
54  // cmp == 0 means the pads have the same parent, therfore the same reference
55  int cmp = pada->GetParent() - padb->GetParent();
56 
57  if( cmp )
58  return cmp < 0;
59  }
60  else if( pada || padb ) // in this case, other item is a via. Sort via first
61  {
62  return padb != nullptr;
63  }
64 
65  // At this point, sort by position, as last sort criteria
66  if( a.m_Hole_Pos.x != b.m_Hole_Pos.x )
67  return a.m_Hole_Pos.x < b.m_Hole_Pos.x;
68 
69  return a.m_Hole_Pos.y < b.m_Hole_Pos.y;
70 }
BOARD_ITEM * m_ItemParent
MODULE * GetParent() const
Definition: class_pad.h:164

References D_PAD::GetParent(), HOLE_INFO::m_Hole_Diameter, HOLE_INFO::m_Hole_NotPlated, HOLE_INFO::m_Hole_Pos, HOLE_INFO::m_ItemParent, wxPoint::x, and wxPoint::y.

Referenced by GENDRILL_WRITER_BASE::buildHolesList().