diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 284ccb3e90..f128905ccd 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -116,6 +116,13 @@ public: */ void Move( wxPoint aMoveVector ); + /** + * Rotates the primitive about a point + * @param aRotCentre center of rotation + * @param aAngle angle in tenths of degree + */ + void Rotate( const wxPoint& aRotCentre, double aAngle ); + /** Export the PAD_CS_PRIMITIVE parameters to a DRAWSEGMENT * useful to draw a primitive shape * @param aTarget is the DRAWSEGMENT to initialize diff --git a/pcbnew/pad_custom_shape_functions.cpp b/pcbnew/pad_custom_shape_functions.cpp index 4ff9ee7948..19d706e0a9 100644 --- a/pcbnew/pad_custom_shape_functions.cpp +++ b/pcbnew/pad_custom_shape_functions.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -88,6 +89,42 @@ void PAD_CS_PRIMITIVE::Move( wxPoint aMoveVector ) } +void PAD_CS_PRIMITIVE::Rotate( const wxPoint& aRotCentre, double aAngle ) +{ + switch( m_Shape ) + { + case S_ARC: + case S_SEGMENT: + case S_CIRCLE: + // these can all be done by just rotating the start and end points + RotatePoint( &m_Start, aRotCentre, aAngle ); + RotatePoint( &m_End, aRotCentre, aAngle ); + break; + + case S_POLYGON: + for( auto& pt : m_Poly ) + RotatePoint( &pt, aRotCentre, aAngle ); + + break; + + case S_CURVE: + RotatePoint( &m_Start, aRotCentre, aAngle ); + RotatePoint( &m_End, aRotCentre, aAngle ); + RotatePoint( &m_Ctrl1, aRotCentre, aAngle ); + RotatePoint( &m_Ctrl2, aRotCentre, aAngle ); + + break; + + case S_RECT: + default: + // un-handled edge transform + wxASSERT_MSG( false, wxT( "PAD_CS_PRIMITIVE::Rotate not implemented for " + + BOARD_ITEM::ShowShape( m_Shape ) ) ); + break; + } +} + + /* * Has meaning only for free shape pads. * add a free shape to the shape list. diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 226514b59f..244e2cede9 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -485,6 +485,8 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) int step = SET_ORIGIN; // Prime the pump + m_toolMgr->RunAction( ACTIONS::refreshPreview ); + if( aEvent.HasPosition() ) m_toolMgr->RunAction( ACTIONS::cursorClick ); @@ -891,6 +893,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPTGetMousePosition(); // Prime the pump + m_toolMgr->RunAction( ACTIONS::refreshPreview ); + if( aStartingPoint ) m_toolMgr->RunAction( ACTIONS::cursorClick ); @@ -1152,6 +1156,8 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic, bool aImmediateMode ) bool cancelled = false; // Prime the pump + m_toolMgr->RunAction( ACTIONS::refreshPreview ); + if( aImmediateMode ) m_toolMgr->RunAction( ACTIONS::cursorClick ); diff --git a/pcbnew/tools/footprint_editor_tools.cpp b/pcbnew/tools/footprint_editor_tools.cpp index 51f34311da..7317b6c099 100644 --- a/pcbnew/tools/footprint_editor_tools.cpp +++ b/pcbnew/tools/footprint_editor_tools.cpp @@ -350,6 +350,7 @@ int MODULE_EDITOR_TOOLS::ExplodePadToShapes( const TOOL_EVENT& aEvent ) // Fix an arbitray draw layer for this EDGE_MODULE ds->SetLayer( Dwgs_User ); //pad->GetLayer() ); ds->Move( anchor ); + ds->Rotate( anchor, pad->GetOrientation() ); commit.Add( ds ); } @@ -446,6 +447,8 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) return 0; } + double refOrientation = 0.0; + if( refPad ) { pad.reset( static_cast( refPad->Clone() ) ); @@ -453,9 +456,10 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) if( refPad->GetShape() == PAD_SHAPE_RECT ) pad->SetAnchorPadShape( PAD_SHAPE_RECT ); - // ignore the pad orientation and offset for the moment. Makes more trouble than it's worth. - pad->SetOrientation( 0 ); + // ignore the pad offset for the moment. Makes more trouble than it's worth. pad->SetOffset( wxPoint( 0, 0 ) ); + refOrientation = pad->GetOrientation(); + pad->SetOrientation( 0.0 ); } else { @@ -497,14 +501,15 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) for( auto& shape : shapes ) { shape.Move( wxPoint( -anchor->x, -anchor->y ) ); + shape.Rotate( wxPoint( 0, 0 ), -refOrientation ); } - pad->SetPosition( wxPoint( anchor->x, anchor->y ) ); pad->AddPrimitives( shapes ); pad->ClearFlags(); bool result = pad->MergePrimitivesAsPolygon(); + pad->Rotate( wxPoint( anchor->x, anchor->y ), refOrientation ); if( !result ) {