55 TRect( 0, 0, _w, _h ),
n( _n ) { }
70 for(
unsigned ii = 0; ii < aFootprintList.size(); ii++ )
72 EDA_RECT fpBox = aFootprintList[ii]->GetBoundingBox(
false,
false );
75 vecSubRects.push_back( fpRect );
84 for(
unsigned ii = 0; ii < aRectList.size(); ii++ )
88 vecSubRects.push_back( fpRect );
97 int areaSizeX,
int areaSizeY )
106 aPlacementArea.
Init( areaSizeX, areaSizeY );
109 CSubRectArray::iterator it;
111 for( it = vecSubRects.begin(); it != vecSubRects.end(); )
121 if( areaSizeX < INT_MAX/2 )
124 areaSizeX = areaSizeX * 1.2;
127 if( areaSizeX < INT_MAX/2 )
130 areaSizeY = areaSizeY * 1.2;
135 aPlacementArea.
Init( areaSizeX, areaSizeY );
136 it = vecSubRects.begin();
152 EDA_RECT& aFreeArea,
bool aFindAreaOnly )
162 for(
unsigned it = 0; it < vecSubRects.size(); ++it )
164 wxPoint pos( vecSubRects[it].x, vecSubRects[it].y );
168 FOOTPRINT* footprint = aFootprintList[vecSubRects[it].n];
193 std::vector <FOOTPRINT*> footprintList;
195 for(
FOOTPRINT* footprint : *aFootprints )
197 if( footprint->IsLocked() )
200 footprintList.push_back( footprint );
203 if( footprintList.empty() )
210 std::vector <FOOTPRINT*> footprintListBySheet;
211 std::vector <EDA_RECT> placementSheetAreas;
213 double placementsurface = 0.0;
219 for(
int pass = 0; pass < 2; pass++ )
222 footprintListBySheet.clear();
225 int fp_max_width = 0;
226 int fp_max_height = 0;
228 for(
unsigned ii = 0; ii < footprintList.size(); ii++ )
230 FOOTPRINT* footprint = footprintList[ii];
231 bool islastItem =
false;
233 if( ii == footprintList.size() - 1 ||
234 ( footprintList[ii]->GetPath().AsString().BeforeLast(
'/' ) !=
235 footprintList[ii+1]->GetPath().AsString().BeforeLast(
'/' ) ) )
238 footprintListBySheet.push_back( footprint );
243 fp_max_width = std::max( fp_max_width, bbox.
GetWidth() );
244 fp_max_height = std::max( fp_max_height, bbox.
GetHeight() );
251 int Xsize_allowed = (int) ( sqrt( subsurface ) * 4.0 / 3.0 );
252 Xsize_allowed = std::max( fp_max_width, Xsize_allowed );
254 int Ysize_allowed = (int) ( subsurface / Xsize_allowed );
255 Ysize_allowed = std::max( fp_max_height, Ysize_allowed );
263 wxPoint areapos = placementSheetAreas[subareaIdx].GetOrigin()
264 + aSpreadAreaPosition;
268 bool findAreaOnly = pass == 0;
280 placementSheetAreas.push_back( sub_area );
282 placementsurface += (double) sub_area.
GetWidth()*
288 footprintListBySheet.clear();
298 int Xsize_allowed = (int) ( sqrt( placementsurface ) * 4.0 / 3.0 );
300 if( Xsize_allowed <= 0 || Xsize_allowed > INT_MAX/2 )
301 Xsize_allowed = INT_MAX/2;
303 int Ysize_allowed = (int) ( placementsurface / Xsize_allowed );
305 if( Ysize_allowed <= 0 || Ysize_allowed > INT_MAX/2 )
306 Ysize_allowed = INT_MAX/2;
311 spreadRectangles( placementArea, vecSubRects, Xsize_allowed, Ysize_allowed );
313 for(
unsigned it = 0; it < vecSubRects.size(); ++it )
321 if( (uint64_t)pos.x + (uint64_t)size.x > INT_MAX/2 )
324 if( (uint64_t)pos.y + (uint64_t)size.y > INT_MAX/2 )
327 placementSheetAreas[srect.
n].SetOrigin( pos );
328 placementSheetAreas[srect.
n].SetSize( size );
void Init(int w=1, int h=1)
This file is part of the common library.
static constexpr double IU_PER_MM
Mock up a conversion function.
void SetOrigin(const wxPoint &pos)
static bool Greater(const TRect &a, const TRect &b)
const wxPoint GetOrigin() const
TSubRect(int _w, int _h, int _n)
Handle the component boundary box.
bool AddAtEmptySpotAutoGrow(TRect *pRect, int maxW, int maxH)
static constexpr int Millimeter2iu(double mm)
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.