Add done messages to various plotters.

Fixes https://gitlab.com/kicad/code/kicad/issues/9172
This commit is contained in:
Jeff Young 2021-09-18 10:34:02 +01:00
parent 847c9e32c8
commit 4779850c10
4 changed files with 82 additions and 78 deletions

View File

@ -398,19 +398,19 @@ void DIALOG_PLOT_SCHEMATIC::plotSchematic( bool aPlotAll )
{
default:
case PLOT_FORMAT::POST:
createPSFile( aPlotAll, getPlotDrawingSheet(), &renderSettings );
createPSFiles( aPlotAll, getPlotDrawingSheet(), &renderSettings );
break;
case PLOT_FORMAT::DXF:
createDxfFile( aPlotAll, getPlotDrawingSheet(), &renderSettings );
createDXFFiles( aPlotAll, getPlotDrawingSheet(), &renderSettings );
break;
case PLOT_FORMAT::PDF:
createPDFFile( aPlotAll, getPlotDrawingSheet(), &renderSettings );
break;
case PLOT_FORMAT::SVG:
createSVGFile( aPlotAll, getPlotDrawingSheet(), &renderSettings );
createSVGFiles( aPlotAll, getPlotDrawingSheet(), &renderSettings );
break;
case PLOT_FORMAT::HPGL:
createHPGLFile( aPlotAll, getPlotDrawingSheet(), &renderSettings );
createHPGLFiles( aPlotAll, getPlotDrawingSheet(), &renderSettings );
break;
}
}
@ -433,8 +433,7 @@ wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( const wxString& aPlotFileN
retv.SetExt( aExtension );
if( !EnsureFileDirectoryExists( &tmp, retv.GetFullName(), aReporter )
|| !tmp.IsDirWritable() )
if( !EnsureFileDirectoryExists( &tmp, retv.GetFullName(), aReporter ) || !tmp.IsDirWritable() )
{
wxString msg = wxString::Format( _( "Failed to write plot files to folder '%s'." ),
tmp.GetPath() );
@ -457,17 +456,16 @@ wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( const wxString& aPlotFileN
}
void DIALOG_PLOT_SCHEMATIC::createDxfFile( bool aPlotAll, bool aPlotDrawingSheet,
RENDER_SETTINGS* aRenderSettings )
void DIALOG_PLOT_SCHEMATIC::createDXFFiles( bool aPlotAll, bool aPlotDrawingSheet,
RENDER_SETTINGS* aRenderSettings )
{
SCH_EDIT_FRAME* schframe = m_parent;
SCH_SHEET_PATH oldsheetpath = schframe->GetCurrentSheet();
/* When printing all pages, the printed page is not the current page.
* In complex hierarchies, we must setup references and others parameters
* in the printed SCH_SCREEN
* because in complex hierarchies a SCH_SCREEN (a schematic drawings)
* is shared between many sheets
/* When printing all pages, the printed page is not the current page. In complex hierarchies,
* we must update symbol references and other parameters in the given printed SCH_SCREEN,
* according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
* shared between many sheets and symbol references depend on the actual sheet path used.
*/
SCH_SHEET_LIST sheetList;
@ -508,7 +506,7 @@ void DIALOG_PLOT_SCHEMATIC::createDxfFile( bool aPlotAll, bool aPlotDrawingSheet
if( !plotFileName.IsOk() )
return;
if( plotOneSheetDxf( plotFileName.GetFullPath(), screen, aRenderSettings,
if( plotOneSheetDXF( plotFileName.GetFullPath(), screen, aRenderSettings,
plot_offset, 1.0, aPlotDrawingSheet ) )
{
msg.Printf( _( "Plotted to '%s'." ), plotFileName.GetFullPath() );
@ -531,13 +529,15 @@ void DIALOG_PLOT_SCHEMATIC::createDxfFile( bool aPlotAll, bool aPlotDrawingSheet
}
}
reporter.ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
schframe->SetCurrentSheet( oldsheetpath );
schframe->GetCurrentSheet().UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount();
}
bool DIALOG_PLOT_SCHEMATIC::plotOneSheetDxf( const wxString& aFileName,
bool DIALOG_PLOT_SCHEMATIC::plotOneSheetDXF( const wxString& aFileName,
SCH_SCREEN* aScreen,
RENDER_SETTINGS* aRenderSettings,
const wxPoint& aPlotOffset,
@ -602,17 +602,16 @@ void DIALOG_PLOT_SCHEMATIC::setHpglPenWidth()
}
void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef,
RENDER_SETTINGS* aRenderSettings )
void DIALOG_PLOT_SCHEMATIC::createHPGLFiles( bool aPlotAll, bool aPlotFrameRef,
RENDER_SETTINGS* aRenderSettings )
{
SCH_SCREEN* screen = m_parent->GetScreen();
SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet();
/* When printing all pages, the printed page is not the current page.
* In complex hierarchies, we must setup references and other parameters
* in the printed SCH_SCREEN
* because in complex hierarchies a SCH_SCREEN (a schematic drawings)
* is shared between many sheets
/* When printing all pages, the printed page is not the current page. In complex hierarchies,
* we must update symbol references and other parameters in the given printed SCH_SCREEN,
* according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
* shared between many sheets and symbol references depend on the actual sheet path used.
*/
SCH_SHEET_LIST sheetList;
@ -695,9 +694,10 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef,
msg.Printf( wxT( "HPGL Plotter exception: %s"), e.What() );
reporter.Report( msg, RPT_SEVERITY_ERROR );
}
}
reporter.ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
m_parent->SetCurrentSheet( oldsheetpath );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
@ -780,12 +780,10 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotDrawingSheet
{
SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet(); // sheetpath is saved here
/* When printing all pages, the printed page is not the current page. In
* complex hierarchies, we must update symbol references and other
* parameters in the given printed SCH_SCREEN, accordant to the sheet path
* because in complex hierarchies a SCH_SCREEN (a drawing ) is shared
* between many sheets and symbol references depend on the actual sheet
* path used
/* When printing all pages, the printed page is not the current page. In complex hierarchies,
* we must update symbol references and other parameters in the given printed SCH_SCREEN,
* according to the sheet path because in complex hierarchies a SCH_SCREEN (a drawing ) is
* shared between many sheets and symbol references depend on the actual sheet path used.
*/
SCH_SHEET_LIST sheetList;
@ -806,10 +804,10 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotDrawingSheet
plotter->SetCreator( wxT( "Eeschema-PDF" ) );
plotter->SetTitle( m_parent->GetTitleBlock().GetTitle() );
wxString msg;
wxString msg;
wxFileName plotFileName;
REPORTER& reporter = m_MessagesBox->Reporter();
LOCALE_IO toggle; // Switch the locale to standard C
REPORTER& reporter = m_MessagesBox->Reporter();
LOCALE_IO toggle; // Switch the locale to standard C
for( unsigned i = 0; i < sheetList.size(); i++ )
{
@ -820,14 +818,13 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotDrawingSheet
if( i == 0 )
{
try
{
wxString fname = m_parent->GetUniqueFilenameForCurrentSheet();
// The sub sheet can be in a sub_hierarchy, but we plot the file in the
// main project folder (or the folder specified by the caller),
// so replace separators to create a unique filename:
// The sub sheet can be in a sub_hierarchy, but we plot the file in the main
// project folder (or the folder specified by the caller), so replace separators
// to create a unique filename:
fname.Replace( "/", "_" );
fname.Replace( "\\", "_" );
wxString ext = PDF_PLOTTER::GetDefaultFileExtension();
@ -874,6 +871,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotDrawingSheet
// Everything done, close the plot and restore the environment
msg.Printf( _( "Plotted to '%s'.\n" ), plotFileName.GetFullPath() );
reporter.Report( msg, RPT_SEVERITY_ACTION );
reporter.ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
restoreEnvironment( plotter, oldsheetpath );
}
@ -955,11 +953,13 @@ void DIALOG_PLOT_SCHEMATIC::setupPlotPagePDF( PLOTTER* aPlotter, SCH_SCREEN* aSc
}
void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef,
RENDER_SETTINGS* aRenderSettings )
void DIALOG_PLOT_SCHEMATIC::createPSFiles( bool aPlotAll, bool aPlotFrameRef,
RENDER_SETTINGS* aRenderSettings )
{
SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet(); // sheetpath is saved here
PAGE_INFO plotPage; // page size selected to plot
wxString msg;
REPORTER& reporter = m_MessagesBox->Reporter();
/* When printing all pages, the printed page is not the current page.
* In complex hierarchies, we must update symbol references and other parameters in the
@ -1008,14 +1008,9 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef,
double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
double scale = std::min( scalex, scaley );
double scale = std::min( scalex, scaley );
wxPoint plot_offset;
wxString msg;
REPORTER& reporter = m_MessagesBox->Reporter();
try
{
wxString fname = m_parent->GetUniqueFilenameForCurrentSheet();
@ -1052,6 +1047,8 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef,
}
}
reporter.ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
m_parent->SetCurrentSheet( oldsheetpath );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
@ -1090,8 +1087,7 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName,
if( m_plotBackgroundColor->GetValue() )
{
plotter->SetColor( plotter->RenderSettings()->GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ) );
wxPoint end( plotter->PageSettings().GetWidthIU(),
plotter->PageSettings().GetHeightIU() );
wxPoint end( plotter->PageSettings().GetWidthIU(), plotter->PageSettings().GetHeightIU() );
plotter->Rect( wxPoint( 0, 0 ), end, FILL_TYPE::FILLED_SHAPE, 1.0 );
}
@ -1114,8 +1110,8 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName,
}
void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef,
RENDER_SETTINGS* aRenderSettings )
void DIALOG_PLOT_SCHEMATIC::createSVGFiles( bool aPrintAll, bool aPrintFrameRef,
RENDER_SETTINGS* aRenderSettings )
{
wxString msg;
REPORTER& reporter = m_MessagesBox->Reporter();
@ -1178,6 +1174,8 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef,
}
}
reporter.ReportTail( _( "Done" ), RPT_SEVERITY_INFO );
m_parent->SetCurrentSheet( oldsheetpath );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
@ -1283,9 +1281,8 @@ wxString DIALOG_PLOT_SCHEMATIC::getOutputPath()
}
else
{
wxMessageDialog dlg( this, msg, _( "Warning" ),
wxOK | wxCENTER | wxRESIZE_BORDER | wxICON_EXCLAMATION |
wxSTAY_ON_TOP );
wxMessageDialog dlg( this, msg, _( "Warning" ), wxOK | wxCENTER | wxRESIZE_BORDER
| wxICON_EXCLAMATION | wxSTAY_ON_TOP );
dlg.SetExtendedMessage( extMsg );
dlg.ShowModal();
@ -1297,9 +1294,8 @@ wxString DIALOG_PLOT_SCHEMATIC::getOutputPath()
{
msg = _( "No project or path defined for the current schematic." );
wxMessageDialog dlg( this, msg, _( "Warning" ),
wxOK | wxCENTER | wxRESIZE_BORDER | wxICON_EXCLAMATION |
wxSTAY_ON_TOP );
wxMessageDialog dlg( this, msg, _( "Warning" ), wxOK | wxCENTER | wxRESIZE_BORDER
| wxICON_EXCLAMATION | wxSTAY_ON_TOP );
dlg.SetExtendedMessage( extMsg );
dlg.ShowModal();

View File

@ -110,8 +110,8 @@ private:
void restoreEnvironment( PDF_PLOTTER* aPlotter, SCH_SHEET_PATH& aOldsheetpath );
// DXF
void createDxfFile( bool aPlotAll, bool aPlotDrawingSheet, RENDER_SETTINGS* aRenderSettings );
bool plotOneSheetDxf( const wxString& aFileName, SCH_SCREEN* aScreen,
void createDXFFiles( bool aPlotAll, bool aPlotDrawingSheet, RENDER_SETTINGS* aRenderSettings );
bool plotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen,
RENDER_SETTINGS* aRenderSettings, const wxPoint& aPlotOffset,
double aScale, bool aPlotFrameRef );
@ -151,7 +151,7 @@ private:
}
}
void createHPGLFile( bool aPlotAll, bool aPlotFrameRef, RENDER_SETTINGS* aRenderSettings );
void createHPGLFiles( bool aPlotAll, bool aPlotFrameRef, RENDER_SETTINGS* aRenderSettings );
void setHpglPenWidth();
bool plotOneSheetHpgl( const wxString& aFileName, SCH_SCREEN* aScreen,
const PAGE_INFO& aPageInfo, RENDER_SETTINGS* aRenderSettings,
@ -159,13 +159,13 @@ private:
HPGL_PLOT_ORIGIN_AND_UNITS aOriginAndUnits );
// PS
void createPSFile( bool aPlotAll, bool aPlotFrameRef, RENDER_SETTINGS* aSettings );
void createPSFiles( bool aPlotAll, bool aPlotFrameRef, RENDER_SETTINGS* aSettings );
bool plotOneSheetPS( const wxString& aFileName, SCH_SCREEN* aScreen,
RENDER_SETTINGS* aRenderSettings, const PAGE_INFO& aPageInfo,
const wxPoint& aPlot0ffset, double aScale, bool aPlotFrameRef );
// SVG
void createSVGFile( bool aPlotAll, bool aPlotFrameRef, RENDER_SETTINGS* aSettings );
void createSVGFiles( bool aPrintAll, bool aPrintFrameRef, RENDER_SETTINGS* aRenderSettings );
bool plotOneSheetSVG( const wxString& aFileName, SCH_SCREEN* aScreen,
RENDER_SETTINGS* aRenderSettings, bool aPlotBlackAndWhite,
bool aPlotFrameRef );

View File

@ -41,7 +41,6 @@
#include <dialog_gendrill.h>
#include <wildcards_and_files_ext.h>
#include <reporter.h>
#include <wx/stdpaths.h>
#include <wx/msgdlg.h>
#include <wx/dirdlg.h>
#include <wx/filedlg.h>
@ -217,7 +216,9 @@ void DIALOG_GENDRILL::onFileFormatSelection( wxCommandEvent& event )
m_radioBoxOvalHoleMode->Enable( enbl_Excellon );
if( enbl_Excellon )
{
UpdatePrecisionOptions();
}
else
{
m_staticTextPrecision->Enable( true );
@ -310,8 +311,10 @@ void DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
if( dialog.ShowModal() == wxID_YES )
{
if( !dirName.MakeRelativeTo( defaultPath ) )
{
wxMessageBox( _( "Cannot make path relative (target volume different from file volume)!" ),
_( "Plot Output Directory" ), wxOK | wxICON_ERROR );
}
}
m_outputDirectoryName->SetValue( dirName.GetFullPath() );
@ -471,4 +474,6 @@ void DIALOG_GENDRILL::OnGenReportFile( wxCommandEvent& event )
msg.Printf( _( "Report file '%s' created." ), dlg.GetPath() );
m_messagesBox->AppendText( msg );
}
m_messagesBox->AppendText( _( "Done." ) );
}

View File

@ -116,7 +116,9 @@ void DIALOG_PLOT::init_Dialog()
// Test for a reasonable scale value. Set to 1 if problem
if( m_XScaleAdjust < PLOT_MIN_SCALE || m_YScaleAdjust < PLOT_MIN_SCALE
|| m_XScaleAdjust > PLOT_MAX_SCALE || m_YScaleAdjust > PLOT_MAX_SCALE )
{
m_XScaleAdjust = m_YScaleAdjust = 1.0;
}
m_fineAdjustXCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, m_XScaleAdjust ) );
m_fineAdjustYCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, m_YScaleAdjust ) );
@ -246,8 +248,7 @@ void DIALOG_PLOT::reInitDialog()
if( knownViolations || exclusions )
{
m_DRCExclusionsWarning->SetLabel( wxString::Format( m_DRCWarningTemplate,
knownViolations,
m_DRCExclusionsWarning->SetLabel( wxString::Format( m_DRCWarningTemplate, knownViolations,
exclusions ) );
m_DRCExclusionsWarning->Show();
}
@ -281,10 +282,8 @@ void DIALOG_PLOT::OnRightClick( wxMouseEvent& event )
// Select or deselect groups of layers in the layers list:
void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event )
{
// Build a list of layers for usual fabrication:
// copper layers + tech layers without courtyard
LSET fab_layer_set = ( LSET::AllCuMask() | LSET::AllTechMask() )
& ~LSET( 2, B_CrtYd, F_CrtYd );
// Build a list of layers for usual fabrication: copper layers + tech layers without courtyard
LSET fab_layer_set = ( LSET::AllCuMask() | LSET::AllTechMask() ) & ~LSET( 2, B_CrtYd, F_CrtYd );
switch( event.GetId() )
{
@ -334,8 +333,7 @@ void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event )
void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event )
{
// Be sure drill file use the same settings (axis option, plot directory)
// as plot files:
// Be sure drill file use the same settings (axis option, plot directory) as plot files:
applyPlotSettings();
DIALOG_GENDRILL dlg( m_parent, this );
@ -349,12 +347,12 @@ void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event )
void DIALOG_PLOT::OnChangeDXFPlotMode( wxCommandEvent& event )
{
// m_DXF_plotTextStrokeFontOpt is disabled if m_DXF_plotModeOpt
// is checked (plot in DXF polygon mode)
// m_DXF_plotTextStrokeFontOpt is disabled if m_DXF_plotModeOpt is checked (plot in DXF
// polygon mode)
m_DXF_plotTextStrokeFontOpt->Enable( !m_DXF_plotModeOpt->GetValue() );
// if m_DXF_plotTextStrokeFontOpt option is disabled (plot DXF in polygon mode),
// force m_DXF_plotTextStrokeFontOpt to true to use Pcbnew stroke font
// if m_DXF_plotTextStrokeFontOpt option is disabled (plot DXF in polygon mode), force
// m_DXF_plotTextStrokeFontOpt to true to use Pcbnew stroke font
if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() )
m_DXF_plotTextStrokeFontOpt->SetValue( true );
}
@ -435,8 +433,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
BOARD* board = m_parent->GetBoard();
const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
if( getPlotFormat() == PLOT_FORMAT::GERBER &&
( brd_settings.m_SolderMaskMargin || brd_settings.m_SolderMaskMinWidth ) )
if( getPlotFormat() == PLOT_FORMAT::GERBER
&& ( brd_settings.m_SolderMaskMargin || brd_settings.m_SolderMaskMinWidth ) )
{
m_PlotOptionsSizer->Show( m_SizerSolderMaskAlert );
}
@ -591,8 +589,7 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
}
// A helper function to "clip" aValue between aMin and aMax
// and write result in * aResult
// A helper function to "clip" aValue between aMin and aMax and write result in * aResult
// return false if clipped, true if aValue is just copied into * aResult
static bool setDouble( double* aResult, double aValue, double aMin, double aMax )
{
@ -682,7 +679,9 @@ void DIALOG_PLOT::applyPlotSettings()
}
}
else // keep the last value (initial value if no HPGL plot made)
{
tempOptions.SetHPGLPenDiameter( m_plotOpts.GetHPGLPenDiameter() );
}
// X scale
double tmpDouble;
@ -717,8 +716,8 @@ void DIALOG_PLOT::applyPlotSettings()
cfg->m_Plot.check_zones_before_plotting = m_zoneFillCheck->GetValue();
// PS Width correction
if( !setInt( &m_PSWidthAdjust, m_trackWidthCorrection.GetValue(),
m_widthAdjustMinValue, m_widthAdjustMaxValue ) )
if( !setInt( &m_PSWidthAdjust, m_trackWidthCorrection.GetValue(), m_widthAdjustMinValue,
m_widthAdjustMaxValue ) )
{
m_trackWidthCorrection.SetValue( m_PSWidthAdjust );
msg.Printf( _( "Width correction constrained. "
@ -745,11 +744,13 @@ void DIALOG_PLOT::applyPlotSettings()
tempOptions.SetSvgPrecision( m_svgPrecsision->GetValue(), m_svgUnits->GetSelection() );
LSET selectedLayers;
for( unsigned i = 0; i < m_layerList.size(); i++ )
{
if( m_layerCheckListBox->IsChecked( i ) )
selectedLayers.set( m_layerList[i] );
}
// Get a list of copper layers that aren't being used by inverting enabled layers.
LSET disabledCopperLayers = LSET::AllCuMask() & ~m_parent->GetBoard()->GetEnabledLayers();
// Enable all of the disabled copper layers.
@ -924,6 +925,8 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
BuildPlotFileName( &fn, outputDir.GetPath(), "job", GerberJobFileExtension );
jobfile_writer.CreateJobFile( fn.GetFullPath() );
}
reporter.ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
}