41 m_drawings( aDrawings ),
42 m_parentFootprint( aParentFootprint ),
44 m_toolMgr( aToolMgr ),
47 m_itemsList( nullptr )
53 std::vector<std::shared_ptr<CLEANUP_ITEM>>* aItemsList,
54 bool aMergeRects,
bool aDeleteRedundant,
bool aMergePads )
65 if( aDeleteRedundant )
82 return abs( a.
x - b.
x ) < epsilon &&
abs( a.
y - b.
y ) < epsilon;
151 wxFAIL_MSG( wxT(
"GRAPHICS_CLEANER::areEquivalent unimplemented for " )
171 item->SetItems( shape );
180 for(
auto it2 = it + 1; it2 !=
m_drawings.end(); it2++ )
190 item->SetItems( shape2 );
205 struct SIDE_CANDIDATE
212 if( start.x > end.x || start.y > end.y )
213 std::swap( start, end );
221 std::vector<SIDE_CANDIDATE*> sides;
222 std::map<VECTOR2I, std::vector<SIDE_CANDIDATE*>> ptMap;
234 sides.emplace_back(
new SIDE_CANDIDATE( shape ) );
235 ptMap[ sides.back()->start ].push_back( sides.back() );
240 for( SIDE_CANDIDATE* side : sides )
245 SIDE_CANDIDATE*
left =
nullptr;
246 SIDE_CANDIDATE* top =
nullptr;
247 SIDE_CANDIDATE*
right =
nullptr;
248 SIDE_CANDIDATE* bottom =
nullptr;
250 auto viable = [&]( SIDE_CANDIDATE* aCandidate ) ->
bool
252 return aCandidate->shape->GetLayer() == side->shape->GetLayer()
253 && aCandidate->shape->GetWidth() == side->shape->GetWidth()
257 if( side->start.x == side->end.x )
263 for( SIDE_CANDIDATE* candidate : ptMap[
left->start ] )
265 if( candidate !=
left && viable( candidate ) )
272 else if( side->start.y == side->end.y )
278 for( SIDE_CANDIDATE* candidate : ptMap[ top->start ] )
280 if( candidate != top && viable( candidate ) )
292 for( SIDE_CANDIDATE* candidate : ptMap[ top->end ] )
294 if( candidate != top && candidate !=
left && viable( candidate ) )
301 for( SIDE_CANDIDATE* candidate : ptMap[
left->end ] )
303 if( candidate != top && candidate !=
left && viable( candidate ) )
310 if(
right && bottom &&
right->end == bottom->end )
318 item->SetItems(
left->shape, top->shape,
right->shape, bottom->shape );
334 rect->
SetEnd( bottom->end );
335 rect->
SetLayer( top->shape->GetLayer() );
336 rect->
SetStroke( top->shape->GetStroke() );
351 for( SIDE_CANDIDATE* side : sides )
358 wxCHECK_MSG(
m_parentFootprint, , wxT(
"mergePads() is FootprintEditor only" ) );
366 if( padToNetTieGroupMap[
pad->GetNumber() ] >= 0 )
371 if( !shapes.empty() )
373 std::shared_ptr<CLEANUP_ITEM> item = std::make_shared<CLEANUP_ITEM>(
CLEANUP_MERGE_PAD );
376 item->AddItem( shape );
378 item->AddItem(
pad );
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
void SetFlags(EDA_ITEM_FLAGS aMask)
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
const VECTOR2I & GetBezierC2() const
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
void SetFilled(bool aFlag)
int GetPointCount() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetShape(SHAPE_T aShape)
const std::vector< VECTOR2I > & GetBezierPoints() const
void SetEnd(const VECTOR2I &aEnd)
wxString SHAPE_T_asString() const
const VECTOR2I & GetBezierC1() const
virtual void SetLocalCoord()
Set relative coordinates from draw coordinates.
void CleanupBoard(bool aDryRun, std::vector< std::shared_ptr< CLEANUP_ITEM > > *aItemsList, bool aMergeRects, bool aDeleteRedundant, bool aMergePads)
the cleanup function.
std::vector< std::shared_ptr< CLEANUP_ITEM > > * m_itemsList
FOOTPRINT * m_parentFootprint
GRAPHICS_CLEANER(DRAWINGS &aDrawings, FOOTPRINT *aParentFootprint, BOARD_COMMIT &aCommit, TOOL_MANAGER *aToolManager)
bool isNullShape(PCB_SHAPE *aShape)
bool areEquivalent(PCB_SHAPE *aShape1, PCB_SHAPE *aShape2)
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
void SetStroke(const STROKE_PARAMS &aStroke) override
@ CLEANUP_DUPLICATE_GRAPHIC
bool equivalent(const VECTOR2I &a, const VECTOR2I &b, int epsilon)
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)