KiCad PCB EDA Suite
SCH_LEGACY_PLUGIN_CACHE Class Reference

A cache assistant for the part library portion of the SCH_PLUGIN API, and only for the SCH_LEGACY_PLUGIN, so therefore is private to this implementation file, i.e. More...

Public Member Functions

 SCH_LEGACY_PLUGIN_CACHE (const wxString &aLibraryPath)
 
 ~SCH_LEGACY_PLUGIN_CACHE ()
 
int GetModifyHash () const
 
void Save (bool aSaveDocFile=true)
 Save the entire library to file m_libFileName;. More...
 
void Load ()
 
void AddSymbol (const LIB_PART *aPart)
 
void DeleteAlias (const wxString &aAliasName)
 
void DeleteSymbol (const wxString &aAliasName)
 
wxFileName GetRealFile () const
 
wxDateTime GetLibModificationTime ()
 
bool IsFile (const wxString &aFullPathAndFileName) const
 
bool IsFileChanged () const
 
void SetModified (bool aModified=true)
 
wxString GetLogicalName () const
 
void SetFileName (const wxString &aFileName)
 
wxString GetFileName () const
 

Private Member Functions

LIB_PARTloadPart (FILE_LINE_READER &aReader)
 
void loadHeader (FILE_LINE_READER &aReader)
 
void loadAliases (std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
 
void loadField (std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
 
void loadDrawEntries (std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
 
void loadFootprintFilters (std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
 
void loadDocs ()
 
LIB_ARCloadArc (std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
 
LIB_CIRCLEloadCircle (std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
 
LIB_TEXTloadText (std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
 
LIB_RECTANGLEloadRectangle (std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
 
LIB_PINloadPin (std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
 
LIB_POLYLINEloadPolyLine (std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
 
LIB_BEZIERloadBezier (std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
 
FILL_T parseFillMode (FILE_LINE_READER &aReader, const char *aLine, const char **aOutput)
 
bool checkForDuplicates (wxString &aAliasName)
 
LIB_ALIASremoveAlias (LIB_ALIAS *aAlias)
 
void saveDocFile ()
 
void saveSymbol (LIB_PART *aSymbol, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
 
void saveArc (LIB_ARC *aArc, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
 
void saveBezier (LIB_BEZIER *aBezier, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
 
void saveCircle (LIB_CIRCLE *aCircle, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
 
void saveField (LIB_FIELD *aField, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
 
void savePin (LIB_PIN *aPin, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
 
void savePolyLine (LIB_POLYLINE *aPolyLine, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
 
void saveRectangle (LIB_RECTANGLE *aRectangle, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
 
void saveText (LIB_TEXT *aText, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
 

Private Attributes

wxString m_fileName
 
wxFileName m_libFileName
 
wxDateTime m_fileModTime
 
LIB_ALIAS_MAP m_aliases
 
bool m_isWritable
 
bool m_isModified
 
int m_versionMajor
 
int m_versionMinor
 
int m_libType
 
friend SCH_LEGACY_PLUGIN
 

Static Private Attributes

static int m_modHash = 1
 

Detailed Description

A cache assistant for the part library portion of the SCH_PLUGIN API, and only for the SCH_LEGACY_PLUGIN, so therefore is private to this implementation file, i.e.

not placed into a header.

Definition at line 465 of file sch_legacy_plugin.cpp.

Constructor & Destructor Documentation

SCH_LEGACY_PLUGIN_CACHE::SCH_LEGACY_PLUGIN_CACHE ( const wxString &  aLibraryPath)
SCH_LEGACY_PLUGIN_CACHE::~SCH_LEGACY_PLUGIN_CACHE ( )

Definition at line 2194 of file sch_legacy_plugin.cpp.

References LIB_PART::GetAliasCount(), GetChars(), GetLogicalName(), m_aliases, and traceSchLegacyPlugin.

2195 {
2196  // When the cache is destroyed, all of the alias objects on the heap should be deleted.
2197  for( LIB_ALIAS_MAP::iterator it = m_aliases.begin(); it != m_aliases.end(); ++it )
2198  {
2199  wxLogTrace( traceSchLegacyPlugin, wxT( "Removing alias %s from library %s." ),
2200  GetChars( it->second->GetName() ), GetChars( GetLogicalName() ) );
2201  LIB_PART* part = it->second->GetPart();
2202  LIB_ALIAS* alias = it->second;
2203  delete alias;
2204 
2205  // When the last alias of a part is destroyed, the part is no longer required and it
2206  // too is destroyed.
2207  if( part && part->GetAliasCount() == 0 )
2208  delete part;
2209  }
2210 
2211  m_aliases.clear();
2212 }
Part library alias object definition.
const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
size_t GetAliasCount() const
Define a library symbol object.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
wxString GetLogicalName() const

Member Function Documentation

void SCH_LEGACY_PLUGIN_CACHE::AddSymbol ( const LIB_PART aPart)

Definition at line 2311 of file sch_legacy_plugin.cpp.

References LIB_PART::GetAliasNames(), LIB_PART::GetName(), i, m_aliases, m_isModified, m_modHash, and removeAlias().

Referenced by GetModifyHash().

2312 {
2313  // aPart is cloned in PART_LIB::AddPart(). The cache takes ownership of aPart.
2314  wxArrayString aliasNames = aPart->GetAliasNames();
2315 
2316  for( size_t i = 0; i < aliasNames.size(); i++ )
2317  {
2318  LIB_ALIAS_MAP::iterator it = m_aliases.find( aliasNames[i] );
2319 
2320  if( it != m_aliases.end() )
2321  removeAlias( it->second );
2322 
2323  LIB_ALIAS* alias = const_cast< LIB_PART* >( aPart )->GetAlias( aliasNames[i] );
2324 
2325  wxASSERT_MSG( alias != NULL, "No alias <" + aliasNames[i] + "> found in symbol <" +
2326  aPart->GetName() +">." );
2327 
2328  m_aliases[ aliasNames[i] ] = alias;
2329  }
2330 
2331  m_isModified = true;
2332  ++m_modHash;
2333 }
Part library alias object definition.
Define a library symbol object.
LIB_ALIAS * removeAlias(LIB_ALIAS *aAlias)
wxArrayString GetAliasNames(bool aIncludeRoot=true) const
size_t i
Definition: json11.cpp:597
const wxString & GetName() const
bool SCH_LEGACY_PLUGIN_CACHE::checkForDuplicates ( wxString &  aAliasName)
private

Definition at line 2725 of file sch_legacy_plugin.cpp.

References m_aliases.

Referenced by loadAliases().

2726 {
2727  wxCHECK_MSG( !aAliasName.IsEmpty(), false, "alias name cannot be empty" );
2728 
2729  // The alias name is not a duplicate so don't change it.
2730  if( m_aliases.find( aAliasName ) == m_aliases.end() )
2731  return false;
2732 
2733  int dupCounter = 1;
2734  wxString newAlias = aAliasName;
2735 
2736  // If the alias is already loaded, the library is broken. It may have been possible in
2737  // the past that this could happen so we assign a new alias name to prevent any conflicts
2738  // rather than throw an exception.
2739  while( m_aliases.find( newAlias ) != m_aliases.end() )
2740  {
2741  newAlias = aAliasName << dupCounter;
2742  dupCounter++;
2743  }
2744 
2745  aAliasName = newAlias;
2746 
2747  return true;
2748 }
void SCH_LEGACY_PLUGIN_CACHE::DeleteAlias ( const wxString &  aAliasName)

Definition at line 3916 of file sch_legacy_plugin.cpp.

References Format(), LIB_ALIAS::GetPart(), m_aliases, m_isModified, m_libFileName, m_modHash, next(), LIB_PART::RemoveAlias(), and THROW_IO_ERROR.

Referenced by DeleteSymbol(), and GetModifyHash().

3917 {
3918  LIB_ALIAS_MAP::iterator it = m_aliases.find( aAliasName );
3919 
3920  if( it == m_aliases.end() )
3921  THROW_IO_ERROR( wxString::Format( _( "library %s does not contain an alias %s" ),
3922  m_libFileName.GetFullName(), aAliasName ) );
3923 
3924  LIB_ALIAS* alias = it->second;
3925  LIB_PART* part = alias->GetPart();
3926 
3927  alias = part->RemoveAlias( alias );
3928 
3929  if( !alias )
3930  {
3931  delete part;
3932 
3933  if( m_aliases.size() > 1 )
3934  {
3935  LIB_ALIAS_MAP::iterator next = it;
3936  next++;
3937 
3938  if( next == m_aliases.end() )
3939  next = m_aliases.begin();
3940 
3941  alias = next->second;
3942  }
3943  }
3944 
3945  m_aliases.erase( it );
3946  ++m_modHash;
3947  m_isModified = true;
3948 }
CITER next(CITER it)
Definition: ptree.cpp:130
Part library alias object definition.
Define a library symbol object.
#define THROW_IO_ERROR(msg)
LIB_PART * GetPart() const
Get the shared LIB_PART.
void RemoveAlias(const wxString &aName)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SCH_LEGACY_PLUGIN_CACHE::DeleteSymbol ( const wxString &  aAliasName)

Definition at line 3951 of file sch_legacy_plugin.cpp.

References DeleteAlias(), Format(), LIB_PART::GetAliasNames(), LIB_ALIAS::GetPart(), i, m_aliases, m_libFileName, and THROW_IO_ERROR.

Referenced by GetModifyHash().

3952 {
3953  LIB_ALIAS_MAP::iterator it = m_aliases.find( aAliasName );
3954 
3955  if( it == m_aliases.end() )
3956  THROW_IO_ERROR( wxString::Format( _( "library %s does not contain an alias %s" ),
3957  m_libFileName.GetFullName(), aAliasName ) );
3958 
3959  LIB_ALIAS* alias = it->second;
3960  LIB_PART* part = alias->GetPart();
3961 
3962  wxArrayString aliasNames = part->GetAliasNames();
3963 
3964  // Deleting all of the aliases deletes the symbol from the library.
3965  for( size_t i = 0; i < aliasNames.Count(); i++ )
3966  DeleteAlias( aliasNames[i] );
3967 }
Part library alias object definition.
void DeleteAlias(const wxString &aAliasName)
Define a library symbol object.
#define THROW_IO_ERROR(msg)
LIB_PART * GetPart() const
Get the shared LIB_PART.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
wxArrayString GetAliasNames(bool aIncludeRoot=true) const
size_t i
Definition: json11.cpp:597
wxString SCH_LEGACY_PLUGIN_CACHE::GetFileName ( ) const
inline

Definition at line 557 of file sch_legacy_plugin.cpp.

557 { return m_libFileName.GetFullPath(); }
wxDateTime SCH_LEGACY_PLUGIN_CACHE::GetLibModificationTime ( )

Definition at line 2239 of file sch_legacy_plugin.cpp.

References GetRealFile(), and m_isWritable.

Referenced by GetModifyHash(), and Load().

2240 {
2241  wxFileName fn = GetRealFile();
2242 
2243  // update the writable flag while we have a wxFileName, in a network this
2244  // is possibly quite dynamic anyway.
2245  m_isWritable = fn.IsFileWritable();
2246 
2247  return fn.GetModificationTime();
2248 }
wxFileName GetRealFile() const
wxString SCH_LEGACY_PLUGIN_CACHE::GetLogicalName ( ) const
inline

Definition at line 553 of file sch_legacy_plugin.cpp.

Referenced by ~SCH_LEGACY_PLUGIN_CACHE().

553 { return m_libFileName.GetName(); }
int SCH_LEGACY_PLUGIN_CACHE::GetModifyHash ( ) const
inline
wxFileName SCH_LEGACY_PLUGIN_CACHE::GetRealFile ( ) const

Definition at line 2216 of file sch_legacy_plugin.cpp.

References m_libFileName, and TO_UTF8.

Referenced by GetLibModificationTime(), GetModifyHash(), IsFileChanged(), and Save().

2217 {
2218  wxFileName fn( m_libFileName );
2219 
2220 #ifndef __WINDOWS__
2221  if( fn.Exists( wxFILE_EXISTS_SYMLINK ) )
2222  {
2223  char buffer[ PATH_MAX + 1 ];
2224  ssize_t pathLen = readlink( TO_UTF8( fn.GetFullPath() ), buffer, PATH_MAX );
2225 
2226  if( pathLen > 0 )
2227  {
2228  buffer[ pathLen ] = '\0';
2229  fn.Assign( fn.GetPath() + wxT( "/" ) + wxString::FromUTF8( buffer ) );
2230  fn.Normalize();
2231  }
2232  }
2233 #endif
2234 
2235  return fn;
2236 }
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
bool SCH_LEGACY_PLUGIN_CACHE::IsFile ( const wxString &  aFullPathAndFileName) const

Definition at line 2251 of file sch_legacy_plugin.cpp.

References m_fileName.

Referenced by GetModifyHash().

2252 {
2253  return m_fileName == aFullPathAndFileName;
2254 }
bool SCH_LEGACY_PLUGIN_CACHE::IsFileChanged ( ) const

Definition at line 2257 of file sch_legacy_plugin.cpp.

References GetRealFile(), and m_fileModTime.

Referenced by GetModifyHash().

2258 {
2259  wxFileName fn = GetRealFile();
2260 
2261  if( m_fileModTime.IsValid() && fn.IsOk() && fn.FileExists() )
2262  return fn.GetModificationTime() != m_fileModTime;
2263 
2264  return false;
2265 }
wxFileName GetRealFile() const
void SCH_LEGACY_PLUGIN_CACHE::Load ( )
Todo:
Probably should check for a valid date and time stamp even though it's not used.

Definition at line 2336 of file sch_legacy_plugin.cpp.

References Format(), GetLibModificationTime(), KIDIALOG::KD_ERROR, LIBRARY_TYPE_EESCHEMA, LIBRARY_TYPE_SYMBOL, loadDocs(), loadHeader(), loadPart(), m_fileModTime, m_libFileName, m_libType, m_modHash, m_versionMajor, m_versionMinor, parseInt(), Pgm(), SCH_PARSE_ERROR, strCompare(), THROW_IO_ERROR, traceSchLegacyPlugin, and USE_OLD_DOC_FILE_FORMAT.

Referenced by GetModifyHash().

2337 {
2338  if( !m_libFileName.FileExists() )
2339  {
2340  wxString msg = wxString::Format( _( "Library file \"%s\" not found.\n\n"
2341  "Use the Manage Symbol Libraries dialog to fix the "
2342  "path (or remove the library)." ),
2343  m_libFileName.GetFullPath() );
2344  KIDIALOG dlg( Pgm().App().GetTopWindow(), msg, KIDIALOG::KD_ERROR );
2345  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
2346  dlg.ShowModal();
2347  return;
2348  }
2349 
2350  wxCHECK_RET( m_libFileName.IsAbsolute(),
2351  wxString::Format( "Cannot use relative file paths in legacy plugin to "
2352  "open library \"%s\".", m_libFileName.GetFullPath() ) );
2353 
2354  wxLogTrace( traceSchLegacyPlugin, "Loading legacy symbol file \"%s\"",
2355  m_libFileName.GetFullPath() );
2356 
2357  FILE_LINE_READER reader( m_libFileName.GetFullPath() );
2358 
2359  if( !reader.ReadLine() )
2360  THROW_IO_ERROR( _( "unexpected end of file" ) );
2361 
2362  const char* line = reader.Line();
2363 
2364  if( !strCompare( "EESchema-LIBRARY Version", line, &line ) )
2365  {
2366  // Old .sym files (which are libraries with only one symbol, used to store and reuse shapes)
2367  // EESchema-LIB Version x.x SYMBOL. They are valid files.
2368  if( !strCompare( "EESchema-LIB Version", line, &line ) )
2369  SCH_PARSE_ERROR( "file is not a valid component or symbol library file", reader, line );
2370  }
2371 
2372  m_versionMajor = parseInt( reader, line, &line );
2373 
2374  if( *line != '.' )
2375  SCH_PARSE_ERROR( "invalid file version formatting in header", reader, line );
2376 
2377  line++;
2378 
2379  m_versionMinor = parseInt( reader, line, &line );
2380 
2381  if( m_versionMajor < 1 || m_versionMinor < 0 || m_versionMinor > 99 )
2382  SCH_PARSE_ERROR( "invalid file version in header", reader, line );
2383 
2384  // Check if this is a symbol library which is the same as a component library but without
2385  // any alias, documentation, footprint filters, etc.
2386  if( strCompare( "SYMBOL", line, &line ) )
2387  {
2388  // Symbol files add date and time stamp info to the header.
2390 
2392  }
2393  else
2394  {
2396  }
2397 
2398  while( reader.ReadLine() )
2399  {
2400  line = reader.Line();
2401 
2402  if( *line == '#' || isspace( *line ) ) // Skip comments and blank lines.
2403  continue;
2404 
2405  // Headers where only supported in older library file formats.
2406  if( m_libType == LIBRARY_TYPE_EESCHEMA && strCompare( "$HEADER", line ) )
2407  loadHeader( reader );
2408 
2409  if( strCompare( "DEF", line ) )
2410  {
2411  // Read one DEF/ENDDEF part entry from library:
2412  loadPart( reader );
2413  }
2414  }
2415 
2416  ++m_modHash;
2417 
2418  // Remember the file modification time of library file when the
2419  // cache snapshot was made, so that in a networked environment we will
2420  // reload the cache as needed.
2422 
2424  loadDocs();
2425 }
Helper class to create more flexible dialogs, including &#39;do not show again&#39; checkbox handling...
Definition: confirm.h:44
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
void loadHeader(FILE_LINE_READER &aReader)
Class FILE_LINE_READER is a LINE_READER that reads from an open file.
Definition: richio.h:180
#define THROW_IO_ERROR(msg)
#define USE_OLD_DOC_FILE_FORMAT(major, minor)
Definition: class_library.h:75
#define SCH_PARSE_ERROR(text, reader, pos)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
LIB_PART * loadPart(FILE_LINE_READER &aReader)
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
void SCH_LEGACY_PLUGIN_CACHE::loadAliases ( std::unique_ptr< LIB_PART > &  aPart,
FILE_LINE_READER aReader 
)
private

Definition at line 2751 of file sch_legacy_plugin.cpp.

References checkForDuplicates(), LINE_READER::Line(), parseUnquotedString(), and strCompare().

Referenced by loadPart().

2753 {
2754  wxString newAlias;
2755  const char* line = aReader.Line();
2756 
2757  wxCHECK_RET( strCompare( "ALIAS", line, &line ), "Invalid ALIAS section" );
2758 
2759  // Parse the ALIAS list.
2760  wxString alias;
2761  parseUnquotedString( alias, aReader, line, &line );
2762 
2763  while( !alias.IsEmpty() )
2764  {
2765  newAlias = alias;
2766  checkForDuplicates( newAlias );
2767  aPart->AddAlias( newAlias );
2768  alias.clear();
2769  parseUnquotedString( alias, aReader, line, &line, true );
2770  }
2771 }
static void parseUnquotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
bool checkForDuplicates(wxString &aAliasName)
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
LIB_ARC * SCH_LEGACY_PLUGIN_CACHE::loadArc ( std::unique_ptr< LIB_PART > &  aPart,
FILE_LINE_READER aReader 
)
private

Definition at line 2991 of file sch_legacy_plugin.cpp.

References LIB_ARC::GetPosition(), LIB_ARC::GetRadius(), LINE_READER::Line(), NORMALIZE_ANGLE_POS(), parseFillMode(), parseInt(), RotatePoint(), LIB_ITEM::SetConvert(), LIB_ARC::SetEnd(), LIB_ITEM::SetFillMode(), LIB_ARC::SetFirstRadiusAngle(), LIB_ITEM::SetPosition(), LIB_ARC::SetRadius(), LIB_ARC::SetSecondRadiusAngle(), LIB_ARC::SetStart(), LIB_ITEM::SetUnit(), LIB_ARC::SetWidth(), strCompare(), wxPoint::x, and wxPoint::y.

Referenced by loadDrawEntries().

2993 {
2994  const char* line = aReader.Line();
2995 
2996  wxCHECK_MSG( strCompare( "A", line, &line ), NULL, "Invalid LIB_ARC definition" );
2997 
2998  LIB_ARC* arc = new LIB_ARC( aPart.get() );
2999 
3000  wxPoint center;
3001 
3002  center.x = parseInt( aReader, line, &line );
3003  center.y = parseInt( aReader, line, &line );
3004 
3005  arc->SetPosition( center );
3006  arc->SetRadius( parseInt( aReader, line, &line ) );
3007 
3008  int angle1 = parseInt( aReader, line, &line );
3009  int angle2 = parseInt( aReader, line, &line );
3010 
3011  NORMALIZE_ANGLE_POS( angle1 );
3012  NORMALIZE_ANGLE_POS( angle2 );
3013  arc->SetFirstRadiusAngle( angle1 );
3014  arc->SetSecondRadiusAngle( angle2 );
3015 
3016  arc->SetUnit( parseInt( aReader, line, &line ) );
3017  arc->SetConvert( parseInt( aReader, line, &line ) );
3018  arc->SetWidth( parseInt( aReader, line, &line ) );
3019 
3020  // Old libraries (version <= 2.2) do not have always this FILL MODE param
3021  // when fill mode is no fill (default mode).
3022  if( *line != 0 )
3023  arc->SetFillMode( parseFillMode( aReader, line, &line ) );
3024 
3025  // Actual Coordinates of arc ends are read from file
3026  if( *line != 0 )
3027  {
3028  wxPoint arcStart, arcEnd;
3029 
3030  arcStart.x = parseInt( aReader, line, &line );
3031  arcStart.y = parseInt( aReader, line, &line );
3032  arcEnd.x = parseInt( aReader, line, &line );
3033  arcEnd.y = parseInt( aReader, line, &line );
3034 
3035  arc->SetStart( arcStart );
3036  arc->SetEnd( arcEnd );
3037  }
3038  else
3039  {
3040  // Actual Coordinates of arc ends are not read from file
3041  // (old library), calculate them
3042  wxPoint arcStart( arc->GetRadius(), 0 );
3043  wxPoint arcEnd( arc->GetRadius(), 0 );
3044 
3045  RotatePoint( &arcStart.x, &arcStart.y, -angle1 );
3046  arcStart += arc->GetPosition();
3047  arc->SetStart( arcStart );
3048  RotatePoint( &arcEnd.x, &arcEnd.y, -angle2 );
3049  arcEnd += arc->GetPosition();
3050  arc->SetEnd( arcEnd );
3051  }
3052 
3053  return arc;
3054 }
void SetPosition(const wxPoint &aPosition)
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
void SetFirstRadiusAngle(int aAngle)
Definition: lib_arc.h:140
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:241
void SetWidth(int aWidth) override
Set the width of the draw item to aWidth.
Definition: lib_arc.h:134
void SetEnd(const wxPoint &aPoint)
Definition: lib_arc.h:154
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
int GetRadius() const
Definition: lib_arc.h:138
FILL_T parseFillMode(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput)
void SetFillMode(FILL_T aFillMode)
void SetSecondRadiusAngle(int aAngle)
Definition: lib_arc.h:144
void SetConvert(int aConvert)
void SetUnit(int aUnit)
void SetRadius(int aRadius)
Definition: lib_arc.h:136
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
void SetStart(const wxPoint &aPoint)
Definition: lib_arc.h:150
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_arc.h:121
LIB_BEZIER * SCH_LEGACY_PLUGIN_CACHE::loadBezier ( std::unique_ptr< LIB_PART > &  aPart,
FILE_LINE_READER aReader 
)
private

Definition at line 3333 of file sch_legacy_plugin.cpp.

References LIB_BEZIER::AddPoint(), bezier(), i, LINE_READER::Line(), parseFillMode(), parseInt(), LIB_BEZIER::Reserve(), LIB_ITEM::SetConvert(), LIB_ITEM::SetFillMode(), LIB_ITEM::SetUnit(), LIB_BEZIER::SetWidth(), strCompare(), wxPoint::x, and wxPoint::y.

Referenced by loadDrawEntries().

3335 {
3336  const char* line = aReader.Line();
3337 
3338  wxCHECK_MSG( strCompare( "B", line, &line ), NULL, "Invalid LIB_BEZIER definition" );
3339 
3340  LIB_BEZIER* bezier = new LIB_BEZIER( aPart.get() );
3341 
3342  int points = parseInt( aReader, line, &line );
3343  bezier->SetUnit( parseInt( aReader, line, &line ) );
3344  bezier->SetConvert( parseInt( aReader, line, &line ) );
3345  bezier->SetWidth( parseInt( aReader, line, &line ) );
3346 
3347  wxPoint pt;
3348  bezier->Reserve( points );
3349 
3350  for( int i = 0; i < points; i++ )
3351  {
3352  pt.x = parseInt( aReader, line, &line );
3353  pt.y = parseInt( aReader, line, &line );
3354  bezier->AddPoint( pt );
3355  }
3356 
3357  if( *line != 0 )
3358  bezier->SetFillMode( parseFillMode( aReader, line, &line ) );
3359 
3360  return bezier;
3361 }
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
static dpoint_t bezier(double t, dpoint_t p0, dpoint_t p1, dpoint_t p2, dpoint_t p3)
Definition: trace.cpp:260
void Reserve(size_t aCount)
Definition: lib_bezier.h:66
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
FILL_T parseFillMode(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput)
void SetFillMode(FILL_T aFillMode)
void SetConvert(int aConvert)
void SetUnit(int aUnit)
size_t i
Definition: json11.cpp:597
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
void SetWidth(int aWidth) override
Set the width of the draw item to aWidth.
Definition: lib_bezier.h:104
void AddPoint(const wxPoint &aPoint)
Definition: lib_bezier.h:67
Class LIB_BEZIER defines bezier curve graphic body item.
Definition: lib_bezier.h:39
LIB_CIRCLE * SCH_LEGACY_PLUGIN_CACHE::loadCircle ( std::unique_ptr< LIB_PART > &  aPart,
FILE_LINE_READER aReader 
)
private

Definition at line 3057 of file sch_legacy_plugin.cpp.

References LINE_READER::Line(), parseFillMode(), parseInt(), LIB_ITEM::SetConvert(), LIB_ITEM::SetFillMode(), LIB_ITEM::SetPosition(), LIB_CIRCLE::SetRadius(), LIB_ITEM::SetUnit(), LIB_CIRCLE::SetWidth(), strCompare(), and wxPoint::x.

Referenced by loadDrawEntries().

3059 {
3060  const char* line = aReader.Line();
3061 
3062  wxCHECK_MSG( strCompare( "C", line, &line ), NULL, "Invalid LIB_CIRCLE definition" );
3063 
3064  LIB_CIRCLE* circle = new LIB_CIRCLE( aPart.get() );
3065 
3066  wxPoint center;
3067 
3068  center.x = parseInt( aReader, line, &line );
3069  center.y = parseInt( aReader, line, &line );
3070 
3071  circle->SetPosition( center );
3072  circle->SetRadius( parseInt( aReader, line, &line ) );
3073  circle->SetUnit( parseInt( aReader, line, &line ) );
3074  circle->SetConvert( parseInt( aReader, line, &line ) );
3075  circle->SetWidth( parseInt( aReader, line, &line ) );
3076 
3077  if( *line != 0 )
3078  circle->SetFillMode( parseFillMode( aReader, line, &line ) );
3079 
3080  return circle;
3081 }
void SetPosition(const wxPoint &aPosition)
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
void SetRadius(int aRadius)
Definition: lib_circle.h:101
FILL_T parseFillMode(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput)
void SetFillMode(FILL_T aFillMode)
void SetConvert(int aConvert)
void SetUnit(int aUnit)
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
void SetWidth(int aWidth) override
Set the width of the draw item to aWidth.
Definition: lib_circle.h:99
void SCH_LEGACY_PLUGIN_CACHE::loadDocs ( )
private

Definition at line 2428 of file sch_legacy_plugin.cpp.

References DOC_EXT, DOCFILE_IDENT, LIB_ID::FixIllegalChars(), Format(), FROM_UTF8(), LIB_ID::ID_SCH, m_aliases, m_libFileName, parseUnquotedString(), FILE_LINE_READER::ReadLine(), SCH_PARSE_ERROR, LIB_ALIAS::SetDescription(), LIB_ALIAS::SetDocFileName(), LIB_ALIAS::SetKeyWords(), strCompare(), and THROW_IO_ERROR.

Referenced by Load().

2429 {
2430  const char* line;
2431  wxString text;
2432  wxString aliasName;
2433  wxFileName fn = m_libFileName;
2434  LIB_ALIAS* alias = NULL;;
2435 
2436  fn.SetExt( DOC_EXT );
2437 
2438  // Not all libraries will have a document file.
2439  if( !fn.FileExists() )
2440  return;
2441 
2442  if( !fn.IsFileReadable() )
2443  THROW_IO_ERROR( wxString::Format( _( "user does not have permission to read library "
2444  "document file \"%s\"" ), fn.GetFullPath() ) );
2445 
2446  FILE_LINE_READER reader( fn.GetFullPath() );
2447 
2448  line = reader.ReadLine();
2449 
2450  if( !line )
2451  THROW_IO_ERROR( _( "symbol document library file is empty" ) );
2452 
2453  if( !strCompare( DOCFILE_IDENT, line, &line ) )
2454  SCH_PARSE_ERROR( "invalid document library file version formatting in header",
2455  reader, line );
2456 
2457  while( reader.ReadLine() )
2458  {
2459  line = reader.Line();
2460 
2461  if( *line == '#' ) // Comment line.
2462  continue;
2463 
2464  if( !strCompare( "$CMP", line, &line ) != 0 )
2465  SCH_PARSE_ERROR( "$CMP command expected", reader, line );
2466 
2467  parseUnquotedString( aliasName, reader, line, &line ); // Alias name.
2468  aliasName = LIB_ID::FixIllegalChars( aliasName, LIB_ID::ID_SCH );
2469  LIB_ALIAS_MAP::iterator it = m_aliases.find( aliasName );
2470 
2471  if( it == m_aliases.end() )
2472  wxLogWarning( "Alias '%s' not found in library:\n\n"
2473  "'%s'\n\nat line %d offset %d", aliasName, fn.GetFullPath(),
2474  reader.LineNumber(), (int) (line - reader.Line() ) );
2475  else
2476  alias = it->second;
2477 
2478  // Read the curent alias associated doc.
2479  // if the alias does not exist, just skip the description
2480  // (Can happen if a .dcm is not synchronized with the corresponding .lib file)
2481  while( reader.ReadLine() )
2482  {
2483  line = reader.Line();
2484 
2485  if( !line )
2486  SCH_PARSE_ERROR( "unexpected end of file", reader, line );
2487 
2488  if( strCompare( "$ENDCMP", line, &line ) )
2489  break;
2490 
2491  text = FROM_UTF8( line + 2 );
2492  // Remove spaces at eol, and eol chars:
2493  text = text.Trim();
2494 
2495  switch( line[0] )
2496  {
2497  case 'D':
2498  if( alias )
2499  alias->SetDescription( text );
2500  break;
2501 
2502  case 'K':
2503  if( alias )
2504  alias->SetKeyWords( text );
2505  break;
2506 
2507  case 'F':
2508  if( alias )
2509  alias->SetDocFileName( text );
2510  break;
2511 
2512  case 0:
2513  case '\n':
2514  case '\r':
2515  case '#':
2516  // Empty line or commment
2517  break;
2518 
2519  default:
2520  SCH_PARSE_ERROR( "expected token in symbol definition", reader, line );
2521  }
2522  }
2523  }
2524 }
Part library alias object definition.
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
void SetDocFileName(const wxString &aDocFileName)
Class FILE_LINE_READER is a LINE_READER that reads from an open file.
Definition: richio.h:180
#define DOCFILE_IDENT
static void parseUnquotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
#define DOC_EXT
Definition: class_library.h:50
#define THROW_IO_ERROR(msg)
void SetDescription(const wxString &aDescription)
#define SCH_PARSE_ERROR(text, reader, pos)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SetKeyWords(const wxString &aKeyWords)
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, LIB_ID_TYPE aType, bool aLib=false)
Replace illegal LIB_ID item name characters with underscores &#39;_&#39;.
Definition: lib_id.cpp:352
void SCH_LEGACY_PLUGIN_CACHE::loadDrawEntries ( std::unique_ptr< LIB_PART > &  aPart,
FILE_LINE_READER aReader 
)
private

Definition at line 2917 of file sch_legacy_plugin.cpp.

References LINE_READER::Line(), loadArc(), loadBezier(), loadCircle(), loadPin(), loadPolyLine(), loadRectangle(), loadText(), FILE_LINE_READER::ReadLine(), SCH_PARSE_ERROR, and strCompare().

Referenced by loadPart().

2919 {
2920  const char* line = aReader.Line();
2921 
2922  wxCHECK_RET( strCompare( "DRAW", line, &line ), "Invalid DRAW section" );
2923 
2924  line = aReader.ReadLine();
2925 
2926  while( line )
2927  {
2928  if( strCompare( "ENDDRAW", line, &line ) )
2929  return;
2930 
2931  switch( line[0] )
2932  {
2933  case 'A': // Arc
2934  aPart->AddDrawItem( loadArc( aPart, aReader ) );
2935  break;
2936 
2937  case 'C': // Circle
2938  aPart->AddDrawItem( loadCircle( aPart, aReader ) );
2939  break;
2940 
2941  case 'T': // Text
2942  aPart->AddDrawItem( loadText( aPart, aReader ) );
2943  break;
2944 
2945  case 'S': // Square
2946  aPart->AddDrawItem( loadRectangle( aPart, aReader ) );
2947  break;
2948 
2949  case 'X': // Pin Description
2950  aPart->AddDrawItem( loadPin( aPart, aReader ) );
2951  break;
2952 
2953  case 'P': // Polyline
2954  aPart->AddDrawItem( loadPolyLine( aPart, aReader ) );
2955  break;
2956 
2957  case 'B': // Bezier Curves
2958  aPart->AddDrawItem( loadBezier( aPart, aReader ) );
2959  break;
2960 
2961  case '#': // Comment
2962  case '\n': // Empty line
2963  case '\r':
2964  case 0:
2965  break;
2966 
2967  default:
2968  SCH_PARSE_ERROR( "undefined DRAW entry", aReader, line );
2969  }
2970 
2971  line = aReader.ReadLine();
2972  }
2973 
2974  SCH_PARSE_ERROR( "file ended prematurely loading component draw element", aReader, line );
2975 }
LIB_PIN * loadPin(std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
LIB_BEZIER * loadBezier(std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
LIB_CIRCLE * loadCircle(std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
LIB_ARC * loadArc(std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
LIB_TEXT * loadText(std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
LIB_POLYLINE * loadPolyLine(std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
#define SCH_PARSE_ERROR(text, reader, pos)
LIB_RECTANGLE * loadRectangle(std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
void SCH_LEGACY_PLUGIN_CACHE::loadField ( std::unique_ptr< LIB_PART > &  aPart,
FILE_LINE_READER aReader 
)
private

Definition at line 2774 of file sch_legacy_plugin.cpp.

References TEMPLATE_FIELDNAME::GetDefaultFieldName(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LINE_READER::Line(), LIB_FIELD::m_name, EDA_TEXT::m_Text, MANDATORY_FIELDS, parseChar(), parseInt(), parseQuotedString(), parseUnquotedString(), SCH_PARSE_ERROR, EDA_TEXT::SetBold(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetItalic(), LIB_ITEM::SetPosition(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), TEXT_ANGLE_HORIZ, TEXT_ANGLE_VERT, VALUE, wxPoint::x, and wxPoint::y.

Referenced by loadPart().

2776 {
2777  const char* line = aReader.Line();
2778 
2779  wxCHECK_RET( *line == 'F', "Invalid field line" );
2780 
2781  int id;
2782 
2783  if( sscanf( line + 1, "%d", &id ) != 1 || id < 0 )
2784  SCH_PARSE_ERROR( "invalid field ID", aReader, line + 1 );
2785 
2786  LIB_FIELD* field;
2787 
2788  if( (unsigned) id < MANDATORY_FIELDS )
2789  {
2790  field = aPart->GetField( id );
2791 
2792  // this will fire only if somebody broke a constructor or editor.
2793  // MANDATORY_FIELDS are always present in ram resident components, no
2794  // exceptions, and they always have their names set, even fixed fields.
2795  wxASSERT( field );
2796  }
2797  else
2798  {
2799  field = new LIB_FIELD( aPart.get(), id );
2800  aPart->AddDrawItem( field );
2801  }
2802 
2803  // Skip to the first double quote.
2804  while( *line != '"' && *line != 0 )
2805  line++;
2806 
2807  if( *line == 0 )
2808  SCH_PARSE_ERROR( _( "unexpected end of line" ), aReader, line );
2809 
2810  parseQuotedString( field->m_Text, aReader, line, &line, true );
2811 
2812  // Doctor the *.lib file field which has a "~" in blank fields. New saves will
2813  // not save like this.
2814  if( field->m_Text.size() == 1 && field->m_Text[0] == '~' )
2815  field->m_Text.clear();
2816 
2817  wxPoint pos;
2818 
2819  pos.x = parseInt( aReader, line, &line );
2820  pos.y = parseInt( aReader, line, &line );
2821  field->SetPosition( pos );
2822 
2823  wxSize textSize;
2824 
2825  textSize.x = textSize.y = parseInt( aReader, line, &line );
2826  field->SetTextSize( textSize );
2827 
2828  char textOrient = parseChar( aReader, line, &line );
2829 
2830  if( textOrient == 'H' )
2831  field->SetTextAngle( TEXT_ANGLE_HORIZ );
2832  else if( textOrient == 'V' )
2833  field->SetTextAngle( TEXT_ANGLE_VERT );
2834  else
2835  SCH_PARSE_ERROR( "invalid field text orientation parameter", aReader, line );
2836 
2837  char textVisible = parseChar( aReader, line, &line );
2838 
2839  if( textVisible == 'V' )
2840  field->SetVisible( true );
2841  else if ( textVisible == 'I' )
2842  field->SetVisible( false );
2843  else
2844  SCH_PARSE_ERROR( "invalid field text visibility parameter", aReader, line );
2845 
2846  // It may be technically correct to use the library version to determine if the field text
2847  // attributes are present. If anyone knows if that is valid and what version that would be,
2848  // please change this to test the library version rather than an EOL or the quoted string
2849  // of the field name.
2850  if( *line != 0 && *line != '"' )
2851  {
2852  char textHJustify = parseChar( aReader, line, &line );
2853 
2854  if( textHJustify == 'C' )
2856  else if( textHJustify == 'L' )
2858  else if( textHJustify == 'R' )
2860  else
2861  SCH_PARSE_ERROR( "invalid field text horizontal justification", aReader, line );
2862 
2863  wxString attributes;
2864 
2865  parseUnquotedString( attributes, aReader, line, &line );
2866 
2867  size_t attrSize = attributes.size();
2868 
2869  if( !(attrSize == 3 || attrSize == 1 ) )
2870  SCH_PARSE_ERROR( "invalid field text attributes size", aReader, line );
2871 
2872  switch( (wxChar) attributes[0] )
2873  {
2874  case 'C': field->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break;
2875  case 'B': field->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break;
2876  case 'T': field->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break;
2877  default: SCH_PARSE_ERROR( "invalid field text vertical justification", aReader, line );
2878  }
2879 
2880  if( attrSize == 3 )
2881  {
2882  wxChar attr_1 = attributes[1];
2883  wxChar attr_2 = attributes[2];
2884 
2885  if( attr_1 == 'I' ) // Italic
2886  field->SetItalic( true );
2887  else if( attr_1 != 'N' ) // No italics is default, check for error.
2888  SCH_PARSE_ERROR( "invalid field text italic parameter", aReader, line );
2889 
2890  if ( attr_2 == 'B' ) // Bold
2891  field->SetBold( true );
2892  else if( attr_2 != 'N' ) // No bold is default, check for error.
2893  SCH_PARSE_ERROR( "invalid field text bold parameter", aReader, line );
2894  }
2895  }
2896 
2897  // Fields in RAM must always have names.
2898  if( (unsigned) id < MANDATORY_FIELDS )
2899  {
2900  // Fields in RAM must always have names, because we are trying to get
2901  // less dependent on field ids and more dependent on names.
2902  // Plus assumptions are made in the field editors.
2904 
2905  // Ensure the VALUE field = the part name (can be not the case
2906  // with malformed libraries: edited by hand, or converted from other tools)
2907  if( id == VALUE )
2908  field->m_Text = aPart->GetName();
2909  }
2910  else
2911  {
2912  parseQuotedString( field->m_name, aReader, line, &line, true ); // Optional.
2913  }
2914 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:169
#define TEXT_ANGLE_HORIZ
wxString m_Text
Definition: eda_text.h:374
void SetPosition(const wxPoint &aPosition)
#define TEXT_ANGLE_VERT
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
static char parseChar(FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL)
Parse a single ASCII character and updates the pointer at aOutput if it is not NULL.
void SetItalic(bool isItalic)
Definition: eda_text.h:182
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
Field object used in symbol libraries.
Definition: lib_field.h:59
void SetVisible(bool aVisible)
Definition: eda_text.h:188
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
static void parseUnquotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:207
#define SCH_PARSE_ERROR(text, reader, pos)
static void parseQuotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an quoted ASCII utf8 and updates the pointer at aOutput if it is not NULL.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:206
wxString m_name
Name (not the field text value itself, that is .m_Text)
Definition: lib_field.h:62
#define VALUE
void SetBold(bool aBold)
Definition: eda_text.h:185
void SCH_LEGACY_PLUGIN_CACHE::loadFootprintFilters ( std::unique_ptr< LIB_PART > &  aPart,
FILE_LINE_READER aReader 
)
private

Definition at line 3364 of file sch_legacy_plugin.cpp.

References LINE_READER::Line(), parseUnquotedString(), FILE_LINE_READER::ReadLine(), SCH_PARSE_ERROR, and strCompare().

Referenced by loadPart().

3366 {
3367  const char* line = aReader.Line();
3368 
3369  wxCHECK_RET( strCompare( "$FPLIST", line, &line ), "Invalid footprint filter list" );
3370 
3371  line = aReader.ReadLine();
3372 
3373  while( line )
3374  {
3375  if( strCompare( "$ENDFPLIST", line, &line ) )
3376  return;
3377 
3378  wxString footprint;
3379 
3380  parseUnquotedString( footprint, aReader, line, &line );
3381  aPart->GetFootprints().Add( footprint );
3382  line = aReader.ReadLine();
3383  }
3384 
3385  SCH_PARSE_ERROR( "file ended prematurely while loading footprint filters", aReader, line );
3386 }
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
static void parseUnquotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
#define SCH_PARSE_ERROR(text, reader, pos)
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
void SCH_LEGACY_PLUGIN_CACHE::loadHeader ( FILE_LINE_READER aReader)
private

Definition at line 2527 of file sch_legacy_plugin.cpp.

References LINE_READER::Line(), FILE_LINE_READER::ReadLine(), SCH_PARSE_ERROR, and strCompare().

Referenced by Load(), and SCH_LEGACY_PLUGIN::loadFile().

2528 {
2529  const char* line = aReader.Line();
2530 
2531  wxASSERT( strCompare( "$HEADER", line, &line ) );
2532 
2533  while( aReader.ReadLine() )
2534  {
2535  line = (char*) aReader;
2536 
2537  // The time stamp saved in old library files is not used or saved in the latest
2538  // library file version.
2539  if( strCompare( "TimeStamp", line, &line ) )
2540  continue;
2541  else if( strCompare( "$ENDHEADER", line, &line ) )
2542  return;
2543  }
2544 
2545  SCH_PARSE_ERROR( "$ENDHEADER not found", aReader, line );
2546 }
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
#define SCH_PARSE_ERROR(text, reader, pos)
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
LIB_PART * SCH_LEGACY_PLUGIN_CACHE::loadPart ( FILE_LINE_READER aReader)
private

Definition at line 2549 of file sch_legacy_plugin.cpp.

References EDA_TEXT::Empty(), Format(), LIB_ALIAS::GetName(), LIB_ALIAS::IsRoot(), LIB_VERSION, LINE_READER::Line(), loadAliases(), loadDrawEntries(), loadField(), loadFootprintFilters(), m_aliases, m_fileName, m_versionMajor, m_versionMinor, name, parseChar(), parseInt(), parseUnquotedString(), FILE_LINE_READER::ReadLine(), SCH_PARSE_ERROR, LIB_ALIAS::SetName(), LIB_FIELD::SetText(), EDA_TEXT::SetVisible(), and strCompare().

Referenced by Load().

2550 {
2551  const char* line = aReader.Line();
2552 
2553  wxCHECK( strCompare( "DEF", line, &line ), NULL );
2554 
2555  // Read DEF line:
2556  char yes_no = 0;
2557 
2558  std::unique_ptr< LIB_PART > part( new LIB_PART( wxEmptyString ) );
2559 
2560  wxString name, prefix;
2561 
2562  parseUnquotedString( name, aReader, line, &line ); // Part name.
2563  parseUnquotedString( prefix, aReader, line, &line ); // Prefix name
2564  parseInt( aReader, line, &line ); // NumOfPins, unused.
2565  part->SetPinNameOffset( parseInt( aReader, line, &line ) ); // Pin name offset.
2566  yes_no = parseChar( aReader, line, &line ); // Show pin numbers.
2567 
2568  if( !( yes_no == 'Y' || yes_no == 'N') )
2569  SCH_PARSE_ERROR( "expected Y or N", aReader, line );
2570 
2571  part->SetShowPinNumbers( ( yes_no == 'N' ) ? false : true );
2572 
2573  yes_no = parseChar( aReader, line, &line ); // Show pin numbers.
2574 
2575  if( !( yes_no == 'Y' || yes_no == 'N') )
2576  SCH_PARSE_ERROR( "expected Y or N", aReader, line );
2577 
2578  part->SetShowPinNames( ( yes_no == 'N' ) ? false : true ); // Show pin names.
2579 
2580  part->SetUnitCount( parseInt( aReader, line, &line ) ); // Number of units.
2581 
2582  // Ensure m_unitCount is >= 1. Could be read as 0 in old libraries.
2583  if( part->GetUnitCount() < 1 )
2584  part->SetUnitCount( 1 );
2585 
2586  // Copy part name and prefix.
2587 
2588  // The root alias is added to the alias list by SetName() which is called by SetText().
2589  if( name.IsEmpty() )
2590  {
2591  part->SetName( "~" );
2592  }
2593  else if( name[0] != '~' )
2594  {
2595  part->SetName( name );
2596  }
2597  else
2598  {
2599  part->SetName( name.Right( name.Length() - 1 ) );
2600  part->GetValueField().SetVisible( false );
2601  }
2602 
2603  // Don't set the library alias, this is determined by the symbol library table.
2604  part->SetLibId( LIB_ID( wxEmptyString, part->GetName() ) );
2605 
2606  // There are some code paths in SetText() that do not set the root alias to the
2607  // alias list so add it here if it didn't get added by SetText().
2608  if( !part->HasAlias( part->GetName() ) )
2609  part->AddAlias( part->GetName() );
2610 
2611  LIB_FIELD& reference = part->GetReferenceField();
2612 
2613  if( prefix == "~" )
2614  {
2615  reference.Empty();
2616  reference.SetVisible( false );
2617  }
2618  else
2619  {
2620  reference.SetText( prefix );
2621  }
2622 
2623  // In version 2.2 and earlier, this parameter was a '0' which was just a place holder.
2624  // The was no concept of interchangeable multiple unit symbols.
2626  {
2627  // Nothing needs to be set since the default setting for symbols with multiple
2628  // units were never interchangeable. Just parse the 0 an move on.
2629  parseInt( aReader, line, &line );
2630  }
2631  else
2632  {
2633  char locked = parseChar( aReader, line, &line );
2634 
2635  if( locked == 'L' )
2636  part->LockUnits( true );
2637  else if( locked == 'F' || locked == '0' )
2638  part->LockUnits( false );
2639  else
2640  SCH_PARSE_ERROR( "expected L, F, or 0", aReader, line );
2641  }
2642 
2643 
2644  // There is the optional power component flag.
2645  if( *line )
2646  {
2647  char power = parseChar( aReader, line, &line );
2648 
2649  if( power == 'P' )
2650  part->SetPower();
2651  else if( power == 'N' )
2652  part->SetNormal();
2653  else
2654  SCH_PARSE_ERROR( "expected P or N", aReader, line );
2655  }
2656 
2657  line = aReader.ReadLine();
2658 
2659  // Read lines until "ENDDEF" is found.
2660  while( line )
2661  {
2662  if( *line == '#' ) // Comment
2663  ;
2664  else if( strCompare( "Ti", line, &line ) ) // Modification date is ignored.
2665  continue;
2666  else if( strCompare( "ALIAS", line, &line ) ) // Aliases
2667  loadAliases( part, aReader );
2668  else if( *line == 'F' ) // Fields
2669  loadField( part, aReader );
2670  else if( strCompare( "DRAW", line, &line ) ) // Drawing objects.
2671  loadDrawEntries( part, aReader );
2672  else if( strCompare( "$FPLIST", line, &line ) ) // Footprint filter list
2673  loadFootprintFilters( part, aReader );
2674  else if( strCompare( "ENDDEF", line, &line ) ) // End of part description
2675  {
2676  // Add aliases
2677  for( size_t ii = 0; ii < part->GetAliasCount(); ++ii )
2678  {
2679  LIB_ALIAS* alias = part->GetAlias( ii );
2680  const wxString& aliasName = alias->GetName();
2681  auto it = m_aliases.find( aliasName );
2682 
2683  if( it != m_aliases.end() )
2684  {
2685  // Find a new name for the alias
2686  wxString newName;
2687  int idx = 0;
2688  LIB_ALIAS_MAP::const_iterator jt;
2689 
2690  do
2691  {
2692  newName = wxString::Format( "%s_%d", aliasName, idx );
2693  jt = m_aliases.find( newName );
2694  ++idx;
2695  }
2696  while( jt != m_aliases.end() );
2697 
2698  wxLogWarning( "Symbol name conflict in library:\n%s\n"
2699  "'%s' has been renamed to '%s'",
2700  m_fileName, aliasName, newName );
2701 
2702  if( alias->IsRoot() )
2703  part->SetName( newName );
2704  else
2705  alias->SetName( newName );
2706 
2707  m_aliases[newName] = alias;
2708  }
2709  else
2710  {
2711  m_aliases[aliasName] = alias;
2712  }
2713  }
2714 
2715  return part.release();
2716  }
2717 
2718  line = aReader.ReadLine();
2719  }
2720 
2721  SCH_PARSE_ERROR( "missing ENDDEF", aReader, line );
2722 }
Part library alias object definition.
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
static char parseChar(FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL)
Parse a single ASCII character and updates the pointer at aOutput if it is not NULL.
Field object used in symbol libraries.
Definition: lib_field.h:59
void SetVisible(bool aVisible)
Definition: eda_text.h:188
#define LIB_VERSION(major, minor)
Definition: class_library.h:61
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void loadAliases(std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
bool IsRoot() const override
For symbols having aliases, IsRoot() indicates the principal item.
void SetName(const wxString &aName)
void SetText(const wxString &aText) override
Sets the field text to aText.
Definition: lib_field.cpp:510
static void parseUnquotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
void Empty()
Definition: eda_text.h:244
Define a library symbol object.
void loadField(std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
void loadDrawEntries(std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
#define SCH_PARSE_ERROR(text, reader, pos)
const wxString & GetName() const override
const char * name
Definition: DXF_plotter.cpp:61
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
void loadFootprintFilters(std::unique_ptr< LIB_PART > &aPart, FILE_LINE_READER &aReader)
LIB_PIN * SCH_LEGACY_PLUGIN_CACHE::loadPin ( std::unique_ptr< LIB_PART > &  aPart,
FILE_LINE_READER aReader 
)
private

Definition at line 3206 of file sch_legacy_plugin.cpp.

References LINE_READER::Line(), LIB_PIN::m_attributes, LIB_ITEM::m_Convert, LIB_PIN::m_length, LIB_PIN::m_name, LIB_PIN::m_nameTextSize, LIB_PIN::m_number, LIB_PIN::m_numTextSize, LIB_PIN::m_orientation, LIB_PIN::m_position, LIB_PIN::m_shape, LIB_PIN::m_type, LIB_ITEM::m_Unit, parseChar(), parseInt(), parseUnquotedString(), PIN_BIDI, PIN_INPUT, PIN_INVISIBLE, PIN_NC, PIN_OPENCOLLECTOR, PIN_OPENEMITTER, PIN_OUTPUT, PIN_PASSIVE, PIN_POWER_IN, PIN_POWER_OUT, PIN_TRISTATE, PIN_UNSPECIFIED, PINSHAPE_CLOCK, PINSHAPE_CLOCK_LOW, PINSHAPE_FALLING_EDGE_CLOCK, PINSHAPE_INPUT_LOW, PINSHAPE_INVERTED, PINSHAPE_INVERTED_CLOCK, PINSHAPE_LINE, PINSHAPE_NONLOGIC, PINSHAPE_OUTPUT_LOW, SCH_PARSE_ERROR, strCompare(), wxPoint::x, and wxPoint::y.

Referenced by loadDrawEntries().

3208 {
3209  const char* line = aReader.Line();
3210 
3211  wxCHECK_MSG( strCompare( "X", line, &line ), NULL, "Invalid LIB_PIN definition" );
3212 
3213  LIB_PIN* pin = new LIB_PIN( aPart.get() );
3214 
3215  parseUnquotedString( pin->m_name, aReader, line, &line );
3216  parseUnquotedString( pin->m_number, aReader, line, &line );
3217 
3218  wxPoint pos;
3219  pos.x = parseInt( aReader, line, &line );
3220  pos.y = parseInt( aReader, line, &line );
3221  pin->m_position = pos;
3222 
3223  pin->m_length = parseInt( aReader, line, &line );
3224  pin->m_orientation = parseChar( aReader, line, &line );
3225  pin->m_numTextSize = parseInt( aReader, line, &line );
3226  pin->m_nameTextSize = parseInt( aReader, line, &line );
3227  pin->m_Unit = parseInt( aReader, line, &line );
3228  pin->m_Convert = parseInt( aReader, line, &line );
3229 
3230  char type = parseChar( aReader, line, &line );
3231 
3232  wxString attributes;
3233 
3234  // Optional
3235  parseUnquotedString( attributes, aReader, line, &line, true );
3236 
3237  switch( type )
3238  {
3239  case 'I': pin->m_type = PIN_INPUT; break;
3240  case 'O': pin->m_type = PIN_OUTPUT; break;
3241  case 'B': pin->m_type = PIN_BIDI; break;
3242  case 'T': pin->m_type = PIN_TRISTATE; break;
3243  case 'P': pin->m_type = PIN_PASSIVE; break;
3244  case 'U': pin->m_type = PIN_UNSPECIFIED; break;
3245  case 'W': pin->m_type = PIN_POWER_IN; break;
3246  case 'w': pin->m_type = PIN_POWER_OUT; break;
3247  case 'C': pin->m_type = PIN_OPENCOLLECTOR; break;
3248  case 'E': pin->m_type = PIN_OPENEMITTER; break;
3249  case 'N': pin->m_type = PIN_NC; break;
3250  default: SCH_PARSE_ERROR( "unknown pin type", aReader, line );
3251  }
3252 
3253  if( !attributes.IsEmpty() ) /* Special Symbol defined */
3254  {
3255  enum
3256  {
3257  INVERTED = 1 << 0,
3258  CLOCK = 1 << 1,
3259  LOWLEVEL_IN = 1 << 2,
3260  LOWLEVEL_OUT = 1 << 3,
3261  FALLING_EDGE = 1 << 4,
3262  NONLOGIC = 1 << 5
3263  };
3264 
3265  int flags = 0;
3266 
3267  for( int j = attributes.size(); j > 0; )
3268  {
3269  switch( attributes[--j].GetValue() )
3270  {
3271  case '~': break;
3272  case 'N': pin->m_attributes |= PIN_INVISIBLE; break;
3273  case 'I': flags |= INVERTED; break;
3274  case 'C': flags |= CLOCK; break;
3275  case 'L': flags |= LOWLEVEL_IN; break;
3276  case 'V': flags |= LOWLEVEL_OUT; break;
3277  case 'F': flags |= FALLING_EDGE; break;
3278  case 'X': flags |= NONLOGIC; break;
3279  default: SCH_PARSE_ERROR( "unknown pin attribute", aReader, line );
3280  }
3281  }
3282 
3283  switch( flags )
3284  {
3285  case 0: pin->m_shape = PINSHAPE_LINE; break;
3286  case INVERTED: pin->m_shape = PINSHAPE_INVERTED; break;
3287  case CLOCK: pin->m_shape = PINSHAPE_CLOCK; break;
3288  case INVERTED | CLOCK: pin->m_shape = PINSHAPE_INVERTED_CLOCK; break;
3289  case LOWLEVEL_IN: pin->m_shape = PINSHAPE_INPUT_LOW; break;
3290  case LOWLEVEL_IN | CLOCK: pin->m_shape = PINSHAPE_CLOCK_LOW; break;
3291  case LOWLEVEL_OUT: pin->m_shape = PINSHAPE_OUTPUT_LOW; break;
3292  case FALLING_EDGE: pin->m_shape = PINSHAPE_FALLING_EDGE_CLOCK; break;
3293  case NONLOGIC: pin->m_shape = PINSHAPE_NONLOGIC; break;
3294  default: SCH_PARSE_ERROR( "pin attributes do not define a valid pin shape", aReader, line );
3295  }
3296  }
3297 
3298  return pin;
3299 }
int m_nameTextSize
Pin num and Pin name sizes.
Definition: lib_pin.h:85
GRAPHIC_PINSHAPE m_shape
Shape drawn around pin.
Definition: lib_pin.h:78
int m_numTextSize
Definition: lib_pin.h:84
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
static char parseChar(FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL)
Parse a single ASCII character and updates the pointer at aOutput if it is not NULL.
int m_Unit
Unit identification for multiple parts per package.
wxString m_name
Definition: lib_pin.h:82
int m_length
Length of the pin.
Definition: lib_pin.h:76
int m_orientation
Pin orientation (Up, Down, Left, Right)
Definition: lib_pin.h:77
wxString m_number
Definition: lib_pin.h:83
static void parseUnquotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
#define PIN_INVISIBLE
Definition: lib_pin.h:46
int m_attributes
Set bit 0 to indicate pin is invisible.
Definition: lib_pin.h:81
wxPoint m_position
Position of the pin.
Definition: lib_pin.h:75
#define SCH_PARSE_ERROR(text, reader, pos)
ELECTRICAL_PINTYPE m_type
Electrical type of the pin. See enum ELECTRICAL_PINTYPE.
Definition: lib_pin.h:80
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
int m_Convert
Shape identification for alternate body styles.
LIB_POLYLINE * SCH_LEGACY_PLUGIN_CACHE::loadPolyLine ( std::unique_ptr< LIB_PART > &  aPart,
FILE_LINE_READER aReader 
)
private

Definition at line 3302 of file sch_legacy_plugin.cpp.

References LIB_POLYLINE::AddPoint(), i, LINE_READER::Line(), parseFillMode(), parseInt(), LIB_POLYLINE::Reserve(), LIB_ITEM::SetConvert(), LIB_ITEM::SetFillMode(), LIB_ITEM::SetUnit(), LIB_POLYLINE::SetWidth(), strCompare(), wxPoint::x, and wxPoint::y.

Referenced by loadDrawEntries().

3304 {
3305  const char* line = aReader.Line();
3306 
3307  wxCHECK_MSG( strCompare( "P", line, &line ), NULL, "Invalid LIB_POLYLINE definition" );
3308 
3309  LIB_POLYLINE* polyLine = new LIB_POLYLINE( aPart.get() );
3310 
3311  int points = parseInt( aReader, line, &line );
3312  polyLine->SetUnit( parseInt( aReader, line, &line ) );
3313  polyLine->SetConvert( parseInt( aReader, line, &line ) );
3314  polyLine->SetWidth( parseInt( aReader, line, &line ) );
3315  polyLine->Reserve( points );
3316 
3317  wxPoint pt;
3318 
3319  for( int i = 0; i < points; i++ )
3320  {
3321  pt.x = parseInt( aReader, line, &line );
3322  pt.y = parseInt( aReader, line, &line );
3323  polyLine->AddPoint( pt );
3324  }
3325 
3326  if( *line != 0 )
3327  polyLine->SetFillMode( parseFillMode( aReader, line, &line ) );
3328 
3329  return polyLine;
3330 }
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
void SetWidth(int aWidth) override
Set the width of the draw item to aWidth.
Definition: lib_polyline.h:115
void Reserve(size_t aPointCount)
Definition: lib_polyline.h:65
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
void AddPoint(const wxPoint &aPoint)
FILL_T parseFillMode(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput)
void SetFillMode(FILL_T aFillMode)
void SetConvert(int aConvert)
void SetUnit(int aUnit)
size_t i
Definition: json11.cpp:597
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
LIB_RECTANGLE * SCH_LEGACY_PLUGIN_CACHE::loadRectangle ( std::unique_ptr< LIB_PART > &  aPart,
FILE_LINE_READER aReader 
)
private

Definition at line 3174 of file sch_legacy_plugin.cpp.

References LINE_READER::Line(), parseFillMode(), parseInt(), LIB_ITEM::SetConvert(), LIB_RECTANGLE::SetEnd(), LIB_ITEM::SetFillMode(), LIB_ITEM::SetPosition(), LIB_ITEM::SetUnit(), LIB_RECTANGLE::SetWidth(), strCompare(), wxPoint::x, and wxPoint::y.

Referenced by loadDrawEntries().

3176 {
3177  const char* line = aReader.Line();
3178 
3179  wxCHECK_MSG( strCompare( "S", line, &line ), NULL, "Invalid LIB_RECTANGLE definition" );
3180 
3181  LIB_RECTANGLE* rectangle = new LIB_RECTANGLE( aPart.get() );
3182 
3183  wxPoint pos;
3184 
3185  pos.x = parseInt( aReader, line, &line );
3186  pos.y = parseInt( aReader, line, &line );
3187  rectangle->SetPosition( pos );
3188 
3189  wxPoint end;
3190 
3191  end.x = parseInt( aReader, line, &line );
3192  end.y = parseInt( aReader, line, &line );
3193  rectangle->SetEnd( end );
3194 
3195  rectangle->SetUnit( parseInt( aReader, line, &line ) );
3196  rectangle->SetConvert( parseInt( aReader, line, &line ) );
3197  rectangle->SetWidth( parseInt( aReader, line, &line ) );
3198 
3199  if( *line != 0 )
3200  rectangle->SetFillMode( parseFillMode( aReader, line, &line ) );
3201 
3202  return rectangle;
3203 }
void SetPosition(const wxPoint &aPosition)
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
void SetWidth(int aWidth) override
Set the width of the draw item to aWidth.
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
FILL_T parseFillMode(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput)
void SetFillMode(FILL_T aFillMode)
void SetConvert(int aConvert)
void SetUnit(int aUnit)
void SetEnd(const wxPoint &aEnd)
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
LIB_TEXT * SCH_LEGACY_PLUGIN_CACHE::loadText ( std::unique_ptr< LIB_PART > &  aPart,
FILE_LINE_READER aReader 
)
private

Definition at line 3084 of file sch_legacy_plugin.cpp.

References GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, is_eol(), LIB_VERSION, LINE_READER::Line(), m_versionMajor, m_versionMinor, parseChar(), parseInt(), parseQuotedString(), parseUnquotedString(), SCH_PARSE_ERROR, EDA_TEXT::SetBold(), LIB_ITEM::SetConvert(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetItalic(), LIB_ITEM::SetPosition(), LIB_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextSize(), LIB_ITEM::SetUnit(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), str, strCompare(), wxPoint::x, and wxPoint::y.

Referenced by loadDrawEntries(), and SCH_LEGACY_PLUGIN::loadFile().

3086 {
3087  const char* line = aReader.Line();
3088 
3089  wxCHECK_MSG( strCompare( "T", line, &line ), NULL, "Invalid LIB_TEXT definition" );
3090 
3091  LIB_TEXT* text = new LIB_TEXT( aPart.get() );
3092 
3093  text->SetTextAngle( (double) parseInt( aReader, line, &line ) );
3094 
3095  wxPoint center;
3096 
3097  center.x = parseInt( aReader, line, &line );
3098  center.y = parseInt( aReader, line, &line );
3099  text->SetPosition( center );
3100 
3101  wxSize size;
3102 
3103  size.x = size.y = parseInt( aReader, line, &line );
3104  text->SetTextSize( size );
3105  text->SetVisible( !parseInt( aReader, line, &line ) );
3106  text->SetUnit( parseInt( aReader, line, &line ) );
3107  text->SetConvert( parseInt( aReader, line, &line ) );
3108 
3109  wxString str;
3110 
3111  // If quoted string loading fails, load as not quoted string.
3112  if( *line == '"' )
3113  parseQuotedString( str, aReader, line, &line );
3114  else
3115  {
3116  parseUnquotedString( str, aReader, line, &line );
3117 
3118  // In old libs, "spaces" are replaced by '~' in unquoted strings:
3119  str.Replace( "~", " " );
3120  }
3121 
3122  if( !str.IsEmpty() )
3123  {
3124  // convert two apostrophes back to double quote
3125  str.Replace( "''", "\"" );
3126  }
3127 
3128  text->SetText( str );
3129 
3130  // Here things are murky and not well defined. At some point it appears the format
3131  // was changed to add text properties. However rather than add the token to the end of
3132  // the text definition, it was added after the string and no mention if the file
3133  // verion was bumped or not so this code make break on very old component libraries.
3134  //
3135  // Update: apparently even in the latest version this can be different so added a test
3136  // for end of line before checking for the text properties.
3137  if( LIB_VERSION( m_versionMajor, m_versionMinor ) > LIB_VERSION( 2, 0 ) && !is_eol( *line ) )
3138  {
3139  if( strCompare( "Italic", line, &line ) )
3140  text->SetItalic( true );
3141  else if( !strCompare( "Normal", line, &line ) )
3142  SCH_PARSE_ERROR( "invalid text stype, expected 'Normal' or 'Italic'", aReader, line );
3143 
3144  if( parseInt( aReader, line, &line ) > 0 )
3145  text->SetBold( true );
3146 
3147  // Some old libaries version > 2.0 do not have these options for text justification:
3148  if( !is_eol( *line ) )
3149  {
3150  switch( parseChar( aReader, line, &line ) )
3151  {
3152  case 'L': text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break;
3153  case 'C': text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); break;
3154  case 'R': text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break;
3155  default: SCH_PARSE_ERROR( "invalid horizontal text justication; expected L, C, or R",
3156  aReader, line );
3157  }
3158 
3159  switch( parseChar( aReader, line, &line ) )
3160  {
3161  case 'T': text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break;
3162  case 'C': text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break;
3163  case 'B': text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break;
3164  default: SCH_PARSE_ERROR( "invalid vertical text justication; expected T, C, or B",
3165  aReader, line );
3166  }
3167  }
3168  }
3169 
3170  return text;
3171 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:169
void SetPosition(const wxPoint &aPosition)
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
Define a symbol library graphical text item.
Definition: lib_text.h:44
static char parseChar(FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL)
Parse a single ASCII character and updates the pointer at aOutput if it is not NULL.
void SetItalic(bool isItalic)
Definition: eda_text.h:182
void SetVisible(bool aVisible)
Definition: eda_text.h:188
#define LIB_VERSION(major, minor)
Definition: class_library.h:61
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
const string & str
Definition: json11.cpp:596
static void parseUnquotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:207
static bool is_eol(char c)
void SetConvert(int aConvert)
void SetUnit(int aUnit)
#define SCH_PARSE_ERROR(text, reader, pos)
static void parseQuotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an quoted ASCII utf8 and updates the pointer at aOutput if it is not NULL.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:206
void SetText(const wxString &aText) override
Sets the text item string to aText.
Definition: lib_text.cpp:350
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
void SetBold(bool aBold)
Definition: eda_text.h:185
FILL_T SCH_LEGACY_PLUGIN_CACHE::parseFillMode ( FILE_LINE_READER aReader,
const char *  aLine,
const char **  aOutput 
)
private

Definition at line 2978 of file sch_legacy_plugin.cpp.

References FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, NO_FILL, parseChar(), and SCH_PARSE_ERROR.

Referenced by loadArc(), loadBezier(), loadCircle(), loadPolyLine(), and loadRectangle().

2980 {
2981  switch( parseChar( aReader, aLine, aOutput ) )
2982  {
2983  case 'F': return FILLED_SHAPE;
2984  case 'f': return FILLED_WITH_BG_BODYCOLOR;
2985  case 'N': return NO_FILL;
2986  default: SCH_PARSE_ERROR( "invalid fill type, expected f, F, or N", aReader, aLine );
2987  }
2988 }
static char parseChar(FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL)
Parse a single ASCII character and updates the pointer at aOutput if it is not NULL.
#define SCH_PARSE_ERROR(text, reader, pos)
LIB_ALIAS * SCH_LEGACY_PLUGIN_CACHE::removeAlias ( LIB_ALIAS aAlias)
private

Definition at line 2268 of file sch_legacy_plugin.cpp.

References LIB_ALIAS::GetName(), m_aliases, m_isModified, m_libFileName, m_modHash, next(), and LIB_PART::RemoveAlias().

Referenced by AddSymbol().

2269 {
2270  wxCHECK_MSG( aAlias != NULL, NULL, "NULL pointer cannot be removed from library." );
2271 
2272  LIB_ALIAS_MAP::iterator it = m_aliases.find( aAlias->GetName() );
2273 
2274  if( it == m_aliases.end() )
2275  return NULL;
2276 
2277  // If the entry pointer doesn't match the name it is mapped to in the library, we
2278  // have done something terribly wrong.
2279  wxCHECK_MSG( *it->second == aAlias, NULL,
2280  "Pointer mismatch while attempting to remove alias entry <" + aAlias->GetName() +
2281  "> from library cache <" + m_libFileName.GetName() + ">." );
2282 
2283  LIB_ALIAS* alias = aAlias;
2284  LIB_PART* part = alias->GetPart();
2285 
2286  alias = part->RemoveAlias( alias );
2287 
2288  if( !alias )
2289  {
2290  delete part;
2291 
2292  if( m_aliases.size() > 1 )
2293  {
2294  LIB_ALIAS_MAP::iterator next = it;
2295  next++;
2296 
2297  if( next == m_aliases.end() )
2298  next = m_aliases.begin();
2299 
2300  alias = next->second;
2301  }
2302  }
2303 
2304  m_aliases.erase( it );
2305  m_isModified = true;
2306  ++m_modHash;
2307  return alias;
2308 }
CITER next(CITER it)
Definition: ptree.cpp:130
Part library alias object definition.
Define a library symbol object.
const wxString & GetName() const override
void RemoveAlias(const wxString &aName)
void SCH_LEGACY_PLUGIN_CACHE::Save ( bool  aSaveDocFile = true)

Save the entire library to file m_libFileName;.

Definition at line 3389 of file sch_legacy_plugin.cpp.

References GetRealFile(), LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIBFILE_IDENT, m_aliases, m_fileModTime, m_isModified, saveDocFile(), and saveSymbol().

Referenced by GetModifyHash().

3390 {
3391  if( !m_isModified )
3392  return;
3393 
3394  // Write through symlinks, don't replace them
3395  wxFileName fn = GetRealFile();
3396 
3397  std::unique_ptr< FILE_OUTPUTFORMATTER > formatter( new FILE_OUTPUTFORMATTER( fn.GetFullPath() ) );
3398  formatter->Print( 0, "%s %d.%d\n", LIBFILE_IDENT, LIB_VERSION_MAJOR, LIB_VERSION_MINOR );
3399  formatter->Print( 0, "#encoding utf-8\n");
3400 
3401  for( LIB_ALIAS_MAP::iterator it = m_aliases.begin(); it != m_aliases.end(); it++ )
3402  {
3403  if( !it->second->IsRoot() )
3404  continue;
3405 
3406  saveSymbol( it->second->GetPart(), formatter );
3407  }
3408 
3409  formatter->Print( 0, "#\n#End Library\n" );
3410  formatter.reset();
3411 
3412  m_fileModTime = fn.GetModificationTime();
3413  m_isModified = false;
3414 
3415  if( aSaveDocFile )
3416  saveDocFile();
3417 }
#define LIBFILE_IDENT
Definition: class_library.h:59
#define LIB_VERSION_MINOR
Definition: class_library.h:56
#define LIB_VERSION_MAJOR
Definition: class_library.h:55
wxFileName GetRealFile() const
Class FILE_OUTPUTFORMATTER may be used for text file output.
Definition: richio.h:492
void saveSymbol(LIB_PART *aSymbol, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
void SCH_LEGACY_PLUGIN_CACHE::saveArc ( LIB_ARC aArc,
std::unique_ptr< FILE_OUTPUTFORMATTER > &  aFormatter 
)
private

Definition at line 3590 of file sch_legacy_plugin.cpp.

References fill_tab, LIB_ITEM::GetConvert(), LIB_ARC::GetEnd(), LIB_ITEM::GetFillMode(), LIB_ARC::GetFirstRadiusAngle(), LIB_ARC::GetPosition(), LIB_ARC::GetRadius(), LIB_ARC::GetSecondRadiusAngle(), LIB_ARC::GetStart(), LIB_ITEM::GetUnit(), LIB_ARC::GetWidth(), LIB_ARC_T, EDA_ITEM::Type(), wxPoint::x, and wxPoint::y.

Referenced by saveSymbol().

3592 {
3593  wxCHECK_RET( aArc && aArc->Type() == LIB_ARC_T, "Invalid LIB_ARC object." );
3594 
3595  int x1 = aArc->GetFirstRadiusAngle();
3596 
3597  if( x1 > 1800 )
3598  x1 -= 3600;
3599 
3600  int x2 = aArc->GetSecondRadiusAngle();
3601 
3602  if( x2 > 1800 )
3603  x2 -= 3600;
3604 
3605  aFormatter->Print( 0, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n",
3606  aArc->GetPosition().x, aArc->GetPosition().y,
3607  aArc->GetRadius(), x1, x2, aArc->GetUnit(), aArc->GetConvert(),
3608  aArc->GetWidth(), fill_tab[aArc->GetFillMode()],
3609  aArc->GetStart().x, aArc->GetStart().y,
3610  aArc->GetEnd().x, aArc->GetEnd().y );
3611 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
FILL_T GetFillMode() const
int GetSecondRadiusAngle() const
Definition: lib_arc.h:146
wxPoint GetStart() const
Definition: lib_arc.h:148
int GetUnit() const
int GetFirstRadiusAngle() const
Definition: lib_arc.h:142
wxPoint GetEnd() const
Definition: lib_arc.h:152
int GetRadius() const
Definition: lib_arc.h:138
int GetWidth() const override
Return the width of the draw item.
Definition: lib_arc.h:132
const int fill_tab[3]
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_arc.h:121
int GetConvert() const
void SCH_LEGACY_PLUGIN_CACHE::saveBezier ( LIB_BEZIER aBezier,
std::unique_ptr< FILE_OUTPUTFORMATTER > &  aFormatter 
)
private

Definition at line 3614 of file sch_legacy_plugin.cpp.

References fill_tab, LIB_ITEM::GetConvert(), LIB_ITEM::GetFillMode(), LIB_BEZIER::GetPoints(), LIB_ITEM::GetUnit(), LIB_BEZIER::GetWidth(), LIB_BEZIER_T, and EDA_ITEM::Type().

Referenced by saveSymbol().

3616 {
3617  wxCHECK_RET( aBezier && aBezier->Type() == LIB_BEZIER_T, "Invalid LIB_BEZIER object." );
3618 
3619  aFormatter->Print( 0, "B %u %d %d %d", (unsigned)aBezier->GetPoints().size(),
3620  aBezier->GetUnit(), aBezier->GetConvert(), aBezier->GetWidth() );
3621 
3622  for( const auto& pt : aBezier->GetPoints() )
3623  aFormatter->Print( 0, " %d %d", pt.x, pt.y );
3624 
3625  aFormatter->Print( 0, " %c\n", fill_tab[aBezier->GetFillMode()] );
3626 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
FILL_T GetFillMode() const
int GetUnit() const
const std::vector< wxPoint > & GetPoints() const
Definition: lib_bezier.h:76
int GetWidth() const override
Return the width of the draw item.
Definition: lib_bezier.h:102
const int fill_tab[3]
int GetConvert() const
void SCH_LEGACY_PLUGIN_CACHE::saveCircle ( LIB_CIRCLE aCircle,
std::unique_ptr< FILE_OUTPUTFORMATTER > &  aFormatter 
)
private

Definition at line 3629 of file sch_legacy_plugin.cpp.

References fill_tab, LIB_ITEM::GetConvert(), LIB_ITEM::GetFillMode(), LIB_CIRCLE::GetPosition(), LIB_CIRCLE::GetRadius(), LIB_ITEM::GetUnit(), LIB_CIRCLE::GetWidth(), LIB_CIRCLE_T, EDA_ITEM::Type(), wxPoint::x, and wxPoint::y.

Referenced by saveSymbol().

3631 {
3632  wxCHECK_RET( aCircle && aCircle->Type() == LIB_CIRCLE_T, "Invalid LIB_CIRCLE object." );
3633 
3634  aFormatter->Print( 0, "C %d %d %d %d %d %d %c\n",
3635  aCircle->GetPosition().x, aCircle->GetPosition().y,
3636  aCircle->GetRadius(), aCircle->GetUnit(), aCircle->GetConvert(),
3637  aCircle->GetWidth(), fill_tab[aCircle->GetFillMode()] );
3638 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
FILL_T GetFillMode() const
int GetUnit() const
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_circle.h:86
int GetWidth() const override
Return the width of the draw item.
Definition: lib_circle.h:97
int GetRadius() const
Definition: lib_circle.h:103
const int fill_tab[3]
int GetConvert() const
void SCH_LEGACY_PLUGIN_CACHE::saveDocFile ( )
private

Definition at line 3880 of file sch_legacy_plugin.cpp.

References DOC_EXT, DOCFILE_IDENT, m_aliases, m_libFileName, OUTPUTFORMATTER::Print(), and TO_UTF8.

Referenced by Save().

3881 {
3882  wxFileName fileName = m_libFileName;
3883 
3884  fileName.SetExt( DOC_EXT );
3885  FILE_OUTPUTFORMATTER formatter( fileName.GetFullPath() );
3886 
3887  formatter.Print( 0, "%s\n", DOCFILE_IDENT );
3888 
3889  for( LIB_ALIAS_MAP::iterator it = m_aliases.begin(); it != m_aliases.end(); it++ )
3890  {
3891  wxString description = it->second->GetDescription();
3892  wxString keyWords = it->second->GetKeyWords();
3893  wxString docFileName = it->second->GetDocFileName();
3894 
3895  if( description.IsEmpty() && keyWords.IsEmpty() && docFileName.IsEmpty() )
3896  continue;
3897 
3898  formatter.Print( 0, "#\n$CMP %s\n", TO_UTF8( it->second->GetName() ) );
3899 
3900  if( !description.IsEmpty() )
3901  formatter.Print( 0, "D %s\n", TO_UTF8( description ) );
3902 
3903  if( !keyWords.IsEmpty() )
3904  formatter.Print( 0, "K %s\n", TO_UTF8( keyWords ) );
3905 
3906  if( !docFileName.IsEmpty() )
3907  formatter.Print( 0, "F %s\n", TO_UTF8( docFileName ) );
3908 
3909  formatter.Print( 0, "$ENDCMP\n" );
3910  }
3911 
3912  formatter.Print( 0, "#\n#End Doc Library\n" );
3913 }
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
#define DOCFILE_IDENT
#define DOC_EXT
Definition: class_library.h:50
Class FILE_OUTPUTFORMATTER may be used for text file output.
Definition: richio.h:492
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
void SCH_LEGACY_PLUGIN_CACHE::saveField ( LIB_FIELD aField,
std::unique_ptr< FILE_OUTPUTFORMATTER > &  aFormatter 
)
private

Definition at line 3641 of file sch_legacy_plugin.cpp.

References EscapedUTF8(), FIELD1, TEMPLATE_FIELDNAME::GetDefaultFieldName(), EDA_TEXT::GetHorizJustify(), LIB_FIELD::GetId(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextWidth(), EDA_TEXT::GetVertJustify(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), LIB_FIELD::IsVisible(), LIB_FIELD_T, LIB_FIELD::m_name, EDA_TEXT::m_Text, EDA_ITEM::Type(), wxPoint::x, and wxPoint::y.

Referenced by SCH_LEGACY_PLUGIN::saveComponent(), and saveSymbol().

3643 {
3644  wxCHECK_RET( aField && aField->Type() == LIB_FIELD_T, "Invalid LIB_FIELD object." );
3645 
3646  int hjustify, vjustify;
3647  int id = aField->GetId();
3648  wxString text = aField->m_Text;
3649 
3650  hjustify = 'C';
3651 
3652  if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
3653  hjustify = 'L';
3654  else if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
3655  hjustify = 'R';
3656 
3657  vjustify = 'C';
3658 
3659  if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
3660  vjustify = 'B';
3661  else if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
3662  vjustify = 'T';
3663 
3664  aFormatter->Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c",
3665  id,
3666  EscapedUTF8( text ).c_str(), // wraps in quotes
3667  aField->GetTextPos().x, aField->GetTextPos().y, aField->GetTextWidth(),
3668  aField->GetTextAngle() == 0 ? 'H' : 'V',
3669  aField->IsVisible() ? 'V' : 'I',
3670  hjustify, vjustify,
3671  aField->IsItalic() ? 'I' : 'N',
3672  aField->IsBold() ? 'B' : 'N' );
3673 
3674  /* Save field name, if necessary
3675  * Field name is saved only if it is not the default name.
3676  * Just because default name depends on the language and can change from
3677  * a country to another
3678  */
3679  wxString defName = TEMPLATE_FIELDNAME::GetDefaultFieldName( id );
3680 
3681  if( id >= FIELD1 && !aField->m_name.IsEmpty() && aField->m_name != defName )
3682  aFormatter->Print( 0, " %s", EscapedUTF8( aField->m_name ).c_str() );
3683 
3684  aFormatter->Print( 0, "\n" );
3685 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
wxString m_Text
Definition: eda_text.h:374
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
bool IsItalic() const
Definition: eda_text.h:183
int GetTextWidth() const
Definition: eda_text.h:231
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
bool IsBold() const
Definition: eda_text.h:186
double GetTextAngle() const
Definition: eda_text.h:177
std::string EscapedUTF8(const wxString &aString)
Function EscapedUTF8 returns an 8 bit UTF8 string given aString in unicode form.
Definition: string.cpp:214
int GetId() const
Definition: lib_field.h:138
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:204
bool IsVisible() const
Definition: lib_field.h:166
wxString m_name
Name (not the field text value itself, that is .m_Text)
Definition: lib_field.h:62
void SCH_LEGACY_PLUGIN_CACHE::savePin ( LIB_PIN aPin,
std::unique_ptr< FILE_OUTPUTFORMATTER > &  aFormatter 
)
private

Definition at line 3688 of file sch_legacy_plugin.cpp.

References EDA_ITEM::ClearFlags(), LIB_ITEM::GetConvert(), LIB_PIN::GetLength(), LIB_PIN::GetName(), LIB_PIN::GetNameTextSize(), LIB_PIN::GetNumber(), LIB_PIN::GetNumberTextSize(), LIB_PIN::GetOrientation(), LIB_PIN::GetPosition(), LIB_PIN::GetShape(), LIB_PIN::GetType(), LIB_ITEM::GetUnit(), IS_CHANGED, LIB_PIN::IsVisible(), LIB_PIN_T, PIN_BIDI, PIN_INPUT, PIN_NC, PIN_OPENCOLLECTOR, PIN_OPENEMITTER, PIN_OUTPUT, PIN_PASSIVE, PIN_POWER_IN, PIN_POWER_OUT, PIN_TRISTATE, PIN_UNSPECIFIED, PINSHAPE_CLOCK, PINSHAPE_CLOCK_LOW, PINSHAPE_FALLING_EDGE_CLOCK, PINSHAPE_INPUT_LOW, PINSHAPE_INVERTED, PINSHAPE_INVERTED_CLOCK, PINSHAPE_LINE, PINSHAPE_NONLOGIC, PINSHAPE_OUTPUT_LOW, TO_UTF8, EDA_ITEM::Type(), wxPoint::x, and wxPoint::y.

Referenced by saveSymbol().

3690 {
3691  wxCHECK_RET( aPin && aPin->Type() == LIB_PIN_T, "Invalid LIB_PIN object." );
3692 
3693  int Etype;
3694 
3695  switch( aPin->GetType() )
3696  {
3697  default:
3698  case PIN_INPUT:
3699  Etype = 'I';
3700  break;
3701 
3702  case PIN_OUTPUT:
3703  Etype = 'O';
3704  break;
3705 
3706  case PIN_BIDI:
3707  Etype = 'B';
3708  break;
3709 
3710  case PIN_TRISTATE:
3711  Etype = 'T';
3712  break;
3713 
3714  case PIN_PASSIVE:
3715  Etype = 'P';
3716  break;
3717 
3718  case PIN_UNSPECIFIED:
3719  Etype = 'U';
3720  break;
3721 
3722  case PIN_POWER_IN:
3723  Etype = 'W';
3724  break;
3725 
3726  case PIN_POWER_OUT:
3727  Etype = 'w';
3728  break;
3729 
3730  case PIN_OPENCOLLECTOR:
3731  Etype = 'C';
3732  break;
3733 
3734  case PIN_OPENEMITTER:
3735  Etype = 'E';
3736  break;
3737 
3738  case PIN_NC:
3739  Etype = 'N';
3740  break;
3741  }
3742 
3743  if( !aPin->GetName().IsEmpty() )
3744  aFormatter->Print( 0, "X %s", TO_UTF8( aPin->GetName() ) );
3745  else
3746  aFormatter->Print( 0, "X ~" );
3747 
3748  aFormatter->Print( 0, " %s %d %d %d %c %d %d %d %d %c",
3749  aPin->GetNumber().IsEmpty() ? "~" : TO_UTF8( aPin->GetNumber() ),
3750  aPin->GetPosition().x, aPin->GetPosition().y,
3751  (int) aPin->GetLength(), (int) aPin->GetOrientation(),
3752  aPin->GetNumberTextSize(), aPin->GetNameTextSize(),
3753  aPin->GetUnit(), aPin->GetConvert(), Etype );
3754 
3755  if( aPin->GetShape() || !aPin->IsVisible() )
3756  aFormatter->Print( 0, " " );
3757 
3758  if( !aPin->IsVisible() )
3759  aFormatter->Print( 0, "N" );
3760 
3761  switch( aPin->GetShape() )
3762  {
3763  case PINSHAPE_LINE:
3764  break;
3765 
3766  case PINSHAPE_INVERTED:
3767  aFormatter->Print( 0, "I" );
3768  break;
3769 
3770  case PINSHAPE_CLOCK:
3771  aFormatter->Print( 0, "C" );
3772  break;
3773 
3775  aFormatter->Print( 0, "IC" );
3776  break;
3777 
3778  case PINSHAPE_INPUT_LOW:
3779  aFormatter->Print( 0, "L" );
3780  break;
3781 
3782  case PINSHAPE_CLOCK_LOW:
3783  aFormatter->Print( 0, "CL" );
3784  break;
3785 
3786  case PINSHAPE_OUTPUT_LOW:
3787  aFormatter->Print( 0, "V" );
3788  break;
3789 
3791  aFormatter->Print( 0, "F" );
3792  break;
3793 
3794  case PINSHAPE_NONLOGIC:
3795  aFormatter->Print( 0, "X" );
3796  break;
3797 
3798  default:
3799  assert( !"Invalid pin shape" );
3800  }
3801 
3802  aFormatter->Print( 0, "\n" );
3803 
3804  aPin->ClearFlags( IS_CHANGED );
3805 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
int GetUnit() const
int GetNameTextSize() const
Definition: lib_pin.h:192
int GetOrientation() const
Definition: lib_pin.h:221
int GetNumberTextSize() const
Definition: lib_pin.h:219
const wxString & GetNumber() const
Definition: lib_pin.h:194
const wxString & GetName() const
Definition: lib_pin.h:166
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: base_struct.h:110
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:251
bool IsVisible() const
Return the visibility status of the draw object.
Definition: lib_pin.h:362
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_pin.h:463
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
int GetLength()
Definition: lib_pin.h:301
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:235
int GetConvert() const
void SCH_LEGACY_PLUGIN_CACHE::savePolyLine ( LIB_POLYLINE aPolyLine,
std::unique_ptr< FILE_OUTPUTFORMATTER > &  aFormatter 
)
private

Definition at line 3808 of file sch_legacy_plugin.cpp.

References fill_tab, LIB_ITEM::GetConvert(), LIB_POLYLINE::GetCornerCount(), LIB_ITEM::GetFillMode(), LIB_POLYLINE::GetPolyPoints(), LIB_ITEM::GetUnit(), LIB_POLYLINE::GetWidth(), LIB_POLYLINE_T, and EDA_ITEM::Type().

Referenced by saveSymbol().

3810 {
3811  wxCHECK_RET( aPolyLine && aPolyLine->Type() == LIB_POLYLINE_T, "Invalid LIB_POLYLINE object." );
3812 
3813  int ccount = aPolyLine->GetCornerCount();
3814 
3815  aFormatter->Print( 0, "P %d %d %d %d", ccount, aPolyLine->GetUnit(), aPolyLine->GetConvert(),
3816  aPolyLine->GetWidth() );
3817 
3818  for( const auto& pt : aPolyLine->GetPolyPoints() )
3819  {
3820  aFormatter->Print( 0, " %d %d", pt.x, pt.y );
3821  }
3822 
3823  aFormatter->Print( 0, " %c\n", fill_tab[aPolyLine->GetFillMode()] );
3824 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
FILL_T GetFillMode() const
int GetUnit() const
const std::vector< wxPoint > & GetPolyPoints() const
Definition: lib_polyline.h:68
unsigned GetCornerCount() const
Definition: lib_polyline.h:78
int GetWidth() const override
Return the width of the draw item.
Definition: lib_polyline.h:113
const int fill_tab[3]
int GetConvert() const
void SCH_LEGACY_PLUGIN_CACHE::saveRectangle ( LIB_RECTANGLE aRectangle,
std::unique_ptr< FILE_OUTPUTFORMATTER > &  aFormatter 
)
private

Definition at line 3827 of file sch_legacy_plugin.cpp.

References fill_tab, LIB_ITEM::GetConvert(), LIB_RECTANGLE::GetEnd(), LIB_ITEM::GetFillMode(), LIB_RECTANGLE::GetPosition(), LIB_ITEM::GetUnit(), LIB_RECTANGLE::GetWidth(), LIB_RECTANGLE_T, EDA_ITEM::Type(), wxPoint::x, and wxPoint::y.

Referenced by saveSymbol().

3829 {
3830  wxCHECK_RET( aRectangle && aRectangle->Type() == LIB_RECTANGLE_T,
3831  "Invalid LIB_RECTANGLE object." );
3832 
3833  aFormatter->Print( 0, "S %d %d %d %d %d %d %d %c\n",
3834  aRectangle->GetPosition().x, aRectangle->GetPosition().y,
3835  aRectangle->GetEnd().x, aRectangle->GetEnd().y,
3836  aRectangle->GetUnit(), aRectangle->GetConvert(),
3837  aRectangle->GetWidth(), fill_tab[aRectangle->GetFillMode()] );
3838 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
FILL_T GetFillMode() const
int GetUnit() const
int GetWidth() const override
Return the width of the draw item.
wxPoint GetEnd() const
const int fill_tab[3]
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_rectangle.h:91
int GetConvert() const
void SCH_LEGACY_PLUGIN_CACHE::saveSymbol ( LIB_PART aSymbol,
std::unique_ptr< FILE_OUTPUTFORMATTER > &  aFormatter 
)
private

Definition at line 3420 of file sch_legacy_plugin.cpp.

References MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::empty(), LIB_PART::GetAliasCount(), LIB_PART::GetAliasNames(), LIB_PART::GetDateLastEdition(), LIB_PART::GetDrawItems(), LIB_PART::GetFields(), LIB_PART::GetFootprints(), LIB_PART::GetPinNameOffset(), LIB_PART::GetReferenceField(), GetText(), EDA_TEXT::GetText(), LIB_PART::GetUnitCount(), LIB_PART::GetValueField(), i, LIB_PART::IsPower(), LIB_FIELD::IsVisible(), LIB_ARC_T, LIB_BEZIER_T, LIB_CIRCLE_T, LIB_FIELD_T, LIB_PIN_T, LIB_POLYLINE_T, LIB_RECTANGLE_T, LIB_TEXT_T, MANDATORY_FIELDS, min, saveArc(), saveBezier(), saveCircle(), saveField(), savePin(), savePolyLine(), saveRectangle(), saveText(), LIB_PART::ShowPinNames(), LIB_PART::ShowPinNumbers(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::sort(), TO_UTF8, and LIB_PART::UnitsLocked().

Referenced by Save().

3422 {
3423  wxCHECK_RET( aSymbol, "Invalid LIB_PART pointer." );
3424 
3425  LIB_FIELD& value = aSymbol->GetValueField();
3426 
3427  // First line: it s a comment (component name for readers)
3428  aFormatter->Print( 0, "#\n# %s\n#\n", TO_UTF8( value.GetText() ) );
3429 
3430  // Save data
3431  aFormatter->Print( 0, "DEF" );
3432 
3433  if( value.IsVisible() )
3434  {
3435  aFormatter->Print( 0, " %s", TO_UTF8( value.GetText() ) );
3436  }
3437  else
3438  {
3439  aFormatter->Print( 0, " ~%s", TO_UTF8( value.GetText() ) );
3440  }
3441 
3442  LIB_FIELD& reference = aSymbol->GetReferenceField();
3443 
3444  if( !reference.GetText().IsEmpty() )
3445  {
3446  aFormatter->Print( 0, " %s", TO_UTF8( reference.GetText() ) );
3447  }
3448  else
3449  {
3450  aFormatter->Print( 0, " ~" );
3451  }
3452 
3453  aFormatter->Print( 0, " %d %d %c %c %d %c %c\n",
3454  0, aSymbol->GetPinNameOffset(),
3455  aSymbol->ShowPinNumbers() ? 'Y' : 'N',
3456  aSymbol->ShowPinNames() ? 'Y' : 'N',
3457  aSymbol->GetUnitCount(), aSymbol->UnitsLocked() ? 'L' : 'F',
3458  aSymbol->IsPower() ? 'P' : 'N' );
3459 
3460  timestamp_t dateModified = aSymbol->GetDateLastEdition();
3461 
3462  if( dateModified != 0 )
3463  {
3464  int sec = dateModified & 63;
3465  int min = ( dateModified >> 6 ) & 63;
3466  int hour = ( dateModified >> 12 ) & 31;
3467  int day = ( dateModified >> 17 ) & 31;
3468  int mon = ( dateModified >> 22 ) & 15;
3469  int year = ( dateModified >> 26 ) + 1990;
3470 
3471  aFormatter->Print( 0, "Ti %d/%d/%d %d:%d:%d\n", year, mon, day, hour, min, sec );
3472  }
3473 
3474  LIB_FIELDS fields;
3475  aSymbol->GetFields( fields );
3476 
3477  // Mandatory fields:
3478  // may have their own save policy so there is a separate loop for them.
3479  // Empty fields are saved, because the user may have set visibility,
3480  // size and orientation
3481  for( int i = 0; i < MANDATORY_FIELDS; ++i )
3482  {
3483  saveField( &fields[i], aFormatter );
3484  }
3485 
3486  // User defined fields:
3487  // may have their own save policy so there is a separate loop for them.
3488 
3489  int fieldId = MANDATORY_FIELDS; // really wish this would go away.
3490 
3491  for( unsigned i = MANDATORY_FIELDS; i < fields.size(); ++i )
3492  {
3493  // There is no need to save empty fields, i.e. no reason to preserve field
3494  // names now that fields names come in dynamically through the template
3495  // fieldnames.
3496  if( !fields[i].GetText().IsEmpty() )
3497  {
3498  fields[i].SetId( fieldId++ );
3499  saveField( &fields[i], aFormatter );
3500  }
3501  }
3502 
3503  // Save the alias list: a line starting by "ALIAS". The first alias is the root
3504  // and has the same name as the component. In the old library file format this
3505  // alias does not get added to the alias list.
3506  if( aSymbol->GetAliasCount() > 1 )
3507  {
3508  wxArrayString aliases = aSymbol->GetAliasNames();
3509 
3510  aFormatter->Print( 0, "ALIAS" );
3511 
3512  for( unsigned i = 1; i < aliases.size(); i++ )
3513  {
3514  aFormatter->Print( 0, " %s", TO_UTF8( aliases[i] ) );
3515  }
3516 
3517  aFormatter->Print( 0, "\n" );
3518  }
3519 
3520  wxArrayString footprints = aSymbol->GetFootprints();
3521 
3522  // Write the footprint filter list
3523  if( footprints.GetCount() != 0 )
3524  {
3525  aFormatter->Print( 0, "$FPLIST\n" );
3526 
3527  for( unsigned i = 0; i < footprints.GetCount(); i++ )
3528  {
3529  aFormatter->Print( 0, " %s\n", TO_UTF8( footprints[i] ) );
3530  }
3531 
3532  aFormatter->Print( 0, "$ENDFPLIST\n" );
3533  }
3534 
3535  // Save graphics items (including pins)
3536  if( !aSymbol->GetDrawItems().empty() )
3537  {
3538  // Sort the draw items in order to editing a file editing by hand.
3539  aSymbol->GetDrawItems().sort();
3540 
3541  aFormatter->Print( 0, "DRAW\n" );
3542 
3543  for( LIB_ITEM& item : aSymbol->GetDrawItems() )
3544  {
3545  switch( item.Type() )
3546  {
3547  case LIB_FIELD_T: // Fields have already been saved above.
3548  continue;
3549 
3550  case LIB_ARC_T:
3551  saveArc( (LIB_ARC*) &item, aFormatter );
3552  break;
3553 
3554  case LIB_BEZIER_T:
3555  saveBezier( (LIB_BEZIER*) &item, aFormatter );
3556  break;
3557 
3558  case LIB_CIRCLE_T:
3559  saveCircle( ( LIB_CIRCLE* ) &item, aFormatter );
3560  break;
3561 
3562  case LIB_PIN_T:
3563  savePin( (LIB_PIN* ) &item, aFormatter );
3564  break;
3565 
3566  case LIB_POLYLINE_T:
3567  savePolyLine( ( LIB_POLYLINE* ) &item, aFormatter );
3568  break;
3569 
3570  case LIB_RECTANGLE_T:
3571  saveRectangle( ( LIB_RECTANGLE* ) &item, aFormatter );
3572  break;
3573 
3574  case LIB_TEXT_T:
3575  saveText( ( LIB_TEXT* ) &item, aFormatter );
3576  break;
3577 
3578  default:
3579  ;
3580  }
3581  }
3582 
3583  aFormatter->Print( 0, "ENDDRAW\n" );
3584  }
3585 
3586  aFormatter->Print( 0, "ENDDEF\n" );
3587 }
bool UnitsLocked() const
Check whether part units are interchangeable.
int GetPinNameOffset()
long timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: common.h:52
bool IsPower() const
Define a symbol library graphical text item.
Definition: lib_text.h:44
void saveRectangle(LIB_RECTANGLE *aRectangle, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
bool empty(int aType=UNDEFINED_TYPE)
Definition: multivector.h:224
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
Field object used in symbol libraries.
Definition: lib_field.h:59
void sort()
Definition: multivector.h:229
LIB_FIELD & GetValueField()
Return reference to the value field.
size_t GetAliasCount() const
void savePin(LIB_PIN *aPin, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
void saveCircle(LIB_CIRCLE *aCircle, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
void saveText(LIB_TEXT *aText, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
bool ShowPinNames()
bool ShowPinNumbers()
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
timestamp_t GetDateLastEdition() const
wxString GetText(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:33
wxArrayString & GetFootprints()
int GetUnitCount() const
bool IsVisible() const
Definition: lib_field.h:166
std::vector< LIB_FIELD > LIB_FIELDS
Definition: lib_field.h:259
wxArrayString GetAliasNames(bool aIncludeRoot=true) const
size_t i
Definition: json11.cpp:597
void savePolyLine(LIB_POLYLINE *aPolyLine, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
void saveArc(LIB_ARC *aArc, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
void saveField(LIB_FIELD *aField, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
void saveBezier(LIB_BEZIER *aBezier, std::unique_ptr< FILE_OUTPUTFORMATTER > &aFormatter)
void GetFields(LIB_FIELDS &aList)
Return a list of fields within this part.
#define min(a, b)
Definition: auxiliary.h:85
Class LIB_BEZIER defines bezier curve graphic body item.
Definition: lib_bezier.h:39
void SCH_LEGACY_PLUGIN_CACHE::saveText ( LIB_TEXT aText,
std::unique_ptr< FILE_OUTPUTFORMATTER > &  aFormatter 
)
private

Definition at line 3841 of file sch_legacy_plugin.cpp.

References LIB_ITEM::GetConvert(), EDA_TEXT::GetHorizJustify(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextWidth(), LIB_ITEM::GetUnit(), EDA_TEXT::GetVertJustify(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsVisible(), LIB_TEXT_T, TO_UTF8, EDA_ITEM::Type(), wxPoint::x, and wxPoint::y.

Referenced by SCH_LEGACY_PLUGIN::Format(), and saveSymbol().

3843 {
3844  wxCHECK_RET( aText && aText->Type() == LIB_TEXT_T, "Invalid LIB_TEXT object." );
3845 
3846  wxString text = aText->GetText();
3847 
3848  if( text.Contains( wxT( " " ) ) || text.Contains( wxT( "~" ) ) || text.Contains( wxT( "\"" ) ) )
3849  {
3850  // convert double quote to similar-looking two apostrophes
3851  text.Replace( wxT( "\"" ), wxT( "''" ) );
3852  text = wxT( "\"" ) + text + wxT( "\"" );
3853  }
3854 
3855  aFormatter->Print( 0, "T %g %d %d %d %d %d %d %s", aText->GetTextAngle(),
3856  aText->GetTextPos().x, aText->GetTextPos().y,
3857  aText->GetTextWidth(), !aText->IsVisible(),
3858  aText->GetUnit(), aText->GetConvert(), TO_UTF8( text ) );
3859 
3860  aFormatter->Print( 0, " %s %d", aText->IsItalic() ? "Italic" : "Normal", aText->IsBold() );
3861 
3862  char hjustify = 'C';
3863 
3864  if( aText->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
3865  hjustify = 'L';
3866  else if( aText->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
3867  hjustify = 'R';
3868 
3869  char vjustify = 'C';
3870 
3871  if( aText->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
3872  vjustify = 'B';
3873  else if( aText->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
3874  vjustify = 'T';
3875 
3876  aFormatter->Print( 0, " %c %c\n", hjustify, vjustify );
3877 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
bool IsItalic() const
Definition: eda_text.h:183
int GetUnit() const
int GetTextWidth() const
Definition: eda_text.h:231
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
bool IsBold() const
Definition: eda_text.h:186
double GetTextAngle() const
Definition: eda_text.h:177
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:204
bool IsVisible() const
Definition: eda_text.h:189
int GetConvert() const
void SCH_LEGACY_PLUGIN_CACHE::SetFileName ( const wxString &  aFileName)
inline

Definition at line 555 of file sch_legacy_plugin.cpp.

555 { m_libFileName = aFileName; }
void SCH_LEGACY_PLUGIN_CACHE::SetModified ( bool  aModified = true)
inline

Definition at line 551 of file sch_legacy_plugin.cpp.

551 { m_isModified = aModified; }

Member Data Documentation

wxDateTime SCH_LEGACY_PLUGIN_CACHE::m_fileModTime
private

Definition at line 471 of file sch_legacy_plugin.cpp.

Referenced by IsFileChanged(), Load(), and Save().

wxString SCH_LEGACY_PLUGIN_CACHE::m_fileName
private

Definition at line 469 of file sch_legacy_plugin.cpp.

Referenced by IsFile(), and loadPart().

bool SCH_LEGACY_PLUGIN_CACHE::m_isModified
private

Definition at line 474 of file sch_legacy_plugin.cpp.

Referenced by AddSymbol(), DeleteAlias(), removeAlias(), and Save().

bool SCH_LEGACY_PLUGIN_CACHE::m_isWritable
private

Definition at line 473 of file sch_legacy_plugin.cpp.

Referenced by GetLibModificationTime().

wxFileName SCH_LEGACY_PLUGIN_CACHE::m_libFileName
private
int SCH_LEGACY_PLUGIN_CACHE::m_libType
private

Definition at line 477 of file sch_legacy_plugin.cpp.

Referenced by Load(), and SCH_LEGACY_PLUGIN_CACHE().

int SCH_LEGACY_PLUGIN_CACHE::m_modHash = 1
staticprivate
int SCH_LEGACY_PLUGIN_CACHE::m_versionMajor
private

Definition at line 475 of file sch_legacy_plugin.cpp.

Referenced by Load(), loadPart(), loadText(), and SCH_LEGACY_PLUGIN_CACHE().

int SCH_LEGACY_PLUGIN_CACHE::m_versionMinor
private

Definition at line 476 of file sch_legacy_plugin.cpp.

Referenced by Load(), loadPart(), loadText(), and SCH_LEGACY_PLUGIN_CACHE().

friend SCH_LEGACY_PLUGIN_CACHE::SCH_LEGACY_PLUGIN
private

Definition at line 519 of file sch_legacy_plugin.cpp.


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