Terminology and coding style.

This commit is contained in:
Jeff Young 2022-09-27 12:23:38 +01:00
parent 9e580b3116
commit b70ffddb04
2 changed files with 90 additions and 88 deletions

View File

@ -142,20 +142,20 @@ void DIALOG_BOARD_STATISTICS::refreshItemsTypes()
m_fpTypes.clear(); m_fpTypes.clear();
// If you need some more types to be shown, simply add them to the corresponding list // If you need some more types to be shown, simply add them to the corresponding list
m_fpTypes.push_back( FOOTPRINT_TYPE_T( FP_THROUGH_HOLE, FP_THROUGH_HOLE, _( "THT:" ) ) ); m_fpTypes.push_back( FP_LINE_ITEM( FP_THROUGH_HOLE, FP_THROUGH_HOLE, _( "THT:" ) ) );
m_fpTypes.push_back( FOOTPRINT_TYPE_T( FP_SMD, FP_SMD, _( "SMD:" ) ) ); m_fpTypes.push_back( FP_LINE_ITEM( FP_SMD, FP_SMD, _( "SMD:" ) ) );
m_fpTypes.push_back( FOOTPRINT_TYPE_T( FP_THROUGH_HOLE|FP_SMD, 0, _( "Unspecified:" ) ) ); m_fpTypes.push_back( FP_LINE_ITEM( FP_THROUGH_HOLE|FP_SMD, 0, _( "Unspecified:" ) ) );
m_padTypes.clear(); m_padTypes.clear();
m_padTypes.push_back( TYPE_CONTAINER_T<PAD_ATTRIB>( PAD_ATTRIB::PTH, _( "Through hole:" ) ) ); m_padTypes.push_back( LINE_ITEM<PAD_ATTRIB>( PAD_ATTRIB::PTH, _( "Through hole:" ) ) );
m_padTypes.push_back( TYPE_CONTAINER_T<PAD_ATTRIB>( PAD_ATTRIB::SMD, _( "SMD:" ) ) ); m_padTypes.push_back( LINE_ITEM<PAD_ATTRIB>( PAD_ATTRIB::SMD, _( "SMD:" ) ) );
m_padTypes.push_back( TYPE_CONTAINER_T<PAD_ATTRIB>( PAD_ATTRIB::CONN, _( "Connector:" ) ) ); m_padTypes.push_back( LINE_ITEM<PAD_ATTRIB>( PAD_ATTRIB::CONN, _( "Connector:" ) ) );
m_padTypes.push_back( TYPE_CONTAINER_T<PAD_ATTRIB>( PAD_ATTRIB::NPTH, _( "NPTH:" ) ) ); m_padTypes.push_back( LINE_ITEM<PAD_ATTRIB>( PAD_ATTRIB::NPTH, _( "NPTH:" ) ) );
m_viaTypes.clear(); m_viaTypes.clear();
m_viaTypes.push_back( TYPE_CONTAINER_T<VIATYPE>( VIATYPE::THROUGH, _( "Through vias:" ) ) ); m_viaTypes.push_back( LINE_ITEM<VIATYPE>( VIATYPE::THROUGH, _( "Through vias:" ) ) );
m_viaTypes.push_back( TYPE_CONTAINER_T<VIATYPE>( VIATYPE::BLIND_BURIED, _( "Blind/buried:" ) ) ); m_viaTypes.push_back( LINE_ITEM<VIATYPE>( VIATYPE::BLIND_BURIED, _( "Blind/buried:" ) ) );
m_viaTypes.push_back( TYPE_CONTAINER_T<VIATYPE>( VIATYPE::MICROVIA, _( "Micro vias:" ) ) ); m_viaTypes.push_back( LINE_ITEM<VIATYPE>( VIATYPE::MICROVIA, _( "Micro vias:" ) ) );
// If there not enough rows in grids, append some // If there not enough rows in grids, append some
int appendRows = m_fpTypes.size() + 2 - m_gridComponents->GetNumberRows(); int appendRows = m_fpTypes.size() + 2 - m_gridComponents->GetNumberRows();
@ -185,8 +185,8 @@ bool DIALOG_BOARD_STATISTICS::TransferDataToWindow()
m_drillsPanel->Layout(); m_drillsPanel->Layout();
m_gridDrills->AutoSizeColumns(); m_gridDrills->AutoSizeColumns();
m_startLayerColInitialSize = m_gridDrills->GetColSize( DRILL_TYPE_T::COL_START_LAYER ); m_startLayerColInitialSize = m_gridDrills->GetColSize( DRILL_LINE_ITEM::COL_START_LAYER );
m_stopLayerColInitialSize = m_gridDrills->GetColSize( DRILL_TYPE_T::COL_STOP_LAYER ); m_stopLayerColInitialSize = m_gridDrills->GetColSize( DRILL_LINE_ITEM::COL_STOP_LAYER );
// Add space for the vertical scrollbar, so that it won't overlap with the cells. // Add space for the vertical scrollbar, so that it won't overlap with the cells.
m_gridDrills->SetMinSize( wxSize( m_gridDrills->GetEffectiveMinSize().x m_gridDrills->SetMinSize( wxSize( m_gridDrills->GetEffectiveMinSize().x
@ -213,14 +213,14 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
continue; continue;
// Go through components types list // Go through components types list
for( FOOTPRINT_TYPE_T& type : m_fpTypes ) for( FP_LINE_ITEM& line : m_fpTypes )
{ {
if( ( footprint->GetAttributes() & type.attribute_mask ) == type.attribute_value ) if( ( footprint->GetAttributes() & line.attribute_mask ) == line.attribute_value )
{ {
if( footprint->IsFlipped() ) if( footprint->IsFlipped() )
type.backSideQty++; line.backSideQty++;
else else
type.frontSideQty++; line.frontSideQty++;
break; break;
} }
} }
@ -228,11 +228,11 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
for( PAD* pad : footprint->Pads() ) for( PAD* pad : footprint->Pads() )
{ {
// Go through pads types list // Go through pads types list
for( TYPE_CONTAINER_T<PAD_ATTRIB>& type : m_padTypes ) for( LINE_ITEM<PAD_ATTRIB>& line : m_padTypes )
{ {
if( pad->GetAttribute() == type.attribute ) if( pad->GetAttribute() == line.attribute )
{ {
type.qty++; line.qty++;
break; break;
} }
} }
@ -253,9 +253,10 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
bottom = pad->GetLayerSet().CuStack().back(); bottom = pad->GetLayerSet().CuStack().back();
} }
DRILL_TYPE_T drill( pad->GetDrillSize().x, pad->GetDrillSize().y, DRILL_LINE_ITEM drill( pad->GetDrillSize().x, pad->GetDrillSize().y,
pad->GetDrillShape(), pad->GetAttribute() != PAD_ATTRIB::NPTH, pad->GetDrillShape(),
true, top, bottom, 0 ); pad->GetAttribute() != PAD_ATTRIB::NPTH,
true, top, bottom );
auto it = m_drillTypes.begin(); auto it = m_drillTypes.begin();
@ -283,17 +284,18 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
{ {
if( PCB_VIA* via = dyn_cast<PCB_VIA*>( track ) ) if( PCB_VIA* via = dyn_cast<PCB_VIA*>( track ) )
{ {
for( TYPE_CONTAINER_T<VIATYPE>& type : m_viaTypes ) for( LINE_ITEM<VIATYPE>& line : m_viaTypes )
{ {
if( via->GetViaType() == type.attribute ) if( via->GetViaType() == line.attribute )
{ {
type.qty++; line.qty++;
break; break;
} }
} }
DRILL_TYPE_T drill( via->GetDrillValue(), via->GetDrillValue(), PAD_DRILL_SHAPE_CIRCLE, DRILL_LINE_ITEM drill( via->GetDrillValue(), via->GetDrillValue(),
true, false, via->TopLayer(), via->BottomLayer(), 0 ); PAD_DRILL_SHAPE_CIRCLE, true, false, via->TopLayer(),
via->BottomLayer() );
auto it = m_drillTypes.begin(); auto it = m_drillTypes.begin();
@ -316,7 +318,7 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
} }
sort( m_drillTypes.begin(), m_drillTypes.end(), sort( m_drillTypes.begin(), m_drillTypes.end(),
DRILL_TYPE_T::COMPARE( DRILL_TYPE_T::COL_COUNT, false ) ); DRILL_LINE_ITEM::COMPARE( DRILL_LINE_ITEM::COL_COUNT, false ) );
bool boundingBoxCreated = false; //flag if bounding box initialized bool boundingBoxCreated = false; //flag if bounding box initialized
BOX2I bbox; BOX2I bbox;
@ -383,11 +385,11 @@ void DIALOG_BOARD_STATISTICS::updateWidets()
int totalPads = 0; int totalPads = 0;
int row = 0; int row = 0;
for( const TYPE_CONTAINER_T<PAD_ATTRIB>& type : m_padTypes ) for( const LINE_ITEM<PAD_ATTRIB>& line : m_padTypes )
{ {
m_gridPads->SetCellValue( row, COL_LABEL, type.title ); m_gridPads->SetCellValue( row, COL_LABEL, line.title );
m_gridPads->SetCellValue( row, COL_AMOUNT, formatCount( type.qty ) ); m_gridPads->SetCellValue( row, COL_AMOUNT, formatCount( line.qty ) );
totalPads += type.qty; totalPads += line.qty;
row++; row++;
} }
@ -397,11 +399,11 @@ void DIALOG_BOARD_STATISTICS::updateWidets()
int totalVias = 0; int totalVias = 0;
row = 0; row = 0;
for( const TYPE_CONTAINER_T<VIATYPE>& type : m_viaTypes ) for( const LINE_ITEM<VIATYPE>& line : m_viaTypes )
{ {
m_gridVias->SetCellValue( row, COL_LABEL, type.title ); m_gridVias->SetCellValue( row, COL_LABEL, line.title );
m_gridVias->SetCellValue( row, COL_AMOUNT, formatCount( type.qty ) ); m_gridVias->SetCellValue( row, COL_AMOUNT, formatCount( line.qty ) );
totalVias += type.qty; totalVias += line.qty;
row++; row++;
} }
@ -415,14 +417,14 @@ void DIALOG_BOARD_STATISTICS::updateWidets()
// We don't use row 0, as there labels are // We don't use row 0, as there labels are
row = 1; row = 1;
for( const FOOTPRINT_TYPE_T& type : m_fpTypes ) for( const FP_LINE_ITEM& line : m_fpTypes )
{ {
m_gridComponents->SetCellValue( row, COL_LABEL, type.title ); m_gridComponents->SetCellValue( row, COL_LABEL, line.title );
m_gridComponents->SetCellValue( row, COL_FRONT_SIDE, formatCount( type.frontSideQty ) ); m_gridComponents->SetCellValue( row, COL_FRONT_SIDE, formatCount( line.frontSideQty ) );
m_gridComponents->SetCellValue( row, COL_BOTTOM_SIDE, formatCount( type.backSideQty ) ); m_gridComponents->SetCellValue( row, COL_BOTTOM_SIDE, formatCount( line.backSideQty ) );
m_gridComponents->SetCellValue( row, 3, formatCount( type.frontSideQty + type.backSideQty ) ); m_gridComponents->SetCellValue( row, 3, formatCount( line.frontSideQty + line.backSideQty ) );
totalFront += type.frontSideQty; totalFront += line.frontSideQty;
totalBack += type.backSideQty; totalBack += line.backSideQty;
row++; row++;
} }
@ -462,45 +464,45 @@ void DIALOG_BOARD_STATISTICS::updateWidets()
void DIALOG_BOARD_STATISTICS::updateDrillGrid() void DIALOG_BOARD_STATISTICS::updateDrillGrid()
{ {
BOARD* board = m_parentFrame->GetBoard(); BOARD* board = m_parentFrame->GetBoard();
int currentRow = 0; int row = 0;
for( const DRILL_TYPE_T& type : m_drillTypes ) for( const DRILL_LINE_ITEM& line : m_drillTypes )
{ {
wxString shapeStr; wxString shapeStr;
wxString startLayerStr; wxString startLayerStr;
wxString stopLayerStr; wxString stopLayerStr;
switch( type.shape ) switch( line.shape )
{ {
case PAD_DRILL_SHAPE_CIRCLE: shapeStr = _( "Round" ); break; case PAD_DRILL_SHAPE_CIRCLE: shapeStr = _( "Round" ); break;
case PAD_DRILL_SHAPE_OBLONG: shapeStr = _( "Slot" ); break; case PAD_DRILL_SHAPE_OBLONG: shapeStr = _( "Slot" ); break;
default: shapeStr = _( "???" ); break; default: shapeStr = _( "???" ); break;
} }
if( type.startLayer == UNDEFINED_LAYER ) if( line.startLayer == UNDEFINED_LAYER )
startLayerStr = _( "N/A" ); startLayerStr = _( "N/A" );
else else
startLayerStr = board->GetLayerName( type.startLayer ); startLayerStr = board->GetLayerName( line.startLayer );
if( type.stopLayer == UNDEFINED_LAYER ) if( line.stopLayer == UNDEFINED_LAYER )
stopLayerStr = _( "N/A" ); stopLayerStr = _( "N/A" );
else else
stopLayerStr = board->GetLayerName( type.stopLayer ); stopLayerStr = board->GetLayerName( line.stopLayer );
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_COUNT, formatCount( type.qty ) ); m_gridDrills->SetCellValue( row, DRILL_LINE_ITEM::COL_COUNT, formatCount( line.qty ) );
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_SHAPE, shapeStr ); m_gridDrills->SetCellValue( row, DRILL_LINE_ITEM::COL_SHAPE, shapeStr );
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_X_SIZE, m_gridDrills->SetCellValue( row, DRILL_LINE_ITEM::COL_X_SIZE,
m_parentFrame->MessageTextFromValue( type.xSize ) ); m_parentFrame->MessageTextFromValue( line.xSize ) );
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_Y_SIZE, m_gridDrills->SetCellValue( row, DRILL_LINE_ITEM::COL_Y_SIZE,
m_parentFrame->MessageTextFromValue( type.ySize ) ); m_parentFrame->MessageTextFromValue( line.ySize ) );
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_PLATED, m_gridDrills->SetCellValue( row, DRILL_LINE_ITEM::COL_PLATED,
type.isPlated ? _( "PTH" ) : _( "NPTH" ) ); line.isPlated ? _( "PTH" ) : _( "NPTH" ) );
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_VIA_PAD, m_gridDrills->SetCellValue( row, DRILL_LINE_ITEM::COL_VIA_PAD,
type.isPad ? _( "Pad" ) : _( "Via" ) ); line.isPad ? _( "Pad" ) : _( "Via" ) );
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_START_LAYER, startLayerStr ); m_gridDrills->SetCellValue( row, DRILL_LINE_ITEM::COL_START_LAYER, startLayerStr );
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_STOP_LAYER, stopLayerStr ); m_gridDrills->SetCellValue( row, DRILL_LINE_ITEM::COL_STOP_LAYER, stopLayerStr );
currentRow++; row++;
} }
} }
@ -602,7 +604,7 @@ void DIALOG_BOARD_STATISTICS::adjustDrillGridColumns()
// Find the total current width // Find the total current width
for( int i = 0; i < m_gridDrills->GetNumberCols(); i++ ) for( int i = 0; i < m_gridDrills->GetNumberCols(); i++ )
{ {
if( i != DRILL_TYPE_T::COL_START_LAYER && i != DRILL_TYPE_T::COL_STOP_LAYER ) if( i != DRILL_LINE_ITEM::COL_START_LAYER && i != DRILL_LINE_ITEM::COL_STOP_LAYER )
remainingWidth -= m_gridDrills->GetColSize( i ); remainingWidth -= m_gridDrills->GetColSize( i );
} }
@ -612,8 +614,8 @@ void DIALOG_BOARD_STATISTICS::adjustDrillGridColumns()
int startLayerColWidth = static_cast<int>( m_startLayerColInitialSize * scalingFactor ); int startLayerColWidth = static_cast<int>( m_startLayerColInitialSize * scalingFactor );
int stopLayerColWidth = static_cast<int>( m_stopLayerColInitialSize * scalingFactor ); int stopLayerColWidth = static_cast<int>( m_stopLayerColInitialSize * scalingFactor );
m_gridDrills->SetColSize( DRILL_TYPE_T::COL_START_LAYER, startLayerColWidth ); m_gridDrills->SetColSize( DRILL_LINE_ITEM::COL_START_LAYER, startLayerColWidth );
m_gridDrills->SetColSize( DRILL_TYPE_T::COL_STOP_LAYER, stopLayerColWidth ); m_gridDrills->SetColSize( DRILL_LINE_ITEM::COL_STOP_LAYER, stopLayerColWidth );
} }
@ -707,12 +709,12 @@ void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent )
int frontTotal = 0; int frontTotal = 0;
int backTotal = 0; int backTotal = 0;
for( const FOOTPRINT_TYPE_T& type : m_fpTypes ) for( const FP_LINE_ITEM& line : m_fpTypes )
{ {
// Get maximum width for left label column // Get maximum width for left label column
widths[0] = std::max<int>( type.title.size(), widths[0] ); widths[0] = std::max<int>( line.title.size(), widths[0] );
frontTotal += type.frontSideQty; frontTotal += line.frontSideQty;
backTotal += type.backSideQty; backTotal += line.backSideQty;
} }
// Get maximum width for other columns // Get maximum width for other columns
@ -754,11 +756,11 @@ void DIALOG_BOARD_STATISTICS::drillGridSize( wxSizeEvent& aEvent )
void DIALOG_BOARD_STATISTICS::drillGridSort( wxGridEvent& aEvent ) void DIALOG_BOARD_STATISTICS::drillGridSort( wxGridEvent& aEvent )
{ {
DRILL_TYPE_T::COL_ID colId = static_cast<DRILL_TYPE_T::COL_ID>( aEvent.GetCol() ); DRILL_LINE_ITEM::COL_ID colId = static_cast<DRILL_LINE_ITEM::COL_ID>( aEvent.GetCol() );
bool ascending = !( m_gridDrills->IsSortingBy( colId ) bool ascending = !( m_gridDrills->IsSortingBy( colId )
&& m_gridDrills->IsSortOrderAscending() ); && m_gridDrills->IsSortOrderAscending() );
sort( m_drillTypes.begin(), m_drillTypes.end(), DRILL_TYPE_T::COMPARE( colId, ascending ) ); sort( m_drillTypes.begin(), m_drillTypes.end(), DRILL_LINE_ITEM::COMPARE( colId, ascending ) );
updateDrillGrid(); updateDrillGrid();
} }

View File

@ -47,9 +47,9 @@ public:
* Type information, which will be shown in dialog. * Type information, which will be shown in dialog.
*/ */
template <typename T> template <typename T>
struct TYPE_CONTAINER_T struct LINE_ITEM
{ {
TYPE_CONTAINER_T<T>( T aAttribute, const wxString& aTitle ) : LINE_ITEM<T>( T aAttribute, const wxString& aTitle ) :
attribute( aAttribute ), attribute( aAttribute ),
title( aTitle ), title( aTitle ),
qty( 0 ) qty( 0 )
@ -65,9 +65,9 @@ public:
* Footprint attributes (such as SMD, THT, Virtual and so on), which will be shown in the * Footprint attributes (such as SMD, THT, Virtual and so on), which will be shown in the
* dialog. Holds both front and back footprint quantities. * dialog. Holds both front and back footprint quantities.
*/ */
struct FOOTPRINT_TYPE_T struct FP_LINE_ITEM
{ {
FOOTPRINT_TYPE_T( int aAttributeMask, int aAttributeValue, wxString aTitle ) : FP_LINE_ITEM( int aAttributeMask, int aAttributeValue, wxString aTitle ) :
attribute_mask( aAttributeMask ), attribute_mask( aAttributeMask ),
attribute_value( aAttributeValue ), attribute_value( aAttributeValue ),
title( aTitle ), title( aTitle ),
@ -83,7 +83,7 @@ public:
int backSideQty; int backSideQty;
}; };
struct DRILL_TYPE_T struct DRILL_LINE_ITEM
{ {
enum COL_ID enum COL_ID
{ {
@ -97,8 +97,8 @@ public:
COL_STOP_LAYER COL_STOP_LAYER
}; };
DRILL_TYPE_T( int aXSize, int aYSize, PAD_DRILL_SHAPE_T aShape, bool aIsPlated, DRILL_LINE_ITEM( int aXSize, int aYSize, PAD_DRILL_SHAPE_T aShape, bool aIsPlated,
bool aIsPad, PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aStopLayer, int aQty ) : bool aIsPad, PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aStopLayer ) :
xSize( aXSize ), xSize( aXSize ),
ySize( aYSize ), ySize( aYSize ),
shape( aShape ), shape( aShape ),
@ -106,11 +106,11 @@ public:
isPad( aIsPad ), isPad( aIsPad ),
startLayer( aStartLayer ), startLayer( aStartLayer ),
stopLayer( aStopLayer ), stopLayer( aStopLayer ),
qty( aQty ) qty( 0 )
{ {
} }
bool operator==( const DRILL_TYPE_T& other ) bool operator==( const DRILL_LINE_ITEM& other )
{ {
return xSize == other.xSize && ySize == other.ySize && shape == other.shape return xSize == other.xSize && ySize == other.ySize && shape == other.shape
&& isPlated == other.isPlated && isPad == other.isPad && isPlated == other.isPlated && isPad == other.isPad
@ -122,7 +122,7 @@ public:
COMPARE( COL_ID aColId, bool aAscending ) : colId( aColId ), ascending( aAscending ) COMPARE( COL_ID aColId, bool aAscending ) : colId( aColId ), ascending( aAscending )
{ {
} }
bool operator()( const DRILL_TYPE_T& aLeft, const DRILL_TYPE_T& aRight ) bool operator()( const DRILL_LINE_ITEM& aLeft, const DRILL_LINE_ITEM& aRight )
{ {
switch( colId ) switch( colId )
{ {
@ -209,10 +209,10 @@ private:
bool m_hasOutline; ///< Show if board outline properly defined. bool m_hasOutline; ///< Show if board outline properly defined.
std::deque<FOOTPRINT_TYPE_T> m_fpTypes; std::deque<FP_LINE_ITEM> m_fpTypes;
std::deque<TYPE_CONTAINER_T<PAD_ATTRIB>> m_padTypes; std::deque<LINE_ITEM<PAD_ATTRIB>> m_padTypes;
std::deque<TYPE_CONTAINER_T<VIATYPE>> m_viaTypes; std::deque<LINE_ITEM<VIATYPE>> m_viaTypes;
std::deque<DRILL_TYPE_T> m_drillTypes; std::deque<DRILL_LINE_ITEM> m_drillTypes;
int m_startLayerColInitialSize; ///< Width of the start layer column as calculated by int m_startLayerColInitialSize; ///< Width of the start layer column as calculated by
///< the wxWidgets autosizing algorithm. ///< the wxWidgets autosizing algorithm.