KiCad PCB EDA Suite
placement_tool.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014-2016 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 #include "tool/selection.h"
25 #include "placement_tool.h"
26 #include "pcb_actions.h"
27 #include "selection_tool.h"
28 #include "edit_tool.h"
29 #include <tool/tool_manager.h>
30 
31 #include <pcb_edit_frame.h>
32 #include <class_board.h>
33 #include <ratsnest_data.h>
34 #include <board_commit.h>
35 #include <bitmaps.h>
36 
37 #include <confirm.h>
38 #include <menus_helpers.h>
39 
40 
42  TOOL_INTERACTIVE( "pcbnew.Placement" ), m_selectionTool( NULL ), m_placementMenu( NULL ),
43  m_frame( NULL )
44 {
45 }
46 
48 {
49  delete m_placementMenu;
50 }
51 
52 
54 {
55  // Find the selection tool, so they can cooperate
57 
58  wxASSERT_MSG( m_selectionTool, _( "pcbnew.InteractiveSelection tool is not available" ) );
59 
60  m_frame = getEditFrame<PCB_BASE_FRAME>();
61 
62  // Create a context menu and make it available through selection tool
63  m_placementMenu = new ACTION_MENU( true );
64  m_placementMenu->SetTool( this );
66  m_placementMenu->SetTitle( _( "Align/Distribute" ) );
67 
68  // Add all align/distribute commands
75 
76  m_placementMenu->AppendSeparator();
79 
82 
83  return true;
84 }
85 
86 
87 template <class T>
89 {
90  ALIGNMENT_RECTS rects;
91 
92  for( auto item : sel )
93  {
94  BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
95 
96  if( item->Type() == PCB_MODULE_T )
97  rects.emplace_back( std::make_pair( boardItem, static_cast<MODULE*>( item )->GetFootprintRect() ) );
98  else
99  rects.emplace_back( std::make_pair( boardItem, item->GetBoundingBox() ) );
100  }
101 
102  return rects;
103 }
104 
105 
106 template< typename T >
108 {
109  wxPoint curPos( getViewControls()->GetCursorPosition().x, getViewControls()->GetCursorPosition().y );
110 
111  // after sorting, the fist item acts as the target for all others
112  // unless we have a locked item, in which case we use that for the target
113  int target = !aLocked.size() ? aGetValue( aItems.front() ): aGetValue( aLocked.front() );
114 
115  // We take the first target that overlaps our cursor.
116  // This is deterministic because we assume sorted arrays
117  for( auto item : aLocked )
118  {
119  if( item.second.Contains( curPos ) )
120  return aGetValue( item );
121  }
122 
123  // If there are locked items, prefer aligning to them over
124  // aligning to the cursor as they do not move
125  if( aLocked.empty() )
126  {
127  for( auto item : aItems )
128  {
129  if( item.second.Contains( curPos ) )
130  return aGetValue( item );
131  }
132  }
133 
134  return target;
135 }
136 
137 
138 template< typename T >
140 {
141 
143  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
144  { EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } );
145 
146  if( selection.Size() <= 1 )
147  return 0;
148 
149  std::vector<BOARD_ITEM*> lockedItems;
150  selection = m_selectionTool->RequestSelection(
151  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
152  { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED ); }, &lockedItems );
153 
154  aItems = GetBoundingBoxes( selection );
155  aLocked = GetBoundingBoxes( lockedItems );
156  std::sort( aItems.begin(), aItems.end(), aCompare );
157  std::sort( aLocked.begin(), aLocked.end(), aCompare );
158 
159  return aItems.size();
160 }
161 
162 
164 {
165  ALIGNMENT_RECTS itemsToAlign;
166  ALIGNMENT_RECTS locked_items;
167 
168  if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
169  { return ( left.second.GetTop() < right.second.GetTop() ); } ) )
170  return 0;
171 
172  BOARD_COMMIT commit( m_frame );
174  auto targetTop = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
175  { return aVal.second.GetTop(); } );
176 
177  // Move the selected items
178  for( auto& i : itemsToAlign )
179  {
180  int difference = targetTop - i.second.GetTop();
181  BOARD_ITEM* item = i.first;
182 
183  // Don't move a pad by itself unless editing the footprint
184  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
185  item = item->GetParent();
186 
187  item->Move( wxPoint( 0, difference ) );
188  }
189 
190  commit.Push( _( "Align to top" ) );
191 
192  return 0;
193 }
194 
195 
197 {
198  ALIGNMENT_RECTS itemsToAlign;
199  ALIGNMENT_RECTS locked_items;
200 
201  if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
202  { return ( left.second.GetBottom() < right.second.GetBottom() ); } ) )
203  return 0;
204 
205  BOARD_COMMIT commit( m_frame );
207  auto targetBottom = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
208  { return aVal.second.GetBottom(); } );
209 
210  // Move the selected items
211  for( auto& i : itemsToAlign )
212  {
213  int difference = targetBottom - i.second.GetBottom();
214  BOARD_ITEM* item = i.first;
215 
216  // Don't move a pad by itself unless editing the footprint
217  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
218  item = item->GetParent();
219 
220  item->Move( wxPoint( 0, difference ) );
221  }
222 
223  commit.Push( _( "Align to bottom" ) );
224 
225  return 0;
226 }
227 
228 
230 {
231  // Because this tool uses bounding boxes and they aren't mirrored even when
232  // the view is mirrored, we need to call the other one if mirrored.
233  if( getView()->IsMirroredX() )
234  {
235  return doAlignRight();
236  }
237  else
238  {
239  return doAlignLeft();
240  }
241 }
242 
243 
245 {
246  ALIGNMENT_RECTS itemsToAlign;
247  ALIGNMENT_RECTS locked_items;
248 
249  if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
250  { return ( left.second.GetLeft() < right.second.GetLeft() ); } ) )
251  return 0;
252 
253  BOARD_COMMIT commit( m_frame );
255  auto targetLeft = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
256  { return aVal.second.GetLeft(); } );
257 
258  // Move the selected items
259  for( auto& i : itemsToAlign )
260  {
261  int difference = targetLeft - i.second.GetLeft();
262  BOARD_ITEM* item = i.first;
263 
264  // Don't move a pad by itself unless editing the footprint
265  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
266  item = item->GetParent();
267 
268  item->Move( wxPoint( difference, 0 ) );
269  }
270 
271  commit.Push( _( "Align to left" ) );
272 
273  return 0;
274 }
275 
276 
278 {
279  // Because this tool uses bounding boxes and they aren't mirrored even when
280  // the view is mirrored, we need to call the other one if mirrored.
281  if( getView()->IsMirroredX() )
282  {
283  return doAlignLeft();
284  }
285  else
286  {
287  return doAlignRight();
288  }
289 }
290 
291 
293 {
294  ALIGNMENT_RECTS itemsToAlign;
295  ALIGNMENT_RECTS locked_items;
296 
297  if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
298  { return ( left.second.GetRight() < right.second.GetRight() ); } ) )
299  return 0;
300 
301  BOARD_COMMIT commit( m_frame );
303  auto targetRight = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
304  { return aVal.second.GetRight(); } );
305 
306  // Move the selected items
307  for( auto& i : itemsToAlign )
308  {
309  int difference = targetRight - i.second.GetRight();
310  BOARD_ITEM* item = i.first;
311 
312  // Don't move a pad by itself unless editing the footprint
313  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
314  item = item->GetParent();
315 
316  item->Move( wxPoint( difference, 0 ) );
317  }
318 
319  commit.Push( _( "Align to right" ) );
320 
321  return 0;
322 }
323 
324 
326 {
327  ALIGNMENT_RECTS itemsToAlign;
328  ALIGNMENT_RECTS locked_items;
329 
330  if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
331  { return ( left.second.GetCenter().x < right.second.GetCenter().x ); } ) )
332  return 0;
333 
334  BOARD_COMMIT commit( m_frame );
336  auto targetX = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
337  { return aVal.second.GetCenter().x; } );
338 
339  // Move the selected items
340  for( auto& i : itemsToAlign )
341  {
342  int difference = targetX - i.second.GetCenter().x;
343  BOARD_ITEM* item = i.first;
344 
345  // Don't move a pad by itself unless editing the footprint
346  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
347  item = item->GetParent();
348 
349  item->Move( wxPoint( difference, 0 ) );
350  }
351 
352  commit.Push( _( "Align to middle" ) );
353 
354  return 0;
355 }
356 
357 
359 {
360  ALIGNMENT_RECTS itemsToAlign;
361  ALIGNMENT_RECTS locked_items;
362 
363  if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
364  { return ( left.second.GetCenter().y < right.second.GetCenter().y ); } ) )
365  return 0;
366 
367  BOARD_COMMIT commit( m_frame );
369  auto targetY = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
370  { return aVal.second.GetCenter().y; } );
371 
372  // Move the selected items
373  for( auto& i : itemsToAlign )
374  {
375  int difference = targetY - i.second.GetCenter().y;
376  BOARD_ITEM* item = i.first;
377 
378  // Don't move a pad by itself unless editing the footprint
379  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
380  item = item->GetParent();
381 
382  item->Move( wxPoint( 0, difference ) );
383  }
384 
385  commit.Push( _( "Align to center" ) );
386 
387  return 0;
388 }
389 
390 
392 {
394  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
396 
397  if( selection.Size() <= 1 )
398  return 0;
399 
400  BOARD_COMMIT commit( m_frame );
401  commit.StageItems( selection, CHT_MODIFY );
402 
403  auto itemsToDistribute = GetBoundingBoxes( selection );
404 
405  // find the last item by reverse sorting
406  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
407  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
408  { return ( left.second.GetRight() > right.second.GetRight() ); } );
409  const auto lastItem = itemsToDistribute.begin()->first;
410 
411  const auto maxRight = itemsToDistribute.begin()->second.GetRight();
412 
413  // sort to get starting order
414  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
415  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
416  { return ( left.second.GetX() < right.second.GetX() ); } );
417  const auto minX = itemsToDistribute.begin()->second.GetX();
418  auto totalGap = maxRight - minX;
419  int totalWidth = 0;
420 
421  for( auto& i : itemsToDistribute )
422  {
423  totalWidth += i.second.GetWidth();
424  }
425 
426  if( totalGap < totalWidth )
427  {
428  // the width of the items exceeds the gap (overlapping items) -> use center point spacing
429  doDistributeCentersHorizontally( itemsToDistribute );
430  }
431  else
432  {
433  totalGap -= totalWidth;
434  doDistributeGapsHorizontally( itemsToDistribute, lastItem, totalGap );
435  }
436 
437  commit.Push( _( "Distribute horizontally" ) );
438 
439  return 0;
440 }
441 
442 
444  const BOARD_ITEM* lastItem, int totalGap ) const
445 {
446  const auto itemGap = totalGap / ( itemsToDistribute.size() - 1 );
447  auto targetX = itemsToDistribute.begin()->second.GetX();
448 
449  for( auto& i : itemsToDistribute )
450  {
451  BOARD_ITEM* item = i.first;
452 
453  // cover the corner case where the last item is wider than the previous item and gap
454  if( lastItem == item )
455  continue;
456 
457  // Don't move a pad by itself unless editing the footprint
458  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
459  item = item->GetParent();
460 
461  int difference = targetX - i.second.GetX();
462  item->Move( wxPoint( difference, 0 ) );
463  targetX += ( i.second.GetWidth() + itemGap );
464  }
465 }
466 
467 
469 {
470  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
471  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
472  { return ( left.second.GetCenter().x < right.second.GetCenter().x ); } );
473  const auto totalGap = ( itemsToDistribute.end()-1 )->second.GetCenter().x
474  - itemsToDistribute.begin()->second.GetCenter().x;
475  const auto itemGap = totalGap / ( itemsToDistribute.size() - 1 );
476  auto targetX = itemsToDistribute.begin()->second.GetCenter().x;
477 
478  for( auto& i : itemsToDistribute )
479  {
480  BOARD_ITEM* item = i.first;
481 
482  // Don't move a pad by itself unless editing the footprint
483  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
484  item = item->GetParent();
485 
486  int difference = targetX - i.second.GetCenter().x;
487  item->Move( wxPoint( difference, 0 ) );
488  targetX += ( itemGap );
489  }
490 }
491 
492 
494 {
496  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
498 
499  if( selection.Size() <= 1 )
500  return 0;
501 
502  BOARD_COMMIT commit( m_frame );
503  commit.StageItems( selection, CHT_MODIFY );
504 
505  auto itemsToDistribute = GetBoundingBoxes( selection );
506 
507  // find the last item by reverse sorting
508  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
509  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
510  { return ( left.second.GetBottom() > right.second.GetBottom() ); } );
511  const auto maxBottom = itemsToDistribute.begin()->second.GetBottom();
512  const auto lastItem = itemsToDistribute.begin()->first;
513 
514  // sort to get starting order
515  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
516  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
517  { return ( left.second.GetCenter().y < right.second.GetCenter().y ); } );
518  auto minY = itemsToDistribute.begin()->second.GetY();
519 
520  auto totalGap = maxBottom - minY;
521  int totalHeight = 0;
522 
523  for( auto& i : itemsToDistribute )
524  {
525  totalHeight += i.second.GetHeight();
526  }
527 
528  if( totalGap < totalHeight )
529  {
530  // the width of the items exceeds the gap (overlapping items) -> use center point spacing
531  doDistributeCentersVertically( itemsToDistribute );
532  }
533  else
534  {
535  totalGap -= totalHeight;
536  doDistributeGapsVertically( itemsToDistribute, lastItem, totalGap );
537  }
538 
539  commit.Push( _( "Distribute vertically" ) );
540 
541  return 0;
542 }
543 
544 
546  const BOARD_ITEM* lastItem, int totalGap ) const
547 {
548  const auto itemGap = totalGap / ( itemsToDistribute.size() - 1 );
549  auto targetY = itemsToDistribute.begin()->second.GetY();
550 
551  for( auto& i : itemsToDistribute )
552  {
553  BOARD_ITEM* item = i.first;
554 
555  // cover the corner case where the last item is wider than the previous item and gap
556  if( lastItem == item )
557  continue;
558 
559  // Don't move a pad by itself unless editing the footprint
560  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
561  item = item->GetParent();
562 
563  int difference = targetY - i.second.GetY();
564  i.first->Move( wxPoint( 0, difference ) );
565  targetY += ( i.second.GetHeight() + itemGap );
566  }
567 }
568 
569 
571 {
572  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
573  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
574  { return ( left.second.GetCenter().y < right.second.GetCenter().y ); } );
575  const auto totalGap = ( itemsToDistribute.end()-1 )->second.GetCenter().y
576  - itemsToDistribute.begin()->second.GetCenter().y;
577  const auto itemGap = totalGap / ( itemsToDistribute.size() - 1 );
578  auto targetY = itemsToDistribute.begin()->second.GetCenter().y;
579 
580  for( auto& i : itemsToDistribute )
581  {
582  BOARD_ITEM* item = i.first;
583 
584  // Don't move a pad by itself unless editing the footprint
585  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
586  item = item->GetParent();
587 
588  int difference = targetY - i.second.GetCenter().y;
589  item->Move( wxPoint( 0, difference ) );
590  targetY += ( itemGap );
591  }
592 }
593 
594 
596 {
603 
606 }
static TOOL_ACTION alignRight
Definition: pcb_actions.h:213
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
int AlignLeft(const TOOL_EVENT &aEvent)
Function AlignLeft() Sets X coordinate of the selected items to the value of the left-most selected i...
wxMenuItem * Add(const wxString &aLabel, int aId, const BITMAP_OPAQUE *aIcon)
Function Add() Adds a wxWidgets-style entry to the menu.
void doDistributeGapsHorizontally(ALIGNMENT_RECTS &itemsToDistribute, const BOARD_ITEM *lastItem, int totalGap) const
Distributes selected items using an even spacing between their bounding boxes.
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
int AlignCenterY(const TOOL_EVENT &aEvent)
Function AlignCenterX() Sets the y coordinate of the midpoint of each of the selected items to the va...
ACTION_MENU.
Definition: action_menu.h:43
This file is part of the common library.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
int AlignCenterX(const TOOL_EVENT &aEvent)
Function AlignCenterX() Sets the x coordinate of the midpoint of each of the selected items to the va...
static SELECTION_CONDITION MoreThan(int aNumber)
Function MoreThan Creates a functor that tests if the number of selected items is greater than the va...
virtual ~ALIGN_DISTRIBUTE_TOOL()
ACTION_MENU * m_placementMenu
SELECTION_TOOL.
void doDistributeCentersVertically(ALIGNMENT_RECTS &itemsToDistribute) const
Distributes selected items using an even spacing between the centers of their bounding boxes.
Class that computes missing connections on a PCB.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
static TOOL_ACTION alignCenterY
Definition: pcb_actions.h:215
TOOL_MENU & GetToolMenu()
int AlignBottom(const TOOL_EVENT &aEvent)
Function AlignBottom() Sets Y coordinate of the selected items to the value of the bottom-most select...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
static TOOL_ACTION distributeVertically
Definition: pcb_actions.h:217
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
ALIGNMENT_RECTS GetBoundingBoxes(const T &sel)
static TOOL_ACTION alignBottom
Definition: pcb_actions.h:211
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
static TOOL_ACTION distributeHorizontally
Definition: pcb_actions.h:216
int DistributeHorizontally(const TOOL_EVENT &aEvent)
Function DistributeHorizontally() Distributes the selected items along the X axis.
class MODULE, a footprint
Definition: typeinfo.h:89
int doAlignRight()
Aligns selected items using the right edge of their bounding boxes to the right-most item.
int doAlignLeft()
Sets X coordinate of the selected items to the value of the left-most selected item X coordinate.
#define NULL
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
const BITMAP_OPAQUE align_items_xpm[1]
Definition: align_items.cpp:21
int AlignTop(const TOOL_EVENT &aEvent)
Function AlignTop() Sets Y coordinate of the selected items to the value of the top-most selected ite...
void SetIcon(const BITMAP_OPAQUE *aIcon)
Function SetIcon() Assigns an icon for the entry.
Definition: action_menu.cpp:68
TOOL_EVENT.
Definition: tool_event.h:171
int DistributeVertically(const TOOL_EVENT &aEvent)
Function DistributeVertically() Distributes the selected items along the Y axis.
COMMIT & StageItems(const Range &aRange, CHANGE_TYPE aChangeType)
Definition: commit.h:116
static TOOL_ACTION alignLeft
Definition: pcb_actions.h:212
void doDistributeCentersHorizontally(ALIGNMENT_RECTS &itemsToDistribute) const
Distributes selected items using an even spacing between the centers of their bounding boxes.
static TOOL_ACTION alignTop
Definition: pcb_actions.h:210
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
size_t GetSelections(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aCompare)
Function GetSelections() Populates two vectors with the sorted selection and sorted locked items Retu...
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the menu.
Definition: action_menu.cpp:86
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
#define _(s)
Definition: 3d_actions.cpp:33
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
void setTransitions() override
Sets up handlers for various events.
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
void doDistributeGapsVertically(ALIGNMENT_RECTS &itemsToDistribute, const BOARD_ITEM *lastItem, int totalGap) const
Distributes selected items using an even spacing between their bounding boxes.
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
virtual const wxPoint GetCenter() const
Function GetCenter()
SELECTION_TOOL * m_selectionTool
int AlignRight(const TOOL_EVENT &aEvent)
Function AlignRight() Sets X coordinate of the selected items to the value of the right-most selected...
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:53
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
BOARD_ITEM_CONTAINER * GetParent() const
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:60
static TOOL_ACTION alignCenterX
Definition: pcb_actions.h:214
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212