Fixes to map pin-to-pin erorrs to new Warning/Error strucutre.

This commit is contained in:
Jeff Young 2020-04-28 09:55:44 +01:00
parent 0c20c0b4af
commit 9d6b987ecc
9 changed files with 162 additions and 46 deletions

View File

@ -29,18 +29,22 @@
PANEL_SETUP_SEVERITIES::PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent, RC_ITEM& aDummyItem,
std::map<int, int>& aSeverities,
int aFirstErrorCode, int aLastErrorCode ) :
int aFirstErrorCode, int aLastErrorCode,
int aPinMapSpecialCase ) :
wxPanel( aParent->GetTreebook() ),
m_severities( aSeverities ),
m_firstErrorCode( aFirstErrorCode ),
m_lastErrorCode( aLastErrorCode )
m_lastErrorCode( aLastErrorCode ),
m_pinMapSpecialCase( aPinMapSpecialCase )
{
wxString severities[] = { _( "Error" ), _( "Warning" ), _( "Ignore" ) };
int severityCount = sizeof( severities ) / sizeof( wxString );
int baseID = 1000;
wxBoxSizer* panelSizer = new wxBoxSizer( wxVERTICAL );
wxScrolledWindow* scrollWin = new wxScrolledWindow( this, wxID_ANY,
wxDefaultPosition, wxDefaultSize,
wxTAB_TRAVERSAL | wxVSCROLL );
scrollWin->SetScrollRate( 0, 5 );
wxFlexGridSizer* gridSizer = new wxFlexGridSizer( 0, 2, 0, 5 );
@ -63,7 +67,7 @@ PANEL_SETUP_SEVERITIES::PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent, RC_ITEM&
wxPanel* radioPanel = new wxPanel( scrollWin );
wxBoxSizer* radioSizer = new wxBoxSizer( wxHORIZONTAL );
for( size_t i = 0; i < sizeof( severities ) / sizeof( wxString ); ++i )
for( size_t i = 0; i < severityCount; ++i )
{
m_buttonMap[ errorCode ][i] = new wxRadioButton( radioPanel,
baseID + errorCode * 10 + i,
@ -71,7 +75,7 @@ PANEL_SETUP_SEVERITIES::PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent, RC_ITEM&
wxDefaultPosition,
wxDefaultSize,
i == 0 ? wxRB_GROUP : 0 );
radioSizer->Add( m_buttonMap[ errorCode ][i], 1, wxRIGHT | wxEXPAND, 25 );
radioSizer->Add( m_buttonMap[ errorCode ][i], 0, wxRIGHT | wxEXPAND, 30 );
}
radioPanel->SetSizer( radioSizer );
@ -80,6 +84,42 @@ PANEL_SETUP_SEVERITIES::PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent, RC_ITEM&
}
}
if( m_pinMapSpecialCase >= 0 )
{
wxString pinMapSeverities[] = { _( "From Pin Conflicts Map" ), _( "" ), _( "Ignore" ) };
int errorCode = m_pinMapSpecialCase;
wxString msg = aDummyItem.GetErrorText( errorCode );
wxStaticText* errorLabel = new wxStaticText( scrollWin, wxID_ANY, msg + wxT( ":" ) );
gridSizer->Add( errorLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 4 );
wxPanel* radioPanel = new wxPanel( scrollWin );
wxBoxSizer* radioSizer = new wxBoxSizer( wxHORIZONTAL );
for( size_t i = 0; i < 3; ++i )
{
if( pinMapSeverities[i] == wxT( "" ) )
{
wxStaticText* spacer = new wxStaticText( radioPanel, wxID_ANY, wxT( "" ) );
radioSizer->Add( spacer, 0, wxRIGHT | wxEXPAND, 17 );
}
else
{
m_buttonMap[ errorCode ][i] = new wxRadioButton( radioPanel,
baseID + errorCode * 10 + i,
pinMapSeverities[i],
wxDefaultPosition,
wxDefaultSize,
i == 0 ? wxRB_GROUP : 0 );
radioSizer->Add( m_buttonMap[ errorCode ][i], 0, wxEXPAND );
}
}
radioPanel->SetSizer( radioSizer );
radioPanel->Layout();
gridSizer->Add( radioPanel, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 4 );
}
scrollWin->SetSizer( gridSizer );
scrollWin->Layout();
gridSizer->Fit( scrollWin );
@ -106,6 +146,14 @@ void PANEL_SETUP_SEVERITIES::ImportSettingsFrom( std::map<int, int>& aSettings )
default: break;
}
}
if( m_pinMapSpecialCase >= 0 )
{
int newSeverity = aSettings[ m_pinMapSpecialCase ];
m_buttonMap[ m_pinMapSpecialCase ][0]->SetValue( newSeverity != RPT_SEVERITY_IGNORE );
m_buttonMap[ m_pinMapSpecialCase ][1]->SetValue( newSeverity == RPT_SEVERITY_IGNORE );
}
}
@ -113,7 +161,7 @@ bool PANEL_SETUP_SEVERITIES::TransferDataToWindow()
{
for( int errorCode = m_firstErrorCode; errorCode <= m_lastErrorCode; ++errorCode )
{
if(! m_buttonMap[ errorCode ][0] ) // this entry does not actually exist
if( !m_buttonMap[ errorCode ][0] ) // this entry does not actually exist
continue;
switch( m_severities[ errorCode ] )
@ -125,27 +173,47 @@ bool PANEL_SETUP_SEVERITIES::TransferDataToWindow()
}
}
if( m_pinMapSpecialCase >= 0 )
{
int severity = m_severities[ m_pinMapSpecialCase ];
m_buttonMap[ m_pinMapSpecialCase ][0]->SetValue( severity != RPT_SEVERITY_IGNORE );
m_buttonMap[ m_pinMapSpecialCase ][2]->SetValue( severity == RPT_SEVERITY_IGNORE );
}
return true;
}
bool PANEL_SETUP_SEVERITIES::TransferDataFromWindow()
{
for( auto const& entry : m_buttonMap )
for( int errorCode = m_firstErrorCode; errorCode <= m_lastErrorCode; ++errorCode )
{
if( !entry.second[0] ) // this entry does not actually exist
if( !m_buttonMap[ errorCode ][0] ) // this entry does not actually exist
continue;
int severity = RPT_SEVERITY_UNDEFINED;
if( entry.second[0]->GetValue() )
if( m_buttonMap[ errorCode ][0]->GetValue() )
severity = RPT_SEVERITY_ERROR;
else if( entry.second[1]->GetValue() )
else if( m_buttonMap[ errorCode ][1]->GetValue() )
severity = RPT_SEVERITY_WARNING;
else if( entry.second[2]->GetValue() )
else if( m_buttonMap[ errorCode ][2]->GetValue() )
severity = RPT_SEVERITY_IGNORE;
m_severities[ entry.first ] = severity;
m_severities[ errorCode ] = severity;
}
if( m_pinMapSpecialCase >= 0 )
{
int severity = RPT_SEVERITY_UNDEFINED;
if( m_buttonMap[ m_pinMapSpecialCase ][0]->GetValue() )
severity = RPT_SEVERITY_ERROR;
else if( m_buttonMap[ m_pinMapSpecialCase ][2]->GetValue() )
severity = RPT_SEVERITY_IGNORE;
m_severities[ m_pinMapSpecialCase ] = severity;
}
return true;

View File

@ -37,15 +37,17 @@ class wxRadioBox;
class PANEL_SETUP_SEVERITIES : public wxPanel
{
private:
std::map<int, int>& m_severities;
int m_firstErrorCode;
int m_lastErrorCode;
std::map<int, int>& m_severities;
int m_firstErrorCode;
int m_lastErrorCode;
int m_pinMapSpecialCase;
std::map<int, wxRadioButton*[4]> m_buttonMap; // map from DRC error code to button group
public:
PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent, RC_ITEM& aDummyItem,
std::map<int, int>& aSeverities, int aFirstError, int aLastError );
std::map<int, int>& aSeverities, int aFirstError, int aLastError,
int aPinMapSpecialCase = -1 );
void ImportSettingsFrom( std::map<int, int>& aSettings );

View File

@ -416,29 +416,40 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
menu.AppendSeparator();
if( GetSeverity( rcItem->GetErrorCode() ) == RPT_SEVERITY_WARNING )
if( rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_WARNING
|| rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_ERROR )
{
msg.Printf( _( "Change severity to Error for all '%s' violations" ),
rcItem->GetErrorText( rcItem->GetErrorCode() ),
_( "Violation severities can also be edited in the Board Setup... dialog" ) );
menu.Append( 3, msg );
// Pin to pin severities edited through pin conflict map
}
else if( GetSeverity( rcItem->GetErrorCode() ) == RPT_SEVERITY_WARNING )
{
menu.Append( 4, wxString::Format( _( "Change severity to Error for all '%s' violations" ),
rcItem->GetErrorText( rcItem->GetErrorCode() ) ),
_( "Violation severities can also be edited in the Board Setup... dialog" ) );
}
else
{
msg.Printf( _( "Change severity to Warning for all '%s' violations" ),
rcItem->GetErrorText( rcItem->GetErrorCode() ),
_( "Violation severities can also be edited in the Board Setup... dialog" ) );
menu.Append( 4, msg );
menu.Append( 5, wxString::Format( _( "Change severity to Warning for all '%s' violations" ),
rcItem->GetErrorText( rcItem->GetErrorCode() ) ),
_( "Violation severities can also be edited in the Board Setup... dialog" ) );
}
msg.Printf( _( "Ignore all '%s' violations" ),
rcItem->GetErrorText( rcItem->GetErrorCode() ),
_( "Violations will not be checked or reported" ) );
menu.Append( 5, msg );
menu.Append( 6, wxString::Format( _( "Ignore all '%s' violations" ),
rcItem->GetErrorText( rcItem->GetErrorCode() ) ),
_( "Violations will not be checked or reported" ) );
menu.AppendSeparator();
menu.Append( 6, _( "Edit violation severities..." ), _( "Open the Schematic Setup... dialog" ) );
if( rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_WARNING
|| rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_ERROR )
{
menu.Append( 7, _( "Edit pin-to-pin conflict map..." ) );
}
else
{
menu.Append( 8, _( "Edit violation severities..." ),
_( "Open the Schematic Setup... dialog" ) );
}
switch( GetPopupMenuSelectionFromUser( menu ) )
{
@ -462,7 +473,7 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
updateDisplayedCounts();
break;
case 3:
case 4:
SetSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_ERROR );
// Rebuild model and view
@ -470,7 +481,7 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
updateDisplayedCounts();
break;
case 4:
case 5:
SetSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_WARNING );
// Rebuild model and view
@ -478,10 +489,13 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
updateDisplayedCounts();
break;
case 5:
case 6:
{
SetSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_IGNORE );
if( rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_ERROR )
SetSeverity( ERCE_PIN_TO_PIN_WARNING, RPT_SEVERITY_IGNORE );
SCH_SCREENS ScreenList;
ScreenList.DeleteMarkers( MARKER_BASE::MARKER_ERC, rcItem->GetErrorCode() );
@ -491,7 +505,11 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
}
break;
case 6:
case 7:
m_parent->DoShowSchematicSetupDialog( _( "Pin Conflicts Map" ) );
break;
case 8:
m_parent->DoShowSchematicSetupDialog( _( "Violation Severity" ) );
break;
}
@ -606,7 +624,7 @@ bool DIALOG_ERC::writeReport( const wxString& aFullFileName )
total_count++;
switch( g_ErcSettings->m_Severities[ marker->GetRCItem()->GetErrorCode() ] )
switch( GetSeverity( marker->GetRCItem()->GetErrorCode() ) )
{
case RPT_SEVERITY_ERROR: err_count++; break;
case RPT_SEVERITY_WARNING: warn_count++; break;

View File

@ -42,7 +42,7 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
ERC_ITEM dummyItem( 0 );
m_severities = new PANEL_SETUP_SEVERITIES( this, dummyItem, g_ErcSettings->m_Severities,
ERCE_FIRST, ERCE_LAST );
ERCE_FIRST, ERCE_LAST, ERCE_PIN_TO_PIN_WARNING );
m_textVars = new PANEL_TEXT_VARIABLES( m_treebook, &Prj() );
@ -55,8 +55,8 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
m_treebook->AddSubPage( m_fieldNameTemplates, _( "Field Name Templates" ) );
m_treebook->AddPage( new wxPanel( this ), _( "Electrical Rules" ) );
m_treebook->AddSubPage( m_pinMap, _( "Pin Conflicts Map" ) );
m_treebook->AddSubPage( m_severities, _( "Violation Severity" ) );
m_treebook->AddSubPage( m_pinMap, _( "Pin Conflicts Map" ) );
m_treebook->AddPage( new wxPanel( this ), _( "Project" ) );
m_treebook->AddSubPage( m_textVars, _( "Text Variables" ) );

View File

@ -209,6 +209,24 @@ public:
int GetSeverity( int aErrorCode )
{
// Special-case pin-to-pin errors:
// Ignore-or-not is controlled by ERCE_PIN_TO_PIN_WARNING (for both)
// Warning-or-error is controlled by which errorCode it is
if( aErrorCode == ERCE_PIN_TO_PIN_ERROR )
{
if( g_ErcSettings->m_Severities[ ERCE_PIN_TO_PIN_WARNING ] == RPT_SEVERITY_IGNORE )
return RPT_SEVERITY_IGNORE;
else
return RPT_SEVERITY_ERROR;
}
else if( aErrorCode == ERCE_PIN_TO_PIN_WARNING )
{
if( g_ErcSettings->m_Severities[ ERCE_PIN_TO_PIN_WARNING ] == RPT_SEVERITY_IGNORE )
return RPT_SEVERITY_IGNORE;
else
return RPT_SEVERITY_WARNING;
}
return g_ErcSettings->m_Severities[ aErrorCode ];
}

View File

@ -427,6 +427,15 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef, unsigned
if( aNetItemRef == netItemTst )
continue;
if( netItemTst < aList->size() )
{
ELECTRICAL_PINTYPE test_elect_type = aList->GetItem( netItemTst )->m_ElectricalPinType;
erc = PinMap[static_cast<int>( ref_elect_type )][static_cast<int>(test_elect_type )];
}
if( erc != OK )
Diagnose( aList->GetItem( aNetItemRef ), aList->GetItem( netItemTst ), 1, erc );
// We examine only a given net. We stop the search if the net changes
if( ( netItemTst >= aList->size() ) // End of list
|| ( aList->GetItemNet( aNetItemRef ) !=
@ -528,8 +537,6 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef, unsigned
{
if( aList->GetConnectionType( netItemTst ) == NET_CONNECTION::UNCONNECTED )
{
Diagnose( aList->GetItem( aNetItemRef ), aList->GetItem( netItemTst ),
0, erc );
aList->SetConnectionType( netItemTst,
NET_CONNECTION::NOCONNECT_SYMBOL_PRESENT );
}

View File

@ -56,8 +56,6 @@ enum ERCE_T
ERCE_DUPLICATE_SHEET_NAME = ERCE_FIRST, // duplicate sheet names within a given sheet
ERCE_PIN_NOT_CONNECTED, // pin not connected and not no connect symbol
ERCE_PIN_NOT_DRIVEN, // pin connected to some others pins but no pin to drive it
ERCE_PIN_TO_PIN_WARNING, // pin connected to an other pin: warning level
ERCE_PIN_TO_PIN_ERROR, // pin connected to an other pin: error level
ERCE_HIERACHICAL_LABEL, // mismatch between hierarchical labels and pins sheets
ERCE_NOCONNECT_CONNECTED, // a no connect symbol is connected to more than 1 pin
ERCE_NOCONNECT_NOT_CONNECTED, // a no connect symbol is not connected to anything
@ -73,7 +71,12 @@ enum ERCE_T
ERCE_BUS_TO_NET_CONFLICT, // a bus wire is graphically connected to a net port/pin (or vice versa)
ERCE_GLOBLABEL, // a global label is unique
ERCE_UNRESOLVED_VARIABLE,
ERCE_LAST = ERCE_UNRESOLVED_VARIABLE
ERCE_LAST = ERCE_UNRESOLVED_VARIABLE,
// Errors after this point will not automatically appear in the Severities Panel
ERCE_PIN_TO_PIN_WARNING, // pin connected to an other pin: warning level
ERCE_PIN_TO_PIN_ERROR, // pin connected to an other pin: error level
};
/* Minimal connection table */

View File

@ -46,9 +46,9 @@ wxString ERC_ITEM::GetErrorText( int aErrorCode ) const
case ERCE_PIN_NOT_DRIVEN:
return wxString( _( "Pin connected to other pins, but not driven by any pin" ) );
case ERCE_PIN_TO_PIN_WARNING:
return wxString( _("Conflict problem between pins. Severity: warning") );
KI_FALLTHROUGH; // Must share text with ERCE_PIN_TO_PIN_ERROR
case ERCE_PIN_TO_PIN_ERROR:
return wxString( _("Conflict problem between pins. Severity: error") );
return wxString( _("Conflict problem between pins") );
case ERCE_HIERACHICAL_LABEL:
return wxString( _("Mismatch between hierarchical labels and pins sheets") );
case ERCE_NOCONNECT_CONNECTED:
@ -81,6 +81,6 @@ wxString ERC_ITEM::GetErrorText( int aErrorCode ) const
return wxString( _( "Unresolved text variable" ) );
default:
wxFAIL_MSG( "Missing ERC error description" );
return wxString( wxT("Unknown.") );
return wxString( wxT( "Unknown" ) );
}
}

View File

@ -77,7 +77,7 @@ void SCH_MARKER::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 2;
switch( g_ErcSettings->m_Severities[ m_rcItem->GetErrorCode() ] )
switch( GetSeverity( m_rcItem->GetErrorCode() ) )
{
default:
case SEVERITY::RPT_SEVERITY_ERROR: aLayers[0] = LAYER_ERC_ERR; break;
@ -93,7 +93,7 @@ SCH_LAYER_ID SCH_MARKER::GetColorLayer() const
if( IsExcluded() )
return LAYER_HIDDEN;
switch( g_ErcSettings->m_Severities[ m_rcItem->GetErrorCode() ] )
switch( GetSeverity( m_rcItem->GetErrorCode() ) )
{
default:
case SEVERITY::RPT_SEVERITY_ERROR: return LAYER_ERC_ERR;