29#include <nlohmann/json.hpp>
34 std::shared_ptr<RC_ITEMS_PROVIDER> aMarkersProvider,
35 std::shared_ptr<RC_ITEMS_PROVIDER> aRatsnestProvider,
36 std::shared_ptr<RC_ITEMS_PROVIDER> aFpWarningsProvider) :
38 m_reportUnits( aReportUnits ),
39 m_markersProvider(
std::
move( aMarkersProvider ) ),
40 m_ratsnestProvider(
std::
move( aRatsnestProvider ) ),
41 m_fpWarningsProvider(
std::
move( aFpWarningsProvider ) )
49 FILE* fp = wxFopen( aFullFileName, wxT(
"w" ) );
54 std::map<KIID, EDA_ITEM*> itemMap;
62 fprintf( fp,
"** Drc report for %s **\n",
TO_UTF8( fn.GetFullName() ) );
68 fprintf( fp,
"\n** Found %d DRC violations **\n", count );
70 for(
int i = 0; i < count; ++i )
73 SEVERITY severity = item->GetParent()->GetSeverity();
78 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
83 fprintf( fp,
"\n** Found %d unconnected pads **\n", count );
85 for(
int i = 0; i < count; ++i )
90 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
95 fprintf( fp,
"\n** Found %d Footprint errors **\n", count );
97 for(
int i = 0; i < count; ++i )
102 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
106 fprintf( fp,
"\n** End of Report **\n" );
116 std::ofstream jsonFileStream( aFullFileName.fn_str() );
120 std::map<KIID, EDA_ITEM*> itemMap;
126 reportHead.
$schema =
"https://schemas.kicad.org/drc.v1.json";
127 reportHead.
source = fn.GetFullName();
135 SEVERITY severity = item->GetParent()->GetSeverity();
138 severity = bds.
GetSeverity( item->GetErrorCode() );
141 item->GetJsonViolation( violation, &unitsProvider, severity, itemMap );
152 item->GetJsonViolation( violation, &unitsProvider, severity, itemMap );
164 item->GetJsonViolation( violation, &unitsProvider, severity, itemMap );
170 nlohmann::json saveJson = nlohmann::json( reportHead );
171 jsonFileStream << std::setw( 4 ) << saveJson << std::endl;
172 jsonFileStream.flush();
173 jsonFileStream.close();
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 ...
Container for design settings for a BOARD object.
SEVERITY GetSeverity(int aDRCErrorCode)
Information pertinent to a Pcbnew printed circuit board.
const wxString & GetFileName() const
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::shared_ptr< RC_ITEMS_PROVIDER > m_ratsnestProvider
bool WriteJsonReport(const wxString &aFullFileName)
std::shared_ptr< RC_ITEMS_PROVIDER > m_markersProvider
bool WriteTextReport(const wxString &aFullFileName)
DRC_REPORT(BOARD *aBoard, EDA_UNITS aReportUnits, std::shared_ptr< RC_ITEMS_PROVIDER > aMarkersProvider, std::shared_ptr< RC_ITEMS_PROVIDER > aRatsnestProvider, std::shared_ptr< RC_ITEMS_PROVIDER > aFpWarningsProvider)
std::shared_ptr< RC_ITEMS_PROVIDER > m_fpWarningsProvider
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()
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
std::vector< VIOLATION > unconnected_items
std::vector< VIOLATION > violations
std::vector< VIOLATION > schematic_parity
wxString coordinate_units