Fix plotting without Pgm context

This commit is contained in:
Jon Evans 2020-03-24 21:45:58 -04:00
parent d69ebfae49
commit 18ad186b99
1 changed files with 14 additions and 4 deletions

View File

@ -70,16 +70,26 @@ class BRDITEMS_PLOTTER : public PCB_PLOT_PARAMS
/// Pointer to color settings that should be used for plotting
COLOR_SETTINGS* m_colors;
/// Dummy colors object that can be created if there is no Pgm context
std::unique_ptr<COLOR_SETTINGS> m_default_colors;
public:
BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts ) :
PCB_PLOT_PARAMS( aPlotOpts )
BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts )
: PCB_PLOT_PARAMS( aPlotOpts ), m_default_colors()
{
m_plotter = aPlotter;
m_board = aBoard;
// TODO(JE) do we ever need to plot outside the context of Pgm()?
if( PgmOrNull() )
{
m_colors = Pgm().GetSettingsManager().GetColorSettings();
}
else
{
m_default_colors = std::make_unique<COLOR_SETTINGS>();
m_colors = m_default_colors.get();
}
}
/**
* @return a 'width adjustment' for the postscript engine