PCB_TARGET: add missing TransformShapeWithClearanceToPolygon() method.

From Master branch.
This commit is contained in:
jean-pierre charras 2022-01-29 18:19:22 +01:00
parent 38a4894d92
commit 26dfc4477f
3 changed files with 53 additions and 2 deletions

View File

@ -4,7 +4,7 @@
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -35,6 +35,7 @@
#include <i18n_utility.h> #include <i18n_utility.h>
#include <geometry/shape_circle.h> #include <geometry/shape_circle.h>
#include <eda_draw_frame.h> #include <eda_draw_frame.h>
#include <pcb_shape.h>
PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent ) : PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent ) :
BOARD_ITEM( aParent, PCB_TARGET_T ) BOARD_ITEM( aParent, PCB_TARGET_T )
@ -159,6 +160,38 @@ void PCB_TARGET::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
} }
void PCB_TARGET::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearanceValue,
int aError, ERROR_LOC aErrorLoc,
bool ignoreLineWidth ) const
{
int size = GetShape() ? GetSize() / 1.5 : GetSize() / 2.0;
int radius = GetShape() ? GetSize() / 2.0 : GetSize() / 3.0;
PCB_SHAPE line1, line2;
PCB_SHAPE circle( nullptr, SHAPE_T::CIRCLE );
line1.SetStart( wxPoint( -size, 0.0 ) );
line1.SetEnd( wxPoint( size, 0.0 ) );
line2.SetStart( wxPoint( 0.0, -size ) );
line2.SetEnd( wxPoint( 0.0, size ) );
circle.SetEndX( radius );
if( GetShape() ) // shape x
{
line1.Rotate( wxPoint(0,0), 450 );
line2.Rotate( wxPoint(0,0), 450 );
}
for( PCB_SHAPE* item: { &line1, &line2, &circle } )
{
item->SetWidth( GetWidth() );
item->Move( GetPosition() );
item->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, aClearanceValue,
aError, aErrorLoc, ignoreLineWidth );
}
}
static struct PCB_TARGET_DESC static struct PCB_TARGET_DESC
{ {
PCB_TARGET_DESC() PCB_TARGET_DESC()

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -96,6 +96,23 @@ public:
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
/**
* Convert the shape to a closed polygon.
*
* Used in filling zones calculations. Circles and arcs are approximated by segments.
*
* @param aCornerBuffer is a buffer to store the polygon.
* @param aClearanceValue is the clearance around the pad.
* @param aError is the maximum deviation from a true arc.
* @param aErrorLoc whether any approximation error shoule be placed inside or outside
* @param ignoreLineWidth is used for edge cut items where the line width is only
* for visualization
*/
void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearanceValue,
int aError, ERROR_LOC aErrorLoc,
bool ignoreLineWidth = false ) const override;
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif #endif

View File

@ -592,6 +592,7 @@ void ZONE_FILLER::addKnockout( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, int aGap,
case PCB_SHAPE_T: case PCB_SHAPE_T:
case PCB_TEXT_T: case PCB_TEXT_T:
case PCB_FP_SHAPE_T: case PCB_FP_SHAPE_T:
case PCB_TARGET_T:
aItem->TransformShapeWithClearanceToPolygon( aHoles, aLayer, aGap, m_maxError, aItem->TransformShapeWithClearanceToPolygon( aHoles, aLayer, aGap, m_maxError,
ERROR_OUTSIDE, aIgnoreLineWidth ); ERROR_OUTSIDE, aIgnoreLineWidth );
break; break;