KiCad PCB EDA Suite
EDIT_TOOL Class Reference

EDIT_TOOL. More...

#include <edit_tool.h>

Inheritance diagram for EDIT_TOOL:
PCB_TOOL_BASE 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

 EDIT_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 GetAndPlace (const TOOL_EVENT &aEvent)
 

Find an item and start moving.

More...
 
int Move (const TOOL_EVENT &aEvent)
 Function Move() Main loop in which events are handled. More...
 
int Drag (const TOOL_EVENT &aEvent)
 Function Drag() Invoke the PNS router to drag tracks. More...
 
int Properties (const TOOL_EVENT &aEvent)
 Function Properties() Displays properties window for the selected object. More...
 
int Rotate (const TOOL_EVENT &aEvent)
 Function Rotate() Rotates currently selected items. More...
 
int Flip (const TOOL_EVENT &aEvent)
 Function Flip() Rotates currently selected items. More...
 
int Mirror (const TOOL_EVENT &aEvent)
 Function Mirror Mirrors the current selection. More...
 
int ChangeTrackWidth (const TOOL_EVENT &aEvent)
 
int Remove (const TOOL_EVENT &aEvent)
 Function Remove() Deletes currently selected items. More...
 
int Duplicate (const TOOL_EVENT &aEvent)
 Function Duplicate() Duplicates the current selection and starts a move action. More...
 
int MoveExact (const TOOL_EVENT &aEvent)
 Function MoveExact() Invokes a dialog box to allow moving of the item by an exact amount. More...
 
int MoveWithReference (const TOOL_EVENT &aEvent)
 Moves an item but with a reference point selected first. More...
 
int CreateArray (const TOOL_EVENT &aEvent)
 Function CreateArray() Creates an array of the selected items, invoking the array editor dialog to set the options. More...
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 
int copyToClipboard (const TOOL_EVENT &aEvent)
 Function copyToClipboard() Sends the current selection to the clipboard by formatting it as a fake pcb see AppendBoardFromClipboard for importing. More...
 
int cutToClipboard (const TOOL_EVENT &aEvent)
 Function cutToClipboard() Cuts the current selection to the clipboard by formatting it as a fake pcb see AppendBoardFromClipboard for importing. More...
 
BOARD_COMMITGetCurrentCommit () const
 
void SetEditModules (bool aEnabled)
 Function SetEditModules() More...
 
bool EditingModules () const
 
void Activate ()
 Function Activate() Runs the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_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...
 
TOOL_EVENTWait (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...
 
bool IsToolActive () const
 

Static Public Member Functions

static void FootprintFilter (const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
 Function FootprintFilter() A selection filter which prunes the selection to contain only items of type PCB_MODULE_T. More...
 
static void PadFilter (const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
 Function PadFilter() A selection filter which prunes the selection to contain only items of type PCB_PAD_T. More...
 

Protected Types

enum  INTERACTIVE_PLACEMENT_OPTIONS { IPO_ROTATE = 0x01, IPO_FLIP = 0x02, IPO_SINGLE_CLICK = 0x04, IPO_REPEAT = 0x08 }
 Options for placing items interactively. More...
 

Protected Member Functions

void doInteractiveItemPlacement (const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_BASE_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
const PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const PCBNEW_SELECTIONselection () const
 
PCBNEW_SELECTIONselection ()
 
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

bool m_editModules
 
TOOL_MENU m_menu
 functions below are not yet implemented - their interface may change More...
 
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
 

Private Member Functions

bool updateModificationPoint (PCBNEW_SELECTION &aSelection)
 

Returns the right modification point (e.g.

More...
 
bool invokeInlineRouter (int aDragMode)
 
bool isInteractiveDragEnabled () const
 
bool isRouterActive () const
 
int doMoveSelection (const TOOL_EVENT &aEvent, bool aPickReference=false)
 
bool pickReferencePoint (const wxString &aTooltip, const wxString &aSuccessMessage, const wxString &aCanceledMessage, VECTOR2I &aReferencePoint)
 

Private Attributes

SELECTION_TOOLm_selectionTool
 
bool m_dragging
 
bool m_lockedSelected
 
VECTOR2I m_cursor
 
std::unique_ptr< BOARD_COMMITm_commit
 

Detailed Description

EDIT_TOOL.

The interactive edit tool. Allows one to move, rotate, flip and change properties of items selected using the pcbnew.InteractiveSelection tool.

Definition at line 67 of file edit_tool.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

Options for placing items interactively.

Enumerator
IPO_ROTATE 

Handle the rotate action in the loop by calling the item's rotate method.

IPO_FLIP 

Handle flip action in the loop by calling the item's flip method.

IPO_SINGLE_CLICK 

Create an item immediately on placement starting, otherwise show the pencil cursor until the item is created.

IPO_REPEAT 

Allow repeat placement of the item.

Definition at line 116 of file pcb_tool_base.h.

116  {
118  IPO_ROTATE = 0x01,
119 
121  IPO_FLIP = 0x02,
122 
125  IPO_SINGLE_CLICK = 0x04,
126 
128  IPO_REPEAT = 0x08
129  };
Handle flip action in the loop by calling the item's flip method.
Allow repeat placement of the item.
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
Handle the rotate action in the loop by calling the item's rotate method.

◆ 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 79 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ EDIT_TOOL()

EDIT_TOOL::EDIT_TOOL ( )

Definition at line 116 of file edit_tool.cpp.

116  :
117  PCB_TOOL_BASE( "pcbnew.InteractiveEdit" ),
119  m_dragging( false ),
120  m_lockedSelected( false )
121 {
122 }
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
bool m_lockedSelected
Definition: edit_tool.h:196
#define NULL
bool m_dragging
Definition: edit_tool.h:195
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool_base.h:75

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

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
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(), copyToClipboard(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), doMoveSelection(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), LIB_TREE::onContextMenu(), POINT_EDITOR::OnSelectionChange(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ 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 60 of file tool_base.cpp.

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

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 166 of file pcb_tool_base.h.

166 { return getModel<BOARD>(); }

Referenced by PCBNEW_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), checkClearancePadToPad(), checkClearanceSegmToPad(), PCB_INSPECTION_TOOL::ClearHighlight(), DRAWING_TOOL::constrainDimension(), copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), ZONE_FILLER_TOOL::FillAllZones(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::getCollectorsGuide(), PCB_INSPECTION_TOOL::highlightNet(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PCB_TOOL_BASE::module(), MoveExact(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::Paste(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), PAD_TOOL::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), SELECTION_TOOL::RebuildSelection(), PAD_TOOL::recombinePad(), Remove(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectConnectedTracks(), SELECTION_TOOL::selectPoint(), PCBNEW_CONTROL::TrackDisplayMode(), POINT_EDITOR::updateItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCBNEW_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ canvas()

◆ ChangeTrackWidth()

int EDIT_TOOL::ChangeTrackWidth ( const TOOL_EVENT aEvent)

Definition at line 620 of file edit_tool.cpp.

621 {
623  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ) {
625  } );
626 
627  for( EDA_ITEM* item : selection )
628  {
629  if( auto via = dyn_cast<VIA*>( item ) )
630  {
631  m_commit->Modify( item );
632 
633  int new_width;
634  int new_drill;
635 
636  if( via->GetViaType() == VIATYPE::MICROVIA )
637  {
638  auto net = via->GetNet();
639 
640  new_width = net->GetMicroViaSize();
641  new_drill = net->GetMicroViaDrillSize();
642  }
643  else
644  {
645  new_width = board()->GetDesignSettings().GetCurrentViaSize();
646  new_drill = board()->GetDesignSettings().GetCurrentViaDrill();
647  }
648 
649  via->SetDrill( new_drill );
650  via->SetWidth( new_width );
651  }
652  else if ( auto track = dyn_cast<TRACK*>( item ) )
653  {
654  m_commit->Modify( item );
655 
656  int new_width = board()->GetDesignSettings().GetCurrentTrackWidth();
657  track->SetWidth( new_width );
658  }
659  }
660 
661  m_commit->Push( _("Edit track width/via size") );
662 
663  if( selection.IsHover() )
664  {
666 
667  // Notify other tools of the changes -- This updates the visual ratsnest
669  }
670 
671  return 0;
672 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
bool IsHover() const
Definition: selection.h:71
BOARD * board() const
int GetCurrentViaDrill() const
Function GetCurrentViaDrill.
int GetCurrentTrackWidth() const
Function GetCurrentTrackWidth.
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:199
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:553
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:207
const PCBNEW_SELECTION & selection() const
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
int GetCurrentViaSize() const
Function GetCurrentViaSize.
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
#define _(s)
Definition: 3d_actions.cpp:33
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:61

References _, PCB_TOOL_BASE::board(), EditToolSelectionFilter(), EXCLUDE_TRANSIENTS, BOARD_DESIGN_SETTINGS::GetCurrentTrackWidth(), BOARD_DESIGN_SETTINGS::GetCurrentViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentViaSize(), BOARD::GetDesignSettings(), SELECTION::IsHover(), m_commit, m_selectionTool, TOOL_BASE::m_toolMgr, MICROVIA, TOOL_MANAGER::ProcessEvent(), SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), and PCB_ACTIONS::selectionClear.

Referenced by setTransitions().

◆ controls()

◆ copyToClipboard()

int EDIT_TOOL::copyToClipboard ( const TOOL_EVENT aEvent)

Function copyToClipboard() Sends the current selection to the clipboard by formatting it as a fake pcb see AppendBoardFromClipboard for importing.

Definition at line 1513 of file edit_tool.cpp.

1514 {
1515  CLIPBOARD_IO io;
1516 
1517  Activate();
1518 
1520  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ) {
1522  } );
1523 
1524  if( selection.Empty() )
1525  return 1;
1526 
1527  VECTOR2I refPoint;
1528  bool rv = pickReferencePoint( _( "Select reference point for the copy..." ),
1529  _( "Selection copied." ), _( "Copy cancelled." ), refPoint );
1530  frame()->SetMsgPanel( board() );
1531 
1532  if( !rv )
1533  return 1;
1534 
1535  selection.SetReferencePoint( refPoint );
1536 
1537  io.SetBoard( board() );
1539 
1540  return 0;
1541 }
BOARD * board() const
void SaveSelection(const PCBNEW_SELECTION &selected, bool isModEdit)
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
void SetBoard(BOARD *aBoard)
bool pickReferencePoint(const wxString &aTooltip, const wxString &aSuccessMessage, const wxString &aCanceledMessage, VECTOR2I &aReferencePoint)
Definition: edit_tool.cpp:1440
PCB_BASE_EDIT_FRAME * frame() const
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:245
const PCBNEW_SELECTION & selection() const
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
#define _(s)
Definition: 3d_actions.cpp:33
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
void Activate()
Function Activate() Runs the tool.
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:61

References _, TOOL_INTERACTIVE::Activate(), PCB_TOOL_BASE::board(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, PCB_TOOL_BASE::frame(), PCB_TOOL_BASE::m_editModules, m_selectionTool, pickReferencePoint(), SELECTION_TOOL::RequestSelection(), CLIPBOARD_IO::SaveSelection(), PCB_TOOL_BASE::selection(), CLIPBOARD_IO::SetBoard(), EDA_DRAW_FRAME::SetMsgPanel(), and SELECTION::SetReferencePoint().

Referenced by cutToClipboard(), and setTransitions().

◆ CreateArray()

int EDIT_TOOL::CreateArray ( const TOOL_EVENT aEvent)

Function CreateArray() Creates an array of the selected items, invoking the array editor dialog to set the options.

Definition at line 1367 of file edit_tool.cpp.

1368 {
1369  if( isRouterActive() )
1370  {
1371  wxBell();
1372  return 0;
1373  }
1374 
1376  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1377  {
1379  } );
1380 
1381  if( selection.Empty() )
1382  return 0;
1383 
1384  // we have a selection to work on now, so start the tool process
1385  PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
1386  ARRAY_CREATOR array_creator( *editFrame, m_editModules, selection );
1387  array_creator.Invoke();
1388 
1389  return 0;
1390 }
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
const PCBNEW_SELECTION & selection() const
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
bool isRouterActive() const
Definition: edit_tool.cpp:281
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:61
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.

References EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, ARRAY_CREATOR::Invoke(), isRouterActive(), PCB_TOOL_BASE::m_editModules, m_selectionTool, SELECTION_TOOL::RequestSelection(), and PCB_TOOL_BASE::selection().

Referenced by setTransitions().

◆ cutToClipboard()

int EDIT_TOOL::cutToClipboard ( const TOOL_EVENT aEvent)

Function cutToClipboard() Cuts the current selection to the clipboard by formatting it as a fake pcb see AppendBoardFromClipboard for importing.

Definition at line 1544 of file edit_tool.cpp.

1545 {
1546  if( !copyToClipboard( aEvent ) )
1547  {
1548  // N.B. Setting the CUT flag prevents lock filtering as we only want to delete the items that
1549  // were copied to the clipboard, no more, no fewer. Filtering for locked item, if any will be done
1550  // in the copyToClipboard() routine
1551  TOOL_EVENT evt( aEvent.Category(), aEvent.Action(), TOOL_ACTION_SCOPE::AS_GLOBAL );
1553  Remove( evt );
1554  }
1555 
1556  return 0;
1557 }
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition: tool_event.h:250
TOOL_EVENT_CATEGORY Category() const
Returns the category (eg. mouse/keyboard/action) of an event..
Definition: tool_event.h:247
void SetParameter(T aParam)
Function SetParameter() Sets a non-standard parameter assigned to the event.
Definition: tool_event.h:453
TOOL_EVENT.
Definition: tool_event.h:171
All active tools
Definition: tool_event.h:147
int Remove(const TOOL_EVENT &aEvent)
Function Remove() Deletes currently selected items.
Definition: edit_tool.cpp:967
int copyToClipboard(const TOOL_EVENT &aEvent)
Function copyToClipboard() Sends the current selection to the clipboard by formatting it as a fake pc...
Definition: edit_tool.cpp:1513

References TOOL_EVENT::Action(), AS_GLOBAL, TOOL_EVENT::Category(), copyToClipboard(), ACTIONS::CUT, Remove(), and TOOL_EVENT::SetParameter().

Referenced by setTransitions().

◆ displayOptions()

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

◆ doInteractiveItemPlacement()

void PCB_TOOL_BASE::doInteractiveItemPlacement ( const std::string &  aTool,
INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc.

More complex interactive processes are not supported here, you should implement a customised event loop for those.

Parameters
aItemCreatorthe callable that will attempt to create the item
aCommitMessagethe message used on a successful commit

Definition at line 37 of file pcb_tool_base.cpp.

40 {
41  using namespace std::placeholders;
42  std::unique_ptr<BOARD_ITEM> newItem;
43 
44  frame()->PushTool( aTool );
45  Activate();
46 
47  BOARD_COMMIT commit( frame() );
48 
50 
51  // do not capture or auto-pan until we start placing an item
52  controls()->ShowCursor( true );
53  controls()->SetSnapping( true );
54 
55  // Add a VIEW_GROUP that serves as a preview for the new item
56  PCBNEW_SELECTION preview;
57  view()->Add( &preview );
58 
59  aPlacer->m_board = board();
60  aPlacer->m_frame = frame();
61  aPlacer->m_modifiers = 0;
62 
63  auto makeNewItem = [&] ( VECTOR2I aPosition )
64  {
65  if( frame()->GetModel() )
66  newItem = aPlacer->CreateItem();
67 
68  if( newItem )
69  {
70  newItem->SetPosition( (wxPoint) aPosition );
71  preview.Add( newItem.get() );
72 
73  if( newItem->Type() == PCB_MODULE_T )
74  {
75  auto module = dyn_cast<MODULE*>( newItem.get() );
76 
77  // modules have more drawable parts
78  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
79  }
80  }
81  };
82 
83  if( aOptions & IPO_SINGLE_CLICK )
84  makeNewItem( controls()->GetCursorPosition() );
85 
86  // Main loop: keep receiving events
87  while( TOOL_EVENT* evt = Wait() )
88  {
89  if( !newItem )
90  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
91  else
92  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
93 
94  VECTOR2I cursorPos = controls()->GetCursorPosition();
95  aPlacer->m_modifiers = evt->Modifier();
96 
97  auto cleanup = [&] ()
98  {
99  newItem = nullptr;
100  preview.Clear();
101  view()->Update( &preview );
102  controls()->SetAutoPan( false );
103  controls()->CaptureCursor( false );
104  controls()->ShowCursor( true );
105  };
106 
107  if( evt->IsCancelInteractive() )
108  {
109  if( aOptions & IPO_SINGLE_CLICK )
110  {
111  cleanup();
112  frame()->PopTool( aTool );
113  break;
114  }
115  else if( newItem )
116  cleanup();
117  else
118  {
119  frame()->PopTool( aTool );
120  break;
121  }
122  }
123  else if( evt->IsActivate() )
124  {
125  if( newItem )
126  cleanup();
127 
128  if( evt->IsPointEditor() )
129  {
130  // don't exit (the point editor runs in the background)
131  }
132  else if( evt->IsMoveTool() )
133  {
134  // leave ourselves on the stack so we come back after the move
135  break;
136  }
137  else
138  {
139  frame()->PopTool( aTool );
140  break;
141  }
142  }
143  else if( evt->IsClick( BUT_LEFT ) )
144  {
145  if( !newItem )
146  {
147  // create the item if possible
148  makeNewItem( cursorPos );
149 
150  // no item created, so wait for another click
151  if( !newItem )
152  continue;
153 
154  controls()->CaptureCursor( true );
155  controls()->SetAutoPan( true );
156  }
157  else
158  {
159  auto oldFlags = newItem->GetFlags();
160  newItem->ClearFlags();
161 
162  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
163  {
164  newItem->SetFlags( oldFlags );
165  continue;
166  }
167 
168  preview.Clear();
169  newItem.release();
170  commit.Push( aCommitMessage );
171 
172  controls()->CaptureCursor( false );
173  controls()->SetAutoPan( false );
174  controls()->ShowCursor( true );
175 
176  if( !( aOptions & IPO_REPEAT ) )
177  break;
178 
179  if( aOptions & IPO_SINGLE_CLICK )
180  makeNewItem( controls()->GetCursorPosition() );
181  }
182  }
183  else if( evt->IsClick( BUT_RIGHT ) )
184  {
186  }
187  else if( newItem && evt->Category() == TC_COMMAND )
188  {
189  /*
190  * Handle any events that can affect the item as we move it around
191  */
192  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
193  {
194  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
195  newItem->Rotate( newItem->GetPosition(), rotationAngle );
196  view()->Update( &preview );
197  }
198  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
199  {
200  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
201  view()->Update( &preview );
202  }
203  else if( evt->IsAction( &PCB_ACTIONS::viaSizeInc )
204  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
205  {
206  // Refresh preview after event runs
208  }
209  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
210  {
211  preview.Clear();
212  newItem.release();
213 
214  makeNewItem( controls()->GetCursorPosition() );
215  view()->Update( &preview );
216  }
217  }
218 
219  else if( newItem && evt->IsMotion() )
220  {
221  // track the cursor
222  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
223  aPlacer->SnapItem( newItem.get() );
224 
225  // Show a preview of the item
226  view()->Update( &preview );
227  }
228 
229  else
230  evt->SetPassEvent();
231  }
232 
233  view()->Remove( &preview );
234 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:95
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Function RunOnChildren.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:92
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:279
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:76
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143
PCB_BASE_EDIT_FRAME * frame() const
virtual void SnapItem(BOARD_ITEM *aItem)
class MODULE, a footprint
Definition: typeinfo.h:89
const PCBNEW_SELECTION & selection() const
Allow repeat placement of the item.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
TOOL_EVENT.
Definition: tool_event.h:171
KIGFX::PCB_VIEW * view() const
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:103
Handle the rotate action in the loop by calling the item's rotate method.
KIGFX::VIEW_CONTROLS * controls() const
MODULE * module() const
PCBNEW_SETTINGS & Settings()
void Activate()
Function Activate() Runs the tool.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
PCB_BASE_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:62
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:280
static TOOL_ACTION refreshPreview
Definition: actions.h:102
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, PCBNEW_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, TOOL_BASE::m_toolMgr, PCB_TOOL_BASE::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), TOOLS_HOLDER::PopTool(), BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, KIGFX::PCB_VIEW::Update(), PCB_ACTIONS::viaSizeDec, PCB_ACTIONS::viaSizeInc, PCB_TOOL_BASE::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint(), DRAWING_TOOL::DrawVia(), and PAD_TOOL::PlacePad().

◆ doMoveSelection()

int EDIT_TOOL::doMoveSelection ( const TOOL_EVENT aEvent,
bool  aPickReference = false 
)
private

Definition at line 326 of file edit_tool.cpp.

327 {
328  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
330  VECTOR2I originalCursorPos = controls->GetCursorPosition();
331 
332  // Be sure that there is at least one item that we can modify. If nothing was selected before,
333  // try looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection)
335  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
336  {
338  } );
339 
340  if( m_dragging || selection.Empty() )
341  return 0;
342 
343  LSET item_layers = selection.GetSelectionLayers();
344  bool unselect = selection.IsHover(); // N.B. This must be saved before the re-selection below
345 
346  // Now filter out locked pads. We cannot do this in the first RequestSelection() as we need
347  // the item_layers when a pad is the selection front (ie: will become curr_tiem).
349  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
350  {
352  } );
353 
354  if( selection.Empty() )
355  return 0;
356 
357  std::string tool = aEvent.GetCommandStr().get();
358  editFrame->PushTool( tool );
359  Activate();
360  controls->ShowCursor( true );
361  controls->SetAutoPan( true );
362 
363  std::vector<BOARD_ITEM*> sel_items;
364 
365  for( EDA_ITEM* item : selection )
366  {
367  BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
368  MODULE* module = dynamic_cast<MODULE*>( item );
369 
370  if( boardItem )
371  sel_items.push_back( boardItem );
372 
373  if( module )
374  {
375  for( D_PAD* pad : module->Pads() )
376  sel_items.push_back( pad );
377  }
378  }
379 
380  bool restore_state = false;
381  VECTOR2I totalMovement;
382  GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() );
383  TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
384  VECTOR2I prevPos;
385 
386  // Prime the pump
388 
389  // Main loop: keep receiving events
390  do
391  {
392  editFrame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
393  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
394  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
395  controls->SetSnapping( !evt->Modifier( MD_ALT ) );
396 
397  if( evt->IsAction( &PCB_ACTIONS::move ) || evt->IsMotion()
398  || evt->IsAction( &PCB_ACTIONS::drag ) || evt->IsDrag( BUT_LEFT )
399  || evt->IsAction( &ACTIONS::refreshPreview )
400  || evt->IsAction( &PCB_ACTIONS::moveWithReference ) )
401  {
402  if( m_dragging && evt->Category() == TC_MOUSE )
403  {
404  VECTOR2I mousePos( controls->GetMousePosition() );
405 
406  m_cursor = grid.BestSnapAnchor( mousePos, item_layers, sel_items );
407 
409  {
411 
412  // The arrow keys are by definition SINGLE AXIS. Do not allow the other
413  // axis to be snapped to the grid.
414  if( action == ACTIONS::CURSOR_LEFT || action == ACTIONS::CURSOR_RIGHT )
415  m_cursor.y = prevPos.y;
416  else if( action == ACTIONS::CURSOR_UP || action == ACTIONS::CURSOR_DOWN )
417  m_cursor.x = prevPos.x;
418  }
419 
422 
423  VECTOR2I movement( m_cursor - prevPos );
424  prevPos = m_cursor;
425  totalMovement += movement;
426 
427  // Drag items to the current cursor position
428  for( EDA_ITEM* item : sel_items )
429  {
430  // Don't double move footprint pads, fields, etc.
431  if( !item->GetParent() || !item->GetParent()->IsSelected() )
432  static_cast<BOARD_ITEM*>( item )->Move( movement );
433  }
434 
435  frame()->UpdateMsgPanel();
436  }
437  else if( !m_dragging ) // Prepare to start dragging
438  {
439  if( !( evt->IsAction( &PCB_ACTIONS::move )
440  || evt->IsAction( &PCB_ACTIONS::moveWithReference ) )
442  {
444  break;
445  }
446 
447  // deal with locked items (override lock or abort the operation)
449 
450  if( lockFlags == SELECTION_LOCKED )
451  break;
452 
453  m_dragging = true;
454 
455  // When editing modules, all items have the same parent
456  if( EditingModules() )
457  {
458  m_commit->Modify( selection.Front() );
459  }
460  else
461  {
462  // Save items, so changes can be undone
463  for( EDA_ITEM* item : selection )
464  {
465  // Don't double move footprint pads, fields, etc.
466  if( item->GetParent() && item->GetParent()->IsSelected() )
467  continue;
468 
469  m_commit->Modify( item );
470  }
471  }
472 
473  editFrame->UndoRedoBlock( true );
475 
477  {
478  // start moving with the reference point attached to the cursor
479  grid.SetAuxAxes( false );
480 
481  auto delta = m_cursor - selection.GetReferencePoint();
482 
483  // Drag items to the current cursor position
484  for( EDA_ITEM* item : selection )
485  {
486  // Don't double move footprint pads, fields, etc.
487  if( item->GetParent() && item->GetParent()->IsSelected() )
488  continue;
489 
490  static_cast<BOARD_ITEM*>( item )->Move( delta );
491  }
492 
494  }
495  else
496  {
497  std::vector<BOARD_ITEM*> items;
498 
499  for( EDA_ITEM* item : selection )
500  items.push_back( static_cast<BOARD_ITEM*>( item ) );
501 
502  m_cursor = grid.BestDragOrigin( originalCursorPos, items );
503 
504  // Set the current cursor position to the first dragged item origin, so the
505  // movement vector could be computed later
506  if( aPickReference )
507  {
508  VECTOR2I ref;
509 
510  if( pickReferencePoint( _( "Select reference point for move..." ),
511  "", "", ref ) )
512  {
514  controls->ForceCursorPosition( true, ref );
515  m_cursor = ref;
516  }
517  else
518  {
519  // Cancel before move started
520  break;
521  }
522  }
523  else
524  {
526  grid.SetAuxAxes( true, m_cursor );
527  }
528  }
529 
531 
532  prevPos = m_cursor;
533  controls->SetAutoPan( true );
534  }
535 
538  }
539 
540  else if( evt->IsCancelInteractive() || evt->IsActivate() )
541  {
542  restore_state = true; // Canceling the tool means that items have to be restored
543  break; // Finish
544  }
545 
546  else if( evt->IsAction( &ACTIONS::undo ) )
547  {
548  restore_state = true; // Perform undo locally
549  break; // Finish
550  }
551 
552  // Dispatch TOOL_ACTIONs
553  else if( evt->Category() == TC_COMMAND )
554  {
555  if( evt->IsAction( &ACTIONS::doDelete ) )
556  {
557  break; // finish -- there is no further processing for removed items
558  }
559  else if( evt->IsAction( &ACTIONS::duplicate ) )
560  {
561  break; // finish -- Duplicate tool will start a new Move with the dup'ed items
562  }
563  else if( evt->IsAction( &PCB_ACTIONS::moveExact ) )
564  {
565  // Reset positions so the Move Exactly is from the start.
566  for( EDA_ITEM* item : selection )
567  {
568  BOARD_ITEM* i = static_cast<BOARD_ITEM*>( item );
569  i->Move( -totalMovement );
570  }
571 
572  break; // finish -- we moved exactly, so we are finished
573  }
574  }
575 
576  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
577  {
578  break; // finish
579  }
580 
581  else
582  {
583  evt->SetPassEvent();
584  }
585 
586  } while( ( evt = Wait() ) ); // Assignment (instead of equality test) is intentional
587 
588  m_lockedSelected = false;
589  controls->ForceCursorPosition( false );
590  controls->ShowCursor( false );
591  controls->SetSnapping( false );
592  controls->SetAutoPan( false );
593 
594  m_dragging = false;
595  editFrame->UndoRedoBlock( false );
596 
597  // Discard reference point when selection is "dropped" onto the board (ie: not dragging anymore)
599 
600  // If canceled, we need to remove the dynamic ratsnest from the screen
601  if( restore_state )
602  {
604  m_commit->Revert();
605  }
606  else
607  {
608  m_commit->Push( _( "Drag" ) );
609  }
610 
611  if( unselect )
613 
614  editFrame->PopTool( tool );
615 
616  return 0;
617 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
VECTOR2I GetReferencePoint() const
Definition: selection.h:240
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
VECTOR2I m_cursor
Definition: edit_tool.h:197
void ClearReferencePoint()
Definition: selection.h:250
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
bool IsHover() const
Definition: selection.h:71
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
static TOOL_ACTION doDelete
Definition: actions.h:74
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:199
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
SELECTION_LOCK_FLAGS CheckLock()
Checks if the user has agreed to modify locked items for the given selection.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
PADS & Pads()
Definition: class_module.h:173
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Moves cursor to the requested position expressed in world coordinates.
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:207
const VC_SETTINGS & GetSettings() const
Returns the current VIEW_CONTROLS settings
static TOOL_ACTION moveExact
Activation of the exact move tool.
Definition: pcb_actions.h:115
bool pickReferencePoint(const wxString &aTooltip, const wxString &aSuccessMessage, const wxString &aCanceledMessage, VECTOR2I &aReferencePoint)
Definition: edit_tool.cpp:1440
const LSET GetSelectionLayers()
PCB_BASE_EDIT_FRAME * frame() const
bool m_lockedSelected
Definition: edit_tool.h:196
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:245
bool isInteractiveDragEnabled() const
Definition: edit_tool.cpp:273
LSET is a set of PCB_LAYER_IDs.
const PCBNEW_SELECTION & selection() const
bool m_dragging
Definition: edit_tool.h:195
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
virtual void PopTool(const std::string &actionName)
SELECTION_LOCK_FLAGS
Definition: selection.h:279
TOOL_EVENT.
Definition: tool_event.h:171
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
static TOOL_ACTION hideDynamicRatsnest
Definition: pcb_actions.h:424
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
static TOOL_ACTION drag
Definition: pcb_actions.h:93
bool EditingModules() const
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:245
bool HasReferencePoint() const
Definition: selection.h:235
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
KIGFX::VIEW_CONTROLS * controls() const
Common, abstract interface for edit frames.
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
long m_lastKeyboardCursorCommand
ACTIONS::CURSOR_UP, ACTIONS::CURSOR_DOWN, etc.
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
bool m_lastKeyboardCursorPositionValid
Is last cursor motion event coming from keyboard arrow cursor motion action
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
void Activate()
Function Activate() Runs the tool.
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:425
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
static TOOL_ACTION moveWithReference
move with a reference point
Definition: pcb_actions.h:96
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:61
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:268
static TOOL_ACTION duplicate
Definition: actions.h:73
static TOOL_ACTION refreshPreview
Definition: actions.h:102
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:184
virtual void UpdateMsgPanel()
Redraw the message panel.

References _, TOOL_INTERACTIVE::Activate(), BUT_LEFT, SELECTION_TOOL::CheckLock(), SELECTION::ClearReferencePoint(), PCB_TOOL_BASE::controls(), ACTIONS::CURSOR_DOWN, ACTIONS::CURSOR_LEFT, ACTIONS::CURSOR_RIGHT, ACTIONS::CURSOR_UP, PNS::DM_ANY, ACTIONS::doDelete, PCB_ACTIONS::drag, ACTIONS::duplicate, PCB_TOOL_BASE::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), SELECTION::Front(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_FRAME::GetMagneticItemsSettings(), KIGFX::VIEW_CONTROLS::GetMousePosition(), SELECTION::GetReferencePoint(), PCBNEW_SELECTION::GetSelectionLayers(), KIGFX::VIEW_CONTROLS::GetSettings(), TOOL_BASE::getViewControls(), SELECTION::HasReferencePoint(), PCB_ACTIONS::hideDynamicRatsnest, invokeInlineRouter(), SELECTION::IsHover(), isInteractiveDragEnabled(), m_commit, m_cursor, m_dragging, KIGFX::VC_SETTINGS::m_lastKeyboardCursorCommand, KIGFX::VC_SETTINGS::m_lastKeyboardCursorPositionValid, m_lockedSelected, m_selectionTool, TOOL_BASE::m_toolMgr, MD_ALT, MD_SHIFT, PCB_TOOL_BASE::module(), PCB_ACTIONS::move, BOARD_ITEM::Move(), PCB_ACTIONS::moveExact, PCB_ACTIONS::moveWithReference, MODULE::Pads(), pickReferencePoint(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::PostEvent(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), SELECTION_LOCKED, PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), SELECTION::SetReferencePoint(), KIGFX::VIEW_CONTROLS::SetSnapping(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, TC_MOUSE, ACTIONS::undo, PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PCB_ACTIONS::updateLocalRatsnest, EDA_DRAW_FRAME::UpdateMsgPanel(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Move(), and MoveWithReference().

◆ Drag()

int EDIT_TOOL::Drag ( const TOOL_EVENT aEvent)

Function Drag() Invoke the PNS router to drag tracks.

Definition at line 289 of file edit_tool.cpp.

290 {
291  int mode = PNS::DM_ANY;
292 
293  if( aEvent.IsAction( &PCB_ACTIONS::dragFreeAngle ) )
294  mode |= PNS::DM_FREE_ANGLE;
295 
296  invokeInlineRouter( mode );
297 
298  return 0;
299 }
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:133
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:245

References PNS::DM_ANY, PNS::DM_FREE_ANGLE, PCB_ACTIONS::dragFreeAngle, invokeInlineRouter(), and TOOL_EVENT::IsAction().

Referenced by setTransitions().

◆ Duplicate()

int EDIT_TOOL::Duplicate ( const TOOL_EVENT aEvent)

Function Duplicate() Duplicates the current selection and starts a move action.

Definition at line 1247 of file edit_tool.cpp.

1248 {
1249  if( isRouterActive() )
1250  {
1251  wxBell();
1252  return 0;
1253  }
1254 
1255  bool increment = aEvent.IsAction( &PCB_ACTIONS::duplicateIncrement );
1256 
1257  // Be sure that there is at least one item that we can modify
1259  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1260  {
1262  } );
1263 
1264  if( selection.Empty() )
1265  return 0;
1266 
1267  // we have a selection to work on now, so start the tool process
1268  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1269 
1270  // If the selection was given a hover, we do not keep the selection after completion
1271  bool is_hover = selection.IsHover();
1272 
1273  std::vector<BOARD_ITEM*> new_items;
1274  new_items.reserve( selection.Size() );
1275 
1276  BOARD_ITEM* orig_item = nullptr;
1277  BOARD_ITEM* dupe_item = nullptr;
1278 
1279  // Each selected item is duplicated and pushed to new_items list
1280  // Old selection is cleared, and new items are then selected.
1281  for( EDA_ITEM* item : selection )
1282  {
1283  orig_item = static_cast<BOARD_ITEM*>( item );
1284 
1285  if( m_editModules )
1286  {
1287  MODULE* editModule = editFrame->GetBoard()->GetFirstModule();
1288  dupe_item = editModule->DuplicateItem( orig_item );
1289 
1290  if( increment && item->Type() == PCB_PAD_T
1291  && PAD_NAMING::PadCanHaveName( *static_cast<D_PAD*>( dupe_item ) ) )
1292  {
1293  PAD_TOOL* padTool = m_toolMgr->GetTool<PAD_TOOL>();
1294  wxString padName = padTool->GetLastPadName();
1295  padName = editModule->GetNextPadName( padName );
1296  padTool->SetLastPadName( padName );
1297  static_cast<D_PAD*>( dupe_item )->SetName( padName );
1298  }
1299  }
1300  else if( orig_item->GetParent() && orig_item->GetParent()->Type() == PCB_MODULE_T )
1301  {
1302  MODULE* parent = static_cast<MODULE*>( orig_item->GetParent() );
1303 
1304  m_commit->Modify( parent );
1305  dupe_item = parent->DuplicateItem( orig_item, true /* add to parent */ );
1306  }
1307  else
1308  {
1309  switch( orig_item->Type() )
1310  {
1311  case PCB_MODULE_T:
1312  case PCB_TEXT_T:
1313  case PCB_LINE_T:
1314  case PCB_TRACE_T:
1315  case PCB_VIA_T:
1316  case PCB_ZONE_AREA_T:
1317  case PCB_TARGET_T:
1318  case PCB_DIMENSION_T:
1319  dupe_item = orig_item->Duplicate();
1320  break;
1321 
1322  default:
1323  // Silently drop other items (such as footprint texts) from duplication
1324  break;
1325  }
1326  }
1327 
1328  if( dupe_item )
1329  {
1330  // Clear the selection flag here, otherwise the SELECTION_TOOL
1331  // will not properly select it later on
1332  dupe_item->ClearSelected();
1333 
1334  new_items.push_back( dupe_item );
1335  m_commit->Add( dupe_item );
1336  }
1337  }
1338 
1339  // Clear the old selection first
1341 
1342  // Select the new items
1343  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &new_items );
1344 
1345  // record the new items as added
1346  if( !selection.Empty() )
1347  {
1348  editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ),
1349  (int) new_items.size() ) );
1350 
1351  // If items were duplicated, pick them up
1352  // this works well for "dropping" copies around and pushes the commit
1354  Move( evt );
1355 
1356  // After moving the new items, we need to refresh the group and view flags
1358 
1359  if( !is_hover )
1360  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &new_items );
1361  }
1362 
1363  return 0;
1364 }
static TOOL_ACTION selectItems
Selects a list of items (specified as the event parameter)
Definition: pcb_actions.h:69
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
bool IsHover() const
Definition: selection.h:71
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:199
void ClearSelected()
Definition: base_struct.h:211
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
bool PadCanHaveName(const D_PAD &aPad)
Check if a pad should be named.
Definition: pad_naming.cpp:26
PAD_TOOL.
Definition: pad_tool.h:37
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
class MODULE, a footprint
Definition: typeinfo.h:89
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
Definition: pcb_actions.h:118
const PCBNEW_SELECTION & selection() const
void SetLastPadName(const wxString &aPadName)
Definition: pad_tool.h:74
wxString GetLastPadName() const
Definition: pad_tool.h:73
TOOL_EVENT.
Definition: tool_event.h:171
MODULE * GetFirstModule() const
Gets the first module in the list (used in footprint viewer/editor) or NULL if none.
Definition: class_board.h:330
wxString GetNextPadName(const wxString &aLastPadName) const
Function GetNextPadName returns the next available pad name in the module.
BOARD_ITEM * DuplicateItem(const BOARD_ITEM *aItem, bool aAddToModule=false)
Function DuplicateItem Duplicate a given item within the module, optionally adding it to the board.
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
int Move(const TOOL_EVENT &aEvent)
Function Move() Main loop in which events are handled.
Definition: edit_tool.cpp:302
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
Common, abstract interface for edit frames.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
TOOL_EVENT MakeEvent() const
Function MakeEvent() Returns the event associated with the action (i.e.
Definition: tool_action.h:107
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
bool isRouterActive() const
Definition: edit_tool.cpp:281
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
BOARD * GetBoard() const
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
BOARD_ITEM_CONTAINER * GetParent() const
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:61
BOARD_ITEM * Duplicate() const
Function Duplicate creates a copy of a BOARD_ITEM.
void DisplayToolMsg(const wxString &msg) override
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References _, EDA_ITEM::ClearSelected(), EDA_DRAW_FRAME::DisplayToolMsg(), BOARD_ITEM::Duplicate(), PCB_ACTIONS::duplicateIncrement, MODULE::DuplicateItem(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, Format(), PCB_BASE_FRAME::GetBoard(), BOARD::GetFirstModule(), PAD_TOOL::GetLastPadName(), MODULE::GetNextPadName(), BOARD_ITEM::GetParent(), TOOL_MANAGER::GetTool(), TOOL_EVENT::IsAction(), SELECTION::IsHover(), isRouterActive(), m_commit, PCB_TOOL_BASE::m_editModules, m_selectionTool, TOOL_BASE::m_toolMgr, TOOL_ACTION::MakeEvent(), Move(), PCB_ACTIONS::move, PAD_NAMING::PadCanHaveName(), PCB_DIMENSION_T, PCB_LINE_T, PCB_MODULE_T, PCB_PAD_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItems, PAD_TOOL::SetLastPadName(), SELECTION::Size(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ EditingModules()

bool PCB_TOOL_BASE::EditingModules ( ) const
inlineinherited

Definition at line 106 of file pcb_tool_base.h.

107  {
108  return m_editModules;
109  }

References PCB_TOOL_BASE::m_editModules.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), doMoveSelection(), Flip(), Mirror(), MoveExact(), and Rotate().

◆ Flip()

int EDIT_TOOL::Flip ( const TOOL_EVENT aEvent)

Function Flip() Rotates currently selected items.

The rotation point is the current cursor position.

Definition at line 910 of file edit_tool.cpp.

911 {
912  if( isRouterActive() )
913  {
914  wxBell();
915  return 0;
916  }
917 
919  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
920  {
922  },
923  nullptr, !m_dragging );
924 
925  if( selection.Empty() )
926  return 0;
927 
929 
930  // Flip around the anchor for footprints, and the bounding box center for board items
931  VECTOR2I modPoint = EditingModules() ? VECTOR2I( 0, 0 ) : selection.GetCenter();
932 
933  // If only one item selected, flip around the item anchor point, instead
934  // of the bounding box center, to avoid moving the item anchor
935  if( selection.GetSize() == 1 )
936  modPoint = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) )->GetPosition();
937 
938  bool leftRight = frame()->Settings().m_FlipLeftRight;
939 
940  // When editing modules, all items have the same parent
941  if( EditingModules() )
942  m_commit->Modify( selection.Front() );
943 
944  for( EDA_ITEM* item : selection )
945  {
946  if( !item->IsNew() && !EditingModules() )
947  m_commit->Modify( item );
948 
949  static_cast<BOARD_ITEM*>( item )->Flip( modPoint, leftRight );
950  }
951 
952  if( !m_dragging )
953  m_commit->Push( _( "Flip" ) );
954 
955  if( selection.IsHover() && !m_dragging )
957 
959 
960  if( m_dragging )
962 
963  return 0;
964 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
bool IsHover() const
Definition: selection.h:71
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:199
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:207
PCB_BASE_EDIT_FRAME * frame() const
const PCBNEW_SELECTION & selection() const
bool m_dragging
Definition: edit_tool.h:195
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:105
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
bool EditingModules() const
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:100
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
#define _(s)
Definition: 3d_actions.cpp:33
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
PCBNEW_SETTINGS & Settings()
bool isRouterActive() const
Definition: edit_tool.cpp:281
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:425
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
bool updateModificationPoint(PCBNEW_SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1417
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:61
EDA_ITEM * Front() const
Definition: selection.h:184

References _, PCB_TOOL_BASE::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, PCB_TOOL_BASE::frame(), SELECTION::Front(), SELECTION::GetCenter(), SELECTION::GetItem(), SELECTION::GetSize(), SELECTION::IsHover(), isRouterActive(), m_commit, m_dragging, PCBNEW_SETTINGS::m_FlipLeftRight, m_selectionTool, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_BASE_FRAME::Settings(), PCB_ACTIONS::updateLocalRatsnest, and updateModificationPoint().

Referenced by setTransitions().

◆ FootprintFilter()

void EDIT_TOOL::FootprintFilter ( const VECTOR2I ,
GENERAL_COLLECTOR aCollector 
)
static

Function FootprintFilter() A selection filter which prunes the selection to contain only items of type PCB_MODULE_T.

Definition at line 1405 of file edit_tool.cpp.

1406 {
1407  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1408  {
1409  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
1410 
1411  if( item->Type() != PCB_MODULE_T )
1412  aCollector.Remove( i );
1413  }
1414 }
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:130
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:101
class MODULE, a footprint
Definition: typeinfo.h:89
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References COLLECTOR::GetCount(), PCB_MODULE_T, COLLECTOR::Remove(), and EDA_ITEM::Type().

Referenced by PCB_EDITOR_CONTROL::EditFpInFpEditor(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), and PCB_INSPECTION_TOOL::LocalRatsnestTool().

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 161 of file pcb_tool_base.h.

162  {
163  return getEditFrame<PCB_BASE_EDIT_FRAME>();
164  }

Referenced by POINT_EDITOR::addCorner(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), copyToClipboard(), ROUTER_TOOL::CustomTrackWidthDialog(), FOOTPRINT_EDITOR_TOOLS::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), doMoveSelection(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), PCB_EDITOR_CONTROL::ExportSpecctraDSN(), ROUTER_TOOL::finishInteractive(), Flip(), PCB_EDITOR_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PCB_EDITOR_CONTROL::ImportSpecctraSession(), SELECTION_TOOL::Init(), Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCBNEW_PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), MoveExact(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), pickReferencePoint(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), PAD_TOOL::recombinePad(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), Remove(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), POINT_EDITOR::setEditedPoint(), ROUTER_TOOL::SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), ROUTER_TOOL::switchLayerOnViaPlacement(), POINT_EDITOR::updateItem(), PCB_EDITOR_CONTROL::UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ GetAndPlace()

int EDIT_TOOL::GetAndPlace ( const TOOL_EVENT aEvent)

Find an item and start moving.

Definition at line 227 of file edit_tool.cpp.

228 {
229  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
230  MODULE* module = getEditFrame<PCB_BASE_FRAME>()->GetFootprintFromBoardByReference();
231 
232  if( module )
233  {
236 
237  selectionTool->GetSelection().SetReferencePoint( module->GetPosition() );
239  }
240 
241  return 0;
242 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:245
MODULE * module() const
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:65
wxPoint GetPosition() const override
Definition: class_module.h:216

References MODULE::GetPosition(), SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, PCB_TOOL_BASE::module(), PCB_ACTIONS::move, TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, and SELECTION::SetReferencePoint().

Referenced by setTransitions().

◆ GetCurrentCommit()

BOARD_COMMIT* EDIT_TOOL::GetCurrentCommit ( ) const
inline

Definition at line 177 of file edit_tool.h.

177 { return m_commit.get(); }
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:199

References m_commit.

◆ 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 187 of file tool_base.h.

188  {
189 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
190  wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
191 #endif
192  return static_cast<T*>( getToolHolderInt() );
193  }
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

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

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

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

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

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

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 201 of file tool_base.h.

202  {
203  EDA_ITEM* m = getModelInt();
204 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
205  wxASSERT( dynamic_cast<T*>( m ) );
206 #endif
207  return static_cast<T*>( m );
208  }
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:54
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159

References TOOL_BASE::getModelInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), 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 132 of file tool_base.h.

133  {
134  return m_toolName;
135  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:218

References TOOL_BASE::m_toolName.

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

◆ GetToolMenu()

◆ 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 110 of file tool_base.h.

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

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

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

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

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::checkPart(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), PL_DRAWING_TOOLS::DrawShape(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindComponentAndItem(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::GuessSelectionCandidates(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), Properties(), Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::Selectable(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), PL_EDITOR_CONTROL::ToggleBackgroundColor(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), EE_POINT_EDITOR::updateItem(), PL_POINT_EDITOR::updateItem(), POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), COMMON_TOOLS::ZoomFitScreen(), SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_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 42 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCorner(), POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), COMMON_TOOLS::OnGridChanged(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LENGTH_TUNER_TOOL::performTuning(), LIB_DRAWING_TOOLS::PlaceAnchor(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), Properties(), Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCBNEW_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateItem(), LIB_MOVE_TOOL::updateModificationPoint(), PL_EDIT_TOOL::updateModificationPoint(), 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

Function Go()

Defines which state (aStateFunc) to go when a certain event arrives (aConditions). No conditions means any event.

Definition at line 129 of file tool_interactive.h.

131 {
132  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
133 
134  goInternal( sptr, aConditions );
135 }
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 LENGTH_TUNER_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), PCB_REANNOTATE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), LIB_PIN_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), PL_POINT_EDITOR::setTransitions(), COMMON_CONTROL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), POINT_EDITOR::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), SCH_MOVE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), LIB_CONTROL::setTransitions(), PL_EDIT_TOOL::setTransitions(), PAD_TOOL::setTransitions(), FOOTPRINT_EDITOR_TOOLS::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCBNEW_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), PCBNEW_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), DRC::setTransitions(), setTransitions(), DRAWING_TOOL::setTransitions(), SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ Init()

bool EDIT_TOOL::Init ( void  )
overridevirtual

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

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

Reimplemented from PCB_TOOL_BASE.

Definition at line 156 of file edit_tool.cpp.

157 {
158  // Find the selection tool, so they can cooperate
159  m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
160  wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" );
161 
162  auto editingModuleCondition =
163  [ this ] ( const SELECTION& aSelection )
164  {
165  return m_editModules;
166  };
167 
168  auto singleModuleCondition = SELECTION_CONDITIONS::OnlyType( PCB_MODULE_T )
170 
171  auto noActiveToolCondition =
172  [ this ] ( const SELECTION& aSelection )
173  {
174  return frame()->ToolStackIsEmpty();
175  };
176 
177  auto notMovingCondition =
178  [ this ] ( const SELECTION& aSelection )
179  {
182  };
183 
184  // Add context menu entries that are displayed when selection tool is active
186 
187  menu.AddItem( PCB_ACTIONS::move, SELECTION_CONDITIONS::NotEmpty && notMovingCondition );
195  menu.AddItem( PCB_ACTIONS::mirror, editingModuleCondition && SELECTION_CONDITIONS::NotEmpty );
196 
200 
202 
203  // Add the submenu for create array and special move
204  auto specialToolsSubMenu = std::make_shared<SPECIAL_TOOLS_CONTEXT_MENU>();
205  specialToolsSubMenu->SetTool( this );
206  menu.AddSeparator();
207  m_selectionTool->GetToolMenu().AddSubMenu( specialToolsSubMenu );
208  menu.AddMenu( specialToolsSubMenu.get(), SELECTION_CONDITIONS::NotEmpty );
209 
210  menu.AddSeparator();
213  // Selection tool handles the context menu for some other tools, such as the Picker.
214  // Don't add things like Paste when another tool is active.
215  menu.AddItem( ACTIONS::paste, noActiveToolCondition );
216 
217  // Footprint actions
218  menu.AddSeparator();
219  menu.AddItem( PCB_ACTIONS::editFpInFpEditor, singleModuleCondition );
220  menu.AddItem( PCB_ACTIONS::updateFootprint, singleModuleCondition );
221  menu.AddItem( PCB_ACTIONS::changeFootprint, singleModuleCondition );
222 
223  return true;
224 }
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
bool IsCurrentTool(const TOOL_ACTION &aAction) const
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:313
static TOOL_ACTION editFpInFpEditor
Definition: pcb_actions.h:323
static TOOL_ACTION doDelete
Definition: actions.h:74
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Function OnlyTypes Creates a functor that tests if the selected items are only of given types.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:133
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:112
TOOL_MENU & GetToolMenu()
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:132
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:106
static TOOL_ACTION changeFootprint
Definition: pcb_actions.h:303
static TOOL_ACTION updateFootprint
Definition: pcb_actions.h:301
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
static SELECTION_CONDITION Count(int aNumber)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
static bool NotEmpty(const SELECTION &aSelection)
Function NotEmpty Tests if there are any items selected.
PCB_BASE_EDIT_FRAME * frame() const
class MODULE, a footprint
Definition: typeinfo.h:89
static TOOL_ACTION copy
Definition: actions.h:70
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:99
static TOOL_ACTION cut
Definition: actions.h:69
bool ToolStackIsEmpty()
Definition: tools_holder.h:84
static TOOL_ACTION inlineBreakTrack
Breaks track when router is not activated.
Definition: pcb_actions.h:130
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:100
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:103
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Function CreateSubMenu.
Definition: tool_menu.cpp:52
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Function OnlyType Creates a functor that tests if the selected items are only of given type.
static TOOL_ACTION moveWithReference
move with a reference point
Definition: pcb_actions.h:96
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
static TOOL_ACTION paste
Definition: actions.h:71
static TOOL_ACTION duplicate
Definition: actions.h:73

References CONDITIONAL_MENU::AddItem(), CONDITIONAL_MENU::AddMenu(), CONDITIONAL_MENU::AddSeparator(), TOOL_MENU::AddSubMenu(), PCB_ACTIONS::changeFootprint, ACTIONS::copy, SELECTION_CONDITIONS::Count(), ACTIONS::cut, ACTIONS::doDelete, PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, ACTIONS::duplicate, PCB_ACTIONS::editFpInFpEditor, TOOL_MANAGER::FindTool(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), TOOL_MENU::GetMenu(), TOOL_INTERACTIVE::GetToolMenu(), PCB_ACTIONS::inlineBreakTrack, TOOLS_HOLDER::IsCurrentTool(), PCB_TOOL_BASE::m_editModules, m_selectionTool, TOOL_BASE::m_toolMgr, PCB_ACTIONS::mirror, PCB_ACTIONS::move, PCB_ACTIONS::moveWithReference, SELECTION_CONDITIONS::NotEmpty(), SELECTION_CONDITIONS::OnlyType(), SELECTION_CONDITIONS::OnlyTypes(), ACTIONS::paste, PCB_MODULE_T, PCB_ACTIONS::properties, PCB_ACTIONS::rotateCcw, PCB_ACTIONS::rotateCw, TOOLS_HOLDER::ToolStackIsEmpty(), GENERAL_COLLECTOR::Tracks, and PCB_ACTIONS::updateFootprint.

◆ invokeInlineRouter()

bool EDIT_TOOL::invokeInlineRouter ( int  aDragMode)
private

Definition at line 245 of file edit_tool.cpp.

246 {
248 
249  if( !theRouter )
250  return false;
251 
252  // don't allow switch from moving to dragging
253  if( m_dragging )
254  {
255  wxBell();
256  return false;
257  }
258 
259  // make sure we don't accidentally invoke inline routing mode while the router is already active!
260  if( theRouter->IsToolActive() )
261  return false;
262 
263  if( theRouter->CanInlineDrag() )
264  {
266  return true;
267  }
268 
269  return false;
270 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
bool m_dragging
Definition: edit_tool.h:195
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:194
static ROUTER * theRouter
Definition: pns_router.cpp:63

References TOOL_MANAGER::GetTool(), m_dragging, TOOL_BASE::m_toolMgr, PCB_ACTIONS::routerInlineDrag, TOOL_MANAGER::RunAction(), and PNS::theRouter.

Referenced by doMoveSelection(), and Drag().

◆ isInteractiveDragEnabled()

bool EDIT_TOOL::isInteractiveDragEnabled ( ) const
private

Definition at line 273 of file edit_tool.cpp.

274 {
276 
277  return router && router->Router()->Settings().InlineDragEnabled();
278 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
ROUTER * Router() const
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:202

References TOOL_MANAGER::GetTool(), PNS::ROUTING_SETTINGS::InlineDragEnabled(), TOOL_BASE::m_toolMgr, PNS::TOOL_BASE::Router(), and PNS::ROUTER::Settings().

Referenced by doMoveSelection().

◆ isRouterActive()

bool EDIT_TOOL::isRouterActive ( ) const
private

Definition at line 281 of file edit_tool.cpp.

282 {
284 
285  return router && router->IsToolActive();
286 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool IsToolActive() const
Definition: tool_base.cpp:31

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

Referenced by CreateArray(), Duplicate(), Flip(), Mirror(), Move(), MoveExact(), MoveWithReference(), Remove(), and Rotate().

◆ 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:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
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.

Referenced by isRouterActive(), and ROUTER_TOOL::onViaCommand().

◆ Mirror()

int EDIT_TOOL::Mirror ( const TOOL_EVENT aEvent)

Function Mirror Mirrors the current selection.

The mirror axis passes through the current point.

Definition at line 813 of file edit_tool.cpp.

814 {
815  if( isRouterActive() )
816  {
817  wxBell();
818  return 0;
819  }
820 
822  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
823  {
825  },
826  nullptr, !m_dragging );
827 
828  if( selection.Empty() )
829  return 0;
830 
832  auto refPoint = selection.GetReferencePoint();
833  wxPoint mirrorPoint( refPoint.x, refPoint.y );
834 
835  // When editing modules, all items have the same parent
836  if( EditingModules() )
837  m_commit->Modify( selection.Front() );
838 
839  for( EDA_ITEM* item : selection )
840  {
841  // only modify items we can mirror
842  switch( item->Type() )
843  {
844  case PCB_MODULE_EDGE_T:
845  case PCB_MODULE_TEXT_T:
847  case PCB_PAD_T:
848  // Only create undo entry for items on the board
849  if( !item->IsNew() && !EditingModules() )
850  m_commit->Modify( item );
851 
852  break;
853  default:
854  continue;
855  }
856 
857  // modify each object as necessary
858  switch( item->Type() )
859  {
860  case PCB_MODULE_EDGE_T:
861  {
862  auto& edge = static_cast<EDGE_MODULE&>( *item );
863  edge.Mirror( mirrorPoint, false );
864  break;
865  }
866 
868  {
869  auto& zone = static_cast<MODULE_ZONE_CONTAINER&>( *item );
870  zone.Mirror( mirrorPoint, false );
871  break;
872  }
873 
874  case PCB_MODULE_TEXT_T:
875  {
876  auto& modText = static_cast<TEXTE_MODULE&>( *item );
877  modText.Mirror( mirrorPoint, false );
878  break;
879  }
880 
881  case PCB_PAD_T:
882  {
883  auto& pad = static_cast<D_PAD&>( *item );
884  mirrorPadX( pad, mirrorPoint );
885  break;
886  }
887 
888  default:
889  // it's likely the commit object is wrong if you get here
890  assert( false );
891  break;
892  }
893  }
894 
895  if( !m_dragging )
896  m_commit->Push( _( "Mirror" ) );
897 
898  if( selection.IsHover() && !m_dragging )
900 
902 
903  if( m_dragging )
905 
906  return 0;
907 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
VECTOR2I GetReferencePoint() const
Definition: selection.h:240
bool IsHover() const
Definition: selection.h:71
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:199
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:207
const PCBNEW_SELECTION & selection() const
bool m_dragging
Definition: edit_tool.h:195
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
bool EditingModules() const
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
#define _(s)
Definition: 3d_actions.cpp:33
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
bool isRouterActive() const
Definition: edit_tool.cpp:281
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:425
class ZONE_CONTAINER, managed by a footprint
Definition: typeinfo.h:95
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
bool updateModificationPoint(PCBNEW_SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1417
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:61
static void mirrorPadX(D_PAD &aPad, const wxPoint &aMirrorPoint)
Mirror a pad in the vertical axis passing through a point (mirror left to right)
Definition: edit_tool.cpp:791
EDA_ITEM * Front() const
Definition: selection.h:184

References _, PCB_TOOL_BASE::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, SELECTION::Front(), SELECTION::GetReferencePoint(), SELECTION::IsHover(), isRouterActive(), m_commit, m_dragging, m_selectionTool, TOOL_BASE::m_toolMgr, mirrorPadX(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, PCB_MODULE_ZONE_AREA_T, PCB_PAD_T, TOOL_MANAGER::ProcessEvent(), SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::updateLocalRatsnest, and updateModificationPoint().

Referenced by setTransitions().

◆ module()

◆ Move()

int EDIT_TOOL::Move ( const TOOL_EVENT aEvent)

Function Move() Main loop in which events are handled.

Definition at line 302 of file edit_tool.cpp.

303 {
304  if( isRouterActive() )
305  {
306  wxBell();
307  return 0;
308  }
309 
310  return doMoveSelection( aEvent );
311 }
int doMoveSelection(const TOOL_EVENT &aEvent, bool aPickReference=false)
Definition: edit_tool.cpp:326
bool isRouterActive() const
Definition: edit_tool.cpp:281

References doMoveSelection(), and isRouterActive().

Referenced by Duplicate(), and setTransitions().

◆ MoveExact()

int EDIT_TOOL::MoveExact ( const TOOL_EVENT aEvent)

Function MoveExact() Invokes a dialog box to allow moving of the item by an exact amount.

Definition at line 1162 of file edit_tool.cpp.

1163 {
1164  if( isRouterActive() )
1165  {
1166  wxBell();
1167  return 0;
1168  }
1169 
1171  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1172  {
1173  EditToolSelectionFilter( aCollector,
1175  } );
1176 
1177  if( selection.Empty() )
1178  return 0;
1179 
1180  wxPoint translation;
1181  double rotation;
1182  ROTATION_ANCHOR rotationAnchor = selection.Size() > 1 ? ROTATE_AROUND_SEL_CENTER
1184 
1185  // TODO: Implement a visible bounding border at the edge
1186  auto sel_box = selection.GetBoundingBox();
1187 
1188  DIALOG_MOVE_EXACT dialog( frame(), translation, rotation, rotationAnchor, sel_box );
1189  int ret = dialog.ShowModal();
1190 
1191  if( ret == wxID_OK )
1192  {
1193  VECTOR2I rp = selection.GetCenter();
1194  wxPoint selCenter( rp.x, rp.y );
1195 
1196  // Make sure the rotation is from the right reference point
1197  selCenter += translation;
1198 
1199  // When editing modules, all items have the same parent
1200  if( EditingModules() )
1201  m_commit->Modify( selection.Front() );
1202 
1203  for( EDA_ITEM* selItem : selection )
1204  {
1205  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selItem );
1206 
1207  if( !item->IsNew() && !EditingModules() )
1208  m_commit->Modify( item );
1209 
1210  item->Move( translation );
1211 
1212  switch( rotationAnchor )
1213  {
1215  item->Rotate( item->GetPosition(), rotation );
1216  break;
1218  item->Rotate( selCenter, rotation );
1219  break;
1221  item->Rotate( (wxPoint) frame()->GetScreen()->m_LocalOrigin, rotation );
1222  break;
1224  item->Rotate( board()->GetDesignSettings().m_AuxOrigin, rotation );
1225  break;
1226  }
1227 
1228  if( !m_dragging )
1229  getView()->Update( item );
1230  }
1231 
1232  m_commit->Push( _( "Move exact" ) );
1233 
1234  if( selection.IsHover() )
1236 
1238 
1239  if( m_dragging )
1241  }
1242 
1243  return 0;
1244 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
bool IsHover() const
Definition: selection.h:71
BOARD * board() const
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:199
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.h:138
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:207
bool IsNew() const
Definition: base_struct.h:199
PCB_BASE_EDIT_FRAME * frame() const
const PCBNEW_SELECTION & selection() const
bool m_dragging
Definition: edit_tool.h:195
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
virtual void Rotate(const wxPoint &aRotCentre, double aAngle)
Function Rotate Rotate this object.
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1544
ROTATION_ANCHOR
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
bool EditingModules() const
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
#define _(s)
Definition: 3d_actions.cpp:33
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:127
bool isRouterActive() const
Definition: edit_tool.cpp:281
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:53
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:425
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:61
EDA_RECT GetBoundingBox() const
Definition: selection.h:156
EDA_ITEM * Front() const
Definition: selection.h:184

References _, PCB_TOOL_BASE::board(), PCB_TOOL_BASE::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED, EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, PCB_TOOL_BASE::frame(), SELECTION::Front(), SELECTION::GetBoundingBox(), SELECTION::GetCenter(), EDA_ITEM::GetPosition(), TOOL_BASE::getView(), SELECTION::IsHover(), EDA_ITEM::IsNew(), isRouterActive(), m_commit, m_dragging, m_selectionTool, TOOL_BASE::m_toolMgr, BOARD_ITEM::Move(), TOOL_MANAGER::ProcessEvent(), SELECTION_TOOL::RequestSelection(), BOARD_ITEM::Rotate(), ROTATE_AROUND_AUX_ORIGIN, ROTATE_AROUND_ITEM_ANCHOR, ROTATE_AROUND_SEL_CENTER, ROTATE_AROUND_USER_ORIGIN, TOOL_MANAGER::RunAction(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, SELECTION::Size(), KIGFX::VIEW::Update(), PCB_ACTIONS::updateLocalRatsnest, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

◆ MoveWithReference()

int EDIT_TOOL::MoveWithReference ( const TOOL_EVENT aEvent)

Moves an item but with a reference point selected first.

Definition at line 314 of file edit_tool.cpp.

315 {
316  if( isRouterActive() )
317  {
318  wxBell();
319  return 0;
320  }
321 
322  return doMoveSelection( aEvent, true );
323 }
int doMoveSelection(const TOOL_EVENT &aEvent, bool aPickReference=false)
Definition: edit_tool.cpp:326
bool isRouterActive() const
Definition: edit_tool.cpp:281

References doMoveSelection(), and isRouterActive().

Referenced by setTransitions().

◆ PadFilter()

void EDIT_TOOL::PadFilter ( const VECTOR2I ,
GENERAL_COLLECTOR aCollector 
)
static

Function PadFilter() A selection filter which prunes the selection to contain only items of type PCB_PAD_T.

Definition at line 1393 of file edit_tool.cpp.

1394 {
1395  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1396  {
1397  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
1398 
1399  if( item->Type() != PCB_PAD_T )
1400  aCollector.Remove( i );
1401  }
1402 }
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
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:130
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:101
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References COLLECTOR::GetCount(), PCB_PAD_T, COLLECTOR::Remove(), and EDA_ITEM::Type().

Referenced by PCB_INSPECTION_TOOL::LocalRatsnestTool().

◆ pickReferencePoint()

bool EDIT_TOOL::pickReferencePoint ( const wxString &  aTooltip,
const wxString &  aSuccessMessage,
const wxString &  aCanceledMessage,
VECTOR2I aReferencePoint 
)
private

Definition at line 1440 of file edit_tool.cpp.

1442 {
1443  std::string tool = "pcbnew.InteractiveEdit.selectReferencePoint";
1444  STATUS_TEXT_POPUP statusPopup( frame() );
1446  OPT<VECTOR2I> pickedPoint;
1447  bool done = false;
1448 
1449  statusPopup.SetText( aTooltip );
1450 
1451  picker->SetClickHandler(
1452  [&]( const VECTOR2D& aPoint ) -> bool
1453  {
1454  pickedPoint = aPoint;
1455 
1456  if( !aSuccessMessage.empty() )
1457  {
1458  statusPopup.SetText( aSuccessMessage );
1459  statusPopup.Expire( 800 );
1460  }
1461  else
1462  {
1463  statusPopup.Hide();
1464  }
1465 
1466  return false; // we don't need any more points
1467  } );
1468 
1469  picker->SetMotionHandler(
1470  [&]( const VECTOR2D& aPos )
1471  {
1472  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
1473  } );
1474 
1475  picker->SetCancelHandler(
1476  [&]()
1477  {
1478  if( !aCanceledMessage.empty() )
1479  {
1480  statusPopup.SetText( aCanceledMessage );
1481  statusPopup.Expire( 800 );
1482  }
1483  else
1484  {
1485  statusPopup.Hide();
1486  }
1487  } );
1488 
1489  picker->SetFinalizeHandler(
1490  [&]( const int& aFinalState )
1491  {
1492  done = true;
1493  } );
1494 
1495  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
1496  statusPopup.Popup();
1497 
1498  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1499 
1500  while( !done )
1501  Wait();
1502 
1503  // Ensure statusPopup is hidden after use and before deleting it:
1504  statusPopup.Hide();
1505 
1506  if( pickedPoint.is_initialized() )
1507  aReferencePoint = pickedPoint.get();
1508 
1509  return pickedPoint.is_initialized();
1510 }
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
static TOOL_ACTION pickerTool
Definition: actions.h:149
PCB_BASE_EDIT_FRAME * frame() const
Generic tool for picking a point.
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
boost::optional< T > OPT
Definition: optional.h:7
void SetCancelHandler(CANCEL_HANDLER aHandler)
Function SetCancelHandler() Sets a handler for cancel events (ESC or context-menu Cancel).
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.

References STATUS_POPUP::Expire(), PCB_TOOL_BASE::frame(), TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, STATUS_POPUP::Move(), ACTIONS::pickerTool, STATUS_POPUP::Popup(), TOOL_MANAGER::RunAction(), PCBNEW_PICKER_TOOL::SetCancelHandler(), PCBNEW_PICKER_TOOL::SetClickHandler(), PCBNEW_PICKER_TOOL::SetFinalizeHandler(), PCBNEW_PICKER_TOOL::SetMotionHandler(), STATUS_TEXT_POPUP::SetText(), and TOOL_INTERACTIVE::Wait().

Referenced by copyToClipboard(), and doMoveSelection().

◆ Properties()

int EDIT_TOOL::Properties ( const TOOL_EVENT aEvent)

Function Properties() Displays properties window for the selected object.

Definition at line 675 of file edit_tool.cpp.

676 {
677  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
679  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
680  {
682  } );
683 
684  // Tracks & vias are treated in a special way:
686  {
687  DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection, *m_commit );
688  dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR
689  }
690  else if( selection.Size() == 1 )
691  {
692  // Display properties dialog
693  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
694 
695  // Do not handle undo buffer, it is done by the properties dialogs
696  editFrame->OnEditItemRequest( item );
697 
698  // Notify other tools of the changes
700  }
701  else if( selection.Size() == 0 && getView()->IsLayerVisible( LAYER_WORKSHEET ) )
702  {
703  KIGFX::WS_PROXY_VIEW_ITEM* worksheet = editFrame->GetCanvas()->GetWorksheet();
704  VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
705 
706  if( worksheet && worksheet->HitTestWorksheetItems( getView(), (wxPoint) cursorPos ) )
708  }
709 
710  if( selection.IsHover() )
711  {
713 
714  // Notify other tools of the changes -- This updates the visual ratsnest
716  }
717 
718  return 0;
719 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
bool IsHover() const
Definition: selection.h:71
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:313
static TOOL_ACTION pageSettings
Definition: actions.h:59
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:199
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Function OnlyTypes Creates a functor that tests if the selected items are only of given types.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void OnEditItemRequest(BOARD_ITEM *aItem)=0
Function OnEditItemRequest Install the corresponding dialog editor for the given item.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:207
bool HitTestWorksheetItems(VIEW *aView, const wxPoint &aPosition)
const PCBNEW_SELECTION & selection() const
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
KIGFX::WS_PROXY_VIEW_ITEM * GetWorksheet() const
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
Common, abstract interface for edit frames.
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:127
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:61
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:184
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:416

References EditToolSelectionFilter(), EXCLUDE_TRANSIENTS, SELECTION::Front(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), PCB_DRAW_PANEL_GAL::GetWorksheet(), KIGFX::WS_PROXY_VIEW_ITEM::HitTestWorksheetItems(), SELECTION::IsHover(), KIGFX::VIEW::IsLayerVisible(), LAYER_WORKSHEET, m_commit, m_selectionTool, TOOL_BASE::m_toolMgr, PCB_BASE_EDIT_FRAME::OnEditItemRequest(), SELECTION_CONDITIONS::OnlyTypes(), ACTIONS::pageSettings, TOOL_MANAGER::ProcessEvent(), SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, DIALOG_SHIM::ShowQuasiModal(), SELECTION::Size(), and GENERAL_COLLECTOR::Tracks.

Referenced by setTransitions().

◆ Remove()

int EDIT_TOOL::Remove ( const TOOL_EVENT aEvent)

Function Remove() Deletes currently selected items.

The rotation point is the current cursor position.

Popup nag for deleting locked items

Definition at line 967 of file edit_tool.cpp.

968 {
969  if( isRouterActive() )
970  {
971  wxBell();
972  return 0;
973  }
974 
975  ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
976 
977  // Do not delete items while actively routing.
978  if( routerTool && routerTool->Router() && routerTool->Router()->RoutingInProgress() )
979  return 1;
980 
981  std::vector<BOARD_ITEM*> lockedItems;
982  Activate();
983 
984  // get a copy instead of reference (as we're going to clear the selection before removing items)
985  PCBNEW_SELECTION selectionCopy;
988 
989  // If we are in a "Cut" operation, then the copied selection exists already
990  if( isCut )
991  {
992  selectionCopy = m_selectionTool->GetSelection();
993  }
994  else
995  {
996  selectionCopy = m_selectionTool->RequestSelection(
997  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
998  {
1000  } );
1001  }
1002 
1003  bool isHover = selectionCopy.IsHover();
1004 
1005  // in "alternative" mode, deletion is not just a simple list of selected items,
1006  // it removes whole tracks, not just segments
1007  if( isAlt && isHover
1008  && ( selectionCopy.HasType( PCB_TRACE_T ) || selectionCopy.HasType( PCB_VIA_T ) ) )
1009  {
1011  }
1012 
1013  if( selectionCopy.Empty() )
1014  return 0;
1015 
1016  // N.B. Setting the CUT flag prevents lock filtering as we only want to delete the items that
1017  // were copied to the clipboard, no more, no fewer. Filtering for locked item, if any will be done
1018  // in the copyToClipboard() routine
1019  if( !m_lockedSelected && !isCut )
1020  {
1021  // Second RequestSelection removes locked items but keeps a copy of their pointers
1022  selectionCopy = m_selectionTool->RequestSelection(
1023  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1024  {
1025  EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED );
1026  },
1027  &lockedItems );
1028  }
1029 
1030 
1031  // As we are about to remove items, they have to be removed from the selection first
1033 
1034  for( EDA_ITEM* item : selectionCopy )
1035  {
1036  if( m_editModules )
1037  {
1038  m_commit->Remove( item );
1039  continue;
1040  }
1041 
1042  switch( item->Type() )
1043  {
1044  case PCB_MODULE_TEXT_T:
1045  {
1046  auto text = static_cast<TEXTE_MODULE*>( item );
1047  auto parent = static_cast<MODULE*>( item->GetParent() );
1048 
1049  if( text->GetType() == TEXTE_MODULE::TEXT_is_DIVERS )
1050  {
1051  m_commit->Modify( text );
1052  getView()->Remove( text );
1053  parent->Remove( text );
1054  }
1055  }
1056  break;
1057 
1058  case PCB_PAD_T:
1059  {
1060  auto pad = static_cast<D_PAD*>( item );
1061  auto parent = static_cast<MODULE*>( item->GetParent() );
1062 
1063  m_commit->Modify( parent );
1064  getView()->Remove( pad );
1065  parent->Remove( pad );
1066  }
1067  break;
1068 
1070  {
1071  auto zone = static_cast<MODULE_ZONE_CONTAINER*>( item );
1072  auto parent = static_cast<MODULE*>( item->GetParent() );
1073 
1074  m_commit->Modify( parent );
1075  getView()->Remove( zone );
1076  parent->Remove( zone );
1077  }
1078  break;
1079 
1080  case PCB_ZONE_AREA_T:
1081  // We process the zones special so that cutouts can be deleted when the delete tool
1082  // is called from inside a cutout when the zone is selected.
1083  {
1084  // Only interact with cutouts when deleting and a single item is selected
1085  if( !isCut && selectionCopy.GetSize() == 1 )
1086  {
1088  auto zone = static_cast<ZONE_CONTAINER*>( item );
1089 
1090  int outlineIdx, holeIdx;
1091 
1092  if( zone->HitTestCutout( curPos, &outlineIdx, &holeIdx ) )
1093  {
1094  // Remove the cutout
1095  m_commit->Modify( zone );
1096  zone->RemoveCutout( outlineIdx, holeIdx );
1097 
1098  std::vector<ZONE_CONTAINER*> toFill;
1099  toFill.emplace_back( zone );
1100 
1101  // Fill the modified zone
1102  ZONE_FILLER filler( board() );
1103  filler.InstallNewProgressReporter( frame(), _( "Fill Zone" ), 4 );
1104  filler.Fill( toFill );
1105 
1106  // Update the display
1107  zone->HatchBorder();
1108  canvas()->Refresh();
1109 
1110  // Restore the selection on the original zone
1112 
1113  break;
1114  }
1115  }
1116 
1117  // Remove the entire zone otherwise
1118  m_commit->Remove( item );
1119  }
1120  break;
1121 
1122  default:
1123  m_commit->Remove( item );
1124  break;
1125  }
1126  }
1127 
1128  if( isCut )
1129  m_commit->Push( _( "Cut" ) );
1130  else
1131  m_commit->Push( _( "Delete" ) );
1132 
1133  if( !m_lockedSelected && !lockedItems.empty() )
1134  {
1136  STATUS_TEXT_POPUP statusPopup( frame() );
1137 
1138  m_lockedSelected = true;
1139  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &lockedItems );
1140  statusPopup.SetText( _( "Delete again to remove locked items" ) );
1141  statusPopup.PopupFor( 2000 );
1142  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1143 
1144  Activate();
1145 
1146  while( m_lockedSelected && statusPopup.IsShown() )
1147  {
1148  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1149  Wait();
1150  }
1151 
1152  // Ensure statusPopup is hidden after use and before deleting it:
1153  statusPopup.Hide();
1154  }
1155 
1156  m_lockedSelected = false;
1157 
1158  return 0;
1159 }
static TOOL_ACTION selectItems
Selects a list of items (specified as the event parameter)
Definition: pcb_actions.h:69
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
bool IsHover() const
Definition: selection.h:71
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
BOARD * board() const
REMOVE_FLAGS
Remove event modifier flags
Definition: actions.h:191
bool HasType(KICAD_T aType) const
Checks if there is at least one item of requested kind.
Definition: selection.h:214
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:199
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:380
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
static TOOL_ACTION selectConnection
Selects tracks between junctions or expands an existing selection to pads or the entire connection.
Definition: pcb_actions.h:77
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
PCB_BASE_EDIT_FRAME * frame() const
bool m_lockedSelected
Definition: edit_tool.h:196
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
#define _(s)
Definition: 3d_actions.cpp:33
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:65
bool isRouterActive() const
Definition: edit_tool.cpp:281
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
void Activate()
Function Activate() Runs the tool.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:53
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
class ZONE_CONTAINER, managed by a footprint
Definition: typeinfo.h:95
bool RoutingInProgress() const
Definition: pns_router.cpp:120
ROUTER * Router() const
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
PCB_DRAW_PANEL_GAL * canvas() const
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:61
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

References _, TOOL_INTERACTIVE::Activate(), ACTIONS::ALT, PCB_TOOL_BASE::board(), PCB_TOOL_BASE::canvas(), ACTIONS::CUT, EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED, EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, ZONE_FILLER::Fill(), PCB_TOOL_BASE::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), SELECTION::HasType(), ZONE_FILLER::InstallNewProgressReporter(), SELECTION::IsHover(), isRouterActive(), m_commit, PCB_TOOL_BASE::m_editModules, m_lockedSelected, m_selectionTool, TOOL_BASE::m_toolMgr, STATUS_POPUP::Move(), TOOL_EVENT::Parameter(), PCB_MODULE_TEXT_T, PCB_MODULE_ZONE_AREA_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, STATUS_POPUP::PopupFor(), EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::VIEW::Remove(), SELECTION_TOOL::RequestSelection(), PNS::TOOL_BASE::Router(), PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectConnection, PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, PCB_ACTIONS::selectItems, STATUS_TEXT_POPUP::SetText(), TEXTE_MODULE::TEXT_is_DIVERS, and TOOL_INTERACTIVE::Wait().

Referenced by cutToClipboard(), and setTransitions().

◆ Reset()

void EDIT_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

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.

Reimplemented from PCB_TOOL_BASE.

Definition at line 125 of file edit_tool.cpp.

126 {
127  m_dragging = false;
128 
129  if( aReason != RUN )
130  m_commit.reset( new BOARD_COMMIT( this ) );
131 }
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:199
Tool is invoked after being inactive.
Definition: tool_base.h:81
bool m_dragging
Definition: edit_tool.h:195

References m_commit, m_dragging, and TOOL_BASE::RUN.

◆ Rotate()

int EDIT_TOOL::Rotate ( const TOOL_EVENT aEvent)

Function Rotate() Rotates currently selected items.

Definition at line 722 of file edit_tool.cpp.

723 {
724  if( isRouterActive() )
725  {
726  wxBell();
727  return 0;
728  }
729 
730  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
731 
733  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
734  {
736  },
737  nullptr, ! m_dragging );
738 
739  if( selection.Empty() )
740  return 0;
741 
743  auto refPt = selection.GetReferencePoint();
744  const int rotateAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *editFrame, aEvent );
745 
746  // When editing modules, all items have the same parent
747  if( EditingModules() )
748  m_commit->Modify( selection.Front() );
749 
750  for( auto item : selection )
751  {
752  if( !item->IsNew() && !EditingModules() )
753  m_commit->Modify( item );
754 
755  static_cast<BOARD_ITEM*>( item )->Rotate( refPt, rotateAngle );
756  }
757 
758  if( !m_dragging )
759  m_commit->Push( _( "Rotate" ) );
760 
761  if( selection.IsHover() && !m_dragging )
763 
765 
766  if( m_dragging )
768 
769  return 0;
770 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
VECTOR2I GetReferencePoint() const
Definition: selection.h:240
bool IsHover() const
Definition: selection.h:71
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:199
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:207
const PCBNEW_SELECTION & selection() const
bool m_dragging
Definition: edit_tool.h:195
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
bool EditingModules() const
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
Common, abstract interface for edit frames.
#define _(s)
Definition: 3d_actions.cpp:33
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
bool isRouterActive() const
Definition: edit_tool.cpp:281
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:425
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
bool updateModificationPoint(PCBNEW_SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1417
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:61
EDA_ITEM * Front() const
Definition: selection.h:184

References _, PCB_TOOL_BASE::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, SELECTION::Front(), TOOL_EVT_UTILS::GetEventRotationAngle(), SELECTION::GetReferencePoint(), SELECTION::IsHover(), isRouterActive(), m_commit, m_dragging, m_selectionTool, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::updateLocalRatsnest, and updateModificationPoint().

Referenced by setTransitions().

◆ 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 87 of file tool_interactive.cpp.

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

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

Referenced by DRAWING_TOOL::PlaceText().

◆ selection() [1/2]

const PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 275 of file pcb_tool_base.cpp.

276 {
277  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
278  const auto& selection = selTool->GetSelection();
279  return selection;
280 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
const PCBNEW_SELECTION & selection() const

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

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), copyToClipboard(), CreateArray(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), PCB_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), doMoveSelection(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), Duplicate(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::filterSelection(), Flip(), DRAWING_TOOL::getSourceZoneForAction(), PCB_INSPECTION_TOOL::highlightNet(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), MoveExact(), POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), PCBNEW_CONTROL::placeBoardItems(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), Properties(), PAD_TOOL::pushPadSettings(), GLOBAL_EDIT_TOOL::RemoveUnusedPads(), Rotate(), PCB_TOOL_BASE::selection(), SELECTION_TOOL::selectNet(), DRAWING_TOOL::SetAnchor(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCB_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 283 of file pcb_tool_base.cpp.

284 {
285  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
286  auto& selection = selTool->GetSelection();
287  return selection;
288 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
const PCBNEW_SELECTION & selection() const

References TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, and PCB_TOOL_BASE::selection().

◆ SetContextMenu()

void TOOL_INTERACTIVE::SetContextMenu ( ACTION_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 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:219
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour 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(), SELECTION_TOOL::doSelectionMenu(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ SetEditModules()

void PCB_TOOL_BASE::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

Toggles edit module mode. When enabled, one may select parts of modules individually (graphics, pads, etc.), so they can be modified.

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 101 of file pcb_tool_base.h.

102  {
103  m_editModules = aEnabled;
104  }

References PCB_TOOL_BASE::m_editModules.

◆ setTransitions()

void EDIT_TOOL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL_BASE.

Definition at line 1560 of file edit_tool.cpp.

1561 {
1563  Go( &EDIT_TOOL::Move, PCB_ACTIONS::move.MakeEvent() );
1564  Go( &EDIT_TOOL::Move, PCB_ACTIONS::drag.MakeEvent() );
1565  Go( &EDIT_TOOL::Drag, PCB_ACTIONS::drag45Degree.MakeEvent() );
1567  Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCw.MakeEvent() );
1568  Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCcw.MakeEvent() );
1569  Go( &EDIT_TOOL::Flip, PCB_ACTIONS::flip.MakeEvent() );
1570  Go( &EDIT_TOOL::Remove, ACTIONS::doDelete.MakeEvent() );
1571  Go( &EDIT_TOOL::Remove, PCB_ACTIONS::deleteFull.MakeEvent() );
1575  Go( &EDIT_TOOL::Duplicate, ACTIONS::duplicate.MakeEvent() );
1578  Go( &EDIT_TOOL::Mirror, PCB_ACTIONS::mirror.MakeEvent() );
1580 
1581  Go( &EDIT_TOOL::copyToClipboard, ACTIONS::copy.MakeEvent() );
1582  Go( &EDIT_TOOL::cutToClipboard, ACTIONS::cut.MakeEvent() );
1583 }
int Properties(const TOOL_EVENT &aEvent)
Function Properties() Displays properties window for the selected object.
Definition: edit_tool.cpp:675
int Rotate(const TOOL_EVENT &aEvent)
Function Rotate() Rotates currently selected items.
Definition: edit_tool.cpp:722
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
static TOOL_ACTION deleteFull
Definition: pcb_actions.h:122
static TOOL_ACTION changeTrackWidth
Updates selected tracks & vias to the current track & via dimensions.
Definition: pcb_actions.h:109
static TOOL_ACTION doDelete
Definition: actions.h:74
int ChangeTrackWidth(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:620
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:133
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:112
static TOOL_ACTION getAndPlace
Find an item and start moving.
Definition: pcb_actions.h:431
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:132
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:106
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int Mirror(const TOOL_EVENT &aEvent)
Function Mirror Mirrors the current selection.
Definition: edit_tool.cpp:813
static TOOL_ACTION moveExact
Activation of the exact move tool.
Definition: pcb_actions.h:115
int cutToClipboard(const TOOL_EVENT &aEvent)
Function cutToClipboard() Cuts the current selection to the clipboard by formatting it as a fake pcb ...
Definition: edit_tool.cpp:1544
static TOOL_ACTION copy
Definition: actions.h:70
int Flip(const TOOL_EVENT &aEvent)
Function Flip() Rotates currently selected items.
Definition: edit_tool.cpp:910
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
Definition: pcb_actions.h:118
int GetAndPlace(const TOOL_EVENT &aEvent)
Find an item and start moving.
Definition: edit_tool.cpp:227
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:99
static TOOL_ACTION createArray
Tool for creating an array of objects.
Definition: pcb_actions.h:365
static TOOL_ACTION cut
Definition: actions.h:69
int MoveWithReference(const TOOL_EVENT &aEvent)
Moves an item but with a reference point selected first.
Definition: edit_tool.cpp:314
int Drag(const TOOL_EVENT &aEvent)
Function Drag() Invoke the PNS router to drag tracks.
Definition: edit_tool.cpp:289
int Move(const TOOL_EVENT &aEvent)
Function Move() Main loop in which events are handled.
Definition: edit_tool.cpp:302
static TOOL_ACTION drag
Definition: pcb_actions.h:93
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:100
int MoveExact(const TOOL_EVENT &aEvent)
Function MoveExact() Invokes a dialog box to allow moving of the item by an exact amount.
Definition: edit_tool.cpp:1162
int Remove(const TOOL_EVENT &aEvent)
Function Remove() Deletes currently selected items.
Definition: edit_tool.cpp:967
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:103
int CreateArray(const TOOL_EVENT &aEvent)
Function CreateArray() Creates an array of the selected items, invoking the array editor dialog to se...
Definition: edit_tool.cpp:1367
int copyToClipboard(const TOOL_EVENT &aEvent)
Function copyToClipboard() Sends the current selection to the clipboard by formatting it as a fake pc...
Definition: edit_tool.cpp:1513
static TOOL_ACTION moveWithReference
move with a reference point
Definition: pcb_actions.h:96
int Duplicate(const TOOL_EVENT &aEvent)
Function Duplicate() Duplicates the current selection and starts a move action.
Definition: edit_tool.cpp:1247
static TOOL_ACTION duplicate
Definition: actions.h:73

References PCB_ACTIONS::changeTrackWidth, ChangeTrackWidth(), ACTIONS::copy, copyToClipboard(), CreateArray(), PCB_ACTIONS::createArray, ACTIONS::cut, cutToClipboard(), PCB_ACTIONS::deleteFull, ACTIONS::doDelete, Drag(), PCB_ACTIONS::drag, PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, ACTIONS::duplicate, Duplicate(), PCB_ACTIONS::duplicateIncrement, PCB_ACTIONS::flip, Flip(), GetAndPlace(), PCB_ACTIONS::getAndPlace, TOOL_INTERACTIVE::Go(), PCB_ACTIONS::mirror, Mirror(), Move(), PCB_ACTIONS::move, PCB_ACTIONS::moveExact, MoveExact(), PCB_ACTIONS::moveWithReference, MoveWithReference(), Properties(), PCB_ACTIONS::properties, Remove(), Rotate(), PCB_ACTIONS::rotateCcw, and PCB_ACTIONS::rotateCw.

◆ updateModificationPoint()

bool EDIT_TOOL::updateModificationPoint ( PCBNEW_SELECTION aSelection)
private

Returns the right modification point (e.g.

for rotation), depending on the number of selected items.

Definition at line 1417 of file edit_tool.cpp.

1418 {
1419  if( m_dragging && aSelection.HasReferencePoint() )
1420  return false;
1421 
1422  // When there is only one item selected, the reference point is its position...
1423  if( aSelection.Size() == 1 )
1424  {
1425  auto item = static_cast<BOARD_ITEM*>( aSelection.Front() );
1426  auto pos = item->GetPosition();
1427  aSelection.SetReferencePoint( VECTOR2I( pos.x, pos.y ) );
1428  }
1429  // ...otherwise modify items with regard to the grid-snapped cursor position
1430  else
1431  {
1433  aSelection.SetReferencePoint( m_cursor );
1434  }
1435 
1436  return true;
1437 }
VECTOR2I m_cursor
Definition: edit_tool.h:197
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:245
bool m_dragging
Definition: edit_tool.h:195
bool HasReferencePoint() const
Definition: selection.h:235
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:184

References SELECTION::Front(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getViewControls(), SELECTION::HasReferencePoint(), m_cursor, m_dragging, SELECTION::SetReferencePoint(), and SELECTION::Size().

Referenced by Flip(), Mirror(), and Rotate().

◆ view()

◆ Wait()

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

58 {
59  return m_toolMgr->ScheduleWait( this, aEventList );
60 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
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 GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), pickReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), Remove(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_commit

std::unique_ptr<BOARD_COMMIT> EDIT_TOOL::m_commit
private

◆ m_cursor

VECTOR2I EDIT_TOOL::m_cursor
private

Definition at line 197 of file edit_tool.h.

Referenced by doMoveSelection(), and updateModificationPoint().

◆ m_dragging

bool EDIT_TOOL::m_dragging
private

◆ m_editModules

◆ m_lockedSelected

bool EDIT_TOOL::m_lockedSelected
private

Definition at line 196 of file edit_tool.h.

Referenced by doMoveSelection(), and Remove().

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

functions below are not yet implemented - their interface may change

Definition at line 108 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(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), PICKER_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), LIB_DRAWING_TOOLS::Init(), PCB_VIEWER_TOOLS::Init(), FOOTPRINT_EDITOR_TOOLS::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), EDA_3D_CONTROLLER::Init(), GERBVIEW_SELECTION_TOOL::Init(), PL_SELECTION_TOOL::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), PCB_TOOL_BASE::Init(), PL_EDIT_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_selectionTool

SELECTION_TOOL* EDIT_TOOL::m_selectionTool
private

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

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

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), SCH_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MICROWAVE_TOOL::createInductorBetween(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), LIB_EDIT_TOOL::editGraphicProperties(), PAD_TOOL::EditPad(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), POINT_EDITOR::finishItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), Flip(), 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(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_INSPECTION_TOOL::HighlightItem(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), LIB_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PCB_INSPECTION_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), PAD_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::Init(), PL_POINT_EDITOR::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), invokeInlineRouter(), isInteractiveDragEnabled(), isRouterActive(), TOOL_BASE::IsToolActive(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), MoveExact(), LIB_CONTROL::OnDeMorgan(), COMMON_TOOLS::OnGridChanged(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), pickReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCBNEW_CONTROL::Print(), GERBVIEW_CONTROL::Print(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), LIB_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), SCH_EDIT_TOOL::RefreshSymbolFromLibrary(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), Remove(), POINT_EDITOR::removeCorner(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC::RunTests(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::SelectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), EDA_3D_CONTROLLER::ToggleVisibility(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), LIB_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::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 218 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 211 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: