45 switch( aItem.
Type() )
81 return pin.GetShownName();
90 for(
int row = 0; row <
table.GetRowCount(); ++row )
92 for(
int col = 0; col <
table.GetColCount(); ++col )
97 if( col <
table.GetColCount() - 1 )
103 if( row <
table.GetRowCount() - 1 )
115 return wxEmptyString;
121 wxArrayString itemTexts;
125 if( item->IsSCH_ITEM() )
130 itemText.Trim(
false ).Trim(
true );
132 if( !itemText.IsEmpty() )
133 itemTexts.Add( itemText );
137 return wxJoin( itemTexts,
'\n',
'\0' );
144 std::vector<SCH_ITEM*> flattened;
145 std::vector<SCH_ITEM*> toVisit;
148 toVisit.push_back(
static_cast<SCH_ITEM*
>( item ) );
150 while( !toVisit.empty() )
154 flattened.push_back( item );
159 toVisit.push_back(
static_cast<SCH_ITEM*
>( child ) );
180 const LIB_ID& aLibId,
int aUnit )
182 for(
size_t i = 0; i < aRefs.
GetCount(); ++i )
189 if( ref.
GetRef() != aRef )
194 if( refSym && refSym->
GetLibId() == aLibId )
215 const bool refIsUnannotated = !symRefDes.IsEmpty() && symRefDes.Last() ==
'?';
223 std::set<int> missingUnits;
225 for(
int unit = 1; unit <= aSym.
GetUnitCount(); ++unit )
226 missingUnits.insert( unit );
230 if( symRefDes != ref.GetRef() )
233 if( refIsUnannotated && ref.GetSymbol() && ref.GetSymbol()->GetLibId() != symLibId )
236 missingUnits.erase( ref.GetUnit() );
244 const wxString& aRef,
int aUnit )
251 if( ref.GetRef() == aRef && ref.GetUnit() == aUnit )
263 std::vector<SCH_SYMBOL*>
result;
270 bool haveRootLibId =
false;
271 size_t rootPinCount = 0;
272 bool haveRootPinCount =
false;
287 wxString ref = sym->
GetRef( &sheet,
false );
289 if( rootRef.IsEmpty() )
302 haveRootLibId =
true;
305 if( libId != rootLibId )
309 size_t pinCount = sym->
GetPins( &sheet ).size();
311 if( !haveRootPinCount )
313 rootPinCount = pinCount;
314 haveRootPinCount =
true;
317 if( pinCount != rootPinCount )
332 wxCHECK_MSG( aFirst && aSecond,
false,
"Invalid pins supplied to SwapPinGeometry" );
351 int secondLength = secondPin->
GetLength();
362 return ( firstPin != aFirst ) || ( secondPin != aSecond );
367 std::set<wxString>* aSheetPaths, std::set<wxString>* aProjectNames )
369 std::set<KIID_PATH> uniquePaths;
370 std::set<wxString> sheetPaths;
371 std::set<wxString> otherProjects;
375 uniquePaths.insert( instance.m_Path );
377 if( !instance.m_Path.empty() )
378 sheetPaths.insert( instance.m_Path.AsString() );
380 if( !instance.m_ProjectName.IsEmpty() )
382 if( aCurrentProject.IsEmpty() || !instance.m_ProjectName.IsSameAs( aCurrentProject ) )
383 otherProjects.insert( instance.m_ProjectName );
387 bool sharedWithinProject = uniquePaths.size() > 1;
388 bool sharedWithOtherProjects = !otherProjects.empty();
392 if( sharedWithinProject )
393 *aSheetPaths = sheetPaths;
395 aSheetPaths->clear();
400 if( sharedWithOtherProjects )
401 *aProjectNames = otherProjects;
403 aProjectNames->clear();
406 return sharedWithinProject || sharedWithOtherProjects;
412 std::set<wxString> friendlyNames;
414 if( aSheetPaths.empty() )
415 return friendlyNames;
419 for(
const wxString& pathStr : aSheetPaths )
421 wxString display = pathStr;
429 if( sheetPath.Path() == kiidPath )
433 for(
size_t ii = 0; ii < sheetPath.size(); ++ii )
450 if( !sheetNames.IsEmpty() )
451 sheetNames << wxS(
"/" );
456 if( sheetNames.IsEmpty() )
457 display = sheetPath.PathHumanReadable(
false,
true );
459 display = sheetNames;
470 friendlyNames.insert( display );
473 return friendlyNames;
482 std::set<wxString> existing;
485 existing.insert(
static_cast<SCH_SHEET*
>( item )->GetShownName(
INTERNAL ).Lower() );
487 if( !existing.count( aBaseName.Lower() ) )
490 for(
int n = 1; n < std::numeric_limits<int>::max(); ++n )
492 wxString candidate = aBaseName + wxString::Format( wxT(
"%d" ), n );
494 if( !existing.count( candidate.Lower() ) )
507 std::vector<SCH_HIERLABEL*> labels;
508 std::set<wxString> names;
511 names.insert(
pin->GetText() );
517 if( names.insert( label->
GetText() ).second )
518 labels.push_back( label );
527 if( aLabels.empty() )
536 const int margin = pitch;
542 int leftY = topY + margin - pitch;
543 int rightY = topY + margin - pitch;
548 rightY = std::max( rightY,
pin->GetPosition().y );
550 leftY = std::max( leftY,
pin->GetPosition().y );
554 std::vector<SCH_HIERLABEL*> leftLabels;
555 std::vector<SCH_HIERLABEL*> rightLabels;
560 rightLabels.push_back( label );
562 leftLabels.push_back( label );
568 return a->
GetText() < b->GetText();
571 std::sort( leftLabels.begin(), leftLabels.end(), byText );
572 std::sort( rightLabels.begin(), rightLabels.end(), byText );
575 int botLeft = leftY + (int) leftLabels.size() * pitch;
576 int botRight = rightY + (int) rightLabels.size() * pitch;
577 int needBot = std::max( botLeft, botRight ) + margin;
579 if( needBot > topY + aSheet->
GetSize().
y )
583 [&](
const std::vector<SCH_HIERLABEL*>& aColumn,
int aX,
int aStartY,
SHEET_SIDE aSide )
592 pin->SetTextSize(
VECTOR2I( textSize, textSize ) );
594 pin->ClearSelected();
595 pin->SetText( label->GetText() );
596 pin->SetShape( label->GetShape() );
597 pin->SetSide( aSide );
613 std::set<wxString> existing;
616 existing.insert(
static_cast<SCH_GROUP*
>( item )->GetName() );
618 if( !existing.count( aBaseName ) )
621 for(
int n = 1; n < std::numeric_limits<int>::max(); ++n )
623 wxString candidate = aBaseName + wxString::Format( wxT(
"%d" ), n );
625 if( !existing.count( candidate ) )
635 wxCHECK( aSymbol && aSchematic.
IsValid(), );
639 std::vector<KIID_PATH> pathsToRemove;
645 pathsToRemove.emplace_back( instance.m_Path );
646 else if( instance.m_ProjectName != projectName )
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
virtual const wxString & GetText() const
Return the string associated with the text 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.
SCHEMATIC_SETTINGS & Settings() const
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,...
SCH_SCREEN * GetParentScreen() const
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...
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.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
SCH_SCREEN * GetScreen() const
VECTOR2I GetPosition() const override
void Resize(const VECTOR2I &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
std::vector< SCH_SHEET_PIN * > & GetPins()
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.
SHEET_SIDE
Define the edge of the sheet that the sheet pin is positioned.
A simple container for schematic symbol instance information.
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< int32_t > VECTOR2I