KiCad PCB EDA Suite
X2_ATTRIBUTE_FILEFUNCTION Class Reference

X2_ATTRIBUTE_FILEFUNCTION ( from TF.FileFunction in Gerber file) Example file function: TF.FileFunction,Copper,L1,Top*%. More...

#include <X2_gerber_attributes.h>

Inheritance diagram for X2_ATTRIBUTE_FILEFUNCTION:
X2_ATTRIBUTE

Public Member Functions

 X2_ATTRIBUTE_FILEFUNCTION (X2_ATTRIBUTE &aAttributeBase)
 
bool IsCopper ()
 return true if the filefunction type is "Copper" More...
 
bool IsDrillFile ()
 
const wxString & GetFileType ()
 the type of layer (Copper, Soldermask ... ) More...
 
const wxString & GetBrdLayerId ()
 the brd layer identifier: Ln, only for Copper type or Top, Bot for other types More...
 
const wxString GetDrillLayerPair ()
 
const wxString & GetLPType ()
 
const wxString & GetRouteType ()
 
const wxString & GetBrdLayerSide ()
 the brd layer Pos: Top, Bot, Inr same as GetBrdLayerId() for non copper type More...
 
const wxString & GetLabel ()
 the filefunction label, if any More...
 
int GetZOrder ()
 the Order of the board layer, from front (Top) side to back (Bot) side More...
 
int GetZSubOrder ()
 the Order of the bdr copper layer, from front (Top) side to back (Bot) side More...
 
wxArrayString & GetPrms ()
 
const wxString & GetPrm (int aIdx)
 
const wxString & GetAttribute ()
 
int GetPrmCount ()
 
bool ParseAttribCmd (FILE *aFile, char *aBuffer, int aBuffSize, char *&aText, int &aLineNum)
 Parse a TF command terminated with a % and fill m_Prms by the parameters found. More...
 
void DbgListPrms ()
 Debug function: print using wxLogMessage le list of parameters. More...
 
bool IsFileFunction ()
 Return true if the attribute is .FileFunction. More...
 
bool IsFileMD5 ()
 Return true if the attribute is .MD5. More...
 
bool IsFilePart ()
 Return true if the attribute is .Part. More...
 

Protected Attributes

wxArrayString m_Prms
 the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '. More...
 

Private Member Functions

void set_Z_Order ()
 Initialize the z order priority of the current file, from its attributes. More...
 

Private Attributes

int m_z_order
 
int m_z_sub_order
 

Detailed Description

X2_ATTRIBUTE_FILEFUNCTION ( from TF.FileFunction in Gerber file) Example file function: TF.FileFunction,Copper,L1,Top*%.

  • Type. Such as copper, solder mask etc.
  • Position. Specifies where the file appears in the PCB layer structure. Corresponding position substring: Copper layer: L1, L2, L3...to indicate the layer position followed by Top, Inr or Bot. L1 is always the top copper layer. E.g. L2,Inr. Extra layer, e.g. solder mask: Top or Bot - defines the attachment of the layer. Drill/rout layer: E.g. 1,4 - where 1 is the start and 4 is the end copper layer. The pair 1,4 defines the span of the drill/rout file Optional index. This can be used in instances where for example there are two solder masks on the same side. The index counts from the PCB surface outwards.

Definition at line 149 of file X2_gerber_attributes.h.

Constructor & Destructor Documentation

◆ X2_ATTRIBUTE_FILEFUNCTION()

X2_ATTRIBUTE_FILEFUNCTION::X2_ATTRIBUTE_FILEFUNCTION ( X2_ATTRIBUTE aAttributeBase)

Definition at line 151 of file X2_gerber_attributes.cpp.

152  : X2_ATTRIBUTE()
153 {
154  m_Prms = aAttributeBase.GetPrms();
155  m_z_order = 0;
156 
157  // ensure at least 7 parameters exist.
158  while( GetPrmCount() < 7 )
159  m_Prms.Add( wxEmptyString );
160 
161  set_Z_Order();
162 }
wxArrayString & GetPrms()
void set_Z_Order()
Initialize the z order priority of the current file, from its attributes.
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References X2_ATTRIBUTE::GetPrmCount(), X2_ATTRIBUTE::GetPrms(), X2_ATTRIBUTE::m_Prms, m_z_order, and set_Z_Order().

Member Function Documentation

◆ DbgListPrms()

void X2_ATTRIBUTE::DbgListPrms ( )
inherited

Debug function: print using wxLogMessage le list of parameters.

Definition at line 76 of file X2_gerber_attributes.cpp.

77 {
78  wxLogMessage( wxT( "prms count %d" ), GetPrmCount() );
79 
80  for( int ii = 0; ii < GetPrmCount(); ii++ )
81  wxLogMessage( m_Prms.Item( ii ) );
82 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References X2_ATTRIBUTE::GetPrmCount(), and X2_ATTRIBUTE::m_Prms.

◆ GetAttribute()

const wxString & X2_ATTRIBUTE::GetAttribute ( )
inherited
Returns
the attribute name (for instance .FileFunction) which is given by TF command (i.e. the first parameter read).

Definition at line 59 of file X2_gerber_attributes.cpp.

60 {
61  return m_Prms.Item( 0 );
62 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References X2_ATTRIBUTE::m_Prms.

Referenced by X2_ATTRIBUTE::IsFileFunction(), X2_ATTRIBUTE::IsFileMD5(), and X2_ATTRIBUTE::IsFilePart().

◆ GetBrdLayerId()

const wxString & X2_ATTRIBUTE_FILEFUNCTION::GetBrdLayerId ( )

the brd layer identifier: Ln, only for Copper type or Top, Bot for other types

Definition at line 172 of file X2_gerber_attributes.cpp.

173 {
174  // the brd layer identifier: Ln (for Copper type) or Top, Bot
175  return m_Prms.Item( 2 );
176 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References X2_ATTRIBUTE::m_Prms.

Referenced by LAYERS_MAP_DIALOG::findNumX2GerbersLoaded(), GERBER_FILE_IMAGE_LIST::GetDisplayName(), and set_Z_Order().

◆ GetBrdLayerSide()

const wxString & X2_ATTRIBUTE_FILEFUNCTION::GetBrdLayerSide ( )

the brd layer Pos: Top, Bot, Inr same as GetBrdLayerId() for non copper type

Definition at line 188 of file X2_gerber_attributes.cpp.

189 {
190  if( IsCopper() )
191  // the brd layer identifier: Top, Bot, Inr
192  return m_Prms.Item( 3 );
193  else
194  // the brd layer identifier: Top, Bot ( same as GetBrdLayerId() )
195  return m_Prms.Item( 2 );
196 }
bool IsCopper()
return true if the filefunction type is "Copper"
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References IsCopper(), and X2_ATTRIBUTE::m_Prms.

Referenced by LAYERS_MAP_DIALOG::findNumX2GerbersLoaded(), and GERBER_FILE_IMAGE_LIST::GetDisplayName().

◆ GetDrillLayerPair()

const wxString X2_ATTRIBUTE_FILEFUNCTION::GetDrillLayerPair ( )
Returns
the brd layer pair identifier: n,m for drill files (files with m_Prms.Item( 1 ) = "Plated" or "NotPlated")

Definition at line 179 of file X2_gerber_attributes.cpp.

180 {
181  // the layer pair identifiers, for drill files, i.e.
182  // with m_Prms.Item( 1 ) = "Plated" or "NonPlated"
183  wxString lpair = m_Prms.Item( 2 ) + ',' + m_Prms.Item( 3 );
184  return lpair;
185 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References X2_ATTRIBUTE::m_Prms.

Referenced by GERBER_FILE_IMAGE_LIST::GetDisplayName().

◆ GetFileType()

const wxString & X2_ATTRIBUTE_FILEFUNCTION::GetFileType ( )

the type of layer (Copper, Soldermask ... )

Definition at line 165 of file X2_gerber_attributes.cpp.

166 {
167  // the type of layer (Copper, Soldermask ... )
168  return m_Prms.Item( 1 );
169 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References X2_ATTRIBUTE::m_Prms.

Referenced by LAYERS_MAP_DIALOG::findNumX2GerbersLoaded(), GERBER_FILE_IMAGE_LIST::GetDisplayName(), IsCopper(), IsDrillFile(), and set_Z_Order().

◆ GetLabel()

const wxString & X2_ATTRIBUTE_FILEFUNCTION::GetLabel ( )

the filefunction label, if any

Definition at line 199 of file X2_gerber_attributes.cpp.

200 {
201  if( IsCopper() )
202  return m_Prms.Item( 4 );
203  else
204  return m_Prms.Item( 3 );
205 }
bool IsCopper()
return true if the filefunction type is "Copper"
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References IsCopper(), and X2_ATTRIBUTE::m_Prms.

◆ GetLPType()

const wxString & X2_ATTRIBUTE_FILEFUNCTION::GetLPType ( )
Returns
the Layer Pair type for drill files (PTH, NPTH, Blind or Buried)

Definition at line 208 of file X2_gerber_attributes.cpp.

209 {
210  // Only for drill files: the Layer Pair type (PTH, NPTH, Blind or Buried)
211  return m_Prms.Item( 4 );
212 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References X2_ATTRIBUTE::m_Prms.

Referenced by GERBER_FILE_IMAGE_LIST::GetDisplayName().

◆ GetPrm()

const wxString & X2_ATTRIBUTE::GetPrm ( int  aIdx)
inherited
Returns
a parameter read in TF command.
Parameters
aIdx= the index of the parameter aIdx = 0 is the parameter read after the TF function (the same as GetAttribute())

Definition at line 65 of file X2_gerber_attributes.cpp.

66 {
67  static const wxString dummy;
68 
69  if( GetPrmCount() > aIdx && aIdx >= 0 )
70  return m_Prms.Item( aIdx );
71 
72  return dummy;
73 }
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References dummy(), X2_ATTRIBUTE::GetPrmCount(), and X2_ATTRIBUTE::m_Prms.

Referenced by GERBER_FILE_IMAGE::RemoveAttribute().

◆ GetPrmCount()

int X2_ATTRIBUTE::GetPrmCount ( )
inlineinherited
Returns
the number of parameters read in TF (or similar like TA TO ...) command.

Definition at line 82 of file X2_gerber_attributes.h.

82 { return int( m_Prms.GetCount() ); }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References X2_ATTRIBUTE::m_Prms.

Referenced by X2_ATTRIBUTE::DbgListPrms(), X2_ATTRIBUTE::GetPrm(), and X2_ATTRIBUTE_FILEFUNCTION().

◆ GetPrms()

wxArrayString& X2_ATTRIBUTE::GetPrms ( )
inlineinherited
Returns
the parameters list read in TF command.

Definition at line 62 of file X2_gerber_attributes.h.

62 { return m_Prms; }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References X2_ATTRIBUTE::m_Prms.

Referenced by X2_ATTRIBUTE_FILEFUNCTION().

◆ GetRouteType()

const wxString & X2_ATTRIBUTE_FILEFUNCTION::GetRouteType ( )
Returns
the drill/routing type for drill files (Drill, Route, Mixed)

Definition at line 215 of file X2_gerber_attributes.cpp.

216 {
217  // Only for drill files: the drill/routing type(Drill, Route, Mixed)
218  return m_Prms.Item( 5 );
219 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References X2_ATTRIBUTE::m_Prms.

Referenced by GERBER_FILE_IMAGE_LIST::GetDisplayName().

◆ GetZOrder()

int X2_ATTRIBUTE_FILEFUNCTION::GetZOrder ( )
inline

the Order of the board layer, from front (Top) side to back (Bot) side

Definition at line 187 of file X2_gerber_attributes.h.

References m_z_order.

Referenced by sortZorder().

◆ GetZSubOrder()

int X2_ATTRIBUTE_FILEFUNCTION::GetZSubOrder ( )
inline

the Order of the bdr copper layer, from front (Top) side to back (Bot) side

Definition at line 189 of file X2_gerber_attributes.h.

Referenced by sortZorder().

◆ IsCopper()

bool X2_ATTRIBUTE_FILEFUNCTION::IsCopper ( )

return true if the filefunction type is "Copper"

Definition at line 222 of file X2_gerber_attributes.cpp.

223 {
224  // the filefunction label, if any
225  return GetFileType().IsSameAs( wxT( "Copper" ), false );
226 }
const wxString & GetFileType()
the type of layer (Copper, Soldermask ... )

References GetFileType().

Referenced by LAYERS_MAP_DIALOG::findNumX2GerbersLoaded(), GetBrdLayerSide(), GERBER_FILE_IMAGE_LIST::GetDisplayName(), GetLabel(), and set_Z_Order().

◆ IsDrillFile()

bool X2_ATTRIBUTE_FILEFUNCTION::IsDrillFile ( )
Returns
true if the filefunction type is "Plated" or "NotPlated" therefore a drill file

Definition at line 229 of file X2_gerber_attributes.cpp.

230 {
231  // the filefunction label, if any
232  return GetFileType().IsSameAs( wxT( "Plated" ), false )
233  || GetFileType().IsSameAs( wxT( "NonPlated" ), false );
234 }
const wxString & GetFileType()
the type of layer (Copper, Soldermask ... )

References GetFileType().

Referenced by GERBER_FILE_IMAGE_LIST::GetDisplayName().

◆ IsFileFunction()

bool X2_ATTRIBUTE::IsFileFunction ( )
inlineinherited

Return true if the attribute is .FileFunction.

Definition at line 106 of file X2_gerber_attributes.h.

107  {
108  return GetAttribute().IsSameAs( wxT(".FileFunction"), false );
109  }
const wxString & GetAttribute()

References X2_ATTRIBUTE::GetAttribute().

◆ IsFileMD5()

bool X2_ATTRIBUTE::IsFileMD5 ( )
inlineinherited

Return true if the attribute is .MD5.

Definition at line 114 of file X2_gerber_attributes.h.

115  {
116  return GetAttribute().IsSameAs( wxT(".MD5"), false );
117  }
const wxString & GetAttribute()

References X2_ATTRIBUTE::GetAttribute().

◆ IsFilePart()

bool X2_ATTRIBUTE::IsFilePart ( )
inlineinherited

Return true if the attribute is .Part.

Definition at line 122 of file X2_gerber_attributes.h.

123  {
124  return GetAttribute().IsSameAs( wxT(".Part"), false );
125  }
const wxString & GetAttribute()

References X2_ATTRIBUTE::GetAttribute().

◆ ParseAttribCmd()

bool X2_ATTRIBUTE::ParseAttribCmd ( FILE *  aFile,
char *  aBuffer,
int  aBuffSize,
char *&  aText,
int &  aLineNum 
)
inherited

Parse a TF command terminated with a % and fill m_Prms by the parameters found.

Parameters
aFile= a FILE* ptr to the current Gerber file.
aBuffer= the buffer containing current Gerber data (can be null)
aBuffSize= the size of the buffer
aText= a pointer to the first char to read from Gerber data stored in aBuffer After parsing, text points the last char of the command line ('') (X2 mode) or the end of line if the line does not contain '' or aBuffer == NULL (X1 mode)
aLineNum= a point to the current line number of aFile
Returns
true if no error.

Definition at line 85 of file X2_gerber_attributes.cpp.

87 {
88  // parse a TF, TA, TO ... command and fill m_Prms by the parameters found.
89  // the "%TF" (start of command) is already read by the caller
90 
91  bool ok = true;
92  std::string data;
93 
94  for( ; ; )
95  {
96  while( *aText )
97  {
98  switch( *aText )
99  {
100  case '%': // end of command
101  return ok; // success completion
102 
103  case ' ':
104  case '\r':
105  case '\n':
106  aText++;
107  break;
108 
109  case '*': // End of block
110  m_Prms.Add( FROM_UTF8( data.c_str() ) );
111  data.clear();
112  aText++;
113  break;
114 
115  case ',': // End of parameter (separator)
116  aText++;
117  m_Prms.Add( FROM_UTF8( data.c_str() ) );
118  data.clear();
119  break;
120 
121  default:
122  data += *aText;
123  aText++;
124  break;
125  }
126  }
127 
128  // end of current line, read another one.
129  if( aBuffer && aFile )
130  {
131  if( fgets( aBuffer, aBuffSize, aFile ) == nullptr )
132  {
133  // end of file
134  ok = false;
135  break;
136  }
137 
138  aLineNum++;
139  aText = aBuffer;
140  }
141  else
142  {
143  return ok;
144  }
145  }
146 
147  return ok;
148 }
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name,...

References FROM_UTF8(), and X2_ATTRIBUTE::m_Prms.

◆ set_Z_Order()

void X2_ATTRIBUTE_FILEFUNCTION::set_Z_Order ( )
private

Initialize the z order priority of the current file, from its attributes.

Definition at line 237 of file X2_gerber_attributes.cpp.

238 {
239  m_z_order = -100; // low level
240  m_z_sub_order = 0;
241 
242  if( IsCopper() )
243  {
244  // Copper layer: the priority is the layer Id
245  m_z_order = 0;
246  wxString num = GetBrdLayerId().Mid( 1 );
247  long lnum;
248 
249  if( num.ToLong( &lnum ) )
250  m_z_sub_order = -lnum;
251  }
252 
253  if( GetFileType().IsSameAs( wxT( "Paste" ), false ) )
254  {
255  // solder paste layer: the priority is top then bottom
256  m_z_order = 1; // for top
257 
258  if( GetBrdLayerId().IsSameAs( wxT( "Bot" ), false ) )
259  m_z_order = -m_z_order;
260  }
261 
262  if( GetFileType().IsSameAs( wxT( "Soldermask" ), false ) )
263  {
264  // solder mask layer: the priority is top then bottom
265  m_z_order = 2; // for top
266 
267  if( GetBrdLayerId().IsSameAs( wxT( "Bot" ), false ) )
268  m_z_order = -m_z_order;
269  }
270 
271  if( GetFileType().IsSameAs( wxT( "Legend" ), false ) )
272  {
273  // Silk screen layer: the priority is top then bottom
274  m_z_order = 3; // for top
275 
276  if( GetBrdLayerId().IsSameAs( wxT( "Bot" ), false ) )
277  m_z_order = -m_z_order;
278  }
279 
280  if( GetFileType().IsSameAs( wxT( "Glue" ), false ) )
281  {
282  // Glue spots used to fix components to the board prior to soldering:
283  // the priority is top then bottom
284  m_z_order = 4; // for top
285 
286  if( GetBrdLayerId().IsSameAs( wxT( "Bot" ), false ) )
287  m_z_order = -m_z_order;
288  }
289 }
const wxString & GetFileType()
the type of layer (Copper, Soldermask ... )
bool IsCopper()
return true if the filefunction type is "Copper"
const wxString & GetBrdLayerId()
the brd layer identifier: Ln, only for Copper type or Top, Bot for other types

References GetBrdLayerId(), GetFileType(), IsCopper(), m_z_order, and m_z_sub_order.

Referenced by X2_ATTRIBUTE_FILEFUNCTION().

Member Data Documentation

◆ m_Prms

wxArrayString X2_ATTRIBUTE::m_Prms
protectedinherited

◆ m_z_order

int X2_ATTRIBUTE_FILEFUNCTION::m_z_order
private

Definition at line 199 of file X2_gerber_attributes.h.

Referenced by GetZOrder(), set_Z_Order(), and X2_ATTRIBUTE_FILEFUNCTION().

◆ m_z_sub_order

int X2_ATTRIBUTE_FILEFUNCTION::m_z_sub_order
private

Definition at line 200 of file X2_gerber_attributes.h.

Referenced by set_Z_Order().


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