7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 11:01:41 +00:00

Fix drawing of selected/highlighted local power port labels.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20262
This commit is contained in:
Jeff Young 2025-03-07 20:32:49 +00:00
parent eedd811c0a
commit 95d8634401
2 changed files with 45 additions and 39 deletions

View File

@ -778,22 +778,26 @@ void SCH_PAINTER::drawPinDanglingIndicator( const SCH_PIN& aPin, const COLOR4D&
/**
* Draw an local power pin indicator icon.
*/
static void drawLocalPowerIcon( GAL& aGal, const VECTOR2D& aPos, double aSize, bool aRotate,
const COLOR4D& aColor )
void SCH_PAINTER::drawLocalPowerIcon( const VECTOR2D& aPos, double aSize, bool aRotate,
const COLOR4D& aColor, bool aDrawingShadows,
bool aBrightened )
{
aGal.Save();
m_gal->Save();
aGal.Translate( aPos );
m_gal->Translate( aPos );
if( aRotate )
{
aGal.Rotate( ANGLE_270.AsRadians() );
}
m_gal->Rotate( ANGLE_270.AsRadians() );
aGal.SetIsFill( false );
aGal.SetIsStroke( true );
aGal.SetLineWidth( KiROUND( aSize / 10.0 ) );
aGal.SetStrokeColor( aColor );
double lineWidth = aSize / 10.0;
if( aDrawingShadows )
lineWidth += getShadowWidth( aBrightened );
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
m_gal->SetLineWidth( lineWidth );
m_gal->SetStrokeColor( aColor );
double x_right = aSize / 1.6180339887;
double x_middle = x_right / 2.0;
@ -808,15 +812,15 @@ static void drawLocalPowerIcon( GAL& aGal, const VECTOR2D& aPos, double aSize, b
VECTOR2D rightSideAnchorPt1 = VECTOR2D{ x_right, -aSize / 2.5 };
VECTOR2D rightSideAnchorPt2 = VECTOR2D{ x_right, -aSize * 1.15 };
aGal.DrawCurve( bottomPt, bottomAnchorPt, leftSideAnchorPt1, leftPt );
aGal.DrawCurve( leftPt, leftSideAnchorPt2, rightSideAnchorPt2, rightPt );
aGal.DrawCurve( rightPt, rightSideAnchorPt1, bottomAnchorPt, bottomPt );
m_gal->DrawCurve( bottomPt, bottomAnchorPt, leftSideAnchorPt1, leftPt );
m_gal->DrawCurve( leftPt, leftSideAnchorPt2, rightSideAnchorPt2, rightPt );
m_gal->DrawCurve( rightPt, rightSideAnchorPt1, bottomAnchorPt, bottomPt );
aGal.SetIsFill( true );
aGal.SetFillColor( aColor );
aGal.DrawCircle( ( leftPt + rightPt ) / 2.0, aSize / 15.0 );
m_gal->SetIsFill( true );
m_gal->SetFillColor( aColor );
m_gal->DrawCircle( ( leftPt + rightPt ) / 2.0, aSize / 15.0 );
aGal.Restore();
m_gal->Restore();
};
@ -2533,30 +2537,30 @@ void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer, bool aDimmed )
const_cast<SCH_FIELD*>( aField )->ClearFlags( IS_SHOWN_AS_BITMAP );
}
}
if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
{
SCH_SYMBOL* parent = static_cast<SCH_SYMBOL*>( aField->GetParent() );
bool rotated = !orient.IsHorizontal() && !aField->CanAutoplace();
VECTOR2D pos;
double size = bbox.GetHeight() / 1.5;
if( rotated )
{
SCH_SYMBOL* parent = static_cast<SCH_SYMBOL*>( aField->GetParent() );
bool rotated = !orient.IsHorizontal() && !aField->CanAutoplace();
VECTOR2D pos;
double size = bbox.GetHeight() / 1.5;
if( rotated )
{
pos = VECTOR2D( bbox.GetRight() - bbox.GetWidth() / 6.0,
bbox.GetBottom() + bbox.GetWidth() / 2.0 );
size = bbox.GetWidth() / 1.5;
}
else
{
pos = VECTOR2D( bbox.GetLeft() - bbox.GetHeight() / 2.0,
bbox.GetBottom() - bbox.GetHeight() / 6.0 );
}
if( parent->IsSymbolLikePowerLocalLabel() )
drawLocalPowerIcon( *m_gal, pos, size, rotated, m_gal->GetStrokeColor() );
pos = VECTOR2D( bbox.GetRight() - bbox.GetWidth() / 6.0,
bbox.GetBottom() + bbox.GetWidth() / 2.0 );
size = bbox.GetWidth() / 1.5;
}
else
{
pos = VECTOR2D( bbox.GetLeft() - bbox.GetHeight() / 2.0,
bbox.GetBottom() - bbox.GetHeight() / 6.0 );
}
if( parent->IsSymbolLikePowerLocalLabel() )
drawLocalPowerIcon( pos, size, rotated, color, drawingShadows, aField->IsBrightened() );
}
// Draw anchor or umbilical line

View File

@ -104,6 +104,8 @@ private:
void drawPinDanglingIndicator( const SCH_PIN& aPin, const COLOR4D& aColor, bool aDrawingShadows,
bool aBrightened );
void drawLocalPowerIcon( const VECTOR2D& aPos, double aSize, bool aRotate,
const COLOR4D& aColor, bool aDrawingShadows, bool aBrightened );
/**
* Draw the target (an open square) for a wire or label which has no connection or is
* being moved.