Add a python script example in demo folder to create various plot files from a board. Fix also some issues in plot controller helper class.

Important note: from a python script one cannot plot the palge layout, because the page layout template file is not stored in the board file, but it is part of the project.
Because when using a python script, the project is not loaded, the page layout template is not known.
Trying to plot it crashes the script.
This commit is contained in:
jean-pierre charras
2015-04-27 20:02:27 +02:00
parent 665f346a03
commit 9da39717ae
7 changed files with 692 additions and 635 deletions
+8 -6
View File
@@ -314,8 +314,10 @@ void BuildPlotFileName( wxFileName* aFilename,
PLOT_CONTROLLER::PLOT_CONTROLLER( BOARD *aBoard )
: m_plotter( NULL ), m_board( aBoard )
{
m_plotter = NULL;
m_board = aBoard;
m_plotLayer = UNDEFINED_LAYER;
}
@@ -351,14 +353,14 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix,
/* Save the current format: sadly some plot routines depends on this
but the main reason is that the StartPlot method uses it to
dispatch the plotter creation */
m_plotOpts.SetFormat( aFormat );
GetPlotOptions().SetFormat( aFormat );
// Ensure that the previous plot is closed
ClosePlot();
// Now compute the full filename for the output and start the plot
// (after ensuring the output directory is OK)
wxString outputDirName = m_plotOpts.GetOutputDirectory() ;
wxString outputDirName = GetPlotOptions().GetOutputDirectory() ;
wxFileName outputDir = wxFileName::DirName( outputDirName );
wxString boardFilename = m_board->GetFileName();
@@ -367,14 +369,14 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix,
wxFileName fn( boardFilename );
BuildPlotFileName( &fn, outputDirName, aSuffix, GetDefaultPlotExtension( aFormat ) );
m_plotter = StartPlotBoard( m_board, &m_plotOpts, UNDEFINED_LAYER, fn.GetFullPath(), aSheetDesc );
m_plotter = StartPlotBoard( m_board, &GetPlotOptions(), ToLAYER_ID( GetLayer() ), fn.GetFullPath(), aSheetDesc );
}
return( m_plotter != NULL );
}
bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer )
bool PLOT_CONTROLLER::PlotLayer()
{
LOCALE_IO toggle;
@@ -383,7 +385,7 @@ bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer )
return false;
// Fully delegated to the parent
PlotOneBoardLayer( m_board, m_plotter, ToLAYER_ID( aLayer ), m_plotOpts );
PlotOneBoardLayer( m_board, m_plotter, ToLAYER_ID( GetLayer() ), GetPlotOptions() );
return true;
}