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 <fmt/format.h>
23
24#include <wx/log.h>
25
26#include <base_units.h>
27#include <build_version.h>
28#include <sch_shape.h>
29#include <lib_symbol.h>
30#include <sch_textbox.h>
31#include <macros.h>
32#include <richio.h>
36#include <string_utils.h>
37#include <trace_helpers.h>
39
40
41SCH_IO_KICAD_SEXPR_LIB_CACHE::SCH_IO_KICAD_SEXPR_LIB_CACHE( const wxString& aFullPathAndFileName ) :
42 SCH_IO_LIB_CACHE( aFullPathAndFileName )
43{
45}
46
47
49{
50}
51
52
54{
55 if( !m_libFileName.FileExists() )
56 {
57 THROW_IO_ERROR( wxString::Format( _( "Library file '%s' not found." ),
58 m_libFileName.GetFullPath() ) );
59 }
60
61 wxCHECK_RET( m_libFileName.IsAbsolute(),
62 wxString::Format( "Cannot use relative file paths in sexpr plugin to "
63 "open library '%s'.", m_libFileName.GetFullPath() ) );
64
65 wxLogTrace( traceSchLegacyPlugin, "Loading sexpr symbol library file '%s'",
66 m_libFileName.GetFullPath() );
67
68 FILE_LINE_READER reader( m_libFileName.GetFullPath() );
69
70 SCH_IO_KICAD_SEXPR_PARSER parser( &reader );
71
72 parser.ParseLib( m_symbols );
74
75 // Remember the file modification time of library file when the cache snapshot was made,
76 // so that in a networked environment we will reload the cache as needed.
79}
80
81
82void SCH_IO_KICAD_SEXPR_LIB_CACHE::Save( const std::optional<bool>& aOpt )
83{
84 if( !m_isModified )
85 return;
86
87 // Write through symlinks, don't replace them.
88 wxFileName fn = GetRealFile();
89
90 auto formatter = std::make_unique<PRETTIFIED_FILE_OUTPUTFORMATTER>( fn.GetFullPath() );
91
92 formatter->Print( "(kicad_symbol_lib (version %d) (generator \"kicad_symbol_editor\") "
93 "(generator_version \"%s\")",
95 GetMajorMinorVersion().c_str().AsChar() );
96
97 std::vector<LIB_SYMBOL*> orderedSymbols;
98
99 for( const auto& [ name, symbol ] : m_symbols )
100 {
101 if( symbol )
102 orderedSymbols.push_back( symbol );
103 }
104
105 // Library must be ordered by inheritance depth.
106 std::sort( orderedSymbols.begin(), orderedSymbols.end(),
107 []( const LIB_SYMBOL* aLhs, const LIB_SYMBOL* aRhs )
108 {
109 unsigned int lhDepth = aLhs->GetInheritanceDepth();
110 unsigned int rhDepth = aRhs->GetInheritanceDepth();
111
112 if( lhDepth == rhDepth )
113 return aLhs->GetName() < aRhs->GetName();
114
115 return lhDepth < rhDepth;
116 } );
117
118 for( LIB_SYMBOL* symbol : orderedSymbols )
119 SaveSymbol( symbol, *formatter.get() );
120
121 formatter->Print( ")" );
122
123 formatter.reset();
124
125 m_fileModTime = fn.GetModificationTime();
126 m_isModified = false;
127}
128
129
131 const wxString& aLibName, bool aIncludeData )
132{
133 wxCHECK_RET( aSymbol, "Invalid LIB_SYMBOL pointer." );
134
135 // If we've requested to embed the fonts in the symbol, do so.
136 // Otherwise, clear the embedded fonts from the symbol. Embedded
137 // fonts will be used if available
138 if( aSymbol->GetAreFontsEmbedded() )
139 aSymbol->EmbedFonts();
140 else
142
143 std::vector<SCH_FIELD*> orderedFields;
144 std::string name = aFormatter.Quotew( aSymbol->GetLibId().GetLibItemName().wx_str() );
145 std::string unitName = aSymbol->GetLibId().GetLibItemName();
146
147 if( !aLibName.IsEmpty() )
148 {
149 name = aFormatter.Quotew( aLibName );
150
151 LIB_ID unitId;
152
153 wxCHECK2( unitId.Parse( aLibName ) < 0, /* do nothing */ );
154
155 unitName = unitId.GetLibItemName();
156 }
157
158 if( aSymbol->IsRoot() )
159 {
160 aFormatter.Print( "(symbol %s", name.c_str() );
161
162 if( aSymbol->IsGlobalPower() )
163 aFormatter.Print( "(power global)" );
164 else if( aSymbol->IsLocalPower() )
165 aFormatter.Print( "(power local)" );
166
167 // TODO: add uuid token here.
168
169 // TODO: add anchor position token here.
170
171 if( !aSymbol->GetShowPinNumbers() )
172 aFormatter.Print( "(pin_numbers (hide yes))" );
173
175 || !aSymbol->GetShowPinNames() )
176 {
177 aFormatter.Print( "(pin_names" );
178
180 {
181 aFormatter.Print( "(offset %s)",
183 aSymbol->GetPinNameOffset() ).c_str() );
184 }
185
186 if( !aSymbol->GetShowPinNames() )
187 KICAD_FORMAT::FormatBool( &aFormatter, "hide", true );
188
189 aFormatter.Print( ")" );
190 }
191
192 KICAD_FORMAT::FormatBool( &aFormatter, "exclude_from_sim", aSymbol->GetExcludedFromSim() );
193 KICAD_FORMAT::FormatBool( &aFormatter, "in_bom", !aSymbol->GetExcludedFromBOM() );
194 KICAD_FORMAT::FormatBool( &aFormatter, "on_board", !aSymbol->GetExcludedFromBoard() );
195
196 KICAD_FORMAT::FormatBool( &aFormatter, "duplicate_pin_numbers_are_jumpers",
198
199 const std::vector<std::set<wxString>>& jumperGroups = aSymbol->JumperPinGroups();
200
201 if( !jumperGroups.empty() )
202 {
203 aFormatter.Print( "(jumper_pin_groups" );
204
205 for( const std::set<wxString>& group : jumperGroups )
206 {
207 aFormatter.Print( "(" );
208
209 for( const wxString& padName : group )
210 aFormatter.Print( "%s ", aFormatter.Quotew( padName ).c_str() );
211
212 aFormatter.Print( ")" );
213 }
214
215 aFormatter.Print( ")" );
216 }
217
218 // TODO: add atomic token here.
219
220 // TODO: add required token here."
221
222 aSymbol->GetFields( orderedFields );
223
224 for( SCH_FIELD* field : orderedFields )
225 saveField( field, aFormatter );
226
227 // @todo At some point in the future the lock status (all units interchangeable) should
228 // be set deterministically. For now a custom lock property is used to preserve the
229 // locked flag state.
230 if( aSymbol->UnitsLocked() )
231 {
232 SCH_FIELD locked( nullptr, FIELD_T::USER, "ki_locked" );
233 saveField( &locked, aFormatter );
234 }
235
236 saveDcmInfoAsFields( aSymbol, aFormatter );
237
238 // Save the draw items grouped by units.
239 std::vector<LIB_SYMBOL_UNIT> units = aSymbol->GetUnitDrawItems();
240 std::sort( units.begin(), units.end(),
241 []( const LIB_SYMBOL_UNIT& a, const LIB_SYMBOL_UNIT& b )
242 {
243 if( a.m_unit == b.m_unit )
244 return a.m_bodyStyle < b.m_bodyStyle;
245
246 return a.m_unit < b.m_unit;
247 } );
248
249 for( const LIB_SYMBOL_UNIT& unit : units )
250 {
251 // Add quotes and escape chars like ") to the UTF8 unitName string
252 name = aFormatter.Quotes( unitName );
253 name.pop_back(); // Remove last char: the quote ending the string.
254
255 aFormatter.Print( "(symbol %s_%d_%d\"",
256 name.c_str(),
257 unit.m_unit,
258 unit.m_bodyStyle );
259
260 // if the unit has a display name, write that
261 if( aSymbol->HasUnitDisplayName( unit.m_unit ) )
262 {
263 name = aSymbol->GetUnitDisplayName( unit.m_unit, false );
264 aFormatter.Print( "(unit_name %s)", aFormatter.Quotes( name ).c_str() );
265 }
266
267 // Enforce item ordering
268 auto cmp =
269 []( const SCH_ITEM* a, const SCH_ITEM* b )
270 {
271 return *a < *b;
272 };
273
274 std::multiset<SCH_ITEM*, decltype( cmp )> save_map( cmp );
275
276 for( SCH_ITEM* item : unit.m_items )
277 save_map.insert( item );
278
279 for( SCH_ITEM* item : save_map )
280 saveSymbolDrawItem( item, aFormatter );
281
282 aFormatter.Print( ")" );
283 }
284
285 KICAD_FORMAT::FormatBool( &aFormatter, "embedded_fonts", aSymbol->GetAreFontsEmbedded() );
286
287 if( !aSymbol->EmbeddedFileMap().empty() )
288 aSymbol->WriteEmbeddedFiles( aFormatter, aIncludeData );
289 }
290 else
291 {
292 std::shared_ptr<LIB_SYMBOL> parent = aSymbol->GetParent().lock();
293
294 wxASSERT( parent );
295
296 aFormatter.Print( "(symbol %s (extends %s)",
297 name.c_str(),
298 aFormatter.Quotew( parent->GetName() ).c_str() );
299
300 aSymbol->GetFields( orderedFields );
301
302 for( SCH_FIELD* field : orderedFields )
303 saveField( field, aFormatter );
304
305 saveDcmInfoAsFields( aSymbol, aFormatter );
306 }
307
308 aFormatter.Print( ")" );
309}
310
311
313 OUTPUTFORMATTER& aFormatter )
314{
315 wxCHECK_RET( aSymbol, "Invalid LIB_SYMBOL pointer." );
316
317 if( !aSymbol->GetKeyWords().IsEmpty() )
318 {
319 SCH_FIELD keywords( nullptr, FIELD_T::USER, wxString( "ki_keywords" ) );
320 keywords.SetVisible( false );
321 keywords.SetText( aSymbol->GetKeyWords() );
322 saveField( &keywords, aFormatter );
323 }
324
325 wxArrayString fpFilters = aSymbol->GetFPFilters();
326
327 if( !fpFilters.IsEmpty() )
328 {
329 wxString tmp;
330
331 for( const wxString& filter : fpFilters )
332 {
333 // Spaces are not handled in fp filter names so escape spaces if any
334 wxString curr_filter = EscapeString( filter, ESCAPE_CONTEXT::CTX_NO_SPACE );
335
336 if( tmp.IsEmpty() )
337 tmp = curr_filter;
338 else
339 tmp += " " + curr_filter;
340 }
341
342 SCH_FIELD description( nullptr, FIELD_T::USER, wxString( "ki_fp_filters" ) );
343 description.SetVisible( false );
344 description.SetText( tmp );
345 saveField( &description, aFormatter );
346 }
347}
348
349
351{
352 wxCHECK_RET( aItem, "Invalid SCH_ITEM pointer." );
353
354 switch( aItem->Type() )
355 {
356 case SCH_SHAPE_T:
357 {
358 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem );
359 STROKE_PARAMS stroke = shape->GetStroke();
360 FILL_T fillMode = shape->GetFillMode();
361 COLOR4D fillColor = shape->GetFillColor();
362 bool isPrivate = shape->IsPrivate();
363
364 switch( shape->GetShape() )
365 {
366 case SHAPE_T::ARC:
367 formatArc( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
368 break;
369
370 case SHAPE_T::CIRCLE:
371 formatCircle( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
372 break;
373
374 case SHAPE_T::RECTANGLE:
375 formatRect( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
376 break;
377
378 case SHAPE_T::BEZIER:
379 formatBezier(&aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
380 break;
381
382 case SHAPE_T::POLY:
383 formatPoly( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
384 break;
385
386 default:
388 }
389
390 break;
391 }
392
393 case SCH_PIN_T:
394 savePin( static_cast<SCH_PIN*>( aItem ), aFormatter );
395 break;
396
397 case SCH_TEXT_T:
398 saveText( static_cast<SCH_TEXT*>( aItem ), aFormatter );
399 break;
400
401 case SCH_TEXTBOX_T:
402 saveTextBox( static_cast<SCH_TEXTBOX*>( aItem ), aFormatter );
403 break;
404
405 default:
406 UNIMPLEMENTED_FOR( aItem->GetClass() );
407 }
408}
409
410
412{
413 wxCHECK_RET( aField && aField->Type() == SCH_FIELD_T, "Invalid SCH_FIELD object." );
414
415 wxString fieldName = aField->GetName();
416
417 if( aField->IsMandatory() )
418 fieldName = GetCanonicalFieldName( aField->GetId() );
419
420 aFormatter.Print( "(property %s %s %s (at %s %s %s)",
421 aField->IsPrivate() ? "private" : "",
422 aFormatter.Quotew( fieldName ).c_str(),
423 aFormatter.Quotew( aField->GetText() ).c_str(),
425 aField->GetPosition().x ).c_str(),
427 -aField->GetPosition().y ).c_str(),
428 fmt::format( "{:g}", aField->GetTextAngle().AsDegrees() ).c_str() );
429
430 if( aField->IsNameShown() )
431 aFormatter.Print( "(show_name)" );
432
433 if( !aField->CanAutoplace() )
434 aFormatter.Print( "(do_not_autoplace)" );
435
436 if( !aField->IsVisible() )
437 KICAD_FORMAT::FormatBool( &aFormatter, "hide", true );
438
439 aField->Format( &aFormatter, 0 );
440 aFormatter.Print( ")" );
441}
442
443
445{
446 wxCHECK_RET( aPin && aPin->Type() == SCH_PIN_T, "Invalid SCH_PIN object." );
447
448 aPin->ClearFlags( IS_CHANGED );
449
450 aFormatter.Print( "(pin %s %s (at %s %s %s) (length %s)",
452 getPinShapeToken( aPin->GetShape() ),
454 aPin->GetPosition().x ).c_str(),
456 -aPin->GetPosition().y ).c_str(),
459 aPin->GetLength() ).c_str() );
460
461 if( !aPin->IsVisible() )
462 KICAD_FORMAT::FormatBool( &aFormatter, "hide", true );
463
464 // This follows the EDA_TEXT effects formatting for future expansion.
465 aFormatter.Print( "(name %s (effects (font (size %s %s))))",
466 aFormatter.Quotew( aPin->GetName() ).c_str(),
468 aPin->GetNameTextSize() ).c_str(),
470 aPin->GetNameTextSize() ).c_str() );
471
472 aFormatter.Print( "(number %s (effects (font (size %s %s))))",
473 aFormatter.Quotew( aPin->GetNumber() ).c_str(),
475 aPin->GetNumberTextSize() ).c_str(),
477 aPin->GetNumberTextSize() ).c_str() );
478
479
480 for( const std::pair<const wxString, SCH_PIN::ALT>& alt : aPin->GetAlternates() )
481 {
482 // There was a bug somewhere in the alternate pin code that allowed pin alternates with no
483 // name to be saved in library symbols. This strips any invalid alternates just in case
484 // that code resurfaces.
485 if( alt.second.m_Name.IsEmpty() )
486 continue;
487
488 aFormatter.Print( "(alternate %s %s %s)",
489 aFormatter.Quotew( alt.second.m_Name ).c_str(),
490 getPinElectricalTypeToken( alt.second.m_Type ),
491 getPinShapeToken( alt.second.m_Shape ) );
492 }
493
494 aFormatter.Print( ")" );
495}
496
497
499{
500 wxCHECK_RET( aText && aText->Type() == SCH_TEXT_T, "Invalid SCH_TEXT object." );
501
502 aFormatter.Print( "(text %s %s (at %s %s %d)",
503 aText->IsPrivate() ? "private" : "",
504 aFormatter.Quotew( aText->GetText() ).c_str(),
506 aText->GetPosition().x ).c_str(),
508 -aText->GetPosition().y ).c_str(),
509 aText->GetTextAngle().AsTenthsOfADegree() );
510
511 aText->EDA_TEXT::Format( &aFormatter, 0 );
512 aFormatter.Print( ")" );
513}
514
515
517{
518 wxCHECK_RET( aTextBox && aTextBox->Type() == SCH_TEXTBOX_T, "Invalid SCH_TEXTBOX object." );
519
520 aFormatter.Print( "(text_box %s %s",
521 aTextBox->IsPrivate() ? "private" : "",
522 aFormatter.Quotew( aTextBox->GetText() ).c_str() );
523
524 VECTOR2I pos = aTextBox->GetStart();
525 VECTOR2I size = aTextBox->GetEnd() - pos;
526
527 aFormatter.Print( "(at %s %s %s) (size %s %s) (margins %s %s %s %s)",
530 EDA_UNIT_UTILS::FormatAngle( aTextBox->GetTextAngle() ).c_str(),
537
538 aTextBox->GetStroke().Format( &aFormatter, schIUScale );
539 formatFill( &aFormatter, aTextBox->GetFillMode(), aTextBox->GetFillColor() );
540 aTextBox->EDA_TEXT::Format( &aFormatter, 0 );
541 aFormatter.Print( ")" );
542}
543
544
545void SCH_IO_KICAD_SEXPR_LIB_CACHE::DeleteSymbol( const wxString& aSymbolName )
546{
547 LIB_SYMBOL_MAP::iterator it = m_symbols.find( aSymbolName );
548
549 if( it == m_symbols.end() )
550 THROW_IO_ERROR( wxString::Format( _( "library %s does not contain a symbol named %s" ),
551 m_libFileName.GetFullName(), aSymbolName ) );
552
553 LIB_SYMBOL* symbol = it->second;
554
555 if( symbol->IsRoot() )
556 {
557 LIB_SYMBOL* rootSymbol = symbol;
558
559 // Remove the root symbol and all its children.
560 m_symbols.erase( it );
561
562 LIB_SYMBOL_MAP::iterator it1 = m_symbols.begin();
563
564 while( it1 != m_symbols.end() )
565 {
566 if( it1->second->IsDerived()
567 && it1->second->GetParent().lock() == rootSymbol->SharedPtr() )
568 {
569 delete it1->second;
570 it1 = m_symbols.erase( it1 );
571 }
572 else
573 {
574 it1++;
575 }
576 }
577
578 delete rootSymbol;
579 }
580 else
581 {
582 // Just remove the alias.
583 m_symbols.erase( it );
584 delete symbol;
585 }
586
588 m_isModified = true;
589}
const char * name
Definition: DXF_plotter.cpp:62
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:114
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
int AsTenthsOfADegree() const
Definition: eda_angle.h:118
double AsDegrees() const
Definition: eda_angle.h:116
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:110
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:144
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:343
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:144
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:97
virtual bool IsVisible() const
Definition: eda_text.h:184
virtual void Format(OUTPUTFORMATTER *aFormatter, int aControlBits) const
Output the object to aFormatter in s-expression form.
Definition: eda_text.cpp:1041
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:386
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
bool HasUnitDisplayName(int aUnit) const
Return true if the given unit aUnit has a display name defined.
Definition: lib_symbol.cpp:281
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.
bool IsLocalPower() const override
Definition: lib_symbol.cpp:423
wxArrayString GetFPFilters() const
Definition: lib_symbol.h:218
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:453
bool GetDuplicatePinNumbersAreJumpers() const
Definition: lib_symbol.h:572
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:579
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the user-defined display name for aUnit for symbols with units.
Definition: lib_symbol.cpp:287
void EmbedFonts() override
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:548
int PRINTF_FUNC_N Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:463
virtual std::string Quotes(const std::string &aWrapee) const
Check aWrapee input string for a need to be quoted (e.g.
Definition: richio.cpp:509
bool IsMandatory() const
Definition: sch_field.cpp:1359
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1337
bool IsNameShown() const
Definition: sch_field.h:202
FIELD_T GetId() const
Definition: sch_field.h:116
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1103
bool CanAutoplace() const
Definition: sch_field.h:213
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1089
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:168
bool IsPrivate() const
Definition: sch_item.h:254
wxString GetClass() const override
Return the class name.
Definition: sch_item.h:178
int GetNumberTextSize() const
Definition: sch_pin.cpp:578
int GetLength() const
Definition: sch_pin.cpp:255
const std::map< wxString, ALT > & GetAlternates() const
Definition: sch_pin.h:133
bool IsVisible() const
Definition: sch_pin.cpp:343
const wxString & GetName() const
Definition: sch_pin.cpp:357
PIN_ORIENTATION GetOrientation() const
Definition: sch_pin.cpp:220
VECTOR2I GetPosition() const override
Definition: sch_pin.cpp:212
int GetNameTextSize() const
Definition: sch_pin.cpp:554
const wxString & GetNumber() const
Definition: sch_pin.h:123
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:234
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:269
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:57
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
int GetPinNameOffset() const
Definition: symbol.h:153
bool GetExcludedFromBoard() const override
Definition: symbol.h:187
virtual bool GetShowPinNames() const
Definition: symbol.h:159
virtual bool GetShowPinNumbers() const
Definition: symbol.h:165
bool GetExcludedFromBOM() const override
Definition: symbol.h:181
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:194
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:186
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:97
wxString GetCanonicalFieldName(FIELD_T aFieldType)
wxLogTrace helper definitions.
@ SCH_FIELD_T
Definition: typeinfo.h:151
@ SCH_SHAPE_T
Definition: typeinfo.h:150
@ SCH_TEXT_T
Definition: typeinfo.h:152
@ SCH_TEXTBOX_T
Definition: typeinfo.h:153
@ SCH_PIN_T
Definition: typeinfo.h:154