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;
107 if( !item->IsType( textTypes ) )
121 center += item->GetPosition();
129 if( !item->IsType( { SCH_TEXT_T, SCH_LABEL_LOCATE_ANY_T } ) )
130 bbox.
Merge( item->GetBoundingBox() );
142 bbox.
Merge( item->GetBoundingBox() );
152 if( item->IsType( { aType } ) )
166 if( item->IsType( { aType } ) )
197 std::vector<VIEW_ITEM*> items;
200 items.push_back( item );
214 return r->Type() == m_items.front()->Type();
224 return r->IsType( aList );
230 bool topBeforeBottom )
const
232 std::vector<EDA_ITEM*> sorted_items = std::vector<EDA_ITEM*>(
m_items.begin(),
m_items.end() );
234 std::sort( sorted_items.begin(), sorted_items.end(),
237 if( a->Type() == b->Type() )
239 const VECTOR2I aPos = a->GetSortPosition();
240 const VECTOR2I bPos = b->GetSortPosition();
242 if( aPos.x == bPos.x )
245 if( aPos.y == bPos.y )
246 return a->m_Uuid < b->m_Uuid;
248 if( topBeforeBottom )
249 return aPos.y < bPos.y;
251 return aPos.y > bPos.y;
253 else if( leftBeforeRight )
255 return aPos.x < bPos.x;
259 return aPos.x > bPos.x;
264 return a->Type() < b->Type();
273 using pairedIterators = std::pair<
decltype(
m_items.begin() ),
277 std::vector<pairedIterators> pairs;
281 for( ; item !=
m_items.end(); ++item, ++order )
282 pairs.emplace_back( make_pair( item, order ) );
285 std::sort( pairs.begin(), pairs.end(),
286 []( pairedIterators
const& a, pairedIterators
const& b )
288 return *a.second < *b.second;
292 std::vector<EDA_ITEM*> sortedItems;
294 for( pairedIterators sortedItem : pairs )
295 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.
constexpr const Vec GetCenter() const
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)
A null aItem is ignored; the selection never holds null members.
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.
VECTOR2< int32_t > VECTOR2I