104 m_IsSymbolEditor( false ),
106 m_ShowBodyStyle( 0 ),
107 m_ShowPinsElectricalType( true ),
108 m_ShowHiddenLibPins( true ),
109 m_ShowHiddenLibFields( true ),
110 m_ShowPinNumbers( false ),
111 m_ShowDisabled( false ),
112 m_ShowGraphicsDisabled( false ),
113 m_OverrideItemColors( false ),
183 text->SetText( wxString( wxT(
"??" ) ) );
195 m_schematic( nullptr )
205 draw( item, aLayer,
false );
213#ifdef CONNECTIVITY_DEBUG
215 auto sch_item =
dynamic_cast<const SCH_ITEM*
>( aItem );
216 auto conn = sch_item ? sch_item->
Connection( *g_CurrentSheet ) :
nullptr;
221 auto label = conn->Name(
true );
228 m_gal->StrokeText( conn->Name(
true ), pos, 0.0, 0 );
236 switch( aItem->
Type() )
242 draw(
static_cast<const LIB_SHAPE*
>( aItem ), aLayer, aDimmed );
245 drawBoundingBox =
false;
246 draw(
static_cast<const LIB_PIN*
>( aItem ), aLayer, aDimmed );
249 drawBoundingBox =
false;
250 draw(
static_cast<const LIB_FIELD*
>( aItem ), aLayer, aDimmed );
253 draw(
static_cast<const LIB_TEXT*
>( aItem ), aLayer, aDimmed );
286 draw(
static_cast<const SCH_FIELD*
>( aItem ), aLayer, aDimmed );
319 if( drawBoundingBox )
329 box =
static_cast<const SCH_SYMBOL*
>( aItem )->GetBodyBoundingBox();
334 :
COLOR4D( 0.2, 0.2, 0.2, 1 ) );
398 color =
static_cast<const SCH_LINE*
>( aItem )->GetLineColor();
468 else if(
const EDA_TEXT* otherTextItem =
dynamic_cast<const EDA_TEXT*
>( aItem ) )
470 color = otherTextItem->GetTextColor();
475 color = m_schSettings.GetLayerColor( aLayer );
477 if( aItem->IsBrightened() )
481 if( aDrawingShadows )
483 if( aItem->IsSelected() )
493 else if( aItem->IsSelected() && aDrawingShadows )
495 if( aDrawingShadows )
498 else if( aItem->IsSelected()
506 if( m_schSettings.m_ShowDisabled
507 || ( m_schSettings.m_ShowGraphicsDisabled && aItem->Type() !=
LIB_FIELD_T ) )
512 if( aDimmed && !( aItem->IsSelected() && aDrawingShadows ) )
519 if( aItem->GetForcedTransparency() > 0.0 )
520 color =
color.WithAlpha(
color.a * ( 1.0 - aItem->GetForcedTransparency() ) );
526float SCH_PAINTER::getLineWidth(
const EDA_ITEM* aItem,
bool aDrawingShadows )
const
532 if(
dynamic_cast<const LIB_ITEM*
>( aItem ) )
533 pen =
static_cast<const LIB_ITEM*
>( aItem )->GetEffectivePenWidth( &m_schSettings );
534 else if(
dynamic_cast<const SCH_ITEM*
>( aItem ) )
543 if( aDrawingShadows && aItem->
IsType( g_ScaledSelectionTypes ) )
551float SCH_PAINTER::getTextThickness(
const EDA_ITEM* aItem )
const
553 int pen = m_schSettings.GetDefaultPenWidth();
555 switch( aItem->
Type() )
558 pen =
static_cast<const SCH_FIELD*
>( aItem )->GetEffectiveTextPenWidth( pen );
562 pen =
static_cast<const SCH_TEXT*
>( aItem )->GetEffectiveTextPenWidth( pen );
570 pen =
static_cast<const SCH_LABEL_BASE*
>( aItem )->GetEffectiveTextPenWidth( pen );
575 pen =
static_cast<const SCH_TEXTBOX*
>( aItem )->GetEffectiveTextPenWidth( pen );
579 pen = std::max( pen,
static_cast<const LIB_FIELD*
>( aItem )->GetEffectiveTextPenWidth() );
583 pen = std::max( pen,
static_cast<const LIB_TEXT*
>( aItem )->GetEffectiveTextPenWidth() );
587 pen = std::max( pen,
static_cast<const LIB_TEXTBOX*
>( aItem )->GetEffectiveTextPenWidth() );
598int SCH_PAINTER::getOperatingPointTextSize()
const
601 int screenTextSize =
std::abs( (
int) m_gal->GetScreenWorldMatrix().GetScale().y * 7 );
604 return KiROUND( ( docTextSize + screenTextSize * 2 ) / 3 );
627void SCH_PAINTER::strokeText(
const wxString& aText,
const VECTOR2D& aPosition,
639 m_gal->SetIsStroke( font->
IsStroke() );
641 font->
Draw( m_gal, aText, aPosition, aAttrs, aFontMetrics );
645void SCH_PAINTER::bitmapText(
const wxString& aText,
const VECTOR2D& aPosition,
653 m_gal->SetHorizontalJustify( aAttrs.
m_Halign );
654 m_gal->SetVerticalJustify( aAttrs.
m_Valign );
656 m_gal->BitmapText( aText, aPosition, aAttrs.
m_Angle );
660void SCH_PAINTER::knockoutText(
const wxString& aText,
const VECTOR2D& aPosition,
683 callback_gal.SetIsStroke(
true );
685 font->
Draw( &callback_gal, aText, aPosition, attrs, aFontMetrics );
699 m_gal->SetIsStroke(
false );
700 m_gal->SetIsFill(
true );
701 m_gal->SetFillColor( attrs.
m_Color );
702 m_gal->DrawPolygon( finalPoly );
706void SCH_PAINTER::boxText(
const wxString& aText,
const VECTOR2D& aPosition,
744 m_gal->SetIsFill(
true );
745 m_gal->SetIsStroke(
false );
752 m_gal->DrawLine( a, b );
753 m_gal->DrawLine( b, c );
757void SCH_PAINTER::draw(
const LIB_SYMBOL* aSymbol,
int aLayer,
bool aDrawFields,
int aUnit,
758 int aBodyStyle,
bool aDimmed )
761 aUnit = m_schSettings.m_ShowUnit;
764 aBodyStyle = m_schSettings.m_ShowBodyStyle;
766 std::unique_ptr< LIB_SYMBOL > tmpSymbol;
771 tmpSymbol = aSymbol->
Flatten();
772 drawnSymbol = tmpSymbol.get();
778 [](
const LIB_ITEM& item,
int layer )
780 int layers[512], layers_count;
783 for(
int ii = 0; ii < layers_count; ++ii )
785 if( layers[ii] == layer )
797 if( !childOnLayer( item, aLayer ) )
806 draw( &item, aLayer, aDimmed );
811bool SCH_PAINTER::setDeviceColors(
const LIB_ITEM* aItem,
int aLayer,
bool aDimmed )
821 m_gal->SetIsFill(
false );
822 m_gal->SetIsStroke(
true );
823 m_gal->SetLineWidth( getLineWidth( aItem,
true ) );
824 m_gal->SetStrokeColor( getRenderColor( aItem,
LAYER_DEVICE,
true, aDimmed ) );
825 m_gal->SetFillColor( getRenderColor( aItem,
LAYER_DEVICE,
true, aDimmed ) );
841 m_gal->SetIsFill(
true );
843 m_gal->SetIsStroke(
false );
857 m_gal->SetFillColor( getRenderColor( aItem,
LAYER_DEVICE,
false, aDimmed ) );
864 if( transparency > 0.0 )
865 fillColour = fillColour.
WithAlpha( fillColour.
a * ( 1.0 - transparency ) );
867 if( m_schSettings.m_OverrideItemColors )
873 fillColour = fillColour.
Mix( bg, 0.5f );
877 m_gal->SetFillColor( fillColour );
882 m_gal->SetIsStroke(
true );
883 m_gal->SetLineWidth( getLineWidth( aItem,
false ) );
884 m_gal->SetStrokeColor( getRenderColor( aItem, aLayer,
false, aDimmed ) );
888 m_gal->SetIsStroke(
false );
899void SCH_PAINTER::draw(
const LIB_SHAPE* aShape,
int aLayer,
bool aDimmed )
901 if( !isUnitAndConversionShown( aShape ) )
904 if( aShape->
IsPrivate() && !m_schSettings.m_IsSymbolEditor )
907 if( !setDeviceColors( aShape, aLayer, aDimmed ) )
912 COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows, aDimmed );
917 switch( shape->GetShape() )
930 EDA_ANGLE angle1 = midAngle - startAngle;
935 m_gal->DrawArc( center, ( start - center ).
EuclideanNorm(), startAngle, angle );
940 m_gal->DrawCircle(
mapCoords( shape->GetPosition() ), shape->GetRadius() );
944 m_gal->DrawRectangle(
mapCoords( shape->GetPosition() ),
951 std::deque<VECTOR2D> mappedPts;
956 m_gal->DrawPolygon( mappedPts );
975 if(
eeconfig()->m_Selection.fill_shapes )
980 m_gal->SetIsFill( aShape->
IsFilled() );
982 m_gal->SetIsFill(
true );
986 m_gal->SetIsStroke(
true );
987 m_gal->SetIsFill(
false );
988 m_gal->SetLineWidth( getLineWidth( aShape,
true ) );
989 m_gal->SetStrokeColor(
color );
999 && !m_schSettings.PrintBlackAndWhiteReq() )
1001 m_gal->SetIsFill(
true );
1002 m_gal->SetIsStroke(
false );
1003 drawShape( aShape );
1008 float lineWidth = getLineWidth( aShape, drawingShadows );
1012 m_gal->SetIsFill(
false );
1013 m_gal->SetIsStroke(
true );
1014 m_gal->SetLineWidth( lineWidth );
1015 m_gal->SetStrokeColor(
color );
1019 drawShape( aShape );
1025 for(
SHAPE* shape : shapes )
1038 for(
SHAPE* shape : shapes )
1046 m_gal->SetIsFill(
true );
1047 m_gal->SetIsStroke(
false );
1048 drawShape( aShape );
1054void SCH_PAINTER::draw(
const LIB_FIELD* aField,
int aLayer,
bool aDimmed )
1061 if( !isUnitAndConversionShown( aField ) )
1068 bool foundLayer =
false;
1072 for(
int i = 0; i < layers_count; ++i )
1074 if( layers[i] == aLayer )
1081 COLOR4D color = getRenderColor( aField, aLayer, drawingShadows, aDimmed );
1086 : m_schSettings.m_ShowHiddenLibFields;
1094 m_gal->SetStrokeColor(
color );
1095 m_gal->SetFillColor(
color );
1099 if( drawingShadows && getFont( aField )->IsOutline() )
1103 m_gal->SetIsStroke(
false );
1104 m_gal->SetIsFill(
true );
1116 if( drawingShadows )
1124 if( aField->
IsMoving() && m_schematic )
1126 m_gal->SetLineWidth( m_schSettings.m_outlineWidth );
1131 if( m_schSettings.GetDrawBoundingBoxes() )
1132 drawItemBoundingBox( aField );
1136void SCH_PAINTER::draw(
const LIB_TEXT* aText,
int aLayer,
bool aDimmed )
1138 if( !isUnitAndConversionShown( aText ) )
1141 if( aText->
IsPrivate() && !m_schSettings.m_IsSymbolEditor )
1149 COLOR4D color = getRenderColor( aText, aLayer, drawingShadows, aDimmed );
1153 if( !m_schematic ||
eeconfig()->m_Appearance.show_hidden_fields )
1161 m_gal->SetFillColor(
color );
1162 m_gal->SetStrokeColor(
color );
1164 if( drawingShadows && getFont( aText )->IsOutline() )
1168 m_gal->SetIsStroke(
false );
1169 m_gal->SetIsFill(
true );
1185 double shadowOffset = 0.0;
1187 if( drawingShadows )
1189 double shadowWidth = getShadowWidth( !aText->
IsSelected() );
1192 const double adjust = 1.2f;
1193 shadowOffset = shadowWidth/2.0f * adjust;
1207 pos.
y = bBox.
GetTop() - shadowOffset;
1210 wxFAIL_MSG( wxT(
"Indeterminate state legal only in dialogs." ) );
1219 pos.
x = bBox.
GetLeft() - shadowOffset;
1228 wxFAIL_MSG( wxT(
"Indeterminate state legal only in dialogs." ) );
1242void SCH_PAINTER::draw(
const LIB_TEXTBOX* aTextBox,
int aLayer,
bool aDimmed )
1244 if( !isUnitAndConversionShown( aTextBox ) )
1247 if( aTextBox->
IsPrivate() && !m_schSettings.m_IsSymbolEditor )
1256 COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows, aDimmed );
1257 float borderWidth = getLineWidth( aTextBox, drawingShadows );
1271 m_gal->SetStrokeColor(
color );
1272 m_gal->SetFillColor(
color );
1276 m_gal->SetIsFill(
true );
1277 m_gal->SetIsStroke(
false );
1278 m_gal->SetLineWidth( borderWidth );
1287 m_gal->SetIsFill(
true );
1288 m_gal->SetIsStroke(
false );
1289 m_gal->SetLineWidth( borderWidth );
1299 if( borderWidth > 0 )
1305 if( m_schSettings.m_OverrideItemColors || aTextBox->
IsBrightened()
1308 borderColor = m_schSettings.GetLayerColor( aLayer );
1311 if( transparency > 0.0 )
1312 borderColor = borderColor.
WithAlpha( borderColor.
a * ( 1.0 - transparency ) );
1316 borderColor = borderColor.
Mix( bg, 0.5f );
1320 m_gal->SetIsFill(
false );
1321 m_gal->SetIsStroke(
true );
1322 m_gal->SetStrokeColor( borderColor );
1323 m_gal->SetLineWidth( borderWidth );
1334 for(
SHAPE* shape : shapes )
1348 for(
SHAPE* shape : shapes )
1356int SCH_PAINTER::internalPinDecoSize(
const LIB_PIN &aPin )
1358 if( m_schSettings.m_PinSymbolSize > 0 )
1359 return m_schSettings.m_PinSymbolSize;
1367int SCH_PAINTER::externalPinDecoSize(
const LIB_PIN &aPin )
1369 if( m_schSettings.m_PinSymbolSize > 0 )
1370 return m_schSettings.m_PinSymbolSize;
1378 bool aDrawingShadows,
bool aBrightened )
1382 m_gal->SetStrokeColor( aColor.
Brightened( 0.3 ) );
1384 m_gal->SetIsFill(
false );
1385 m_gal->SetIsStroke(
true );
1386 m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth( aBrightened )
1387 : m_schSettings.GetDanglingIndicatorThickness() );
1393void SCH_PAINTER::draw(
const LIB_PIN* aPin,
int aLayer,
bool aDimmed )
1395 if( !isUnitAndConversionShown( aPin ) )
1400 if( m_schSettings.IsPrinting() && drawingShadows )
1415 if( m_schSettings.IsPrinting() )
1419 : m_schSettings.m_ShowHiddenLibPins;
1426 if( drawingDangling && isDangling && aPin->
IsGlobalPower() )
1433 if( drawingDangling )
1441 if( m_schSettings.GetDrawBoundingBoxes() )
1442 drawItemBoundingBox( aPin );
1475 int textSize = getOperatingPointTextSize();
1477 int textOffset =
KiROUND( textSize * 0.22 );
1480 if( len > textSize )
1484 mid.
x +=
KiROUND( textOffset * 1.2 );
1489 mid.
y -=
KiROUND( textOffset * 1.2 );
1510 m_gal->SetIsStroke(
true );
1511 m_gal->SetIsFill(
false );
1512 m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
1513 m_gal->SetStrokeColor(
color );
1514 m_gal->SetFontBold(
false );
1515 m_gal->SetFontUnderlined(
false );
1516 m_gal->SetFontItalic(
false );
1519 const int diam = radius*2;
1524 m_gal->DrawLine( p0, pos );
1536 m_gal->DrawLine( p0, pos );
1540 m_gal->DrawCircle( p0 + dir * radius, radius );
1541 m_gal->DrawLine( p0 + dir * ( diam ), pos );
1545 pc = p0 - dir * clock_size ;
1547 triLine( p0 +
VECTOR2D( dir.
y, -dir.
x) * clock_size,
1549 p0 +
VECTOR2D( -dir.
y, dir.
x) * clock_size );
1551 m_gal->DrawCircle( p0 + dir * radius, radius );
1552 m_gal->DrawLine( p0 + dir * ( diam ), pos );
1557 pc = p0 - dir * clock_size ;
1559 triLine( p0 +
VECTOR2D( dir.
y, -dir.
x) * clock_size,
1561 p0 +
VECTOR2D( -dir.
y, dir.
x) * clock_size );
1565 triLine( p0 +
VECTOR2D(dir.
x, 0) * diam,
1571 triLine( p0 +
VECTOR2D( 0, dir.
y) * diam,
1576 m_gal->DrawLine( p0, pos );
1580 m_gal->DrawLine( p0, pos );
1584 triLine( p0 +
VECTOR2D( 0, clock_size ),
1585 p0 +
VECTOR2D( -dir.
x * clock_size, 0 ),
1590 triLine( p0 +
VECTOR2D( clock_size, 0 ),
1591 p0 +
VECTOR2D( 0, -dir.
y * clock_size ),
1597 m_gal->DrawLine( p0, pos );
1601 triLine( p0 +
VECTOR2D(dir.
x, 0) * diam,
1607 triLine( p0 +
VECTOR2D( 0, dir.
y) * diam,
1614 m_gal->DrawLine( p0, pos );
1623 m_gal->DrawLine( p0, pos );
1625 m_gal->DrawLine( p0 -
VECTOR2D( dir.
x + dir.
y, dir.
y - dir.
x ) * radius,
1626 p0 +
VECTOR2D( dir.
x + dir.
y, dir.
y - dir.
x ) * radius );
1627 m_gal->DrawLine( p0 -
VECTOR2D( dir.
x - dir.
y, dir.
x + dir.
y ) * radius,
1628 p0 +
VECTOR2D( dir.
x - dir.
y, dir.
x + dir.
y ) * radius );
1639 if( drawingShadows && !
eeconfig()->m_Selection.draw_selected_children )
1643 float penWidth = (float) m_schSettings.GetDefaultPenWidth();
1645 float nameStrokeWidth = getLineWidth( aPin,
false );
1646 float numStrokeWidth = getLineWidth( aPin,
false );
1648 bool showPinNumbers = m_schSettings.m_ShowPinNumbers || libEntry->
ShowPinNumbers();
1656 enum { INSIDE = 0,
OUTSIDE, ABOVE, BELOW };
1657 int size[4] = { 0, 0, 0, 0 };
1658 float thickness[4] = { numStrokeWidth, numStrokeWidth, numStrokeWidth, numStrokeWidth };
1666 thickness[INSIDE] = nameStrokeWidth;
1667 colour [INSIDE] = getRenderColor( aPin,
LAYER_PINNAM, drawingShadows, aDimmed );
1671 thickness[ABOVE] = numStrokeWidth;
1672 colour [ABOVE] = getRenderColor( aPin,
LAYER_PINNUM, drawingShadows, aDimmed );
1676 else if( showPinNames && showPinNumbers )
1679 thickness[ABOVE] = nameStrokeWidth;
1680 colour [ABOVE] = getRenderColor( aPin,
LAYER_PINNAM, drawingShadows, aDimmed );
1684 thickness[BELOW] = numStrokeWidth;
1685 colour [BELOW] = getRenderColor( aPin,
LAYER_PINNUM, drawingShadows, aDimmed );
1688 else if( showPinNames )
1691 thickness[ABOVE] = nameStrokeWidth;
1692 colour [ABOVE] = getRenderColor( aPin,
LAYER_PINNAM, drawingShadows, aDimmed );
1695 else if( showPinNumbers )
1698 thickness[ABOVE] = numStrokeWidth;
1699 colour [ABOVE] = getRenderColor( aPin,
LAYER_PINNUM, drawingShadows, aDimmed );
1703 if( m_schSettings.m_ShowPinsElectricalType )
1715 #define BITMAP_FONT_SIZE_THRESHOLD 3.5
1725 c = getRenderColor( aPin,
LAYER_HIDDEN, drawingShadows, aDimmed );
1728 float insideOffset = (float) textOffset - thickness[INSIDE] / 2.0f;
1730 float aboveOffset =
PIN_TEXT_MARGIN + penWidth / 2.0f + thickness[ABOVE] / 2.0f;
1731 float belowOffset =
PIN_TEXT_MARGIN + penWidth / 2.0f + thickness[BELOW] / 2.0f;
1736 if( drawingShadows )
1738 float shadowWidth = getShadowWidth( aPin->
IsBrightened() );
1740 for(
float& t : thickness )
1750 const float adjust = 1.2f;
1751 float shadowOffset = shadowWidth/2.0f * adjust;
1752 insideOffset -= shadowOffset;
1753 outsideOffset -= shadowOffset;
1761 if(
text[i].IsEmpty() )
1765 m_gal->SetStrokeColor( colour[i] );
1766 m_gal->SetFillColor( colour[i] );
1780 else if( drawingShadows )
1784 else if( nonCached( aPin ) && renderTextAsBitmap )
1786 bitmapText(
text[i], aPos, attrs );
1801 drawText( INSIDE, pos +
VECTOR2D( -insideOffset - (
float) len, 0 ),
1811 drawText( ABOVE, pos +
VECTOR2D( -len / 2.0, -aboveOffset ),
1816 drawText( BELOW, pos +
VECTOR2D( -len / 2.0, belowOffset ),
1824 drawText( INSIDE, pos +
VECTOR2D( insideOffset + (
float) len, 0 ),
1834 drawText( ABOVE, pos +
VECTOR2D( len / 2.0, -aboveOffset ),
1839 drawText( BELOW, pos +
VECTOR2D( len / 2.0, belowOffset ),
1847 drawText( INSIDE, pos +
VECTOR2D( 0, insideOffset + (
float) len ),
1857 drawText( ABOVE, pos +
VECTOR2D( -aboveOffset, len / 2.0 ),
1862 drawText( BELOW, pos +
VECTOR2D( belowOffset, len / 2.0 ),
1870 drawText( INSIDE, pos +
VECTOR2D( 0, -insideOffset - (
float) len ),
1880 drawText( ABOVE, pos +
VECTOR2D( -aboveOffset, -len / 2.0 ),
1885 drawText( BELOW, pos +
VECTOR2D( belowOffset, -len / 2.0 ),
1891 wxFAIL_MSG(
"Unknown pin orientation" );
1898void SCH_PAINTER::drawDanglingIndicator(
const VECTOR2I& aPos,
const COLOR4D& aColor,
int aWidth,
1899 bool aDangling,
bool aDrawingShadows,
bool aBrightened )
1901 if( m_schSettings.IsPrinting() )
1914 m_gal->SetStrokeColor( aColor.
Brightened( 0.3 ) );
1915 m_gal->SetIsStroke(
true );
1916 m_gal->SetIsFill(
false );
1917 m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth( aBrightened )
1918 : m_schSettings.GetDanglingIndicatorThickness() );
1920 m_gal->DrawRectangle( aPos - radius, aPos + radius );
1928 if( m_schSettings.IsPrinting() && drawingShadows )
1938 if( junctionSize > 1 )
1940 m_gal->SetIsStroke( drawingShadows );
1941 m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1942 m_gal->SetStrokeColor(
color );
1943 m_gal->SetIsFill( !drawingShadows );
1944 m_gal->SetFillColor(
color );
1945 m_gal->DrawCircle( aJct->
GetPosition(), junctionSize );
1950void SCH_PAINTER::draw(
const SCH_LINE* aLine,
int aLayer )
1954 if( m_schSettings.IsPrinting() && drawingShadows )
1965 if( aLine->
IsNew() && drawingDangling )
1969 float width = getLineWidth( aLine, drawingShadows );
1972 if( ( drawingDangling || drawingShadows ) && !aLine->
IsNew() )
1979 drawDanglingIndicator( aLine->
GetStartPoint(), danglingColor,
1980 KiROUND( getLineWidth( aLine, drawingShadows ) ),
1990 drawDanglingIndicator( aLine->
GetEndPoint(), danglingColor,
1991 KiROUND( getLineWidth( aLine, drawingShadows ) ),
1997 if( drawingDangling )
2002 int textSize = getOperatingPointTextSize();
2004 int textOffset =
KiROUND( textSize * 0.22 );
2009 pos.
y -= textOffset;
2015 pos.
x +=
KiROUND( textOffset * 1.2 );
2031 m_gal->SetIsStroke(
true );
2032 m_gal->SetStrokeColor(
color );
2033 m_gal->SetLineWidth( width );
2049 m_gal->DrawLine( a+1, b );
2051 m_gal->DrawLine( a, b );
2057void SCH_PAINTER::draw(
const SCH_SHAPE* aShape,
int aLayer )
2061 if( m_schSettings.IsPrinting() && drawingShadows )
2065 COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows );
2073 switch( shape->GetShape() )
2082 endAngle - startAngle );
2087 m_gal->DrawCircle( shape->GetPosition(), shape->GetRadius() );
2091 m_gal->DrawRectangle( shape->GetPosition(), shape->GetEnd() );
2096 std::deque<VECTOR2D> pts;
2098 for(
const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() )
2099 pts.push_back( pt );
2101 m_gal->DrawPolygon( pts );
2107 m_gal->DrawCurve( shape->GetStart(), shape->GetBezierC1(), shape->GetBezierC2(),
2119 if(
eeconfig()->m_Selection.fill_shapes )
2124 m_gal->SetIsFill( aShape->
IsFilled() );
2126 m_gal->SetIsFill(
true );
2128 m_gal->SetIsStroke(
false );
2129 m_gal->SetFillColor(
color );
2133 m_gal->SetIsStroke(
true );
2134 m_gal->SetIsFill(
false );
2135 m_gal->SetLineWidth( getLineWidth( aShape,
true ) );
2136 m_gal->SetStrokeColor(
color );
2139 drawShape( aShape );
2145 if( aShape->
IsFilled() && !m_schSettings.PrintBlackAndWhiteReq() )
2147 m_gal->SetIsFill(
true );
2148 m_gal->SetIsStroke(
false );
2149 m_gal->SetFillColor(
color );
2151 drawShape( aShape );
2156 float lineWidth = getLineWidth( aShape, drawingShadows );
2160 m_gal->SetIsFill(
false );
2161 m_gal->SetIsStroke(
true );
2162 m_gal->SetLineWidth( lineWidth );
2163 m_gal->SetStrokeColor(
color );
2167 drawShape( aShape );
2173 for(
SHAPE* shape : shapes )
2180 m_gal->DrawLine( a+1, b );
2182 m_gal->DrawLine( a, b );
2186 for(
SHAPE* shape : shapes )
2194void SCH_PAINTER::draw(
const SCH_TEXT* aText,
int aLayer )
2198 if( m_schSettings.IsPrinting() && drawingShadows )
2204 switch( aText->
Type() )
2214 COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
2223 if( conn && conn->
IsBus() )
2239 m_gal->SetStrokeColor(
color );
2240 m_gal->SetFillColor(
color );
2250 if( drawingShadows && !font->
IsOutline() )
2252 m_gal->SetIsFill(
false );
2253 m_gal->SetIsStroke(
true );
2260 double fudge = getShadowWidth( !aText->
IsSelected() ) / 1.52;
2263 text_offset.
x -= fudge;
2265 text_offset.
y -= fudge;
2267 text_offset.
x += fudge;
2269 text_offset.
y += fudge;
2274 else if( drawingShadows )
2280 m_gal->SetIsStroke(
false );
2281 m_gal->SetIsFill(
true );
2288 m_gal->SetStrokeColor( m_schSettings.GetLayerColor(
LAYER_HOVERED ) );
2289 m_gal->SetFillColor( m_schSettings.GetLayerColor(
LAYER_HOVERED ) );
2299 int adjust =
KiROUND( sizeDiff * 0.4 );
2300 VECTOR2I adjust_offset( 0, - adjust );
2303 text_offset += adjust_offset;
2306 if( nonCached( aText )
2308 && !shownText.Contains( wxT(
"\n" ) ) )
2310 bitmapText( shownText, aText->
GetDrawPos() + text_offset, attrs );
2315 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache =
nullptr;
2323 m_gal->DrawGlyphs( *cache );
2327 strokeText( shownText, aText->
GetDrawPos() + text_offset, attrs,
2349 if( m_schSettings.IsPrinting() && drawingShadows )
2352 COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows );
2353 float borderWidth = getLineWidth( aTextBox, drawingShadows );
2367 m_gal->SetStrokeColor( m_schSettings.GetLayerColor(
LAYER_HOVERED ) );
2368 m_gal->SetFillColor( m_schSettings.GetLayerColor(
LAYER_HOVERED ) );
2372 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache =
nullptr;
2380 m_gal->DrawGlyphs( *cache );
2391 m_gal->SetFillColor(
color );
2392 m_gal->SetStrokeColor(
color );
2396 m_gal->SetIsFill(
true );
2397 m_gal->SetIsStroke(
false );
2398 m_gal->SetLineWidth( borderWidth );
2406 if( aTextBox->
IsFilled() && !m_schSettings.PrintBlackAndWhiteReq() )
2408 m_gal->SetIsFill(
true );
2409 m_gal->SetIsStroke(
false );
2410 m_gal->SetLineWidth( borderWidth );
2424 if( m_schSettings.m_OverrideItemColors || aTextBox->
IsBrightened()
2427 borderColor = m_schSettings.GetLayerColor( aLayer );
2430 m_gal->SetIsFill(
false );
2431 m_gal->SetIsStroke(
true );
2432 m_gal->SetStrokeColor( borderColor );
2433 m_gal->SetLineWidth( borderWidth );
2443 for(
SHAPE* shape : shapes )
2451 m_gal->DrawLine( a+1, b );
2453 m_gal->DrawLine( a, b );
2457 for(
SHAPE* shape : shapes )
2465void SCH_PAINTER::draw(
const SCH_TABLE* aTable,
int aLayer )
2468 draw(
static_cast<SCH_TEXTBOX*
>( cell ), aLayer );
2483 lineWidth = stroke.GetWidth();
2484 color = stroke.GetColor();
2485 lineStyle = stroke.GetLineStyle();
2487 if( lineWidth == 0 )
2488 lineWidth = m_schSettings.m_defaultPenWidth;
2496 m_gal->SetIsFill(
false );
2497 m_gal->SetIsStroke(
true );
2498 m_gal->SetStrokeColor(
color );
2499 m_gal->SetLineWidth( lineWidth );
2503 [&](
const SHAPE& shape )
2510 m_gal->DrawLine( a+1, b );
2512 m_gal->DrawLine( a, b );
2521 m_gal->DrawLine( ptA, ptB );
2535 m_gal->DrawRectangle( ptA, ptB );
2540 strokeShape( rect );
2550 for(
int col = 0; col < aTable->
GetColCount() - 1; ++col )
2552 for(
int row = 0; row < aTable->
GetRowCount(); ++row )
2558 strokeLine( topRight, cell->
GetEnd() );
2565 for(
int row = 0; row < aTable->
GetRowCount() - 1; ++row )
2567 for(
int col = 0; col < aTable->
GetColCount(); ++col )
2573 strokeLine( botLeft, cell->
GetEnd() );
2590 strokeRect( pos, end );
2620 ORIENT o = orientations[ 0 ];
2622 for( ORIENT& i : orientations )
2624 if( i.flag == orientation )
2633 for(
int i = 0; i < o.n_rots; i++ )
2634 item.Rotate(
VECTOR2I(0, 0 ),
true );
2637 item.MirrorVertical(
VECTOR2I( 0, 0 ) );
2640 item.MirrorHorizontal(
VECTOR2I( 0, 0 ) );
2645wxString SCH_PAINTER::expandLibItemTextVars(
const wxString& aSourceText,
2648 std::function<bool( wxString* )> symbolResolver =
2649 [&]( wxString* token ) ->
bool
2651 return aSymbolContext->
ResolveTextVar( &m_schematic->CurrentSheet(), token );
2662 if( m_schSettings.IsPrinting() && drawingShadows )
2665 if( !drawingShadows ||
eeconfig()->m_Selection.draw_selected_children )
2668 draw( &field, aLayer, aSymbol->
GetDNP() );
2687 originalSymbol->
GetPins( originalPins, unit, bodyStyle );
2692 tempSymbol.
GetPins( tempPins, unit, bodyStyle );
2700 tempItem.SetFlags( aSymbol->
GetFlags() );
2708 textItem->
SetText( expandLibItemTextVars( textItem->
GetText(), aSymbol ) );
2715 textboxItem->
SetText( expandLibItemTextVars( textboxItem->
GetText(), aSymbol ) );
2720 for(
unsigned i = 0; i < tempPins.size(); ++ i )
2723 LIB_PIN* tempPin = tempPins[ i ];
2743 for(
unsigned i = 0; i < tempPins.size(); ++i )
2746 LIB_PIN* tempPin = tempPins[ i ];
2761 margins.
x = std::max( margins.
x * 0.6, margins.
y * 0.3 );
2762 margins.
y = std::max( margins.
y * 0.6, margins.
x * 0.3 );
2769 m_gal->AdvanceDepth();
2770 m_gal->SetIsStroke(
true );
2771 m_gal->SetIsFill(
true );
2776 std::swap( pt1.
x, pt2.
x );
2783void SCH_PAINTER::draw(
const SCH_FIELD* aField,
int aLayer,
bool aDimmed )
2787 if( m_schSettings.IsPrinting() && drawingShadows )
2793 if( !drawingShadows && aField->
GetLayer() != aLayer )
2798 COLOR4D color = getRenderColor( aField, aLayer, drawingShadows, aDimmed );
2802 if( !m_schematic ||
eeconfig()->m_Appearance.show_hidden_fields )
2810 if( shownText.IsEmpty() )
2846 if( m_schSettings.GetDrawBoundingBoxes() )
2847 drawItemBoundingBox( aField );
2849 m_gal->SetStrokeColor(
color );
2850 m_gal->SetFillColor(
color );
2852 if( drawingShadows && getFont( aField )->IsOutline() )
2854 BOX2I shadow_box = bbox;
2858 m_gal->SetIsStroke(
false );
2859 m_gal->SetIsFill(
true );
2872 if( drawingShadows )
2877 m_gal->SetStrokeColor( m_schSettings.GetLayerColor(
LAYER_HOVERED ) );
2878 m_gal->SetFillColor( m_schSettings.GetLayerColor(
LAYER_HOVERED ) );
2882 if( nonCached( aField ) && aField->
RenderAsBitmap( m_gal->GetWorldScale() ) )
2884 bitmapText( shownText, textpos, attributes );
2889 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache =
nullptr;
2892 cache = aField->
GetRenderCache( shownText, textpos, attributes );
2897 m_gal->DrawGlyphs( *cache );
2901 strokeText( shownText, textpos, attributes, aField->
GetFontMetrics() );
2913 m_gal->SetLineWidth( m_schSettings.m_outlineWidth );
2915 m_gal->DrawLine( bbox.
Centre(), parentPos );
2924 if( m_schSettings.IsPrinting() && drawingShadows )
2929 if( !drawingShadows ||
eeconfig()->m_Selection.draw_selected_children )
2932 draw( &field, aLayer,
false );
2943 if( drawingDangling )
2955 std::vector<VECTOR2I> pts;
2956 std::deque<VECTOR2D> pts2;
2961 pts2.emplace_back(
VECTOR2D( p.x, p.y ) );
2963 m_gal->SetIsStroke(
true );
2964 m_gal->SetLineWidth( getLineWidth( aLabel, drawingShadows ) );
2965 m_gal->SetStrokeColor(
color );
2967 if( drawingShadows )
2969 m_gal->SetIsFill(
eeconfig()->m_Selection.fill_shapes );
2970 m_gal->SetFillColor(
color );
2971 m_gal->DrawPolygon( pts2 );
2975 m_gal->SetIsFill(
false );
2976 m_gal->DrawPolyline( pts2 );
2979 draw(
static_cast<const SCH_TEXT*
>( aLabel ), aLayer );
2983void SCH_PAINTER::draw(
const SCH_LABEL* aLabel,
int aLayer )
2987 if( m_schSettings.IsPrinting() && drawingShadows )
2992 if( !drawingShadows ||
eeconfig()->m_Selection.draw_selected_children )
2995 draw( &field, aLayer,
false );
3006 if( drawingDangling )
3018 draw(
static_cast<const SCH_TEXT*
>( aLabel ), aLayer );
3026 if( m_schSettings.IsPrinting() && drawingShadows )
3031 if( !( drawingShadows || drawingDangling ) ||
eeconfig()->m_Selection.draw_selected_children )
3034 draw( &field, aLayer,
false );
3045 if( drawingDangling )
3064 if( conn && conn->
IsBus() )
3068 std::vector<VECTOR2I> pts;
3069 std::deque<VECTOR2D> pts2;
3074 pts2.emplace_back(
VECTOR2D( p.x, p.y ) );
3076 m_gal->SetIsFill(
true );
3078 m_gal->SetIsStroke(
true );
3079 m_gal->SetLineWidth( getLineWidth( aLabel, drawingShadows ) );
3080 m_gal->SetStrokeColor(
color );
3081 m_gal->DrawPolyline( pts2 );
3083 draw(
static_cast<const SCH_TEXT*
>( aLabel ), aLayer );
3094 if( m_schSettings.IsPrinting() && drawingShadows )
3097 if( !drawingShadows ||
eeconfig()->m_Selection.draw_selected_children )
3100 draw( &field, aLayer,
false );
3123 std::vector<VECTOR2I> pts;
3124 std::deque<VECTOR2D> pts2;
3129 pts2.emplace_back(
VECTOR2D( p.x, p.y ) );
3131 m_gal->SetIsFill(
false );
3132 m_gal->SetFillColor(
color );
3133 m_gal->SetIsStroke(
true );
3134 m_gal->SetLineWidth( getLineWidth( aLabel, drawingShadows ) );
3135 m_gal->SetStrokeColor(
color );
3139 m_gal->DrawLine( pts2[0], pts2[1] );
3140 m_gal->SetIsFill(
true );
3141 m_gal->DrawCircle( pts2[2], ( pts2[2] - pts2[1] ).
EuclideanNorm() );
3145 m_gal->DrawLine( pts2[0], pts2[1] );
3146 m_gal->DrawCircle( pts2[2], ( pts2[2] - pts2[1] ).
EuclideanNorm() );
3150 m_gal->DrawPolyline( pts2 );
3155void SCH_PAINTER::draw(
const SCH_SHEET* aSheet,
int aLayer )
3159 if( m_schSettings.IsPrinting() && drawingShadows )
3162 if( !drawingShadows ||
eeconfig()->m_Selection.draw_selected_children )
3165 draw( &field, aLayer,
false );
3181 if( !m_schSettings.PrintBlackAndWhiteReq() )
3184 m_gal->SetIsFill(
true );
3185 m_gal->SetIsStroke(
false );
3187 m_gal->DrawRectangle( pos, pos + size );
3193 m_gal->SetStrokeColor( getRenderColor( aSheet,
LAYER_SHEET, drawingShadows ) );
3194 m_gal->SetIsStroke(
true );
3195 m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
3196 m_gal->SetIsFill(
false );
3198 m_gal->DrawRectangle( pos, pos + size );
3207 if( m_schSettings.IsPrinting() && drawingShadows )
3213 m_gal->SetIsStroke(
true );
3214 m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
3215 m_gal->SetStrokeColor( getRenderColor( aNC,
LAYER_NOCONNECT, drawingShadows ) );
3216 m_gal->SetIsFill(
false );
3219 int delta = std::max( aNC->
GetSize(), m_schSettings.GetDefaultPenWidth() * 3 ) / 2;
3232 if( m_schSettings.IsPrinting() && drawingShadows )
3259 if( drawingDangling )
3261 m_gal->SetIsFill(
false );
3262 m_gal->SetIsStroke(
true );
3263 m_gal->SetStrokeColor(
color.Brightened( 0.3 ) );
3264 m_gal->SetLineWidth( m_schSettings.GetDanglingIndicatorThickness() );
3274 m_gal->DrawCircle( aEntry->
GetEnd(),
3283 draw( &line, aLayer );
3297 if( img_scale != 1.0 )
3298 m_gal->Scale(
VECTOR2D( img_scale, img_scale ) );
3302 m_gal->DrawBitmap( *aBitmap->
GetImage() );
3310 m_gal->SetIsStroke(
true );
3311 m_gal->SetStrokeColor(
color );
3312 m_gal->SetLineWidth ( getShadowWidth( aBitmap->
IsBrightened() ) );
3313 m_gal->SetIsFill(
false );
3320 bm_size.
x /= img_scale;
3321 bm_size.
y /= img_scale;
3322 VECTOR2D origin( -bm_size.
x / 2.0, -bm_size.
y / 2.0 );
3325 m_gal->DrawRectangle( origin, end );
3337 if( m_schSettings.IsPrinting() && drawingShadows )
3347 m_gal->SetIsFill( !drawingShadows );
3348 m_gal->SetFillColor(
color );
3349 m_gal->SetIsStroke( drawingShadows );
3350 m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
3351 m_gal->SetStrokeColor(
color );
3356 m_gal->DrawPolygon( polygon );
VECTOR2D mapCoords(const VECTOR2D &aSource)
constexpr EDA_IU_SCALE schIUScale
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
const Vec & GetPosition() const
const Vec & GetOrigin() const
void Offset(coord_type dx, coord_type dy)
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
void SetX(coord_type val)
void SetY(coord_type val)
coord_type GetTop() const
coord_type GetHeight() const
coord_type GetWidth() const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
coord_type GetRight() const
coord_type GetLeft() const
const BOX2< Vec > GetBoundingBoxRotated(const VECTOR2I &aRotCenter, const EDA_ANGLE &aAngle) const
Useful to calculate bounding box of rotated items, when rotation is not cardinal.
coord_type GetBottom() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
bool GetOverrideSchItemColors() const
COLOR4D GetColor(int aLayer) const
bool IsHorizontal() const
A base class for most all the KiCad significant classes used in schematics and boards.
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
EDA_ITEM * GetParent() const
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
bool IsBrightened() const
virtual wxString GetClass() const =0
Return the class name.
bool IsForceVisible() const
EDA_ITEM_FLAGS GetFlags() const
FILL_T GetFillMode() const
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
COLOR4D GetFillColor() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
BOX2I GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
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.
virtual bool IsVisible() const
KIFONT::FONT * GetFont() const
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
virtual EDA_ANGLE GetDrawRotation() const
virtual VECTOR2I GetDrawPos() const
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
const TEXT_ATTRIBUTES & GetAttributes() const
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)
VECTOR2I GetTextSize() const
APP_SETTINGS_BASE * KifaceSettings() const
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)
virtual bool IsStroke() const
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics) const
Draw a string.
virtual bool IsOutline() const
VECTOR2I StringBoundaryLimits(const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic, const METRICS &aFontMetrics) const
Compute the boundary limits of aText (the bounding box of all shapes).
A color representation with 4 components: red, green, blue, alpha.
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
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.
Abstract interface for drawing on a 2D-surface.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
void SetVerticalJustify(const GR_TEXT_V_ALIGN_T aVerticalJustify)
void SetHorizontalJustify(const GR_TEXT_H_ALIGN_T aHorizontalJustify)
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
void SetGlyphSize(const VECTOR2I aSize)
Contains all the knowledge about how to draw graphical object onto any particular output device.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
COLOR4D m_backgroundColor
void SetDefaultPenWidth(int aWidth)
void SetGapLengthRatio(double aRatio)
const wxString & GetDefaultFont() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void SetDashLengthRatio(double aRatio)
COLOR4D m_layerColors[LAYER_ID_COUNT]
bool GetDrawBoundingBoxes() const
virtual bool Draw(const VIEW_ITEM *, int) override
Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item.
float getShadowWidth(bool aForHighlight) const
KIFONT::FONT * getFont(const EDA_TEXT *aText) const
void draw(const EDA_ITEM *, int, bool aDimmed)
bool isUnitAndConversionShown(const LIB_ITEM *aItem) const
static std::vector< KICAD_T > g_ScaledSelectionTypes
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows, bool aDimmed=false) const
SCH_RENDER_SETTINGS m_schSettings
bool nonCached(const EDA_ITEM *aItem)
void drawItemBoundingBox(const EDA_ITEM *aItem)
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
bool m_OverrideItemColors
void LoadColors(const COLOR_SETTINGS *aSettings) override
bool GetShowPageLimits() const override
An abstract base class for deriving all objects that can be added to a VIEW.
double GetForcedTransparency() const
static constexpr int VIEW_MAX_LAYERS
Rendering order modifier for layers that are marked as top layers.
Field object used in symbol libraries.
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
The base class for drawable items used by schematic library symbols.
virtual int GetPenWidth() const =0
const KIFONT::METRICS & GetFontMetrics() const
LIB_SYMBOL * GetParent() const
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
bool IsGlobalPower() const
Return whether this pin forms a global power connection: i.e., is part of a power symbol and of type ...
void SetShape(GRAPHIC_PINSHAPE aShape)
ELECTRICAL_PINTYPE GetType() const
void SetName(const wxString &aName)
void SetType(ELECTRICAL_PINTYPE aType)
PIN_ORIENTATION GetOrientation() const
wxString GetShownNumber() const
int GetNumberTextSize() const
wxString GetShownName() const
void SetOperatingPoint(const wxString &aText)
VECTOR2I GetPosition() const override
const wxString & GetOperatingPoint() const
wxString const GetElectricalTypeName() const
GRAPHIC_PINSHAPE GetShape() const
int GetNameTextSize() const
STROKE_PARAMS GetStroke() const
VECTOR2I GetPosition() const override
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the LIB_SHAPE.
Define a library symbol object.
int GetPinNameOffset() const
void GetPins(LIB_PINS &aList, int aUnit=0, int aBodyStyle=0) const
Return a list of pin object pointers from the draw item list.
bool ShowPinNames() const
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
bool ShowPinNumbers() const
VECTOR2I GetDrawPos() const override
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Define a symbol library graphical text item.
const BOX2I GetBoundingBox() const override
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Object to handle a bitmap image that can be inserted in a schematic.
double GetImageScale() const
VECTOR2I GetPosition() const override
BITMAP_BASE * GetImage() const
Base class for a bus or wire entry.
LINE_STYLE GetLineStyle() const
VECTOR2I GetPosition() const override
bool IsDanglingStart() const
virtual STROKE_PARAMS GetStroke() const override
bool IsDanglingEnd() const
int GetPenWidth() const override
Class for a wire to bus entry.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
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.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const wxString &forResolvedText, const VECTOR2I &forPosition, TEXT_ATTRIBUTES &aAttrs) const
VECTOR2I GetParentPosition() const
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.
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 CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual int GetPenWidth() const
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
bool RenderAsBitmap(double aWorldScale) const override
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
int GetEffectiveDiameter() const
VECTOR2I GetPosition() const override
bool IsDangling() const override
LABEL_FLAG_SHAPE GetShape() const
std::vector< SCH_FIELD > & GetFields()
Segment description base class to describe items which have 2 end points (track, wire,...
void SetStartPoint(const VECTOR2I &aPosition)
bool IsWire() const
Return true if the line is a wire.
bool IsStartDangling() const
void SetLineColor(const COLOR4D &aColor)
void SetLineWidth(const int aSize)
LINE_STYLE GetEffectiveLineStyle() const
VECTOR2I GetMidPoint() const
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
bool IsEndDangling() const
void SetLineStyle(const LINE_STYLE aStyle)
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
void SetEndPoint(const VECTOR2I &aPosition)
const wxString & GetOperatingPoint() const
SCH_LAYER_ID GetColorLayer() const
VECTOR2I GetPosition() const override
VECTOR2I GetPosition() const override
const wxString & GetOperatingPoint() const
bool IsDangling() const override
wxString GetShownName() const
GRAPHIC_PINSHAPE GetShape() const
ELECTRICAL_PINTYPE GetType() const
LINE_STYLE GetEffectiveLineStyle() const
VECTOR2I GetCenter() const
STROKE_PARAMS GetStroke() const override
VECTOR2I GetPosition() const override
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
std::vector< SCH_FIELD > & GetFields()
VECTOR2I GetPosition() const override
KIGFX::COLOR4D GetBorderColor() const
std::vector< SCH_SHEET_PIN * > & GetPins()
KIGFX::COLOR4D GetBackgroundColor() const
VECTOR2I GetPosition() const override
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
TRANSFORM & GetTransform()
int GetOrientation() const
Get the display symbol orientation.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
BOX2I GetBodyAndPinsBoundingBox() const
Return a bounding box for the symbol body and pins but not the fields.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
BOX2I GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.
const STROKE_PARAMS & GetSeparatorsStroke() const
bool StrokeExternal() const
std::vector< SCH_TABLECELL * > GetCells() const
const STROKE_PARAMS & GetBorderStroke() const
VECTOR2I GetPosition() const override
SCH_TABLECELL * GetCell(int aRow, int aCol) const
bool StrokeColumns() const
bool StrokeHeader() const
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
VECTOR2I GetDrawPos() const override
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
virtual VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const
This offset depends on the orientation, the type of text, and the area required to draw the associate...
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
void Fracture(POLYGON_MODE aFastMode)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
int NewOutline()
Creates a new empty polygon in the set and returns its index.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
An abstract shape on 2D plane.
Simple container to manage line stroke parameters.
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, std::function< void(const VECTOR2I &a, const VECTOR2I &b)> aStroker)
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
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
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define DEFAULT_TEXT_OFFSET_RATIO
Ratio of the font height to space around global labels.
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
#define UNSELECTED_END_SIZE
The default pin len value when creating pins(can be changed in preference menu)
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
#define IS_SHOWN_AS_BITMAP
#define ENDPOINT
ends. (Used to support dragging.)
#define IS_DANGLING
indicates a pin is dangling
#define STARTPOINT
When a line is selected, these flags indicate which.
@ ARC
use RECTANGLE instead of RECT to avoid collision in a Windows header
@ FILLED_WITH_BG_BODYCOLOR
int GetPenSizeForDemiBold(int aTextSize)
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aStrict)
Pen width should not allow characters to become cluttered up in their own fatness.
double m_MinPlotPenWidth
Absolute minimum pen width for plotting.
@ LAYER_DRAW_BITMAPS
to handle and draw images bitmaps
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc)
SCH_LAYER_ID
Eeschema drawing layers.
@ LAYER_DEVICE_BACKGROUND
@ LAYER_SELECTION_SHADOWS
@ LAYER_SCHEMATIC_BACKGROUND
@ LAYER_SCHEMATIC_AUX_ITEMS
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
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
#define UNIMPLEMENTED_FOR(type)
The Cairo implementation of the graphics abstraction layer.
static LIB_SYMBOL * dummy()
Used when a LIB_SYMBOL is not found in library to draw a dummy shape.
EESCHEMA_SETTINGS * eeconfig()
static bool isFieldsLayer(int aLayer)
static void orientSymbol(LIB_SYMBOL *symbol, int orientation)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ OUTSIDE
Text appears outside the dimension line (default)
@ PT_NC
not connected (must be left open)
PIN_ORIENTATION
The symbol library pin object orientations.
#define TARGET_BUSENTRY_RADIUS
#define BITMAP_FONT_SIZE_THRESHOLD
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
LINE_STYLE
Dashed line types.
constexpr int MilsToIU(int mils) const
constexpr int mmToIU(double mm) const
Definition for symbol library class.
@ GR_TEXT_H_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_INDETERMINATE
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.
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
double EuclideanNorm(const VECTOR2I &vector)
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