Support json reports as option in erc/drc dialogs
This commit is contained in:
parent
e842a788db
commit
061d18cbb0
|
@ -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 } );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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() ) );
|
||||
|
|
|
@ -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 ) )
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<br>" ),
|
||||
fn.GetFullPath() ) );
|
||||
|
|
Loading…
Reference in New Issue