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:
parent
8260f0ee13
commit
b2177718a1
|
@ -45,6 +45,8 @@
|
|||
#include <sch_edit_frame.h>
|
||||
#include <sch_plugins/kicad/sch_sexpr_plugin.h>
|
||||
#include <sch_line.h>
|
||||
#include <sch_junction.h>
|
||||
#include <sch_bus_entry.h>
|
||||
#include <sch_shape.h>
|
||||
#include <sch_painter.h>
|
||||
#include <sch_sheet.h>
|
||||
|
@ -1282,7 +1284,23 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
|
|||
getView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||
[]( 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;
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2148,8 +2148,15 @@ void DIALOG_NET_INSPECTOR::onDeleteNet( wxCommandEvent& aEvent )
|
|||
m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||
[removedCode]( KIGFX::VIEW_ITEM* aItem ) -> bool
|
||||
{
|
||||
if( auto bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem ) )
|
||||
return bci->GetNetCode() == removedCode;
|
||||
auto boardItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
|
||||
|
||||
if( boardItem && boardItem->GetNetCode() == removedCode )
|
||||
return true;
|
||||
|
||||
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
|
||||
|
||||
if( text && text->HasTextVars() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
|
|
@ -87,10 +87,31 @@ void PCB_EDIT_FRAME::OnNetlistChanged( BOARD_NETLIST_UPDATER& aUpdater, bool* aR
|
|||
|
||||
SetMsgPanel( board );
|
||||
|
||||
// Update rendered tracks and vias net labels
|
||||
// TODO is there a way to extract information about which nets were modified?
|
||||
for( auto track : board->Tracks() )
|
||||
GetCanvas()->GetView()->Update( track );
|
||||
// Update rendered track/via/pad net labels, and any text items that might reference a
|
||||
// netName or netClass
|
||||
int netNamesCfg = GetPcbNewSettings()->m_Display.m_NetNames;
|
||||
|
||||
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.
|
||||
std::vector<FOOTPRINT*> newFootprints = aUpdater.GetAddedFootprints();
|
||||
|
|
|
@ -1144,25 +1144,27 @@ void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage )
|
|||
PCBNEW_SETTINGS* settings = GetPcbNewSettings();
|
||||
static LSET maskAndPasteLayers = LSET( 4, F_Mask, F_Paste, B_Mask, B_Paste );
|
||||
|
||||
bool maskOrPasteVisible = ( GetBoard()->GetVisibleLayers() & maskAndPasteLayers ).any();
|
||||
|
||||
GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||
[&]( KIGFX::VIEW_ITEM* aItem ) -> bool
|
||||
{
|
||||
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 ) )
|
||||
{
|
||||
return settings->m_Display.m_PadClearance || maskOrPasteVisible;
|
||||
if( settings->m_Display.m_PadClearance )
|
||||
return true;
|
||||
|
||||
if( ( GetBoard()->GetVisibleLayers() & maskAndPasteLayers ).any() )
|
||||
return true;
|
||||
}
|
||||
else if( dynamic_cast<EDA_TEXT*>( aItem ) )
|
||||
{
|
||||
|
||||
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
|
||||
|
||||
return text->HasTextVars();
|
||||
}
|
||||
if( text && text->HasTextVars() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
|
|
@ -302,20 +302,12 @@ int BOARD_EDITOR_CONTROL::PageSettings( const TOOL_EVENT& aEvent )
|
|||
m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||
[&]( KIGFX::VIEW_ITEM* aItem ) -> bool
|
||||
{
|
||||
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aItem );
|
||||
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
|
||||
|
||||
if( text && text->HasTextVars() )
|
||||
return true;
|
||||
|
||||
if( !item )
|
||||
return false;
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case PCB_TEXT_T:
|
||||
case PCB_FP_TEXT_T:
|
||||
return true; // text variables
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
|
||||
m_frame->OnModify();
|
||||
|
|
Loading…
Reference in New Issue