KiCad PCB EDA Suite
BOX2< Vec > Class Template Reference

A 2D bounding box built on top of an origin point and size vector. More...

#include <box2.h>

Public Types

typedef Vec::coord_type coord_type
 
typedef Vec::extended_type ecoord_type
 
typedef std::numeric_limits< coord_typecoord_limits
 

Public Member Functions

 BOX2 ()
 
 BOX2 (const Vec &aPos, const Vec &aSize=Vec(0, 0))
 
void SetMaximum ()
 
Vec Centre () const
 
template<class Container >
void Compute (const Container &aPointList)
 Compute the bounding box from a given list of points. More...
 
void Move (const Vec &aMoveVector)
 Move the rectangle by the aMoveVector. More...
 
BOX2< Vec > & Normalize ()
 Ensure that the height and width are positive. More...
 
bool Contains (const Vec &aPoint) const
 
bool Contains (coord_type x, coord_type y) const
 
bool Contains (const BOX2< Vec > &aRect) const
 
const Vec & GetSize () const
 
coord_type GetX () const
 
coord_type GetY () const
 
const Vec & GetOrigin () const
 
const Vec & GetPosition () const
 
const Vec GetEnd () const
 
coord_type GetWidth () const
 
coord_type GetHeight () const
 
coord_type GetRight () const
 
coord_type GetBottom () const
 
coord_type GetLeft () const
 
coord_type GetTop () const
 
const Vec GetCenter () const
 
int GetSizeMax () const
 
void SetOrigin (const Vec &pos)
 
void SetOrigin (coord_type x, coord_type y)
 
void SetSize (const Vec &size)
 
void SetSize (coord_type w, coord_type h)
 
void Offset (coord_type dx, coord_type dy)
 
void Offset (const Vec &offset)
 
void SetX (coord_type val)
 
void SetY (coord_type val)
 
void SetWidth (coord_type val)
 
void SetHeight (coord_type val)
 
void SetEnd (coord_type x, coord_type y)
 
void SetEnd (const Vec &pos)
 
bool Intersects (const BOX2< Vec > &aRect) const
 
BOX2< Vec > Intersect (const BOX2< Vec > &aRect)
 
bool Intersects (const Vec &aPoint1, const Vec &aPoint2) const
 
bool Intersects (const BOX2< Vec > &aRect, const EDA_ANGLE &aRotation) const
 
bool IntersectsCircle (const Vec &aCenter, const int aRadius) const
 
bool IntersectsCircleEdge (const Vec &aCenter, const int aRadius, const int aWidth) const
 
const std::string Format () const
 
BOX2< Vec > & Inflate (coord_type dx, coord_type dy)
 Inflates the rectangle horizontally by dx and vertically by dy. More...
 
BOX2< Vec > & Inflate (int aDelta)
 Inflate the rectangle horizontally and vertically by aDelta. More...
 
BOX2< Vec > & Merge (const BOX2< Vec > &aRect)
 Modify the position and size of the rectangle in order to contain aRect. More...
 
BOX2< Vec > & Merge (const Vec &aPoint)
 Modify the position and size of the rectangle in order to contain the given point. More...
 
const BOX2< Vec > GetBoundingBoxRotated (const VECTOR2I &aRotCenter, const EDA_ANGLE &aAngle) const
 Useful to calculate bounding box of rotated items, when rotation is not cardinal. More...
 
void RevertYAxis ()
 Mirror the rectangle from the X axis (negate Y pos and size). More...
 
ecoord_type GetArea () const
 Return the area of the rectangle. More...
 
ecoord_type Diagonal () const
 Return the length of the diagonal of the rectangle. More...
 
ecoord_type SquaredDistance (const Vec &aP) const
 
ecoord_type Distance (const Vec &aP) const
 
ecoord_type SquaredDistance (const BOX2< Vec > &aBox) const
 Return the square of the minimum distance between self and box aBox. More...
 
ecoord_type Distance (const BOX2< Vec > &aBox) const
 Return the minimum distance between self and aBox. More...
 
const Vec ClosestPointTo (const Vec &aPoint) const
 Return the point in this rect that is closest to the provided point. More...
 
const Vec FarthestPointTo (const Vec &aPoint) const
 Return the point in this rect that is farthest from the provided point. More...
 
bool operator== (const BOX2< Vec > &aOther) const
 
bool operator!= (const BOX2< Vec > &aOther) const
 

Private Attributes

Vec m_Pos
 
Vec m_Size
 
bool m_init
 

Detailed Description

template<class Vec>
class BOX2< Vec >

A 2D bounding box built on top of an origin point and size vector.

Definition at line 42 of file box2.h.

Member Typedef Documentation

◆ coord_limits

template<class Vec >
typedef std::numeric_limits<coord_type> BOX2< Vec >::coord_limits

Definition at line 47 of file box2.h.

◆ coord_type

template<class Vec >
typedef Vec::coord_type BOX2< Vec >::coord_type

Definition at line 45 of file box2.h.

◆ ecoord_type

template<class Vec >
typedef Vec::extended_type BOX2< Vec >::ecoord_type

Definition at line 46 of file box2.h.

Constructor & Destructor Documentation

◆ BOX2() [1/2]

template<class Vec >
BOX2< Vec >::BOX2 ( )
inline

Definition at line 49 of file box2.h.

49 :
50 m_Pos( 0, 0 ),
51 m_Size( 0, 0 ),
52 m_init( false )
53 {};
bool m_init
Definition: box2.h:843
Vec m_Size
Definition: box2.h:841
Vec m_Pos
Definition: box2.h:840

◆ BOX2() [2/2]

template<class Vec >
BOX2< Vec >::BOX2 ( const Vec &  aPos,
const Vec &  aSize = Vec(0, 0) 
)
inline

Definition at line 55 of file box2.h.

55 :
56 m_Pos( aPos ),
57 m_Size( aSize ),
58 m_init( true )
59 {
60 Normalize();
61 }
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119

References BOX2< Vec >::Normalize().

Member Function Documentation

◆ Centre()

template<class Vec >
Vec BOX2< Vec >::Centre ( ) const
inline

Definition at line 70 of file box2.h.

71 {
72 return Vec( m_Pos.x + ( m_Size.x / 2 ),
73 m_Pos.y + ( m_Size.y / 2 ) );
74 }

References BOX2< Vec >::m_Pos, and BOX2< Vec >::m_Size.

Referenced by COMMON_TOOLS::CenterContents(), SHAPE::Centre(), SCH_EDIT_TOOL::ChangeTextType(), PCB_GRID_HELPER::computeAnchors(), PCB_SELECTION_TOOL::doSyncSelection(), COMMON_TOOLS::doZoomFit(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), DRAWING_TOOL::DrawDimension(), BOARD_PRINTOUT::DrawPage(), BOARD_NETLIST_UPDATER::estimateFootprintInsertionPosition(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), AUTOPLACER::fieldBoxPlacement(), AUTOPLACER::fieldHPlacement(), SYMBOL_PREVIEW_WIDGET::fitOnDrawArea(), PCB_BASE_FRAME::FocusOnItems(), GENDRILL_WRITER_BASE::genDrillMapFile(), EDA_SHAPE::getCenter(), BOX2< Vec >::GetCenter(), GERBVIEW_SELECTION::GetCenter(), PCB_GROUP::GetPosition(), GERBER_DRAW_ITEM::HitTest(), initializePlotter(), BOARD_ADAPTER::InitSettings(), BOX2< Vec >::Intersects(), SCH_FIELD::IsHorizJustifyFlipped(), SCH_FIELD::IsVertJustifyFlipped(), CADSTAR_SCH_ARCHIVE_LOADER::Load(), SCH_EAGLE_PLUGIN::loadSheet(), SCH_EDIT_TOOL::Mirror(), PCB_EDIT_FRAME::OnExportIDF3(), DIALOG_PIN_PROPERTIES::OnPaintShowPanel(), SCH_FIELD::Plot(), LIB_FIELD::Plot(), LIB_TEXT::Plot(), SCH_FIELD::Print(), LIB_TEXT::print(), KIGFX::VIEW::SetCenter(), KIGFX::VIEW::SetViewport(), EE_SELECTION_TOOL::SyncSelection(), DRC_TEST_PROVIDER_MISC::testOutline(), KIGFX::WX_VIEW_CONTROLS::UpdateScrollbars(), PANEL_EESCHEMA_COLOR_SETTINGS::zoomFitPreview(), PANEL_PCBNEW_COLOR_SETTINGS::zoomFitPreview(), and PCB_SELECTION_TOOL::zoomFitSelection().

◆ ClosestPointTo()

template<class Vec >
const Vec BOX2< Vec >::ClosestPointTo ( const Vec &  aPoint) const
inline

Return the point in this rect that is closest to the provided point.

Definition at line 781 of file box2.h.

782 {
783 BOX2<Vec> me( *this );
784
785 me.Normalize(); // ensure size is >= 0
786
787 // Determine closest point to the circle centre within this rect
788 coord_type nx = std::max( me.GetLeft(), std::min( aPoint.x, me.GetRight() ) );
789 coord_type ny = std::max( me.GetTop(), std::min( aPoint.y, me.GetBottom() ) );
790
791 return Vec( nx, ny );
792 }
A 2D bounding box built on top of an origin point and size vector.
Definition: box2.h:43
Vec::coord_type coord_type
Definition: box2.h:45

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

Referenced by BOX2< Vec >::IntersectsCircle().

◆ Compute()

template<class Vec >
template<class Container >
void BOX2< Vec >::Compute ( const Container &  aPointList)
inline

Compute the bounding box from a given list of points.

Parameters
aPointListis the list points of the object.

Definition at line 82 of file box2.h.

83 {
84 Vec vmin, vmax;
85
86 typename Container::const_iterator i;
87
88 if( !aPointList.size() )
89 return;
90
91 vmin = vmax = aPointList[0];
92
93 for( i = aPointList.begin(); i != aPointList.end(); ++i )
94 {
95 Vec p( *i );
96 vmin.x = std::min( vmin.x, p.x );
97 vmin.y = std::min( vmin.y, p.y );
98 vmax.x = std::max( vmax.x, p.x );
99 vmax.y = std::max( vmax.y, p.y );
100 }
101
102 SetOrigin( vmin );
103 SetSize( vmax - vmin );
104 }
void SetOrigin(const Vec &pos)
Definition: box2.h:202
void SetSize(const Vec &size)
Definition: box2.h:213

References BOX2< Vec >::SetOrigin(), and BOX2< Vec >::SetSize().

Referenced by SHAPE_LINE_CHAIN::BBox(), SHAPE_LINE_CHAIN::GenerateBBoxCache(), and SHAPE_ARC::update_bbox().

◆ Contains() [1/3]

template<class Vec >
bool BOX2< Vec >::Contains ( const BOX2< Vec > &  aRect) const
inline
Parameters
aRectis the the area to test.
Returns
true if aRect is contained. A common edge is seen as contained.

Definition at line 174 of file box2.h.

175 {
176 return Contains( aRect.GetOrigin() ) && Contains( aRect.GetEnd() );
177 }
const Vec & GetOrigin() const
Definition: box2.h:183
const Vec GetEnd() const
Definition: box2.h:185
bool Contains(const Vec &aPoint) const
Definition: box2.h:141

References BOX2< Vec >::Contains(), BOX2< Vec >::GetEnd(), and BOX2< Vec >::GetOrigin().

◆ Contains() [2/3]

template<class Vec >
bool BOX2< Vec >::Contains ( const Vec &  aPoint) const
inline
Parameters
aPointis the point to test.
Returns
true if aPoint is inside the boundary box. A point on a edge is seen as inside.

Definition at line 141 of file box2.h.

142 {
143 Vec rel_pos = aPoint - m_Pos;
144 Vec size = m_Size;
145
146 if( size.x < 0 )
147 {
148 size.x = -size.x;
149 rel_pos.x += size.x;
150 }
151
152 if( size.y < 0 )
153 {
154 size.y = -size.y;
155 rel_pos.y += size.y;
156 }
157
158 return ( rel_pos.x >= 0 ) && ( rel_pos.y >= 0 ) && ( rel_pos.y <= size.y) &&
159 ( rel_pos.x <= size.x);
160 }

References BOX2< Vec >::m_Pos, and BOX2< Vec >::m_Size.

Referenced by AR_AUTOPLACER::AutoplaceFootprints(), LABEL_MANAGER::boxMtv(), PNS::AREA_CONSTRAINT::Check(), CN_VISITOR::checkZoneZoneConnection(), SHAPE_RECT::Collide(), BOX2< Vec >::Contains(), KIGFX::PCB_PAINTER::draw(), drawBacksideTicks(), DRAWING_TOOL::DrawDimension(), SCH_DRAWING_TOOLS::DrawSheet(), drawTicksAlongLine(), DRAWING_TOOL::DrawVia(), PCB_SELECTION_TOOL::FindItem(), EE_SELECTION_TOOL::GuessSelectionCandidates(), EDA_SHAPE::hitTest(), LIB_ITEM::HitTest(), LIB_TEXT::HitTest(), SCH_BUS_ENTRY_BASE::HitTest(), SCH_JUNCTION::HitTest(), SCH_LINE::HitTest(), SCH_NO_CONNECT::HitTest(), DS_DRAW_ITEM_BASE::HitTest(), DS_DRAW_ITEM_POLYPOLYGONS::HitTest(), DS_DRAW_ITEM_RECT::HitTest(), PAD::HitTest(), PCB_DIMENSION_BASE::HitTest(), PCB_TARGET::HitTest(), PCB_TRACK::HitTest(), PCB_VIA::HitTest(), PCB_ARC::HitTest(), ZONE::HitTest(), SCH_SHEET::HitTest(), FP_TEXTBOX::HitTest(), PCB_TEXTBOX::HitTest(), LIB_PIN::HitTest(), LIB_TEXTBOX::HitTest(), SCH_BITMAP::HitTest(), SCH_FIELD::HitTest(), SCH_LABEL_BASE::HitTest(), SCH_PIN::HitTest(), SCH_SHEET_PIN::HitTest(), SCH_SYMBOL::HitTest(), SCH_TEXT::HitTest(), SCH_TEXTBOX::HitTest(), DS_DRAW_ITEM_BITMAP::HitTest(), FOOTPRINT::HitTest(), PCB_BITMAP::HitTest(), GERBER_DRAW_ITEM::HitTest(), MARKER_BASE::HitTestMarker(), BOX2< Vec >::Intersects(), EE_SELECTION_TOOL::Main(), AR_AUTOPLACER::nearestPad(), ALTIUM_PCB::ParsePolygons6Data(), PNS::NODE::QueryJoints(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectPoint(), KIGFX::VIEW::SetCenter(), KIGFX::WX_VIEW_CONTROLS::SetCrossHairCursorPosition(), PCB_TEXT::TextHitTest(), EDA_TEXT::TextHitTest(), FP_TEXT::TextHitTest(), PCB_POINT_EDITOR::updateItem(), and KIGFX::WX_VIEW_CONTROLS::WarpMouseCursor().

◆ Contains() [3/3]

template<class Vec >
bool BOX2< Vec >::Contains ( coord_type  x,
coord_type  y 
) const
inline
Parameters
xis the x coordinate of the point to test.
yis the x coordinate of the point to test.
Returns
true if point is inside the boundary box. A point on a edge is seen as inside.

Definition at line 167 of file box2.h.

167{ return Contains( Vec( x, y ) ); }

References BOX2< Vec >::Contains().

Referenced by BOX2< Vec >::Contains().

◆ Diagonal()

template<class Vec >
ecoord_type BOX2< Vec >::Diagonal ( ) const
inline

Return the length of the diagonal of the rectangle.

Returns
The length of the rectangle diagonal.

Definition at line 711 of file box2.h.

712 {
713 return m_Size.EuclideanNorm();
714 }

References BOX2< Vec >::m_Size.

◆ Distance() [1/2]

template<class Vec >
ecoord_type BOX2< Vec >::Distance ( const BOX2< Vec > &  aBox) const
inline

Return the minimum distance between self and aBox.

Parameters
aBoxis the other box to get the distance from.
Returns
The distance from aBox.

Definition at line 773 of file box2.h.

774 {
775 return sqrt( SquaredDistance( aBox ) );
776 }
ecoord_type SquaredDistance(const Vec &aP) const
Definition: box2.h:716

References BOX2< Vec >::SquaredDistance().

◆ Distance() [2/2]

template<class Vec >
ecoord_type BOX2< Vec >::Distance ( const Vec &  aP) const
inline

Definition at line 727 of file box2.h.

728 {
729 return sqrt( SquaredDistance( aP ) );
730 }

References BOX2< Vec >::SquaredDistance().

Referenced by SHAPE_INDEX_LIST< T, >::query_iterator::next().

◆ FarthestPointTo()

template<class Vec >
const Vec BOX2< Vec >::FarthestPointTo ( const Vec &  aPoint) const
inline

Return the point in this rect that is farthest from the provided point.

Definition at line 797 of file box2.h.

798 {
799 BOX2<Vec> me( *this );
800
801 me.Normalize(); // ensure size is >= 0
802
803 coord_type fx;
804 coord_type fy;
805
806 Vec center = me.GetCenter();
807
808 if( aPoint.x < center.x )
809 fx = me.GetRight();
810 else
811 fx = me.GetLeft();
812
813 if( aPoint.y < center.y )
814 fy = me.GetBottom();
815 else
816 fy = me.GetTop();
817
818 return Vec( fx, fy );
819 }

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

Referenced by BOX2< Vec >::IntersectsCircleEdge().

◆ Format()

template<class Vec >
const std::string BOX2< Vec >::Format ( ) const
inline

Definition at line 493 of file box2.h.

494 {
495 std::stringstream ss;
496
497 ss << "( box corner " << m_Pos.Format() << " w " << m_Size.x << " h " << m_Size.y << " )";
498
499 return ss.str();
500 }

References BOX2< Vec >::m_Pos, and BOX2< Vec >::m_Size.

◆ GetArea()

template<class Vec >
ecoord_type BOX2< Vec >::GetArea ( ) const
inline

Return the area of the rectangle.

Returns
The area of the rectangle.

Definition at line 701 of file box2.h.

702 {
703 return (ecoord_type) GetWidth() * (ecoord_type) GetHeight();
704 }
Vec::extended_type ecoord_type
Definition: box2.h:46
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187

References BOX2< Vec >::GetHeight(), and BOX2< Vec >::GetWidth().

Referenced by SCH_SYMBOL::operator<(), and SpreadFootprints().

◆ GetBottom()

template<class Vec >
coord_type BOX2< Vec >::GetBottom ( ) const
inline

Definition at line 190 of file box2.h.

190{ return m_Pos.y + m_Size.y; }

References BOX2< Vec >::m_Pos, and BOX2< Vec >::m_Size.

Referenced by SHAPE_INDEX< T >::Add(), AR_AUTOPLACER::addPad(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), CN_ZONE_LAYER::BuildRTree(), ZONE_FILLER::buildThermalSpokes(), DRC_RTREE::CheckColliding(), ClipLine(), clipOutCode(), BOX2< Vec >::ClosestPointTo(), CN_ZONE_LAYER::Collide(), TEST_BOARD_ITEM_FIXTURE::CompareItems(), TEST_EE_ITEM_FIXTURE::CompareItems(), EE_RTREE::contains(), ConvertPolygonToBlocks(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), SCH_SYMBOL::doGetBoundingBox(), KIGFX::SCH_PAINTER::draw(), DRAWING_TOOL::DrawDimension(), DRC_RTREE::DRC_LAYER::DRC_LAYER(), EE_RTREE::EE_TYPE::EE_TYPE(), PDF_PLOTTER::EndPlot(), BOARD_NETLIST_UPDATER::estimateFootprintInsertionPosition(), BOX2< Vec >::FarthestPointTo(), AR_AUTOPLACER::fillMatrix(), GENDRILL_WRITER_BASE::genDrillMapFile(), AR_AUTOPLACER::genModuleOnRoutingMatrix(), PLACE_FILE_EXPORTER::GenReportData(), PCB_DIMENSION_BASE::GetBoundingBox(), PCB_TRACK::GetBoundingBox(), KIFONT::OUTLINE_FONT::getBoundingBox(), LIB_TEXTBOX::GetDrawPos(), SCH_TEXTBOX::GetDrawPos(), BOX2< Vec >::GetEnd(), SCH_SHEET::GetMinHeight(), DRC_RTREE::Insert(), EE_RTREE::insert(), CN_RTREE< T >::Insert(), KIGFX::VIEW_RTREE::Insert(), SCH_EAGLE_PLUGIN::loadSchematic(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), FP_TEXTBOX::Mirror(), PCB_TEXTBOX::Mirror(), DIALOG_MOVE_EXACT::OnTextChanged(), CN_RTREE< T >::Query(), KIGFX::VIEW_RTREE::Query(), SHAPE_INDEX< T >::Query(), DRC_RTREE::QueryColliding(), DRC_RTREE::QueryCollidingPairs(), DIALOG_PAD_PROPERTIES::redraw(), SHAPE_INDEX< T >::Reindex(), EE_RTREE::remove(), CN_RTREE< T >::Remove(), SHAPE_INDEX< T >::Remove(), KIGFX::VIEW::SetCenter(), SHAPE_POLY_SET::SHAPE_POLY_SET(), EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(), and PCB_POINT_EDITOR::updateItem().

◆ GetBoundingBoxRotated()

template<class Vec >
const BOX2< Vec > BOX2< Vec >::GetBoundingBoxRotated ( const VECTOR2I aRotCenter,
const EDA_ANGLE aAngle 
) const
inline

Useful to calculate bounding box of rotated items, when rotation is not cardinal.

Returns
the bounding box of this, after rotation.

Definition at line 650 of file box2.h.

652 {
653 VECTOR2I corners[4];
654
655 // Build the corners list
656 corners[0] = GetOrigin();
657 corners[2] = GetEnd();
658 corners[1].x = corners[0].x;
659 corners[1].y = corners[2].y;
660 corners[3].x = corners[2].x;
661 corners[3].y = corners[0].y;
662
663 // Rotate all corners, to find the bounding box
664 for( int ii = 0; ii < 4; ii++ )
665 RotatePoint( corners[ii], aRotCenter, aAngle );
666
667 // Find the corners bounding box
668 VECTOR2I start = corners[0];
669 VECTOR2I end = corners[0];
670
671 for( int ii = 1; ii < 4; ii++ )
672 {
673 start.x = std::min( start.x, corners[ii].x );
674 start.y = std::min( start.y, corners[ii].y );
675 end.x = std::max( end.x, corners[ii].x );
676 end.y = std::max( end.y, corners[ii].y );
677 }
678
679 BOX2<Vec> bbox;
680 bbox.SetOrigin( start );
681 bbox.SetEnd( end );
682
683 return bbox;
684 }
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:255
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

References BOX2< Vec >::GetEnd(), BOX2< Vec >::GetOrigin(), RotatePoint(), BOX2< Vec >::SetEnd(), BOX2< Vec >::SetOrigin(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by KIGFX::SCH_PAINTER::boxText(), FP_TEXT::GetBoundingBox(), PCB_TEXT::GetBoundingBox(), and FP_TEXT::ViewBBox().

◆ GetCenter()

◆ GetEnd()

template<class Vec >
const Vec BOX2< Vec >::GetEnd ( ) const
inline

Definition at line 185 of file box2.h.

185{ return Vec( GetRight(), GetBottom() ); }
coord_type GetRight() const
Definition: box2.h:189
coord_type GetBottom() const
Definition: box2.h:190

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

Referenced by BOOST_AUTO_TEST_CASE(), LABEL_MANAGER::boxMtv(), KIGFX::SCH_PAINTER::boxText(), buildBoardBoundingBoxPoly(), BuildBoardPolygonOutlines(), AR_AUTOPLACER::buildFpAreas(), AR_AUTOPLACER::calculateKeepOutArea(), SCH_EDIT_TOOL::ChangeTextType(), PDF_PLOTTER::ClosePage(), AR_MATRIX::ComputeMatrixSize(), BOX2< Vec >::Contains(), KIGFX::DS_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::GAL::DrawRectangle(), FillNegativeKnockout(), SCH_LABEL::GetBodyBoundingBox(), LIB_FIELD::GetBoundingBox(), LIB_TEXT::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), GERBER_DRAW_ITEM::GetBoundingBox(), PCB_DIMENSION_BASE::GetBoundingBox(), BOX2< Vec >::GetBoundingBoxRotated(), NL_SCHEMATIC_PLUGIN_IMPL::GetModelExtents(), NL_PCBNEW_PLUGIN_IMPL::GetModelExtents(), AR_AUTOPLACER::getOptimalFPPlacement(), EDIT_TOOL::getSafeMovement(), KIFONT::STROKE_FONT::GetTextAsGlyphs(), BOX2< Vec >::Intersects(), BOX2< Vec >::Merge(), PCB_SHAPE::NormalizeRect(), SVG_PLOTTER::Rect(), EDIT_TOOL::Rotate(), KIGFX::VIEW::SetBoundary(), AR_AUTOPLACER::testRectangle(), TRANSFORM::TransformCoordinate(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), and PCB_DIM_LEADER::updateGeometry().

◆ GetHeight()

template<class Vec >
coord_type BOX2< Vec >::GetHeight ( ) const
inline

Definition at line 188 of file box2.h.

188{ return m_Size.y; }

References BOX2< Vec >::m_Size.

Referenced by ZONE_FILLER::addHatchFillTypeOnZone(), GERBER_JOBFILE_WRITER::addJSONGeneralSpecs(), AUTOPLACE_TOOL::autoplace(), LABEL_MANAGER::boxMtv(), KIGFX::SCH_PAINTER::boxText(), buildBoardBoundingBoxPoly(), BuildBoardPolygonOutlines(), EAGLE_PLUGIN::centerBoard(), COMMON_TOOLS::CenterContents(), AUTOPLACER::computeFBoxSize(), AR_MATRIX::ComputeMatrixSize(), PNS::ConvexHull(), DIALOG_EXPORT_SVG::CreateSVGFile(), PNS::OPTIMIZER::customBreakouts(), EDIT_TOOL::doMoveSelection(), PCB_SELECTION_TOOL::doSyncSelection(), COMMON_TOOLS::doZoomFit(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), DRAWING_TOOL::DrawBoardCharacteristics(), DRAWING_TOOL::DrawDimension(), BOARD_PRINTOUT::DrawPage(), HPGL_PLOTTER::EndPlot(), BOARD_NETLIST_UPDATER::estimateFootprintInsertionPosition(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), AUTOPLACER::fieldBoxPlacement(), AUTOPLACER::fieldVPlacement(), PCB_SELECTION_TOOL::FindItem(), SYMBOL_PREVIEW_WIDGET::fitOnDrawArea(), PCB_BASE_FRAME::FocusOnItems(), GENDRILL_WRITER_BASE::genDrillMapFile(), AR_AUTOPLACER::genPlacementRoutingMatrix(), BOX2< Vec >::GetArea(), FOOTPRINT::GetArea(), PAD::GetBestAnchorPosition(), PCB_BASE_FRAME::GetBoardBoundingBox(), GERBER_DRAW_ITEM::GetBoundingBox(), DIALOG_BOARD_STATISTICS::getDataFromPCB(), PCB_BITMAP::GetEffectiveShape(), BOARD::GetFootprint(), NL_SCHEMATIC_PLUGIN_IMPL::GetModelExtents(), NL_PCBNEW_PLUGIN_IMPL::GetModelExtents(), AUTOPLACER::getPreferredSides(), KIFONT::OUTLINE_FONT::getTextAsGlyphs(), EDA_TEXT::GetTextBox(), NL_SCHEMATIC_PLUGIN_IMPL::GetViewExtents(), NL_PCBNEW_PLUGIN_IMPL::GetViewExtents(), EE_SELECTION_TOOL::GuessSelectionCandidates(), SCH_JUNCTION::HitTest(), PCB_SELECTION_TOOL::hitTestDistance(), BOARD_ADAPTER::InitSettings(), BOX2< Vec >::Intersects(), CADSTAR_PCB_ARCHIVE_PLUGIN::Load(), SCH_EAGLE_PLUGIN::loadSchematic(), DSN::SPECCTRA_DB::makePADSTACK(), LABEL_MANAGER::nearestBoxCorner(), LIB_TEXT::NormalizeJustification(), DIALOG_PIN_PROPERTIES::OnPaintShowPanel(), DIALOG_PAD_PROPERTIES::padValuesOK(), ALTIUM_PCB::Parse(), ALTIUM_PCB::ParsePolygons6Data(), partitionPolyIntoRegularCellGrid(), SCH_TEXT::Plot(), SCH_TEXT::Print(), KIGFX::VIEW::Redraw(), PNS_LOG_VIEWER_FRAME::SetBoard2(), KIGFX::VIEW::SetCenter(), DS_DATA_ITEM_TEXT::SetConstrainedTextSize(), PNS_LOG_VIEWER_FRAME::SetLogFile(), SpreadFootprints(), EE_SELECTION_TOOL::SyncSelection(), PolygonTriangulation::TesselatePolygon(), PCB_POINT_EDITOR::updateItem(), KIGFX::WX_VIEW_CONTROLS::UpdateScrollbars(), PANEL_PCBNEW_COLOR_SETTINGS::zoomFitPreview(), PCB_SELECTION_TOOL::zoomFitSelection(), PolygonTriangulation::zOrder(), and POLYGON_TEST::zOrder().

◆ GetLeft()

◆ GetOrigin()

template<class Vec >
const Vec & BOX2< Vec >::GetOrigin ( ) const
inline

Definition at line 183 of file box2.h.

183{ return m_Pos; }

References BOX2< Vec >::m_Pos.

Referenced by KIFONT::OUTLINE_GLYPH::BoundingBox(), KIGFX::SCH_PAINTER::boxText(), buildBoardBoundingBoxPoly(), BuildBoardPolygonOutlines(), AR_AUTOPLACER::buildFpAreas(), AR_AUTOPLACER::calculateKeepOutArea(), SCH_EDIT_TOOL::ChangeTextType(), BOX2< Vec >::Contains(), PNS::ConvexHull(), DIALOG_EXPORT_SVG::CreateSVGFile(), KIGFX::DS_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::GAL::DrawRectangle(), drawShapes(), FillNegativeKnockout(), PCB_SELECTION_TOOL::FindItem(), PCB_BASE_FRAME::FocusOnItems(), SCH_LABEL::GetBodyBoundingBox(), LIB_FIELD::GetBoundingBox(), LIB_TEXT::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), GERBER_DRAW_ITEM::GetBoundingBox(), PCB_DIMENSION_BASE::GetBoundingBox(), BOX2< Vec >::GetBoundingBoxRotated(), AR_MATRIX::GetBrdCoordOrigin(), NL_SCHEMATIC_PLUGIN_IMPL::GetModelExtents(), NL_PCBNEW_PLUGIN_IMPL::GetModelExtents(), AR_AUTOPLACER::getOptimalFPPlacement(), ROUTER_TOOL::handleCommonEvents(), idf_export_outline(), ROUTER_TOOL::InlineDrag(), BOX2< Vec >::Intersects(), operator<<(), EDIT_TOOL::PackAndMoveFootprints(), playground_main_func(), SVG_PLOTTER::Rect(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), KIGFX::VIEW::SetBoundary(), SpreadFootprints(), AR_AUTOPLACER::testRectangle(), EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(), TRANSFORM::TransformCoordinate(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), PCB_DIM_LEADER::updateGeometry(), PAD::ViewBBox(), and PCB_TRACK::ViewGetLOD().

◆ GetPosition()

◆ GetRight()

template<class Vec >
coord_type BOX2< Vec >::GetRight ( ) const
inline

Definition at line 189 of file box2.h.

189{ return m_Pos.x + m_Size.x; }

References BOX2< Vec >::m_Pos, and BOX2< Vec >::m_Size.

Referenced by SHAPE_INDEX< T >::Add(), AR_AUTOPLACER::addPad(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), CN_ZONE_LAYER::BuildRTree(), ZONE_FILLER::buildThermalSpokes(), DRC_RTREE::CheckColliding(), ClipLine(), clipOutCode(), BOX2< Vec >::ClosestPointTo(), CN_ZONE_LAYER::Collide(), TEST_BOARD_ITEM_FIXTURE::CompareItems(), TEST_EE_ITEM_FIXTURE::CompareItems(), EE_RTREE::contains(), ConvertPolygonToBlocks(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), SCH_SYMBOL::doGetBoundingBox(), KIGFX::SCH_PAINTER::draw(), DRAWING_TOOL::DrawDimension(), DRC_RTREE::DRC_LAYER::DRC_LAYER(), EE_RTREE::EE_TYPE::EE_TYPE(), PDF_PLOTTER::EndPlot(), BOX2< Vec >::FarthestPointTo(), AUTOPLACER::fieldBoxPlacement(), AUTOPLACER::fieldHPlacement(), AR_AUTOPLACER::genModuleOnRoutingMatrix(), PLACE_FILE_EXPORTER::GenReportData(), PCB_DIMENSION_BASE::GetBoundingBox(), PCB_TRACK::GetBoundingBox(), KIFONT::OUTLINE_FONT::getBoundingBox(), LIB_TEXTBOX::GetDrawPos(), SCH_TEXTBOX::GetDrawPos(), BOX2< Vec >::GetEnd(), SCH_SHEET::GetMinWidth(), DRC_RTREE::Insert(), EE_RTREE::insert(), CN_RTREE< T >::Insert(), KIGFX::VIEW_RTREE::Insert(), FP_TEXTBOX::Mirror(), PCB_TEXTBOX::Mirror(), DIALOG_MOVE_EXACT::OnTextChanged(), CN_RTREE< T >::Query(), KIGFX::VIEW_RTREE::Query(), SHAPE_INDEX< T >::Query(), DRC_RTREE::QueryColliding(), DRC_RTREE::QueryCollidingPairs(), DIALOG_PAD_PROPERTIES::redraw(), SHAPE_INDEX< T >::Reindex(), EE_RTREE::remove(), CN_RTREE< T >::Remove(), SHAPE_INDEX< T >::Remove(), KIGFX::VIEW::SetCenter(), SHAPE_POLY_SET::SHAPE_POLY_SET(), EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(), PCB_POINT_EDITOR::updateItem(), and KIGFX::WX_VIEW_CONTROLS::UpdateScrollbars().

◆ GetSize()

◆ GetSizeMax()

template<class Vec >
int BOX2< Vec >::GetSizeMax ( ) const
inline
Returns
the width or height, whichever is greater.

Definition at line 200 of file box2.h.

200{ return ( m_Size.x > m_Size.y ) ? m_Size.x : m_Size.y; }

References BOX2< Vec >::m_Size.

Referenced by BOARD_ADAPTER::addShape(), SCH_LABEL_BASE::AutoplaceFields(), and ZONE_FILLER::fillCopperZone().

◆ GetTop()

◆ GetWidth()

template<class Vec >
coord_type BOX2< Vec >::GetWidth ( ) const
inline

Definition at line 187 of file box2.h.

187{ return m_Size.x; }

References BOX2< Vec >::m_Size.

Referenced by ZONE_FILLER::addHatchFillTypeOnZone(), GERBER_JOBFILE_WRITER::addJSONGeneralSpecs(), AUTOPLACE_TOOL::autoplace(), BOOST_AUTO_TEST_CASE(), LABEL_MANAGER::boxMtv(), KIGFX::SCH_PAINTER::boxText(), buildBoardBoundingBoxPoly(), BuildBoardPolygonOutlines(), EAGLE_PLUGIN::centerBoard(), COMMON_TOOLS::CenterContents(), AUTOPLACER::computeFBoxSize(), AR_MATRIX::ComputeMatrixSize(), PNS::ConvexHull(), SCH_GLOBALLABEL::CreateGraphicShape(), DIALOG_EXPORT_SVG::CreateSVGFile(), PNS::OPTIMIZER::customBreakouts(), EDIT_TOOL::doMoveSelection(), PCB_SELECTION_TOOL::doSyncSelection(), COMMON_TOOLS::doZoomFit(), KIGFX::PCB_PAINTER::draw(), DRAWING_TOOL::DrawBoardCharacteristics(), DRAWING_TOOL::DrawDimension(), BOARD_PRINTOUT::DrawPage(), HPGL_PLOTTER::EndPlot(), BOARD_NETLIST_UPDATER::estimateFootprintInsertionPosition(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), AUTOPLACER::fieldBoxPlacement(), PCB_SELECTION_TOOL::FindItem(), SYMBOL_PREVIEW_WIDGET::fitOnDrawArea(), PCB_BASE_FRAME::FocusOnItems(), GENDRILL_WRITER_BASE::genDrillMapFile(), AR_AUTOPLACER::genPlacementRoutingMatrix(), BOX2< Vec >::GetArea(), FOOTPRINT::GetArea(), PCB_BASE_FRAME::GetBoardBoundingBox(), SCH_HIERLABEL::GetBodyBoundingBox(), GERBER_DRAW_ITEM::GetBoundingBox(), DIALOG_BOARD_STATISTICS::getDataFromPCB(), PCB_BITMAP::GetEffectiveShape(), BOARD::GetFootprint(), NL_SCHEMATIC_PLUGIN_IMPL::GetModelExtents(), NL_PCBNEW_PLUGIN_IMPL::GetModelExtents(), AUTOPLACER::getPreferredSides(), EDA_TEXT::GetTextBox(), NL_SCHEMATIC_PLUGIN_IMPL::GetViewExtents(), NL_PCBNEW_PLUGIN_IMPL::GetViewExtents(), EE_SELECTION_TOOL::GuessSelectionCandidates(), SCH_JUNCTION::HitTest(), PCB_SELECTION_TOOL::hitTestDistance(), BOARD_ADAPTER::InitSettings(), BOX2< Vec >::Intersects(), CADSTAR_PCB_ARCHIVE_PLUGIN::Load(), SCH_EAGLE_PLUGIN::loadSchematic(), DSN::SPECCTRA_DB::makePADSTACK(), LABEL_MANAGER::nearestBoxCorner(), NL_PCBNEW_PLUGIN_IMPL::NL_PCBNEW_PLUGIN_IMPL(), LIB_TEXT::NormalizeJustification(), DIALOG_PIN_PROPERTIES::OnPaintShowPanel(), DIALOG_PAD_PROPERTIES::padValuesOK(), ALTIUM_PCB::Parse(), ALTIUM_PCB::ParsePolygons6Data(), partitionPolyIntoRegularCellGrid(), KIGFX::VIEW::Redraw(), PNS_LOG_VIEWER_FRAME::SetBoard2(), NL_SCHEMATIC_PLUGIN_IMPL::SetCanvas(), KIGFX::VIEW::SetCenter(), DS_DATA_ITEM_TEXT::SetConstrainedTextSize(), PNS_LOG_VIEWER_FRAME::SetLogFile(), NL_SCHEMATIC_PLUGIN_IMPL::SetViewExtents(), NL_PCBNEW_PLUGIN_IMPL::SetViewExtents(), SpreadFootprints(), EE_SELECTION_TOOL::SyncSelection(), PolygonTriangulation::TesselatePolygon(), PCB_DIM_LEADER::updateGeometry(), PCB_POINT_EDITOR::updateItem(), KIGFX::WX_VIEW_CONTROLS::UpdateScrollbars(), GERBER_DRAW_ITEM::ViewGetLOD(), EE_SELECTION_TOOL::ZoomFitCrossProbeBBox(), PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox(), PANEL_PCBNEW_COLOR_SETTINGS::zoomFitPreview(), PCB_SELECTION_TOOL::zoomFitSelection(), PolygonTriangulation::zOrder(), and POLYGON_TEST::zOrder().

◆ GetX()

◆ GetY()

◆ Inflate() [1/2]

template<class Vec >
BOX2< Vec > & BOX2< Vec >::Inflate ( coord_type  dx,
coord_type  dy 
)
inline

Inflates the rectangle horizontally by dx and vertically by dy.

If dx and/or dy is negative the rectangle is deflated.

Definition at line 506 of file box2.h.

507 {
508 if( m_Size.x >= 0 )
509 {
510 if( m_Size.x < -2 * dx )
511 {
512 // Don't allow deflate to eat more width than we have,
513 m_Pos.x += m_Size.x / 2;
514 m_Size.x = 0;
515 }
516 else
517 {
518 // The inflate is valid.
519 m_Pos.x -= dx;
520 m_Size.x += 2 * dx;
521 }
522 }
523 else // size.x < 0:
524 {
525 if( m_Size.x > 2 * dx )
526 {
527 // Don't allow deflate to eat more width than we have,
528 m_Pos.x -= m_Size.x / 2;
529 m_Size.x = 0;
530 }
531 else
532 {
533 // The inflate is valid.
534 m_Pos.x += dx;
535 m_Size.x -= 2 * dx; // m_Size.x <0: inflate when dx > 0
536 }
537 }
538
539 if( m_Size.y >= 0 )
540 {
541 if( m_Size.y < -2 * dy )
542 {
543 // Don't allow deflate to eat more height than we have,
544 m_Pos.y += m_Size.y / 2;
545 m_Size.y = 0;
546 }
547 else
548 {
549 // The inflate is valid.
550 m_Pos.y -= dy;
551 m_Size.y += 2 * dy;
552 }
553 }
554 else // size.y < 0:
555 {
556 if( m_Size.y > 2 * dy )
557 {
558 // Don't allow deflate to eat more height than we have,
559 m_Pos.y -= m_Size.y / 2;
560 m_Size.y = 0;
561 }
562 else
563 {
564 // The inflate is valid.
565 m_Pos.y += dy;
566 m_Size.y -= 2 * dy; // m_Size.y <0: inflate when dy > 0
567 }
568 }
569
570 return *this;
571 }

References BOX2< Vec >::m_Pos, and BOX2< Vec >::m_Size.

Referenced by AR_AUTOPLACER::addPad(), SHAPE_ARC::BBox(), SHAPE_LINE_CHAIN::BBox(), SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI::BBox(), SHAPE_POLY_SET::BBox(), SHAPE_SEGMENT::BBox(), KIGFX::SCH_PAINTER::boxText(), buildBoardBoundingBoxPoly(), BuildBoardPolygonOutlines(), ZONE_FILLER::buildCopperItemClearances(), AR_AUTOPLACER::buildFpAreas(), ZONE_FILLER::buildThermalSpokes(), PNS::LINE::ChangedArea(), SCH_EDIT_TOOL::ChangeTextType(), DRC_RTREE::CheckColliding(), EE_RTREE::contains(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), drawBacksideTicks(), drawShapes(), drawTicksAlongLine(), DRAWING_TOOL::DrawVia(), ZONE_FILLER::Fill(), FillNegativeKnockout(), SHAPE_LINE_CHAIN::GenerateBBoxCache(), AR_AUTOPLACER::genModuleOnRoutingMatrix(), APERTURE_MACRO::GetApertureMacroShape(), SCH_LABEL_BASE::GetBodyBoundingBox(), SCH_SHEET::GetBodyBoundingBox(), SCH_LABEL::GetBodyBoundingBox(), BITMAP_BASE::GetBoundingBox(), EDA_SHAPE::getBoundingBox(), SCH_BUS_ENTRY_BASE::GetBoundingBox(), SCH_JUNCTION::GetBoundingBox(), SCH_NO_CONNECT::GetBoundingBox(), GERBER_DRAW_ITEM::GetBoundingBox(), PCB_GROUP::GetBoundingBox(), PCB_DIMENSION_BASE::GetBoundingBox(), PCB_TEXT::GetBoundingBox(), LIB_PIN::GetBoundingBox(), FOOTPRINT::GetBoundingBox(), FOOTPRINT_EDIT_FRAME::GetDocumentExtents(), ZONE::GetInteractingZones(), SCH_SCREEN::GetItem(), EE_SELECTION_TOOL::GuessSelectionCandidates(), EDA_SHAPE::hitTest(), LIB_ITEM::HitTest(), LIB_TEXT::HitTest(), SCH_BUS_ENTRY_BASE::HitTest(), SCH_JUNCTION::HitTest(), SCH_LINE::HitTest(), SCH_NO_CONNECT::HitTest(), DS_DRAW_ITEM_BASE::HitTest(), DS_DRAW_ITEM_POLYPOLYGONS::HitTest(), DS_DRAW_ITEM_RECT::HitTest(), PAD::HitTest(), PCB_DIMENSION_BASE::HitTest(), PCB_TARGET::HitTest(), PCB_TRACK::HitTest(), PCB_VIA::HitTest(), PCB_ARC::HitTest(), ZONE::HitTest(), SCH_SHEET::HitTest(), FP_TEXTBOX::HitTest(), PCB_TEXTBOX::HitTest(), LIB_PIN::HitTest(), LIB_TEXTBOX::HitTest(), SCH_BITMAP::HitTest(), SCH_FIELD::HitTest(), SCH_LABEL_BASE::HitTest(), SCH_PIN::HitTest(), SCH_SHEET_PIN::HitTest(), SCH_SYMBOL::HitTest(), SCH_TEXT::HitTest(), SCH_TEXTBOX::HitTest(), DS_DRAW_ITEM_BITMAP::HitTest(), FOOTPRINT::HitTest(), PCB_BITMAP::HitTest(), MARKER_BASE::HitTestMarker(), BOX2< Vec >::Inflate(), BOARD_ADAPTER::InitSettings(), DRC_RTREE::Insert(), EE_RTREE::insert(), BOX2< Vec >::Intersects(), ZONE_FILLER::knockoutThermalReliefs(), EE_SELECTION_TOOL::Main(), EE_RTREE::Overlapping(), DRC_RTREE::Overlapping(), SCH_LINE::Plot(), SHAPE_INDEX< T >::Query(), DRC_RTREE::QueryColliding(), DRC_RTREE::QueryCollidingPairs(), DIALOG_PAD_PROPERTIES::redraw(), EE_RTREE::remove(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectionContains(), PNS_LOG_VIEWER_FRAME::SetBoard2(), PNS_LOG_VIEWER_FRAME::SetLogFile(), SpreadFootprints(), KIFONT::FONT::StringBoundaryLimits(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE_ON_MOVE::testCourtyardClearances(), AR_AUTOPLACER::testFootprintOnBoard(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones(), AR_AUTOPLACER::testRectangle(), PCB_TEXT::TextHitTest(), EDA_TEXT::TextHitTest(), FP_TEXT::TextHitTest(), EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), PCB_DIM_LEADER::updateGeometry(), FOOTPRINT::ViewBBox(), PCB_SHAPE::ViewBBox(), PCB_TRACK::ViewBBox(), ROUTER_PREVIEW_ITEM::ViewBBox(), EE_SELECTION_TOOL::ZoomFitCrossProbeBBox(), and PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox().

◆ Inflate() [2/2]

template<class Vec >
BOX2< Vec > & BOX2< Vec >::Inflate ( int  aDelta)
inline

Inflate the rectangle horizontally and vertically by aDelta.

If aDelta is negative the rectangle is deflated.

Definition at line 577 of file box2.h.

578 {
579 Inflate( aDelta, aDelta );
580 return *this;
581 }
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506

References BOX2< Vec >::Inflate().

◆ Intersect()

template<class Vec >
BOX2< Vec > BOX2< Vec >::Intersect ( const BOX2< Vec > &  aRect)
inline
Returns
true if this rectangle intersects aRect.

Definition at line 300 of file box2.h.

301 {
302 BOX2<Vec> me( *this );
303 BOX2<Vec> rect( aRect );
304 me.Normalize(); // ensure size is >= 0
305 rect.Normalize(); // ensure size is >= 0
306
307 Vec topLeft, bottomRight;
308
309 topLeft.x = std::max( me.m_Pos.x, rect.m_Pos.x );
310 bottomRight.x = std::min( me.m_Pos.x + me.m_Size.x, rect.m_Pos.x + rect.m_Size.x );
311 topLeft.y = std::max( me.m_Pos.y, rect.m_Pos.y );
312 bottomRight.y = std::min( me.m_Pos.y + me.m_Size.y, rect.m_Pos.y + rect.m_Size.y );
313
314 if ( topLeft.x < bottomRight.x && topLeft.y < bottomRight.y )
315 return BOX2<Vec>( topLeft, bottomRight - topLeft );
316 else
317 return BOX2<Vec>( Vec( 0, 0 ), Vec( 0, 0 ) );
318 }

References BOX2< Vec >::m_Pos, BOX2< Vec >::m_Size, and BOX2< Vec >::Normalize().

◆ Intersects() [1/3]

template<class Vec >
bool BOX2< Vec >::Intersects ( const BOX2< Vec > &  aRect) const
inline
Returns
true if the argument rectangle intersects this rectangle. (i.e. if the 2 rectangles have at least a common point)

Definition at line 269 of file box2.h.

270 {
271 // this logic taken from wxWidgets' geometry.cpp file:
272 bool rc;
273
274 BOX2<Vec> me( *this );
275 BOX2<Vec> rect( aRect );
276 me.Normalize(); // ensure size is >= 0
277 rect.Normalize(); // ensure size is >= 0
278
279 // calculate the left common area coordinate:
280 int left = std::max( me.m_Pos.x, rect.m_Pos.x );
281 // calculate the right common area coordinate:
282 int right = std::min( me.m_Pos.x + me.m_Size.x, rect.m_Pos.x + rect.m_Size.x );
283 // calculate the upper common area coordinate:
284 int top = std::max( me.m_Pos.y, rect.m_Pos.y );
285 // calculate the lower common area coordinate:
286 int bottom = std::min( me.m_Pos.y + me.m_Size.y, rect.m_Pos.y + rect.m_Size.y );
287
288 // if a common area exists, it must have a positive (null accepted) size
289 if( left <= right && top <= bottom )
290 rc = true;
291 else
292 rc = false;
293
294 return rc;
295 }

References left, BOX2< Vec >::m_Pos, BOX2< Vec >::m_Size, BOX2< Vec >::Normalize(), and right.

Referenced by BOOST_AUTO_TEST_CASE(), LABEL_MANAGER::boxMtv(), ZONE_FILLER::buildCopperItemClearances(), ZONE_FILLER::buildThermalSpokes(), CN_VISITOR::checkZoneZoneConnection(), Collide(), ZONE_FILLER::Fill(), AUTOPLACER::filterCollisions(), EDA_SHAPE::hitTest(), LIB_ITEM::HitTest(), LIB_PIN::HitTest(), LIB_TEXT::HitTest(), LIB_TEXTBOX::HitTest(), SCH_BITMAP::HitTest(), SCH_BUS_ENTRY_BASE::HitTest(), SCH_FIELD::HitTest(), SCH_LABEL_BASE::HitTest(), SCH_LINE::HitTest(), SCH_NO_CONNECT::HitTest(), SCH_PIN::HitTest(), SCH_SHEET::HitTest(), SCH_SYMBOL::HitTest(), SCH_TEXT::HitTest(), SCH_TEXTBOX::HitTest(), DS_DRAW_ITEM_BASE::HitTest(), DS_DRAW_ITEM_POLYPOLYGONS::HitTest(), DS_DRAW_ITEM_RECT::HitTest(), FOOTPRINT::HitTest(), FP_TEXTBOX::HitTest(), PAD::HitTest(), PCB_BITMAP::HitTest(), PCB_DIMENSION_BASE::HitTest(), PCB_TARGET::HitTest(), PCB_TEXTBOX::HitTest(), PCB_TRACK::HitTest(), PCB_ARC::HitTest(), ZONE::HitTest(), SHAPE_LINE_CHAIN::Intersect(), BOX2< Vec >::Intersects(), ZONE_FILLER::knockoutThermalReliefs(), FABMASTER::loadZones(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE_ON_MOVE::testCourtyardClearances(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones(), BOARD::TestZoneIntersection(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer(), EDA_TEXT::TextHitTest(), FP_TEXT::TextHitTest(), and PCB_TEXT::TextHitTest().

◆ Intersects() [2/3]

template<class Vec >
bool BOX2< Vec >::Intersects ( const BOX2< Vec > &  aRect,
const EDA_ANGLE aRotation 
) const
inline
Returns
true if this rectangle intersects a rotated rect given by aRect and aRotaiton.

Definition at line 352 of file box2.h.

353 {
354 if( !m_init )
355 return false;
356
357 EDA_ANGLE rotation = aRotation;
358 rotation.Normalize();
359
360 /*
361 * Most rectangles will be axis aligned. It is quicker to check for this case and pass
362 * the rect to the simpler intersection test.
363 */
364
365 // Prevent floating point comparison errors
366 static const EDA_ANGLE ROT_EPSILON( 0.000000001, DEGREES_T );
367
368 static const EDA_ANGLE ROT_PARALLEL[] = { ANGLE_0, ANGLE_180, ANGLE_360 };
369 static const EDA_ANGLE ROT_PERPENDICULAR[] = { ANGLE_0, ANGLE_90, ANGLE_270 };
370
371 // Test for non-rotated rectangle
372 for( EDA_ANGLE ii : ROT_PARALLEL )
373 {
374 if( std::abs( rotation - ii ) < ROT_EPSILON )
375 return Intersects( aRect );
376 }
377
378 // Test for rectangle rotated by multiple of 90 degrees
379 for( EDA_ANGLE jj : ROT_PERPENDICULAR )
380 {
381 if( std::abs( rotation - jj ) < ROT_EPSILON )
382 {
383 BOX2<Vec> rotRect;
384
385 // Rotate the supplied rect by 90 degrees
386 rotRect.SetOrigin( aRect.Centre() );
387 rotRect.Inflate( aRect.GetHeight(), aRect.GetWidth() );
388 return Intersects( rotRect );
389 }
390 }
391
392 /* There is some non-orthogonal rotation.
393 * There are three cases to test:
394 * A) One point of this rect is inside the rotated rect
395 * B) One point of the rotated rect is inside this rect
396 * C) One of the sides of the rotated rect intersect this
397 */
398
399 VECTOR2I corners[4];
400
401 /* Test A : Any corners exist in rotated rect? */
402 corners[0] = m_Pos;
403 corners[1] = m_Pos + VECTOR2I( m_Size.x, 0 );
404 corners[2] = m_Pos + VECTOR2I( m_Size.x, m_Size.y );
405 corners[3] = m_Pos + VECTOR2I( 0, m_Size.y );
406
407 VECTOR2I rCentre = aRect.Centre();
408
409 for( int i = 0; i < 4; i++ )
410 {
411 VECTOR2I delta = corners[i] - rCentre;
412 RotatePoint( delta, -rotation );
413 delta += rCentre;
414
415 if( aRect.Contains( delta ) )
416 return true;
417 }
418
419 /* Test B : Any corners of rotated rect exist in this one? */
420 int w = aRect.GetWidth() / 2;
421 int h = aRect.GetHeight() / 2;
422
423 // Construct corners around center of shape
424 corners[0] = VECTOR2I( -w, -h );
425 corners[1] = VECTOR2I( w, -h );
426 corners[2] = VECTOR2I( w, h );
427 corners[3] = VECTOR2I( -w, h );
428
429 // Rotate and test each corner
430 for( int j = 0; j < 4; j++ )
431 {
432 RotatePoint( corners[j], rotation );
433 corners[j] += rCentre;
434
435 if( Contains( corners[j] ) )
436 return true;
437 }
438
439 /* Test C : Any sides of rotated rect intersect this */
440 if( Intersects( corners[0], corners[1] ) || Intersects( corners[1], corners[2] )
441 || Intersects( corners[2], corners[3] ) || Intersects( corners[3], corners[0] ) )
442 {
443 return true;
444 }
445
446 return false;
447 }
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:269
EDA_ANGLE Normalize()
Definition: eda_angle.h:249
static constexpr EDA_ANGLE & ANGLE_180
Definition: eda_angle.h:416
@ DEGREES_T
Definition: eda_angle.h:31
static constexpr EDA_ANGLE & ANGLE_360
Definition: eda_angle.h:418
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:414
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412
static constexpr EDA_ANGLE & ANGLE_270
Definition: eda_angle.h:417
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401
constexpr int delta
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References std::abs(), ANGLE_0, ANGLE_180, ANGLE_270, ANGLE_360, ANGLE_90, BOX2< Vec >::Centre(), BOX2< Vec >::Contains(), DEGREES_T, delta, BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Inflate(), BOX2< Vec >::Intersects(), BOX2< Vec >::m_init, BOX2< Vec >::m_Pos, BOX2< Vec >::m_Size, EDA_ANGLE::Normalize(), RotatePoint(), and BOX2< Vec >::SetOrigin().

◆ Intersects() [3/3]

template<class Vec >
bool BOX2< Vec >::Intersects ( const Vec &  aPoint1,
const Vec &  aPoint2 
) const
inline
Returns
true if this rectangle intersects a line from aPoint1 to aPoint2

Definition at line 323 of file box2.h.

324 {
325 Vec point2, point4;
326
327 if( Contains( aPoint1 ) || Contains( aPoint2 ) )
328 return true;
329
330 point2.x = GetEnd().x;
331 point2.y = GetOrigin().y;
332 point4.x = GetOrigin().x;
333 point4.y = GetEnd().y;
334
335 //Only need to test 3 sides since a straight line can't enter and exit on same side
336 if( SegmentIntersectsSegment( aPoint1, aPoint2, GetOrigin(), point2 ) )
337 return true;
338
339 if( SegmentIntersectsSegment( aPoint1, aPoint2, point2, GetEnd() ) )
340 return true;
341
342 if( SegmentIntersectsSegment( aPoint1, aPoint2, GetEnd(), point4 ) )
343 return true;
344
345 return false;
346 }
bool SegmentIntersectsSegment(const VECTOR2I &a_p1_l1, const VECTOR2I &a_p2_l1, const VECTOR2I &a_p1_l2, const VECTOR2I &a_p2_l2, VECTOR2I *aIntersectionPoint=nullptr)
Test if two lines intersect.
Definition: trigo.cpp:61

References BOX2< Vec >::Contains(), BOX2< Vec >::GetEnd(), BOX2< Vec >::GetOrigin(), and SegmentIntersectsSegment().

◆ IntersectsCircle()

template<class Vec >
bool BOX2< Vec >::IntersectsCircle ( const Vec &  aCenter,
const int  aRadius 
) const
inline
Returns
true if this rectangle intersects the circle defined by aCenter and aRadius.

Definition at line 452 of file box2.h.

453 {
454 if( !m_init )
455 return false;
456
457 Vec closest = ClosestPointTo( aCenter );
458
459 double dx = static_cast<double>( aCenter.x ) - closest.x;
460 double dy = static_cast<double>( aCenter.y ) - closest.y;
461
462 double r = static_cast<double>( aRadius );
463
464 return ( dx * dx + dy * dy ) <= ( r * r );
465 }
const Vec ClosestPointTo(const Vec &aPoint) const
Return the point in this rect that is closest to the provided point.
Definition: box2.h:781
E_SERIE r
Definition: eserie.cpp:41

References BOX2< Vec >::ClosestPointTo(), BOX2< Vec >::m_init, and r.

Referenced by PCB_VIA::HitTest(), and BOX2< Vec >::IntersectsCircleEdge().

◆ IntersectsCircleEdge()

template<class Vec >
bool BOX2< Vec >::IntersectsCircleEdge ( const Vec &  aCenter,
const int  aRadius,
const int  aWidth 
) const
inline
Returns
true if this rectangle intersects the edge of a circle defined by aCenter and aRadius.

Definition at line 471 of file box2.h.

472 {
473 if( !m_init )
474 return false;
475
476 BOX2<Vec> me( *this );
477 me.Normalize(); // ensure size is >= 0
478
479 // Test if the circle intersects at all
480 if( !IntersectsCircle( aCenter, aRadius + aWidth / 2 ) )
481 return false;
482
483 Vec farpt = FarthestPointTo( aCenter );
484 // Farthest point must be further than the inside of the line
485 double fx = (double) farpt.x - aCenter.x;
486 double fy = (double) farpt.y - aCenter.y;
487
488 double r = (double) aRadius - (double) aWidth / 2;
489
490 return ( fx * fx + fy * fy ) > ( r * r );
491 }
const Vec FarthestPointTo(const Vec &aPoint) const
Return the point in this rect that is farthest from the provided point.
Definition: box2.h:797
bool IntersectsCircle(const Vec &aCenter, const int aRadius) const
Definition: box2.h:452

References BOX2< Vec >::FarthestPointTo(), BOX2< Vec >::IntersectsCircle(), BOX2< Vec >::m_init, BOX2< Vec >::Normalize(), and r.

Referenced by EDA_SHAPE::hitTest().

◆ Merge() [1/2]

template<class Vec >
BOX2< Vec > & BOX2< Vec >::Merge ( const BOX2< Vec > &  aRect)
inline

Modify the position and size of the rectangle in order to contain aRect.

Parameters
aRectis the rectangle to merge with this rectangle.

Definition at line 588 of file box2.h.

589 {
590 if( !m_init )
591 {
592 if( aRect.m_init )
593 {
594 m_Pos = aRect.GetPosition();
595 m_Size = aRect.GetSize();
596 m_init = true;
597 }
598
599 return *this;
600 }
601
602 Normalize(); // ensure width and height >= 0
603 BOX2<Vec> rect = aRect;
604 rect.Normalize(); // ensure width and height >= 0
605 Vec end = GetEnd();
606 Vec rect_end = rect.GetEnd();
607
608 // Change origin and size in order to contain the given rect
609 m_Pos.x = std::min( m_Pos.x, rect.m_Pos.x );
610 m_Pos.y = std::min( m_Pos.y, rect.m_Pos.y );
611 end.x = std::max( end.x, rect_end.x );
612 end.y = std::max( end.y, rect_end.y );
613 SetEnd( end );
614 return *this;
615 }
const Vec & GetPosition() const
Definition: box2.h:184
const Vec & GetSize() const
Definition: box2.h:179

References BOX2< Vec >::GetEnd(), BOX2< Vec >::GetPosition(), BOX2< Vec >::GetSize(), BOX2< Vec >::m_init, BOX2< Vec >::m_Pos, BOX2< Vec >::m_Size, BOX2< Vec >::Normalize(), and BOX2< Vec >::SetEnd().

Referenced by SHAPE_LINE_CHAIN::Append(), HPGL_PLOTTER::Arc(), SHAPE_COMPOUND::BBox(), SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI::BBox(), SHAPE_POLY_SET::BBox(), SHAPE_POLY_SET::BBoxFromCaches(), boundingBox(), PAD::BuildEffectiveShapes(), PNS::ARC::ChangedArea(), PNS::VIA::ChangedArea(), HPGL_PLOTTER::Circle(), EDA_SHAPE::computeArcBBox(), GBR_LAYOUT::ComputeBoundingBox(), BOARD::ComputeBoundingBox(), SCH_SYMBOL::doGetBoundingBox(), EDIT_TOOL::doMoveSelection(), drawMarkup(), drawShapes(), HPGL_PLOTTER::EndPlot(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), PNS::extendBox(), AUTOPLACER::fieldBoxPlacement(), SCH_LABEL_BASE::GetBodyBoundingBox(), SCH_LABEL::GetBodyBoundingBox(), LIB_SYMBOL::GetBodyBoundingBox(), EDA_SHAPE::getBoundingBox(), SELECTION::GetBoundingBox(), SCH_LABEL_BASE::GetBoundingBox(), SCH_SHEET::GetBoundingBox(), EE_SELECTION::GetBoundingBox(), PCB_GROUP::GetBoundingBox(), NETINFO_ITEM::GetBoundingBox(), FOOTPRINT::GetBoundingBox(), SELECTION::GetCenter(), GERBVIEW_SELECTION::GetCenter(), DIALOG_BOARD_STATISTICS::getDataFromPCB(), SCH_EDIT_FRAME::GetDocumentExtents(), FOOTPRINT::GetFpPadsLocalBbox(), AUTOPLACER::getPossibleCollisions(), getSheetBbox(), PNS_TEST_DEBUG_DECORATOR::GetStageExtents(), KIFONT::OUTLINE_FONT::getTextAsGlyphs(), LIB_SYMBOL::GetUnitBoundingBox(), PCB_ARC::HitTest(), CADSTAR_SCH_ARCHIVE_LOADER::Load(), EDIT_TOOL::PackAndMoveFootprints(), HPGL_PLOTTER::PenTo(), playground_main_func(), HPGL_PLOTTER::Rect(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), EDIT_TOOL::Rotate(), SHAPE_LINE_CHAIN::Slice(), SpreadFootprints(), SCH_EDIT_FRAME::TrimWire(), GERBVIEW_SELECTION::ViewBBox(), EDIT_POINTS::ViewBBox(), KIGFX::VIEW_GROUP::ViewBBox(), PCB_DIMENSION_BASE::ViewBBox(), and ROUTER_PREVIEW_ITEM::ViewBBox().

◆ Merge() [2/2]

template<class Vec >
BOX2< Vec > & BOX2< Vec >::Merge ( const Vec &  aPoint)
inline

Modify the position and size of the rectangle in order to contain the given point.

Parameters
aPointis the point to merge with the rectangle.

Definition at line 622 of file box2.h.

623 {
624 if( !m_init )
625 {
626 m_Pos = aPoint;
627 m_Size = VECTOR2I( 0, 0 );
628 m_init = true;
629 return *this;
630 }
631
632 Normalize(); // ensure width and height >= 0
633
634 Vec end = GetEnd();
635
636 // Change origin and size in order to contain the given rectangle.
637 m_Pos.x = std::min( m_Pos.x, aPoint.x );
638 m_Pos.y = std::min( m_Pos.y, aPoint.y );
639 end.x = std::max( end.x, aPoint.x );
640 end.y = std::max( end.y, aPoint.y );
641 SetEnd( end );
642 return *this;
643 }

References BOX2< Vec >::GetEnd(), BOX2< Vec >::m_init, BOX2< Vec >::m_Pos, BOX2< Vec >::m_Size, BOX2< Vec >::Normalize(), and BOX2< Vec >::SetEnd().

◆ Move()

template<class Vec >
void BOX2< Vec >::Move ( const Vec &  aMoveVector)
inline

Move the rectangle by the aMoveVector.

Parameters
aMoveVectoris a point that is the value to move this rectangle.

Definition at line 111 of file box2.h.

112 {
113 m_Pos += aMoveVector;
114 }

References BOX2< Vec >::m_Pos.

Referenced by LABEL_MANAGER::boxMtv(), APERTURE_MACRO::GetApertureMacroShape(), SCH_BITMAP::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), AR_AUTOPLACER::getOptimalFPPlacement(), FOOTPRINT::MoveAnchorPosition(), DIALOG_PAD_PROPERTIES::redraw(), FOOTPRINT::SetPosition(), and AR_AUTOPLACER::testFootprintOnBoard().

◆ Normalize()

template<class Vec >
BOX2< Vec > & BOX2< Vec >::Normalize ( )
inline

Ensure that the height and width are positive.

Definition at line 119 of file box2.h.

120 {
121 if( m_Size.y < 0 )
122 {
123 m_Size.y = -m_Size.y;
124 m_Pos.y -= m_Size.y;
125 }
126
127 if( m_Size.x < 0 )
128 {
129 m_Size.x = -m_Size.x;
130 m_Pos.x -= m_Size.x;
131 }
132
133 return *this;
134 }

References BOX2< Vec >::m_Pos, and BOX2< Vec >::m_Size.

Referenced by BOX2< Vec >::BOX2(), LABEL_MANAGER::boxMtv(), KIGFX::SCH_PAINTER::boxText(), BOX2< Vec >::ClosestPointTo(), GBR_LAYOUT::ComputeBoundingBox(), PNS::ConvexHull(), SCH_SYMBOL::doGetBoundingBox(), KIGFX::PCB_PAINTER::draw(), BOX2< Vec >::FarthestPointTo(), SCH_LABEL_BASE::GetBodyBoundingBox(), SCH_LABEL::GetBodyBoundingBox(), SCH_HIERLABEL::GetBodyBoundingBox(), EDA_SHAPE::getBoundingBox(), SCH_BUS_ENTRY_BASE::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_LABEL_BASE::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), GERBER_DRAW_ITEM::GetBoundingBox(), PCB_DIMENSION_BASE::GetBoundingBox(), PCB_DIM_CENTER::GetBoundingBox(), LIB_PIN::GetBoundingBox(), KIFONT::OUTLINE_FONT::getBoundingBox(), SCH_TEXTBOX::GetDrawPos(), NL_SCHEMATIC_PLUGIN_IMPL::GetModelExtents(), NL_PCBNEW_PLUGIN_IMPL::GetModelExtents(), KIFONT::STROKE_FONT::GetTextAsGlyphs(), EDA_TEXT::GetTextBox(), KIGFX::VIEW::GetViewport(), EDA_SHAPE::hitTest(), PAD::HitTest(), ZONE::HitTest(), BOX2< Vec >::Intersect(), BOX2< Vec >::Intersects(), BOX2< Vec >::IntersectsCircleEdge(), BOX2< Vec >::Merge(), FP_TEXTBOX::Mirror(), PCB_TEXTBOX::Mirror(), PCB_SHAPE::NormalizeRect(), EDIT_TOOL::PackAndMoveFootprints(), SVG_PLOTTER::Rect(), KIGFX::VIEW::Redraw(), BOX2< Vec >::RevertYAxis(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), STROKE_PARAMS::Stroke(), KIGFX::PREVIEW::SELECTION_AREA::ViewBBox(), KIGFX::ORIGIN_VIEWITEM::ViewDraw(), EE_SELECTION_TOOL::ZoomFitCrossProbeBBox(), and PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox().

◆ Offset() [1/2]

template<class Vec >
void BOX2< Vec >::Offset ( const Vec &  offset)
inline

Definition at line 230 of file box2.h.

231 {
232 Offset( offset.x, offset.y );
233 }
void Offset(coord_type dx, coord_type dy)
Definition: box2.h:224

References BOX2< Vec >::Offset().

◆ Offset() [2/2]

template<class Vec >
void BOX2< Vec >::Offset ( coord_type  dx,
coord_type  dy 
)
inline

◆ operator!=()

template<class Vec >
bool BOX2< Vec >::operator!= ( const BOX2< Vec > &  aOther) const
inline

Definition at line 830 of file box2.h.

831 {
832 auto t1 ( *this );
833 auto t2 ( aOther );
834 t1.Normalize();
835 t2.Normalize();
836 return ( t1.m_Pos != t2.m_Pos || t1.m_Size != t2.m_Size );
837 }

◆ operator==()

template<class Vec >
bool BOX2< Vec >::operator== ( const BOX2< Vec > &  aOther) const
inline

Definition at line 821 of file box2.h.

822 {
823 auto t1 ( *this );
824 auto t2 ( aOther );
825 t1.Normalize();
826 t2.Normalize();
827 return ( t1.m_Pos == t2.m_Pos && t1.m_Size == t2.m_Size );
828 }

◆ RevertYAxis()

template<class Vec >
void BOX2< Vec >::RevertYAxis ( )
inline

◆ SetEnd() [1/2]

template<class Vec >
void BOX2< Vec >::SetEnd ( const Vec &  pos)
inline

Definition at line 260 of file box2.h.

261 {
262 SetSize( pos - m_Pos );
263 }

References BOX2< Vec >::m_Pos, and BOX2< Vec >::SetSize().

◆ SetEnd() [2/2]

◆ SetHeight()

◆ SetMaximum()

◆ SetOrigin() [1/2]

template<class Vec >
void BOX2< Vec >::SetOrigin ( const Vec &  pos)
inline

Definition at line 202 of file box2.h.

203 {
204 m_Pos = pos;
205 m_init = true;
206 }

References BOX2< Vec >::m_init, and BOX2< Vec >::m_Pos.

Referenced by LABEL_MANAGER::Add(), PCB_GRID_HELPER::BestSnapAnchor(), PDF_PLOTTER::ClosePage(), BOX2< Vec >::Compute(), EDA_SHAPE::computeArcBBox(), KIGFX::PCB_PAINTER::draw(), AUTOPLACER::fitFieldsBetweenWires(), PCB_BASE_FRAME::GetBoardBoundingBox(), SCH_LABEL::GetBodyBoundingBox(), EDA_SHAPE::getBoundingBox(), LIB_FIELD::GetBoundingBox(), LIB_TEXT::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), GERBER_DRAW_ITEM::GetBoundingBox(), DS_DRAW_ITEM_BITMAP::GetBoundingBox(), LIB_PIN::GetBoundingBox(), KIFONT::OUTLINE_FONT::getBoundingBox(), BOX2< Vec >::GetBoundingBoxRotated(), SCH_SCREEN::GetItem(), AR_AUTOPLACER::getOptimalFPPlacement(), KIFONT::OUTLINE_FONT::GetTextAsGlyphs(), KIFONT::STROKE_FONT::GetTextAsGlyphs(), EDA_TEXT::GetTextBox(), KIGFX::VIEW::GetViewport(), KIGFX::GAL::GetVisibleWorldExtents(), BOX2< Vec >::Intersects(), MARKER_BASE::MARKER_BASE(), KIGFX::PCB_VIEW::PCB_VIEW(), KIGFX::SCH_VIEW::ResizeSheetWorkingArea(), KIGFX::SCH_VIEW::SCH_VIEW(), PNS_LOG_VIEWER_FRAME::SetBoard2(), KIGFX::VIEW::SetBoundary(), PNS_LOG_VIEWER_FRAME::SetLogFile(), BOX2< Vec >::SetOrigin(), BOX2< Vec >::SetX(), BOX2< Vec >::SetY(), SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), TRANSFORM::TransformCoordinate(), KIGFX::VIEW::VIEW(), DS_PROXY_VIEW_ITEM::ViewBBox(), KIGFX::PREVIEW::SELECTION_AREA::ViewBBox(), and EDIT_POINTS::ViewBBox().

◆ SetOrigin() [2/2]

template<class Vec >
void BOX2< Vec >::SetOrigin ( coord_type  x,
coord_type  y 
)
inline

Definition at line 208 of file box2.h.

209 {
210 SetOrigin( Vec( x, y ) );
211 }

References BOX2< Vec >::SetOrigin().

◆ SetSize() [1/2]

◆ SetSize() [2/2]

template<class Vec >
void BOX2< Vec >::SetSize ( coord_type  w,
coord_type  h 
)
inline

Definition at line 219 of file box2.h.

220 {
221 SetSize( Vec( w, h ) );
222 }

References BOX2< Vec >::SetSize().

◆ SetWidth()

◆ SetX()

◆ SetY()

◆ SquaredDistance() [1/2]

template<class Vec >
ecoord_type BOX2< Vec >::SquaredDistance ( const BOX2< Vec > &  aBox) const
inline

Return the square of the minimum distance between self and box aBox.

Parameters
aBoxis the other box.
Returns
The distance squared from aBox.

Definition at line 738 of file box2.h.

739 {
740 ecoord_type s = 0;
741
742 if( aBox.m_Pos.x + aBox.m_Size.x < m_Pos.x )
743 {
744 ecoord_type d = aBox.m_Pos.x + aBox.m_Size.x - m_Pos.x;
745 s += d * d;
746 }
747 else if( aBox.m_Pos.x > m_Pos.x + m_Size.x )
748 {
749 ecoord_type d = aBox.m_Pos.x - m_Size.x - m_Pos.x;
750 s += d * d;
751 }
752
753 if( aBox.m_Pos.y + aBox.m_Size.y < m_Pos.y )
754 {
755 ecoord_type d = aBox.m_Pos.y + aBox.m_Size.y - m_Pos.y;
756 s += d * d;
757 }
758 else if( aBox.m_Pos.y > m_Pos.y + m_Size.y )
759 {
760 ecoord_type d = aBox.m_Pos.y - m_Size.y - m_Pos.y;
761 s += d * d;
762 }
763
764 return s;
765 }

References BOX2< Vec >::m_Pos, and BOX2< Vec >::m_Size.

◆ SquaredDistance() [2/2]

template<class Vec >
ecoord_type BOX2< Vec >::SquaredDistance ( const Vec &  aP) const
inline

Definition at line 716 of file box2.h.

717 {
718 ecoord_type x2 = m_Pos.x + m_Size.x;
719 ecoord_type y2 = m_Pos.y + m_Size.y;
720 ecoord_type xdiff = std::max( aP.x < m_Pos.x ? m_Pos.x - aP.x : m_Pos.x - x2,
721 (ecoord_type) 0 );
722 ecoord_type ydiff = std::max( aP.y < m_Pos.y ? m_Pos.y - aP.y : m_Pos.y - y2,
723 (ecoord_type) 0 );
724 return xdiff * xdiff + ydiff * ydiff;
725 }

References BOX2< Vec >::m_Pos, and BOX2< Vec >::m_Size.

Referenced by BOX2< Vec >::Distance(), and SHAPE_INDEX_LIST< T, >::Query().

Member Data Documentation

◆ m_init

◆ m_Pos

◆ m_Size


The documentation for this class was generated from the following file: