KiCad PCB EDA Suite
EDIT_TOOL Class Reference

The interactive 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 }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 EDIT_TOOL ()
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
int GetAndPlace (const TOOL_EVENT &aEvent)
 
int Move (const TOOL_EVENT &aEvent)
 Main loop in which events are handled. More...
 
int Drag (const TOOL_EVENT &aEvent)
 Invoke the PNS router to drag tracks or do an offline resizing of an arc track if a single arc track is selected. More...
 
int DragArcTrack (const TOOL_EVENT &aTrack)
 Drag-resize an arc (and change end points of connected straight segments). More...
 
int Properties (const TOOL_EVENT &aEvent)
 Display properties window for the selected object. More...
 
int Rotate (const TOOL_EVENT &aEvent)
 Rotate currently selected items. More...
 
int Flip (const TOOL_EVENT &aEvent)
 Rotate currently selected items. More...
 
int Mirror (const TOOL_EVENT &aEvent)
 Mirror the current selection. More...
 
int ChangeTrackWidth (const TOOL_EVENT &aEvent)
 
int FilletTracks (const TOOL_EVENT &aEvent)
 Fillet (i.e. More...
 
int Remove (const TOOL_EVENT &aEvent)
 Delete currently selected items. More...
 
int Duplicate (const TOOL_EVENT &aEvent)
 Duplicate the current selection and starts a move action. More...
 
int MoveExact (const TOOL_EVENT &aEvent)
 Invoke a dialog box to allow moving of the item by an exact amount. More...
 
int MoveWithReference (const TOOL_EVENT &aEvent)
 Move an item but with a reference point selected first. More...
 
int CreateArray (const TOOL_EVENT &aEvent)
 Create an array of the selected items, invoking the array editor dialog to set the options. More...
 
BOARD_COMMITGetCurrentCommit () const
 
void SetIsFootprintEditor (bool aEnabled)
 Function SetIsFootprintEditor() More...
 
bool IsFootprintEditor () const
 
bool Is45Limited () const
 Should the tool use its 45° mode option? More...
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Static Public Member Functions

static void FootprintFilter (const VECTOR2I &, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *sTool)
 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, PCB_SELECTION_TOOL *sTool)
 A selection filter which prunes the selection to contain only items of type PCB_PAD_T. More...
 

Protected Types

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

Protected Member Functions

void doInteractiveItemPlacement (const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_BASE_EDIT_FRAMEframe () const
 
BOARDboard () const
 
FOOTPRINTfootprint () const
 
const PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const PCB_SELECTIONselection () const
 
PCB_SELECTIONselection ()
 
void attachManager (TOOL_MANAGER *aManager)
 Set the TOOL_MANAGER the tool will belong to. More...
 
KIGFX::VIEWgetView () const
 Returns the instance of #VIEW object used in the application. More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Return the instance of VIEW_CONTROLS object used in the application. More...
 
template<typename T >
T * getEditFrame () const
 Return the application window object, casted to requested user type. More...
 
template<typename T >
T * getModel () const
 Return the model object if it matches the requested type. More...
 

Protected Attributes

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

Private Member Functions

void setTransitions () override
 < Set up handlers for various events. More...
 
int copyToClipboard (const TOOL_EVENT &aEvent)
 Send the current selection to the clipboard by formatting it as a fake pcb see #AppendBoardFromClipboard for importing. More...
 
int cutToClipboard (const TOOL_EVENT &aEvent)
 Cut the current selection to the clipboard by formatting it as a fake pcb see #AppendBoardFromClipboard for importing. More...
 
bool updateModificationPoint (PCB_SELECTION &aSelection)
 
bool invokeInlineRouter (int aDragMode)
 
bool isInteractiveDragEnabled () const
 
bool isRouterActive () const
 
int doMoveSelection (TOOL_EVENT aEvent, bool aPickReference=false)
 
bool pickReferencePoint (const wxString &aTooltip, const wxString &aSuccessMessage, const wxString &aCanceledMessage, VECTOR2I &aReferencePoint)
 

Private Attributes

PCB_SELECTION_TOOLm_selectionTool
 
std::unique_ptr< BOARD_COMMITm_commit
 
bool m_dragging
 
VECTOR2I m_cursor
 
std::unique_ptr< STATUS_TEXT_POPUPm_statusPopup
 

Detailed Description

The interactive edit tool.

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

Definition at line 64 of file edit_tool.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

Options for placing items interactively.

Enumerator
IPO_ROTATE 

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

IPO_FLIP 

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

IPO_SINGLE_CLICK 

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

IPO_REPEAT 

Allow repeat placement of the item.

Definition at line 116 of file pcb_tool_base.h.

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

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determine the reason of reset for a tool.

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 77 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ EDIT_TOOL()

EDIT_TOOL::EDIT_TOOL ( )

Definition at line 68 of file edit_tool.cpp.

68  :
69  PCB_TOOL_BASE( "pcbnew.InteractiveEdit" ),
70  m_selectionTool( nullptr ),
71  m_dragging( false )
72 {
73 }
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
bool m_dragging
Definition: edit_tool.h:192
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool_base.h:77

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run the tool.

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

Definition at line 51 of file tool_interactive.cpp.

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

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

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

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Set the TOOL_MANAGER the tool will belong to.

Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

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

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 165 of file pcb_tool_base.h.

165 { return getModel<BOARD>(); }

Referenced by PCB_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), BOARD_INSPECTION_TOOL::ClearHighlight(), copyToClipboard(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), MICROWAVE_TOOL::createInductorBetween(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), BOARD_EDITOR_CONTROL::ExportNetlist(), ZONE_FILLER_TOOL::FillAllZones(), FilletTracks(), PCB_SELECTION_TOOL::filterSelection(), PCB_TOOL_BASE::footprint(), PCB_SELECTION_TOOL::GetBoard(), PCB_SELECTION_TOOL::getCollectorsGuide(), GROUP_TOOL::Group(), ROUTER_TOOL::handleLayerSwitch(), BOARD_INSPECTION_TOOL::highlightNet(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_CONTROL::LayerNext(), PCB_CONTROL::LayerPrev(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), MoveExact(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), PCB_CONTROL::Paste(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PAD_TOOL::PlacePad(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::recombinePad(), BOARD_EDITOR_CONTROL::RepairBoard(), FOOTPRINT_EDITOR_CONTROL::RepairFootprint(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::selectAllItemsOnNet(), PCB_SELECTION_TOOL::selectAllItemsOnSheet(), PCB_SELECTION_TOOL::selectConnectedTracks(), PCB_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectPoint(), PCB_CONTROL::TrackDisplayMode(), PCB_CONTROL::unfilledZoneCheck(), GROUP_TOOL::Ungroup(), ROUTER_TOOL::updateMessagePanel(), PCB_CONTROL::ViaDisplayMode(), PCB_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), BOARD_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ canvas()

◆ ChangeTrackWidth()

int EDIT_TOOL::ChangeTrackWidth ( const TOOL_EVENT aEvent)

Definition at line 1138 of file edit_tool.cpp.

1139 {
1141  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1142  {
1143  // Iterate from the back so we don't have to worry about removals.
1144  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
1145  {
1146  BOARD_ITEM* item = aCollector[ i ];
1147 
1148  if( !dynamic_cast<PCB_TRACK*>( item ) )
1149  aCollector.Remove( item );
1150  }
1151  },
1152  true /* prompt user regarding locked items */ );
1153 
1154  for( EDA_ITEM* item : selection )
1155  {
1156  if( item->Type() == PCB_VIA_T )
1157  {
1158  PCB_VIA* via = static_cast<PCB_VIA*>( item );
1159 
1160  m_commit->Modify( via );
1161 
1162  int new_width;
1163  int new_drill;
1164 
1165  if( via->GetViaType() == VIATYPE::MICROVIA )
1166  {
1167  NETCLASS* netClass = via->GetNetClass();
1168 
1169  new_width = netClass->GetuViaDiameter();
1170  new_drill = netClass->GetuViaDrill();
1171  }
1172  else
1173  {
1174  new_width = board()->GetDesignSettings().GetCurrentViaSize();
1175  new_drill = board()->GetDesignSettings().GetCurrentViaDrill();
1176  }
1177 
1178  via->SetDrill( new_drill );
1179  via->SetWidth( new_width );
1180  }
1181  else if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
1182  {
1183  PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item );
1184 
1185  wxCHECK( track, 0 );
1186 
1187  m_commit->Modify( track );
1188 
1189  int new_width = board()->GetDesignSettings().GetCurrentTrackWidth();
1190  track->SetWidth( new_width );
1191  }
1192  }
1193 
1194  m_commit->Push( _("Edit track width/via size") );
1195 
1196  if( selection.IsHover() )
1197  {
1199 
1200  // Notify other tools of the changes -- This updates the visual ratsnest
1202  }
1203 
1204  return 0;
1205 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
bool IsHover() const
Definition: selection.h:73
BOARD * board() const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:191
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:589
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:204
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
const PCB_SELECTION & selection() const
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:46
#define _(s)
int GetuViaDiameter() const
Definition: netclass.h:140
void SetWidth(int aWidth)
Definition: pcb_track.h:101
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
int GetuViaDrill() const
Definition: netclass.h:144
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References _, PCB_TOOL_BASE::board(), COLLECTOR::GetCount(), BOARD_DESIGN_SETTINGS::GetCurrentTrackWidth(), BOARD_DESIGN_SETTINGS::GetCurrentViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentViaSize(), BOARD::GetDesignSettings(), NETCLASS::GetuViaDiameter(), NETCLASS::GetuViaDrill(), SELECTION::IsHover(), m_commit, m_selectionTool, TOOL_BASE::m_toolMgr, MICROVIA, PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, TOOL_MANAGER::ProcessEvent(), COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_TRACK::SetWidth(), and via.

Referenced by setTransitions().

◆ controls()

◆ copyToClipboard()

int EDIT_TOOL::copyToClipboard ( const TOOL_EVENT aEvent)
private

Send the current selection to the clipboard by formatting it as a fake pcb see #AppendBoardFromClipboard for importing.

Definition at line 2405 of file edit_tool.cpp.

2406 {
2407  std::string tool = "pcbnew.InteractiveEdit.selectReferencePoint";
2408  CLIPBOARD_IO io;
2410  getEditFrame<PCB_BASE_EDIT_FRAME>()->GetMagneticItemsSettings() );
2411 
2412  frame()->PushTool( tool );
2413  Activate();
2414 
2416  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
2417  {
2418  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
2419  {
2420  BOARD_ITEM* item = aCollector[i];
2421 
2422  // We can't copy both a footprint and its text in the same operation, so if
2423  // both are selected, remove the text
2424  if( item->Type() == PCB_FP_TEXT_T && aCollector.HasItem( item->GetParent() ) )
2425  aCollector.Remove( item );
2426  }
2427  },
2428 
2429  // Prompt user regarding locked items.
2430  aEvent.IsAction( &ACTIONS::cut ) && !m_isFootprintEditor );
2431 
2432  if( !selection.Empty() )
2433  {
2434  std::vector<BOARD_ITEM*> items;
2435 
2436  for( EDA_ITEM* item : selection )
2437  items.push_back( static_cast<BOARD_ITEM*>( item ) );
2438 
2439  VECTOR2I refPoint;
2440 
2441  if( aEvent.IsAction( &PCB_ACTIONS::copyWithReference ) )
2442  {
2443  if( !pickReferencePoint( _( "Select reference point for the copy..." ),
2444  _( "Selection copied" ),
2445  _( "Copy canceled" ),
2446  refPoint ) )
2447  return 0;
2448  }
2449  else
2450  {
2451  refPoint = grid.BestDragOrigin( getViewControls()->GetCursorPosition(), items );
2452  }
2453 
2454  selection.SetReferencePoint( refPoint );
2455 
2456  io.SetBoard( board() );
2458  frame()->SetStatusText( _( "Selection copied" ) );
2459  }
2460 
2461  frame()->PopTool( tool );
2462 
2463  return 0;
2464 }
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
BOARD * board() const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
void SetBoard(BOARD *aBoard)
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
bool pickReferencePoint(const wxString &aTooltip, const wxString &aSuccessMessage, const wxString &aCanceledMessage, VECTOR2I &aReferencePoint)
Definition: edit_tool.cpp:2327
PCB_BASE_EDIT_FRAME * frame() const
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:186
const PCB_SELECTION & selection() const
virtual void PopTool(const std::string &actionName)
static TOOL_ACTION cut
Definition: actions.h:66
bool HasItem(const EDA_ITEM *aItem) const
Tests if aItem has already been collected.
Definition: collector.h:203
#define _(s)
static TOOL_ACTION copyWithReference
copy command with manual reference point selection
Definition: pcb_actions.h:98
bool m_isFootprintEditor
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
void Activate()
Run the tool.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
void SaveSelection(const PCB_SELECTION &selected, bool isFootprintEditor)
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:166
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References _, TOOL_INTERACTIVE::Activate(), PCB_TOOL_BASE::board(), PCB_ACTIONS::copyWithReference, ACTIONS::cut, SELECTION::Empty(), PCB_TOOL_BASE::frame(), COLLECTOR::GetCount(), BOARD_ITEM::GetParent(), TOOL_BASE::getViewControls(), grid, COLLECTOR::HasItem(), TOOL_EVENT::IsAction(), PCB_TOOL_BASE::m_isFootprintEditor, m_selectionTool, TOOL_BASE::m_toolMgr, PCB_FP_TEXT_T, pickReferencePoint(), TOOLS_HOLDER::PopTool(), TOOLS_HOLDER::PushTool(), COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), CLIPBOARD_IO::SaveSelection(), PCB_TOOL_BASE::selection(), CLIPBOARD_IO::SetBoard(), SELECTION::SetReferencePoint(), and EDA_ITEM::Type().

Referenced by cutToClipboard(), and setTransitions().

◆ CreateArray()

int EDIT_TOOL::CreateArray ( const TOOL_EVENT aEvent)

Create an array of the selected items, invoking the array editor dialog to set the options.

Definition at line 2251 of file edit_tool.cpp.

2252 {
2253  if( isRouterActive() )
2254  {
2255  wxBell();
2256  return 0;
2257  }
2258 
2259  // Be sure that there is at least one item that we can modify
2261  []( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
2262  {
2263  sTool->FilterCollectorForHierarchy( aCollector, true );
2264  } );
2265 
2266  if( selection.Empty() )
2267  return 0;
2268 
2269  // we have a selection to work on now, so start the tool process
2270  PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
2271  ARRAY_CREATOR array_creator( *editFrame, m_isFootprintEditor, selection );
2272  array_creator.Invoke();
2273 
2274  return 0;
2275 }
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
const PCB_SELECTION & selection() const
bool m_isFootprintEditor
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
void FilterCollectorForHierarchy(GENERAL_COLLECTOR &aCollector, bool aMultiselect) const
In general we don't want to select both a parent and any of it's children.
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
bool isRouterActive() const
Definition: edit_tool.cpp:273
The selection tool: currently supports:
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.

References SELECTION::Empty(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), ARRAY_CREATOR::Invoke(), isRouterActive(), PCB_TOOL_BASE::m_isFootprintEditor, m_selectionTool, PCB_SELECTION_TOOL::RequestSelection(), and PCB_TOOL_BASE::selection().

Referenced by setTransitions().

◆ cutToClipboard()

int EDIT_TOOL::cutToClipboard ( const TOOL_EVENT aEvent)
private

Cut the current selection to the clipboard by formatting it as a fake pcb see #AppendBoardFromClipboard for importing.

Return the right modification point (e.g. for rotation), depending on the number of selected items.

Definition at line 2467 of file edit_tool.cpp.

2468 {
2469  if( !copyToClipboard( aEvent ) )
2470  {
2471  // N.B. Setting the CUT flag prevents lock filtering as we only want to delete the items
2472  // that were copied to the clipboard, no more, no fewer. Filtering for locked item, if
2473  // any will be done in the copyToClipboard() routine
2474  TOOL_EVENT evt( aEvent.Category(), aEvent.Action(), TOOL_ACTION_SCOPE::AS_GLOBAL );
2476  Remove( evt );
2477  }
2478 
2479  return 0;
2480 }
TOOL_ACTIONS Action() const
These give a tool a method of informing the TOOL_MANAGER that a particular event should be passed on ...
Definition: tool_event.h:230
TOOL_EVENT_CATEGORY Category() const
Returns more specific information about the type of an event.
Definition: tool_event.h:227
void SetParameter(T aParam)
Set a non-standard parameter assigned to the event.
Definition: tool_event.h:450
Generic, UI-independent tool event.
Definition: tool_event.h:152
int Remove(const TOOL_EVENT &aEvent)
Delete currently selected items.
Definition: edit_tool.cpp:1754
Global action (toolbar/main menu event, global shortcut)
int copyToClipboard(const TOOL_EVENT &aEvent)
Send the current selection to the clipboard by formatting it as a fake pcb see #AppendBoardFromClipbo...
Definition: edit_tool.cpp:2405

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

Referenced by setTransitions().

◆ displayOptions()

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

Definition at line 302 of file pcb_tool_base.cpp.

303 {
304  return frame()->GetDisplayOptions();
305 }
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
PCB_BASE_EDIT_FRAME * frame() const

References PCB_TOOL_BASE::frame(), and PCB_BASE_FRAME::GetDisplayOptions().

Referenced by BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), PCB_CONTROL::HighContrastMode(), PCB_CONTROL::HighContrastModeCycle(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PNS::TOOL_BASE::pickSingleItem(), PCB_CONTROL::ToggleRatsnest(), PCB_CONTROL::TrackDisplayMode(), PCB_CONTROL::ViaDisplayMode(), and PCB_CONTROL::ZoneDisplayMode().

◆ doInteractiveItemPlacement()

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

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

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

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

Definition at line 37 of file pcb_tool_base.cpp.

40 {
41  using namespace std::placeholders;
42  std::unique_ptr<BOARD_ITEM> newItem;
43 
44  frame()->PushTool( aTool );
45 
46  BOARD_COMMIT commit( frame() );
47 
49 
50  Activate();
51  // Must be done after Activate() so that it gets set into the correct context
52  controls()->ShowCursor( true );
53  // do not capture or auto-pan until we start placing an item
54 
55  PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() );
56 
57  // Add a VIEW_GROUP that serves as a preview for the new item
58  PCB_SELECTION preview;
59  view()->Add( &preview );
60 
61  aPlacer->m_board = board();
62  aPlacer->m_frame = frame();
63  aPlacer->m_modifiers = 0;
64 
65  auto makeNewItem =
66  [&]( VECTOR2I aPosition )
67  {
68  if( frame()->GetModel() )
69  newItem = aPlacer->CreateItem();
70 
71  if( newItem )
72  {
73  newItem->SetPosition( (wxPoint) aPosition );
74  preview.Add( newItem.get() );
75 
76  if( newItem->Type() == PCB_FOOTPRINT_T )
77  {
78  FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( newItem.get() );
79 
80  // footprints have more drawable parts
81  fp->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
82  }
83  }
84  };
85 
86  if( aOptions & IPO_SINGLE_CLICK )
87  makeNewItem( controls()->GetCursorPosition() );
88 
89  auto setCursor =
90  [&]()
91  {
92  if( !newItem )
94  else
96  };
97 
98  // Set initial cursor
99  setCursor();
100 
101  // Main loop: keep receiving events
102  while( TOOL_EVENT* evt = Wait() )
103  {
104  setCursor();
105 
106  grid.SetSnap( false ); // Interactive placement tools need to set their own item snaps
107  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
108  VECTOR2I cursorPos = grid.BestSnapAnchor( controls()->GetMousePosition(), nullptr );
109 
110  aPlacer->m_modifiers = evt->Modifier();
111 
112  auto cleanup =
113  [&] ()
114  {
115  newItem = nullptr;
116  preview.Clear();
117  view()->Update( &preview );
118  controls()->SetAutoPan( false );
119  controls()->CaptureCursor( false );
120  controls()->ShowCursor( true );
121  };
122 
123  if( evt->IsCancelInteractive() )
124  {
125  if( aOptions & IPO_SINGLE_CLICK )
126  {
127  cleanup();
128  frame()->PopTool( aTool );
129  break;
130  }
131  else if( newItem )
132  {
133  cleanup();
134  }
135  else
136  {
137  frame()->PopTool( aTool );
138  break;
139  }
140  }
141  else if( evt->IsActivate() )
142  {
143  if( newItem )
144  cleanup();
145 
146  if( evt->IsPointEditor() )
147  {
148  // don't exit (the point editor runs in the background)
149  }
150  else if( evt->IsMoveTool() )
151  {
152  // leave ourselves on the stack so we come back after the move
153  break;
154  }
155  else
156  {
157  frame()->PopTool( aTool );
158  break;
159  }
160  }
161  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
162  {
163  if( !newItem )
164  {
165  // create the item if possible
166  makeNewItem( cursorPos );
167 
168  // no item created, so wait for another click
169  if( !newItem )
170  continue;
171 
172  controls()->CaptureCursor( true );
173  controls()->SetAutoPan( true );
174  }
175  else
176  {
177  auto oldFlags = newItem->GetFlags();
178  newItem->ClearFlags();
179 
180  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
181  {
182  newItem->SetFlags( oldFlags );
183  continue;
184  }
185 
186  preview.Clear();
187  newItem.release();
188  commit.Push( aCommitMessage );
189 
190  controls()->CaptureCursor( false );
191  controls()->SetAutoPan( false );
192  controls()->ShowCursor( true );
193 
194  if( !( aOptions & IPO_REPEAT ) )
195  break;
196 
197  if( aOptions & IPO_SINGLE_CLICK )
198  makeNewItem( controls()->GetCursorPosition() );
199 
200  setCursor();
201  }
202  }
203  else if( evt->IsClick( BUT_RIGHT ) )
204  {
206  }
207  else if( evt->IsAction( &PCB_ACTIONS::trackViaSizeChanged ) )
208  {
210  }
211  else if( newItem && evt->Category() == TC_COMMAND )
212  {
213  /*
214  * Handle any events that can affect the item as we move it around
215  */
216  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
217  {
218  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
219  newItem->Rotate( newItem->GetPosition(), rotationAngle );
220  view()->Update( &preview );
221  }
222  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
223  {
224  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
225  view()->Update( &preview );
226  }
227  else if( evt->IsAction( &PCB_ACTIONS::viaSizeInc )
228  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
229  {
230  // Refresh preview after event runs
232  }
233  else if( evt->IsAction( &PCB_ACTIONS::properties ) )
234  {
235  frame()->OnEditItemRequest( newItem.get() );
236 
237  // Notify other tools of the changes
239  }
240  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
241  {
242  preview.Clear();
243  newItem.release();
244 
245  makeNewItem( (wxPoint) cursorPos );
246  aPlacer->SnapItem( newItem.get() );
247  view()->Update( &preview );
248  }
249  else
250  {
251  evt->SetPassEvent();
252  }
253  }
254  else if( newItem && evt->IsMotion() )
255  {
256  // track the cursor
257  newItem->SetPosition( (wxPoint) cursorPos );
258  aPlacer->SnapItem( newItem.get() );
259 
260  // Show a preview of the item
261  view()->Update( &preview );
262  }
263  else
264  {
265  evt->SetPassEvent();
266  }
267  }
268 
269  view()->Remove( &preview );
271  controls()->SetAutoPan( false );
272  controls()->CaptureCursor( false );
273 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:82
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:31
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:296
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
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:214
virtual void OnEditItemRequest(BOARD_ITEM *aItem)=0
Install the corresponding dialog editor for the given item.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:117
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:299
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:204
TOOL_MANAGER * GetManager() const
Return 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)
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: pcb_view.cpp:92
const PCB_SELECTION & selection() const
Allow repeat placement of the item.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
Generic, UI-independent tool event.
Definition: tool_event.h:152
KIGFX::PCB_VIEW * view() const
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:56
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:105
Handle the rotate action in the loop by calling the item's rotate method.
KIGFX::VIEW_CONTROLS * controls() const
PCBNEW_SETTINGS & Settings()
void Activate()
Run the tool.
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all BOARD_ITEMs that belong to the footprint (pads, drawings,...
Definition: footprint.cpp:1236
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
PCB_BASE_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:64
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:297
static TOOL_ACTION refreshPreview
Definition: actions.h:106

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), TOOL_BASE::getView(), grid, PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, PCBNEW_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, TOOL_BASE::m_toolMgr, PCB_BASE_EDIT_FRAME::OnEditItemRequest(), PCB_FOOTPRINT_T, PENCIL, PLACE, INTERACTIVE_PLACER_BASE::PlaceItem(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::ProcessEvent(), PCB_ACTIONS::properties, BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), FOOTPRINT::RunOnChildren(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, PCB_ACTIONS::trackViaSizeChanged, KIGFX::PCB_VIEW::Update(), PCB_ACTIONS::viaSizeDec, PCB_ACTIONS::viaSizeInc, PCB_TOOL_BASE::view(), and TOOL_INTERACTIVE::Wait().

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

◆ doMoveSelection()

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

Definition at line 705 of file edit_tool.cpp.

706 {
707  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
709  VECTOR2I originalCursorPos = controls->GetCursorPosition();
710 
711  // Be sure that there is at least one item that we can modify. If nothing was selected before,
712  // try looking for the stuff under mouse cursor (i.e. KiCad old-style hover selection)
714  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
715  {
716  // Iterate from the back so we don't have to worry about removals.
717  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
718  {
719  BOARD_ITEM* item = aCollector[ i ];
720 
721  if( item->Type() == PCB_MARKER_T )
722  aCollector.Remove( item );
723  }
724  } );
725 
726  if( m_dragging || selection.Empty() )
727  return 0;
728 
729  LSET item_layers = selection.GetSelectionLayers();
730  bool is_hover = selection.IsHover(); // N.B. This must be saved before the re-selection
731  // below
732  VECTOR2I pickedReferencePoint;
733 
734  // Now filter out locked and grouped items. We cannot do this in the first RequestSelection()
735  // as we need the item_layers when a pad is the selection front.
736  if( frame()->Settings().m_AllowFreePads )
737  {
739  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
740  {
741  std::set<BOARD_ITEM*> to_add;
742 
743  // Iterate from the back so we don't have to worry about removals.
744  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
745  {
746  BOARD_ITEM* item = aCollector[i];
747 
748  if( item->Type() == PCB_MARKER_T )
749  aCollector.Remove( item );
750 
751  // Locked pads do not get moved independently of the footprint
752  if( !sTool->IsFootprintEditor() && item->Type() == PCB_PAD_T
753  && item->IsLocked() )
754  {
755  if( !aCollector.HasItem( item->GetParent() ) )
756  to_add.insert( item->GetParent() );
757 
758  aCollector.Remove( item );
759  }
760  }
761 
762  for( BOARD_ITEM* item : to_add )
763  aCollector.Append( item );
764  },
765  !m_isFootprintEditor /* prompt user regarding locked items only in pcb editor*/ );
766  }
767  else
768  {
769  // Unlocked pads are treated as locked if the setting m_AllowFreePads is false
771  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector,
772  PCB_SELECTION_TOOL* sTool )
773  {
774  std::set<BOARD_ITEM*> to_add;
775 
776  // Iterate from the back so we don't have to worry about removals.
777  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
778  {
779  BOARD_ITEM* item = aCollector[i];
780 
781  if( item->Type() == PCB_MARKER_T )
782  aCollector.Remove( item );
783 
784  // Treat all pads as locked (i.e. cannot be moved independently of parent)
785  if( !sTool->IsFootprintEditor() && item->Type() == PCB_PAD_T )
786  {
787  if( !aCollector.HasItem( item->GetParent() ) )
788  to_add.insert( item->GetParent() );
789 
790  aCollector.Remove( item );
791  }
792  }
793 
794  for( BOARD_ITEM* item : to_add )
795  aCollector.Append( item );
796  },
797  !m_isFootprintEditor /* prompt user regarding locked items only in pcb editor*/ );
798  }
799 
800  if( selection.Empty() )
801  return 0;
802 
803  std::string tool = aEvent.GetCommandStr().get();
804  editFrame->PushTool( tool );
805 
806  Activate();
807  // Must be done after Activate() so that it gets set into the correct context
808  controls->ShowCursor( true );
809  controls->SetAutoPan( true );
810 
811  if( aPickReference && !pickReferencePoint( _( "Select reference point for move..." ), "", "",
812  pickedReferencePoint ) )
813  {
814  if( is_hover )
816 
817  editFrame->PopTool( tool );
818  return 0;
819  }
820 
821  std::vector<BOARD_ITEM*> sel_items; // All the items operated on by the move below
822  std::vector<BOARD_ITEM*> orig_items; // All the original items in the selection
823 
824  for( EDA_ITEM* item : selection )
825  {
826  BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
827  FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( item );
828 
829  if( boardItem )
830  {
831  orig_items.push_back( boardItem );
832  sel_items.push_back( boardItem );
833  }
834 
835  if( footprint )
836  {
837  for( PAD* pad : footprint->Pads() )
838  sel_items.push_back( pad );
839  }
840  }
841 
842  bool restore_state = false;
843  VECTOR2I originalPos;
844  VECTOR2I totalMovement;
846  TOOL_EVENT* evt = &aEvent;
847  VECTOR2I prevPos;
848 
849  bool eatFirstMouseUp = true;
850  bool hasRedrawn3D = false;
851  bool allowRedraw3D = editFrame->GetDisplayOptions().m_Live3DRefresh;
852 
853  // Prime the pump
855 
856  // Main loop: keep receiving events
857  do
858  {
859  VECTOR2I movement;
861  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
862  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
863 
864  if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
865  eatFirstMouseUp = false;
866 
867  if( evt->IsAction( &PCB_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
868  || evt->IsAction( &ACTIONS::refreshPreview )
869  || evt->IsAction( &PCB_ACTIONS::moveWithReference ) )
870  {
871  if( m_dragging && evt->Category() == TC_MOUSE )
872  {
873  bool redraw3D = false;
874 
875  VECTOR2I mousePos( controls->GetMousePosition() );
876 
877  m_cursor = grid.BestSnapAnchor( mousePos, item_layers, sel_items );
878 
880  {
882 
883  // The arrow keys are by definition SINGLE AXIS. Do not allow the other
884  // axis to be snapped to the grid.
885  if( action == ACTIONS::CURSOR_LEFT || action == ACTIONS::CURSOR_RIGHT )
886  m_cursor.y = prevPos.y;
887  else if( action == ACTIONS::CURSOR_UP || action == ACTIONS::CURSOR_DOWN )
888  m_cursor.x = prevPos.x;
889  }
890 
892  originalPos = m_cursor;
893 
894  if( Is45Limited() )
895  {
896  VECTOR2I moveVector = m_cursor - originalPos;
897  m_cursor = originalPos + GetVectorSnapped45( moveVector );
898  }
899 
902 
903  movement = m_cursor - prevPos;
904  prevPos = m_cursor;
905  totalMovement += movement;
906 
907  // Drag items to the current cursor position
908  for( EDA_ITEM* item : sel_items )
909  {
910  // Don't double move footprint pads, fields, etc.
911  //
912  // For PCB_GROUP_T, we make sure the selection includes only the top level
913  // group and not its descendants.
914  if( !item->GetParent() || !item->GetParent()->IsSelected() )
915  static_cast<BOARD_ITEM*>( item )->Move( movement );
916 
917  if( !redraw3D && item->Type() == PCB_FOOTPRINT_T )
918  redraw3D = true;
919  }
920 
921  if( redraw3D && allowRedraw3D )
922  {
923  editFrame->Update3DView( false, true );
924  hasRedrawn3D = true;
925  }
926 
928  }
929  else if( !m_dragging && !evt->IsAction( &ACTIONS::refreshPreview ) )
930  {
931  // Prepare to start dragging
932  if( !( evt->IsAction( &PCB_ACTIONS::move )
933  || evt->IsAction( &PCB_ACTIONS::moveWithReference ) )
935  {
937  break;
938  }
939 
940  m_dragging = true;
941 
942  // When editing footprints, all items have the same parent
943  if( IsFootprintEditor() )
944  {
945  m_commit->Modify( selection.Front() );
946  }
947  else
948  {
949  // Save items, so changes can be undone
950  for( EDA_ITEM* item : selection )
951  {
952  // Don't double move footprint pads, fields, etc.
953  //
954  // For PCB_GROUP_T, the parent is the board.
955  if( item->GetParent() && item->GetParent()->IsSelected() )
956  continue;
957 
958  m_commit->Modify( item );
959 
960  // If moving a group, record position of all the descendants for undo
961  if( item->Type() == PCB_GROUP_T )
962  {
963  PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
964  group->RunOnDescendants( [&]( BOARD_ITEM* bItem )
965  {
966  m_commit->Modify( bItem );
967  });
968  }
969  }
970  }
971 
972  editFrame->UndoRedoBlock( true );
974 
976  {
977  // start moving with the reference point attached to the cursor
978  grid.SetAuxAxes( false );
979 
980  if( Is45Limited() )
981  {
982  VECTOR2I moveVector = m_cursor - originalPos;
983  m_cursor = originalPos + GetVectorSnapped45( moveVector );
984  }
985 
986  movement = m_cursor - selection.GetReferencePoint();
987 
988  // Drag items to the current cursor position
989  for( EDA_ITEM* item : selection )
990  {
991  // Don't double move footprint pads, fields, etc.
992  if( item->GetParent() && item->GetParent()->IsSelected() )
993  continue;
994 
995  static_cast<BOARD_ITEM*>( item )->Move( movement );
996  }
997 
999  }
1000  else
1001  {
1002  std::vector<BOARD_ITEM*> items;
1003 
1004  for( EDA_ITEM* item : selection )
1005  items.push_back( static_cast<BOARD_ITEM*>( item ) );
1006 
1007  m_cursor = grid.BestDragOrigin( originalCursorPos, items );
1008 
1009  // Set the current cursor position to the first dragged item origin, so the
1010  // movement vector could be computed later
1011  if( aPickReference )
1012  {
1013  selection.SetReferencePoint( pickedReferencePoint );
1014  controls->ForceCursorPosition( true, pickedReferencePoint );
1015  m_cursor = pickedReferencePoint;
1016  }
1017  else
1018  {
1019  // Check if user wants to warp the mouse to origin of moved object
1020  if( !editFrame->GetMoveWarpsCursor() )
1021  m_cursor = originalCursorPos; // No, so use original mouse pos instead
1022 
1024  grid.SetAuxAxes( true, m_cursor );
1025  }
1026 
1027  originalPos = m_cursor;
1028 
1029  }
1030 
1031  controls->SetCursorPosition( m_cursor, false );
1032 
1033  prevPos = m_cursor;
1034  controls->SetAutoPan( true );
1036  }
1037 
1039  new VECTOR2I( movement ) );
1040  }
1041  else if( evt->IsCancelInteractive() || evt->IsActivate() )
1042  {
1043  if( m_dragging && evt->IsCancelInteractive() )
1044  evt->SetPassEvent( false );
1045 
1046  restore_state = true; // Canceling the tool means that items have to be restored
1047  break; // Finish
1048  }
1049  else if( evt->IsAction( &ACTIONS::undo ) )
1050  {
1051  restore_state = true; // Perform undo locally
1052  break; // Finish
1053  }
1054  else if( evt->IsAction( &ACTIONS::doDelete ) || evt->IsAction( &ACTIONS::cut ) )
1055  {
1056  // Dispatch TOOL_ACTIONs
1057  evt->SetPassEvent();
1058  break; // finish -- there is no further processing for removed items
1059  }
1060  else if( evt->IsAction( &ACTIONS::duplicate ) )
1061  {
1062  evt->SetPassEvent();
1063  break; // finish -- Duplicate tool will start a new Move with the dup'ed items
1064  }
1065  else if( evt->IsAction( &PCB_ACTIONS::rotateCw )
1066  || evt->IsAction( &PCB_ACTIONS::rotateCcw )
1067  || evt->IsAction( &PCB_ACTIONS::flip )
1068  || evt->IsAction( &PCB_ACTIONS::mirror ) )
1069  {
1070  eatFirstMouseUp = false;
1071  evt->SetPassEvent();
1072  }
1073  else if( evt->IsAction( &PCB_ACTIONS::moveExact ) )
1074  {
1075  // Reset positions so the Move Exactly is from the start.
1076  for( EDA_ITEM* item : selection )
1077  {
1078  BOARD_ITEM* i = static_cast<BOARD_ITEM*>( item );
1079  i->Move( -totalMovement );
1080  }
1081 
1082  break; // finish -- we moved exactly, so we are finished
1083  }
1084  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
1085  {
1086  // Eat mouse-up/-click events that leaked through from the lock dialog
1087  if( eatFirstMouseUp && evt->Parameter<intptr_t>() != ACTIONS::CURSOR_CLICK )
1088  {
1089  eatFirstMouseUp = false;
1090  continue;
1091  }
1092 
1093  break; // finish
1094  }
1095  else
1096  {
1097  evt->SetPassEvent();
1098  }
1099 
1100  } while( ( evt = Wait() ) ); // Assignment (instead of equality test) is intentional
1101 
1102  controls->ForceCursorPosition( false );
1103  controls->ShowCursor( false );
1104  controls->SetAutoPan( false );
1105 
1106  m_dragging = false;
1107  editFrame->UndoRedoBlock( false );
1108 
1109  if( hasRedrawn3D && restore_state )
1110  editFrame->Update3DView( false, true );
1111 
1112  // Discard reference point when selection is "dropped" onto the board
1114 
1115  // TODO: there's an encapsulation leak here: this commit often has more than just the move
1116  // in it; for instance it might have a paste, append board, etc. as well.
1117  if( restore_state )
1118  m_commit->Revert();
1119  else
1120  m_commit->Push( _( "Drag" ) );
1121 
1122  // Remove the dynamic ratsnest from the screen
1124 
1125  // Unselect all items to update flags
1127 
1128  // Reselect items if they were already selected and we completed the move
1129  if( !is_hover && !restore_state )
1130  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &orig_items );
1131 
1132  editFrame->PopTool( tool );
1133 
1134  return restore_state ? -1 : 0;
1135 }
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Definition: pcb_actions.h:66
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
VECTOR2I GetReferencePoint() const
Definition: selection.h:181
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
VECTOR2I m_cursor
Definition: edit_tool.h:193
void ClearReferencePoint()
Definition: selection.h:191
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
bool IsHover() const
Definition: selection.h:73
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
bool IsSelected() const
Definition: eda_item.h:123
static TOOL_ACTION doDelete
Definition: actions.h:72
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:191
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
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:214
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:108
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
class PAD, a pad in a footprint
Definition: typeinfo.h:89
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
virtual bool IsLocked() const
Definition: board_item.cpp:78
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:204
PADS & Pads()
Definition: footprint.h:168
const VC_SETTINGS & GetSettings() const
Apply VIEW_CONTROLS settings from an object.
static TOOL_ACTION moveExact
Activation of the exact move tool.
Definition: pcb_actions.h:120
bool pickReferencePoint(const wxString &aTooltip, const wxString &aSuccessMessage, const wxString &aCanceledMessage, VECTOR2I &aReferencePoint)
Definition: edit_tool.cpp:2327
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:105
PCB_BASE_EDIT_FRAME * frame() const
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:186
bool isInteractiveDragEnabled() const
Definition: edit_tool.cpp:265
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:101
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:502
const PCB_SELECTION & selection() const
bool m_dragging
Definition: edit_tool.h:192
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:272
virtual void PopTool(const std::string &actionName)
Generic, UI-independent tool event.
Definition: tool_event.h:152
FOOTPRINT * footprint() const
static TOOL_ACTION cut
Definition: actions.h:66
bool HasItem(const EDA_ITEM *aItem) const
Tests if aItem has already been collected.
Definition: collector.h:203
An interface for classes handling user events controlling the view behavior such as zooming,...
#define _(s)
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
Definition: actions.h:207
bool Is45Limited() const
Should the tool use its 45° mode option?
bool m_isFootprintEditor
static TOOL_ACTION hideDynamicRatsnest
Definition: pcb_actions.h:459
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:102
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:105
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:235
bool HasReferencePoint() const
Definition: selection.h:176
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:98
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
KIGFX::VIEW_CONTROLS * controls() const
Common, abstract interface for edit frames.
long m_lastKeyboardCursorCommand
Position of the above event.
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
bool m_Live3DRefresh
If true, 3D viewer will redraw on every modification operation.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
bool m_lastKeyboardCursorPositionValid
ACTIONS::CURSOR_UP, ACTIONS::CURSOR_DOWN, etc.
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
bool IsFootprintEditor() const
bool GetMoveWarpsCursor() const
Indicate that a move operation should warp the mouse pointer to the origin of the move object.
Definition: tools_holder.h:141
void Activate()
Run the tool.
static TOOL_ACTION undo
Definition: actions.h:64
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:460
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
Definition: pad.h:57
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:166
static TOOL_ACTION moveWithReference
move with a reference point
Definition: pcb_actions.h:95
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
const LSET GetSelectionLayers()
static TOOL_ACTION duplicate
Definition: actions.h:71
static TOOL_ACTION refreshPreview
Definition: actions.h:106
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:144
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References _, TOOL_INTERACTIVE::Activate(), COLLECTOR::Append(), BUT_LEFT, SELECTION::ClearReferencePoint(), PCB_TOOL_BASE::controls(), ACTIONS::CURSOR_CLICK, ACTIONS::CURSOR_DOWN, ACTIONS::CURSOR_LEFT, ACTIONS::CURSOR_RIGHT, ACTIONS::CURSOR_UP, ACTIONS::cut, PNS::DM_ANY, ACTIONS::doDelete, ACTIONS::duplicate, SELECTION::Empty(), PCB_ACTIONS::flip, PCB_TOOL_BASE::footprint(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), SELECTION::Front(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), COLLECTOR::GetCount(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_FRAME::GetDisplayOptions(), PCB_BASE_FRAME::GetMagneticItemsSettings(), KIGFX::VIEW_CONTROLS::GetMousePosition(), TOOLS_HOLDER::GetMoveWarpsCursor(), BOARD_ITEM::GetParent(), SELECTION::GetReferencePoint(), PCB_SELECTION::GetSelectionLayers(), KIGFX::VIEW_CONTROLS::GetSettings(), GetVectorSnapped45(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), grid, group, COLLECTOR::HasItem(), SELECTION::HasReferencePoint(), PCB_ACTIONS::hideDynamicRatsnest, invokeInlineRouter(), PCB_TOOL_BASE::Is45Limited(), PCB_TOOL_BASE::IsFootprintEditor(), SELECTION::IsHover(), isInteractiveDragEnabled(), BOARD_ITEM::IsLocked(), m_commit, m_cursor, m_dragging, PCB_TOOL_BASE::m_isFootprintEditor, KIGFX::VC_SETTINGS::m_lastKeyboardCursorCommand, KIGFX::VC_SETTINGS::m_lastKeyboardCursorPositionValid, PCB_DISPLAY_OPTIONS::m_Live3DRefresh, m_selectionTool, TOOL_BASE::m_toolMgr, MD_SHIFT, PCB_ACTIONS::mirror, PCB_ACTIONS::move, BOARD_ITEM::Move(), PCB_ACTIONS::moveExact, PCB_ACTIONS::moveWithReference, MOVING, pad, FOOTPRINT::Pads(), PCB_FOOTPRINT_T, PCB_GROUP_T, PCB_MARKER_T, PCB_PAD_T, pickReferencePoint(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::PostEvent(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), PCB_ACTIONS::rotateCcw, PCB_ACTIONS::rotateCw, TOOL_MANAGER::RunAction(), EVENTS::SelectedItemsModified, EVENTS::SelectedItemsMoved, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItems, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), SELECTION::SetReferencePoint(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_MOUSE, EDA_ITEM::Type(), ACTIONS::undo, PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PCB_BASE_FRAME::Update3DView(), PCB_ACTIONS::updateLocalRatsnest, TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Move(), and MoveWithReference().

◆ Drag()

int EDIT_TOOL::Drag ( const TOOL_EVENT aEvent)

Invoke the PNS router to drag tracks or do an offline resizing of an arc track if a single arc track is selected.

Definition at line 281 of file edit_tool.cpp.

282 {
283  int mode = PNS::DM_ANY;
284 
285  if( aEvent.IsAction( &PCB_ACTIONS::dragFreeAngle ) )
286  mode |= PNS::DM_FREE_ANGLE;
287 
289  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
290  {
291  // Iterate from the back so we don't have to worry about removals.
292  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
293  {
294  BOARD_ITEM* item = aCollector[ i ];
295 
296  // We don't operate on pads; convert them to footprint selections
297  if( !sTool->IsFootprintEditor() && item->Type() == PCB_PAD_T )
298  {
299  aCollector.Remove( item );
300 
301  if( item->GetParent() && !aCollector.HasItem( item->GetParent() ) )
302  aCollector.Append( item->GetParent() );
303  }
304  }
305 
306  sTool->FilterCollectorForHierarchy( aCollector, true );
307  },
308  true /* prompt user regarding locked items */ );
309 
310  if( selection.Empty() )
311  return 0;
312 
313  if( selection.Size() == 1 && selection.Front()->Type() == PCB_ARC_T )
314  {
315  // TODO: This really should be done in PNS to ensure DRC is maintained, but for now
316  // it allows interactive editing of an arc track
317  return DragArcTrack( aEvent );
318  }
319  else
320  {
321  invokeInlineRouter( mode );
322  }
323 
324  return 0;
325 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:138
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class PAD, a pad in a footprint
Definition: typeinfo.h:89
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:105
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
const PCB_SELECTION & selection() const
bool HasItem(const EDA_ITEM *aItem) const
Tests if aItem has already been collected.
Definition: collector.h:203
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
void FilterCollectorForHierarchy(GENERAL_COLLECTOR &aCollector, bool aMultiselect) const
In general we don't want to select both a parent and any of it's children.
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:235
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
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:103
The selection tool: currently supports:
bool IsFootprintEditor() const
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:166
EDA_ITEM * Front() const
Definition: selection.h:144
int DragArcTrack(const TOOL_EVENT &aTrack)
Drag-resize an arc (and change end points of connected straight segments).
Definition: edit_tool.cpp:328
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References COLLECTOR::Append(), PNS::DM_ANY, PNS::DM_FREE_ANGLE, DragArcTrack(), PCB_ACTIONS::dragFreeAngle, SELECTION::Empty(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), SELECTION::Front(), COLLECTOR::GetCount(), BOARD_ITEM::GetParent(), COLLECTOR::HasItem(), invokeInlineRouter(), TOOL_EVENT::IsAction(), PCB_TOOL_BASE::IsFootprintEditor(), m_selectionTool, PCB_ARC_T, PCB_PAD_T, COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), PCB_TOOL_BASE::selection(), SELECTION::Size(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ DragArcTrack()

int EDIT_TOOL::DragArcTrack ( const TOOL_EVENT aTrack)

Drag-resize an arc (and change end points of connected straight segments).

Definition at line 328 of file edit_tool.cpp.

329 {
331 
332  if( selection.Size() != 1 || selection.Front()->Type() != PCB_ARC_T )
333  return 0;
334 
335  PCB_ARC* theArc = static_cast<PCB_ARC*>( selection.Front() );
336  double arcAngleDegrees = std::abs( theArc->GetAngle() ) / 10.0;
337 
338  if( arcAngleDegrees + ADVANCED_CFG::GetCfg().m_MaxTangentAngleDeviation >= 180.0 )
339  {
341  wxString::Format( _( "Unable to resize arc tracks %.1f degrees or greater." ),
342  180.0 - ADVANCED_CFG::GetCfg().m_MaxTangentAngleDeviation ) );
343  return 0; // don't bother with > 180 degree arcs
344  }
345 
347 
348  Activate();
349  // Must be done after Activate() so that it gets set into the correct context
350  controls->ShowCursor( true );
351  controls->SetAutoPan( true );
352 
353  bool restore_state = false;
354  VECTOR2I arcCenter = theArc->GetCenter();
355  SEG tanStart = SEG( arcCenter, theArc->GetStart() ).PerpendicularSeg( theArc->GetStart() );
356  SEG tanEnd = SEG( arcCenter, theArc->GetEnd() ).PerpendicularSeg( theArc->GetEnd() );
357 
358  //Ensure the tangent segments are in the correct orientation
359  VECTOR2I tanIntersect = tanStart.IntersectLines( tanEnd ).get();
360  tanStart.A = tanIntersect;
361  tanStart.B = theArc->GetStart();
362  tanEnd.A = tanIntersect;
363  tanEnd.B = theArc->GetEnd();
364 
365  KICAD_T track_types[] = { PCB_PAD_T, PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, EOT };
366 
367  auto getUniqueTrackAtAnchorCollinear =
368  [&]( const VECTOR2I& aAnchor, const SEG& aCollinearSeg ) -> PCB_TRACK*
369  {
370  auto conn = board()->GetConnectivity();
371 
372  // Allow items at a distance within the width of the arc track
373  int allowedDeviation = theArc->GetWidth();
374 
375  std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
376 
377  for( int i = 0; i < 3; i++ )
378  {
379  itemsOnAnchor = conn->GetConnectedItemsAtAnchor( theArc, aAnchor, track_types,
380  allowedDeviation );
381  allowedDeviation /= 2;
382 
383  if( itemsOnAnchor.size() == 1 )
384  break;
385  }
386 
387  PCB_TRACK* retval = nullptr;
388 
389  if( itemsOnAnchor.size() == 1 && itemsOnAnchor.front()->Type() == PCB_TRACE_T )
390  {
391  retval = static_cast<PCB_TRACK*>( itemsOnAnchor.front() );
392  SEG trackSeg( retval->GetStart(), retval->GetEnd() );
393 
394  // Allow deviations in colinearity as defined in ADVANCED_CFG
395  if( trackSeg.AngleDegrees( aCollinearSeg )
397  {
398  retval = nullptr;
399  }
400  }
401 
402  if( !retval )
403  {
404  retval = new PCB_TRACK( theArc->GetParent() );
405  retval->SetStart( (wxPoint) aAnchor );
406  retval->SetEnd( (wxPoint) aAnchor );
407  retval->SetNet( theArc->GetNet() );
408  retval->SetLayer( theArc->GetLayer() );
409  retval->SetWidth( theArc->GetWidth() );
410  retval->SetLocked( theArc->IsLocked() );
411  retval->SetFlags( IS_NEW );
412  getView()->Add( retval );
413  }
414 
415  return retval;
416  };
417 
418  PCB_TRACK* trackOnStart = getUniqueTrackAtAnchorCollinear( theArc->GetStart(), tanStart);
419  PCB_TRACK* trackOnEnd = getUniqueTrackAtAnchorCollinear( theArc->GetEnd(), tanEnd );
420 
421  // Make copies of items to be edited
422  PCB_ARC* theArcCopy = new PCB_ARC( *theArc );
423  PCB_TRACK* trackOnStartCopy = new PCB_TRACK( *trackOnStart );
424  PCB_TRACK* trackOnEndCopy = new PCB_TRACK( *trackOnEnd );
425 
426  if( trackOnStart->GetLength() != 0 )
427  {
428  tanStart.A = trackOnStart->GetStart();
429  tanStart.B = trackOnStart->GetEnd();
430  }
431 
432  if( trackOnEnd->GetLength() != 0 )
433  {
434  tanEnd.A = trackOnEnd->GetStart();
435  tanEnd.B = trackOnEnd->GetEnd();
436  }
437 
438  // Recalculate intersection point
439  tanIntersect = tanStart.IntersectLines( tanEnd ).get();
440 
441  auto isTrackStartClosestToArcStart =
442  [&]( PCB_TRACK* aTrack ) -> bool
443  {
444  double trackStartToArcStart = GetLineLength( aTrack->GetStart(), theArc->GetStart() );
445  double trackEndToArcStart = GetLineLength( aTrack->GetEnd(), theArc->GetStart() );
446 
447  return trackStartToArcStart < trackEndToArcStart;
448  };
449 
450  bool isStartTrackOnStartPt = isTrackStartClosestToArcStart( trackOnStart );
451  bool isEndTrackOnStartPt = isTrackStartClosestToArcStart( trackOnEnd );
452 
453  // Calculate constraints
454  //======================
455  // maxTanCircle is the circle with maximum radius that is tangent to the two adjacent straight
456  // tracks and whose tangent points are constrained within the original tracks and their
457  // projected intersection points.
458  //
459  // The cursor will be constrained first within the isosceles triangle formed by the segments
460  // cSegTanStart, cSegTanEnd and cSegChord. After that it will be constrained to be outside
461  // maxTanCircle.
462  //
463  //
464  // ____________ <-cSegTanStart
465  // / * . ' *
466  // cSegTanEnd-> / * . ' *
467  // /* . ' <-cSegChord *
468  // /. '
469  // /* *
470  //
471  // * c * <-maxTanCircle
472  //
473  // * *
474  //
475  // * *
476  // * *
477  // * *
478  //
479 
480  auto getFurthestPointToTanInterstect =
481  [&]( VECTOR2I& aPointA, VECTOR2I& aPointB ) -> VECTOR2I
482  {
483  if( ( aPointA - tanIntersect ).EuclideanNorm()
484  > ( aPointB - tanIntersect ).EuclideanNorm() )
485  {
486  return aPointA;
487  }
488  else
489  {
490  return aPointB;
491  }
492  };
493 
494  CIRCLE maxTanCircle;
495  VECTOR2I tanStartPoint = getFurthestPointToTanInterstect( tanStart.A, tanStart.B );
496  VECTOR2I tanEndPoint = getFurthestPointToTanInterstect( tanEnd.A, tanEnd.B );
497  VECTOR2I tempTangentPoint = tanEndPoint;
498 
499  if( getFurthestPointToTanInterstect( tanStartPoint, tanEndPoint ) == tanEndPoint )
500  tempTangentPoint = tanStartPoint;
501 
502  maxTanCircle.ConstructFromTanTanPt( tanStart, tanEnd, tempTangentPoint );
503  VECTOR2I maxTanPtStart = tanStart.LineProject( maxTanCircle.Center );
504  VECTOR2I maxTanPtEnd = tanEnd.LineProject( maxTanCircle.Center );
505 
506  SEG cSegTanStart( maxTanPtStart, tanIntersect );
507  SEG cSegTanEnd( maxTanPtEnd, tanIntersect );
508  SEG cSegChord( maxTanPtStart, maxTanPtEnd );
509 
510  int cSegTanStartSide = cSegTanStart.Side( theArc->GetMid() );
511  int cSegTanEndSide = cSegTanEnd.Side( theArc->GetMid() );
512  int cSegChordSide = cSegChord.Side( theArc->GetMid() );
513 
514  bool eatFirstMouseUp = true;
515 
516  // Start the tool loop
517  while( TOOL_EVENT* evt = Wait() )
518  {
520 
521  // Constrain cursor within the isosceles triangle
522  if( cSegTanStartSide != cSegTanStart.Side( m_cursor )
523  || cSegTanEndSide != cSegTanEnd.Side( m_cursor )
524  || cSegChordSide != cSegChord.Side( m_cursor ) )
525  {
526  std::vector<VECTOR2I> possiblePoints;
527 
528  possiblePoints.push_back( cSegTanEnd.NearestPoint( m_cursor ) );
529  possiblePoints.push_back( cSegChord.NearestPoint( m_cursor ) );
530 
531  VECTOR2I closest = cSegTanStart.NearestPoint( m_cursor );
532 
533  for( VECTOR2I candidate : possiblePoints )
534  {
535  if( ( candidate - m_cursor ).SquaredEuclideanNorm()
536  < ( closest - m_cursor ).SquaredEuclideanNorm() )
537  {
538  closest = candidate;
539  }
540  }
541 
542  m_cursor = closest;
543  }
544 
545  // Constrain cursor to be outside maxTanCircle
546  if( ( m_cursor - maxTanCircle.Center ).EuclideanNorm() < maxTanCircle.Radius )
547  m_cursor = maxTanCircle.NearestPoint( m_cursor );
548 
550 
551  // Calculate resulting object coordinates
552  CIRCLE circlehelper;
553  circlehelper.ConstructFromTanTanPt( cSegTanStart, cSegTanEnd, m_cursor );
554 
555  VECTOR2I newCenter = circlehelper.Center;
556  VECTOR2I newStart = cSegTanStart.LineProject( newCenter );
557  VECTOR2I newEnd = cSegTanEnd.LineProject( newCenter );
558  VECTOR2I newMid = GetArcMid( newStart, newEnd, newCenter );
559 
560  // Update objects
561  theArc->SetStart( (wxPoint) newStart );
562  theArc->SetEnd( (wxPoint) newEnd );
563  theArc->SetMid( (wxPoint) newMid );
564 
565  if( isStartTrackOnStartPt )
566  trackOnStart->SetStart( (wxPoint) newStart );
567  else
568  trackOnStart->SetEnd( (wxPoint) newStart );
569 
570  if( isEndTrackOnStartPt )
571  trackOnEnd->SetStart( (wxPoint) newEnd );
572  else
573  trackOnEnd->SetEnd( (wxPoint) newEnd );
574 
575  // Update view
576  getView()->Update( trackOnStart );
577  getView()->Update( trackOnEnd );
578  getView()->Update( theArc );
579 
580  // Handle events
581  if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
582  {
583  eatFirstMouseUp = false;
584  }
585  else if( evt->IsCancelInteractive() || evt->IsActivate() )
586  {
587  restore_state = true; // Canceling the tool means that items have to be restored
588  break; // Finish
589  }
590  else if( evt->IsAction( &ACTIONS::undo ) )
591  {
592  restore_state = true; // Perform undo locally
593  break; // Finish
594  }
595  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT )
596  || evt->IsDblClick( BUT_LEFT ) )
597  {
598  // Eat mouse-up/-click events that leaked through from the lock dialog
599  if( eatFirstMouseUp && evt->Parameter<intptr_t>() != ACTIONS::CURSOR_CLICK )
600  {
601  eatFirstMouseUp = false;
602  continue;
603  }
604 
605  break; // Finish
606  }
607  }
608 
609  // Ensure we only do one commit operation on each object
610  auto processTrack =
611  [&]( PCB_TRACK* aTrack, PCB_TRACK* aTrackCopy, int aMaxLengthIU ) -> bool
612  {
613  if( aTrack->IsNew() )
614  {
615  getView()->Remove( aTrack );
616 
617  if( aTrack->GetLength() <= aMaxLengthIU )
618  {
619  delete aTrack;
620  delete aTrackCopy;
621  aTrack = nullptr;
622  aTrackCopy = nullptr;
623  return false;
624  }
625  else
626  {
627  m_commit->Add( aTrack );
628  delete aTrackCopy;
629  aTrackCopy = nullptr;
630  return true;
631  }
632  }
633  else if( aTrack->GetLength() <= aMaxLengthIU )
634  {
635  aTrack->SwapData( aTrackCopy ); //restore the original before notifying COMMIT
636  m_commit->Remove( aTrack );
637  delete aTrackCopy;
638  aTrackCopy = nullptr;
639  return false;
640  }
641  else
642  {
643  m_commit->Modified( aTrack, aTrackCopy );
644  }
645 
646  return true;
647  };
648 
649  // Amend the end points of the arc if we delete the joining tracks
650  wxPoint newStart = trackOnStart->GetStart();
651  wxPoint newEnd = trackOnEnd->GetStart();
652 
653  if( isStartTrackOnStartPt )
654  newStart = trackOnStart->GetEnd();
655 
656  if( isEndTrackOnStartPt )
657  newEnd = trackOnEnd->GetEnd();
658 
659  int maxLengthIU = KiROUND( ADVANCED_CFG::GetCfg().m_MaxTrackLengthToKeep * IU_PER_MM );
660 
661  if( !processTrack( trackOnStart, trackOnStartCopy, maxLengthIU ) )
662  theArc->SetStart( newStart );
663 
664  if( !processTrack( trackOnEnd, trackOnEndCopy, maxLengthIU ) )
665  theArc->SetEnd( newEnd );
666 
667  processTrack( theArc, theArcCopy, 0 ); // only delete the arc if start and end points coincide
668 
669  // Should we commit?
670  if( restore_state )
671  m_commit->Revert();
672  else
673  m_commit->Push( _( "Drag Arc Track" ) );
674 
675  return 0;
676 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
VECTOR2I m_cursor
Definition: edit_tool.h:193
virtual wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_track.h:282
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:222
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
BOARD * board() const
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
#define IS_NEW
New item, just created.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:192
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:191
void SetEnd(const wxPoint &aEnd)
Definition: pcb_track.h:104
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
static constexpr double IU_PER_MM
Mock up a conversion function.
virtual double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
Definition: pcb_track.cpp:286
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:353
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class PAD, a pad in a footprint
Definition: typeinfo.h:89
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Compute the intersection point of lines passing through ends of (this) and aSeg.
Definition: seg.h:209
virtual void SetLocked(bool aLocked)
Modify the 'lock' status for of the item.
Definition: board_item.h:252
int GetWidth() const
Definition: pcb_track.h:102
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
virtual bool IsLocked() const
Definition: board_item.cpp:78
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
CIRCLE & ConstructFromTanTanPt(const SEG &aLineA, const SEG &aLineB, const VECTOR2I &aP)
Construct this circle such that it is tangent to the given segments and passes through the given poin...
Definition: circle.cpp:51
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
bool IsNew() const
Definition: eda_item.h:119
PCB_BASE_EDIT_FRAME * frame() const
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
Definition: seg.cpp:268
const PCB_SELECTION & selection() const
const VECTOR2I GetArcMid(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aMinArcAngle=true)
Return the middle point of an arc, half-way between aStart and aEnd.
Definition: trigo.cpp:163
void SetMid(const wxPoint &aMid)
Definition: pcb_track.h:272
Generic, UI-independent tool event.
Definition: tool_event.h:152
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:344
void SetStart(const wxPoint &aStart)
Definition: pcb_track.h:107
An interface for classes handling user events controlling the view behavior such as zooming,...
#define _(s)
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
int Radius
Public to make access simpler.
Definition: circle.h:115
Represent basic circle geometry with utility geometry functions.
Definition: circle.h:32
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
Definition: seg.h:40
void SetWidth(int aWidth)
Definition: pcb_track.h:101
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: pcb_track.cpp:940
double GetAngle() const
Definition: pcb_track.cpp:974
void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
double m_MaxTangentAngleDeviation
Maximum angle between the tangent line of an arc track and a connected straight track in order to com...
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I A
Definition: seg.h:48
VECTOR2I Center
Public to make access simpler.
Definition: circle.h:116
int Size() const
Returns the number of selected parts.
Definition: selection.h:103
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
void Activate()
Run the tool.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
static TOOL_ACTION undo
Definition: actions.h:64
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:323
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:166
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:171
const wxPoint & GetMid() const
Definition: pcb_track.h:273
const wxPoint & GetStart() const
Definition: pcb_track.h:108
EDA_ITEM * Front() const
Definition: selection.h:144
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1518
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute the point on the circumference of the circle that is the closest to aP.
Definition: circle.cpp:197
VECTOR2I B
Definition: seg.h:49

References _, SEG::A, TOOL_INTERACTIVE::Activate(), KIGFX::VIEW::Add(), SEG::B, PCB_TOOL_BASE::board(), BUT_LEFT, CIRCLE::Center, CIRCLE::ConstructFromTanTanPt(), PCB_TOOL_BASE::controls(), ACTIONS::CURSOR_CLICK, EOT, EuclideanNorm(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), Format(), PCB_TOOL_BASE::frame(), SELECTION::Front(), PCB_ARC::GetAngle(), GetArcMid(), PCB_ARC::GetCenter(), ADVANCED_CFG::GetCfg(), BOARD::GetConnectivity(), PCB_TRACK::GetEnd(), BOARD_ITEM::GetLayer(), PCB_TRACK::GetLength(), GetLineLength(), PCB_ARC::GetMid(), KIGFX::VIEW_CONTROLS::GetMousePosition(), BOARD_CONNECTED_ITEM::GetNet(), BOARD_ITEM::GetParent(), PCB_SELECTION_TOOL::GetSelection(), PCB_TRACK::GetStart(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), PCB_TRACK::GetWidth(), SEG::IntersectLines(), IS_NEW, BOARD_ITEM::IsLocked(), EDA_ITEM::IsNew(), IU_PER_MM, KiROUND(), SEG::LineProject(), m_commit, m_cursor, ADVANCED_CFG::m_MaxTangentAngleDeviation, m_selectionTool, CIRCLE::NearestPoint(), SEG::NearestPoint(), PCB_ARC_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, CIRCLE::Radius, KIGFX::VIEW::Remove(), PCB_TOOL_BASE::selection(), KIGFX::VIEW_CONTROLS::SetAutoPan(), PCB_TRACK::SetEnd(), EDA_ITEM::SetFlags(), BOARD_ITEM::SetLayer(), BOARD_ITEM::SetLocked(), PCB_ARC::SetMid(), BOARD_CONNECTED_ITEM::SetNet(), PCB_TRACK::SetStart(), PCB_TRACK::SetWidth(), KIGFX::VIEW_CONTROLS::ShowCursor(), EDA_BASE_FRAME::ShowInfoBarError(), SEG::Side(), SELECTION::Size(), PCB_TRACK::SwapData(), EDA_ITEM::Type(), ACTIONS::undo, KIGFX::VIEW::Update(), and TOOL_INTERACTIVE::Wait().

Referenced by Drag().

◆ Duplicate()

int EDIT_TOOL::Duplicate ( const TOOL_EVENT aEvent)

Duplicate the current selection and starts a move action.

Definition at line 2102 of file edit_tool.cpp.

2103 {
2104  if( isRouterActive() )
2105  {
2106  wxBell();
2107  return 0;
2108  }
2109 
2110  bool increment = aEvent.IsAction( &PCB_ACTIONS::duplicateIncrement );
2111 
2112  // Be sure that there is at least one item that we can modify
2114  []( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
2115  {
2116  // Iterate from the back so we don't have to worry about removals.
2117  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
2118  {
2119  BOARD_ITEM* item = aCollector[i];
2120 
2121  if( item->Type() == PCB_MARKER_T )
2122  aCollector.Remove( item );
2123  }
2124 
2125  sTool->FilterCollectorForHierarchy( aCollector, true );
2126  } );
2127 
2128  if( selection.Empty() )
2129  return 0;
2130 
2131  // we have a selection to work on now, so start the tool process
2132  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
2133 
2134  // If the selection was given a hover, we do not keep the selection after completion
2135  bool is_hover = selection.IsHover();
2136 
2137  std::vector<BOARD_ITEM*> new_items;
2138  new_items.reserve( selection.Size() );
2139 
2140  // Each selected item is duplicated and pushed to new_items list
2141  // Old selection is cleared, and new items are then selected.
2142  for( EDA_ITEM* item : selection )
2143  {
2144  BOARD_ITEM* dupe_item = nullptr;
2145  BOARD_ITEM* orig_item = static_cast<BOARD_ITEM*>( item );
2146 
2147  if( m_isFootprintEditor )
2148  {
2149  FOOTPRINT* parentFootprint = editFrame->GetBoard()->GetFirstFootprint();
2150  dupe_item = parentFootprint->DuplicateItem( orig_item );
2151 
2152  if( increment && dupe_item->Type() == PCB_PAD_T
2153  && static_cast<PAD*>( dupe_item )->CanHaveNumber() )
2154  {
2155  PAD_TOOL* padTool = m_toolMgr->GetTool<PAD_TOOL>();
2156  wxString padNumber = padTool->GetLastPadNumber();
2157  padNumber = parentFootprint->GetNextPadNumber( padNumber );
2158  padTool->SetLastPadNumber( padNumber );
2159  static_cast<PAD*>( dupe_item )->SetNumber( padNumber );
2160  }
2161  }
2162  else if( orig_item->GetParent() && orig_item->GetParent()->Type() == PCB_FOOTPRINT_T )
2163  {
2164  FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( orig_item->GetParent() );
2165 
2166  m_commit->Modify( parentFootprint );
2167  dupe_item = parentFootprint->DuplicateItem( orig_item, true /* add to parent */ );
2168  }
2169  else
2170  {
2171  switch( orig_item->Type() )
2172  {
2173  case PCB_FOOTPRINT_T:
2174  case PCB_TEXT_T:
2175  case PCB_SHAPE_T:
2176  case PCB_TRACE_T:
2177  case PCB_ARC_T:
2178  case PCB_VIA_T:
2179  case PCB_ZONE_T:
2180  case PCB_TARGET_T:
2181  case PCB_DIM_ALIGNED_T:
2182  case PCB_DIM_CENTER_T:
2183  case PCB_DIM_ORTHOGONAL_T:
2184  case PCB_DIM_LEADER_T:
2185  dupe_item = orig_item->Duplicate();
2186  break;
2187 
2188  case PCB_GROUP_T:
2189  dupe_item = static_cast<PCB_GROUP*>( orig_item )->DeepDuplicate();
2190  break;
2191 
2192  default:
2193  wxASSERT_MSG( false, wxString::Format( "Unhandled item type %d",
2194  orig_item->Type() ) );
2195  break;
2196  }
2197  }
2198 
2199  if( dupe_item )
2200  {
2201  if( dupe_item->Type() == PCB_GROUP_T )
2202  {
2203  static_cast<PCB_GROUP*>( dupe_item )->RunOnDescendants(
2204  [&]( BOARD_ITEM* bItem )
2205  {
2206  m_commit->Add( bItem );
2207  });
2208  }
2209 
2210  // Clear the selection flag here, otherwise the PCB_SELECTION_TOOL
2211  // will not properly select it later on
2212  dupe_item->ClearSelected();
2213 
2214  new_items.push_back( dupe_item );
2215  m_commit->Add( dupe_item );
2216  }
2217  }
2218 
2219  // Clear the old selection first
2221 
2222  // Select the new items
2223  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &new_items );
2224 
2225  // record the new items as added
2226  if( !selection.Empty() )
2227  {
2228  editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ),
2229  (int) new_items.size() ) );
2230 
2231  // TODO(ISM): This line can't be used to activate the tool until we allow multiple
2232  // activations.
2233  // m_toolMgr->RunAction( PCB_ACTIONS::move, true );
2234  // Instead we have to create the event and call the tool's function
2235  // directly
2236 
2237  // If items were duplicated, pick them up
2238  // this works well for "dropping" copies around and pushes the commit
2240  Move( evt );
2241 
2242  // Deslect the duplicated item if we originally started as a hover selection
2243  if( is_hover )
2245  }
2246 
2247  return 0;
2248 }
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Definition: pcb_actions.h:66
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
BOARD_ITEM * DuplicateItem(const BOARD_ITEM *aItem, bool aAddToFootprint=false)
Duplicate a given item within the footprint, optionally adding it to the board.
Definition: footprint.cpp:1676
void SetLastPadNumber(const wxString &aPadNumber)
Definition: pad_tool.h:63
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:100
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:101
bool IsHover() const
Definition: selection.h:73
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:191
void ClearSelected()
Definition: eda_item.h:132
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:102
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
Tool relating to pads and pad settings.
Definition: pad_tool.h:35
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class PAD, a pad in a footprint
Definition: typeinfo.h:89
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
Definition: pcb_actions.h:123
const PCB_SELECTION & selection() const
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:317
Generic, UI-independent tool event.
Definition: tool_event.h:152
wxString GetLastPadNumber() const
Definition: pad_tool.h:62
#define _(s)
class ZONE, a copper pour area
Definition: typeinfo.h:105
wxString GetNextPadNumber(const wxString &aLastPadName) const
Return the next available pad number in the footprint.
Definition: footprint.cpp:1761
bool m_isFootprintEditor
int Move(const TOOL_EVENT &aEvent)
Main loop in which events are handled.
Definition: edit_tool.cpp:679
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:104
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void FilterCollectorForHierarchy(GENERAL_COLLECTOR &aCollector, bool aMultiselect) const
In general we don't want to select both a parent and any of it's children.
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:98
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
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
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Definition: tool_action.cpp:72
int Size() const
Returns the number of selected parts.
Definition: selection.h:103
bool isRouterActive() const
Definition: edit_tool.cpp:273
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
Definition: board_item.h:200
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:103
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
BOARD * GetBoard() const
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:166
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
void DisplayToolMsg(const wxString &msg) override
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References _, EDA_ITEM::ClearSelected(), EDA_DRAW_FRAME::DisplayToolMsg(), BOARD_ITEM::Duplicate(), PCB_ACTIONS::duplicateIncrement, FOOTPRINT::DuplicateItem(), SELECTION::Empty(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), Format(), PCB_BASE_FRAME::GetBoard(), COLLECTOR::GetCount(), BOARD::GetFirstFootprint(), PAD_TOOL::GetLastPadNumber(), FOOTPRINT::GetNextPadNumber(), BOARD_ITEM::GetParent(), TOOL_MANAGER::GetTool(), TOOL_EVENT::IsAction(), SELECTION::IsHover(), isRouterActive(), m_commit, PCB_TOOL_BASE::m_isFootprintEditor, m_selectionTool, TOOL_BASE::m_toolMgr, TOOL_ACTION::MakeEvent(), Move(), PCB_ACTIONS::move, PCB_ARC_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_FOOTPRINT_T, PCB_GROUP_T, PCB_MARKER_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItems, PAD_TOOL::SetLastPadNumber(), SELECTION::Size(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ FilletTracks()

int EDIT_TOOL::FilletTracks ( const TOOL_EVENT aEvent)

Fillet (i.e.

adds an arc tangent to) all selected straight tracks by a user defined radius.

Definition at line 1208 of file edit_tool.cpp.

1209 {
1210  // Store last used fillet radius to allow pressing "enter" if repeat fillet is required
1211  static long long filletRadiusIU = 0;
1212 
1214  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1215  {
1216  // Iterate from the back so we don't have to worry about removals.
1217  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
1218  {
1219  BOARD_ITEM* item = aCollector[i];
1220 
1221  if( !dynamic_cast<PCB_TRACK*>( item ) )
1222  aCollector.Remove( item );
1223  }
1224  },
1225  true /* prompt user regarding locked items */ );
1226 
1227  if( selection.Size() < 2 )
1228  {
1229  frame()->ShowInfoBarMsg( _( "At least two straight track segments must be selected." ) );
1230  return 0;
1231  }
1232 
1233  WX_UNIT_ENTRY_DIALOG dia( frame(), _( "Enter fillet radius:" ), _( "Fillet Tracks" ),
1234  filletRadiusIU );
1235 
1236  if( dia.ShowModal() == wxID_CANCEL )
1237  return 0;
1238 
1239  filletRadiusIU = dia.GetValue();
1240 
1241  if( filletRadiusIU == 0 )
1242  {
1243  frame()->ShowInfoBarMsg( _( "A radius of zero was entered.\n"
1244  "The fillet operation was not performed." ) );
1245  return 0;
1246  }
1247 
1248  struct FILLET_OP
1249  {
1250  PCB_TRACK* t1;
1251  PCB_TRACK* t2;
1252  // Start point of track is modified after PCB_ARC is added, otherwise the end point:
1253  bool t1Start = true;
1254  bool t2Start = true;
1255  };
1256 
1257  std::vector<FILLET_OP> filletOperations;
1258  KICAD_T track_types[] = { PCB_PAD_T, PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, EOT };
1259  bool operationPerformedOnAtLeastOne = false;
1260  bool didOneAttemptFail = false;
1261  std::set<PCB_TRACK*> processedTracks;
1262 
1263  for( auto it = selection.begin(); it != selection.end(); it++ )
1264  {
1265  PCB_TRACK* track = dyn_cast<PCB_TRACK*>( *it );
1266 
1267  if( !track || track->Type() != PCB_TRACE_T || track->GetLength() == 0 )
1268  {
1269  continue;
1270  }
1271 
1272  auto processFilletOp =
1273  [&]( bool aStartPoint )
1274  {
1275  wxPoint anchor = ( aStartPoint ) ? track->GetStart() : track->GetEnd();
1276  auto connectivity = board()->GetConnectivity();
1277  auto itemsOnAnchor = connectivity->GetConnectedItemsAtAnchor( track, anchor,
1278  track_types );
1279 
1280  if( itemsOnAnchor.size() > 0
1281  && selection.Contains( itemsOnAnchor.at( 0 ) )
1282  && itemsOnAnchor.at( 0 )->Type() == PCB_TRACE_T )
1283  {
1284  PCB_TRACK* trackOther = dyn_cast<PCB_TRACK*>( itemsOnAnchor.at( 0 ) );
1285 
1286  // Make sure we don't fillet the same pair of tracks twice
1287  if( processedTracks.find( trackOther ) == processedTracks.end() )
1288  {
1289  if( itemsOnAnchor.size() == 1 )
1290  {
1291  FILLET_OP filletOp;
1292  filletOp.t1 = track;
1293  filletOp.t2 = trackOther;
1294  filletOp.t1Start = aStartPoint;
1295  filletOp.t2Start = track->IsPointOnEnds( filletOp.t2->GetStart() );
1296  filletOperations.push_back( filletOp );
1297  }
1298  else
1299  {
1300  // User requested to fillet these two tracks but not possible as
1301  // there are other elements connected at that point
1302  didOneAttemptFail = true;
1303  }
1304  }
1305  }
1306  };
1307 
1308  processFilletOp( true ); // on the start point of track
1309  processFilletOp( false ); // on the end point of track
1310 
1311  processedTracks.insert( track );
1312  }
1313 
1314  std::vector<BOARD_ITEM*> itemsToAddToSelection;
1315 
1316  for( FILLET_OP filletOp : filletOperations )
1317  {
1318  PCB_TRACK* track1 = filletOp.t1;
1319  PCB_TRACK* track2 = filletOp.t2;
1320 
1321  bool trackOnStart = track1->IsPointOnEnds( track2->GetStart() );
1322  bool trackOnEnd = track1->IsPointOnEnds( track2->GetEnd() );
1323 
1324  if( trackOnStart && trackOnEnd )
1325  continue; // Ignore duplicate tracks
1326 
1327  if( ( trackOnStart || trackOnEnd ) && track1->GetLayer() == track2->GetLayer() )
1328  {
1329  SEG t1Seg( track1->GetStart(), track1->GetEnd() );
1330  SEG t2Seg( track2->GetStart(), track2->GetEnd() );
1331 
1332  if( t1Seg.ApproxCollinear( t2Seg ) )
1333  continue;
1334 
1335  SHAPE_ARC sArc( t1Seg, t2Seg, filletRadiusIU );
1336 
1337  wxPoint t1newPoint, t2newPoint;
1338 
1339  auto setIfPointOnSeg =
1340  []( wxPoint& aPointToSet, SEG aSegment, VECTOR2I aVecToTest )
1341  {
1342  VECTOR2I segToVec = aSegment.NearestPoint( aVecToTest ) - aVecToTest;
1343 
1344  // Find out if we are on the segment (minimum precision)
1345  if( segToVec.EuclideanNorm() < SHAPE_ARC::MIN_PRECISION_IU )
1346  {
1347  aPointToSet.x = aVecToTest.x;
1348  aPointToSet.y = aVecToTest.y;
1349  return true;
1350  }
1351 
1352  return false;
1353  };
1354 
1355  //Do not draw a fillet if the end points of the arc are not within the track segments
1356  if( !setIfPointOnSeg( t1newPoint, t1Seg, sArc.GetP0() )
1357  && !setIfPointOnSeg( t2newPoint, t2Seg, sArc.GetP0() ) )
1358  {
1359  didOneAttemptFail = true;
1360  continue;
1361  }
1362 
1363  if( !setIfPointOnSeg( t1newPoint, t1Seg, sArc.GetP1() )
1364  && !setIfPointOnSeg( t2newPoint, t2Seg, sArc.GetP1() ) )
1365  {
1366  didOneAttemptFail = true;
1367  continue;
1368  }
1369 
1370  PCB_ARC* tArc = new PCB_ARC( frame()->GetBoard(), &sArc );
1371  tArc->SetLayer( track1->GetLayer() );
1372  tArc->SetWidth( track1->GetWidth() );
1373  tArc->SetNet( track1->GetNet() );
1374  tArc->SetLocked( track1->IsLocked() );
1375  m_commit->Add( tArc );
1376  itemsToAddToSelection.push_back( tArc );
1377 
1378  m_commit->Modify( track1 );
1379  m_commit->Modify( track2 );
1380 
1381  if( filletOp.t1Start )
1382  track1->SetStart( t1newPoint );
1383  else
1384  track1->SetEnd( t1newPoint );
1385 
1386  if( filletOp.t2Start )
1387  track2->SetStart( t2newPoint );
1388  else
1389  track2->SetEnd( t2newPoint );
1390 
1391  operationPerformedOnAtLeastOne = true;
1392  }
1393  }
1394 
1395  m_commit->Push( _( "Fillet Tracks" ) );
1396 
1397  //select the newly created arcs
1398  for( BOARD_ITEM* item : itemsToAddToSelection )
1399  m_selectionTool->AddItemToSel( item );
1400 
1401  if( !operationPerformedOnAtLeastOne )
1402  frame()->ShowInfoBarMsg( _( "Unable to fillet the selected track segments." ) );
1403  else if( didOneAttemptFail )
1404  frame()->ShowInfoBarMsg( _( "Some of the track segments could not be filleted." ) );
1405 
1406  return 0;
1407 }
BOARD * board() const
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:192
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:191
void SetEnd(const wxPoint &aEnd)
Definition: pcb_track.h:104
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
virtual double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
Definition: pcb_track.cpp:286
ITER end()
Definition: selection.h:64
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class PAD, a pad in a footprint
Definition: typeinfo.h:89
virtual void SetLocked(bool aLocked)
Modify the 'lock' status for of the item.
Definition: board_item.h:252
int GetWidth() const
Definition: pcb_track.h:102
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
virtual bool IsLocked() const
Definition: board_item.cpp:78
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PCB_BASE_EDIT_FRAME * frame() const
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
ITER begin()
Definition: selection.h:63
const PCB_SELECTION & selection() const
An extension of WX_TEXT_ENTRY_DIALOG that uses UNIT_BINDER to request a dimension (e....
void AddItemToSel(BOARD_ITEM *aItem, bool aQuietMode=false)
Select all items on the board.
static const int MIN_PRECISION_IU
This is the minimum precision for all the points in a shape.
Definition: shape.h:122
bool Contains(EDA_ITEM *aItem) const
Definition: selection.cpp:61
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:344
void SetStart(const wxPoint &aStart)
Definition: pcb_track.h:107
#define _(s)
BOARD * GetBoard()
Definition: seg.h:40
void SetWidth(int aWidth)
Definition: pcb_track.h:101
void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
EDA_ITEM_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
Definition: pcb_track.cpp:208
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:103
The selection tool: currently supports:
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition: vector2d.h:293
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:171
const wxPoint & GetStart() const
Definition: pcb_track.h:108
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References _, PCB_SELECTION_TOOL::AddItemToSel(), anchor, SELECTION::begin(), PCB_TOOL_BASE::board(), SELECTION::Contains(), SELECTION::end(), EOT, VECTOR2< T >::EuclideanNorm(), PCB_TOOL_BASE::frame(), GetBoard(), BOARD::GetConnectivity(), COLLECTOR::GetCount(), PCB_TRACK::GetEnd(), BOARD_ITEM::GetLayer(), PCB_TRACK::GetLength(), BOARD_CONNECTED_ITEM::GetNet(), SHAPE_ARC::GetP0(), SHAPE_ARC::GetP1(), PCB_TRACK::GetStart(), WX_UNIT_ENTRY_DIALOG::GetValue(), PCB_TRACK::GetWidth(), BOARD_ITEM::IsLocked(), PCB_TRACK::IsPointOnEnds(), m_commit, m_selectionTool, SHAPE::MIN_PRECISION_IU, PCB_ARC_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), PCB_TOOL_BASE::selection(), PCB_TRACK::SetEnd(), BOARD_ITEM::SetLayer(), BOARD_ITEM::SetLocked(), BOARD_CONNECTED_ITEM::SetNet(), PCB_TRACK::SetStart(), PCB_TRACK::SetWidth(), EDA_BASE_FRAME::ShowInfoBarMsg(), SELECTION::Size(), EDA_ITEM::Type(), and VECTOR2< T >::x.

Referenced by setTransitions().

◆ Flip()

int EDIT_TOOL::Flip ( const TOOL_EVENT aEvent)

Rotate currently selected items.

The rotation point is the current cursor position.

Definition at line 1672 of file edit_tool.cpp.

1673 {
1674  if( isRouterActive() )
1675  {
1676  wxBell();
1677  return 0;
1678  }
1679 
1681  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1682  {
1683  sTool->FilterCollectorForHierarchy( aCollector, true );
1684  },
1685  !m_dragging /* prompt user regarding locked items */ );
1686 
1687  if( selection.Empty() )
1688  return 0;
1689 
1690  OPT<VECTOR2I> oldRefPt = boost::make_optional<VECTOR2I>( false, VECTOR2I( 0, 0 ) );
1691 
1693  oldRefPt = selection.GetReferencePoint();
1694 
1696 
1697  // Flip around the anchor for footprints, and the bounding box center for board items
1698  VECTOR2I refPt = IsFootprintEditor() ? VECTOR2I( 0, 0 ) : selection.GetCenter();
1699 
1700  // If only one item selected, flip around the selection or item anchor point (instead
1701  // of the bounding box center) to avoid moving the item anchor
1702  if( selection.GetSize() == 1 )
1703  {
1705  refPt = selection.GetReferencePoint();
1706  else
1707  refPt = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) )->GetPosition();
1708  }
1709 
1710  bool leftRight = frame()->Settings().m_FlipLeftRight;
1711 
1712  // When editing footprints, all items have the same parent
1713  if( IsFootprintEditor() )
1714  m_commit->Modify( selection.Front() );
1715 
1716  for( EDA_ITEM* item : selection )
1717  {
1718  if( !item->IsNew() && !IsFootprintEditor() )
1719  m_commit->Modify( item );
1720 
1721  if( item->Type() == PCB_GROUP_T )
1722  {
1723  static_cast<PCB_GROUP*>( item )->RunOnDescendants( [&]( BOARD_ITEM* bItem )
1724  {
1725  m_commit->Modify( bItem );
1726  });
1727  }
1728 
1729  static_cast<BOARD_ITEM*>( item )->Flip( refPt, leftRight );
1730  }
1731 
1732  if( !m_dragging )
1733  m_commit->Push( _( "Change Side / Flip" ) );
1734 
1735  if( selection.IsHover() && !m_dragging )
1737 
1739 
1740  if( m_dragging )
1742 
1743  // Restore the old reference so any mouse dragging that occurs doesn't make the selection jump
1744  // to this now invalid reference
1745  if( oldRefPt )
1746  selection.SetReferencePoint( *oldRefPt );
1747  else
1749 
1750  return 0;
1751 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
VECTOR2I GetReferencePoint() const
Definition: selection.h:181
void ClearReferencePoint()
Definition: selection.h:191
bool IsHover() const
Definition: selection.h:73
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:191
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:204
PCB_BASE_EDIT_FRAME * frame() const
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:186
const PCB_SELECTION & selection() const
bool updateModificationPoint(PCB_SELECTION &aSelection)
Definition: edit_tool.cpp:2304
bool m_dragging
Definition: edit_tool.h:192
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
#define _(s)
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:87
void FilterCollectorForHierarchy(GENERAL_COLLECTOR &aCollector, bool aMultiselect) const
In general we don't want to select both a parent and any of it's children.
bool HasReferencePoint() const
Definition: selection.h:176
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:52
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
PCBNEW_SETTINGS & Settings()
bool isRouterActive() const
Definition: edit_tool.cpp:273
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
bool IsFootprintEditor() const
boost::optional< T > OPT
Definition: optional.h:7
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:460
EDA_ITEM * Front() const
Definition: selection.h:144

References _, SELECTION::ClearReferencePoint(), SELECTION::Empty(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), PCB_TOOL_BASE::frame(), SELECTION::Front(), SELECTION::GetCenter(), SELECTION::GetItem(), SELECTION::GetReferencePoint(), SELECTION::GetSize(), SELECTION::HasReferencePoint(), PCB_TOOL_BASE::IsFootprintEditor(), SELECTION::IsHover(), isRouterActive(), m_commit, m_dragging, PCBNEW_SETTINGS::m_FlipLeftRight, m_selectionTool, TOOL_BASE::m_toolMgr, PCB_GROUP_T, TOOL_MANAGER::ProcessEvent(), PCB_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, SELECTION::SetReferencePoint(), PCB_BASE_FRAME::Settings(), PCB_ACTIONS::updateLocalRatsnest, and updateModificationPoint().

Referenced by setTransitions().

◆ footprint()

◆ FootprintFilter()

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

A selection filter which prunes the selection to contain only items of type #PCB_MODULE_T.

Definition at line 2291 of file edit_tool.cpp.

2293 {
2294  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
2295  {
2296  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
2297 
2298  if( item->Type() != PCB_FOOTPRINT_T )
2299  aCollector.Remove( i );
2300  }
2301 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

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

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

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 160 of file pcb_tool_base.h.

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

Referenced by PCB_POINT_EDITOR::addCorner(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), copyToClipboard(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), ROUTER_TOOL::CustomTrackWidthDialog(), FOOTPRINT_EDITOR_CONTROL::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), doMoveSelection(), ROUTER_TOOL::DpDimensionsDialog(), DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), BOARD_EDITOR_CONTROL::ExportSpecctraDSN(), ZONE_FILLER_TOOL::FillAllZones(), FilletTracks(), ROUTER_TOOL::finishInteractive(), Flip(), PCB_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), ROUTER_TOOL::handleLayerSwitch(), BOARD_INSPECTION_TOOL::HighlightItem(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), BOARD_EDITOR_CONTROL::ImportSpecctraSession(), ROUTER_TOOL::Init(), SCRIPTING_TOOL::Init(), PCB_SELECTION_TOOL::Init(), Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_TOOL_BASE::Is45Limited(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), PCB_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), PAD_TOOL::recombinePad(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), SCRIPTING_TOOL::reloadPlugins(), Remove(), PCB_POINT_EDITOR::removeCorner(), PCB_SELECTION_TOOL::RequestSelection(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_POINT_EDITOR::setEditedPoint(), ROUTER_TOOL::SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), ROUTER_TOOL::switchLayerOnViaPlacement(), PCB_CONTROL::unfilledZoneCheck(), ROUTER_TOOL::updateMessagePanel(), updateModificationPoint(), BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ GetAndPlace()

int EDIT_TOOL::GetAndPlace ( const TOOL_EVENT aEvent)

Definition at line 212 of file edit_tool.cpp.

213 {
214  // GetAndPlace makes sense only in board editor, although it is also called
215  // in fpeditor, that shares the same EDIT_TOOL list
216  if( !getEditFrame<PCB_BASE_FRAME>()->IsType( FRAME_PCB_EDITOR ) )
217  return 0;
218 
220  FOOTPRINT* fp = getEditFrame<PCB_BASE_FRAME>()->GetFootprintFromBoardByReference();
221 
222  if( fp )
223  {
225  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, (void*) fp );
226 
227  selectionTool->GetSelection().SetReferencePoint( fp->GetPosition() );
229  }
230 
231  return 0;
232 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:186
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition: pcb_actions.h:62
The selection tool: currently supports:

References FRAME_PCB_EDITOR, PCB_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, 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 158 of file edit_tool.h.

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

References m_commit.

◆ getEditFrame()

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

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

Definition at line 184 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 120 of file tool_base.h.

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

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 143 of file tool_base.h.

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

References TOOL_BASE::m_toolMgr.

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

◆ getModel()

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

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 196 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Return the name of the tool.

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

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

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

References TOOL_BASE::m_toolName.

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

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 108 of file tool_base.h.

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

References TOOL_BASE::m_type.

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

◆ getView()

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

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

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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

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

◆ getViewControls()

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

Return the instance of VIEW_CONTROLS object used in the application.

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

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

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

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

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

◆ Go()

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

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

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

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

References TOOL_INTERACTIVE::goInternal().

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

◆ Init()

bool EDIT_TOOL::Init ( void  )
overridevirtual

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

Returns
True if the initialization went fine, false - otherwise. Find an item and start moving.

Reimplemented from PCB_TOOL_BASE.

Definition at line 100 of file edit_tool.cpp.

101 {
102  // Find the selection tool, so they can cooperate
104 
105  auto propertiesCondition =
106  [&]( const SELECTION& aSel )
107  {
108  if( aSel.GetSize() == 0 )
109  {
111  {
114 
115  if( ds && ds->HitTestDrawingSheetItems( getView(), (wxPoint) cursor ) )
116  return true;
117  }
118 
119  return false;
120  }
121 
122  if( aSel.GetSize() == 1 )
123  return true;
124 
125  for( EDA_ITEM* item : aSel )
126  {
127  if( !dynamic_cast<PCB_TRACK*>( item ) )
128  return false;
129  }
130 
131  return true;
132  };
133 
134  auto inFootprintEditor =
135  [ this ]( const SELECTION& aSelection )
136  {
137  return m_isFootprintEditor;
138  };
139 
140  auto singleFootprintCondition = SELECTION_CONDITIONS::OnlyType( PCB_FOOTPRINT_T )
142 
143  auto noActiveToolCondition =
144  [ this ]( const SELECTION& aSelection )
145  {
146  return frame()->ToolStackIsEmpty();
147  };
148 
149  auto notMovingCondition =
150  [ this ]( const SELECTION& aSelection )
151  {
154  };
155 
156  auto noItemsCondition =
157  [ this ]( const SELECTION& aSelections ) -> bool
158  {
159  return frame()->GetBoard() && !frame()->GetBoard()->IsEmpty();
160  };
161 
162  // Add context menu entries that are displayed when selection tool is active
164 
166  && notMovingCondition );
178  menu.AddItem( PCB_ACTIONS::mirror, inFootprintEditor && SELECTION_CONDITIONS::NotEmpty );
179 
180  menu.AddItem( PCB_ACTIONS::properties, propertiesCondition );
181 
182  // Footprint actions
183  menu.AddSeparator();
184  menu.AddItem( PCB_ACTIONS::editFpInFpEditor, singleFootprintCondition );
185  menu.AddItem( PCB_ACTIONS::updateFootprint, singleFootprintCondition );
186  menu.AddItem( PCB_ACTIONS::changeFootprint, singleFootprintCondition );
187 
188  // Add the submenu for create array and special move
189  auto specialToolsSubMenu = std::make_shared<SPECIAL_TOOLS_CONTEXT_MENU>( this );
190  menu.AddSeparator();
191  m_selectionTool->GetToolMenu().AddSubMenu( specialToolsSubMenu );
192  menu.AddMenu( specialToolsSubMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
193 
194  menu.AddSeparator( 150 );
197 
198  // Selection tool handles the context menu for some other tools, such as the Picker.
199  // Don't add things like Paste when another tool is active.
200  menu.AddItem( ACTIONS::paste, noActiveToolCondition, 150 );
201  menu.AddItem( ACTIONS::pasteSpecial, noActiveToolCondition && !inFootprintEditor, 150 );
204 
205  menu.AddSeparator( 150 );
206  menu.AddItem( ACTIONS::selectAll, noItemsCondition, 150 );
207 
208  return true;
209 }
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Add a submenu to the menu.
bool IsCurrentTool(const TOOL_ACTION &aAction) const
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
static const KICAD_T Tracks[]
A scan list for only TRACKs.
Definition: collectors.h:298
static TOOL_ACTION editFpInFpEditor
Definition: pcb_actions.h:344
static TOOL_ACTION doDelete
Definition: actions.h:72
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create a functor that tests if the selected items are only of given types.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:138
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:117
TOOL_MENU & GetToolMenu()
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:137
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:108
static TOOL_ACTION changeFootprint
Definition: pcb_actions.h:324
bool HitTestDrawingSheetItems(KIGFX::VIEW *aView, const wxPoint &aPosition)
static TOOL_ACTION updateFootprint
Definition: pcb_actions.h:322
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
static TOOL_ACTION filletTracks
Fillet (i.e. adds an arc tangent to) all selected straight tracks by a user defined radius.
Definition: pcb_actions.h:114
PCB_BASE_EDIT_FRAME * frame() const
static TOOL_ACTION copy
Definition: actions.h:67
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:101
static TOOL_ACTION cut
Definition: actions.h:66
bool ToolStackIsEmpty()
Definition: tools_holder.h:116
bool m_isFootprintEditor
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
static TOOL_ACTION inlineBreakTrack
Breaks track when router is not activated.
Definition: pcb_actions.h:135
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
static TOOL_ACTION pasteSpecial
Definition: actions.h:69
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:102
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:105
static const KICAD_T DraggableItems[]
A scan list for items that can be dragged.
Definition: collectors.h:313
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:52
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
BOARD * GetBoard() const
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
static TOOL_ACTION moveWithReference
move with a reference point
Definition: pcb_actions.h:95
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
static TOOL_ACTION selectAll
Definition: actions.h:70
bool IsEmpty() const
Definition: board.h:281
static TOOL_ACTION paste
Definition: actions.h:68
static TOOL_ACTION duplicate
Definition: actions.h:71
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:405

References CONDITIONAL_MENU::AddItem(), CONDITIONAL_MENU::AddMenu(), CONDITIONAL_MENU::AddSeparator(), TOOL_MENU::AddSubMenu(), PCB_ACTIONS::changeFootprint, ACTIONS::copy, SELECTION_CONDITIONS::Count(), cursor, ACTIONS::cut, ACTIONS::doDelete, PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, GENERAL_COLLECTOR::DraggableItems, ACTIONS::duplicate, PCB_ACTIONS::editFpInFpEditor, PCB_ACTIONS::filletTracks, PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_DRAW_PANEL_GAL::GetDrawingSheet(), TOOL_MENU::GetMenu(), TOOL_MANAGER::GetTool(), TOOL_INTERACTIVE::GetToolMenu(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), DS_PROXY_VIEW_ITEM::HitTestDrawingSheetItems(), PCB_ACTIONS::inlineBreakTrack, TOOLS_HOLDER::IsCurrentTool(), BOARD::IsEmpty(), KIGFX::VIEW::IsLayerVisible(), LAYER_SCHEMATIC_DRAWINGSHEET, PCB_TOOL_BASE::m_isFootprintEditor, m_selectionTool, TOOL_BASE::m_toolMgr, PCB_ACTIONS::mirror, PCB_ACTIONS::move, PCB_ACTIONS::moveWithReference, SELECTION_CONDITIONS::NotEmpty(), SELECTION_CONDITIONS::OnlyType(), SELECTION_CONDITIONS::OnlyTypes(), ACTIONS::paste, ACTIONS::pasteSpecial, PCB_FOOTPRINT_T, PCB_ACTIONS::properties, PCB_ACTIONS::rotateCcw, PCB_ACTIONS::rotateCw, ACTIONS::selectAll, TOOLS_HOLDER::ToolStackIsEmpty(), GENERAL_COLLECTOR::Tracks, and PCB_ACTIONS::updateFootprint.

◆ invokeInlineRouter()

bool EDIT_TOOL::invokeInlineRouter ( int  aDragMode)
private

Definition at line 235 of file edit_tool.cpp.

236 {
238 
239  if( !theRouter )
240  return false;
241 
242  // don't allow switch from moving to dragging
243  if( m_dragging )
244  {
245  wxBell();
246  return false;
247  }
248 
249  // make sure we don't accidentally invoke inline routing mode while the router is already
250  // active!
251  if( theRouter->IsToolActive() )
252  return false;
253 
254  if( theRouter->CanInlineDrag( aDragMode ) )
255  {
257  static_cast<intptr_t>( aDragMode ) );
258  return true;
259  }
260 
261  return false;
262 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
bool m_dragging
Definition: edit_tool.h:192
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:205
static ROUTER * theRouter
Definition: pns_router.cpp:58

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

Referenced by doMoveSelection(), and Drag().

◆ Is45Limited()

bool PCB_TOOL_BASE::Is45Limited ( ) const
inherited

Should the tool use its 45° mode option?

Returns
True if set to use 45°

Definition at line 329 of file pcb_tool_base.cpp.

330 {
331  return frame()->Settings().m_Use45DegreeLimit;
332 }
PCB_BASE_EDIT_FRAME * frame() const
PCBNEW_SETTINGS & Settings()

References PCB_TOOL_BASE::frame(), PCBNEW_SETTINGS::m_Use45DegreeLimit, and PCB_BASE_FRAME::Settings().

Referenced by doMoveSelection(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), and PCB_POINT_EDITOR::OnSelectionChange().

◆ IsFootprintEditor()

bool PCB_TOOL_BASE::IsFootprintEditor ( ) const
inlineinherited

◆ isInteractiveDragEnabled()

bool EDIT_TOOL::isInteractiveDragEnabled ( ) const
private

Definition at line 265 of file edit_tool.cpp.

266 {
268 
269  return router && router->Router()->Settings().InlineDragEnabled();
270 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
ROUTER * Router() const
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:181

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

Referenced by doMoveSelection().

◆ isRouterActive()

bool EDIT_TOOL::isRouterActive ( ) const
private

Definition at line 273 of file edit_tool.cpp.

274 {
276 
277  return router && router->IsToolActive();
278 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool IsToolActive() const
Definition: tool_base.cpp:31

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

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

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

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

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

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

◆ Mirror()

int EDIT_TOOL::Mirror ( const TOOL_EVENT aEvent)

Mirror the current selection.

The mirror axis passes through the current point.

Definition at line 1574 of file edit_tool.cpp.

1575 {
1576  if( isRouterActive() )
1577  {
1578  wxBell();
1579  return 0;
1580  }
1581 
1583  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1584  {
1585  sTool->FilterCollectorForHierarchy( aCollector, true );
1586  },
1587  !m_dragging /* prompt user regarding locked items */ );
1588 
1589  if( selection.Empty() )
1590  return 0;
1591 
1593  auto refPoint = selection.GetReferencePoint();
1594  wxPoint mirrorPoint( refPoint.x, refPoint.y );
1595 
1596  // When editing footprints, all items have the same parent
1597  if( IsFootprintEditor() )
1598  m_commit->Modify( selection.Front() );
1599 
1600  for( EDA_ITEM* item : selection )
1601  {
1602  // only modify items we can mirror
1603  switch( item->Type() )
1604  {
1605  case PCB_FP_SHAPE_T:
1606  case PCB_FP_TEXT_T:
1607  case PCB_FP_ZONE_T:
1608  case PCB_PAD_T:
1609  // Only create undo entry for items on the board
1610  if( !item->IsNew() && !IsFootprintEditor() )
1611  m_commit->Modify( item );
1612 
1613  break;
1614  default:
1615  continue;
1616  }
1617 
1618  // modify each object as necessary
1619  switch( item->Type() )
1620  {
1621  case PCB_FP_SHAPE_T:
1622  {
1623  FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
1624  shape->Mirror( mirrorPoint, false );
1625  break;
1626  }
1627 
1628  case PCB_FP_ZONE_T:
1629  {
1630  FP_ZONE* zone = static_cast<FP_ZONE*>( item );
1631  zone->Mirror( mirrorPoint, false );
1632  break;
1633  }
1634 
1635  case PCB_FP_TEXT_T:
1636  {
1637  FP_TEXT* text = static_cast<FP_TEXT*>( item );
1638  text->Mirror( mirrorPoint, false );
1639  break;
1640  }
1641 
1642  case PCB_PAD_T:
1643  {
1644  PAD* pad = static_cast<PAD*>( item );
1645  mirrorPadX( *pad, mirrorPoint );
1646  break;
1647  }
1648 
1649  default:
1650  // it's likely the commit object is wrong if you get here
1651  // Unsure if PCB_GROUP_T needs special attention here.
1652  assert( false );
1653  break;
1654  }
1655  }
1656 
1657  if( !m_dragging )
1658  m_commit->Push( _( "Mirror" ) );
1659 
1660  if( selection.IsHover() && !m_dragging )
1662 
1664 
1665  if( m_dragging )
1667 
1668  return 0;
1669 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
VECTOR2I GetReferencePoint() const
Definition: selection.h:181
bool IsHover() const
Definition: selection.h:73
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:191
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static void mirrorPadX(PAD &aPad, const wxPoint &aMirrorPoint)
Mirror a pad in the vertical axis passing through a point (mirror left to right).
Definition: edit_tool.cpp:1552
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
class PAD, a pad in a footprint
Definition: typeinfo.h:89
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:204
const PCB_SELECTION & selection() const
bool updateModificationPoint(PCB_SELECTION &aSelection)
Definition: edit_tool.cpp:2304
bool m_dragging
Definition: edit_tool.h:192
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
#define _(s)
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
void FilterCollectorForHierarchy(GENERAL_COLLECTOR &aCollector, bool aMultiselect) const
In general we don't want to select both a parent and any of it's children.
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
void Mirror(const wxPoint &aCentre, bool aMirrorAroundXAxis)
Mirror an edge of the footprint.
Definition: fp_shape.cpp:224
class ZONE, managed by a footprint
Definition: typeinfo.h:94
bool isRouterActive() const
Definition: edit_tool.cpp:273
void Mirror(const wxPoint &aMirrorRef, bool aMirrorLeftRight)
Mirror the outlines relative to a given horizontal axis the layer is not changed.
Definition: zone.cpp:745
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
bool IsFootprintEditor() const
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:460
Definition: pad.h:57
A specialization of ZONE for use in footprints.
Definition: zone.h:946
EDA_ITEM * Front() const
Definition: selection.h:144

References _, SELECTION::Empty(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), SELECTION::Front(), SELECTION::GetReferencePoint(), PCB_TOOL_BASE::IsFootprintEditor(), SELECTION::IsHover(), isRouterActive(), m_commit, m_dragging, m_selectionTool, TOOL_BASE::m_toolMgr, FP_SHAPE::Mirror(), ZONE::Mirror(), mirrorPadX(), pad, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_ZONE_T, PCB_PAD_T, TOOL_MANAGER::ProcessEvent(), PCB_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, text, PCB_ACTIONS::updateLocalRatsnest, and updateModificationPoint().

Referenced by setTransitions().

◆ Move()

int EDIT_TOOL::Move ( const TOOL_EVENT aEvent)

Main loop in which events are handled.

Definition at line 679 of file edit_tool.cpp.

680 {
681  if( isRouterActive() )
682  {
683  wxBell();
684  return 0;
685  }
686 
687  return doMoveSelection( aEvent );
688 }
int doMoveSelection(TOOL_EVENT aEvent, bool aPickReference=false)
Definition: edit_tool.cpp:705
bool isRouterActive() const
Definition: edit_tool.cpp:273

References doMoveSelection(), and isRouterActive().

Referenced by Duplicate(), and setTransitions().

◆ MoveExact()

int EDIT_TOOL::MoveExact ( const TOOL_EVENT aEvent)

Invoke a dialog box to allow moving of the item by an exact amount.

Definition at line 1995 of file edit_tool.cpp.

1996 {
1997  if( isRouterActive() )
1998  {
1999  wxBell();
2000  return 0;
2001  }
2002 
2004  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
2005  {
2006  // Iterate from the back so we don't have to worry about removals.
2007  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
2008  {
2009  BOARD_ITEM* item = aCollector[i];
2010 
2011  if( item->Type() == PCB_MARKER_T )
2012  aCollector.Remove( item );
2013  }
2014 
2015  sTool->FilterCollectorForHierarchy( aCollector, true );
2016  },
2017  true /* prompt user regarding locked items */ );
2018 
2019  if( selection.Empty() )
2020  return 0;
2021 
2022  wxPoint translation;
2023  double rotation;
2024  ROTATION_ANCHOR rotationAnchor = selection.Size() > 1 ? ROTATE_AROUND_SEL_CENTER
2026 
2027  // TODO: Implement a visible bounding border at the edge
2028  auto sel_box = selection.GetBoundingBox();
2029 
2030  DIALOG_MOVE_EXACT dialog( frame(), translation, rotation, rotationAnchor, sel_box );
2031  int ret = dialog.ShowModal();
2032 
2033  if( ret == wxID_OK )
2034  {
2035  VECTOR2I rp = selection.GetCenter();
2036  wxPoint selCenter( rp.x, rp.y );
2037 
2038  // Make sure the rotation is from the right reference point
2039  selCenter += translation;
2040 
2041  // When editing footprints, all items have the same parent
2042  if( IsFootprintEditor() )
2043  m_commit->Modify( selection.Front() );
2044 
2045  for( EDA_ITEM* selItem : selection )
2046  {
2047  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selItem );
2048 
2049  if( !item->IsNew() && !IsFootprintEditor() )
2050  {
2051  m_commit->Modify( item );
2052 
2053  if( item->Type() == PCB_GROUP_T )
2054  {
2055  PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
2056 
2057  group->RunOnDescendants( [&]( BOARD_ITEM* bItem )
2058  {
2059  m_commit->Modify( bItem );
2060  });
2061  }
2062  }
2063 
2064  if( !item->GetParent() || !item->GetParent()->IsSelected() )
2065  item->Move( translation );
2066 
2067  switch( rotationAnchor )
2068  {
2070  item->Rotate( item->GetPosition(), rotation );
2071  break;
2073  item->Rotate( selCenter, rotation );
2074  break;
2076  item->Rotate( (wxPoint) frame()->GetScreen()->m_LocalOrigin, rotation );
2077  break;
2079  item->Rotate( board()->GetDesignSettings().m_AuxOrigin, rotation );
2080  break;
2081  }
2082 
2083  if( !m_dragging )
2084  getView()->Update( item );
2085  }
2086 
2087  m_commit->Push( _( "Move exact" ) );
2088 
2089  if( selection.IsHover() )
2091 
2093 
2094  if( m_dragging )
2096  }
2097 
2098  return 0;
2099 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.cpp:70
bool IsHover() const
Definition: selection.h:73
BOARD * board() const
bool IsSelected() const
Definition: eda_item.h:123
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:191
virtual void Rotate(const wxPoint &aRotCentre, double aAngle)
Rotate this object.
Definition: board_item.cpp:191
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
virtual wxPoint GetPosition() const
Definition: eda_item.h:252
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:204
bool IsNew() const
Definition: eda_item.h:119
PCB_BASE_EDIT_FRAME * frame() const
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
const PCB_SELECTION & selection() const
bool m_dragging
Definition: edit_tool.h:192
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:272
#define _(s)
ROTATION_ANCHOR
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
void FilterCollectorForHierarchy(GENERAL_COLLECTOR &aCollector, bool aMultiselect) const
In general we don't want to select both a parent and any of it's children.
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:98
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
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:103
bool isRouterActive() const
Definition: edit_tool.cpp:273
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
bool IsFootprintEditor() const
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:460
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:166
virtual EDA_RECT GetBoundingBox() const
Definition: selection.cpp:99
EDA_ITEM * Front() const
Definition: selection.h:144
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1518
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References _, PCB_TOOL_BASE::board(), SELECTION::Empty(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), PCB_TOOL_BASE::frame(), SELECTION::Front(), SELECTION::GetBoundingBox(), SELECTION::GetCenter(), COLLECTOR::GetCount(), BOARD_ITEM::GetParent(), EDA_ITEM::GetPosition(), TOOL_BASE::getView(), group, PCB_TOOL_BASE::IsFootprintEditor(), SELECTION::IsHover(), EDA_ITEM::IsNew(), isRouterActive(), EDA_ITEM::IsSelected(), m_commit, m_dragging, m_selectionTool, TOOL_BASE::m_toolMgr, BOARD_ITEM::Move(), PCB_GROUP_T, PCB_MARKER_T, TOOL_MANAGER::ProcessEvent(), COLLECTOR::Remove(), PCB_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(), EDA_ITEM::Type(), KIGFX::VIEW::Update(), PCB_ACTIONS::updateLocalRatsnest, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

◆ MoveWithReference()

int EDIT_TOOL::MoveWithReference ( const TOOL_EVENT aEvent)

Move an item but with a reference point selected first.

Definition at line 691 of file edit_tool.cpp.

692 {
693  if( isRouterActive() )
694  {
695  wxBell();
696  return 0;
697  }
698 
699  return doMoveSelection( aEvent, true );
700 }
int doMoveSelection(TOOL_EVENT aEvent, bool aPickReference=false)
Definition: edit_tool.cpp:705
bool isRouterActive() const
Definition: edit_tool.cpp:273

References doMoveSelection(), and isRouterActive().

Referenced by setTransitions().

◆ PadFilter()

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

A selection filter which prunes the selection to contain only items of type PCB_PAD_T.

Definition at line 2278 of file edit_tool.cpp.

2280 {
2281  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
2282  {
2283  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
2284 
2285  if( item->Type() != PCB_PAD_T )
2286  aCollector.Remove( i );
2287  }
2288 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
class PAD, a pad in a footprint
Definition: typeinfo.h:89
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

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

Referenced by BOARD_INSPECTION_TOOL::LocalRatsnestTool().

◆ pickReferencePoint()

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

Definition at line 2327 of file edit_tool.cpp.

2329 {
2331  OPT<VECTOR2I> pickedPoint;
2332  bool done = false;
2333 
2334  m_statusPopup->SetText( aTooltip );
2335 
2336  picker->SetClickHandler(
2337  [&]( const VECTOR2D& aPoint ) -> bool
2338  {
2339  pickedPoint = aPoint;
2340 
2341  if( !aSuccessMessage.empty() )
2342  {
2343  m_statusPopup->SetText( aSuccessMessage );
2344  m_statusPopup->Expire( 800 );
2345  }
2346  else
2347  {
2348  m_statusPopup->Hide();
2349  }
2350 
2351  return false; // we don't need any more points
2352  } );
2353 
2354  picker->SetMotionHandler(
2355  [&]( const VECTOR2D& aPos )
2356  {
2357  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
2358  } );
2359 
2360  picker->SetCancelHandler(
2361  [&]()
2362  {
2363  if( !aCanceledMessage.empty() )
2364  {
2365  m_statusPopup->SetText( aCanceledMessage );
2366  m_statusPopup->Expire( 800 );
2367  }
2368  else
2369  {
2370  m_statusPopup->Hide();
2371  }
2372  } );
2373 
2374  picker->SetFinalizeHandler(
2375  [&]( const int& aFinalState )
2376  {
2377  done = true;
2378  } );
2379 
2380  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
2381  m_statusPopup->Popup();
2382 
2383  std::string tool = "";
2384  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
2385 
2386  while( !done )
2387  {
2388  // Pass events unless we receive a null event, then we must shut down
2389  if( TOOL_EVENT* evt = Wait() )
2390  evt->SetPassEvent();
2391  else
2392  break;
2393  }
2394 
2395  // Ensure statusPopup is hidden after use and before deleting it:
2396  m_statusPopup->Hide();
2397 
2398  if( pickedPoint.is_initialized() )
2399  aReferencePoint = pickedPoint.get();
2400 
2401  return pickedPoint.is_initialized();
2402 }
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:102
static TOOL_ACTION pickerTool
Definition: actions.h:155
Generic, UI-independent tool event.
Definition: tool_event.h:152
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:82
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
Definition: edit_tool.h:195
Generic tool for picking an item.
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:71
boost::optional< T > OPT
Definition: optional.h:7
void SetCancelHandler(CANCEL_HANDLER aHandler)
Set a handler for cancel events (ESC or context-menu Cancel).
Definition: picker_tool.h:91

References TOOL_MANAGER::GetTool(), m_statusPopup, TOOL_BASE::m_toolMgr, ACTIONS::pickerTool, TOOL_MANAGER::RunAction(), PICKER_TOOL_BASE::SetCancelHandler(), PICKER_TOOL_BASE::SetClickHandler(), PICKER_TOOL_BASE::SetFinalizeHandler(), PICKER_TOOL_BASE::SetMotionHandler(), and TOOL_INTERACTIVE::Wait().

Referenced by copyToClipboard(), and doMoveSelection().

◆ Properties()

int EDIT_TOOL::Properties ( const TOOL_EVENT aEvent)

Display properties window for the selected object.

Definition at line 1410 of file edit_tool.cpp.

1411 {
1412  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1414  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1415  {
1416  } );
1417 
1418  // Tracks & vias are treated in a special way:
1420  {
1421  DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection, *m_commit );
1422  dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR
1423  }
1424  else if( selection.Size() == 1 )
1425  {
1426  // Display properties dialog
1427  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
1428 
1429  // Do not handle undo buffer, it is done by the properties dialogs
1430  editFrame->OnEditItemRequest( item );
1431 
1432  // Notify other tools of the changes
1434  }
1435  else if( selection.Size() == 0 && getView()->IsLayerVisible( LAYER_DRAWINGSHEET ) )
1436  {
1437  DS_PROXY_VIEW_ITEM* ds = editFrame->GetCanvas()->GetDrawingSheet();
1438  VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
1439 
1440  if( ds && ds->HitTestDrawingSheetItems( getView(), (wxPoint) cursorPos ) )
1442  else
1444  }
1445 
1446  if( selection.IsHover() )
1447  {
1449 
1450  // Notify other tools of the changes -- This updates the visual ratsnest
1452  }
1453 
1454  return 0;
1455 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:373
bool IsHover() const
Definition: selection.h:73
static const KICAD_T Tracks[]
A scan list for only TRACKs.
Definition: collectors.h:298
static TOOL_ACTION pageSettings
Definition: actions.h:56
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:191
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create a functor that tests if the selected items are only of given types.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void OnEditItemRequest(BOARD_ITEM *aItem)=0
Install the corresponding dialog editor for the given item.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
bool HitTestDrawingSheetItems(KIGFX::VIEW *aView, const wxPoint &aPosition)
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:204
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
const PCB_SELECTION & selection() const
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
drawingsheet frame and titleblock
Definition: layer_ids.h:212
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
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:103
The selection tool: currently supports:
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:144
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:405

References PCB_ACTIONS::footprintProperties, SELECTION::Front(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_DRAW_PANEL_GAL::GetDrawingSheet(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), DS_PROXY_VIEW_ITEM::HitTestDrawingSheetItems(), SELECTION::IsHover(), KIGFX::VIEW::IsLayerVisible(), LAYER_DRAWINGSHEET, m_commit, m_selectionTool, TOOL_BASE::m_toolMgr, PCB_BASE_EDIT_FRAME::OnEditItemRequest(), SELECTION_CONDITIONS::OnlyTypes(), ACTIONS::pageSettings, TOOL_MANAGER::ProcessEvent(), PCB_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)

Delete currently selected items.

Definition at line 1754 of file edit_tool.cpp.

1755 {
1756  if( isRouterActive() )
1757  {
1759  return 0;
1760  }
1761 
1762  auto isSelectedForDelete =
1763  []( BOARD_ITEM* aItem )
1764  {
1765  for( BOARD_ITEM* item = aItem; item; item = item->GetParentGroup() )
1766  {
1767  if( item->IsSelected() )
1768  return true;
1769  }
1770 
1771  return false;
1772  };
1773 
1774  std::vector<BOARD_ITEM*> lockedItems;
1775  Activate();
1776 
1777  // get a copy instead of reference (as we're going to clear the selection before removing items)
1778  PCB_SELECTION selectionCopy;
1781  std::vector<BOARD_ITEM*> disallowedPads;
1782 
1783  // If we are in a "Cut" operation, then the copied selection exists already and we want to
1784  // delete exactly that; no more, no fewer. Any filtering for locked items must be done in
1785  // the copyToClipboard() routine.
1786  if( isCut )
1787  {
1788  selectionCopy = m_selectionTool->GetSelection();
1789  }
1790  else
1791  {
1792  selectionCopy = m_selectionTool->RequestSelection(
1793  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1794  {
1795  },
1796  false /* ignore locked items until after we filter out non-free pads */ );
1797 
1798  if( !IsFootprintEditor() && !frame()->Settings().m_AllowFreePads )
1799  {
1800  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
1801  {
1802  PAD* pad = dynamic_cast<PAD*>( item );
1803 
1804  if( pad && !isSelectedForDelete( pad->GetParent() ) )
1805  {
1806  disallowedPads.push_back( pad );
1807  m_selectionTool->RemoveItemFromSel( pad, true /* quiet mode */ );
1808  }
1809  }
1810 
1812  {
1813  wxBell();
1814  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &disallowedPads );
1815  canvas()->Refresh();
1816  return 0;
1817  }
1818  }
1819 
1820  selectionCopy = m_selectionTool->RequestSelection(
1821  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1822  {
1823  },
1824  true /* prompt user regarding locked items */ );
1825  }
1826 
1827  bool isHover = selectionCopy.IsHover();
1828 
1829  // in "alternative" mode, deletion is not just a simple list of selected items,
1830  // it removes whole tracks, not just segments
1831  if( isAlt && isHover
1832  && ( selectionCopy.HasType( PCB_TRACE_T ) || selectionCopy.HasType( PCB_VIA_T ) ) )
1833  {
1835  }
1836 
1837  // As we are about to remove items, they have to be removed from the selection first
1839 
1840  for( EDA_ITEM* item : selectionCopy )
1841  {
1842  PCB_GROUP* parentGroup = static_cast<BOARD_ITEM*>( item )->GetParentGroup();
1843 
1844  if( parentGroup )
1845  {
1846  m_commit->Modify( parentGroup );
1847  parentGroup->RemoveItem( static_cast<BOARD_ITEM*>( item ) );
1848  }
1849 
1850  switch( item->Type() )
1851  {
1852  case PCB_FP_TEXT_T:
1853  {
1854  FP_TEXT* text = static_cast<FP_TEXT*>( item );
1855  FOOTPRINT* parent = static_cast<FOOTPRINT*>( item->GetParent() );
1856 
1857  if( text->GetType() == FP_TEXT::TEXT_is_DIVERS )
1858  {
1859  m_commit->Modify( parent );
1860  getView()->Remove( text );
1861  parent->Remove( text );
1862  }
1863 
1864  break;
1865  }
1866 
1867  case PCB_PAD_T:
1868  if( IsFootprintEditor() || frame()->Settings().m_AllowFreePads )
1869  {
1870  PAD* pad = static_cast<PAD*>( item );
1871  FOOTPRINT* parent = static_cast<FOOTPRINT*>( item->GetParent() );
1872 
1873  m_commit->Modify( parent );
1874  getView()->Remove( pad );
1875  parent->Remove( pad );
1876  }
1877 
1878  break;
1879 
1880  case PCB_FP_ZONE_T:
1881  {
1882  FP_ZONE* zone = static_cast<FP_ZONE*>( item );
1883  FOOTPRINT* parent = static_cast<FOOTPRINT*>( item->GetParent() );
1884 
1885  m_commit->Modify( parent );
1886  getView()->Remove( zone );
1887  parent->Remove( zone );
1888  break;
1889  }
1890 
1891  case PCB_ZONE_T:
1892  // We process the zones special so that cutouts can be deleted when the delete tool
1893  // is called from inside a cutout when the zone is selected.
1894  {
1895  // Only interact with cutouts when deleting and a single item is selected
1896  if( !isCut && selectionCopy.GetSize() == 1 )
1897  {
1899  ZONE* zone = static_cast<ZONE*>( item );
1900 
1901  int outlineIdx, holeIdx;
1902 
1903  if( zone->HitTestCutout( curPos, &outlineIdx, &holeIdx ) )
1904  {
1905  // Remove the cutout
1906  m_commit->Modify( zone );
1907  zone->RemoveCutout( outlineIdx, holeIdx );
1908  zone->UnFill();
1909 
1910  // TODO Refill zone when KiCad supports auto re-fill
1911 
1912  // Update the display
1913  zone->HatchBorder();
1914  canvas()->Refresh();
1915 
1916  // Restore the selection on the original zone
1918 
1919  break;
1920  }
1921  }
1922 
1923  // Remove the entire zone otherwise
1924  m_commit->Remove( item );
1925  break;
1926  }
1927 
1928  case PCB_GROUP_T:
1929  {
1930  PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
1931 
1932  auto removeItem =
1933  [&]( BOARD_ITEM* bItem )
1934  {
1935  if( bItem->GetParent() && bItem->GetParent()->Type() == PCB_FOOTPRINT_T )
1936  {
1937  // Silently ignore delete of Reference or Value if they happen to be
1938  // in group.
1939  if( bItem->Type() == PCB_FP_TEXT_T )
1940  {
1941  FP_TEXT* textItem = static_cast<FP_TEXT*>( bItem );
1942 
1943  if( textItem->GetType() != FP_TEXT::TEXT_is_DIVERS )
1944  return;
1945  }
1946  else if( bItem->Type() == PCB_PAD_T )
1947  {
1949  return;
1950  }
1951 
1952  m_commit->Modify( bItem->GetParent() );
1953  getView()->Remove( bItem );
1954  bItem->GetParent()->Remove( bItem );
1955  }
1956  else
1957  {
1958  m_commit->Remove( bItem );
1959  }
1960  };
1961 
1962  removeItem( group );
1963 
1964  group->RunOnDescendants( [&]( BOARD_ITEM* aDescendant )
1965  {
1966  removeItem( aDescendant );
1967  });
1968  break;
1969  }
1970 
1971  default:
1972  m_commit->Remove( item );
1973  break;
1974  }
1975  }
1976 
1977  // If the entered group has been emptied then leave it.
1978  PCB_GROUP* enteredGroup = m_selectionTool->GetEnteredGroup();
1979 
1980  if( enteredGroup && enteredGroup->GetItems().empty() )
1982 
1983  if( isCut )
1984  m_commit->Push( _( "Cut" ) );
1985  else
1986  m_commit->Push( _( "Delete" ) );
1987 
1988  if( !disallowedPads.empty() )
1989  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &disallowedPads );
1990 
1991  return 0;
1992 }
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Definition: pcb_actions.h:66
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:91
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
Definition: zone.cpp:790
bool IsHover() const
Definition: selection.h:73
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
REMOVE_FLAGS
Definition: actions.h:189
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
bool HasType(KICAD_T aType) const
Checks if there is at least one item of requested kind.
Definition: selection.cpp:110
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:191
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
static TOOL_ACTION routerUndoLastSegment
Definition: pcb_actions.h:192
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:353
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: footprint.cpp:566
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static TOOL_ACTION selectConnection
Select tracks between junctions or expands an existing selection to pads or the entire connection.
Definition: pcb_actions.h:74
class PAD, a pad in a footprint
Definition: typeinfo.h:89
PCB_GROUP * GetEnteredGroup()
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
std::unordered_set< BOARD_ITEM * > & GetItems()
Definition: pcb_group.h:68
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PCB_BASE_EDIT_FRAME * frame() const
bool HitTestCutout(const VECTOR2I &aRefPos, int *aOutlineIdx=nullptr, int *aHoleIdx=nullptr) const
Test if the given point is contained within a cutout of the zone.
Definition: zone.cpp:521
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
Definition: zone.cpp:927
TEXT_TYPE GetType() const
Definition: fp_text.h:141
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
#define _(s)
bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
Definition: pcb_group.cpp:50
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
class ZONE, a copper pour area
Definition: typeinfo.h:105
void ExitGroup(bool aSelectGroup=false)
Leave the currently entered group.
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition: pcb_actions.h:62
class ZONE, managed by a footprint
Definition: typeinfo.h:94
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
PCBNEW_SETTINGS & Settings()
bool isRouterActive() const
Definition: edit_tool.cpp:273
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
bool IsFootprintEditor() const
void Activate()
Run the tool.
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
void RemoveItemFromSel(BOARD_ITEM *aItem, bool aQuietMode=false)
Multiple item unselection event handler.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
Definition: pad.h:57
bool UnFill()
Removes the zone filling.
Definition: zone.cpp:188
PCB_DRAW_PANEL_GAL * canvas() const
A specialization of ZONE for use in footprints.
Definition: zone.h:946
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.

References _, TOOL_INTERACTIVE::Activate(), ACTIONS::ALT, PCB_TOOL_BASE::canvas(), ACTIONS::CUT, SELECTION::Empty(), PCB_SELECTION_TOOL::ExitGroup(), PCB_TOOL_BASE::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_SELECTION_TOOL::GetEnteredGroup(), PCB_GROUP::GetItems(), BOARD_ITEM::GetParentGroup(), PCB_SELECTION_TOOL::GetSelection(), FP_TEXT::GetType(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), group, SELECTION::HasType(), ZONE::HatchBorder(), ZONE::HitTestCutout(), PCB_TOOL_BASE::IsFootprintEditor(), SELECTION::IsHover(), isRouterActive(), PCBNEW_SETTINGS::m_AllowFreePads, m_commit, m_selectionTool, TOOL_BASE::m_toolMgr, pad, TOOL_EVENT::Parameter(), PCB_FOOTPRINT_T, PCB_FP_TEXT_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::VIEW::Remove(), FOOTPRINT::Remove(), ZONE::RemoveCutout(), PCB_GROUP::RemoveItem(), PCB_SELECTION_TOOL::RemoveItemFromSel(), PCB_SELECTION_TOOL::RequestSelection(), PCB_ACTIONS::routerUndoLastSegment, TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectConnection, PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, PCB_ACTIONS::selectItems, PCB_BASE_FRAME::Settings(), text, FP_TEXT::TEXT_is_DIVERS, and ZONE::UnFill().

Referenced by cutToClipboard(), and setTransitions().

◆ Reset()

void EDIT_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

Bring the tool to a known, initial state.

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

Parameters
aReasoncontains information about the reason of tool reset.

Reimplemented from PCB_TOOL_BASE.

Definition at line 76 of file edit_tool.cpp.

77 {
78  m_dragging = false;
79 
80  m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
81 
82  if( aReason != RUN )
83  m_commit.reset( new BOARD_COMMIT( this ) );
84 }