39#include <api/board/board_types.pb.h>
43 m_Profile( aBoard.GetDesignSettings().GetDrillSymbolProfile() )
88 wxCHECK_RET( aImage && aImage->
Type() ==
Type(), wxT(
"Cannot swap data with invalid chart." ) );
118 return model.Groups();
135 const int firstDataRow = 1;
138 return aRow >= firstDataRow && aRow <= lastDataRow;
144 return wxString::Format(
_(
"Drill Chart (%d rows)" ),
GetRowCount() );
150 aList.emplace_back(
_(
"Drill Chart" ), wxEmptyString );
151 aList.emplace_back(
_(
"Rows" ), wxString::Format( wxT(
"%d" ),
GetRowCount() ) );
182const wxString
NO_VALUE( wxS(
"\u2014" ) );
196 return wxT(
"Backdrill" );
199 return wxT(
"Slot" );
201 return wxT(
"Drill" );
210 parts.Add( wxT(
"filled" ) );
213 parts.Add( wxT(
"capped" ) );
216 parts.Add( wxT(
"plugged" ) );
219 parts.Add( wxT(
"covered" ) );
222 parts.Add( wxT(
"tented" ) );
224 return parts.IsEmpty() ?
NO_VALUE : wxJoin( parts,
',' );
241 return wxEmptyString;
252 std::vector<DRILL_CHART_GROUP> groups =
266 const std::map<std::string, DRILL_SYMBOL_ASSIGNMENT> resolved =
271 const auto it = resolved.find(
group.m_SymbolKey );
273 if( it != resolved.end() )
274 group.m_Symbol = it->second;
278 auto content = std::make_unique<DRILL_CHART_CONTENT>();
279 content->m_Rows.reserve( groups.size() );
280 content->m_RowShapes.reserve( groups.size() );
282 const int cols =
static_cast<int>(
m_columns.size() );
284 for(
int col = 0; col < cols; ++col )
287 content->m_SymbolColumn = col;
297 content->m_RowShapes.emplace_back(
group.m_Symbol.m_ShapeIndex );
299 content->m_RowShapes.emplace_back();
301 for(
int col = 0; col < cols; ++col )
317 ? wxString::Format( wxT(
"%s x %s" ),
326 text =
group.m_NotPlated ? wxT(
"No" ) : wxT(
"Yes" );
330 text = wxString::Format( wxT(
"%d" ),
group.m_OperationCount );
334 text = wxString::Format( wxT(
"%d" ),
group.m_SiteCount );
362 const int diameter =
group.m_Diameter;
364 text = depth > 0 && diameter > 0
365 ? wxString::Format( wxT(
"%.1f:1" ), (
double) depth / diameter )
385 std::set<std::pair<int, int>> sites;
389 operations +=
group.m_OperationCount;
392 sites.emplace( site.
x, site.
y );
395 content->m_Trailer.push_back( { wxString::Format( wxT(
"%d OPS / %zu SITES" ), operations, sites.size() ) } );
408 for(
size_t ii = 0; ii < content.
m_RowShapes.size(); ++ii )
422 types::DrillChart chart;
426 types::DrillChartFilter*
filter = chart.mutable_filter();
439 ( *chart.mutable_row_shapes() )[row] = shapeIndex;
441 aContainer.PackFrom( chart );
448 types::DrillChart chart;
450 if( !aContainer.UnpackTo( &chart ) )
460 if( chart.has_filter() )
462 m_filter.m_Plated = chart.filter().plated();
463 m_filter.m_NonPlated = chart.filter().non_plated();
464 m_filter.m_Vias = chart.filter().vias();
465 m_filter.m_Slots = chart.filter().slots();
466 m_filter.m_Backdrills = chart.filter().backdrills();
467 m_filter.m_Castellated = chart.filter().castellated();
474 for(
const auto& [row, shapeIndex] : chart.row_shapes() )
496 const wxString chartProps =
_(
"Drill Chart Properties" );
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...
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
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() const
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 ...
The base class for create windows for drawing purpose.
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.
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
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 ApplyTemplate(const DRILL_CHART_TEMPLATE &aTemplate)
Copy a template's formatting.
void swapData(BOARD_ITEM *aImage) override
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
uint64_t m_builtGeneration
void SetShowTotals(bool aShow)
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.
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.
bool GetShowTotals() const
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
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
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
std::vector< GENERATED_TABLE_COLUMN > m_columns
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
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
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.
Message panel definition file.
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