70 using ITER = std::deque<EDA_ITEM*>::iterator;
71 using CITER = std::deque<EDA_ITEM*>::const_iterator;
99 virtual unsigned int GetSize()
const override
136 bool topBeforeBottom =
true )
const
138 std::vector<EDA_ITEM*> sorted_items = std::vector<EDA_ITEM*>(
m_items.begin(),
141 std::sort( sorted_items.begin(), sorted_items.end(),
144 if( a->Type() == b->Type() )
146 if( a->GetSortPosition().x == b->GetSortPosition().x )
149 if( a->GetSortPosition().y == b->GetSortPosition().y )
150 return a->m_Uuid < b->m_Uuid;
152 if( topBeforeBottom )
153 return a->GetSortPosition().y < b->GetSortPosition().y;
155 return a->GetSortPosition().y > b->GetSortPosition().y;
157 else if( leftBeforeRight )
159 return a->GetSortPosition().x < b->GetSortPosition().x;
163 return a->GetSortPosition().x > b->GetSortPosition().x;
168 return a->Type() < b->Type();
175 const std::vector<EDA_ITEM*> GetItemsSortedBySelectionOrder()
const;
190 return GetBoundingBox().GetPosition();
193 virtual BOX2I GetBoundingBox()
const;
202 if( aIdx < m_items.size() )
203 return m_items[ aIdx ];
210 return m_items.size() ? m_items.front() :
nullptr;
218 const std::deque<EDA_ITEM*>&
Items()
const
226 for(
auto item : m_items )
228 if( IsA<T, EDA_ITEM>( item ) )
229 return static_cast<T*
> ( item );
241 bool HasType(
KICAD_T aType )
const;
243 size_t CountType(
KICAD_T aType )
const;
245 virtual const std::vector<KIGFX::VIEW_ITEM*> updateDrawList()
const override;
249 return m_referencePoint != std::nullopt;
254 if( m_referencePoint )
255 return *m_referencePoint;
257 return GetBoundingBox().Centre();
262 m_referencePoint = aP;
267 m_referencePoint = std::nullopt;
275 bool AreAllItemsIdentical()
const;
281 bool OnlyContains( std::vector<KICAD_T> aList )
const;
292 using VIEW_GROUP::Add;
293 using VIEW_GROUP::Remove;
A base class for most all the KiCad significant classes used in schematics and boards.
Extend VIEW_ITEM by possibility of grouping items into a single object.
VIEW_GROUP(VIEW *aView=nullptr)
An abstract base class for deriving all objects that can be added to a VIEW.
std::deque< EDA_ITEM * > m_items
virtual void Add(EDA_ITEM *aItem)
SELECTION & operator=(const SELECTION &aOther)
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
const std::vector< EDA_ITEM * > GetItemsSortedByTypeAndXY(bool leftBeforeRight=true, bool topBeforeBottom=true) const
Returns a copy of this selection of items sorted by their X then Y position.
bool operator==(const SELECTION &aOther) const
const std::deque< EDA_ITEM * > GetItems() const
VECTOR2I GetReferencePoint() const
std::deque< int > m_itemsOrders
const std::deque< EDA_ITEM * > & Items() const
VECTOR2I GetPosition() const
Returns the top left point of the selection area bounding box.
void SetIsHover(bool aIsHover)
std::deque< EDA_ITEM * >::const_iterator CITER
EDA_ITEM * GetLastAddedItem() const
virtual void Remove(EDA_ITEM *aItem)
virtual unsigned int GetSize() const override
Return the number of stored items.
virtual void Clear() override
Remove all the stored items from the group.
int Size() const
Returns the number of selected parts.
virtual EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const
virtual const BOX2I ViewBBox() const override
Return the bounding box for all stored items covering all its layers.
std::deque< EDA_ITEM * >::iterator ITER
std::deque< EDA_ITEM * > & Items()
EDA_ITEM * operator[](const size_t aIdx) const
void ClearReferencePoint()
void SetReferencePoint(const VECTOR2I &aP)
bool Empty() const
Checks if there is anything selected.
EDA_ITEM * m_lastAddedItem
bool HasReferencePoint() const
std::optional< VECTOR2I > m_referencePoint
bool Contains(EDA_ITEM *aItem) const
SELECTION(const SELECTION &aOther)
The Cairo implementation of the graphics abstraction layer.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.