From c7ad5efbed36397aa3ac3cb5fd41c15fdba72b6b Mon Sep 17 00:00:00 2001 From: Sven Pauli Date: Sat, 1 Jun 2024 09:50:49 +0200 Subject: [PATCH] Implemented flip for tuning patterns. --- pcbnew/generators/pcb_tuning_pattern.cpp | 28 +++++++++++++++++++----- pcbnew/pcb_generator.cpp | 20 +++++++++++++++++ pcbnew/pcb_generator.h | 4 ++++ 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/pcbnew/generators/pcb_tuning_pattern.cpp b/pcbnew/generators/pcb_tuning_pattern.cpp index 870a55a980..47b745229e 100644 --- a/pcbnew/generators/pcb_tuning_pattern.cpp +++ b/pcbnew/generators/pcb_tuning_pattern.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -289,12 +290,10 @@ public: void Move( const VECTOR2I& aMoveVector ) override { - m_origin += aMoveVector; - m_end += aMoveVector; - if( !this->HasFlag( IN_EDIT ) ) { - PCB_GROUP::Move( aMoveVector ); + PCB_GENERATOR::Move( aMoveVector ); + m_end += aMoveVector; if( m_baseLine ) m_baseLine->Move( aMoveVector ); @@ -308,9 +307,8 @@ public: { if( !this->HasFlag( IN_EDIT ) ) { - RotatePoint( m_origin, aRotCentre, aAngle ); + PCB_GENERATOR::Rotate( aRotCentre, aAngle ); RotatePoint( m_end, aRotCentre, aAngle ); - PCB_GROUP::Rotate( aRotCentre, aAngle ); if( m_baseLine ) m_baseLine->Rotate( aAngle, aRotCentre ); @@ -320,6 +318,24 @@ public: } } + void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override + { + if( !this->HasFlag( IN_EDIT ) ) + { + PCB_GENERATOR::Flip( aCentre, aFlipLeftRight ); + if( aFlipLeftRight ) + MIRROR( m_end.x, aCentre.x ); + else + MIRROR( m_end.y, aCentre.y ); + + if( m_baseLine ) + m_baseLine->Mirror( aFlipLeftRight, !aFlipLeftRight, aCentre ); + + if( m_baseLineCoupled ) + m_baseLineCoupled->Mirror( aFlipLeftRight, !aFlipLeftRight, aCentre ); + } + } + const BOX2I GetBoundingBox() const override { return getOutline().BBox(); diff --git a/pcbnew/pcb_generator.cpp b/pcbnew/pcb_generator.cpp index 91d455c2f4..861ce1d403 100644 --- a/pcbnew/pcb_generator.cpp +++ b/pcbnew/pcb_generator.cpp @@ -23,6 +23,8 @@ */ #include +#include +#include PCB_GENERATOR::PCB_GENERATOR( BOARD_ITEM* aParent, PCB_LAYER_ID aLayer ) : @@ -126,6 +128,24 @@ void PCB_GENERATOR::Move( const VECTOR2I& aMoveVector ) PCB_GROUP::Move( aMoveVector ); } +void PCB_GENERATOR::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) +{ + RotatePoint( m_origin, aRotCentre, aAngle ); + + PCB_GROUP::Rotate( aRotCentre, aAngle ); +} + +void PCB_GENERATOR::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) +{ + if( aFlipLeftRight ) + MIRROR( m_origin.x, aCentre.x ); + else + MIRROR( m_origin.y, aCentre.y ); + + SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); + + PCB_GROUP::Flip( aCentre, aFlipLeftRight ); +} bool PCB_GENERATOR::AddItem( BOARD_ITEM* aItem ) { diff --git a/pcbnew/pcb_generator.h b/pcbnew/pcb_generator.h index d95bf6ddbb..6fb0577b68 100644 --- a/pcbnew/pcb_generator.h +++ b/pcbnew/pcb_generator.h @@ -83,6 +83,10 @@ public: void Move( const VECTOR2I& aMoveVector ) override; + void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override; + + void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override; + bool AddItem( BOARD_ITEM* aItem ) override; LSET GetLayerSet() const override;