KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 <stambaughw@gmail.com>
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 KICAD_FORMAT::FormatBool( &aFormatter, "duplicate_pin_numbers_are_jumpers",
207
208 const std::vector<std::set<wxString>>& jumperGroups = aSymbol->JumperPinGroups();
209
210 if( !jumperGroups.empty() )
211 {
212 aFormatter.Print( "(jumper_pin_groups" );
213
214 for( const std::set<wxString>& group : jumperGroups )
215 {
216 aFormatter.Print( "(" );
217
218 for( const wxString& padName : group )
219 aFormatter.Print( "%s ", aFormatter.Quotew( padName ).c_str() );
220
221 aFormatter.Print( ")" );
222 }
223
224 aFormatter.Print( ")" );
225 }
226
227 // TODO: add atomic token here.
228
229 // TODO: add required token here."
230
231 aSymbol->GetFields( orderedFields );
232
233 for( SCH_FIELD* field : orderedFields )
234 saveField( field, aFormatter );
235
236 // @todo At some point in the future the lock status (all units interchangeable) should
237 // be set deterministically. For now a custom lock property is used to preserve the
238 // locked flag state.
239 if( aSymbol->UnitsLocked() )
240 {
241 SCH_FIELD locked( nullptr, FIELD_T::USER, "ki_locked" );
242 saveField( &locked, aFormatter );
243 }
244
245 saveDcmInfoAsFields( aSymbol, aFormatter );
246
247 // Save the draw items grouped by units.
248 std::vector<LIB_SYMBOL_UNIT> units = aSymbol->GetUnitDrawItems();
249 std::sort( units.begin(), units.end(),
250 []( const LIB_SYMBOL_UNIT& a, const LIB_SYMBOL_UNIT& b )
251 {
252 if( a.m_unit == b.m_unit )
253 return a.m_bodyStyle < b.m_bodyStyle;
254
255 return a.m_unit < b.m_unit;
256 } );
257
258 for( const LIB_SYMBOL_UNIT& unit : units )
259 {
260 // Add quotes and escape chars like ") to the UTF8 unitName string
261 name = aFormatter.Quotes( unitName );
262 name.pop_back(); // Remove last char: the quote ending the string.
263
264 aFormatter.Print( "(symbol %s_%d_%d\"",
265 name.c_str(),
266 unit.m_unit,
267 unit.m_bodyStyle );
268
269 // if the unit has a display name, write that
270 if( aSymbol->HasUnitDisplayName( unit.m_unit ) )
271 {
272 name = aSymbol->GetUnitDisplayName( unit.m_unit );
273 aFormatter.Print( "(unit_name %s)", aFormatter.Quotes( name ).c_str() );
274 }
275
276 // Enforce item ordering
277 auto cmp =
278 []( const SCH_ITEM* a, const SCH_ITEM* b )
279 {
280 return *a < *b;
281 };
282
283 std::multiset<SCH_ITEM*, decltype( cmp )> save_map( cmp );
284
285 for( SCH_ITEM* item : unit.m_items )
286 save_map.insert( item );
287
288 for( SCH_ITEM* item : save_map )
289 saveSymbolDrawItem( item, aFormatter );
290
291 aFormatter.Print( ")" );
292 }
293
294 KICAD_FORMAT::FormatBool( &aFormatter, "embedded_fonts", aSymbol->GetAreFontsEmbedded() );
295
296 if( !aSymbol->EmbeddedFileMap().empty() )
297 aSymbol->WriteEmbeddedFiles( aFormatter, aIncludeData );
298 }
299 else
300 {
301 std::shared_ptr<LIB_SYMBOL> parent = aSymbol->GetParent().lock();
302
303 wxASSERT( parent );
304
305 aFormatter.Print( "(symbol %s (extends %s)",
306 name.c_str(),
307 aFormatter.Quotew( parent->GetName() ).c_str() );
308
309 aSymbol->GetFields( orderedFields );
310
311 for( SCH_FIELD* field : orderedFields )
312 saveField( field, aFormatter );
313
314 saveDcmInfoAsFields( aSymbol, aFormatter );
315 }
316
317 aFormatter.Print( ")" );
318}
319
320
322 OUTPUTFORMATTER& aFormatter )
323{
324 wxCHECK_RET( aSymbol, "Invalid LIB_SYMBOL pointer." );
325
326 if( !aSymbol->GetKeyWords().IsEmpty() )
327 {
328 SCH_FIELD keywords( nullptr, FIELD_T::USER, wxString( "ki_keywords" ) );
329 keywords.SetVisible( false );
330 keywords.SetText( aSymbol->GetKeyWords() );
331 saveField( &keywords, aFormatter );
332 }
333
334 wxArrayString fpFilters = aSymbol->GetFPFilters();
335
336 if( !fpFilters.IsEmpty() )
337 {
338 wxString tmp;
339
340 for( const wxString& filter : fpFilters )
341 {
342 // Spaces are not handled in fp filter names so escape spaces if any
343 wxString curr_filter = EscapeString( filter, ESCAPE_CONTEXT::CTX_NO_SPACE );
344
345 if( tmp.IsEmpty() )
346 tmp = curr_filter;
347 else
348 tmp += " " + curr_filter;
349 }
350
351 SCH_FIELD description( nullptr, FIELD_T::USER, wxString( "ki_fp_filters" ) );
352 description.SetVisible( false );
353 description.SetText( tmp );
354 saveField( &description, aFormatter );
355 }
356}
357
358
360{
361 wxCHECK_RET( aItem, "Invalid SCH_ITEM pointer." );
362
363 switch( aItem->Type() )
364 {
365 case SCH_SHAPE_T:
366 {
367 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem );
368 STROKE_PARAMS stroke = shape->GetStroke();
369 FILL_T fillMode = shape->GetFillMode();
370 COLOR4D fillColor = shape->GetFillColor();
371 bool isPrivate = shape->IsPrivate();
372
373 switch( shape->GetShape() )
374 {
375 case SHAPE_T::ARC:
376 formatArc( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
377 break;
378
379 case SHAPE_T::CIRCLE:
380 formatCircle( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
381 break;
382
383 case SHAPE_T::RECTANGLE:
384 formatRect( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
385 break;
386
387 case SHAPE_T::BEZIER:
388 formatBezier(&aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
389 break;
390
391 case SHAPE_T::POLY:
392 formatPoly( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
393 break;
394
395 default:
397 }
398
399 break;
400 }
401
402 case SCH_PIN_T:
403 savePin( static_cast<SCH_PIN*>( aItem ), aFormatter );
404 break;
405
406 case SCH_TEXT_T:
407 saveText( static_cast<SCH_TEXT*>( aItem ), aFormatter );
408 break;
409
410 case SCH_TEXTBOX_T:
411 saveTextBox( static_cast<SCH_TEXTBOX*>( aItem ), aFormatter );
412 break;
413
414 default:
415 UNIMPLEMENTED_FOR( aItem->GetClass() );
416 }
417}
418
419
421{
422 wxCHECK_RET( aField && aField->Type() == SCH_FIELD_T, "Invalid SCH_FIELD object." );
423
424 wxString fieldName = aField->GetName();
425
426 if( aField->IsMandatory() )
427 fieldName = GetCanonicalFieldName( aField->GetId() );
428
429 aFormatter.Print( "(property %s %s %s (at %s %s %g)",
430 aField->IsPrivate() ? "private" : "",
431 aFormatter.Quotew( fieldName ).c_str(),
432 aFormatter.Quotew( aField->GetText() ).c_str(),
434 aField->GetPosition().x ).c_str(),
436 -aField->GetPosition().y ).c_str(),
437 aField->GetTextAngle().AsDegrees() );
438
439 if( aField->IsNameShown() )
440 aFormatter.Print( "(show_name)" );
441
442 if( !aField->CanAutoplace() )
443 aFormatter.Print( "(do_not_autoplace)" );
444
445 if( !aField->IsVisible() )
446 KICAD_FORMAT::FormatBool( &aFormatter, "hide", true );
447
448 aField->Format( &aFormatter, 0 );
449 aFormatter.Print( ")" );
450}
451
452
454{
455 wxCHECK_RET( aPin && aPin->Type() == SCH_PIN_T, "Invalid SCH_PIN object." );
456
457 aPin->ClearFlags( IS_CHANGED );
458
459 aFormatter.Print( "(pin %s %s (at %s %s %s) (length %s)",
461 getPinShapeToken( aPin->GetShape() ),
463 aPin->GetPosition().x ).c_str(),
465 -aPin->GetPosition().y ).c_str(),
468 aPin->GetLength() ).c_str() );
469
470 if( !aPin->IsVisible() )
471 KICAD_FORMAT::FormatBool( &aFormatter, "hide", true );
472
473 // This follows the EDA_TEXT effects formatting for future expansion.
474 aFormatter.Print( "(name %s (effects (font (size %s %s))))",
475 aFormatter.Quotew( aPin->GetName() ).c_str(),
477 aPin->GetNameTextSize() ).c_str(),
479 aPin->GetNameTextSize() ).c_str() );
480
481 aFormatter.Print( "(number %s (effects (font (size %s %s))))",
482 aFormatter.Quotew( aPin->GetNumber() ).c_str(),
484 aPin->GetNumberTextSize() ).c_str(),
486 aPin->GetNumberTextSize() ).c_str() );
487
488
489 for( const std::pair<const wxString, SCH_PIN::ALT>& alt : aPin->GetAlternates() )
490 {
491 aFormatter.Print( "(alternate %s %s %s)",
492 aFormatter.Quotew( alt.second.m_Name ).c_str(),
493 getPinElectricalTypeToken( alt.second.m_Type ),
494 getPinShapeToken( alt.second.m_Shape ) );
495 }
496
497 aFormatter.Print( ")" );
498}
499
500
502{
503 wxCHECK_RET( aText && aText->Type() == SCH_TEXT_T, "Invalid SCH_TEXT object." );
504
505 aFormatter.Print( "(text %s %s (at %s %s %g)",
506 aText->IsPrivate() ? "private" : "",
507 aFormatter.Quotew( aText->GetText() ).c_str(),
509 aText->GetPosition().x ).c_str(),
511 -aText->GetPosition().y ).c_str(),
512 (double) aText->GetTextAngle().AsTenthsOfADegree() );
513
514 aText->EDA_TEXT::Format( &aFormatter, 0 );
515 aFormatter.Print( ")" );
516}
517
518
520{
521 wxCHECK_RET( aTextBox && aTextBox->Type() == SCH_TEXTBOX_T, "Invalid SCH_TEXTBOX object." );
522
523 aFormatter.Print( "(text_box %s %s",
524 aTextBox->IsPrivate() ? "private" : "",
525 aFormatter.Quotew( aTextBox->GetText() ).c_str() );
526
527 VECTOR2I pos = aTextBox->GetStart();
528 VECTOR2I size = aTextBox->GetEnd() - pos;
529
530 aFormatter.Print( "(at %s %s %s) (size %s %s) (margins %s %s %s %s)",
533 EDA_UNIT_UTILS::FormatAngle( aTextBox->GetTextAngle() ).c_str(),
540
541 aTextBox->GetStroke().Format( &aFormatter, schIUScale );
542 formatFill( &aFormatter, aTextBox->GetFillMode(), aTextBox->GetFillColor() );
543 aTextBox->EDA_TEXT::Format( &aFormatter, 0 );
544 aFormatter.Print( ")" );
545}
546
547
548void SCH_IO_KICAD_SEXPR_LIB_CACHE::DeleteSymbol( const wxString& aSymbolName )
549{
550 LIB_SYMBOL_MAP::iterator it = m_symbols.find( aSymbolName );
551
552 if( it == m_symbols.end() )
553 THROW_IO_ERROR( wxString::Format( _( "library %s does not contain a symbol named %s" ),
554 m_libFileName.GetFullName(), aSymbolName ) );
555
556 LIB_SYMBOL* symbol = it->second;
557
558 if( symbol->IsRoot() )
559 {
560 LIB_SYMBOL* rootSymbol = symbol;
561
562 // Remove the root symbol and all its children.
563 m_symbols.erase( it );
564
565 LIB_SYMBOL_MAP::iterator it1 = m_symbols.begin();
566
567 while( it1 != m_symbols.end() )
568 {
569 if( it1->second->IsDerived()
570 && it1->second->GetParent().lock() == rootSymbol->SharedPtr() )
571 {
572 delete it1->second;
573 it1 = m_symbols.erase( it1 );
574 }
575 else
576 {
577 it1++;
578 }
579 }
580
581 delete rootSymbol;
582 }
583 else
584 {
585 // Just remove the alias.
586 m_symbols.erase( it );
587 delete symbol;
588 }
589
591 m_isModified = true;
592}
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:108
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:137
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:52
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:301
bool IsLocalPower() const override
Definition: lib_symbol.cpp:424
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:295
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:454
bool GetDuplicatePinNumbersAreJumpers() const
Definition: lib_symbol.h:570
LIB_SYMBOL_REF & GetParent()
Definition: lib_symbol.h:118
std::vector< std::set< wxString > > & JumperPinGroups()
Each jumper pin group is a set of pin numbers that should be treated as internally connected.
Definition: lib_symbol.h:577
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:1338
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1316
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:1086
bool CanAutoplace() const
Definition: sch_field.h:219
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1071
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:242
wxString GetClass() const override
Return the class name.
Definition: sch_item.h:177
int GetNumberTextSize() const
Definition: sch_pin.cpp:582
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:558
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:54
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:139
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