mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-14 17:19:35 +00:00
Pcbnew: Add differential and single line length/skew mirroring
ADDED: Added functionality for mirroring differential and single line length, as well as skew adjustment elements. Fixes https://gitlab.com/kicad/code/kicad/issues/18469
This commit is contained in:
parent
5e3c9334cc
commit
260014710a
@ -360,6 +360,14 @@ public:
|
||||
*/
|
||||
virtual void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection );
|
||||
|
||||
/**
|
||||
* Mirror this object relative to a given horizontal axis the layer is not changed.
|
||||
*
|
||||
* @param aCentre the mirror point.
|
||||
* @param aMirrorAroundXAxis mirror across X axis instead of Y (the default).
|
||||
*/
|
||||
virtual void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection );
|
||||
|
||||
/**
|
||||
* Perform any normalization required after a user rotate and/or flip.
|
||||
*/
|
||||
|
@ -365,6 +365,12 @@ void BOARD_ITEM::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ITEM::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
|
||||
{
|
||||
wxMessageBox( wxT( "virtual BOARD_ITEM::Mirror used, should not occur" ), GetClass() );
|
||||
}
|
||||
|
||||
|
||||
wxString BOARD_ITEM::GetParentAsString() const
|
||||
{
|
||||
if( FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( m_parent ) )
|
||||
|
@ -338,13 +338,17 @@ public:
|
||||
{
|
||||
PCB_GENERATOR::Flip( aCentre, aFlipDirection );
|
||||
|
||||
MIRROR( m_end, aCentre, aFlipDirection );
|
||||
baseMirror( aCentre, aFlipDirection );
|
||||
}
|
||||
}
|
||||
|
||||
if( m_baseLine )
|
||||
m_baseLine->Mirror( aCentre, aFlipDirection );
|
||||
void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override
|
||||
{
|
||||
if( !this->HasFlag( IN_EDIT ) )
|
||||
{
|
||||
PCB_GENERATOR::Mirror( aCentre, aFlipDirection );
|
||||
|
||||
if( m_baseLineCoupled )
|
||||
m_baseLineCoupled->Mirror( aCentre, aFlipDirection );
|
||||
baseMirror( aCentre, aFlipDirection );
|
||||
}
|
||||
}
|
||||
|
||||
@ -511,6 +515,26 @@ protected:
|
||||
|
||||
SHAPE_LINE_CHAIN getOutline() const;
|
||||
|
||||
void baseMirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
|
||||
{
|
||||
PCB_GENERATOR::baseMirror( aCentre, aFlipDirection );
|
||||
|
||||
if( m_baseLine )
|
||||
{
|
||||
m_baseLine->Mirror( aCentre, aFlipDirection );
|
||||
m_origin = m_baseLine->CPoint( 0 );
|
||||
m_end = m_baseLine->CPoint( -1 );
|
||||
}
|
||||
|
||||
if( m_baseLineCoupled )
|
||||
m_baseLineCoupled->Mirror( aCentre, aFlipDirection );
|
||||
|
||||
if( m_settings.m_initialSide == PNS::MEANDER_SIDE_RIGHT )
|
||||
m_settings.m_initialSide = PNS::MEANDER_SIDE_LEFT;
|
||||
else
|
||||
m_settings.m_initialSide = PNS::MEANDER_SIDE_RIGHT;
|
||||
}
|
||||
|
||||
protected:
|
||||
VECTOR2I m_end;
|
||||
|
||||
|
@ -264,7 +264,7 @@ public:
|
||||
*
|
||||
* @param axis_pos is the vertical axis position to mirror around.
|
||||
*/
|
||||
virtual void Mirror( const VECTOR2I& axis_pos, FLIP_DIRECTION aFlipDirection );
|
||||
virtual void Mirror( const VECTOR2I& axis_pos, FLIP_DIRECTION aFlipDirection ) override;
|
||||
|
||||
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
||||
|
||||
|
@ -137,13 +137,28 @@ void PCB_GENERATOR::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle
|
||||
|
||||
void PCB_GENERATOR::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
|
||||
{
|
||||
MIRROR( m_origin, aCentre, aFlipDirection );
|
||||
baseMirror( aCentre, aFlipDirection );
|
||||
|
||||
SetLayer( GetBoard()->FlipLayer( GetLayer() ) );
|
||||
|
||||
PCB_GROUP::Flip( aCentre, aFlipDirection );
|
||||
}
|
||||
|
||||
void PCB_GENERATOR::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
|
||||
{
|
||||
baseMirror( aCentre, aFlipDirection );
|
||||
|
||||
PCB_GROUP::Mirror( aCentre, aFlipDirection );
|
||||
}
|
||||
|
||||
void PCB_GENERATOR::baseMirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
|
||||
{
|
||||
if( aFlipDirection == FLIP_DIRECTION::TOP_BOTTOM )
|
||||
MIRROR( m_origin.y, aCentre.y );
|
||||
else
|
||||
MIRROR( m_origin.x, aCentre.x );
|
||||
}
|
||||
|
||||
bool PCB_GENERATOR::AddItem( BOARD_ITEM* aItem )
|
||||
{
|
||||
// Items can only be in one group at a time
|
||||
|
@ -88,6 +88,8 @@ public:
|
||||
|
||||
void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
|
||||
|
||||
void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aMirrorDirection ) override;
|
||||
|
||||
bool AddItem( BOARD_ITEM* aItem ) override;
|
||||
|
||||
LSET GetLayerSet() const override;
|
||||
@ -131,6 +133,8 @@ protected:
|
||||
#endif
|
||||
|
||||
friend class GENERATORS_MGR;
|
||||
|
||||
void baseMirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection );
|
||||
};
|
||||
|
||||
#endif /* GENERATOR_H_ */
|
||||
|
@ -366,6 +366,13 @@ void PCB_GROUP::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
|
||||
}
|
||||
|
||||
|
||||
void PCB_GROUP::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
|
||||
{
|
||||
for( BOARD_ITEM* item : m_items )
|
||||
item->Mirror( aCentre, aFlipDirection );
|
||||
}
|
||||
|
||||
|
||||
wxString PCB_GROUP::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
|
||||
{
|
||||
if( m_name.empty() )
|
||||
|
@ -186,6 +186,9 @@ public:
|
||||
/// @copydoc BOARD_ITEM::Flip
|
||||
void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
|
||||
|
||||
/// @copydoc BOARD_ITEM::Mirror
|
||||
void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
|
||||
|
||||
/// @copydoc EDA_ITEM::GetItemDescription
|
||||
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
|
||||
|
||||
|
@ -143,7 +143,7 @@ public:
|
||||
|
||||
void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
|
||||
|
||||
virtual void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection );
|
||||
virtual void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
|
||||
|
||||
void Scale( double aScale );
|
||||
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
|
||||
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection );
|
||||
void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
|
||||
|
||||
void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
|
||||
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
|
||||
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
virtual void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection );
|
||||
virtual void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
|
||||
|
||||
void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
|
||||
|
||||
|
@ -2062,6 +2062,7 @@ const std::vector<KICAD_T> EDIT_TOOL::MirrorableItems = {
|
||||
PCB_TRACE_T,
|
||||
PCB_ARC_T,
|
||||
PCB_VIA_T,
|
||||
PCB_GENERATOR_T,
|
||||
};
|
||||
|
||||
int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
||||
@ -2157,6 +2158,10 @@ int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
||||
static_cast<PCB_TRACK*>( item )->Mirror( mirrorPoint, flipDirection );
|
||||
break;
|
||||
|
||||
case PCB_GENERATOR_T:
|
||||
static_cast<PCB_GENERATOR*>( item )->Mirror( mirrorPoint, flipDirection );
|
||||
break;
|
||||
|
||||
default:
|
||||
// it's likely the commit object is wrong if you get here
|
||||
UNIMPLEMENTED_FOR( item->GetClass() );
|
||||
|
@ -500,7 +500,7 @@ public:
|
||||
* @param aMirrorRef is axis position
|
||||
* @param aFlipDirection is the direction of the flip.
|
||||
*/
|
||||
void Mirror( const VECTOR2I& aMirrorRef, FLIP_DIRECTION aFlipDirection );
|
||||
void Mirror( const VECTOR2I& aMirrorRef, FLIP_DIRECTION aFlipDirection ) override;
|
||||
|
||||
/**
|
||||
* @return the class name.
|
||||
|
Loading…
Reference in New Issue
Block a user