Improved naming.

This commit is contained in:
Jeff Young 2021-11-02 18:32:39 +00:00
parent 21cb56dfe7
commit eaf10a04dd
4 changed files with 31 additions and 29 deletions

View File

@ -1258,7 +1258,7 @@ void LIB_SYMBOL::SetSubpartIdNotation( int aSep, int aFirstId )
}
std::vector<LIB_ITEM*> LIB_SYMBOL::GetUnitItems( int aUnit, int aConvert )
std::vector<LIB_ITEM*> LIB_SYMBOL::GetUnitDrawItems( int aUnit, int aConvert )
{
std::vector<LIB_ITEM*> unitItems;
@ -1279,9 +1279,9 @@ std::vector<LIB_ITEM*> LIB_SYMBOL::GetUnitItems( int aUnit, int aConvert )
}
std::vector<struct LIB_SYMBOL_UNITS> LIB_SYMBOL::GetUnitDrawItems()
std::vector<struct LIB_SYMBOL_UNIT> LIB_SYMBOL::GetUnitDrawItems()
{
std::vector<struct LIB_SYMBOL_UNITS> units;
std::vector<struct LIB_SYMBOL_UNIT> units;
for( LIB_ITEM& item : m_drawings )
{
@ -1292,14 +1292,14 @@ std::vector<struct LIB_SYMBOL_UNITS> LIB_SYMBOL::GetUnitDrawItems()
int convert = item.GetConvert();
auto it = std::find_if( units.begin(), units.end(),
[unit, convert]( const LIB_SYMBOL_UNITS& a )
[unit, convert]( const LIB_SYMBOL_UNIT& a )
{
return a.m_unit == unit && a.m_convert == convert;
} );
if( it == units.end() )
{
struct LIB_SYMBOL_UNITS newUnit;
struct LIB_SYMBOL_UNIT newUnit;
newUnit.m_unit = item.GetUnit();
newUnit.m_convert = item.GetConvert();
newUnit.m_items.push_back( &item );
@ -1315,19 +1315,19 @@ std::vector<struct LIB_SYMBOL_UNITS> LIB_SYMBOL::GetUnitDrawItems()
}
std::vector<struct LIB_SYMBOL_UNITS> LIB_SYMBOL::GetUniqueUnits()
std::vector<struct LIB_SYMBOL_UNIT> LIB_SYMBOL::GetUniqueUnits()
{
int unitNum;
size_t i;
struct LIB_SYMBOL_UNITS unit;
struct LIB_SYMBOL_UNIT unit;
std::vector<LIB_ITEM*> compareDrawItems;
std::vector<LIB_ITEM*> currentDrawItems;
std::vector<struct LIB_SYMBOL_UNITS> uniqueUnits;
std::vector<struct LIB_SYMBOL_UNIT> uniqueUnits;
// The first unit is guaranteed to be unique so always include it.
unit.m_unit = 1;
unit.m_convert = 1;
unit.m_items = GetUnitItems( 1, 1 );
unit.m_items = GetUnitDrawItems( 1, 1 );
// There are no unique units if there are no draw items other than fields.
if( unit.m_items.size() == 0 )
@ -1342,7 +1342,7 @@ std::vector<struct LIB_SYMBOL_UNITS> LIB_SYMBOL::GetUniqueUnits()
for( unitNum = 2; unitNum <= GetUnitCount(); unitNum++ )
{
compareDrawItems = GetUnitItems( unitNum, 1 );
compareDrawItems = GetUnitDrawItems( unitNum, 1 );
wxCHECK2_MSG( compareDrawItems.size() != 0, continue,
"Multiple unit symbol defined with empty units." );
@ -1372,7 +1372,7 @@ std::vector<struct LIB_SYMBOL_UNITS> LIB_SYMBOL::GetUniqueUnits()
if( HasConversion() )
{
currentDrawItems = GetUnitItems( 1, 2 );
currentDrawItems = GetUnitDrawItems( 1, 2 );
if( ( GetUnitCount() == 1 || UnitsLocked() ) )
{
@ -1386,7 +1386,7 @@ std::vector<struct LIB_SYMBOL_UNITS> LIB_SYMBOL::GetUniqueUnits()
for( unitNum = 2; unitNum <= GetUnitCount(); unitNum++ )
{
compareDrawItems = GetUnitItems( unitNum, 2 );
compareDrawItems = GetUnitDrawItems( unitNum, 2 );
wxCHECK2_MSG( compareDrawItems.size() != 0, continue,
"Multiple unit symbol defined with empty units." );

View File

@ -79,7 +79,7 @@ struct LIB_SYMBOL_OPTIONS
};
struct LIB_SYMBOL_UNITS
struct LIB_SYMBOL_UNIT
{
int m_unit; ///< The unit number.
int m_convert; ///< The alternate body style of the unit.
@ -624,7 +624,7 @@ public:
* @note This does not include LIB_FIELD objects since they are not associated with
* unit and/or convert numbers.
*/
std::vector<struct LIB_SYMBOL_UNITS> GetUnitDrawItems();
std::vector<struct LIB_SYMBOL_UNIT> GetUnitDrawItems();
/**
* Return a list of unit numbers that are unique to this symbol.
@ -634,7 +634,7 @@ public:
*
* @return a list of unique unit numbers and their associated draw items.
*/
std::vector<struct LIB_SYMBOL_UNITS> GetUniqueUnits();
std::vector<struct LIB_SYMBOL_UNIT> GetUniqueUnits();
/**
* Return a list of item pointers for \a aUnit and \a aConvert for this symbol.
@ -646,7 +646,7 @@ public:
*
* @return a list of unit items.
*/
std::vector<LIB_ITEM*> GetUnitItems( int aUnit, int aConvert );
std::vector<LIB_ITEM*> GetUnitDrawItems( int aUnit, int aConvert );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }

View File

@ -786,8 +786,10 @@ void SCH_SEXPR_PLUGIN::Format( SCH_SHEET* aSheet )
if( itemType != SCH_SYMBOL_T
&& itemType != SCH_JUNCTION_T
&& itemType != SCH_SHEET_T )
{
m_out->Print( 0, "\n" );
}
}
switch( item->Type() )
{
@ -1801,9 +1803,9 @@ void SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& a
saveDcmInfoAsFields( aSymbol, aFormatter, nextFreeFieldId, aNestLevel );
// Save the draw items grouped by units.
std::vector<LIB_SYMBOL_UNITS> units = aSymbol->GetUnitDrawItems();
std::vector<LIB_SYMBOL_UNIT> units = aSymbol->GetUnitDrawItems();
std::sort( units.begin(), units.end(),
[]( const LIB_SYMBOL_UNITS& a, const LIB_SYMBOL_UNITS& b )
[]( const LIB_SYMBOL_UNIT& a, const LIB_SYMBOL_UNIT& b )
{
if( a.m_unit == b.m_unit )
return a.m_convert < b.m_convert;
@ -1820,7 +1822,7 @@ void SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& a
aFormatter.Print( aNestLevel + 1, "(symbol %s_%d_%d\"\n",
name.c_str(), unit.m_unit, unit.m_convert );
for( auto item : unit.m_items )
for( LIB_ITEM* item : unit.m_items )
saveSymbolDrawItem( item, aFormatter, aNestLevel + 2 );
aFormatter.Print( aNestLevel + 1, ")\n" );

View File

@ -382,20 +382,20 @@ BOOST_AUTO_TEST_CASE( Compare )
BOOST_AUTO_TEST_CASE( GetUnitItems )
{
// There are no unit draw items in the empty LIB_SYMBOL object.
BOOST_CHECK( m_part_no_data.GetUnitItems( 1, 1 ).size() == 0 );
BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 0 );
// A single unique unit with 1 pin common to all units and all body styles.
LIB_PIN* pin1 = new LIB_PIN( &m_part_no_data );
m_part_no_data.AddDrawItem( pin1 );
BOOST_CHECK( m_part_no_data.GetUnitItems( 0, 0 ).size() == 1 );
BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 0, 0 ).size() == 1 );
// A single unique unit with 1 pin in unit 1 and common to all body styles.
pin1->SetUnit( 1 );
BOOST_CHECK( m_part_no_data.GetUnitItems( 1, 0 ).size() == 1 );
BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 0 ).size() == 1 );
// A single unique unit with 1 pin in unit 1 and body style 1.
pin1->SetConvert( 1 );
BOOST_CHECK( m_part_no_data.GetUnitItems( 1, 1 ).size() == 1 );
BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 1 );
// Two unique units with pin 1 assigned to unit 1 and body style 1 and pin 2 assigned to
// unit 2 and body style 1.
@ -405,12 +405,12 @@ BOOST_AUTO_TEST_CASE( GetUnitItems )
pin2->SetConvert( 2 );
pin2->SetNumber( "4" );
m_part_no_data.AddDrawItem( pin2 );
BOOST_CHECK( m_part_no_data.GetUnitItems( 2, 2 ).size() == 1 );
BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 2, 2 ).size() == 1 );
// Make pin 1 body style common to all units.
pin1->SetConvert( 0 );
BOOST_CHECK( m_part_no_data.GetUnitItems( 1, 1 ).size() == 0 );
BOOST_CHECK( m_part_no_data.GetUnitItems( 2, 1 ).size() == 1 );
BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 0 );
BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 2, 1 ).size() == 1 );
m_part_no_data.RemoveDrawItem( pin2 );
m_part_no_data.RemoveDrawItem( pin1 );
@ -430,7 +430,7 @@ BOOST_AUTO_TEST_CASE( GetUnitDrawItems )
LIB_PIN* pin1 = new LIB_PIN( &m_part_no_data );
pin1->SetNumber( "1" );
m_part_no_data.AddDrawItem( pin1 );
std::vector<struct LIB_SYMBOL_UNITS> units = m_part_no_data.GetUnitDrawItems();
std::vector<struct LIB_SYMBOL_UNIT> units = m_part_no_data.GetUnitDrawItems();
BOOST_CHECK( units.size() == 1 );
BOOST_CHECK( units[0].m_unit == 0 );
BOOST_CHECK( units[0].m_convert == 0 );