KiCad PCB EDA Suite
shape_index.h File Reference
#include <vector>
#include <geometry/shape.h>
#include <geometry/rtree.h>

Go to the source code of this file.

Classes

class  SHAPE_INDEX< T >
 
class  SHAPE_INDEX< T >::Iterator
 

Functions

template<class T >
static const SHAPEshapeFunctor (T aItem)
 shapeFunctor template function More...
 
template<class T >
BOX2I boundingBox (T aObject)
 boundingBox template method More...
 
template<class T , class V >
void acceptVisitor (T aObject, V aVisitor)
 acceptVisitor template method More...
 
template<class T , class U >
bool collide (T aObject, U aAnotherObject, int aMinDistance)
 collide template method More...
 
template<class T , class V >
bool queryCallback (T aShape, void *aContext)
 

Function Documentation

template<class T , class V >
void acceptVisitor ( aObject,
aVisitor 
)

acceptVisitor template method

It is used by SHAPE_INDEX to implement Accept(). By default relies on V::operation() redefinition, should be specialized if V class doesn't have its () operation defined to accept T objects.

Parameters
aObjectgeneric T object
aVisitorV visitor object

Definition at line 74 of file shape_index.h.

Referenced by SHAPE_INDEX< T >::Accept().

75 {
76  aVisitor( aObject );
77 }
template<class T >
BOX2I boundingBox ( aObject)

boundingBox template method

It is used by SHAPE_INDEX to get the bounding box of a generic T object. By default relies on T::BBox() method, should be specialized if the T object doesn't allow that method.

Parameters
aObjectgeneric T object
Returns
a BOX2I object containing the bounding box of the T object.

Definition at line 59 of file shape_index.h.

References SHAPE::BBox(), and shapeFunctor().

Referenced by SHAPE_INDEX< T >::Add(), LIB_VIEW_FRAME::BestZoom(), LIB_EDIT_FRAME::BestZoom(), KIGFX::STROKE_FONT::computeBoundingBox(), SCH_COMPONENT::Draw(), SCH_COMPONENT::IsSelectStateChanged(), SCH_SHEET::IsSelectStateChanged(), SHAPE_INDEX< T >::Reindex(), and SHAPE_INDEX< T >::Remove().

60 {
61  return shapeFunctor( aObject )->BBox();
62 }
static const SHAPE * shapeFunctor(T aItem)
shapeFunctor template function
Definition: shape_index.h:44
virtual const BOX2I BBox(int aClearance=0) const =0
Function BBox()
template<class T , class U >
bool collide ( aObject,
aAnotherObject,
int  aMinDistance 
)

collide template method

It is used by SHAPE_INDEX to implement Query(). By default relies on T::Collide(U) method, should be specialized if the T object doesn't allow that method.

Parameters
aObjectgeneric T object
aAnotherObjectgeneric U object
aMinDistanceminimum collision distance
Returns
if object and anotherObject collide

Definition at line 91 of file shape_index.h.

References SHAPE::Collide(), and shapeFunctor().

Referenced by AUTOPLACER::choose_side_filtered().

92 {
93  return shapeFunctor( aObject )->Collide( aAnotherObject, aMinDistance );
94 }
static const SHAPE * shapeFunctor(T aItem)
shapeFunctor template function
Definition: shape_index.h:44
virtual bool Collide(const VECTOR2I &aP, int aClearance=0) const
Function Collide()
Definition: shape.h:106
template<class T , class V >
bool queryCallback ( aShape,
void *  aContext 
)

Definition at line 97 of file shape_index.h.

98 {
99  V* visitor = (V*) aContext;
100 
101  acceptVisitor<T, V>( aShape, *visitor );
102 
103  return true;
104 }
template<class T >
static const SHAPE* shapeFunctor ( aItem)
static

shapeFunctor template function

It is used by SHAPE_INDEX to get a SHAPE* from another type. By default relies on T::GetShape() method, should be specialized if the T object doesn't allow that method.

Parameters
aItemgeneric T object
Returns
a SHAPE* object equivalent to object.

Definition at line 44 of file shape_index.h.

Referenced by boundingBox(), and collide().

45 {
46  return aItem->Shape();
47 }