KiCad PCB EDA Suite
gendrill_file_writer_base.cpp File Reference
#include <fctsys.h>
#include <class_board.h>
#include <class_module.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

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

Definition at line 39 of file gendrill_file_writer_base.cpp.

References dyn_cast(), BOARD_ITEM::GetParent(), 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().

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