Fix merging of subgraphs with multiple labels
This commit is contained in:
parent
ff8b7cc6c1
commit
ec2c571abb
|
@ -143,26 +143,18 @@ bool CONNECTION_SUBGRAPH::ResolveDrivers( bool aCreateMarkers )
|
||||||
}
|
}
|
||||||
|
|
||||||
// For power connections, we allow multiple drivers
|
// For power connections, we allow multiple drivers
|
||||||
if( highest_priority == 5 && candidates.size() > 1 &&
|
if( highest_priority >= 4 && candidates.size() > 1 )
|
||||||
candidates[0]->Type() == SCH_PIN_T )
|
m_multiple_drivers = true;
|
||||||
{
|
|
||||||
auto pin = static_cast<SCH_PIN*>( candidates[0] );
|
|
||||||
|
|
||||||
wxASSERT( pin->IsPowerConnection() );
|
if( aCreateMarkers && m_multiple_drivers )
|
||||||
|
|
||||||
m_multiple_power_ports = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( aCreateMarkers && !m_multiple_power_ports &&
|
|
||||||
candidates.size() > 1 && highest_priority > 1 )
|
|
||||||
{
|
{
|
||||||
// First check if all the candidates are actually the same
|
// First check if all the candidates are actually the same
|
||||||
bool same = true;
|
bool same = true;
|
||||||
auto first = candidates[0]->Connection( m_sheet )->Name();
|
auto first = GetNameForDriver( candidates[0] );
|
||||||
|
|
||||||
for( unsigned i = 1; i < candidates.size(); i++ )
|
for( unsigned i = 1; i < candidates.size(); i++ )
|
||||||
{
|
{
|
||||||
if( candidates[i]->Connection( m_sheet )->Name() != first )
|
if( GetNameForDriver( candidates[i] ) != first )
|
||||||
{
|
{
|
||||||
same = false;
|
same = false;
|
||||||
break;
|
break;
|
||||||
|
@ -249,6 +241,39 @@ std::vector<SCH_ITEM*> CONNECTION_SUBGRAPH::GetBusLabels()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString CONNECTION_SUBGRAPH::GetNameForDriver( SCH_ITEM* aItem )
|
||||||
|
{
|
||||||
|
wxString name;
|
||||||
|
|
||||||
|
switch( aItem->Type() )
|
||||||
|
{
|
||||||
|
case SCH_PIN_T:
|
||||||
|
{
|
||||||
|
auto power_object = static_cast<SCH_PIN*>( aItem );
|
||||||
|
name = power_object->GetDefaultNetName( m_sheet );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SCH_LABEL_T:
|
||||||
|
case SCH_GLOBAL_LABEL_T:
|
||||||
|
{
|
||||||
|
auto label = static_cast<SCH_TEXT*>( aItem );
|
||||||
|
|
||||||
|
SCH_CONNECTION conn;
|
||||||
|
conn.ConfigureFromLabel( label->GetText() );
|
||||||
|
|
||||||
|
name = conn.Name();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void CONNECTION_GRAPH::Reset()
|
void CONNECTION_GRAPH::Reset()
|
||||||
{
|
{
|
||||||
for( auto sg : m_subgraphs )
|
for( auto sg : m_subgraphs )
|
||||||
|
@ -1032,25 +1057,20 @@ void CONNECTION_GRAPH::buildConnectionGraph()
|
||||||
|
|
||||||
// Collapse power nets that are shorted together
|
// Collapse power nets that are shorted together
|
||||||
|
|
||||||
if( subgraph->m_multiple_power_ports )
|
if( subgraph->m_multiple_drivers )
|
||||||
{
|
{
|
||||||
for( auto obj : subgraph->m_drivers )
|
for( auto obj : subgraph->m_drivers )
|
||||||
{
|
{
|
||||||
if( obj == subgraph->m_driver )
|
if( obj == subgraph->m_driver )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto power_object = dynamic_cast<SCH_PIN*>( obj );
|
wxString name = subgraph->GetNameForDriver( obj );
|
||||||
|
|
||||||
// Skip drivers that aren't power ports
|
|
||||||
if( !power_object )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto name = power_object->GetDefaultNetName( subgraph->m_sheet );
|
|
||||||
int code = -1;
|
|
||||||
|
|
||||||
if( m_net_name_to_code_map.count( name ) == 0 )
|
if( m_net_name_to_code_map.count( name ) == 0 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
int code = m_net_name_to_code_map.at( name );
|
||||||
|
|
||||||
for( auto subgraph_to_update : m_subgraphs )
|
for( auto subgraph_to_update : m_subgraphs )
|
||||||
{
|
{
|
||||||
if( !subgraph_to_update->m_driver )
|
if( !subgraph_to_update->m_driver )
|
||||||
|
|
|
@ -61,7 +61,7 @@ class CONNECTION_SUBGRAPH
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CONNECTION_SUBGRAPH( SCH_EDIT_FRAME* aFrame ) :
|
CONNECTION_SUBGRAPH( SCH_EDIT_FRAME* aFrame ) :
|
||||||
m_dirty( false ), m_code( -1 ), m_multiple_power_ports( false ),
|
m_dirty( false ), m_code( -1 ), m_multiple_drivers( false ),
|
||||||
m_strong_driver( false ), m_no_connect( nullptr ), m_bus_entry( nullptr ),
|
m_strong_driver( false ), m_no_connect( nullptr ), m_bus_entry( nullptr ),
|
||||||
m_driver( nullptr ), m_frame( aFrame ), m_driver_connection( nullptr )
|
m_driver( nullptr ), m_frame( aFrame ), m_driver_connection( nullptr )
|
||||||
{}
|
{}
|
||||||
|
@ -84,12 +84,19 @@ public:
|
||||||
/// Returns all the bus labels attached to this subgraph (if any)
|
/// Returns all the bus labels attached to this subgraph (if any)
|
||||||
std::vector<SCH_ITEM*> GetBusLabels();
|
std::vector<SCH_ITEM*> GetBusLabels();
|
||||||
|
|
||||||
|
// Returns the candidate net name for a driver
|
||||||
|
wxString GetNameForDriver( SCH_ITEM* aItem );
|
||||||
|
|
||||||
bool m_dirty;
|
bool m_dirty;
|
||||||
|
|
||||||
long m_code;
|
long m_code;
|
||||||
|
|
||||||
/// True if this subgraph contains multiple power ports to join in one net
|
/**
|
||||||
bool m_multiple_power_ports;
|
* True if this subgraph contains more than one driver that should be
|
||||||
|
* shorted together in the netlist. For example, two labels or
|
||||||
|
* two power ports.
|
||||||
|
*/
|
||||||
|
bool m_multiple_drivers;
|
||||||
|
|
||||||
/// True if the driver is "strong": a label or power object
|
/// True if the driver is "strong": a label or power object
|
||||||
bool m_strong_driver;
|
bool m_strong_driver;
|
||||||
|
|
Loading…
Reference in New Issue