46#include <magic_enum.hpp>
48#include <api/schematic/schematic_types.pb.h>
58 wxString outputFormat;
59 wxString outputNumber;
60 int ii =
name.Len() - 1;
63 while( ii >= 0 && !wxIsdigit(
name.GetChar( ii ) ) )
65 suffix =
name.GetChar( ii ) + suffix;
69 while( ii >= 0 && wxIsdigit(
name.GetChar( ii ) ) )
71 digits =
name.GetChar( ii ) + digits;
76 if( digits.IsEmpty() )
81 if( digits.ToLong( &number ) )
89 name.Remove( ii + 1 );
91 outputFormat.Printf( wxS(
"%%0%dld" ), dCount );
93 outputNumber.Printf( outputFormat, number );
94 name << outputNumber << suffix;
108static int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
109static int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
110static int TemplateIN_UP[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
111static int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
113static int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
114static int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
115static int TemplateOUT_UP[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
116static int TemplateOUT_BOTTOM[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
118static int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
119static int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
120static int TemplateUNSPC_UP[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
121static int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
123static int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
124static int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
125static int TemplateBIDI_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
126static int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
128static int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
129static int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
130static int Template3STATE_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
131static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
152 default:
return wxT(
"???" );
209 m_isDangling( true ),
222 m_shape( aLabel.m_shape ),
223 m_connectionType( aLabel.m_connectionType ),
224 m_isDangling( aLabel.m_isDangling ),
225 m_lastResolvedColor( aLabel.m_lastResolvedColor ),
226 m_cached_driver_name( aLabel.m_cached_driver_name )
233 field.SetParent(
this );
249 if( aName == wxT(
"Intersheetrefs" ) )
250 return _(
"Sheet References" );
251 else if( aName == wxT(
"Netclass" ) )
252 return _(
"Net Class" );
253 else if( aName.IsEmpty() && aUseDefaultName )
265 for(
KICAD_T scanType : aScanTypes )
271 wxCHECK_MSG(
Schematic(),
false, wxT(
"No parent SCHEMATIC set for SCH_LABEL!" ) );
280 for(
KICAD_T scanType : aScanTypes )
284 for(
SCH_ITEM* connection : item_set )
286 if( connection->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_PIN_T } ) )
293 for(
SCH_ITEM* connection : item_set )
295 if( connection->IsType( { SCH_ITEM_LOCATE_BUS_T } ) )
315 field.SetParent(
this );
345 wxFAIL_MSG(
"Bad spin style" );
424 field.Offset( aMoveVector );
439 field.SetTextPos( field.GetTextPos() + offset );
455 if( field.GetTextAngle().IsVertical()
463 else if( field.GetTextAngle().IsVertical()
471 else if( field.GetTextAngle().IsHorizontal()
479 else if( field.GetTextAngle().IsHorizontal()
490 field.SetTextPos( pos );
502 if( ( aLeftRight && field.GetTextAngle().IsHorizontal() )
503 || ( !aLeftRight && field.GetTextAngle().IsVertical() ) )
519 field.SetTextPos( pos );
532 field.FlipHJustify();
538 field.SetPosition( pos );
551 field.FlipHJustify();
557 field.SetPosition( pos );
592 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
614 if(
typeid( *
this ) !=
typeid( aOther ) )
623 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
633 similarity *= std::pow( 0.9, diff );
659 if( field.GetCanonicalName() == wxT(
"Intersheetrefs" ) )
660 offset.
x = - ( labelLen + margin );
662 offset.
y = accumulated + field.GetTextHeight() / 2;
670 if( field.GetCanonicalName() == wxT(
"Intersheetrefs" ) )
671 offset.
y = - ( labelLen + margin );
673 offset.
x = accumulated + field.GetTextHeight() / 2;
681 if( field.GetCanonicalName() == wxT(
"Intersheetrefs" ) )
682 offset.
x = labelLen + margin;
684 offset.
y = accumulated + field.GetTextHeight() / 2;
692 if( field.GetCanonicalName() == wxT(
"Intersheetrefs" ) )
693 offset.
y = labelLen + margin;
695 offset.
x = accumulated + field.GetTextHeight() / 2;
702 if( field.GetCanonicalName() != wxT(
"Intersheetrefs" ) )
703 accumulated += field.GetTextHeight() + margin;
711 std::vector<std::pair<wxString, wxString>>* pages )
720 if( it !=
Schematic()->GetPageRefsMap().end() )
722 std::vector<int> pageListCopy;
724 pageListCopy.insert( pageListCopy.end(), it->second.begin(), it->second.end() );
726 if( !
Schematic()->Settings().m_IntersheetRefsListOwnPage )
731 if( pageListCopy.empty() )
735 std::sort( pageListCopy.begin(), pageListCopy.end() );
740 for(
int pageNum : pageListCopy )
741 pages->push_back( { sheetPages[ pageNum ], sheetNames[ pageNum ] } );
750 aVars->push_back( field.GetCanonicalName().Upper() );
752 aVars->push_back( wxT(
"OP" ) );
753 aVars->push_back( wxT(
"CONNECTION_TYPE" ) );
754 aVars->push_back( wxT(
"SHORT_NET_NAME" ) );
755 aVars->push_back( wxT(
"NET_NAME" ) );
756 aVars->push_back( wxT(
"NET_CLASS" ) );
763 static wxRegEx operatingPoint( wxT(
"^"
765 "(.([0-9])?([a-zA-Z]*))?"
768 wxCHECK( aPath,
false );
775 if( operatingPoint.Matches( *token ) )
778 wxString precisionStr( operatingPoint.GetMatch( *token, 2 ) );
779 wxString range( operatingPoint.GetMatch( *token, 3 ) );
781 if( !precisionStr.IsEmpty() )
782 precision = precisionStr[0] -
'0';
784 if( range.IsEmpty() )
796 if( token->Contains(
':' ) )
803 && token->IsSameAs( wxT(
"CONNECTION_TYPE" ) ) )
809 else if( token->IsSameAs( wxT(
"SHORT_NET_NAME" ) ) )
812 *token = wxEmptyString;
819 else if( token->IsSameAs( wxT(
"NET_NAME" ) ) )
822 *token = wxEmptyString;
825 *token = connection->
Name();
829 else if( token->IsSameAs( wxT(
"NET_CLASS" ) ) )
832 *token = wxEmptyString;
842 if( token->IsSameAs( field.GetName() ) )
844 *token = field.GetShownText(
false, aDepth + 1 );
856 path.push_back( sheet );
895 std::function<bool( wxString* )> textResolver =
896 [&]( wxString* token ) ->
bool
903 if(
text == wxS(
"~" ) )
941 const std::vector<KICAD_T>& aScanTypes )
943 if(
IsType( aScanTypes ) )
945 if( INSPECT_RESULT::QUIT == aInspector(
this,
nullptr ) )
946 return INSPECT_RESULT::QUIT;
949 for(
KICAD_T scanType : aScanTypes )
955 if( INSPECT_RESULT::QUIT == aInspector( &field,
this ) )
956 return INSPECT_RESULT::QUIT;
961 return INSPECT_RESULT::CONTINUE;
968 aItemList.push_back( item );
1009 std::vector<VECTOR2I> pts;
1030 if( field.IsVisible() )
1032 BOX2I fieldBBox = field.GetBoundingBox();
1037 box.
Merge( fieldBBox );
1057 if( field.IsVisible() )
1059 BOX2I fieldBBox = field.GetBoundingBox();
1060 fieldBBox.
Inflate( aAccuracy );
1065 if( fieldBBox.
Contains( aPosition ) )
1091 if( field.IsVisible() )
1093 BOX2I fieldBBox = field.GetBoundingBox();
1109 std::vector<DANGLING_END_ITEM>& aItemListByPos,
1118 it < aItemListByPos.end() && it->GetPosition() == text_pos; it++ )
1150 it < aItemListByType.end() && it->GetType() ==
BUS_END; it++ )
1171 sch_item->AddConnectionTo( *aPath,
this );
1179 it < aItemListByType.end() && it->GetType() ==
WIRE_END; it++ )
1200 sch_item->AddConnectionTo( *aPath,
this );
1224 wxCHECK( label,
false );
1232 std::vector<wxString> netclasses;
1233 std::vector<wxString> otherNetclasses;
1237 if( field.GetCanonicalName() == wxT(
"Netclass" ) )
1238 netclasses.push_back( field.GetText() );
1244 otherNetclasses.push_back( field.
GetText() );
1247 return netclasses != otherNetclasses;
1272 aList.emplace_back(
_(
"Font" ),
GetFont() ?
GetFont()->GetName() :
_(
"Default" ) );
1274 wxString textStyle[] = {
_(
"Normal" ),
_(
"Italic" ),
_(
"Bold" ),
_(
"Bold Italic" ) };
1276 aList.emplace_back(
_(
"Style" ), textStyle[style] );
1286 default: msg = wxT(
"???" );
break;
1289 aList.emplace_back(
_(
"Justification" ), msg );
1300 if( !conn->
IsBus() )
1302 aList.emplace_back(
_(
"Resolved Netclass" ),
1310 int aUnit,
int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
1312 static std::vector<VECTOR2I> s_poly;
1348 if(
GetShape() == LABEL_FLAG_SHAPE::F_DOT )
1350 aPlotter->
MoveTo( s_poly[0] );
1351 aPlotter->
LineTo( s_poly[1] );
1354 int diameter = ( s_poly[2] - s_poly[1] ).
EuclideanNorm() * 2;
1357 else if(
GetShape() == LABEL_FLAG_SHAPE::F_ROUND )
1359 aPlotter->
MoveTo( s_poly[0] );
1360 aPlotter->
LineTo( s_poly[1] );
1363 int diameter = ( s_poly[2] - s_poly[1] ).
EuclideanNorm() * 2;
1368 if( !s_poly.empty() )
1369 aPlotter->
PlotPoly( s_poly, FILL_T::NO_FILL, penWidth );
1375 std::vector<wxString> properties;
1379 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ),
_(
"Net" ),
1380 connection->
Name() ) );
1382 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ),
1383 _(
"Resolved netclass" ),
1389 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ), field.GetName(),
1390 field.GetShownText(
false ) ) );
1393 if( !properties.empty() )
1400 _(
"Hierarchical Labels" ) );
1405 field.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1410 const VECTOR2I& aOffset,
bool aForceNoFill,
bool aDimmed )
1412 static std::vector<VECTOR2I> s_poly;
1422 if( !blackAndWhiteMode &&
GetTextColor() != COLOR4D::UNSPECIFIED )
1429 if(
GetShape() == LABEL_FLAG_SHAPE::F_DOT )
1431 GRLine( DC, s_poly[0], s_poly[1], penWidth,
color );
1436 else if(
GetShape() == LABEL_FLAG_SHAPE::F_ROUND )
1438 GRLine( DC, s_poly[0], s_poly[1], penWidth,
color );
1445 if( !s_poly.empty() )
1450 field.Print( aSettings, aUnit, aBodyStyle, aOffset, aForceNoFill, aDimmed );
1470 m_shape = LABEL_FLAG_SHAPE::L_INPUT;
1477 kiapi::schematic::types::LocalLabel label;
1482 aContainer.PackFrom( label );
1488 kiapi::schematic::types::LocalLabel label;
1490 if( !aContainer.UnpackTo( &label ) )
1531 return wxString::Format(
_(
"Label '%s'" ),
1538 return BITMAPS::add_line_label;
1546 m_shape = LABEL_FLAG_SHAPE::F_ROUND;
1605 if( ( aLeftRight && field.GetTextAngle().IsHorizontal() )
1606 || ( !aLeftRight && field.GetTextAngle().IsVertical() ) )
1622 field.SetTextPos( pos );
1649 field.SetPosition( pos );
1671 field.SetPosition( pos );
1677 std::vector<VECTOR2I>& aPoints,
1686 case LABEL_FLAG_SHAPE::F_DOT:
1687 symbolSize =
KiROUND( symbolSize * 0.7 );
1690 case LABEL_FLAG_SHAPE::F_ROUND:
1692 aPoints.emplace_back(
VECTOR2I( 0, 0 ) );
1702 case LABEL_FLAG_SHAPE::F_DIAMOND:
1703 aPoints.emplace_back(
VECTOR2I( 0, 0 ) );
1709 aPoints.emplace_back(
VECTOR2I( 0, 0 ) );
1712 case LABEL_FLAG_SHAPE::F_RECTANGLE:
1713 symbolSize =
KiROUND( symbolSize * 0.8 );
1715 aPoints.emplace_back(
VECTOR2I( 0, 0 ) );
1722 aPoints.emplace_back(
VECTOR2I( 0, 0 ) );
1752 if(
m_shape == LABEL_FLAG_SHAPE::F_DIAMOND ||
m_shape == LABEL_FLAG_SHAPE::F_RECTANGLE )
1756 margin =
KiROUND( margin * 1.5 );
1767 offset = { symbolWidth + margin, origin };
1772 offset = { -origin, -( symbolWidth + margin ) };
1777 offset = { symbolWidth + margin, -origin };
1782 offset = { origin, -( symbolWidth + margin ) };
1789 origin -= field.GetTextHeight() + margin;
1800 return _(
"Directive Label" );
1804 return wxString::Format(
_(
"Directive Label [%s %s]" ),
1839 m_shape = LABEL_FLAG_SHAPE::L_BIDI;
1845 m_fields[0].SetText( wxT(
"${INTERSHEET_REFS}" ) );
1880 case LABEL_FLAG_SHAPE::L_INPUT:
1881 case LABEL_FLAG_SHAPE::L_BIDI:
1882 case LABEL_FLAG_SHAPE::L_TRISTATE:
1886 case LABEL_FLAG_SHAPE::L_OUTPUT:
1887 case LABEL_FLAG_SHAPE::L_UNSPECIFIED:
1913 wxCHECK( aPath,
false );
1920 if( token->IsSameAs( wxT(
"INTERSHEET_REFS" ) ) )
1932 std::vector<int> pageListCopy;
1934 pageListCopy.insert( pageListCopy.end(), it->second.begin(), it->second.end() );
1935 std::sort( pageListCopy.begin(), pageListCopy.end() );
1947 ref.Append( wxString::Format( wxT(
"%s..%s" ),
1948 sheetPages[pageListCopy.front()],
1949 sheetPages[pageListCopy.back()] ) );
1953 for(
const int& pageNo : pageListCopy )
1954 ref.Append( wxString::Format( wxT(
"%s," ), sheetPages[pageNo] ) );
1956 if( !ref.IsEmpty() && ref.Last() ==
',' )
1982 std::vector<VECTOR2I>& aPoints,
1990 int x = symb_len + linewidth + 3;
1991 int y = halfSize + linewidth + 3;
1996 aPoints.emplace_back(
VECTOR2I( 0, 0 ) );
1997 aPoints.emplace_back(
VECTOR2I( 0, -y ) );
1998 aPoints.emplace_back(
VECTOR2I( -x, -y ) );
1999 aPoints.emplace_back(
VECTOR2I( -x, 0 ) );
2000 aPoints.emplace_back(
VECTOR2I( -x, y ) );
2001 aPoints.emplace_back(
VECTOR2I( 0, y ) );
2007 case LABEL_FLAG_SHAPE::L_INPUT:
2008 x_offset = -halfSize;
2009 aPoints[0].x += halfSize;
2012 case LABEL_FLAG_SHAPE::L_OUTPUT:
2013 aPoints[3].x -= halfSize;
2016 case LABEL_FLAG_SHAPE::L_BIDI:
2017 case LABEL_FLAG_SHAPE::L_TRISTATE:
2018 x_offset = -halfSize;
2019 aPoints[0].x += halfSize;
2020 aPoints[3].x -= halfSize;
2023 case LABEL_FLAG_SHAPE::L_UNSPECIFIED:
2031 aPoint.x += x_offset;
2045 aPoints.push_back( aPoints[0] );
2051 return wxString::Format(
_(
"Global Label '%s'" ),
2058 return BITMAPS::add_glabel;
2066 m_shape = LABEL_FLAG_SHAPE::L_INPUT;
2092 std::vector<VECTOR2I>& aPoints,
const VECTOR2I& aPos )
const
2099 std::vector<VECTOR2I>& aPoints,
const VECTOR2I& aPos,
2104 int imax = *Template;
2109 for(
int ii = 0; ii < imax; ii++ )
2112 corner.
x = ( halfSize * (*Template) ) + aPos.
x;
2115 corner.
y = ( halfSize * (*Template) ) + aPos.
y;
2118 aPoints.push_back( corner );
2198 return wxString::Format(
_(
"Hierarchical Label '%s'" ),
2205 return BITMAPS::add_hierarchical_label;
2216 wxSize sz( 320, 320 );
2218 dlg->SetMinSize( dlg->ConvertDialogToPixels( sz ) );
2236 if( labelShapeEnum.Choices().GetCount() == 0 )
2238 labelShapeEnum.Map( LABEL_SHAPE::LABEL_INPUT,
_HKI(
"Input" ) )
2239 .Map( LABEL_SHAPE::LABEL_OUTPUT,
_HKI(
"Output" ) )
2240 .Map( LABEL_SHAPE::LABEL_BIDI,
_HKI(
"Bidirectional" ) )
2241 .Map( LABEL_SHAPE::LABEL_TRISTATE,
_HKI(
"Tri-state" ) )
2242 .Map( LABEL_SHAPE::LABEL_PASSIVE,
_HKI(
"Passive" ) );
2267 auto hasLabelShape =
2278 .SetAvailableFunc( hasLabelShape );
2291 if( flagShapeEnum.Choices().GetCount() == 0 )
2293 flagShapeEnum.Map( FLAG_SHAPE::FLAG_DOT,
_HKI(
"Dot" ) )
2294 .Map( FLAG_SHAPE::FLAG_CIRCLE,
_HKI(
"Circle" ) )
2295 .Map( FLAG_SHAPE::FLAG_DIAMOND,
_HKI(
"Diamond" ) )
2296 .Map( FLAG_SHAPE::FLAG_RECTANGLE,
_HKI(
"Rectangle" ) );
2312 PROPERTY_DISPLAY::PT_SIZE ) );
2319 _HKI(
"Horizontal Justification" ) );
2321 _HKI(
"Vertical Justification" ) );
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.
const Vec & GetOrigin() const
void Offset(coord_type dx, coord_type dy)
bool Intersects(const BOX2< Vec > &aRect) const
size_type GetWidth() 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)
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
static std::vector< DANGLING_END_ITEM >::iterator get_lower_type(std::vector< DANGLING_END_ITEM > &aItemListByType, const DANGLING_END_T &aType)
static std::vector< DANGLING_END_ITEM >::iterator get_lower_pos(std::vector< DANGLING_END_ITEM > &aItemListByPos, const VECTOR2I &aPos)
Helper class used to store the state of schematic items that can be connected to other schematic item...
DANGLING_END_T GetType() const
EDA_ITEM * GetItem() const
VECTOR2I GetPosition() const
The base class for create windows for drawing purpose.
KICAD_T Type() const
Returns the type of object.
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM * m_parent
Linked list: Link (parent struct)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
int GetTextHeight() const
const VECTOR2I & GetTextPos() const
COLOR4D GetTextColor() const
const EDA_ANGLE & GetTextAngle() const
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetTextPos(const VECTOR2I &aPoint)
KIFONT::FONT * GetFont() const
BOX2I GetTextBox(int aLine=-1) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
GR_TEXT_H_ALIGN_T GetHorizJustify() const
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
virtual void cacheShownText()
const TEXT_ATTRIBUTES & GetAttributes() const
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, const COLOR4D &aColor, OUTLINE_MODE aDisplay_mode=FILLED)
Print this text object to the device context aDC.
void SetMultilineAllowed(bool aAllow)
VECTOR2I GetTextSize() const
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
static ENUM_MAP< T > & Instance()
void SetDialogSizeInDU(int aWidth, int aHeight)
Set the dialog size, using a "logical" value.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
void ShowModeless()
Show a modeless version of the dialog (without an OK button).
Class that other classes need to inherit from, in order to be inspectable.
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.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
int GetMinPenWidth() const
const wxString & GetDefaultFont() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
std::string AsStdString() const
Base plotter engine class.
virtual void ThickCircle(const VECTOR2I &pos, int diametre, int width, OUTLINE_MODE tracemode, void *aData)
virtual void FilledCircle(const VECTOR2I &pos, int diametre, OUTLINE_MODE tracemode, void *aData)
void MoveTo(const VECTOR2I &pos)
RENDER_SETTINGS * RenderSettings()
virtual void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString)
Create a bookmark to a symbol.
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 PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr)
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
These settings were stored in SCH_BASE_FRAME previously.
wxString m_IntersheetRefsPrefix
wxString m_IntersheetRefsSuffix
bool m_IntersheetRefsFormatShort
bool m_IntersheetRefsListOwnPage
Holds all the data relating to one schematic.
SCH_SHEET_PATH & CurrentSheet() const override
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
SCHEMATIC_SETTINGS & Settings() const
std::map< wxString, std::set< int > > & GetPageRefsMap()
std::map< int, wxString > GetVirtualPageToSheetPagesMap() const
std::map< int, wxString > GetVirtualPageToSheetNamesMap() const
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString LocalName() const
wxString Name(bool aIgnoreSheet=false) const
void AppendInfoToMsgPanel(std::vector< MSG_PANEL_ITEM > &aList) const
Adds information about the connection object to aList.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void MirrorSpinStyle(bool aLeftRight) override
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void RemoveConnectedRuleArea(SCH_RULE_AREA *aRuleArea)
Removes a specific rule area from the cache.
void ClearConnectedRuleAreas()
Removes all rule areas from the cache.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
SCH_DIRECTIVE_LABEL(const VECTOR2I &aPos=VECTOR2I(0, 0))
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
FLAG_SHAPE GetFlagShape() const
int GetPenWidth() const override
std::unordered_set< SCH_RULE_AREA * > m_connected_rule_areas
Cache of any rule areas with borders which this label connects to.
void SetPinLength(int aLength)
virtual bool IsDangling() const override
Determines dangling state from connectivity and cached connected rule areas.
void AddConnectedRuleArea(SCH_RULE_AREA *aRuleArea)
Adds an entry to the connected rule area cache.
void SetFlagShape(FLAG_SHAPE aShape)
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Schematic editor (Eeschema) main window.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
void CreateGraphicShape(const RENDER_SETTINGS *aRenderSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth) const override
Resolve any references to system tokens supported by the label.
VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const override
This offset depends on the orientation, the type of text, and the area required to draw the associate...
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
SCH_GLOBALLABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString)
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
const BOX2I GetBodyBoundingBox() const override
Return the bounding box of the label only, without taking in account its fields.
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
SCH_HIERLABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString, KICAD_T aType=SCH_HIER_LABEL_T)
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const override
This offset depends on the orientation, the type of text, and the area required to draw the associate...
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual bool IsConnectable() const
SCH_ITEM & operator=(const SCH_ITEM &aPin)
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
void AddConnectionTo(const SCH_SHEET_PATH &aPath, SCH_ITEM *aItem)
Add a connection link between this item and another.
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
void ClearFieldsAutoplaced()
FIELDS_AUTOPLACED m_fieldsAutoplaced
bool IsConnectivityDirty() const
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
const KIFONT::METRICS & GetFontMetrics() const
std::map< SCH_SHEET_PATH, SCH_ITEM_VEC, SHEET_PATH_CMP > m_connected_items
Store pointers to other items that are connected to this one, per sheet.
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
bool operator==(const SCH_ITEM &aItem) const override
const wxString & GetCachedDriverName() const override
SCH_LABEL_BASE(const VECTOR2I &aPos, const wxString &aText, KICAD_T aType)
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
COLOR4D m_lastResolvedColor
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const override
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &offset, bool aForceNoFill, bool aDimmed) override
Print an item.
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
bool HasCachedDriverName() const override
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
SCH_LABEL_BASE & operator=(const SCH_LABEL_BASE &aLabel)
std::vector< SCH_FIELD > m_fields
CONNECTION_TYPE m_connectionType
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
void SetLabelShape(LABEL_SHAPE aShape)
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
SPIN_STYLE GetSpinStyle() const
void GetIntersheetRefs(const SCH_SHEET_PATH *aPath, std::vector< std::pair< wxString, wxString > > *pages)
Builds an array of { pageNumber, pageName } pairs.
void MirrorSpinStyle(bool aLeftRight) override
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
COLOR4D GetLabelColor() const
LABEL_FLAG_SHAPE GetShape() const
const BOX2I GetBoundingBox() const override
Return the bounding box of the label including its fields.
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void SetPosition(const VECTOR2I &aPosition) override
virtual bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth) const
Resolve any references to system tokens supported by the label.
LABEL_SHAPE GetLabelShape() const
bool m_autoRotateOnPlacement
wxString m_cached_driver_name
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
int GetLabelBoxExpansion(const RENDER_SETTINGS *aSettings=nullptr) const
bool IncrementLabel(int aIncrement)
Increment the label text, if it ends with a number.
void SetAutoRotateOnPlacement(bool autoRotate=true)
setAutoRotateOnPlacement
void cacheShownText() override
void Rotate90(bool aClockwise) override
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this label.
virtual const BOX2I GetBodyBoundingBox() const
Return the bounding box of the label only, without taking in account its fields.
virtual void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &Pos) const
Calculate the graphic shape (a polygon) associated to the text.
std::vector< SCH_FIELD > & GetFields()
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const override
This offset depends on the orientation, the type of text, and the area required to draw the associate...
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
double Similarity(const SCH_ITEM &aItem) const override
Return a measure of how likely the other object is to represent the same object.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
SCH_LABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString)
const BOX2I GetBodyBoundingBox() const override
Return the bounding box of the label only, without taking in account its fields.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
int GetVirtualPageNumber() const
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
VECTOR2I GetPosition() const override
virtual void Rotate90(bool aClockwise)
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
double Similarity(const SCH_ITEM &aItem) const override
Return a measure of how likely the other object is to represent the same object.
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
int GetPenWidth() const override
virtual void MirrorSpinStyle(bool aLeftRight)
bool operator==(const SCH_ITEM &aItem) const override
int GetTextOffset(const RENDER_SETTINGS *aSettings=nullptr) const
SPIN_STYLE MirrorX()
Mirror the label spin style across the X axis or simply swaps up and bottom.
SPIN_STYLE MirrorY()
Mirror the label spin style across the Y axis or simply swaps left and right.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
#define DEFAULT_LABEL_SIZE_RATIO
The offset of the pin name string from the end of the pin in mils.
#define DANGLING_SYMBOL_SIZE
< The size of the rectangle indicating an unconnected wire or label
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
static constexpr EDA_ANGLE ANGLE_270
static constexpr EDA_ANGLE ANGLE_180
const INSPECTOR_FUNC & INSPECTOR
void GRCircle(wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aColor)
void GRLine(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
void GRPoly(wxDC *DC, int n, const VECTOR2I *Points, bool Fill, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Draw a new polyline and fill it if Fill, in drawing space.
bool GetGRForceBlackPenState(void)
void GRFilledCircle(wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aStrokeColor, const COLOR4D &aFillColor)
Draw a circle onto the drawing context aDC centered at the user coordinates (x,y).
@ LAYER_SELECTION_SHADOWS
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
T MIRRORVAL(T aPoint, T aMirrorRef)
Returns the mirror of aPoint relative to the aMirrorRef.
Message panel definition file.
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
void delete_matching(_Container &__c, _Value __value)
Covers for the horrifically named std::remove and std::remove_if (neither of which remove anything).
void PackVector2(kiapi::common::types::Vector2 &aOutput, const VECTOR2I aInput)
VECTOR2I UnpackVector2(const types::Vector2 &aInput)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
std::vector< SCH_ITEM * > SCH_ITEM_VEC
static int TemplateIN_HI[]
static int TemplateUNSPC_HI[]
static int TemplateOUT_HN[]
static int Template3STATE_HN[]
static int TemplateBIDI_HN[]
static int * TemplateShape[5][4]
bool IncrementLabelMember(wxString &name, int aIncrement)
static int TemplateIN_HN[]
static int TemplateIN_BOTTOM[]
static int TemplateUNSPC_HN[]
static int Template3STATE_BOTTOM[]
static int TemplateBIDI_BOTTOM[]
static struct SCH_LABEL_DESC _SCH_LABEL_DESC
static int Template3STATE_UP[]
static int TemplateOUT_UP[]
static int TemplateOUT_HI[]
static int TemplateUNSPC_UP[]
static int TemplateUNSPC_BOTTOM[]
static int TemplateOUT_BOTTOM[]
static int Template3STATE_HI[]
static int TemplateIN_UP[]
wxString getElectricalTypeLabel(LABEL_FLAG_SHAPE aType)
static int TemplateBIDI_UP[]
static int TemplateBIDI_HI[]
static struct SCH_DIRECTIVE_LABEL_DESC _SCH_DIRECTIVE_LABEL_DESC
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
constexpr int MilsToIU(int mils) const
SCH_DIRECTIVE_LABEL_DESC()
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
double EuclideanNorm(const VECTOR2I &vector)
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ SCH_LABEL_LOCATE_WIRE_T
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".