38 m_drawings( aDrawings ),
39 m_parentFootprint( aParentFootprint ),
42 m_itemsList( nullptr )
48 std::vector<std::shared_ptr<CLEANUP_ITEM>>* aItemsList,
49 bool aMergeRects,
bool aDeleteRedundant )
60 if( aDeleteRedundant )
74 return abs( a.
x - b.
x ) < epsilon && abs( a.
y - b.
y ) < epsilon;
137 wxFAIL_MSG( wxT(
"GRAPHICS_CLEANER::areEquivalent unimplemented for " )
149 PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( *it );
157 item->SetItems( shape );
166 for(
auto it2 = it + 1; it2 !=
m_drawings.end(); it2++ )
168 PCB_SHAPE* shape2 = dynamic_cast<PCB_SHAPE*>( *it2 );
176 item->SetItems( shape2 );
191 struct SIDE_CANDIDATE
198 if( start.x > end.x || start.y > end.y )
199 std::swap( start, end );
207 std::vector<SIDE_CANDIDATE*> sides;
208 std::map<wxPoint, std::vector<SIDE_CANDIDATE*>> ptMap;
213 PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( item );
220 sides.emplace_back(
new SIDE_CANDIDATE( shape ) );
221 ptMap[ sides.back()->start ].push_back( sides.back() );
226 for( SIDE_CANDIDATE* side : sides )
231 SIDE_CANDIDATE*
left =
nullptr;
232 SIDE_CANDIDATE* top =
nullptr;
233 SIDE_CANDIDATE*
right =
nullptr;
234 SIDE_CANDIDATE* bottom =
nullptr;
236 auto viable = [&]( SIDE_CANDIDATE* aCandidate ) ->
bool 238 return aCandidate->shape->GetLayer() == side->shape->GetLayer()
239 && aCandidate->shape->GetWidth() == side->shape->GetWidth()
243 if( side->start.x == side->end.x )
249 for( SIDE_CANDIDATE* candidate : ptMap[
left->start ] )
251 if( candidate !=
left && viable( candidate ) )
258 else if( side->start.y == side->end.y )
264 for( SIDE_CANDIDATE* candidate : ptMap[ top->start ] )
266 if( candidate != top && viable( candidate ) )
278 for( SIDE_CANDIDATE* candidate : ptMap[ top->end ] )
280 if( candidate != top && candidate !=
left && viable( candidate ) )
287 for( SIDE_CANDIDATE* candidate : ptMap[
left->end ] )
289 if( candidate != top && candidate !=
left && viable( candidate ) )
296 if(
right && bottom &&
right->end == bottom->end )
304 item->SetItems(
left->shape, top->shape,
right->shape, bottom->shape );
320 rect->
SetEnd( bottom->end );
321 rect->
SetLayer( top->shape->GetLayer() );
322 rect->
SetWidth( top->shape->GetWidth() );
337 for( SIDE_CANDIDATE* side : sides )
const std::vector< wxPoint > & GetBezierPoints() const
bool isNullShape(PCB_SHAPE *aShape)
void SetFilled(bool aFlag)
void SetEnd(const wxPoint &aEnd)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
const wxPoint & GetStart() const
Return the starting point of the graphic.
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
std::vector< std::shared_ptr< CLEANUP_ITEM > > * m_itemsList
void SetFlags(EDA_ITEM_FLAGS aMask)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
GRAPHICS_CLEANER(DRAWINGS &aDrawings, FOOTPRINT *aParentFootprint, BOARD_COMMIT &aCommit)
This file contains miscellaneous commonly used macros and functions.
void SetStart(const wxPoint &aStart)
const wxPoint & GetBezierC1() const
int GetPointCount() const
const wxPoint & GetEnd() const
Return the ending point of the graphic.
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
const wxPoint & GetBezierC2() const
void CleanupBoard(bool aDryRun, std::vector< std::shared_ptr< CLEANUP_ITEM > > *aItemsList, bool aMergeRects, bool aDeleteRedundant)
the cleanup function.
#define UNIMPLEMENTED_FOR(type)
void SetWidth(int aWidth)
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
bool areEquivalent(PCB_SHAPE *aShape1, PCB_SHAPE *aShape2)
wxString SHAPE_T_asString() const
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
void SetShape(SHAPE_T aShape)
void SetLocalCoord()
Set relative coordinates from draw coordinates.
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
FOOTPRINT * m_parentFootprint
bool equivalent(const VECTOR2I &a, const VECTOR2I &b, int epsilon)