diff --git a/eeschema/dialogs/panel_setup_pinmap.cpp b/eeschema/dialogs/panel_setup_pinmap.cpp index c10acb383b..f19345150b 100644 --- a/eeschema/dialogs/panel_setup_pinmap.cpp +++ b/eeschema/dialogs/panel_setup_pinmap.cpp @@ -42,9 +42,12 @@ #define ID_MATRIX_0 1800 +// NC is not included in the pin map as it generates errors separately +#define PINMAP_TYPE_COUNT ( ELECTRICAL_PINTYPES_TOTAL - 1 ) + + BEGIN_EVENT_TABLE( PANEL_SETUP_PINMAP, PANEL_SETUP_PINMAP_BASE ) - EVT_COMMAND_RANGE( ID_MATRIX_0, - ID_MATRIX_0 + ( ELECTRICAL_PINTYPES_TOTAL * ELECTRICAL_PINTYPES_TOTAL ) - 1, + EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PINMAP_TYPE_COUNT * PINMAP_TYPE_COUNT ) - 1, wxEVT_COMMAND_BUTTON_CLICKED, PANEL_SETUP_PINMAP::changeErrorLevel ) END_EVENT_TABLE() @@ -66,7 +69,7 @@ PANEL_SETUP_PINMAP::~PANEL_SETUP_PINMAP() #ifndef __WXMAC__ if( m_initialized ) { - for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ ) + for( int ii = 0; ii < PINMAP_TYPE_COUNT; ii++ ) { for( int jj = 0; jj <= ii; jj++ ) { @@ -129,7 +132,7 @@ void PANEL_SETUP_PINMAP::reBuildMatrixPanel() std::vector labels; // Print row labels - for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ ) + for( int ii = 0; ii < PINMAP_TYPE_COUNT; ii++ ) { int y = pos.y + ( ii * ( bitmapSize.y + text_padding.y ) ); text = new wxStaticText( m_matrixPanel, - 1, CommentERC_H[ii], @@ -141,7 +144,7 @@ void PANEL_SETUP_PINMAP::reBuildMatrixPanel() } // Right-align - for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ ) + for( int ii = 0; ii < PINMAP_TYPE_COUNT; ii++ ) { wxPoint labelPos = labels[ ii ]->GetPosition(); labelPos.x = pos.x - labels[ ii ]->GetRect().GetWidth(); @@ -156,7 +159,7 @@ void PANEL_SETUP_PINMAP::reBuildMatrixPanel() pos = m_buttonList[0][0]->GetPosition(); } - for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ ) + for( int ii = 0; ii < PINMAP_TYPE_COUNT; ii++ ) { int y = pos.y + (ii * ( bitmapSize.y + text_padding.y ) ); @@ -178,7 +181,7 @@ void PANEL_SETUP_PINMAP::reBuildMatrixPanel() new wxStaticText( m_matrixPanel, wxID_ANY, "|", calloutPos ); } - int id = ID_MATRIX_0 + ii + ( jj * ELECTRICAL_PINTYPES_TOTAL ); + int id = ID_MATRIX_0 + ii + ( jj * PINMAP_TYPE_COUNT ); BITMAPS bitmap_butt = BITMAPS::erc_green; #ifdef __WXMAC__ @@ -250,8 +253,8 @@ void PANEL_SETUP_PINMAP::changeErrorLevel( wxCommandEvent& event ) { int id = event.GetId(); int ii = id - ID_MATRIX_0; - ELECTRICAL_PINTYPE x = static_cast( ii / ELECTRICAL_PINTYPES_TOTAL ); - ELECTRICAL_PINTYPE y = static_cast( ii % ELECTRICAL_PINTYPES_TOTAL ); + ELECTRICAL_PINTYPE x = static_cast( ii / PINMAP_TYPE_COUNT ); + ELECTRICAL_PINTYPE y = static_cast( ii % PINMAP_TYPE_COUNT ); wxWindow* butt = static_cast( event.GetEventObject() ); int level = static_cast( m_schematic->ErcSettings().GetPinMapValue( y, x ) ); @@ -266,7 +269,7 @@ void PANEL_SETUP_PINMAP::changeErrorLevel( wxCommandEvent& event ) void PANEL_SETUP_PINMAP::ImportSettingsFrom( PIN_ERROR aPinMap[][ELECTRICAL_PINTYPES_TOTAL] ) { - for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ ) + for( int ii = 0; ii < PINMAP_TYPE_COUNT; ii++ ) { for( int jj = 0; jj <= ii; jj++ ) setDRCMatrixButtonState( m_buttonList[ii][jj], aPinMap[ii][jj] ); diff --git a/eeschema/dialogs/panel_setup_pinmap_base.cpp b/eeschema/dialogs/panel_setup_pinmap_base.cpp index 5294b76e43..16b9d8e05d 100644 --- a/eeschema/dialogs/panel_setup_pinmap_base.cpp +++ b/eeschema/dialogs/panel_setup_pinmap_base.cpp @@ -18,12 +18,12 @@ PANEL_SETUP_PINMAP_BASE::PANEL_SETUP_PINMAP_BASE( wxWindow* parent, wxWindowID i m_panelMatrixSizer = new wxBoxSizer( wxVERTICAL ); m_matrixPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_matrixPanel->SetMinSize( wxSize( 500,444 ) ); + m_matrixPanel->SetMinSize( wxSize( 500,424 ) ); m_panelMatrixSizer->Add( m_matrixPanel, 1, wxEXPAND | wxALL, 5 ); - bSizer2->Add( m_panelMatrixSizer, 1, wxEXPAND, 10 ); + bSizer2->Add( m_panelMatrixSizer, 1, wxEXPAND|wxTOP, 5 ); this->SetSizer( bSizer2 ); diff --git a/eeschema/dialogs/panel_setup_pinmap_base.fbp b/eeschema/dialogs/panel_setup_pinmap_base.fbp index 6b49da813b..f12bd500cb 100644 --- a/eeschema/dialogs/panel_setup_pinmap_base.fbp +++ b/eeschema/dialogs/panel_setup_pinmap_base.fbp @@ -58,8 +58,8 @@ wxHORIZONTAL none - 10 - wxEXPAND + 5 + wxEXPAND|wxTOP 1 @@ -103,7 +103,7 @@ 0 - 500,444 + 500,424 1 m_matrixPanel 1 diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 745a4fb93f..56fa9e8c26 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -552,7 +552,14 @@ int ERC_TESTER::TestNoConnectPins() for( const SCH_SHEET_PATH& sheet : m_schematic->GetSheets() ) { - std::map> pinMap; + std::map> pinMap; + + auto addOther = + [&]( const VECTOR2I& pt, SCH_ITEM* aOther ) + { + if( pinMap.count( pt ) ) + pinMap[pt].emplace_back( aOther ); + }; for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) ) { @@ -565,7 +572,26 @@ int ERC_TESTER::TestNoConnectPins() } } - for( const std::pair>& pair : pinMap ) + for( SCH_ITEM* item : sheet.LastScreen()->Items() ) + { + if( item->Type() == SCH_SYMBOL_T ) + { + SCH_SYMBOL* symbol = static_cast( item ); + + for( SCH_PIN* pin : symbol->GetPins( &sheet ) ) + { + if( pin->GetLibPin()->GetType() != ELECTRICAL_PINTYPE::PT_NC ) + addOther( pin->GetPosition(), pin ); + } + } + else if( item->IsConnectable() ) + { + for( const VECTOR2I& pt : item->GetConnectionPoints() ) + addOther( pt, item ); + } + } + + for( const std::pair>& pair : pinMap ) { if( pair.second.size() > 1 ) { @@ -576,7 +602,7 @@ int ERC_TESTER::TestNoConnectPins() ercItem->SetItems( pair.second[0], pair.second[1], pair.second.size() > 2 ? pair.second[2] : nullptr, pair.second.size() > 3 ? pair.second[3] : nullptr ); - ercItem->SetErrorMessage( _( "Pins with 'no connection' type are connected" ) ); + ercItem->SetErrorMessage( _( "Pin with 'no connection' type is connected" ) ); SCH_MARKER* marker = new SCH_MARKER( ercItem, pair.first ); sheet.LastScreen()->Append( marker );