40 std::shared_ptr<RC_ITEMS_PROVIDER> aMarkersProvider ) :
65 wxString msg = wxString::Format( wxT(
"ERC report (%s, Encoding UTF8)\n" ),
68 msg += wxString::Format( wxT(
"Report includes: %s\n" ),
71 std::map<KIID, EDA_ITEM*> itemMap;
82 std::map<SCH_SHEET_PATH, std::vector<ERC_ITEM*>> orderedItems;
88 if( item->MainItemHasSheetPath() )
89 orderedItems[item->GetMainItemSheetPath()].emplace_back( item );
91 orderedItems[sheetList[0]].emplace_back( item );
95 for(
unsigned i = 0; i < sheetList.size(); i++ )
97 msg << wxString::Format( wxT(
"\n***** Sheet %s\n" ), sheetList[i].PathHumanReadable() );
99 for(
ERC_ITEM* item : orderedItems[sheetList[i]] )
112 msg << item->ShowReport( &unitsProvider, severity, itemMap );
116 msg << wxString::Format( wxT(
"\n ** ERC messages: %d Errors %d Warnings %d\n" ),
121 msg << wxT(
"\n ** Ignored checks:\n" );
123 bool hasIgnored =
false;
127 int code = item.GetErrorCode();
131 msg << wxString::Format( wxT(
" - %s\n" ), item.GetErrorMessage(
false ) );
137 msg << wxT(
" - " ) << wxT(
"None" ) << wxT(
"\n" );
145 wxFFile file( aFullFileName, wxT(
"wt" ) );
147 if( !file.IsOpened() )
159 std::ofstream jsonFileStream( aFullFileName.fn_str() );
162 std::map<KIID, EDA_ITEM*> itemMap;
165 wxFileName fn(
m_sch->GetFileName() );
166 reportHead.
$schema =
"https://schemas.kicad.org/erc.v1.json";
167 reportHead.
source = fn.GetFullName();
187 std::map<SCH_SHEET_PATH, std::vector<ERC_ITEM*>> orderedItems;
193 if( item->MainItemHasSheetPath() )
194 orderedItems[item->GetMainItemSheetPath()].emplace_back( item );
196 orderedItems[sheetList[0]].emplace_back( item );
200 for(
unsigned i = 0; i < sheetList.size(); i++ )
202 RC_JSON::ERC_SHEET jsonSheet;
203 jsonSheet.path = sheetList[i].PathHumanReadable();
204 jsonSheet.uuid_path = sheetList[i].Path().AsString();
206 for(
ERC_ITEM* item : orderedItems[sheetList[i]] )
211 item->GetJsonViolation( violation, &unitsProvider, severity, itemMap );
213 jsonSheet.violations.push_back( violation );
216 reportHead.
sheets.push_back( jsonSheet );
221 int code = item.GetErrorCode();
226 ignoredCheck.
key = item.GetSettingsKey();
227 ignoredCheck.
description = item.GetErrorMessage(
false );
232 nlohmann::json saveJson = nlohmann::json( reportHead );
233 jsonFileStream << std::setw( 4 ) << saveJson << std::endl;
234 jsonFileStream.flush();
235 jsonFileStream.close();
constexpr EDA_IU_SCALE schIUScale
constexpr EDA_IU_SCALE pcbIUScale
wxString GetMajorMinorPatchVersion()
Get the major, minor and patch version in a string major.minor.patch This is extracted by CMake from ...
static std::vector< std::reference_wrapper< RC_ITEM > > GetItemsWithSeverities()
ERC_REPORT(SCHEMATIC *aSchematic, EDA_UNITS aReportUnits, std::shared_ptr< RC_ITEMS_PROVIDER > aMarkersProvider=nullptr)
wxString GetTextReport()
Returns the ERC report in "text" (human readable) format in the C-locale.
bool WriteJsonReport(const wxString &aFullFileName)
Writes a JSON formatted ERC Report to the given file path in the c-locale.
std::shared_ptr< RC_ITEMS_PROVIDER > m_markersProvider
bool WriteTextReport(const wxString &aFullFileName)
Writes the text report also available via GetTextReport directly to a given file path.
Container for ERC settings.
SEVERITY GetSeverity(int aErrorCode) const
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.
Holds all the data relating to one schematic.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Fill an item cache for temporary use when many items need to be fetched.
This file contains miscellaneous commonly used macros and functions.
KICOMMON_API wxString GetLabel(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
wxString formatSeverities(int aSeverities)
Convert a severity mask to a human-readable comma-separated string.
wxString GetISO8601CurrentDateTime()
std::vector< wxString > included_severities
std::vector< ERC_SHEET > sheets
std::vector< IGNORED_CHECK > ignored_checks
wxString coordinate_units