38 #define PIN_TEXT_MARGIN 4 46 static const wxChar* msgPinElectricType[] =
50 wxT(
"bidirectional" ),
57 wxT(
"open_collector" ),
58 wxT(
"open_emitter" ),
62 return msgPinElectricType[static_cast<int>( aType )];
108 m_length = Mils2iu( settings->m_Defaults.pin_length );
109 m_numTextSize = Mils2iu( settings->m_Defaults.pin_num_size );
123 int aNumTextSize,
int aConvert,
const wxPoint& aPos,
int aUnit ) :
127 m_orientation( aOrientation ),
131 m_numTextSize( aNumTextSize ),
132 m_nameTextSize( aNameTextSize )
174 if(
m_name == wxT(
"~" ) )
175 return wxEmptyString;
220 if( show_connect_point
235 int MapX1, MapY1, x1, y1;
237 int posX = aPos.x, posY = aPos.y, len =
m_length;
246 case PIN_UP: y1 = posY - len; MapY1 = 1;
break;
247 case PIN_DOWN: y1 = posY + len; MapY1 = -1;
break;
248 case PIN_LEFT: x1 = posX - len; MapX1 = 1;
break;
249 case PIN_RIGHT: x1 = posX + len; MapX1 = -1;
break;
255 GRCircle(
nullptr, DC, MapX1 * radius + x1, MapY1 * radius + y1, radius, width,
color );
257 GRMoveTo( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 );
276 GRLineTo(
nullptr, DC, x1 - MapX1 * clock_size * 2, y1, width,
color );
282 GRLineTo(
nullptr, DC, x1, y1 - MapY1 * clock_size * 2, width,
color );
295 GRMoveTo( x1 + MapX1 * deco_size * 2, y1 );
296 GRLineTo(
nullptr, DC, x1 + MapX1 * deco_size * 2, y1 - deco_size * 2, width,
color );
301 GRMoveTo( x1, y1 + MapY1 * deco_size * 2 );
302 GRLineTo(
nullptr, DC, x1 - deco_size * 2, y1 + MapY1 * deco_size * 2, width,
color );
313 GRLineTo(
nullptr, DC, x1 + MapX1 * deco_size * 2, y1, width,
color );
318 GRLineTo(
nullptr, DC, x1, y1 + MapY1 * deco_size * 2, width,
color );
324 GRMoveTo( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size );
325 GRLineTo(
nullptr, DC, x1 + (MapX1 + MapY1) * deco_size,
326 y1 + ( MapY1 - MapX1 ) * deco_size, width,
color );
327 GRMoveTo( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size );
328 GRLineTo(
nullptr, DC, x1 + (MapX1 - MapY1) * deco_size,
329 y1 + ( MapY1 + MapX1 ) * deco_size, width,
color );
335 GRLine(
nullptr, DC, posX - deco_size, posY - deco_size, posX + deco_size,
336 posY + deco_size, width,
color );
337 GRLine(
nullptr, DC, posX + deco_size, posY - deco_size, posX - deco_size,
338 posY + deco_size, width,
color );
344 int aTextInside,
bool aDrawPinNum,
bool aDrawPinName )
346 if( !aDrawPinName && !aDrawPinNum )
381 aDrawPinName =
false;
383 if( number.IsEmpty() )
395 x = x1 + aTextInside;
402 x = x1 - aTextInside;
411 GRText( DC, wxPoint(( x1 + aPinPos.x) / 2, y1 - num_offset ), NumColor, number,
421 y = y1 + aTextInside;
432 GRText( DC, wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor,
439 y = y1 - aTextInside;
450 GRText( DC, wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor,
464 x = ( x1 + aPinPos.x) / 2;
467 namePenWidth,
false,
false );
471 x = ( x1 + aPinPos.x) / 2;
481 y = ( y1 + aPinPos.y) / 2;
484 namePenWidth,
false,
false );
489 GRText( DC, wxPoint( x1 + num_offset, ( y1 + aPinPos.y) / 2 ), NumColor, number,
491 numPenWidth,
false,
false );
508 #define ETXT_MAX_SIZE Millimeter2iu( 0.7 ) 514 int pensize = textSize/6;
519 wxPoint txtpos = aPosition;
524 switch( aOrientation )
547 GRText( DC, txtpos,
color, typeName, orient, wxSize( textSize, textSize ), hjustify,
554 int MapX1, MapY1, x1, y1;
562 x1 = aPosition.x; y1 = aPosition.y;
564 switch( aOrientation )
575 aPlotter->
Circle( wxPoint( MapX1 * radius + x1, MapY1 * radius + y1 ), radius * 2,
578 aPlotter->
MoveTo( wxPoint( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ) );
586 aPlotter->
MoveTo( wxPoint( x1, y1 + deco_size ) );
587 aPlotter->
LineTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 ) );
588 aPlotter->
FinishTo( wxPoint( x1, y1 - deco_size ) );
592 aPlotter->
MoveTo( wxPoint( x1 + deco_size, y1 ) );
593 aPlotter->
LineTo( wxPoint( x1, y1 + MapY1 * deco_size * 2 ) );
594 aPlotter->
FinishTo( wxPoint( x1 - deco_size, y1 ) );
597 aPlotter->
MoveTo( wxPoint( MapX1 * deco_size * 2 + x1, MapY1 * deco_size * 2 + y1 ) );
602 aPlotter->
MoveTo( wxPoint( x1, y1 ) );
613 aPlotter->
MoveTo( wxPoint( x1, y1 + deco_size ) );
614 aPlotter->
LineTo( wxPoint( x1 - MapX1 * deco_size * 2, y1 ) );
615 aPlotter->
FinishTo( wxPoint( x1, y1 - deco_size ) );
619 aPlotter->
MoveTo( wxPoint( x1 + deco_size, y1 ) );
620 aPlotter->
LineTo( wxPoint( x1, y1 - MapY1 * deco_size * 2 ) );
621 aPlotter->
FinishTo( wxPoint( x1 - deco_size, y1 ) );
632 aPlotter->
MoveTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 ) );
633 aPlotter->
LineTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 - deco_size * 2 ) );
634 aPlotter->
FinishTo( wxPoint( x1, y1 ) );
638 aPlotter->
MoveTo( wxPoint( x1, y1 + MapY1 * deco_size * 2 ) );
639 aPlotter->
LineTo( wxPoint( x1 - deco_size * 2, y1 + MapY1 * deco_size * 2 ) );
640 aPlotter->
FinishTo( wxPoint( x1, y1 ) );
650 aPlotter->
MoveTo( wxPoint( x1, y1 - symbol_size * 2 ) );
651 aPlotter->
FinishTo( wxPoint( x1 + MapX1 * symbol_size * 2, y1 ) );
655 aPlotter->
MoveTo( wxPoint( x1 - symbol_size * 2, y1 ) );
656 aPlotter->
FinishTo( wxPoint( x1, y1 + MapY1 * symbol_size * 2 ) );
662 aPlotter->
MoveTo( wxPoint( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size ) );
663 aPlotter->
FinishTo( wxPoint( x1 + (MapX1 + MapY1) * deco_size, y1 + (MapY1 - MapX1) * deco_size ) );
664 aPlotter->
MoveTo( wxPoint( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size ) );
665 aPlotter->
FinishTo( wxPoint( x1 + (MapX1 - MapY1) * deco_size, y1 + (MapY1 + MapX1) * deco_size ) );
671 const int ex1 = aPosition.x;
672 const int ey1 = aPosition.y;
673 aPlotter->
MoveTo( wxPoint( ex1 - deco_size, ey1 - deco_size ) );
674 aPlotter->
FinishTo( wxPoint( ex1 + deco_size, ey1 + deco_size ) );
675 aPlotter->
MoveTo( wxPoint( ex1 + deco_size, ey1 - deco_size ) );
676 aPlotter->
FinishTo( wxPoint( ex1 - deco_size, ey1 + deco_size ) );
682 bool aDrawPinNum,
bool aDrawPinName )
const 688 aDrawPinName =
false;
690 if( number.IsEmpty() )
693 if( !aDrawPinNum && !aDrawPinName )
733 x = x1 + aTextInside;
738 x = x1 - aTextInside;
748 aPlotter->
Text( wxPoint( ( x1 + aPinPos.x) / 2, y1 - num_offset ), numColor,
757 y = y1 + aTextInside;
762 namePenWidth,
false,
false );
766 aPlotter->
Text( wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor,
773 y = y1 - aTextInside;
779 namePenWidth,
false,
false );
784 aPlotter->
Text( wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor,
798 x = ( x1 + aPinPos.x) / 2;
799 aPlotter->
Text( wxPoint( x, y1 - name_offset ), nameColor,
name,
806 x = ( x1 + aPinPos.x ) / 2;
807 aPlotter->
Text( wxPoint( x, y1 + num_offset ), numColor, number,
816 y = ( y1 + aPinPos.y ) / 2;
817 aPlotter->
Text( wxPoint( x1 - name_offset, y ), nameColor,
name,
824 aPlotter->
Text( wxPoint( x1 + num_offset, ( y1 + aPinPos.y ) / 2 ), numColor,
840 case PIN_UP: end.y = 1;
break;
907 return static_cast<int>(
m_shape ) - static_cast<int>( tmp->
m_shape );
910 return static_cast<int>(
m_type ) - static_cast<int>( tmp->
m_type );
929 const ALT& lhsAlt = lhsItem->second;
930 const ALT& rhsAlt = rhsItem->second;
938 return static_cast<int>( lhsAlt.
m_Type ) - static_cast<int>( rhsAlt.
m_Type );
941 return static_cast<int>( lhsAlt.
m_Shape ) - static_cast<int>( rhsAlt.
m_Shape );
995 int rot_angle = aRotateCCW ? -900 : 900;
1048 aList.emplace_back(
_(
"Style" ),
IsVisible() ?
_(
"Yes" ) :
_(
"No" ) );
1057 pinpos.y = -pinpos.y;
1080 int nameTextOffset = 0;
1083 bool showName = !
name.IsEmpty();
1084 bool showNum = !number.IsEmpty();
1087 if( !aIncludeInvisibles && !
IsVisible() )
1108 int numberTextLength = showNum ?
m_numTextSize * number.Len() : 0;
1118 begin.y = std::max( minsizeV, numberTextHeight + Mils2iu(
PIN_TEXT_MARGIN ) );
1119 begin.x = std::min( 0,
m_length - (numberTextLength / 2) );
1122 int nameTextLength = 0;
1123 int nameTextHeight = 0;
1127 int length =
name.Len();
1136 if( nameTextOffset )
1139 end.y = std::min( -minsizeV, -nameTextHeight / 2 );
1145 end.x = std::max(
m_length, nameTextLength );
1147 begin.y = std::max( minsizeV, nameTextHeight );
1221 void LIB_PIN::Show(
int nestLevel, std::ostream& os )
const 1223 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str()
int compare(const LIB_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
void FinishTo(const wxPoint &pos)
wxString GetClass() const override
Return the class name.
virtual SETTINGS_MANAGER & GetSettingsManager() const
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
int GetPinNameOffset() const
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
wxString GetShownNumber() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
void Plot(PLOTTER *aPlotter, const wxPoint &aPffset, bool aFill, const TRANSFORM &aTransform) const override
Plot the draw item using the plot object.
void PlotPinTexts(PLOTTER *aPlotter, const wxPoint &aPinPos, int aPinOrient, int aTextInside, bool aDrawPinNum, bool aDrawPinName) const
Plot the pin number and pin text info, given the pin line coordinates.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void MoveTo(const wxPoint &aNewPosition) override
Move a draw object to aPosition.
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Container for data for KiCad programs.
void printPinTexts(const RENDER_SETTINGS *aSettings, wxPoint &aPinPos, int aPinOrient, int aTextInside, bool aDrawPinNum, bool aDrawPinName)
Put the pin number and pin text info, given the pin line coordinates.
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE aType)
LIB_PIN(LIB_SYMBOL *aParent)
void PlotSymbol(PLOTTER *aPlotter, const wxPoint &aPosition, int aOrientation) const
BITMAPS ElectricalPinTypeGetBitmap(ELECTRICAL_PINTYPE aType)
bool ShowPinNumbers() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
unknown electrical properties: creates always a warning when connected
void SetOrigin(const wxPoint &pos)
int PinOrientationIndex(int code)
virtual int GetEffectivePenWidth(const RENDER_SETTINGS *aSettings) const
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void GRText(wxDC *aDC, const wxPoint &aPos, const COLOR4D &aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Draw a graphic text (like footprint texts).
#define DEFAULT_PIN_LENGTH
The default pin number size when creating pins(can be changed in preference menu)
wxString PinShapeGetText(GRAPHIC_PINSHAPE aShape)
void RotatePoint(int *pX, int *pY, double angle)
const EDA_RECT GetBoundingBox() const override
The base class for create windows for drawing purpose.
int PinDrawOrient(const TRANSFORM &aTransform) const
Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT), according to its orientation...
Define a library symbol object.
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
ELECTRICAL_PINTYPE m_Type
bool Contains(const wxPoint &aPoint) const
The base class for drawable items used by schematic library symbols.
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
void SetNumber(const wxString &aNumber)
wxPoint GetPinRoot() const
wxString PinOrientationName(unsigned aPinOrientationCode)
not internally connected (may be connected to anything)
void LineTo(const wxPoint &pos)
virtual int compare(const LIB_ITEM &aOther, int aCompareFlags=0) const
Provide the draw object specific comparison called by the == and < operators.
void printPinSymbol(const RENDER_SETTINGS *aSettings, const wxPoint &aPos, int aOrientation)
Print the pin symbol without text.
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Don't allow text to become cluttered up in its own fatness.
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
wxString const GetElectricalTypeName() const
void SetEnd(int x, int y)
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, const COLOR4D &Color)
Draw a circle onto the drawing context aDC centered at the user coordinates (x,y).
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
bool ShowPinNames() const
#define STRUCT_DELETED
flag indication structures to be erased
int GetPenWidth() const override
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
wxDC * GetPrintDC() const
#define DEFAULT_PINNUM_SIZE
The default pin name size when creating pins(can be changed in preference menu)
int GetNameTextSize() const
wxString GetShownName() const
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
#define DEFAULT_PINNAME_SIZE
The default selection highlight thickness (can be changed in preference menu)
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.
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 UnescapeString(const wxString &aSource)
void CalcEdit(const wxPoint &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, const COLOR4D &Color)
virtual void SetColor(const COLOR4D &color)=0
void SetConvert(int aConvert)
wxPoint GetPosition() const override
void MoveTo(const wxPoint &pos)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void GRMoveTo(int x, int y)
void Normalize()
Ensures that the height ant width are positive.
LIB_SYMBOL * GetParent() const
Base plotter engine class.
std::map< wxString, ALT > m_alternates
RENDER_SETTINGS * RenderSettings()
int GetNumberTextSize() const
TRANSFORM DefaultTransform
void SetName(const wxString &aName)
#define SKIP_STRUCT
flag indicating that the structure should be ignored
BITMAPS
A list of all bitmap identifiers.
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
static int internalPinDecoSize(const RENDER_SETTINGS *aSettings, const LIB_PIN &aPin)
Utility for getting the size of the 'internal' pin decorators (as a radius)
void printPinElectricalTypeName(const RENDER_SETTINGS *aSettings, wxPoint &aPosition, int aOrientation)
Draw the electrical type text of the pin (only for the footprint editor)
static int externalPinDecoSize(const RENDER_SETTINGS *aSettings, const LIB_PIN &aPin)
Utility for getting the size of the 'external' pin decorators (as a radius)
Handle the component boundary box.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
#define TARGET_PIN_RADIUS
A base class for most all the KiCad significant classes used in schematics and boards.
ELECTRICAL_PINTYPE m_type
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Store schematic specific render settings.
int GetDefaultPenWidth() const
virtual void Text(const wxPoint &aPos, const COLOR4D &aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=nullptr)
Draw text with the plotter.
wxString const GetCanonicalElectricalTypeName() const
not connected (must be left open)
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
static constexpr int Millimeter2iu(double mm)
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
void print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print a pin, with or without the pin texts.
KICAD_T Type() const
Returns the type of object.
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
A color representation with 4 components: red, green, blue, alpha.