52 wxString msg = wxString::Format(
_(
"ERC report (%s, Encoding UTF8)\n" ),
55 std::map<KIID, EDA_ITEM*> itemMap;
69 std::map<SCH_SHEET_PATH, std::vector<ERC_ITEM*>> orderedItems;
71 for(
int i = 0; i < errors.
GetCount(); ++i )
75 if( item->MainItemHasSheetPath() )
76 orderedItems[item->GetMainItemSheetPath()].emplace_back( item );
78 orderedItems[sheetList[0]].emplace_back( item );
82 for(
unsigned i = 0; i < sheetList.size(); i++ )
84 msg << wxString::Format(
_(
"\n***** Sheet %s\n" ), sheetList[i].PathHumanReadable() );
86 for(
ERC_ITEM* item : orderedItems[sheetList[i]] )
99 msg << item->ShowReport( &unitsProvider, severity, itemMap );
103 msg << wxString::Format(
_(
"\n ** ERC messages: %d Errors %d Warnings %d\n" ), total_count,
104 err_count, warn_count );
112 wxFFile file( aFullFileName, wxT(
"wt" ) );
114 if( !file.IsOpened() )
126 std::ofstream jsonFileStream( aFullFileName.fn_str() );
129 std::map<KIID, EDA_ITEM*> itemMap;
132 wxFileName fn(
m_sch->GetFileName() );
133 reportHead.
$schema =
"https://schemas.kicad.org/erc.v1.json";
134 reportHead.
source = fn.GetFullName();
147 std::map<SCH_SHEET_PATH, std::vector<ERC_ITEM*>> orderedItems;
149 for(
int i = 0; i < errors.
GetCount(); ++i )
153 if( item->MainItemHasSheetPath() )
154 orderedItems[item->GetMainItemSheetPath()].emplace_back( item );
156 orderedItems[sheetList[0]].emplace_back( item );
160 for(
unsigned i = 0; i < sheetList.size(); i++ )
162 RC_JSON::ERC_SHEET jsonSheet;
163 jsonSheet.path = sheetList[i].PathHumanReadable();
164 jsonSheet.uuid_path = sheetList[i].Path().AsString();
166 for(
ERC_ITEM* item : orderedItems[sheetList[i]] )
171 item->GetJsonViolation( violation, &unitsProvider, severity, itemMap );
173 jsonSheet.violations.push_back( violation );
176 reportHead.
sheets.push_back( jsonSheet );
179 nlohmann::json saveJson = nlohmann::json( reportHead );
180 jsonFileStream << std::setw( 4 ) << saveJson << std::endl;
181 jsonFileStream.flush();
182 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 ...
ERC_REPORT(SCHEMATIC *aSchematic, EDA_UNITS aReportUnits)
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.
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.
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.
An implementation of the RC_ITEM_LIST interface which uses the global SHEETLIST to fulfill the contra...
int GetCount(int aSeverity=-1) const override
void SetSeverities(int aSeverities) override
std::shared_ptr< RC_ITEM > GetItem(int aIndex) const override
Retrieve a RC_ITEM by index.
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 GetISO8601CurrentDateTime()
std::vector< ERC_SHEET > sheets
wxString coordinate_units