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++ )
99 if( !
next.pin->GetName().IsEmpty() )
100 nextName =
" '" +
next.pin->GetName() +
"'";
102 auto formatNumberForMessage = [](
const SCH_PIN*
pin,
const wxString& logicalNumber )
104 wxString shown =
pin->GetNumber();
106 if( shown == logicalNumber )
107 return logicalNumber;
109 return wxString::Format( wxT(
"%s (%s)" ), logicalNumber, shown );
112 wxString prevNumber = formatNumberForMessage( prev.
pin, prev.
number );
113 wxString nextNumber = formatNumberForMessage(
next.pin,
next.number );
119 msg.Printf(
_(
"<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
120 " conflicts with pin %s%s at location <b>(%s, %s)</b>"
121 " in %s body style." ),
134 msg.Printf(
_(
"<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
135 " conflicts with pin %s%s at location <b>(%s, %s)</b>"
136 " in units %s and %s of %s body style." ),
154 msg.Printf(
_(
"<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
155 " conflicts with pin %s%s at location <b>(%s, %s)</b>." ),
167 msg.Printf(
_(
"<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
168 " conflicts with pin %s%s at location <b>(%s, %s)</b>"
169 " in units %s and %s." ),
183 msg += wxT(
"<br><br>" );
184 aMessages.push_back( msg );
217 if( reference_base.IsEmpty() )
219 aMessages.push_back(
_(
"<b>Warning: reference is empty</b><br><br>" ) );
223 wxString illegal_end( wxT(
"0123456789?" ) );
224 wxUniChar last_char = reference_base.Last();
226 if( illegal_end.Find( last_char ) != wxNOT_FOUND )
228 msg.Printf(
_(
"<b>Warning: reference prefix</b><br>prefix ending by '%s' can create"
229 " issues if saved in a symbol library" ),
231 msg += wxT(
"<br><br>" );
232 aMessages.push_back( msg );
246 const int min_grid_size =
schIUScale.MilsToIU( 25 );
247 const int clamped_grid_size = ( aGridForPins < min_grid_size ) ? min_grid_size : aGridForPins;
257 msg.Printf(
_(
"<b>A Power Symbol should have only one unit</b><br><br>" ) );
258 aMessages.push_back( msg );
261 if( pinList.size() != 1 )
263 msg.Printf(
_(
"<b>A Power Symbol should have only one pin</b><br><br>" ) );
264 aMessages.push_back( msg );
272 msg.Printf(
_(
"<b>Suspicious Power Symbol</b><br>"
273 "Only an input or output power pin has meaning<br><br>" ) );
274 aMessages.push_back( msg );
279 msg.Printf(
_(
"<b>Suspicious Power Symbol</b><br>"
280 "Invisible input power pins are no longer required<br><br>" ) );
281 aMessages.push_back( msg );
288 wxString pinName =
pin->GetName();
290 if( pinName.IsEmpty() || pinName ==
"~" )
293 pinName =
"'" + pinName +
"'";
297 && !
pin->IsVisible() )
304 msg.Printf(
_(
"Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
305 " in %s body style." ),
314 msg.Printf(
_(
"Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
315 " in unit %c of %s body style." ),
320 'A' +
pin->GetUnit() - 1,
328 msg.Printf(
_(
"Info: <b>Hidden power pin %s</b> %s at location <b>"
337 msg.Printf(
_(
"Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
343 'A' +
pin->GetUnit() - 1 );
347 msg += wxT(
"<br>" );
348 msg +=
_(
"(Hidden power pins will drive their pin names on to any connected nets.)" );
349 msg += wxT(
"<br><br>" );
350 aMessages.push_back( msg );
353 if( ( (
pin->GetPosition().x % clamped_grid_size) != 0 )
354 || ( (
pin->GetPosition().y % clamped_grid_size) != 0 ) )
363 msg.Printf(
_(
"<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
364 " of %s body style." ),
373 msg.Printf(
_(
"<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
374 " in unit %c of %s body style." ),
379 'A' +
pin->GetUnit() - 1,
387 msg.Printf(
_(
"<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>." ),
395 msg.Printf(
_(
"<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
401 'A' +
pin->GetUnit() - 1 );
405 msg += wxT(
"<br><br>" );
406 aMessages.push_back( msg );
437 msg.Printf(
_(
"<b>Graphic circle has radius = 0</b> at location "
438 "<b>(%s, %s)</b>." ),
441 msg += wxT(
"<br>" );
442 aMessages.push_back( msg );
449 msg.Printf(
_(
"<b>Graphic rectangle has size 0</b> at location <b>(%s, %s)</b>." ),
452 msg += wxT(
"<br>" );
453 aMessages.push_back( msg );
467 msg.Printf(
_(
"<b>Graphic ellipse has null or negative radii</b> at location "
468 "<b>(%s, %s)</b>." ),
471 msg += wxT(
"<br>" );
472 aMessages.push_back( msg );
478 msg.Printf(
_(
"<b>Graphic elliptical arc has zero sweep</b> at location "
479 "<b>(%s, %s)</b>." ),
482 msg += wxT(
"<br>" );
483 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.
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)