40 m_reportUnits( aReportUnits )
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() )
130 std::ofstream jsonFileStream( aFullFileName.fn_str() );
133 std::map<KIID, EDA_ITEM*> itemMap;
137 reportHead.
$schema =
"https://schemas.kicad.org/erc.v1.json";
138 reportHead.
source = fn.GetFullName();
151 std::map<SCH_SHEET_PATH, std::vector<ERC_ITEM*>> orderedItems;
153 for(
int i = 0; i < errors.
GetCount(); ++i )
157 if( item->MainItemHasSheetPath() )
158 orderedItems[item->GetMainItemSheetPath()].emplace_back( item );
160 orderedItems[sheetList[0]].emplace_back( item );
164 for(
unsigned i = 0; i < sheetList.size(); i++ )
166 RC_JSON::ERC_SHEET jsonSheet;
167 jsonSheet.path = sheetList[i].PathHumanReadable();
168 jsonSheet.uuid_path = sheetList[i].Path().AsString();
170 for(
ERC_ITEM* item : orderedItems[sheetList[i]] )
175 item->GetJsonViolation( violation, &unitsProvider, severity, itemMap );
177 jsonSheet.violations.push_back( violation );
180 reportHead.
sheets.push_back( jsonSheet );
183 nlohmann::json saveJson = nlohmann::json( reportHead );
184 jsonFileStream << std::setw( 4 ) << saveJson << std::endl;
185 jsonFileStream.flush();
186 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.
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
ERC_SETTINGS & ErcSettings() const
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