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
@ -281,4 +282,4 @@ void SCH_BASE_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
wxCHECK_RET( aCfg, wxS( "Call to SCH_BASE_FRAME::SaveSettings with null settings" ) );
EDA_DRAW_FRAME::SaveSettings( aCfg );
}
}

View File

@ -69,7 +69,8 @@ EESCHEMA_JOBS_HANDLER::EESCHEMA_JOBS_HANDLER()
Register( "bom",
std::bind( &EESCHEMA_JOBS_HANDLER::JobExportBom, this, std::placeholders::_1 ) );
Register( "pythonbom",
std::bind( &EESCHEMA_JOBS_HANDLER::JobExportPythonBom, this, std::placeholders::_1 ) );
std::bind( &EESCHEMA_JOBS_HANDLER::JobExportPythonBom, this,
std::placeholders::_1 ) );
Register( "netlist",
std::bind( &EESCHEMA_JOBS_HANDLER::JobExportNetlist, this, std::placeholders::_1 ) );
Register( "plot",
@ -181,13 +182,23 @@ int EESCHEMA_JOBS_HANDLER::JobExportPlot( JOB* aJob )
HPGL_PLOT_ORIGIN_AND_UNITS hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE;
switch( aPlotJob->m_HPGLPlotOrigin )
{
case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT: hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT; break;
case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER: hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER; break;
case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT: hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT; break;
case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE: hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE; break;
case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT;
break;
case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER:
hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER;
break;
case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT;
break;
case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE;
break;
}
int pageSizeSelect = PageFormatReq::PAGE_SIZE_AUTO;
switch( aPlotJob->m_pageSizeSelect )
{
case JOB_PAGE_SIZE::PAGE_SIZE_A: pageSizeSelect = PageFormatReq::PAGE_SIZE_A; break;
@ -300,7 +311,6 @@ int EESCHEMA_JOBS_HANDLER::JobExportNetlist( JOB* aJob )
return CLI::EXIT_CODES::ERR_UNKNOWN;
}
if( aNetJob->m_outputFile.IsEmpty() )
{
wxFileName fn = sch->GetFileName();
@ -312,7 +322,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportNetlist( JOB* aJob )
bool res = helper->WriteNetlist( aNetJob->m_outputFile, netlistOption, *m_reporter );
if(!res)
if( !res )
{
return CLI::EXIT_CODES::ERR_UNKNOWN;
}
@ -369,7 +379,6 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
m_reporter->Report( _( "Warning: duplicate sheet names.\n" ), RPT_SEVERITY_WARNING );
}
// Build our data model
FIELDS_EDITOR_GRID_DATA_MODEL dataModel( referenceList );
@ -436,6 +445,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
else
{
size_t i = 0;
for( wxString fieldName : aBomJob->m_fieldsOrdered )
{
struct BOM_FIELD field;
@ -473,6 +483,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
}
wxFile f;
if( !f.Open( aBomJob->m_outputFile, wxFile::write ) )
{
m_reporter->Report(
@ -645,6 +656,7 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob,
fn.SetExt( SVGFileExtension );
filename = symbol->GetName().Lower();
while( wxString::npos
!= ( forbidden_char = filename.find_first_of(
wxFileName::GetForbiddenChars( wxPATH_DOS ) ) ) )
@ -690,7 +702,7 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob,
VECTOR2I plot_offset;
const double scale = 1.0;
// Currently, plot units are in decimil
// Currently, plot units are in decimal
plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS / 10, scale, false );
plotter->SetCreator( wxT( "Eeschema-SVG" ) );
@ -901,6 +913,7 @@ int EESCHEMA_JOBS_HANDLER::JobSchErc( JOB* aJob )
}
EDA_UNITS units;
switch( ercJob->m_units )
{
case JOB_SCH_ERC::UNITS::INCHES:
@ -933,6 +946,7 @@ int EESCHEMA_JOBS_HANDLER::JobSchErc( JOB* aJob )
ERC_REPORT reportWriter( sch, units );
bool wroteReport = false;
if( ercJob->m_format == JOB_SCH_ERC::OUTPUT_FORMAT::JSON )
wroteReport = reportWriter.WriteJsonReport( ercJob->m_outputFile );
else
@ -949,7 +963,6 @@ int EESCHEMA_JOBS_HANDLER::JobSchErc( JOB* aJob )
m_reporter->Report( wxString::Format( _( "Saved ERC Report to %s\n" ), ercJob->m_outputFile ),
RPT_SEVERITY_INFO );
if( ercJob->m_exitCodeViolations )
{
if( markersProvider->GetCount() > 0 )
@ -965,8 +978,9 @@ int EESCHEMA_JOBS_HANDLER::JobSchErc( JOB* aJob )
DS_PROXY_VIEW_ITEM* EESCHEMA_JOBS_HANDLER::getDrawingSheetProxyView( SCHEMATIC* aSch )
{
DS_PROXY_VIEW_ITEM* drawingSheet =
new DS_PROXY_VIEW_ITEM( schIUScale, &aSch->RootScreen()->GetPageSettings(), &aSch->Prj(),
&aSch->RootScreen()->GetTitleBlock(), aSch->GetProperties() );
new DS_PROXY_VIEW_ITEM( schIUScale, &aSch->RootScreen()->GetPageSettings(),
&aSch->Prj(), &aSch->RootScreen()->GetTitleBlock(),
aSch->GetProperties() );
drawingSheet->SetPageNumber( TO_UTF8( aSch->RootScreen()->GetPageNumber() ) );
drawingSheet->SetSheetCount( aSch->RootScreen()->GetPageCount() );

View File

@ -35,7 +35,7 @@ class LIB_SYMBOL;
class DS_PROXY_VIEW_ITEM;
/**
* Handles eeschema job dispatches
* Handle Eeschema job dispatches.
*/
class EESCHEMA_JOBS_HANDLER : public JOB_DISPATCHER
{
@ -50,16 +50,19 @@ public:
int JobSymExportSvg( JOB* aJob );
/**
* Configures the SCH_RENDER_SETTINGS object with the correct data to be used with plotting
* Configure the SCH_RENDER_SETTINGS object with the correct data to be used with plotting.
*
* It's sort of a kludge due to the plotter depending on this object normally managed by the frame and canvas
* It's sort of a kludge due to the plotter depending on this object normally managed by
*the frame and canvas
*
* @param aRenderSettings The object to populate with working settings
* @param aTheme The theme to take color data from to stick into render settings, can be left blank for default
* @param aSch The schematic to further copy settings from to be put into aRenderSettings
* @param aRenderSettings The object to populate with working settings.
* @param aTheme The theme to take color data from to stick into render settings, can be
* left blank for default.
* @param aSch The schematic to further copy settings from to be put into aRenderSettings.
*/
void InitRenderSettings( KIGFX::SCH_RENDER_SETTINGS* aRenderSettings, const wxString& aTheme,
SCHEMATIC* aSch, const wxString& aDrawingSheetOverride = wxEmptyString );
SCHEMATIC* aSch,
const wxString& aDrawingSheetOverride = wxEmptyString );
private:

View File

@ -159,6 +159,7 @@ public:
wxString intersheets_ref_suffix;
bool auto_start_wires;
std::vector<double> junction_size_mult_list;
// Pulldown index for user default junction dot size (e.g. smallest = 0, small = 1, etc)
int junction_size_choice;
};

View File

@ -155,7 +155,8 @@ int ERC_TESTER::TestDuplicateSheetNames( bool aCreateMarker )
{
if( aCreateMarker )
{
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DUPLICATE_SHEET_NAME );
std::shared_ptr<ERC_ITEM> ercItem =
ERC_ITEM::Create( ERCE_DUPLICATE_SHEET_NAME );
ercItem->SetItems( sheet, test_item );
SCH_MARKER* marker = new SCH_MARKER( ercItem, sheet->GetPosition() );
@ -179,7 +180,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
auto unresolved = [this]( wxString str )
{
str = ExpandEnvVarSubstitutions( str, &m_schematic->Prj() );
return str.Matches( wxT( "*${*}*" ) );
return str.Matches( wxS( "*${*}*" ) );
};
if( aDrawingSheet )
@ -190,7 +191,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
wsItems.SetSheetName( wxS( "dummySheet" ) );
wsItems.SetSheetLayer( wxS( "dummyLayer" ) );
wsItems.SetProject( &m_schematic->Prj() );
wsItems.BuildDrawItemsList( aDrawingSheet->GetPageInfo(), aDrawingSheet->GetTitleBlock());
wsItems.BuildDrawItemsList( aDrawingSheet->GetPageInfo(), aDrawingSheet->GetTitleBlock() );
}
SCH_SHEET_PATH savedCurrentSheet = m_schematic->CurrentSheet();
@ -239,7 +240,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
{
if( pin->GetShownText( true ).Matches( wxT( "*${*}*" ) ) )
if( pin->GetShownText( true ).Matches( wxS( "*${*}*" ) ) )
{
std::shared_ptr<ERC_ITEM> ercItem =
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
@ -252,7 +253,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
}
else if( SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( item ) )
{
if( text->GetShownText( true ).Matches( wxT( "*${*}*" ) ) )
if( text->GetShownText( true ).Matches( wxS( "*${*}*" ) ) )
{
std::shared_ptr<ERC_ITEM> ercItem =
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
@ -264,7 +265,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
}
else if( SCH_TEXTBOX* textBox = dynamic_cast<SCH_TEXTBOX*>( item ) )
{
if( textBox->GetShownText( true ).Matches( wxT( "*${*}*" ) ) )
if( textBox->GetShownText( true ).Matches( wxS( "*${*}*" ) ) )
{
std::shared_ptr<ERC_ITEM> ercItem =
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
@ -280,7 +281,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
{
if( DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item ) )
{
if( text->GetShownText( true ).Matches( wxT( "*${*}*" ) ) )
if( text->GetShownText( true ).Matches( wxS( "*${*}*" ) ) )
{
std::shared_ptr<ERC_ITEM> erc = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
erc->SetErrorMessage( _( "Unresolved text variable in drawing sheet" ) );
@ -435,17 +436,18 @@ int ERC_TESTER::TestMissingUnits()
std::set<int> instance_units;
std::set<int> missing_units;
auto report_missing = [&]( std::set<int>& aMissingUnits, wxString aErrorMsg, int aErrorCode )
auto report_missing = [&]( std::set<int>& aMissingUnits, wxString aErrorMsg,
int aErrorCode )
{
wxString msg;
wxString missing_pin_units = wxT( "[ " );
wxString missing_pin_units = wxS( "[ " );
int ii = 0;
for( int missing_unit : aMissingUnits )
{
if( ii++ == 3 )
{
missing_pin_units += wxT( "....." );
missing_pin_units += wxS( "....." );
break;
}
@ -453,7 +455,7 @@ int ERC_TESTER::TestMissingUnits()
}
missing_pin_units.Truncate( missing_pin_units.length() - 2 );
missing_pin_units += wxT( " ]" );
missing_pin_units += wxS( " ]" );
msg.Printf( aErrorMsg, symbol.first, missing_pin_units );
@ -480,7 +482,7 @@ int ERC_TESTER::TestMissingUnits()
if( !missing_units.empty() && settings.IsTestEnabled( ERCE_MISSING_UNIT ) )
{
report_missing( missing_units, _( "Symbol %s has unplaced units %s" ),
ERCE_MISSING_UNIT );
ERCE_MISSING_UNIT );
}
std::set<int> missing_power;
@ -527,20 +529,24 @@ int ERC_TESTER::TestMissingUnits()
if( !missing_power.empty() && settings.IsTestEnabled( ERCE_MISSING_POWER_INPUT_PIN ) )
{
report_missing( missing_power, _( "Symbol %s has input power pins in units %s that are not placed." ),
ERCE_MISSING_POWER_INPUT_PIN );
report_missing( missing_power,
_( "Symbol %s has input power pins in units %s that are not placed." ),
ERCE_MISSING_POWER_INPUT_PIN );
}
if( !missing_input.empty() && settings.IsTestEnabled( ERCE_MISSING_INPUT_PIN ) )
{
report_missing( missing_input, _( "Symbol %s has input pins in units %s that are not placed." ),
ERCE_MISSING_INPUT_PIN );
report_missing( missing_input,
_( "Symbol %s has input pins in units %s that are not placed." ),
ERCE_MISSING_INPUT_PIN );
}
if( !missing_bidi.empty() && settings.IsTestEnabled( ERCE_MISSING_BIDI_PIN ) )
{
report_missing( missing_bidi, _( "Symbol %s has bidirectional pins in units %s that are not placed." ),
ERCE_MISSING_BIDI_PIN );
report_missing( missing_bidi,
_( "Symbol %s has bidirectional pins in units %s that are not "
"placed." ),
ERCE_MISSING_BIDI_PIN );
}
}
@ -1023,7 +1029,8 @@ int ERC_TESTER::TestOffGridEndpoints( int aGridSize )
if( ( pinPos.x % clamped_grid_size ) != 0
|| ( pinPos.y % clamped_grid_size) != 0 )
{
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
std::shared_ptr<ERC_ITEM> ercItem =
ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
ercItem->SetItems( pin );
markers.emplace_back( new SCH_MARKER( ercItem, pinPos ) );
@ -1106,6 +1113,7 @@ void ERC_TESTER::RunTests( DS_PROXY_VIEW_ITEM* aDrawingSheet, SCH_EDIT_FRAME* aE
{
if( aProgressReporter )
aProgressReporter->AdvancePhase( _( "Checking sheet names..." ) );
TestDuplicateSheetNames( true );
}
@ -1113,6 +1121,7 @@ void ERC_TESTER::RunTests( DS_PROXY_VIEW_ITEM* aDrawingSheet, SCH_EDIT_FRAME* aE
{
if( aProgressReporter )
aProgressReporter->AdvancePhase( _( "Checking bus conflicts..." ) );
TestConflictingBusAliases();
}
@ -1139,6 +1148,7 @@ void ERC_TESTER::RunTests( DS_PROXY_VIEW_ITEM* aDrawingSheet, SCH_EDIT_FRAME* aE
{
if( aProgressReporter )
aProgressReporter->AdvancePhase( _( "Checking footprints..." ) );
TestMultiunitFootprints();
}
@ -1170,6 +1180,7 @@ void ERC_TESTER::RunTests( DS_PROXY_VIEW_ITEM* aDrawingSheet, SCH_EDIT_FRAME* aE
{
if( aProgressReporter )
aProgressReporter->AdvancePhase( _( "Checking labels..." ) );
TestSimilarLabels();
}
@ -1177,6 +1188,7 @@ void ERC_TESTER::RunTests( DS_PROXY_VIEW_ITEM* aDrawingSheet, SCH_EDIT_FRAME* aE
{
if( aProgressReporter )
aProgressReporter->AdvancePhase( _( "Checking for unresolved variables..." ) );
TestTextVars( aDrawingSheet );
}
@ -1184,6 +1196,7 @@ void ERC_TESTER::RunTests( DS_PROXY_VIEW_ITEM* aDrawingSheet, SCH_EDIT_FRAME* aE
{
if( aProgressReporter )
aProgressReporter->AdvancePhase( _( "Checking SPICE models..." ) );
TestSimModelIssues();
}
@ -1191,6 +1204,7 @@ void ERC_TESTER::RunTests( DS_PROXY_VIEW_ITEM* aDrawingSheet, SCH_EDIT_FRAME* aE
{
if( aProgressReporter )
aProgressReporter->AdvancePhase( _( "Checking no connect pins for connections..." ) );
TestNoConnectPins();
}
@ -1198,6 +1212,7 @@ void ERC_TESTER::RunTests( DS_PROXY_VIEW_ITEM* aDrawingSheet, SCH_EDIT_FRAME* aE
{
if( aProgressReporter )
aProgressReporter->AdvancePhase( _( "Checking for library symbol issues..." ) );
TestLibSymbolIssues();
}
@ -1205,9 +1220,10 @@ void ERC_TESTER::RunTests( DS_PROXY_VIEW_ITEM* aDrawingSheet, SCH_EDIT_FRAME* aE
{
if( aProgressReporter )
aProgressReporter->AdvancePhase( _( "Checking for off grid pins and wires..." ) );
if( aEditFrame )
TestOffGridEndpoints( aEditFrame->GetCanvas()->GetView()->GetGAL()->GetGridSize().x );
}
m_schematic->ResolveERCExclusionsPostUpdate();
}
}

View File

@ -29,41 +29,31 @@
#include <erc_sch_pin_context.h>
/**
* Gets the SCH_PIN for this context
*/
SCH_PIN* ERC_SCH_PIN_CONTEXT::Pin()
{
return m_pin;
}
/**
* Gets the SCH_SHEET_PATH context for the paired SCH_PIN
*/
SCH_SHEET_PATH& ERC_SCH_PIN_CONTEXT::Sheet()
{
return m_sheet;
}
/**
* Tests two pin contexts for equality based on the deterministic hash
*/
bool ERC_SCH_PIN_CONTEXT::operator==( const ERC_SCH_PIN_CONTEXT& other ) const
{
return m_hash == other.m_hash;
}
/**
* Provides a deterministic ordering for item contexts based on hash value
*/
bool ERC_SCH_PIN_CONTEXT::operator<( const ERC_SCH_PIN_CONTEXT& other ) const
{
return m_hash < other.m_hash;
}
/**
* Calculates the deterministic hash for this pin / sheet context
*/
void ERC_SCH_PIN_CONTEXT::rehash()
{
m_hash = 0;

View File

@ -34,16 +34,11 @@
#include <boost/functional/hash.hpp>
/**
* A class used to associate a SCH_PIN with its owning SCH_SHEET_PATH, in order to handle ERC checks
* across connected common hierarchical schematics
* A class used to associate a #SCH_PIN with its owning #SCH_SHEET_PATH, in order to handle ERC
* checks across connected common hierarchical schematics/
*/
class ERC_SCH_PIN_CONTEXT
{
protected:
SCH_PIN* m_pin;
SCH_SHEET_PATH m_sheet;
size_t m_hash;
public:
ERC_SCH_PIN_CONTEXT() : m_pin( nullptr ), m_sheet(), m_hash( 0 ) {}
@ -59,24 +54,34 @@ public:
~ERC_SCH_PIN_CONTEXT() = default;
/**
* Gets the SCH_PIN for this context
* Get the SCH_PIN for this context.
*/
SCH_PIN* Pin();
/**
* Gets the SCH_SHEET_PATH context for the paired SCH_PIN
* Get the #SCH_SHEET_PATH context for the paired #SCH_PIN.
*/
SCH_SHEET_PATH& Sheet();
/**
* Test two pin contexts for equality based on the deterministic hash.
*/
bool operator==( const ERC_SCH_PIN_CONTEXT& other ) const;
/**
* Provide a deterministic ordering for item contexts based on hash value.
*/
bool operator<( const ERC_SCH_PIN_CONTEXT& other ) const;
protected:
/**
* Calculates the deterministic hash for this context
* Calculate the deterministic hash for this context.
*/
void rehash();
SCH_PIN* m_pin;
SCH_SHEET_PATH m_sheet;
size_t m_hash;
};
#endif //_ERC_ITEM_CONTEXT_H

View File

@ -1,3 +1,22 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2023 <author>
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <wx/string.h>
#include <wx/debug.h>
#include <wx/grid.h>
@ -9,9 +28,11 @@
#include "fields_data_model.h"
const wxString FIELDS_EDITOR_GRID_DATA_MODEL::QUANTITY_VARIABLE = wxS( "${QUANTITY}" );
const wxString FIELDS_EDITOR_GRID_DATA_MODEL::ITEM_NUMBER_VARIABLE = wxS( "${ITEM_NUMBER}" );
void FIELDS_EDITOR_GRID_DATA_MODEL::AddColumn( const wxString& aFieldName, const wxString& aLabel,
bool aAddedByUser )
{
@ -34,6 +55,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::updateDataStoreSymbolField( const SCH_SYMBOL
m_dataStore[aSymbol.m_Uuid][aFieldName] = field->GetText();
else if( isAttribute( aFieldName ) )
m_dataStore[aSymbol.m_Uuid][aFieldName] = getAttributeValue( aSymbol, aFieldName );
// Handle fields with variables as names that are not present in the symbol
// by giving them the correct value
else if( IsTextVar( aFieldName ) )
@ -234,24 +256,28 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::ColIsReference( int aCol )
return m_cols[aCol].m_fieldName == GetCanonicalFieldName( REFERENCE_FIELD );
}
bool FIELDS_EDITOR_GRID_DATA_MODEL::ColIsValue( int aCol )
{
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false );
return m_cols[aCol].m_fieldName == GetCanonicalFieldName( VALUE_FIELD );
}
bool FIELDS_EDITOR_GRID_DATA_MODEL::ColIsQuantity( int aCol )
{
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false );
return m_cols[aCol].m_fieldName == QUANTITY_VARIABLE;
}
bool FIELDS_EDITOR_GRID_DATA_MODEL::ColIsItemNumber( int aCol )
{
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false );
return m_cols[aCol].m_fieldName == ITEM_NUMBER_VARIABLE;
}
bool FIELDS_EDITOR_GRID_DATA_MODEL::ColIsAttribute( int aCol )
{
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false );
@ -343,6 +369,7 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::unitMatch( const SCH_REFERENCE& lhRef,
return ( lhRef.GetRef() == rhRef.GetRef() && lhRef.GetRefNumber() == rhRef.GetRefNumber() );
}
bool FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch( const SCH_REFERENCE& lhRef,
const SCH_REFERENCE& rhRef )
@ -552,6 +579,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::RebuildRows()
Sort();
}
void FIELDS_EDITOR_GRID_DATA_MODEL::ExpandRow( int aRow )
{
std::vector<DATA_MODEL_ROW> children;
@ -593,6 +621,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::ExpandRow( int aRow )
GetView()->ProcessTableMessage( msg );
}
void FIELDS_EDITOR_GRID_DATA_MODEL::CollapseRow( int aRow )
{
auto firstChild = m_rows.begin() + aRow + 1;
@ -721,6 +750,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(
m_edited = false;
}
int FIELDS_EDITOR_GRID_DATA_MODEL::GetDataWidth( int aCol )
{
int width = 0;
@ -943,7 +973,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::UpdateReferences( const SCH_REFERENCE_LIST&
for( const SCH_REFERENCE& ref : aRefs )
{
// Update the fields of every reference. Do this by iterating through the data model
// colums; we must have all fields in the symbol added to the data model at this point,
// columns; we must have all fields in the symbol added to the data model at this point,
// and some of the data model columns may be variables that are not present in the symbol
for( const DATA_MODEL_COL& col : m_cols )
updateDataStoreSymbolField( *ref.GetSymbol(), col.m_fieldName );

View File

@ -1,12 +1,33 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2023 <author>
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sch_reference_list.h>
#include <wx/grid.h>
// The field name in the data model (translated)
#define DISPLAY_NAME_COLUMN 0
// The field name's label for exporting (CSV, etc.)
#define LABEL_COLUMN 1
#define SHOW_FIELD_COLUMN 2
#define GROUP_BY_COLUMN 3
// The internal field name (untranslated)
#define FIELD_NAME_COLUMN 4
@ -73,6 +94,7 @@ public:
void AddColumn( const wxString& aFieldName, const wxString& aLabel, bool aAddedByUser );
void RemoveColumn( int aCol );
void RenameColumn( int aCol, const wxString& newName );
void MoveColumn( int aCol, int aNewPos )
{
wxCHECK_RET( aCol >= 0 && aCol < (int) m_cols.size(), "Invalid Column Number" );
@ -104,7 +126,7 @@ public:
int GetFieldNameCol( wxString aFieldName );
const std::vector<BOM_FIELD> GetFieldsOrdered();
void SetFieldsOrder( const std::vector<wxString>& aNewOrder );
void SetFieldsOrder( const std::vector<wxString>& aNewOrder );
bool IsEmptyCell( int aRow, int aCol ) override
{
@ -116,11 +138,13 @@ public:
const wxString& refDelimiter = wxT( ", " ),
const wxString& refRangDelimiter = wxT( "-" ),
bool resolveVars = false );
wxString GetExportValue( int aRow, int aCol, const wxString& refDelimiter,
const wxString& refRangeDelimiter )
{
return GetValue( m_rows[aRow], aCol, refDelimiter, refRangeDelimiter, true );
}
void SetValue( int aRow, int aCol, const wxString& aValue ) override;
GROUP_TYPE GetRowFlags( int aRow ) { return m_rows[aRow].m_Flag; }
@ -143,6 +167,7 @@ public:
m_sortColumn = aCol;
m_sortAscending = ascending;
}
int GetSortCol() { return m_sortColumn; }
bool GetSortAsc() { return m_sortAscending; }
@ -191,6 +216,7 @@ public:
wxCHECK_RET( aCol >= 0 && aCol < (int) m_cols.size(), "Invalid Column Number" );
m_cols[aCol].m_group = group;
}
bool GetGroupColumn( int aCol )
{
wxCHECK_MSG( aCol >= 0 && aCol < (int) m_cols.size(), false, "Invalid Column Number" );
@ -202,6 +228,7 @@ public:
wxCHECK_RET( aCol >= 0 && aCol < (int) m_cols.size(), "Invalid Column Number" );
m_cols[aCol].m_show = show;
}
bool GetShowColumn( int aCol )
{
wxCHECK_MSG( aCol >= 0 && aCol < (int) m_cols.size(), false, "Invalid Column Number" );
@ -243,7 +270,6 @@ private:
void storeReferenceFields( SCH_REFERENCE& aRef );
void updateDataStoreSymbolField( const SCH_SYMBOL& aSymbol, const wxString& aFieldName );
protected:
SCH_REFERENCE_LIST m_symbolsList;
bool m_edited;

View File

@ -795,7 +795,8 @@ void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue
if( value == DEFAULT_FONT_NAME )
field.SetFont( nullptr );
else if( value == KICAD_FONT_NAME )
field.SetFont( KIFONT::FONT::GetFont( wxEmptyString, field.IsBold(), field.IsItalic() ) );
field.SetFont( KIFONT::FONT::GetFont( wxEmptyString, field.IsBold(),
field.IsItalic() ) );
else
field.SetFont( KIFONT::FONT::GetFont( aValue, field.IsBold(), field.IsItalic() ) );
@ -871,7 +872,8 @@ void FIELDS_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
_( "Browse for footprint" ) );
menu.AppendSeparator();
}
else if( m_grid->GetGridCursorRow() == DATASHEET_FIELD && m_grid->GetGridCursorCol() == FDC_VALUE )
else if( m_grid->GetGridCursorRow() == DATASHEET_FIELD
&& m_grid->GetGridCursorCol() == FDC_VALUE )
{
menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ),
_( "Show datasheet in browser" ) );

View File

@ -99,7 +99,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
wxFileName wx_filename( fullFileName );
// We insist on caller sending us an absolute path, if it does not, we say it's a bug.
wxASSERT_MSG( wx_filename.IsAbsolute(), wxT( "Path is not absolute!" ) );
wxASSERT_MSG( wx_filename.IsAbsolute(), wxS( "Path is not absolute!" ) );
if( !LockFile( fullFileName ) )
{
@ -571,7 +571,7 @@ bool SCH_EDIT_FRAME::AppendSchematic()
if( !screen )
{
wxLogError( wxT( "Document not ready, cannot import" ) );
wxLogError( wxS( "Document not ready, cannot import" ) );
return false;
}
@ -663,10 +663,10 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent )
fileFiltersStr += desc.FileFilter();
for( const std::string& ext : desc.m_FileExtensions )
allWildcardsStr << wxT( "*." ) << formatWildcardExt( ext ) << wxT( ";" );
allWildcardsStr << wxS( "*." ) << formatWildcardExt( ext ) << wxS( ";" );
}
fileFiltersStr = _( "All supported formats" ) + wxT( "|" ) + allWildcardsStr + wxT( "|" )
fileFiltersStr = _( "All supported formats" ) + wxS( "|" ) + allWildcardsStr + wxS( "|" )
+ fileFiltersStr;
wxFileDialog dlg( this, _( "Import Schematic" ), path, wxEmptyString, fileFiltersStr,
@ -803,6 +803,7 @@ bool SCH_EDIT_FRAME::saveSchematicFile( SCH_SHEET* aSheet, const wxString& aSave
{
// Preserve the permissions of the current file
KIPLATFORM::IO::DuplicatePermissions( schematicFileName.GetFullPath(), tempFile );
// Replace the original with the temporary file we just wrote
success = wxRenameFile( tempFile, schematicFileName.GetFullPath() );
@ -829,8 +830,8 @@ bool SCH_EDIT_FRAME::saveSchematicFile( SCH_SHEET* aSheet, const wxString& aSave
if( autoSaveFileName.FileExists() )
{
wxLogTrace( traceAutoSave,
wxT( "Removing auto save file <" ) + autoSaveFileName.GetFullPath() +
wxT( ">" ) );
wxS( "Removing auto save file <" ) + autoSaveFileName.GetFullPath() +
wxS( ">" ) );
wxRemoveFile( autoSaveFileName.GetFullPath() );
}
@ -971,7 +972,7 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
}
wxLogTrace( tracePathsAndFiles,
wxT( "Moving schematic from '%s' to '%s'." ),
wxS( "Moving schematic from '%s' to '%s'." ),
screen->GetFileName(),
tmp.GetFullPath() );
@ -1273,7 +1274,7 @@ void SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
{
// We insist on caller sending us an absolute path, if it does not, we say it's a bug.
wxCHECK_MSG( filename.IsAbsolute(), /*void*/,
wxT( "Import schematic: path is not absolute!" ) );
wxS( "Import schematic: path is not absolute!" ) );
try
{
@ -1470,10 +1471,10 @@ void SCH_EDIT_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
if( !Pgm().IsGUI() )
return;
wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
wxCHECK_RET( aFileName.IsOk(), wxS( "Invalid file name!" ) );
wxLogTrace( traceAutoSave,
wxT( "Checking for auto save file " ) + aFileName.GetFullPath() );
wxS( "Checking for auto save file " ) + aFileName.GetFullPath() );
if( !aFileName.FileExists() )
return;
@ -1509,14 +1510,14 @@ void SCH_EDIT_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
wxString tmp = recoveredFn.GetName();
// Strip "_autosave-" prefix from the auto save file name.
tmp.Replace( GetAutoSaveFilePrefix(), wxT( "" ), false );
tmp.Replace( GetAutoSaveFilePrefix(), wxS( "" ), false );
recoveredFn.SetName( tmp );
wxFileName backupFn = recoveredFn;
backupFn.SetExt( backupFn.GetExt() + BackupFileSuffix );
wxLogTrace( traceAutoSave, wxT( "Recovering auto save file:\n"
wxLogTrace( traceAutoSave, wxS( "Recovering auto save file:\n"
" Original file: '%s'\n"
" Backup file: '%s'\n"
" Auto save file: '%s'" ),
@ -1544,7 +1545,7 @@ void SCH_EDIT_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
msg = _( "The following automatically saved file(s) could not be restored\n" );
for( size_t i = 0; i < unrecoveredFiles.GetCount(); i++ )
msg += unrecoveredFiles[i] + wxT( "\n" );
msg += unrecoveredFiles[i] + wxS( "\n" );
msg += _( "Manual recovery will be required to restore the file(s) above." );
wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION,
@ -1558,7 +1559,7 @@ void SCH_EDIT_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
for( wxString fn = autoSaveFile.GetFirstLine(); !autoSaveFile.Eof();
fn = autoSaveFile.GetNextLine() )
{
wxLogTrace( traceAutoSave, wxT( "Removing auto save file " ) + fn );
wxLogTrace( traceAutoSave, wxS( "Removing auto save file " ) + fn );
if( wxFileExists( fn ) && !wxRemoveFile( fn ) )
unremovedFiles.Add( fn );
@ -1569,7 +1570,7 @@ void SCH_EDIT_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
msg = _( "The following automatically saved file(s) could not be removed\n" );
for( size_t i = 0; i < unremovedFiles.GetCount(); i++ )
msg += unremovedFiles[i] + wxT( "\n" );
msg += unremovedFiles[i] + wxS( "\n" );
msg += _( "Manual removal will be required for the file(s) above." );
wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION,
@ -1578,7 +1579,7 @@ void SCH_EDIT_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
}
// Remove the auto save master file.
wxLogTrace( traceAutoSave, wxT( "Removing auto save file '%s'" ), aFileName.GetFullPath() );
wxLogTrace( traceAutoSave, wxS( "Removing auto save file '%s'" ), aFileName.GetFullPath() );
if( !wxRemoveFile( aFileName.GetFullPath() ) )
{
@ -1600,7 +1601,7 @@ void SCH_EDIT_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
const wxString& SCH_EDIT_FRAME::getAutoSaveFileName() const
{
static wxString autoSaveFileName( wxT( "#auto_saved_files#" ) );
static wxString autoSaveFileName( wxS( "#auto_saved_files#" ) );
return autoSaveFileName;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015-2022 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2015-2023 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -208,7 +208,8 @@ LIB_SYMBOL* SCH_BASE_FRAME::GetLibSymbol( const LIB_ID& aLibId, bool aUseCacheLi
SYMBOL_LIB* cache =
( aUseCacheLib ) ? PROJECT_SCH::SchLibs( &Prj() )->GetCacheLibrary() : nullptr;
return SchGetLibSymbol( aLibId, PROJECT_SCH::SchSymbolLibTable( &Prj() ), cache, this, aShowErrorMsg );
return SchGetLibSymbol( aLibId, PROJECT_SCH::SchSymbolLibTable( &Prj() ), cache, this,
aShowErrorMsg );
}
@ -384,8 +385,8 @@ void SCH_BASE_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpda
}
/**
* Be careful when calling this. Update will invalidate RTree iterators, so you cannot call this
* while doing things like `for( SCH_ITEM* item : screen->Items() )`
* Be careful when calling this. Update will invalidate RTree iterators, so you cannot
* call this while doing things like `for( SCH_ITEM* item : screen->Items() )`
*/
if( aUpdateRtree && dynamic_cast<SCH_ITEM*>( aItem ) )
GetScreen()->Update( static_cast<SCH_ITEM*>( aItem ) );
@ -438,7 +439,7 @@ void SCH_BASE_FRAME::AddToScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen )
// Null pointers will cause boost::ptr_vector to raise a boost::bad_pointer exception which
// will be unhandled. There is no valid reason to pass an invalid EDA_ITEM pointer to the
// screen append function.
wxCHECK( aItem != nullptr, /* voide */ );
wxCHECK( aItem != nullptr, /* void */ );
auto screen = aScreen;
@ -727,4 +728,4 @@ void SCH_BASE_FRAME::OnSymChangeDebounceTimer( wxTimerEvent& aEvent )
Kiway().ExpressMail( FRAME_SCH_VIEWER, MAIL_REFRESH_SYMBOL, libName );
Kiway().ExpressMail( FRAME_SCH_SYMBOL_EDITOR, MAIL_REFRESH_SYMBOL, libName );
}
}
}

View File

@ -294,7 +294,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
if( cfg->m_AuiPanels.hierarchy_panel_docked_width > 0 )
{
// If the net navigator is not show, let the heirarchy navigator take all of the vertical
// If the net navigator is not show, let the hierarchy navigator take all of the vertical
// space.
if( !cfg->m_AuiPanels.show_net_nav_panel )
{
@ -427,7 +427,7 @@ void SCH_EDIT_FRAME::OnResizeHierarchyNavigator( wxSizeEvent& aEvent )
// Store the current pane size
// It allows to retrieve the last defined pane size when switching between
// docked and floating pane state
// Note: *DO NOT* call m_auimgr.Update() here: it crashes Kicad at least on Windows
// Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
@ -1496,7 +1496,8 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay()
}
else
{
SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol, devnull ).model;
SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol,
devnull ).model;
SPICE_ITEM spiceItem;
spiceItem.refName = ref;
@ -1893,6 +1894,7 @@ void SCH_EDIT_FRAME::OnPageSettingsChange()
// Store the current zoom level into the current screen before calling
// DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
GetScreen()->m_LastZoomLevel = GetCanvas()->GetView()->GetScale();
// Rebuild the sheet view (draw area and any other items):
DisplayCurrentSheet();
}
@ -2096,11 +2098,11 @@ void SCH_EDIT_FRAME::SaveSymbolToSchematic( const LIB_SYMBOL& aSymbol,
unit->SetLibSymbol( aSymbol.Flatten().release() );
unit->UpdateFields( &GetCurrentSheet(),
true, /* update style */
true, /* update ref */
true, /* update other fields */
false, /* reset ref */
false /* reset other fields */ );
true, /* update style */
true, /* update ref */
true, /* update other fields */
false, /* reset ref */
false /* reset other fields */ );
path.LastScreen()->Append( unit );
GetCanvas()->GetView()->Update( unit );