Restore severity in saved DRC/ERC reports.
Fixes https://gitlab.com/kicad/code/kicad/issues/5733
This commit is contained in:
parent
1b77c4c270
commit
c6fb799fcd
|
@ -50,8 +50,23 @@ wxString RC_ITEM::ShowCoord( EDA_UNITS aUnits, const wxPoint& aPos )
|
|||
}
|
||||
|
||||
|
||||
wxString RC_ITEM::ShowReport( EDA_UNITS aUnits, const std::map<KIID, EDA_ITEM*>& aItemMap ) const
|
||||
wxString RC_ITEM::ShowReport( EDA_UNITS aUnits, SEVERITY aSeverity,
|
||||
const std::map<KIID, EDA_ITEM*>& aItemMap ) const
|
||||
{
|
||||
wxString severity;
|
||||
|
||||
switch( aSeverity )
|
||||
{
|
||||
case RPT_SEVERITY_ERROR: severity = wxT( "Severity: error" );
|
||||
case RPT_SEVERITY_WARNING: severity = wxT( "Severity: warning" );
|
||||
case RPT_SEVERITY_ACTION: severity = wxT( "Severity: action" );
|
||||
case RPT_SEVERITY_INFO: severity = wxT( "Severity: info" );
|
||||
default: ;
|
||||
};
|
||||
|
||||
if( m_parent && m_parent->IsExcluded() )
|
||||
severity += wxT( " (excluded)" );
|
||||
|
||||
EDA_ITEM* mainItem = nullptr;
|
||||
EDA_ITEM* auxItem = nullptr;
|
||||
|
||||
|
@ -65,11 +80,17 @@ wxString RC_ITEM::ShowReport( EDA_UNITS aUnits, const std::map<KIID, EDA_ITEM*>&
|
|||
if( ii != aItemMap.end() )
|
||||
auxItem = ii->second;
|
||||
|
||||
// Note: some customers machine-process these. So:
|
||||
// 1) don't translate
|
||||
// 2) try not to re-order or change syntax
|
||||
// 3) report numeric error code (which should be more stable) in addition to message
|
||||
|
||||
if( mainItem && auxItem )
|
||||
{
|
||||
return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ),
|
||||
return wxString::Format( wxT( "ErrType(%d): %s %s\n %s: %s\n %s: %s\n" ),
|
||||
GetErrorCode(),
|
||||
GetErrorMessage(),
|
||||
severity,
|
||||
ShowCoord( aUnits, mainItem->GetPosition() ),
|
||||
mainItem->GetSelectMenuText( aUnits ),
|
||||
ShowCoord( aUnits, auxItem->GetPosition() ),
|
||||
|
@ -77,17 +98,19 @@ wxString RC_ITEM::ShowReport( EDA_UNITS aUnits, const std::map<KIID, EDA_ITEM*>&
|
|||
}
|
||||
else if( mainItem )
|
||||
{
|
||||
return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n" ),
|
||||
return wxString::Format( wxT( "ErrType(%d): %s %s\n %s: %s\n" ),
|
||||
GetErrorCode(),
|
||||
GetErrorMessage(),
|
||||
severity,
|
||||
ShowCoord( aUnits, mainItem->GetPosition() ),
|
||||
mainItem->GetSelectMenuText( aUnits ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxString::Format( wxT( "ErrType(%d): %s\n" ),
|
||||
return wxString::Format( wxT( "ErrType(%d): %s %s\n" ),
|
||||
GetErrorCode(),
|
||||
GetErrorMessage() );
|
||||
GetErrorMessage(),
|
||||
severity );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <wx/dataview.h>
|
||||
#include <macros.h>
|
||||
#include <base_struct.h>
|
||||
#include <reporter.h>
|
||||
|
||||
class MARKER_BASE;
|
||||
class EDA_BASE_FRAME;
|
||||
|
@ -150,7 +151,7 @@ public:
|
|||
* translates this object into a text string suitable for saving to disk in a report.
|
||||
* @return wxString - the simple multi-line report text.
|
||||
*/
|
||||
virtual wxString ShowReport( EDA_UNITS aUnits,
|
||||
virtual wxString ShowReport( EDA_UNITS aUnits, SEVERITY aSeverity,
|
||||
const std::map<KIID, EDA_ITEM*>& aItemMap ) const;
|
||||
|
||||
int GetErrorCode() const { return m_errorCode; }
|
||||
|
|
|
@ -586,20 +586,22 @@ bool DIALOG_ERC::writeReport( const wxString& aFullFileName )
|
|||
for( SCH_ITEM* aItem : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) )
|
||||
{
|
||||
const SCH_MARKER* marker = static_cast<const SCH_MARKER*>( aItem );
|
||||
RC_ITEM* item = marker->GetRCItem().get();
|
||||
SEVERITY severity = (SEVERITY)settings.GetSeverity( item->GetErrorCode() );
|
||||
|
||||
if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC )
|
||||
continue;
|
||||
|
||||
total_count++;
|
||||
|
||||
switch( settings.GetSeverity( marker->GetRCItem()->GetErrorCode() ) )
|
||||
switch( severity )
|
||||
{
|
||||
case RPT_SEVERITY_ERROR: err_count++; break;
|
||||
case RPT_SEVERITY_WARNING: warn_count++; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
msg << marker->GetRCItem()->ShowReport( GetUserUnits(), itemMap );
|
||||
msg << marker->GetRCItem()->ShowReport( GetUserUnits(), severity, itemMap );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -640,8 +640,9 @@ bool DIALOG_DRC::writeReport( const wxString& aFullFileName )
|
|||
std::map<KIID, EDA_ITEM*> itemMap;
|
||||
m_brdEditor->GetBoard()->FillItemMap( itemMap );
|
||||
|
||||
int count;
|
||||
EDA_UNITS units = GetUserUnits();
|
||||
EDA_UNITS units = GetUserUnits();
|
||||
BOARD_DESIGN_SETTINGS& bds = m_brdEditor->GetBoard()->GetDesignSettings();
|
||||
int count;
|
||||
|
||||
fprintf( fp, "** Drc report for %s **\n", TO_UTF8( m_brdEditor->GetBoard()->GetFileName() ) );
|
||||
|
||||
|
@ -654,21 +655,36 @@ bool DIALOG_DRC::writeReport( const wxString& aFullFileName )
|
|||
fprintf( fp, "\n** Found %d DRC violations **\n", count );
|
||||
|
||||
for( int i = 0; i < count; ++i )
|
||||
fprintf( fp, "%s", TO_UTF8( m_markersProvider->GetItem( i )->ShowReport( units, itemMap ) ) );
|
||||
{
|
||||
const std::shared_ptr<RC_ITEM>& item = m_markersProvider->GetItem( i );
|
||||
SEVERITY severity = (SEVERITY) bds.GetSeverity( item->GetErrorCode() );
|
||||
|
||||
fprintf( fp, "%s", TO_UTF8( item->ShowReport( units, severity, itemMap ) ) );
|
||||
}
|
||||
|
||||
count = m_unconnectedItemsProvider->GetCount();
|
||||
|
||||
fprintf( fp, "\n** Found %d unconnected pads **\n", count );
|
||||
|
||||
for( int i = 0; i < count; ++i )
|
||||
fprintf( fp, "%s", TO_UTF8( m_unconnectedItemsProvider->GetItem( i )->ShowReport( units, itemMap ) ) );
|
||||
{
|
||||
const std::shared_ptr<RC_ITEM>& item = m_unconnectedItemsProvider->GetItem( i );
|
||||
SEVERITY severity = (SEVERITY) bds.GetSeverity( item->GetErrorCode() );
|
||||
|
||||
fprintf( fp, "%s", TO_UTF8( item->ShowReport( units, severity, itemMap ) ) );
|
||||
}
|
||||
|
||||
count = m_footprintWarningsProvider->GetCount();
|
||||
|
||||
fprintf( fp, "\n** Found %d Footprint errors **\n", count );
|
||||
|
||||
for( int i = 0; i < count; ++i )
|
||||
fprintf( fp, "%s", TO_UTF8( m_footprintWarningsProvider->GetItem( i )->ShowReport( units, itemMap ) ) );
|
||||
{
|
||||
const std::shared_ptr<RC_ITEM>& item = m_footprintWarningsProvider->GetItem( i );
|
||||
SEVERITY severity = (SEVERITY) bds.GetSeverity( item->GetErrorCode() );
|
||||
|
||||
fprintf( fp, "%s", TO_UTF8( item->ShowReport( units, severity, itemMap ) ) );
|
||||
}
|
||||
|
||||
|
||||
fprintf( fp, "\n** End of Report **\n" );
|
||||
|
|
Loading…
Reference in New Issue