86 const std::vector<ITEM_BOX>& aLocked,
T aGetValue )
90 if( !aLocked.empty() )
92 for(
const ITEM_BOX& item : aLocked )
94 if( item.second.Contains( cursorPos ) )
95 return aGetValue( item );
98 return aGetValue( aLocked.front() );
101 for(
const ITEM_BOX& item : aItems )
103 if( item.second.Contains( cursorPos ) )
104 return aGetValue( item );
107 return aGetValue( aItems.front() );
111template<
typename T >
113 std::vector<ITEM_BOX>& aLockedItems,
T aCompare )
119 if( !item->IsSCH_ITEM() )
130 aLockedItems.emplace_back( schItem, bbox );
132 aItemsToAlign.emplace_back( schItem, bbox );
135 std::sort( aItemsToAlign.begin(), aItemsToAlign.end(), aCompare );
136 std::sort( aLockedItems.begin(), aLockedItems.end(), aCompare );
138 return aItemsToAlign.size();
171 VECTOR2I snappedPos =
grid.AlignGrid( desiredPos, gridType );
190 std::vector<ITEM_BOX> itemsToAlign;
191 std::vector<ITEM_BOX> lockedItems;
196 return lhs.second.GetTop() < rhs.second.GetTop();
204 int targetTop =
selectTarget( itemsToAlign, lockedItems,
207 return item.second.GetTop();
210 for(
const ITEM_BOX& item : itemsToAlign )
212 int difference = targetTop - item.second.GetTop();
218 commit.
Push(
_(
"Align to Top" ) );
225 std::vector<ITEM_BOX> itemsToAlign;
226 std::vector<ITEM_BOX> lockedItems;
231 return lhs.second.GetBottom() > rhs.second.GetBottom();
239 int targetBottom =
selectTarget( itemsToAlign, lockedItems,
242 return item.second.GetBottom();
245 for(
const ITEM_BOX& item : itemsToAlign )
247 int difference = targetBottom - item.second.GetBottom();
253 commit.
Push(
_(
"Align to Bottom" ) );
260 std::vector<ITEM_BOX> itemsToAlign;
261 std::vector<ITEM_BOX> lockedItems;
266 return lhs.second.GetLeft() < rhs.second.GetLeft();
274 int targetLeft =
selectTarget( itemsToAlign, lockedItems,
277 return item.second.GetLeft();
280 for(
const ITEM_BOX& item : itemsToAlign )
282 int difference = targetLeft - item.second.GetLeft();
288 commit.
Push(
_(
"Align to Left" ) );
295 std::vector<ITEM_BOX> itemsToAlign;
296 std::vector<ITEM_BOX> lockedItems;
301 return lhs.second.GetRight() > rhs.second.GetRight();
309 int targetRight =
selectTarget( itemsToAlign, lockedItems,
312 return item.second.GetRight();
315 for(
const ITEM_BOX& item : itemsToAlign )
317 int difference = targetRight - item.second.GetRight();
323 commit.
Push(
_(
"Align to Right" ) );
330 std::vector<ITEM_BOX> itemsToAlign;
331 std::vector<ITEM_BOX> lockedItems;
336 return lhs.second.Centre().x < rhs.second.Centre().x;
347 return item.second.Centre().x;
350 for(
const ITEM_BOX& item : itemsToAlign )
352 int difference = targetX - item.second.Centre().x;
358 commit.
Push(
_(
"Align to Middle" ) );
365 std::vector<ITEM_BOX> itemsToAlign;
366 std::vector<ITEM_BOX> lockedItems;
371 return lhs.second.Centre().y < rhs.second.Centre().y;
382 return item.second.Centre().y;
385 for(
const ITEM_BOX& item : itemsToAlign )
387 int difference = targetY - item.second.Centre().y;
393 commit.
Push(
_(
"Align to Center" ) );
404 for(
const ITEM_BOX& item : aItems )
405 alignedItems.
Add( item.first );
411 item->ClearTempFlags();
413 m_frame->Schematic().CleanUp( &aCommit );
416 item->ClearEditFlags();
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
EDA_ITEM * GetParent() const
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION alignTop
static TOOL_ACTION alignRight
static TOOL_ACTION alignBottom
static TOOL_ACTION alignLeft
static TOOL_ACTION alignCenterX
static TOOL_ACTION alignCenterY
static const std::vector< KICAD_T > MovableItems
Commit for the schematic and symbol editors.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
bool IsLocked() const override
virtual void Move(const VECTOR2I &aMoveVector)
Move the item by aMoveVector to a new position.
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
virtual void Add(EDA_ITEM *aItem)
A null aItem is ignored; the selection never holds null members.
#define IS_MOVING
Item being moved.
VECTOR2< int32_t > VECTOR2I