diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp index 670e087076..edd4706164 100644 --- a/common/wildcards_and_files_ext.cpp +++ b/common/wildcards_and_files_ext.cpp @@ -485,9 +485,15 @@ wxString PSFileWildcard() } +wxString JsonFileWildcard() +{ + return _( "Json files" ) + AddFileExtListToFilter( { JsonFileExtension } ); +} + + wxString ReportFileWildcard() { - return _( "Report files" ) + AddFileExtListToFilter( { "rpt" } ); + return _( "Report files" ) + AddFileExtListToFilter( { ReportFileExtension } ); } diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 958fa64500..04fad617c6 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -964,12 +964,16 @@ void DIALOG_ERC::OnSaveReport( wxCommandEvent& aEvent ) wxFileName fn( wxS( "ERC." ) + ReportFileExtension ); wxFileDialog dlg( this, _( "Save Report to File" ), Prj().GetProjectPath(), fn.GetFullName(), - ReportFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + ReportFileWildcard() + wxS( "|" ) + JsonFileWildcard(), + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() != wxID_OK ) return; - fn = EnsureFileExtension( dlg.GetPath(), ReportFileExtension ); + fn = dlg.GetPath(); + + if( fn.GetExt().IsEmpty() ) + fn.SetExt( ReportFileExtension ); if( !fn.IsAbsolute() ) { @@ -979,7 +983,13 @@ void DIALOG_ERC::OnSaveReport( wxCommandEvent& aEvent ) ERC_REPORT reportWriter( &m_parent->Schematic(), m_parent->GetUserUnits() ); - if( reportWriter.WriteTextReport( fn.GetFullPath() ) ) + bool success = false; + if( fn.GetExt() == JsonFileExtension ) + success = reportWriter.WriteJsonReport( fn.GetFullPath() ); + else + success = reportWriter.WriteTextReport( fn.GetFullPath() ); + + if( success ) { m_messages->Report( wxString::Format( _( "Report file '%s' created." ), fn.GetFullPath() ) ); diff --git a/eeschema/erc_report.cpp b/eeschema/erc_report.cpp index 526b3d6cff..4d248b7938 100644 --- a/eeschema/erc_report.cpp +++ b/eeschema/erc_report.cpp @@ -129,6 +129,7 @@ bool ERC_REPORT::WriteJsonReport( const wxString& aFullFileName ) { RC_JSON::ERC_SHEET jsonSheet; jsonSheet.path = sheetList[i].PathHumanReadable(); + jsonSheet.uuid = sheetList[i].Path().AsString(); for( SCH_ITEM* aItem : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) ) { diff --git a/include/wildcards_and_files_ext.h b/include/wildcards_and_files_ext.h index 7052034341..004cb47f45 100644 --- a/include/wildcards_and_files_ext.h +++ b/include/wildcards_and_files_ext.h @@ -239,6 +239,7 @@ extern wxString PSFileWildcard(); extern wxString MacrosFileWildcard(); extern wxString DrillFileWildcard(); extern wxString SVGFileWildcard(); +extern wxString JsonFileWildcard(); extern wxString ReportFileWildcard(); extern wxString FootprintPlaceFileWildcard(); extern wxString Shapes3DFileWildcard(); diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 2df69fa599..a3e8e32e63 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -854,7 +854,8 @@ void DIALOG_DRC::OnSaveReport( wxCommandEvent& aEvent ) wxFileName fn( "DRC." + ReportFileExtension ); wxFileDialog dlg( this, _( "Save Report to File" ), Prj().GetProjectPath(), fn.GetFullName(), - ReportFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + ReportFileWildcard() + wxS( "|" ) + JsonFileWildcard(), + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() != wxID_OK ) return; @@ -873,7 +874,13 @@ void DIALOG_DRC::OnSaveReport( wxCommandEvent& aEvent ) DRC_REPORT reportWriter( m_frame->GetBoard(), GetUserUnits(), m_markersProvider, m_ratsnestProvider, m_fpWarningsProvider ); - if( reportWriter.WriteJsonReport( fn.GetFullPath() ) ) + bool success = false; + if( fn.GetExt() == JsonFileExtension ) + success = reportWriter.WriteJsonReport( fn.GetFullPath() ); + else + success = reportWriter.WriteTextReport( fn.GetFullPath() ); + + if( success ) { m_messages->Report( wxString::Format( _( "Report file '%s' created
" ), fn.GetFullPath() ) );