Coding policy and Doxygen comment fixes.

This commit is contained in:
Wayne Stambaugh 2023-10-12 09:36:28 -04:00
parent 499f3ca95b
commit 5d6ef69726
16 changed files with 374 additions and 258 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 CERN
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Jon Evans <jon@craftyjon.com>
*
@ -52,13 +52,14 @@
#include <advanced_config.h> // for realtime connectivity switch in release builds
/*
/**
* Flag to enable connectivity profiling
* @ingroup trace_env_vars
*/
static const wxChar DanglingProfileMask[] = wxT( "CONN_PROFILE" );
/*
/**
* Flag to enable connectivity tracing
* @ingroup trace_env_vars
*/
@ -230,7 +231,8 @@ bool CONNECTION_SUBGRAPH::ResolveDrivers( bool aCheckMultipleDrivers )
}
void CONNECTION_SUBGRAPH::getAllConnectedItems( std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>>& aItems, std::set<CONNECTION_SUBGRAPH*>& aSubgraphs )
void CONNECTION_SUBGRAPH::getAllConnectedItems( std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>>& aItems,
std::set<CONNECTION_SUBGRAPH*>& aSubgraphs )
{
CONNECTION_SUBGRAPH* sg = this;
@ -500,7 +502,8 @@ CONNECTION_SUBGRAPH::PRIORITY CONNECTION_SUBGRAPH::GetDriverPriority( SCH_ITEM*
if( sch_pin->IsGlobalPower() )
return PRIORITY::POWER_PIN;
else if( !sym || sym->GetExcludedFromBoard() || sym->GetLibSymbolRef()->GetReferenceField().GetText().StartsWith( '#' ) )
else if( !sym || sym->GetExcludedFromBoard()
|| sym->GetLibSymbolRef()->GetReferenceField().GetText().StartsWith( '#' ) )
return PRIORITY::NONE;
else
return PRIORITY::PIN;
@ -613,6 +616,7 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco
for( const SCH_SHEET_PATH& sheet : aSheetList )
{
std::vector<SCH_ITEM*> items;
// Store current unit value, to regenerate it after calculations
// (useful in complex hierarchies)
std::vector<std::pair<SCH_SYMBOL*, int>> symbolsChanged;
@ -626,6 +630,7 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco
items.push_back( item );
dirty_items.insert( item );
}
// Ensure the hierarchy info stored in SCREENS is built and up to date
// (multi-unit symbols)
if( item->Type() == SCH_SYMBOL_T )
@ -676,6 +681,7 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco
recalc_time.Show();
}
std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> CONNECTION_GRAPH::ExtractAffectedItems(
const std::set<SCH_ITEM*> &aItems )
{
@ -834,7 +840,8 @@ void CONNECTION_GRAPH::removeSubgraphs( std::set<CONNECTION_SUBGRAPH*>& aSubgrap
++it;
}
for( auto it = m_net_code_to_subgraphs_map.begin(); it != m_net_code_to_subgraphs_map.end(); )
for( auto it = m_net_code_to_subgraphs_map.begin();
it != m_net_code_to_subgraphs_map.end(); )
{
if( remove_sg( it ) )
{
@ -845,7 +852,8 @@ void CONNECTION_GRAPH::removeSubgraphs( std::set<CONNECTION_SUBGRAPH*>& aSubgrap
++it;
}
for( auto it = m_net_name_to_subgraphs_map.begin(); it != m_net_name_to_subgraphs_map.end(); )
for( auto it = m_net_name_to_subgraphs_map.begin();
it != m_net_name_to_subgraphs_map.end(); )
{
if( remove_sg( it ) )
it = m_net_name_to_subgraphs_map.erase( it );
@ -951,6 +959,7 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
case SCH_BUS_BUS_ENTRY_T:
conn->SetType( CONNECTION_TYPE::BUS );
// clean previous (old) links:
static_cast<SCH_BUS_BUS_ENTRY*>( item )->m_connected_bus_items[0] = nullptr;
static_cast<SCH_BUS_BUS_ENTRY*>( item )->m_connected_bus_items[1] = nullptr;
@ -962,6 +971,7 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
case SCH_BUS_WIRE_ENTRY_T:
conn->SetType( CONNECTION_TYPE::NET );
// clean previous (old) link:
static_cast<SCH_BUS_WIRE_ENTRY*>( item )->m_connected_bus_item = nullptr;
break;
@ -1124,7 +1134,6 @@ void CONNECTION_GRAPH::buildItemSubGraphs()
}
// Build subgraphs from items (on a per-sheet basis)
for( SCH_ITEM* item : m_items )
{
for( const auto& it : item->m_connection_map )
@ -1365,16 +1374,17 @@ void CONNECTION_GRAPH::generateBusAliasMembers()
new_conn->SetType( CONNECTION_TYPE::NET );
int code = assignNewNetCode( *new_conn );
wxLogTrace( ConnTrace, wxS( "SG(%ld), Adding full local name (%s) with sg (%d) on subsheet %s" ), subgraph->m_code,
name, code, subgraph->m_sheet.PathHumanReadable() );
wxLogTrace( ConnTrace, wxS( "SG(%ld), Adding full local name (%s) with sg (%d) "
"on subsheet %s" ),
subgraph->m_code, name, code, subgraph->m_sheet.PathHumanReadable() );
new_sg->m_driver_connection = new_conn;
new_sg->m_code = m_last_subgraph_code++;
new_sg->m_sheet = subgraph->GetSheet();
new_sg->m_is_bus_member = true;
new_sg->m_strong_driver = true;
/// Need to figure out why these sgs are not getting connected to their bus parents
/// Need to figure out why these sgs are not getting connected to their bus parents
NET_NAME_CODE_CACHE_KEY key = { new_sg->GetNetName(), code };
m_net_code_to_subgraphs_map[ key ].push_back( new_sg );
m_net_name_to_subgraphs_map[ name ].push_back( new_sg );
@ -1530,7 +1540,8 @@ void CONNECTION_GRAPH::processSubGraphs()
while( m_net_name_to_subgraphs_map.count( new_name ) )
new_name = create_new_name( connection );
wxLogTrace( ConnTrace, wxS( "%ld (%s) is weakly driven and not unique. Changing to %s." ),
wxLogTrace( ConnTrace,
wxS( "%ld (%s) is weakly driven and not unique. Changing to %s." ),
subgraph->m_code, name, new_name );
alg::delete_matching( *vec, subgraph );
@ -1571,7 +1582,8 @@ void CONNECTION_GRAPH::processSubGraphs()
if( conflict )
{
wxLogTrace( ConnTrace,
wxS( "%ld (%s) skipped for promotion due to potential conflict" ),
wxS( "%ld (%s) skipped for promotion due to potential "
"conflict" ),
subgraph->m_code, name );
}
else
@ -1579,7 +1591,8 @@ void CONNECTION_GRAPH::processSubGraphs()
UNITS_PROVIDER unitsProvider( schIUScale, EDA_UNITS::MILLIMETRES );
wxLogTrace( ConnTrace,
wxS( "%ld (%s) weakly driven by unique sheet pin %s, promoting" ),
wxS( "%ld (%s) weakly driven by unique sheet pin %s, "
"promoting" ),
subgraph->m_code, name,
subgraph->m_driver->GetItemDescription( &unitsProvider ) );
@ -1590,7 +1603,6 @@ void CONNECTION_GRAPH::processSubGraphs()
}
// Assign net codes
if( connection->IsBus() )
{
int code = -1;
@ -1623,7 +1635,6 @@ void CONNECTION_GRAPH::processSubGraphs()
// If this subgraph doesn't have a strong driver, let's skip it, since there is no
// way it will be merged with anything.
if( !subgraph->m_strong_driver )
continue;
@ -1631,7 +1642,6 @@ void CONNECTION_GRAPH::processSubGraphs()
// as the subgraph we are considering that has a strong driver.
// Weakly driven subgraphs are not considered since they will never be absorbed or
// form neighbor links.
std::vector<CONNECTION_SUBGRAPH*> candidate_subgraphs;
std::copy_if( m_sheet_to_subgraphs_map[ subgraph->m_sheet ].begin(),
m_sheet_to_subgraphs_map[ subgraph->m_sheet ].end(),
@ -1671,7 +1681,8 @@ void CONNECTION_GRAPH::processSubGraphs()
connections_to_check.push_back( c );
wxLogTrace( ConnTrace,
wxS( "%lu (%s): Adding secondary driver %s" ), aSubgraph->m_code,
wxS( "%lu (%s): Adding secondary driver %s" ),
aSubgraph->m_code,
aSubgraph->m_driver_connection->Name( true ),
c->Name( true ) );
}
@ -1757,8 +1768,9 @@ void CONNECTION_GRAPH::processSubGraphs()
{
if( connection->IsBus() && candidate->m_driver_connection->IsNet() )
{
wxLogTrace( ConnTrace, wxS( "%lu (%s) has bus child %lu (%s)" ), subgraph->m_code,
connection->Name(), candidate->m_code, member->Name() );
wxLogTrace( ConnTrace, wxS( "%lu (%s) has bus child %lu (%s)" ),
subgraph->m_code, connection->Name(),
candidate->m_code, member->Name() );
subgraph->m_bus_neighbors[member].insert( candidate );
candidate->m_bus_parents[member].insert( subgraph );
@ -1886,7 +1898,6 @@ void CONNECTION_GRAPH::buildConnectionGraph( std::function<void( SCH_ITEM* )>* a
// Next time through the subgraphs, we do some post-processing to handle things like
// connecting bus members to their neighboring subgraphs, and then propagate connections
// through the hierarchy
for( CONNECTION_SUBGRAPH* subgraph : m_driver_subgraphs )
{
if( !subgraph->m_dirty )
@ -1926,8 +1937,9 @@ void CONNECTION_GRAPH::buildConnectionGraph( std::function<void( SCH_ITEM* )>* a
if( conn->Name() == secondary_name )
{
wxLogTrace( ConnTrace, wxS( "Global %lu (%s) promoted to %s" ), candidate->m_code,
conn->Name(), subgraph->m_driver_connection->Name() );
wxLogTrace( ConnTrace, wxS( "Global %lu (%s) promoted to %s" ),
candidate->m_code, conn->Name(),
subgraph->m_driver_connection->Name() );
conn->Clone( *subgraph->m_driver_connection );
@ -1961,11 +1973,11 @@ void CONNECTION_GRAPH::buildConnectionGraph( std::function<void( SCH_ITEM* )>* a
// the bus may have been renamed by a hierarchical connection. So, for each of these cases,
// we need to identify the appropriate bus members to link together (and their final names),
// and then update all instances of the old name in the hierarchy.
for( CONNECTION_SUBGRAPH* subgraph : m_driver_subgraphs )
{
// All SGs should have been processed by propagateToNeighbors above
wxASSERT_MSG( !subgraph->m_dirty, wxS( "Subgraph not processed by propagateToNeighbors!" ) );
wxASSERT_MSG( !subgraph->m_dirty,
wxS( "Subgraph not processed by propagateToNeighbors!" ) );
if( subgraph->m_bus_parents.size() < 2 )
continue;
@ -1999,8 +2011,9 @@ void CONNECTION_GRAPH::buildConnectionGraph( std::function<void( SCH_ITEM* )>* a
{
wxString old_name = match->Name();
wxLogTrace( ConnTrace, wxS( "Updating %lu (%s) member %s to %s" ), parent->m_code,
parent->m_driver_connection->Name(), old_name, conn->Name() );
wxLogTrace( ConnTrace, wxS( "Updating %lu (%s) member %s to %s" ),
parent->m_code, parent->m_driver_connection->Name(),
old_name, conn->Name() );
match->Clone( *conn );
@ -2044,7 +2057,6 @@ void CONNECTION_GRAPH::buildConnectionGraph( std::function<void( SCH_ITEM* )>* a
// As a visual aid, we can check sheet pins that are driven by themselves to see
// if they should be promoted to buses
if( subgraph->m_driver && subgraph->m_driver->Type() == SCH_SHEET_PIN_T )
{
SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( subgraph->m_driver );
@ -2124,7 +2136,7 @@ void CONNECTION_GRAPH::buildConnectionGraph( std::function<void( SCH_ITEM* )>* a
const CONNECTION_SUBGRAPH* driverSubgraph = nullptr;
wxString netclass;
wxCHECK_RET( !subgraphs.empty(), wxT("Invalid empty subgraph" ) );
wxCHECK_RET( !subgraphs.empty(), wxS( "Invalid empty subgraph" ) );
for( const CONNECTION_SUBGRAPH* subgraph : subgraphs )
{
@ -2423,7 +2435,8 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, boo
}
else if( aSubgraph->m_hier_ports.empty() && aSubgraph->m_hier_pins.empty() )
{
wxLogTrace( ConnTrace, wxS( "%lu (%s) has no hier pins or ports on sheet %s; marking clean" ),
wxLogTrace( ConnTrace,
wxS( "%lu (%s) has no hier pins or ports on sheet %s; marking clean" ),
aSubgraph->m_code, conn->Name(), aSubgraph->m_sheet.PathHumanReadable() );
aSubgraph->m_dirty = false;
return;
@ -2721,7 +2734,8 @@ wxString CONNECTION_GRAPH::GetResolvedSubgraphName( const CONNECTION_SUBGRAPH* a
// This is a hacky way to find the true subgraph net name (why do we not store it?)
// TODO: Remove once the actual netname of the subgraph is stored with the subgraph
for( auto it = m_net_name_to_subgraphs_map.begin(); it != m_net_name_to_subgraphs_map.end() && !found; ++it )
for( auto it = m_net_name_to_subgraphs_map.begin();
it != m_net_name_to_subgraphs_map.end() && !found; ++it )
{
for( CONNECTION_SUBGRAPH* graph : it->second )
{
@ -3232,7 +3246,6 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
{
// Any subgraph that contains a no-connect should not
// more than one pin (which would indicate it is connected
for( SCH_ITEM* item : aProcessGraph->m_items )
{
switch( item->Type() )
@ -3307,7 +3320,8 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
ok = false;
}
if( unique_pins.empty() && unique_labels.empty() && settings.IsTestEnabled( ERCE_NOCONNECT_NOT_CONNECTED ) )
if( unique_pins.empty() && unique_labels.empty() &&
settings.IsTestEnabled( ERCE_NOCONNECT_NOT_CONNECTED ) )
{
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_NOT_CONNECTED );
ercItem->SetItems( aSubgraph->m_no_connect );
@ -3446,7 +3460,6 @@ bool CONNECTION_GRAPH::ercCheckFloatingWires( const CONNECTION_SUBGRAPH* aSubgra
// We've gotten this far, so we know we have no valid driver. All we need to do is check
// for a wire that we can place the error on.
for( SCH_ITEM* item : aSubgraph->m_items )
{
if( item->Type() == SCH_LINE_T && item->GetLayer() == LAYER_WIRE )
@ -3483,7 +3496,6 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
// Global labels are flagged if they appear only once, don't connect to any local labels,
// and don't have a no-connect marker
if( !aSubgraph->m_driver_connection )
return true;
@ -3504,8 +3516,11 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
[]( const CONNECTION_SUBGRAPH* aLocSubgraph ) -> int
{
return
std::count_if( aLocSubgraph->m_items.begin(), aLocSubgraph->m_items.end(), []( const SCH_ITEM* item )
{ return item->Type() == SCH_PIN_T; } );
std::count_if( aLocSubgraph->m_items.begin(), aLocSubgraph->m_items.end(),
[]( const SCH_ITEM* item )
{
return item->Type() == SCH_PIN_T;
} );
};
auto reportError = [&]( SCH_TEXT* aText, int errCode )

View File

@ -56,7 +56,6 @@ class SCH_SHEET_PIN;
*
* For example, multiple bus wires can come together at a junction but have
* different labels on each branch. Each label+wire branch is its own subgraph.
*
*/
class CONNECTION_SUBGRAPH
{
@ -95,48 +94,48 @@ public:
friend class CONNECTION_GRAPH;
/**
* Determines which potential driver should drive the subgraph.
* Determine which potential driver should drive the subgraph.
*
* If multiple possible drivers exist, picks one according to the priority.
* If multiple "winners" exist, returns false and sets m_driver to nullptr.
* If multiple "winners" exist, returns false and sets #m_driver to nullptr.
*
* @param aCheckMultipleDrivers controls whether the second driver should be captured for ERC
* @return true if m_driver was set, or false if a conflict occurred
* @param aCheckMultipleDrivers controls whether the second driver should be captured for ERC.
* @return true if m_driver was set, or false if a conflict occurred.
*/
bool ResolveDrivers( bool aCheckMultipleDrivers = false );
/**
* Returns the fully-qualified net name for this subgraph (if one exists)
* Return the fully-qualified net name for this subgraph (if one exists)
*/
wxString GetNetName() const;
/// Returns all the vector-based bus labels attached to this subgraph (if any)
/// Return all the vector-based bus labels attached to this subgraph (if any).
std::vector<SCH_ITEM*> GetVectorBusLabels() const;
/// Returns all the all bus labels attached to this subgraph (if any)
/// Return all the all bus labels attached to this subgraph (if any).
std::vector<SCH_ITEM*> GetAllBusLabels() const;
/// Returns the candidate net name for a driver
/// Return the candidate net name for a driver.
const wxString& GetNameForDriver( SCH_ITEM* aItem ) const;
const wxString GetNetclassForDriver( SCH_ITEM* aItem ) const;
/// Combines another subgraph on the same sheet into this one.
/// Combine another subgraph on the same sheet into this one.
void Absorb( CONNECTION_SUBGRAPH* aOther );
/// Adds a new item to the subgraph
/// Add a new item to the subgraph.
void AddItem( SCH_ITEM* aItem );
/// Updates all items to match the driver connection
/// Update all items to match the driver connection.
void UpdateItemConnections();
/// Provides a read-only reference to the items in the subgraph
/// Provide a read-only reference to the items in the subgraph.
const std::set<SCH_ITEM*>& GetItems() const
{
return m_items;
}
/// Finds all items in the subgraph as well as child subgraphs recursively
/// Find all items in the subgraph as well as child subgraphs recursively.
void getAllConnectedItems( std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>>& aItems,
std::set<CONNECTION_SUBGRAPH*>& aSubgraphs );
@ -166,7 +165,7 @@ public:
/**
* @return pointer to the SCH_ITEM whose name sets the subgraph netname.
* N.B. This item may not be in the subgraph
* N.B. This item may not be in the subgraph.
*/
const SCH_ITEM* GetDriver() const
{
@ -174,7 +173,7 @@ public:
}
/**
* @return SCH_CONNECTION object for m_driver on m_sheet
* @return #SCH_CONNECTION object for m_driver on #m_sheet.
*/
const SCH_CONNECTION* GetDriverConnection() const
{
@ -182,7 +181,7 @@ public:
}
/**
* @return pointer to the item causing a no-connect or nullptr if none
* @return pointer to the item causing a no-connect or nullptr if none.
*/
const SCH_ITEM* GetNoConnect() const
{
@ -227,13 +226,13 @@ private:
*/
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;
/// True if the driver is a local (i.e. non-global) type
/// True if the driver is a local (i.e. non-global) type.
bool m_local_driver;
/// Bus entry in graph, if any
/// Bus entry in graph, if any.
SCH_ITEM* m_bus_entry;
std::set<SCH_ITEM*> m_drivers;
@ -257,34 +256,35 @@ private:
std::unordered_map< std::shared_ptr<SCH_CONNECTION>,
std::unordered_set<CONNECTION_SUBGRAPH*> > m_bus_parents;
// Cache for lookup of any hierarchical (sheet) pins on this subgraph (for referring down)
/// Cache for lookup of any hierarchical (sheet) pins on this subgraph (for referring down).
std::set<SCH_SHEET_PIN*> m_hier_pins;
// Cache for lookup of any hierarchical ports on this subgraph (for referring up)
/// Cache for lookup of any hierarchical ports on this subgraph (for referring up).
std::set<SCH_HIERLABEL*> m_hier_ports;
// If not null, this indicates the subgraph on a higher level sheet that is linked to this one
/// If not null, this indicates the subgraph on a higher level sheet that is linked to this one.
CONNECTION_SUBGRAPH* m_hier_parent;
// If not null, this indicates the subgraph(s) on a lower level sheet that are linked to this one
/// If not null, this indicates the subgraph(s) on a lower level sheet that are linked to
/// this one.
std::unordered_set<CONNECTION_SUBGRAPH*> m_hier_children;
/// A cache of escaped netnames from schematic items
/// A cache of escaped netnames from schematic items.
mutable std::unordered_map<SCH_ITEM*, wxString> m_driver_name_cache;
/// Fully-resolved driver for the subgraph (might not exist in this subgraph)
/// Fully-resolved driver for the subgraph (might not exist in this subgraph).
SCH_ITEM* m_driver;
/// Contents of the subgraph
/// Contents of the subgraph.
std::set<SCH_ITEM*> m_items;
/// No-connect item in graph, if any
/// No-connect item in graph, if any.
SCH_ITEM* m_no_connect;
/// On which logical sheet is the subgraph contained
/// On which logical sheet is the subgraph contained.
SCH_SHEET_PATH m_sheet;
/// Cache for driver connection
/// Cache for driver connection.
SCH_CONNECTION* m_driver_connection;
};
@ -313,11 +313,11 @@ namespace std
};
}
/// Associates a NET_CODE_NAME with all the subgraphs in that net
/// Associate a #NET_CODE_NAME with all the subgraphs in that net.
typedef std::unordered_map<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> NET_MAP;
/**
* Calculates the connectivity of a schematic and generates netlists
* Calculate the connectivity of a schematic and generates netlists.
*/
class CONNECTION_GRAPH
{
@ -349,7 +349,7 @@ public:
}
/**
* Updates the connection graph for the given list of sheets.
* Update the connection graph for the given list of sheets.
*
* @param aSheetList is the list of possibly modified sheets
* @param aUnconditional is true if an unconditional full recalculation should be done
@ -359,7 +359,7 @@ public:
std::function<void( SCH_ITEM* )>* aChangedItemHandler = nullptr );
/**
* Returns a bus alias pointer for the given name if it exists (from cache)
* Return a bus alias pointer for the given name if it exists (from cache)
*
* CONNECTION_GRAPH caches these, they are owned by the SCH_SCREEN that
* the alias was defined on. The cache is only used to update the graph.
@ -367,7 +367,7 @@ public:
std::shared_ptr<BUS_ALIAS> GetBusAlias( const wxString& aName );
/**
* Determines which subgraphs have more than one conflicting bus label.
* Determine which subgraphs have more than one conflicting bus label.
*
* @see DIALOG_MIGRATE_BUSES
* @return a list of subgraphs that need migration
@ -376,7 +376,7 @@ public:
std::vector<const CONNECTION_SUBGRAPH*> GetBusesNeedingMigration();
/**
* Runs electrical rule checks on the connectivity graph.
* Run electrical rule checks on the connectivity graph.
*
* Precondition: graph is up-to-date
*
@ -387,19 +387,22 @@ public:
const NET_MAP& GetNetMap() const { return m_net_code_to_subgraphs_map; }
/**
* Returns the subgraph for a given net name on a given sheet
* @param aNetName is the local net name to look for
* @param aPath is a sheet path to look on
* @return the subgraph matching the query, or nullptr if none is found
* Return the subgraph for a given net name on a given sheet.
*
* @param aNetName is the local net name to look for.
* @param aPath is a sheet path to look on.
* @return the subgraph matching the query, or nullptr if none is found.
*/
CONNECTION_SUBGRAPH* FindSubgraphByName( const wxString& aNetName,
const SCH_SHEET_PATH& aPath );
/**
* Retrieves a subgraph for the given net name, if one exists.
* Searches every sheet
* @param aNetName is the full net name to search for
* @return the subgraph matching the query, or nullptr if none is found
* Retrieve a subgraph for the given net name, if one exists.
*
* Search every sheet.
*
* @param aNetName is the full net name to search for.
* @return the subgraph matching the query, or nullptr if none is found.
*/
CONNECTION_SUBGRAPH* FindFirstSubgraphByName( const wxString& aNetName );
@ -408,9 +411,10 @@ public:
const std::vector<CONNECTION_SUBGRAPH*> GetAllSubgraphs( const wxString& aNetName ) const;
/**
* Returns the fully-resolved netname for a given subgraph
* @param aSubGraph Reference to the subgraph
* @return Netname string usable with m_net_name_to_subgraphs_map
* Return the fully-resolved netname for a given subgraph.
*
* @param aSubGraph Reference to the subgraph.
* @return Netname string usable with m_net_name_to_subgraphs_map.
*/
wxString GetResolvedSubgraphName( const CONNECTION_SUBGRAPH* aSubGraph ) const;
@ -418,23 +422,24 @@ public:
* For a set of items, this will remove the connected items and their
* associated data including subgraphs and generated codes from the connection graph.
*
* @param aItems A vector of items whose presence should be removed from the graph
* @return The full set of all items associated with the input items that were removed
* @param aItems A vector of items whose presence should be removed from the graph.
* @return The full set of all items associated with the input items that were removed.
*/
std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> ExtractAffectedItems(
const std::set<SCH_ITEM*> &aItems );
/**
* Combines the input graph contents into the current graph. After merging, the
* original graph is invalid.
* Combine the input graph contents into the current graph.
*
* @param aGraph Input graph reference to add to the current graph
* @warning After merging, the original graph is invalid.
*
* @param aGraph Input graph reference to add to the current graph.
*/
void Merge( CONNECTION_GRAPH& aGraph );
private:
/**
* Updates the graphical connectivity between items (i.e. where they touch)
* Update the graphical connectivity between items (i.e. where they touch)
* The items passed in must be on the same sheet.
*
* In the first phase, all items in aItemList have their connections
@ -455,16 +460,16 @@ private:
* checks to ensure that the items should actually connect, the items are
* linked together using ConnectedItems().
*
* As a side effect, items are loaded into m_items for BuildConnectionGraph()
* As a side effect, items are loaded into m_items for BuildConnectionGraph().
*
* @param aSheet is the path to the sheet of all items in the list
* @param aItemList is a list of items to consider
* @param aSheet is the path to the sheet of all items in the list.
* @param aItemList is a list of items to consider.
*/
void updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
const std::vector<SCH_ITEM*>& aItemList );
/**
* Generates the connection graph (after all item connectivity has been updated)
* Generate the connection graph (after all item connectivity has been updated).
*
* In the first phase, the algorithm iterates over all items, and then over
* all items that are connected (graphically) to each item, placing them into
@ -479,39 +484,37 @@ private:
void buildConnectionGraph( std::function<void( SCH_ITEM* )>* aChangedItemHandler );
/**
* Generates individual item subgraphs on a per-sheet basis
* Generate individual item subgraphs on a per-sheet basis.
*/
void buildItemSubGraphs();
/**
* Finds all subgraphs in the connection graph and calls ResolveDrivers() in
* parallel
* Find all subgraphs in the connection graph and calls ResolveDrivers() in parallel.
*/
void resolveAllDrivers();
/**
* Maps the driver values for each subgraph
* Map the driver values for each subgraph.
*/
void collectAllDriverValues();
/**
* Iterate through the global power pins to collect the global labels
* as drivers
* Iterate through the global power pins to collect the global labels as drivers.
*/
void generateGlobalPowerPinSubGraphs();
/**
* Iterate through labels to create placeholders for bus elements
* Iterate through labels to create placeholders for bus elements.
*/
void generateBusAliasMembers();
/**
* Process all subgraphs to assign netcodes and merge subgraphs based on labels
* Process all subgraphs to assign netcodes and merge subgraphs based on labels.
*/
void processSubGraphs();
/**
* Helper to assign a new net code to a connection
* Helper to assign a new net code to a connection.
*
* @return the assigned code
*/
@ -525,50 +528,51 @@ private:
int getOrCreateNetCode( const wxString& aNetName );
/**
* Ensures all members of the bus connection have a valid net code assigned
* @param aConnection is a bus connection
* Ensure all members of the bus connection have a valid net code assigned.
*
* @param aConnection is a bus connection.
*/
void assignNetCodesToBus( SCH_CONNECTION* aConnection );
/**
* Updates all neighbors of a subgraph with this one's connectivity info
* Update all neighbors of a subgraph with this one's connectivity info.
*
* If this subgraph contains hierarchical links, this method will descent the
* hierarchy and propagate the connectivity across all linked sheets.
*
* @param aSubgraph is the subgraph being processed
* @param aForce prevents this routine from skipping subgraphs
* @param aSubgraph is the subgraph being processed.
* @param aForce prevents this routine from skipping subgraphs.
*/
void propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, bool aForce );
/**
* Removes references to the given subgraphs from all structures in the
* connection graph.
* Remove references to the given subgraphs from all structures in the connection graph.
*
* @param aSubgraphs set of unique subgraphs to find/remove
* @param aSubgraphs set of unique subgraphs to find/remove.
*/
void removeSubgraphs( std::set<CONNECTION_SUBGRAPH*>& aSubgraphs );
/**
* Search for a matching bus member inside a bus connection
* Search for a matching bus member inside a bus connection.
*
* For bus groups, this returns a bus member that matches aSearch by name.
* For bus vectors, this returns a bus member that matches by vector index.
*
* @param aBusConnection is the bus connection to search
* @param aSearch is the net connection to search for
* @returns a member of aBusConnection that matches aSearch
* @param aBusConnection is the bus connection to search.
* @param aSearch is the net connection to search for.
* @returns a member of aBusConnection that matches aSearch.
*/
static SCH_CONNECTION* matchBusMember( SCH_CONNECTION* aBusConnection,
SCH_CONNECTION* aSearch );
/**
* Builds a new default connection for the given item based on its properties.
* Handles strong drivers (power pins and labels) only
* Build a new default connection for the given item based on its properties.
*
* @param aItem is an item that can generate a connection name
* @param aSubgraph is used to determine the sheet to use and retrieve the cached name
* @return a connection generated from the item, or nullptr if item is not valid
* Handles strong drivers (power pins and labels) only.
*
* @param aItem is an item that can generate a connection name.
* @param aSubgraph is used to determine the sheet to use and retrieve the cached name.
* @return a connection generated from the item, or nullptr if item is not valid.
*/
std::shared_ptr<SCH_CONNECTION> getDefaultConnection( SCH_ITEM* aItem,
CONNECTION_SUBGRAPH* aSubgraph );
@ -578,7 +582,8 @@ private:
/**
* If the subgraph has multiple drivers of equal priority that are graphically connected,
* ResolveDrivers() will have stored the second driver for use by this function, which actually
* creates the markers
* creates the markers.
*
* @param aSubgraph is the subgraph to examine
* @return true for no errors, false for errors
*/
@ -587,84 +592,85 @@ private:
bool ercCheckNetclassConflicts( const std::vector<CONNECTION_SUBGRAPH*>& subgraphs );
/**
* Checks one subgraph for conflicting connections between net and bus labels
* Check one subgraph for conflicting connections between net and bus labels.
*
* For example, a net wire connected to a bus port/pin, or vice versa
*
* @param aSubgraph is the subgraph to examine
* @return true for no errors, false for errors
* @param aSubgraph is the subgraph to examine.
* @return true for no errors, false for errors.
*/
bool ercCheckBusToNetConflicts( const CONNECTION_SUBGRAPH* aSubgraph );
/**
* Checks one subgraph for conflicting connections between two bus items
* Check one subgraph for conflicting connections between two bus items.
*
* For example, a labeled bus wire connected to a hierarchical sheet pin
* where the labeled bus doesn't contain any of the same bus members as the
* sheet pin
* sheet pin.
*
* @param aSubgraph is the subgraph to examine
* @return true for no errors, false for errors
* @param aSubgraph is the subgraph to examine.
* @return true for no errors, false for errors.
*/
bool ercCheckBusToBusConflicts( const CONNECTION_SUBGRAPH* aSubgraph );
/**
* Checks one subgraph for conflicting bus entry to bus connections
* Check one subgraph for conflicting bus entry to bus connections.
*
* For example, a wire with label "A0" is connected to a bus labeled "D[8..0]"
*
* Will also check for mistakes related to bus group names, for example:
* A bus group named "USB{DP DM}" should have bus entry connections like
* "USB.DP" but someone might accidentally just enter "DP"
* "USB.DP" but someone might accidentally just enter "DP".
*
* @param aSubgraph is the subgraph to examine
* @return true for no errors, false for errors
* @param aSubgraph is the subgraph to examine.
* @return true for no errors, false for errors.
*/
bool ercCheckBusToBusEntryConflicts( const CONNECTION_SUBGRAPH* aSubgraph );
/**
* Checks one subgraph for proper presence or absence of no-connect symbols
* Check one subgraph for proper presence or absence of no-connect symbols.
*
* A pin with a no-connect symbol should not have any connections
* A pin without a no-connect symbol should have at least one connection
* A pin with a no-connect symbol should not have any connections.
* A pin without a no-connect symbol should have at least one connection.
*
* @param aSubgraph is the subgraph to examine
* @return true for no errors, false for errors
* @param aSubgraph is the subgraph to examine.
* @return true for no errors, false for errors.
*/
bool ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph );
/**
* Checks one subgraph for floating wires
* Check one subgraph for floating wires.
*
* Will throw an error for any subgraph that consists of just wires with no driver
* Will throw an error for any subgraph that consists of just wires with no driver.
*
* @param aSubgraph is the subgraph to examine
* @return true for no errors, false for errors
* @param aSubgraph is the subgraph to examine.
* @return true for no errors, false for errors.
*/
bool ercCheckFloatingWires( const CONNECTION_SUBGRAPH* aSubgraph );
/**
* Checks one subgraph for proper connection of labels
* Check one subgraph for proper connection of labels.
*
* Labels should be connected to something
* Labels should be connected to something.
*
* @param aSubgraph is the subgraph to examine
* @param aCheckGlobalLabels is true if global labels should be checked for loneliness
* @return true for no errors, false for errors
* @param aSubgraph is the subgraph to examine.
* @param aCheckGlobalLabels is true if global labels should be checked for loneliness.
* @return true for no errors, false for errors.
*/
bool ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph );
/**
* Checks that a hierarchical sheet has at least one matching label inside the sheet for each
* port on the parent sheet object
* Check that a hierarchical sheet has at least one matching label inside the sheet for each
* port on the parent sheet object.
*
* @param aSubgraph is the subgraph to examine
* @return the number of errors found
* @param aSubgraph is the subgraph to examine.
* @return the number of errors found.
*/
int ercCheckHierSheets();
/**
* Get the number of pins in a given subgraph
* Get the number of pins in a given subgraph.
*
* @param aLocSubgraph Subgraph to search
* @return total number of pins in the subgraph
*/
@ -672,19 +678,19 @@ private:
private:
// All the sheets in the schematic (as long as we don't have partial updates)
/// All the sheets in the schematic (as long as we don't have partial updates).
SCH_SHEET_LIST m_sheetList;
// All connectable items in the schematic
/// All connectable items in the schematic.
std::vector<SCH_ITEM*> m_items;
// The owner of all CONNECTION_SUBGRAPH objects
/// The owner of all #CONNECTION_SUBGRAPH objects.
std::vector<CONNECTION_SUBGRAPH*> m_subgraphs;
// Cache of a subset of m_subgraphs
/// Cache of a subset of #m_subgraphs.
std::vector<CONNECTION_SUBGRAPH*> m_driver_subgraphs;
// Cache to lookup subgraphs in m_driver_subgraphs by sheet path
/// Cache to lookup subgraphs in #m_driver_subgraphs by sheet path.
std::unordered_map<SCH_SHEET_PATH, std::vector<CONNECTION_SUBGRAPH*>> m_sheet_to_subgraphs_map;
std::vector<std::pair<SCH_SHEET_PATH, SCH_PIN*>> m_global_power_pins;
@ -712,7 +718,7 @@ private:
int m_last_subgraph_code;
SCHEMATIC* m_schematic; ///< The schematic this graph represents
SCHEMATIC* m_schematic; ///< The schematic this graph represents.
};
#endif

View File

@ -364,6 +364,7 @@ PGM_BASE& Pgm()
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from
// a python script or something else.
PGM_BASE* PgmOrNull()
@ -377,6 +378,7 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
// This is process-level-initialization, not project-level-initialization of the DSO.
// Do nothing in here pertinent to a project!
InitSettings( new EESCHEMA_SETTINGS );
// Register the symbol editor settings as well because they share a KiFACE and need to be
// loaded prior to use to avoid threading deadlocks
aProgram->GetSettingsManager().RegisterSettings( new SYMBOL_EDITOR_SETTINGS );
@ -641,6 +643,7 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje
}
}
int IFACE::HandleJob( JOB* aJob )
{
return m_jobHandler->RunJob( aJob );

View File

@ -212,6 +212,7 @@ void SCH_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
cfg->m_System.units = static_cast<int>( GetUserUnits() );
cfg->m_AuiPanels.show_schematic_hierarchy = hierarchy_pane.IsShown();
cfg->m_AuiPanels.schematic_hierarchy_float = hierarchy_pane.IsFloating();
// Other parameters (hierarchy_panel_float_width, hierarchy_panel_float_height,
// and hierarchy_panel_docked_width should have been updated when resizing the
// hierarchy panel