26#include <fmt/format.h>
27#include <wx/mstream.h>
31#include <schematic_lexer.h>
33using namespace TSCHEMATIC_T;
96 aFormatter->
Print(
"(fill (type %s) (color %d %d %d %s))", fillType,
KiROUND( aFillColor.
r * 255.0 ),
102 aFormatter->
Print(
"(fill (type %s))", fillType );
135 default: wxFAIL_MSG(
"Missing symbol library pin connection type" );
164 default: wxFAIL_MSG(
"Missing symbol library pin shape type" );
173 switch( aOrientation )
179 default: wxFAIL_MSG(
"Missing symbol library pin orientation type" );
return ANGLE_0;
197 default: wxFAIL;
return SCHEMATIC_LEXER::TokenName( T_passive );
211 default: wxFAIL;
return ANGLE_0;
220 case SCH_TEXT_T:
return SCHEMATIC_LEXER::TokenName( T_text );
221 case SCH_LABEL_T:
return SCHEMATIC_LEXER::TokenName( T_label );
223 case SCH_HIER_LABEL_T:
return SCHEMATIC_LEXER::TokenName( T_hierarchical_label );
225 default: wxFAIL;
return SCHEMATIC_LEXER::TokenName( T_text );
246 aFormatter->
Print(
"(arc %s (start %s) (mid %s) (end %s)", aIsPrivate ?
"private" :
"",
251 formatFill( aFormatter, aFillMode, aFillColor );
256 aFormatter->
Print(
")" );
264 aFormatter->
Print(
"(circle %s (center %s) (radius %s)", aIsPrivate ?
"private" :
"",
268 formatFill( aFormatter, aFillMode, aFillColor );
273 aFormatter->
Print(
")" );
280 aFormatter->
Print(
"(rectangle %s (start %s) (end %s)", aIsPrivate ?
"private" :
"",
285 formatFill( aFormatter, aFillMode, aFillColor );
290 aFormatter->
Print(
")" );
298 aFormatter->
Print(
"(bezier %s (pts ", aIsPrivate ?
"private" :
"" );
303 aFormatter->
Print(
"(xy %s)",
formatIU( pt, aInvertY ).c_str() );
306 aFormatter->
Print(
")" );
309 formatFill( aFormatter, aFillMode, aFillColor );
314 aFormatter->
Print(
")" );
322 aFormatter->
Print(
"(polyline %s (pts ", aIsPrivate ?
"private" :
"" );
330 wxFAIL_MSG(
"Polyline has no outlines" );
337 aFormatter->
Print(
"(xy %s)",
formatIU( pt, aInvertY ).c_str() );
343 aFormatter->
Print(
")" );
346 formatFill( aFormatter, aFillMode, aFillColor );
351 aFormatter->
Print(
")" );
356 bool aIncludeData =
true );
368 wxCHECK_RET( aSymbol,
"Invalid LIB_SYMBOL pointer." );
378 std::vector<SCH_FIELD*> orderedFields;
382 if( !aLibName.IsEmpty() )
388 wxCHECK2( unitId.
Parse( aLibName ) < 0, );
395 aFormatter.
Print(
"(symbol %s",
name.c_str() );
398 aFormatter.
Print(
"(power global)" );
400 aFormatter.
Print(
"(power local)" );
404 aFormatter.
Print(
"(body_styles " );
408 aFormatter.
Print(
"demorgan" );
413 aFormatter.
Print(
"%s ", aFormatter.
Quotew( bodyStyle ).c_str() );
416 aFormatter.
Print(
")" );
420 aFormatter.
Print(
"(pin_numbers (hide yes))" );
425 aFormatter.
Print(
"(pin_names" );
437 aFormatter.
Print(
")" );
452 aFormatter.
Print(
"(jumper_pin_groups" );
456 aFormatter.
Print(
"(" );
458 for(
const wxString& padName :
group.GetNames() )
459 aFormatter.
Print(
"%s ", aFormatter.
Quotew( padName ).c_str() );
461 aFormatter.
Print(
")" );
464 aFormatter.
Print(
")" );
485 std::sort( units.begin(), units.end(),
488 if( a.m_unit == b.m_unit )
489 return a.m_bodyStyle < b.m_bodyStyle;
491 return a.m_unit < b.m_unit;
500 aFormatter.
Print(
"(symbol %s_%d_%d\"",
name.c_str(), unit.m_unit, unit.m_bodyStyle );
506 aFormatter.
Print(
"(unit_name %s)", aFormatter.
Quotes(
name ).c_str() );
515 std::multiset<
SCH_ITEM*,
decltype( cmp )> save_map( cmp );
517 for(
SCH_ITEM* item : unit.m_items )
518 save_map.insert( item );
523 aFormatter.
Print(
")" );
533 std::shared_ptr<LIB_SYMBOL> parent = aSymbol->
GetParent().lock();
537 aFormatter.
Print(
"(symbol %s (extends %s)",
name.c_str(), aFormatter.
Quotew( parent->GetName() ).c_str() );
552 aFormatter.
Print(
")" );
558 wxCHECK_RET( aSymbol,
"Invalid LIB_SYMBOL pointer." );
570 if( !fpFilters.IsEmpty() )
574 for(
const wxString&
filter : fpFilters )
582 tmp +=
" " + curr_filter;
595 wxCHECK_RET( aItem,
"Invalid SCH_ITEM pointer." );
597 switch( aItem->
Type() )
609 case SHAPE_T::ARC:
formatArc( &aFormatter, shape, isPrivate, stroke, fillMode, fillColor,
true );
break;
638 wxCHECK_RET( aField && aField->
Type() ==
SCH_FIELD_T,
"Invalid SCH_FIELD object." );
640 wxString fieldName = aField->
GetName();
645 aFormatter.
Print(
"(property %s %s %s (at %s %s %s)", aField->
IsPrivate() ?
"private" :
"",
659 aFormatter.
Print(
")" );
665 wxCHECK_RET( aPin && aPin->
Type() ==
SCH_PIN_T,
"Invalid SCH_PIN object." );
680 aFormatter.
Print(
"(name %s (effects (font (size %s %s))))", aFormatter.
Quotew( aPin->
GetName() ).c_str(),
684 aFormatter.
Print(
"(number %s (effects (font (size %s %s))))", aFormatter.
Quotew( aPin->
GetNumber() ).c_str(),
689 for(
const std::pair<const wxString, SCH_PIN::ALT>& alt : aPin->
GetAlternates() )
694 if( alt.second.m_Name.IsEmpty() )
697 aFormatter.
Print(
"(alternate %s %s %s)", aFormatter.
Quotew( alt.second.m_Name ).c_str(),
701 aFormatter.
Print(
")" );
707 wxCHECK_RET( aText && aText->
Type() ==
SCH_TEXT_T,
"Invalid SCH_TEXT object." );
709 aFormatter.
Print(
"(text %s %s (at %s %s %d)", aText->
IsPrivate() ?
"private" :
"",
716 aFormatter.
Print(
")" );
722 wxCHECK_RET( aTextBox && aTextBox->
Type() ==
SCH_TEXTBOX_T,
"Invalid SCH_TEXTBOX object." );
724 aFormatter.
Print(
"(text_box %s %s", aTextBox->
IsPrivate() ?
"private" :
"",
730 aFormatter.
Print(
"(at %s %s %s) (size %s %s) (margins %s %s %s %s)",
744 aFormatter.
Print(
")" );
769 formatter.
Print(
"(kicad_symbol_lib (version %d) (generator \"kicad_symbol_editor\") "
770 "(generator_version \"%s\")",
776 formatter.
Print(
")" );
783 wxCHECK_RET( aSheet !=
nullptr,
"NULL SCH_SHEET* object." );
784 wxCHECK_RET(
m_schematic !=
nullptr,
"NULL SCHEMATIC* object." );
797 m_schematic->GetEmbeddedFiles()->ClearEmbeddedFonts();
799 m_out->Print(
"(kicad_sch (version %d) (generator \"eeschema\") (generator_version %s)",
808 m_out->Print(
"(lib_symbols" );
810 for(
const auto& [libItemName, libSymbol] : screen->
GetLibSymbols() )
818 if( a->
Type() != b->Type() )
819 return a->
Type() < b->Type();
821 return a->
m_Uuid < b->m_Uuid;
824 std::multiset<
SCH_ITEM*,
decltype( cmp )> save_map( cmp );
830 save_map.insert( item );
835 switch( item->Type() )
868 default: wxASSERT(
"Unexpected schematic object type in SCH_WRITER_V10::Format()" );
874 std::vector<SCH_SHEET_INSTANCE> instances;
896 wxCHECK_RET( aSymbol !=
nullptr &&
m_out !=
nullptr,
"" );
902 if( symbol_name.size() )
908 libName =
"_NONAME_";
923 m_out->Print(
"(symbol" );
930 m_out->Print(
"(lib_id %s) (at %s %s %s)",
939 if( mirrorX || mirrorY )
941 m_out->Print(
"(mirror %s %s)", mirrorX ?
"x" :
"", mirrorY ?
"y" :
"" );
952 wxASSERT( parentScreen );
956 std::optional<SCH_SHEET_PATH> ordinalPath =
m_schematic->Hierarchy().GetOrdinalPath( parentScreen );
963 aSymbol->
GetInstance( ordinalInstance, ordinalPath->Path() );
968 int unit = ordinalInstance.
m_Unit;
970 if( aForClipboard && aRelativePath )
975 unit = unitInstance.
m_Unit;
978 m_out->Print(
"(unit %d)", unit );
994 std::vector<SCH_FIELD*> orderedFields;
995 aSymbol->
GetFields( orderedFields,
false );
1000 wxString value = field->GetText();
1025 field->SetText( value );
1031 field->SetText( value );
1034 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol->
GetRawPins() )
1039 if(
pin->GetAlt().IsEmpty() || (
pin->GetAlt() ==
pin->GetBaseName() ) )
1041 m_out->Print(
"(pin %s",
m_out->Quotew(
pin->GetNumber() ).c_str() );
1043 m_out->Print(
")" );
1047 m_out->Print(
"(pin %s",
m_out->Quotew(
pin->GetNumber() ).c_str() );
1049 m_out->Print(
"(alternate %s))",
m_out->Quotew(
pin->GetAlt() ).c_str() );
1055 std::map<KIID, std::vector<SCH_SYMBOL_INSTANCE>> projectInstances;
1056 std::set<KIID> currentProjectKeys;
1058 m_out->Print(
"(instances" );
1060 wxString projectName;
1067 if( rootSheetUuid ==
niluuid )
1070 currentProjectKeys.insert( sheet->m_Uuid );
1074 currentProjectKeys.insert( rootSheetUuid );
1080 wxCHECK2( inst.m_Path.size(),
continue );
1092 if( rootSheetUuid ==
niluuid && !pathToCheck.empty() && pathToCheck[0] ==
niluuid )
1094 if( pathToCheck.size() > 1 )
1096 pathToCheck.erase( pathToCheck.begin() );
1108 bool belongsToThisProject = currentProjectKeys.count( pathToCheck[0] );
1113 if( !aForClipboard && isOrphaned )
1118 auto it = projectInstances.find(
projectKey );
1120 if( it == projectInstances.end() )
1123 it->second.emplace_back( inst );
1126 for(
auto& [uuid, instances] : projectInstances )
1128 wxCHECK2( instances.size(),
continue );
1131 std::sort( instances.begin(), instances.end(),
1134 return aLhs.m_Path < aRhs.m_Path;
1137 if( currentProjectKeys.count( uuid ) )
1138 projectName =
m_schematic->Project().GetProjectName();
1140 projectName = instances[0].m_ProjectName;
1142 m_out->Print(
"(project %s",
m_out->Quotew( projectName ).c_str() );
1149 if( aForClipboard && aRelativePath )
1154 m_out->Print(
"(path %s (reference %s) (unit %d)",
m_out->Quotew(
path ).c_str(),
1155 m_out->Quotew( instance.m_Reference ).c_str(), instance.m_Unit );
1157 if( !instance.m_Variants.empty() )
1159 for(
const auto& [
name, variant] : instance.m_Variants )
1161 m_out->Print(
"(variant (name %s)",
m_out->Quotew(
name ).c_str() );
1163 if( variant.m_DNP != aSymbol->
GetDNP() )
1178 for(
const auto& [fname, fvalue] : variant.m_Fields )
1180 m_out->Print(
"(field (name %s) (value %s))",
m_out->Quotew( fname ).c_str(),
1181 m_out->Quotew( fvalue ).c_str() );
1184 m_out->Print(
")" );
1188 m_out->Print(
")" );
1191 m_out->Print(
")" );
1194 m_out->Print(
")" );
1197 m_out->Print(
")" );
1203 wxCHECK_RET( aField !=
nullptr &&
m_out !=
nullptr,
"" );
1210 fieldName = aField->
GetName();
1212 m_out->Print(
"(property %s %s %s (at %s %s %s)", aField->
IsPrivate() ?
"private" :
"",
1231 m_out->Print(
")" );
1237 wxCHECK_RET(
m_out !=
nullptr,
"" );
1244 wxCHECK_RET(
image !=
nullptr,
"wxImage* is NULL" );
1246 m_out->Print(
"(image (at %s %s)",
1258 m_out->Print(
"%s", fmt::format(
"(scale {:g})", refImage.
GetImageScale() ).c_str() );
1262 wxMemoryOutputStream stream;
1267 m_out->Print(
")" );
1273 wxCHECK_RET( aSheet !=
nullptr &&
m_out !=
nullptr,
"" );
1275 m_out->Print(
"(sheet (at %s %s) (size %s %s)",
1317 m_out->Print(
")" );
1321 std::vector<SCH_SHEET_INSTANCE> sheetInstances = aSheet->
GetInstances();
1323 auto it = sheetInstances.begin();
1325 while( it != sheetInstances.end() )
1327 if( it->m_Path.size() == 0 )
1328 it = sheetInstances.erase( it );
1333 if( !sheetInstances.empty() )
1335 m_out->Print(
"(instances" );
1337 KIID lastProjectUuid;
1339 bool inProjectClause =
false;
1341 std::set<KIID> currentProjectKeys;
1343 if( rootSheetUuid ==
niluuid )
1346 currentProjectKeys.insert( sheet->m_Uuid );
1350 currentProjectKeys.insert( rootSheetUuid );
1353 for(
size_t i = 0; i < sheetInstances.size(); i++ )
1360 bool belongsToThisProject =
1361 !sheetInstances[i].m_Path.empty() && currentProjectKeys.count( sheetInstances[i].m_Path[0] );
1366 && ( ( i + 1 == sheetInstances.size() ) || lastProjectUuid != sheetInstances[i + 1].m_Path[0] ) )
1368 m_out->Print(
")" );
1369 inProjectClause =
false;
1375 if( lastProjectUuid != sheetInstances[i].m_Path[0] )
1377 wxString projectName;
1379 if( belongsToThisProject )
1380 projectName =
m_schematic->Project().GetProjectName();
1382 projectName = sheetInstances[i].m_ProjectName;
1384 lastProjectUuid = sheetInstances[i].m_Path[0];
1385 m_out->Print(
"(project %s",
m_out->Quotew( projectName ).c_str() );
1386 inProjectClause =
true;
1389 wxString
path = sheetInstances[i].m_Path.AsString();
1391 m_out->Print(
"(path %s (page %s)",
m_out->Quotew(
path ).c_str(),
1392 m_out->Quotew( sheetInstances[i].m_PageNumber ).c_str() );
1394 if( !sheetInstances[i].m_Variants.empty() )
1396 for(
const auto& [
name, variant] : sheetInstances[i].m_Variants )
1398 m_out->Print(
"(variant (name %s)",
m_out->Quotew(
name ).c_str() );
1400 if( variant.m_DNP != aSheet->
GetDNP() )
1409 for(
const auto& [fname, fvalue] : variant.m_Fields )
1411 m_out->Print(
"(field (name %s) (value %s))",
m_out->Quotew( fname ).c_str(),
1412 m_out->Quotew( fvalue ).c_str() );
1415 m_out->Print(
")" );
1419 m_out->Print(
")" );
1422 && ( ( i + 1 == sheetInstances.size() ) || lastProjectUuid != sheetInstances[i + 1].m_Path[0] ) )
1424 m_out->Print(
")" );
1425 inProjectClause =
false;
1429 m_out->Print(
")" );
1432 m_out->Print(
")" );
1438 wxCHECK_RET( aJunction !=
nullptr &&
m_out !=
nullptr,
"" );
1440 m_out->Print(
"(junction (at %s %s) (diameter %s) (color %d %d %d %s)",
1448 m_out->Print(
")" );
1454 wxCHECK_RET( aNoConnect !=
nullptr &&
m_out !=
nullptr,
"" );
1456 m_out->Print(
"(no_connect (at %s %s)",
1461 m_out->Print(
")" );
1467 wxCHECK_RET( aBusEntry !=
nullptr &&
m_out !=
nullptr,
"" );
1470 if( aBusEntry->
GetClass() ==
"SCH_BUS_BUS_ENTRY" )
1479 m_out->Print(
"(bus_entry (at %s %s) (size %s %s)",
1487 m_out->Print(
")" );
1493 wxCHECK_RET( aShape !=
nullptr &&
m_out !=
nullptr,
"" );
1529 wxCHECK_RET( aRuleArea !=
nullptr &&
m_out !=
nullptr,
"" );
1531 m_out->Print(
"(rule_area " );
1540 m_out->Print(
")" );
1546 wxCHECK_RET( aLine !=
nullptr &&
m_out !=
nullptr,
"" );
1554 case LAYER_BUS: lineType =
"bus";
break;
1560 m_out->Print(
"(%s (pts (xy %s %s) (xy %s %s))",
TO_UTF8( lineType ),
1568 m_out->Print(
")" );
1574 wxCHECK_RET( aText !=
nullptr &&
m_out !=
nullptr,
"" );
1617 if( label && !label->
GetFields().empty() )
1634 m_out->Print(
")" );
1640 wxCHECK_RET( aTextBox !=
nullptr &&
m_out !=
nullptr,
"" );
1650 m_out->Print(
"(at %s %s %s) (size %s %s) (margins %s %s %s %s)",
1662 m_out->Print(
"(span %d %d)", cell->GetColSpan(), cell->GetRowSpan() );
1670 m_out->Print(
")" );
1685 for(
int row = 0; row < aTable->
GetRowCount(); ++row )
1687 for(
int col = 0; col < aTable->
GetColCount(); ++col )
1693 minRow = std::min( minRow, row );
1694 maxRow = std::max( maxRow, row );
1695 minCol = std::min( minCol, col );
1696 maxCol = std::max( maxCol, col );
1705 wxCHECK_MSG( maxCol >= minCol && maxRow >= minRow, , wxT(
"No selected cells!" ) );
1709 for(
int row = minRow; row <= maxRow; row++ )
1714 for(
int col = minCol; col <= maxCol; col++ )
1721 wxCHECK_RET( aTable !=
nullptr &&
m_out !=
nullptr,
"" );
1725 m_out->Print(
"(border" );
1732 m_out->Print(
")" );
1734 m_out->Print(
"(separators" );
1741 m_out->Print(
")" );
1743 m_out->Print(
"(column_widths" );
1745 for(
int col = 0; col < aTable->
GetColCount(); ++col )
1750 m_out->Print(
")" );
1752 m_out->Print(
"(row_heights" );
1754 for(
int row = 0; row < aTable->
GetRowCount(); ++row )
1759 m_out->Print(
")" );
1763 m_out->Print(
"(cells" );
1768 m_out->Print(
")" );
1769 m_out->Print(
")" );
1792 wxArrayString memberIds;
1795 memberIds.Add( member->m_Uuid.AsString() );
1799 m_out->Print(
"(members" );
1801 for(
const wxString& memberId : memberIds )
1802 m_out->Print(
" %s",
m_out->Quotew( memberId ).c_str() );
1804 m_out->Print(
")" );
1805 m_out->Print(
")" );
1811 if( aInstances.size() )
1813 m_out->Print(
"(sheet_instances" );
1817 wxString
path = instance.m_Path.AsString();
1819 if(
path.IsEmpty() )
1822 m_out->Print(
"(path %s (page %s))",
m_out->Quotew(
path ).c_str(),
1823 m_out->Quotew( instance.m_PageNumber ).c_str() );
1826 m_out->Print(
")" );
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
This class handle bitmap images in KiCad.
bool SaveImageData(wxOutputStream &aOutStream) const
Write the bitmap data to aOutStream.
int AsTenthsOfADegree() const
const LIB_ID & GetDesignBlockLibId() const
std::unordered_set< EDA_ITEM * > & GetItems()
bool HasDesignBlockLink() const
A base class for most all the KiCad significant classes used in schematics and boards.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
EDA_ITEM * GetParent() const
EDA_ITEM_FLAGS GetFlags() const
const VECTOR2I & GetBezierC2() const
FILL_T GetFillMode() const
SHAPE_POLY_SET & GetPolyShape()
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
COLOR4D GetFillColor() const
wxString SHAPE_T_asString() const
const VECTOR2I & GetBezierC1() const
int GetCornerRadius() const
VECTOR2I GetArcMid() const
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual bool IsVisible() const
virtual int GetTextHeight() const
virtual void SetVisible(bool aVisible)
virtual EDA_ANGLE GetTextAngle() const
void ClearEmbeddedFonts()
Remove all embedded fonts from the collection.
const std::map< wxString, std::shared_ptr< EMBEDDED_FILE > > & EmbeddedFileMap() const
Provide an iterable view of the file collection.
bool GetAreFontsEmbedded() const
Represents an (ordered) list of JUMPER_GROUP objects.
const std::vector< JUMPER_GROUP > & GetAll() const
Represents a group of jumper pins or pads, keyed by name.
A color representation with 4 components: red, green, blue, alpha.
bool MakeRelativeTo(const KIID_PATH &aPath)
wxString AsString() const
wxString AsString() const
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
const UTF8 & GetLibItemName() const
Define a library symbol object.
const wxString & GetRawKeyWords() const
Return only this symbol's keywords, without inheriting from its parent.
const LIB_ID & GetLibId() const override
std::weak_ptr< LIB_SYMBOL > & GetParent()
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.
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
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()
bool IsMultiBodyStyle() const override
JUMPER_GROUP_SET & JumperPinGroups()
Each jumper pin group is a set of pin numbers that should be treated as internally connected.
bool IsLocalPower() const override
wxArrayString GetFPFilters() const
const std::vector< wxString > & GetBodyStyleNames() const
bool HasDeMorganBodyStyles() const override
EMBEDDED_FILES * GetEmbeddedFiles() override
bool IsGlobalPower() const override
bool GetDuplicatePinNumbersAreJumpers() const
void EmbedFonts() override
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
VECTOR2I GetPosition() const
const BITMAP_BASE & GetImage() const
Get the underlying image.
double GetImageScale() const
Holds all the data relating to one schematic.
std::vector< SCH_SHEET * > GetTopLevelSheets() const
Get the list of top-level sheets.
Object to handle a bitmap image that can be inserted in a schematic.
REFERENCE_IMAGE & GetReferenceImage()
Base class for a bus or wire entry.
VECTOR2I GetPosition() const override
virtual STROKE_PARAMS GetStroke() const override
VECTOR2I GetPosition() const override
virtual const wxString & GetText() const override
Return the string associated with the text object.
wxString GetUntranslatedName() const
Get the untranslated field name for storage, variable look-up, etc.
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
bool CanAutoplace() const
void SetText(const wxString &aText) override
A set of SCH_ITEMs (i.e., without duplicates).
Base class for any item which can be embedded within the SCHEMATIC container class,...
bool IsLocked() const override
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
AUTOPLACE_ALGO GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
wxString GetClass() const override
Return the class name.
VECTOR2I GetPosition() const override
KIGFX::COLOR4D GetColor() const
SPIN_STYLE GetSpinStyle() const
LABEL_FLAG_SHAPE GetShape() const
std::vector< SCH_FIELD > & GetFields()
Segment description base class to describe items which have 2 end points (track, wire,...
virtual STROKE_PARAMS GetStroke() const override
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
void SetEndPoint(const VECTOR2I &aPosition)
VECTOR2I GetPosition() const override
int GetNumberTextSize() const
const std::map< wxString, ALT > & GetAlternates() const
const wxString & GetName() const
PIN_ORIENTATION GetOrientation() const
VECTOR2I GetPosition() const override
int GetNameTextSize() const
const wxString & GetNumber() const
GRAPHIC_PINSHAPE GetShape() const
ELECTRICAL_PINTYPE GetType() const
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flag.
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
const PAGE_INFO & GetPageSettings() const
const std::map< wxString, LIB_SYMBOL * > & GetLibSymbols() const
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
EE_RTREE & Items()
Get the full RTree, usually for iterating.
const KIID & GetUuid() const
TITLE_BLOCK & GetTitleBlock()
STROKE_PARAMS GetStroke() const override
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
std::optional< SCH_SHEET_PATH > GetSheetPathByKIIDPath(const KIID_PATH &aPath, bool aIncludeLastSheet=true) const
Finds a SCH_SHEET_PATH that matches the provided KIID_PATH.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
bool HasRootInstance() const
Check to see if this sheet has a root sheet instance.
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
SCH_SCREEN * GetScreen() const
VECTOR2I GetPosition() const override
const SCH_SHEET_INSTANCE & GetRootInstance() const
Return the root sheet instance data.
KIGFX::COLOR4D GetBorderColor() const
bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flags.
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
int GetBorderWidth() const
std::vector< SCH_SHEET_PIN * > & GetPins()
const std::vector< SCH_SHEET_INSTANCE > & GetInstances() const
KIGFX::COLOR4D GetBackgroundColor() const
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
bool UseLibIdLookup() const
wxString GetSchSymbolLibraryName() const
bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
VECTOR2I GetPosition() const override
const LIB_ID & GetLibId() const override
bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
int GetOrientation() const override
Get the display symbol orientation.
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flag.
wxString GetPrefix() const
void SetRowHeight(int aRow, int aHeight)
const STROKE_PARAMS & GetSeparatorsStroke() const
void SetColCount(int aCount)
bool StrokeExternal() const
int GetRowHeight(int aRow) const
void SetColWidth(int aCol, int aWidth)
std::vector< SCH_TABLECELL * > GetCells() const
int GetColWidth(int aCol) const
const STROKE_PARAMS & GetBorderStroke() const
bool StrokeHeaderSeparator() const
SCH_TABLECELL * GetCell(int aRow, int aCol) const
bool StrokeColumns() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
int GetMarginBottom() const
int GetMarginLeft() const
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
int GetMarginRight() const
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
VECTOR2I GetPosition() const override
void saveTextBox(SCH_TEXTBOX *aTextBox)
void saveBitmap(const SCH_BITMAP &aBitmap)
void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic)
void saveText(SCH_TEXT *aText)
static constexpr int FORMAT_VERSION
void saveTable(SCH_TABLE *aTable)
void Format(SCH_SHEET *aSheet)
void SaveSymbolLibrary(const wxString &aFileName, const std::vector< LIB_SYMBOL * > &aSymbols)
void saveSymbol(SCH_SYMBOL *aSymbol, const SCHEMATIC &aSchematic, const SCH_SHEET_LIST &aSheetList, bool aForClipboard, const SCH_SHEET_PATH *aRelativePath=nullptr)
void saveGroup(SCH_GROUP *aGroup)
void saveLine(SCH_LINE *aLine)
void saveRuleArea(SCH_RULE_AREA *aRuleArea)
static constexpr int SYMBOL_LIB_VERSION
void saveInstances(const std::vector< SCH_SHEET_INSTANCE > &aInstances)
void saveSheet(SCH_SHEET *aSheet, const SCH_SHEET_LIST &aSheetList)
void saveJunction(SCH_JUNCTION *aJunction)
void saveBusEntry(SCH_BUS_ENTRY_BASE *aBusEntry)
void saveNoConnect(SCH_NO_CONNECT *aNoConnect)
void saveField(SCH_FIELD *aField)
void saveShape(SCH_SHAPE *aShape)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
bool IsClosed() const override
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
int GetPinNameOffset() const
virtual bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
virtual bool GetShowPinNames() const
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
virtual bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
virtual bool GetShowPinNumbers() const
#define DEFAULT_PIN_NAME_OFFSET
The offset of the pin name string from the end of the pin in mils.
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_270
static constexpr EDA_ANGLE ANGLE_180
@ FILLED_WITH_BG_BODYCOLOR
@ FILLED_SHAPE
Fill with object color.
#define IS_CHANGED
Item was edited, and modified.
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
#define UNIMPLEMENTED_FOR(type)
KICOMMON_API std::string FormatAngle(const EDA_ANGLE &aAngle)
Convert aAngle from board units to a string appropriate for writing to file.
KICOMMON_API std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue, EDA_DATA_TYPE aDataType=EDA_DATA_TYPE::DISTANCE)
Converts aValue from internal units to a string appropriate for writing to file.
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
@ PT_INPUT
usual pin input: must be connected
@ PT_NC
not connected (must be left open)
@ PT_TRISTATE
tri state bus pin
@ PT_NIC
not internally connected (may be connected to anything)
@ PT_BIDI
input or output (like port for a microprocessor)
@ PT_OPENEMITTER
pin type open emitter
@ PT_POWER_OUT
output of a regulator: intended to be connected to power input pins
@ PT_OPENCOLLECTOR
pin type open collector
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
PIN_ORIENTATION
The symbol library pin object orientations.
@ PIN_UP
The pin extends upwards from the connection point: Probably on the bottom side of the symbol.
@ PIN_RIGHT
The pin extends rightwards from the connection point.
@ PIN_LEFT
The pin extends leftwards from the connection point: Probably on the right side of the symbol.
@ PIN_DOWN
The pin extends downwards from the connection: Probably on the top side of the symbol.
Class to handle a set of SCH_ITEMs.
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, bool aLocked)
void formatCircle(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aCircle, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid, bool aLocked)
const char * getSheetPinShapeToken(LABEL_FLAG_SHAPE aShape)
void formatRect(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aRect, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid, bool aLocked)
const char * getPinElectricalTypeToken(ELECTRICAL_PINTYPE aType)
const char * getTextTypeToken(KICAD_T 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, bool aLocked)
std::string formatIU(const int &aValue)
void formatPoly(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aPolyLine, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid, bool aLocked)
EDA_ANGLE getSheetPinAngle(SHEET_SIDE aSide)
void formatFill(OUTPUTFORMATTER *aFormatter, FILL_T aFillMode, const COLOR4D &aFillColor)
Fill token formatting helper.
const char * getPinShapeToken(GRAPHIC_PINSHAPE aShape)
static const char * emptyString
LABEL_FLAG_SHAPE
Label and flag shapes used with text objects.
SHEET_SIDE
Define the edge of the sheet that the sheet pin is positioned.
std::string toUTFTildaText(const wxString &txt)
Convert a wxString to UTF8 and replace any control characters with a ~, where a control character is ...
static const char * getTextTypeToken(KICAD_T aType)
static EDA_ANGLE getSheetPinAngle(SHEET_SIDE aSide)
static void formatFill(OUTPUTFORMATTER *aFormatter, FILL_T aFillMode, const COLOR4D &aFillColor)
static void formatArc(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aArc, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid=niluuid)
static void formatPoly(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aPolyLine, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid=niluuid)
static EDA_ANGLE getPinAngle(PIN_ORIENTATION aOrientation)
static void formatCircle(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aCircle, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid=niluuid)
static void libSaveField(SCH_FIELD *aField, OUTPUTFORMATTER &aFormatter)
static void libSaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, const wxString &aLibName=wxEmptyString, bool aIncludeData=true)
static const char * getPinShapeToken(GRAPHIC_PINSHAPE aShape)
static void formatBezier(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aBezier, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid=niluuid)
static std::string formatIU(const int &aValue)
static void libSaveText(SCH_TEXT *aText, OUTPUTFORMATTER &aFormatter)
static void formatRect(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aRect, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid=niluuid)
static void libSaveTextBox(SCH_TEXTBOX *aTextBox, OUTPUTFORMATTER &aFormatter)
static void libSaveDcmInfoAsFields(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter)
static const char * getPinElectricalTypeToken(ELECTRICAL_PINTYPE aType)
static void libSavePin(SCH_PIN *aPin, OUTPUTFORMATTER &aFormatter)
static void libSaveSymbolDrawItem(SCH_ITEM *aItem, OUTPUTFORMATTER &aFormatter)
static const char * getSheetPinShapeToken(LABEL_FLAG_SHAPE aShape)
static wxString projectKey(const wxString &aFullPath)
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
std::string EscapedUTF8(const wxString &aString)
Return an 8 bit UTF8 string given aString in Unicode form.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
A simple container for sheet instance information.
A simple container for schematic symbol instance information.
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ USER
The field ID hasn't been set yet; field is invalid.
@ REFERENCE
Field Reference of part, i.e. "IC21".
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I