ERC/DRC reports: list what severities are part of the report
an ERC or DRC report without violations or without violations of a
particular kind does not tell the user whether there actually are no
violations of that severity, or if the severity was filtered.
we now list the severities by name that are included in the report.
(cherry picked from commit cd03794b23)
This commit is contained in:
committed by
Wayne Stambaugh
parent
662b7daf00
commit
a5f5298cad
@@ -129,6 +129,7 @@ set( KICOMMON_SRCS
|
||||
widgets/kistatusbar.cpp
|
||||
widgets/number_badge.cpp
|
||||
widgets/progress_reporter_base.cpp
|
||||
widgets/report_severity.cpp
|
||||
widgets/std_bitmap_button.cpp
|
||||
widgets/ui_common.cpp
|
||||
widgets/wx_html_report_panel.cpp
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <widgets/report_severity.h>
|
||||
#include <wx/intl.h>
|
||||
#include <i18n_utility.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
wxString formatSeverities( int aSeverities )
|
||||
{
|
||||
wxString result;
|
||||
std::vector<wxString> items;
|
||||
|
||||
if( aSeverities & RPT_SEVERITY_ERROR )
|
||||
items.push_back( _( "Errors" ) );
|
||||
|
||||
if( aSeverities & RPT_SEVERITY_WARNING )
|
||||
items.push_back( _( "Warnings" ) );
|
||||
|
||||
if( aSeverities & RPT_SEVERITY_EXCLUSION )
|
||||
items.push_back( _( "Exclusions" ) );
|
||||
|
||||
if( items.empty() )
|
||||
return _( "None" );
|
||||
|
||||
for( size_t i = 0; i < items.size(); i++ )
|
||||
{
|
||||
result += items[i];
|
||||
|
||||
if( i < items.size() - 1 )
|
||||
result += wxS( ", " );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -32,13 +32,15 @@
|
||||
#include <macros.h>
|
||||
#include <json_common.h>
|
||||
#include <rc_json_schema.h>
|
||||
#include <widgets/report_severity.h>
|
||||
|
||||
|
||||
ERC_REPORT::ERC_REPORT( SCHEMATIC* aSchematic, EDA_UNITS aReportUnits,
|
||||
std::shared_ptr<RC_ITEMS_PROVIDER> aMarkersProvider ) :
|
||||
m_sch( aSchematic ),
|
||||
m_reportUnits( aReportUnits ),
|
||||
m_markersProvider( std::move( aMarkersProvider ) )
|
||||
m_markersProvider( std::move( aMarkersProvider ) ),
|
||||
m_reportedSeverities( 0 )
|
||||
{
|
||||
if( !m_markersProvider )
|
||||
{
|
||||
@@ -47,6 +49,8 @@ ERC_REPORT::ERC_REPORT( SCHEMATIC* aSchematic, EDA_UNITS aReportUnits,
|
||||
m_markersProvider = std::make_shared<SHEETLIST_ERC_ITEMS_PROVIDER>( m_sch );
|
||||
m_markersProvider->SetSeverities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING );
|
||||
}
|
||||
|
||||
m_reportedSeverities = m_markersProvider->GetSeverities();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +61,9 @@ wxString ERC_REPORT::GetTextReport()
|
||||
wxString msg = wxString::Format( _( "ERC report (%s, Encoding UTF8)\n" ),
|
||||
GetISO8601CurrentDateTime() );
|
||||
|
||||
msg += wxString::Format( _( "Report includes: %s\n" ),
|
||||
formatSeverities( m_reportedSeverities ) );
|
||||
|
||||
std::map<KIID, EDA_ITEM*> itemMap;
|
||||
|
||||
int err_count = 0;
|
||||
@@ -138,6 +145,16 @@ bool ERC_REPORT::WriteJsonReport( const wxString& aFullFileName )
|
||||
reportHead.kicad_version = GetMajorMinorPatchVersion();
|
||||
reportHead.coordinate_units = EDA_UNIT_UTILS::GetLabel( m_reportUnits );
|
||||
|
||||
// Document which severities are included in this report
|
||||
if( m_reportedSeverities & RPT_SEVERITY_ERROR )
|
||||
reportHead.included_severities.push_back( wxS( "error" ) );
|
||||
|
||||
if( m_reportedSeverities & RPT_SEVERITY_WARNING )
|
||||
reportHead.included_severities.push_back( wxS( "warning" ) );
|
||||
|
||||
if( m_reportedSeverities & RPT_SEVERITY_EXCLUSION )
|
||||
reportHead.included_severities.push_back( wxS( "exclusion" ) );
|
||||
|
||||
SCH_SHEET_LIST sheetList = m_sch->Hierarchy();
|
||||
sheetList.FillItemMap( itemMap );
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ private:
|
||||
SCHEMATIC* m_sch;
|
||||
EDA_UNITS m_reportUnits;
|
||||
std::shared_ptr<RC_ITEMS_PROVIDER> m_markersProvider;
|
||||
int m_reportedSeverities;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -408,6 +408,12 @@ void SHEETLIST_ERC_ITEMS_PROVIDER::SetSeverities( int aSeverities )
|
||||
}
|
||||
|
||||
|
||||
int SHEETLIST_ERC_ITEMS_PROVIDER::GetSeverities() const
|
||||
{
|
||||
return m_severities;
|
||||
}
|
||||
|
||||
|
||||
int SHEETLIST_ERC_ITEMS_PROVIDER::GetCount( int aSeverity ) const
|
||||
{
|
||||
if( aSeverity < 0 )
|
||||
|
||||
@@ -256,6 +256,8 @@ public:
|
||||
|
||||
void SetSeverities( int aSeverities ) override;
|
||||
|
||||
int GetSeverities() const override;
|
||||
|
||||
int GetCount( int aSeverity = -1 ) const override;
|
||||
|
||||
std::shared_ptr<RC_ITEM> GetItem( int aIndex ) const override;
|
||||
|
||||
@@ -53,6 +53,8 @@ class RC_ITEMS_PROVIDER
|
||||
public:
|
||||
virtual void SetSeverities( int aSeverities ) = 0;
|
||||
|
||||
virtual int GetSeverities() const = 0;
|
||||
|
||||
virtual int GetCount( int aSeverity = -1 ) const = 0;
|
||||
|
||||
/**
|
||||
|
||||
@@ -99,10 +99,12 @@ struct DRC_REPORT : REPORT_BASE
|
||||
std::vector<VIOLATION> violations;
|
||||
std::vector<VIOLATION> unconnected_items;
|
||||
std::vector<VIOLATION> schematic_parity;
|
||||
std::vector<wxString> included_severities;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( DRC_REPORT, $schema, source, date, kicad_version, violations,
|
||||
unconnected_items, schematic_parity, coordinate_units )
|
||||
unconnected_items, schematic_parity, coordinate_units,
|
||||
included_severities )
|
||||
|
||||
struct ERC_SHEET
|
||||
{
|
||||
@@ -118,10 +120,11 @@ struct ERC_REPORT : REPORT_BASE
|
||||
ERC_REPORT() { type = wxS( "erc" ); }
|
||||
|
||||
std::vector<ERC_SHEET> sheets;
|
||||
std::vector<wxString> included_severities;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( ERC_REPORT, $schema, source, date, kicad_version, sheets,
|
||||
coordinate_units )
|
||||
coordinate_units, included_severities )
|
||||
|
||||
} // namespace RC_JSON
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef REPORT_SEVERITY_H
|
||||
#define REPORT_SEVERITY_H
|
||||
|
||||
#include <kicommon.h>
|
||||
#include <wx/string.h>
|
||||
|
||||
// Note: On windows, SEVERITY_ERROR collides with a system declaration,
|
||||
// so we used RPT_SEVERITY_xxx instead of SEVERITY_xxx
|
||||
enum SEVERITY {
|
||||
@@ -34,4 +37,11 @@ enum SEVERITY {
|
||||
RPT_SEVERITY_DEBUG = 0x80,
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert a severity mask to a human-readable comma-separated string.
|
||||
* @param aSeverities A bitmask of SEVERITY values
|
||||
* @return A translated string like "Errors, Warnings"
|
||||
*/
|
||||
KICOMMON_API wxString formatSeverities( int aSeverities );
|
||||
|
||||
#endif // REPORT_SEVERITY_H
|
||||
|
||||
@@ -78,6 +78,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
int GetSeverities() const override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetCount( int aSeverity = -1 ) const override
|
||||
{
|
||||
return m_sourceVector->size();
|
||||
|
||||
@@ -521,6 +521,12 @@ void DRC_ITEMS_PROVIDER::SetSeverities( int aSeverities )
|
||||
}
|
||||
|
||||
|
||||
int DRC_ITEMS_PROVIDER::GetSeverities() const
|
||||
{
|
||||
return m_severities;
|
||||
}
|
||||
|
||||
|
||||
int DRC_ITEMS_PROVIDER::GetCount( int aSeverity ) const
|
||||
{
|
||||
if( aSeverity < 0 )
|
||||
|
||||
@@ -270,6 +270,8 @@ public:
|
||||
|
||||
void SetSeverities( int aSeverities ) override;
|
||||
|
||||
int GetSeverities() const override;
|
||||
|
||||
int GetCount( int aSeverity = -1 ) const override;
|
||||
|
||||
std::shared_ptr<RC_ITEM> GetItem( int aIndex ) const override;
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <macros.h>
|
||||
#include <json_common.h>
|
||||
#include <rc_json_schema.h>
|
||||
#include <string_utils.h>
|
||||
#include <widgets/report_severity.h>
|
||||
|
||||
|
||||
DRC_REPORT::DRC_REPORT( BOARD* aBoard, EDA_UNITS aReportUnits,
|
||||
@@ -38,9 +40,11 @@ DRC_REPORT::DRC_REPORT( BOARD* aBoard, EDA_UNITS aReportUnits,
|
||||
m_reportUnits( aReportUnits ),
|
||||
m_markersProvider( std::move( aMarkersProvider ) ),
|
||||
m_ratsnestProvider( std::move( aRatsnestProvider ) ),
|
||||
m_fpWarningsProvider( std::move( aFpWarningsProvider ) )
|
||||
m_fpWarningsProvider( std::move( aFpWarningsProvider ) ),
|
||||
m_reportedSeverities( 0 )
|
||||
{
|
||||
|
||||
if( m_markersProvider )
|
||||
m_reportedSeverities = m_markersProvider->GetSeverities();
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +67,8 @@ bool DRC_REPORT::WriteTextReport( const wxString& aFullFileName )
|
||||
|
||||
fprintf( fp, "** Created on %s **\n", TO_UTF8( GetISO8601CurrentDateTime() ) );
|
||||
|
||||
fprintf( fp, "** Report includes: %s **\n", TO_UTF8( formatSeverities( m_reportedSeverities ) ) );
|
||||
|
||||
count = m_markersProvider->GetCount();
|
||||
|
||||
fprintf( fp, "\n** Found %d DRC violations **\n", count );
|
||||
@@ -129,6 +135,16 @@ bool DRC_REPORT::WriteJsonReport( const wxString& aFullFileName )
|
||||
reportHead.kicad_version = GetMajorMinorPatchVersion();
|
||||
reportHead.coordinate_units = EDA_UNIT_UTILS::GetLabel( m_reportUnits );
|
||||
|
||||
// Document which severities are included in this report
|
||||
if( m_reportedSeverities & RPT_SEVERITY_ERROR )
|
||||
reportHead.included_severities.push_back( wxS( "error" ) );
|
||||
|
||||
if( m_reportedSeverities & RPT_SEVERITY_WARNING )
|
||||
reportHead.included_severities.push_back( wxS( "warning" ) );
|
||||
|
||||
if( m_reportedSeverities & RPT_SEVERITY_EXCLUSION )
|
||||
reportHead.included_severities.push_back( wxS( "exclusion" ) );
|
||||
|
||||
for( int i = 0; i < m_markersProvider->GetCount(); ++i )
|
||||
{
|
||||
const std::shared_ptr<RC_ITEM>& item = m_markersProvider->GetItem( i );
|
||||
@@ -173,4 +189,4 @@ bool DRC_REPORT::WriteJsonReport( const wxString& aFullFileName )
|
||||
jsonFileStream.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ private:
|
||||
std::shared_ptr<RC_ITEMS_PROVIDER> m_markersProvider;
|
||||
std::shared_ptr<RC_ITEMS_PROVIDER> m_ratsnestProvider;
|
||||
std::shared_ptr<RC_ITEMS_PROVIDER> m_fpWarningsProvider;
|
||||
int m_reportedSeverities;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +50,18 @@
|
||||
"mils",
|
||||
"in"
|
||||
]
|
||||
},
|
||||
"included_severities": {
|
||||
"type": "array",
|
||||
"description": "List of severities included in this report (e.g., error, warning, exclusion)",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"error",
|
||||
"warning",
|
||||
"exclusion"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
||||
@@ -38,6 +38,18 @@
|
||||
"mils",
|
||||
"in"
|
||||
]
|
||||
},
|
||||
"included_severities": {
|
||||
"type": "array",
|
||||
"description": "List of severities included in this report (e.g., error, warning, exclusion)",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"error",
|
||||
"warning",
|
||||
"exclusion"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
||||
Reference in New Issue
Block a user