KiCad PCB EDA Suite
ALIGN_DISTRIBUTE_TOOL Class Reference

#include <placement_tool.h>

Inheritance diagram for ALIGN_DISTRIBUTE_TOOL:
TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 ALIGN_DISTRIBUTE_TOOL ()
 
virtual ~ALIGN_DISTRIBUTE_TOOL ()
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
int AlignTop (const TOOL_EVENT &aEvent)
 Set Y coordinate of the selected items to the value of the top-most selected item Y coordinate. More...
 
int AlignBottom (const TOOL_EVENT &aEvent)
 Sets Y coordinate of the selected items to the value of the bottom-most selected item Y coordinate. More...
 
int AlignLeft (const TOOL_EVENT &aEvent)
 Sets X coordinate of the selected items to the value of the left-most selected item X coordinate. More...
 
int AlignRight (const TOOL_EVENT &aEvent)
 Sets X coordinate of the selected items to the value of the right-most selected item X coordinate. More...
 
int AlignCenterX (const TOOL_EVENT &aEvent)
 Set the x coordinate of the midpoint of each of the selected items to the value of the x coordinate of the center of the middle selected item. More...
 
int AlignCenterY (const TOOL_EVENT &aEvent)
 Set the y coordinate of the midpoint of each of the selected items to the value of the y coordinate of the center of the middle selected item. More...
 
int DistributeHorizontally (const TOOL_EVENT &aEvent)
 Distribute the selected items along the X axis. More...
 
int DistributeVertically (const TOOL_EVENT &aEvent)
 Distribute the selected items along the Y axis. More...
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Protected Member Functions

void attachManager (TOOL_MANAGER *aManager)
 Set the TOOL_MANAGER the tool will belong to. More...
 
KIGFX::VIEWgetView () const
 Returns the instance of #VIEW object used in the application. More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Return the instance of VIEW_CONTROLS object used in the application. More...
 
template<typename T >
T * getEditFrame () const
 Return the application window object, casted to requested user type. More...
 
template<typename T >
T * getModel () const
 Return the model object if it matches the requested type. More...
 

Protected Attributes

TOOL_MENU m_menu
 The functions below are not yet implemented - their interface may change. More...
 
TOOL_TYPE m_type
 Unique identifier for the tool, assigned by a TOOL_MANAGER instance. More...
 
TOOL_ID m_toolId
 Name of the tool. More...
 
std::string m_toolName
 
TOOL_MANAGERm_toolMgr
 

Private Member Functions

template<typename T >
size_t GetSelections (ALIGNMENT_RECTS &aItemsToAlign, ALIGNMENT_RECTS &aLockedItems, T aCompare)
 Populate two vectors with the sorted selection and sorted locked items. More...
 
template<typename T >
int selectTarget (ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
 
int doAlignLeft ()
 Sets X coordinate of the selected items to the value of the left-most selected item X coordinate. More...
 
int doAlignRight ()
 Align selected items using the right edge of their bounding boxes to the right-most item. More...
 
void doDistributeCentersHorizontally (ALIGNMENT_RECTS &itemsToDistribute, BOARD_COMMIT &aCommit) const
 Distribute selected items using an even spacing between the centers of their bounding boxes. More...
 
void doDistributeCentersVertically (ALIGNMENT_RECTS &itemsToDistribute, BOARD_COMMIT &aCommit) const
 Distribute selected items using an even spacing between the centers of their bounding boxes. More...
 
void doDistributeGapsHorizontally (ALIGNMENT_RECTS &itemsToDistribute, BOARD_COMMIT &aCommit, const BOARD_ITEM *lastItem, int totalGap) const
 Distributes selected items using an even spacing between their bounding boxes. More...
 
void doDistributeGapsVertically (ALIGNMENT_RECTS &itemsToDistribute, BOARD_COMMIT &aCommit, const BOARD_ITEM *lastItem, int totalGap) const
 Distributes selected items using an even spacing between their bounding boxes. More...
 

Private Attributes

PCB_SELECTION_TOOLm_selectionTool
 
ACTION_MENUm_placementMenu
 
PCB_BASE_FRAMEm_frame
 

Detailed Description

Definition at line 40 of file placement_tool.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determine the reason of reset for a tool.

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 77 of file tool_base.h.

78  {
79  RUN,
80  MODEL_RELOAD,
81  GAL_SWITCH
82  };
Model changes (required full reload)
Definition: tool_base.h:80
Tool is invoked after being inactive.
Definition: tool_base.h:79
Rendering engine changes.
Definition: tool_base.h:81

Constructor & Destructor Documentation

◆ ALIGN_DISTRIBUTE_TOOL()

ALIGN_DISTRIBUTE_TOOL::ALIGN_DISTRIBUTE_TOOL ( )

Definition at line 42 of file placement_tool.cpp.

42  :
43  TOOL_INTERACTIVE( "pcbnew.Placement" ),
44  m_selectionTool( nullptr ),
45  m_placementMenu( nullptr ),
46  m_frame( nullptr )
47 {
48 }
PCB_SELECTION_TOOL * m_selectionTool
ACTION_MENU * m_placementMenu
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Create a tool with given id & name.
PCB_BASE_FRAME * m_frame

◆ ~ALIGN_DISTRIBUTE_TOOL()

ALIGN_DISTRIBUTE_TOOL::~ALIGN_DISTRIBUTE_TOOL ( )
virtual

Definition at line 50 of file placement_tool.cpp.

51 {
52  delete m_placementMenu;
53 }
ACTION_MENU * m_placementMenu

References m_placementMenu.

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run the tool.

After activation, the tool starts receiving events until it is finished.

Definition at line 51 of file tool_interactive.cpp.

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.

References TOOL_MANAGER::InvokeTool(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_TREE::onContextMenu(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ AlignBottom()

int ALIGN_DISTRIBUTE_TOOL::AlignBottom ( const TOOL_EVENT aEvent)

Sets Y coordinate of the selected items to the value of the bottom-most selected item Y coordinate.

Definition at line 239 of file placement_tool.cpp.

240 {
241  ALIGNMENT_RECTS itemsToAlign;
242  ALIGNMENT_RECTS locked_items;
243 
244  if( !GetSelections( itemsToAlign, locked_items,
245  []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
246  {
247  return ( left.second.GetBottom() < right.second.GetBottom() );
248  } ) )
249  {
250  return 0;
251  }
252 
253  BOARD_COMMIT commit( m_frame );
254 
255  int targetBottom = selectTarget( itemsToAlign, locked_items,
256  []( const ALIGNMENT_RECT& aVal )
257  {
258  return aVal.second.GetBottom();
259  } );
260 
261  // Move the selected items
262  for( std::pair<BOARD_ITEM*, EDA_RECT>& i : itemsToAlign )
263  {
264  int difference = targetBottom - i.second.GetBottom();
265  BOARD_ITEM* item = i.first;
266 
267  if( item->GetParent() && item->GetParent()->IsSelected() )
268  continue;
269 
270  // Don't move a pad by itself unless editing the footprint
271  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
272  item = item->GetParent();
273 
274  commit.Stage( item, CHT_MODIFY );
275  item->Move( wxPoint( 0, difference ) );
276  }
277 
278  commit.Push( _( "Align to bottom" ) );
279 
280  return 0;
281 }
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
bool IsSelected() const
Definition: eda_item.h:122
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PAD, a pad in a footprint
Definition: typeinfo.h:89
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:238
#define _(s)
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
size_t GetSelections(ALIGNMENT_RECTS &aItemsToAlign, ALIGNMENT_RECTS &aLockedItems, T aCompare)
Populate two vectors with the sorted selection and sorted locked items.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, CHT_MODIFY, FRAME_PCB_EDITOR, BOARD_ITEM::GetParent(), GetSelections(), EDA_ITEM::IsSelected(), EDA_BASE_FRAME::IsType(), left, m_frame, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Push(), right, selectTarget(), BOARD_COMMIT::Stage(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ AlignCenterX()

int ALIGN_DISTRIBUTE_TOOL::AlignCenterX ( const TOOL_EVENT aEvent)

Set the x coordinate of the midpoint of each of the selected items to the value of the x coordinate of the center of the middle selected item.

Definition at line 404 of file placement_tool.cpp.

405 {
406  ALIGNMENT_RECTS itemsToAlign;
407  ALIGNMENT_RECTS locked_items;
408 
409  if( !GetSelections( itemsToAlign, locked_items,
410  []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
411  {
412  return ( left.second.GetCenter().x < right.second.GetCenter().x );
413  } ) )
414  {
415  return 0;
416  }
417 
418  BOARD_COMMIT commit( m_frame );
419 
420  int targetX = selectTarget( itemsToAlign, locked_items,
421  []( const ALIGNMENT_RECT& aVal )
422  {
423  return aVal.second.GetCenter().x;
424  } );
425 
426  // Move the selected items
427  for( std::pair<BOARD_ITEM*, EDA_RECT>& i : itemsToAlign )
428  {
429  int difference = targetX - i.second.GetCenter().x;
430  BOARD_ITEM* item = i.first;
431 
432  if( item->GetParent() && item->GetParent()->IsSelected() )
433  continue;
434 
435  // Don't move a pad by itself unless editing the footprint
436  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
437  item = item->GetParent();
438 
439  commit.Stage( item, CHT_MODIFY );
440  item->Move( wxPoint( difference, 0 ) );
441  }
442 
443  commit.Push( _( "Align to middle" ) );
444 
445  return 0;
446 }
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
bool IsSelected() const
Definition: eda_item.h:122
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PAD, a pad in a footprint
Definition: typeinfo.h:89
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:238
#define _(s)
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
size_t GetSelections(ALIGNMENT_RECTS &aItemsToAlign, ALIGNMENT_RECTS &aLockedItems, T aCompare)
Populate two vectors with the sorted selection and sorted locked items.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, CHT_MODIFY, FRAME_PCB_EDITOR, BOARD_ITEM::GetParent(), GetSelections(), EDA_ITEM::IsSelected(), EDA_BASE_FRAME::IsType(), left, m_frame, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Push(), right, selectTarget(), BOARD_COMMIT::Stage(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ AlignCenterY()

int ALIGN_DISTRIBUTE_TOOL::AlignCenterY ( const TOOL_EVENT aEvent)

Set the y coordinate of the midpoint of each of the selected items to the value of the y coordinate of the center of the middle selected item.

Definition at line 449 of file placement_tool.cpp.

450 {
451  ALIGNMENT_RECTS itemsToAlign;
452  ALIGNMENT_RECTS locked_items;
453 
454  if( !GetSelections( itemsToAlign, locked_items,
455  []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
456  {
457  return ( left.second.GetCenter().y < right.second.GetCenter().y );
458  } ) )
459  {
460  return 0;
461  }
462 
463  BOARD_COMMIT commit( m_frame );
464 
465  int targetY = selectTarget( itemsToAlign, locked_items,
466  []( const ALIGNMENT_RECT& aVal )
467  {
468  return aVal.second.GetCenter().y;
469  } );
470 
471  // Move the selected items
472  for( std::pair<BOARD_ITEM*, EDA_RECT>& i : itemsToAlign )
473  {
474  int difference = targetY - i.second.GetCenter().y;
475  BOARD_ITEM* item = i.first;
476 
477  if( item->GetParent() && item->GetParent()->IsSelected() )
478  continue;
479 
480  // Don't move a pad by itself unless editing the footprint
481  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
482  item = item->GetParent();
483 
484  commit.Stage( item, CHT_MODIFY );
485  item->Move( wxPoint( 0, difference ) );
486  }
487 
488  commit.Push( _( "Align to center" ) );
489 
490  return 0;
491 }
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
bool IsSelected() const
Definition: eda_item.h:122
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PAD, a pad in a footprint
Definition: typeinfo.h:89
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:238
#define _(s)
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
size_t GetSelections(ALIGNMENT_RECTS &aItemsToAlign, ALIGNMENT_RECTS &aLockedItems, T aCompare)
Populate two vectors with the sorted selection and sorted locked items.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, CHT_MODIFY, FRAME_PCB_EDITOR, BOARD_ITEM::GetParent(), GetSelections(), EDA_ITEM::IsSelected(), EDA_BASE_FRAME::IsType(), left, m_frame, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Push(), right, selectTarget(), BOARD_COMMIT::Stage(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ AlignLeft()

int ALIGN_DISTRIBUTE_TOOL::AlignLeft ( const TOOL_EVENT aEvent)

Sets X coordinate of the selected items to the value of the left-most selected item X coordinate.

Definition at line 284 of file placement_tool.cpp.

285 {
286  // Because this tool uses bounding boxes and they aren't mirrored even when
287  // the view is mirrored, we need to call the other one if mirrored.
288  if( getView()->IsMirroredX() )
289  {
290  return doAlignRight();
291  }
292  else
293  {
294  return doAlignLeft();
295  }
296 }
int doAlignRight()
Align 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.
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36

References doAlignLeft(), doAlignRight(), and TOOL_BASE::getView().

Referenced by setTransitions().

◆ AlignRight()

int ALIGN_DISTRIBUTE_TOOL::AlignRight ( const TOOL_EVENT aEvent)

Sets X coordinate of the selected items to the value of the right-most selected item X coordinate.

Definition at line 344 of file placement_tool.cpp.

345 {
346  // Because this tool uses bounding boxes and they aren't mirrored even when
347  // the view is mirrored, we need to call the other one if mirrored.
348  if( getView()->IsMirroredX() )
349  {
350  return doAlignLeft();
351  }
352  else
353  {
354  return doAlignRight();
355  }
356 }
int doAlignRight()
Align 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.
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36

References doAlignLeft(), doAlignRight(), and TOOL_BASE::getView().

Referenced by setTransitions().

◆ AlignTop()

int ALIGN_DISTRIBUTE_TOOL::AlignTop ( const TOOL_EVENT aEvent)

Set Y coordinate of the selected items to the value of the top-most selected item Y coordinate.

Definition at line 194 of file placement_tool.cpp.

195 {
196  ALIGNMENT_RECTS itemsToAlign;
197  ALIGNMENT_RECTS locked_items;
198 
199  if( !GetSelections( itemsToAlign, locked_items,
200  []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
201  {
202  return ( left.second.GetTop() < right.second.GetTop() );
203  } ) )
204  {
205  return 0;
206  }
207 
208  BOARD_COMMIT commit( m_frame );
209 
210  int targetTop = selectTarget( itemsToAlign, locked_items,
211  []( const ALIGNMENT_RECT& aVal )
212  {
213  return aVal.second.GetTop();
214  } );
215 
216  // Move the selected items
217  for( std::pair<BOARD_ITEM*, EDA_RECT>& i : itemsToAlign )
218  {
219  BOARD_ITEM* item = i.first;
220  int difference = targetTop - i.second.GetTop();
221 
222  if( item->GetParent() && item->GetParent()->IsSelected() )
223  continue;
224 
225  // Don't move a pad by itself unless editing the footprint
226  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
227  item = item->GetParent();
228 
229  commit.Stage( item, CHT_MODIFY );
230  item->Move( wxPoint( 0, difference ) );
231  }
232 
233  commit.Push( _( "Align to top" ) );
234 
235  return 0;
236 }
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
bool IsSelected() const
Definition: eda_item.h:122
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PAD, a pad in a footprint
Definition: typeinfo.h:89
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:238
#define _(s)
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
size_t GetSelections(ALIGNMENT_RECTS &aItemsToAlign, ALIGNMENT_RECTS &aLockedItems, T aCompare)
Populate two vectors with the sorted selection and sorted locked items.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, CHT_MODIFY, FRAME_PCB_EDITOR, BOARD_ITEM::GetParent(), GetSelections(), EDA_ITEM::IsSelected(), EDA_BASE_FRAME::IsType(), left, m_frame, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Push(), right, selectTarget(), BOARD_COMMIT::Stage(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Set the TOOL_MANAGER the tool will belong to.

Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

61 {
62  m_toolMgr = aManager;
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ DistributeHorizontally()

int ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally ( const TOOL_EVENT aEvent)

Distribute the selected items along the X axis.

Definition at line 494 of file placement_tool.cpp.

495 {
497  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
498  {
499  // Iterate from the back so we don't have to worry about removals.
500  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
501  {
502  BOARD_ITEM* item = aCollector[i];
503 
504  if( item->Type() == PCB_MARKER_T )
505  aCollector.Remove( item );
506  }
507  },
508  m_frame->IsType( FRAME_PCB_EDITOR ) /* prompt user regarding locked items */ );
509 
510  if( selection.Size() <= 1 )
511  return 0;
512 
513  BOARD_COMMIT commit( m_frame );
514  ALIGNMENT_RECTS itemsToDistribute = GetBoundingBoxes( selection );
515 
516  // find the last item by reverse sorting
517  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
518  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
519  {
520  return ( left.second.GetRight() > right.second.GetRight() );
521  } );
522 
523  BOARD_ITEM* lastItem = itemsToDistribute.begin()->first;
524  const int maxRight = itemsToDistribute.begin()->second.GetRight();
525 
526  // sort to get starting order
527  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
528  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
529  {
530  return ( left.second.GetX() < right.second.GetX() );
531  } );
532 
533  const int minX = itemsToDistribute.begin()->second.GetX();
534  int totalGap = maxRight - minX;
535  int totalWidth = 0;
536 
537  for( std::pair<BOARD_ITEM*, EDA_RECT>& i : itemsToDistribute )
538  totalWidth += i.second.GetWidth();
539 
540  if( totalGap < totalWidth )
541  {
542  // the width of the items exceeds the gap (overlapping items) -> use center point spacing
543  doDistributeCentersHorizontally( itemsToDistribute, commit );
544  }
545  else
546  {
547  totalGap -= totalWidth;
548  doDistributeGapsHorizontally( itemsToDistribute, commit, lastItem, totalGap );
549  }
550 
551  commit.Push( _( "Distribute horizontally" ) );
552 
553  return 0;
554 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
PCB_SELECTION_TOOL * m_selectionTool
void doDistributeCentersHorizontally(ALIGNMENT_RECTS &itemsToDistribute, BOARD_COMMIT &aCommit) const
Distribute selected items using an even spacing between the centers of their bounding boxes.
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:110
ALIGNMENT_RECTS GetBoundingBoxes(const T &aItems)
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
void doDistributeGapsHorizontally(ALIGNMENT_RECTS &itemsToDistribute, BOARD_COMMIT &aCommit, const BOARD_ITEM *lastItem, int totalGap) const
Distributes selected items using an even spacing between their bounding boxes.
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
#define _(s)
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:98
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
int GetX() const
Definition: board_item.h:64
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
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
int Size() const
Returns the number of selected parts.
Definition: selection.h:104
The selection tool: currently supports:
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, doDistributeCentersHorizontally(), doDistributeGapsHorizontally(), FRAME_PCB_EDITOR, GetBoundingBoxes(), COLLECTOR::GetCount(), BOARD_ITEM::GetX(), EDA_BASE_FRAME::IsType(), left, m_frame, m_selectionTool, PCB_MARKER_T, BOARD_COMMIT::Push(), COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), right, SELECTION::Size(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ DistributeVertically()

int ALIGN_DISTRIBUTE_TOOL::DistributeVertically ( const TOOL_EVENT aEvent)

Distribute the selected items along the Y axis.

Set up handlers for various events.

Definition at line 621 of file placement_tool.cpp.

622 {
624  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
625  {
626  // Iterate from the back so we don't have to worry about removals.
627  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
628  {
629  BOARD_ITEM* item = aCollector[i];
630 
631  if( item->Type() == PCB_MARKER_T )
632  aCollector.Remove( item );
633  }
634  },
635  m_frame->IsType( FRAME_PCB_EDITOR ) /* prompt user regarding locked items */ );
636 
637  if( selection.Size() <= 1 )
638  return 0;
639 
640  BOARD_COMMIT commit( m_frame );
641  ALIGNMENT_RECTS itemsToDistribute = GetBoundingBoxes( selection );
642 
643  // find the last item by reverse sorting
644  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
645  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
646  {
647  return ( left.second.GetBottom() > right.second.GetBottom() );
648  } );
649 
650  BOARD_ITEM* lastItem = itemsToDistribute.begin()->first;
651  const int maxBottom = itemsToDistribute.begin()->second.GetBottom();
652 
653  // sort to get starting order
654  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
655  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
656  {
657  return ( left.second.GetCenter().y < right.second.GetCenter().y );
658  } );
659 
660  int minY = itemsToDistribute.begin()->second.GetY();
661  int totalGap = maxBottom - minY;
662  int totalHeight = 0;
663 
664  for( std::pair<BOARD_ITEM*, EDA_RECT>& i : itemsToDistribute )
665  totalHeight += i.second.GetHeight();
666 
667  if( totalGap < totalHeight )
668  {
669  // the width of the items exceeds the gap (overlapping items) -> use center point spacing
670  doDistributeCentersVertically( itemsToDistribute, commit );
671  }
672  else
673  {
674  totalGap -= totalHeight;
675  doDistributeGapsVertically( itemsToDistribute, commit, lastItem, totalGap );
676  }
677 
678  commit.Push( _( "Distribute vertically" ) );
679 
680  return 0;
681 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
PCB_SELECTION_TOOL * m_selectionTool
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:110
ALIGNMENT_RECTS GetBoundingBoxes(const T &aItems)
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
int GetY() const
Definition: board_item.h:70
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
#define _(s)
void doDistributeGapsVertically(ALIGNMENT_RECTS &itemsToDistribute, BOARD_COMMIT &aCommit, const BOARD_ITEM *lastItem, int totalGap) const
Distributes selected items using an even spacing between their bounding boxes.
void doDistributeCentersVertically(ALIGNMENT_RECTS &itemsToDistribute, BOARD_COMMIT &aCommit) const
Distribute selected items using an even spacing between the centers of their bounding boxes.
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:98
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
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
int Size() const
Returns the number of selected parts.
Definition: selection.h:104
The selection tool: currently supports:
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, doDistributeCentersVertically(), doDistributeGapsVertically(), FRAME_PCB_EDITOR, GetBoundingBoxes(), COLLECTOR::GetCount(), BOARD_ITEM::GetY(), EDA_BASE_FRAME::IsType(), left, m_frame, m_selectionTool, PCB_MARKER_T, BOARD_COMMIT::Push(), COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), right, SELECTION::Size(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ doAlignLeft()

int ALIGN_DISTRIBUTE_TOOL::doAlignLeft ( )
private

Sets X coordinate of the selected items to the value of the left-most selected item X coordinate.

Note
Uses the bounding box of items, which do not get mirrored even when the view is mirrored!

Definition at line 299 of file placement_tool.cpp.

300 {
301  ALIGNMENT_RECTS itemsToAlign;
302  ALIGNMENT_RECTS locked_items;
303 
304  if( !GetSelections( itemsToAlign, locked_items,
305  []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
306  {
307  return ( left.second.GetLeft() < right.second.GetLeft() );
308  } ) )
309  {
310  return 0;
311  }
312 
313  BOARD_COMMIT commit( m_frame );
314 
315  int targetLeft = selectTarget( itemsToAlign, locked_items,
316  []( const ALIGNMENT_RECT& aVal )
317  {
318  return aVal.second.GetLeft();
319  } );
320 
321  // Move the selected items
322  for( std::pair<BOARD_ITEM*, EDA_RECT>& i : itemsToAlign )
323  {
324  int difference = targetLeft - i.second.GetLeft();
325  BOARD_ITEM* item = i.first;
326 
327  if( item->GetParent() && item->GetParent()->IsSelected() )
328  continue;
329 
330  // Don't move a pad by itself unless editing the footprint
331  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
332  item = item->GetParent();
333 
334  commit.Stage( item, CHT_MODIFY );
335  item->Move( wxPoint( difference, 0 ) );
336  }
337 
338  commit.Push( _( "Align to left" ) );
339 
340  return 0;
341 }
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
bool IsSelected() const
Definition: eda_item.h:122
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PAD, a pad in a footprint
Definition: typeinfo.h:89
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:238
#define _(s)
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
size_t GetSelections(ALIGNMENT_RECTS &aItemsToAlign, ALIGNMENT_RECTS &aLockedItems, T aCompare)
Populate two vectors with the sorted selection and sorted locked items.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, CHT_MODIFY, FRAME_PCB_EDITOR, BOARD_ITEM::GetParent(), GetSelections(), EDA_ITEM::IsSelected(), EDA_BASE_FRAME::IsType(), left, m_frame, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Push(), right, selectTarget(), BOARD_COMMIT::Stage(), and EDA_ITEM::Type().

Referenced by AlignLeft(), and AlignRight().

◆ doAlignRight()

int ALIGN_DISTRIBUTE_TOOL::doAlignRight ( )
private

Align selected items using the right edge of their bounding boxes to the right-most item.

Note
Uses the bounding box of items, which do not get mirrored even when the view is mirrored!

Definition at line 359 of file placement_tool.cpp.

360 {
361  ALIGNMENT_RECTS itemsToAlign;
362  ALIGNMENT_RECTS locked_items;
363 
364  if( !GetSelections( itemsToAlign, locked_items,
365  []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
366  {
367  return ( left.second.GetRight() < right.second.GetRight() );
368  } ) )
369  {
370  return 0;
371  }
372 
373  BOARD_COMMIT commit( m_frame );
374 
375  int targetRight = selectTarget( itemsToAlign, locked_items,
376  []( const ALIGNMENT_RECT& aVal )
377  {
378  return aVal.second.GetRight();
379  } );
380 
381  // Move the selected items
382  for( std::pair<BOARD_ITEM*, EDA_RECT>& i : itemsToAlign )
383  {
384  int difference = targetRight - i.second.GetRight();
385  BOARD_ITEM* item = i.first;
386 
387  if( item->GetParent() && item->GetParent()->IsSelected() )
388  continue;
389 
390  // Don't move a pad by itself unless editing the footprint
391  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
392  item = item->GetParent();
393 
394  commit.Stage( item, CHT_MODIFY );
395  item->Move( wxPoint( difference, 0 ) );
396  }
397 
398  commit.Push( _( "Align to right" ) );
399 
400  return 0;
401 }
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
bool IsSelected() const
Definition: eda_item.h:122
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PAD, a pad in a footprint
Definition: typeinfo.h:89
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:238
#define _(s)
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
size_t GetSelections(ALIGNMENT_RECTS &aItemsToAlign, ALIGNMENT_RECTS &aLockedItems, T aCompare)
Populate two vectors with the sorted selection and sorted locked items.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, CHT_MODIFY, FRAME_PCB_EDITOR, BOARD_ITEM::GetParent(), GetSelections(), EDA_ITEM::IsSelected(), EDA_BASE_FRAME::IsType(), left, m_frame, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Push(), right, selectTarget(), BOARD_COMMIT::Stage(), and EDA_ITEM::Type().

Referenced by AlignLeft(), and AlignRight().

◆ doDistributeCentersHorizontally()

void ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally ( ALIGNMENT_RECTS itemsToDistribute,
BOARD_COMMIT aCommit 
) const
private

Distribute selected items using an even spacing between the centers of their bounding boxes.

Note
Using the centers of bounding box of items can give unsatisfactory visual results since items of differing widths will be placed with different gaps. Is only used if items overlap.

Definition at line 588 of file placement_tool.cpp.

590 {
591  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
592  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
593  {
594  return ( left.second.GetCenter().x < right.second.GetCenter().x );
595  } );
596 
597  const int totalGap = ( itemsToDistribute.end()-1 )->second.GetCenter().x
598  - itemsToDistribute.begin()->second.GetCenter().x;
599  const int itemGap = totalGap / ( itemsToDistribute.size() - 1 );
600  int targetX = itemsToDistribute.begin()->second.GetCenter().x;
601 
602  for( std::pair<BOARD_ITEM*, EDA_RECT>& i : itemsToDistribute )
603  {
604  BOARD_ITEM* item = i.first;
605 
606  if( item->GetParent() && item->GetParent()->IsSelected() )
607  continue;
608 
609  // Don't move a pad by itself unless editing the footprint
610  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
611  item = item->GetParent();
612 
613  int difference = targetX - i.second.GetCenter().x;
614  aCommit.Stage( item, CHT_MODIFY );
615  item->Move( wxPoint( difference, 0 ) );
616  targetX += ( itemGap );
617  }
618 }
bool IsSelected() const
Definition: eda_item.h:122
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PAD, a pad in a footprint
Definition: typeinfo.h:89
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:238
virtual wxPoint GetCenter() const
This defaults to the center of the bounding box if not overridden.
Definition: board_item.h:81
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType) override
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References CHT_MODIFY, FRAME_PCB_EDITOR, BOARD_ITEM::GetCenter(), BOARD_ITEM::GetParent(), EDA_ITEM::IsSelected(), EDA_BASE_FRAME::IsType(), left, m_frame, BOARD_ITEM::Move(), PCB_PAD_T, right, BOARD_COMMIT::Stage(), and EDA_ITEM::Type().

Referenced by DistributeHorizontally().

◆ doDistributeCentersVertically()

void ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically ( ALIGNMENT_RECTS itemsToDistribute,
BOARD_COMMIT aCommit 
) const
private

Distribute selected items using an even spacing between the centers of their bounding boxes.

Note
Using the centers of bounding box of items can give unsatisfactory visual results since items of differing widths will be placed with different gaps. Is only used if items overlap

Definition at line 715 of file placement_tool.cpp.

717 {
718  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
719  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
720  {
721  return ( left.second.GetCenter().y < right.second.GetCenter().y );
722  } );
723 
724  const int totalGap = ( itemsToDistribute.end()-1 )->second.GetCenter().y
725  - itemsToDistribute.begin()->second.GetCenter().y;
726  const int itemGap = totalGap / ( itemsToDistribute.size() - 1 );
727  int targetY = itemsToDistribute.begin()->second.GetCenter().y;
728 
729  for( std::pair<BOARD_ITEM*, EDA_RECT>& i : itemsToDistribute )
730  {
731  BOARD_ITEM* item = i.first;
732 
733  if( item->GetParent() && item->GetParent()->IsSelected() )
734  continue;
735 
736  // Don't move a pad by itself unless editing the footprint
737  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
738  item = item->GetParent();
739 
740  int difference = targetY - i.second.GetCenter().y;
741  aCommit.Stage( item, CHT_MODIFY );
742  item->Move( wxPoint( 0, difference ) );
743  targetY += ( itemGap );
744  }
745 }
bool IsSelected() const
Definition: eda_item.h:122
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PAD, a pad in a footprint
Definition: typeinfo.h:89
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:238
virtual wxPoint GetCenter() const
This defaults to the center of the bounding box if not overridden.
Definition: board_item.h:81
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType) override
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References CHT_MODIFY, FRAME_PCB_EDITOR, BOARD_ITEM::GetCenter(), BOARD_ITEM::GetParent(), EDA_ITEM::IsSelected(), EDA_BASE_FRAME::IsType(), left, m_frame, BOARD_ITEM::Move(), PCB_PAD_T, right, BOARD_COMMIT::Stage(), and EDA_ITEM::Type().

Referenced by DistributeVertically().

◆ doDistributeGapsHorizontally()

void ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally ( ALIGNMENT_RECTS itemsToDistribute,
BOARD_COMMIT aCommit,
const BOARD_ITEM lastItem,
int  totalGap 
) const
private

Distributes selected items using an even spacing between their bounding boxes.

Note
Using the edges of bounding box of items is only possible if there is enough space between them. If this is not the case, use the center spacing method

Definition at line 557 of file placement_tool.cpp.

561 {
562  const int itemGap = totalGap / ( itemsToDistribute.size() - 1 );
563  int targetX = itemsToDistribute.begin()->second.GetX();
564 
565  for( std::pair<BOARD_ITEM*, EDA_RECT>& i : itemsToDistribute )
566  {
567  BOARD_ITEM* item = i.first;
568 
569  // cover the corner case where the last item is wider than the previous item and gap
570  if( lastItem == item )
571  continue;
572 
573  if( item->GetParent() && item->GetParent()->IsSelected() )
574  continue;
575 
576  // Don't move a pad by itself unless editing the footprint
577  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
578  item = item->GetParent();
579 
580  int difference = targetX - i.second.GetX();
581  aCommit.Stage( item, CHT_MODIFY );
582  item->Move( wxPoint( difference, 0 ) );
583  targetX += ( i.second.GetWidth() + itemGap );
584  }
585 }
bool IsSelected() const
Definition: eda_item.h:122
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PAD, a pad in a footprint
Definition: typeinfo.h:89
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:238
int GetX() const
Definition: board_item.h:64
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType) override
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References CHT_MODIFY, FRAME_PCB_EDITOR, BOARD_ITEM::GetParent(), BOARD_ITEM::GetX(), EDA_ITEM::IsSelected(), EDA_BASE_FRAME::IsType(), m_frame, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Stage(), and EDA_ITEM::Type().

Referenced by DistributeHorizontally().

◆ doDistributeGapsVertically()

void ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically ( ALIGNMENT_RECTS itemsToDistribute,
BOARD_COMMIT aCommit,
const BOARD_ITEM lastItem,
int  totalGap 
) const
private

Distributes selected items using an even spacing between their bounding boxes.

Note
Using the edges of bounding box of items is only possible if there is enough space between them. If this is not the case, use the center spacing method

Definition at line 684 of file placement_tool.cpp.

688 {
689  const int itemGap = totalGap / ( itemsToDistribute.size() - 1 );
690  int targetY = itemsToDistribute.begin()->second.GetY();
691 
692  for( std::pair<BOARD_ITEM*, EDA_RECT>& i : itemsToDistribute )
693  {
694  BOARD_ITEM* item = i.first;
695 
696  // cover the corner case where the last item is wider than the previous item and gap
697  if( lastItem == item )
698  continue;
699 
700  if( item->GetParent() && item->GetParent()->IsSelected() )
701  continue;
702 
703  // Don't move a pad by itself unless editing the footprint
704  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB_EDITOR ) )
705  item = item->GetParent();
706 
707  int difference = targetY - i.second.GetY();
708  aCommit.Stage( item, CHT_MODIFY );
709  item->Move( wxPoint( 0, difference ) );
710  targetY += ( i.second.GetHeight() + itemGap );
711  }
712 }
bool IsSelected() const
Definition: eda_item.h:122
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PAD, a pad in a footprint
Definition: typeinfo.h:89
int GetY() const
Definition: board_item.h:70
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:238
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType) override
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References CHT_MODIFY, FRAME_PCB_EDITOR, BOARD_ITEM::GetParent(), BOARD_ITEM::GetY(), EDA_ITEM::IsSelected(), EDA_BASE_FRAME::IsType(), m_frame, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Stage(), and EDA_ITEM::Type().

Referenced by DistributeVertically().

◆ getEditFrame()

template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Return the application window object, casted to requested user type.

Definition at line 184 of file tool_base.h.

185  {
186 #if !defined( QA_TEST ) // Dynamic casts give the linker a seizure in the test framework
187  wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
188 #endif
189  return static_cast<T*>( getToolHolderInt() );
190  }
TOOLS_HOLDER * getToolHolderInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 120 of file tool_base.h.

121  {
122  return m_toolId;
123  }
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209

References TOOL_BASE::m_toolId.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), TOOL_MANAGER::runTool(), TOOL_MANAGER::saveViewControls(), and TOOL_MANAGER::ShutdownTool().

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Return the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER or NULL if there is no associated tool manager.

Definition at line 143 of file tool_base.h.

144  {
145  return m_toolMgr;
146  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), LIB_TREE::onContextMenu(), ZONE_CREATE_HELPER::OnFirstPoint(), ACTION_MENU::OnMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ getModel()

template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 196 of file tool_base.h.

References TOOL_BASE::getModelInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), and ZONE_CREATE_HELPER::createZoneFromExisting().

◆ GetName()

const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Return the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

134  {
135  return m_toolName;
136  }
std::string m_toolName
Definition: tool_base.h:213

References TOOL_BASE::m_toolName.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), TOOL_MANAGER::RegisterTool(), and TOOL_MANAGER::runTool().

◆ GetSelections()

template<typename T >
size_t ALIGN_DISTRIBUTE_TOOL::GetSelections ( ALIGNMENT_RECTS aItemsToAlign,
ALIGNMENT_RECTS aLockedItems,
aCompare 
)
private

Populate two vectors with the sorted selection and sorted locked items.

Returns the size of aItemsToAlign()

Definition at line 144 of file placement_tool.cpp.

146 {
148  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
149  {
150  // Iterate from the back so we don't have to worry about removals.
151  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
152  {
153  BOARD_ITEM* item = aCollector[i];
154 
155  if( item->Type() == PCB_MARKER_T )
156  aCollector.Remove( item );
157  }
158  } );
159 
160  std::vector<BOARD_ITEM*> lockedItems;
161  std::vector<BOARD_ITEM*> itemsToAlign;
162 
163  for( EDA_ITEM* item : selection )
164  {
165  BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
166 
167  // We do not lock items in the footprint editor
168  if( boardItem->IsLocked() && m_frame->IsType( FRAME_PCB_EDITOR ) )
169  {
170  // Locking a pad but not the footprint means that we align the footprint using
171  // the pad position. So we test for footprint locking here
172  if( boardItem->Type() == PCB_PAD_T && !boardItem->GetParent()->IsLocked() )
173  {
174  itemsToAlign.push_back( boardItem );
175  }
176  else
177  {
178  lockedItems.push_back( boardItem );
179  }
180  }
181  else
182  itemsToAlign.push_back( boardItem );
183  }
184 
185  aItemsToAlign = GetBoundingBoxes( itemsToAlign );
186  aLockedItems = GetBoundingBoxes( lockedItems );
187  std::sort( aItemsToAlign.begin(), aItemsToAlign.end(), aCompare );
188  std::sort( aLockedItems.begin(), aLockedItems.end(), aCompare );
189 
190  return aItemsToAlign.size();
191 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
PCB_SELECTION_TOOL * m_selectionTool
class PAD, a pad in a footprint
Definition: typeinfo.h:89
virtual bool IsLocked() const
Definition: board_item.cpp:64
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:110
ALIGNMENT_RECTS GetBoundingBoxes(const T &aItems)
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:98
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References FRAME_PCB_EDITOR, GetBoundingBoxes(), COLLECTOR::GetCount(), BOARD_ITEM::GetParent(), BOARD_ITEM::IsLocked(), EDA_BASE_FRAME::IsType(), m_frame, m_selectionTool, PCB_MARKER_T, PCB_PAD_T, COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), and EDA_ITEM::Type().

Referenced by AlignBottom(), AlignCenterX(), AlignCenterY(), AlignTop(), doAlignLeft(), and doAlignRight().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 108 of file tool_base.h.

109  {
110  return m_type;
111  }
TOOL_TYPE m_type
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:206

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::ShutdownTool().

◆ getView()

KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Returns the instance of #VIEW object used in the application.

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

37 {
38  return m_toolMgr->GetView();
39 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_MANAGER::GetView(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCornerCondition(), AlignLeft(), AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), GERBVIEW_CONTROL::ClearAllLayers(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), ROUTER_TOOL::handleCommonEvents(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), BOARD_EDITOR_CONTROL::PlaceTarget(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), BOARD_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), PCB_SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectAll(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SCH_DRAWING_TOOLS::TwoClickPlace(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), PCB_SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updateParentItem(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), PCB_SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL().

◆ getViewControls()

KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited

Return the instance of VIEW_CONTROLS object used in the application.

It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.).

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

43 {
44  return m_toolMgr->GetViewControls();
45 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:285

References TOOL_MANAGER::GetViewControls(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), SCH_DRAWING_TOOLS::createSheetPin(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_DRAWING_TOOLS::GetCanvasFreeAreaPixels(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), PCB_POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), PCB_SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), selectTarget(), PCB_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), PL_POINT_EDITOR::setEditedPoint(), EE_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Define which state (aStateFunc) to go when a certain event arrives (aConditions).

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

149 {
150  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
151 
152  goInternal( sptr, aConditions );
153 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by AUTOPLACE_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), PCB_PICKER_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), ROUTER_TOOL::setTransitions(), SCRIPTING_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), CONVERT_TOOL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PAD_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), SCH_EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), setTransitions(), COMMON_TOOLS::setTransitions(), DRC_TOOL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCB_CONTROL::setTransitions(), CVPCB_CONTROL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ Init()

bool ALIGN_DISTRIBUTE_TOOL::Init ( )
overridevirtual

Init() is called once upon a registration of the tool.

Returns
True if the initialization went fine, false - otherwise.

Reimplemented from TOOL_BASE.

Definition at line 56 of file placement_tool.cpp.

57 {
58  // Find the selection tool, so they can cooperate
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, this );
65  m_placementMenu->SetTitle( _( "Align/Distribute" ) );
66 
67  // Add all align/distribute commands
71 
72  m_placementMenu->AppendSeparator();
76 
77  m_placementMenu->AppendSeparator();
80 
83 
84  return true;
85 }
static TOOL_ACTION alignRight
Definition: pcb_actions.h:222
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Add a submenu to the menu.
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:48
PCB_SELECTION_TOOL * m_selectionTool
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:73
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...
ACTION_MENU * m_placementMenu
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
static TOOL_ACTION alignCenterY
Definition: pcb_actions.h:224
TOOL_MENU & GetToolMenu()
static TOOL_ACTION distributeVertically
Definition: pcb_actions.h:226
static TOOL_ACTION alignBottom
Definition: pcb_actions.h:220
static TOOL_ACTION distributeHorizontally
Definition: pcb_actions.h:225
static TOOL_ACTION alignLeft
Definition: pcb_actions.h:221
#define _(s)
static TOOL_ACTION alignTop
Definition: pcb_actions.h:219
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:87
PCB_BASE_FRAME * m_frame
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
The selection tool: currently supports:
static TOOL_ACTION alignCenterX
Definition: pcb_actions.h:223

References _, ACTION_MENU::Add(), CONDITIONAL_MENU::AddMenu(), align_items, PCB_ACTIONS::alignBottom, PCB_ACTIONS::alignCenterX, PCB_ACTIONS::alignCenterY, PCB_ACTIONS::alignLeft, PCB_ACTIONS::alignRight, PCB_ACTIONS::alignTop, PCB_ACTIONS::distributeHorizontally, PCB_ACTIONS::distributeVertically, TOOL_MENU::GetMenu(), TOOL_MANAGER::GetTool(), TOOL_INTERACTIVE::GetToolMenu(), m_frame, m_placementMenu, m_selectionTool, TOOL_BASE::m_toolMgr, SELECTION_CONDITIONS::MoreThan(), ACTION_MENU::SetIcon(), and ACTION_MENU::SetTitle().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32 {
33  return m_toolMgr->IsToolActive( m_toolId );
34 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool IsToolActive(TOOL_ID aId) const
Return true if a tool with given id is active (executing)

References TOOL_MANAGER::IsToolActive(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by EDIT_TOOL::Drag(), ROUTER_TOOL::handleLayerSwitch(), EDIT_TOOL::isRouterActive(), PCB_SELECTION_TOOL::Main(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ Reset()

void ALIGN_DISTRIBUTE_TOOL::Reset ( RESET_REASON  aReason)
inlineoverridevirtual

Bring the tool to a known, initial state.

If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Implements TOOL_BASE.

Definition at line 47 of file placement_tool.h.

47 {}

◆ RunMainStack()

void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Call a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

88 {
89  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
90 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::RunMainStack().

Referenced by DRAWING_TOOL::PlaceText().

◆ selectTarget()

template<typename T >
int ALIGN_DISTRIBUTE_TOOL::selectTarget ( ALIGNMENT_RECTS aItems,
ALIGNMENT_RECTS aLocked,
aGetValue 
)
private

Definition at line 114 of file placement_tool.cpp.

116 {
117  wxPoint curPos = (wxPoint) getViewControls()->GetCursorPosition();
118 
119  // Prefer locked items to unlocked items.
120  // Secondly, prefer items under the cursor to other items.
121 
122  if( aLocked.size() >= 1 )
123  {
124  for( const ALIGNMENT_RECT& item : aLocked )
125  {
126  if( item.second.Contains( curPos ) )
127  return aGetValue( item );
128  }
129 
130  return aGetValue( aLocked.front() );
131  }
132 
133  for( const ALIGNMENT_RECT& item : aItems )
134  {
135  if( item.second.Contains( curPos ) )
136  return aGetValue( item );
137  }
138 
139  return aGetValue( aItems.front() );
140 }
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.

References KIGFX::VIEW_CONTROLS::GetCursorPosition(), and TOOL_BASE::getViewControls().

Referenced by AlignBottom(), AlignCenterX(), AlignCenterY(), AlignTop(), doAlignLeft(), and doAlignRight().

◆ SetContextMenu()

void TOOL_INTERACTIVE::SetContextMenu ( ACTION_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Assign a context menu and tells when it should be activated.

Parameters
aMenuis the menu to be assigned.
aTriggerdetermines conditions upon which the context menu is activated.

Definition at line 76 of file tool_interactive.cpp.

77 {
78  if( aMenu )
79  aMenu->SetTool( this );
80  else
81  aTrigger = CMENU_OFF;
82 
83  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
84 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void SetTool(TOOL_INTERACTIVE *aTool)
Set a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Set behavior of the tool's context popup menu.

References CMENU_OFF, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ScheduleContextMenu(), and ACTION_MENU::SetTool().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ setTransitions()

void ALIGN_DISTRIBUTE_TOOL::setTransitions ( )
overridevirtual

This method is meant to be overridden in order to specify handlers for events.

It is called every time tool is reset or finished.

Implements TOOL_INTERACTIVE.

Definition at line 748 of file placement_tool.cpp.

749 {
756 
760  PCB_ACTIONS::distributeVertically.MakeEvent() );
761 }
static TOOL_ACTION alignRight
Definition: pcb_actions.h:222
int AlignLeft(const TOOL_EVENT &aEvent)
Sets X coordinate of the selected items to the value of the left-most selected item X coordinate.
int AlignCenterY(const TOOL_EVENT &aEvent)
Set the y coordinate of the midpoint of each of the selected items to the value of the y coordinate o...
int AlignCenterX(const TOOL_EVENT &aEvent)
Set the x coordinate of the midpoint of each of the selected items to the value of the x coordinate o...
static TOOL_ACTION alignCenterY
Definition: pcb_actions.h:224
int AlignBottom(const TOOL_EVENT &aEvent)
Sets Y coordinate of the selected items to the value of the bottom-most selected item Y coordinate.
static TOOL_ACTION distributeVertically
Definition: pcb_actions.h:226
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
static TOOL_ACTION alignBottom
Definition: pcb_actions.h:220
static TOOL_ACTION distributeHorizontally
Definition: pcb_actions.h:225
int DistributeHorizontally(const TOOL_EVENT &aEvent)
Distribute the selected items along the X axis.
int AlignTop(const TOOL_EVENT &aEvent)
Set Y coordinate of the selected items to the value of the top-most selected item Y coordinate.
int DistributeVertically(const TOOL_EVENT &aEvent)
Distribute the selected items along the Y axis.
static TOOL_ACTION alignLeft
Definition: pcb_actions.h:221
static TOOL_ACTION alignTop
Definition: pcb_actions.h:219
int AlignRight(const TOOL_EVENT &aEvent)
Sets X coordinate of the selected items to the value of the right-most selected item X coordinate.
static TOOL_ACTION alignCenterX
Definition: pcb_actions.h:223

References AlignBottom(), PCB_ACTIONS::alignBottom, AlignCenterX(), PCB_ACTIONS::alignCenterX, AlignCenterY(), PCB_ACTIONS::alignCenterY, AlignLeft(), PCB_ACTIONS::alignLeft, AlignRight(), PCB_ACTIONS::alignRight, AlignTop(), PCB_ACTIONS::alignTop, DistributeHorizontally(), PCB_ACTIONS::distributeHorizontally, DistributeVertically(), PCB_ACTIONS::distributeVertically, and TOOL_INTERACTIVE::Go().

◆ Wait()

TOOL_EVENT * TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Suspend execution of the tool until an event specified in aEventList arrives.

No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

58 {
59  return m_toolMgr->ScheduleWait( this, aEventList );
60 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_EVENT * ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pause execution of a given tool until one or more events matching aConditions arrives.

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::ScheduleWait().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), ZOOM_TOOL::Main(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), CVPCB_CONTROL::Main(), PL_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_frame

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

The functions below are not yet implemented - their interface may change.

Definition at line 125 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), ROUTER_TOOL::Init(), LENGTH_TUNER_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), PL_DRAWING_TOOLS::Init(), SYMBOL_EDITOR_DRAWING_TOOLS::Init(), SYMBOL_EDITOR_CONTROL::Init(), PCB_VIEWER_TOOLS::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), PL_SELECTION_TOOL::Init(), SCH_DRAWING_TOOLS::Init(), BOARD_EDITOR_CONTROL::Init(), GERBVIEW_SELECTION_TOOL::Init(), EDA_3D_CONTROLLER::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), PCB_SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), PCB_TOOL_BASE::Init(), PICKER_TOOL::Init(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_PICKER_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PL_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_placementMenu

ACTION_MENU* ALIGN_DISTRIBUTE_TOOL::m_placementMenu
private

Definition at line 173 of file placement_tool.h.

Referenced by Init(), and ~ALIGN_DISTRIBUTE_TOOL().

◆ m_selectionTool

PCB_SELECTION_TOOL* ALIGN_DISTRIBUTE_TOOL::m_selectionTool
private

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName (eg. pcbnew.InteractiveSelection).

Definition at line 209 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::GetId(), and TOOL_BASE::IsToolActive().

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 214 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), PCB_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SCH_MOVE_TOOL::AlignElements(), SCH_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), SCH_EDIT_TOOL::BreakWire(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_CONTROL::ClearAllLayers(), BOARD_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), PL_SELECTION_TOOL::ClearSelection(), PCB_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), PL_EDIT_TOOL::Copy(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), MICROWAVE_TOOL::createInductorBetween(), DRC_TOOL::CrossProbe(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), SYMBOL_EDITOR_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), BOARD_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::Drag(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties(), SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), PCB_SELECTION_TOOL::filterSelection(), PCB_SELECTION_TOOL::FindItem(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), PCB_CONTROL::GridSetOrigin(), GROUP_TOOL::Group(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::HighlightItem(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PL_EDIT_TOOL::ImportDrawingSheetContent(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), BOARD_REANNOTATE_TOOL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), GROUP_TOOL::Init(), PAD_TOOL::Init(), CONVERT_TOOL::Init(), PL_DRAWING_TOOLS::Init(), GLOBAL_EDIT_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), PL_POINT_EDITOR::Init(), BOARD_INSPECTION_TOOL::Init(), Init(), PCB_POINT_EDITOR::Init(), BOARD_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isRouterActive(), TOOL_BASE::IsToolActive(), GROUP_TOOL::LeaveGroup(), SCH_NAVIGATE_TOOL::LeaveSheet(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), CVPCB_CONTROL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), SYMBOL_EDITOR_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), SYMBOL_EDITOR_CONTROL::OnDeMorgan(), PL_SELECTION_TOOL::onDisambiguationExpire(), EE_SELECTION_TOOL::onDisambiguationExpire(), PCB_SELECTION_TOOL::onDisambiguationExpire(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), PL_EDIT_TOOL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performRouting(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_EDIT_TOOL::PinTable(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_CONTROL::Print(), GERBVIEW_CONTROL::Print(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), SYMBOL_EDITOR_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), PCB_SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), PCB_SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), SYMBOL_EDITOR_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), EE_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), PCB_SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_SELECTION_TOOL::selectSameSheet(), PCB_SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), EDA_3D_CONTROLLER::SetMaterial(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), EDA_3D_CONTROLLER::ToggleVisibility(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GROUP_TOOL::Ungroup(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), PCB_SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCB_CONTROL::UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), EE_POINT_EDITOR::updateParentItem(), BOARD_INSPECTION_TOOL::UpdateSelectionRatsnest(), PNS::TOOL_BASE::updateStartItem(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), and BOARD_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Definition at line 213 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

Definition at line 206 of file tool_base.h.

Referenced by TOOL_BASE::GetType(), and BOARD_COMMIT::Push().


The documentation for this class was generated from the following files: