38#include <api/board/board_types.pb.h>
42 m_Profile( aBoard.GetDesignSettings().GetDrillSymbolProfile() )
88 wxCHECK_RET( aImage && aImage->
Type() ==
Type(), wxT(
"Cannot swap data with invalid chart." ) );
119 return model.Groups();
125 wxCHECK_RET( aOther.
Type() ==
Type(), wxT(
"Cannot apply settings from another kind of table." ) );
158 const int firstDataRow = 1;
161 return aRow >= firstDataRow && aRow <= lastDataRow;
167 return wxString::Format(
_(
"Drill Chart (%d rows)" ),
GetRowCount() );
188const wxString
NO_VALUE( wxS(
"\u2014" ) );
202 return wxT(
"Backdrill" );
205 return wxT(
"Slot" );
207 return wxT(
"Drill" );
216 parts.Add( wxT(
"filled" ) );
219 parts.Add( wxT(
"capped" ) );
222 parts.Add( wxT(
"plugged" ) );
225 parts.Add( wxT(
"covered" ) );
228 parts.Add( wxT(
"tented" ) );
230 return parts.IsEmpty() ?
NO_VALUE : wxJoin( parts,
',' );
247 return wxEmptyString;
258 std::vector<DRILL_CHART_GROUP> groups =
272 const std::map<std::string, DRILL_SYMBOL_ASSIGNMENT> resolved =
277 const auto it = resolved.find(
group.m_SymbolKey );
279 if( it != resolved.end() )
280 group.m_Symbol = it->second;
284 auto content = std::make_unique<DRILL_CHART_CONTENT>();
285 content->m_Rows.reserve( groups.size() );
286 content->m_RowShapes.reserve( groups.size() );
288 const int cols =
static_cast<int>(
m_columns.size() );
290 for(
int col = 0; col < cols; ++col )
293 content->m_SymbolColumn = col;
303 content->m_RowShapes.emplace_back(
group.m_Symbol.m_ShapeIndex );
305 content->m_RowShapes.emplace_back();
307 for(
int col = 0; col < cols; ++col )
322 text =
group.m_IsSlot ? wxString::Format( wxT(
"%s x %s" ),
331 text =
group.m_NotPlated ? wxT(
"No" ) : wxT(
"Yes" );
335 text = wxString::Format( wxT(
"%d" ),
group.m_OperationCount );
339 text = wxString::Format( wxT(
"%d" ),
group.m_SiteCount );
365 group.m_BottomLayer );
367 const int diameter =
group.m_Diameter;
369 text = depth > 0 && diameter > 0 ? wxString::Format( wxT(
"%.1f:1" ), (
double) depth / diameter )
389 std::set<std::pair<int, int>> sites;
393 operations +=
group.m_OperationCount;
396 sites.emplace( site.
x, site.
y );
399 content->m_Trailer.push_back( { wxString::Format( wxT(
"%d OPS / %zu SITES" ), operations, sites.size() ) } );
420 for(
size_t ii = 0; ii < content.
m_RowShapes.size(); ++ii )
434 types::DrillChart chart;
438 types::DrillChartFilter*
filter = chart.mutable_filter();
451 ( *chart.mutable_row_shapes() )[row] = shapeIndex;
453 if( !aContainer.PackFrom( chart ) )
454 wxFAIL_MSG( wxT(
"Failed to pack PCB_DRILL_CHART" ) );
461 types::DrillChart chart;
463 if( !aContainer.UnpackTo( &chart ) )
473 if( chart.has_filter() )
475 m_filter.m_Plated = chart.filter().plated();
476 m_filter.m_NonPlated = chart.filter().non_plated();
477 m_filter.m_Vias = chart.filter().vias();
478 m_filter.m_Slots = chart.filter().slots();
479 m_filter.m_Backdrills = chart.filter().backdrills();
480 m_filter.m_Castellated = chart.filter().castellated();
487 for(
const auto& [row, shapeIndex] : chart.row_shapes() )
511 const wxString chartProps =
_(
"Drill Chart Properties" );
518 const wxString includeProps =
_HKI(
"Include Holes" );
void PackGeneratedTable(const PCB_GENERATED_TABLE &aTable, MSG &aMsg)
Pack what every generated table shares into its message.
bool UnpackGeneratedTable(const MSG &aMsg, PCB_GENERATED_TABLE &aTable)
The reverse of PackGeneratedTable.
constexpr EDA_IU_SCALE pcbIUScale
DRILL_SYMBOL_PROFILE & GetDrillSymbolProfile()
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
int GetLayerDistance(PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer) const
Calculate the distance (height) between the two given copper layers.
Information pertinent to a Pcbnew printed circuit board.
BOARD_STACKUP GetStackupOrDefault() const
uint64_t GetDrillModelGeneration() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
BOARD_DESIGN_SETTINGS & GetDesignSettings()
The column set and formatting a new chart starts from.
GENERATED_TABLE_UNITS GetUnits() const
std::vector< GENERATED_TABLE_COLUMN > & Columns()
static DRILL_CHART_TEMPLATE MakeDefault()
bool GetShowTotals() const
Grouping rules and symbol assignments, shared by reference so a chart and its map can never disagree ...
KICAD_T Type() const
Returns the type of object.
One pass of rebuilding tables.
T & Pending()
The pass's T, created from the board on first use.
A drill chart placed on the board, kept in step with the holes.
bool GetIncludeNonPlated() const
bool GetIncludeBackdrills() const
bool GetIncludeCastellated() const
PCB_DRILL_CHART(BOARD_ITEM *aParent)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void SetIncludePlated(bool aInclude)
void ApplyTemplate(const DRILL_CHART_TEMPLATE &aTemplate)
Copy a template's formatting.
void swapData(BOARD_ITEM *aImage) override
std::optional< bool > m_laidOutShowTotals
Set only between a change and the next rebuild.
void onRebuilt(const BOARD &aBoard, const GENERATED_TABLE_CONTENT &aContent) override
Called once the cells are laid out, with the content they were built from.
std::map< int, int > m_rowShapes
void onColumnsReversed() override
Called once the columns have been reversed, for any column index a subclass keeps.
void ApplySettings(const PCB_GENERATED_TABLE &aOther) override
Take aOther's settings and placement but keep this table's cells, so formatting applied to them survi...
uint64_t m_builtGeneration
void SetShowTotals(bool aShow)
A chart without row keys can only tell its totals row by position, so it remembers the setting its ro...
bool operator==(const BOARD_ITEM &aOther) const override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
std::unique_ptr< GENERATED_TABLE_CONTENT > generate(const BOARD &aBoard, GENERATED_TABLE_REFRESH *aRefresh) const override
The rows this table reports.
bool GetIncludeSlots() const
std::vector< DRILL_CHART_GROUP > buildGroups(const BOARD &aBoard, const DRILL_SYMBOL_PROFILE &aProfile) const
The board data this chart reports on, as chart rows grouped the way aProfile says.
bool IsDataRow(int aRow) const override
True for a row that reports a drill group, false for the title, heading and totals.
void SetIncludeVias(bool aInclude)
void SetIncludeCastellated(bool aInclude)
bool GetShowTotals() const
void SetIncludeNonPlated(bool aInclude)
bool GetIncludeVias() const
void SetIncludeSlots(bool aInclude)
bool GetIncludePlated() const
void RestoreShowTotals(bool aShow)
Set it without that, for a loader whose cells were laid out with this setting.
bool IsStale(const BOARD &aBoard) const override
One integer comparison, so a board with nothing drill related changed pays nothing.
DRILL_CHART_COLUMN_ID columnId(int aCol) const
The typed id a column at this index holds, so generate's switch stays exhaustive even though a stored...
DRILL_CHART_FILTER m_filter
void SetIncludeBackdrills(bool aInclude)
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
std::vector< GENERATED_TABLE_COLUMN > m_columns
virtual void ApplySettings(const PCB_GENERATED_TABLE &aOther)
Take aOther's settings and placement but keep this table's cells, so formatting applied to them survi...
GENERATED_TABLE_UNITS m_units
virtual bool IsDataRow(int aRow) const
True for a row that reports on the board, false for the heading and trailer rows.
bool generatedEquals(const PCB_GENERATED_TABLE &aOther) const
Equality of the members this class owns and of the underlying PCB_TABLE.
void swapData(BOARD_ITEM *aImage) override
PCB_GENERATED_TABLE(BOARD_ITEM *aParent, KICAD_T aType, int aLineWidth)
std::map< int, std::string > m_rowKeys
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
std::vector< DRILL_SPAN > EnumerateDrillSpans(const BOARD &aBoard, bool aPadBackdrills)
Every drill span present on the board, through-holes first.
std::map< std::string, DRILL_SYMBOL_ASSIGNMENT > ResolveDrillSymbols(const BOARD &aBoard)
The symbol every hole should carry, without touching the board.
void AssignDrillSymbols(std::vector< DRILL_CHART_GROUP > &aGroups, DRILL_SYMBOL_PROFILE &aProfile)
Give every group a mark, keeping the ones the profile already records.
wxString FormatGeneratedTableLength(int aValue, GENERATED_TABLE_UNITS aUnits, int aPrecision)
Render a length the way a generated table's cell shows it.
Some functions to handle hotkeys in KiCad.
static struct PCB_DRILL_CHART_DESC _PCB_DRILL_CHART_DESC
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
A drill chart's rows, with the symbol each one is drawn with.
std::vector< std::optional< int > > m_RowShapes
Per m_Rows entry, empty when the mark is not a shape.
DRILL_SYMBOL_ASSIGNMENT m_Symbol
PCB_LAYER_ID m_BottomLayer
Turns the board's drill operations into chart rows for one symbol profile.
DRILL_CHART_FILTER m_Filter
The board's drill symbol profile as a refresh assigns new symbols into it.
DRILL_SYMBOL_PROFILE m_Profile
void Commit(BOARD &aBoard) override
DRILL_PROFILE_PENDING(BOARD &aBoard)
DRILL_MARK_MODE m_MarkMode
What a generated table reports, one entry per cell below the heading row.
One data row of a generated table, and the identity its formatting follows across rebuilds.
std::vector< wxString > m_Cells
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
VECTOR2< int32_t > VECTOR2I