pcbnew: fix graphical polygon movement, rotation, flipping and edit points synchronization.
Fixes: lp:1738449 * https://bugs.launchpad.net/kicad/+bug/1738449 Fixes: lp:1738032 * https://bugs.launchpad.net/kicad/+bug/1738032
This commit is contained in:
parent
758d5727b0
commit
a4528988ca
|
@ -194,7 +194,7 @@ public:
|
|||
* @return const wxPoint& - The position of this object.
|
||||
* This function exists mainly to satisfy the virtual GetPosition() in parent class
|
||||
*/
|
||||
const wxPoint& GetPosition() const { return m_Start; }
|
||||
const wxPoint GetPosition() const { return m_Start; }
|
||||
void SetPosition( const wxPoint& aPos ) { m_Start = aPos; }
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
// Do not create a copy constructor & operator=.
|
||||
// The ones generated by the compiler are adequate.
|
||||
|
||||
virtual const wxPoint& GetPosition() const = 0;
|
||||
virtual const wxPoint GetPosition() const = 0;
|
||||
|
||||
/**
|
||||
* Function GetCenter()
|
||||
|
|
|
@ -211,7 +211,7 @@ public:
|
|||
// Accessors:
|
||||
int GetPenWidth() const { return m_penWidth; }
|
||||
bool IsFilled() const { return m_fill; }
|
||||
const wxPoint& GetPosition() const { return m_pos; }
|
||||
const wxPoint GetPosition() const { return m_pos; }
|
||||
|
||||
/** The function to draw a WS_DRAW_ITEM_POLYGON
|
||||
*/
|
||||
|
@ -361,7 +361,7 @@ public:
|
|||
*/
|
||||
virtual bool HitTestStartPoint( const wxPoint& aPosition) override;
|
||||
|
||||
const wxPoint& GetPosition() { return m_pos; }
|
||||
const wxPoint GetPosition() { return m_pos; }
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -135,7 +135,7 @@ void BOARD::BuildConnectivity()
|
|||
}
|
||||
|
||||
|
||||
const wxPoint& BOARD::GetPosition() const
|
||||
const wxPoint BOARD::GetPosition() const
|
||||
{
|
||||
wxLogWarning( wxT( "This should not be called on the BOARD object") );
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ public:
|
|||
BOARD();
|
||||
~BOARD();
|
||||
|
||||
virtual const wxPoint& GetPosition() const override;
|
||||
virtual const wxPoint GetPosition() const override;
|
||||
|
||||
virtual void SetPosition( const wxPoint& aPos ) override;
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ void DIMENSION::SetPosition( const wxPoint& aPos )
|
|||
}
|
||||
|
||||
|
||||
const wxPoint& DIMENSION::GetPosition() const
|
||||
const wxPoint DIMENSION::GetPosition() const
|
||||
{
|
||||
return m_Text.GetTextPos();
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
|
||||
int GetValue() const { return m_Value; }
|
||||
|
||||
const wxPoint& GetPosition() const override;
|
||||
const wxPoint GetPosition() const override;
|
||||
|
||||
void SetPosition( const wxPoint& aPos ) override;
|
||||
|
||||
|
|
|
@ -66,6 +66,37 @@ DRAWSEGMENT::~DRAWSEGMENT()
|
|||
{
|
||||
}
|
||||
|
||||
void DRAWSEGMENT::SetPosition( const wxPoint& aPos )
|
||||
{
|
||||
m_Start = aPos;
|
||||
}
|
||||
|
||||
const wxPoint DRAWSEGMENT::GetPosition() const
|
||||
{
|
||||
if( m_Shape == S_POLYGON )
|
||||
return (wxPoint) m_Poly.CVertex( 0 );
|
||||
else
|
||||
return m_Start;
|
||||
}
|
||||
|
||||
void DRAWSEGMENT::Move( const wxPoint& aMoveVector )
|
||||
{
|
||||
m_Start += aMoveVector;
|
||||
m_End += aMoveVector;
|
||||
|
||||
switch ( m_Shape )
|
||||
{
|
||||
case S_POLYGON:
|
||||
for( auto iter = m_Poly.Iterate(); iter; iter++ )
|
||||
{
|
||||
(*iter) += VECTOR2I( aMoveVector );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DRAWSEGMENT::Rotate( const wxPoint& aRotCentre, double aAngle )
|
||||
{
|
||||
|
@ -110,8 +141,20 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre )
|
|||
m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
|
||||
m_End.y = aCentre.y - (m_End.y - aCentre.y);
|
||||
|
||||
if( m_Shape == S_ARC )
|
||||
switch ( m_Shape )
|
||||
{
|
||||
case S_ARC:
|
||||
m_Angle = -m_Angle;
|
||||
break;
|
||||
case S_POLYGON:
|
||||
for( auto iter = m_Poly.Iterate(); iter; iter++ )
|
||||
{
|
||||
iter->y = aCentre.y - (iter->y - aCentre.y);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// DRAWSEGMENT items are not allowed on copper layers, so
|
||||
// copper layers count is not taken in accoun in Flip transform
|
||||
|
@ -164,7 +207,7 @@ const wxPoint DRAWSEGMENT::GetArcEnd() const
|
|||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
break;
|
||||
}
|
||||
|
||||
return endPoint; // after rotation, the end of the arc.
|
||||
|
|
|
@ -99,8 +99,8 @@ public:
|
|||
void SetBezControl2( const wxPoint& aPoint ) { m_BezierC2 = aPoint; }
|
||||
const wxPoint& GetBezControl2() const { return m_BezierC2; }
|
||||
|
||||
void SetPosition( const wxPoint& aPos ) override { m_Start = aPos; }
|
||||
const wxPoint& GetPosition() const override { return m_Start; }
|
||||
void SetPosition( const wxPoint& aPos ) override;
|
||||
const wxPoint GetPosition() const override;
|
||||
|
||||
/**
|
||||
* Function GetStart
|
||||
|
@ -205,11 +205,7 @@ public:
|
|||
return GetLineLength( GetStart(), GetEnd() );
|
||||
}
|
||||
|
||||
virtual void Move( const wxPoint& aMoveVector ) override
|
||||
{
|
||||
m_Start += aMoveVector;
|
||||
m_End += aMoveVector;
|
||||
}
|
||||
virtual void Move( const wxPoint& aMoveVector ) override;
|
||||
|
||||
virtual void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
DrawMarker( aPanel, aDC, aDrawMode, aOffset );
|
||||
}
|
||||
|
||||
const wxPoint& GetPosition() const override { return m_Pos; }
|
||||
const wxPoint GetPosition() const override { return m_Pos; }
|
||||
void SetPosition( const wxPoint& aPos ) override { m_Pos = aPos; }
|
||||
|
||||
void SetItem( const BOARD_ITEM* aItem )
|
||||
|
|
|
@ -172,7 +172,7 @@ public:
|
|||
|
||||
void SetPosition( const wxPoint& aPos ) override;
|
||||
|
||||
const wxPoint& GetPosition() const override { return m_Pos; }
|
||||
const wxPoint GetPosition() const override { return m_Pos; }
|
||||
|
||||
void SetOrientation( double newangle );
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
const wxPoint& GetPosition() const override
|
||||
const wxPoint GetPosition() const override
|
||||
{
|
||||
static wxPoint dummy(0, 0);
|
||||
return dummy;
|
||||
|
|
|
@ -217,7 +217,7 @@ public:
|
|||
void SetShape( PAD_SHAPE_T aShape ) { m_padShape = aShape; m_boundingRadius = -1; }
|
||||
|
||||
void SetPosition( const wxPoint& aPos ) override { m_Pos = aPos; }
|
||||
const wxPoint& GetPosition() const override { return m_Pos; }
|
||||
const wxPoint GetPosition() const override { return m_Pos; }
|
||||
|
||||
/**
|
||||
* Function GetAnchorPadShape
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
~PCB_TARGET();
|
||||
|
||||
void SetPosition( const wxPoint& aPos ) override { m_Pos = aPos; }
|
||||
const wxPoint& GetPosition() const override { return m_Pos; }
|
||||
const wxPoint GetPosition() const override { return m_Pos; }
|
||||
|
||||
void SetShape( int aShape ) { m_Shape = aShape; }
|
||||
int GetShape() const { return m_Shape; }
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
return aItem && PCB_TEXT_T == aItem->Type();
|
||||
}
|
||||
|
||||
virtual const wxPoint& GetPosition() const override
|
||||
virtual const wxPoint GetPosition() const override
|
||||
{
|
||||
return EDA_TEXT::GetTextPos();
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
return aItem && PCB_MODULE_TEXT_T == aItem->Type();
|
||||
}
|
||||
|
||||
virtual const wxPoint& GetPosition() const override
|
||||
virtual const wxPoint GetPosition() const override
|
||||
{
|
||||
return EDA_TEXT::GetTextPos();
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
virtual void Flip( const wxPoint& aCentre ) override;
|
||||
|
||||
void SetPosition( const wxPoint& aPos ) override { m_Start = aPos; }
|
||||
const wxPoint& GetPosition() const override { return m_Start; }
|
||||
const wxPoint GetPosition() const override { return m_Start; }
|
||||
|
||||
void SetWidth( int aWidth ) { m_Width = aWidth; }
|
||||
int GetWidth() const { return m_Width; }
|
||||
|
@ -412,7 +412,7 @@ public:
|
|||
*/
|
||||
void LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const;
|
||||
|
||||
const wxPoint& GetPosition() const override { return m_Start; }
|
||||
const wxPoint GetPosition() const override { return m_Start; }
|
||||
void SetPosition( const wxPoint& aPoint ) override { m_Start = aPoint; m_End = aPoint; }
|
||||
|
||||
virtual bool HitTest( const wxPoint& aPosition ) const override;
|
||||
|
|
|
@ -163,15 +163,9 @@ bool ZONE_CONTAINER::UnFill()
|
|||
}
|
||||
|
||||
|
||||
const wxPoint& ZONE_CONTAINER::GetPosition() const
|
||||
const wxPoint ZONE_CONTAINER::GetPosition() const
|
||||
{
|
||||
const WX_VECTOR_CONVERTER* pos;
|
||||
|
||||
// The retrieved vertex is a VECTOR2I. Casting it to a union WX_VECTOR_CONVERTER, we can later
|
||||
// return the object shaped as a wxPoint. See the definition of the union in class_zone.h for
|
||||
// more information on this hack.
|
||||
pos = reinterpret_cast<const WX_VECTOR_CONVERTER*>( &GetCornerPosition( 0 ) );
|
||||
return pos->wx;
|
||||
return (wxPoint) GetCornerPosition( 0 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
*
|
||||
* @return a wxPoint, position of the first point of the outline
|
||||
*/
|
||||
const wxPoint& GetPosition() const override;
|
||||
const wxPoint GetPosition() const override;
|
||||
void SetPosition( const wxPoint& aPos ) override {}
|
||||
|
||||
/**
|
||||
|
|
|
@ -932,11 +932,6 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer )
|
|||
m_gal->Translate( module->GetPosition() );
|
||||
m_gal->Rotate( -module->GetOrientationRadians() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gal->Translate( aSegment->GetPosition() );
|
||||
m_gal->Rotate( DECIDEG2RAD( -aSegment->GetAngle() ) );
|
||||
}
|
||||
|
||||
std::copy( points.begin(), points.end(), std::back_inserter( pointsList ) );
|
||||
pointsList.push_back( points[0] );
|
||||
|
|
|
@ -427,7 +427,9 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
// Drag items to the current cursor position
|
||||
for( auto item : selection )
|
||||
{
|
||||
static_cast<BOARD_ITEM*>( item )->Move( movement );
|
||||
}
|
||||
}
|
||||
else if( !m_dragging ) // Prepare to start dragging
|
||||
{
|
||||
|
|
|
@ -355,7 +355,10 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
|
|||
|
||||
case S_POLYGON:
|
||||
{
|
||||
// no anchors for the moment
|
||||
for( const auto& p : dseg->GetPolyPoints() )
|
||||
{
|
||||
addAnchor( p, CORNER | SNAPPABLE, dseg );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -615,6 +615,15 @@ void POINT_EDITOR::updatePoints()
|
|||
m_editPoints->Point( CIRC_END ).SetPosition( segment->GetEnd() );
|
||||
break;
|
||||
|
||||
case S_POLYGON:
|
||||
{
|
||||
const auto& points = segment->GetPolyPoints();
|
||||
for( int i = 0; i < points.size(); i++ )
|
||||
{
|
||||
m_editPoints->Point( i ).SetPosition( points[i] );
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: // suppress warnings
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue