Implemented flip for tuning patterns.

This commit is contained in:
Sven Pauli 2024-06-01 09:50:49 +02:00 committed by Jeff Young
parent 4a01f322ff
commit c7ad5efbed
3 changed files with 46 additions and 6 deletions

View File

@ -35,6 +35,7 @@
#include <dialogs/dialog_unit_entry.h>
#include <collectors.h>
#include <scoped_set_reset.h>
#include <core/mirror.h>
#include <board_design_settings.h>
#include <drc/drc_engine.h>
@ -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();

View File

@ -23,6 +23,8 @@
*/
#include <pcb_generator.h>
#include <core/mirror.h>
#include <board.h>
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 )
{

View File

@ -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;