58 m_rootSheet( nullptr ),
59 m_schematicHolder( nullptr )
80 if( !symbol || aProperty->
Name() !=
_HKI(
"Text" ) )
86 wxString newValue = aItem->
Get<wxString>( aProperty );
88 if( field->
GetId() == FIELD_T::REFERENCE )
90 symbol->
SetRef( &sheetPath, newValue );
98 wxString ref = symbol->
GetRef( &sheetPath );
104 std::vector<SCH_SYMBOL*> otherUnits;
110 switch( field->
GetId() )
113 case FIELD_T::FOOTPRINT:
114 case FIELD_T::DATASHEET:
117 aCommit->
Modify( otherUnit, sheet.LastScreen() );
119 otherUnit->GetField( field->
GetId() )->SetText( newValue );
151 project.m_ErcSettings =
nullptr;
154 delete project.m_SchematicSettings;
155 project.m_SchematicSettings =
nullptr;
177 project.m_ErcSettings =
nullptr;
180 delete project.m_SchematicSettings;
181 project.m_SchematicSettings =
nullptr;
192 project.m_SchematicSettings->LoadFromFile();
193 project.m_SchematicSettings->m_NgspiceSettings->LoadFromFile();
194 project.m_ErcSettings->LoadFromFile();
201 wxCHECK_RET( aRootSheet, wxS(
"Call to SetRoot with null SCH_SHEET!" ) );
236 [&](
const wxString& aVar )
239 aVars->push_back( aVar );
244 add( wxT(
"SHEETPATH" ) );
245 add( wxT(
"SHEETNAME" ) );
246 add( wxT(
"FILENAME" ) );
247 add( wxT(
"FILEPATH" ) );
248 add( wxT(
"PROJECTNAME" ) );
261 wxCHECK( aSheetPath,
false );
263 if( token->IsSameAs( wxT(
"#" ) ) )
268 else if( token->IsSameAs( wxT(
"##" ) ) )
270 *token = wxString::Format(
"%i",
Root().CountSheets() );
273 else if( token->IsSameAs( wxT(
"SHEETPATH" ) ) )
278 else if( token->IsSameAs( wxT(
"SHEETNAME" ) ) )
283 else if( token->IsSameAs( wxT(
"FILENAME" ) ) )
286 *token = fn.GetFullName();
289 else if( token->IsSameAs( wxT(
"FILEPATH" ) ) )
292 *token = fn.GetFullPath();
295 else if( token->IsSameAs( wxT(
"PROJECTNAME" ) ) )
341 std::set<wxString> migratedExclusions;
355 const wxString settingsKey = testMarker->
GetRCItem()->GetSettingsKey();
357 if( settingsKey != wxT(
"pin_to_pin" )
358 && settingsKey != wxT(
"hier_label_mismatch" )
359 && settingsKey != wxT(
"different_unit_net" ) )
374 settings.
m_ErcExclusions.insert( migratedExclusions.begin(), migratedExclusions.end() );
384 std::set<wxString>::iterator it = settings.
m_ErcExclusions.find( serialized );
394 std::vector<SCH_MARKER*> newMarkers;
403 newMarkers.push_back( marker );
417 for(
const std::shared_ptr<BUS_ALIAS>& alias : sheet.LastScreen()->GetBusAliases() )
419 if( alias->GetName() == aLabel )
430 std::set<wxString> names;
439 names.insert( key.Name );
450 wxString ref = token->BeforeFirst(
':', &remainder );
456 if(
path.size() > 1 )
466 if( refSymbol->
ResolveTextVar( &sheetPath, &remainder, aDepth + 1 ) )
467 *token = std::move( remainder );
469 *token = refSymbol->
GetRef( &sheetPath,
true ) + wxS(
":" ) + remainder;
479 if( refSheet->
ResolveTextVar( &sheetPath, &remainder, aDepth + 1 ) )
480 *token = std::move( remainder );
491 std::map<int, wxString> namesMap;
495 if( sheet.size() == 1 )
496 namesMap[sheet.GetVirtualPageNumber()] =
_(
"<root sheet>" );
498 namesMap[sheet.GetVirtualPageNumber()] = sheet.Last()->GetName();
507 std::map<int, wxString> pagesMap;
510 pagesMap[sheet.GetVirtualPageNumber()] = sheet.GetPageNumber();
519 size_t sourceLen = aSource.length();
521 for(
size_t i = 0; i < sourceLen; ++i )
523 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
526 bool isCrossRef =
false;
529 for( i = i + 2; i < sourceLen; ++i )
531 if( aSource[i] ==
'{'
532 && ( aSource[i-1] ==
'_' || aSource[i-1] ==
'^' || aSource[i-1] ==
'~' ) )
537 if( aSource[i] ==
'}' )
545 if( aSource[i] ==
':' )
548 token.append( aSource[i] );
554 wxString ref = token.BeforeFirst(
':', &remainder );
559 for(
size_t jj = 0; jj < references.
GetCount(); jj++ )
561 SCH_SYMBOL* refSymbol = references[ jj ].GetSymbol();
563 if( ref == refSymbol->
GetRef( &references[ jj ].GetSheetPath(),
true ) )
568 token =
path.AsString() + wxS(
":" ) + remainder;
574 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
578 newbuf.append( aSource[i] );
589 size_t sourceLen = aSource.length();
591 for(
size_t i = 0; i < sourceLen; ++i )
593 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
596 bool isCrossRef =
false;
598 for( i = i + 2; i < sourceLen; ++i )
600 if( aSource[i] ==
'}' )
603 if( aSource[i] ==
':' )
606 token.append( aSource[i] );
612 wxString ref = token.BeforeFirst(
':', &remainder );
618 if(
path.size() > 1 )
627 token = refSymbol->
GetRef( &sheetPath,
true ) + wxS(
":" ) + remainder;
631 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
635 newbuf.append( aSource[i] );
658 wxString filename = rootFn.GetName();
674 int sheet_number = 1;
681 if( sheet.Path() == current_sheetpath )
687 for( screen = s_list.
GetFirst(); screen !=
nullptr; screen = s_list.
GetNext() )
698 std::map<wxString, std::set<int>>& pageRefsMap =
GetPageRefsMap();
707 wxString resolvedLabel = global->
GetShownText( &sheet,
false );
709 pageRefsMap[ resolvedLabel ].insert( sheet.GetVirtualPageNumber() );
718 std::vector<SCH_GLOBALLABEL*> currentSheetGlobalLabels;
721 currentSheetGlobalLabels.push_back(
static_cast<SCH_GLOBALLABEL*
>( item ) );
725 std::vector<SCH_FIELD>& fields = globalLabel->GetFields();
727 fields[0].SetVisible( show );
731 if( fields.size() == 1 && fields[0].GetTextPos() == globalLabel->GetPosition() )
736 for(
SCH_FIELD& field : globalLabel->GetFields() )
737 field.ClearBoundingBoxCache();
739 globalLabel->ClearBoundingBoxCache();
749 const wxString& aRange )
751 wxString spiceNetName( aNetName.Lower() );
754 if( spiceNetName == wxS(
"gnd" ) || spiceNetName == wxS(
"0" ) )
755 return wxEmptyString;
774 std::deque<EDA_ITEM*> allItems;
776 for(
SCH_ITEM* item : screen->Items() )
777 allItems.push_back( item );
780 for(
const VECTOR2I& point : screen->GetNeededJunctions( allItems ) )
783 screen->Append( junction );
786 for(
SCH_LINE* wire : screen->GetBusesAndWires( point,
true ) )
789 screen->Append( newSegment );
854 for(
unsigned i = 0; i < sheetList.size(); i++ )
902 std::set<KIFONT::OUTLINE_FONT*>
fonts;
908 for(
SCH_ITEM* item : sheet.LastScreen()->Items() )
920 if( outline->GetEmbeddingPermission() == EMBEDDING_PERMISSION::EDITABLE
921 || outline->GetEmbeddingPermission() == EMBEDDING_PERMISSION::INSTALLABLE )
923 fonts.insert( outline );
943 wxLogTrace(
"EMBED",
"Failed to add font file: %s", font->GetFileName() );
954 std::set<const SCH_SCREEN*> retv;
967 const std::vector<SCH_SYMBOL_INSTANCE> symbolInstances = symbol->
GetInstances();
971 if( !hierarchy.
HasPath( instance.m_Path ) )
973 retv.insert( screen );
978 if( retv.count( screen ) )
995 wxCHECK2( screen,
continue );
997 if( screen->GetRefCount() > 1 )
1009 aCommit->
Modify( aSegment, aScreen );
1019 aCommit->
Added( newSegment, aScreen );
1021 *aNewSegment = newSegment;
1027 bool brokenSegments =
false;
1032 BreakSegment( aCommit, wire, aPos, &new_line, aScreen );
1033 brokenSegments =
true;
1036 return brokenSegments;
1042 bool brokenSegments =
false;
1044 std::set<VECTOR2I> point_set;
1047 point_set.insert( item->GetPosition() );
1053 point_set.insert( entry->
GetEnd() );
1056 for(
const VECTOR2I& pt : point_set )
1059 brokenSegments =
true;
1062 return brokenSegments;
1069 std::vector<SCH_LINE*> lines;
1070 std::vector<SCH_JUNCTION*> junctions;
1071 std::vector<SCH_NO_CONNECT*> ncs;
1072 std::vector<SCH_ITEM*> items_to_remove;
1073 bool changed =
true;
1075 if( aScreen ==
nullptr )
1078 auto remove_item = [&](
SCH_ITEM* aItem ) ->
void
1086 if( aItem->IsSelected() && selectionTool )
1093 aCommit->
Removed( aItem, aScreen );
1102 items_to_remove.push_back( item );
1104 junctions.push_back(
static_cast<SCH_JUNCTION*
>( item ) );
1107 for(
SCH_ITEM* item : items_to_remove )
1108 remove_item( item );
1116 if( ( aFirst->GetEditFlags() & STRUCT_DELETED )
1117 || ( aSecond->GetEditFlags() & STRUCT_DELETED ) )
1123 remove_item( aSecond );
1129 if( ( aFirst->GetEditFlags() & STRUCT_DELETED )
1130 || ( aSecond->GetEditFlags() & STRUCT_DELETED ) )
1136 remove_item( aSecond );
1140 auto minX = [](
const SCH_LINE* l )
1142 return std::min( l->GetStartPoint().x, l->GetEndPoint().x );
1145 auto maxX = [](
const SCH_LINE* l )
1147 return std::max( l->GetStartPoint().x, l->GetEndPoint().x );
1150 auto minY = [](
const SCH_LINE* l )
1152 return std::min( l->GetStartPoint().y, l->GetEndPoint().y );
1155 auto maxY = [](
const SCH_LINE* l )
1157 return std::max( l->GetStartPoint().y, l->GetEndPoint().y );
1170 lines.push_back(
static_cast<SCH_LINE*
>( item ) );
1174 std::sort( lines.begin(), lines.end(),
1177 return minX( a ) < minX( b );
1180 for(
auto it1 = lines.begin(); it1 != lines.end(); ++it1 )
1187 if( firstLine->
IsNull() )
1189 remove_item( firstLine );
1193 int firstRightXEdge = maxX( firstLine );
1196 for( ++it2; it2 != lines.end(); ++it2 )
1199 int secondLeftXEdge = minX( secondLine );
1202 if( secondLeftXEdge > firstRightXEdge )
1206 if( !( std::max( minY( firstLine ), minY( secondLine ) )
1207 <= std::min( maxY( firstLine ), maxY( secondLine ) ) ) )
1226 remove_item( secondLine );
1234 if( mergedLine !=
nullptr )
1236 remove_item( firstLine );
1237 remove_item( secondLine );
1239 if( m_schematicHolder )
1241 m_schematicHolder->AddToScreen( mergedLine, aScreen );
1244 aCommit->Added( mergedLine, aScreen );
1247 selectionTool->AddItemToSel( mergedLine,
true );
1261 std::function<
void(
SCH_ITEM* )>* aChangedItemHandler,
1269 aCommit = &localCommit;
1281 CleanUp( aCommit, sheet.LastScreen() );
1285 wxLogTrace(
"CONN_PROFILE",
"SchematicCleanUp() %0.4f ms", timer.
msecs() );
1292 || aLastChangeList ==
nullptr
1299 std::unordered_set<SCH_SCREEN*> all_screens;
1302 all_screens.insert(
path.LastScreen() );
1319 std::set<SCH_ITEM*> changed_items;
1320 std::set<VECTOR2I> pts;
1321 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> item_paths;
1324 std::unordered_set<SCH_SCREEN*> changed_screens;
1325 std::set<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> changed_rule_areas;
1326 std::vector<CHANGED_ITEM> changed_connectable_items;
1329 auto addItemToChangeSet = [&changed_items, &pts, &item_paths]( CHANGED_ITEM itemData )
1333 std::vector<VECTOR2I> tmp_pts = itemData.item->GetConnectionPoints();
1334 pts.insert( tmp_pts.begin(), tmp_pts.end() );
1335 changed_items.insert( itemData.item );
1338 item_paths.insert( std::make_pair(
path, itemData.item ) );
1340 if( !itemData.linked_item || !itemData.linked_item->IsConnectable() )
1343 tmp_pts = itemData.linked_item->GetConnectionPoints();
1344 pts.insert( tmp_pts.begin(), tmp_pts.end() );
1345 changed_items.insert( itemData.linked_item );
1351 std::vector<SCH_PIN*> pins = symbol->GetPins();
1352 changed_items.insert( pins.begin(), pins.end() );
1356 item_paths.insert( std::make_pair(
path, itemData.linked_item ) );
1360 for(
unsigned ii = 0; ii < aLastChangeList->
GetCount(); ++ii )
1366 case UNDO_REDO::CHANGED:
1367 case UNDO_REDO::NEWITEM:
1368 case UNDO_REDO::DELETED:
1380 changed_screens.insert( screen );
1385 changed_rule_areas.insert( { ruleArea, screen } );
1390 changed_connectable_items.push_back( { item, linked_item, screen } );
1396 std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> forceUpdateRuleAreas =
1399 std::for_each( forceUpdateRuleAreas.begin(), forceUpdateRuleAreas.end(),
1400 [&]( std::pair<SCH_RULE_AREA*, SCH_SCREEN*>& updatedRuleArea )
1402 changed_rule_areas.insert( updatedRuleArea );
1407 std::map<KIID, EDA_ITEM*> itemMap;
1410 auto addPastAndPresentContainedItems =
1415 if( itemMap.contains( pastItem ) )
1416 addItemToChangeSet( {
static_cast<SCH_ITEM*
>( itemMap[pastItem] ),
nullptr, screen } );
1420 addItemToChangeSet( { containedItem,
nullptr, screen } );
1423 for(
const auto& [changedRuleArea, screen] : changed_rule_areas )
1424 addPastAndPresentContainedItems( changedRuleArea, screen );
1427 for( CHANGED_ITEM& changed_item_data : changed_connectable_items )
1429 addItemToChangeSet( changed_item_data );
1435 const std::vector<VECTOR2I> labelConnectionPoints =
1436 changed_item_data.item->GetConnectionPoints();
1438 auto candidateRuleAreas =
1440 changed_item_data.item->GetBoundingBox() );
1442 for(
SCH_ITEM* candidateRuleArea : candidateRuleAreas )
1448 addPastAndPresentContainedItems( ruleArea, changed_item_data.screen );
1458 if( !item->IsConnectable() )
1463 if( item->HitTest( pt ) )
1464 changed_items.insert( item );
1466 else if( item->Type() ==
SCH_SYMBOL_T && item->IsConnected( pt ) )
1469 std::vector<SCH_PIN*> pins = symbol->
GetPins();
1471 changed_items.insert( pins.begin(), pins.end() );
1477 wxCHECK2( sheet,
continue );
1479 std::vector<SCH_SHEET_PIN*> sheetPins = sheet->
GetPins();
1480 changed_items.insert( sheetPins.begin(), sheetPins.end() );
1484 if( item->IsConnected( pt ) )
1485 changed_items.insert( item );
1490 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> all_items =
1493 all_items.insert( item_paths.begin(), item_paths.end() );
1501 std::set<wxString> affectedNets;
1503 for(
auto&[
path, item ] : all_items )
1505 wxCHECK2( item,
continue );
1506 item->SetConnectivityDirty();
1510 affectedNets.insert( conn->
Name() );
1514 for(
const wxString& netName : affectedNets )
1515 netSettings->ClearCacheForNet( netName );
1517 new_graph.
Recalculate( list,
false, aChangedItemHandler, aProgressReporter );
1521 if( !localCommit.
Empty() )
1522 localCommit.
Push(
_(
"Schematic Cleanup" ) );
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void SetPageCount(int aPageCount)
void SetPageNumber(const wxString &aPageNumber)
void SetVirtualPageNumber(int aPageNumber)
Represent a set of changes (additions, deletions or modifications) of a data model (e....
COMMIT & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT & Removed(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Calculate the connectivity of a schematic and generates netlists.
const NET_MAP & GetNetMap() const
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Update the connection graph for the given list of sheets.
std::set< std::pair< SCH_SHEET_PATH, SCH_ITEM * > > ExtractAffectedItems(const std::set< SCH_ITEM * > &aItems)
For a set of items, this will remove the connected items and their associated data including subgraph...
void SetLastCodes(const CONNECTION_GRAPH *aOther)
void Merge(CONNECTION_GRAPH &aGraph)
Combine the input graph contents into the current graph.
A subgraph is a set of items that are electrically connected on a single sheet.
static PRIORITY GetDriverPriority(SCH_ITEM *aDriver)
Return the priority (higher is more important) of a candidate driver.
const SCH_CONNECTION * GetDriverConnection() const
A base class for most all the KiCad significant classes used in schematics and boards.
EDA_ITEM_FLAGS GetEditFlags() const
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
EDA_ITEM_FLAGS GetFlags() const
SHAPE_POLY_SET & GetPolyShape()
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
EE_TYPE Overlapping(const BOX2I &aRect) const
EE_TYPE OfType(KICAD_T aType) const
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Load a file from disk and adds it to the collection.
Container for ERC settings.
std::map< wxString, wxString > m_ErcExclusionComments
std::set< wxString > m_ErcExclusions
Class that other classes need to inherit from, in order to be inspectable.
wxAny Get(PROPERTY_BASE *aProperty) const
FONT is an abstract base class for both outline and stroke fonts.
virtual bool IsStroke() const
Class OUTLINE_FONT implements outline font drawing.
A logical library item identifier and consists of various portions much like a URI.
std::shared_ptr< RC_ITEM > GetRCItem() const
void SetExcluded(bool aExcluded, const wxString &aComment=wxEmptyString)
wxString GetComment() const
static void ConvertToSpiceMarkup(wxString *aNetName)
Remove formatting wrappers and replace illegal spice net name characters with underscores.
A holder to handle information on schematic or board items.
UNDO_REDO GetPickedItemStatus(unsigned int aIdx) const
EDA_ITEM * GetPickedItemLink(unsigned int aIdx) const
unsigned GetCount() const
BASE_SCREEN * GetScreenForItem(unsigned int aIdx) const
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
A small class to help profiling.
void Stop()
Save the time when this function was called, and set the counter stane to stop.
double msecs(bool aSinceLast=false)
A progress reporter interface for use in multi-threaded environments.
The backing store for a PROJECT, in JSON format.
ERC_SETTINGS * m_ErcSettings
Eeschema params.
SCHEMATIC_SETTINGS * m_SchematicSettings
std::shared_ptr< NET_SETTINGS > & NetSettings()
Container for project specific data.
virtual const wxString GetProjectName() const
Return the short name of the project.
virtual bool TextVarResolver(wxString *aToken) const
virtual PROJECT_FILE & GetProjectFile() const
virtual std::map< wxString, wxString > & GetTextVars() const
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
const wxString & Name() const
static PROPERTY_MANAGER & Instance()
void UnregisterListeners(TYPE_ID aType)
void RegisterListener(TYPE_ID aType, PROPERTY_LISTENER aListenerFunc)
Registers a listener for the given type.
virtual void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)=0
Add an item to the screen (and view) aScreen is the screen the item is located on,...
virtual void IntersheetRefUpdate(SCH_GLOBALLABEL *aItem)
virtual void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)=0
virtual SCH_SELECTION_TOOL * GetSelectionTool()
virtual void OnSchItemsRemoved(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
virtual void OnSchItemsChanged(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
virtual void OnSchSheetChanged(SCHEMATIC &aSch)
virtual void OnSchItemsAdded(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
These are loaded from Eeschema settings but then overwritten by the project settings.
bool m_IntersheetRefsShow
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
std::set< const SCH_SCREEN * > GetSchematicsSharedByMultipleProjects() const
Return a list of schematic files in the current project that contain instance data for multiple proje...
void SetLegacySymbolInstanceData()
Update the symbol value and footprint instance data for legacy designs.
void OnItemsAdded(std::vector< SCH_ITEM * > &aNewItems)
Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for listeners.
CONNECTION_GRAPH * m_connectionGraph
Hold and calculate connectivity information of this schematic.
void BreakSegment(SCH_COMMIT *aCommit, SCH_LINE *aSegment, const VECTOR2I &aPoint, SCH_LINE **aNewSegment, SCH_SCREEN *aScreen)
Break a single segment into two at the specified point.
SCH_SHEET_LIST m_hierarchy
Cache of the entire schematic hierarchy sorted by sheet page number.
void ResolveERCExclusionsPostUpdate()
Update markers to match recorded exclusions.
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const
void RemoveListener(SCHEMATIC_LISTENER *aListener)
Remove the specified listener.
bool BreakSegmentsOnJunctions(SCH_COMMIT *aCommit, SCH_SCREEN *aScreen)
Test all junctions and bus entries in the schematic for intersections with wires and buses and breaks...
bool IsComplexHierarchy() const
Test if the schematic is a complex hierarchy.
void OnSchSheetChanged()
Notify the schematic and its listeners that the current sheet has been changed.
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
SCH_SHEET_PATH * m_currentSheet
The sheet path of the sheet currently being edited or displayed.
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
void CleanUp(SCH_COMMIT *aCommit, SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
void OnItemsRemoved(std::vector< SCH_ITEM * > &aRemovedItems)
Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event for listeners.
std::shared_ptr< BUS_ALIAS > GetBusAlias(const wxString &aLabel) const
Return a pointer to a bus alias object for the given label, or null if one doesn't exist.
std::vector< SCH_MARKER * > ResolveERCExclusions()
void EmbedFonts() override
Embed fonts in the schematic.
SCHEMATIC_SETTINGS & Settings() const
SCH_SCREEN * GetCurrentScreen() const
wxString ConvertKIIDsToRefs(const wxString &aSource) const
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
std::map< wxString, std::set< int > > & GetPageRefsMap()
void FixupJunctions()
Add junctions to this schematic where required.
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
Get a set of fonts used in the schematic.
wxString ConvertRefsToKIIDs(const wxString &aSource) const
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
void SetProject(PROJECT *aPrj)
void AddListener(SCHEMATIC_LISTENER *aListener)
Add a listener to the schematic to receive calls whenever something on the schematic has been modifie...
std::map< int, wxString > GetVirtualPageToSheetPagesMap() const
EMBEDDED_FILES * GetEmbeddedFiles() override
CONNECTION_GRAPH * ConnectionGraph() const
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
std::set< wxString > GetNetClassAssignmentCandidates()
Return the set of netname candidates for netclass assignment.
void InvokeListeners(Func &&aFunc, Args &&... args)
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
static bool m_IsSchematicExists
True if a SCHEMATIC exists, false if not.
void RemoveAllListeners()
Remove all listeners.
void GetContextualTextVars(wxArrayString *aVars) const
std::map< int, wxString > GetVirtualPageToSheetNamesMap() const
SCHEMATIC_HOLDER * m_schematicHolder
What currently "Holds" the schematic, i.e.
wxString GetUniqueFilenameForCurrentSheet()
Get the unique file name for the current sheet.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
bool BreakSegments(SCH_COMMIT *aCommit, const VECTOR2I &aPoint, SCH_SCREEN *aScreen)
Check every wire and bus for a intersection at aPoint and break into two segments at aPoint if an int...
std::vector< SCHEMATIC_LISTENER * > m_listeners
Currently installed listeners.
SCH_SHEET_PATH & CurrentSheet() const
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, TOOL_MANAGER *aToolManager, PROGRESS_REPORTER *aProgressReporter=nullptr, KIGFX::SCH_VIEW *aSchView=nullptr, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PICKED_ITEMS_LIST *aLastChangeList=nullptr)
Generate the connection data for the entire schematic hierarchy.
std::map< wxString, double > m_operatingPoints
Simulation operating points for text variable substitution.
ERC_SETTINGS & ErcSettings() const
void OnItemsChanged(std::vector< SCH_ITEM * > &aItems)
Notify the schematic and its listeners that an item on the schematic has been modified in some way.
SCH_SHEET * m_rootSheet
The top-level sheet in this schematic hierarchy (or potentially the only one)
VECTOR2I GetPosition() const override
Class for a wire to bus entry.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString Name(bool aIgnoreSheet=false) const
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual bool IsConnectable() const
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
VECTOR2I GetPosition() const override
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const override
Segment description base class to describe items which have 2 end points (track, wire,...
bool IsParallel(const SCH_LINE *aLine) const
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
SCH_LINE * MergeOverlap(SCH_SCREEN *aScreen, SCH_LINE *aLine, bool aCheckJunctions)
Check line against aLine to see if it overlaps and merge if it does.
SCH_LINE * BreakAt(SCH_COMMIT *aCommit, const VECTOR2I &aPoint)
Break this segment into two at the specified point.
bool IsStrokeEquivalent(const SCH_LINE *aLine)
bool IsEndPoint(const VECTOR2I &aPoint) const override
Test if aPt is an end point of this schematic object.
static SCH_MARKER * DeserializeFromString(const SCH_SHEET_LIST &aSheetList, const wxString &data)
wxString SerializeToString() const
bool IsLegacyMarker() const
Determine if this marker is legacy (i.e.
VECTOR2I GetPosition() const override
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the EDA_SHAPE.
const std::unordered_set< SCH_ITEM * > & GetContainedItems() const
Return a set of all items contained within the rule area.
static std::vector< std::pair< SCH_RULE_AREA *, SCH_SCREEN * > > UpdateRuleAreasInScreens(std::unordered_set< SCH_SCREEN * > &screens, KIGFX::SCH_VIEW *view)
Update all rule area connectvity / caches in the given sheet paths.
const std::unordered_set< KIID > & GetPastContainedItems() const
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void SetLegacySymbolInstanceData()
Update the symbol value and footprint instance data for legacy designs.
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
std::vector< SCH_SHEET_PATH > & GetClientSheetPaths()
Return the number of times this screen is used.
std::vector< SCH_LINE * > GetBusesAndWires(const VECTOR2I &aPosition, bool aIgnoreEndpoints=false) const
Return buses and wires passing through aPosition.
bool IsExplicitJunction(const VECTOR2I &aPosition) const
Indicate that a junction dot is necessary at the given location.
EE_RTREE & Items()
Get the full RTree, usually for iterating.
const wxString & GetFileName() const
const TITLE_BLOCK & GetTitleBlock() const
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
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.
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
Fetch a SCH_ITEM by ID.
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Fill an item cache for temporary use when many items need to be fetched.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
bool HasPath(const KIID_PATH &aPath) const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SCREEN * LastScreen()
wxString GetPageNumber() const
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
void SetVirtualPageNumber(int aPageNumber)
Set the sheet instance virtual page number.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void clear()
Forwarded method from std::vector.
size_t size() const
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
SCH_SCREEN * GetScreen() const
std::vector< SCH_SHEET_PIN * > & GetPins()
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
std::vector< 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
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
bool CollideEdge(const VECTOR2I &aPoint, VERTEX_INDEX *aClosestVertex=nullptr, int aClearance=0) const
Check whether aPoint collides with any edge of any of the contours of the polygon.
Helper class to recognize Spice formatted values.
wxString ToString() const
Return string value as when converting double to string (e.g.
bool TextVarResolver(wxString *aToken, const PROJECT *aProject, int aFlags=0) const
static void GetContextualTextVars(wxArrayString *aVars)
static bool empty(const wxTextEntryBase *aCtrl)
#define IS_CHANGED
Item was edited, and modified.
#define IS_NEW
New item, just created.
#define IS_BROKEN
Is a segment just broken by BreakSegment.
#define STRUCT_DELETED
flag indication structures to be erased
void ignore_unused(const T &)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
void for_all_pairs(_InputIterator __first, _InputIterator __last, _Function __f)
Apply a function to every possible pair of elements of a sequence.
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
A simple container for schematic symbol instance information.