Eeschema, directive labels: fix some issues:
- honor mirroring of fields attached to labels (all types) - fix incorrect orientation of the graphic shape of SCH_DIRECTIVE_LABEL items after mirroring the item. Fixes #14758 https://gitlab.com/kicad/code/kicad/issues/14758
This commit is contained in:
parent
27afd22bbf
commit
898d88cc11
|
@ -374,6 +374,34 @@ void SCH_LABEL_BASE::Rotate90( bool aClockwise )
|
|||
}
|
||||
|
||||
|
||||
void SCH_LABEL_BASE::MirrorSpinStyle( bool aLeftRight )
|
||||
{
|
||||
SCH_TEXT::MirrorSpinStyle( aLeftRight );
|
||||
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( ( aLeftRight && field.GetTextAngle().IsHorizontal() )
|
||||
|| ( !aLeftRight && field.GetTextAngle().IsVertical() ) )
|
||||
{
|
||||
if( field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
|
||||
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
|
||||
else
|
||||
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
}
|
||||
|
||||
VECTOR2I pos = field.GetTextPos();
|
||||
VECTOR2I delta = (VECTOR2I)GetPosition() - pos;
|
||||
|
||||
if( aLeftRight )
|
||||
pos.x = GetPosition().x + delta.x;
|
||||
else
|
||||
pos.y = GetPosition().y + delta.y;
|
||||
|
||||
field.SetTextPos( pos );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SCH_LABEL_BASE::IncrementLabel( int aIncrement )
|
||||
{
|
||||
wxString text = GetText();
|
||||
|
@ -1163,6 +1191,37 @@ int SCH_DIRECTIVE_LABEL::GetPenWidth() const
|
|||
}
|
||||
|
||||
|
||||
void SCH_DIRECTIVE_LABEL::MirrorSpinStyle( bool aLeftRight )
|
||||
{
|
||||
// The "text" is in fact a graphic shape. For a horizontal "text", it looks like a
|
||||
// vertical shape (like a text reduced to only "I" letter).
|
||||
// So the mirroring is not exactly similar to a SCH_TEXT item
|
||||
SCH_TEXT::MirrorSpinStyle( !aLeftRight );
|
||||
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( ( aLeftRight && field.GetTextAngle().IsHorizontal() )
|
||||
|| ( !aLeftRight && field.GetTextAngle().IsVertical() ) )
|
||||
{
|
||||
if( field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
|
||||
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
|
||||
else
|
||||
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
}
|
||||
|
||||
VECTOR2I pos = field.GetTextPos();
|
||||
VECTOR2I delta = (VECTOR2I)GetPosition() - pos;
|
||||
|
||||
if( aLeftRight )
|
||||
pos.x = GetPosition().x + delta.x;
|
||||
else
|
||||
pos.y = GetPosition().y + delta.y;
|
||||
|
||||
field.SetTextPos( pos );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_DIRECTIVE_LABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings,
|
||||
std::vector<VECTOR2I>& aPoints,
|
||||
const VECTOR2I& aPos ) const
|
||||
|
|
|
@ -121,6 +121,8 @@ public:
|
|||
void Rotate( const VECTOR2I& aCenter ) override;
|
||||
void Rotate90( bool aClockwise ) override;
|
||||
|
||||
void MirrorSpinStyle( bool aLeftRight ) override;
|
||||
|
||||
void SetPosition( const VECTOR2I& aPosition ) override;
|
||||
|
||||
void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override;
|
||||
|
@ -330,6 +332,8 @@ public:
|
|||
|
||||
bool AutoRotateOnPlacementSupported() const override { return false; }
|
||||
|
||||
void MirrorSpinStyle( bool aLeftRight ) override;
|
||||
|
||||
private:
|
||||
int m_pinLength;
|
||||
int m_symbolSize;
|
||||
|
|
Loading…
Reference in New Issue