41#define PIN_TEXT_MARGIN 4
49 static const wxChar* msgPinElectricType[] =
53 wxT(
"bidirectional" ),
60 wxT(
"open_collector" ),
61 wxT(
"open_emitter" ),
65 return msgPinElectricType[
static_cast<int>( aType )];
126 int aNumTextSize,
int aConvert,
const VECTOR2I& aPos,
int aUnit ) :
130 m_orientation( aOrientation ),
134 m_numTextSize( aNumTextSize ),
135 m_nameTextSize( aNameTextSize )
177 if(
m_name == wxS(
"~" ) )
178 return wxEmptyString;
198 const TRANSFORM& aTransform,
bool aDimmed )
207 wxCHECK( part && opts, );
227 if( show_connect_point
254 int MapX1, MapY1, x1, y1;
256 int posX = aPos.
x, posY = aPos.
y, len =
m_length;
278 case PIN_UP: y1 = posY - len; MapY1 = 1;
break;
279 case PIN_DOWN: y1 = posY + len; MapY1 = -1;
break;
280 case PIN_LEFT: x1 = posX - len; MapX1 = 1;
break;
281 case PIN_RIGHT: x1 = posX + len; MapX1 = -1;
break;
289 GRMoveTo( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 );
308 GRLineTo( DC, x1 - MapX1 * clock_size * 2, y1, width,
color );
314 GRLineTo( DC, x1, y1 - MapY1 * clock_size * 2, width,
color );
327 GRMoveTo( x1 + MapX1 * deco_size * 2, y1 );
328 GRLineTo( DC, x1 + MapX1 * deco_size * 2, y1 - deco_size * 2, width,
color );
333 GRMoveTo( x1, y1 + MapY1 * deco_size * 2 );
334 GRLineTo( DC, x1 - deco_size * 2, y1 + MapY1 * deco_size * 2, width,
color );
345 GRLineTo( DC, x1 + MapX1 * deco_size * 2, y1, width,
color );
350 GRLineTo( DC, x1, y1 + MapY1 * deco_size * 2, width,
color );
356 GRMoveTo( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size );
357 GRLineTo( DC, x1 + (MapX1 + MapY1) * deco_size, y1 + ( MapY1 - MapX1 ) * deco_size, width,
359 GRMoveTo( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size );
360 GRLineTo( DC, x1 + (MapX1 - MapY1) * deco_size, y1 + ( MapY1 + MapX1 ) * deco_size, width,
367 GRLine( DC, posX - deco_size, posY - deco_size, posX + deco_size, posY + deco_size, width,
369 GRLine( DC, posX + deco_size, posY - deco_size, posX - deco_size, posY + deco_size, width,
376 int aTextInside,
bool aDrawPinNum,
bool aDrawPinName,
bool aDimmed )
378 if( !aDrawPinName && !aDrawPinNum )
411 nameColor = nameColor.
Mix( bg, 0.5f );
412 numColor = numColor.
Mix( bg, 0.5f );
430 aDrawPinName =
false;
444 x = x1 + aTextInside;
447 namePenWidth,
false,
false, font );
451 x = x1 - aTextInside;
454 namePenWidth,
false,
false, font );
470 y = y1 + aTextInside;
476 namePenWidth,
false,
false, font );
488 y = y1 - aTextInside;
494 namePenWidth,
false,
false, font );
513 x = ( x1 + aPinPos.
x) / 2;
516 namePenWidth,
false,
false, font );
520 x = ( x1 + aPinPos.
x) / 2;
523 numPenWidth,
false,
false, font );
530 y = ( y1 + aPinPos.
y) / 2;
533 namePenWidth,
false,
false, font );
549 int aOrientation,
bool aDimmed )
557 #define ETXT_MAX_SIZE schIUScale.mmToIU( 0.7 )
563 int pensize = textSize/6;
587 switch( aOrientation )
618 int MapX1, MapY1, x1, y1;
623 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->
GetColorMode() )
636 x1 = aPosition.
x; y1 = aPosition.
y;
638 switch( aOrientation )
649 aPlotter->
Circle(
VECTOR2I( MapX1 * radius + x1, MapY1 * radius + y1 ), radius * 2,
652 aPlotter->
MoveTo(
VECTOR2I( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ) );
671 aPlotter->
MoveTo(
VECTOR2I( MapX1 * deco_size * 2 + x1, MapY1 * deco_size * 2 + y1 ) );
707 aPlotter->
LineTo(
VECTOR2I( x1 + MapX1 * deco_size * 2, y1 - deco_size * 2 ) );
713 aPlotter->
LineTo(
VECTOR2I( x1 - deco_size * 2, y1 + MapY1 * deco_size * 2 ) );
737 y1 - ( MapY1 - MapX1 ) * deco_size ) );
739 y1 + ( MapY1 - MapX1 ) * deco_size ) );
741 y1 - ( MapY1 + MapX1 ) * deco_size ) );
743 y1 + ( MapY1 + MapX1 ) * deco_size ) );
749 const int ex1 = aPosition.
x;
750 const int ey1 = aPosition.
y;
759 int aTextInside,
bool aDrawPinNum,
bool aDrawPinName,
bool aDimmed )
const
767 aDrawPinName =
false;
772 if( !aDrawPinNum && !aDrawPinName )
788 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->
GetColorMode() )
795 nameColor = nameColor.
Mix( bg, 0.5f );
796 numColor = numColor.
Mix( bg, 0.5f );
836 x = x1 + aTextInside;
841 x = x1 - aTextInside;
851 plotText( ( x1 + aPinPos.
x) / 2, y1 - num_offset, numColor, number,
860 y = y1 + aTextInside;
870 plotText( x1 - num_offset, ( y1 + aPinPos.
y) / 2, numColor, number,
877 y = y1 - aTextInside;
887 plotText( x1 - num_offset, ( y1 + aPinPos.
y) / 2, numColor, number,
901 x = ( x1 + aPinPos.
x) / 2;
908 x = ( x1 + aPinPos.
x ) / 2;
917 y = ( y1 + aPinPos.
y ) / 2;
924 plotText( x1 + num_offset, ( y1 + aPinPos.
y ) / 2, numColor, number,
ANGLE_VERTICAL,
1006 return static_cast<int>(
m_shape ) -
static_cast<int>( tmp->
m_shape );
1009 return static_cast<int>(
m_type ) -
static_cast<int>( tmp->
m_type );
1028 const ALT& lhsAlt = lhsItem->second;
1029 const ALT& rhsAlt = rhsItem->second;
1037 return static_cast<int>( lhsAlt.
m_Type ) -
static_cast<int>( rhsAlt.
m_Type );
1040 return static_cast<int>( lhsAlt.
m_Shape ) -
static_cast<int>( rhsAlt.
m_Shape );
1051 int lengthChange =
m_length - aLength;
1058 offsetX = lengthChange;
1061 offsetX = -1 * lengthChange;
1064 offsetY = lengthChange;
1067 offsetY = -1 * lengthChange;
1149 const TRANSFORM& aTransform,
bool aDimmed )
const
1157 PlotSymbol( aPlotter, pos, orient, aDimmed );
1173 aList.emplace_back(
_(
"Style" ),
IsVisible() ?
_(
"Yes" ) :
_(
"No" ) );
1182 pinpos.
y = -pinpos.
y;
1208 bool aIncludeElectricalType )
const
1216 int pinNameOffset = 0;
1217 int nameTextLength = 0;
1218 int nameTextHeight = 0;
1219 int numberTextLength = 0;
1220 int numberTextHeight = 0;
1221 int typeTextLength = 0;
1224 bool includeName = aIncludeNameAndNumber && !
name.IsEmpty();
1225 bool includeNumber = aIncludeNameAndNumber && !number.IsEmpty();
1226 bool includeType = aIncludeElectricalType;
1230 if( !aIncludeInvisiblePins && !
IsVisible() )
1232 includeName =
false;
1233 includeType =
false;
1241 includeName =
false;
1244 includeNumber =
false;
1248 wxString
test = wxT(
"Xg" );
1253 numberTextLength = font->StringBoundaryLimits( number, fontSize, penWidth,
false,
false ).x;
1254 numberTextHeight = font->StringBoundaryLimits(
test, fontSize, penWidth,
false,
false ).y;
1261 nameTextLength = font->StringBoundaryLimits(
name, fontSize, penWidth,
false,
false ).x
1263 nameTextHeight = font->StringBoundaryLimits(
test, fontSize, penWidth,
false,
false ).y
1270 if( font->IsStroke() )
1272 numberTextHeight += 2 * penWidth;
1273 nameTextHeight += 2 * penWidth;
1279 double stroke = fontSize / 8.0;
1282 KiROUND( stroke ),
false,
false );
1285 minsizeV = std::max( minsizeV, typeTextSize.
y / 2 );
1297 if( pinNameOffset || !includeName )
1301 begin.
y = std::max( minsizeV, numberTextHeight + PIN_TEXT_OFFSET );
1302 begin.
x = std::min( -typeTextLength,
m_length - ( numberTextLength / 2) );
1305 end.
y = std::min( -minsizeV, -nameTextHeight / 2 );
1311 begin.
y = std::max( minsizeV, nameTextHeight + PIN_TEXT_OFFSET );
1312 begin.
x = std::min( -typeTextLength,
m_length - ( numberTextLength / 2) );
1314 end.
x = std::max(
m_length, nameTextLength );
1315 end.
y = std::min( -minsizeV, -numberTextHeight - PIN_TEXT_OFFSET );
1378 if ( !shownName.IsEmpty() )
1396 if( !shownName.IsEmpty() )
1417void LIB_PIN::Show(
int nestLevel, std::ostream& os )
const
1419 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str()
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
void SetOrigin(const Vec &pos)
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
bool Intersects(const BOX2< Vec > &aRect) const
bool Contains(const Vec &aPoint) const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
void SetEnd(coord_type x, coord_type y)
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
FONT is an abstract base class for both outline and stroke fonts.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
A color representation with 4 components: red, green, blue, alpha.
COLOR4D & Desaturate()
Removes color (in HSL model)
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
const wxString & GetDefaultFont() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
wxDC * GetPrintDC() const
Store schematic specific render settings.
The base class for drawable items used by schematic library symbols.
virtual int compare(const LIB_ITEM &aOther, int aCompareFlags=0) const
Provide the draw object specific comparison called by the == and < operators.
virtual int GetEffectivePenWidth(const RENDER_SETTINGS *aSettings) const
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
LIB_SYMBOL * GetParent() const
void SetConvert(int aConvert)
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
void MirrorHorizontal(const VECTOR2I &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
void Offset(const VECTOR2I &aOffset) override
Set the drawing object by aOffset from the current position.
void PlotPinTexts(PLOTTER *aPlotter, const VECTOR2I &aPinPos, int aPinOrient, int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed) const
Plot the pin number and pin text info, given the pin line coordinates.
const BOX2I GetBoundingBox() const override
void SetName(const wxString &aName)
void MirrorVertical(const VECTOR2I &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
int compare(const LIB_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
wxString GetShownNumber() const
LIB_PIN(LIB_SYMBOL *aParent)
int GetNumberTextSize() const
void printPinSymbol(const RENDER_SETTINGS *aSettings, const VECTOR2I &aPos, int aOrientation, bool aDimmed)
Print the pin symbol without text.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
wxString GetShownName() const
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
void ChangeLength(int aLength)
Change the length of a pin and adjust its position based on orientation.
wxString const GetCanonicalElectricalTypeName() const
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void MoveTo(const VECTOR2I &aNewPosition) override
Move a draw object to aPosition.
wxString GetClass() const override
Return the class name.
VECTOR2I GetPosition() const override
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
wxString const GetElectricalTypeName() const
std::map< wxString, ALT > m_alternates
void SetNumber(const wxString &aNumber)
void print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, void *aData, const TRANSFORM &aTransform, bool aDimmed) override
Print a pin, with or without the pin texts.
ELECTRICAL_PINTYPE m_type
void Plot(PLOTTER *aPlotter, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const override
Plot the draw item using the plot object.
int PinDrawOrient(const TRANSFORM &aTransform) const
Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT), according to its orientation...
int GetNameTextSize() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
VECTOR2I GetPinRoot() const
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
int GetPenWidth() const override
void printPinElectricalTypeName(const RENDER_SETTINGS *aSettings, VECTOR2I &aPosition, int aOrientation, bool aDimmed)
Draw the electrical type text of the pin (only for the footprint editor)
void PlotSymbol(PLOTTER *aPlotter, const VECTOR2I &aPosition, int aOrientation, bool aDimmed) const
void printPinTexts(const RENDER_SETTINGS *aSettings, VECTOR2I &aPinPos, int aPinOrient, int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed)
Put the pin number and pin text info, given the pin line coordinates.
Define a library symbol object.
int GetPinNameOffset() const
bool ShowPinNames() const
bool ShowPinNumbers() const
Container for data for KiCad programs.
virtual SETTINGS_MANAGER & GetSettingsManager() const
Base plotter engine class.
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
void MoveTo(const VECTOR2I &pos)
void FinishTo(const VECTOR2I &pos)
RENDER_SETTINGS * RenderSettings()
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, void *aData=nullptr)
bool GetColorMode() const
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
void LineTo(const VECTOR2I &pos)
virtual void SetColor(const COLOR4D &color)=0
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
#define DEFAULT_PINNUM_SIZE
The default pin name size when creating pins(can be changed in preference menu)
#define DEFAULT_PINNAME_SIZE
The default selection highlight thickness (can be changed in preference menu)
#define DEFAULT_PIN_LENGTH
The default pin number size when creating pins(can be changed in preference menu)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
static constexpr EDA_ANGLE & ANGLE_VERTICAL
static constexpr EDA_ANGLE & ANGLE_90
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define SHOW_ELEC_TYPE
Show pin electrical type. Shared with IS_ROLLOVER.
void GRLineTo(wxDC *DC, int x, int y, int width, const COLOR4D &Color)
void GRCircle(wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aColor)
void GRMoveTo(int x, int y)
void GRLine(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
bool GetGRForceBlackPenState(void)
void GRPrintText(wxDC *aDC, const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, KIFONT::FONT *aFont)
Print a graphic text through wxDC.
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aStrict)
Pen width should not allow characters to become cluttered up in their own fatness.
@ LAYER_SELECTION_SHADOWS
static int externalPinDecoSize(const RENDER_SETTINGS *aSettings, const LIB_PIN &aPin)
Utility for getting the size of the 'external' pin decorators (as a radius)
static int internalPinDecoSize(const RENDER_SETTINGS *aSettings, const LIB_PIN &aPin)
Utility for getting the size of the 'internal' pin decorators (as a radius)
#define TARGET_PIN_RADIUS
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
wxString PinOrientationName(unsigned aPinOrientationCode)
int PinOrientationIndex(int code)
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE aType)
BITMAPS ElectricalPinTypeGetBitmap(ELECTRICAL_PINTYPE aType)
wxString PinShapeGetText(GRAPHIC_PINSHAPE aShape)
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
@ PT_NC
not connected (must be left open)
@ PT_NIC
not internally connected (may be connected to anything)
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
wxString UnescapeString(const wxString &aSource)
constexpr int MilsToIU(int mils) const
constexpr int mmToIU(double mm) const
ELECTRICAL_PINTYPE m_Type
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
VECTOR2< double > VECTOR2D