49 if( i ==
m_items.end() || *i > aItem )
64 if( !( i ==
m_items.end() || *i > aItem ) )
88 return !( i ==
m_items.end() || *i > aItem );
96 bool hasOnlyText =
true;
104 if( !item->IsType( textTypes ) )
118 center += item->GetPosition();
120 center = center /
static_cast<int>(
m_items.size() );
121 return static_cast<VECTOR2I>( center );
127 bbox.
Merge( item->GetBoundingBox() );
130 return static_cast<VECTOR2I>( bbox.GetCenter() );
139 bbox.
Merge( item->GetBoundingBox() );
149 if( item->IsType( { aType } ) )
163 if( item->IsType( { aType } ) )
194 std::vector<VIEW_ITEM*> items;
197 items.push_back( item );
208 return r->Type() == m_items.front()->Type();
218 return r->IsType( aList );
224 bool topBeforeBottom )
const
226 std::vector<EDA_ITEM*> sorted_items = std::vector<EDA_ITEM*>(
m_items.begin(),
m_items.end() );
228 std::sort( sorted_items.begin(), sorted_items.end(),
231 if( a->Type() == b->Type() )
233 const VECTOR2I aPos = a->GetSortPosition();
234 const VECTOR2I bPos = b->GetSortPosition();
236 if( aPos.x == bPos.x )
239 if( aPos.y == bPos.y )
240 return a->m_Uuid < b->m_Uuid;
242 if( topBeforeBottom )
243 return aPos.y < bPos.y;
245 return aPos.y > bPos.y;
247 else if( leftBeforeRight )
249 return aPos.x < bPos.x;
253 return aPos.x > bPos.x;
258 return a->Type() < b->Type();
267 using pairedIterators = std::pair<
decltype(
m_items.begin() ),
271 std::vector<pairedIterators> pairs;
275 for( ; item !=
m_items.end(); ++item, ++order )
276 pairs.emplace_back( make_pair( item, order ) );
279 std::sort( pairs.begin(), pairs.end(),
280 []( pairedIterators
const& a, pairedIterators
const& b )
282 return *a.second < *b.second;
286 std::vector<EDA_ITEM*> sortedItems;
288 for( pairedIterators sortedItem : pairs )
289 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.