43 std::vector<LIB_SYMBOL::LOGICAL_PIN> logicalPins;
44 logicalPins.reserve( pinList.size() );
49 std::vector<wxString> numbers =
pin->GetStackedPinNumbers( &valid );
51 if( !valid || numbers.empty() )
53 logicalPins.push_back( {
pin,
pin->GetNumber() } );
57 for(
const wxString& number : numbers )
58 logicalPins.push_back( {
pin, number } );
61 sort( logicalPins.begin(), logicalPins.end(),
64 int result = lhs.number.Cmp( rhs.number );
67 result = lhs.pin->GetBodyStyle() - rhs.pin->GetBodyStyle();
70 result = lhs.pin->GetUnit() - rhs.pin->GetUnit();
72 if( result == 0 && lhs.pin != rhs.pin )
73 return lhs.pin < rhs.pin;
78 for(
unsigned ii = 1; ii < logicalPins.size(); ii++ )
103 if( !
next.pin->GetName().IsEmpty() )
104 nextName =
" '" +
next.pin->GetName() +
"'";
106 auto formatNumberForMessage = [](
const SCH_PIN*
pin,
const wxString& logicalNumber )
108 wxString shown =
pin->GetNumber();
110 if( shown == logicalNumber )
111 return logicalNumber;
113 return wxString::Format( wxT(
"%s (%s)" ), logicalNumber, shown );
116 wxString prevNumber = formatNumberForMessage( prev.
pin, prev.
number );
117 wxString nextNumber = formatNumberForMessage(
next.pin,
next.number );
123 msg.Printf(
_(
"<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
124 " conflicts with pin %s%s at location <b>(%s, %s)</b>"
125 " in %s body style." ),
138 msg.Printf(
_(
"<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
139 " conflicts with pin %s%s at location <b>(%s, %s)</b>"
140 " in units %s and %s of %s body style." ),
158 msg.Printf(
_(
"<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
159 " conflicts with pin %s%s at location <b>(%s, %s)</b>." ),
171 msg.Printf(
_(
"<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
172 " conflicts with pin %s%s at location <b>(%s, %s)</b>"
173 " in units %s and %s." ),
187 msg += wxT(
"<br><br>" );
188 aMessages.push_back( msg );
221 if( reference_base.IsEmpty() )
223 aMessages.push_back(
_(
"<b>Warning: reference is empty</b><br><br>" ) );
227 wxString illegal_end( wxT(
"0123456789?" ) );
228 wxUniChar last_char = reference_base.Last();
230 if( illegal_end.Find( last_char ) != wxNOT_FOUND )
232 msg.Printf(
_(
"<b>Warning: reference prefix</b><br>prefix ending by '%s' can create"
233 " issues if saved in a symbol library" ),
235 msg += wxT(
"<br><br>" );
236 aMessages.push_back( msg );
250 const int min_grid_size =
schIUScale.MilsToIU( 25 );
251 const int clamped_grid_size = ( aGridForPins < min_grid_size ) ? min_grid_size : aGridForPins;
261 msg.Printf(
_(
"<b>A Power Symbol should have only one unit</b><br><br>" ) );
262 aMessages.push_back( msg );
265 if( pinList.size() != 1 )
267 msg.Printf(
_(
"<b>A Power Symbol should have only one pin</b><br><br>" ) );
268 aMessages.push_back( msg );
276 msg.Printf(
_(
"<b>Suspicious Power Symbol</b><br>"
277 "Only an input or output power pin has meaning<br><br>" ) );
278 aMessages.push_back( msg );
283 msg.Printf(
_(
"<b>Suspicious Power Symbol</b><br>"
284 "Invisible input power pins are no longer required<br><br>" ) );
285 aMessages.push_back( msg );
292 wxString pinName =
pin->GetName();
294 if( pinName.IsEmpty() || pinName ==
"~" )
297 pinName =
"'" + pinName +
"'";
301 && !
pin->IsVisible() )
308 msg.Printf(
_(
"Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
309 " in %s body style." ),
318 msg.Printf(
_(
"Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
319 " in unit %c of %s body style." ),
324 'A' +
pin->GetUnit() - 1,
332 msg.Printf(
_(
"Info: <b>Hidden power pin %s</b> %s at location <b>"
341 msg.Printf(
_(
"Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
347 'A' +
pin->GetUnit() - 1 );
351 msg += wxT(
"<br>" );
352 msg +=
_(
"(Hidden power pins will drive their pin names on to any connected nets.)" );
353 msg += wxT(
"<br><br>" );
354 aMessages.push_back( msg );
357 if( ( (
pin->GetPosition().x % clamped_grid_size) != 0 )
358 || ( (
pin->GetPosition().y % clamped_grid_size) != 0 ) )
367 msg.Printf(
_(
"<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
368 " of %s body style." ),
377 msg.Printf(
_(
"<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
378 " in unit %c of %s body style." ),
383 'A' +
pin->GetUnit() - 1,
391 msg.Printf(
_(
"<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>." ),
399 msg.Printf(
_(
"<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
405 'A' +
pin->GetUnit() - 1 );
409 msg += wxT(
"<br><br>" );
410 aMessages.push_back( msg );
441 msg.Printf(
_(
"<b>Graphic circle has radius = 0</b> at location "
442 "<b>(%s, %s)</b>." ),
445 msg += wxT(
"<br>" );
446 aMessages.push_back( msg );
453 msg.Printf(
_(
"<b>Graphic rectangle has size 0</b> at location <b>(%s, %s)</b>." ),
456 msg += wxT(
"<br>" );
457 aMessages.push_back( msg );
constexpr EDA_IU_SCALE schIUScale
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
wxString SHAPE_T_asString() const
Define a library symbol object.
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
bool IsPower() const override
bool IsMultiBodyStyle() const override
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
bool IsGlobalPower() const override
wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const override
int GetUnitCount() const override
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the user-defined display name for aUnit for symbols with units.
SCH_FIELD & GetReferenceField()
Return reference to the reference designator field.
virtual const wxString & GetText() const override
Return the string associated with the text object.
Base class for any item which can be embedded within the SCHEMATIC container class,...
const wxString & GetName() const
VECTOR2I GetPosition() const override
const wxString & GetNumber() const
VECTOR2I GetPosition() const override
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
@ PT_POWER_OUT
output of a regulator: intended to be connected to power input pins
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
Logical pins: Return expanded logical pins based on stacked-pin notation.
wxString number
expanded logical pin number
const SCH_PIN * pin
pointer to the base graphical pin
static bool sort_by_pin_number(const SCH_PIN *ref, const SCH_PIN *tst)
void CheckDuplicatePins(LIB_SYMBOL *aSymbol, std::vector< wxString > &aMessages, UNITS_PROVIDER *aUnitsProvider)
void CheckLibSymbol(LIB_SYMBOL *aSymbol, std::vector< wxString > &aMessages, int aGridForPins, UNITS_PROVIDER *aUnitsProvider)
Check a library symbol to find incorrect settings.
static void CheckLibSymbolGraphics(LIB_SYMBOL *aSymbol, std::vector< wxString > &aMessages, UNITS_PROVIDER *aUnitsProvider)