Schematic/Fields Table: handle sheet changes

This commit is contained in:
Mike Williams 2023-08-20 16:13:07 -04:00
parent ab06f277c5
commit a9c4534a38
5 changed files with 42 additions and 13 deletions

View File

@ -2113,6 +2113,15 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnSchItemsChanged( SCHEMATIC& aSch
}
void DIALOG_SYMBOL_FIELDS_TABLE::OnSchSheetChanged( SCHEMATIC& aSch )
{
m_dataModel->SetPath( aSch.CurrentSheet() );
if( m_dataModel->GetScope() != FIELDS_EDITOR_GRID_DATA_MODEL::SCOPE::SCOPE_ALL )
m_dataModel->RebuildRows();
}
SCH_REFERENCE_LIST DIALOG_SYMBOL_FIELDS_TABLE::getSymbolReferences( SCH_SYMBOL* aSymbol )
{
SCH_SHEET_LIST allSheets = m_parent->Schematic().GetSheets();

View File

@ -105,9 +105,11 @@ private:
void ApplyBomFmtPreset( const wxString& aPresetName );
void ApplyBomFmtPreset( const BOM_FMT_PRESET& aPreset );
// Schematic listener event handlers
void OnSchItemsAdded( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aSchItem ) override;
void OnSchItemsRemoved( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aSchItem ) override;
void OnSchItemsChanged( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aSchItem ) override;
void OnSchSheetChanged( SCHEMATIC& aSch ) override;
private:
SCH_REFERENCE_LIST getSymbolReferences( SCH_SYMBOL* aSymbol );

View File

@ -2191,6 +2191,8 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
editTool->UpdateNetHighlighting( dummy );
m_hierarchy->UpdateHierarchySelection();
m_schematic->OnSchSheetChanged();
}

View File

@ -691,6 +691,18 @@ void SCHEMATIC::OnItemsRemoved( std::vector<SCH_ITEM*>& aRemovedItems )
}
void SCHEMATIC::OnItemsChanged( std::vector<SCH_ITEM*>& aItems )
{
InvokeListeners( &SCHEMATIC_LISTENER::OnSchItemsChanged, *this, aItems );
}
void SCHEMATIC::OnSchSheetChanged()
{
InvokeListeners( &SCHEMATIC_LISTENER::OnSchSheetChanged, *this );
}
void SCHEMATIC::AddListener( SCHEMATIC_LISTENER* aListener )
{
if( !alg::contains( m_listeners, aListener ) )
@ -716,12 +728,6 @@ void SCHEMATIC::RemoveAllListeners()
}
void SCHEMATIC::OnItemsChanged( std::vector<SCH_ITEM*>& aItems )
{
InvokeListeners( &SCHEMATIC_LISTENER::OnSchItemsChanged, *this, aItems );
}
void SCHEMATIC::RecordERCExclusions()
{
SCH_SHEET_LIST sheetList = GetSheets();

View File

@ -59,6 +59,9 @@ public:
virtual void OnSchItemsAdded( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aSchItem ) {}
virtual void OnSchItemsRemoved( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aSchItem ) {}
virtual void OnSchItemsChanged( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aSchItem ) {}
// This is called when the user changes to a new sheet, not when a sheet is altered.
// Sheet alteration events will call OnSchItems*
virtual void OnSchSheetChanged( SCHEMATIC& aSch ) {}
};
/**
@ -261,6 +264,19 @@ public:
*/
void OnItemsRemoved( std::vector<SCH_ITEM*>& aRemovedItems );
/**
* Notify the schematic and its listeners that an item on the schematic has
* been modified in some way.
*/
void OnItemsChanged( std::vector<SCH_ITEM*>& aItems );
/**
* Notify the schematic and its listeners that the current sheet has been changed.
* This is called when the user navigates to a different sheet, not when the sheet is
* altered.
*/
void OnSchSheetChanged();
/**
* Add a listener to the schematic to receive calls whenever something on the
* schematic has been modified. The schematic does not take ownership of the
@ -282,12 +298,6 @@ public:
*/
void RemoveAllListeners();
/**
* Notify the schematic and its listeners that an item on the schematic has
* been modified in some way.
*/
void OnItemsChanged( std::vector<SCH_ITEM*>& aItems );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override {}
#endif