KiCad PCB EDA Suite
EDIT_TOOL Class Reference

Class EDIT_TOOL. More...

#include <edit_tool.h>

Inheritance diagram for EDIT_TOOL:
PCB_TOOL TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 EDIT_TOOL ()
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
int Main (const TOOL_EVENT &aEvent)
 Function Main() More...
 
int Drag (const TOOL_EVENT &aEvent)
 Function Drag() More...
 
int Properties (const TOOL_EVENT &aEvent)
 Function Edit() More...
 
int Rotate (const TOOL_EVENT &aEvent)
 Function Rotate() More...
 
int Flip (const TOOL_EVENT &aEvent)
 Function Flip() More...
 
int Mirror (const TOOL_EVENT &aEvent)
 Function Mirror. More...
 
int Remove (const TOOL_EVENT &aEvent)
 Function Remove() More...
 
int Duplicate (const TOOL_EVENT &aEvent)
 Function Duplicate() More...
 
int MoveExact (const TOOL_EVENT &aEvent)
 Function MoveExact() More...
 
int CreateArray (const TOOL_EVENT &aEvent)
 Function CreateArray() More...
 
int ExchangeFootprints (const TOOL_EVENT &aEvent)
 Function ExchangeFootprints() More...
 
int MeasureTool (const TOOL_EVENT &aEvent)
 

Launches a tool to measure between points

More...
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 
int copyToClipboard (const TOOL_EVENT &aEvent)
 Function copyToClipboard() Sends the current selection to the clipboard by formatting it as a fake pcb see AppendBoardFromClipboard for importing. More...
 
int copyToClipboardWithAnchor (const TOOL_EVENT &aEvent)
 
int doCopyToClipboard (bool withAnchor)
 
int cutToClipboard (const TOOL_EVENT &aEvent)
 Function cutToClipboard() Cuts the current selection to the clipboard by formatting it as a fake pcb see AppendBoardFromClipboard for importing. More...
 
BOARD_COMMITGetCurrentCommit () const
 
void SetEditModules (bool aEnabled)
 Function SetEditModules() More...
 
bool EditingModules () const
 
void Activate ()
 Function Activate() Runs the tool. More...
 
void SetContextMenu (CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
OPT_TOOL_EVENT Wait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Static Public Member Functions

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

Protected Types

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

Protected Member Functions

void doInteractiveItemPlacement (INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const SELECTIONselection () const
 
SELECTIONselection ()
 
const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

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

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

bool updateModificationPoint (SELECTION &aSelection)
 

Returns the right modification point (e.g.

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

Private Attributes

SELECTION_TOOLm_selectionTool
 

Selection tool used for obtaining selected items

More...
 
bool m_dragging
 

Flag determining if anything is being dragged right now

More...
 
VECTOR2I m_cursor
 

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

More...
 
std::unique_ptr< BOARD_COMMITm_commit
 

Detailed Description

Class EDIT_TOOL.

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

Definition at line 59 of file edit_tool.h.

Member Enumeration Documentation

enum PCB_TOOL::INTERACTIVE_PLACEMENT_OPTIONS
protectedinherited
Enumerator
IPO_ROTATE 
IPO_FLIP 
IPO_PROPERTIES 
IPO_SINGLE_CLICK 
IPO_REPEAT 

Definition at line 109 of file pcb_tool.h.

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 80 of file tool_base.h.

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

Constructor & Destructor Documentation

EDIT_TOOL::EDIT_TOOL ( )

Definition at line 214 of file edit_tool.cpp.

214  :
215  PCB_TOOL( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ),
216  m_dragging( false )
217 {
218 }
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:194
PCB_TOOL(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool.h:71

Member Function Documentation

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 49 of file tool_interactive.cpp.

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

Referenced by AUTOPLACE_TOOL::autoplace(), PCBNEW_CONTROL::DeleteItemCursor(), doCopyToClipboard(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), MeasureTool(), POINT_EDITOR::OnSelectionChange(), pickCopyReferencePoint(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

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

Definition at line 59 of file tool_base.cpp.

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

Referenced by TOOL_MANAGER::RegisterTool().

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

Definition at line 140 of file pcb_tool.h.

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

140 { return getModel<BOARD>(); }
PCB_DRAW_PANEL_GAL * PCB_TOOL::canvas ( ) const
protectedinherited
bool EDIT_TOOL::changeTrackWidthOnClick ( const SELECTION selection)
private

Definition at line 580 of file edit_tool.cpp.

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

Referenced by Properties().

581 {
582  if ( selection.Size() == 1 && frame()->Settings().m_editActionChangesTrackWidth )
583  {
584  auto item = static_cast<BOARD_ITEM *>( selection[0] );
585 
586  m_commit->Modify( item );
587 
588  if( auto via = dyn_cast<VIA*>( item ) )
589  {
590  int new_width, new_drill;
591 
592  if( via->GetViaType() == VIA_MICROVIA )
593  {
594  auto net = via->GetNet();
595 
596  new_width = net->GetMicroViaSize();
597  new_drill = net->GetMicroViaDrillSize();
598  }
599  else
600  {
601  new_width = board()->GetDesignSettings().GetCurrentViaSize();
602  new_drill = board()->GetDesignSettings().GetCurrentViaDrill();
603  }
604 
605  via->SetDrill( new_drill );
606  via->SetWidth( new_width );
607  }
608  else if ( auto track = dyn_cast<TRACK*>( item ) )
609  {
610  int new_width = board()->GetDesignSettings().GetCurrentTrackWidth();
611  track->SetWidth( new_width );
612  }
613 
614  m_commit->Push( _("Edit track width/via size") );
615  return true;
616  }
617 
618  return false;
619 }
int GetCurrentViaDrill() const
Function GetCurrentViaDrill.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:212
int GetCurrentViaSize() const
Function GetCurrentViaSize.
PCB_GENERAL_SETTINGS & Settings()
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
int Size() const
Returns the number of selected parts.
Definition: selection.h:122
int GetCurrentTrackWidth() const
Function GetCurrentTrackWidth.
BOARD * board() const
Definition: pcb_tool.h:140
int EDIT_TOOL::copyToClipboard ( const TOOL_EVENT aEvent)

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

Returns
True if it was sent succesfully

Definition at line 1457 of file edit_tool.cpp.

References doCopyToClipboard().

Referenced by cutToClipboard(), and setTransitions().

1458 {
1459  return doCopyToClipboard( true );
1460 }
int doCopyToClipboard(bool withAnchor)
Definition: edit_tool.cpp:1425
int EDIT_TOOL::copyToClipboardWithAnchor ( const TOOL_EVENT aEvent)

Definition at line 1463 of file edit_tool.cpp.

References doCopyToClipboard().

1464 {
1465  return doCopyToClipboard( true );
1466 }
int doCopyToClipboard(bool withAnchor)
Definition: edit_tool.cpp:1425
int EDIT_TOOL::CreateArray ( const TOOL_EVENT aEvent)

Function CreateArray()

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

Definition at line 1149 of file edit_tool.cpp.

References EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, PCB_TOOL::m_editModules, m_selectionTool, SELECTION_TOOL::RequestSelection(), and PCB_TOOL::selection().

Referenced by setTransitions().

1150 {
1152  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1154 
1155  if( selection.Empty() )
1156  return 0;
1157 
1158  // we have a selection to work on now, so start the tool process
1159  PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
1160  GAL_ARRAY_CREATOR array_creator( *editFrame, m_editModules, selection );
1161  array_creator.Invoke();
1162 
1163  return 0;
1164 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:116
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Function RequestSelection()
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:47
bool m_editModules
Definition: pcb_tool.h:150
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:242
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:46
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
int EDIT_TOOL::cutToClipboard ( const TOOL_EVENT aEvent)

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

Returns
True if it was sent succesfully

Definition at line 1469 of file edit_tool.cpp.

References copyToClipboard(), and Remove().

Referenced by setTransitions().

1470 {
1471  if( !copyToClipboard( aEvent ) )
1472  Remove( aEvent );
1473 
1474  return 0;
1475 }
int Remove(const TOOL_EVENT &aEvent)
Function Remove()
Definition: edit_tool.cpp:858
int copyToClipboard(const TOOL_EVENT &aEvent)
Function copyToClipboard() Sends the current selection to the clipboard by formatting it as a fake pc...
Definition: edit_tool.cpp:1457
PCB_DISPLAY_OPTIONS * PCB_TOOL::displayOptions ( ) const
protectedinherited

Definition at line 235 of file pcb_tool.cpp.

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

Referenced by PCBNEW_CONTROL::GraphicDisplayMode(), PCBNEW_CONTROL::HighContrastMode(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), PCBNEW_CONTROL::PadDisplayMode(), PNS::TOOL_BASE::pickSingleItem(), PCBNEW_CONTROL::TrackDisplayMode(), PCBNEW_CONTROL::ViaDisplayMode(), and PCBNEW_CONTROL::ZoneDisplayMode().

236 {
237  return static_cast<PCB_DISPLAY_OPTIONS*>( frame()->GetDisplayOptions() );
238 }
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
int EDIT_TOOL::doCopyToClipboard ( bool  withAnchor)

Definition at line 1425 of file edit_tool.cpp.

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

Referenced by copyToClipboard(), and copyToClipboardWithAnchor().

1426 {
1427  CLIPBOARD_IO io;
1428 
1429  Activate();
1430 
1432  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1434 
1435  if( selection.Empty() )
1436  return 1;
1437 
1438  if( withAnchor )
1439  {
1440  VECTOR2I refPoint;
1441  bool rv = pickCopyReferencePoint( refPoint );
1442  frame()->SetMsgPanel( board() );
1443 
1444  if( !rv )
1445  return 1;
1446 
1447  selection.SetReferencePoint( refPoint );
1448  }
1449 
1450  io.SetBoard( board() );
1451  io.SaveSelection( selection );
1452 
1453  return 0;
1454 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:116
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Function RequestSelection()
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
void SaveSelection(const SELECTION &selected)
void SetBoard(BOARD *aBoard)
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:205
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:47
bool pickCopyReferencePoint(VECTOR2I &aP)
Definition: edit_tool.cpp:1386
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:242
void Activate()
Function Activate() Runs the tool.
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:46
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173
BOARD * board() const
Definition: pcb_tool.h:140
void PCB_TOOL::doInteractiveItemPlacement ( INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

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

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

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

Definition at line 39 of file pcb_tool.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), PCB_TOOL::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), dyn_cast(), PCB_ACTIONS::flip, PCB_TOOL::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_TOOL::IPO_FLIP, PCB_TOOL::IPO_PROPERTIES, PCB_TOOL::IPO_REPEAT, PCB_TOOL::IPO_ROTATE, PCB_TOOL::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, INTERACTIVE_PLACER_BASE::m_frame, PCB_TOOL::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, PCB_TOOL::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), BOARD_COMMIT::Push(), KIGFX::PCB_VIEW::Remove(), KIGFX::VIEW_GROUP::Remove(), SELECTION::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, KIGFX::PCB_VIEW::Update(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

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

Function Drag()

todo

Definition at line 324 of file edit_tool.cpp.

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

Referenced by setTransitions().

325 {
326  int mode = PNS::DM_ANY;
327 
328  if( aEvent.IsAction( &PCB_ACTIONS::dragFreeAngle ) )
329  mode |= PNS::DM_FREE_ANGLE;
330 
331  invokeInlineRouter( mode );
332 
333  return 0;
334 }
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:137
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:54
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:295
int EDIT_TOOL::Duplicate ( const TOOL_EVENT aEvent)

Function Duplicate()

Duplicates the current selection and starts a move action.

Definition at line 999 of file edit_tool.cpp.

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

Referenced by setTransitions().

1000 {
1001  bool increment = aEvent.IsAction( &PCB_ACTIONS::duplicateIncrement );
1002 
1003  // Be sure that there is at least one item that we can modify
1005  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
1007 
1008  if( selection.Empty() )
1009  return 0;
1010 
1011  // we have a selection to work on now, so start the tool process
1012  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1013 
1014  std::vector<BOARD_ITEM*> new_items;
1015  new_items.reserve( selection.Size() );
1016 
1017  BOARD_ITEM* orig_item = nullptr;
1018  BOARD_ITEM* dupe_item = nullptr;
1019 
1020  // Each selected item is duplicated and pushed to new_items list
1021  // Old selection is cleared, and new items are then selected.
1022  for( auto item : selection )
1023  {
1024  if( !item )
1025  continue;
1026 
1027  orig_item = static_cast<BOARD_ITEM*>( item );
1028 
1029  if( m_editModules )
1030  {
1031  dupe_item = editFrame->GetBoard()->m_Modules->Duplicate( orig_item, increment );
1032  }
1033  else
1034  {
1035 #if 0
1036  // @TODO: see if we allow zone duplication here
1037  // Duplicate zones is especially tricky (overlaping zones must be merged)
1038  // so zones are not duplicated
1039  if( item->Type() != PCB_ZONE_AREA_T )
1040 #endif
1041  dupe_item = editFrame->GetBoard()->Duplicate( orig_item );
1042  }
1043 
1044  if( dupe_item )
1045  {
1046  // Clear the selection flag here, otherwise the SELECTION_TOOL
1047  // will not properly select it later on
1048  dupe_item->ClearSelected();
1049 
1050  new_items.push_back( dupe_item );
1051  m_commit->Add( dupe_item );
1052  }
1053  }
1054 
1055  // Clear the old selection first
1057 
1058  // Select the new items
1059  m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &new_items );
1060 
1061  // record the new items as added
1062  if( !selection.Empty() )
1063  {
1064  editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ),
1065  (int) new_items.size() ) );
1066 
1067 
1068  // If items were duplicated, pick them up
1069  // this works well for "dropping" copies around and pushes the commit
1071  Main( evt );
1072  }
1073 
1074  return 0;
1075 }
static TOOL_ACTION selectItems
Selects a list of items (specified as the event parameter)
Definition: pcb_actions.h:59
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:116
int Main(const TOOL_EVENT &aEvent)
Function Main()
Definition: edit_tool.cpp:336
static TOOL_ACTION move
move an item
Definition: pcb_actions.h:96
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Function RequestSelection()
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:212
void ClearSelected()
Definition: base_struct.h:234
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
BOARD_ITEM * Duplicate(const BOARD_ITEM *aItem, bool aIncrementPadNumbers, bool aAddToModule=false)
Function Duplicate Duplicate a given item within the module, without adding to the board...
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
BOARD * GetBoard() const
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:54
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
Definition: pcb_actions.h:123
Class TOOL_EVENT.
Definition: tool_event.h:168
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:47
bool m_editModules
Definition: pcb_tool.h:150
TOOL_EVENT MakeEvent() const
Function HasHotKey() Checks if the action has a hot key assigned.
Definition: tool_action.h:104
void DisplayToolMsg(const wxString &msg)
Common, abstract interface for edit frames.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
DLIST< MODULE > m_Modules
Definition: class_board.h:248
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:242
int Size() const
Returns the number of selected parts.
Definition: selection.h:122
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:46
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173
BOARD_ITEM * Duplicate(const BOARD_ITEM *aItem, bool aAddToBoard=false)
int EDIT_TOOL::editFootprintInFpEditor ( const TOOL_EVENT aEvent)
private

Definition at line 1349 of file edit_tool.cpp.

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

Referenced by setTransitions().

1350 {
1352 
1353  if( selection.Empty() )
1354  return 0;
1355 
1357 
1358  if( !mod )
1359  return 0;
1360 
1361  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1362 
1363  editFrame->SetCurItem( mod );
1364 
1365  if( editFrame->GetCurItem()->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
1366  {
1367  editFrame->GetCurItem()->SetTimeStamp( GetNewTimeStamp() );
1368  editFrame->OnModify();
1369  }
1370 
1372 
1373  editor->Load_Module_From_BOARD( (MODULE*) editFrame->GetCurItem() );
1374  editFrame->SetCurItem( NULL ); // the current module could be deleted by
1375 
1376  editor->Show( true );
1377  editor->Raise(); // Iconize( false );
1378 
1379  if( selection.IsHover() )
1381 
1382  return 0;
1383 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:116
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Function RequestSelection()
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
timestamp_t GetNewTimeStamp()
Definition: common.cpp:212
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
bool Load_Module_From_BOARD(MODULE *Module)
Load in Modedit a footprint from the main board.
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
T * FirstOfKind() const
Definition: selection.h:163
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
Common, abstract interface for edit frames.
bool IsHover() const
Definition: selection.h:69
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
Function FootprintFilter()
Definition: edit_tool.cpp:1167
BOARD_ITEM * GetCurItem()
#define mod(a, n)
Definition: greymap.cpp:24
timestamp_t GetTimeStamp() const
Definition: base_struct.h:207
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:206
bool PCB_TOOL::EditingModules ( ) const
inlineinherited

Definition at line 102 of file pcb_tool.h.

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

103  {
104  return m_editModules;
105  }
bool m_editModules
Definition: pcb_tool.h:150
const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited
int EDIT_TOOL::ExchangeFootprints ( const TOOL_EVENT aEvent)

Function ExchangeFootprints()

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

Definition at line 1179 of file edit_tool.cpp.

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

Referenced by setTransitions().

1180 {
1182 
1183  bool updateMode = aEvent.IsAction( &PCB_ACTIONS::updateFootprints );
1184 
1185  MODULE* mod = (selection.Empty() ? nullptr : selection.FirstOfKind<MODULE> () );
1186 
1187  frame()->SetCurItem( mod );
1188 
1189  // Footprint exchange could remove modules, so they have to be
1190  // removed from the selection first
1192 
1193  // invoke the exchange dialog process
1194  {
1195  DIALOG_EXCHANGE_FOOTPRINTS dialog( frame(), mod, updateMode, mod != nullptr );
1196  dialog.ShowQuasiModal();
1197  }
1198 
1199  return 0;
1200 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:116
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Function RequestSelection()
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:54
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
T * FirstOfKind() const
Definition: selection.h:163
static TOOL_ACTION updateFootprints
Update footprints to reflect any changes in the library.
Definition: pcb_actions.h:126
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
Function FootprintFilter()
Definition: edit_tool.cpp:1167
#define mod(a, n)
Definition: greymap.cpp:24
int EDIT_TOOL::Flip ( const TOOL_EVENT aEvent)

Function Flip()

Rotates currently selected items. The rotation point is the current cursor position.

Definition at line 820 of file edit_tool.cpp.

References PCB_TOOL::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED, EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, SELECTION::Front(), SELECTION::GetReferencePoint(), m_commit, m_dragging, m_selectionTool, TOOL_BASE::m_toolMgr, SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_TOOL::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionModified, and updateModificationPoint().

Referenced by setTransitions().

821 {
823  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
825 
826  if( selection.Empty() )
827  return 0;
828 
830  auto modPoint = selection.GetReferencePoint();
831 
832  // When editing modules, all items have the same parent
833  if( EditingModules() )
834  {
835  m_commit->Modify( selection.Front() );
836  }
837 
838  for( auto item : selection )
839  {
840  if( !item->IsNew() && !EditingModules() )
841  m_commit->Modify( item );
842 
843  static_cast<BOARD_ITEM*>( item )->Flip( modPoint );
844  }
845 
846  if( !m_dragging )
847  m_commit->Push( _( "Flip" ) );
848 
849  if( selection.IsHover() && !m_dragging )
851 
853 
854  return 0;
855 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:116
VECTOR2I GetReferencePoint() const
Definition: selection.h:200
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Function RequestSelection()
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:212
bool updateModificationPoint(SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1326
EDA_ITEM * Front() const
Definition: selection.h:152
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:114
int Flip(const TOOL_EVENT &aEvent)
Function Flip()
Definition: edit_tool.cpp:820
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:194
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:47
bool EditingModules() const
Definition: pcb_tool.h:102
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:242
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:45
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:46
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173
void EDIT_TOOL::FootprintFilter ( const VECTOR2I ,
GENERAL_COLLECTOR aCollector 
)
static

Function FootprintFilter()

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

Definition at line 1167 of file edit_tool.cpp.

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

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

1168 {
1169  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1170  {
1171  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
1172 
1173  if( item->Type() != PCB_MODULE_T )
1174  aCollector.Remove( i );
1175  }
1176 }
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:143
class MODULE, a footprint
Definition: typeinfo.h:89
size_t i
Definition: json11.cpp:597
PCB_EDIT_FRAME* PCB_TOOL::frame ( ) const
inlineprotectedinherited

Definition at line 139 of file pcb_tool.h.

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

139 { return getEditFrame<PCB_EDIT_FRAME>(); }
BOARD_COMMIT* EDIT_TOOL::GetCurrentCommit ( ) const
inline

Definition at line 184 of file edit_tool.h.

References m_commit.

185  {
186  return m_commit.get();
187  }
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:212
template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

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

Definition at line 188 of file tool_base.h.

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

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

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

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

123  {
124  return m_toolId;
125  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 144 of file tool_base.h.

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

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 199 of file tool_base.h.

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

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

Function GetName() Returns the name of the tool.

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

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

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

134  {
135  return m_toolName;
136  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:214
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

Referenced by GERBVIEW_CONTROL::HighlightControl(), ROUTER_TOOL::Init(), and ROUTER_TOOL::~ROUTER_TOOL().

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

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

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:207
KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Function getView()

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

Returns
The instance of VIEW.

Definition at line 35 of file tool_base.cpp.

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

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

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

Function getViewControls()

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

Returns
The instance of VIEW_CONTROLS.

Definition at line 41 of file tool_base.cpp.

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

Referenced by POINT_EDITOR::addCorner(), COMMON_TOOLS::CursorControl(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), Main(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), CVPCB_CONTROL::ResetCoords(), GERBVIEW_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PICKER_TOOL::setControls(), POINT_EDITOR::setEditedPoint(), updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257
template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited
bool EDIT_TOOL::Init ( )
overridevirtual

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

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

Reimplemented from PCB_TOOL.

Definition at line 230 of file edit_tool.cpp.

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

231 {
232  // Find the selection tool, so they can cooperate
233  m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
234 
235  if( !m_selectionTool )
236  {
237  DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) );
238  return false;
239  }
240 
241  auto editingModuleCondition = [ this ] ( const SELECTION& aSelection ) {
242  return m_editModules;
243  };
244 
245  auto singleModuleCondition = SELECTION_CONDITIONS::OnlyType( PCB_MODULE_T )
247 
248  auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) {
249  return ( frame()->GetToolId() == ID_NO_TOOL_SELECTED );
250  };
251 
252  // Add context menu entries that are displayed when selection tool is active
254 
264 
265 
270 
271 
275  // Selection tool handles the context menu for some other tools, such as the Picker.
276  // Don't add things like Paste when another tool is active.
277  menu.AddItem( PCB_ACTIONS::pasteFromClipboard, noActiveToolCondition );
278 
279  // Mirror only available in modedit
280  menu.AddSeparator( editingModuleCondition && SELECTION_CONDITIONS::NotEmpty );
281  menu.AddItem( PCB_ACTIONS::mirror, editingModuleCondition && SELECTION_CONDITIONS::NotEmpty );
284 
285  // Footprint actions
286  menu.AddSeparator( singleModuleCondition );
287  menu.AddItem( PCB_ACTIONS::editFootprintInFpEditor, singleModuleCondition );
288  menu.AddItem( PCB_ACTIONS::updateFootprints, singleModuleCondition );
289  menu.AddItem( PCB_ACTIONS::exchangeFootprints, singleModuleCondition );
290 
291  return true;
292 }
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
static TOOL_ACTION move
move an item
Definition: pcb_actions.h:96
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:315
void AddSeparator(const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddSeparator()
Class SELECTION_TOOL.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:49
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:137
static TOOL_ACTION explodePadToShapes
Definition: pcb_actions.h:312
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:111
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:136
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:108
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
static SELECTION_CONDITION Count(int aNumber)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
static TOOL_ACTION pasteFromClipboard
Paste from clipboard.
Definition: pcb_actions.h:324
static bool NotEmpty(const SELECTION &aSelection)
Function NotEmpty Tests if there are any items selected.
static TOOL_ACTION moveExact
Activation of the exact move tool.
Definition: pcb_actions.h:117
static TOOL_ACTION duplicate
Activation of the duplication tool.
Definition: pcb_actions.h:120
class MODULE, a footprint
Definition: typeinfo.h:89
static TOOL_ACTION rotateCw
Rotation of selected objects clockwise.
Definition: pcb_actions.h:99
static SELECTION_CONDITION OnlyTypes(const std::vector< KICAD_T > &aTypes)
Function OnlyTypes Creates a functor that tests if the selected items are only of given types...
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
static TOOL_ACTION createArray
Tool for creating an array of objects.
Definition: pcb_actions.h:318
static TOOL_ACTION exchangeFootprints
Exchange footprints of modules.
Definition: pcb_actions.h:129
static TOOL_ACTION cutToClipboard
Paste from clipboard.
Definition: pcb_actions.h:327
static TOOL_ACTION copyToClipboard
Copy selected items to clipboard.
Definition: pcb_actions.h:321
bool m_editModules
Definition: pcb_tool.h:150
static TOOL_ACTION updateFootprints
Update footprints to reflect any changes in the library.
Definition: pcb_actions.h:126
static TOOL_ACTION rotateCcw
Rotation of selected objects counter-clockwise.
Definition: pcb_actions.h:102
static TOOL_ACTION createPadFromShapes
Definition: pcb_actions.h:311
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:105
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddItem()
static TOOL_ACTION editFootprintInFpEditor
Definition: pcb_actions.h:387
int GetToolId() const
Definition: draw_frame.h:519
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Function OnlyType Creates a functor that tests if the selected items are only of given type...
static TOOL_ACTION positionRelative
Activation of the position relative tool.
Definition: pcb_actions.h:254
static TOOL_ACTION remove
Deleting a BOARD_ITEM.
Definition: pcb_actions.h:132
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
bool EDIT_TOOL::invokeInlineRouter ( int  aDragMode)
private

Definition at line 295 of file edit_tool.cpp.

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

Referenced by Drag(), and Main().

296 {
297  auto theRouter = static_cast<ROUTER_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveRouter" ) );
298 
299  if( !theRouter )
300  return false;
301 
302  // make sure we don't accidentally invoke inline routing mode while the router is already active!
303  if( theRouter->IsToolActive() )
304  return false;
305 
306  if( theRouter->CanInlineDrag() )
307  {
309  return true;
310  }
311 
312  return false;
313 }
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:218
static ROUTER * theRouter
Definition: pns_router.cpp:59
bool EDIT_TOOL::isInteractiveDragEnabled ( ) const
private

Definition at line 316 of file edit_tool.cpp.

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

Referenced by Main().

317 {
318  auto theRouter = static_cast<ROUTER_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveRouter" ) );
319 
320  return theRouter ? theRouter->Router()->Settings().InlineDragEnabled() : false;
321 }
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
static ROUTER * theRouter
Definition: pns_router.cpp:59
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:187
bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

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

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

Function Main()

Main loop in which events are handled.

Parameters
aEventis the handled event.

Definition at line 336 of file edit_tool.cpp.

References TOOL_INTERACTIVE::Activate(), GRID_HELPER::Align(), GRID_HELPER::BestDragOrigin(), GRID_HELPER::BestSnapAnchor(), BUT_LEFT, SELECTION_TOOL::CheckLock(), PCB_TOOL::controls(), delta, PNS::DM_ANY, PCB_ACTIONS::duplicate, PCB_ACTIONS::editActivate, PCB_TOOL::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED, EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL::frame(), SELECTION::Front(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW_CONTROLS::GetMousePosition(), BOARD_ITEM::GetPosition(), TOOL_BASE::getViewControls(), i, invokeInlineRouter(), SELECTION::IsHover(), isInteractiveDragEnabled(), m_commit, m_cursor, m_dragging, m_selectionTool, TOOL_BASE::m_toolMgr, MD_ALT, MD_SHIFT, PCB_ACTIONS::move, PCB_ACTIONS::moveExact, PCB_ACTIONS::remove, SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_TOOL::selection(), SELECTION_LOCKED, PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionModified, KIGFX::VIEW_CONTROLS::SetAutoPan(), GRID_HELPER::SetAuxAxes(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), BOARD_ITEM::SetPosition(), GRID_HELPER::SetSnap(), KIGFX::VIEW_CONTROLS::SetSnapping(), GRID_HELPER::SetUseGrid(), KIGFX::VIEW_CONTROLS::ShowCursor(), TA_UNDO_REDO_PRE, TC_COMMAND, TC_MOUSE, PCB_BASE_EDIT_FRAME::UndoRedoBlock(), updateModificationPoint(), PCB_BASE_FRAME::UpdateMsgPanel(), and TOOL_INTERACTIVE::Wait().

Referenced by Duplicate(), and setTransitions().

337 {
339  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
340  VECTOR2I originalCursorPos = controls->GetCursorPosition();
341 
342  // Be sure that there is at least one item that we can modify. If nothing was selected before,
343  // try looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection)
345  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
347 
348  if( m_dragging || selection.Empty() )
349  return 0;
350 
351  LSET item_layers = static_cast<BOARD_ITEM*>( selection.Front() )->GetLayerSet();
352  bool unselect = selection.IsHover(); //N.B. This must be saved before the re-selection below
353 
354  // Filter out locked pads here
355  // We cannot do this in the selection filter as we need the pad layers
356  // when it is the curr_item.
358  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
360 
361  if( selection.Empty() )
362  return 0;
363 
364  Activate();
365  controls->ShowCursor( true );
366  controls->SetAutoPan( true );
367 
368  auto curr_item = static_cast<BOARD_ITEM*>( selection.Front() );
369  std::vector<BOARD_ITEM*> sel_items;
370 
371  for( auto it : selection )
372  {
373  auto item = dynamic_cast<BOARD_ITEM*>( it );
374 
375  if( item )
376  sel_items.push_back( item );
377  }
378 
379  bool restore_state = false;
380  VECTOR2I totalMovement;
381  GRID_HELPER grid( editFrame );
382  OPT_TOOL_EVENT evt = aEvent;
383  VECTOR2I prevPos;
384 
385  // Main loop: keep receiving events
386  do
387  {
388  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
389  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
390  controls->SetSnapping( !evt->Modifier( MD_ALT ) );
391 
392  if( evt->IsAction( &PCB_ACTIONS::editActivate ) ||
393  evt->IsAction( &PCB_ACTIONS::move ) ||
394  evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
395  {
396  if( m_dragging && evt->Category() == TC_MOUSE )
397  {
398  m_cursor = grid.BestSnapAnchor( controls->GetMousePosition(),
399  item_layers, sel_items );
400  controls->ForceCursorPosition(true, m_cursor );
401  VECTOR2I movement( m_cursor - prevPos );
402  selection.SetReferencePoint( m_cursor );
403 
404  totalMovement += movement;
405  prevPos = m_cursor;
406 
407  // Drag items to the current cursor position
408  for( auto item : selection )
409  {
410  // Don't double move footprint pads, fields, etc.
411  if( item->GetParent() && item->GetParent()->IsSelected() )
412  continue;
413 
414  static_cast<BOARD_ITEM*>( item )->Move( movement );
415  }
416 
417  frame()->UpdateMsgPanel();
418  }
419  else if( !m_dragging ) // Prepare to start dragging
420  {
421  bool invokedRouter = false;
422 
423  if ( !evt->IsAction( &PCB_ACTIONS::move ) && isInteractiveDragEnabled() )
424  invokedRouter = invokeInlineRouter( PNS::DM_ANY );
425 
426  if( !invokedRouter )
427  {
428  // deal with locked items (override lock or abort the operation)
430 
431  if( lockFlags == SELECTION_LOCKED )
432  break;
433 
434  // When editing modules, all items have the same parent
435  if( EditingModules() )
436  {
437  m_commit->Modify( selection.Front() );
438  }
439  else
440  {
441  // Save items, so changes can be undone
442  for( auto item : selection )
443  {
444  // Don't double move footprint pads, fields, etc.
445  if( item->GetParent() && item->GetParent()->IsSelected() )
446  continue;
447 
448  m_commit->Modify( item );
449  }
450  }
451 
452  editFrame->UndoRedoBlock( true );
453  m_cursor = controls->GetCursorPosition();
454 
455  if ( selection.HasReferencePoint() )
456  {
457  // start moving with the reference point attached to the cursor
458  grid.SetAuxAxes( false );
459 
460  auto delta = m_cursor - selection.GetReferencePoint();
461 
462  // Drag items to the current cursor position
463  for( auto item : selection )
464  {
465  // Don't double move footprint pads, fields, etc.
466  if( item->GetParent() && item->GetParent()->IsSelected() )
467  continue;
468 
469  static_cast<BOARD_ITEM*>( item )->Move( delta );
470  }
471 
472  selection.SetReferencePoint( m_cursor );
473  }
474  else if( selection.Size() == 1 )
475  {
476  // Set the current cursor position to the first dragged item origin, so the
477  // movement vector could be computed later
478  updateModificationPoint( selection );
479  m_cursor = grid.BestDragOrigin( originalCursorPos, curr_item );
480  grid.SetAuxAxes( true, m_cursor );
481  }
482  else
483  {
484  updateModificationPoint( selection );
485  m_cursor = grid.Align( m_cursor );
486  }
487 
488  controls->SetCursorPosition( m_cursor, false );
489 
490  prevPos = m_cursor;
491  controls->SetAutoPan( true );
492  m_dragging = true;
493  }
494  }
495 
497  }
498 
499  else if( evt->IsCancel() || evt->IsActivate() )
500  {
501  restore_state = true; // Canceling the tool means that items have to be restored
502  break; // Finish
503  }
504 
505  else if( evt->Action() == TA_UNDO_REDO_PRE )
506  {
507  unselect = true;
508  break;
509  }
510 
511  // Dispatch TOOL_ACTIONs
512  else if( evt->Category() == TC_COMMAND )
513  {
514  if( evt->IsAction( &PCB_ACTIONS::remove ) )
515  {
516  // exit the loop, as there is no further processing for removed items
517  break;
518  }
519  else if( evt->IsAction( &PCB_ACTIONS::duplicate ) )
520  {
521  // On duplicate, stop moving this item
522  // The duplicate tool should then select the new item and start
523  // a new move procedure
524  break;
525  }
526  else if( evt->IsAction( &PCB_ACTIONS::moveExact ) )
527  {
528  // Can't do this, because the selection will then contain
529  // stale pointers and it will all go horribly wrong...
530  //editFrame->RestoreCopyFromUndoList( dummy );
531  //
532  // So, instead, reset the position manually
533  for( auto item : selection )
534  {
535  BOARD_ITEM* i = static_cast<BOARD_ITEM*>( item );
536  auto delta = VECTOR2I( i->GetPosition() ) - totalMovement;
537  i->SetPosition( wxPoint( delta.x, delta.y ) );
538 
539  // And what about flipping and rotation?
540  // for now, they won't be undone, but maybe that is how
541  // it should be, so you can flip and move exact in the
542  // same action?
543  }
544 
545  // This causes a double event, so we will get the dialogue
546  // correctly, somehow - why does Rotate not?
547  //MoveExact( aEvent );
548  break; // exit the loop - we move exactly, so we have finished moving
549  }
550  }
551 
552  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
553  {
554  break; // Finish
555  }
556  } while( ( evt = Wait() ) ); //Should be assignment not equality test
557 
558  controls->ForceCursorPosition( false );
559  controls->ShowCursor( false );
560  controls->SetSnapping( false );
561  controls->SetAutoPan( false );
562 
563  m_dragging = false;
564  editFrame->UndoRedoBlock( false );
565 
566  // Discard reference point when selection is "dropped" onto the board (ie: not dragging anymore)
567  selection.ClearReferencePoint();
568 
569  if( unselect || restore_state )
571 
572  if( restore_state )
573  m_commit->Revert();
574  else
575  m_commit->Push( _( "Drag" ) );
576 
577  return 0;
578 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
VECTOR2I m_cursor
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point)...
Definition: edit_tool.h:198
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:116
static TOOL_ACTION move
move an item
Definition: pcb_actions.h:96
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Function RequestSelection()
static TOOL_ACTION editActivate
Activation of the edit tool.
Definition: pcb_actions.h:93
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
virtual void SetPosition(const wxPoint &aPos)=0
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:212
SELECTION_LOCK_FLAGS CheckLock()
Checks if the user has agreed to modify locked items for the given selection.
bool updateModificationPoint(SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1326
EDA_ITEM * Front() const
Definition: selection.h:152
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
static const int delta[8][2]
Definition: solve.cpp:112
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:114
static TOOL_ACTION moveExact
Activation of the exact move tool.
Definition: pcb_actions.h:117
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves cursor to the requested position expressed in world coordinates.
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:138
static TOOL_ACTION duplicate
Activation of the duplication tool.
Definition: pcb_actions.h:120
Class LSET is a set of PCB_LAYER_IDs.
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:194
SELECTION_LOCK_FLAGS
Definition: selection.h:229
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
bool isInteractiveDragEnabled() const
Definition: edit_tool.cpp:316
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:47
virtual const wxPoint GetPosition() const =0
bool EditingModules() const
Definition: pcb_tool.h:102
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:295
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:242
size_t i
Definition: json11.cpp:597
bool IsHover() const
Definition: selection.h:69
void Activate()
Function Activate() Runs the tool.
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:45
static TOOL_ACTION remove
Deleting a BOARD_ITEM.
Definition: pcb_actions.h:132
void UpdateMsgPanel() override
>
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:46
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
int EDIT_TOOL::MeasureTool ( const TOOL_EVENT aEvent)

Launches a tool to measure between points

Definition at line 1203 of file edit_tool.cpp.

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

Referenced by setTransitions().

1204 {
1205  if( EditingModules() && !frame()->GetModel())
1206  return 0;
1207 
1208  auto& view = *getView();
1209  auto& controls = *getViewControls();
1211 
1212  Activate();
1213  frame()->SetToolID( toolID, wxCURSOR_PENCIL, _( "Measure distance" ) );
1214 
1215  EDA_UNITS_T units = frame()->GetUserUnits();
1217  KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, units );
1218 
1219  view.Add( &ruler );
1220  view.SetVisible( &ruler, false );
1221 
1222  GRID_HELPER grid( frame() );
1223 
1224  bool originSet = false;
1225 
1226  controls.ShowCursor( true );
1227  controls.SetAutoPan( false );
1228 
1229  while( auto evt = Wait() )
1230  {
1231  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1232  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1233  controls.SetSnapping( !evt->Modifier( MD_ALT ) );
1234  const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr );
1235  controls.ForceCursorPosition(true, cursorPos );
1236 
1237  if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
1238  {
1239  break;
1240  }
1241 
1242  // click or drag starts
1243  else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
1244  {
1245  twoPtMgr.SetOrigin( cursorPos );
1246  twoPtMgr.SetEnd( cursorPos );
1247 
1248  controls.CaptureCursor( true );
1249  controls.SetAutoPan( true );
1250 
1251  originSet = true;
1252  }
1253 
1254  // second click or mouse up after drag ends
1255  else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
1256  {
1257  originSet = false;
1258 
1259  controls.SetAutoPan( false );
1260  controls.CaptureCursor( false );
1261  }
1262 
1263  // move or drag when origin set updates rules
1264  else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
1265  {
1266  twoPtMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) );
1267  twoPtMgr.SetEnd( cursorPos );
1268 
1269  view.SetVisible( &ruler, true );
1270  view.Update( &ruler, KIGFX::GEOMETRY );
1271  }
1272 
1273  else if( evt->IsAction( &PCB_ACTIONS::switchUnits )
1274  || evt->IsAction( &PCB_ACTIONS::updateUnits ) )
1275  {
1276  if( frame()->GetUserUnits() != units )
1277  {
1278  units = frame()->GetUserUnits();
1279  ruler.SwitchUnits();
1280  view.Update( &ruler, KIGFX::GEOMETRY );
1281  }
1282  }
1283 
1284  else if( evt->IsClick( BUT_RIGHT ) )
1285  {
1287  }
1288  }
1289 
1290  view.SetVisible( &ruler, false );
1291  view.Remove( &ruler );
1292 
1293  frame()->SetNoToolSelected();
1294 
1295  return 0;
1296 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:81
Class TWO_POINT_GEOMETRY_MANAGER.
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
static TOOL_ACTION updateUnits
Definition: pcb_actions.h:368
static TOOL_ACTION switchUnits
Definition: pcb_actions.h:367
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:64
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:138
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
void SetOrigin(const VECTOR2I &aOrigin)
Set the origin of the ruler (the fixed end)
Class RULER_ITEM.
Definition: ruler_item.h:43
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
ID_MODEDIT_MEASUREMENT_TOOL
bool EditingModules() const
Definition: pcb_tool.h:102
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:137
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1467
void Activate()
Function Activate() Runs the tool.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:48
SGLIB_API S3DMODEL * GetModel(SCENEGRAPH *aNode)
Function GetModel creates an S3DMODEL representation of aNode (raw data, no transforms) ...
Definition: ifsg_api.cpp:471
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
EDA_UNITS_T
Definition: common.h:159
void SetEnd(const VECTOR2I &aEnd)
Set the current end of the rectangle (the end that moves with the cursor.
Color has changed.
Definition: view_item.h:57
int EDIT_TOOL::Mirror ( const TOOL_EVENT aEvent)

Function Mirror.

Mirrors the current selection. The mirror axis passes through the current point.

Definition at line 741 of file edit_tool.cpp.

References PCB_TOOL::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED, EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, SELECTION::Front(), SELECTION::GetReferencePoint(), m_commit, m_dragging, m_selectionTool, TOOL_BASE::m_toolMgr, EDGE_MODULE::Mirror(), TEXTE_MODULE::Mirror(), mirrorPadX(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, PCB_PAD_T, SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_TOOL::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionModified, and updateModificationPoint().

Referenced by setTransitions().

742 {
744  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
746 
747  if( selection.Empty() )
748  return 0;
749 
751  auto refPoint = selection.GetReferencePoint();
752  wxPoint mirrorPoint( refPoint.x, refPoint.y );
753 
754  // When editing modules, all items have the same parent
755  if( EditingModules() )
756  {
757  m_commit->Modify( selection.Front() );
758  }
759 
760  for( auto item : selection )
761  {
762  // only modify items we can mirror
763  switch( item->Type() )
764  {
765  case PCB_MODULE_EDGE_T:
766  case PCB_MODULE_TEXT_T:
767  case PCB_PAD_T:
768  // Only create undo entry for items on the board
769  if( !item->IsNew() && !EditingModules() )
770  m_commit->Modify( item );
771 
772  break;
773  default:
774  continue;
775  }
776 
777  // modify each object as necessary
778  switch( item->Type() )
779  {
780  case PCB_MODULE_EDGE_T:
781  {
782  auto& edge = static_cast<EDGE_MODULE&>( *item );
783  edge.Mirror( mirrorPoint, false );
784  break;
785  }
786 
787  case PCB_MODULE_TEXT_T:
788  {
789  auto& modText = static_cast<TEXTE_MODULE&>( *item );
790  modText.Mirror( mirrorPoint, false );
791  break;
792  }
793 
794  case PCB_PAD_T:
795  {
796  auto& pad = static_cast<D_PAD&>( *item );
797  mirrorPadX( pad, mirrorPoint );
798  break;
799  }
800 
801  default:
802  // it's likely the commit object is wrong if you get here
803  assert( false );
804  break;
805  }
806  }
807 
808  if( !m_dragging )
809  m_commit->Push( _( "Mirror" ) );
810 
811  if( selection.IsHover() && !m_dragging )
813 
815 
816  return 0;
817 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:116
VECTOR2I GetReferencePoint() const
Definition: selection.h:200
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Function RequestSelection()
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:212
bool updateModificationPoint(SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1326
EDA_ITEM * Front() const
Definition: selection.h:152
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:114
void Mirror(const wxPoint aCentre, bool aMirrorAroundXAxis)
Mirror an edge of the footprint.
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:194
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:47
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
bool EditingModules() const
Definition: pcb_tool.h:102
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:242
void Mirror(const wxPoint &aCentre, bool aMirrorAroundXAxis)
Mirror text position in footprint editing the text itself is not mirrored, and the layer not modified...
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:45
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:46
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173
static void mirrorPadX(D_PAD &aPad, const wxPoint &aMirrorPoint)
Mirror a pad in the vertical axis passing through a point.
Definition: edit_tool.cpp:721
int EDIT_TOOL::MoveExact ( const TOOL_EVENT aEvent)

Function MoveExact()

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

Definition at line 926 of file edit_tool.cpp.

References PCB_TOOL::EditingModules(), EditToolSelectionFilter(), SELECTION::Empty(), EXCLUDE_LOCKED, EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, SELECTION::Front(), PCB_BASE_FRAME::GetAuxOrigin(), SELECTION::GetCenter(), BOARD_ITEM::GetPosition(), PCB_BASE_FRAME::GetScreen(), TOOL_BASE::getView(), EDA_ITEM::IsNew(), m_commit, m_dragging, BASE_SCREEN::m_O_Curseur, m_selectionTool, TOOL_BASE::m_toolMgr, BOARD_ITEM::Move(), 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(), PCB_TOOL::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionModified, SELECTION::Size(), KIGFX::VIEW::Update(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

927 {
929  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
931 
932  if( selection.Empty() )
933  return 0;
934 
935  PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
936  wxPoint translation;
937  double rotation;
938  ROTATION_ANCHOR rotationAnchor = selection.Size() > 1 ? ROTATE_AROUND_SEL_CENTER
940 
941  DIALOG_MOVE_EXACT dialog( editFrame, translation, rotation, rotationAnchor );
942  int ret = dialog.ShowModal();
943 
944  if( ret == wxID_OK )
945  {
947  wxPoint selCenter( rp.x, rp.y );
948 
949  // Make sure the rotation is from the right reference point
950  selCenter += translation;
951 
952  // When editing modules, all items have the same parent
953  if( EditingModules() )
954  {
955  m_commit->Modify( selection.Front() );
956  }
957 
958  for( auto selItem : selection )
959  {
960  BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( selItem );
961 
962  if( !item->IsNew() && !EditingModules() )
963  m_commit->Modify( item );
964 
965  item->Move( translation );
966 
967  switch( rotationAnchor )
968  {
970  item->Rotate( item->GetPosition(), rotation );
971  break;
973  item->Rotate( selCenter, rotation );
974  break;
976  item->Rotate( editFrame->GetScreen()->m_O_Curseur, rotation );
977  break;
979  item->Rotate( editFrame->GetAuxOrigin(), rotation );
980  break;
981  }
982 
983  if( !m_dragging )
984  getView()->Update( item );
985  }
986 
987  m_commit->Push( _( "Move exact" ) );
988 
989  if( selection.IsHover() )
991 
993  }
994 
995  return 0;
996 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:116
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Function RequestSelection()
bool IsNew() const
Definition: base_struct.h:219
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:212
EDA_ITEM * Front() const
Definition: selection.h:152
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:114
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:194
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
virtual void Rotate(const wxPoint &aRotCentre, double aAngle)
Function Rotate Rotate this object.
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1521
ROTATION_ANCHOR
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:47
virtual const wxPoint GetPosition() const =0
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
bool EditingModules() const
Definition: pcb_tool.h:102
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:242
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
int Size() const
Returns the number of selected parts.
Definition: selection.h:122
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:45
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:46
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173
VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.cpp:67
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
bool EDIT_TOOL::pickCopyReferencePoint ( VECTOR2I aP)
private

Definition at line 1386 of file edit_tool.cpp.

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

Referenced by doCopyToClipboard().

1387 {
1388  STATUS_TEXT_POPUP statusPopup( frame() );
1389  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1390  bool picking = true;
1391  bool retVal = true;
1392 
1393  statusPopup.SetText( _( "Select reference point for the copy..." ) );
1394  picker->Activate();
1395  picker->SetClickHandler( [&]( const VECTOR2D& aPoint ) -> bool
1396  {
1397  aP = aPoint;
1398  statusPopup.SetText( _( "Selection copied." ) );
1399  statusPopup.Expire( 800 );
1400  picking = false;
1401  return false; // we don't need any more points
1402  } );
1403  picker->SetCancelHandler( [&]()
1404  {
1405  statusPopup.SetText( _( "Copy cancelled." ) );
1406  statusPopup.Expire( 800 );
1407  picking = false;
1408  retVal = false;
1409  } );
1410 
1411  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
1412  statusPopup.Popup();
1413 
1414  while( picking )
1415  {
1416  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
1417  Wait();
1418  }
1419 
1420  statusPopup.Hide();
1421  return retVal;
1422 }
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:85
Class STATUS_TEXT_POPUP.
Definition: status_popup.h:77
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Generic tool for picking a point.
Definition: picker_tool.h:34
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
void SetCancelHandler(CANCEL_HANDLER aHandler)
Function SetCancelHandler() Sets a handler for cancel events (ESC or context-menu Cancel)...
Definition: picker_tool.h:95
void Activate()
Function Activate() Runs the tool.
int EDIT_TOOL::Properties ( const TOOL_EVENT aEvent)

Function Edit()

Displays properties window for the selected object.

Definition at line 621 of file edit_tool.cpp.

References changeTrackWidthOnClick(), EditToolSelectionFilter(), EXCLUDE_TRANSIENTS, m_commit, m_selectionTool, TOOL_BASE::m_toolMgr, PCB_BASE_EDIT_FRAME::OnEditItemRequest(), SELECTION_CONDITIONS::OnlyTypes(), SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_TOOL::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionModified, DIALOG_SHIM::ShowQuasiModal(), and GENERAL_COLLECTOR::Tracks.

Referenced by setTransitions().

622 {
623  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
624 
626  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
627  { EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } );
628 
629  // Tracks & vias are treated in a special way:
631  {
632  if ( !changeTrackWidthOnClick( selection ) )
633  {
634  DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection, *m_commit );
635  dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR
636  }
637  }
638  else if( selection.Size() == 1 ) // Properties are displayed when there is only one item selected
639  {
640  // Display properties dialog
641  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
642 
643  // Do not handle undo buffer, it is done by the properties dialogs @todo LEGACY
644  // Display properties dialog provided by the legacy canvas frame
645  editFrame->OnEditItemRequest( NULL, item );
646 
647  // Notify other tools of the changes
649  }
650 
651  if( selection.IsHover() )
652  {
654 
655  // Notify other tools of the changes -- This updates the visual ratsnest
657  }
658 
659  return 0;
660 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Function RequestSelection()
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:315
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:212
virtual void OnEditItemRequest(wxDC *aDC, BOARD_ITEM *aItem)=0
Function OnEditItemRequest Install the corresponding dialog editor for the given item.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:114
static SELECTION_CONDITION OnlyTypes(const std::vector< KICAD_T > &aTypes)
Function OnlyTypes Creates a functor that tests if the selected items are only of given types...
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:47
bool changeTrackWidthOnClick(const SELECTION &selection)
Definition: edit_tool.cpp:580
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:242
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173
int EDIT_TOOL::Remove ( const TOOL_EVENT aEvent)

Function Remove()

Deletes currently selected items. The rotation point is the current cursor position.

Definition at line 858 of file edit_tool.cpp.

References ACTIONS::ALT, EditToolSelectionFilter(), EXCLUDE_LOCKED, EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, PCB_ACTIONS::expandSelectedConnection, TOOL_MANAGER::FindTool(), SELECTION_TOOL::GetSelection(), TOOL_BASE::getView(), m_commit, PCB_TOOL::m_editModules, m_selectionTool, TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), PCB_MODULE_TEXT_T, PCB_TRACE_T, PCB_VIA_T, KIGFX::VIEW::Remove(), SELECTION_TOOL::RequestSelection(), PNS::TOOL_BASE::Router(), PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, and TEXTE_MODULE::TEXT_is_DIVERS.

Referenced by cutToClipboard(), and setTransitions().

859 {
860  ROUTER_TOOL* routerTool = static_cast<ROUTER_TOOL*>
861  ( m_toolMgr->FindTool( "pcbnew.InteractiveRouter" ) );
862 
863  // Do not delete items while actively routing.
864  if( routerTool && routerTool->Router() && routerTool->Router()->RoutingInProgress() )
865  return 0;
866 
867  // get a copy instead of reference (as we're going to clear the selection before removing items)
868  auto selectionCopy = m_selectionTool->RequestSelection(
869  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
871 
872  // is this "alternative" remove?
873  const bool isAlt = aEvent.Parameter<intptr_t>() == (int) PCB_ACTIONS::REMOVE_FLAGS::ALT;
874 
875  // in "alternative" mode, deletion is not just a simple list of selected items,
876  // it removes whole tracks, not just segments
877  if( isAlt && selectionCopy.IsHover()
878  && ( selectionCopy.HasType( PCB_TRACE_T ) || selectionCopy.HasType( PCB_VIA_T ) ) )
879  {
881  selectionCopy = m_selectionTool->GetSelection();
882  }
883 
884  if( selectionCopy.Empty() )
885  return 0;
886 
887  // As we are about to remove items, they have to be removed from the selection first
889 
890  for( auto item : selectionCopy )
891  {
892  if( m_editModules )
893  {
894  m_commit->Remove( item );
895  continue;
896  }
897 
898  switch( item->Type() )
899  {
900  case PCB_MODULE_TEXT_T:
901  {
902  auto text = static_cast<TEXTE_MODULE*>( item );
903  auto parent = static_cast<MODULE*>( item->GetParent() );
904 
905  if( text->GetType() == TEXTE_MODULE::TEXT_is_DIVERS )
906  {
907  m_commit->Modify( text );
908  getView()->Remove( text );
909  parent->Remove( text );
910  }
911  }
912  break;
913 
914  default:
915  m_commit->Remove( item );
916  break;
917  }
918  }
919 
920  m_commit->Push( _( "Delete" ) );
921 
922  return 0;
923 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
if(dlg.ShowModal()==wxID_OK)
Definition: selcolor.cpp:76
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Function RequestSelection()
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:212
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:365
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
bool RoutingInProgress() const
Definition: pns_router.cpp:112
SELECTION & GetSelection()
Function GetSelection()
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:47
bool m_editModules
Definition: pcb_tool.h:150
static TOOL_ACTION expandSelectedConnection
Expands the current selection to select a connection between two junctions.
Definition: pcb_actions.h:74
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:387
Class PCB_ACTIONS.
Definition: pcb_actions.h:42
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:242
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:45
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:46
ROUTER * Router() const
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173
void EDIT_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

Function Reset() Brings the tool to a known, initial state.

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

Parameters
aReasoncontains information about the reason of tool reset.

Reimplemented from PCB_TOOL.

Definition at line 221 of file edit_tool.cpp.

References m_commit, m_dragging, and TOOL_BASE::RUN.

222 {
223  m_dragging = false;
224 
225  if( aReason != RUN )
226  m_commit.reset( new BOARD_COMMIT( this ) );
227 }
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:212
Tool is invoked after being inactive.
Definition: tool_base.h:82
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:194
int EDIT_TOOL::Rotate ( const TOOL_EVENT aEvent)

Function Rotate()

Rotates currently selected items.

Definition at line 663 of file edit_tool.cpp.

References PCB_TOOL::EditingModules(), EditToolSelectionFilter(), EXCLUDE_LOCKED, EXCLUDE_LOCKED_PADS, EXCLUDE_TRANSIENTS, TOOL_EVT_UTILS::GetEventRotationAngle(), m_commit, m_dragging, m_selectionTool, TOOL_BASE::m_toolMgr, SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_TOOL::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionModified, and updateModificationPoint().

Referenced by setTransitions().

664 {
665  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
666 
668  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
670 
671  if( selection.Empty() )
672  return 0;
673 
674  updateModificationPoint( selection );
675  const int rotateAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *editFrame, aEvent );
676 
677  // When editing modules, all items have the same parent
678  if( EditingModules() )
679  {
680  m_commit->Modify( selection.Front() );
681  }
682 
683  for( auto item : selection )
684  {
685  if( !item->IsNew() && !EditingModules() )
686  m_commit->Modify( item );
687 
688  static_cast<BOARD_ITEM*>( item )->Rotate( selection.GetReferencePoint(), rotateAngle );
689  }
690 
691  if( !m_dragging )
692  m_commit->Push( _( "Rotate" ) );
693 
694  if( selection.IsHover() && !m_dragging )
696 
698 
699  return 0;
700 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
int Rotate(const TOOL_EVENT &aEvent)
Function Rotate()
Definition: edit_tool.cpp:663
SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Function RequestSelection()
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:212
bool updateModificationPoint(SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1326
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:191
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:114
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:194
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
#define EXCLUDE_TRANSIENTS
Definition: edit_tool.h:47
bool EditingModules() const
Definition: pcb_tool.h:102
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:242
#define EXCLUDE_LOCKED
Function EditToolSelectionFilter.
Definition: edit_tool.h:45
#define EXCLUDE_LOCKED_PADS
Definition: edit_tool.h:46
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173
void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 85 of file tool_interactive.cpp.

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

Referenced by DRAWING_TOOL::PlaceText().

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
const SELECTION & PCB_TOOL::selection ( ) const
protectedinherited

Definition at line 245 of file pcb_tool.cpp.

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

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

246 {
247  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
248  const auto& selection = selTool->GetSelection();
249  return selection;
250 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
SELECTION & PCB_TOOL::selection ( )
protectedinherited

Definition at line 252 of file pcb_tool.cpp.

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

253 {
254  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
255  auto& selection = selTool->GetSelection();
256  return selection;
257 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Function SetContextMenu()

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

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

Definition at line 74 of file tool_interactive.cpp.

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

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

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

Function SetEditModules()

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

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 97 of file pcb_tool.h.

98  {
99  m_editModules = aEnabled;
100  }
bool m_editModules
Definition: pcb_tool.h:150
void EDIT_TOOL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL.

Definition at line 1299 of file edit_tool.cpp.

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

1300 {
1301  Go( &EDIT_TOOL::Main, PCB_ACTIONS::editActivate.MakeEvent() );
1302  Go( &EDIT_TOOL::Main, PCB_ACTIONS::move.MakeEvent() );
1303  Go( &EDIT_TOOL::Drag, PCB_ACTIONS::drag45Degree.MakeEvent() );
1305  Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCw.MakeEvent() );
1306  Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCcw.MakeEvent() );
1307  Go( &EDIT_TOOL::Flip, PCB_ACTIONS::flip.MakeEvent() );
1308  Go( &EDIT_TOOL::Remove, PCB_ACTIONS::remove.MakeEvent() );
1309  Go( &EDIT_TOOL::Remove, PCB_ACTIONS::removeAlt.MakeEvent() );
1315  Go( &EDIT_TOOL::Mirror, PCB_ACTIONS::mirror.MakeEvent() );
1316 
1323 }
int Main(const TOOL_EVENT &aEvent)
Function Main()
Definition: edit_tool.cpp:336
int Properties(const TOOL_EVENT &aEvent)
Function Edit()
Definition: edit_tool.cpp:621
int Rotate(const TOOL_EVENT &aEvent)
Function Rotate()
Definition: edit_tool.cpp:663
static TOOL_ACTION move
move an item
Definition: pcb_actions.h:96
int ExchangeFootprints(const TOOL_EVENT &aEvent)
Function ExchangeFootprints()
Definition: edit_tool.cpp:1179
static TOOL_ACTION editActivate
Activation of the edit tool.
Definition: pcb_actions.h:93
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:137
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:111
static TOOL_ACTION removeAlt
Definition: pcb_actions.h:133
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:136
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:108
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int Mirror(const TOOL_EVENT &aEvent)
Function Mirror.
Definition: edit_tool.cpp:741
static TOOL_ACTION moveExact
Activation of the exact move tool.
Definition: pcb_actions.h:117
int cutToClipboard(const TOOL_EVENT &aEvent)
Function cutToClipboard() Cuts the current selection to the clipboard by formatting it as a fake pcb ...
Definition: edit_tool.cpp:1469
static TOOL_ACTION duplicate
Activation of the duplication tool.
Definition: pcb_actions.h:120
int Flip(const TOOL_EVENT &aEvent)
Function Flip()
Definition: edit_tool.cpp:820
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
Definition: pcb_actions.h:123
static TOOL_ACTION rotateCw
Rotation of selected objects clockwise.
Definition: pcb_actions.h:99
static TOOL_ACTION createArray
Tool for creating an array of objects.
Definition: pcb_actions.h:318
int Drag(const TOOL_EVENT &aEvent)
Function Drag()
Definition: edit_tool.cpp:324
static TOOL_ACTION exchangeFootprints
Exchange footprints of modules.
Definition: pcb_actions.h:129
static TOOL_ACTION cutToClipboard
Paste from clipboard.
Definition: pcb_actions.h:327
static TOOL_ACTION copyToClipboard
Copy selected items to clipboard.
Definition: pcb_actions.h:321
static TOOL_ACTION updateFootprints
Update footprints to reflect any changes in the library.
Definition: pcb_actions.h:126
static TOOL_ACTION rotateCcw
Rotation of selected objects counter-clockwise.
Definition: pcb_actions.h:102
int MoveExact(const TOOL_EVENT &aEvent)
Function MoveExact()
Definition: edit_tool.cpp:926
int Remove(const TOOL_EVENT &aEvent)
Function Remove()
Definition: edit_tool.cpp:858
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:105
int CreateArray(const TOOL_EVENT &aEvent)
Function CreateArray()
Definition: edit_tool.cpp:1149
int MeasureTool(const TOOL_EVENT &aEvent)
Launches a tool to measure between points
Definition: edit_tool.cpp:1203
static TOOL_ACTION editFootprintInFpEditor
Definition: pcb_actions.h:387
int editFootprintInFpEditor(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:1349
int copyToClipboard(const TOOL_EVENT &aEvent)
Function copyToClipboard() Sends the current selection to the clipboard by formatting it as a fake pc...
Definition: edit_tool.cpp:1457
static TOOL_ACTION remove
Deleting a BOARD_ITEM.
Definition: pcb_actions.h:132
int Duplicate(const TOOL_EVENT &aEvent)
Function Duplicate()
Definition: edit_tool.cpp:999
static TOOL_ACTION measureTool
Definition: pcb_actions.h:365
bool EDIT_TOOL::updateModificationPoint ( SELECTION aSelection)
private

Returns the right modification point (e.g.

for rotation), depending on the number of

selected items.

Definition at line 1326 of file edit_tool.cpp.

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

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

1327 {
1328  if( m_dragging && aSelection.HasReferencePoint() )
1329  return false;
1330 
1331  // When there is only one item selected, the reference point is its position...
1332  if( aSelection.Size() == 1 )
1333  {
1334  auto item = static_cast<BOARD_ITEM*>( aSelection.Front() );
1335  auto pos = item->GetPosition();
1336  aSelection.SetReferencePoint( VECTOR2I( pos.x, pos.y ) );
1337  }
1338  // ...otherwise modify items with regard to the cursor position
1339  else
1340  {
1342  aSelection.SetReferencePoint( m_cursor );
1343  }
1344 
1345  return true;
1346 }
VECTOR2I m_cursor
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point)...
Definition: edit_tool.h:198
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
EDA_ITEM * Front() const
Definition: selection.h:152
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:205
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:194
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
virtual const wxPoint GetPosition() const =0
int Size() const
Returns the number of selected parts.
Definition: selection.h:122
bool HasReferencePoint() const
Definition: selection.h:195
OPT_TOOL_EVENT TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

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

Definition at line 55 of file tool_interactive.cpp.

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

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

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

Member Data Documentation

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

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

Definition at line 198 of file edit_tool.h.

Referenced by Main(), and updateModificationPoint().

bool EDIT_TOOL::m_dragging
private

Flag determining if anything is being dragged right now

Definition at line 194 of file edit_tool.h.

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

SELECTION_TOOL* EDIT_TOOL::m_selectionTool
private

Selection tool used for obtaining selected items

Definition at line 191 of file edit_tool.h.

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

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 210 of file tool_base.h.

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

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

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName

(eg. pcbnew.InteractiveSelection).

Definition at line 214 of file tool_base.h.

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 of file tool_base.h.

Referenced by TOOL_BASE::attachManager().

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 207 of file tool_base.h.


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