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 }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 ALIGN_DISTRIBUTE_TOOL ()
 
virtual ~ALIGN_DISTRIBUTE_TOOL ()
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
int AlignTop (const TOOL_EVENT &aEvent)
 Function AlignTop() Sets Y coordinate of the selected items to the value of the top-most selected item Y coordinate. More...
 
int AlignBottom (const TOOL_EVENT &aEvent)
 Function AlignBottom() 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)
 Function AlignLeft() 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)
 Function AlignRight() 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)
 Function AlignCenterX() Sets 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)
 Function AlignCenterX() Sets 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)
 Function DistributeHorizontally() Distributes the selected items along the X axis. More...
 
int DistributeVertically (const TOOL_EVENT &aEvent)
 Function DistributeVertically() Distributes the selected items along the Y axis. More...
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 
void Activate ()
 Function Activate() Runs the tool. More...
 
void SetContextMenu (CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
OPT_TOOL_EVENT Wait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Protected Member Functions

const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

template<typename T >
size_t GetSelections (ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aCompare)
 Function GetSelections() Populates two vectors with the sorted selection and sorted locked items Returns the size of aItems() 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 ()
 Aligns selected items using the right edge of their bounding boxes to the right-most item. More...
 
int checkLockedStatus (const SELECTION &selection) const
 Check a selection to ensure locks are valid for alignment. More...
 
void doDistributeCentersHorizontally (ALIGNMENT_RECTS &itemsToDistribute) const
 Distributes selected items using an even spacing between the centers of their bounding boxes. More...
 
void doDistributeCentersVertically (ALIGNMENT_RECTS &itemsToDistribute) const
 Distributes selected items using an even spacing between the centers of their bounding boxes. More...
 
void doDistributeGapsHorizontally (ALIGNMENT_RECTS &itemsToDistribute, const BOARD_ITEM *lastItem, int totalGap) const
 Distributes selected items using an even spacing between their bounding boxes. More...
 
void doDistributeGapsVertically (ALIGNMENT_RECTS &itemsToDistribute, const BOARD_ITEM *lastItem, int totalGap) const
 Distributes selected items using an even spacing between their bounding boxes. More...
 

Private Attributes

SELECTION_TOOLm_selectionTool
 
CONTEXT_MENUm_placementMenu
 
PCB_BASE_FRAMEm_frame
 

Detailed Description

Definition at line 37 of file placement_tool.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determines 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 80 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ ALIGN_DISTRIBUTE_TOOL()

ALIGN_DISTRIBUTE_TOOL::ALIGN_DISTRIBUTE_TOOL ( )

Definition at line 82 of file placement_tool.cpp.

82  :
83  TOOL_INTERACTIVE( "pcbnew.Placement" ), m_selectionTool( NULL ), m_placementMenu( NULL ),
84  m_frame( NULL )
85 {
86 }
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Constructor.
CONTEXT_MENU * m_placementMenu
PCB_BASE_FRAME * m_frame
SELECTION_TOOL * m_selectionTool

◆ ~ALIGN_DISTRIBUTE_TOOL()

ALIGN_DISTRIBUTE_TOOL::~ALIGN_DISTRIBUTE_TOOL ( )
virtual

Definition at line 88 of file placement_tool.cpp.

89 {
90  delete m_placementMenu;
91 }
CONTEXT_MENU * m_placementMenu

References m_placementMenu.

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 49 of file tool_interactive.cpp.

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls 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(), PCBNEW_CONTROL::DeleteItemCursor(), EDIT_TOOL::doCopyToClipboard(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

◆ AlignBottom()

int ALIGN_DISTRIBUTE_TOOL::AlignBottom ( const TOOL_EVENT aEvent)

Function AlignBottom() Sets Y coordinate of the selected items to the value of the bottom-most selected item Y coordinate.

Definition at line 245 of file placement_tool.cpp.

246 {
247  ALIGNMENT_RECTS itemsToAlign;
248  ALIGNMENT_RECTS locked_items;
249 
250  if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
251  { return ( left.second.GetBottom() < right.second.GetBottom() ); } ) )
252  return 0;
253 
254  BOARD_COMMIT commit( m_frame );
255  commit.StageItems( m_selectionTool->GetSelection(), CHT_MODIFY );
256  auto targetBottom = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
257  { return aVal.second.GetBottom(); } );
258 
259  // Move the selected items
260  for( auto& i : itemsToAlign )
261  {
262  int difference = targetBottom - i.second.GetBottom();
263  BOARD_ITEM* item = i.first;
264 
265  // Don't move a pad by itself unless editing the footprint
266  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB ) )
267  item = item->GetParent();
268 
269  item->Move( wxPoint( 0, difference ) );
270  }
271 
272  commit.Push( _( "Align to bottom" ) );
273 
274  return 0;
275 }
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
SELECTION & GetSelection()
Function GetSelection()
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...
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
size_t i
Definition: json11.cpp:597
SELECTION_TOOL * m_selectionTool
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References CHT_MODIFY, FRAME_PCB, BOARD_ITEM::GetParent(), SELECTION_TOOL::GetSelection(), GetSelections(), i, EDA_BASE_FRAME::IsType(), m_frame, m_selectionTool, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Push(), selectTarget(), COMMIT::StageItems(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ AlignCenterX()

int ALIGN_DISTRIBUTE_TOOL::AlignCenterX ( const TOOL_EVENT aEvent)

Function AlignCenterX() Sets 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 374 of file placement_tool.cpp.

375 {
376  ALIGNMENT_RECTS itemsToAlign;
377  ALIGNMENT_RECTS locked_items;
378 
379  if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
380  { return ( left.second.GetCenter().x < right.second.GetCenter().x ); } ) )
381  return 0;
382 
383  BOARD_COMMIT commit( m_frame );
384  commit.StageItems( m_selectionTool->GetSelection(), CHT_MODIFY );
385  auto targetX = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
386  { return aVal.second.GetCenter().x; } );
387 
388  // Move the selected items
389  for( auto& i : itemsToAlign )
390  {
391  int difference = targetX - i.second.GetCenter().x;
392  BOARD_ITEM* item = i.first;
393 
394  // Don't move a pad by itself unless editing the footprint
395  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB ) )
396  item = item->GetParent();
397 
398  item->Move( wxPoint( difference, 0 ) );
399  }
400 
401  commit.Push( _( "Align to middle" ) );
402 
403  return 0;
404 }
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
SELECTION & GetSelection()
Function GetSelection()
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...
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
size_t i
Definition: json11.cpp:597
SELECTION_TOOL * m_selectionTool
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References CHT_MODIFY, FRAME_PCB, BOARD_ITEM::GetParent(), SELECTION_TOOL::GetSelection(), GetSelections(), i, EDA_BASE_FRAME::IsType(), m_frame, m_selectionTool, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Push(), selectTarget(), COMMIT::StageItems(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ AlignCenterY()

int ALIGN_DISTRIBUTE_TOOL::AlignCenterY ( const TOOL_EVENT aEvent)

Function AlignCenterX() Sets 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 407 of file placement_tool.cpp.

408 {
409  ALIGNMENT_RECTS itemsToAlign;
410  ALIGNMENT_RECTS locked_items;
411 
412  if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
413  { return ( left.second.GetCenter().y < right.second.GetCenter().y ); } ) )
414  return 0;
415 
416  BOARD_COMMIT commit( m_frame );
417  commit.StageItems( m_selectionTool->GetSelection(), CHT_MODIFY );
418  auto targetY = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
419  { return aVal.second.GetCenter().y; } );
420 
421  // Move the selected items
422  for( auto& i : itemsToAlign )
423  {
424  int difference = targetY - i.second.GetCenter().y;
425  BOARD_ITEM* item = i.first;
426 
427  // Don't move a pad by itself unless editing the footprint
428  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB ) )
429  item = item->GetParent();
430 
431  item->Move( wxPoint( 0, difference ) );
432  }
433 
434  commit.Push( _( "Align to center" ) );
435 
436  return 0;
437 }
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
SELECTION & GetSelection()
Function GetSelection()
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...
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
size_t i
Definition: json11.cpp:597
SELECTION_TOOL * m_selectionTool
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References CHT_MODIFY, FRAME_PCB, BOARD_ITEM::GetParent(), SELECTION_TOOL::GetSelection(), GetSelections(), i, EDA_BASE_FRAME::IsType(), m_frame, m_selectionTool, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Push(), selectTarget(), COMMIT::StageItems(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ AlignLeft()

int ALIGN_DISTRIBUTE_TOOL::AlignLeft ( const TOOL_EVENT aEvent)

Function AlignLeft() Sets X coordinate of the selected items to the value of the left-most selected item X coordinate.

Definition at line 278 of file placement_tool.cpp.

279 {
280  // Because this tool uses bounding boxes and they aren't mirrored even when
281  // the view is mirrored, we need to call the other one if mirrored.
282  if( getView()->IsMirroredX() )
283  {
284  return doAlignRight();
285  }
286  else
287  {
288  return doAlignLeft();
289  }
290 }
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.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35

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

Referenced by setTransitions().

◆ AlignRight()

int ALIGN_DISTRIBUTE_TOOL::AlignRight ( const TOOL_EVENT aEvent)

Function AlignRight() Sets X coordinate of the selected items to the value of the right-most selected item X coordinate.

Definition at line 326 of file placement_tool.cpp.

327 {
328  // Because this tool uses bounding boxes and they aren't mirrored even when
329  // the view is mirrored, we need to call the other one if mirrored.
330  if( getView()->IsMirroredX() )
331  {
332  return doAlignLeft();
333  }
334  else
335  {
336  return doAlignRight();
337  }
338 }
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.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35

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

Referenced by setTransitions().

◆ AlignTop()

int ALIGN_DISTRIBUTE_TOOL::AlignTop ( const TOOL_EVENT aEvent)

Function AlignTop() Sets Y coordinate of the selected items to the value of the top-most selected item Y coordinate.

Definition at line 212 of file placement_tool.cpp.

213 {
214  ALIGNMENT_RECTS itemsToAlign;
215  ALIGNMENT_RECTS locked_items;
216 
217  if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
218  { return ( left.second.GetTop() < right.second.GetTop() ); } ) )
219  return 0;
220 
221  BOARD_COMMIT commit( m_frame );
222  commit.StageItems( m_selectionTool->GetSelection(), CHT_MODIFY );
223  auto targetTop = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
224  { return aVal.second.GetTop(); } );
225 
226  // Move the selected items
227  for( auto& i : itemsToAlign )
228  {
229  int difference = targetTop - i.second.GetTop();
230  BOARD_ITEM* item = i.first;
231 
232  // Don't move a pad by itself unless editing the footprint
233  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB ) )
234  item = item->GetParent();
235 
236  item->Move( wxPoint( 0, difference ) );
237  }
238 
239  commit.Push( _( "Align to top" ) );
240 
241  return 0;
242 }
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
SELECTION & GetSelection()
Function GetSelection()
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...
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
size_t i
Definition: json11.cpp:597
SELECTION_TOOL * m_selectionTool
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References CHT_MODIFY, FRAME_PCB, BOARD_ITEM::GetParent(), SELECTION_TOOL::GetSelection(), GetSelections(), i, EDA_BASE_FRAME::IsType(), m_frame, m_selectionTool, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Push(), selectTarget(), COMMIT::StageItems(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

Sets the TOOL_MANAGER the tool will belong to. Called by TOOL_MANAGER::RegisterTool()

Definition at line 59 of file tool_base.cpp.

60 {
61  m_toolMgr = aManager;
62  m_toolSettings = TOOL_SETTINGS( this );
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
friend class TOOL_SETTINGS
Definition: tool_base.h:155

References TOOL_BASE::m_toolMgr, TOOL_BASE::m_toolSettings, and TOOL_BASE::TOOL_SETTINGS.

Referenced by TOOL_MANAGER::RegisterTool().

◆ checkLockedStatus()

int ALIGN_DISTRIBUTE_TOOL::checkLockedStatus ( const SELECTION selection) const
private

Check a selection to ensure locks are valid for alignment.

This is slightly different from the standard lock checking in that we ignore the lock of the first element in the selection as this is meant to be our anchor. We also check the lock of a pad's parent as we will not move pads independently of the parent module

◆ DistributeHorizontally()

int ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally ( const TOOL_EVENT aEvent)

Function DistributeHorizontally() Distributes the selected items along the X axis.

Definition at line 440 of file placement_tool.cpp.

441 {
443  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
445 
446  if( selection.Size() <= 1 )
447  return 0;
448 
449  BOARD_COMMIT commit( m_frame );
450  commit.StageItems( selection, CHT_MODIFY );
451 
452  auto itemsToDistribute = GetBoundingBoxes( selection );
453 
454  // find the last item by reverse sorting
455  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
456  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
457  { return ( left.second.GetRight() > right.second.GetRight() ); } );
458  const auto lastItem = itemsToDistribute.begin()->first;
459 
460  const auto maxRight = itemsToDistribute.begin()->second.GetRight();
461 
462  // sort to get starting order
463  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
464  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
465  { return ( left.second.GetX() < right.second.GetX() ); } );
466  const auto minX = itemsToDistribute.begin()->second.GetX();
467  auto totalGap = maxRight - minX;
468  int totalWidth = 0;
469 
470  for( auto& i : itemsToDistribute )
471  {
472  totalWidth += i.second.GetWidth();
473  }
474 
475  if( totalGap < totalWidth )
476  {
477  // the width of the items exceeds the gap (overlapping items) -> use center point spacing
478  doDistributeCentersHorizontally( itemsToDistribute );
479  }
480  else
481  {
482  totalGap -= totalWidth;
483  doDistributeGapsHorizontally( itemsToDistribute, lastItem, totalGap );
484  }
485 
486  commit.Push( _( "Distribute horizontally" ) );
487 
488  return 0;
489 }
void doDistributeGapsHorizontally(ALIGNMENT_RECTS &itemsToDistribute, const BOARD_ITEM *lastItem, int totalGap) const
Distributes selected items using an even spacing between their bounding boxes.
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
ALIGNMENT_RECTS GetBoundingBoxes(const T &sel)
void doDistributeCentersHorizontally(ALIGNMENT_RECTS &itemsToDistribute) const
Distributes selected items using an even spacing between the centers of their bounding boxes.
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:48
PCB_BASE_FRAME * m_frame
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:245
size_t i
Definition: json11.cpp:597
int Size() const
Returns the number of selected parts.
Definition: selection.h:122
SELECTION_TOOL * m_selectionTool
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:46
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173

References CHT_MODIFY, doDistributeCentersHorizontally(), doDistributeGapsHorizontally(), EditToolSelectionFilter(), EXCLUDE_LOCKED, EXCLUDE_TRANSIENTS, GetBoundingBoxes(), i, m_frame, m_selectionTool, BOARD_COMMIT::Push(), SELECTION_TOOL::RequestSelection(), SELECTION::Size(), and COMMIT::StageItems().

Referenced by setTransitions().

◆ DistributeVertically()

int ALIGN_DISTRIBUTE_TOOL::DistributeVertically ( const TOOL_EVENT aEvent)

Function DistributeVertically() Distributes the selected items along the Y axis.

Definition at line 542 of file placement_tool.cpp.

543 {
545  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
547 
548  if( selection.Size() <= 1 )
549  return 0;
550 
551  BOARD_COMMIT commit( m_frame );
552  commit.StageItems( selection, CHT_MODIFY );
553 
554  auto itemsToDistribute = GetBoundingBoxes( selection );
555 
556  // find the last item by reverse sorting
557  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
558  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
559  { return ( left.second.GetBottom() > right.second.GetBottom() ); } );
560  const auto maxBottom = itemsToDistribute.begin()->second.GetBottom();
561  const auto lastItem = itemsToDistribute.begin()->first;
562 
563  // sort to get starting order
564  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
565  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
566  { return ( left.second.GetCenter().y < right.second.GetCenter().y ); } );
567  auto minY = itemsToDistribute.begin()->second.GetY();
568 
569  auto totalGap = maxBottom - minY;
570  int totalHeight = 0;
571 
572  for( auto& i : itemsToDistribute )
573  {
574  totalHeight += i.second.GetHeight();
575  }
576 
577  if( totalGap < totalHeight )
578  {
579  // the width of the items exceeds the gap (overlapping items) -> use center point spacing
580  doDistributeCentersVertically( itemsToDistribute );
581  }
582  else
583  {
584  totalGap -= totalHeight;
585  doDistributeGapsVertically( itemsToDistribute, lastItem, totalGap );
586  }
587 
588  commit.Push( _( "Distribute vertically" ) );
589 
590  return 0;
591 }
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
void doDistributeCentersVertically(ALIGNMENT_RECTS &itemsToDistribute) const
Distributes selected items using an even spacing between the centers of their bounding boxes.
ALIGNMENT_RECTS GetBoundingBoxes(const T &sel)
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:48
PCB_BASE_FRAME * m_frame
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:245
size_t i
Definition: json11.cpp:597
int Size() const
Returns the number of selected parts.
Definition: selection.h:122
void doDistributeGapsVertically(ALIGNMENT_RECTS &itemsToDistribute, const BOARD_ITEM *lastItem, int totalGap) const
Distributes selected items using an even spacing between their bounding boxes.
SELECTION_TOOL * m_selectionTool
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:46
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173

References CHT_MODIFY, doDistributeCentersVertically(), doDistributeGapsVertically(), EditToolSelectionFilter(), EXCLUDE_LOCKED, EXCLUDE_TRANSIENTS, GetBoundingBoxes(), i, m_frame, m_selectionTool, BOARD_COMMIT::Push(), SELECTION_TOOL::RequestSelection(), SELECTION::Size(), and COMMIT::StageItems().

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 293 of file placement_tool.cpp.

294 {
295  ALIGNMENT_RECTS itemsToAlign;
296  ALIGNMENT_RECTS locked_items;
297 
298  if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
299  { return ( left.second.GetLeft() < right.second.GetLeft() ); } ) )
300  return 0;
301 
302  BOARD_COMMIT commit( m_frame );
303  commit.StageItems( m_selectionTool->GetSelection(), CHT_MODIFY );
304  auto targetLeft = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
305  { return aVal.second.GetLeft(); } );
306 
307  // Move the selected items
308  for( auto& i : itemsToAlign )
309  {
310  int difference = targetLeft - i.second.GetLeft();
311  BOARD_ITEM* item = i.first;
312 
313  // Don't move a pad by itself unless editing the footprint
314  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB ) )
315  item = item->GetParent();
316 
317  item->Move( wxPoint( difference, 0 ) );
318  }
319 
320  commit.Push( _( "Align to left" ) );
321 
322  return 0;
323 }
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
SELECTION & GetSelection()
Function GetSelection()
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...
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
size_t i
Definition: json11.cpp:597
SELECTION_TOOL * m_selectionTool
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References CHT_MODIFY, FRAME_PCB, BOARD_ITEM::GetParent(), SELECTION_TOOL::GetSelection(), GetSelections(), i, EDA_BASE_FRAME::IsType(), m_frame, m_selectionTool, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Push(), selectTarget(), COMMIT::StageItems(), and EDA_ITEM::Type().

Referenced by AlignLeft(), and AlignRight().

◆ doAlignRight()

int ALIGN_DISTRIBUTE_TOOL::doAlignRight ( )
private

Aligns 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 341 of file placement_tool.cpp.

342 {
343  ALIGNMENT_RECTS itemsToAlign;
344  ALIGNMENT_RECTS locked_items;
345 
346  if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
347  { return ( left.second.GetRight() < right.second.GetRight() ); } ) )
348  return 0;
349 
350  BOARD_COMMIT commit( m_frame );
351  commit.StageItems( m_selectionTool->GetSelection(), CHT_MODIFY );
352  auto targetRight = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
353  { return aVal.second.GetRight(); } );
354 
355  // Move the selected items
356  for( auto& i : itemsToAlign )
357  {
358  int difference = targetRight - i.second.GetRight();
359  BOARD_ITEM* item = i.first;
360 
361  // Don't move a pad by itself unless editing the footprint
362  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB ) )
363  item = item->GetParent();
364 
365  item->Move( wxPoint( difference, 0 ) );
366  }
367 
368  commit.Push( _( "Align to right" ) );
369 
370  return 0;
371 }
int selectTarget(ALIGNMENT_RECTS &aItems, ALIGNMENT_RECTS &aLocked, T aGetValue)
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
std::vector< ALIGNMENT_RECT > ALIGNMENT_RECTS
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
SELECTION & GetSelection()
Function GetSelection()
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...
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
size_t i
Definition: json11.cpp:597
SELECTION_TOOL * m_selectionTool
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References CHT_MODIFY, FRAME_PCB, BOARD_ITEM::GetParent(), SELECTION_TOOL::GetSelection(), GetSelections(), i, EDA_BASE_FRAME::IsType(), m_frame, m_selectionTool, BOARD_ITEM::Move(), PCB_PAD_T, BOARD_COMMIT::Push(), selectTarget(), COMMIT::StageItems(), and EDA_ITEM::Type().

Referenced by AlignLeft(), and AlignRight().

◆ doDistributeCentersHorizontally()

void ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally ( ALIGNMENT_RECTS itemsToDistribute) const
private

Distributes 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 517 of file placement_tool.cpp.

518 {
519  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
520  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
521  { return ( left.second.GetCenter().x < right.second.GetCenter().x ); } );
522  const auto totalGap = ( itemsToDistribute.end()-1 )->second.GetCenter().x
523  - itemsToDistribute.begin()->second.GetCenter().x;
524  const auto itemGap = totalGap / ( itemsToDistribute.size() - 1 );
525  auto targetX = itemsToDistribute.begin()->second.GetCenter().x;
526 
527  for( auto& i : itemsToDistribute )
528  {
529  BOARD_ITEM* item = i.first;
530 
531  // Don't move a pad by itself unless editing the footprint
532  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB ) )
533  item = item->GetParent();
534 
535  int difference = targetX - i.second.GetCenter().x;
536  item->Move( wxPoint( difference, 0 ) );
537  targetX += ( itemGap );
538  }
539 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
size_t i
Definition: json11.cpp:597
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References FRAME_PCB, BOARD_ITEM::GetParent(), i, EDA_BASE_FRAME::IsType(), m_frame, BOARD_ITEM::Move(), PCB_PAD_T, and EDA_ITEM::Type().

Referenced by DistributeHorizontally().

◆ doDistributeCentersVertically()

void ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically ( ALIGNMENT_RECTS itemsToDistribute) const
private

Distributes 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 619 of file placement_tool.cpp.

620 {
621  std::sort( itemsToDistribute.begin(), itemsToDistribute.end(),
622  [] ( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
623  { return ( left.second.GetCenter().y < right.second.GetCenter().y ); } );
624  const auto totalGap = ( itemsToDistribute.end()-1 )->second.GetCenter().y
625  - itemsToDistribute.begin()->second.GetCenter().y;
626  const auto itemGap = totalGap / ( itemsToDistribute.size() - 1 );
627  auto targetY = itemsToDistribute.begin()->second.GetCenter().y;
628 
629  for( auto& i : itemsToDistribute )
630  {
631  BOARD_ITEM* item = i.first;
632 
633  // Don't move a pad by itself unless editing the footprint
634  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB ) )
635  item = item->GetParent();
636 
637  int difference = targetY - i.second.GetCenter().y;
638  item->Move( wxPoint( 0, difference ) );
639  targetY += ( itemGap );
640  }
641 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
std::pair< BOARD_ITEM *, EDA_RECT > ALIGNMENT_RECT
size_t i
Definition: json11.cpp:597
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References FRAME_PCB, BOARD_ITEM::GetParent(), i, EDA_BASE_FRAME::IsType(), m_frame, BOARD_ITEM::Move(), PCB_PAD_T, and EDA_ITEM::Type().

Referenced by DistributeVertically().

◆ doDistributeGapsHorizontally()

void ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally ( ALIGNMENT_RECTS itemsToDistribute,
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 492 of file placement_tool.cpp.

494 {
495  const auto itemGap = totalGap / ( itemsToDistribute.size() - 1 );
496  auto targetX = itemsToDistribute.begin()->second.GetX();
497 
498  for( auto& i : itemsToDistribute )
499  {
500  BOARD_ITEM* item = i.first;
501 
502  // cover the corner case where the last item is wider than the previous item and gap
503  if( lastItem == item )
504  continue;
505 
506  // Don't move a pad by itself unless editing the footprint
507  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB ) )
508  item = item->GetParent();
509 
510  int difference = targetX - i.second.GetX();
511  item->Move( wxPoint( difference, 0 ) );
512  targetX += ( i.second.GetWidth() + itemGap );
513  }
514 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
size_t i
Definition: json11.cpp:597
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References FRAME_PCB, BOARD_ITEM::GetParent(), i, EDA_BASE_FRAME::IsType(), m_frame, BOARD_ITEM::Move(), PCB_PAD_T, and EDA_ITEM::Type().

Referenced by DistributeHorizontally().

◆ doDistributeGapsVertically()

void ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically ( ALIGNMENT_RECTS itemsToDistribute,
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 594 of file placement_tool.cpp.

596 {
597  const auto itemGap = totalGap / ( itemsToDistribute.size() - 1 );
598  auto targetY = itemsToDistribute.begin()->second.GetY();
599 
600  for( auto& i : itemsToDistribute )
601  {
602  BOARD_ITEM* item = i.first;
603 
604  // cover the corner case where the last item is wider than the previous item and gap
605  if( lastItem == item )
606  continue;
607 
608  // Don't move a pad by itself unless editing the footprint
609  if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB ) )
610  item = item->GetParent();
611 
612  int difference = targetY - i.second.GetY();
613  i.first->Move( wxPoint( 0, difference ) );
614  targetY += ( i.second.GetHeight() + itemGap );
615  }
616 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
PCB_BASE_FRAME * m_frame
bool IsType(FRAME_T aType) const
size_t i
Definition: json11.cpp:597
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References FRAME_PCB, BOARD_ITEM::GetParent(), i, EDA_BASE_FRAME::IsType(), m_frame, PCB_PAD_T, and EDA_ITEM::Type().

Referenced by DistributeVertically().

◆ evActivate()

const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

◆ evButtonDown()

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited

◆ evButtonUp()

const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited

◆ evClick()

const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited

◆ evCommand() [1/2]

const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited

◆ evCommand() [2/2]

const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited

◆ evDrag()

const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited

◆ evMotion()

const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited

◆ getEditFrame()

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

Function getEditFrame()

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

Definition at line 188 of file tool_base.h.

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47

References TOOL_BASE::getEditFrameInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), and TOOL_SETTINGS::getConfigBase().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Function GetId() Returns the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

123  {
124  return m_toolId;
125  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210

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(), and TOOL_MANAGER::saveViewControls().

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER. If there is no TOOL_MANAGER associated, it returns NULL.

Definition at line 144 of file tool_base.h.

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL::doInteractiveItemPlacement(), CONTEXT_MENU::getToolManager(), CONTEXT_MENU::onMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ getModel()

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 199 of file tool_base.h.

200  {
201  EDA_ITEM* m = getModelInt();
202 
203  return static_cast<T*>( m );
204  }
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:53
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Function GetName() Returns 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
Name of the tool.
Definition: tool_base.h:214

References TOOL_BASE::m_toolName.

Referenced by TOOL_SETTINGS::getKeyName(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), and TOOL_MANAGER::RegisterTool().

◆ GetSelections()

template<typename T >
size_t ALIGN_DISTRIBUTE_TOOL::GetSelections ( ALIGNMENT_RECTS aItems,
ALIGNMENT_RECTS aLocked,
aCompare 
)
private

Function GetSelections() Populates two vectors with the sorted selection and sorted locked items Returns the size of aItems()

Definition at line 188 of file placement_tool.cpp.

189 {
190 
192  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
193  { EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } );
194 
195  if( selection.Size() <= 1 )
196  return 0;
197 
198  std::vector<BOARD_ITEM*> lockedItems;
199  selection = m_selectionTool->RequestSelection(
200  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
201  { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED ); }, &lockedItems );
202 
203  aItems = GetBoundingBoxes( selection );
204  aLocked = GetBoundingBoxes( lockedItems );
205  std::sort( aItems.begin(), aItems.end(), aCompare );
206  std::sort( aLocked.begin(), aLocked.end(), aCompare );
207 
208  return aItems.size();
209 }
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
ALIGNMENT_RECTS GetBoundingBoxes(const T &sel)
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:48
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:245
int Size() const
Returns the number of selected parts.
Definition: selection.h:122
SELECTION_TOOL * m_selectionTool
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:46
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173

References EditToolSelectionFilter(), EXCLUDE_LOCKED, EXCLUDE_TRANSIENTS, GetBoundingBoxes(), m_selectionTool, SELECTION_TOOL::RequestSelection(), and SELECTION::Size().

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

◆ GetSettings()

TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216

References TOOL_BASE::m_toolSettings.

Referenced by ROUTER_TOOL::Init(), GERBVIEW_SELECTION_TOOL::selectable(), and ROUTER_TOOL::~ROUTER_TOOL().

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:207

References TOOL_BASE::m_type.

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

◆ getView()

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

Function getView()

Returns the instance of VIEW object used in the application. It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 35 of file tool_base.cpp.

36 {
37  return m_toolMgr->GetView();
38 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

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

Referenced by AlignLeft(), AlignRight(), COMMON_TOOLS::CenterContents(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), DRAWING_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), POINT_EDITOR::updateEditedPoint(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_TOOL::view(), COMMON_TOOLS::ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), CVPCB_SELECTION_TOOL::~CVPCB_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

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

Function getViewControls()

Returns 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 41 of file tool_base.cpp.

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257

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

Referenced by POINT_EDITOR::addCorner(), PCB_TOOL::controls(), COMMON_TOOLS::CursorControl(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), CVPCB_CONTROL::ResetCoords(), GERBVIEW_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), selectTarget(), PICKER_TOOL::setControls(), POINT_EDITOR::setEditedPoint(), 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

◆ Init()

bool ALIGN_DISTRIBUTE_TOOL::Init ( )
overridevirtual

Function Init() 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 94 of file placement_tool.cpp.

95 {
96  // Find the selection tool, so they can cooperate
97  m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
98 
99  if( !m_selectionTool )
100  {
101  DisplayError( NULL, _( "pcbnew.InteractiveSelection tool is not available" ) );
102  return false;
103  }
104 
105  m_frame = getEditFrame<PCB_BASE_FRAME>();
106 
107  // Create a context menu and make it available through selection tool
109  m_placementMenu->SetIcon( align_items_xpm );
110  m_placementMenu->SetTitle( _( "Align/Distribute" ) );
111 
112  // Add all align/distribute commands
119  m_placementMenu->AppendSeparator();
122 
125 
126  return true;
127 }
static TOOL_ACTION alignRight
Align items to the right edge of selection bounding box.
Definition: pcb_actions.h:243
static SELECTION_CONDITION MoreThan(int aNumber)
Function MoreThan Creates a functor that tests if the number of selected items is greater than the va...
Class CONTEXT_MENU.
Definition: context_menu.h:44
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:49
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
static TOOL_ACTION alignCenterY
Align items to the center of selection bounding box.
Definition: pcb_actions.h:249
static TOOL_ACTION distributeVertically
Distributes items evenly along the vertical axis.
Definition: pcb_actions.h:255
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
CONTEXT_MENU * m_placementMenu
static TOOL_ACTION alignBottom
Align items to the bottom edge of selection bounding box.
Definition: pcb_actions.h:237
wxMenuItem * Add(const wxString &aLabel, int aId, const BITMAP_OPAQUE *aIcon=NULL)
Function Add() Adds an entry to the menu.
static TOOL_ACTION distributeHorizontally
Distributes items evenly along the horizontal axis.
Definition: pcb_actions.h:252
static TOOL_ACTION alignLeft
Align items to the left edge of selection bounding box.
Definition: pcb_actions.h:240
static TOOL_ACTION alignTop
Align items to the top edge of selection bounding box.
Definition: pcb_actions.h:234
void SetIcon(const BITMAP_OPAQUE *aIcon)
Function SetIcon() Assigns an icon for the entry.
PCB_BASE_FRAME * m_frame
void AddMenu(CONTEXT_MENU *aMenu, bool aExpand=false, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the context menu.
SELECTION_TOOL * m_selectionTool
static TOOL_ACTION alignCenterX
Align items to the middle of selection bounding box.
Definition: pcb_actions.h:246
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:243

References CONTEXT_MENU::Add(), CONDITIONAL_MENU::AddMenu(), PCB_ACTIONS::alignBottom, PCB_ACTIONS::alignCenterX, PCB_ACTIONS::alignCenterY, PCB_ACTIONS::alignLeft, PCB_ACTIONS::alignRight, PCB_ACTIONS::alignTop, DisplayError(), PCB_ACTIONS::distributeHorizontally, PCB_ACTIONS::distributeVertically, TOOL_MANAGER::FindTool(), TOOL_MENU::GetMenu(), SELECTION_TOOL::GetToolMenu(), m_frame, m_placementMenu, m_selectionTool, TOOL_BASE::m_toolMgr, SELECTION_CONDITIONS::MoreThan(), CONTEXT_MENU::SetIcon(), and CONTEXT_MENU::SetTitle().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

31 {
32  return m_toolMgr->IsToolActive( m_toolId );
33 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
bool IsToolActive(TOOL_ID aId) const
Function IsToolActive() Returns true if a tool with given id is active (executing)

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

◆ Reset()

void ALIGN_DISTRIBUTE_TOOL::Reset ( RESET_REASON  aReason)
inlineoverridevirtual

Function Reset() Brings 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 44 of file placement_tool.h.

44 {}

◆ RunMainStack()

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

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 85 of file tool_interactive.cpp.

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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 150 of file placement_tool.cpp.

151 {
152  wxPoint curPos( getViewControls()->GetCursorPosition().x, getViewControls()->GetCursorPosition().y );
153 
154  // after sorting, the fist item acts as the target for all others
155  // unless we have a locked item, in which case we use that for the target
156  int target = !aLocked.size() ? aGetValue( aItems.front() ): aGetValue( aLocked.front() );
157 
158  // Iterate through both lists to find if we are mouse-over on one of the items.
159  for( auto sel = aLocked.begin(); sel != aItems.end(); sel++ )
160  {
161  // If there are locked items, prefer aligning to them over
162  // aligning to the cursor as they do not move
163  if( sel == aLocked.end() )
164  {
165  if( aLocked.size() == 0 )
166  {
167  sel = aItems.begin();
168  continue;
169  }
170 
171  break;
172  }
173 
174  // We take the first target that overlaps our cursor.
175  // This is deterministic because we assume sorted arrays
176  if( sel->second.Contains( curPos ) )
177  {
178  target = aGetValue( *sel );
179  break;
180  }
181  }
182 
183  return target;
184 }
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41

References TOOL_BASE::getViewControls().

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

◆ SetContextMenu()

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

Function SetContextMenu()

Assigns 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 74 of file tool_interactive.cpp.

75 {
76  if( aMenu )
77  aMenu->SetTool( this );
78  else
79  aTrigger = CMENU_OFF;
80 
81  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
82 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool's context popup menu.
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::doSelectionMenu(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), and TOOL_MENU::ShowContextMenu().

◆ setTransitions()

void ALIGN_DISTRIBUTE_TOOL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

Definition at line 644 of file placement_tool.cpp.

645 {
652 
655 }
static TOOL_ACTION alignRight
Align items to the right edge of selection bounding box.
Definition: pcb_actions.h:243
int AlignLeft(const TOOL_EVENT &aEvent)
Function AlignLeft() Sets X coordinate of the selected items to the value of the left-most selected i...
int AlignCenterY(const TOOL_EVENT &aEvent)
Function AlignCenterX() Sets the y coordinate of the midpoint of each of the selected items to the va...
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 TOOL_ACTION alignCenterY
Align items to the center of selection bounding box.
Definition: pcb_actions.h:249
int AlignBottom(const TOOL_EVENT &aEvent)
Function AlignBottom() Sets Y coordinate of the selected items to the value of the bottom-most select...
static TOOL_ACTION distributeVertically
Distributes items evenly along the vertical axis.
Definition: pcb_actions.h:255
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION alignBottom
Align items to the bottom edge of selection bounding box.
Definition: pcb_actions.h:237
static TOOL_ACTION distributeHorizontally
Distributes items evenly along the horizontal axis.
Definition: pcb_actions.h:252
int DistributeHorizontally(const TOOL_EVENT &aEvent)
Function DistributeHorizontally() Distributes the selected items along the X axis.
int AlignTop(const TOOL_EVENT &aEvent)
Function AlignTop() Sets Y coordinate of the selected items to the value of the top-most selected ite...
int DistributeVertically(const TOOL_EVENT &aEvent)
Function DistributeVertically() Distributes the selected items along the Y axis.
static TOOL_ACTION alignLeft
Align items to the left edge of selection bounding box.
Definition: pcb_actions.h:240
static TOOL_ACTION alignTop
Align items to the top edge of selection bounding box.
Definition: pcb_actions.h:234
int AlignRight(const TOOL_EVENT &aEvent)
Function AlignRight() Sets X coordinate of the selected items to the value of the right-most selected...
static TOOL_ACTION alignCenterX
Align items to the middle of selection bounding box.
Definition: pcb_actions.h:246

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()

OPT_TOOL_EVENT TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

Suspends execution of the tool until an event specified in aEventList arrives. No parameters means waiting for any event.

Definition at line 55 of file tool_interactive.cpp.

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

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

Referenced by PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

Member Data Documentation

◆ m_frame

◆ m_placementMenu

CONTEXT_MENU* ALIGN_DISTRIBUTE_TOOL::m_placementMenu
private

Definition at line 133 of file placement_tool.h.

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

◆ m_selectionTool

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 210 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 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), PCB_EDITOR_CONTROL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandSelectedConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), PAD_TOOL::Init(), Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), PCBNEW_CONTROL::placeBoardItems(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), SELECTION_TOOL::RequestSelection(), CVPCB_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), TOOL_INTERACTIVE::resetTransitions(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), ZONE_FILLER_TOOL::SegzoneDeleteFill(), SELECTION_TOOL::selectCopper(), PCB_TOOL::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), GERBVIEW_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

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

Definition at line 214 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 of file tool_base.h.

Referenced by TOOL_BASE::attachManager(), and TOOL_BASE::GetSettings().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 207 of file tool_base.h.

Referenced by TOOL_BASE::GetType().


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