KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_io_kicad_sexpr_lib_cache.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * @author Wayne Stambaugh <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <wx/log.h>
23#include <base_units.h>
24#include <build_version.h>
25#include <sch_shape.h>
26#include <lib_symbol.h>
27#include <sch_textbox.h>
28#include <locale_io.h>
29#include <macros.h>
30#include <richio.h>
34#include <string_utils.h>
35#include <trace_helpers.h>
37
38
39SCH_IO_KICAD_SEXPR_LIB_CACHE::SCH_IO_KICAD_SEXPR_LIB_CACHE( const wxString& aFullPathAndFileName ) :
40 SCH_IO_LIB_CACHE( aFullPathAndFileName )
41{
43}
44
45
47{
48}
49
50
52{
53 if( !m_libFileName.FileExists() )
54 {
55 THROW_IO_ERROR( wxString::Format( _( "Library file '%s' not found." ),
56 m_libFileName.GetFullPath() ) );
57 }
58
59 wxCHECK_RET( m_libFileName.IsAbsolute(),
60 wxString::Format( "Cannot use relative file paths in sexpr plugin to "
61 "open library '%s'.", m_libFileName.GetFullPath() ) );
62
63 // The current locale must use period as the decimal point.
64 // Yes, we did this earlier, but it's sadly not thread-safe.
65 LOCALE_IO toggle;
66
67 wxLogTrace( traceSchLegacyPlugin, "Loading sexpr symbol library file '%s'",
68 m_libFileName.GetFullPath() );
69
70 FILE_LINE_READER reader( m_libFileName.GetFullPath() );
71
72 SCH_IO_KICAD_SEXPR_PARSER parser( &reader );
73
74 parser.ParseLib( m_symbols );
76
77 // Remember the file modification time of library file when the cache snapshot was made,
78 // so that in a networked environment we will reload the cache as needed.
81}
82
83
84void SCH_IO_KICAD_SEXPR_LIB_CACHE::Save( const std::optional<bool>& aOpt )
85{
86 if( !m_isModified )
87 return;
88
89 LOCALE_IO toggle; // toggles on, then off, the C locale.
90
91 // Write through symlinks, don't replace them.
92 wxFileName fn = GetRealFile();
93
94 auto formatter = std::make_unique<PRETTIFIED_FILE_OUTPUTFORMATTER>( fn.GetFullPath() );
95
96 formatter->Print( "(kicad_symbol_lib (version %d) (generator \"kicad_symbol_editor\") "
97 "(generator_version \"%s\")",
99 GetMajorMinorVersion().c_str().AsChar() );
100
101 std::vector<LIB_SYMBOL*> orderedSymbols;
102
103 for( const auto& [ name, symbol ] : m_symbols )
104 {
105 if( symbol )
106 orderedSymbols.push_back( symbol );
107 }
108
109 // Library must be ordered by inheritance depth.
110 std::sort( orderedSymbols.begin(), orderedSymbols.end(),
111 []( const LIB_SYMBOL* aLhs, const LIB_SYMBOL* aRhs )
112 {
113 unsigned int lhDepth = aLhs->GetInheritanceDepth();
114 unsigned int rhDepth = aRhs->GetInheritanceDepth();
115
116 if( lhDepth == rhDepth )
117 return aLhs->GetName() < aRhs->GetName();
118
119 return lhDepth < rhDepth;
120 } );
121
122 for( LIB_SYMBOL* symbol : orderedSymbols )
123 SaveSymbol( symbol, *formatter.get() );
124
125 formatter->Print( ")" );
126
127 formatter.reset();
128
129 m_fileModTime = fn.GetModificationTime();
130 m_isModified = false;
131}
132
133
135 const wxString& aLibName, bool aIncludeData )
136{
137 wxCHECK_RET( aSymbol, "Invalid LIB_SYMBOL pointer." );
138
139 // The current locale must use period as the decimal point.
140 wxCHECK2( wxLocale::GetInfo( wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER ) == ".",
141 LOCALE_IO toggle );
142
143
144 // If we've requested to embed the fonts in the symbol, do so.
145 // Otherwise, clear the embedded fonts from the symbol. Embedded
146 // fonts will be used if available
147 if( aSymbol->GetAreFontsEmbedded() )
148 aSymbol->EmbedFonts();
149 else
151
152 std::vector<SCH_FIELD*> orderedFields;
153 std::string name = aFormatter.Quotew( aSymbol->GetLibId().GetLibItemName().wx_str() );
154 std::string unitName = aSymbol->GetLibId().GetLibItemName();
155
156 if( !aLibName.IsEmpty() )
157 {
158 name = aFormatter.Quotew( aLibName );
159
160 LIB_ID unitId;
161
162 wxCHECK2( unitId.Parse( aLibName ) < 0, /* do nothing */ );
163
164 unitName = unitId.GetLibItemName();
165 }
166
167 if( aSymbol->IsRoot() )
168 {
169 aFormatter.Print( "(symbol %s", name.c_str() );
170
171 if( aSymbol->IsGlobalPower() )
172 aFormatter.Print( "(power global)" );
173 else if( aSymbol->IsLocalPower() )
174 aFormatter.Print( "(power local)" );
175
176 // TODO: add uuid token here.
177
178 // TODO: add anchor position token here.
179
180 if( !aSymbol->GetShowPinNumbers() )
181 aFormatter.Print( "(pin_numbers (hide yes))" );
182
184 || !aSymbol->GetShowPinNames() )
185 {
186 aFormatter.Print( "(pin_names" );
187
189 {
190 aFormatter.Print( "(offset %s)",
192 aSymbol->GetPinNameOffset() ).c_str() );
193 }
194
195 if( !aSymbol->GetShowPinNames() )
196 KICAD_FORMAT::FormatBool( &aFormatter, "hide", true );
197
198 aFormatter.Print( ")" );
199 }
200
201 KICAD_FORMAT::FormatBool( &aFormatter, "exclude_from_sim", aSymbol->GetExcludedFromSim() );
202 KICAD_FORMAT::FormatBool( &aFormatter, "in_bom", !aSymbol->GetExcludedFromBOM() );
203 KICAD_FORMAT::FormatBool( &aFormatter, "on_board", !aSymbol->GetExcludedFromBoard() );
204
205 // TODO: add atomic token here.
206
207 // TODO: add required token here."
208
209 aSymbol->GetFields( orderedFields );
210
211 for( SCH_FIELD* field : orderedFields )
212 saveField( field, aFormatter );
213
214 // @todo At some point in the future the lock status (all units interchangeable) should
215 // be set deterministically. For now a custom lock property is used to preserve the
216 // locked flag state.
217 if( aSymbol->UnitsLocked() )
218 {
219 SCH_FIELD locked( nullptr, FIELD_T::USER, "ki_locked" );
220 saveField( &locked, aFormatter );
221 }
222
223 saveDcmInfoAsFields( aSymbol, aFormatter );
224
225 // Save the draw items grouped by units.
226 std::vector<LIB_SYMBOL_UNIT> units = aSymbol->GetUnitDrawItems();
227 std::sort( units.begin(), units.end(),
228 []( const LIB_SYMBOL_UNIT& a, const LIB_SYMBOL_UNIT& b )
229 {
230 if( a.m_unit == b.m_unit )
231 return a.m_bodyStyle < b.m_bodyStyle;
232
233 return a.m_unit < b.m_unit;
234 } );
235
236 for( const LIB_SYMBOL_UNIT& unit : units )
237 {
238 // Add quotes and escape chars like ") to the UTF8 unitName string
239 name = aFormatter.Quotes( unitName );
240 name.pop_back(); // Remove last char: the quote ending the string.
241
242 aFormatter.Print( "(symbol %s_%d_%d\"",
243 name.c_str(),
244 unit.m_unit,
245 unit.m_bodyStyle );
246
247 // if the unit has a display name, write that
248 if( aSymbol->HasUnitDisplayName( unit.m_unit ) )
249 {
250 name = aSymbol->GetUnitDisplayName( unit.m_unit );
251 aFormatter.Print( "(unit_name %s)", aFormatter.Quotes( name ).c_str() );
252 }
253
254 // Enforce item ordering
255 auto cmp =
256 []( const SCH_ITEM* a, const SCH_ITEM* b )
257 {
258 return *a < *b;
259 };
260
261 std::multiset<SCH_ITEM*, decltype( cmp )> save_map( cmp );
262
263 for( SCH_ITEM* item : unit.m_items )
264 save_map.insert( item );
265
266 for( SCH_ITEM* item : save_map )
267 saveSymbolDrawItem( item, aFormatter );
268
269 aFormatter.Print( ")" );
270 }
271
272 KICAD_FORMAT::FormatBool( &aFormatter, "embedded_fonts", aSymbol->GetAreFontsEmbedded() );
273
274 if( !aSymbol->EmbeddedFileMap().empty() )
275 aSymbol->WriteEmbeddedFiles( aFormatter, aIncludeData );
276 }
277 else
278 {
279 std::shared_ptr<LIB_SYMBOL> parent = aSymbol->GetParent().lock();
280
281 wxASSERT( parent );
282
283 aFormatter.Print( "(symbol %s (extends %s)",
284 name.c_str(),
285 aFormatter.Quotew( parent->GetName() ).c_str() );
286
287 aSymbol->GetFields( orderedFields );
288
289 for( SCH_FIELD* field : orderedFields )
290 saveField( field, aFormatter );
291
292 saveDcmInfoAsFields( aSymbol, aFormatter );
293 }
294
295 aFormatter.Print( ")" );
296}
297
298
300 OUTPUTFORMATTER& aFormatter )
301{
302 wxCHECK_RET( aSymbol, "Invalid LIB_SYMBOL pointer." );
303
304 if( !aSymbol->GetKeyWords().IsEmpty() )
305 {
306 SCH_FIELD keywords( nullptr, FIELD_T::USER, wxString( "ki_keywords" ) );
307 keywords.SetVisible( false );
308 keywords.SetText( aSymbol->GetKeyWords() );
309 saveField( &keywords, aFormatter );
310 }
311
312 wxArrayString fpFilters = aSymbol->GetFPFilters();
313
314 if( !fpFilters.IsEmpty() )
315 {
316 wxString tmp;
317
318 for( const wxString& filter : fpFilters )
319 {
320 // Spaces are not handled in fp filter names so escape spaces if any
321 wxString curr_filter = EscapeString( filter, ESCAPE_CONTEXT::CTX_NO_SPACE );
322
323 if( tmp.IsEmpty() )
324 tmp = curr_filter;
325 else
326 tmp += " " + curr_filter;
327 }
328
329 SCH_FIELD description( nullptr, FIELD_T::USER, wxString( "ki_fp_filters" ) );
330 description.SetVisible( false );
331 description.SetText( tmp );
332 saveField( &description, aFormatter );
333 }
334}
335
336
338{
339 wxCHECK_RET( aItem, "Invalid SCH_ITEM pointer." );
340
341 switch( aItem->Type() )
342 {
343 case SCH_SHAPE_T:
344 {
345 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem );
346 STROKE_PARAMS stroke = shape->GetStroke();
347 FILL_T fillMode = shape->GetFillMode();
348 COLOR4D fillColor = shape->GetFillColor();
349 bool isPrivate = shape->IsPrivate();
350
351 switch( shape->GetShape() )
352 {
353 case SHAPE_T::ARC:
354 formatArc( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
355 break;
356
357 case SHAPE_T::CIRCLE:
358 formatCircle( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
359 break;
360
361 case SHAPE_T::RECTANGLE:
362 formatRect( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
363 break;
364
365 case SHAPE_T::BEZIER:
366 formatBezier(&aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
367 break;
368
369 case SHAPE_T::POLY:
370 formatPoly( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
371 break;
372
373 default:
375 }
376
377 break;
378 }
379
380 case SCH_PIN_T:
381 savePin( static_cast<SCH_PIN*>( aItem ), aFormatter );
382 break;
383
384 case SCH_TEXT_T:
385 saveText( static_cast<SCH_TEXT*>( aItem ), aFormatter );
386 break;
387
388 case SCH_TEXTBOX_T:
389 saveTextBox( static_cast<SCH_TEXTBOX*>( aItem ), aFormatter );
390 break;
391
392 default:
393 UNIMPLEMENTED_FOR( aItem->GetClass() );
394 }
395}
396
397
399{
400 wxCHECK_RET( aField && aField->Type() == SCH_FIELD_T, "Invalid SCH_FIELD object." );
401
402 wxString fieldName = aField->GetName();
403
404 if( aField->IsMandatory() )
405 fieldName = GetCanonicalFieldName( aField->GetId() );
406
407 aFormatter.Print( "(property %s %s %s (at %s %s %g)",
408 aField->IsPrivate() ? "private" : "",
409 aFormatter.Quotew( fieldName ).c_str(),
410 aFormatter.Quotew( aField->GetText() ).c_str(),
412 aField->GetPosition().x ).c_str(),
414 -aField->GetPosition().y ).c_str(),
415 aField->GetTextAngle().AsDegrees() );
416
417 if( aField->IsNameShown() )
418 aFormatter.Print( "(show_name)" );
419
420 if( !aField->CanAutoplace() )
421 aFormatter.Print( "(do_not_autoplace)" );
422
423 if( !aField->IsVisible() )
424 KICAD_FORMAT::FormatBool( &aFormatter, "hide", true );
425
426 aField->Format( &aFormatter, 0 );
427 aFormatter.Print( ")" );
428}
429
430
432{
433 wxCHECK_RET( aPin && aPin->Type() == SCH_PIN_T, "Invalid SCH_PIN object." );
434
435 aPin->ClearFlags( IS_CHANGED );
436
437 aFormatter.Print( "(pin %s %s (at %s %s %s) (length %s)",
439 getPinShapeToken( aPin->GetShape() ),
441 aPin->GetPosition().x ).c_str(),
443 -aPin->GetPosition().y ).c_str(),
446 aPin->GetLength() ).c_str() );
447
448 if( !aPin->IsVisible() )
449 KICAD_FORMAT::FormatBool( &aFormatter, "hide", true );
450
451 // This follows the EDA_TEXT effects formatting for future expansion.
452 aFormatter.Print( "(name %s (effects (font (size %s %s))))",
453 aFormatter.Quotew( aPin->GetName() ).c_str(),
455 aPin->GetNameTextSize() ).c_str(),
457 aPin->GetNameTextSize() ).c_str() );
458
459 aFormatter.Print( "(number %s (effects (font (size %s %s))))",
460 aFormatter.Quotew( aPin->GetNumber() ).c_str(),
462 aPin->GetNumberTextSize() ).c_str(),
464 aPin->GetNumberTextSize() ).c_str() );
465
466
467 for( const std::pair<const wxString, SCH_PIN::ALT>& alt : aPin->GetAlternates() )
468 {
469 aFormatter.Print( "(alternate %s %s %s)",
470 aFormatter.Quotew( alt.second.m_Name ).c_str(),
471 getPinElectricalTypeToken( alt.second.m_Type ),
472 getPinShapeToken( alt.second.m_Shape ) );
473 }
474
475 aFormatter.Print( ")" );
476}
477
478
480{
481 wxCHECK_RET( aText && aText->Type() == SCH_TEXT_T, "Invalid SCH_TEXT object." );
482
483 aFormatter.Print( "(text %s %s (at %s %s %g)",
484 aText->IsPrivate() ? "private" : "",
485 aFormatter.Quotew( aText->GetText() ).c_str(),
487 aText->GetPosition().x ).c_str(),
489 -aText->GetPosition().y ).c_str(),
490 (double) aText->GetTextAngle().AsTenthsOfADegree() );
491
492 aText->EDA_TEXT::Format( &aFormatter, 0 );
493 aFormatter.Print( ")" );
494}
495
496
498{
499 wxCHECK_RET( aTextBox && aTextBox->Type() == SCH_TEXTBOX_T, "Invalid SCH_TEXTBOX object." );
500
501 aFormatter.Print( "(text_box %s %s",
502 aTextBox->IsPrivate() ? "private" : "",
503 aFormatter.Quotew( aTextBox->GetText() ).c_str() );
504
505 VECTOR2I pos = aTextBox->GetStart();
506 VECTOR2I size = aTextBox->GetEnd() - pos;
507
508 aFormatter.Print( "(at %s %s %s) (size %s %s) (margins %s %s %s %s)",
511 EDA_UNIT_UTILS::FormatAngle( aTextBox->GetTextAngle() ).c_str(),
518
519 aTextBox->GetStroke().Format( &aFormatter, schIUScale );
520 formatFill( &aFormatter, aTextBox->GetFillMode(), aTextBox->GetFillColor() );
521 aTextBox->EDA_TEXT::Format( &aFormatter, 0 );
522 aFormatter.Print( ")" );
523}
524
525
526void SCH_IO_KICAD_SEXPR_LIB_CACHE::DeleteSymbol( const wxString& aSymbolName )
527{
528 LIB_SYMBOL_MAP::iterator it = m_symbols.find( aSymbolName );
529
530 if( it == m_symbols.end() )
531 THROW_IO_ERROR( wxString::Format( _( "library %s does not contain a symbol named %s" ),
532 m_libFileName.GetFullName(), aSymbolName ) );
533
534 LIB_SYMBOL* symbol = it->second;
535
536 if( symbol->IsRoot() )
537 {
538 LIB_SYMBOL* rootSymbol = symbol;
539
540 // Remove the root symbol and all its children.
541 m_symbols.erase( it );
542
543 LIB_SYMBOL_MAP::iterator it1 = m_symbols.begin();
544
545 while( it1 != m_symbols.end() )
546 {
547 if( it1->second->IsDerived()
548 && it1->second->GetParent().lock() == rootSymbol->SharedPtr() )
549 {
550 delete it1->second;
551 it1 = m_symbols.erase( it1 );
552 }
553 else
554 {
555 it1++;
556 }
557 }
558
559 delete rootSymbol;
560 }
561 else
562 {
563 // Just remove the alias.
564 m_symbols.erase( it );
565 delete symbol;
566 }
567
569 m_isModified = true;
570}
const char * name
Definition: DXF_plotter.cpp:59
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
int AsTenthsOfADegree() const
Definition: eda_angle.h:115
double AsDegrees() const
Definition: eda_angle.h:113
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:127
FILL_T GetFillMode() const
Definition: eda_shape.h:142
SHAPE_T GetShape() const
Definition: eda_shape.h:168
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:215
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:173
COLOR4D GetFillColor() const
Definition: eda_shape.h:152
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:340
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:134
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
virtual bool IsVisible() const
Definition: eda_text.h:174
virtual void Format(OUTPUTFORMATTER *aFormatter, int aControlBits) const
Output the object to aFormatter in s-expression form.
Definition: eda_text.cpp:1053
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:379
void WriteEmbeddedFiles(OUTPUTFORMATTER &aOut, bool aWriteData) const
Output formatter for the embedded files.
void ClearEmbeddedFonts()
Remove all embedded fonts from the collection.
const std::map< wxString, EMBEDDED_FILE * > & EmbeddedFileMap() const
bool GetAreFontsEmbedded() const
A LINE_READER that reads from an open file.
Definition: richio.h:185
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:51
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
Define a library symbol object.
Definition: lib_symbol.h:85
const LIB_ID & GetLibId() const override
Definition: lib_symbol.h:155
wxString GetKeyWords() const override
Definition: lib_symbol.h:183
void GetFields(std::vector< SCH_FIELD * > &aList, bool aVisibleOnly=false) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
bool UnitsLocked() const
Check whether symbol units are interchangeable.
Definition: lib_symbol.h:289
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition: lib_symbol.h:206
std::vector< struct LIB_SYMBOL_UNIT > GetUnitDrawItems()
Return a list of SCH_ITEM objects separated by unit and convert number.
wxString GetUnitDisplayName(int aUnit) override
Return the user-defined display name for aUnit for symbols with units.
Definition: lib_symbol.cpp:291
bool IsLocalPower() const override
Definition: lib_symbol.cpp:414
wxArrayString GetFPFilters() const
Definition: lib_symbol.h:218
bool HasUnitDisplayName(int aUnit) override
Return true if the given unit aUnit has a display name defined.
Definition: lib_symbol.cpp:285
LIB_SYMBOL_SPTR SharedPtr() const
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared.
Definition: lib_symbol.h:96
EMBEDDED_FILES * GetEmbeddedFiles() override
bool IsGlobalPower() const override
Definition: lib_symbol.cpp:444
LIB_SYMBOL_REF & GetParent()
Definition: lib_symbol.h:118
void EmbedFonts() override
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:545
int PRINTF_FUNC_N Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:460
virtual std::string Quotes(const std::string &aWrapee) const
Check aWrapee input string for a need to be quoted (e.g.
Definition: richio.cpp:506
bool IsMandatory() const
Definition: sch_field.cpp:1331
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1309
bool IsNameShown() const
Definition: sch_field.h:208
FIELD_T GetId() const
Definition: sch_field.h:124
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1079
bool CanAutoplace() const
Definition: sch_field.h:219
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1064
static void saveSymbolDrawItem(SCH_ITEM *aItem, OUTPUTFORMATTER &aFormatter)
SCH_IO_KICAD_SEXPR_LIB_CACHE(const wxString &aLibraryPath)
static void saveDcmInfoAsFields(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter)
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, const wxString &aLibName=wxEmptyString, bool aIncludeData=true)
static void saveTextBox(SCH_TEXTBOX *aTextBox, OUTPUTFORMATTER &aFormatter)
static void saveField(SCH_FIELD *aField, OUTPUTFORMATTER &aFormatter)
void DeleteSymbol(const wxString &aName) override
static void savePin(SCH_PIN *aPin, OUTPUTFORMATTER &aFormatter)
static void saveText(SCH_TEXT *aText, OUTPUTFORMATTER &aFormatter)
void Save(const std::optional< bool > &aOpt=std::nullopt) override
Save the entire library to file m_libFileName;.
Object to parser s-expression symbol library and schematic file formats.
void ParseLib(LIB_SYMBOL_MAP &aSymbolLibMap)
A base cache assistant implementation for the symbol library portion of the SCH_IO API.
wxDateTime GetLibModificationTime()
LIB_SYMBOL_MAP m_symbols
wxFileName GetRealFile() const
wxDateTime m_fileModTime
wxFileName m_libFileName
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:167
bool IsPrivate() const
Definition: sch_item.h:239
wxString GetClass() const override
Return the class name.
Definition: sch_item.h:177
int GetNumberTextSize() const
Definition: sch_pin.cpp:588
int GetLength() const
Definition: sch_pin.cpp:291
const std::map< wxString, ALT > & GetAlternates() const
Definition: sch_pin.h:133
bool IsVisible() const
Definition: sch_pin.cpp:383
const wxString & GetName() const
Definition: sch_pin.cpp:397
PIN_ORIENTATION GetOrientation() const
Definition: sch_pin.cpp:256
VECTOR2I GetPosition() const override
Definition: sch_pin.cpp:248
int GetNameTextSize() const
Definition: sch_pin.cpp:564
const wxString & GetNumber() const
Definition: sch_pin.h:123
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:270
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:305
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:56
int GetMarginBottom() const
Definition: sch_textbox.h:66
int GetMarginLeft() const
Definition: sch_textbox.h:63
int GetMarginRight() const
Definition: sch_textbox.h:65
int GetMarginTop() const
Definition: sch_textbox.h:64
VECTOR2I GetPosition() const override
Definition: sch_text.h:141
Simple container to manage line stroke parameters.
Definition: stroke_params.h:94
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale) const
bool GetExcludedFromBoard() const
Definition: symbol.h:187
bool GetExcludedFromBOM() const
Definition: symbol.h:181
int GetPinNameOffset() const
Definition: symbol.h:153
virtual bool GetShowPinNames() const
Definition: symbol.h:159
virtual bool GetShowPinNumbers() const
Definition: symbol.h:165
bool GetExcludedFromSim() const override
Definition: symbol.h:175
wxString wx_str() const
Definition: utf8.cpp:45
#define DEFAULT_PIN_NAME_OFFSET
The intersheets references prefix string.
#define _(s)
#define IS_CHANGED
Item was edited, and modified.
FILL_T
Definition: eda_shape.h:56
const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:39
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:96
KICOMMON_API std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue)
Converts aValue from internal units to a string appropriate for writing to file.
Definition: eda_units.cpp:170
KICOMMON_API std::string FormatAngle(const EDA_ANGLE &aAngle)
Convert aAngle from board units to a string appropriate for writing to file.
Definition: eda_units.cpp:162
void FormatBool(OUTPUTFORMATTER *aOut, const wxString &aKey, bool aValue)
Writes a boolean to the formatter, in the style (aKey [yes|no])
#define SEXPR_SYMBOL_LIB_FILE_VERSION
This file contains the file format version information for the s-expression schematic and symbol libr...
EDA_ANGLE getPinAngle(PIN_ORIENTATION aOrientation)
void formatArc(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aArc, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
void formatCircle(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aCircle, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
const char * getPinElectricalTypeToken(ELECTRICAL_PINTYPE aType)
void formatBezier(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aBezier, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
void formatRect(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aRect, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
void formatPoly(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aPolyLine, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
void formatFill(OUTPUTFORMATTER *aFormatter, FILL_T aFillMode, const COLOR4D &aFillColor)
Fill token formatting helper.
const char * getPinShapeToken(GRAPHIC_PINSHAPE aShape)
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 MilsToIU(int mils) const
Definition: base_units.h:93
wxString GetCanonicalFieldName(FIELD_T aFieldType)
wxLogTrace helper definitions.
@ SCH_FIELD_T
Definition: typeinfo.h:150
@ SCH_SHAPE_T
Definition: typeinfo.h:149
@ SCH_TEXT_T
Definition: typeinfo.h:151
@ SCH_TEXTBOX_T
Definition: typeinfo.h:152
@ SCH_PIN_T
Definition: typeinfo.h:153