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
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->IsMultiBodyStyle() )
172 {
173 aFormatter.Print( "(body_styles " );
174
175 if( aSymbol->HasDeMorganBodyStyles() )
176 {
177 aFormatter.Print( "demorgan" );
178 }
179 else
180 {
181 for( const wxString& bodyStyle : aSymbol->GetBodyStyleNames() )
182 aFormatter.Print( "%s ", aFormatter.Quotew( bodyStyle ).c_str() );
183 }
184
185 aFormatter.Print( ")" );
186 }
187
188 if( !aSymbol->GetShowPinNumbers() )
189 aFormatter.Print( "(pin_numbers (hide yes))" );
190
191 if( aSymbol->GetPinNameOffset() != schIUScale.MilsToIU( DEFAULT_PIN_NAME_OFFSET )
192 || !aSymbol->GetShowPinNames() )
193 {
194 aFormatter.Print( "(pin_names" );
195
196 if( aSymbol->GetPinNameOffset() != schIUScale.MilsToIU( DEFAULT_PIN_NAME_OFFSET ) )
197 {
198 aFormatter.Print( "(offset %s)",
200 aSymbol->GetPinNameOffset() ).c_str() );
201 }
202
203 if( !aSymbol->GetShowPinNames() )
204 KICAD_FORMAT::FormatBool( &aFormatter, "hide", true );
205
206 aFormatter.Print( ")" );
207 }
208
209 KICAD_FORMAT::FormatBool( &aFormatter, "exclude_from_sim", aSymbol->GetExcludedFromSim() );
210 KICAD_FORMAT::FormatBool( &aFormatter, "in_bom", !aSymbol->GetExcludedFromBOM() );
211 KICAD_FORMAT::FormatBool( &aFormatter, "on_board", !aSymbol->GetExcludedFromBoard() );
212
213 KICAD_FORMAT::FormatBool( &aFormatter, "duplicate_pin_numbers_are_jumpers",
215
216 const std::vector<std::set<wxString>>& jumperGroups = aSymbol->JumperPinGroups();
217
218 if( !jumperGroups.empty() )
219 {
220 aFormatter.Print( "(jumper_pin_groups" );
221
222 for( const std::set<wxString>& group : jumperGroups )
223 {
224 aFormatter.Print( "(" );
225
226 for( const wxString& padName : group )
227 aFormatter.Print( "%s ", aFormatter.Quotew( padName ).c_str() );
228
229 aFormatter.Print( ")" );
230 }
231
232 aFormatter.Print( ")" );
233 }
234
235 // TODO: add atomic token here.
236
237 // TODO: add required token here."
238
239 aSymbol->GetFields( orderedFields );
240
241 for( SCH_FIELD* field : orderedFields )
242 saveField( field, aFormatter );
243
244 // @todo At some point in the future the lock status (all units interchangeable) should
245 // be set deterministically. For now a custom lock property is used to preserve the
246 // locked flag state.
247 if( aSymbol->UnitsLocked() )
248 {
249 SCH_FIELD locked( nullptr, FIELD_T::USER, "ki_locked" );
250 saveField( &locked, aFormatter );
251 }
252
253 saveDcmInfoAsFields( aSymbol, aFormatter );
254
255 // Save the draw items grouped by units.
256 std::vector<LIB_SYMBOL_UNIT> units = aSymbol->GetUnitDrawItems();
257 std::sort( units.begin(), units.end(),
258 []( const LIB_SYMBOL_UNIT& a, const LIB_SYMBOL_UNIT& b )
259 {
260 if( a.m_unit == b.m_unit )
261 return a.m_bodyStyle < b.m_bodyStyle;
262
263 return a.m_unit < b.m_unit;
264 } );
265
266 for( const LIB_SYMBOL_UNIT& unit : units )
267 {
268 // Add quotes and escape chars like ") to the UTF8 unitName string
269 name = aFormatter.Quotes( unitName );
270 name.pop_back(); // Remove last char: the quote ending the string.
271
272 aFormatter.Print( "(symbol %s_%d_%d\"",
273 name.c_str(),
274 unit.m_unit,
275 unit.m_bodyStyle );
276
277 // if the unit has a display name, write that
278 if( aSymbol->GetUnitDisplayNames().contains( unit.m_unit ) )
279 {
280 name = aSymbol->GetUnitDisplayNames().at( unit.m_unit );
281 aFormatter.Print( "(unit_name %s)", aFormatter.Quotes( name ).c_str() );
282 }
283
284 // Enforce item ordering
285 auto cmp =
286 []( const SCH_ITEM* a, const SCH_ITEM* b )
287 {
288 return *a < *b;
289 };
290
291 std::multiset<SCH_ITEM*, decltype( cmp )> save_map( cmp );
292
293 for( SCH_ITEM* item : unit.m_items )
294 save_map.insert( item );
295
296 for( SCH_ITEM* item : save_map )
297 saveSymbolDrawItem( item, aFormatter );
298
299 aFormatter.Print( ")" );
300 }
301
302 KICAD_FORMAT::FormatBool( &aFormatter, "embedded_fonts", aSymbol->GetAreFontsEmbedded() );
303
304 if( !aSymbol->EmbeddedFileMap().empty() )
305 aSymbol->WriteEmbeddedFiles( aFormatter, aIncludeData );
306 }
307 else
308 {
309 std::shared_ptr<LIB_SYMBOL> parent = aSymbol->GetParent().lock();
310
311 wxASSERT( parent );
312
313 aFormatter.Print( "(symbol %s (extends %s)",
314 name.c_str(),
315 aFormatter.Quotew( parent->GetName() ).c_str() );
316
317 aSymbol->GetFields( orderedFields );
318
319 for( SCH_FIELD* field : orderedFields )
320 saveField( field, aFormatter );
321
322 saveDcmInfoAsFields( aSymbol, aFormatter );
323 }
324
325 aFormatter.Print( ")" );
326}
327
328
330 OUTPUTFORMATTER& aFormatter )
331{
332 wxCHECK_RET( aSymbol, "Invalid LIB_SYMBOL pointer." );
333
334 if( !aSymbol->GetKeyWords().IsEmpty() )
335 {
336 SCH_FIELD keywords( nullptr, FIELD_T::USER, wxString( "ki_keywords" ) );
337 keywords.SetVisible( false );
338 keywords.SetText( aSymbol->GetKeyWords() );
339 saveField( &keywords, aFormatter );
340 }
341
342 wxArrayString fpFilters = aSymbol->GetFPFilters();
343
344 if( !fpFilters.IsEmpty() )
345 {
346 wxString tmp;
347
348 for( const wxString& filter : fpFilters )
349 {
350 // Spaces are not handled in fp filter names so escape spaces if any
351 wxString curr_filter = EscapeString( filter, ESCAPE_CONTEXT::CTX_NO_SPACE );
352
353 if( tmp.IsEmpty() )
354 tmp = curr_filter;
355 else
356 tmp += " " + curr_filter;
357 }
358
359 SCH_FIELD description( nullptr, FIELD_T::USER, wxString( "ki_fp_filters" ) );
360 description.SetVisible( false );
361 description.SetText( tmp );
362 saveField( &description, aFormatter );
363 }
364}
365
366
368{
369 wxCHECK_RET( aItem, "Invalid SCH_ITEM pointer." );
370
371 switch( aItem->Type() )
372 {
373 case SCH_SHAPE_T:
374 {
375 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem );
376 STROKE_PARAMS stroke = shape->GetStroke();
377 FILL_T fillMode = shape->GetFillMode();
378 COLOR4D fillColor = shape->GetFillColor();
379 bool isPrivate = shape->IsPrivate();
380
381 switch( shape->GetShape() )
382 {
383 case SHAPE_T::ARC:
384 formatArc( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
385 break;
386
387 case SHAPE_T::CIRCLE:
388 formatCircle( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
389 break;
390
392 formatRect( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
393 break;
394
395 case SHAPE_T::BEZIER:
396 formatBezier(&aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
397 break;
398
399 case SHAPE_T::POLY:
400 formatPoly( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor, true );
401 break;
402
403 default:
405 }
406
407 break;
408 }
409
410 case SCH_PIN_T:
411 savePin( static_cast<SCH_PIN*>( aItem ), aFormatter );
412 break;
413
414 case SCH_TEXT_T:
415 saveText( static_cast<SCH_TEXT*>( aItem ), aFormatter );
416 break;
417
418 case SCH_TEXTBOX_T:
419 saveTextBox( static_cast<SCH_TEXTBOX*>( aItem ), aFormatter );
420 break;
421
422 default:
423 UNIMPLEMENTED_FOR( aItem->GetClass() );
424 }
425}
426
427
429{
430 wxCHECK_RET( aField && aField->Type() == SCH_FIELD_T, "Invalid SCH_FIELD object." );
431
432 wxString fieldName = aField->GetName();
433
434 if( aField->IsMandatory() )
435 fieldName = GetCanonicalFieldName( aField->GetId() );
436
437 aFormatter.Print( "(property %s %s %s (at %s %s %s)",
438 aField->IsPrivate() ? "private" : "",
439 aFormatter.Quotew( fieldName ).c_str(),
440 aFormatter.Quotew( aField->GetText() ).c_str(),
442 aField->GetPosition().x ).c_str(),
444 -aField->GetPosition().y ).c_str(),
445 fmt::format( "{:g}", aField->GetTextAngle().AsDegrees() ).c_str() );
446
447 if( aField->IsNameShown() )
448 aFormatter.Print( "(show_name)" );
449
450 if( !aField->CanAutoplace() )
451 aFormatter.Print( "(do_not_autoplace)" );
452
453 if( !aField->IsVisible() )
454 KICAD_FORMAT::FormatBool( &aFormatter, "hide", true );
455
456 aField->Format( &aFormatter, 0 );
457 aFormatter.Print( ")" );
458}
459
460
462{
463 wxCHECK_RET( aPin && aPin->Type() == SCH_PIN_T, "Invalid SCH_PIN object." );
464
465 aPin->ClearFlags( IS_CHANGED );
466
467 aFormatter.Print( "(pin %s %s (at %s %s %s) (length %s)",
469 getPinShapeToken( aPin->GetShape() ),
471 aPin->GetPosition().x ).c_str(),
473 -aPin->GetPosition().y ).c_str(),
476 aPin->GetLength() ).c_str() );
477
478 if( !aPin->IsVisible() )
479 KICAD_FORMAT::FormatBool( &aFormatter, "hide", true );
480
481 // This follows the EDA_TEXT effects formatting for future expansion.
482 aFormatter.Print( "(name %s (effects (font (size %s %s))))",
483 aFormatter.Quotew( aPin->GetName() ).c_str(),
485 aPin->GetNameTextSize() ).c_str(),
487 aPin->GetNameTextSize() ).c_str() );
488
489 aFormatter.Print( "(number %s (effects (font (size %s %s))))",
490 aFormatter.Quotew( aPin->GetNumber() ).c_str(),
492 aPin->GetNumberTextSize() ).c_str(),
494 aPin->GetNumberTextSize() ).c_str() );
495
496
497 for( const std::pair<const wxString, SCH_PIN::ALT>& alt : aPin->GetAlternates() )
498 {
499 // There was a bug somewhere in the alternate pin code that allowed pin alternates with no
500 // name to be saved in library symbols. This strips any invalid alternates just in case
501 // that code resurfaces.
502 if( alt.second.m_Name.IsEmpty() )
503 continue;
504
505 aFormatter.Print( "(alternate %s %s %s)",
506 aFormatter.Quotew( alt.second.m_Name ).c_str(),
507 getPinElectricalTypeToken( alt.second.m_Type ),
508 getPinShapeToken( alt.second.m_Shape ) );
509 }
510
511 aFormatter.Print( ")" );
512}
513
514
516{
517 wxCHECK_RET( aText && aText->Type() == SCH_TEXT_T, "Invalid SCH_TEXT object." );
518
519 aFormatter.Print( "(text %s %s (at %s %s %d)",
520 aText->IsPrivate() ? "private" : "",
521 aFormatter.Quotew( aText->GetText() ).c_str(),
523 aText->GetPosition().x ).c_str(),
525 -aText->GetPosition().y ).c_str(),
526 aText->GetTextAngle().AsTenthsOfADegree() );
527
528 aText->EDA_TEXT::Format( &aFormatter, 0 );
529 aFormatter.Print( ")" );
530}
531
532
534{
535 wxCHECK_RET( aTextBox && aTextBox->Type() == SCH_TEXTBOX_T, "Invalid SCH_TEXTBOX object." );
536
537 aFormatter.Print( "(text_box %s %s",
538 aTextBox->IsPrivate() ? "private" : "",
539 aFormatter.Quotew( aTextBox->GetText() ).c_str() );
540
541 VECTOR2I pos = aTextBox->GetStart();
542 VECTOR2I size = aTextBox->GetEnd() - pos;
543
544 aFormatter.Print( "(at %s %s %s) (size %s %s) (margins %s %s %s %s)",
547 EDA_UNIT_UTILS::FormatAngle( aTextBox->GetTextAngle() ).c_str(),
554
555 aTextBox->GetStroke().Format( &aFormatter, schIUScale );
556 formatFill( &aFormatter, aTextBox->GetFillMode(), aTextBox->GetFillColor() );
557 aTextBox->EDA_TEXT::Format( &aFormatter, 0 );
558 aFormatter.Print( ")" );
559}
560
561
562void SCH_IO_KICAD_SEXPR_LIB_CACHE::DeleteSymbol( const wxString& aSymbolName )
563{
564 LIB_SYMBOL_MAP::iterator it = m_symbols.find( aSymbolName );
565
566 if( it == m_symbols.end() )
567 THROW_IO_ERROR( wxString::Format( _( "library %s does not contain a symbol named %s" ),
568 m_libFileName.GetFullName(), aSymbolName ) );
569
570 LIB_SYMBOL* symbol = it->second;
571
572 if( symbol->IsRoot() )
573 {
574 LIB_SYMBOL* rootSymbol = symbol;
575
576 // Remove the root symbol and all its children.
577 m_symbols.erase( it );
578
579 LIB_SYMBOL_MAP::iterator it1 = m_symbols.begin();
580
581 while( it1 != m_symbols.end() )
582 {
583 if( it1->second->IsDerived()
584 && it1->second->GetParent().lock() == rootSymbol->SharedPtr() )
585 {
586 delete it1->second;
587 it1 = m_symbols.erase( it1 );
588 }
589 else
590 {
591 it1++;
592 }
593 }
594
595 delete rootSymbol;
596 }
597 else
598 {
599 // Just remove the alias.
600 m_symbols.erase( it );
601 delete symbol;
602 }
603
605 m_isModified = true;
606}
const char * name
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
const EDA_ANGLE & GetTextAngle() const
Definition eda_text.h:146
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:186
virtual void Format(OUTPUTFORMATTER *aFormatter, int aControlBits) const
Output the object to aFormatter in s-expression form.
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:387
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:154
wxString GetKeyWords() const override
Definition lib_symbol.h:182
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:291
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition lib_symbol.h:205
std::vector< struct LIB_SYMBOL_UNIT > GetUnitDrawItems()
Return a list of SCH_ITEM objects separated by unit and convert number.
std::map< int, wxString > & GetUnitDisplayNames()
Definition lib_symbol.h:570
bool IsMultiBodyStyle() const override
Definition lib_symbol.h:594
bool IsLocalPower() const override
wxArrayString GetFPFilters() const
Definition lib_symbol.h:217
const std::vector< wxString > & GetBodyStyleNames() const
Definition lib_symbol.h:607
bool HasDeMorganBodyStyles() const override
Definition lib_symbol.h:604
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:95
EMBEDDED_FILES * GetEmbeddedFiles() override
bool IsGlobalPower() const override
bool GetDuplicatePinNumbersAreJumpers() const
Definition lib_symbol.h:573
LIB_SYMBOL_REF & GetParent()
Definition lib_symbol.h:117
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:580
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
VECTOR2I GetPosition() const override
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).
bool CanAutoplace() const
Definition sch_field.h:213
void SetText(const wxString &aText) override
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)
wxDateTime GetLibModificationTime()
LIB_SYMBOL_MAP m_symbols
wxFileName GetRealFile() const
wxFileName m_libFileName
SCH_IO_LIB_CACHE(const wxString &aLibraryPath)
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:250
wxString GetClass() const override
Return the class name.
Definition sch_item.h:177
int GetNumberTextSize() const
Definition sch_pin.cpp:670
int GetLength() const
Definition sch_pin.cpp:298
const std::map< wxString, ALT > & GetAlternates() const
Definition sch_pin.h:147
bool IsVisible() const
Definition sch_pin.cpp:386
const wxString & GetName() const
Definition sch_pin.cpp:400
PIN_ORIENTATION GetOrientation() const
Definition sch_pin.cpp:263
VECTOR2I GetPosition() const override
Definition sch_pin.cpp:255
int GetNameTextSize() const
Definition sch_pin.cpp:646
const wxString & GetNumber() const
Definition sch_pin.h:124
GRAPHIC_PINSHAPE GetShape() const
Definition sch_pin.cpp:277
ELECTRICAL_PINTYPE GetType() const
Definition sch_pin.cpp:312
STROKE_PARAMS GetStroke() const override
Definition sch_shape.h:58
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.
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale) const
int GetPinNameOffset() const
Definition symbol.h:158
bool GetExcludedFromBoard() const override
Definition symbol.h:192
virtual bool GetShowPinNames() const
Definition symbol.h:164
virtual bool GetShowPinNumbers() const
Definition symbol.h:170
bool GetExcludedFromBOM() const override
Definition symbol.h:186
bool GetExcludedFromSim() const override
Definition symbol.h:180
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.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:46
FILL_T
Definition eda_shape.h:56
const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
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.
KICOMMON_API std::string FormatAngle(const EDA_ANGLE &aAngle)
Convert aAngle from board units to a string appropriate for writing to file.
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:...
@ CTX_NO_SPACE
@ USER
The field ID hasn't been set yet; field is invalid.
wxString GetCanonicalFieldName(FIELD_T aFieldType)
wxLogTrace helper definitions.
@ SCH_FIELD_T
Definition typeinfo.h:152
@ SCH_SHAPE_T
Definition typeinfo.h:151
@ SCH_TEXT_T
Definition typeinfo.h:153
@ SCH_TEXTBOX_T
Definition typeinfo.h:154
@ SCH_PIN_T
Definition typeinfo.h:155
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695