41 m_drawings( aDrawings ),
42 m_parentFootprint( aParentFootprint ),
44 m_toolMgr( aToolMgr ),
48 m_outlinesTolerance( 0 ),
49 m_itemsList( nullptr )
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 )
98 case SHAPE_T::SEGMENT:
99 case SHAPE_T::RECTANGLE:
103 case SHAPE_T::CIRCLE:
109 case SHAPE_T::BEZIER:
137 case SHAPE_T::SEGMENT:
138 case SHAPE_T::RECTANGLE:
139 case SHAPE_T::CIRCLE:
152 case SHAPE_T::BEZIER:
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;
217 std::vector<std::unique_ptr<PCB_SHAPE>> newShapes;
226 shapeList.push_back( shape );
234 std::vector<PCB_SHAPE*> items_to_select;
236 for( std::unique_ptr<PCB_SHAPE>& ptr : newShapes )
243 struct SIDE_CANDIDATE
250 if( start.x >
end.
x || start.y >
end.
y )
251 std::swap( start,
end );
259 std::vector<SIDE_CANDIDATE*> sides;
260 std::map<VECTOR2I, std::vector<SIDE_CANDIDATE*>> ptMap;
272 sides.emplace_back(
new SIDE_CANDIDATE( shape ) );
273 ptMap[ sides.back()->start ].push_back( sides.back() );
278 for( SIDE_CANDIDATE* side : sides )
283 SIDE_CANDIDATE*
left =
nullptr;
284 SIDE_CANDIDATE* top =
nullptr;
285 SIDE_CANDIDATE*
right =
nullptr;
286 SIDE_CANDIDATE* bottom =
nullptr;
288 auto viable = [&]( SIDE_CANDIDATE* aCandidate ) ->
bool
290 return aCandidate->shape->GetLayer() == side->shape->GetLayer()
291 && aCandidate->shape->GetWidth() == side->shape->GetWidth()
295 if( side->start.x == side->end.x )
301 for( SIDE_CANDIDATE* candidate : ptMap[
left->start ] )
303 if( candidate !=
left && viable( candidate ) )
310 else if( side->start.y == side->end.y )
316 for( SIDE_CANDIDATE* candidate : ptMap[ top->start ] )
318 if( candidate != top && viable( candidate ) )
330 for( SIDE_CANDIDATE* candidate : ptMap[ top->end ] )
332 if( candidate != top && candidate !=
left && viable( candidate ) )
339 for( SIDE_CANDIDATE* candidate : ptMap[
left->end ] )
341 if( candidate != top && candidate !=
left && viable( candidate ) )
348 if(
right && bottom &&
right->end == bottom->end )
356 item->SetItems(
left->shape, top->shape,
right->shape, bottom->shape );
363 rect->
SetShape( SHAPE_T::RECTANGLE );
366 rect->
SetEnd( bottom->end );
367 rect->
SetLayer( top->shape->GetLayer() );
368 rect->
SetStroke( top->shape->GetStroke() );
380 for( SIDE_CANDIDATE* side : sides )
387 wxCHECK_MSG(
m_parentFootprint, , wxT(
"mergePads() is FootprintEditor only" ) );
395 if( padToNetTieGroupMap[
pad->GetNumber() ] >= 0 )
403 if( !shapes.empty() )
405 std::shared_ptr<CLEANUP_ITEM> item = std::make_shared<CLEANUP_ITEM>(
CLEANUP_MERGE_PAD );
408 item->AddItem( shape );
410 item->AddItem(
pad );
constexpr int ARC_HIGH_DEF
int GetDRCEpsilon() const
Return an epsilon which accounts for rounding errors, etc.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
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)
void ConnectBoardShapes(std::vector< PCB_SHAPE * > &aShapeList, std::vector< std::unique_ptr< PCB_SHAPE > > &aNewShapes, 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)