49 if( i ==
m_items.end() || *i > aItem )
64 if( !( i ==
m_items.end() || *i > aItem ) )
88 return !( i ==
m_items.end() || *i > aItem );
95 bool hasOnlyText =
true;
102 if( !item->IsType( textTypes ) )
116 center += item->GetPosition();
118 center = center /
static_cast<int>(
m_items.size() );
119 return static_cast<VECTOR2I>( center );
125 bbox.
Merge( item->GetBoundingBox() );
128 return static_cast<VECTOR2I>( bbox.GetCenter() );
137 bbox.
Merge( item->GetBoundingBox() );
147 if( item->IsType( { aType } ) )
161 if( item->IsType( { aType } ) )
192 std::vector<VIEW_ITEM*> items;
195 items.push_back( item );
206 return r->Type() == m_items.front()->Type();
216 return r->IsType( aList );
222 bool topBeforeBottom )
const
224 std::vector<EDA_ITEM*> sorted_items = std::vector<EDA_ITEM*>(
m_items.begin(),
m_items.end() );
226 std::sort( sorted_items.begin(), sorted_items.end(),
229 if( a->Type() == b->Type() )
231 const VECTOR2I aPos = a->GetSortPosition();
232 const VECTOR2I bPos = b->GetSortPosition();
234 if( aPos.x == bPos.x )
237 if( aPos.y == bPos.y )
238 return a->m_Uuid < b->m_Uuid;
240 if( topBeforeBottom )
241 return aPos.y < bPos.y;
243 return aPos.y > bPos.y;
245 else if( leftBeforeRight )
247 return aPos.x < bPos.x;
251 return aPos.x > bPos.x;
256 return a->Type() < b->Type();
265 using pairedIterators = std::pair<
decltype(
m_items.begin() ),
269 std::vector<pairedIterators> pairs;
273 for( ; item !=
m_items.end(); ++item, ++order )
274 pairs.emplace_back( make_pair( item, order ) );
277 std::sort( pairs.begin(), pairs.end(),
278 []( pairedIterators
const& a, pairedIterators
const& b )
280 return *a.second < *b.second;
284 std::vector<EDA_ITEM*> sortedItems;
286 for( pairedIterators sortedItem : pairs )
287 sortedItems.emplace_back( *sortedItem.first );
constexpr Vec Centre() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
A base class for most all the KiCad significant classes used in schematics and boards.
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)
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
bool operator==(const SELECTION &aOther) const
VECTOR2I GetReferencePoint() const
std::deque< int > m_itemsOrders
std::deque< EDA_ITEM * >::const_iterator CITER
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
virtual void Remove(EDA_ITEM *aItem)
bool AreAllItemsIdentical() const
Checks if all items in the selection are the same KICAD_T type.
bool HasType(KICAD_T aType) const
Checks if there is at least one item of requested kind.
std::deque< EDA_ITEM * >::iterator ITER
std::vector< EDA_ITEM * > GetItemsSortedBySelectionOrder() const
void ClearReferencePoint()
bool OnlyContains(std::vector< KICAD_T > aList) const
Checks if all items in the selection have a type in aList.
void SetReferencePoint(const VECTOR2I &aP)
EDA_ITEM * m_lastAddedItem
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.
size_t CountType(KICAD_T aType) const
std::optional< VECTOR2I > m_referencePoint
bool Contains(EDA_ITEM *aItem) const
virtual BOX2I GetBoundingBox() const
virtual const std::vector< KIGFX::VIEW_ITEM * > updateDrawList() const override
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.