Finish moving eeschema assigned netclasses to sheet-path-relative.

Also adds code for the case where a new label is created on a net
with an existing netclass assignment.

Fixes https://gitlab.com/kicad/code/kicad/issues/5886
This commit is contained in:
Jeff Young 2020-10-07 15:40:12 +01:00
parent cfc636d25f
commit 4565631728
18 changed files with 157 additions and 138 deletions

View File

@ -238,10 +238,23 @@ NET_SETTINGS::~NET_SETTINGS()
}
const wxString& NET_SETTINGS::GetNetclassName( const wxString& aNetName ) const
{
static wxString defaultNetname = NETCLASS::Default;
auto it = m_NetClassAssignments.find( aNetName );
if( it == m_NetClassAssignments.end() )
return defaultNetname;
else
return it->second;
}
static bool isSuperSub( wxChar c )
{
return c == '_' || c == '^';
};
}
bool NET_SETTINGS::ParseBusVector( const wxString& aBus, wxString* aName,

View File

@ -120,8 +120,8 @@ bool CONNECTION_SUBGRAPH::ResolveDrivers( bool aCreateMarkers )
std::sort( candidates.begin(), candidates.end(),
[&]( SCH_ITEM* a, SCH_ITEM* b ) -> bool
{
SCH_CONNECTION* ac = a->Connection( m_sheet );
SCH_CONNECTION* bc = b->Connection( m_sheet );
SCH_CONNECTION* ac = a->Connection( &m_sheet );
SCH_CONNECTION* bc = b->Connection( &m_sheet );
// Ensure we don't pick the subset over the superset
if( ac->IsBus() && bc->IsBus() )
@ -145,7 +145,7 @@ bool CONNECTION_SUBGRAPH::ResolveDrivers( bool aCreateMarkers )
// Cache driver connection
if( m_driver )
m_driver_connection = m_driver->Connection( m_sheet );
m_driver_connection = m_driver->Connection( &m_sheet );
else
m_driver_connection = nullptr;
@ -193,7 +193,7 @@ wxString CONNECTION_SUBGRAPH::GetNetName() const
if( !m_driver || m_dirty )
return "";
if( !m_driver->Connection( m_sheet ) )
if( !m_driver->Connection( &m_sheet ) )
{
#ifdef CONNECTIVITY_DEBUG
wxASSERT_MSG( false, "Tried to get the net name of an item with no connection" );
@ -202,7 +202,7 @@ wxString CONNECTION_SUBGRAPH::GetNetName() const
return "";
}
return m_driver->Connection( m_sheet )->Name();
return m_driver->Connection( &m_sheet )->Name();
}
@ -217,7 +217,7 @@ std::vector<SCH_ITEM*> CONNECTION_SUBGRAPH::GetBusLabels() const
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
{
SCH_CONNECTION* label_conn = item->Connection( m_sheet );
SCH_CONNECTION* label_conn = item->Connection( &m_sheet );
// Only consider bus vectors
if( label_conn->Type() == CONNECTION_TYPE::BUS )
@ -273,7 +273,7 @@ void CONNECTION_SUBGRAPH::Absorb( CONNECTION_SUBGRAPH* aOther )
for( SCH_ITEM* item : aOther->m_items )
{
item->Connection( m_sheet )->SetSubgraphCode( m_code );
item->Connection( &m_sheet )->SetSubgraphCode( m_code );
AddItem( item );
}
@ -294,7 +294,7 @@ void CONNECTION_SUBGRAPH::AddItem( SCH_ITEM* aItem )
{
m_items.push_back( aItem );
if( aItem->Connection( m_sheet )->IsDriver() )
if( aItem->Connection( &m_sheet )->IsDriver() )
m_drivers.push_back( aItem );
if( aItem->Type() == SCH_SHEET_PIN_T )
@ -311,7 +311,7 @@ void CONNECTION_SUBGRAPH::UpdateItemConnections()
for( SCH_ITEM* item : m_items )
{
SCH_CONNECTION* item_conn = item->Connection( m_sheet );
SCH_CONNECTION* item_conn = item->Connection( &m_sheet );
if( !item_conn )
item_conn = item->InitializeConnection( m_sheet, m_graph );
@ -455,11 +455,11 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
{
for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
{
if( !pin->Connection( aSheet ) )
if( !pin->Connection( &aSheet ) )
pin->InitializeConnection( aSheet, this );
pin->ConnectedItems( aSheet ).clear();
pin->Connection( aSheet )->Reset();
pin->Connection( &aSheet )->Reset();
connection_map[ pin->GetTextPos() ].push_back( pin );
m_items.emplace_back( pin );
@ -616,7 +616,7 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
// Set up the link between the bus entry net and the bus
if( connected_item->Type() == SCH_BUS_WIRE_ENTRY_T )
{
if( test_item->Connection( aSheet )->IsBus() )
if( test_item->Connection( &aSheet )->IsBus() )
{
auto bus_entry = static_cast<SCH_BUS_WIRE_ENTRY*>( connected_item );
bus_entry->m_connected_bus_item = test_item;
@ -696,7 +696,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
auto get_items =
[&]( SCH_ITEM* aItem ) -> bool
{
auto* conn = aItem->Connection( sheet );
auto* conn = aItem->Connection( &sheet );
if( !conn )
conn = aItem->InitializeConnection( sheet, this );
@ -713,7 +713,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
if( connected_item->Type() == SCH_NO_CONNECT_T )
subgraph->m_no_connect = connected_item;
auto connected_conn = connected_item->Connection( sheet );
auto connected_conn = connected_item->Connection( &sheet );
wxASSERT( connected_conn );
@ -817,7 +817,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
// Now the subgraph has only one driver
SCH_ITEM* driver = subgraph->m_driver;
SCH_SHEET_PATH sheet = subgraph->m_sheet;
SCH_CONNECTION* connection = driver->Connection( sheet );
SCH_CONNECTION* connection = driver->Connection( &sheet );
connection->ConfigureFromLabel( subgraph->GetNameForDriver( driver ) );
connection->SetDriver( driver );
@ -911,7 +911,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
continue;
}
SCH_CONNECTION* connection = pin->Connection( sheet );
SCH_CONNECTION* connection = pin->Connection( &sheet );
if( !connection )
connection = pin->InitializeConnection( sheet, this );
@ -1461,7 +1461,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
SCH_SHEET_PATH path = subgraph->m_sheet;
path.push_back( sheet );
SCH_CONNECTION* parent_conn = label->Connection( path );
SCH_CONNECTION* parent_conn = label->Connection( &path );
if( parent_conn && parent_conn->IsBus() )
subgraph->m_driver_connection->SetType( CONNECTION_TYPE::BUS );
@ -1943,7 +1943,7 @@ std::vector<const CONNECTION_SUBGRAPH*> CONNECTION_GRAPH::GetBusesNeedingMigrati
continue;
auto sheet = subgraph->m_sheet;
auto connection = subgraph->m_driver->Connection( sheet );
auto connection = subgraph->m_driver->Connection( &sheet );
if( !connection->IsBus() )
continue;
@ -2156,7 +2156,7 @@ bool CONNECTION_GRAPH::ercCheckBusToBusConflicts( const CONNECTION_SUBGRAPH* aSu
case SCH_TEXT_T:
case SCH_GLOBAL_LABEL_T:
{
if( !label && item->Connection( sheet )->IsBus() )
if( !label && item->Connection( &sheet )->IsBus() )
label = item;
break;
}
@ -2164,7 +2164,7 @@ bool CONNECTION_GRAPH::ercCheckBusToBusConflicts( const CONNECTION_SUBGRAPH* aSu
case SCH_SHEET_PIN_T:
case SCH_HIER_LABEL_T:
{
if( !port && item->Connection( sheet )->IsBus() )
if( !port && item->Connection( &sheet )->IsBus() )
port = item;
break;
}
@ -2178,9 +2178,9 @@ bool CONNECTION_GRAPH::ercCheckBusToBusConflicts( const CONNECTION_SUBGRAPH* aSu
{
bool match = false;
for( const auto& member : label->Connection( sheet )->Members() )
for( const auto& member : label->Connection( &sheet )->Members() )
{
for( const auto& test : port->Connection( sheet )->Members() )
for( const auto& test : port->Connection( &sheet )->Members() )
{
if( test != member && member->Name() == test->Name() )
{
@ -2242,14 +2242,14 @@ bool CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts( const CONNECTION_SUBGRAPH
// In some cases, the connection list (SCH_CONNECTION*) can be null.
// Skip null connections.
if( bus_entry->Connection( sheet ) && bus_wire->Type() == SCH_LINE_T
&& bus_wire->Connection( sheet ) )
if( bus_entry->Connection( &sheet ) && bus_wire->Type() == SCH_LINE_T
&& bus_wire->Connection( &sheet ) )
{
conflict = true;
auto test_name = bus_entry->Connection( sheet )->Name( true );
auto test_name = bus_entry->Connection( &sheet )->Name( true );
for( const auto& member : bus_wire->Connection( sheet )->Members() )
for( const auto& member : bus_wire->Connection( &sheet )->Members() )
{
if( member->Type() == CONNECTION_TYPE::BUS )
{
@ -2391,8 +2391,8 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
&& !pin->IsVisible()
&& !pin->GetLibPin()->GetParent()->IsPower() )
{
wxString name = pin->Connection( sheet )->Name();
wxString local_name = pin->Connection( sheet )->Name( true );
wxString name = pin->Connection( &sheet )->Name();
wxString local_name = pin->Connection( &sheet )->Name( true );
if( m_global_label_cache.count( name ) ||
( m_local_label_cache.count( std::make_pair( sheet, local_name ) ) ) )

View File

@ -184,7 +184,7 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow()
else if( selection.GetSize() )
{
SCH_ITEM* sch_item = (SCH_ITEM*) selection.Front();
SCH_CONNECTION* connection = sch_item->Connection( m_parent->GetCurrentSheet() );
SCH_CONNECTION* connection = sch_item->Connection();
if( connection )
m_netFilter->SetValue( connection->Name() );
@ -302,7 +302,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
{
if( m_netFilterOpt->GetValue() && !m_netFilter->GetValue().IsEmpty() )
{
SCH_CONNECTION* connection = aItem->Connection( aSheetPath );
SCH_CONNECTION* connection = aItem->Connection( &aSheetPath );
if( !connection )
return;

View File

@ -153,7 +153,7 @@ void NETLIST_EXPORTER::CreatePinList( SCH_COMPONENT* comp, SCH_SHEET_PATH* aShee
{
for( const auto& pin : comp->GetPins( aSheetPath ) )
{
if( auto conn = pin->Connection( *aSheetPath ) )
if( auto conn = pin->Connection( aSheetPath ) )
{
const wxString& netName = conn->Name();
@ -234,7 +234,7 @@ void NETLIST_EXPORTER::findAllUnitsOfComponent( SCH_COMPONENT* aComponent,
for( const auto& pin : comp2->GetPins( aSheetPath ) )
{
if( auto conn = pin->Connection( *aSheetPath ) )
if( auto conn = pin->Connection( aSheetPath ) )
{
const wxString& netName = conn->Name();

View File

@ -422,7 +422,7 @@ void SCH_BUS_ENTRY_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEM
if( !frame )
return;
if( auto conn = Connection( frame->GetCurrentSheet() ) )
if( SCH_CONNECTION* conn = Connection() )
conn->AppendInfoToMsgPanel( aList );
}

View File

@ -29,9 +29,7 @@
#include <dialogs/dialog_schematic_find.h>
#include <eeschema_id.h>
#include <executable_names.h>
#include <general.h>
#include <gestfich.h>
#include <gr_basic.h>
#include <hierarch.h>
#include <html_messagebox.h>
#include <invoke_sch_dialog.h>
@ -44,7 +42,7 @@
#include <profile.h>
#include <project.h>
#include <project/project_file.h>
#include <reporter.h>
#include <project/net_settings.h>
#include <sch_edit_frame.h>
#include <sch_iref.h>
#include <sch_painter.h>
@ -73,12 +71,10 @@
#include <tools/sch_line_wire_bus_tool.h>
#include <tools/sch_move_tool.h>
#include <tools/sch_navigate_tool.h>
#include <view/view.h>
#include <view/view_controls.h>
#include <widgets/infobar.h>
#include <wildcards_and_files_ext.h>
#include <wx/cmdline.h>
#include <gal/graphics_abstraction_layer.h>
#include <ws_proxy_view_item.h>
@ -1017,6 +1013,53 @@ bool SCH_EDIT_FRAME::isAutoSaveRequired() const
}
static void inheritNetclass( const SCH_SHEET_PATH& aSheetPath, SCH_TEXT* aItem )
{
// Netclasses are assigned to subgraphs by association with their netname. However, when
// a new label is attached to an existing subgraph (with an existing netclass association),
// the association will be lost as the label will drive its name on to the graph.
//
// Here we find the previous driver of the subgraph and if it had a netclass we associate
// the new netname with that netclass as well.
//
SCHEMATIC* schematic = aItem->Schematic();
CONNECTION_SUBGRAPH* subgraph = schematic->ConnectionGraph()->GetSubgraphForItem( aItem );
std::map<wxString, wxString>& netclassAssignments =
schematic->Prj().GetProjectFile().NetSettings().m_NetClassAssignments;
if( subgraph )
{
SCH_ITEM* previousDriver = nullptr;
CONNECTION_SUBGRAPH::PRIORITY priority = CONNECTION_SUBGRAPH::PRIORITY::INVALID;
for( SCH_ITEM* item : subgraph->m_items )
{
if( item == aItem )
continue;
CONNECTION_SUBGRAPH::PRIORITY p = CONNECTION_SUBGRAPH::GetDriverPriority( item );
if( p > priority )
{
priority = p;
previousDriver = item;
}
}
if( previousDriver )
{
wxString path = aSheetPath.PathHumanReadable();
wxString oldDrivenName = path + subgraph->GetNameForDriver( previousDriver );
wxString drivenName = path + subgraph->GetNameForDriver( aItem );
if( netclassAssignments.count( oldDrivenName ) )
netclassAssignments[ drivenName ] = netclassAssignments[ oldDrivenName ];
}
}
}
void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_SCREEN* aScreen, SCH_ITEM* aItem,
bool aUndoAppend )
{
@ -1072,7 +1115,12 @@ void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_SCREEN* aScreen, SCH_ITEM*
// Update connectivity info for new item
if( !aItem->IsMoving() )
{
RecalculateConnections( LOCAL_CLEANUP );
if( SCH_TEXT* textItem = dynamic_cast<SCH_TEXT*>( aItem ) )
inheritNetclass( GetCurrentSheet(), textItem );
}
}
aItem->ClearFlags( IS_NEW );
@ -1520,38 +1568,6 @@ void SCH_EDIT_FRAME::FocusOnItem( SCH_ITEM* aItem )
}
void SCH_EDIT_FRAME::ConvertTimeStampUuids()
{
// Remove this once this method is fully implemented. Otherwise, don't use it.
wxCHECK( false, /* void */ );
// Replace sheet and symbol time stamps with real UUIDs and update symbol instance
// sheet paths using the new UUID based sheet paths.
// Save the time stamp sheet paths.
SCH_SHEET_LIST timeStampSheetPaths = Schematic().GetSheets();
std::vector<KIID_PATH> oldSheetPaths = timeStampSheetPaths.GetPaths();
// The root sheet now gets a permanent UUID.
const_cast<KIID&>( Schematic().Root().m_Uuid ).ConvertTimestampToUuid();
SCH_SCREENS schematic( Schematic().Root() );
// Change the sheet and symbol time stamps to UUIDs.
for( SCH_SCREEN* screen = schematic.GetFirst(); screen; screen = schematic.GetNext() )
{
for( auto sheet : screen->Items().OfType( SCH_SHEET_T ) )
const_cast<KIID&>( sheet->m_Uuid ).ConvertTimestampToUuid();
for( auto symbol : screen->Items().OfType( SCH_COMPONENT_T ) )
const_cast<KIID&>( symbol->m_Uuid ).ConvertTimestampToUuid();
}
timeStampSheetPaths.ReplaceLegacySheetPaths( oldSheetPaths );
}
wxString SCH_EDIT_FRAME::GetCurrentFileName() const
{
return Schematic().GetFileName();

View File

@ -927,17 +927,6 @@ public:
void FocusOnItem( SCH_ITEM* aItem );
/**
* Convert sheet and symbol legacy time stamp UUIDs to full UUIDs.
*
* @warning This is a work in progress. It only contains the original code that automatically
* updated the UUIDs when loading legacy schematics. This is an incomplete solution
* because a way to force a PCB update from schematic with the update symbol links
* from references setting must be executed to ensure proper synchronization between
* the schematic and board.
*/
void ConvertTimeStampUuids();
/**
* Update the #LIB_PART of the currently selected symbol.
*

View File

@ -144,28 +144,33 @@ bool SCH_ITEM::IsConnected( const wxPoint& aPosition ) const
}
SCH_CONNECTION* SCH_ITEM::Connection( const SCH_SHEET_PATH& aSheet ) const
SCH_CONNECTION* SCH_ITEM::Connection( const SCH_SHEET_PATH* aSheet ) const
{
// Warning: the m_connection_map can be empty.
if( m_connection_map.size() && m_connection_map.count( aSheet ) )
return m_connection_map.at( aSheet );
if( !aSheet )
aSheet = &Schematic()->CurrentSheet();
return nullptr;
auto it = m_connection_map.find( *aSheet );
if( it == m_connection_map.end() )
return nullptr;
else
return it->second;
}
NETCLASSPTR SCH_ITEM::NetClass() const
NETCLASSPTR SCH_ITEM::NetClass( const SCH_SHEET_PATH* aSheet ) const
{
if( m_connection_map.size() )
{
NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings();
const wxString& netname = m_connection_map.begin()->second->Name( true );
const wxString& netclassName = netSettings.m_NetClassAssignments[ netname ];
SCH_CONNECTION* connection = Connection( aSheet );
if( connection )
{
NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings();
const wxString& netclassName = netSettings.GetNetclassName( connection->Name() );
if( !netclassName.IsEmpty() )
return netSettings.m_NetClasses.Find( netclassName );
else
return netSettings.m_NetClasses.GetDefault();
}
}
return nullptr;
@ -187,18 +192,20 @@ void SCH_ITEM::AddConnectionTo( const SCH_SHEET_PATH& aSheet, SCH_ITEM* aItem )
SCH_CONNECTION* SCH_ITEM::InitializeConnection( const SCH_SHEET_PATH& aSheet,
CONNECTION_GRAPH* aGraph )
{
if( Connection( aSheet ) )
SCH_CONNECTION* connection = Connection( &aSheet );
if( connection )
{
Connection( aSheet )->Reset();
Connection( aSheet )->SetSheet( aSheet );
return Connection( aSheet );
connection->Reset();
}
else
{
connection = new SCH_CONNECTION( this );
m_connection_map.insert( std::make_pair( aSheet, connection ) );
connection->SetGraph( aGraph );
}
auto connection = new SCH_CONNECTION( this );
connection->SetSheet( aSheet );
m_connection_map.insert( std::make_pair( aSheet, connection ) );
connection->SetGraph( aGraph );
return connection;
}

View File

@ -411,7 +411,7 @@ public:
*
* @note The returned value can be nullptr.
*/
SCH_CONNECTION* Connection( const SCH_SHEET_PATH& aPath ) const;
SCH_CONNECTION* Connection( const SCH_SHEET_PATH* aSheet = nullptr ) const;
/**
* Retrieves the set of items connected to this item on the given sheet
@ -439,7 +439,7 @@ public:
void SetConnectivityDirty( bool aDirty = true ) { m_connectivity_dirty = aDirty; }
NETCLASSPTR NetClass() const;
NETCLASSPTR NetClass( const SCH_SHEET_PATH* aSheet = nullptr ) const;
/**
* Return whether the fields have been automatically placed.

View File

@ -825,7 +825,7 @@ void SCH_LINE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
if( frame )
{
if( SCH_CONNECTION* conn = Connection( frame->GetCurrentSheet() ) )
if( SCH_CONNECTION* conn = Connection() )
{
conn->AppendInfoToMsgPanel( aList );

View File

@ -1307,7 +1307,7 @@ void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer )
if( m_schematic )
{
SCH_CONNECTION* conn = aText->Connection( m_schematic->CurrentSheet() );
SCH_CONNECTION* conn = aText->Connection();
if( conn && conn->IsBus() )
color = getRenderColor( aText, LAYER_BUS, drawingShadows );
@ -1612,7 +1612,7 @@ void SCH_PAINTER::draw( SCH_HIERLABEL *aLabel, int aLayer )
if( m_schematic )
{
SCH_CONNECTION* conn = aLabel->Connection( m_schematic->CurrentSheet() );
SCH_CONNECTION* conn = aLabel->Connection();
if( conn && conn->IsBus() )
color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );

View File

@ -196,7 +196,7 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
if( !frame )
return;
SCH_CONNECTION* conn = Connection( frame->GetCurrentSheet() );
SCH_CONNECTION* conn = Connection();
if( conn )
conn->AppendInfoToMsgPanel( aList );

View File

@ -671,7 +671,7 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
if( frame )
{
if( SCH_CONNECTION* conn = Connection( frame->GetCurrentSheet() ) )
if( SCH_CONNECTION* conn = Connection() )
{
conn->AppendInfoToMsgPanel( aList );
@ -1111,7 +1111,7 @@ void SCH_HIERLABEL::Print( RENDER_SETTINGS* aSettings, const wxPoint& offset )
static std::vector <wxPoint> Poly;
wxDC* DC = aSettings->GetPrintDC();
SCH_CONNECTION* conn = Connection( Schematic()->CurrentSheet() );
SCH_CONNECTION* conn = Connection();
bool isBus = conn && conn->IsBus();
COLOR4D color = aSettings->GetLayerColor( isBus ? LAYER_BUS : m_Layer );
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );

View File

@ -369,7 +369,7 @@ void BACK_ANNOTATE::applyChangelist()
const wxString& pinNumber = entry.first;
const wxString& shortNetName = entry.second;
SCH_PIN* pin = comp->GetPin( pinNumber );
SCH_CONNECTION* conn = pin->Connection( ref.GetSheetPath() );
SCH_CONNECTION* conn = pin->Connection( &ref.GetSheetPath() );
wxString key = shortNetName + ref.GetSheetPath().PathAsString();
@ -492,11 +492,12 @@ void BACK_ANNOTATE::processNetNameChange( SCH_CONNECTION* aConn, const wxString&
if( !m_dryRun )
{
SCH_SCREEN* screen = aConn->Sheet().LastScreen();
SCH_SHEET_PATH sheet = aConn->Sheet();
SCH_SCREEN* screen = sheet.LastScreen();
for( SCH_ITEM* label : screen->Items().OfType( SCH_LABEL_T ) )
{
SCH_CONNECTION* conn = label->Connection( aConn->Sheet() );
SCH_CONNECTION* conn = label->Connection( &sheet );
if( conn && conn->Driver() == driver )
{

View File

@ -643,11 +643,9 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
if( !item )
return false;
SCH_SHEET_PATH& sheet = m_frame->GetCurrentSheet();
if( item->IsType( wires ) )
{
if( SCH_CONNECTION* conn = static_cast<SCH_ITEM*>( item )->Connection( sheet ) )
if( SCH_CONNECTION* conn = static_cast<SCH_ITEM*>( item )->Connection() )
simFrame->AddVoltagePlot( UnescapeString( conn->Name() ) );
}
else if( item->Type() == SCH_PIN_T )
@ -667,7 +665,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
else
param = wxString::Format( wxT( "I%s" ), pin->GetName().Lower() );
simFrame->AddCurrentPlot( comp->GetRef( &sheet ), param );
simFrame->AddCurrentPlot( comp->GetRef( &m_frame->GetCurrentSheet() ), param );
}
return true;
@ -691,7 +689,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
if( wire )
{
item = nullptr;
conn = wire->Connection( m_frame->GetCurrentSheet() );
conn = wire->Connection();
}
if( item && item->Type() == SCH_PIN_T )
@ -853,10 +851,10 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
std::vector<SCH_PIN*> pins = comp->GetPins();
if( pins.size() == 1 )
conn = pins[0]->Connection( editFrame->GetCurrentSheet() );
conn = pins[0]->Connection();
}
else
conn = item->Connection( editFrame->GetCurrentSheet() );
conn = item->Connection();
}
}
}
@ -919,17 +917,17 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
if( conn )
{
wxString netName = conn->Name( true );
if( conn->Name( true ).IsEmpty() )
if( !conn->Driver() || CONNECTION_SUBGRAPH::GetDriverPriority( conn->Driver() )
< CONNECTION_SUBGRAPH::PRIORITY::SHEET_PIN )
{
m_frame->ShowInfoBarError( _( "Net must be labelled to assign a netclass." ) );
highlightNet( m_toolMgr, CLEAR );
return 0;
}
wxString netName = conn->Name();
NET_SETTINGS& netSettings = m_frame->Schematic().Prj().GetProjectFile().NetSettings();
wxString netclassName = netSettings.m_NetClassAssignments[ netName ];
wxString netclassName = netSettings.GetNetclassName( netName );
wxArrayString headers;
std::vector<wxArrayString> items;
@ -1015,9 +1013,9 @@ int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent )
comp = static_cast<SCH_COMPONENT*>( item );
if( comp && comp->GetPartRef() && comp->GetPartRef()->IsPower() )
itemConn = comp->Connection( m_frame->GetCurrentSheet() );
itemConn = comp->Connection();
else
itemConn = item->Connection( m_frame->GetCurrentSheet() );
itemConn = item->Connection();
if( selectedIsNoNet && selectedSubgraph )
{
@ -1073,7 +1071,7 @@ int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent )
for( SCH_PIN* pin : comp->GetPins() )
{
SCH_CONNECTION* pin_conn = pin->Connection( m_frame->GetCurrentSheet() );
SCH_CONNECTION* pin_conn = pin->Connection();
if( pin_conn && pin_conn->Name() == selectedName )
{
@ -1099,7 +1097,7 @@ int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent )
{
for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
{
SCH_CONNECTION* pin_conn = pin->Connection( m_frame->GetCurrentSheet() );
SCH_CONNECTION* pin_conn = pin->Connection();
bool redrawPin = pin->IsBrightened();
if( pin_conn && pin_conn->Name() == selectedName )

View File

@ -119,7 +119,7 @@ private:
return;
}
SCH_CONNECTION* connection = bus->Connection( frame->GetCurrentSheet() );
SCH_CONNECTION* connection = bus->Connection();
if( !connection || !connection->IsBus() || connection->Members().empty() )
{

View File

@ -51,6 +51,8 @@ public:
std::map<wxString, KIGFX::COLOR4D> m_PcbNetColors;
public:
const wxString& GetNetclassName( const wxString& aNetName ) const;
/**
* Parses a bus vector (e.g. A[7..0]) into name, begin, and end.
* Ensures that begin and end are positive and that end > begin.

View File

@ -1388,16 +1388,9 @@ void BOARD::SynchronizeNetsAndNetClasses()
for( NETINFO_ITEM* net : m_NetInfo )
{
const wxString& netname = net->GetNetname();
const wxString& netclassName = netSettings->GetNetclassName( netname );
if( netSettings->m_NetClassAssignments.count( netname ) )
{
const wxString& classname = netSettings->m_NetClassAssignments[ netname ];
net->SetClass( netClasses.Find( classname ) );
}
else
{
net->SetClass( defaultNetClass );
}
net->SetClass( netClasses.Find( netclassName ) );
}
BOARD_DESIGN_SETTINGS& bds = GetDesignSettings();