39 std::vector<LIB_SYMBOL::LOGICAL_PIN> logicalPins;
40 logicalPins.reserve( pinList.size() );
45 std::vector<wxString> numbers =
pin->GetStackedPinNumbers( &valid );
47 if( !valid || numbers.empty() )
49 logicalPins.push_back( {
pin,
pin->GetNumber() } );
53 for(
const wxString& number : numbers )
54 logicalPins.push_back( {
pin, number } );
57 sort( logicalPins.begin(), logicalPins.end(),
60 int result = lhs.number.Cmp( rhs.number );
63 result = lhs.pin->GetBodyStyle() - rhs.pin->GetBodyStyle();
66 result = lhs.pin->GetUnit() - rhs.pin->GetUnit();
68 if( result == 0 && lhs.pin != rhs.pin )
69 return lhs.pin < rhs.pin;
74 for(
unsigned ii = 1; ii < logicalPins.size(); ii++ )
98 if( !
next.pin->GetName().IsEmpty() )
99 nextName =
" '" +
next.pin->GetName() +
"'";
101 auto formatNumberForMessage = [](
const SCH_PIN*
pin,
const wxString& logicalNumber )
103 wxString shown =
pin->GetNumber();
105 if( shown == logicalNumber )
106 return logicalNumber;
108 return wxString::Format( wxT(
"%s (%s)" ), logicalNumber, shown );
111 wxString prevNumber = formatNumberForMessage( prev.
pin, prev.
number );
112 wxString nextNumber = formatNumberForMessage(
next.pin,
next.number );
118 msg.Printf(
_(
"<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
119 " conflicts with pin %s%s at location <b>(%s, %s)</b>"
120 " in %s body style." ),
133 msg.Printf(
_(
"<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
134 " conflicts with pin %s%s at location <b>(%s, %s)</b>"
135 " in units %s and %s of %s body style." ),
153 msg.Printf(
_(
"<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
154 " conflicts with pin %s%s at location <b>(%s, %s)</b>." ),
166 msg.Printf(
_(
"<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
167 " conflicts with pin %s%s at location <b>(%s, %s)</b>"
168 " in units %s and %s." ),
182 msg += wxT(
"<br><br>" );
183 aMessages.push_back( msg );
216 if( reference_base.IsEmpty() )
218 aMessages.push_back(
_(
"<b>Warning: reference is empty</b><br><br>" ) );
222 wxString illegal_end( wxT(
"0123456789?" ) );
223 wxUniChar last_char = reference_base.Last();
225 if( illegal_end.Find( last_char ) != wxNOT_FOUND )
227 msg.Printf(
_(
"<b>Warning: reference prefix</b><br>prefix ending by '%s' can create"
228 " issues if saved in a symbol library" ),
230 msg += wxT(
"<br><br>" );
231 aMessages.push_back( msg );
245 const int min_grid_size =
schIUScale.MilsToIU( 25 );
246 const int clamped_grid_size = ( aGridForPins < min_grid_size ) ? min_grid_size : aGridForPins;
256 msg.Printf(
_(
"<b>A Power Symbol should have only one unit</b><br><br>" ) );
257 aMessages.push_back( msg );
260 if( pinList.size() == 0 )
262 msg.Printf(
_(
"<b>A Power Symbol should have exactly one pin</b><br><br>" ) );
263 aMessages.push_back( msg );
267 if( pinList.size() > 1 )
269 msg.Printf(
_(
"<b>A Power Symbol should have only one pin</b><br><br>" ) );
270 aMessages.push_back( msg );
278 msg.Printf(
_(
"<b>Suspicious Power Symbol</b><br>"
279 "Only an input or output power pin has meaning<br><br>" ) );
280 aMessages.push_back( msg );
285 msg.Printf(
_(
"<b>Suspicious Power Symbol</b><br>"
286 "Invisible input power pins are no longer required<br><br>" ) );
287 aMessages.push_back( msg );
295 wxString pinName =
pin->GetName();
297 if( pinName.IsEmpty() || pinName ==
"~" )
300 pinName =
"'" + pinName +
"'";
304 && !
pin->IsVisible() )
311 msg.Printf(
_(
"Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
312 " in %s body style." ),
321 msg.Printf(
_(
"Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
322 " in unit %c of %s body style." ),
327 'A' +
pin->GetUnit() - 1,
335 msg.Printf(
_(
"Info: <b>Hidden power pin %s</b> %s at location <b>"
344 msg.Printf(
_(
"Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
350 'A' +
pin->GetUnit() - 1 );
354 msg += wxT(
"<br>" );
355 msg +=
_(
"(Hidden power pins will drive their pin names on to any connected nets.)" );
356 msg += wxT(
"<br><br>" );
357 aMessages.push_back( msg );
360 if( ( (
pin->GetPosition().x % clamped_grid_size) != 0 )
361 || ( (
pin->GetPosition().y % clamped_grid_size) != 0 ) )
370 msg.Printf(
_(
"<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
371 " of %s body style." ),
380 msg.Printf(
_(
"<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
381 " in unit %c of %s body style." ),
386 'A' +
pin->GetUnit() - 1,
394 msg.Printf(
_(
"<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>." ),
402 msg.Printf(
_(
"<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
408 'A' +
pin->GetUnit() - 1 );
412 msg += wxT(
"<br><br>" );
413 aMessages.push_back( msg );
444 msg.Printf(
_(
"<b>Graphic circle has radius = 0</b> at location "
445 "<b>(%s, %s)</b>." ),
448 msg += wxT(
"<br>" );
449 aMessages.push_back( msg );
456 msg.Printf(
_(
"<b>Graphic rectangle has size 0</b> at location <b>(%s, %s)</b>." ),
459 msg += wxT(
"<br>" );
460 aMessages.push_back( msg );
474 msg.Printf(
_(
"<b>Graphic ellipse has null or negative radii</b> at location "
475 "<b>(%s, %s)</b>." ),
478 msg += wxT(
"<br>" );
479 aMessages.push_back( msg );
485 msg.Printf(
_(
"<b>Graphic elliptical arc has zero sweep</b> at location "
486 "<b>(%s, %s)</b>." ),
489 msg += wxT(
"<br>" );
490 aMessages.push_back( msg );
constexpr EDA_IU_SCALE schIUScale
int GetEllipseMinorRadius() const
EDA_ANGLE GetEllipseEndAngle() const
int GetEllipseMajorRadius() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
EDA_ANGLE GetEllipseStartAngle() const
wxString SHAPE_T_asString() const
Define a library symbol object.
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
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const override
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the user-defined display name for aUnit for symbols with units.
SCH_FIELD & GetReferenceField()
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)