55 std::vector<std::shared_ptr<CLEANUP_ITEM>>* aItemsList,
56 bool aMergeRects,
bool aDeleteRedundant,
bool aMergePads,
57 bool aFixBoardOutlines,
int aTolerance )
70 if( aDeleteRedundant )
73 if( aFixBoardOutlines )
159 wxFAIL_MSG( wxT(
"GRAPHICS_CLEANER::areEquivalent unimplemented for " )
179 item->SetItems( shape );
188 for(
auto it2 = it + 1; it2 !=
m_drawings.end(); it2++ )
198 item->SetItems( shape2 );
216 std::vector<PCB_SHAPE*> shapeList;
225 shapeList.push_back( shape );
233 std::vector<PCB_SHAPE*> items_to_select;
239 struct SIDE_CANDIDATE
246 if( start.x >
end.x || start.y >
end.y )
247 std::swap( start,
end );
255 std::vector<SIDE_CANDIDATE*> sides;
256 std::map<VECTOR2I, std::vector<SIDE_CANDIDATE*>> ptMap;
268 sides.emplace_back(
new SIDE_CANDIDATE( shape ) );
269 ptMap[ sides.back()->start ].push_back( sides.back() );
274 for( SIDE_CANDIDATE* side : sides )
279 SIDE_CANDIDATE*
left =
nullptr;
280 SIDE_CANDIDATE* top =
nullptr;
281 SIDE_CANDIDATE*
right =
nullptr;
282 SIDE_CANDIDATE* bottom =
nullptr;
284 auto viable = [&]( SIDE_CANDIDATE* aCandidate ) ->
bool
286 return aCandidate->shape->GetLayer() == side->shape->GetLayer()
287 && aCandidate->shape->GetWidth() == side->shape->GetWidth()
291 if( side->start.x == side->end.x )
297 for( SIDE_CANDIDATE* candidate : ptMap[
left->start ] )
299 if( candidate !=
left && viable( candidate ) )
306 else if( side->start.y == side->end.y )
312 for( SIDE_CANDIDATE* candidate : ptMap[ top->start ] )
314 if( candidate != top && viable( candidate ) )
326 for( SIDE_CANDIDATE* candidate : ptMap[ top->end ] )
328 if( candidate != top && candidate !=
left && viable( candidate ) )
335 for( SIDE_CANDIDATE* candidate : ptMap[
left->end ] )
337 if( candidate != top && candidate !=
left && viable( candidate ) )
344 if(
right && bottom &&
right->end == bottom->end )
352 item->SetItems(
left->shape, top->shape,
right->shape, bottom->shape );
362 rect->
SetEnd( bottom->end );
363 rect->
SetLayer( top->shape->GetLayer() );
364 rect->
SetStroke( top->shape->GetStroke() );
376 for( SIDE_CANDIDATE* side : sides )
383 wxCHECK_MSG(
m_parentFootprint, , wxT(
"mergePads() is FootprintEditor only" ) );
386 std::map<wxString, int> padToNetTieGroupMap =
m_parentFootprint->MapPadNumbersToNetTieGroups();
391 if( padToNetTieGroupMap[
pad->GetNumber() ] >= 0 )
399 if( !shapes.empty() )
401 std::shared_ptr<CLEANUP_ITEM> item = std::make_shared<CLEANUP_ITEM>(
CLEANUP_MERGE_PAD );
404 item->AddItem( shape );
406 item->AddItem(
pad );
constexpr int ARC_HIGH_DEF
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void SetFlags(EDA_ITEM_FLAGS aMask)
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
const VECTOR2I & GetBezierC2() const
virtual void SetFilled(bool aFlag)
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
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
GRAPHICS_CLEANER(const DRAWINGS &aDrawings, FOOTPRINT *aParentFootprint, BOARD_COMMIT &aCommit, TOOL_MANAGER *aToolManager)
std::vector< std::shared_ptr< CLEANUP_ITEM > > * m_itemsList
FOOTPRINT * m_parentFootprint
void CleanupBoard(bool aDryRun, std::vector< std::shared_ptr< CLEANUP_ITEM > > *aItemsList, bool aMergeRects, bool aDeleteRedundant, bool aMergePads, bool aFixBoardOutlines, int aTolerance)
the cleanup function.
const DRAWINGS & m_drawings
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.
int GetWidth() const override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
void SetStroke(const STROKE_PARAMS &aStroke) override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
@ CLEANUP_DUPLICATE_GRAPHIC
bool equivalent(SIM_MODEL::DEVICE_T a, SIM_MODEL::DEVICE_T b)
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
void ConnectBoardShapes(std::vector< PCB_SHAPE * > &aShapeList, int aChainingEpsilon)
Connects shapes to each other, making continious contours (adjacent shapes will have a common vertex)...
bool equivalent(const VECTOR2I &a, const VECTOR2I &b, int epsilon)
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
VECTOR2< int32_t > VECTOR2I