43 switch( aItem.
Type() )
79 return pin.GetShownName();
88 for(
int row = 0; row <
table.GetRowCount(); ++row )
90 for(
int col = 0; col <
table.GetColCount(); ++col )
95 if( col <
table.GetColCount() - 1 )
101 if( row <
table.GetRowCount() - 1 )
113 return wxEmptyString;
119 wxArrayString itemTexts;
123 if( item->IsSCH_ITEM() )
128 itemText.Trim(
false ).Trim(
true );
130 if( !itemText.IsEmpty() )
131 itemTexts.Add( itemText );
135 return wxJoin( itemTexts,
'\n',
'\0' );
142 std::vector<SCH_ITEM*> flattened;
143 std::vector<SCH_ITEM*> toVisit;
146 toVisit.push_back(
static_cast<SCH_ITEM*
>( item ) );
148 while( !toVisit.empty() )
152 flattened.push_back( item );
157 toVisit.push_back(
static_cast<SCH_ITEM*
>( child ) );
178 const LIB_ID& aLibId,
int aUnit )
180 for(
size_t i = 0; i < aRefs.
GetCount(); ++i )
187 if( ref.
GetRef() != aRef )
192 if( refSym && refSym->
GetLibId() == aLibId )
213 const bool refIsUnannotated = !symRefDes.IsEmpty() && symRefDes.Last() ==
'?';
221 std::set<int> missingUnits;
223 for(
int unit = 1; unit <= aSym.
GetUnitCount(); ++unit )
224 missingUnits.insert( unit );
228 if( symRefDes != ref.GetRef() )
231 if( refIsUnannotated && ref.GetSymbol() && ref.GetSymbol()->GetLibId() != symLibId )
234 missingUnits.erase( ref.GetUnit() );
242 const wxString& aRef,
int aUnit )
249 if( ref.GetRef() == aRef && ref.GetUnit() == aUnit )
261 std::vector<SCH_SYMBOL*>
result;
268 bool haveRootLibId =
false;
269 size_t rootPinCount = 0;
270 bool haveRootPinCount =
false;
285 wxString ref = sym->
GetRef( &sheet,
false );
287 if( rootRef.IsEmpty() )
300 haveRootLibId =
true;
303 if( libId != rootLibId )
307 size_t pinCount = sym->
GetPins( &sheet ).size();
309 if( !haveRootPinCount )
311 rootPinCount = pinCount;
312 haveRootPinCount =
true;
315 if( pinCount != rootPinCount )
330 wxCHECK_MSG( aFirst && aSecond,
false,
"Invalid pins supplied to SwapPinGeometry" );
349 int secondLength = secondPin->
GetLength();
360 return ( firstPin != aFirst ) || ( secondPin != aSecond );
365 std::set<wxString>* aSheetPaths, std::set<wxString>* aProjectNames )
367 std::set<KIID_PATH> uniquePaths;
368 std::set<wxString> sheetPaths;
369 std::set<wxString> otherProjects;
373 uniquePaths.insert( instance.m_Path );
375 if( !instance.m_Path.empty() )
376 sheetPaths.insert( instance.m_Path.AsString() );
378 if( !instance.m_ProjectName.IsEmpty() )
380 if( aCurrentProject.IsEmpty() || !instance.m_ProjectName.IsSameAs( aCurrentProject ) )
381 otherProjects.insert( instance.m_ProjectName );
385 bool sharedWithinProject = uniquePaths.size() > 1;
386 bool sharedWithOtherProjects = !otherProjects.empty();
390 if( sharedWithinProject )
391 *aSheetPaths = sheetPaths;
393 aSheetPaths->clear();
398 if( sharedWithOtherProjects )
399 *aProjectNames = otherProjects;
401 aProjectNames->clear();
404 return sharedWithinProject || sharedWithOtherProjects;
410 std::set<wxString> friendlyNames;
412 if( aSheetPaths.empty() )
413 return friendlyNames;
417 for(
const wxString& pathStr : aSheetPaths )
419 wxString display = pathStr;
427 if( sheetPath.Path() == kiidPath )
431 for(
size_t ii = 0; ii < sheetPath.size(); ++ii )
448 if( !sheetNames.IsEmpty() )
449 sheetNames << wxS(
"/" );
454 if( sheetNames.IsEmpty() )
455 display = sheetPath.PathHumanReadable(
false,
true );
457 display = sheetNames;
468 friendlyNames.insert( display );
471 return friendlyNames;
480 std::set<wxString> existing;
483 existing.insert(
static_cast<SCH_SHEET*
>( item )->GetShownName(
INTERNAL ).Lower() );
485 if( !existing.count( aBaseName.Lower() ) )
488 for(
int n = 1; n < std::numeric_limits<int>::max(); ++n )
490 wxString candidate = aBaseName + wxString::Format( wxT(
"%d" ), n );
492 if( !existing.count( candidate.Lower() ) )
505 std::set<wxString> existing;
508 existing.insert(
static_cast<SCH_GROUP*
>( item )->GetName() );
510 if( !existing.count( aBaseName ) )
513 for(
int n = 1; n < std::numeric_limits<int>::max(); ++n )
515 wxString candidate = aBaseName + wxString::Format( wxT(
"%d" ), n );
517 if( !existing.count( candidate ) )
527 wxCHECK( aSymbol && aSchematic.
IsValid(), );
531 std::vector<KIID_PATH> pathsToRemove;
537 pathsToRemove.emplace_back( instance.m_Path );
538 else if( instance.m_ProjectName != projectName )
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
EE_TYPE OfType(KICAD_T aType) const
A logical library item identifier and consists of various portions much like a URI.
int GetUnitCount() const override
virtual const wxString GetProjectName() const
Return the short name of the project.
Holds all the data relating to one schematic.
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
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.
SCH_SHEET_PATH & CurrentSheet() const
bool IsInstancePathInProject(const KIID_PATH &aPath) const
Test whether an instance path is rooted in this schematic's top level sheets.
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString, int aDepth=0) const
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.
VECTOR2I GetLocalPosition() const
const wxString & GetOperatingPoint() const
void SetOrientation(PIN_ORIENTATION aOrientation)
SCH_PIN * GetLibPin() const
void SetPosition(const VECTOR2I &aPos) override
void SetLength(int aLength)
PIN_ORIENTATION GetOrientation() const
void SetOperatingPoint(const wxString &aText)
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
A helper to define a symbol's reference designator in a schematic.
SCH_SYMBOL * GetSymbol() const
EE_RTREE & Items()
Get the full RTree, usually for iterating.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
bool SetInstanceProjectName(const KIID_PATH &aSheetPath, const wxString &aProjectName)
Set the owning project of the instance stored for aSheetPath.
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
const LIB_ID & GetLibId() const override
int GetUnitCount() const override
Return the number of units per package of the symbol.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
wxString GetShownText(const RENDER_SETTINGS *aSettings, const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, int aDepth=0) const override
virtual wxString GetShownText(const RENDER_SETTINGS *aSettings, const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, int aDepth=0) const
virtual unsigned int GetSize() const override
Return the number of stored items.
std::vector< EDA_ITEM * > GetItemsSortedBySelectionOrder() const
bool OnlyContains(std::vector< KICAD_T > aList) const
Checks if all items in the selection have a type in aList.
PIN_ORIENTATION
The symbol library pin object orientations.
Class to handle a set of SCH_ITEMs.
std::vector< EDA_ITEM * > EDA_ITEMS
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
A simple container for schematic symbol instance information.
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< int32_t > VECTOR2I