37#define LIB_VERSION_MAJOR 2
38#define LIB_VERSION_MINOR 4
40#define LIB_VERSION( major, minor ) ( major * 100 + minor )
43#define LIBFILE_IDENT "EESchema-LIBRARY Version"
46#define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0"
54#define USE_OLD_DOC_FILE_FORMAT( major, minor ) \
55 ( LIB_VERSION( major, minor ) <= LIB_VERSION( 2, 4 ) )
86 const char* line = reader.
Line();
88 if( !
strCompare(
"EESchema-LIBRARY Version", line, &line ) )
92 if( !
strCompare(
"EESchema-LIB Version", line, &line ) )
93 SCH_PARSE_ERROR(
"file is not a valid symbol or symbol library file", reader, line );
99 SCH_PARSE_ERROR(
"invalid file version formatting in header", reader, line );
105 if(
m_versionMajor < 1 || m_versionMinor < 0 || m_versionMinor > 99 )
124 line = reader.
Line();
126 if( *line ==
'#' || isspace( *line ) )
165 if( !fn.FileExists() )
168 if( !fn.IsFileReadable() )
171 fn.GetFullPath() ) );
183 SCH_PARSE_ERROR(
"invalid document library file version formatting in header",
189 line = reader.
Line();
197 aliasName = wxString::FromUTF8( line );
200 LIB_SYMBOL_MAP::iterator it =
m_symbols.find( aliasName );
203 wxLogWarning(
"Symbol '%s' not found in library:\n\n"
204 "'%s'\n\nat line %d offset %d", aliasName, fn.GetFullPath(),
214 line = reader.
Line();
251 SCH_PARSE_ERROR(
"expected token in symbol definition", reader, line );
260 const char* line = aReader.
Line();
262 wxASSERT(
strCompare(
"$HEADER", line, &line ) );
266 line = (
char*) aReader;
272 else if(
strCompare(
"$ENDHEADER", line, &line ) )
283 const char* line = aReader.
Line();
285 while( *line ==
'#' )
293 wxString utf8Line = wxString::FromUTF8( line );
294 wxStringTokenizer tokens( utf8Line,
" \r\n\t" );
296 if( tokens.CountTokens() < 8 )
300 std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( wxEmptyString );
302 wxString
name, prefix, tmp;
304 name = tokens.GetNextToken();
311 pos +=
name.size() + 1;
313 prefix = tokens.GetNextToken();
314 pos += prefix.size() + 1;
316 tmp = tokens.GetNextToken();
317 pos += tmp.size() + 1;
319 tmp = tokens.GetNextToken();
321 if( !tmp.ToLong( &num ) )
327 pos += tmp.size() + 1;
330 tmp = tokens.GetNextToken();
332 if( !( tmp ==
"Y" || tmp ==
"N") )
336 pos += tmp.size() + 1;
337 symbol->SetShowPinNumbers( ( tmp ==
"N" ) ?
false :
true );
339 tmp = tokens.GetNextToken();
341 if( !( tmp ==
"Y" || tmp ==
"N") )
347 pos += tmp.size() + 1;
348 symbol->SetShowPinNames( ( tmp ==
"N" ) ?
false :
true );
350 tmp = tokens.GetNextToken();
352 if( !tmp.ToLong( &num ) )
358 pos += tmp.size() + 1;
359 symbol->SetUnitCount( (
int)num );
362 if( symbol->GetUnitCount() < 1 )
363 symbol->SetUnitCount( 1 );
370 symbol->SetName(
"~" );
372 else if(
name[0] !=
'~' )
374 symbol->SetName(
name );
378 symbol->SetName(
name.Right(
name.Length() - 1 ) );
379 symbol->GetValueField().SetVisible(
false );
383 symbol->SetLibId(
LIB_ID( wxEmptyString, symbol->GetName() ) );
385 LIB_FIELD& reference = symbol->GetReferenceField();
399 if(
LIB_VERSION( aMajorVersion, aMinorVersion ) > 0
404 tmp = tokens.GetNextToken();
405 pos += tmp.size() + 1;
409 tmp = tokens.GetNextToken();
412 symbol->LockUnits(
true );
413 else if( tmp ==
"F" || tmp ==
"0" )
414 symbol->LockUnits(
false );
419 pos += tmp.size() + 1;
423 if( tokens.HasMoreTokens() )
425 tmp = tokens.GetNextToken();
429 else if( tmp ==
"N" )
447 else if( *line ==
'F' )
451 else if(
strCompare(
"$FPLIST", line, &line ) )
453 else if(
strCompare(
"ENDDEF", line, &line ) )
455 return symbol.release();
469 wxString newAliasName;
470 const char* line = aReader.
Line();
472 wxCHECK_RET(
strCompare(
"ALIAS", line, &line ),
"Invalid ALIAS section" );
474 wxString utf8Line = wxString::FromUTF8( line );
475 wxStringTokenizer tokens( utf8Line,
" \r\n\t" );
478 while( tokens.HasMoreTokens() )
480 newAliasName = tokens.GetNextToken();
494 LIB_FIELD* parentField = aSymbol->GetFieldById(
id );
496 wxASSERT( parentField );
498 *field = *parentField;
501 field->
SetText( newAliasName );
509 (*aMap)[ newSymbol->
GetName() ] = newSymbol;
518 const char* line = aReader.
Line();
520 wxCHECK_RET( *line ==
'F',
"Invalid field line" );
525 if( sscanf( line + 1,
"%d", &
id ) != 1 ||
id < 0 )
532 field = aSymbol->GetFieldById(
id );
541 field =
new LIB_FIELD( aSymbol.get(),
id );
542 aSymbol->AddDrawItem( field,
false );
546 while( *line !=
'"' && *line != 0 )
561 if(
text.size() == 1 &&
text[0] ==
'~' )
562 field->
SetText( wxEmptyString );
577 char textOrient =
parseChar( aReader, line, &line );
579 if( textOrient ==
'H' )
581 else if( textOrient ==
'V' )
584 SCH_PARSE_ERROR(
"invalid field text orientation parameter", aReader, line );
586 char textVisible =
parseChar( aReader, line, &line );
588 if( textVisible ==
'V' )
590 else if ( textVisible ==
'I' )
593 SCH_PARSE_ERROR(
"invalid field text visibility parameter", aReader, line );
599 if( *line != 0 && *line !=
'"' )
601 char textHJustify =
parseChar( aReader, line, &line );
603 if( textHJustify ==
'C' )
605 else if( textHJustify ==
'L' )
607 else if( textHJustify ==
'R' )
610 SCH_PARSE_ERROR(
"invalid field text horizontal justification", aReader, line );
616 size_t attrSize = attributes.size();
618 if( !(attrSize == 3 || attrSize == 1 ) )
619 SCH_PARSE_ERROR(
"invalid field text attributes size", aReader, line );
621 switch( (wxChar) attributes[0] )
626 default:
SCH_PARSE_ERROR(
"invalid field text vertical justification", aReader, line );
631 wxChar attr_1 = attributes[1];
632 wxChar attr_2 = attributes[2];
636 else if( attr_1 !=
'N' )
637 SCH_PARSE_ERROR(
"invalid field text italic parameter", aReader, line );
641 else if( attr_2 !=
'N' )
657 field->
SetText( aSymbol->GetName() );
671 const char* line = aReader.
Line();
673 wxCHECK_RET(
strCompare(
"DRAW", line, &line ),
"Invalid DRAW section" );
681 aSymbol->GetDrawItems().sort();
688 aSymbol->AddDrawItem(
loadArc( aSymbol, aReader ),
false );
692 aSymbol->AddDrawItem(
loadCircle( aSymbol, aReader ),
false );
696 aSymbol->AddDrawItem(
loadText( aSymbol, aReader, aMajorVersion, aMinorVersion ),
701 aSymbol->AddDrawItem(
loadRect( aSymbol, aReader ),
false );
705 aSymbol->AddDrawItem(
loadPin( aSymbol, aReader ),
false );
709 aSymbol->AddDrawItem(
loadPolyLine( aSymbol, aReader ),
false );
713 aSymbol->AddDrawItem(
loadBezier( aSymbol, aReader ),
false );
729 SCH_PARSE_ERROR(
"File ended prematurely loading symbol draw element.", aReader, line );
734 const char** aOutput )
736 switch (
parseChar( aReader, aLine, aOutput ) )
741 default:
SCH_PARSE_ERROR(
"invalid fill type, expected f, F, or N", aReader, aLine );
752 const char* line = aReader.
Line();
754 wxCHECK_MSG(
strCompare(
"A", line, &line ),
nullptr,
"Invalid arc definition" );
836 const char* line = aReader.
Line();
838 wxCHECK_MSG(
strCompare(
"C", line, &line ),
nullptr,
"Invalid circle definition" );
870 const char* line = aReader.
Line();
872 wxCHECK_MSG(
strCompare(
"T", line, &line ),
nullptr,
"Invalid LIB_TEXT definition" );
875 double angleInTenths =
parseInt( aReader, line, &line );
883 text->SetPosition( center );
888 text->SetTextSize( size );
907 str.Replace(
"~",
" " );
913 str.Replace(
"''",
"\"" );
916 text->SetText( str );
925 if(
LIB_VERSION( aMajorVersion, aMinorVersion ) > 0
930 text->SetItalic(
true );
931 else if( !
strCompare(
"Normal", line, &line ) )
932 SCH_PARSE_ERROR(
"invalid text stype, expected 'Normal' or 'Italic'", aReader, line );
934 if(
parseInt( aReader, line, &line ) > 0 )
935 text->SetBold(
true );
940 switch(
parseChar( aReader, line, &line ) )
945 default:
SCH_PARSE_ERROR(
"invalid horizontal text justication; expected L, C, or R",
949 switch(
parseChar( aReader, line, &line ) )
954 default:
SCH_PARSE_ERROR(
"invalid vertical text justication; expected T, C, or B",
967 const char* line = aReader.
Line();
969 wxCHECK_MSG(
strCompare(
"S", line, &line ),
nullptr,
"Invalid rectangle definition" );
1003 const char* line = aReader.
Line();
1005 wxCHECK_MSG(
strCompare(
"X", line, &line ),
nullptr,
"Invalid LIB_PIN definition" );
1012 wxString utf8Line = wxString::FromUTF8( line );
1013 wxStringTokenizer tokens( utf8Line,
" \r\n\t" );
1015 if( tokens.CountTokens() < 11 )
1018 tmp = tokens.GetNextToken();
1020 pos += tmp.size() + 1;
1022 tmp = tokens.GetNextToken();
1024 pos += tmp.size() + 1;
1029 tmp = tokens.GetNextToken();
1031 if( !tmp.ToLong( &num ) )
1037 pos += tmp.size() + 1;
1040 tmp = tokens.GetNextToken();
1042 if( !tmp.ToLong( &num ) )
1048 pos += tmp.size() + 1;
1051 tmp = tokens.GetNextToken();
1053 if( !tmp.ToLong( &num ) )
1059 pos += tmp.size() + 1;
1063 tmp = tokens.GetNextToken();
1065 if( tmp.size() > 1 )
1071 pos += tmp.size() + 1;
1072 int orientation = tmp[0];
1074 tmp = tokens.GetNextToken();
1076 if( !tmp.ToLong( &num ) )
1082 pos += tmp.size() + 1;
1085 tmp = tokens.GetNextToken();
1087 if( !tmp.ToLong( &num ) )
1093 pos += tmp.size() + 1;
1096 tmp = tokens.GetNextToken();
1098 if( !tmp.ToLong( &num ) )
1104 pos += tmp.size() + 1;
1105 int unit = (int) num;
1107 tmp = tokens.GetNextToken();
1109 if( !tmp.ToLong( &num ) )
1115 pos += tmp.size() + 1;
1118 tmp = tokens.GetNextToken();
1120 if( tmp.size() != 1 )
1126 pos += tmp.size() + 1;
1162 if( tokens.HasMoreTokens() )
1164 tmp = tokens.GetNextToken();
1170 LOWLEVEL_IN = 1 << 2,
1171 LOWLEVEL_OUT = 1 << 3,
1172 FALLING_EDGE = 1 << 4,
1178 for(
int j = tmp.size(); j > 0; )
1180 switch( tmp[--j].GetValue() )
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;
1209 SCH_PARSE_ERROR(
"pin attributes do not define a valid pin shape", aReader, line );
1220 const char* line = aReader.
Line();
1222 wxCHECK_MSG(
strCompare(
"P", line, &line ),
nullptr,
"Invalid poly definition" );
1226 int points =
parseInt( aReader, line, &line );
1236 for(
int i = 0; i < points; i++ )
1253 const char* line = aReader.
Line();
1255 wxCHECK_MSG(
strCompare(
"B", line, &line ),
nullptr,
"Invalid Bezier definition" );
1257 int points =
parseInt( aReader, line, &line );
1259 wxCHECK_MSG( points == 4, NULL,
"Invalid Bezier curve definition" );
1300 const char* line = aReader.
Line();
1302 wxCHECK_RET(
strCompare(
"$FPLIST", line, &line ),
"Invalid footprint filter list" );
1306 wxArrayString footprintFilters;
1310 if(
strCompare(
"$ENDFPLIST", line, &line ) )
1312 aSymbol->SetFPFilters( footprintFilters );
1319 footprintFilters.Add( footprint );
1323 SCH_PARSE_ERROR(
"File ended prematurely while loading footprint filters.", aReader, line );
1331 bool doSaveDocFile = *aOpt;
1339 auto formatter = std::make_unique<FILE_OUTPUTFORMATTER>( fn.GetFullPath() );
1341 formatter->Print( 0,
"#encoding utf-8\n");
1345 if( !it->second->IsRoot() )
1351 formatter->Print( 0,
"#\n#End Library\n" );
1371 wxCHECK_RET( aSymbol && aSymbol->
IsRoot(),
"Invalid LIB_SYMBOL pointer." );
1375 wxArrayString aliasNames;
1379 for(
auto& entry : *aMap )
1384 aliasNames.Add( symbol->
GetName() );
1394 aFormatter.
Print( 0,
"DEF" );
1399 if( !reference.
GetText().IsEmpty() )
1402 aFormatter.
Print( 0,
" ~" );
1404 aFormatter.
Print( 0,
" %d %d %c %c %d %c %c\n",
1409 aSymbol->
IsPower() ?
'P' :
'N' );
1413 if( dateModified != 0 )
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;
1422 aFormatter.
Print( 0,
"Ti %d/%d/%d %d:%d:%d\n", year, mon, day, hour, min, sec );
1425 std::vector<LIB_FIELD*> fields;
1444 if( !fields[i]->
GetText().IsEmpty() )
1446 fields[i]->SetId( fieldId++ );
1452 if( !aliasNames.IsEmpty() )
1454 aFormatter.
Print( 0,
"ALIAS" );
1456 for(
unsigned i = 0; i < aliasNames.GetCount(); i++ )
1457 aFormatter.
Print( 0,
" %s",
TO_UTF8( aliasNames[i] ) );
1459 aFormatter.
Print( 0,
"\n" );
1465 if( footprints.GetCount() != 0 )
1467 aFormatter.
Print( 0,
"$FPLIST\n" );
1469 for(
unsigned i = 0; i < footprints.GetCount(); i++ )
1470 aFormatter.
Print( 0,
" %s\n",
TO_UTF8( footprints[i] ) );
1472 aFormatter.
Print( 0,
"$ENDFPLIST\n" );
1481 aFormatter.
Print( 0,
"DRAW\n" );
1485 switch( item.Type() )
1508 aFormatter.
Print( 0,
"ENDDRAW\n" );
1511 aFormatter.
Print( 0,
"ENDDEF\n" );
1525 aFormatter.
Print( 0,
"A %d %d %d %d %d %d %d %d %c %d %d %d %d\n",
1546 aFormatter.
Print( 0,
"B 4 %d %d %d",
1551 aFormatter.
Print( 0,
" %d %d %d %d %d %d %d %d",
1569 aFormatter.
Print( 0,
"C %d %d %d %d %d %d %c\n",
1582 wxCHECK_RET( aField && aField->
Type() ==
LIB_FIELD_T,
"Invalid LIB_FIELD object." );
1584 int hjustify, vjustify;
1585 int id = aField->
GetId();
1602 aFormatter.
Print( 0,
"F%d %s %d %d %d %c %c %c %c%c%c",
1612 aField->
IsBold() ?
'B' :
'N' );
1624 aFormatter.
Print( 0,
"\n" );
1630 wxCHECK_RET( aPin && aPin->
Type() ==
LIB_PIN_T,
"Invalid LIB_PIN object." );
1650 if( !aPin->
GetName().IsEmpty() )
1653 aFormatter.
Print( 0,
"X ~" );
1655 aFormatter.
Print( 0,
" %s %d %d %d %c %d %d %d %d %c",
1668 aFormatter.
Print( 0,
" " );
1671 aFormatter.
Print( 0,
"N" );
1684 default: wxFAIL_MSG(
"Invalid pin shape" );
1687 aFormatter.
Print( 0,
"\n" );
1697 aFormatter.
Print( 0,
"P %d %d %d %d",
1714 aFormatter.
Print( 0,
"S %d %d %d %d %d %d %d %c\n",
1728 wxCHECK_RET( aText && aText->
Type() ==
LIB_TEXT_T,
"Invalid LIB_TEXT object." );
1732 if(
text.Contains( wxT(
" " ) ) ||
text.Contains( wxT(
"~" ) ) ||
text.Contains( wxT(
"\"" ) ) )
1735 text.Replace( wxT(
"\"" ), wxT(
"''" ) );
1736 text = wxT(
"\"" ) +
text + wxT(
"\"" );
1739 aFormatter.
Print( 0,
"T %g %d %d %d %d %d %d %s",
1749 aFormatter.
Print( 0,
" %s %d", aText->
IsItalic() ?
"Italic" :
"Normal", aText->
IsBold() );
1751 char hjustify =
'C';
1758 char vjustify =
'C';
1765 aFormatter.
Print( 0,
" %c %c\n", hjustify, vjustify );
1786 wxString description = it->second->GetDescription();
1787 wxString keyWords = it->second->GetKeyWords();
1788 wxString docFileName = it->second->GetDatasheetField().GetText();
1790 if( description.IsEmpty() && keyWords.IsEmpty() && docFileName.IsEmpty() )
1793 formatter.
Print( 0,
"#\n$CMP %s\n",
TO_UTF8( it->second->GetName() ) );
1795 if( !description.IsEmpty() )
1796 formatter.
Print( 0,
"D %s\n",
TO_UTF8( description ) );
1798 if( !keyWords.IsEmpty() )
1801 if( !docFileName.IsEmpty() )
1802 formatter.
Print( 0,
"F %s\n",
TO_UTF8( docFileName ) );
1804 formatter.
Print( 0,
"$ENDCMP\n" );
1807 formatter.
Print( 0,
"#\n#End Doc Library\n" );
1813 LIB_SYMBOL_MAP::iterator it =
m_symbols.find( aSymbolName );
1828 LIB_SYMBOL_MAP::iterator it1 =
m_symbols.begin();
1832 if( it1->second->IsAlias()
1833 && it1->second->GetParent().lock() == rootSymbol->
SharedPtr() )
constexpr EDA_IU_SCALE schIUScale
int AsTenthsOfADegree() const
bool IsHorizontal() const
KICAD_T Type() const
Returns the type of object.
virtual void SetParent(EDA_ITEM *aParent)
EDA_ANGLE GetArcAngle() const
const VECTOR2I & GetBezierC2() const
void SetBezierC2(const VECTOR2I &aPt)
void SetCenter(const VECTOR2I &aCenter)
FILL_T GetFillMode() const
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
SHAPE_POLY_SET & GetPolyShape()
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetEnd(const VECTOR2I &aEnd)
void SetBezierC1(const VECTOR2I &aPt)
const VECTOR2I & GetBezierC1() const
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
void SetFillMode(FILL_T aFill)
const VECTOR2I & GetTextPos() const
const EDA_ANGLE & GetTextAngle() const
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual bool IsVisible() const
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
GR_TEXT_H_ALIGN_T GetHorizJustify() const
virtual void SetVisible(bool aVisible)
GR_TEXT_V_ALIGN_T GetVertJustify() const
void SetTextSize(const VECTOR2I &aNewSize)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetItalic(bool aItalic)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
A LINE_READER that reads from an open file.
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
Field object used in symbol libraries.
wxString m_name
Name (not the field text value itself, that is #EDA_TEXT::m_Text)
A logical library item identifier and consists of various portions much like a URI.
The base class for drawable items used by schematic library symbols.
void SetPosition(const VECTOR2I &aPosition) override
void SetConvert(int aConvert)
ELECTRICAL_PINTYPE GetType() const
int GetOrientation() const
int GetNumberTextSize() const
VECTOR2I GetPosition() const override
const wxString & GetNumber() const
GRAPHIC_PINSHAPE GetShape() const
const wxString & GetName() const
int GetNameTextSize() const
void SetStroke(const STROKE_PARAMS &aStroke)
void AddPoint(const VECTOR2I &aPosition)
void SetPosition(const VECTOR2I &aPosition) override
VECTOR2I GetPosition() const override
Define a library symbol object.
int GetPinNameOffset() const
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
bool UnitsLocked() const
Check whether symbol units are interchangeable.
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
timestamp_t GetLastModDate() const
bool ShowPinNames() const
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
void SetParent(LIB_SYMBOL *aParent=nullptr)
wxString GetName() const override
void SetDescription(const wxString &aDescription)
void SetKeyWords(const wxString &aKeyWords)
void GetFields(std::vector< LIB_FIELD * > &aList)
Return a list of fields within this symbol.
wxArrayString GetFPFilters() const
LIB_FIELD & GetValueField()
Return reference to the value field.
LIB_SYMBOL_SPTR SharedPtr() const
int GetUnitCount() const override
For items with units, return the number of units.
LIB_SYMBOL_REF & GetParent()
bool ShowPinNumbers() const
Define a symbol library graphical text item.
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
virtual char * ReadLine()=0
Read a line of text into the buffer and increments the line number counter.
virtual const wxString & GetSource() const
Returns the name of the source of the lines in an abstract sense.
virtual unsigned LineNumber() const
Return the line number of the last line read from this LINE_READER.
char * Line() const
Return a pointer to the last line that was read in.
bool empty(int aType=UNDEFINED_TYPE) const
SCH_LEGACY_PLUGIN_CACHE(const wxString &aLibraryPath)
static void saveField(const LIB_FIELD *aField, OUTPUTFORMATTER &aFormatter)
static void loadField(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
void Save(const std::optional< bool > &aOpt) override
Save the entire library to file m_libFileName;.
static LIB_SHAPE * loadCircle(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
void DeleteSymbol(const wxString &aName) override
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 FILL_T parseFillMode(LINE_READER &aReader, const char *aLine, const char **aOutput)
static void savePin(const LIB_PIN *aPin, OUTPUTFORMATTER &aFormatter)
static LIB_TEXT * loadText(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, int aMajorVersion, int aMinorVersion)
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 loadFootprintFilters(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
void loadHeader(FILE_LINE_READER &aReader)
static void saveText(const LIB_TEXT *aText, OUTPUTFORMATTER &aFormatter)
static LIB_SHAPE * loadRect(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, LIB_SYMBOL_MAP *aMap=nullptr)
static void savePolyLine(LIB_SHAPE *aPolyLine, OUTPUTFORMATTER &aFormatter)
static void loadDrawEntries(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, int aMajorVersion, int aMinorVersion)
static LIB_PIN * loadPin(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static void loadAliases(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, LIB_SYMBOL_MAP *aMap=nullptr)
static LIB_SHAPE * loadArc(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static void saveArc(LIB_SHAPE *aArc, OUTPUTFORMATTER &aFormatter)
static LIB_SYMBOL * LoadPart(LINE_READER &aReader, int aMajorVersion, int aMinorVersion, LIB_SYMBOL_MAP *aMap=nullptr)
A base cache assistant implementation for the symbol library portion of the SCH_PLUGIN API.
wxFileName GetRealFile() const
void IncrementModifyHash()
wxDateTime GetLibModificationTime()
virtual size_t GetPointCount() const override
const std::vector< VECTOR2I > & CPoints() const
SHAPE_LINE_CHAIN & Outline(int aIndex)
Simple container to manage line stroke parameters.
static constexpr EDA_ANGLE & ANGLE_180
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
static constexpr EDA_ANGLE & ANGLE_VERTICAL
#define IS_CHANGED
Item was edited, and modified.
@ FILLED_WITH_BG_BODYCOLOR
const std::string LegacySymbolDocumentFileExtension
const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
std::chrono::steady_clock CLOCK
#define THROW_IO_ERROR(msg)
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
wxString GetText(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
@ PT_INPUT
usual pin input: must be connected
@ PT_NC
not connected (must be left open)
@ 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
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
#define LIB_VERSION_MINOR
Legacy symbol library minor version.
#define LIBFILE_IDENT
Legacy symbol library (.lib) file header.
#define USE_OLD_DOC_FILE_FORMAT(major, minor)
Library versions 2.4 and lower use the old separate library (.lib) and document (....
#define LIB_VERSION(major, minor)
#define DOCFILE_IDENT
Legacy symbol library document (.dcm) file header.
#define LIB_VERSION_MAJOR
Legacy symbol library major version.
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...
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.
#define SCH_PARSE_ERROR(text, reader, pos)
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
wxString UnescapeString(const wxString &aSource)
std::string EscapedUTF8(const wxString &aString)
Return an 8 bit UTF8 string given aString in Unicode form.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
constexpr int IUToMils(int iu) const
constexpr int MilsToIU(int mils) const
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP
@ DATASHEET_FIELD
name of datasheet
@ 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.
wxLogTrace helper definitions.
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 of file extensions used in Kicad.