Coding standards.
This commit is contained in:
parent
fb80f83335
commit
57a79f3020
|
@ -140,36 +140,35 @@ DIALOG_BOARD_STATISTICS::DIALOG_BOARD_STATISTICS( PCB_EDIT_FRAME* aParentFrame )
|
||||||
|
|
||||||
void DIALOG_BOARD_STATISTICS::refreshItemsTypes()
|
void DIALOG_BOARD_STATISTICS::refreshItemsTypes()
|
||||||
{
|
{
|
||||||
m_componentsTypes.clear();
|
m_fpTypes.clear();
|
||||||
|
|
||||||
// If you need some more types to be shown, simply add them to the
|
// If you need some more types to be shown, simply add them to the corresponding list
|
||||||
// corresponding list
|
m_fpTypes.push_back( FOOTPRINT_TYPE_T( FP_THROUGH_HOLE, FP_THROUGH_HOLE, _( "THT:" ) ) );
|
||||||
m_componentsTypes.push_back( componentsType_t( FP_THROUGH_HOLE, _( "THT:" ) ) );
|
m_fpTypes.push_back( FOOTPRINT_TYPE_T( FP_SMD, FP_SMD, _( "SMD:" ) ) );
|
||||||
m_componentsTypes.push_back( componentsType_t( FP_SMD, _( "SMD:" ) ) );
|
|
||||||
|
|
||||||
m_padsTypes.clear();
|
m_padTypes.clear();
|
||||||
m_padsTypes.push_back( padsType_t( PAD_ATTRIB::PTH, _( "Through hole:" ) ) );
|
m_padTypes.push_back( TYPE_CONTAINER_T<PAD_ATTRIB>( PAD_ATTRIB::PTH, _( "Through hole:" ) ) );
|
||||||
m_padsTypes.push_back( padsType_t( PAD_ATTRIB::SMD, _( "SMD:" ) ) );
|
m_padTypes.push_back( TYPE_CONTAINER_T<PAD_ATTRIB>( PAD_ATTRIB::SMD, _( "SMD:" ) ) );
|
||||||
m_padsTypes.push_back( padsType_t( PAD_ATTRIB::CONN, _( "Connector:" ) ) );
|
m_padTypes.push_back( TYPE_CONTAINER_T<PAD_ATTRIB>( PAD_ATTRIB::CONN, _( "Connector:" ) ) );
|
||||||
m_padsTypes.push_back( padsType_t( PAD_ATTRIB::NPTH, _( "NPTH:" ) ) );
|
m_padTypes.push_back( TYPE_CONTAINER_T<PAD_ATTRIB>( PAD_ATTRIB::NPTH, _( "NPTH:" ) ) );
|
||||||
|
|
||||||
m_viasTypes.clear();
|
m_viaTypes.clear();
|
||||||
m_viasTypes.push_back( viasType_t( VIATYPE::THROUGH, _( "Through vias:" ) ) );
|
m_viaTypes.push_back( TYPE_CONTAINER_T<VIATYPE>( VIATYPE::THROUGH, _( "Through vias:" ) ) );
|
||||||
m_viasTypes.push_back( viasType_t( VIATYPE::BLIND_BURIED, _( "Blind/buried:" ) ) );
|
m_viaTypes.push_back( TYPE_CONTAINER_T<VIATYPE>( VIATYPE::BLIND_BURIED, _( "Blind/buried:" ) ) );
|
||||||
m_viasTypes.push_back( viasType_t( VIATYPE::MICROVIA, _( "Micro vias:" ) ) );
|
m_viaTypes.push_back( TYPE_CONTAINER_T<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_componentsTypes.size() + 2 - m_gridComponents->GetNumberRows();
|
int appendRows = m_fpTypes.size() + 2 - m_gridComponents->GetNumberRows();
|
||||||
|
|
||||||
if( appendRows > 0 )
|
if( appendRows > 0 )
|
||||||
m_gridComponents->AppendRows( appendRows );
|
m_gridComponents->AppendRows( appendRows );
|
||||||
|
|
||||||
appendRows = m_padsTypes.size() + 1 - m_gridPads->GetNumberRows();
|
appendRows = m_padTypes.size() + 1 - m_gridPads->GetNumberRows();
|
||||||
|
|
||||||
if( appendRows > 0 )
|
if( appendRows > 0 )
|
||||||
m_gridPads->AppendRows( appendRows );
|
m_gridPads->AppendRows( appendRows );
|
||||||
|
|
||||||
appendRows = m_viasTypes.size() + 1 - m_gridVias->GetNumberRows();
|
appendRows = m_viaTypes.size() + 1 - m_gridVias->GetNumberRows();
|
||||||
|
|
||||||
if( appendRows )
|
if( appendRows )
|
||||||
m_gridVias->AppendRows( appendRows );
|
m_gridVias->AppendRows( appendRows );
|
||||||
|
@ -186,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( drillType_t::COL_START_LAYER );
|
m_startLayerColInitialSize = m_gridDrills->GetColSize( DRILL_TYPE_T::COL_START_LAYER );
|
||||||
m_stopLayerColInitialSize = m_gridDrills->GetColSize( drillType_t::COL_STOP_LAYER );
|
m_stopLayerColInitialSize = m_gridDrills->GetColSize( DRILL_TYPE_T::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( m_gridDrills->GetEffectiveMinSize()
|
m_gridDrills->SetMinSize( m_gridDrills->GetEffectiveMinSize()
|
||||||
|
@ -213,9 +212,9 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Go through components types list
|
// Go through components types list
|
||||||
for( auto& type : m_componentsTypes )
|
for( FOOTPRINT_TYPE_T& type : m_fpTypes )
|
||||||
{
|
{
|
||||||
if(( footprint->GetAttributes() & type.attribute ) > 0 )
|
if( ( footprint->GetAttributes() & type.attribute_mask ) == type.attribute_value )
|
||||||
{
|
{
|
||||||
if( footprint->IsFlipped() )
|
if( footprint->IsFlipped() )
|
||||||
type.backSideQty++;
|
type.backSideQty++;
|
||||||
|
@ -228,7 +227,7 @@ 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( auto& type : m_padsTypes )
|
for( TYPE_CONTAINER_T<PAD_ATTRIB>& type : m_padTypes )
|
||||||
{
|
{
|
||||||
if( pad->GetAttribute() == type.attribute )
|
if( pad->GetAttribute() == type.attribute )
|
||||||
{
|
{
|
||||||
|
@ -253,9 +252,9 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
|
||||||
bottom = pad->GetLayerSet().CuStack().back();
|
bottom = pad->GetLayerSet().CuStack().back();
|
||||||
}
|
}
|
||||||
|
|
||||||
drillType_t drill( pad->GetDrillSize().x, pad->GetDrillSize().y,
|
DRILL_TYPE_T drill( pad->GetDrillSize().x, pad->GetDrillSize().y,
|
||||||
pad->GetDrillShape(), pad->GetAttribute() != PAD_ATTRIB::NPTH,
|
pad->GetDrillShape(), pad->GetAttribute() != PAD_ATTRIB::NPTH,
|
||||||
true, top, bottom );
|
true, top, bottom, 0 );
|
||||||
|
|
||||||
auto it = m_drillTypes.begin();
|
auto it = m_drillTypes.begin();
|
||||||
|
|
||||||
|
@ -283,7 +282,7 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
|
||||||
{
|
{
|
||||||
if( PCB_VIA* via = dyn_cast<PCB_VIA*>( track ) )
|
if( PCB_VIA* via = dyn_cast<PCB_VIA*>( track ) )
|
||||||
{
|
{
|
||||||
for( auto& type : m_viasTypes )
|
for( TYPE_CONTAINER_T<VIATYPE>& type : m_viaTypes )
|
||||||
{
|
{
|
||||||
if( via->GetViaType() == type.attribute )
|
if( via->GetViaType() == type.attribute )
|
||||||
{
|
{
|
||||||
|
@ -292,8 +291,8 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
drillType_t drill( via->GetDrillValue(), via->GetDrillValue(), PAD_DRILL_SHAPE_CIRCLE,
|
DRILL_TYPE_T drill( via->GetDrillValue(), via->GetDrillValue(), PAD_DRILL_SHAPE_CIRCLE,
|
||||||
true, false, via->TopLayer(), via->BottomLayer() );
|
true, false, via->TopLayer(), via->BottomLayer(), 0 );
|
||||||
|
|
||||||
auto it = m_drillTypes.begin();
|
auto it = m_drillTypes.begin();
|
||||||
|
|
||||||
|
@ -316,7 +315,7 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
|
||||||
}
|
}
|
||||||
|
|
||||||
sort( m_drillTypes.begin(), m_drillTypes.end(),
|
sort( m_drillTypes.begin(), m_drillTypes.end(),
|
||||||
drillType_t::COMPARE( drillType_t::COL_COUNT, false ) );
|
DRILL_TYPE_T::COMPARE( DRILL_TYPE_T::COL_COUNT, false ) );
|
||||||
|
|
||||||
bool boundingBoxCreated = false; //flag if bounding box initialized
|
bool boundingBoxCreated = false; //flag if bounding box initialized
|
||||||
BOX2I bbox;
|
BOX2I bbox;
|
||||||
|
@ -372,75 +371,74 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static wxString formatCount( int aCount )
|
||||||
|
{
|
||||||
|
return wxString::Format( wxT( "%i" ), aCount );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_BOARD_STATISTICS::updateWidets()
|
void DIALOG_BOARD_STATISTICS::updateWidets()
|
||||||
{
|
{
|
||||||
int totalPads = 0;
|
int totalPads = 0;
|
||||||
int currentRow = 0;
|
int row = 0;
|
||||||
|
|
||||||
for( const auto& type : m_padsTypes )
|
for( const TYPE_CONTAINER_T<PAD_ATTRIB>& type : m_padTypes )
|
||||||
{
|
{
|
||||||
m_gridPads->SetCellValue( currentRow, COL_LABEL, type.title );
|
m_gridPads->SetCellValue( row, COL_LABEL, type.title );
|
||||||
m_gridPads->SetCellValue( currentRow, COL_AMOUNT,
|
m_gridPads->SetCellValue( row, COL_AMOUNT, formatCount( type.qty ) );
|
||||||
wxString::Format( wxT( "%i " ), type.qty ) );
|
|
||||||
totalPads += type.qty;
|
totalPads += type.qty;
|
||||||
currentRow++;
|
row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_gridPads->SetCellValue( currentRow, COL_LABEL, _( "Total:" ) );
|
m_gridPads->SetCellValue( row, COL_LABEL, _( "Total:" ) );
|
||||||
m_gridPads->SetCellValue( currentRow, COL_AMOUNT, wxString::Format( wxT( "%i " ), totalPads ) );
|
m_gridPads->SetCellValue( row, COL_AMOUNT, formatCount( totalPads ) );
|
||||||
|
|
||||||
int totalVias = 0;
|
int totalVias = 0;
|
||||||
currentRow = 0;
|
row = 0;
|
||||||
|
|
||||||
for( const auto& type : m_viasTypes )
|
for( const TYPE_CONTAINER_T<VIATYPE>& type : m_viaTypes )
|
||||||
{
|
{
|
||||||
m_gridVias->SetCellValue( currentRow, COL_LABEL, type.title );
|
m_gridVias->SetCellValue( row, COL_LABEL, type.title );
|
||||||
m_gridVias->SetCellValue( currentRow, COL_AMOUNT, wxString::Format( wxT( "%i " ), type.qty ) );
|
m_gridVias->SetCellValue( row, COL_AMOUNT, formatCount( type.qty ) );
|
||||||
totalVias += type.qty;
|
totalVias += type.qty;
|
||||||
currentRow++;
|
row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_gridVias->SetCellValue( currentRow, COL_LABEL, _( "Total:" ) );
|
m_gridVias->SetCellValue( row, COL_LABEL, _( "Total:" ) );
|
||||||
m_gridVias->SetCellValue( currentRow, COL_AMOUNT, wxString::Format( wxT( "%i " ), totalVias ) );
|
m_gridVias->SetCellValue( row, COL_AMOUNT, formatCount( totalVias ) );
|
||||||
|
|
||||||
|
|
||||||
int totalFront = 0;
|
int totalFront = 0;
|
||||||
int totalBack = 0;
|
int totalBack = 0;
|
||||||
|
|
||||||
// We don't use row 0, as there labels are
|
// We don't use row 0, as there labels are
|
||||||
currentRow = 1;
|
row = 1;
|
||||||
|
|
||||||
for( const auto& type : m_componentsTypes )
|
for( const FOOTPRINT_TYPE_T& type : m_fpTypes )
|
||||||
{
|
{
|
||||||
m_gridComponents->SetCellValue( currentRow, COL_LABEL, type.title );
|
m_gridComponents->SetCellValue( row, COL_LABEL, type.title );
|
||||||
m_gridComponents->SetCellValue( currentRow, COL_FRONT_SIDE,
|
m_gridComponents->SetCellValue( row, COL_FRONT_SIDE, formatCount( type.frontSideQty ) );
|
||||||
wxString::Format( wxT( "%i " ), type.frontSideQty ) );
|
m_gridComponents->SetCellValue( row, COL_BOTTOM_SIDE, formatCount( type.backSideQty ) );
|
||||||
m_gridComponents->SetCellValue( currentRow, COL_BOTTOM_SIDE,
|
m_gridComponents->SetCellValue( row, 3, formatCount( type.frontSideQty + type.backSideQty ) );
|
||||||
wxString::Format( wxT( "%i " ), type.backSideQty ) );
|
|
||||||
m_gridComponents->SetCellValue( currentRow, 3,
|
|
||||||
wxString::Format( wxT( "%i " ),
|
|
||||||
type.frontSideQty + type.backSideQty ) );
|
|
||||||
totalFront += type.frontSideQty;
|
totalFront += type.frontSideQty;
|
||||||
totalBack += type.backSideQty;
|
totalBack += type.backSideQty;
|
||||||
currentRow++;
|
row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_gridComponents->SetCellValue( currentRow, COL_LABEL, _( "Total:" ) );
|
m_gridComponents->SetCellValue( row, COL_LABEL, _( "Total:" ) );
|
||||||
m_gridComponents->SetCellValue( currentRow, COL_FRONT_SIDE,
|
m_gridComponents->SetCellValue( row, COL_FRONT_SIDE, formatCount( totalFront ) );
|
||||||
wxString::Format( wxT( "%i " ), totalFront ) );
|
m_gridComponents->SetCellValue( row, COL_BOTTOM_SIDE, formatCount( totalBack ) );
|
||||||
m_gridComponents->SetCellValue( currentRow, COL_BOTTOM_SIDE,
|
m_gridComponents->SetCellValue( row, COL_TOTAL, formatCount( totalFront + totalBack ) );
|
||||||
wxString::Format( wxT( "%i " ), totalBack ) );
|
|
||||||
m_gridComponents->SetCellValue( currentRow, COL_TOTAL,
|
|
||||||
wxString::Format( wxT( "%i " ), totalFront + totalBack ) );
|
|
||||||
|
|
||||||
if( m_hasOutline )
|
if( m_hasOutline )
|
||||||
{
|
{
|
||||||
m_gridBoard->SetCellValue( ROW_BOARD_WIDTH, COL_AMOUNT,
|
m_gridBoard->SetCellValue( ROW_BOARD_WIDTH, COL_AMOUNT,
|
||||||
m_parentFrame->MessageTextFromValue( m_boardWidth ) + wxS( " " ) );
|
m_parentFrame->MessageTextFromValue( m_boardWidth ) );
|
||||||
m_gridBoard->SetCellValue( ROW_BOARD_HEIGHT, COL_AMOUNT,
|
m_gridBoard->SetCellValue( ROW_BOARD_HEIGHT, COL_AMOUNT,
|
||||||
m_parentFrame->MessageTextFromValue( m_boardHeight ) + wxS( " " ) );
|
m_parentFrame->MessageTextFromValue( m_boardHeight ) );
|
||||||
m_gridBoard->SetCellValue( ROW_BOARD_AREA, COL_AMOUNT,
|
m_gridBoard->SetCellValue( ROW_BOARD_AREA, COL_AMOUNT,
|
||||||
m_parentFrame->MessageTextFromValue( m_boardArea, true, EDA_DATA_TYPE::AREA ) );
|
m_parentFrame->MessageTextFromValue( m_boardArea, true,
|
||||||
|
EDA_DATA_TYPE::AREA ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -465,7 +463,7 @@ void DIALOG_BOARD_STATISTICS::updateDrillGrid()
|
||||||
BOARD* board = m_parentFrame->GetBoard();
|
BOARD* board = m_parentFrame->GetBoard();
|
||||||
int currentRow = 0;
|
int currentRow = 0;
|
||||||
|
|
||||||
for( const auto& type : m_drillTypes )
|
for( const DRILL_TYPE_T& type : m_drillTypes )
|
||||||
{
|
{
|
||||||
wxString shapeStr;
|
wxString shapeStr;
|
||||||
wxString startLayerStr;
|
wxString startLayerStr;
|
||||||
|
@ -488,19 +486,18 @@ void DIALOG_BOARD_STATISTICS::updateDrillGrid()
|
||||||
else
|
else
|
||||||
stopLayerStr = board->GetLayerName( type.stopLayer );
|
stopLayerStr = board->GetLayerName( type.stopLayer );
|
||||||
|
|
||||||
m_gridDrills->SetCellValue( currentRow, drillType_t::COL_COUNT,
|
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_COUNT, formatCount( type.qty ) );
|
||||||
wxString::Format( wxT( "%i" ), type.qty ) );
|
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_SHAPE, shapeStr );
|
||||||
m_gridDrills->SetCellValue( currentRow, drillType_t::COL_SHAPE, shapeStr );
|
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_X_SIZE,
|
||||||
m_gridDrills->SetCellValue( currentRow, drillType_t::COL_X_SIZE,
|
|
||||||
m_parentFrame->MessageTextFromValue( type.xSize ) );
|
m_parentFrame->MessageTextFromValue( type.xSize ) );
|
||||||
m_gridDrills->SetCellValue( currentRow, drillType_t::COL_Y_SIZE,
|
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_Y_SIZE,
|
||||||
m_parentFrame->MessageTextFromValue( type.ySize ) );
|
m_parentFrame->MessageTextFromValue( type.ySize ) );
|
||||||
m_gridDrills->SetCellValue( currentRow, drillType_t::COL_PLATED,
|
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_PLATED,
|
||||||
type.isPlated ? _( "PTH" ) : _( "NPTH" ) );
|
type.isPlated ? _( "PTH" ) : _( "NPTH" ) );
|
||||||
m_gridDrills->SetCellValue( currentRow, drillType_t::COL_VIA_PAD,
|
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_VIA_PAD,
|
||||||
type.isPad ? _( "Pad" ) : _( "Via" ) );
|
type.isPad ? _( "Pad" ) : _( "Via" ) );
|
||||||
m_gridDrills->SetCellValue( currentRow, drillType_t::COL_START_LAYER, startLayerStr );
|
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_START_LAYER, startLayerStr );
|
||||||
m_gridDrills->SetCellValue( currentRow, drillType_t::COL_STOP_LAYER, stopLayerStr );
|
m_gridDrills->SetCellValue( currentRow, DRILL_TYPE_T::COL_STOP_LAYER, stopLayerStr );
|
||||||
|
|
||||||
currentRow++;
|
currentRow++;
|
||||||
}
|
}
|
||||||
|
@ -508,7 +505,7 @@ void DIALOG_BOARD_STATISTICS::updateDrillGrid()
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_BOARD_STATISTICS::printGridToStringAsTable( wxGrid* aGrid, wxString& aStr,
|
void DIALOG_BOARD_STATISTICS::printGridToStringAsTable( wxGrid* aGrid, wxString& aStr,
|
||||||
bool aUseRowLabels, bool aUseColLabels,
|
bool aUseColLabels,
|
||||||
bool aUseFirstColAsLabel )
|
bool aUseFirstColAsLabel )
|
||||||
{
|
{
|
||||||
std::vector<int> widths( aGrid->GetNumberCols(), 0 );
|
std::vector<int> widths( aGrid->GetNumberCols(), 0 );
|
||||||
|
@ -538,12 +535,6 @@ void DIALOG_BOARD_STATISTICS::printGridToStringAsTable( wxGrid* aGrid, wxString&
|
||||||
|
|
||||||
aStr << wxT( "|" );
|
aStr << wxT( "|" );
|
||||||
|
|
||||||
if( aUseRowLabels )
|
|
||||||
{
|
|
||||||
aStr.Append( ' ', rowLabelsWidth );
|
|
||||||
aStr << wxT( " |" );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( int col = 0; col < aGrid->GetNumberCols(); col++ )
|
for( int col = 0; col < aGrid->GetNumberCols(); col++ )
|
||||||
{
|
{
|
||||||
if( aUseColLabels )
|
if( aUseColLabels )
|
||||||
|
@ -560,12 +551,6 @@ void DIALOG_BOARD_STATISTICS::printGridToStringAsTable( wxGrid* aGrid, wxString&
|
||||||
|
|
||||||
aStr << wxT( "|" );
|
aStr << wxT( "|" );
|
||||||
|
|
||||||
if( aUseRowLabels )
|
|
||||||
{
|
|
||||||
aStr.Append( '-', rowLabelsWidth );
|
|
||||||
aStr << wxT( "-|" );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( int col = 0; col < aGrid->GetNumberCols(); col++ )
|
for( int col = 0; col < aGrid->GetNumberCols(); col++ )
|
||||||
{
|
{
|
||||||
aStr << wxT( "-" );
|
aStr << wxT( "-" );
|
||||||
|
@ -582,14 +567,12 @@ void DIALOG_BOARD_STATISTICS::printGridToStringAsTable( wxGrid* aGrid, wxString&
|
||||||
if( !aUseColLabels )
|
if( !aUseColLabels )
|
||||||
firstRow = 1;
|
firstRow = 1;
|
||||||
|
|
||||||
if( !aUseRowLabels && aUseFirstColAsLabel )
|
if( aUseFirstColAsLabel )
|
||||||
firstCol = 1;
|
firstCol = 1;
|
||||||
|
|
||||||
for( int row = firstRow; row < aGrid->GetNumberRows(); row++ )
|
for( int row = firstRow; row < aGrid->GetNumberRows(); row++ )
|
||||||
{
|
{
|
||||||
if( aUseRowLabels )
|
if( aUseFirstColAsLabel )
|
||||||
tmp.Printf( wxT( "|%-*s |" ), rowLabelsWidth, aGrid->GetRowLabelValue( row ) );
|
|
||||||
else if( aUseFirstColAsLabel )
|
|
||||||
tmp.Printf( wxT( "|%-*s |" ), widths[0], aGrid->GetCellValue( row, 0 ) );
|
tmp.Printf( wxT( "|%-*s |" ), widths[0], aGrid->GetCellValue( row, 0 ) );
|
||||||
else
|
else
|
||||||
tmp.Printf( wxT( "|" ) );
|
tmp.Printf( wxT( "|" ) );
|
||||||
|
@ -618,17 +601,18 @@ 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 != drillType_t::COL_START_LAYER && i != drillType_t::COL_STOP_LAYER )
|
if( i != DRILL_TYPE_T::COL_START_LAYER && i != DRILL_TYPE_T::COL_STOP_LAYER )
|
||||||
remainingWidth -= m_gridDrills->GetColSize( i );
|
remainingWidth -= m_gridDrills->GetColSize( i );
|
||||||
}
|
}
|
||||||
|
|
||||||
double scalingFactor = std::max(
|
double scalingFactor = std::max( 1.0,
|
||||||
1.0, remainingWidth / ( m_startLayerColInitialSize + m_stopLayerColInitialSize ) );
|
remainingWidth
|
||||||
|
/ ( m_startLayerColInitialSize + m_stopLayerColInitialSize ) );
|
||||||
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( drillType_t::COL_START_LAYER, startLayerColWidth );
|
m_gridDrills->SetColSize( DRILL_TYPE_T::COL_START_LAYER, startLayerColWidth );
|
||||||
m_gridDrills->SetColSize( drillType_t::COL_STOP_LAYER, stopLayerColWidth );
|
m_gridDrills->SetColSize( DRILL_TYPE_T::COL_STOP_LAYER, stopLayerColWidth );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -652,23 +636,21 @@ void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
wxFileName fn = m_parentFrame->GetBoard()->GetFileName();
|
wxFileName fn = m_parentFrame->GetBoard()->GetFileName();
|
||||||
boardName = fn.GetName();
|
boardName = fn.GetName();
|
||||||
wxFileDialog saveFileDialog( this, _( "Save Report File" ),
|
wxFileDialog dlg( this, _( "Save Report File" ), s_savedDialogState.saveReportFolder,
|
||||||
s_savedDialogState.saveReportFolder,
|
s_savedDialogState.saveReportName, TextFileWildcard(),
|
||||||
s_savedDialogState.saveReportName,
|
|
||||||
TextFileWildcard(),
|
|
||||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||||
|
|
||||||
if( saveFileDialog.ShowModal() == wxID_CANCEL )
|
if( dlg.ShowModal() == wxID_CANCEL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s_savedDialogState.saveReportFolder = wxPathOnly( saveFileDialog.GetPath() );
|
s_savedDialogState.saveReportFolder = wxPathOnly( dlg.GetPath() );
|
||||||
s_savedDialogState.saveReportName = saveFileDialog.GetFilename();
|
s_savedDialogState.saveReportName = dlg.GetFilename();
|
||||||
|
|
||||||
outFile = wxFopen( saveFileDialog.GetPath(), wxT( "wt" ) );
|
outFile = wxFopen( dlg.GetPath(), wxT( "wt" ) );
|
||||||
|
|
||||||
if( outFile == nullptr )
|
if( outFile == nullptr )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Failed to create file '%s'." ), saveFileDialog.GetPath() );
|
msg.Printf( _( "Failed to create file '%s'." ), dlg.GetPath() );
|
||||||
DisplayErrorMessage( this, msg );
|
DisplayErrorMessage( this, msg );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -701,13 +683,13 @@ void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent )
|
||||||
msg << wxT( "\n" );
|
msg << wxT( "\n" );
|
||||||
msg << _( "Pads" ) << wxT( "\n----\n" );
|
msg << _( "Pads" ) << wxT( "\n----\n" );
|
||||||
|
|
||||||
for( auto& type : m_padsTypes )
|
for( auto& type : m_padTypes )
|
||||||
msg << wxT( "- " ) << type.title << wxS( " " ) << type.qty << wxT( "\n" );
|
msg << wxT( "- " ) << type.title << wxS( " " ) << type.qty << wxT( "\n" );
|
||||||
|
|
||||||
msg << wxT( "\n" );
|
msg << wxT( "\n" );
|
||||||
msg << _( "Vias" ) << wxT( "\n----\n" );
|
msg << _( "Vias" ) << wxT( "\n----\n" );
|
||||||
|
|
||||||
for( auto& type : m_viasTypes )
|
for( auto& type : m_viaTypes )
|
||||||
msg << wxT( "- " ) << type.title << wxS( " " ) << type.qty << wxT( "\n" );
|
msg << wxT( "- " ) << type.title << wxS( " " ) << type.qty << wxT( "\n" );
|
||||||
|
|
||||||
// We will save data about components in the table.
|
// We will save data about components in the table.
|
||||||
|
@ -718,13 +700,13 @@ void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
widths.reserve( labels.size() );
|
widths.reserve( labels.size() );
|
||||||
|
|
||||||
for( const auto& label : labels )
|
for( const wxString& label : labels )
|
||||||
widths.push_back( label.size() );
|
widths.push_back( label.size() );
|
||||||
|
|
||||||
int frontTotal = 0;
|
int frontTotal = 0;
|
||||||
int backTotal = 0;
|
int backTotal = 0;
|
||||||
|
|
||||||
for( const auto& type : m_componentsTypes )
|
for( const FOOTPRINT_TYPE_T& type : 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>( type.title.size(), widths[0] );
|
||||||
|
@ -745,17 +727,17 @@ void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent )
|
||||||
msg << _( "Components" ) << wxT( "\n----------\n" );
|
msg << _( "Components" ) << wxT( "\n----------\n" );
|
||||||
msg << wxT( "\n" );
|
msg << wxT( "\n" );
|
||||||
|
|
||||||
printGridToStringAsTable( m_gridComponents, msg, false, false, true );
|
printGridToStringAsTable( m_gridComponents, msg, false, true );
|
||||||
|
|
||||||
msg << wxT( "\n" );
|
msg << wxT( "\n" );
|
||||||
msg << _( "Drill holes" ) << wxT( "\n-----------\n" );
|
msg << _( "Drill holes" ) << wxT( "\n-----------\n" );
|
||||||
msg << wxT( "\n" );
|
msg << wxT( "\n" );
|
||||||
|
|
||||||
printGridToStringAsTable( m_gridDrills, msg, false, true, false );
|
printGridToStringAsTable( m_gridDrills, msg, true, false );
|
||||||
|
|
||||||
if( fprintf( outFile, "%s", TO_UTF8( msg ) ) < 0 )
|
if( fprintf( outFile, "%s", TO_UTF8( msg ) ) < 0 )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Error writing file '%s'." ), saveFileDialog.GetPath() );
|
msg.Printf( _( "Error writing file '%s'." ), dlg.GetPath() );
|
||||||
DisplayErrorMessage( this, msg );
|
DisplayErrorMessage( this, msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,11 +753,11 @@ void DIALOG_BOARD_STATISTICS::drillGridSize( wxSizeEvent& aEvent )
|
||||||
|
|
||||||
void DIALOG_BOARD_STATISTICS::drillGridSort( wxGridEvent& aEvent )
|
void DIALOG_BOARD_STATISTICS::drillGridSort( wxGridEvent& aEvent )
|
||||||
{
|
{
|
||||||
drillType_t::COL_ID colId = static_cast<drillType_t::COL_ID>( aEvent.GetCol() );
|
DRILL_TYPE_T::COL_ID colId = static_cast<DRILL_TYPE_T::COL_ID>( aEvent.GetCol() );
|
||||||
bool ascending =
|
bool ascending = !( m_gridDrills->IsSortingBy( colId )
|
||||||
!( m_gridDrills->IsSortingBy( colId ) && m_gridDrills->IsSortOrderAscending() );
|
&& m_gridDrills->IsSortOrderAscending() );
|
||||||
|
|
||||||
sort( m_drillTypes.begin(), m_drillTypes.end(), drillType_t::COMPARE( colId, ascending ) );
|
sort( m_drillTypes.begin(), m_drillTypes.end(), DRILL_TYPE_T::COMPARE( colId, ascending ) );
|
||||||
|
|
||||||
updateDrillGrid();
|
updateDrillGrid();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,10 +47,10 @@ public:
|
||||||
* Type information, which will be shown in dialog.
|
* Type information, which will be shown in dialog.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct typeContainer_t
|
struct TYPE_CONTAINER_T
|
||||||
{
|
{
|
||||||
typeContainer_t<T>( T aAttribute, const wxString& aTitle )
|
TYPE_CONTAINER_T<T>( T aAttribute, const wxString& aTitle ) :
|
||||||
: attribute( aAttribute ),
|
attribute( aAttribute ),
|
||||||
title( aTitle ),
|
title( aTitle ),
|
||||||
qty( 0 )
|
qty( 0 )
|
||||||
{
|
{
|
||||||
|
@ -61,30 +61,29 @@ public:
|
||||||
int qty;
|
int qty;
|
||||||
};
|
};
|
||||||
|
|
||||||
using padsType_t = typeContainer_t<PAD_ATTRIB>;
|
|
||||||
using viasType_t = typeContainer_t<VIATYPE>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 bottom components quantities.
|
* dialog. Holds both front and back footprint quantities.
|
||||||
*/
|
*/
|
||||||
struct componentsType_t
|
struct FOOTPRINT_TYPE_T
|
||||||
{
|
{
|
||||||
componentsType_t( FOOTPRINT_ATTR_T aAttribute, wxString aTitle )
|
FOOTPRINT_TYPE_T( int aAttributeMask, int aAttributeValue, wxString aTitle ) :
|
||||||
: attribute( aAttribute ),
|
attribute_mask( aAttributeMask ),
|
||||||
|
attribute_value( aAttributeValue ),
|
||||||
title( aTitle ),
|
title( aTitle ),
|
||||||
frontSideQty( 0 ),
|
frontSideQty( 0 ),
|
||||||
backSideQty( 0 )
|
backSideQty( 0 )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FOOTPRINT_ATTR_T attribute;
|
int attribute_mask;
|
||||||
|
int attribute_value;
|
||||||
wxString title;
|
wxString title;
|
||||||
int frontSideQty;
|
int frontSideQty;
|
||||||
int backSideQty;
|
int backSideQty;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct drillType_t
|
struct DRILL_TYPE_T
|
||||||
{
|
{
|
||||||
enum COL_ID
|
enum COL_ID
|
||||||
{
|
{
|
||||||
|
@ -98,9 +97,9 @@ public:
|
||||||
COL_STOP_LAYER
|
COL_STOP_LAYER
|
||||||
};
|
};
|
||||||
|
|
||||||
drillType_t( int aXSize, int aYSize, PAD_DRILL_SHAPE_T aShape, bool aIsPlated, bool aIsPad,
|
DRILL_TYPE_T( int aXSize, int aYSize, PAD_DRILL_SHAPE_T aShape, bool aIsPlated,
|
||||||
PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aStopLayer, int aQty = 0 )
|
bool aIsPad, PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aStopLayer, int aQty ) :
|
||||||
: xSize( aXSize ),
|
xSize( aXSize ),
|
||||||
ySize( aYSize ),
|
ySize( aYSize ),
|
||||||
shape( aShape ),
|
shape( aShape ),
|
||||||
isPlated( aIsPlated ),
|
isPlated( aIsPlated ),
|
||||||
|
@ -111,7 +110,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==( const drillType_t& other )
|
bool operator==( const DRILL_TYPE_T& 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
|
||||||
|
@ -123,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 drillType_t& aLeft, const drillType_t& aRight )
|
bool operator()( const DRILL_TYPE_T& aLeft, const DRILL_TYPE_T& aRight )
|
||||||
{
|
{
|
||||||
switch( colId )
|
switch( colId )
|
||||||
{
|
{
|
||||||
|
@ -167,11 +166,6 @@ public:
|
||||||
int qty;
|
int qty;
|
||||||
};
|
};
|
||||||
|
|
||||||
using componentsTypeList_t = std::deque<componentsType_t>;
|
|
||||||
using padsTypeList_t = std::deque<padsType_t>;
|
|
||||||
using viasTypeList_t = std::deque<viasType_t>;
|
|
||||||
using drillTypeList_t = std::deque<drillType_t>;
|
|
||||||
|
|
||||||
DIALOG_BOARD_STATISTICS( PCB_EDIT_FRAME* aParentFrame );
|
DIALOG_BOARD_STATISTICS( PCB_EDIT_FRAME* aParentFrame );
|
||||||
~DIALOG_BOARD_STATISTICS();
|
~DIALOG_BOARD_STATISTICS();
|
||||||
|
|
||||||
|
@ -193,8 +187,8 @@ private:
|
||||||
void updateDrillGrid();
|
void updateDrillGrid();
|
||||||
|
|
||||||
///< Print grid to string in tabular format.
|
///< Print grid to string in tabular format.
|
||||||
void printGridToStringAsTable( wxGrid* aGrid, wxString& aStr, bool aUseRowLabels,
|
void printGridToStringAsTable( wxGrid* aGrid, wxString& aStr, bool aUseColLabels,
|
||||||
bool aUseColLabels, bool aUseFirstColAsLabel );
|
bool aUseFirstColAsLabel );
|
||||||
|
|
||||||
void adjustDrillGridColumns();
|
void adjustDrillGridColumns();
|
||||||
|
|
||||||
|
@ -213,26 +207,16 @@ private:
|
||||||
int m_boardHeight;
|
int m_boardHeight;
|
||||||
double m_boardArea;
|
double m_boardArea;
|
||||||
|
|
||||||
///< Show if board outline properly defined.
|
bool m_hasOutline; ///< Show if board outline properly defined.
|
||||||
bool m_hasOutline;
|
|
||||||
|
|
||||||
///< Hold all components types to be shown in the dialog.
|
std::deque<FOOTPRINT_TYPE_T> m_fpTypes;
|
||||||
componentsTypeList_t m_componentsTypes;
|
std::deque<TYPE_CONTAINER_T<PAD_ATTRIB>> m_padTypes;
|
||||||
|
std::deque<TYPE_CONTAINER_T<VIATYPE>> m_viaTypes;
|
||||||
|
std::deque<DRILL_TYPE_T> m_drillTypes;
|
||||||
|
|
||||||
///< Hold all pads types to be shown in the dialog.
|
int m_startLayerColInitialSize; ///< Width of the start layer column as calculated by
|
||||||
padsTypeList_t m_padsTypes;
|
///< the wxWidgets autosizing algorithm.
|
||||||
|
int m_stopLayerColInitialSize; ///< Width of the stop layer column.
|
||||||
///< Hold all vias types to be shown in the dialog.
|
|
||||||
viasTypeList_t m_viasTypes;
|
|
||||||
|
|
||||||
///< Hold all drill hole types to be shown in the dialog.
|
|
||||||
drillTypeList_t m_drillTypes;
|
|
||||||
|
|
||||||
///< Width of the start layer column as calculated by the wxWidgets autosizing algorithm.
|
|
||||||
int m_startLayerColInitialSize;
|
|
||||||
|
|
||||||
///< Width of the stop layer column as calculated by the wxWidgets autosizing algorithm.
|
|
||||||
int m_stopLayerColInitialSize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __DIALOG_BOARD_STATISTICS_H
|
#endif // __DIALOG_BOARD_STATISTICS_H
|
||||||
|
|
Loading…
Reference in New Issue