106 return static_cast<const SCH_SHAPE&
>( aItem ).IsHatchedFill();
113 if( !aPoints.empty() && aPoints.front() != aPoints.back() )
114 aPoints.push_back( aPoints.front() );
131 std::vector<VECTOR2I> points(
chain.CPoints().begin(),
chain.CPoints().end() );
180 if( !aNumber.StartsWith( wxT(
"[" ) ) )
190 for(
size_t i = 0; i + 1 < aNumber.length(); ++i )
192 if( aNumber[i] !=
'\\' )
197 wxString
next( aNumber[i + 1] );
218 return valid && !( expanded.size() == 1 && expanded.front() == aNumber );
240 std::vector<SCH_SHAPE*> ellipses;
245 ellipses.push_back(
static_cast<SCH_SHAPE*
>( &item ) );
306 std::vector<SCH_SHAPE*> rects;
311 rects.push_back(
static_cast<SCH_SHAPE*
>( &item ) );
415 std::vector<SCH_SYMBOL*> symbols;
420 symbols.push_back(
static_cast<SCH_SYMBOL*
>( item ) );
423 std::map<std::pair<wxString, int>,
LIB_SYMBOL*> bakedSymbols;
427 wxCHECK_RET( symbol->GetLibSymbolRef() && !symbol->IsMissingLibSymbol(),
428 wxT(
"Cannot bake a body style without its library symbol." ) );
430 const wxString sourceName = symbol->GetSchSymbolLibraryName();
431 const int bodyStyle = symbol->GetBodyStyle();
432 const auto key = std::make_pair( sourceName, bodyStyle );
439 baked = symbol->GetLibSymbolRef()->
Flatten().release();
440 std::vector<SCH_ITEM*> remove;
444 if( item.GetBodyStyle() && item.GetBodyStyle() != bodyStyle )
445 remove.push_back( &item );
446 else if( item.GetBodyStyle() == bodyStyle )
456 const wxString baseName = wxString::Format( wxT(
"%s__KiCad9_body_%d" ), sourceName, bodyStyle );
457 wxString
name = baseName;
460 name = wxString::Format( wxT(
"%s_%d" ), baseName, suffix );
467 aScreen->
Remove( symbol );
473 symbol->SetLibSymbol(
new LIB_SYMBOL( *baked ) );
474 aScreen->
Append( symbol );
497 if(
static_cast<const SCH_SYMBOL*
>( item )->GetExcludedFromPosFiles() )
514 static_cast<SCH_SYMBOL*
>( item )->SetExcludedFromPosFiles(
false );
534 if(
group->AsEdaItem()->IsLocked() )
561 item->SetLocked(
false );
590 std::vector<SCH_SHAPE*> ellipses;
595 ellipses.push_back(
static_cast<SCH_SHAPE*
>( item ) );
621 if(
static_cast<SCH_SHAPE*
>( item )->IsHatchedFill() )
664 for(
const auto& [
name, variant] : instance.m_Variants )
666 if( !variant.m_PinMapOverride.IsDefault() )
672 return lib && ( lib->GetPinMaps() !=
PIN_MAP_SET() || !lib->GetAssociatedFootprints().empty() );
744 return static_cast<int>( std::distance( groups.begin(), groups.end() ) );
750 std::vector<SCH_GROUP*> groups;
753 groups.push_back(
static_cast<SCH_GROUP*
>( item ) );
815 std::vector<SCH_SHAPE*> rects;
820 rects.push_back(
static_cast<SCH_SHAPE*
>( item ) );
913 std::vector<SCH_ITEM*> remove;
917 if( aMatches( &item ) )
918 remove.push_back( &item );
929 std::vector<SCH_ITEM*> remove;
933 if( aMatches( item ) )
934 remove.push_back( item );
941 group->RemoveItem( item );
1026 aVisit(
const_cast<LIB_SYMBOL*
>( aSymbol ) );
1029 aVisit(
const_cast<SCH_ITEM*
>( &item ) );
1035 std::set<EDA_ITEM*> visited;
1038 if( visited.insert( item ).second )
1045 item->RunOnChildren(
1063 const wxString token = aToken.AfterLast(
':' );
1064 return token.StartsWith( wxT(
"PROPERTY." ) ) || token == wxT(
"SYMBOL_IS_POWER" )
1065 || token == wxT(
"SYMBOL_IS_LOCAL_POWER" );
1072 std::function<bool( wxString* )> scan = [&]( wxString* token )
1084 std::function<bool( wxString* )> preserve = []( wxString* )
1094 return aText.Contains( wxT(
"\\${" ) ) || aText.Contains( wxT(
"\\@{" ) );
1099 std::set<wxString>& aVisiting,
const TITLE_BLOCK* aTitles =
nullptr )
1102 std::function<bool( wxString* )> scan = [&]( wxString* token )
1109 auto value = vars.find( *token );
1111 if( value != vars.end() && aVisiting.insert( *token ).second )
1113 found |=
textNeedsDowngrade( value->second, aProject, aLegacyExpressions, aVisiting, aTitles );
1114 aVisiting.erase( *token );
1118 if( aTitles && aVisiting.insert( *token ).second )
1122 if( *token == wxT(
"TITLE" ) )
1123 value = aTitles->GetTitle();
1124 else if( *token == wxT(
"ISSUE_DATE" ) )
1125 value = aTitles->GetDate();
1126 else if( *token == wxT(
"REVISION" ) )
1127 value = aTitles->GetRevision();
1128 else if( *token == wxT(
"COMPANY" ) )
1129 value = aTitles->GetCompany();
1130 else if( token->length() == 8 && token->StartsWith( wxT(
"COMMENT" ) ) && ( *token )[7] >=
'1'
1131 && ( *token )[7] <=
'9' )
1132 value = aTitles->GetComment( ( *token )[7].GetValue() -
'1' );
1134 found |=
textNeedsDowngrade( value, aProject, aLegacyExpressions, aVisiting, aTitles );
1135 aVisiting.erase( *token );
1148 for(
size_t pos = 0; pos + 1 < aText.length(); ++pos )
1150 if( aText[pos] ==
'\\' && ( aText[pos + 1] ==
'$' || aText[pos + 1] ==
'@' ) )
1156 if( aText[pos] !=
'@' || aText[pos + 1] !=
'{' )
1159 size_t end = pos + 2;
1162 for( ;
end < aText.length() && depth; ++
end )
1164 if( aText[
end] ==
'{' )
1166 else if( aText[
end] ==
'}' )
1176 const wxString expression = aText.Mid( pos,
end - pos );
1177 wxString value = aItem->
ResolveText( expression, aPath, 0, wxEmptyString );
1187 aText = aText.Left( pos ) + value + aText.Mid(
end );
1188 pos += value.length();
1212 if( !
text || !item )
1217 std::set<wxString> visiting;
1228 if( !aLibrary && ( aPaths.empty() || !
project ) )
1234 std::optional<wxString> replacement;
1235 bool failed =
false;
1238 std::function<bool( wxString* )> resolver = [&]( wxString* token )
1240 std::set<wxString> dependencies;
1246 const wxString reference = wxT(
"${" ) + *token + wxT(
"}" );
1247 wxString value = item->
ResolveText( reference,
path, 0, wxEmptyString );
1251 || value.Contains( wxT(
"<Unresolved:" ) ) || ( aLegacyExpressions &&
hasEscapedTextControl( value ) ) )
1262 if( aLegacyExpressions )
1270 replacement = value;
1281 if( failed || !replacement )
1303 std::vector<SCH_SHEET_PATH> paths;
1309 if(
const SCHEMATIC* schematic = owner )
1313 if(
path.LastScreen() == aScreen )
1314 paths.push_back(
path );
1318 std::set<EDA_ITEM*> visited;
1319 auto planItem = [&](
SCH_ITEM* item )
1321 if( visited.insert( item ).second )
1328 item->RunOnChildren(
1352 for(
int i = 0; i < 9; ++i )
1353 borderText.push_back( titles.
GetComment( i ) );
1355 for(
const wxString& value : borderText )
1357 std::set<wxString> visiting;
1372 _(
"Dynamic evaluation of unsupported references and expressions is removed. Resolved literal "
1373 "values are kept." ),
1380 _(
"The target cannot preserve these references, literal escapes or page-border expressions and a "
1381 "reliable compatible value is unavailable." ),
1390 text->SetText( value );
1398 const wxString range = aText.AfterFirst(
'[' ).BeforeFirst(
']' );
1399 const wxString begin = range.BeforeFirst(
'.' );
1400 const wxString
end = range.AfterLast(
'.' );
1401 return ( begin.length() > 1 && begin[0] ==
'0' ) || (
end.length() > 1 &&
end[0] ==
'0' );
1404 std::vector<wxString> members;
1408 for(
const wxString& member : members )
1432 const size_t length = aBus.length();
1435 bool quoted =
false;
1436 auto digit = []( wxUniChar c )
1438 return c >=
'0' && c <=
'9';
1440 auto formatting = []( wxUniChar c )
1442 return c ==
'_' || c ==
'^' || c ==
'~';
1444 auto escaped = [&](
size_t pos )
1447 for( ; pos && aBus[pos - 1] ==
'\\'; --pos )
1449 return slashes % 2 == 1;
1452 for( ; i < length; ++i )
1454 if( !aPreTen && aBus[i] ==
'"' && !escaped( i ) )
1462 if( aBus[i] ==
'\\' && i + 1 < length )
1463 result.m_prefix += aBus[++i];
1465 result.m_prefix += aBus[i];
1469 if( aBus[i] ==
'{' )
1471 if( i == 0 || !formatting( aBus[i - 1] ) )
1476 if( !
result.m_prefix.IsEmpty() )
1477 result.m_prefix.RemoveLast();
1481 else if( aBus[i] ==
'}' )
1488 if( !aPreTen && aBus[i] ==
'\\' && i + 1 < length && aBus[i + 1] ==
' ' )
1490 result.m_prefix += aBus[++i];
1494 if( aBus[i] ==
' ' || aBus[i] ==
']' )
1496 if( aBus[i] ==
'[' )
1498 result.m_prefix += aBus[i];
1505 for( ; i < length; ++i )
1507 if( aBus[i] ==
'.' && i + 1 < length && aBus[i + 1] ==
'.' )
1509 number.ToLong( &
result.m_begin );
1513 if( !digit( aBus[i] ) )
1522 for( ; i < length; ++i )
1524 if( aBus[i] ==
']' )
1526 number.ToLong( &
result.m_end );
1530 if( !digit( aBus[i] ) )
1535 for( ; i < length; ++i )
1537 if( aBus[i] ==
'}' )
1539 else if( aPreTen || ( aBus[i] !=
'+' && aBus[i] !=
'-' && aBus[i] !=
'P' && aBus[i] !=
'N' ) )
1550 wxString currentPrefix;
1555 || ( current && legacy.
m_prefix != currentPrefix ) )
1558 std::vector<wxString> members;
1561 for(
const wxString& member : members )
1585 if( !
text || !label )
1588 if( schematic && schematic->
IsValid() )
1592 if(
path.LastScreen() != aScreen )
1599 count += incompatible;
1628 _(
"The target removes the leading zeros from bus members and would change their net names." ),
1638 _(
"The target would reinterpret a literal as a bus, rename formatted bus members or overflow "
1639 "while expanding the range." ),
1702 for(
const auto& [
name, variant] : instance.m_Variants )
1703 count += variant.m_SymbolOverride.has_value();
1720 for(
auto& [
name, variant] : instance.m_Variants )
1721 variant.m_SymbolOverride.reset();
1786 if( !solid( ending->GetStroke().GetLineStyle() ) )
1789 const auto& color = ending->GetStroke().GetColor();
1843 source.SetStroke( stroke );
1848 std::vector<SCH_SHAPE*>
result;
1862 result.push_back( shape );
1871 std::vector<SCH_ITEM*> items;
1876 items.push_back( &item );
1887 if( shapes.empty() )
1895 shape->SetParent( aSymbol );
1907 std::vector<SCH_ITEM*> items;
1912 items.push_back( item );
1924 if( shapes.empty() )
1931 group->RemoveItem( item );
1937 shape->SetParentGroup(
nullptr );
1938 aScreen->
Append( shape );
1941 group->AddItem( shape );
1998 _(
"Alternate-symbol choices in retained variant definitions are removed. The base symbol is unchanged." ),
2003 _(
"Selected custom body styles" ),
2004 _(
"The selected drawing and pins are baked into a separate base-style symbol." ),
2011 _(
"Symbols selecting a custom body style are omitted, including their pins. Connectivity may change." ) },
2017 _(
"Locked items" ),
2018 _(
"The lock is not kept." ),
2025 _(
"Lock metadata is removed; the supported items are kept." ) },
2029 _(
"Line-ending embellishments are removed. The original supported body is kept." ) },
2032 _(
"Ellipse graphics are omitted instead of approximated." ) },
2042 _(
"Grouping is removed; the items are kept." ),
2049 _(
"Group metadata is removed; the supported items are kept." ) },
2054 _(
"Custom names are removed. The target can select only the base and De Morgan styles." ),
2071 _(
"The target reads the brackets as one literal pin number and the netlist changes." ),
countStackedPins,
2078 bool aDropInsteadOfApproximate )
2083 wxT(
"Schematic format changed. Review the downgrade rules and denylist, then "
2084 "update SCH_DOWNGRADE_COVERED." ) );
2108 _(
"Dashed, filled, differently colored or non-graphical endings cannot be approximated "
2109 "faithfully. Explicitly dropping approximations keeps the supported body." ),
2118 if(
int count = rule.m_count( aScreen ); count > 0 )
2122 omit ? rule.m_omitDetail : rule.m_detail, count );
2156 _(
"The target can only open a single root sheet." ), 1 );
2174 _(
"The target keeps variants but cannot store a variant's alternate symbol, so the "
2175 "variant would resolve to the base symbol." ),
2183 int incompatible = 0;
2187 for(
const wxString& member : alias->Members() )
2217 const auto& apply = omit ? rule.m_omit : rule.m_apply;
2218 wxASSERT_MSG( !omit || apply, wxT(
"A LOWER rule needs an omission transform." ) );
2228 bool aDropInsteadOfApproximate )
2231 wxT(
"Symbol library format changed. Review the symbol downgrade path, then "
2232 "update SYMLIB_DOWNGRADE_COVERED." ) );
2248 _(
"Dashed, filled or differently colored endings cannot be approximated faithfully. "
2249 "Explicitly dropping approximations keeps the supported body." ),
2255 if( aTarget.
m_schVersion >= rule.m_introducedIn || !rule.m_countSymbol )
2258 if(
int count = rule.m_countSymbol( aSymbol ); count > 0 )
2262 omit ? rule.m_omitDetail : rule.m_detail, count );
2281 const auto& apply = omit ? rule.m_omitSymbol : rule.m_applySymbol;
2282 wxASSERT_MSG( !omit || !rule.m_applySymbol || apply,
2283 wxT(
"A symbol LOWER rule needs an omission transform." ) );
2342 wxFAIL_MSG( wxT(
"No writer for this downgrade target." ) );
2354 wxFAIL_MSG( wxT(
"No writer for this downgrade target." ) );
2373 return wxEmptyString;
2398 const wxString& aVariantName )
2402 snap.
m_dnp = aSymbol->
GetDNP( &aPath, aVariantName );
2411 if( instance.m_Path != aPath.
Path() )
2414 auto it = instance.m_Variants.find( aVariantName );
2416 if( it != instance.m_Variants.end() )
2451 const wxString& aVariantName )
2455 snap.
m_dnp = aSheet->
GetDNP( &aPath, aVariantName );
2462 if( instance.m_Path != aPath.
Path() )
2465 auto it = instance.m_Variants.find( aVariantName );
2467 if( it != instance.m_Variants.end() )
2479 std::map<SCH_SYMBOL*, SYMBOL_VARIANT_SNAPSHOT> symbols;
2480 std::map<SCH_SHEET*, SHEET_VARIANT_SNAPSHOT> sheets;
2481 std::map<SCH_SYMBOL*, SCH_SCREEN*> screens;
2500 *aConflict = wxString::Format(
2501 _(
"Alternate symbol '%s' cannot be resolved and validated against the base symbol." ),
2508 auto [it, inserted] = symbols.emplace( symbol, snap );
2509 screens.emplace( symbol, screen );
2513 if( !inserted && !( it->second == snap ) )
2516 *aConflict = wxString::Format(
2517 _(
"Shared symbol '%s' has different effective values between sheet instances." ),
2528 auto [it, inserted] = sheets.emplace( sheet, snap );
2530 if( !inserted && !( it->second == snap ) )
2533 *aConflict = wxString::Format(
2534 _(
"Shared sheet '%s' has different effective values between sheet instances." ),
2542 for(
auto& [symbol, snap] : symbols )
2544 if( snap.m_alternate )
2547 std::unique_ptr<LIB_SYMBOL> baked = snap.m_alternate->Flatten();
2548 const wxString baseName = baked->GetName() + wxT(
"__KiCad_variant" );
2549 wxString
name = baseName;
2552 name = wxString::Format( wxT(
"%s_%d" ), baseName, suffix );
2554 baked->SetName(
name );
2555 baked->SetLibId(
LIB_ID( wxEmptyString,
name ) );
2556 screen->
Remove( symbol );
2557 symbol->SetLibId( *snap.m_symbolOverride );
2558 symbol->SetSchSymbolLibraryName(
name );
2559 symbol->SetLibSymbol(
new LIB_SYMBOL( *baked ) );
2561 screen->
Append( symbol );
2564 symbol->SetDNP( snap.m_dnp );
2565 symbol->SetExcludedFromSim( snap.m_excludedFromSim );
2566 symbol->SetExcludedFromBOM( snap.m_excludedFromBOM );
2567 symbol->SetExcludedFromBoard( snap.m_excludedFromBoard );
2568 symbol->SetExcludedFromPosFiles( snap.m_excludedFromPosFiles );
2569 symbol->SetPinMapOverride( snap.m_pinMap );
2571 auto& instances =
const_cast<std::vector<SCH_SYMBOL_INSTANCE>&
>( symbol->GetInstances() );
2575 auto variant = instance.m_Variants.find( aVariantName );
2577 if( variant != instance.m_Variants.end() )
2579 variant->second.m_SymbolOverride.reset();
2580 variant->second.m_PinMapOverride = {};
2584 for(
const auto& [
name, value] : snap.m_fieldOverrides )
2586 for(
SCH_FIELD& field : symbol->GetFields() )
2589 field.SetText( value );
2594 for(
auto& [sheet, snap] : sheets )
2596 sheet->SetDNP( snap.m_dnp );
2597 sheet->SetExcludedFromSim( snap.m_excludedFromSim );
2598 sheet->SetExcludedFromBOM( snap.m_excludedFromBOM );
2599 sheet->SetExcludedFromBoard( snap.m_excludedFromBoard );
2601 for(
const auto& [
name, value] : snap.m_fieldOverrides )
2603 for(
SCH_FIELD& field : sheet->GetFields() )
2607 if( !mandatory && field.GetName() ==
name )
2608 field.SetText( value );
constexpr EDA_IU_SCALE schIUScale
int GetLegacyPPI() const
Recompute the PPI the way it was computed before the pixels/cm truncation fix.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
What an export to a given target will keep, approximate, drop, or block.
void Add(DOWNGRADE_BUCKET aBucket, const wxString &aFeature, const wxString &aDetail=wxEmptyString, int aCount=1)
A set of EDA_ITEMs (i.e., without duplicates).
A base class for most all the KiCad significant classes used in schematics and boards.
void ClearCustomProperties()
virtual EDA_GROUP * GetParentGroup() const
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
const std::map< wxString, wxString > & GetCustomProperties() const
Custom user-defined string key/value properties attached to this item.
virtual void SetEnd(const VECTOR2I &aEnd)
int GetEllipseMinorRadius() const
const VECTOR2I & GetEllipseCenter() const
void SetEndEnding(const LINE_ENDING &aEnding)
EDA_ANGLE GetEllipseEndAngle() const
FILL_T GetFillMode() const
virtual void SetCornerRadius(int aRadius)
int GetEllipseMajorRadius() const
EDA_ANGLE GetEllipseRotation() const
void SetStartEnding(const LINE_ENDING &aEnding)
bool IsHatchedFill() const
void SetFillColor(const COLOR4D &aColor)
LINE_STYLE GetLineStyle() const
virtual void SetShape(SHAPE_T aShape)
std::vector< VECTOR2I > GetRectCorners() const
EDA_ANGLE GetEllipseStartAngle() const
const LINE_ENDING & GetStartEnding() const
const LINE_ENDING & GetEndEnding() const
void SetPolyPoints(const std::vector< VECTOR2I > &aPoints)
int GetCornerRadius() const
void SetFillMode(FILL_T aFill)
virtual void SetPolyShape(const SHAPE_POLY_SET &aShape)
virtual void SetStart(const VECTOR2I &aStart)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
EE_TYPE OfType(KICAD_T aType) const
A logical library item identifier and consists of various portions much like a URI.
Define a library symbol object.
const LIB_ID & GetLibId() const override
void SetDuplicatePinNumbersAreJumpers(bool aEnabled)
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.
void SetAssociatedFootprints(std::vector< ASSOCIATED_FOOTPRINT > aList)
void SetBodyStyleNames(const std::vector< wxString > &aBodyStyleNames)
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
bool IsLocalPower() const override
void RemoveDrawItem(SCH_ITEM *aItem)
Remove draw aItem from list.
void SetHasDeMorganBodyStyles(bool aFlag)
void SetPinMaps(const PIN_MAP_SET &aPinMaps)
bool HasDeMorganBodyStyles() const override
const PIN_MAP_SET & GetPinMaps() const
Pin-to-pad mapping (issue #2282).
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
void SetLibId(const LIB_ID &aLibId)
bool GetDuplicatePinNumbersAreJumpers() const
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const override
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
virtual void SetName(const wxString &aName)
const std::vector< ASSOCIATED_FOOTPRINT > & GetAssociatedFootprints() const
Decorative shape (arrowhead, circle, square) at the start or end of a graphic line,...
static bool ParseBusGroup(const wxString &aGroup, wxString *name, std::vector< wxString > *aMemberList, size_t *aPrefixEnd=nullptr)
Parse a bus group label into the name and a list of components.
static bool ParseBusVector(const wxString &aBus, wxString *aName, std::vector< wxString > *aMemberList)
Parse a bus vector (e.g.
A symbol-owned ordered set of named pin maps.
Container for project specific data.
virtual std::map< wxString, wxString > & GetTextVars() const
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
const BITMAP_BASE & GetImage() const
Get the underlying image.
double GetImageScale() const
void SetImageScale(double aScale)
Set the image "zoom" value.
Holds all the data relating to one schematic.
const std::vector< std::shared_ptr< BUS_ALIAS > > & GetAllBusAliases() const
SCH_SHEET_LIST BuildUnorderedSheetList() const
PROJECT & Project() const
Return a reference to the project this schematic is part of.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
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.
virtual const wxString & GetText() const override
Return the string associated with the text object.
A set of SCH_ITEMs (i.e., without duplicates).
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
bool IsLocked() const override
void SetLayer(SCH_LAYER_ID aLayer)
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, int aDepth=0) const override
Segment description base class to describe items which have 2 end points (track, wire,...
int GetPenWidth() const override
virtual STROKE_PARAMS GetStroke() const override
const LINE_ENDING & GetEndEnding() const
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
const LINE_ENDING & GetStartEnding() const
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
void SetDNP(bool aDNP, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void SetExcludedFromSim(bool aExcludeFromSim, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
void SetExcludedFromBOM(bool aExcludeFromBOM, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
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
void SetExcludedFromBoard(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from board netlist flag.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
void AddLibSymbol(LIB_SYMBOL *aLibSymbol)
Add aLibSymbol to the library symbol map.
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.
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
TITLE_BLOCK & GetTitleBlock()
void SetStroke(const STROKE_PARAMS &aStroke) override
STROKE_PARAMS GetStroke() const override
int GetEffectiveWidth() const override
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.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
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
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
const std::vector< SCH_SHEET_INSTANCE > & GetInstances() const
void ClearPinMapOverrides()
Clear the base pin-to-pad map override and every variant's override.
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
wxString GetFieldText(const wxString &aFieldName, const SCH_SHEET_PATH *aPath=nullptr, const wxString &aVariantName=wxEmptyString) const
PIN_MAP_INSTANCE_OVERRIDE GetPinMapOverride(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) 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.
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
const LIB_ID & GetLibId() const override
LIB_SYMBOL * GetVariantLibSymbol(const wxString &aVariantName, const SCH_SHEET_PATH &aPath) const
Resolve the alternate library symbol for a given variant.
bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flag.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
Writes a schematic or symbol library in the KiCad 10.0 file format.
void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic)
static constexpr int FORMAT_VERSION
void SaveSymbolLibrary(const wxString &aFileName, const std::vector< LIB_SYMBOL * > &aSymbols)
static constexpr int SYMBOL_LIB_VERSION
Writes a schematic or symbol library in the KiCad 9.0 file format.
void SaveSymbolLibrary(const wxString &aFileName, const std::vector< LIB_SYMBOL * > &aSymbols)
static constexpr int FORMAT_VERSION
void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic)
static constexpr int SYMBOL_LIB_VERSION
SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError) const
Build a polyline approximation of the ellipse or arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
void Simplify()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
SHAPE_POLY_SET Fillet(int aRadius, int aErrorMax)
Return a filleted version of the polygon set.
void Fracture(bool aSimplify=true)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
KIGFX::COLOR4D GetColor() const
bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
void SetExcludedFromPosFiles(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from position files flag.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
const wxString & GetCompany() const
const wxString & GetRevision() const
const wxString & GetDate() const
const wxString & GetComment(int aIdx) const
const wxString & GetTitle() const
void FinalizeTextVarExpansion(wxString &aText, RESOLUTION_CONTEXT aContext)
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, RESOLUTION_CONTEXT aContext)
std::vector< TEXT_VAR_REF_KEY > ExtractTextVarReferences(const wxString &aSource)
Lex-scan aSource and return every ${...} reference that appears, without resolving.
DOWNGRADE_BUCKET
What happens to a feature when we export to an older KiCad.
@ BLOCK
Cannot be represented at all, export to this target is not possible.
@ LOWER
Approximated down to a simpler equivalent.
@ DROP
No equivalent, left out.
static bool empty(const wxTextEntryBase *aCtrl)
wxString FindUnsupportedToken(const wxString &aSerialized, const DATED_TOKEN *aNodes, size_t aNodeCount, const DATED_TOKEN *aValues, size_t aValueCount, int aTargetVersion)
Scan serialized s-expression text against dated node and value denylists.
@ FILLED_SHAPE
Fill with object color.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
static std::vector< PENDING_PROPERTY > plan(const EDA_ITEM &aSource, const EDA_ITEM &aTarget, const std::set< wxString > &aEnabledKeys)
Target properties to write, paired with values read off the source.
static constexpr int SCH_VER_PIN_MAPS
static int countJumperPinGroups(const SCH_SCREEN *aScreen)
static void unlockItems(SCH_SCREEN *aScreen)
static bool hasLineEndings(const SCH_ITEM *aItem)
static constexpr int SCH_VER_ELLIPSE
static int countCustomProperties(const SCH_SCREEN *aScreen)
COMPATIBILITY_REPORT ClassifySchematicStructureForDowngrade(const SCHEMATIC &aSchematic, const DOWNGRADE_TARGET &aTarget)
Schematic-wide structure the per-screen rules cannot see. Does not modify it.
static constexpr int SCH_VER_GROUPS
static int countEscapedStackedPins(const SCH_SCREEN *aScreen)
void DowngradeScreenInPlace(SCH_SCREEN *aScreen, const DOWNGRADE_TARGET &aTarget, bool aDropInsteadOfApproximate)
Approximate or remove, in place, what the target cannot represent.
static std::vector< SCREEN_RULE > screenRules()
static constexpr int SYMLIB_VER_LINE_ENDINGS
static void omitScreenItems(SCH_SCREEN *aScreen, const std::function< bool(const SCH_ITEM *)> &aMatches)
static int countSymbolEscapedStackedPins(const LIB_SYMBOL *aSymbol)
static int countSymbolRoundedRects(const LIB_SYMBOL *aSymbol)
static void omitSymbolRoundedRects(LIB_SYMBOL *aSymbol)
static SHEET_VARIANT_SNAPSHOT snapshotSheet(const SCH_SHEET *aSheet, const SCH_SHEET_PATH &aPath, const wxString &aVariantName)
static void dropAlternateSymbols(SCH_SCREEN *aScreen)
static void dropSymbolPinMaps(LIB_SYMBOL *aSymbol)
static int countPinMaps(const SCH_SCREEN *aScreen)
static int countSymbolLineEndings(const LIB_SYMBOL *aSymbol)
static int countUnresolvedCustomBodyStyles(const SCH_SCREEN *aScreen)
static bool usesPlainStackedPinNumber(const wxString &aNumber)
static bool hasActiveExpression(const wxString &aText)
static int countSymbolLocalPower(const LIB_SYMBOL *aSymbol)
static void planTextDowngrade(EDA_ITEM *aItem, const std::vector< SCH_SHEET_PATH > &aPaths, bool aLibrary, bool aLegacyExpressions, TEXT_DOWNGRADE_PLAN &aPlan, const TITLE_BLOCK *aTitles=nullptr)
static void dropRuleAreaFlags(SCH_SCREEN *aScreen)
static int countRuleAreaFlags(const SCH_SCREEN *aScreen)
static int countPositionExclusions(const SCH_SCREEN *aScreen)
static void omitHatchedFills(SCH_SCREEN *aScreen)
static void dropPinMaps(SCH_SCREEN *aScreen)
static bool hasIncompatibleBusVector(const wxString &aText, bool aPreTen)
static void ungroupAll(SCH_SCREEN *aScreen)
bool FlattenSchematicVariant(SCHEMATIC &aSchematic, const wxString &aVariantName, wxString *aConflict)
Bake a variant into the base attributes of every symbol and sheet.
static void omitSelectedCustomBodyStyles(SCH_SCREEN *aScreen)
static void lowerEllipses(SCH_SCREEN *aScreen)
static void dropSymbolCustomProperties(LIB_SYMBOL *aSymbol)
static void omitEllipses(SCH_SCREEN *aScreen)
static constexpr int SCH_DOWNGRADE_COVERED
static SCH_SHAPE lineEndingShape(const SCH_ITEM *aItem)
static void roundedRectToPolygon(SCH_SHAPE *aShape)
static constexpr int SCH_VER_LINE_ENDINGS
static constexpr int SCH_VER_RULE_AREA_FLAGS
static bool hasEscapedTextControl(const wxString &aText)
static int countStackedPins(const SCH_SCREEN *aScreen)
static bool isEllipse(const SCH_ITEM *aItem)
static bool hasPaddedBusVector(const wxString &aText)
static wxString bakeLegacyExpressions(wxString aText, const SCH_ITEM *aItem, const SCH_SHEET_PATH *aPath, bool &aFailed)
static void lowerRoundedRects(SCH_SCREEN *aScreen)
static int countLocalPowerSymbols(const SCH_SCREEN *aScreen)
void SaveSymbolLibraryForTarget(const std::vector< LIB_SYMBOL * > &aSymbols, const wxString &aPath, const DOWNGRADE_TARGET &aTarget)
Save a .kicad_sym library stamped for the target.
int SymbolLibDowngradeCoveredVersion()
The symbol library format the denylist was generated against.
static void dropLineEndings(SCH_SCREEN *aScreen)
static constexpr DATED_TOKEN SCH_TOKENS[]
static void dropSymbolPositionExclusions(LIB_SYMBOL *aSymbol)
static void omitSymbolHatchedFills(LIB_SYMBOL *aSymbol)
static void omitSymbolGraphics(LIB_SYMBOL *aSymbol, const std::function< bool(const SCH_ITEM *)> &aMatches)
static constexpr int SCH_VER_LOCAL_POWER
static constexpr int SYMLIB_DOWNGRADE_COVERED
static bool isRoundedRect(const SCH_ITEM *aItem)
static void closePolyline(std::vector< VECTOR2I > &aPoints)
static FROZEN_BUS_VECTOR frozenBusVector(const wxString &aBus, bool aPreTen)
static int countSymbolEllipses(const LIB_SYMBOL *aSymbol)
static bool hasPostTargetTextVars(const wxString &aText)
static void reportTextPlan(const TEXT_DOWNGRADE_PLAN &aPlan, COMPATIBILITY_REPORT &aReport)
COMPATIBILITY_REPORT ClassifyLibSymbolForDowngrade(const LIB_SYMBOL *aSymbol, const DOWNGRADE_TARGET &aTarget, bool aDropInsteadOfApproximate)
Report what a library symbol would lose if exported to an older KiCad. Does not modify it.
static constexpr KICAD_T FILLABLE_TYPES[]
static int countNamedBodyStyles(const SCH_SCREEN *aScreen)
static bool hasOwnLock(const SCH_ITEM *aItem)
void DowngradeLibSymbolInPlace(LIB_SYMBOL *aSymbol, const DOWNGRADE_TARGET &aTarget, bool aDropInsteadOfApproximate)
Symbol-scoped downgrade for standalone .kicad_sym files the screen pass never sees.
static int countLineEndings(const SCH_SCREEN *aScreen)
static void compensateReferenceImageScales(SCH_SCREEN *aScreen)
static int countRoundedRects(const SCH_SCREEN *aScreen)
static constexpr int SCH_VER_ALTERNATE_SYMBOLS
static void lowerLineEndings(SCH_SCREEN *aScreen)
static int countSymbolHatchedFills(const LIB_SYMBOL *aSymbol)
static bool canLowerLineEndings(const SCH_ITEM *aItem)
static constexpr int SCH_VER_JUMPER_PINS
static void bakeSelectedCustomBodyStyles(SCH_SCREEN *aScreen)
static void dropNamedBodyStyles(SCH_SCREEN *aScreen)
static TEXT_DOWNGRADE_PLAN screenTextPlan(const SCH_SCREEN *aScreen, bool aLegacyExpressions)
static void omitRoundedRects(SCH_SCREEN *aScreen)
static void lowerSymbolHatchedFills(LIB_SYMBOL *aSymbol)
static int countLockedItems(const SCH_SCREEN *aScreen)
static void visitSymbolItems(const LIB_SYMBOL *aSymbol, const std::function< void(EDA_ITEM *)> &aVisit)
static constexpr int SCH_VER_CUSTOM_PROPERTIES
static void visitScreenItems(const SCH_SCREEN *aScreen, const std::function< void(EDA_ITEM *)> &aVisit)
static void dropJumperPinGroups(SCH_SCREEN *aScreen)
static int countGroups(const SCH_SCREEN *aScreen)
static constexpr int SCH_VER_LOCKING
static int countSymbolPinMaps(const LIB_SYMBOL *aSymbol)
static constexpr int SCH_VER_IMAGE_PPI
static void lowerHatchedFills(SCH_SCREEN *aScreen)
static void lowerSymbolLineEndings(LIB_SYMBOL *aSymbol)
static int countPaddedBusLabels(const SCH_SCREEN *aScreen)
static constexpr int SCH_VER_ROUNDED_RECT
void SaveSchematicForTarget(SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const wxString &aPath, const DOWNGRADE_TARGET &aTarget)
Save a schematic sheet file stamped for the target, using the writer for that version.
static void lowerSymbolEllipses(LIB_SYMBOL *aSymbol)
static void reportIncompatibleBuses(int aCount, COMPATIBILITY_REPORT &aReport)
static constexpr int SCH_VER_POSITION_EXCLUSIONS
static constexpr int SCH_VER_BODY_STYLES
static void dropPositionExclusions(SCH_SCREEN *aScreen)
static bool textNeedsDowngrade(const wxString &aText, const PROJECT *aProject, bool aLegacyExpressions, std::set< wxString > &aVisiting, const TITLE_BLOCK *aTitles=nullptr)
static void clearLineEndings(SCH_ITEM *aItem)
static void lowerSymbolRoundedRects(LIB_SYMBOL *aSymbol)
static constexpr int SCH_VER_SHAPE_HATCH
static void omitSymbolEllipses(LIB_SYMBOL *aSymbol)
static int countSymbolStackedPins(const LIB_SYMBOL *aSymbol)
static bool isHatchedFillItem(const SCH_ITEM &aItem)
static int countSymbolCustomProperties(const LIB_SYMBOL *aSymbol)
static SYMBOL_VARIANT_SNAPSHOT snapshotSymbol(const SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aPath, const wxString &aVariantName)
static void dropSymbolBodyStyleNames(LIB_SYMBOL *aSymbol)
static void dropSymbolJumperPins(LIB_SYMBOL *aSymbol)
static std::vector< SCH_SHAPE * > lineEndingPolygons(SCH_ITEM *aItem)
static bool hasRuleAreaFlags(const SCH_RULE_AREA *aArea)
static int countSelectedCustomBodyStyles(const SCH_SCREEN *aScreen)
wxString FindUnsupportedSchToken(const wxString &aSerialized, const DOWNGRADE_TARGET &aTarget)
Scan serialized schematic text for tokens the target cannot parse.
static int countHatchedFills(const SCH_SCREEN *aScreen)
static bool hasPinMaps(const SCH_SYMBOL *aSymbol)
static bool hasEscapedStackedPinNumber(const wxString &aNumber)
static int countSymbolPositionExclusions(const LIB_SYMBOL *aSymbol)
static void applyTextPlan(const TEXT_DOWNGRADE_PLAN &aPlan)
static int countIncompatibleBusLabels(const SCH_SCREEN *aScreen, bool aPreTen)
static bool isPostTargetTextVar(const wxString &aToken)
static void reportPaddedBuses(int aCount, COMPATIBILITY_REPORT &aReport)
static void dropSymbolLineEndings(LIB_SYMBOL *aSymbol)
int SchDowngradeCoveredVersion()
The format the denylist was generated against. A format bump forces a review.
static constexpr DATED_TOKEN SCH_VALUES[]
COMPATIBILITY_REPORT ClassifyScreenForDowngrade(const SCH_SCREEN *aScreen, const DOWNGRADE_TARGET &aTarget, bool aDropInsteadOfApproximate)
Report what a schematic screen would lose if exported to an older KiCad.
static int countSymbolNamedBodyStyles(const LIB_SYMBOL *aSymbol)
static void dropCustomProperties(SCH_SCREEN *aScreen)
static void ellipseToPolygon(SCH_SHAPE *aShape)
static int countSymbolJumperPins(const LIB_SYMBOL *aSymbol)
static int countAlternateSymbols(const SCH_SCREEN *aScreen)
static constexpr int SCH_VER_STACKED_PINS
static constexpr int SCH_VER_STACKED_PIN_ESCAPES
static int countEllipses(const SCH_SCREEN *aScreen)
static TEXT_DOWNGRADE_PLAN symbolTextPlan(const LIB_SYMBOL *aSymbol, bool aLegacyExpressions)
constexpr int SCH_VER_VARIANTS
Format dates for rules the jobs handler applies at schematic scope.
constexpr int SCH_VER_FLAT_HIERARCHY
constexpr int SCH_VER_NET_CHAINS
#define SEXPR_SYMBOL_LIB_FILE_VERSION
This file contains the file format version information for the s-expression schematic and symbol libr...
#define SEXPR_SCHEMATIC_FILE_VERSION
Schematic file version.
Class to handle a set of SCH_ITEMs.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::vector< wxString > ExpandStackedPinNotation(const wxString &aPinName, bool *aValid)
Expand stacked pin notation like [1,2,3], [1-4], [A1-A4], or [AA1-AA3,AB4,CD12-CD14] into individual ...
wxString EscapeStackedPinItem(const wxString &aPinNumber)
Escape the characters that carry structural meaning inside stacked pin notation ('[',...
LINE_STYLE
Dashed line types.
A token dated by the format that introduced it, for the fail-closed downgrade gates.
An older KiCad release we can export a project back to.
int m_schVersion
SEXPR_SCHEMATIC_FILE_VERSION for the target.
int m_symLibVersion
SEXPR_SYMBOL_LIB_FILE_VERSION for the target.
Per-instance override of the active pin map and a sparse delta on top.
A simple container for sheet instance information.
A simple container for schematic symbol instance information.
std::function< void(SCH_SCREEN *)> m_apply
std::function< int(const SCH_SCREEN *)> m_count
DOWNGRADE_BUCKET m_bucket
std::function< void(SCH_SCREEN *)> m_omit
std::function< void(LIB_SYMBOL *)> m_applySymbol
std::function< void(LIB_SYMBOL *)> m_omitSymbol
std::function< int(const LIB_SYMBOL *)> m_countSymbol
Symbol-scoped part, for .kicad_sym files.
bool operator==(const SHEET_VARIANT_SNAPSHOT &) const =default
std::map< wxString, wxString > m_fieldOverrides
std::optional< LIB_ID > m_symbolOverride
bool m_excludedFromPosFiles
PIN_MAP_INSTANCE_OVERRIDE m_pinMap
std::map< wxString, wxString > m_fieldOverrides
bool operator==(const SYMBOL_VARIANT_SNAPSHOT &) const =default
std::map< EDA_TEXT *, wxString > m_replacements
@ REFERENCE
Field Reference of part, i.e. "IC21".
const SHAPE_LINE_CHAIN chain
wxString result
Test unit parsing edge cases and error handling.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I