KiCad PCB EDA Suite
X2_ATTRIBUTE_FILEFUNCTION Class Reference

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

#include <class_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...
 
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 & 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)
 parse a TF command terminated with a % and fill m_Prms by the parameters found. More...
 
void DbgListPrms ()
 Debug function: pring 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

class 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 class_X2_gerber_attributes.h.

Constructor & Destructor Documentation

X2_ATTRIBUTE_FILEFUNCTION::X2_ATTRIBUTE_FILEFUNCTION ( X2_ATTRIBUTE aAttributeBase)

Definition at line 171 of file class_X2_gerber_attributes.cpp.

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

172  : X2_ATTRIBUTE()
173 {
174  m_Prms = aAttributeBase.GetPrms();
175  m_z_order = 0;
176 
177  //ensure at least 5 parameters
178  while( GetPrmCount() < 5 )
179  m_Prms.Add( wxEmptyString );
180 
181  set_Z_Order();
182 }
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, if starting by '.

Member Function Documentation

void X2_ATTRIBUTE::DbgListPrms ( )
inherited

Debug function: pring using wxLogMessage le list of parameters.

Definition at line 84 of file class_X2_gerber_attributes.cpp.

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

85 {
86  wxLogMessage( wxT("prms count %d"), GetPrmCount() );
87 
88  for( int ii = 0; ii < GetPrmCount(); ii++ )
89  wxLogMessage( m_Prms.Item( ii ) );
90 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
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 63 of file class_X2_gerber_attributes.cpp.

References X2_ATTRIBUTE::m_Prms.

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

64 {
65  return m_Prms.Item( 0 );
66 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
const wxString & X2_ATTRIBUTE_FILEFUNCTION::GetBrdLayerId ( )

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

Definition at line 190 of file class_X2_gerber_attributes.cpp.

References X2_ATTRIBUTE::m_Prms.

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

191 {
192  // the brd layer identifier: Ln (for Copper type) or Top, Bot
193  return m_Prms.Item( 2 );
194 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
const wxString & X2_ATTRIBUTE_FILEFUNCTION::GetBrdLayerSide ( )

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

Definition at line 196 of file class_X2_gerber_attributes.cpp.

References IsCopper(), and X2_ATTRIBUTE::m_Prms.

Referenced by GERBER_FILE_IMAGE_LIST::GetDisplayName().

197 {
198  if( IsCopper() )
199  // the brd layer identifier: Top, Bot, Inr
200  return m_Prms.Item( 3 );
201  else
202  // the brd layer identifier: Top, Bot ( same as GetBrdLayerId() )
203  return m_Prms.Item( 2 );
204 }
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, if starting by '.
const wxString & X2_ATTRIBUTE_FILEFUNCTION::GetFileType ( )

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

Definition at line 184 of file class_X2_gerber_attributes.cpp.

References X2_ATTRIBUTE::m_Prms.

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

185 {
186  // the type of layer (Copper , Soldermask ... )
187  return m_Prms.Item( 1 );
188 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
const wxString & X2_ATTRIBUTE_FILEFUNCTION::GetLabel ( )

the filefunction label, if any

Definition at line 206 of file class_X2_gerber_attributes.cpp.

References IsCopper(), and X2_ATTRIBUTE::m_Prms.

207 {
208  if( IsCopper() )
209  return m_Prms.Item( 4 );
210  else
211  return m_Prms.Item( 3 );
212 }
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, if starting by '.
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 73 of file class_X2_gerber_attributes.cpp.

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

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand(), and GERBER_FILE_IMAGE::RemoveAttribute().

74 {
75  static const wxString dummy;
76 
77  if( GetPrmCount() > aIdx && aIdx >= 0 )
78  return m_Prms.Item( aIdx );
79 
80  return dummy;
81 }
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
int X2_ATTRIBUTE::GetPrmCount ( )
inlineinherited
Returns
the number of parameters read in TF (or similar like TA TO ...) command.

Definition at line 88 of file class_X2_gerber_attributes.h.

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

88 { return int( m_Prms.GetCount() ); }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
wxArrayString& X2_ATTRIBUTE::GetPrms ( )
inlineinherited
Returns
the parameters list read in TF command.

Definition at line 68 of file class_X2_gerber_attributes.h.

References X2_ATTRIBUTE::m_Prms.

Referenced by X2_ATTRIBUTE_FILEFUNCTION().

68 { return m_Prms; }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
int X2_ATTRIBUTE_FILEFUNCTION::GetZOrder ( )
inline

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

Definition at line 166 of file class_X2_gerber_attributes.h.

References m_z_order.

Referenced by sortZorder().

int X2_ATTRIBUTE_FILEFUNCTION::GetZSubOrder ( )
inline

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

Definition at line 168 of file class_X2_gerber_attributes.h.

Referenced by sortZorder().

bool X2_ATTRIBUTE_FILEFUNCTION::IsCopper ( )

return true if the filefunction type is "Copper"

Definition at line 215 of file class_X2_gerber_attributes.cpp.

References GetFileType().

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

216 {
217  // the filefunction label, if any
218  return GetFileType().IsSameAs( wxT( "Copper" ), false );
219 }
const wxString & GetFileType()
the type of layer (Copper, Soldermask ... )
bool X2_ATTRIBUTE::IsFileFunction ( )
inlineinherited

return true if the attribute is .FileFunction

Definition at line 111 of file class_X2_gerber_attributes.h.

References X2_ATTRIBUTE::GetAttribute().

Referenced by GERBER_FILE_IMAGE::Execute_G_Command(), and GERBER_FILE_IMAGE::ExecuteRS274XCommand().

112  {
113  return GetAttribute().IsSameAs( wxT(".FileFunction"), false );
114  }
const wxString & GetAttribute()
bool X2_ATTRIBUTE::IsFileMD5 ( )
inlineinherited

return true if the attribute is .MD5

Definition at line 119 of file class_X2_gerber_attributes.h.

References X2_ATTRIBUTE::GetAttribute().

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

120  {
121  return GetAttribute().IsSameAs( wxT(".MD5"), false );
122  }
const wxString & GetAttribute()
bool X2_ATTRIBUTE::IsFilePart ( )
inlineinherited

return true if the attribute is .Part

Definition at line 127 of file class_X2_gerber_attributes.h.

References X2_ATTRIBUTE::GetAttribute().

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

128  {
129  return GetAttribute().IsSameAs( wxT(".Part"), false );
130  }
const wxString & GetAttribute()
bool X2_ATTRIBUTE::ParseAttribCmd ( FILE *  aFile,
char *  aBuffer,
int  aBuffSize,
char *&  aText 
)
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)
Returns
true if no error.

Definition at line 98 of file class_X2_gerber_attributes.cpp.

References X2_ATTRIBUTE::m_Prms.

Referenced by GERBER_FILE_IMAGE::Execute_G_Command(), GERBER_FILE_IMAGE::ExecuteRS274XCommand(), and EXCELLON_IMAGE::LoadFile().

99 {
100  bool ok = true;
101  wxString data;
102 
103  for( ; ; )
104  {
105  while( *aText )
106  {
107  switch( *aText )
108  {
109  case '%': // end of command
110  return ok; // success completion
111 
112  case ' ':
113  case '\r':
114  case '\n':
115  aText++;
116  break;
117 
118  case '*': // End of block
119  m_Prms.Add( data );
120  data.Empty();
121  aText++;
122  break;
123 
124  case ',': // End of parameter
125  aText++;
126  m_Prms.Add( data );
127  data.Empty();
128  break;
129 
130  default:
131  data.Append( *aText );
132  aText++;
133  break;
134  }
135  }
136 
137  // end of current line, read another one.
138  if( aBuffer )
139  {
140  if( fgets( aBuffer, aBuffSize, aFile ) == NULL )
141  {
142  // end of file
143  ok = false;
144  break;
145  }
146 
147  aText = aBuffer;
148  }
149  else
150  return ok;
151  }
152 
153  return ok;
154 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
void X2_ATTRIBUTE_FILEFUNCTION::set_Z_Order ( )
private

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

Definition at line 226 of file class_X2_gerber_attributes.cpp.

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

Referenced by X2_ATTRIBUTE_FILEFUNCTION().

227 {
228  m_z_order = -100; // low level
229  m_z_sub_order = 0;
230 
231  if( IsCopper() )
232  {
233  // Copper layer: the priority is the layer Id
234  m_z_order = 0;
235  wxString num = GetBrdLayerId().Mid( 1 );
236  long lnum;
237  if( num.ToLong( &lnum ) )
238  m_z_sub_order = -lnum;
239  }
240 
241  if( GetFileType().IsSameAs( wxT( "Paste" ), false ) )
242  {
243  // solder paste layer: the priority is top then bottom
244  m_z_order = 1; // for top
245 
246  if( GetBrdLayerId().IsSameAs( wxT( "Bot" ), false ) )
247  m_z_order = -m_z_order;
248  }
249 
250  if( GetFileType().IsSameAs( wxT( "Soldermask" ), false ) )
251  {
252  // solder mask layer: the priority is top then bottom
253  m_z_order = 2; // for top
254 
255  if( GetBrdLayerId().IsSameAs( wxT( "Bot" ), false ) )
256  m_z_order = -m_z_order;
257  }
258 
259  if( GetFileType().IsSameAs( wxT( "Legend" ), false ) )
260  {
261  // Silk screen layer: the priority is top then bottom
262  m_z_order = 3; // for top
263 
264  if( GetFileType().IsSameAs( wxT( "Legend" ), false ) )
265 
266  if( GetBrdLayerId().IsSameAs( wxT( "Bot" ), false ) )
267  m_z_order = -m_z_order;
268  }
269 }
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

Member Data Documentation

wxArrayString X2_ATTRIBUTE::m_Prms
protectedinherited

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

'

Definition at line 57 of file class_X2_gerber_attributes.h.

Referenced by X2_ATTRIBUTE::DbgListPrms(), X2_ATTRIBUTE::GetAttribute(), GetBrdLayerId(), GetBrdLayerSide(), GetFileType(), GetLabel(), X2_ATTRIBUTE::GetPrm(), X2_ATTRIBUTE::GetPrms(), X2_ATTRIBUTE::ParseAttribCmd(), and X2_ATTRIBUTE_FILEFUNCTION().

int X2_ATTRIBUTE_FILEFUNCTION::m_z_order
private

Definition at line 151 of file class_X2_gerber_attributes.h.

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

int X2_ATTRIBUTE_FILEFUNCTION::m_z_sub_order
private

Definition at line 152 of file class_X2_gerber_attributes.h.

Referenced by set_Z_Order().


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