KiCad PCB EDA Suite
PLOT_CONTROLLER Class Reference

Batch plotter state object. More...

#include <plotcontroller.h>

Public Member Functions

 PLOT_CONTROLLER (BOARD *aBoard)
 Batch plotter constructor, nothing interesting here. More...
 
 ~PLOT_CONTROLLER ()
 Batch plotter destructor, ensures that the last plot is closed. More...
 
PCB_PLOT_PARAMSGetPlotOptions ()
 Accessor to the plot parameters and options. More...
 
void SetLayer (LAYER_NUM aLayer)
 
LAYER_NUM GetLayer ()
 
bool IsPlotOpen () const
 
void ClosePlot ()
 Close the current plot, nothing happens if it isn't open. More...
 
bool OpenPlotfile (const wxString &aSuffix, PlotFormat aFormat, const wxString &aSheetDesc)
 Open a new plotfile; works as a factory for plotter objects. More...
 
bool PlotLayer ()
 Plot a single layer on the current plotfile m_plotLayer is the layer to plot. More...
 
const wxString GetPlotFileName ()
 
const wxString GetPlotDirName ()
 
void SetColorMode (bool)
 Plotters can plot in Black and White mode or Color mode SetColorMode activate/de-actiavte the Color mode. More...
 
bool GetColorMode ()
 

Private Attributes

LAYER_NUM m_plotLayer
 the layer to plot More...
 
PCB_PLOT_PARAMS m_plotOptions
 Option bank. More...
 
PLOTTERm_plotter
 This is the plotter object; it starts NULL and become instantiated when a plotfile is requested. More...
 
BOARDm_board
 The board we're plotting. More...
 
wxFileName m_plotFile
 The current plot filename, set by OpenPlotfile. More...
 

Detailed Description

Batch plotter state object.

Keeps the plot options and handles multiple plot requests Especially useful in Python scripts

Definition at line 45 of file plotcontroller.h.

Constructor & Destructor Documentation

PLOT_CONTROLLER::PLOT_CONTROLLER ( BOARD aBoard)

Batch plotter constructor, nothing interesting here.

Definition at line 421 of file pcbplot.cpp.

References m_board, m_plotLayer, m_plotter, and UNDEFINED_LAYER.

422 {
423  m_plotter = NULL;
424  m_board = aBoard;
426 }
PLOTTER * m_plotter
This is the plotter object; it starts NULL and become instantiated when a plotfile is requested...
BOARD * m_board
The board we're plotting.
LAYER_NUM m_plotLayer
the layer to plot
PLOT_CONTROLLER::~PLOT_CONTROLLER ( )

Batch plotter destructor, ensures that the last plot is closed.

Definition at line 429 of file pcbplot.cpp.

References ClosePlot().

430 {
431  ClosePlot();
432 }
void ClosePlot()
Close the current plot, nothing happens if it isn't open.
Definition: pcbplot.cpp:439

Member Function Documentation

void PLOT_CONTROLLER::ClosePlot ( )

Close the current plot, nothing happens if it isn't open.

Definition at line 439 of file pcbplot.cpp.

References PLOTTER::EndPlot(), and m_plotter.

Referenced by OpenPlotfile(), and ~PLOT_CONTROLLER().

440 {
441  LOCALE_IO toggle;
442 
443  if( m_plotter )
444  {
445  m_plotter->EndPlot();
446  delete m_plotter;
447  m_plotter = NULL;
448  }
449 }
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
PLOTTER * m_plotter
This is the plotter object; it starts NULL and become instantiated when a plotfile is requested...
virtual bool EndPlot()=0
bool PLOT_CONTROLLER::GetColorMode ( )
Returns
true if the current plot color mode is Color, false if the current plot color mode is Black and White

Definition at line 520 of file pcbplot.cpp.

References PLOTTER::GetColorMode(), and m_plotter.

521 {
522  if( !m_plotter )
523  return false;
524 
525  return m_plotter->GetColorMode();
526 }
PLOTTER * m_plotter
This is the plotter object; it starts NULL and become instantiated when a plotfile is requested...
bool GetColorMode() const
Definition: plot_common.h:121
LAYER_NUM PLOT_CONTROLLER::GetLayer ( )
inline

Definition at line 61 of file plotcontroller.h.

References m_plotLayer.

Referenced by OpenPlotfile(), and PlotLayer().

61 { return m_plotLayer; }
LAYER_NUM m_plotLayer
the layer to plot
const wxString PLOT_CONTROLLER::GetPlotDirName ( )
inline
Returns
the current plot full filename, set by OpenPlotfile

Definition at line 95 of file plotcontroller.h.

References m_plotFile.

95 { return m_plotFile.GetPathWithSep(); }
wxFileName m_plotFile
The current plot filename, set by OpenPlotfile.
const wxString PLOT_CONTROLLER::GetPlotFileName ( )
inline
Returns
the current plot full filename, set by OpenPlotfile

Definition at line 90 of file plotcontroller.h.

References m_plotFile.

90 { return m_plotFile.GetFullPath(); }
wxFileName m_plotFile
The current plot filename, set by OpenPlotfile.
PCB_PLOT_PARAMS& PLOT_CONTROLLER::GetPlotOptions ( )
inline

Accessor to the plot parameters and options.

Definition at line 58 of file plotcontroller.h.

References m_plotOptions.

Referenced by OpenPlotfile(), and PlotLayer().

58 { return m_plotOptions; }
PCB_PLOT_PARAMS m_plotOptions
Option bank.
bool PLOT_CONTROLLER::IsPlotOpen ( ) const
inline
Returns
true if a plotter is initialized and can be used

Definition at line 67 of file plotcontroller.h.

References m_plotter.

67 { return m_plotter != NULL; }
PLOTTER * m_plotter
This is the plotter object; it starts NULL and become instantiated when a plotfile is requested...
bool PLOT_CONTROLLER::OpenPlotfile ( const wxString &  aSuffix,
PlotFormat  aFormat,
const wxString &  aSheetDesc 
)

Open a new plotfile; works as a factory for plotter objects.

Parameters
aSuffixis a string added to the base filename (derived from the board filename) to identify the plot file
aFormatis the plot file format identifier
aSheetDesc

Definition at line 452 of file pcbplot.cpp.

References BuildPlotFileName(), ClosePlot(), EnsureFileDirectoryExists(), GetDefaultPlotExtension(), BOARD::GetFileName(), GetGerberProtelExtension(), GetLayer(), PCB_PLOT_PARAMS::GetOutputDirectory(), GetPlotOptions(), m_board, m_plotFile, m_plotter, PLOT_FORMAT_GERBER, PCB_PLOT_PARAMS::SetFormat(), StartPlotBoard(), and ToLAYER_ID().

455 {
456  LOCALE_IO toggle;
457 
458  /* Save the current format: sadly some plot routines depends on this
459  but the main reason is that the StartPlot method uses it to
460  dispatch the plotter creation */
461  GetPlotOptions().SetFormat( aFormat );
462 
463  // Ensure that the previous plot is closed
464  ClosePlot();
465 
466  // Now compute the full filename for the output and start the plot
467  // (after ensuring the output directory is OK)
468  wxString outputDirName = GetPlotOptions().GetOutputDirectory() ;
469  wxFileName outputDir = wxFileName::DirName( outputDirName );
470  wxString boardFilename = m_board->GetFileName();
471 
472  if( EnsureFileDirectoryExists( &outputDir, boardFilename ) )
473  {
474  // outputDir contains now the full path of plot files
475  m_plotFile = boardFilename;
476  m_plotFile.SetPath( outputDir.GetPath() );
477  wxString fileExt = GetDefaultPlotExtension( aFormat );
478 
479  // Gerber format can use specific file ext, depending on layers
480  // (now not a good practice, because the official file ext is .gbr)
481  if( GetPlotOptions().GetFormat() == PLOT_FORMAT_GERBER &&
482  GetPlotOptions().GetUseGerberProtelExtensions() )
483  fileExt = GetGerberProtelExtension( GetLayer() );
484 
485  // Build plot filenames from the board name and layer names:
486  BuildPlotFileName( &m_plotFile, outputDir.GetPath(), aSuffix, fileExt );
487 
489  m_plotFile.GetFullPath(), aSheetDesc );
490  }
491 
492  return( m_plotter != NULL );
493 }
PCB_PLOT_PARAMS & GetPlotOptions()
Accessor to the plot parameters and options.
LAYER_NUM GetLayer()
void ClosePlot()
Close the current plot, nothing happens if it isn't open.
Definition: pcbplot.cpp:439
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
PLOTTER * m_plotter
This is the plotter object; it starts NULL and become instantiated when a plotfile is requested...
void SetFormat(PlotFormat aFormat)
wxString GetDefaultPlotExtension(PlotFormat aFormat)
Returns the default plot extension for a format.
const wxString GetGerberProtelExtension(LAYER_NUM aLayer)
Function GetGerberProtelExtension.
Definition: pcbplot.cpp:48
wxFileName m_plotFile
The current plot filename, set by OpenPlotfile.
BOARD * m_board
The board we're plotting.
wxString GetOutputDirectory() const
const wxString & GetFileName() const
Definition: class_board.h:234
bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
Helper function EnsureFileDirectoryExists make aTargetFullFileName absolute and creates the path of t...
Definition: common.cpp:267
void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Function BuildPlotFileName (helper function) Complete a plot filename: forces the output directory...
Definition: pcbplot.cpp:389
PLOTTER * StartPlotBoard(BOARD *aBoard, PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aFullFileName, const wxString &aSheetDesc)
Open a new plotfile using the options (and especially the format) specified in the options and prepar...
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
bool PLOT_CONTROLLER::PlotLayer ( )

Plot a single layer on the current plotfile m_plotLayer is the layer to plot.

Definition at line 496 of file pcbplot.cpp.

References GetLayer(), GetPlotOptions(), m_board, m_plotter, PlotOneBoardLayer(), and ToLAYER_ID().

497 {
498  LOCALE_IO toggle;
499 
500  // No plot open, nothing to do...
501  if( !m_plotter )
502  return false;
503 
504  // Fully delegated to the parent
506 
507  return true;
508 }
PCB_PLOT_PARAMS & GetPlotOptions()
Accessor to the plot parameters and options.
LAYER_NUM GetLayer()
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
PLOTTER * m_plotter
This is the plotter object; it starts NULL and become instantiated when a plotfile is requested...
void PlotOneBoardLayer(BOARD *aBoard, PLOTTER *aPlotter, PCB_LAYER_ID aLayer, const PCB_PLOT_PARAMS &aPlotOpt)
Function PlotOneBoardLayer main function to plot one copper or technical layer.
BOARD * m_board
The board we're plotting.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
void PLOT_CONTROLLER::SetColorMode ( bool  aColorMode)

Plotters can plot in Black and White mode or Color mode SetColorMode activate/de-actiavte the Color mode.

Parameters
aColorMode= true to activate the plot color mode

Definition at line 511 of file pcbplot.cpp.

References m_plotter, and PLOTTER::SetColorMode().

512 {
513  if( !m_plotter )
514  return;
515 
516  m_plotter->SetColorMode( aColorMode );
517 }
PLOTTER * m_plotter
This is the plotter object; it starts NULL and become instantiated when a plotfile is requested...
virtual void SetColorMode(bool _color_mode)
Definition: plot_common.h:116
void PLOT_CONTROLLER::SetLayer ( LAYER_NUM  aLayer)
inline

Definition at line 60 of file plotcontroller.h.

References m_plotLayer.

60 { m_plotLayer = aLayer; }
LAYER_NUM m_plotLayer
the layer to plot

Member Data Documentation

BOARD* PLOT_CONTROLLER::m_board
private

The board we're plotting.

Definition at line 122 of file plotcontroller.h.

Referenced by OpenPlotfile(), PLOT_CONTROLLER(), and PlotLayer().

wxFileName PLOT_CONTROLLER::m_plotFile
private

The current plot filename, set by OpenPlotfile.

Definition at line 125 of file plotcontroller.h.

Referenced by GetPlotDirName(), GetPlotFileName(), and OpenPlotfile().

LAYER_NUM PLOT_CONTROLLER::m_plotLayer
private

the layer to plot

Definition at line 112 of file plotcontroller.h.

Referenced by GetLayer(), PLOT_CONTROLLER(), and SetLayer().

PCB_PLOT_PARAMS PLOT_CONTROLLER::m_plotOptions
private

Option bank.

Definition at line 115 of file plotcontroller.h.

Referenced by GetPlotOptions().

PLOTTER* PLOT_CONTROLLER::m_plotter
private

This is the plotter object; it starts NULL and become instantiated when a plotfile is requested.

Definition at line 119 of file plotcontroller.h.

Referenced by ClosePlot(), GetColorMode(), IsPlotOpen(), OpenPlotfile(), PLOT_CONTROLLER(), PlotLayer(), and SetColorMode().


The documentation for this class was generated from the following files: