Commit 70a61b80 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: fix Bug #1373267 (polygons in footprint outlines do not flip correctly)

Minor other fixes.
parent dda896d5
......@@ -48,7 +48,7 @@ int LIB_EDIT_FRAME::BlockCommand( int key )
switch( key )
{
default:
cmd = key & 0x255;
cmd = key & 0xFF;
break;
case -1:
......
......@@ -185,7 +185,7 @@ int PCB_EDIT_FRAME::BlockCommand( int aKey )
switch( aKey )
{
default:
cmd = aKey & 0x255;
cmd = aKey & 0xFF;
break;
case 0:
......@@ -219,6 +219,8 @@ int PCB_EDIT_FRAME::BlockCommand( int aKey )
void PCB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
{
GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST;
if( !m_canvas->IsMouseCaptured() )
{
DisplayError( this, wxT( "Error in HandleBlockPLace : m_mouseCaptureCallback = NULL" ) );
......@@ -274,7 +276,6 @@ bool PCB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
{
bool nextcmd = false; // Will be set to true if a block place is needed
bool cancelCmd = false;
// If coming here after cancel block, clean up and exit
if( GetScreen()->m_BlockLocate.GetState() == STATE_NO_BLOCK )
{
......@@ -369,6 +370,7 @@ bool PCB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
if( ! nextcmd )
{
GetBoard()->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST;
GetScreen()->ClearBlockCommand();
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString,
false );
......@@ -562,6 +564,10 @@ static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
{
BASE_SCREEN* screen = aPanel->GetScreen();
// do not show local module rastnest in block move, it is not usable.
bool tmp = g_Show_Module_Ratsnest;
g_Show_Module_Ratsnest = false;
if( aErase )
{
if( screen->m_BlockLocate.GetMoveVector().x || screen->m_BlockLocate.GetMoveVector().y )
......@@ -589,6 +595,8 @@ static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
if( blockDrawItems )
drawPickedItems( aPanel, aDC, screen->m_BlockLocate.GetMoveVector() );
}
g_Show_Module_Ratsnest = tmp;
}
......@@ -795,6 +803,7 @@ void PCB_EDIT_FRAME::Block_Move()
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
itemsList->SetPickedItemStatus( UR_MOVED, ii );
item->Move( MoveVector );
item->ClearFlags( IS_MOVED );
switch( item->Type() )
{
......
......@@ -80,7 +80,7 @@ int FOOTPRINT_EDIT_FRAME::BlockCommand( int key )
switch( key )
{
default:
cmd = key & 0x255;
cmd = key & 0xFF;
break;
case - 1:
......
......@@ -130,7 +130,6 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
const wxPoint& offset )
{
int ux0, uy0, dx, dy, radius, StAngle, EndAngle;
int type_trace;
int typeaff;
LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
......@@ -154,8 +153,6 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
type_trace = m_Shape;
ux0 = m_Start.x - offset.x;
uy0 = m_Start.y - offset.y;
......@@ -176,7 +173,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
if( DC->LogicalToDeviceXRel( m_Width ) <= MIN_DRAW_WIDTH )
typeaff = LINE;
switch( type_trace )
switch( m_Shape )
{
case S_SEGMENT:
if( typeaff == LINE )
......@@ -245,10 +242,9 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
break;
case S_POLYGON:
{
// We must compute true coordinates from m_PolyPoints
// which are relative to module position, orientation 0
std::vector<wxPoint> points = m_PolyPoints;
for( unsigned ii = 0; ii < points.size(); ii++ )
......@@ -260,6 +256,10 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
}
GRPoly( panel->GetClipBox(), DC, points.size(), &points[0], true, m_Width, color, color );
}
break;
default:
break;
}
}
......@@ -312,3 +312,41 @@ EDA_ITEM* EDGE_MODULE::Clone() const
return new EDGE_MODULE( *this );
}
void EDGE_MODULE::Flip(const wxPoint& aCentre )
{
wxPoint pt;
switch( GetShape() )
{
case S_ARC:
SetAngle( -GetAngle() );
//Fall through
default:
case S_SEGMENT:
pt = GetStart();
pt.y -= aCentre.y;
pt.y = -pt.y;
pt.y += aCentre.y;
SetStart( pt );
pt = GetEnd();
pt.y -= aCentre.y;
pt.y = -pt.y;
pt.y += aCentre.y;
SetEnd( pt );
NEGATE( m_Start0.y );
NEGATE( m_End0.y );
break;
case S_POLYGON:
// polygon corners coordinates are always relative to the
// footprint position, orientation 0
for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
NEGATE( m_PolyPoints[ii].y );
}
SetLayer( FlipLayer( GetLayer() ) );
}
......@@ -68,6 +68,9 @@ public:
SetLocalCoord();
}
/// Flip entity relative to aCentre
void Flip( const wxPoint& aCentre );
void SetStart0( const wxPoint& aPoint ) { m_Start0 = aPoint; }
const wxPoint& GetStart0() const { return m_Start0; }
......
......@@ -947,31 +947,7 @@ void MODULE::Flip( const wxPoint& aCentre )
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* em = (EDGE_MODULE*) item;
wxPoint s = em->GetStart();
s.y -= m_Pos.y;
s.y = -s.y;
s.y += m_Pos.y;
em->SetStart( s );
wxPoint e = em->GetEnd();
e.y -= m_Pos.y;
e.y = -e.y;
e.y += m_Pos.y;
em->SetEnd( e );
NEGATE( em->m_Start0.y );
NEGATE( em->m_End0.y );
if( em->GetShape() == S_ARC )
{
em->SetAngle( -em->GetAngle() );
}
em->SetLayer( FlipLayer( em->GetLayer() ) );
}
( (EDGE_MODULE*) item )->Flip( m_Pos );
break;
case PCB_MODULE_TEXT_T:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment