49 else if( aLayer ==
B_Cu )
52 return wxString::Format( wxT(
"g%d" ), aLayer+1 );
58 case B_Adhes:
return wxT(
"gba" );
59 case F_Adhes:
return wxT(
"gta" );
61 case B_Paste:
return wxT(
"gbp" );
62 case F_Paste:
return wxT(
"gtp" );
64 case B_SilkS:
return wxT(
"gbo" );
65 case F_SilkS:
return wxT(
"gto" );
67 case B_Mask:
return wxT(
"gbs" );
68 case F_Mask:
return wxT(
"gts" );
76 default:
return wxT(
"gbr" );
90 attrib = wxT(
"Glue,Top" );
94 attrib = wxT(
"Glue,Bot" );
98 attrib = wxT(
"Legend,Top" );
102 attrib = wxT(
"Legend,Bot" );
106 attrib = wxT(
"Soldermask,Top" );
110 attrib = wxT(
"Soldermask,Bot" );
114 attrib = wxT(
"Paste,Top" );
118 attrib = wxT(
"Paste,Bot" );
125 attrib = wxT(
"Profile,NP" );
129 attrib = wxT(
"OtherDrawing,Comment" );
133 attrib = wxT(
"Other,Comment" );
137 attrib = wxT(
"Other,ECO1" );
141 attrib = wxT(
"Other,ECO2" );
146 attrib = wxT(
"AssemblyDrawing,Bot" );
151 attrib = wxT(
"AssemblyDrawing,Top" );
159 attrib = wxT(
"Copper,L1,Top" );
167 int ly_id = ( ( aLayer -
B_Cu ) / 2 ) + 1;
168 attrib.Printf( wxT(
"Copper,L%d,Inr" ), ly_id );
171 attrib.Printf( wxT(
"Other,User" ), aLayer+1 );
189 attrib += wxT(
",Signal" );
192 attrib += wxT(
",Plane" );
195 attrib += wxT(
",Mixed" );
204 fileFct.Printf( wxT(
"%%TF.FileFunction,%s*%%" ), attrib );
254 wxString filePolarity;
257 filePolarity = wxT(
"%TF.FilePolarity,Positive*%" );
259 filePolarity = wxT(
"%TF.FilePolarity,Negative*%" );
273 if( aUseX1CompatibilityMode )
275 aText.Replace( wxT(
"%" ), wxEmptyString );
276 aText.Prepend( wxT(
"G04 #@! " ) );
288 aMsg.Replace( wxT(
"," ), wxT(
"_" ) );
289 aMsg.Replace( wxT(
"*" ), wxT(
"\\u002A" ) );
290 aMsg.Replace( wxT(
"%" ), wxT(
"\\u0025" ) );
318 wxString msg = fn.GetFullName();
335 text.Printf( wxT(
"%%TF.ProjectId,%s,%s,%s*%%" ), msg.ToAscii(), guid, rev.ToAscii() );
349 wxString registration_id = wxT(
"Original" );
353 registration_id.Printf( wxT(
"PX%xPY%x" ), auxOrigin.
x, auxOrigin.
y );
355 text.Printf( wxT(
"%%TF.SameCoordinates,%s*%%" ), registration_id.GetData() );
361 bool aUseX1CompatibilityMode )
374 if( !
text.IsEmpty() )
380 const wxString& aSuffix,
const wxString& aExtension )
385 aFilename->SetPath( aOutputDir );
388 aFilename->SetExt( aExtension );
396 wxString suffix = aSuffix;
398 suffix.Trim(
false );
400 wxString badchars = wxFileName::GetForbiddenChars(wxPATH_DOS);
401 badchars.Append(
"%." );
403 for(
unsigned ii = 0; ii < badchars.Len(); ii++ )
404 suffix.Replace( badchars[ii], wxT(
"_") );
406 if( !suffix.IsEmpty() )
407 aFilename->SetName( aFilename->GetName() + wxT(
"-" ) + suffix );
446 const wxString& aSheetName,
const wxString& aSheetPath )
460 std::function<bool( wxString* )> textResolver =
461 [&]( wxString* token ) ->
bool
471 wxFileName outputDir = wxFileName::DirName( outputDirName );
495 m_plotFile.GetFullPath(), aSheetName, aSheetPath );
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
wxString GetBuildVersion()
Get the full KiCad version string.
const VECTOR2I & GetAuxOrigin()
Information pertinent to a Pcbnew printed circuit board.
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
bool ResolveTextVar(wxString *token, int aDepth) const
TITLE_BLOCK & GetTitleBlock()
int GetCopperLayerCount() const
const wxString & GetFileName() const
const PCB_PLOT_PARAMS & GetPlotOptions() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
PROJECT * GetProject() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
bool GetUseAuxOrigin() const
wxString GetOutputDirectory() const
void SetFormat(PLOT_FORMAT aFormat)
Base plotter engine class.
RENDER_SETTINGS * RenderSettings()
bool GetColorMode() const
void AddLineToHeader(const wxString &aExtraString)
Add a line to the list of free lines to print at the beginning of the file.
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
~PLOT_CONTROLLER()
Ensure that the last plot is closed.
bool PlotLayer()
Plot a single layer on the current plotfile m_plotLayer is the layer to plot.
PLOT_CONTROLLER(BOARD *aBoard)
Batch plotter constructor, nothing interesting here.
void SetColorMode(bool aColorMode)
Choose color or bland and white plot mode.
bool OpenPlotfile(const wxString &aSuffix, PLOT_FORMAT aFormat, const wxString &aSheetName=wxEmptyString, const wxString &aSheetPath=wxEmptyString)
Open a new plotfile; works as a factory for plotter objects/.
bool PlotLayers(const LSEQ &aLayerSequence)
Plot a sequence of board layer IDs in the given order.
PLOTTER * m_plotter
This is the plotter object; it starts NULL and become instantiated when a plotfile is.
PCB_PLOT_PARAMS & GetPlotOptions()
Accessor to the plot parameters and options.
void ClosePlot()
Close the current plot, nothing happens if it isn't open.
const wxString & GetRevision() const
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
wxString GetDefaultPlotExtension(PLOT_FORMAT aFormat)
Returns the default plot extension for a format.
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
const wxString GetGerberProtelExtension(int aLayer)
static wxString & makeStringCompatX1(wxString &aText, bool aUseX1CompatibilityMode)
void AddGerberX2Header(PLOTTER *aPlotter, const BOARD *aBoard, bool aUseX1CompatibilityMode)
Calculate some X2 attributes as defined in the Gerber file format specification J4 (chapter 5) and ad...
const wxString GetGerberFileFunctionAttribute(const BOARD *aBoard, int aLayer)
Return the "file function" attribute for aLayer, as defined in the Gerber file format specification J...
static void replaceReservedCharsField(wxString &aMsg)
void AddGerberX2Attribute(PLOTTER *aPlotter, const BOARD *aBoard, int aLayer, bool aUseX1CompatibilityMode)
Calculate some X2 attributes as defined in the Gerber file format specification and add them to the g...
void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Complete a plot filename.
static const wxString GetGerberFilePolarityAttribute(int aLayer)
void PlotOneBoardLayer(BOARD *aBoard, PLOTTER *aPlotter, PCB_LAYER_ID aLayer, const PCB_PLOT_PARAMS &aPlotOpt)
Plot one copper or technical layer.
void PlotBoardLayers(BOARD *aBoard, PLOTTER *aPlotter, const LSEQ &aLayerSequence, const PCB_PLOT_PARAMS &aPlotOptions)
Plot a sequence of board layer IDs.
void PlotInteractiveLayer(BOARD *aBoard, PLOTTER *aPlotter, const PCB_PLOT_PARAMS &aPlotOpt)
Plot interactive items (hypertext links, properties, etc.).
PLOTTER * StartPlotBoard(BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aLayerName, const wxString &aFullFileName, const wxString &aSheetName, const wxString &aSheetPath)
Open a new plotfile using the options (and especially the format) specified in the options and prepar...
PLOT_FORMAT
The set of supported output plot formats.