KiCad PCB EDA Suite
SCH_LEGACY_PLUGIN_CACHE Class Reference

A cache assistant for KiCad legacy symbol libraries. More...

#include <sch_legacy_lib_plugin_cache.h>

Inheritance diagram for SCH_LEGACY_PLUGIN_CACHE:
SCH_LIB_PLUGIN_CACHE

Public Member Functions

 SCH_LEGACY_PLUGIN_CACHE (const wxString &aLibraryPath)
 
virtual ~SCH_LEGACY_PLUGIN_CACHE ()
 
void Save (const std::optional< bool > &aOpt) override
 Save the entire library to file m_libFileName;. More...
 
void Load () override
 
void DeleteSymbol (const wxString &aName) override
 
void IncrementModifyHash ()
 
int GetModifyHash ()
 
virtual void AddSymbol (const LIB_SYMBOL *aSymbol)
 
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
 

Static Public Member Functions

static LIB_SYMBOLLoadPart (LINE_READER &aReader, int aMajorVersion, int aMinorVersion, LIB_SYMBOL_MAP *aMap=nullptr)
 
static void SaveSymbol (LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, LIB_SYMBOL_MAP *aMap=nullptr)
 

Protected Member Functions

LIB_SYMBOLremoveSymbol (LIB_SYMBOL *aAlias)
 

Protected Attributes

int m_modHash
 
std::mutex m_modHashMutex
 
wxString m_fileName
 
wxFileName m_libFileName
 
wxDateTime m_fileModTime
 
LIB_SYMBOL_MAP m_symbols
 
bool m_isWritable
 
bool m_isModified
 
SCH_LIB_TYPE m_libType
 

Private Member Functions

void loadHeader (FILE_LINE_READER &aReader)
 
void loadDocs ()
 
void saveDocFile ()
 

Static Private Member Functions

static void loadAliases (std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, LIB_SYMBOL_MAP *aMap=nullptr)
 
static void loadField (std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
 
static void loadDrawEntries (std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, int aMajorVersion, int aMinorVersion)
 
static void loadFootprintFilters (std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
 
static LIB_SHAPEloadArc (std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
 
static LIB_SHAPEloadCircle (std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
 
static LIB_TEXTloadText (std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, int aMajorVersion, int aMinorVersion)
 
static LIB_SHAPEloadRect (std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
 
static LIB_PINloadPin (std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
 
static LIB_SHAPEloadPolyLine (std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
 
static LIB_SHAPEloadBezier (std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
 
static FILL_T parseFillMode (LINE_READER &aReader, const char *aLine, const char **aOutput)
 
static void saveArc (LIB_SHAPE *aArc, OUTPUTFORMATTER &aFormatter)
 
static void saveBezier (LIB_SHAPE *aBezier, OUTPUTFORMATTER &aFormatter)
 
static void saveCircle (LIB_SHAPE *aCircle, OUTPUTFORMATTER &aFormatter)
 
static void saveField (const LIB_FIELD *aField, OUTPUTFORMATTER &aFormatter)
 
static void savePin (const LIB_PIN *aPin, OUTPUTFORMATTER &aFormatter)
 
static void savePolyLine (LIB_SHAPE *aPolyLine, OUTPUTFORMATTER &aFormatter)
 
static void saveRectangle (LIB_SHAPE *aRectangle, OUTPUTFORMATTER &aFormatter)
 
static void saveText (const LIB_TEXT *aText, OUTPUTFORMATTER &aFormatter)
 

Private Attributes

friend SCH_LEGACY_PLUGIN
 
int m_versionMajor
 
int m_versionMinor
 

Detailed Description

A cache assistant for KiCad legacy symbol libraries.

Definition at line 43 of file sch_legacy_lib_plugin_cache.h.

Constructor & Destructor Documentation

◆ SCH_LEGACY_PLUGIN_CACHE()

SCH_LEGACY_PLUGIN_CACHE::SCH_LEGACY_PLUGIN_CACHE ( const wxString &  aLibraryPath)

Definition at line 58 of file sch_legacy_lib_plugin_cache.cpp.

58 :
59 SCH_LIB_PLUGIN_CACHE( aFullPathAndFileName )
60{
61 m_versionMajor = -1;
62 m_versionMinor = -1;
63}
SCH_LIB_PLUGIN_CACHE(const wxString &aLibraryPath)

References m_versionMajor, and m_versionMinor.

◆ ~SCH_LEGACY_PLUGIN_CACHE()

virtual SCH_LEGACY_PLUGIN_CACHE::~SCH_LEGACY_PLUGIN_CACHE ( )
inlinevirtual

Definition at line 47 of file sch_legacy_lib_plugin_cache.h.

47{}

Member Function Documentation

◆ AddSymbol()

void SCH_LIB_PLUGIN_CACHE::AddSymbol ( const LIB_SYMBOL aSymbol)
virtualinherited

Definition at line 161 of file sch_lib_plugin_cache.cpp.

162{
163 // aSymbol is cloned in SYMBOL_LIB::AddSymbol(). The cache takes ownership of aSymbol.
164 wxString name = aSymbol->GetName();
165 LIB_SYMBOL_MAP::iterator it = m_symbols.find( name );
166
167 if( it != m_symbols.end() )
168 {
169 removeSymbol( it->second );
170 }
171
172 m_symbols[ name ] = const_cast< LIB_SYMBOL* >( aSymbol );
173 m_isModified = true;
175}
const char * name
Definition: DXF_plotter.cpp:56
Define a library symbol object.
Definition: lib_symbol.h:98
wxString GetName() const override
Definition: lib_symbol.h:136
LIB_SYMBOL * removeSymbol(LIB_SYMBOL *aAlias)

References LIB_SYMBOL::GetName(), SCH_LIB_PLUGIN_CACHE::IncrementModifyHash(), SCH_LIB_PLUGIN_CACHE::m_isModified, SCH_LIB_PLUGIN_CACHE::m_symbols, name, and SCH_LIB_PLUGIN_CACHE::removeSymbol().

Referenced by SCH_SEXPR_PLUGIN::SaveSymbol(), and SCH_LEGACY_PLUGIN::SaveSymbol().

◆ DeleteSymbol()

void SCH_LEGACY_PLUGIN_CACHE::DeleteSymbol ( const wxString &  aName)
overridevirtual

Implements SCH_LIB_PLUGIN_CACHE.

Definition at line 1811 of file sch_legacy_lib_plugin_cache.cpp.

1812{
1813 LIB_SYMBOL_MAP::iterator it = m_symbols.find( aSymbolName );
1814
1815 if( it == m_symbols.end() )
1816 THROW_IO_ERROR( wxString::Format( _( "library %s does not contain a symbol named %s" ),
1817 m_libFileName.GetFullName(), aSymbolName ) );
1818
1819 LIB_SYMBOL* symbol = it->second;
1820
1821 if( symbol->IsRoot() )
1822 {
1823 LIB_SYMBOL* rootSymbol = symbol;
1824
1825 // Remove the root symbol and all its children.
1826 m_symbols.erase( it );
1827
1828 LIB_SYMBOL_MAP::iterator it1 = m_symbols.begin();
1829
1830 while( it1 != m_symbols.end() )
1831 {
1832 if( it1->second->IsAlias()
1833 && it1->second->GetParent().lock() == rootSymbol->SharedPtr() )
1834 {
1835 delete it1->second;
1836 it1 = m_symbols.erase( it1 );
1837 }
1838 else
1839 {
1840 it1++;
1841 }
1842 }
1843
1844 delete rootSymbol;
1845 }
1846 else
1847 {
1848 // Just remove the alias.
1849 m_symbols.erase( it );
1850 delete symbol;
1851 }
1852
1854 m_isModified = true;
1855}
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition: lib_symbol.h:182
LIB_SYMBOL_SPTR SharedPtr() const
Definition: lib_symbol.h:108
#define _(s)
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References _, Format(), SCH_LIB_PLUGIN_CACHE::IncrementModifyHash(), LIB_SYMBOL::IsRoot(), SCH_LIB_PLUGIN_CACHE::m_isModified, SCH_LIB_PLUGIN_CACHE::m_libFileName, SCH_LIB_PLUGIN_CACHE::m_symbols, LIB_SYMBOL::SharedPtr(), and THROW_IO_ERROR.

Referenced by SCH_LEGACY_PLUGIN::DeleteSymbol().

◆ GetFileName()

wxString SCH_LIB_PLUGIN_CACHE::GetFileName ( void  ) const
inlineinherited

Definition at line 86 of file sch_lib_plugin_cache.h.

86{ return m_libFileName.GetFullPath(); }

References SCH_LIB_PLUGIN_CACHE::m_libFileName.

Referenced by SCH_SEXPR_PLUGIN::SaveLibrary(), and SCH_LEGACY_PLUGIN::SaveLibrary().

◆ GetLibModificationTime()

wxDateTime SCH_LIB_PLUGIN_CACHE::GetLibModificationTime ( )
inherited

Definition at line 65 of file sch_lib_plugin_cache.cpp.

66{
67 wxFileName fn = GetRealFile();
68
69 // update the writable flag while we have a wxFileName, in a network this
70 // is possibly quite dynamic anyway.
71 m_isWritable = fn.IsFileWritable();
72
73 return fn.GetModificationTime();
74}
wxFileName GetRealFile() const

References SCH_LIB_PLUGIN_CACHE::GetRealFile(), and SCH_LIB_PLUGIN_CACHE::m_isWritable.

Referenced by SCH_SEXPR_PLUGIN_CACHE::Load(), and Load().

◆ GetLogicalName()

wxString SCH_LIB_PLUGIN_CACHE::GetLogicalName ( ) const
inlineinherited

Definition at line 82 of file sch_lib_plugin_cache.h.

82{ return m_libFileName.GetName(); }

References SCH_LIB_PLUGIN_CACHE::m_libFileName.

◆ GetModifyHash()

int SCH_LIB_PLUGIN_CACHE::GetModifyHash ( )
inlineinherited

◆ GetRealFile()

wxFileName SCH_LIB_PLUGIN_CACHE::GetRealFile ( ) const
inherited

Definition at line 55 of file sch_lib_plugin_cache.cpp.

56{
57 wxFileName fn( m_libFileName );
58
59 // If m_libFileName is a symlink follow it to the real source file
61 return fn;
62}
static void ResolvePossibleSymlinks(wxFileName &aFilename)
Definition: wx_filename.cpp:92

References SCH_LIB_PLUGIN_CACHE::m_libFileName, and WX_FILENAME::ResolvePossibleSymlinks().

Referenced by SCH_LIB_PLUGIN_CACHE::GetLibModificationTime(), SCH_LIB_PLUGIN_CACHE::IsFileChanged(), Save(), and SCH_SEXPR_PLUGIN_CACHE::Save().

◆ IncrementModifyHash()

void SCH_LIB_PLUGIN_CACHE::IncrementModifyHash ( )
inlineinherited

◆ IsFile()

bool SCH_LIB_PLUGIN_CACHE::IsFile ( const wxString &  aFullPathAndFileName) const
inherited

◆ IsFileChanged()

bool SCH_LIB_PLUGIN_CACHE::IsFileChanged ( ) const
inherited

Definition at line 83 of file sch_lib_plugin_cache.cpp.

84{
85 wxFileName fn = GetRealFile();
86
87 if( m_fileModTime.IsValid() && fn.IsOk() && fn.FileExists() )
88 return fn.GetModificationTime() != m_fileModTime;
89
90 return false;
91}

References SCH_LIB_PLUGIN_CACHE::GetRealFile(), and SCH_LIB_PLUGIN_CACHE::m_fileModTime.

Referenced by SCH_SEXPR_PLUGIN::cacheLib(), and SCH_LEGACY_PLUGIN::cacheLib().

◆ Load()

void SCH_LEGACY_PLUGIN_CACHE::Load ( )
overridevirtual
Todo:
Probably should check for a valid date and time stamp even though it's not used.

Implements SCH_LIB_PLUGIN_CACHE.

Definition at line 66 of file sch_legacy_lib_plugin_cache.cpp.

67{
68 if( !m_libFileName.FileExists() )
69 {
70 THROW_IO_ERROR( wxString::Format( _( "Library file '%s' not found." ),
71 m_libFileName.GetFullPath() ) );
72 }
73
74 wxCHECK_RET( m_libFileName.IsAbsolute(),
75 wxString::Format( "Cannot use relative file paths in legacy plugin to "
76 "open library '%s'.", m_libFileName.GetFullPath() ) );
77
78 wxLogTrace( traceSchLegacyPlugin, "Loading legacy symbol file '%s'",
79 m_libFileName.GetFullPath() );
80
81 FILE_LINE_READER reader( m_libFileName.GetFullPath() );
82
83 if( !reader.ReadLine() )
84 THROW_IO_ERROR( _( "Unexpected end of file." ) );
85
86 const char* line = reader.Line();
87
88 if( !strCompare( "EESchema-LIBRARY Version", line, &line ) )
89 {
90 // Old .sym files (which are libraries with only one symbol, used to store and reuse shapes)
91 // EESchema-LIB Version x.x SYMBOL. They are valid files.
92 if( !strCompare( "EESchema-LIB Version", line, &line ) )
93 SCH_PARSE_ERROR( "file is not a valid symbol or symbol library file", reader, line );
94 }
95
96 m_versionMajor = parseInt( reader, line, &line );
97
98 if( *line != '.' )
99 SCH_PARSE_ERROR( "invalid file version formatting in header", reader, line );
100
101 line++;
102
103 m_versionMinor = parseInt( reader, line, &line );
104
105 if( m_versionMajor < 1 || m_versionMinor < 0 || m_versionMinor > 99 )
106 SCH_PARSE_ERROR( "invalid file version in header", reader, line );
107
108 // Check if this is a symbol library which is the same as a symbol library but without
109 // any alias, documentation, footprint filters, etc.
110 if( strCompare( "SYMBOL", line, &line ) )
111 {
112 // Symbol files add date and time stamp info to the header.
114
116 }
117 else
118 {
120 }
121
122 while( reader.ReadLine() )
123 {
124 line = reader.Line();
125
126 if( *line == '#' || isspace( *line ) ) // Skip comments and blank lines.
127 continue;
128
129 // Headers where only supported in older library file formats.
130 if( m_libType == SCH_LIB_TYPE::LT_EESCHEMA && strCompare( "$HEADER", line ) )
131 loadHeader( reader );
132
133 if( strCompare( "DEF", line ) )
134 {
135 // Read one DEF/ENDDEF symbol entry from library:
137
138 m_symbols[ symbol->GetName() ] = symbol;
139 }
140 }
141
143
144 // Remember the file modification time of library file when the
145 // cache snapshot was made, so that in a networked environment we will
146 // reload the cache as needed.
148
150 loadDocs();
151}
A LINE_READER that reads from an open file.
Definition: richio.h:173
void loadHeader(FILE_LINE_READER &aReader)
static LIB_SYMBOL * LoadPart(LINE_READER &aReader, int aMajorVersion, int aMinorVersion, LIB_SYMBOL_MAP *aMap=nullptr)
const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
#define USE_OLD_DOC_FILE_FORMAT(major, minor)
Library versions 2.4 and lower use the old separate library (.lib) and document (....
int parseInt(LINE_READER &aReader, const char *aLine, const char **aOutput)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
bool strCompare(const char *aString, const char *aLine, const char **aOutput)
Compare aString to the string starting at aLine and advances the character point to the end of String...
#define SCH_PARSE_ERROR(text, reader, pos)

References _, Format(), SCH_LIB_PLUGIN_CACHE::GetLibModificationTime(), LIB_SYMBOL::GetName(), SCH_LIB_PLUGIN_CACHE::IncrementModifyHash(), LINE_READER::Line(), loadDocs(), loadHeader(), LoadPart(), LT_EESCHEMA, LT_SYMBOL, SCH_LIB_PLUGIN_CACHE::m_fileModTime, SCH_LIB_PLUGIN_CACHE::m_libFileName, SCH_LIB_PLUGIN_CACHE::m_libType, SCH_LIB_PLUGIN_CACHE::m_symbols, m_versionMajor, m_versionMinor, parseInt(), FILE_LINE_READER::ReadLine(), SCH_PARSE_ERROR, strCompare(), THROW_IO_ERROR, traceSchLegacyPlugin, and USE_OLD_DOC_FILE_FORMAT.

Referenced by SCH_LEGACY_PLUGIN::cacheLib(), and SCH_LEGACY_PLUGIN::CreateSymbolLib().

◆ loadAliases()

void SCH_LEGACY_PLUGIN_CACHE::loadAliases ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
LINE_READER aReader,
LIB_SYMBOL_MAP aMap = nullptr 
)
staticprivate

Definition at line 465 of file sch_legacy_lib_plugin_cache.cpp.

468{
469 wxString newAliasName;
470 const char* line = aReader.Line();
471
472 wxCHECK_RET( strCompare( "ALIAS", line, &line ), "Invalid ALIAS section" );
473
474 wxString utf8Line = wxString::FromUTF8( line );
475 wxStringTokenizer tokens( utf8Line, " \r\n\t" );
476
477 // Parse the ALIAS list.
478 while( tokens.HasMoreTokens() )
479 {
480 newAliasName = tokens.GetNextToken();
481
482 if( aMap )
483 {
484 LIB_SYMBOL* newSymbol = new LIB_SYMBOL( newAliasName );
485
486 // Inherit the parent mandatory field attributes.
487 for( int id = 0; id < MANDATORY_FIELDS; ++id )
488 {
489 LIB_FIELD* field = newSymbol->GetFieldById( id );
490
491 // the MANDATORY_FIELDS are exactly that in RAM.
492 wxASSERT( field );
493
494 LIB_FIELD* parentField = aSymbol->GetFieldById( id );
495
496 wxASSERT( parentField );
497
498 *field = *parentField;
499
500 if( id == VALUE_FIELD )
501 field->SetText( newAliasName );
502
503 field->SetParent( newSymbol );
504 }
505
506 newSymbol->SetParent( aSymbol.get() );
507
508 // This will prevent duplicate aliases.
509 (*aMap)[ newSymbol->GetName() ] = newSymbol;
510 }
511 }
512}
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
Field object used in symbol libraries.
Definition: lib_field.h:60
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
void SetParent(LIB_SYMBOL *aParent=nullptr)
Definition: lib_symbol.cpp:451
char * Line() const
Return a pointer to the last line that was read in.
Definition: richio.h:117
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.

References LIB_SYMBOL::GetFieldById(), LIB_SYMBOL::GetName(), LINE_READER::Line(), MANDATORY_FIELDS, EDA_ITEM::SetParent(), LIB_SYMBOL::SetParent(), EDA_TEXT::SetText(), strCompare(), and VALUE_FIELD.

Referenced by LoadPart().

◆ loadArc()

LIB_SHAPE * SCH_LEGACY_PLUGIN_CACHE::loadArc ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
LINE_READER aReader 
)
staticprivate

Definition at line 749 of file sch_legacy_lib_plugin_cache.cpp.

751{
752 const char* line = aReader.Line();
753
754 wxCHECK_MSG( strCompare( "A", line, &line ), nullptr, "Invalid arc definition" );
755
756 LIB_SHAPE* arc = new LIB_SHAPE( aSymbol.get(), SHAPE_T::ARC );
757
758 VECTOR2I center;
759
760 center.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
761 center.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
762
763 arc->SetPosition( center );
764
765 (void) schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
766
767 EDA_ANGLE angle1( parseInt( aReader, line, &line ), TENTHS_OF_A_DEGREE_T );
768 EDA_ANGLE angle2( parseInt( aReader, line, &line ), TENTHS_OF_A_DEGREE_T );
769
770 arc->SetUnit( parseInt( aReader, line, &line ) );
771 arc->SetConvert( parseInt( aReader, line, &line ) );
772
773 STROKE_PARAMS stroke( schIUScale.MilsToIU( parseInt( aReader, line, &line ) ), PLOT_DASH_TYPE::SOLID );
774
775 arc->SetStroke( stroke );
776
777 // Old libraries (version <= 2.2) do not have always this FILL MODE param when fill mode
778 // is no fill (default mode).
779 if( *line != 0 )
780 arc->SetFillMode( parseFillMode( aReader, line, &line ) );
781
782 // Actual Coordinates of arc ends are read from file
783 if( *line != 0 )
784 {
785 VECTOR2I arcStart, arcEnd;
786
787 arcStart.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
788 arcStart.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
789 arcEnd.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
790 arcEnd.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
791
792 arc->SetStart( arcStart );
793 arc->SetEnd( arcEnd );
794 }
795 // Actual Coordinates of arc ends are not read from file (old library), calculate them
796 else
797 {
798 arc->SetArcAngleAndEnd( angle2 - angle1, true );
799 }
800
801 /*
802 * Current file format stores start-mid-end and so doesn't care about winding. We
803 * store start-end with an implied winding internally though.
804 * This issue is only for 180 deg arcs, because 180 deg are a limit to handle arcs in
805 * legacy libs.
806 *
807 * So a workaround is to slightly change the arc angle to
808 * avoid 180 deg arc after correction
809 */
810 EDA_ANGLE arc_angle = arc->GetArcAngle();
811
812 if( arc_angle == ANGLE_180 )
813 {
814 VECTOR2I new_center = CalcArcCenter( arc->GetStart(), arc->GetEnd(),
815 EDA_ANGLE( 179.5, DEGREES_T ) );
816 arc->SetCenter( new_center );
817 }
818
819 // In legacy libraries, an arc angle is always <= 180.0 degrees
820 // So if the created arc is > 180 degrees, swap arc ends to have a < 180 deg arc.
821 if( arc->GetArcAngle() > ANGLE_180 )
822 {
823 VECTOR2I new_end = arc->GetStart();
824 VECTOR2I new_start = arc->GetEnd();
825 arc->SetStart( new_start );
826 arc->SetEnd( new_end );
827 }
828
829 return arc;
830}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
EDA_ANGLE GetArcAngle() const
Definition: eda_shape.cpp:573
void SetCenter(const VECTOR2I &aCenter)
Definition: eda_shape.cpp:458
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:145
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:124
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:120
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:149
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
Definition: eda_shape.cpp:584
void SetFillMode(FILL_T aFill)
Definition: eda_shape.h:100
void SetConvert(int aConvert)
Definition: lib_item.h:275
void SetUnit(int aUnit)
Definition: lib_item.h:272
void SetStroke(const STROKE_PARAMS &aStroke)
Definition: lib_shape.h:53
void SetPosition(const VECTOR2I &aPosition) override
Definition: lib_shape.h:86
static FILL_T parseFillMode(LINE_READER &aReader, const char *aLine, const char **aOutput)
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88
static constexpr EDA_ANGLE & ANGLE_180
Definition: eda_angle.h:416
@ TENTHS_OF_A_DEGREE_T
Definition: eda_angle.h:30
@ DEGREES_T
Definition: eda_angle.h:31
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
Definition: trigo.cpp:472

References ANGLE_180, ARC, CalcArcCenter(), DEGREES_T, EDA_SHAPE::GetArcAngle(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetStart(), LINE_READER::Line(), EDA_IU_SCALE::MilsToIU(), parseFillMode(), parseInt(), schIUScale, EDA_SHAPE::SetArcAngleAndEnd(), EDA_SHAPE::SetCenter(), LIB_ITEM::SetConvert(), EDA_SHAPE::SetEnd(), EDA_SHAPE::SetFillMode(), LIB_SHAPE::SetPosition(), EDA_SHAPE::SetStart(), LIB_SHAPE::SetStroke(), LIB_ITEM::SetUnit(), SOLID, strCompare(), TENTHS_OF_A_DEGREE_T, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by loadDrawEntries().

◆ loadBezier()

LIB_SHAPE * SCH_LEGACY_PLUGIN_CACHE::loadBezier ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
LINE_READER aReader 
)
staticprivate

Definition at line 1250 of file sch_legacy_lib_plugin_cache.cpp.

1252{
1253 const char* line = aReader.Line();
1254
1255 wxCHECK_MSG( strCompare( "B", line, &line ), nullptr, "Invalid Bezier definition" );
1256
1257 int points = parseInt( aReader, line, &line );
1258
1259 wxCHECK_MSG( points == 4, NULL, "Invalid Bezier curve definition" );
1260
1261 LIB_SHAPE* bezier = new LIB_SHAPE( aSymbol.get(), SHAPE_T::BEZIER );
1262
1263 bezier->SetUnit( parseInt( aReader, line, &line ) );
1264 bezier->SetConvert( parseInt( aReader, line, &line ) );
1265
1266 STROKE_PARAMS stroke ( schIUScale.MilsToIU( parseInt( aReader, line, &line ) ), PLOT_DASH_TYPE::SOLID );
1267
1268 bezier->SetStroke( stroke );
1269
1270 VECTOR2I pt;
1271
1272 pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
1273 pt.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
1274 bezier->SetStart( pt );
1275
1276 pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
1277 pt.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
1278 bezier->SetBezierC1( pt );
1279
1280 pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
1281 pt.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
1282 bezier->SetBezierC2( pt );
1283
1284 pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
1285 pt.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
1286 bezier->SetEnd( pt );
1287
1288 bezier->RebuildBezierToSegmentsPointsList( bezier->GetWidth() );
1289
1290 if( *line != 0 )
1291 bezier->SetFillMode( parseFillMode( aReader, line, &line ) );
1292
1293 return bezier;
1294}
void SetBezierC2(const VECTOR2I &aPt)
Definition: eda_shape.h:178
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
Definition: eda_shape.cpp:405
int GetWidth() const
Definition: eda_shape.h:109
void SetBezierC1(const VECTOR2I &aPt)
Definition: eda_shape.h:175

References BEZIER, EDA_SHAPE::GetWidth(), LINE_READER::Line(), EDA_IU_SCALE::MilsToIU(), parseFillMode(), parseInt(), EDA_SHAPE::RebuildBezierToSegmentsPointsList(), schIUScale, EDA_SHAPE::SetBezierC1(), EDA_SHAPE::SetBezierC2(), LIB_ITEM::SetConvert(), EDA_SHAPE::SetEnd(), EDA_SHAPE::SetFillMode(), EDA_SHAPE::SetStart(), LIB_SHAPE::SetStroke(), LIB_ITEM::SetUnit(), SOLID, strCompare(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by loadDrawEntries().

◆ loadCircle()

LIB_SHAPE * SCH_LEGACY_PLUGIN_CACHE::loadCircle ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
LINE_READER aReader 
)
staticprivate

Definition at line 833 of file sch_legacy_lib_plugin_cache.cpp.

835{
836 const char* line = aReader.Line();
837
838 wxCHECK_MSG( strCompare( "C", line, &line ), nullptr, "Invalid circle definition" );
839
840 LIB_SHAPE* circle = new LIB_SHAPE( aSymbol.get(), SHAPE_T::CIRCLE );
841
842 VECTOR2I center;
843
844 center.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
845 center.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
846
847 int radius = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
848
849 circle->SetStart( center );
850 circle->SetEnd( VECTOR2I( center.x + radius, center.y ) );
851 circle->SetUnit( parseInt( aReader, line, &line ) );
852 circle->SetConvert( parseInt( aReader, line, &line ) );
853
854 STROKE_PARAMS stroke( schIUScale.MilsToIU( parseInt( aReader, line, &line ) ), PLOT_DASH_TYPE::SOLID );
855
856 circle->SetStroke( stroke );
857
858 if( *line != 0 )
859 circle->SetFillMode( parseFillMode( aReader, line, &line ) );
860
861 return circle;
862}
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References CIRCLE, LINE_READER::Line(), EDA_IU_SCALE::MilsToIU(), parseFillMode(), parseInt(), schIUScale, LIB_ITEM::SetConvert(), EDA_SHAPE::SetEnd(), EDA_SHAPE::SetFillMode(), EDA_SHAPE::SetStart(), LIB_SHAPE::SetStroke(), LIB_ITEM::SetUnit(), SOLID, strCompare(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by loadDrawEntries().

◆ loadDocs()

void SCH_LEGACY_PLUGIN_CACHE::loadDocs ( )
private

Definition at line 154 of file sch_legacy_lib_plugin_cache.cpp.

155{
156 const char* line;
157 wxString text;
158 wxString aliasName;
159 wxFileName fn = m_libFileName;
160 LIB_SYMBOL* symbol = nullptr;;
161
163
164 // Not all libraries will have a document file.
165 if( !fn.FileExists() )
166 return;
167
168 if( !fn.IsFileReadable() )
169 {
170 THROW_IO_ERROR( wxString::Format( _( "Insufficient permissions to read library '%s'." ),
171 fn.GetFullPath() ) );
172 }
173
174 FILE_LINE_READER reader( fn.GetFullPath() );
175
176 line = reader.ReadLine();
177
178 if( !line )
179 THROW_IO_ERROR( _( "symbol document library file is empty" ) );
180
181 if( !strCompare( DOCFILE_IDENT, line, &line ) )
182 {
183 SCH_PARSE_ERROR( "invalid document library file version formatting in header",
184 reader, line );
185 }
186
187 while( reader.ReadLine() )
188 {
189 line = reader.Line();
190
191 if( *line == '#' ) // Comment line.
192 continue;
193
194 if( !strCompare( "$CMP", line, &line ) != 0 )
195 SCH_PARSE_ERROR( "$CMP command expected", reader, line );
196
197 aliasName = wxString::FromUTF8( line );
198 aliasName.Trim();
199
200 LIB_SYMBOL_MAP::iterator it = m_symbols.find( aliasName );
201
202 if( it == m_symbols.end() )
203 wxLogWarning( "Symbol '%s' not found in library:\n\n"
204 "'%s'\n\nat line %d offset %d", aliasName, fn.GetFullPath(),
205 reader.LineNumber(), (int) (line - reader.Line() ) );
206 else
207 symbol = it->second;
208
209 // Read the current alias associated doc.
210 // if the alias does not exist, just skip the description
211 // (Can happen if a .dcm is not synchronized with the corresponding .lib file)
212 while( reader.ReadLine() )
213 {
214 line = reader.Line();
215
216 if( !line )
217 SCH_PARSE_ERROR( "unexpected end of file", reader, line );
218
219 if( strCompare( "$ENDCMP", line, &line ) )
220 break;
221
222 text = FROM_UTF8( line + 2 );
223 // Remove spaces at eol, and eol chars:
224 text = text.Trim();
225
226 switch( line[0] )
227 {
228 case 'D':
229 if( symbol )
230 symbol->SetDescription( text );
231 break;
232
233 case 'K':
234 if( symbol )
235 symbol->SetKeyWords( text );
236 break;
237
238 case 'F':
239 if( symbol )
241 break;
242
243 case 0:
244 case '\n':
245 case '\r':
246 case '#':
247 // Empty line or commment
248 break;
249
250 default:
251 SCH_PARSE_ERROR( "expected token in symbol definition", reader, line );
252 }
253 }
254 }
255}
void SetDescription(const wxString &aDescription)
Definition: lib_symbol.h:144
void SetKeyWords(const wxString &aKeyWords)
Definition: lib_symbol.h:157
const std::string LegacySymbolDocumentFileExtension
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
#define DOCFILE_IDENT
Legacy symbol library document (.dcm) file header.
@ DATASHEET_FIELD
name of datasheet

References _, DATASHEET_FIELD, DOCFILE_IDENT, Format(), FROM_UTF8(), LIB_SYMBOL::GetFieldById(), LegacySymbolDocumentFileExtension, LINE_READER::Line(), LINE_READER::LineNumber(), SCH_LIB_PLUGIN_CACHE::m_libFileName, SCH_LIB_PLUGIN_CACHE::m_symbols, FILE_LINE_READER::ReadLine(), SCH_PARSE_ERROR, LIB_SYMBOL::SetDescription(), LIB_SYMBOL::SetKeyWords(), EDA_TEXT::SetText(), strCompare(), text, and THROW_IO_ERROR.

Referenced by Load().

◆ loadDrawEntries()

void SCH_LEGACY_PLUGIN_CACHE::loadDrawEntries ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
LINE_READER aReader,
int  aMajorVersion,
int  aMinorVersion 
)
staticprivate

Definition at line 666 of file sch_legacy_lib_plugin_cache.cpp.

670{
671 const char* line = aReader.Line();
672
673 wxCHECK_RET( strCompare( "DRAW", line, &line ), "Invalid DRAW section" );
674
675 line = aReader.ReadLine();
676
677 while( line )
678 {
679 if( strCompare( "ENDDRAW", line, &line ) )
680 {
681 aSymbol->GetDrawItems().sort();
682 return;
683 }
684
685 switch( line[0] )
686 {
687 case 'A': // Arc
688 aSymbol->AddDrawItem( loadArc( aSymbol, aReader ), false );
689 break;
690
691 case 'C': // Circle
692 aSymbol->AddDrawItem( loadCircle( aSymbol, aReader ), false );
693 break;
694
695 case 'T': // Text
696 aSymbol->AddDrawItem( loadText( aSymbol, aReader, aMajorVersion, aMinorVersion ),
697 false );
698 break;
699
700 case 'S': // Square
701 aSymbol->AddDrawItem( loadRect( aSymbol, aReader ), false );
702 break;
703
704 case 'X': // Pin Description
705 aSymbol->AddDrawItem( loadPin( aSymbol, aReader ), false );
706 break;
707
708 case 'P': // Polyline
709 aSymbol->AddDrawItem( loadPolyLine( aSymbol, aReader ), false );
710 break;
711
712 case 'B': // Bezier Curves
713 aSymbol->AddDrawItem( loadBezier( aSymbol, aReader ), false );
714 break;
715
716 case '#': // Comment
717 case '\n': // Empty line
718 case '\r':
719 case 0:
720 break;
721
722 default:
723 SCH_PARSE_ERROR( "undefined DRAW entry", aReader, line );
724 }
725
726 line = aReader.ReadLine();
727 }
728
729 SCH_PARSE_ERROR( "File ended prematurely loading symbol draw element.", aReader, line );
730}
virtual char * ReadLine()=0
Read a line of text into the buffer and increments the line number counter.
static LIB_SHAPE * loadCircle(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static LIB_SHAPE * loadPolyLine(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static LIB_SHAPE * loadBezier(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static LIB_TEXT * loadText(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, int aMajorVersion, int aMinorVersion)
static LIB_SHAPE * loadRect(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static LIB_PIN * loadPin(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static LIB_SHAPE * loadArc(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)

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

Referenced by LoadPart().

◆ loadField()

void SCH_LEGACY_PLUGIN_CACHE::loadField ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
LINE_READER aReader 
)
staticprivate

Definition at line 515 of file sch_legacy_lib_plugin_cache.cpp.

517{
518 const char* line = aReader.Line();
519
520 wxCHECK_RET( *line == 'F', "Invalid field line" );
521
522 wxString text;
523 int id;
524
525 if( sscanf( line + 1, "%d", &id ) != 1 || id < 0 )
526 SCH_PARSE_ERROR( "invalid field ID", aReader, line + 1 );
527
528 LIB_FIELD* field;
529
530 if( id >= 0 && id < MANDATORY_FIELDS )
531 {
532 field = aSymbol->GetFieldById( id );
533
534 // this will fire only if somebody broke a constructor or editor.
535 // MANDATORY_FIELDS are always present in ram resident symbols, no
536 // exceptions, and they always have their names set, even fixed fields.
537 wxASSERT( field );
538 }
539 else
540 {
541 field = new LIB_FIELD( aSymbol.get(), id );
542 aSymbol->AddDrawItem( field, false );
543 }
544
545 // Skip to the first double quote.
546 while( *line != '"' && *line != 0 )
547 line++;
548
549 if( *line == 0 )
550 SCH_PARSE_ERROR( _( "unexpected end of line" ), aReader, line );
551
552 parseQuotedString( text, aReader, line, &line, true );
553
554 // The value field needs to be "special" escaped. The other fields are
555 // escaped normally and don't need special handling
556 if( id == VALUE_FIELD )
558
559 // Doctor the *.lib file field which has a "~" in blank fields. New saves will
560 // not save like this.
561 if( text.size() == 1 && text[0] == '~' )
562 field->SetText( wxEmptyString );
563 else
565
566 VECTOR2I pos;
567
568 pos.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
569 pos.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
570 field->SetPosition( pos );
571
572 wxSize textSize;
573
574 textSize.x = textSize.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
575 field->SetTextSize( textSize );
576
577 char textOrient = parseChar( aReader, line, &line );
578
579 if( textOrient == 'H' )
581 else if( textOrient == 'V' )
583 else
584 SCH_PARSE_ERROR( "invalid field text orientation parameter", aReader, line );
585
586 char textVisible = parseChar( aReader, line, &line );
587
588 if( textVisible == 'V' )
589 field->SetVisible( true );
590 else if ( textVisible == 'I' )
591 field->SetVisible( false );
592 else
593 SCH_PARSE_ERROR( "invalid field text visibility parameter", aReader, line );
594
595 // It may be technically correct to use the library version to determine if the field text
596 // attributes are present. If anyone knows if that is valid and what version that would be,
597 // please change this to test the library version rather than an EOL or the quoted string
598 // of the field name.
599 if( *line != 0 && *line != '"' )
600 {
601 char textHJustify = parseChar( aReader, line, &line );
602
603 if( textHJustify == 'C' )
605 else if( textHJustify == 'L' )
607 else if( textHJustify == 'R' )
609 else
610 SCH_PARSE_ERROR( "invalid field text horizontal justification", aReader, line );
611
612 wxString attributes;
613
614 parseUnquotedString( attributes, aReader, line, &line );
615
616 size_t attrSize = attributes.size();
617
618 if( !(attrSize == 3 || attrSize == 1 ) )
619 SCH_PARSE_ERROR( "invalid field text attributes size", aReader, line );
620
621 switch( (wxChar) attributes[0] )
622 {
623 case 'C': field->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break;
624 case 'B': field->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break;
625 case 'T': field->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break;
626 default: SCH_PARSE_ERROR( "invalid field text vertical justification", aReader, line );
627 }
628
629 if( attrSize == 3 )
630 {
631 wxChar attr_1 = attributes[1];
632 wxChar attr_2 = attributes[2];
633
634 if( attr_1 == 'I' ) // Italic
635 field->SetItalic( true );
636 else if( attr_1 != 'N' ) // No italics is default, check for error.
637 SCH_PARSE_ERROR( "invalid field text italic parameter", aReader, line );
638
639 if ( attr_2 == 'B' ) // Bold
640 field->SetBold( true );
641 else if( attr_2 != 'N' ) // No bold is default, check for error.
642 SCH_PARSE_ERROR( "invalid field text bold parameter", aReader, line );
643 }
644 }
645
646 // Fields in RAM must always have names.
647 if( id >= 0 && id < MANDATORY_FIELDS )
648 {
649 // Fields in RAM must always have names, because we are trying to get
650 // less dependent on field ids and more dependent on names.
651 // Plus assumptions are made in the field editors.
653
654 // Ensure the VALUE field = the symbol name (can be not the case
655 // with malformed libraries: edited by hand, or converted from other tools)
656 if( id == VALUE_FIELD )
657 field->SetText( aSymbol->GetName() );
658 }
659 else
660 {
661 parseQuotedString( field->m_name, aReader, line, &line, true ); // Optional.
662 }
663}
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:248
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:217
void SetBold(bool aBold)
Definition: eda_text.cpp:209
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:347
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:193
void SetItalic(bool aItalic)
Definition: eda_text.cpp:201
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:240
wxString m_name
Name (not the field text value itself, that is #EDA_TEXT::m_Text)
Definition: lib_field.h:225
void SetPosition(const VECTOR2I &aPosition) override
Definition: lib_item.h:234
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:408
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:409
void parseQuotedString(wxString &aString, LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken, bool aCanBeEmpty)
Parse an quoted ASCII utf8 and updates the pointer at aOutput if it is not NULL.
void parseUnquotedString(wxString &aString, LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken, bool aCanBeEmpty)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
char parseChar(LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken)
Parse a single ASCII character and updates the pointer at aOutput if it is not NULL.
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_QUOTED_STR
Definition: string_utils.h:57
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP

References _, ANGLE_HORIZONTAL, ANGLE_VERTICAL, ConvertToNewOverbarNotation(), CTX_QUOTED_STR, EscapeString(), TEMPLATE_FIELDNAME::GetDefaultFieldName(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, LINE_READER::Line(), LIB_FIELD::m_name, MANDATORY_FIELDS, EDA_IU_SCALE::MilsToIU(), parseChar(), parseInt(), parseQuotedString(), parseUnquotedString(), SCH_PARSE_ERROR, schIUScale, EDA_TEXT::SetBold(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetItalic(), LIB_ITEM::SetPosition(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), text, VALUE_FIELD, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by LoadPart().

◆ loadFootprintFilters()

void SCH_LEGACY_PLUGIN_CACHE::loadFootprintFilters ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
LINE_READER aReader 
)
staticprivate

Definition at line 1297 of file sch_legacy_lib_plugin_cache.cpp.

1299{
1300 const char* line = aReader.Line();
1301
1302 wxCHECK_RET( strCompare( "$FPLIST", line, &line ), "Invalid footprint filter list" );
1303
1304 line = aReader.ReadLine();
1305
1306 wxArrayString footprintFilters;
1307
1308 while( line )
1309 {
1310 if( strCompare( "$ENDFPLIST", line, &line ) )
1311 {
1312 aSymbol->SetFPFilters( footprintFilters );
1313 return;
1314 }
1315
1316 wxString footprint;
1317
1318 parseUnquotedString( footprint, aReader, line, &line );
1319 footprintFilters.Add( footprint );
1320 line = aReader.ReadLine();
1321 }
1322
1323 SCH_PARSE_ERROR( "File ended prematurely while loading footprint filters.", aReader, line );
1324}

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

Referenced by LoadPart().

◆ loadHeader()

void SCH_LEGACY_PLUGIN_CACHE::loadHeader ( FILE_LINE_READER aReader)
private

Definition at line 258 of file sch_legacy_lib_plugin_cache.cpp.

259{
260 const char* line = aReader.Line();
261
262 wxASSERT( strCompare( "$HEADER", line, &line ) );
263
264 while( aReader.ReadLine() )
265 {
266 line = (char*) aReader;
267
268 // The time stamp saved in old library files is not used or saved in the latest
269 // library file version.
270 if( strCompare( "TimeStamp", line, &line ) )
271 continue;
272 else if( strCompare( "$ENDHEADER", line, &line ) )
273 return;
274 }
275
276 SCH_PARSE_ERROR( "$ENDHEADER not found", aReader, line );
277}
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
Definition: richio.cpp:219

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

Referenced by Load().

◆ LoadPart()

LIB_SYMBOL * SCH_LEGACY_PLUGIN_CACHE::LoadPart ( LINE_READER aReader,
int  aMajorVersion,
int  aMinorVersion,
LIB_SYMBOL_MAP aMap = nullptr 
)
static

Definition at line 280 of file sch_legacy_lib_plugin_cache.cpp.

282{
283 const char* line = aReader.Line();
284
285 while( *line == '#' )
286 aReader.ReadLine();
287
288 if( !strCompare( "DEF", line, &line ) )
289 SCH_PARSE_ERROR( "invalid symbol definition", aReader, line );
290
291 long num;
292 size_t pos = 4; // "DEF" plus the first space.
293 wxString utf8Line = wxString::FromUTF8( line );
294 wxStringTokenizer tokens( utf8Line, " \r\n\t" );
295
296 if( tokens.CountTokens() < 8 )
297 SCH_PARSE_ERROR( "invalid symbol definition", aReader, line );
298
299 // Read DEF line:
300 std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( wxEmptyString );
301
302 wxString name, prefix, tmp;
303
304 name = tokens.GetNextToken();
305
306 // This fixes a dubious decision to escape LIB_ID characters. Escaped LIB_IDs broke rescue
307 // library look up. Legacy LIB_IDs should not be escaped.
308 if( name != UnescapeString( name ) )
310
311 pos += name.size() + 1;
312
313 prefix = tokens.GetNextToken();
314 pos += prefix.size() + 1;
315
316 tmp = tokens.GetNextToken();
317 pos += tmp.size() + 1; // NumOfPins, unused.
318
319 tmp = tokens.GetNextToken(); // Pin name offset.
320
321 if( !tmp.ToLong( &num ) )
322 {
323 THROW_PARSE_ERROR( "invalid pin offset", aReader.GetSource(), aReader.Line(),
324 aReader.LineNumber(), pos );
325 }
326
327 pos += tmp.size() + 1;
328 symbol->SetPinNameOffset( schIUScale.MilsToIU( (int)num ) );
329
330 tmp = tokens.GetNextToken(); // Show pin numbers.
331
332 if( !( tmp == "Y" || tmp == "N") )
333 THROW_PARSE_ERROR( "expected Y or N", aReader.GetSource(), aReader.Line(),
334 aReader.LineNumber(), pos );
335
336 pos += tmp.size() + 1;
337 symbol->SetShowPinNumbers( ( tmp == "N" ) ? false : true );
338
339 tmp = tokens.GetNextToken(); // Show pin names.
340
341 if( !( tmp == "Y" || tmp == "N") )
342 {
343 THROW_PARSE_ERROR( "expected Y or N", aReader.GetSource(), aReader.Line(),
344 aReader.LineNumber(), pos );
345 }
346
347 pos += tmp.size() + 1;
348 symbol->SetShowPinNames( ( tmp == "N" ) ? false : true );
349
350 tmp = tokens.GetNextToken(); // Number of units.
351
352 if( !tmp.ToLong( &num ) )
353 {
354 THROW_PARSE_ERROR( "invalid unit count", aReader.GetSource(), aReader.Line(),
355 aReader.LineNumber(), pos );
356 }
357
358 pos += tmp.size() + 1;
359 symbol->SetUnitCount( (int)num );
360
361 // Ensure m_unitCount is >= 1. Could be read as 0 in old libraries.
362 if( symbol->GetUnitCount() < 1 )
363 symbol->SetUnitCount( 1 );
364
365 // Copy symbol name and prefix.
366
367 // The root alias is added to the alias list by SetName() which is called by SetText().
368 if( name.IsEmpty() )
369 {
370 symbol->SetName( "~" );
371 }
372 else if( name[0] != '~' )
373 {
374 symbol->SetName( name );
375 }
376 else
377 {
378 symbol->SetName( name.Right( name.Length() - 1 ) );
379 symbol->GetValueField().SetVisible( false );
380 }
381
382 // Don't set the library alias, this is determined by the symbol library table.
383 symbol->SetLibId( LIB_ID( wxEmptyString, symbol->GetName() ) );
384
385 LIB_FIELD& reference = symbol->GetReferenceField();
386
387 if( prefix == "~" )
388 {
389 reference.Empty();
390 reference.SetVisible( false );
391 }
392 else
393 {
394 reference.SetText( prefix );
395 }
396
397 // In version 2.2 and earlier, this parameter was a '0' which was just a place holder.
398 // The was no concept of interchangeable multiple unit symbols.
399 if( LIB_VERSION( aMajorVersion, aMinorVersion ) > 0
400 && LIB_VERSION( aMajorVersion, aMinorVersion ) <= LIB_VERSION( 2, 2 ) )
401 {
402 // Nothing needs to be set since the default setting for symbols with multiple
403 // units were never interchangeable. Just parse the 0 an move on.
404 tmp = tokens.GetNextToken();
405 pos += tmp.size() + 1;
406 }
407 else
408 {
409 tmp = tokens.GetNextToken();
410
411 if( tmp == "L" )
412 symbol->LockUnits( true );
413 else if( tmp == "F" || tmp == "0" )
414 symbol->LockUnits( false );
415 else
416 THROW_PARSE_ERROR( "expected L, F, or 0", aReader.GetSource(), aReader.Line(),
417 aReader.LineNumber(), pos );
418
419 pos += tmp.size() + 1;
420 }
421
422 // There is the optional power symbol flag.
423 if( tokens.HasMoreTokens() )
424 {
425 tmp = tokens.GetNextToken();
426
427 if( tmp == "P" )
428 symbol->SetPower();
429 else if( tmp == "N" )
430 symbol->SetNormal();
431 else
432 THROW_PARSE_ERROR( "expected P or N", aReader.GetSource(), aReader.Line(),
433 aReader.LineNumber(), pos );
434 }
435
436 line = aReader.ReadLine();
437
438 // Read lines until "ENDDEF" is found.
439 while( line )
440 {
441 if( *line == '#' ) // Comment
442 ;
443 else if( strCompare( "Ti", line, &line ) ) // Modification date is ignored.
444 continue;
445 else if( strCompare( "ALIAS", line, &line ) ) // Aliases
446 loadAliases( symbol, aReader, aMap );
447 else if( *line == 'F' ) // Fields
448 loadField( symbol, aReader );
449 else if( strCompare( "DRAW", line, &line ) ) // Drawing objects.
450 loadDrawEntries( symbol, aReader, aMajorVersion, aMinorVersion );
451 else if( strCompare( "$FPLIST", line, &line ) ) // Footprint filter list
452 loadFootprintFilters( symbol, aReader );
453 else if( strCompare( "ENDDEF", line, &line ) ) // End of symbol description
454 {
455 return symbol.release();
456 }
457
458 line = aReader.ReadLine();
459 }
460
461 SCH_PARSE_ERROR( "missing ENDDEF", aReader, line );
462}
void Empty()
Definition: eda_text.cpp:400
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
virtual const wxString & GetSource() const
Returns the name of the source of the lines in an abstract sense.
Definition: richio.h:109
virtual unsigned LineNumber() const
Return the line number of the last line read from this LINE_READER.
Definition: richio.h:135
static void loadField(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static void loadFootprintFilters(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static void loadDrawEntries(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, int aMajorVersion, int aMinorVersion)
static void loadAliases(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, LIB_SYMBOL_MAP *aMap=nullptr)
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
Definition: ki_exception.h:164
#define LIB_VERSION(major, minor)
wxString UnescapeString(const wxString &aSource)

References EDA_TEXT::Empty(), LINE_READER::GetSource(), LIB_VERSION, LINE_READER::Line(), LINE_READER::LineNumber(), loadAliases(), loadDrawEntries(), loadField(), loadFootprintFilters(), EDA_IU_SCALE::MilsToIU(), name, LINE_READER::ReadLine(), SCH_PARSE_ERROR, schIUScale, EDA_TEXT::SetText(), EDA_TEXT::SetVisible(), strCompare(), THROW_PARSE_ERROR, and UnescapeString().

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

◆ loadPin()

LIB_PIN * SCH_LEGACY_PLUGIN_CACHE::loadPin ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
LINE_READER aReader 
)
staticprivate

Definition at line 1000 of file sch_legacy_lib_plugin_cache.cpp.

1002{
1003 const char* line = aReader.Line();
1004
1005 wxCHECK_MSG( strCompare( "X", line, &line ), nullptr, "Invalid LIB_PIN definition" );
1006
1007 wxString name;
1008 wxString number;
1009
1010 size_t pos = 2; // "X" plus ' ' space character.
1011 wxString tmp;
1012 wxString utf8Line = wxString::FromUTF8( line );
1013 wxStringTokenizer tokens( utf8Line, " \r\n\t" );
1014
1015 if( tokens.CountTokens() < 11 )
1016 SCH_PARSE_ERROR( "invalid pin definition", aReader, line );
1017
1018 tmp = tokens.GetNextToken();
1019 name = tmp;
1020 pos += tmp.size() + 1;
1021
1022 tmp = tokens.GetNextToken();
1023 number = tmp ;
1024 pos += tmp.size() + 1;
1025
1026 long num;
1027 VECTOR2I position;
1028
1029 tmp = tokens.GetNextToken();
1030
1031 if( !tmp.ToLong( &num ) )
1032 {
1033 THROW_PARSE_ERROR( "invalid pin X coordinate", aReader.GetSource(), aReader.Line(),
1034 aReader.LineNumber(), pos );
1035 }
1036
1037 pos += tmp.size() + 1;
1038 position.x = schIUScale.MilsToIU( (int) num );
1039
1040 tmp = tokens.GetNextToken();
1041
1042 if( !tmp.ToLong( &num ) )
1043 {
1044 THROW_PARSE_ERROR( "invalid pin Y coordinate", aReader.GetSource(), aReader.Line(),
1045 aReader.LineNumber(), pos );
1046 }
1047
1048 pos += tmp.size() + 1;
1049 position.y = schIUScale.MilsToIU( (int) num );
1050
1051 tmp = tokens.GetNextToken();
1052
1053 if( !tmp.ToLong( &num ) )
1054 {
1055 THROW_PARSE_ERROR( "invalid pin length", aReader.GetSource(), aReader.Line(),
1056 aReader.LineNumber(), pos );
1057 }
1058
1059 pos += tmp.size() + 1;
1060 int length = schIUScale.MilsToIU( (int) num );
1061
1062
1063 tmp = tokens.GetNextToken();
1064
1065 if( tmp.size() > 1 )
1066 {
1067 THROW_PARSE_ERROR( "invalid pin orientation", aReader.GetSource(), aReader.Line(),
1068 aReader.LineNumber(), pos );
1069 }
1070
1071 pos += tmp.size() + 1;
1072 int orientation = tmp[0];
1073
1074 tmp = tokens.GetNextToken();
1075
1076 if( !tmp.ToLong( &num ) )
1077 {
1078 THROW_PARSE_ERROR( "invalid pin number text size", aReader.GetSource(), aReader.Line(),
1079 aReader.LineNumber(), pos );
1080 }
1081
1082 pos += tmp.size() + 1;
1083 int numberTextSize = schIUScale.MilsToIU( (int) num );
1084
1085 tmp = tokens.GetNextToken();
1086
1087 if( !tmp.ToLong( &num ) )
1088 {
1089 THROW_PARSE_ERROR( "invalid pin name text size", aReader.GetSource(), aReader.Line(),
1090 aReader.LineNumber(), pos );
1091 }
1092
1093 pos += tmp.size() + 1;
1094 int nameTextSize = schIUScale.MilsToIU( (int) num );
1095
1096 tmp = tokens.GetNextToken();
1097
1098 if( !tmp.ToLong( &num ) )
1099 {
1100 THROW_PARSE_ERROR( "invalid pin unit", aReader.GetSource(), aReader.Line(),
1101 aReader.LineNumber(), pos );
1102 }
1103
1104 pos += tmp.size() + 1;
1105 int unit = (int) num;
1106
1107 tmp = tokens.GetNextToken();
1108
1109 if( !tmp.ToLong( &num ) )
1110 {
1111 THROW_PARSE_ERROR( "invalid pin alternate body type", aReader.GetSource(), aReader.Line(),
1112 aReader.LineNumber(), pos );
1113 }
1114
1115 pos += tmp.size() + 1;
1116 int convert = (int) num;
1117
1118 tmp = tokens.GetNextToken();
1119
1120 if( tmp.size() != 1 )
1121 {
1122 THROW_PARSE_ERROR( "invalid pin type", aReader.GetSource(), aReader.Line(),
1123 aReader.LineNumber(), pos );
1124 }
1125
1126 pos += tmp.size() + 1;
1127 char type = tmp[0];
1128 ELECTRICAL_PINTYPE pinType;
1129
1130 switch( type )
1131 {
1132 case 'I': pinType = ELECTRICAL_PINTYPE::PT_INPUT; break;
1133 case 'O': pinType = ELECTRICAL_PINTYPE::PT_OUTPUT; break;
1134 case 'B': pinType = ELECTRICAL_PINTYPE::PT_BIDI; break;
1135 case 'T': pinType = ELECTRICAL_PINTYPE::PT_TRISTATE; break;
1136 case 'P': pinType = ELECTRICAL_PINTYPE::PT_PASSIVE; break;
1137 case 'U': pinType = ELECTRICAL_PINTYPE::PT_UNSPECIFIED; break;
1138 case 'W': pinType = ELECTRICAL_PINTYPE::PT_POWER_IN; break;
1139 case 'w': pinType = ELECTRICAL_PINTYPE::PT_POWER_OUT; break;
1140 case 'C': pinType = ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR; break;
1141 case 'E': pinType = ELECTRICAL_PINTYPE::PT_OPENEMITTER; break;
1142 case 'N': pinType = ELECTRICAL_PINTYPE::PT_NC; break;
1143 default:
1144 THROW_PARSE_ERROR( "unknown pin type", aReader.GetSource(), aReader.Line(),
1145 aReader.LineNumber(), pos );
1146 }
1147
1148
1149 LIB_PIN* pin = new LIB_PIN( aSymbol.get(),
1152 orientation,
1153 pinType,
1154 length,
1155 nameTextSize,
1156 numberTextSize,
1157 convert,
1158 position,
1159 unit );
1160
1161 // Optional
1162 if( tokens.HasMoreTokens() ) /* Special Symbol defined */
1163 {
1164 tmp = tokens.GetNextToken();
1165
1166 enum
1167 {
1168 INVERTED = 1 << 0,
1169 CLOCK = 1 << 1,
1170 LOWLEVEL_IN = 1 << 2,
1171 LOWLEVEL_OUT = 1 << 3,
1172 FALLING_EDGE = 1 << 4,
1173 NONLOGIC = 1 << 5
1174 };
1175
1176 int flags = 0;
1177
1178 for( int j = tmp.size(); j > 0; )
1179 {
1180 switch( tmp[--j].GetValue() )
1181 {
1182 case '~': break;
1183 case 'N': pin->SetVisible( false ); break;
1184 case 'I': flags |= INVERTED; break;
1185 case 'C': flags |= CLOCK; break;
1186 case 'L': flags |= LOWLEVEL_IN; break;
1187 case 'V': flags |= LOWLEVEL_OUT; break;
1188 case 'F': flags |= FALLING_EDGE; break;
1189 case 'X': flags |= NONLOGIC; break;
1190 default: THROW_PARSE_ERROR( "invalid pin attribut", aReader.GetSource(),
1191 aReader.Line(), aReader.LineNumber(), pos );
1192 }
1193
1194 pos += 1;
1195 }
1196
1197 switch( flags )
1198 {
1199 case 0: pin->SetShape( GRAPHIC_PINSHAPE::LINE ); break;
1200 case INVERTED: pin->SetShape( GRAPHIC_PINSHAPE::INVERTED ); break;
1201 case CLOCK: pin->SetShape( GRAPHIC_PINSHAPE::CLOCK ); break;
1202 case INVERTED | CLOCK: pin->SetShape( GRAPHIC_PINSHAPE::INVERTED_CLOCK ); break;
1203 case LOWLEVEL_IN: pin->SetShape( GRAPHIC_PINSHAPE::INPUT_LOW ); break;
1204 case LOWLEVEL_IN | CLOCK: pin->SetShape( GRAPHIC_PINSHAPE::CLOCK_LOW ); break;
1205 case LOWLEVEL_OUT: pin->SetShape( GRAPHIC_PINSHAPE::OUTPUT_LOW ); break;
1206 case FALLING_EDGE: pin->SetShape( GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK ); break;
1207 case NONLOGIC: pin->SetShape( GRAPHIC_PINSHAPE::NONLOGIC ); break;
1208 default:
1209 SCH_PARSE_ERROR( "pin attributes do not define a valid pin shape", aReader, line );
1210 }
1211 }
1212
1213 return pin;
1214}
std::chrono::steady_clock CLOCK
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
Definition: pin_type.h:36
@ PT_INPUT
usual pin input: must be connected
@ PT_NC
not connected (must be left open)
@ PT_OUTPUT
usual output
@ PT_TRISTATE
tris state bus pin
@ PT_BIDI
input or output (like port for a microprocessor)
@ PT_OPENEMITTER
pin type open emitter
@ PT_POWER_OUT
output of a regulator: intended to be connected to power input pins
@ PT_OPENCOLLECTOR
pin type open collector
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin

References CLOCK, CLOCK_LOW, convert, ConvertToNewOverbarNotation(), FALLING_EDGE_CLOCK, LINE_READER::GetSource(), INPUT_LOW, INVERTED, INVERTED_CLOCK, LINE, LINE_READER::Line(), LINE_READER::LineNumber(), EDA_IU_SCALE::MilsToIU(), name, NONLOGIC, OUTPUT_LOW, pin, PT_BIDI, PT_INPUT, PT_NC, PT_OPENCOLLECTOR, PT_OPENEMITTER, PT_OUTPUT, PT_PASSIVE, PT_POWER_IN, PT_POWER_OUT, PT_TRISTATE, PT_UNSPECIFIED, SCH_PARSE_ERROR, schIUScale, strCompare(), THROW_PARSE_ERROR, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by loadDrawEntries().

◆ loadPolyLine()

LIB_SHAPE * SCH_LEGACY_PLUGIN_CACHE::loadPolyLine ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
LINE_READER aReader 
)
staticprivate

Definition at line 1217 of file sch_legacy_lib_plugin_cache.cpp.

1219{
1220 const char* line = aReader.Line();
1221
1222 wxCHECK_MSG( strCompare( "P", line, &line ), nullptr, "Invalid poly definition" );
1223
1224 LIB_SHAPE* polyLine = new LIB_SHAPE( aSymbol.get(), SHAPE_T::POLY );
1225
1226 int points = parseInt( aReader, line, &line );
1227 polyLine->SetUnit( parseInt( aReader, line, &line ) );
1228 polyLine->SetConvert( parseInt( aReader, line, &line ) );
1229
1230 STROKE_PARAMS stroke( schIUScale.MilsToIU( parseInt( aReader, line, &line ) ), PLOT_DASH_TYPE::SOLID );
1231
1232 polyLine->SetStroke( stroke );
1233
1234 VECTOR2I pt;
1235
1236 for( int i = 0; i < points; i++ )
1237 {
1238 pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
1239 pt.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
1240 polyLine->AddPoint( pt );
1241 }
1242
1243 if( *line != 0 )
1244 polyLine->SetFillMode( parseFillMode( aReader, line, &line ) );
1245
1246 return polyLine;
1247}
void AddPoint(const VECTOR2I &aPosition)
Definition: lib_shape.cpp:501

References LIB_SHAPE::AddPoint(), LINE_READER::Line(), EDA_IU_SCALE::MilsToIU(), parseFillMode(), parseInt(), POLY, schIUScale, LIB_ITEM::SetConvert(), EDA_SHAPE::SetFillMode(), LIB_SHAPE::SetStroke(), LIB_ITEM::SetUnit(), SOLID, strCompare(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by loadDrawEntries().

◆ loadRect()

LIB_SHAPE * SCH_LEGACY_PLUGIN_CACHE::loadRect ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
LINE_READER aReader 
)
staticprivate

Definition at line 964 of file sch_legacy_lib_plugin_cache.cpp.

966{
967 const char* line = aReader.Line();
968
969 wxCHECK_MSG( strCompare( "S", line, &line ), nullptr, "Invalid rectangle definition" );
970
971 LIB_SHAPE* rectangle = new LIB_SHAPE( aSymbol.get(), SHAPE_T::RECT );
972
973 VECTOR2I pos;
974
975 pos.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
976 pos.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
977 rectangle->SetPosition( pos );
978
979 VECTOR2I end;
980
981 end.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
982 end.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
983 rectangle->SetEnd( end );
984
985 rectangle->SetUnit( parseInt( aReader, line, &line ) );
986 rectangle->SetConvert( parseInt( aReader, line, &line ) );
987
988 STROKE_PARAMS stroke( schIUScale.MilsToIU( parseInt( aReader, line, &line ) ), PLOT_DASH_TYPE::SOLID );
989
990 rectangle->SetStroke( stroke );
991
992
993 if( *line != 0 )
994 rectangle->SetFillMode( parseFillMode( aReader, line, &line ) );
995
996 return rectangle;
997}

References LINE_READER::Line(), EDA_IU_SCALE::MilsToIU(), parseFillMode(), parseInt(), RECT, schIUScale, LIB_ITEM::SetConvert(), EDA_SHAPE::SetEnd(), EDA_SHAPE::SetFillMode(), LIB_SHAPE::SetPosition(), LIB_SHAPE::SetStroke(), LIB_ITEM::SetUnit(), SOLID, strCompare(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by loadDrawEntries().

◆ loadText()

LIB_TEXT * SCH_LEGACY_PLUGIN_CACHE::loadText ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
LINE_READER aReader,
int  aMajorVersion,
int  aMinorVersion 
)
staticprivate

Definition at line 865 of file sch_legacy_lib_plugin_cache.cpp.

869{
870 const char* line = aReader.Line();
871
872 wxCHECK_MSG( strCompare( "T", line, &line ), nullptr, "Invalid LIB_TEXT definition" );
873
874 LIB_TEXT* text = new LIB_TEXT( aSymbol.get() );
875 double angleInTenths = parseInt( aReader, line, &line );
876
877 text->SetTextAngle( EDA_ANGLE( angleInTenths, TENTHS_OF_A_DEGREE_T ) );
878
879 VECTOR2I center;
880
881 center.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
882 center.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
883 text->SetPosition( center );
884
885 wxSize size;
886
887 size.x = size.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
888 text->SetTextSize( size );
889 text->SetVisible( !parseInt( aReader, line, &line ) );
890 text->SetUnit( parseInt( aReader, line, &line ) );
891 text->SetConvert( parseInt( aReader, line, &line ) );
892
893 wxString str;
894
895 // If quoted string loading fails, load as not quoted string.
896 if( *line == '"' )
897 {
898 parseQuotedString( str, aReader, line, &line );
899
900 str = ConvertToNewOverbarNotation( str );
901 }
902 else
903 {
904 parseUnquotedString( str, aReader, line, &line );
905
906 // In old libs, "spaces" are replaced by '~' in unquoted strings:
907 str.Replace( "~", " " );
908 }
909
910 if( !str.IsEmpty() )
911 {
912 // convert two apostrophes back to double quote
913 str.Replace( "''", "\"" );
914 }
915
916 text->SetText( str );
917
918 // Here things are murky and not well defined. At some point it appears the format
919 // was changed to add text properties. However rather than add the token to the end of
920 // the text definition, it was added after the string and no mention if the file
921 // verion was bumped or not so this code make break on very old symbol libraries.
922 //
923 // Update: apparently even in the latest version this can be different so added a test
924 // for end of line before checking for the text properties.
925 if( LIB_VERSION( aMajorVersion, aMinorVersion ) > 0
926 && LIB_VERSION( aMajorVersion, aMinorVersion ) > LIB_VERSION( 2, 0 )
927 && !is_eol( *line ) )
928 {
929 if( strCompare( "Italic", line, &line ) )
930 text->SetItalic( true );
931 else if( !strCompare( "Normal", line, &line ) )
932 SCH_PARSE_ERROR( "invalid text stype, expected 'Normal' or 'Italic'", aReader, line );
933
934 if( parseInt( aReader, line, &line ) > 0 )
935 text->SetBold( true );
936
937 // Some old libaries version > 2.0 do not have these options for text justification:
938 if( !is_eol( *line ) )
939 {
940 switch( parseChar( aReader, line, &line ) )
941 {
942 case 'L': text->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break;
943 case 'C': text->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break;
944 case 'R': text->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break;
945 default: SCH_PARSE_ERROR( "invalid horizontal text justication; expected L, C, or R",
946 aReader, line );
947 }
948
949 switch( parseChar( aReader, line, &line ) )
950 {
951 case 'T': text->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break;
952 case 'C': text->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break;
953 case 'B': text->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break;
954 default: SCH_PARSE_ERROR( "invalid vertical text justication; expected T, C, or B",
955 aReader, line );
956 }
957 }
958 }
959
960 return text;
961}
Define a symbol library graphical text item.
Definition: lib_text.h:40
bool is_eol(char c)

References ConvertToNewOverbarNotation(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, is_eol(), LIB_VERSION, LINE_READER::Line(), EDA_IU_SCALE::MilsToIU(), parseChar(), parseInt(), parseQuotedString(), parseUnquotedString(), SCH_PARSE_ERROR, schIUScale, strCompare(), TENTHS_OF_A_DEGREE_T, text, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by loadDrawEntries().

◆ parseFillMode()

FILL_T SCH_LEGACY_PLUGIN_CACHE::parseFillMode ( LINE_READER aReader,
const char *  aLine,
const char **  aOutput 
)
staticprivate

Definition at line 733 of file sch_legacy_lib_plugin_cache.cpp.

735{
736 switch ( parseChar( aReader, aLine, aOutput ) )
737 {
738 case 'F': return FILL_T::FILLED_SHAPE;
739 case 'f': return FILL_T::FILLED_WITH_BG_BODYCOLOR;
740 case 'N': return FILL_T::NO_FILL;
741 default: SCH_PARSE_ERROR( "invalid fill type, expected f, F, or N", aReader, aLine );
742 }
743
744 // This will never be reached but quiets the compiler warnings
745 return FILL_T::NO_FILL;
746}
@ FILLED_WITH_BG_BODYCOLOR
@ FILLED_SHAPE

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

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

◆ removeSymbol()

LIB_SYMBOL * SCH_LIB_PLUGIN_CACHE::removeSymbol ( LIB_SYMBOL aAlias)
protectedinherited

Definition at line 94 of file sch_lib_plugin_cache.cpp.

95{
96 wxCHECK_MSG( aSymbol != nullptr, nullptr, "NULL pointer cannot be removed from library." );
97
98 LIB_SYMBOL* firstChild = nullptr;
99 LIB_SYMBOL_MAP::iterator it = m_symbols.find( aSymbol->GetName() );
100
101 if( it == m_symbols.end() )
102 return nullptr;
103
104 // If the entry pointer doesn't match the name it is mapped to in the library, we
105 // have done something terribly wrong.
106 wxCHECK_MSG( *it->second == aSymbol, nullptr,
107 "Pointer mismatch while attempting to remove alias entry <" + aSymbol->GetName() +
108 "> from library cache <" + m_libFileName.GetName() + ">." );
109
110 // If the symbol is a root symbol used by other symbols find the first alias that uses
111 // the root symbol and make it the new root.
112 if( aSymbol->IsRoot() )
113 {
114 for( const std::pair<const wxString, LIB_SYMBOL*>& entry : m_symbols )
115 {
116 if( entry.second->IsAlias()
117 && entry.second->GetParent().lock() == aSymbol->SharedPtr() )
118 {
119 firstChild = entry.second;
120 break;
121 }
122 }
123
124 if( firstChild )
125 {
126 for( LIB_ITEM& drawItem : aSymbol->GetDrawItems() )
127 {
128 if( drawItem.Type() == LIB_FIELD_T )
129 {
130 LIB_FIELD& field = static_cast<LIB_FIELD&>( drawItem );
131
132 if( firstChild->FindField( field.GetCanonicalName() ) )
133 continue;
134 }
135
136 LIB_ITEM* newItem = (LIB_ITEM*) drawItem.Clone();
137 drawItem.SetParent( firstChild );
138 firstChild->AddDrawItem( newItem );
139 }
140
141 // Reparent the remaining aliases.
142 for( const std::pair<const wxString, LIB_SYMBOL*>& entry : m_symbols )
143 {
144 if( entry.second->IsAlias()
145 && entry.second->GetParent().lock() == aSymbol->SharedPtr() )
146 {
147 entry.second->SetParent( firstChild );
148 }
149 }
150 }
151 }
152
153 m_symbols.erase( it );
154 delete aSymbol;
155 m_isModified = true;
157 return firstChild;
158}
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: lib_field.cpp:479
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Definition: lib_symbol.cpp:816
LIB_FIELD * FindField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName and returns it or NULL if not found.
@ LIB_FIELD_T
Definition: typeinfo.h:208

References LIB_SYMBOL::AddDrawItem(), EDA_ITEM::Clone(), LIB_SYMBOL::FindField(), LIB_FIELD::GetCanonicalName(), LIB_SYMBOL::GetDrawItems(), LIB_SYMBOL::GetName(), SCH_LIB_PLUGIN_CACHE::IncrementModifyHash(), LIB_SYMBOL::IsRoot(), LIB_FIELD_T, SCH_LIB_PLUGIN_CACHE::m_isModified, SCH_LIB_PLUGIN_CACHE::m_libFileName, SCH_LIB_PLUGIN_CACHE::m_symbols, EDA_ITEM::SetParent(), and LIB_SYMBOL::SharedPtr().

Referenced by SCH_LIB_PLUGIN_CACHE::AddSymbol().

◆ Save()

void SCH_LEGACY_PLUGIN_CACHE::Save ( const std::optional< bool > &  aOpt)
overridevirtual

Save the entire library to file m_libFileName;.

Reimplemented from SCH_LIB_PLUGIN_CACHE.

Definition at line 1327 of file sch_legacy_lib_plugin_cache.cpp.

1328{
1329 wxCHECK( aOpt, /* void */ );
1330
1331 bool doSaveDocFile = *aOpt;
1332
1333 if( !m_isModified )
1334 return;
1335
1336 // Write through symlinks, don't replace them
1337 wxFileName fn = GetRealFile();
1338
1339 auto formatter = std::make_unique<FILE_OUTPUTFORMATTER>( fn.GetFullPath() );
1340 formatter->Print( 0, "%s %d.%d\n", LIBFILE_IDENT, LIB_VERSION_MAJOR, LIB_VERSION_MINOR );
1341 formatter->Print( 0, "#encoding utf-8\n");
1342
1343 for( LIB_SYMBOL_MAP::iterator it = m_symbols.begin(); it != m_symbols.end(); it++ )
1344 {
1345 if( !it->second->IsRoot() )
1346 continue;
1347
1348 SaveSymbol( it->second, *formatter.get(), &m_symbols );
1349 }
1350
1351 formatter->Print( 0, "#\n#End Library\n" );
1352 formatter.reset();
1353
1354 m_fileModTime = fn.GetModificationTime();
1355 m_isModified = false;
1356
1357 if( doSaveDocFile )
1358 saveDocFile();
1359}
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, LIB_SYMBOL_MAP *aMap=nullptr)
#define LIB_VERSION_MINOR
Legacy symbol library minor version.
#define LIBFILE_IDENT
Legacy symbol library (.lib) file header.
#define LIB_VERSION_MAJOR
Legacy symbol library major version.

References SCH_LIB_PLUGIN_CACHE::GetRealFile(), LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIBFILE_IDENT, SCH_LIB_PLUGIN_CACHE::m_fileModTime, SCH_LIB_PLUGIN_CACHE::m_isModified, SCH_LIB_PLUGIN_CACHE::m_symbols, saveDocFile(), and SaveSymbol().

Referenced by SCH_LEGACY_PLUGIN::CreateSymbolLib(), SCH_LEGACY_PLUGIN::DeleteSymbol(), SCH_LEGACY_PLUGIN::SaveLibrary(), and SCH_LEGACY_PLUGIN::SaveSymbol().

◆ saveArc()

void SCH_LEGACY_PLUGIN_CACHE::saveArc ( LIB_SHAPE aArc,
OUTPUTFORMATTER aFormatter 
)
staticprivate

Definition at line 1515 of file sch_legacy_lib_plugin_cache.cpp.

1516{
1517 wxCHECK_RET( aArc && aArc->GetShape() == SHAPE_T::ARC, "Invalid ARC object." );
1518
1519 EDA_ANGLE startAngle, endAngle;
1520
1521 aArc->CalcArcAngles( startAngle, endAngle );
1522 startAngle.Normalize180();
1523 endAngle.Normalize180();
1524
1525 aFormatter.Print( 0, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n",
1526 schIUScale.IUToMils( aArc->GetPosition().x ),
1527 schIUScale.IUToMils( aArc->GetPosition().y ),
1528 schIUScale.IUToMils( aArc->GetRadius() ),
1529 startAngle.AsTenthsOfADegree(),
1530 endAngle.AsTenthsOfADegree(),
1531 aArc->GetUnit(),
1532 aArc->GetConvert(),
1533 schIUScale.IUToMils( aArc->GetWidth() ),
1534 fill_tab[ static_cast<int>( aArc->GetFillMode() ) - 1 ],
1535 schIUScale.IUToMils( aArc->GetStart().x ),
1536 schIUScale.IUToMils( aArc->GetStart().y ),
1537 schIUScale.IUToMils( aArc->GetEnd().x ),
1538 schIUScale.IUToMils( aArc->GetEnd().y ) );
1539}
int AsTenthsOfADegree() const
Definition: eda_angle.h:151
EDA_ANGLE Normalize180()
Definition: eda_angle.h:271
FILL_T GetFillMode() const
Definition: eda_shape.h:101
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
Definition: eda_shape.cpp:490
int GetRadius() const
Definition: eda_shape.cpp:511
SHAPE_T GetShape() const
Definition: eda_shape.h:113
int GetUnit() const
Definition: lib_item.h:273
int GetConvert() const
Definition: lib_item.h:276
VECTOR2I GetPosition() const override
Definition: lib_shape.h:85
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:431
const int fill_tab[3]
Definition: lib_item.cpp:35
constexpr int IUToMils(int iu) const
Definition: base_units.h:100

References ARC, EDA_ANGLE::AsTenthsOfADegree(), EDA_SHAPE::CalcArcAngles(), fill_tab, LIB_ITEM::GetConvert(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetFillMode(), LIB_SHAPE::GetPosition(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), LIB_ITEM::GetUnit(), EDA_SHAPE::GetWidth(), EDA_IU_SCALE::IUToMils(), EDA_ANGLE::Normalize180(), OUTPUTFORMATTER::Print(), schIUScale, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SaveSymbol().

◆ saveBezier()

void SCH_LEGACY_PLUGIN_CACHE::saveBezier ( LIB_SHAPE aBezier,
OUTPUTFORMATTER aFormatter 
)
staticprivate

Definition at line 1542 of file sch_legacy_lib_plugin_cache.cpp.

1543{
1544 wxCHECK_RET( aBezier && aBezier->GetShape() == SHAPE_T::BEZIER, "Invalid BEZIER object." );
1545
1546 aFormatter.Print( 0, "B 4 %d %d %d",
1547 aBezier->GetUnit(),
1548 aBezier->GetConvert(),
1549 schIUScale.IUToMils( aBezier->GetWidth() ) );
1550
1551 aFormatter.Print( 0, " %d %d %d %d %d %d %d %d",
1552 schIUScale.IUToMils( aBezier->GetStart().x ),
1553 schIUScale.IUToMils( aBezier->GetStart().y ),
1554 schIUScale.IUToMils( aBezier->GetBezierC1().x ),
1555 schIUScale.IUToMils( aBezier->GetBezierC1().y ),
1556 schIUScale.IUToMils( aBezier->GetBezierC2().x ),
1557 schIUScale.IUToMils( aBezier->GetBezierC2().y ),
1558 schIUScale.IUToMils( aBezier->GetEnd().x ),
1559 schIUScale.IUToMils( aBezier->GetEnd().y ) );
1560
1561 aFormatter.Print( 0, " %c\n", fill_tab[ static_cast<int>( aBezier->GetFillMode() ) - 1 ] );
1562}
const VECTOR2I & GetBezierC2() const
Definition: eda_shape.h:179
const VECTOR2I & GetBezierC1() const
Definition: eda_shape.h:176

References BEZIER, fill_tab, EDA_SHAPE::GetBezierC1(), EDA_SHAPE::GetBezierC2(), LIB_ITEM::GetConvert(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetFillMode(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), LIB_ITEM::GetUnit(), EDA_SHAPE::GetWidth(), EDA_IU_SCALE::IUToMils(), OUTPUTFORMATTER::Print(), schIUScale, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SaveSymbol().

◆ saveCircle()

void SCH_LEGACY_PLUGIN_CACHE::saveCircle ( LIB_SHAPE aCircle,
OUTPUTFORMATTER aFormatter 
)
staticprivate

Definition at line 1565 of file sch_legacy_lib_plugin_cache.cpp.

1566{
1567 wxCHECK_RET( aCircle && aCircle->GetShape() == SHAPE_T::CIRCLE, "Invalid CIRCLE object." );
1568
1569 aFormatter.Print( 0, "C %d %d %d %d %d %d %c\n",
1570 schIUScale.IUToMils( aCircle->GetPosition().x ),
1571 schIUScale.IUToMils( aCircle->GetPosition().y ),
1572 schIUScale.IUToMils( aCircle->GetRadius() ),
1573 aCircle->GetUnit(),
1574 aCircle->GetConvert(),
1575 schIUScale.IUToMils( aCircle->GetWidth() ),
1576 fill_tab[ static_cast<int>( aCircle->GetFillMode() ) - 1 ] );
1577}

References CIRCLE, fill_tab, LIB_ITEM::GetConvert(), EDA_SHAPE::GetFillMode(), LIB_SHAPE::GetPosition(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetShape(), LIB_ITEM::GetUnit(), EDA_SHAPE::GetWidth(), EDA_IU_SCALE::IUToMils(), OUTPUTFORMATTER::Print(), schIUScale, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SaveSymbol().

◆ saveDocFile()

void SCH_LEGACY_PLUGIN_CACHE::saveDocFile ( )
private

Definition at line 1769 of file sch_legacy_lib_plugin_cache.cpp.

1770{
1771 /*
1772 * NB:
1773 * Some of the rescue code still uses the legacy format as an intermediary, so we have
1774 * to keep this code.
1775 */
1776
1777 wxFileName fileName = m_libFileName;
1778
1779 fileName.SetExt( LegacySymbolDocumentFileExtension );
1780 FILE_OUTPUTFORMATTER formatter( fileName.GetFullPath() );
1781
1782 formatter.Print( 0, "%s\n", DOCFILE_IDENT );
1783
1784 for( LIB_SYMBOL_MAP::iterator it = m_symbols.begin(); it != m_symbols.end(); ++it )
1785 {
1786 wxString description = it->second->GetDescription();
1787 wxString keyWords = it->second->GetKeyWords();
1788 wxString docFileName = it->second->GetDatasheetField().GetText();
1789
1790 if( description.IsEmpty() && keyWords.IsEmpty() && docFileName.IsEmpty() )
1791 continue;
1792
1793 formatter.Print( 0, "#\n$CMP %s\n", TO_UTF8( it->second->GetName() ) );
1794
1795 if( !description.IsEmpty() )
1796 formatter.Print( 0, "D %s\n", TO_UTF8( description ) );
1797
1798 if( !keyWords.IsEmpty() )
1799 formatter.Print( 0, "K %s\n", TO_UTF8( keyWords ) );
1800
1801 if( !docFileName.IsEmpty() )
1802 formatter.Print( 0, "F %s\n", TO_UTF8( docFileName ) );
1803
1804 formatter.Print( 0, "$ENDCMP\n" );
1805 }
1806
1807 formatter.Print( 0, "#\n#End Doc Library\n" );
1808}
Used for text file output.
Definition: richio.h:457
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96

References DOCFILE_IDENT, LegacySymbolDocumentFileExtension, SCH_LIB_PLUGIN_CACHE::m_libFileName, SCH_LIB_PLUGIN_CACHE::m_symbols, OUTPUTFORMATTER::Print(), and TO_UTF8.

Referenced by Save().

◆ saveField()

void SCH_LEGACY_PLUGIN_CACHE::saveField ( const LIB_FIELD aField,
OUTPUTFORMATTER aFormatter 
)
staticprivate

Definition at line 1580 of file sch_legacy_lib_plugin_cache.cpp.

1581{
1582 wxCHECK_RET( aField && aField->Type() == LIB_FIELD_T, "Invalid LIB_FIELD object." );
1583
1584 int hjustify, vjustify;
1585 int id = aField->GetId();
1586 wxString text = aField->GetText();
1587
1588 hjustify = 'C';
1589
1590 if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
1591 hjustify = 'L';
1592 else if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
1593 hjustify = 'R';
1594
1595 vjustify = 'C';
1596
1597 if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
1598 vjustify = 'B';
1599 else if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
1600 vjustify = 'T';
1601
1602 aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c",
1603 id,
1604 EscapedUTF8( text ).c_str(), // wraps in quotes
1605 schIUScale.IUToMils( aField->GetTextPos().x ),
1606 schIUScale.IUToMils( aField->GetTextPos().y ),
1607 schIUScale.IUToMils( aField->GetTextWidth() ),
1608 aField->GetTextAngle().IsHorizontal() ? 'H' : 'V',
1609 aField->IsVisible() ? 'V' : 'I',
1610 hjustify, vjustify,
1611 aField->IsItalic() ? 'I' : 'N',
1612 aField->IsBold() ? 'B' : 'N' );
1613
1614 /* Save field name, if necessary
1615 * Field name is saved only if it is not the default name.
1616 * Just because default name depends on the language and can change from
1617 * a country to another
1618 */
1619 wxString defName = TEMPLATE_FIELDNAME::GetDefaultFieldName( id );
1620
1621 if( id >= MANDATORY_FIELDS && !aField->m_name.IsEmpty() && aField->m_name != defName )
1622 aFormatter.Print( 0, " %s", EscapedUTF8( aField->m_name ).c_str() );
1623
1624 aFormatter.Print( 0, "\n" );
1625}
bool IsHorizontal() const
Definition: eda_angle.h:174
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:208
bool IsItalic() const
Definition: eda_text.h:130
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
virtual bool IsVisible() const
Definition: eda_text.h:136
int GetTextWidth() const
Definition: eda_text.h:199
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:149
bool IsBold() const
Definition: eda_text.h:133
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:152
int GetId() const
Definition: lib_field.h:115
std::string EscapedUTF8(const wxString &aString)
Return an 8 bit UTF8 string given aString in Unicode form.

References EscapedUTF8(), TEMPLATE_FIELDNAME::GetDefaultFieldName(), EDA_TEXT::GetHorizJustify(), LIB_FIELD::GetId(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextWidth(), EDA_TEXT::GetVertJustify(), GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_TOP, EDA_TEXT::IsBold(), EDA_ANGLE::IsHorizontal(), EDA_TEXT::IsItalic(), EDA_TEXT::IsVisible(), EDA_IU_SCALE::IUToMils(), LIB_FIELD_T, LIB_FIELD::m_name, MANDATORY_FIELDS, OUTPUTFORMATTER::Print(), schIUScale, text, EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SaveSymbol().

◆ savePin()

void SCH_LEGACY_PLUGIN_CACHE::savePin ( const LIB_PIN aPin,
OUTPUTFORMATTER aFormatter 
)
staticprivate

Definition at line 1628 of file sch_legacy_lib_plugin_cache.cpp.

1629{
1630 wxCHECK_RET( aPin && aPin->Type() == LIB_PIN_T, "Invalid LIB_PIN object." );
1631
1632 int Etype;
1633
1634 switch( aPin->GetType() )
1635 {
1636 default:
1637 case ELECTRICAL_PINTYPE::PT_INPUT: Etype = 'I'; break;
1638 case ELECTRICAL_PINTYPE::PT_OUTPUT: Etype = 'O'; break;
1639 case ELECTRICAL_PINTYPE::PT_BIDI: Etype = 'B'; break;
1640 case ELECTRICAL_PINTYPE::PT_TRISTATE: Etype = 'T'; break;
1641 case ELECTRICAL_PINTYPE::PT_PASSIVE: Etype = 'P'; break;
1642 case ELECTRICAL_PINTYPE::PT_UNSPECIFIED: Etype = 'U'; break;
1643 case ELECTRICAL_PINTYPE::PT_POWER_IN: Etype = 'W'; break;
1644 case ELECTRICAL_PINTYPE::PT_POWER_OUT: Etype = 'w'; break;
1645 case ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR: Etype = 'C'; break;
1646 case ELECTRICAL_PINTYPE::PT_OPENEMITTER: Etype = 'E'; break;
1647 case ELECTRICAL_PINTYPE::PT_NC: Etype = 'N'; break;
1648 }
1649
1650 if( !aPin->GetName().IsEmpty() )
1651 aFormatter.Print( 0, "X %s", TO_UTF8( aPin->GetName() ) );
1652 else
1653 aFormatter.Print( 0, "X ~" );
1654
1655 aFormatter.Print( 0, " %s %d %d %d %c %d %d %d %d %c",
1656 aPin->GetNumber().IsEmpty() ? "~" : TO_UTF8( aPin->GetNumber() ),
1657 schIUScale.IUToMils( aPin->GetPosition().x ),
1658 schIUScale.IUToMils( aPin->GetPosition().y ),
1659 schIUScale.IUToMils( (int) aPin->GetLength() ),
1660 (int) aPin->GetOrientation(),
1663 aPin->GetUnit(),
1664 aPin->GetConvert(),
1665 Etype );
1666
1667 if( aPin->GetShape() != GRAPHIC_PINSHAPE::LINE || !aPin->IsVisible() )
1668 aFormatter.Print( 0, " " );
1669
1670 if( !aPin->IsVisible() )
1671 aFormatter.Print( 0, "N" );
1672
1673 switch( aPin->GetShape() )
1674 {
1675 case GRAPHIC_PINSHAPE::LINE: break;
1676 case GRAPHIC_PINSHAPE::INVERTED: aFormatter.Print( 0, "I" ); break;
1677 case GRAPHIC_PINSHAPE::CLOCK: aFormatter.Print( 0, "C" ); break;
1678 case GRAPHIC_PINSHAPE::INVERTED_CLOCK: aFormatter.Print( 0, "IC" ); break;
1679 case GRAPHIC_PINSHAPE::INPUT_LOW: aFormatter.Print( 0, "L" ); break;
1680 case GRAPHIC_PINSHAPE::CLOCK_LOW: aFormatter.Print( 0, "CL" ); break;
1681 case GRAPHIC_PINSHAPE::OUTPUT_LOW: aFormatter.Print( 0, "V" ); break;
1682 case GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK: aFormatter.Print( 0, "F" ); break;
1683 case GRAPHIC_PINSHAPE::NONLOGIC: aFormatter.Print( 0, "X" ); break;
1684 default: wxFAIL_MSG( "Invalid pin shape" );
1685 }
1686
1687 aFormatter.Print( 0, "\n" );
1688
1689 const_cast<LIB_PIN*>( aPin )->ClearFlags( IS_CHANGED );
1690}
int GetLength() const
Definition: lib_pin.h:80
ELECTRICAL_PINTYPE GetType() const
Definition: lib_pin.h:90
int GetOrientation() const
Definition: lib_pin.h:74
int GetNumberTextSize() const
Definition: lib_pin.h:135
VECTOR2I GetPosition() const override
Definition: lib_pin.h:222
const wxString & GetNumber() const
Definition: lib_pin.h:122
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:77
bool IsVisible() const
Definition: lib_pin.h:103
const wxString & GetName() const
Definition: lib_pin.h:112
int GetNameTextSize() const
Definition: lib_pin.h:132
#define IS_CHANGED
Item was edited, and modified.
@ LIB_PIN_T
Definition: typeinfo.h:202

References CLOCK, CLOCK_LOW, FALLING_EDGE_CLOCK, 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(), INPUT_LOW, INVERTED, INVERTED_CLOCK, IS_CHANGED, LIB_PIN::IsVisible(), EDA_IU_SCALE::IUToMils(), LIB_PIN_T, LINE, NONLOGIC, OUTPUT_LOW, OUTPUTFORMATTER::Print(), PT_BIDI, PT_INPUT, PT_NC, PT_OPENCOLLECTOR, PT_OPENEMITTER, PT_OUTPUT, PT_PASSIVE, PT_POWER_IN, PT_POWER_OUT, PT_TRISTATE, PT_UNSPECIFIED, schIUScale, TO_UTF8, EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SaveSymbol().

◆ savePolyLine()

void SCH_LEGACY_PLUGIN_CACHE::savePolyLine ( LIB_SHAPE aPolyLine,
OUTPUTFORMATTER aFormatter 
)
staticprivate

Definition at line 1693 of file sch_legacy_lib_plugin_cache.cpp.

1694{
1695 wxCHECK_RET( aPolyLine && aPolyLine->GetShape() == SHAPE_T::POLY, "Invalid POLY object." );
1696
1697 aFormatter.Print( 0, "P %d %d %d %d",
1698 (int) aPolyLine->GetPolyShape().Outline( 0 ).GetPointCount(),
1699 aPolyLine->GetUnit(),
1700 aPolyLine->GetConvert(),
1701 schIUScale.IUToMils( aPolyLine->GetWidth() ) );
1702
1703 for( const VECTOR2I& pt : aPolyLine->GetPolyShape().Outline( 0 ).CPoints() )
1704 aFormatter.Print( 0, " %d %d", schIUScale.IUToMils( pt.x ), schIUScale.IUToMils( pt.y ) );
1705
1706 aFormatter.Print( 0, " %c\n", fill_tab[ static_cast<int>( aPolyLine->GetFillMode() ) - 1 ] );
1707}
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:247
virtual size_t GetPointCount() const override
const std::vector< VECTOR2I > & CPoints() const
SHAPE_LINE_CHAIN & Outline(int aIndex)

References SHAPE_LINE_CHAIN::CPoints(), fill_tab, LIB_ITEM::GetConvert(), EDA_SHAPE::GetFillMode(), SHAPE_LINE_CHAIN::GetPointCount(), EDA_SHAPE::GetPolyShape(), EDA_SHAPE::GetShape(), LIB_ITEM::GetUnit(), EDA_SHAPE::GetWidth(), EDA_IU_SCALE::IUToMils(), SHAPE_POLY_SET::Outline(), POLY, OUTPUTFORMATTER::Print(), and schIUScale.

Referenced by SaveSymbol().

◆ saveRectangle()

void SCH_LEGACY_PLUGIN_CACHE::saveRectangle ( LIB_SHAPE aRectangle,
OUTPUTFORMATTER aFormatter 
)
staticprivate

Definition at line 1710 of file sch_legacy_lib_plugin_cache.cpp.

1711{
1712 wxCHECK_RET( aRectangle && aRectangle->GetShape() == SHAPE_T::RECT, "Invalid RECT object." );
1713
1714 aFormatter.Print( 0, "S %d %d %d %d %d %d %d %c\n",
1715 schIUScale.IUToMils( aRectangle->GetPosition().x ),
1716 schIUScale.IUToMils( aRectangle->GetPosition().y ),
1717 schIUScale.IUToMils( aRectangle->GetEnd().x ),
1718 schIUScale.IUToMils( aRectangle->GetEnd().y ),
1719 aRectangle->GetUnit(),
1720 aRectangle->GetConvert(),
1721 schIUScale.IUToMils( aRectangle->GetWidth() ),
1722 fill_tab[ static_cast<int>( aRectangle->GetFillMode() ) - 1 ] );
1723}

References fill_tab, LIB_ITEM::GetConvert(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetFillMode(), LIB_SHAPE::GetPosition(), EDA_SHAPE::GetShape(), LIB_ITEM::GetUnit(), EDA_SHAPE::GetWidth(), EDA_IU_SCALE::IUToMils(), OUTPUTFORMATTER::Print(), RECT, schIUScale, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SaveSymbol().

◆ SaveSymbol()

void SCH_LEGACY_PLUGIN_CACHE::SaveSymbol ( LIB_SYMBOL aSymbol,
OUTPUTFORMATTER aFormatter,
LIB_SYMBOL_MAP aMap = nullptr 
)
static

Definition at line 1362 of file sch_legacy_lib_plugin_cache.cpp.

1364{
1365 /*
1366 * NB:
1367 * Some of the rescue code still uses the legacy format as an intermediary, so we have
1368 * to keep this code.
1369 */
1370
1371 wxCHECK_RET( aSymbol && aSymbol->IsRoot(), "Invalid LIB_SYMBOL pointer." );
1372
1373 // LIB_ALIAS objects are deprecated but we still need to gather up the derived symbols
1374 // and save their names for the old file format.
1375 wxArrayString aliasNames;
1376
1377 if( aMap )
1378 {
1379 for( auto& entry : *aMap )
1380 {
1381 LIB_SYMBOL* symbol = entry.second;
1382
1383 if( symbol->IsAlias() && symbol->GetParent().lock() == aSymbol->SharedPtr() )
1384 aliasNames.Add( symbol->GetName() );
1385 }
1386 }
1387
1388 LIB_FIELD& value = aSymbol->GetValueField();
1389
1390 // First line: it s a comment (symbol name for readers)
1391 aFormatter.Print( 0, "#\n# %s\n#\n", TO_UTF8( value.GetText() ) );
1392
1393 // Save data
1394 aFormatter.Print( 0, "DEF" );
1395 aFormatter.Print( 0, " %s", TO_UTF8( value.GetText() ) );
1396
1397 LIB_FIELD& reference = aSymbol->GetReferenceField();
1398
1399 if( !reference.GetText().IsEmpty() )
1400 aFormatter.Print( 0, " %s", TO_UTF8( reference.GetText() ) );
1401 else
1402 aFormatter.Print( 0, " ~" );
1403
1404 aFormatter.Print( 0, " %d %d %c %c %d %c %c\n",
1405 0, schIUScale.IUToMils( aSymbol->GetPinNameOffset() ),
1406 aSymbol->ShowPinNumbers() ? 'Y' : 'N',
1407 aSymbol->ShowPinNames() ? 'Y' : 'N',
1408 aSymbol->GetUnitCount(), aSymbol->UnitsLocked() ? 'L' : 'F',
1409 aSymbol->IsPower() ? 'P' : 'N' );
1410
1411 timestamp_t dateModified = aSymbol->GetLastModDate();
1412
1413 if( dateModified != 0 )
1414 {
1415 int sec = dateModified & 63;
1416 int min = ( dateModified >> 6 ) & 63;
1417 int hour = ( dateModified >> 12 ) & 31;
1418 int day = ( dateModified >> 17 ) & 31;
1419 int mon = ( dateModified >> 22 ) & 15;
1420 int year = ( dateModified >> 26 ) + 1990;
1421
1422 aFormatter.Print( 0, "Ti %d/%d/%d %d:%d:%d\n", year, mon, day, hour, min, sec );
1423 }
1424
1425 std::vector<LIB_FIELD*> fields;
1426 aSymbol->GetFields( fields );
1427
1428 // Mandatory fields:
1429 // may have their own save policy so there is a separate loop for them.
1430 // Empty fields are saved, because the user may have set visibility,
1431 // size and orientation
1432 for( int i = 0; i < MANDATORY_FIELDS; ++i )
1433 saveField( fields[i], aFormatter );
1434
1435 // User defined fields:
1436 // may have their own save policy so there is a separate loop for them.
1437 int fieldId = MANDATORY_FIELDS; // really wish this would go away.
1438
1439 for( unsigned i = MANDATORY_FIELDS; i < fields.size(); ++i )
1440 {
1441 // There is no need to save empty fields, i.e. no reason to preserve field
1442 // names now that fields names come in dynamically through the template
1443 // fieldnames.
1444 if( !fields[i]->GetText().IsEmpty() )
1445 {
1446 fields[i]->SetId( fieldId++ );
1447 saveField( fields[i], aFormatter );
1448 }
1449 }
1450
1451 // Save the alias list: a line starting by "ALIAS".
1452 if( !aliasNames.IsEmpty() )
1453 {
1454 aFormatter.Print( 0, "ALIAS" );
1455
1456 for( unsigned i = 0; i < aliasNames.GetCount(); i++ )
1457 aFormatter.Print( 0, " %s", TO_UTF8( aliasNames[i] ) );
1458
1459 aFormatter.Print( 0, "\n" );
1460 }
1461
1462 wxArrayString footprints = aSymbol->GetFPFilters();
1463
1464 // Write the footprint filter list
1465 if( footprints.GetCount() != 0 )
1466 {
1467 aFormatter.Print( 0, "$FPLIST\n" );
1468
1469 for( unsigned i = 0; i < footprints.GetCount(); i++ )
1470 aFormatter.Print( 0, " %s\n", TO_UTF8( footprints[i] ) );
1471
1472 aFormatter.Print( 0, "$ENDFPLIST\n" );
1473 }
1474
1475 // Save graphics items (including pins)
1476 if( !aSymbol->GetDrawItems().empty() )
1477 {
1478 // Sort the draw items in order to editing a file editing by hand.
1479 aSymbol->GetDrawItems().sort();
1480
1481 aFormatter.Print( 0, "DRAW\n" );
1482
1483 for( LIB_ITEM& item : aSymbol->GetDrawItems() )
1484 {
1485 switch( item.Type() )
1486 {
1487 default:
1488 case LIB_FIELD_T: /* Fields have already been saved above. */ break;
1489 case LIB_PIN_T: savePin( (LIB_PIN* ) &item, aFormatter ); break;
1490 case LIB_TEXT_T: saveText( ( LIB_TEXT* ) &item, aFormatter ); break;
1491 case LIB_SHAPE_T:
1492 {
1493 LIB_SHAPE& shape = static_cast<LIB_SHAPE&>( item );
1494
1495 switch( shape.GetShape() )
1496 {
1497 case SHAPE_T::ARC: saveArc( &shape, aFormatter ); break;
1498 case SHAPE_T::BEZIER: saveBezier( &shape, aFormatter ); break;
1499 case SHAPE_T::CIRCLE: saveCircle( &shape, aFormatter ); break;
1500 case SHAPE_T::POLY: savePolyLine( &shape, aFormatter ); break;
1501 case SHAPE_T::RECT: saveRectangle( &shape, aFormatter ); break;
1502 default: break;
1503 }
1504 }
1505 }
1506 }
1507
1508 aFormatter.Print( 0, "ENDDRAW\n" );
1509 }
1510
1511 aFormatter.Print( 0, "ENDDEF\n" );
1512}
int GetPinNameOffset() const
Definition: lib_symbol.h:628
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
bool UnitsLocked() const
Check whether symbol units are interchangeable.
Definition: lib_symbol.h:253
timestamp_t GetLastModDate() const
Definition: lib_symbol.h:190
bool IsAlias() const
Definition: lib_symbol.h:183
bool IsPower() const
Definition: lib_symbol.cpp:552
bool ShowPinNames() const
Definition: lib_symbol.h:636
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:519
void GetFields(std::vector< LIB_FIELD * > &aList)
Return a list of fields within this symbol.
wxArrayString GetFPFilters() const
Definition: lib_symbol.h:194
LIB_FIELD & GetValueField()
Return reference to the value field.
int GetUnitCount() const override
For items with units, return the number of units.
LIB_SYMBOL_REF & GetParent()
Definition: lib_symbol.h:125
bool ShowPinNumbers() const
Definition: lib_symbol.h:644
void sort()
Definition: multivector.h:247
bool empty(int aType=UNDEFINED_TYPE) const
Definition: multivector.h:242
static void saveField(const LIB_FIELD *aField, OUTPUTFORMATTER &aFormatter)
static void savePin(const LIB_PIN *aPin, OUTPUTFORMATTER &aFormatter)
static void saveRectangle(LIB_SHAPE *aRectangle, OUTPUTFORMATTER &aFormatter)
static void saveBezier(LIB_SHAPE *aBezier, OUTPUTFORMATTER &aFormatter)
static void saveCircle(LIB_SHAPE *aCircle, OUTPUTFORMATTER &aFormatter)
static void saveText(const LIB_TEXT *aText, OUTPUTFORMATTER &aFormatter)
static void savePolyLine(LIB_SHAPE *aPolyLine, OUTPUTFORMATTER &aFormatter)
static void saveArc(LIB_SHAPE *aArc, OUTPUTFORMATTER &aFormatter)
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: kiid.h:45
wxString GetText(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
Definition: eda_units.cpp:98
@ LIB_TEXT_T
Definition: typeinfo.h:200
@ LIB_SHAPE_T
Definition: typeinfo.h:199

References ARC, BEZIER, CIRCLE, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::empty(), LIB_SYMBOL::GetDrawItems(), LIB_SYMBOL::GetFields(), LIB_SYMBOL::GetFPFilters(), LIB_SYMBOL::GetLastModDate(), LIB_SYMBOL::GetName(), LIB_SYMBOL::GetParent(), LIB_SYMBOL::GetPinNameOffset(), LIB_SYMBOL::GetReferenceField(), EDA_SHAPE::GetShape(), EDA_TEXT::GetText(), EDA_UNIT_UTILS::GetText(), LIB_SYMBOL::GetUnitCount(), LIB_SYMBOL::GetValueField(), LIB_SYMBOL::IsAlias(), LIB_SYMBOL::IsPower(), LIB_SYMBOL::IsRoot(), EDA_IU_SCALE::IUToMils(), LIB_FIELD_T, LIB_PIN_T, LIB_SHAPE_T, LIB_TEXT_T, MANDATORY_FIELDS, POLY, OUTPUTFORMATTER::Print(), RECT, saveArc(), saveBezier(), saveCircle(), saveField(), savePin(), savePolyLine(), saveRectangle(), saveText(), schIUScale, LIB_SYMBOL::SharedPtr(), LIB_SYMBOL::ShowPinNames(), LIB_SYMBOL::ShowPinNumbers(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::sort(), TO_UTF8, and LIB_SYMBOL::UnitsLocked().

Referenced by SCH_LEGACY_PLUGIN::FormatPart(), and Save().

◆ saveText()

void SCH_LEGACY_PLUGIN_CACHE::saveText ( const LIB_TEXT aText,
OUTPUTFORMATTER aFormatter 
)
staticprivate

Definition at line 1726 of file sch_legacy_lib_plugin_cache.cpp.

1727{
1728 wxCHECK_RET( aText && aText->Type() == LIB_TEXT_T, "Invalid LIB_TEXT object." );
1729
1730 wxString text = aText->GetText();
1731
1732 if( text.Contains( wxT( " " ) ) || text.Contains( wxT( "~" ) ) || text.Contains( wxT( "\"" ) ) )
1733 {
1734 // convert double quote to similar-looking two apostrophes
1735 text.Replace( wxT( "\"" ), wxT( "''" ) );
1736 text = wxT( "\"" ) + text + wxT( "\"" );
1737 }
1738
1739 aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s",
1740 (double) aText->GetTextAngle().AsTenthsOfADegree(),
1741 schIUScale.IUToMils( aText->GetTextPos().x ),
1742 schIUScale.IUToMils( aText->GetTextPos().y ),
1743 schIUScale.IUToMils( aText->GetTextWidth() ),
1744 !aText->IsVisible(),
1745 aText->GetUnit(),
1746 aText->GetConvert(),
1747 TO_UTF8( text ) );
1748
1749 aFormatter.Print( 0, " %s %d", aText->IsItalic() ? "Italic" : "Normal", aText->IsBold() );
1750
1751 char hjustify = 'C';
1752
1753 if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
1754 hjustify = 'L';
1755 else if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
1756 hjustify = 'R';
1757
1758 char vjustify = 'C';
1759
1760 if( aText->GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
1761 vjustify = 'B';
1762 else if( aText->GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
1763 vjustify = 'T';
1764
1765 aFormatter.Print( 0, " %c %c\n", hjustify, vjustify );
1766}

References EDA_ANGLE::AsTenthsOfADegree(), 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_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_TOP, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsVisible(), EDA_IU_SCALE::IUToMils(), LIB_TEXT_T, OUTPUTFORMATTER::Print(), schIUScale, text, TO_UTF8, EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SaveSymbol().

◆ SetFileName()

void SCH_LIB_PLUGIN_CACHE::SetFileName ( const wxString &  aFileName)
inlineinherited

◆ SetModified()

void SCH_LIB_PLUGIN_CACHE::SetModified ( bool  aModified = true)
inlineinherited

Member Data Documentation

◆ m_fileModTime

wxDateTime SCH_LIB_PLUGIN_CACHE::m_fileModTime
protectedinherited

◆ m_fileName

wxString SCH_LIB_PLUGIN_CACHE::m_fileName
protectedinherited

Definition at line 94 of file sch_lib_plugin_cache.h.

Referenced by SCH_LIB_PLUGIN_CACHE::IsFile().

◆ m_isModified

◆ m_isWritable

bool SCH_LIB_PLUGIN_CACHE::m_isWritable
protectedinherited

Definition at line 98 of file sch_lib_plugin_cache.h.

Referenced by SCH_LIB_PLUGIN_CACHE::GetLibModificationTime().

◆ m_libFileName

◆ m_libType

SCH_LIB_TYPE SCH_LIB_PLUGIN_CACHE::m_libType
protectedinherited

Definition at line 100 of file sch_lib_plugin_cache.h.

Referenced by Load(), and SCH_LIB_PLUGIN_CACHE::SCH_LIB_PLUGIN_CACHE().

◆ m_modHash

◆ m_modHashMutex

std::mutex SCH_LIB_PLUGIN_CACHE::m_modHashMutex
protectedinherited

◆ m_symbols

◆ m_versionMajor

int SCH_LEGACY_PLUGIN_CACHE::m_versionMajor
private

Definition at line 98 of file sch_legacy_lib_plugin_cache.h.

Referenced by Load(), and SCH_LEGACY_PLUGIN_CACHE().

◆ m_versionMinor

int SCH_LEGACY_PLUGIN_CACHE::m_versionMinor
private

Definition at line 99 of file sch_legacy_lib_plugin_cache.h.

Referenced by Load(), and SCH_LEGACY_PLUGIN_CACHE().

◆ SCH_LEGACY_PLUGIN

friend SCH_LEGACY_PLUGIN_CACHE::SCH_LEGACY_PLUGIN
private

Definition at line 66 of file sch_legacy_lib_plugin_cache.h.


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