KiCad PCB EDA Suite
EDIT_TOOL Class Reference

Class 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 Main (const TOOL_EVENT &aEvent)
 Function Main() More...
 
int Drag (const TOOL_EVENT &aEvent)
 Function Drag() More...
 
int Properties (const TOOL_EVENT &aEvent)
 Function Edit() More...
 
int Rotate (const TOOL_EVENT &aEvent)
 Function Rotate() More...
 
int Flip (const TOOL_EVENT &aEvent)
 Function Flip() More...
 
int Mirror (const TOOL_EVENT &aEvent)
 Function Mirror. More...
 
int Remove (const TOOL_EVENT &aEvent)
 Function Remove() More...
 
int Duplicate (const TOOL_EVENT &aEvent)
 Function Duplicate() More...
 
int MoveExact (const TOOL_EVENT &aEvent)
 Function MoveExact() More...
 
int CreateArray (const TOOL_EVENT &aEvent)
 Function CreateArray() More...
 
int ExchangeFootprints (const TOOL_EVENT &aEvent)
 Function ExchangeFootprints() More...
 
int MeasureTool (const TOOL_EVENT &aEvent)
 

Launches a tool to measure between points

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 copyToClipboardWithAnchor (const TOOL_EVENT &aEvent)
 
int doCopyToClipboard (bool withAnchor)
 
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...
 
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...
 
OPT_TOOL_EVENT Wait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Static Public Member Functions

static void FootprintFilter (const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
 Function FootprintFilter() More...
 
static void PadFilter (const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
 Function PadFilter() More...
 

Protected Types

enum  INTERACTIVE_PLACEMENT_OPTIONS {
  IPO_ROTATE = 1, IPO_FLIP = 2, IPO_PROPERTIES = 4, IPO_SINGLE_CLICK = 8,
  IPO_REPEAT = 16
}
 

Protected Member Functions

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

Protected Attributes

TOOL_MENU m_menu
 Menu model displayed by the tool. More...
 
bool m_editModules
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

bool updateModificationPoint (SELECTION &aSelection)
 

Returns the right modification point (e.g.

More...
 
int editFootprintInFpEditor (const TOOL_EVENT &aEvent)
 
bool invokeInlineRouter (int aDragMode)
 
bool isInteractiveDragEnabled () const
 
bool changeTrackWidthOnClick (const SELECTION &selection)
 
bool pickCopyReferencePoint (VECTOR2I &aP)
 

Private Attributes

SELECTION_TOOLm_selectionTool
 

Selection tool used for obtaining selected items

More...
 
bool m_dragging
 

Flag determining if anything is being dragged right now

More...
 
bool m_lockedSelected
 

Flag determining whether we are prompting for locked removal

More...
 
VECTOR2I m_cursor
 

Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).

More...
 
std::unique_ptr< BOARD_COMMITm_commit
 

Detailed Description

Class 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 59 of file edit_tool.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

Enumerator
IPO_ROTATE 
IPO_FLIP 
IPO_PROPERTIES 
IPO_SINGLE_CLICK 
IPO_REPEAT 

Definition at line 109 of file pcb_tool_base.h.

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 80 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ EDIT_TOOL()

EDIT_TOOL::EDIT_TOOL ( )

Definition at line 200 of file edit_tool.cpp.

200  :
201  PCB_TOOL_BASE( "pcbnew.InteractiveEdit" ),
202  m_selectionTool( NULL ),
203  m_dragging( false ),
204  m_lockedSelected( false )
205 {
206 }
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
bool m_lockedSelected
Flag determining whether we are prompting for locked removal
Definition: edit_tool.h:205
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:202
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool_base.h:71

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 49 of file tool_interactive.cpp.

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:211
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(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), doCopyToClipboard(), SCH_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), MeasureTool(), POINT_EDITOR::OnSelectionChange(), pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SCH_WIRE_BUS_TOOL::StartBus(), SCH_WIRE_BUS_TOOL::StartWire(), and SCH_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 59 of file tool_base.cpp.

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

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

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 140 of file pcb_tool_base.h.

140 { return getModel<BOARD>(); }

Referenced by PCBNEW_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), changeTrackWidthOnClick(), PCB_EDITOR_CONTROL::ClearHighlight(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), doCopyToClipboard(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), MODULE_EDITOR_TOOLS::EnumeratePads(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), POINT_EDITOR::finishItem(), SELECTION_TOOL::getCollectorsGuide(), PCBNEW_CONTROL::GraphicDisplayMode(), PAD_TOOL::haveFootprints(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCB_TOOL_BASE::module(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PasteItemsFromClipboard(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), SELECTION_TOOL::RebuildSelection(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectAllItemsConnectedToItem(), SELECTION_TOOL::selectAllItemsConnectedToTrack(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectPoint(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), PCBNEW_CONTROL::TrackDisplayMode(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCBNEW_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), ZONE_FILLER_TOOL::ZoneFillAll(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ canvas()

◆ changeTrackWidthOnClick()

bool EDIT_TOOL::changeTrackWidthOnClick ( const SELECTION selection)
private

Definition at line 578 of file edit_tool.cpp.

579 {
581  {
582  auto item = static_cast<BOARD_ITEM *>( selection[0] );
583 
584  m_commit->Modify( item );
585 
586  if( auto via = dyn_cast<VIA*>( item ) )
587  {
588  int new_width, new_drill;
589 
590  if( via->GetViaType() == VIA_MICROVIA )
591  {
592  auto net = via->GetNet();
593 
594  new_width = net->GetMicroViaSize();
595  new_drill = net->GetMicroViaDrillSize();
596  }
597  else
598  {
599  new_width = board()->GetDesignSettings().GetCurrentViaSize();
600  new_drill = board()->GetDesignSettings().GetCurrentViaDrill();
601  }
602 
603  via->SetDrill( new_drill );
604  via->SetWidth( new_width );
605  }
606  else if ( auto track = dyn_cast<TRACK*>( item ) )
607  {
608  int new_width = board()->GetDesignSettings().GetCurrentTrackWidth();
609  track->SetWidth( new_width );
610  }
611 
612  m_commit->Push( _("Edit track width/via size") );
613  return true;
614  }
615 
616  return false;
617 }
BOARD * board() const
int GetCurrentViaDrill() const
Function GetCurrentViaDrill.
int GetCurrentTrackWidth() const
Function GetCurrentTrackWidth.
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:223
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:534
PCB_GENERAL_SETTINGS & Settings()
PCB_EDIT_FRAME * frame() const
int GetCurrentViaSize() const
Function GetCurrentViaSize.
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
const SELECTION & selection() const

References PCB_TOOL_BASE::board(), PCB_TOOL_BASE::frame(), BOARD_DESIGN_SETTINGS::GetCurrentTrackWidth(), BOARD_DESIGN_SETTINGS::GetCurrentViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentViaSize(), BOARD::GetDesignSettings(), m_commit, PCB_GENERAL_SETTINGS::m_editActionChangesTrackWidth, PCB_TOOL_BASE::selection(), PCB_BASE_FRAME::Settings(), SELECTION::Size(), and VIA_MICROVIA.

Referenced by Properties().

◆ 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.

Returns
True if it was sent succesfully

Definition at line 1498 of file edit_tool.cpp.

1499 {
1500  return doCopyToClipboard( true );
1501 }
int doCopyToClipboard(bool withAnchor)
Definition: edit_tool.cpp:1466

References doCopyToClipboard().

Referenced by cutToClipboard(), and setTransitions().

◆ copyToClipboardWithAnchor()

int EDIT_TOOL::copyToClipboardWithAnchor ( const TOOL_EVENT aEvent)

Definition at line 1504 of file edit_tool.cpp.

1505 {
1506  return doCopyToClipboard( true );
1507 }
int doCopyToClipboard(bool withAnchor)
Definition: edit_tool.cpp:1466

References doCopyToClipboard().

◆ 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 array options

Definition at line 1204 of file edit_tool.cpp.

1205 {
1207  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1209 
1210  if( selection.Empty() )
1211  return 0;
1212 
1213  // we have a selection to work on now, so start the tool process
1214  PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
1215  GAL_ARRAY_CREATOR array_creator( *editFrame, m_editModules, selection );
1216  array_creator.Invoke();
1217 
1218  return 0;
1219 }
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:48
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:47
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:159
const SELECTION & selection() const
class 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(), 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.

Returns
True if it was sent succesfully

Definition at line 1510 of file edit_tool.cpp.

1511 {
1512  if( !copyToClipboard( aEvent ) )
1513  {
1514  // N.B. Setting the CUT flag prevents lock filtering as we only want to delete the items that
1515  // were copied to the clipboard, no more, no fewer. Filtering for locked item, if any will be done
1516  // in the copyToClipboard() routine
1517  TOOL_EVENT evt( aEvent.Category(), aEvent.Action(), TOOL_ACTION_SCOPE::AS_GLOBAL );
1519  Remove( evt );
1520  }
1521 
1522  return 0;
1523 }
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition: tool_event.h:239
TOOL_EVENT_CATEGORY Category() const
Returns the category (eg. mouse/keyboard/action) of an event..
Definition: tool_event.h:233
void SetParameter(T aParam)
Function SetParameter() Sets a non-standard parameter assigned to the event.
Definition: tool_event.h:390
Class TOOL_EVENT.
Definition: tool_event.h:167
All active tools
Definition: tool_event.h:143
int Remove(const TOOL_EVENT &aEvent)
Function Remove()
Definition: edit_tool.cpp:863
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:1498

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

Referenced by setTransitions().

◆ displayOptions()

◆ doCopyToClipboard()

int EDIT_TOOL::doCopyToClipboard ( bool  withAnchor)

Definition at line 1466 of file edit_tool.cpp.

1467 {
1468  CLIPBOARD_IO io;
1469 
1470  Activate();
1471 
1473  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1475 
1476  if( selection.Empty() )
1477  return 1;
1478 
1479  if( withAnchor )
1480  {
1481  VECTOR2I refPoint;
1482  bool rv = pickCopyReferencePoint( refPoint );
1483  frame()->SetMsgPanel( board() );
1484 
1485  if( !rv )
1486  return 1;
1487 
1488  selection.SetReferencePoint( refPoint );
1489  }
1490 
1491  io.SetBoard( board() );
1492  io.SaveSelection( selection );
1493 
1494  return 0;
1495 }
BOARD * board() const
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
void SaveSelection(const SELECTION &selected)
void SetBoard(BOARD *aBoard)
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:208
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
PCB_EDIT_FRAME * frame() const
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:48
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
bool pickCopyReferencePoint(VECTOR2I &aP)
Definition: edit_tool.cpp:1427
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:47
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:159
const SELECTION & selection() const

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

Referenced by copyToClipboard(), and copyToClipboardWithAnchor().

◆ doInteractiveItemPlacement()

void PCB_TOOL_BASE::doInteractiveItemPlacement ( 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 39 of file pcb_tool_base.cpp.

42 {
43  using namespace std::placeholders;
44  std::unique_ptr<BOARD_ITEM> newItem;
45 
46  Activate();
47 
48  BOARD_COMMIT commit( frame() );
49 
51 
52  // do not capture or auto-pan until we start placing an item
53  controls()->ShowCursor( true );
54  controls()->SetSnapping( true );
55 
56  // Add a VIEW_GROUP that serves as a preview for the new item
57  SELECTION preview;
58  view()->Add( &preview );
59 
60  aPlacer->m_board = board();
61  aPlacer->m_frame = frame();
62  aPlacer->m_modifiers = 0;
63 
64  if( aOptions & IPO_SINGLE_CLICK && !( aOptions & IPO_PROPERTIES ) )
65  {
66  VECTOR2I cursorPos = controls()->GetCursorPosition();
67 
68  newItem = aPlacer->CreateItem();
69 
70  if( newItem )
71  {
72  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
73  preview.Add( newItem.get() );
74  }
75  }
76 
77  // Main loop: keep receiving events
78  while( OPT_TOOL_EVENT evt = Wait() )
79  {
80  VECTOR2I cursorPos = controls()->GetCursorPosition();
81  aPlacer->m_modifiers = evt->Modifier();
82 
84  {
85  if( newItem )
86  {
87  // Delete the old item and have another try
88  newItem = nullptr;
89 
90  preview.Clear();
91 
92  if( aOptions & IPO_SINGLE_CLICK )
93  break;
94 
95  controls()->SetAutoPan( false );
96  controls()->CaptureCursor( false );
97  controls()->ShowCursor( true );
98  }
99  else
100  {
101  break;
102  }
103 
104  if( evt->IsActivate() ) // now finish unconditionally
105  break;
106  }
107  else if( evt->IsClick( BUT_LEFT ) )
108  {
109  if( !newItem )
110  {
111  // create the item if possible
112  newItem = aPlacer->CreateItem();
113 
114  // no item created, so wait for another click
115  if( !newItem )
116  continue;
117 
118  controls()->CaptureCursor( true );
119  controls()->SetAutoPan( true );
120 
121  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
122 
123  preview.Add( newItem.get() );
124 
125  if( newItem->Type() == PCB_MODULE_T )
126  {
127  auto module = dyn_cast<MODULE*>( newItem.get() );
128 
129  // modules have more drawable parts
130  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
131  }
132  }
133  else
134  {
135  auto oldFlags = newItem->GetFlags();
136  newItem->ClearFlags();
137 
138  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
139  {
140  newItem->SetFlags( oldFlags );
141  continue;
142  }
143 
144  preview.Remove( newItem.get() );
145 
146  if( newItem->Type() == PCB_MODULE_T )
147  {
148  auto module = dyn_cast<MODULE*>( newItem.get() );
149  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
150  }
151 
152  newItem.release();
153  commit.Push( aCommitMessage );
154 
155  controls()->CaptureCursor( false );
156  controls()->SetAutoPan( false );
157  controls()->ShowCursor( true );
158 
159  if( !( aOptions & IPO_REPEAT ) )
160  break;
161 
162  if( aOptions & IPO_SINGLE_CLICK && !( aOptions & IPO_PROPERTIES ) )
163  {
165 
166  newItem = aPlacer->CreateItem();
167 
168  if( newItem )
169  {
170  newItem->SetPosition( wxPoint( pos.x, pos.y ) );
171  preview.Add( newItem.get() );
172  }
173  }
174  }
175  }
176  else if( evt->IsClick( BUT_RIGHT ) )
177  {
179  }
180  else if( newItem && evt->Category() == TC_COMMAND )
181  {
182  /*
183  * Handle any events that can affect the item as we move
184  * it around, eg rotate and flip
185  */
186 
187  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
188  {
189  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
190  newItem->Rotate( newItem->GetPosition(), rotationAngle );
191  view()->Update( &preview );
192  }
193  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
194  {
195  newItem->Flip( newItem->GetPosition() );
196  view()->Update( &preview );
197  }
198  }
199 
200  else if( newItem && evt->IsMotion() )
201  {
202  // track the cursor
203  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
204  aPlacer->SnapItem( newItem.get() );
205 
206  // Show a preview of the item
207  view()->Update( &preview );
208  }
209  }
210 
211  view()->Remove( &preview );
212 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
Menu model displayed by the tool.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:93
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Function RunOnChildren.
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
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:91
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
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:125
PCB_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:58
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:74
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:144
virtual void SnapItem(BOARD_ITEM *aItem)
class MODULE, a footprint
Definition: typeinfo.h:89
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
KIGFX::PCB_VIEW * view() const
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
Definition: tool_event.cpp:177
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
PCB_EDIT_FRAME * frame() const
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:99
KIGFX::VIEW_CONTROLS * controls() const
MODULE * module() const
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
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
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:85

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(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_PROPERTIES, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, INTERACTIVE_PLACER_BASE::m_frame, PCB_TOOL_BASE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, PCB_TOOL_BASE::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), BOARD_COMMIT::Push(), KIGFX::PCB_VIEW::Remove(), KIGFX::VIEW_GROUP::Remove(), SELECTION::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, KIGFX::PCB_VIEW::Update(), PCB_TOOL_BASE::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ Drag()

int EDIT_TOOL::Drag ( const TOOL_EVENT aEvent)

Function Drag()

todo

Definition at line 314 of file edit_tool.cpp.

315 {
316  int mode = PNS::DM_ANY;
317 
318  if( aEvent.IsAction( &PCB_ACTIONS::dragFreeAngle ) )
319  mode |= PNS::DM_FREE_ANGLE;
320 
321  invokeInlineRouter( mode );
322 
323  return 0;
324 }
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:54
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:285

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 1055 of file edit_tool.cpp.

1056 {
1057  bool increment = aEvent.IsAction( &PCB_ACTIONS::duplicateIncrement );
1058 
1059  // Be sure that there is at least one item that we can modify
1061  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1063 
1064  if( selection.Empty() )
1065  return 0;
1066 
1067  // we have a selection to work on now, so start the tool process
1068  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1069 
1070  std::vector<BOARD_ITEM*> new_items;
1071  new_items.reserve( selection.Size() );
1072 
1073  BOARD_ITEM* orig_item = nullptr;
1074  BOARD_ITEM* dupe_item = nullptr;
1075 
1076  // Each selected item is duplicated and pushed to new_items list
1077  // Old selection is cleared, and new items are then selected.
1078  for( EDA_ITEM* item : selection )
1079  {
1080  if( !item )
1081  continue;
1082 
1083  orig_item = static_cast<BOARD_ITEM*>( item );
1084 
1085  if( m_editModules )
1086  {
1087  dupe_item = editFrame->GetBoard()->m_Modules->Duplicate( orig_item, increment );
1088  }
1089  else
1090  {
1091 #if 0
1092  // @TODO: see if we allow zone duplication here
1093  // Duplicate zones is especially tricky (overlaping zones must be merged)
1094  // so zones are not duplicated
1095  if( item->Type() != PCB_ZONE_AREA_T )
1096 #endif
1097  dupe_item = editFrame->GetBoard()->Duplicate( orig_item );
1098  }
1099 
1100  if( dupe_item )
1101  {
1102  // Clear the selection flag here, otherwise the SELECTION_TOOL
1103  // will not properly select it later on
1104  dupe_item->ClearSelected();
1105 
1106  new_items.push_back( dupe_item );
1107  m_commit->Add( dupe_item );
1108  }
1109  }
1110 
1111  // Clear the old selection first
1113 
1114  // Select the new items
1115  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &new_items );
1116 
1117  // record the new items as added
1118  if( !selection.Empty() )
1119  {
1120  editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ),
1121  (int) new_items.size() ) );
1122 
1123  // If items were duplicated, pick them up
1124  // this works well for "dropping" copies around and pushes the commit
1126  Main( evt );
1127  }
1128 
1129  return 0;
1130 }
static TOOL_ACTION selectItems
Selects a list of items (specified as the event parameter)
Definition: pcb_actions.h:60
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
int Main(const TOOL_EVENT &aEvent)
Function Main()
Definition: edit_tool.cpp:326
static TOOL_ACTION move
move an item
Definition: pcb_actions.h:92
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
Class 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:223
void ClearSelected()
Definition: base_struct.h:237
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:100
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
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:54
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
Definition: pcb_actions.h:114
Class TOOL_EVENT.
Definition: tool_event.h:167
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:48
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
void DisplayToolMsg(const wxString &msg)
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
DLIST< MODULE > m_Modules
Definition: class_board.h:248
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:95
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
BOARD * GetBoard() const
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:47
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:159
const SELECTION & selection() const
BOARD_ITEM * Duplicate(const BOARD_ITEM *aItem, bool aAddToBoard=false)

References EDA_ITEM::ClearSelected(), EDA_DRAW_FRAME::DisplayToolMsg(), BOARD::Duplicate(), PCB_ACTIONS::duplicateIncrement, EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, Format(), PCB_BASE_FRAME::GetBoard(), TOOL_EVENT::IsAction(), m_commit, PCB_TOOL_BASE::m_editModules, BOARD::m_Modules, m_selectionTool, TOOL_BASE::m_toolMgr, Main(), TOOL_ACTION::MakeEvent(), PCB_ACTIONS::move, PCB_ZONE_AREA_T, SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItems, and SELECTION::Size().

Referenced by setTransitions().

◆ editFootprintInFpEditor()

int EDIT_TOOL::editFootprintInFpEditor ( const TOOL_EVENT aEvent)
private

Definition at line 1390 of file edit_tool.cpp.

1391 {
1393 
1394  if( selection.Empty() )
1395  return 0;
1396 
1398 
1399  if( !mod )
1400  return 0;
1401 
1402  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1403 
1404  editFrame->SetCurItem( mod );
1405 
1406  if( editFrame->GetCurItem()->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
1407  {
1408  editFrame->GetCurItem()->SetTimeStamp( GetNewTimeStamp() );
1409  editFrame->OnModify();
1410  }
1411 
1413 
1414  editor->Load_Module_From_BOARD( (MODULE*) editFrame->GetCurItem() );
1415  editFrame->SetCurItem( NULL ); // the current module could be deleted by
1416 
1417  editor->Show( true );
1418  editor->Raise(); // Iconize( false );
1419 
1420  if( selection.IsHover() )
1422 
1423  return 0;
1424 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:61
bool IsHover() const
Definition: selection.h:69
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:321
timestamp_t GetTimeStamp() const
Definition: base_struct.h:210
bool Load_Module_From_BOARD(MODULE *Module)
Load in Modedit a footprint from the main board.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
Common, abstract interface for edit frames.
T * FirstOfKind() const
Definition: selection.h:166
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
Function FootprintFilter()
Definition: edit_tool.cpp:1234
BOARD_ITEM * GetCurItem()
const SELECTION & selection() const
#define mod(a, n)
Definition: greymap.cpp:24
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:209

References SELECTION::Empty(), SELECTION::FirstOfKind(), FootprintFilter(), FRAME_PCB_MODULE_EDITOR, PCB_BASE_FRAME::GetCurItem(), GetNewTimeStamp(), EDA_ITEM::GetTimeStamp(), SELECTION::IsHover(), KIWAY_HOLDER::Kiway(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), m_selectionTool, TOOL_BASE::m_toolMgr, mod, PCB_BASE_FRAME::OnModify(), KIWAY::Player(), SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_BASE_FRAME::SetCurItem(), and EDA_ITEM::SetTimeStamp().

Referenced by setTransitions().

◆ EditingModules()

bool PCB_TOOL_BASE::EditingModules ( ) const
inlineinherited

Definition at line 102 of file pcb_tool_base.h.

103  {
104  return m_editModules;
105  }

References PCB_TOOL_BASE::m_editModules.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), Flip(), PAD_TOOL::Init(), Main(), MeasureTool(), Mirror(), MoveExact(), and Rotate().

◆ evActivate()

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

functions below are not yet implemented - their interface may change

◆ evButtonDown()

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

◆ evButtonUp()

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

◆ evClick()

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

◆ evCommand() [1/2]

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

◆ evCommand() [2/2]

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

◆ evDrag()

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

◆ evMotion()

const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited

◆ ExchangeFootprints()

int EDIT_TOOL::ExchangeFootprints ( const TOOL_EVENT aEvent)

Function ExchangeFootprints()

Invoke the dialog used to update or exchange the footprints used for modules. The mode depends on the PCB_ACTIONS held by the TOOL_EVENT.

Definition at line 1246 of file edit_tool.cpp.

1247 {
1249 
1250  bool updateMode = aEvent.IsAction( &PCB_ACTIONS::updateFootprints );
1251 
1252  MODULE* mod = (selection.Empty() ? nullptr : selection.FirstOfKind<MODULE> () );
1253 
1254  frame()->SetCurItem( mod );
1255 
1256  // Footprint exchange could remove modules, so they have to be
1257  // removed from the selection first
1259 
1260  // invoke the exchange dialog process
1261  {
1262  DIALOG_EXCHANGE_FOOTPRINTS dialog( frame(), mod, updateMode, mod != nullptr );
1263  dialog.ShowQuasiModal();
1264  }
1265 
1266  return 0;
1267 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
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:54
PCB_EDIT_FRAME * frame() const
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
static TOOL_ACTION updateFootprints
Update footprints to reflect any changes in the library.
Definition: pcb_actions.h:117
T * FirstOfKind() const
Definition: selection.h:166
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
Function FootprintFilter()
Definition: edit_tool.cpp:1234
const SELECTION & selection() const
#define mod(a, n)
Definition: greymap.cpp:24

References SELECTION::Empty(), SELECTION::FirstOfKind(), FootprintFilter(), PCB_TOOL_BASE::frame(), TOOL_EVENT::IsAction(), m_selectionTool, TOOL_BASE::m_toolMgr, mod, SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_BASE_FRAME::SetCurItem(), DIALOG_SHIM::ShowQuasiModal(), and PCB_ACTIONS::updateFootprints.

Referenced by setTransitions().

◆ 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 824 of file edit_tool.cpp.

825 {
827  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
828  { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); }, nullptr, ! m_dragging );
829 
830  if( selection.Empty() )
831  return 0;
832 
834  auto modPoint = selection.GetReferencePoint();
835 
836  // When editing modules, all items have the same parent
837  if( EditingModules() )
838  m_commit->Modify( selection.Front() );
839 
840  for( EDA_ITEM* item : selection )
841  {
842  if( !item->IsNew() && !EditingModules() )
843  m_commit->Modify( item );
844 
845  static_cast<BOARD_ITEM*>( item )->Flip( modPoint );
846  }
847 
848  if( !m_dragging )
849  m_commit->Push( _( "Flip" ) );
850 
851  if( selection.IsHover() && !m_dragging )
853 
855 
856  if( m_dragging )
858 
859  return 0;
860 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
VECTOR2I GetReferencePoint() const
Definition: selection.h:203
bool IsHover() const
Definition: selection.h:69
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:223
bool updateModificationPoint(SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1367
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:136
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:202
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:48
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
bool EditingModules() const
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:324
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:47
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:159
const SELECTION & selection() const
EDA_ITEM * Front() const
Definition: selection.h:155

References PCB_TOOL_BASE::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, SELECTION::Front(), SELECTION::GetReferencePoint(), SELECTION::IsHover(), 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().

◆ 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 1234 of file edit_tool.cpp.

1235 {
1236  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1237  {
1238  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
1239 
1240  if( item->Type() != PCB_MODULE_T )
1241  aCollector.Remove( i );
1242  }
1243 }
Class 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:143
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:114
class MODULE, a footprint
Definition: typeinfo.h:89
size_t i
Definition: json11.cpp:597
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

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

Referenced by editFootprintInFpEditor(), ExchangeFootprints(), and showLocalRatsnest().

◆ frame()

PCB_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 139 of file pcb_tool_base.h.

139 { return getEditFrame<PCB_EDIT_FRAME>(); }

Referenced by POINT_EDITOR::addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), changeTrackWidthOnClick(), PNS::TOOL_BASE::checkSnap(), PCB_EDITOR_CONTROL::ClearHighlight(), PAD_TOOL::copyPadSettings(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL_BASE::displayOptions(), doCopyToClipboard(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), DRAWING_TOOL::drawZone(), MODULE_EDITOR_TOOLS::EnumeratePads(), ExchangeFootprints(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), ROUTER_TOOL::finishInteractive(), PAD_TOOL::Init(), Init(), SELECTION_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PICKER_TOOL::Main(), Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PasteItemsFromClipboard(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), pickCopyReferencePoint(), MODULE_EDITOR_TOOLS::PlacePad(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), Remove(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::RouteDiffPair(), ROUTER_TOOL::RouteSingleTrace(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ROUTER_TOOL::SettingsDialog(), ROUTER_TOOL::switchLayerOnViaPlacement(), LENGTH_TUNER_TOOL::TuneDiffPair(), LENGTH_TUNER_TOOL::TuneDiffPairSkew(), LENGTH_TUNER_TOOL::TuneSingleTrace(), POINT_EDITOR::updateItem(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ GetCurrentCommit()

BOARD_COMMIT* EDIT_TOOL::GetCurrentCommit ( ) const
inline

Definition at line 192 of file edit_tool.h.

193  {
194  return m_commit.get();
195  }
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:223

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

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

References TOOL_BASE::getEditFrameInt().

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

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

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

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 144 of file tool_base.h.

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

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), 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 199 of file tool_base.h.

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

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Function GetName() Returns the name of the tool.

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

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

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

References TOOL_BASE::m_toolName.

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

◆ GetSettings()

TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

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

References TOOL_BASE::m_toolSettings.

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

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

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

References TOOL_BASE::m_type.

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

◆ getView()

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

Function getView()

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

Returns
The instance of VIEW.

Definition at line 35 of file tool_base.cpp.

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

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(), EE_SELECTION_TOOL::clearSelection(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), COMMON_TOOLS::doGridPreset(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), EE_POINT_EDITOR::Main(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), MeasureTool(), SCH_EDIT_TOOL::Mirror(), MoveExact(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), Remove(), POINT_EDITOR::removeCorner(), 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(), GERBVIEW_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), COMMON_TOOLS::ToggleGrid(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), PCBNEW_CONTROL::updateGrid(), EE_POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_TOOL_BASE::view(), COMMON_TOOLS::ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), CVPCB_SELECTION_TOOL::~CVPCB_SELECTION_TOOL(), 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 41 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCorner(), POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), COMMON_TOOLS::CursorControl(), SCH_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), SCH_WIRE_BUS_TOOL::finishSegments(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), Main(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), CVPCB_CONTROL::ResetCoords(), GERBVIEW_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), EE_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), LIB_MOVE_TOOL::updateModificationPoint(), SCH_MOVE_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 135 of file tool_interactive.h.

137 {
138  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
139 
140  goInternal( sptr, aConditions );
141 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), LIB_CONTROL::setTransitions(), LIB_PIN_TOOL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), LIB_MOVE_TOOL::setTransitions(), POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), CVPCB_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), SCH_WIRE_BUS_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), EE_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), SELECTION_TOOL::setTransitions(), setTransitions(), DRAWING_TOOL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ Init()

bool EDIT_TOOL::Init ( )
overridevirtual

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

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

Reimplemented from PCB_TOOL_BASE.

Definition at line 218 of file edit_tool.cpp.

219 {
220  // Find the selection tool, so they can cooperate
221  m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
222 
223  if( !m_selectionTool )
224  {
225  DisplayError( NULL, _( "pcbnew.InteractiveSelection tool is not available" ) );
226  return false;
227  }
228 
229  auto editingModuleCondition = [ this ] ( const SELECTION& aSelection ) {
230  return m_editModules;
231  };
232 
233  auto singleModuleCondition = SELECTION_CONDITIONS::OnlyType( PCB_MODULE_T )
235 
236  auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) {
237  return ( frame()->GetToolId() == ID_NO_TOOL_SELECTED );
238  };
239 
240  // Add context menu entries that are displayed when selection tool is active
242 
254 
255 
260 
261 
265  // Selection tool handles the context menu for some other tools, such as the Picker.
266  // Don't add things like Paste when another tool is active.
267  menu.AddItem( ACTIONS::paste, noActiveToolCondition );
268 
269  // Mirror only available in modedit
270  menu.AddSeparator( editingModuleCondition && SELECTION_CONDITIONS::NotEmpty );
271  menu.AddItem( PCB_ACTIONS::mirror, editingModuleCondition && SELECTION_CONDITIONS::NotEmpty );
274 
275  // Footprint actions
276  menu.AddSeparator( singleModuleCondition );
277  menu.AddItem( PCB_ACTIONS::editFootprintInFpEditor, singleModuleCondition );
278  menu.AddItem( PCB_ACTIONS::updateFootprints, singleModuleCondition );
279  menu.AddItem( PCB_ACTIONS::exchangeFootprints, singleModuleCondition );
280 
281  return true;
282 }
static TOOL_ACTION move
move an item
Definition: pcb_actions.h:92
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:313
void AddSeparator(const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddSeparator()
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_MENU & GetToolMenu()
static TOOL_ACTION explodePadToShapes
Definition: pcb_actions.h:264
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:105
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:132
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:102
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
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.
static TOOL_ACTION moveExact
Activation of the exact move tool.
Definition: pcb_actions.h:108
static TOOL_ACTION duplicate
Activation of the duplication tool.
Definition: pcb_actions.h:111
class MODULE, a footprint
Definition: typeinfo.h:89
static TOOL_ACTION copy
Definition: actions.h:53
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:95
static TOOL_ACTION createArray
Tool for creating an array of objects.
Definition: pcb_actions.h:270
static TOOL_ACTION cut
Definition: actions.h:52
static TOOL_ACTION exchangeFootprints
Exchange footprints of modules.
Definition: pcb_actions.h:120
PCB_EDIT_FRAME * frame() const
static TOOL_ACTION inlineBreakTrack
Breaks track when router is not activated.
Definition: pcb_actions.h:130
static TOOL_ACTION updateFootprints
Update footprints to reflect any changes in the library.
Definition: pcb_actions.h:117
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:96
static TOOL_ACTION createPadFromShapes
Definition: pcb_actions.h:263
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:99
static TOOL_ACTION editFootprintInFpEditor
Definition: pcb_actions.h:332
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 positionRelative
Activation of the position relative tool.
Definition: pcb_actions.h:206
static TOOL_ACTION remove
Deleting a BOARD_ITEM.
Definition: pcb_actions.h:123
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:244
static TOOL_ACTION paste
Definition: actions.h:54
int GetToolId() const
Definition: draw_frame.h:524

References CONDITIONAL_MENU::AddItem(), CONDITIONAL_MENU::AddSeparator(), ACTIONS::copy, SELECTION_CONDITIONS::Count(), PCB_ACTIONS::createArray, PCB_ACTIONS::createPadFromShapes, ACTIONS::cut, DisplayError(), PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, PCB_ACTIONS::duplicate, PCB_ACTIONS::editFootprintInFpEditor, PCB_ACTIONS::exchangeFootprints, PCB_ACTIONS::explodePadToShapes, TOOL_MANAGER::FindTool(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), TOOL_MENU::GetMenu(), EDA_DRAW_FRAME::GetToolId(), SELECTION_TOOL::GetToolMenu(), ID_NO_TOOL_SELECTED, PCB_ACTIONS::inlineBreakTrack, PCB_TOOL_BASE::m_editModules, m_selectionTool, TOOL_BASE::m_toolMgr, PCB_ACTIONS::mirror, PCB_ACTIONS::move, PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::NotEmpty(), SELECTION_CONDITIONS::OnlyType(), SELECTION_CONDITIONS::OnlyTypes(), ACTIONS::paste, PCB_MODULE_T, PCB_ACTIONS::positionRelative, PCB_ACTIONS::properties, PCB_ACTIONS::remove, PCB_ACTIONS::rotateCcw, PCB_ACTIONS::rotateCw, GENERAL_COLLECTOR::Tracks, and PCB_ACTIONS::updateFootprints.

◆ invokeInlineRouter()

bool EDIT_TOOL::invokeInlineRouter ( int  aDragMode)
private

Definition at line 285 of file edit_tool.cpp.

286 {
287  auto theRouter = static_cast<ROUTER_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveRouter" ) );
288 
289  if( !theRouter )
290  return false;
291 
292  // make sure we don't accidentally invoke inline routing mode while the router is already active!
293  if( theRouter->IsToolActive() )
294  return false;
295 
296  if( theRouter->CanInlineDrag() )
297  {
299  return true;
300  }
301 
302  return false;
303 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:185
static ROUTER * theRouter
Definition: pns_router.cpp:59

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

Referenced by Drag(), and Main().

◆ isInteractiveDragEnabled()

bool EDIT_TOOL::isInteractiveDragEnabled ( ) const
private

Definition at line 306 of file edit_tool.cpp.

307 {
308  auto theRouter = static_cast<ROUTER_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveRouter" ) );
309 
310  return theRouter ? theRouter->Router()->Settings().InlineDragEnabled() : false;
311 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
static ROUTER * theRouter
Definition: pns_router.cpp:59
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:187

References TOOL_MANAGER::FindTool(), PNS::ROUTING_SETTINGS::InlineDragEnabled(), TOOL_BASE::m_toolMgr, PNS::ROUTER::Settings(), and PNS::theRouter.

Referenced by Main().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

31 {
32  return m_toolMgr->IsToolActive( m_toolId );
33 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:211
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.

◆ Main()

int EDIT_TOOL::Main ( const TOOL_EVENT aEvent)

Function Main()

Main loop in which events are handled.

Parameters
aEventis the handled event.

Definition at line 326 of file edit_tool.cpp.

327 {
329  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  { EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } );
337 
338  if( m_dragging || selection.Empty() )
339  return 0;
340 
341  LSET item_layers = static_cast<BOARD_ITEM*>( selection.Front() )->GetLayerSet();
342  bool unselect = selection.IsHover(); //N.B. This must be saved before the re-selection below
343 
344  // Filter out locked pads here
345  // We cannot do this in the selection filter as we need the pad layers
346  // when it is the curr_item.
348  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
349  { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS ); } );
350 
351  if( selection.Empty() )
352  return 0;
353 
354  Activate();
355  controls->ShowCursor( true );
356  controls->SetAutoPan( true );
357 
358  auto curr_item = static_cast<BOARD_ITEM*>( selection.Front() );
359  std::vector<BOARD_ITEM*> sel_items;
360 
361  for( EDA_ITEM* item : selection )
362  {
363  BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
364  MODULE* module = dynamic_cast<MODULE*>( item );
365 
366  if( boardItem )
367  sel_items.push_back( boardItem );
368 
369  if( module )
370  {
371  for( D_PAD* pad : module->Pads() )
372  sel_items.push_back( pad );
373  }
374  }
375 
376  bool restore_state = false;
377  VECTOR2I totalMovement;
378  GRID_HELPER grid( editFrame );
379  OPT_TOOL_EVENT evt = aEvent;
380  VECTOR2I prevPos;
381 
382  // Main loop: keep receiving events
383  do
384  {
385  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
386  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
387  controls->SetSnapping( !evt->Modifier( MD_ALT ) );
388 
389  if( evt->IsAction( &PCB_ACTIONS::editActivate ) ||
390  evt->IsAction( &PCB_ACTIONS::move ) ||
391  evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
392  {
393  if( m_dragging && evt->Category() == TC_MOUSE )
394  {
395  m_cursor = grid.BestSnapAnchor( controls->GetMousePosition(),
396  item_layers, sel_items );
398  VECTOR2I movement( m_cursor - prevPos );
400 
401  totalMovement += movement;
402  prevPos = m_cursor;
403 
404  // Drag items to the current cursor position
405  for( EDA_ITEM* item : selection )
406  {
407  // Don't double move footprint pads, fields, etc.
408  if( item->GetParent() && item->GetParent()->IsSelected() )
409  continue;
410 
411  static_cast<BOARD_ITEM*>( item )->Move( movement );
412  }
413 
414  frame()->UpdateMsgPanel();
415  }
416  else if( !m_dragging ) // Prepare to start dragging
417  {
418  if ( !evt->IsAction( &PCB_ACTIONS::move ) && isInteractiveDragEnabled() )
419  {
421  break;
422  }
423 
424  // deal with locked items (override lock or abort the operation)
426 
427  if( lockFlags == SELECTION_LOCKED )
428  break;
429 
430  // When editing modules, all items have the same parent
431  if( EditingModules() )
432  {
433  m_commit->Modify( selection.Front() );
434  }
435  else
436  {
437  // Save items, so changes can be undone
438  for( auto item : selection )
439  {
440  // Don't double move footprint pads, fields, etc.
441  if( item->GetParent() && item->GetParent()->IsSelected() )
442  continue;
443 
444  m_commit->Modify( item );
445  }
446  }
447 
448  editFrame->UndoRedoBlock( true );
450 
452  {
453  // start moving with the reference point attached to the cursor
454  grid.SetAuxAxes( false );
455 
457 
458  // Drag items to the current cursor position
459  for( auto item : selection )
460  {
461  // Don't double move footprint pads, fields, etc.
462  if( item->GetParent() && item->GetParent()->IsSelected() )
463  continue;
464 
465  static_cast<BOARD_ITEM*>( item )->Move( delta );
466  }
467 
469  }
470  else if( selection.Size() == 1 )
471  {
472  // Set the current cursor position to the first dragged item origin, so the
473  // movement vector could be computed later
475  m_cursor = grid.BestDragOrigin( originalCursorPos, curr_item );
476  grid.SetAuxAxes( true, m_cursor );
477  }
478  else
479  {
481  m_cursor = grid.Align( m_cursor );
482  }
483 
485 
486  prevPos = m_cursor;
487  controls->SetAutoPan( true );
488  m_dragging = true;
489  }
490 
493  }
494 
495  else if( evt->IsCancel() || evt->IsActivate() )
496  {
497  restore_state = true; // Canceling the tool means that items have to be restored
498  break; // Finish
499  }
500 
501  else if( evt->Action() == TA_UNDO_REDO_PRE )
502  {
503  unselect = true;
504  break;
505  }
506 
507  // Dispatch TOOL_ACTIONs
508  else if( evt->Category() == TC_COMMAND )
509  {
510  if( evt->IsAction( &PCB_ACTIONS::remove ) )
511  {
512  // exit the loop, as there is no further processing for removed items
513  break;
514  }
515  else if( evt->IsAction( &PCB_ACTIONS::duplicate ) )
516  {
517  // On duplicate, stop moving this item
518  // The duplicate tool should then select the new item and start
519  // a new move procedure
520  break;
521  }
522  else if( evt->IsAction( &PCB_ACTIONS::moveExact ) )
523  {
524  // Can't do this, because the selection will then contain
525  // stale pointers and it will all go horribly wrong...
526  //editFrame->RestoreCopyFromUndoList( dummy );
527  //
528  // So, instead, reset the position manually
529  for( auto item : selection )
530  {
531  BOARD_ITEM* i = static_cast<BOARD_ITEM*>( item );
532  auto delta = VECTOR2I( i->GetPosition() ) - totalMovement;
533  i->SetPosition( wxPoint( delta.x, delta.y ) );
534 
535  // And what about flipping and rotation?
536  // for now, they won't be undone, but maybe that is how
537  // it should be, so you can flip and move exact in the
538  // same action?
539  }
540 
541  // This causes a double event, so we will get the dialogue
542  // correctly, somehow - why does Rotate not?
543  //MoveExact( aEvent );
544  break; // exit the loop - we move exactly, so we have finished moving
545  }
546  }
547 
548  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
549  {
550  break; // Finish
551  }
552 
553  } while( ( evt = Wait() ) ); //Should be assignment not equality test
554 
555  m_lockedSelected = false;
556  controls->ForceCursorPosition( false );
557  controls->ShowCursor( false );
558  controls->SetSnapping( false );
559  controls->SetAutoPan( false );
560 
561  m_dragging = false;
562  editFrame->UndoRedoBlock( false );
563 
564  // Discard reference point when selection is "dropped" onto the board (ie: not dragging anymore)
566 
567  if( unselect )
569 
570  if( restore_state )
571  m_commit->Revert();
572  else
573  m_commit->Push( _( "Drag" ) );
574 
575  return 0;
576 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
VECTOR2I GetReferencePoint() const
Definition: selection.h:203
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
VECTOR2I m_cursor
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).
Definition: edit_tool.h:209
void ClearReferencePoint()
Definition: selection.h:213
static TOOL_ACTION move
move an item
Definition: pcb_actions.h:92
bool IsHover() const
Definition: selection.h:69
static TOOL_ACTION editActivate
Activation of the edit tool.
Definition: pcb_actions.h:89
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
Class 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:223
SELECTION_LOCK_FLAGS CheckLock()
Checks if the user has agreed to modify locked items for the given selection.
bool updateModificationPoint(SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1367
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
DLIST_ITERATOR_WRAPPER< D_PAD > Pads()
Definition: class_module.h:168
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
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:125
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
static const int delta[8][2]
Definition: solve.cpp:112
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:136
static TOOL_ACTION moveExact
Activation of the exact move tool.
Definition: pcb_actions.h:108
bool m_lockedSelected
Flag determining whether we are prompting for locked removal
Definition: edit_tool.h:205
static TOOL_ACTION duplicate
Activation of the duplication tool.
Definition: pcb_actions.h:111
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:208
bool isInteractiveDragEnabled() const
Definition: edit_tool.cpp:306
Class LSET is a set of PCB_LAYER_IDs.
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:202
SELECTION_LOCK_FLAGS
Definition: selection.h:232
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
PCB_EDIT_FRAME * frame() const
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:48
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
bool EditingModules() const
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:285
bool HasReferencePoint() const
Definition: selection.h:198
KIGFX::VIEW_CONTROLS * controls() const
Common, abstract interface for edit frames.
MODULE * module() const
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
size_t i
Definition: json11.cpp:597
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
void Activate()
Function Activate() Runs the tool.
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:324
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
static TOOL_ACTION remove
Deleting a BOARD_ITEM.
Definition: pcb_actions.h:123
void UpdateMsgPanel() override
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:47
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:159
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:238
const SELECTION & selection() const
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false)=0
Moves cursor to the requested position expressed in world coordinates.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:155
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486

References TOOL_INTERACTIVE::Activate(), GRID_HELPER::Align(), GRID_HELPER::BestDragOrigin(), GRID_HELPER::BestSnapAnchor(), BUT_LEFT, SELECTION_TOOL::CheckLock(), SELECTION::ClearReferencePoint(), PCB_TOOL_BASE::controls(), delta, PNS::DM_ANY, PCB_ACTIONS::duplicate, PCB_ACTIONS::editActivate, PCB_TOOL_BASE::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), SELECTION::Front(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW_CONTROLS::GetMousePosition(), SELECTION::GetReferencePoint(), TOOL_BASE::getViewControls(), SELECTION::HasReferencePoint(), i, invokeInlineRouter(), SELECTION::IsHover(), isInteractiveDragEnabled(), m_commit, m_cursor, m_dragging, m_lockedSelected, m_selectionTool, TOOL_BASE::m_toolMgr, MD_ALT, MD_SHIFT, PCB_TOOL_BASE::module(), PCB_ACTIONS::move, PCB_ACTIONS::moveExact, MODULE::Pads(), TOOL_MANAGER::PostEvent(), PCB_ACTIONS::remove, SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), SELECTION_LOCKED, PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), GRID_HELPER::SetAuxAxes(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), SELECTION::SetReferencePoint(), GRID_HELPER::SetSnap(), KIGFX::VIEW_CONTROLS::SetSnapping(), GRID_HELPER::SetUseGrid(), KIGFX::VIEW_CONTROLS::ShowCursor(), SELECTION::Size(), TA_UNDO_REDO_PRE, TC_COMMAND, TC_MOUSE, PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PCB_ACTIONS::updateLocalRatsnest, updateModificationPoint(), PCB_BASE_FRAME::UpdateMsgPanel(), and TOOL_INTERACTIVE::Wait().

Referenced by Duplicate(), and setTransitions().

◆ MeasureTool()

int EDIT_TOOL::MeasureTool ( const TOOL_EVENT aEvent)

Launches a tool to measure between points

Definition at line 1270 of file edit_tool.cpp.

1271 {
1272  if( EditingModules() && !frame()->GetModel())
1273  return 0;
1274 
1275  auto& view = *getView();
1276  auto& controls = *getViewControls();
1278 
1279  Activate();
1280  frame()->SetToolID( toolID, wxCURSOR_PENCIL, _( "Measure distance" ) );
1281 
1282  EDA_UNITS_T units = frame()->GetUserUnits();
1284  KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, units );
1285 
1286  view.Add( &ruler );
1287  view.SetVisible( &ruler, false );
1288 
1289  GRID_HELPER grid( frame() );
1290 
1291  bool originSet = false;
1292 
1293  controls.ShowCursor( true );
1294  controls.SetAutoPan( false );
1295  controls.CaptureCursor( false );
1296 
1297  while( auto evt = Wait() )
1298  {
1299  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1300  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1301  controls.SetSnapping( !evt->Modifier( MD_ALT ) );
1302  const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr );
1303  controls.ForceCursorPosition(true, cursorPos );
1304 
1306  {
1307  break;
1308  }
1309 
1310  // click or drag starts
1311  else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
1312  {
1313  twoPtMgr.SetOrigin( cursorPos );
1314  twoPtMgr.SetEnd( cursorPos );
1315 
1316  controls.CaptureCursor( true );
1317  controls.SetAutoPan( true );
1318 
1319  originSet = true;
1320  }
1321 
1322  // second click or mouse up after drag ends
1323  else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
1324  {
1325  originSet = false;
1326 
1327  controls.SetAutoPan( false );
1328  controls.CaptureCursor( false );
1329  }
1330 
1331  // move or drag when origin set updates rules
1332  else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
1333  {
1334  twoPtMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) );
1335  twoPtMgr.SetEnd( cursorPos );
1336 
1337  view.SetVisible( &ruler, true );
1338  view.Update( &ruler, KIGFX::GEOMETRY );
1339  }
1340 
1341  else if( evt->IsAction( &ACTIONS::toggleUnits )
1342  || evt->IsAction( &PCB_ACTIONS::updateUnits ) )
1343  {
1344  if( frame()->GetUserUnits() != units )
1345  {
1346  units = frame()->GetUserUnits();
1347  ruler.SwitchUnits();
1348  view.Update( &ruler, KIGFX::GEOMETRY );
1349  }
1350  }
1351 
1352  else if( evt->IsClick( BUT_RIGHT ) )
1353  {
1355  }
1356  }
1357 
1358  view.SetVisible( &ruler, false );
1359  view.Remove( &ruler );
1360 
1361  frame()->SetNoToolSelected();
1362 
1363  return 0;
1364 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
Menu model displayed by the tool.
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
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:91
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
static TOOL_ACTION updateUnits
Definition: pcb_actions.h:309
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:74
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:289
void SetOrigin(const VECTOR2I &aOrigin)
Set the origin of the ruler (the fixed end)
KIGFX::PCB_VIEW * view() const
Class RULER_ITEM.
Definition: ruler_item.h:43
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
PCB_EDIT_FRAME::OnSelectOptionToolbar ID_PCB_MEASUREMENT_TOOL
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
Definition: tool_event.cpp:177
PCB_EDIT_FRAME * frame() const
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
bool EditingModules() const
ID_MODEDIT_MEASUREMENT_TOOL
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
KIGFX::VIEW_CONTROLS * controls() const
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1485
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
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
SGLIB_API S3DMODEL * GetModel(SCENEGRAPH *aNode)
Function GetModel creates an S3DMODEL representation of aNode (raw data, no transforms)
Definition: ifsg_api.cpp:471
static TOOL_ACTION toggleUnits
Definition: actions.h:104
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
EDA_UNITS_T
Definition: common.h:157
void SetEnd(const VECTOR2I &aEnd)
Set the current end of the rectangle (the end that moves with the cursor.
Color has changed.
Definition: view_item.h:57

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), GRID_HELPER::BestSnapAnchor(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), PCB_TOOL_BASE::controls(), PCB_TOOL_BASE::EditingModules(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), KIGFX::GEOMETRY, S3D::GetModel(), KIGFX::VIEW_CONTROLS::GetMousePosition(), EDA_DRAW_FRAME::GetUserUnits(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), ID_MODEDIT_MEASUREMENT_TOOL, ID_PCB_MEASUREMENT_TOOL, TOOL_EVT_UTILS::IsCancelInteractive(), PCB_TOOL_BASE::m_menu, MD_ALT, MD_CTRL, MD_SHIFT, KIGFX::PCB_VIEW::Remove(), KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetAngleSnap(), KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetEnd(), EDA_DRAW_FRAME::SetNoToolSelected(), KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetOrigin(), GRID_HELPER::SetSnap(), KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::SetToolID(), GRID_HELPER::SetUseGrid(), KIGFX::VIEW::SetVisible(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIGFX::PREVIEW::RULER_ITEM::SwitchUnits(), ACTIONS::toggleUnits, KIGFX::PCB_VIEW::Update(), PCB_ACTIONS::updateUnits, PCB_TOOL_BASE::view(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ 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 744 of file edit_tool.cpp.

745 {
747  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
748  { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); }, nullptr, ! m_dragging );
749 
750  if( selection.Empty() )
751  return 0;
752 
754  auto refPoint = selection.GetReferencePoint();
755  wxPoint mirrorPoint( refPoint.x, refPoint.y );
756 
757  // When editing modules, all items have the same parent
758  if( EditingModules() )
759  m_commit->Modify( selection.Front() );
760 
761  for( EDA_ITEM* item : selection )
762  {
763  // only modify items we can mirror
764  switch( item->Type() )
765  {
766  case PCB_MODULE_EDGE_T:
767  case PCB_MODULE_TEXT_T:
768  case PCB_PAD_T:
769  // Only create undo entry for items on the board
770  if( !item->IsNew() && !EditingModules() )
771  m_commit->Modify( item );
772 
773  break;
774  default:
775  continue;
776  }
777 
778  // modify each object as necessary
779  switch( item->Type() )
780  {
781  case PCB_MODULE_EDGE_T:
782  {
783  auto& edge = static_cast<EDGE_MODULE&>( *item );
784  edge.Mirror( mirrorPoint, false );
785  break;
786  }
787 
788  case PCB_MODULE_TEXT_T:
789  {
790  auto& modText = static_cast<TEXTE_MODULE&>( *item );
791  modText.Mirror( mirrorPoint, false );
792  break;
793  }
794 
795  case PCB_PAD_T:
796  {
797  auto& pad = static_cast<D_PAD&>( *item );
798  mirrorPadX( pad, mirrorPoint );
799  break;
800  }
801 
802  default:
803  // it's likely the commit object is wrong if you get here
804  assert( false );
805  break;
806  }
807  }
808 
809  if( !m_dragging )
810  m_commit->Push( _( "Mirror" ) );
811 
812  if( selection.IsHover() && !m_dragging )
814 
816 
817  if( m_dragging )
819 
820  return 0;
821 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
VECTOR2I GetReferencePoint() const
Definition: selection.h:203
bool IsHover() const
Definition: selection.h:69
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:223
bool updateModificationPoint(SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1367
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:136
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:202
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:48
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
bool EditingModules() const
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:324
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:47
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:159
const SELECTION & selection() const
static void mirrorPadX(D_PAD &aPad, const wxPoint &aMirrorPoint)
Mirror a pad in the vertical axis passing through a point.
Definition: edit_tool.cpp:721
EDA_ITEM * Front() const
Definition: selection.h:155

References PCB_TOOL_BASE::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, SELECTION::Front(), SELECTION::GetReferencePoint(), SELECTION::IsHover(), m_commit, m_dragging, m_selectionTool, TOOL_BASE::m_toolMgr, mirrorPadX(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_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()

◆ 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 981 of file edit_tool.cpp.

982 {
984  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
986 
987  if( selection.Empty() )
988  return 0;
989 
990  PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
991  wxPoint translation;
992  double rotation;
993  ROTATION_ANCHOR rotationAnchor = selection.Size() > 1 ? ROTATE_AROUND_SEL_CENTER
995 
996  DIALOG_MOVE_EXACT dialog( editFrame, translation, rotation, rotationAnchor );
997  int ret = dialog.ShowModal();
998 
999  if( ret == wxID_OK )
1000  {
1001  VECTOR2I rp = selection.GetCenter();
1002  wxPoint selCenter( rp.x, rp.y );
1003 
1004  // Make sure the rotation is from the right reference point
1005  selCenter += translation;
1006 
1007  // When editing modules, all items have the same parent
1008  if( EditingModules() )
1009  m_commit->Modify( selection.Front() );
1010 
1011  for( EDA_ITEM* selItem : selection )
1012  {
1013  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selItem );
1014 
1015  if( !item->IsNew() && !EditingModules() )
1016  m_commit->Modify( item );
1017 
1018  item->Move( translation );
1019 
1020  switch( rotationAnchor )
1021  {
1023  item->Rotate( item->GetPosition(), rotation );
1024  break;
1026  item->Rotate( selCenter, rotation );
1027  break;
1029  item->Rotate( editFrame->GetScreen()->m_O_Curseur, rotation );
1030  break;
1032  item->Rotate( editFrame->GetAuxOrigin(), rotation );
1033  break;
1034  }
1035 
1036  if( !m_dragging )
1037  getView()->Update( item );
1038  }
1039 
1040  m_commit->Push( _( "Move exact" ) );
1041 
1042  if( selection.IsHover() )
1044 
1046 
1047  if( m_dragging )
1049  }
1050 
1051  return 0;
1052 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
bool IsHover() const
Definition: selection.h:69
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
Class 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:223
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:136
bool IsNew() const
Definition: base_struct.h:222
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:202
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:1539
ROTATION_ANCHOR
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:48
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
virtual const wxPoint GetPosition() const =0
bool EditingModules() const
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:125
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:46
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:324
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:47
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:159
const SELECTION & selection() const
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
EDA_ITEM * Front() const
Definition: selection.h:155

References PCB_TOOL_BASE::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED, EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, SELECTION::Front(), PCB_BASE_FRAME::GetAuxOrigin(), SELECTION::GetCenter(), BOARD_ITEM::GetPosition(), PCB_BASE_FRAME::GetScreen(), TOOL_BASE::getView(), SELECTION::IsHover(), EDA_ITEM::IsNew(), m_commit, m_dragging, BASE_SCREEN::m_O_Curseur, 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().

◆ 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 1222 of file edit_tool.cpp.

1223 {
1224  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1225  {
1226  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
1227 
1228  if( item->Type() != PCB_PAD_T )
1229  aCollector.Remove( i );
1230  }
1231 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:143
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:114
size_t i
Definition: json11.cpp:597
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

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

Referenced by showLocalRatsnest().

◆ pickCopyReferencePoint()

bool EDIT_TOOL::pickCopyReferencePoint ( VECTOR2I aP)
private

Definition at line 1427 of file edit_tool.cpp.

1428 {
1429  STATUS_TEXT_POPUP statusPopup( frame() );
1430  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1431  bool picking = true;
1432  bool retVal = true;
1433 
1434  statusPopup.SetText( _( "Select reference point for the copy..." ) );
1435  picker->Activate();
1436  picker->SetClickHandler( [&]( const VECTOR2D& aPoint ) -> bool
1437  {
1438  aP = aPoint;
1439  statusPopup.SetText( _( "Selection copied." ) );
1440  statusPopup.Expire( 800 );
1441  picking = false;
1442  return false; // we don't need any more points
1443  } );
1444  picker->SetCancelHandler( [&]()
1445  {
1446  statusPopup.SetText( _( "Copy cancelled." ) );
1447  statusPopup.Expire( 800 );
1448  picking = false;
1449  retVal = false;
1450  } );
1451 
1452  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
1453  statusPopup.Popup();
1454 
1455  while( picking )
1456  {
1457  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
1458  Wait();
1459  }
1460 
1461  statusPopup.Hide();
1462  return retVal;
1463 }
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:83
Class STATUS_TEXT_POPUP.
Definition: status_popup.h:79
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Generic tool for picking a point.
Definition: picker_tool.h:34
PCB_EDIT_FRAME * frame() const
void SetCancelHandler(CANCEL_HANDLER aHandler)
Function SetCancelHandler() Sets a handler for cancel events (ESC or context-menu Cancel).
Definition: picker_tool.h:93
void Activate()
Function Activate() Runs the tool.

References TOOL_INTERACTIVE::Activate(), STATUS_POPUP::Expire(), PCB_TOOL_BASE::frame(), TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, STATUS_POPUP::Move(), STATUS_POPUP::Popup(), PICKER_TOOL::SetCancelHandler(), PICKER_TOOL::SetClickHandler(), STATUS_TEXT_POPUP::SetText(), and TOOL_INTERACTIVE::Wait().

Referenced by doCopyToClipboard().

◆ Properties()

int EDIT_TOOL::Properties ( const TOOL_EVENT aEvent)

Function Edit()

Displays properties window for the selected object.

Definition at line 619 of file edit_tool.cpp.

620 {
621  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
622 
624  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
625  { EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } );
626 
627  // Tracks & vias are treated in a special way:
629  {
631  {
632  DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection, *m_commit );
633  dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR
634  }
635  }
636  else if( selection.Size() == 1 ) // Properties are displayed when there is only one item selected
637  {
638  // Display properties dialog
639  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
640 
641  // Do not handle undo buffer, it is done by the properties dialogs @todo LEGACY
642  // Display properties dialog provided by the legacy canvas frame
643  editFrame->OnEditItemRequest( NULL, item );
644 
645  // Notify other tools of the changes
647  }
648 
649  if( selection.IsHover() )
650  {
652 
653  // Notify other tools of the changes -- This updates the visual ratsnest
655  }
656 
657  return 0;
658 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
bool IsHover() const
Definition: selection.h:69
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:313
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
Class 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:223
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Function OnlyTypes Creates a functor that tests if the selected items are only of given types.
virtual void OnEditItemRequest(wxDC *aDC, BOARD_ITEM *aItem)=0
Function OnEditItemRequest Install the corresponding dialog editor for the given item.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:136
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:48
bool changeTrackWidthOnClick(const SELECTION &selection)
Definition: edit_tool.cpp:578
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:125
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:159
const SELECTION & selection() const
EDA_ITEM * Front() const
Definition: selection.h:155

References changeTrackWidthOnClick(), EditToolSelectionFilter(), EXCLUDE_TRANSIENTS, SELECTION::Front(), SELECTION::IsHover(), m_commit, m_selectionTool, TOOL_BASE::m_toolMgr, PCB_BASE_EDIT_FRAME::OnEditItemRequest(), SELECTION_CONDITIONS::OnlyTypes(), 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 863 of file edit_tool.cpp.

864 {
865  ROUTER_TOOL* routerTool = static_cast<ROUTER_TOOL*>
866  ( m_toolMgr->FindTool( "pcbnew.InteractiveRouter" ) );
867 
868  // Do not delete items while actively routing.
869  if( routerTool && routerTool->Router() && routerTool->Router()->RoutingInProgress() )
870  return 1;
871 
872  std::vector<BOARD_ITEM*> lockedItems;
873 
874  // get a copy instead of reference (as we're going to clear the selection before removing items)
875  SELECTION selectionCopy;
876  bool isCut = aEvent.Parameter<intptr_t>() == static_cast<intptr_t>( PCB_ACTIONS::REMOVE_FLAGS::CUT );
877  bool isAlt = aEvent.Parameter<intptr_t>() == static_cast<intptr_t>( PCB_ACTIONS::REMOVE_FLAGS::ALT );
878 
879  // If we are in a "Cut" operation, then the copied selection exists already
880  if( isCut )
881  {
882  selectionCopy = m_selectionTool->GetSelection();
883  }
884  else
885  {
886  selectionCopy = m_selectionTool->RequestSelection(
887  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
889  }
890 
891  bool isHover = selectionCopy.IsHover();
892 
893  // in "alternative" mode, deletion is not just a simple list of selected items,
894  // it removes whole tracks, not just segments
895  if( isAlt && isHover
896  && ( selectionCopy.HasType( PCB_TRACE_T ) || selectionCopy.HasType( PCB_VIA_T ) ) )
897  {
899  }
900 
901  if( selectionCopy.Empty() )
902  return 0;
903 
904  // N.B. Setting the CUT flag prevents lock filtering as we only want to delete the items that
905  // were copied to the clipboard, no more, no fewer. Filtering for locked item, if any will be done
906  // in the copyToClipboard() routine
907  if( !m_lockedSelected && !isCut )
908  {
909  // Second RequestSelection removes locked items but keeps a copy of their pointers
910  selectionCopy = m_selectionTool->RequestSelection(
911  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
912  { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED ); }, &lockedItems );
913  }
914 
915 
916  // As we are about to remove items, they have to be removed from the selection first
918 
919  for( EDA_ITEM* item : selectionCopy )
920  {
921  if( m_editModules )
922  {
923  m_commit->Remove( item );
924  continue;
925  }
926 
927  switch( item->Type() )
928  {
929  case PCB_MODULE_TEXT_T:
930  {
931  auto text = static_cast<TEXTE_MODULE*>( item );
932  auto parent = static_cast<MODULE*>( item->GetParent() );
933 
934  if( text->GetType() == TEXTE_MODULE::TEXT_is_DIVERS )
935  {
936  m_commit->Modify( text );
937  getView()->Remove( text );
938  parent->Remove( text );
939  }
940  }
941  break;
942 
943  default:
944  m_commit->Remove( item );
945  break;
946  }
947  }
948 
949  if( isCut )
950  m_commit->Push( _( "Cut" ) );
951  else
952  m_commit->Push( _( "Delete" ) );
953 
954  if( !m_lockedSelected && lockedItems.size() > 0 )
955  {
957  STATUS_TEXT_POPUP statusPopup( frame() );
958 
959  m_lockedSelected = true;
960  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &lockedItems );
961  statusPopup.SetText( _( "Delete again to remove locked items" ) );
962  statusPopup.Expire( 2000 );
963  statusPopup.Popup();
964  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
965 
966  Activate();
967 
968  while( m_lockedSelected && statusPopup.IsShown() )
969  {
970  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
971  Wait();
972  }
973  }
974 
975  m_lockedSelected = false;
976 
977  return 0;
978 }
static TOOL_ACTION selectItems
Selects a list of items (specified as the event parameter)
Definition: pcb_actions.h:60
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
bool IsHover() const
Definition: selection.h:69
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
bool HasType(KICAD_T aType) const
Checks if there is at least one item of requested kind.
Definition: selection.h:185
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:223
Class STATUS_TEXT_POPUP.
Definition: status_popup.h:79
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
bool m_lockedSelected
Flag determining whether we are prompting for locked removal
Definition: edit_tool.h:205
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
SELECTION & GetSelection()
Function GetSelection()
PCB_EDIT_FRAME * frame() const
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:48
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
static TOOL_ACTION expandSelectedConnection
Expands the current selection to select a connection between two junctions.
Definition: pcb_actions.h:70
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
void Activate()
Function Activate() Runs the tool.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:46
bool RoutingInProgress() const
Definition: pns_router.cpp:112
ROUTER * Router() const
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:47
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:159

References TOOL_INTERACTIVE::Activate(), ACTIONS::ALT, ACTIONS::CUT, EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED, EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, PCB_ACTIONS::expandSelectedConnection, STATUS_POPUP::Expire(), TOOL_MANAGER::FindTool(), PCB_TOOL_BASE::frame(), SELECTION_TOOL::GetSelection(), TOOL_BASE::getView(), SELECTION::HasType(), SELECTION::IsHover(), 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_TRACE_T, PCB_VIA_T, STATUS_POPUP::Popup(), KIGFX::VIEW::Remove(), SELECTION_TOOL::RequestSelection(), PNS::TOOL_BASE::Router(), PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, 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 209 of file edit_tool.cpp.

210 {
211  m_dragging = false;
212 
213  if( aReason != RUN )
214  m_commit.reset( new BOARD_COMMIT( this ) );
215 }
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:223
Tool is invoked after being inactive.
Definition: tool_base.h:82
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:202

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 661 of file edit_tool.cpp.

662 {
663  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
664 
666  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
667  { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); }, nullptr, ! m_dragging );
668 
669  if( selection.Empty() )
670  return 0;
671 
673  auto refPt = selection.GetReferencePoint();
674  const int rotateAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *editFrame, aEvent );
675 
676  // When editing modules, all items have the same parent
677  if( EditingModules() )
678  m_commit->Modify( selection.Front() );
679 
680  for( auto item : selection )
681  {
682  if( !item->IsNew() && !EditingModules() )
683  m_commit->Modify( item );
684 
685  static_cast<BOARD_ITEM*>( item )->Rotate( refPt, rotateAngle );
686  }
687 
688  if( !m_dragging )
689  m_commit->Push( _( "Rotate" ) );
690 
691  if( selection.IsHover() && !m_dragging )
693 
695 
696  if( m_dragging )
698 
699  return 0;
700 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
VECTOR2I GetReferencePoint() const
Definition: selection.h:203
bool IsHover() const
Definition: selection.h:69
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=NULL, bool aConfirmLockedItems=false)
Function RequestSelection()
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:223
bool updateModificationPoint(SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1367
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:136
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:202
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:48
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
bool EditingModules() const
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
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:324
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:47
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:159
const SELECTION & selection() const
EDA_ITEM * Front() const
Definition: selection.h:155

References PCB_TOOL_BASE::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, SELECTION::Front(), TOOL_EVT_UTILS::GetEventRotationAngle(), SELECTION::GetReferencePoint(), SELECTION::IsHover(), 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 85 of file tool_interactive.cpp.

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
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 SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 251 of file pcb_tool_base.cpp.

252 {
253  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
254  const auto& selection = selTool->GetSelection();
255  return selection;
256 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
const SELECTION & selection() const

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

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), changeTrackWidthOnClick(), PAD_TOOL::copyPadSettings(), CreateArray(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), doCopyToClipboard(), Duplicate(), editFootprintInFpEditor(), ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), Flip(), DRAWING_TOOL::getSourceZoneForAction(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), Main(), Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), MoveExact(), POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), Properties(), PAD_TOOL::pushPadSettings(), Rotate(), SELECTION_TOOL::selectCopper(), PCB_TOOL_BASE::selection(), SELECTION_TOOL::selectNet(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 258 of file pcb_tool_base.cpp.

259 {
260  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
261  auto& selection = selTool->GetSelection();
262  return selection;
263 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
const 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 74 of file tool_interactive.cpp.

75 {
76  if( aMenu )
77  aMenu->SetTool( this );
78  else
79  aTrigger = CMENU_OFF;
80 
81  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
82 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
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(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), TOOL_MENU::ShowContextMenu(), and SCH_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 97 of file pcb_tool_base.h.

98  {
99  m_editModules = aEnabled;
100  }

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 1526 of file edit_tool.cpp.

1527 {
1528  Go( &EDIT_TOOL::Main, PCB_ACTIONS::editActivate.MakeEvent() );
1529  Go( &EDIT_TOOL::Main, PCB_ACTIONS::move.MakeEvent() );
1530  Go( &EDIT_TOOL::Drag, PCB_ACTIONS::drag45Degree.MakeEvent() );
1532  Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCw.MakeEvent() );
1533  Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCcw.MakeEvent() );
1534  Go( &EDIT_TOOL::Flip, PCB_ACTIONS::flip.MakeEvent() );
1535  Go( &EDIT_TOOL::Remove, PCB_ACTIONS::remove.MakeEvent() );
1536  Go( &EDIT_TOOL::Remove, PCB_ACTIONS::removeAlt.MakeEvent() );
1542  Go( &EDIT_TOOL::Mirror, PCB_ACTIONS::mirror.MakeEvent() );
1543 
1548 
1549  Go( &EDIT_TOOL::copyToClipboard, ACTIONS::copy.MakeEvent() );
1550  Go( &EDIT_TOOL::cutToClipboard, ACTIONS::cut.MakeEvent() );
1551 }
int Main(const TOOL_EVENT &aEvent)
Function Main()
Definition: edit_tool.cpp:326
int Properties(const TOOL_EVENT &aEvent)
Function Edit()
Definition: edit_tool.cpp:619
int Rotate(const TOOL_EVENT &aEvent)
Function Rotate()
Definition: edit_tool.cpp:661
static TOOL_ACTION move
move an item
Definition: pcb_actions.h:92
int ExchangeFootprints(const TOOL_EVENT &aEvent)
Function ExchangeFootprints()
Definition: edit_tool.cpp:1246
static TOOL_ACTION editActivate
Activation of the edit tool.
Definition: pcb_actions.h:89
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:133
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:105
static TOOL_ACTION removeAlt
Definition: pcb_actions.h:124
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:132
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:102
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.
Definition: edit_tool.cpp:744
static TOOL_ACTION moveExact
Activation of the exact move tool.
Definition: pcb_actions.h:108
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:1510
static TOOL_ACTION duplicate
Activation of the duplication tool.
Definition: pcb_actions.h:111
static TOOL_ACTION copy
Definition: actions.h:53
int Flip(const TOOL_EVENT &aEvent)
Function Flip()
Definition: edit_tool.cpp:824
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
Definition: pcb_actions.h:114
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:95
static TOOL_ACTION createArray
Tool for creating an array of objects.
Definition: pcb_actions.h:270
static TOOL_ACTION cut
Definition: actions.h:52
int Drag(const TOOL_EVENT &aEvent)
Function Drag()
Definition: edit_tool.cpp:314
static TOOL_ACTION exchangeFootprints
Exchange footprints of modules.
Definition: pcb_actions.h:120
static TOOL_ACTION updateFootprints
Update footprints to reflect any changes in the library.
Definition: pcb_actions.h:117
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:96
int MoveExact(const TOOL_EVENT &aEvent)
Function MoveExact()
Definition: edit_tool.cpp:981
int Remove(const TOOL_EVENT &aEvent)
Function Remove()
Definition: edit_tool.cpp:863
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:99
int CreateArray(const TOOL_EVENT &aEvent)
Function CreateArray()
Definition: edit_tool.cpp:1204
int MeasureTool(const TOOL_EVENT &aEvent)
Launches a tool to measure between points
Definition: edit_tool.cpp:1270
static TOOL_ACTION editFootprintInFpEditor
Definition: pcb_actions.h:332
int editFootprintInFpEditor(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:1390
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:1498
static TOOL_ACTION remove
Deleting a BOARD_ITEM.
Definition: pcb_actions.h:123
int Duplicate(const TOOL_EVENT &aEvent)
Function Duplicate()
Definition: edit_tool.cpp:1055
static TOOL_ACTION measureTool
Definition: pcb_actions.h:308

References ACTIONS::copy, copyToClipboard(), CreateArray(), PCB_ACTIONS::createArray, ACTIONS::cut, cutToClipboard(), Drag(), PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, PCB_ACTIONS::duplicate, Duplicate(), PCB_ACTIONS::duplicateIncrement, PCB_ACTIONS::editActivate, editFootprintInFpEditor(), PCB_ACTIONS::editFootprintInFpEditor, PCB_ACTIONS::exchangeFootprints, ExchangeFootprints(), PCB_ACTIONS::flip, Flip(), TOOL_INTERACTIVE::Go(), Main(), MeasureTool(), PCB_ACTIONS::measureTool, PCB_ACTIONS::mirror, Mirror(), PCB_ACTIONS::move, PCB_ACTIONS::moveExact, MoveExact(), Properties(), PCB_ACTIONS::properties, Remove(), PCB_ACTIONS::remove, PCB_ACTIONS::removeAlt, Rotate(), PCB_ACTIONS::rotateCcw, PCB_ACTIONS::rotateCw, and PCB_ACTIONS::updateFootprints.

◆ updateModificationPoint()

bool EDIT_TOOL::updateModificationPoint ( SELECTION aSelection)
private

Returns the right modification point (e.g.

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

Definition at line 1367 of file edit_tool.cpp.

1368 {
1369  if( m_dragging && aSelection.HasReferencePoint() )
1370  return false;
1371 
1372  // When there is only one item selected, the reference point is its position...
1373  if( aSelection.Size() == 1 )
1374  {
1375  auto item = static_cast<BOARD_ITEM*>( aSelection.Front() );
1376  auto pos = item->GetPosition();
1377  aSelection.SetReferencePoint( VECTOR2I( pos.x, pos.y ) );
1378  }
1379  // ...otherwise modify items with regard to the grid-snapped cursor position
1380  else
1381  {
1383  aSelection.SetReferencePoint( m_cursor );
1384  }
1385 
1386  return true;
1387 }
VECTOR2I m_cursor
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).
Definition: edit_tool.h:209
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:208
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:202
bool HasReferencePoint() const
Definition: selection.h:198
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:155

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

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

◆ view()

◆ Wait()

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

Function Wait()

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

Definition at line 55 of file tool_interactive.cpp.

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

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

Referenced by LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_DRAWING_TOOLS::doPlaceComponent(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), Remove(), GERBVIEW_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(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), and SCH_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

Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).

Definition at line 209 of file edit_tool.h.

Referenced by Main(), and updateModificationPoint().

◆ m_dragging

bool EDIT_TOOL::m_dragging
private

Flag determining if anything is being dragged right now

Definition at line 202 of file edit_tool.h.

Referenced by Flip(), Main(), Mirror(), MoveExact(), Reset(), Rotate(), and updateModificationPoint().

◆ m_editModules

◆ m_lockedSelected

bool EDIT_TOOL::m_lockedSelected
private

Flag determining whether we are prompting for locked removal

Definition at line 205 of file edit_tool.h.

Referenced by Main(), and Remove().

◆ m_menu

◆ m_selectionTool

SELECTION_TOOL* EDIT_TOOL::m_selectionTool
private

Selection tool used for obtaining selected items

Definition at line 199 of file edit_tool.h.

Referenced by CreateArray(), doCopyToClipboard(), Duplicate(), editFootprintInFpEditor(), ExchangeFootprints(), Flip(), Init(), Main(), Mirror(), MoveExact(), Properties(), Remove(), and Rotate().

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

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

Referenced by TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemToSel(), SCH_DRAWING_TOOLS::AddJunction(), SCH_DRAWING_TOOLS::AddLabel(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDITOR_CONTROL::ClearHighlight(), PCB_EDITOR_CONTROL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), SCH_EDITOR_CONTROL::Cut(), LIB_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_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), SCH_WIRE_BUS_TOOL::DrawBusses(), DRAWING_TOOL::DrawDimension(), SCH_WIRE_BUS_TOOL::DrawLines(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_WIRE_BUS_TOOL::DrawWires(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), Duplicate(), editFootprintInFpEditor(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), SCH_EDITOR_CONTROL::EnterSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), SCH_WIRE_BUS_TOOL::finishSegments(), Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), invokeInlineRouter(), isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), MoveExact(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), pickCopyReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), Properties(), PAD_TOOL::pushPadSettings(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), Remove(), POINT_EDITOR::removeCorner(), EE_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), SELECTION_TOOL::RequestSelection(), CVPCB_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), Rotate(), TOOL_INTERACTIVE::RunMainStack(), EE_SELECTION_TOOL::SelectConnection(), SELECTION_TOOL::selectCopper(), PCB_TOOL_BASE::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), EE_SELECTION_TOOL::SelectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SCH_WIRE_BUS_TOOL::StartBus(), SCH_WIRE_BUS_TOOL::StartLine(), SCH_WIRE_BUS_TOOL::StartWire(), GERBVIEW_SELECTION_TOOL::toggleSelection(), EE_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), SCH_EDITOR_CONTROL::Undo(), SCH_WIRE_BUS_TOOL::UnfoldBus(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

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

Definition at line 215 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 217 of file tool_base.h.

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

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 208 of file tool_base.h.

Referenced by TOOL_BASE::GetType().


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