KiCad PCB EDA Suite
Loading...
Searching...
No Matches
box2.h File Reference
#include <algorithm>
#include <limits>
#include <optional>
#include <math/vector2d.h>
#include <geometry/eda_angle.h>
#include <core/kicad_algo.h>
#include <trigo.h>

Go to the source code of this file.

Classes

class  BOX2< Vec >
 A 2D bounding box built on top of an origin point and size vector. More...
 

Typedefs

typedef BOX2< VECTOR2IBOX2I
 
typedef BOX2< VECTOR2DBOX2D
 
typedef BOX2< VECTOR2LBOX2L
 
typedef std::optional< BOX2IOPT_BOX2I
 

Functions

constexpr BOX2I BOX2ISafe (const BOX2D &aInput)
 
template<typename Vec >
constexpr bool IsBOX2Safe (const BOX2< Vec > &aInput)
 Check if a BOX2 is safe for use with BOX2D (probably BOX2D or BOX2L)
 
constexpr BOX2I BOX2ISafe (const VECTOR2D &aPos, const VECTOR2D &aSize)
 
template<typename S , std::enable_if_t< std::is_integral< S >::value, int > = 0>
constexpr BOX2I BOX2ISafe (const VECTOR2I &aPos, const VECTOR2< S > &aSize)
 
constexpr BOX2I KiROUND (const BOX2D &aBoxD)
 

Typedef Documentation

◆ BOX2D

typedef BOX2<VECTOR2D> BOX2D

Definition at line 923 of file box2.h.

◆ BOX2I

typedef BOX2<VECTOR2I> BOX2I

Definition at line 922 of file box2.h.

◆ BOX2L

typedef BOX2<VECTOR2L> BOX2L

Definition at line 924 of file box2.h.

◆ OPT_BOX2I

typedef std::optional<BOX2I> OPT_BOX2I

Definition at line 926 of file box2.h.

Function Documentation

◆ BOX2ISafe() [1/3]

◆ BOX2ISafe() [2/3]

constexpr BOX2I BOX2ISafe ( const VECTOR2D aPos,
const VECTOR2D aSize 
)
inlineconstexpr

Definition at line 959 of file box2.h.

References left, right, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ BOX2ISafe() [3/3]

template<typename S , std::enable_if_t< std::is_integral< S >::value, int > = 0>
constexpr BOX2I BOX2ISafe ( const VECTOR2I aPos,
const VECTOR2< S > &  aSize 
)
inlineconstexpr

Definition at line 975 of file box2.h.

References right, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ IsBOX2Safe()

template<typename Vec >
constexpr bool IsBOX2Safe ( const BOX2< Vec > &  aInput)
inlineconstexpr

Check if a BOX2 is safe for use with BOX2D (probably BOX2D or BOX2L)

Definition at line 949 of file box2.h.

References BOX2< Vec >::GetBottom(), BOX2< Vec >::GetLeft(), BOX2< Vec >::GetRight(), and BOX2< Vec >::GetTop().

Referenced by REFERENCE_IMAGE::Flip(), REFERENCE_IMAGE::scaleBy(), and REFERENCE_IMAGE::SetPosition().

◆ KiROUND()

constexpr BOX2I KiROUND ( const BOX2D aBoxD)
inlineconstexpr

Definition at line 990 of file box2.h.

References BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetSize(), and KiROUND().

Referenced by ZONE_FILLER::addHatchFillTypeOnZone(), FEATURES_MANAGER::AddPadShape(), PCB_IO_IPC2581::addPadStack(), PCB_IO_IPC2581::addShape(), TEARDROP_MANAGER::AddTeardropsOnTracks(), PCAD2KICAD::PCAD_POLYGON::AddToBoard(), SYMBOL_EDITOR_MOVE_TOOL::AlignElements(), Altium2KiCadUnit(), AltiumGetEllipticalPos(), CADSTAR_PCB_ARCHIVE_LOADER::applyTextCode(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextCodeIfExists(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), CADSTAR_SCH_ARCHIVE_LOADER::applyTransform(), HPGL_PLOTTER::Arc(), PDF_PLOTTER::Arc(), EDA_ANGLE::AsTenthsOfADegree(), SCH_DIRECTIVE_LABEL::AutoplaceFields(), SCH_SHEET::AutoplaceFields(), SHAPE_ARC::BBox(), PCB_GRID_HELPER::BestSnapAnchor(), KIGFX::bitmapText(), PCB_IO_KICAD_LEGACY::biuParse(), build45DegLeader(), BuildCornersList_S_Shape(), PNS::DP_GATEWAYS::buildDpContinuation(), PAD::BuildEffectivePolygon(), DIRECTION_45::BuildInitialTrace(), CalcArcCenter(), EDA_SHAPE::calcEdit(), PCAD2KICAD::CalculateTextLengthSize(), SHAPE_POLY_SET::chamferFilletPolygon(), SCH_EDIT_TOOL::ChangeTextType(), DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkews(), EE_INSPECTION_TOOL::CheckSymbol(), CircleToEndSegmentDeltaRadius(), Clamp_Text_PenSize(), EE_SELECTION_TOOL::CollectHits(), SHAPE_ARC::Collide(), commonParallelProjection(), TEARDROP_MANAGER::computeAnchorPoints(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), computeCenter(), TEARDROP_MANAGER::computeCurvedForRoundShape(), GRID_HELPER::computeNearest(), TEARDROP_MANAGER::computeTeardropPolygon(), ConfigureHPGLPenSizes(), ALTIUM_PCB::ConvertArcs6ToBoardItemOnLayer(), ALTIUM_PCB::ConvertArcs6ToPcbShape(), ConvertArcToPolyline(), AM_PRIMITIVE::ConvertBasicShapeToPolygon(), convertPolygon(), AM_PRIMITIVE::ConvertShapeToPolygon(), ALTIUM_PROPS_UTILS::ConvertToKicadUnit(), SHAPE_ARC::ConvertToPolyline(), PCAD2KICAD::CorrectTextPosition(), SCH_DIRECTIVE_LABEL::CreateGraphicShape(), BOARD_ADAPTER::createLayers(), MICROWAVE_TOOL::createPolygonShape(), CONVERT_TOOL::CreatePolys(), BOARD_ADAPTER::createTrackWithMargin(), PAD::doCheckPad(), EDIT_TOOL::DragArcTrack(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), GRID_CELL_LAYER_RENDERER::Draw(), KIGFX::drawAltPinModesIcon(), KIGFX::SCH_PAINTER::drawAnchor(), KIGFX::OPENGL_GAL::DrawArcSegment(), BITMAP_BASE::DrawBitmap(), KIGFX::OPENGL_GAL::drawBitmapChar(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), KIGFX::DrawDashedLine(), KIGFX::CAIRO_GAL_BASE::DrawGrid(), KIGFX::OPENGL_GAL::DrawGrid(), SCH_DRAWING_TOOLS::DrawTable(), DRAWING_TOOL::DrawTable(), GERBER_PLOTTER::emitDcode(), SIM_PLOT_TAB::EnableCursor(), PCBEXPR_EVALUATOR::Evaluate(), GERBER_FILE_IMAGE::ExecuteRS274XCommand(), extractDiffPairCoupledItems(), PANEL_GALVANIC_CORROSION::fillTable(), TEARDROP_MANAGER::findAnchorPointsOnTrack(), EDIT_POINTS::FindPoint(), HPGL_PLOTTER::FlashPadCircle(), HPGL_PLOTTER::FlashPadOval(), HPGL_PLOTTER::FlashPadRect(), HPGL_PLOTTER::FlashPadRoundRect(), GENCAD_EXPORTER::FootprintWriteShape(), DS_DATA_MODEL_IO::format(), EDA_TEXT::Format(), STROKE_PARAMS::Format(), formatFill(), BITMAP2CMP_PANEL::FormatOutputSize(), gen_arc(), GENDRILL_WRITER_BASE::genDrillMapFile(), GENERAL_COLLECTORS_GUIDE::GENERAL_COLLECTORS_GUIDE(), RENDER_3D_OPENGL::generate3dGrid(), PCB_IO_IPC2581::generateContentStackup(), WX_HTML_REPORT_BOX::generateHtml(), GERBER_DRAW_ITEM::GetABPosition(), SCH_LINE::GetAngleFrom(), DS_DRAW_ITEM_TEXT::GetApproxBBox(), GetArcToSegmentCount(), CADSTAR_SCH_ARCHIVE_LOADER::getCadstarAngle(), GetDeltasForDistributeByGaps(), GetDeltasForDistributeByPoints(), DS_DATA_ITEM::GetEndPosIU(), GRID_HELPER::GetGrid(), KIGFX::GAL::GetGridPoint(), getGUIFont(), EDA_TEXT::GetInterline(), GetKnockoutTextMargin(), SCH_LABEL_BASE::GetLabelBoxExpansion(), SCH_TEXTBOX::GetLegacyTextMargin(), PCB_TEXTBOX::GetLegacyTextMargin(), EDA_DRAW_FRAME::GetNearestGridPosition(), EDA_DRAW_FRAME::GetNearestHalfGridPosition(), EE_SELECTION_TOOL::GetNode(), KIGFX::SCH_PAINTER::getOperatingPointTextSize(), PCB_TUNING_PATTERN::getOutline(), IMAGE_SIZE::GetOutputDPI(), GetPenSizeForBold(), GetPenSizeForDemiBold(), GetPenSizeForNormal(), DS_DATA_ITEM::GetPenSizeIU(), DS_DATA_ITEM_POLYGONS::GetPenSizeIU(), DS_DATA_ITEM_TEXT::GetPenSizeIU(), PIN_LAYOUT_CACHE::GetPinElectricalTypeInfo(), PIN_LAYOUT_CACHE::GetPinNameInfo(), PIN_LAYOUT_CACHE::getPinTextOffset(), BEZIER_POLY::GetPoly(), EDA_SHAPE::GetRadius(), SCH_LINE::GetReverseAngleFrom(), EDIT_TOOL::getSafeMovement(), BITMAP_BASE::GetSize(), PAD::GetSolderPasteMargin(), DS_DATA_ITEM::GetStartPosIU(), KIFONT::OUTLINE_FONT::GetTextAsGlyphs(), KIFONT::STROKE_FONT::GetTextAsGlyphs(), EDA_TEXT::GetTextBox(), CADSTAR_SCH_ARCHIVE_LOADER::getTextHeightFromTextCode(), SCH_TEXT::GetTextOffset(), DIALOG_POSITION_RELATIVE::getTranslationInIU(), GERBER_DRAW_ITEM::GetXYPosition(), GRTextWidth(), EE_SELECTION_TOOL::GuessSelectionCandidates(), PCB_SELECTION_TOOL::GuessSelectionCandidates(), ZONE::HatchBorder(), ALTIUM_PCB::HelperParseDimensions6Leader(), HelperShapeLineChainFromAltiumVertices(), DIALOG_PLOT::init_Dialog(), initializePlotter(), GENERAL_COLLECTOR::Inspect(), SCH_EDIT_TOOL::InteractiveDelete(), PL_EDIT_TOOL::InteractiveDelete(), PCB_CONTROL::InteractiveDelete(), CIRCLE::Intersect(), CN_ANCHOR::IsDangling(), iu_to_d356(), KiROUND(), KiScaledBitmap(), PCB_IO_EAGLE::LoadBoard(), PCB_IO_EASYEDA::LoadBoard(), CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols(), SCH_IO_EAGLE::loadFrame(), SCH_IO_EAGLE::loadLabel(), SCH_IO_EAGLE::loadModuleInstance(), PCB_IO_EAGLE::loadPlain(), PCB_IO_EAGLE::loadPolygon(), CADSTAR_SCH_ARCHIVE_LOADER::loadShapeVertices(), PCB_IO_EAGLE::loadSignals(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymbolFieldAttribute(), PCB_TUNING_PATTERN::MakeEditPoints(), DSN::SPECCTRA_DB::makePADSTACK(), MapAnglesV6(), GRAPHICS_IMPORTER_LIB_SYMBOL::MapCoordinate(), GRAPHICS_IMPORTER_SCH::MapCoordinate(), GRAPHICS_IMPORTER_PCBNEW::MapCoordinate(), PLOTTER::markerSquare(), SIM_MODEL::MigrateSimModel(), EDA_UNIT_UTILS::Mils2mm(), GERBVIEW_PRINTOUT::milsToIU(), PCBNEW_PRINTOUT::milsToIU(), SCH_PRINTOUT::milsToIU(), EDA_UNIT_UTILS::Mm2mils(), ACTION_TOOLBAR::OnCustomRender(), PANEL_SYM_EDITING_OPTIONS::onKillFocusPinPitch(), EDA_LIST_DIALOG::onSize(), PANEL_PACKAGE::OnSize(), BITMAP2CMP_PANEL::OpenProjectFiles(), PCB_IO_EAGLE::orientFPText(), PCB_IO_EAGLE::packagePad(), PCB_IO_EAGLE::packagePolygon(), PCB_IO_EAGLE::packageText(), PANEL_PACKAGE::PANEL_PACKAGE(), PCAD2KICAD::PCAD_ARC::Parse(), SCH_IO_ALTIUM::ParseArc(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), PCB_IO_KICAD_SEXPR_PARSER::parseBoardUnits(), ALTIUM_PCB::ParseComponentsBodies6Data(), SCH_IO_ALTIUM::ParseEllipse(), SCH_IO_ALTIUM::ParseEllipticalArc(), parseInt(), SCH_IO_KICAD_SEXPR_PARSER::parseInternalUnits(), SCH_IO_ALTIUM::ParsePieChart(), SCH_EASYEDAPRO_PARSER::ParseSchematic(), SCH_EASYEDA_PARSER::ParseSchematic(), STROKE_PARAMS_PARSER::ParseStroke(), PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(), DRAWING_TOOL::PlaceTuningPattern(), SCH_SHEET::Plot(), SCH_TEXT::Plot(), GERBER_PLOTTER::plotArc(), SCH_SYMBOL::PlotDNP(), PS_PLOTTER::PlotImage(), BRDITEMS_PLOTTER::PlotPadNumber(), GERBER_PLOTTER::plotRoundRectAsRegion(), PLOTTER::polyArc(), SCH_SHEET::Print(), SCH_SYMBOL::Print(), SCH_TEXT::Print(), GERBER_DRAW_ITEM::Print(), FABMASTER::processArc(), FABMASTER::processFootprints(), FABMASTER::processLine(), FABMASTER::processPadStacks(), FABMASTER::processPins(), FABMASTER::processRectangle(), FABMASTER::processText(), FABMASTER::processVias(), GERBER_FILE_IMAGE::ReadIJCoord(), PARAM_CFG_INT_WITH_SCALE::ReadParam(), EXCELLON_IMAGE::readToolInformation(), GERBER_FILE_IMAGE::ReadXYCoord(), PANEL_SETUP_PINMAP::reBuildMatrixPanel(), KIGFX::PCB_PAINTER::renderNetNameForSegment(), PSLIKE_PLOTTER::returnPostscriptTextWidth(), RotatePoint(), rotationFromString(), EDA_ANGLE::Round(), PADSTACK::RoundRectRadius(), SCH_IO_KICAD_SEXPR::saveJunction(), SCH_IO_KICAD_SEXPR::saveSheet(), EDA_SHAPE::scale(), DSN::scale(), REFERENCE_IMAGE::scaleBy(), SCH_EASYEDA_PARSER::ScaleSize(), PCB_IO_EASYEDA_PARSER::ScaleSize(), SCH_EASYEDAPRO_PARSER::ScaleSize(), PCB_IO_EASYEDAPRO_PARSER::ScaleSize(), scaletoIU(), SCH_JUNCTION::SCH_JUNCTION(), SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS(), PNS::SegmentHull(), SegmentIntersectsSegment(), EE_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::SelectPoint(), DS_DATA_ITEM_TEXT::SetConstrainedTextSize(), GERBER_FILE_IMAGE::SetDrawOffetAndRotation(), PCAD2KICAD::SetTextSizeFromStrokeFontHeight(), PCAD2KICAD::SetTextSizeFromTrueTypeFontHeight(), SHAPE_ARC::SHAPE_ARC(), PNS::SHOVE::ShoveObstacleLine(), SCH_EDITOR_CONTROL::SimProbe(), SCH_EDITOR_CONTROL::SimTune(), snapAngle(), PS_PLOTTER::StartPlot(), KIFONT::FONT::StringBoundaryLimits(), STROKE_PARAMS::Stroke(), KIGFX::PCB_PAINTER::strokeText(), PCAD2KICAD::StrToInt1Units(), PCAD2KICAD::StrToIntUnits(), KIFONT::OUTLINE_FONT::subscriptSize(), DS_DATA_ITEM_TEXT::SyncDrawItems(), CONNECTIVITY_DATA::TestTrackEndpointDangling(), KIGFX::COLOR4D::ToHexString(), SPICE_VALUE::ToString(), AR_MATRIX::traceArc(), AR_MATRIX::traceCircle(), AR_MATRIX::TraceFilledRectangle(), DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_SYM_EDITING_OPTIONS::TransferDataFromWindow(), DIALOG_MOVE_EXACT::TransferDataFromWindow(), PANEL_SETUP_CONSTRAINTS::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow(), TransformRoundChamferedRectToPolygon(), TransformTrapezoidToPolygon(), SHAPE_ARC::update_values(), DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample(), PCB_TUNING_PATTERN::UpdateEditPoints(), PCB_TUNING_PATTERN::UpdateFromEditPoints(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), BITMAP_BASE::updatePPI(), TUNER_SLIDER::updateSlider(), PCB_DIM_RADIAL::updateText(), SIMULATOR_FRAME_UI::updateTrace(), DIALOG_DRC::updateUI(), TUNING_STATUS_VIEW_ITEM::ViewDraw(), ROUTER_STATUS_VIEW_ITEM::ViewDraw(), KIGFX::PREVIEW::BEZIER_ASSISTANT::ViewDraw(), PCB_TUNING_PATTERN::ViewDraw(), KIGFX::ORIGIN_VIEWITEM::ViewDraw(), EXCELLON_WRITER::writeCoordinates(), WriteImageStream(), EE_SELECTION_TOOL::ZoomFitCrossProbeBBox(), and PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox().