53std::optional<TEXT_EVAL_VCS::CONTEXT_PATH_SCOPE> sourceProjectContext(
const SCHEMATIC& aSchematic )
58 return std::optional<TEXT_EVAL_VCS::CONTEXT_PATH_SCOPE>( std::in_place,
path );
64struct INSTANCE_TEXT_CONTEXT
72 std::vector<wxString> title;
75 bool portrait =
false;
76 bool operator==(
const INSTANCE_TEXT_CONTEXT& )
const =
default;
79struct VARIANT_TEXT_CONTEXT
81 std::map<wxString, wxString> fields;
82 std::array<bool, 5> attributes{};
83 bool operator==(
const VARIANT_TEXT_CONTEXT& )
const =
default;
86struct SHEET_TEXT_CONTEXT
88 std::vector<std::tuple<FIELD_T, wxString, wxString>> fields;
89 std::array<bool, 5> attributes{};
90 std::map<KIID_PATH, std::map<wxString, VARIANT_TEXT_CONTEXT>> variants;
91 bool operator==(
const SHEET_TEXT_CONTEXT& )
const =
default;
94struct MODEL_TEXT_CONTEXT
99 wxString workingDirectory;
100 wxString drawingLayout;
101 bool allowEmptyLayout =
false;
103 bool vcsContextIsFile =
false;
105 wxString variantDescription;
107 std::map<wxString, wxString> variables;
108 std::vector<wxString> templateFields;
109 std::vector<INSTANCE_TEXT_CONTEXT> instances;
110 std::map<KIID_PATH, SHEET_TEXT_CONTEXT> sheets;
111 bool operator==(
const MODEL_TEXT_CONTEXT& )
const =
default;
114std::optional<MODEL_TEXT_CONTEXT> CaptureTextContext(
SCHEMATIC& aSchematic,
const SCH_SHEET_LIST& aPaths )
116 MODEL_TEXT_CONTEXT
result;
125 result.workingDirectory = wxGetCwd();
127 if(
project.GetProjectPath().empty() )
141 for(
const auto& field :
project.GetProjectFile().m_TemplateFieldNames.GetResolvedTemplateFieldNames() )
142 result.templateFields.push_back( field.m_Name );
144 for(
const SCH_SHEET_PATH&
path : aPaths )
146 SCH_SCREEN* screen =
path.LastScreen();
153 path.GetPageNumber(),
path.PathHumanReadable(),
path.Last()->GetName(),
160 for(
int comment = 0; comment < 9; ++comment )
161 instance.title.push_back( title.
GetComment( comment ) );
163 result.instances.push_back( std::move( instance ) );
166 for(
size_t depth = 0; depth <
path.size(); ++depth )
168 const SCH_SHEET* sheet =
path.at( depth );
169 sheetPath.push_back( sheet->
m_Uuid );
171 if(
result.sheets.contains( sheetPath ) )
174 SHEET_TEXT_CONTEXT source;
178 for(
const SCH_FIELD& field : sheet->
GetFields() )
179 source.fields.emplace_back( field.GetId(), field.GetName(
false ), field.GetText() );
181 for(
const SCH_SHEET_INSTANCE& sheetInstance : sheet->
GetInstances() )
183 auto& variants = source.variants[sheetInstance.m_Path];
185 for(
const auto& [
name, variant] : sheetInstance.m_Variants )
187 variants.emplace(
name, VARIANT_TEXT_CONTEXT{
189 { variant.m_DNP, variant.m_ExcludedFromSim, variant.m_ExcludedFromBOM,
190 variant.m_ExcludedFromBoard, variant.m_ExcludedFromPosFiles } } );
194 result.sheets.emplace( sheetPath, std::move( source ) );
198 std::ranges::sort(
result.instances, {}, &INSTANCE_TEXT_CONTEXT::path );
207 std::shared_ptr<const COMPONENT_CONTENT>
content;
227 std::map<INST_ID, std::weak_ptr<const SCH_SCREEN::CONNECTIVITY_SOURCE>>
sources;
228 std::map<NODE_ID, std::shared_ptr<const NET_ITEMS>>
netItems;
234 throw std::logic_error(
"ERC sources require applied connectivity outside input capture" );
240 if( !
path.LastScreen() )
243 const auto instance =
engine.Keys().FindInstance(
path.PathRef() );
245 if( !instance ||
Screen( *instance ) !=
path.LastScreen() )
246 throw std::logic_error(
"ERC sources require current connectivity" );
256 for(
const auto& [node, component] :
engine.Published().Components() )
258 const auto old =
netItems.find( node );
260 if( old !=
netItems.end() && old->second->content == component.content )
262 current.emplace( node, old->second );
266 auto membership = std::make_shared<NET_ITEMS>();
267 membership->content = component.content;
269 for(
const ITEM_KEY& item : component.content->items )
270 membership->instances[item.
inst].push_back( item.
item );
272 for(
const SLOT_KEY& slot : component.content->slots )
275 current.emplace( node, std::move( membership ) );
283 std::vector<INST_ID> live;
284 live.reserve(
sources.size() );
286 for(
const auto& [instance, source] :
sources )
289 live.push_back( instance );
297 const auto found =
netItems.find( aNode );
298 return found !=
netItems.end() && std::any_of( found->second->instances.begin(),
299 found->second->instances.end(), [&](
const auto& entry )
301 return std::binary_search( aLive.begin(), aLive.end(), entry.first );
305 std::optional<NODE_ID>
BusNode(
const wxString& aName )
const
307 const auto node =
engine.Published().FindByName( aName );
308 return node &&
engine.Published().Components().at( *node ).content->kind ==
KIND::BUNDLE
309 ? node : std::nullopt;
312 std::optional<NET_GROUP>
Group(
NODE_ID aNode, std::span<const INST_ID> aLive,
313 const std::weak_ptr<const FACADE_STATE>& aState )
const
315 const auto component =
engine.Published().Components().find( aNode );
317 if( component ==
engine.Published().Components().end() || component->second.name ==
INVALID_ID )
320 std::vector<INST_ID> instances;
322 for(
const auto& [instance, items] :
netItems.at( aNode )->instances )
324 if( std::binary_search( aLive.begin(), aLive.end(), instance ) )
325 instances.push_back( instance );
328 if( instances.empty() )
333 result.instances.reserve( instances.size() );
335 for(
INST_ID instance : instances )
336 result.instances.push_back(
NET_VIEW( aState, aNode, instance ) );
341 std::vector<NET_GROUP>
Groups( std::vector<NODE_ID> aNodes, std::span<const INST_ID> aLive,
342 const std::weak_ptr<const FACADE_STATE>& aState )
const
345 std::erase_if( aNodes,
353 return engine.Published().Components().at( aNode ).name;
355 std::vector<NET_GROUP>
result;
356 result.reserve( aNodes.size() );
360 if(
auto group =
Group( node, aLive, aState ) )
369 wxASSERT( wxThread::IsMain() );
370 const auto found =
netItems.find( aNode );
372 if( found ==
netItems.end() || !found->second->instances.contains( aInstance ) || !
Screen( aInstance ) )
375 return &
engine.Published().Components().at( aNode );
385 if( aIgnoreSheet && aComponent.
content->best )
402 const std::weak_ptr<const FACADE_STATE>& aState,
const ITEM_RESULT* aRow =
nullptr )
const
404 const auto& component =
engine.Published().Components().at( aNode );
405 const auto& content = *component.content;
411 const auto* local = aRow && aRow->busSource ? &*aRow->busSource :
nullptr;
413 if( local && !
Resolve( local->source ) )
416 result.schema = local ? local->schema : content.best->schema;
417 result.tree =
engine.FindBusTree(
engine.Keys().Name( local ? aRow->localName : content.best->name ) );
418 wxASSERT(
result.tree && content.best->schema->leaves.size() == content.members.size() );
419 std::span<const SLOT_KEY> slots = content.members;
420 std::vector<SLOT_KEY> localSlots;
424 localSlots.resize(
result.schema->leaves.size() );
428 for(
const auto& [from, to] : alignment.
matched )
429 localSlots[from] = content.members.at( to );
432 localSlots[from] =
SLOT_KEY{ local->source,
static_cast<uint32_t
>( from ) };
437 result.leaves.reserve( slots.size() );
441 const NODE_ID leaf =
engine.Published().SlotComponents().at( slot );
442 const auto& instances =
netItems.at( leaf )->instances;
443 const INST_ID instance = instances.contains( aInstance ) ? aInstance : slot.bundleDriver.inst;
452 const auto found =
sources.find( aInstance );
457 return Screen( found->second );
460 SCH_SCREEN*
Screen(
const std::weak_ptr<const SCH_SCREEN::CONNECTIVITY_SOURCE>& aSource )
const
462 const auto source = aSource.lock();
464 if( !source || !source->screen )
468 const auto& revisions =
engine.Published().Auxiliary().ScreenRevisions();
471 if( revision == revisions.end() )
482 const auto& revisions =
engine.Published().Auxiliary().ScreenRevisions();
489 wxASSERT( wxThread::IsMain() );
496 const auto& rows =
engine.Published().Rows();
497 const auto row = rows.find( aItem );
499 if( row == rows.end() )
524 m_state( std::move( aOther.m_state ) ),
m_id( std::exchange( aOther.m_id, 0 ) )
530 if(
this != &aOther )
533 m_state = std::move( aOther.m_state );
534 m_id = std::exchange( aOther.m_id, 0 );
542 wxASSERT( wxThread::IsMain() );
544 if(
auto state =
m_state.lock() )
545 state->listeners.erase(
m_id );
561 wxASSERT( wxThread::IsMain() );
564 throw std::invalid_argument(
"Connectivity listener is empty" );
566 if(
m_state->nextListener == std::numeric_limits<uint64_t>::max() )
567 throw std::overflow_error(
"Connectivity listener identities exhausted" );
569 const uint64_t
id = ++
m_state->nextListener;
570 m_state->listeners.emplace(
id, std::move( aListener ) );
575 const std::function<
void(
SCH_ITEM* )>& aChangedHandler )
577 wxASSERT( wxThread::IsMain() );
580 throw std::invalid_argument(
"Cannot apply connectivity without a schematic project" );
583 const auto handler = aChangedHandler;
591 chains.
sheets.reserve( paths.size() );
597 std::map<INST_ID, SHEET_SOURCE> sheets;
601 if( !
path.LastScreen() )
607 throw std::logic_error(
"Missing sheet instance while rebuilding netchains" );
609 SCH_SCREEN* screen = state->Screen( *instance );
612 throw std::logic_error(
"Stale screen while rebuilding netchains" );
615 sheets.emplace( *instance, SHEET_SOURCE{ &chains.
sheets.back(), screen } );
618 for(
const auto& [key, row] :
Published().Rows() )
620 const auto sheet = sheets.find( key.inst );
621 SCH_ITEM* item = sheet != sheets.end()
622 ? sheet->second.screen->GetConnectivityItem( key.item ) :
nullptr;
625 throw std::logic_error(
"Stale item while rebuilding netchains" );
632 sheet->second.input->nets.emplace( item, std::move( net ) );
643 std::map<SCREEN_ID, INST_ID> displayed;
647 if(
const auto instance =
Keys().FindInstance(
path.PathRef() ) )
649 if(
SCH_SCREEN* screen = state->Screen( *instance ) )
656 if(
SCH_SCREEN* screen = state->Screen( *current ) )
660 std::set<ITEM_KEY, KEY_LESS> changed(
KEY_LESS{
Keys() } );
662 changed.insert( publishedChanges.begin(), publishedChanges.end() );
666 const auto applyEnds = [](
auto* aItem,
auto aDangling )
668 const bool differs = aItem->IsStartDangling() != bool( aDangling & 1 )
669 || aItem->IsEndDangling() != bool( aDangling & 2 );
670 aItem->SetDanglingState( aDangling & 1, aDangling & 2 );
674 for(
const auto& [key, island] :
Published().Auxiliary().Islands() )
676 SCH_SCREEN* screen = state->Screen( key.inst );
683 if( instance == displayed.end() || instance->second != key.inst )
686 for(
const auto& [
id, dangling] : island.value.dangling )
689 bool differs =
false;
694 switch( item->
Type() )
697 differs = applyEnds(
static_cast<SCH_LINE*
>( item ), dangling );
710 differs = label->SCH_LABEL_BASE::IsDangling() != bool( dangling );
711 label->SetIsDangling( dangling );
716 std::unordered_set<SCH_RULE_AREA*> areas;
718 const auto attached = auxiliary.
RuleAreasOf().find( { id, key.inst } );
720 if( attached != auxiliary.RuleAreasOf().end() )
722 for(
const KIID& areaId : attached->second )
725 areas.insert( live );
729 if( directive->GetConnectedRuleAreas() != areas )
731 directive->ClearConnectedRuleAreas();
734 directive->AddConnectedRuleArea( area );
742 differs =
static_cast<SCH_PIN*
>( item )->SetIsDangling( dangling );
749 changed.insert( { id, key.inst } );
753 for(
const auto& [
id, instance] : displayed )
755 SCH_SCREEN* screen = state->Screen( instance );
762 item->SetConnectivityDirty(
false );
768 state->publicationApplied =
true;
770 const uint64_t generation = state->resetGeneration;
771 const uint64_t dispatch = ++state->dispatchGeneration;
772 std::vector<uint64_t> listeners;
775 if( !state->listeners.empty() )
777 notification = state->engine.Published().Changes();
778 notification.
changedItems.assign( changed.begin(), changed.end() );
779 std::ranges::copy( state->listeners | std::views::keys, std::back_inserter( listeners ) );
783 const auto superseded = [&]()
785 return state->resetGeneration != generation || state->dispatchGeneration != dispatch;
789 const auto deliver = [](
const char* aKind,
const auto& aCall )
795 catch(
const std::exception& error )
797 wxLogTrace(
"KICAD_CONNECTIVITY",
"Connectivity %s failed: %s", aKind, error.what() );
801 wxLogTrace(
"KICAD_CONNECTIVITY",
"Connectivity %s failed with an unknown exception", aKind );
807 for(
const ITEM_KEY& key : changed )
812 if(
SCH_ITEM* item = state->Resolve( key ) )
813 deliver(
"change handler",
821 if( !notification.
Empty() )
823 for( uint64_t
id : listeners )
828 const auto found = state->listeners.find(
id );
830 if( found != state->listeners.end() )
832 const auto listener = found->second;
836 listener( notification );
846 wxASSERT( wxThread::IsMain() );
866 catch(
const std::exception& error )
869 wxLogTrace(
"CONN_SHADOW",
"Shadow connectivity failed: %s", error.what() );
874 wxLogTrace(
"CONN_SHADOW",
"Shadow connectivity failed with an unknown exception" );
883 wxASSERT( wxThread::IsMain() );
884 std::map<wxString, std::set<wxString>> assignments;
886 for(
const auto& [
name, classes] :
Published().Netclasses() )
890 for(
NAME_ID netclass : *classes )
891 names.insert(
Keys().Name( netclass ) );
894 std::vector<wxString> retired;
898 if( !assignments.contains(
name ) )
899 retired.push_back(
name );
902 for(
const wxString&
name : retired )
910 for(
const auto& [
name, classes] : assignments )
912 const auto old = previous.find(
name );
914 if( old == previous.end() || old->second != classes )
925 wxASSERT( wxThread::IsMain() );
929 auto context = CaptureTextContext( aSchematic, aPaths );
930 const bool changed = !context ||
m_state->textContext != context
931 ||
m_state->engine.ExternalSourcesChanged( aPaths,
true );
933 if( changed &&
m_state->textEpoch == std::numeric_limits<uint64_t>::max() )
934 throw std::overflow_error(
"Connectivity text epoch exhausted" );
941 aliases.insert_or_assign( alias->GetName(), alias->Members() );
944 Update( aPaths,
m_state->textEpoch + ( changed ? 1 : 0 ), aliases, aRebuild );
945 m_state->textContext = std::move( context );
950 wxASSERT( wxThread::IsMain() );
953 m_state->publicationApplied =
false;
955 m_state->simulationModels.reset();
959 m_state->engine.Update( aPaths, aTextEpoch, aAliases, aRebuild );
960 decltype(
m_state->sources ) sources;
966 if(
const auto instance =
Keys().FindInstance(
path.PathRef() ) )
972 m_state->sources.swap( sources );
973 m_state->textEpoch = aTextEpoch;
984 m_state->publicationApplied =
false;
986 m_state->simulationModels.reset();
997 wxASSERT( wxThread::IsMain() );
998 ++aFacade.
m_state->publicationHolds;
1003 if(
const auto state =
m_state.lock() )
1004 --state->publicationHolds;
1013 wxASSERT( wxThread::IsMain() );
1015 const auto paths =
m_state->SourcePaths( aSchematic );
1016 const auto vcs = sourceProjectContext( aSchematic );
1017 std::optional<DS_DATA_MODEL> isolated;
1018 struct RESTORE_LAYOUT
1028 if( aIncludeDrawingSheet )
1035 restoreLayout.previous = &original;
1037 isolated->SetPageLayout( layout.utf8_str() );
1041 std::map<KIID_PATH, FACADE_STATE::TEXT_CHECKS> captured;
1045 auto& checks = captured[
path.PathRef()];
1047 if( aIncludeDrawingSheet )
1048 checks.drawingSheet.emplace();
1054 if( aIncludeDrawingSheet )
1059 m_state->textChecks = std::move( captured );
1064 wxASSERT( wxThread::IsMain() );
1067 throw std::logic_error(
"Text sources have not been prepared" );
1069 const auto& captured =
m_state->textChecks->at( aPath );
1071 if( aDrawingSheet && !captured.drawingSheet )
1072 throw std::logic_error(
"Drawing sheet text sources have not been prepared" );
1074 return aDrawingSheet ? *captured.drawingSheet : captured.items;
1079 wxASSERT( wxThread::IsMain() );
1080 m_state->simulationModels.reset();
1081 const auto vcs = sourceProjectContext( aSchematic );
1083 std::map<KIID_PATH, std::vector<SIMULATION_MODEL_FACT>> captured;
1089 m_state->simulationModels = std::move( captured );
1094 wxASSERT( wxThread::IsMain() );
1096 if( !
m_state->simulationModels )
1097 throw std::logic_error(
"Simulation sources have not been prepared" );
1099 return m_state->simulationModels->at( aPath );
1107 return std::nullopt;
1109 const ITEM_KEY key{ aItem, *instance };
1112 return std::nullopt;
1119 const auto state =
m_state.lock();
1120 const auto* row = state ? state->Row(
m_item ) :
nullptr;
1121 return row ? state->Name( state->engine.Published().Components().at( row->component ), aIgnoreSheet ) : wxString();
1126 const auto state =
m_state.lock();
1127 const auto* row = state ? state->Row(
m_item ) :
nullptr;
1128 return row && row->localName !=
INVALID_ID ? state->engine.Keys().Name( row->localName ) : wxString();
1133 const auto state =
m_state.lock();
1134 const auto* row = state ? state->Row(
m_item ) :
nullptr;
1135 return row && row->fullLocalName !=
INVALID_ID ? state->engine.Keys().Name( row->fullLocalName ) : wxString();
1140 const auto state =
m_state.lock();
1141 const auto* row = state ? state->Row(
m_item ) :
nullptr;
1147 const auto state =
m_state.lock();
1148 const auto* row = state ? state->Row(
m_item ) :
nullptr;
1154 const auto state =
m_state.lock();
1155 const auto* row = state ? state->Row(
m_item ) :
nullptr;
1156 return !row || !row->driver;
1161 const auto state =
m_state.lock();
1162 const auto* row = state ? state->Row(
m_item ) :
nullptr;
1163 return row ? row->netCode : 0;
1168 const auto state =
m_state.lock();
1169 const auto* row = state ? state->Row(
m_item ) :
nullptr;
1170 return row ? row->subgraphCode : 0;
1175 const auto state =
m_state.lock();
1176 const auto* row = state ? state->Row(
m_item ) :
nullptr;
1177 return row && row->driver ? state->Resolve( *row->driver ) :
nullptr;
1182 std::vector<SCH_ITEM*>
result;
1183 const auto state =
m_state.lock();
1185 if( !state || !state->Row(
m_item ) )
1188 const auto& neighbors = state->engine.Published().Auxiliary().NeighborsOf();
1189 const auto found = neighbors.find(
m_item );
1191 if( found == neighbors.end() )
1194 result.reserve( found->second.size() );
1196 for(
const KIID&
id : found->second )
1198 if(
SCH_ITEM* item = state->Resolve( { id, m_item.inst } ) )
1199 result.push_back( item );
1207 const auto state =
m_state.lock();
1208 const auto* row = state ? state->Row(
m_item ) :
nullptr;
1209 return row ? state->Sheet( row->driver ) :
KIID_PATH();
1214 const auto state =
m_state.lock();
1215 const auto* row = state ? state->Row(
m_item ) :
nullptr;
1224 return std::nullopt;
1226 const auto* row =
m_state->Row( { aItem, *instance } );
1229 return std::nullopt;
1236 const auto live =
m_state->LiveInstances();
1237 std::vector<NET_GROUP>
result;
1251 const auto live =
m_state->LiveInstances();
1252 std::vector<wxString>
result;
1257 if(
m_state->AnyLive( node, live ) )
1270 return std::nullopt;
1278 const auto node =
m_state->BusNode( aName );
1283 const auto live =
m_state->LiveInstances();
1285 if( !
m_state->AnyLive( *node, live ) )
1289 std::vector<NODE_ID> nodes( members.begin(), members.end() );
1290 nodes.push_back( *node );
1298 if( parents.empty() )
1301 const auto live =
m_state->LiveInstances();
1303 if( !
m_state->AnyLive( aSignal, live ) )
1306 return m_state->Groups( { parents.begin(), parents.end() }, live,
m_state );
1311 const auto node =
m_state->BusNode( aName );
1316 const auto live =
m_state->LiveInstances();
1318 if( !
m_state->AnyLive( *node, live ) )
1322 std::erase_if( names, [&](
const wxString&
name )
1332 const auto state =
m_state.lock();
1338 const auto state =
m_state.lock();
1340 return net ? state->Name( *net, aIgnoreSheet ) : wxString();
1345 const auto state =
m_state.lock();
1352 const auto state =
m_state.lock();
1359 const auto state =
m_state.lock();
1361 return net && net->content->best ? state->Resolve( net->content->best->source ) :
nullptr;
1366 const auto state =
m_state.lock();
1368 return net && net->content->best ? state->Sheet( net->content->best->source ) :
KIID_PATH();
1373 const auto state =
m_state.lock();
1380 std::vector<SCH_ITEM*>
result;
1381 const auto state =
m_state.lock();
1387 result.reserve( ids.size() );
1389 for(
const KIID&
id : ids )
1391 if(
SCH_ITEM* item = state->Resolve( { id, m_instance } ) )
1392 result.push_back( item );
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
Handle the graphic items list to draw/plot the frame and title block.
static DS_DATA_MODEL & GetTheInstance()
Return the instance of DS_DATA_MODEL used in the application.
void SaveInString(wxString *aOutputString)
Save the description in a buffer.
static void SetAltInstance(DS_DATA_MODEL *aLayout=nullptr)
Set an alternate instance of DS_DATA_MODEL.
KICAD_T Type() const
Returns the type of object.
NET_SETTINGS stores various net-related settings in a project context.
void ClearCacheForNet(const wxString &netName)
Clears the net cache and cached bus classes derived from that net.
void ClearNetclassLabelAssignment(const wxString &netName)
Clears a specific net name to netclass assignment Calling user is responsible for resetting the effec...
void SetNetclassLabelAssignment(const wxString &netName, const std::set< wxString > &netclasses)
Sets a net name to netclasses assignment Calling user is responsible for resetting the effective netc...
const std::map< wxString, std::set< wxString > > & GetNetclassLabelAssignments() const
Gets all current net name to netclasses assignments.
wxString GetTypeAsString() const
const VECTOR2D & GetSizeMils() const
std::shared_ptr< NET_SETTINGS > & NetSettings()
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual PROJECT_FILE & GetProjectFile() const
Holds all the data relating to one schematic.
SCH_CONNECTIVITY::NETCHAIN_MANAGER & NetChains() const
wxString GetVariantDescription(const wxString &aVariantName) const
Return the description for a variant.
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const
const std::vector< std::shared_ptr< BUS_ALIAS > > & GetAllBusAliases() const
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
PROJECT & Project() const
Return a reference to the project this schematic is part of.
wxString GetCurrentVariant() const
Return the current variant being edited.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
SCH_SHEET_PATH & CurrentSheet() const
Base class for a bus or wire entry.
const AREA_INDEX & RuleAreasOf() const
Owns one key/version session and its current stage evaluations; main-thread use only.
Model-owned source resolver.
std::optional< NET_GROUP > NetByName(const wxString &aName) const
void Update(SCHEMATIC &aSchematic, bool aRebuild=false)
std::optional< NET_VIEW > GetSubgraphForItem(const KIID &aItem, const KIID_PATH &aPath) const
void Recalculate(SCHEMATIC &aSchematic, bool aRebuild=false, const std::function< void(SCH_ITEM *)> &aChangedHandler={})
Update the complete model and apply netclasses, dangling flags and dirty-state clearing.
void ApplyNetclasses(NET_SETTINGS &aSettings) const
Replace label-derived assignments from a complete publication; invalidate changed net caches.
std::vector< NET_GROUP > GetNetMap() const
Owned query-time groups in canonical name order, with unique instances in KIID_PATH order.
std::vector< TEXT_CHECK_FACT > TextChecks(const KIID_PATH &aPath, bool aDrawingSheet=false) const
std::vector< wxString > NetNames() const
const SESSION_KEYS & Keys() const
void PrepareSimulationModels(SCHEMATIC &aSchematic)
const ENGINE & Engine() const
void updateModel(SCHEMATIC &aSchematic, const SCH_SHEET_LIST &aPaths, bool aRebuild)
Capture the text context and advance the text epoch when it or an external source changed.
void PrepareTextChecks(SCHEMATIC &aSchematic, bool aIncludeDrawingSheet=false)
std::vector< SIMULATION_MODEL_FACT > SimulationModels(const KIID_PATH &aPath) const
bool UpdateShadow(SCHEMATIC &aSchematic, const SCH_SHEET_LIST &aPaths, bool aRebuild=false)
std::optional< ITEM_VIEW > Connection(const KIID &aItem, const KIID_PATH &aPath) const
const PUBLICATION & Published() const
SUBSCRIPTION Subscribe(std::function< void(const CHANGE_SET &)> aListener)
std::vector< wxString > GetEquivalentBusNames(const wxString &aName) const
std::vector< NET_GROUP > BundlesOf(NODE_ID aSignal) const
std::shared_ptr< FACADE_STATE > m_state
std::vector< NET_GROUP > BusWithMembers(const wxString &aName) const
Excludes derived graph text and shares dynamic source values through nested resolvers.
bool IsUnconnected() const
wxString FullLocalName() const
BUS_MEMBERS Members() const
SCH_ITEM * Driver() const
wxString Name(bool aIgnoreSheet=false) const
wxString LocalName() const
std::weak_ptr< const FACADE_STATE > m_state
uint32_t SubgraphCode() const
std::vector< SCH_ITEM * > ConnectedItems() const
void Rebuild(const NETCHAIN_INPUT &aConnectivity, const std::function< void(NETCHAIN_MANAGER &)> &aBeforePublish={})
void ApplyNetChainNetclasses()
Mirror each committed net chain's netclass override into the project NET_SETTINGS as a chain-derived ...
wxString Name(bool aIgnoreSheet=false) const
BUS_MEMBERS Members() const
SCH_ITEM * Driver() const
std::vector< SCH_ITEM * > Items() const
KIID_PATH Instance() const
std::weak_ptr< const FACADE_STATE > m_state
PUBLICATION_HOLD(const FACADE &aFacade)
std::weak_ptr< FACADE_STATE > m_state
std::span< const NODE_ID > MembersOf(NODE_ID aBundle) const
std::vector< wxString > EquivalentBusNames(const wxString &aName) const
const AUXILIARY & Auxiliary() const
std::span< const NODE_ID > ParentsOf(NODE_ID aSignal) const
const CHANGE_SET & Changes() const
std::optional< NODE_ID > FindByName(const wxString &aName) const
static bool Active()
True inside a render scope, unless an INPUT_TEXT_SCOPE is also active.
Session IDs are dense handles, never a canonical ordering.
const wxString & Name(NAME_ID aId) const
const KIID_PATH & Instance(INST_ID aId) const
std::optional< INST_ID > FindInstance(const KIID_PATH &aPath) const
Main-thread registration owner.
SUBSCRIPTION & operator=(const SUBSCRIPTION &)=delete
std::weak_ptr< FACADE_STATE > m_state
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
void SetConnectivityDirty(bool aDirty=true)
Set the dirty flag.
Segment description base class to describe items which have 2 end points (track, wire,...
static wxString MakeKey(const wxString &aName, uint32_t aComponent)
const PAGE_INFO & GetPageSettings() const
uint64_t ConnectivityId() const
Process-local lifetime identity; file UUIDs can be shared by distinct screens.
uint64_t ConnectivityRevision() const
The only change signal that the connectivity engine reads from this screen.
EE_RTREE & Items()
Get the full RTree, usually for iterating.
const wxString & GetFileName() const
std::weak_ptr< const CONNECTIVITY_SOURCE > ConnectivitySource() const
SCH_ITEM * GetConnectivityItem(const KIID &aId) const
Resolve a drawing item or a connectable child on this screen; ambiguous IDs return null.
TITLE_BLOCK & GetTitleBlock()
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
const KIID_PATH & PathRef() const
Borrow the cached path until this sheet path is modified or destroyed.
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
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
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
const wxString & GetCompany() const
const wxString & GetRevision() const
const wxString & GetDate() const
const wxString & GetComment(int aIdx) const
const wxString & GetTitle() const
bool equivalent(SIM_MODEL::DEVICE_T a, SIM_MODEL::DEVICE_T b)
Value keys and the key session of the schematic connectivity engine.
std::map< wxString, std::vector< wxString > > BUS_ALIASES
Bus alias table, from alias name to member texts.
uint32_t INST_ID
Session handle of a sheet instance KIID_PATH.
std::vector< SIMULATION_MODEL_FACT > ExtractSimulationModelFacts(const SCH_SHEET_PATH &aPath, const wxString &aVariantName)
std::vector< TEXT_CHECK_FACT > ExtractTextChecks(const SCH_SCREEN &aScreen, const SCH_SHEET_PATH &aPath)
uint32_t NAME_ID
Session handle of a name, ordered by UTF-8 value through NAME_LESS.
uint64_t SCREEN_ID
Process-local SCH_SCREEN::ConnectivityId(), never a file UUID.
uint32_t NODE_ID
Session handle of a NODE_KEY graph node.
std::vector< TEXT_CHECK_FACT > ExtractDrawingSheetTextChecks(const SCH_SCREEN &aScreen, const SCH_SHEET_PATH &aPath)
TEXT_EVAL::ENVIRONMENT TEXT_ENVIRONMENT
BUS_ALIGNMENT Align(const BUS_SCHEMA &aLeft, const BUS_SCHEMA &aRight)
Match the leaves of aLeft to the leaves of aRight.
constexpr uint32_t INVALID_ID
Marks an unset handle.
wxString GetContextPath()
Return the current context path for repo-scoped VCS queries.
bool GetContextIsFile()
File/directory classification captured when the current context was activated.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
Member correspondence between two bus schemas.
std::vector< size_t > unmappedLeft
Left leaf ordinals without a right partner.
std::vector< std::pair< size_t, size_t > > matched
Pairs of left and right leaf ordinals.
Query-time snapshot; reacquire after Update.
Difference between two publications.
std::vector< ITEM_KEY > changedItems
Items whose row, island, rule area, source or text changed.
std::shared_ptr< const COMPONENT_CONTENT > content
std::map< INST_ID, std::vector< KIID > > instances
std::optional< std::vector< TEXT_CHECK_FACT > > drawingSheet
std::vector< TEXT_CHECK_FACT > items
std::map< NODE_ID, std::shared_ptr< const NET_ITEMS > > netItems
std::optional< NODE_ID > BusNode(const wxString &aName) const
std::vector< NET_GROUP > Groups(std::vector< NODE_ID > aNodes, std::span< const INST_ID > aLive, const std::weak_ptr< const FACADE_STATE > &aState) const
uint64_t dispatchGeneration
std::vector< INST_ID > LiveInstances() const
const ITEM_RESULT * Row(const ITEM_KEY &aItem) const
KIID_PATH Sheet(const std::optional< ITEM_KEY > &aDriver) const
const PUBLISHED_COMPONENT * Net(NODE_ID aNode, INST_ID aInstance) const
std::optional< NET_GROUP > Group(NODE_ID aNode, std::span< const INST_ID > aLive, const std::weak_ptr< const FACADE_STATE > &aState) const
wxString Name(const PUBLISHED_COMPONENT &aComponent, bool aIgnoreSheet) const
unsigned publicationHolds
std::map< INST_ID, std::weak_ptr< const SCH_SCREEN::CONNECTIVITY_SOURCE > > sources
bool AnyLive(NODE_ID aNode, std::span< const INST_ID > aLive) const
std::map< uint64_t, std::function< void(const CHANGE_SET &)> > listeners
BUS_MEMBERS Members(NODE_ID aNode, INST_ID aInstance, const std::weak_ptr< const FACADE_STATE > &aState, const ITEM_RESULT *aRow=nullptr) const
bool Current(const SCH_SCREEN &aScreen) const
SCH_SCREEN * Screen(const std::weak_ptr< const SCH_SCREEN::CONNECTIVITY_SOURCE > &aSource) const
SCH_ITEM * Resolve(const ITEM_KEY &aItem) const
std::optional< MODEL_TEXT_CONTEXT > textContext
SCH_SHEET_LIST SourcePaths(SCHEMATIC &aSchematic) const
std::optional< std::map< KIID_PATH, std::vector< SIMULATION_MODEL_FACT > > > simulationModels
SCH_SCREEN * Screen(INST_ID aInstance) const
std::optional< std::map< KIID_PATH, TEXT_CHECKS > > textChecks
One item or pin in one sheet instance.
KIID item
The item or pin KIID.
INST_ID inst
The sheet instance that shows the item.
Published connection of one item on one sheet instance.
Orders keys by value through SESSION_KEYS::Less().
Orders name handles by UTF-8 value.
One published net or bus with its identity.
NAME_ID name
Unique name, invalid without a claim.
std::shared_ptr< const COMPONENT_CONTENT > content
One member position of a bus.
ITEM_KEY bundleDriver
The source item of the claim that defines the leaf order.
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< double > VECTOR2D