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;
103 if( !item->IsType( { SCH_TEXT_T, SCH_LABEL_LOCATE_ANY_T } ) )
117 center += item->GetPosition();
119 center = center /
static_cast<int>(
m_items.size() );
120 return static_cast<VECTOR2I>( center );
126 bbox.
Merge( item->GetBoundingBox() );
129 return static_cast<VECTOR2I>( bbox.GetCenter() );
138 bbox.
Merge( item->GetBoundingBox() );
148 if( item->IsType( { aType } ) )
162 if( item->IsType( { aType } ) )
193 std::vector<VIEW_ITEM*> items;
196 items.push_back( item );
207 return r->Type() == m_items.front()->Type();
217 return r->IsType( aList );
223 bool topBeforeBottom )
const
225 std::vector<EDA_ITEM*> sorted_items = std::vector<EDA_ITEM*>(
m_items.begin(),
m_items.end() );
227 std::sort( sorted_items.begin(), sorted_items.end(),
230 if( a->Type() == b->Type() )
232 const VECTOR2I aPos = a->GetSortPosition();
233 const VECTOR2I bPos = b->GetSortPosition();
235 if( aPos.x == bPos.x )
238 if( aPos.y == bPos.y )
239 return a->m_Uuid < b->m_Uuid;
241 if( topBeforeBottom )
242 return aPos.y < bPos.y;
244 return aPos.y > bPos.y;
246 else if( leftBeforeRight )
248 return aPos.x < bPos.x;
252 return aPos.x > bPos.x;
257 return a->Type() < b->Type();
266 using pairedIterators = std::pair<
decltype(
m_items.begin() ),
270 std::vector<pairedIterators> pairs;
274 for( ; item !=
m_items.end(); ++item, ++order )
275 pairs.emplace_back( make_pair( item, order ) );
278 std::sort( pairs.begin(), pairs.end(),
279 []( pairedIterators
const& a, pairedIterators
const& b )
281 return *a.second < *b.second;
285 std::vector<EDA_ITEM*> sortedItems;
287 for( pairedIterators sortedItem : pairs )
288 sortedItems.emplace_back( *sortedItem.first );
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)
virtual BOX2I GetBoundingBox(bool aOnlyVisible=false) const
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 const std::vector< KIGFX::VIEW_ITEM * > updateDrawList() const override
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.