88 const std::vector<ITEM_BOX>& aLocked,
T aGetValue )
92 if( !aLocked.empty() )
94 for(
const ITEM_BOX& item : aLocked )
96 if( item.second.Contains( cursorPos ) )
97 return aGetValue( item );
100 return aGetValue( aLocked.front() );
103 for(
const ITEM_BOX& item : aItems )
105 if( item.second.Contains( cursorPos ) )
106 return aGetValue( item );
109 return aGetValue( aItems.front() );
113template<
typename T >
115 std::vector<ITEM_BOX>& aLockedItems,
T aCompare )
121 if( !item->IsSCH_ITEM() )
132 aLockedItems.emplace_back( schItem, bbox );
134 aItemsToAlign.emplace_back( schItem, bbox );
137 std::sort( aItemsToAlign.begin(), aItemsToAlign.end(), aCompare );
138 std::sort( aLockedItems.begin(), aLockedItems.end(), aCompare );
140 return aItemsToAlign.size();
173 VECTOR2I snappedPos =
grid.AlignGrid( desiredPos, gridType );
192 std::vector<ITEM_BOX> itemsToAlign;
193 std::vector<ITEM_BOX> lockedItems;
198 return lhs.second.GetTop() < rhs.second.GetTop();
206 int targetTop =
selectTarget( itemsToAlign, lockedItems,
209 return item.second.GetTop();
212 for(
const ITEM_BOX& item : itemsToAlign )
214 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();
251 commit.
Push(
_(
"Align to Bottom" ) );
258 std::vector<ITEM_BOX> itemsToAlign;
259 std::vector<ITEM_BOX> lockedItems;
264 return lhs.second.GetLeft() < rhs.second.GetLeft();
272 int targetLeft =
selectTarget( itemsToAlign, lockedItems,
275 return item.second.GetLeft();
278 for(
const ITEM_BOX& item : itemsToAlign )
280 int difference = targetLeft - item.second.GetLeft();
284 commit.
Push(
_(
"Align to Left" ) );
291 std::vector<ITEM_BOX> itemsToAlign;
292 std::vector<ITEM_BOX> lockedItems;
297 return lhs.second.GetRight() > rhs.second.GetRight();
305 int targetRight =
selectTarget( itemsToAlign, lockedItems,
308 return item.second.GetRight();
311 for(
const ITEM_BOX& item : itemsToAlign )
313 int difference = targetRight - item.second.GetRight();
317 commit.
Push(
_(
"Align to Right" ) );
324 std::vector<ITEM_BOX> itemsToAlign;
325 std::vector<ITEM_BOX> lockedItems;
330 return lhs.second.Centre().x < rhs.second.Centre().x;
341 return item.second.Centre().x;
344 for(
const ITEM_BOX& item : itemsToAlign )
346 int difference = targetX - item.second.Centre().x;
350 commit.
Push(
_(
"Align to Middle" ) );
357 std::vector<ITEM_BOX> itemsToAlign;
358 std::vector<ITEM_BOX> lockedItems;
363 return lhs.second.Centre().y < rhs.second.Centre().y;
374 return item.second.Centre().y;
377 for(
const ITEM_BOX& item : itemsToAlign )
379 int difference = targetY - item.second.Centre().y;
383 commit.
Push(
_(
"Align to Center" ) );
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
virtual bool IsLocked() 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
virtual void Push(const wxString &aMessage=wxT("A commit"), 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,...
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...
#define IS_MOVING
Item being moved.
VECTOR2< int32_t > VECTOR2I