KiCad PCB EDA Suite
EDIT_TOOL Class Reference

EDIT_TOOL. More...

#include <edit_tool.h>

Inheritance diagram for EDIT_TOOL:
PCB_TOOL_BASE TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 EDIT_TOOL ()
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
int GetAndPlace (const TOOL_EVENT &aEvent)
 

Find an item and start moving.

More...
 
int Move (const TOOL_EVENT &aEvent)
 Function Move() Main loop in which events are handled. More...
 
int Drag (const TOOL_EVENT &aEvent)
 Function Drag() Invoke the PNS router to drag tracks. More...
 
int Properties (const TOOL_EVENT &aEvent)
 Function Properties() Displays properties window for the selected object. More...
 
int Rotate (const TOOL_EVENT &aEvent)
 Function Rotate() Rotates currently selected items. More...
 
int Flip (const TOOL_EVENT &aEvent)
 Function Flip() Rotates currently selected items. More...
 
int Mirror (const TOOL_EVENT &aEvent)
 Function Mirror Mirrors the current selection. More...
 
int ChangeTrackWidth (const TOOL_EVENT &aEvent)
 
int Remove (const TOOL_EVENT &aEvent)
 Function Remove() Deletes currently selected items. More...
 
int Duplicate (const TOOL_EVENT &aEvent)
 Function Duplicate() Duplicates the current selection and starts a move action. More...
 
int MoveExact (const TOOL_EVENT &aEvent)
 Function MoveExact() Invokes a dialog box to allow moving of the item by an exact amount. More...
 
int CreateArray (const TOOL_EVENT &aEvent)
 Function CreateArray() Creates an array of the selected items, invoking the array editor dialog to set the options. 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 cutToClipboard (const TOOL_EVENT &aEvent)
 Function cutToClipboard() Cuts the current selection to the clipboard by formatting it as a fake pcb see AppendBoardFromClipboard for importing. More...
 
BOARD_COMMITGetCurrentCommit () const
 
void SetEditModules (bool aEnabled)
 Function SetEditModules() More...
 
bool EditingModules () const
 
void Activate ()
 Function Activate() Runs the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Static Public Member Functions

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

Protected Types

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

Protected Member Functions

void doInteractiveItemPlacement (const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_BASE_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
const PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const PCBNEW_SELECTIONselection () const
 
PCBNEW_SELECTIONselection ()
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

bool m_editModules
 
TOOL_MENU m_menu
 functions below are not yet implemented - their interface may change More...
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

bool updateModificationPoint (PCBNEW_SELECTION &aSelection)
 

Returns the right modification point (e.g.

More...
 
int EditFpInFpEditor (const TOOL_EVENT &aEvent)
 
bool invokeInlineRouter (int aDragMode)
 
bool isInteractiveDragEnabled () const
 
bool pickCopyReferencePoint (VECTOR2I &aReferencePoint)
 

Private Attributes

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

Detailed Description

EDIT_TOOL.

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

Definition at line 66 of file edit_tool.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

Enumerator
IPO_ROTATE 
IPO_FLIP 
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 79 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ EDIT_TOOL()

EDIT_TOOL::EDIT_TOOL ( )

Definition at line 100 of file edit_tool.cpp.

100  :
101  PCB_TOOL_BASE( "pcbnew.InteractiveEdit" ),
103  m_dragging( false ),
104  m_lockedSelected( false )
105 {
106 }
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
bool m_lockedSelected
Definition: edit_tool.h:191
#define NULL
bool m_dragging
Definition: edit_tool.h:190
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 51 of file tool_interactive.cpp.

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.

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

Referenced by AUTOPLACE_TOOL::autoplace(), copyToClipboard(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), MeasureTool(), Move(), LIB_TREE::onContextMenu(), POINT_EDITOR::OnSelectionChange(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), 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(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

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

Definition at line 60 of file tool_base.cpp.

61 {
62  m_toolMgr = aManager;
63  m_toolSettings = TOOL_SETTINGS( this );
64 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:220
friend class TOOL_SETTINGS
Definition: tool_base.h:154

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 151 of file pcb_tool_base.h.

151 { return getModel<BOARD>(); }

Referenced by PCBNEW_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), PCB_INSPECTION_TOOL::ClearHighlight(), DRAWING_TOOL::constrainDimension(), copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PAD_TOOL::EnumeratePads(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), ZONE_FILLER_TOOL::FillAllZones(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::getCollectorsGuide(), PCBNEW_CONTROL::GraphicDisplayMode(), PCB_INSPECTION_TOOL::highlightNet(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PCB_TOOL_BASE::module(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::Paste(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), 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::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectConnectedTracks(), SELECTION_TOOL::selectPoint(), DRC::testDisabledLayers(), DRC::TestZoneToZoneOutline(), PCBNEW_CONTROL::TrackDisplayMode(), POINT_EDITOR::updateItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCBNEW_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ canvas()

◆ ChangeTrackWidth()

int EDIT_TOOL::ChangeTrackWidth ( const TOOL_EVENT aEvent)

Definition at line 515 of file edit_tool.cpp.

516 {
518  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
519  { EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } );
520 
521  for( EDA_ITEM* item : selection )
522  {
523  if( auto via = dyn_cast<VIA*>( item ) )
524  {
525  m_commit->Modify( item );
526 
527  int new_width;
528  int new_drill;
529 
530  if( via->GetViaType() == VIATYPE::MICROVIA )
531  {
532  auto net = via->GetNet();
533 
534  new_width = net->GetMicroViaSize();
535  new_drill = net->GetMicroViaDrillSize();
536  }
537  else
538  {
539  new_width = board()->GetDesignSettings().GetCurrentViaSize();
540  new_drill = board()->GetDesignSettings().GetCurrentViaDrill();
541  }
542 
543  via->SetDrill( new_drill );
544  via->SetWidth( new_width );
545  }
546  else if ( auto track = dyn_cast<TRACK*>( item ) )
547  {
548  m_commit->Modify( item );
549 
550  int new_width = board()->GetDesignSettings().GetCurrentTrackWidth();
551  track->SetWidth( new_width );
552  }
553  }
554 
555  m_commit->Push( _("Edit track width/via size") );
556 
557  if( selection.IsHover() )
558  {
560 
561  // Notify other tools of the changes -- This updates the visual ratsnest
563  }
564 
565  return 0;
566 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
bool IsHover() const
Definition: selection.h:70
BOARD * board() const
int GetCurrentViaDrill() const
Function GetCurrentViaDrill.
int GetCurrentTrackWidth() const
Function GetCurrentTrackWidth.
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:194
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:201
const PCBNEW_SELECTION & selection() const
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
int GetCurrentViaSize() const
Function GetCurrentViaSize.
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
#define _(s)
Definition: 3d_actions.cpp:31
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:59

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

Referenced by setTransitions().

◆ controls()

◆ copyToClipboard()

int EDIT_TOOL::copyToClipboard ( const TOOL_EVENT aEvent)

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

Definition at line 1379 of file edit_tool.cpp.

1380 {
1381  CLIPBOARD_IO io;
1382 
1383  Activate();
1384 
1386  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1388 
1389  if( selection.Empty() )
1390  return 1;
1391 
1392  VECTOR2I refPoint;
1393  bool rv = pickCopyReferencePoint( refPoint );
1394  frame()->SetMsgPanel( board() );
1395 
1396  if( !rv )
1397  return 1;
1398 
1399  selection.SetReferencePoint( refPoint );
1400 
1401  io.SetBoard( board() );
1402  io.SaveSelection( selection );
1403 
1404  return 0;
1405 }
BOARD * board() const
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
void SetBoard(BOARD *aBoard)
PCB_BASE_EDIT_FRAME * frame() const
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:244
const PCBNEW_SELECTION & selection() const
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
void SaveSelection(const PCBNEW_SELECTION &selected)
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
void Activate()
Function Activate() Runs the tool.
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:59
bool pickCopyReferencePoint(VECTOR2I &aReferencePoint)
Definition: edit_tool.cpp:1326

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 cutToClipboard(), and setTransitions().

◆ CreateArray()

int EDIT_TOOL::CreateArray ( const TOOL_EVENT aEvent)

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

Definition at line 1099 of file edit_tool.cpp.

1100 {
1102  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1104 
1105  if( selection.Empty() )
1106  return 0;
1107 
1108  // we have a selection to work on now, so start the tool process
1109  PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
1110  ARRAY_CREATOR array_creator( *editFrame, m_editModules, selection );
1111  array_creator.Invoke();
1112 
1113  return 0;
1114 }
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
const PCBNEW_SELECTION & selection() const
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:59
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.

Definition at line 1408 of file edit_tool.cpp.

1409 {
1410  if( !copyToClipboard( aEvent ) )
1411  {
1412  // N.B. Setting the CUT flag prevents lock filtering as we only want to delete the items that
1413  // were copied to the clipboard, no more, no fewer. Filtering for locked item, if any will be done
1414  // in the copyToClipboard() routine
1415  TOOL_EVENT evt( aEvent.Category(), aEvent.Action(), TOOL_ACTION_SCOPE::AS_GLOBAL );
1417  Remove( evt );
1418  }
1419 
1420  return 0;
1421 }
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition: tool_event.h:250
TOOL_EVENT_CATEGORY Category() const
Returns the category (eg. mouse/keyboard/action) of an event..
Definition: tool_event.h:247
void SetParameter(T aParam)
Function SetParameter() Sets a non-standard parameter assigned to the event.
Definition: tool_event.h:453
TOOL_EVENT.
Definition: tool_event.h:171
All active tools
Definition: tool_event.h:147
int Remove(const TOOL_EVENT &aEvent)
Function Remove() Deletes currently selected items.
Definition: edit_tool.cpp:819
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:1379

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

Referenced by setTransitions().

◆ displayOptions()

◆ doInteractiveItemPlacement()

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

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

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

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

Definition at line 36 of file pcb_tool_base.cpp.

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

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

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

◆ Drag()

int EDIT_TOOL::Drag ( const TOOL_EVENT aEvent)

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

Definition at line 235 of file edit_tool.cpp.

236 {
237  int mode = PNS::DM_ANY;
238 
239  if( aEvent.IsAction( &PCB_ACTIONS::dragFreeAngle ) )
240  mode |= PNS::DM_FREE_ANGLE;
241 
242  invokeInlineRouter( mode );
243 
244  return 0;
245 }
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:144
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:206

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

1026 {
1027  bool increment = aEvent.IsAction( &PCB_ACTIONS::duplicateIncrement );
1028 
1029  // Be sure that there is at least one item that we can modify
1031  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1033 
1034  if( selection.Empty() )
1035  return 0;
1036 
1037  // we have a selection to work on now, so start the tool process
1038  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1039 
1040  // If the selection was given a hover, we do not keep the selection after completion
1041  bool is_hover = selection.IsHover();
1042 
1043  std::vector<BOARD_ITEM*> new_items;
1044  new_items.reserve( selection.Size() );
1045 
1046  BOARD_ITEM* orig_item = nullptr;
1047  BOARD_ITEM* dupe_item = nullptr;
1048 
1049  // Each selected item is duplicated and pushed to new_items list
1050  // Old selection is cleared, and new items are then selected.
1051  for( EDA_ITEM* item : selection )
1052  {
1053  orig_item = static_cast<BOARD_ITEM*>( item );
1054 
1055  if( m_editModules )
1056  dupe_item = editFrame->GetBoard()->GetFirstModule()->Duplicate( orig_item, increment );
1057  else
1058  dupe_item = editFrame->GetBoard()->Duplicate( orig_item );
1059 
1060  if( dupe_item )
1061  {
1062  // Clear the selection flag here, otherwise the SELECTION_TOOL
1063  // will not properly select it later on
1064  dupe_item->ClearSelected();
1065 
1066  new_items.push_back( dupe_item );
1067  m_commit->Add( dupe_item );
1068  }
1069  }
1070 
1071  // Clear the old selection first
1073 
1074  // Select the new items
1075  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &new_items );
1076 
1077  // record the new items as added
1078  if( !selection.Empty() )
1079  {
1080  editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ),
1081  (int) new_items.size() ) );
1082 
1083  // If items were duplicated, pick them up
1084  // this works well for "dropping" copies around and pushes the commit
1086  Move( evt );
1087 
1088  // After moving the new items, we need to refresh the group and view flags
1090 
1091  if( !is_hover )
1092  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &new_items );
1093  }
1094 
1095  return 0;
1096 }
static TOOL_ACTION selectItems
Selects a list of items (specified as the event parameter)
Definition: pcb_actions.h:80
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:103
bool IsHover() const
Definition: selection.h:70
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:194
void ClearSelected()
Definition: base_struct.h:233
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
BOARD_ITEM * Duplicate(const BOARD_ITEM *aItem, bool aIncrementPadNumbers, bool aAddToModule=false)
Function Duplicate Duplicate a given item within the module, without adding to the board.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
Definition: pcb_actions.h:129
const PCBNEW_SELECTION & selection() const
TOOL_EVENT.
Definition: tool_event.h:171
MODULE * GetFirstModule() const
Gets the first module in the list (used in footprint viewer/editor) or NULL if none.
Definition: class_board.h:275
int Move(const TOOL_EVENT &aEvent)
Function Move() Main loop in which events are handled.
Definition: edit_tool.cpp:247
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
Common, abstract interface for edit frames.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:31
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
TOOL_EVENT MakeEvent() const
Function MakeEvent() Returns the event associated with the action (i.e.
Definition: tool_action.h:107
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
BOARD * GetBoard() const
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:59
void DisplayToolMsg(const wxString &msg) override
BOARD_ITEM * Duplicate(const BOARD_ITEM *aItem, bool aAddToBoard=false)

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

Referenced by setTransitions().

◆ EditFpInFpEditor()

int EDIT_TOOL::EditFpInFpEditor ( const TOOL_EVENT aEvent)
private

Definition at line 1292 of file edit_tool.cpp.

1293 {
1295 
1296  if( selection.Empty() )
1297  return 0;
1298 
1299  MODULE* mod = selection.FirstOfKind<MODULE>();
1300 
1301  if( !mod )
1302  return 0;
1303 
1304  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1305 
1306  if( mod->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
1307  {
1308  mod->SetTimeStamp( GetNewTimeStamp() );
1309  editFrame->OnModify();
1310  }
1311 
1312  auto editor = (FOOTPRINT_EDIT_FRAME*) editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1313 
1314  editor->Load_Module_From_BOARD( mod );
1315 
1316  editor->Show( true );
1317  editor->Raise(); // Iconize( false );
1318 
1319  if( selection.IsHover() )
1321 
1322  return 0;
1323 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
bool IsHover() const
Definition: selection.h:70
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
timestamp_t GetNewTimeStamp()
Definition: common.cpp:215
const PCBNEW_SELECTION & selection() const
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:341
timestamp_t GetTimeStamp() const
Definition: base_struct.h:213
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
Common, abstract interface for edit frames.
T * FirstOfKind() const
Definition: selection.h:194
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
Function FootprintFilter() A selection filter which prunes the selection to contain only items of typ...
Definition: edit_tool.cpp:1129
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:212

References SELECTION::Empty(), SELECTION::FirstOfKind(), FootprintFilter(), FRAME_FOOTPRINT_EDITOR, GetNewTimeStamp(), EDA_ITEM::GetTimeStamp(), SELECTION::IsHover(), KIWAY_HOLDER::Kiway(), m_selectionTool, TOOL_BASE::m_toolMgr, PCB_BASE_FRAME::OnModify(), KIWAY::Player(), SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, 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(), MeasureTool(), Mirror(), Move(), MoveExact(), and Rotate().

◆ Flip()

int EDIT_TOOL::Flip ( const TOOL_EVENT aEvent)

Function Flip() Rotates currently selected items.

The rotation point is the current cursor position.

Definition at line 770 of file edit_tool.cpp.

771 {
773  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
775  nullptr, ! m_dragging );
776 
777  if( selection.Empty() )
778  return 0;
779 
781 
782  // Flip around the anchor for footprints, and the bounding box center for board items
783  VECTOR2I modPoint = EditingModules() ? VECTOR2I( 0, 0 ) : selection.GetCenter();
784 
785  // If only one item selected, flip around the item anchor point, instead
786  // of the bounding box center, to avoid moving the item anchor
787  if( selection.GetSize() == 1 )
788  modPoint = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) )->GetPosition();
789 
790  bool leftRight = frame()->Settings().m_FlipLeftRight;
791 
792  // When editing modules, all items have the same parent
793  if( EditingModules() )
794  m_commit->Modify( selection.Front() );
795 
796  for( EDA_ITEM* item : selection )
797  {
798  if( !item->IsNew() && !EditingModules() )
799  m_commit->Modify( item );
800 
801  static_cast<BOARD_ITEM*>( item )->Flip( modPoint, leftRight );
802  }
803 
804  if( !m_dragging )
805  m_commit->Push( _( "Flip" ) );
806 
807  if( selection.IsHover() && !m_dragging )
809 
811 
812  if( m_dragging )
814 
815  return 0;
816 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
bool IsHover() const
Definition: selection.h:70
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:194
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:201
PCB_BASE_EDIT_FRAME * frame() const
const PCBNEW_SELECTION & selection() const
bool m_dragging
Definition: edit_tool.h:190
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
PCB_GENERAL_SETTINGS & Settings()
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:104
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
bool EditingModules() const
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:99
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
#define _(s)
Definition: 3d_actions.cpp:31
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:420
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
bool updateModificationPoint(PCBNEW_SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1269
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:59
EDA_ITEM * Front() const
Definition: selection.h:183

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

Referenced by setTransitions().

◆ FootprintFilter()

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

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

Definition at line 1129 of file edit_tool.cpp.

1130 {
1131  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1132  {
1133  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
1134 
1135  if( item->Type() != PCB_MODULE_T )
1136  aCollector.Remove( i );
1137  }
1138 }
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:145
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:116
class MODULE, a footprint
Definition: typeinfo.h:89
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207

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

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

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 146 of file pcb_tool_base.h.

147  {
148  return getEditFrame<PCB_BASE_EDIT_FRAME>();
149  }

Referenced by POINT_EDITOR::addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), ROUTER_TOOL::CustomTrackWidthDialog(), MODULE_EDITOR_TOOLS::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), 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(), PAD_TOOL::EnumeratePads(), PCB_EDITOR_CONTROL::ExportSpecctraDSN(), ROUTER_TOOL::finishInteractive(), Flip(), PCB_EDITOR_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), MODULE_EDITOR_TOOLS::ImportFootprint(), PCB_EDITOR_CONTROL::ImportSpecctraSession(), SELECTION_TOOL::Init(), Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), MeasureTool(), Move(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), pickCopyReferencePoint(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), Remove(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), POINT_EDITOR::setEditedPoint(), ROUTER_TOOL::SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), ROUTER_TOOL::switchLayerOnViaPlacement(), POINT_EDITOR::updateItem(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ GetAndPlace()

int EDIT_TOOL::GetAndPlace ( const TOOL_EVENT aEvent)

Find an item and start moving.

Definition at line 188 of file edit_tool.cpp.

189 {
190  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
191  MODULE* module = getEditFrame<PCB_BASE_FRAME>()->GetFootprintFromBoardByReference();
192 
193  if( module )
194  {
197 
198  selectionTool->GetSelection().SetReferencePoint( module->GetPosition() );
200  }
201 
202  return 0;
203 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:103
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:244
MODULE * module() const
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:76
const wxPoint GetPosition() const override
Definition: class_module.h:210

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

Referenced by setTransitions().

◆ GetCurrentCommit()

BOARD_COMMIT* EDIT_TOOL::GetCurrentCommit ( ) const
inline

Definition at line 174 of file edit_tool.h.

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

References m_commit.

◆ getEditFrame()

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

Function getEditFrame()

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

Definition at line 187 of file tool_base.h.

188  {
189 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
190  wxASSERT( dynamic_cast<T*>( getEditFrameInt() ) );
191 #endif
192  return static_cast<T*>( getEditFrameInt() );
193  }
EDA_BASE_FRAME * getEditFrameInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getEditFrameInt().

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

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

References TOOL_BASE::m_toolId.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), TOOL_MANAGER::runTool(), 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 143 of file tool_base.h.

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

References TOOL_BASE::m_toolMgr.

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

◆ getModel()

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 201 of file tool_base.h.

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

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

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

References TOOL_BASE::m_toolName.

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

◆ GetSettings()

TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 78 of file tool_base.cpp.

79 {
80  return m_toolSettings;
81 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:220

References TOOL_BASE::m_toolSettings.

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

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 110 of file tool_base.h.

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

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), 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 36 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), EE_SELECTION_TOOL::ClearSelection(), COMMON_TOOLS::CursorControl(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), COMMON_TOOLS::GridPreset(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::GuessSelectionCandidates(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), MeasureTool(), SCH_EDIT_TOOL::Mirror(), MoveExact(), SCH_MOVE_TOOL::moveItem(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), 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(), SCH_EDITOR_CONTROL::UpdateFind(), 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(), SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

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

Function getViewControls()

Returns the instance of VIEW_CONTROLS object used in the application. It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.)

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

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

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_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), COMMON_TOOLS::GridPreset(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::HighlightNetTool(), MODULE_EDITOR_TOOLS::ImportFootprint(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), MeasureTool(), Move(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LIB_DRAWING_TOOLS::PlaceAnchor(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), 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(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCBNEW_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), LIB_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 129 of file tool_interactive.h.

131 {
132  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
133 
134  goInternal( sptr, aConditions );
135 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by LENGTH_TUNER_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_CONTROL::setTransitions(), LIB_PIN_TOOL::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), POINT_EDITOR::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), LIB_CONTROL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), PCBNEW_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), setTransitions(), SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), EE_SELECTION_TOOL::setTransitions(), and DRC::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 118 of file edit_tool.cpp.

119 {
120  // Find the selection tool, so they can cooperate
121  m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
122  wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" );
123 
124  auto editingModuleCondition = [ this ] ( const SELECTION& aSelection ) {
125  return m_editModules;
126  };
127 
128  auto singleModuleCondition = SELECTION_CONDITIONS::OnlyType( PCB_MODULE_T )
130 
131  auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) {
132  return frame()->ToolStackIsEmpty();
133  };
134 
135  // Add context menu entries that are displayed when selection tool is active
137 
149 
154  menu.AddItem( PCB_ACTIONS::mirror, editingModuleCondition && SELECTION_CONDITIONS::NotEmpty );
155 
156  menu.AddSeparator();
159  // Selection tool handles the context menu for some other tools, such as the Picker.
160  // Don't add things like Paste when another tool is active.
161  menu.AddItem( ACTIONS::paste, noActiveToolCondition );
162 
163  // Footprint actions
164  menu.AddSeparator();
165  menu.AddItem( PCB_ACTIONS::editFootprintInFpEditor, singleModuleCondition );
166  menu.AddItem( PCB_ACTIONS::updateFootprint, singleModuleCondition );
167  menu.AddItem( PCB_ACTIONS::changeFootprint, singleModuleCondition );
168 
169  // Populate the context menu displayed during the edit tool (primarily the measure tool)
170  auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
171  return frame()->ToolStackIsEmpty();
172  };
173 
174  auto frame = getEditFrame<PCB_BASE_FRAME>();
175  auto& ctxMenu = m_menu.GetMenu();
176 
177  // "Cancel" goes at the top of the context menu when a tool is active
178  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
179  ctxMenu.AddSeparator( 1 );
180 
181  if( frame )
183 
184  return true;
185 }
void AddStandardSubMenus(TOOL_MENU &aMenu)
Function CreateBasicMenu.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:103
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:313
static TOOL_ACTION doDelete
Definition: actions.h:74
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Function OnlyTypes Creates a functor that tests if the selected items are only of given types.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:144
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:120
TOOL_MENU & GetToolMenu()
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:143
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:114
static TOOL_ACTION changeFootprint
Definition: pcb_actions.h:305
static TOOL_ACTION updateFootprint
Definition: pcb_actions.h:303
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
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:123
PCB_BASE_EDIT_FRAME * frame() const
class MODULE, a footprint
Definition: typeinfo.h:89
static TOOL_ACTION copy
Definition: actions.h:70
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:107
static TOOL_ACTION createArray
Tool for creating an array of objects.
Definition: pcb_actions.h:366
static TOOL_ACTION cut
Definition: actions.h:69
static TOOL_ACTION inlineBreakTrack
Breaks track when router is not activated.
Definition: pcb_actions.h:141
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:108
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:111
bool ToolStackIsEmpty()
static TOOL_ACTION editFootprintInFpEditor
Definition: pcb_actions.h:324
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:219
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
static TOOL_ACTION paste
Definition: actions.h:71
static TOOL_ACTION duplicate
Definition: actions.h:73

References CONDITIONAL_MENU::AddItem(), CONDITIONAL_MENU::AddSeparator(), EDA_DRAW_FRAME::AddStandardSubMenus(), ACTIONS::cancelInteractive, PCB_ACTIONS::changeFootprint, ACTIONS::copy, SELECTION_CONDITIONS::Count(), PCB_ACTIONS::createArray, ACTIONS::cut, ACTIONS::doDelete, PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, ACTIONS::duplicate, PCB_ACTIONS::editFootprintInFpEditor, TOOL_MANAGER::FindTool(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), TOOL_MENU::GetMenu(), TOOL_INTERACTIVE::GetToolMenu(), PCB_ACTIONS::inlineBreakTrack, PCB_TOOL_BASE::m_editModules, TOOL_INTERACTIVE::m_menu, 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::rotateCcw, PCB_ACTIONS::rotateCw, EDA_BASE_FRAME::ToolStackIsEmpty(), GENERAL_COLLECTOR::Tracks, and PCB_ACTIONS::updateFootprint.

◆ invokeInlineRouter()

bool EDIT_TOOL::invokeInlineRouter ( int  aDragMode)
private

Definition at line 206 of file edit_tool.cpp.

207 {
209 
210  if( !theRouter )
211  return false;
212 
213  // make sure we don't accidentally invoke inline routing mode while the router is already active!
214  if( theRouter->IsToolActive() )
215  return false;
216 
217  if( theRouter->CanInlineDrag() )
218  {
220  return true;
221  }
222 
223  return false;
224 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:198
static ROUTER * theRouter
Definition: pns_router.cpp:58

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

Referenced by Drag(), and Move().

◆ isInteractiveDragEnabled()

bool EDIT_TOOL::isInteractiveDragEnabled ( ) const
private

Definition at line 227 of file edit_tool.cpp.

228 {
229  auto theRouter = static_cast<ROUTER_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveRouter" ) );
230 
231  return theRouter ? theRouter->Router()->Settings().InlineDragEnabled() : false;
232 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
static ROUTER * theRouter
Definition: pns_router.cpp:58
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:190

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

Referenced by Move().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

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

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

◆ MeasureTool()

int EDIT_TOOL::MeasureTool ( const TOOL_EVENT aEvent)

Launches a tool to measure between points

Definition at line 1141 of file edit_tool.cpp.

1142 {
1143  if( EditingModules() && !frame()->GetModel())
1144  return 0;
1145 
1146  auto& view = *getView();
1147  auto& controls = *getViewControls();
1148 
1149  std::string tool = aEvent.GetCommandStr().get();
1150  frame()->PushTool( tool );
1151  Activate();
1152 
1153  EDA_UNITS units = frame()->GetUserUnits();
1155  KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, units );
1156 
1157  view.Add( &ruler );
1158  view.SetVisible( &ruler, false );
1159 
1160  GRID_HELPER grid( frame() );
1161 
1162  bool originSet = false;
1163 
1164  controls.ShowCursor( true );
1165  controls.SetAutoPan( false );
1166  controls.CaptureCursor( false );
1167 
1168  while( auto evt = Wait() )
1169  {
1170  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
1171  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1172  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1173  controls.SetSnapping( !evt->Modifier( MD_ALT ) );
1174  const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr );
1175  controls.ForceCursorPosition(true, cursorPos );
1176 
1177  auto clearRuler = [&] () {
1178  view.SetVisible( &ruler, false );
1179  controls.SetAutoPan( false );
1180  controls.CaptureCursor( false );
1181  originSet = false;
1182  };
1183 
1184  if( evt->IsCancelInteractive() )
1185  {
1186  if( originSet )
1187  clearRuler();
1188  else
1189  {
1190  frame()->PopTool( tool );
1191  break;
1192  }
1193  }
1194 
1195  else if( evt->IsActivate() )
1196  {
1197  if( originSet )
1198  clearRuler();
1199 
1200  if( evt->IsMoveTool() )
1201  {
1202  // leave ourselves on the stack so we come back after the move
1203  break;
1204  }
1205  else
1206  {
1207  frame()->PopTool( tool );
1208  break;
1209  }
1210  }
1211 
1212  // click or drag starts
1213  else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
1214  {
1215  twoPtMgr.SetOrigin( cursorPos );
1216  twoPtMgr.SetEnd( cursorPos );
1217 
1218  controls.CaptureCursor( true );
1219  controls.SetAutoPan( true );
1220 
1221  originSet = true;
1222  }
1223 
1224  // second click or mouse up after drag ends
1225  else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
1226  {
1227  originSet = false;
1228 
1229  controls.SetAutoPan( false );
1230  controls.CaptureCursor( false );
1231  }
1232 
1233  // move or drag when origin set updates rules
1234  else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
1235  {
1236  twoPtMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) );
1237  twoPtMgr.SetEnd( cursorPos );
1238 
1239  view.SetVisible( &ruler, true );
1240  view.Update( &ruler, KIGFX::GEOMETRY );
1241  }
1242 
1243  else if( evt->IsAction( &ACTIONS::toggleUnits )
1244  || evt->IsAction( &PCB_ACTIONS::updateUnits ) )
1245  {
1246  if( frame()->GetUserUnits() != units )
1247  {
1248  units = frame()->GetUserUnits();
1249  ruler.SwitchUnits();
1250  view.Update( &ruler, KIGFX::GEOMETRY );
1251  }
1252  }
1253 
1254  else if( evt->IsClick( BUT_RIGHT ) )
1255  {
1257  }
1258 
1259  else
1260  evt->SetPassEvent();
1261  }
1262 
1263  view.SetVisible( &ruler, false );
1264  view.Remove( &ruler );
1265  return 0;
1266 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
EDA_UNITS
Definition: common.h:72
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
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
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
static TOOL_ACTION updateUnits
Definition: pcb_actions.h:405
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:74
PCB_BASE_EDIT_FRAME * frame() const
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
void SetOrigin(const VECTOR2I &aOrigin)
Set the origin of the ruler (the fixed end)
KIGFX::PCB_VIEW * view() const
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
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
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
KIGFX::VIEW_CONTROLS * controls() const
virtual void PopTool(const std::string &actionName)
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1486
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:42
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:138
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
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, PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), S3D::GetModel(), KIGFX::VIEW_CONTROLS::GetMousePosition(), EDA_BASE_FRAME::GetUserUnits(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::m_menu, MD_ALT, MD_CTRL, MD_SHIFT, EDA_BASE_FRAME::PopTool(), EDA_BASE_FRAME::PushTool(), KIGFX::PCB_VIEW::Remove(), KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetAngleSnap(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetEnd(), KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetOrigin(), GRID_HELPER::SetSnap(), KIGFX::VIEW_CONTROLS::SetSnapping(), 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 690 of file edit_tool.cpp.

691 {
693  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
694  { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); }, nullptr, ! m_dragging );
695 
696  if( selection.Empty() )
697  return 0;
698 
700  auto refPoint = selection.GetReferencePoint();
701  wxPoint mirrorPoint( refPoint.x, refPoint.y );
702 
703  // When editing modules, all items have the same parent
704  if( EditingModules() )
705  m_commit->Modify( selection.Front() );
706 
707  for( EDA_ITEM* item : selection )
708  {
709  // only modify items we can mirror
710  switch( item->Type() )
711  {
712  case PCB_MODULE_EDGE_T:
713  case PCB_MODULE_TEXT_T:
714  case PCB_PAD_T:
715  // Only create undo entry for items on the board
716  if( !item->IsNew() && !EditingModules() )
717  m_commit->Modify( item );
718 
719  break;
720  default:
721  continue;
722  }
723 
724  // modify each object as necessary
725  switch( item->Type() )
726  {
727  case PCB_MODULE_EDGE_T:
728  {
729  auto& edge = static_cast<EDGE_MODULE&>( *item );
730  edge.Mirror( mirrorPoint, false );
731  break;
732  }
733 
734  case PCB_MODULE_TEXT_T:
735  {
736  auto& modText = static_cast<TEXTE_MODULE&>( *item );
737  modText.Mirror( mirrorPoint, false );
738  break;
739  }
740 
741  case PCB_PAD_T:
742  {
743  auto& pad = static_cast<D_PAD&>( *item );
744  mirrorPadX( pad, mirrorPoint );
745  break;
746  }
747 
748  default:
749  // it's likely the commit object is wrong if you get here
750  assert( false );
751  break;
752  }
753  }
754 
755  if( !m_dragging )
756  m_commit->Push( _( "Mirror" ) );
757 
758  if( selection.IsHover() && !m_dragging )
760 
762 
763  if( m_dragging )
765 
766  return 0;
767 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
VECTOR2I GetReferencePoint() const
Definition: selection.h:239
bool IsHover() const
Definition: selection.h:70
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:194
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:201
const PCBNEW_SELECTION & selection() const
bool m_dragging
Definition: edit_tool.h:190
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
bool EditingModules() const
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
#define _(s)
Definition: 3d_actions.cpp:31
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:420
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
bool updateModificationPoint(PCBNEW_SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1269
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:59
static void mirrorPadX(D_PAD &aPad, const wxPoint &aMirrorPoint)
Mirror a pad in the vertical axis passing through a point.
Definition: edit_tool.cpp:667
EDA_ITEM * Front() const
Definition: selection.h:183

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

◆ Move()

int EDIT_TOOL::Move ( const TOOL_EVENT aEvent)

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

Definition at line 247 of file edit_tool.cpp.

248 {
250  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
251  VECTOR2I originalCursorPos = controls->GetCursorPosition();
252 
253  // Be sure that there is at least one item that we can modify. If nothing was selected before,
254  // try looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection)
256  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
257  {
259  } );
260 
261  if( m_dragging || selection.Empty() )
262  return 0;
263 
264  LSET item_layers = selection.GetSelectionLayers();
265  bool unselect = selection.IsHover(); //N.B. This must be saved before the re-selection below
266 
267  // Now filter out locked pads. We cannot do this in the first RequestSelection() as we need
268  // the item_layers when a pad is the selection front (ie: will become curr_tiem).
270  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
271  {
273  } );
274 
275  if( selection.Empty() )
276  return 0;
277 
278  std::string tool = aEvent.GetCommandStr().get();
279  editFrame->PushTool( tool );
280  Activate();
281  controls->ShowCursor( true );
282  controls->SetAutoPan( true );
283 
284  std::vector<BOARD_ITEM*> sel_items;
285 
286  for( EDA_ITEM* item : selection )
287  {
288  BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
289  MODULE* module = dynamic_cast<MODULE*>( item );
290 
291  if( boardItem )
292  sel_items.push_back( boardItem );
293 
294  if( module )
295  {
296  for( D_PAD* pad : module->Pads() )
297  sel_items.push_back( pad );
298  }
299  }
300 
301  bool restore_state = false;
302  VECTOR2I totalMovement;
303  GRID_HELPER grid( editFrame );
304  TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
305  VECTOR2I prevPos;
306 
307  // Prime the pump
309 
310  // Main loop: keep receiving events
311  do
312  {
313  editFrame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
314  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
315  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
316  controls->SetSnapping( !evt->Modifier( MD_ALT ) );
317 
318  if( evt->IsAction( &PCB_ACTIONS::move ) || evt->IsMotion() ||
319  evt->IsAction( &PCB_ACTIONS::drag ) || evt->IsDrag( BUT_LEFT ) ||
321  {
322  if( m_dragging && evt->Category() == TC_MOUSE )
323  {
324  VECTOR2I mousePos( controls->GetMousePosition() );
325 
326  m_cursor = grid.BestSnapAnchor( mousePos, item_layers, sel_items );
327 
329  {
331 
332  // The arrow keys are by definition SINGLE AXIS. Do not allow the other
333  // axis to be snapped to the grid.
334  if( action == ACTIONS::CURSOR_LEFT || action == ACTIONS::CURSOR_RIGHT )
335  m_cursor.y = prevPos.y;
336  else if( action == ACTIONS::CURSOR_UP || action == ACTIONS::CURSOR_DOWN )
337  m_cursor.x = prevPos.x;
338  }
339 
342 
343  VECTOR2I movement( m_cursor - prevPos );
344  prevPos = m_cursor;
345  totalMovement += movement;
346 
347  // Drag items to the current cursor position
348  for( EDA_ITEM* item : sel_items )
349  {
350  // Don't double move footprint pads, fields, etc.
351  if( !item->GetParent() || !item->GetParent()->IsSelected() )
352  static_cast<BOARD_ITEM*>( item )->Move( movement );
353  }
354 
355  frame()->UpdateMsgPanel();
356  }
357  else if( !m_dragging ) // Prepare to start dragging
358  {
360  {
362  break;
363  }
364 
365  // deal with locked items (override lock or abort the operation)
367 
368  if( lockFlags == SELECTION_LOCKED )
369  break;
370 
371  m_dragging = true;
372 
373  // When editing modules, all items have the same parent
374  if( EditingModules() )
375  {
376  m_commit->Modify( selection.Front() );
377  }
378  else
379  {
380  // Save items, so changes can be undone
381  for( EDA_ITEM* item : selection )
382  {
383  // Don't double move footprint pads, fields, etc.
384  if( item->GetParent() && item->GetParent()->IsSelected() )
385  continue;
386 
387  m_commit->Modify( item );
388  }
389  }
390 
391  editFrame->UndoRedoBlock( true );
393 
395  {
396  // start moving with the reference point attached to the cursor
397  grid.SetAuxAxes( false );
398 
399  auto delta = m_cursor - selection.GetReferencePoint();
400 
401  // Drag items to the current cursor position
402  for( EDA_ITEM* item : selection )
403  {
404  // Don't double move footprint pads, fields, etc.
405  if( item->GetParent() && item->GetParent()->IsSelected() )
406  continue;
407 
408  static_cast<BOARD_ITEM*>( item )->Move( delta );
409  }
410 
412  }
413  else
414  {
415  std::vector<BOARD_ITEM*> items;
416 
417  for( EDA_ITEM* item : selection )
418  items.push_back( static_cast<BOARD_ITEM*>( item ) );
419 
420  // Set the current cursor position to the first dragged item origin, so the
421  // movement vector could be computed later
422  m_cursor = grid.BestDragOrigin( originalCursorPos, items );
424  grid.SetAuxAxes( true, m_cursor );
425  }
426 
428 
429  prevPos = m_cursor;
430  controls->SetAutoPan( true );
431  }
432 
435  }
436 
437  else if( evt->IsCancelInteractive() || evt->IsActivate() )
438  {
439  restore_state = true; // Canceling the tool means that items have to be restored
440  break; // Finish
441  }
442 
443  else if( evt->IsAction( &ACTIONS::undo ) )
444  {
445  restore_state = true; // Perform undo locally
446  break; // Finish
447  }
448 
449  // Dispatch TOOL_ACTIONs
450  else if( evt->Category() == TC_COMMAND )
451  {
452  if( evt->IsAction( &ACTIONS::doDelete ) )
453  {
454  break; // finish -- there is no further processing for removed items
455  }
456  else if( evt->IsAction( &ACTIONS::duplicate ) )
457  {
458  break; // finish -- Duplicate tool will start a new Move with the dup'ed items
459  }
460  else if( evt->IsAction( &PCB_ACTIONS::moveExact ) )
461  {
462  // Reset positions so the Move Exactly is from the start.
463  for( EDA_ITEM* item : selection )
464  {
465  BOARD_ITEM* i = static_cast<BOARD_ITEM*>( item );
466  i->Move( -totalMovement );
467  }
468 
469  break; // finish -- we moved exactly, so we are finished
470  }
471  }
472 
473  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
474  {
475  break; // finish
476  }
477 
478  else
479  {
480  evt->SetPassEvent();
481  }
482 
483  } while( ( evt = Wait() ) ); // Assignment (instead of equality test) is intentional
484 
485  m_lockedSelected = false;
486  controls->ForceCursorPosition( false );
487  controls->ShowCursor( false );
488  controls->SetSnapping( false );
489  controls->SetAutoPan( false );
490 
491  m_dragging = false;
492  editFrame->UndoRedoBlock( false );
493 
494  // Discard reference point when selection is "dropped" onto the board (ie: not dragging anymore)
496 
497  if( unselect )
499 
500  // If canceled, we need to remove the dynamic ratsnest from the screen
501  if( restore_state )
502  {
504  m_commit->Revert();
505  }
506  else
507  {
508  m_commit->Push( _( "Drag" ) );
509  }
510 
511  editFrame->PopTool( tool );
512  return 0;
513 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
VECTOR2I GetReferencePoint() const
Definition: selection.h:239
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
VECTOR2I m_cursor
Definition: edit_tool.h:192
void ClearReferencePoint()
Definition: selection.h:249
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:103
bool IsHover() const
Definition: selection.h:70
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
static TOOL_ACTION doDelete
Definition: actions.h:74
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:194
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:178
SELECTION_LOCK_FLAGS CheckLock()
Checks if the user has agreed to modify locked items for the given selection.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
PADS & Pads()
Definition: class_module.h:173
bool IsMotion() const
Definition: tool_event.h:306
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:109
TOOL_EVENT_CATEGORY Category() const
Returns the category (eg. mouse/keyboard/action) of an event..
Definition: tool_event.h:247
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Moves cursor to the requested position expressed in world coordinates.
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:201
const VC_SETTINGS & GetSettings() const
Returns the current VIEW_CONTROLS settings
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
static TOOL_ACTION moveExact
Activation of the exact move tool.
Definition: pcb_actions.h:123
const LSET GetSelectionLayers()
PCB_BASE_EDIT_FRAME * frame() const
bool m_lockedSelected
Definition: edit_tool.h:191
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:244
bool isInteractiveDragEnabled() const
Definition: edit_tool.cpp:227
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:296
LSET is a set of PCB_LAYER_IDs.
const PCBNEW_SELECTION & selection() const
bool m_dragging
Definition: edit_tool.h:190
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
SELECTION_LOCK_FLAGS
Definition: selection.h:278
TOOL_EVENT.
Definition: tool_event.h:171
void SetPassEvent()
Definition: tool_event.h:256
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
bool IsMouseUp(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:301
bool IsCancelInteractive()
Function IsCancelInteractive()
Definition: tool_event.cpp:190
static TOOL_ACTION hideDynamicRatsnest
Definition: pcb_actions.h:419
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
static TOOL_ACTION drag
Definition: pcb_actions.h:104
bool EditingModules() const
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
bool IsActivate() const
Definition: tool_event.h:321
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:206
bool HasReferencePoint() const
Definition: selection.h:234
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
KIGFX::VIEW_CONTROLS * controls() const
Common, abstract interface for edit frames.
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:31
long m_lastKeyboardCursorCommand
ACTIONS::CURSOR_UP, ACTIONS::CURSOR_DOWN, etc.
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
bool m_lastKeyboardCursorPositionValid
Is last cursor motion event coming from keyboard arrow cursor motion action
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
virtual void PopTool(const std::string &actionName)
void Activate()
Function Activate() Runs the tool.
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:420
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:59
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:237
static TOOL_ACTION duplicate
Definition: actions.h:73
static TOOL_ACTION refreshPreview
Definition: actions.h:101
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:183
virtual void UpdateMsgPanel()
Redraw the message panel.

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

Referenced by Duplicate(), and setTransitions().

◆ MoveExact()

int EDIT_TOOL::MoveExact ( const TOOL_EVENT aEvent)

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

Definition at line 948 of file edit_tool.cpp.

949 {
951  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
953 
954  if( selection.Empty() )
955  return 0;
956 
957  PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
958  wxPoint translation;
959  double rotation;
960  ROTATION_ANCHOR rotationAnchor = selection.Size() > 1 ? ROTATE_AROUND_SEL_CENTER
962 
963  // TODO: Implement a visible bounding border at the edge
964  auto sel_box = selection.GetBoundingBox();
965 
966  DIALOG_MOVE_EXACT dialog( editFrame, translation, rotation, rotationAnchor, sel_box );
967  int ret = dialog.ShowModal();
968 
969  if( ret == wxID_OK )
970  {
972  wxPoint selCenter( rp.x, rp.y );
973 
974  // Make sure the rotation is from the right reference point
975  selCenter += translation;
976 
977  // When editing modules, all items have the same parent
978  if( EditingModules() )
979  m_commit->Modify( selection.Front() );
980 
981  for( EDA_ITEM* selItem : selection )
982  {
983  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selItem );
984 
985  if( !item->IsNew() && !EditingModules() )
986  m_commit->Modify( item );
987 
988  item->Move( translation );
989 
990  switch( rotationAnchor )
991  {
993  item->Rotate( item->GetPosition(), rotation );
994  break;
996  item->Rotate( selCenter, rotation );
997  break;
999  item->Rotate( (wxPoint) editFrame->GetScreen()->m_LocalOrigin, rotation );
1000  break;
1002  item->Rotate( editFrame->GetAuxOrigin(), rotation );
1003  break;
1004  }
1005 
1006  if( !m_dragging )
1007  getView()->Update( item );
1008  }
1009 
1010  m_commit->Push( _( "Move exact" ) );
1011 
1012  if( selection.IsHover() )
1014 
1016 
1017  if( m_dragging )
1019  }
1020 
1021  return 0;
1022 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
bool IsHover() const
Definition: selection.h:70
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:194
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.h:137
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
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:201
bool IsNew() const
Definition: base_struct.h:218
const PCBNEW_SELECTION & selection() const
bool m_dragging
Definition: edit_tool.h:190
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:1540
ROTATION_ANCHOR
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
virtual const wxPoint GetPosition() const =0
bool EditingModules() const
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
#define _(s)
Definition: 3d_actions.cpp:31
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:126
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
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:53
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:420
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:59
EDA_RECT GetBoundingBox() const
Definition: selection.h:155
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
EDA_ITEM * Front() const
Definition: selection.h:183
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:114

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

1118 {
1119  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1120  {
1121  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
1122 
1123  if( item->Type() != PCB_PAD_T )
1124  aCollector.Remove( i );
1125  }
1126 }
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:145
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:116
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207

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

Referenced by PCB_INSPECTION_TOOL::LocalRatsnestTool().

◆ pickCopyReferencePoint()

bool EDIT_TOOL::pickCopyReferencePoint ( VECTOR2I aReferencePoint)
private

Definition at line 1326 of file edit_tool.cpp.

1327 {
1328  std::string tool = "pcbnew.InteractiveEdit.selectReferencePoint";
1329  STATUS_TEXT_POPUP statusPopup( frame() );
1331  OPT<VECTOR2I> pickedPoint;
1332  bool done = false;
1333 
1334  statusPopup.SetText( _( "Select reference point for the copy..." ) );
1335 
1336  picker->SetClickHandler(
1337  [&]( const VECTOR2D& aPoint ) -> bool
1338  {
1339  pickedPoint = aPoint;
1340  statusPopup.SetText( _( "Selection copied." ) );
1341  statusPopup.Expire( 800 );
1342  return false; // we don't need any more points
1343  } );
1344 
1345  picker->SetMotionHandler(
1346  [&] ( const VECTOR2D& aPos )
1347  {
1348  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
1349  } );
1350 
1351  picker->SetCancelHandler(
1352  [&]()
1353  {
1354  statusPopup.SetText( _( "Copy cancelled." ) );
1355  statusPopup.Expire( 800 );
1356  } );
1357 
1358  picker->SetFinalizeHandler(
1359  [&]( const int& aFinalState )
1360  {
1361  done = true;
1362  } );
1363 
1364  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
1365  statusPopup.Popup();
1366 
1367  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1368 
1369  while( !done )
1370  Wait();
1371 
1372  if( pickedPoint.is_initialized() )
1373  aReferencePoint = pickedPoint.get();
1374 
1375  return pickedPoint.is_initialized();
1376 }
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
static TOOL_ACTION pickerTool
Definition: actions.h:145
PCB_BASE_EDIT_FRAME * frame() const
Generic tool for picking a point.
#define _(s)
Definition: 3d_actions.cpp:31
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
boost::optional< T > OPT
Definition: optional.h:7
void SetCancelHandler(CANCEL_HANDLER aHandler)
Function SetCancelHandler() Sets a handler for cancel events (ESC or context-menu Cancel).
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.

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

Referenced by copyToClipboard().

◆ Properties()

int EDIT_TOOL::Properties ( const TOOL_EVENT aEvent)

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

Definition at line 569 of file edit_tool.cpp.

570 {
571  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
572 
574  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
575  { EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } );
576 
577  // Tracks & vias are treated in a special way:
579  {
580  DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection, *m_commit );
581  dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR
582  }
583  else if( selection.Size() == 1 ) // Properties are displayed when there is only one item selected
584  {
585  // Display properties dialog
586  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
587 
588  // Do not handle undo buffer, it is done by the properties dialogs
589  editFrame->OnEditItemRequest( item );
590 
591  // Notify other tools of the changes
593  }
594 
595  if( selection.IsHover() )
596  {
598 
599  // Notify other tools of the changes -- This updates the visual ratsnest
601  }
602 
603  return 0;
604 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
bool IsHover() const
Definition: selection.h:70
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:313
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:194
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Function OnlyTypes Creates a functor that tests if the selected items are only of given types.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void OnEditItemRequest(BOARD_ITEM *aItem)=0
Function OnEditItemRequest Install the corresponding dialog editor for the given item.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:201
const PCBNEW_SELECTION & selection() const
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
Common, abstract interface for edit frames.
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:59
EDA_ITEM * Front() const
Definition: selection.h:183

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

820 {
821  ROUTER_TOOL* routerTool = static_cast<ROUTER_TOOL*>
822  ( m_toolMgr->FindTool( "pcbnew.InteractiveRouter" ) );
823 
824  // Do not delete items while actively routing.
825  if( routerTool && routerTool->Router() && routerTool->Router()->RoutingInProgress() )
826  return 1;
827 
828  std::vector<BOARD_ITEM*> lockedItems;
829  Activate();
830 
831  // get a copy instead of reference (as we're going to clear the selection before removing items)
832  PCBNEW_SELECTION selectionCopy;
835 
836  // If we are in a "Cut" operation, then the copied selection exists already
837  if( isCut )
838  {
839  selectionCopy = m_selectionTool->GetSelection();
840  }
841  else
842  {
843  selectionCopy = m_selectionTool->RequestSelection(
844  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
846  }
847 
848  bool isHover = selectionCopy.IsHover();
849 
850  // in "alternative" mode, deletion is not just a simple list of selected items,
851  // it removes whole tracks, not just segments
852  if( isAlt && isHover
853  && ( selectionCopy.HasType( PCB_TRACE_T ) || selectionCopy.HasType( PCB_VIA_T ) ) )
854  {
856  }
857 
858  if( selectionCopy.Empty() )
859  return 0;
860 
861  // N.B. Setting the CUT flag prevents lock filtering as we only want to delete the items that
862  // were copied to the clipboard, no more, no fewer. Filtering for locked item, if any will be done
863  // in the copyToClipboard() routine
864  if( !m_lockedSelected && !isCut )
865  {
866  // Second RequestSelection removes locked items but keeps a copy of their pointers
867  selectionCopy = m_selectionTool->RequestSelection(
868  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
869  { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED ); }, &lockedItems );
870  }
871 
872 
873  // As we are about to remove items, they have to be removed from the selection first
875 
876  for( EDA_ITEM* item : selectionCopy )
877  {
878  if( m_editModules )
879  {
880  m_commit->Remove( item );
881  continue;
882  }
883 
884  switch( item->Type() )
885  {
886  case PCB_MODULE_TEXT_T:
887  {
888  auto text = static_cast<TEXTE_MODULE*>( item );
889  auto parent = static_cast<MODULE*>( item->GetParent() );
890 
891  if( text->GetType() == TEXTE_MODULE::TEXT_is_DIVERS )
892  {
893  m_commit->Modify( text );
894  getView()->Remove( text );
895  parent->Remove( text );
896  }
897  }
898  break;
899 
900  case PCB_PAD_T:
901  {
902  auto pad = static_cast<D_PAD*>( item );
903  auto parent = static_cast<MODULE*>( item->GetParent() );
904 
905  m_commit->Modify( parent );
906  getView()->Remove( pad );
907  parent->Remove( pad );
908  }
909  break;
910 
911  default:
912  m_commit->Remove( item );
913  break;
914  }
915  }
916 
917  if( isCut )
918  m_commit->Push( _( "Cut" ) );
919  else
920  m_commit->Push( _( "Delete" ) );
921 
922  if( !m_lockedSelected && !lockedItems.empty() )
923  {
925  STATUS_TEXT_POPUP statusPopup( frame() );
926 
927  m_lockedSelected = true;
928  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &lockedItems );
929  statusPopup.SetText( _( "Delete again to remove locked items" ) );
930  statusPopup.PopupFor( 2000 );
931  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
932 
933  Activate();
934 
935  while( m_lockedSelected && statusPopup.IsShown() )
936  {
937  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
938  Wait();
939  }
940  }
941 
942  m_lockedSelected = false;
943 
944  return 0;
945 }
static TOOL_ACTION selectItems
Selects a list of items (specified as the event parameter)
Definition: pcb_actions.h:80
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
bool IsHover() const
Definition: selection.h:70
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
REMOVE_FLAGS
Remove event modifier flags
Definition: actions.h:185
bool HasType(KICAD_T aType) const
Checks if there is at least one item of requested kind.
Definition: selection.h:213
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:194
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
static TOOL_ACTION selectConnection
Selects tracks between junctions or expands an existing selection to pads or the entire connection.
Definition: pcb_actions.h:88
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
PCB_BASE_EDIT_FRAME * frame() const
bool m_lockedSelected
Definition: edit_tool.h:191
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
#define _(s)
Definition: 3d_actions.cpp:31
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
void Activate()
Function Activate() Runs the tool.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:53
bool RoutingInProgress() const
Definition: pns_router.cpp:111
ROUTER * Router() const
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:59

References _, TOOL_INTERACTIVE::Activate(), ACTIONS::ALT, ACTIONS::CUT, EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED, EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, 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_PAD_T, PCB_TRACE_T, PCB_VIA_T, STATUS_POPUP::PopupFor(), KIGFX::VIEW::Remove(), SELECTION_TOOL::RequestSelection(), PNS::TOOL_BASE::Router(), PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectConnection, 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 109 of file edit_tool.cpp.

110 {
111  m_dragging = false;
112 
113  if( aReason != RUN )
114  m_commit.reset( new BOARD_COMMIT( this ) );
115 }
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:194
Tool is invoked after being inactive.
Definition: tool_base.h:81
bool m_dragging
Definition: edit_tool.h:190

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

608 {
609  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
610 
612  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
613  { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); }, nullptr, ! m_dragging );
614 
615  if( selection.Empty() )
616  return 0;
617 
619  auto refPt = selection.GetReferencePoint();
620  const int rotateAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *editFrame, aEvent );
621 
622  // When editing modules, all items have the same parent
623  if( EditingModules() )
624  m_commit->Modify( selection.Front() );
625 
626  for( auto item : selection )
627  {
628  if( !item->IsNew() && !EditingModules() )
629  m_commit->Modify( item );
630 
631  static_cast<BOARD_ITEM*>( item )->Rotate( refPt, rotateAngle );
632  }
633 
634  if( !m_dragging )
635  m_commit->Push( _( "Rotate" ) );
636 
637  if( selection.IsHover() && !m_dragging )
639 
641 
642  if( m_dragging )
644 
645  return 0;
646 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
VECTOR2I GetReferencePoint() const
Definition: selection.h:239
bool IsHover() const
Definition: selection.h:70
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:194
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:201
const PCBNEW_SELECTION & selection() const
bool m_dragging
Definition: edit_tool.h:190
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:55
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
bool EditingModules() const
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
Common, abstract interface for edit frames.
#define _(s)
Definition: 3d_actions.cpp:31
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:420
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:54
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
bool updateModificationPoint(PCBNEW_SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1269
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:59
EDA_ITEM * Front() const
Definition: selection.h:183

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

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

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

Referenced by DRAWING_TOOL::PlaceText().

◆ selection() [1/2]

const PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 269 of file pcb_tool_base.cpp.

270 {
271  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
272  const auto& selection = selTool->GetSelection();
273  return selection;
274 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
const PCBNEW_SELECTION & selection() const

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

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

◆ selection() [2/2]

PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 277 of file pcb_tool_base.cpp.

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

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

◆ SetContextMenu()

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

Function SetContextMenu()

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

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

Definition at line 76 of file tool_interactive.cpp.

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

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ SetEditModules()

void PCB_TOOL_BASE::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

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

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 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 1424 of file edit_tool.cpp.

1425 {
1427  Go( &EDIT_TOOL::Move, PCB_ACTIONS::move.MakeEvent() );
1428  Go( &EDIT_TOOL::Move, PCB_ACTIONS::drag.MakeEvent() );
1429  Go( &EDIT_TOOL::Drag, PCB_ACTIONS::drag45Degree.MakeEvent() );
1431  Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCw.MakeEvent() );
1432  Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCcw.MakeEvent() );
1433  Go( &EDIT_TOOL::Flip, PCB_ACTIONS::flip.MakeEvent() );
1434  Go( &EDIT_TOOL::Remove, ACTIONS::doDelete.MakeEvent() );
1435  Go( &EDIT_TOOL::Remove, PCB_ACTIONS::deleteFull.MakeEvent() );
1438  Go( &EDIT_TOOL::Duplicate, ACTIONS::duplicate.MakeEvent() );
1441  Go( &EDIT_TOOL::Mirror, PCB_ACTIONS::mirror.MakeEvent() );
1443 
1446 
1447  Go( &EDIT_TOOL::copyToClipboard, ACTIONS::copy.MakeEvent() );
1448  Go( &EDIT_TOOL::cutToClipboard, ACTIONS::cut.MakeEvent() );
1449 }
int Properties(const TOOL_EVENT &aEvent)
Function Properties() Displays properties window for the selected object.
Definition: edit_tool.cpp:569
int Rotate(const TOOL_EVENT &aEvent)
Function Rotate() Rotates currently selected items.
Definition: edit_tool.cpp:607
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:103
static TOOL_ACTION deleteFull
Definition: pcb_actions.h:133
static TOOL_ACTION changeTrackWidth
Updates selected tracks & vias to the current track & via dimensions.
Definition: pcb_actions.h:117
static TOOL_ACTION doDelete
Definition: actions.h:74
int ChangeTrackWidth(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:515
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:144
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:120
static TOOL_ACTION getAndPlace
Find an item and start moving.
Definition: pcb_actions.h:426
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:143
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:114
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int Mirror(const TOOL_EVENT &aEvent)
Function Mirror Mirrors the current selection.
Definition: edit_tool.cpp:690
static TOOL_ACTION moveExact
Activation of the exact move tool.
Definition: pcb_actions.h:123
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:1408
int EditFpInFpEditor(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:1292
static TOOL_ACTION measureTool
Definition: actions.h:144
static TOOL_ACTION copy
Definition: actions.h:70
int Flip(const TOOL_EVENT &aEvent)
Function Flip() Rotates currently selected items.
Definition: edit_tool.cpp:770
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
Definition: pcb_actions.h:129
int GetAndPlace(const TOOL_EVENT &aEvent)
Find an item and start moving.
Definition: edit_tool.cpp:188
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:107
static TOOL_ACTION createArray
Tool for creating an array of objects.
Definition: pcb_actions.h:366
static TOOL_ACTION cut
Definition: actions.h:69
int Drag(const TOOL_EVENT &aEvent)
Function Drag() Invoke the PNS router to drag tracks.
Definition: edit_tool.cpp:235
int Move(const TOOL_EVENT &aEvent)
Function Move() Main loop in which events are handled.
Definition: edit_tool.cpp:247
static TOOL_ACTION drag
Definition: pcb_actions.h:104
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:108
int MoveExact(const TOOL_EVENT &aEvent)
Function MoveExact() Invokes a dialog box to allow moving of the item by an exact amount.
Definition: edit_tool.cpp:948
int Remove(const TOOL_EVENT &aEvent)
Function Remove() Deletes currently selected items.
Definition: edit_tool.cpp:819
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:111
int CreateArray(const TOOL_EVENT &aEvent)
Function CreateArray() Creates an array of the selected items, invoking the array editor dialog to se...
Definition: edit_tool.cpp:1099
int MeasureTool(const TOOL_EVENT &aEvent)
Launches a tool to measure between points
Definition: edit_tool.cpp:1141
static TOOL_ACTION editFootprintInFpEditor
Definition: pcb_actions.h:324
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:1379
int Duplicate(const TOOL_EVENT &aEvent)
Function Duplicate() Duplicates the current selection and starts a move action.
Definition: edit_tool.cpp:1025
static TOOL_ACTION duplicate
Definition: actions.h:73

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

◆ updateModificationPoint()

bool EDIT_TOOL::updateModificationPoint ( PCBNEW_SELECTION aSelection)
private

Returns the right modification point (e.g.

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

Definition at line 1269 of file edit_tool.cpp.

1270 {
1271  if( m_dragging && aSelection.HasReferencePoint() )
1272  return false;
1273 
1274  // When there is only one item selected, the reference point is its position...
1275  if( aSelection.Size() == 1 )
1276  {
1277  auto item = static_cast<BOARD_ITEM*>( aSelection.Front() );
1278  auto pos = item->GetPosition();
1279  aSelection.SetReferencePoint( VECTOR2I( pos.x, pos.y ) );
1280  }
1281  // ...otherwise modify items with regard to the grid-snapped cursor position
1282  else
1283  {
1285  aSelection.SetReferencePoint( m_cursor );
1286  }
1287 
1288  return true;
1289 }
VECTOR2I m_cursor
Definition: edit_tool.h:192
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:244
bool m_dragging
Definition: edit_tool.h:190
bool HasReferencePoint() const
Definition: selection.h:234
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:183

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

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

◆ view()

◆ Wait()

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

Function Wait()

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

Definition at line 57 of file tool_interactive.cpp.

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

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), CVPCB_CONTROL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), MeasureTool(), Move(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), Remove(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_commit

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

◆ m_cursor

VECTOR2I EDIT_TOOL::m_cursor
private

Definition at line 192 of file edit_tool.h.

Referenced by Move(), and updateModificationPoint().

◆ m_dragging

bool EDIT_TOOL::m_dragging
private

Definition at line 190 of file edit_tool.h.

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

◆ m_editModules

◆ m_lockedSelected

bool EDIT_TOOL::m_lockedSelected
private

Definition at line 191 of file edit_tool.h.

Referenced by Move(), and Remove().

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

functions below are not yet implemented - their interface may change

Definition at line 108 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), PICKER_TOOL::Init(), SCH_EDIT_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), LIB_DRAWING_TOOLS::Init(), MODULE_EDITOR_TOOLS::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), Init(), PCB_TOOL_BASE::Init(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), MeasureTool(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_selectionTool

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 214 of file tool_base.h.

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 219 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), ChangeTrackWidth(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), 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_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), Duplicate(), SCH_EDIT_TOOL::editComponentFieldText(), EditFpInFpEditor(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), POINT_EDITOR::finishItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), Flip(), GetAndPlace(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_INSPECTION_TOOL::HighlightItem(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), MODULE_EDITOR_TOOLS::ImportFootprint(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), invokeInlineRouter(), isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), SCH_MOVE_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), Move(), MoveExact(), LIB_CONTROL::OnDeMorgan(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), pickCopyReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCBNEW_CONTROL::Print(), GERBVIEW_CONTROL::Print(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), LIB_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), Remove(), POINT_EDITOR::removeCorner(), EE_SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC::RunTests(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::SelectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), LIB_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

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

Definition at line 218 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

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

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


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