Tighten up refresh logic for net & netclass references.

Also tightens it up a bit for text variables which can reference things
like netnames and netclasses, but also board settings.

Fixes https://gitlab.com/kicad/code/kicad/issues/13032
This commit is contained in:
Jeff Young 2022-11-29 15:17:38 +00:00
parent 8260f0ee13
commit b2177718a1
5 changed files with 69 additions and 29 deletions

View File

@ -45,6 +45,8 @@
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <sch_plugins/kicad/sch_sexpr_plugin.h> #include <sch_plugins/kicad/sch_sexpr_plugin.h>
#include <sch_line.h> #include <sch_line.h>
#include <sch_junction.h>
#include <sch_bus_entry.h>
#include <sch_shape.h> #include <sch_shape.h>
#include <sch_painter.h> #include <sch_painter.h>
#include <sch_sheet.h> #include <sch_sheet.h>
@ -1282,7 +1284,23 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
getView()->UpdateAllItemsConditionally( KIGFX::REPAINT, getView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
[]( KIGFX::VIEW_ITEM* aItem ) -> bool []( KIGFX::VIEW_ITEM* aItem ) -> bool
{ {
return dynamic_cast<SCH_LINE*>( aItem ); // Netclass coloured items
//
if( dynamic_cast<SCH_LINE*>( aItem ) )
return true;
else if( dynamic_cast<SCH_JUNCTION*>( aItem ) )
return true;
else if( dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem ) )
return true;
// Items that might reference an item's netclass name
//
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
if( text && text->HasTextVars() )
return true;
return false;
} ); } );
} }
} }

View File

@ -2148,8 +2148,15 @@ void DIALOG_NET_INSPECTOR::onDeleteNet( wxCommandEvent& aEvent )
m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT, m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
[removedCode]( KIGFX::VIEW_ITEM* aItem ) -> bool [removedCode]( KIGFX::VIEW_ITEM* aItem ) -> bool
{ {
if( auto bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem ) ) auto boardItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
return bci->GetNetCode() == removedCode;
if( boardItem && boardItem->GetNetCode() == removedCode )
return true;
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
if( text && text->HasTextVars() )
return true;
return false; return false;
} ); } );

View File

@ -87,10 +87,31 @@ void PCB_EDIT_FRAME::OnNetlistChanged( BOARD_NETLIST_UPDATER& aUpdater, bool* aR
SetMsgPanel( board ); SetMsgPanel( board );
// Update rendered tracks and vias net labels // Update rendered track/via/pad net labels, and any text items that might reference a
// TODO is there a way to extract information about which nets were modified? // netName or netClass
for( auto track : board->Tracks() ) int netNamesCfg = GetPcbNewSettings()->m_Display.m_NetNames;
GetCanvas()->GetView()->Update( track );
GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
[&]( KIGFX::VIEW_ITEM* aItem ) -> bool
{
if( dynamic_cast<PCB_TRACK*>( aItem ) )
{
if( netNamesCfg == 2 || netNamesCfg == 3 )
return true;
}
else if( dynamic_cast<PAD*>( aItem ) )
{
if( netNamesCfg == 1 || netNamesCfg == 3 )
return true;
}
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
if( text && text->HasTextVars() )
return true;
return false;
} );
// Spread new footprints. // Spread new footprints.
std::vector<FOOTPRINT*> newFootprints = aUpdater.GetAddedFootprints(); std::vector<FOOTPRINT*> newFootprints = aUpdater.GetAddedFootprints();

View File

@ -1144,26 +1144,28 @@ void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage )
PCBNEW_SETTINGS* settings = GetPcbNewSettings(); PCBNEW_SETTINGS* settings = GetPcbNewSettings();
static LSET maskAndPasteLayers = LSET( 4, F_Mask, F_Paste, B_Mask, B_Paste ); static LSET maskAndPasteLayers = LSET( 4, F_Mask, F_Paste, B_Mask, B_Paste );
bool maskOrPasteVisible = ( GetBoard()->GetVisibleLayers() & maskAndPasteLayers ).any();
GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT, GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
[&]( KIGFX::VIEW_ITEM* aItem ) -> bool [&]( KIGFX::VIEW_ITEM* aItem ) -> bool
{ {
if( dynamic_cast<PCB_TRACK*>( aItem ) ) if( dynamic_cast<PCB_TRACK*>( aItem ) )
{ {
return settings->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS; if( settings->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS )
return true;
} }
else if( dynamic_cast<PAD*>( aItem ) ) else if( dynamic_cast<PAD*>( aItem ) )
{ {
return settings->m_Display.m_PadClearance || maskOrPasteVisible; if( settings->m_Display.m_PadClearance )
} return true;
else if( dynamic_cast<EDA_TEXT*>( aItem ) )
{
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
return text->HasTextVars(); if( ( GetBoard()->GetVisibleLayers() & maskAndPasteLayers ).any() )
return true;
} }
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
if( text && text->HasTextVars() )
return true;
return false; return false;
} ); } );

View File

@ -294,7 +294,7 @@ int BOARD_EDITOR_CONTROL::PageSettings( const TOOL_EVENT& aEvent )
m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS ); m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS );
DIALOG_PAGES_SETTINGS dlg( m_frame, pcbIUScale.IU_PER_MILS, wxSize( MAX_PAGE_SIZE_PCBNEW_MILS, DIALOG_PAGES_SETTINGS dlg( m_frame, pcbIUScale.IU_PER_MILS, wxSize( MAX_PAGE_SIZE_PCBNEW_MILS,
MAX_PAGE_SIZE_PCBNEW_MILS ) ); MAX_PAGE_SIZE_PCBNEW_MILS ) );
dlg.SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName ); dlg.SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )
@ -302,20 +302,12 @@ int BOARD_EDITOR_CONTROL::PageSettings( const TOOL_EVENT& aEvent )
m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT, m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
[&]( KIGFX::VIEW_ITEM* aItem ) -> bool [&]( KIGFX::VIEW_ITEM* aItem ) -> bool
{ {
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aItem ); EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
if( !item ) if( text && text->HasTextVars() )
return false; return true;
switch( item->Type() ) return false;
{
case PCB_TEXT_T:
case PCB_FP_TEXT_T:
return true; // text variables
default:
return false;
}
} ); } );
m_frame->OnModify(); m_frame->OnModify();