KiCad PCB EDA Suite
Loading...
Searching...
No Matches
spread_footprints.cpp File Reference

functions to spread footprints on free areas outside a board. More...

#include <spread_footprints.h>
#include <optional>
#include <algorithm>
#include <refdes_utils.h>
#include <string_utils.h>
#include <confirm.h>
#include <pcb_edit_frame.h>
#include <board.h>
#include <rectpack2d/finders_interface.h>

Go to the source code of this file.

Typedefs

using spaces_type = rectpack2D::empty_spaces< allow_flip, rectpack2D::default_empty_spaces >
 
using rect_type = rectpack2D::output_rect_t< spaces_type >
 
using rect_ptr = rect_type *
 
using rect_vector = std::vector< rect_type >
 

Functions

static bool compareFootprintsbyRef (FOOTPRINT *ref, FOOTPRINT *compare)
 
std::optional< rectpack2D::rect_wh > spreadRectangles (rect_vector &vecSubRects, int areaSizeX, int areaSizeY)
 
void SpreadFootprints (std::vector< FOOTPRINT * > *aFootprints, VECTOR2I aTargetBoxPosition, bool aGroupBySheet, int aComponentGap, int aGroupGap)
 Footprints (after loaded by reading a netlist for instance) are moved to be in a small free area (outside the current board) without overlapping.
 

Variables

constexpr bool allow_flip = true
 
const int scale = (int) ( 0.01 * pcbIUScale.IU_PER_MM )
 

Detailed Description

functions to spread footprints on free areas outside a board.

this is useful after reading a netlist, when new footprints are loaded and stacked at 0,0 coordinate. Often, spread them on a free area near the board being edited make more easy their selection.

Definition in file spread_footprints.cpp.

Typedef Documentation

◆ rect_ptr

using rect_ptr = rect_type*

Definition at line 52 of file spread_footprints.cpp.

◆ rect_type

using rect_type = rectpack2D::output_rect_t<spaces_type>

Definition at line 51 of file spread_footprints.cpp.

◆ rect_vector

using rect_vector = std::vector<rect_type>

Definition at line 53 of file spread_footprints.cpp.

◆ spaces_type

using spaces_type = rectpack2D::empty_spaces<allow_flip, rectpack2D::default_empty_spaces>

Definition at line 50 of file spread_footprints.cpp.

Function Documentation

◆ compareFootprintsbyRef()

static bool compareFootprintsbyRef ( FOOTPRINT ref,
FOOTPRINT compare 
)
static

◆ SpreadFootprints()

void SpreadFootprints ( std::vector< FOOTPRINT * > *  aFootprints,
VECTOR2I  aTargetBoxPosition,
bool  aGroupBySheet = true,
int  aComponentGap = pcbIUScale.mmToIU(1),
int  aGroupGap = pcbIUScale.mmToIU(1.5) 
)

Footprints (after loaded by reading a netlist for instance) are moved to be in a small free area (outside the current board) without overlapping.

Parameters
aBoardis the board to edit.
aFootprintsa list of footprints to be spread out.
aTargetBoxPositionthe position of the upper left corner of the area allowed to spread footprints

Definition at line 125 of file spread_footprints.cpp.

References compareFootprintsbyRef(), BOX2< Vec >::GetArea(), FOOTPRINT::GetBoundingBox(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Inflate(), BOX2< Vec >::Merge(), FOOTPRINT::Move(), path, scale, spreadRectangles(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PCB_EDIT_FRAME::OnNetlistChanged(), and EDIT_TOOL::PackAndMoveFootprints().

◆ spreadRectangles()

std::optional< rectpack2D::rect_wh > spreadRectangles ( rect_vector vecSubRects,
int  areaSizeX,
int  areaSizeY 
)

Definition at line 81 of file spread_footprints.cpp.

References scale.

Referenced by SpreadFootprints().

Variable Documentation

◆ allow_flip

constexpr bool allow_flip = true
constexpr

Definition at line 48 of file spread_footprints.cpp.

◆ scale

const int scale = (int) ( 0.01 * pcbIUScale.IU_PER_MM )

Definition at line 56 of file spread_footprints.cpp.

Referenced by DXF_IMPORT_PLUGIN::addInsert(), ACTION_TOOLBAR::AddScaledSeparator(), GRID_MENU::BuildChoiceList(), Clamp_Text_PenSize(), KIGFX::GAL::ComputeWorldScreenMatrix(), KIGFX::CAIRO_PRINT_GAL::ComputeWorldScreenMatrix(), SCH_PLOTTER::createPSFiles(), EDA_3D_CANVAS::DoRePaint(), EESCHEMA_JOBS_HANDLER::doSymExportSvg(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomToPreset(), KIGFX::CAIRO_GAL_BASE::DrawBitmap(), KIGFX::OPENGL_GAL::DrawBitmap(), BITMAP_BASE::DrawBitmap(), WX_AUI_TOOLBAR_ART::DrawButton(), SCH_EDIT_FRAME::DrawCurrentSheetToClipboard(), PCB_EDIT_FRAME::Export_IDF3(), DSN::SPECCTRA_DB::exportNETCLASS(), PCB_SELECTION_TOOL::FindItem(), DESIGN_BLOCK_PREVIEW_WIDGET::fitOnDrawArea(), SYMBOL_PREVIEW_WIDGET::fitOnDrawArea(), DSN::SPECCTRA_DB::FromBOARD(), GENDRILL_WRITER_BASE::genDrillMapFile(), RENDER_3D_OPENGL::generate3dGrid(), RENDER_3D_OPENGL::get3dModelsFromFootprint(), DXF_IMPORT_PLUGIN::getCurrentUnitScale(), KIUI::GetDockedPaneFont(), getEnvironmentScale(), getKiCadConfiguredScale(), SIMULATOR_FRAME_UI::getNoiseSource(), BEZIER_POLY::getQuadPoly(), DIALOG_PRINT_GENERIC::getScaleValue(), KIUI::GetStatusFont(), NL_SCHEMATIC_PLUGIN_IMPL::GetViewExtents(), NL_GERBVIEW_PLUGIN_IMPL::GetViewExtents(), NL_PL_EDITOR_PLUGIN_IMPL::GetViewExtents(), NL_PCBNEW_PLUGIN_IMPL::GetViewExtents(), idf_export_footprint(), idf_export_outline(), PCBNEW_JOBS_HANDLER::JobExportStep(), KiScaledBitmap(), KIGFX::WX_VIEW_CONTROLS::LoadSettings(), DSN::SPECCTRA_DB::makeIMAGE(), DSN::SPECCTRA_DB::makePADSTACK(), DSN::SPECCTRA_DB::makeTRACK(), DSN::SPECCTRA_DB::makeVia(), DSN::SPECCTRA_DB::makeVIA(), GRAPHICS_IMPORTER_LIB_SYMBOL::MapLineWidth(), GRAPHICS_IMPORTER_SCH::MapLineWidth(), GRAPHICS_IMPORTER_PCBNEW::MapLineWidth(), DSN::mapPt(), DSN::mapX(), DSN::mapY(), PCB_EDIT_FRAME::OnExportVRML(), KIGFX::WX_VIEW_CONTROLS::onMotion(), BITMAP_BUTTON::OnPaint(), DIALOG_PIN_PROPERTIES::OnPaintShowPanel(), PANEL_SETUP_BOARD_STACKUP::onUnitsChanged(), std::hash< SCALED_BITMAP_ID >::operator()(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), DIALOG_SIM_COMMAND::parseCommand(), SCH_IO_KICAD_SEXPR_PARSER::parseImage(), SCH_EASYEDAPRO_PARSER::ParseSymbol(), SCH_EASYEDA_PARSER::ParseSymbolShapes(), SCH_PLOTTER::plotOneSheetSVG(), PCB_EDIT_FRAME::PrepareLayerIndicator(), PANEL_GRID_SETTINGS::RebuildGridSizes(), COMMON_TOOLS::Reset(), GBR_LAYER_BOX_SELECTOR::Resync(), PCB_LAYER_BOX_SELECTOR::Resync(), ROW_ICON_PROVIDER::ROW_ICON_PROVIDER(), SCH_IO_KICAD_SEXPR::saveBitmap(), PCB_SHAPE::Scale(), ZOOM_TOOL::selectRegion(), UNIT_BINDER::setPrecision(), SCH_PLOTTER::setupPlotPagePDF(), NL_SCHEMATIC_PLUGIN_IMPL::SetViewExtents(), NL_GERBVIEW_PLUGIN_IMPL::SetViewExtents(), NL_PL_EDITOR_PLUGIN_IMPL::SetViewExtents(), NL_PCBNEW_PLUGIN_IMPL::SetViewExtents(), GERBVIEW_INSPECTION_TOOL::ShowDCodes(), SpreadFootprints(), spreadRectangles(), SYMBOL_EDIT_FRAME::SVGPlotSymbol(), SPICE_VALUE::ToString(), DIALOG_IMPORT_GFX_SCH::TransferDataFromWindow(), DIALOG_IMPORT_GRAPHICS::TransferDataFromWindow(), PANEL_IMAGE_EDITOR::TransferToImage(), PANEL_TRACK_WIDTH::TWCalculateCurrent(), PANEL_TRACK_WIDTH::TWCalculateWidth(), GERBVIEW_FRAME::updateDCodeSelectBox(), DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample(), PANEL_EESCHEMA_COLOR_SETTINGS::zoomFitPreview(), PANEL_PCBNEW_COLOR_SETTINGS::zoomFitPreview(), PANEL_ZONE_GAL::ZoomFitScreen(), and PCB_SELECTION_TOOL::zoomFitSelection().