124 draw( item, aLayer,
false );
127 m_gal->SetStrokePixelPad( 0.0 );
136#ifdef CONNECTIVITY_DEBUG
138 auto sch_item =
dynamic_cast<const SCH_ITEM*
>( aItem );
139 auto conn = sch_item ? sch_item->
Connection( *g_CurrentSheet ) :
nullptr;
144 auto label = conn->Name(
true );
149 m_canvas->SetLineWidth( Mils2ui( 2 ) );
150 m_canvas->SetGlyphSize(
VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) );
151 m_canvas->StrokeText( *m_canvas, conn->Name(
true ), pos, 0.0, 0 );
159 switch( aItem->
Type() )
165 drawBoundingBox =
false;
166 draw(
static_cast<const SCH_PIN*
>( aItem ), aLayer, aDimmed );
178 draw(
static_cast<const SCH_SHAPE*
>( aItem ), aLayer, aDimmed );
181 draw(
static_cast<const SCH_SHAPE*
>( aItem ), aLayer, aDimmed );
184 draw(
static_cast<const SCH_TEXT*
>( aItem ), aLayer, aDimmed );
190 draw(
static_cast<const SCH_TABLE*
>( aItem ), aLayer, aDimmed );
193 draw(
static_cast<const SCH_LABEL*
>( aItem ), aLayer, aDimmed );
199 draw(
static_cast<const SCH_FIELD*
>( aItem ), aLayer, aDimmed );
235 if( drawBoundingBox )
251 box =
static_cast<const SCH_SYMBOL*
>( aItem )->GetBodyBoundingBox();
253 m_gal->SetIsFill(
false );
254 m_gal->SetIsStroke(
true );
256 :
COLOR4D( 0.2, 0.2, 0.2, 1 ) );
304 return limit > 0.0 &&
m_gal->WorldScaleBelow( limit );
314 if(
m_gal->SupportsStrokePixelPad() )
316 m_gal->SetStrokePixelPad( milsWidth );
317 return (
float)
schIUScale.MilsToIU( milsWidth );
324 return (
float) std::fabs( matrix.
GetScale().
x * milsWidth ) +
schIUScale.MilsToIU( milsWidth );
329 bool aDimmed,
bool aIgnoreNets )
const
331 auto isBackgroundLayer =
348 color =
static_cast<const SCH_LINE*
>( aItem )->GetLineColor();
356 color =
static_cast<const SCH_JUNCTION*
>( aItem )->GetJunctionColor();
362 if( isBackgroundLayer( aLayer ) )
371 if( isBackgroundLayer( aLayer ) )
394 wxFAIL_MSG( wxT(
"Unsupported fill type" ) );
403 else if( isSymbolChild )
414 else if( aItem->
IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
420 else if( aIgnoreNets )
427 color =
static_cast<const SCH_FIELD*
>( aItem )->GetFieldColor();
433 if( isBackgroundLayer( aLayer ) )
438 else if(
const EDA_TEXT* otherTextItem =
dynamic_cast<const EDA_TEXT*
>( aItem ) )
441 color = otherTextItem->GetTextColor();
452 if( isBackgroundLayer( aLayer) )
477 if( aDrawingShadows )
484 else if( isBackgroundLayer( aLayer ) )
489 else if( aItem->
IsSelected() && aDrawingShadows )
493 else if( aItem->
IsSelected() && isBackgroundLayer( aLayer ) )
503 color = color.
Darken( 0.5f );
506 if( aDimmed && !( aItem->
IsSelected() && aDrawingShadows ) )
510 color = color.
Mix( sheetColour, 0.5f );
521 bool aDrawingWireColorHighlights )
const
534 if( aDrawingWireColorHighlights )
536 float colorHighlightWidth =
schIUScale.MilsToIU( 15.0 );
542 width += colorHighlightWidth;
553 switch( aItem->
Type() )
556 pen =
static_cast<const SCH_FIELD*
>( aItem )->GetEffectiveTextPenWidth( pen );
560 pen =
static_cast<const SCH_TEXT*
>( aItem )->GetEffectiveTextPenWidth( pen );
568 pen =
static_cast<const SCH_LABEL_BASE*
>( aItem )->GetEffectiveTextPenWidth( pen );
573 pen =
static_cast<const SCH_TEXTBOX*
>( aItem )->GetEffectiveTextPenWidth( pen );
587 int screenTextSize =
std::abs( (
int)
m_gal->GetScreenWorldMatrix().GetScale().y * 7 );
590 return KiROUND( ( docTextSize + screenTextSize * 2 ) / 3.0 );
609 std::optional<VECTOR2I> aMousePos = std::nullopt, wxString* aActiveUrl =
nullptr )
616 if( aShadowWidth > 0.0f )
635 font->
Draw( &callback_gal, aText, aPosition, aAttrs, aFontMetrics );
642 font->
Draw( &aGal, aText, aPosition, aAttrs, aFontMetrics, aMousePos, aActiveUrl );
662static void drawCache(
KIGFX::GAL& aGal, std::vector<std::unique_ptr<KIFONT::GLYPH>>* aCache,
float aStrokeWidth,
668 if( aShadowWidth > 0.0f )
670 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : *aCache )
672 if( glyph->IsOutline() )
679 for(
int ii = 0; ii < outlineGlyph->
OutlineCount(); ++ii )
710 callback_gal.SetIsStroke(
true );
712 font->
Draw( &callback_gal, aText, aPosition, attrs, aFontMetrics );
735 m_gal->DrawLine( a, b );
736 m_gal->DrawLine( b, c );
741 int aBodyStyle,
bool aDimmed )
749 std::unique_ptr< LIB_SYMBOL > tmpSymbol;
754 tmpSymbol = aSymbol->
Flatten();
755 drawnSymbol = tmpSymbol.get();
761 [](
const SCH_ITEM& item,
int layer )
771 if( !childOnLayer( item, aLayer ) )
788 draw( &item, aLayer, aDimmed );
815 bool aDrawingShadows,
bool aBrightened )
827 m_gal->SetIsFill(
false );
828 m_gal->SetIsStroke(
true );
829 m_gal->SetLineWidth( lineWidth );
838 const COLOR4D& aColor,
bool aDrawingShadows,
841 double lineWidth = aSize / 10.0;
843 if( aDrawingShadows )
846 std::vector<SCH_SHAPE> shapeList;
849 m_gal->SetLineWidth( lineWidth );
850 m_gal->SetIsStroke(
true );
851 m_gal->SetStrokeColor( aColor );
852 m_gal->SetFillColor( aColor );
854 for(
const SCH_SHAPE& shape : shapeList )
860 m_gal->DrawCurve( shape.GetStart(), shape.GetBezierC1(), shape.GetBezierC2(), shape.GetEnd() );
862 m_gal->DrawCircle( shape.getCenter(), shape.GetRadius() );
871 bool aRotate,
int aExtraLineWidth,
const COLOR4D& aColor )
899 const double lineYOffset = aSize / 4;
900 const double arrowHead = aSize / 8;
916 topLineREnd -
VECTOR2D{ aSize * 0.7, 0 } );
919 aGal.
DrawLine( topLineREnd, topLineREnd -
VECTOR2D{ arrowHead * 1.2, arrowHead } );
920 aGal.
DrawLine( topLineREnd, topLineREnd -
VECTOR2D{ arrowHead * 1.2, -arrowHead } );
924 aGal.
DrawLine( btmLineREnd, btmLineREnd -
VECTOR2D{ arrowHead * 1.2, arrowHead } );
925 aGal.
DrawLine( btmLineREnd, btmLineREnd -
VECTOR2D{ arrowHead * 1.2, -arrowHead } );
934 aGal.
DrawArc( topLineREnd -
VECTOR2D{ aSize - lineYOffset * 2, -lineYOffset },
955 if(
m_schSettings.IsPrinting() && ( drawingShadows || drawingDangling ) )
987 if( drawingDangling )
1006 int textOffset =
KiROUND( textSize * 0.22 );
1009 if( len > textSize )
1013 mid.
x +=
KiROUND( textOffset * 1.2 );
1018 mid.
y -=
KiROUND( textOffset * 1.2 );
1039 m_gal->SetIsStroke(
true );
1040 m_gal->SetIsFill(
false );
1042 m_gal->SetStrokeColor( color );
1043 m_gal->SetFontBold(
false );
1044 m_gal->SetFontUnderlined(
false );
1045 m_gal->SetFontItalic(
false );
1048 const int diam =
radius*2;
1053 m_gal->DrawLine( p0, pos );
1066 m_gal->DrawLine( p0, pos );
1071 m_gal->DrawLine( p0 + dir * ( diam ), pos );
1075 pc = p0 - dir * clock_size ;
1079 p0 +
VECTOR2D( -dir.
y, dir.
x) * clock_size );
1082 m_gal->DrawLine( p0 + dir * ( diam ), pos );
1087 pc = p0 - dir * clock_size ;
1091 p0 +
VECTOR2D( -dir.
y, dir.
x) * clock_size );
1106 m_gal->DrawLine( p0, pos );
1110 m_gal->DrawLine( p0, pos );
1115 p0 +
VECTOR2D( -dir.
x * clock_size, 0 ),
1121 p0 +
VECTOR2D( 0, -dir.
y * clock_size ),
1127 m_gal->DrawLine( p0, pos );
1144 m_gal->DrawLine( p0, pos );
1153 m_gal->DrawLine( p0, pos );
1163 if( drawingShadows && !
eeconfig()->m_Selection.draw_selected_children )
1173 float shadowWidth = 0.0f;
1175 if( drawingShadows )
1182 const auto textRendersAsBitmap =
1196 const auto drawBrace =
1201 VECTOR2D mid = ( aTop + aBottom ) / 2.0;
1203 aGal.
SetLineWidth( (
float) aAttrs.m_StrokeWidth + aShadowWidth );
1219 double braceOffset = aLeftBrace ? -aBraceWidth : aBraceWidth;
1220 p2.
y += braceOffset / 2;
1221 p3.
y += braceOffset;
1222 p4.
y += braceOffset / 2;
1227 double braceOffset = aLeftBrace ? -aBraceWidth : aBraceWidth;
1228 p2.
x += braceOffset / 2;
1229 p3.
x += braceOffset;
1230 p4.
x += braceOffset / 2;
1240 const auto drawBracesAroundText =
1241 [&](
KIGFX::GAL& aGal,
const wxArrayString& aLines,
const VECTOR2D& aStartPos,
int aLineSpacing,
1244 if( aLines.size() <= 1 )
1248 int braceWidth = aAttrs.m_Size.x / 3;
1251 int maxLineWidth = 0;
1257 for(
const wxString& line : aLines )
1259 wxString trimmedLine = line;
1260 trimmedLine.Trim(
true ).Trim(
false );
1262 aAttrs.m_StrokeWidth,
false,
false,
1264 maxLineWidth = std::max( maxLineWidth, lineExtents.
x );
1272 int textHeight = aAttrs.m_Size.y;
1273 int extraHeight = textHeight / 3;
1278 braceEnd.
x += ( (int) aLines.size() - 1 ) * aLineSpacing;
1281 braceStart.
x -= 2 * extraHeight;
1284 int braceSpacing = maxLineWidth / 2 + braceWidth;
1286 VECTOR2D topBraceStart = braceStart;
1287 topBraceStart.
y -= braceSpacing;
1290 topBraceEnd.
y -= braceSpacing;
1292 drawBrace( aGal, topBraceStart, topBraceEnd, braceWidth,
true, aAttrs, aShadowWidth );
1294 VECTOR2D bottomBraceStart = braceStart;
1295 bottomBraceStart.
y += braceSpacing;
1297 VECTOR2D bottomBraceEnd = braceEnd;
1298 bottomBraceEnd.
y += braceSpacing;
1300 drawBrace( aGal, bottomBraceStart, bottomBraceEnd, braceWidth,
false, aAttrs, aShadowWidth );
1305 braceEnd.
y += ( (int) aLines.size() - 1 ) * aLineSpacing;
1308 braceStart.
y -= 2 * extraHeight;
1311 int braceSpacing = maxLineWidth / 2 + braceWidth;
1315 leftTop.
x -= braceSpacing;
1318 leftBottom.
x -= braceSpacing;
1320 drawBrace( aGal, leftTop, leftBottom, braceWidth,
true, aAttrs, aShadowWidth );
1324 rightTop.
x += braceSpacing;
1327 rightBottom.
x += braceSpacing;
1329 drawBrace( aGal, rightTop, rightBottom, braceWidth,
false, aAttrs, aShadowWidth );
1333 const auto drawBracesAroundTextBitmap =
1338 if( aLines.size() <= 1 )
1341 int braceWidth = aAttrs.m_Size.x / 4;
1344 int maxLineWidth = aAttrs.m_Size.x * 4;
1350 int textHalfHeight = aAttrs.m_Size.y / 2;
1355 braceEnd.
x += ( (int) aLines.size() - 1 ) * aLineSpacing;
1358 leftStart.
y -= maxLineWidth / 2.0 + braceWidth / 2.0;
1361 leftEnd.
y -= maxLineWidth / 2.0 + braceWidth / 2.0;
1363 drawBrace( aGal, leftStart, leftEnd, braceWidth,
true, aAttrs, 0.0f );
1366 rightStart.
y += maxLineWidth / 2.0 + braceWidth / 2.0;
1369 rightEnd.
y += maxLineWidth / 2.0 + braceWidth / 2.0;
1371 drawBrace( aGal, rightStart, rightEnd, braceWidth,
false, aAttrs, 0.0f );
1376 braceEnd.
y += ( (int) aLines.size() - 1 ) * aLineSpacing;
1379 braceTop.
y -= textHalfHeight;
1382 braceBottom.
y += textHalfHeight;
1385 leftTop.
x -= maxLineWidth / 2.0 + braceWidth / 2.0;
1388 leftBottom.
x -= maxLineWidth / 2.0 + braceWidth / 2.0;
1390 drawBrace( aGal, leftTop, leftBottom, braceWidth,
true, aAttrs, 0.0f );
1393 rightTop.
x += maxLineWidth / 2.0 + braceWidth / 2.0;
1395 VECTOR2D rightBottom = braceBottom;
1396 rightBottom.
x += maxLineWidth / 2.0 + braceWidth / 2.0;
1398 drawBrace( aGal, rightTop, rightBottom, braceWidth,
false, aAttrs, 0.0f );
1403 const auto drawMultiLineText =
1405 bool aRenderTextAsBitmap,
float aShadowWidth,
const KIFONT::METRICS& aFontMetrics )
1408 if( aText.StartsWith(
"[" ) && aText.EndsWith(
"]" ) && aText.Contains(
"\n" ) )
1411 wxString content = aText.Mid( 1, aText.Length() - 2 );
1412 wxArrayString lines;
1415 if( lines.size() > 1 )
1418 int lineSpacing =
KiROUND( aAttrs.m_Size.y * 1.3 );
1429 int totalWidth = ( (int) lines.size() - 1 ) * lineSpacing;
1430 startPos.
x -= totalWidth;
1434 int totalWidth = ( (int) lines.size() - 1 ) * lineSpacing;
1435 startPos.
x -= totalWidth / 2.0;
1439 for(
size_t i = 0; i < lines.size(); i++ )
1442 linePos.
x += (int) i * lineSpacing;
1444 wxString line = lines[i];
1445 line.Trim(
true ).Trim(
false );
1447 if( aRenderTextAsBitmap )
1450 drawText( aGal, line, linePos, aAttrs, aShadowWidth, aFontMetrics );
1459 int totalHeight = ( (int) lines.size() - 1 ) * lineSpacing;
1460 startPos.
y -= totalHeight;
1464 int totalHeight = ( (int) lines.size() - 1 ) * lineSpacing;
1465 startPos.
y -= totalHeight / 2.0;
1469 for(
size_t i = 0; i < lines.size(); i++ )
1472 linePos.
y += (int) i * lineSpacing;
1474 wxString line = lines[i];
1475 line.Trim(
true ).Trim(
false );
1477 if( aRenderTextAsBitmap )
1480 drawText( aGal, line, linePos, aAttrs, aShadowWidth, aFontMetrics );
1485 if( aRenderTextAsBitmap )
1486 drawBracesAroundTextBitmap( aGal, lines, startPos, lineSpacing, aAttrs );
1488 drawBracesAroundText( aGal, lines, startPos, lineSpacing, aAttrs, aShadowWidth );
1495 if( aRenderTextAsBitmap )
1496 bitmapText( aGal, aText, aPosition, aAttrs );
1498 drawText( aGal, aText, aPosition, aAttrs, aShadowWidth, aFontMetrics );
1501 const auto drawTextInfo =
1505 const bool renderTextAsBitmap = textRendersAsBitmap( *
m_gal, aTextInfo.
m_TextSize );
1508 m_gal->SetStrokeColor( aColor );
1509 m_gal->SetFillColor( aColor );
1519 if(
nonCached( aPin ) && renderTextAsBitmap )
1534 const auto getColorForLayer =
1535 [&](
int aDrawnLayer )
1540 return getRenderColor( aPin, aDrawnLayer, drawingShadows, aDimmed );
1545 if( std::optional<PIN_LAYOUT_CACHE::TEXT_INFO> numInfo = cache.
GetPinNumberInfo( shadowWidth ) )
1547 std::optional<PIN_LAYOUT_CACHE::TEXT_INFO> origInfo;
1555 origInfo = *numInfo;
1557 origInfo->m_TextSize = std::max( 1, ( numInfo->m_TextSize * 4 ) / 5 );
1561 VECTOR2I fontSize( origInfo->m_TextSize, origInfo->m_TextSize );
1563 origInfo->m_Thickness,
false,
false,
1568 int shift = dir.
y > 0 ? labelExtents.
x : 0;
1569 numInfo->m_TextPosition.y += shift;
1570 origInfo->m_TextPosition.y = numBox->GetTop() + shift;
1574 int shift = dir.
x < 0 ? labelExtents.
x : 0;
1575 numInfo->m_TextPosition.x -= shift;
1576 origInfo->m_TextPosition.x = numBox->GetRight() - shift;
1581 drawTextInfo( *numInfo, getColorForLayer(
LAYER_PINNUM ) );
1588 if( !drawingShadows )
1591 drawTextInfo( *origInfo, dimmed );
1595 if( std::optional<PIN_LAYOUT_CACHE::TEXT_INFO> nameInfo = cache.
GetPinNameInfo( shadowWidth ) )
1597 drawTextInfo( *nameInfo, getColorForLayer(
LAYER_PINNAM ) );
1618 m_gal->SetStrokeColor( emphasis );
1619 m_gal->SetIsFill(
false );
1620 m_gal->SetIsStroke(
true );
1635 const bool lengthPad =
m_gal->SupportsStrokeLengthPad();
1652 m_gal->SetStrokeColor( color );
1653 m_gal->SetIsStroke(
true );
1661 m_gal->SetStrokeLengthPad( 0.0 );
1666 bool aDangling,
bool aDrawingShadows,
bool aBrightened )
1682 m_gal->SetIsStroke(
true );
1683 m_gal->SetIsFill(
false );
1693 bool highlightNetclassColors =
false;
1696 highlightNetclassColors = eeschemaCfg->m_Selection.highlight_netclass_colors;
1708 if( highlightNetclassColors && aLayer == aJct->
GetLayer() )
1715 if( junctionSize > 1 )
1717 m_gal->SetIsStroke( drawingShadows );
1719 m_gal->SetStrokeColor( color );
1720 m_gal->SetIsFill( !drawingShadows );
1721 m_gal->SetFillColor( color );
1732 bool drawingBusses = aLayer ==
LAYER_BUS;
1735 bool highlightNetclassColors =
false;
1736 double highlightAlpha = 0.6;
1737 double hopOverScale = 0.0;
1748 highlightNetclassColors = eeschemaCfg->m_Selection.highlight_netclass_colors;
1749 highlightAlpha = eeschemaCfg->m_Selection.highlight_netclass_colors_alpha;
1752 if( !highlightNetclassColors && drawingNetColorHighlights )
1755 if( drawingNetColorHighlights && !( aLine->
IsWire() || aLine->
IsBus() ) )
1758 if(
m_schSettings.m_OverrideItemColors && drawingNetColorHighlights )
1769 if( aLine->
IsNew() && drawingDangling )
1773 float width =
getLineWidth( aLine, drawingShadows, drawingNetColorHighlights );
1776 if( highlightNetclassColors )
1781 else if( drawingBusses )
1794 if( net && !net->IsEmpty() )
1801 color =
chain->GetColor().WithAlpha( color.
a );
1807 if( drawingNetColorHighlights )
1816 color = color.
WithAlpha( color.
a * highlightAlpha );
1819 if( ( drawingDangling || drawingShadows ) && !aLine->
IsNew() )
1824 COLOR4D indicatorColor( color );
1837 COLOR4D indicatorColor( color );
1848 if( drawingDangling )
1855 int textOffset =
KiROUND( textSize * 0.22 );
1860 pos.
y -= textOffset;
1866 pos.
x +=
KiROUND( textOffset * 1.2 );
1882 m_gal->SetIsStroke(
true );
1883 m_gal->SetIsFill(
false );
1884 m_gal->SetStrokeColor( color );
1885 m_gal->SetLineWidth( width );
1887 std::vector<VECTOR3I> curr_wire_shape;
1889 if( ( aLine->
IsWire() || aLine->
IsBus() ) && hopOverScale > 0.0 )
1891 double arcRadius = defaultLineWidth * hopOverScale;
1898 bool drawLineBody =
true;
1908 curr_wire_shape.emplace_back( lineStart.
x, lineStart.
y, 0 );
1909 curr_wire_shape.emplace_back( lineEnd.
x, lineEnd.
y, 0 );
1913 for(
size_t ii = 1; ii < curr_wire_shape.size(); ii++ )
1915 VECTOR2I start( curr_wire_shape[ii-1].x, curr_wire_shape[ii-1].y );
1917 if( curr_wire_shape[ii-1].z == 0 )
1920 VECTOR2I end( curr_wire_shape[ii].x, curr_wire_shape[ii].y );
1926 VECTOR2I arc_middle( curr_wire_shape[ii].x, curr_wire_shape[ii].y );
1928 VECTOR2I arc_end( curr_wire_shape[ii].x, curr_wire_shape[ii].y );
1940 EDA_ANGLE angle1 = midAngle - startAngle;
1945 m_gal->DrawArc(
center, ( dstart -
center ).EuclideanNorm(), startAngle, angle );
1976 if(
static_cast<const SCH_RULE_AREA*
>( aShape )->IsDirectiveLabelOnlyArea() )
1996 switch( shape->GetShape() )
2000 SHAPE_ARC arc( shape->GetStart(), shape->GetArcMid(), shape->GetEnd(), 0 );
2004 if( shape->ShortenArcForEndings( startAngle, arcAngle, arc.
GetRadius(), lineWidth ) )
2011 m_gal->DrawCircle( shape->GetPosition(), shape->GetRadius() );
2015 if( shape->GetCornerRadius() > 0 )
2020 shape->GetRectangleWidth(),
2021 shape->GetRectangleHeight() ),
2022 shape->GetCornerRadius(),
true );
2025 m_gal->DrawPolygon( poly );
2029 m_gal->DrawRectangle( shape->GetPosition(), shape->GetEnd() );
2035 if( shape->GetPolyShape().OutlineCount() == 0 )
2039 std::deque<VECTOR2D> drawPts;
2041 if( shape->GetStartEnding().GetShortenDepth( lineWidth ) > 0
2042 || shape->GetEndEnding().GetShortenDepth( lineWidth ) > 0 )
2044 std::vector<VECTOR2I> pts;
2046 if( shape->GetShortenedBodyPolyPoints( outline, 0, pts, lineWidth ) )
2049 drawPts.emplace_back( pt );
2055 drawPts.emplace_back( pt );
2057 if( shape->IsClosed() )
2058 drawPts.emplace_back( outline.
CPoint( 0 ) );
2061 if( drawPts.size() >= 2 )
2062 m_gal->DrawPolygon( drawPts );
2068 if( std::optional<
BEZIER<double>> curve = shape->ShortenedBezierCurve( lineWidth ) )
2069 m_gal->DrawCurve( curve->Start, curve->C1, curve->C2, curve->End, shape->GetMaxError() );
2074 m_gal->DrawEllipse( shape->GetEllipseCenter(), shape->GetEllipseMajorRadius(),
2075 shape->GetEllipseMinorRadius(), shape->GetEllipseRotation() );
2088 std::vector<VECTOR2I> pts;
2097 chain.SetClosed(
false );
2112 if(
eeconfig()->m_Selection.fill_shapes )
2119 m_gal->SetIsFill(
true );
2121 m_gal->SetFillColor( color );
2125 m_gal->SetIsFill(
false );
2130 m_gal->SetIsStroke(
true );
2132 m_gal->SetStrokeColor( color );
2134 drawShape( aShape );
2152 m_gal->SetIsFill(
false );
2153 m_gal->SetIsStroke(
true );
2154 m_gal->SetStrokeColor( color );
2158 m_gal->DrawLine( seg.A, seg.B );
2167 m_gal->SetIsFill(
true );
2168 m_gal->SetIsStroke(
false );
2169 m_gal->SetFillColor( color );
2171 drawShape( aShape );
2176 wxFAIL_MSG( wxT(
"Unsupported fill type" ) );
2185 m_gal->SetIsFill(
true );
2186 m_gal->SetIsStroke(
false );
2187 m_gal->SetFillColor( color );
2189 drawShape( aShape );
2192 float lineWidth =
getLineWidth( aShape, drawingShadows );
2196 int lineWidthIU =
KiROUND( lineWidth );
2198 m_gal->SetIsFill(
false );
2199 m_gal->SetIsStroke(
true );
2200 m_gal->SetLineWidth( lineWidth );
2201 m_gal->SetStrokeColor( color );
2205 drawShape( aShape );
2211 for(
SHAPE* shape : shapes )
2217 m_gal->DrawLine( a + 1, b );
2219 m_gal->DrawLine( a, b );
2223 for(
SHAPE* shape : shapes )
2263 switch( aText->
Type() )
2293 bool transparentColor = !drawingShadows && color.
a <= 0.0;
2295 m_gal->SetStrokeColor( color );
2296 m_gal->SetFillColor( color );
2297 m_gal->SetHoverColor( color );
2307 float shadowWidth = 0.0f;
2309 if( drawingShadows )
2315 if( transparentColor )
2327 double shadowOffset = 0.0;
2340 pos.
y = bBox.
GetTop() - shadowOffset;
2343 wxFAIL_MSG( wxT(
"Indeterminate state legal only in dialogs." ) );
2352 pos.
x = bBox.
GetLeft() - shadowOffset;
2361 wxFAIL_MSG( wxT(
"Indeterminate state legal only in dialogs." ) );
2394 && !shownText.Contains( wxT(
"\n" ) ) )
2402 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache =
nullptr;
2428 switch( aText->
Type() )
2436 showAnchor = !
static_cast<const SCH_LABEL*
>( aText )->IsDangling();
2481 float borderWidth =
getLineWidth( aTextBox, drawingShadows );
2487 bool transparentColor = !drawingShadows && color.
a <= 0.0;
2489 m_gal->SetFillColor( color );
2490 m_gal->SetStrokeColor( color );
2491 m_gal->SetHoverColor( color );
2495 m_gal->SetIsFill(
true );
2496 m_gal->SetIsStroke(
false );
2497 m_gal->SetLineWidth( borderWidth );
2508 m_gal->SetIsFill(
true );
2509 m_gal->SetIsStroke(
false );
2510 m_gal->SetLineWidth( borderWidth );
2517 if( transparentColor )
2544 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache =
nullptr;
2574 if( transparency > 0.0 )
2575 borderColor = borderColor.
WithAlpha( borderColor.
a * ( 1.0 - transparency ) );
2579 borderColor = borderColor.
Mix( bg, 0.5f );
2583 m_gal->SetIsFill(
false );
2584 m_gal->SetIsStroke(
true );
2585 m_gal->SetStrokeColor( borderColor );
2586 m_gal->SetLineWidth( borderWidth );
2596 for(
SHAPE* shape : shapes )
2604 m_gal->DrawLine( a+1, b );
2606 m_gal->DrawLine( a, b );
2610 for(
SHAPE* shape : shapes )
2624 draw( cell, aLayer, aDimmed );
2638 if( lineWidth == 0 )
2647 m_gal->SetIsFill(
false );
2648 m_gal->SetIsStroke(
true );
2649 m_gal->SetStrokeColor( color );
2650 m_gal->SetLineWidth( (
float) lineWidth );
2654 m_gal->DrawLine( ptA, ptB );
2664 m_gal->DrawLine( a+1, b );
2666 m_gal->DrawLine( a, b );
2676 std::function<bool( wxString* )> symbolResolver =
2677 [&]( wxString* token ) ->
bool
2698 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol->
GetRawPins() )
2700 if( shadows ?
pin->IsBrightened() ||
pin->IsSelected() : !
pin->GetOperatingPoint().IsEmpty() )
2710 auto t1 = std::chrono::high_resolution_clock::now();
2713 std::optional<SCH_SHEET_PATH> optSheetPath;
2715 wxString variantName;
2722 "SCH_PAINTER::draw symbol %s: Current sheet path='%s', variant='%s', size=%zu, empty=%d",
2725 optSheetPath->Path().AsString(),
2726 optSheetPath->size(),
2727 optSheetPath->empty() ? 1 : 0 );
2730 SCH_SHEET_PATH* sheetPath = optSheetPath ? &optSheetPath.value() :
nullptr;
2731 bool DNP = aSymbol->
GetDNP( sheetPath, variantName );
2738 if( !drawingShadows ||
eeconfig()->m_Selection.draw_selected_children )
2741 draw( &field, aLayer, DNP );
2760 if( !originalSymbol )
2763 bool usingAlternateSymbol = ( originalSymbol != aSymbol->
GetLibSymbolRef().get()
2766 std::vector<SCH_PIN*> originalPins = originalSymbol->
GetGraphicalPins( unit, bodyStyle );
2768 if( usingAlternateSymbol && originalPins.empty() && bodyStyle > 1 )
2772 auto tCopy1 = std::chrono::high_resolution_clock::now();
2773 LIB_SYMBOL tempSymbol( *originalSymbol,
nullptr,
false );
2774 auto tCopy2 = std::chrono::high_resolution_clock::now();
2776 if( std::chrono::duration_cast<std::chrono::microseconds>( tCopy2 - tCopy1 ).count() > 100 )
2779 std::chrono::duration_cast<std::chrono::microseconds>( tCopy2 - tCopy1 ).count() );
2782 std::vector<SCH_PIN*> tempPins = tempSymbol.
GetGraphicalPins( unit, bodyStyle );
2784 if( usingAlternateSymbol && tempPins.empty() && bodyStyle > 1 )
2793 tempItem.SetFlags( aSymbol->
GetFlags() );
2814 std::vector<SCH_PIN*> symbolPins = aSymbol->
MapLibPins( originalPins, usingAlternateSymbol );
2820 for(
unsigned i = 0; i < tempPins.size(); ++ i )
2822 SCH_PIN* symbolPin = symbolPins[ i ];
2824 SCH_PIN* tempPin = tempPins[ i ];
2837 if( highlightedChain
2853 const wxString effective =
2856 if( effective != original )
2882 for(
unsigned i = 0; i < tempPins.size(); ++i )
2884 SCH_PIN* symbolPin = symbolPins[ i ];
2886 SCH_PIN* tempPin = tempPins[ i ];
2910 margins.
x = std::max( margins.
x * 0.6, margins.
y * 0.3 );
2911 margins.
y = std::max( margins.
y * 0.6, margins.
x * 0.3 );
2918 m_gal->AdvanceDepth();
2919 m_gal->SetIsStroke(
true );
2920 m_gal->SetIsFill(
true );
2921 m_gal->SetStrokeColor( marker_color );
2922 m_gal->SetFillColor( marker_color );
2924 m_gal->DrawSegment( pt1, pt2, strokeWidth );
2925 std::swap( pt1.
x, pt2.
x );
2926 m_gal->DrawSegment( pt1, pt2, strokeWidth );
2938 m_gal->AdvanceDepth();
2939 m_gal->SetIsStroke(
true );
2940 m_gal->SetIsFill(
true );
2941 m_gal->SetStrokeColor( marker_color );
2942 m_gal->SetFillColor( marker_color );
2949 int offset = 2 * strokeWidth;
2958 m_gal->AdvanceDepth();
2959 m_gal->SetFillColor( marker_color );
2963 auto t2 = std::chrono::high_resolution_clock::now();
2965 if( std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count() > 100 )
2968 std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count() );
2993 if( std::find( layers.begin(), layers.end(), aLayer ) == layers.end() )
3013 bool transparentColor = !drawingShadows && color.
a <= 0.0;
3026 if( shownText.IsEmpty() )
3068 float shadowWidth = 0.0f;
3070 if( drawingShadows )
3076 m_gal->SetStrokeColor( color );
3077 m_gal->SetFillColor( color );
3078 m_gal->SetHoverColor( color );
3080 if( transparentColor )
3113 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache =
nullptr;
3160 bool parentMoving = fieldParent && fieldParent->
IsMoving();
3170 else if( aField->
IsSelected() && !parentMoving )
3186 if( !drawingShadows ||
eeconfig()->m_Selection.draw_selected_children )
3189 draw( &field, aLayer,
false );
3200 if( drawingDangling )
3214 bool transparentColor = !drawingShadows && color.
a <= 0.0;
3216 if( !transparentColor )
3218 std::vector<VECTOR2I> pts;
3219 std::deque<VECTOR2D> pts2;
3224 pts2.emplace_back(
VECTOR2D( p.x, p.y ) );
3226 m_gal->SetIsStroke(
true );
3228 m_gal->SetStrokeColor( color );
3230 if( drawingShadows )
3233 m_gal->SetFillColor( color );
3234 m_gal->DrawPolygon( pts2 );
3238 m_gal->SetIsFill(
false );
3239 m_gal->DrawPolyline( pts2 );
3243 draw(
static_cast<const SCH_TEXT*
>( aLabel ), aLayer,
false );
3256 if( !drawingShadows ||
eeconfig()->m_Selection.draw_selected_children )
3259 draw( &field, aLayer,
false );
3270 if( drawingDangling )
3283 draw(
static_cast<const SCH_TEXT*
>( aLabel ), aLayer,
false );
3296 if( !( drawingShadows || drawingDangling ) ||
eeconfig()->m_Selection.draw_selected_children )
3299 draw( &field, aLayer,
false );
3310 if( drawingDangling )
3323 bool transparentColor = !drawingShadows && color.
a <= 0.0;
3325 if( !transparentColor )
3327 std::vector<VECTOR2I> i_pts;
3328 std::deque<VECTOR2D> d_pts;
3332 for(
const VECTOR2I& i_pt : i_pts )
3333 d_pts.emplace_back(
VECTOR2D( i_pt.x, i_pt.y ) );
3335 m_gal->SetIsFill(
true );
3337 m_gal->SetIsStroke(
true );
3339 m_gal->SetStrokeColor( color );
3340 m_gal->DrawPolyline( d_pts );
3343 draw(
static_cast<const SCH_TEXT*
>( aLabel ), aLayer, aDimmed );
3357 if( !drawingShadows ||
eeconfig()->m_Selection.draw_selected_children )
3360 draw( &field, aLayer,
false );
3383 if( !drawingShadows && color.
a <= 0.0 )
3386 std::vector<VECTOR2I> pts;
3387 std::deque<VECTOR2D> pts2;
3392 pts2.emplace_back(
VECTOR2D( p.x, p.y ) );
3394 m_gal->SetIsFill(
false );
3395 m_gal->SetFillColor( color );
3396 m_gal->SetIsStroke(
true );
3398 m_gal->SetStrokeColor( color );
3402 m_gal->DrawLine( pts2[0], pts2[1] );
3403 m_gal->SetIsFill(
true );
3404 m_gal->DrawCircle( pts2[2], ( pts2[2] - pts2[1] ).EuclideanNorm() );
3408 m_gal->DrawLine( pts2[0], pts2[1] );
3409 m_gal->DrawCircle( pts2[2], ( pts2[2] - pts2[1] ).EuclideanNorm() );
3413 m_gal->DrawPolyline( pts2 );
3428 DNP = aSheet->
GetDNP( sheetPath, variant );
3439 if( !drawingShadows ||
eeconfig()->m_Selection.draw_selected_children )
3442 draw( &field, aLayer, DNP );
3445 draw( sheetPin, aLayer, DNP );
3466 if( backgroundColor.
a > 0.0 )
3469 m_gal->SetIsFill(
true );
3470 m_gal->SetIsStroke(
false );
3472 m_gal->DrawRectangle( pos, pos + size );
3480 m_gal->SetIsStroke(
true );
3482 m_gal->SetIsFill(
false );
3484 m_gal->DrawRectangle( pos, pos + size );
3496 margins.
x = std::max( margins.
x * 0.6, margins.
y * 0.3 );
3497 margins.
y = std::max( margins.
y * 0.6, margins.
x * 0.3 );
3504 m_gal->AdvanceDepth();
3505 m_gal->SetIsStroke(
true );
3506 m_gal->SetIsFill(
true );
3510 m_gal->DrawSegment( pt1, pt2, strokeWidth );
3511 std::swap( pt1.
x, pt2.
x );
3512 m_gal->DrawSegment( pt1, pt2, strokeWidth );
3524 m_gal->AdvanceDepth();
3525 m_gal->SetIsStroke(
true );
3526 m_gal->SetIsFill(
true );
3535 int offset = 2 * strokeWidth;
3544 m_gal->AdvanceDepth();
3561 m_gal->SetIsStroke(
true );
3564 m_gal->SetIsFill(
false );
3582 bool drawingBusses = aLayer ==
LAYER_BUS;
3587 bool highlightNetclassColors =
false;
3590 highlightNetclassColors = eeschemaCfg->m_Selection.highlight_netclass_colors;
3592 if( !highlightNetclassColors && drawingNetColorHighlights )
3595 if(
m_schSettings.m_OverrideItemColors && drawingNetColorHighlights )
3623 if( highlightNetclassColors )
3628 else if( drawingBusses )
3632 if( drawingNetColorHighlights )
3642 if( drawingDangling )
3644 m_gal->SetIsFill(
false );
3645 m_gal->SetIsStroke(
true );
3660 draw( &line, aLayer );
3673 auto t1 = std::chrono::high_resolution_clock::now();
3683 if( img_scale != 1.0 )
3693 imageAlpha = std::max( imageAlpha, 0.1 );
3704 m_gal->SetIsStroke(
true );
3705 m_gal->SetStrokeColor( color );
3707 m_gal->SetIsFill(
false );
3715 bm_size.
x /= img_scale;
3716 bm_size.
y /= img_scale;
3717 const VECTOR2D origin( -bm_size.
x / 2.0, -bm_size.
y / 2.0 );
3720 m_gal->DrawRectangle( origin,
end );
3725 auto t2 = std::chrono::high_resolution_clock::now();
3727 if( std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count() > 100 )
3730 std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count() );
3749 m_gal->SetIsFill( !drawingShadows );
3750 m_gal->SetFillColor( color );
3751 m_gal->SetIsStroke( drawingShadows );
3753 m_gal->SetStrokeColor( color );
3758 m_gal->DrawPolygon( polygon );
3768 const bool drawingShadows =
false;
3789 m_gal->SetStrokeColor( color );
3797 m_gal->DrawLine( topLeft, topLeft + width );
3798 m_gal->DrawLine( topLeft + width, topLeft + width + height );
3799 m_gal->DrawLine( topLeft + width + height, topLeft + height );
3800 m_gal->DrawLine( topLeft + height, topLeft );
3804 if(
name.IsEmpty() )
3808 int scaledSize = abs(
KiROUND(
m_gal->GetScreenWorldMatrix().GetScale().x * ptSize ) );
3809 int unscaledSize =
schIUScale.MilsToIU( ptSize );
3812 int textSize = ( scaledSize + ( unscaledSize * 2 ) ) / 3;
3818 m_gal->DrawLine( topLeft, topLeft - titleHeight );
3819 m_gal->DrawLine( topLeft - titleHeight, topLeft + width - titleHeight );
3820 m_gal->DrawLine( topLeft + width - titleHeight, topLeft + width );
3837 LINE_STYLE aLineStyle,
bool aDrawDirectLine,
int aWidth )
3839 if( aDrawDirectLine )
3841 m_gal->DrawLine( aStartPoint, aEndPoint );
constexpr EDA_IU_SCALE schIUScale
std::optional< BOX2I > OPT_BOX2I
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Generic cubic Bezier representation.
constexpr const Vec & GetPosition() const
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr const Vec GetEnd() const
constexpr coord_type GetY() const
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr coord_type GetX() const
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr const Vec & GetOrigin() const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr void Offset(coord_type dx, coord_type dy)
constexpr coord_type GetBottom() const
Represent basic circle geometry with utility geometry functions.
VECTOR2I Center
Public to make access simpler.
int Radius
Public to make access simpler.
bool IsHorizontal() const
A base class for most all the KiCad significant classes used in schematics and boards.
VECTOR2I GetRolloverPos() const
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)
void SetNetHighlighted(bool aHighlighted)
EDA_ITEM * GetParent() const
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
bool IsBrightened() const
bool IsNetHighlighted() const
Net highlighting must not clear brightening owned by find or picker tools.
bool IsForceVisible() const
EDA_ITEM_FLAGS GetFlags() const
EDA_ANGLE GetAngle() const
static bool ShortenSegmentForEndings(VECTOR2I &aStart, VECTOR2I &aEnd, const LINE_ENDING &aStartEnding, const LINE_ENDING &aEndEnding, int aLineWidth)
Shorten a segment body for line endings.
int GetEllipseMinorRadius() const
const VECTOR2I & GetEllipseCenter() const
EDA_ANGLE GetEllipseEndAngle() const
FILL_T GetFillMode() const
int GetEllipseMajorRadius() const
void GetEndingTangents(EDA_ANGLE &aStartTangent, EDA_ANGLE &aEndTangent, int aLineWidth=0) const
Compute outward-facing tangent angles at the start and end of the shape.
EDA_ANGLE GetEllipseRotation() const
std::vector< SHAPE * > MakeEffectiveShapesForStroking(int aLineWidth=-1) const
Make a set of SHAPE objects to hand to STROKE_PARAMS::Stroke().
bool GetShortenedBodyPolyPoints(const SHAPE_LINE_CHAIN &aOutline, int aOutlineIdx, std::vector< VECTOR2I > &aPoints, int aLineWidth) const
Copy an outline and apply line-ending body shortening when applicable.
const std::vector< SEG > & GetHatchLines() const
bool GetLineEndingEndpoints(VECTOR2I &aStartPoint, VECTOR2I &aEndPoint) const
Return the source endpoints used to place line endings.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
COLOR4D GetFillColor() const
EDA_ANGLE GetEllipseStartAngle() const
const LINE_ENDING & GetStartEnding() const
const LINE_ENDING & GetEndEnding() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
COLOR4D GetTextColor() const
virtual VECTOR2I GetTextPos() const
void SetActiveUrl(const wxString &aUrl) const
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual bool IsVisible() 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
virtual bool HasHyperlink() const
wxString GetHyperlink() const
virtual KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
virtual EDA_ANGLE GetTextAngle() const
const TEXT_ATTRIBUTES & GetAttributes() const
virtual void SetText(const wxString &aText)
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, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=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, std::optional< VECTOR2I > aMousePos=std::nullopt, wxString *aActiveUrl=nullptr) 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 & Invert()
Makes the color inverted, alpha remains the same.
COLOR4D & Darken(double aFactor)
Makes the color darker by a given factor.
std::shared_ptr< wxString > m_text
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.
Attribute save/restore for GAL attributes.
Abstract interface for drawing on a 2D-surface.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void Rotate(double aAngle)
Rotate the context.
void SetVerticalJustify(const GR_TEXT_V_ALIGN_T aVerticalJustify)
void SetHorizontalJustify(const GR_TEXT_H_ALIGN_T aHorizontalJustify)
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void Restore()
Restore the context.
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.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
void SetGlyphSize(const VECTOR2I aSize)
virtual void DrawGlyphs(const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs)
Draw polygons representing font glyphs.
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle)
Draw an arc.
bool WorldScaleBelow(double aLimit) const
Tell whether the world scale is below a limit.
virtual void BitmapText(const wxString &aText, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle)
Draw a text using a bitmap font.
virtual void Save()
Save the context.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
PAINTER(GAL *aGal)
Initialize this object for painting on any of the polymorphic GRAPHICS_ABSTRACTION_LAYER* derivatives...
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.
void drawPinDanglingIndicator(const SCH_PIN &aPin, const COLOR4D &aColor, bool aDrawingShadows, bool aBrightened)
float getTextThickness(const SCH_ITEM *aItem) const
void drawLocalPowerIcon(const VECTOR2D &aPos, double aSize, bool aRotate, const COLOR4D &aColor, bool aDrawingShadows, bool aBrightened)
Draw an local power pin indicator icon.
float getShadowWidth(bool aForHighlight) const
COLOR4D getRenderColor(const SCH_ITEM *aItem, int aLayer, bool aDrawingShadows, bool aDimmed=false, bool aIgnoreNets=false) const
int externalPinDecoSize(const SCH_PIN &aPin)
KIFONT::FONT * getFont(const EDA_TEXT *aText) const
void draw(const EDA_ITEM *, int, bool aDimmed)
wxString expandLibItemTextVars(const wxString &aSourceText, const SCH_SYMBOL *aSymbolContext)
static std::vector< KICAD_T > g_ScaledSelectionTypes
bool renderAsBitmap(const SCH_ITEM *aItem) const
Whether a text item is drawn as bitmap text at this zoom, see SCH_ITEM::RenderAsBitmap().
void drawLine(const VECTOR2I &aStartPoint, const VECTOR2I &aEndPoint, LINE_STYLE aLineStyle, bool aDrawDirectLine=false, int aWidth=0)
int getOperatingPointTextSize() const
float getLineWidth(const SCH_ITEM *aItem, bool aDrawingShadows, bool aDrawingWireColorHighlights=false) const
void triLine(const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
std::set< const SCH_PIN * > m_netChainTerminalPins
Temporary pins standing in for the highlighted chain's terminals during a symbol draw.
SCH_RENDER_SETTINGS m_schSettings
void drawAnchor(const VECTOR2I &aPos, bool aDrawingShadows)
Draw anchor indicating the anchor position of text objects, local labels, or fields.
bool nonCached(const EDA_ITEM *aItem)
Indicates the item is drawn on a non-cached layer in OpenGL.
void drawDanglingIndicator(const VECTOR2I &aPos, const COLOR4D &aColor, int aWidth, bool aDangling, bool aDrawingShadows, bool aBrightened)
Draw the target (an open square) for a wire or label which has no connection or is being moved.
void drawItemBoundingBox(const EDA_ITEM *aItem)
int internalPinDecoSize(const SCH_PIN &aPin)
bool isUnitAndConversionShown(const SCH_ITEM *aItem) const
An abstract base class for deriving all objects that can be added to a VIEW.
double GetForcedTransparency() const
wxString AsString() const
Define a library symbol object.
static LIB_SYMBOL * GetDummy()
Return a dummy LIB_SYMBOL, used when one is missing in the schematic.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const override
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
void Draw(KIGFX::GAL &aGal, const VECTOR2I &aPoint, const EDA_ANGLE &aTangent, double aLineWidth, const KIGFX::COLOR4D &aColor) const
LINE_ENDING_STYLE GetStyle() const
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.
A pin layout helper is a class that manages the layout of the parts of a pin on a schematic symbol:
OPT_BOX2I GetAltIconBBox()
Get the box of the alt mode icon, if there is one.
OPT_BOX2I GetPinNumberBBox()
Get the bounding box of the pin number, if there is one.
std::optional< TEXT_INFO > GetPinNameInfo(int aShadowWidth)
Get the text info for the pin name.
std::optional< TEXT_INFO > GetPinElectricalTypeInfo(int aShadowWidth)
CIRCLE GetDanglingIndicator() const
Gets the dangling indicator geometry for this pin, if the pin were to be dangling.
std::optional< TEXT_INFO > GetPinNumberInfo(int aShadowWidth)
void SetRenderParameters(int aNameThickness, int aNumberThickness, bool aShowElectricalType, bool aShowAltIcons)
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
EDA_ANGLE GetOrientation() const
double GetOpacity() const
const BITMAP_BASE & GetImage() const
Get the underlying image.
double GetImageScale() const
A round rectangle shape, based on a rectangle and a radius.
void TransformToPolygon(SHAPE_POLY_SET &aBuffer, int aMaxError) const
Get the polygonal representation of the roundrect.
double GetHopOverScale()
Accessor that computes the current hop-over size.
SCHEMATIC_SETTINGS & Settings() const
SCH_SCREEN * GetCurrentScreen() const
Object to handle a bitmap image that can be inserted in a schematic.
VECTOR2I GetPosition() const override
REFERENCE_IMAGE & GetReferenceImage()
Base class for a bus or wire entry.
bool IsStartDangling() const
VECTOR2I GetPosition() const override
bool IsEndDangling() const
virtual STROKE_PARAMS GetStroke() const override
int GetPenWidth() const override
LINE_STYLE GetEffectiveLineStyle() const
Class for a wire to bus entry.
Marks the canvas reads of this thread, which are item drawing and view bounds.
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.
virtual bool IsDangling() const override
Determines dangling state from connectivity and cached connected rule areas.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
VECTOR2I GetPosition() const override
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString, int aDepth=0) const
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
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...
A set of SCH_ITEMs (i.e., without duplicates).
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
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,...
const SYMBOL * GetParentSymbol() const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
bool IsConnectivityDirty() const
std::optional< wxString > GetConnectionName(const SCH_SHEET_PATH *aSheet=nullptr, bool aLocal=false, bool aIgnoreSheet=false) const
Return the active connection name; absent for missing or stale published rows.
double BitmapWorldScaleLimit() const
The world scale below which the item is drawn as bitmap text, or 0 if it never is.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
wxString GetClass() const override
Return the class name.
const KIFONT::METRICS & GetFontMetrics() const
bool HasBusConnection(const SCH_SHEET_PATH *aSheet=nullptr) const
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.
int GetEffectiveDiameter() const
VECTOR2I GetPosition() const override
bool IsDangling() const override
COLOR4D GetLabelColor() const
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)
std::vector< VECTOR3I > BuildWireWithHopShape(const SCH_SCREEN *aScreen, double aArcRadius) const
For wires only: build the list of points to draw the shape using segments and 180 deg arcs Points are...
bool IsWire() const
Return true if the line is a wire.
bool IsStartDangling() const
void SetLineWidth(const int aSize)
LINE_STYLE GetEffectiveLineStyle() const
const LINE_ENDING & GetEndEnding() const
VECTOR2I GetMidPoint() const
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
bool IsEndDangling() const
bool IsBus() const
Return true if the line is a bus.
void SetLineStyle(const LINE_STYLE aStyle)
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
bool IsGraphicLine() const
Return if the line is a graphic (non electrical line)
void SetLineColor(const KIGFX::COLOR4D &aColor)
const LINE_ENDING & GetStartEnding() const
void SetEndPoint(const VECTOR2I &aPosition)
const wxString & GetOperatingPoint() const
SCH_LAYER_ID GetColorLayer() const
VECTOR2I GetPosition() const override
A net chain is a collection of nets that are connected together through passive components.
bool IsTerminal(const KIID &aPin, const KIID_PATH &aSheet) const
VECTOR2I GetPosition() const override
int GetNumberTextSize() const
void SetNumber(const wxString &aNumber)
const wxString & GetOperatingPoint() const
void SetName(const wxString &aName)
bool IsGlobalPower() const
Return whether this pin forms a global power connection: i.e., is part of a power symbol and of type ...
VECTOR2I GetPinRoot() const
void SetFlipStackedTextSide(bool aFlip)
bool IsDangling() const override
void SetShape(GRAPHIC_PINSHAPE aShape)
VECTOR2I GetPosition() const override
int GetNameTextSize() const
const wxString & GetShownName() const
PIN_LAYOUT_CACHE & GetLayoutCache() const
Get the layout cache associated with this pin.
const wxString & GetRemappedFromNumber() const
Transient, render-only original pin number for a pad-remapped pin (issue #2282).
void SetOperatingPoint(const wxString &aText)
void SetType(ELECTRICAL_PINTYPE aType)
void SetRemappedFromNumber(const wxString &aNumber)
wxString GetEffectivePadNumber(const SCH_SHEET_PATH &aSheet, const wxString &aVariantName, const LIB_ID &aFootprintLibId, const std::set< wxString > *aFootprintPadNumbers, PAD_RESOLUTION *aState=nullptr) const
Resolve the footprint pad number this symbol pin lands on (issue #2282).
const wxString & GetShownNumber() const
GRAPHIC_PINSHAPE GetShape() const
ELECTRICAL_PINTYPE GetType() const
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
void UpdateHatching() const override
LINE_STYLE GetEffectiveLineStyle() const
int GetHatchLineWidth() const override
STROKE_PARAMS GetStroke() const override
VECTOR2I GetPosition() const override
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
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()
Return a reference to the vector holding the sheet's fields.
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
VECTOR2I GetPosition() const override
const BOX2I GetBodyBoundingBox() const
Return a bounding box for the sheet body but not the fields.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
KIGFX::COLOR4D GetBorderColor() const
bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flags.
std::vector< SCH_SHEET_PIN * > & GetPins()
KIGFX::COLOR4D GetBackgroundColor() const
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
BOX2I GetBodyAndPinsBoundingBox() const override
Return a bounding box for the symbol body and pins but not the fields.
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
std::vector< SCH_PIN * > MapLibPins(const std::vector< SCH_PIN * > &aLibPins, bool aByNumber) const
Map pins of an effective library symbol to this symbol's instance pins.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
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.
const LIB_SYMBOL * GetEffectiveLibSymbol(const SCH_SHEET_PATH *aPath=nullptr) const
Return the library symbol to use for rendering and bounding box calculations.
static void BuildLocalPowerIconShape(std::vector< SCH_SHAPE > &aShapeList, const VECTOR2D &aPos, double aSize, double aLineWidth, bool aHorizontal)
Build the local power pin indicator icon shape, at coordinate aPos.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
int GetOrientation() const override
Get the display symbol orientation.
bool IsSymbolLikePowerLocalLabel() const
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
BOX2I GetBodyBoundingBox() const override
Return a bounding box for the symbol body but not the pins or fields.
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flag.
std::vector< SCH_TABLECELL * > GetCells() const
void DrawBorders(const std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2, const STROKE_PARAMS &aStroke)> &aCallback) const
virtual wxString GetShownText(const RENDER_SETTINGS *aSettings, const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, int aDepth=0) const
VECTOR2I GetDrawPos() const override
VECTOR2I GetPosition() const override
VECTOR2I GetOffsetToMatchSCH_FIELD(SCH_RENDER_SETTINGS *aRenderSettings) const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, 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...
EDA_ANGLE GetCentralAngle() const
Get the "central angle" of the arc - this is the angle at the point of the "pie slice".
EDA_ANGLE GetStartAngle() const
const VECTOR2I & GetCenter() const
SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError) const
Build a polyline approximation of the ellipse or arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
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)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
void Fracture(bool aSimplify=true)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
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.
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
const TRANSFORM & GetTransform() const
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, RESOLUTION_CONTEXT aContext)
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
#define DANGLING_SYMBOL_SIZE
The size of the rectangle indicating an unconnected wire or label.
#define DEFAULT_LINE_WIDTH_MILS
The default line width in mils. (can be changed in preference menu)
#define UNSELECTED_END_SIZE
The size of the rectangle indicating a connected, unselected wire end.
#define TEXT_ANCHOR_SIZE
The size of the rectangle indicating the anchor of a text object (including fields)
static constexpr EDA_ANGLE ANGLE_0
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
@ FILLED_WITH_BG_BODYCOLOR
@ FILLED_SHAPE
Fill with object color.
#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.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
int GetPenSizeForDemiBold(int aTextSize)
int GetPenSizeForNormal(int aTextSize)
int ClampTextPenSize(int aPenSize, int aSize, bool aStrict)
Pen width should not allow characters to become cluttered up in their own fatness.
const wxChar *const traceSchPainter
Flag to enable debug output of schematic painter operations.
@ LAYER_DRAW_BITMAPS
Draw images.
SCH_LAYER_ID
Eeschema drawing layers.
@ LAYER_SHAPES_BACKGROUND
@ LAYER_EXCLUDED_FROM_SIM
@ LAYER_NET_COLOR_HIGHLIGHT
@ LAYER_DEVICE_BACKGROUND
@ LAYER_SELECTION_SHADOWS
@ LAYER_SCHEMATIC_BACKGROUND
#define UNIMPLEMENTED_FOR(type)
MATRIX3x3< double > MATRIX3x3D
The Cairo implementation of the graphics abstraction layer.
static void drawCache(KIGFX::GAL &aGal, std::vector< std::unique_ptr< KIFONT::GLYPH > > *aCache, float aStrokeWidth, float aShadowWidth)
static void bitmapText(KIGFX::GAL &aGal, const wxString &aText, const VECTOR2D &aPosition, const TEXT_ATTRIBUTES &aAttrs)
EESCHEMA_SETTINGS * eeconfig()
static void drawText(KIGFX::GAL &aGal, const wxString &aText, const VECTOR2D &aPosition, const TEXT_ATTRIBUTES &aAttrs, float aShadowWidth, const KIFONT::METRICS &aFontMetrics, std::optional< VECTOR2I > aMousePos=std::nullopt, wxString *aActiveUrl=nullptr)
static bool symbolDrawsOnOverlay(const SCH_SYMBOL *aSymbol, int aLayer)
static void knockoutText(KIGFX::GAL &aGal, const wxString &aText, const VECTOR2D &aPosition, const TEXT_ATTRIBUTES &aAttrs, const KIFONT::METRICS &aFontMetrics)
static void drawAltPinModesIcon(GAL &aGal, const VECTOR2D &aPos, double aSize, bool aBaseSelected, bool aRotate, int aExtraLineWidth, const COLOR4D &aColor)
Draw an alternate pin mode indicator icon.
static bool isFieldsLayer(int aLayer)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ PT_NC
not connected (must be left open)
#define TARGET_BUSENTRY_RADIUS
Class to handle a set of SCH_ITEMs.
#define BITMAP_FONT_SIZE_THRESHOLD
#define TARGET_PIN_RADIUS
Utility functions for working with shapes.
wxString GetDefaultVariantName()
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
int PrintableCharCount(const wxString &aString)
Return the number of printable (ie: non-formatting) chars.
LINE_STYLE
Dashed line types.
bool show_remapped_pin_numbers
int highlight_netclass_colors_thickness
GR_TEXT_H_ALIGN_T m_HAlign
GR_TEXT_V_ALIGN_T m_VAlign
@ VALUE
Field Value of part, i.e. "3.3K".
KIBIS top(path, &reporter)
const SHAPE_LINE_CHAIN chain
@ GR_TEXT_H_ALIGN_INDETERMINATE
wxLogTrace helper definitions.
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.
constexpr int sign(T val)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D