2022-04-16 16:55:04 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-02-14 21:44:49 +00:00
|
|
|
* Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2022-04-16 16:55:04 +00:00
|
|
|
*
|
|
|
|
* 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 2
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <vector>
|
2022-09-19 09:25:20 +00:00
|
|
|
#include <eda_draw_frame.h>
|
2024-04-27 19:57:24 +00:00
|
|
|
#include <lib_symbol.h>
|
2024-04-15 20:18:54 +00:00
|
|
|
#include <sch_shape.h>
|
2023-10-10 16:30:56 +00:00
|
|
|
#include <macros.h>
|
2022-04-16 16:55:04 +00:00
|
|
|
|
|
|
|
// helper function to sort pins by pin num
|
2024-04-20 09:44:34 +00:00
|
|
|
static bool sort_by_pin_number( const SCH_PIN* ref, const SCH_PIN* tst );
|
2022-04-16 16:55:04 +00:00
|
|
|
|
2023-10-10 16:30:56 +00:00
|
|
|
static void CheckLibSymbolGraphics( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
|
2024-05-26 15:18:23 +00:00
|
|
|
UNITS_PROVIDER* aUnitsProvider );
|
2023-10-10 16:30:56 +00:00
|
|
|
|
2024-05-26 15:18:23 +00:00
|
|
|
void CheckDuplicatePins( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
|
|
|
|
UNITS_PROVIDER* aUnitsProvider )
|
2022-04-16 16:55:04 +00:00
|
|
|
{
|
2024-05-26 15:18:23 +00:00
|
|
|
wxString msg;
|
2024-04-20 09:44:34 +00:00
|
|
|
std::vector<SCH_PIN*> pinList = aSymbol->GetPins();
|
2022-04-16 16:55:04 +00:00
|
|
|
|
|
|
|
// Test for duplicates:
|
|
|
|
// Sort pins by pin num, so 2 duplicate pins
|
|
|
|
// (pins with the same number) will be consecutive in list
|
|
|
|
sort( pinList.begin(), pinList.end(), sort_by_pin_number );
|
|
|
|
|
|
|
|
for( unsigned ii = 1; ii < pinList.size(); ii++ )
|
|
|
|
{
|
2024-04-20 09:44:34 +00:00
|
|
|
SCH_PIN* pin = pinList[ii - 1];
|
|
|
|
SCH_PIN* next = pinList[ii];
|
2022-04-16 16:55:04 +00:00
|
|
|
|
2022-05-23 09:20:12 +00:00
|
|
|
if( pin->GetNumber() != next->GetNumber() )
|
2022-04-16 16:55:04 +00:00
|
|
|
continue;
|
|
|
|
|
2024-01-26 16:16:13 +00:00
|
|
|
// Pins are not duplicated only if they are in different body styles
|
|
|
|
// (but GetBodyStyle() == 0 means commun to all body styles)
|
|
|
|
if( pin->GetBodyStyle() != 0 && next->GetBodyStyle() != 0 )
|
2022-05-23 09:20:12 +00:00
|
|
|
{
|
2024-01-26 16:16:13 +00:00
|
|
|
if( pin->GetBodyStyle() != next->GetBodyStyle() )
|
2022-05-23 09:20:12 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-04-16 16:55:04 +00:00
|
|
|
wxString pinName;
|
|
|
|
wxString nextName;
|
|
|
|
|
|
|
|
if( pin->GetName() != "~" && !pin->GetName().IsEmpty() )
|
|
|
|
pinName = " '" + pin->GetName() + "'";
|
|
|
|
|
|
|
|
if( next->GetName() != "~" && !next->GetName().IsEmpty() )
|
|
|
|
nextName = " '" + next->GetName() + "'";
|
|
|
|
|
2024-01-26 16:16:13 +00:00
|
|
|
if( aSymbol->HasAlternateBodyStyle() && next->GetBodyStyle() )
|
2022-04-16 16:55:04 +00:00
|
|
|
{
|
|
|
|
if( pin->GetUnit() == 0 || next->GetUnit() == 0 )
|
|
|
|
{
|
2024-01-26 02:01:23 +00:00
|
|
|
msg.Printf( _( "<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
|
|
|
|
" conflicts with pin %s%s at location <b>(%s, %s)</b>"
|
2024-01-26 18:11:10 +00:00
|
|
|
" in %s body style." ),
|
2022-04-16 16:55:04 +00:00
|
|
|
next->GetNumber(),
|
|
|
|
nextName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( next->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -next->GetPosition().y ),
|
2022-04-16 16:55:04 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pin->GetName(),
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
|
2024-01-26 18:11:10 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
|
2024-04-06 13:14:44 +00:00
|
|
|
SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
|
2022-04-16 16:55:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-26 02:01:23 +00:00
|
|
|
msg.Printf( _( "<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
|
|
|
|
" conflicts with pin %s%s at location <b>(%s, %s)</b>"
|
2024-01-26 18:11:10 +00:00
|
|
|
" in units %s and %s of %s body style." ),
|
2022-04-16 16:55:04 +00:00
|
|
|
next->GetNumber(),
|
|
|
|
nextName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( next->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -next->GetPosition().y ),
|
2022-04-16 16:55:04 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
|
2022-04-16 16:55:04 +00:00
|
|
|
aSymbol->GetUnitReference( next->GetUnit() ),
|
2024-01-26 18:11:10 +00:00
|
|
|
aSymbol->GetUnitReference( pin->GetUnit() ),
|
2024-04-06 13:14:44 +00:00
|
|
|
SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
|
2022-04-16 16:55:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( pin->GetUnit() == 0 || next->GetUnit() == 0 )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
|
|
|
|
" conflicts with pin %s%s at location <b>(%s, %s)</b>." ),
|
|
|
|
next->GetNumber(),
|
|
|
|
nextName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( next->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -next->GetPosition().y ),
|
2022-04-16 16:55:04 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) );
|
2022-04-16 16:55:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msg.Printf( _( "<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
|
|
|
|
" conflicts with pin %s%s at location <b>(%s, %s)</b>"
|
|
|
|
" in units %s and %s." ),
|
|
|
|
next->GetNumber(),
|
|
|
|
nextName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( next->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -next->GetPosition().y ),
|
2022-04-16 16:55:04 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
|
2022-04-16 16:55:04 +00:00
|
|
|
aSymbol->GetUnitReference( next->GetUnit() ),
|
|
|
|
aSymbol->GetUnitReference( pin->GetUnit() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msg += wxT( "<br><br>" );
|
|
|
|
aMessages.push_back( msg );
|
|
|
|
}
|
2024-05-26 15:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check a lib symbol to find incorrect settings
|
|
|
|
* Pins not on a valid grid
|
|
|
|
* Pins duplicated
|
|
|
|
* Conflict with pins at same location
|
|
|
|
* Incorrect Power Symbols
|
|
|
|
* illegal reference prefix (cannot ends by a digit or a '?')
|
|
|
|
* @param aSymbol is the library symbol to check
|
|
|
|
* @param aMessages is a room to store error messages
|
|
|
|
* @param aGridForPins (in IU) is the grid to test pin positions ( >= 25 mils )
|
|
|
|
* should be 25, 50 or 100 mils (convered to IUs)
|
|
|
|
* @param aUnitsProvider a frame to format coordinates in messages
|
|
|
|
*/
|
|
|
|
void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
|
|
|
|
int aGridForPins, UNITS_PROVIDER* aUnitsProvider )
|
|
|
|
{
|
|
|
|
if( !aSymbol )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
// Test reference prefix validity:
|
|
|
|
// if the symbol is saved in a library, the prefix should not ends by a digit or a '?'
|
|
|
|
// but it is acceptable if the symbol is saved to aschematic
|
|
|
|
wxString reference_base = aSymbol->GetReferenceField().GetText();
|
|
|
|
wxString illegal_end( wxT( "0123456789?" ) );
|
|
|
|
wxUniChar last_char = reference_base.Last();
|
|
|
|
|
|
|
|
if( illegal_end.Find( last_char ) != wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "<b>Warning: reference prefix</b><br>prefix ending by '%s' can create"
|
|
|
|
" issues if saved in a symbol library" ),
|
|
|
|
illegal_end );
|
|
|
|
msg += wxT( "<br><br>" );
|
|
|
|
aMessages.push_back( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckDuplicatePins( aSymbol, aMessages, aUnitsProvider );
|
|
|
|
|
|
|
|
std::vector<SCH_PIN*> pinList = aSymbol->GetPins();
|
|
|
|
sort( pinList.begin(), pinList.end(), sort_by_pin_number );
|
|
|
|
|
|
|
|
// The minimal grid size allowed to place a pin is 25 mils
|
|
|
|
// the best grid size is 50 mils, but 25 mils is still usable
|
|
|
|
// this is because all aSymbols are using a 50 mils grid to place pins, and therefore
|
|
|
|
// the wires must be on the 50 mils grid
|
|
|
|
// So raise an error if a pin is not on a 25 (or bigger :50 or 100) mils grid
|
|
|
|
const int min_grid_size = schIUScale.MilsToIU( 25 );
|
|
|
|
const int clamped_grid_size = ( aGridForPins < min_grid_size ) ? min_grid_size : aGridForPins;
|
2022-04-16 16:55:04 +00:00
|
|
|
|
|
|
|
// Test for a valid power aSymbol.
|
2024-01-26 16:16:13 +00:00
|
|
|
// A valid power aSymbol has only one unit, no alternate body styles and one pin.
|
2022-04-16 16:55:04 +00:00
|
|
|
// And this pin should be PT_POWER_IN (invisible to be automatically connected)
|
|
|
|
// or PT_POWER_OUT for a power flag
|
|
|
|
if( aSymbol->IsPower() )
|
|
|
|
{
|
|
|
|
if( aSymbol->GetUnitCount() != 1 )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "<b>A Power Symbol should have only one unit</b><br><br>" ) );
|
|
|
|
aMessages.push_back( msg );
|
|
|
|
}
|
|
|
|
|
2024-01-26 16:16:13 +00:00
|
|
|
if( aSymbol->HasAlternateBodyStyle() )
|
2022-04-16 16:55:04 +00:00
|
|
|
{
|
2024-02-05 11:05:31 +00:00
|
|
|
msg.Printf( _( "<b>A Power Symbol should not have DeMorgan variants</b><br><br>" ) );
|
2022-04-16 16:55:04 +00:00
|
|
|
aMessages.push_back( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pinList.size() != 1 )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "<b>A Power Symbol should have only one pin</b><br><br>" ) );
|
|
|
|
aMessages.push_back( msg );
|
|
|
|
}
|
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
SCH_PIN* pin = pinList[0];
|
2022-04-16 16:55:04 +00:00
|
|
|
|
|
|
|
if( pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_IN
|
|
|
|
&& pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_OUT )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "<b>Suspicious Power Symbol</b><br>"
|
2023-02-14 21:44:49 +00:00
|
|
|
"Only an input or output power pin has meaning<br><br>" ) );
|
2022-04-16 16:55:04 +00:00
|
|
|
aMessages.push_back( msg );
|
|
|
|
}
|
|
|
|
|
2023-01-18 14:58:47 +00:00
|
|
|
if( pin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN && !pin->IsVisible() )
|
2022-04-16 16:55:04 +00:00
|
|
|
{
|
|
|
|
msg.Printf( _( "<b>Suspicious Power Symbol</b><br>"
|
2023-01-18 14:58:47 +00:00
|
|
|
"Invisible input power pins are no longer required<br><br>" ) );
|
2022-04-16 16:55:04 +00:00
|
|
|
aMessages.push_back( msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
for( SCH_PIN* pin : pinList )
|
2022-04-16 16:55:04 +00:00
|
|
|
{
|
|
|
|
wxString pinName = pin->GetName();
|
|
|
|
|
|
|
|
if( pinName.IsEmpty() || pinName == "~" )
|
|
|
|
pinName = "";
|
|
|
|
else
|
|
|
|
pinName = "'" + pinName + "'";
|
|
|
|
|
|
|
|
if( !aSymbol->IsPower()
|
|
|
|
&& pin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN
|
|
|
|
&& !pin->IsVisible() )
|
|
|
|
{
|
|
|
|
// hidden power pin
|
2024-01-26 16:16:13 +00:00
|
|
|
if( aSymbol->HasAlternateBodyStyle() && pin->GetBodyStyle() )
|
2022-04-16 16:55:04 +00:00
|
|
|
{
|
|
|
|
if( aSymbol->GetUnitCount() <= 1 )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
|
2024-01-26 18:11:10 +00:00
|
|
|
" in %s body style." ),
|
2022-04-16 16:55:04 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
|
2024-01-26 18:11:10 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
|
2024-04-06 13:14:44 +00:00
|
|
|
SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
|
2022-04-16 16:55:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
|
2024-01-26 18:11:10 +00:00
|
|
|
" in unit %c of %s body style." ),
|
2022-04-16 16:55:04 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
|
2024-01-26 18:11:10 +00:00
|
|
|
'A' + pin->GetUnit() - 1,
|
2024-04-06 13:14:44 +00:00
|
|
|
SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
|
2022-04-16 16:55:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( aSymbol->GetUnitCount() <= 1 )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>." ),
|
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) );
|
2022-04-16 16:55:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
|
|
|
|
" in unit %c." ),
|
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
|
2022-04-16 16:55:04 +00:00
|
|
|
'A' + pin->GetUnit() - 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msg += wxT( "<br>" );
|
|
|
|
msg += _( "(Hidden power pins will drive their pin names on to any connected nets.)" );
|
|
|
|
msg += wxT( "<br><br>" );
|
|
|
|
aMessages.push_back( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ( (pin->GetPosition().x % clamped_grid_size) != 0 )
|
|
|
|
|| ( (pin->GetPosition().y % clamped_grid_size) != 0 ) )
|
|
|
|
{
|
|
|
|
// pin is off grid
|
2024-01-26 09:19:58 +00:00
|
|
|
msg.Empty();
|
|
|
|
|
2024-01-26 16:16:13 +00:00
|
|
|
if( aSymbol->HasAlternateBodyStyle() && pin->GetBodyStyle() )
|
2022-04-16 16:55:04 +00:00
|
|
|
{
|
|
|
|
if( aSymbol->GetUnitCount() <= 1 )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
|
2024-01-26 18:11:10 +00:00
|
|
|
" of %s body style." ),
|
2022-04-16 16:55:04 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
|
2024-01-26 18:11:10 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
|
2024-04-06 13:14:44 +00:00
|
|
|
SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
|
2022-04-16 16:55:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-26 18:11:10 +00:00
|
|
|
msg.Printf( _( "<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
|
|
|
|
" in unit %c of %s body style." ),
|
2022-04-16 16:55:04 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
|
2024-01-26 18:11:10 +00:00
|
|
|
'A' + pin->GetUnit() - 1,
|
2024-04-06 13:14:44 +00:00
|
|
|
SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() );
|
2024-01-26 09:19:58 +00:00
|
|
|
}
|
2022-04-16 16:55:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( aSymbol->GetUnitCount() <= 1 )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>." ),
|
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) );
|
2022-04-16 16:55:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msg.Printf( _( "<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
|
|
|
|
" in unit %c." ),
|
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2022-09-19 09:25:20 +00:00
|
|
|
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
|
2022-04-16 16:55:04 +00:00
|
|
|
'A' + pin->GetUnit() - 1 );
|
|
|
|
}
|
|
|
|
}
|
2024-01-26 09:19:58 +00:00
|
|
|
|
|
|
|
msg += wxT( "<br><br>" );
|
|
|
|
aMessages.push_back( msg );
|
2023-10-10 16:30:56 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-16 16:55:04 +00:00
|
|
|
|
2023-10-10 16:30:56 +00:00
|
|
|
CheckLibSymbolGraphics( aSymbol, aMessages, aUnitsProvider );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CheckLibSymbolGraphics( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
|
2024-05-26 15:18:23 +00:00
|
|
|
UNITS_PROVIDER* aUnitsProvider )
|
2023-10-10 16:30:56 +00:00
|
|
|
{
|
|
|
|
if( !aSymbol )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
2024-04-06 13:14:44 +00:00
|
|
|
for( const SCH_ITEM& item : aSymbol->GetDrawItems() )
|
2023-10-10 16:30:56 +00:00
|
|
|
{
|
2024-04-15 20:18:54 +00:00
|
|
|
if( item.Type() != SCH_SHAPE_T )
|
2023-10-10 16:30:56 +00:00
|
|
|
continue;
|
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
const SCH_SHAPE* shape = static_cast<const SCH_SHAPE*>( &item );
|
2023-10-10 16:30:56 +00:00
|
|
|
|
|
|
|
switch( shape->GetShape() )
|
|
|
|
{
|
|
|
|
case SHAPE_T::ARC:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::CIRCLE:
|
|
|
|
if( shape->GetRadius() <= 0 )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "<b>Graphic circle has radius = 0</b> at location <b>(%s, %s)</b>." ),
|
|
|
|
aUnitsProvider->MessageTextFromValue(shape->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -shape->GetPosition().y ) );
|
|
|
|
msg += wxT( "<br>" );
|
|
|
|
aMessages.push_back( msg );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::RECTANGLE:
|
|
|
|
if( shape->GetPosition() == shape->GetEnd() )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "<b>Graphic rectangle has size 0</b> at location <b>(%s, %s)</b>." ),
|
|
|
|
aUnitsProvider->MessageTextFromValue(shape->GetPosition().x ),
|
|
|
|
aUnitsProvider->MessageTextFromValue( -shape->GetPosition().y ) );
|
|
|
|
msg += wxT( "<br>" );
|
|
|
|
aMessages.push_back( msg );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::POLY:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::BEZIER:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() );
|
2022-04-16 16:55:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
bool sort_by_pin_number( const SCH_PIN* ref, const SCH_PIN* tst )
|
2022-04-16 16:55:04 +00:00
|
|
|
{
|
|
|
|
// Use number as primary key
|
|
|
|
int test = ref->GetNumber().Cmp( tst->GetNumber() );
|
|
|
|
|
|
|
|
// Use DeMorgan variant as secondary key
|
|
|
|
if( test == 0 )
|
2024-01-26 16:16:13 +00:00
|
|
|
test = ref->GetBodyStyle() - tst->GetBodyStyle();
|
2022-04-16 16:55:04 +00:00
|
|
|
|
|
|
|
// Use unit as tertiary key
|
|
|
|
if( test == 0 )
|
|
|
|
test = ref->GetUnit() - tst->GetUnit();
|
|
|
|
|
|
|
|
return test < 0;
|
|
|
|
}
|